Tables: Internal: Maintain InnerRect to further clarify some code. Renamed Bg1 fields to Bg2 (used by Selectable) as the other handles Bg0+Bg1.
This commit is contained in:
parent
ad83976b35
commit
30468829c2
@ -10512,8 +10512,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
// Debugging enums
|
// Debugging enums
|
||||||
enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type
|
enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type
|
||||||
const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentRegionRect" };
|
const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentRegionRect" };
|
||||||
enum { TRT_OuterRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersIdeal, TRT_ColumnsContentFrozen, TRT_ColumnsContentUnfrozen, TRT_Count }; // Tables Rect Type
|
enum { TRT_OuterRect, TRT_InnerRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersIdeal, TRT_ColumnsContentFrozen, TRT_ColumnsContentUnfrozen, TRT_Count }; // Tables Rect Type
|
||||||
const char* trt_rects_names[TRT_Count] = { "OuterRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersIdeal", "ColumnsContentFrozen", "ColumnsContentUnfrozen" };
|
const char* trt_rects_names[TRT_Count] = { "OuterRect", "InnerRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersIdeal", "ColumnsContentFrozen", "ColumnsContentUnfrozen" };
|
||||||
if (cfg->ShowWindowsRectsType < 0)
|
if (cfg->ShowWindowsRectsType < 0)
|
||||||
cfg->ShowWindowsRectsType = WRT_WorkRect;
|
cfg->ShowWindowsRectsType = WRT_WorkRect;
|
||||||
if (cfg->ShowTablesRectsType < 0)
|
if (cfg->ShowTablesRectsType < 0)
|
||||||
@ -10524,6 +10524,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
static ImRect GetTableRect(ImGuiTable* table, int rect_type, int n)
|
static ImRect GetTableRect(ImGuiTable* table, int rect_type, int n)
|
||||||
{
|
{
|
||||||
if (rect_type == TRT_OuterRect) { return table->OuterRect; }
|
if (rect_type == TRT_OuterRect) { return table->OuterRect; }
|
||||||
|
else if (rect_type == TRT_InnerRect) { return table->InnerRect; }
|
||||||
else if (rect_type == TRT_WorkRect) { return table->WorkRect; }
|
else if (rect_type == TRT_WorkRect) { return table->WorkRect; }
|
||||||
else if (rect_type == TRT_HostClipRect) { return table->HostClipRect; }
|
else if (rect_type == TRT_HostClipRect) { return table->HostClipRect; }
|
||||||
else if (rect_type == TRT_InnerClipRect) { return table->InnerClipRect; }
|
else if (rect_type == TRT_InnerClipRect) { return table->InnerClipRect; }
|
||||||
|
@ -4687,11 +4687,11 @@ static void ShowDemoWindowTables()
|
|||||||
| ImGuiTableFlags_ColumnsWidthFixed;
|
| ImGuiTableFlags_ColumnsWidthFixed;
|
||||||
|
|
||||||
enum ContentsType { CT_Text, CT_Button, CT_SmallButton, CT_FillButton, CT_Selectable, CT_SelectableSpanRow };
|
enum ContentsType { CT_Text, CT_Button, CT_SmallButton, CT_FillButton, CT_Selectable, CT_SelectableSpanRow };
|
||||||
static int contents_type = CT_Button;
|
static int contents_type = CT_SelectableSpanRow;
|
||||||
const char* contents_type_names[] = { "Text", "Button", "SmallButton", "FillButton", "Selectable", "Selectable (span row)" };
|
const char* contents_type_names[] = { "Text", "Button", "SmallButton", "FillButton", "Selectable", "Selectable (span row)" };
|
||||||
static int freeze_cols = 1;
|
static int freeze_cols = 1;
|
||||||
static int freeze_rows = 1;
|
static int freeze_rows = 1;
|
||||||
static int items_count = IM_ARRAYSIZE(template_items_names);
|
static int items_count = IM_ARRAYSIZE(template_items_names) * 2;
|
||||||
static ImVec2 outer_size_value = ImVec2(0, TEXT_BASE_HEIGHT * 12);
|
static ImVec2 outer_size_value = ImVec2(0, TEXT_BASE_HEIGHT * 12);
|
||||||
static float row_min_height = 0.0f; // Auto
|
static float row_min_height = 0.0f; // Auto
|
||||||
static float inner_width_with_scroll = 0.0f; // Auto-extend
|
static float inner_width_with_scroll = 0.0f; // Auto-extend
|
||||||
|
@ -2014,7 +2014,8 @@ struct ImGuiTable
|
|||||||
float ResizedColumnNextWidth;
|
float ResizedColumnNextWidth;
|
||||||
float ResizeLockMinContentsX2; // Lock minimum contents width while resizing down in order to not create feedback loops. But we allow growing the table.
|
float ResizeLockMinContentsX2; // Lock minimum contents width while resizing down in order to not create feedback loops. But we allow growing the table.
|
||||||
float RefScale; // Reference scale to be able to rescale columns on font/dpi changes.
|
float RefScale; // Reference scale to be able to rescale columns on font/dpi changes.
|
||||||
ImRect OuterRect; // Note: OuterRect.Max.y is often FLT_MAX until EndTable(), unless a height has been specified in BeginTable().
|
ImRect OuterRect; // Note: for non-scrolling table, OuterRect.Max.y is often FLT_MAX until EndTable(), unless a height has been specified in BeginTable().
|
||||||
|
ImRect InnerRect; // InnerRect but without decoration. As with OuterRect, for non-scrolling tables, InnerRect.Max.y is
|
||||||
ImRect WorkRect;
|
ImRect WorkRect;
|
||||||
ImRect InnerClipRect;
|
ImRect InnerClipRect;
|
||||||
ImRect BgClipRect; // We use this to cpu-clip cell background color fill
|
ImRect BgClipRect; // We use this to cpu-clip cell background color fill
|
||||||
@ -2022,7 +2023,7 @@ struct ImGuiTable
|
|||||||
ImRect HostClipRect; // This is used to check if we can eventually merge our columns draw calls into the current draw call of the current window.
|
ImRect HostClipRect; // This is used to check if we can eventually merge our columns draw calls into the current draw call of the current window.
|
||||||
ImRect HostBackupWorkRect; // Backup of InnerWindow->WorkRect at the end of BeginTable()
|
ImRect HostBackupWorkRect; // Backup of InnerWindow->WorkRect at the end of BeginTable()
|
||||||
ImRect HostBackupParentWorkRect; // Backup of InnerWindow->ParentWorkRect at the end of BeginTable()
|
ImRect HostBackupParentWorkRect; // Backup of InnerWindow->ParentWorkRect at the end of BeginTable()
|
||||||
ImRect HostBackupClipRect; // Backup of InnerWindow->ClipRect during PushTableBackground()/PopTableBackground()
|
ImRect HostBackupInnerClipRect; // Backup of InnerWindow->ClipRect during PushTableBackground()/PopTableBackground()
|
||||||
ImVec2 HostBackupPrevLineSize; // Backup of InnerWindow->DC.PrevLineSize at the end of BeginTable()
|
ImVec2 HostBackupPrevLineSize; // Backup of InnerWindow->DC.PrevLineSize at the end of BeginTable()
|
||||||
ImVec2 HostBackupCurrLineSize; // Backup of InnerWindow->DC.CurrLineSize at the end of BeginTable()
|
ImVec2 HostBackupCurrLineSize; // Backup of InnerWindow->DC.CurrLineSize at the end of BeginTable()
|
||||||
ImVec2 HostBackupCursorMaxPos; // Backup of InnerWindow->DC.CursorMaxPos at the end of BeginTable()
|
ImVec2 HostBackupCursorMaxPos; // Backup of InnerWindow->DC.CursorMaxPos at the end of BeginTable()
|
||||||
@ -2058,8 +2059,8 @@ struct ImGuiTable
|
|||||||
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 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 Bg1DrawChannelCurrent; // For Selectable() and other widgets drawing accross columns after the freezing line. Index within DrawSplitter.Channels[]
|
ImGuiTableDrawChannelIdx Bg2DrawChannelCurrent; // For Selectable() and other widgets drawing accross columns after the freezing line. Index within DrawSplitter.Channels[]
|
||||||
ImGuiTableDrawChannelIdx Bg1DrawChannelUnfrozen;
|
ImGuiTableDrawChannelIdx Bg2DrawChannelUnfrozen;
|
||||||
bool IsLayoutLocked; // Set by TableUpdateLayout() which is called when beginning the first row.
|
bool IsLayoutLocked; // Set by TableUpdateLayout() which is called when beginning the first row.
|
||||||
bool IsInsideRow; // Set when inside TableBeginRow()/TableEndRow().
|
bool IsInsideRow; // Set when inside TableBeginRow()/TableEndRow().
|
||||||
bool IsInitializing;
|
bool IsInitializing;
|
||||||
|
@ -177,8 +177,8 @@ Index of this file:
|
|||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
static const int TABLE_DRAW_CHANNEL_BG0 = 0;
|
static const int TABLE_DRAW_CHANNEL_BG0 = 0;
|
||||||
static const int TABLE_DRAW_CHANNEL_BG1_FROZEN = 1;
|
static const int TABLE_DRAW_CHANNEL_BG2_FROZEN = 1;
|
||||||
static const int TABLE_DRAW_CHANNEL_NOCLIP = 2; // When using ImGuiTableFlags_NoClip
|
static const int TABLE_DRAW_CHANNEL_NOCLIP = 2; // When using ImGuiTableFlags_NoClip (this becomes the last visible channel)
|
||||||
static const float TABLE_BORDER_SIZE = 1.0f; // FIXME-TABLE: Currently hard-coded because of clipping assumptions with outer borders rendering.
|
static const float TABLE_BORDER_SIZE = 1.0f; // FIXME-TABLE: Currently hard-coded because of clipping assumptions with outer borders rendering.
|
||||||
static const float TABLE_RESIZE_SEPARATOR_HALF_THICKNESS = 4.0f; // Extend outside inner borders.
|
static const float TABLE_RESIZE_SEPARATOR_HALF_THICKNESS = 4.0f; // Extend outside inner borders.
|
||||||
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.
|
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.
|
||||||
@ -278,8 +278,6 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
table->ColumnsCount = columns_count;
|
table->ColumnsCount = columns_count;
|
||||||
table->IsLayoutLocked = false;
|
table->IsLayoutLocked = false;
|
||||||
table->InnerWidth = inner_width;
|
table->InnerWidth = inner_width;
|
||||||
table->OuterRect = outer_rect;
|
|
||||||
table->WorkRect = outer_rect;
|
|
||||||
table->IsOuterRectFitX = (outer_size.x >= -1.0f && outer_size.x <= 0.0f); // Bit ambiguous
|
table->IsOuterRectFitX = (outer_size.x >= -1.0f && outer_size.x <= 0.0f); // Bit ambiguous
|
||||||
|
|
||||||
// When not using a child window, WorkRect.Max will grow as we append contents.
|
// When not using a child window, WorkRect.Max will grow as we append contents.
|
||||||
@ -303,12 +301,19 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
|
|
||||||
// Create scrolling region (without border and zero window padding)
|
// Create scrolling region (without border and zero window padding)
|
||||||
ImGuiWindowFlags child_flags = (flags & ImGuiTableFlags_ScrollX) ? ImGuiWindowFlags_HorizontalScrollbar : ImGuiWindowFlags_None;
|
ImGuiWindowFlags child_flags = (flags & ImGuiTableFlags_ScrollX) ? ImGuiWindowFlags_HorizontalScrollbar : ImGuiWindowFlags_None;
|
||||||
BeginChildEx(name, instance_id, table->OuterRect.GetSize(), false, child_flags);
|
BeginChildEx(name, instance_id, outer_rect.GetSize(), false, child_flags);
|
||||||
table->InnerWindow = g.CurrentWindow;
|
table->InnerWindow = g.CurrentWindow;
|
||||||
table->WorkRect = table->InnerWindow->WorkRect;
|
table->WorkRect = table->InnerWindow->WorkRect;
|
||||||
table->OuterRect = table->InnerWindow->Rect();
|
table->OuterRect = table->InnerWindow->Rect();
|
||||||
|
table->InnerRect = table->InnerWindow->InnerRect;
|
||||||
IM_ASSERT(table->InnerWindow->WindowPadding.x == 0.0f && table->InnerWindow->WindowPadding.y == 0.0f && table->InnerWindow->WindowBorderSize == 0.0f);
|
IM_ASSERT(table->InnerWindow->WindowPadding.x == 0.0f && table->InnerWindow->WindowPadding.y == 0.0f && table->InnerWindow->WindowBorderSize == 0.0f);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// For non-scrolling tables, WorkRect == OuterRect == InnerRect.
|
||||||
|
// But at this point we do NOT have a correct value for .Max.y (unless a height has been explicitly passed in). It will only be updated in EndTable().
|
||||||
|
table->WorkRect = table->OuterRect = table->InnerRect = outer_rect;
|
||||||
|
}
|
||||||
|
|
||||||
// Push a standardized ID for both child-using and not-child-using tables
|
// Push a standardized ID for both child-using and not-child-using tables
|
||||||
PushOverrideID(instance_id);
|
PushOverrideID(instance_id);
|
||||||
@ -1148,12 +1153,13 @@ void ImGui::EndTable()
|
|||||||
inner_window->DC.CursorMaxPos = table->HostBackupCursorMaxPos;
|
inner_window->DC.CursorMaxPos = table->HostBackupCursorMaxPos;
|
||||||
if (inner_window != outer_window)
|
if (inner_window != outer_window)
|
||||||
{
|
{
|
||||||
table->OuterRect.Max.y = ImMax(table->OuterRect.Max.y, inner_window->Pos.y + inner_window->Size.y);
|
// Both OuterRect/InnerRect are valid from BeginTable
|
||||||
inner_window->DC.CursorMaxPos.y = table->RowPosY2;
|
inner_window->DC.CursorMaxPos.y = table->RowPosY2;
|
||||||
}
|
}
|
||||||
else if (!(flags & ImGuiTableFlags_NoHostExtendY))
|
else if (!(flags & ImGuiTableFlags_NoHostExtendY))
|
||||||
{
|
{
|
||||||
table->OuterRect.Max.y = ImMax(table->OuterRect.Max.y, inner_window->DC.CursorPos.y);
|
// Patch OuterRect/InnerRect height
|
||||||
|
table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_window->DC.CursorPos.y);
|
||||||
inner_window->DC.CursorMaxPos.y = table->RowPosY2;
|
inner_window->DC.CursorMaxPos.y = table->RowPosY2;
|
||||||
}
|
}
|
||||||
table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y);
|
table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y);
|
||||||
@ -1166,7 +1172,6 @@ void ImGui::EndTable()
|
|||||||
// Draw borders
|
// Draw borders
|
||||||
if ((flags & ImGuiTableFlags_Borders) != 0)
|
if ((flags & ImGuiTableFlags_Borders) != 0)
|
||||||
TableDrawBorders(table);
|
TableDrawBorders(table);
|
||||||
table->DrawSplitter.SetCurrentChannel(inner_window->DrawList, 0);
|
|
||||||
|
|
||||||
// Store content width reference for each column (before attempting to merge draw calls)
|
// Store content width reference for each column (before attempting to merge draw calls)
|
||||||
const float backup_outer_cursor_pos_x = outer_window->DC.CursorPos.x;
|
const float backup_outer_cursor_pos_x = outer_window->DC.CursorPos.x;
|
||||||
@ -1192,6 +1197,7 @@ void ImGui::EndTable()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Flatten channels and merge draw calls
|
// Flatten channels and merge draw calls
|
||||||
|
table->DrawSplitter.SetCurrentChannel(inner_window->DrawList, 0);
|
||||||
if ((table->Flags & ImGuiTableFlags_NoClip) == 0)
|
if ((table->Flags & ImGuiTableFlags_NoClip) == 0)
|
||||||
TableMergeDrawChannels(table);
|
TableMergeDrawChannels(table);
|
||||||
table->DrawSplitter.Merge(inner_window->DrawList);
|
table->DrawSplitter.Merge(inner_window->DrawList);
|
||||||
@ -1563,7 +1569,6 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
|||||||
// Row background fill
|
// Row background fill
|
||||||
const float bg_y1 = table->RowPosY1;
|
const float bg_y1 = table->RowPosY1;
|
||||||
const float bg_y2 = table->RowPosY2;
|
const float bg_y2 = table->RowPosY2;
|
||||||
|
|
||||||
const bool unfreeze_rows_actual = (table->CurrentRow + 1 == table->FreezeRowsCount);
|
const bool unfreeze_rows_actual = (table->CurrentRow + 1 == table->FreezeRowsCount);
|
||||||
const bool unfreeze_rows_request = (table->CurrentRow + 1 == table->FreezeRowsRequest);
|
const bool unfreeze_rows_request = (table->CurrentRow + 1 == table->FreezeRowsRequest);
|
||||||
if (table->CurrentRow == 0)
|
if (table->CurrentRow == 0)
|
||||||
@ -1654,7 +1659,7 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
|||||||
float y0 = ImMax(table->RowPosY2 + 1, window->InnerClipRect.Min.y);
|
float y0 = ImMax(table->RowPosY2 + 1, window->InnerClipRect.Min.y);
|
||||||
table->BgClipRect.Min.y = table->BgClipRectForDrawCmd.Min.y = ImMin(y0, window->InnerClipRect.Max.y);
|
table->BgClipRect.Min.y = table->BgClipRectForDrawCmd.Min.y = ImMin(y0, window->InnerClipRect.Max.y);
|
||||||
table->BgClipRect.Max.y = table->BgClipRectForDrawCmd.Max.y = window->InnerClipRect.Max.y;
|
table->BgClipRect.Max.y = table->BgClipRectForDrawCmd.Max.y = window->InnerClipRect.Max.y;
|
||||||
table->Bg1DrawChannelCurrent = table->Bg1DrawChannelUnfrozen;
|
table->Bg2DrawChannelCurrent = table->Bg2DrawChannelUnfrozen;
|
||||||
IM_ASSERT(table->BgClipRectForDrawCmd.Min.y <= table->BgClipRectForDrawCmd.Max.y);
|
IM_ASSERT(table->BgClipRectForDrawCmd.Min.y <= table->BgClipRectForDrawCmd.Max.y);
|
||||||
|
|
||||||
float row_height = table->RowPosY2 - table->RowPosY1;
|
float row_height = table->RowPosY2 - table->RowPosY1;
|
||||||
@ -2004,6 +2009,8 @@ void ImGui::TableUpdateColumnsWeightFromWidth(ImGuiTable* table)
|
|||||||
// - TableDrawBorders() [Internal]
|
// - TableDrawBorders() [Internal]
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Bg2 is used by Selectable (and possibly other widgets) to render to the background.
|
||||||
|
// Unlike our Bg0/1 channel which we uses for RowBg/CellBg/Borders and where we guarantee all shapes to be CPU-clipped, the Bg2 channel being widgets-facing will rely on regular ClipRect.
|
||||||
void ImGui::TablePushBackgroundChannel()
|
void ImGui::TablePushBackgroundChannel()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -2011,9 +2018,9 @@ void ImGui::TablePushBackgroundChannel()
|
|||||||
ImGuiTable* table = g.CurrentTable;
|
ImGuiTable* table = g.CurrentTable;
|
||||||
|
|
||||||
// Optimization: avoid SetCurrentChannel() + PushClipRect()
|
// Optimization: avoid SetCurrentChannel() + PushClipRect()
|
||||||
table->HostBackupClipRect = window->ClipRect;
|
table->HostBackupInnerClipRect = window->ClipRect;
|
||||||
SetWindowClipRectBeforeSetChannel(window, table->BgClipRectForDrawCmd);
|
SetWindowClipRectBeforeSetChannel(window, table->BgClipRectForDrawCmd);
|
||||||
table->DrawSplitter.SetCurrentChannel(window->DrawList, table->Bg1DrawChannelCurrent);
|
table->DrawSplitter.SetCurrentChannel(window->DrawList, table->Bg2DrawChannelCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::TablePopBackgroundChannel()
|
void ImGui::TablePopBackgroundChannel()
|
||||||
@ -2024,7 +2031,7 @@ void ImGui::TablePopBackgroundChannel()
|
|||||||
ImGuiTableColumn* column = &table->Columns[table->CurrentColumn];
|
ImGuiTableColumn* column = &table->Columns[table->CurrentColumn];
|
||||||
|
|
||||||
// Optimization: avoid PopClipRect() + SetCurrentChannel()
|
// Optimization: avoid PopClipRect() + SetCurrentChannel()
|
||||||
SetWindowClipRectBeforeSetChannel(window, table->HostBackupClipRect);
|
SetWindowClipRectBeforeSetChannel(window, table->HostBackupInnerClipRect);
|
||||||
table->DrawSplitter.SetCurrentChannel(window->DrawList, column->DrawChannelCurrent);
|
table->DrawSplitter.SetCurrentChannel(window->DrawList, column->DrawChannelCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2036,10 +2043,10 @@ void ImGui::TablePopBackgroundChannel()
|
|||||||
// - After crossing FreezeRowsCount, all columns see their current draw channel changed to a second set of channels.
|
// - After crossing FreezeRowsCount, all columns see their current draw channel changed to a second set of channels.
|
||||||
// - We only use the dummy draw channel so we can push a null clipping rectangle into it without affecting other
|
// - We only use the dummy draw channel so we can push a null clipping rectangle into it without affecting other
|
||||||
// channels, while simplifying per-row/per-cell overhead. It will be empty and discarded when merged.
|
// channels, while simplifying per-row/per-cell overhead. It will be empty and discarded when merged.
|
||||||
// - We allocate 1 or 2 background draw channels. This is because we know PushTableBackground() is only used for
|
// - We allocate 1 or 2 background draw channels. This is because we know TablePushBackgroundChannel() is only used for
|
||||||
// horizontal spanning. If we allowed vertical spanning we'd need one background draw channel per merge group (1-4).
|
// horizontal spanning. If we allowed vertical spanning we'd need one background draw channel per merge group (1-4).
|
||||||
// Draw channel allocation (before merging):
|
// Draw channel allocation (before merging):
|
||||||
// - NoClip --> 2+D+1 channels: bg0 + bg1 + foreground (same clip rect == 1 draw call) (FIXME-TABLE: could merge bg1 and foreground?)
|
// - NoClip --> 2+D+1 channels: bg0/1 + bg2 + foreground (same clip rect == 1 draw call) (FIXME-TABLE: could merge bg2 and foreground?)
|
||||||
// - Clip --> 2+D+N channels
|
// - Clip --> 2+D+N channels
|
||||||
// - FreezeRows --> 2+D+N*2 (unless scrolling value is zero)
|
// - FreezeRows --> 2+D+N*2 (unless scrolling value is zero)
|
||||||
// - FreezeRows || FreezeColunns --> 3+D+N*2 (unless scrolling value is zero)
|
// - FreezeRows || FreezeColunns --> 3+D+N*2 (unless scrolling value is zero)
|
||||||
@ -2053,8 +2060,8 @@ void ImGui::TableSetupDrawChannels(ImGuiTable* table)
|
|||||||
const int channels_total = channels_for_bg + (channels_for_row * freeze_row_multiplier) + channels_for_dummy;
|
const int channels_total = channels_for_bg + (channels_for_row * freeze_row_multiplier) + channels_for_dummy;
|
||||||
table->DrawSplitter.Split(table->InnerWindow->DrawList, channels_total);
|
table->DrawSplitter.Split(table->InnerWindow->DrawList, channels_total);
|
||||||
table->DummyDrawChannel = (ImGuiTableDrawChannelIdx)((channels_for_dummy > 0) ? channels_total - 1 : -1);
|
table->DummyDrawChannel = (ImGuiTableDrawChannelIdx)((channels_for_dummy > 0) ? channels_total - 1 : -1);
|
||||||
table->Bg1DrawChannelCurrent = TABLE_DRAW_CHANNEL_BG1_FROZEN;
|
table->Bg2DrawChannelCurrent = TABLE_DRAW_CHANNEL_BG2_FROZEN;
|
||||||
table->Bg1DrawChannelUnfrozen = (ImGuiTableDrawChannelIdx)((table->FreezeRowsCount > 0) ? 2 + channels_for_row : TABLE_DRAW_CHANNEL_BG1_FROZEN);
|
table->Bg2DrawChannelUnfrozen = (ImGuiTableDrawChannelIdx)((table->FreezeRowsCount > 0) ? 2 + channels_for_row : TABLE_DRAW_CHANNEL_BG2_FROZEN);
|
||||||
|
|
||||||
int draw_channel_current = 2;
|
int draw_channel_current = 2;
|
||||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||||
@ -2117,6 +2124,7 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
|
|||||||
ImDrawListSplitter* splitter = &table->DrawSplitter;
|
ImDrawListSplitter* splitter = &table->DrawSplitter;
|
||||||
const bool has_freeze_v = (table->FreezeRowsCount > 0);
|
const bool has_freeze_v = (table->FreezeRowsCount > 0);
|
||||||
const bool has_freeze_h = (table->FreezeColumnsCount > 0);
|
const bool has_freeze_h = (table->FreezeColumnsCount > 0);
|
||||||
|
IM_ASSERT(splitter->_Current == 0);
|
||||||
|
|
||||||
// Track which groups we are going to attempt to merge, and which channels goes into each group.
|
// Track which groups we are going to attempt to merge, and which channels goes into each group.
|
||||||
struct MergeGroup
|
struct MergeGroup
|
||||||
@ -2200,15 +2208,15 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
|
|||||||
// 2. Rewrite channel list in our preferred order
|
// 2. Rewrite channel list in our preferred order
|
||||||
if (merge_group_mask != 0)
|
if (merge_group_mask != 0)
|
||||||
{
|
{
|
||||||
// We skip channel 0 (Bg0) and 1 (Bg1 frozen) from the shuffling since they won't move - see channels allocation in TableSetupDrawChannels().
|
// We skip channel 0 (Bg0/Bg1) and 1 (Bg2 frozen) from the shuffling since they won't move - see channels allocation in TableSetupDrawChannels().
|
||||||
const int LEADING_DRAW_CHANNELS = 2;
|
const int LEADING_DRAW_CHANNELS = 2;
|
||||||
g.DrawChannelsTempMergeBuffer.resize(splitter->_Count - LEADING_DRAW_CHANNELS); // Use shared temporary storage so the allocation gets amortized
|
g.DrawChannelsTempMergeBuffer.resize(splitter->_Count - LEADING_DRAW_CHANNELS); // Use shared temporary storage so the allocation gets amortized
|
||||||
ImDrawChannel* dst_tmp = g.DrawChannelsTempMergeBuffer.Data;
|
ImDrawChannel* dst_tmp = g.DrawChannelsTempMergeBuffer.Data;
|
||||||
ImBitArray<IMGUI_TABLE_MAX_DRAW_CHANNELS> remaining_mask; // We need 132-bit of storage
|
ImBitArray<IMGUI_TABLE_MAX_DRAW_CHANNELS> remaining_mask; // We need 132-bit of storage
|
||||||
remaining_mask.ClearBits();
|
remaining_mask.ClearBits();
|
||||||
remaining_mask.SetBitRange(LEADING_DRAW_CHANNELS, splitter->_Count - 1);
|
remaining_mask.SetBitRange(LEADING_DRAW_CHANNELS, splitter->_Count - 1);
|
||||||
remaining_mask.ClearBit(table->Bg1DrawChannelUnfrozen);
|
remaining_mask.ClearBit(table->Bg2DrawChannelUnfrozen);
|
||||||
IM_ASSERT(has_freeze_v == false || table->Bg1DrawChannelUnfrozen != TABLE_DRAW_CHANNEL_BG1_FROZEN);
|
IM_ASSERT(has_freeze_v == false || table->Bg2DrawChannelUnfrozen != TABLE_DRAW_CHANNEL_BG2_FROZEN);
|
||||||
int remaining_count = splitter->_Count - (has_freeze_v ? LEADING_DRAW_CHANNELS + 1 : LEADING_DRAW_CHANNELS);
|
int remaining_count = splitter->_Count - (has_freeze_v ? LEADING_DRAW_CHANNELS + 1 : LEADING_DRAW_CHANNELS);
|
||||||
//ImRect host_rect = (table->InnerWindow == table->OuterWindow) ? table->InnerClipRect : table->HostClipRect;
|
//ImRect host_rect = (table->InnerWindow == table->OuterWindow) ? table->InnerClipRect : table->HostClipRect;
|
||||||
ImRect host_rect = table->HostClipRect;
|
ImRect host_rect = table->HostClipRect;
|
||||||
@ -2257,9 +2265,9 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure Bg1DrawChannelUnfrozen appears in the middle of our groups (whereas Bg0 and Bg1 frozen are fixed to 0 and 1)
|
// Make sure Bg2DrawChannelUnfrozen appears in the middle of our groups (whereas Bg0/Bg1 and Bg2 frozen are fixed to 0 and 1)
|
||||||
if (merge_group_n == 1 && has_freeze_v)
|
if (merge_group_n == 1 && has_freeze_v)
|
||||||
memcpy(dst_tmp++, &splitter->_Channels[table->Bg1DrawChannelUnfrozen], sizeof(ImDrawChannel));
|
memcpy(dst_tmp++, &splitter->_Channels[table->Bg2DrawChannelUnfrozen], sizeof(ImDrawChannel));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append unmergeable channels that we didn't reorder at the end of the list
|
// Append unmergeable channels that we didn't reorder at the end of the list
|
||||||
@ -2289,8 +2297,8 @@ void ImGui::TableDrawBorders(ImGuiTable* table)
|
|||||||
|
|
||||||
// Draw inner border and resizing feedback
|
// Draw inner border and resizing feedback
|
||||||
const float border_size = TABLE_BORDER_SIZE;
|
const float border_size = TABLE_BORDER_SIZE;
|
||||||
const float draw_y1 = table->OuterRect.Min.y;
|
const float draw_y1 = table->InnerRect.Min.y;
|
||||||
const float draw_y2_body = table->OuterRect.Max.y;
|
const float draw_y2_body = table->InnerRect.Max.y;
|
||||||
const float draw_y2_head = table->IsUsingHeaders ? ((table->FreezeRowsCount >= 1 ? table->OuterRect.Min.y : table->WorkRect.Min.y) + table->LastFirstRowHeight) : draw_y1;
|
const float draw_y2_head = table->IsUsingHeaders ? ((table->FreezeRowsCount >= 1 ? table->OuterRect.Min.y : table->WorkRect.Min.y) + table->LastFirstRowHeight) : draw_y1;
|
||||||
|
|
||||||
if (table->Flags & ImGuiTableFlags_BordersInnerV)
|
if (table->Flags & ImGuiTableFlags_BordersInnerV)
|
||||||
|
Loading…
Reference in New Issue
Block a user