本文整理汇总了C++中UIElement::GetParent方法的典型用法代码示例。如果您正苦于以下问题:C++ UIElement::GetParent方法的具体用法?C++ UIElement::GetParent怎么用?C++ UIElement::GetParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIElement
的用法示例。
在下文中一共展示了UIElement::GetParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleFocusChanged
void Menu::HandleFocusChanged(StringHash eventType, VariantMap& eventData)
{
if (!showPopup_)
return;
using namespace FocusChanged;
UIElement* element = static_cast<UIElement*>(eventData[P_ELEMENT].GetPtr());
UIElement* root = GetRoot();
// If another element was focused due to the menu button being clicked, do not hide the popup
if (eventType == E_FOCUSCHANGED && static_cast<UIElement*>(eventData[P_CLICKEDELEMENT].GetPtr()))
return;
// If clicked emptiness or defocused, hide the popup
if (!element)
{
ShowPopup(false);
return;
}
// Otherwise see if the clicked element has either the menu item or the popup in its parent chain.
// In that case, do not hide
while (element)
{
if (element == this || element == popup_)
return;
if (element->GetParent() == root)
element = static_cast<UIElement*>(element->GetVar(originHash).GetPtr());
else
element = element->GetParent();
}
ShowPopup(false);
}
示例2: Update
void ScrollView::Update(float timeStep)
{
// Update touch scrolling here if necessary
if (touchScrollSpeed_ == Vector2::ZERO && touchScrollSpeedMax_ == Vector2::ZERO && !barScrolling_)
return;
// Check if we should not scroll:
// - ScrollView is not visible, is not enabled, or doesn't have focus
// - The element being dragged is not a child of the ScrollView, or is one of our scrollbars
if (!IsVisible() || !IsEnabled() || !HasFocus())
{
touchScrollSpeed_ = Vector2::ZERO;
touchScrollSpeedMax_ = Vector2::ZERO;
return;
}
if (GetSubsystem<UI>()->IsDragging())
{
Vector<UIElement*> dragElements = GetSubsystem<UI>()->GetDragElements();
for (unsigned i = 0; i < dragElements.Size(); i++)
{
UIElement* dragElement = dragElements[i];
int dragButtons = dragElement->GetDragButtonCombo();
if (dragButtons != MOUSEB_LEFT)
continue;
UIElement* dragParent = dragElement->GetParent();
bool dragElementIsChild = false;
while (dragParent)
{
if (dragParent == this)
{
dragElementIsChild = true;
break;
}
dragParent = dragParent->GetParent();
}
if (!dragElementIsChild || dragElement == horizontalScrollBar_->GetSlider() ||
dragElement == verticalScrollBar_->GetSlider())
{
touchScrollSpeed_ = Vector2::ZERO;
touchScrollSpeedMax_ = Vector2::ZERO;
return;
}
}
}
// Update view position
IntVector2 newPosition = viewPosition_;
newPosition.x_ += (int)touchScrollSpeed_.x_;
newPosition.y_ += (int)touchScrollSpeed_.y_;
SetViewPosition(newPosition);
// Smooth deceleration
ScrollSmooth(timeStep);
}
示例3: Update
void ScrollView::Update(float timeStep)
{
// Update touch scrolling here if necessary
if (touchScrollSpeed_ == IntVector2::ZERO)
return;
// Check if we should not scroll:
// - ScrollView is not visible, is not enabled, or doesn't have focus
// - The element being dragged is not a child of the ScrollView, or is one of our scrollbars
if (!IsVisible() || !IsEnabled() || !HasFocus())
{
touchScrollSpeed_ = IntVector2::ZERO;
return;
}
UIElement* dragElement = GetSubsystem<UI>()->GetDragElement();
if (dragElement)
{
UIElement* dragParent = dragElement->GetParent();
bool dragElementIsChild = false;
while (dragParent)
{
if (dragParent == this)
{
dragElementIsChild = true;
break;
}
dragParent = dragParent->GetParent();
}
if (!dragElementIsChild || dragElement == horizontalScrollBar_->GetSlider() || dragElement == verticalScrollBar_->GetSlider())
{
touchScrollSpeed_ = IntVector2::ZERO;
return;
}
}
// Update view position, reset speed accumulation for next frame
IntVector2 newPosition = viewPosition_;
newPosition.x_ += touchScrollSpeed_.x_;
newPosition.y_ += touchScrollSpeed_.y_;
SetViewPosition(newPosition);
/// \todo Could have smooth deceleration
touchScrollSpeed_ = IntVector2::ZERO;
}
示例4: HandleItemFocusChanged
void ListView::HandleItemFocusChanged(StringHash eventType, VariantMap& eventData)
{
using namespace FocusChanged;
UIElement* element = static_cast<UIElement*>(eventData[P_ELEMENT].GetPtr());
while (element)
{
// If the focused element or its parent is in the list, scroll the list to make the item visible
UIElement* parent = element->GetParent();
if (parent == contentElement_)
{
EnsureItemVisibility(element);
return;
}
element = parent;
}
}