Browse Source
Merge pull request #3989 from AvaloniaUI/fixes/3984-adorner-clipping
Apply global clip to adorner element.
pull/4000/head
Dariusz Komosiński
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
11 additions and
5 deletions
-
src/Avalonia.Controls/Primitives/AdornerLayer.cs
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Specialized; |
|
|
|
using System.Linq; |
|
|
|
using Avalonia.Media; |
|
|
|
using Avalonia.Rendering; |
|
|
|
using Avalonia.Utilities; |
|
|
|
using Avalonia.VisualTree; |
|
|
|
|
|
|
|
namespace Avalonia.Controls.Primitives |
|
|
|
@ -78,15 +79,20 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
private void UpdateClip(IControl control, TransformedBounds bounds) |
|
|
|
{ |
|
|
|
var clip = control.Clip as RectangleGeometry; |
|
|
|
|
|
|
|
if (clip == null) |
|
|
|
if (!(control.Clip is RectangleGeometry clip)) |
|
|
|
{ |
|
|
|
clip = new RectangleGeometry { Transform = new MatrixTransform() }; |
|
|
|
clip = new RectangleGeometry(); |
|
|
|
control.Clip = clip; |
|
|
|
} |
|
|
|
|
|
|
|
clip.Rect = bounds.Bounds; |
|
|
|
var clipBounds = bounds.Bounds; |
|
|
|
|
|
|
|
if (bounds.Transform.HasInverse) |
|
|
|
{ |
|
|
|
clipBounds = bounds.Clip.TransformToAABB(bounds.Transform.Invert()); |
|
|
|
} |
|
|
|
|
|
|
|
clip.Rect = clipBounds; |
|
|
|
} |
|
|
|
|
|
|
|
private void ChildrenCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) |
|
|
|
|