Skip to content

Commit 72ff070

Browse files
grokysmaxkatz6
authored andcommitted
Fix Adorner Layer Clipping (#13921)
* Don't overwrite IsClipEnabled. The user should be able to set this on an adorner themselves. * Use correct clip bounds for adorners. Only take the adorned visual's clip bounds into account if the adorner is clipped to these bounds. * Disable clipping on GridSplitter adorner. Fixes #10700 * Don't clip adorners in ControlCatalog. Default setting is `true`, but this was being overridden in `AdornerLayer.AddVisualAdorner`. That was fixed by an earlier commit in this PR, so property needs to be set explicitly to false in ControlCatalog.
1 parent 906e0cc commit 72ff070

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

samples/ControlCatalog/Pages/AdornerLayerPage.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
Background="Cyan"
5151
IsHitTestVisible="False"
5252
Opacity="0.3"
53-
IsVisible="True">
53+
IsVisible="True"
54+
AdornerLayer.IsClipEnabled="False">
5455
<Line StartPoint="-10000,0" EndPoint="10000,0" Stroke="Cyan" StrokeThickness="1" />
5556
<Line StartPoint="-10000,42" EndPoint="10000,42" Stroke="Cyan" StrokeThickness="1" />
5657
<Line StartPoint="0,-10000" EndPoint="0,10000" Stroke="Cyan" StrokeThickness="1" />

src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionVisual.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public virtual UpdateResult Update(ServerCompositionTarget root)
205205
}
206206

207207
_combinedTransformedClipBounds =
208-
AdornedVisual?._combinedTransformedClipBounds
208+
(AdornerIsClipped ? AdornedVisual?._combinedTransformedClipBounds : null)
209209
?? (Parent?.Effect == null ? Parent?._combinedTransformedClipBounds : null)
210210
?? new Rect(Root!.Size);
211211

src/Avalonia.Controls/GridSplitter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ private void SetupPreviewAdorner()
341341
_resizeData.Adorner = new PreviewAdorner(builtPreviewContent);
342342

343343
AdornerLayer.SetAdornedElement(_resizeData.Adorner, this);
344+
AdornerLayer.SetIsClipEnabled(_resizeData.Adorner, false);
344345

345346
adornerLayer.Children.Add(_resizeData.Adorner);
346347

src/Avalonia.Controls/Primitives/AdornerLayer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ private static void AddVisualAdorner(Visual visual, Control? adorner, AdornerLay
174174
}
175175

176176
SetAdornedElement(adorner, visual);
177-
SetIsClipEnabled(adorner, false);
178177

179178
((ISetLogicalParent) adorner).SetParent(visual);
180179
layer.Children.Add(adorner);

0 commit comments

Comments
 (0)