aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/mapper
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-23 21:48:08 +0800
committercrupest <crupest@outlook.com>2022-01-23 21:48:08 +0800
commit275fe302cd03adf59fff1a0e4a08f13c6cfcaf31 (patch)
tree542bd59bca9459b93813c9cae9e964b229efafd4 /include/cru/ui/mapper
parentda9bdf2baced1ff51350c98047b7ade68fcae930 (diff)
downloadcru-275fe302cd03adf59fff1a0e4a08f13c6cfcaf31.tar.gz
cru-275fe302cd03adf59fff1a0e4a08f13c6cfcaf31.tar.bz2
cru-275fe302cd03adf59fff1a0e4a08f13c6cfcaf31.zip
...
Diffstat (limited to 'include/cru/ui/mapper')
-rw-r--r--include/cru/ui/mapper/Mapper.hpp5
-rw-r--r--include/cru/ui/mapper/MapperRegistry.hpp5
-rw-r--r--include/cru/ui/mapper/style/BorderStylerMapper.hpp21
3 files changed, 30 insertions, 1 deletions
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 <typename T>
using BasicRefMapper = BasicMapper<std::shared_ptr<T>>;
+
+template <typename T>
+using BasicPtrMapper = BasicMapper<ClonablePtr<T>>;
} // 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<std::shared_ptr<T>>();
}
+ template <typename T>
+ BasicPtrMapper<T>* GetPtrMapper() const {
+ return GetMapper<ClonablePtr<T>>();
+ }
+
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<ui::style::BorderStyler> {
+ public:
+ CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(BorderStylerMapper)
+
+ public:
+ bool SupportMapFromXml() override { return true; }
+ bool XmlElementIsOfThisType(xml::XmlElementNode* node) override;
+
+ protected:
+ ClonablePtr<ui::style::BorderStyler> DoMapFromXml(
+ xml::XmlElementNode* node) override;
+};
+} // namespace cru::ui::mapper::style