imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Docking / Dock Panel Layout

Open Flix01 opened this issue 11 years ago • 96 comments

[ADMIN] EDIT: There is now an official docking branch. See #2109 for details.

I'd like to see if somebody is interested in a Mini Dock Panel Layout: I implemented a very basic one a few months ago (I still have to port my code to the new version of ImGui).

This is an old screenshot of what it looked: imgui mini dockpanel test

Basically it just supports one docked window per side, with a "hover" window (when the mouse hovers the buttons that are not active), with no animation and no drag and drop at all, and no re-arrangeable buttons and windows.

This is very limited compared to a "full featured" dock panel implementation but it's better than nothing and is OK for my needs (although it's currently just a proof of the concept not tested for real usage).

Flix01 avatar Sep 26 '15 15:09 Flix01

I start to create mine too, but it's more like an small window framework who used ImGui than an extensions for ImGui. And thanks Omar for created an easy and powerful gui lib ;) Screenshot1

thennequin avatar Sep 26 '15 23:09 thennequin

@thennequin that looks awesome! ;)

extrawurst avatar Sep 27 '15 02:09 extrawurst

@thennequin thats really great .

codz01 avatar Sep 27 '15 09:09 codz01

Hands down: @thennequn that's much better than mine!

Flix01 avatar Sep 27 '15 11:09 Flix01

@thennequin this is great stuff!

Pagghiu avatar Sep 27 '15 12:09 Pagghiu

Really cool. Thibault's code is here: https://github.com/thennequin/ImWindow

ocornut avatar Sep 27 '15 16:09 ocornut

@thennequin I'd be curious to hear about what you've learned / think about the current architecture you've developed. It looks interesting and I'd eventually want to incorporate some form of docking into ImGui. Do you think some aspect of it could be adapted to be included in the core library? How could ImGui evolve to support that sort of extension more naturally?

ocornut avatar Sep 27 '15 16:09 ocornut

Thanks everybody.

@ocornut I wanted to make one simple way to create windows for easily create editors for the company where I work. Actually, the scene editor of our engine (it's PlayAll, maybe you've heard about this at Darkworks :) ) is based on old technologies and it's slow and very hard to evolve, so we want to recreate it from scratch. We are searching for a good alternative for implementing new features easily but during our research we couldn't find a good and light alternative to our old version of wxWidgets used in our scene editor. Last year i learnt to use Unity and make custom tools, it was easy to make new windows just by instancing class who inherited from Editor class, it's just perfect for our needs. So my current architecture is probably based on the ImGui of Unity. At first i created a new widget for wxWidgets for use wxAUI (docking system of wxWidgets) but this attempt had many problems so i started to create this library from scratch and your samples. My goal is to use your library without modifications, so i won't search a way to include dock system directly in ImGui. I don't know where to start, but if you want to include dock system, i think you can look at the class ImwContainer.

thennequin avatar Sep 27 '15 21:09 thennequin

Just to say that I added my worse implementation (the first screenshot of this thread) here: https://github.com/Flix01/imgui, together with other (mostly outdated and non-functional) ImGui "addon widgets".

[Edit:] Live Demo Here (proof-of-the-concept test demo of my mini imgui panel manager, with a custom font).

I also made a wiki page of my addon branch here: Addons Wiki .

Flix01 avatar Oct 03 '15 13:10 Flix01

@Flix01 Thanks! always useful to have more example/reference code available.

@thennequin Branimir has reworked your code here (haven't looked at it in details yet myself) imgui_wm.cpp / .h in this folder: https://github.com/bkaradzic/bgfx/tree/master/3rdparty/ocornut-imgui

  • Made it single compile unit .h/.cpp file.
  • Fixed internals to use ImGui utility functions and macros instead of custom ones
  • Made input and window handling use data passed to ImGui::IO structure.

I heard of PlayAll (it is a french middleware partly developed by Darkworks) but never seen it. Did we met at Darkworks? I only spent sometimes like 9 weeks there in the summer of 2008, so I don't recall everyone :)

I don't know when I'll be able to tackle docking but it's very good to have those different attempts working.

ocornut avatar Oct 05 '15 13:10 ocornut

@ocornut Indeed, he reduced my lib into a pair of files. That's pretty cool, but i will still continue to use my multi files structure for a possible growth.

I worked at Darkworks at that time but we couldn't meet each other because there were over a hundred people at the company, it's impossible to get to know everyone.

Branimir use only one RenderWindow. So when he docked a WIndow ouside of his RenderWindow, he lost it because he didn't recreate a new RenderWindow, It can be a future feature for my lib to restrict the number of RenderWindow.

thennequin avatar Oct 07 '15 23:10 thennequin

Just to say that I'm doing something like @thennequin (I'm on Linux, I cannot use his code!) using imgui only.

It's still W.I.P. and I don't know if it will work across different imgui windows. [Edit:] it works, see updated gif.

However here is a preliminary animated .gif: tabwindow

P.S. Some buttons shaped like tab labels would be useful...

Happy new year to all imgui users (and to the developer) !

Flix01 avatar Dec 31 '15 16:12 Flix01

It seems pretty cool :)

thennequin avatar Jan 01 '16 15:01 thennequin

@thennequin : thanks.

However my preliminary tests show that I cannot make "tab buttons" fly from an ImGui::Window to another... :(.

Never mind... I was thinking of using this kind of layout only in the "central window" (e.g. "document window") of my "Mini Dock Panel Layout".

[EDIT] flying tabs work now.

Flix01 avatar Jan 01 '16 20:01 Flix01

Also see LumixEngine code by @nem0 https://github.com/nem0/lumixengine

dock

IMGUI_API bool BeginDock(const char* label, bool* opened = nullptr);
IMGUI_API void EndDock();

https://github.com/nem0/LumixEngine/blob/master/src/studio_lib/imgui/imgui_user.inl

Looks like a fairly small amount of code and it could be ported/redesigned to work in ImGui code perhaps.

EDIT I'd suggest experimenting with the idea of making this an extension e.g ImGuiDock.cpp

ocornut avatar Jan 02 '16 10:01 ocornut

Yes, lumixengine's dock seems better than mine, for a lot of reasons:

  • tab buttons are shaped like tab labels.
  • tab buttons can become imgui floating Windows.
  • code looks very compact.
  • it seems to be a "pure imgui" solution (mine too, but @thennequin's depends on the Windows OS AFAICS).
  • As far as I can see, it has load/save support.

So I guess it's better to use @mem0's code as a reference for a future ImGuiDock system.

Flix01 avatar Jan 02 '16 12:01 Flix01

Also the way I did my docking system was to have it fully outside of the ImGui code and just doing SetWindowNextPos/Size. In my cases it makes it much easier as I have no divergences with the core ImGui code which is preferable imo.

emoon avatar Jan 02 '16 12:01 emoon

@Flix01

it seems to be a "pure imgui" solution (mine too, but @thennequin's depends on the Windows OS AFAICS).

I plan to support os windows too and keep the "pure imgui" interface too, using concept similar to io::RenderDrawListsFn

As far as I can see, it has load/save support.

It uses my own structures for saving and Lua for loading, but it should not take more than 10 minutes to rewrite it. However I do not know about any way/interface to connect to imgui's save/load at the moment and I would prefer pure imgui save/load.

code looks very compact

it's still far from finished, has some known bugs and missing features

nem0 avatar Jan 02 '16 13:01 nem0

Looks great but you can't drag outside the confines of the window it seems. @thennequin's can.

On Sat, 2 Jan 2016 at 08:13 Mikulas Florek [email protected] wrote:

@Flix01 https://github.com/Flix01

it seems to be a "pure imgui" solution (mine too, but @thennequin https://github.com/thennequin's depends on the Windows OS AFAICS). I plan to support os windows too and keep the "pure imgui" interface too, using concept similar to io::RenderDrawListsFn

As far as I can see, it has load/save support. It uses my own structures for saving and Lua for loading, but it should not take more than 10 minutes to rewrite it. However I do not know about any way/interface to connect to imgui's save/load at the moment and I would prefer pure imgui save/load.

— Reply to this email directly or view it on GitHub https://github.com/ocornut/imgui/issues/351#issuecomment-168389868.

Cthutu avatar Jan 02 '16 18:01 Cthutu

Looks great but you can't drag outside the confines of the window it seems. @thennequin's can.

I don't know, I've never tried. However I've managed to do it with my code (see the updated animated .gif above).

Still, lumixengine's solution is much better than mine. I guess I'll stop developing mine, maybe making a gist and/or adding it to my imgui branch.

For now this is what I got (and what I need).

If I'll find time in the future (or I'll need something more complete), I know where to look at (= lumixengine's dock system).

[EDIT] Added gist: https://gist.github.com/Flix01/2cdf1db8d936100628c0 [EDIT] Added to my imgui branch and to the central window of the Live Demo Here : press the last button on the top to show it (and it should be straight-forward to turn one of the "lateral windows" into an ImGui::TabWindow, so that it can exchange content with the central window). [EDIT] Added some changes in the tab label look and serialization, but only in my branch here ATM: https://github.com/Flix01/imgui/wiki/ImGui-Addons-Branch-Home.

Flix01 avatar Jan 03 '16 13:01 Flix01