Skip to content

Table angled headers, sorting only works on first column #7937

@dcnieho

Description

@dcnieho

Version/Branch of Dear ImGui:

Version 1.90.9, Branch: docking

Back-ends:

imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

Windows 11, msvc 1940

Full config/build information:

NB: this is imgui_bundle 1.5.2
Dear ImGui 1.90.9 (19090)
--------------------------------

sizeof(size_t): 8, sizeof(ImDrawIdx): 4, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1940
define: _MSVC_LANG=201703
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------

io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000480
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMoveFromTitleBarOnly
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------

io.Fonts: 16 fonts, Flags: 0x00000000, TexSize: 2048,4096
io.DisplaySize: 3500.00,1750.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------

style.WindowPadding: 20.00,20.00
style.WindowBorderSize: 1.00
style.FramePadding: 10.00,7.00
style.FrameRounding: 7.00
style.FrameBorderSize: 1.00
style.ItemSpacing: 20.00,10.00
style.ItemInnerSpacing: 10.00,10.00

Details:

My Issue/Question:
See the below screenshot. I have a table with mixed normal and angled headers. First two normal headers, then a series of angled headers. I can sort the table on the normal header and the first angled header, but not the rest. Any click on those is just ignored. (sort specs does not become dirty). This is both when clicking on the angled header or the line below it (only the normal header row works for the first angled header column, but i understand that is expected).

Screenshots/Video:

image

Minimal, Complete and Verifiable Example code:

This is not an complete minimal example, nor in C++ (its Python using imgui_bundle), but shows the main relevant code

table_flags: int = (
    imgui.TableFlags_.scroll_x |
    imgui.TableFlags_.scroll_y |
    imgui.TableFlags_.hideable |
    imgui.TableFlags_.sortable |
    imgui.TableFlags_.resizable |
    imgui.TableFlags_.sort_multi |
    imgui.TableFlags_.reorderable |
    imgui.TableFlags_.sizing_fixed_fit |
    imgui.TableFlags_.no_host_extend_y |
    imgui.TableFlags_.no_borders_in_body_until_resize |
    imgui.TableFlags_.highlight_hovered_column
)

if imgui.begin_table(
    f"##session_list",
    columns=self._view_column_count,
    flags=self.table_flags,
):
    # Setup
    checkbox_width = frame_height-2*imgui.get_style().frame_padding.y
    imgui.table_setup_column("Selector", imgui.TableColumnFlags_.no_hide | imgui.TableColumnFlags_.no_sort | imgui.TableColumnFlags_.no_resize | imgui.TableColumnFlags_.no_reorder, init_width_or_weight=checkbox_width)  # 0
    imgui.table_setup_column("Name", imgui.TableColumnFlags_.default_sort | imgui.TableColumnFlags_.no_hide | imgui.TableColumnFlags_.no_resize)  # 1
    imgui.table_setup_column("Recordings", imgui.TableColumnFlags_.no_resize | imgui.TableColumnFlags_.angled_header)  # 2
    for k in ['Import', 'Code Episodes']:   # 3+, just put the first two here...
        imgui.table_setup_column(k, imgui.TableColumnFlags_.no_resize | imgui.TableColumnFlags_.angled_header)

imgui.table_setup_scroll_freeze(1, 2)  # Sticky column headers and selector row

imgui.table_angled_headers_row()
imgui.table_next_row(imgui.TableRowFlags_.headers)
for i in range(imgui.table_get_column_count()):
    if not imgui.table_set_column_index(i):
        continue
    column_name = '' if imgui.table_get_column_flags(i) & imgui.TableColumnFlags_.no_header_label else imgui.table_get_column_name(i)
    if i==0:  # checkbox column, skip all logic here as not relevant for this problem
        pass
    else:
        imgui.table_header(column_name)

# draw rows... logic skipped, not relevant

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions