aboutsummaryrefslogtreecommitdiff
path: root/src/ui/mapper
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-23 22:37:40 +0800
committercrupest <crupest@outlook.com>2022-01-23 22:37:40 +0800
commit6f9ccdc9983c2cade1955c611b36b74a1caf037a (patch)
treec507421e0ebe71477839d6d34064be4c45a5401b /src/ui/mapper
parent275fe302cd03adf59fff1a0e4a08f13c6cfcaf31 (diff)
downloadcru-6f9ccdc9983c2cade1955c611b36b74a1caf037a.tar.gz
cru-6f9ccdc9983c2cade1955c611b36b74a1caf037a.tar.bz2
cru-6f9ccdc9983c2cade1955c611b36b74a1caf037a.zip
...
Diffstat (limited to 'src/ui/mapper')
-rw-r--r--src/ui/mapper/style/CursorStylerMapper.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ui/mapper/style/CursorStylerMapper.cpp b/src/ui/mapper/style/CursorStylerMapper.cpp
new file mode 100644
index 00000000..0b29c938
--- /dev/null
+++ b/src/ui/mapper/style/CursorStylerMapper.cpp
@@ -0,0 +1,27 @@
+#include "cru/ui/mapper/style/CursorStylerMapper.hpp"
+#include "cru/common/ClonablePtr.hpp"
+#include "cru/platform/gui/Cursor.hpp"
+#include "cru/ui/mapper/MapperRegistry.hpp"
+#include "cru/ui/style/Styler.hpp"
+
+namespace cru::ui::mapper::style {
+bool CursorStylerMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
+ return node->GetTag().CaseInsensitiveEqual(u"cursor");
+}
+
+ClonablePtr<ui::style::CursorStyler> CursorStylerMapper::DoMapFromXml(
+ xml::XmlElementNode* node) {
+ auto cursor_mapper =
+ MapperRegistry::GetInstance()->GetRefMapper<platform::gui::ICursor>();
+ std::shared_ptr<platform::gui::ICursor> cursor;
+
+ for (auto child : node->GetChildren()) {
+ if (child->GetType() == xml::XmlNode::Type::Element &&
+ cursor_mapper->XmlElementIsOfThisType(child->AsElement())) {
+ cursor = cursor_mapper->MapFromXml(child->AsElement());
+ }
+ }
+
+ return ui::style::CursorStyler::Create(cursor);
+}
+} // namespace cru::ui::mapper::style