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

Fixing ScrollBar regression for Issue #4255 #4495

Merged
merged 7 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 11 additions & 5 deletions dev/CommonStyles/CommonStyles.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@
<Version>RS1</Version>
<Type>ThemeResources</Type>
</Page>
<Page Include="$(MSBuildThisFileDirectory)ScrollViewer_themeresources.xaml">
<ControlsResourcesVersion>Version2</ControlsResourcesVersion>
<Version>RS1</Version>
<Type>ThemeResources</Type>
</Page>
<Page Include="$(MSBuildThisFileDirectory)ToggleSwitch_themeresources.xaml">
<ControlsResourcesVersion>Version2</ControlsResourcesVersion>
<Version>RS1</Version>
Expand Down Expand Up @@ -384,6 +379,17 @@
<Type>ThemeResources</Type>
</Page>

<Page Include="$(MSBuildThisFileDirectory)ScrollViewer_themeresources.xaml">
<ControlsResourcesVersion>Version2</ControlsResourcesVersion>
<Version>RS1</Version>
<Type>ThemeResources</Type>
</Page>
<Page Include="$(MSBuildThisFileDirectory)ScrollViewer_themeresources_v1.xaml">
<ControlsResourcesVersion>Version1</ControlsResourcesVersion>
<Version>RS1</Version>
<Type>ThemeResources</Type>
</Page>

<Page Include="$(MSBuildThisFileDirectory)Slider_themeresources.xaml">
<ControlsResourcesVersion>Version2</ControlsResourcesVersion>
<Version>RS1</Version>
Expand Down
2 changes: 0 additions & 2 deletions dev/CommonStyles/ScrollBar_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
<x:String x:Key="ScrollBarContractDelay">00:00:02</x:String>
<x:String x:Key="ScrollBarContractFinalKeyframe">00:00:02.1</x:String>
<x:Double x:Key="ScrollBarSize">12</x:Double>
<Thickness x:Key="ScrollBarMargin">1</Thickness>

<x:Double x:Key="ScrollBarVerticalThumbMinHeight">30</x:Double>
<x:Double x:Key="ScrollBarVerticalThumbMinWidth">8</x:Double>
Expand All @@ -213,7 +212,6 @@
<Style x:Key="DefaultScrollBarStyle" TargetType="ScrollBar">
<Setter Property="MinWidth" Value="{StaticResource ScrollBarSize}" />
<Setter Property="MinHeight" Value="{StaticResource ScrollBarSize}" />
<Setter Property="Margin" Value="{StaticResource ScrollBarMargin}"/>
<Setter Property="Background" Value="{ThemeResource ScrollBarBackground}" />
<Setter Property="Foreground" Value="{ThemeResource ScrollBarForeground}" />
<Setter Property="BorderBrush" Value="{ThemeResource ScrollBarBorderBrush}" />
Expand Down
249 changes: 248 additions & 1 deletion dev/CommonStyles/ScrollViewer_themeresources.xaml

Large diffs are not rendered by default.

255 changes: 255 additions & 0 deletions dev/CommonStyles/ScrollViewer_themeresources_v1.xaml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dev/ScrollView/ScrollView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1646,14 +1646,14 @@ bool ScrollView::IsInputKindIgnored(winrt::ScrollingInputKinds const& inputKind)

bool ScrollView::AreAllScrollControllersCollapsed() const
{
return (!m_horizontalScrollControllerElement || m_horizontalScrollControllerElement.get().Visibility() == winrt::Visibility::Collapsed) &&
(!m_verticalScrollControllerElement || m_verticalScrollControllerElement.get().Visibility() == winrt::Visibility::Collapsed);
return !SharedHelpers::IsAncestor(m_horizontalScrollControllerElement.try_as<winrt::DependencyObject>() /*child*/, static_cast<winrt::DependencyObject>(*this) /*parent*/, true /*checkVisibility*/) &&
!SharedHelpers::IsAncestor(m_verticalScrollControllerElement.try_as<winrt::DependencyObject>() /*child*/, static_cast<winrt::DependencyObject>(*this) /*parent*/, true /*checkVisibility*/);
}

bool ScrollView::AreBothScrollControllersVisible() const
{
return m_horizontalScrollControllerElement && m_horizontalScrollControllerElement.get().Visibility() == winrt::Visibility::Visible &&
m_verticalScrollControllerElement && m_verticalScrollControllerElement.get().Visibility() == winrt::Visibility::Visible;
return SharedHelpers::IsAncestor(m_horizontalScrollControllerElement.try_as<winrt::DependencyObject>() /*child*/, static_cast<winrt::DependencyObject>(*this) /*parent*/, true /*checkVisibility*/) &&
SharedHelpers::IsAncestor(m_verticalScrollControllerElement.try_as<winrt::DependencyObject>() /*child*/, static_cast<winrt::DependencyObject>(*this) /*parent*/, true /*checkVisibility*/);
}

bool ScrollView::AreScrollControllersAutoHiding()
Expand Down
20 changes: 12 additions & 8 deletions dev/ScrollView/ScrollView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,22 @@
MaxZoomFactor="{TemplateBinding MaxZoomFactor}"
HorizontalAnchorRatio="{TemplateBinding HorizontalAnchorRatio}"
VerticalAnchorRatio="{TemplateBinding VerticalAnchorRatio}"/>
<ScrollBar x:Name="PART_HorizontalScrollBar"
<Grid
Grid.Row="1"
Orientation="Horizontal"
HorizontalAlignment="Stretch"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
contract7Present:CornerRadius="{TemplateBinding CornerRadius}"/>
<ScrollBar x:Name="PART_VerticalScrollBar"
Padding="{ThemeResource ScrollViewScrollBarsMargin}">
<ScrollBar x:Name="PART_HorizontalScrollBar"
Orientation="Horizontal"
contract7Present:CornerRadius="{TemplateBinding CornerRadius}"/>
</Grid>
<Grid
Grid.Column="1"
Orientation="Vertical"
VerticalAlignment="Stretch"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
contract7Present:CornerRadius="{TemplateBinding CornerRadius}"/>
Padding="{ThemeResource ScrollViewScrollBarsMargin}">
<ScrollBar x:Name="PART_VerticalScrollBar"
Orientation="Vertical"
contract7Present:CornerRadius="{TemplateBinding CornerRadius}"/>
</Grid>
<Border x:Name="PART_ScrollBarsSeparator"
Grid.Row="1"
Grid.Column="1"
Expand Down
8 changes: 5 additions & 3 deletions dev/ScrollView/ScrollView_rs1_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="ScrollViewScrollBarsSeparatorBackground" Color="{StaticResource SystemChromeMediumColor}" Opacity="0.9" />
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="ControlFillColorTransparentBrush"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="ScrollViewScrollBarsSeparatorBackground" Color="{StaticResource SystemChromeMediumColor}" Opacity="0.9" />
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="ControlFillColorTransparentBrush"/>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="SystemControlPageBackgroundChromeLowBrush" />
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="SystemControlTransparentBrush"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<Thickness x:Key="ScrollViewScrollBarsMargin">1</Thickness>

<x:String x:Key="ScrollViewScrollBarsSeparatorExpandDelay">00:00:00</x:String>
<x:String x:Key="ScrollViewScrollBarsSeparatorExpandDuration">00:00:00.1</x:String>
<x:String x:Key="ScrollViewScrollBarsSeparatorContractDelay">00:00:02</x:String>
Expand Down
8 changes: 5 additions & 3 deletions dev/ScrollView/ScrollView_rs3_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="ScrollViewScrollBarsSeparatorBackground" Color="{StaticResource SystemChromeMediumColor}" Opacity="0.9" />
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="ControlFillColorTransparentBrush"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="ScrollViewScrollBarsSeparatorBackground" Color="{StaticResource SystemChromeMediumColor}" Opacity="0.9" />
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="ControlFillColorTransparentBrush"/>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="SystemControlPageBackgroundChromeLowBrush" />
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="SystemControlTransparentBrush"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<Thickness x:Key="ScrollViewScrollBarsMargin">1</Thickness>

<x:String x:Key="ScrollViewScrollBarsSeparatorExpandDelay">00:00:00</x:String>
<x:String x:Key="ScrollViewScrollBarsSeparatorExpandDuration">00:00:00.1</x:String>
<x:String x:Key="ScrollViewScrollBarsSeparatorContractDelay">00:00:02</x:String>
Expand Down
8 changes: 5 additions & 3 deletions dev/ScrollView/ScrollView_rs4_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="ScrollViewScrollBarsSeparatorBackground" Color="{StaticResource SystemChromeMediumColor}" Opacity="0.9" />
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="ControlFillColorTransparentBrush"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="ScrollViewScrollBarsSeparatorBackground" Color="{StaticResource SystemChromeMediumColor}" Opacity="0.9" />
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="ControlFillColorTransparentBrush"/>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="SystemControlPageBackgroundChromeLowBrush" />
<StaticResource x:Key="ScrollViewScrollBarsSeparatorBackground" ResourceKey="SystemControlTransparentBrush"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<Thickness x:Key="ScrollViewScrollBarsMargin">1</Thickness>

<x:String x:Key="ScrollViewScrollBarsSeparatorExpandDelay">00:00:00.4</x:String>
<x:String x:Key="ScrollViewScrollBarsSeparatorExpandDuration">00:00:00.1</x:String>
<x:String x:Key="ScrollViewScrollBarsSeparatorContractDelay">00:00:02</x:String>
Expand Down
2 changes: 2 additions & 0 deletions dev/ScrollView/TestUI/ScrollViewDynamicPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

<ScrollViewer
x:Name="wuxScrollViewer"
Style="{ThemeResource DefaultScrollViewerStyle}"
Width="300" Height="400"
Grid.Row="2" Margin="1"
Background="SkyBlue" VerticalAlignment="Top">
Expand All @@ -101,6 +102,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand Down
56 changes: 31 additions & 25 deletions test/MUXControlsTestApp/Themes/DisableAnimationsStyles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<Style TargetType="ListView" BasedOn="{StaticResource ListViewCommon}"/>

<!-- There"s no good way to disable ScrollViewer's indicator transitions so just make a ScrollViewer style that doesn't have VSM -->
<!-- There is no good way to disable ScrollViewer's indicator transitions so just make a ScrollViewer style that doesn't have VSM -->
<Style TargetType="ScrollViewer">
<Setter Property="Template">
<Setter.Value>
Expand All @@ -31,36 +31,42 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollContentPresenter x:Name="ScrollContentPresenter"
Grid.RowSpan="2"
Grid.ColumnSpan="2"
ContentTemplate="{TemplateBinding ContentTemplate}"
Margin="{TemplateBinding Padding}" />
Grid.RowSpan="2"
Grid.ColumnSpan="2"
ContentTemplate="{TemplateBinding ContentTemplate}"
Margin="{TemplateBinding Padding}" />
<Grid Grid.RowSpan="2"
Grid.ColumnSpan="2" />
<ScrollBar x:Name="VerticalScrollBar"
Grid.ColumnSpan="2" />
<Grid
Grid.Column="1"
IsTabStop="False"
Maximum="{TemplateBinding ScrollableHeight}"
Orientation="Vertical"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
Value="{TemplateBinding VerticalOffset}"
ViewportSize="{TemplateBinding ViewportHeight}"
HorizontalAlignment="Right"
IndicatorMode="MouseIndicator"/>
<ScrollBar x:Name="HorizontalScrollBar"
IsTabStop="False"
Maximum="{TemplateBinding ScrollableWidth}"
Orientation="Horizontal"
Padding="{ThemeResource ScrollViewerScrollBarMargin}">
<ScrollBar x:Name="VerticalScrollBar"
IsTabStop="False"
Maximum="{TemplateBinding ScrollableHeight}"
Orientation="Vertical"
Value="{TemplateBinding VerticalOffset}"
ViewportSize="{TemplateBinding ViewportHeight}"
HorizontalAlignment="Right"
IndicatorMode="MouseIndicator"/>
</Grid>
<Grid
Grid.Row="1"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
Value="{TemplateBinding HorizontalOffset}"
ViewportSize="{TemplateBinding ViewportWidth}"
IndicatorMode="MouseIndicator"/>
Padding="{ThemeResource ScrollViewerScrollBarMargin}">
<ScrollBar x:Name="HorizontalScrollBar"
IsTabStop="False"
Maximum="{TemplateBinding ScrollableWidth}"
Orientation="Horizontal"
Value="{TemplateBinding HorizontalOffset}"
ViewportSize="{TemplateBinding ViewportWidth}"
IndicatorMode="MouseIndicator"/>
</Grid>
<Border x:Name="ScrollBarSeparator"
Grid.Row="1"
Grid.Column="1"
Opacity="0"
Background="{ThemeResource ScrollViewerScrollBarSeparatorBackground}" />
Grid.Row="1"
Grid.Column="1"
Opacity="0"
Background="{ThemeResource ScrollViewerScrollBarSeparatorBackground}" />
</Grid>
</Border>
</ControlTemplate>
Expand Down
Loading