aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-27 20:07:15 +0800
committercrupest <crupest@outlook.com>2022-01-27 20:07:15 +0800
commit56633dab8c1bf9d25a6367a651b5b054055a2130 (patch)
treed372843e3f6f91604a077ed15c353bedd5ef7e1b /include
parentd3aa43d9ea0dfc32935767cf60a89af2736dc339 (diff)
downloadcru-56633dab8c1bf9d25a6367a651b5b054055a2130.tar.gz
cru-56633dab8c1bf9d25a6367a651b5b054055a2130.tar.bz2
cru-56633dab8c1bf9d25a6367a651b5b054055a2130.zip
...
Diffstat (limited to 'include')
-rw-r--r--include/cru/ui/mapper/BrushMapper.hpp20
-rw-r--r--include/cru/xml/XmlNode.hpp3
2 files changed, 23 insertions, 0 deletions
diff --git a/include/cru/ui/mapper/BrushMapper.hpp b/include/cru/ui/mapper/BrushMapper.hpp
new file mode 100644
index 00000000..b2021076
--- /dev/null
+++ b/include/cru/ui/mapper/BrushMapper.hpp
@@ -0,0 +1,20 @@
+#pragma once
+#include "Mapper.hpp"
+#include "cru/common/Base.hpp"
+#include "cru/platform/graphics/Brush.hpp"
+#include "cru/xml/XmlNode.hpp"
+
+namespace cru::ui::mapper {
+class BrushMapper : public BasicRefMapper<platform::graphics::IBrush> {
+ public:
+ CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(BrushMapper)
+
+ public:
+ bool SupportMapFromXml() override { return true; }
+ bool XmlElementIsOfThisType(xml::XmlElementNode* node) override;
+
+ protected:
+ std::shared_ptr<platform::graphics::IBrush> DoMapFromXml(
+ xml::XmlElementNode* node) override;
+};
+} // namespace cru::ui::mapper
diff --git a/include/cru/xml/XmlNode.hpp b/include/cru/xml/XmlNode.hpp
index f308c9de..d1cb9430 100644
--- a/include/cru/xml/XmlNode.hpp
+++ b/include/cru/xml/XmlNode.hpp
@@ -33,6 +33,9 @@ class CRU_XML_API XmlNode {
virtual XmlNode* Clone() const = 0;
+ bool IsTextNode() const { return type_ == Type::Text; }
+ bool IsElementNode() const { return type_ == Type::Element; }
+
XmlElementNode* AsElement();
XmlTextNode* AsText();
const XmlElementNode* AsElement() const;