Skip to content

Commit

Permalink
Navigation View Visual Update (#4009)
Browse files Browse the repository at this point in the history
* update brushes

* update NavViewItems

* navView items visual update

* panelToggle and back button

* adjust icon width when compact left

* fix rebase

* update pane closed layout

* fix toggleButton cutoff

* top nav visual update

* fix bad rebase

* remove reveal style

* revert c_BackButtonHeight changes

* add templateSettings properties

* update latest style with template setting prop

* bind old style to templateSettings

* bind NavView item presenter icon column wip

* add itemPresenter TemplateSettings and bind to latest style

* bind to old style + cleanup

* top nav coloring fix

* fix failing tests WIP

* fix failing tests

* fetch new verification files

* update verification files

* update verificationt files

* fix failing tests

* fix failing test

* fix test

* fix syntax
  • Loading branch information
karkarl authored Feb 12, 2021
1 parent 58849ae commit 6bdf738
Show file tree
Hide file tree
Showing 72 changed files with 45,303 additions and 7,731 deletions.
2 changes: 1 addition & 1 deletion dev/CommonStyles/TestUI/CompactPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void RunTest_Click(object sender, RoutedEventArgs e)
item = TreeView.FindVisualChildByType<TreeViewItem>();
VerifyHeight(simpleVerify, item, 24, "TreeViewItem");

VerifyHeight(simpleVerify, NavItem1, 32, "NavigationViewItem");
VerifyHeight(simpleVerify, NavItem1, 36, "NavigationViewItem");

VerifyChildHeight(simpleVerify, TextBox, "BorderElement", 24, "TextBox");
VerifyChildHeight(simpleVerify, PasswordBox, "BorderElement", 24, "PasswordBox");
Expand Down
26 changes: 26 additions & 0 deletions dev/Generated/NavigationViewItemPresenter.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace winrt::Microsoft::UI::Xaml::Controls::Primitives
#include "NavigationViewItemPresenter.g.cpp"

GlobalDependencyProperty NavigationViewItemPresenterProperties::s_IconProperty{ nullptr };
GlobalDependencyProperty NavigationViewItemPresenterProperties::s_TemplateSettingsProperty{ nullptr };

NavigationViewItemPresenterProperties::NavigationViewItemPresenterProperties()
{
Expand All @@ -33,11 +34,23 @@ void NavigationViewItemPresenterProperties::EnsureProperties()
ValueHelper<winrt::IconElement>::BoxedDefaultValue(),
nullptr);
}
if (!s_TemplateSettingsProperty)
{
s_TemplateSettingsProperty =
InitializeDependencyProperty(
L"TemplateSettings",
winrt::name_of<winrt::NavigationViewItemPresenterTemplateSettings>(),
winrt::name_of<winrt::NavigationViewItemPresenter>(),
false /* isAttached */,
ValueHelper<winrt::NavigationViewItemPresenterTemplateSettings>::BoxedDefaultValue(),
nullptr);
}
}

void NavigationViewItemPresenterProperties::ClearProperties()
{
s_IconProperty = nullptr;
s_TemplateSettingsProperty = nullptr;
}

void NavigationViewItemPresenterProperties::Icon(winrt::IconElement const& value)
Expand All @@ -52,3 +65,16 @@ winrt::IconElement NavigationViewItemPresenterProperties::Icon()
{
return ValueHelper<winrt::IconElement>::CastOrUnbox(static_cast<NavigationViewItemPresenter*>(this)->GetValue(s_IconProperty));
}

void NavigationViewItemPresenterProperties::TemplateSettings(winrt::NavigationViewItemPresenterTemplateSettings const& value)
{
[[gsl::suppress(con)]]
{
static_cast<NavigationViewItemPresenter*>(this)->SetValue(s_TemplateSettingsProperty, ValueHelper<winrt::NavigationViewItemPresenterTemplateSettings>::BoxValueIfNecessary(value));
}
}

winrt::NavigationViewItemPresenterTemplateSettings NavigationViewItemPresenterProperties::TemplateSettings()
{
return ValueHelper<winrt::NavigationViewItemPresenterTemplateSettings>::CastOrUnbox(static_cast<NavigationViewItemPresenter*>(this)->GetValue(s_TemplateSettingsProperty));
}
5 changes: 5 additions & 0 deletions dev/Generated/NavigationViewItemPresenter.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ class NavigationViewItemPresenterProperties
void Icon(winrt::IconElement const& value);
winrt::IconElement Icon();

void TemplateSettings(winrt::NavigationViewItemPresenterTemplateSettings const& value);
winrt::NavigationViewItemPresenterTemplateSettings TemplateSettings();

static winrt::DependencyProperty IconProperty() { return s_IconProperty; }
static winrt::DependencyProperty TemplateSettingsProperty() { return s_TemplateSettingsProperty; }

static GlobalDependencyProperty s_IconProperty;
static GlobalDependencyProperty s_TemplateSettingsProperty;

static void EnsureProperties();
static void ClearProperties();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen
#include "pch.h"
#include "common.h"
#include "NavigationViewItemPresenterTemplateSettings.h"

namespace winrt::Microsoft::UI::Xaml::Controls::Primitives
{
CppWinRTActivatableClassWithDPFactory(NavigationViewItemPresenterTemplateSettings)
}

#include "NavigationViewItemPresenterTemplateSettings.g.cpp"

GlobalDependencyProperty NavigationViewItemPresenterTemplateSettingsProperties::s_IconColumnWidthProperty{ nullptr };
GlobalDependencyProperty NavigationViewItemPresenterTemplateSettingsProperties::s_LatestIconColumnWidthProperty{ nullptr };

NavigationViewItemPresenterTemplateSettingsProperties::NavigationViewItemPresenterTemplateSettingsProperties()
{
EnsureProperties();
}

void NavigationViewItemPresenterTemplateSettingsProperties::EnsureProperties()
{
if (!s_IconColumnWidthProperty)
{
s_IconColumnWidthProperty =
InitializeDependencyProperty(
L"IconColumnWidth",
winrt::name_of<double>(),
winrt::name_of<winrt::NavigationViewItemPresenterTemplateSettings>(),
false /* isAttached */,
ValueHelper<double>::BoxedDefaultValue(),
nullptr);
}
if (!s_LatestIconColumnWidthProperty)
{
s_LatestIconColumnWidthProperty =
InitializeDependencyProperty(
L"LatestIconColumnWidth",
winrt::name_of<double>(),
winrt::name_of<winrt::NavigationViewItemPresenterTemplateSettings>(),
false /* isAttached */,
ValueHelper<double>::BoxedDefaultValue(),
nullptr);
}
}

void NavigationViewItemPresenterTemplateSettingsProperties::ClearProperties()
{
s_IconColumnWidthProperty = nullptr;
s_LatestIconColumnWidthProperty = nullptr;
}

void NavigationViewItemPresenterTemplateSettingsProperties::IconColumnWidth(double value)
{
[[gsl::suppress(con)]]
{
static_cast<NavigationViewItemPresenterTemplateSettings*>(this)->SetValue(s_IconColumnWidthProperty, ValueHelper<double>::BoxValueIfNecessary(value));
}
}

double NavigationViewItemPresenterTemplateSettingsProperties::IconColumnWidth()
{
return ValueHelper<double>::CastOrUnbox(static_cast<NavigationViewItemPresenterTemplateSettings*>(this)->GetValue(s_IconColumnWidthProperty));
}

void NavigationViewItemPresenterTemplateSettingsProperties::LatestIconColumnWidth(double value)
{
[[gsl::suppress(con)]]
{
static_cast<NavigationViewItemPresenterTemplateSettings*>(this)->SetValue(s_LatestIconColumnWidthProperty, ValueHelper<double>::BoxValueIfNecessary(value));
}
}

double NavigationViewItemPresenterTemplateSettingsProperties::LatestIconColumnWidth()
{
return ValueHelper<double>::CastOrUnbox(static_cast<NavigationViewItemPresenterTemplateSettings*>(this)->GetValue(s_LatestIconColumnWidthProperty));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen
#pragma once

class NavigationViewItemPresenterTemplateSettingsProperties
{
public:
NavigationViewItemPresenterTemplateSettingsProperties();

void IconColumnWidth(double value);
double IconColumnWidth();

void LatestIconColumnWidth(double value);
double LatestIconColumnWidth();

static winrt::DependencyProperty IconColumnWidthProperty() { return s_IconColumnWidthProperty; }
static winrt::DependencyProperty LatestIconColumnWidthProperty() { return s_LatestIconColumnWidthProperty; }

static GlobalDependencyProperty s_IconColumnWidthProperty;
static GlobalDependencyProperty s_LatestIconColumnWidthProperty;

static void EnsureProperties();
static void ClearProperties();
};
52 changes: 52 additions & 0 deletions dev/Generated/NavigationViewTemplateSettings.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ namespace winrt::Microsoft::UI::Xaml::Controls
#include "NavigationViewTemplateSettings.g.cpp"

GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_BackButtonVisibilityProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_LatestPaneButtonWidthProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_LeftPaneVisibilityProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_OverflowButtonVisibilityProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_PaneButtonWidthProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_PaneToggleButtonVisibilityProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_SingleSelectionFollowsFocusProperty{ nullptr };
GlobalDependencyProperty NavigationViewTemplateSettingsProperties::s_TopPaddingProperty{ nullptr };
Expand All @@ -39,6 +41,17 @@ void NavigationViewTemplateSettingsProperties::EnsureProperties()
ValueHelper<winrt::Visibility>::BoxValueIfNecessary(winrt::Visibility::Collapsed),
nullptr);
}
if (!s_LatestPaneButtonWidthProperty)
{
s_LatestPaneButtonWidthProperty =
InitializeDependencyProperty(
L"LatestPaneButtonWidth",
winrt::name_of<double>(),
winrt::name_of<winrt::NavigationViewTemplateSettings>(),
false /* isAttached */,
ValueHelper<double>::BoxedDefaultValue(),
nullptr);
}
if (!s_LeftPaneVisibilityProperty)
{
s_LeftPaneVisibilityProperty =
Expand All @@ -61,6 +74,17 @@ void NavigationViewTemplateSettingsProperties::EnsureProperties()
ValueHelper<winrt::Visibility>::BoxValueIfNecessary(winrt::Visibility::Collapsed),
nullptr);
}
if (!s_PaneButtonWidthProperty)
{
s_PaneButtonWidthProperty =
InitializeDependencyProperty(
L"PaneButtonWidth",
winrt::name_of<double>(),
winrt::name_of<winrt::NavigationViewTemplateSettings>(),
false /* isAttached */,
ValueHelper<double>::BoxedDefaultValue(),
nullptr);
}
if (!s_PaneToggleButtonVisibilityProperty)
{
s_PaneToggleButtonVisibilityProperty =
Expand Down Expand Up @@ -110,8 +134,10 @@ void NavigationViewTemplateSettingsProperties::EnsureProperties()
void NavigationViewTemplateSettingsProperties::ClearProperties()
{
s_BackButtonVisibilityProperty = nullptr;
s_LatestPaneButtonWidthProperty = nullptr;
s_LeftPaneVisibilityProperty = nullptr;
s_OverflowButtonVisibilityProperty = nullptr;
s_PaneButtonWidthProperty = nullptr;
s_PaneToggleButtonVisibilityProperty = nullptr;
s_SingleSelectionFollowsFocusProperty = nullptr;
s_TopPaddingProperty = nullptr;
Expand All @@ -131,6 +157,19 @@ winrt::Visibility NavigationViewTemplateSettingsProperties::BackButtonVisibility
return ValueHelper<winrt::Visibility>::CastOrUnbox(static_cast<NavigationViewTemplateSettings*>(this)->GetValue(s_BackButtonVisibilityProperty));
}

void NavigationViewTemplateSettingsProperties::LatestPaneButtonWidth(double value)
{
[[gsl::suppress(con)]]
{
static_cast<NavigationViewTemplateSettings*>(this)->SetValue(s_LatestPaneButtonWidthProperty, ValueHelper<double>::BoxValueIfNecessary(value));
}
}

double NavigationViewTemplateSettingsProperties::LatestPaneButtonWidth()
{
return ValueHelper<double>::CastOrUnbox(static_cast<NavigationViewTemplateSettings*>(this)->GetValue(s_LatestPaneButtonWidthProperty));
}

void NavigationViewTemplateSettingsProperties::LeftPaneVisibility(winrt::Visibility const& value)
{
[[gsl::suppress(con)]]
Expand All @@ -157,6 +196,19 @@ winrt::Visibility NavigationViewTemplateSettingsProperties::OverflowButtonVisibi
return ValueHelper<winrt::Visibility>::CastOrUnbox(static_cast<NavigationViewTemplateSettings*>(this)->GetValue(s_OverflowButtonVisibilityProperty));
}

void NavigationViewTemplateSettingsProperties::PaneButtonWidth(double value)
{
[[gsl::suppress(con)]]
{
static_cast<NavigationViewTemplateSettings*>(this)->SetValue(s_PaneButtonWidthProperty, ValueHelper<double>::BoxValueIfNecessary(value));
}
}

double NavigationViewTemplateSettingsProperties::PaneButtonWidth()
{
return ValueHelper<double>::CastOrUnbox(static_cast<NavigationViewTemplateSettings*>(this)->GetValue(s_PaneButtonWidthProperty));
}

void NavigationViewTemplateSettingsProperties::PaneToggleButtonVisibility(winrt::Visibility const& value)
{
[[gsl::suppress(con)]]
Expand Down
10 changes: 10 additions & 0 deletions dev/Generated/NavigationViewTemplateSettings.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ class NavigationViewTemplateSettingsProperties
void BackButtonVisibility(winrt::Visibility const& value);
winrt::Visibility BackButtonVisibility();

void LatestPaneButtonWidth(double value);
double LatestPaneButtonWidth();

void LeftPaneVisibility(winrt::Visibility const& value);
winrt::Visibility LeftPaneVisibility();

void OverflowButtonVisibility(winrt::Visibility const& value);
winrt::Visibility OverflowButtonVisibility();

void PaneButtonWidth(double value);
double PaneButtonWidth();

void PaneToggleButtonVisibility(winrt::Visibility const& value);
winrt::Visibility PaneToggleButtonVisibility();

Expand All @@ -31,16 +37,20 @@ class NavigationViewTemplateSettingsProperties
winrt::Visibility TopPaneVisibility();

static winrt::DependencyProperty BackButtonVisibilityProperty() { return s_BackButtonVisibilityProperty; }
static winrt::DependencyProperty LatestPaneButtonWidthProperty() { return s_LatestPaneButtonWidthProperty; }
static winrt::DependencyProperty LeftPaneVisibilityProperty() { return s_LeftPaneVisibilityProperty; }
static winrt::DependencyProperty OverflowButtonVisibilityProperty() { return s_OverflowButtonVisibilityProperty; }
static winrt::DependencyProperty PaneButtonWidthProperty() { return s_PaneButtonWidthProperty; }
static winrt::DependencyProperty PaneToggleButtonVisibilityProperty() { return s_PaneToggleButtonVisibilityProperty; }
static winrt::DependencyProperty SingleSelectionFollowsFocusProperty() { return s_SingleSelectionFollowsFocusProperty; }
static winrt::DependencyProperty TopPaddingProperty() { return s_TopPaddingProperty; }
static winrt::DependencyProperty TopPaneVisibilityProperty() { return s_TopPaneVisibilityProperty; }

static GlobalDependencyProperty s_BackButtonVisibilityProperty;
static GlobalDependencyProperty s_LatestPaneButtonWidthProperty;
static GlobalDependencyProperty s_LeftPaneVisibilityProperty;
static GlobalDependencyProperty s_OverflowButtonVisibilityProperty;
static GlobalDependencyProperty s_PaneButtonWidthProperty;
static GlobalDependencyProperty s_PaneToggleButtonVisibilityProperty;
static GlobalDependencyProperty s_SingleSelectionFollowsFocusProperty;
static GlobalDependencyProperty s_TopPaddingProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ public void CoreWindowEventsTests()
}

[TestMethod]
[TestProperty("Ignore", "True")] // Disabling as Reveal Brush is being deprecated
public void RevealBrushFromMarkup()
{
if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
Expand Down
13 changes: 10 additions & 3 deletions dev/NavigationView/NavigationBackButton.xaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)"
xmlns:contract7NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,7)">

<Style x:Key="NavigationBackButtonNormalStyle" TargetType="Button">
<Setter Property="Background" Value="{ThemeResource NavigationViewBackButtonBackground}" />
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="Foreground" Value="{ThemeResource NavigationViewItemForeground}" />
<Setter Property="FontFamily" Value="{ThemeResource SymbolThemeFontFamily}" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Height" Value="{ThemeResource NavigationBackButtonHeight}" />
Expand All @@ -14,10 +16,15 @@
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
<Setter Property="Content" Value="&#xE72B;" />
<Setter Property="Margin" Value="4,2" />
<contract7Present:Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="RootGrid" Background="{TemplateBinding Background}">
<Grid x:Name="RootGrid"
Background="{TemplateBinding Background}"
contract7Present:CornerRadius="{TemplateBinding CornerRadius}"
contract7NotPresent:CornerRadius="{ThemeResource OverlayCornerRadius}">

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
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">40</x:Double>
<x:Double x:Key="NavigationBackButtonHeight">40</x:Double>
<x:Double x:Key="NavigationBackButtonWidth">38</x:Double>
<x:Double x:Key="NavigationBackButtonHeight">34</x:Double>

<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Dark">
Expand Down
Loading

0 comments on commit 6bdf738

Please sign in to comment.