diff options
-rw-r--r-- | include/cru/ui/mapper/style/CursorStylerMapper.hpp | 19 | ||||
-rw-r--r-- | src/ui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/ui/mapper/style/CursorStylerMapper.cpp | 27 |
3 files changed, 47 insertions, 0 deletions
diff --git a/include/cru/ui/mapper/style/CursorStylerMapper.hpp b/include/cru/ui/mapper/style/CursorStylerMapper.hpp new file mode 100644 index 00000000..c12efbd9 --- /dev/null +++ b/include/cru/ui/mapper/style/CursorStylerMapper.hpp @@ -0,0 +1,19 @@ +#pragma once +#include "../Mapper.hpp" +#include "cru/ui/style/Styler.hpp" + +namespace cru::ui::mapper::style { +class CRU_UI_API CursorStylerMapper + : public BasicPtrMapper<ui::style::CursorStyler> { + public: + CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(CursorStylerMapper) + + public: + bool SupportMapFromXml() override { return true; } + bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; + + protected: + ClonablePtr<ui::style::CursorStyler> DoMapFromXml( + xml::XmlElementNode* node) override; +}; +} // namespace cru::ui::mapper::style diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index f13f4983..76a3530c 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -36,6 +36,7 @@ add_library(cru_ui SHARED mapper/SizeMapper.cpp mapper/ThicknessMapper.cpp mapper/style/BorderStylerMapper.cpp + mapper/style/CursorStylerMapper.cpp render/BorderRenderObject.cpp render/CanvasRenderObject.cpp render/FlexLayoutRenderObject.cpp 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 |