From 13860c88910c00478abe3001cc80125e76767381 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 22 Jan 2022 22:37:24 +0800 Subject: ... --- include/cru/ui/mapper/CursorMapper.hpp | 18 +++++++++++++++++- include/cru/ui/mapper/Mapper.hpp | 4 ++++ include/cru/ui/mapper/MapperRegistry.hpp | 5 +++++ 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/cru/ui/mapper/CursorMapper.hpp b/include/cru/ui/mapper/CursorMapper.hpp index b4254061..6cb61d87 100644 --- a/include/cru/ui/mapper/CursorMapper.hpp +++ b/include/cru/ui/mapper/CursorMapper.hpp @@ -1,5 +1,21 @@ #pragma once #include "Mapper.hpp" #include "cru/platform/gui/Cursor.hpp" +#include "cru/xml/XmlNode.hpp" -namespace cru::ui::mapper::style {} +namespace cru::ui::mapper { +class CRU_UI_API CursorMapper : public BasicRefMapper { + public: + CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(CursorMapper); + + public: + bool SupportMapFromString() override { return true; } + bool SupportMapFromXml() override { return true; } + bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; + + protected: + std::shared_ptr DoMapFromString(String str) override; + std::shared_ptr DoMapFromXml( + xml::XmlElementNode* node) override; +}; +} // namespace cru::ui::mapper diff --git a/include/cru/ui/mapper/Mapper.hpp b/include/cru/ui/mapper/Mapper.hpp index d15b63aa..4e5499d0 100644 --- a/include/cru/ui/mapper/Mapper.hpp +++ b/include/cru/ui/mapper/Mapper.hpp @@ -5,6 +5,7 @@ #include "cru/common/Exception.hpp" #include "cru/xml/XmlNode.hpp" +#include #include #include #include @@ -81,4 +82,7 @@ class CRU_UI_API BasicMapper : public MapperBase { virtual T DoMapFromString(String str) { return {}; } virtual T DoMapFromXml(xml::XmlElementNode* node) { return {}; } }; + +template +using BasicRefMapper = BasicMapper>; } // namespace cru::ui::mapper diff --git a/include/cru/ui/mapper/MapperRegistry.hpp b/include/cru/ui/mapper/MapperRegistry.hpp index 94643ce0..55051ba9 100644 --- a/include/cru/ui/mapper/MapperRegistry.hpp +++ b/include/cru/ui/mapper/MapperRegistry.hpp @@ -29,6 +29,11 @@ class CRU_UI_API MapperRegistry { return nullptr; } + template + BasicRefMapper* GetRefMapper() const { + return GetMapper>(); + } + void RegisterMapper(MapperBase* mapper); void UnregisterMapper(MapperBase* mapper); -- cgit v1.2.3