aboutsummaryrefslogtreecommitdiff
path: root/src/theme_builder/components/stylers
diff options
context:
space:
mode:
Diffstat (limited to 'src/theme_builder/components/stylers')
-rw-r--r--src/theme_builder/components/stylers/BorderStylerEditor.cpp17
-rw-r--r--src/theme_builder/components/stylers/BorderStylerEditor.h4
-rw-r--r--src/theme_builder/components/stylers/CompoundStylerEditor.cpp29
-rw-r--r--src/theme_builder/components/stylers/CompoundStylerEditor.h4
-rw-r--r--src/theme_builder/components/stylers/CursorStylerEditor.cpp4
-rw-r--r--src/theme_builder/components/stylers/CursorStylerEditor.h4
-rw-r--r--src/theme_builder/components/stylers/StylerEditor.h5
7 files changed, 25 insertions, 42 deletions
diff --git a/src/theme_builder/components/stylers/BorderStylerEditor.cpp b/src/theme_builder/components/stylers/BorderStylerEditor.cpp
index 2b169dcf..b2522786 100644
--- a/src/theme_builder/components/stylers/BorderStylerEditor.cpp
+++ b/src/theme_builder/components/stylers/BorderStylerEditor.cpp
@@ -15,16 +15,11 @@ BorderStylerEditor::BorderStylerEditor() {
GetContainer()->AddChild(foreground_brush_editor_.GetRootControl());
GetContainer()->AddChild(background_brush_editor_.GetRootControl());
- auto connect = [this](IEvent<std::nullptr_t>* event) {
- event->AddHandler(
- [this](std::nullptr_t) { this->change_event_.Raise(nullptr); });
- };
-
- connect(corner_radius_editor_.ChangeEvent());
- connect(thickness_editor_.ChangeEvent());
- connect(brush_editor_.ChangeEvent());
- connect(foreground_brush_editor_.ChangeEvent());
- connect(background_brush_editor_.ChangeEvent());
+ ConnectChangeEvent(corner_radius_editor_);
+ ConnectChangeEvent(thickness_editor_);
+ ConnectChangeEvent(brush_editor_);
+ ConnectChangeEvent(foreground_brush_editor_);
+ ConnectChangeEvent(background_brush_editor_);
}
BorderStylerEditor::~BorderStylerEditor() {}
@@ -93,7 +88,7 @@ void BorderStylerEditor::SetValue(ui::style::BorderStyler* styler,
}
if (trigger_change) {
- change_event_.Raise(nullptr);
+ RaiseChangeEvent();
}
}
diff --git a/src/theme_builder/components/stylers/BorderStylerEditor.h b/src/theme_builder/components/stylers/BorderStylerEditor.h
index ec871775..539262d6 100644
--- a/src/theme_builder/components/stylers/BorderStylerEditor.h
+++ b/src/theme_builder/components/stylers/BorderStylerEditor.h
@@ -21,8 +21,6 @@ class BorderStylerEditor : public StylerEditor {
ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
- IEvent<std::nullptr_t>* ChangeEvent() override { return &change_event_; }
-
private:
properties::OptionalPropertyEditor<properties::CornerRadiusPropertyEditor>
corner_radius_editor_;
@@ -34,7 +32,5 @@ class BorderStylerEditor : public StylerEditor {
foreground_brush_editor_;
properties::OptionalPropertyEditor<properties::ColorPropertyEditor>
background_brush_editor_;
-
- Event<std::nullptr_t> change_event_;
};
} // namespace cru::theme_builder::components::stylers
diff --git a/src/theme_builder/components/stylers/CompoundStylerEditor.cpp b/src/theme_builder/components/stylers/CompoundStylerEditor.cpp
index 568c34f3..ac1cc0ea 100644
--- a/src/theme_builder/components/stylers/CompoundStylerEditor.cpp
+++ b/src/theme_builder/components/stylers/CompoundStylerEditor.cpp
@@ -12,7 +12,7 @@ CompoundStylerEditorChild::CompoundStylerEditorChild(
container_.AddChild(&remove_button_);
remove_button_.SetChild(&remove_button_text_);
- remove_button_text_.SetText(u"-");
+ remove_button_text_.SetText(u"X");
container_.AddChild(styler_editor_->GetRootControl());
@@ -49,17 +49,18 @@ CompoundStylerEditor::CompoundStylerEditor() {
break;
}
if (editor) {
+ ConnectChangeEvent(editor.get());
auto child =
std::make_unique<CompoundStylerEditorChild>(std::move(editor));
child->RemoveEvent()->AddSpyOnlyHandler([this, c = child.get()] {
auto index = this->children_container_.IndexOf(c->GetRootControl());
this->children_.erase(this->children_.begin() + index);
this->children_container_.RemoveChildAt(index);
- change_event_.Raise(nullptr);
+ RaiseChangeEvent();
});
children_container_.AddChild(child->GetRootControl());
children_.push_back(std::move(child));
- change_event_.Raise(nullptr);
+ RaiseChangeEvent();
}
});
}
@@ -80,18 +81,16 @@ void CompoundStylerEditor::SetValue(ui::style::CompoundStyler* value,
children_container_.ClearChildren();
for (const auto& styler : value->GetChildren()) {
auto editor = CreateStylerEditor(styler.get());
- if (editor) {
- auto child =
- std::make_unique<CompoundStylerEditorChild>(std::move(editor));
- child->RemoveEvent()->AddSpyOnlyHandler([this, c = child.get()] {
- auto index = this->children_container_.IndexOf(c->GetRootControl());
- this->children_.erase(this->children_.begin() + index);
- this->children_container_.RemoveChildAt(index);
- change_event_.Raise(nullptr);
- });
- children_.push_back(std::move(child));
- children_container_.AddChild(children_.back()->GetRootControl());
- }
+ ConnectChangeEvent(editor.get());
+ auto child = std::make_unique<CompoundStylerEditorChild>(std::move(editor));
+ child->RemoveEvent()->AddSpyOnlyHandler([this, c = child.get()] {
+ auto index = this->children_container_.IndexOf(c->GetRootControl());
+ this->children_.erase(this->children_.begin() + index);
+ this->children_container_.RemoveChildAt(index);
+ RaiseChangeEvent();
+ });
+ children_.push_back(std::move(child));
+ children_container_.AddChild(children_.back()->GetRootControl());
}
}
} // namespace cru::theme_builder::components::stylers
diff --git a/src/theme_builder/components/stylers/CompoundStylerEditor.h b/src/theme_builder/components/stylers/CompoundStylerEditor.h
index a5c6fbb2..33a3d7cf 100644
--- a/src/theme_builder/components/stylers/CompoundStylerEditor.h
+++ b/src/theme_builder/components/stylers/CompoundStylerEditor.h
@@ -42,13 +42,9 @@ class CompoundStylerEditor : public StylerEditor {
ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
- IEvent<std::nullptr_t>* ChangeEvent() override { 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
diff --git a/src/theme_builder/components/stylers/CursorStylerEditor.cpp b/src/theme_builder/components/stylers/CursorStylerEditor.cpp
index d7e5c351..9984d81a 100644
--- a/src/theme_builder/components/stylers/CursorStylerEditor.cpp
+++ b/src/theme_builder/components/stylers/CursorStylerEditor.cpp
@@ -10,6 +10,8 @@ CursorStylerEditor::CursorStylerEditor() {
cursor_select_.SetLabel(u"Cursor");
cursor_select_.SetItems({u"arrow", u"hand", u"ibeam"});
cursor_select_.SetSelectedIndex(0);
+
+ ConnectChangeEvent(cursor_select_);
}
CursorStylerEditor::~CursorStylerEditor() {}
@@ -57,7 +59,7 @@ void CursorStylerEditor::SetValue(ui::style::CursorStyler* styler,
}
if (trigger_change) {
- change_event_.Raise(nullptr);
+ RaiseChangeEvent();
}
}
} // namespace cru::theme_builder::components::stylers
diff --git a/src/theme_builder/components/stylers/CursorStylerEditor.h b/src/theme_builder/components/stylers/CursorStylerEditor.h
index 5c443819..552619a0 100644
--- a/src/theme_builder/components/stylers/CursorStylerEditor.h
+++ b/src/theme_builder/components/stylers/CursorStylerEditor.h
@@ -18,11 +18,7 @@ class CursorStylerEditor : public StylerEditor {
ClonablePtr<ui::style::Styler> GetStyler() override { return GetValue(); }
- IEvent<std::nullptr_t>* ChangeEvent() override { return &change_event_; }
-
private:
properties::SelectPropertyEditor cursor_select_;
-
- Event<std::nullptr_t> change_event_;
};
} // namespace cru::theme_builder::components::stylers
diff --git a/src/theme_builder/components/stylers/StylerEditor.h b/src/theme_builder/components/stylers/StylerEditor.h
index b3e0d287..02005481 100644
--- a/src/theme_builder/components/stylers/StylerEditor.h
+++ b/src/theme_builder/components/stylers/StylerEditor.h
@@ -1,11 +1,11 @@
#pragma once
-#include "cru/ui/components/Component.h"
+#include "../Editor.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/controls/TextBlock.h"
#include "cru/ui/style/Styler.h"
namespace cru::theme_builder::components::stylers {
-class StylerEditor : public ui::components::Component {
+class StylerEditor : public Editor {
public:
StylerEditor();
~StylerEditor() override;
@@ -19,7 +19,6 @@ class StylerEditor : public ui::components::Component {
void SetLabel(String label) { label_.SetText(std::move(label)); }
virtual ClonablePtr<ui::style::Styler> GetStyler() = 0;
- virtual IEvent<std::nullptr_t>* ChangeEvent() = 0;
private:
ui::controls::FlexLayout container_;