diff options
| author | crupest <crupest@outlook.com> | 2022-02-14 00:28:51 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2022-02-14 00:28:51 +0800 |
| commit | 091c0419a254a28f80963193b36bf0a7f30d6590 (patch) | |
| tree | d47e7726569023c5f8492d81042ad7ade09cb9dc /src/theme_builder/components/properties/OptionalPropertyEditor.h | |
| parent | 308cdd54083dde627be738820f798ad25e73c300 (diff) | |
| download | cru-091c0419a254a28f80963193b36bf0a7f30d6590.tar.gz cru-091c0419a254a28f80963193b36bf0a7f30d6590.tar.bz2 cru-091c0419a254a28f80963193b36bf0a7f30d6590.zip | |
...
Diffstat (limited to 'src/theme_builder/components/properties/OptionalPropertyEditor.h')
| -rw-r--r-- | src/theme_builder/components/properties/OptionalPropertyEditor.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/theme_builder/components/properties/OptionalPropertyEditor.h b/src/theme_builder/components/properties/OptionalPropertyEditor.h new file mode 100644 index 00000000..e343727f --- /dev/null +++ b/src/theme_builder/components/properties/OptionalPropertyEditor.h @@ -0,0 +1,28 @@ +#pragma once +#include "cru/ui/components/Component.h" +#include "cru/ui/controls/CheckBox.h" +#include "cru/ui/controls/FlexLayout.h" + +namespace cru::theme_builder::components::properties { +template <typename TEditor> +class OptionalPropertyEditor : public ui::components::Component { + public: + OptionalPropertyEditor() { + container_.AddChild(&check_box_); + container_.AddChild(editor_->GetRootControl()); + } + ~OptionalPropertyEditor() override { container_.RemoveFromParent(); } + + ui::controls::Control* GetRootControl() override { return &container_; } + + bool IsEnabled() const { return check_box_.IsChecked(); } + void SetEnabled(bool enabled) { check_box_.SetChecked(enabled); } + + TEditor* GetEditor() { return &editor_; } + + private: + ui::controls::FlexLayout container_; + ui::controls::CheckBox check_box_; + TEditor editor_; +}; +} // namespace cru::theme_builder::components::properties |
