Skip to content

Commit

Permalink
Remove code that removed focus visual in SelectionFollowsFocus mode (#…
Browse files Browse the repository at this point in the history
…3190)

* Remove code that removed focus visual in SelectionFollowsFocus mode

* Remove unused func
  • Loading branch information
marcelwgn authored Sep 8, 2020
1 parent 8730c31 commit dadcc05
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 53 deletions.
46 changes: 0 additions & 46 deletions dev/NavigationView/NavigationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ void NavigationView::OnApplyTemplate()
UpdatePaneTabFocusNavigation();
UpdateBackAndCloseButtonsVisibility();
UpdateSingleSelectionFollowsFocusTemplateSetting();
UpdateNavigationViewUseSystemVisual();
UpdatePaneVisibility();
UpdateVisualState();
UpdatePaneTitleMargins();
Expand Down Expand Up @@ -1185,11 +1184,6 @@ void NavigationView::OnRepeaterElementPrepared(const winrt::ItemsRepeater& ir, c
}();
winrt::get_self<NavigationViewItem>(nvi)->PropagateDepthToChildren(childDepth);

if (ir != m_topNavRepeaterOverflowView.get())
{
nvibImpl->UseSystemFocusVisuals(ShouldShowFocusVisual());
}

// Register for item events
auto nviRevokers = winrt::make_self<NavigationViewItemRevokers>();
nviRevokers->tappedRevoker = nvi.Tapped(winrt::auto_revoke, { this, &NavigationView::OnNavigationViewItemTapped });
Expand Down Expand Up @@ -3165,45 +3159,6 @@ void NavigationView::UpdateLeftNavigationOnlyVisualState(bool useTransitions)
winrt::VisualStateManager::GoToState(*this, isToggleButtonVisible ? L"TogglePaneButtonVisible" : L"TogglePaneButtonCollapsed", false /*useTransitions*/);
}

void NavigationView::UpdateNavigationViewUseSystemVisual()
{
if (SharedHelpers::IsRS1OrHigher() && !ShouldPreserveNavigationViewRS4Behavior() && m_appliedTemplate)
{
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_leftNavRepeater.get(), ShouldShowFocusVisual());
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_leftNavFooterMenuRepeater.get(), ShouldShowFocusVisual());
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_topNavRepeater.get(), ShouldShowFocusVisual());
PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(m_topNavFooterMenuRepeater.get(), ShouldShowFocusVisual());
}
}

bool NavigationView::ShouldShowFocusVisual()
{
return SelectionFollowsFocus() == winrt::NavigationViewSelectionFollowsFocus::Disabled;
}

void NavigationView::PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(winrt::ItemsRepeater const& ir, bool showFocusVisual)
{
if (ir)
{
if (auto itemsSourceView = ir.ItemsSourceView())
{
const auto numberOfItems = itemsSourceView.Count();
for (int i = 0; i < numberOfItems; i++)
{
if (auto nvib = ir.TryGetElement(i))
{
if (auto nvi = nvib.try_as<winrt::NavigationViewItem>())
{
auto nviImpl = winrt::get_self<NavigationViewItem>(nvi);
nviImpl->UseSystemFocusVisuals(showFocusVisual);
}
}

}
}
}
}

void NavigationView::InvalidateTopNavPrimaryLayout()
{
if (m_appliedTemplate && IsTopNavigationView())
Expand Down Expand Up @@ -3793,7 +3748,6 @@ void NavigationView::OnPropertyChanged(const winrt::DependencyPropertyChangedEve
else if (property == s_SelectionFollowsFocusProperty)
{
UpdateSingleSelectionFollowsFocusTemplateSetting();
UpdateNavigationViewUseSystemVisual();
}
else if (property == s_IsPaneToggleButtonVisibleProperty)
{
Expand Down
3 changes: 0 additions & 3 deletions dev/NavigationView/NavigationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ class NavigationView :
void UpdateVisualState(bool useTransitions = false);
void UpdateVisualStateForOverflowButton();
void UpdateLeftNavigationOnlyVisualState(bool useTransitions);
void UpdateNavigationViewUseSystemVisual();
static void PropagateShowFocusVisualToAllNavigationViewItemsInRepeater(winrt::ItemsRepeater const& ir, bool showFocusVisual);
void UpdatePaneShadow();
void UpdateNavigationViewItemsFactory();
void SyncItemTemplates();
Expand Down Expand Up @@ -321,7 +319,6 @@ class NavigationView :
bool ShouldPreserveNavigationViewRS3Behavior();

bool NeedRearrangeOfTopElementsAfterOverflowSelectionChanged(int selectedOriginalIndex);
bool ShouldShowFocusVisual();
void KeyboardFocusFirstItemFromItem(const winrt::NavigationViewItemBase& nvib);
void KeyboardFocusLastItemFromItem(const winrt::NavigationViewItemBase& nvib);
void FocusNextDownItem(const winrt::NavigationViewItem& nvi, const winrt::KeyRoutedEventArgs& args);
Expand Down
4 changes: 0 additions & 4 deletions dev/NavigationView/NavigationView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,6 @@
</Setter>
</Style>

<!--Note: Even though UseSystemFocusVisuals is set to True here in the Style, and because
bindings in Styles are only evaluated once, we were unable to bring a TemplateSettings.UseSystemFocusVisuals
to handle the removal of the focus rect when SelectionFollowsFocus is enabled. Therefore, that has
been done in code and it's updated whenever SelectionFollowsFocus is changed.-->
<Style TargetType="local:NavigationViewItem">
<Setter Property="Foreground" Value="{ThemeResource NavigationViewItemForeground}" />
<Setter Property="Background" Value="{ThemeResource NavigationViewItemBackground}" />
Expand Down

0 comments on commit dadcc05

Please sign in to comment.