From 549b072d241a8d2d1ca187bba8c1cb5190dd737e Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 24 Jan 2022 18:28:25 +0800 Subject: ... --- include/cru/ui/mapper/style/BorderStylerMapper.hpp | 9 ++++++++- include/cru/ui/mapper/style/CursorStylerMapper.hpp | 9 ++++++++- include/cru/ui/mapper/style/IStylerMapper.hpp | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 include/cru/ui/mapper/style/IStylerMapper.hpp diff --git a/include/cru/ui/mapper/style/BorderStylerMapper.hpp b/include/cru/ui/mapper/style/BorderStylerMapper.hpp index 6c967bed..2f48550c 100644 --- a/include/cru/ui/mapper/style/BorderStylerMapper.hpp +++ b/include/cru/ui/mapper/style/BorderStylerMapper.hpp @@ -1,12 +1,14 @@ #pragma once #include "../Mapper.hpp" #include "cru/common/ClonablePtr.hpp" +#include "cru/ui/mapper/style/IStylerMapper.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 BasicPtrMapper, + public virtual IStylerMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(BorderStylerMapper) @@ -14,6 +16,11 @@ class CRU_UI_API BorderStylerMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; + ClonablePtr MapStylerFromXml( + xml::XmlElementNode* node) override { + return MapFromXml(node); + } + protected: ClonablePtr DoMapFromXml( xml::XmlElementNode* node) override; diff --git a/include/cru/ui/mapper/style/CursorStylerMapper.hpp b/include/cru/ui/mapper/style/CursorStylerMapper.hpp index c12efbd9..2b0c62a8 100644 --- a/include/cru/ui/mapper/style/CursorStylerMapper.hpp +++ b/include/cru/ui/mapper/style/CursorStylerMapper.hpp @@ -1,10 +1,12 @@ #pragma once #include "../Mapper.hpp" +#include "cru/ui/mapper/style/IStylerMapper.hpp" #include "cru/ui/style/Styler.hpp" namespace cru::ui::mapper::style { class CRU_UI_API CursorStylerMapper - : public BasicPtrMapper { + : public BasicPtrMapper, + public virtual IStylerMapper { public: CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(CursorStylerMapper) @@ -12,6 +14,11 @@ class CRU_UI_API CursorStylerMapper bool SupportMapFromXml() override { return true; } bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; + ClonablePtr MapStylerFromXml( + xml::XmlElementNode* node) override { + return MapFromXml(node); + } + protected: ClonablePtr DoMapFromXml( xml::XmlElementNode* node) override; diff --git a/include/cru/ui/mapper/style/IStylerMapper.hpp b/include/cru/ui/mapper/style/IStylerMapper.hpp new file mode 100644 index 00000000..03ee4289 --- /dev/null +++ b/include/cru/ui/mapper/style/IStylerMapper.hpp @@ -0,0 +1,17 @@ +#pragma once +#include "../../Base.hpp" +#include "cru/common/ClonablePtr.hpp" +#include "cru/ui/mapper/Mapper.hpp" +#include "cru/ui/style/Styler.hpp" +#include "cru/xml/XmlNode.hpp" + +namespace cru::ui::mapper::style { +struct IStylerMapper : virtual Interface { + bool XmlElementIsOfThisType(xml::XmlElementNode* node) { + return dynamic_cast(this)->XmlElementIsOfThisType(node); + } + + virtual ClonablePtr MapStylerFromXml( + xml::XmlElementNode* node) = 0; +}; +} // namespace cru::ui::mapper::style -- cgit v1.2.3