Browse Source
Merge pull request #3357 from donandren/issues/3356
Fix ImmediateRenderer hit testing for Adorner type layers
pull/3447/head
Steven Kirk
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
20 additions and
10 deletions
-
src/Avalonia.Controls/Notifications/WindowNotificationManager.cs
-
src/Avalonia.Controls/Primitives/AdornerLayer.cs
-
src/Avalonia.Controls/Primitives/OverlayLayer.cs
-
src/Avalonia.Visuals/Rendering/ICustomSimpleHitTest.cs
|
|
|
@ -7,6 +7,7 @@ using System.Linq; |
|
|
|
using System.Reactive.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Controls.Primitives; |
|
|
|
using Avalonia.Rendering; |
|
|
|
using Avalonia.VisualTree; |
|
|
|
|
|
|
|
namespace Avalonia.Controls.Notifications |
|
|
|
@ -14,7 +15,7 @@ namespace Avalonia.Controls.Notifications |
|
|
|
/// <summary>
|
|
|
|
/// An <see cref="INotificationManager"/> that displays notifications in a <see cref="Window"/>.
|
|
|
|
/// </summary>
|
|
|
|
public class WindowNotificationManager : TemplatedControl, IManagedNotificationManager |
|
|
|
public class WindowNotificationManager : TemplatedControl, IManagedNotificationManager, ICustomSimpleHitTest |
|
|
|
{ |
|
|
|
private IList _items; |
|
|
|
|
|
|
|
@ -153,5 +154,7 @@ namespace Avalonia.Controls.Notifications |
|
|
|
|
|
|
|
adornerLayer?.Children.Add(this); |
|
|
|
} |
|
|
|
|
|
|
|
public bool HitTest(Point point) => VisualChildren.HitTestCustom(point); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -138,10 +138,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public bool HitTest(Point point) |
|
|
|
{ |
|
|
|
return Children.Any(ctrl => ctrl.TransformedBounds?.Contains(point) == true); |
|
|
|
} |
|
|
|
public bool HitTest(Point point) => Children.HitTestCustom(point); |
|
|
|
|
|
|
|
private class AdornedElementInfo |
|
|
|
{ |
|
|
|
|
|
|
|
@ -21,11 +21,8 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public bool HitTest(Point point) |
|
|
|
{ |
|
|
|
return Children.Any(ctrl => ctrl.TransformedBounds?.Contains(point) == true); |
|
|
|
} |
|
|
|
|
|
|
|
public bool HitTest(Point point) => Children.HitTestCustom(point); |
|
|
|
|
|
|
|
protected override Size ArrangeOverride(Size finalSize) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -1,3 +1,7 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using Avalonia.VisualTree; |
|
|
|
|
|
|
|
namespace Avalonia.Rendering |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
@ -9,4 +13,13 @@ namespace Avalonia.Rendering |
|
|
|
{ |
|
|
|
bool HitTest(Point point); |
|
|
|
} |
|
|
|
|
|
|
|
public static class CustomSimpleHitTestExtensions |
|
|
|
{ |
|
|
|
public static bool HitTestCustom(this IVisual visual, Point point) |
|
|
|
=> (visual as ICustomSimpleHitTest)?.HitTest(point) ?? visual.TransformedBounds?.Contains(point) == true; |
|
|
|
|
|
|
|
public static bool HitTestCustom(this IEnumerable<IVisual> children, Point point) |
|
|
|
=> children.Any(ctrl => ctrl.HitTestCustom(point)); |
|
|
|
} |
|
|
|
} |
|
|
|
|