mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-05 20:48:46 +02:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_win32.cpp # imgui.cpp # imgui_demo.cpp
This commit is contained in:
186
imgui.cpp
186
imgui.cpp
@ -382,6 +382,7 @@ CODE
|
||||
- 2020/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
|
||||
|
||||
- 2020/12/04 (1.80) - added imgui_tables.cpp file! Manually constructed project files will need the new file added!
|
||||
- 2020/11/18 (1.80) - renamed undocumented/internals ImGuiColumnsFlags_* to ImGuiOldColumnFlags_* in prevision of incoming Tables API.
|
||||
- 2020/11/03 (1.80) - renamed io.ConfigWindowsMemoryCompactTimer to io.ConfigMemoryCompactTimer as the feature will apply to other data structures
|
||||
- 2020/10/14 (1.80) - backends: moved all backends files (imgui_impl_XXXX.cpp, imgui_impl_XXXX.h) from examples/ to backends/.
|
||||
@ -973,6 +974,7 @@ ImGuiStyle::ImGuiStyle()
|
||||
FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested.
|
||||
ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines
|
||||
ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
|
||||
CellPadding = ImVec2(4,2); // Padding within a table cell
|
||||
TouchExtraPadding = ImVec2(0,0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
|
||||
IndentSpacing = 21.0f; // Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2).
|
||||
ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1).
|
||||
@ -1013,6 +1015,7 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
|
||||
FrameRounding = ImFloor(FrameRounding * scale_factor);
|
||||
ItemSpacing = ImFloor(ItemSpacing * scale_factor);
|
||||
ItemInnerSpacing = ImFloor(ItemInnerSpacing * scale_factor);
|
||||
CellPadding = ImFloor(CellPadding * scale_factor);
|
||||
TouchExtraPadding = ImFloor(TouchExtraPadding * scale_factor);
|
||||
IndentSpacing = ImFloor(IndentSpacing * scale_factor);
|
||||
ColumnsMinSpacing = ImFloor(ColumnsMinSpacing * scale_factor);
|
||||
@ -2171,6 +2174,14 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
|
||||
// the API mid-way through development and support two ways to using the clipper, needs some rework (see TODO)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// FIXME-TABLE: This prevents us from using ImGuiListClipper _inside_ a table cell.
|
||||
// The problem we have is that without a Begin/End scheme for rows using the clipper is ambiguous.
|
||||
static bool GetSkipItemForListClipping()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
return (g.CurrentTable ? g.CurrentTable->HostSkipItems : g.CurrentWindow->SkipItems);
|
||||
}
|
||||
|
||||
// Helper to calculate coarse clipping of large list of evenly sized items.
|
||||
// NB: Prefer using the ImGuiListClipper higher-level helper if you can! Read comments and instructions there on how those use this sort of pattern.
|
||||
// NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX
|
||||
@ -2185,7 +2196,7 @@ void ImGui::CalcListClipping(int items_count, float items_height, int* out_items
|
||||
*out_items_display_end = items_count;
|
||||
return;
|
||||
}
|
||||
if (window->SkipItems)
|
||||
if (GetSkipItemForListClipping())
|
||||
{
|
||||
*out_items_display_start = *out_items_display_end = 0;
|
||||
return;
|
||||
@ -2221,12 +2232,22 @@ static void SetCursorPosYAndSetupForPrevLine(float pos_y, float line_height)
|
||||
// The clipper should probably have a 4th step to display the last item in a regular manner.
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
float off_y = pos_y - window->DC.CursorPos.y;
|
||||
window->DC.CursorPos.y = pos_y;
|
||||
window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, pos_y);
|
||||
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHereY() can properly function after the end of our clipper usage.
|
||||
window->DC.PrevLineSize.y = (line_height - g.Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list.
|
||||
if (ImGuiOldColumns* columns = window->DC.CurrentColumns)
|
||||
columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
|
||||
if (ImGuiTable* table = g.CurrentTable)
|
||||
{
|
||||
if (table->IsInsideRow)
|
||||
ImGui::TableEndRow(table);
|
||||
table->RowPosY2 = window->DC.CursorPos.y;
|
||||
const int row_increase = (int)((off_y / line_height) + 0.5f);
|
||||
//table->CurrentRow += row_increase; // Can't do without fixing TableEndRow()
|
||||
table->RowBgColorCounter += row_increase;
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiListClipper::ImGuiListClipper()
|
||||
@ -2248,9 +2269,14 @@ void ImGuiListClipper::Begin(int items_count, float items_height)
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
if (ImGuiTable* table = g.CurrentTable)
|
||||
if (table->IsInsideRow)
|
||||
ImGui::TableEndRow(table);
|
||||
|
||||
StartPosY = window->DC.CursorPos.y;
|
||||
ItemsHeight = items_height;
|
||||
ItemsCount = items_count;
|
||||
ItemsFrozen = 0;
|
||||
StepNo = 0;
|
||||
DisplayStart = -1;
|
||||
DisplayEnd = 0;
|
||||
@ -2263,7 +2289,7 @@ void ImGuiListClipper::End()
|
||||
|
||||
// In theory here we should assert that ImGui::GetCursorPosY() == StartPosY + DisplayEnd * ItemsHeight, but it feels saner to just seek at the end and not assert/crash the user.
|
||||
if (ItemsCount < INT_MAX && DisplayStart >= 0)
|
||||
SetCursorPosYAndSetupForPrevLine(StartPosY + ItemsCount * ItemsHeight, ItemsHeight);
|
||||
SetCursorPosYAndSetupForPrevLine(StartPosY + (ItemsCount - ItemsFrozen) * ItemsHeight, ItemsHeight);
|
||||
ItemsCount = -1;
|
||||
StepNo = 3;
|
||||
}
|
||||
@ -2273,8 +2299,12 @@ bool ImGuiListClipper::Step()
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
ImGuiTable* table = g.CurrentTable;
|
||||
if (table && table->IsInsideRow)
|
||||
ImGui::TableEndRow(table);
|
||||
|
||||
// Reached end of list
|
||||
if (DisplayEnd >= ItemsCount || window->SkipItems)
|
||||
if (DisplayEnd >= ItemsCount || GetSkipItemForListClipping())
|
||||
{
|
||||
End();
|
||||
return false;
|
||||
@ -2283,12 +2313,22 @@ bool ImGuiListClipper::Step()
|
||||
// Step 0: Let you process the first element (regardless of it being visible or not, so we can measure the element height)
|
||||
if (StepNo == 0)
|
||||
{
|
||||
// While we are in frozen row state, keep displaying items one by one, unclipped
|
||||
// FIXME: Could be stored as a table-agnostic state.
|
||||
if (table != NULL && !table->IsUnfrozen)
|
||||
{
|
||||
DisplayStart = ItemsFrozen;
|
||||
DisplayEnd = ItemsFrozen + 1;
|
||||
ItemsFrozen++;
|
||||
return true;
|
||||
}
|
||||
|
||||
StartPosY = window->DC.CursorPos.y;
|
||||
if (ItemsHeight <= 0.0f)
|
||||
{
|
||||
// Submit the first item so we can measure its height (generally it is 0..1)
|
||||
DisplayStart = 0;
|
||||
DisplayEnd = 1;
|
||||
DisplayStart = ItemsFrozen;
|
||||
DisplayEnd = ItemsFrozen + 1;
|
||||
StepNo = 1;
|
||||
return true;
|
||||
}
|
||||
@ -2302,7 +2342,17 @@ bool ImGuiListClipper::Step()
|
||||
if (StepNo == 1)
|
||||
{
|
||||
IM_ASSERT(ItemsHeight <= 0.0f);
|
||||
ItemsHeight = window->DC.CursorPos.y - StartPosY;
|
||||
if (table)
|
||||
{
|
||||
const float pos_y1 = table->RowPosY1; // Using this instead of StartPosY to handle clipper straddling the frozen row
|
||||
const float pos_y2 = table->RowPosY2; // Using this instead of CursorPos.y to take account of tallest cell.
|
||||
ItemsHeight = pos_y2 - pos_y1;
|
||||
window->DC.CursorPos.y = pos_y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemsHeight = window->DC.CursorPos.y - StartPosY;
|
||||
}
|
||||
IM_ASSERT(ItemsHeight > 0.0f && "Unable to calculate item height! First item hasn't moved the cursor vertically!");
|
||||
StepNo = 2;
|
||||
}
|
||||
@ -2319,7 +2369,7 @@ bool ImGuiListClipper::Step()
|
||||
|
||||
// Seek cursor
|
||||
if (DisplayStart > already_submitted)
|
||||
SetCursorPosYAndSetupForPrevLine(StartPosY + DisplayStart * ItemsHeight, ItemsHeight);
|
||||
SetCursorPosYAndSetupForPrevLine(StartPosY + (DisplayStart - ItemsFrozen) * ItemsHeight, ItemsHeight);
|
||||
|
||||
StepNo = 3;
|
||||
return true;
|
||||
@ -2331,7 +2381,7 @@ bool ImGuiListClipper::Step()
|
||||
{
|
||||
// Seek cursor
|
||||
if (ItemsCount < INT_MAX)
|
||||
SetCursorPosYAndSetupForPrevLine(StartPosY + ItemsCount * ItemsHeight, ItemsHeight); // advance cursor
|
||||
SetCursorPosYAndSetupForPrevLine(StartPosY + (ItemsCount - ItemsFrozen) * ItemsHeight, ItemsHeight); // advance cursor
|
||||
ItemsCount = -1;
|
||||
return false;
|
||||
}
|
||||
@ -2441,6 +2491,7 @@ static const ImGuiStyleVarInfo GStyleVarInfo[] =
|
||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
|
||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
|
||||
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, CellPadding) }, // ImGuiStyleVar_CellPadding
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
|
||||
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
||||
@ -2550,6 +2601,11 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
|
||||
case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered";
|
||||
case ImGuiCol_PlotHistogram: return "PlotHistogram";
|
||||
case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered";
|
||||
case ImGuiCol_TableHeaderBg: return "TableHeaderBg";
|
||||
case ImGuiCol_TableBorderStrong: return "TableBorderStrong";
|
||||
case ImGuiCol_TableBorderLight: return "TableBorderLight";
|
||||
case ImGuiCol_TableRowBg: return "TableRowBg";
|
||||
case ImGuiCol_TableRowBgAlt: return "TableRowBgAlt";
|
||||
case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
|
||||
case ImGuiCol_DragDropTarget: return "DragDropTarget";
|
||||
case ImGuiCol_NavHighlight: return "NavHighlight";
|
||||
@ -2931,6 +2987,7 @@ static void SetCurrentWindow(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.CurrentWindow = window;
|
||||
g.CurrentTable = window && window->DC.CurrentTableIdx != -1 ? g.Tables.GetByIndex(window->DC.CurrentTableIdx) : NULL;
|
||||
if (window)
|
||||
g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize();
|
||||
}
|
||||
@ -2940,6 +2997,7 @@ void ImGui::GcCompactTransientMiscBuffers()
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.ItemFlagsStack.clear();
|
||||
g.GroupStack.clear();
|
||||
TableGcCompactSettings();
|
||||
}
|
||||
|
||||
// Free up/compact internal window buffers, we can use this when a window becomes unused.
|
||||
@ -4020,6 +4078,11 @@ void ImGui::NewFrame()
|
||||
if (!window->WasActive && !window->MemoryCompacted && window->LastTimeActive < memory_compact_start_time)
|
||||
GcCompactTransientWindowBuffers(window);
|
||||
}
|
||||
|
||||
// Garbage collect transient buffers of recently unused tables
|
||||
for (int i = 0; i < g.TablesLastTimeActive.Size; i++)
|
||||
if (g.TablesLastTimeActive[i] >= 0.0f && g.TablesLastTimeActive[i] < memory_compact_start_time)
|
||||
TableGcCompactTransientBuffers(g.Tables.GetByIndex(i));
|
||||
if (g.GcCompactAll)
|
||||
GcCompactTransientMiscBuffers();
|
||||
g.GcCompactAll = false;
|
||||
@ -4099,15 +4162,7 @@ void ImGui::Initialize(ImGuiContext* context)
|
||||
|
||||
#ifdef IMGUI_HAS_TABLE
|
||||
// Add .ini handle for ImGuiTable type
|
||||
{
|
||||
ImGuiSettingsHandler ini_handler;
|
||||
ini_handler.TypeName = "Table";
|
||||
ini_handler.TypeHash = ImHashStr("Table");
|
||||
ini_handler.ReadOpenFn = TableSettingsHandler_ReadOpen;
|
||||
ini_handler.ReadLineFn = TableSettingsHandler_ReadLine;
|
||||
ini_handler.WriteAllFn = TableSettingsHandler_WriteAll;
|
||||
g.SettingsHandlers.push_back(ini_handler);
|
||||
}
|
||||
TableSettingsInstallHandler(context);
|
||||
#endif // #ifdef IMGUI_HAS_TABLE
|
||||
|
||||
#ifdef IMGUI_HAS_DOCK
|
||||
@ -4191,6 +4246,10 @@ void ImGui::Shutdown(ImGuiContext* context)
|
||||
g.CurrentTabBarStack.clear();
|
||||
g.ShrinkWidthBuffer.clear();
|
||||
|
||||
g.Tables.Clear();
|
||||
g.CurrentTableStack.clear();
|
||||
g.DrawChannelsTempMergeBuffer.clear();
|
||||
|
||||
g.ClipboardHandlerData.clear();
|
||||
g.MenusIdSubmittedThisFrame.clear();
|
||||
g.InputTextState.ClearFreeMemory();
|
||||
@ -6002,6 +6061,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->ClipRect = ImVec4(-FLT_MAX, -FLT_MAX, +FLT_MAX, +FLT_MAX);
|
||||
window->IDStack.resize(1);
|
||||
window->DrawList->_ResetForNewFrame();
|
||||
window->DC.CurrentTableIdx = -1;
|
||||
|
||||
// Restore buffer capacity when woken from a compacted state, to avoid
|
||||
if (window->MemoryCompacted)
|
||||
@ -8090,7 +8150,7 @@ ImVec2 ImGui::GetContentRegionMax()
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImVec2 mx = window->ContentRegionRect.Max - window->Pos;
|
||||
if (window->DC.CurrentColumns)
|
||||
if (window->DC.CurrentColumns || g.CurrentTable)
|
||||
mx.x = window->WorkRect.Max.x - window->Pos.x;
|
||||
return mx;
|
||||
}
|
||||
@ -8101,7 +8161,7 @@ ImVec2 ImGui::GetContentRegionMaxAbs()
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImVec2 mx = window->ContentRegionRect.Max;
|
||||
if (window->DC.CurrentColumns)
|
||||
if (window->DC.CurrentColumns || g.CurrentTable)
|
||||
mx.x = window->WorkRect.Max.x;
|
||||
return mx;
|
||||
}
|
||||
@ -15642,8 +15702,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
// Debugging enums
|
||||
enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type
|
||||
const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentRegionRect" };
|
||||
enum { TRT_OuterRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersIdeal, TRT_ColumnsContentRowsFrozen, TRT_ColumnsContentRowsUnfrozen, TRT_Count }; // Tables Rect Type
|
||||
const char* trt_rects_names[TRT_Count] = { "OuterRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersIdeal", "ColumnsContentRowsFrozen", "ColumnsContentRowsUnfrozen" };
|
||||
enum { TRT_OuterRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersIdeal, TRT_ColumnsContentFrozen, TRT_ColumnsContentUnfrozen, TRT_Count }; // Tables Rect Type
|
||||
const char* trt_rects_names[TRT_Count] = { "OuterRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersIdeal", "ColumnsContentFrozen", "ColumnsContentUnfrozen" };
|
||||
if (cfg->ShowWindowsRectsType < 0)
|
||||
cfg->ShowWindowsRectsType = WRT_WorkRect;
|
||||
if (cfg->ShowTablesRectsType < 0)
|
||||
@ -15651,6 +15711,23 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
|
||||
struct Funcs
|
||||
{
|
||||
static ImRect GetTableRect(ImGuiTable* table, int rect_type, int n)
|
||||
{
|
||||
if (rect_type == TRT_OuterRect) { return table->OuterRect; }
|
||||
else if (rect_type == TRT_WorkRect) { return table->WorkRect; }
|
||||
else if (rect_type == TRT_HostClipRect) { return table->HostClipRect; }
|
||||
else if (rect_type == TRT_InnerClipRect) { return table->InnerClipRect; }
|
||||
else if (rect_type == TRT_BackgroundClipRect) { return table->BgClipRect; }
|
||||
else if (rect_type == TRT_ColumnsRect) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->MinX, table->InnerClipRect.Min.y, c->MaxX, table->InnerClipRect.Min.y + table->LastOuterHeight); }
|
||||
else if (rect_type == TRT_ColumnsClipRect) { ImGuiTableColumn* c = &table->Columns[n]; return c->ClipRect; }
|
||||
else if (rect_type == TRT_ColumnsContentHeadersUsed){ ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersUsed, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } // Note: y1/y2 not always accurate
|
||||
else if (rect_type == TRT_ColumnsContentHeadersIdeal){ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersIdeal, table->InnerClipRect.Min.y + table->LastFirstRowHeight); }
|
||||
else if (rect_type == TRT_ColumnsContentFrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXFrozen, table->InnerClipRect.Min.y + table->LastFirstRowHeight); }
|
||||
else if (rect_type == TRT_ColumnsContentUnfrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y + table->LastFirstRowHeight, c->ContentMaxXUnfrozen, table->InnerClipRect.Max.y); }
|
||||
IM_ASSERT(0);
|
||||
return ImRect();
|
||||
}
|
||||
|
||||
static ImRect GetWindowRect(ImGuiWindow* window, int rect_type)
|
||||
{
|
||||
if (rect_type == WRT_OuterRect) { return window->Rect(); }
|
||||
@ -15692,6 +15769,52 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
}
|
||||
Checkbox("Show ImDrawCmd mesh when hovering", &cfg->ShowDrawCmdMesh);
|
||||
Checkbox("Show ImDrawCmd bounding boxes when hovering", &cfg->ShowDrawCmdBoundingBoxes);
|
||||
|
||||
Checkbox("Show tables rectangles", &cfg->ShowTablesRects);
|
||||
SameLine();
|
||||
SetNextItemWidth(GetFontSize() * 12);
|
||||
cfg->ShowTablesRects |= Combo("##show_table_rects_type", &cfg->ShowTablesRectsType, trt_rects_names, TRT_Count, TRT_Count);
|
||||
if (cfg->ShowTablesRects && g.NavWindow != NULL)
|
||||
{
|
||||
for (int table_n = 0; table_n < g.Tables.GetSize(); table_n++)
|
||||
{
|
||||
ImGuiTable* table = g.Tables.GetByIndex(table_n);
|
||||
if (table->LastFrameActive < g.FrameCount - 1 || (table->OuterWindow != g.NavWindow && table->InnerWindow != g.NavWindow))
|
||||
continue;
|
||||
|
||||
BulletText("Table 0x%08X (%d columns, in '%s')", table->ID, table->ColumnsCount, table->OuterWindow->Name);
|
||||
if (IsItemHovered())
|
||||
GetForegroundDrawList()->AddRect(table->OuterRect.Min - ImVec2(1, 1), table->OuterRect.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, ~0, 2.0f);
|
||||
Indent();
|
||||
char buf[128];
|
||||
for (int rect_n = 0; rect_n < TRT_Count; rect_n++)
|
||||
{
|
||||
if (rect_n >= TRT_ColumnsRect)
|
||||
{
|
||||
if (rect_n != TRT_ColumnsRect && rect_n != TRT_ColumnsClipRect)
|
||||
continue;
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
{
|
||||
ImRect r = Funcs::GetTableRect(table, rect_n, column_n);
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) Col %d %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), column_n, trt_rects_names[rect_n]);
|
||||
Selectable(buf);
|
||||
if (IsItemHovered())
|
||||
GetForegroundDrawList()->AddRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, ~0, 2.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImRect r = Funcs::GetTableRect(table, rect_n, -1);
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), trt_rects_names[rect_n]);
|
||||
Selectable(buf);
|
||||
if (IsItemHovered())
|
||||
GetForegroundDrawList()->AddRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, ~0, 2.0f);
|
||||
}
|
||||
}
|
||||
Unindent();
|
||||
}
|
||||
}
|
||||
|
||||
TreePop();
|
||||
}
|
||||
|
||||
@ -15743,7 +15866,6 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
}
|
||||
|
||||
// Details for Tables
|
||||
IM_UNUSED(trt_rects_names);
|
||||
#ifdef IMGUI_HAS_TABLE
|
||||
if (TreeNode("Tables", "Tables (%d)", g.Tables.GetSize()))
|
||||
{
|
||||
@ -15910,11 +16032,29 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
|
||||
#ifdef IMGUI_HAS_TABLE
|
||||
// Overlay: Display Tables Rectangles
|
||||
if (show_tables_rects)
|
||||
if (cfg->ShowTablesRects)
|
||||
{
|
||||
for (int table_n = 0; table_n < g.Tables.GetSize(); table_n++)
|
||||
{
|
||||
ImGuiTable* table = g.Tables.GetByIndex(table_n);
|
||||
if (table->LastFrameActive < g.FrameCount - 1)
|
||||
continue;
|
||||
ImDrawList* draw_list = GetForegroundDrawList(table->OuterWindow);
|
||||
if (cfg->ShowTablesRectsType >= TRT_ColumnsRect)
|
||||
{
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
{
|
||||
ImRect r = Funcs::GetTableRect(table, cfg->ShowTablesRectsType, column_n);
|
||||
ImU32 col = (table->HoveredColumnBody == column_n) ? IM_COL32(255, 255, 128, 255) : IM_COL32(255, 0, 128, 255);
|
||||
float thickness = (table->HoveredColumnBody == column_n) ? 3.0f : 1.0f;
|
||||
draw_list->AddRect(r.Min, r.Max, col, 0.0f, ~0, thickness);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImRect r = Funcs::GetTableRect(table, cfg->ShowTablesRectsType, -1);
|
||||
draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // #ifdef IMGUI_HAS_TABLE
|
||||
|
Reference in New Issue
Block a user