From 99fd3d54f34ccbad2457f126a97d08e63a101f10 Mon Sep 17 00:00:00 2001 From: wangyihui Date: Thu, 10 Oct 2024 07:58:38 +0000 Subject: [PATCH] =?UTF-8?q?=E3=80=90Menu=E3=80=91=E9=80=82=E9=85=8D?= =?UTF-8?q?=E6=99=BA=E6=85=A7=E5=A4=9A=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyihui Change-Id: I34007b4da896da994571c1479bf6210c3b5b5a41 --- adapter/ohos/entrance/ui_content_impl.cpp | 21 +- .../base/view_abstract_model_ng.cpp | 1 + .../pattern/menu/menu_layout_algorithm.cpp | 223 ++++++++++-------- .../pattern/menu/menu_layout_algorithm.h | 43 ++-- .../menu/sub_menu_layout_algorithm.cpp | 19 +- .../menu/wrapper/menu_wrapper_pattern.cpp | 4 + .../menu/wrapper/menu_wrapper_pattern.h | 2 + .../pattern/menu/menu_layoutFst_test_ng.cpp | 18 +- .../pattern/menu/menu_layoutScd_test_ng.cpp | 12 +- .../pattern/menu/menu_layoutThi_test_ng.cpp | 4 +- .../core/pattern/menu/menu_origin_test_ng.cpp | 4 +- .../pattern/menu/menuitem_pattern_test_ng.cpp | 4 +- 12 files changed, 194 insertions(+), 161 deletions(-) diff --git a/adapter/ohos/entrance/ui_content_impl.cpp b/adapter/ohos/entrance/ui_content_impl.cpp index d9876885b3a..24af359178c 100644 --- a/adapter/ohos/entrance/ui_content_impl.cpp +++ b/adapter/ohos/entrance/ui_content_impl.cpp @@ -315,7 +315,6 @@ void AddAlarmLogFunc() OHOS::Rosen::RSTransactionData::AddAlarmLog(logFunc); } - void DeduplicateAvoidAreas(const RefPtr& context, std::map& updatingInsets, const std::map& avoidAreas, @@ -600,7 +599,11 @@ public: auto displayAvailableRect = ConvertDMRect2Rect(availableArea); ContainerScope scope(instanceId_); taskExecutor->PostTask( - [pipeline, displayAvailableRect] { pipeline->UpdateDisplayAvailableRect(displayAvailableRect); }, + [pipeline, displayAvailableRect] { + pipeline->UpdateDisplayAvailableRect(displayAvailableRect); + TAG_LOGI(AceLogTag::ACE_WINDOW, "UpdateDisplayAvailableRect : %{public}s", + displayAvailableRect.ToString().c_str()); + }, TaskExecutor::TaskType::UI, "ArkUIUpdateDisplayAvailableRect"); } @@ -2076,11 +2079,11 @@ void UIContentImpl::InitializeDisplayAvailableRect(const RefPtrGetAvailableArea(availableArea); - TAG_LOGI(AceLogTag::ACE_WINDOW, - "DisplayAvailableRect info: %{public}d, %{public}d, %{public}d, %{public}d", availableArea.posX_, - availableArea.posX_, availableArea.width_, availableArea.height_); if (ret == Rosen::DMError::DM_OK) { pipeline->UpdateDisplayAvailableRect(ConvertDMRect2Rect(availableArea)); + TAG_LOGI(AceLogTag::ACE_WINDOW, + "InitializeDisplayAvailableRect : %{public}d, %{public}d, %{public}d, %{public}d", availableArea.posX_, + availableArea.posY_, availableArea.width_, availableArea.height_); } } } @@ -2468,8 +2471,10 @@ void UIContentImpl::UpdateViewportConfigWithAnimation(const ViewportConfig& conf auto container = Platform::AceContainer::GetContainer(instanceId_); CHECK_NULL_VOID(container); if (container->IsSubContainer()) { - SubwindowManager::GetInstance()->SetRect(NG::RectF(config.Left(), config.Top(), - config.Width(), config.Height()), instanceId_); + auto rect = NG::RectF(config.Left(), config.Top(), config.Width(), config.Height()); + SubwindowManager::GetInstance()->SetRect(rect, instanceId_); + TAG_LOGI(AceLogTag::ACE_WINDOW, "UpdateViewportConfig for subContainer: %{public}s", + rect.ToString().c_str()); } // The density of sub windows related to dialog needs to be consistent with the main window. auto modifyConfig = config; @@ -2528,7 +2533,7 @@ void UIContentImpl::UpdateViewportConfigWithAnimation(const ViewportConfig& conf UpdateSafeArea(pipelineContext, updatingInsets, avoidAreas, config, container); pipelineContext->SetDisplayWindowRectInfo( Rect(Offset(config.Left(), config.Top()), Size(config.Width(), config.Height()))); - TAG_LOGI(AceLogTag::ACE_WINDOW, "Update displayAvailableRect to : %{public}s", + TAG_LOGI(AceLogTag::ACE_WINDOW, "Update displayAvailableRect in UpdateViewportConfig to : %{public}s", pipelineContext->GetDisplayWindowRectInfo().ToString().c_str()); if (rsWindow) { pipelineContext->SetIsLayoutFullScreen( diff --git a/frameworks/core/components_ng/base/view_abstract_model_ng.cpp b/frameworks/core/components_ng/base/view_abstract_model_ng.cpp index 0c3619ee21c..74283572477 100644 --- a/frameworks/core/components_ng/base/view_abstract_model_ng.cpp +++ b/frameworks/core/components_ng/base/view_abstract_model_ng.cpp @@ -261,6 +261,7 @@ void ViewAbstractModelNG::BindContextMenu(const RefPtr& targetNode, R auto weakTarget = AceType::WeakClaim(AceType::RawPtr(targetNode)); if (type == ResponseType::RIGHT_CLICK) { OnMouseEventFunc event = [builderF = buildFunc, weakTarget, menuParam](MouseInfo& info) mutable { + TAG_LOGI(AceLogTag::ACE_MENU, "Execute rightClick task for menu"); auto containerId = Container::CurrentId(); auto taskExecutor = Container::CurrentTaskExecutor(); CHECK_NULL_VOID(taskExecutor); diff --git a/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp index 82111d65312..d5bc4df576e 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp @@ -322,17 +322,19 @@ void MenuLayoutAlgorithm::Initialize(LayoutWrapper* layoutWrapper) } else { InitializePadding(layoutWrapper); } - InitWrapperRect(props, menuPattern); InitializeParam(menuPattern); + InitWrapperRect(props, menuPattern); + dumpInfo_.originPlacement = + PlacementUtils::ConvertPlacementToString(props->GetMenuPlacement().value_or(Placement::NONE)); placement_ = props->GetMenuPlacement().value_or(Placement::BOTTOM_LEFT); if (menuPattern->IsSubMenu() && Container::GreatOrEqualAPITargetVersion(PlatformVersion::VERSION_TWELVE)) { placement_ = props->GetMenuPlacement().value_or(Placement::BOTTOM_RIGHT); } - dumpInfo_.originPlacement = PlacementUtils::ConvertPlacementToString(placement_); ModifyPositionToWrapper(layoutWrapper, position_); if (menuPattern->GetPreviewMode() != MenuPreviewMode::NONE) { ModifyPreviewMenuPlacement(layoutWrapper); } + dumpInfo_.defaultPlacement = PlacementUtils::ConvertPlacementToString(placement_); InitSpace(props, menuPattern); } @@ -347,15 +349,14 @@ void MenuLayoutAlgorithm::InitializeParam(const RefPtr& menuPattern auto props = menuPattern->GetLayoutProperty(); CHECK_NULL_VOID(props); auto bottom = GetBottomBySafeAreaManager(safeAreaManager, props, menuPattern); - auto windowGlobalRect = hierarchicalParameters_ ? pipelineContext->GetDisplayAvailableRect() - : pipelineContext->GetDisplayWindowRectInfo(); - float windowsOffsetX = static_cast(windowGlobalRect.GetOffset().GetX()); - float windowsOffsetY = static_cast(windowGlobalRect.GetOffset().GetY()); + auto menuWindowRect = GetMenuWindowRectInfo(menuPattern); + float windowsOffsetX = static_cast(menuWindowRect.GetOffset().GetX()); + float windowsOffsetY = static_cast(menuWindowRect.GetOffset().GetY()); float screenHeight = wrapperSize_.Height() + wrapperRect_.Top(); - if (!NearEqual(screenHeight, windowGlobalRect.Height())) { + if (!NearEqual(screenHeight, menuWindowRect.Height())) { screenHeight += bottom; } - SizeF windowGlobalSizeF(windowGlobalRect.Width(), screenHeight - windowsOffsetY); + SizeF windowGlobalSizeF(menuWindowRect.Width(), menuWindowRect.Width()); float topSecurity = 0.0f; float bottomSecurity = 0.0f; if (SystemProperties::GetDeviceOrientation() == DeviceOrientation::PORTRAIT) { @@ -370,9 +371,15 @@ void MenuLayoutAlgorithm::InitializeParam(const RefPtr& menuPattern topSecurity = static_cast(LANDSCAPE_TOP_SECURITY.ConvertToPx()); bottomSecurity = static_cast(LANDSCAPE_BOTTOM_SECURITY.ConvertToPx()); } + if (canExpandCurrentWindow_) { + param_.windowsOffsetX = windowsOffsetX; + param_.windowsOffsetY = windowsOffsetY; + } else { + param_.windowsOffsetX = 0; + param_.windowsOffsetY = 0; + } + param_.menuWindowRect = menuWindowRect; param_.windowGlobalSizeF = windowGlobalSizeF; - param_.windowsOffsetX = windowsOffsetX; - param_.windowsOffsetY = windowsOffsetY; param_.top = top; param_.bottom = bottom; param_.left = safeAreaInsets.left_.Length(); @@ -437,15 +444,10 @@ void MenuLayoutAlgorithm::InitializeLayoutRegionMargin(const RefPtr void MenuLayoutAlgorithm::InitWrapperRect( const RefPtr& props, const RefPtr& menuPattern) { - auto constraint = props->GetLayoutConstraint(); - // has minus navgation bar height(AvoidAreaType.TYPE_NAVIGATION_INDICATOR) - auto wrapperIdealSize = - CreateIdealSize(constraint.value(), Axis::FREE, props->GetMeasureType(MeasureType::MATCH_PARENT), true); + wrapperRect_ = param_.menuWindowRect; + TAG_LOGI(AceLogTag::ACE_MENU, "wrapperRect initialized to : %{public}s", wrapperRect_.ToString().c_str()); auto pipelineContext = GetCurrentPipelineContext(); CHECK_NULL_VOID(pipelineContext); - auto windowGlobalRect = hierarchicalParameters_ ? pipelineContext->GetDisplayAvailableRect() - : pipelineContext->GetDisplayWindowRectInfo(); - wrapperRect_.SetRect(0, 0, wrapperIdealSize.Width(), wrapperIdealSize.Height()); auto safeAreaManager = pipelineContext->GetSafeAreaManager(); CHECK_NULL_VOID(safeAreaManager); // system safeArea(AvoidAreaType.TYPE_SYSTEM) only include status bar,now the bottom is 0 @@ -454,36 +456,24 @@ void MenuLayoutAlgorithm::InitWrapperRect( top_ = static_cast(safeAreaInsets.top_.Length()); left_ = static_cast(safeAreaInsets.left_.Length()); right_ = static_cast(safeAreaInsets.right_.Length()); + width_ = wrapperRect_.Width(); + height_ = wrapperRect_.Height(); + auto windowManager = pipelineContext->GetWindowManager(); + auto isContainerModal = pipelineContext->GetWindowModal() == WindowModal::CONTAINER_MODAL && windowManager && + windowManager->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING; if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN)) { - if (hierarchicalParameters_) { - // wrapperRect_= windowGlobalRect- dock -statusbar - wrapperRect_ = pipelineContext->GetDisplayAvailableRect(); - } else { - auto windowManager = pipelineContext->GetWindowManager(); - auto isContainerModal = pipelineContext->GetWindowModal() == WindowModal::CONTAINER_MODAL && - windowManager && windowManager->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING; - width_ = windowGlobalRect.Width(); - height_ = windowGlobalRect.Height(); - if (isContainerModal) { - LimitContainerModalMenuRect(width_, height_); - } - isHalfFoldHover_ = pipelineContext->IsHalfFoldHoverStatus(); - if (isHalfFoldHover_ && menuPattern->GetHoverMode()) { - UpdateWrapperRectForHoverMode(props, menuPattern); - } else { - wrapperRect_.SetRect(left_, top_, width_ - left_ - right_, height_ - top_ - bottom_); - } + if (canExpandCurrentWindow_ && isContainerModal) { + LimitContainerModalMenuRect(width_, height_); } - } - if (menuPattern->GetPreviewMode() != MenuPreviewMode::NONE) { - // come from ModifyPreviewMenuPlacement - if (NearEqual(wrapperIdealSize.Height(), windowGlobalRect.Height())) { - wrapperRect_.SetRect( - left_, top_, windowGlobalRect.Width() - left_ - - right_, windowGlobalRect.Height() - top_ - bottom_); + isHalfFoldHover_ = pipelineContext->IsHalfFoldHoverStatus(); + if (isHalfFoldHover_ && menuPattern->GetHoverMode()) { + UpdateWrapperRectForHoverMode(props, menuPattern); + } else { + wrapperRect_.SetRect(left_, top_, width_ - left_ - right_, height_ - top_ - bottom_); } } + TAG_LOGI(AceLogTag::ACE_MENU, "wrapperRect update to : %{public}s", wrapperRect_.ToString().c_str()); wrapperSize_ = SizeF(wrapperRect_.Width(), wrapperRect_.Height()); dumpInfo_.wrapperRect = wrapperRect_; } @@ -561,7 +551,7 @@ void MenuLayoutAlgorithm::InitSpace(const RefPtr& props, con rightSpace_ = wrapperRect_.Right() - leftSpace_; } } else { - if (hierarchicalParameters_ || !Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN)) { + if (canExpandCurrentWindow_ || !Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN)) { topSpace_ = position_.GetY() - targetSize.Height() - paddingTop_ - wrapperRect_.Top(); bottomSpace_ = wrapperRect_.Bottom() - position_.GetY() - paddingBottom_; } else { @@ -604,7 +594,7 @@ void MenuLayoutAlgorithm::InitializePaddingAPI12(LayoutWrapper* layoutWrapper) margin_ = static_cast(theme->GetOutPadding().ConvertToPx()); optionPadding_ = margin_; - if (!hierarchicalParameters_) { + if (!canExpandCurrentWindow_) { paddingStart_ = static_cast(theme->GetMenuLargeMargin().ConvertToPx()); paddingEnd_ = static_cast(theme->GetMenuLargeMargin().ConvertToPx()); } else { @@ -635,7 +625,7 @@ void MenuLayoutAlgorithm::ModifyPositionToWrapper(LayoutWrapper* layoutWrapper, CHECK_NULL_VOID(menuPattern); bool isSubMenu = menuPattern->IsSubMenu() || menuPattern->IsSelectOverlaySubMenu(); if ((menuPattern->IsContextMenu() || (isSubMenu && Container::CurrentId() >= MIN_SUBCONTAINER_ID) || - hierarchicalParameters_) && + canExpandCurrentWindow_) && (targetTag_ != V2::SELECT_ETS_TAG)) { // no need to modify for context menu, because context menu wrapper is full screen. return; @@ -687,11 +677,11 @@ void MenuLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper) auto menuLayoutProperty = AceType::DynamicCast(layoutWrapper->GetLayoutProperty()); CHECK_NULL_VOID(menuLayoutProperty); auto isShowInSubWindow = menuLayoutProperty->GetShowInSubWindowValue(true); - InitHierarchicalParameters(isShowInSubWindow, menuPattern); + InitCanExpandCurrentWindow(isShowInSubWindow); + Initialize(layoutWrapper); if (!targetTag_.empty()) { InitTargetSizeAndPosition(layoutWrapper, menuPattern->IsContextMenu(), menuPattern); } - Initialize(layoutWrapper); const auto& constraint = menuLayoutProperty->GetLayoutConstraint(); if (!constraint) return; @@ -940,15 +930,13 @@ SizeF MenuLayoutAlgorithm::GetPreviewNodeAndMenuNodeTotalSize(const RefPtrGetDisplayAvailableRect() - : pipelineContext->GetDisplayWindowRectInfo(); for (auto& child : frameNode->GetAllChildrenWithBuild()) { auto hostNode = child->GetHostNode(); auto geometryNode = child->GetGeometryNode(); if (!hostNode || !geometryNode) { continue; } - GetPreviewNodeTotalSize(child, windowGlobalRect, previewLayoutWrapper, size, isShowHoverImage); + GetPreviewNodeTotalSize(child, param_.menuWindowRect, previewLayoutWrapper, size, isShowHoverImage); auto menuPattern = hostNode->GetPattern(); if (hostNode->GetTag() == V2::MENU_ETS_TAG && menuPattern && !menuPattern->IsSubMenu()) { menuLayoutWrapper = child; @@ -1039,8 +1027,6 @@ void MenuLayoutAlgorithm::LayoutNormalTopPreviewBottomMenu(const RefPtrGetDisplayAvailableRect() - : pipelineContext->GetDisplayWindowRectInfo(); if (LessNotEqual(totalSize.Height() + targetSecurity_, wrapperRect_.Height() - paddingTop_ - paddingBottom_ - param_.topSecurity - param_.bottomSecurity)) { LayoutNormalTopPreviewBottomMenuLessThan(previewGeometryNode, menuGeometryNode, totalSize); @@ -1049,7 +1035,7 @@ void MenuLayoutAlgorithm::LayoutNormalTopPreviewBottomMenu(const RefPtrGetMarginFrameSize(); auto securityHeight = wrapperRect_.Height() - param_.topSecurity - param_.bottomSecurity; - if (GreatNotEqual(param_.windowGlobalSizeF.Height(), windowGlobalRect.Height()) && + if (GreatNotEqual(param_.windowGlobalSizeF.Height(), param_.menuWindowRect.Height()) && GreatNotEqual(previewSize.Height(), securityHeight)) { previewGeometryNode->SetFrameSize(SizeF(previewSize.Width(), securityHeight)); } @@ -1136,8 +1122,6 @@ void MenuLayoutAlgorithm::LayoutNormalBottomPreviewTopMenu(const RefPtrGetDisplayAvailableRect() - : pipelineContext->GetDisplayWindowRectInfo(); if (LessNotEqual(totalSize.Height() + targetSecurity_, param_.windowGlobalSizeF.Height() - param_.topSecurity - param_.bottomSecurity - param_.top - param_.bottom)) { LayoutNormalBottomPreviewTopMenuLessThan(previewGeometryNode, menuGeometryNode, totalSize); @@ -1146,8 +1130,8 @@ void MenuLayoutAlgorithm::LayoutNormalBottomPreviewTopMenu(const RefPtrGetMarginFrameSize(); auto securityHeight = - windowGlobalRect.Height() - param_.topSecurity - param_.top - param_.bottomSecurity - param_.bottom; - if (GreatNotEqual(param_.windowGlobalSizeF.Height(), windowGlobalRect.Height()) && + param_.menuWindowRect.Height() - param_.topSecurity - param_.top - param_.bottomSecurity - param_.bottom; + if (GreatNotEqual(param_.windowGlobalSizeF.Height(), param_.menuWindowRect.Height()) && GreatNotEqual(previewSize.Height(), securityHeight)) { previewGeometryNode->SetFrameSize(SizeF(previewSize.Width(), securityHeight)); } @@ -1320,12 +1304,8 @@ void MenuLayoutAlgorithm::LayoutOtherDeviceLeftPreviewRightMenu(const RefPtrGetDisplayAvailableRect() - : pipelineContext->GetDisplayWindowRectInfo(); auto safeAreaWidth = param_.left + param_.right; - auto maxRectRight = param_.windowGlobalSizeF.Width() - paddingStart_ - paddingEnd_ - safeAreaWidth; + auto maxRectRight = param_.windowGlobalSizeF.Width() - paddingStart_ - paddingEnd_ - safeAreaWidth; if (LessNotEqual(totalSize.Width() + targetSecurity_, maxRectRight)) { LayoutOtherDeviceLeftPreviewRightMenuLessThan(previewGeometryNode, menuGeometryNode, totalSize); } else { @@ -1333,8 +1313,8 @@ void MenuLayoutAlgorithm::LayoutOtherDeviceLeftPreviewRightMenu(const RefPtrGetMarginFrameSize(); auto securityHeight = - windowGlobalRect.Height() - param_.topSecurity - param_.top - param_.bottomSecurity - param_.bottom; - if (GreatNotEqual(param_.windowGlobalSizeF.Height(), windowGlobalRect.Height()) && + param_.menuWindowRect.Height() - param_.topSecurity - param_.top - param_.bottomSecurity - param_.bottom; + if (GreatNotEqual(param_.windowGlobalSizeF.Height(), param_.menuWindowRect.Height()) && GreatNotEqual(previewSize.Height(), securityHeight)) { previewGeometryNode->SetFrameSize(SizeF(previewSize.Width(), securityHeight)); } @@ -1528,7 +1508,6 @@ void MenuLayoutAlgorithm::UpdateMenuFrameSizeWithArrow(const RefPtrUpdateLastPosition(menuPosition); if (menuPattern->IsSelectOverlayRightClickMenu()) { AdjustSelectOverlayMenuPosition(menuPosition, geometryNode); @@ -1678,8 +1658,9 @@ BorderRadiusProperty MenuLayoutAlgorithm::GetMenuRadius(const LayoutWrapper* lay CHECK_NULL_RETURN(pipeline, radius); auto theme = pipeline->GetTheme(); CHECK_NULL_RETURN(theme, radius); - auto defaultRadius = Container::GreatOrEqualAPITargetVersion(PlatformVersion::VERSION_TWELVE) ? - theme->GetMenuDefaultRadius() : theme->GetMenuBorderRadius(); + auto defaultRadius = Container::GreatOrEqualAPITargetVersion(PlatformVersion::VERSION_TWELVE) + ? theme->GetMenuDefaultRadius() + : theme->GetMenuBorderRadius(); radius.SetRadius(defaultRadius); auto menuLayoutProp = DynamicCast(layoutWrapper->GetLayoutProperty()); CHECK_NULL_RETURN(menuLayoutProp, radius); @@ -1901,6 +1882,7 @@ OffsetF MenuLayoutAlgorithm::ComputeMenuPositionByOffset( RefPtr MenuLayoutAlgorithm::GetCurrentPipelineContext() { + // Get pipelineContext of main window or host window for UIExtension auto containerId = Container::CurrentId(); RefPtr context; if (containerId >= MIN_SUBCONTAINER_ID) { @@ -2250,11 +2232,8 @@ void MenuLayoutAlgorithm::InitTargetSizeAndPosition( if (Container::LessThanAPIVersion(PlatformVersion::VERSION_ELEVEN)) { expandDisplay = true; } - if (((isContextMenu && expandDisplay) || hierarchicalParameters_) && (targetTag_ != V2::SELECT_ETS_TAG)) { - auto windowGlobalRect = pipelineContext->GetDisplayWindowRectInfo(); - float windowsOffsetX = static_cast(windowGlobalRect.GetOffset().GetX()); - float windowsOffsetY = static_cast(windowGlobalRect.GetOffset().GetY()); - targetOffset_ += OffsetF(windowsOffsetX, windowsOffsetY); + if (canExpandCurrentWindow_ && targetTag_ != V2::SELECT_ETS_TAG) { + ModifyTargetOffset(); OffsetF offset = GetMenuWrapperOffset(layoutWrapper); targetOffset_ -= offset; return; @@ -2547,7 +2526,7 @@ bool MenuLayoutAlgorithm::CheckPlacement(const SizeF& childSize) case static_cast(DirectionState::Bottom_Direction): case static_cast(DirectionState::Top_Direction): { if ((LessNotEqual(x, preRect_.Left()) || GreatNotEqual(x + childSize.Width(), preRect_.Right())) && - !(LessNotEqual(y, preRect_.Top()) || GreatNotEqual(y + childSize.Height(), preRect_.Bottom()))) { + !(LessNotEqual(y, preRect_.Top()) || GreatNotEqual(y + childSize.Height(), preRect_.Bottom()))) { placement_ = Placement::NONE; return true; } @@ -2740,44 +2719,80 @@ OffsetF MenuLayoutAlgorithm::GetPositionWithPlacementRightBottom( return childPosition; } -void MenuLayoutAlgorithm::InitHierarchicalParameters(bool isShowInSubWindow, const RefPtr& menuPattern) +void MenuLayoutAlgorithm::InitCanExpandCurrentWindow(bool isShowInSubWindow) { - auto pipeline = PipelineBase::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); + auto pipelineContext = GetCurrentPipelineContext(); + CHECK_NULL_VOID(pipelineContext); + auto containerId = Container::CurrentId(); + auto container = AceEngine::Get().GetContainer(containerId); + if (containerId >= MIN_SUBCONTAINER_ID) { + auto parentContainerId = SubwindowManager::GetInstance()->GetParentContainerId(containerId); + container = AceEngine::Get().GetContainer(parentContainerId); + } + CHECK_NULL_VOID(container); + // Get FreeMultiWindow status of main window or host window + isFreeMultiWindow_ = container->IsFreeMultiWindow(); + auto theme = pipelineContext->GetTheme(); CHECK_NULL_VOID(theme); - auto expandDisplay = theme->GetExpandDisplay(); - CHECK_NULL_VOID(menuPattern); - auto menuWrapperNode = menuPattern->GetMenuWrapper(); - CHECK_NULL_VOID(menuWrapperNode); - auto menuWrapperPattern = menuWrapperNode->GetPattern(); - CHECK_NULL_VOID(menuWrapperPattern); - auto containerId = Container::CurrentIdSafely(); - if (expandDisplay && !isShowInSubWindow) { - if (containerId >= MIN_SUBCONTAINER_ID && menuWrapperPattern->IsSelectMenu()) { - hierarchicalParameters_ = true; - } else { - hierarchicalParameters_ = false; - } + // false for phone devices + isExpandDisplay_ = theme->GetExpandDisplay() || isFreeMultiWindow_; + if (isExpandDisplay_ && !isShowInSubWindow && containerId >= MIN_SUBCONTAINER_ID) { + canExpandCurrentWindow_ = true; return; } - - hierarchicalParameters_ = expandDisplay; - - RefPtr container = Container::Current(); + canExpandCurrentWindow_ = isExpandDisplay_ && isShowInSubWindow; if (containerId >= MIN_SUBCONTAINER_ID) { auto parentContainerId = SubwindowManager::GetInstance()->GetParentContainerId(containerId); container = AceEngine::Get().GetContainer(parentContainerId); + CHECK_NULL_VOID(container); + isUIExtensionSubWindow_ = container->IsUIExtensionWindow(); + if (isUIExtensionSubWindow_) { + canExpandCurrentWindow_ = true; + auto subwindow = SubwindowManager::GetInstance()->GetSubwindow(parentContainerId); + CHECK_NULL_VOID(subwindow); + auto rect = subwindow->GetUIExtensionHostWindowRect(); + UIExtensionHostWindowRect_ = RectF(rect.Left(), rect.Top(), rect.Width(), rect.Height()); + TAG_LOGI(AceLogTag::ACE_MENU, "GetUIExtensionHostWindowRect : %{public}s", + UIExtensionHostWindowRect_.ToString().c_str()); + } } - if (SubwindowManager::GetInstance()->IsFreeMultiWindow(containerId)) { - hierarchicalParameters_ = true; - } +} - CHECK_NULL_VOID(container); - if (container->IsUIExtensionWindow()) { - if (menuWrapperPattern->IsContextMenu()) { - hierarchicalParameters_ = true; - } +Rect MenuLayoutAlgorithm::GetMenuWindowRectInfo(const RefPtr& menuPattern) +{ + auto menuWindowRect = Rect(); + CHECK_NULL_RETURN(menuPattern, menuWindowRect); + auto pipelineContext = GetCurrentPipelineContext(); + CHECK_NULL_RETURN(pipelineContext, menuWindowRect); + auto rect = pipelineContext->GetDisplayWindowRectInfo(); + displayWindowRect_ = RectF(rect.Left(), rect.Top(), rect.Width(), rect.Height()); + TAG_LOGI(AceLogTag::ACE_MENU, "GetDisplayWindowRectInfo : %{public}s", displayWindowRect_.ToString().c_str()); + menuWindowRect = Rect(rect.Left(), rect.Top(), rect.Width(), rect.Height()); + auto availableRect = pipelineContext->GetDisplayAvailableRect(); + TAG_LOGI(AceLogTag::ACE_MENU, "GetDisplayAvailableRect : %{public}s", availableRect.ToString().c_str()); + if (canExpandCurrentWindow_ && isExpandDisplay_) { + menuWindowRect = Rect(availableRect.Left(), availableRect.Top(), availableRect.Width(), availableRect.Height()); + } else if (isUIExtensionSubWindow_ && !isExpandDisplay_) { + rect = Rect(UIExtensionHostWindowRect_.Left(), UIExtensionHostWindowRect_.Top(), + UIExtensionHostWindowRect_.Width(), UIExtensionHostWindowRect_.Height()); + menuWindowRect = rect; + } + TAG_LOGI(AceLogTag::ACE_MENU, "GetMenuWindowRectInfo : %{public}s", menuWindowRect.ToString().c_str()); + dumpInfo_.menuWindowRect = menuWindowRect; + return menuWindowRect; +} + +void MenuLayoutAlgorithm::ModifyTargetOffset() +{ + TAG_LOGI(AceLogTag::ACE_MENU, "original targetOffset is : %{public}s", targetOffset_.ToString().c_str()); + if (canExpandCurrentWindow_ && isExpandDisplay_) { + targetOffset_ += displayWindowRect_.GetOffset(); + TAG_LOGI(AceLogTag::ACE_MENU, "ModifyTargetOffset for displayAvailableRect : %{public}s", + targetOffset_.ToString().c_str()); + } else if (isUIExtensionSubWindow_ && !isExpandDisplay_) { + targetOffset_ += displayWindowRect_.GetOffset() - UIExtensionHostWindowRect_.GetOffset(); + TAG_LOGI(AceLogTag::ACE_MENU, "ModifyTargetOffset for UIExtensionHostWindowRect : %{public}s", + targetOffset_.ToString().c_str()); } } diff --git a/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.h b/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.h index 52708394b20..5069050254b 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.h +++ b/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.h @@ -38,6 +38,7 @@ struct MenuDumpInfo { std::string targetNode; OffsetF targetOffset; SizeF targetSize; + Rect menuWindowRect; Rect wrapperRect; float previewBeginScale = 0.0f; float previewEndScale = 0.0f; @@ -47,6 +48,7 @@ struct MenuDumpInfo { float right = 0.0f; OffsetF globalLocation; std::string originPlacement; + std::string defaultPlacement; OffsetF finalPosition; std::string finalPlacement = "NONE"; }; @@ -75,9 +77,10 @@ public: return clipPath_; } - bool hierarchicalParameters_ = false; - void InitHierarchicalParameters(bool isShowInSubWindow, const RefPtr& menuPattern); + bool canExpandCurrentWindow_ = false; + void InitCanExpandCurrentWindow(bool isShowInSubWindow); bool CheckIsEmbeddedMode(LayoutWrapper* layoutWrapper); + Rect GetMenuWindowRectInfo(const RefPtr& menuPattern); protected: float VerticalLayout(const SizeF& size, float clickPosition, bool IsContextMenu = false); @@ -93,6 +96,21 @@ protected: SizeF wrapperSize_; // rect is relative to menuWrapper Rect wrapperRect_; + struct PreviewMenuParam { + SizeF windowGlobalSizeF; + Rect menuWindowRect; + float windowsOffsetX = 0.0f; + float windowsOffsetY = 0.0f; + float top = 0.0f; + float bottom = 0.0f; + float left = 0.0f; + float right = 0.0f; + float topSecurity = 0.0f; + float bottomSecurity = 0.0f; + float previewMenuGap = 0.0f; + float menuItemTotalHeight = 0.0f; + }; + PreviewMenuParam param_; private: enum class ErrorPositionType { @@ -107,19 +125,6 @@ private: Left_Direction, None_Direction, }; - struct PreviewMenuParam { - SizeF windowGlobalSizeF; - float windowsOffsetX = 0.0f; - float windowsOffsetY = 0.0f; - float top = 0.0f; - float bottom = 0.0f; - float left = 0.0f; - float right = 0.0f; - float topSecurity = 0.0f; - float bottomSecurity = 0.0f; - float previewMenuGap = 0.0f; - float menuItemTotalHeight = 0.0f; - }; void Initialize(LayoutWrapper* layoutWrapper); void InitializePadding(LayoutWrapper* layoutWrapper); @@ -234,6 +239,8 @@ private: void UpdateChildConstraintByDevice(const RefPtr& menuPattern, LayoutConstraintF& childConstraint, const LayoutConstraintF& layoutConstraint); void CheckPreviewConstraint(const RefPtr& frameNode, const Rect& windowGlobalRect); + void ModifyTargetOffset(); + std::string MoveTo(double x, double y); std::string LineTo(double x, double y); std::string ArcTo(double rx, double ry, double rotation, int32_t arc_flag, double x, double y); @@ -307,9 +314,13 @@ private: bool isHalfFoldHover_ = false; // previewScale_ must be greater than 0 float previewScale_ = 1.0f; - PreviewMenuParam param_; MenuDumpInfo dumpInfo_; MarginPropertyF layoutRegionMargin_; + bool isExpandDisplay_ = false; + bool isFreeMultiWindow_ = false; + bool isUIExtensionSubWindow_ = false; + RectF displayWindowRect_; + RectF UIExtensionHostWindowRect_; OffsetF childOffset_; SizeF childMarginFrameSize_; diff --git a/frameworks/core/components_ng/pattern/menu/sub_menu_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/menu/sub_menu_layout_algorithm.cpp index 89cebd4c39f..1309cbba5ed 100644 --- a/frameworks/core/components_ng/pattern/menu/sub_menu_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/menu/sub_menu_layout_algorithm.cpp @@ -31,7 +31,7 @@ void SubMenuLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper) CHECK_NULL_VOID(props); auto parentMenuItem = menuPattern->GetParentMenuItem(); CHECK_NULL_VOID(parentMenuItem); - InitHierarchicalParameters(props->GetShowInSubWindowValue(false), menuPattern); + InitCanExpandCurrentWindow(props->GetShowInSubWindowValue(false)); if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN)) { ModifySubMenuWrapper(layoutWrapper); } @@ -54,7 +54,7 @@ void SubMenuLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper) auto isContainerModal = pipelineContext->GetWindowModal() == WindowModal::CONTAINER_MODAL && windowManager && windowManager->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING; OffsetF wrapperOffset; - if (!hierarchicalParameters_) { + if (!canExpandCurrentWindow_) { if (isContainerModal) { auto newOffsetX = static_cast(CONTAINER_BORDER_WIDTH.ConvertToPx()) + static_cast(CONTENT_PADDING.ConvertToPx()); @@ -101,7 +101,7 @@ OffsetF SubMenuLayoutAlgorithm::MenuLayoutAvoidAlgorithm(const RefPtr float x = HorizontalLayoutSubMenu(size, position_.GetX(), menuItemSize); x = std::clamp(x, paddingStart_, wrapperSize_.Width() - size.Width() - paddingEnd_); float y = 0.0f; - if (hierarchicalParameters_ || !Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN)) { + if (canExpandCurrentWindow_ || !Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN)) { y = VerticalLayoutSubMenu(size, position_.GetY(), menuItemSize); } else { y = VerticalLayoutSubMenuHalfScreen(size, position_.GetY(), menuItemSize); @@ -136,7 +136,7 @@ OffsetF SubMenuLayoutAlgorithm::GetSubMenuPosition(const RefPtr& pare CHECK_NULL_RETURN(windowManager, OffsetF()); auto isContainerModal = pipelineContext->GetWindowModal() == WindowModal::CONTAINER_MODAL && windowManager && windowManager->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING; - if (!hierarchicalParameters_) { + if (!canExpandCurrentWindow_) { if (isContainerModal) { auto newOffsetX = static_cast(CONTAINER_BORDER_WIDTH.ConvertToPx()) + static_cast(CONTENT_PADDING.ConvertToPx()); @@ -172,11 +172,9 @@ float SubMenuLayoutAlgorithm::VerticalLayoutSubMenuHalfScreen( CHECK_NULL_RETURN(pipelineContext, 0.0f); auto safeAreaManager = pipelineContext->GetSafeAreaManager(); CHECK_NULL_RETURN(safeAreaManager, 0.0f); - auto windowGlobalRect = pipelineContext->GetDisplayWindowRectInfo(); - float windowsOffsetY = static_cast(windowGlobalRect.GetOffset().GetY()); float wrapperHeight = wrapperSize_.Height(); - float bottomSpace = wrapperSize_.Height() - (position_.GetY() - windowsOffsetY) - margin_ * 2.0f; + float bottomSpace = wrapperSize_.Height() - (position_.GetY() - param_.windowsOffsetY) - margin_ * 2.0f; // line up top of subMenu with top of the menuItem if (bottomSpace >= size.Height()) { return position; @@ -244,10 +242,9 @@ void SubMenuLayoutAlgorithm::ModifySubMenuWrapper(LayoutWrapper* layoutWrapper) CHECK_NULL_VOID(pipelineContext); auto safeAreaManager = pipelineContext->GetSafeAreaManager(); CHECK_NULL_VOID(safeAreaManager); - auto windowGlobalRect = pipelineContext->GetDisplayWindowRectInfo(); auto bottom = safeAreaManager->GetSystemSafeArea().bottom_.Length(); - if (!hierarchicalParameters_) { - wrapperSize_ = SizeF(windowGlobalRect.Width(), windowGlobalRect.Height() - bottom); + if (!canExpandCurrentWindow_) { + wrapperSize_ = SizeF(param_.menuWindowRect.Width(), param_.menuWindowRect.Height() - bottom); } else { wrapperSize_ = SizeF(wrapperSize_.Width(), wrapperSize_.Height()); } @@ -284,7 +281,7 @@ void SubMenuLayoutAlgorithm::InitializePaddingAPI12(LayoutWrapper* layoutWrapper CHECK_NULL_VOID(theme); if (!menuPattern->IsSelectOverlayExtensionMenu()) { margin_ = static_cast(theme->GetOutPadding().ConvertToPx()); - if (!hierarchicalParameters_) { + if (!canExpandCurrentWindow_) { paddingStart_ = static_cast(theme->GetMenuLargeMargin().ConvertToPx()); paddingEnd_ = static_cast(theme->GetMenuLargeMargin().ConvertToPx()); } else { diff --git a/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.cpp b/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.cpp index 22d69fce16c..a15c00102e5 100644 --- a/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.cpp +++ b/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.cpp @@ -771,6 +771,7 @@ void MenuWrapperPattern::DumpInfo() DumpLog::GetInstance().AddDesc("TargetNode: " + dumpInfo_.targetNode); DumpLog::GetInstance().AddDesc("TargetOffset: " + dumpInfo_.targetOffset.ToString()); DumpLog::GetInstance().AddDesc("TargetSize: " + dumpInfo_.targetSize.ToString()); + DumpLog::GetInstance().AddDesc("MenuWindowRect: " + dumpInfo_.menuWindowRect.ToString()); DumpLog::GetInstance().AddDesc("WrapperRect: " + dumpInfo_.wrapperRect.ToString()); DumpLog::GetInstance().AddDesc("PreviewBeginScale: " + std::to_string(dumpInfo_.previewBeginScale)); DumpLog::GetInstance().AddDesc("PreviewEndScale: " + std::to_string(dumpInfo_.previewEndScale)); @@ -778,6 +779,7 @@ void MenuWrapperPattern::DumpInfo() DumpLog::GetInstance().AddDesc("Bottom: " + std::to_string(dumpInfo_.bottom)); DumpLog::GetInstance().AddDesc("GlobalLocation: " + dumpInfo_.globalLocation.ToString()); DumpLog::GetInstance().AddDesc("OriginPlacement: " + dumpInfo_.originPlacement); + DumpLog::GetInstance().AddDesc("DefaultPlacement: " + dumpInfo_.defaultPlacement); DumpLog::GetInstance().AddDesc("FinalPosition: " + dumpInfo_.finalPosition.ToString()); DumpLog::GetInstance().AddDesc("FinalPlacement: " + dumpInfo_.finalPlacement); } @@ -791,6 +793,7 @@ void MenuWrapperPattern::DumpInfo(std::unique_ptr& json) json->Put("TargetOffset", dumpInfo_.targetOffset.ToString().c_str()); json->Put("TargetSize", dumpInfo_.targetSize.ToString().c_str()); + json->Put("MenuWindowRect", dumpInfo_.menuWindowRect.ToString().c_str()); json->Put("WrapperRect", dumpInfo_.wrapperRect.ToString().c_str()); json->Put("PreviewBeginScale", std::to_string(dumpInfo_.previewBeginScale).c_str()); json->Put("PreviewEndScale", std::to_string(dumpInfo_.previewEndScale).c_str()); @@ -799,6 +802,7 @@ void MenuWrapperPattern::DumpInfo(std::unique_ptr& json) json->Put("Bottom", std::to_string(dumpInfo_.bottom).c_str()); json->Put("GlobalLocation", dumpInfo_.globalLocation.ToString().c_str()); json->Put("OriginPlacement", dumpInfo_.originPlacement.c_str()); + json->Put("DefaultPlacement", dumpInfo_.defaultPlacement.c_str()); json->Put("FinalPosition", dumpInfo_.finalPosition.ToString().c_str()); json->Put("FinalPlacement", dumpInfo_.finalPlacement.c_str()); } diff --git a/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h b/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h index f55d9c03122..93108e9d36e 100644 --- a/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h +++ b/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h @@ -371,6 +371,7 @@ public: dumpInfo_.targetNode = dumpInfo.targetNode; dumpInfo_.targetOffset = dumpInfo.targetOffset; dumpInfo_.targetSize = dumpInfo.targetSize; + dumpInfo_.menuWindowRect = dumpInfo.menuWindowRect; dumpInfo_.wrapperRect = dumpInfo.wrapperRect; dumpInfo_.previewBeginScale = dumpInfo.previewBeginScale; dumpInfo_.previewEndScale = dumpInfo.previewEndScale; @@ -378,6 +379,7 @@ public: dumpInfo_.bottom = dumpInfo.bottom; dumpInfo_.globalLocation = dumpInfo.globalLocation; dumpInfo_.originPlacement = dumpInfo.originPlacement; + dumpInfo_.defaultPlacement = dumpInfo.defaultPlacement; dumpInfo_.finalPosition = dumpInfo.finalPosition; dumpInfo_.finalPlacement = dumpInfo.finalPlacement; } diff --git a/test/unittest/core/pattern/menu/menu_layoutFst_test_ng.cpp b/test/unittest/core/pattern/menu/menu_layoutFst_test_ng.cpp index b5fc5684bd3..39a6e3b27ee 100644 --- a/test/unittest/core/pattern/menu/menu_layoutFst_test_ng.cpp +++ b/test/unittest/core/pattern/menu/menu_layoutFst_test_ng.cpp @@ -1747,7 +1747,7 @@ HWTEST_F(MenuLayout1TestNg, MenuLayoutAlgorithmTestNg041, TestSize.Level1) } /** * @tc.name: MenuLayoutAlgorithmTestNg044 - * @tc.desc: Verify InitHierarchicalParameters. + * @tc.desc: Verify InitCanExpandCurrentWindow. * @tc.type: FUNC */ HWTEST_F(MenuLayout1TestNg, MenuLayoutAlgorithmTestNg044, TestSize.Level1) @@ -1788,14 +1788,14 @@ HWTEST_F(MenuLayout1TestNg, MenuLayoutAlgorithmTestNg044, TestSize.Level1) selectTheme->expandDisplay_ = true; EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(selectTheme)); - layoutAlgorithm->InitHierarchicalParameters(false, menuPattern); + layoutAlgorithm->InitCanExpandCurrentWindow(false); menuPattern->isSelectMenu_ = true; - layoutAlgorithm->InitHierarchicalParameters(false, menuPattern); + layoutAlgorithm->InitCanExpandCurrentWindow(false); } /** * @tc.name: MenuLayoutAlgorithmTestNg045 - * @tc.desc: Verify InitHierarchicalParameters. + * @tc.desc: Verify InitCanExpandCurrentWindow. * @tc.type: FUNC */ HWTEST_F(MenuLayout1TestNg, MenuLayoutAlgorithmTestNg045, TestSize.Level1) @@ -1827,9 +1827,7 @@ HWTEST_F(MenuLayout1TestNg, MenuLayoutAlgorithmTestNg045, TestSize.Level1) layoutWrapper.GetLayoutProperty()->UpdateContentConstraint(); layoutAlgorithm->Measure(&layoutWrapper); layoutAlgorithm->Layout(&layoutWrapper); - auto menuPattern = menuNode->GetPattern(); - CHECK_NULL_VOID(menuPattern); - layoutAlgorithm->InitHierarchicalParameters(false, menuPattern); + layoutAlgorithm->InitCanExpandCurrentWindow(false); } /** @@ -1860,7 +1858,7 @@ HWTEST_F(MenuLayout1TestNg, MenuLayoutAlgorithmTestNg046, TestSize.Level1) RefPtr layoutAlgorithm = AceType::MakeRefPtr(); RefPtr geometryNode = AceType::MakeRefPtr(); - layoutAlgorithm->hierarchicalParameters_ = true; + layoutAlgorithm->canExpandCurrentWindow_ = true; LayoutWrapperNode layoutWrapper(menuNode, geometryNode, menuNode->GetLayoutProperty()); Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TWELVE); layoutWrapper.GetLayoutProperty()->UpdateUserDefinedIdealSize( @@ -1906,7 +1904,7 @@ HWTEST_F(MenuLayout1TestNg, MenuLayoutAlgorithmTestNg047, TestSize.Level1) RefPtr layoutAlgorithm = AceType::MakeRefPtr(); RefPtr geometryNode = AceType::MakeRefPtr(); - layoutAlgorithm->hierarchicalParameters_ = true; + layoutAlgorithm->canExpandCurrentWindow_ = true; LayoutWrapperNode layoutWrapper(menuNode, geometryNode, menuNode->GetLayoutProperty()); Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TWELVE); layoutWrapper.GetLayoutProperty()->UpdateUserDefinedIdealSize( @@ -1953,7 +1951,7 @@ HWTEST_F(MenuLayout1TestNg, MenuLayoutAlgorithmTestNg048, TestSize.Level1) RefPtr layoutAlgorithm = AceType::MakeRefPtr(); RefPtr geometryNode = AceType::MakeRefPtr(); - layoutAlgorithm->hierarchicalParameters_ = true; + layoutAlgorithm->canExpandCurrentWindow_ = true; LayoutWrapperNode layoutWrapper(menuNode, geometryNode, menuNode->GetLayoutProperty()); Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN); layoutWrapper.GetLayoutProperty()->UpdateUserDefinedIdealSize( diff --git a/test/unittest/core/pattern/menu/menu_layoutScd_test_ng.cpp b/test/unittest/core/pattern/menu/menu_layoutScd_test_ng.cpp index dc893a06e60..4daeb22b901 100644 --- a/test/unittest/core/pattern/menu/menu_layoutScd_test_ng.cpp +++ b/test/unittest/core/pattern/menu/menu_layoutScd_test_ng.cpp @@ -1341,7 +1341,7 @@ HWTEST_F(MenuLayout2TestNg, MenuLayoutAlgorithmTestNg5910, TestSize.Level1) ASSERT_NE(menuNode, nullptr); RefPtr layoutAlgorithm = AceType::MakeRefPtr(); - layoutAlgorithm->hierarchicalParameters_ = true; + layoutAlgorithm->canExpandCurrentWindow_ = true; RefPtr geometryNode = AceType::MakeRefPtr(); LayoutWrapperNode layoutWrapper(menuNode, geometryNode, menuNode->GetLayoutProperty()); layoutWrapper.GetLayoutProperty()->UpdateUserDefinedIdealSize( @@ -1392,7 +1392,7 @@ HWTEST_F(MenuLayout2TestNg, MenuLayoutAlgorithmTestNg5920, TestSize.Level1) ASSERT_NE(menuNode, nullptr); RefPtr layoutAlgorithm = AceType::MakeRefPtr(); - layoutAlgorithm->hierarchicalParameters_ = true; + layoutAlgorithm->canExpandCurrentWindow_ = true; RefPtr geometryNode = AceType::MakeRefPtr(); LayoutWrapperNode layoutWrapper(menuNode, geometryNode, menuNode->GetLayoutProperty()); layoutWrapper.GetLayoutProperty()->UpdateUserDefinedIdealSize( @@ -1547,7 +1547,7 @@ HWTEST_F(MenuLayout2TestNg, SubMenuLayoutAlgorithmTestNg002, TestSize.Level1) * @tc.steps: step3. call the InitializePaddingAPI12 method. * @tc.expected: padding is not zero */ - algorithm->hierarchicalParameters_ = true; + algorithm->canExpandCurrentWindow_ = true; auto selectTheme = MockPipelineContext::GetCurrent()->GetTheme(); selectTheme->menuMediumMargin_ = 10.0_vp; algorithm->InitializePaddingAPI12(wrapper); @@ -1624,7 +1624,7 @@ HWTEST_F(MenuLayout2TestNg, SubMenuLayoutAlgorithmTestNg003, TestSize.Level1) * @tc.cases: case2. layering parameter is false. * @tc.expected: padding is not zero */ - algorithm->hierarchicalParameters_ = false; + algorithm->canExpandCurrentWindow_ = false; auto selectTheme = MockPipelineContext::GetCurrent()->GetTheme(); selectTheme->menuLargeMargin_ = 10.0_vp; algorithm->InitializePaddingAPI12(wrapper); @@ -1668,7 +1668,7 @@ HWTEST_F(MenuLayout2TestNg, MenuLayoutAlgorithmTestNg5900, TestSize.Level1) * @tc.expected: no exception in the method return value. */ RefPtr layoutAlgorithm = AceType::MakeRefPtr(); - layoutAlgorithm->hierarchicalParameters_ = true; + layoutAlgorithm->canExpandCurrentWindow_ = true; RefPtr geometryNode = AceType::MakeRefPtr(); LayoutWrapperNode layoutWrapper(menuNode, geometryNode, menuNode->GetLayoutProperty()); layoutWrapper.GetLayoutProperty()->UpdateUserDefinedIdealSize( @@ -1720,7 +1720,7 @@ HWTEST_F(MenuLayout2TestNg, MenuLayoutAlgorithmTestNg6000, TestSize.Level1) * @tc.expected: no exception in the method return value. */ RefPtr layoutAlgorithm = AceType::MakeRefPtr(); - layoutAlgorithm->hierarchicalParameters_ = false; + layoutAlgorithm->canExpandCurrentWindow_ = false; RefPtr geometryNode = AceType::MakeRefPtr(); LayoutWrapperNode layoutWrapper(menuNode, geometryNode, menuNode->GetLayoutProperty()); layoutWrapper.GetLayoutProperty()->UpdateUserDefinedIdealSize( diff --git a/test/unittest/core/pattern/menu/menu_layoutThi_test_ng.cpp b/test/unittest/core/pattern/menu/menu_layoutThi_test_ng.cpp index a8a9da5e7c0..7a83633d145 100644 --- a/test/unittest/core/pattern/menu/menu_layoutThi_test_ng.cpp +++ b/test/unittest/core/pattern/menu/menu_layoutThi_test_ng.cpp @@ -419,9 +419,9 @@ HWTEST_F(MenuLayout3TestNg, InitWrapperRect001, TestSize.Level1) int32_t backApiVersion = context->GetMinPlatformVersion(); context->SetMinPlatformVersion(static_cast(PlatformVersion::VERSION_TWELVE)); - menuAlgorithm->hierarchicalParameters_ = true; + menuAlgorithm->canExpandCurrentWindow_ = true; menuAlgorithm->InitWrapperRect(props, menuPattern); - menuAlgorithm->hierarchicalParameters_ = false; + menuAlgorithm->canExpandCurrentWindow_ = false; menuAlgorithm->InitWrapperRect(props, menuPattern); EXPECT_EQ(menuAlgorithm->wrapperRect_.Width(), FULL_SCREEN_WIDTH); EXPECT_EQ(menuAlgorithm->wrapperRect_.Height(), FULL_SCREEN_HEIGHT - KEYBOARD_HEIGHT); diff --git a/test/unittest/core/pattern/menu/menu_origin_test_ng.cpp b/test/unittest/core/pattern/menu/menu_origin_test_ng.cpp index cd3703c792d..4c07e6351f6 100644 --- a/test/unittest/core/pattern/menu/menu_origin_test_ng.cpp +++ b/test/unittest/core/pattern/menu/menu_origin_test_ng.cpp @@ -1990,7 +1990,7 @@ HWTEST_F(MenuTestNg, MenuLayoutAlgorithmAPI11PaddingTest1, TestSize.Level1) * @tc.steps: step3. call the InitializePaddingAPI12 method. * @tc.expected: padding is not zero */ - algorithm->hierarchicalParameters_ = true; + algorithm->canExpandCurrentWindow_ = true; auto selectTheme = MockPipelineContext::GetCurrent()->GetTheme(); selectTheme->menuMediumMargin_ = 10.0_vp; algorithm->InitializePaddingAPI12(wrapper); @@ -2058,7 +2058,7 @@ HWTEST_F(MenuTestNg, MenuLayoutAlgorithmAPI11PaddingTest2, TestSize.Level1) * @tc.steps: step3. call the InitializePaddingAPI12 method. * @tc.expected: padding is not zero */ - algorithm->hierarchicalParameters_ = false; + algorithm->canExpandCurrentWindow_ = false; auto selectTheme = MockPipelineContext::GetCurrent()->GetTheme(); selectTheme->outPadding_ = 10.0_vp; selectTheme->menuLargeMargin_ = 10.0_vp; diff --git a/test/unittest/core/pattern/menu/menuitem_pattern_test_ng.cpp b/test/unittest/core/pattern/menu/menuitem_pattern_test_ng.cpp index d1693782d30..a459e8598b8 100644 --- a/test/unittest/core/pattern/menu/menuitem_pattern_test_ng.cpp +++ b/test/unittest/core/pattern/menu/menuitem_pattern_test_ng.cpp @@ -1121,7 +1121,7 @@ HWTEST_F(MenuItemPatternTestNg, MenuItemPatternTestNg010, TestSize.Level1) * @tc.cases: case1. the hierarchicalParameter is true. * @tc.expected: algorithm is not null and sub menu show correctly. */ - algorithm->hierarchicalParameters_ = true; + algorithm->canExpandCurrentWindow_ = true; subMenuPattern->SetParentMenuItem(menuItemNode); auto geometryNode = AceType::MakeRefPtr(); geometryNode->SetFrameSize(SizeF(MENU_SIZE_WIDTH, MENU_SIZE_HEIGHT)); @@ -1191,7 +1191,7 @@ HWTEST_F(MenuItemPatternTestNg, MenuItemPatternTestNg011, TestSize.Level1) * @tc.cases: case1. the hierarchicalParameter is false. * @tc.expected: algorithm is not null and sub menu show correctly. */ - algorithm->hierarchicalParameters_ = false; + algorithm->canExpandCurrentWindow_ = false; subMenuPattern->SetParentMenuItem(menuItemNode); auto geometryNode = AceType::MakeRefPtr(); geometryNode->SetFrameSize(SizeF(MENU_SIZE_WIDTH, MENU_SIZE_HEIGHT)); -- Gitee