Skip to content

Commit 1930257

Browse files
committed
feat: Align Panel DPs
1 parent 2b2429e commit 1930257

File tree

16 files changed

+429
-178
lines changed

16 files changed

+429
-178
lines changed

src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Controls/StarStackPanel.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,6 @@ private static void HandleSizePropertyChanged(DependencyObject d, DependencyProp
634634
}
635635
#endregion
636636

637-
#if !__ANDROID__ && !__IOS__ && !UNO_REFERENCE_API //In Uno, Padding is (incorrectly) defined on Panel
638637
#region Padding DependencyProperty
639638

640639
public Thickness Padding
@@ -648,7 +647,6 @@ public Thickness Padding
648647
DependencyProperty.Register("Padding", typeof(Thickness), typeof(StarStackPanel), new PropertyMetadata(default(Thickness), InvalidateLayoutOnChanged));
649648

650649
#endregion
651-
#endif
652650

653651
#region struct Record
654652
private struct Record

src/Uno.UI/Microsoft/UI/Xaml/Controls/LayoutPanel/LayoutPanel.Properties.cs

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,71 @@
1-
using Windows.UI.Xaml;
1+
using Uno.UI.Xaml;
2+
using Windows.UI.Xaml;
3+
using Windows.UI.Xaml.Media;
24

35
namespace Microsoft.UI.Xaml.Controls
46
{
57
partial class LayoutPanel
68
{
9+
#region BorderBrush DependencyProperty
10+
11+
public Brush BorderBrush
12+
{
13+
get => GetBorderBrushValue();
14+
set => SetBorderBrushValue(value);
15+
}
16+
17+
private static Brush GetBorderBrushDefaultValue() => SolidColorBrushHelper.Transparent;
18+
19+
[GeneratedDependencyProperty(ChangedCallback = false, Options = FrameworkPropertyMetadataOptions.ValueInheritsDataContext)]
20+
public static DependencyProperty BorderBrushProperty { get; } = CreateBorderBrushProperty();
21+
22+
#endregion
23+
24+
#region BorderThickness DependencyProperty
25+
26+
public Thickness BorderThickness
27+
{
28+
get => GetBorderThicknessValue();
29+
set => SetBorderThicknessValue(value);
30+
}
31+
32+
private static Thickness GetBorderThicknessDefaultValue() => Thickness.Empty;
33+
34+
[GeneratedDependencyProperty(ChangedCallback = false)]
35+
public static DependencyProperty BorderThicknessProperty { get; } = CreateBorderThicknessProperty();
36+
37+
#endregion
38+
39+
#region Padding DependencyProperty
40+
41+
public Thickness Padding
42+
{
43+
get => GetPaddingValue();
44+
set => SetPaddingValue(value);
45+
}
46+
47+
private static Thickness GetPaddingDefaultValue() => Thickness.Empty;
48+
49+
[GeneratedDependencyProperty(ChangedCallback = false)]
50+
public static DependencyProperty PaddingProperty { get; } = CreatePaddingProperty();
51+
52+
#endregion
53+
54+
#region CornerRadius DependencyProperty
55+
56+
public CornerRadius CornerRadius
57+
{
58+
get => GetCornerRadiusValue();
59+
set => SetCornerRadiusValue(value);
60+
}
61+
62+
private static CornerRadius GetCornerRadiusDefaultValue() => CornerRadius.None;
63+
64+
[GeneratedDependencyProperty(ChangedCallback = false)]
65+
public static DependencyProperty CornerRadiusProperty { get; } = CreateCornerRadiusProperty();
66+
67+
#endregion
68+
769
public static DependencyProperty LayoutProperty { get; } = DependencyProperty.Register(
870
"Layout", typeof(Layout), typeof(LayoutPanel), new FrameworkPropertyMetadata(default(Layout)));
971

src/Uno.UI/Microsoft/UI/Xaml/Controls/LayoutPanel/LayoutPanel.cs

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Windows.Foundation;
77
using Windows.UI.Xaml;
88
using Windows.UI.Xaml.Controls.Primitives;
9+
using Windows.UI.Xaml.Media;
910

1011
namespace Microsoft.UI.Xaml.Controls
1112
{
@@ -27,31 +28,34 @@ void OnPropertyChanged(DependencyPropertyChangedEventArgs args)
2728
{
2829
OnLayoutChanged(args.OldValue as Layout, args.NewValue as Layout);
2930
}
30-
#if USE_INTERNAL_SDK
31-
else if (dependencyProperty == s_borderBrushProperty)
32-
{
33-
if (var panelProtected = try_as<Microsoft.UI.Xaml.Controls.IPanelProtectedFeature_WUXCPreviewTypes>())
34-
{
35-
panelProtected.BorderBrushProtected(Brush>(args.NewValue()));
36-
}
37-
}
38-
else if (dependencyProperty == s_borderThicknessProperty)
39-
{
40-
if (var panelProtected = try_as<Microsoft.UI.Xaml.Controls.IPanelProtectedFeature_WUXCPreviewTypes>())
41-
{
42-
panelProtected.BorderThicknessProtected((Thickness)(args.NewValue()));
43-
}
44-
}
45-
else if (dependencyProperty == s_cornerRadiusProperty)
46-
{
47-
if (var panelProtected = try_as<Microsoft.UI.Xaml.Controls.IPanelProtectedFeature_WUXCPreviewTypes>())
48-
{
49-
panelProtected.CornerRadiusProtected((CornerRadius)(args.NewValue()));
50-
}
51-
}
52-
#endif
31+
else if (dependencyProperty == BorderBrushProperty)
32+
{
33+
var newValue = (Brush)args.NewValue;
34+
35+
BorderBrushInternal = newValue;
36+
OnBorderBrushChanged((Brush)args.OldValue, newValue);
37+
}
38+
else if (dependencyProperty == BorderThicknessProperty)
39+
{
40+
var newValue = (Thickness)args.NewValue;
41+
42+
BorderThicknessInternal = newValue;
43+
OnBorderThicknessChanged((Thickness)args.OldValue, newValue);
44+
}
45+
else if (dependencyProperty == CornerRadiusProperty)
46+
{
47+
var newValue = (CornerRadius)args.NewValue;
48+
49+
CornerRadiusInternal = newValue;
50+
OnCornerRadiusChanged((CornerRadius)args.OldValue, newValue);
51+
}
5352
else if (dependencyProperty == PaddingProperty)
5453
{
54+
var newValue = (Thickness)args.NewValue;
55+
56+
PaddingInternal = newValue;
57+
OnPaddingChanged((Thickness)args.OldValue, newValue);
58+
5559
InvalidateMeasure();
5660
}
5761
}

src/Uno.UI/Mock/Panel.net.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ public override IEnumerable<View> GetChildren()
3232
=> Children.OfType<View>().ToArray<View>();
3333

3434
bool ICustomClippingElement.AllowClippingToLayoutSlot => false;
35-
bool ICustomClippingElement.ForceClippingToLayoutSlot => CornerRadius != CornerRadius.None;
35+
bool ICustomClippingElement.ForceClippingToLayoutSlot => CornerRadiusInternal != CornerRadius.None;
3636
}
3737
}

src/Uno.UI/Mock/Panel.netstdref.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ protected virtual void OnChildrenChanged()
2929
}
3030

3131
bool ICustomClippingElement.AllowClippingToLayoutSlot => false;
32-
bool ICustomClippingElement.ForceClippingToLayoutSlot => CornerRadius != CornerRadius.None;
32+
bool ICustomClippingElement.ForceClippingToLayoutSlot => CornerRadiusInternal != CornerRadius.None;
3333
}
3434
}

src/Uno.UI/UI/Xaml/Controls/Grid/Grid.Properties.cs

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Uno.UI;
77
using Uno.UI.Extensions;
88
using Uno.UI.Xaml;
9+
using Windows.UI.Xaml.Media;
910

1011
#if XAMARIN_ANDROID
1112
using View = Android.Views.View;
@@ -45,6 +46,90 @@ private void OnBackgroundSizingChanged(DependencyPropertyChangedEventArgs e)
4546
}
4647
#endregion
4748

49+
#region BorderBrush DependencyProperty
50+
51+
public Brush BorderBrush
52+
{
53+
get => GetBorderBrushValue();
54+
set => SetBorderBrushValue(value);
55+
}
56+
57+
private static Brush GetBorderBrushDefaultValue() => SolidColorBrushHelper.Transparent;
58+
59+
[GeneratedDependencyProperty(ChangedCallbackName = nameof(OnBorderBrushPropertyChanged), Options = FrameworkPropertyMetadataOptions.ValueInheritsDataContext)]
60+
public static DependencyProperty BorderBrushProperty { get; } = CreateBorderBrushProperty();
61+
62+
private void OnBorderBrushPropertyChanged(Brush oldValue, Brush newValue)
63+
{
64+
BorderBrushInternal = newValue;
65+
OnBorderBrushChanged(oldValue, newValue);
66+
}
67+
68+
#endregion
69+
70+
#region BorderThickness DependencyProperty
71+
72+
public Thickness BorderThickness
73+
{
74+
get => GetBorderThicknessValue();
75+
set => SetBorderThicknessValue(value);
76+
}
77+
78+
private static Thickness GetBorderThicknessDefaultValue() => Thickness.Empty;
79+
80+
[GeneratedDependencyProperty(ChangedCallbackName = nameof(OnBorderThicknessPropertyChanged))]
81+
public static DependencyProperty BorderThicknessProperty { get; } = CreateBorderThicknessProperty();
82+
83+
private void OnBorderThicknessPropertyChanged(Thickness oldValue, Thickness newValue)
84+
{
85+
BorderThicknessInternal = newValue;
86+
OnBorderThicknessChanged(oldValue, newValue);
87+
}
88+
89+
#endregion
90+
91+
#region Padding DependencyProperty
92+
93+
public Thickness Padding
94+
{
95+
get => GetPaddingValue();
96+
set => SetPaddingValue(value);
97+
}
98+
99+
private static Thickness GetPaddingDefaultValue() => Thickness.Empty;
100+
101+
[GeneratedDependencyProperty(ChangedCallbackName = nameof(OnPaddingPropertyChanged))]
102+
public static DependencyProperty PaddingProperty { get; } = CreatePaddingProperty();
103+
104+
private void OnPaddingPropertyChanged(Thickness oldValue, Thickness newValue)
105+
{
106+
PaddingInternal = newValue;
107+
OnPaddingChanged(oldValue, newValue);
108+
}
109+
110+
#endregion
111+
112+
#region CornerRadius DependencyProperty
113+
114+
public CornerRadius CornerRadius
115+
{
116+
get => GetCornerRadiusValue();
117+
set => SetCornerRadiusValue(value);
118+
}
119+
120+
private static CornerRadius GetCornerRadiusDefaultValue() => CornerRadius.None;
121+
122+
[GeneratedDependencyProperty(ChangedCallbackName = nameof(OnCornerRadiusPropertyChanged))]
123+
public static DependencyProperty CornerRadiusProperty { get; } = CreateCornerRadiusProperty();
124+
125+
private void OnCornerRadiusPropertyChanged(CornerRadius oldValue, CornerRadius newValue)
126+
{
127+
CornerRadiusInternal = newValue;
128+
OnCornerRadiusChanged(oldValue, newValue);
129+
}
130+
131+
#endregion
132+
48133
#region Row Property
49134
[GeneratedDependencyProperty(DefaultValue = 0, AttachedBackingFieldOwner = typeof(UIElement), Attached = true, ChangedCallbackName = nameof(OnGenericPropertyChanged))]
50135
public static DependencyProperty RowProperty { get ; } = CreateRowProperty();

src/Uno.UI/UI/Xaml/Controls/Panel/Panel.Android.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ private void UpdateBorder(bool willUpdateMeasures)
5757
this,
5858
Background,
5959
InternalBackgroundSizing,
60-
BorderThickness,
61-
BorderBrush,
62-
CornerRadius,
63-
Padding,
60+
BorderThicknessInternal,
61+
BorderBrushInternal,
62+
CornerRadiusInternal,
63+
PaddingInternal,
6464
willUpdateMeasures
6565
);
6666
}
@@ -75,7 +75,7 @@ protected override void OnLayoutCore(bool changed, int left, int top, int right,
7575

7676
protected override void OnDraw(Android.Graphics.Canvas canvas)
7777
{
78-
AdjustCornerRadius(canvas, CornerRadius);
78+
AdjustCornerRadius(canvas, CornerRadiusInternal);
7979
}
8080

8181
protected virtual void OnChildrenChanged()
@@ -147,6 +147,6 @@ public IEnumerator GetEnumerator()
147147
}
148148

149149
bool ICustomClippingElement.AllowClippingToLayoutSlot => true;
150-
bool ICustomClippingElement.ForceClippingToLayoutSlot => CornerRadius != CornerRadius.None;
150+
bool ICustomClippingElement.ForceClippingToLayoutSlot => CornerRadiusInternal != CornerRadius.None;
151151
}
152152
}

0 commit comments

Comments
 (0)