blob: 7c1200ef25bc7a6572844c842201713acac825cb (
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
|
#include "cru/ui/mapper/style/ClickStateConditionMapper.h"
#include "cru/common/ClonablePtr.h"
#include "cru/common/Exception.h"
#include "cru/ui/helper/ClickDetector.h"
#include "cru/ui/style/Condition.h"
namespace cru::ui::mapper::style {
bool ClickStateConditionMapper::XmlElementIsOfThisType(
xml::XmlElementNode *node) {
return node->GetTag().CaseInsensitiveEqual(u"ClickStateCondition");
}
ClonablePtr<ui::style::ClickStateCondition>
ClickStateConditionMapper::DoMapFromXml(xml::XmlElementNode *node) {
auto state = helper::ClickState::None;
auto value_attr = node->GetOptionalAttributeCaseInsensitive(u"value");
if (value_attr) {
if (value_attr->CaseInsensitiveEqual(u"none")) {
state = helper::ClickState::None;
} else if (value_attr->CaseInsensitiveEqual(u"hover")) {
state = helper::ClickState::Hover;
} else if (value_attr->CaseInsensitiveEqual(u"press")) {
state = helper::ClickState::Press;
} else if (value_attr->CaseInsensitiveEqual(u"pressinactive")) {
state = helper::ClickState::PressInactive;
} else {
throw Exception(u"Unknown click state: " + *value_attr);
}
}
return ui::style::ClickStateCondition::Create(state);
}
} // namespace cru::ui::mapper::style
|