diff --git a/src/ui/windows/console_tab.cpp b/src/ui/windows/console_tab.cpp index 1e3ca75..ca8b9b1 100644 --- a/src/ui/windows/console_tab.cpp +++ b/src/ui/windows/console_tab.cpp @@ -572,12 +572,14 @@ void ConsoleTab::renderToolbar(ConsoleCommandExecutor& exec) ImGui::SameLine(); { float btnSz = ImGui::GetFrameHeight(); + // Capture the flag BEFORE the button can flip it — the push/pop guards must use the SAME value, + // or a click leaves the colour stack unbalanced (ImGui then draws a red error rect on the window). + const bool dim = !s_line_accents_enabled; const char* icon = s_line_accents_enabled ? ICON_MD_FORMAT_COLOR_FILL : ICON_MD_FORMAT_COLOR_RESET; - if (!s_line_accents_enabled) - ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled())); + if (dim) ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled())); if (TactileButton(icon, ImVec2(btnSz, btnSz), Type().iconMed())) s_line_accents_enabled = !s_line_accents_enabled; - if (!s_line_accents_enabled) ImGui::PopStyleColor(); + if (dim) ImGui::PopStyleColor(); if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("console_toggle_accents")); } @@ -585,11 +587,11 @@ void ConsoleTab::renderToolbar(ConsoleCommandExecutor& exec) ImGui::SameLine(); { float btnSz = ImGui::GetFrameHeight(); - if (!s_line_text_color_enabled) - ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled())); + const bool dim = !s_line_text_color_enabled; // capture before the click flips it (balanced push/pop) + if (dim) ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled())); if (TactileButton(ICON_MD_FORMAT_COLOR_TEXT, ImVec2(btnSz, btnSz), Type().iconMed())) s_line_text_color_enabled = !s_line_text_color_enabled; - if (!s_line_text_color_enabled) ImGui::PopStyleColor(); + if (dim) ImGui::PopStyleColor(); if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("console_toggle_text_color")); }