本文整理汇总了C++中Rect::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::GetPosition方法的具体用法?C++ Rect::GetPosition怎么用?C++ Rect::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::GetPosition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TranslatePoint
Vector2 LandscapeEditorDrawSystem::TranslatePoint(const Vector2& point, const Rect& fromRect, const Rect& toRect)
{
DVASSERT(fromRect.dx != 0.f && fromRect.dy != 0.f);
Vector2 origRectSize = fromRect.GetSize();
Vector2 destRectSize = toRect.GetSize();
Vector2 scale(destRectSize.x / origRectSize.x,
destRectSize.y / origRectSize.y);
Vector2 relPos = point - fromRect.GetPosition();
Vector2 newRelPos(relPos.x * scale.x,
relPos.y * scale.y);
Vector2 newPos = newRelPos + toRect.GetPosition();
return newPos;
}
示例2: TranslateRect
Rect LandscapeTestData::TranslateRect(const Rect &rect, const Rect& destPlane) const
{
DVASSERT(landscapeRect.dx != 0 && landscapeRect.dy !=0);
Vector2 origPlaneSize = landscapeRect.GetSize();
Vector2 destPlaneSize = destPlane.GetSize();
Vector2 scale(destPlaneSize.x / origPlaneSize.x,
destPlaneSize.y / origPlaneSize.y);
Vector2 relPos = rect.GetPosition() - landscapeRect.GetPosition();
Vector2 newRelPos(relPos.x * scale.x,
relPos.y * scale.y);
Vector2 newPos = newRelPos + destPlane.GetPosition();
Vector2 newSize(rect.GetSize().x * scale.x,
rect.GetSize().y * scale.y);
return Rect(newPos, newSize);
}
示例3: GetParentDelta
Vector2 HierarchyTreeControlNode::GetParentDelta(bool skipControl/* = false*/) const
{
Vector2 parentDelta(0, 0);
if (!skipControl && uiObject)
{
Rect rect = uiObject->GetRect();
parentDelta = rect.GetPosition();
}
const HierarchyTreeControlNode* parentControl = dynamic_cast<const HierarchyTreeControlNode* >(parent);
if (parentControl)
parentDelta += parentControl->GetParentDelta();
return parentDelta;
}
示例4: Input
void UIJoypad::Input(UIEvent *currentInput)
{
if((TOUCH_INVALID_ID == mainTouch) && currentInput->phase == UIEvent::PHASE_BEGAN)
{
mainTouch = currentInput->tid;
}
if(mainTouch != currentInput->tid)
{
return;
}
if(currentInput->phase == UIEvent::PHASE_ENDED)
{
currentPos.x = 0;
currentPos.y = 0;
mainTouch = TOUCH_INVALID_ID;
}
else
{
Rect r = GetGeometricData().GetUnrotatedRect();//GetRect(true);
currentPos = currentInput->point - r.GetPosition();
currentPos -= Vector2(r.dx * 0.5f, r.dy * 0.5f);
if(currentPos.x < deadAreaSize && currentPos.x > -deadAreaSize && currentPos.y < deadAreaSize && currentPos.y > -deadAreaSize)
{
currentPos.x = 0;
currentPos.y = 0;
}
currentPos.x = Max(currentPos.x, -size.x/2);
currentPos.x = Min(currentPos.x, size.x/2);
currentPos.y = Max(currentPos.y, -size.y/2);
currentPos.y = Min(currentPos.y, size.y/2);
}
if (stick)
{
stick->relativePosition.x = size.x/2 + currentPos.x;
stick->relativePosition.y = size.y/2 + currentPos.y;
}
needRecalcAnalog = true;
needRecalcDigital = true;
currentInput->SetInputHandledType(UIEvent::INPUT_HANDLED_HARD); // Drag is handled - see please DF-2508.
}
示例5: LoadResources
void DeviceInfoTest::LoadResources()
{
UITestTemplate::LoadResources();
Font *font = FTFont::Create("~res:/Fonts/korinna.ttf");
DVASSERT(font);
font->SetSize(20);
Rect textRect = GetRect();
textRect.SetPosition(textRect.GetPosition() + Vector2(1.0f, 31.0f));
textRect.SetSize(textRect.GetSize() - Vector2(1.0f, 31.0f));
deviceInfoText = new UIStaticText(textRect);
deviceInfoText->SetMultiline(true);
deviceInfoText->SetTextAlign(ALIGN_LEFT | ALIGN_TOP);
deviceInfoText->SetFont(font);
deviceInfoText->SetTextColor(Color::White);
deviceInfoText->SetDebugDraw(true);
AddControl(deviceInfoText);
}
示例6: GetParentDelta
Vector2 HierarchyTreeControlNode::GetParentDelta(bool skipControl/* = false*/) const
{
Vector2 parentDelta(0, 0);
if (!skipControl && uiObject)
{
Rect rect = uiObject->GetRect();
parentDelta = rect.GetPosition();
// For UIScrollView we should consider scrollcontainer delta also
UIScrollView* scrollView = dynamic_cast<UIScrollView* >(uiObject);
if (scrollView)
{
parentDelta += scrollView->GetPadding();
}
}
const HierarchyTreeControlNode* parentControl = dynamic_cast<const HierarchyTreeControlNode* >(parent);
if (parentControl)
parentDelta += parentControl->GetParentDelta();
return parentDelta;
}
示例7: SetParent
void HierarchyTreeControlNode::SetParent(HierarchyTreeNode* node, HierarchyTreeNode* insertAfter)
{
if (this == insertAfter)
return;
if (parent)
parent->RemoveTreeNode(this, false, false);
HierarchyTreeControlNode* newParentControl = dynamic_cast<HierarchyTreeControlNode* >(node);
HierarchyTreeScreenNode* newParentScreen = dynamic_cast<HierarchyTreeScreenNode* >(node);
DVASSERT(newParentControl || newParentScreen);
if (!newParentControl && !newParentScreen)
return;
UIControl* afterControl = NULL;
HierarchyTreeControlNode* insertAfterControl = dynamic_cast<HierarchyTreeControlNode* >(insertAfter);
if (insertAfterControl)
afterControl = insertAfterControl->GetUIObject();
UIControl* newParentUI = NULL;
if (newParentControl)
newParentUI = newParentControl->GetUIObject();
else if (newParentScreen)
newParentUI = newParentScreen->GetScreen();
node->AddTreeNode(this, insertAfter);
if (newParentUI && uiObject)
{
Rect controlAbsoluteRect = uiObject->GetRect(true);
Rect parentAbsoluteRect = newParentUI->GetRect(true);
if (insertAfter != node)
{
newParentUI->InsertChildAbove(uiObject, afterControl);
}
else
{
UIControl* belowControl = NULL;
const List<UIControl*> & controls = newParentUI->GetChildren();
if (controls.size())
{
belowControl = *controls.begin();
}
newParentUI->InsertChildBelow(uiObject, belowControl);
}
// Recalculate the relative coords of the moved object to don't change its position.
Vector2 newControlOffset = controlAbsoluteRect.GetPosition() - parentAbsoluteRect.GetPosition();
uiObject->SetRect(Rect(newControlOffset, uiObject->GetRect().GetSize()));
// Fix
// DF-2395 - Recalculate scrollContainer content each time we add controls to it
UIScrollViewContainer *container = dynamic_cast<UIScrollViewContainer*>(newParentUI);
if (container)
{
UIScrollView *scroll = dynamic_cast<UIScrollView*>(container->GetParent());
if (scroll)
{
scroll->RecalculateContentSize();
}
}
}
parent = node;
}