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

Tables: Is there a way to freeze a specific column? #4206

Open
LunaTheFoxgirl opened this issue Jun 7, 2021 · 6 comments
Open

Tables: Is there a way to freeze a specific column? #4206

LunaTheFoxgirl opened this issue Jun 7, 2021 · 6 comments

Comments

@LunaTheFoxgirl
Copy link

Version/Branch of Dear ImGui:

Version: 1.82 WIP
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: cimgui + bindbc-imgui, imgui_impl_sdl.cpp & custom OpenGL backend
Operating System: Windows

My Issue/Question:

I'm working on an editor for a 2D puppet animation format, and for a node tree in this editor I want the user to be able to toggle each Node in the puppet, I've decided to use Tables for this.

I seem to be unable to freeze/lock a specific column (the one with the visibility switches)
Is there a way to set a specific column as frozen or if not, how feasible would it be to allow that?

Screenshots/Video
billede
Moving the scroll bar just scrolls the visibility icon

Standalone, minimal, complete and verifiable example: (see #2261)

igTableSetupColumn("Nodes", ImGuiTableColumnFlags_WidthFixed, 1000, 0);
igTableSetupColumn("Visibility", ImGuiTableColumnFlags_WidthFixed, 32, 1);
igTableSetupScrollFreeze(1, 0); // I want "Visibility" to be frozen
                
igTableNextColumn();
igTableHeader("Nodes");
igTableNextColumn();
igTableHeader("   ");

// Put stuff in to table here
@ocornut
Copy link
Owner

ocornut commented Jun 7, 2021

Hello,

It's not currently possible but the TableSetupScrollFreeze() api was designed to allow this eventually. So I'll leave this open until we support it (freezing from right side will likely come sooner than freezing from bottom).

Note that freezing generally goes hand to hand with using ImGuiTableColumnFlags_NoReorder on the column. (EDIT Clarification: we prevent manual reordering from crossing the frozen line, but I think saved .ini data or other api could still allow it.)

Interestingly, looking at your example I realize it would be nice to add a new column flag to hide the header label, so you could still benefit from using TableHeadersRow(). I'm going to add this.

ocornut added a commit that referenced this issue Jun 7, 2021
@ocornut
Copy link
Owner

ocornut commented Jun 7, 2021

Interestingly, looking at your example I realize it would be nice to add a new column flag to hide the header label, so you could still benefit from using TableHeadersRow(). I'm going to add this.

Now added ImGuiTableColumnFlags_NoHeaderLabel.
Note that column name can still appear in context menu, so you could call this column "Visibility" and even set _NoHide but it would show in the list (and debugging tools) and you can use TableHeaderRows() instead of submitting the headers manually.

@LunaTheFoxgirl
Copy link
Author

Even better would be the ability to freeze arbitrary columns, granted this would probably be a lot more difficult to implement, but could allow for some interesting use of tables.

Potentially have a flag specifically for freezing an entire column outside of TableSetupScrollFreeze?

@ocornut
Copy link
Owner

ocornut commented Jun 7, 2021

The merging of draw calls relies on contiguous frozen blocks, and non-contiguous unfrozen section would requires multiple scrollbars and will probably make several other things more complex. I guess it is unlikely we allow arbitrary non-contiguous columns to be frozen this way.

I'm looking at potentially freezing from the right and already that opens up a few new problems in terms of sizing constraints (right + left frozen columns can't overlap and must leave space for scrolling section, can't push each others etc.).

@ocornut
Copy link
Owner

ocornut commented Jun 7, 2021

I spent an hour trying to do this and identifying the changes that would be required.
There are about a dozen changes here and there that are doable. The main non-trivial things are:

  • TableUpdateLayout()'s "Setup final position, offset, skip/clip states and clipping rectangles" section needs to reworked to allow out of order layout of column. That will eventually simplify a few things but it means the TableGetMaxColumnWidth() stuff will need to be expressed differently.
  • TableMergeDrawChannels() needs to reworked. I'll wait until we merge the work to include AABB in ImDrawCmd at it will simplify some of rework needed, and while we are at it we can make it more generic.

I reckon it'll probably take a solid full day to do those safely and sanely but it should also improve the code quality of those two sections so it is quite desirable. Realistically this is not going to happen very soon but I'll get to it eventually.

@LunaTheFoxgirl
Copy link
Author

Sounds good to me, do poke me when/if it happens.

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

No branches or pull requests

2 participants