diff --git a/frameworks/core/components/popup/popup_theme.h b/frameworks/core/components/popup/popup_theme.h index 4605999844e8a4cac5e070295c74df5dd243f333..16a52f2d0baeaf442b318e45d94d8a384ee744ea 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 6a5b5696ac2bb19509eed234db3247e23e6e88d2..ee99950f536b57ed39fd71d3273335c82ac4f50f 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 0be1b3a42548456d167e5e7a5246714423cc10ce..f63606671d61ac16c1ce96436dabf812426ca5e3 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;