mirror of
https://github.com/ocornut/imgui.git
synced 2026-04-02 05:27:40 -05:00
Tables: clarify FrozenColumns order to be in order space not in visible space.
+ Removed LeftMostUnfrozenOrder + Angled Headers comments. While not strictly part of #9312, presenting a suitable reordering menu was made difficult by the old behavior.
This commit is contained in:
@@ -93,6 +93,15 @@ Other Changes:
|
|||||||
using the idiom of not applying edits before IsItemDeactivatedAfterEdit().
|
using the idiom of not applying edits before IsItemDeactivatedAfterEdit().
|
||||||
(#9308, #8915, #8273)
|
(#9308, #8915, #8273)
|
||||||
- Tables:
|
- Tables:
|
||||||
|
- Fixed and clarified the behavior of using TableSetupScrollFreeze() with columns>1,
|
||||||
|
and where some of the columns within that range were Hidable.
|
||||||
|
- Before: TableSetupScrollFreeze(N, 0) made the first N _visible_ columns
|
||||||
|
part of the scroll freeze. So if you intentionally hide columns <N
|
||||||
|
the scroll freeze area would encompass the subsequent right columns.
|
||||||
|
- After: TableSetupScrollFreeze(N, 0) makes the first N _declared_ columns
|
||||||
|
part of the scroll freeze. So if you intentionally hide columns <N
|
||||||
|
the scroll freeze area will cover less columns.
|
||||||
|
- This is generally more sane and logical.
|
||||||
- Fixed dragging a header to reorder outside of visible bounds (due to horizontal scrolling)
|
- Fixed dragging a header to reorder outside of visible bounds (due to horizontal scrolling)
|
||||||
from losing active id.
|
from losing active id.
|
||||||
- Angled Headers: angled section for column being reordered via the regular headers
|
- Angled Headers: angled section for column being reordered via the regular headers
|
||||||
|
|||||||
2
imgui.h
2
imgui.h
@@ -30,7 +30,7 @@
|
|||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||||
#define IMGUI_VERSION "1.92.7 WIP"
|
#define IMGUI_VERSION "1.92.7 WIP"
|
||||||
#define IMGUI_VERSION_NUM 19268
|
#define IMGUI_VERSION_NUM 19269
|
||||||
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
||||||
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
||||||
|
|
||||||
|
|||||||
@@ -3056,7 +3056,6 @@ struct IMGUI_API ImGuiTable
|
|||||||
ImGuiTableColumnIdx FreezeRowsCount; // Actual frozen row count (== FreezeRowsRequest, or == 0 when no scrolling offset)
|
ImGuiTableColumnIdx FreezeRowsCount; // Actual frozen row count (== FreezeRowsRequest, or == 0 when no scrolling offset)
|
||||||
ImGuiTableColumnIdx FreezeColumnsRequest; // Requested frozen columns count
|
ImGuiTableColumnIdx FreezeColumnsRequest; // Requested frozen columns count
|
||||||
ImGuiTableColumnIdx FreezeColumnsCount; // Actual frozen columns count (== FreezeColumnsRequest, or == 0 when no scrolling offset)
|
ImGuiTableColumnIdx FreezeColumnsCount; // Actual frozen columns count (== FreezeColumnsRequest, or == 0 when no scrolling offset)
|
||||||
ImGuiTableColumnIdx LeftMostUnfrozenOrder; // Display order of the left-most unfrozen column, which is used to determine where the freezing line should be.
|
|
||||||
ImGuiTableColumnIdx RowCellDataCurrent; // Index of current RowCellData[] entry in current row
|
ImGuiTableColumnIdx RowCellDataCurrent; // Index of current RowCellData[] entry in current row
|
||||||
ImGuiTableDrawChannelIdx DummyDrawChannel; // Redirect non-visible columns here.
|
ImGuiTableDrawChannelIdx DummyDrawChannel; // Redirect non-visible columns here.
|
||||||
ImGuiTableDrawChannelIdx Bg2DrawChannelCurrent; // For Selectable() and other widgets drawing across columns after the freezing line. Index within DrawSplitter.Channels[]
|
ImGuiTableDrawChannelIdx Bg2DrawChannelCurrent; // For Selectable() and other widgets drawing across columns after the freezing line. Index within DrawSplitter.Channels[]
|
||||||
|
|||||||
@@ -753,7 +753,7 @@ void ImGui::TableQueueSetColumnDisplayOrder(ImGuiTable* table, int column_n, int
|
|||||||
|
|
||||||
// Verify that we don't cross the frozen column limit.
|
// Verify that we don't cross the frozen column limit.
|
||||||
// TableSetupScrollFreeze() enforce a display order range for frozen columns. Reordering across the frozen column barrier is illegal and will be undone.
|
// TableSetupScrollFreeze() enforce a display order range for frozen columns. Reordering across the frozen column barrier is illegal and will be undone.
|
||||||
if (src_column->IsUserEnabled && (src_order < table->LeftMostUnfrozenOrder) != (dst_order < table->LeftMostUnfrozenOrder))
|
if (src_column->IsUserEnabled && (src_order < table->FreezeColumnsRequest) != (dst_order < table->FreezeColumnsRequest))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Verify that we don't reorder columns with the ImGuiTableColumnFlags_NoReorder flag, nor cross through them.
|
// Verify that we don't reorder columns with the ImGuiTableColumnFlags_NoReorder flag, nor cross through them.
|
||||||
@@ -836,7 +836,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
ImBitArrayClearAllBits(table->EnabledMaskByIndex, table->ColumnsCount);
|
ImBitArrayClearAllBits(table->EnabledMaskByIndex, table->ColumnsCount);
|
||||||
ImBitArrayClearAllBits(table->EnabledMaskByDisplayOrder, table->ColumnsCount);
|
ImBitArrayClearAllBits(table->EnabledMaskByDisplayOrder, table->ColumnsCount);
|
||||||
table->LeftMostEnabledColumn = -1;
|
table->LeftMostEnabledColumn = -1;
|
||||||
table->LeftMostUnfrozenOrder = -1;
|
|
||||||
table->MinColumnWidth = ImMax(1.0f, g.Style.FramePadding.x * 1.0f); // g.Style.ColumnsMinSpacing; // FIXME-TABLE
|
table->MinColumnWidth = ImMax(1.0f, g.Style.FramePadding.x * 1.0f); // g.Style.ColumnsMinSpacing; // FIXME-TABLE
|
||||||
|
|
||||||
// [Part 1] Apply/lock Enabled and Order states. Calculate auto/ideal width for columns. Count fixed/stretch columns.
|
// [Part 1] Apply/lock Enabled and Order states. Calculate auto/ideal width for columns. Count fixed/stretch columns.
|
||||||
@@ -900,8 +899,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
else
|
else
|
||||||
table->LeftMostEnabledColumn = (ImGuiTableColumnIdx)column_n;
|
table->LeftMostEnabledColumn = (ImGuiTableColumnIdx)column_n;
|
||||||
column->IndexWithinEnabledSet = table->ColumnsEnabledCount++;
|
column->IndexWithinEnabledSet = table->ColumnsEnabledCount++;
|
||||||
if (table->ColumnsEnabledCount == table->FreezeColumnsRequest)
|
|
||||||
table->LeftMostUnfrozenOrder = (ImGuiTableColumnIdx)(order_n + 1);
|
|
||||||
ImBitArraySetBit(table->EnabledMaskByIndex, column_n);
|
ImBitArraySetBit(table->EnabledMaskByIndex, column_n);
|
||||||
ImBitArraySetBit(table->EnabledMaskByDisplayOrder, column->DisplayOrder);
|
ImBitArraySetBit(table->EnabledMaskByDisplayOrder, column->DisplayOrder);
|
||||||
prev_visible_column_idx = column_n;
|
prev_visible_column_idx = column_n;
|
||||||
@@ -935,8 +932,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
if ((table->Flags & ImGuiTableFlags_Sortable) && table->SortSpecsCount == 0 && !(table->Flags & ImGuiTableFlags_SortTristate))
|
if ((table->Flags & ImGuiTableFlags_Sortable) && table->SortSpecsCount == 0 && !(table->Flags & ImGuiTableFlags_SortTristate))
|
||||||
table->IsSortSpecsDirty = true;
|
table->IsSortSpecsDirty = true;
|
||||||
table->RightMostEnabledColumn = (ImGuiTableColumnIdx)prev_visible_column_idx;
|
table->RightMostEnabledColumn = (ImGuiTableColumnIdx)prev_visible_column_idx;
|
||||||
if (table->LeftMostUnfrozenOrder == -1)
|
|
||||||
table->LeftMostUnfrozenOrder = table->ColumnsEnabledCount;
|
|
||||||
IM_ASSERT(table->LeftMostEnabledColumn >= 0 && table->RightMostEnabledColumn >= 0);
|
IM_ASSERT(table->LeftMostEnabledColumn >= 0 && table->RightMostEnabledColumn >= 0);
|
||||||
|
|
||||||
// [Part 2] Disable child window clipping while fitting columns. This is not strictly necessary but makes it possible to avoid
|
// [Part 2] Disable child window clipping while fitting columns. This is not strictly necessary but makes it possible to avoid
|
||||||
@@ -1077,7 +1072,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
|
|
||||||
// [Part 6] Setup final position, offset, skip/clip states and clipping rectangles, detect hovered column
|
// [Part 6] Setup final position, offset, skip/clip states and clipping rectangles, detect hovered column
|
||||||
// Process columns in their visible orders as we are comparing the visible order and adjusting host_clip_rect while looping.
|
// Process columns in their visible orders as we are comparing the visible order and adjusting host_clip_rect while looping.
|
||||||
int visible_n = 0;
|
|
||||||
bool has_at_least_one_column_requesting_output = false;
|
bool has_at_least_one_column_requesting_output = false;
|
||||||
bool offset_x_frozen = (table->FreezeColumnsCount > 0);
|
bool offset_x_frozen = (table->FreezeColumnsCount > 0);
|
||||||
float offset_x = ((table->FreezeColumnsCount > 0) ? table->OuterRect.Min.x : work_rect.Min.x) + table->OuterPaddingX - table->CellSpacingX1;
|
float offset_x = ((table->FreezeColumnsCount > 0) ? table->OuterRect.Min.x : work_rect.Min.x) + table->OuterPaddingX - table->CellSpacingX1;
|
||||||
@@ -1092,7 +1086,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
// Initial nav layer: using FreezeRowsCount, NOT FreezeRowsRequest, so Header line changes layer when frozen
|
// Initial nav layer: using FreezeRowsCount, NOT FreezeRowsRequest, so Header line changes layer when frozen
|
||||||
column->NavLayerCurrent = (ImS8)(table->FreezeRowsCount > 0 ? ImGuiNavLayer_Menu : (ImGuiNavLayer)table->NavLayer);
|
column->NavLayerCurrent = (ImS8)(table->FreezeRowsCount > 0 ? ImGuiNavLayer_Menu : (ImGuiNavLayer)table->NavLayer);
|
||||||
|
|
||||||
if (offset_x_frozen && table->FreezeColumnsCount == visible_n)
|
if (offset_x_frozen && table->FreezeColumnsCount == column_n)
|
||||||
{
|
{
|
||||||
offset_x += work_rect.Min.x - table->OuterRect.Min.x;
|
offset_x += work_rect.Min.x - table->OuterRect.Min.x;
|
||||||
offset_x_frozen = false;
|
offset_x_frozen = false;
|
||||||
@@ -1212,11 +1206,10 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
column->CannotSkipItemsQueue >>= 1;
|
column->CannotSkipItemsQueue >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visible_n < table->FreezeColumnsCount)
|
if (column_n < table->FreezeColumnsCount)
|
||||||
host_clip_rect.Min.x = ImClamp(column->MaxX + TABLE_BORDER_SIZE, host_clip_rect.Min.x, host_clip_rect.Max.x);
|
host_clip_rect.Min.x = ImClamp(column->MaxX + TABLE_BORDER_SIZE, host_clip_rect.Min.x, host_clip_rect.Max.x);
|
||||||
|
|
||||||
offset_x += column->WidthGiven + table->CellSpacingX1 + table->CellSpacingX2 + table->CellPaddingX * 2.0f;
|
offset_x += column->WidthGiven + table->CellSpacingX1 + table->CellSpacingX2 + table->CellPaddingX * 2.0f;
|
||||||
visible_n++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case the table is visible (e.g. decorations) but all columns clipped, we keep a column visible.
|
// In case the table is visible (e.g. decorations) but all columns clipped, we keep a column visible.
|
||||||
@@ -1297,7 +1290,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
|
|
||||||
// [Part 13] Setup inner window decoration size (for scrolling / nav tracking to properly take account of frozen rows/columns)
|
// [Part 13] Setup inner window decoration size (for scrolling / nav tracking to properly take account of frozen rows/columns)
|
||||||
if (table->FreezeColumnsRequest > 0)
|
if (table->FreezeColumnsRequest > 0)
|
||||||
table->InnerWindow->DecoInnerSizeX1 = table->Columns[table->DisplayOrderToIndex[table->FreezeColumnsRequest - 1]].MaxX - table->OuterRect.Min.x;
|
table->InnerWindow->DecoInnerSizeX1 = table->Columns[table->DisplayOrderToIndex[table->FreezeColumnsRequest - 1]].MaxX - table->OuterRect.Min.x; // FIXME-FROZEN
|
||||||
if (table->FreezeRowsRequest > 0)
|
if (table->FreezeRowsRequest > 0)
|
||||||
table->InnerWindow->DecoInnerSizeY1 = table_instance->LastFrozenHeight;
|
table->InnerWindow->DecoInnerSizeY1 = table_instance->LastFrozenHeight;
|
||||||
table_instance->LastFrozenHeight = 0.0f;
|
table_instance->LastFrozenHeight = 0.0f;
|
||||||
@@ -3362,13 +3355,14 @@ void ImGui::TableAngledHeadersRowEx(ImGuiID row_id, float angle, float max_label
|
|||||||
const ImVec2 header_angled_vector = unit_right * (row_height / -sin_a); // vector from bottom-left to top-left, and from bottom-right to top-right
|
const ImVec2 header_angled_vector = unit_right * (row_height / -sin_a); // vector from bottom-left to top-left, and from bottom-right to top-right
|
||||||
|
|
||||||
// Declare row, override and draw our own background
|
// Declare row, override and draw our own background
|
||||||
|
// FIXME-TABLE: Generally broken when overlapping frozen columns limit.
|
||||||
TableNextRow(ImGuiTableRowFlags_Headers, row_height);
|
TableNextRow(ImGuiTableRowFlags_Headers, row_height);
|
||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
const ImRect row_r(table->WorkRect.Min.x, table->BgClipRect.Min.y, table->WorkRect.Max.x, table->RowPosY2);
|
const ImRect row_r(table->WorkRect.Min.x, table->BgClipRect.Min.y, table->WorkRect.Max.x, table->RowPosY2);
|
||||||
table->DrawSplitter->SetCurrentChannel(draw_list, TABLE_DRAW_CHANNEL_BG0);
|
table->DrawSplitter->SetCurrentChannel(draw_list, TABLE_DRAW_CHANNEL_BG0);
|
||||||
float clip_rect_min_x = table->BgClipRect.Min.x;
|
float clip_rect_min_x = table->BgClipRect.Min.x;
|
||||||
if (table->FreezeColumnsCount > 0)
|
if (table->FreezeColumnsCount > 0)
|
||||||
clip_rect_min_x = ImMax(clip_rect_min_x, table->Columns[table->FreezeColumnsCount - 1].MaxX);
|
clip_rect_min_x = ImMax(clip_rect_min_x, table->Columns[table->DisplayOrderToIndex[table->FreezeColumnsCount - 1]].MaxX);
|
||||||
TableSetBgColor(ImGuiTableBgTarget_RowBg0, 0); // Cancel
|
TableSetBgColor(ImGuiTableBgTarget_RowBg0, 0); // Cancel
|
||||||
PushClipRect(table->BgClipRect.Min, table->BgClipRect.Max, false); // Span all columns
|
PushClipRect(table->BgClipRect.Min, table->BgClipRect.Max, false); // Span all columns
|
||||||
draw_list->AddRectFilled(ImVec2(table->BgClipRect.Min.x, row_r.Min.y), ImVec2(table->BgClipRect.Max.x, row_r.Max.y), GetColorU32(ImGuiCol_TableHeaderBg, 0.25f)); // FIXME-STYLE: Change row background with an arbitrary color.
|
draw_list->AddRectFilled(ImVec2(table->BgClipRect.Min.x, row_r.Min.y), ImVec2(table->BgClipRect.Max.x, row_r.Max.y), GetColorU32(ImGuiCol_TableHeaderBg, 0.25f)); // FIXME-STYLE: Change row background with an arbitrary color.
|
||||||
|
|||||||
Reference in New Issue
Block a user