diff options
author | crupest <crupest@outlook.com> | 2022-02-13 00:31:30 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-13 00:31:30 +0800 |
commit | ecda6570b707617c4b9365180684bbe94f43e4f9 (patch) | |
tree | 9af11cf15a2f5a6531ca40e5e26aced1c2bcecbb /src/ui | |
parent | 614c9d27ff0aa8eeff663469979af191c07792e3 (diff) | |
download | cru-ecda6570b707617c4b9365180684bbe94f43e4f9.tar.gz cru-ecda6570b707617c4b9365180684bbe94f43e4f9.tar.bz2 cru-ecda6570b707617c4b9365180684bbe94f43e4f9.zip |
...
Diffstat (limited to 'src/ui')
-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 |