@ -350,6 +350,8 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
g . TablesTempDataStack . resize ( g . CurrentTableStackIdx + 1 , ImGuiTableTempData ( ) ) ;
g . TablesTempDataStack . resize ( g . CurrentTableStackIdx + 1 , ImGuiTableTempData ( ) ) ;
ImGuiTableTempData * temp_data = table - > TempData = & g . TablesTempDataStack [ g . CurrentTableStackIdx ] ;
ImGuiTableTempData * temp_data = table - > TempData = & g . TablesTempDataStack [ g . CurrentTableStackIdx ] ;
temp_data - > TableIndex = table_idx ;
temp_data - > TableIndex = table_idx ;
table - > DrawSplitter = & table - > TempData - > DrawSplitter ;
table - > DrawSplitter - > Clear ( ) ;
// Fix flags
// Fix flags
table - > IsDefaultSizingPolicy = ( flags & ImGuiTableFlags_SizingMask_ ) = = 0 ;
table - > IsDefaultSizingPolicy = ( flags & ImGuiTableFlags_SizingMask_ ) = = 0 ;
@ -475,6 +477,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
if ( table_idx > = g . TablesLastTimeActive . Size )
if ( table_idx > = g . TablesLastTimeActive . Size )
g . TablesLastTimeActive . resize ( table_idx + 1 , - 1.0f ) ;
g . TablesLastTimeActive . resize ( table_idx + 1 , - 1.0f ) ;
g . TablesLastTimeActive [ table_idx ] = ( float ) g . Time ;
g . TablesLastTimeActive [ table_idx ] = ( float ) g . Time ;
temp_data - > LastTimeActive = ( float ) g . Time ;
table - > MemoryCompacted = false ;
table - > MemoryCompacted = false ;
// Setup memory buffer (clear data if columns count changed)
// Setup memory buffer (clear data if columns count changed)
@ -1123,7 +1126,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
// Initial state
// Initial state
ImGuiWindow * inner_window = table - > InnerWindow ;
ImGuiWindow * inner_window = table - > InnerWindow ;
if ( table - > Flags & ImGuiTableFlags_NoClip )
if ( table - > Flags & ImGuiTableFlags_NoClip )
table - > DrawSplitter . SetCurrentChannel ( inner_window - > DrawList , TABLE_DRAW_CHANNEL_NOCLIP ) ;
table - > DrawSplitter - > SetCurrentChannel ( inner_window - > DrawList , TABLE_DRAW_CHANNEL_NOCLIP ) ;
else
else
inner_window - > DrawList - > PushClipRect ( inner_window - > ClipRect . Min , inner_window - > ClipRect . Max , false ) ;
inner_window - > DrawList - > PushClipRect ( inner_window - > ClipRect . Min , inner_window - > ClipRect . Max , false ) ;
}
}
@ -1273,7 +1276,7 @@ void ImGui::EndTable()
# endif
# endif
// Flatten channels and merge draw calls
// Flatten channels and merge draw calls
ImDrawListSplitter * splitter = & table - > DrawSplitter ;
ImDrawListSplitter * splitter = table - > DrawSplitter ;
splitter - > SetCurrentChannel ( inner_window - > DrawList , 0 ) ;
splitter - > SetCurrentChannel ( inner_window - > DrawList , 0 ) ;
if ( ( table - > Flags & ImGuiTableFlags_NoClip ) = = 0 )
if ( ( table - > Flags & ImGuiTableFlags_NoClip ) = = 0 )
TableMergeDrawChannels ( table ) ;
TableMergeDrawChannels ( table ) ;
@ -1387,7 +1390,10 @@ void ImGui::EndTable()
temp_data = g . CurrentTableStackIdx > = 0 ? & g . TablesTempDataStack [ g . CurrentTableStackIdx ] : NULL ;
temp_data = g . CurrentTableStackIdx > = 0 ? & g . TablesTempDataStack [ g . CurrentTableStackIdx ] : NULL ;
g . CurrentTable = temp_data ? g . Tables . GetByIndex ( temp_data - > TableIndex ) : NULL ;
g . CurrentTable = temp_data ? g . Tables . GetByIndex ( temp_data - > TableIndex ) : NULL ;
if ( g . CurrentTable )
if ( g . CurrentTable )
{
g . CurrentTable - > TempData = temp_data ;
g . CurrentTable - > TempData = temp_data ;
g . CurrentTable - > DrawSplitter = & temp_data - > DrawSplitter ;
}
outer_window - > DC . CurrentTableIdx = g . CurrentTable ? g . Tables . GetIndex ( g . CurrentTable ) : - 1 ;
outer_window - > DC . CurrentTableIdx = g . CurrentTable ? g . Tables . GetIndex ( g . CurrentTable ) : - 1 ;
}
}
@ -1760,7 +1766,7 @@ void ImGui::TableEndRow(ImGuiTable* table)
// always followed by a change of clipping rectangle we perform the smallest overwrite possible here.
// always followed by a change of clipping rectangle we perform the smallest overwrite possible here.
if ( ( table - > Flags & ImGuiTableFlags_NoClip ) = = 0 )
if ( ( table - > Flags & ImGuiTableFlags_NoClip ) = = 0 )
window - > DrawList - > _CmdHeader . ClipRect = table - > Bg0ClipRectForDrawCmd . ToVec4 ( ) ;
window - > DrawList - > _CmdHeader . ClipRect = table - > Bg0ClipRectForDrawCmd . ToVec4 ( ) ;
table - > DrawSplitter . SetCurrentChannel ( window - > DrawList , TABLE_DRAW_CHANNEL_BG0 ) ;
table - > DrawSplitter - > SetCurrentChannel ( window - > DrawList , TABLE_DRAW_CHANNEL_BG0 ) ;
}
}
// Draw row background
// Draw row background
@ -1832,7 +1838,7 @@ void ImGui::TableEndRow(ImGuiTable* table)
// Update cliprect ahead of TableBeginCell() so clipper can access to new ClipRect->Min.y
// Update cliprect ahead of TableBeginCell() so clipper can access to new ClipRect->Min.y
SetWindowClipRectBeforeSetChannel ( window , table - > Columns [ 0 ] . ClipRect ) ;
SetWindowClipRectBeforeSetChannel ( window , table - > Columns [ 0 ] . ClipRect ) ;
table - > DrawSplitter . SetCurrentChannel ( window - > DrawList , table - > Columns [ 0 ] . DrawChannelCurrent ) ;
table - > DrawSplitter - > SetCurrentChannel ( window - > DrawList , table - > Columns [ 0 ] . DrawChannelCurrent ) ;
}
}
if ( ! ( table - > RowFlags & ImGuiTableRowFlags_Headers ) )
if ( ! ( table - > RowFlags & ImGuiTableRowFlags_Headers ) )
@ -1947,14 +1953,14 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
if ( table - > Flags & ImGuiTableFlags_NoClip )
if ( table - > Flags & ImGuiTableFlags_NoClip )
{
{
// FIXME: if we end up drawing all borders/bg in EndTable, could remove this and just assert that channel hasn't changed.
// FIXME: if we end up drawing all borders/bg in EndTable, could remove this and just assert that channel hasn't changed.
table - > DrawSplitter . SetCurrentChannel ( window - > DrawList , TABLE_DRAW_CHANNEL_NOCLIP ) ;
table - > DrawSplitter - > SetCurrentChannel ( window - > DrawList , TABLE_DRAW_CHANNEL_NOCLIP ) ;
//IM_ASSERT(table->DrawSplitter._Current == TABLE_DRAW_CHANNEL_NOCLIP);
//IM_ASSERT(table->DrawSplitter._Current == TABLE_DRAW_CHANNEL_NOCLIP);
}
}
else
else
{
{
// FIXME-TABLE: Could avoid this if draw channel is dummy channel?
// FIXME-TABLE: Could avoid this if draw channel is dummy channel?
SetWindowClipRectBeforeSetChannel ( window , column - > ClipRect ) ;
SetWindowClipRectBeforeSetChannel ( window , column - > ClipRect ) ;
table - > DrawSplitter . SetCurrentChannel ( window - > DrawList , column - > DrawChannelCurrent ) ;
table - > DrawSplitter - > SetCurrentChannel ( window - > DrawList , column - > DrawChannelCurrent ) ;
}
}
// Logging
// Logging
@ -2202,7 +2208,7 @@ void ImGui::TablePushBackgroundChannel()
// Optimization: avoid SetCurrentChannel() + PushClipRect()
// Optimization: avoid SetCurrentChannel() + PushClipRect()
table - > HostBackupInnerClipRect = window - > ClipRect ;
table - > HostBackupInnerClipRect = window - > ClipRect ;
SetWindowClipRectBeforeSetChannel ( window , table - > Bg2ClipRectForDrawCmd ) ;
SetWindowClipRectBeforeSetChannel ( window , table - > Bg2ClipRectForDrawCmd ) ;
table - > DrawSplitter . SetCurrentChannel ( window - > DrawList , table - > Bg2DrawChannelCurrent ) ;
table - > DrawSplitter - > SetCurrentChannel ( window - > DrawList , table - > Bg2DrawChannelCurrent ) ;
}
}
void ImGui : : TablePopBackgroundChannel ( )
void ImGui : : TablePopBackgroundChannel ( )
@ -2214,7 +2220,7 @@ void ImGui::TablePopBackgroundChannel()
// Optimization: avoid PopClipRect() + SetCurrentChannel()
// Optimization: avoid PopClipRect() + SetCurrentChannel()
SetWindowClipRectBeforeSetChannel ( window , table - > HostBackupInnerClipRect ) ;
SetWindowClipRectBeforeSetChannel ( window , table - > HostBackupInnerClipRect ) ;
table - > DrawSplitter . SetCurrentChannel ( window - > DrawList , column - > DrawChannelCurrent ) ;
table - > DrawSplitter - > SetCurrentChannel ( window - > DrawList , column - > DrawChannelCurrent ) ;
}
}
// Allocate draw channels. Called by TableUpdateLayout()
// Allocate draw channels. Called by TableUpdateLayout()
@ -2240,7 +2246,7 @@ void ImGui::TableSetupDrawChannels(ImGuiTable* table)
const int channels_for_bg = 1 + 1 * freeze_row_multiplier ;
const int channels_for_bg = 1 + 1 * freeze_row_multiplier ;
const int channels_for_dummy = ( table - > ColumnsEnabledCount < table - > ColumnsCount | | table - > VisibleMaskByIndex ! = table - > EnabledMaskByIndex ) ? + 1 : 0 ;
const int channels_for_dummy = ( table - > ColumnsEnabledCount < table - > ColumnsCount | | table - > VisibleMaskByIndex ! = table - > EnabledMaskByIndex ) ? + 1 : 0 ;
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 - > Bg2DrawChannelCurrent = TABLE_DRAW_CHANNEL_BG2_FROZEN ;
table - > Bg2DrawChannelCurrent = TABLE_DRAW_CHANNEL_BG2_FROZEN ;
table - > Bg2DrawChannelUnfrozen = ( ImGuiTableDrawChannelIdx ) ( ( table - > FreezeRowsCount > 0 ) ? 2 + channels_for_row : TABLE_DRAW_CHANNEL_BG2_FROZEN ) ;
table - > Bg2DrawChannelUnfrozen = ( ImGuiTableDrawChannelIdx ) ( ( table - > FreezeRowsCount > 0 ) ? 2 + channels_for_row : TABLE_DRAW_CHANNEL_BG2_FROZEN ) ;
@ -2304,7 +2310,7 @@ void ImGui::TableSetupDrawChannels(ImGuiTable* table)
void ImGui : : TableMergeDrawChannels ( ImGuiTable * table )
void ImGui : : TableMergeDrawChannels ( ImGuiTable * table )
{
{
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
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 ) ;
IM_ASSERT ( splitter - > _Current = = 0 ) ;
@ -2475,7 +2481,7 @@ void ImGui::TableDrawBorders(ImGuiTable* table)
return ;
return ;
ImDrawList * inner_drawlist = inner_window - > DrawList ;
ImDrawList * inner_drawlist = inner_window - > DrawList ;
table - > DrawSplitter . SetCurrentChannel ( inner_drawlist , TABLE_DRAW_CHANNEL_BG0 ) ;
table - > DrawSplitter - > SetCurrentChannel ( inner_drawlist , TABLE_DRAW_CHANNEL_BG0 ) ;
inner_drawlist - > PushClipRect ( table - > Bg0ClipRectForDrawCmd . Min , table - > Bg0ClipRectForDrawCmd . Max , false ) ;
inner_drawlist - > PushClipRect ( table - > Bg0ClipRectForDrawCmd . Min , table - > Bg0ClipRectForDrawCmd . Max , false ) ;
// Draw inner border and resizing feedback
// Draw inner border and resizing feedback
@ -2735,8 +2741,9 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
TableSortSpecsSanitize ( table ) ;
TableSortSpecsSanitize ( table ) ;
// Write output
// Write output
table - > SortSpecsMulti . resize ( table - > SortSpecsCount < = 1 ? 0 : table - > SortSpecsCount ) ;
ImGuiTableTempData * temp_data = table - > TempData ;
ImGuiTableColumnSortSpecs * sort_specs = ( table - > SortSpecsCount = = 0 ) ? NULL : ( table - > SortSpecsCount = = 1 ) ? & table - > SortSpecsSingle : table - > SortSpecsMulti . Data ;
temp_data - > SortSpecsMulti . resize ( table - > SortSpecsCount < = 1 ? 0 : table - > SortSpecsCount ) ;
ImGuiTableColumnSortSpecs * sort_specs = ( table - > SortSpecsCount = = 0 ) ? NULL : ( table - > SortSpecsCount = = 1 ) ? & temp_data - > SortSpecsSingle : temp_data - > SortSpecsMulti . Data ;
if ( sort_specs ! = NULL )
if ( sort_specs ! = NULL )
for ( int column_n = 0 ; column_n < table - > ColumnsCount ; column_n + + )
for ( int column_n = 0 ; column_n < table - > ColumnsCount ; column_n + + )
{
{
@ -3434,8 +3441,6 @@ void ImGui::TableGcCompactTransientBuffers(ImGuiTable* table)
//IMGUI_DEBUG_LOG("TableGcCompactTransientBuffers() id=0x%08X\n", table->ID);
//IMGUI_DEBUG_LOG("TableGcCompactTransientBuffers() id=0x%08X\n", table->ID);
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
IM_ASSERT ( table - > MemoryCompacted = = false ) ;
IM_ASSERT ( table - > MemoryCompacted = = false ) ;
table - > DrawSplitter . ClearFreeMemory ( ) ;
table - > SortSpecsMulti . clear ( ) ;
table - > SortSpecs . Specs = NULL ;
table - > SortSpecs . Specs = NULL ;
table - > IsSortSpecsDirty = true ;
table - > IsSortSpecsDirty = true ;
table - > ColumnsNames . clear ( ) ;
table - > ColumnsNames . clear ( ) ;
@ -3445,6 +3450,13 @@ void ImGui::TableGcCompactTransientBuffers(ImGuiTable* table)
g . TablesLastTimeActive [ g . Tables . GetIndex ( table ) ] = - 1.0f ;
g . TablesLastTimeActive [ g . Tables . GetIndex ( table ) ] = - 1.0f ;
}
}
void ImGui : : TableGcCompactTransientBuffers ( ImGuiTableTempData * temp_data )
{
temp_data - > DrawSplitter . ClearFreeMemory ( ) ;
temp_data - > SortSpecsMulti . clear ( ) ;
temp_data - > LastTimeActive = - 1.0f ;
}
// Compact and remove unused settings data (currently only used by TestEngine)
// Compact and remove unused settings data (currently only used by TestEngine)
void ImGui : : TableGcCompactSettings ( )
void ImGui : : TableGcCompactSettings ( )
{
{