aboutsummaryrefslogtreecommitdiff
path: root/src/ThemeBuilder/components/properties/TextPropertyEditor.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-05-15 14:15:31 +0800
committercrupest <crupest@outlook.com>2022-05-15 14:15:31 +0800
commit34a64e6ffefaab007578932ddbab931a25f1d56e (patch)
tree541fdb8279e829a129df62288d09916bf23c9200 /src/ThemeBuilder/components/properties/TextPropertyEditor.h
parent8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6 (diff)
downloadcru-34a64e6ffefaab007578932ddbab931a25f1d56e.tar.gz
cru-34a64e6ffefaab007578932ddbab931a25f1d56e.tar.bz2
cru-34a64e6ffefaab007578932ddbab931a25f1d56e.zip
...
Diffstat (limited to 'src/ThemeBuilder/components/properties/TextPropertyEditor.h')
-rw-r--r--src/ThemeBuilder/components/properties/TextPropertyEditor.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ThemeBuilder/components/properties/TextPropertyEditor.h b/src/ThemeBuilder/components/properties/TextPropertyEditor.h
new file mode 100644
index 00000000..c4944228
--- /dev/null
+++ b/src/ThemeBuilder/components/properties/TextPropertyEditor.h
@@ -0,0 +1,31 @@
+#pragma once
+#include "cru/ui/components/Component.h"
+#include "cru/ui/controls/FlexLayout.h"
+#include "cru/ui/controls/TextBlock.h"
+#include "cru/ui/controls/TextBox.h"
+
+namespace cru::theme_builder::components::properties {
+class TextPropertyEditor : public ui::components::Component {
+ public:
+ TextPropertyEditor();
+ ~TextPropertyEditor() override;
+
+ ui::controls::Control* GetRootControl() override { return &container_; }
+
+ String GetLabel() const { return label_.GetText(); }
+ void SetLabel(String label) { label_.SetText(std::move(label)); }
+
+ String GetText() const { return editor_.GetText(); }
+ StringView GetTextView() const { return editor_.GetTextView(); }
+ void SetText(String text) { editor_.SetText(std::move(text)); }
+
+ protected:
+ virtual bool Validate(StringView text, String* error_message);
+ virtual void OnTextChanged(StringView text);
+
+ private:
+ ui::controls::FlexLayout container_;
+ ui::controls::TextBlock label_;
+ ui::controls::TextBox editor_;
+};
+} // namespace cru::theme_builder::components::properties