From cbe454c4adfea0ab9fcd7b0a79996ca90fa1125f Mon Sep 17 00:00:00 2001 From: Nomango Date: Mon, 12 Oct 2020 20:51:38 +0800 Subject: [PATCH] [deploy] remove Value & ValueObserver --- projects/kiwano/kiwano.vcxproj | 1 - projects/kiwano/kiwano.vcxproj.filters | 3 - src/kiwano/2d/Actor.h | 63 ----------- src/kiwano/core/Common.h | 1 - src/kiwano/core/Value.h | 148 ------------------------- 5 files changed, 216 deletions(-) delete mode 100644 src/kiwano/core/Value.h diff --git a/projects/kiwano/kiwano.vcxproj b/projects/kiwano/kiwano.vcxproj index 7d53d52c..5263f3e8 100644 --- a/projects/kiwano/kiwano.vcxproj +++ b/projects/kiwano/kiwano.vcxproj @@ -45,7 +45,6 @@ - diff --git a/projects/kiwano/kiwano.vcxproj.filters b/projects/kiwano/kiwano.vcxproj.filters index 5b33f584..823c4b29 100644 --- a/projects/kiwano/kiwano.vcxproj.filters +++ b/projects/kiwano/kiwano.vcxproj.filters @@ -336,9 +336,6 @@ core - - core - 2d\animation diff --git a/src/kiwano/2d/Actor.h b/src/kiwano/2d/Actor.h index a06619b4..90d79a7a 100644 --- a/src/kiwano/2d/Actor.h +++ b/src/kiwano/2d/Actor.h @@ -446,69 +446,6 @@ public: /// @brief 设置默认锚点 static void SetDefaultAnchor(float anchor_x, float anchor_y); - /// \~chinese - /// @brief 获取可见性属性 - inline Value VisibleProperty() - { - return Value(visible_); - } - - /// \~chinese - /// @brief 获取不透明度属性 - inline Value OpacityProperty() - { - return Value(opacity_, { dirty_flag_, DirtyFlag::DirtyOpacity }); - } - - /// \~chinese - /// @brief 获取锚点属性 - inline Value AnchorProperty() - { - return Value(anchor_, { dirty_flag_, DirtyFlag::DirtyTransform }); - } - - /// \~chinese - /// @brief 获取大小属性 - inline Value SizeProperty() - { - return Value(size_, { dirty_flag_, DirtyFlag::DirtyTransform }); - } - - /// \~chinese - /// @brief 获取位置属性 - inline Value PositionProperty() - { - return Value(transform_.position, { dirty_flag_, DirtyFlag::DirtyTransform }); - } - - /// \~chinese - /// @brief 获取旋转角度属性 - inline Value RotationProperty() - { - return Value(transform_.rotation, { dirty_flag_, DirtyFlag::DirtyTransform }); - } - - /// \~chinese - /// @brief 获取缩放属性 - inline Value ScaleProperty() - { - return Value(transform_.scale, { dirty_flag_, DirtyFlag::DirtyTransform }); - } - - /// \~chinese - /// @brief 获取错切角度属性 - inline Value SkewProperty() - { - return Value(transform_.skew, { dirty_flag_, DirtyFlag::DirtyTransform }); - } - - /// \~chinese - /// @brief 获取Z轴顺序属性 - inline Value> ZOrderProperty() - { - return Value>(z_order_, Closure(this, &Actor::Reorder)); - } - protected: /// \~chinese /// @brief 更新自身和所有子角色 diff --git a/src/kiwano/core/Common.h b/src/kiwano/core/Common.h index 0f40191b..1daa622a 100644 --- a/src/kiwano/core/Common.h +++ b/src/kiwano/core/Common.h @@ -36,7 +36,6 @@ #include #include #include -#include namespace kiwano { diff --git a/src/kiwano/core/Value.h b/src/kiwano/core/Value.h deleted file mode 100644 index 7dc2707f..00000000 --- a/src/kiwano/core/Value.h +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) 2019-2020 Kiwano - Nomango -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#pragma once -#include -#include -#include - -namespace kiwano -{ - -template -struct ValueObserver; - -template -struct ValueObserver -{ - static_assert(std::is_arithmetic<_FlagTy>::value, "_Ty must be an arithmetic type"); - - inline ValueObserver(_FlagTy& observer, _FlagTy value) - : observer(observer) - , value(value) - { - } - - inline void Changed(const _Ty& old_val, const _Ty& new_val) - { - bits::Set(observer, value); - } - - _FlagTy& observer; - _FlagTy value; -}; - -template -struct ValueObserver<_Ty, Flag<_FlagTy>> -{ - inline ValueObserver(Flag<_FlagTy>& flag, _FlagTy flag_value) - : flag(flag) - , flag_value(flag_value) - { - } - - inline void Changed(const _Ty& old_val, const _Ty& new_val) - { - flag.Set(flag_value); - } - - Flag<_FlagTy>& flag; - _FlagTy flag_value; -}; - -template -struct ValueObserver<_Ty, Function> -{ - inline ValueObserver(const Function& callback) - : callback(callback) - { - } - - inline void Changed(const _Ty& old_val, const _Ty& new_val) - { - if (callback) - { - callback(); - } - } - - Function callback; -}; - -template -class Value; - -template -class Value<_Ty, void> -{ -public: - typedef _Ty value_type; - typedef void observer_type; - - inline Value(_Ty& ptr) - : ptr_(ptr) - { - } - - inline const _Ty& Get() const - { - return ptr_; - } - - inline void Set(const _Ty& value) - { - ptr_ = value; - } - -private: - _Ty& ptr_; -}; - -template -class Value -{ -public: - typedef _Ty value_type; - - typedef ValueObserver<_Ty, _ObserverTy> observer_type; - - inline Value(_Ty& ptr, const observer_type& observer) - : ptr_(ptr) - , observer_(observer) - { - } - - inline const _Ty& Get() const - { - return ptr_; - } - - inline void Set(const _Ty& value) - { - ptr_ = value; - observer_.Changed(ptr_, value); - } - -private: - _Ty& ptr_; - observer_type observer_; -}; - -}