aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-12 22:21:47 +0800
committercrupest <crupest@outlook.com>2022-02-12 22:21:47 +0800
commit614c9d27ff0aa8eeff663469979af191c07792e3 (patch)
tree08905333656e2a9e473d65f16bfc4819ea19624e /include
parent0f91e36d49cbdadedce96009954810bffd614359 (diff)
downloadcru-614c9d27ff0aa8eeff663469979af191c07792e3.tar.gz
cru-614c9d27ff0aa8eeff663469979af191c07792e3.tar.bz2
cru-614c9d27ff0aa8eeff663469979af191c07792e3.zip
...
Diffstat (limited to 'include')
-rw-r--r--include/cru/ui/controls/CheckBox.h32
-rw-r--r--include/cru/ui/controls/ICheckableControl.h11
2 files changed, 43 insertions, 0 deletions
diff --git a/include/cru/ui/controls/CheckBox.h b/include/cru/ui/controls/CheckBox.h
new file mode 100644
index 00000000..a892389b
--- /dev/null
+++ b/include/cru/ui/controls/CheckBox.h
@@ -0,0 +1,32 @@
+#pragma once
+#include "IBorderControl.h"
+#include "ICheckableControl.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:
+ CheckBox();
+ ~CheckBox() override;
+
+ render::RenderObject* GetRenderObject() const override {
+ return container_render_object_.get();
+ }
+
+ bool IsChecked() const override { return checked_; }
+ void SetChecked(bool checked) override;
+
+ IEvent<bool>* CheckedChangeEvent() override { return &checked_change_event_; }
+
+ void ApplyBorderStyle(const style::ApplyBorderStyleInfo& style) override;
+
+ private:
+ bool checked_ = false;
+ Event<bool> checked_change_event_;
+
+ std::unique_ptr<render::BorderRenderObject> container_render_object_;
+};
+} // namespace cru::ui::controls
diff --git a/include/cru/ui/controls/ICheckableControl.h b/include/cru/ui/controls/ICheckableControl.h
new file mode 100644
index 00000000..2c7aace8
--- /dev/null
+++ b/include/cru/ui/controls/ICheckableControl.h
@@ -0,0 +1,11 @@
+#pragma once
+#include "../Base.h"
+#include "cru/common/Event.h"
+
+namespace cru::ui::controls {
+struct CRU_UI_API ICheckableControl : virtual Interface {
+ virtual bool IsChecked() const = 0;
+ virtual void SetChecked(bool checked) = 0;
+ virtual IEvent<bool>* CheckedChangeEvent() = 0;
+};
+} // namespace cru::ui::controls