diff options
author | crupest <crupest@outlook.com> | 2022-02-16 17:30:49 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-16 17:30:49 +0800 |
commit | da6f0bcfc6ec786cf14f67f100b4c50cf2325db4 (patch) | |
tree | 8e9a2c5389ba9f352f5823c0eec525a04993f2b4 /src/theme_builder/components/properties/CheckBoxPropertyEditor.cpp | |
parent | 674e8af2e92074b71c77e656a54244ce2693460c (diff) | |
download | cru-da6f0bcfc6ec786cf14f67f100b4c50cf2325db4.tar.gz cru-da6f0bcfc6ec786cf14f67f100b4c50cf2325db4.tar.bz2 cru-da6f0bcfc6ec786cf14f67f100b4c50cf2325db4.zip |
...
Diffstat (limited to 'src/theme_builder/components/properties/CheckBoxPropertyEditor.cpp')
-rw-r--r-- | src/theme_builder/components/properties/CheckBoxPropertyEditor.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/theme_builder/components/properties/CheckBoxPropertyEditor.cpp b/src/theme_builder/components/properties/CheckBoxPropertyEditor.cpp new file mode 100644 index 00000000..2e921f96 --- /dev/null +++ b/src/theme_builder/components/properties/CheckBoxPropertyEditor.cpp @@ -0,0 +1,26 @@ +#include "CheckBoxPropertyEditor.h" + +namespace cru::theme_builder::components::properties { +CheckBoxPropertyEditor::CheckBoxPropertyEditor() { + container_.SetFlexDirection(ui::controls::FlexDirection::Horizontal); + container_.AddChild(&label_); + container_.AddChild(&check_box_); + + check_box_.CheckedChangeEvent()->AddSpyOnlyHandler([this] { + if (!suppress_next_change_event_) { + change_event_.Raise(nullptr); + } else { + suppress_next_change_event_ = false; + } + }); +} + +CheckBoxPropertyEditor::~CheckBoxPropertyEditor() { + container_.RemoveFromParent(); +} + +void CheckBoxPropertyEditor::SetValue(bool value, bool trigger_change) { + if (!trigger_change) suppress_next_change_event_ = true; + check_box_.SetChecked(value); +} +} // namespace cru::theme_builder::components::properties |