aboutsummaryrefslogtreecommitdiff
path: root/src/theme_builder/components/StyleRuleEditor.cpp
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/theme_builder/components/StyleRuleEditor.cpp
parent8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6 (diff)
downloadcru-34a64e6ffefaab007578932ddbab931a25f1d56e.tar.gz
cru-34a64e6ffefaab007578932ddbab931a25f1d56e.tar.bz2
cru-34a64e6ffefaab007578932ddbab931a25f1d56e.zip
...
Diffstat (limited to 'src/theme_builder/components/StyleRuleEditor.cpp')
-rw-r--r--src/theme_builder/components/StyleRuleEditor.cpp62
1 files changed, 0 insertions, 62 deletions
diff --git a/src/theme_builder/components/StyleRuleEditor.cpp b/src/theme_builder/components/StyleRuleEditor.cpp
deleted file mode 100644
index dcb33184..00000000
--- a/src/theme_builder/components/StyleRuleEditor.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "StyleRuleEditor.h"
-#include "Common.h"
-#include "conditions/ConditionEditor.h"
-#include "cru/ui/ThemeManager.h"
-#include "cru/ui/style/StyleRule.h"
-
-namespace cru::theme_builder::components {
-StyleRuleEditor::StyleRuleEditor() {
- container_.SetChild(&main_layout_);
- container_.SetBackgroundBrush(CreateRandomEditorBackgroundBrush());
-
- main_layout_.SetFlexDirection(ui::controls::FlexDirection::Vertical);
- main_layout_.SetItemCrossAlign(ui::controls::FlexCrossAlignment::Start);
-
- main_layout_.AddChild(&head_layout_);
-
- label_.SetText(u"Style Rule");
- head_layout_.AddChild(&label_);
- head_layout_.AddChild(&remove_button_);
-
- remove_button_.GetStyleRuleSet()->SetParent(
- ui::ThemeManager::GetInstance()->GetResourceStyleRuleSet(
- u"cru.theme_builder.icon-button.style"));
- remove_button_.SetIconWithSvgPathDataStringResourceKey(u"icon.close",
- {0, 0, 16, 16});
- remove_button_.SetIconFillColor(ui::colors::red);
-
- main_layout_.AddChild(&body_layout_);
- body_layout_.SetFlexDirection(ui::controls::FlexDirection::Vertical);
- body_layout_.SetItemCrossAlign(ui::controls::FlexCrossAlignment::Start);
- body_layout_.SetMargin({10, 0, 0, 0});
-
- remove_button_.ClickEvent()->AddSpyOnlyHandler(
- [this] { remove_event_.Raise(nullptr); });
-}
-
-StyleRuleEditor::~StyleRuleEditor() {}
-
-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) {
- body_layout_.ClearChildren();
- condition_editor_ =
- components::conditions::CreateConditionEditor(style_rule.GetCondition());
- styler_editor_ =
- components::stylers::CreateStylerEditor(style_rule.GetStyler());
- body_layout_.AddChild(condition_editor_->GetRootControl());
- body_layout_.AddChild(styler_editor_->GetRootControl());
- condition_editor_->ChangeEvent()->AddSpyOnlyHandler(
- [this] { change_event_.Raise(nullptr); });
- styler_editor_->ChangeEvent()->AddSpyOnlyHandler(
- [this] { change_event_.Raise(nullptr); });
-
- if (trigger_change) {
- change_event_.Raise(nullptr);
- }
-}
-} // namespace cru::theme_builder::components