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


C++ Rect::InRect方法代码示例

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


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

示例1: drawScrollButton

bool Listbox::drawScrollButton(GL2DProgram * shaders,bool isTop) {
	Rect drawPos;
	Shape * triangleShape;
	vec4 drawColor;
	bool retValue = false;

	//First select values based off of button
	if (isTop) {
		triangleShape = &upShape;
		drawPos = Rect(position.Width-3-scrollButtonWidth,3,scrollButtonWidth,scrollButtonWidth);
	}
	else {
		triangleShape = &downShape;
		drawPos = Rect(position.Width-3-scrollButtonWidth,position.Height-3-scrollButtonWidth,scrollButtonWidth,scrollButtonWidth);
	}
	//Now select color based off of cursor status
	if (drawPos.InRect(lastMousePos)) {
		if (lastScrollUpdate != 0) {
			retValue = true;
			drawColor = highlightColor;
		}
		else
			drawColor = (highlightColor+barColor)/2.0;
	}
	else
		drawColor = barColor;

	//Calculate the triangle position
	Rect tPos = Rect(drawPos.Width*.25f,drawPos.Height*.25f,drawPos.Width*.5f,drawPos.Height*.5f);

	//Now draw the shape
	shaders->Model.PushMatrix();
	shaders->Model.Translate(drawPos.X,drawPos.Y,0);

	scrollPosShape.color = drawColor;
	scrollPosShape.OverrideCalculatedSize(drawPos);
	scrollPosShape.Draw(shaders);

	//Draw the triangle too
	shaders->Model.Translate(tPos.X,tPos.Y,0);
	triangleShape->color = shapeColor;
	triangleShape->OverrideCalculatedSize(tPos);
	triangleShape->Draw(shaders);

	shaders->Model.PopMatrix();

	return retValue;
}
开发者ID:mattbucci,项目名称:destruct-o,代码行数:48,代码来源:Listbox.cpp

示例2: drawScrollBar

void Listbox::drawScrollBar(GL2DProgram * shaders) {
	vec4 drawColor;
	Rect scrollBarLoc = calcScrollBarRect();
	//Is the user dragging the bar?
	if ((lastScrollUpdate != 0) && (lastScrollPos.x >= 0)) {
		//The bar is being dragged now
		drawColor = highlightColor;
		//Determine the new scrollPosition scrollPosition =
		float scrollBarMovement = (lastScrollPos.y-lastMousePos.y)/scrollBarRange();
		scrollPosition += scrollBarMovement*scrollRange();
		lastScrollPos.y = lastMousePos.y;

		//Limit scroll position
		SafeScrollPosition();

		//Since the scroll position moved, recalculate the bars position
		scrollBarLoc = calcScrollBarRect();
	}
	else if (scrollBarLoc.InRect(lastMousePos)) {
		if (lastScrollUpdate != 0) {
			//Just started dragging
			drawColor = highlightColor;
			lastScrollPos = lastMousePos;
		}
		else
			drawColor = (highlightColor+barColor)/2.0;
	}
	else
		drawColor = barColor;
	//Finally draw the bar
	shaders->Model.PushMatrix();
	shaders->Model.Translate(scrollBarLoc.X,scrollBarLoc.Y,0);

	scrollPosShape.color = drawColor;
	scrollPosShape.OverrideCalculatedSize(scrollBarLoc);
	scrollPosShape.Draw(shaders);

	shaders->Model.PopMatrix();
}
开发者ID:mattbucci,项目名称:destruct-o,代码行数:39,代码来源:Listbox.cpp


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