Browse Source

Merge branch 'master' into features/Issue_6971

pull/6972/head
Dan Walmsley 5 years ago
committed by GitHub
parent
commit
bc7af9f0ba
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      build/SourceLink.props
  2. 6
      src/Avalonia.Animation/Animation.cs
  3. 3
      src/Avalonia.Animation/ApiCompatBaseline.txt
  4. 15
      src/Avalonia.Base/Data/Converters/MethodToCommandConverter.cs
  5. 2
      src/Avalonia.Controls/Platform/InternalPlatformThreadingInterface.cs
  6. 3
      src/Avalonia.Controls/Remote/RemoteServer.cs
  7. 2
      src/Avalonia.Controls/TextBoxTextInputMethodClient.cs
  8. 2
      src/Avalonia.DesignerSupport/Remote/FileWatcherTransport.cs
  9. 6
      src/Avalonia.FreeDesktop/DBusMenuExporter.cs
  10. 2
      src/Avalonia.Native/AvaloniaNativeMenuExporter.cs
  11. 22
      src/Avalonia.Visuals/Matrix.cs
  12. 10
      src/Avalonia.Visuals/Media/Transformation/InterpolationUtilities.cs
  13. 5
      src/Avalonia.Visuals/Media/Transformation/TransformOperation.cs
  14. 4
      src/Avalonia.X11/X11Window.Xim.cs
  15. 2
      tests/Avalonia.Controls.UnitTests/ItemsSourceViewTests.cs
  16. 72
      tests/Avalonia.Visuals.UnitTests/Media/TransformOperationsTests.cs

2
build/SourceLink.props

@ -3,7 +3,7 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>false</IncludeSymbols>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<DebugType>embedded</DebugType>
<DebugType>full</DebugType>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

6
src/Avalonia.Animation/Animation.cs

@ -353,6 +353,12 @@ namespace Avalonia.Animation
return new CompositeDisposable(subscriptions);
}
/// <inheritdoc/>
public Task RunAsync(Animatable control, IClock clock = null)
{
return RunAsync(control, clock, default);
}
/// <inheritdoc/>
public Task RunAsync(Animatable control, IClock clock = null, CancellationToken cancellationToken = default)
{

3
src/Avalonia.Animation/ApiCompatBaseline.txt

@ -1,6 +1,5 @@
Compat issues with assembly Avalonia.Animation:
MembersMustExist : Member 'public System.Threading.Tasks.Task Avalonia.Animation.Animation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' is present in the contract but not in the implementation.
MembersMustExist : Member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock, System.Threading.CancellationToken)' is present in the implementation but not in the contract.
Total Issues: 4
Total Issues: 3

15
src/Avalonia.Base/Data/Converters/MethodToCommandConverter.cs

@ -140,18 +140,9 @@ namespace Avalonia.Data.Converters
);
}
Action<object> action = null;
try
{
action = Expression
.Lambda<Action<object>>(body, parameter)
.Compile();
}
catch (Exception ex)
{
throw ex;
}
return action;
return Expression
.Lambda<Action<object>>(body, parameter)
.Compile();
}
static Func<object, bool> CreateCanExecute(object target

2
src/Avalonia.Controls/Platform/InternalPlatformThreadingInterface.cs

@ -85,7 +85,9 @@ namespace Avalonia.Controls.Platform
public bool CurrentThreadIsLoopThread => TlsCurrentThreadIsLoopThread;
public event Action<DispatcherPriority?> Signaled;
#pragma warning disable CS0067
public event Action<TimeSpan> Tick;
#pragma warning restore CS0067
}
}

3
src/Avalonia.Controls/Remote/RemoteServer.cs

@ -15,9 +15,6 @@ namespace Avalonia.Controls.Remote
public EmbeddableRemoteServerTopLevelImpl(IAvaloniaRemoteTransportConnection transport) : base(transport)
{
}
#pragma warning disable 67
public Action LostFocus { get; set; }
}
public RemoteServer(IAvaloniaRemoteTransportConnection transport)

2
src/Avalonia.Controls/TextBoxTextInputMethodClient.cs

@ -18,7 +18,7 @@ namespace Avalonia.Controls
public bool SupportsSurroundingText => false;
public TextInputMethodSurroundingText SurroundingText => throw new NotSupportedException();
public event EventHandler SurroundingTextChanged;
public event EventHandler SurroundingTextChanged { add { } remove { } }
public string TextBeforeCursor => null;
public string TextAfterCursor => null;

2
src/Avalonia.DesignerSupport/Remote/FileWatcherTransport.cs

@ -59,7 +59,7 @@ namespace Avalonia.DesignerSupport.Remote
remove { _onMessage -= value; }
}
public event Action<IAvaloniaRemoteTransportConnection, Exception> OnException;
public event Action<IAvaloniaRemoteTransportConnection, Exception> OnException { add { } remove { } }
public void Start()
{
UpdaterThread();

6
src/Avalonia.FreeDesktop/DBusMenuExporter.cs

@ -413,10 +413,10 @@ namespace Avalonia.FreeDesktop
#region Events
private event Action<((int, IDictionary<string, object>)[] updatedProps, (int, string[])[] removedProps)>
ItemsPropertiesUpdated;
ItemsPropertiesUpdated { add { } remove { } }
private event Action<(uint revision, int parent)> LayoutUpdated;
private event Action<(int id, uint timestamp)> ItemActivationRequested;
private event Action<PropertyChanges> PropertiesChanged;
private event Action<(int id, uint timestamp)> ItemActivationRequested { add { } remove { } }
private event Action<PropertyChanges> PropertiesChanged { add { } remove { } }
async Task<IDisposable> IDBusMenu.WatchItemsPropertiesUpdatedAsync(Action<((int, IDictionary<string, object>)[] updatedProps, (int, string[])[] removedProps)> handler, Action<Exception> onError)
{

2
src/Avalonia.Native/AvaloniaNativeMenuExporter.cs

@ -44,7 +44,7 @@ namespace Avalonia.Native
public bool IsNativeMenuExported => _exported;
public event EventHandler OnIsNativeMenuExportedChanged;
public event EventHandler OnIsNativeMenuExportedChanged { add { } remove { } }
public void SetNativeMenu(NativeMenu menu)
{

22
src/Avalonia.Visuals/Matrix.cs

@ -215,6 +215,28 @@ namespace Avalonia
return angle * 0.0174532925;
}
/// <summary>
/// Appends another matrix as post-multiplication operation.
/// Equivalent to this * value;
/// </summary>
/// <param name="value">A matrix.</param>
/// <returns>Post-multiplied matrix.</returns>
public Matrix Append(Matrix value)
{
return this * value;
}
/// <summary>
/// Prpends another matrix as pre-multiplication operation.
/// Equivalent to value * this;
/// </summary>
/// <param name="value">A matrix.</param>
/// <returns>Pre-multiplied matrix.</returns>
public Matrix Prepend(Matrix value)
{
return value * this;
}
/// <summary>
/// Calculates the determinant for this matrix.
/// </summary>

10
src/Avalonia.Visuals/Media/Transformation/InterpolationUtilities.cs

@ -18,11 +18,11 @@ namespace Avalonia.Media.Transformation
public static Matrix ComposeTransform(Matrix.Decomposed decomposed)
{
// According to https://www.w3.org/TR/css-transforms-1/#recomposing-to-a-2d-matrix
return Matrix.CreateTranslation(decomposed.Translate) *
Matrix.CreateRotation(decomposed.Angle) *
Matrix.CreateSkew(decomposed.Skew.X, decomposed.Skew.Y) *
Matrix.CreateScale(decomposed.Scale);
return Matrix.Identity
.Prepend(Matrix.CreateTranslation(decomposed.Translate))
.Prepend(Matrix.CreateRotation(decomposed.Angle))
.Prepend(Matrix.CreateSkew(decomposed.Skew.X, decomposed.Skew.Y))
.Prepend(Matrix.CreateScale(decomposed.Scale));
}
public static Matrix.Decomposed InterpolateDecomposedTransforms(ref Matrix.Decomposed from, ref Matrix.Decomposed to, double progress)

5
src/Avalonia.Visuals/Media/Transformation/TransformOperation.cs

@ -86,6 +86,8 @@ namespace Avalonia.Media.Transformation
if (fromIdentity && toIdentity)
{
result.Matrix = Matrix.Identity;
return true;
}
@ -179,7 +181,8 @@ namespace Avalonia.Media.Transformation
}
case OperationType.Identity:
{
// Do nothing.
result.Matrix = Matrix.Identity;
break;
}
}

4
src/Avalonia.X11/X11Window.Xim.cs

@ -112,8 +112,8 @@ namespace Avalonia.X11
public ValueTask<bool> HandleEventAsync(RawKeyEventArgs args, int keyVal, int keyCode) =>
new ValueTask<bool>(false);
public event Action<string> Commit;
public event Action<X11InputMethodForwardedKey> ForwardKey;
public event Action<string> Commit { add { } remove { } }
public event Action<X11InputMethodForwardedKey> ForwardKey { add { } remove { } }
}

2
tests/Avalonia.Controls.UnitTests/ItemsSourceViewTests.cs

@ -47,7 +47,7 @@ namespace Avalonia.Controls.UnitTests
private class InvalidCollection : INotifyCollectionChanged, IEnumerable<string>
{
public event NotifyCollectionChangedEventHandler CollectionChanged;
public event NotifyCollectionChangedEventHandler CollectionChanged { add { } remove { } }
public IEnumerator<string> GetEnumerator()
{

72
tests/Avalonia.Visuals.UnitTests/Media/TransformOperationsTests.cs

@ -129,7 +129,7 @@ namespace Avalonia.Visuals.UnitTests.Media
Assert.Single(operations);
Assert.Equal(TransformOperation.OperationType.Matrix, operations[0].Type);
var expectedMatrix = new Matrix(1, 2, 3, 4, 5, 6);
Assert.Equal(expectedMatrix, operations[0].Matrix);
@ -195,7 +195,7 @@ namespace Avalonia.Visuals.UnitTests.Media
[Theory]
[InlineData(0d, 10d)]
[InlineData(0.5d, 15d)]
[InlineData(1d,20d)]
[InlineData(1d, 20d)]
public void Can_Interpolate_Rotation(double progress, double angle)
{
var from = TransformOperations.Parse("rotate(10deg)");
@ -225,5 +225,73 @@ namespace Avalonia.Visuals.UnitTests.Media
Assert.Single(operations);
Assert.Equal(TransformOperation.OperationType.Matrix, operations[0].Type);
}
[Fact]
public void Order_Of_Operations_Is_Preserved_No_Prefix()
{
var from = TransformOperations.Parse("scale(1)");
var to = TransformOperations.Parse("translate(50px,50px) scale(0.5,0.5)");
var interpolated_0 = TransformOperations.Interpolate(from, to, 0);
Assert.True(interpolated_0.IsIdentity);
var interpolated_50 = TransformOperations.Interpolate(from, to, 0.5);
AssertMatrix(interpolated_50.Value, scaleX: 0.75, scaleY: 0.75, translateX: 12.5, translateY: 12.5);
var interpolated_100 = TransformOperations.Interpolate(from, to, 1);
AssertMatrix(interpolated_100.Value, scaleX: 0.5, scaleY: 0.5, translateX: 25, translateY: 25);
}
[Fact]
public void Order_Of_Operations_Is_Preserved_One_Prefix()
{
var from = TransformOperations.Parse("scale(1)");
var to = TransformOperations.Parse("scale(0.5,0.5) translate(50px,50px)");
var interpolated_0 = TransformOperations.Interpolate(from, to, 0);
Assert.True(interpolated_0.IsIdentity);
var interpolated_50 = TransformOperations.Interpolate(from, to, 0.5);
AssertMatrix(interpolated_50.Value, scaleX: 0.75, scaleY: 0.75, translateX: 25.0, translateY: 25);
var interpolated_100 = TransformOperations.Interpolate(from, to, 1);
AssertMatrix(interpolated_100.Value, scaleX: 0.5, scaleY: 0.5, translateX: 50, translateY: 50);
}
private static void AssertMatrix(Matrix matrix, double? angle = null, double? scaleX = null, double? scaleY = null, double? translateX = null, double? translateY = null)
{
Assert.True(Matrix.TryDecomposeTransform(matrix, out var composed));
if (angle.HasValue)
{
Assert.Equal(angle.Value, composed.Angle);
}
if (scaleX.HasValue)
{
Assert.Equal(scaleX.Value, composed.Scale.X);
}
if (scaleY.HasValue)
{
Assert.Equal(scaleY.Value, composed.Scale.Y);
}
if (translateX.HasValue)
{
Assert.Equal(translateX.Value, composed.Translate.X);
}
if (translateY.HasValue)
{
Assert.Equal(translateY.Value, composed.Translate.Y);
}
}
}
}

Loading…
Cancel
Save