mirror of
https://gitee.com/chinware/atomui.git
synced 2024-11-29 18:38:16 +08:00
Fixed ArrowDecoratedBox ArrowPosition calculate issue
This commit is contained in:
parent
a4e7064a72
commit
0dc2b9b5ef
@ -51,7 +51,7 @@ internal static class MotionInvoker
|
||||
{
|
||||
Dispatcher.UIThread.Invoke(async () =>
|
||||
{
|
||||
await Task.Delay(100);
|
||||
await Task.Delay(300);
|
||||
sceneLayer.Hide();
|
||||
sceneLayer.Dispose();
|
||||
});
|
||||
|
@ -1,78 +1,79 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Layout;
|
||||
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
public enum ArrowPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// Preferred location is below the target element.
|
||||
/// </summary>
|
||||
Bottom,
|
||||
/// <summary>
|
||||
/// Preferred location is below the target element.
|
||||
/// </summary>
|
||||
Bottom,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is to the right of the target element.
|
||||
/// </summary>
|
||||
Right,
|
||||
/// <summary>
|
||||
/// Preferred location is to the right of the target element.
|
||||
/// </summary>
|
||||
Right,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is to the left of the target element.
|
||||
/// </summary>
|
||||
Left,
|
||||
/// <summary>
|
||||
/// Preferred location is to the left of the target element.
|
||||
/// </summary>
|
||||
Left,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is above the target element.
|
||||
/// </summary>
|
||||
Top,
|
||||
/// <summary>
|
||||
/// Preferred location is above the target element.
|
||||
/// </summary>
|
||||
Top,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is above the target element, with the left edge of the popup
|
||||
/// aligned with the left edge of the target element.
|
||||
/// </summary>
|
||||
TopEdgeAlignedLeft,
|
||||
/// <summary>
|
||||
/// Preferred location is above the target element, with the left edge of the popup
|
||||
/// aligned with the left edge of the target element.
|
||||
/// </summary>
|
||||
TopEdgeAlignedLeft,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is above the target element, with the right edge of popup aligned with right edge of the target
|
||||
/// element.
|
||||
/// </summary>
|
||||
TopEdgeAlignedRight,
|
||||
/// <summary>
|
||||
/// Preferred location is above the target element, with the right edge of popup aligned with right edge of the target
|
||||
/// element.
|
||||
/// </summary>
|
||||
TopEdgeAlignedRight,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is below the target element, with the left edge of popup aligned with left edge of the target
|
||||
/// element.
|
||||
/// </summary>
|
||||
BottomEdgeAlignedLeft,
|
||||
/// <summary>
|
||||
/// Preferred location is below the target element, with the left edge of popup aligned with left edge of the target
|
||||
/// element.
|
||||
/// </summary>
|
||||
BottomEdgeAlignedLeft,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is below the target element, with the right edge of popup aligned with right edge of the target
|
||||
/// element.
|
||||
/// </summary>
|
||||
BottomEdgeAlignedRight,
|
||||
/// <summary>
|
||||
/// Preferred location is below the target element, with the right edge of popup aligned with right edge of the target
|
||||
/// element.
|
||||
/// </summary>
|
||||
BottomEdgeAlignedRight,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is to the left of the target element, with the top edge of popup aligned with top edge of the
|
||||
/// target element.
|
||||
/// </summary>
|
||||
LeftEdgeAlignedTop,
|
||||
/// <summary>
|
||||
/// Preferred location is to the left of the target element, with the top edge of popup aligned with top edge of the
|
||||
/// target element.
|
||||
/// </summary>
|
||||
LeftEdgeAlignedTop,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is to the left of the target element, with the bottom edge of popup aligned with bottom edge of
|
||||
/// the target element.
|
||||
/// </summary>
|
||||
LeftEdgeAlignedBottom,
|
||||
/// <summary>
|
||||
/// Preferred location is to the left of the target element, with the bottom edge of popup aligned with bottom edge of
|
||||
/// the target element.
|
||||
/// </summary>
|
||||
LeftEdgeAlignedBottom,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is to the right of the target element, with the top edge of popup aligned with top edge of the
|
||||
/// target element.
|
||||
/// </summary>
|
||||
RightEdgeAlignedTop,
|
||||
/// <summary>
|
||||
/// Preferred location is to the right of the target element, with the top edge of popup aligned with top edge of the
|
||||
/// target element.
|
||||
/// </summary>
|
||||
RightEdgeAlignedTop,
|
||||
|
||||
/// <summary>
|
||||
/// Preferred location is to the right of the target element, with the bottom edge of popup aligned with bottom edge of
|
||||
/// the target element.
|
||||
/// </summary>
|
||||
RightEdgeAlignedBottom
|
||||
/// <summary>
|
||||
/// Preferred location is to the right of the target element, with the bottom edge of popup aligned with bottom edge of
|
||||
/// the target element.
|
||||
/// </summary>
|
||||
RightEdgeAlignedBottom
|
||||
}
|
||||
|
||||
public class ArrowDecoratedBox : ContentControl, IShadowMaskInfoProvider
|
||||
@ -205,9 +206,16 @@ public class ArrowDecoratedBox : ContentControl, IShadowMaskInfoProvider
|
||||
{
|
||||
return default;
|
||||
}
|
||||
var targetRect = _arrowIndicatorLayout.Bounds;
|
||||
var center = targetRect.Center;
|
||||
var controlSize = Bounds.Size;
|
||||
|
||||
if (_arrowIndicatorLayout.Bounds == default)
|
||||
{
|
||||
LayoutHelper.MeasureChild(this, Size.Infinity, Padding);
|
||||
Arrange(new Rect(DesiredSize));
|
||||
}
|
||||
|
||||
var targetRect = _arrowIndicatorLayout.Bounds;
|
||||
var center = targetRect.Center;
|
||||
var controlSize = Bounds.Size;
|
||||
|
||||
// 计算中点
|
||||
var direction = GetDirection(ArrowPosition);
|
||||
@ -234,10 +242,10 @@ public class ArrowDecoratedBox : ContentControl, IShadowMaskInfoProvider
|
||||
{
|
||||
return;
|
||||
}
|
||||
var offsetX = 0d;
|
||||
var offsetY = 0d;
|
||||
var position = ArrowPosition;
|
||||
var size = _arrowIndicatorLayout.DesiredSize;
|
||||
var offsetX = 0d;
|
||||
var offsetY = 0d;
|
||||
var position = ArrowPosition;
|
||||
var size = _arrowIndicatorLayout.DesiredSize;
|
||||
|
||||
var minValue = Math.Min(size.Width, size.Height);
|
||||
var maxValue = Math.Max(size.Width, size.Height);
|
||||
|
@ -6,7 +6,6 @@ using AtomUI.Utils;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives.PopupPositioning;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Metadata;
|
||||
@ -26,7 +25,7 @@ public class Flyout : PopupFlyoutBase
|
||||
/// 是否显示指示箭头
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<bool> IsShowArrowProperty =
|
||||
ArrowDecoratedBox.IsShowArrowProperty.AddOwner<PopupFlyoutBase>();
|
||||
ArrowDecoratedBox.IsShowArrowProperty.AddOwner<Flyout>();
|
||||
|
||||
public static readonly StyledProperty<BoxShadows> MaskShadowsProperty =
|
||||
Border.BoxShadowProperty.AddOwner<Flyout>();
|
||||
@ -320,6 +319,7 @@ public class Flyout : PopupFlyoutBase
|
||||
|
||||
var offsetX = HorizontalOffset;
|
||||
var offsetY = VerticalOffset;
|
||||
|
||||
if (IsPointAtCenter)
|
||||
{
|
||||
offsetX += pointAtCenterOffset.X;
|
||||
|
Loading…
Reference in New Issue
Block a user