aboutsummaryrefslogtreecommitdiff
path: root/src/theme_builder/components/stylers/CompoundStylerEditor.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-16 20:22:25 +0800
committercrupest <crupest@outlook.com>2022-02-16 20:22:25 +0800
commit3cd44092c44651650a760752a3d374f610ca4f77 (patch)
treed3481e8d93d8d47674d0df46eb765ccf9100bca8 /src/theme_builder/components/stylers/CompoundStylerEditor.h
parent6459edc7c8af9e5c9bafe4f1635194334f42f415 (diff)
downloadcru-3cd44092c44651650a760752a3d374f610ca4f77.tar.gz
cru-3cd44092c44651650a760752a3d374f610ca4f77.tar.bz2
cru-3cd44092c44651650a760752a3d374f610ca4f77.zip
...
Diffstat (limited to 'src/theme_builder/components/stylers/CompoundStylerEditor.h')
-rw-r--r--src/theme_builder/components/stylers/CompoundStylerEditor.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/theme_builder/components/stylers/CompoundStylerEditor.h b/src/theme_builder/components/stylers/CompoundStylerEditor.h
new file mode 100644
index 00000000..5b1f86e0
--- /dev/null
+++ b/src/theme_builder/components/stylers/CompoundStylerEditor.h
@@ -0,0 +1,54 @@
+#pragma once
+#include "StylerEditor.h"
+#include "cru/common/ClonablePtr.h"
+#include "cru/ui/components/PopupButton.h"
+#include "cru/ui/controls/FlexLayout.h"
+#include "cru/ui/style/Styler.h"
+
+namespace cru::theme_builder::components::stylers {
+class CompoundStylerEditorChild : public ui::components::Component {
+ public:
+ explicit CompoundStylerEditorChild(std::unique_ptr<StylerEditor>&& editor);
+ ~CompoundStylerEditorChild() override;
+
+ public:
+ ui::controls::Control* GetRootControl() override { return &container_; }
+
+ StylerEditor* GetStylerEditor() { return styler_editor_.get(); }
+
+ IEvent<std::nullptr_t>* RemoveEvent() { return &remove_event_; }
+
+ private:
+ ui::controls::FlexLayout container_;
+ ui::controls::Button remove_button_;
+ ui::controls::TextBlock remove_button_text_;
+ std::unique_ptr<StylerEditor> styler_editor_;
+
+ Event<std::nullptr_t> remove_event_;
+};
+
+class CompoundStylerEditor : public StylerEditor {
+ public:
+ CompoundStylerEditor();
+ ~CompoundStylerEditor() override;
+
+ public:
+ ClonablePtr<ui::style::CompoundStyler> GetValue();
+ void SetValue(ui::style::CompoundStyler* styler, bool trigger_change = true);
+ void SetValue(const ClonablePtr<ui::style::CompoundStyler>& styler,
+ bool trigger_change = true) {
+ SetValue(styler.get(), trigger_change);
+ }
+
+ ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
+
+ IEvent<std::nullptr_t>* ChangeEvent() { return &change_event_; }
+
+ private:
+ ui::controls::FlexLayout children_container_;
+ std::vector<std::unique_ptr<CompoundStylerEditorChild>> children_;
+ ui::components::PopupMenuTextButton add_child_button_;
+
+ Event<std::nullptr_t> change_event_;
+};
+} // namespace cru::theme_builder::components::stylers