Browse Source

Use ForgroundProperty directly where possible

pull/7746/head
Benedikt Stebner 5 years ago
parent
commit
55d28216a7
  1. 2
      src/Avalonia.Diagnostics/Diagnostics/Views/LayoutExplorerView.axaml
  2. 2
      src/Avalonia.Themes.Default/Controls/Button.xaml
  3. 2
      src/Avalonia.Themes.Default/Controls/CaptionButtons.xaml
  4. 2
      src/Avalonia.Themes.Default/Controls/CheckBox.xaml
  5. 4
      src/Avalonia.Themes.Default/Controls/DatePicker.xaml
  6. 2
      src/Avalonia.Themes.Default/Controls/RepeatButton.xaml
  7. 24
      src/Avalonia.Themes.Default/Controls/SplitButton.xaml
  8. 4
      src/Avalonia.Themes.Default/Controls/TimePicker.xaml
  9. 2
      src/Avalonia.Themes.Fluent/Controls/Button.xaml
  10. 6
      src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml
  11. 18
      src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml
  12. 2
      src/Avalonia.Themes.Fluent/Controls/ComboBoxItem.xaml
  13. 2
      src/Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml
  14. 4
      src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml
  15. 2
      src/Avalonia.Themes.Fluent/Controls/ListBox.xaml
  16. 10
      src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml
  17. 2
      src/Avalonia.Themes.Fluent/Controls/RadioButton.xaml
  18. 2
      src/Avalonia.Themes.Fluent/Controls/RepeatButton.xaml
  19. 6
      src/Avalonia.Themes.Fluent/Controls/Slider.xaml
  20. 24
      src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml
  21. 4
      src/Avalonia.Themes.Fluent/Controls/TabItem.xaml
  22. 4
      src/Avalonia.Themes.Fluent/Controls/TabStripItem.xaml
  23. 6
      src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml
  24. 2
      src/Avalonia.Themes.Fluent/Controls/ToggleButton.xaml
  25. 2
      src/Avalonia.Themes.Fluent/Controls/TreeViewItem.xaml
  26. 45
      src/Avalonia.Visuals/Media/TextFormatting/TextLineImpl.cs
  27. 4
      tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs

2
src/Avalonia.Diagnostics/Diagnostics/Views/LayoutExplorerView.axaml

@ -47,7 +47,7 @@
<controls:ThicknessEditor Grid.Row="0" Grid.Column="0" Header="margin" VerticalAlignment="Top"
HorizontalAlignment="Center"
TextElement.Foreground="{StaticResource ThicknessEditorForeground}"
Foreground="{StaticResource ThicknessEditorForeground}"
Background="{StaticResource MarginBackgroundBrush}"
Highlight="{StaticResource MarginHighlightBrush}"
Thickness="{Binding MarginThickness}">

2
src/Avalonia.Themes.Default/Controls/Button.xaml

@ -3,7 +3,7 @@
<Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}"/>
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>
<Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="4"/>

2
src/Avalonia.Themes.Default/Controls/CaptionButtons.xaml

@ -1,6 +1,6 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="CaptionButtons">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
<Setter Property="MaxHeight" Value="30" />
<Setter Property="Template">
<ControlTemplate>

2
src/Avalonia.Themes.Default/Controls/CheckBox.xaml

@ -1,6 +1,6 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="CheckBox">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/>

4
src/Avalonia.Themes.Default/Controls/DatePicker.xaml

@ -112,7 +112,7 @@
<Style Selector="DatePicker">
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlHighlightMidBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
@ -226,7 +226,7 @@
<!-- Changes foreground for watermark text when SelectedDate is null-->
<Style Selector="DatePicker:hasnodate /template/ Button#FlyoutButton TextBlock">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundLowBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundLowBrush}"/>
</Style>
<!--WinUI: DatePickerFlyoutPresenter-->

2
src/Avalonia.Themes.Default/Controls/RepeatButton.xaml

@ -6,7 +6,7 @@
Value="{DynamicResource ThemeBorderLowBrush}" />
<Setter Property="BorderThickness"
Value="{DynamicResource ThemeBorderThickness}" />
<Setter Property="TextElement.Foreground"
<Setter Property="Foreground"
Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />

24
src/Avalonia.Themes.Default/Controls/SplitButton.xaml

@ -56,7 +56,7 @@
<Style Selector="SplitButton">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackground}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForeground}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource SplitButtonBorderThemeThickness}" />
<Setter Property="HorizontalAlignment" Value="Left" />
@ -149,7 +149,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
</Style>
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton:pointerover PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
</Style>
<!-- Primary and Secondary buttons Pressed State -->
@ -160,7 +160,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton:pressed PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- SplitButton Pressed State -->
@ -172,7 +172,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton:pressed /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- Primary and Secondary buttons Flyout Open State -->
@ -184,7 +184,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton:flyout-open /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- Disabled State -->
@ -196,7 +196,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" />
</Style>
<Style Selector="SplitButton:disabled /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" />
</Style>
<!-- Checked State -->
@ -208,7 +208,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" />
</Style>
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" />
</Style>
<!-- Checked PointerOver State -->
@ -219,7 +219,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
</Style>
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton:pointerover PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
</Style>
<!-- Checked Pressed State -->
@ -230,7 +230,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton:pressed PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<!-- SplitButton Checked Pressed State -->
@ -242,7 +242,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<Style Selector="SplitButton:pressed:checked /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<!-- Checked Flyout Open State -->
@ -254,7 +254,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<Style Selector="SplitButton:checked:flyout-open /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<!-- Disabled Checked State -->
@ -266,6 +266,6 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" />
</Style>
<Style Selector="SplitButton:checked:disabled /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" />
</Style>
</Styles>

4
src/Avalonia.Themes.Default/Controls/TimePicker.xaml

@ -33,7 +33,7 @@
<Style Selector="TimePicker">
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlHighlightMidBrush}"/>
<Setter Property="BorderThickness" Value="{DynamicResource TimePickerBorderThemeThickness}"/>
@ -163,7 +163,7 @@
</Style>
<Style Selector="TimePicker:hasnotime /template/ Button#FlyoutButton TextBlock">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundLowBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundLowBrush}"/>
</Style>
<Style Selector="TimePickerPresenter">

2
src/Avalonia.Themes.Fluent/Controls/Button.xaml

@ -13,7 +13,7 @@
<Style Selector="Button">
<Setter Property="Background" Value="{DynamicResource ButtonBackground}" />
<!--<Setter Property="BackgroundSizing" Value="OuterBorderEdge" />-->
<Setter Property="TextElement.Foreground" Value="{DynamicResource ButtonForeground}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />

6
src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml

@ -56,7 +56,7 @@
<!-- Unchecked Normal State -->
<Style Selector="CheckBox">
<Setter Property="TextElement.Foreground" Value="{DynamicResource CheckBoxForegroundUnchecked}" />
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundUnchecked}" />
</Style>
<Style Selector="CheckBox">
@ -134,7 +134,7 @@
<!-- Checked Normal State -->
<Style Selector="CheckBox:checked">
<Setter Property="TextElement.Foreground" Value="{DynamicResource CheckBoxForegroundChecked}" />
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundChecked}" />
</Style>
<Style Selector="CheckBox:checked">
@ -214,7 +214,7 @@
<!-- Indeterminate Normal State -->
<Style Selector="CheckBox:indeterminate">
<Setter Property="TextElement.Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminate}" />
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForegroundIndeterminate}" />
</Style>
<Style Selector="CheckBox:indeterminate">

18
src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml

@ -30,7 +30,7 @@
<Setter Property="Padding" Value="{DynamicResource ComboBoxPadding}" />
<Setter Property="FocusAdorner" Value="{x:Null}" />
<Setter Property="MaxDropDownHeight" Value="504" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ComboBoxForeground}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForeground}" />
<Setter Property="Background" Value="{DynamicResource ComboBoxBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ComboBoxBorderThemeThickness}" />
@ -146,7 +146,7 @@
<!-- Normal State -->
<Style Selector="ComboBox /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ComboBoxPlaceHolderForeground}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForeground}" />
</Style>
<Style Selector="ComboBox /template/ Border#HighlightBackground">
@ -154,7 +154,7 @@
</Style>
<Style Selector="ComboBox /template/ PathIcon#DropDownGlyph">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForeground}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForeground}" />
<Setter Property="Data" Value="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" />
</Style>
@ -185,11 +185,11 @@
</Style>
<Style Selector="ComboBox:disabled /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}" />
</Style>
<Style Selector="ComboBox:disabled /template/ PathIcon#DropDownGlyph">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundDisabled}" />
</Style>
<!-- Focused State -->
@ -203,11 +203,11 @@
</Style>
<Style Selector="ComboBox:focus-visible /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ComboBoxForegroundFocused}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxForegroundFocused}" />
</Style>
<Style Selector="ComboBox:focus-visible /template/ PathIcon#DropDownGlyph">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocused}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocused}" />
</Style>
<!-- Focus Pressed State -->
@ -216,11 +216,11 @@
</Style>
<Style Selector="ComboBox:focused:pressed /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ComboBoxPlaceHolderForegroundFocusedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForegroundFocusedPressed}" />
</Style>
<Style Selector="ComboBox:focused:pressed /template/ PathIcon#DropDownGlyph">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocusedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocusedPressed}" />
</Style>
<!-- Error State -->

2
src/Avalonia.Themes.Fluent/Controls/ComboBoxItem.xaml

@ -18,7 +18,7 @@
</Design.PreviewWith>
<Style Selector="ComboBoxItem">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForeground}" />
<Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForeground}" />
<Setter Property="Background" Value="{DynamicResource ComboBoxItemBackground}" />
<Setter Property="Padding" Value="{DynamicResource ComboBoxItemThemePadding}" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />

2
src/Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml

@ -29,7 +29,7 @@
<Style Selector="DataValidationErrors">
<Style.Resources>
<DataTemplate x:Key="InlineDataValidationErrorTemplate">
<ItemsControl Items="{Binding}" x:DataType="DataValidationErrors" TextElement.Foreground="{DynamicResource SystemControlErrorTextForegroundBrush}">
<ItemsControl Items="{Binding}" x:DataType="DataValidationErrors" Foreground="{DynamicResource SystemControlErrorTextForegroundBrush}">
<ItemsControl.Styles>
<Style Selector="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />

4
src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml

@ -125,7 +125,7 @@
<Style Selector="DatePicker">
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource DatePickerButtonForeground}" />
<Setter Property="Foreground" Value="{DynamicResource DatePickerButtonForeground}" />
<Setter Property="Background" Value="{DynamicResource DatePickerButtonBackground}"/>
<Setter Property="BorderBrush" Value="{DynamicResource DatePickerButtonBorderBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
@ -238,7 +238,7 @@
<!-- Changes foreground for watermark text when SelectedDate is null-->
<Style Selector="DatePicker:hasnodate /template/ Button#FlyoutButton TextBlock">
<Setter Property="TextElement.Foreground" Value="{DynamicResource TextControlPlaceholderForeground}"/>
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForeground}"/>
</Style>
<Style Selector="DatePicker:error /template/ Button#FlyoutButton /template/ ContentPresenter">

2
src/Avalonia.Themes.Fluent/Controls/ListBox.xaml

@ -10,7 +10,7 @@
</Border>
</Design.PreviewWith>
<Style Selector="ListBox">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ListBoxBorderThemeThickness}" />

10
src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml

@ -53,7 +53,7 @@
<Style Selector="MenuItem">
<Setter Property="Background" Value="{DynamicResource MenuFlyoutItemBackground}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForeground}" />
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemForeground}" />
<Setter Property="Padding" Value="{DynamicResource MenuFlyoutItemThemePadding}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Template">
@ -208,7 +208,7 @@
</Style>
<Style Selector="MenuItem /template/ TextBlock#PART_InputGestureText">
<Setter Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForeground}" />
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForeground}" />
</Style>
<Style Selector="MenuItem /template/ Path#PART_ChevronPath">
<Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevron}" />
@ -221,7 +221,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPointerOver}" />
</Style>
<Style Selector="MenuItem:selected /template/ TextBlock#PART_InputGestureText">
<Setter Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPointerOver}" />
</Style>
<Style Selector="MenuItem:selected /template/ Path#PART_ChevronPath">
<Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronPointerOver}" />
@ -235,7 +235,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundPressed}" />
</Style>
<Style Selector="MenuItem:pressed /template/ Border#PART_LayoutRoot:pointerover TextBlock#PART_InputGestureText">
<Setter Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPressed}" />
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundPressed}" />
</Style>
<Style Selector="MenuItem:pressed /template/ Border#PART_LayoutRoot:pointerover Path#PART_ChevronPath">
<Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronPressed}" />
@ -248,7 +248,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemForegroundDisabled}" />
</Style>
<Style Selector="MenuItem:disabled /template/ TextBlock#PART_InputGestureText">
<Setter Property="TextElement.Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource MenuFlyoutItemKeyboardAcceleratorTextForegroundDisabled}" />
</Style>
<Style Selector="MenuItem:disabled /template/ Path#PART_ChevronPath">
<Setter Property="Fill" Value="{DynamicResource MenuFlyoutSubItemChevronDisabled}" />

2
src/Avalonia.Themes.Fluent/Controls/RadioButton.xaml

@ -11,7 +11,7 @@
</Design.PreviewWith>
<Style Selector="RadioButton">
<Setter Property="Background" Value="{DynamicResource RadioButtonBackground}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource RadioButtonForeground}" />
<Setter Property="Foreground" Value="{DynamicResource RadioButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource RadioButtonBorderBrush}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Padding" Value="8,0,0,0" />

2
src/Avalonia.Themes.Fluent/Controls/RepeatButton.xaml

@ -12,7 +12,7 @@
<Style Selector="RepeatButton">
<Setter Property="Background" Value="{DynamicResource RepeatButtonBackground}" />
<!--<Setter Property="BackgroundSizing" Value="OuterBorderEdge" />-->
<Setter Property="TextElement.Foreground" Value="{DynamicResource RepeatButtonForeground}" />
<Setter Property="Foreground" Value="{DynamicResource RepeatButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource RepeatButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />

6
src/Avalonia.Themes.Fluent/Controls/Slider.xaml

@ -38,7 +38,7 @@
<Style Selector="Slider:horizontal">
<Setter Property="Background" Value="{DynamicResource SliderTrackFill}" />
<Setter Property="BorderThickness" Value="{DynamicResource SliderBorderThemeThickness}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SliderTrackValueFill}" />
<Setter Property="Foreground" Value="{DynamicResource SliderTrackValueFill}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Template">
<ControlTemplate>
@ -100,7 +100,7 @@
<Style Selector="Slider:vertical">
<Setter Property="Background" Value="{DynamicResource SliderTrackFill}" />
<Setter Property="BorderThickness" Value="{DynamicResource SliderBorderThemeThickness}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SliderTrackValueFill}" />
<Setter Property="Foreground" Value="{DynamicResource SliderTrackValueFill}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Template">
<ControlTemplate>
@ -270,6 +270,6 @@
</Style>
<Style Selector="Slider:error">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SystemControlErrorTextForegroundBrush}" />
<Setter Property="Foreground" Value="{DynamicResource SystemControlErrorTextForegroundBrush}" />
</Style>
</Styles>

24
src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml

@ -32,7 +32,7 @@
<Style Selector="SplitButton">
<Setter Property="Background" Value="{DynamicResource SplitButtonBackground}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForeground}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource SplitButtonBorderThemeThickness}" />
<Setter Property="HorizontalAlignment" Value="Left" />
@ -125,7 +125,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
</Style>
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton:pointerover PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" />
</Style>
<!-- Primary and Secondary buttons Pressed State -->
@ -136,7 +136,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton:pressed PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- SplitButton Pressed State -->
@ -148,7 +148,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton:pressed /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- Primary and Secondary buttons Flyout Open State -->
@ -160,7 +160,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<Style Selector="SplitButton:flyout-open /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" />
</Style>
<!-- Disabled State -->
@ -172,7 +172,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" />
</Style>
<Style Selector="SplitButton:disabled /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" />
</Style>
<!-- Checked State -->
@ -184,7 +184,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" />
</Style>
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" />
</Style>
<!-- Checked PointerOver State -->
@ -195,7 +195,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
</Style>
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton:pointerover PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" />
</Style>
<!-- Checked Pressed State -->
@ -206,7 +206,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton:pressed PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<!-- SplitButton Checked Pressed State -->
@ -218,7 +218,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<Style Selector="SplitButton:pressed:checked /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<!-- Checked Flyout Open State -->
@ -230,7 +230,7 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<Style Selector="SplitButton:checked:flyout-open /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" />
</Style>
<!-- Disabled Checked State -->
@ -242,6 +242,6 @@
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" />
</Style>
<Style Selector="SplitButton:checked:disabled /template/ Button#PART_SecondaryButton PathIcon">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" />
</Style>
</Styles>

4
src/Avalonia.Themes.Fluent/Controls/TabItem.xaml

@ -19,7 +19,7 @@
<Setter Property="FontSize" Value="{DynamicResource TabItemHeaderFontSize}" />
<Setter Property="FontWeight" Value="{DynamicResource TabItemHeaderThemeFontWeight}" />
<Setter Property="Background" Value="{DynamicResource TabItemHeaderBackgroundUnselected}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TabItemHeaderForegroundUnselected}" />
<Setter Property="Foreground" Value="{DynamicResource TabItemHeaderForegroundUnselected}" />
<Setter Property="Padding" Value="{DynamicResource TabItemHeaderMargin}" />
<Setter Property="Margin" Value="0" />
<Setter Property="MinHeight" Value="{DynamicResource TabItemMinHeight}" />
@ -61,7 +61,7 @@
<!-- We don't use selector to PART_LayoutRoot, so developer can override selected item background with TabStripItem.Background -->
<Style Selector="TabItem:selected">
<Setter Property="Background" Value="{DynamicResource TabItemHeaderBackgroundSelected}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TabItemHeaderForegroundSelected}" />
<Setter Property="Foreground" Value="{DynamicResource TabItemHeaderForegroundSelected}" />
</Style>
<Style Selector="TabItem:selected /template/ Border#PART_SelectedPipe">
<Setter Property="IsVisible" Value="True" />

4
src/Avalonia.Themes.Fluent/Controls/TabStripItem.xaml

@ -18,7 +18,7 @@
<Setter Property="FontSize" Value="{DynamicResource TabItemHeaderFontSize}" />
<Setter Property="FontWeight" Value="{DynamicResource TabItemHeaderThemeFontWeight}" />
<Setter Property="Background" Value="{DynamicResource TabItemHeaderBackgroundUnselected}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TabItemHeaderForegroundUnselected}" />
<Setter Property="Foreground" Value="{DynamicResource TabItemHeaderForegroundUnselected}" />
<Setter Property="Padding" Value="{DynamicResource TabItemHeaderMargin}" />
<Setter Property="Margin" Value="0" />
<Setter Property="MinHeight" Value="{DynamicResource TabStripItemMinHeight}" />
@ -69,7 +69,7 @@
<!-- We don't use selector to PART_LayoutRoot, so developer can override selected item background with TabStripItem.Background -->
<Style Selector="TabStripItem:selected">
<Setter Property="Background" Value="{DynamicResource TabItemHeaderBackgroundSelected}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TabItemHeaderForegroundSelected}" />
<Setter Property="Foreground" Value="{DynamicResource TabItemHeaderForegroundSelected}" />
</Style>
<Style Selector="TabStripItem:selected /template/ Border#PART_SelectedPipe">
<Setter Property="IsVisible" Value="True" />

6
src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml

@ -34,7 +34,7 @@
<Style Selector="TimePicker">
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TimePickerButtonForeground}" />
<Setter Property="Foreground" Value="{DynamicResource TimePickerButtonForeground}" />
<Setter Property="Background" Value="{DynamicResource TimePickerButtonBackground}"/>
<Setter Property="BorderBrush" Value="{DynamicResource TimePickerButtonBorderBrush}"/>
<Setter Property="BorderThickness" Value="{DynamicResource TimePickerBorderThemeThickness}"/>
@ -57,7 +57,7 @@
<Button x:Name="FlyoutButton"
Grid.Row="1"
TextElement.Foreground="{TemplateBinding Foreground}"
Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
@ -164,7 +164,7 @@
</Style>
<Style Selector="TimePicker:hasnotime /template/ Button#FlyoutButton TextBlock">
<Setter Property="TextElement.Foreground" Value="{DynamicResource TextControlPlaceholderForeground}"/>
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForeground}"/>
</Style>
<Style Selector="TimePicker:error /template/ Button#FlyoutButton /template/ ContentPresenter">

2
src/Avalonia.Themes.Fluent/Controls/ToggleButton.xaml

@ -15,7 +15,7 @@
</Styles.Resources>
<Style Selector="ToggleButton">
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackground}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ToggleButtonForeground}" />
<Setter Property="Foreground" Value="{DynamicResource ToggleButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ToggleButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ToggleButtonBorderThemeThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />

2
src/Avalonia.Themes.Fluent/Controls/TreeViewItem.xaml

@ -58,7 +58,7 @@
<Setter Property="Background" Value="{DynamicResource TreeViewItemBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TreeViewItemBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource TreeViewItemBorderThemeThickness}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource TreeViewItemForeground}" />
<Setter Property="Foreground" Value="{DynamicResource TreeViewItemForeground}" />
<Setter Property="MinHeight" Value="{DynamicResource TreeViewItemMinHeight}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Template">

45
src/Avalonia.Visuals/Media/TextFormatting/TextLineImpl.cs

@ -358,7 +358,7 @@ namespace Avalonia.Media.TextFormatting
}
// Can't move, we're after the last character
var runIndex = GetRunIndexAtCharacterIndex(TextRange.End, LogicalDirection.Forward);
var runIndex = GetRunIndexAtCharacterIndex(TextRange.End, LogicalDirection.Forward, out var currentPosition);
var currentRun = _textRuns[runIndex];
@ -371,7 +371,7 @@ namespace Avalonia.Media.TextFormatting
}
default:
{
characterHit = new CharacterHit(currentRun.Text.Start, currentRun.Text.Length);
characterHit = new CharacterHit(currentPosition + currentRun.TextSourceLength);
break;
}
}
@ -804,7 +804,7 @@ namespace Avalonia.Media.TextFormatting
codepointIndex = TextRange.Start;
}
var runIndex = GetRunIndexAtCharacterIndex(codepointIndex, LogicalDirection.Forward);
var runIndex = GetRunIndexAtCharacterIndex(codepointIndex, LogicalDirection.Forward, out var currentPosition);
while (runIndex < _textRuns.Count)
{
@ -848,9 +848,9 @@ namespace Avalonia.Media.TextFormatting
{
var textPosition = characterHit.FirstCharacterIndex + characterHit.TrailingLength;
if (textPosition == currentRun.Text.Start)
if (textPosition == currentPosition)
{
nextCharacterHit = new CharacterHit(currentRun.Text.Start + currentRun.Text.Length);
nextCharacterHit = new CharacterHit(currentPosition + currentRun.TextSourceLength);
return true;
}
@ -859,6 +859,7 @@ namespace Avalonia.Media.TextFormatting
}
}
currentPosition += currentRun.TextSourceLength;
runIndex++;
}
@ -889,7 +890,7 @@ namespace Avalonia.Media.TextFormatting
return false; // Cannot go backward anymore.
}
var runIndex = GetRunIndexAtCharacterIndex(characterIndex, LogicalDirection.Backward);
var runIndex = GetRunIndexAtCharacterIndex(characterIndex, LogicalDirection.Backward, out var currentPosition);
while (runIndex >= 0)
{
@ -924,9 +925,9 @@ namespace Avalonia.Media.TextFormatting
}
default:
{
if(characterIndex == currentRun.Text.Start + currentRun.Text.Length)
if(characterIndex == currentPosition + currentRun.TextSourceLength)
{
previousCharacterHit = new CharacterHit(currentRun.Text.Start);
previousCharacterHit = new CharacterHit(currentPosition);
return true;
}
@ -935,6 +936,7 @@ namespace Avalonia.Media.TextFormatting
}
}
currentPosition -= currentRun.TextSourceLength;
runIndex--;
}
@ -946,10 +948,12 @@ namespace Avalonia.Media.TextFormatting
/// </summary>
/// <param name="codepointIndex">The codepoint index.</param>
/// <param name="direction">The logical direction.</param>
/// <param name="textPosition">The text position of the found run index.</param>
/// <returns>The text run index.</returns>
private int GetRunIndexAtCharacterIndex(int codepointIndex, LogicalDirection direction)
private int GetRunIndexAtCharacterIndex(int codepointIndex, LogicalDirection direction, out int textPosition)
{
var runIndex = 0;
textPosition = TextRange.Start;
DrawableTextRun? previousRun = null;
while (runIndex < _textRuns.Count)
@ -994,31 +998,22 @@ namespace Avalonia.Media.TextFormatting
}
}
if (runIndex + 1 < _textRuns.Count)
{
runIndex++;
previousRun = currentRun;
}
else
if (runIndex + 1 >= _textRuns.Count)
{
break;
return runIndex;
}
break;
}
default:
{
if (codepointIndex == currentRun.Text.Start)
if (codepointIndex == textPosition)
{
return runIndex;
}
if (runIndex + 1 < _textRuns.Count)
{
runIndex++;
previousRun = currentRun;
}
else
if (runIndex + 1 >= _textRuns.Count)
{
return runIndex;
}
@ -1026,6 +1021,10 @@ namespace Avalonia.Media.TextFormatting
break;
}
}
runIndex++;
previousRun = currentRun;
textPosition += currentRun.TextSourceLength;
}
return runIndex;

4
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs

@ -450,8 +450,8 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
currentHit = textLine.GetNextCaretCharacterHit(currentHit);
Assert.Equal(3, currentHit.FirstCharacterIndex);
Assert.Equal(1, currentHit.TrailingLength);
Assert.Equal(4, currentHit.FirstCharacterIndex);
Assert.Equal(0, currentHit.TrailingLength);
}
}

Loading…
Cancel
Save