From 3b875091c445b7465b9bd044914318989a94d2ad Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Fri, 21 Nov 2025 21:43:42 +0800 Subject: Clean codes. Remove member function const. --- .../components/properties/OptionalPropertyEditor.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/ThemeBuilder/components/properties/OptionalPropertyEditor.h') diff --git a/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h b/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h index 8db14114..b44b3b1b 100644 --- a/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h +++ b/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h @@ -1,14 +1,14 @@ #pragma once #include "../Editor.h" +#include "../LabeledMixin.h" #include "cru/ui/controls/CheckBox.h" #include "cru/ui/controls/FlexLayout.h" -#include "cru/ui/controls/TextBlock.h" #include namespace cru::theme_builder::components::properties { template -class OptionalPropertyEditor : public Editor { +class OptionalPropertyEditor : public Editor, public LabeledMixin { public: using PropertyType = typename TEditor::PropertyType; @@ -28,10 +28,7 @@ class OptionalPropertyEditor : public Editor { ui::controls::Control* GetRootControl() override { return &container_; } - std::string GetLabel() const { return label_.GetText(); } - void SetLabel(std::string label) { label_.SetText(std::move(label)); } - - bool IsEnabled() const { return check_box_.IsChecked(); } + bool IsEnabled() { return check_box_.IsChecked(); } void SetEnabled(bool enabled, bool trigger_change = true) { check_box_.SetChecked(enabled); if (trigger_change) { @@ -39,7 +36,7 @@ class OptionalPropertyEditor : public Editor { } } - std::optional GetValue() const { + std::optional GetValue() { return IsEnabled() ? std::optional(editor_.GetValue()) : std::nullopt; } @@ -58,7 +55,6 @@ class OptionalPropertyEditor : public Editor { private: ui::controls::FlexLayout container_; - ui::controls::TextBlock label_; ui::controls::CheckBox check_box_; TEditor editor_; }; -- cgit v1.2.3