@@ -1281,7 +1281,7 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo
1281
1281
table->DeclColumnsCount ++;
1282
1282
1283
1283
// When passing a width automatically enforce WidthFixed policy
1284
- // (vs TableFixColumnFlags would default to WidthAutoResize)
1284
+ // (whereas TableSetupColumnFlags would default to WidthAutoResize)
1285
1285
if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0 )
1286
1286
if ((table->Flags & ImGuiTableFlags_ColumnsWidthFixed) && (init_width_or_weight > 0 .0f ))
1287
1287
flags |= ImGuiTableColumnFlags_WidthFixed;
@@ -1856,7 +1856,8 @@ void ImGui::TableSetColumnWidth(int column_n, float width)
1856
1856
// - All fixed: easy.
1857
1857
// - All stretch: easy.
1858
1858
// - One or more fixed + one stretch: easy.
1859
- // - One or more fixed + more than one stretch: A MESS
1859
+ // - One or more fixed + more than one stretch: tricky.
1860
+ // Qt when manual resize is enabled only support a single _trailing_ stretch column.
1860
1861
1861
1862
// When forwarding resize from Wn| to Fn+1| we need to be considerate of the _NoResize flag on Fn+1.
1862
1863
// FIXME-TABLE: Find a way to rewrite all of this so interactions feel more consistent for the user.
@@ -1877,6 +1878,11 @@ void ImGui::TableSetColumnWidth(int column_n, float width)
1877
1878
// - W1 F2 F3 resize from F2| --> ok
1878
1879
// All resizes from a Wx columns are locking other columns.
1879
1880
1881
+ // Possible improvements:
1882
+ // - W1 W2 W3 resize W1| --> to not be stuck, both W2 and W3 would stretch down. Seems possible to fix. Would be most beneficial to simplify resize of all-weighted columns.
1883
+ // - W1 F2 W3 resize W1| or F2| --> symmetrical resize is weird and glitchy. Seems possible to fix.
1884
+ // - W3 F1 F2 resize W3| --> to not be stuck past F1|, both F1 and F2 would need to stretch down, which would be lossy or ambiguous. Seems hard to fix.
1885
+
1880
1886
// Rules:
1881
1887
// - [Resize Rule 1] Can't resize from right of right-most visible column if there is any Stretch column. Implemented in TableUpdateLayout().
1882
1888
// - [Resize Rule 2] Resizing from right-side of a Stretch column before a fixed column forward sizing to left-side of fixed column.
@@ -1901,7 +1907,7 @@ void ImGui::TableSetColumnWidth(int column_n, float width)
1901
1907
}
1902
1908
else if (column_0->Flags & ImGuiTableColumnFlags_WidthStretch)
1903
1909
{
1904
- // We can also use previous column if there's no next one
1910
+ // We can also use previous column if there's no next one (this is used when doing an auto-fit on the right-most stretch column)
1905
1911
if (column_1 == NULL )
1906
1912
column_1 = (column_0->PrevEnabledColumn != -1 ) ? &table->Columns [column_0->PrevEnabledColumn ] : NULL ;
1907
1913
if (column_1 == NULL )
@@ -1916,6 +1922,7 @@ void ImGui::TableSetColumnWidth(int column_n, float width)
1916
1922
}
1917
1923
else
1918
1924
{
1925
+ // At this point column_1 is the next OR previous column and we know it is a stretch column.
1919
1926
// (old_a + old_b == new_a + new_b) --> (new_a == old_a + old_b - new_b)
1920
1927
float column_1_width = ImMax (column_1->WidthRequest - (column_0_width - column_0->WidthRequest ), min_width);
1921
1928
column_0_width = column_0->WidthRequest + column_1->WidthRequest - column_1_width;
@@ -1946,7 +1953,7 @@ void ImGui::TableSetColumnWidthAutoAll(ImGuiTable* table)
1946
1953
for (int column_n = 0 ; column_n < table->ColumnsCount ; column_n++)
1947
1954
{
1948
1955
ImGuiTableColumn* column = &table->Columns [column_n];
1949
- if (!column->IsEnabled )
1956
+ if (!column->IsEnabled && !(column-> Flags & ImGuiTableColumnFlags_WidthStretch)) // Can reset weight of hidden stretch column
1950
1957
continue ;
1951
1958
column->CannotSkipItemsQueue = (1 << 0 );
1952
1959
column->AutoFitQueue = (1 << 1 );
@@ -1977,7 +1984,8 @@ void ImGui::TableUpdateColumnsWeightFromWidth(ImGuiTable* table)
1977
1984
ImGuiTableColumn* column = &table->Columns [column_n];
1978
1985
if (!column->IsEnabled || !(column->Flags & ImGuiTableColumnFlags_WidthStretch))
1979
1986
continue ;
1980
- column->StretchWeight = ((column->WidthRequest + 0 .0f ) / visible_width) * visible_weight;
1987
+ column->StretchWeight = (column->WidthRequest / visible_width) * visible_weight;
1988
+ IM_ASSERT (column->StretchWeight > 0 .0f );
1981
1989
}
1982
1990
}
1983
1991
@@ -3276,20 +3284,24 @@ void ImGui::DebugNodeTable(ImGuiTable* table)
3276
3284
BulletText (" HoveredColumnBody: %d, HoveredColumnBorder: %d" , table->HoveredColumnBody , table->HoveredColumnBorder );
3277
3285
BulletText (" ResizedColumn: %d, ReorderColumn: %d, HeldHeaderColumn: %d" , table->ResizedColumn , table->ReorderColumn , table->HeldHeaderColumn );
3278
3286
// BulletText("BgDrawChannels: %d/%d", 0, table->BgDrawChannelUnfrozen);
3287
+ float sum_weights = 0 .0f ;
3288
+ for (int n = 0 ; n < table->ColumnsCount ; n++)
3289
+ if (table->Columns [n].Flags & ImGuiTableColumnFlags_WidthStretch)
3290
+ sum_weights += table->Columns [n].StretchWeight ;
3279
3291
for (int n = 0 ; n < table->ColumnsCount ; n++)
3280
3292
{
3281
3293
ImGuiTableColumn* column = &table->Columns [n];
3282
3294
const char * name = TableGetColumnName (table, n);
3283
3295
ImFormatString (buf, IM_ARRAYSIZE (buf),
3284
3296
" Column %d order %d name '%s': offset %+.2f to %+.2f\n "
3285
3297
" Enabled: %d, VisibleX/Y: %d/%d, RequestOutput: %d, SkipItems: %d, DrawChannels: %d,%d\n "
3286
- " WidthGiven: %.1f, Request/Auto: %.1f/%.1f, StretchWeight: %.3f\n "
3298
+ " WidthGiven: %.1f, Request/Auto: %.1f/%.1f, StretchWeight: %.3f (%.1f%%) \n "
3287
3299
" MinX: %.1f, MaxX: %.1f (%+.1f), ClipRect: %.1f to %.1f (+%.1f)\n "
3288
3300
" ContentWidth: %.1f,%.1f, HeadersUsed/Ideal %.1f/%.1f\n "
3289
3301
" Sort: %d%s, UserID: 0x%08X, Flags: 0x%04X: %s%s%s%s.." ,
3290
3302
n, column->DisplayOrder , name, column->MinX - table->WorkRect .Min .x , column->MaxX - table->WorkRect .Min .x ,
3291
3303
column->IsEnabled , column->IsVisibleX , column->IsVisibleY , column->IsRequestOutput , column->IsSkipItems , column->DrawChannelFrozen , column->DrawChannelUnfrozen ,
3292
- column->WidthGiven , column->WidthRequest , column->WidthAuto , column->StretchWeight ,
3304
+ column->WidthGiven , column->WidthRequest , column->WidthAuto , column->StretchWeight , (column-> StretchWeight / sum_weights) * 100 . 0f ,
3293
3305
column->MinX , column->MaxX , column->MaxX - column->MinX , column->ClipRect .Min .x , column->ClipRect .Max .x , column->ClipRect .Max .x - column->ClipRect .Min .x ,
3294
3306
column->ContentMaxXFrozen - column->WorkMinX , column->ContentMaxXUnfrozen - column->WorkMinX , column->ContentMaxXHeadersUsed - column->WorkMinX , column->ContentMaxXHeadersIdeal - column->WorkMinX ,
3295
3307
column->SortOrder , (column->SortDirection == ImGuiSortDirection_Ascending) ? " (Asc)" : (column->SortDirection == ImGuiSortDirection_Descending) ? " (Des)" : " " , column->UserID , column->Flags ,
0 commit comments