blob: fa3f672dc04b6dab35c5b5f9256b97b648f2cca8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#include "cru/ui/mapper/BorderStyleMapper.h"
#include "cru/base/StringUtil.h"
#include "cru/platform/graphics/Brush.h"
#include "cru/ui/mapper/MapperRegistry.h"
#include "cru/ui/style/ApplyBorderStyleInfo.h"
#include "cru/xml/XmlNode.h"
namespace cru::ui::mapper {
using namespace xml;
using ui::style::ApplyBorderStyleInfo;
bool BorderStyleMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
return cru::string::CaseInsensitiveCompare(node->GetTag(), "BorderStyle") ==
0;
}
ApplyBorderStyleInfo BorderStyleMapper::DoMapFromXml(
xml::XmlElementNode* node) {
ApplyBorderStyleInfo result;
for (auto child : node->GetChildren()) {
if (child->GetType() == XmlNode::Type::Text) {
} else {
auto c = child->AsElement();
auto thickness_mapper =
MapperRegistry::GetInstance()->GetMapper<Thickness>();
auto corner_radius_mapper =
MapperRegistry::GetInstance()->GetMapper<CornerRadius>();
auto brush_mapper =
MapperRegistry::GetInstance()
->GetSharedPtrMapper<platform::graphics::IBrush>();
if (thickness_mapper->XmlElementIsOfThisType(c)) {
result.border_thickness = thickness_mapper->MapFromXml(c);
} else if (corner_radius_mapper->XmlElementIsOfThisType(c)) {
result.border_radius = corner_radius_mapper->MapFromXml(c);
} else if (brush_mapper->XmlElementIsOfThisType(c)) {
auto brush = brush_mapper->MapFromXml(c);
auto name = c->GetOptionalAttributeValueCaseInsensitive("name");
if (name) {
if (cru::string::CaseInsensitiveCompare(*name, "foreground") == 0) {
result.foreground_brush = std::move(brush);
} else if (cru::string::CaseInsensitiveCompare(*name, "background") ==
0) {
result.background_brush = std::move(brush);
} else {
}
} else {
result.border_brush = std::move(brush);
}
}
}
}
return result;
}
} // namespace cru::ui::mapper
|