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

Navigation View Layout Reflow #4779

Merged
merged 29 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b6c0169
update backbutton
karkarl Apr 5, 2021
4777400
update itemSeparator margins
karkarl Apr 5, 2021
cb92bf7
update itemHeader when compact
karkarl Apr 5, 2021
a22672f
update itemHeader margins
karkarl Apr 5, 2021
eab72d9
update content header and margin
karkarl Apr 5, 2021
f9336f2
update top nav layout
karkarl Apr 7, 2021
381c12a
fix navView colouring
karkarl Apr 7, 2021
61d87b5
update pane border
karkarl Apr 7, 2021
bc608f2
add default foreground for itempresenter
karkarl Apr 8, 2021
15b2400
adjust margins on left nav compact
karkarl Apr 9, 2021
895c5a3
fix paneoverlay on load bug
karkarl Apr 9, 2021
2ace461
update compact pane button widths
karkarl Apr 9, 2021
8e84196
update layout from review
karkarl Apr 10, 2021
a3d9257
update paneTitle position when toggle collapsed
karkarl Apr 10, 2021
5436678
fix settings disappearing in compactmode bug
karkarl Apr 10, 2021
53d3ea1
changes from comments
karkarl Apr 12, 2021
bb029fb
update verificationfiles
karkarl Apr 12, 2021
abb287c
fix failing tests
karkarl Apr 13, 2021
7704cd8
update verification files
karkarl Apr 14, 2021
5dfb196
fix panetitletoppane margin and visibility
karkarl Apr 15, 2021
b6e5bdd
fix top nav margin and colouring
karkarl Apr 16, 2021
d86133c
update verification files
karkarl Apr 16, 2021
4975774
fix top nav item margins
karkarl Apr 16, 2021
0eeccc0
fix top nav grid margin
karkarl Apr 16, 2021
ade89b5
fix heading margins for left and top nav
karkarl Apr 16, 2021
99bfa99
update verification files
karkarl Apr 20, 2021
c7650ad
fix tests
karkarl Apr 20, 2021
34bfd0c
fix tests
karkarl Apr 20, 2021
ca48e49
temporarily disabling tests
karkarl Apr 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/NavigationView/NavigationBackButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<Style x:Key="NavigationBackButtonNormalStyle" TargetType="Button">
<Setter Property="Background" Value="{ThemeResource NavigationViewBackButtonBackground}" />
<Setter Property="Foreground" Value="{ThemeResource NavigationViewItemForeground}" />
<Setter Property="Foreground" Value="{ThemeResource NavigationViewItemForegroundChecked}" />
<Setter Property="FontFamily" Value="{ThemeResource SymbolThemeFontFamily}" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Height" Value="{ThemeResource NavigationBackButtonHeight}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<x:Double x:Key="NavigationBackButtonWidth">38</x:Double>
<x:Double x:Key="NavigationBackButtonHeight">34</x:Double>
<x:Double x:Key="NavigationBackButtonWidth">40</x:Double>
<x:Double x:Key="NavigationBackButtonHeight">36</x:Double>

<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Dark">
Expand Down
64 changes: 33 additions & 31 deletions dev/NavigationView/NavigationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static constexpr int c_paneToggleButtonWidth = 40;
static constexpr int c_toggleButtonHeightWhenShouldPreserveNavigationViewRS3Behavior = 56;
static constexpr int c_backButtonRowDefinition = 1;
static constexpr float c_paneElevationTranslationZ = 32;
static constexpr int c_paneItemsSeparatorHeight = 21;
static constexpr int c_paneItemsSeparatorHeight = 9;

static constexpr int c_mainMenuBlockIndex = 0;
static constexpr int c_footerMenuBlockIndex = 1;
Expand Down Expand Up @@ -707,6 +707,7 @@ void NavigationView::OnApplyTemplate()
UpdateVisualState();
UpdatePaneTitleMargins();
UpdatePaneLayout();
UpdatePaneOverlayGroup();
}

void NavigationView::UpdateRepeaterItemsSource(bool forceSelectionModelUpdate)
Expand Down Expand Up @@ -1491,7 +1492,7 @@ void NavigationView::UpdatePaneLayout()
}();
auto availableHeight = paneContentRow.ActualHeight() - itemsContainerMargin;

// The -21 below is to account for the separator height that we need to subtract.
// The c_paneItemsSeparatorHeight is to account for the 9px separator height that we need to subtract.
if (PaneFooter())
{
availableHeight -= c_paneItemsSeparatorHeight;
Expand Down Expand Up @@ -1716,8 +1717,6 @@ void NavigationView::OnSplitViewPaneClosing(const winrt::DependencyObject& /*sen
winrt::VisualStateManager::GoToState(*this, L"ListSizeCompact", true /*useTransitions*/);
UpdatePaneToggleSize();
}

winrt::VisualStateManager::GoToState(*this, L"PaneNotOverlaying", true /*useTransitions*/);
}
}
}
Expand All @@ -1734,14 +1733,6 @@ void NavigationView::OnSplitViewPaneOpening(const winrt::DependencyObject& /*sen
{
// See UpdateIsClosedCompact 'RS3+ animation timing enhancement' for explanation:
winrt::VisualStateManager::GoToState(*this, L"ListSizeFull", true /*useTransitions*/);

if (const auto splitView = m_rootSplitView.get())
{
if (splitView.DisplayMode() == winrt::SplitViewDisplayMode::CompactOverlay || splitView.DisplayMode() == winrt::SplitViewDisplayMode::Overlay)
{
winrt::VisualStateManager::GoToState(*this, L"PaneOverlaying", true /*useTransitions*/);
}
}
}

m_paneOpeningEventSource(*this, nullptr);
Expand Down Expand Up @@ -1916,20 +1907,25 @@ void NavigationView::UpdatePaneTitleFrameworkElementParents()
{
const auto isPaneToggleButtonVisible = IsPaneToggleButtonVisible();
const auto isTopNavigationView = IsTopNavigationView();
const auto paneTitleSize = PaneTitle().size();

paneTitleHolderFrameworkElement.Visibility(
(isPaneToggleButtonVisible ||
isTopNavigationView ||
PaneTitle().size() == 0 ||
(PaneDisplayMode() == winrt::NavigationViewPaneDisplayMode::LeftMinimal && !IsPaneOpen())) ?
winrt::Visibility::Collapsed : winrt::Visibility::Visible);
m_isLeftPaneTitleEmpty = (isPaneToggleButtonVisible ||
isTopNavigationView ||
paneTitleSize == 0 ||
(PaneDisplayMode() == winrt::NavigationViewPaneDisplayMode::LeftMinimal && !IsPaneOpen()));

paneTitleHolderFrameworkElement.Visibility(m_isLeftPaneTitleEmpty ? winrt::Visibility::Collapsed : winrt::Visibility::Visible);

if (auto&& paneTitleFrameworkElement = m_paneTitleFrameworkElement.get())
{
const auto paneTitleTopPane = m_paneTitleOnTopPane.get();

const auto first = SetPaneTitleFrameworkElementParent(m_paneToggleButton.get(), paneTitleFrameworkElement, isTopNavigationView || !isPaneToggleButtonVisible);
const auto second = SetPaneTitleFrameworkElementParent(m_paneTitlePresenter.get(), paneTitleFrameworkElement, isTopNavigationView || isPaneToggleButtonVisible);
const auto third = SetPaneTitleFrameworkElementParent(m_paneTitleOnTopPane.get(), paneTitleFrameworkElement, !isTopNavigationView || isPaneToggleButtonVisible);
const auto third = SetPaneTitleFrameworkElementParent(paneTitleTopPane, paneTitleFrameworkElement, !isTopNavigationView || isPaneToggleButtonVisible);
first ? first() : second ? second() : third ? third() : []() {}();

paneTitleTopPane.Visibility(third && paneTitleSize != 0 ? winrt::Visibility::Visible : winrt::Visibility::Collapsed);
}
}
}
Expand Down Expand Up @@ -3361,7 +3357,7 @@ void NavigationView::UpdateVisualStateForOverflowButton()
void NavigationView::UpdateLeftNavigationOnlyVisualState(bool useTransitions)
{
const bool isToggleButtonVisible = IsPaneToggleButtonVisible();
winrt::VisualStateManager::GoToState(*this, isToggleButtonVisible ? L"TogglePaneButtonVisible" : L"TogglePaneButtonCollapsed", false /*useTransitions*/);
winrt::VisualStateManager::GoToState(*this, isToggleButtonVisible || !m_isLeftPaneTitleEmpty ? L"TogglePaneButtonVisible" : L"TogglePaneButtonCollapsed", false /*useTransitions*/);
}

void NavigationView::InvalidateTopNavPrimaryLayout()
Expand Down Expand Up @@ -4090,6 +4086,8 @@ void NavigationView::OnIsPaneOpenChanged()
UpdatePaneTabFocusNavigation();
UpdateSettingsItemToolTip();
UpdatePaneTitleFrameworkElementParents();
UpdatePaneOverlayGroup();
UpdatePaneButtonsWidths();

if (SharedHelpers::IsThemeShadowAvailable())
{
Expand Down Expand Up @@ -4120,8 +4118,6 @@ void NavigationView::OnIsPaneOpenChanged()
}
}
}

UpdatePaneButtonsWidths();
}

void NavigationView::UpdatePaneToggleButtonVisibility()
Expand Down Expand Up @@ -4458,15 +4454,6 @@ void NavigationView::UpdateBackAndCloseButtonsVisibility()
paneHeaderCloseButtonColumn.Width(winrt::GridLengthHelper::FromValueAndType(paneHeaderPaddingForCloseButton, winrt::GridUnitType::Pixel));
}

if (auto paneTitleHolderFrameworkElement = m_paneTitleHolderFrameworkElement.get())
{
if (paneHeaderContentBorderRowMinHeight == 0.00 && paneTitleHolderFrameworkElement.Visibility() == winrt::Visibility::Visible)
{
// Handling the case where the PaneTottleButton is collapsed and the PaneTitle's height needs to push the rest of the NavigationView's UI down.
paneHeaderContentBorderRowMinHeight = paneTitleHolderFrameworkElement.ActualHeight();
}
}

if (auto paneHeaderContentBorderRow = m_paneHeaderContentBorderRow.get())
{
paneHeaderContentBorderRow.MinHeight(paneHeaderContentBorderRowMinHeight);
Expand Down Expand Up @@ -4868,6 +4855,21 @@ void NavigationView::UpdatePaneShadow()
}
}

void NavigationView::UpdatePaneOverlayGroup()
{
if (const auto splitView = m_rootSplitView.get())
{
if (IsPaneOpen() && (splitView.DisplayMode() == winrt::SplitViewDisplayMode::CompactOverlay || splitView.DisplayMode() == winrt::SplitViewDisplayMode::Overlay))
{
winrt::VisualStateManager::GoToState(*this, L"PaneOverlaying", true /*useTransitions*/);
}
else
{
winrt::VisualStateManager::GoToState(*this, L"PaneNotOverlaying", true /*useTransitions*/);
}
}
}

template<typename T> T NavigationView::GetContainerForData(const winrt::IInspectable& data)
{
if (!data)
Expand Down
3 changes: 3 additions & 0 deletions dev/NavigationView/NavigationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class NavigationView :
void UpdateVisualStateForOverflowButton();
void UpdateLeftNavigationOnlyVisualState(bool useTransitions);
void UpdatePaneShadow();
void UpdatePaneOverlayGroup();
void UpdateNavigationViewItemsFactory();
void SyncItemTemplates();
bool IsRootGridOfFlyout(const winrt::DependencyObject& element);
Expand Down Expand Up @@ -496,5 +497,7 @@ class NavigationView :
bool m_OrientationChangedPendingAnimation{ false };

bool m_TabKeyPrecedesFocusChange{ false };

bool m_isLeftPaneTitleEmpty{ false };
};

Loading