Skip to content

Commit

Permalink
修正navigationBar在寻找stackElement时的逻辑,会向上在所有父节点下面查找
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyang219 committed Aug 3, 2024
1 parent 43c6f82 commit 8896ded
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions MusicPlayer2/UIElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1955,15 +1955,21 @@ void UiElement::NavigationBar::FindStackElement()
{
if (!find_stack_element)
{
if (pParent != nullptr)
UiElement::Element* parent = pParent;
while (parent != nullptr)
{
//查找与自己同级的StackElement
for (const auto& ele : pParent->childLst)
//依次查找所有父节点下面的StackElement
for (const auto& ele : parent->childLst)
{
StackElement* _stack_element = dynamic_cast<StackElement*>(ele.get());
if (_stack_element != nullptr)
{
stack_element = _stack_element;
find_stack_element = true;
return;
}
}
parent = parent->pParent;
}

//如果没有找到,则查找整个界面第一个StackElement
Expand All @@ -1984,7 +1990,7 @@ void UiElement::NavigationBar::FindStackElement()
}
}

find_stack_element = true;
find_stack_element = true; //找过一次没找到就不找了
}
}

Expand Down
2 changes: 1 addition & 1 deletion MusicPlayer2/skins/skin.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@
</xs:complexType>
<xs:complexType name="navigationBarType">
<xs:annotation>
<xs:documentation>导航栏。用于控制stackElement的切换,优先作用于和它同一级的stackElement,如果未找到,则作用于ui元素下第一个stackElement。</xs:documentation>
<xs:documentation>导航栏。用于控制stackElement的切换,依次向上在它的所有父节点下面查找stackElement,如果未找到,则作用于ui元素下第一个stackElement。</xs:documentation>
</xs:annotation>
<xs:group ref="elements"></xs:group>
<xs:attribute name="item_list">
Expand Down

0 comments on commit 8896ded

Please sign in to comment.