From c23912021a8676a4d7a6ccc5dd9cd7d8e3441746 Mon Sep 17 00:00:00 2001 From: yeyinglong_admin Date: Sun, 4 Feb 2024 17:42:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=AF=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=86=85=E5=AD=98=E6=B6=88=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yeyinglong_admin --- frameworks/core/components_ng/base/modifier.h | 38 ++----------------- .../render/adapter/rosen_modifier_adapter.cpp | 27 ++++++++++--- .../core/render/mock_modifier_adapter.cpp | 8 ++++ 3 files changed, 32 insertions(+), 41 deletions(-) diff --git a/frameworks/core/components_ng/base/modifier.h b/frameworks/core/components_ng/base/modifier.h index 0bd49c543b2..08e29153f73 100644 --- a/frameworks/core/components_ng/base/modifier.h +++ b/frameworks/core/components_ng/base/modifier.h @@ -92,15 +92,11 @@ public: ~NormalProperty() override = default; void SetUpCallbacks(std::function&& getFunc, std::function&& setFunc, - std::function&& getStageFunc = nullptr, - std::function&& setThresholdTypeFunc = nullptr, - std::function&& setPropertyUnitFunc = nullptr) + std::function&& getStageFunc = nullptr) { getFunc_ = std::move(getFunc); setFunc_ = std::move(setFunc); getStageFunc_ = std::move(getStageFunc); - setThresholdTypeFunc_ = std::move(setThresholdTypeFunc); - setPropertyUnitFunc_ = std::move(setPropertyUnitFunc); } T Get() @@ -112,20 +108,6 @@ public: } } - void SetThresholdType(ThresholdType type) - { - if (setThresholdTypeFunc_) { - setThresholdTypeFunc_(type); - } - } - - void SetPropertyUnit(PropertyUnit unit) - { - if (setPropertyUnitFunc_) { - setPropertyUnitFunc_(unit); - } - } - void Set(const T& value) { if (setFunc_) { @@ -160,8 +142,6 @@ private: std::function setFunc_; std::function getStageFunc_; std::function updateCallback_; - std::function setThresholdTypeFunc_; - std::function setPropertyUnitFunc_; ACE_DISALLOW_COPY_AND_MOVE(NormalProperty); }; @@ -342,21 +322,9 @@ public: } } - void SetThresholdType(ThresholdType type) - { - auto property = AceType::DynamicCast(GetProperty()); - if (property) { - property->SetThresholdType(type); - } - } + void SetThresholdType(ThresholdType type); - void SetPropertyUnit(PropertyUnit unit) - { - auto property = AceType::DynamicCast(GetProperty()); - if (property) { - property->SetPropertyUnit(unit); - } - } + void SetPropertyUnit(PropertyUnit unit); T Get() const { diff --git a/frameworks/core/components_ng/render/adapter/rosen_modifier_adapter.cpp b/frameworks/core/components_ng/render/adapter/rosen_modifier_adapter.cpp index 23c482e2e3c..3fa52bbf16c 100644 --- a/frameworks/core/components_ng/render/adapter/rosen_modifier_adapter.cpp +++ b/frameworks/core/components_ng/render/adapter/rosen_modifier_adapter.cpp @@ -97,12 +97,7 @@ void ContentModifierAdapter::Draw(RSDrawingContext& context) const auto rsProp = std::make_shared>(castProp->Get()); \ castProp->SetUpCallbacks([rsProp]() -> propType { return rsProp->Get(); }, \ [rsProp](const propType& value) { rsProp->Set(value); }, \ - [rsProp]() -> propType { return rsProp->GetStagingValue(); }, \ - [rsProp](ThresholdType type) { if (type == ThresholdType::LAYOUT) { \ - auto rsBaseProp = std::static_pointer_cast(rsProp); \ - rsBaseProp->SetThresholdType(Rosen::ThresholdType::LAYOUT); }}, \ - [rsProp](PropertyUnit unit) { if (unit == PropertyUnit::PIXEL_POSITION) { \ - rsProp->SetPropertyUnit(Rosen::RSPropertyUnit::PIXEL_POSITION); }}); \ + [rsProp]() -> propType { return rsProp->GetStagingValue(); }); \ rsProp->SetUpdateCallback(castProp->GetUpdateCallback()); \ return rsProp; \ } @@ -248,4 +243,24 @@ void NodeAnimatableProperty::AnimateWithVelocity } } } + +template<> +void NodeAnimatableProperty::SetThresholdType(ThresholdType type) +{ + auto modify = std::static_pointer_cast(GetModifyImpl()); + CHECK_NULL_VOID(modify); + auto property = std::static_pointer_cast(modify->GetProperty()); + CHECK_NULL_VOID(property); + property->SetThresholdType(static_cast(type)); +} + +template<> +void NodeAnimatableProperty::SetPropertyUnit(PropertyUnit unit) +{ + auto modify = std::static_pointer_cast(GetModifyImpl()); + CHECK_NULL_VOID(modify); + auto property = std::static_pointer_cast>(modify->GetProperty()); + CHECK_NULL_VOID(property); + property->SetPropertyUnit(static_cast(unit)); +} } // namespace OHOS::Ace::NG diff --git a/test/mock/core/render/mock_modifier_adapter.cpp b/test/mock/core/render/mock_modifier_adapter.cpp index 16127e32604..dcb0305219b 100644 --- a/test/mock/core/render/mock_modifier_adapter.cpp +++ b/test/mock/core/render/mock_modifier_adapter.cpp @@ -25,4 +25,12 @@ void NodeAnimatableProperty::AnimateWithVelocity const AnimationOption &option, float value, float velocity, const FinishCallback &finishCallback) { } +template<> +void NodeAnimatableProperty::SetThresholdType(ThresholdType type) +{ +} +template<> +void NodeAnimatableProperty::SetPropertyUnit(PropertyUnit unit) +{ +} } // namespace OHOS::Ace::NG \ No newline at end of file -- Gitee