blob: a5d2c5e391e4607af1ca665b22e91877bc719539 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include "cru/ui/mapper/ColorMapper.hpp"
namespace cru::ui::mapper {
bool ColorMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
return node->GetTag() == u"Color";
}
Color ColorMapper::DoMapFromString(String str) {
auto c = Color::Parse(str);
if (!c) {
throw Exception(u"Invalid color value.");
}
return *c;
}
Color ColorMapper::DoMapFromXml(xml::XmlElementNode* node) {
auto value_attr = node->GetOptionalAttribute(u"value");
if (!value_attr) {
return colors::transparent;
}
return DoMapFromString(*value_attr);
}
} // namespace cru::ui::mapper
|