本文整理汇总了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;
}
示例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();
}