mirror of
https://github.com/shadps4-emu/ext-imgui.git
synced 2024-11-26 19:51:27 +00:00
Tables: Added ImGuiTableColumnFlags_Disabled acting a master disable over (hidden from user/context menu). (#3935, #3740)
This commit is contained in:
parent
b918751ff4
commit
6ee398ac2b
@ -37,6 +37,7 @@ HOW TO UPDATE?
|
||||
|
||||
Other Changes:
|
||||
- TabBar: Fixed using more than 32 KB-worth of tab names. (#4176)
|
||||
- Tables: Added ImGuiTableColumnFlags_Disabled acting a master disable over (hidden from user/context menu). (#3935)
|
||||
- Tables: Clarified that TableSetColumnEnabled() requires the table to use the ImGuiTableFlags_Hideable flag,
|
||||
because it manipulates the user-accessible show/hide state. (#3935)
|
||||
- Tables: Added ImGuiTableColumnFlags_NoHeaderLabel to request TableHeadersRow() to not submit label for a column.
|
||||
|
3
imgui.h
3
imgui.h
@ -741,7 +741,7 @@ namespace ImGui
|
||||
IMGUI_API int TableGetRowIndex(); // return current row index.
|
||||
IMGUI_API const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column.
|
||||
IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. Pass -1 to use current column.
|
||||
IMGUI_API void TableSetColumnEnabled(int column_n, bool v);// change enabled/disabled state of a column, set to false to hide the column. Note that end-user can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody)
|
||||
IMGUI_API void TableSetColumnEnabled(int column_n, bool v);// change user accessible enabled/disabled state of a column. Set to false to hide the column. User can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody)
|
||||
IMGUI_API void TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n = -1); // change the color of a cell, row, or column. See ImGuiTableBgTarget_ flags for details.
|
||||
|
||||
// Legacy Columns API (2020: prefer using Tables!)
|
||||
@ -1164,6 +1164,7 @@ enum ImGuiTableColumnFlags_
|
||||
{
|
||||
// Input configuration flags
|
||||
ImGuiTableColumnFlags_None = 0,
|
||||
ImGuiTableColumnFlags_Disabled = 1 << 0, // Overriding/master disable flag: hide column, won't show in context menu (unlike calling TableSetColumnEnabled() which manipulates the user accessible state)
|
||||
ImGuiTableColumnFlags_DefaultHide = 1 << 1, // Default as a hidden/disabled column.
|
||||
ImGuiTableColumnFlags_DefaultSort = 1 << 2, // Default as a sorting column.
|
||||
ImGuiTableColumnFlags_WidthStretch = 1 << 3, // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is _SizingStretchSame or _SizingStretchProp).
|
||||
|
@ -3496,6 +3496,7 @@ static void EditTableSizingFlags(ImGuiTableFlags* p_flags)
|
||||
|
||||
static void EditTableColumnsFlags(ImGuiTableColumnFlags* p_flags)
|
||||
{
|
||||
ImGui::CheckboxFlags("_Disabled", p_flags, ImGuiTableColumnFlags_Disabled); ImGui::SameLine(); HelpMarker("Master disable flag (also hide from context menu)");
|
||||
ImGui::CheckboxFlags("_DefaultHide", p_flags, ImGuiTableColumnFlags_DefaultHide);
|
||||
ImGui::CheckboxFlags("_DefaultSort", p_flags, ImGuiTableColumnFlags_DefaultSort);
|
||||
if (ImGui::CheckboxFlags("_WidthStretch", p_flags, ImGuiTableColumnFlags_WidthStretch))
|
||||
|
@ -2068,8 +2068,9 @@ struct ImGuiTableColumn
|
||||
ImGuiTableDrawChannelIdx DrawChannelCurrent; // Index within DrawSplitter.Channels[]
|
||||
ImGuiTableDrawChannelIdx DrawChannelFrozen; // Draw channels for frozen rows (often headers)
|
||||
ImGuiTableDrawChannelIdx DrawChannelUnfrozen; // Draw channels for unfrozen rows
|
||||
bool IsEnabled; // Is the column not marked Hidden by the user? (even if off view, e.g. clipped by scrolling).
|
||||
bool IsEnabledNextFrame;
|
||||
bool IsEnabled; // IsUserEnabled && (Flags & ImGuiTableColumnFlags_Disabled) == 0
|
||||
bool IsUserEnabled; // Is the column not marked Hidden by the user? (unrelated to being off view, e.g. clipped by scrolling).
|
||||
bool IsUserEnabledNextFrame;
|
||||
bool IsVisibleX; // Is actually in view (e.g. overlapping the host window clipping rectangle, not scrolled).
|
||||
bool IsVisibleY;
|
||||
bool IsRequestOutput; // Return value for TableSetColumnIndex() / TableNextColumn(): whether we request user to output contents or not.
|
||||
|
@ -522,7 +522,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
||||
*column = ImGuiTableColumn();
|
||||
column->WidthAuto = width_auto;
|
||||
column->IsPreserveWidthAuto = true; // Preserve WidthAuto when reinitializing a live table: not technically necessary but remove a visible flicker
|
||||
column->IsEnabled = column->IsEnabledNextFrame = true;
|
||||
column->IsEnabled = column->IsUserEnabled = column->IsUserEnabledNextFrame = true;
|
||||
}
|
||||
column->DisplayOrder = table->DisplayOrderToIndex[n] = (ImGuiTableColumnIdx)n;
|
||||
}
|
||||
@ -756,16 +756,18 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
column->InitStretchWeightOrWidth = -1.0f;
|
||||
}
|
||||
|
||||
// Update Enabled state, mark settings/sortspecs dirty
|
||||
// Update Enabled state, mark settings and sort specs dirty
|
||||
if (!(table->Flags & ImGuiTableFlags_Hideable) || (column->Flags & ImGuiTableColumnFlags_NoHide))
|
||||
column->IsEnabledNextFrame = true;
|
||||
if (column->IsEnabled != column->IsEnabledNextFrame)
|
||||
column->IsUserEnabledNextFrame = true;
|
||||
if (column->IsUserEnabled != column->IsUserEnabledNextFrame)
|
||||
{
|
||||
column->IsEnabled = column->IsEnabledNextFrame;
|
||||
column->IsUserEnabled = column->IsUserEnabledNextFrame;
|
||||
table->IsSettingsDirty = true;
|
||||
if (!column->IsEnabled && column->SortOrder != -1)
|
||||
table->IsSortSpecsDirty = true;
|
||||
}
|
||||
column->IsEnabled = column->IsUserEnabled && (column->Flags & ImGuiTableColumnFlags_Disabled) == 0;
|
||||
|
||||
if (column->SortOrder != -1 && !column->IsEnabled)
|
||||
table->IsSortSpecsDirty = true;
|
||||
if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti))
|
||||
table->IsSortSpecsDirty = true;
|
||||
|
||||
@ -1448,7 +1450,7 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo
|
||||
|
||||
// Init default visibility/sort state
|
||||
if ((flags & ImGuiTableColumnFlags_DefaultHide) && (table->SettingsLoadedFlags & ImGuiTableFlags_Hideable) == 0)
|
||||
column->IsEnabled = column->IsEnabledNextFrame = false;
|
||||
column->IsUserEnabled = column->IsUserEnabledNextFrame = false;
|
||||
if (flags & ImGuiTableColumnFlags_DefaultSort && (table->SettingsLoadedFlags & ImGuiTableFlags_Sortable) == 0)
|
||||
{
|
||||
column->SortOrder = 0; // Multiple columns using _DefaultSort will be reassigned unique SortOrder values when building the sort specs.
|
||||
@ -1540,6 +1542,7 @@ const char* ImGui::TableGetColumnName(const ImGuiTable* table, int column_n)
|
||||
// - Require table to have the ImGuiTableFlags_Hideable flag because we are manipulating user accessible state.
|
||||
// - Request will be applied during next layout, which happens on the first call to TableNextRow() after BeginTable().
|
||||
// - For the getter you can test (TableGetColumnFlags() & ImGuiTableColumnFlags_IsEnabled) != 0.
|
||||
// - Alternative: the ImGuiTableColumnFlags_Disabled is an overriding/master disable flag which will also hide the column from context menu.
|
||||
void ImGui::TableSetColumnEnabled(int column_n, bool enabled)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -1552,7 +1555,7 @@ void ImGui::TableSetColumnEnabled(int column_n, bool enabled)
|
||||
column_n = table->CurrentColumn;
|
||||
IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount);
|
||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||
column->IsEnabledNextFrame = enabled;
|
||||
column->IsUserEnabledNextFrame = enabled;
|
||||
}
|
||||
|
||||
// We allow querying for an extra column in order to poll the IsHovered state of the right-most section
|
||||
@ -3089,16 +3092,19 @@ void ImGui::TableDrawContextMenu(ImGuiTable* table)
|
||||
for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
|
||||
{
|
||||
ImGuiTableColumn* other_column = &table->Columns[other_column_n];
|
||||
if (other_column->Flags & ImGuiTableColumnFlags_Disabled)
|
||||
continue;
|
||||
|
||||
const char* name = TableGetColumnName(table, other_column_n);
|
||||
if (name == NULL || name[0] == 0)
|
||||
name = "<Unknown>";
|
||||
|
||||
// Make sure we can't hide the last active column
|
||||
bool menu_item_active = (other_column->Flags & ImGuiTableColumnFlags_NoHide) ? false : true;
|
||||
if (other_column->IsEnabled && table->ColumnsEnabledCount <= 1)
|
||||
if (other_column->IsUserEnabled && table->ColumnsEnabledCount <= 1)
|
||||
menu_item_active = false;
|
||||
if (MenuItem(name, NULL, other_column->IsEnabled, menu_item_active))
|
||||
other_column->IsEnabledNextFrame = !other_column->IsEnabled;
|
||||
if (MenuItem(name, NULL, other_column->IsUserEnabled, menu_item_active))
|
||||
other_column->IsUserEnabledNextFrame = !other_column->IsUserEnabled;
|
||||
}
|
||||
PopItemFlag();
|
||||
}
|
||||
@ -3223,7 +3229,7 @@ void ImGui::TableSaveSettings(ImGuiTable* table)
|
||||
column_settings->DisplayOrder = column->DisplayOrder;
|
||||
column_settings->SortOrder = column->SortOrder;
|
||||
column_settings->SortDirection = column->SortDirection;
|
||||
column_settings->IsEnabled = column->IsEnabled;
|
||||
column_settings->IsEnabled = column->IsUserEnabled;
|
||||
column_settings->IsStretch = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? 1 : 0;
|
||||
if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) == 0)
|
||||
save_ref_scale = true;
|
||||
@ -3237,7 +3243,7 @@ void ImGui::TableSaveSettings(ImGuiTable* table)
|
||||
settings->SaveFlags |= ImGuiTableFlags_Reorderable;
|
||||
if (column->SortOrder != -1)
|
||||
settings->SaveFlags |= ImGuiTableFlags_Sortable;
|
||||
if (column->IsEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) == 0))
|
||||
if (column->IsUserEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) == 0))
|
||||
settings->SaveFlags |= ImGuiTableFlags_Hideable;
|
||||
}
|
||||
settings->SaveFlags &= table->Flags;
|
||||
@ -3295,7 +3301,7 @@ void ImGui::TableLoadSettings(ImGuiTable* table)
|
||||
else
|
||||
column->DisplayOrder = (ImGuiTableColumnIdx)column_n;
|
||||
display_order_mask |= (ImU64)1 << column->DisplayOrder;
|
||||
column->IsEnabled = column->IsEnabledNextFrame = column_settings->IsEnabled;
|
||||
column->IsUserEnabled = column->IsUserEnabledNextFrame = column_settings->IsEnabled;
|
||||
column->SortOrder = column_settings->SortOrder;
|
||||
column->SortDirection = column_settings->SortDirection;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user