当前位置: 首页>>代码示例>>C++>>正文


C++ Contour::AddPoint方法代码示例

本文整理汇总了C++中Contour::AddPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ Contour::AddPoint方法的具体用法?C++ Contour::AddPoint怎么用?C++ Contour::AddPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contour的用法示例。


在下文中一共展示了Contour::AddPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: msg

GUIButton::GUIButton(const Properties& properties) : mName(properties.mName), mPosition(properties.mPosition),
		mWidth(static_cast<float>(properties.mWidth)),
		mHeight(static_cast<float>(std::max(10u, properties.mHeight))),
		mTextOffset(properties.mTextOffset) {
	
	{ // create and setup the shapes and renderstring the represent the button
		// create the contour that represents both button shapes
		Contour contour;
		contour.AddPoints({glm::vec2(0.0f, 0.0f), glm::vec2(mWidth, 0.0f), glm::vec2(mWidth, mHeight - 10.0f)});
		contour.AddBezier({glm::vec2(mWidth, mHeight - 4.0f), glm::vec2(mWidth - 6.0f, mHeight - 4.0f)});
		contour.AddPoint(glm::vec2(6.0f, mHeight - 4.0f));
		contour.AddBezier({glm::vec2(0.0f, mHeight - 4.0f), glm::vec2(0.0f, mHeight - 10.0f)});
		
		mButtonTop.AddContour(contour);
		mButtonTop.SetOrigin(glm::vec2(0.0f, -2.0f)); // set the offset of the top button to be slightly higher than the base
		mButtonTop.SetColour(properties.mButtonColourTop);
		
		mButtonBottom.AddContour(contour);
		mButtonBottom.SetOrigin(glm::vec2(0.0f, -4.0f));
		mButtonBottom.SetColour(properties.mButtonColourBase);
		
		mButtonText.SetFont(properties.mFont);
		mButtonText.SetText(properties.mText);
		mButtonText.SetSize(properties.mTextSize);
		mButtonText.SetOrigin(glm::vec2(0.0f, -2.0f)); // set the offset of the button text to match the top button
		mButtonText.SetColour(properties.mTextColour);
	}
	
	SetPosition(properties.mPosition); // store the position of the button
	UpdateRenderState(1u); // update the button shapes and render string
	
	if (auto mSharedInputManagerPtr = GUI::mInputManagerPtr.lock()) { // if the input manager pointer is valid...
		// retrieve the current mouse cursor coordinates and update the button state depending on whether they
		// are within the button's bounding box or not
		auto mouseCoords = mSharedInputManagerPtr->GetMouseCoords(CoordinateSpace::Local);
		if (mouseCoords.x > mPosition.x && mouseCoords.x < mPosition.x + mWidth &&
				mouseCoords.y > mPosition.y && mouseCoords.y < mPosition.y + mHeight) {
			
			mInArea = true;
			UpdateRenderState(2u);
		}
	}
	
	{ // serialise the clicked message now as it won't change and we can reuse it
		std::stringstream strStream;
		ClickedMessage msg(mName);
		
		{
			// create an output archive using cereal and our stringstream and serialise the message
			cereal::BinaryOutputArchive archiveOutBinary(strStream);
			archiveOutBinary(msg);
		} // flush the archive on destruction
		
		mMessage = strStream.str(); // store the serialised string
	}
}
开发者ID:dakodun,项目名称:uair,代码行数:56,代码来源:guibutton.cpp


注:本文中的Contour::AddPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。