From 471ba80b4d4e6ff485d3843bc1feadf0917a08c3 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 21 Sep 2021 23:17:50 +0200 Subject: [PATCH] ux: Properly evaluate pattern changes when already evaluating --- include/views/view_pattern_editor.hpp | 1 + source/views/view_pattern_editor.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/views/view_pattern_editor.hpp b/include/views/view_pattern_editor.hpp index d53ece472..7b7117d7e 100644 --- a/include/views/view_pattern_editor.hpp +++ b/include/views/view_pattern_editor.hpp @@ -30,6 +30,7 @@ namespace hex { int m_selectedPatternFile = 0; bool m_runAutomatically = false; bool m_evaluatorRunning = false; + bool m_hasUnevaluatedChanges = false; TextEditor m_textEditor; std::vector> m_console; diff --git a/source/views/view_pattern_editor.cpp b/source/views/view_pattern_editor.cpp index dd82a258f..1715901cf 100644 --- a/source/views/view_pattern_editor.cpp +++ b/source/views/view_pattern_editor.cpp @@ -246,13 +246,21 @@ namespace hex { if (this->m_evaluatorRunning) ImGui::TextSpinner("hex.view.pattern.evaluating"_lang); else - ImGui::Checkbox("hex.view.pattern.auto"_lang, &this->m_runAutomatically); + if (ImGui::Checkbox("hex.view.pattern.auto"_lang, &this->m_runAutomatically)) { + if (this->m_runAutomatically) + this->m_hasUnevaluatedChanges = true; + } if (this->m_textEditor.IsTextChanged()) { if (this->m_runAutomatically) - this->parsePattern(this->m_textEditor.GetText().data()); + this->m_hasUnevaluatedChanges = true; + } + if (this->m_hasUnevaluatedChanges && !this->m_evaluatorRunning) { + this->m_hasUnevaluatedChanges = false; ProjectFile::markDirty(); + + this->parsePattern(this->m_textEditor.GetText().data()); } }