diff options
| author | crupest <crupest@outlook.com> | 2022-02-17 18:32:52 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2022-02-17 18:32:52 +0800 |
| commit | ada641977cd57a50fc862243ba256c58efc065b8 (patch) | |
| tree | 0f2124b88496f42e2cce2e3aaa64211131c18b37 /src/theme_builder/components/properties/OptionalPropertyEditor.h | |
| parent | 9b3b13f78fffefb18f64aad88891d36009a8052e (diff) | |
| download | cru-ada641977cd57a50fc862243ba256c58efc065b8.tar.gz cru-ada641977cd57a50fc862243ba256c58efc065b8.tar.bz2 cru-ada641977cd57a50fc862243ba256c58efc065b8.zip | |
...
Diffstat (limited to 'src/theme_builder/components/properties/OptionalPropertyEditor.h')
| -rw-r--r-- | src/theme_builder/components/properties/OptionalPropertyEditor.h | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/theme_builder/components/properties/OptionalPropertyEditor.h b/src/theme_builder/components/properties/OptionalPropertyEditor.h index 4467d4de..d7362d50 100644 --- a/src/theme_builder/components/properties/OptionalPropertyEditor.h +++ b/src/theme_builder/components/properties/OptionalPropertyEditor.h @@ -1,5 +1,5 @@ #pragma once -#include "cru/ui/components/Component.h" +#include "../Editor.h" #include "cru/ui/controls/CheckBox.h" #include "cru/ui/controls/FlexLayout.h" @@ -7,7 +7,7 @@ namespace cru::theme_builder::components::properties { template <typename TEditor> -class OptionalPropertyEditor : public ui::components::Component { +class OptionalPropertyEditor : public Editor { public: using PropertyType = typename TEditor::PropertyType; @@ -17,7 +17,7 @@ class OptionalPropertyEditor : public ui::components::Component { editor_.ChangeEvent()->AddHandler([this](std::nullptr_t) { if (IsEnabled()) { - change_event_.Raise(nullptr); + RaiseChangeEvent(); } }); } @@ -29,7 +29,7 @@ class OptionalPropertyEditor : public ui::components::Component { void SetEnabled(bool enabled, bool trigger_change = true) { check_box_.SetChecked(enabled); if (trigger_change) { - change_event_.Raise(nullptr); + RaiseChangeEvent(); } } @@ -42,7 +42,7 @@ class OptionalPropertyEditor : public ui::components::Component { if (value) { SetEnabled(true, false); editor_.SetValue(*value, false); - if (trigger_change) change_event_.Raise(nullptr); + if (trigger_change) RaiseChangeEvent(); } else { SetEnabled(false, trigger_change); } @@ -50,13 +50,9 @@ class OptionalPropertyEditor : public ui::components::Component { TEditor* GetEditor() { return &editor_; } - IEvent<std::nullptr_t>* ChangeEvent() { return &change_event_; } - private: ui::controls::FlexLayout container_; ui::controls::CheckBox check_box_; TEditor editor_; - - Event<std::nullptr_t> change_event_; }; } // namespace cru::theme_builder::components::properties |
