Skip to content

Synced tables with a scrollbar have different column's width #5920

Closed
@the-goodies

Description

Two synced tables with a ImGuiTableFlags_SizingStretchSame and ImGuiTableFlags_ScrollY flags set, have different columns widths if the first table has a vertical scrollbar:

synced_tables_different_widths.mp4

Maybe this is a correct behavior and not a bug, but if I want to align those columns contents, I have to add additional spaces or do some extra layout calculations to position them correctly.
Ideally, in this particular use case there would be a way to freeze the bottom row, so it wouldn't be necessary to create those synced tables.

Code example in Go language:

columnsNum := 6
columnsSetup := func() {
	ui.TableSetupColumn("First")
	ui.TableSetupColumn("Second")
	ui.TableSetupColumn("Third")
	ui.TableSetupColumn("Fourth")
	ui.TableSetupColumn("Fifth")
	ui.TableSetupColumn("And so on")
}

tableID := "##syncedTable"
tableFlags := ui.TableFlagsSizingStretchSame | ui.TableFlagsScrollY | ui.TableFlagsBorders

if ui.BeginTableV(tableID, columnsNum, tableFlags, ui.Vec2{Y: -30}, 0) {
	columnsSetup()
	ui.TableSetupScrollFreeze(0, 1)

	ui.TableHeadersRow()
	for i := 0; i < 60; i += 1 {
		ui.TableNextRow()
		for j := 1; j <= columnsNum; j += 1 {
			ui.TableNextColumn()
			ui.Text(fmt.Sprintf("%d. %d", j, i))
		}
	}

	ui.EndTable()
}

// sum row
if ui.BeginTableV(tableID, columnsNum, tableFlags, ui.Vec2{}, 0) {
	columnsSetup()

	ui.TableNextRow()
	for j := 1; j <= columnsNum; j += 1 {
		ui.TableNextColumn()
		ui.Text(fmt.Sprintf("%d. %d", j, 252352))
	}

	ui.EndTable()
}

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions