Skip to content

Commit c0ac4fb

Browse files
committed
Columns/Internals: (Breaking): Renamed data structures. (#125, #513, #913, #1204, #1444, #2142, #2707)
1 parent 72de6f3 commit c0ac4fb

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

imgui.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -2188,7 +2188,7 @@ static void SetCursorPosYAndSetupForPrevLine(float pos_y, float line_height)
21882188
window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, pos_y);
21892189
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.
21902190
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.
2191-
if (ImGuiColumns* columns = window->DC.CurrentColumns)
2191+
if (ImGuiOldColumns* columns = window->DC.CurrentColumns)
21922192
columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
21932193
}
21942194

@@ -2802,7 +2802,7 @@ ImGuiWindow::~ImGuiWindow()
28022802
IM_ASSERT(DrawList == &DrawListInst);
28032803
IM_DELETE(Name);
28042804
for (int i = 0; i != ColumnsStorage.Size; i++)
2805-
ColumnsStorage[i].~ImGuiColumns();
2805+
ColumnsStorage[i].~ImGuiOldColumns();
28062806
}
28072807

28082808
ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
@@ -10600,7 +10600,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
1060010600
}
1060110601

1060210602
// [DEBUG] Display contents of Columns
10603-
void ImGui::DebugNodeColumns(ImGuiColumns* columns)
10603+
void ImGui::DebugNodeColumns(ImGuiOldColumns* columns)
1060410604
{
1060510605
if (!TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags))
1060610606
return;
@@ -10858,7 +10858,7 @@ void ImGui::DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* la
1085810858
#else
1085910859

1086010860
void ImGui::ShowMetricsWindow(bool*) {}
10861-
void ImGui::DebugNodeColumns(ImGuiColumns*) {}
10861+
void ImGui::DebugNodeColumns(ImGuiOldColumns*) {}
1086210862
void ImGui::DebugNodeDrawList(ImGuiWindow*, const ImDrawList*, const char*) {}
1086310863
void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImGuiWindow*, const ImDrawList*, const ImDrawCmd*, bool, bool) {}
1086410864
void ImGui::DebugNodeStorage(ImGuiStorage*, const char*) {}

imgui_internal.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ struct ImRect; // An axis-aligned rectangle (2 points)
9292
struct ImDrawDataBuilder; // Helper to build a ImDrawData instance
9393
struct ImDrawListSharedData; // Data shared between all ImDrawList instances
9494
struct ImGuiColorMod; // Stacked color modifier, backup of modified data so we can restore it
95-
struct ImGuiColumnData; // Storage data for a single column
96-
struct ImGuiColumns; // Storage data for a columns set
9795
struct ImGuiContext; // Main Dear ImGui context
9896
struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine
9997
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
@@ -105,6 +103,8 @@ struct ImGuiNavMoveResult; // Result of a gamepad/keyboard directional
105103
struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions
106104
struct ImGuiNextWindowData; // Storage for SetNextWindow** functions
107105
struct ImGuiNextItemData; // Storage for SetNextItem** functions
106+
struct ImGuiOldColumnData; // Storage data for a single column for legacy Columns() api
107+
struct ImGuiOldColumns; // Storage data for a columns set for legacy Columns() api
108108
struct ImGuiPopupData; // Storage for current popup stack
109109
struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file
110110
struct ImGuiStackSizes; // Storage of stack sizes for debugging/asserting
@@ -1011,17 +1011,17 @@ enum ImGuiOldColumnFlags_
10111011
#endif
10121012
};
10131013

1014-
struct ImGuiColumnData
1014+
struct ImGuiOldColumnData
10151015
{
10161016
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
10171017
float OffsetNormBeforeResize;
10181018
ImGuiOldColumnFlags Flags; // Not exposed
10191019
ImRect ClipRect;
10201020

1021-
ImGuiColumnData() { memset(this, 0, sizeof(*this)); }
1021+
ImGuiOldColumnData() { memset(this, 0, sizeof(*this)); }
10221022
};
10231023

1024-
struct ImGuiColumns
1024+
struct ImGuiOldColumns
10251025
{
10261026
ImGuiID ID;
10271027
ImGuiOldColumnFlags Flags;
@@ -1036,10 +1036,10 @@ struct ImGuiColumns
10361036
ImRect HostInitialClipRect; // Backup of ClipRect at the time of BeginColumns()
10371037
ImRect HostBackupClipRect; // Backup of ClipRect during PushColumnsBackground()/PopColumnsBackground()
10381038
ImRect HostBackupParentWorkRect;//Backup of WorkRect at the time of BeginColumns()
1039-
ImVector<ImGuiColumnData> Columns;
1039+
ImVector<ImGuiOldColumnData> Columns;
10401040
ImDrawListSplitter Splitter;
10411041

1042-
ImGuiColumns() { memset(this, 0, sizeof(*this)); }
1042+
ImGuiOldColumns() { memset(this, 0, sizeof(*this)); }
10431043
};
10441044

10451045
//-----------------------------------------------------------------------------
@@ -1578,7 +1578,7 @@ struct IMGUI_API ImGuiWindowTempData
15781578
ImU32 TreeJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary.
15791579
ImVector<ImGuiWindow*> ChildWindows;
15801580
ImGuiStorage* StateStorage; // Current persistent per-window storage (store e.g. tree node open/close state)
1581-
ImGuiColumns* CurrentColumns; // Current columns set
1581+
ImGuiOldColumns* CurrentColumns; // Current columns set
15821582
ImGuiLayoutType LayoutType;
15831583
ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin()
15841584
int FocusCounterRegular; // (Legacy Focus/Tabbing system) Sequential counter, start at -1 and increase as assigned via FocusableItemRegister() (FIXME-NAV: Needs redesign)
@@ -1664,7 +1664,7 @@ struct IMGUI_API ImGuiWindow
16641664
float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there)
16651665
float ItemWidthDefault;
16661666
ImGuiStorage StateStorage;
1667-
ImVector<ImGuiColumns> ColumnsStorage;
1667+
ImVector<ImGuiOldColumns> ColumnsStorage;
16681668
float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale()
16691669
int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back)
16701670

@@ -1970,9 +1970,9 @@ namespace ImGui
19701970
IMGUI_API void PushColumnsBackground();
19711971
IMGUI_API void PopColumnsBackground();
19721972
IMGUI_API ImGuiID GetColumnsID(const char* str_id, int count);
1973-
IMGUI_API ImGuiColumns* FindOrCreateColumns(ImGuiWindow* window, ImGuiID id);
1974-
IMGUI_API float GetColumnOffsetFromNorm(const ImGuiColumns* columns, float offset_norm);
1975-
IMGUI_API float GetColumnNormFromOffset(const ImGuiColumns* columns, float offset);
1973+
IMGUI_API ImGuiOldColumns* FindOrCreateColumns(ImGuiWindow* window, ImGuiID id);
1974+
IMGUI_API float GetColumnOffsetFromNorm(const ImGuiOldColumns* columns, float offset_norm);
1975+
IMGUI_API float GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offset);
19761976

19771977
// Tab Bars
19781978
IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags);
@@ -2085,7 +2085,7 @@ namespace ImGui
20852085
inline void DebugDrawItemRect(ImU32 col = IM_COL32(255,0,0,255)) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; GetForegroundDrawList(window)->AddRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max, col); }
20862086
inline void DebugStartItemPicker() { ImGuiContext& g = *GImGui; g.DebugItemPickerActive = true; }
20872087

2088-
IMGUI_API void DebugNodeColumns(ImGuiColumns* columns);
2088+
IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns);
20892089
IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label);
20902090
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImGuiWindow* window, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
20912091
IMGUI_API void DebugNodeStorage(ImGuiStorage* storage, const char* label);

imgui_widgets.cpp

+24-24
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
13511351
if (g.GroupStack.Size > 0 && g.GroupStack.back().WindowID == window->ID)
13521352
x1 += window->DC.Indent.x;
13531353

1354-
ImGuiColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL;
1354+
ImGuiOldColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL;
13551355
if (columns)
13561356
PushColumnsBackground();
13571357

@@ -7907,19 +7907,19 @@ int ImGui::GetColumnsCount()
79077907
return window->DC.CurrentColumns ? window->DC.CurrentColumns->Count : 1;
79087908
}
79097909

7910-
float ImGui::GetColumnOffsetFromNorm(const ImGuiColumns* columns, float offset_norm)
7910+
float ImGui::GetColumnOffsetFromNorm(const ImGuiOldColumns* columns, float offset_norm)
79117911
{
79127912
return offset_norm * (columns->OffMaxX - columns->OffMinX);
79137913
}
79147914

7915-
float ImGui::GetColumnNormFromOffset(const ImGuiColumns* columns, float offset)
7915+
float ImGui::GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offset)
79167916
{
79177917
return offset / (columns->OffMaxX - columns->OffMinX);
79187918
}
79197919

79207920
static const float COLUMNS_HIT_RECT_HALF_WIDTH = 4.0f;
79217921

7922-
static float GetDraggedColumnOffset(ImGuiColumns* columns, int column_index)
7922+
static float GetDraggedColumnOffset(ImGuiOldColumns* columns, int column_index)
79237923
{
79247924
// Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing
79257925
// window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning.
@@ -7939,7 +7939,7 @@ static float GetDraggedColumnOffset(ImGuiColumns* columns, int column_index)
79397939
float ImGui::GetColumnOffset(int column_index)
79407940
{
79417941
ImGuiWindow* window = GetCurrentWindowRead();
7942-
ImGuiColumns* columns = window->DC.CurrentColumns;
7942+
ImGuiOldColumns* columns = window->DC.CurrentColumns;
79437943
if (columns == NULL)
79447944
return 0.0f;
79457945

@@ -7952,7 +7952,7 @@ float ImGui::GetColumnOffset(int column_index)
79527952
return x_offset;
79537953
}
79547954

7955-
static float GetColumnWidthEx(ImGuiColumns* columns, int column_index, bool before_resize = false)
7955+
static float GetColumnWidthEx(ImGuiOldColumns* columns, int column_index, bool before_resize = false)
79567956
{
79577957
if (column_index < 0)
79587958
column_index = columns->Current;
@@ -7969,7 +7969,7 @@ float ImGui::GetColumnWidth(int column_index)
79697969
{
79707970
ImGuiContext& g = *GImGui;
79717971
ImGuiWindow* window = g.CurrentWindow;
7972-
ImGuiColumns* columns = window->DC.CurrentColumns;
7972+
ImGuiOldColumns* columns = window->DC.CurrentColumns;
79737973
if (columns == NULL)
79747974
return GetContentRegionAvail().x;
79757975

@@ -7982,7 +7982,7 @@ void ImGui::SetColumnOffset(int column_index, float offset)
79827982
{
79837983
ImGuiContext& g = *GImGui;
79847984
ImGuiWindow* window = g.CurrentWindow;
7985-
ImGuiColumns* columns = window->DC.CurrentColumns;
7985+
ImGuiOldColumns* columns = window->DC.CurrentColumns;
79867986
IM_ASSERT(columns != NULL);
79877987

79887988
if (column_index < 0)
@@ -8003,7 +8003,7 @@ void ImGui::SetColumnOffset(int column_index, float offset)
80038003
void ImGui::SetColumnWidth(int column_index, float width)
80048004
{
80058005
ImGuiWindow* window = GetCurrentWindowRead();
8006-
ImGuiColumns* columns = window->DC.CurrentColumns;
8006+
ImGuiOldColumns* columns = window->DC.CurrentColumns;
80078007
IM_ASSERT(columns != NULL);
80088008

80098009
if (column_index < 0)
@@ -8014,19 +8014,19 @@ void ImGui::SetColumnWidth(int column_index, float width)
80148014
void ImGui::PushColumnClipRect(int column_index)
80158015
{
80168016
ImGuiWindow* window = GetCurrentWindowRead();
8017-
ImGuiColumns* columns = window->DC.CurrentColumns;
8017+
ImGuiOldColumns* columns = window->DC.CurrentColumns;
80188018
if (column_index < 0)
80198019
column_index = columns->Current;
80208020

8021-
ImGuiColumnData* column = &columns->Columns[column_index];
8021+
ImGuiOldColumnData* column = &columns->Columns[column_index];
80228022
PushClipRect(column->ClipRect.Min, column->ClipRect.Max, false);
80238023
}
80248024

80258025
// Get into the columns background draw command (which is generally the same draw command as before we called BeginColumns)
80268026
void ImGui::PushColumnsBackground()
80278027
{
80288028
ImGuiWindow* window = GetCurrentWindowRead();
8029-
ImGuiColumns* columns = window->DC.CurrentColumns;
8029+
ImGuiOldColumns* columns = window->DC.CurrentColumns;
80308030
if (columns->Count == 1)
80318031
return;
80328032

@@ -8039,7 +8039,7 @@ void ImGui::PushColumnsBackground()
80398039
void ImGui::PopColumnsBackground()
80408040
{
80418041
ImGuiWindow* window = GetCurrentWindowRead();
8042-
ImGuiColumns* columns = window->DC.CurrentColumns;
8042+
ImGuiOldColumns* columns = window->DC.CurrentColumns;
80438043
if (columns->Count == 1)
80448044
return;
80458045

@@ -8048,15 +8048,15 @@ void ImGui::PopColumnsBackground()
80488048
columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1);
80498049
}
80508050

8051-
ImGuiColumns* ImGui::FindOrCreateColumns(ImGuiWindow* window, ImGuiID id)
8051+
ImGuiOldColumns* ImGui::FindOrCreateColumns(ImGuiWindow* window, ImGuiID id)
80528052
{
80538053
// We have few columns per window so for now we don't need bother much with turning this into a faster lookup.
80548054
for (int n = 0; n < window->ColumnsStorage.Size; n++)
80558055
if (window->ColumnsStorage[n].ID == id)
80568056
return &window->ColumnsStorage[n];
80578057

8058-
window->ColumnsStorage.push_back(ImGuiColumns());
8059-
ImGuiColumns* columns = &window->ColumnsStorage.back();
8058+
window->ColumnsStorage.push_back(ImGuiOldColumns());
8059+
ImGuiOldColumns* columns = &window->ColumnsStorage.back();
80608060
columns->ID = id;
80618061
return columns;
80628062
}
@@ -8084,7 +8084,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiOldColumnFl
80848084

80858085
// Acquire storage for the columns set
80868086
ImGuiID id = GetColumnsID(str_id, columns_count);
8087-
ImGuiColumns* columns = FindOrCreateColumns(window, id);
8087+
ImGuiOldColumns* columns = FindOrCreateColumns(window, id);
80888088
IM_ASSERT(columns->ID == id);
80898089
columns->Current = 0;
80908090
columns->Count = columns_count;
@@ -8118,7 +8118,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiOldColumnFl
81188118
columns->Columns.reserve(columns_count + 1);
81198119
for (int n = 0; n < columns_count + 1; n++)
81208120
{
8121-
ImGuiColumnData column;
8121+
ImGuiOldColumnData column;
81228122
column.OffsetNorm = n / (float)columns_count;
81238123
columns->Columns.push_back(column);
81248124
}
@@ -8127,7 +8127,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiOldColumnFl
81278127
for (int n = 0; n < columns_count; n++)
81288128
{
81298129
// Compute clipping rectangle
8130-
ImGuiColumnData* column = &columns->Columns[n];
8130+
ImGuiOldColumnData* column = &columns->Columns[n];
81318131
float clip_x1 = IM_ROUND(window->Pos.x + GetColumnOffset(n));
81328132
float clip_x2 = IM_ROUND(window->Pos.x + GetColumnOffset(n + 1) - 1.0f);
81338133
column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
@@ -8158,7 +8158,7 @@ void ImGui::NextColumn()
81588158
return;
81598159

81608160
ImGuiContext& g = *GImGui;
8161-
ImGuiColumns* columns = window->DC.CurrentColumns;
8161+
ImGuiOldColumns* columns = window->DC.CurrentColumns;
81628162

81638163
if (columns->Count == 1)
81648164
{
@@ -8175,7 +8175,7 @@ void ImGui::NextColumn()
81758175

81768176
// Optimization: avoid PopClipRect() + SetCurrentChannel() + PushClipRect()
81778177
// (which would needlessly attempt to update commands in the wrong channel, then pop or overwrite them),
8178-
ImGuiColumnData* column = &columns->Columns[columns->Current];
8178+
ImGuiOldColumnData* column = &columns->Columns[columns->Current];
81798179
SetWindowClipRectBeforeSetChannel(window, column->ClipRect);
81808180
columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1);
81818181

@@ -8210,7 +8210,7 @@ void ImGui::EndColumns()
82108210
{
82118211
ImGuiContext& g = *GImGui;
82128212
ImGuiWindow* window = GetCurrentWindow();
8213-
ImGuiColumns* columns = window->DC.CurrentColumns;
8213+
ImGuiOldColumns* columns = window->DC.CurrentColumns;
82148214
IM_ASSERT(columns != NULL);
82158215

82168216
PopItemWidth();
@@ -8237,7 +8237,7 @@ void ImGui::EndColumns()
82378237
int dragging_column = -1;
82388238
for (int n = 1; n < columns->Count; n++)
82398239
{
8240-
ImGuiColumnData* column = &columns->Columns[n];
8240+
ImGuiOldColumnData* column = &columns->Columns[n];
82418241
float x = window->Pos.x + GetColumnOffset(n);
82428242
const ImGuiID column_id = columns->ID + ImGuiID(n);
82438243
const float column_hit_hw = COLUMNS_HIT_RECT_HALF_WIDTH;
@@ -8289,7 +8289,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
82898289

82908290
ImGuiOldColumnFlags flags = (border ? 0 : ImGuiOldColumnFlags_NoBorder);
82918291
//flags |= ImGuiOldColumnFlags_NoPreserveWidths; // NB: Legacy behavior
8292-
ImGuiColumns* columns = window->DC.CurrentColumns;
8292+
ImGuiOldColumns* columns = window->DC.CurrentColumns;
82938293
if (columns != NULL && columns->Count == columns_count && columns->Flags == flags)
82948294
return;
82958295

0 commit comments

Comments
 (0)