Skip to content

Commit 1fb26d1

Browse files
committed
Tables: fixed seemingly unnecessarily copy of ImGuiTableColumnFlags_NoDirectResize_ which broken resizing from W3| in a F1 W3 F2 setup. Header only allow overlap on hover, not when active (amend f2df804)
Otherwise TableUpdateBorders() tends to override mouse cursor.
1 parent 892b48e commit 1fb26d1

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

imgui_tables.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -815,23 +815,12 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
815815
continue;
816816
ImGuiTableColumn* column = &table->Columns[column_n];
817817

818-
// Allocate width for stretched/weighted columns
819-
if (column->Flags & ImGuiTableColumnFlags_WidthStretch)
818+
// Allocate width for stretched/weighted columns (StretchWeight gets converted into WidthRequest)
819+
if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) && !mixed_same_widths)
820820
{
821-
// StretchWeight gets converted into WidthRequest
822-
if (!mixed_same_widths)
823-
{
824-
float weight_ratio = column->StretchWeight / sum_weights_stretched;
825-
column->WidthRequest = IM_FLOOR(ImMax(width_avail_for_stretched_columns * weight_ratio, min_column_width) + 0.01f);
826-
width_remaining_for_stretched_columns -= column->WidthRequest;
827-
}
828-
829-
// [Resize Rule 2] Resizing from right-side of a stretch column preceding a fixed column
830-
// needs to forward resizing to left-side of fixed column. We also need to copy the NoResize flag..
831-
if (column->NextEnabledColumn != -1)
832-
if (ImGuiTableColumn* next_column = &table->Columns[column->NextEnabledColumn])
833-
if (next_column->Flags & ImGuiTableColumnFlags_WidthFixed)
834-
column->Flags |= (next_column->Flags & ImGuiTableColumnFlags_NoDirectResize_);
821+
float weight_ratio = column->StretchWeight / sum_weights_stretched;
822+
column->WidthRequest = IM_FLOOR(ImMax(width_avail_for_stretched_columns * weight_ratio, min_column_width) + 0.01f);
823+
width_remaining_for_stretched_columns -= column->WidthRequest;
835824
}
836825

837826
// [Resize Rule 1] The right-most Visible column is not resizable if there is at least one Stretch column
@@ -1876,15 +1865,17 @@ void ImGui::TableSetColumnWidth(int column_n, float width)
18761865
// - F1 F2 F3 resize from F3| --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered.
18771866
// - F1 F2 W3 resize from F1| or F2| --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered, but it doesn't make much sense as the Stretch column will always be minimal size.
18781867
// - F1 F2 W3 resize from W3| --> ok: no-op (disabled by Resize Rule 1)
1879-
// - W1 W2 W3 resize from W1| or W2| --> FIXME
1868+
// - W1 W2 W3 resize from W1| or W2| --> ok
18801869
// - W1 W2 W3 resize from W3| --> ok: no-op (disabled by Resize Rule 1)
18811870
// - W1 F2 F3 resize from F3| --> ok: no-op (disabled by Resize Rule 1)
18821871
// - W1 F2 resize from F2| --> ok: no-op (disabled by Resize Rule 1)
18831872
// - W1 W2 F3 resize from W1| or W2| --> ok
18841873
// - W1 F2 W3 resize from W1| or F2| --> FIXME
18851874
// - F1 W2 F3 resize from W2| --> ok
1875+
// - F1 W3 F2 resize from W3| --> ok
18861876
// - W1 F2 F3 resize from W1| --> ok: equivalent to resizing |F2. F3 will not move. (forwarded by Resize Rule 2)
1887-
// - W1 F2 F3 resize from F2| --> FIXME should resize F2, F3 and not have effect on W1 (Stretch columns are _before_ the Fixed column).
1877+
// - W1 F2 F3 resize from F2| --> ok
1878+
// All resizes from a Wx columns are locking other columns.
18881879

18891880
// Rules:
18901881
// - [Resize Rule 1] Can't resize from right of right-most visible column if there is any Stretch column. Implemented in TableUpdateLayout().
@@ -2679,7 +2670,8 @@ void ImGui::TableHeader(const char* label)
26792670
// Using AllowItemOverlap mode because we cover the whole cell, and we want user to be able to submit subsequent items.
26802671
bool hovered, held;
26812672
bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_AllowItemOverlap);
2682-
SetItemAllowOverlap();
2673+
if (g.ActiveId != id)
2674+
SetItemAllowOverlap();
26832675
if (hovered || selected)
26842676
{
26852677
const ImU32 col = GetColorU32(held ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);

imgui_widgets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7664,7 +7664,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
76647664
hovered |= (g.HoveredId == id);
76657665

76667666
// Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered)
7667-
if (!held)
7667+
if (g.ActiveId != id)
76687668
SetItemAllowOverlap();
76697669

76707670
// Drag and drop: re-order tabs

0 commit comments

Comments
 (0)