mirror of
https://github.com/ocornut/imgui.git
synced 2026-10-16 22:40:48 +00:00
Tables: column order scrambled on topology change in non-reorderable tables #9570
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#9570
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version/Branch of Dear ImGui:
1.93.0 WIP, Branch: master
ed73ef4e8and docking64944b452Back-ends:
imgui_impl_sdl2.cpp + imgui_impl_metal.mm (backend independent)
Compiler, OS:
macOS, Clang
Full config/build information:
No response
Details:
My Issue/Question:
Follow-up to #9108 (and distinct from #9519): in a table without
ImGuiTableFlags_Reorderable, the column order gets scrambled when columns are added. This happens on a live topology change and also on restart with .ini settings.Results for columns
Month, C, D->Month, A, B, C, D(insert) andMonth, A, B, C->Month, A, B, C, AB, AD(append), on mastered73ef4e8and docking64944b452:Month A C B DMonth A B C DMonth A B C AB ADC D Month A BMonth A B C DMonth A C B DMonth A B C DAB AD Month A B CMonth A B C AB ADMonth A B C AB AD"Never resized" means the table is saved as a bare
[Table][0x...,N]entry with noColumnlines (it records itself in default state, #7934). That is the common case for us.Cause, as far as I can tell:
TableReconcileColumns()copies the old column data, including the oldDisplayOrder(= old index), to the matched columns.TableLoadSettingsForColumn()setscolumn->DisplayOrder = column_settings->Index(the saved index) when the settings have no Reorderable data. New columns getDisplayOrder= their new index fromTableInitColumnDefaults(), so old and new values clash.ID = 0,Index = -1) are matched sequentially onto the first N columns. Those columns then getDisplayOrder = -1and sort to the end, so every column beyond the old count displays first.TableFixDisplayOrder()then sorts by these values.Since a non-reorderable table always shows columns in index order, the fix I'm using locally is to apply that directly in
TableFixDisplayOrder(), which both the load and the reconcile paths go through:Widths and other per-column data are still matched by ID. With the patch, all six scenarios display the expected order (tested headless against master and docking).
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code: