From 308cdd54083dde627be738820f798ad25e73c300 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 13 Feb 2022 19:13:15 +0800 Subject: ... --- include/cru/ui/controls/CheckBox.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'include/cru/ui/controls/CheckBox.h') diff --git a/include/cru/ui/controls/CheckBox.h b/include/cru/ui/controls/CheckBox.h index a892389b..1c81b284 100644 --- a/include/cru/ui/controls/CheckBox.h +++ b/include/cru/ui/controls/CheckBox.h @@ -1,13 +1,16 @@ #pragma once +#include "../helper/ClickDetector.h" +#include "../render/BorderRenderObject.h" #include "IBorderControl.h" #include "ICheckableControl.h" +#include "IClickableControl.h" #include "NoChildControl.h" -#include "cru/ui/render/BorderRenderObject.h" namespace cru::ui::controls { class CRU_UI_API CheckBox : public NoChildControl, public virtual IBorderControl, - public virtual ICheckableControl { + public virtual ICheckableControl, + public virtual IClickableControl { public: CheckBox(); ~CheckBox() override; @@ -18,15 +21,26 @@ class CRU_UI_API CheckBox : public NoChildControl, bool IsChecked() const override { return checked_; } void SetChecked(bool checked) override; + void Toggle() { SetChecked(!checked_); } IEvent* CheckedChangeEvent() override { return &checked_change_event_; } void ApplyBorderStyle(const style::ApplyBorderStyleInfo& style) override; + helper::ClickState GetClickState() const { + return click_detector_.GetState(); + } + + IEvent* ClickStateChangeEvent() override { + return click_detector_.StateChangeEvent(); + } + private: bool checked_ = false; Event checked_change_event_; std::unique_ptr container_render_object_; + + helper::ClickDetector click_detector_; }; } // namespace cru::ui::controls -- cgit v1.2.3