From 4e0b7d82cd64ef8016dcb49247a8a5e4de8a0b3d Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Sun, 16 Nov 2025 10:37:36 +0800 Subject: Rename ClonePtr, update theme. --- include/cru/base/ClonablePtr.h | 216 --------------------- include/cru/base/ClonePtr.h | 119 ++++++++++++ include/cru/ui/mapper/Mapper.h | 4 +- include/cru/ui/mapper/MapperRegistry.h | 4 +- include/cru/ui/mapper/style/AndConditionMapper.h | 6 +- include/cru/ui/mapper/style/BorderStylerMapper.h | 8 +- .../cru/ui/mapper/style/CheckedConditionMapper.h | 6 +- .../ui/mapper/style/ClickStateConditionMapper.h | 6 +- .../cru/ui/mapper/style/ContentBrushStylerMapper.h | 6 +- include/cru/ui/mapper/style/CursorStylerMapper.h | 6 +- include/cru/ui/mapper/style/FocusConditionMapper.h | 6 +- include/cru/ui/mapper/style/FontStylerMapper.h | 6 +- include/cru/ui/mapper/style/HoverConditionMapper.h | 6 +- include/cru/ui/mapper/style/IConditionMapper.h | 4 +- include/cru/ui/mapper/style/IStylerMapper.h | 4 +- include/cru/ui/mapper/style/MarginStylerMapper.h | 6 +- include/cru/ui/mapper/style/NoConditionMapper.h | 8 +- include/cru/ui/mapper/style/OrConditionMapper.h | 6 +- include/cru/ui/mapper/style/PaddingStylerMapper.h | 6 +- .../ui/mapper/style/PreferredSizeStylerMapper.h | 6 +- include/cru/ui/mapper/style/StyleRuleMapper.h | 6 +- include/cru/ui/style/Condition.h | 40 ++-- include/cru/ui/style/StyleRule.h | 18 +- include/cru/ui/style/Styler.h | 56 +++--- 24 files changed, 231 insertions(+), 328 deletions(-) delete mode 100644 include/cru/base/ClonablePtr.h create mode 100644 include/cru/base/ClonePtr.h (limited to 'include') diff --git a/include/cru/base/ClonablePtr.h b/include/cru/base/ClonablePtr.h deleted file mode 100644 index 1198315f..00000000 --- a/include/cru/base/ClonablePtr.h +++ /dev/null @@ -1,216 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace cru { -template -class ClonablePtr { - template - friend class ClonablePtr; - - public: - using element_type = typename std::unique_ptr::element_type; - using pointer = typename std::unique_ptr::pointer; - - ClonablePtr() = default; - ClonablePtr(std::nullptr_t) noexcept : ptr_(nullptr) {} - explicit ClonablePtr(pointer p) noexcept : ptr_(p) {} - ClonablePtr(std::unique_ptr&& p) noexcept - : ptr_(std::move(p)) {} - template ::pointer, pointer>, - int> = 0> - ClonablePtr(std::unique_ptr&& p) : ptr_(std::move(p)) {} - ClonablePtr(const ClonablePtr& other) : ptr_(other.ptr_->Clone()) {} - ClonablePtr(ClonablePtr&& other) = default; - template ::pointer, pointer>, - int> = 0> - ClonablePtr(const ClonablePtr& other) : ptr_(other.ptr_->Clone()) {} - template ::pointer, pointer>, - int> = 0> - ClonablePtr(ClonablePtr&& other) noexcept : ptr_(std::move(other.ptr_)) {} - ClonablePtr& operator=(std::nullptr_t) noexcept { - ptr_ = nullptr; - return *this; - } - ClonablePtr& operator=(std::unique_ptr&& other) noexcept { - ptr_ = std::move(other); - return *this; - } - template ::pointer, pointer>, - int> = 0> - ClonablePtr& operator=(std::unique_ptr&& p) noexcept { - ptr_ = std::move(p); - return *this; - } - ClonablePtr& operator=(const ClonablePtr& other) { - if (this != &other) { - ptr_ = std::unique_ptr(other.ptr_->Clone()); - } - return *this; - } - ClonablePtr& operator=(ClonablePtr&& other) = default; - template ::pointer, pointer>, - int> = 0> - ClonablePtr& operator=(const ClonablePtr& other) noexcept { - if (this != &other) { - ptr_ = std::unique_ptr(other.ptr_->Clone()); - } - return *this; - } - template ::pointer, pointer>, - int> = 0> - ClonablePtr& operator=(ClonablePtr&& other) noexcept { - ptr_ = std::move(other.ptr_); - } - - ~ClonablePtr() = default; - - public: - pointer release() noexcept { return ptr_.release(); } - void reset(pointer p = pointer()) noexcept { ptr_.reset(p); } - void swap(ClonablePtr& other) noexcept { ptr_.swap(other.ptr_); } - - public: - pointer get() const noexcept { return ptr_.get(); } - - operator bool() const noexcept { return ptr_ != nullptr; } - - element_type& operator*() const noexcept { return *ptr_; } - pointer operator->() const noexcept { return ptr_.get(); } - - int Compare(const ClonablePtr& other) const noexcept { - if (ptr_ == other.ptr_) { - return 0; - } else if (ptr_ < other.ptr_) { - return -1; - } else { - return 1; - } - } - - int Compare(std::nullptr_t) const noexcept { return ptr_ ? 1 : 0; } - - private: - std::unique_ptr ptr_; -}; - -template -void swap(ClonablePtr& left, ClonablePtr& right) noexcept { - left.swap(right); -} - -template -bool operator==(const ClonablePtr& left, const ClonablePtr& right) { - return left.Compare(right) == 0; -} - -template -bool operator!=(const ClonablePtr& left, const ClonablePtr& right) { - return left.Compare(right) != 0; -} - -template -bool operator<(const ClonablePtr& left, const ClonablePtr& right) { - return left.Compare(right) < 0; -} - -template -bool operator<=(const ClonablePtr& left, const ClonablePtr& right) { - return left.Compare(right) <= 0; -} - -template -bool operator>(const ClonablePtr& left, const ClonablePtr& right) { - return left.Compare(right) > 0; -} - -template -bool operator>=(const ClonablePtr& left, const ClonablePtr& right) { - return left.Compare(right) >= 0; -} - -template -bool operator==(const ClonablePtr& left, std::nullptr_t) { - return left.Compare(nullptr) == 0; -} - -template -bool operator!=(const ClonablePtr& left, std::nullptr_t) { - return left.Compare(nullptr) != 0; -} - -template -bool operator<(const ClonablePtr& left, std::nullptr_t) { - return left.Compare(nullptr) < 0; -} - -template -bool operator<=(const ClonablePtr& left, std::nullptr_t) { - return left.Compare(nullptr) <= 0; -} - -template -bool operator>(const ClonablePtr& left, std::nullptr_t) { - return left.Compare(nullptr) > 0; -} - -template -bool operator>=(const ClonablePtr& left, std::nullptr_t) { - return left.Compare(nullptr) >= 0; -} - -template -bool operator==(std::nullptr_t, const ClonablePtr& right) { - return right.Compare(nullptr) == 0; -} - -template -bool operator!=(std::nullptr_t, const ClonablePtr& right) { - return right.Compare(nullptr) != 0; -} - -template -bool operator<(std::nullptr_t, const ClonablePtr& right) { - return right.Compare(nullptr) > 0; -} - -template -bool operator<=(std::nullptr_t, const ClonablePtr& right) { - return right.Compare(nullptr) >= 0; -} - -template -bool operator>(std::nullptr_t, const ClonablePtr& right) { - return right.Compare(nullptr) < 0; -} - -template -bool operator>=(std::nullptr_t, const ClonablePtr& right) { - return right.Compare(nullptr) <= 0; -} - -} // namespace cru - -namespace std { -template -struct hash> { - std::size_t operator()(const cru::ClonablePtr& p) const { - return std::hash::pointer>(p.get()); - } -}; -} // namespace std diff --git a/include/cru/base/ClonePtr.h b/include/cru/base/ClonePtr.h new file mode 100644 index 00000000..452c2cdd --- /dev/null +++ b/include/cru/base/ClonePtr.h @@ -0,0 +1,119 @@ +#pragma once + +#include +#include +#include +#include + +namespace cru { +template +class ClonePtr { + template + friend class ClonePtr; + + public: + using element_type = typename std::unique_ptr::element_type; + using pointer = typename std::unique_ptr::pointer; + + ClonePtr() = default; + ClonePtr(std::nullptr_t) noexcept : ptr_(nullptr) {} + explicit ClonePtr(pointer p) noexcept : ptr_(p) {} + ClonePtr(std::unique_ptr&& p) noexcept : ptr_(std::move(p)) {} + template ::pointer, pointer>, + int> = 0> + ClonePtr(std::unique_ptr&& p) : ptr_(std::move(p)) {} + ClonePtr(const ClonePtr& other) : ptr_(other.ptr_->Clone()) {} + ClonePtr(ClonePtr&& other) = default; + template ::pointer, pointer>, + int> = 0> + ClonePtr(const ClonePtr& other) : ptr_(other.ptr_->Clone()) {} + template ::pointer, pointer>, + int> = 0> + ClonePtr(ClonePtr&& other) noexcept : ptr_(std::move(other.ptr_)) {} + ClonePtr& operator=(std::nullptr_t) noexcept { + ptr_ = nullptr; + return *this; + } + ClonePtr& operator=(std::unique_ptr&& other) noexcept { + ptr_ = std::move(other); + return *this; + } + template ::pointer, pointer>, + int> = 0> + ClonePtr& operator=(std::unique_ptr&& p) noexcept { + ptr_ = std::move(p); + return *this; + } + ClonePtr& operator=(const ClonePtr& other) { + if (this != &other) { + ptr_ = std::unique_ptr(other.ptr_->Clone()); + } + return *this; + } + ClonePtr& operator=(ClonePtr&& other) = default; + template ::pointer, pointer>, + int> = 0> + ClonePtr& operator=(const ClonePtr& other) noexcept { + if (this != &other) { + ptr_ = std::unique_ptr(other.ptr_->Clone()); + } + return *this; + } + template ::pointer, pointer>, + int> = 0> + ClonePtr& operator=(ClonePtr&& other) noexcept { + ptr_ = std::move(other.ptr_); + } + + ~ClonePtr() = default; + + public: + pointer release() noexcept { return ptr_.release(); } + void reset(pointer p = pointer()) noexcept { ptr_.reset(p); } + void swap(ClonePtr& other) noexcept { ptr_.swap(other.ptr_); } + + public: + pointer get() const noexcept { return ptr_.get(); } + + operator bool() const noexcept { return ptr_ != nullptr; } + + element_type& operator*() const noexcept { return *ptr_; } + pointer operator->() const noexcept { return ptr_.get(); } + + auto operator<=>(std::nullptr_t) const { return ptr_.operator<=>(nullptr); } + + auto operator<=>(const ClonePtr& other) const { + return ptr_.operator<=>(other.ptr_); + } + + private: + std::unique_ptr ptr_; +}; + +template +void swap(ClonePtr& left, ClonePtr& right) noexcept { + left.swap(right); +} + +} // namespace cru + +namespace std { +template +struct hash> { + std::size_t operator()(const cru::ClonePtr& p) const { + return std::hash::pointer>(p.get()); + } +}; +} // namespace std diff --git a/include/cru/ui/mapper/Mapper.h b/include/cru/ui/mapper/Mapper.h index 88081816..164329d3 100644 --- a/include/cru/ui/mapper/Mapper.h +++ b/include/cru/ui/mapper/Mapper.h @@ -1,7 +1,7 @@ #pragma once #include "../Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/base/xml/XmlNode.h" #include @@ -88,5 +88,5 @@ template using BasicSharedPtrMapper = BasicMapper>; template -using BasicClonablePtrMapper = BasicMapper>; +using BasicClonePtrMapper = BasicMapper>; } // namespace cru::ui::mapper diff --git a/include/cru/ui/mapper/MapperRegistry.h b/include/cru/ui/mapper/MapperRegistry.h index ca1170b5..fae90b40 100644 --- a/include/cru/ui/mapper/MapperRegistry.h +++ b/include/cru/ui/mapper/MapperRegistry.h @@ -35,8 +35,8 @@ class CRU_UI_API MapperRegistry { } template - BasicClonablePtrMapper* GetClonablePtrMapper() const { - return GetMapper>(); + BasicClonePtrMapper* GetClonePtrMapper() const { + return GetMapper>(); } template diff --git a/include/cru/ui/mapper/style/AndConditionMapper.h b/include/cru/ui/mapper/style/AndConditionMapper.h index 65d0337c..5569e0fc 100644 --- a/include/cru/ui/mapper/style/AndConditionMapper.h +++ b/include/cru/ui/mapper/style/AndConditionMapper.h @@ -4,7 +4,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API AndConditionMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(AndConditionMapper) @@ -13,13 +13,13 @@ class CRU_UI_API AndConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr MapConditionFromXml( + ClonePtr MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/BorderStylerMapper.h b/include/cru/ui/mapper/style/BorderStylerMapper.h index 8cb4d392..c1554255 100644 --- a/include/cru/ui/mapper/style/BorderStylerMapper.h +++ b/include/cru/ui/mapper/style/BorderStylerMapper.h @@ -1,13 +1,13 @@ #pragma once #include "../Mapper.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/ui/mapper/style/IStylerMapper.h" #include "cru/ui/style/Styler.h" #include "cru/base/xml/XmlNode.h" namespace cru::ui::mapper::style { class CRU_UI_API BorderStylerMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IStylerMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(BorderStylerMapper) @@ -16,13 +16,13 @@ class CRU_UI_API BorderStylerMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr MapStylerFromXml( + ClonePtr MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/CheckedConditionMapper.h b/include/cru/ui/mapper/style/CheckedConditionMapper.h index 1bed9597..87d892a7 100644 --- a/include/cru/ui/mapper/style/CheckedConditionMapper.h +++ b/include/cru/ui/mapper/style/CheckedConditionMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API CheckedConditionMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(CheckedConditionMapper) @@ -14,13 +14,13 @@ class CRU_UI_API CheckedConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr MapConditionFromXml( + ClonePtr MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/ClickStateConditionMapper.h b/include/cru/ui/mapper/style/ClickStateConditionMapper.h index a54a3ad4..13c72a36 100644 --- a/include/cru/ui/mapper/style/ClickStateConditionMapper.h +++ b/include/cru/ui/mapper/style/ClickStateConditionMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API ClickStateConditionMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(ClickStateConditionMapper) @@ -14,13 +14,13 @@ class CRU_UI_API ClickStateConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr MapConditionFromXml( + ClonePtr MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } public: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/ContentBrushStylerMapper.h b/include/cru/ui/mapper/style/ContentBrushStylerMapper.h index 04b19bf8..d15eb28a 100644 --- a/include/cru/ui/mapper/style/ContentBrushStylerMapper.h +++ b/include/cru/ui/mapper/style/ContentBrushStylerMapper.h @@ -4,7 +4,7 @@ namespace cru::ui::mapper::style { class ContentBrushStylerMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IStylerMapper { public: ContentBrushStylerMapper(); @@ -13,13 +13,13 @@ class ContentBrushStylerMapper public: bool SupportMapFromXml() override { return true; } - ClonablePtr MapStylerFromXml( + ClonePtr MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/CursorStylerMapper.h b/include/cru/ui/mapper/style/CursorStylerMapper.h index c88a5170..54ade7f0 100644 --- a/include/cru/ui/mapper/style/CursorStylerMapper.h +++ b/include/cru/ui/mapper/style/CursorStylerMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API CursorStylerMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IStylerMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(CursorStylerMapper) @@ -14,13 +14,13 @@ class CRU_UI_API CursorStylerMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr MapStylerFromXml( + ClonePtr MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/FocusConditionMapper.h b/include/cru/ui/mapper/style/FocusConditionMapper.h index 6a7c56a2..e18150cf 100644 --- a/include/cru/ui/mapper/style/FocusConditionMapper.h +++ b/include/cru/ui/mapper/style/FocusConditionMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API FocusConditionMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(FocusConditionMapper) @@ -14,13 +14,13 @@ class CRU_UI_API FocusConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr MapConditionFromXml( + ClonePtr MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/FontStylerMapper.h b/include/cru/ui/mapper/style/FontStylerMapper.h index 34c94b73..6a79eb99 100644 --- a/include/cru/ui/mapper/style/FontStylerMapper.h +++ b/include/cru/ui/mapper/style/FontStylerMapper.h @@ -3,7 +3,7 @@ #include "IStylerMapper.h" namespace cru::ui::mapper::style { -class FontStylerMapper : public BasicClonablePtrMapper, +class FontStylerMapper : public BasicClonePtrMapper, public virtual IStylerMapper { public: FontStylerMapper(); @@ -12,13 +12,13 @@ class FontStylerMapper : public BasicClonablePtrMapper, public: bool SupportMapFromXml() override { return true; } - ClonablePtr MapStylerFromXml( + ClonePtr MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/HoverConditionMapper.h b/include/cru/ui/mapper/style/HoverConditionMapper.h index d3aa0b60..faa889e7 100644 --- a/include/cru/ui/mapper/style/HoverConditionMapper.h +++ b/include/cru/ui/mapper/style/HoverConditionMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API HoverConditionMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(HoverConditionMapper) @@ -14,13 +14,13 @@ class CRU_UI_API HoverConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr MapConditionFromXml( + ClonePtr MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/IConditionMapper.h b/include/cru/ui/mapper/style/IConditionMapper.h index 7bfd1427..27c09e82 100644 --- a/include/cru/ui/mapper/style/IConditionMapper.h +++ b/include/cru/ui/mapper/style/IConditionMapper.h @@ -1,6 +1,6 @@ #pragma once #include "../../Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/ui/mapper/Mapper.h" #include "cru/ui/style/Condition.h" #include "cru/base/xml/XmlNode.h" @@ -11,7 +11,7 @@ struct CRU_UI_API IConditionMapper : virtual Interface { return dynamic_cast(this)->XmlElementIsOfThisType(node); } - virtual ClonablePtr MapConditionFromXml( + virtual ClonePtr MapConditionFromXml( xml::XmlElementNode* node) = 0; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/IStylerMapper.h b/include/cru/ui/mapper/style/IStylerMapper.h index 4aa43665..ce9c4243 100644 --- a/include/cru/ui/mapper/style/IStylerMapper.h +++ b/include/cru/ui/mapper/style/IStylerMapper.h @@ -1,6 +1,6 @@ #pragma once #include "../../Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/ui/mapper/Mapper.h" #include "cru/ui/style/Styler.h" #include "cru/base/xml/XmlNode.h" @@ -11,7 +11,7 @@ struct CRU_UI_API IStylerMapper : virtual Interface { return dynamic_cast(this)->XmlElementIsOfThisType(node); } - virtual ClonablePtr MapStylerFromXml( + virtual ClonePtr MapStylerFromXml( xml::XmlElementNode* node) = 0; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/MarginStylerMapper.h b/include/cru/ui/mapper/style/MarginStylerMapper.h index 39d55fb6..b20452a9 100644 --- a/include/cru/ui/mapper/style/MarginStylerMapper.h +++ b/include/cru/ui/mapper/style/MarginStylerMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API MarginStylerMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IStylerMapper { public: MarginStylerMapper(); @@ -14,13 +14,13 @@ class CRU_UI_API MarginStylerMapper public: bool SupportMapFromXml() override { return true; } - ClonablePtr MapStylerFromXml( + ClonePtr MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/NoConditionMapper.h b/include/cru/ui/mapper/style/NoConditionMapper.h index bd2adf14..8acb79e0 100644 --- a/include/cru/ui/mapper/style/NoConditionMapper.h +++ b/include/cru/ui/mapper/style/NoConditionMapper.h @@ -2,13 +2,13 @@ #include "../Mapper.h" #include "IConditionMapper.h" #include "cru/base/Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/ui/style/Condition.h" #include "cru/base/xml/XmlNode.h" namespace cru::ui::mapper::style { class CRU_UI_API NoConditionMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(NoConditionMapper) @@ -17,13 +17,13 @@ class CRU_UI_API NoConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr MapConditionFromXml( + ClonePtr MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/OrConditionMapper.h b/include/cru/ui/mapper/style/OrConditionMapper.h index de8e0695..0aa5b241 100644 --- a/include/cru/ui/mapper/style/OrConditionMapper.h +++ b/include/cru/ui/mapper/style/OrConditionMapper.h @@ -4,7 +4,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API OrConditionMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IConditionMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(OrConditionMapper) @@ -13,13 +13,13 @@ class CRU_UI_API OrConditionMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr MapConditionFromXml( + ClonePtr MapConditionFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/PaddingStylerMapper.h b/include/cru/ui/mapper/style/PaddingStylerMapper.h index e7515ec1..bf0c5650 100644 --- a/include/cru/ui/mapper/style/PaddingStylerMapper.h +++ b/include/cru/ui/mapper/style/PaddingStylerMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API PaddingStylerMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IStylerMapper { public: PaddingStylerMapper(); @@ -14,13 +14,13 @@ class CRU_UI_API PaddingStylerMapper public: bool SupportMapFromXml() override { return true; } - ClonablePtr MapStylerFromXml( + ClonePtr MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/PreferredSizeStylerMapper.h b/include/cru/ui/mapper/style/PreferredSizeStylerMapper.h index f46b70d5..ee4f5705 100644 --- a/include/cru/ui/mapper/style/PreferredSizeStylerMapper.h +++ b/include/cru/ui/mapper/style/PreferredSizeStylerMapper.h @@ -5,7 +5,7 @@ namespace cru::ui::mapper::style { class CRU_UI_API PreferredSizeStylerMapper - : public BasicClonablePtrMapper, + : public BasicClonePtrMapper, public virtual IStylerMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(PreferredSizeStylerMapper) @@ -14,13 +14,13 @@ class CRU_UI_API PreferredSizeStylerMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; - ClonablePtr MapStylerFromXml( + ClonePtr MapStylerFromXml( xml::XmlElementNode* node) override { return MapFromXml(node); } protected: - ClonablePtr DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/mapper/style/StyleRuleMapper.h b/include/cru/ui/mapper/style/StyleRuleMapper.h index b4cb95e7..5622d0f4 100644 --- a/include/cru/ui/mapper/style/StyleRuleMapper.h +++ b/include/cru/ui/mapper/style/StyleRuleMapper.h @@ -1,12 +1,12 @@ #pragma once #include "../Mapper.h" #include "cru/base/Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/ui/style/StyleRule.h" #include "cru/base/xml/XmlNode.h" namespace cru::ui::mapper::style { -class CRU_UI_API StyleRuleMapper : public BasicClonablePtrMapper { +class CRU_UI_API StyleRuleMapper : public BasicClonePtrMapper { CRU_DEFINE_CLASS_LOG_TAG("StyleRuleMapper") public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(StyleRuleMapper) @@ -16,7 +16,7 @@ class CRU_UI_API StyleRuleMapper : public BasicClonablePtrMapper DoMapFromXml( + ClonePtr DoMapFromXml( xml::XmlElementNode* node) override; }; } // namespace cru::ui::mapper::style diff --git a/include/cru/ui/style/Condition.h b/include/cru/ui/style/Condition.h index 2d2dceac..e9b0e9d5 100644 --- a/include/cru/ui/style/Condition.h +++ b/include/cru/ui/style/Condition.h @@ -1,7 +1,7 @@ #pragma once #include "../Base.h" #include "cru/base/Base.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/base/Event.h" #include "cru/ui/controls/IClickableControl.h" #include "cru/ui/helper/ClickDetector.h" @@ -23,8 +23,8 @@ class CRU_UI_API Condition : public Object { class CRU_UI_API NoCondition : public Condition { public: - static ClonablePtr Create() { - return ClonablePtr(new NoCondition); + static ClonePtr Create() { + return ClonePtr(new NoCondition); }; std::vector ChangeOn(controls::Control*) const override { @@ -38,23 +38,23 @@ class CRU_UI_API NoCondition : public Condition { class CRU_UI_API CompoundCondition : public Condition { public: - explicit CompoundCondition(std::vector> conditions); + explicit CompoundCondition(std::vector> conditions); std::vector ChangeOn(controls::Control* control) const override; - std::vector> GetChildren() const { + std::vector> GetChildren() const { return conditions_; } protected: - std::vector> conditions_; + std::vector> conditions_; }; class CRU_UI_API AndCondition : public CompoundCondition { public: - static ClonablePtr Create( - std::vector> conditions) { - return ClonablePtr(new AndCondition(std::move(conditions))); + static ClonePtr Create( + std::vector> conditions) { + return ClonePtr(new AndCondition(std::move(conditions))); } using CompoundCondition::CompoundCondition; @@ -66,9 +66,9 @@ class CRU_UI_API AndCondition : public CompoundCondition { class CRU_UI_API OrCondition : public CompoundCondition { public: - static ClonablePtr Create( - std::vector> conditions) { - return ClonablePtr(new OrCondition(std::move(conditions))); + static ClonePtr Create( + std::vector> conditions) { + return ClonePtr(new OrCondition(std::move(conditions))); } using CompoundCondition::CompoundCondition; @@ -80,8 +80,8 @@ class CRU_UI_API OrCondition : public CompoundCondition { class CRU_UI_API FocusCondition : public Condition { public: - static ClonablePtr Create(bool has_focus) { - return ClonablePtr(new FocusCondition(has_focus)); + static ClonePtr Create(bool has_focus) { + return ClonePtr(new FocusCondition(has_focus)); } explicit FocusCondition(bool has_focus); @@ -101,8 +101,8 @@ class CRU_UI_API FocusCondition : public Condition { class CRU_UI_API HoverCondition : public Condition { public: - static ClonablePtr Create(bool hover) { - return ClonablePtr(new HoverCondition(hover)); + static ClonePtr Create(bool hover) { + return ClonePtr(new HoverCondition(hover)); } explicit HoverCondition(bool hover) : hover_(hover) {} @@ -118,9 +118,9 @@ class CRU_UI_API HoverCondition : public Condition { class CRU_UI_API ClickStateCondition : public Condition { public: - static ClonablePtr Create( + static ClonePtr Create( helper::ClickState click_state) { - return ClonablePtr( + return ClonePtr( new ClickStateCondition(click_state)); } @@ -141,8 +141,8 @@ class CRU_UI_API ClickStateCondition : public Condition { class CRU_UI_API CheckedCondition : public Condition { public: - static ClonablePtr Create(bool checked) { - return ClonablePtr(new CheckedCondition(checked)); + static ClonePtr Create(bool checked) { + return ClonePtr(new CheckedCondition(checked)); } explicit CheckedCondition(bool checked); diff --git a/include/cru/ui/style/StyleRule.h b/include/cru/ui/style/StyleRule.h index 382cd664..dd0d8780 100644 --- a/include/cru/ui/style/StyleRule.h +++ b/include/cru/ui/style/StyleRule.h @@ -2,7 +2,7 @@ #include "../Base.h" #include "Condition.h" #include "Styler.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" namespace cru::ui::style { /** @@ -11,14 +11,14 @@ namespace cru::ui::style { */ class CRU_UI_API StyleRule { public: - static ClonablePtr Create(ClonablePtr condition, - ClonablePtr styler, + static ClonePtr Create(ClonePtr condition, + ClonePtr styler, std::string name = {}) { - return ClonablePtr(new StyleRule( + return ClonePtr(new StyleRule( std::move(condition), std::move(styler), std::move(name))); } - StyleRule(ClonablePtr condition, ClonablePtr styler, + StyleRule(ClonePtr condition, ClonePtr styler, std::string name = {}); public: @@ -26,12 +26,12 @@ class CRU_UI_API StyleRule { Condition* GetCondition() const { return condition_.get(); } Styler* GetStyler() const { return styler_.get(); } - StyleRule WithNewCondition(ClonablePtr condition, + StyleRule WithNewCondition(ClonePtr condition, std::string name = {}) const { return StyleRule{std::move(condition), styler_, std::move(name)}; } - StyleRule WithNewStyler(ClonablePtr styler, + StyleRule WithNewStyler(ClonePtr styler, std::string name = {}) const { return StyleRule{condition_, std::move(styler), std::move(name)}; } @@ -39,8 +39,8 @@ class CRU_UI_API StyleRule { bool CheckAndApply(controls::Control* control) const; private: - ClonablePtr condition_; - ClonablePtr styler_; + ClonePtr condition_; + ClonePtr styler_; std::string name_; }; } // namespace cru::ui::style diff --git a/include/cru/ui/style/Styler.h b/include/cru/ui/style/Styler.h index 3ed85e1e..0e21945d 100644 --- a/include/cru/ui/style/Styler.h +++ b/include/cru/ui/style/Styler.h @@ -1,7 +1,7 @@ #pragma once #include "../Base.h" #include "ApplyBorderStyleInfo.h" -#include "cru/base/ClonablePtr.h" +#include "cru/base/ClonePtr.h" #include "cru/platform/graphics/Brush.h" #include "cru/platform/gui/Cursor.h" #include "cru/ui/render/MeasureRequirement.h" @@ -12,7 +12,7 @@ namespace cru::ui::style { /** * \brief The base class for all styler implementations. - * \remarks Styler should be immutable. And we use cru::ClonablePtr to wrap it + * \remarks Styler should be immutable. And we use cru::ClonePtr to wrap it * in order to get both polymorphic and value semantics. */ class CRU_UI_API Styler : public Object { @@ -25,17 +25,17 @@ class CRU_UI_API Styler : public Object { class CRU_UI_API CompoundStyler : public Styler { public: template - static ClonablePtr Create(ClonablePtr... s) { - return ClonablePtr( - new CompoundStyler(std::vector>{std::move(s)...})); + static ClonePtr Create(ClonePtr... s) { + return ClonePtr( + new CompoundStyler(std::vector>{std::move(s)...})); } - static ClonablePtr Create( - std::vector> stylers) { - return ClonablePtr(new CompoundStyler(std::move(stylers))); + static ClonePtr Create( + std::vector> stylers) { + return ClonePtr(new CompoundStyler(std::move(stylers))); } - explicit CompoundStyler(std::vector> stylers) + explicit CompoundStyler(std::vector> stylers) : stylers_(std::move(stylers)) {} void Apply(controls::Control* control) const override { @@ -44,24 +44,24 @@ class CRU_UI_API CompoundStyler : public Styler { } } - std::vector> GetChildren() const { return stylers_; } + std::vector> GetChildren() const { return stylers_; } virtual CompoundStyler* Clone() const override { return new CompoundStyler(stylers_); } private: - std::vector> stylers_; + std::vector> stylers_; }; class CRU_UI_API BorderStyler : public Styler { public: - static ClonablePtr Create() { - return ClonablePtr(new BorderStyler()); + static ClonePtr Create() { + return ClonePtr(new BorderStyler()); } - static ClonablePtr Create(ApplyBorderStyleInfo style) { - return ClonablePtr(new BorderStyler(std::move(style))); + static ClonePtr Create(ApplyBorderStyleInfo style) { + return ClonePtr(new BorderStyler(std::move(style))); } BorderStyler() = default; @@ -79,12 +79,12 @@ class CRU_UI_API BorderStyler : public Styler { class CRU_UI_API CursorStyler : public Styler { public: - static ClonablePtr Create( + static ClonePtr Create( std::shared_ptr cursor) { - return ClonablePtr(new CursorStyler(std::move(cursor))); + return ClonePtr(new CursorStyler(std::move(cursor))); } - static ClonablePtr Create(platform::gui::SystemCursorType type); + static ClonePtr Create(platform::gui::SystemCursorType type); explicit CursorStyler(std::shared_ptr cursor) : cursor_(std::move(cursor)) {} @@ -101,8 +101,8 @@ class CRU_UI_API CursorStyler : public Styler { class CRU_UI_API PreferredSizeStyler : public Styler { public: - static ClonablePtr Create(render::MeasureSize size) { - return ClonablePtr(new PreferredSizeStyler(size)); + static ClonePtr Create(render::MeasureSize size) { + return ClonePtr(new PreferredSizeStyler(size)); } explicit PreferredSizeStyler(render::MeasureSize size) : size_(size) {} @@ -121,8 +121,8 @@ class CRU_UI_API PreferredSizeStyler : public Styler { class CRU_UI_API MarginStyler : public Styler { public: - static ClonablePtr Create(const Thickness& margin) { - return ClonablePtr(new MarginStyler(margin)); + static ClonePtr Create(const Thickness& margin) { + return ClonePtr(new MarginStyler(margin)); } explicit MarginStyler(const Thickness& margin) : margin_(margin) {} @@ -139,8 +139,8 @@ class CRU_UI_API MarginStyler : public Styler { class CRU_UI_API PaddingStyler : public Styler { public: - static ClonablePtr Create(const Thickness& padding) { - return ClonablePtr(new PaddingStyler(padding)); + static ClonePtr Create(const Thickness& padding) { + return ClonePtr(new PaddingStyler(padding)); } explicit PaddingStyler(const Thickness& padding) : padding_(padding) {} @@ -157,9 +157,9 @@ class CRU_UI_API PaddingStyler : public Styler { class CRU_UI_API ContentBrushStyler : public Styler { public: - static ClonablePtr Create( + static ClonePtr Create( std::shared_ptr brush) { - return ClonablePtr( + return ClonePtr( new ContentBrushStyler(std::move(brush))); } @@ -182,9 +182,9 @@ class CRU_UI_API ContentBrushStyler : public Styler { class CRU_UI_API FontStyler : public Styler { public: - static ClonablePtr Create( + static ClonePtr Create( std::shared_ptr font) { - return ClonablePtr(new FontStyler(std::move(font))); + return ClonePtr(new FontStyler(std::move(font))); } explicit FontStyler(std::shared_ptr font) -- cgit v1.2.3