Browse Source
Merge branch 'master' into fixes/osx-extended-titlebar-double-click
pull/5110/head
Dan Walmsley
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
55 additions and
8 deletions
-
src/Avalonia.Controls/AutoCompleteBox.cs
-
src/Avalonia.Visuals/Matrix.cs
-
src/Avalonia.Visuals/VisualExtensions.cs
-
tests/Avalonia.Visuals.UnitTests/VisualTests.cs
|
|
|
@ -1405,8 +1405,11 @@ namespace Avalonia.Controls |
|
|
|
break; |
|
|
|
|
|
|
|
case Key.Enter: |
|
|
|
OnAdapterSelectionComplete(this, new RoutedEventArgs()); |
|
|
|
e.Handled = true; |
|
|
|
if (IsDropDownOpen) |
|
|
|
{ |
|
|
|
OnAdapterSelectionComplete(this, new RoutedEventArgs()); |
|
|
|
e.Handled = true; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
@ -282,25 +282,44 @@ namespace Avalonia |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Inverts the Matrix.
|
|
|
|
/// Attempts to invert the Matrix.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The inverted matrix.</returns>
|
|
|
|
public Matrix Invert() |
|
|
|
/// <returns>The inverted matrix or <see langword="null"/> when matrix is not invertible.</returns>
|
|
|
|
public bool TryInvert(out Matrix inverted) |
|
|
|
{ |
|
|
|
double d = GetDeterminant(); |
|
|
|
|
|
|
|
if (MathUtilities.IsZero(d)) |
|
|
|
{ |
|
|
|
throw new InvalidOperationException("Transform is not invertible."); |
|
|
|
inverted = default; |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return new Matrix( |
|
|
|
inverted = new Matrix( |
|
|
|
_m22 / d, |
|
|
|
-_m12 / d, |
|
|
|
-_m21 / d, |
|
|
|
_m11 / d, |
|
|
|
((_m21 * _m32) - (_m22 * _m31)) / d, |
|
|
|
((_m12 * _m31) - (_m11 * _m32)) / d); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Inverts the Matrix.
|
|
|
|
/// </summary>
|
|
|
|
/// <exception cref="InvalidOperationException">Matrix is not invertible.</exception>
|
|
|
|
/// <returns>The inverted matrix.</returns>
|
|
|
|
public Matrix Invert() |
|
|
|
{ |
|
|
|
if (!TryInvert(out Matrix inverted)) |
|
|
|
{ |
|
|
|
throw new InvalidOperationException("Transform is not invertible."); |
|
|
|
} |
|
|
|
|
|
|
|
return inverted; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
@ -50,7 +50,13 @@ namespace Avalonia |
|
|
|
{ |
|
|
|
var thisOffset = GetOffsetFrom(common, from); |
|
|
|
var thatOffset = GetOffsetFrom(common, to); |
|
|
|
return -thatOffset * thisOffset; |
|
|
|
|
|
|
|
if (!thatOffset.TryInvert(out var thatOffsetInverted)) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
return thatOffsetInverted * thisOffset; |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
@ -235,6 +235,25 @@ namespace Avalonia.Visuals.UnitTests |
|
|
|
Assert.Equal(new Point(100, 100), point); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void TransformToVisual_With_NonInvertible_RenderTransform_Should_Work() |
|
|
|
{ |
|
|
|
var child = new Decorator |
|
|
|
{ |
|
|
|
Width = 100, |
|
|
|
Height = 100, |
|
|
|
RenderTransform = new ScaleTransform() { ScaleX = 0, ScaleY = 0 } |
|
|
|
}; |
|
|
|
var root = new TestRoot() { Child = child, Width = 400, Height = 400 }; |
|
|
|
|
|
|
|
root.Measure(Size.Infinity); |
|
|
|
root.Arrange(new Rect(new Point(), root.DesiredSize)); |
|
|
|
|
|
|
|
var tr = root.TransformToVisual(child); |
|
|
|
|
|
|
|
Assert.Null(tr); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Should_Not_Log_Binding_Error_When_Not_Attached_To_Logical_Tree() |
|
|
|
{ |
|
|
|
|