Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table: unable to display table with more than 64 columns #251

Closed
gucio321 opened this issue Aug 9, 2021 · 14 comments · Fixed by #628
Closed

table: unable to display table with more than 64 columns #251

gucio321 opened this issue Aug 9, 2021 · 14 comments · Fixed by #628
Labels
enhancement New feature or request

Comments

@gucio321
Copy link
Collaborator

gucio321 commented Aug 9, 2021

Hi there,
in refer to OpenDiablo2/HellSpawner#335 (comment) I'd like to show the situation, we can notice the behavior:
when I create a large table, e.g.:

        rowItems := make([]giu.Widget, numCols)
        for i := range rowItems {
                rowItems[i] = giu.Label(strconv.Itoa(i))
        }
        row := giu.TableRow(rowItems...)
full code
package main

import (
	"strconv"

	"github.com/AllenDang/giu"
)

func loop() {
	const numCols = 65

	rowItems := make([]giu.Widget, numCols)
	for i := range rowItems {
		rowItems[i] = giu.Label(strconv.Itoa(i))
	}
	row := giu.TableRow(rowItems...)

	giu.SingleWindow().Layout(
		giu.Table().Rows(row),
	)
}

func main() {
	wnd := giu.NewMasterWindow("table", 640, 480, 0)
	wnd.Run(loop)
}

i'm getting the following panic:

table: imgui_tables.cpp:323: bool ImGui::BeginTableEx(const char*, ImGuiID, int, ImGuiTableFlags, const ImVec2&, float): Assertion `columns_count > 0 && columns_count <= 64 && "Only 1..64 columns allowed!"' failed.
SIGABRT: abort
PC=0x7f7e2133d9e5 m=0 sigcode=18446744073709551610
signal arrived during cgo execution
@r00tc0d3
Copy link

r00tc0d3 commented Aug 9, 2021

This is due to a limitation of imgui not of giu.

From imgui_tables.cpp

// Sanity checks
IM_ASSERT(columns_count > 0 && columns_count <= IMGUI_TABLE_MAX_COLUMNS && "Only 1..64 columns allowed!");

So imgui asserts and you get a SIGABRT: abort

@gucio321
Copy link
Collaborator Author

you're right. I see an issue in imgui repo: ocornut/imgui#3572
maybe the suggested workaround, would work?

@gucio321
Copy link
Collaborator Author

from https://github.com/ocornut/imgui imgui_demog.cpp:

        if (ImGui::BeginTable("table_scrolly", 3, flags, outer_size))
        {
            ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible
            ImGui::TableSetupColumn("One", ImGuiTableColumnFlags_None);
            ImGui::TableSetupColumn("Two", ImGuiTableColumnFlags_None);
            ImGui::TableSetupColumn("Three", ImGuiTableColumnFlags_None);
            ImGui::TableHeadersRow();

            // Demonstrate using clipper for large vertical lists
            ImGuiListClipper clipper;
            clipper.Begin(1000);
            while (clipper.Step())
            {
                for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++)
                {
                    ImGui::TableNextRow();
                    for (int column = 0; column < 3; column++)
                    {
                        ImGui::TableSetColumnIndex(column);
                        ImGui::Text("Hello %d,%d", column, row);
                    }
                }
            }
            ImGui::EndTable();

@gucio321
Copy link
Collaborator Author

ImGuiListClipper work on the vertical axis which is were the count can grow the most.
Both TableSetColumnIndex() and TableNextColumn() return a bool reporting the column visibility so you can skip rendering your contents.

@gucio321
Copy link
Collaborator Author

gucio321 commented Sep 5, 2021

as an alternative, we can update the internal imgui tables mechanism like suggested in ocornut/imgui#3572 (comment)

so, to sum up:
there are 2 possible workarounds

  1. externally affect imgui table to display only the visible rows and bypass 64 columns limit
  2. modify the tables mechanism to remove columns limit

@AllenDang should we focus on working around this issue or just wait until the upstream issue gets solved?

@AllenDang
Copy link
Owner

@gucio321 IMO, let's wait upstream issue gets solved. I've been suffered much to apply custom patches, for now the power-saving patch. I have to do line-by-line diff and merge each time upgrading imgui.

@gucio321
Copy link
Collaborator Author

@AllenDang upstream issue is solved now
IMO, we should wait for cimgui-go migration with that anyway.

@gucio321
Copy link
Collaborator Author

gucio321 commented May 8, 2023

@AllenDang upstream issue has been closed. I think it may be fixed after cimgui migration

@AllenDang
Copy link
Owner

@gucio321 Yes, after migration this should be fixed.

@gucio321 gucio321 added the enhancement New feature or request label May 9, 2023
@gucio321 gucio321 linked a pull request May 9, 2023 that will close this issue
69 tasks
@fnicastri
Copy link

I still get the error with more than 64 columns, using @latest 0.7.0 and master is not compiling

@gucio321

@gucio321
Copy link
Collaborator Author

gucio321 commented Feb 3, 2024

This works on matter, if it doesn't compile it a separated issue

@fnicastri
Copy link

good to know!

can you point me at a working commit?

@gucio321
Copy link
Collaborator Author

gucio321 commented Feb 4, 2024

this issue was related to old imgui. master uses cimgui-go so relatively new imgui where 64 column tables works. THats why I said master works. (but may not compile, however it does for me)

@fnicastri
Copy link

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants