Browse Source

Added WantsLayer property

layers-wtf-repro
Nikita Tsukanov 7 years ago
parent
commit
0909407582
  1. 2
      src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs
  2. 20
      src/Avalonia.Visuals/Visual.cs
  3. 5
      src/Avalonia.Visuals/VisualTree/IVisual.cs

2
src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs

@ -367,6 +367,8 @@ namespace Avalonia.Rendering.SceneGraph
private static bool ShouldStartLayer(IVisual visual)
{
if (visual.WantsLayer)
return true;
var o = visual as IAvaloniaObject;
return visual.VisualChildren.Count > 0 &&
o != null &&

20
src/Avalonia.Visuals/Visual.cs

@ -90,10 +90,18 @@ namespace Avalonia
public static readonly StyledProperty<int> ZIndexProperty =
AvaloniaProperty.Register<Visual, int>(nameof(ZIndex));
/// <summary>
/// Defines the <see cref="WantsLayer"/> property.
/// </summary>
public static readonly DirectProperty<Visual, bool> WantsLayerProperty =
AvaloniaProperty.RegisterDirect<Visual, bool>("WantsLayer", o => o._wantsLayer,
(o, v) => o._wantsLayer = v);
private Rect _bounds;
private TransformedBounds? _transformedBounds;
private IRenderRoot _visualRoot;
private IVisual _visualParent;
private bool _wantsLayer;
/// <summary>
/// Initializes static members of the <see cref="Visual"/> class.
@ -105,7 +113,8 @@ namespace Avalonia
ClipProperty,
ClipToBoundsProperty,
IsVisibleProperty,
OpacityProperty);
OpacityProperty,
WantsLayerProperty);
RenderTransformProperty.Changed.Subscribe(RenderTransformChanged);
}
@ -239,6 +248,15 @@ namespace Avalonia
private set;
}
/// <summary>
/// Allows to explicitly force a rendering layer for a particular visual. Use with caution.
/// </summary>
public bool WantsLayer
{
get => GetValue(WantsLayerProperty);
set => SetValue(WantsLayerProperty, value);
}
/// <summary>
/// Gets the root of the visual tree, if the control is attached to a visual tree.
/// </summary>

5
src/Avalonia.Visuals/VisualTree/IVisual.cs

@ -127,5 +127,10 @@ namespace Avalonia.VisualTree
/// common ancestor.
/// </returns>
Matrix? TransformToVisual(IVisual visual);
/// <summary>
/// Allows to explicitly force a rendering layer for a particular visual. Use with caution.
/// </summary>
bool WantsLayer { get; }
}
}

Loading…
Cancel
Save