aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/theme_builder/components/StyleRuleEditor.cpp8
-rw-r--r--src/theme_builder/components/properties/CornerRadiusPropertyEditor.cpp8
-rw-r--r--src/theme_builder/components/properties/OptionalPropertyEditor.h2
-rw-r--r--src/theme_builder/components/properties/PointPropertyEditor.cpp30
-rw-r--r--src/theme_builder/components/properties/PointPropertyEditor.h1
5 files changed, 31 insertions, 18 deletions
diff --git a/src/theme_builder/components/StyleRuleEditor.cpp b/src/theme_builder/components/StyleRuleEditor.cpp
index b697f92c..aa2806b1 100644
--- a/src/theme_builder/components/StyleRuleEditor.cpp
+++ b/src/theme_builder/components/StyleRuleEditor.cpp
@@ -33,5 +33,13 @@ void StyleRuleEditor::SetValue(const ui::style::StyleRule& style_rule,
components::stylers::CreateStylerEditor(style_rule.GetStyler());
right_layout_.AddChild(condition_editor_->GetRootControl());
right_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
diff --git a/src/theme_builder/components/properties/CornerRadiusPropertyEditor.cpp b/src/theme_builder/components/properties/CornerRadiusPropertyEditor.cpp
index 635069fe..d124b8fe 100644
--- a/src/theme_builder/components/properties/CornerRadiusPropertyEditor.cpp
+++ b/src/theme_builder/components/properties/CornerRadiusPropertyEditor.cpp
@@ -38,10 +38,10 @@ CornerRadiusPropertyEditor::~CornerRadiusPropertyEditor() {}
void CornerRadiusPropertyEditor::SetValue(const ui::CornerRadius& corner_radius,
bool trigger_change) {
- left_top_editor_.SetValue(corner_radius_.left_top, false);
- right_top_editor_.SetValue(corner_radius_.right_top, false);
- left_bottom_editor_.SetValue(corner_radius_.left_bottom, false);
- right_bottom_editor_.SetValue(corner_radius_.right_bottom, false);
+ left_top_editor_.SetValue(corner_radius.left_top, false);
+ right_top_editor_.SetValue(corner_radius.right_top, false);
+ left_bottom_editor_.SetValue(corner_radius.left_bottom, false);
+ right_bottom_editor_.SetValue(corner_radius.right_bottom, false);
if (trigger_change) change_event_.Raise(nullptr);
}
} // namespace cru::theme_builder::components::properties
diff --git a/src/theme_builder/components/properties/OptionalPropertyEditor.h b/src/theme_builder/components/properties/OptionalPropertyEditor.h
index 98b9786d..4467d4de 100644
--- a/src/theme_builder/components/properties/OptionalPropertyEditor.h
+++ b/src/theme_builder/components/properties/OptionalPropertyEditor.h
@@ -41,7 +41,7 @@ class OptionalPropertyEditor : public ui::components::Component {
void SetValue(std::optional<PropertyType> value, bool trigger_change = true) {
if (value) {
SetEnabled(true, false);
- editor_.SetValue(*value);
+ editor_.SetValue(*value, false);
if (trigger_change) change_event_.Raise(nullptr);
} else {
SetEnabled(false, trigger_change);
diff --git a/src/theme_builder/components/properties/PointPropertyEditor.cpp b/src/theme_builder/components/properties/PointPropertyEditor.cpp
index 702b26e8..60f3c06c 100644
--- a/src/theme_builder/components/properties/PointPropertyEditor.cpp
+++ b/src/theme_builder/components/properties/PointPropertyEditor.cpp
@@ -9,17 +9,21 @@ PointPropertyEditor::PointPropertyEditor() {
container_.AddChild(&text_);
text_.TextChangeEvent()->AddHandler([this](std::nullptr_t) {
- auto text = text_.GetTextView();
- auto point_mapper =
- ui::mapper::MapperRegistry::GetInstance()->GetMapper<ui::Point>();
- try {
- auto point = point_mapper->MapFromString(text.ToString());
- point_ = point;
- is_text_valid_ = true;
- change_event_.Raise(nullptr);
- } catch (const Exception&) {
- is_text_valid_ = false;
- // TODO: Show error!
+ if (!suppress_next_change_event_) {
+ auto text = text_.GetTextView();
+ auto point_mapper =
+ ui::mapper::MapperRegistry::GetInstance()->GetMapper<ui::Point>();
+ try {
+ auto point = point_mapper->MapFromString(text.ToString());
+ point_ = point;
+ is_text_valid_ = true;
+ change_event_.Raise(nullptr);
+ } catch (const Exception&) {
+ is_text_valid_ = false;
+ // TODO: Show error!
+ }
+ } else {
+ suppress_next_change_event_ = false;
}
});
}
@@ -29,9 +33,9 @@ PointPropertyEditor::~PointPropertyEditor() {}
void PointPropertyEditor::SetValue(const ui::Point& point,
bool trigger_change) {
point_ = point;
- text_.SetText(ConvertPointToString(point));
is_text_valid_ = true;
- if (trigger_change) change_event_.Raise(nullptr);
+ if (!trigger_change) suppress_next_change_event_ = true;
+ text_.SetText(ConvertPointToString(point));
}
String PointPropertyEditor::ConvertPointToString(const ui::Point& point) {
diff --git a/src/theme_builder/components/properties/PointPropertyEditor.h b/src/theme_builder/components/properties/PointPropertyEditor.h
index e3f52925..e4604c84 100644
--- a/src/theme_builder/components/properties/PointPropertyEditor.h
+++ b/src/theme_builder/components/properties/PointPropertyEditor.h
@@ -34,6 +34,7 @@ class PointPropertyEditor : public ui::components::Component {
ui::controls::TextBox text_;
bool is_text_valid_;
+ bool suppress_next_change_event_ = false;
Event<std::nullptr_t> change_event_;
};
} // namespace cru::theme_builder::components::properties