Replace AppChromeAcrylicHostBackdropMediumLowBrush from OverflowTextBlock + improvements (#647)

* replace acrylic brush by margin/padding

* Modify how the control manages the focus

* remove comment

* Prevent deadlock
This commit is contained in:
Rudy Huyn
2019-09-05 11:01:58 -07:00
committed by Stephanie Anderl
parent 98908c627f
commit c877b0a2e9
3 changed files with 183 additions and 175 deletions

View File

@@ -53,22 +53,23 @@
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Style="{StaticResource ResultsScrollerSnapped}"
AutomationProperties.AccessibilityView="Raw">
<ItemsControl x:Name="TokenList"
Padding="0"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Right"
VerticalContentAlignment="Stretch"
IsTabStop="False"
ItemTemplateSelector="{StaticResource ExpressionItemTemplateSelector}"
ItemsSource="{Binding ExpressionTokens}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel HorizontalAlignment="Right"
VerticalAlignment="Stretch"
Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<Grid x:Name="ExpressionContent">
<ItemsControl x:Name="TokenList"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Right"
VerticalContentAlignment="Stretch"
IsTabStop="False"
ItemTemplateSelector="{StaticResource ExpressionItemTemplateSelector}"
ItemsSource="{Binding ExpressionTokens}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel HorizontalAlignment="Right"
VerticalAlignment="Stretch"
Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
</ScrollViewer>
<Button x:Name="ScrollLeft"
x:Uid="scrollLeft"
@@ -94,11 +95,8 @@
</Setter>
</Style>
<Style x:Key="AlwaysOnTopStyleS" TargetType="controls:OverflowTextBlock">
<Style x:Key="AOTResultsStyle" TargetType="controls:OverflowTextBlock">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="ColumnWidth" Value="14"/>
<Setter Property="ColumnHeight" Value="14"/>
<Setter Property="ScrollButtonFontSize" Value="12"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:OverflowTextBlock">
@@ -111,26 +109,42 @@
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="Transparent"/>
<SolidColorBrush x:Key="ButtonBackgroundDisabled" Color="Transparent"/>
<SolidColorBrush x:Key="ButtonForeground" Color="#99000000"/>
<SolidColorBrush x:Key="ButtonForegroundPointerOver" Color="{ThemeResource SystemAccentColor}" Opacity="0.8"/>
<SolidColorBrush x:Key="ButtonForegroundPressed" Color="{ThemeResource SystemAccentColor}" Opacity="1.0"/>
<SolidColorBrush x:Key="ButtonForegroundPointerOver"
Opacity="0.8"
Color="{ThemeResource SystemAccentColor}"/>
<SolidColorBrush x:Key="ButtonForegroundPressed"
Opacity="1.0"
Color="{ThemeResource SystemAccentColor}"/>
<SolidColorBrush x:Key="ButtonForegroundDisabled" Color="#33000000"/>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="Transparent"/>
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="Transparent"/>
<SolidColorBrush x:Key="ButtonBackgroundDisabled" Color="Transparent"/>
<SolidColorBrush x:Key="ButtonForeground" Color="{ThemeResource SystemColorWindowTextColor}" Opacity="0.6"/>
<SolidColorBrush x:Key="ButtonForegroundPointerOver" Color="{ThemeResource SystemColorHighlightColor}" Opacity="0.8"/>
<SolidColorBrush x:Key="ButtonForegroundPressed" Color="{ThemeResource SystemColorHighlightColor}" Opacity="1.0"/>
<SolidColorBrush x:Key="ButtonForegroundDisabled" Color="{ThemeResource SystemColorGrayTextColor}" Opacity="0.2"/>
<SolidColorBrush x:Key="ButtonForeground"
Opacity="0.6"
Color="{ThemeResource SystemColorWindowTextColor}"/>
<SolidColorBrush x:Key="ButtonForegroundPointerOver"
Opacity="0.8"
Color="{ThemeResource SystemColorHighlightColor}"/>
<SolidColorBrush x:Key="ButtonForegroundPressed"
Opacity="1.0"
Color="{ThemeResource SystemColorHighlightColor}"/>
<SolidColorBrush x:Key="ButtonForegroundDisabled"
Opacity="0.2"
Color="{ThemeResource SystemColorGrayTextColor}"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="Transparent"/>
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="Transparent"/>
<SolidColorBrush x:Key="ButtonBackgroundDisabled" Color="Transparent"/>
<SolidColorBrush x:Key="ButtonForeground" Color="#99FFFFFF"/>
<SolidColorBrush x:Key="ButtonForegroundPointerOver" Color="{ThemeResource SystemAccentColorLight1}" Opacity="0.8"/>
<SolidColorBrush x:Key="ButtonForegroundPressed" Color="{ThemeResource SystemAccentColorLight1}" Opacity="1.0"/>
<SolidColorBrush x:Key="ButtonForegroundPointerOver"
Opacity="0.8"
Color="{ThemeResource SystemAccentColorLight1}"/>
<SolidColorBrush x:Key="ButtonForegroundPressed"
Opacity="1.0"
Color="{ThemeResource SystemAccentColorLight1}"/>
<SolidColorBrush x:Key="ButtonForegroundDisabled" Color="#33FFFFFF"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
@@ -148,56 +162,49 @@
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Style="{StaticResource ResultsScrollerSnapped}"
AutomationProperties.AccessibilityView="Control">
<TextBlock x:Name="EditableToken"
AutomationProperties.AccessibilityView="Raw"
Text="{Binding DisplayValue, Mode=OneWay}"
Margin="4,0,4,0"
Padding="0"
VerticalAlignment="Stretch"
FontWeight="SemiBold"
Grid.Row="2"
HorizontalAlignment="Right"/>
<Grid x:Name="ExpressionContent">
<TextBlock x:Name="EditableToken"
Grid.Row="2"
Margin="4,0,4,0"
Padding="0"
HorizontalAlignment="Right"
VerticalAlignment="Stretch"
FontWeight="SemiBold"
AutomationProperties.AccessibilityView="Raw"
Text="{Binding DisplayValue, Mode=OneWay}"/>
</Grid>
</ScrollViewer>
<Border Background="{ThemeResource AppChromeAcrylicHostBackdropMediumLowBrush}"
Grid.Column="0">
<Button x:Name="ScrollLeft"
<Button x:Name="ScrollLeft"
x:Uid="scrollLeft"
Grid.Column="0"
Width="{TemplateBinding ScrollButtonsWidth}"
Margin="0,3,0,0"
VerticalAlignment="Stretch"
Style="{StaticResource AlwaysOnTopScrollButtonStyleS}"
MinWidth="{TemplateBinding ColumnWidth}"
MinHeight="{TemplateBinding ColumnHeight}"
Background="Transparent">
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="{TemplateBinding ScrollButtonFontSize}"
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="{TemplateBinding ScrollButtonsFontSize}"
Glyph="&#xE26C;"/>
</Button>
</Border>
<Border Background="{ThemeResource AppChromeAcrylicHostBackdropMediumLowBrush}"
Grid.Column="2">
<Button x:Name="ScrollRight"
</Button>
<Button x:Name="ScrollRight"
x:Uid="scrollRight"
Grid.Column="2"
Width="{TemplateBinding ScrollButtonsWidth}"
Margin="0,3,0,0"
VerticalAlignment="Stretch"
Style="{StaticResource AlwaysOnTopScrollButtonStyleS}"
MinWidth="{TemplateBinding ColumnWidth}"
MinHeight="{TemplateBinding ColumnHeight}"
Background="Transparent">
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="{TemplateBinding ScrollButtonFontSize}"
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="{TemplateBinding ScrollButtonsFontSize}"
Glyph="&#xE26B;"/>
</Button>
</Border>
</Button>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="AlwaysOnTopStyleM" BasedOn="{StaticResource AlwaysOnTopStyleS}" TargetType="controls:OverflowTextBlock">
<Setter Property="ColumnWidth" Value="28"/>
<Setter Property="ColumnHeight" Value="280"/>
<Setter Property="ScrollButtonFontSize" Value="28"/>
</Style>
<!-- Calculation Result Styles -->
<Style x:Key="ResultsStyle"
BasedOn="{StaticResource CalculationResultStyle}"
@@ -223,7 +230,7 @@
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
<Style x:Key="AlwaysOnTopScrollButtonStyleS" TargetType="Button">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="0,0,0,0"/>
@@ -518,8 +525,6 @@
<VisualState.Setters>
<Setter Target="RowResult.MinHeight" Value="54"/>
<Setter Target="RowResult.Height" Value="72*"/>
<Setter Target="AlwaysOnTopResults.FontSize" Value="40"/>
<Setter Target="AlwaysOnTopResults.Style" Value="{StaticResource AlwaysOnTopStyleM}"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="MinAlwaysOnTop">
@@ -530,7 +535,8 @@
<Setter Target="RowResult.MinHeight" Value="20"/>
<Setter Target="RowResult.Height" Value="72*"/>
<Setter Target="AlwaysOnTopResults.FontSize" Value="18"/>
<Setter Target="AlwaysOnTopResults.Style" Value="{StaticResource AlwaysOnTopStyleS}"/>
<Setter Target="AlwaysOnTopResults.ScrollButtonsWidth" Value="14"/>
<Setter Target="AlwaysOnTopResults.ScrollButtonsFontSize" Value="12"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
@@ -592,8 +598,8 @@
<controls:OverflowTextBlock x:Name="ExpressionText"
Grid.Row="1"
Margin="6,0,6,0"
Style="{StaticResource NormalStyle}"
VerticalAlignment="Bottom"
Style="{StaticResource NormalStyle}"
AutomationProperties.AutomationId="CalculatorExpression"
AutomationProperties.Name="{x:Bind Model.CalculationExpressionAutomationName, Mode=OneWay}"
IsTabStop="False"
@@ -620,12 +626,17 @@
x:Uid="CalculatorAlwaysOnTopResults"
Grid.Row="2"
Margin="6,0,6,0"
HorizontalContentAlignment="Right"
Style="{StaticResource AOTResultsStyle}"
FontSize="40"
AutomationProperties.AutomationId="CalculatorAlwaysOnTopResults"
AutomationProperties.HeadingLevel="Level1"
AutomationProperties.Name="{x:Bind Model.CalculationResultAutomationName, Mode=OneWay}"
TokensUpdated="{x:Bind Model.AreAlwaysOnTopResultsUpdated, Mode=OneWay}"
HorizontalContentAlignment="Right"
IsActive="True"
ScrollButtonsFontSize="28"
ScrollButtonsPlacement="Above"
ScrollButtonsWidth="28"
TokensUpdated="{x:Bind Model.AreAlwaysOnTopResultsUpdated, Mode=OneWay}"
UseSystemFocusVisuals="True"
Visibility="{x:Bind Model.IsAlwaysOnTop, Mode=OneWay}"/>
@@ -644,18 +655,17 @@
TabIndex="7"
Visibility="{x:Bind Model.IsProgrammer, Mode=OneWay}"/>
<Grid x:Name="HistoryButtonParent"
Visibility="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}">
<Grid x:Name="HistoryButtonParent" Visibility="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}">
<Button x:Name="HistoryButton"
x:Uid="HistoryButton"
Grid.Row="0"
IsEnabled="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}"
Style="{StaticResource HistoryButtonStyle}"
AutomationProperties.AutomationId="HistoryButton"
Command="{x:Bind HistoryButtonPressed, Mode=OneTime}"
Content="&#xe81c;"
ExitDisplayModeOnAccessKeyInvoked="False"
TabIndex="2">
x:Uid="HistoryButton"
Grid.Row="0"
Style="{StaticResource HistoryButtonStyle}"
AutomationProperties.AutomationId="HistoryButton"
Command="{x:Bind HistoryButtonPressed, Mode=OneTime}"
Content="&#xe81c;"
ExitDisplayModeOnAccessKeyInvoked="False"
IsEnabled="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}"
TabIndex="2">
<FlyoutBase.AttachedFlyout>
<Flyout x:Name="HistoryFlyout"
AutomationProperties.AutomationId="HistoryFlyout"
@@ -666,7 +676,7 @@
</FlyoutBase.AttachedFlyout>
</Button>
</Grid>
<!-- Scientific angle buttons -->
<local:CalculatorScientificAngleButtons x:Name="ScientificAngleButtons"
Grid.Row="3"
@@ -680,8 +690,8 @@
x:Uid="MemoryPanel"
Grid.Row="4"
Margin="3,0,3,0"
Visibility="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}"
AutomationProperties.HeadingLevel="Level1">
AutomationProperties.HeadingLevel="Level1"
Visibility="{x:Bind Model.IsAlwaysOnTop, Converter={StaticResource BooleanToVisibilityNegationConverter}, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" MaxWidth="80"/>
<ColumnDefinition Width="1*" MaxWidth="80"/>