Skip to content

Commit

Permalink
Fix Adorner Layer Clipping (#13921)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
grokys authored and maxkatz6 committed Jan 17, 2024
1 parent 906e0cc commit 72ff070
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion samples/ControlCatalog/Pages/AdornerLayerPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
Background="Cyan"
IsHitTestVisible="False"
Opacity="0.3"
IsVisible="True">
IsVisible="True"
AdornerLayer.IsClipEnabled="False">
<Line StartPoint="-10000,0" EndPoint="10000,0" Stroke="Cyan" StrokeThickness="1" />
<Line StartPoint="-10000,42" EndPoint="10000,42" Stroke="Cyan" StrokeThickness="1" />
<Line StartPoint="0,-10000" EndPoint="0,10000" Stroke="Cyan" StrokeThickness="1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public virtual UpdateResult Update(ServerCompositionTarget root)
}

_combinedTransformedClipBounds =
AdornedVisual?._combinedTransformedClipBounds
(AdornerIsClipped ? AdornedVisual?._combinedTransformedClipBounds : null)
?? (Parent?.Effect == null ? Parent?._combinedTransformedClipBounds : null)
?? new Rect(Root!.Size);

Expand Down
1 change: 1 addition & 0 deletions src/Avalonia.Controls/GridSplitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ private void SetupPreviewAdorner()
_resizeData.Adorner = new PreviewAdorner(builtPreviewContent);

AdornerLayer.SetAdornedElement(_resizeData.Adorner, this);
AdornerLayer.SetIsClipEnabled(_resizeData.Adorner, false);

adornerLayer.Children.Add(_resizeData.Adorner);

Expand Down
1 change: 0 additions & 1 deletion src/Avalonia.Controls/Primitives/AdornerLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ private static void AddVisualAdorner(Visual visual, Control? adorner, AdornerLay
}

SetAdornedElement(adorner, visual);
SetIsClipEnabled(adorner, false);

((ISetLogicalParent) adorner).SetParent(visual);
layer.Children.Add(adorner);
Expand Down

0 comments on commit 72ff070

Please sign in to comment.