From ada641977cd57a50fc862243ba256c58efc065b8 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 17 Feb 2022 18:32:52 +0800 Subject: ... --- .../components/properties/OptionalPropertyEditor.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/theme_builder/components/properties/OptionalPropertyEditor.h') 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 -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* ChangeEvent() { return &change_event_; } - private: ui::controls::FlexLayout container_; ui::controls::CheckBox check_box_; TEditor editor_; - - Event change_event_; }; } // namespace cru::theme_builder::components::properties -- cgit v1.2.3