From 88bcba787b6f73e556137af1b8053ac48090bd64 Mon Sep 17 00:00:00 2001 From: sunxuhui Date: Mon, 23 Jun 2025 02:49:15 +0000 Subject: [PATCH] slider Signed-off-by: sunxuhui Change-Id: I684b99da60a688b547484c6beaf6a0dd55a4ea1e --- .../slider/slider_layout_algorithm.cpp | 20 +++++++++++++++++++ .../pattern/slider/slider_pattern.h | 6 +++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/frameworks/core/components_ng/pattern/slider/slider_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/slider/slider_layout_algorithm.cpp index 46472b8a543..dfa75b5e92a 100644 --- a/frameworks/core/components_ng/pattern/slider/slider_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/slider/slider_layout_algorithm.cpp @@ -84,6 +84,26 @@ std::optional SliderLayoutAlgorithm::MeasureContent( float width = contentConstraint.selfIdealSize.Width().value_or(contentConstraint.maxSize.Width()); float height = contentConstraint.selfIdealSize.Height().value_or(contentConstraint.maxSize.Height()); + auto layoutPolicy = layoutWrapper->GetLayoutProperty()->GetLayoutPolicyProperty(); + auto widthLayoutPolicy = LayoutCalPolicy::NO_MATCH; + auto heightLayoutPolicy = LayoutCalPolicy::NO_MATCH; + + if (layoutPolicy.has_value()) { + widthLayoutPolicy = layoutPolicy.value().widthLayoutPolicy_.value_or(LayoutCalPolicy::NO_MATCH); + heightLayoutPolicy = layoutPolicy.value().heightLayoutPolicy_.value_or(LayoutCalPolicy::NO_MATCH); + LOGE("test----widthLayoutPolicy: %{public}d, heightLayoutPolicy: %{public}d", widthLayoutPolicy, heightLayoutPolicy); + } + + + if (widthLayoutPolicy == LayoutCalPolicy::MATCH_PARENT) { + width = contentConstraint.parentIdealSize.Width().value(); + LOGE("TEST--width: %{public}f", width); + } + + if (heightLayoutPolicy == LayoutCalPolicy::MATCH_PARENT) { + height = contentConstraint.parentIdealSize.Height().value(); + LOGE("TEST--height: %{public}f", height); + } Axis direction = sliderLayoutProperty->GetDirection().value_or(Axis::HORIZONTAL); if (direction == Axis::HORIZONTAL && GreaterOrEqualToInfinity(width)) { width = static_cast(theme->GetLayoutMaxLength().ConvertToPx()); diff --git a/frameworks/core/components_ng/pattern/slider/slider_pattern.h b/frameworks/core/components_ng/pattern/slider/slider_pattern.h index 23dc3a9f13e..17c7b762e00 100644 --- a/frameworks/core/components_ng/pattern/slider/slider_pattern.h +++ b/frameworks/core/components_ng/pattern/slider/slider_pattern.h @@ -257,10 +257,14 @@ public: void OnFinishEventTipSize(); void CalculateOffset(); void MountToNavigation(RefPtr& tipNode); - void UpdateSliderComponentColor(const Color& color, const SliderColorType sliderColorType, const Gradient& value); void UpdateSliderComponentMedia(); void UpdateSliderComponentString(const bool isShowTips, const std::string& value); + bool IsEnableMatchParent() override + { + LOGE("slider pattern"); + return true; + } private: void OnAttachToFrameNode() override; -- Gitee