mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
!44501 修复弹出其他二级菜单,再弹出STACK_EXPAND,此时点击STACK_EXPAND的关闭按钮,整个Menu都变为透明
Merge pull request !44501 from 林昊/menu_stack_200924
This commit is contained in:
commit
2b6d7de568
@ -202,6 +202,25 @@ void MenuWrapperPattern::HideMenu()
|
||||
HideMenu(menuNode);
|
||||
}
|
||||
|
||||
void MenuWrapperPattern::GetExpandingMode(const RefPtr<UINode>& subMenu, SubMenuExpandingMode& expandingMode,
|
||||
bool& hasAnimation)
|
||||
{
|
||||
CHECK_NULL_VOID(subMenu);
|
||||
auto subMenuPattern = DynamicCast<FrameNode>(subMenu)->GetPattern<MenuPattern>();
|
||||
CHECK_NULL_VOID(subMenuPattern);
|
||||
hasAnimation = subMenuPattern->GetDisappearAnimation();
|
||||
auto menuItem = FrameNode::GetFrameNode(subMenuPattern->GetTargetTag(), subMenuPattern->GetTargetId());
|
||||
CHECK_NULL_VOID(menuItem);
|
||||
auto menuItemPattern = menuItem->GetPattern<MenuItemPattern>();
|
||||
CHECK_NULL_VOID(menuItemPattern);
|
||||
auto menuNode = menuItemPattern->GetMenu();
|
||||
CHECK_NULL_VOID(menuNode);
|
||||
auto menuProperty = menuNode->GetLayoutProperty<MenuLayoutProperty>();
|
||||
CHECK_NULL_VOID(menuProperty);
|
||||
expandingMode = menuProperty->GetExpandingMode().value_or(SubMenuExpandingMode::SIDE);
|
||||
menuItemPattern->SetIsSubMenuShowed (false);
|
||||
}
|
||||
|
||||
void MenuWrapperPattern::HideSubMenu()
|
||||
{
|
||||
auto host = GetHost();
|
||||
@ -216,16 +235,6 @@ void MenuWrapperPattern::HideSubMenu()
|
||||
CHECK_NULL_VOID(menuPattern);
|
||||
menuPattern->SetShowedSubMenu(nullptr);
|
||||
auto subMenu = host->GetChildren().back();
|
||||
auto subMenuPattern = DynamicCast<FrameNode>(subMenu)->GetPattern<MenuPattern>();
|
||||
if (subMenuPattern) {
|
||||
subMenuPattern->RemoveParentHoverStyle();
|
||||
auto frameNode = FrameNode::GetFrameNode(subMenuPattern->GetTargetTag(), subMenuPattern->GetTargetId());
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto menuItem = frameNode->GetPattern<MenuItemPattern>();
|
||||
if (menuItem) {
|
||||
menuItem->SetIsSubMenuShowed(false);
|
||||
}
|
||||
}
|
||||
auto focusMenu = MenuFocusViewShow();
|
||||
CHECK_NULL_VOID(focusMenu);
|
||||
auto innerMenu = GetMenuChild(focusMenu);
|
||||
@ -236,7 +245,6 @@ void MenuWrapperPattern::HideSubMenu()
|
||||
host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF_AND_CHILD);
|
||||
return;
|
||||
}
|
||||
CHECK_NULL_VOID(innerMenu);
|
||||
auto innerMenuPattern = innerMenu->GetPattern<MenuPattern>();
|
||||
CHECK_NULL_VOID(innerMenuPattern);
|
||||
auto layoutProps = innerMenuPattern->GetLayoutProperty<MenuLayoutProperty>();
|
||||
@ -245,8 +253,11 @@ void MenuWrapperPattern::HideSubMenu()
|
||||
auto outterMenuPattern = focusMenu->GetPattern<MenuPattern>();
|
||||
CHECK_NULL_VOID(outterMenuPattern);
|
||||
bool hasAnimation = outterMenuPattern->GetDisappearAnimation();
|
||||
GetExpandingMode(subMenu, expandingMode, hasAnimation);
|
||||
if (expandingMode == SubMenuExpandingMode::STACK && hasAnimation) {
|
||||
HideStackExpandMenu(subMenu);
|
||||
host->RemoveChild(subMenu);
|
||||
host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF_AND_CHILD);
|
||||
} else {
|
||||
UpdateMenuAnimation(host);
|
||||
SendToAccessibility(subMenu, false);
|
||||
|
@ -111,7 +111,7 @@ public:
|
||||
void HideSubMenu();
|
||||
RefPtr<FrameNode> MenuFocusViewShow();
|
||||
void HideStackExpandMenu(const RefPtr<UINode>& subMenu);
|
||||
|
||||
void GetExpandingMode(const RefPtr<UINode>& subMenu, SubMenuExpandingMode& expandingMode, bool& hasAnimation);
|
||||
RefPtr<FrameNode> GetMenu() const
|
||||
{
|
||||
auto host = GetHost();
|
||||
|
@ -830,7 +830,7 @@ HWTEST_F(MenuWrapperTestNg, MenuWrapperPatternTestNg015, TestSize.Level1)
|
||||
mainMenu->GetPattern<MenuPattern>()->SetDisappearAnimation(true);
|
||||
subMenu->GetPattern<MenuPattern>()->SetDisappearAnimation(true);
|
||||
wrapperPattern->HideSubMenu();
|
||||
EXPECT_EQ(wrapperNode->GetChildren().size(), 2);
|
||||
EXPECT_EQ(wrapperNode->GetChildren().size(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user