imgui_tables.cpp (imgui-1.86) | : | imgui_tables.cpp (imgui-1.87) | ||
---|---|---|---|---|
// dear imgui, v1.86 | // dear imgui, v1.87 | |||
// (tables and columns code) | // (tables and columns code) | |||
/* | /* | |||
Index of this file: | Index of this file: | |||
// [SECTION] Commentary | // [SECTION] Commentary | |||
// [SECTION] Header mess | // [SECTION] Header mess | |||
// [SECTION] Tables: Main code | // [SECTION] Tables: Main code | |||
// [SECTION] Tables: Simple accessors | // [SECTION] Tables: Simple accessors | |||
skipping to change at line 1571 | skipping to change at line 1571 | |||
return ImGuiTableColumnFlags_None; | return ImGuiTableColumnFlags_None; | |||
if (column_n < 0) | if (column_n < 0) | |||
column_n = table->CurrentColumn; | column_n = table->CurrentColumn; | |||
if (column_n == table->ColumnsCount) | if (column_n == table->ColumnsCount) | |||
return (table->HoveredColumnBody == column_n) ? ImGuiTableColumnFlags_Is Hovered : ImGuiTableColumnFlags_None; | return (table->HoveredColumnBody == column_n) ? ImGuiTableColumnFlags_Is Hovered : ImGuiTableColumnFlags_None; | |||
return table->Columns[column_n].Flags; | return table->Columns[column_n].Flags; | |||
} | } | |||
// Return the cell rectangle based on currently known height. | // Return the cell rectangle based on currently known height. | |||
// - Important: we generally don't know our row height until the end of the row, so Max.y will be incorrect in many situations. | // - Important: we generally don't know our row height until the end of the row, so Max.y will be incorrect in many situations. | |||
// The only case where this is correct is if we provided a min_row_height to T ableNextRow() and don't go below it. | // The only case where this is correct is if we provided a min_row_height to T ableNextRow() and don't go below it, or in TableEndRow() when we locked that hei ght. | |||
// - Important: if ImGuiTableFlags_PadOuterX is set but ImGuiTableFlags_PadInner X is not set, the outer-most left and right | // - Important: if ImGuiTableFlags_PadOuterX is set but ImGuiTableFlags_PadInner X is not set, the outer-most left and right | |||
// columns report a small offset so their CellBgRect can extend up to the oute r border. | // columns report a small offset so their CellBgRect can extend up to the oute r border. | |||
// FIXME: But the rendering code in TableEndRow() nullifies that with clamping required for scrolling. | ||||
ImRect ImGui::TableGetCellBgRect(const ImGuiTable* table, int column_n) | ImRect ImGui::TableGetCellBgRect(const ImGuiTable* table, int column_n) | |||
{ | { | |||
const ImGuiTableColumn* column = &table->Columns[column_n]; | const ImGuiTableColumn* column = &table->Columns[column_n]; | |||
float x1 = column->MinX; | float x1 = column->MinX; | |||
float x2 = column->MaxX; | float x2 = column->MaxX; | |||
if (column->PrevEnabledColumn == -1) | //if (column->PrevEnabledColumn == -1) | |||
x1 -= table->CellSpacingX1; | // x1 -= table->OuterPaddingX; | |||
if (column->NextEnabledColumn == -1) | //if (column->NextEnabledColumn == -1) | |||
x2 += table->CellSpacingX2; | // x2 += table->OuterPaddingX; | |||
x1 = ImMax(x1, table->WorkRect.Min.x); | ||||
x2 = ImMin(x2, table->WorkRect.Max.x); | ||||
return ImRect(x1, table->RowPosY1, x2, table->RowPosY2); | return ImRect(x1, table->RowPosY1, x2, table->RowPosY2); | |||
} | } | |||
// Return the resizing ID for the right-side of the given column. | // Return the resizing ID for the right-side of the given column. | |||
ImGuiID ImGui::TableGetColumnResizeID(const ImGuiTable* table, int column_n, int instance_no) | ImGuiID ImGui::TableGetColumnResizeID(const ImGuiTable* table, int column_n, int instance_no) | |||
{ | { | |||
IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount); | IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount); | |||
ImGuiID id = table->ID + 1 + (instance_no * table->ColumnsCount) + column_n; | ImGuiID id = table->ID + 1 + (instance_no * table->ColumnsCount) + column_n; | |||
return id; | return id; | |||
} | } | |||
skipping to change at line 1799 | skipping to change at line 1802 | |||
if (bg_col1 != 0 && row_rect.Min.y < row_rect.Max.y) | if (bg_col1 != 0 && row_rect.Min.y < row_rect.Max.y) | |||
window->DrawList->AddRectFilled(row_rect.Min, row_rect.Max, bg_c ol1); | window->DrawList->AddRectFilled(row_rect.Min, row_rect.Max, bg_c ol1); | |||
} | } | |||
// Draw cell background color | // Draw cell background color | |||
if (draw_cell_bg_color) | if (draw_cell_bg_color) | |||
{ | { | |||
ImGuiTableCellData* cell_data_end = &table->RowCellData[table->RowCe llDataCurrent]; | ImGuiTableCellData* cell_data_end = &table->RowCellData[table->RowCe llDataCurrent]; | |||
for (ImGuiTableCellData* cell_data = &table->RowCellData[0]; cell_da ta <= cell_data_end; cell_data++) | for (ImGuiTableCellData* cell_data = &table->RowCellData[0]; cell_da ta <= cell_data_end; cell_data++) | |||
{ | { | |||
// As we render the BG here we need to clip things (for layout w | ||||
e would not) | ||||
// FIXME: This cancels the OuterPadding addition done by TableGe | ||||
tCellBgRect(), need to keep it while rendering correctly while scrolling. | ||||
const ImGuiTableColumn* column = &table->Columns[cell_data->Colu mn]; | const ImGuiTableColumn* column = &table->Columns[cell_data->Colu mn]; | |||
ImRect cell_bg_rect = TableGetCellBgRect(table, cell_data->Colum n); | ImRect cell_bg_rect = TableGetCellBgRect(table, cell_data->Colum n); | |||
cell_bg_rect.ClipWith(table->BgClipRect); | cell_bg_rect.ClipWith(table->BgClipRect); | |||
cell_bg_rect.Min.x = ImMax(cell_bg_rect.Min.x, column->ClipRect. Min.x); // So that first column after frozen one gets clipped | cell_bg_rect.Min.x = ImMax(cell_bg_rect.Min.x, column->ClipRect. Min.x); // So that first column after frozen one gets clipped when scrolling | |||
cell_bg_rect.Max.x = ImMin(cell_bg_rect.Max.x, column->MaxX); | cell_bg_rect.Max.x = ImMin(cell_bg_rect.Max.x, column->MaxX); | |||
window->DrawList->AddRectFilled(cell_bg_rect.Min, cell_bg_rect.M ax, cell_data->BgColor); | window->DrawList->AddRectFilled(cell_bg_rect.Min, cell_bg_rect.M ax, cell_data->BgColor); | |||
} | } | |||
} | } | |||
// Draw top border | // Draw top border | |||
if (border_col && bg_y1 >= table->BgClipRect.Min.y && bg_y1 < table->BgC lipRect.Max.y) | if (border_col && bg_y1 >= table->BgClipRect.Min.y && bg_y1 < table->BgC lipRect.Max.y) | |||
window->DrawList->AddLine(ImVec2(table->BorderX1, bg_y1), ImVec2(tab le->BorderX2, bg_y1), border_col, border_size); | window->DrawList->AddLine(ImVec2(table->BorderX1, bg_y1), ImVec2(tab le->BorderX2, bg_y1), border_col, border_size); | |||
// Draw bottom border at the row unfreezing mark (always strong) | // Draw bottom border at the row unfreezing mark (always strong) | |||
skipping to change at line 2354 | skipping to change at line 2359 | |||
continue; | continue; | |||
ImGuiTableColumn* column = &table->Columns[column_n]; | ImGuiTableColumn* column = &table->Columns[column_n]; | |||
const int merge_group_sub_count = has_freeze_v ? 2 : 1; | const int merge_group_sub_count = has_freeze_v ? 2 : 1; | |||
for (int merge_group_sub_n = 0; merge_group_sub_n < merge_group_sub_coun t; merge_group_sub_n++) | for (int merge_group_sub_n = 0; merge_group_sub_n < merge_group_sub_coun t; merge_group_sub_n++) | |||
{ | { | |||
const int channel_no = (merge_group_sub_n == 0) ? column->DrawChanne lFrozen : column->DrawChannelUnfrozen; | const int channel_no = (merge_group_sub_n == 0) ? column->DrawChanne lFrozen : column->DrawChannelUnfrozen; | |||
// Don't attempt to merge if there are multiple draw calls within th e column | // Don't attempt to merge if there are multiple draw calls within th e column | |||
ImDrawChannel* src_channel = &splitter->_Channels[channel_no]; | ImDrawChannel* src_channel = &splitter->_Channels[channel_no]; | |||
if (src_channel->_CmdBuffer.Size > 0 && src_channel->_CmdBuffer.back ().ElemCount == 0) | if (src_channel->_CmdBuffer.Size > 0 && src_channel->_CmdBuffer.back ().ElemCount == 0 && src_channel->_CmdBuffer.back().UserCallback != NULL) // Equ ivalent of PopUnusedDrawCmd() | |||
src_channel->_CmdBuffer.pop_back(); | src_channel->_CmdBuffer.pop_back(); | |||
if (src_channel->_CmdBuffer.Size != 1) | if (src_channel->_CmdBuffer.Size != 1) | |||
continue; | continue; | |||
// Find out the width of this merge group and check if it will fit i n our column | // Find out the width of this merge group and check if it will fit i n our column | |||
// (note that we assume that rendering didn't stray on the left dire ction. we should need a CursorMinPos to detect it) | // (note that we assume that rendering didn't stray on the left dire ction. we should need a CursorMinPos to detect it) | |||
if (!(column->Flags & ImGuiTableColumnFlags_NoClip)) | if (!(column->Flags & ImGuiTableColumnFlags_NoClip)) | |||
{ | { | |||
float content_max_x; | float content_max_x; | |||
if (!has_freeze_v) | if (!has_freeze_v) | |||
End of changes. 7 change blocks. | ||||
8 lines changed or deleted | 15 lines changed or added |