Browse Source

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.
release/11.0.7
Steven Kirk 2 years ago
committed by Max Katz
parent
commit
72ff070d31
  1. 3
      samples/ControlCatalog/Pages/AdornerLayerPage.xaml
  2. 2
      src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionVisual.cs
  3. 1
      src/Avalonia.Controls/GridSplitter.cs
  4. 1
      src/Avalonia.Controls/Primitives/AdornerLayer.cs

3
samples/ControlCatalog/Pages/AdornerLayerPage.xaml

@ -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" />

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

@ -205,7 +205,7 @@ namespace Avalonia.Rendering.Composition.Server
}
_combinedTransformedClipBounds =
AdornedVisual?._combinedTransformedClipBounds
(AdornerIsClipped ? AdornedVisual?._combinedTransformedClipBounds : null)
?? (Parent?.Effect == null ? Parent?._combinedTransformedClipBounds : null)
?? new Rect(Root!.Size);

1
src/Avalonia.Controls/GridSplitter.cs

@ -341,6 +341,7 @@ namespace Avalonia.Controls
_resizeData.Adorner = new PreviewAdorner(builtPreviewContent);
AdornerLayer.SetAdornedElement(_resizeData.Adorner, this);
AdornerLayer.SetIsClipEnabled(_resizeData.Adorner, false);
adornerLayer.Children.Add(_resizeData.Adorner);

1
src/Avalonia.Controls/Primitives/AdornerLayer.cs

@ -174,7 +174,6 @@ namespace Avalonia.Controls.Primitives
}
SetAdornedElement(adorner, visual);
SetIsClipEnabled(adorner, false);
((ISetLogicalParent) adorner).SetParent(visual);
layer.Children.Add(adorner);

Loading…
Cancel
Save