aboutsummaryrefslogtreecommitdiff
path: root/src/ThemeBuilder/components/properties/OptionalPropertyEditor.h
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-21 21:43:42 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-21 21:43:42 +0800
commit3b875091c445b7465b9bd044914318989a94d2ad (patch)
treea358aebb488ec1ddc86bf87b8038bacd5d7515cb /src/ThemeBuilder/components/properties/OptionalPropertyEditor.h
parent3cda35dbcbbe1e3854b880169c0efa0fc7a79264 (diff)
downloadcru-3b875091c445b7465b9bd044914318989a94d2ad.tar.gz
cru-3b875091c445b7465b9bd044914318989a94d2ad.tar.bz2
cru-3b875091c445b7465b9bd044914318989a94d2ad.zip
Clean codes. Remove member function const.
Diffstat (limited to 'src/ThemeBuilder/components/properties/OptionalPropertyEditor.h')
-rw-r--r--src/ThemeBuilder/components/properties/OptionalPropertyEditor.h12
1 files changed, 4 insertions, 8 deletions
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 <optional>
namespace cru::theme_builder::components::properties {
template <typename TEditor>
-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<PropertyType> GetValue() const {
+ std::optional<PropertyType> GetValue() {
return IsEnabled() ? std::optional<PropertyType>(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_;
};