Dear ImGui new Table API


GeeXLab - Dear ImGui table

 
GeeXLab 0.40.0 comes with Dear ImGui 1.80 and one of the new feature is the new table API to build tables. If your code uses the column functions (gh_imgui.column_xxxxx()) to build tables, don’t panic, the column API is still there.

All functions of the new table API are available in the gh_imgui lib:

gh_imgui.table_begin()
gh_imgui.table_end()
gh_imgui.table_next_row()
gh_imgui.table_next_column()
gh_imgui.table_set_column_index()
gh_imgui.table_setup_column()
gh_imgui.table_setup_scroll_freeze()
gh_imgui.table_headers_row()
gh_imgui.table_header()
gh_imgui.table_get_column_count()
gh_imgui.table_get_column_index()
gh_imgui.table_get_row_index()
gh_imgui.table_get_column_name()
gh_imgui.table_get_column_flags()
gh_imgui.table_set_bg_color()

A demo showing the table API in action is available in the OpenGL 2.1 demopack in the
d29-imgui/imgui-table/ folder.

Here is a code snippet that shows how to draw the table you can see on the post header screenshot:

local flags = ImGuiTableFlags_Resizable + ImGuiTableFlags_Borders
if (gh_imgui.table_begin("Table1", 2, flags, 0,0, 0) == 1) then
    gh_imgui.table_setup_column("Feature")
    gh_imgui.table_setup_column("Value")
    gh_imgui.table_headers_row()

    gh_imgui.table_next_column()
    gh_imgui.text("Model")
    gh_imgui.table_next_column()
    gh_imgui.text("Radeon RX 6800 XT")

    gh_imgui.table_next_column()
    gh_imgui.text("GPU")
    gh_imgui.table_next_column()
    gh_imgui.text("Navi 21")

    gh_imgui.table_next_column()
    gh_imgui.text("Arch")
    gh_imgui.table_next_column()
    gh_imgui.text("RDNA 2")

    gh_imgui.table_next_row()

    gh_imgui.table_next_column()
    gh_imgui.text("Shader cores")
    gh_imgui.table_next_column()
    gh_imgui.text("4608")

    gh_imgui.table_next_row()

    gh_imgui.table_next_column()
    gh_imgui.text("Compute units")
    gh_imgui.table_next_column()
    gh_imgui.text("72")

    gh_imgui.table_next_column()
    gh_imgui.text("TMUs")
    gh_imgui.table_next_column()
    gh_imgui.text("288")

    gh_imgui.table_next_column()
    gh_imgui.text("ROPs")
    gh_imgui.table_next_column()
    gh_imgui.text("64")

    gh_imgui.table_next_column()
    gh_imgui.text("Ray acceleration units")
    gh_imgui.table_next_column()
    gh_imgui.text("72")

    gh_imgui.table_next_column()
    gh_imgui.text("Power draw")
    gh_imgui.table_next_column()
    gh_imgui.text("300W")

    gh_imgui.table_next_row()

    gh_imgui.table_next_column()
    gh_imgui.text("GeeXLab")
    gh_imgui.table_next_column()
    gh_imgui.url("homepage", "https://geeks3d.com/geexlab/", "URL: https://geeks3d.com/geexlab/")

    gh_imgui.table_end()
  end

Constants like ImGuiTableFlags_Resizable are defined in the imgui.lua file available in GeeXLab/libs/lua/ folder.

If you want to see all possibilities of the table API, just look at the built-in ImGui demo (available in the d29-imgui/imgui-01/ folder of the OpenGL 2.1 demopack):

GeeXLab - Dear ImGui table

To be honest, I haven’t tested all new functions. I think I added all necessary functions to code tables like in ImGui official demo, but I may have forgotten something…





Leave a Comment

Your email address will not be published. Required fields are marked *