From ecda6570b707617c4b9365180684bbe94f43e4f9 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 13 Feb 2022 00:31:30 +0800 Subject: ... --- src/ui/style/Condition.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/ui') 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 CheckedCondition::ChangeOn( + controls::Control* control) const { + auto checkable_control = dynamic_cast(control); + if (checkable_control) { + return {checkable_control->CheckedChangeEvent()}; + } else { + return {}; + } +} + +bool CheckedCondition::Judge(controls::Control* control) const { + auto checkable_control = dynamic_cast(control); + if (checkable_control) { + return checkable_control->IsChecked() == checked_; + } + return false; +} } // namespace cru::ui::style -- cgit v1.2.3