mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-22 00:46:48 +08:00
refactor popup motion
Now supports setting opening and closing animations
This commit is contained in:
@@ -4,7 +4,6 @@ using AtomUI.Animations;
|
||||
using Avalonia;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Animation.Easings;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Transformation;
|
||||
using Avalonia.ReactiveUI;
|
||||
@@ -12,20 +11,20 @@ using Avalonia.Threading;
|
||||
|
||||
namespace AtomUI.MotionScene;
|
||||
|
||||
internal class AbstractMotion : IMotion
|
||||
public class AbstractMotion : IMotion
|
||||
{
|
||||
public RelativePoint RenderTransformOrigin { get; protected set; }
|
||||
public IList<Animation> Animations { get; }
|
||||
public IList<INotifyTransitionCompleted> Transitions { get; }
|
||||
public TimeSpan Duration { get; }
|
||||
public Easing Easing { get; }
|
||||
public FillMode PropertyValueFillMode { get; }
|
||||
public TimeSpan Duration { get; set; }
|
||||
public Easing Easing { get; set; }
|
||||
public FillMode PropertyValueFillMode { get; set; }
|
||||
public MotionSpiritType SpiritType { get; set; } = MotionSpiritType.Transition;
|
||||
|
||||
public AbstractMotion(TimeSpan duration, Easing? easing = null, FillMode fillMode = FillMode.Forward)
|
||||
public AbstractMotion(TimeSpan? duration = null, Easing? easing = null, FillMode fillMode = FillMode.Forward)
|
||||
{
|
||||
Animations = new List<Animation>();
|
||||
Duration = duration;
|
||||
Duration = duration ?? TimeSpan.FromMilliseconds(300);
|
||||
Easing = easing ?? new LinearEasing();
|
||||
PropertyValueFillMode = fillMode;
|
||||
Transitions = new List<INotifyTransitionCompleted>();
|
||||
|
||||
@@ -9,7 +9,7 @@ internal class CollapseMotion : AbstractMotion
|
||||
public Direction Direction { get; }
|
||||
|
||||
public CollapseMotion(Direction direction,
|
||||
TimeSpan duration,
|
||||
TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CubicEaseOut(), fillMode)
|
||||
@@ -72,7 +72,7 @@ internal class ExpandMotion : AbstractMotion
|
||||
public Direction Direction { get; }
|
||||
|
||||
public ExpandMotion(Direction direction,
|
||||
TimeSpan duration,
|
||||
TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CubicEaseIn(), fillMode)
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AtomUI.MotionScene;
|
||||
|
||||
internal class FadeInMotion : AbstractMotion
|
||||
{
|
||||
public FadeInMotion(TimeSpan duration,
|
||||
public FadeInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new LinearEasing(), fillMode)
|
||||
@@ -33,7 +33,7 @@ internal class FadeInMotion : AbstractMotion
|
||||
|
||||
internal class FadeOutMotion : AbstractMotion
|
||||
{
|
||||
public FadeOutMotion(TimeSpan duration,
|
||||
public FadeOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new LinearEasing(), fillMode)
|
||||
|
||||
@@ -5,13 +5,13 @@ using Avalonia.Animation.Easings;
|
||||
|
||||
namespace AtomUI.MotionScene;
|
||||
|
||||
internal enum MotionSpiritType
|
||||
public enum MotionSpiritType
|
||||
{
|
||||
Animation,
|
||||
Transition
|
||||
}
|
||||
|
||||
internal interface IMotion
|
||||
public interface IMotion
|
||||
{
|
||||
RelativePoint RenderTransformOrigin { get; }
|
||||
IList<Animation> Animations { get; }
|
||||
|
||||
@@ -10,7 +10,7 @@ internal class MoveDownInMotion : AbstractMotion
|
||||
public double Offset { get; }
|
||||
|
||||
public MoveDownInMotion(double offset,
|
||||
TimeSpan duration,
|
||||
TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new QuinticEaseOut(), fillMode)
|
||||
@@ -111,7 +111,7 @@ internal class MoveDownOutMotion : AbstractMotion
|
||||
public double Offset { get; }
|
||||
|
||||
public MoveDownOutMotion(double offset,
|
||||
TimeSpan duration,
|
||||
TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new QuinticEaseIn(), fillMode)
|
||||
@@ -202,7 +202,7 @@ internal class MoveUpInMotion : AbstractMotion
|
||||
public double Offset { get; }
|
||||
|
||||
public MoveUpInMotion(double offset,
|
||||
TimeSpan duration,
|
||||
TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new QuinticEaseOut(), fillMode)
|
||||
@@ -303,7 +303,7 @@ internal class MoveUpOutMotion : AbstractMotion
|
||||
public double Offset { get; }
|
||||
|
||||
public MoveUpOutMotion(double offset,
|
||||
TimeSpan duration,
|
||||
TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new QuinticEaseIn(), fillMode)
|
||||
@@ -396,7 +396,7 @@ internal class MoveLeftInMotion : AbstractMotion
|
||||
public double Offset { get; }
|
||||
|
||||
public MoveLeftInMotion(double offset,
|
||||
TimeSpan duration,
|
||||
TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new QuinticEaseOut(), fillMode)
|
||||
@@ -500,7 +500,7 @@ internal class MoveLeftOutMotion : AbstractMotion
|
||||
public double Offset { get; }
|
||||
|
||||
public MoveLeftOutMotion(double offset,
|
||||
TimeSpan duration,
|
||||
TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new QuinticEaseIn(), fillMode)
|
||||
@@ -589,7 +589,7 @@ internal class MoveRightInMotion : AbstractMotion
|
||||
public double Offset { get; }
|
||||
|
||||
public MoveRightInMotion(double offset,
|
||||
TimeSpan duration,
|
||||
TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new QuinticEaseOut(), fillMode)
|
||||
@@ -691,7 +691,7 @@ internal class MoveRightOutMotion : AbstractMotion
|
||||
public double Offset { get; }
|
||||
|
||||
public MoveRightOutMotion(double offset,
|
||||
TimeSpan duration,
|
||||
TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new QuinticEaseIn(), fillMode)
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AtomUI.MotionScene;
|
||||
|
||||
internal class SlideUpInMotion : AbstractMotion
|
||||
{
|
||||
public SlideUpInMotion(TimeSpan duration,
|
||||
public SlideUpInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CubicEaseOut(), fillMode)
|
||||
@@ -35,7 +35,7 @@ internal class SlideUpInMotion : AbstractMotion
|
||||
|
||||
internal class SlideUpOutMotion : AbstractMotion
|
||||
{
|
||||
public SlideUpOutMotion(TimeSpan duration,
|
||||
public SlideUpOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CubicEaseIn(), fillMode)
|
||||
@@ -63,7 +63,7 @@ internal class SlideUpOutMotion : AbstractMotion
|
||||
|
||||
internal class SlideDownInMotion : AbstractMotion
|
||||
{
|
||||
public SlideDownInMotion(TimeSpan duration,
|
||||
public SlideDownInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CubicEaseOut(), fillMode)
|
||||
@@ -91,7 +91,7 @@ internal class SlideDownInMotion : AbstractMotion
|
||||
|
||||
internal class SlideDownOutMotion : AbstractMotion
|
||||
{
|
||||
public SlideDownOutMotion(TimeSpan duration,
|
||||
public SlideDownOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CubicEaseIn(), fillMode)
|
||||
@@ -119,7 +119,7 @@ internal class SlideDownOutMotion : AbstractMotion
|
||||
|
||||
internal class SlideLeftInMotion : AbstractMotion
|
||||
{
|
||||
public SlideLeftInMotion(TimeSpan duration,
|
||||
public SlideLeftInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CubicEaseOut(), fillMode)
|
||||
@@ -147,7 +147,7 @@ internal class SlideLeftInMotion : AbstractMotion
|
||||
|
||||
internal class SlideLeftOutMotion : AbstractMotion
|
||||
{
|
||||
public SlideLeftOutMotion(TimeSpan duration,
|
||||
public SlideLeftOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CubicEaseIn(), fillMode)
|
||||
@@ -175,7 +175,7 @@ internal class SlideLeftOutMotion : AbstractMotion
|
||||
|
||||
internal class SlideRightInMotion : AbstractMotion
|
||||
{
|
||||
public SlideRightInMotion(TimeSpan duration,
|
||||
public SlideRightInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CubicEaseOut(), fillMode)
|
||||
@@ -203,7 +203,7 @@ internal class SlideRightInMotion : AbstractMotion
|
||||
|
||||
internal class SlideRightOutMotion : AbstractMotion
|
||||
{
|
||||
public SlideRightOutMotion(TimeSpan duration,
|
||||
public SlideRightOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CubicEaseIn(), fillMode)
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AtomUI.MotionScene;
|
||||
|
||||
internal class ZoomInMotion : AbstractMotion
|
||||
{
|
||||
public ZoomInMotion(TimeSpan duration,
|
||||
public ZoomInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -35,7 +35,7 @@ internal class ZoomInMotion : AbstractMotion
|
||||
|
||||
internal class ZoomOutMotion : AbstractMotion
|
||||
{
|
||||
public ZoomOutMotion(TimeSpan duration,
|
||||
public ZoomOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -69,7 +69,7 @@ internal class ZoomOutMotion : AbstractMotion
|
||||
|
||||
internal class ZoomBigInMotion : AbstractMotion
|
||||
{
|
||||
public ZoomBigInMotion(TimeSpan duration,
|
||||
public ZoomBigInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -97,7 +97,7 @@ internal class ZoomBigInMotion : AbstractMotion
|
||||
|
||||
internal class ZoomBigOutMotion : AbstractMotion
|
||||
{
|
||||
public ZoomBigOutMotion(TimeSpan duration,
|
||||
public ZoomBigOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -131,7 +131,7 @@ internal class ZoomBigOutMotion : AbstractMotion
|
||||
|
||||
internal class ZoomUpInMotion : AbstractMotion
|
||||
{
|
||||
public ZoomUpInMotion(TimeSpan duration,
|
||||
public ZoomUpInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -159,7 +159,7 @@ internal class ZoomUpInMotion : AbstractMotion
|
||||
|
||||
internal class ZoomUpOutMotion : AbstractMotion
|
||||
{
|
||||
public ZoomUpOutMotion(TimeSpan duration,
|
||||
public ZoomUpOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -193,7 +193,7 @@ internal class ZoomUpOutMotion : AbstractMotion
|
||||
|
||||
internal class ZoomLeftInMotion : AbstractMotion
|
||||
{
|
||||
public ZoomLeftInMotion(TimeSpan duration,
|
||||
public ZoomLeftInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -221,7 +221,7 @@ internal class ZoomLeftInMotion : AbstractMotion
|
||||
|
||||
internal class ZoomLeftOutMotion : AbstractMotion
|
||||
{
|
||||
public ZoomLeftOutMotion(TimeSpan duration,
|
||||
public ZoomLeftOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -255,7 +255,7 @@ internal class ZoomLeftOutMotion : AbstractMotion
|
||||
|
||||
internal class ZoomRightInMotion : AbstractMotion
|
||||
{
|
||||
public ZoomRightInMotion(TimeSpan duration,
|
||||
public ZoomRightInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -283,7 +283,7 @@ internal class ZoomRightInMotion : AbstractMotion
|
||||
|
||||
internal class ZoomRightOutMotion : AbstractMotion
|
||||
{
|
||||
public ZoomRightOutMotion(TimeSpan duration,
|
||||
public ZoomRightOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -317,7 +317,7 @@ internal class ZoomRightOutMotion : AbstractMotion
|
||||
|
||||
internal class ZoomDownInMotion : AbstractMotion
|
||||
{
|
||||
public ZoomDownInMotion(TimeSpan duration,
|
||||
public ZoomDownInMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
@@ -345,7 +345,7 @@ internal class ZoomDownInMotion : AbstractMotion
|
||||
|
||||
internal class ZoomDownOutMotion : AbstractMotion
|
||||
{
|
||||
public ZoomDownOutMotion(TimeSpan duration,
|
||||
public ZoomDownOutMotion(TimeSpan? duration = null,
|
||||
Easing? easing = null,
|
||||
FillMode fillMode = FillMode.Forward)
|
||||
: base(duration, easing ?? new CircularEaseOut(), fillMode)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Reactive.Disposables;
|
||||
using AtomUI.Controls.Utils;
|
||||
using AtomUI.Data;
|
||||
using AtomUI.MotionScene;
|
||||
using AtomUI.Theme;
|
||||
using AtomUI.Theme.Data;
|
||||
using AtomUI.Theme.Styling;
|
||||
@@ -62,8 +63,17 @@ public class FlyoutHost : Control,
|
||||
public static readonly StyledProperty<PopupGravity> PlacementGravityProperty =
|
||||
Popup.PlacementGravityProperty.AddOwner<FlyoutHost>();
|
||||
|
||||
public static readonly StyledProperty<bool> IsMotionEnabledProperty
|
||||
= MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<FlyoutHost>();
|
||||
public static readonly StyledProperty<bool> IsMotionEnabledProperty =
|
||||
MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<FlyoutHost>();
|
||||
|
||||
public static readonly StyledProperty<TimeSpan> MotionDurationProperty =
|
||||
Popup.MotionDurationProperty.AddOwner<FlyoutHost>();
|
||||
|
||||
public static readonly StyledProperty<AbstractMotion?> OpenMotionProperty =
|
||||
Popup.OpenMotionProperty.AddOwner<FlyoutHost>();
|
||||
|
||||
public static readonly StyledProperty<AbstractMotion?> CloseMotionProperty =
|
||||
Popup.CloseMotionProperty.AddOwner<FlyoutHost>();
|
||||
|
||||
/// <summary>
|
||||
/// 距离 anchor 的边距,根据垂直和水平进行设置
|
||||
@@ -154,6 +164,24 @@ public class FlyoutHost : Control,
|
||||
get => GetValue(IsMotionEnabledProperty);
|
||||
set => SetValue(IsMotionEnabledProperty, value);
|
||||
}
|
||||
|
||||
public TimeSpan MotionDuration
|
||||
{
|
||||
get => GetValue(MotionDurationProperty);
|
||||
set => SetValue(MotionDurationProperty, value);
|
||||
}
|
||||
|
||||
public AbstractMotion? OpenMotion
|
||||
{
|
||||
get => GetValue(OpenMotionProperty);
|
||||
set => SetValue(OpenMotionProperty, value);
|
||||
}
|
||||
|
||||
public AbstractMotion? CloseMotion
|
||||
{
|
||||
get => GetValue(CloseMotionProperty);
|
||||
set => SetValue(CloseMotionProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -212,6 +240,9 @@ public class FlyoutHost : Control,
|
||||
BindUtils.RelayBind(this, IsPointAtCenterProperty, Flyout, FlyoutControl.IsPointAtCenterProperty);
|
||||
BindUtils.RelayBind(this, MarginToAnchorProperty, Flyout, PopupFlyoutBase.MarginToAnchorProperty);
|
||||
BindUtils.RelayBind(this, IsMotionEnabledProperty, Flyout, PopupFlyoutBase.IsMotionEnabledProperty);
|
||||
BindUtils.RelayBind(this, MotionDurationProperty, Flyout, PopupFlyoutBase.MotionDurationProperty);
|
||||
BindUtils.RelayBind(this, OpenMotionProperty, Flyout, PopupFlyoutBase.OpenMotionProperty);
|
||||
BindUtils.RelayBind(this, CloseMotionProperty, Flyout, PopupFlyoutBase.CloseMotionProperty);
|
||||
Flyout.IsDetectMouseClickEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel;
|
||||
using AtomUI.Controls.Utils;
|
||||
using AtomUI.Data;
|
||||
using AtomUI.MotionScene;
|
||||
using AtomUI.Reflection;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
@@ -37,8 +38,7 @@ public class FlyoutPopupCreatedEventArgs : EventArgs
|
||||
/// <summary>
|
||||
/// 最基本得弹窗 Flyout,在这里不处理那种带箭头得
|
||||
/// </summary>
|
||||
public abstract class PopupFlyoutBase : FlyoutBase,
|
||||
IPopupHostProvider
|
||||
public abstract class PopupFlyoutBase : FlyoutBase, IPopupHostProvider
|
||||
{
|
||||
#region 公共属性定义
|
||||
|
||||
@@ -88,7 +88,17 @@ public abstract class PopupFlyoutBase : FlyoutBase,
|
||||
public static readonly StyledProperty<PopupPositionerConstraintAdjustment> PlacementConstraintAdjustmentProperty =
|
||||
Avalonia.Controls.Primitives.Popup.PlacementConstraintAdjustmentProperty.AddOwner<PopupFlyoutBase>();
|
||||
|
||||
public static readonly StyledProperty<bool> IsMotionEnabledProperty = MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<PopupFlyoutBase>();
|
||||
public static readonly StyledProperty<bool> IsMotionEnabledProperty =
|
||||
MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<PopupFlyoutBase>();
|
||||
|
||||
public static readonly StyledProperty<TimeSpan> MotionDurationProperty =
|
||||
Popup.MotionDurationProperty.AddOwner<PopupFlyoutBase>();
|
||||
|
||||
public static readonly StyledProperty<AbstractMotion?> OpenMotionProperty =
|
||||
Popup.OpenMotionProperty.AddOwner<PopupFlyoutBase>();
|
||||
|
||||
public static readonly StyledProperty<AbstractMotion?> CloseMotionProperty =
|
||||
Popup.CloseMotionProperty.AddOwner<PopupFlyoutBase>();
|
||||
|
||||
public static readonly StyledProperty<bool> IsDetectMouseClickEnabledProperty =
|
||||
AvaloniaProperty.Register<PopupFlyoutBase, bool>(nameof(IsDetectMouseClickEnabled), true);
|
||||
@@ -166,6 +176,24 @@ public abstract class PopupFlyoutBase : FlyoutBase,
|
||||
set => SetValue(IsMotionEnabledProperty, value);
|
||||
}
|
||||
|
||||
public TimeSpan MotionDuration
|
||||
{
|
||||
get => GetValue(MotionDurationProperty);
|
||||
set => SetValue(MotionDurationProperty, value);
|
||||
}
|
||||
|
||||
public AbstractMotion? OpenMotion
|
||||
{
|
||||
get => GetValue(OpenMotionProperty);
|
||||
set => SetValue(OpenMotionProperty, value);
|
||||
}
|
||||
|
||||
public AbstractMotion? CloseMotion
|
||||
{
|
||||
get => GetValue(CloseMotionProperty);
|
||||
set => SetValue(CloseMotionProperty, value);
|
||||
}
|
||||
|
||||
public bool IsDetectMouseClickEnabled
|
||||
{
|
||||
get => GetValue(IsDetectMouseClickEnabledProperty);
|
||||
@@ -214,6 +242,9 @@ public abstract class PopupFlyoutBase : FlyoutBase,
|
||||
BindUtils.RelayBind(this, MarginToAnchorProperty, popup);
|
||||
BindUtils.RelayBind(this, IsDetectMouseClickEnabledProperty, popup, Popup.IsDetectMouseClickEnabledProperty);
|
||||
BindUtils.RelayBind(this, IsMotionEnabledProperty, popup, Popup.IsMotionEnabledProperty);
|
||||
BindUtils.RelayBind(this, MotionDurationProperty, popup, Popup.MotionDurationProperty);
|
||||
BindUtils.RelayBind(this, OpenMotionProperty, popup, Popup.OpenMotionProperty);
|
||||
BindUtils.RelayBind(this, CloseMotionProperty, popup, Popup.CloseMotionProperty);
|
||||
PopupCreated?.Invoke(this, new FlyoutPopupCreatedEventArgs(popup));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reactive.Disposables;
|
||||
using AtomUI.Data;
|
||||
using AtomUI.MotionScene;
|
||||
using AtomUI.Theme;
|
||||
using AtomUI.Theme.Data;
|
||||
using AtomUI.Theme.Styling;
|
||||
@@ -36,19 +37,25 @@ public class Popup : AvaloniaPopup,
|
||||
public static readonly StyledProperty<double> MarginToAnchorProperty =
|
||||
AvaloniaProperty.Register<Popup, double>(nameof(MarginToAnchor), 4);
|
||||
|
||||
public static readonly StyledProperty<TimeSpan> MotionDurationProperty
|
||||
= AvaloniaProperty.Register<Popup, TimeSpan>(nameof(MotionDuration));
|
||||
public static readonly StyledProperty<TimeSpan> MotionDurationProperty =
|
||||
AvaloniaProperty.Register<Popup, TimeSpan>(nameof(MotionDuration), TimeSpan.Zero);
|
||||
|
||||
public static readonly StyledProperty<AbstractMotion?> OpenMotionProperty =
|
||||
AvaloniaProperty.Register<Popup, AbstractMotion?>(nameof(OpenMotion));
|
||||
|
||||
public static readonly StyledProperty<AbstractMotion?> CloseMotionProperty =
|
||||
AvaloniaProperty.Register<Popup, AbstractMotion?>(nameof(CloseMotion));
|
||||
|
||||
public static readonly DirectProperty<Popup, bool> IsFlippedProperty =
|
||||
AvaloniaProperty.RegisterDirect<Popup, bool>(nameof(IsFlipped),
|
||||
o => o.IsFlipped,
|
||||
(o, v) => o.IsFlipped = v);
|
||||
|
||||
public static readonly StyledProperty<bool> IsMotionEnabledProperty
|
||||
= MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<Popup>();
|
||||
public static readonly StyledProperty<bool> IsMotionEnabledProperty =
|
||||
MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<Popup>();
|
||||
|
||||
public static readonly StyledProperty<bool> IsWaveSpiritEnabledProperty
|
||||
= WaveSpiritAwareControlProperty.IsWaveSpiritEnabledProperty.AddOwner<Popup>();
|
||||
public static readonly StyledProperty<bool> IsWaveSpiritEnabledProperty =
|
||||
WaveSpiritAwareControlProperty.IsWaveSpiritEnabledProperty.AddOwner<Popup>();
|
||||
|
||||
public BoxShadows MaskShadows
|
||||
{
|
||||
@@ -87,7 +94,18 @@ public class Popup : AvaloniaPopup,
|
||||
get => GetValue(IsWaveSpiritEnabledProperty);
|
||||
set => SetValue(IsWaveSpiritEnabledProperty, value);
|
||||
}
|
||||
|
||||
public AbstractMotion? OpenMotion
|
||||
{
|
||||
get => GetValue(OpenMotionProperty);
|
||||
set => SetValue(OpenMotionProperty, value);
|
||||
}
|
||||
|
||||
public AbstractMotion? CloseMotion
|
||||
{
|
||||
get => GetValue(CloseMotionProperty);
|
||||
set => SetValue(CloseMotionProperty, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 内部属性定义
|
||||
@@ -126,7 +144,6 @@ public class Popup : AvaloniaPopup,
|
||||
AffectsMeasure<Popup>(PlacementProperty);
|
||||
AffectsMeasure<Popup>(PlacementAnchorProperty);
|
||||
AffectsMeasure<Popup>(PlacementGravityProperty);
|
||||
|
||||
IsLightDismissEnabledProperty.OverrideDefaultValue<Popup>(false);
|
||||
}
|
||||
|
||||
@@ -264,6 +281,8 @@ public class Popup : AvaloniaPopup,
|
||||
_buddyLayer = new PopupBuddyLayer(this, topLevel);
|
||||
BindUtils.RelayBind(this, MaskShadowsProperty, _buddyLayer, PopupBuddyLayer.MaskShadowsProperty);
|
||||
BindUtils.RelayBind(this, MotionDurationProperty, _buddyLayer, PopupBuddyLayer.MotionDurationProperty);
|
||||
BindUtils.RelayBind(this, OpenMotionProperty, _buddyLayer, PopupBuddyLayer.OpenMotionProperty);
|
||||
BindUtils.RelayBind(this, CloseMotionProperty, _buddyLayer, PopupBuddyLayer.CloseMotionProperty);
|
||||
}
|
||||
|
||||
internal (bool, bool) CalculateFlipInfo(Size translatedSize, Rect anchorRect, PopupAnchor anchor,
|
||||
|
||||
@@ -20,6 +20,12 @@ internal class PopupBuddyLayer : SceneLayer, IPopupBuddyLayer, IShadowAwareLayer
|
||||
public static readonly StyledProperty<TimeSpan> MotionDurationProperty =
|
||||
Popup.MotionDurationProperty.AddOwner<PopupBuddyLayer>();
|
||||
|
||||
public static readonly StyledProperty<AbstractMotion?> OpenMotionProperty =
|
||||
Popup.OpenMotionProperty.AddOwner<PopupBuddyLayer>();
|
||||
|
||||
public static readonly StyledProperty<AbstractMotion?> CloseMotionProperty =
|
||||
Popup.CloseMotionProperty.AddOwner<PopupBuddyLayer>();
|
||||
|
||||
public BoxShadows MaskShadows
|
||||
{
|
||||
get => GetValue(MaskShadowsProperty);
|
||||
@@ -32,6 +38,18 @@ internal class PopupBuddyLayer : SceneLayer, IPopupBuddyLayer, IShadowAwareLayer
|
||||
set => SetValue(MotionDurationProperty, value);
|
||||
}
|
||||
|
||||
public AbstractMotion? OpenMotion
|
||||
{
|
||||
get => GetValue(OpenMotionProperty);
|
||||
set => SetValue(OpenMotionProperty, value);
|
||||
}
|
||||
|
||||
public AbstractMotion? CloseMotion
|
||||
{
|
||||
get => GetValue(CloseMotionProperty);
|
||||
set => SetValue(CloseMotionProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Popup _buddyPopup;
|
||||
@@ -177,7 +195,11 @@ internal class PopupBuddyLayer : SceneLayer, IPopupBuddyLayer, IShadowAwareLayer
|
||||
_buddyDecorator.Opacity = 0.0d;
|
||||
_buddyDecorator.NotifySceneShowed();
|
||||
aboutToStart?.Invoke();
|
||||
var motion = new ZoomBigInMotion(MotionDuration);
|
||||
var motion = OpenMotion ?? new ZoomBigInMotion();
|
||||
if (MotionDuration != TimeSpan.Zero)
|
||||
{
|
||||
motion.Duration = MotionDuration;
|
||||
}
|
||||
NotifyAboutToRunAttachMotion();
|
||||
motion.Run(_buddyDecorator, null, () =>
|
||||
{
|
||||
@@ -190,7 +212,11 @@ internal class PopupBuddyLayer : SceneLayer, IPopupBuddyLayer, IShadowAwareLayer
|
||||
Action? completedAction = null)
|
||||
{
|
||||
aboutToStart?.Invoke();
|
||||
var motion = new ZoomBigOutMotion(MotionDuration);
|
||||
var motion = CloseMotion ?? new ZoomBigOutMotion();
|
||||
if (MotionDuration != TimeSpan.Zero)
|
||||
{
|
||||
motion.Duration = MotionDuration;
|
||||
}
|
||||
NotifyAboutToRunDetachMotion();
|
||||
motion.Run(_buddyDecorator, null, () =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user