aboutsummaryrefslogtreecommitdiff
path: root/src/ui/mapper
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/mapper')
-rw-r--r--src/ui/mapper/MapperRegistry.cpp2
-rw-r--r--src/ui/mapper/style/PreferredSizeStylerMapper.cpp26
2 files changed, 28 insertions, 0 deletions
diff --git a/src/ui/mapper/MapperRegistry.cpp b/src/ui/mapper/MapperRegistry.cpp
index afbbc8b9..b70418ef 100644
--- a/src/ui/mapper/MapperRegistry.cpp
+++ b/src/ui/mapper/MapperRegistry.cpp
@@ -17,6 +17,7 @@
#include "cru/ui/mapper/style/HoverConditionMapper.h"
#include "cru/ui/mapper/style/NoConditionMapper.h"
#include "cru/ui/mapper/style/OrConditionMapper.h"
+#include "cru/ui/mapper/style/PreferredSizeStylerMapper.h"
#include "cru/ui/mapper/style/StyleRuleMapper.h"
#include "cru/ui/mapper/style/StyleRuleSetMapper.h"
@@ -47,6 +48,7 @@ MapperRegistry::MapperRegistry() {
RegisterMapper(new HoverConditionMapper());
RegisterMapper(new NoConditionMapper());
RegisterMapper(new OrConditionMapper());
+ RegisterMapper(new PreferredSizeStylerMapper());
RegisterMapper(new StyleRuleMapper());
RegisterMapper(new StyleRuleSetMapper());
}
diff --git a/src/ui/mapper/style/PreferredSizeStylerMapper.cpp b/src/ui/mapper/style/PreferredSizeStylerMapper.cpp
new file mode 100644
index 00000000..b4382c19
--- /dev/null
+++ b/src/ui/mapper/style/PreferredSizeStylerMapper.cpp
@@ -0,0 +1,26 @@
+#include "cru/ui/mapper/style/PreferredSizeStylerMapper.h"
+#include "cru/ui/render/MeasureRequirement.h"
+#include "cru/ui/style/Styler.h"
+
+namespace cru::ui::mapper::style {
+bool PreferredSizeStylerMapper::XmlElementIsOfThisType(
+ xml::XmlElementNode* node) {
+ return node->GetTag().CaseInsensitiveEqual(u"PreferredSizeStyler");
+}
+
+ClonablePtr<ui::style::PreferredSizeStyler>
+PreferredSizeStylerMapper::DoMapFromXml(xml::XmlElementNode* node) {
+ render::MeasureSize size;
+ auto width_attribute = node->GetOptionalAttributeCaseInsensitive(u"width");
+ if (width_attribute) {
+ size.width = width_attribute->ParseToFloat();
+ }
+
+ auto height_attribute = node->GetOptionalAttributeCaseInsensitive(u"height");
+ if (height_attribute) {
+ size.height = height_attribute->ParseToFloat();
+ }
+
+ return ui::style::PreferredSizeStyler::Create(size);
+}
+} // namespace cru::ui::mapper::style