mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 03:47:00 +00:00
Metrics: Tweak, reorganize tools menu.
This commit is contained in:
parent
a5dec42866
commit
788bb58b6b
@ -87,6 +87,7 @@ Other changes:
|
||||
- Debug Tools: Debug Log: Hide its own clipper log to reduce noise in the output. (#5855)
|
||||
- Debug Tools: Debug Log: Clicking any filter with SHIFT held enables it for 2 frames only,
|
||||
making it easier when dealing with spammy logs. (#5855)
|
||||
- Debug Tools: Metrics: Reorganize Tools menu.
|
||||
- Misc: Added IMGUI_USER_H_FILENAME to change the path included when using
|
||||
IMGUI_INCLUDE_IMGUI_USER_H. (#7039) [@bryceberger]
|
||||
- Misc: Rework debug display of texture id in Metrics window to avoid compile-error when
|
||||
|
54
imgui.cpp
54
imgui.cpp
@ -8149,7 +8149,7 @@ const char* ImGui::GetKeyName(ImGuiKey key)
|
||||
}
|
||||
|
||||
// ImGuiMod_Shortcut is translated to either Ctrl or Super.
|
||||
void ImGui::GetKeyChordName(ImGuiKeyChord key_chord, char* out_buf, int out_buf_size)
|
||||
const char* ImGui::GetKeyChordName(ImGuiKeyChord key_chord, char* out_buf, int out_buf_size)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (key_chord & ImGuiMod_Shortcut)
|
||||
@ -8160,6 +8160,7 @@ void ImGui::GetKeyChordName(ImGuiKeyChord key_chord, char* out_buf, int out_buf_
|
||||
(key_chord & ImGuiMod_Alt) ? "Alt+" : "",
|
||||
(key_chord & ImGuiMod_Super) ? (g.IO.ConfigMacOSXBehaviors ? "Cmd+" : "Super+") : "",
|
||||
GetKeyName((ImGuiKey)(key_chord & ~ImGuiMod_Mask_)));
|
||||
return out_buf;
|
||||
}
|
||||
|
||||
// t0 = previous time (e.g.: g.Time - g.IO.DeltaTime)
|
||||
@ -8234,11 +8235,15 @@ static void ImGui::UpdateKeyRoutingTable(ImGuiKeyRoutingTable* rt)
|
||||
rt->EntriesNext.push_back(*routing_entry); // Write alive ones into new buffer
|
||||
|
||||
// Apply routing to owner if there's no owner already (RoutingCurr == None at this point)
|
||||
// This is the result of previous frame's SetShortcutRouting() call.
|
||||
if (routing_entry->Mods == g.IO.KeyMods)
|
||||
{
|
||||
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
||||
if (owner_data->OwnerCurr == ImGuiKeyOwner_None)
|
||||
{
|
||||
owner_data->OwnerCurr = routing_entry->RoutingCurr;
|
||||
//IMGUI_DEBUG_LOG("SetKeyOwner(%s, owner_id=0x%08X) via Routing\n", GetKeyName(key), routing_entry->RoutingCurr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8363,6 +8368,7 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI
|
||||
if (flags & ImGuiInputFlags_RouteUnlessBgFocused)
|
||||
if (g.NavWindow == NULL)
|
||||
return false;
|
||||
// Note how ImGuiInputFlags_RouteAlways won't set routing and thus won't set owner. May want to rework this?
|
||||
if (flags & ImGuiInputFlags_RouteAlways)
|
||||
return true;
|
||||
|
||||
@ -9264,10 +9270,11 @@ bool ImGui::TestKeyOwner(ImGuiKey key, ImGuiID owner_id)
|
||||
// - SetKeyOwner(..., Any or None, Lock) : set lock
|
||||
void ImGui::SetKeyOwner(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(IsNamedKeyOrModKey(key) && (owner_id != ImGuiKeyOwner_Any || (flags & (ImGuiInputFlags_LockThisFrame | ImGuiInputFlags_LockUntilRelease)))); // Can only use _Any with _LockXXX flags (to eat a key away without an ID to retrieve it)
|
||||
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetKeyOwner) == 0); // Passing flags not supported by this function!
|
||||
//IMGUI_DEBUG_LOG("SetKeyOwner(%s, owner_id=0x%08X, flags=%08X)\n", GetKeyName(key), owner_id, flags);
|
||||
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
||||
owner_data->OwnerCurr = owner_data->OwnerNext = owner_id;
|
||||
|
||||
@ -9336,6 +9343,9 @@ bool ImGui::IsKeyChordPressed(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiIn
|
||||
|
||||
bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags flags)
|
||||
{
|
||||
//ImGuiContext& g = *GImGui;
|
||||
//IMGUI_DEBUG_LOG("Shortcut(%s, owner_id=0x%08X, flags=%X)\n", GetKeyChordName(key_chord, g.TempBuffer.Data, g.TempBuffer.Size), owner_id, flags);
|
||||
|
||||
// When using (owner_id == 0/Any): SetShortcutRouting() will use CurrentFocusScopeId and filter with this, so IsKeyPressed() is fine with he 0/Any.
|
||||
if ((flags & ImGuiInputFlags_RouteMask_) == 0)
|
||||
flags |= ImGuiInputFlags_RouteFocused;
|
||||
@ -12371,6 +12381,7 @@ static void ImGui::NavUpdateWindowing()
|
||||
}
|
||||
|
||||
// Start CTRL+Tab or Square+L/R window selection
|
||||
// (g.ConfigNavWindowingKeyNext/g.ConfigNavWindowingKeyPrev defaults are ImGuiMod_Ctrl|ImGuiKey_Tab and ImGuiMod_Ctrl|ImGuiMod_Shift|ImGuiKey_Tab)
|
||||
const ImGuiID owner_id = ImHashStr("###NavUpdateWindowing");
|
||||
const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
|
||||
const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
|
||||
@ -14061,18 +14072,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
// Tools
|
||||
if (TreeNode("Tools"))
|
||||
{
|
||||
bool show_encoding_viewer = TreeNode("UTF-8 Encoding viewer");
|
||||
SameLine();
|
||||
MetricsHelpMarker("You can also call ImGui::DebugTextEncoding() from your code with a given string to test that your UTF-8 encoding settings are correct.");
|
||||
if (show_encoding_viewer)
|
||||
{
|
||||
static char buf[100] = "";
|
||||
SetNextItemWidth(-FLT_MIN);
|
||||
InputText("##Text", buf, IM_ARRAYSIZE(buf));
|
||||
if (buf[0] != 0)
|
||||
DebugTextEncoding(buf);
|
||||
TreePop();
|
||||
}
|
||||
SeparatorText("Debug breaks");
|
||||
|
||||
// The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted.
|
||||
if (Checkbox("Show Item Picker", &g.DebugItemPickerActive) && g.DebugItemPickerActive)
|
||||
@ -14080,6 +14080,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
SameLine();
|
||||
MetricsHelpMarker("Will call the IM_DEBUG_BREAK() macro to break in debugger.\nWarning: If you don't have a debugger attached, this will probably crash.");
|
||||
|
||||
SeparatorText("Visualize");
|
||||
|
||||
Checkbox("Show Debug Log", &cfg->ShowDebugLog);
|
||||
SameLine();
|
||||
MetricsHelpMarker("You can also call ImGui::ShowDebugLogWindow() from your code.");
|
||||
@ -14151,10 +14153,24 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
}
|
||||
Checkbox("Show groups rectangles", &g.DebugShowGroupRects); // Storing in context as this is used by group code and prefers to be in hot-data
|
||||
|
||||
SeparatorText("Validate");
|
||||
|
||||
Checkbox("Debug Begin/BeginChild return value", &io.ConfigDebugBeginReturnValueLoop);
|
||||
SameLine();
|
||||
MetricsHelpMarker("Some calls to Begin()/BeginChild() will return false.\n\nWill cycle through window depths then repeat. Windows should be flickering while running.");
|
||||
|
||||
Checkbox("UTF-8 Encoding viewer", &cfg->ShowTextEncodingViewer);
|
||||
SameLine();
|
||||
MetricsHelpMarker("You can also call ImGui::DebugTextEncoding() from your code with a given string to test that your UTF-8 encoding settings are correct.");
|
||||
if (cfg->ShowTextEncodingViewer)
|
||||
{
|
||||
static char buf[64] = "";
|
||||
SetNextItemWidth(-FLT_MIN);
|
||||
InputText("##Text", buf, IM_ARRAYSIZE(buf));
|
||||
if (buf[0] != 0)
|
||||
DebugTextEncoding(buf);
|
||||
}
|
||||
|
||||
TreePop();
|
||||
}
|
||||
|
||||
@ -14389,7 +14405,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
Text("KEY OWNERS");
|
||||
{
|
||||
Indent();
|
||||
if (BeginChild("##owners", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_NoSavedSettings))
|
||||
if (BeginChild("##owners", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 8), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_NoSavedSettings))
|
||||
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
||||
{
|
||||
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
||||
@ -14403,9 +14419,11 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
Unindent();
|
||||
}
|
||||
Text("SHORTCUT ROUTING");
|
||||
SameLine();
|
||||
MetricsHelpMarker("Declared shortcut routes automatically set key owner when mods matches.");
|
||||
{
|
||||
Indent();
|
||||
if (BeginChild("##routes", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_NoSavedSettings))
|
||||
if (BeginChild("##routes", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 8), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_NoSavedSettings))
|
||||
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
||||
{
|
||||
ImGuiKeyRoutingTable* rt = &g.KeysRoutingTable;
|
||||
@ -14413,8 +14431,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
{
|
||||
char key_chord_name[64];
|
||||
ImGuiKeyRoutingData* routing_data = &rt->Entries[idx];
|
||||
GetKeyChordName(key | routing_data->Mods, key_chord_name, IM_ARRAYSIZE(key_chord_name));
|
||||
Text("%s: 0x%08X", key_chord_name, routing_data->RoutingCurr);
|
||||
ImGuiKeyChord key_chord = key | routing_data->Mods;
|
||||
Text("%s: 0x%08X", GetKeyChordName(key_chord, key_chord_name, IM_ARRAYSIZE(key_chord_name)), routing_data->RoutingCurr);
|
||||
DebugLocateItemOnHover(routing_data->RoutingCurr);
|
||||
idx = routing_data->NextEntryIndex;
|
||||
}
|
||||
|
@ -227,13 +227,13 @@ namespace ImStb
|
||||
#else
|
||||
#define IMGUI_DEBUG_LOG(...) ((void)0)
|
||||
#endif
|
||||
#define IMGUI_DEBUG_LOG_ACTIVEID(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventActiveId) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_FOCUS(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventFocus) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_POPUP(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_NAV(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventNav) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_SELECTION(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventSelection)IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_CLIPPER(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventClipper) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_IO(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_ACTIVEID(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventActiveId) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_FOCUS(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventFocus) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_POPUP(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_NAV(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventNav) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_SELECTION(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventSelection) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_CLIPPER(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventClipper) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
#define IMGUI_DEBUG_LOG_IO(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||
|
||||
// Static Asserts
|
||||
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
|
||||
@ -1820,6 +1820,7 @@ struct ImGuiMetricsConfig
|
||||
bool ShowTablesRects = false;
|
||||
bool ShowDrawCmdMesh = true;
|
||||
bool ShowDrawCmdBoundingBoxes = true;
|
||||
bool ShowTextEncodingViewer = false;
|
||||
bool ShowAtlasTintedWithTextColor = false;
|
||||
int ShowWindowsRectsType = -1;
|
||||
int ShowTablesRectsType = -1;
|
||||
@ -3116,7 +3117,7 @@ namespace ImGui
|
||||
|
||||
IMGUI_API ImGuiKeyData* GetKeyData(ImGuiContext* ctx, ImGuiKey key);
|
||||
inline ImGuiKeyData* GetKeyData(ImGuiKey key) { ImGuiContext& g = *GImGui; return GetKeyData(&g, key); }
|
||||
IMGUI_API void GetKeyChordName(ImGuiKeyChord key_chord, char* out_buf, int out_buf_size);
|
||||
IMGUI_API const char* GetKeyChordName(ImGuiKeyChord key_chord, char* out_buf, int out_buf_size);
|
||||
inline ImGuiKey MouseButtonToKey(ImGuiMouseButton button) { IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT); return (ImGuiKey)(ImGuiKey_MouseLeft + button); }
|
||||
IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
|
||||
IMGUI_API ImVec2 GetKeyMagnitude2d(ImGuiKey key_left, ImGuiKey key_right, ImGuiKey key_up, ImGuiKey key_down);
|
||||
|
@ -5030,7 +5030,7 @@ void ImGui::DebugNodeInputTextState(ImGuiInputTextState* state)
|
||||
Text("CurLenW: %d, CurLenA: %d, Cursor: %d, Selection: %d..%d", state->CurLenW, state->CurLenA, stb_state->cursor, stb_state->select_start, stb_state->select_end);
|
||||
Text("has_preferred_x: %d (%.2f)", stb_state->has_preferred_x, stb_state->preferred_x);
|
||||
Text("undo_point: %d, redo_point: %d, undo_char_point: %d, redo_char_point: %d", undo_state->undo_point, undo_state->redo_point, undo_state->undo_char_point, undo_state->redo_char_point);
|
||||
if (BeginChild("undopoints", ImVec2(0.0f, GetTextLineHeight() * 15), ImGuiChildFlags_Border)) // Visualize undo state
|
||||
if (BeginChild("undopoints", ImVec2(0.0f, GetTextLineHeight() * 10), ImGuiChildFlags_Border | ImGuiChildFlags_ResizeY)) // Visualize undo state
|
||||
{
|
||||
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
||||
for (int n = 0; n < IMSTB_TEXTEDIT_UNDOSTATECOUNT; n++)
|
||||
|
Loading…
Reference in New Issue
Block a user