Skip to content

Add action to distribute height/width for all open/split editors - #50

Open
reidswanson wants to merge 1 commit into
dkandalov:masterfrom
reidswanson:add-distribute-action
Open

Add action to distribute height/width for all open/split editors#50
reidswanson wants to merge 1 commit into
dkandalov:masterfrom
reidswanson:add-distribute-action

Conversation

@reidswanson

Copy link
Copy Markdown

I think this pull request addresses issue #8. It is not clear to me whether the EqualSizeSplit action is working as intended, namely to only equalize the active splitter or if it is supposed to equalize all of them. To avoid overwriting the existing behavior I created a new one DistributeSplitSize (I know the name is not great), that distributes the height and width across all open splits/editors.

As an example, consider a 3 column layout. The reason setting proportion=0.5 doesn't work is that it gives 50% of the space to one side of the layout tree (e.g., a single editor) and 50% to the other side (another splitter). Each of those splitters gets 50% of the remaining space, which is only 25% of the full space. That is why @nkgm noticed the layout looks like:

┌──┬─┬─┐
│  │ │ │
└──┴─┴─┘

To solve the issue you have to find out how many editors (of the same orientation) are under each branch (first and second). The "correct" proportion is the number under the 1st branch divided by the total number under both branches.

For example, consider the following layout tree where S stands for a Split node, V means vertical orientation, H means horizontal and W means Window.

S1(V)
├── S2(V)
│   ├── S3(H)
│   │   ├── W
│   │   └── S5(H)
│   │       ├── W
│   │       └── W
│   └── S4(V)
│       ├── W
│       └── S6(H)
│           ├── W
│           └── W
└── W

S1(V) has 1 direct W child, 1 W that is reachable from edges connected by other V nodes and 2 H nodes that are sub containers for other editors. 3 of the 4 leaves are in the first branch so the proportion to give to the splitter is 0.75.

So, the tree above would produce a layout like this:

________________________
|     |     |     |     |
|_____|     |     |     |
|     |     |_____|     |
|_____|     |     |     |
|     |     |     |     |
|_____|_____|_____|_____|

I am new to Kotlin and Pull Requests, so forgive any unintentional faux pas.

This commit adds an action that distributes the height and widths of
split editors evenly. Note, this is not the same as setting the
proportion of all Split elements equal to '0.5'. For example, in this
new action a window with 2 vertical splits would assign proportions
such that each editor gets 1/3 of the available space. Whereas, the
current 'equalSizeSplitter' method would assign 50% of the space
to one editor and 25% to each of the remaining two.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant