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


C++ UIElement::GetParent方法代码示例

本文整理汇总了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);
}
开发者ID:acremean,项目名称:urho3d,代码行数:35,代码来源:Menu.cpp

示例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);
}
开发者ID:TheComet93,项目名称:Urho3D,代码行数:60,代码来源:ScrollView.cpp

示例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;
}
开发者ID:AGreatFish,项目名称:Urho3D,代码行数:47,代码来源:ScrollView.cpp

示例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;
    }
}
开发者ID:03050903,项目名称:Urho3D,代码行数:17,代码来源:ListView.cpp


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