From b47461fb07fab29393bcd60d956b6485b19efce2 Mon Sep 17 00:00:00 2001 From: kangpeng Date: Sat, 13 Sep 2025 17:21:32 +0800 Subject: [PATCH] =?UTF-8?q?[popup]arrow=E9=BB=98=E8=AE=A4=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E6=94=AF=E6=8C=81=E5=B7=AE=E5=BC=82=E5=8C=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kangpeng --- frameworks/core/components/popup/popup_theme.h | 8 ++++++++ .../core/components_ng/pattern/bubble/bubble_view.cpp | 8 ++++++-- test/unittest/core/pattern/bubble/bubble_test_One_ng.cpp | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/frameworks/core/components/popup/popup_theme.h b/frameworks/core/components/popup/popup_theme.h index 4605999844e..16a52f2d0ba 100644 --- a/frameworks/core/components/popup/popup_theme.h +++ b/frameworks/core/components/popup/popup_theme.h @@ -149,6 +149,8 @@ public: theme->buttonTopMargin_ = pattern->GetAttr("popup_button_top_margin", 0.0_vp); theme->buttonBottomMargin_ = pattern->GetAttr("popup_button_bottom_margin", 4.0_vp); theme->popupDoubleButtonIsSameStyle_ = pattern->GetAttr("popup_double_button_is_same_style", 1); + theme->arrowHeight_ = pattern->GetAttr("popup_arrow_height", 8.0_vp); + theme->arrowWidth_ = pattern->GetAttr("popup_arrow_width", 16.0_vp); } }; @@ -304,6 +306,11 @@ public: return arrowHeight_; } + const Dimension& GetArrowWidth() const + { + return arrowWidth_; + } + float GetPopupAnimationOffset() const { return popupAnimationOffset_; @@ -543,6 +550,7 @@ private: Dimension buttonSpacing = 4.0_vp; Dimension littlePadding_ = 4.0_vp; Dimension arrowHeight_ = 8.0_vp; + Dimension arrowWidth_ = 16.0_vp; Dimension focusPaintWidth_ = 2.0_vp; Dimension buttonMiniMumWidth = 72.0_vp; Dimension bubbleMiniMumHeight_ = 48.0_vp; diff --git a/frameworks/core/components_ng/pattern/bubble/bubble_view.cpp b/frameworks/core/components_ng/pattern/bubble/bubble_view.cpp index 6a5b5696ac2..ee99950f536 100644 --- a/frameworks/core/components_ng/pattern/bubble/bubble_view.cpp +++ b/frameworks/core/components_ng/pattern/bubble/bubble_view.cpp @@ -202,11 +202,17 @@ RefPtr BubbleView::CreateBubbleNode(const std::string& targetTag, int popupProp->ResetEnableHoverMode(); } + auto popupTheme = GetPopupTheme(); + CHECK_NULL_RETURN(popupTheme, nullptr); if (param->GetArrowHeight().has_value()) { popupProp->UpdateArrowHeight(param->GetArrowHeight().value()); + } else { + popupProp->UpdateArrowHeight(popupTheme->GetArrowHeight()); } if (param->GetArrowWidth().has_value()) { popupProp->UpdateArrowWidth(param->GetArrowWidth().value()); + } else { + popupProp->UpdateArrowWidth(popupTheme->GetArrowWidth()); } if (param->GetRadius().has_value()) { popupProp->UpdateRadius(param->GetRadius().value()); @@ -254,8 +260,6 @@ RefPtr BubbleView::CreateBubbleNode(const std::string& targetTag, int if (param->IsTips()) { bubblePattern->SetTipsTag(true); } - auto popupTheme = GetPopupTheme(); - CHECK_NULL_RETURN(popupTheme, nullptr); // Create child RefPtr child; int textLineHeight = 0; diff --git a/test/unittest/core/pattern/bubble/bubble_test_One_ng.cpp b/test/unittest/core/pattern/bubble/bubble_test_One_ng.cpp index 0be1b3a4254..f63606671d6 100644 --- a/test/unittest/core/pattern/bubble/bubble_test_One_ng.cpp +++ b/test/unittest/core/pattern/bubble/bubble_test_One_ng.cpp @@ -2419,8 +2419,8 @@ HWTEST_F(BubbleTestOneNg, CheckIfNeedRemoveArrow, TestSize.Level1) float xMax = 100.0; float yMin = 0.0; float yMax = 100.0; - Dimension BUBBLE_ARROW_HEIGHT = 8.0_vp; - layoutAlgorithm->arrowHeight_ = BUBBLE_ARROW_HEIGHT.ConvertToPx(); + auto popupTheme = AceType::MakeRefPtr(); + layoutAlgorithm->arrowHeight_ = popupTheme->arrowHeight_.ConvertToPx(); layoutAlgorithm->showArrow_ = true; layoutAlgorithm->avoidKeyboard_ = true; -- Gitee