diff options
author | crupest <crupest@outlook.com> | 2022-03-06 16:38:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-06 16:38:51 +0800 |
commit | 62a0c3f1785e789357c892d94b3ea0bc3ea6833e (patch) | |
tree | ebf1436b728ba62ed1251f04021da8ce839028eb /src/ui | |
parent | afc40737f2dc990f4805342e52e2be128f161808 (diff) | |
download | cru-62a0c3f1785e789357c892d94b3ea0bc3ea6833e.tar.gz cru-62a0c3f1785e789357c892d94b3ea0bc3ea6833e.tar.bz2 cru-62a0c3f1785e789357c892d94b3ea0bc3ea6833e.zip |
...
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/ui/mapper/MapperRegistry.cpp | 2 | ||||
-rw-r--r-- | src/ui/mapper/style/FontStylerMapper.cpp | 25 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 4c272e12..c9f0df8e 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -47,6 +47,7 @@ add_library(cru_ui SHARED mapper/style/ContentBrushStylerMapper.cpp mapper/style/CursorStylerMapper.cpp mapper/style/FocusConditionMapper.cpp + mapper/style/FontStylerMapper.cpp mapper/style/HoverConditionMapper.cpp mapper/style/MarginStylerMapper.cpp mapper/style/NoConditionMapper.cpp diff --git a/src/ui/mapper/MapperRegistry.cpp b/src/ui/mapper/MapperRegistry.cpp index a8cb4157..a542bfca 100644 --- a/src/ui/mapper/MapperRegistry.cpp +++ b/src/ui/mapper/MapperRegistry.cpp @@ -17,6 +17,7 @@ #include "cru/ui/mapper/style/ContentBrushStylerMapper.h" #include "cru/ui/mapper/style/CursorStylerMapper.h" #include "cru/ui/mapper/style/FocusConditionMapper.h" +#include "cru/ui/mapper/style/FontStylerMapper.h" #include "cru/ui/mapper/style/HoverConditionMapper.h" #include "cru/ui/mapper/style/MarginStylerMapper.h" #include "cru/ui/mapper/style/NoConditionMapper.h" @@ -53,6 +54,7 @@ MapperRegistry::MapperRegistry() { RegisterMapper(new ContentBrushStylerMapper()); RegisterMapper(new CursorStylerMapper()); RegisterMapper(new FocusConditionMapper()); + RegisterMapper(new FontStylerMapper()); RegisterMapper(new HoverConditionMapper()); RegisterMapper(new MarginStylerMapper()); RegisterMapper(new NoConditionMapper()); diff --git a/src/ui/mapper/style/FontStylerMapper.cpp b/src/ui/mapper/style/FontStylerMapper.cpp new file mode 100644 index 00000000..884832ee --- /dev/null +++ b/src/ui/mapper/style/FontStylerMapper.cpp @@ -0,0 +1,25 @@ +#include "cru/ui/mapper/style/FontStylerMapper.h" +#include "cru/common/ClonablePtr.h" +#include "cru/ui/mapper/MapperRegistry.h" + +namespace cru::ui::mapper::style { +FontStylerMapper::FontStylerMapper() { SetAllowedTags({u"FontStyler"}); } + +FontStylerMapper::~FontStylerMapper() {} + +ClonablePtr<ui::style::FontStyler> FontStylerMapper::DoMapFromXml( + xml::XmlElementNode* node) { + auto font_mapper = MapperRegistry::GetInstance() + ->GetSharedPtrMapper<platform::graphics::IFont>(); + + std::shared_ptr<platform::graphics::IFont> font; + + for (auto child_node : node->GetChildren()) { + if (child_node->IsElementNode()) { + font = font_mapper->MapFromXml(child_node->AsElement()); + } + } + + return ui::style::FontStyler::Create(std::move(font)); +} +} // namespace cru::ui::mapper::style |