Browse Source

WIP

pull/1350/head
Steven Kirk 9 years ago
parent
commit
375e0f0a64
  1. 16
      src/Avalonia.Controls/Primitives/AdornerLayer.cs
  2. 2
      src/Avalonia.Themes.Default/FocusAdorner.xaml
  3. 9
      src/Avalonia.Visuals/Rendering/DeferredRenderer.cs
  4. 6
      src/Avalonia.Visuals/VisualTree/TransformedBounds.cs

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

@ -55,12 +55,13 @@ namespace Avalonia.Controls.Primitives
foreach (var child in Children)
{
var info = (AdornedElementInfo)child.GetValue(s_adornedElementInfoProperty);
var info = child.GetValue(s_adornedElementInfoProperty);
if (info != null && info.Bounds.HasValue)
{
child.RenderTransform = new MatrixTransform(info.Bounds.Value.Transform);
child.RenderTransformOrigin = new RelativePoint(new Point(0,0), RelativeUnit.Absolute);
UpdateClip(child, info.Bounds.Value);
child.Arrange(info.Bounds.Value.Bounds);
}
else
@ -80,6 +81,19 @@ namespace Avalonia.Controls.Primitives
layer?.UpdateAdornedElement(adorner, adorned);
}
private void UpdateClip(IControl control, TransformedBounds bounds)
{
var clip = control.Clip as RectangleGeometry;
if (clip == null)
{
clip = new RectangleGeometry { Transform = new MatrixTransform() };
control.Clip = clip;
}
clip.Rect = bounds.Clip.TransformToAABB(-bounds.Transform);
}
private void ChildrenCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
switch (e.Action)

2
src/Avalonia.Themes.Default/FocusAdorner.xaml

@ -1,7 +1,7 @@
<Style xmlns="https://github.com/avaloniaui" Selector=":is(Control)">
<Setter Property="FocusAdorner">
<FocusAdornerTemplate>
<Rectangle Stroke="Black"
<Rectangle Stroke="Black" Name="abcd"
StrokeThickness="1"
StrokeDashArray="1,2"/>
</FocusAdornerTemplate>

9
src/Avalonia.Visuals/Rendering/DeferredRenderer.cs

@ -243,6 +243,15 @@ namespace Avalonia.Rendering
{
clipBounds = node.ClipBounds.Intersect(clipBounds);
var np = node.Visual.GetType().GetProperty("Name");
var name = (string)np.GetValue(node.Visual);
if (name == "abcd")
{
var clip = (IStreamGeometryImpl)node.GeometryClip;
System.Diagnostics.Debug.WriteLine(clip?.GetRenderBounds(new Pen(Brushes.Black, 1)).ToString() ?? "(null)");
}
if (!clipBounds.IsEmpty && node.Opacity > 0)
{
var isLayerRoot = node.Visual == layer;

6
src/Avalonia.Visuals/VisualTree/TransformedBounds.cs

@ -24,17 +24,17 @@ namespace Avalonia.VisualTree
}
/// <summary>
/// Gets the control's bounds.
/// Gets the control's bounds in its local coordinate space.
/// </summary>
public Rect Bounds { get; }
/// <summary>
/// Gets the control's clip rectangle.
/// Gets the control's clip rectangle in global coordinate space.
/// </summary>
public Rect Clip { get; }
/// <summary>
/// Gets the control's transform.
/// Gets the transform from local to global coordinate space.
/// </summary>
public Matrix Transform { get; }

Loading…
Cancel
Save