Skip to content

Commit 3a36f78

Browse files
committed
move border container implementation up to decorator
1 parent 5b3da4c commit 3a36f78

File tree

2 files changed

+46
-34
lines changed

2 files changed

+46
-34
lines changed

src/Avalonia.Controls/Border.cs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Avalonia.Controls
1616
/// A control which decorates a child with a border and background.
1717
/// </summary>
1818
#pragma warning disable CS0618 // Type or member is obsolete
19-
public partial class Border : Decorator, IVisualWithRoundRectClip, IContainer
19+
public partial class Border : Decorator, IVisualWithRoundRectClip
2020
#pragma warning restore CS0618 // Type or member is obsolete
2121
{
2222
/// <summary>
@@ -57,25 +57,10 @@ public partial class Border : Decorator, IVisualWithRoundRectClip, IContainer
5757
public static readonly StyledProperty<BoxShadows> BoxShadowProperty =
5858
AvaloniaProperty.Register<Border, BoxShadows>(nameof(BoxShadow));
5959

60-
/// <summary>
61-
/// Defines the <see cref="ContainerType"/> property
62-
/// </summary>
63-
public static readonly StyledProperty<ContainerType> ContainerTypeProperty =
64-
AvaloniaProperty.Register<Border, ContainerType>(nameof(ContainerType),
65-
defaultValue: ContainerType.Normal);
66-
67-
/// <summary>
68-
/// Defines the <see cref="ContainerName"/> property
69-
/// </summary>
70-
public static readonly StyledProperty<string?> ContainerNameProperty =
71-
AvaloniaProperty.Register<Border, string?>(nameof(ContainerName),
72-
defaultValue: null);
73-
7460
private readonly BorderRenderHelper _borderRenderHelper = new BorderRenderHelper();
7561
private Thickness? _layoutThickness;
7662
private double _scale;
7763
private CompositionBorderVisual? _borderVisual;
78-
private VisualQueryProvider? _queryProvider;
7964

8065
/// <summary>
8166
/// Initializes static members of the <see cref="Border"/> class.
@@ -162,23 +147,6 @@ public BoxShadows BoxShadow
162147
set => SetValue(BoxShadowProperty, value);
163148
}
164149

165-
/// <inheritdoc/>
166-
public ContainerType ContainerType
167-
{
168-
get => GetValue(ContainerTypeProperty);
169-
set => SetValue(ContainerTypeProperty, value);
170-
}
171-
172-
/// <inheritdoc/>
173-
public string? ContainerName
174-
{
175-
get => GetValue(ContainerNameProperty);
176-
set => SetValue(ContainerNameProperty, value);
177-
}
178-
179-
/// <inheritdoc/>
180-
public VisualQueryProvider QueryProvider => _queryProvider ??= new VisualQueryProvider(this);
181-
182150
private Thickness LayoutThickness
183151
{
184152
get

src/Avalonia.Controls/Decorator.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1+
using System;
2+
using Avalonia.Collections;
3+
using Avalonia.Controls;
4+
using Avalonia.Controls.Shapes;
5+
using Avalonia.Controls.Utils;
16
using Avalonia.Layout;
7+
using Avalonia.Media;
28
using Avalonia.Metadata;
9+
using Avalonia.Platform;
10+
using Avalonia.Rendering.Composition;
11+
using Avalonia.Styling;
12+
using Avalonia.Utilities;
13+
using Avalonia.VisualTree;
314

415
namespace Avalonia.Controls
516
{
617
/// <summary>
718
/// Base class for controls which decorate a single child control.
819
/// </summary>
9-
public class Decorator : Control
20+
public class Decorator : Control, IContainer
1021
{
1122
/// <summary>
1223
/// Defines the <see cref="Child"/> property.
@@ -20,6 +31,22 @@ public class Decorator : Control
2031
public static readonly StyledProperty<Thickness> PaddingProperty =
2132
AvaloniaProperty.Register<Decorator, Thickness>(nameof(Padding));
2233

34+
/// <summary>
35+
/// Defines the <see cref="ContainerName"/> property
36+
/// </summary>
37+
public static readonly StyledProperty<string?> ContainerNameProperty =
38+
AvaloniaProperty.Register<Decorator, string?>(nameof(ContainerName),
39+
defaultValue: null);
40+
41+
/// <summary>
42+
/// Defines the <see cref="ContainerType"/> property
43+
/// </summary>
44+
public static readonly StyledProperty<ContainerType> ContainerTypeProperty =
45+
AvaloniaProperty.Register<Decorator, ContainerType>(nameof(ContainerType),
46+
defaultValue: ContainerType.Normal);
47+
48+
private VisualQueryProvider? _queryProvider;
49+
2350
/// <summary>
2451
/// Initializes static members of the <see cref="Decorator"/> class.
2552
/// </summary>
@@ -48,6 +75,23 @@ public Thickness Padding
4875
set => SetValue(PaddingProperty, value);
4976
}
5077

78+
/// <inheritdoc/>
79+
public string? ContainerName
80+
{
81+
get => GetValue(ContainerNameProperty);
82+
set => SetValue(ContainerNameProperty, value);
83+
}
84+
85+
/// <inheritdoc/>
86+
public ContainerType ContainerType
87+
{
88+
get => GetValue(ContainerTypeProperty);
89+
set => SetValue(ContainerTypeProperty, value);
90+
}
91+
92+
/// <inheritdoc/>
93+
public VisualQueryProvider QueryProvider => _queryProvider ??= new VisualQueryProvider(this);
94+
5195
/// <inheritdoc/>
5296
protected override Size MeasureOverride(Size availableSize)
5397
{

0 commit comments

Comments
 (0)