aboutsummaryrefslogtreecommitdiff
path: root/src/theme_builder/components/properties/CheckBoxPropertyEditor.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-16 17:30:49 +0800
committercrupest <crupest@outlook.com>2022-02-16 17:30:49 +0800
commitda6f0bcfc6ec786cf14f67f100b4c50cf2325db4 (patch)
tree8e9a2c5389ba9f352f5823c0eec525a04993f2b4 /src/theme_builder/components/properties/CheckBoxPropertyEditor.h
parent674e8af2e92074b71c77e656a54244ce2693460c (diff)
downloadcru-da6f0bcfc6ec786cf14f67f100b4c50cf2325db4.tar.gz
cru-da6f0bcfc6ec786cf14f67f100b4c50cf2325db4.tar.bz2
cru-da6f0bcfc6ec786cf14f67f100b4c50cf2325db4.zip
...
Diffstat (limited to 'src/theme_builder/components/properties/CheckBoxPropertyEditor.h')
-rw-r--r--src/theme_builder/components/properties/CheckBoxPropertyEditor.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/theme_builder/components/properties/CheckBoxPropertyEditor.h b/src/theme_builder/components/properties/CheckBoxPropertyEditor.h
new file mode 100644
index 00000000..07ac4fe0
--- /dev/null
+++ b/src/theme_builder/components/properties/CheckBoxPropertyEditor.h
@@ -0,0 +1,35 @@
+#pragma once
+#include "cru/ui/components/Component.h"
+#include "cru/ui/controls/CheckBox.h"
+#include "cru/ui/controls/Control.h"
+#include "cru/ui/controls/FlexLayout.h"
+#include "cru/ui/controls/TextBlock.h"
+
+namespace cru::theme_builder::components::properties {
+class CheckBoxPropertyEditor : public ui::components::Component {
+ public:
+ using PropertyType = bool;
+
+ CheckBoxPropertyEditor();
+ ~CheckBoxPropertyEditor() override;
+
+ public:
+ ui::controls::Control* GetRootControl() override { return &container_; }
+
+ String GetLabel() const { return label_.GetText(); }
+ void SetLabel(String label) { label_.SetText(std::move(label)); }
+
+ bool GetValue() const { return check_box_.IsChecked(); }
+ void SetValue(bool value, bool trigger_change = true);
+
+ IEvent<std::nullptr_t>* ChangeEvent() { return &change_event_; }
+
+ private:
+ ui::controls::FlexLayout container_;
+ ui::controls::TextBlock label_;
+ ui::controls::CheckBox check_box_;
+
+ bool suppress_next_change_event_ = false;
+ Event<std::nullptr_t> change_event_;
+};
+} // namespace cru::theme_builder::components::properties