pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping

Home Page:https://pthom.github.io/hello_imgui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docking feature and persisted window layout

Guillaume227 opened this issue · comments

One thing with Docking is not super clear yet: what's the 'right' (as in idiomatic) way to load the layout from the *.ini file that persists user modifications to the layout, after closing and reopening the application?

Right now on startup I populate dockingParams.dockableWindows programmatically every time so it gets rid of whatever customization was made the previous time the app was run.

Also, would be nice to have a way to customize the name of the ini file (imgui.ini is not appropriate in the presence of several co-existing imgui-based apps).
I have done it before with:

ImGuiIO& io = ImGui::GetIO();
io.IniFilename = ...;

but maybe you want to expose that in the RunnerParams ?

One thing with Docking is not super clear yet: what's the 'right' (as in idiomatic) way to load the layout from the *.ini file that persists user modifications to the layout, after closing and reopening the application?

I need to work on this. This will take a couple of days

I'm on holidays this week. I'll try to,find a few minutes for this tonight.
I pushed a modif that enables to store the ini filename in params : c037e98

Concerning the persistence of user settings, it still needs some adaptations

a58f14c adds some settings to reload user settings for the docking layout.

Also see comments in the related commit of ImGui bundle:
pthom/imgui_bundle@d9c5595#diff-6b423f8761a5a9441f8502a922eb99740ce2ecf0b621a37977f09c452f931671

(the name of the ini file is derived from the window title by default)

Thanks, I tested the latest changes in my app and that's looking good.
I made a number of observations:

  • application window size is not restored (although it does appear in the ini file). I am not sure it's a problem on the hello_imgui side though.

  • in a given dock division, while the docked windows tab order is preserved, which docked windows is visible is not.
    Let's take an example : if I select the Config tab docked window below and close the app, when I next reopen it, Plot is still the one that shows up on top. I do see that the ini file is changed in that case so I am thinking we might be throwing away information?
    Note: In my code when I list the dockable windows, Plot is the last one, which could explain why it's always on top.

image

  • Also, if I close a window so it doesn't even appear in the tabs, it always gets restored on a restart. Example here when closing the Config window:
    image
    In that case the ini file does not appear to change though.
    However, the 'Restore Default Layout' View menu entry does not restore the close tab. Only the restart does, which feels the wrong way around.

Some partial answers.

application window size is not restored (although it does appear in the ini file). I am not sure it's a problem on the hello_imgui side though.

You can restore the application window size and position with HelloImGui specific params:

    runnerParams.appWindowParams.restorePreviousGeometry = true;

They will be stored in a separate ini file (e.g. imgui_appWindow.ini), and they are managed by HelloImgui since they deal with the native platform window.

  • in a given dock division, while the docked windows tab order is preserved, which docked windows is visible is not.

Handling this is very much on the imgui side. I'm not sure if this situation is handled at the time.

Also, if I close a window so it doesn't even appear in the tabs, it always gets restored on a restart. Example here when closing the Config window

This could be handled from HelloImGui. I will keep this in mind.

Important note: lots of adaptation were made to store and persist several different window layouts.

See demo video on youtube for more explanations: https://www.youtube.com/watch?v=XKxmz__F4ow