mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-06 06:25:54 +01:00
Tables: Context-menu: added "Reset" sub-menu and "Reset Visibility" option.
This commit is contained in:
parent
b10137f92f
commit
e5ff2d07d7
@ -55,6 +55,9 @@ Other Changes:
|
|||||||
- InputText:
|
- InputText:
|
||||||
- Added `style.InputTextCursorSize` to configure cursor/caret thickness. (#7031, #9409)
|
- Added `style.InputTextCursorSize` to configure cursor/caret thickness. (#7031, #9409)
|
||||||
This is automatically scaled by `style.ScaleAllSizes()`.
|
This is automatically scaled by `style.ScaleAllSizes()`.
|
||||||
|
- Tables:
|
||||||
|
- Context Menu: added a "Reset" sub-menu with a "Reset Visibility" option.
|
||||||
|
(which is greyed out when using default settings)
|
||||||
- Fonts:
|
- Fonts:
|
||||||
- Added `IMGUI_DISABLE_DEFAULT_FONT_BITMAP`/`IMGUI_DISABLE_DEFAULT_FONT_VECTOR` to
|
- Added `IMGUI_DISABLE_DEFAULT_FONT_BITMAP`/`IMGUI_DISABLE_DEFAULT_FONT_VECTOR` to
|
||||||
disable embedding either fonts separately. (#9407)
|
disable embedding either fonts separately. (#9407)
|
||||||
|
|||||||
@ -4161,7 +4161,10 @@ static const ImGuiLocEntry GLocalizationEntriesEnUS[] =
|
|||||||
{ ImGuiLocKey_TableSizeOne, "Size column to fit###SizeOne" },
|
{ ImGuiLocKey_TableSizeOne, "Size column to fit###SizeOne" },
|
||||||
{ ImGuiLocKey_TableSizeAllFit, "Size all columns to fit###SizeAll" },
|
{ ImGuiLocKey_TableSizeAllFit, "Size all columns to fit###SizeAll" },
|
||||||
{ ImGuiLocKey_TableSizeAllDefault, "Size all columns to default###SizeAll" },
|
{ ImGuiLocKey_TableSizeAllDefault, "Size all columns to default###SizeAll" },
|
||||||
|
{ ImGuiLocKey_TableReset, "Reset" },
|
||||||
|
//{ ImGuiLocKey_TableResetAll, "Reset to default###ResetAll" },
|
||||||
{ ImGuiLocKey_TableResetOrder, "Reset order###ResetOrder" },
|
{ ImGuiLocKey_TableResetOrder, "Reset order###ResetOrder" },
|
||||||
|
{ ImGuiLocKey_TableResetVisibility, "Reset visibility###ResetVisibility" },
|
||||||
{ ImGuiLocKey_WindowingMainMenuBar, "(Main menu bar)" },
|
{ ImGuiLocKey_WindowingMainMenuBar, "(Main menu bar)" },
|
||||||
{ ImGuiLocKey_WindowingPopup, "(Popup)" },
|
{ ImGuiLocKey_WindowingPopup, "(Popup)" },
|
||||||
{ ImGuiLocKey_WindowingUntitled, "(Untitled)" },
|
{ ImGuiLocKey_WindowingUntitled, "(Untitled)" },
|
||||||
|
|||||||
2
imgui.h
2
imgui.h
@ -30,7 +30,7 @@
|
|||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||||
#define IMGUI_VERSION "1.92.9 WIP"
|
#define IMGUI_VERSION "1.92.9 WIP"
|
||||||
#define IMGUI_VERSION_NUM 19282
|
#define IMGUI_VERSION_NUM 19283
|
||||||
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
||||||
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
||||||
|
|
||||||
|
|||||||
@ -2047,7 +2047,10 @@ enum ImGuiLocKey : int
|
|||||||
ImGuiLocKey_TableSizeOne,
|
ImGuiLocKey_TableSizeOne,
|
||||||
ImGuiLocKey_TableSizeAllFit,
|
ImGuiLocKey_TableSizeAllFit,
|
||||||
ImGuiLocKey_TableSizeAllDefault,
|
ImGuiLocKey_TableSizeAllDefault,
|
||||||
|
ImGuiLocKey_TableReset,
|
||||||
|
//ImGuiLocKey_TableResetAll,
|
||||||
ImGuiLocKey_TableResetOrder,
|
ImGuiLocKey_TableResetOrder,
|
||||||
|
ImGuiLocKey_TableResetVisibility,
|
||||||
ImGuiLocKey_WindowingMainMenuBar,
|
ImGuiLocKey_WindowingMainMenuBar,
|
||||||
ImGuiLocKey_WindowingPopup,
|
ImGuiLocKey_WindowingPopup,
|
||||||
ImGuiLocKey_WindowingUntitled,
|
ImGuiLocKey_WindowingUntitled,
|
||||||
@ -3086,8 +3089,10 @@ struct IMGUI_API ImGuiTable
|
|||||||
bool IsSettingsRequestLoad;
|
bool IsSettingsRequestLoad;
|
||||||
bool IsSettingsDirty; // Set when table settings have changed and needs to be reported into ImGuiTableSettings data.
|
bool IsSettingsDirty; // Set when table settings have changed and needs to be reported into ImGuiTableSettings data.
|
||||||
bool IsDefaultDisplayOrder; // Set when display order is unchanged from default (DisplayOrder contains 0...Count-1)
|
bool IsDefaultDisplayOrder; // Set when display order is unchanged from default (DisplayOrder contains 0...Count-1)
|
||||||
bool IsResetAllRequest;
|
bool IsDefaultVisibility; // Set when enabled/visibility is unchanged from default
|
||||||
|
bool IsResetAllRequest; // Set to queue a call to TableResetSettings() in BeginTable()
|
||||||
bool IsResetDisplayOrderRequest;
|
bool IsResetDisplayOrderRequest;
|
||||||
|
bool IsResetVisibilityRequest;
|
||||||
bool IsUnfrozenRows; // Set when we got past the frozen row.
|
bool IsUnfrozenRows; // Set when we got past the frozen row.
|
||||||
bool IsDefaultSizingPolicy; // Set if user didn't explicitly set a sizing policy in BeginTable()
|
bool IsDefaultSizingPolicy; // Set if user didn't explicitly set a sizing policy in BeginTable()
|
||||||
bool IsActiveIdAliveBeforeTable;
|
bool IsActiveIdAliveBeforeTable;
|
||||||
|
|||||||
@ -704,7 +704,7 @@ void ImGui::TableBeginApplyRequests(ImGuiTable* table)
|
|||||||
// table->ReorderColumn = -1;
|
// table->ReorderColumn = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle display order reset request
|
// Handle display order / visibility reset requests
|
||||||
if (table->IsResetDisplayOrderRequest)
|
if (table->IsResetDisplayOrderRequest)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < table->ColumnsCount; n++)
|
for (int n = 0; n < table->ColumnsCount; n++)
|
||||||
@ -712,6 +712,13 @@ void ImGui::TableBeginApplyRequests(ImGuiTable* table)
|
|||||||
table->IsResetDisplayOrderRequest = false;
|
table->IsResetDisplayOrderRequest = false;
|
||||||
table->IsSettingsDirty = true;
|
table->IsSettingsDirty = true;
|
||||||
}
|
}
|
||||||
|
if (table->IsResetVisibilityRequest)
|
||||||
|
{
|
||||||
|
for (ImGuiTableColumn& column : table->Columns)
|
||||||
|
column.IsUserEnabled = column.IsUserEnabledNextFrame = (column.Flags & ImGuiTableColumnFlags_DefaultHide) ? 0 : 1;
|
||||||
|
table->IsResetVisibilityRequest = false;
|
||||||
|
table->IsSettingsDirty = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply immediately. See TableQueueSetColumnDisplayOrder() for additional checks/constraints.
|
// Apply immediately. See TableQueueSetColumnDisplayOrder() for additional checks/constraints.
|
||||||
@ -853,7 +860,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
table->RefScale = new_ref_scale_unit;
|
table->RefScale = new_ref_scale_unit;
|
||||||
|
|
||||||
const ImGuiTableFlags table_sizing_policy = (table->Flags & ImGuiTableFlags_SizingMask_);
|
const ImGuiTableFlags table_sizing_policy = (table->Flags & ImGuiTableFlags_SizingMask_);
|
||||||
table->IsDefaultDisplayOrder = true;
|
table->IsDefaultDisplayOrder = table->IsDefaultVisibility = true;
|
||||||
table->ColumnsEnabledCount = 0;
|
table->ColumnsEnabledCount = 0;
|
||||||
ImBitArrayClearAllBits(table->EnabledMaskByIndex, columns_count);
|
ImBitArrayClearAllBits(table->EnabledMaskByIndex, columns_count);
|
||||||
ImBitArrayClearAllBits(table->EnabledMaskByDisplayOrder, columns_count);
|
ImBitArrayClearAllBits(table->EnabledMaskByDisplayOrder, columns_count);
|
||||||
@ -872,8 +879,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
for (int order_n = 0; order_n < columns_count; order_n++)
|
for (int order_n = 0; order_n < columns_count; order_n++)
|
||||||
{
|
{
|
||||||
const int column_n = table->DisplayOrderToIndex[order_n];
|
const int column_n = table->DisplayOrderToIndex[order_n];
|
||||||
if (column_n != order_n)
|
|
||||||
table->IsDefaultDisplayOrder = false;
|
|
||||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||||
|
|
||||||
// Clear column setup if not submitted by user. Currently we make it mandatory to call TableSetupColumn() every frame.
|
// Clear column setup if not submitted by user. Currently we make it mandatory to call TableSetupColumn() every frame.
|
||||||
@ -897,6 +902,11 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
}
|
}
|
||||||
column->IsEnabled = column->IsUserEnabled && (column->Flags & ImGuiTableColumnFlags_Disabled) == 0;
|
column->IsEnabled = column->IsUserEnabled && (column->Flags & ImGuiTableColumnFlags_Disabled) == 0;
|
||||||
|
|
||||||
|
if (column->IsEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) ? 0 : 1))
|
||||||
|
table->IsDefaultVisibility = false;
|
||||||
|
if (column_n != order_n)
|
||||||
|
table->IsDefaultDisplayOrder = false;
|
||||||
|
|
||||||
if (column->SortOrder != -1 && !column->IsEnabled)
|
if (column->SortOrder != -1 && !column->IsEnabled)
|
||||||
table->IsSortSpecsDirty = true;
|
table->IsSortSpecsDirty = true;
|
||||||
if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti))
|
if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti))
|
||||||
@ -3598,17 +3608,20 @@ void ImGui::TableDrawDefaultContextMenu(ImGuiTable* table, ImGuiTableFlags flags
|
|||||||
want_separator = true;
|
want_separator = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ordering
|
// Reset Order/Visibility etc.
|
||||||
if (flags_for_section_to_display & ImGuiTableFlags_Reorderable)
|
if (flags_for_section_to_display & (ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable))
|
||||||
{
|
if (BeginMenu(LocalizeGetMsg(ImGuiLocKey_TableReset)))
|
||||||
if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetOrder), NULL, false, !table->IsDefaultDisplayOrder))
|
{
|
||||||
table->IsResetDisplayOrderRequest = true;
|
//if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetAll))) // FIXME: Hiding because altering Sort Order + requesting auto-fit simultaneously has a tendency to exhibit a sizing glitch.
|
||||||
want_separator = true;
|
// table->IsResetAllRequest = true;
|
||||||
}
|
if (flags_for_section_to_display & ImGuiTableFlags_Reorderable)
|
||||||
|
if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetOrder), NULL, false, !table->IsDefaultDisplayOrder)) // PS: cannot be hidden because it would mess with drag reordering.
|
||||||
// Reset all (should work but seems unnecessary/noisy to expose?)
|
table->IsResetDisplayOrderRequest = true;
|
||||||
//if (MenuItem("Reset all"))
|
if (flags_for_section_to_display & ImGuiTableFlags_Hideable)
|
||||||
// table->IsResetAllRequest = true;
|
if (MenuItem(LocalizeGetMsg(ImGuiLocKey_TableResetVisibility), NULL, false, !table->IsDefaultVisibility))
|
||||||
|
table->IsResetVisibilityRequest = true;
|
||||||
|
EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
// Sorting
|
// Sorting
|
||||||
// (modify TableOpenContextMenu() to add _Sortable flag if enabling this)
|
// (modify TableOpenContextMenu() to add _Sortable flag if enabling this)
|
||||||
|
|||||||
@ -9638,7 +9638,7 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut
|
|||||||
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.)
|
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.)
|
||||||
float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f;
|
float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f;
|
||||||
float shortcut_w = (shortcut && shortcut[0]) ? CalcTextSize(shortcut, NULL).x : 0.0f;
|
float shortcut_w = (shortcut && shortcut[0]) ? CalcTextSize(shortcut, NULL).x : 0.0f;
|
||||||
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f);
|
float checkmark_w = IM_TRUNC(g.FontSize * 1.20f); // FIXME: Always accounted for, even in a menu with none, because 'selected' has no neutral setting.
|
||||||
float min_w = offsets->DeclColumns(icon_w, label_size.x, shortcut_w, checkmark_w); // Feedback for next frame
|
float min_w = offsets->DeclColumns(icon_w, label_size.x, shortcut_w, checkmark_w); // Feedback for next frame
|
||||||
float stretch_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
float stretch_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
||||||
ImVec2 text_pos(pos.x, pos.y + window->DC.CurrLineTextBaseOffset);
|
ImVec2 text_pos(pos.x, pos.y + window->DC.CurrLineTextBaseOffset);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user