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

How to use ImGuiListClipper ? #493

Open
guillaC opened this issue Aug 31, 2024 · 0 comments
Open

How to use ImGuiListClipper ? #493

guillaC opened this issue Aug 31, 2024 · 0 comments

Comments

@guillaC
Copy link

guillaC commented Aug 31, 2024

Hello,

I want to display a table containing HEX data in a UI, with a large amount of data.
That's why I need to use the ImGuiListClipper object.

Unfortunately, this object does not contain the Begin, Step, and End methods.

        public static void ShowHex(byte[] data)
        {
            ImGui.BeginTable("Hex", 16, ImGuiTableFlags.Resizable | ImGuiTableFlags.NoSavedSettings | ImGuiTableFlags.Borders, new Vector2(500, 0));

            for (int i = 0; i <= 0xF; i++)
            {
                ImGui.TableSetupColumn(" " + i.ToString("X"), ImGuiTableColumnFlags.NoResize);
            }

            ImGui.TableHeadersRow();

            int valuesPerRow = 16;

            for (int i = 0; i < data.Length; i += valuesPerRow)
            {
                ImGui.TableNextRow();
                for (int j = 0; j < valuesPerRow; j++)
                {
                    ImGui.TableNextColumn();
                    int index = i + j;
                    if (index < data.Length)
                    {
                        var oct = data[index].ToString("X2");
                        ImGui.TextColored(oct == "00" ? (Vector4)Color.Gray : (Vector4)Color.WhiteSmoke, oct);
                    }
                    else
                    {
                        ImGui.Text("");
                    }
                }
            }

            ImGui.EndTable();
        }

Is there perhaps another way to optimize the display of my table ?

Regards.

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

No branches or pull requests

1 participant