From 275fe302cd03adf59fff1a0e4a08f13c6cfcaf31 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 23 Jan 2022 21:48:08 +0800 Subject: ... --- include/cru/common/String.hpp | 6 ++++++ include/cru/ui/mapper/Mapper.hpp | 5 ++++- include/cru/ui/mapper/MapperRegistry.hpp | 5 +++++ include/cru/ui/mapper/style/BorderStylerMapper.hpp | 21 +++++++++++++++++++++ include/cru/ui/style/Styler.hpp | 5 +++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 include/cru/ui/mapper/style/BorderStylerMapper.hpp (limited to 'include') diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp index 5891e929..22d68980 100644 --- a/include/cru/common/String.hpp +++ b/include/cru/common/String.hpp @@ -226,6 +226,9 @@ class CRU_BASE_API String { int Compare(const String& other) const; int CaseInsensitiveCompare(const String& other) const; + bool CaseInsensitiveEqual(const String& other) const { + return CaseInsensitiveCompare(other) == 0; + } private: static char16_t kEmptyBuffer[1]; @@ -310,6 +313,9 @@ class CRU_BASE_API StringView { public: int Compare(const StringView& other) const; int CaseInsensitiveCompare(const StringView& other) const; + bool CaseInsensitiveEqual(const StringView& other) const { + return CaseInsensitiveCompare(other) == 0; + } String ToString() const { return String(ptr_, size_); } diff --git a/include/cru/ui/mapper/Mapper.hpp b/include/cru/ui/mapper/Mapper.hpp index 4e5499d0..5febb26e 100644 --- a/include/cru/ui/mapper/Mapper.hpp +++ b/include/cru/ui/mapper/Mapper.hpp @@ -1,7 +1,7 @@ #pragma once - #include "../Base.hpp" +#include "cru/common/ClonablePtr.hpp" #include "cru/common/Exception.hpp" #include "cru/xml/XmlNode.hpp" @@ -85,4 +85,7 @@ class CRU_UI_API BasicMapper : public MapperBase { template using BasicRefMapper = BasicMapper>; + +template +using BasicPtrMapper = BasicMapper>; } // namespace cru::ui::mapper diff --git a/include/cru/ui/mapper/MapperRegistry.hpp b/include/cru/ui/mapper/MapperRegistry.hpp index 55051ba9..c3e5b4c4 100644 --- a/include/cru/ui/mapper/MapperRegistry.hpp +++ b/include/cru/ui/mapper/MapperRegistry.hpp @@ -34,6 +34,11 @@ class CRU_UI_API MapperRegistry { return GetMapper>(); } + template + BasicPtrMapper* GetPtrMapper() const { + return GetMapper>(); + } + void RegisterMapper(MapperBase* mapper); void UnregisterMapper(MapperBase* mapper); diff --git a/include/cru/ui/mapper/style/BorderStylerMapper.hpp b/include/cru/ui/mapper/style/BorderStylerMapper.hpp new file mode 100644 index 00000000..6c967bed --- /dev/null +++ b/include/cru/ui/mapper/style/BorderStylerMapper.hpp @@ -0,0 +1,21 @@ +#pragma once +#include "../Mapper.hpp" +#include "cru/common/ClonablePtr.hpp" +#include "cru/ui/style/Styler.hpp" +#include "cru/xml/XmlNode.hpp" + +namespace cru::ui::mapper::style { +class CRU_UI_API BorderStylerMapper + : public BasicPtrMapper { + public: + CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(BorderStylerMapper) + + public: + bool SupportMapFromXml() override { return true; } + bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; + + protected: + ClonablePtr DoMapFromXml( + xml::XmlElementNode* node) override; +}; +} // namespace cru::ui::mapper::style diff --git a/include/cru/ui/style/Styler.hpp b/include/cru/ui/style/Styler.hpp index 865cbbaf..721a3bfd 100644 --- a/include/cru/ui/style/Styler.hpp +++ b/include/cru/ui/style/Styler.hpp @@ -44,10 +44,15 @@ class CompoundStyler : public Styler { class BorderStyler : public Styler { public: + static ClonablePtr Create() { + return ClonablePtr(new BorderStyler()); + } + static ClonablePtr Create(ApplyBorderStyleInfo style) { return ClonablePtr(new BorderStyler(std::move(style))); } + BorderStyler() = default; explicit BorderStyler(ApplyBorderStyleInfo style); void Apply(controls::Control* control) const override; -- cgit v1.2.3