mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 16:29:02 +08:00
Tables: Fix for calling TableSetBgColor(ImGuiTableBgTarget_CellBg) multiple times on the same cell.
This commit is contained in:
parent
45a80716b1
commit
8e97cdf8e8
4
imgui.h
4
imgui.h
@ -1022,8 +1022,8 @@ enum ImGuiTabItemFlags_
|
||||
// When ScrollX is on:
|
||||
// - Table defaults to ImGuiTableFlags_SizingPolicyFixedX -> all Columns defaults to ImGuiTableColumnFlags_WidthFixed.
|
||||
// - Columns sizing policy allowed: Fixed/Auto mostly! Using Stretch columns OFTEN DOES NOT MAKE SENSE if ScrollX is on, UNLESS you have specified a value for 'inner_width' in BeginTable().
|
||||
// - Fixed Columns can be enlarged as needed. Table will show an horizontal scrollbar if needed.
|
||||
// - Stretch Columns, if any, will calculate their width using inner_width, assuming no scrolling (it really doesn't make sense to do otherwise).
|
||||
// - Fixed Columns can be enlarged as needed. Table will show an horizontal scrollbar if needed.
|
||||
// - Stretch Columns, if any, will calculate their width using inner_width, assuming no scrolling (it really doesn't make sense to do otherwise).
|
||||
// - Mixing up columns with different sizing policy is possible BUT can be tricky and has some side-effects and restrictions.
|
||||
// (their visible order and the scrolling state have subtle but necessary effects on how they can be manually resized).
|
||||
// The typical use of mixing sizing policies is to have ScrollX disabled, one or two Stretch Column and many Fixed Columns.
|
||||
|
@ -2028,7 +2028,7 @@ struct ImGuiTable
|
||||
ImS8 FreezeRowsCount; // Actual frozen row count (== FreezeRowsRequest, or == 0 when no scrolling offset)
|
||||
ImS8 FreezeColumnsRequest; // Requested frozen columns count
|
||||
ImS8 FreezeColumnsCount; // Actual frozen columns count (== FreezeColumnsRequest, or == 0 when no scrolling offset)
|
||||
ImS8 RowCellDataCount; // Number of RowCellData[] entries in current row
|
||||
ImS8 RowCellDataCurrent; // Index of current RowCellData[] entry in current row
|
||||
bool IsLayoutLocked; // Set by TableUpdateLayout() which is called when beginning the first row.
|
||||
bool IsInsideRow; // Set when inside TableBeginRow()/TableEndRow().
|
||||
bool IsInitializing;
|
||||
|
@ -1623,7 +1623,7 @@ void ImGui::TableBeginRow(ImGuiTable* table)
|
||||
table->CurrentRow++;
|
||||
table->CurrentColumn = -1;
|
||||
table->RowBgColor[0] = table->RowBgColor[1] = IM_COL32_DISABLE;
|
||||
table->RowCellDataCount = 0;
|
||||
table->RowCellDataCurrent = -1;
|
||||
table->IsInsideRow = true;
|
||||
|
||||
// Begin frozen rows
|
||||
@ -1702,7 +1702,7 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
||||
}
|
||||
}
|
||||
|
||||
const bool draw_cell_bg_color = table->RowCellDataCount > 0;
|
||||
const bool draw_cell_bg_color = table->RowCellDataCurrent >= 0;
|
||||
const bool draw_strong_bottom_border = unfreeze_rows;// || (table->RowFlags & ImGuiTableRowFlags_Headers);
|
||||
if ((bg_col0 | bg_col1 | border_col) != 0 || draw_strong_bottom_border || draw_cell_bg_color)
|
||||
{
|
||||
@ -1727,7 +1727,7 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
||||
// Draw cell background color
|
||||
if (draw_cell_bg_color)
|
||||
{
|
||||
ImGuiTableCellData* cell_data_end = &table->RowCellData[table->RowCellDataCount - 1];
|
||||
ImGuiTableCellData* cell_data_end = &table->RowCellData[table->RowCellDataCurrent];
|
||||
for (ImGuiTableCellData* cell_data = &table->RowCellData[0]; cell_data <= cell_data_end; cell_data++)
|
||||
{
|
||||
ImGuiTableColumn* column = &table->Columns[cell_data->Column];
|
||||
@ -2359,7 +2359,9 @@ void ImGui::TableSetBgColor(ImGuiTableBgTarget bg_target, ImU32 color, int colum
|
||||
column_n = table->CurrentColumn;
|
||||
if ((table->VisibleUnclippedMaskByIndex & ((ImU64)1 << column_n)) == 0)
|
||||
return;
|
||||
ImGuiTableCellData* cell_data = &table->RowCellData[table->RowCellDataCount++];
|
||||
if (table->RowCellDataCurrent < 0 || table->RowCellData[table->RowCellDataCurrent].Column != column_n)
|
||||
table->RowCellDataCurrent++;
|
||||
ImGuiTableCellData* cell_data = &table->RowCellData[table->RowCellDataCurrent];
|
||||
cell_data->BgColor = color;
|
||||
cell_data->Column = (ImS8)column_n;
|
||||
break;
|
||||
|
@ -5999,7 +5999,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
// which would be advantageous since most selectable are not selected.
|
||||
if (span_all_columns && window->DC.CurrentColumns)
|
||||
PushColumnsBackground();
|
||||
else if ((flags & ImGuiSelectableFlags_SpanAllColumns) && g.CurrentTable)
|
||||
else if (span_all_columns && g.CurrentTable)
|
||||
PushTableBackground();
|
||||
|
||||
// We use NoHoldingActiveID on menus so user can click and _hold_ on a menu then drag to browse child entries
|
||||
|
Loading…
Reference in New Issue
Block a user