@@ -42,13 +42,11 @@ Pane::Pane(const IPaneContent& content, const bool lastFocused) :
42
42
const auto & control{ _content.GetRoot () };
43
43
_borderFirst.Child (control);
44
44
45
- // _setupControlEvents();
46
-
47
45
// Register an event with the control to have it inform us when it gains focus.
48
46
if (control)
49
47
{
50
- _gotFocusRevoker = control.GotFocus (winrt::auto_revoke, { this , &Pane::_ControlGotFocusHandler });
51
- _lostFocusRevoker = control.LostFocus (winrt::auto_revoke, { this , &Pane::_ControlLostFocusHandler });
48
+ _gotFocusRevoker = control.GotFocus (winrt::auto_revoke, { this , &Pane::_ContentGotFocusHandler });
49
+ _lostFocusRevoker = control.LostFocus (winrt::auto_revoke, { this , &Pane::_ContentLostFocusHandler });
52
50
}
53
51
54
52
// When our border is tapped, make sure to transfer focus to our control.
@@ -974,7 +972,7 @@ Pane::PaneNeighborSearch Pane::_FindPaneAndNeighbor(const std::shared_ptr<Pane>
974
972
// - <unused>
975
973
// Return Value:
976
974
// - <none>
977
- void Pane::_ControlGotFocusHandler (const winrt::Windows::Foundation::IInspectable& sender,
975
+ void Pane::_ContentGotFocusHandler (const winrt::Windows::Foundation::IInspectable& sender,
978
976
const RoutedEventArgs& /* args */ )
979
977
{
980
978
auto f = FocusState::Programmatic;
@@ -989,7 +987,7 @@ void Pane::_ControlGotFocusHandler(const winrt::Windows::Foundation::IInspectabl
989
987
// - Called when our control loses focus. We'll use this to trigger our LostFocus
990
988
// callback. The tab that's hosting us should have registered a callback which
991
989
// can be used to update its own internal focus state
992
- void Pane::_ControlLostFocusHandler (const winrt::Windows::Foundation::IInspectable& /* sender */ ,
990
+ void Pane::_ContentLostFocusHandler (const winrt::Windows::Foundation::IInspectable& /* sender */ ,
993
991
const RoutedEventArgs& /* args */ )
994
992
{
995
993
_LostFocusHandlers (shared_from_this ());
@@ -1458,8 +1456,8 @@ void Pane::_CloseChild(const bool closeFirst, const bool /*isDetaching*/)
1458
1456
// re-attach our handler for the control's GotFocus event.
1459
1457
if (control)
1460
1458
{
1461
- _gotFocusRevoker = control.GotFocus (winrt::auto_revoke, { this , &Pane::_ControlGotFocusHandler });
1462
- _lostFocusRevoker = control.LostFocus (winrt::auto_revoke, { this , &Pane::_ControlLostFocusHandler });
1459
+ _gotFocusRevoker = control.GotFocus (winrt::auto_revoke, { this , &Pane::_ContentGotFocusHandler });
1460
+ _lostFocusRevoker = control.LostFocus (winrt::auto_revoke, { this , &Pane::_ContentLostFocusHandler });
1463
1461
}
1464
1462
1465
1463
// If we're inheriting the "last active" state from one of our children,
@@ -1589,126 +1587,126 @@ winrt::fire_and_forget Pane::_CloseChildRoutine(const bool closeFirst)
1589
1587
1590
1588
if (auto pane{ weakThis.get () })
1591
1589
{
1592
- // // This will query if animations are enabled via the "Show animations in
1593
- // // Windows" setting in the OS
1594
- // winrt::Windows::UI::ViewManagement::UISettings uiSettings;
1595
- // const auto animationsEnabledInOS = uiSettings.AnimationsEnabled();
1596
- // const auto animationsEnabledInApp = Media::Animation::Timeline::AllowDependentAnimations();
1590
+ // This will query if animations are enabled via the "Show animations in
1591
+ // Windows" setting in the OS
1592
+ winrt::Windows::UI::ViewManagement::UISettings uiSettings;
1593
+ const auto animationsEnabledInOS = uiSettings.AnimationsEnabled ();
1594
+ const auto animationsEnabledInApp = Media::Animation::Timeline::AllowDependentAnimations ();
1597
1595
1598
- // // GH#7252: If either child is zoomed, just skip the animation. It won't work.
1599
- // const auto eitherChildZoomed = pane->_firstChild->_zoomed || pane->_secondChild->_zoomed;
1596
+ // GH#7252: If either child is zoomed, just skip the animation. It won't work.
1597
+ const auto eitherChildZoomed = pane->_firstChild ->_zoomed || pane->_secondChild ->_zoomed ;
1600
1598
// If animations are disabled, just skip this and go straight to
1601
1599
// _CloseChild. Curiously, the pane opening animation doesn't need this,
1602
1600
// and will skip straight to Completed when animations are disabled, but
1603
1601
// this one doesn't seem to.
1604
- // if (!animationsEnabledInOS || !animationsEnabledInApp || eitherChildZoomed)
1605
- // {
1606
- pane->_CloseChild (closeFirst, false );
1607
- co_return ;
1608
- // }
1609
-
1610
- // // Setup the animation
1611
-
1612
- // auto removedChild = closeFirst ? _firstChild : _secondChild;
1613
- // auto remainingChild = closeFirst ? _secondChild : _firstChild;
1614
- // const auto splitWidth = _splitState == SplitState::Vertical;
1615
-
1616
- // Size removedOriginalSize{
1617
- // ::base::saturated_cast<float>(removedChild->_root.ActualWidth()),
1618
- // ::base::saturated_cast<float>(removedChild->_root.ActualHeight())
1619
- // };
1620
- // Size remainingOriginalSize{
1621
- // ::base::saturated_cast<float>(remainingChild->_root.ActualWidth()),
1622
- // ::base::saturated_cast<float>(remainingChild->_root.ActualHeight())
1623
- // };
1624
-
1625
- // // Remove both children from the grid
1626
- // _borderFirst.Child(nullptr);
1627
- // _borderSecond.Child(nullptr);
1628
-
1629
- // if (_splitState == SplitState::Vertical)
1630
- // {
1631
- // Controls::Grid::SetColumn(_borderFirst, 0);
1632
- // Controls::Grid::SetColumn(_borderSecond, 1);
1633
- // }
1634
- // else if (_splitState == SplitState::Horizontal)
1635
- // {
1636
- // Controls::Grid::SetRow(_borderFirst, 0);
1637
- // Controls::Grid::SetRow(_borderSecond, 1);
1638
- // }
1639
-
1640
- // // Create the dummy grid. This grid will be the one we actually animate,
1641
- // // in the place of the closed pane.
1642
- // Controls::Grid dummyGrid;
1643
- // // GH#603 - we can safely add a BG here, as the control is gone right
1644
- // // away, to fill the space as the rest of the pane expands.
1645
- // dummyGrid.Background(_themeResources.unfocusedBorderBrush);
1646
- // // It should be the size of the closed pane.
1647
- // dummyGrid.Width(removedOriginalSize.Width);
1648
- // dummyGrid.Height(removedOriginalSize.Height);
1649
-
1650
- // _borderFirst.Child(closeFirst ? dummyGrid : remainingChild->GetRootElement());
1651
- // _borderSecond.Child(closeFirst ? remainingChild->GetRootElement() : dummyGrid);
1652
-
1653
- // // Set up the rows/cols as auto/auto, so they'll only use the size of
1654
- // // the elements in the grid.
1655
- // //
1656
- // // * For the closed pane, we want to make that row/col "auto" sized, so
1657
- // // it takes up as much space as is available.
1658
- // // * For the remaining pane, we'll make that row/col "*" sized, so it
1659
- // // takes all the remaining space. As the dummy grid is resized down,
1660
- // // the remaining pane will expand to take the rest of the space.
1661
- // _root.ColumnDefinitions().Clear();
1662
- // _root.RowDefinitions().Clear();
1663
- // if (_splitState == SplitState::Vertical)
1664
- // {
1665
- // auto firstColDef = Controls::ColumnDefinition();
1666
- // auto secondColDef = Controls::ColumnDefinition();
1667
- // firstColDef.Width(!closeFirst ? GridLengthHelper::FromValueAndType(1, GridUnitType::Star) : GridLengthHelper::Auto());
1668
- // secondColDef.Width(closeFirst ? GridLengthHelper::FromValueAndType(1, GridUnitType::Star) : GridLengthHelper::Auto());
1669
- // _root.ColumnDefinitions().Append(firstColDef);
1670
- // _root.ColumnDefinitions().Append(secondColDef);
1671
- // }
1672
- // else if (_splitState == SplitState::Horizontal)
1673
- // {
1674
- // auto firstRowDef = Controls::RowDefinition();
1675
- // auto secondRowDef = Controls::RowDefinition();
1676
- // firstRowDef.Height(!closeFirst ? GridLengthHelper::FromValueAndType(1, GridUnitType::Star) : GridLengthHelper::Auto());
1677
- // secondRowDef.Height(closeFirst ? GridLengthHelper::FromValueAndType(1, GridUnitType::Star) : GridLengthHelper::Auto());
1678
- // _root.RowDefinitions().Append(firstRowDef);
1679
- // _root.RowDefinitions().Append(secondRowDef);
1680
- // }
1681
-
1682
- // // Animate the dummy grid from its current size down to 0
1683
- // Media::Animation::DoubleAnimation animation{};
1684
- // animation.Duration(AnimationDuration);
1685
- // animation.From(splitWidth ? removedOriginalSize.Width : removedOriginalSize.Height);
1686
- // animation.To(0.0);
1687
- // // This easing is the same as the entrance animation.
1688
- // animation.EasingFunction(Media::Animation::QuadraticEase{});
1689
- // animation.EnableDependentAnimation(true);
1690
-
1691
- // Media::Animation::Storyboard s;
1692
- // s.Duration(AnimationDuration);
1693
- // s.Children().Append(animation);
1694
- // s.SetTarget(animation, dummyGrid);
1695
- // s.SetTargetProperty(animation, splitWidth ? L"Width" : L"Height");
1696
-
1697
- // // Start the animation.
1698
- // s.Begin();
1699
-
1700
- // std::weak_ptr<Pane> weakThis{ shared_from_this() };
1701
-
1702
- // // When the animation is completed, reparent the child's content up to
1703
- // // us, and remove the child nodes from the tree.
1704
- // animation.Completed([weakThis, closeFirst](auto&&, auto&&) {
1705
- // if (auto pane{ weakThis.lock() })
1706
- // {
1707
- // // We don't need to manually undo any of the above trickiness.
1708
- // // We're going to re-parent the child's content into us anyways
1709
- // pane->_CloseChild(closeFirst, false);
1710
- // }
1711
- // });
1602
+ if (!animationsEnabledInOS || !animationsEnabledInApp || eitherChildZoomed)
1603
+ {
1604
+ pane->_CloseChild (closeFirst, false );
1605
+ co_return ;
1606
+ }
1607
+
1608
+ // Setup the animation
1609
+
1610
+ auto removedChild = closeFirst ? _firstChild : _secondChild;
1611
+ auto remainingChild = closeFirst ? _secondChild : _firstChild;
1612
+ const auto splitWidth = _splitState == SplitState::Vertical;
1613
+
1614
+ Size removedOriginalSize{
1615
+ ::base::saturated_cast<float >(removedChild->_root .ActualWidth ()),
1616
+ ::base::saturated_cast<float >(removedChild->_root .ActualHeight ())
1617
+ };
1618
+ Size remainingOriginalSize{
1619
+ ::base::saturated_cast<float >(remainingChild->_root .ActualWidth ()),
1620
+ ::base::saturated_cast<float >(remainingChild->_root .ActualHeight ())
1621
+ };
1622
+
1623
+ // Remove both children from the grid
1624
+ _borderFirst.Child (nullptr );
1625
+ _borderSecond.Child (nullptr );
1626
+
1627
+ if (_splitState == SplitState::Vertical)
1628
+ {
1629
+ Controls::Grid::SetColumn (_borderFirst, 0 );
1630
+ Controls::Grid::SetColumn (_borderSecond, 1 );
1631
+ }
1632
+ else if (_splitState == SplitState::Horizontal)
1633
+ {
1634
+ Controls::Grid::SetRow (_borderFirst, 0 );
1635
+ Controls::Grid::SetRow (_borderSecond, 1 );
1636
+ }
1637
+
1638
+ // Create the dummy grid. This grid will be the one we actually animate,
1639
+ // in the place of the closed pane.
1640
+ Controls::Grid dummyGrid;
1641
+ // GH#603 - we can safely add a BG here, as the control is gone right
1642
+ // away, to fill the space as the rest of the pane expands.
1643
+ dummyGrid.Background (_themeResources.unfocusedBorderBrush );
1644
+ // It should be the size of the closed pane.
1645
+ dummyGrid.Width (removedOriginalSize.Width );
1646
+ dummyGrid.Height (removedOriginalSize.Height );
1647
+
1648
+ _borderFirst.Child (closeFirst ? dummyGrid : remainingChild->GetRootElement ());
1649
+ _borderSecond.Child (closeFirst ? remainingChild->GetRootElement () : dummyGrid);
1650
+
1651
+ // Set up the rows/cols as auto/auto, so they'll only use the size of
1652
+ // the elements in the grid.
1653
+ //
1654
+ // * For the closed pane, we want to make that row/col "auto" sized, so
1655
+ // it takes up as much space as is available.
1656
+ // * For the remaining pane, we'll make that row/col "*" sized, so it
1657
+ // takes all the remaining space. As the dummy grid is resized down,
1658
+ // the remaining pane will expand to take the rest of the space.
1659
+ _root.ColumnDefinitions ().Clear ();
1660
+ _root.RowDefinitions ().Clear ();
1661
+ if (_splitState == SplitState::Vertical)
1662
+ {
1663
+ auto firstColDef = Controls::ColumnDefinition ();
1664
+ auto secondColDef = Controls::ColumnDefinition ();
1665
+ firstColDef.Width (!closeFirst ? GridLengthHelper::FromValueAndType (1 , GridUnitType::Star) : GridLengthHelper::Auto ());
1666
+ secondColDef.Width (closeFirst ? GridLengthHelper::FromValueAndType (1 , GridUnitType::Star) : GridLengthHelper::Auto ());
1667
+ _root.ColumnDefinitions ().Append (firstColDef);
1668
+ _root.ColumnDefinitions ().Append (secondColDef);
1669
+ }
1670
+ else if (_splitState == SplitState::Horizontal)
1671
+ {
1672
+ auto firstRowDef = Controls::RowDefinition ();
1673
+ auto secondRowDef = Controls::RowDefinition ();
1674
+ firstRowDef.Height (!closeFirst ? GridLengthHelper::FromValueAndType (1 , GridUnitType::Star) : GridLengthHelper::Auto ());
1675
+ secondRowDef.Height (closeFirst ? GridLengthHelper::FromValueAndType (1 , GridUnitType::Star) : GridLengthHelper::Auto ());
1676
+ _root.RowDefinitions ().Append (firstRowDef);
1677
+ _root.RowDefinitions ().Append (secondRowDef);
1678
+ }
1679
+
1680
+ // Animate the dummy grid from its current size down to 0
1681
+ Media::Animation::DoubleAnimation animation{};
1682
+ animation.Duration (AnimationDuration);
1683
+ animation.From (splitWidth ? removedOriginalSize.Width : removedOriginalSize.Height );
1684
+ animation.To (0.0 );
1685
+ // This easing is the same as the entrance animation.
1686
+ animation.EasingFunction (Media::Animation::QuadraticEase{});
1687
+ animation.EnableDependentAnimation (true );
1688
+
1689
+ Media::Animation::Storyboard s;
1690
+ s.Duration (AnimationDuration);
1691
+ s.Children ().Append (animation);
1692
+ s.SetTarget (animation, dummyGrid);
1693
+ s.SetTargetProperty (animation, splitWidth ? L" Width" : L" Height" );
1694
+
1695
+ // Start the animation.
1696
+ s.Begin ();
1697
+
1698
+ std::weak_ptr<Pane> weakThis{ shared_from_this () };
1699
+
1700
+ // When the animation is completed, reparent the child's content up to
1701
+ // us, and remove the child nodes from the tree.
1702
+ animation.Completed ([weakThis, closeFirst](auto &&, auto &&) {
1703
+ if (auto pane{ weakThis.lock () })
1704
+ {
1705
+ // We don't need to manually undo any of the above trickiness.
1706
+ // We're going to re-parent the child's content into us anyways
1707
+ pane->_CloseChild (closeFirst, false );
1708
+ }
1709
+ });
1712
1710
}
1713
1711
}
1714
1712
0 commit comments