diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/style/Condition.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ui/style/Condition.cpp b/src/ui/style/Condition.cpp index b68fd0ee..f7cdf7fd 100644 --- a/src/ui/style/Condition.cpp +++ b/src/ui/style/Condition.cpp @@ -4,6 +4,7 @@ #include "cru/common/ClonablePtr.h" #include "cru/common/Event.h" #include "cru/ui/controls/Control.h" +#include "cru/ui/controls/ICheckableControl.h" #include "cru/ui/controls/IClickableControl.h" #include "cru/ui/helper/ClickDetector.h" @@ -81,4 +82,24 @@ bool ClickStateCondition::Judge(controls::Control* control) const { } return false; } + +CheckedCondition::CheckedCondition(bool checked) : checked_(checked) {} + +std::vector<IBaseEvent*> CheckedCondition::ChangeOn( + controls::Control* control) const { + auto checkable_control = dynamic_cast<controls::ICheckableControl*>(control); + if (checkable_control) { + return {checkable_control->CheckedChangeEvent()}; + } else { + return {}; + } +} + +bool CheckedCondition::Judge(controls::Control* control) const { + auto checkable_control = dynamic_cast<controls::ICheckableControl*>(control); + if (checkable_control) { + return checkable_control->IsChecked() == checked_; + } + return false; +} } // namespace cru::ui::style |