Skip to content

Commit

Permalink
Merge pull request AtomicGameEngine#1583 from AtomicGameEngine/JME-AT…
Browse files Browse the repository at this point in the history
…OMIC-FIXMENU

Update for GetParentRoot which gets the UIView root by default
  • Loading branch information
JoshEngebretson authored Jun 27, 2017
2 parents 31eacc5 + ccc2a1b commit f1fb3ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion Source/ThirdParty/TurboBadger/tb_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,11 +814,19 @@ bool TBWidget::IsEventDestinationFor(TBWidget *other_widget) const
return false;
}

TBWidget *TBWidget::GetParentRoot()
TBWidget *TBWidget::GetParentRoot(bool view_root)
{
TBWidget *tmp = this;

while (tmp->m_parent)
{
if (view_root && !tmp->m_parent->m_parent)
{
return tmp;
}

tmp = tmp->m_parent;
}
return tmp;
}

Expand Down
5 changes: 3 additions & 2 deletions Source/ThirdParty/TurboBadger/tb_widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,9 @@ class TBWidget : public TBTypedObject, public TBLinkOf<TBWidget>
for widgets having multiple children by default, to specify which one that should get the children. */
virtual TBWidget *GetContentRoot() { return this; }

/** Get this widget or a parent widget that is the absolute root parent. */
TBWidget *GetParentRoot();
/** Get this widget or a parent widget that is the absolute root parent
if view_root is true, will return the widget for the UIView attached to root widget */
TBWidget *GetParentRoot(bool view_root = true);

/** Get the closest parent widget that is a TBWindow or nullptr if there is none.
If this widget is a window itself, this will be returned. */
Expand Down

0 comments on commit f1fb3ae

Please sign in to comment.