From f3027670aba4b0e14796a2faf979e2c5bea271bd Mon Sep 17 00:00:00 2001 From: jiangdayuan Date: Thu, 3 Mar 2022 19:58:57 +0800 Subject: [PATCH] add window title hide split button when window mode is split type Signed-off-by: jiangdayuan Change-Id: I24e9bb28fe9e16c11013d8accc19d4c8da737100 --- .../container_modal_component.cpp | 22 +++++++++--------- .../container_modal_element.cpp | 23 +++++++++++++++---- .../components/padding/render_padding.cpp | 2 -- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/frameworks/core/components/container_modal/container_modal_component.cpp b/frameworks/core/components/container_modal/container_modal_component.cpp index ae5ad46ab50..48c618db451 100644 --- a/frameworks/core/components/container_modal/container_modal_component.cpp +++ b/frameworks/core/components/container_modal/container_modal_component.cpp @@ -205,18 +205,18 @@ std::list> ContainerModalComponent::BuildTitleChildren(bool is auto buttonResourceId = isFloating ? InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_RECOVER : InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_MAXIMIZE; auto titleMaximizeRecoverButton = BuildControlButton(buttonResourceId, [contextWptr]() { - auto context = contextWptr.Upgrade(); - if (context) { - auto mode = context->FireWindowGetModeCallBack(); - if (mode == WindowMode::WINDOW_MODE_FULLSCREEN) { - LOGI("recover button clicked"); - context->FireWindowRecoverCallBack(); - } else { - LOGI("maximize button clicked"); - context->FireWindowMaximizeCallBack(); - } + auto context = contextWptr.Upgrade(); + if (context) { + auto mode = context->FireWindowGetModeCallBack(); + if (mode == WindowMode::WINDOW_MODE_FULLSCREEN) { + LOGI("recover button clicked"); + context->FireWindowRecoverCallBack(); + } else { + LOGI("maximize button clicked"); + context->FireWindowMaximizeCallBack(); } - }); + } + }); auto titleMinimizeButton = BuildControlButton(InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_MINIMIZE, [contextWptr]() { auto context = contextWptr.Upgrade(); diff --git a/frameworks/core/components/container_modal/container_modal_element.cpp b/frameworks/core/components/container_modal/container_modal_element.cpp index 329b3abe37a..1f11f8ce5c1 100644 --- a/frameworks/core/components/container_modal/container_modal_element.cpp +++ b/frameworks/core/components/container_modal/container_modal_element.cpp @@ -20,12 +20,14 @@ #include "core/components/container_modal/render_container_modal.h" #include "core/components/flex/flex_element.h" #include "core/components/flex/flex_item_element.h" +#include "core/components/padding/render_padding.h" #include "core/gestures/tap_gesture.h" namespace OHOS::Ace { namespace { constexpr uint32_t COLUMN_CHILD_NUM = 2; +constexpr uint32_t SPLIT_BUTTON_POSITION = 2; constexpr uint32_t TITLE_POPUP_TIME = 500; // 500ms constexpr double TITLE_POPUP_DISTANCE = 100.0; // 100px @@ -332,16 +334,27 @@ void ContainerModalElement::ChangeFloatingTitleIcon() LOGE("ChangeFloatingTitleIcon failed, context is null."); return; } - auto row = AceType::DynamicCast(floatingTitleBox_->GetFirstChild()); - if (!row) { - LOGE("ChangeFloatingTitleIcon failed, row element is null"); + auto rowElement = AceType::DynamicCast(floatingTitleBox_->GetFirstChild()); + if (!rowElement) { + LOGE("ChangeFloatingTitleIcon failed, row element is null."); return; } + auto renderRow = AceType::DynamicCast(rowElement->GetRenderNode()); + if (!renderRow) { + LOGE("ChangeFloatingTitleIcon failed, renderRow is null."); + return; + } + auto iterator = renderRow->GetChildren().begin(); + std::advance(iterator, SPLIT_BUTTON_POSITION); + auto splitButton = AceType::DynamicCast(*iterator); + auto mode = context->FireWindowGetModeCallBack(); if (mode == WindowMode::WINDOW_MODE_FULLSCREEN) { - row->SetUpdateComponent(floatingTitleChildrenRow_); + rowElement->SetUpdateComponent(floatingTitleChildrenRow_); + splitButton->SetHidden(false); } else { - row->SetUpdateComponent(titleChildrenRow_); + rowElement->SetUpdateComponent(titleChildrenRow_); + splitButton->SetHidden(true); } } diff --git a/frameworks/core/components/padding/render_padding.cpp b/frameworks/core/components/padding/render_padding.cpp index 86d866b114e..a7f5d08d8a8 100644 --- a/frameworks/core/components/padding/render_padding.cpp +++ b/frameworks/core/components/padding/render_padding.cpp @@ -15,8 +15,6 @@ #include "core/components/padding/render_padding.h" -#include "base/log/log.h" -#include "base/utils/utils.h" #include "core/components/padding/padding_component.h" namespace OHOS::Ace { -- Gitee