Debug Tools: Added DebugFlashStyleColor() to identify a style color. Added to Style Editor.

This commit is contained in:
ocornut
2023-11-28 19:33:19 +01:00
parent c1a3c7f445
commit 7965494ff3
5 changed files with 47 additions and 3 deletions

View File

@ -1100,6 +1100,7 @@ static void ErrorCheckNewFrameSanityChecks();
static void ErrorCheckEndFrameSanityChecks();
static void UpdateDebugToolItemPicker();
static void UpdateDebugToolStackQueries();
static void UpdateDebugToolFlashStyleColor();
// Inputs
static void UpdateKeyboardInputs();
@ -3097,7 +3098,8 @@ void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col)
backup.Col = idx;
backup.BackupValue = g.Style.Colors[idx];
g.ColorStack.push_back(backup);
g.Style.Colors[idx] = ColorConvertU32ToFloat4(col);
if (g.DebugFlashStyleColorIdx != idx)
g.Style.Colors[idx] = ColorConvertU32ToFloat4(col);
}
void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col)
@ -3107,7 +3109,8 @@ void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col)
backup.Col = idx;
backup.BackupValue = g.Style.Colors[idx];
g.ColorStack.push_back(backup);
g.Style.Colors[idx] = col;
if (g.DebugFlashStyleColorIdx != idx)
g.Style.Colors[idx] = col;
}
void ImGui::PopStyleColor(int count)
@ -4823,6 +4826,7 @@ void ImGui::NewFrame()
// [DEBUG] Update debug features
UpdateDebugToolItemPicker();
UpdateDebugToolStackQueries();
UpdateDebugToolFlashStyleColor();
if (g.DebugLocateFrames > 0 && --g.DebugLocateFrames == 0)
g.DebugLocateId = 0;
if (g.DebugLogClipperAutoDisableFrames > 0 && --g.DebugLogClipperAutoDisableFrames == 0)
@ -13891,6 +13895,35 @@ void ImGui::DebugTextEncoding(const char* str)
EndTable();
}
static void DebugFlashStyleColorStop()
{
ImGuiContext& g = *GImGui;
if (g.DebugFlashStyleColorIdx != ImGuiCol_COUNT)
g.Style.Colors[g.DebugFlashStyleColorIdx] = g.DebugFlashStyleColorBackup;
g.DebugFlashStyleColorIdx = ImGuiCol_COUNT;
}
// Flash a given style color for some + inhibit modifications of this color via PushStyleColor() calls.
void ImGui::DebugFlashStyleColor(ImGuiCol idx)
{
ImGuiContext& g = *GImGui;
DebugFlashStyleColorStop();
g.DebugFlashStyleColorTime = 0.5f;
g.DebugFlashStyleColorIdx = idx;
g.DebugFlashStyleColorBackup = g.Style.Colors[idx];
}
void ImGui::UpdateDebugToolFlashStyleColor()
{
ImGuiContext& g = *GImGui;
if (g.DebugFlashStyleColorTime <= 0.0f)
return;
ColorConvertHSVtoRGB(cosf(g.DebugFlashStyleColorTime * 6.0f) * 0.5f + 0.5f, 0.5f, 0.5f, g.Style.Colors[g.DebugFlashStyleColorIdx].x, g.Style.Colors[g.DebugFlashStyleColorIdx].y, g.Style.Colors[g.DebugFlashStyleColorIdx].z);
g.Style.Colors[g.DebugFlashStyleColorIdx].w = 1.0f;
if ((g.DebugFlashStyleColorTime -= g.IO.DeltaTime) <= 0.0f)
DebugFlashStyleColorStop();
}
// Avoid naming collision with imgui_demo.cpp's HelpMarker() for unity builds.
static void MetricsHelpMarker(const char* desc)
{