mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-25 13:07:01 +00:00
Using range-based for where it makes sense. (#4537)
This commit is contained in:
parent
33ea1e8b78
commit
82d177ccbd
190
imgui.cpp
190
imgui.cpp
@ -2551,16 +2551,15 @@ void ImGuiTextFilter::Build()
|
|||||||
input_range.split(',', &Filters);
|
input_range.split(',', &Filters);
|
||||||
|
|
||||||
CountGrep = 0;
|
CountGrep = 0;
|
||||||
for (int i = 0; i != Filters.Size; i++)
|
for (ImGuiTextRange& f : Filters)
|
||||||
{
|
{
|
||||||
ImGuiTextRange& f = Filters[i];
|
|
||||||
while (f.b < f.e && ImCharIsBlankA(f.b[0]))
|
while (f.b < f.e && ImCharIsBlankA(f.b[0]))
|
||||||
f.b++;
|
f.b++;
|
||||||
while (f.e > f.b && ImCharIsBlankA(f.e[-1]))
|
while (f.e > f.b && ImCharIsBlankA(f.e[-1]))
|
||||||
f.e--;
|
f.e--;
|
||||||
if (f.empty())
|
if (f.empty())
|
||||||
continue;
|
continue;
|
||||||
if (Filters[i].b[0] != '-')
|
if (f.b[0] != '-')
|
||||||
CountGrep += 1;
|
CountGrep += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2573,9 +2572,8 @@ bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
|
|||||||
if (text == NULL)
|
if (text == NULL)
|
||||||
text = "";
|
text = "";
|
||||||
|
|
||||||
for (int i = 0; i != Filters.Size; i++)
|
for (const ImGuiTextRange& f : Filters)
|
||||||
{
|
{
|
||||||
const ImGuiTextRange& f = Filters[i];
|
|
||||||
if (f.empty())
|
if (f.empty())
|
||||||
continue;
|
continue;
|
||||||
if (f.b[0] == '-')
|
if (f.b[0] == '-')
|
||||||
@ -2964,14 +2962,14 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
|||||||
// - Very important: when a starting position is after our maximum item, we set Min to (ItemsCount - 1). This allows us to handle most forms of wrapping.
|
// - Very important: when a starting position is after our maximum item, we set Min to (ItemsCount - 1). This allows us to handle most forms of wrapping.
|
||||||
// - Due to how Selectable extra padding they tend to be "unaligned" with exact unit in the item list,
|
// - Due to how Selectable extra padding they tend to be "unaligned" with exact unit in the item list,
|
||||||
// which with the flooring/ceiling tend to lead to 2 items instead of one being submitted.
|
// which with the flooring/ceiling tend to lead to 2 items instead of one being submitted.
|
||||||
for (int i = 0; i < data->Ranges.Size; i++)
|
for (ImGuiListClipperRange& range : data->Ranges)
|
||||||
if (data->Ranges[i].PosToIndexConvert)
|
if (range.PosToIndexConvert)
|
||||||
{
|
{
|
||||||
int m1 = (int)(((double)data->Ranges[i].Min - window->DC.CursorPos.y - data->LossynessOffset) / clipper->ItemsHeight);
|
int m1 = (int)(((double)range.Min - window->DC.CursorPos.y - data->LossynessOffset) / clipper->ItemsHeight);
|
||||||
int m2 = (int)((((double)data->Ranges[i].Max - window->DC.CursorPos.y - data->LossynessOffset) / clipper->ItemsHeight) + 0.999999f);
|
int m2 = (int)((((double)range.Max - window->DC.CursorPos.y - data->LossynessOffset) / clipper->ItemsHeight) + 0.999999f);
|
||||||
data->Ranges[i].Min = ImClamp(already_submitted + m1 + data->Ranges[i].PosToIndexOffsetMin, already_submitted, clipper->ItemsCount - 1);
|
range.Min = ImClamp(already_submitted + m1 + range.PosToIndexOffsetMin, already_submitted, clipper->ItemsCount - 1);
|
||||||
data->Ranges[i].Max = ImClamp(already_submitted + m2 + data->Ranges[i].PosToIndexOffsetMax, data->Ranges[i].Min + 1, clipper->ItemsCount);
|
range.Max = ImClamp(already_submitted + m2 + range.PosToIndexOffsetMax, range.Min + 1, clipper->ItemsCount);
|
||||||
data->Ranges[i].PosToIndexConvert = false;
|
range.PosToIndexConvert = false;
|
||||||
}
|
}
|
||||||
ImGuiListClipper_SortAndFuseRanges(data->Ranges, data->StepNo);
|
ImGuiListClipper_SortAndFuseRanges(data->Ranges, data->StepNo);
|
||||||
}
|
}
|
||||||
@ -3482,13 +3480,12 @@ void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCurso
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
|
IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
|
||||||
ImFontAtlas* font_atlas = g.DrawListSharedData.Font->ContainerAtlas;
|
ImFontAtlas* font_atlas = g.DrawListSharedData.Font->ContainerAtlas;
|
||||||
for (int n = 0; n < g.Viewports.Size; n++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
{
|
{
|
||||||
// We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor.
|
// We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor.
|
||||||
ImVec2 offset, size, uv[4];
|
ImVec2 offset, size, uv[4];
|
||||||
if (!font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2]))
|
if (!font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2]))
|
||||||
continue;
|
continue;
|
||||||
ImGuiViewportP* viewport = g.Viewports[n];
|
|
||||||
const ImVec2 pos = base_pos - offset;
|
const ImVec2 pos = base_pos - offset;
|
||||||
const float scale = base_scale;
|
const float scale = base_scale;
|
||||||
if (!viewport->GetMainRect().Overlaps(ImRect(pos, pos + ImVec2(size.x + 2, size.y + 2) * scale)))
|
if (!viewport->GetMainRect().Overlaps(ImRect(pos, pos + ImVec2(size.x + 2, size.y + 2) * scale)))
|
||||||
@ -3707,9 +3704,9 @@ void ImGui::RemoveContextHook(ImGuiContext* ctx, ImGuiID hook_id)
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
IM_ASSERT(hook_id != 0);
|
IM_ASSERT(hook_id != 0);
|
||||||
for (int n = 0; n < g.Hooks.Size; n++)
|
for (ImGuiContextHook& hook : g.Hooks)
|
||||||
if (g.Hooks[n].HookId == hook_id)
|
if (hook.HookId == hook_id)
|
||||||
g.Hooks[n].Type = ImGuiContextHookType_PendingRemoval_;
|
hook.Type = ImGuiContextHookType_PendingRemoval_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call context hooks (used by e.g. test engine)
|
// Call context hooks (used by e.g. test engine)
|
||||||
@ -3717,9 +3714,9 @@ void ImGui::RemoveContextHook(ImGuiContext* ctx, ImGuiID hook_id)
|
|||||||
void ImGui::CallContextHooks(ImGuiContext* ctx, ImGuiContextHookType hook_type)
|
void ImGui::CallContextHooks(ImGuiContext* ctx, ImGuiContextHookType hook_type)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
for (int n = 0; n < g.Hooks.Size; n++)
|
for (ImGuiContextHook& hook : g.Hooks)
|
||||||
if (g.Hooks[n].Type == hook_type)
|
if (hook.Type == hook_type)
|
||||||
g.Hooks[n].Callback(&g, &g.Hooks[n]);
|
hook.Callback(&g, &hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4554,8 +4551,8 @@ void ImGui::NewFrame()
|
|||||||
SetCurrentFont(GetDefaultFont());
|
SetCurrentFont(GetDefaultFont());
|
||||||
IM_ASSERT(g.Font->IsLoaded());
|
IM_ASSERT(g.Font->IsLoaded());
|
||||||
ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
|
ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||||
for (int n = 0; n < g.Viewports.Size; n++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
virtual_space.Add(g.Viewports[n]->GetMainRect());
|
virtual_space.Add(viewport->GetMainRect());
|
||||||
g.DrawListSharedData.ClipRectFullscreen = virtual_space.ToVec4();
|
g.DrawListSharedData.ClipRectFullscreen = virtual_space.ToVec4();
|
||||||
g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
|
g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
|
||||||
g.DrawListSharedData.SetCircleTessellationMaxError(g.Style.CircleTessellationMaxError);
|
g.DrawListSharedData.SetCircleTessellationMaxError(g.Style.CircleTessellationMaxError);
|
||||||
@ -4570,8 +4567,8 @@ void ImGui::NewFrame()
|
|||||||
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
|
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
|
||||||
|
|
||||||
// Mark rendering data as invalid to prevent user who may have a handle on it to use it.
|
// Mark rendering data as invalid to prevent user who may have a handle on it to use it.
|
||||||
for (int n = 0; n < g.Viewports.Size; n++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
g.Viewports[n]->DrawDataP.Valid = false;
|
viewport->DrawDataP.Valid = false;
|
||||||
|
|
||||||
// Drag and drop keep the source ID alive so even if the source disappear our state is consistent
|
// Drag and drop keep the source ID alive so even if the source disappear our state is consistent
|
||||||
if (g.DragDropActive && g.DragDropPayload.SourceId == g.ActiveId)
|
if (g.DragDropActive && g.DragDropPayload.SourceId == g.ActiveId)
|
||||||
@ -4717,9 +4714,8 @@ void ImGui::NewFrame()
|
|||||||
// Mark all windows as not visible and compact unused memory.
|
// Mark all windows as not visible and compact unused memory.
|
||||||
IM_ASSERT(g.WindowsFocusOrder.Size <= g.Windows.Size);
|
IM_ASSERT(g.WindowsFocusOrder.Size <= g.Windows.Size);
|
||||||
const float memory_compact_start_time = (g.GcCompactAll || g.IO.ConfigMemoryCompactTimer < 0.0f) ? FLT_MAX : (float)g.Time - g.IO.ConfigMemoryCompactTimer;
|
const float memory_compact_start_time = (g.GcCompactAll || g.IO.ConfigMemoryCompactTimer < 0.0f) ? FLT_MAX : (float)g.Time - g.IO.ConfigMemoryCompactTimer;
|
||||||
for (int i = 0; i != g.Windows.Size; i++)
|
for (ImGuiWindow* window : g.Windows)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = g.Windows[i];
|
|
||||||
window->WasActive = window->Active;
|
window->WasActive = window->Active;
|
||||||
window->Active = false;
|
window->Active = false;
|
||||||
window->WriteAccessed = false;
|
window->WriteAccessed = false;
|
||||||
@ -4735,9 +4731,9 @@ void ImGui::NewFrame()
|
|||||||
for (int i = 0; i < g.TablesLastTimeActive.Size; i++)
|
for (int i = 0; i < g.TablesLastTimeActive.Size; i++)
|
||||||
if (g.TablesLastTimeActive[i] >= 0.0f && g.TablesLastTimeActive[i] < memory_compact_start_time)
|
if (g.TablesLastTimeActive[i] >= 0.0f && g.TablesLastTimeActive[i] < memory_compact_start_time)
|
||||||
TableGcCompactTransientBuffers(g.Tables.GetByIndex(i));
|
TableGcCompactTransientBuffers(g.Tables.GetByIndex(i));
|
||||||
for (int i = 0; i < g.TablesTempData.Size; i++)
|
for (ImGuiTableTempData& table_temp_data : g.TablesTempData)
|
||||||
if (g.TablesTempData[i].LastTimeActive >= 0.0f && g.TablesTempData[i].LastTimeActive < memory_compact_start_time)
|
if (table_temp_data.LastTimeActive >= 0.0f && table_temp_data.LastTimeActive < memory_compact_start_time)
|
||||||
TableGcCompactTransientBuffers(&g.TablesTempData[i]);
|
TableGcCompactTransientBuffers(&table_temp_data);
|
||||||
if (g.GcCompactAll)
|
if (g.GcCompactAll)
|
||||||
GcCompactTransientMiscBuffers();
|
GcCompactTransientMiscBuffers();
|
||||||
g.GcCompactAll = false;
|
g.GcCompactAll = false;
|
||||||
@ -4817,12 +4813,9 @@ static void AddWindowToDrawData(ImGuiWindow* window, int layer)
|
|||||||
ImGuiViewportP* viewport = g.Viewports[0];
|
ImGuiViewportP* viewport = g.Viewports[0];
|
||||||
g.IO.MetricsRenderWindows++;
|
g.IO.MetricsRenderWindows++;
|
||||||
ImGui::AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[layer], window->DrawList);
|
ImGui::AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[layer], window->DrawList);
|
||||||
for (int i = 0; i < window->DC.ChildWindows.Size; i++)
|
for (ImGuiWindow* child : window->DC.ChildWindows)
|
||||||
{
|
|
||||||
ImGuiWindow* child = window->DC.ChildWindows[i];
|
|
||||||
if (IsWindowActiveAndVisible(child)) // Clipped children may have been marked not active
|
if (IsWindowActiveAndVisible(child)) // Clipped children may have been marked not active
|
||||||
AddWindowToDrawData(child, layer);
|
AddWindowToDrawData(child, layer);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int GetWindowDisplayLayer(ImGuiWindow* window)
|
static inline int GetWindowDisplayLayer(ImGuiWindow* window)
|
||||||
@ -5047,9 +5040,8 @@ void ImGui::EndFrame()
|
|||||||
// We cannot do that on FocusWindow() because children may not exist yet
|
// We cannot do that on FocusWindow() because children may not exist yet
|
||||||
g.WindowsTempSortBuffer.resize(0);
|
g.WindowsTempSortBuffer.resize(0);
|
||||||
g.WindowsTempSortBuffer.reserve(g.Windows.Size);
|
g.WindowsTempSortBuffer.reserve(g.Windows.Size);
|
||||||
for (int i = 0; i != g.Windows.Size; i++)
|
for (ImGuiWindow* window : g.Windows)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = g.Windows[i];
|
|
||||||
if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it
|
if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it
|
||||||
continue;
|
continue;
|
||||||
AddWindowToSortBuffer(&g.WindowsTempSortBuffer, window);
|
AddWindowToSortBuffer(&g.WindowsTempSortBuffer, window);
|
||||||
@ -5092,9 +5084,8 @@ void ImGui::Render()
|
|||||||
RenderDimmedBackgrounds();
|
RenderDimmedBackgrounds();
|
||||||
|
|
||||||
// Add background ImDrawList (for each active viewport)
|
// Add background ImDrawList (for each active viewport)
|
||||||
for (int n = 0; n != g.Viewports.Size; n++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
{
|
{
|
||||||
ImGuiViewportP* viewport = g.Viewports[n];
|
|
||||||
InitViewportDrawData(viewport);
|
InitViewportDrawData(viewport);
|
||||||
if (viewport->BgFgDrawLists[0] != NULL)
|
if (viewport->BgFgDrawLists[0] != NULL)
|
||||||
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
|
AddDrawListToDrawDataEx(&viewport->DrawDataP, viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
|
||||||
@ -5104,9 +5095,8 @@ void ImGui::Render()
|
|||||||
ImGuiWindow* windows_to_render_top_most[2];
|
ImGuiWindow* windows_to_render_top_most[2];
|
||||||
windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL;
|
windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL;
|
||||||
windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingListWindow : NULL);
|
windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingListWindow : NULL);
|
||||||
for (int n = 0; n != g.Windows.Size; n++)
|
for (ImGuiWindow* window : g.Windows)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = g.Windows[n];
|
|
||||||
IM_MSVC_WARNING_SUPPRESS(6011); // Static Analysis false positive "warning C6011: Dereferencing NULL pointer 'window'"
|
IM_MSVC_WARNING_SUPPRESS(6011); // Static Analysis false positive "warning C6011: Dereferencing NULL pointer 'window'"
|
||||||
if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1])
|
if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1])
|
||||||
AddRootWindowToDrawData(window);
|
AddRootWindowToDrawData(window);
|
||||||
@ -5121,9 +5111,8 @@ void ImGui::Render()
|
|||||||
|
|
||||||
// Setup ImDrawData structures for end-user
|
// Setup ImDrawData structures for end-user
|
||||||
g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0;
|
g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0;
|
||||||
for (int n = 0; n < g.Viewports.Size; n++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
{
|
{
|
||||||
ImGuiViewportP* viewport = g.Viewports[n];
|
|
||||||
FlattenDrawDataIntoSingleLayer(&viewport->DrawDataBuilder);
|
FlattenDrawDataIntoSingleLayer(&viewport->DrawDataBuilder);
|
||||||
|
|
||||||
// Add foreground ImDrawList (for each active viewport)
|
// Add foreground ImDrawList (for each active viewport)
|
||||||
@ -5133,8 +5122,8 @@ void ImGui::Render()
|
|||||||
// We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch).
|
// We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch).
|
||||||
ImDrawData* draw_data = &viewport->DrawDataP;
|
ImDrawData* draw_data = &viewport->DrawDataP;
|
||||||
IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount);
|
IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount);
|
||||||
for (int draw_list_n = 0; draw_list_n < draw_data->CmdLists.Size; draw_list_n++)
|
for (ImDrawList* draw_list : draw_data->CmdLists)
|
||||||
draw_data->CmdLists[draw_list_n]->_PopUnusedDrawCmd();
|
draw_list->_PopUnusedDrawCmd();
|
||||||
|
|
||||||
g.IO.MetricsRenderVertices += draw_data->TotalVtxCount;
|
g.IO.MetricsRenderVertices += draw_data->TotalVtxCount;
|
||||||
g.IO.MetricsRenderIndices += draw_data->TotalIdxCount;
|
g.IO.MetricsRenderIndices += draw_data->TotalIdxCount;
|
||||||
@ -6199,9 +6188,9 @@ ImGuiWindow* ImGui::FindBlockingModal(ImGuiWindow* window)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Find a modal that has common parent with specified window. Specified window should be positioned behind that modal.
|
// Find a modal that has common parent with specified window. Specified window should be positioned behind that modal.
|
||||||
for (int i = 0; i < g.OpenPopupStack.Size; i++)
|
for (ImGuiPopupData& popup_data : g.OpenPopupStack)
|
||||||
{
|
{
|
||||||
ImGuiWindow* popup_window = g.OpenPopupStack.Data[i].Window;
|
ImGuiWindow* popup_window = popup_data.Window;
|
||||||
if (popup_window == NULL || !(popup_window->Flags & ImGuiWindowFlags_Modal))
|
if (popup_window == NULL || !(popup_window->Flags & ImGuiWindowFlags_Modal))
|
||||||
continue;
|
continue;
|
||||||
if (!popup_window->Active && !popup_window->WasActive) // Check WasActive, because this code may run before popup renders on current frame, also check Active to handle newly created windows.
|
if (!popup_window->Active && !popup_window->WasActive) // Check WasActive, because this code may run before popup renders on current frame, also check Active to handle newly created windows.
|
||||||
@ -12967,9 +12956,9 @@ ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const ImGuiID type_hash = ImHashStr(type_name);
|
const ImGuiID type_hash = ImHashStr(type_name);
|
||||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
for (ImGuiSettingsHandler& handler : g.SettingsHandlers)
|
||||||
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
|
if (handler.TypeHash == type_hash)
|
||||||
return &g.SettingsHandlers[handler_n];
|
return &handler;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12978,9 +12967,9 @@ void ImGui::ClearIniSettings()
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
g.SettingsIniData.clear();
|
g.SettingsIniData.clear();
|
||||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
for (ImGuiSettingsHandler& handler : g.SettingsHandlers)
|
||||||
if (g.SettingsHandlers[handler_n].ClearAllFn)
|
if (handler.ClearAllFn != NULL)
|
||||||
g.SettingsHandlers[handler_n].ClearAllFn(&g, &g.SettingsHandlers[handler_n]);
|
handler.ClearAllFn(&g, &handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
||||||
@ -13015,9 +13004,9 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
|||||||
|
|
||||||
// Call pre-read handlers
|
// Call pre-read handlers
|
||||||
// Some types will clear their data (e.g. dock information) some types will allow merge/override (window)
|
// Some types will clear their data (e.g. dock information) some types will allow merge/override (window)
|
||||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
for (ImGuiSettingsHandler& handler : g.SettingsHandlers)
|
||||||
if (g.SettingsHandlers[handler_n].ReadInitFn)
|
if (handler.ReadInitFn != NULL)
|
||||||
g.SettingsHandlers[handler_n].ReadInitFn(&g, &g.SettingsHandlers[handler_n]);
|
handler.ReadInitFn(&g, &handler);
|
||||||
|
|
||||||
void* entry_data = NULL;
|
void* entry_data = NULL;
|
||||||
ImGuiSettingsHandler* entry_handler = NULL;
|
ImGuiSettingsHandler* entry_handler = NULL;
|
||||||
@ -13061,9 +13050,9 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
|||||||
memcpy(buf, ini_data, ini_size);
|
memcpy(buf, ini_data, ini_size);
|
||||||
|
|
||||||
// Call post-read handlers
|
// Call post-read handlers
|
||||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
for (ImGuiSettingsHandler& handler : g.SettingsHandlers)
|
||||||
if (g.SettingsHandlers[handler_n].ApplyAllFn)
|
if (handler.ApplyAllFn != NULL)
|
||||||
g.SettingsHandlers[handler_n].ApplyAllFn(&g, &g.SettingsHandlers[handler_n]);
|
handler.ApplyAllFn(&g, &handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::SaveIniSettingsToDisk(const char* ini_filename)
|
void ImGui::SaveIniSettingsToDisk(const char* ini_filename)
|
||||||
@ -13089,11 +13078,8 @@ const char* ImGui::SaveIniSettingsToMemory(size_t* out_size)
|
|||||||
g.SettingsDirtyTimer = 0.0f;
|
g.SettingsDirtyTimer = 0.0f;
|
||||||
g.SettingsIniData.Buf.resize(0);
|
g.SettingsIniData.Buf.resize(0);
|
||||||
g.SettingsIniData.Buf.push_back(0);
|
g.SettingsIniData.Buf.push_back(0);
|
||||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
for (ImGuiSettingsHandler& handler : g.SettingsHandlers)
|
||||||
{
|
handler.WriteAllFn(&g, &handler, &g.SettingsIniData);
|
||||||
ImGuiSettingsHandler* handler = &g.SettingsHandlers[handler_n];
|
|
||||||
handler->WriteAllFn(&g, handler, &g.SettingsIniData);
|
|
||||||
}
|
|
||||||
if (out_size)
|
if (out_size)
|
||||||
*out_size = (size_t)g.SettingsIniData.size();
|
*out_size = (size_t)g.SettingsIniData.size();
|
||||||
return g.SettingsIniData.c_str();
|
return g.SettingsIniData.c_str();
|
||||||
@ -13159,8 +13145,8 @@ void ImGui::ClearWindowSettings(const char* name)
|
|||||||
static void WindowSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
static void WindowSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
for (int i = 0; i != g.Windows.Size; i++)
|
for (ImGuiWindow* window : g.Windows)
|
||||||
g.Windows[i]->SettingsOffset = -1;
|
window->SettingsOffset = -1;
|
||||||
g.SettingsWindows.clear();
|
g.SettingsWindows.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13205,9 +13191,8 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl
|
|||||||
// Gather data from windows that were active during this session
|
// Gather data from windows that were active during this session
|
||||||
// (if a window wasn't opened in this session we preserve its settings)
|
// (if a window wasn't opened in this session we preserve its settings)
|
||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
for (int i = 0; i != g.Windows.Size; i++)
|
for (ImGuiWindow* window : g.Windows)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = g.Windows[i];
|
|
||||||
if (window->Flags & ImGuiWindowFlags_NoSavedSettings)
|
if (window->Flags & ImGuiWindowFlags_NoSavedSettings)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -13286,10 +13271,8 @@ static void ImGui::UpdateViewportsNewFrame()
|
|||||||
main_viewport->Pos = ImVec2(0.0f, 0.0f);
|
main_viewport->Pos = ImVec2(0.0f, 0.0f);
|
||||||
main_viewport->Size = g.IO.DisplaySize;
|
main_viewport->Size = g.IO.DisplaySize;
|
||||||
|
|
||||||
for (int n = 0; n < g.Viewports.Size; n++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
{
|
{
|
||||||
ImGuiViewportP* viewport = g.Viewports[n];
|
|
||||||
|
|
||||||
// Lock down space taken by menu bars and status bars, reset the offset for fucntions like BeginMainMenuBar() to alter them again.
|
// Lock down space taken by menu bars and status bars, reset the offset for fucntions like BeginMainMenuBar() to alter them again.
|
||||||
viewport->WorkOffsetMin = viewport->BuildWorkOffsetMin;
|
viewport->WorkOffsetMin = viewport->BuildWorkOffsetMin;
|
||||||
viewport->WorkOffsetMax = viewport->BuildWorkOffsetMax;
|
viewport->WorkOffsetMax = viewport->BuildWorkOffsetMax;
|
||||||
@ -13507,9 +13490,8 @@ void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP*
|
|||||||
ImVec2 off = bb.Min - viewport->Pos * scale;
|
ImVec2 off = bb.Min - viewport->Pos * scale;
|
||||||
float alpha_mul = 1.0f;
|
float alpha_mul = 1.0f;
|
||||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border, alpha_mul * 0.40f));
|
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border, alpha_mul * 0.40f));
|
||||||
for (int i = 0; i != g.Windows.Size; i++)
|
for (ImGuiWindow* thumb_window : g.Windows)
|
||||||
{
|
{
|
||||||
ImGuiWindow* thumb_window = g.Windows[i];
|
|
||||||
if (!thumb_window->WasActive || (thumb_window->Flags & ImGuiWindowFlags_ChildWindow))
|
if (!thumb_window->WasActive || (thumb_window->Flags & ImGuiWindowFlags_ChildWindow))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -13536,13 +13518,12 @@ static void RenderViewportsThumbnails()
|
|||||||
// We don't display full monitor bounds (we could, but it often looks awkward), instead we display just enough to cover all of our viewports.
|
// We don't display full monitor bounds (we could, but it often looks awkward), instead we display just enough to cover all of our viewports.
|
||||||
float SCALE = 1.0f / 8.0f;
|
float SCALE = 1.0f / 8.0f;
|
||||||
ImRect bb_full(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
|
ImRect bb_full(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||||
for (int n = 0; n < g.Viewports.Size; n++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
bb_full.Add(g.Viewports[n]->GetMainRect());
|
bb_full.Add(viewport->GetMainRect());
|
||||||
ImVec2 p = window->DC.CursorPos;
|
ImVec2 p = window->DC.CursorPos;
|
||||||
ImVec2 off = p - bb_full.Min * SCALE;
|
ImVec2 off = p - bb_full.Min * SCALE;
|
||||||
for (int n = 0; n < g.Viewports.Size; n++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
{
|
{
|
||||||
ImGuiViewportP* viewport = g.Viewports[n];
|
|
||||||
ImRect viewport_draw_bb(off + (viewport->Pos) * SCALE, off + (viewport->Pos + viewport->Size) * SCALE);
|
ImRect viewport_draw_bb(off + (viewport->Pos) * SCALE, off + (viewport->Pos + viewport->Size) * SCALE);
|
||||||
ImGui::DebugRenderViewportThumbnail(window->DrawList, viewport, viewport_draw_bb);
|
ImGui::DebugRenderViewportThumbnail(window->DrawList, viewport, viewport_draw_bb);
|
||||||
}
|
}
|
||||||
@ -13650,9 +13631,8 @@ static void MetricsHelpMarker(const char* desc)
|
|||||||
// [DEBUG] List fonts in a font atlas and display its texture
|
// [DEBUG] List fonts in a font atlas and display its texture
|
||||||
void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < atlas->Fonts.Size; i++)
|
for (ImFont* font : atlas->Fonts)
|
||||||
{
|
{
|
||||||
ImFont* font = atlas->Fonts[i];
|
|
||||||
PushID(font);
|
PushID(font);
|
||||||
DebugNodeFont(font);
|
DebugNodeFont(font);
|
||||||
PopID();
|
PopID();
|
||||||
@ -13853,9 +13833,9 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
// Here we display windows in their submitted order/hierarchy, however note that the Begin stack doesn't constitute a Parent<>Child relationship!
|
// Here we display windows in their submitted order/hierarchy, however note that the Begin stack doesn't constitute a Parent<>Child relationship!
|
||||||
ImVector<ImGuiWindow*>& temp_buffer = g.WindowsTempSortBuffer;
|
ImVector<ImGuiWindow*>& temp_buffer = g.WindowsTempSortBuffer;
|
||||||
temp_buffer.resize(0);
|
temp_buffer.resize(0);
|
||||||
for (int i = 0; i < g.Windows.Size; i++)
|
for (ImGuiWindow* window : g.Windows)
|
||||||
if (g.Windows[i]->LastFrameActive + 1 >= g.FrameCount)
|
if (window->LastFrameActive + 1 >= g.FrameCount)
|
||||||
temp_buffer.push_back(g.Windows[i]);
|
temp_buffer.push_back(window);
|
||||||
struct Func { static int IMGUI_CDECL WindowComparerByBeginOrder(const void* lhs, const void* rhs) { return ((int)(*(const ImGuiWindow* const *)lhs)->BeginOrderWithinContext - (*(const ImGuiWindow* const*)rhs)->BeginOrderWithinContext); } };
|
struct Func { static int IMGUI_CDECL WindowComparerByBeginOrder(const void* lhs, const void* rhs) { return ((int)(*(const ImGuiWindow* const *)lhs)->BeginOrderWithinContext - (*(const ImGuiWindow* const*)rhs)->BeginOrderWithinContext); } };
|
||||||
ImQsort(temp_buffer.Data, (size_t)temp_buffer.Size, sizeof(ImGuiWindow*), Func::WindowComparerByBeginOrder);
|
ImQsort(temp_buffer.Data, (size_t)temp_buffer.Size, sizeof(ImGuiWindow*), Func::WindowComparerByBeginOrder);
|
||||||
DebugNodeWindowsListByBeginStackParent(temp_buffer.Data, temp_buffer.Size, NULL);
|
DebugNodeWindowsListByBeginStackParent(temp_buffer.Data, temp_buffer.Size, NULL);
|
||||||
@ -13867,18 +13847,15 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
|
|
||||||
// DrawLists
|
// DrawLists
|
||||||
int drawlist_count = 0;
|
int drawlist_count = 0;
|
||||||
for (int viewport_i = 0; viewport_i < g.Viewports.Size; viewport_i++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
drawlist_count += g.Viewports[viewport_i]->DrawDataP.CmdLists.Size;
|
drawlist_count += viewport->DrawDataP.CmdLists.Size;
|
||||||
if (TreeNode("DrawLists", "DrawLists (%d)", drawlist_count))
|
if (TreeNode("DrawLists", "DrawLists (%d)", drawlist_count))
|
||||||
{
|
{
|
||||||
Checkbox("Show ImDrawCmd mesh when hovering", &cfg->ShowDrawCmdMesh);
|
Checkbox("Show ImDrawCmd mesh when hovering", &cfg->ShowDrawCmdMesh);
|
||||||
Checkbox("Show ImDrawCmd bounding boxes when hovering", &cfg->ShowDrawCmdBoundingBoxes);
|
Checkbox("Show ImDrawCmd bounding boxes when hovering", &cfg->ShowDrawCmdBoundingBoxes);
|
||||||
for (int viewport_i = 0; viewport_i < g.Viewports.Size; viewport_i++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
{
|
for (ImDrawList* draw_list : viewport->DrawDataP.CmdLists)
|
||||||
ImGuiViewportP* viewport = g.Viewports[viewport_i];
|
DebugNodeDrawList(NULL, viewport, draw_list, "DrawList");
|
||||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataP.CmdLists.Size; draw_list_i++)
|
|
||||||
DebugNodeDrawList(NULL, viewport, viewport->DrawDataP.CmdLists[draw_list_i], "DrawList");
|
|
||||||
}
|
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13888,22 +13865,21 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
Indent(GetTreeNodeToLabelSpacing());
|
Indent(GetTreeNodeToLabelSpacing());
|
||||||
RenderViewportsThumbnails();
|
RenderViewportsThumbnails();
|
||||||
Unindent(GetTreeNodeToLabelSpacing());
|
Unindent(GetTreeNodeToLabelSpacing());
|
||||||
for (int i = 0; i < g.Viewports.Size; i++)
|
for (ImGuiViewportP* viewport : g.Viewports)
|
||||||
DebugNodeViewport(g.Viewports[i]);
|
DebugNodeViewport(viewport);
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Details for Popups
|
// Details for Popups
|
||||||
if (TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size))
|
if (TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < g.OpenPopupStack.Size; i++)
|
for (const ImGuiPopupData& popup_data : g.OpenPopupStack)
|
||||||
{
|
{
|
||||||
// As it's difficult to interact with tree nodes while popups are open, we display everything inline.
|
// As it's difficult to interact with tree nodes while popups are open, we display everything inline.
|
||||||
const ImGuiPopupData* popup_data = &g.OpenPopupStack[i];
|
ImGuiWindow* window = popup_data.Window;
|
||||||
ImGuiWindow* window = popup_data->Window;
|
|
||||||
BulletText("PopupID: %08x, Window: '%s' (%s%s), BackupNavWindow '%s', ParentWindow '%s'",
|
BulletText("PopupID: %08x, Window: '%s' (%s%s), BackupNavWindow '%s', ParentWindow '%s'",
|
||||||
popup_data->PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? "Child;" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? "Menu;" : "",
|
popup_data.PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? "Child;" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? "Menu;" : "",
|
||||||
popup_data->BackupNavWindow ? popup_data->BackupNavWindow->Name : "NULL", window && window->ParentWindow ? window->ParentWindow->Name : "NULL");
|
popup_data.BackupNavWindow ? popup_data.BackupNavWindow->Name : "NULL", window && window->ParentWindow ? window->ParentWindow->Name : "NULL");
|
||||||
}
|
}
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
@ -13973,8 +13949,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
Text("SettingsDirtyTimer %.2f", g.SettingsDirtyTimer);
|
Text("SettingsDirtyTimer %.2f", g.SettingsDirtyTimer);
|
||||||
if (TreeNode("SettingsHandlers", "Settings handlers: (%d)", g.SettingsHandlers.Size))
|
if (TreeNode("SettingsHandlers", "Settings handlers: (%d)", g.SettingsHandlers.Size))
|
||||||
{
|
{
|
||||||
for (int n = 0; n < g.SettingsHandlers.Size; n++)
|
for (ImGuiSettingsHandler& handler : g.SettingsHandlers)
|
||||||
BulletText("\"%s\"", g.SettingsHandlers[n].TypeName);
|
BulletText("\"%s\"", handler.TypeName);
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
if (TreeNode("SettingsWindows", "Settings packed data: Windows: %d bytes", g.SettingsWindows.size()))
|
if (TreeNode("SettingsWindows", "Settings packed data: Windows: %d bytes", g.SettingsWindows.size()))
|
||||||
@ -14138,9 +14114,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
// Overlay: Display windows Rectangles and Begin Order
|
// Overlay: Display windows Rectangles and Begin Order
|
||||||
if (cfg->ShowWindowsRects || cfg->ShowWindowsBeginOrder)
|
if (cfg->ShowWindowsRects || cfg->ShowWindowsBeginOrder)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < g.Windows.Size; n++)
|
for (ImGuiWindow* window : g.Windows)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = g.Windows[n];
|
|
||||||
if (!window->WasActive)
|
if (!window->WasActive)
|
||||||
continue;
|
continue;
|
||||||
ImDrawList* draw_list = GetForegroundDrawList(window);
|
ImDrawList* draw_list = GetForegroundDrawList(window);
|
||||||
@ -14203,8 +14178,8 @@ void ImGui::DebugNodeColumns(ImGuiOldColumns* columns)
|
|||||||
if (!TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags))
|
if (!TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags))
|
||||||
return;
|
return;
|
||||||
BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->OffMaxX - columns->OffMinX, columns->OffMinX, columns->OffMaxX);
|
BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->OffMaxX - columns->OffMinX, columns->OffMinX, columns->OffMaxX);
|
||||||
for (int column_n = 0; column_n < columns->Columns.Size; column_n++)
|
for (ImGuiOldColumnData& column : columns->Columns)
|
||||||
BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", column_n, columns->Columns[column_n].OffsetNorm, GetColumnOffsetFromNorm(columns, columns->Columns[column_n].OffsetNorm));
|
BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", (int)columns->Columns.index_from_ptr(&column), column.OffsetNorm, GetColumnOffsetFromNorm(columns, column.OffsetNorm));
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14439,11 +14414,8 @@ void ImGui::DebugNodeStorage(ImGuiStorage* storage, const char* label)
|
|||||||
{
|
{
|
||||||
if (!TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes()))
|
if (!TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes()))
|
||||||
return;
|
return;
|
||||||
for (int n = 0; n < storage->Data.Size; n++)
|
for (const ImGuiStorage::ImGuiStoragePair& p : storage->Data)
|
||||||
{
|
|
||||||
const ImGuiStorage::ImGuiStoragePair& p = storage->Data[n];
|
|
||||||
BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer.
|
BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer.
|
||||||
}
|
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14501,8 +14473,8 @@ void ImGui::DebugNodeViewport(ImGuiViewportP* viewport)
|
|||||||
(flags & ImGuiViewportFlags_IsPlatformWindow) ? " IsPlatformWindow" : "",
|
(flags & ImGuiViewportFlags_IsPlatformWindow) ? " IsPlatformWindow" : "",
|
||||||
(flags & ImGuiViewportFlags_IsPlatformMonitor) ? " IsPlatformMonitor" : "",
|
(flags & ImGuiViewportFlags_IsPlatformMonitor) ? " IsPlatformMonitor" : "",
|
||||||
(flags & ImGuiViewportFlags_OwnedByApp) ? " OwnedByApp" : "");
|
(flags & ImGuiViewportFlags_OwnedByApp) ? " OwnedByApp" : "");
|
||||||
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataP.CmdLists.Size; draw_list_i++)
|
for (ImDrawList* draw_list : viewport->DrawDataP.CmdLists)
|
||||||
DebugNodeDrawList(NULL, viewport, viewport->DrawDataP.CmdLists[draw_list_i], "DrawList");
|
DebugNodeDrawList(NULL, viewport, draw_list, "DrawList");
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14557,8 +14529,8 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label)
|
|||||||
if (window->DC.ChildWindows.Size > 0) { DebugNodeWindowsList(&window->DC.ChildWindows, "ChildWindows"); }
|
if (window->DC.ChildWindows.Size > 0) { DebugNodeWindowsList(&window->DC.ChildWindows, "ChildWindows"); }
|
||||||
if (window->ColumnsStorage.Size > 0 && TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size))
|
if (window->ColumnsStorage.Size > 0 && TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size))
|
||||||
{
|
{
|
||||||
for (int n = 0; n < window->ColumnsStorage.Size; n++)
|
for (ImGuiOldColumns& columns : window->ColumnsStorage)
|
||||||
DebugNodeColumns(&window->ColumnsStorage[n]);
|
DebugNodeColumns(&columns);
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
DebugNodeStorage(&window->StateStorage, "Storage");
|
DebugNodeStorage(&window->StateStorage, "Storage");
|
||||||
|
@ -6230,9 +6230,8 @@ void ImGui::ShowFontSelector(const char* label)
|
|||||||
ImFont* font_current = ImGui::GetFont();
|
ImFont* font_current = ImGui::GetFont();
|
||||||
if (ImGui::BeginCombo(label, font_current->GetDebugName()))
|
if (ImGui::BeginCombo(label, font_current->GetDebugName()))
|
||||||
{
|
{
|
||||||
for (int n = 0; n < io.Fonts->Fonts.Size; n++)
|
for (ImFont* font : io.Fonts->Fonts)
|
||||||
{
|
{
|
||||||
ImFont* font = io.Fonts->Fonts[n];
|
|
||||||
ImGui::PushID((void*)font);
|
ImGui::PushID((void*)font);
|
||||||
if (ImGui::Selectable(font->GetDebugName(), font == font_current))
|
if (ImGui::Selectable(font->GetDebugName(), font == font_current))
|
||||||
io.FontDefault = font;
|
io.FontDefault = font;
|
||||||
@ -6840,9 +6839,8 @@ struct ExampleAppConsole
|
|||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing
|
||||||
if (copy_to_clipboard)
|
if (copy_to_clipboard)
|
||||||
ImGui::LogToClipboard();
|
ImGui::LogToClipboard();
|
||||||
for (int i = 0; i < Items.Size; i++)
|
for (const char* item : Items)
|
||||||
{
|
{
|
||||||
const char* item = Items[i];
|
|
||||||
if (!Filter.PassFilter(item))
|
if (!Filter.PassFilter(item))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -8027,12 +8025,11 @@ struct ExampleAppDocuments
|
|||||||
// Note that this completely optional, and only affect tab bars with the ImGuiTabBarFlags_Reorderable flag.
|
// Note that this completely optional, and only affect tab bars with the ImGuiTabBarFlags_Reorderable flag.
|
||||||
static void NotifyOfDocumentsClosedElsewhere(ExampleAppDocuments& app)
|
static void NotifyOfDocumentsClosedElsewhere(ExampleAppDocuments& app)
|
||||||
{
|
{
|
||||||
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
for (MyDocument& doc : app.Documents)
|
||||||
{
|
{
|
||||||
MyDocument* doc = &app.Documents[doc_n];
|
if (!doc.Open && doc.OpenPrev)
|
||||||
if (!doc->Open && doc->OpenPrev)
|
ImGui::SetTabItemClosed(doc.Name);
|
||||||
ImGui::SetTabItemClosed(doc->Name);
|
doc.OpenPrev = doc.Open;
|
||||||
doc->OpenPrev = doc->Open;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8057,23 +8054,19 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
if (ImGui::BeginMenu("File"))
|
if (ImGui::BeginMenu("File"))
|
||||||
{
|
{
|
||||||
int open_count = 0;
|
int open_count = 0;
|
||||||
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
for (MyDocument& doc : app.Documents)
|
||||||
open_count += app.Documents[doc_n].Open ? 1 : 0;
|
open_count += doc.Open ? 1 : 0;
|
||||||
|
|
||||||
if (ImGui::BeginMenu("Open", open_count < app.Documents.Size))
|
if (ImGui::BeginMenu("Open", open_count < app.Documents.Size))
|
||||||
{
|
{
|
||||||
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
for (MyDocument& doc : app.Documents)
|
||||||
{
|
if (!doc.Open && ImGui::MenuItem(doc.Name))
|
||||||
MyDocument* doc = &app.Documents[doc_n];
|
doc.DoOpen();
|
||||||
if (!doc->Open)
|
|
||||||
if (ImGui::MenuItem(doc->Name))
|
|
||||||
doc->DoOpen();
|
|
||||||
}
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0))
|
if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0))
|
||||||
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
for (MyDocument& doc : app.Documents)
|
||||||
app.Documents[doc_n].DoQueueClose();
|
doc.DoQueueClose();
|
||||||
if (ImGui::MenuItem("Exit", "Ctrl+F4") && p_open)
|
if (ImGui::MenuItem("Exit", "Ctrl+F4") && p_open)
|
||||||
*p_open = false;
|
*p_open = false;
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
@ -8084,13 +8077,13 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
// [Debug] List documents with one checkbox for each
|
// [Debug] List documents with one checkbox for each
|
||||||
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
||||||
{
|
{
|
||||||
MyDocument* doc = &app.Documents[doc_n];
|
MyDocument& doc = app.Documents[doc_n];
|
||||||
if (doc_n > 0)
|
if (doc_n > 0)
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::PushID(doc);
|
ImGui::PushID(&doc);
|
||||||
if (ImGui::Checkbox(doc->Name, &doc->Open))
|
if (ImGui::Checkbox(doc.Name, &doc.Open))
|
||||||
if (!doc->Open)
|
if (!doc.Open)
|
||||||
doc->DoForceClose();
|
doc.DoForceClose();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8119,26 +8112,25 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
//if (ImGui::GetIO().KeyCtrl) ImGui::SetTabItemSelected(docs[1].Name); // [DEBUG] Test SetTabItemSelected(), probably not very useful as-is anyway..
|
//if (ImGui::GetIO().KeyCtrl) ImGui::SetTabItemSelected(docs[1].Name); // [DEBUG] Test SetTabItemSelected(), probably not very useful as-is anyway..
|
||||||
|
|
||||||
// Submit Tabs
|
// Submit Tabs
|
||||||
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
for (MyDocument& doc : app.Documents)
|
||||||
{
|
{
|
||||||
MyDocument* doc = &app.Documents[doc_n];
|
if (!doc.Open)
|
||||||
if (!doc->Open)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ImGuiTabItemFlags tab_flags = (doc->Dirty ? ImGuiTabItemFlags_UnsavedDocument : 0);
|
ImGuiTabItemFlags tab_flags = (doc.Dirty ? ImGuiTabItemFlags_UnsavedDocument : 0);
|
||||||
bool visible = ImGui::BeginTabItem(doc->Name, &doc->Open, tab_flags);
|
bool visible = ImGui::BeginTabItem(doc.Name, &doc.Open, tab_flags);
|
||||||
|
|
||||||
// Cancel attempt to close when unsaved add to save queue so we can display a popup.
|
// Cancel attempt to close when unsaved add to save queue so we can display a popup.
|
||||||
if (!doc->Open && doc->Dirty)
|
if (!doc.Open && doc.Dirty)
|
||||||
{
|
{
|
||||||
doc->Open = true;
|
doc.Open = true;
|
||||||
doc->DoQueueClose();
|
doc.DoQueueClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
MyDocument::DisplayContextMenu(doc);
|
MyDocument::DisplayContextMenu(&doc);
|
||||||
if (visible)
|
if (visible)
|
||||||
{
|
{
|
||||||
MyDocument::DisplayContents(doc);
|
MyDocument::DisplayContents(&doc);
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8152,15 +8144,12 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
if (close_queue.empty())
|
if (close_queue.empty())
|
||||||
{
|
{
|
||||||
// Close queue is locked once we started a popup
|
// Close queue is locked once we started a popup
|
||||||
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
for (MyDocument& doc : app.Documents)
|
||||||
{
|
if (doc.WantClose)
|
||||||
MyDocument* doc = &app.Documents[doc_n];
|
|
||||||
if (doc->WantClose)
|
|
||||||
{
|
{
|
||||||
doc->WantClose = false;
|
doc.WantClose = false;
|
||||||
close_queue.push_back(doc);
|
close_queue.push_back(&doc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display closing confirmation UI
|
// Display closing confirmation UI
|
||||||
|
@ -1890,15 +1890,9 @@ void ImDrawData::DeIndexAllBuffers()
|
|||||||
// or if there is a difference between your window resolution and framebuffer resolution.
|
// or if there is a difference between your window resolution and framebuffer resolution.
|
||||||
void ImDrawData::ScaleClipRects(const ImVec2& fb_scale)
|
void ImDrawData::ScaleClipRects(const ImVec2& fb_scale)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < CmdListsCount; i++)
|
for (ImDrawList* draw_list : CmdLists)
|
||||||
{
|
for (ImDrawCmd& cmd : draw_list->CmdBuffer)
|
||||||
ImDrawList* cmd_list = CmdLists[i];
|
cmd.ClipRect = ImVec4(cmd.ClipRect.x * fb_scale.x, cmd.ClipRect.y * fb_scale.y, cmd.ClipRect.z * fb_scale.x, cmd.ClipRect.w * fb_scale.y);
|
||||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
|
||||||
{
|
|
||||||
ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i];
|
|
||||||
cmd->ClipRect = ImVec4(cmd->ClipRect.x * fb_scale.x, cmd->ClipRect.y * fb_scale.y, cmd->ClipRect.z * fb_scale.x, cmd->ClipRect.w * fb_scale.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -2039,19 +2033,19 @@ ImFontAtlas::~ImFontAtlas()
|
|||||||
void ImFontAtlas::ClearInputData()
|
void ImFontAtlas::ClearInputData()
|
||||||
{
|
{
|
||||||
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
||||||
for (int i = 0; i < ConfigData.Size; i++)
|
for (ImFontConfig& font_cfg : ConfigData)
|
||||||
if (ConfigData[i].FontData && ConfigData[i].FontDataOwnedByAtlas)
|
if (font_cfg.FontData && font_cfg.FontDataOwnedByAtlas)
|
||||||
{
|
{
|
||||||
IM_FREE(ConfigData[i].FontData);
|
IM_FREE(font_cfg.FontData);
|
||||||
ConfigData[i].FontData = NULL;
|
font_cfg.FontData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When clearing this we lose access to the font name and other information used to build the font.
|
// When clearing this we lose access to the font name and other information used to build the font.
|
||||||
for (int i = 0; i < Fonts.Size; i++)
|
for (ImFont* font : Fonts)
|
||||||
if (Fonts[i]->ConfigData >= ConfigData.Data && Fonts[i]->ConfigData < ConfigData.Data + ConfigData.Size)
|
if (font->ConfigData >= ConfigData.Data && font->ConfigData < ConfigData.Data + ConfigData.Size)
|
||||||
{
|
{
|
||||||
Fonts[i]->ConfigData = NULL;
|
font->ConfigData = NULL;
|
||||||
Fonts[i]->ConfigDataCount = 0;
|
font->ConfigDataCount = 0;
|
||||||
}
|
}
|
||||||
ConfigData.clear();
|
ConfigData.clear();
|
||||||
CustomRects.clear();
|
CustomRects.clear();
|
||||||
@ -2856,9 +2850,9 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build all fonts lookup tables
|
// Build all fonts lookup tables
|
||||||
for (int i = 0; i < atlas->Fonts.Size; i++)
|
for (ImFont* font : atlas->Fonts)
|
||||||
if (atlas->Fonts[i]->DirtyLookupTables)
|
if (font->DirtyLookupTables)
|
||||||
atlas->Fonts[i]->BuildLookupTable();
|
font->BuildLookupTable();
|
||||||
|
|
||||||
atlas->TexReady = true;
|
atlas->TexReady = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user