diff --git a/frameworks/core/components_ng/base/modifier.h b/frameworks/core/components_ng/base/modifier.h index 0bd49c543b2df9a2f4bcf1cb2eeecf4870ba2066..08e29153f735ea61dbfbdc61400bbde76492516b 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 23c482e2e3c1464d45733ef01afa91d1f22741d8..3fa52bbf16ce3e6cbe482f6acd4452e5698ae71e 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 16127e326048e432957f4156b53d73f9534d35fc..dcb0305219bd0407fbc67d22fc3425803bad3533 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