Browse Source

Merge branch 'master' into feature/transparency-hints-list

pull/11509/head
Max Katz 3 years ago
committed by GitHub
parent
commit
1218a0ae51
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      build/SharedVersion.props
  2. 38
      nukebuild/RefAssemblyGenerator.cs
  3. 4
      samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs
  4. 2
      samples/ControlCatalog/Pages/DialogsPage.xaml.cs
  5. 3
      samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs
  6. 2
      samples/GpuInterop/MainWindow.axaml.cs
  7. 2
      samples/RenderDemo/MainWindow.xaml.cs
  8. 4
      samples/RenderDemo/Pages/AnimationsPage.xaml
  9. 15
      samples/RenderDemo/Pages/AnimationsPage.xaml.cs
  10. 12
      samples/RenderDemo/Pages/CustomAnimatorPage.xaml
  11. 5
      samples/RenderDemo/Pages/CustomStringAnimator.cs
  12. 3
      samples/RenderDemo/Pages/Transform3DPage.axaml
  13. 4
      samples/RenderDemo/Pages/TransitionsPage.xaml
  14. 15
      samples/RenderDemo/Pages/TransitionsPage.xaml.cs
  15. 1
      samples/Sandbox/Sandbox.csproj
  16. 7
      src/Android/Avalonia.Android/AndroidPlatform.cs
  17. 4
      src/Android/Avalonia.Android/AvaloniaView.cs
  18. 5
      src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs
  19. 4
      src/Avalonia.Base/Animation/Animatable.cs
  20. 27
      src/Avalonia.Base/Animation/Animation.cs
  21. 9
      src/Avalonia.Base/Animation/AnimatorDrivenTransition.cs
  22. 2
      src/Avalonia.Base/Animation/AnimatorKeyFrame.cs
  23. 6
      src/Avalonia.Base/Animation/AnimatorTransitionObservable.cs
  24. 2
      src/Avalonia.Base/Animation/Animators/Animator`1.cs
  25. 2
      src/Avalonia.Base/Animation/Animators/BaseBrushAnimator.cs
  26. 2
      src/Avalonia.Base/Animation/Animators/BoolAnimator.cs
  27. 2
      src/Avalonia.Base/Animation/Animators/BoxShadowAnimator.cs
  28. 2
      src/Avalonia.Base/Animation/Animators/BoxShadowsAnimator.cs
  29. 2
      src/Avalonia.Base/Animation/Animators/ByteAnimator.cs
  30. 2
      src/Avalonia.Base/Animation/Animators/ColorAnimator.cs
  31. 2
      src/Avalonia.Base/Animation/Animators/CornerRadiusAnimator.cs
  32. 2
      src/Avalonia.Base/Animation/Animators/DecimalAnimator.cs
  33. 2
      src/Avalonia.Base/Animation/Animators/DoubleAnimator.cs
  34. 2
      src/Avalonia.Base/Animation/Animators/FloatAnimator.cs
  35. 2
      src/Avalonia.Base/Animation/Animators/GradientBrushAnimator.cs
  36. 2
      src/Avalonia.Base/Animation/Animators/Int16Animator.cs
  37. 2
      src/Avalonia.Base/Animation/Animators/Int32Animator.cs
  38. 2
      src/Avalonia.Base/Animation/Animators/Int64Animator.cs
  39. 2
      src/Avalonia.Base/Animation/Animators/PointAnimator.cs
  40. 2
      src/Avalonia.Base/Animation/Animators/RectAnimator.cs
  41. 2
      src/Avalonia.Base/Animation/Animators/RelativePointAnimator.cs
  42. 2
      src/Avalonia.Base/Animation/Animators/SizeAnimator.cs
  43. 2
      src/Avalonia.Base/Animation/Animators/SolidColorBrushAnimator.cs
  44. 2
      src/Avalonia.Base/Animation/Animators/ThicknessAnimator.cs
  45. 2
      src/Avalonia.Base/Animation/Animators/TransformAnimator.cs
  46. 2
      src/Avalonia.Base/Animation/Animators/TransformOperationsAnimator.cs
  47. 2
      src/Avalonia.Base/Animation/Animators/UInt16Animator.cs
  48. 2
      src/Avalonia.Base/Animation/Animators/UInt32Animator.cs
  49. 2
      src/Avalonia.Base/Animation/Animators/UInt64Animator.cs
  50. 2
      src/Avalonia.Base/Animation/Animators/VectorAnimator.cs
  51. 5
      src/Avalonia.Base/Animation/Clock.cs
  52. 2
      src/Avalonia.Base/Animation/ClockBase.cs
  53. 3
      src/Avalonia.Base/Animation/Easings/IEasing.cs
  54. 5
      src/Avalonia.Base/Animation/Easings/SpringEasing.cs
  55. 4
      src/Avalonia.Base/Animation/IAnimation.cs
  56. 2
      src/Avalonia.Base/Animation/IAnimationSetter.cs
  57. 3
      src/Avalonia.Base/Animation/IAnimator.cs
  58. 3
      src/Avalonia.Base/Animation/IClock.cs
  59. 30
      src/Avalonia.Base/Animation/ICustomAnimator.cs
  60. 3
      src/Avalonia.Base/Animation/IGlobalClock.cs
  61. 4
      src/Avalonia.Base/Animation/ITransition.cs
  62. 2
      src/Avalonia.Base/Animation/KeyFrame.cs
  63. 2
      src/Avalonia.Base/Animation/KeyFrames.cs
  64. 2
      src/Avalonia.Base/Animation/KeySpline.cs
  65. 26
      src/Avalonia.Base/Animation/RenderLoopClock.cs
  66. 2
      src/Avalonia.Base/Animation/Spring.cs
  67. 2
      src/Avalonia.Base/Animation/SpringTypeConverter.cs
  68. 7
      src/Avalonia.Base/Animation/Transition.cs
  69. 6
      src/Avalonia.Base/Animation/TransitionObservableBase.cs
  70. 2
      src/Avalonia.Base/Animation/Transitions.cs
  71. 6
      src/Avalonia.Base/Animation/Transitions/BoxShadowsTransition.cs
  72. 2
      src/Avalonia.Base/Animation/Transitions/BrushTransition.cs
  73. 7
      src/Avalonia.Base/Animation/Transitions/ColorTransition.cs
  74. 7
      src/Avalonia.Base/Animation/Transitions/CornerRadiusTransition.cs
  75. 5
      src/Avalonia.Base/Animation/Transitions/DoubleTransition.cs
  76. 5
      src/Avalonia.Base/Animation/Transitions/FloatTransition.cs
  77. 5
      src/Avalonia.Base/Animation/Transitions/IntegerTransition.cs
  78. 5
      src/Avalonia.Base/Animation/Transitions/PointTransition.cs
  79. 5
      src/Avalonia.Base/Animation/Transitions/RelativePointTransition.cs
  80. 5
      src/Avalonia.Base/Animation/Transitions/SizeTransition.cs
  81. 5
      src/Avalonia.Base/Animation/Transitions/ThicknessTransition.cs
  82. 2
      src/Avalonia.Base/Animation/Transitions/TransformOperationsTransition.cs
  83. 5
      src/Avalonia.Base/Animation/Transitions/VectorTransition.cs
  84. 37
      src/Avalonia.Base/Data/TemplateBinding.cs
  85. 4
      src/Avalonia.Base/Input/AccessKeyHandler.cs
  86. 2
      src/Avalonia.Base/Input/IMainMenu.cs
  87. 11
      src/Avalonia.Base/Input/PointerEventArgs.cs
  88. 2
      src/Avalonia.Base/Input/TextInput/TransformTrackingHelper.cs
  89. 46
      src/Avalonia.Base/Interactivity/RoutedPropertyChangedEventArgs.cs
  90. 2
      src/Avalonia.Base/Layout/ILayoutManager.cs
  91. 2
      src/Avalonia.Base/Layout/ILayoutRoot.cs
  92. 11
      src/Avalonia.Base/Layout/LayoutManager.cs
  93. 9
      src/Avalonia.Base/Layout/Layoutable.cs
  94. 1
      src/Avalonia.Base/Media/CharacterHit.cs
  95. 2
      src/Avalonia.Base/Media/DashStyle.cs
  96. 5
      src/Avalonia.Base/Media/Drawing.cs
  97. 2
      src/Avalonia.Base/Media/DrawingBrush.cs
  98. 2
      src/Avalonia.Base/Media/DrawingGroup.cs
  99. 2
      src/Avalonia.Base/Media/Effects/BlurEffect.cs
  100. 4
      src/Avalonia.Base/Media/Effects/DropShadowEffect.cs

2
build/SharedVersion.props

@ -4,7 +4,7 @@
<Product>Avalonia</Product>
<Version>11.0.999</Version>
<Authors>Avalonia Team</Authors>
<Copyright>Copyright 2022 &#169; The AvaloniaUI Project</Copyright>
<Copyright>Copyright 2013-$([System.DateTime]::Now.ToString(`yyyy`)) &#169; The AvaloniaUI Project</Copyright>
<PackageProjectUrl>https://avaloniaui.net</PackageProjectUrl>
<RepositoryUrl>https://github.com/AvaloniaUI/Avalonia/</RepositoryUrl>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

38
nukebuild/RefAssemblyGenerator.cs

@ -71,10 +71,10 @@ public class RefAssemblyGenerator
foreach (var nested in type.NestedTypes)
ProcessType(nested, obsoleteCtor);
var hideMethods = (type.IsInterface && type.Name.EndsWith("Impl"))
var hideMembers = (type.IsInterface && type.Name.EndsWith("Impl"))
|| HasPrivateApi(type.CustomAttributes);
var injectMethod = hideMethods
var injectMethod = hideMembers
|| type.CustomAttributes.Any(a =>
a.AttributeType.FullName == "Avalonia.Metadata.NotClientImplementableAttribute");
@ -95,21 +95,47 @@ public class RefAssemblyGenerator
foreach (var m in type.Methods)
{
if (hideMethods || HasPrivateApi(m.CustomAttributes))
if (hideMembers || HasPrivateApi(m.CustomAttributes))
{
var dflags = MethodAttributes.Public | MethodAttributes.Family | MethodAttributes.FamORAssem |
MethodAttributes.FamANDAssem | MethodAttributes.Assembly;
m.Attributes = ((m.Attributes | dflags) ^ dflags) | MethodAttributes.Assembly;
HideMethod(m);
}
MarkAsUnstable(m, obsoleteCtor, forceUnstable);
}
foreach (var p in type.Properties)
{
if (HasPrivateApi(p.CustomAttributes))
{
if (p.SetMethod != null)
HideMethod(p.SetMethod);
if (p.GetMethod != null)
HideMethod(p.GetMethod);
}
}
foreach (var f in type.Fields)
{
if (hideMembers || HasPrivateApi(f.CustomAttributes))
{
var dflags = FieldAttributes.Public | FieldAttributes.Family | FieldAttributes.FamORAssem |
FieldAttributes.FamANDAssem | FieldAttributes.Assembly;
f.Attributes = ((f.Attributes | dflags) ^ dflags) | FieldAttributes.Assembly;
}
}
foreach (var m in type.Properties)
MarkAsUnstable(m, obsoleteCtor, forceUnstable);
foreach (var m in type.Events)
MarkAsUnstable(m, obsoleteCtor, forceUnstable);
}
static void HideMethod(MethodDefinition m)
{
var dflags = MethodAttributes.Public | MethodAttributes.Family | MethodAttributes.FamORAssem |
MethodAttributes.FamANDAssem | MethodAttributes.Assembly;
m.Attributes = ((m.Attributes | dflags) ^ dflags) | MethodAttributes.Assembly;
}
static void MarkAsUnstable(IMemberDefinition def, MethodReference obsoleteCtor, ICustomAttribute unstableAttribute)
{
if (def.CustomAttributes.Any(a => a.AttributeType.FullName == "System.ObsoleteAttribute"))

4
samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs

@ -19,8 +19,8 @@ namespace ControlCatalog.Pages
customContextRequestedBorder.AddHandler(ContextRequestedEvent, CustomContextRequested, RoutingStrategies.Tunnel);
var cancellableContextBorder = this.Get<Border>("CancellableContextBorder");
cancellableContextBorder.ContextMenu!.ContextMenuClosing += ContextFlyoutPage_Closing;
cancellableContextBorder.ContextMenu!.ContextMenuOpening += ContextFlyoutPage_Opening;
cancellableContextBorder.ContextMenu!.Closing += ContextFlyoutPage_Closing;
cancellableContextBorder.ContextMenu!.Opening += ContextFlyoutPage_Opening;
}
private ContextPageViewModel? _model;

2
samples/ControlCatalog/Pages/DialogsPage.xaml.cs

@ -307,7 +307,7 @@ namespace ControlCatalog.Pages
Content:
";
resultText += await ReadTextFromFile(file, 10000);
resultText += await ReadTextFromFile(file, 500);
}
openedFileContent.Text = resultText;

3
samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml.cs

@ -117,9 +117,8 @@ namespace ControlCatalog.Pages
private void ScrollTo(int index)
{
System.Diagnostics.Debug.WriteLine("Scroll to " + index);
var layoutManager = ((TopLevel)VisualRoot!).LayoutManager;
var element = _repeater.GetOrCreateElement(index);
layoutManager.ExecuteLayoutPass();
((TopLevel)VisualRoot!).UpdateLayout();
element.BringIntoView();
}

2
samples/GpuInterop/MainWindow.axaml.cs

@ -11,7 +11,7 @@ namespace GpuInterop
{
InitializeComponent();
this.AttachDevTools();
Renderer.Diagnostics.DebugOverlays = RendererDebugOverlays.Fps;
RendererDiagnostics.DebugOverlays = RendererDebugOverlays.Fps;
}
private void InitializeComponent()

2
samples/RenderDemo/MainWindow.xaml.cs

@ -21,7 +21,7 @@ namespace RenderDemo
void BindOverlay(Expression<Func<MainWindowViewModel, bool>> expr, RendererDebugOverlays overlay)
=> vm.WhenAnyValue(expr).Subscribe(x =>
{
var diagnostics = Renderer.Diagnostics;
var diagnostics = RendererDiagnostics;
diagnostics.DebugOverlays = x ?
diagnostics.DebugOverlays | overlay :
diagnostics.DebugOverlays & ~overlay;

4
samples/RenderDemo/Pages/AnimationsPage.xaml

@ -347,12 +347,8 @@
</UserControl.Styles>
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" ClipToBounds="False">
<StackPanel.Clock>
<Clock />
</StackPanel.Clock>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="20">
<TextBlock VerticalAlignment="Center">Hover to activate Keyframe Animations.</TextBlock>
<Button Content="{Binding PlayStateText}" Command="{Binding TogglePlayState}" Click="ToggleClock" />
</StackPanel>
<WrapPanel ClipToBounds="False">
<Border Classes="Test Rect1" Background="DarkRed"/>

15
samples/RenderDemo/Pages/AnimationsPage.xaml.cs

@ -24,20 +24,5 @@ namespace RenderDemo.Pages
{
AvaloniaXamlLoader.Load(this);
}
private void ToggleClock(object sender, RoutedEventArgs args)
{
var button = sender as Button;
var clock = button.Clock;
if (clock.PlayState == PlayState.Run)
{
clock.PlayState = PlayState.Pause;
}
else if (clock.PlayState == PlayState.Pause)
{
clock.PlayState = PlayState.Run;
}
}
}
}

12
samples/RenderDemo/Pages/CustomAnimatorPage.xaml

@ -11,10 +11,18 @@
<Style.Animations>
<Animation Duration="0:0:1" IterationCount="Infinite">
<KeyFrame Cue="0%">
<Setter Property="Text" Value="" Animation.Animator="{x:Type pages:CustomStringAnimator}"/>
<Setter Property="Text" Value="">
<Animation.Animator>
<pages:CustomStringAnimator/>
</Animation.Animator>
</Setter>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Text" Value="0123456789" Animation.Animator="{x:Type pages:CustomStringAnimator}"/>
<Setter Property="Text" Value="0123456789" >
<Animation.Animator>
<pages:CustomStringAnimator/>
</Animation.Animator>
</Setter>
</KeyFrame>
</Animation>
</Style.Animations>

5
samples/RenderDemo/Pages/CustomStringAnimator.cs

@ -1,8 +1,9 @@
using Avalonia.Animation.Animators;
using Avalonia.Animation;
using Avalonia.Animation.Animators;
namespace RenderDemo.Pages
{
public class CustomStringAnimator : Animator<string>
public class CustomStringAnimator : CustomAnimatorBase<string>
{
public override string Interpolate(double progress, string oldValue, string newValue)
{

3
samples/RenderDemo/Pages/Transform3DPage.axaml

@ -134,9 +134,6 @@
</UserControl.Styles>
<Grid ColumnDefinitions="Auto,*,Auto,*" RowDefinitions="*, Auto, Auto, Auto, Auto, Auto, Auto, Auto">
<Grid.Clock>
<Clock />
</Grid.Clock>
<Border Name="B1" Background="DarkRed" Classes="Test">
<Border.RenderTransform>
<Rotate3DTransform CenterZ="-100"

4
samples/RenderDemo/Pages/TransitionsPage.xaml

@ -248,12 +248,8 @@
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" ClipToBounds="False">
<StackPanel.Clock>
<Clock />
</StackPanel.Clock>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="20">
<TextBlock VerticalAlignment="Center">Hover to activate Transitions.</TextBlock>
<Button Content="{Binding PlayStateText}" Command="{Binding TogglePlayState}" Click="ToggleClock" />
</StackPanel>
<WrapPanel ClipToBounds="False">
<Border Classes="Test Rect1" Background="DarkRed"/>

15
samples/RenderDemo/Pages/TransitionsPage.xaml.cs

@ -18,20 +18,5 @@ namespace RenderDemo.Pages
{
AvaloniaXamlLoader.Load(this);
}
private void ToggleClock(object sender, RoutedEventArgs args)
{
var button = sender as Button;
var clock = button.Clock;
if (clock.PlayState == PlayState.Run)
{
clock.PlayState = PlayState.Pause;
}
else if (clock.PlayState == PlayState.Pause)
{
clock.PlayState = PlayState.Run;
}
}
}
}

1
samples/Sandbox/Sandbox.csproj

@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
<!-- <AvaloniaXamlIlDebuggerLaunch>true</AvaloniaXamlIlDebuggerLaunch>-->
</PropertyGroup>
<ItemGroup>

7
src/Android/Avalonia.Android/AndroidPlatform.cs

@ -45,7 +45,6 @@ namespace Avalonia.Android
.Bind<IPlatformThreadingInterface>().ToConstant(new AndroidThreadingInterface())
.Bind<IPlatformIconLoader>().ToSingleton<PlatformIconLoaderStub>()
.Bind<IRenderTimer>().ToConstant(new ChoreographerTimer())
.Bind<IRenderLoop>().ToConstant(new RenderLoop())
.Bind<PlatformHotkeyConfiguration>().ToSingleton<PlatformHotkeyConfiguration>();
if (Options.UseGpu)
@ -53,11 +52,7 @@ namespace Avalonia.Android
EglPlatformGraphics.TryInitialize();
}
Compositor = new Compositor(
AvaloniaLocator.Current.GetRequiredService<IRenderLoop>(),
AvaloniaLocator.Current.GetService<IPlatformGraphics>());
Compositor = new Compositor(AvaloniaLocator.Current.GetService<IPlatformGraphics>());
}
}

4
src/Android/Avalonia.Android/AvaloniaView.cs

@ -67,7 +67,7 @@ namespace Avalonia.Android
_timerSubscription = timer.SubscribeView(this);
}
_root.Renderer.Start();
_root.StartRendering();
if (_view.TryGetFeature<IInsetsManager>(out var insetsManager) == true)
{
@ -76,7 +76,7 @@ namespace Avalonia.Android
}
else
{
_root.Renderer.Stop();
_root.StopRendering();
_timerSubscription?.Dispose();
}
}

5
src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs

@ -106,9 +106,8 @@ namespace Avalonia.Android.Platform.SkiaPlatform
public IEnumerable<object> Surfaces => new object[] { _gl, _framebuffer, Handle };
public IRenderer CreateRenderer(IRenderRoot root) =>
new CompositingRenderer(root, AndroidPlatform.Compositor, () => Surfaces);
public Compositor Compositor => AndroidPlatform.Compositor;
public virtual void Hide()
{
_view.Visibility = ViewStates.Invisible;

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

@ -17,7 +17,7 @@ namespace Avalonia.Animation
/// <summary>
/// Defines the <see cref="Clock"/> property.
/// </summary>
public static readonly StyledProperty<IClock> ClockProperty =
internal static readonly StyledProperty<IClock> ClockProperty =
AvaloniaProperty.Register<Animatable, IClock>(nameof(Clock), inherits: true);
/// <summary>
@ -36,7 +36,7 @@ namespace Avalonia.Animation
/// <summary>
/// Gets or sets the clock which controls the animations on the control.
/// </summary>
public IClock Clock
internal IClock Clock
{
get => GetValue(ClockProperty);
set => SetValue(ClockProperty, value);

27
src/Avalonia.Base/Animation/Animation.cs

@ -16,7 +16,7 @@ namespace Avalonia.Animation
/// <summary>
/// Tracks the progress of an animation.
/// </summary>
public class Animation : AvaloniaObject, IAnimation
public sealed class Animation : AvaloniaObject, IAnimation
{
/// <summary>
/// Defines the <see cref="Duration"/> property.
@ -186,7 +186,7 @@ namespace Avalonia.Animation
/// </summary>
/// <param name="setter">The animation setter.</param>
/// <returns>The property animator type.</returns>
public static (Type Type, Func<IAnimator> Factory)? GetAnimator(IAnimationSetter setter)
internal static (Type Type, Func<IAnimator> Factory)? GetAnimator(IAnimationSetter setter)
{
if (s_animators.TryGetValue(setter, out var type))
{
@ -200,11 +200,9 @@ namespace Avalonia.Animation
/// </summary>
/// <param name="setter">The animation setter.</param>
/// <param name="value">The property animator value.</param>
public static void SetAnimator(IAnimationSetter setter,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.PublicMethods)]
Type value)
public static void SetAnimator(IAnimationSetter setter, CustomAnimatorBase value)
{
s_animators[setter] = (value, () => (IAnimator)Activator.CreateInstance(value)!);
s_animators[setter] = (value.WrapperType, value.CreateWrapper);
}
private readonly static List<(Func<AvaloniaProperty, bool> Condition, Type Animator, Func<IAnimator> Factory)> Animators = new()
@ -233,7 +231,7 @@ namespace Avalonia.Animation
/// <typeparam name="TAnimator">
/// The type of the animator to instantiate.
/// </typeparam>
public static void RegisterAnimator<TAnimator>(Func<AvaloniaProperty, bool> condition)
internal static void RegisterAnimator<TAnimator>(Func<AvaloniaProperty, bool> condition)
where TAnimator : IAnimator, new()
{
Animators.Insert(0, (condition, typeof(TAnimator), () => new TAnimator()));
@ -312,8 +310,11 @@ namespace Avalonia.Animation
return (newAnimatorInstances, subscriptions);
}
IDisposable IAnimation.Apply(Animatable control, IClock? clock, IObservable<bool> match, Action? onComplete)
=> Apply(control, clock, match, onComplete);
/// <inheritdoc/>
public IDisposable Apply(Animatable control, IClock? clock, IObservable<bool> match, Action? onComplete)
internal IDisposable Apply(Animatable control, IClock? clock, IObservable<bool> match, Action? onComplete)
{
var (animators, subscriptions) = InterpretKeyframes(control);
if (animators.Count == 1)
@ -358,14 +359,20 @@ namespace Avalonia.Animation
return new CompositeDisposable(subscriptions);
}
public Task RunAsync(Animatable control, CancellationToken cancellationToken = default) =>
RunAsync(control, null, cancellationToken);
/// <inheritdoc/>
public Task RunAsync(Animatable control, IClock? clock = null)
internal Task RunAsync(Animatable control, IClock? clock)
{
return RunAsync(control, clock, default);
}
Task IAnimation.RunAsync(Animatable control, IClock? clock, CancellationToken cancellationToken)
=> RunAsync(control, clock, cancellationToken);
/// <inheritdoc/>
public Task RunAsync(Animatable control, IClock? clock = null, CancellationToken cancellationToken = default)
internal Task RunAsync(Animatable control, IClock? clock, CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested)
{

9
src/Avalonia.Base/Animation/AnimatorDrivenTransition.cs

@ -1,5 +1,6 @@
using System;
using Avalonia.Animation.Animators;
using Avalonia.Animation.Easings;
namespace Avalonia.Animation
{
@ -8,13 +9,11 @@ namespace Avalonia.Animation
/// </summary>
/// <typeparam name="T">Type of the transitioned value.</typeparam>
/// <typeparam name="TAnimator">Type of the animator.</typeparam>
public abstract class AnimatorDrivenTransition<T, TAnimator> : Transition<T> where TAnimator : Animator<T>, new()
internal static class AnimatorDrivenTransition<T, TAnimator> where TAnimator : Animator<T>, new()
{
private static readonly TAnimator s_animator = new TAnimator();
public override IObservable<T> DoTransition(IObservable<double> progress, T oldValue, T newValue)
{
return new AnimatorTransitionObservable<T, TAnimator>(s_animator, progress, Easing, oldValue, newValue);
}
public static IObservable<T> Transition(IEasing easing, IObservable<double> progress, T oldValue, T newValue) =>
new AnimatorTransitionObservable<T, TAnimator>(s_animator, progress, easing, oldValue, newValue);
}
}

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

@ -11,7 +11,7 @@ namespace Avalonia.Animation
/// Defines a KeyFrame that is used for
/// <see cref="Animator{T}"/> objects.
/// </summary>
public class AnimatorKeyFrame : AvaloniaObject
internal class AnimatorKeyFrame : AvaloniaObject
{
public static readonly DirectProperty<AnimatorKeyFrame, object?> ValueProperty =
AvaloniaProperty.RegisterDirect<AnimatorKeyFrame, object?>(nameof(Value), k => k.Value, (k, v) => k.Value = v);

6
src/Avalonia.Base/Animation/AnimatorTransitionObservable.cs

@ -9,17 +9,15 @@ namespace Avalonia.Animation
/// </summary>
/// <typeparam name="T">Type of the transitioned value.</typeparam>
/// <typeparam name="TAnimator">Type of the animator.</typeparam>
public class AnimatorTransitionObservable<T, TAnimator> : TransitionObservableBase<T> where TAnimator : Animator<T>
internal class AnimatorTransitionObservable<T, TAnimator> : TransitionObservableBase<T> where TAnimator : Animator<T>
{
private readonly TAnimator _animator;
private readonly Easing _easing;
private readonly T _oldValue;
private readonly T _newValue;
public AnimatorTransitionObservable(TAnimator animator, IObservable<double> progress, Easing easing, T oldValue, T newValue) : base(progress, easing)
public AnimatorTransitionObservable(TAnimator animator, IObservable<double> progress, IEasing easing, T oldValue, T newValue) : base(progress, easing)
{
_animator = animator;
_easing = easing;
_oldValue = oldValue;
_newValue = newValue;
}

2
src/Avalonia.Base/Animation/Animators/Animator`1.cs

@ -11,7 +11,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Base class for <see cref="Animator{T}"/> objects
/// </summary>
public abstract class Animator<T> : AvaloniaList<AnimatorKeyFrame>, IAnimator
internal abstract class Animator<T> : AvaloniaList<AnimatorKeyFrame>, IAnimator
{
/// <summary>
/// List of type-converted keyframes.

2
src/Avalonia.Base/Animation/Animators/BaseBrushAnimator.cs

@ -15,7 +15,7 @@ namespace Avalonia.Animation.Animators
/// redirect them to the properly registered
/// animators in this class.
/// </summary>
public class BaseBrushAnimator : Animator<IBrush?>
internal class BaseBrushAnimator : Animator<IBrush?>
{
private static readonly List<(Func<Type, bool> Match, Type AnimatorType, Func<IAnimator> AnimatorFactory)> _brushAnimators = new();

2
src/Avalonia.Base/Animation/Animators/BoolAnimator.cs

@ -3,7 +3,7 @@
/// <summary>
/// Animator that handles <see cref="bool"/> properties.
/// </summary>
public class BoolAnimator : Animator<bool>
internal class BoolAnimator : Animator<bool>
{
/// <inheritdocs/>
public override bool Interpolate(double progress, bool oldValue, bool newValue)

2
src/Avalonia.Base/Animation/Animators/BoxShadowAnimator.cs

@ -2,7 +2,7 @@ using Avalonia.Media;
namespace Avalonia.Animation.Animators
{
public class BoxShadowAnimator : Animator<BoxShadow>
internal class BoxShadowAnimator : Animator<BoxShadow>
{
static ColorAnimator s_colorAnimator = new ColorAnimator();
static DoubleAnimator s_doubleAnimator = new DoubleAnimator();

2
src/Avalonia.Base/Animation/Animators/BoxShadowsAnimator.cs

@ -2,7 +2,7 @@ using Avalonia.Media;
namespace Avalonia.Animation.Animators
{
public class BoxShadowsAnimator : Animator<BoxShadows>
internal class BoxShadowsAnimator : Animator<BoxShadows>
{
private static readonly BoxShadowAnimator s_boxShadowAnimator = new BoxShadowAnimator();
public override BoxShadows Interpolate(double progress, BoxShadows oldValue, BoxShadows newValue)

2
src/Avalonia.Base/Animation/Animators/ByteAnimator.cs

@ -5,7 +5,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="byte"/> properties.
/// </summary>
public class ByteAnimator : Animator<byte>
internal class ByteAnimator : Animator<byte>
{
const double maxVal = (double)byte.MaxValue;

2
src/Avalonia.Base/Animation/Animators/ColorAnimator.cs

@ -12,7 +12,7 @@ namespace Avalonia.Animation.Animators
/// Animator that interpolates <see cref="Color"/> through
/// gamma sRGB color space for better visual result.
/// </summary>
public class ColorAnimator : Animator<Color>
internal class ColorAnimator : Animator<Color>
{
/// <summary>
/// Opto-electronic conversion function for the sRGB color space.

2
src/Avalonia.Base/Animation/Animators/CornerRadiusAnimator.cs

@ -7,7 +7,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="CornerRadius"/> properties.
/// </summary>
public class CornerRadiusAnimator : Animator<CornerRadius>
internal class CornerRadiusAnimator : Animator<CornerRadius>
{
public override CornerRadius Interpolate(double progress, CornerRadius oldValue, CornerRadius newValue)
{

2
src/Avalonia.Base/Animation/Animators/DecimalAnimator.cs

@ -3,7 +3,7 @@
/// <summary>
/// Animator that handles <see cref="decimal"/> properties.
/// </summary>
public class DecimalAnimator : Animator<decimal>
internal class DecimalAnimator : Animator<decimal>
{
/// <inheritdocs/>
public override decimal Interpolate(double progress, decimal oldValue, decimal newValue)

2
src/Avalonia.Base/Animation/Animators/DoubleAnimator.cs

@ -3,7 +3,7 @@
/// <summary>
/// Animator that handles <see cref="double"/> properties.
/// </summary>
public class DoubleAnimator : Animator<double>
internal class DoubleAnimator : Animator<double>
{
/// <inheritdocs/>
public override double Interpolate(double progress, double oldValue, double newValue)

2
src/Avalonia.Base/Animation/Animators/FloatAnimator.cs

@ -3,7 +3,7 @@
/// <summary>
/// Animator that handles <see cref="float"/> properties.
/// </summary>
public class FloatAnimator : Animator<float>
internal class FloatAnimator : Animator<float>
{
/// <inheritdocs/>
public override float Interpolate(double progress, float oldValue, float newValue)

2
src/Avalonia.Base/Animation/Animators/GradientBrushAnimator.cs

@ -13,7 +13,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="SolidColorBrush"/> values.
/// </summary>
public class GradientBrushAnimator : Animator<IGradientBrush?>
internal class GradientBrushAnimator : Animator<IGradientBrush?>
{
private static readonly RelativePointAnimator s_relativePointAnimator = new RelativePointAnimator();
private static readonly DoubleAnimator s_doubleAnimator = new DoubleAnimator();

2
src/Avalonia.Base/Animation/Animators/Int16Animator.cs

@ -5,7 +5,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="Int16"/> properties.
/// </summary>
public class Int16Animator : Animator<Int16>
internal class Int16Animator : Animator<Int16>
{
const double maxVal = (double)Int16.MaxValue;

2
src/Avalonia.Base/Animation/Animators/Int32Animator.cs

@ -5,7 +5,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="Int32"/> properties.
/// </summary>
public class Int32Animator : Animator<Int32>
internal class Int32Animator : Animator<Int32>
{
const double maxVal = (double)Int32.MaxValue;

2
src/Avalonia.Base/Animation/Animators/Int64Animator.cs

@ -5,7 +5,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="Int64"/> properties.
/// </summary>
public class Int64Animator : Animator<Int64>
internal class Int64Animator : Animator<Int64>
{
const double maxVal = (double)Int64.MaxValue;

2
src/Avalonia.Base/Animation/Animators/PointAnimator.cs

@ -7,7 +7,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="Point"/> properties.
/// </summary>
public class PointAnimator : Animator<Point>
internal class PointAnimator : Animator<Point>
{
public override Point Interpolate(double progress, Point oldValue, Point newValue)
{

2
src/Avalonia.Base/Animation/Animators/RectAnimator.cs

@ -7,7 +7,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="Rect"/> properties.
/// </summary>
public class RectAnimator : Animator<Rect>
internal class RectAnimator : Animator<Rect>
{
public override Rect Interpolate(double progress, Rect oldValue, Rect newValue)
{

2
src/Avalonia.Base/Animation/Animators/RelativePointAnimator.cs

@ -3,7 +3,7 @@
/// <summary>
/// Animator that handles <see cref="RelativePoint"/> properties.
/// </summary>
public class RelativePointAnimator : Animator<RelativePoint>
internal class RelativePointAnimator : Animator<RelativePoint>
{
private static readonly PointAnimator s_pointAnimator = new PointAnimator();

2
src/Avalonia.Base/Animation/Animators/SizeAnimator.cs

@ -7,7 +7,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="Size"/> properties.
/// </summary>
public class SizeAnimator : Animator<Size>
internal class SizeAnimator : Animator<Size>
{
public override Size Interpolate(double progress, Size oldValue, Size newValue)
{

2
src/Avalonia.Base/Animation/Animators/SolidColorBrushAnimator.cs

@ -10,7 +10,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="SolidColorBrush"/> values.
/// </summary>
public class ISolidColorBrushAnimator : Animator<ISolidColorBrush?>
internal class ISolidColorBrushAnimator : Animator<ISolidColorBrush?>
{
private static readonly DoubleAnimator s_doubleAnimator = new DoubleAnimator();

2
src/Avalonia.Base/Animation/Animators/ThicknessAnimator.cs

@ -7,7 +7,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="Thickness"/> properties.
/// </summary>
public class ThicknessAnimator : Animator<Thickness>
internal class ThicknessAnimator : Animator<Thickness>
{
public override Thickness Interpolate(double progress, Thickness oldValue, Thickness newValue)
{

2
src/Avalonia.Base/Animation/Animators/TransformAnimator.cs

@ -9,7 +9,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="Transform"/> properties.
/// </summary>
public class TransformAnimator : Animator<double>
internal class TransformAnimator : Animator<double>
{
DoubleAnimator? _doubleAnimator;

2
src/Avalonia.Base/Animation/Animators/TransformOperationsAnimator.cs

@ -4,7 +4,7 @@ using Avalonia.Media.Transformation;
namespace Avalonia.Animation.Animators
{
public class TransformOperationsAnimator : Animator<TransformOperations>
internal class TransformOperationsAnimator : Animator<TransformOperations>
{
public TransformOperationsAnimator()
{

2
src/Avalonia.Base/Animation/Animators/UInt16Animator.cs

@ -5,7 +5,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="UInt16"/> properties.
/// </summary>
public class UInt16Animator : Animator<UInt16>
internal class UInt16Animator : Animator<UInt16>
{
const double maxVal = (double)UInt16.MaxValue;

2
src/Avalonia.Base/Animation/Animators/UInt32Animator.cs

@ -5,7 +5,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="UInt32"/> properties.
/// </summary>
public class UInt32Animator : Animator<UInt32>
internal class UInt32Animator : Animator<UInt32>
{
const double maxVal = (double)UInt32.MaxValue;

2
src/Avalonia.Base/Animation/Animators/UInt64Animator.cs

@ -5,7 +5,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="UInt64"/> properties.
/// </summary>
public class UInt64Animator : Animator<UInt64>
internal class UInt64Animator : Animator<UInt64>
{
const double maxVal = (double)UInt64.MaxValue;

2
src/Avalonia.Base/Animation/Animators/VectorAnimator.cs

@ -7,7 +7,7 @@ namespace Avalonia.Animation.Animators
/// <summary>
/// Animator that handles <see cref="Vector"/> properties.
/// </summary>
public class VectorAnimator : Animator<Vector>
internal class VectorAnimator : Animator<Vector>
{
public override Vector Interpolate(double progress, Vector oldValue, Vector newValue)
{

5
src/Avalonia.Base/Animation/Clock.cs

@ -3,7 +3,10 @@ using Avalonia.Reactive;
namespace Avalonia.Animation
{
public class Clock : ClockBase
// Note: this class was always broken: it subscribes to the global clock immediately even it if
// doesn't actually have subscriptions
internal class Clock : ClockBase
{
public static IClock GlobalClock => AvaloniaLocator.Current.GetRequiredService<IGlobalClock>();

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

@ -3,7 +3,7 @@ using Avalonia.Reactive;
namespace Avalonia.Animation
{
public class ClockBase : IClock
internal class ClockBase : IClock
{
private readonly ClockObservable _observable;

3
src/Avalonia.Base/Animation/Easings/IEasing.cs

@ -1,8 +1,11 @@
using Avalonia.Metadata;
namespace Avalonia.Animation.Easings
{
/// <summary>
/// Defines the interface for easing classes.
/// </summary>
[NotClientImplementable]
public interface IEasing
{
/// <summary>

5
src/Avalonia.Base/Animation/Easings/SpringEasing.cs

@ -64,11 +64,6 @@ public class SpringEasing : Easing
Damping = damping;
InitialVelocity = initialVelocity;
}
public SpringEasing(Spring keySpline)
{
_internalSpring = keySpline;
}
public SpringEasing()
{

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

@ -14,11 +14,11 @@ namespace Avalonia.Animation
/// <summary>
/// Apply the animation to the specified control and run it when <paramref name="match" /> produces <c>true</c>.
/// </summary>
IDisposable Apply(Animatable control, IClock? clock, IObservable<bool> match, Action? onComplete = null);
internal IDisposable Apply(Animatable control, IClock? clock, IObservable<bool> match, Action? onComplete = null);
/// <summary>
/// Run the animation on the specified control.
/// </summary>
Task RunAsync(Animatable control, IClock clock, CancellationToken cancellationToken = default);
internal Task RunAsync(Animatable control, IClock clock, CancellationToken cancellationToken = default);
}
}

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

@ -2,7 +2,7 @@ using Avalonia.Metadata;
namespace Avalonia.Animation
{
[NotClientImplementable]
[NotClientImplementable, PrivateApi]
public interface IAnimationSetter
{
AvaloniaProperty? Property { get; set; }

3
src/Avalonia.Base/Animation/IAnimator.cs

@ -7,8 +7,7 @@ namespace Avalonia.Animation
/// <summary>
/// Interface for Animator objects
/// </summary>
[NotClientImplementable]
public interface IAnimator : IList<AnimatorKeyFrame>
internal interface IAnimator : IList<AnimatorKeyFrame>
{
/// <summary>
/// The target property.

3
src/Avalonia.Base/Animation/IClock.cs

@ -3,8 +3,7 @@ using Avalonia.Metadata;
namespace Avalonia.Animation
{
[NotClientImplementable]
public interface IClock : IObservable<TimeSpan>
internal interface IClock : IObservable<TimeSpan>
{
PlayState PlayState { get; set; }
}

30
src/Avalonia.Base/Animation/ICustomAnimator.cs

@ -0,0 +1,30 @@
using System;
using Avalonia.Animation.Animators;
namespace Avalonia.Animation;
public abstract class CustomAnimatorBase
{
internal abstract IAnimator CreateWrapper();
internal abstract Type WrapperType { get; }
}
public abstract class CustomAnimatorBase<T> : CustomAnimatorBase
{
public abstract T Interpolate(double progress, T oldValue, T newValue);
internal override Type WrapperType => typeof(AnimatorWrapper);
internal override IAnimator CreateWrapper() => new AnimatorWrapper(this);
internal class AnimatorWrapper : Animator<T>
{
private readonly CustomAnimatorBase<T> _parent;
public AnimatorWrapper(CustomAnimatorBase<T> parent)
{
_parent = parent;
}
public override T Interpolate(double progress, T oldValue, T newValue) => _parent.Interpolate(progress, oldValue, newValue);
}
}

3
src/Avalonia.Base/Animation/IGlobalClock.cs

@ -2,8 +2,7 @@ using Avalonia.Metadata;
namespace Avalonia.Animation
{
[NotClientImplementable]
public interface IGlobalClock : IClock
internal interface IGlobalClock : IClock
{
}
}

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

@ -6,13 +6,13 @@ namespace Avalonia.Animation
/// <summary>
/// Interface for Transition objects.
/// </summary>
[NotClientImplementable]
[NotClientImplementable, PrivateApi]
public interface ITransition
{
/// <summary>
/// Applies the transition to the specified <see cref="Animatable"/>.
/// </summary>
IDisposable Apply(Animatable control, IClock clock, object? oldValue, object? newValue);
internal IDisposable Apply(Animatable control, IClock clock, object? oldValue, object? newValue);
/// <summary>
/// Gets the property to be animated.

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

@ -15,7 +15,7 @@ namespace Avalonia.Animation
/// Stores data regarding a specific key
/// point and value in an animation.
/// </summary>
public class KeyFrame : AvaloniaObject
public sealed class KeyFrame : AvaloniaObject
{
private TimeSpan _ktimeSpan;
private Cue _kCue;

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

@ -7,7 +7,7 @@ namespace Avalonia.Animation
/// <summary>
/// A collection of <see cref="KeyFrame"/>s.
/// </summary>
public class KeyFrames : AvaloniaList<KeyFrame>
public sealed class KeyFrames : AvaloniaList<KeyFrame>
{
/// <summary>
/// Initializes a new instance of the <see cref="KeyFrames"/> class.

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

@ -17,7 +17,7 @@ namespace Avalonia.Animation
/// See https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.animation.keyspline
/// </summary>
[TypeConverter(typeof(KeySplineTypeConverter))]
public class KeySpline : AvaloniaObject
public sealed class KeySpline : AvaloniaObject
{
// Control points
private double _controlPointX1;

26
src/Avalonia.Base/Animation/RenderLoopClock.cs

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Avalonia.Rendering;
namespace Avalonia.Animation
{
public class RenderLoopClock : ClockBase, IRenderLoopTask, IGlobalClock
{
protected override void Stop()
{
AvaloniaLocator.Current.GetRequiredService<IRenderLoop>().Remove(this);
}
bool IRenderLoopTask.NeedsUpdate => HasSubscriptions;
void IRenderLoopTask.Render()
{
}
void IRenderLoopTask.Update(TimeSpan time)
{
Pulse(time);
}
}
}

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

@ -10,7 +10,7 @@ namespace Avalonia.Animation;
/// Determines how an animation is used based on spring formula.
/// </summary>
[TypeConverter(typeof(SpringTypeConverter))]
public class Spring
internal class Spring
{
private SpringSolver _springSolver;
private double _mass;

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

@ -7,7 +7,7 @@ namespace Avalonia.Animation;
/// <summary>
/// Converts string values to <see cref="Spring"/> values.
/// </summary>
public class SpringTypeConverter : TypeConverter
internal class SpringTypeConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{

7
src/Avalonia.Base/Animation/Transition.cs

@ -53,10 +53,13 @@ namespace Avalonia.Animation
/// <summary>
/// Apply interpolation to the property.
/// </summary>
public abstract IObservable<T> DoTransition(IObservable<double> progress, T oldValue, T newValue);
internal abstract IObservable<T> DoTransition(IObservable<double> progress, T oldValue, T newValue);
/// <inheritdocs/>
public virtual IDisposable Apply(Animatable control, IClock clock, object? oldValue, object? newValue)
IDisposable ITransition.Apply(Animatable control, IClock clock, object? oldValue, object? newValue)
=> Apply(control, clock, oldValue, newValue);
internal virtual IDisposable Apply(Animatable control, IClock clock, object? oldValue, object? newValue)
{
if (Property is null)
throw new InvalidOperationException("Transition has no property specified.");

6
src/Avalonia.Base/Animation/TransitionObservableBase.cs

@ -10,13 +10,13 @@ namespace Avalonia.Animation
/// Provides base for observables implementing transitions.
/// </summary>
/// <typeparam name="T">Type of the transitioned value.</typeparam>
public abstract class TransitionObservableBase<T> : SingleSubscriberObservableBase<T>, IObserver<double>
internal abstract class TransitionObservableBase<T> : SingleSubscriberObservableBase<T>, IObserver<double>
{
private readonly Easing _easing;
private readonly IEasing _easing;
private readonly IObservable<double> _progress;
private IDisposable? _progressSubscription;
protected TransitionObservableBase(IObservable<double> progress, Easing easing)
protected TransitionObservableBase(IObservable<double> progress, IEasing easing)
{
_progress = progress;
_easing = easing;

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

@ -7,7 +7,7 @@ namespace Avalonia.Animation
/// <summary>
/// A collection of <see cref="ITransition"/> definitions.
/// </summary>
public class Transitions : AvaloniaList<ITransition>
public sealed class Transitions : AvaloniaList<ITransition>
{
/// <summary>
/// Initializes a new instance of the <see cref="Transitions"/> class.

6
src/Avalonia.Base/Animation/Transitions/BoxShadowsTransition.cs

@ -1,3 +1,4 @@
using System;
using Avalonia.Animation.Animators;
using Avalonia.Media;
@ -6,7 +7,10 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="BoxShadows"/> type.
/// </summary>
public class BoxShadowsTransition : AnimatorDrivenTransition<BoxShadows, BoxShadowsAnimator>
public class BoxShadowsTransition : Transition<BoxShadows>
{
internal override IObservable<BoxShadows> DoTransition(IObservable<double> progress, BoxShadows oldValue,
BoxShadows newValue) =>
AnimatorDrivenTransition<BoxShadows, BoxShadowsAnimator>.Transition(Easing, progress, oldValue, newValue);
}
}

2
src/Avalonia.Base/Animation/Transitions/BrushTransition.cs

@ -16,7 +16,7 @@ namespace Avalonia.Animation
private static readonly GradientBrushAnimator s_gradientAnimator = new GradientBrushAnimator();
private static readonly ISolidColorBrushAnimator s_solidColorBrushAnimator = new ISolidColorBrushAnimator();
public override IObservable<IBrush?> DoTransition(IObservable<double> progress, IBrush? oldValue, IBrush? newValue)
internal override IObservable<IBrush?> DoTransition(IObservable<double> progress, IBrush? oldValue, IBrush? newValue)
{
if (oldValue is null || newValue is null)
{

7
src/Avalonia.Base/Animation/Transitions/ColorTransition.cs

@ -1,4 +1,5 @@
using Avalonia.Animation.Animators;
using System;
using Avalonia.Animation.Animators;
using Avalonia.Media;
namespace Avalonia.Animation
@ -6,7 +7,9 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="Color"/> type.
/// </summary>
public class ColorTransition : AnimatorDrivenTransition<Color, ColorAnimator>
public class ColorTransition : Transition<Color>
{
internal override IObservable<Color> DoTransition(IObservable<double> progress, Color oldValue, Color newValue)
=> AnimatorDrivenTransition<Color, ColorAnimator>.Transition(Easing, progress, oldValue, newValue);
}
}

7
src/Avalonia.Base/Animation/Transitions/CornerRadiusTransition.cs

@ -1,3 +1,4 @@
using System;
using Avalonia.Animation.Animators;
namespace Avalonia.Animation
@ -5,7 +6,11 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="CornerRadius"/> type.
/// </summary>
public class CornerRadiusTransition : AnimatorDrivenTransition<CornerRadius, CornerRadiusAnimator>
public class CornerRadiusTransition : Transition<CornerRadius>
{
internal override IObservable<CornerRadius> DoTransition(IObservable<double> progress, CornerRadius oldValue,
CornerRadius newValue) =>
AnimatorDrivenTransition<CornerRadius, CornerRadiusAnimator>.Transition(Easing, progress, oldValue,
newValue);
}
}

5
src/Avalonia.Base/Animation/Transitions/DoubleTransition.cs

@ -1,3 +1,4 @@
using System;
using Avalonia.Animation.Animators;
namespace Avalonia.Animation
@ -5,7 +6,9 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="double"/> types.
/// </summary>
public class DoubleTransition : AnimatorDrivenTransition<double, DoubleAnimator>
public class DoubleTransition : Transition<double>
{
internal override IObservable<double> DoTransition(IObservable<double> progress, double oldValue, double newValue) =>
AnimatorDrivenTransition<double, DoubleAnimator>.Transition(Easing, progress, oldValue, newValue);
}
}

5
src/Avalonia.Base/Animation/Transitions/FloatTransition.cs

@ -1,3 +1,4 @@
using System;
using Avalonia.Animation.Animators;
namespace Avalonia.Animation
@ -5,7 +6,9 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="float"/> types.
/// </summary>
public class FloatTransition : AnimatorDrivenTransition<float, FloatAnimator>
public class FloatTransition : Transition<float>
{
internal override IObservable<float> DoTransition(IObservable<double> progress, float oldValue, float newValue) =>
AnimatorDrivenTransition<float, FloatAnimator>.Transition(Easing, progress, oldValue, newValue);
}
}

5
src/Avalonia.Base/Animation/Transitions/IntegerTransition.cs

@ -1,3 +1,4 @@
using System;
using Avalonia.Animation.Animators;
namespace Avalonia.Animation
@ -5,7 +6,9 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="int"/> types.
/// </summary>
public class IntegerTransition : AnimatorDrivenTransition<int, Int32Animator>
public class IntegerTransition : Transition<int>
{
internal override IObservable<int> DoTransition(IObservable<double> progress, int oldValue, int newValue) =>
AnimatorDrivenTransition<int, Int32Animator>.Transition(Easing, progress, oldValue, newValue);
}
}

5
src/Avalonia.Base/Animation/Transitions/PointTransition.cs

@ -1,3 +1,4 @@
using System;
using Avalonia.Animation.Animators;
namespace Avalonia.Animation
@ -5,7 +6,9 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="Point"/> type.
/// </summary>
public class PointTransition : AnimatorDrivenTransition<Point, PointAnimator>
public class PointTransition : Transition<Point>
{
internal override IObservable<Point> DoTransition(IObservable<double> progress, Point oldValue, Point newValue) =>
AnimatorDrivenTransition<Point, PointAnimator>.Transition(Easing, progress, oldValue, newValue);
}
}

5
src/Avalonia.Base/Animation/Transitions/RelativePointTransition.cs

@ -1,3 +1,4 @@
using System;
using Avalonia.Animation.Animators;
namespace Avalonia.Animation
@ -5,7 +6,9 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="RelativePoint"/> type.
/// </summary>
public class RelativePointTransition : AnimatorDrivenTransition<RelativePoint, RelativePointAnimator>
public class RelativePointTransition : Transition<RelativePoint>
{
internal override IObservable<RelativePoint> DoTransition(IObservable<double> progress, RelativePoint oldValue, RelativePoint newValue) =>
AnimatorDrivenTransition<RelativePoint, RelativePointAnimator>.Transition(Easing, progress, oldValue, newValue);
}
}

5
src/Avalonia.Base/Animation/Transitions/SizeTransition.cs

@ -1,3 +1,4 @@
using System;
using Avalonia.Animation.Animators;
namespace Avalonia.Animation
@ -5,7 +6,9 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="Size"/> type.
/// </summary>
public class SizeTransition : AnimatorDrivenTransition<Size, SizeAnimator>
public class SizeTransition : Transition<Size>
{
internal override IObservable<Size> DoTransition(IObservable<double> progress, Size oldValue, Size newValue) =>
AnimatorDrivenTransition<Size, SizeAnimator>.Transition(Easing, progress, oldValue, newValue);
}
}

5
src/Avalonia.Base/Animation/Transitions/ThicknessTransition.cs

@ -1,3 +1,4 @@
using System;
using Avalonia.Animation.Animators;
namespace Avalonia.Animation
@ -5,7 +6,9 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="Thickness"/> type.
/// </summary>
public class ThicknessTransition : AnimatorDrivenTransition<Thickness, ThicknessAnimator>
public class ThicknessTransition : Transition<Thickness>
{
internal override IObservable<Thickness> DoTransition(IObservable<double> progress, Thickness oldValue, Thickness newValue) =>
AnimatorDrivenTransition<Thickness, ThicknessAnimator>.Transition(Easing, progress, oldValue, newValue);
}
}

2
src/Avalonia.Base/Animation/Transitions/TransformOperationsTransition.cs

@ -11,7 +11,7 @@ namespace Avalonia.Animation
{
private static readonly TransformOperationsAnimator s_operationsAnimator = new TransformOperationsAnimator();
public override IObservable<ITransform> DoTransition(
internal override IObservable<ITransform> DoTransition(
IObservable<double> progress,
ITransform oldValue,
ITransform newValue)

5
src/Avalonia.Base/Animation/Transitions/VectorTransition.cs

@ -1,3 +1,4 @@
using System;
using Avalonia.Animation.Animators;
namespace Avalonia.Animation
@ -5,7 +6,9 @@ namespace Avalonia.Animation
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="Vector"/> type.
/// </summary>
public class VectorTransition : AnimatorDrivenTransition<Vector, VectorAnimator>
public class VectorTransition : Transition<Vector>
{
internal override IObservable<Vector> DoTransition(IObservable<double> progress, Vector oldValue, Vector newValue) =>
AnimatorDrivenTransition<Vector, VectorAnimator>.Transition(Easing, progress, oldValue, newValue);
}
}

37
src/Avalonia.Base/Data/TemplateBinding.cs

@ -3,18 +3,21 @@ using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Reactive;
using Avalonia.Styling;
using Avalonia.Threading;
namespace Avalonia.Data
{
/// <summary>
/// A XAML binding to a property on a control's templated parent.
/// </summary>
public class TemplateBinding : SingleSubscriberObservableBase<object?>,
public class TemplateBinding : IObservable<object?>,
IBinding,
IDescription,
IAvaloniaSubject<object?>,
ISetterValue
ISetterValue,
IDisposable
{
private IObserver<object?>? _observer;
private bool _isSetterValue;
private StyledElement? _target;
private Type? _targetType;
@ -29,6 +32,28 @@ namespace Avalonia.Data
Property = property;
}
public IDisposable Subscribe(IObserver<object?> observer)
{
_ = observer ?? throw new ArgumentNullException(nameof(observer));
Dispatcher.UIThread.VerifyAccess();
if (_observer != null)
{
throw new InvalidOperationException("The observable can only be subscribed once.");
}
_observer = observer;
Subscribed();
return this;
}
public virtual void Dispose()
{
Unsubscribed();
_observer = null;
}
/// <inheritdoc/>
public InstancedBinding? Initiate(
AvaloniaObject target,
@ -111,7 +136,7 @@ namespace Avalonia.Data
/// <inheritdoc/>
void ISetterValue.Initialize(SetterBase setter) => _isSetterValue = true;
protected override void Subscribed()
private void Subscribed()
{
TemplatedParentChanged();
@ -121,7 +146,7 @@ namespace Avalonia.Data
}
}
protected override void Unsubscribed()
private void Unsubscribed()
{
if (_target?.TemplatedParent is { } templatedParent)
{
@ -147,12 +172,12 @@ namespace Avalonia.Data
value = Converter.Convert(value, _targetType ?? typeof(object), ConverterParameter, CultureInfo.CurrentCulture);
}
PublishNext(value);
_observer?.OnNext(value);
_hasProducedValue = true;
}
else if (_hasProducedValue)
{
PublishNext(AvaloniaProperty.UnsetValue);
_observer?.OnNext(AvaloniaProperty.UnsetValue);
_hasProducedValue = false;
}
}

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

@ -65,14 +65,14 @@ namespace Avalonia.Input
{
if (_mainMenu != null)
{
_mainMenu.MenuClosed -= MainMenuClosed;
_mainMenu.Closed -= MainMenuClosed;
}
_mainMenu = value;
if (_mainMenu != null)
{
_mainMenu.MenuClosed += MainMenuClosed;
_mainMenu.Closed += MainMenuClosed;
}
}
}

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

@ -26,6 +26,6 @@ namespace Avalonia.Input
/// <summary>
/// Occurs when the main menu closes.
/// </summary>
event EventHandler<RoutedEventArgs>? MenuClosed;
event EventHandler<RoutedEventArgs>? Closed;
}
}

11
src/Avalonia.Base/Input/PointerEventArgs.cs

@ -70,6 +70,17 @@ namespace Avalonia.Input
if (relativeTo == null)
return pt;
// If the visual the user passed in, is not connected to the same visual root
// (i.e. they called it for a control inside a popup.
if (!ReferenceEquals(_rootVisual, relativeTo.VisualRoot) && relativeTo.VisualRoot is { })
{
// Convert to absolute screen coordinates.
var screenPt = _rootVisual.PointToScreen(pt);
// Convert to client co-ordinates of the visual inside the other visual root.
return relativeTo.PointToClient(screenPt);
}
return pt * _rootVisual.TransformToVisual(relativeTo) ?? default;
}

2
src/Avalonia.Base/Input/TextInput/TransformTrackingHelper.cs

@ -91,7 +91,7 @@ namespace Avalonia.Input.TextInput
if(_queuedForUpdate)
return;
_queuedForUpdate = true;
Dispatcher.UIThread.Post(UpdateMatrix, DispatcherPriority.Render);
Dispatcher.UIThread.Post(UpdateMatrix, DispatcherPriority.AfterRender);
}
private void PropertyChangedHandler(object? sender, AvaloniaPropertyChangedEventArgs e)

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

@ -1,46 +0,0 @@
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/Layout/ILayoutManager.cs

@ -7,7 +7,7 @@ namespace Avalonia.Layout
/// Manages measuring and arranging of controls.
/// </summary>
[NotClientImplementable]
public interface ILayoutManager : IDisposable
internal interface ILayoutManager : IDisposable
{
/// <summary>
/// Raised when the layout manager completes a layout pass.

2
src/Avalonia.Base/Layout/ILayoutRoot.cs

@ -21,6 +21,6 @@ namespace Avalonia.Layout
/// <summary>
/// Associated instance of layout manager
/// </summary>
ILayoutManager LayoutManager { get; }
internal ILayoutManager LayoutManager { get; }
}
}

11
src/Avalonia.Base/Layout/LayoutManager.cs

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Avalonia.Logging;
using Avalonia.Media;
using Avalonia.Rendering;
using Avalonia.Threading;
using Avalonia.Utilities;
@ -15,24 +16,24 @@ namespace Avalonia.Layout
/// <summary>
/// Manages measuring and arranging of controls.
/// </summary>
public class LayoutManager : ILayoutManager, IDisposable
internal class LayoutManager : ILayoutManager, IDisposable
{
private const int MaxPasses = 10;
private readonly Layoutable _owner;
private readonly LayoutQueue<Layoutable> _toMeasure = new LayoutQueue<Layoutable>(v => !v.IsMeasureValid);
private readonly LayoutQueue<Layoutable> _toArrange = new LayoutQueue<Layoutable>(v => !v.IsArrangeValid);
private readonly List<Layoutable> _toArrangeAfterMeasure = new();
private readonly Action _executeLayoutPass;
private List<EffectiveViewportChangedListener>? _effectiveViewportChangedListeners;
private bool _disposed;
private bool _queued;
private bool _running;
private int _totalPassCount;
private Action _invokeOnRender;
public LayoutManager(ILayoutRoot owner)
{
_owner = owner as Layoutable ?? throw new ArgumentNullException(nameof(owner));
_executeLayoutPass = ExecuteQueuedLayoutPass;
_invokeOnRender = ExecuteQueuedLayoutPass;
}
public virtual event EventHandler? LayoutUpdated;
@ -99,7 +100,7 @@ namespace Avalonia.Layout
QueueLayoutPass();
}
private void ExecuteQueuedLayoutPass()
internal void ExecuteQueuedLayoutPass()
{
if (!_queued)
{
@ -346,7 +347,7 @@ namespace Avalonia.Layout
if (!_queued && !_running)
{
_queued = true;
Dispatcher.UIThread.Post(_executeLayoutPass, DispatcherPriority.Layout);
MediaContext.Instance.BeginInvokeOnRender(_invokeOnRender);
}
}

9
src/Avalonia.Base/Layout/Layoutable.cs

@ -205,6 +205,15 @@ namespace Avalonia.Layout
}
}
/// <summary>
/// Executes a layout pass.
/// </summary>
/// <remarks>
/// You should not usually need to call this method explictly, the layout manager will
/// schedule layout passes itself.
/// </remarks>
public void UpdateLayout() => (this.GetVisualRoot() as ILayoutRoot)?.LayoutManager?.ExecuteLayoutPass();
/// <summary>
/// Gets or sets the width of the element.
/// </summary>

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

@ -19,6 +19,7 @@ namespace Avalonia.Media
/// <param name="firstCharacterIndex">Index of the first character that got hit.</param>
/// <param name="trailingLength">In the case of a leading edge, this value is 0. In the case of a trailing edge,
/// this value is the number of code points until the next valid caret position.</param>
[DebuggerStepThrough]
public CharacterHit(int firstCharacterIndex, int trailingLength = 0)
{
FirstCharacterIndex = firstCharacterIndex;

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

@ -13,7 +13,7 @@ namespace Avalonia.Media
/// <summary>
/// Represents the sequence of dashes and gaps that will be applied by a <see cref="Pen"/>.
/// </summary>
public class DashStyle : Animatable, IDashStyle
public sealed class DashStyle : Animatable, IDashStyle
{
/// <summary>
/// Defines the <see cref="Dashes"/> property.

5
src/Avalonia.Base/Media/Drawing.cs

@ -5,6 +5,11 @@
/// </summary>
public abstract class Drawing : AvaloniaObject
{
internal Drawing()
{
}
/// <summary>
/// Draws this drawing to the given <see cref="DrawingContext"/>.
/// </summary>

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

@ -12,7 +12,7 @@ namespace Avalonia.Media
/// <summary>
/// Paints an area with an <see cref="Drawing"/>.
/// </summary>
public class DrawingBrush : TileBrush, ISceneBrush
public sealed class DrawingBrush : TileBrush, ISceneBrush
{
/// <summary>
/// Defines the <see cref="Drawing"/> property.

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

@ -8,7 +8,7 @@ using Avalonia.Utilities;
namespace Avalonia.Media
{
public class DrawingGroup : Drawing
public sealed class DrawingGroup : Drawing
{
public static readonly StyledProperty<double> OpacityProperty =
AvaloniaProperty.Register<DrawingGroup, double>(nameof(Opacity), 1);

2
src/Avalonia.Base/Media/Effects/BlurEffect.cs

@ -2,7 +2,7 @@ using System;
// ReSharper disable CheckNamespace
namespace Avalonia.Media;
public class BlurEffect : Effect, IBlurEffect, IMutableEffect
public sealed class BlurEffect : Effect, IBlurEffect, IMutableEffect
{
public static readonly StyledProperty<double> RadiusProperty = AvaloniaProperty.Register<BlurEffect, double>(
nameof(Radius), 5);

4
src/Avalonia.Base/Media/Effects/DropShadowEffect.cs

@ -42,7 +42,7 @@ public abstract class DropShadowEffectBase : Effect
}
}
public class DropShadowEffect : DropShadowEffectBase, IDropShadowEffect, IMutableEffect
public sealed class DropShadowEffect : DropShadowEffectBase, IDropShadowEffect, IMutableEffect
{
public static readonly StyledProperty<double> OffsetXProperty = AvaloniaProperty.Register<DropShadowEffect, double>(
nameof(OffsetX), 3.5355);
@ -76,7 +76,7 @@ public class DropShadowEffect : DropShadowEffectBase, IDropShadowEffect, IMutabl
/// <summary>
/// This class is compatible with WPF's DropShadowEffect and provides Direction and ShadowDepth properties instead of OffsetX/OffsetY
/// </summary>
public class DropShadowDirectionEffect : DropShadowEffectBase, IDirectionDropShadowEffect, IMutableEffect
public sealed class DropShadowDirectionEffect : DropShadowEffectBase, IDirectionDropShadowEffect, IMutableEffect
{
public static readonly StyledProperty<double> ShadowDepthProperty =
AvaloniaProperty.Register<DropShadowDirectionEffect, double>(

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

Loading…
Cancel
Save