|
|
|
@ -65,11 +65,17 @@ namespace Avalonia.Controls.Primitives |
|
|
|
public static readonly StyledProperty<PopupGravity> PlacementGravityProperty = |
|
|
|
AvaloniaProperty.Register<Popup, PopupGravity>(nameof(PlacementGravity)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Defines the <see cref="Placement"/> property.
|
|
|
|
/// </summary>
|
|
|
|
public static readonly StyledProperty<PlacementMode> PlacementProperty = |
|
|
|
AvaloniaProperty.Register<Popup, PlacementMode>(nameof(Placement), defaultValue: PlacementMode.Bottom); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Defines the <see cref="PlacementMode"/> property.
|
|
|
|
/// </summary>
|
|
|
|
public static readonly StyledProperty<PlacementMode> PlacementModeProperty = |
|
|
|
AvaloniaProperty.Register<Popup, PlacementMode>(nameof(PlacementMode), defaultValue: PlacementMode.Bottom); |
|
|
|
[Obsolete("Use the Placement property instead.")] |
|
|
|
public static readonly StyledProperty<PlacementMode> PlacementModeProperty = PlacementProperty; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Defines the <see cref="PlacementRect"/> property.
|
|
|
|
@ -146,8 +152,8 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
public bool WindowManagerAddShadowHint |
|
|
|
{ |
|
|
|
get { return GetValue(WindowManagerAddShadowHintProperty); } |
|
|
|
set { SetValue(WindowManagerAddShadowHintProperty, value); } |
|
|
|
get => GetValue(WindowManagerAddShadowHintProperty); |
|
|
|
set => SetValue(WindowManagerAddShadowHintProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -156,8 +162,8 @@ namespace Avalonia.Controls.Primitives |
|
|
|
[Content] |
|
|
|
public Control? Child |
|
|
|
{ |
|
|
|
get { return GetValue(ChildProperty); } |
|
|
|
set { SetValue(ChildProperty, value); } |
|
|
|
get => GetValue(ChildProperty); |
|
|
|
set => SetValue(ChildProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -205,13 +211,13 @@ namespace Avalonia.Controls.Primitives |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the anchor point on the <see cref="PlacementRect"/> when <see cref="PlacementMode"/>
|
|
|
|
/// Gets or sets the anchor point on the <see cref="PlacementRect"/> when <see cref="Placement"/>
|
|
|
|
/// is <see cref="PlacementMode.AnchorAndGravity"/>.
|
|
|
|
/// </summary>
|
|
|
|
public PopupAnchor PlacementAnchor |
|
|
|
{ |
|
|
|
get { return GetValue(PlacementAnchorProperty); } |
|
|
|
set { SetValue(PlacementAnchorProperty, value); } |
|
|
|
get => GetValue(PlacementAnchorProperty); |
|
|
|
set => SetValue(PlacementAnchorProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -220,32 +226,40 @@ namespace Avalonia.Controls.Primitives |
|
|
|
/// </summary>
|
|
|
|
public PopupPositionerConstraintAdjustment PlacementConstraintAdjustment |
|
|
|
{ |
|
|
|
get { return GetValue(PlacementConstraintAdjustmentProperty); } |
|
|
|
set { SetValue(PlacementConstraintAdjustmentProperty, value); } |
|
|
|
get => GetValue(PlacementConstraintAdjustmentProperty); |
|
|
|
set => SetValue(PlacementConstraintAdjustmentProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets a value which defines in what direction the popup should open
|
|
|
|
/// when <see cref="PlacementMode"/> is <see cref="PlacementMode.AnchorAndGravity"/>.
|
|
|
|
/// when <see cref="Placement"/> is <see cref="PlacementMode.AnchorAndGravity"/>.
|
|
|
|
/// </summary>
|
|
|
|
public PopupGravity PlacementGravity |
|
|
|
{ |
|
|
|
get { return GetValue(PlacementGravityProperty); } |
|
|
|
set { SetValue(PlacementGravityProperty, value); } |
|
|
|
get => GetValue(PlacementGravityProperty); |
|
|
|
set => SetValue(PlacementGravityProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc cref="Placement"/>
|
|
|
|
[Obsolete("Use the Placement property instead.")] |
|
|
|
public PlacementMode PlacementMode |
|
|
|
{ |
|
|
|
get => GetValue(PlacementProperty); |
|
|
|
set => SetValue(PlacementProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the placement mode of the popup in relation to the <see cref="PlacementTarget"/>.
|
|
|
|
/// Gets or sets the desired placement of the popup in relation to the <see cref="PlacementTarget"/>.
|
|
|
|
/// </summary>
|
|
|
|
public PlacementMode PlacementMode |
|
|
|
public PlacementMode Placement |
|
|
|
{ |
|
|
|
get { return GetValue(PlacementModeProperty); } |
|
|
|
set { SetValue(PlacementModeProperty, value); } |
|
|
|
get => GetValue(PlacementProperty); |
|
|
|
set => SetValue(PlacementProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the the anchor rectangle within the parent that the popup will be placed
|
|
|
|
/// relative to when <see cref="PlacementMode"/> is <see cref="PlacementMode.AnchorAndGravity"/>.
|
|
|
|
/// relative to when <see cref="Placement"/> is <see cref="PlacementMode.AnchorAndGravity"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// The placement rect defines a rectangle relative to <see cref="PlacementTarget"/> around
|
|
|
|
@ -256,8 +270,8 @@ namespace Avalonia.Controls.Primitives |
|
|
|
/// </remarks>
|
|
|
|
public Rect? PlacementRect |
|
|
|
{ |
|
|
|
get { return GetValue(PlacementRectProperty); } |
|
|
|
set { SetValue(PlacementRectProperty, value); } |
|
|
|
get => GetValue(PlacementRectProperty); |
|
|
|
set => SetValue(PlacementRectProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -266,8 +280,8 @@ namespace Avalonia.Controls.Primitives |
|
|
|
[ResolveByName] |
|
|
|
public Control? PlacementTarget |
|
|
|
{ |
|
|
|
get { return GetValue(PlacementTargetProperty); } |
|
|
|
set { SetValue(PlacementTargetProperty, value); } |
|
|
|
get => GetValue(PlacementTargetProperty); |
|
|
|
set => SetValue(PlacementTargetProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -301,8 +315,8 @@ namespace Avalonia.Controls.Primitives |
|
|
|
/// </summary>
|
|
|
|
public double HorizontalOffset |
|
|
|
{ |
|
|
|
get { return GetValue(HorizontalOffsetProperty); } |
|
|
|
set { SetValue(HorizontalOffsetProperty, value); } |
|
|
|
get => GetValue(HorizontalOffsetProperty); |
|
|
|
set => SetValue(HorizontalOffsetProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -310,8 +324,8 @@ namespace Avalonia.Controls.Primitives |
|
|
|
/// </summary>
|
|
|
|
public double VerticalOffset |
|
|
|
{ |
|
|
|
get { return GetValue(VerticalOffsetProperty); } |
|
|
|
set { SetValue(VerticalOffsetProperty, value); } |
|
|
|
get => GetValue(VerticalOffsetProperty); |
|
|
|
set => SetValue(VerticalOffsetProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -319,8 +333,8 @@ namespace Avalonia.Controls.Primitives |
|
|
|
/// </summary>
|
|
|
|
public bool Topmost |
|
|
|
{ |
|
|
|
get { return GetValue(TopmostProperty); } |
|
|
|
set { SetValue(TopmostProperty, value); } |
|
|
|
get => GetValue(TopmostProperty); |
|
|
|
set => SetValue(TopmostProperty, value); |
|
|
|
} |
|
|
|
|
|
|
|
IPopupHost? IPopupHostProvider.PopupHost => Host; |
|
|
|
@ -404,7 +418,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<IWindowImpl, Action<PixelPoint>>(window.PlatformImpl, WindowPositionChanged, |
|
|
|
(x, handler) => x.PositionChanged += handler, |
|
|
|
@ -534,7 +548,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 +581,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
{ |
|
|
|
popupHost.ConfigurePosition( |
|
|
|
placementTarget, |
|
|
|
PlacementMode, |
|
|
|
Placement, |
|
|
|
new Point(HorizontalOffset, VerticalOffset), |
|
|
|
PlacementAnchor, |
|
|
|
PlacementGravity, |
|
|
|
@ -615,7 +629,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
return; |
|
|
|
_openState.PopupHost.ConfigurePosition( |
|
|
|
placementTarget, |
|
|
|
PlacementMode, |
|
|
|
Placement, |
|
|
|
new Point(HorizontalOffset, VerticalOffset), |
|
|
|
PlacementAnchor, |
|
|
|
PlacementGravity, |
|
|
|
|