Skip to content

Commit

Permalink
Hierarchical Navigation View (#2004)
Browse files Browse the repository at this point in the history
* automation peer fixes

* hnav core functionality

* hooked up expanding and collapse events

* fix indicator animation and file formatting

* moved get parentnvi functiont to nv

* updated indentation

* added flyout closing logic, updated isChildSelected logic

* added flyout header

* addressed comments

* added chevron to NVI (non-animating)

* added tests, fixed overflow parent selection

* animations and bug fixes

- added selection indicator and chevron animations
- fixed bugs in icon content, overflow selection, closing flyout

* fixed some tests

* fixed tests, fixed header, updated separator

* fixed and updated tests

* updated masters, clean up, disabled test

* re-enable interaction test, updated scrolling masters

* addressed some comments

* addressed more comments

* removed flyout title content presenter

* clean up, top nav chevron update

* masters update

Co-authored-by: Ranjesh <[email protected]>
  • Loading branch information
ojhad and ranjeshj authored Mar 22, 2020
1 parent 768854a commit 5d444b6
Show file tree
Hide file tree
Showing 60 changed files with 19,496 additions and 6,334 deletions.
22 changes: 22 additions & 0 deletions dev/Generated/NavigationView.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ GlobalDependencyProperty NavigationViewProperties::s_TemplateSettingsProperty{ n

NavigationViewProperties::NavigationViewProperties()
: m_backRequestedEventSource{static_cast<NavigationView*>(this)}
, m_collapsedEventSource{static_cast<NavigationView*>(this)}
, m_displayModeChangedEventSource{static_cast<NavigationView*>(this)}
, m_expandingEventSource{static_cast<NavigationView*>(this)}
, m_itemInvokedEventSource{static_cast<NavigationView*>(this)}
, m_paneClosedEventSource{static_cast<NavigationView*>(this)}
, m_paneClosingEventSource{static_cast<NavigationView*>(this)}
Expand Down Expand Up @@ -1146,6 +1148,16 @@ void NavigationViewProperties::BackRequested(winrt::event_token const& token)
m_backRequestedEventSource.remove(token);
}

winrt::event_token NavigationViewProperties::Collapsed(winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewCollapsedEventArgs> const& value)
{
return m_collapsedEventSource.add(value);
}

void NavigationViewProperties::Collapsed(winrt::event_token const& token)
{
m_collapsedEventSource.remove(token);
}

winrt::event_token NavigationViewProperties::DisplayModeChanged(winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewDisplayModeChangedEventArgs> const& value)
{
return m_displayModeChangedEventSource.add(value);
Expand All @@ -1156,6 +1168,16 @@ void NavigationViewProperties::DisplayModeChanged(winrt::event_token const& toke
m_displayModeChangedEventSource.remove(token);
}

winrt::event_token NavigationViewProperties::Expanding(winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewExpandingEventArgs> const& value)
{
return m_expandingEventSource.add(value);
}

void NavigationViewProperties::Expanding(winrt::event_token const& token)
{
m_expandingEventSource.remove(token);
}

winrt::event_token NavigationViewProperties::ItemInvoked(winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewItemInvokedEventArgs> const& value)
{
return m_itemInvokedEventSource.add(value);
Expand Down
6 changes: 6 additions & 0 deletions dev/Generated/NavigationView.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,12 @@ class NavigationViewProperties

winrt::event_token BackRequested(winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewBackRequestedEventArgs> const& value);
void BackRequested(winrt::event_token const& token);
winrt::event_token Collapsed(winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewCollapsedEventArgs> const& value);
void Collapsed(winrt::event_token const& token);
winrt::event_token DisplayModeChanged(winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewDisplayModeChangedEventArgs> const& value);
void DisplayModeChanged(winrt::event_token const& token);
winrt::event_token Expanding(winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewExpandingEventArgs> const& value);
void Expanding(winrt::event_token const& token);
winrt::event_token ItemInvoked(winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewItemInvokedEventArgs> const& value);
void ItemInvoked(winrt::event_token const& token);
winrt::event_token PaneClosed(winrt::TypedEventHandler<winrt::NavigationView, winrt::IInspectable> const& value);
Expand All @@ -204,7 +208,9 @@ class NavigationViewProperties
void SelectionChanged(winrt::event_token const& token);

event_source<winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewBackRequestedEventArgs>> m_backRequestedEventSource;
event_source<winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewCollapsedEventArgs>> m_collapsedEventSource;
event_source<winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewDisplayModeChangedEventArgs>> m_displayModeChangedEventSource;
event_source<winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewExpandingEventArgs>> m_expandingEventSource;
event_source<winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewItemInvokedEventArgs>> m_itemInvokedEventSource;
event_source<winrt::TypedEventHandler<winrt::NavigationView, winrt::IInspectable>> m_paneClosedEventSource;
event_source<winrt::TypedEventHandler<winrt::NavigationView, winrt::NavigationViewPaneClosingEventArgs>> m_paneClosingEventSource;
Expand Down
141 changes: 141 additions & 0 deletions dev/Generated/NavigationViewItem.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ namespace winrt::Microsoft::UI::Xaml::Controls
#include "NavigationViewItem.g.cpp"

GlobalDependencyProperty NavigationViewItemProperties::s_CompactPaneLengthProperty{ nullptr };
GlobalDependencyProperty NavigationViewItemProperties::s_HasUnrealizedChildrenProperty{ nullptr };
GlobalDependencyProperty NavigationViewItemProperties::s_IconProperty{ nullptr };
GlobalDependencyProperty NavigationViewItemProperties::s_IsChildSelectedProperty{ nullptr };
GlobalDependencyProperty NavigationViewItemProperties::s_IsExpandedProperty{ nullptr };
GlobalDependencyProperty NavigationViewItemProperties::s_MenuItemsProperty{ nullptr };
GlobalDependencyProperty NavigationViewItemProperties::s_MenuItemsSourceProperty{ nullptr };
GlobalDependencyProperty NavigationViewItemProperties::s_SelectsOnInvokedProperty{ nullptr };

NavigationViewItemProperties::NavigationViewItemProperties()
Expand All @@ -24,6 +29,7 @@ NavigationViewItemProperties::NavigationViewItemProperties()

void NavigationViewItemProperties::EnsureProperties()
{
NavigationViewItemBase::EnsureProperties();
if (!s_CompactPaneLengthProperty)
{
s_CompactPaneLengthProperty =
Expand All @@ -35,6 +41,17 @@ void NavigationViewItemProperties::EnsureProperties()
ValueHelper<double>::BoxValueIfNecessary(48.0),
nullptr);
}
if (!s_HasUnrealizedChildrenProperty)
{
s_HasUnrealizedChildrenProperty =
InitializeDependencyProperty(
L"HasUnrealizedChildren",
winrt::name_of<bool>(),
winrt::name_of<winrt::NavigationViewItem>(),
false /* isAttached */,
ValueHelper<bool>::BoxValueIfNecessary(false),
winrt::PropertyChangedCallback(&OnHasUnrealizedChildrenPropertyChanged));
}
if (!s_IconProperty)
{
s_IconProperty =
Expand All @@ -46,6 +63,50 @@ void NavigationViewItemProperties::EnsureProperties()
ValueHelper<winrt::IconElement>::BoxedDefaultValue(),
winrt::PropertyChangedCallback(&OnIconPropertyChanged));
}
if (!s_IsChildSelectedProperty)
{
s_IsChildSelectedProperty =
InitializeDependencyProperty(
L"IsChildSelected",
winrt::name_of<bool>(),
winrt::name_of<winrt::NavigationViewItem>(),
false /* isAttached */,
ValueHelper<bool>::BoxValueIfNecessary(false),
nullptr);
}
if (!s_IsExpandedProperty)
{
s_IsExpandedProperty =
InitializeDependencyProperty(
L"IsExpanded",
winrt::name_of<bool>(),
winrt::name_of<winrt::NavigationViewItem>(),
false /* isAttached */,
ValueHelper<bool>::BoxValueIfNecessary(false),
nullptr);
}
if (!s_MenuItemsProperty)
{
s_MenuItemsProperty =
InitializeDependencyProperty(
L"MenuItems",
winrt::name_of<winrt::IVector<winrt::IInspectable>>(),
winrt::name_of<winrt::NavigationViewItem>(),
false /* isAttached */,
ValueHelper<winrt::IVector<winrt::IInspectable>>::BoxedDefaultValue(),
winrt::PropertyChangedCallback(&OnMenuItemsPropertyChanged));
}
if (!s_MenuItemsSourceProperty)
{
s_MenuItemsSourceProperty =
InitializeDependencyProperty(
L"MenuItemsSource",
winrt::name_of<winrt::IInspectable>(),
winrt::name_of<winrt::NavigationViewItem>(),
false /* isAttached */,
ValueHelper<winrt::IInspectable>::BoxedDefaultValue(),
winrt::PropertyChangedCallback(&OnMenuItemsSourcePropertyChanged));
}
if (!s_SelectsOnInvokedProperty)
{
s_SelectsOnInvokedProperty =
Expand All @@ -62,8 +123,22 @@ void NavigationViewItemProperties::EnsureProperties()
void NavigationViewItemProperties::ClearProperties()
{
s_CompactPaneLengthProperty = nullptr;
s_HasUnrealizedChildrenProperty = nullptr;
s_IconProperty = nullptr;
s_IsChildSelectedProperty = nullptr;
s_IsExpandedProperty = nullptr;
s_MenuItemsProperty = nullptr;
s_MenuItemsSourceProperty = nullptr;
s_SelectsOnInvokedProperty = nullptr;
NavigationViewItemBase::ClearProperties();
}

void NavigationViewItemProperties::OnHasUnrealizedChildrenPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
{
auto owner = sender.as<winrt::NavigationViewItem>();
winrt::get_self<NavigationViewItem>(owner)->OnHasUnrealizedChildrenPropertyChanged(args);
}

void NavigationViewItemProperties::OnIconPropertyChanged(
Expand All @@ -74,6 +149,22 @@ void NavigationViewItemProperties::OnIconPropertyChanged(
winrt::get_self<NavigationViewItem>(owner)->OnIconPropertyChanged(args);
}

void NavigationViewItemProperties::OnMenuItemsPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
{
auto owner = sender.as<winrt::NavigationViewItem>();
winrt::get_self<NavigationViewItem>(owner)->OnMenuItemsPropertyChanged(args);
}

void NavigationViewItemProperties::OnMenuItemsSourcePropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
{
auto owner = sender.as<winrt::NavigationViewItem>();
winrt::get_self<NavigationViewItem>(owner)->OnMenuItemsSourcePropertyChanged(args);
}

void NavigationViewItemProperties::CompactPaneLength(double value)
{
static_cast<NavigationViewItem*>(this)->SetValue(s_CompactPaneLengthProperty, ValueHelper<double>::BoxValueIfNecessary(value));
Expand All @@ -84,6 +175,16 @@ double NavigationViewItemProperties::CompactPaneLength()
return ValueHelper<double>::CastOrUnbox(static_cast<NavigationViewItem*>(this)->GetValue(s_CompactPaneLengthProperty));
}

void NavigationViewItemProperties::HasUnrealizedChildren(bool value)
{
static_cast<NavigationViewItem*>(this)->SetValue(s_HasUnrealizedChildrenProperty, ValueHelper<bool>::BoxValueIfNecessary(value));
}

bool NavigationViewItemProperties::HasUnrealizedChildren()
{
return ValueHelper<bool>::CastOrUnbox(static_cast<NavigationViewItem*>(this)->GetValue(s_HasUnrealizedChildrenProperty));
}

void NavigationViewItemProperties::Icon(winrt::IconElement const& value)
{
static_cast<NavigationViewItem*>(this)->SetValue(s_IconProperty, ValueHelper<winrt::IconElement>::BoxValueIfNecessary(value));
Expand All @@ -94,6 +195,46 @@ winrt::IconElement NavigationViewItemProperties::Icon()
return ValueHelper<winrt::IconElement>::CastOrUnbox(static_cast<NavigationViewItem*>(this)->GetValue(s_IconProperty));
}

void NavigationViewItemProperties::IsChildSelected(bool value)
{
static_cast<NavigationViewItem*>(this)->SetValue(s_IsChildSelectedProperty, ValueHelper<bool>::BoxValueIfNecessary(value));
}

bool NavigationViewItemProperties::IsChildSelected()
{
return ValueHelper<bool>::CastOrUnbox(static_cast<NavigationViewItem*>(this)->GetValue(s_IsChildSelectedProperty));
}

void NavigationViewItemProperties::IsExpanded(bool value)
{
static_cast<NavigationViewItem*>(this)->SetValue(s_IsExpandedProperty, ValueHelper<bool>::BoxValueIfNecessary(value));
}

bool NavigationViewItemProperties::IsExpanded()
{
return ValueHelper<bool>::CastOrUnbox(static_cast<NavigationViewItem*>(this)->GetValue(s_IsExpandedProperty));
}

void NavigationViewItemProperties::MenuItems(winrt::IVector<winrt::IInspectable> const& value)
{
static_cast<NavigationViewItem*>(this)->SetValue(s_MenuItemsProperty, ValueHelper<winrt::IVector<winrt::IInspectable>>::BoxValueIfNecessary(value));
}

winrt::IVector<winrt::IInspectable> NavigationViewItemProperties::MenuItems()
{
return ValueHelper<winrt::IVector<winrt::IInspectable>>::CastOrUnbox(static_cast<NavigationViewItem*>(this)->GetValue(s_MenuItemsProperty));
}

void NavigationViewItemProperties::MenuItemsSource(winrt::IInspectable const& value)
{
static_cast<NavigationViewItem*>(this)->SetValue(s_MenuItemsSourceProperty, ValueHelper<winrt::IInspectable>::BoxValueIfNecessary(value));
}

winrt::IInspectable NavigationViewItemProperties::MenuItemsSource()
{
return ValueHelper<winrt::IInspectable>::CastOrUnbox(static_cast<NavigationViewItem*>(this)->GetValue(s_MenuItemsSourceProperty));
}

void NavigationViewItemProperties::SelectsOnInvoked(bool value)
{
static_cast<NavigationViewItem*>(this)->SetValue(s_SelectsOnInvokedProperty, ValueHelper<bool>::BoxValueIfNecessary(value));
Expand Down
37 changes: 37 additions & 0 deletions dev/Generated/NavigationViewItem.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,61 @@ class NavigationViewItemProperties
void CompactPaneLength(double value);
double CompactPaneLength();

void HasUnrealizedChildren(bool value);
bool HasUnrealizedChildren();

void Icon(winrt::IconElement const& value);
winrt::IconElement Icon();

void IsChildSelected(bool value);
bool IsChildSelected();

void IsExpanded(bool value);
bool IsExpanded();

void MenuItems(winrt::IVector<winrt::IInspectable> const& value);
winrt::IVector<winrt::IInspectable> MenuItems();

void MenuItemsSource(winrt::IInspectable const& value);
winrt::IInspectable MenuItemsSource();

void SelectsOnInvoked(bool value);
bool SelectsOnInvoked();

static winrt::DependencyProperty CompactPaneLengthProperty() { return s_CompactPaneLengthProperty; }
static winrt::DependencyProperty HasUnrealizedChildrenProperty() { return s_HasUnrealizedChildrenProperty; }
static winrt::DependencyProperty IconProperty() { return s_IconProperty; }
static winrt::DependencyProperty IsChildSelectedProperty() { return s_IsChildSelectedProperty; }
static winrt::DependencyProperty IsExpandedProperty() { return s_IsExpandedProperty; }
static winrt::DependencyProperty MenuItemsProperty() { return s_MenuItemsProperty; }
static winrt::DependencyProperty MenuItemsSourceProperty() { return s_MenuItemsSourceProperty; }
static winrt::DependencyProperty SelectsOnInvokedProperty() { return s_SelectsOnInvokedProperty; }

static GlobalDependencyProperty s_CompactPaneLengthProperty;
static GlobalDependencyProperty s_HasUnrealizedChildrenProperty;
static GlobalDependencyProperty s_IconProperty;
static GlobalDependencyProperty s_IsChildSelectedProperty;
static GlobalDependencyProperty s_IsExpandedProperty;
static GlobalDependencyProperty s_MenuItemsProperty;
static GlobalDependencyProperty s_MenuItemsSourceProperty;
static GlobalDependencyProperty s_SelectsOnInvokedProperty;

static void EnsureProperties();
static void ClearProperties();

static void OnHasUnrealizedChildrenPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);

static void OnIconPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);

static void OnMenuItemsPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);

static void OnMenuItemsSourcePropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);
};
37 changes: 36 additions & 1 deletion dev/Generated/NavigationViewItemBase.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,44 @@

namespace winrt::Microsoft::UI::Xaml::Controls
{
CppWinRTActivatableClassWithBasicFactory(NavigationViewItemBase)
CppWinRTActivatableClassWithDPFactory(NavigationViewItemBase)
}

#include "NavigationViewItemBase.g.cpp"

GlobalDependencyProperty NavigationViewItemBaseProperties::s_IsSelectedProperty{ nullptr };

NavigationViewItemBaseProperties::NavigationViewItemBaseProperties()
{
EnsureProperties();
}

void NavigationViewItemBaseProperties::EnsureProperties()
{
if (!s_IsSelectedProperty)
{
s_IsSelectedProperty =
InitializeDependencyProperty(
L"IsSelected",
winrt::name_of<bool>(),
winrt::name_of<winrt::NavigationViewItemBase>(),
false /* isAttached */,
ValueHelper<bool>::BoxedDefaultValue(),
nullptr);
}
}

void NavigationViewItemBaseProperties::ClearProperties()
{
s_IsSelectedProperty = nullptr;
}

void NavigationViewItemBaseProperties::IsSelected(bool value)
{
static_cast<NavigationViewItemBase*>(this)->SetValue(s_IsSelectedProperty, ValueHelper<bool>::BoxValueIfNecessary(value));
}

bool NavigationViewItemBaseProperties::IsSelected()
{
return ValueHelper<bool>::CastOrUnbox(static_cast<NavigationViewItemBase*>(this)->GetValue(s_IsSelectedProperty));
}
21 changes: 21 additions & 0 deletions dev/Generated/NavigationViewItemBase.properties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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 NavigationViewItemBaseProperties
{
public:
NavigationViewItemBaseProperties();

void IsSelected(bool value);
bool IsSelected();

static winrt::DependencyProperty IsSelectedProperty() { return s_IsSelectedProperty; }

static GlobalDependencyProperty s_IsSelectedProperty;

static void EnsureProperties();
static void ClearProperties();
};
Loading

0 comments on commit 5d444b6

Please sign in to comment.