Version/Branch of Dear ImGui:
1.93.0 WIP (19293) Docking
Back-ends:
imgui_impl_XXX.cpp + imgui_impl_XXX.cpp
Compiler, OS:
Mac OS, Clang
Full config/build information:
// (Copy from the next line. Keep the ``` markers for formatting.)
Dear ImGui 1.93.0 WIP (19293)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=202002
define: IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
define: IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
define: IMGUI_DISABLE_FILE_FUNCTIONS
define: IMGUI_DISABLE_DEFAULT_ALLOCATORS
define: __APPLE__
define: __GNUC__=4
define: __clang_version__=17.0.0 (clang-1700.6.3.2)
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
IM_ASSERT: runs expression: OK. expand size: OK
--------------------------------
io.BackendPlatformName: NULL
io.BackendRendererName: imgui_impl_TGCEngine
io.ConfigFlags: 0x00000081
NavEnableKeyboard
DockingEnable
io.ConfigViewportsNoDecoration
io.ConfigViewportsNoDefaultParent
io.ConfigMacOSXBehaviors
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMoveFromTitleBarOnly
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00000C18
PlatformHasViewports
RendererHasVtxOffset
RendererHasTextures
RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,256
io.Fonts->FontLoaderName: stb_truetype
io.DisplaySize: 2701.00,1548.00
io.DisplayFramebufferScale: 2.00,2.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 6.00,6.00
style.FrameRounding: 4.00
style.FrameBorderSize: 1.00
style.ItemSpacing: 6.00,6.00
style.ItemInnerSpacing: 4.00,4.00Details:
This used to work and broke recently. The order of the columns in a table aren't in the right order when restoring them. With no ini file, they appear correct. When I close the application and relaunch it without touching anything, they are in a different order. What I think is happening is that the column that is being sorted jumps to the first column in the table.
My situation is that the first column in the table is asset status, like perforce state information. The second column is the asset name. Third column is the asset comment. The name column is the one that is being sorted. When it restores information from the .ini file the name column is first.
To test this out I can set the status column as the active sort column and when I relaunch it's back to being first.
Screenshots/Video:
Minimal, Complete and Verifiable Example code:
// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();Activity
7This is likely related to the changes between june 8 and june 24 (#9108) but I would need more details, because settings saving/restore is generally exercised by our tests (even more so recently). Something may be interfering or causing the issue but I don't know what it is.
Can you confirm:
- the content of .ini file at the time of saving.
- parameters passed to BeginTable/TableSetupColumn.
- best is you try to setup a minimum repro to demonstrate the issue and doing so you will likely understand the cause of it and then we can better address it.
I have code for you that exhibits the issue: It seems that it's one of the sort flags on the table that's causing the issue:
if( ImGui::BeginTable( "###asset_table", 3,
ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable |
ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg |
ImGuiTableFlags_Sortable | ImGuiTableFlags_SortMulti,
ImVec2( -1.0f, ImGui::GetContentRegionAvail().y - ImGui::GetFrameHeight() ) ) )
{
ImGui::TableSetupColumn( "Status", ImGuiTableColumnFlags_WidthFixed, 60.0f );
ImGui::TableSetupColumn( "Name", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_DefaultSort, 400.0f );
ImGui::TableSetupColumn( "Comment", ImGuiTableColumnFlags_WidthFixed, 400.0f );
ImGui::TableSetupScrollFreeze( 0, 1 );
ImGui::TableHeadersRow();
for( const AssetId& assetId : m_filteredIds )
{
for( int32_t i = 0; i < 3; ++i )
{
if( ImGui::TableNextColumn() )
{
ImGui::TextUnformatted( "Test" );
}
}
}
ImGui::EndTable();
}Steps:
- Delete you ini file.
- Run the app.
- See that the table looks right.
- Close the app.
- Run the app again.
- Table columns are swapped
Thanks, I can confirm there's an issue with this setup. Currently in holidays but i'll try to work it out soonish.
In this precise setup only 1 column gets its data saved in the .ini file. We exit TableLoadSettingsForColumns() with columns display order of { -1, 1, -1 }, and TableFixDisplayOrder() is programmed to treat -1 as "move to end (preserve order)" because that's the desirable outcome of new columns being added during topology changes.
The simple workaround is to modify the end of TableSaveSettings():
++ if (table->Flags & ImGuiTableFlags_Sortable)
++ settings->SaveFlags |= ImGuiTableFlags_Sortable | ImGuiTableFlags_Reorderable;
settings->SaveFlags &= table->Flags;There should be a better fix, but I'm currently on a Mac laptop and my computer agility is divided by 16, so I am pushing the workaround as 1d7b37d and will investigate the better fix later.
I confirmed that the fix I pushed on Aug 19 is correct. There's no other things to do. I made a minor amend with cc072ca but should essentially be the same.
@wolfpld suggested using this alternative to my patch, will evaluate it imgui-phantom-column.patch
I also noticed that If I hide a column, restoring the table works as expected.