Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable resizing the panes with the keyboard. #1207

Merged
merged 14 commits into from
Jul 10, 2019

Conversation

zadjii-msft
Copy link
Member

Summary of the Pull Request

Adds the ability to resize panes with the keyboard.

PR Checklist

Detailed Description of the Pull Request / Additional comments

This is accomplished by making the Column/RowDefinitions for a Pane use GridLengthHelper::FromPixels to set their size. We store a pair of floats that represents the relative amount that each pane takes out of the parent pane. When the window is resized, we use that percentage to figure out the new size of each child in pixels, and manually size each column.

Then, when the user presses the keybindings for resizePane{Left/Right/Up/Down}, we'll adjust those percentages, and resize the rows/cols as appropriate.

Currently, each pane adjusts the width/height by 5% of the total size at a time. I am not in love with this, but it works for now. I think when we get support for keybindings with arbitrary arg blobs, then we could do either a percent movement, or a number of characters at a time. The number of characters one would be trickier, because we'd have to get the focused control, and get the number of pixels per character, as adjacent panes might not have the same font sizes.

Validation Steps Performed

Opened a bunch of panes and tried moving them with the keybindings

…e size, but doesn't resize down. I also had to remove the seperator. I think I need to have the resize event start from the top, then recurse down
  * Works for both vertical and horizontal splits
  * seperator is visible too
  * resizing the window works right
  If you add keybindings for resizing, like so:
  ```json
            {
                "command" : "resizePaneDown",
                "keys" :
                [
                    "alt+shift+down"
                ]
            },
            {
                "command" : "resizePaneLeft",
                "keys" :
                [
                    "alt+shift+left"
                ]
            },
            {
                "command" : "resizePaneRight",
                "keys" :
                [
                    "alt+shift+right"
                ]
            },
            {
                "command" : "resizePaneUp",
                "keys" :
                [
                    "alt+shift+up"
                ]
            },

  ```

  Then you can now resize the panes, 5% at a time.

  We correctly traverse the tree to find the separator that's closest to the
  focused pane (depth-wise), but also the correct direction.
@zadjii-msft zadjii-msft added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. labels Jun 11, 2019
@zadjii-msft zadjii-msft added this to the Terminal v1.0 milestone Jun 11, 2019
@zadjii-msft zadjii-msft changed the title Enable resizing the panes witht he keyboard. Enable resizing the panes witht the keyboard. Jun 11, 2019
@zadjii-msft zadjii-msft changed the title Enable resizing the panes witht the keyboard. Enable resizing the panes with the keyboard. Jun 11, 2019
  I need the padding fix however
…sizable-panes

# Conflicts:
#	src/cascadia/TerminalApp/AppKeyBindings.cpp
#	src/cascadia/TerminalApp/AppKeyBindings.h
#	src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp
@DHowett-MSFT
Copy link
Contributor

If you have this layout:

+--------------------------------+-----------------------------------+
|                                |                                   |
| *PARENT*                       | *SIBLING*                         |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                +-----------------------------------+
|                                |                                   |
|                                | *ACTIVE*                          |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
+--------------------------------+-----------------------------------+

and you resize <-->, does it bubble up to the parent pane? Even if the horizontal split is nested inside the vertical one?

@carlos-zamora
Copy link
Member

If you have this layout:

+--------------------------------+-----------------------------------+
|                                |                                   |
| *PARENT*                       | *SIBLING*                         |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                +-----------------------------------+
|                                |                                   |
|                                | *ACTIVE*                          |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
|                                |                                   |
+--------------------------------+-----------------------------------+

and you resize <-->, does it bubble up to the parent pane? Even if the horizontal split is nested inside the vertical one?

Yup. Pretty neat :)

@zadjii-msft
Copy link
Member Author

@DHowett-MSFT you bet it does :)

@zadjii-msft zadjii-msft requested a review from miniksa June 19, 2019 19:12
@zadjii-msft
Copy link
Member Author

@adiviness @DHowett-MSFT @miniksa Can I get a second on this at some point? I'll have another PR to follow this one for moving pane focus

Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a few things and there are a few open comments still in here from other folks.

src/cascadia/TerminalApp/App.cpp Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.h Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/TermControl.cpp Show resolved Hide resolved
@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jul 1, 2019
…sizable-panes

# Conflicts:
#	src/cascadia/TerminalApp/App.cpp
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jul 3, 2019
@zadjii-msft zadjii-msft requested a review from miniksa July 3, 2019 21:26
Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry we took so long!

…sizable-panes

# Conflicts:
#	src/cascadia/TerminalApp/App.cpp
@zadjii-msft zadjii-msft merged commit 2de2f44 into master Jul 10, 2019
@zadjii-msft zadjii-msft deleted the dev/migrie/f/991-resizable-panes branch July 10, 2019 13:27
mcpiroman pushed a commit to mcpiroman/terminal that referenced this pull request Jul 23, 2019
Adds the ability to resize panes with the keyboard. 

This is accomplished by making the Column/RowDefinitions for a Pane use `GridLengthHelper::FromPixels` to set their size. We store a pair of floats that represents the relative amount that each pane takes out of the parent pane. When the window is resized, we use that percentage to figure out the new size of each child in pixels, and manually size each column. 

Then, when the user presses the keybindings for resizePane{Left/Right/Up/Down}, we'll adjust those percentages, and resize the rows/cols as appropriate.

Currently, each pane adjusts the width/height by 5% of the total size at a time. I am not in love with this, but it works for now. I think when we get support for keybindings with arbitrary arg blobs, then we could do either a percent movement, or a number of characters at a time. The number of characters one would be trickier, because we'd have to get the focused control, and get the number of pixels per character, as adjacent panes might not have the same font sizes.
@ghost
Copy link

ghost commented Aug 3, 2019

🎉Windows Terminal Preview v0.3.2142.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panes should be resizable with the keyboard.
5 participants