From 2eb04c271909c2a54af23fa77ad99f96e7aeec74 Mon Sep 17 00:00:00 2001 From: robloo Date: Tue, 14 Mar 2023 12:08:20 -0400 Subject: [PATCH 1/9] Rename Popup.PlacementMode to Popup.Placement --- .../IntegrationTestApp/MainWindow.axaml.cs | 2 +- src/Avalonia.Controls/ContextMenu.cs | 4 +-- .../DateTimePickers/DatePicker.cs | 2 +- .../DateTimePickers/TimePicker.cs | 2 +- .../Flyouts/PopupFlyoutBase.cs | 14 ++++------ src/Avalonia.Controls/Primitives/Popup.cs | 28 +++++++++---------- .../SplitButton/SplitButton.cs | 2 +- .../Controls/DatePicker.xaml | 2 +- .../Controls/MenuItem.xaml | 2 +- .../Controls/TimePicker.xaml | 2 +- .../Controls/DatePicker.xaml | 2 +- .../Controls/MenuItem.xaml | 2 +- .../Controls/TimePicker.xaml | 2 +- .../Primitives/PopupRootTests.cs | 2 +- .../Primitives/PopupTests.cs | 20 ++++++------- 15 files changed, 43 insertions(+), 45 deletions(-) diff --git a/samples/IntegrationTestApp/MainWindow.axaml.cs b/samples/IntegrationTestApp/MainWindow.axaml.cs index 19eb1d64b0..b0b06303a4 100644 --- a/samples/IntegrationTestApp/MainWindow.axaml.cs +++ b/samples/IntegrationTestApp/MainWindow.axaml.cs @@ -158,7 +158,7 @@ namespace IntegrationTestApp var popup = new Popup { WindowManagerAddShadowHint = false, - PlacementMode = PlacementMode.AnchorAndGravity, + Placement = PlacementMode.AnchorAndGravity, PlacementAnchor = PopupAnchor.Top, PlacementGravity = PopupGravity.Bottom, Width= 200, diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index 0e7d31967c..d1af361867 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -58,7 +58,7 @@ namespace Avalonia.Controls /// Defines the property. /// public static readonly StyledProperty PlacementModeProperty = - Popup.PlacementModeProperty.AddOwner(); + Popup.PlacementProperty.AddOwner(); /// /// Defines the property. @@ -343,7 +343,7 @@ namespace Avalonia.Controls ((ISetLogicalParent)_popup).SetParent(control); } - _popup.PlacementMode = !requestedByPointer && PlacementMode == PlacementMode.Pointer + _popup.Placement = !requestedByPointer && PlacementMode == PlacementMode.Pointer ? PlacementMode.Bottom : PlacementMode; diff --git a/src/Avalonia.Controls/DateTimePickers/DatePicker.cs b/src/Avalonia.Controls/DateTimePickers/DatePicker.cs index 118183102a..f3faef26dd 100644 --- a/src/Avalonia.Controls/DateTimePickers/DatePicker.cs +++ b/src/Avalonia.Controls/DateTimePickers/DatePicker.cs @@ -389,7 +389,7 @@ namespace Avalonia.Controls _presenter.Date = SelectedDate ?? DateTimeOffset.Now; - _popup.PlacementMode = PlacementMode.AnchorAndGravity; + _popup.Placement = PlacementMode.AnchorAndGravity; _popup.PlacementAnchor = Primitives.PopupPositioning.PopupAnchor.Bottom; _popup.PlacementGravity = Primitives.PopupPositioning.PopupGravity.Bottom; _popup.PlacementConstraintAdjustment = Primitives.PopupPositioning.PopupPositionerConstraintAdjustment.SlideY; diff --git a/src/Avalonia.Controls/DateTimePickers/TimePicker.cs b/src/Avalonia.Controls/DateTimePickers/TimePicker.cs index 2f49a44b8c..0046e1de52 100644 --- a/src/Avalonia.Controls/DateTimePickers/TimePicker.cs +++ b/src/Avalonia.Controls/DateTimePickers/TimePicker.cs @@ -255,7 +255,7 @@ namespace Avalonia.Controls _presenter.Time = SelectedTime ?? DateTime.Now.TimeOfDay; - _popup.PlacementMode = PlacementMode.AnchorAndGravity; + _popup.Placement = PlacementMode.AnchorAndGravity; _popup.PlacementAnchor = Primitives.PopupPositioning.PopupAnchor.Bottom; _popup.PlacementGravity = Primitives.PopupPositioning.PopupGravity.Bottom; _popup.PlacementConstraintAdjustment = Primitives.PopupPositioning.PopupPositionerConstraintAdjustment.SlideY; diff --git a/src/Avalonia.Controls/Flyouts/PopupFlyoutBase.cs b/src/Avalonia.Controls/Flyouts/PopupFlyoutBase.cs index a3d05a34b7..7b78bacd5f 100644 --- a/src/Avalonia.Controls/Flyouts/PopupFlyoutBase.cs +++ b/src/Avalonia.Controls/Flyouts/PopupFlyoutBase.cs @@ -14,9 +14,9 @@ namespace Avalonia.Controls.Primitives { public abstract class PopupFlyoutBase : FlyoutBase, IPopupHostProvider { - /// + /// public static readonly StyledProperty PlacementProperty = - Popup.PlacementModeProperty.AddOwner(); + Popup.PlacementProperty.AddOwner(); /// public static readonly StyledProperty HorizontalOffsetProperty = @@ -64,15 +64,13 @@ namespace Avalonia.Controls.Primitives protected Popup Popup => _popupLazy.Value; - /// - /// Gets or sets the desired placement. - /// + /// public PlacementMode Placement { get => GetValue(PlacementProperty); set => SetValue(PlacementProperty, value); } - + /// public PopupGravity PlacementGravity { @@ -423,11 +421,11 @@ namespace Avalonia.Controls.Primitives Popup.PlacementGravity = PlacementGravity; if (showAtPointer) { - Popup.PlacementMode = PlacementMode.Pointer; + Popup.Placement = PlacementMode.Pointer; } else { - Popup.PlacementMode = Placement; + Popup.Placement = Placement; Popup.PlacementConstraintAdjustment = PopupPositioning.PopupPositionerConstraintAdjustment.SlideX | PopupPositioning.PopupPositionerConstraintAdjustment.SlideY; diff --git a/src/Avalonia.Controls/Primitives/Popup.cs b/src/Avalonia.Controls/Primitives/Popup.cs index 0c6c434713..acfd37244e 100644 --- a/src/Avalonia.Controls/Primitives/Popup.cs +++ b/src/Avalonia.Controls/Primitives/Popup.cs @@ -66,10 +66,10 @@ namespace Avalonia.Controls.Primitives AvaloniaProperty.Register(nameof(PlacementGravity)); /// - /// Defines the property. + /// Defines the property. /// - public static readonly StyledProperty PlacementModeProperty = - AvaloniaProperty.Register(nameof(PlacementMode), defaultValue: PlacementMode.Bottom); + public static readonly StyledProperty PlacementProperty = + AvaloniaProperty.Register(nameof(Placement), defaultValue: PlacementMode.Bottom); /// /// Defines the property. @@ -205,7 +205,7 @@ namespace Avalonia.Controls.Primitives } /// - /// Gets or sets the anchor point on the when + /// Gets or sets the anchor point on the when /// is . /// public PopupAnchor PlacementAnchor @@ -226,7 +226,7 @@ namespace Avalonia.Controls.Primitives /// /// Gets or sets a value which defines in what direction the popup should open - /// when is . + /// when is . /// public PopupGravity PlacementGravity { @@ -235,17 +235,17 @@ namespace Avalonia.Controls.Primitives } /// - /// Gets or sets the placement mode of the popup in relation to the . + /// Gets or sets the desired placement of the popup in relation to the . /// - public PlacementMode PlacementMode + public PlacementMode Placement { - get { return GetValue(PlacementModeProperty); } - set { SetValue(PlacementModeProperty, value); } + get { return GetValue(PlacementProperty); } + set { SetValue(PlacementProperty, value); } } /// /// Gets or sets the the anchor rectangle within the parent that the popup will be placed - /// relative to when is . + /// relative to when is . /// /// /// The placement rect defines a rectangle relative to around @@ -404,7 +404,7 @@ namespace Avalonia.Controls.Primitives (x, handler) => x.LostFocus -= handler).DisposeWith(handlerCleanup); // Recalculate popup position on parent moved/resized, but not if placement was on pointer - if (PlacementMode != PlacementMode.Pointer) + if (Placement != PlacementMode.Pointer) { SubscribeToEventHandler>(window.PlatformImpl, WindowPositionChanged, (x, handler) => x.PositionChanged += handler, @@ -534,7 +534,7 @@ namespace Avalonia.Controls.Primitives UpdateHostSizing(_openState.PopupHost, _openState.TopLevel, _openState.PlacementTarget); } else if (change.Property == PlacementTargetProperty || - change.Property == PlacementModeProperty || + change.Property == PlacementProperty || change.Property == HorizontalOffsetProperty || change.Property == VerticalOffsetProperty || change.Property == PlacementAnchorProperty || @@ -567,7 +567,7 @@ namespace Avalonia.Controls.Primitives { popupHost.ConfigurePosition( placementTarget, - PlacementMode, + Placement, new Point(HorizontalOffset, VerticalOffset), PlacementAnchor, PlacementGravity, @@ -615,7 +615,7 @@ namespace Avalonia.Controls.Primitives return; _openState.PopupHost.ConfigurePosition( placementTarget, - PlacementMode, + Placement, new Point(HorizontalOffset, VerticalOffset), PlacementAnchor, PlacementGravity, diff --git a/src/Avalonia.Controls/SplitButton/SplitButton.cs b/src/Avalonia.Controls/SplitButton/SplitButton.cs index e790578675..7f10c632c5 100644 --- a/src/Avalonia.Controls/SplitButton/SplitButton.cs +++ b/src/Avalonia.Controls/SplitButton/SplitButton.cs @@ -172,7 +172,7 @@ namespace Avalonia.Controls flyout.Opened += Flyout_Opened; flyout.Closed += Flyout_Closed; - _flyoutPropertyChangedDisposable = flyout.GetPropertyChangedObservable(Popup.PlacementModeProperty).Subscribe(Flyout_PlacementPropertyChanged); + _flyoutPropertyChangedDisposable = flyout.GetPropertyChangedObservable(Popup.PlacementProperty).Subscribe(Flyout_PlacementPropertyChanged); } } diff --git a/src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml b/src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml index 28ec553660..e71e733eff 100644 --- a/src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml @@ -127,7 +127,7 @@ + Placement="Bottom"> diff --git a/src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml b/src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml index 72a7797bc3..5a10c62860 100644 --- a/src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml @@ -118,7 +118,7 @@ diff --git a/src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml b/src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml index 71ff0eaebc..39f7b0b224 100644 --- a/src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml @@ -151,7 +151,7 @@ WindowManagerAddShadowHint="False" IsLightDismissEnabled="True" PlacementTarget="{TemplateBinding}" - PlacementMode="Bottom"> + Placement="Bottom"> diff --git a/src/Avalonia.Themes.Simple/Controls/DatePicker.xaml b/src/Avalonia.Themes.Simple/Controls/DatePicker.xaml index 5c57240aea..6cf352518a 100644 --- a/src/Avalonia.Themes.Simple/Controls/DatePicker.xaml +++ b/src/Avalonia.Themes.Simple/Controls/DatePicker.xaml @@ -142,7 +142,7 @@ diff --git a/src/Avalonia.Themes.Simple/Controls/MenuItem.xaml b/src/Avalonia.Themes.Simple/Controls/MenuItem.xaml index 6056938938..7ec666eaf9 100644 --- a/src/Avalonia.Themes.Simple/Controls/MenuItem.xaml +++ b/src/Avalonia.Themes.Simple/Controls/MenuItem.xaml @@ -65,7 +65,7 @@ IsLightDismissEnabled="False" IsOpen="{TemplateBinding IsSubMenuOpen, Mode=TwoWay}" - PlacementMode="Right"> + Placement="Right"> diff --git a/src/Avalonia.Themes.Simple/Controls/TimePicker.xaml b/src/Avalonia.Themes.Simple/Controls/TimePicker.xaml index 58066bb9a5..5acbc41a68 100644 --- a/src/Avalonia.Themes.Simple/Controls/TimePicker.xaml +++ b/src/Avalonia.Themes.Simple/Controls/TimePicker.xaml @@ -156,7 +156,7 @@ diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/PopupRootTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/PopupRootTests.cs index 788e6a48bb..fb88c98343 100644 --- a/tests/Avalonia.Controls.UnitTests/Primitives/PopupRootTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Primitives/PopupRootTests.cs @@ -67,7 +67,7 @@ namespace Avalonia.Controls.UnitTests.Primitives using (UnitTestApplication.Start(TestServices.StyledWindow)) { var window = new Window(); - var target = new Popup {PlacementMode = PlacementMode.Pointer}; + var target = new Popup {Placement = PlacementMode.Pointer}; var child = new Control(); window.Content = target; diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs index bc1225e0e8..c3d76954e4 100644 --- a/tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs @@ -207,7 +207,7 @@ namespace Avalonia.Controls.UnitTests.Primitives { using (CreateServices()) { - var target = new Popup() {PlacementMode = PlacementMode.Pointer}; + var target = new Popup() {Placement = PlacementMode.Pointer}; var root = PreparedWindow(target); target.Open(); @@ -226,7 +226,7 @@ namespace Avalonia.Controls.UnitTests.Primitives using (CreateServices()) { var window = PreparedWindow(); - var target = new Popup() {PlacementMode = PlacementMode.Pointer}; + var target = new Popup() {Placement = PlacementMode.Pointer}; window.Content = target; @@ -249,7 +249,7 @@ namespace Avalonia.Controls.UnitTests.Primitives using (CreateServices()) { var window = PreparedWindow(); - var target = new Popup() {PlacementMode = PlacementMode.Pointer}; + var target = new Popup() {Placement = PlacementMode.Pointer}; window.Content = target; window.ApplyTemplate(); @@ -274,7 +274,7 @@ namespace Avalonia.Controls.UnitTests.Primitives using (CreateServices()) { var window = PreparedWindow(); - var target = new Popup() { PlacementMode = PlacementMode.Pointer }; + var target = new Popup() { Placement = PlacementMode.Pointer }; window.Content = target; window.ApplyTemplate(); @@ -742,7 +742,7 @@ namespace Avalonia.Controls.UnitTests.Primitives { Width = 400, Height = 200, - PlacementMode = PlacementMode.Pointer + Placement = PlacementMode.Pointer }; var window = PreparedWindow(popup); window.Show(); @@ -791,7 +791,7 @@ namespace Avalonia.Controls.UnitTests.Primitives var popup = new Popup() { PlacementTarget = placementTarget, - PlacementMode = PlacementMode.Bottom, + Placement = PlacementMode.Bottom, Width = 10, Height = 10 }; @@ -852,7 +852,7 @@ namespace Avalonia.Controls.UnitTests.Primitives var popup = new Popup() { PlacementTarget = placementTarget, - PlacementMode = PlacementMode.Pointer, + Placement = PlacementMode.Pointer, Width = 10, Height = 10 }; @@ -907,7 +907,7 @@ namespace Avalonia.Controls.UnitTests.Primitives var popup = new Popup() { PlacementTarget = placementTarget, - PlacementMode = PlacementMode.Bottom, + Placement = PlacementMode.Bottom, Width = 10, Height = 10 }; @@ -967,7 +967,7 @@ namespace Avalonia.Controls.UnitTests.Primitives var popup = new Popup() { PlacementTarget = placementTarget, - PlacementMode = PlacementMode.Pointer, + Placement = PlacementMode.Pointer, Width = 10, Height = 10 }; @@ -1020,7 +1020,7 @@ namespace Avalonia.Controls.UnitTests.Primitives Width = 20, Height = 20, PlacementTarget = parentPopup, - PlacementMode = PlacementMode.AnchorAndGravity, + Placement = PlacementMode.AnchorAndGravity, PlacementAnchor = PopupAnchor.TopLeft, PlacementGravity = PopupGravity.BottomRight }; From cc7656eecb25204375e971b091fa21cea7da5348 Mon Sep 17 00:00:00 2001 From: robloo Date: Tue, 14 Mar 2023 12:25:36 -0400 Subject: [PATCH 2/9] Rename ContextMenu.PlacementMode to ContextMenu.Placement --- src/Avalonia.Controls/ContextMenu.cs | 24 +++++++++---------- .../ContextMenuTests.cs | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index d1af361867..5d964dd172 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -55,9 +55,9 @@ namespace Avalonia.Controls Popup.PlacementGravityProperty.AddOwner(); /// - /// Defines the property. + /// Defines the property. /// - public static readonly StyledProperty PlacementModeProperty = + public static readonly StyledProperty PlacementProperty = Popup.PlacementProperty.AddOwner(); /// @@ -108,7 +108,7 @@ namespace Avalonia.Controls static ContextMenu() { ItemsPanelProperty.OverrideDefaultValue(DefaultPanel); - PlacementModeProperty.OverrideDefaultValue(PlacementMode.Pointer); + PlacementProperty.OverrideDefaultValue(PlacementMode.Pointer); ContextMenuProperty.Changed.Subscribe(ContextMenuChanged); AutomationProperties.AccessibilityViewProperty.OverrideDefaultValue(AccessibilityView.Control); AutomationProperties.ControlTypeOverrideProperty.OverrideDefaultValue(AutomationControlType.Menu); @@ -133,7 +133,7 @@ namespace Avalonia.Controls } /// - /// Gets or sets the anchor point on the when + /// Gets or sets the anchor point on the when /// is . /// public PopupAnchor PlacementAnchor @@ -154,7 +154,7 @@ namespace Avalonia.Controls /// /// Gets or sets a value which defines in what direction the context menu should open - /// when is . + /// when is . /// public PopupGravity PlacementGravity { @@ -163,12 +163,12 @@ namespace Avalonia.Controls } /// - /// Gets or sets the placement mode of the context menu in relation to the. + /// Gets or sets the desired placement of the context menu in relation to the. /// - public PlacementMode PlacementMode + public PlacementMode Placement { - get { return GetValue(PlacementModeProperty); } - set { SetValue(PlacementModeProperty, value); } + get { return GetValue(PlacementProperty); } + set { SetValue(PlacementProperty, value); } } public bool WindowManagerAddShadowHint @@ -179,7 +179,7 @@ namespace Avalonia.Controls /// /// Gets or sets the the anchor rectangle within the parent that the context menu will be placed - /// relative to when is . + /// relative to when is . /// /// /// The placement rect defines a rectangle relative to around @@ -343,9 +343,9 @@ namespace Avalonia.Controls ((ISetLogicalParent)_popup).SetParent(control); } - _popup.Placement = !requestedByPointer && PlacementMode == PlacementMode.Pointer + _popup.Placement = !requestedByPointer && Placement == PlacementMode.Pointer ? PlacementMode.Bottom - : PlacementMode; + : Placement; //Position of the line below is really important. //All styles are being applied only when control has logical parent. diff --git a/tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs b/tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs index d99c90cb77..803cc793fd 100644 --- a/tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ContextMenuTests.cs @@ -303,7 +303,7 @@ namespace Avalonia.Controls.UnitTests window.Show(); var c = new ContextMenu(); - c.PlacementMode = PlacementMode.Bottom; + c.Placement = PlacementMode.Bottom; c.Open(button); var overlay = LightDismissOverlayLayer.GetLightDismissOverlayLayer(window); From a2a60fa0312256ca7875d9110b9de5f45942e8b7 Mon Sep 17 00:00:00 2001 From: robloo Date: Tue, 14 Mar 2023 12:33:26 -0400 Subject: [PATCH 3/9] Use newer convention for property get/set --- src/Avalonia.Controls/ContextMenu.cs | 36 +++++++++---------- src/Avalonia.Controls/Primitives/Popup.cs | 44 +++++++++++------------ 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index 5d964dd172..923982e723 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -119,8 +119,8 @@ namespace Avalonia.Controls /// public double HorizontalOffset { - get { return GetValue(HorizontalOffsetProperty); } - set { SetValue(HorizontalOffsetProperty, value); } + get => GetValue(HorizontalOffsetProperty); + set => SetValue(HorizontalOffsetProperty, value); } /// @@ -128,8 +128,8 @@ namespace Avalonia.Controls /// public double VerticalOffset { - get { return GetValue(VerticalOffsetProperty); } - set { SetValue(VerticalOffsetProperty, value); } + get => GetValue(VerticalOffsetProperty); + set => SetValue(VerticalOffsetProperty, value); } /// @@ -138,8 +138,8 @@ namespace Avalonia.Controls /// public PopupAnchor PlacementAnchor { - get { return GetValue(PlacementAnchorProperty); } - set { SetValue(PlacementAnchorProperty, value); } + get => GetValue(PlacementAnchorProperty); + set => SetValue(PlacementAnchorProperty, value); } /// @@ -148,8 +148,8 @@ namespace Avalonia.Controls /// public PopupPositionerConstraintAdjustment PlacementConstraintAdjustment { - get { return GetValue(PlacementConstraintAdjustmentProperty); } - set { SetValue(PlacementConstraintAdjustmentProperty, value); } + get => GetValue(PlacementConstraintAdjustmentProperty); + set => SetValue(PlacementConstraintAdjustmentProperty, value); } /// @@ -158,8 +158,8 @@ namespace Avalonia.Controls /// public PopupGravity PlacementGravity { - get { return GetValue(PlacementGravityProperty); } - set { SetValue(PlacementGravityProperty, value); } + get => GetValue(PlacementGravityProperty); + set => SetValue(PlacementGravityProperty, value); } /// @@ -167,14 +167,14 @@ namespace Avalonia.Controls /// public PlacementMode Placement { - get { return GetValue(PlacementProperty); } - set { SetValue(PlacementProperty, value); } + get => GetValue(PlacementProperty); + set => SetValue(PlacementProperty, value); } public bool WindowManagerAddShadowHint { - get { return GetValue(WindowManagerAddShadowHintProperty); } - set { SetValue(WindowManagerAddShadowHintProperty, value); } + get => GetValue(WindowManagerAddShadowHintProperty); + set => SetValue(WindowManagerAddShadowHintProperty, value); } /// @@ -190,8 +190,8 @@ namespace Avalonia.Controls /// public Rect? PlacementRect { - get { return GetValue(PlacementRectProperty); } - set { SetValue(PlacementRectProperty, value); } + get => GetValue(PlacementRectProperty); + set => SetValue(PlacementRectProperty, value); } /// @@ -199,8 +199,8 @@ namespace Avalonia.Controls /// public Control? PlacementTarget { - get { return GetValue(PlacementTargetProperty); } - set { SetValue(PlacementTargetProperty, value); } + get => GetValue(PlacementTargetProperty); + set => SetValue(PlacementTargetProperty, value); } /// diff --git a/src/Avalonia.Controls/Primitives/Popup.cs b/src/Avalonia.Controls/Primitives/Popup.cs index acfd37244e..76c7b19e68 100644 --- a/src/Avalonia.Controls/Primitives/Popup.cs +++ b/src/Avalonia.Controls/Primitives/Popup.cs @@ -146,8 +146,8 @@ namespace Avalonia.Controls.Primitives public bool WindowManagerAddShadowHint { - get { return GetValue(WindowManagerAddShadowHintProperty); } - set { SetValue(WindowManagerAddShadowHintProperty, value); } + get => GetValue(WindowManagerAddShadowHintProperty); + set => SetValue(WindowManagerAddShadowHintProperty, value); } /// @@ -156,8 +156,8 @@ namespace Avalonia.Controls.Primitives [Content] public Control? Child { - get { return GetValue(ChildProperty); } - set { SetValue(ChildProperty, value); } + get => GetValue(ChildProperty); + set => SetValue(ChildProperty, value); } /// @@ -210,8 +210,8 @@ namespace Avalonia.Controls.Primitives /// public PopupAnchor PlacementAnchor { - get { return GetValue(PlacementAnchorProperty); } - set { SetValue(PlacementAnchorProperty, value); } + get => GetValue(PlacementAnchorProperty); + set => SetValue(PlacementAnchorProperty, value); } /// @@ -220,8 +220,8 @@ namespace Avalonia.Controls.Primitives /// public PopupPositionerConstraintAdjustment PlacementConstraintAdjustment { - get { return GetValue(PlacementConstraintAdjustmentProperty); } - set { SetValue(PlacementConstraintAdjustmentProperty, value); } + get => GetValue(PlacementConstraintAdjustmentProperty); + set => SetValue(PlacementConstraintAdjustmentProperty, value); } /// @@ -230,8 +230,8 @@ namespace Avalonia.Controls.Primitives /// public PopupGravity PlacementGravity { - get { return GetValue(PlacementGravityProperty); } - set { SetValue(PlacementGravityProperty, value); } + get => GetValue(PlacementGravityProperty); + set => SetValue(PlacementGravityProperty, value); } /// @@ -239,8 +239,8 @@ namespace Avalonia.Controls.Primitives /// public PlacementMode Placement { - get { return GetValue(PlacementProperty); } - set { SetValue(PlacementProperty, value); } + get => GetValue(PlacementProperty); + set => SetValue(PlacementProperty, value); } /// @@ -256,8 +256,8 @@ namespace Avalonia.Controls.Primitives /// public Rect? PlacementRect { - get { return GetValue(PlacementRectProperty); } - set { SetValue(PlacementRectProperty, value); } + get => GetValue(PlacementRectProperty); + set => SetValue(PlacementRectProperty, value); } /// @@ -266,8 +266,8 @@ namespace Avalonia.Controls.Primitives [ResolveByName] public Control? PlacementTarget { - get { return GetValue(PlacementTargetProperty); } - set { SetValue(PlacementTargetProperty, value); } + get => GetValue(PlacementTargetProperty); + set => SetValue(PlacementTargetProperty, value); } /// @@ -301,8 +301,8 @@ namespace Avalonia.Controls.Primitives /// public double HorizontalOffset { - get { return GetValue(HorizontalOffsetProperty); } - set { SetValue(HorizontalOffsetProperty, value); } + get => GetValue(HorizontalOffsetProperty); + set => SetValue(HorizontalOffsetProperty, value); } /// @@ -310,8 +310,8 @@ namespace Avalonia.Controls.Primitives /// public double VerticalOffset { - get { return GetValue(VerticalOffsetProperty); } - set { SetValue(VerticalOffsetProperty, value); } + get => GetValue(VerticalOffsetProperty); + set => SetValue(VerticalOffsetProperty, value); } /// @@ -319,8 +319,8 @@ namespace Avalonia.Controls.Primitives /// public bool Topmost { - get { return GetValue(TopmostProperty); } - set { SetValue(TopmostProperty, value); } + get => GetValue(TopmostProperty); + set => SetValue(TopmostProperty, value); } IPopupHost? IPopupHostProvider.PopupHost => Host; From 6f523e1414148b76a8d680f72c437e774d03886c Mon Sep 17 00:00:00 2001 From: robloo Date: Tue, 14 Mar 2023 12:43:32 -0400 Subject: [PATCH 4/9] Inherit some ContextMenu property docs from Popup --- src/Avalonia.Controls/ContextMenu.cs | 43 ++++++---------------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index 923982e723..2a87e54618 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -114,57 +114,42 @@ namespace Avalonia.Controls AutomationProperties.ControlTypeOverrideProperty.OverrideDefaultValue(AutomationControlType.Menu); } - /// - /// Gets or sets the Horizontal offset of the context menu in relation to the . - /// + /// public double HorizontalOffset { get => GetValue(HorizontalOffsetProperty); set => SetValue(HorizontalOffsetProperty, value); } - /// - /// Gets or sets the Vertical offset of the context menu in relation to the . - /// + /// public double VerticalOffset { get => GetValue(VerticalOffsetProperty); set => SetValue(VerticalOffsetProperty, value); } - /// - /// Gets or sets the anchor point on the when - /// is . - /// + /// public PopupAnchor PlacementAnchor { get => GetValue(PlacementAnchorProperty); set => SetValue(PlacementAnchorProperty, value); } - /// - /// Gets or sets a value describing how the context menu position will be adjusted if the - /// unadjusted position would result in the context menu being partly constrained. - /// + /// public PopupPositionerConstraintAdjustment PlacementConstraintAdjustment { get => GetValue(PlacementConstraintAdjustmentProperty); set => SetValue(PlacementConstraintAdjustmentProperty, value); } - /// - /// Gets or sets a value which defines in what direction the context menu should open - /// when is . - /// + /// public PopupGravity PlacementGravity { get => GetValue(PlacementGravityProperty); set => SetValue(PlacementGravityProperty, value); } - /// - /// Gets or sets the desired placement of the context menu in relation to the. - /// + /// public PlacementMode Placement { get => GetValue(PlacementProperty); @@ -177,26 +162,14 @@ namespace Avalonia.Controls set => SetValue(WindowManagerAddShadowHintProperty, value); } - /// - /// Gets or sets the the anchor rectangle within the parent that the context menu will be placed - /// relative to when is . - /// - /// - /// The placement rect defines a rectangle relative to around - /// which the popup will be opened, with determining which edge - /// of the placement target is used. - /// - /// If unset, the anchor rectangle will be the bounds of the . - /// + /// public Rect? PlacementRect { get => GetValue(PlacementRectProperty); set => SetValue(PlacementRectProperty, value); } - /// - /// Gets or sets the control that is used to determine the popup's position. - /// + /// public Control? PlacementTarget { get => GetValue(PlacementTargetProperty); From c636dc5f6604197991373a7882b6bf195d193c16 Mon Sep 17 00:00:00 2001 From: robloo Date: Wed, 15 Mar 2023 18:58:35 -0400 Subject: [PATCH 5/9] Update for latest master changes --- src/Avalonia.Themes.Fluent/Controls/Menu.xaml | 2 +- src/Avalonia.Themes.Simple/Controls/Menu.xaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Controls/Menu.xaml b/src/Avalonia.Themes.Fluent/Controls/Menu.xaml index 039482d70f..c234cfd68e 100644 --- a/src/Avalonia.Themes.Fluent/Controls/Menu.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/Menu.xaml @@ -37,7 +37,7 @@ MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}" IsLightDismissEnabled="True" IsOpen="{TemplateBinding IsSubMenuOpen, Mode=TwoWay}" - PlacementMode="BottomEdgeAlignedLeft" + Placement="BottomEdgeAlignedLeft" OverlayInputPassThroughElement="{Binding $parent[Menu]}"> Date: Wed, 15 Mar 2023 19:09:28 -0400 Subject: [PATCH 6/9] Add back PlacementMode properties as obsolete aliases of Placement --- src/Avalonia.Controls/ContextMenu.cs | 18 ++++++++++++++++++ src/Avalonia.Controls/Primitives/Popup.cs | 14 ++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index 2a87e54618..38da6f6e72 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -54,12 +54,22 @@ namespace Avalonia.Controls public static readonly StyledProperty PlacementGravityProperty = Popup.PlacementGravityProperty.AddOwner(); + /// + /// Defines the property. + /// + [Obsolete("Use the Placement property instead.")] + public static readonly StyledProperty PlacementModeProperty = PlacementProperty; + +#pragma warning disable AVP1013 // AvaloniaProperty owners should not be added superfluously + /// /// Defines the property. /// public static readonly StyledProperty PlacementProperty = Popup.PlacementProperty.AddOwner(); +#pragma warning restore AVP1013 // AvaloniaProperty owners should not be added superfluously + /// /// Defines the property. /// @@ -149,6 +159,14 @@ namespace Avalonia.Controls set => SetValue(PlacementGravityProperty, value); } + /// + [Obsolete("Use the Placement property instead.")] + public PlacementMode PlacementMode + { + get => GetValue(PlacementProperty); + set => SetValue(PlacementProperty, value); + } + /// public PlacementMode Placement { diff --git a/src/Avalonia.Controls/Primitives/Popup.cs b/src/Avalonia.Controls/Primitives/Popup.cs index 76c7b19e68..e4fadcdf67 100644 --- a/src/Avalonia.Controls/Primitives/Popup.cs +++ b/src/Avalonia.Controls/Primitives/Popup.cs @@ -65,6 +65,12 @@ namespace Avalonia.Controls.Primitives public static readonly StyledProperty PlacementGravityProperty = AvaloniaProperty.Register(nameof(PlacementGravity)); + /// + /// Defines the property. + /// + [Obsolete("Use the Placement property instead.")] + public static readonly StyledProperty PlacementModeProperty = PlacementProperty; + /// /// Defines the property. /// @@ -234,6 +240,14 @@ namespace Avalonia.Controls.Primitives set => SetValue(PlacementGravityProperty, value); } + /// + [Obsolete("Use the Placement property instead.")] + public PlacementMode PlacementMode + { + get => GetValue(PlacementProperty); + set => SetValue(PlacementProperty, value); + } + /// /// Gets or sets the desired placement of the popup in relation to the . /// From b116a870b12a13586f65cec6283654744e5383da Mon Sep 17 00:00:00 2001 From: robloo Date: Wed, 15 Mar 2023 23:04:04 -0400 Subject: [PATCH 7/9] Attempt to fix CI build failure --- src/Avalonia.Controls/ContextMenu.cs | 2 +- src/Avalonia.Controls/Primitives/Popup.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index 38da6f6e72..a6242721b4 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -58,7 +58,7 @@ namespace Avalonia.Controls /// Defines the property. /// [Obsolete("Use the Placement property instead.")] - public static readonly StyledProperty PlacementModeProperty = PlacementProperty; + public static readonly StyledProperty PlacementModeProperty = PlacementProperty!; #pragma warning disable AVP1013 // AvaloniaProperty owners should not be added superfluously diff --git a/src/Avalonia.Controls/Primitives/Popup.cs b/src/Avalonia.Controls/Primitives/Popup.cs index e4fadcdf67..da21cc6439 100644 --- a/src/Avalonia.Controls/Primitives/Popup.cs +++ b/src/Avalonia.Controls/Primitives/Popup.cs @@ -69,7 +69,7 @@ namespace Avalonia.Controls.Primitives /// Defines the property. /// [Obsolete("Use the Placement property instead.")] - public static readonly StyledProperty PlacementModeProperty = PlacementProperty; + public static readonly StyledProperty PlacementModeProperty = PlacementProperty!; /// /// Defines the property. From 32886d717cfcc7a360eda5e880742599484cdb66 Mon Sep 17 00:00:00 2001 From: robloo Date: Thu, 16 Mar 2023 07:25:23 -0400 Subject: [PATCH 8/9] Revert "Attempt to fix CI build failure" This reverts commit b116a870b12a13586f65cec6283654744e5383da. --- src/Avalonia.Controls/ContextMenu.cs | 2 +- src/Avalonia.Controls/Primitives/Popup.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index a6242721b4..38da6f6e72 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -58,7 +58,7 @@ namespace Avalonia.Controls /// Defines the property. /// [Obsolete("Use the Placement property instead.")] - public static readonly StyledProperty PlacementModeProperty = PlacementProperty!; + public static readonly StyledProperty PlacementModeProperty = PlacementProperty; #pragma warning disable AVP1013 // AvaloniaProperty owners should not be added superfluously diff --git a/src/Avalonia.Controls/Primitives/Popup.cs b/src/Avalonia.Controls/Primitives/Popup.cs index da21cc6439..e4fadcdf67 100644 --- a/src/Avalonia.Controls/Primitives/Popup.cs +++ b/src/Avalonia.Controls/Primitives/Popup.cs @@ -69,7 +69,7 @@ namespace Avalonia.Controls.Primitives /// Defines the property. /// [Obsolete("Use the Placement property instead.")] - public static readonly StyledProperty PlacementModeProperty = PlacementProperty!; + public static readonly StyledProperty PlacementModeProperty = PlacementProperty; /// /// Defines the property. From 8fa365c08ec348a01169b5819bf48903a006ffcc Mon Sep 17 00:00:00 2001 From: robloo Date: Thu, 16 Mar 2023 07:35:54 -0400 Subject: [PATCH 9/9] Fix PlacementMode property order --- src/Avalonia.Controls/ContextMenu.cs | 14 +++++--------- src/Avalonia.Controls/Primitives/Popup.cs | 12 ++++++------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/Avalonia.Controls/ContextMenu.cs b/src/Avalonia.Controls/ContextMenu.cs index 38da6f6e72..f46594ff96 100644 --- a/src/Avalonia.Controls/ContextMenu.cs +++ b/src/Avalonia.Controls/ContextMenu.cs @@ -54,21 +54,17 @@ namespace Avalonia.Controls public static readonly StyledProperty PlacementGravityProperty = Popup.PlacementGravityProperty.AddOwner(); - /// - /// Defines the property. - /// - [Obsolete("Use the Placement property instead.")] - public static readonly StyledProperty PlacementModeProperty = PlacementProperty; - -#pragma warning disable AVP1013 // AvaloniaProperty owners should not be added superfluously - /// /// Defines the property. /// public static readonly StyledProperty PlacementProperty = Popup.PlacementProperty.AddOwner(); -#pragma warning restore AVP1013 // AvaloniaProperty owners should not be added superfluously + /// + /// Defines the property. + /// + [Obsolete("Use the Placement property instead.")] + public static readonly StyledProperty PlacementModeProperty = PlacementProperty; /// /// Defines the property. diff --git a/src/Avalonia.Controls/Primitives/Popup.cs b/src/Avalonia.Controls/Primitives/Popup.cs index e4fadcdf67..eda794f33a 100644 --- a/src/Avalonia.Controls/Primitives/Popup.cs +++ b/src/Avalonia.Controls/Primitives/Popup.cs @@ -65,18 +65,18 @@ namespace Avalonia.Controls.Primitives public static readonly StyledProperty PlacementGravityProperty = AvaloniaProperty.Register(nameof(PlacementGravity)); - /// - /// Defines the property. - /// - [Obsolete("Use the Placement property instead.")] - public static readonly StyledProperty PlacementModeProperty = PlacementProperty; - /// /// Defines the property. /// public static readonly StyledProperty PlacementProperty = AvaloniaProperty.Register(nameof(Placement), defaultValue: PlacementMode.Bottom); + /// + /// Defines the property. + /// + [Obsolete("Use the Placement property instead.")] + public static readonly StyledProperty PlacementModeProperty = PlacementProperty; + /// /// Defines the property. ///