@@ -178,7 +178,7 @@ Index of this file:
178
178
// Configuration
179
179
static const int TABLE_DRAW_CHANNEL_BG0 = 0 ;
180
180
static const int TABLE_DRAW_CHANNEL_BG1_FROZEN = 1 ;
181
- static const int TABLE_DRAW_CHANNEL_UNCLIPPED = 2 ; // When using ImGuiTableFlags_NoClip
181
+ static const int TABLE_DRAW_CHANNEL_NOCLIP = 2 ; // When using ImGuiTableFlags_NoClip
182
182
static const float TABLE_BORDER_SIZE = 1 .0f ; // FIXME-TABLE: Currently hard-coded because of clipping assumptions with outer borders rendering.
183
183
static const float TABLE_RESIZE_SEPARATOR_HALF_THICKNESS = 4 .0f ; // Extend outside inner borders.
184
184
static const float TABLE_RESIZE_SEPARATOR_FEEDBACK_TIMER = 0 .06f ; // Delay/timer before making the hover feedback (color+cursor) visible because tables/columns tends to be more cramped.
@@ -226,25 +226,6 @@ inline ImGuiTableFlags TableFixFlags(ImGuiTableFlags flags, ImGuiWindow* outer_w
226
226
return flags;
227
227
}
228
228
229
- ImGuiTable::ImGuiTable ()
230
- {
231
- memset (this , 0 , sizeof (*this ));
232
- SettingsOffset = -1 ;
233
- InstanceInteracted = -1 ;
234
- LastFrameActive = -1 ;
235
- LastResizedColumn = -1 ;
236
- ContextPopupColumn = -1 ;
237
- ReorderColumn = -1 ;
238
- ResizedColumn = -1 ;
239
- AutoFitSingleStretchColumn = -1 ;
240
- HoveredColumnBody = HoveredColumnBorder = -1 ;
241
- }
242
-
243
- ImGuiTable::~ImGuiTable ()
244
- {
245
- IM_FREE (RawData);
246
- }
247
-
248
229
ImGuiTable* ImGui::TableFindByID (ImGuiID id)
249
230
{
250
231
ImGuiContext& g = *GImGui;
@@ -433,9 +414,14 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
433
414
TableResetSettings (table);
434
415
if (table->IsInitializing )
435
416
{
436
- // Initialize for new settings
417
+ // Initialize
437
418
table->SettingsOffset = -1 ;
438
419
table->IsSortSpecsDirty = true ;
420
+ table->InstanceInteracted = -1 ;
421
+ table->ContextPopupColumn = -1 ;
422
+ table->ReorderColumn = table->ResizedColumn = table->LastResizedColumn = -1 ;
423
+ table->AutoFitSingleStretchColumn = -1 ;
424
+ table->HoveredColumnBody = table->HoveredColumnBorder = -1 ;
439
425
for (int n = 0 ; n < columns_count; n++)
440
426
{
441
427
ImGuiTableColumn* column = &table->Columns [n];
@@ -473,16 +459,9 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
473
459
inner_window->SkipItems = true ;
474
460
475
461
// Clear names
476
- // FIXME-TABLE: probably could be done differently...
462
+ // At this point the ->NameOffset field of each column will be invalid until TableUpdateLayout() or the first call to TableSetupColumn()
477
463
if (table->ColumnsNames .Buf .Size > 0 )
478
- {
479
464
table->ColumnsNames .Buf .resize (0 );
480
- for (int column_n = 0 ; column_n < table->ColumnsCount ; column_n++)
481
- {
482
- ImGuiTableColumn* column = &table->Columns [column_n];
483
- column->NameOffset = -1 ;
484
- }
485
- }
486
465
487
466
// Apply queued resizing/reordering/hiding requests
488
467
TableBeginApplyRequests (table);
@@ -619,14 +598,6 @@ static void TableSetupColumnFlags(ImGuiTable* table, ImGuiTableColumn* column, I
619
598
column->Flags = flags | (column->Flags & ImGuiTableColumnFlags_StatusMask_);
620
599
}
621
600
622
- // Minimum column content width (without padding)
623
- static float TableGetMinColumnWidth ()
624
- {
625
- ImGuiContext& g = *GImGui;
626
- // return g.Style.ColumnsMinSpacing; // FIXME-TABLE
627
- return g.Style .FramePadding .x * 1 .0f ;
628
- }
629
-
630
601
// Layout columns for the frame. This is in essence the followup to BeginTable().
631
602
// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() to be called first.
632
603
// FIXME-TABLE: Our width (and therefore our WorkRect) will be minimal in the first frame for WidthAutoResize
@@ -659,6 +630,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
659
630
if (column_n >= table->DeclColumnsCount )
660
631
{
661
632
TableSetupColumnFlags (table, column, ImGuiTableColumnFlags_None);
633
+ column->NameOffset = -1 ;
662
634
column->UserID = 0 ;
663
635
column->InitStretchWeightOrWidth = -1 .0f ;
664
636
}
@@ -835,7 +807,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
835
807
if (column->Flags & ImGuiTableColumnFlags_WidthStretch)
836
808
{
837
809
// StretchWeight gets converted into WidthRequest
838
- if (!mixed_same_widths)
810
+ if (!mixed_same_widths)
839
811
{
840
812
float weight_ratio = column->StretchWeight / sum_weights_stretched;
841
813
column->WidthRequest = IM_FLOOR (ImMax (width_avail_for_stretched_columns * weight_ratio, min_column_width) + 0 .01f );
@@ -1074,7 +1046,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
1074
1046
// Initial state
1075
1047
ImGuiWindow* inner_window = table->InnerWindow ;
1076
1048
if (table->Flags & ImGuiTableFlags_NoClip)
1077
- table->DrawSplitter .SetCurrentChannel (inner_window->DrawList , TABLE_DRAW_CHANNEL_UNCLIPPED );
1049
+ table->DrawSplitter .SetCurrentChannel (inner_window->DrawList , TABLE_DRAW_CHANNEL_NOCLIP );
1078
1050
else
1079
1051
inner_window->DrawList ->PushClipRect (inner_window->ClipRect .Min , inner_window->ClipRect .Max , false );
1080
1052
}
@@ -1346,7 +1318,7 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo
1346
1318
}
1347
1319
1348
1320
// Store name (append with zero-terminator in contiguous buffer)
1349
- IM_ASSERT ( column->NameOffset == -1 ) ;
1321
+ column->NameOffset = -1 ;
1350
1322
if (label != NULL && label[0 ] != 0 )
1351
1323
{
1352
1324
column->NameOffset = (ImS16)table->ColumnsNames .size ();
@@ -1389,6 +1361,15 @@ const char* ImGui::TableGetColumnName(int column_n)
1389
1361
return TableGetColumnName (table, column_n);
1390
1362
}
1391
1363
1364
+ const char * ImGui::TableGetColumnName (const ImGuiTable* table, int column_n)
1365
+ {
1366
+ IM_ASSERT (table->IsLayoutLocked == true || column_n <= table->DeclColumnsCount ); // NameOffset is invalid otherwise
1367
+ const ImGuiTableColumn* column = &table->Columns [column_n];
1368
+ if (column->NameOffset == -1 )
1369
+ return " " ;
1370
+ return &table->ColumnsNames .Buf [column->NameOffset ];
1371
+ }
1372
+
1392
1373
// We allow querying for an extra column in order to poll the IsHovered state of the right-most section
1393
1374
ImGuiTableColumnFlags ImGui::TableGetColumnFlags (int column_n)
1394
1375
{
@@ -1403,17 +1384,6 @@ ImGuiTableColumnFlags ImGui::TableGetColumnFlags(int column_n)
1403
1384
return table->Columns [column_n].Flags ;
1404
1385
}
1405
1386
1406
- void ImGui::TableSetColumnIsEnabled (int column_n, bool hidden)
1407
- {
1408
- ImGuiContext& g = *GImGui;
1409
- ImGuiTable* table = g.CurrentTable ;
1410
- IM_ASSERT (table != NULL && table->IsLayoutLocked == false );
1411
- if (column_n < 0 )
1412
- column_n = table->CurrentColumn ;
1413
- IM_ASSERT (column_n >= 0 && column_n < table->ColumnsCount );
1414
- table->Columns [column_n].IsEnabledNextFrame = !hidden;
1415
- }
1416
-
1417
1387
// Return the cell rectangle based on currently known height.
1418
1388
// - Important: we generally don't know our row height until the end of the row, so Max.y will be incorrect in many situations.
1419
1389
// The only case where this is correct is if we provided a min_row_height to TableNextRow() and don't go below it.
@@ -1431,14 +1401,6 @@ ImRect ImGui::TableGetCellBgRect(const ImGuiTable* table, int column_n)
1431
1401
return ImRect (x1, table->RowPosY1 , x2, table->RowPosY2 );
1432
1402
}
1433
1403
1434
- const char * ImGui::TableGetColumnName (const ImGuiTable* table, int column_n)
1435
- {
1436
- const ImGuiTableColumn* column = &table->Columns [column_n];
1437
- if (column->NameOffset == -1 )
1438
- return " " ;
1439
- return &table->ColumnsNames .Buf [column->NameOffset ];
1440
- }
1441
-
1442
1404
// Return the resizing ID for the right-side of the given column.
1443
1405
ImGuiID ImGui::TableGetColumnResizeID (const ImGuiTable* table, int column_n, int instance_no)
1444
1406
{
@@ -1810,8 +1772,8 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
1810
1772
if (table->Flags & ImGuiTableFlags_NoClip)
1811
1773
{
1812
1774
// FIXME: if we end up drawing all borders/bg in EndTable, could remove this and just assert that channel hasn't changed.
1813
- table->DrawSplitter .SetCurrentChannel (window->DrawList , TABLE_DRAW_CHANNEL_UNCLIPPED );
1814
- // IM_ASSERT(table->DrawSplitter._Current == TABLE_DRAW_CHANNEL_UNCLIPPED );
1775
+ table->DrawSplitter .SetCurrentChannel (window->DrawList , TABLE_DRAW_CHANNEL_NOCLIP );
1776
+ // IM_ASSERT(table->DrawSplitter._Current == TABLE_DRAW_CHANNEL_NOCLIP );
1815
1777
}
1816
1778
else
1817
1779
{
@@ -1845,12 +1807,21 @@ void ImGui::TableEndCell(ImGuiTable* table)
1845
1807
// -------------------------------------------------------------------------
1846
1808
// [SECTION] Tables: Columns width management
1847
1809
// -------------------------------------------------------------------------
1810
+ // - TableGetMinColumnWidth() [Internal]
1848
1811
// - TableSetColumnWidth()
1849
1812
// - TableSetColumnWidthAutoSingle() [Internal]
1850
1813
// - TableSetColumnWidthAutoAll() [Internal]
1851
1814
// - TableUpdateColumnsWeightFromWidth() [Internal]
1852
1815
// -------------------------------------------------------------------------
1853
1816
1817
+ // Minimum column content width (without padding)
1818
+ float ImGui::TableGetMinColumnWidth ()
1819
+ {
1820
+ ImGuiContext& g = *GImGui;
1821
+ // return g.Style.ColumnsMinSpacing; // FIXME-TABLE
1822
+ return g.Style .FramePadding .x * 1 .0f ;
1823
+ }
1824
+
1854
1825
// 'width' = inner column width, without padding
1855
1826
void ImGui::TableSetColumnWidth (int column_n, float width)
1856
1827
{
0 commit comments