cogentcore / core

A free and open source framework for building powerful, fast, and elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the Web with a single pure Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.31k stars 71 forks source link

Add dock widget support #993

Open kkoreilly opened 4 days ago

kkoreilly commented 4 days ago

Describe the feature

This would be somewhat similar to the already existing splits, except instead of having a gradient handle for how much space each component should get, there would be discrete buttons that toggle each component between being displayed or not.

In fact, it may make sense to add dock functionality as an option on splits, since you may want to use both at the same time; they are not mutually exclusive. I put an example of how this could look below, although we would probably need more than just a bool option, depending on where you want to place the dock and how many different modalities you want it to have; in #742, one of the example dock widgets appears to support going between hidden, small, and full size.

I can probably work on this soon, although it would be helpful to have some more feedback about dock positioning and modalities for intended use cases.

Relevant code

sp := core.NewSplits(parent).SetDock(true)
core.NewText(sp).SetText("First")
core.NewText(sp).SetText("Second")
runrc commented 4 days ago

The Rust based GUI framework Egui dock has docking type functionality.

It would be useful to have the ability to,

The following shows examples. demo

rcoreilly commented 3 days ago

The Drag-n-drop support in Cogent Code would probably need some improvements to support this egui-dock kind of functionality, including #33 for going across different windows and apps. #84 is also related. Our current event handling happens mostly on a per-Scene level, via the Events type, so coordinating across different Scenes (windows) would potentially require some additional global event coordination infrastructure.

In general, everything is a widget and widgets can be put anywhere, so there aren't any other obvious in-principle barriers to implementing such a thing in terms of the contents of the panels.

Overall, there are a number of issues with this kind of functionality that personally limit my interest in pursuing such a thing, but nevertheless, it would be good to ensure that the framework can support it if someone wants to implement it:

rcoreilly commented 3 days ago

Also all the little widget "handles" (e.g., tabs) for each panel need to live somewhere, so you need to build in spaces for these to live -- these seem like important app-specific design decisions in general. In VSCode and Adobe products, these handles proliferate everywhere and are generally rather obscure and hard to identify, and they definitely need bits of space in various places.. lots of complexity to this it seems.

runrc commented 3 days ago

I agree with the premise that these types of complex configurable layouts are more suited to large screen desktop type applications, rather than single, smaller screen mobile type devices.

Additionally, I also agree a more simplistic approach is better across multiple platforms. Even simplistic functionality would still be extremely useful in allowing users to organise multiple complex views.

kkoreilly commented 3 days ago

I agree with @rcoreilly about the general idea that excessively complicated GUI layouts are not good, and should be avoided if possible. However, I also recognize that sometimes more sophisticated functionality may be necessary.

I am certainly in favor of the changes proposed in #996, and I hope that those will fulfill most of your needs. If you have specific situations in which you need more functionality than #996 provides, please tell us about them and we will work with you on figuring out a way to structure them well. It is possible that may reveal a need for more advanced dock-like functionality. I don't want to implement things that aren't necessary, but I am absolutely happy implementing complex things if they are necessary for real use cases.