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

Splits improvements: double-click to collapse / expand; persistence api; history & context menu #996

Open rcoreilly opened 3 days ago

rcoreilly commented 3 days ago

Describe the feature

Relevant code

No response

rcoreilly commented 2 days ago

Here's a way to parameterize 2D layouts that seems sufficiently general: a list (slice) of integers specifying locations of panes in a window, up to n panes, with the number of columns additionally specified, such that the panes fully tile the 2D window space.

We can probably enumerate all the possibilities for each set of n, up to some reasonable smallish size n (it is combinatorially explosive presumably), and just have that as a list of options, displayed with graphical icons. Many cases will have rotational variants so we might want a more compact way of specifying that instead of enumerating them all. I looked for existing math on this but it was hard to specify exactly the right terms.

Note that the 1d sequential list, with row-vs-column rotation is always an option for any n. There aren't any interesting cases until N=3. We constrain the permutation of indexes such that you always start at 0 and increment to the extent possible.

In terms of splits data, we retain a simple slice of content panes as we have now, and the widget uses the 2D tiling config to decide where to put the splitters. The relevant size of each split zone should be specified with a single float as now, except that the tiling will impose constraints such that there can be fewer degrees of freedom relative to the 1D case (corresponding to fewer

N = 3

012

// cols = 2:

00  // big on top
12

01  // big on bottom
22

// rotational variants:

01  // big on left
02

01  // big on right
21

N = 4

// cols = 4
0123

// cols = 3

000  // big on top
123

012  // big on bottom
333

// splits for above (n=3):

0|1|2
-----
3 3 3

012  // smalls on left
312

012  // smalls in middle
032

012  // smalls on right
013

// splits for above (n = 3):

0|1|2
 | |-
0|1|3

001 // long on TL, R
231

011 // long on TR, L
023

012 // long on BL, R
332

012 // long on BR, L  (ideal case for Cogent Code)
033

// splits for above (n=3):

0|1|2
 |---
0|3 3

// cols = 2

01  
23

// rotational analogs of the cols=3 case:

01 // big on left
02
03

01 // big on right
21
31

// see above for rest of cases...

// cols = 1
0
1
2
3