Skip to content

Commit

Permalink
Theme: Improve keyboard navigation and focus behaviour
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Gembe <[email protected]>
  • Loading branch information
EchterAgo committed Sep 13, 2016
1 parent b3bb8f5 commit 967880b
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="clr-namespace:Gemini.Demo.Modules.Shell.ViewModels"
x:Class="Gemini.Demo.Modules.Shell.Views.DemoApplicationSettingsView" mc:Ignorable="d" d:DesignHeight="300"
d:DesignWidth="300" d:DataContext="{d:DesignInstance dd:DemoApplicationSettingsViewModel}">
d:DesignWidth="300" d:DataContext="{d:DesignInstance dd:DemoApplicationSettingsViewModel}"
IsTabStop="False">
<Grid>
<CheckBox IsChecked="{Binding ConfirmExit}">Confirm application exit</CheckBox>
</Grid>
Expand Down
3 changes: 2 additions & 1 deletion src/Gemini.Modules.Inspector/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
</Style>

<Style TargetType="local:ScreenColorPicker">
<Setter Property="Template">
<Setter Property="FocusVisualStyle" Value="{DynamicResource GeminiFocusVisualStyle}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:ScreenColorPicker">
<Image Source="/Gemini.Modules.Inspector;component/Resources/eyedropper_16xLG.png" />
Expand Down
5 changes: 3 additions & 2 deletions src/Gemini.Modules.Inspector/Views/InspectorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</UserControl.Resources>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel Focusable="False" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="{l:Static p:Resources.ResetAll}"
ToolTip="{l:Static p:Resources.ResetToolTip}"
Foreground="{DynamicResource EnvironmentToolWindowText}"
Expand All @@ -25,7 +25,8 @@
/>
</StackPanel>
<Grid SnapsToDevicePixels="True" UseLayoutRounding="True">
<ItemsControl ItemsSource="{Binding SelectedObject.Inspectors}"
<ItemsControl IsTabStop="False"
ItemsSource="{Binding SelectedObject.Inspectors}"
ItemTemplateSelector="{StaticResource InspectorItemTemplateSelector}" />
</Grid>
</StackPanel>
Expand Down
4 changes: 4 additions & 0 deletions src/Gemini/Gemini.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\VS2013\Controls\Focus.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\VS2013\Controls\Button.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
3 changes: 2 additions & 1 deletion src/Gemini/Modules/MainMenu/Views/MainMenuSettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
xmlns:converters="clr-namespace:Gemini.Modules.MainMenu.Converters"
l:ErrorHandling.Mode="ReturnErrorInfoPreserveNeutral"
x:Class="Gemini.Modules.MainMenu.Views.MainMenuSettingsView" mc:Ignorable="d" d:DesignHeight="300"
d:DesignWidth="300" d:DataContext="{d:DesignInstance viewModels:MainMenuSettingsViewModel}">
d:DesignWidth="300" d:DataContext="{d:DesignInstance viewModels:MainMenuSettingsViewModel}"
IsTabStop="False">
<UserControl.Resources>
<converters:CultureInfoNameConverter x:Key="CultureInfoNameConverter" />
</UserControl.Resources>
Expand Down
8 changes: 4 additions & 4 deletions src/Gemini/Modules/Settings/Views/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
<RowDefinition Height="*" />
<RowDefinition Height="10" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<ItemsControl HorizontalContentAlignment="Stretch"

<ScrollViewer IsTabStop="False" Grid.Row="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<ItemsControl IsTabStop="False" HorizontalContentAlignment="Stretch"
ItemsSource="{Binding ElementName=TreeView, Path=SelectedValue}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto"
BorderBrush="{x:Null}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ContentControl cal:View.Model="{Binding}" />
<ContentControl IsTabStop="False" cal:View.Model="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Expand Down
3 changes: 3 additions & 0 deletions src/Gemini/Themes/VS2013/BlueTheme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,7 @@
<!-- Label -->
<SolidColorBrush x:Key="Label.Static.Text" Color="#000000" />
<SolidColorBrush x:Key="Label.Disabled.Text" Color="#A4ADBA" />

<!-- Focus style -->
<SolidColorBrush x:Key="FocusStyle.Brush" Color="#000000" />
</ResourceDictionary>
8 changes: 8 additions & 0 deletions src/Gemini/Themes/VS2013/Controls/Button.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Setter Property="Foreground" Value="{DynamicResource EnvironmentToolWindowText}" />
<Setter Property="BorderBrush" Value="{DynamicResource Button.Static.Border}" />
<Setter Property="Padding" Value="3,0" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
Expand All @@ -16,6 +17,9 @@
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Button.MouseOver.Border}" />
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Button.MouseOver.Border}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
Expand All @@ -24,11 +28,15 @@
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource Button.MouseOver.Background}" />
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="Background" Value="{DynamicResource Button.MouseOver.Background}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource EnvironmentToolWindowDisabledText}" />
<Setter Property="Opacity" Value="0.5" />
</Trigger>
</Style.Triggers>
</Style>

<Style TargetType="{x:Type Button}" BasedOn="{StaticResource GeminiButtonStyle}" />
</ResourceDictionary>
13 changes: 2 additions & 11 deletions src/Gemini/Themes/VS2013/Controls/CheckBox.xaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="FocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource EnvironmentToolWindowText}" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="OptionMarkFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="14,0,0,0" SnapsToDevicePixels="true" Stroke="{DynamicResource EnvironmentToolWindowText}" StrokeThickness="1" StrokeDashArray="1 2"/>
<Rectangle Margin="14,0,0,0" SnapsToDevicePixels="true" Stroke="{DynamicResource FocusStyle.Brush}" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type CheckBox}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="FocusVisualStyle" Value="{DynamicResource GeminiFocusVisual}"/>
<Setter Property="Background" Value="{DynamicResource OptionMark.Static.Background}"/>
<Setter Property="BorderBrush" Value="{DynamicResource OptionMark.Static.Border}"/>
<Setter Property="Foreground" Value="{DynamicResource EnvironmentToolWindowText}"/>
Expand Down
20 changes: 14 additions & 6 deletions src/Gemini/Themes/VS2013/Controls/ColorPicker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Button.MouseOver.Border}" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource Button.MouseOver.Background}" />
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Button.MouseOver.Border}" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource Button.MouseOver.Background}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Fill" TargetName="Arrow" Value="{DynamicResource ColorPicker.Disabled.Glyph}" />
</Trigger>
Expand All @@ -114,12 +118,14 @@
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource Button.MouseOver.Background}" />
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="Background" Value="{DynamicResource Button.MouseOver.Background}" />
</Trigger>
</Style.Triggers>
</Style>

<Style x:Key="ColorDisplayStyle" TargetType="ContentControl">
<Setter Property="Focusable"
Value="False" />
<Setter Property="Focusable" Value="False" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
Expand Down Expand Up @@ -158,16 +164,18 @@
<Setter Property="BorderBrush" Value="{DynamicResource ColorPicker.Border}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="ButtonStyle" Value="{StaticResource ColorPickerToggleButtonStyle}" />
<Setter Property="Focusable" Value="False" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type xctk:ColorPicker}">
<Grid>
<ToggleButton x:Name="PART_ColorPickerToggleButton"
IsTabStop="True"
IsTabStop="False"
Focusable="False"
MinHeight="22"
FocusVisualStyle="{x:Null}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Expand All @@ -178,11 +186,11 @@
IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}"
Style="{TemplateBinding ButtonStyle}">
<Grid Margin="2">
<ContentControl x:Name="ColorOnly" Style="{StaticResource ColorDisplayStyle}" />
<ContentControl x:Name="ColorOnly" IsTabStop="False" Style="{StaticResource ColorDisplayStyle}" />

<Border x:Name="ColorAndName" Background="{DynamicResource ColorPicker.Background}" Visibility="Hidden">
<StackPanel Orientation="Horizontal">
<ContentControl HorizontalAlignment="Left" Width="20" Margin="2,1,4,1" Style="{StaticResource ColorDisplayStyle}" BorderThickness="1" BorderBrush="{DynamicResource ColorPicker.Border}" />
<ContentControl IsTabStop="False" HorizontalAlignment="Left" Width="20" Margin="2,1,4,1" Style="{StaticResource ColorDisplayStyle}" BorderThickness="1" BorderBrush="{DynamicResource ColorPicker.Border}" />
<TextBlock Text="{Binding SelectedColorText, RelativeSource={RelativeSource TemplatedParent}}" Foreground="{DynamicResource EnvironmentToolWindowText}" VerticalAlignment="Center" />
</StackPanel>
</Border>
Expand Down
26 changes: 13 additions & 13 deletions src/Gemini/Themes/VS2013/Controls/ComboBox.xaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">

<Style x:Key="FocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle StrokeDashArray="1 2" StrokeThickness="1" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" Margin="2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="IsTabStop" Value="True"/>
<Setter Property="Focusable" Value="True"/>
<Setter Property="ClickMode" Value="Press"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
Expand All @@ -32,6 +23,13 @@
<Setter Property="Background" TargetName="splitBorder" Value="{DynamicResource ComboBox.MouseOver.Button.Background}"/>
<Setter Property="BorderBrush" TargetName="splitBorder" Value="{DynamicResource ComboBox.MouseOver.Button.Border}"/>
</Trigger>
<Trigger Property="IsKeyboardFocusWithin" Value="true">
<Setter Property="Fill" TargetName="arrow" Value="{DynamicResource ComboBox.MouseOver.Glyph}"/>
<Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource ComboBox.MouseOver.Background}"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource ComboBox.MouseOver.Border}"/>
<Setter Property="Background" TargetName="splitBorder" Value="{DynamicResource ComboBox.MouseOver.Button.Background}"/>
<Setter Property="BorderBrush" TargetName="splitBorder" Value="{DynamicResource ComboBox.MouseOver.Button.Border}"/>
</Trigger>
<Trigger Property="IsChecked" Value="true">
<!-- TODO: This seems to not update at the point where the button is pressed but after the combo box closes again -->
<Setter Property="Fill" TargetName="arrow" Value="{DynamicResource ComboBox.Pressed.Glyph}"/>
Expand Down Expand Up @@ -168,7 +166,9 @@
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Background" Value="{DynamicResource ComboBox.Static.Background}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ComboBox.Static.Border}"/>
<Setter Property="Foreground" Value="{DynamicResource EnvironmentToolWindowText}"/>
Expand Down
16 changes: 16 additions & 0 deletions src/Gemini/Themes/VS2013/Controls/Focus.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="GeminiFocusVisualStyle">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2"
StrokeThickness="1"
Stroke="{DynamicResource FocusStyle.Brush}"
StrokeDashArray="1 2"
SnapsToDevicePixels="True" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
1 change: 1 addition & 0 deletions src/Gemini/Themes/VS2013/Controls/Merged.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ResourceDictionary Source="ColorCanvas.xaml" />
<ResourceDictionary Source="ColorPicker.xaml" />
<ResourceDictionary Source="ComboBox.xaml" />
<ResourceDictionary Source="Focus.xaml" />
<ResourceDictionary Source="Label.xaml" />
<ResourceDictionary Source="Menu.xaml" />
<ResourceDictionary Source="ScrollBar.xaml" />
Expand Down
11 changes: 1 addition & 10 deletions src/Gemini/Themes/VS2013/Controls/ScrollBar.xaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:InteractiveAsia.OptiREMOTE">
<Style x:Key="FocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ScrollBarButton" TargetType="{x:Type RepeatButton}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="FocusVisualStyle" Value="{DynamicResource GeminiFocusVisual}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
Expand Down
3 changes: 3 additions & 0 deletions src/Gemini/Themes/VS2013/DarkTheme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,7 @@
<!-- Label -->
<SolidColorBrush x:Key="Label.Static.Text" Color="#F1F1F1" />
<SolidColorBrush x:Key="Label.Disabled.Text" Color="#434346" />

<!-- Focus style -->
<SolidColorBrush x:Key="FocusStyle.Brush" Color="#F1F1F1" />
</ResourceDictionary>
3 changes: 3 additions & 0 deletions src/Gemini/Themes/VS2013/LightTheme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,7 @@
<!-- Label -->
<SolidColorBrush x:Key="Label.Static.Text" Color="#1E1E1E" />
<SolidColorBrush x:Key="Label.Disabled.Text" Color="#CCCEDB" />

<!-- Focus style -->
<SolidColorBrush x:Key="FocusStyle.Brush" Color="#1E1E1E" />
</ResourceDictionary>

0 comments on commit 967880b

Please sign in to comment.