aboutsummaryrefslogtreecommitdiff
path: root/src/ui/mapper/CornerRadiusMapper.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-20 23:17:17 +0800
committercrupest <crupest@outlook.com>2022-01-20 23:17:17 +0800
commit193b3fe67eaadf291ae77f689362d87861c26118 (patch)
treebebf8343a730b3b43502d403be83350b871d672b /src/ui/mapper/CornerRadiusMapper.cpp
parentc0f802594e17efd5b93d4019431bf1a6d24249c3 (diff)
downloadcru-193b3fe67eaadf291ae77f689362d87861c26118.tar.gz
cru-193b3fe67eaadf291ae77f689362d87861c26118.tar.bz2
cru-193b3fe67eaadf291ae77f689362d87861c26118.zip
...
Diffstat (limited to 'src/ui/mapper/CornerRadiusMapper.cpp')
-rw-r--r--src/ui/mapper/CornerRadiusMapper.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/ui/mapper/CornerRadiusMapper.cpp b/src/ui/mapper/CornerRadiusMapper.cpp
new file mode 100644
index 00000000..ef63e26f
--- /dev/null
+++ b/src/ui/mapper/CornerRadiusMapper.cpp
@@ -0,0 +1,46 @@
+#include "cru/ui/mapper/CornerRadiusMapper.hpp"
+#include "cru/ui/mapper/MapperRegistry.hpp"
+#include "cru/ui/mapper/PointMapper.hpp"
+
+namespace cru::ui::mapper {
+bool CornerRadiusMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
+ if (node->GetTag() == u"CornerRadius") {
+ return true;
+ }
+ return false;
+}
+
+std::unique_ptr<CornerRadius> CornerRadiusMapper::DoMapFromXml(
+ xml::XmlElementNode* node) {
+ auto point_mapper = MapperRegistry::GetInstance()->GetMapper<Point>();
+
+ auto result = std::make_unique<CornerRadius>();
+
+ auto all = node->GetOptionalAttribute(u"all");
+ if (all) {
+ result->SetAll(*point_mapper->MapFromString(*all));
+ }
+
+ auto lefttop = node->GetOptionalAttribute(u"lefttop");
+ if (lefttop) {
+ result->left_top = *point_mapper->MapFromString(*lefttop);
+ }
+
+ auto righttop = node->GetOptionalAttribute(u"righttop");
+ if (righttop) {
+ result->right_top = *point_mapper->MapFromString(*righttop);
+ }
+
+ auto rightbottom = node->GetOptionalAttribute(u"rightbottom");
+ if (rightbottom) {
+ result->right_bottom = *point_mapper->MapFromString(*rightbottom);
+ }
+
+ auto leftbottom = node->GetOptionalAttribute(u"leftbottom");
+ if (leftbottom) {
+ result->left_bottom = *point_mapper->MapFromString(*leftbottom);
+ }
+
+ return result;
+}
+} // namespace cru::ui::mapper