diff options
author | crupest <crupest@outlook.com> | 2022-03-29 16:37:33 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-29 16:37:33 +0800 |
commit | e45106981ba5720947cdb56a3f48ad3e91a996b8 (patch) | |
tree | 77a0300f4badb0dfc888983e75d5d2c1ad1d7c8a /src/theme_builder/components/StyleRuleSetEditor.cpp | |
parent | 7a564d98db0b7c7be5b3bfac955cb88998a472ac (diff) | |
download | cru-e45106981ba5720947cdb56a3f48ad3e91a996b8.tar.gz cru-e45106981ba5720947cdb56a3f48ad3e91a996b8.tar.bz2 cru-e45106981ba5720947cdb56a3f48ad3e91a996b8.zip |
...
Diffstat (limited to 'src/theme_builder/components/StyleRuleSetEditor.cpp')
-rw-r--r-- | src/theme_builder/components/StyleRuleSetEditor.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/theme_builder/components/StyleRuleSetEditor.cpp b/src/theme_builder/components/StyleRuleSetEditor.cpp index 15c88d33..bc28a462 100644 --- a/src/theme_builder/components/StyleRuleSetEditor.cpp +++ b/src/theme_builder/components/StyleRuleSetEditor.cpp @@ -4,6 +4,7 @@ #include <optional> #include "cru/common/Exception.h" #include "cru/common/String.h" +#include "cru/ui/DeleteLater.h" #include "cru/ui/ThemeManager.h" #include "cru/ui/controls/FlexLayout.h" #include "cru/ui/model/IListChangeNotify.h" @@ -54,7 +55,7 @@ void StyleRuleSetEditor::BindStyleRuleSet( Index StyleRuleSetEditor::IndexOfRuleEditor(StyleRuleEditor* editor) { auto iter = std::find_if(style_rule_editors_.cbegin(), style_rule_editors_.cend(), - [editor](const std::unique_ptr<StyleRuleEditor>& p) { + [editor](const ui::DeleteLaterPtr<StyleRuleEditor>& p) { return p.get() == editor; }); return iter - style_rule_editors_.cbegin(); @@ -69,7 +70,7 @@ void StyleRuleSetEditor::UpdateView( for (auto i = change->position; i < change->position + change->count; ++i) { const auto& rule = style_rule_set->GetStyleRule(i); - auto style_rule_editor = std::make_unique<StyleRuleEditor>(); + auto style_rule_editor = ui::MakeDeleteLaterPtr<StyleRuleEditor>(); style_rule_editor->SetValue(rule, false); style_rule_editor->RemoveEvent()->AddSpyOnlyHandler( [this, editor = style_rule_editor.get()] { @@ -77,6 +78,7 @@ void StyleRuleSetEditor::UpdateView( }); style_rule_editor->ChangeEvent()->AddSpyOnlyHandler( [this, editor = style_rule_editor.get()]() { + suppress_next_set_ = true; style_rule_set_->SetStyleRule(IndexOfRuleEditor(editor), editor->GetValue()); }); @@ -95,6 +97,10 @@ void StyleRuleSetEditor::UpdateView( break; } case ui::model::ListChangeType::kItemSet: { + if (suppress_next_set_) { + suppress_next_set_ = false; + break; + } for (auto i = change->position; i < change->position + change->count; ++i) { const auto& rule = style_rule_set->GetStyleRule(i); |