Compare commits

...

127 Commits

Author SHA1 Message Date
Mike Griese
4684e1880f Merge remote-tracking branch 'origin/main' into dev/migrie/f/992-redux-redux 2024-06-10 16:57:43 -05:00
Mike Griese
6f9ec763db Merge remote-tracking branch 'origin/main' into dev/migrie/f/992-redux-redux 2024-06-10 16:28:34 -05:00
Mike Griese
26a1ed5836 Merge branch 'main' into dev/migrie/f/992-redux-redux 2024-06-03 17:01:37 -05:00
Mike Griese
aa6f9bcb4c derp; 2024-04-04 16:00:24 -05:00
Mike Griese
194f37e9dd well, definitely this 2024-04-03 14:52:55 -05:00
Mike Griese
96c6a442ca Merge branch 'dev/migrie/f/sui-panes' into dev/migrie/f/992-redux-redux 2024-04-03 11:06:28 -05:00
Mike Griese
7c4dfff451 Merge remote-tracking branch 'origin/main' into dev/migrie/f/sui-panes 2024-04-03 11:03:46 -05:00
Mike Griese
a0e014f277 Merge remote-tracking branch 'origin/main' into dev/migrie/f/sui-panes 2024-04-03 10:13:40 -05:00
Mike Griese
e05b2bbe37 Merge branch 'main' into dev/migrie/f/sui-panes 2024-03-29 15:13:01 -05:00
Mike Griese
ef560bf48e Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2024-03-26 13:56:21 -05:00
Mike Griese
7243d220e5 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/scratchpad-pane 2024-03-26 13:55:54 -05:00
Mike Griese
10e1e46945 ALSO doesn't really need to be projected 2024-03-26 13:55:11 -05:00
Mike Griese
ddc88c83b2 Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2024-03-26 13:26:16 -05:00
Mike Griese
1d20599186 un fix this file 2024-03-26 11:38:47 -05:00
Mike Griese
b6e4b62e15 Doesn't really need to be projected 2024-03-26 11:37:35 -05:00
Mike Griese
0979cd6c44 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2024-03-26 11:22:45 -05:00
Mike Griese
61e952c58e Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2024-03-26 11:22:27 -05:00
Mike Griese
a0d62ab40b Merge branch 'dev/migrie/f/sui-panes' into dev/migrie/f/992-redux-redux 2024-03-21 14:03:02 -05:00
Mike Griese
216cc3fa66 Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2024-03-21 14:02:24 -05:00
Mike Griese
d41793470f Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2024-03-21 13:51:52 -05:00
Mike Griese
df73d75541 derp 2024-03-21 13:51:34 -05:00
Mike Griese
4f77204325 Merge branch 'dev/migrie/f/sui-panes' into dev/migrie/f/992-redux-redux 2024-03-21 13:19:00 -05:00
Mike Griese
77022e92f1 Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2024-03-21 13:17:20 -05:00
Mike Griese
f1ab16e7d5 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2024-03-21 13:16:08 -05:00
Mike Griese
2083b2ff9e Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2024-03-21 13:14:32 -05:00
Mike Griese
7300b5bb7a Merge branch 'dev/migrie/f/sui-panes' into dev/migrie/f/992-redux-redux 2024-03-20 09:37:50 -05:00
Mike Griese
bcceb85057 Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2024-03-20 09:20:16 -05:00
Mike Griese
352e0a211a fix settings pane for merge
(cherry picked from commit 0c6a353967)
2024-03-20 09:19:03 -05:00
Mike Griese
e0bb8409b3 Fix scratch pane for merge
(cherry picked from commit 591080db39)
2024-03-20 09:17:55 -05:00
Mike Griese
0946a43ee8 Merge branch 'dev/migrie/f/sui-panes' into dev/migrie/f/992-redux-redux 2024-03-20 06:41:13 -05:00
Mike Griese
c8d0c0aab7 Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2024-03-20 06:40:43 -05:00
Mike Griese
2357653de5 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2024-03-20 06:40:04 -05:00
Mike Griese
52970ef854 RegisterBigTimeEncapsulationViolatingTerminalPaneContentEvents 2024-03-19 16:30:00 -05:00
Mike Griese
826fc087b0 hey there buddy, did you get lost? 2024-03-19 15:50:58 -05:00
Mike Griese
a7533faf45 eh these events are from pane content anyways! 2024-03-19 15:15:08 -05:00
Mike Griese
052dc78af5 more nits 2024-03-19 14:54:30 -05:00
Mike Griese
fd8b083a46 get rid of this file 2024-03-19 13:55:11 -05:00
Mike Griese
6789ec0765 some of the easier nits 2024-03-19 13:34:35 -05:00
Mike Griese
6bf09df7ad Merge branch 'dev/migrie/f/sui-panes' into dev/migrie/f/992-redux-redux 2024-03-19 05:38:11 -05:00
Mike Griese
77d56e0b15 dead code 2024-03-18 16:15:10 -05:00
Mike Griese
36cefec30a comments, comments, comments 2024-03-18 16:02:17 -05:00
Mike Griese
dde4d0d1fa AHAHAHA IT WORKS 2024-03-18 15:30:40 -05:00
Mike Griese
863840ee0f Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2024-03-18 13:20:43 -05:00
Mike Griese
1951f30434 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2024-03-18 13:20:26 -05:00
Mike Griese
524d658699 GREAT-GREAT-GRANDPARENT: Hey when a pane wants to get closed, we should close it 2024-03-18 13:19:45 -05:00
Mike Griese
ef775a87c9 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2024-03-18 13:19:26 -05:00
Mike Griese
978fd6e2ba Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2024-03-08 10:36:17 -06:00
Mike Griese
35651bc92c Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2024-03-08 10:33:31 -06:00
Mike Griese
a3fbc64384 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2024-03-08 10:33:00 -06:00
Mike Griese
b6254f8294 GREAT-GRANDPARENT: This fixes a crash in parent pane selection
(cherry picked from commit 91a0d0e26d)
2024-03-07 16:51:02 -06:00
Mike Griese
6ba704d036 a thought 2024-03-07 16:47:55 -06:00
Mike Griese
032d15f1f3 Trying to figure out why the drag starting in the control continues into the border 2024-03-07 16:44:02 -06:00
Mike Griese
5e5e13ed14 VERY IMPORTANT 2024-03-07 16:43:21 -06:00
Mike Griese
ba5fab4009 beautiful elegance 2024-03-07 11:43:14 -06:00
Mike Griese
63ad45a2de endless joy. This is so much more elegant 2024-03-07 11:29:09 -06:00
Mike Griese
921c94b69c cleanup before I blow it all up 2024-03-07 11:01:39 -06:00
Mike Griese
8f89dd4efa Again, even closer, but now the middle bottom left pane doesn't resize on the left. That moves the rightmost split instead 2024-03-07 10:58:05 -06:00
Mike Griese
47b06e0b01 GAH this is SO close.
Only one that doesn't work is the pane in the middle. Resizing it's right resizes the left border.
2024-03-07 10:19:17 -06:00
Mike Griese
91a0d0e26d GREAT-GRANDPARENT: This fixes a crash in parent pane selection 2024-03-07 09:49:48 -06:00
Mike Griese
18bd6a847f OMG this is so close. the _Resize instead of ResizePane is LOAD-BEARING 2024-03-07 09:09:21 -06:00
Mike Griese
93a789cbc1 This almost works right
It doesn't manipulate if you started the drag in a termcontrol, mostly. There's
some edge cases where you can start a selection, then drag across a border, and
then we _start_ manipulating the border. But not always! So that's weird.

There are also edge cases still where if you
* drag an inactive border, it no resize-y
* drag the left border, it resizes the right one. That kinda makes sense, at least.
2024-03-05 15:52:45 -06:00
Mike Griese
67c1128201 commenting out a lot of failed ideas 2024-03-05 14:51:07 -06:00
Mike Griese
112cdf52ff this seems to work, but only on the right/bottom edges of a pane. Never the top/left 2024-03-05 10:59:00 -06:00
Mike Griese
7a27354fb3 this double-notifies the parent again, but again, not the end of the world 2024-03-05 10:19:47 -06:00
Mike Griese
04870c90f8 this totally works, except for the parent pane 2024-03-05 06:50:23 -06:00
Mike Griese
38f30c3ecb horizontal <---> resizing works great 2024-03-05 06:28:42 -06:00
Mike Griese
254f3ee50a this does resize panes but as noted, DPI is wack 2024-03-05 06:21:19 -06:00
Mike Griese
4d47cd5866 cleanup 2024-03-04 16:34:36 -06:00
Mike Griese
0a11643f1d sanely pass around a cache instead of... whatever that was. 2024-03-04 16:30:16 -06:00
Mike Griese
17075d6744 Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2024-02-28 11:50:29 -06:00
Mike Griese
25a8851986 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2024-02-28 11:36:02 -06:00
Mike Griese
de5f7af25d Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2024-02-28 11:32:40 -06:00
Mike Griese
092b3558f3 Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2024-02-08 09:47:33 -06:00
Mike Griese
c2446334e6 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2024-02-08 09:46:46 -06:00
Mike Griese
3982358188 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2024-02-08 09:40:19 -06:00
Mike Griese
0d528f84f2 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2024-01-19 16:25:31 -06:00
Mike Griese
6bc711de06 maybe I'm not that good at coding 2023-11-08 11:10:58 -06:00
Mike Griese
f622d80004 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2023-11-08 05:55:27 -06:00
Mike Griese
4cec7e9b4b try to remove a few of these but ultimately, eh 2023-11-06 06:01:55 -06:00
Mike Griese
cf920e7d58 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2023-11-02 06:13:22 -05:00
Mike Griese
389ba20a98 spel 2023-10-25 14:41:57 -05:00
Mike Griese
dd8606ff9b Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2023-10-25 11:04:43 -05:00
Mike Griese
7bc1457d42 nits and such 2023-10-25 11:03:41 -05:00
Mike Griese
e9e04d4e70 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2023-10-25 09:37:37 -05:00
Mike Griese
58e8f3c11c mostly nits 2023-10-25 09:37:23 -05:00
Mike Griese
8df9523a77 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2023-10-25 09:04:35 -05:00
Mike Griese
fd0640997d annoying build break 2023-10-13 15:17:38 -05:00
Mike Griese
fb74fc8c6a dead code 2023-10-13 14:58:19 -05:00
Mike Griese
5f4087ff00 finish exorcising SettingsTab 2023-10-13 14:56:50 -05:00
Mike Griese
81889a685c derp 2023-10-13 14:08:49 -05:00
Mike Griese
e82c627ebe dead code removal 2023-10-13 12:09:08 -05:00
Mike Griese
d726165330 terrible, but it works 2023-10-13 12:06:59 -05:00
Mike Griese
57e1f26d14 Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2023-10-13 11:36:27 -05:00
Mike Griese
b49997b4b4 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2023-10-13 11:12:24 -05:00
Mike Griese
2086e0f3af Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2023-10-13 10:39:02 -05:00
Mike Griese
6107c3e551 Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes 2023-09-11 05:43:06 -05:00
Mike Griese
46469aa5e3 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2023-09-11 05:24:30 -05:00
Mike Griese
c869b47e13 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2023-09-11 05:22:43 -05:00
Mike Griese
9531069538 background brush, done 2023-08-07 15:17:09 -05:00
Mike Griese
521e301541 update settings should work now 2023-08-03 13:50:11 -05:00
Mike Griese
842326daa5 icons for non-terminal pane content 2023-08-03 11:31:57 -05:00
Mike Griese
fb7c80938b derp 2023-08-01 11:37:10 -05:00
Mike Griese
29d0d57656 this works better than it has any right to 2023-07-27 16:29:26 -05:00
Mike Griese
cbd61b0a7d POC: yea, this works 2023-07-27 15:55:05 -05:00
Mike Griese
1cc9835454 feature flags too 2023-07-27 13:58:44 -05:00
Mike Griese
86914bdfc1 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2023-07-25 13:28:25 -05:00
Mike Griese
e0b003ad4d Merge branch 'main' into dev/migrie/fhl/non-terminal-panes-2023 2023-07-24 14:10:40 -05:00
Mike Griese
f89368c19b [PARENT] try to use GetActiveTerminalControl less in TerminalTab
(cherry picked from commit 262d95aae5)
2023-07-20 10:59:41 -05:00
Mike Griese
5582e1bcc8 [PARENT] You know what, I just went for it.
(cherry picked from commit 63ba8e19fd)
2023-07-20 10:59:28 -05:00
Mike Griese
a23c1a24dc keybindings too 2023-07-20 07:39:02 -05:00
Mike Griese
5f9add4000 Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie/fhl/scratchpad-pane 2023-07-20 07:04:10 -05:00
Mike Griese
11126f9b37 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2023-07-20 07:02:16 -05:00
Mike Griese
e31202b0b8 Merge commit '6a10ea5' into dev/migrie/fhl/non-terminal-panes-2023 2023-07-20 07:02:04 -05:00
Mike Griese
e6dc314c17 Merge commit 'b4042ea' into dev/migrie/fhl/non-terminal-panes-2023 2023-07-19 16:22:03 -05:00
Mike Griese
2d4030683a Let's just make it experimental 2023-07-18 13:47:58 -05:00
Mike Griese
262d95aae5 [PARENT] try to use GetActiveTerminalControl less in TerminalTab 2023-07-18 13:47:38 -05:00
Mike Griese
63ba8e19fd [PARENT] You know what, I just went for it. 2023-07-18 13:21:18 -05:00
Mike Griese
1b39db7ab0 Single commit that adds the whole scratchpad and action 2023-07-18 12:58:55 -05:00
Mike Griese
2dd8f409b2 [TO PARENT] dead code 2023-07-18 11:48:33 -05:00
Mike Griese
049c043279 some last cleanups 2023-07-18 10:26:32 -05:00
Mike Griese
a1da6c117e huge shuffling so that pane content can raise events instead of relying on termcontrol 2023-07-18 10:13:44 -05:00
Mike Griese
7c9ffb0e02 snapping now uses an interface, so that it's not TermControl-specific 2023-07-18 06:06:07 -05:00
Mike Griese
84df8197d4 close event 2023-07-17 14:22:12 -05:00
Mike Griese
5b3aa54b56 move GetNewTerminalArgs into IPaneContent 2023-07-17 12:42:43 -05:00
Mike Griese
ef6bb8a73c hey look, it builds now 2023-07-17 12:35:27 -05:00
Mike Griese
4e144425f0 Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-terminal-panes-2023 2023-07-17 10:53:56 -05:00
Mike Griese
f353323a23 I wanted to do this in one shot but _zelda_ 2023-05-12 13:32:12 -05:00
2 changed files with 231 additions and 8 deletions

View File

@@ -43,6 +43,9 @@ Pane::Pane(IPaneContent content, const bool lastFocused) :
_lostFocusRevoker = control.LostFocus(winrt::auto_revoke, { this, &Pane::_ContentLostFocusHandler });
}
_manipulationDeltaRevoker = _root.ManipulationDelta(winrt::auto_revoke, { this, &Pane::_ManipulationDeltaHandler });
_manipulationStartedRevoker = _root.ManipulationStarted(winrt::auto_revoke, { this, &Pane::_ManipulationStartedHandler });
// When our border is tapped, make sure to transfer focus to our control.
// LOAD-BEARING: This will NOT work if the border's BorderBrush is set to
// Colors::Transparent! The border won't get Tapped events, and they'll fall
@@ -73,6 +76,8 @@ Pane::Pane(std::shared_ptr<Pane> first,
_root.Children().Append(_borderFirst);
_root.Children().Append(_borderSecond);
_manipulationDeltaRevoker = _root.ManipulationDelta(winrt::auto_revoke, { this, &Pane::_ManipulationDeltaHandler });
_ApplySplitDefinitions();
// Register event handlers on our children to handle their Close events
@@ -243,14 +248,13 @@ Pane::BuildStartupState Pane::BuildStartupActions(uint32_t currentId, uint32_t n
// decreasing the size of our first child.
// Return Value:
// - false if we couldn't resize this pane in the given direction, else true.
bool Pane::_Resize(const ResizeDirection& direction)
bool Pane::_Resize(const ResizeDirection& direction, float amount)
{
if (!DirectionMatchesSplit(direction, _splitState))
{
return false;
}
auto amount = .05f;
if (direction == ResizeDirection::Right || direction == ResizeDirection::Down)
{
amount = -amount;
@@ -284,7 +288,7 @@ bool Pane::_Resize(const ResizeDirection& direction)
// - direction: The direction to move the separator in.
// Return Value:
// - true if we or a child handled this resize request.
bool Pane::ResizePane(const ResizeDirection& direction)
bool Pane::ResizePane(const ResizeDirection& direction, float amount)
{
// If we're a leaf, do nothing. We can't possibly have a descendant with a
// separator the correct direction.
@@ -301,7 +305,7 @@ bool Pane::ResizePane(const ResizeDirection& direction)
const auto secondIsFocused = _secondChild->_lastActive;
if (firstIsFocused || secondIsFocused)
{
return _Resize(direction);
return _Resize(direction, amount);
}
// If neither of our children were the focused pane, then recurse into
@@ -315,17 +319,200 @@ bool Pane::ResizePane(const ResizeDirection& direction)
// either.
if ((!_firstChild->_IsLeaf()) && _firstChild->_HasFocusedChild())
{
return _firstChild->ResizePane(direction) || _Resize(direction);
return _firstChild->ResizePane(direction, amount) || _Resize(direction, amount);
}
if ((!_secondChild->_IsLeaf()) && _secondChild->_HasFocusedChild())
{
return _secondChild->ResizePane(direction) || _Resize(direction);
return _secondChild->ResizePane(direction, amount) || _Resize(direction, amount);
}
return false;
}
// Handler for the _root's ManipulationStarted event. We use this to check if a
// manipulation (read: drag) started inside our content. If it did, we _don't_
// want to do our normal pane dragging.
//
// Consider the case that the TermControl might be selecting text, and the user
// drags the mouse over the pane border. We don't want that to start moving the
// border!
void Pane::_ManipulationStartedHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::UI::Xaml::Input::ManipulationStartedRoutedEventArgs& args)
{
// This is added to each _root. But it also bubbles, so only leaves should actually try to handle this.
if (args.Handled())
{
return;
}
args.Handled(true);
assert(_IsLeaf());
const auto contentSize = _content.GetRoot().ActualSize();
auto transformCurrentPos = args.Position();
auto transformOrigin = transformCurrentPos;
const auto transform_contentFromOurRoot = _root.TransformToVisual(_content.GetRoot());
const auto transformInControlSpace = transform_contentFromOurRoot.TransformPoint(transformOrigin);
// If we clicked on the control. bail, and don't allow any manipulations
// for this series of events.
_shouldManipulate = !((transformInControlSpace.X >= 0 && transformInControlSpace.X < contentSize.x) &&
(transformInControlSpace.Y >= 0 && transformInControlSpace.Y < contentSize.y));
}
// Handler for the _root's ManipulationDelta event. This is the event raised
// when a user clicks and drags somewhere inside the pane. We're going to use
// this to determine if the user clicked on one of our borders. If they did,
// we're going to need to ask our parent pane (or other ancestors) to resize
// their split.
//
// Recall that a leaf itself is responsible for having the right borders, but it
// is the parent of the leaf that actually controls how big a split is.
//
// When we do want to be resized, we'll pass the delta from this event upwards
// via ManipulationRequested, which will be handled in
// Pane::_handleOrBubbleManipulation.
void Pane::_ManipulationDeltaHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::UI::Xaml::Input::ManipulationDeltaRoutedEventArgs& args)
{
// sender is ORIGINALLY the root Grid of a leaf, and the leaf may or may not
// have a border.
if (args.Handled())
{
return;
}
if (!_shouldManipulate)
{
// Using our stored _shouldManipulate set up in
// _ManipulationStartedHandler, bail if the manipulation didn't start
// _on the border_.
return;
}
assert(_IsLeaf());
const auto delta = args.Delta().Translation;
const auto transformOrigin = args.Position();
const auto contentSize = _content.GetRoot().ActualSize();
const auto transform_contentFromOurRoot = _root.TransformToVisual(_content.GetRoot());
// This is the position of the drag relative to the bounds of our content.
const auto transformInControlSpace = transform_contentFromOurRoot.TransformPoint(transformOrigin);
// Did we click somewhere in the bounds of our content?
if ((transformInControlSpace.X >= 0 && transformInControlSpace.X < contentSize.x) &&
(transformInControlSpace.Y >= 0 && transformInControlSpace.Y < contentSize.y))
{
// We did! Bail.
return;
}
// Now, we know we clicked somewhere outside the bounds of our content. Set
// border flags based on the side that was clicked on.
Borders clicked = Borders::None;
clicked |= (transformInControlSpace.X < 0) ? Borders::Left : Borders::None;
clicked |= (transformInControlSpace.Y < 0) ? Borders::Top : Borders::None;
clicked |= (transformInControlSpace.X > contentSize.x) ? Borders::Right : Borders::None;
clicked |= (transformInControlSpace.Y > contentSize.y) ? Borders::Bottom : Borders::None;
// Ask our parent to resize their split.
ManipulationRequested.raise(shared_from_this(), delta, clicked);
}
// Handler for our child's own ManipulationRequested event. They will pass to us
// (their immediate parent) the delta and the side that was clicked on.
// * If we control that border, then we'll handle the resize ourself in _handleManipulation.
// * If not, then we'll ask our own parent to try and resize that same border.
void Pane::_handleOrBubbleManipulation(std::shared_ptr<Pane> sender,
const winrt::Windows::Foundation::Point delta,
Borders side)
{
if (side == Borders::None || _splitState == SplitState::None)
{
return;
}
const bool isFirstChild = sender == _firstChild;
// We want to handle this drag in the following cases
// * In a vertical split: if we're dragging the right of the first pane or the left of the second
// * In a horizontal split: if we're dragging the bottom of the first pane or the top of the second
const auto sideMatched = (_splitState == SplitState::Vertical) ? (isFirstChild && WI_IsFlagSet(side, Borders::Right)) || (!isFirstChild && WI_IsFlagSet(side, Borders::Left)) :
(_splitState == SplitState::Horizontal) ? (isFirstChild && WI_IsFlagSet(side, Borders::Bottom)) || (!isFirstChild && WI_IsFlagSet(side, Borders::Top)) :
false;
if (sideMatched)
{
_handleManipulation(delta);
}
else
{
// Bubble, with us as the new sender.
ManipulationRequested.raise(shared_from_this(), delta, side);
}
}
// Actually handle resizing our split in response to a drag event. If we're
// being called, then we know that the delta that's passed to us should be
// applied to our own split. The delta that's passed in here is in PIXELS, not
// DIPs.
void Pane::_handleManipulation(const winrt::Windows::Foundation::Point delta)
{
const auto scaleFactor = DisplayInformation::GetForCurrentView().RawPixelsPerViewPixel();
const auto weAreVertical = _splitState == SplitState::Vertical;
const winrt::Windows::Foundation::Point translationForUs = (weAreVertical) ? Point{ delta.X, 0 } : Point{ 0, delta.Y };
// Decide on direction based on delta
ResizeDirection dir = ResizeDirection::None;
if (_splitState == SplitState::Vertical)
{
if (translationForUs.X < 0)
{
dir = ResizeDirection::Left;
}
else if (translationForUs.X > 0)
{
dir = ResizeDirection::Right;
}
}
else if (_splitState == SplitState::Horizontal)
{
if (translationForUs.Y < 0)
{
dir = ResizeDirection::Up;
}
else if (translationForUs.Y > 0)
{
dir = ResizeDirection::Down;
}
}
// Resize in the given direction
if (dir != ResizeDirection::None)
{
// turn delta into a percentage
base::ClampedNumeric<float> amount;
base::ClampedNumeric<float> actualDimension;
if (dir == ResizeDirection::Left || dir == ResizeDirection::Right)
{
amount = translationForUs.X;
actualDimension = base::ClampedNumeric<float>(_root.ActualWidth());
}
else if (dir == ResizeDirection::Up || dir == ResizeDirection::Down)
{
amount = translationForUs.Y;
actualDimension = base::ClampedNumeric<float>(_root.ActualHeight());
}
const auto scaledAmount = amount * scaleFactor;
const auto percentDelta = scaledAmount / actualDimension;
_Resize(dir, percentDelta.Abs());
}
}
// Method Description:
// - Attempt to navigate from the sourcePane according to direction.
// - If the direction is NextInOrder or PreviousInOrder, the next or previous
@@ -1865,6 +2052,9 @@ Borders Pane::_GetCommonBorders()
// - <none>
void Pane::_ApplySplitDefinitions()
{
// Remove our old handler, if we had one.
_manipulationDeltaRevoker.revoke();
if (_splitState == SplitState::Vertical)
{
Controls::Grid::SetColumn(_borderFirst, 0);
@@ -1889,6 +2079,17 @@ void Pane::_ApplySplitDefinitions()
_firstChild->_ApplySplitDefinitions();
_secondChild->_ApplySplitDefinitions();
}
else
{
assert(_IsLeaf());
// If we're a leaf, then add a ManipulationDelta handler.
_manipulationDeltaRevoker = _root.ManipulationDelta(winrt::auto_revoke, { this, &Pane::_ManipulationDeltaHandler });
}
_root.ManipulationMode(Xaml::Input::ManipulationModes::TranslateX |
Xaml::Input::ManipulationModes::TranslateRailsX |
Xaml::Input::ManipulationModes::TranslateY |
Xaml::Input::ManipulationModes::TranslateRailsY);
_UpdateBorders();
}
@@ -2272,6 +2473,9 @@ std::pair<std::shared_ptr<Pane>, std::shared_ptr<Pane>> Pane::_Split(SplitDirect
// Create a new pane from ourself
if (!_IsLeaf())
{
_firstChild->ManipulationRequested(_firstManipulatedToken);
_secondChild->ManipulationRequested(_secondManipulatedToken);
// Since we are a parent we don't have borders normally,
// so set them temporarily for when we update our split definition.
_borders = _GetCommonBorders();
@@ -2309,6 +2513,9 @@ std::pair<std::shared_ptr<Pane>, std::shared_ptr<Pane>> Pane::_Split(SplitDirect
_ApplySplitDefinitions();
_firstManipulatedToken = _firstChild->ManipulationRequested({ this, &Pane::_handleOrBubbleManipulation });
_secondManipulatedToken = _secondChild->ManipulationRequested({ this, &Pane::_handleOrBubbleManipulation });
// Register event handlers on our children to handle their Close events
_SetupChildCloseHandlers();

View File

@@ -109,7 +109,8 @@ public:
winrt::Microsoft::Terminal::Settings::Model::INewContentArgs GetTerminalArgsForPane(winrt::TerminalApp::BuildStartupKind kind) const;
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
bool ResizePane(const winrt::Microsoft::Terminal::Settings::Model::ResizeDirection& direction);
bool ResizePane(const winrt::Microsoft::Terminal::Settings::Model::ResizeDirection& direction, float amount = .05f);
std::shared_ptr<Pane> NavigateDirection(const std::shared_ptr<Pane> sourcePane,
const winrt::Microsoft::Terminal::Settings::Model::FocusDirection& direction,
const std::vector<uint32_t>& mruPanes);
@@ -223,6 +224,7 @@ public:
til::event<gotFocusArgs> GotFocus;
til::event<winrt::delegate<std::shared_ptr<Pane>>> LostFocus;
til::event<winrt::delegate<std::shared_ptr<Pane>>> Detached;
til::event<winrt::delegate<std::shared_ptr<Pane>, winrt::Windows::Foundation::Point, Borders>> ManipulationRequested;
private:
struct PanePoint;
@@ -252,10 +254,17 @@ private:
winrt::event_token _firstClosedToken{ 0 };
winrt::event_token _secondClosedToken{ 0 };
winrt::event_token _firstManipulatedToken{ 0 };
winrt::event_token _secondManipulatedToken{ 0 };
winrt::Windows::UI::Xaml::UIElement::GotFocus_revoker _gotFocusRevoker;
winrt::Windows::UI::Xaml::UIElement::LostFocus_revoker _lostFocusRevoker;
winrt::TerminalApp::IPaneContent::CloseRequested_revoker _closeRequestedRevoker;
winrt::Windows::UI::Xaml::UIElement::ManipulationDelta_revoker _manipulationDeltaRevoker;
winrt::Windows::UI::Xaml::UIElement::ManipulationStarted_revoker _manipulationStartedRevoker;
bool _shouldManipulate{ false };
Borders _borders{ Borders::None };
bool _zoomed{ false };
@@ -280,7 +289,9 @@ private:
Borders _GetCommonBorders();
winrt::Windows::UI::Xaml::Media::SolidColorBrush _ComputeBorderColor();
bool _Resize(const winrt::Microsoft::Terminal::Settings::Model::ResizeDirection& direction);
void _handleOrBubbleManipulation(std::shared_ptr<Pane> sender, const winrt::Windows::Foundation::Point delta, Borders side);
void _handleManipulation(const winrt::Windows::Foundation::Point delta);
bool _Resize(const winrt::Microsoft::Terminal::Settings::Model::ResizeDirection& direction, float amount);
std::shared_ptr<Pane> _FindParentOfPane(const std::shared_ptr<Pane> pane);
std::pair<PanePoint, PanePoint> _GetOffsetsForPane(const PanePoint parentOffset) const;
@@ -303,6 +314,11 @@ private:
void _ContentLostFocusHandler(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void _ManipulationStartedHandler(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::UI::Xaml::Input::ManipulationStartedRoutedEventArgs& e);
void _ManipulationDeltaHandler(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::UI::Xaml::Input::ManipulationDeltaRoutedEventArgs& e);
std::pair<float, float> _CalcChildrenSizes(const float fullSize) const;
SnapChildrenSizeResult _CalcSnappedChildrenSizes(const bool widthOrHeight, const float fullSize) const;
SnapSizeResult _CalcSnappedDimension(const bool widthOrHeight, const float dimension) const;