pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping
https://pthom.github.io/hello_imgui
MIT License
678 stars 103 forks source link

Docking feature and persisted window layout #39

Closed Guillaume227 closed 1 year ago

Guillaume227 commented 1 year ago

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 ?

pthom commented 1 year ago

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

pthom commented 1 year ago

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 : https://github.com/pthom/hello_imgui/commit/c037e98ed76bb1d2981f6cb0d21aecaefa4b413e

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

pthom commented 1 year ago

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

Also see comments in the related commit of ImGui bundle: https://github.com/pthom/imgui_bundle/commit/d9c55952f1df035abf0062ed4adfff08f6978985#diff-6b423f8761a5a9441f8502a922eb99740ce2ecf0b621a37977f09c452f931671

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

Guillaume227 commented 1 year ago

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

image

pthom commented 1 year ago

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.

pthom commented 1 year ago

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