Browse Source

Merge branch 'master' into fixOpacityClip

pull/11394/head
Benedikt Stebner 3 years ago
committed by GitHub
parent
commit
8a55ebde23
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .ncrunch/AppWithoutLifetime.v3.ncrunchproject
  2. 5
      .ncrunch/Avalonia.Headless.NUnit.netstandard2.0.v3.ncrunchproject
  3. 5
      .ncrunch/Avalonia.Headless.XUnit.netstandard2.0.v3.ncrunchproject
  4. 11
      Avalonia.Desktop.slnf
  5. 2
      packages/Avalonia/Avalonia.csproj
  6. 3
      samples/ControlCatalog/Pages/ColorPickerPage.xaml
  7. 5
      samples/ControlCatalog/Pages/DragAndDropPage.xaml.cs
  8. 29
      samples/ControlCatalog/Pages/TabControlPage.xaml
  9. 2
      samples/GpuInterop/VulkanDemo/VulkanContext.cs
  10. 3
      samples/IntegrationTestApp/MainWindow.axaml
  11. 6
      samples/VirtualizationDemo/ViewModels/PlaygroundPageViewModel.cs
  12. 112
      src/Android/Avalonia.Android/Platform/Input/AndroidKeyboardDevice.cs
  13. 4
      src/Avalonia.Base/Animation/Animatable.cs
  14. 2
      src/Avalonia.Base/Animation/AnimatorKeyFrame.cs
  15. 1
      src/Avalonia.Base/Avalonia.Base.csproj
  16. 2
      src/Avalonia.Base/AvaloniaProperty.cs
  17. 2
      src/Avalonia.Base/AvaloniaPropertyExtensions.cs
  18. 2
      src/Avalonia.Base/AvaloniaProperty`1.cs
  19. 2
      src/Avalonia.Base/Collections/AvaloniaListConverter.cs
  20. 2
      src/Avalonia.Base/Collections/Pooled/ClearMode.cs
  21. 2
      src/Avalonia.Base/Collections/Pooled/IReadOnlyPooledList.cs
  22. 2
      src/Avalonia.Base/Collections/Pooled/PooledList.cs
  23. 2
      src/Avalonia.Base/Collections/Pooled/PooledStack.cs
  24. 2
      src/Avalonia.Base/Controls/ChildNameScope.cs
  25. 4
      src/Avalonia.Base/Data/BindingValue.cs
  26. 2
      src/Avalonia.Base/Data/Converters/DefaultValueConverter.cs
  27. 2
      src/Avalonia.Base/Data/Core/BindingExpression.cs
  28. 2
      src/Avalonia.Base/Data/Core/CommonPropertyNames.cs
  29. 2
      src/Avalonia.Base/Data/IndexerBinding.cs
  30. 2
      src/Avalonia.Base/Data/TemplateBinding.cs
  31. 18
      src/Avalonia.Base/Diagnostics/AppliedStyle.cs
  32. 2
      src/Avalonia.Base/Diagnostics/IAvaloniaObjectDebug.cs
  33. 2
      src/Avalonia.Base/Diagnostics/INotifyCollectionChangedDebug.cs
  34. 4
      src/Avalonia.Base/Diagnostics/StyleDiagnostics.cs
  35. 8
      src/Avalonia.Base/Diagnostics/TrimmingMessages.cs
  36. 2
      src/Avalonia.Base/EnumExtensions.cs
  37. 6
      src/Avalonia.Base/Input/AccessKeyHandler.cs
  38. 56
      src/Avalonia.Base/Input/FocusManager.cs
  39. 3
      src/Avalonia.Base/Input/IAccessKeyHandler.cs
  40. 36
      src/Avalonia.Base/Input/IFocusManager.cs
  41. 3
      src/Avalonia.Base/Input/IFocusScope.cs
  42. 4
      src/Avalonia.Base/Input/IInputElement.cs
  43. 13
      src/Avalonia.Base/Input/IInputRoot.cs
  44. 8
      src/Avalonia.Base/Input/IKeyboardDevice.cs
  45. 5
      src/Avalonia.Base/Input/IMainMenu.cs
  46. 17
      src/Avalonia.Base/Input/InputElement.cs
  47. 4
      src/Avalonia.Base/Input/KeyboardDevice.cs
  48. 18
      src/Avalonia.Base/Input/KeyboardNavigationHandler.cs
  49. 2
      src/Avalonia.Base/Input/MouseDevice.cs
  50. 6
      src/Avalonia.Base/Input/Navigation/TabNavigation.cs
  51. 2
      src/Avalonia.Base/Input/PenDevice.cs
  52. 2
      src/Avalonia.Base/Input/TouchDevice.cs
  53. 2
      src/Avalonia.Base/Interactivity/Interactive.cs
  54. 46
      src/Avalonia.Base/Interactivity/RoutedPropertyChangedEventArgs.cs
  55. 2
      src/Avalonia.Base/Logging/TraceLogSink.cs
  56. 2
      src/Avalonia.Base/Media/ArcSegment.cs
  57. 2
      src/Avalonia.Base/Media/BezierSegment .cs
  58. 32
      src/Avalonia.Base/Media/Color.cs
  59. 78
      src/Avalonia.Base/Media/HslColor.cs
  60. 78
      src/Avalonia.Base/Media/HsvColor.cs
  61. 2
      src/Avalonia.Base/Media/Imaging/Bitmap.cs
  62. 2
      src/Avalonia.Base/Media/Immutable/ImmutableTileBrush.cs
  63. 2
      src/Avalonia.Base/Media/LineSegment.cs
  64. 4
      src/Avalonia.Base/Media/PathSegment.cs
  65. 2
      src/Avalonia.Base/Media/PolyLineSegment.cs
  66. 2
      src/Avalonia.Base/Media/QuadraticBezierSegment .cs
  67. 1
      src/Avalonia.Base/Media/StreamGeometryContext.cs
  68. 18
      src/Avalonia.Base/Media/TextFormatting/TextLayout.cs
  69. 2
      src/Avalonia.Base/Media/Transformation/TransformParser.cs
  70. 6
      src/Avalonia.Base/Platform/Storage/NameCollisionOption.cs
  71. 1
      src/Avalonia.Base/Properties/AssemblyInfo.cs
  72. 2
      src/Avalonia.Base/PropertyStore/DirectUntypedBindingObserver.cs
  73. 5
      src/Avalonia.Base/PropertyStore/EffectiveValue`1.cs
  74. 2
      src/Avalonia.Base/PropertyStore/LocalValueBindingObserver.cs
  75. 4
      src/Avalonia.Base/PropertyStore/UntypedValueUtils.cs
  76. 2
      src/Avalonia.Base/Rendering/ManagedDeferredRendererLock.cs
  77. 50
      src/Avalonia.Base/Rendering/RendererBase.cs
  78. 2
      src/Avalonia.Base/Rendering/Utilities/TileBrushCalculator.cs
  79. 3
      src/Avalonia.Base/Rendering/ZIndexComparer.cs
  80. 6
      src/Avalonia.Base/StyledElement.cs
  81. 2
      src/Avalonia.Base/StyledProperty.cs
  82. 3
      src/Avalonia.Base/Styling/Activators/IStyleActivator.cs
  83. 3
      src/Avalonia.Base/Styling/Activators/IStyleActivatorSink.cs
  84. 12
      src/Avalonia.Base/Styling/ChildSelector.cs
  85. 12
      src/Avalonia.Base/Styling/DescendentSelector.cs
  86. 24
      src/Avalonia.Base/Styling/ISetter.cs
  87. 2
      src/Avalonia.Base/Styling/ISetterInstance.cs
  88. 4
      src/Avalonia.Base/Styling/ISetterValue.cs
  89. 3
      src/Avalonia.Base/Styling/IStyleInstance.cs
  90. 12
      src/Avalonia.Base/Styling/NestingSelector.cs
  91. 12
      src/Avalonia.Base/Styling/NotSelector.cs
  92. 14
      src/Avalonia.Base/Styling/NthChildSelector.cs
  93. 2
      src/Avalonia.Base/Styling/NthLastChildSelector.cs
  94. 12
      src/Avalonia.Base/Styling/OrSelector.cs
  95. 16
      src/Avalonia.Base/Styling/PropertyEqualsSelector.cs
  96. 14
      src/Avalonia.Base/Styling/Selector.cs
  97. 4
      src/Avalonia.Base/Styling/SelectorMatch.cs
  98. 6
      src/Avalonia.Base/Styling/Setter.cs
  99. 12
      src/Avalonia.Base/Styling/SetterBase.cs
  100. 6
      src/Avalonia.Base/Styling/StyleBase.cs

5
.ncrunch/AppWithoutLifetime.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

5
.ncrunch/Avalonia.Headless.NUnit.netstandard2.0.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

5
.ncrunch/Avalonia.Headless.XUnit.netstandard2.0.v3.ncrunchproject

@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>

11
Avalonia.Desktop.slnf

@ -39,14 +39,13 @@
"src\\Markup\\Avalonia.Markup.Xaml\\Avalonia.Markup.Xaml.csproj",
"src\\Markup\\Avalonia.Markup\\Avalonia.Markup.csproj",
"src\\Skia\\Avalonia.Skia\\Avalonia.Skia.csproj",
"src\\tools\\Avalonia.Generators\\Avalonia.Generators.csproj",
"src\\tools\\Avalonia.Generators\\Avalonia.Generators.csproj",
"src\\tools\\DevAnalyzers\\DevAnalyzers.csproj",
"src\\tools\\DevGenerators\\DevGenerators.csproj",
"src\\tools\\PublicAnalyzers\\Avalonia.Analyzers.csproj",
"src\\Windows\\Avalonia.Direct2D1\\Avalonia.Direct2D1.csproj",
"src\\Windows\\Avalonia.Win32.Interop\\Avalonia.Win32.Interop.csproj",
"src\\Windows\\Avalonia.Win32\\Avalonia.Win32.csproj",
"src\\tools\\Avalonia.Analyzers\\Avalonia.Analyzers.csproj",
"src\\tools\\Avalonia.Generators\\Avalonia.Generators.csproj",
"src\\tools\\DevAnalyzers\\DevAnalyzers.csproj",
"src\\tools\\DevGenerators\\DevGenerators.csproj",
"tests\\Avalonia.Base.UnitTests\\Avalonia.Base.UnitTests.csproj",
"tests\\Avalonia.Benchmarks\\Avalonia.Benchmarks.csproj",
"tests\\Avalonia.Controls.DataGrid.UnitTests\\Avalonia.Controls.DataGrid.UnitTests.csproj",
@ -66,4 +65,4 @@
"tests\\Avalonia.UnitTests\\Avalonia.UnitTests.csproj"
]
}
}
}

2
packages/Avalonia/Avalonia.csproj

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia.BuildServices" Version="0.0.12" />
<PackageReference Include="Avalonia.BuildServices" Version="0.0.16" />
<ProjectReference Include="../../src/Avalonia.Remote.Protocol/Avalonia.Remote.Protocol.csproj" />
<ProjectReference Include="../../src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj">
<PrivateAssets>all</PrivateAssets>

3
samples/ControlCatalog/Pages/ColorPickerPage.xaml

@ -103,7 +103,8 @@
HsvColor="{Binding HsvColor, ElementName=ColorSpectrum1}" />-->
<ColorPreviewer Grid.Row="8"
IsAccentColorsVisible="False"
HsvColor="{Binding HsvColor, ElementName=ColorSpectrum1}" />
HsvColor="{Binding HsvColor, ElementName=ColorSpectrum1}"
Margin="0,2,0,0" />
</Grid>
</Grid>
</UserControl>

5
samples/ControlCatalog/Pages/DragAndDropPage.xaml.cs

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Avalonia.Controls;
@ -23,7 +22,7 @@ namespace ControlCatalog.Pages
$"Text was dragged {++textCount} times"), DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link);
SetupDnd("Custom", d => d.Set(CustomFormat, "Test123"), DragDropEffects.Move);
SetupDnd("Files", d => d.Set(DataFormats.Files, new[] { Assembly.GetEntryAssembly()?.GetModules().FirstOrDefault()?.FullyQualifiedName }), DragDropEffects.Copy);
SetupDnd("Files", async d => d.Set(DataFormats.Files, new[] { await (VisualRoot as TopLevel)!.StorageProvider.TryGetFileFromPathAsync(Assembly.GetEntryAssembly()?.GetModules().FirstOrDefault()?.FullyQualifiedName) }), DragDropEffects.Copy);
}
void SetupDnd(string suffix, Action<DataObject> factory, DragDropEffects effects)
@ -99,7 +98,7 @@ namespace ControlCatalog.Pages
{
if (item is IStorageFile file)
{
var content = await DialogsPage.ReadTextFromFile(file, 1000);
var content = await DialogsPage.ReadTextFromFile(file, 500);
contentStr += $"File {item.Name}:{Environment.NewLine}{content}{Environment.NewLine}{Environment.NewLine}";
}
else if (item is IStorageFolder folder)

29
samples/ControlCatalog/Pages/TabControlPage.xaml

@ -4,7 +4,27 @@
xmlns="https://github.com/avaloniaui"
xmlns:viewModels="using:ControlCatalog.ViewModels"
x:DataType="viewModels:TabControlPageViewModel">
<DockPanel>
<DockPanel Classes.WithContentTemplates="{Binding IsChecked, ElementName=UseContentTemplates}">
<DockPanel.Styles>
<Style Selector="DockPanel.WithContentTemplates">
<Style Selector="^ TabItem">
<Setter Property="ContentTemplate">
<DataTemplate x:CompileBindings="False">
<Border BorderBrush="Red" BorderThickness="10">
<ContentPresenter Content="{Binding}"/>
</Border>
</DataTemplate>
</Setter>
</Style>
<Style Selector="^ TabControl">
<Setter Property="ContentTemplate">
<DataTemplate>
<TextBlock Text="This template should be overriden by each TabItem's template."/>
</DataTemplate>
</Setter>
</Style>
</Style>
</DockPanel.Styles>
<TextBlock
DockPanel.Dock="Top"
Classes="h2"
@ -55,14 +75,14 @@
Margin="0 16"
DisplayMemberBinding="{Binding Header, x:DataType=viewModels:TabControlPageViewModelItem}"
TabStripPlacement="{Binding TabPlacement}">
<TabControl.ContentTemplate>
<TabControl.DataTemplates>
<DataTemplate x:DataType="viewModels:TabControlPageViewModelItem">
<StackPanel Orientation="Vertical" Spacing="8">
<TextBlock Text="{Binding Text}"/>
<Image Source="{Binding Image}" Width="300"/>
</StackPanel>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl.DataTemplates>
<TabControl.Styles>
<Style Selector="TabItem" x:DataType="viewModels:TabControlPageViewModelItem">
<Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
@ -78,12 +98,13 @@
HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center">Tab Placement:</TextBlock>
<ComboBox SelectedIndex="{Binding TabPlacement, Mode=TwoWay}">
<ComboBox SelectedIndex="{Binding TabPlacement, Mode=TwoWay}" Width="100">
<ComboBoxItem>Left</ComboBoxItem>
<ComboBoxItem>Bottom</ComboBoxItem>
<ComboBoxItem>Right</ComboBoxItem>
<ComboBoxItem>Top</ComboBoxItem>
</ComboBox>
<CheckBox Name="UseContentTemplates">Set TabItem.ContentTemplate</CheckBox>
</StackPanel>
</Grid>
</DockPanel>

2
samples/GpuInterop/VulkanDemo/VulkanContext.cs

@ -174,7 +174,7 @@ public unsafe class VulkanContext : IDisposable
for (uint queueFamilyIndex = 0; queueFamilyIndex < queueFamilyCount; queueFamilyIndex++)
{
var family = familyProperties[queueFamilyIndex];
if (!family.QueueFlags.HasAllFlags(QueueFlags.GraphicsBit))
if (!family.QueueFlags.HasFlag(QueueFlags.GraphicsBit))
continue;

3
samples/IntegrationTestApp/MainWindow.axaml

@ -47,6 +47,9 @@
<Button Name="DisabledButton" IsEnabled="False">
Disabled Button
</Button>
<Button Name="EffectivelyDisabledButton" Command="{ReflectionBinding DoesntExist}">
Effectively Disabled Button
</Button>
<Button Name="BasicButton">
Basic Button
</Button>

6
samples/VirtualizationDemo/ViewModels/PlaygroundPageViewModel.cs

@ -24,19 +24,19 @@ public class PlaygroundPageViewModel : ViewModelBase
public bool Multiple
{
get => _selectionMode.HasAnyFlag(SelectionMode.Multiple);
get => _selectionMode.HasFlag(SelectionMode.Multiple);
set => SetSelectionMode(SelectionMode.Multiple, value);
}
public bool Toggle
{
get => _selectionMode.HasAnyFlag(SelectionMode.Toggle);
get => _selectionMode.HasFlag(SelectionMode.Toggle);
set => SetSelectionMode(SelectionMode.Toggle, value);
}
public bool AlwaysSelected
{
get => _selectionMode.HasAnyFlag(SelectionMode.AlwaysSelected);
get => _selectionMode.HasFlag(SelectionMode.AlwaysSelected);
set => SetSelectionMode(SelectionMode.AlwaysSelected, value);
}

112
src/Android/Avalonia.Android/Platform/Input/AndroidKeyboardDevice.cs

@ -5,8 +5,9 @@ using Avalonia.Input;
namespace Avalonia.Android.Platform.Input
{
internal class AndroidKeyboardDevice : KeyboardDevice, IKeyboardDevice {
private static readonly Dictionary<Keycode, Key> KeyDic = new Dictionary<Keycode, Key>
internal class AndroidKeyboardDevice : KeyboardDevice, IKeyboardDevice
{
private static readonly Dictionary<Keycode, Key> KeyDic = new Dictionary<Keycode, Key>
{
// { Keycode.Cancel?, Key.Cancel },
{ Keycode.Del, Key.Back },
@ -15,7 +16,7 @@ namespace Avalonia.Android.Platform.Input
{ Keycode.Clear, Key.Clear },
{ Keycode.Enter, Key.Return },
{ Keycode.MediaPause, Key.Pause },
//{ Keycode.?, Key.CapsLock }
{ Keycode.CapsLock, Key.CapsLock },
//{ Keycode.?, Key.HangulMode }
//{ Keycode.?, Key.JunjaMode }
//{ Keycode.?, Key.FinalMode }
@ -28,8 +29,8 @@ namespace Avalonia.Android.Platform.Input
{ Keycode.Space, Key.Space },
{ Keycode.PageUp, Key.Prior },
{ Keycode.PageDown, Key.PageDown },
// { Keycode.end?, Key.End },
{ Keycode.Home, Key.Home },
{ Keycode.MoveEnd, Key.End },
{ Keycode.MoveHome, Key.Home },
{ Keycode.DpadLeft, Key.Left },
{ Keycode.DpadUp, Key.Up },
{ Keycode.DpadRight, Key.Right },
@ -37,20 +38,20 @@ namespace Avalonia.Android.Platform.Input
// { Keycode.ButtonSelect?, Key.Select },
// { Keycode.print?, Key.Print },
//{ Keycode.execute?, Key.Execute },
// { Keycode.snap, Key.Snapshot }
//{ Keycode.snap?, Key.Snapshot }
{ Keycode.Insert, Key.Insert },
{ Keycode.ForwardDel, Key.Delete },
//{ Keycode.help, Key.Help },
//{ Keycode.?, Key.D0 }
//{ Keycode.?, Key.D1 }
//{ Keycode.?, Key.D2 }
//{ Keycode.?, Key.D3 }
//{ Keycode.?, Key.D4 }
//{ Keycode.?, Key.D5 }
//{ Keycode.?, Key.D6 }
//{ Keycode.?, Key.D7 }
//{ Keycode.?, Key.D8 }
//{ Keycode.?, Key.D9 }
{ Keycode.Help, Key.Help },
{ Keycode.Num0, Key.D0 },
{ Keycode.Num1, Key.D1 },
{ Keycode.Num2, Key.D2 },
{ Keycode.Num3, Key.D3 },
{ Keycode.Num4, Key.D4 },
{ Keycode.Num5, Key.D5 },
{ Keycode.Num6, Key.D6 },
{ Keycode.Num7, Key.D7 },
{ Keycode.Num8, Key.D8 },
{ Keycode.Num9, Key.D9 },
{ Keycode.A, Key.A },
{ Keycode.B, Key.B },
{ Keycode.C, Key.C },
@ -106,22 +107,22 @@ namespace Avalonia.Android.Platform.Input
//{ Keycode.?, Key.LWin }
//{ Keycode.?, Key.RWin }
//{ Keycode.?, Key.Apps }
//{ Keycode.?, Key.Sleep }
//{ Keycode.?, Key.NumPad0 }
//{ Keycode.?, Key.NumPad1 }
//{ Keycode.?, Key.NumPad2 }
//{ Keycode.?, Key.NumPad3 }
//{ Keycode.?, Key.NumPad4 }
//{ Keycode.?, Key.NumPad5 }
//{ Keycode.?, Key.NumPad6 }
//{ Keycode.?, Key.NumPad7 }
//{ Keycode.?, Key.NumPad8 }
//{ Keycode.?, Key.NumPad9 }
{ Keycode.Sleep, Key.Sleep },
{ Keycode.Numpad0, Key.NumPad0 },
{ Keycode.Numpad1, Key.NumPad1 },
{ Keycode.Numpad2, Key.NumPad2 },
{ Keycode.Numpad3, Key.NumPad3 },
{ Keycode.Numpad4, Key.NumPad4 },
{ Keycode.Numpad5, Key.NumPad5 },
{ Keycode.Numpad6, Key.NumPad6 },
{ Keycode.Numpad7, Key.NumPad7 },
{ Keycode.Numpad8, Key.NumPad8 },
{ Keycode.Numpad9, Key.NumPad9 },
{ Keycode.NumpadMultiply, Key.Multiply },
{ Keycode.NumpadAdd, Key.Add },
{ Keycode.NumpadComma, Key.Separator },
{ Keycode.NumpadSubtract, Key.Subtract },
//{ Keycode.numpaddecimal?, Key.Decimal }
{ Keycode.NumpadDot, Key.Decimal },
{ Keycode.NumpadDivide, Key.Divide },
{ Keycode.F1, Key.F1 },
{ Keycode.F2, Key.F2 },
@ -147,14 +148,14 @@ namespace Avalonia.Android.Platform.Input
//{ Keycode.R2, Key.F22 },
//{ Keycode.F23, Key.F23 },
//{ Keycode.R4, Key.F24 },
// { Keycode.numpad, Key.NumLock }
{ Keycode.NumLock, Key.NumLock },
{ Keycode.ScrollLock, Key.Scroll },
{ Keycode.ShiftLeft, Key.LeftShift },
//{ Keycode.?, Key.RightShift }
//{ Keycode.?, Key.LeftCtrl }
//{ Keycode.?, Key.RightCtrl }
//{ Keycode.?, Key.LeftAlt }
//{ Keycode.?, Key.RightAlt }
{ Keycode.ShiftRight, Key.RightShift },
{ Keycode.CtrlLeft, Key.LeftCtrl },
{ Keycode.CtrlRight, Key.RightCtrl },
{ Keycode.AltLeft, Key.LeftAlt },
{ Keycode.AltRight, Key.RightAlt },
//{ Keycode.?, Key.BrowserBack }
//{ Keycode.?, Key.BrowserForward }
//{ Keycode.?, Key.BrowserRefresh }
@ -163,28 +164,30 @@ namespace Avalonia.Android.Platform.Input
//{ Keycode.?, Key.BrowserFavorites }
//{ Keycode.?, Key.BrowserHome }
//{ Keycode.?, Key.VolumeMute }
//{ Keycode.?, Key.VolumeDown }
//{ Keycode.?, Key.VolumeUp }
//{ Keycode.?, Key.MediaNextTrack }
//{ Keycode.?, Key.MediaPreviousTrack }
//{ Keycode.?, Key.MediaStop }
//{ Keycode.?, Key.MediaPlayPause }
{ Keycode.VolumeDown, Key.VolumeDown },
{ Keycode.VolumeUp, Key.VolumeUp },
{ Keycode.MediaNext, Key.MediaNextTrack },
{ Keycode.MediaPrevious, Key.MediaPreviousTrack },
{ Keycode.MediaStop, Key.MediaStop },
{ Keycode.MediaPlayPause, Key.MediaPlayPause },
//{ Keycode.?, Key.LaunchMail }
//{ Keycode.?, Key.SelectMedia }
//{ Keycode.?, Key.LaunchApplication1 }
//{ Keycode.?, Key.LaunchApplication2 }
//{ Keycode.?, Key.OemSemicolon }
//{ Keycode.?, Key.OemPlus }
//{ Keycode.?, Key.OemComma }
//{ Keycode.?, Key.OemMinus }
//{ Keycode.?, Key.OemPeriod }
{ Keycode.Semicolon, Key.OemSemicolon },
{ Keycode.Plus, Key.OemPlus },
{ Keycode.Comma, Key.OemComma },
{ Keycode.Minus, Key.OemMinus },
{ Keycode.Period, Key.OemPeriod },
//{ Keycode.?, Key.Oem2 }
//{ Keycode.?, Key.OemTilde }
{ Keycode.Grave, Key.OemTilde },
//{ Keycode.?, Key.AbntC1 }
//{ Keycode.?, Key.AbntC2 }
//{ Keycode.?, Key.Oem4 }
//{ Keycode.?, Key.OemPipe }
//{ Keycode.?, Key.OemCloseBrackets }
{ Keycode.Apostrophe, Key.OemQuotes },
{ Keycode.Slash, Key.OemQuestion },
{ Keycode.LeftBracket, Key.OemOpenBrackets },
{ Keycode.RightBracket, Key.OemCloseBrackets },
//{ Keycode.?, Key.Oem7 }
//{ Keycode.?, Key.Oem8 }
//{ Keycode.?, Key.Oem102 }
@ -200,17 +203,18 @@ namespace Avalonia.Android.Platform.Input
//{ Keycode.?, Key.DbeEnterWordRegisterMode }
//{ Keycode.?, Key.DbeEnterImeConfigureMode }
//{ Keycode.?, Key.EraseEof }
//{ Keycode.?, Key.Play }
{ Keycode.MediaPlay, Key.Play },
//{ Keycode.?, Key.Zoom }
//{ Keycode.?, Key.NoName }
//{ Keycode.?, Key.DbeEnterDialogConversionMode }
//{ Keycode.?, Key.OemClear }
//{ Keycode.?, Key.DeadCharProcessed }
{ Keycode.Backslash, Key.OemBackslash }
};
internal static Key ConvertKey(Keycode key) {
Key result;
return KeyDic.TryGetValue(key, out result) ? result : Key.None;
internal static Key ConvertKey(Keycode key)
{
return KeyDic.TryGetValue(key, out var result) ? result : Key.None;
}
}
}
}

4
src/Avalonia.Base/Animation/Animatable.cs

@ -58,7 +58,7 @@ namespace Avalonia.Animation
/// This method should not be called from user code, it will be called automatically by the framework
/// when a control is added to the visual tree.
/// </remarks>
protected void EnableTransitions()
internal void EnableTransitions()
{
if (!_transitionsEnabled)
{
@ -83,7 +83,7 @@ namespace Avalonia.Animation
/// This method should not be called from user code, it will be called automatically by the framework
/// when a control is removed from the visual tree.
/// </remarks>
protected void DisableTransitions()
internal void DisableTransitions()
{
if (_transitionsEnabled)
{

2
src/Avalonia.Base/Animation/AnimatorKeyFrame.cs

@ -67,7 +67,7 @@ namespace Avalonia.Animation
}
}
[RequiresUnreferencedCode(TrimmingMessages.TypeConvertionRequiresUnreferencedCodeMessage)]
[RequiresUnreferencedCode(TrimmingMessages.TypeConversionRequiresUnreferencedCodeMessage)]
public T GetTypedValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>()
{
var typeConv = TypeDescriptor.GetConverter(typeof(T));

1
src/Avalonia.Base/Avalonia.Base.csproj

@ -63,6 +63,7 @@
<InternalsVisibleTo Include="Avalonia.iOS, PublicKey=$(AvaloniaPublicKey)" />
<InternalsVisibleTo Include="Avalonia.Dialogs, PublicKey=$(AvaloniaPublicKey)" />
<InternalsVisibleTo Include="Avalonia.Diagnostics, PublicKey=$(AvaloniaPublicKey)" />
<InternalsVisibleTo Include="Avalonia.LinuxFramebuffer, PublicKey=$(AvaloniaPublicKey)" />
<InternalsVisibleTo Include="MiniMvvm, PublicKey=$(AvaloniaPublicKey)" />
<InternalsVisibleTo Include="ControlCatalog, PublicKey=$(AvaloniaPublicKey)" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" />

2
src/Avalonia.Base/AvaloniaProperty.cs

@ -476,7 +476,7 @@ namespace Avalonia
/// </summary>
/// <param name="value">The value.</param>
/// <returns>True if the value is valid, otherwise false.</returns>
[RequiresUnreferencedCode(TrimmingMessages.ImplicitTypeConvertionRequiresUnreferencedCodeMessage)]
[RequiresUnreferencedCode(TrimmingMessages.ImplicitTypeConversionRequiresUnreferencedCodeMessage)]
public bool IsValidValue(object? value)
{
return TypeUtilities.TryConvertImplicit(PropertyType, value, out _);

2
src/Avalonia.Base/AvaloniaPropertyExtensions.cs

@ -7,7 +7,7 @@ namespace Avalonia
/// <summary>
/// Extensions for <see cref="AvaloniaProperty"/>.
/// </summary>
public static class AvaloniaPropertyExtensions
internal static class AvaloniaPropertyExtensions
{
/// <summary>
/// Checks if values of given property can affect rendering (via <see cref="IAffectsRender"/>).

2
src/Avalonia.Base/AvaloniaProperty`1.cs

@ -70,7 +70,7 @@ namespace Avalonia
private protected override IObservable<AvaloniaPropertyChangedEventArgs> GetChanged() => Changed;
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConvertionSupressWarningMessage)]
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConversionSupressWarningMessage)]
private protected BindingValue<object?> TryConvert(object? value)
{
if (value == UnsetValue)

2
src/Avalonia.Base/Collections/AvaloniaListConverter.cs

@ -9,7 +9,7 @@ namespace Avalonia.Collections
/// <summary>
/// Creates an <see cref="AvaloniaList{T}"/> from a string representation.
/// </summary>
[RequiresUnreferencedCode(TrimmingMessages.TypeConvertionRequiresUnreferencedCodeMessage)]
[RequiresUnreferencedCode(TrimmingMessages.TypeConversionRequiresUnreferencedCodeMessage)]
public class AvaloniaListConverter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T> : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)

2
src/Avalonia.Base/Collections/Pooled/ClearMode.cs

@ -9,7 +9,7 @@ namespace Avalonia.Collections.Pooled
/// what each option does before using anything other than the default
/// of Auto.
/// </summary>
public enum ClearMode
internal enum ClearMode
{
/// <summary>
/// <para><code>Auto</code> has different behavior depending on the host project's target framework.</para>

2
src/Avalonia.Base/Collections/Pooled/IReadOnlyPooledList.cs

@ -11,7 +11,7 @@ namespace Avalonia.Collections.Pooled
/// </summary>
/// <typeparam name="T">The type of elements in the read-only pooled list.</typeparam>
public interface IReadOnlyPooledList<T> : IReadOnlyList<T>
internal interface IReadOnlyPooledList<T> : IReadOnlyList<T>
{
#pragma warning disable CS0419
/// <summary>

2
src/Avalonia.Base/Collections/Pooled/PooledList.cs

@ -29,7 +29,7 @@ namespace Avalonia.Collections.Pooled
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(ICollectionDebugView<>))]
[Serializable]
public class PooledList<T> : IList<T>, IReadOnlyPooledList<T>, IList, IDisposable, IDeserializationCallback
internal class PooledList<T> : IList<T>, IReadOnlyPooledList<T>, IList, IDisposable, IDeserializationCallback
{
// internal constant copied from Array.MaxArrayLength
private const int MaxArrayLength = 0x7FEFFFFF;

2
src/Avalonia.Base/Collections/Pooled/PooledStack.cs

@ -29,7 +29,7 @@ namespace Avalonia.Collections.Pooled
[DebuggerTypeProxy(typeof(StackDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
public class PooledStack<T> : IEnumerable<T>, ICollection, IReadOnlyCollection<T>, IDisposable, IDeserializationCallback
internal class PooledStack<T> : IEnumerable<T>, ICollection, IReadOnlyCollection<T>, IDisposable, IDeserializationCallback
{
[NonSerialized]
private ArrayPool<T> _pool;

2
src/Avalonia.Base/Controls/ChildNameScope.cs

@ -3,7 +3,7 @@ using Avalonia.Utilities;
namespace Avalonia.Controls
{
public class ChildNameScope : INameScope
internal class ChildNameScope : INameScope
{
private readonly INameScope _parentScope;
private readonly NameScope _inner = new NameScope();

4
src/Avalonia.Base/Data/BindingValue.cs

@ -237,7 +237,7 @@ namespace Avalonia.Data
/// </summary>
/// <param name="value">The untyped value.</param>
/// <returns>The typed binding value.</returns>
[RequiresUnreferencedCode(TrimmingMessages.ImplicitTypeConvertionRequiresUnreferencedCodeMessage)]
[RequiresUnreferencedCode(TrimmingMessages.ImplicitTypeConversionRequiresUnreferencedCodeMessage)]
public static BindingValue<T> FromUntyped(object? value)
{
return FromUntyped(value, typeof(T));
@ -251,7 +251,7 @@ namespace Avalonia.Data
/// <param name="value">The untyped value.</param>
/// <param name="targetType">The runtime target type.</param>
/// <returns>The typed binding value.</returns>
[RequiresUnreferencedCode(TrimmingMessages.ImplicitTypeConvertionRequiresUnreferencedCodeMessage)]
[RequiresUnreferencedCode(TrimmingMessages.ImplicitTypeConversionRequiresUnreferencedCodeMessage)]
public static BindingValue<T> FromUntyped(object? value, Type targetType)
{
if (value == AvaloniaProperty.UnsetValue)

2
src/Avalonia.Base/Data/Converters/DefaultValueConverter.cs

@ -10,7 +10,7 @@ namespace Avalonia.Data.Converters
/// Provides a default set of value conversions for bindings that do not specify a value
/// converter.
/// </summary>
[RequiresUnreferencedCode(TrimmingMessages.TypeConvertionRequiresUnreferencedCodeMessage)]
[RequiresUnreferencedCode(TrimmingMessages.TypeConversionRequiresUnreferencedCodeMessage)]
public class DefaultValueConverter : IValueConverter
{
/// <summary>

2
src/Avalonia.Base/Data/Core/BindingExpression.cs

@ -12,7 +12,7 @@ namespace Avalonia.Data.Core
/// Binds to an expression on an object using a type value converter to convert the values
/// that are sent and received.
/// </summary>
[RequiresUnreferencedCode(TrimmingMessages.TypeConvertionRequiresUnreferencedCodeMessage)]
[RequiresUnreferencedCode(TrimmingMessages.TypeConversionRequiresUnreferencedCodeMessage)]
internal class BindingExpression : LightweightObservableBase<object?>, IAvaloniaSubject<object?>, IDescription
{
private readonly ExpressionObserver _inner;

2
src/Avalonia.Base/Data/Core/CommonPropertyNames.cs

@ -1,6 +1,6 @@
namespace Avalonia.Data.Core
{
public static class CommonPropertyNames
internal static class CommonPropertyNames
{
public const string IndexerName = "Item";
}

2
src/Avalonia.Base/Data/IndexerBinding.cs

@ -2,7 +2,7 @@
namespace Avalonia.Data
{
public class IndexerBinding : IBinding
internal class IndexerBinding : IBinding
{
public IndexerBinding(
AvaloniaObject source,

2
src/Markup/Avalonia.Markup/Data/TemplateBinding.cs → src/Avalonia.Base/Data/TemplateBinding.cs

@ -109,7 +109,7 @@ namespace Avalonia.Data
}
/// <inheritdoc/>
void ISetterValue.Initialize(ISetter setter) => _isSetterValue = true;
void ISetterValue.Initialize(SetterBase setter) => _isSetterValue = true;
protected override void Subscribed()
{

18
src/Avalonia.Base/Diagnostics/AppliedStyle.cs

@ -0,0 +1,18 @@
using Avalonia.Styling;
namespace Avalonia.Diagnostics
{
public class AppliedStyle
{
private readonly IStyleInstance _instance;
internal AppliedStyle(IStyleInstance instance)
{
_instance = instance;
}
public bool HasActivator => _instance.HasActivator;
public bool IsActive => _instance.IsActive;
public StyleBase Style => (StyleBase)_instance.Source;
}
}

2
src/Avalonia.Base/Diagnostics/IAvaloniaObjectDebug.cs

@ -5,7 +5,7 @@ namespace Avalonia.Diagnostics
/// <summary>
/// Provides a debug interface into <see cref="AvaloniaObject"/>.
/// </summary>
public interface IAvaloniaObjectDebug
internal interface IAvaloniaObjectDebug
{
/// <summary>
/// Gets the subscriber list for the <see cref="AvaloniaObject.PropertyChanged"/>

2
src/Avalonia.Base/Diagnostics/INotifyCollectionChangedDebug.cs

@ -8,7 +8,7 @@ namespace Avalonia.Diagnostics
/// Provides a debug interface into <see cref="INotifyCollectionChanged"/> subscribers on
/// <see cref="AvaloniaList{T}"/>
/// </summary>
public interface INotifyCollectionChangedDebug
internal interface INotifyCollectionChangedDebug
{
/// <summary>
/// Gets the subscriber list for the <see cref="INotifyCollectionChanged.CollectionChanged"/>

4
src/Avalonia.Base/Diagnostics/StyleDiagnostics.cs

@ -11,9 +11,9 @@ namespace Avalonia.Diagnostics
/// <summary>
/// Currently applied styles.
/// </summary>
public IReadOnlyList<IStyleInstance> AppliedStyles { get; }
public IReadOnlyList<AppliedStyle> AppliedStyles { get; }
public StyleDiagnostics(IReadOnlyList<IStyleInstance> appliedStyles)
public StyleDiagnostics(IReadOnlyList<AppliedStyle> appliedStyles)
{
AppliedStyles = appliedStyles;
}

8
src/Avalonia.Base/Diagnostics/TrimmingMessages.cs

@ -2,11 +2,11 @@
internal static class TrimmingMessages
{
public const string ImplicitTypeConvertionSupressWarningMessage = "Implicit convertion methods might be removed by the linker. We don't have a reliable way to prevent it, except converting everything in compile time when possible.";
public const string ImplicitTypeConvertionRequiresUnreferencedCodeMessage = "Implicit convertion methods are required for type conversion.";
public const string ImplicitTypeConversionSupressWarningMessage = "Implicit conversion methods might be removed by the linker. We don't have a reliable way to prevent it, except converting everything in compile time when possible.";
public const string ImplicitTypeConversionRequiresUnreferencedCodeMessage = "Implicit conversion methods are required for type conversion.";
public const string TypeConvertionSupressWarningMessage = "Convertion methods might be removed by the linker. We don't have a reliable way to prevent it, except converting everything in compile time when possible.";
public const string TypeConvertionRequiresUnreferencedCodeMessage = "Convertion methods are required for type conversion, including op_Implicit, op_Explicit, Parse and TypeConverter.";
public const string TypeConversionSupressWarningMessage = "Conversion methods might be removed by the linker. We don't have a reliable way to prevent it, except converting everything in compile time when possible.";
public const string TypeConversionRequiresUnreferencedCodeMessage = "Conversion methods are required for type conversion, including op_Implicit, op_Explicit, Parse and TypeConverter.";
public const string ReflectionBindingRequiresUnreferencedCodeMessage = "BindingExpression and ReflectionBinding heavily use reflection. Consider using CompiledBindings instead.";
public const string ReflectionBindingSupressWarningMessage = "BindingExpression and ReflectionBinding internal heavily use reflection.";

2
src/Avalonia.Base/EnumExtensions.cs

@ -6,7 +6,7 @@ namespace Avalonia
/// <summary>
/// Provides extension methods for enums.
/// </summary>
public static class EnumExtensions
internal static class EnumExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]

6
src/Avalonia.Base/Input/AccessKeyHandler.cs

@ -9,7 +9,7 @@ namespace Avalonia.Input
/// <summary>
/// Handles access keys for a window.
/// </summary>
public class AccessKeyHandler : IAccessKeyHandler
internal class AccessKeyHandler : IAccessKeyHandler
{
/// <summary>
/// Defines the AccessKeyPressed attached event.
@ -141,9 +141,11 @@ namespace Avalonia.Input
if (MainMenu == null || !MainMenu.IsOpen)
{
var focusManager = FocusManager.GetFocusManager(e.Source as IInputElement);
// TODO: Use FocusScopes to store the current element and restore it when context menu is closed.
// Save currently focused input element.
_restoreFocusElement = FocusManager.Instance?.Current;
_restoreFocusElement = focusManager?.GetFocusedElement();
// When Alt is pressed without a main menu, or with a closed main menu, show
// access key markers in the window (i.e. "_File").

56
src/Avalonia.Base/Input/FocusManager.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Avalonia.Interactivity;
using Avalonia.Metadata;
using Avalonia.VisualTree;
namespace Avalonia.Input
@ -10,6 +11,7 @@ namespace Avalonia.Input
/// <summary>
/// Manages focus for the application.
/// </summary>
[PrivateApi]
public class FocusManager : IFocusManager
{
/// <summary>
@ -29,15 +31,12 @@ namespace Avalonia.Input
RoutingStrategies.Tunnel);
}
/// <summary>
/// Gets the instance of the <see cref="IFocusManager"/>.
/// </summary>
public static IFocusManager? Instance => AvaloniaLocator.Current.GetService<IFocusManager>();
private IInputElement? Current => KeyboardDevice.Instance?.FocusedElement;
/// <summary>
/// Gets the currently focused <see cref="IInputElement"/>.
/// </summary>
public IInputElement? Current => KeyboardDevice.Instance?.FocusedElement;
public IInputElement? GetFocusedElement() => Current;
/// <summary>
/// Gets the current focus scope.
@ -54,7 +53,7 @@ namespace Avalonia.Input
/// <param name="control">The control to focus.</param>
/// <param name="method">The method by which focus was changed.</param>
/// <param name="keyModifiers">Any key modifiers active at the time of focus.</param>
public void Focus(
public bool Focus(
IInputElement? control,
NavigationMethod method = NavigationMethod.Unspecified,
KeyModifiers keyModifiers = KeyModifiers.None)
@ -67,7 +66,7 @@ namespace Avalonia.Input
if (scope != null)
{
Scope = scope;
SetFocusedElement(scope, control, method, keyModifiers);
return SetFocusedElement(scope, control, method, keyModifiers);
}
}
else if (Current != null)
@ -79,28 +78,29 @@ namespace Avalonia.Input
_focusScopes.TryGetValue(scope, out var element) &&
element != null)
{
Focus(element, method);
return;
return Focus(element, method);
}
}
if (Scope is object)
{
// Couldn't find a focus scope, clear focus.
SetFocusedElement(Scope, null);
return SetFocusedElement(Scope, null);
}
}
return false;
}
public IInputElement? GetFocusedElement(IInputElement e)
public void ClearFocus()
{
if (e is IFocusScope scope)
{
_focusScopes.TryGetValue(scope, out var result);
return result;
}
Focus(null);
}
return null;
public IInputElement? GetFocusedElement(IFocusScope scope)
{
_focusScopes.TryGetValue(scope, out var result);
return result;
}
/// <summary>
@ -114,7 +114,7 @@ namespace Avalonia.Input
/// If the specified scope is the current <see cref="Scope"/> then the keyboard focus
/// will change.
/// </remarks>
public void SetFocusedElement(
public bool SetFocusedElement(
IFocusScope scope,
IInputElement? element,
NavigationMethod method = NavigationMethod.Unspecified,
@ -124,7 +124,7 @@ namespace Avalonia.Input
if (element is not null && !CanFocus(element))
{
return;
return false;
}
if (_focusScopes.TryGetValue(scope, out var existingElement))
@ -144,6 +144,8 @@ namespace Avalonia.Input
{
KeyboardDevice.Instance?.SetFocusedElement(element, method, keyModifiers);
}
return true;
}
/// <summary>
@ -185,6 +187,20 @@ namespace Avalonia.Input
public static bool GetIsFocusScope(IInputElement e) => e is IFocusScope;
/// <summary>
/// Public API customers should use TopLevel.GetTopLevel(control).FocusManager.
/// But since we have split projects, we can't access TopLevel from Avalonia.Base.
/// That's why we need this helper method instead.
/// </summary>
internal static FocusManager? GetFocusManager(IInputElement? element)
{
// Element might not be a visual, and not attached to the root.
// But IFocusManager is always expected to be a FocusManager.
return (FocusManager?)((element as Visual)?.VisualRoot as IInputRoot)?.FocusManager
// In our unit tests some elements might not have a root. Remove when we migrate to headless tests.
?? (FocusManager?)AvaloniaLocator.Current.GetService<IFocusManager>();
}
/// <summary>
/// Checks if the specified element can be focused.
/// </summary>
@ -237,7 +253,7 @@ namespace Avalonia.Input
{
if (element is IInputElement inputElement && CanFocus(inputElement))
{
Instance?.Focus(inputElement, NavigationMethod.Pointer, ev.KeyModifiers);
inputElement.Focus(NavigationMethod.Pointer, ev.KeyModifiers);
break;
}

3
src/Avalonia.Base/Input/IAccessKeyHandler.cs

@ -5,8 +5,7 @@ namespace Avalonia.Input
/// <summary>
/// Defines the interface for classes that handle access keys for a window.
/// </summary>
[Unstable]
public interface IAccessKeyHandler
internal interface IAccessKeyHandler
{
/// <summary>
/// Gets or sets the window's main menu.

36
src/Avalonia.Base/Input/IFocusManager.cs

@ -11,40 +11,12 @@ namespace Avalonia.Input
/// <summary>
/// Gets the currently focused <see cref="IInputElement"/>.
/// </summary>
IInputElement? Current { get; }
IInputElement? GetFocusedElement();
/// <summary>
/// Gets the current focus scope.
/// Clears currently focused element.
/// </summary>
IFocusScope? Scope { get; }
/// <summary>
/// Focuses a control.
/// </summary>
/// <param name="control">The control to focus.</param>
/// <param name="method">The method by which focus was changed.</param>
/// <param name="keyModifiers">Any key modifiers active at the time of focus.</param>
void Focus(
IInputElement? control,
NavigationMethod method = NavigationMethod.Unspecified,
KeyModifiers keyModifiers = KeyModifiers.None);
/// <summary>
/// Notifies the focus manager of a change in focus scope.
/// </summary>
/// <param name="scope">The new focus scope.</param>
/// <remarks>
/// This should not be called by client code. It is called by an <see cref="IFocusScope"/>
/// when it activates, e.g. when a Window is activated.
/// </remarks>
void SetFocusScope(IFocusScope scope);
/// <summary>
/// Notifies the focus manager that a focus scope has been removed.
/// </summary>
/// <param name="scope">The focus scope to be removed.</param>
/// This should not be called by client code. It is called by an <see cref="IFocusScope"/>
/// when it deactivates or closes, e.g. when a Window is closed.
void RemoveFocusScope(IFocusScope scope);
[Unstable("This API might be removed in 11.x minor updates. Please consider focusing another element instead of removing focus at all for better UX.")]
void ClearFocus();
}
}

3
src/Avalonia.Base/Input/IFocusScope.cs

@ -1,5 +1,8 @@
using Avalonia.Metadata;
namespace Avalonia.Input
{
[NotClientImplementable]
public interface IFocusScope
{
}

4
src/Avalonia.Base/Input/IInputElement.cs

@ -119,7 +119,9 @@ namespace Avalonia.Input
/// <summary>
/// Focuses the control.
/// </summary>
void Focus();
/// <param name="method">The method by which focus was changed.</param>
/// <param name="keyModifiers">Any key modifiers active at the time of focus.</param>
bool Focus(NavigationMethod method = NavigationMethod.Unspecified, KeyModifiers keyModifiers = KeyModifiers.None);
/// <summary>
/// Gets the key bindings for the element.

13
src/Avalonia.Base/Input/IInputRoot.cs

@ -8,16 +8,19 @@ namespace Avalonia.Input
[NotClientImplementable]
public interface IInputRoot : IInputElement
{
/// <summary>
/// Gets or sets the access key handler.
/// </summary>
IAccessKeyHandler AccessKeyHandler { get; }
/// <summary>
/// Gets or sets the keyboard navigation handler.
/// </summary>
IKeyboardNavigationHandler KeyboardNavigationHandler { get; }
/// <summary>
/// Gets focus manager of the root.
/// </summary>
/// <remarks>
/// Focus manager can be null only if application wasn't initialized yet.
/// </remarks>
IFocusManager? FocusManager { get; }
/// <summary>
/// Gets or sets the input element that the pointer is currently over.
/// </summary>

8
src/Avalonia.Base/Input/IKeyboardDevice.cs

@ -44,13 +44,7 @@ namespace Avalonia.Input
}
[NotClientImplementable]
public interface IKeyboardDevice : IInputDevice, INotifyPropertyChanged
public interface IKeyboardDevice : IInputDevice
{
IInputElement? FocusedElement { get; }
void SetFocusedElement(
IInputElement? element,
NavigationMethod method,
KeyModifiers modifiers);
}
}

5
src/Avalonia.Base/Input/IMainMenu.cs

@ -1,15 +1,12 @@
using System;
using Avalonia.Interactivity;
using Avalonia.Metadata;
using Avalonia.VisualTree;
namespace Avalonia.Input
{
/// <summary>
/// Defines the interface for a window's main menu.
/// </summary>
[NotClientImplementable]
public interface IMainMenu
internal interface IMainMenu
{
/// <summary>
/// Gets a value indicating whether the menu is open.

17
src/Avalonia.Base/Input/InputElement.cs

@ -458,9 +458,10 @@ namespace Avalonia.Input
SetAndRaise(IsEffectivelyEnabledProperty, ref _isEffectivelyEnabled, value);
PseudoClasses.Set(":disabled", !value);
if (!IsEffectivelyEnabled && FocusManager.Instance?.Current == this)
if (!IsEffectivelyEnabled && FocusManager.GetFocusManager(this) is {} focusManager
&& Equals(focusManager.GetFocusedElement(), this))
{
FocusManager.Instance?.Focus(null);
focusManager.ClearFocus();
}
}
}
@ -491,12 +492,10 @@ namespace Avalonia.Input
public GestureRecognizerCollection GestureRecognizers
=> _gestureRecognizers ?? (_gestureRecognizers = new GestureRecognizerCollection(this));
/// <summary>
/// Focuses the control.
/// </summary>
public void Focus()
/// <inheritdoc />
public bool Focus(NavigationMethod method = NavigationMethod.Unspecified, KeyModifiers keyModifiers = KeyModifiers.None)
{
FocusManager.Instance?.Focus(this);
return FocusManager.GetFocusManager(this)?.Focus(this, method, keyModifiers) ?? false;
}
/// <inheritdoc/>
@ -506,7 +505,7 @@ namespace Avalonia.Input
if (IsFocused)
{
FocusManager.Instance?.Focus(null);
FocusManager.GetFocusManager(this)?.ClearFocus();
}
}
@ -649,7 +648,7 @@ namespace Avalonia.Input
}
else if (change.Property == IsVisibleProperty && !change.GetNewValue<bool>() && IsFocused)
{
FocusManager.Instance?.Focus(null);
FocusManager.GetFocusManager(this)?.ClearFocus();
}
}

4
src/Avalonia.Base/Input/KeyboardDevice.cs

@ -3,9 +3,11 @@ using System.Runtime.CompilerServices;
using Avalonia.Input.Raw;
using Avalonia.Input.TextInput;
using Avalonia.Interactivity;
using Avalonia.Metadata;
namespace Avalonia.Input
{
[PrivateApi]
public class KeyboardDevice : IKeyboardDevice, INotifyPropertyChanged
{
private IInputElement? _focusedElement;
@ -13,7 +15,7 @@ namespace Avalonia.Input
public event PropertyChangedEventHandler? PropertyChanged;
public static IKeyboardDevice? Instance => AvaloniaLocator.Current.GetService<IKeyboardDevice>();
internal static KeyboardDevice? Instance => AvaloniaLocator.Current.GetService<IKeyboardDevice>() as KeyboardDevice;
public IInputManager? InputManager => AvaloniaLocator.Current.GetService<IInputManager>();

18
src/Avalonia.Base/Input/KeyboardNavigationHandler.cs

@ -1,6 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Input.Navigation;
using Avalonia.Metadata;
using Avalonia.VisualTree;
namespace Avalonia.Input
@ -8,6 +9,7 @@ namespace Avalonia.Input
/// <summary>
/// Handles keyboard navigation for a window.
/// </summary>
[Unstable]
public class KeyboardNavigationHandler : IKeyboardNavigationHandler
{
/// <summary>
@ -75,20 +77,23 @@ namespace Avalonia.Input
/// <param name="direction">The direction to move.</param>
/// <param name="keyModifiers">Any key modifiers active at the time of focus.</param>
public void Move(
IInputElement element,
IInputElement? element,
NavigationDirection direction,
KeyModifiers keyModifiers = KeyModifiers.None)
{
element = element ?? throw new ArgumentNullException(nameof(element));
if (element is null && _owner is null)
{
return;
}
var next = GetNext(element, direction);
var next = GetNext(element ?? _owner!, direction);
if (next != null)
{
var method = direction == NavigationDirection.Next ||
direction == NavigationDirection.Previous ?
NavigationMethod.Tab : NavigationMethod.Directional;
FocusManager.Instance?.Focus(next, method, keyModifiers);
next.Focus(method, keyModifiers);
}
}
@ -99,10 +104,9 @@ namespace Avalonia.Input
/// <param name="e">The event args.</param>
protected virtual void OnKeyDown(object? sender, KeyEventArgs e)
{
var current = FocusManager.Instance?.Current;
if (current != null && e.Key == Key.Tab)
if (e.Key == Key.Tab)
{
var current = FocusManager.GetFocusManager(e.Source as IInputElement)?.GetFocusedElement();
var direction = (e.KeyModifiers & KeyModifiers.Shift) == 0 ?
NavigationDirection.Next : NavigationDirection.Previous;
Move(current, direction, e.KeyModifiers);

2
src/Avalonia.Base/Input/MouseDevice.cs

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using Avalonia.Reactive;
using Avalonia.Input.Raw;
using Avalonia.Metadata;
using Avalonia.Platform;
using Avalonia.Utilities;
#pragma warning disable CS0618
@ -11,6 +12,7 @@ namespace Avalonia.Input
/// <summary>
/// Represents a mouse device.
/// </summary>
[PrivateApi]
public class MouseDevice : IMouseDevice, IDisposable
{
private int _clickCount;

6
src/Avalonia.Base/Input/Navigation/TabNavigation.cs

@ -190,9 +190,11 @@ namespace Avalonia.Input.Navigation
private static IInputElement? FocusedElement(IInputElement? e)
{
// Focus delegation is enabled only if keyboard focus is outside the container
if (e != null && !e.IsKeyboardFocusWithin)
if (e != null && !e.IsKeyboardFocusWithin && e is IFocusScope scope)
{
var focusedElement = (FocusManager.Instance as FocusManager)?.GetFocusedElement(e);
var focusManager = FocusManager.GetFocusManager(e);
var focusedElement = focusManager?.GetFocusedElement(scope);
if (focusedElement != null)
{
if (!IsFocusScope(e))

2
src/Avalonia.Base/Input/PenDevice.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Avalonia.Input.Raw;
using Avalonia.Metadata;
using Avalonia.Platform;
#pragma warning disable CS0618
@ -11,6 +12,7 @@ namespace Avalonia.Input
/// <summary>
/// Represents a pen/stylus device.
/// </summary>
[PrivateApi]
public class PenDevice : IPenDevice, IDisposable
{
private readonly Dictionary<long, Pointer> _pointers = new();

2
src/Avalonia.Base/Input/TouchDevice.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Avalonia.Input.Raw;
using Avalonia.Metadata;
using Avalonia.Platform;
#pragma warning disable CS0618
@ -14,6 +15,7 @@ namespace Avalonia.Input
/// <remarks>
/// This class is supposed to be used on per-toplevel basis, don't use a shared one
/// </remarks>
[PrivateApi]
public class TouchDevice : IPointerDevice, IDisposable
{
private readonly Dictionary<long, Pointer> _pointers = new Dictionary<long, Pointer>();

2
src/Avalonia.Base/Interactivity/Interactive.cs

@ -17,7 +17,7 @@ namespace Avalonia.Interactivity
/// <summary>
/// Gets the interactive parent of the object for bubbling and tunneling events.
/// </summary>
protected internal virtual Interactive? InteractiveParent => VisualParent as Interactive;
internal virtual Interactive? InteractiveParent => VisualParent as Interactive;
/// <summary>
/// Adds a handler for the specified routed event.

46
src/Avalonia.Base/Interactivity/RoutedPropertyChangedEventArgs.cs

@ -0,0 +1,46 @@
namespace Avalonia.Interactivity
{
/// <summary>
/// Provides both old and new property values with a routed event.
/// </summary>
/// <typeparam name="T">The type of values.</typeparam>
public class RoutedPropertyChangedEventArgs<T> : RoutedEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="RoutedPropertyChangedEventArgs{T}"/> class.
/// </summary>
/// <param name="oldValue">The old property value.</param>
/// <param name="newValue">The new property value.</param>
/// <param name="routedEvent">The routed event associated with these event args.</param>
public RoutedPropertyChangedEventArgs(T oldValue, T newValue, RoutedEvent? routedEvent)
: base(routedEvent)
{
OldValue = oldValue;
NewValue = newValue;
}
/// <summary>
/// Initializes a new instance of the <see cref="RoutedPropertyChangedEventArgs{T}"/> class.
/// </summary>
/// <param name="oldValue">The old property value.</param>
/// <param name="newValue">The new property value.</param>
/// <param name="routedEvent">The routed event associated with these event args.</param>
/// <param name="source">The source object that raised the routed event.</param>
public RoutedPropertyChangedEventArgs(T oldValue, T newValue, RoutedEvent? routedEvent, object? source)
: base(routedEvent, source)
{
OldValue = oldValue;
NewValue = newValue;
}
/// <summary>
/// Gets the old value of the property.
/// </summary>
public T OldValue { get; init; }
/// <summary>
/// Gets the new value of the property.
/// </summary>
public T NewValue { get; init; }
}
}

2
src/Avalonia.Base/Logging/TraceLogSink.cs

@ -6,7 +6,7 @@ using Avalonia.Utilities;
namespace Avalonia.Logging
{
public class TraceLogSink : ILogSink
internal class TraceLogSink : ILogSink
{
private readonly LogEventLevel _level;
private readonly IList<string>? _areas;

2
src/Avalonia.Base/Media/ArcSegment.cs

@ -95,7 +95,7 @@ namespace Avalonia.Media
set { SetValue(SweepDirectionProperty, value); }
}
protected internal override void ApplyTo(StreamGeometryContext ctx)
internal override void ApplyTo(StreamGeometryContext ctx)
{
ctx.ArcTo(Point, Size, RotationAngle, IsLargeArc, SweepDirection);
}

2
src/Avalonia.Base/Media/BezierSegment .cs

@ -56,7 +56,7 @@ namespace Avalonia.Media
set { SetValue(Point3Property, value); }
}
protected internal override void ApplyTo(StreamGeometryContext ctx)
internal override void ApplyTo(StreamGeometryContext ctx)
{
ctx.CubicBezierTo(Point1, Point2, Point3);
}

32
src/Avalonia.Base/Media/Color.cs

@ -478,7 +478,6 @@ namespace Avalonia.Media
/// <returns>The HSL equivalent color.</returns>
public HslColor ToHsl()
{
// Don't use the HslColor(Color) constructor to avoid an extra HslColor
return Color.ToHsl(R, G, B, A);
}
@ -488,7 +487,6 @@ namespace Avalonia.Media
/// <returns>The HSV equivalent color.</returns>
public HsvColor ToHsv()
{
// Don't use the HsvColor(Color) constructor to avoid an extra HsvColor
return Color.ToHsv(R, G, B, A);
}
@ -517,21 +515,6 @@ namespace Avalonia.Media
}
}
/// <summary>
/// Converts the given RGB color to its HSL color equivalent.
/// </summary>
/// <param name="color">The color in the RGB color model.</param>
/// <returns>A new <see cref="HslColor"/> equivalent to the given RGBA values.</returns>
public static HslColor ToHsl(Color color)
{
// Normalize RGBA components into the 0..1 range
return Color.ToHsl(
(byteToDouble * color.R),
(byteToDouble * color.G),
(byteToDouble * color.B),
(byteToDouble * color.A));
}
/// <summary>
/// Converts the given RGBA color component values to their HSL color equivalent.
/// </summary>
@ -606,21 +589,6 @@ namespace Avalonia.Media
return new HslColor(a, 60 * h1, saturation, lightness, clampValues: false);
}
/// <summary>
/// Converts the given RGB color to its HSV color equivalent.
/// </summary>
/// <param name="color">The color in the RGB color model.</param>
/// <returns>A new <see cref="HsvColor"/> equivalent to the given RGBA values.</returns>
public static HsvColor ToHsv(Color color)
{
// Normalize RGBA components into the 0..1 range
return Color.ToHsv(
(byteToDouble * color.R),
(byteToDouble * color.G),
(byteToDouble * color.B),
(byteToDouble * color.A));
}
/// <summary>
/// Converts the given RGBA color component values to their HSV color equivalent.
/// </summary>

78
src/Avalonia.Base/Media/HslColor.cs

@ -90,7 +90,7 @@ namespace Avalonia.Media
/// <param name="color">The RGB color to convert to HSL.</param>
public HslColor(Color color)
{
var hsl = Color.ToHsl(color);
var hsl = color.ToHsl();
A = hsl.A;
H = hsl.H;
@ -165,10 +165,18 @@ namespace Avalonia.Media
/// <returns>The RGB equivalent color.</returns>
public Color ToRgb()
{
// Use the by-component conversion method directly for performance
return HslColor.ToRgb(H, S, L, A);
}
/// <summary>
/// Returns the HSV color model equivalent of this HSL color.
/// </summary>
/// <returns>The HSV equivalent color.</returns>
public HsvColor ToHsv()
{
return HslColor.ToHsv(H, S, L, A);
}
/// <inheritdoc/>
public override string ToString()
{
@ -349,16 +357,6 @@ namespace Avalonia.Media
return new HslColor(1.0, h, s, l);
}
/// <summary>
/// Converts the given HSL color to its RGB color equivalent.
/// </summary>
/// <param name="hslColor">The color in the HSL color model.</param>
/// <returns>A new RGB <see cref="Color"/> equivalent to the given HSLA values.</returns>
public static Color ToRgb(HslColor hslColor)
{
return HslColor.ToRgb(hslColor.H, hslColor.S, hslColor.L, hslColor.A);
}
/// <summary>
/// Converts the given HSLA color component values to their RGB color equivalent.
/// </summary>
@ -442,13 +440,67 @@ namespace Avalonia.Media
b1 = x;
}
return Color.FromArgb(
return new Color(
(byte)Math.Round(255 * alpha),
(byte)Math.Round(255 * (r1 + m)),
(byte)Math.Round(255 * (g1 + m)),
(byte)Math.Round(255 * (b1 + m)));
}
/// <summary>
/// Converts the given HSLA color component values to their HSV color equivalent.
/// </summary>
/// <param name="hue">The Hue component in the HSL color model in the range from 0..360.</param>
/// <param name="saturation">The Saturation component in the HSL color model in the range from 0..1.</param>
/// <param name="lightness">The Lightness component in the HSL color model in the range from 0..1.</param>
/// <param name="alpha">The Alpha component in the range from 0..1.</param>
/// <returns>A new <see cref="HsvColor"/> equivalent to the given HSLA values.</returns>
public static HsvColor ToHsv(
double hue,
double saturation,
double lightness,
double alpha = 1.0)
{
// We want the hue to be between 0 and 359,
// so we first ensure that that's the case.
while (hue >= 360.0)
{
hue -= 360.0;
}
while (hue < 0.0)
{
hue += 360.0;
}
// We similarly clamp saturation, lightness and alpha between 0 and 1.
saturation = saturation < 0.0 ? 0.0 : saturation;
saturation = saturation > 1.0 ? 1.0 : saturation;
lightness = lightness < 0.0 ? 0.0 : lightness;
lightness = lightness > 1.0 ? 1.0 : lightness;
alpha = alpha < 0.0 ? 0.0 : alpha;
alpha = alpha > 1.0 ? 1.0 : alpha;
// The conversion algorithm is from the below link
// https://en.wikipedia.org/wiki/HSL_and_HSV#Interconversion
double s;
double v = lightness + (saturation * Math.Min(lightness, 1.0 - lightness));
if (v <= 0)
{
s = 0;
}
else
{
s = 2.0 * (1.0 - (lightness / v));
}
return new HsvColor(alpha, hue, s, v);
}
/// <summary>
/// Indicates whether the values of two specified <see cref="HslColor"/> objects are equal.
/// </summary>

78
src/Avalonia.Base/Media/HsvColor.cs

@ -90,7 +90,7 @@ namespace Avalonia.Media
/// <param name="color">The RGB color to convert to HSV.</param>
public HsvColor(Color color)
{
var hsv = Color.ToHsv(color);
var hsv = color.ToHsv();
A = hsv.A;
H = hsv.H;
@ -195,10 +195,18 @@ namespace Avalonia.Media
/// <returns>The RGB equivalent color.</returns>
public Color ToRgb()
{
// Use the by-component conversion method directly for performance
return HsvColor.ToRgb(H, S, V, A);
}
/// <summary>
/// Returns the HSL color model equivalent of this HSV color.
/// </summary>
/// <returns>The HSL equivalent color.</returns>
public HslColor ToHsl()
{
return HsvColor.ToHsl(H, S, V, A);
}
/// <inheritdoc/>
public override string ToString()
{
@ -379,16 +387,6 @@ namespace Avalonia.Media
return new HsvColor(1.0, h, s, v);
}
/// <summary>
/// Converts the given HSV color to its RGB color equivalent.
/// </summary>
/// <param name="hsvColor">The color in the HSV color model.</param>
/// <returns>A new RGB <see cref="Color"/> equivalent to the given HSVA values.</returns>
public static Color ToRgb(HsvColor hsvColor)
{
return HsvColor.ToRgb(hsvColor.H, hsvColor.S, hsvColor.V, hsvColor.A);
}
/// <summary>
/// Converts the given HSVA color component values to their RGB color equivalent.
/// </summary>
@ -520,13 +518,67 @@ namespace Avalonia.Media
break;
}
return Color.FromArgb(
return new Color(
(byte)Math.Round(alpha * 255),
(byte)Math.Round(r * 255),
(byte)Math.Round(g * 255),
(byte)Math.Round(b * 255));
}
/// <summary>
/// Converts the given HSVA color component values to their HSL color equivalent.
/// </summary>
/// <param name="hue">The Hue component in the HSV color model in the range from 0..360.</param>
/// <param name="saturation">The Saturation component in the HSV color model in the range from 0..1.</param>
/// <param name="value">The Value component in the HSV color model in the range from 0..1.</param>
/// <param name="alpha">The Alpha component in the range from 0..1.</param>
/// <returns>A new <see cref="HslColor"/> equivalent to the given HSVA values.</returns>
public static HslColor ToHsl(
double hue,
double saturation,
double value,
double alpha = 1.0)
{
// We want the hue to be between 0 and 359,
// so we first ensure that that's the case.
while (hue >= 360.0)
{
hue -= 360.0;
}
while (hue < 0.0)
{
hue += 360.0;
}
// We similarly clamp saturation, value and alpha between 0 and 1.
saturation = saturation < 0.0 ? 0.0 : saturation;
saturation = saturation > 1.0 ? 1.0 : saturation;
value = value < 0.0 ? 0.0 : value;
value = value > 1.0 ? 1.0 : value;
alpha = alpha < 0.0 ? 0.0 : alpha;
alpha = alpha > 1.0 ? 1.0 : alpha;
// The conversion algorithm is from the below link
// https://en.wikipedia.org/wiki/HSL_and_HSV#Interconversion
double s;
double l = value * (1.0 - (saturation / 2.0));
if (l <= 0 || l >= 1)
{
s = 0.0;
}
else
{
s = (value - l) / Math.Min(l, 1.0 - l);
}
return new HslColor(alpha, hue, s, l);
}
/// <summary>
/// Indicates whether the values of two specified <see cref="HsvColor"/> objects are equal.
/// </summary>

2
src/Avalonia.Base/Media/Imaging/Bitmap.cs

@ -173,7 +173,7 @@ namespace Avalonia.Media.Imaging
public virtual PixelFormat? Format => (PlatformImpl.Item as IReadableBitmapImpl)?.Format;
protected internal unsafe void CopyPixelsCore(PixelRect sourceRect, IntPtr buffer, int bufferSize, int stride,
private protected unsafe void CopyPixelsCore(PixelRect sourceRect, IntPtr buffer, int bufferSize, int stride,
ILockedFramebuffer fb)
{
if ((sourceRect.Width <= 0 || sourceRect.Height <= 0) && (sourceRect.X != 0 || sourceRect.Y != 0))

2
src/Avalonia.Base/Media/Immutable/ImmutableTileBrush.cs

@ -21,7 +21,7 @@ namespace Avalonia.Media.Immutable
/// How the source rectangle will be stretched to fill the destination rect.
/// </param>
/// <param name="tileMode">The tile mode.</param>
protected internal ImmutableTileBrush(
private protected ImmutableTileBrush(
AlignmentX alignmentX,
AlignmentY alignmentY,
RelativeRect destinationRect,

2
src/Avalonia.Base/Media/LineSegment.cs

@ -22,7 +22,7 @@ namespace Avalonia.Media
set { SetValue(PointProperty, value); }
}
protected internal override void ApplyTo(StreamGeometryContext ctx)
internal override void ApplyTo(StreamGeometryContext ctx)
{
ctx.LineTo(Point);
}

4
src/Avalonia.Base/Media/PathSegment.cs

@ -2,6 +2,6 @@ namespace Avalonia.Media
{
public abstract class PathSegment : AvaloniaObject
{
protected internal abstract void ApplyTo(StreamGeometryContext ctx);
internal abstract void ApplyTo(StreamGeometryContext ctx);
}
}
}

2
src/Avalonia.Base/Media/PolyLineSegment.cs

@ -44,7 +44,7 @@ namespace Avalonia.Media
Points = new Points(points);
}
protected internal override void ApplyTo(StreamGeometryContext ctx)
internal override void ApplyTo(StreamGeometryContext ctx)
{
var points = Points;
if (points.Count > 0)

2
src/Avalonia.Base/Media/QuadraticBezierSegment .cs

@ -40,7 +40,7 @@ namespace Avalonia.Media
set { SetValue(Point2Property, value); }
}
protected internal override void ApplyTo(StreamGeometryContext ctx)
internal override void ApplyTo(StreamGeometryContext ctx)
{
ctx.QuadraticBezierTo(Point1, Point2);
}

1
src/Avalonia.Base/Media/StreamGeometryContext.cs

@ -10,7 +10,6 @@ namespace Avalonia.Media
/// of <see cref="StreamGeometryContext"/> is obtained by calling
/// <see cref="StreamGeometry.Open"/>.
/// </remarks>
/// TODO: This class is just a wrapper around IStreamGeometryContextImpl: is it needed?
public class StreamGeometryContext : IGeometryContext
{
private readonly IStreamGeometryContextImpl _impl;

18
src/Avalonia.Base/Media/TextFormatting/TextLayout.cs

@ -60,14 +60,10 @@ namespace Avalonia.Media.TextFormatting
_textTrimming = textTrimming ?? TextTrimming.None;
LineHeight = lineHeight;
MaxWidth = maxWidth;
MaxHeight = maxHeight;
LetterSpacing = letterSpacing;
MaxLines = maxLines;
_textLines = CreateTextLines();
@ -81,8 +77,6 @@ namespace Avalonia.Media.TextFormatting
/// <param name="textTrimming">The text trimming.</param>
/// <param name="maxWidth">The maximum width.</param>
/// <param name="maxHeight">The maximum height.</param>
/// <param name="lineHeight">The height of each line of text.</param>
/// <param name="letterSpacing">The letter spacing that is applied to rendered glyphs.</param>
/// <param name="maxLines">The maximum number of text lines.</param>
public TextLayout(
ITextSource textSource,
@ -90,8 +84,6 @@ namespace Avalonia.Media.TextFormatting
TextTrimming? textTrimming = null,
double maxWidth = double.PositiveInfinity,
double maxHeight = double.PositiveInfinity,
double lineHeight = double.NaN,
double letterSpacing = 0,
int maxLines = 0)
{
_textSource = textSource;
@ -100,14 +92,10 @@ namespace Avalonia.Media.TextFormatting
_textTrimming = textTrimming ?? TextTrimming.None;
LineHeight = lineHeight;
MaxWidth = maxWidth;
MaxHeight = maxHeight;
LetterSpacing = letterSpacing;
MaxLines = maxLines;
_textLines = CreateTextLines();
@ -120,7 +108,7 @@ namespace Avalonia.Media.TextFormatting
/// A value of NaN (equivalent to an attribute value of "Auto") indicates that the line height
/// is determined automatically from the current font characteristics. The default is NaN.
/// </remarks>
public double LineHeight { get; }
public double LineHeight => _paragraphProperties.LineHeight;
/// <summary>
/// Gets the maximum width.
@ -140,7 +128,7 @@ namespace Avalonia.Media.TextFormatting
/// <summary>
/// Gets the text spacing.
/// </summary>
public double LetterSpacing { get; }
public double LetterSpacing => _paragraphProperties.LetterSpacing;
/// <summary>
/// Gets the text lines.
@ -495,7 +483,7 @@ namespace Avalonia.Media.TextFormatting
/// <param name="lineHeight">The height of each line of text.</param>
/// <param name="letterSpacing">The letter spacing that is applied to rendered glyphs.</param>
/// <returns></returns>
private static TextParagraphProperties CreateTextParagraphProperties(Typeface typeface, double fontSize,
internal static TextParagraphProperties CreateTextParagraphProperties(Typeface typeface, double fontSize,
IBrush? foreground, TextAlignment textAlignment, TextWrapping textWrapping,
TextDecorationCollection? textDecorations, FlowDirection flowDirection, double lineHeight,
double letterSpacing)

2
src/Avalonia.Base/Media/Transformation/TransformParser.cs

@ -4,7 +4,7 @@ using Avalonia.Utilities;
namespace Avalonia.Media.Transformation
{
public static class TransformParser
internal static class TransformParser
{
private static readonly (string, TransformFunction)[] s_functionMapping =
{

6
src/Avalonia.Base/Platform/Storage/NameCollisionOption.cs

@ -1,6 +0,0 @@
namespace Avalonia.Platform.Storage;
public class NameCollisionOption
{
}

1
src/Avalonia.Base/Properties/AssemblyInfo.cs

@ -6,6 +6,7 @@ using Avalonia.Metadata;
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Animation")]
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Animation.Easings")]
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls")]
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Data")]
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Data.Converters")]
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Input")]
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Input.GestureRecognizers")]

2
src/Avalonia.Base/PropertyStore/DirectUntypedBindingObserver.cs

@ -5,7 +5,7 @@ using Avalonia.Threading;
namespace Avalonia.PropertyStore
{
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConvertionSupressWarningMessage)]
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConversionSupressWarningMessage)]
internal class DirectUntypedBindingObserver<T> : IObserver<object?>,
IDisposable
{

5
src/Avalonia.Base/PropertyStore/EffectiveValue`1.cs

@ -208,7 +208,7 @@ namespace Avalonia.PropertyStore
IsOverridenCurrentValue = isOverriddenCurrentValue;
IsCoercedDefaultValue = isCoercedDefaultValue;
if (_uncommon?._coerce is { } coerce)
if (!isCoercedDefaultValue && _uncommon?._coerce is { } coerce)
v = coerce(owner.Owner, value);
if (priority <= Priority)
@ -262,7 +262,8 @@ namespace Avalonia.PropertyStore
if (_uncommon?._coerce is { } coerce)
{
v = coerce(owner.Owner, value);
bv = coerce(owner.Owner, baseValue);
if (priority != basePriority)
bv = coerce(owner.Owner, baseValue);
}
if (!EqualityComparer<T>.Default.Equals(Value, v))

2
src/Avalonia.Base/PropertyStore/LocalValueBindingObserver.cs

@ -14,7 +14,7 @@ namespace Avalonia.PropertyStore
public void Start(IObservable<object?> source) => _subscription = source.Subscribe(this);
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConvertionSupressWarningMessage)]
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConversionSupressWarningMessage)]
public void OnNext(object? value)
{
if (value == BindingOperations.DoNothing)

4
src/Avalonia.Base/PropertyStore/UntypedValueUtils.cs

@ -7,7 +7,7 @@ namespace Avalonia.PropertyStore
{
internal static class UntypedValueUtils
{
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConvertionSupressWarningMessage)]
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConversionSupressWarningMessage)]
public static BindingValue<T> ConvertAndValidate<T>(
object? value,
Type targetType,
@ -24,7 +24,7 @@ namespace Avalonia.PropertyStore
return v;
}
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConvertionSupressWarningMessage)]
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConversionSupressWarningMessage)]
public static bool TryConvertAndValidate<T>(
StyledProperty<T> property,
object? value,

2
src/Avalonia.Base/Rendering/ManagedDeferredRendererLock.cs

@ -4,7 +4,7 @@ using Avalonia.Utilities;
namespace Avalonia.Rendering
{
public class ManagedDeferredRendererLock : DisposableLock, IDeferredRendererLock
internal class ManagedDeferredRendererLock : DisposableLock, IDeferredRendererLock
{
}

50
src/Avalonia.Base/Rendering/RendererBase.cs

@ -1,50 +0,0 @@
using System;
using System.Diagnostics;
using System.Globalization;
using Avalonia.Media;
namespace Avalonia.Rendering
{
public class RendererBase
{
private readonly bool _useManualFpsCounting;
private static int s_fontSize = 18;
private readonly Stopwatch _stopwatch = Stopwatch.StartNew();
private int _framesThisSecond;
private int _fps;
private TimeSpan _lastFpsUpdate;
public RendererBase(bool useManualFpsCounting = false)
{
_useManualFpsCounting = useManualFpsCounting;
}
protected void FpsTick() => _framesThisSecond++;
protected void RenderFps(DrawingContext context, Rect clientRect, int? layerCount)
{
var now = _stopwatch.Elapsed;
var elapsed = now - _lastFpsUpdate;
if (!_useManualFpsCounting)
++_framesThisSecond;
if (elapsed.TotalSeconds > 1)
{
_fps = (int)(_framesThisSecond / elapsed.TotalSeconds);
_framesThisSecond = 0;
_lastFpsUpdate = now;
}
var text = layerCount.HasValue ? FormattableString.Invariant($"Layers: {layerCount} FPS: {_fps:000}") : FormattableString.Invariant($"FPS: {_fps:000}");
var formattedText = new FormattedText(text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, Typeface.Default, s_fontSize, Brushes.White);
var rect = new Rect(clientRect.Right - formattedText.Width, 0, formattedText.Width, formattedText.Height);
context.DrawRectangle(Brushes.Black, null, rect);
context.DrawText(formattedText, rect.TopLeft);
}
}
}

2
src/Avalonia.Base/Rendering/Utilities/TileBrushCalculator.cs

@ -2,7 +2,7 @@
namespace Avalonia.Rendering.Utilities
{
public class TileBrushCalculator
internal class TileBrushCalculator
{
private readonly Size _imageSize;
private readonly Rect _drawRect;

3
src/Avalonia.Base/Rendering/ZIndexComparer.cs

@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using Avalonia.VisualTree;
namespace Avalonia.Rendering
{
public class ZIndexComparer : IComparer<Visual>
internal class ZIndexComparer : IComparer<Visual>
{
public static readonly ZIndexComparer Instance = new ZIndexComparer();
public static readonly Comparison<Visual> ComparisonInstance = Instance.Compare;

6
src/Avalonia.Base/StyledElement.cs

@ -420,12 +420,12 @@ namespace Avalonia
internal StyleDiagnostics GetStyleDiagnosticsInternal()
{
var styles = new List<IStyleInstance>();
var styles = new List<AppliedStyle>();
foreach (var frame in GetValueStore().Frames)
{
if (frame is IStyleInstance style)
styles.Add(style);
styles.Add(new(style));
}
return new StyleDiagnostics(styles);
@ -556,7 +556,7 @@ namespace Avalonia
/// Notifies child controls that a change has been made to resources that apply to them.
/// </summary>
/// <param name="e">The event args.</param>
protected virtual void NotifyChildResourcesChanged(ResourcesChangedEventArgs e)
internal virtual void NotifyChildResourcesChanged(ResourcesChangedEventArgs e)
{
if (_logicalChildren is object)
{

2
src/Avalonia.Base/StyledProperty.cs

@ -221,7 +221,7 @@ namespace Avalonia
return target.Bind<TValue>(this, source, priority);
}
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConvertionSupressWarningMessage)]
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConversionSupressWarningMessage)]
private bool ShouldSetValue(AvaloniaObject target, object? value, [NotNullWhen(true)] out TValue? converted)
{
if (value == BindingOperations.DoNothing)

3
src/Avalonia.Base/Styling/Activators/IStyleActivator.cs

@ -15,8 +15,7 @@ namespace Avalonia.Styling.Activators
/// - The activation state can be re-evaluated at any time by calling <see cref="GetIsActive"/>
/// - No error or completion messages
/// </remarks>
[Unstable]
public interface IStyleActivator : IDisposable
internal interface IStyleActivator : IDisposable
{
/// <summary>
/// Gets a value indicating whether the style is subscribed.

3
src/Avalonia.Base/Styling/Activators/IStyleActivatorSink.cs

@ -5,8 +5,7 @@ namespace Avalonia.Styling.Activators
/// <summary>
/// Receives notifications from an <see cref="IStyleActivator"/>.
/// </summary>
[Unstable]
public interface IStyleActivatorSink
internal interface IStyleActivatorSink
{
/// <summary>
/// Called when the subscribed activator value changes.

12
src/Avalonia.Base/Styling/ChildSelector.cs

@ -19,13 +19,13 @@ namespace Avalonia.Styling
}
/// <inheritdoc/>
public override bool InTemplate => _parent.InTemplate;
internal override bool InTemplate => _parent.InTemplate;
/// <inheritdoc/>
public override bool IsCombinator => true;
internal override bool IsCombinator => true;
/// <inheritdoc/>
public override Type? TargetType => null;
internal override Type? TargetType => null;
public override string ToString(Style? owner)
{
@ -37,7 +37,7 @@ namespace Avalonia.Styling
return _selectorString;
}
protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
private protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
{
var controlParent = ((ILogical)control).LogicalParent;
@ -64,7 +64,7 @@ namespace Avalonia.Styling
}
}
protected override Selector? MovePrevious() => null;
protected override Selector? MovePreviousOrParent() => _parent;
private protected override Selector? MovePrevious() => null;
private protected override Selector? MovePreviousOrParent() => _parent;
}
}

12
src/Avalonia.Base/Styling/DescendentSelector.cs

@ -17,13 +17,13 @@ namespace Avalonia.Styling
}
/// <inheritdoc/>
public override bool IsCombinator => true;
internal override bool IsCombinator => true;
/// <inheritdoc/>
public override bool InTemplate => _parent.InTemplate;
internal override bool InTemplate => _parent.InTemplate;
/// <inheritdoc/>
public override Type? TargetType => null;
internal override Type? TargetType => null;
public override string ToString(Style? owner)
{
@ -35,7 +35,7 @@ namespace Avalonia.Styling
return _selectorString;
}
protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
private protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
{
var c = (ILogical)control;
var descendantMatches = new OrActivatorBuilder();
@ -69,7 +69,7 @@ namespace Avalonia.Styling
}
}
protected override Selector? MovePrevious() => null;
protected override Selector? MovePreviousOrParent() => _parent;
private protected override Selector? MovePrevious() => null;
private protected override Selector? MovePreviousOrParent() => _parent;
}
}

24
src/Avalonia.Base/Styling/ISetter.cs

@ -1,24 +0,0 @@
using System;
using Avalonia.Metadata;
namespace Avalonia.Styling
{
/// <summary>
/// Represents a setter for a <see cref="Style"/>.
/// </summary>
[NotClientImplementable]
public interface ISetter
{
/// <summary>
/// Instances a setter on a control.
/// </summary>
/// <param name="styleInstance">The style which contains the setter.</param>
/// <param name="target">The control.</param>
/// <returns>An <see cref="ISetterInstance"/>.</returns>
/// <remarks>
/// This method should return an <see cref="ISetterInstance"/> which can be used to apply
/// the setter to the specified control.
/// </remarks>
ISetterInstance Instance(IStyleInstance styleInstance, StyledElement target);
}
}

2
src/Avalonia.Base/Styling/ISetterInstance.cs

@ -3,7 +3,7 @@
namespace Avalonia.Styling
{
/// <summary>
/// Represents an <see cref="ISetter"/> that has been instanced on a control.
/// Represents a <see cref="Setter"/> that has been instanced on a control.
/// </summary>
[Unstable]
public interface ISetterInstance

4
src/Avalonia.Base/Styling/ISetterValue.cs

@ -3,13 +3,13 @@
namespace Avalonia.Styling
{
/// <summary>
/// Customizes the behavior of a class when added as a value to an <see cref="ISetter"/>.
/// Customizes the behavior of a class when added as a value to a <see cref="SetterBase"/>.
/// </summary>
public interface ISetterValue
{
/// <summary>
/// Notifies that the object has been added as a setter value.
/// </summary>
void Initialize(ISetter setter);
void Initialize(SetterBase setter);
}
}

3
src/Avalonia.Base/Styling/IStyleInstance.cs

@ -5,8 +5,7 @@ namespace Avalonia.Styling
/// <summary>
/// Represents a <see cref="Style"/> that has been instanced on a control.
/// </summary>
[Unstable]
public interface IStyleInstance
internal interface IStyleInstance
{
/// <summary>
/// Gets the source style.

12
src/Avalonia.Base/Styling/NestingSelector.cs

@ -7,13 +7,13 @@ namespace Avalonia.Styling
/// </summary>
internal class NestingSelector : Selector
{
public override bool InTemplate => false;
public override bool IsCombinator => false;
public override Type? TargetType => null;
internal override bool InTemplate => false;
internal override bool IsCombinator => false;
internal override Type? TargetType => null;
public override string ToString(Style? owner) => owner?.Parent?.ToString() ?? "^";
protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
private protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
{
if (parent is Style s && s.Selector is not null)
{
@ -32,7 +32,7 @@ namespace Avalonia.Styling
"Nesting selector was specified but cannot determine parent selector.");
}
protected override Selector? MovePrevious() => null;
protected override Selector? MovePreviousOrParent() => null;
private protected override Selector? MovePrevious() => null;
private protected override Selector? MovePreviousOrParent() => null;
}
}

12
src/Avalonia.Base/Styling/NotSelector.cs

@ -26,13 +26,13 @@ namespace Avalonia.Styling
}
/// <inheritdoc/>
public override bool InTemplate => _argument.InTemplate;
internal override bool InTemplate => _argument.InTemplate;
/// <inheritdoc/>
public override bool IsCombinator => false;
internal override bool IsCombinator => false;
/// <inheritdoc/>
public override Type? TargetType => _previous?.TargetType;
internal override Type? TargetType => _previous?.TargetType;
/// <inheritdoc/>
public override string ToString(Style? owner)
@ -45,7 +45,7 @@ namespace Avalonia.Styling
return _selectorString;
}
protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
private protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
{
var innerResult = _argument.Match(control, parent, subscribe);
@ -66,7 +66,7 @@ namespace Avalonia.Styling
}
}
protected override Selector? MovePrevious() => _previous;
protected override Selector? MovePreviousOrParent() => _previous;
private protected override Selector? MovePrevious() => _previous;
private protected override Selector? MovePreviousOrParent() => _previous;
}
}

14
src/Avalonia.Base/Styling/NthChildSelector.cs

@ -12,7 +12,7 @@ namespace Avalonia.Styling
/// <remarks>
/// Element indices are 1-based.
/// </remarks>
public class NthChildSelector : Selector
internal class NthChildSelector : Selector
{
private const string NthChildSelectorName = "nth-child";
private const string NthLastChildSelectorName = "nth-last-child";
@ -39,16 +39,16 @@ namespace Avalonia.Styling
}
public override bool InTemplate => _previous?.InTemplate ?? false;
internal override bool InTemplate => _previous?.InTemplate ?? false;
public override bool IsCombinator => false;
internal override bool IsCombinator => false;
public override Type? TargetType => _previous?.TargetType;
internal override Type? TargetType => _previous?.TargetType;
public int Step { get; }
public int Offset { get; }
protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
private protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
{
if (!(control is ILogical logical))
{
@ -103,8 +103,8 @@ namespace Avalonia.Styling
return match ? SelectorMatch.AlwaysThisInstance : SelectorMatch.NeverThisInstance;
}
protected override Selector? MovePrevious() => _previous;
protected override Selector? MovePreviousOrParent() => _previous;
private protected override Selector? MovePrevious() => _previous;
private protected override Selector? MovePreviousOrParent() => _previous;
public override string ToString(Style? owner)
{

2
src/Avalonia.Base/Styling/NthLastChildSelector.cs

@ -8,7 +8,7 @@ namespace Avalonia.Styling
/// <remarks>
/// Element indices are 1-based.
/// </remarks>
public class NthLastChildSelector : NthChildSelector
internal class NthLastChildSelector : NthChildSelector
{
/// <summary>
/// Creates an instance of <see cref="NthLastChildSelector"/>

12
src/Avalonia.Base/Styling/OrSelector.cs

@ -36,13 +36,13 @@ namespace Avalonia.Styling
}
/// <inheritdoc/>
public override bool InTemplate => false;
internal override bool InTemplate => false;
/// <inheritdoc/>
public override bool IsCombinator => false;
internal override bool IsCombinator => false;
/// <inheritdoc/>
public override Type? TargetType => _targetType ??= EvaluateTargetType();
internal override Type? TargetType => _targetType ??= EvaluateTargetType();
/// <inheritdoc/>
public override string ToString(Style? owner)
@ -55,7 +55,7 @@ namespace Avalonia.Styling
return _selectorString;
}
protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
private protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
{
var activators = new OrActivatorBuilder();
var neverThisInstance = false;
@ -94,8 +94,8 @@ namespace Avalonia.Styling
}
}
protected override Selector? MovePrevious() => null;
protected override Selector? MovePreviousOrParent() => null;
private protected override Selector? MovePrevious() => null;
private protected override Selector? MovePreviousOrParent() => null;
internal override void ValidateNestingSelector(bool inControlTheme)
{

16
src/Avalonia.Base/Styling/PropertyEqualsSelector.cs

@ -28,13 +28,13 @@ namespace Avalonia.Styling
}
/// <inheritdoc/>
public override bool InTemplate => _previous?.InTemplate ?? false;
internal override bool InTemplate => _previous?.InTemplate ?? false;
/// <inheritdoc/>
public override bool IsCombinator => false;
internal override bool IsCombinator => false;
/// <inheritdoc/>
public override Type? TargetType => _previous?.TargetType;
internal override Type? TargetType => _previous?.TargetType;
/// <inheritdoc/>
public override string ToString(Style? owner)
@ -73,7 +73,7 @@ namespace Avalonia.Styling
}
/// <inheritdoc/>
protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
private protected override SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe)
{
if (subscribe)
{
@ -88,11 +88,11 @@ namespace Avalonia.Styling
}
protected override Selector? MovePrevious() => _previous;
protected override Selector? MovePreviousOrParent() => _previous;
private protected override Selector? MovePrevious() => _previous;
private protected override Selector? MovePreviousOrParent() => _previous;
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.TypeConvertionSupressWarningMessage)]
[UnconditionalSuppressMessage("Trimming", "IL2067", Justification = TrimmingMessages.TypeConvertionSupressWarningMessage)]
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.TypeConversionSupressWarningMessage)]
[UnconditionalSuppressMessage("Trimming", "IL2067", Justification = TrimmingMessages.TypeConversionSupressWarningMessage)]
internal static bool Compare(Type propertyType, object? propertyValue, object? value)
{
if (propertyType == typeof(object) &&

14
src/Avalonia.Base/Styling/Selector.cs

@ -14,7 +14,7 @@ namespace Avalonia.Styling
/// Gets a value indicating whether either this selector or a previous selector has moved
/// into a template.
/// </summary>
public abstract bool InTemplate { get; }
internal abstract bool InTemplate { get; }
/// <summary>
/// Gets a value indicating whether this selector is a combinator.
@ -22,12 +22,12 @@ namespace Avalonia.Styling
/// <remarks>
/// A combinator is a selector such as Child or Descendent which links simple selectors.
/// </remarks>
public abstract bool IsCombinator { get; }
internal abstract bool IsCombinator { get; }
/// <summary>
/// Gets the target type of the selector, if available.
/// </summary>
public abstract Type? TargetType { get; }
internal abstract Type? TargetType { get; }
/// <summary>
/// Tries to match the selector with a control.
@ -41,7 +41,7 @@ namespace Avalonia.Styling
/// or simply return an immediate result.
/// </param>
/// <returns>A <see cref="SelectorMatch"/>.</returns>
public SelectorMatch Match(StyledElement control, IStyle? parent = null, bool subscribe = true)
internal SelectorMatch Match(StyledElement control, IStyle? parent = null, bool subscribe = true)
{
// First match the selector until a combinator is found. Selectors are stored from
// right-to-left, so MatchUntilCombinator reverses this order because the type selector
@ -88,17 +88,17 @@ namespace Avalonia.Styling
/// or simply return an immediate result.
/// </param>
/// <returns>A <see cref="SelectorMatch"/>.</returns>
protected abstract SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe);
private protected abstract SelectorMatch Evaluate(StyledElement control, IStyle? parent, bool subscribe);
/// <summary>
/// Moves to the previous selector.
/// </summary>
protected abstract Selector? MovePrevious();
private protected abstract Selector? MovePrevious();
/// <summary>
/// Moves to the previous selector or the parent selector.
/// </summary>
protected abstract Selector? MovePreviousOrParent();
private protected abstract Selector? MovePreviousOrParent();
internal virtual void ValidateNestingSelector(bool inControlTheme)
{

4
src/Avalonia.Base/Styling/SelectorMatch.cs

@ -8,7 +8,7 @@ namespace Avalonia.Styling
/// <summary>
/// Describes how a <see cref="SelectorMatch"/> matches a control and its type.
/// </summary>
public enum SelectorMatchResult
internal enum SelectorMatchResult
{
/// <summary>
/// The selector never matches this type.
@ -43,7 +43,7 @@ namespace Avalonia.Styling
/// A selector match describes whether and how a <see cref="Selector"/> matches a control, and
/// in addition whether the selector can ever match a control of the same type.
/// </remarks>
public readonly record struct SelectorMatch
internal readonly record struct SelectorMatch
{
/// <summary>
/// A selector match with the result of <see cref="SelectorMatchResult.NeverThisType"/>.

6
src/Avalonia.Base/Styling/Setter.cs

@ -14,7 +14,7 @@ namespace Avalonia.Styling
/// A <see cref="Setter"/> is used to set a <see cref="AvaloniaProperty"/> value on a
/// <see cref="AvaloniaObject"/> depending on a condition.
/// </remarks>
public class Setter : ISetter, IValueEntry, ISetterInstance, IAnimationSetter
public class Setter : SetterBase, IValueEntry, ISetterInstance, IAnimationSetter
{
private object? _value;
private DirectPropertySetterInstance? _direct;
@ -65,8 +65,8 @@ namespace Avalonia.Styling
void IValueEntry.Unsubscribe() { }
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConvertionSupressWarningMessage)]
ISetterInstance ISetter.Instance(IStyleInstance instance, StyledElement target)
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.ImplicitTypeConversionSupressWarningMessage)]
internal override ISetterInstance Instance(IStyleInstance instance, StyledElement target)
{
if (target is not AvaloniaObject ao)
throw new InvalidOperationException("Don't know how to instance a style on this type.");

12
src/Avalonia.Base/Styling/SetterBase.cs

@ -0,0 +1,12 @@
namespace Avalonia.Styling
{
/// <summary>
/// Represents the base class for value setters.
/// </summary>
public abstract class SetterBase
{
internal abstract ISetterInstance Instance(
IStyleInstance styleInstance,
StyledElement target);
}
}

6
src/Avalonia.Base/Styling/StyleBase.cs

@ -16,7 +16,7 @@ namespace Avalonia.Styling
private IResourceHost? _owner;
private StyleChildren? _children;
private IResourceDictionary? _resources;
private List<ISetter>? _setters;
private List<SetterBase>? _setters;
private List<IAnimation>? _animations;
private StyleInstance? _sharedInstance;
@ -60,7 +60,7 @@ namespace Avalonia.Styling
}
}
public IList<ISetter> Setters => _setters ??= new List<ISetter>();
public IList<SetterBase> Setters => _setters ??= new();
public IList<IAnimation> Animations => _animations ??= new List<IAnimation>();
bool IResourceNode.HasResources => _resources?.Count > 0;
@ -69,7 +69,7 @@ namespace Avalonia.Styling
internal bool HasChildren => _children?.Count > 0;
internal bool HasSettersOrAnimations => _setters?.Count > 0 || _animations?.Count > 0;
public void Add(ISetter setter) => Setters.Add(setter);
public void Add(SetterBase setter) => Setters.Add(setter);
public void Add(IStyle style) => Children.Add(style);
public event EventHandler? OwnerChanged;

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save