ImGui.NET icon indicating copy to clipboard operation
ImGui.NET copied to clipboard

How to use ImGuiListClipper ?

Open guillaC opened this issue 1 year ago • 1 comments

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.

guillaC avatar Aug 31 '24 22:08 guillaC