aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/controls
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/ui/controls')
-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