aboutsummaryrefslogtreecommitdiff
path: root/src/theme_builder/components/StyleRuleEditor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/theme_builder/components/StyleRuleEditor.cpp')
-rw-r--r--src/theme_builder/components/StyleRuleEditor.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/theme_builder/components/StyleRuleEditor.cpp b/src/theme_builder/components/StyleRuleEditor.cpp
index 977672e3..7a99900b 100644
--- a/src/theme_builder/components/StyleRuleEditor.cpp
+++ b/src/theme_builder/components/StyleRuleEditor.cpp
@@ -1,15 +1,37 @@
#include "StyleRuleEditor.h"
+#include "conditions/ConditionEditor.h"
+#include "cru/ui/style/StyleRule.h"
namespace cru::theme_builder {
-StyleRuleEditor::StyleRuleEditor() {}
+StyleRuleEditor::StyleRuleEditor() {
+ main_layout_.SetFlexDirection(ui::controls::FlexDirection::Horizontal);
+ main_layout_.AddChild(&remove_button_);
-StyleRuleEditor::~StyleRuleEditor() { main_layout_.RemoveFromParent(); }
+ remove_button_.SetChild(&remove_button_text_);
+ remove_button_text_.SetText(u"X");
+
+ main_layout_.AddChild(&right_layout_);
+ right_layout_.SetFlexDirection(ui::controls::FlexDirection::Vertical);
-void StyleRuleEditor::BindStyleRule(ui::style::StyleRule *rule) {
- style_rule_ = rule;
- UpdateView();
+ remove_button_.ClickEvent()->AddSpyOnlyHandler(
+ [this] { remove_event_.Raise(nullptr); });
}
-void StyleRuleEditor::UpdateView() {}
+StyleRuleEditor::~StyleRuleEditor() { main_layout_.RemoveFromParent(); }
+
+ui::style::StyleRule StyleRuleEditor::GetValue() const {
+ return ui::style::StyleRule(condition_editor_->GetCondition(),
+ styler_editor_->GetStyler());
+}
+void StyleRuleEditor::SetValue(const ui::style::StyleRule& style_rule,
+ bool trigger_change) {
+ right_layout_.ClearChildren();
+ condition_editor_ =
+ components::conditions::CreateConditionEditor(style_rule.GetCondition());
+ styler_editor_ =
+ components::stylers::CreateStylerEditor(style_rule.GetStyler());
+ right_layout_.AddChild(condition_editor_->GetRootControl());
+ right_layout_.AddChild(styler_editor_->GetRootControl());
+}
} // namespace cru::theme_builder