mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-21 19:37:01 +00:00
Debug Tools: Added DebugFlashStyleColor() to identify a style color. Added to Style Editor.
This commit is contained in:
parent
c1a3c7f445
commit
7965494ff3
@ -51,6 +51,7 @@ Other changes:
|
||||
- Drag and Drop: Fixed drop target highlight on items temporarily pushing a widened clip rect
|
||||
(namely Selectables and Treenodes using SpanAllColumn flag) so the highlight properly covers
|
||||
all columns. (#7049, #4281, #3272)
|
||||
- Debug Tools: Added DebugFlashStyleColor() to identify a style color. Added to Style Editor.
|
||||
- Misc: Added extra courtesy ==/!= operators when IMGUI_DEFINE_MATH_OPERATORS is defined.
|
||||
- Misc: Fixed text functions fast-path for handling "%s" and "%.*s" to handle null pointers gracefully,
|
||||
like most printf implementations. (#7016, #3466, #6846) [@codefrog2002]
|
||||
|
37
imgui.cpp
37
imgui.cpp
@ -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)
|
||||
{
|
||||
|
3
imgui.h
3
imgui.h
@ -298,7 +298,7 @@ namespace ImGui
|
||||
|
||||
// Main
|
||||
IMGUI_API ImGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags)
|
||||
IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame!
|
||||
IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleColor(), PushStyleVar() to modify style mid-frame!
|
||||
IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame().
|
||||
IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all!
|
||||
IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can then get call GetDrawData().
|
||||
@ -964,6 +964,7 @@ namespace ImGui
|
||||
|
||||
// Debug Utilities
|
||||
IMGUI_API void DebugTextEncoding(const char* text);
|
||||
IMGUI_API void DebugFlashStyleColor(ImGuiCol idx);
|
||||
IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // This is called by IMGUI_CHECKVERSION() macro.
|
||||
|
||||
// Memory Allocators
|
||||
|
@ -6631,6 +6631,10 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
if (!filter.PassFilter(name))
|
||||
continue;
|
||||
ImGui::PushID(i);
|
||||
if (ImGui::Button("?"))
|
||||
ImGui::DebugFlashStyleColor((ImGuiCol)i);
|
||||
ImGui::SetItemTooltip("Flash given color to identify places where it is used.");
|
||||
ImGui::SameLine();
|
||||
ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags);
|
||||
if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0)
|
||||
{
|
||||
|
@ -1957,6 +1957,7 @@ struct ImGuiContext
|
||||
bool DebugShowGroupRects;
|
||||
|
||||
// Shared stacks
|
||||
ImGuiCol DebugFlashStyleColorIdx; // (Keep close to ColorStack to share cache line)
|
||||
ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
|
||||
ImVector<ImGuiStyleMod> StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin()
|
||||
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont() - inherited by Begin()
|
||||
@ -2153,6 +2154,8 @@ struct ImGuiContext
|
||||
bool DebugItemPickerActive; // Item picker is active (started with DebugStartItemPicker())
|
||||
ImU8 DebugItemPickerMouseButton;
|
||||
ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this ID
|
||||
float DebugFlashStyleColorTime;
|
||||
ImVec4 DebugFlashStyleColorBackup;
|
||||
ImGuiMetricsConfig DebugMetricsConfig;
|
||||
ImGuiIDStackTool DebugIDStackTool;
|
||||
ImGuiDebugAllocInfo DebugAllocInfo;
|
||||
@ -2335,6 +2338,8 @@ struct ImGuiContext
|
||||
DebugItemPickerActive = false;
|
||||
DebugItemPickerMouseButton = ImGuiMouseButton_Left;
|
||||
DebugItemPickerBreakId = 0;
|
||||
DebugFlashStyleColorTime = 0.0f;
|
||||
DebugFlashStyleColorIdx = ImGuiCol_COUNT;
|
||||
|
||||
memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
|
||||
FramerateSecPerFrameIdx = FramerateSecPerFrameCount = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user