Adanos020 / egui_dock

Docking support for egui – an immediate-mode GUI library for Rust
MIT License
458 stars 75 forks source link

Enable Nested DockAreas #240

Closed jarruda closed 5 months ago

jarruda commented 6 months ago

Is your feature request related to a problem? Please describe. I want to build a UI where top-level tabs contains their own DockArea whose tabs are exclusive to it. For example: top level tabs represent a file editor, which has tabs for searching, statistics, etc. The inner tabs should not be moveable to other top-level tabs.

Describe the solution you'd like Allow DockAreas to be nested, and make the tabs in them only able to be dragged within that DockArea.

Describe alternatives you've considered n/a

Adanos020 commented 5 months ago

Hi, this is already supported. All you need to do is call DockArea::show_inside in your tab's ui function, and also set a unique ID for that DockArea via the id method. Let me know if that helps.

jarruda commented 5 months ago

Thanks, that worked perfectly. I might have missed this in the examples or in the docs, but a small note or example would be helpful to add.

When looking through the docs initially, this line implied to me that only one DockArea could be used, and combined with trying it without using .id resulting in a debug ID conflict, led me to assume it wasn't possible:

There can only be one Main surface. It’s the one surface that is rendered inside the Ui you’ve passed to DockArea::show_inside, or inside the egui::CentralPanel created by DockArea::show.

As an aside, I wonder if it isn't possible to make nested DockAreas "just work" without needing to manually specify an Id?

Adanos020 commented 5 months ago

I wonder if it isn't possible to make nested DockAreas "just work" without needing to manually specify an Id?

Yeah, I guess we could base it on the ID of the Ui. Shouldn't be too difficult!