diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/ui/mapper/style/ClickStateConditionMapper.cpp | 33 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index da4754f6..fc2ef76b 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -35,10 +35,13 @@ add_library(cru_ui SHARED mapper/PointMapper.cpp mapper/SizeMapper.cpp mapper/ThicknessMapper.cpp + mapper/style/AndConditionMapper.cpp mapper/style/BorderStylerMapper.cpp + mapper/style/ClickStateConditionMapper.cpp mapper/style/CursorStylerMapper.cpp mapper/style/FocusConditionMapper.cpp mapper/style/NoConditionMapper.cpp + mapper/style/OrConditionMapper.cpp render/BorderRenderObject.cpp render/CanvasRenderObject.cpp render/FlexLayoutRenderObject.cpp diff --git a/src/ui/mapper/style/ClickStateConditionMapper.cpp b/src/ui/mapper/style/ClickStateConditionMapper.cpp new file mode 100644 index 00000000..8e162a86 --- /dev/null +++ b/src/ui/mapper/style/ClickStateConditionMapper.cpp @@ -0,0 +1,33 @@ +#include "cru/ui/mapper/style/ClickStateConditionMapper.hpp" +#include "cru/common/ClonablePtr.hpp" +#include "cru/common/Exception.hpp" +#include "cru/ui/helper/ClickDetector.hpp" +#include "cru/ui/style/Condition.hpp" + +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 |