aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-13 19:13:15 +0800
committercrupest <crupest@outlook.com>2022-02-13 19:13:15 +0800
commit308cdd54083dde627be738820f798ad25e73c300 (patch)
treeee0d0c342ff5ba2c6389df4a0c07550e55520eda /include/cru/ui
parentecda6570b707617c4b9365180684bbe94f43e4f9 (diff)
downloadcru-308cdd54083dde627be738820f798ad25e73c300.tar.gz
cru-308cdd54083dde627be738820f798ad25e73c300.tar.bz2
cru-308cdd54083dde627be738820f798ad25e73c300.zip
...
Diffstat (limited to 'include/cru/ui')
-rw-r--r--include/cru/ui/controls/CheckBox.h18
1 files changed, 16 insertions, 2 deletions
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<bool>* CheckedChangeEvent() override { return &checked_change_event_; }
void ApplyBorderStyle(const style::ApplyBorderStyleInfo& style) override;
+ helper::ClickState GetClickState() const {
+ return click_detector_.GetState();
+ }
+
+ IEvent<helper::ClickState>* ClickStateChangeEvent() override {
+ return click_detector_.StateChangeEvent();
+ }
+
private:
bool checked_ = false;
Event<bool> checked_change_event_;
std::unique_ptr<render::BorderRenderObject> container_render_object_;
+
+ helper::ClickDetector click_detector_;
};
} // namespace cru::ui::controls