From 645166fe0a204510e16d4d259c7c3a2cb5fdfc04 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Mon, 30 Mar 2020 18:40:54 +0200 Subject: [PATCH 01/14] Add initial wip --- dev/TabView/TabView.xaml | 95 +++++++++++++++++++------ dev/TabView/TabViewItem.cpp | 9 +++ dev/TabView/TabView_themeresources.xaml | 2 +- 3 files changed, 84 insertions(+), 22 deletions(-) diff --git a/dev/TabView/TabView.xaml b/dev/TabView/TabView.xaml index 75cfa9bf94..cf2706e929 100644 --- a/dev/TabView/TabView.xaml +++ b/dev/TabView/TabView.xaml @@ -134,28 +134,43 @@ - - - - - + + + + + + + + + + @@ -389,6 +404,12 @@ Padding="{TemplateBinding Padding}" Margin="-1,0,0,0"> + + + + + + @@ -424,6 +445,11 @@ + + + + + @@ -434,6 +460,10 @@ + + + + @@ -444,6 +474,10 @@ + + + + @@ -604,9 +638,28 @@ + + + + + diff --git a/dev/TabView/TabViewItem.cpp b/dev/TabView/TabViewItem.cpp index e191b46e54..11eaf19665 100644 --- a/dev/TabView/TabViewItem.cpp +++ b/dev/TabView/TabViewItem.cpp @@ -84,6 +84,15 @@ void TabViewItem::OnApplyTemplate() void TabViewItem::OnIsSelectedPropertyChanged(const winrt::DependencyObject& sender, const winrt::DependencyProperty& args) { + if (IsSelected()) + { + SetValue(winrt::Canvas::ZIndexProperty(),box_value(20)); + } + else + { + SetValue(winrt::Canvas::ZIndexProperty(), box_value(0)); + } + UpdateShadow(); UpdateWidthModeVisualState(); diff --git a/dev/TabView/TabView_themeresources.xaml b/dev/TabView/TabView_themeresources.xaml index ea7256bcc1..d9a3f31517 100644 --- a/dev/TabView/TabView_themeresources.xaml +++ b/dev/TabView/TabView_themeresources.xaml @@ -114,6 +114,6 @@ 29 6,4,10,5 - 16 + 100 From 3fa2014e2b2cb58433ad40a6239558cf01fad35e Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Tue, 31 Mar 2020 01:42:14 +0200 Subject: [PATCH 02/14] More improvements, added shadow --- dev/TabView/TabView.xaml | 44 +++++++++++++------- dev/TabView/TabViewItem.cpp | 55 ++++++++++++++++++++++++- dev/TabView/TabViewItem.h | 2 + dev/TabView/TabView_themeresources.xaml | 4 +- dev/TabView/TestUI/TabViewPage.xaml | 8 +++- 5 files changed, 93 insertions(+), 20 deletions(-) diff --git a/dev/TabView/TabView.xaml b/dev/TabView/TabView.xaml index cf2706e929..22e00f7640 100644 --- a/dev/TabView/TabView.xaml +++ b/dev/TabView/TabView.xaml @@ -135,13 +135,17 @@ - - + + + + + - + Fill="{TemplateBinding Background}"> + + + + @@ -449,7 +459,7 @@ - + @@ -638,24 +648,28 @@ - - - - + + + + + - + Fill="{ThemeResource TabViewItemHeaderBackgroundSelected}"> + + + + GetShadowReceiver()); + m_leftRadiusShadow = leftShadow; + + winrt::ThemeShadow rightShadow; + rightShadow.Receivers().Append(internalTabView->GetShadowReceiver()); + m_rightRadiusShadow = rightShadow; + winrt::ThemeShadow shadow; shadow.Receivers().Append(internalTabView->GetShadowReceiver()); m_shadow = shadow; @@ -80,6 +88,23 @@ void TabViewItem::OnApplyTemplate() } UpdateCloseButton(); + + + if (auto leftPath = GetTemplateChildT(L"LeftRadiusRender", *this)) + { + double shadowDepth = unbox_value(SharedHelpers::FindInApplicationResources(c_tabViewShadowDepthName, box_value(c_tabShadowDepth))); + auto currentTranslation = Translation(); + auto translation = winrt::float3{ currentTranslation.x, currentTranslation.y, (float)shadowDepth }; + leftPath.Translation(translation); + } + + if (auto rightPath = GetTemplateChildT(L"RightRadiusRender", *this)) + { + double shadowDepth = unbox_value(SharedHelpers::FindInApplicationResources(c_tabViewShadowDepthName, box_value(c_tabShadowDepth))); + auto currentTranslation = Translation(); + auto translation = winrt::float3{ currentTranslation.x, currentTranslation.y, (float)shadowDepth }; + rightPath.Translation(translation); + } } void TabViewItem::OnIsSelectedPropertyChanged(const winrt::DependencyObject& sender, const winrt::DependencyProperty& args) @@ -105,11 +130,37 @@ void TabViewItem::UpdateShadow() { if (IsSelected() && !m_isDragging) { - Shadow(m_shadow.as()); + if (auto leftPath = GetTemplateChildT(L"LeftRadiusRender", *this)) + { + leftPath.Shadow(m_leftRadiusShadow.as()); + } + + if (auto rightPath = GetTemplateChildT(L"RightRadiusRender", *this)) + { + rightPath.Shadow(m_rightRadiusShadow.as()); + } + + if (auto tabContainer = GetTemplateChildT(L"TabContainer", *this)) + { + tabContainer.Shadow(m_shadow.as()); + } } else { - Shadow(nullptr); + if (auto leftPath = GetTemplateChildT(L"LeftRadiusRender", *this)) + { + leftPath.Shadow(nullptr); + } + + if (auto rightPath = GetTemplateChildT(L"RightRadiusRender", *this)) + { + rightPath.Shadow(nullptr); + } + + if (auto tabContainer = GetTemplateChildT(L"TabContainer", *this)) + { + tabContainer.Shadow(nullptr); + } } } } diff --git a/dev/TabView/TabViewItem.h b/dev/TabView/TabViewItem.h index 117c67d909..c320968d9a 100644 --- a/dev/TabView/TabViewItem.h +++ b/dev/TabView/TabViewItem.h @@ -72,4 +72,6 @@ class TabViewItem : void UpdateShadow(); winrt::IInspectable m_shadow{ nullptr }; + winrt::IInspectable m_leftRadiusShadow{ nullptr }; + winrt::IInspectable m_rightRadiusShadow{ nullptr }; }; diff --git a/dev/TabView/TabView_themeresources.xaml b/dev/TabView/TabView_themeresources.xaml index d9a3f31517..c2603bbbd0 100644 --- a/dev/TabView/TabView_themeresources.xaml +++ b/dev/TabView/TabView_themeresources.xaml @@ -96,7 +96,7 @@ - 8,8,0,0 + 8,8,4,0 12,8,10,8 240 @@ -114,6 +114,6 @@ 29 6,4,10,5 - 100 + 16 diff --git a/dev/TabView/TestUI/TabViewPage.xaml b/dev/TabView/TestUI/TabViewPage.xaml index 90bed5bc07..f1f93b9f3e 100644 --- a/dev/TabView/TestUI/TabViewPage.xaml +++ b/dev/TabView/TestUI/TabViewPage.xaml @@ -1,4 +1,4 @@ - + + + + + + + From 0c3b202ad16b37af0ef2ef8627eba89c9e0cd539 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Tue, 31 Mar 2020 12:47:27 +0200 Subject: [PATCH 03/14] remove unused corners --- dev/TabView/TabView.xaml | 65 +++++++++++++--------------------------- 1 file changed, 21 insertions(+), 44 deletions(-) diff --git a/dev/TabView/TabView.xaml b/dev/TabView/TabView.xaml index 22e00f7640..0b2234ca19 100644 --- a/dev/TabView/TabView.xaml +++ b/dev/TabView/TabView.xaml @@ -134,53 +134,30 @@ - - - - - - - - - + + - - - - - - - + - From 67283dfa6f0423da75569b49a67957d2903c3fec Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Tue, 31 Mar 2020 13:49:48 +0200 Subject: [PATCH 04/14] Improve hit testing --- dev/TabView/TabView.xaml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/dev/TabView/TabView.xaml b/dev/TabView/TabView.xaml index 0b2234ca19..9469cd56e5 100644 --- a/dev/TabView/TabView.xaml +++ b/dev/TabView/TabView.xaml @@ -1,4 +1,4 @@ - + - + + - - @@ -447,10 +446,9 @@ - - - + + @@ -461,10 +459,9 @@ - - - + + From 12ec6683cb721314cb704b20384f35296faa91aa Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Tue, 31 Mar 2020 15:55:37 +0200 Subject: [PATCH 05/14] Switch to rounded corners --- dev/TabView/TabView.xaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/dev/TabView/TabView.xaml b/dev/TabView/TabView.xaml index 9469cd56e5..c0040c91c9 100644 --- a/dev/TabView/TabView.xaml +++ b/dev/TabView/TabView.xaml @@ -1,4 +1,4 @@ - + - - - + VerticalAlignment="Bottom" + Data="M4 0 L4 4 L0 4 A4,4 90 0 0 4 0 Z"> - - - + Date: Tue, 31 Mar 2020 16:18:25 +0200 Subject: [PATCH 06/14] Add rounded corners --- dev/TabView/TabView.xaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/TabView/TabView.xaml b/dev/TabView/TabView.xaml index c0040c91c9..7419713e30 100644 --- a/dev/TabView/TabView.xaml +++ b/dev/TabView/TabView.xaml @@ -626,6 +626,7 @@ IsHitTestVisible="False" Grid.Column="0" Canvas.ZIndex="20" + Stretch="Uniform" Height="{Binding Source={ThemeResource OverlayCornerRadius},Path=BottomLeft}" Fill="{ThemeResource TabViewItemHeaderBackgroundSelected}" VerticalAlignment="Bottom" @@ -637,9 +638,9 @@ Canvas.ZIndex="20" Height="{Binding Source={ThemeResource OverlayCornerRadius},Path=BottomRight}" VerticalAlignment="Bottom" + Stretch="Uniform" Data="M0 0 L0 4 L4 4 A4 4 90 0 1 0 0 Z" Fill="{ThemeResource TabViewItemHeaderBackgroundSelected}"> - Date: Tue, 31 Mar 2020 19:25:18 +0200 Subject: [PATCH 07/14] Switch to single shadow --- dev/TabView/TabViewItem.cpp | 55 ++----------------------------------- dev/TabView/TabViewItem.h | 2 -- 2 files changed, 2 insertions(+), 55 deletions(-) diff --git a/dev/TabView/TabViewItem.cpp b/dev/TabView/TabViewItem.cpp index 87f829111e..11eaf19665 100644 --- a/dev/TabView/TabViewItem.cpp +++ b/dev/TabView/TabViewItem.cpp @@ -61,14 +61,6 @@ void TabViewItem::OnApplyTemplate() { if (internalTabView) { - winrt::ThemeShadow leftShadow; - leftShadow.Receivers().Append(internalTabView->GetShadowReceiver()); - m_leftRadiusShadow = leftShadow; - - winrt::ThemeShadow rightShadow; - rightShadow.Receivers().Append(internalTabView->GetShadowReceiver()); - m_rightRadiusShadow = rightShadow; - winrt::ThemeShadow shadow; shadow.Receivers().Append(internalTabView->GetShadowReceiver()); m_shadow = shadow; @@ -88,23 +80,6 @@ void TabViewItem::OnApplyTemplate() } UpdateCloseButton(); - - - if (auto leftPath = GetTemplateChildT(L"LeftRadiusRender", *this)) - { - double shadowDepth = unbox_value(SharedHelpers::FindInApplicationResources(c_tabViewShadowDepthName, box_value(c_tabShadowDepth))); - auto currentTranslation = Translation(); - auto translation = winrt::float3{ currentTranslation.x, currentTranslation.y, (float)shadowDepth }; - leftPath.Translation(translation); - } - - if (auto rightPath = GetTemplateChildT(L"RightRadiusRender", *this)) - { - double shadowDepth = unbox_value(SharedHelpers::FindInApplicationResources(c_tabViewShadowDepthName, box_value(c_tabShadowDepth))); - auto currentTranslation = Translation(); - auto translation = winrt::float3{ currentTranslation.x, currentTranslation.y, (float)shadowDepth }; - rightPath.Translation(translation); - } } void TabViewItem::OnIsSelectedPropertyChanged(const winrt::DependencyObject& sender, const winrt::DependencyProperty& args) @@ -130,37 +105,11 @@ void TabViewItem::UpdateShadow() { if (IsSelected() && !m_isDragging) { - if (auto leftPath = GetTemplateChildT(L"LeftRadiusRender", *this)) - { - leftPath.Shadow(m_leftRadiusShadow.as()); - } - - if (auto rightPath = GetTemplateChildT(L"RightRadiusRender", *this)) - { - rightPath.Shadow(m_rightRadiusShadow.as()); - } - - if (auto tabContainer = GetTemplateChildT(L"TabContainer", *this)) - { - tabContainer.Shadow(m_shadow.as()); - } + Shadow(m_shadow.as()); } else { - if (auto leftPath = GetTemplateChildT(L"LeftRadiusRender", *this)) - { - leftPath.Shadow(nullptr); - } - - if (auto rightPath = GetTemplateChildT(L"RightRadiusRender", *this)) - { - rightPath.Shadow(nullptr); - } - - if (auto tabContainer = GetTemplateChildT(L"TabContainer", *this)) - { - tabContainer.Shadow(nullptr); - } + Shadow(nullptr); } } } diff --git a/dev/TabView/TabViewItem.h b/dev/TabView/TabViewItem.h index c320968d9a..117c67d909 100644 --- a/dev/TabView/TabViewItem.h +++ b/dev/TabView/TabViewItem.h @@ -72,6 +72,4 @@ class TabViewItem : void UpdateShadow(); winrt::IInspectable m_shadow{ nullptr }; - winrt::IInspectable m_leftRadiusShadow{ nullptr }; - winrt::IInspectable m_rightRadiusShadow{ nullptr }; }; From eb4e27889d5d71f8dcbfef3b9454343eca31a1db Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Tue, 31 Mar 2020 20:42:38 +0200 Subject: [PATCH 08/14] Switch to TemplateSettings --- ...TabViewItemTemplateSettings.properties.cpp | 46 +++++++++++++++++++ .../TabViewItemTemplateSettings.properties.h | 10 ++++ dev/TabView/TabView.idl | 4 ++ dev/TabView/TabView.xaml | 13 +++--- dev/TabView/TabViewItem.cpp | 14 ++++++ dev/TabView/TabViewItem.h | 3 ++ 6 files changed, 83 insertions(+), 7 deletions(-) diff --git a/dev/Generated/TabViewItemTemplateSettings.properties.cpp b/dev/Generated/TabViewItemTemplateSettings.properties.cpp index 361ed9b514..b2f68f9a09 100644 --- a/dev/Generated/TabViewItemTemplateSettings.properties.cpp +++ b/dev/Generated/TabViewItemTemplateSettings.properties.cpp @@ -14,6 +14,8 @@ namespace winrt::Microsoft::UI::Xaml::Controls #include "TabViewItemTemplateSettings.g.cpp" GlobalDependencyProperty TabViewItemTemplateSettingsProperties::s_IconElementProperty{ nullptr }; +GlobalDependencyProperty TabViewItemTemplateSettingsProperties::s_LeftInsetRadiusMarginProperty{ nullptr }; +GlobalDependencyProperty TabViewItemTemplateSettingsProperties::s_RightInsetRadiusMarginProperty{ nullptr }; TabViewItemTemplateSettingsProperties::TabViewItemTemplateSettingsProperties() { @@ -33,11 +35,35 @@ void TabViewItemTemplateSettingsProperties::EnsureProperties() ValueHelper::BoxedDefaultValue(), nullptr); } + if (!s_LeftInsetRadiusMarginProperty) + { + s_LeftInsetRadiusMarginProperty = + InitializeDependencyProperty( + L"LeftInsetRadiusMargin", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } + if (!s_RightInsetRadiusMarginProperty) + { + s_RightInsetRadiusMarginProperty = + InitializeDependencyProperty( + L"RightInsetRadiusMargin", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxedDefaultValue(), + nullptr); + } } void TabViewItemTemplateSettingsProperties::ClearProperties() { s_IconElementProperty = nullptr; + s_LeftInsetRadiusMarginProperty = nullptr; + s_RightInsetRadiusMarginProperty = nullptr; } void TabViewItemTemplateSettingsProperties::IconElement(winrt::IconElement const& value) @@ -49,3 +75,23 @@ winrt::IconElement TabViewItemTemplateSettingsProperties::IconElement() { return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_IconElementProperty)); } + +void TabViewItemTemplateSettingsProperties::LeftInsetRadiusMargin(winrt::Thickness const& value) +{ + static_cast(this)->SetValue(s_LeftInsetRadiusMarginProperty, ValueHelper::BoxValueIfNecessary(value)); +} + +winrt::Thickness TabViewItemTemplateSettingsProperties::LeftInsetRadiusMargin() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_LeftInsetRadiusMarginProperty)); +} + +void TabViewItemTemplateSettingsProperties::RightInsetRadiusMargin(winrt::Thickness const& value) +{ + static_cast(this)->SetValue(s_RightInsetRadiusMarginProperty, ValueHelper::BoxValueIfNecessary(value)); +} + +winrt::Thickness TabViewItemTemplateSettingsProperties::RightInsetRadiusMargin() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_RightInsetRadiusMarginProperty)); +} diff --git a/dev/Generated/TabViewItemTemplateSettings.properties.h b/dev/Generated/TabViewItemTemplateSettings.properties.h index 2d6cba447b..1320115997 100644 --- a/dev/Generated/TabViewItemTemplateSettings.properties.h +++ b/dev/Generated/TabViewItemTemplateSettings.properties.h @@ -12,9 +12,19 @@ class TabViewItemTemplateSettingsProperties void IconElement(winrt::IconElement const& value); winrt::IconElement IconElement(); + void LeftInsetRadiusMargin(winrt::Thickness const& value); + winrt::Thickness LeftInsetRadiusMargin(); + + void RightInsetRadiusMargin(winrt::Thickness const& value); + winrt::Thickness RightInsetRadiusMargin(); + static winrt::DependencyProperty IconElementProperty() { return s_IconElementProperty; } + static winrt::DependencyProperty LeftInsetRadiusMarginProperty() { return s_LeftInsetRadiusMarginProperty; } + static winrt::DependencyProperty RightInsetRadiusMarginProperty() { return s_RightInsetRadiusMarginProperty; } static GlobalDependencyProperty s_IconElementProperty; + static GlobalDependencyProperty s_LeftInsetRadiusMarginProperty; + static GlobalDependencyProperty s_RightInsetRadiusMarginProperty; static void EnsureProperties(); static void ClearProperties(); diff --git a/dev/TabView/TabView.idl b/dev/TabView/TabView.idl index 1607a14189..efcc0e3b29 100644 --- a/dev/TabView/TabView.idl +++ b/dev/TabView/TabView.idl @@ -182,8 +182,12 @@ unsealed runtimeclass TabViewItemTemplateSettings : Windows.UI.Xaml.DependencyOb TabViewItemTemplateSettings(); Windows.UI.Xaml.Controls.IconElement IconElement; + Windows.UI.Xaml.Thickness LeftInsetRadiusMargin; + Windows.UI.Xaml.Thickness RightInsetRadiusMargin; static Windows.UI.Xaml.DependencyProperty IconElementProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty LeftInsetRadiusMarginProperty{ get; }; + static Windows.UI.Xaml.DependencyProperty RightInsetRadiusMarginProperty{ get; }; } } diff --git a/dev/TabView/TabView.xaml b/dev/TabView/TabView.xaml index 7419713e30..6069f723ef 100644 --- a/dev/TabView/TabView.xaml +++ b/dev/TabView/TabView.xaml @@ -432,10 +432,9 @@ - - + + - @@ -447,8 +446,8 @@ - - + + @@ -460,8 +459,8 @@ - - + + diff --git a/dev/TabView/TabViewItem.cpp b/dev/TabView/TabViewItem.cpp index 11eaf19665..d524886520 100644 --- a/dev/TabView/TabViewItem.cpp +++ b/dev/TabView/TabViewItem.cpp @@ -9,6 +9,8 @@ #include "ResourceAccessor.h" #include "SharedHelpers.h" +static constexpr auto c_overlayCornerRadiusKey = L"OverlayCornerRadius"sv; + TabViewItem::TabViewItem() { __RP_Marker_ClassById(RuntimeProfiler::ProfId_TabViewItem); @@ -18,10 +20,17 @@ TabViewItem::TabViewItem() SetValue(s_TabViewTemplateSettingsProperty, winrt::make()); RegisterPropertyChangedCallback(winrt::SelectorItem::IsSelectedProperty(), { this, &TabViewItem::OnIsSelectedPropertyChanged }); + } void TabViewItem::OnApplyTemplate() { + auto const templateSettings = winrt::get_self(TabViewTemplateSettings()); + auto popupRadius = unbox_value(ResourceLookup(*this, box_value(c_overlayCornerRadiusKey))); + + templateSettings->LeftInsetRadiusMargin(winrt::Thickness({ -popupRadius.BottomLeft,0,0,0 })); + templateSettings->RightInsetRadiusMargin(winrt::Thickness({0,0,-popupRadius.BottomRight,0})); + winrt::IControlProtected controlProtected{ *this }; auto tabView = SharedHelpers::GetAncestorOfType(winrt::VisualTreeHelper::GetParent(*this)); @@ -365,3 +374,8 @@ void TabViewItem::OnIconSourceChanged() winrt::VisualStateManager::GoToState(*this, L"NoIcon"sv, false); } } + +winrt::IInspectable TabViewItem::ResourceLookup(const winrt::Control& control, const winrt::IInspectable& key) +{ + return control.Resources().HasKey(key) ? control.Resources().Lookup(key) : winrt::Application::Current().Resources().TryLookup(key); +} diff --git a/dev/TabView/TabViewItem.h b/dev/TabView/TabViewItem.h index 117c67d909..d9e3015b9a 100644 --- a/dev/TabView/TabViewItem.h +++ b/dev/TabView/TabViewItem.h @@ -72,4 +72,7 @@ class TabViewItem : void UpdateShadow(); winrt::IInspectable m_shadow{ nullptr }; + + winrt::IInspectable TabViewItem::ResourceLookup(const winrt::Control& control, const winrt::IInspectable& key); + }; From 7644520f791f485f92bfb90df6767091fa78d4dd Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Tue, 31 Mar 2020 23:03:30 +0200 Subject: [PATCH 09/14] Cleanup --- dev/TabView/TabView.xaml | 18 ++++++++---------- dev/TabView/TabViewItem.cpp | 1 - 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/dev/TabView/TabView.xaml b/dev/TabView/TabView.xaml index 6069f723ef..22afe52ddf 100644 --- a/dev/TabView/TabView.xaml +++ b/dev/TabView/TabView.xaml @@ -136,7 +136,6 @@ + Padding="{TemplateBinding Padding}" /> @@ -625,22 +623,22 @@ IsHitTestVisible="False" Grid.Column="0" Canvas.ZIndex="20" - Stretch="Uniform" Height="{Binding Source={ThemeResource OverlayCornerRadius},Path=BottomLeft}" Fill="{ThemeResource TabViewItemHeaderBackgroundSelected}" VerticalAlignment="Bottom" - Data="M4 0 L4 4 L0 4 A4,4 90 0 0 4 0 Z"> - - + + - + Data="M0 0 L0 4 L4 4 A4 4 90 0 1 0 0 Z" /> + ()); RegisterPropertyChangedCallback(winrt::SelectorItem::IsSelectedProperty(), { this, &TabViewItem::OnIsSelectedPropertyChanged }); - } void TabViewItem::OnApplyTemplate() From 4c6a4101491e19e357fe46f52b8514e4007ce772 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Wed, 1 Apr 2020 17:39:25 +0200 Subject: [PATCH 10/14] CR feedback --- dev/AutoSuggestBox/AutoSuggestBoxHelper.cpp | 10 +++------- dev/AutoSuggestBox/AutoSuggestBoxHelper.h | 1 - dev/ComboBox/ComboBoxHelper.cpp | 10 +++------- dev/ComboBox/ComboBoxHelper.h | 1 - dev/ResourceHelper/ResourceAccessor.cpp | 7 ++++++- dev/ResourceHelper/ResourceAccessor.h | 1 + dev/TabView/TabView.xaml | 4 +--- dev/TabView/TabViewItem.cpp | 7 +------ dev/TabView/TabViewItem.h | 3 --- 9 files changed, 15 insertions(+), 29 deletions(-) diff --git a/dev/AutoSuggestBox/AutoSuggestBoxHelper.cpp b/dev/AutoSuggestBox/AutoSuggestBoxHelper.cpp index 6e0ed8a878..20f9bb7878 100644 --- a/dev/AutoSuggestBox/AutoSuggestBoxHelper.cpp +++ b/dev/AutoSuggestBox/AutoSuggestBoxHelper.cpp @@ -6,6 +6,7 @@ #include "AutoSuggestBoxHelper.h" #include "DispatcherHelper.h" #include "CornerRadiusFilterConverter.h" +#include "ResourceAccessor.h" static constexpr auto c_popupName = L"SuggestionsPopup"sv; static constexpr auto c_popupBorderName = L"SuggestionsContainer"sv; @@ -103,8 +104,8 @@ void AutoSuggestBoxHelper::OnAutoSuggestBoxLoaded(const winrt::IInspectable& sen void AutoSuggestBoxHelper::UpdateCornerRadius(const winrt::AutoSuggestBox& autoSuggestBox, bool isPopupOpen) { - auto textBoxRadius = unbox_value(ResourceLookup(autoSuggestBox, box_value(c_controlCornerRadiusKey))); - auto popupRadius = unbox_value(ResourceLookup(autoSuggestBox, box_value(c_overlayCornerRadiusKey))); + auto textBoxRadius = unbox_value(ResourceAccessor::ResourceLookup(autoSuggestBox, box_value(c_controlCornerRadiusKey))); + auto popupRadius = unbox_value(ResourceAccessor::ResourceLookup(autoSuggestBox, box_value(c_overlayCornerRadiusKey))); if (winrt::IControl7 autoSuggextBoxControl7 = autoSuggestBox) { @@ -158,8 +159,3 @@ bool AutoSuggestBoxHelper::IsPopupOpenDown(const winrt::AutoSuggestBox& autoSugg } return verticalOffset >= 0; } - -winrt::IInspectable AutoSuggestBoxHelper::ResourceLookup(const winrt::Control& control, const winrt::IInspectable& key) -{ - return control.Resources().HasKey(key) ? control.Resources().Lookup(key) : winrt::Application::Current().Resources().TryLookup(key); -} diff --git a/dev/AutoSuggestBox/AutoSuggestBoxHelper.h b/dev/AutoSuggestBox/AutoSuggestBoxHelper.h index 7f45bacf83..7f03ba398c 100644 --- a/dev/AutoSuggestBox/AutoSuggestBoxHelper.h +++ b/dev/AutoSuggestBox/AutoSuggestBoxHelper.h @@ -25,7 +25,6 @@ class AutoSuggestBoxHelper static void UpdateCornerRadius(const winrt::AutoSuggestBox& autoSuggestBox, bool isPopupOpen); static bool IsPopupOpenDown(const winrt::AutoSuggestBox& autoSuggestBox); - static winrt::IInspectable ResourceLookup(const winrt::Control& control, const winrt::IInspectable& key); }; class AutoSuggestEventRevokers diff --git a/dev/ComboBox/ComboBoxHelper.cpp b/dev/ComboBox/ComboBoxHelper.cpp index 7cc89c6c6c..f8520f5c04 100644 --- a/dev/ComboBox/ComboBoxHelper.cpp +++ b/dev/ComboBox/ComboBoxHelper.cpp @@ -6,6 +6,7 @@ #include "ComboBoxHelper.h" #include "DispatcherHelper.h" #include "CornerRadiusFilterConverter.h" +#include "ResourceAccessor.h" static constexpr auto c_popupBorderName = L"PopupBorder"sv; static constexpr auto c_editableTextName = L"EditableText"sv; @@ -93,8 +94,8 @@ void ComboBoxHelper::UpdateCornerRadius(const winrt::ComboBox& comboBox, bool is { if (comboBox.IsEditable()) { - auto textBoxRadius = unbox_value(ResourceLookup(comboBox, box_value(c_controlCornerRadiusKey))); - auto popupRadius = unbox_value(ResourceLookup(comboBox, box_value(c_overlayCornerRadiusKey))); + auto textBoxRadius = unbox_value(ResourceAccessor::ResourceLookup(comboBox, box_value(c_controlCornerRadiusKey))); + auto popupRadius = unbox_value(ResourceAccessor::ResourceLookup(comboBox, box_value(c_overlayCornerRadiusKey))); if (winrt::IControl7 comboBoxControl7 = comboBox) { @@ -149,8 +150,3 @@ bool ComboBoxHelper::IsPopupOpenDown(const winrt::ComboBox& comboBox) } return verticalOffset > 0; } - -winrt::IInspectable ComboBoxHelper::ResourceLookup(const winrt::Control& control, const winrt::IInspectable& key) -{ - return control.Resources().HasKey(key) ? control.Resources().Lookup(key) : winrt::Application::Current().Resources().TryLookup(key); -} diff --git a/dev/ComboBox/ComboBoxHelper.h b/dev/ComboBox/ComboBoxHelper.h index 42243471c3..bb47f2750e 100644 --- a/dev/ComboBox/ComboBoxHelper.h +++ b/dev/ComboBox/ComboBoxHelper.h @@ -25,7 +25,6 @@ class ComboBoxHelper static void UpdateCornerRadius(const winrt::ComboBox& comboBox, bool isDropDownOpen); static bool IsPopupOpenDown(const winrt::ComboBox& comboBox); - static winrt::IInspectable ResourceLookup(const winrt::Control& control, const winrt::IInspectable& key); }; class ComboBoxDropDownEventRevokers diff --git a/dev/ResourceHelper/ResourceAccessor.cpp b/dev/ResourceHelper/ResourceAccessor.cpp index 32e6f17fad..86cfab777f 100644 --- a/dev/ResourceHelper/ResourceAccessor.cpp +++ b/dev/ResourceHelper/ResourceAccessor.cpp @@ -45,4 +45,9 @@ winrt::LoadedImageSurface ResourceAccessor::GetImageSurface(const wstring_view & } }(); return winrt::LoadedImageSurface::StartLoadFromUri(imageUri, imageSize); -} \ No newline at end of file +} + +winrt::IInspectable ResourceAccessor::ResourceLookup(const winrt::Control& control, const winrt::IInspectable& key) +{ + return control.Resources().HasKey(key) ? control.Resources().Lookup(key) : winrt::Application::Current().Resources().TryLookup(key); +} diff --git a/dev/ResourceHelper/ResourceAccessor.h b/dev/ResourceHelper/ResourceAccessor.h index 527705b4b0..335975a9f3 100644 --- a/dev/ResourceHelper/ResourceAccessor.h +++ b/dev/ResourceHelper/ResourceAccessor.h @@ -25,6 +25,7 @@ class ResourceAccessor sealed public: static winrt::hstring GetLocalizedStringResource(const wstring_view &resourceName); static winrt::LoadedImageSurface GetImageSurface(const wstring_view &assetName, winrt::Size imageSize); + static winrt::IInspectable ResourceLookup(const winrt::Control& control, const winrt::IInspectable& key); static bool IsResourceIdNull(ResourceIdType resourceId) { diff --git a/dev/TabView/TabView.xaml b/dev/TabView/TabView.xaml index 22afe52ddf..19caa158a8 100644 --- a/dev/TabView/TabView.xaml +++ b/dev/TabView/TabView.xaml @@ -1,4 +1,4 @@ - + (TabViewTemplateSettings()); - auto popupRadius = unbox_value(ResourceLookup(*this, box_value(c_overlayCornerRadiusKey))); + auto popupRadius = unbox_value(ResourceAccessor::ResourceLookup(*this, box_value(c_overlayCornerRadiusKey))); templateSettings->LeftInsetRadiusMargin(winrt::Thickness({ -popupRadius.BottomLeft,0,0,0 })); templateSettings->RightInsetRadiusMargin(winrt::Thickness({0,0,-popupRadius.BottomRight,0})); @@ -373,8 +373,3 @@ void TabViewItem::OnIconSourceChanged() winrt::VisualStateManager::GoToState(*this, L"NoIcon"sv, false); } } - -winrt::IInspectable TabViewItem::ResourceLookup(const winrt::Control& control, const winrt::IInspectable& key) -{ - return control.Resources().HasKey(key) ? control.Resources().Lookup(key) : winrt::Application::Current().Resources().TryLookup(key); -} diff --git a/dev/TabView/TabViewItem.h b/dev/TabView/TabViewItem.h index d9e3015b9a..117c67d909 100644 --- a/dev/TabView/TabViewItem.h +++ b/dev/TabView/TabViewItem.h @@ -72,7 +72,4 @@ class TabViewItem : void UpdateShadow(); winrt::IInspectable m_shadow{ nullptr }; - - winrt::IInspectable TabViewItem::ResourceLookup(const winrt::Control& control, const winrt::IInspectable& key); - }; From 794bd84fc320319f6207877d6be1d65cd90f2c5c Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Sat, 4 Apr 2020 01:26:29 +0200 Subject: [PATCH 11/14] Fix test failure --- dev/TabView/InteractionTests/TabViewTests.cs | 2 +- dev/TabView/TabView.xaml | 33 +++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/dev/TabView/InteractionTests/TabViewTests.cs b/dev/TabView/InteractionTests/TabViewTests.cs index 2a9fb2bfce..9da1fd6092 100644 --- a/dev/TabView/InteractionTests/TabViewTests.cs +++ b/dev/TabView/InteractionTests/TabViewTests.cs @@ -118,7 +118,7 @@ public void TabSizeAndScrollButtonsTest() { using (var setup = new TestSetupHelper("TabView Tests")) { - UIObject smallerTab = FindElement.ByName("FirstTab"); + UIObject smallerTab = FindElement.ByName("SecondTab"); UIObject largerTab = FindElement.ByName("LongHeaderTab"); FindElement.ByName