From f891e05e4cf01ff4a0013b1cda0f4b81db4ca3a1 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Tue, 24 Dec 2024 17:41:23 +0800 Subject: [PATCH 1/4] feat:popup animation. --- demo/Semi.Avalonia.Demo/App.axaml | 1 + .../Animations/PopupAnimations.axaml | 47 +++++++++++++++ .../Animations/PopupAnimations.axaml.cs | 8 +++ src/Semi.Avalonia/Controls/Popup.axaml | 14 +++-- ...acementToRenderTransformOriginConverter.cs | 57 +++++++++++++++++++ 5 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 src/Semi.Avalonia/Animations/PopupAnimations.axaml create mode 100644 src/Semi.Avalonia/Animations/PopupAnimations.axaml.cs create mode 100644 src/Semi.Avalonia/Converters/PlacementToRenderTransformOriginConverter.cs diff --git a/demo/Semi.Avalonia.Demo/App.axaml b/demo/Semi.Avalonia.Demo/App.axaml index 1e0383a..f41110b 100644 --- a/demo/Semi.Avalonia.Demo/App.axaml +++ b/demo/Semi.Avalonia.Demo/App.axaml @@ -7,6 +7,7 @@ + diff --git a/src/Semi.Avalonia/Animations/PopupAnimations.axaml b/src/Semi.Avalonia/Animations/PopupAnimations.axaml new file mode 100644 index 0000000..a08d5cf --- /dev/null +++ b/src/Semi.Avalonia/Animations/PopupAnimations.axaml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + diff --git a/src/Semi.Avalonia/Animations/PopupAnimations.axaml.cs b/src/Semi.Avalonia/Animations/PopupAnimations.axaml.cs new file mode 100644 index 0000000..4172c6d --- /dev/null +++ b/src/Semi.Avalonia/Animations/PopupAnimations.axaml.cs @@ -0,0 +1,8 @@ +using Avalonia.Styling; + +namespace Semi.Avalonia; + +public class PopupAnimations: Styles +{ + +} \ No newline at end of file diff --git a/src/Semi.Avalonia/Controls/Popup.axaml b/src/Semi.Avalonia/Controls/Popup.axaml index 15b6636..7a5208b 100644 --- a/src/Semi.Avalonia/Controls/Popup.axaml +++ b/src/Semi.Avalonia/Controls/Popup.axaml @@ -11,12 +11,14 @@ - + + + diff --git a/src/Semi.Avalonia/Converters/PlacementToRenderTransformOriginConverter.cs b/src/Semi.Avalonia/Converters/PlacementToRenderTransformOriginConverter.cs new file mode 100644 index 0000000..a370678 --- /dev/null +++ b/src/Semi.Avalonia/Converters/PlacementToRenderTransformOriginConverter.cs @@ -0,0 +1,57 @@ +using System; +using System.Globalization; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Data.Converters; + +namespace Semi.Avalonia.Converters; + +public class PlacementToRenderTransformOriginConverter: IValueConverter +{ + public static PlacementToRenderTransformOriginConverter Instance { get; } = new PlacementToRenderTransformOriginConverter(); + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is not PlacementMode p) + { + return new RelativePoint(0.5, 0.5, RelativeUnit.Relative); + } + switch (p) + { + case PlacementMode.Bottom: + return new RelativePoint(0.5, 0.0, RelativeUnit.Relative); + case PlacementMode.Left: + return new RelativePoint(1.0, 0.5, RelativeUnit.Relative); + case PlacementMode.Right: + return new RelativePoint(0.0, 0.5, RelativeUnit.Relative); + case PlacementMode.Top: + return new RelativePoint(0.5, 1.0, RelativeUnit.Relative); + case PlacementMode.Pointer: + return new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + case PlacementMode.Center: + case PlacementMode.AnchorAndGravity: + return new RelativePoint(0.5, 0.5, RelativeUnit.Relative); + case PlacementMode.BottomEdgeAlignedLeft: + return new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + case PlacementMode.BottomEdgeAlignedRight: + return new RelativePoint(1.0, 0.0, RelativeUnit.Relative); + case PlacementMode.LeftEdgeAlignedTop: + return new RelativePoint(1.0, 1.0, RelativeUnit.Relative); + case PlacementMode.LeftEdgeAlignedBottom: + return new RelativePoint(1.0, 0.0, RelativeUnit.Relative); + case PlacementMode.RightEdgeAlignedTop: + return new RelativePoint(0.0, 1.0, RelativeUnit.Relative); + case PlacementMode.RightEdgeAlignedBottom: + return new RelativePoint(0.0, 0.0, RelativeUnit.Relative); + case PlacementMode.TopEdgeAlignedLeft: + return new RelativePoint(0.0, 1.0, RelativeUnit.Relative); + case PlacementMode.TopEdgeAlignedRight: + return new RelativePoint(1.0, 1.0, RelativeUnit.Relative); + } + return new RelativePoint(0.5, 0.5, RelativeUnit.Relative); + } + + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } +} \ No newline at end of file From f71e2630bb6e67a271385f4ebeea07e33234da6b Mon Sep 17 00:00:00 2001 From: rabbitism Date: Tue, 24 Dec 2024 18:06:40 +0800 Subject: [PATCH 2/4] feat: implement for overlaypopup. change name. --- demo/Semi.Avalonia.Demo/App.axaml | 2 +- ...mations.axaml => SemiPopupAnimations.axaml} | 18 +++++++++--------- ...s.axaml.cs => SemiPopupAnimations.axaml.cs} | 2 +- src/Semi.Avalonia/Controls/Popup.axaml | 14 ++++++++------ 4 files changed, 19 insertions(+), 17 deletions(-) rename src/Semi.Avalonia/Animations/{PopupAnimations.axaml => SemiPopupAnimations.axaml} (88%) rename src/Semi.Avalonia/Animations/{PopupAnimations.axaml.cs => SemiPopupAnimations.axaml.cs} (59%) diff --git a/demo/Semi.Avalonia.Demo/App.axaml b/demo/Semi.Avalonia.Demo/App.axaml index f41110b..c3605fa 100644 --- a/demo/Semi.Avalonia.Demo/App.axaml +++ b/demo/Semi.Avalonia.Demo/App.axaml @@ -7,7 +7,7 @@ - + diff --git a/src/Semi.Avalonia/Animations/PopupAnimations.axaml b/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml similarity index 88% rename from src/Semi.Avalonia/Animations/PopupAnimations.axaml rename to src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml index a08d5cf..ff1486a 100644 --- a/src/Semi.Avalonia/Animations/PopupAnimations.axaml +++ b/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml @@ -1,5 +1,5 @@ @@ -18,10 +18,10 @@ diff --git a/src/Semi.Avalonia/Animations/PopupAnimations.axaml.cs b/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml.cs similarity index 59% rename from src/Semi.Avalonia/Animations/PopupAnimations.axaml.cs rename to src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml.cs index 4172c6d..00d769e 100644 --- a/src/Semi.Avalonia/Animations/PopupAnimations.axaml.cs +++ b/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml.cs @@ -2,7 +2,7 @@ using Avalonia.Styling; namespace Semi.Avalonia; -public class PopupAnimations: Styles +public class SemiPopupAnimations: Styles { } \ No newline at end of file diff --git a/src/Semi.Avalonia/Controls/Popup.axaml b/src/Semi.Avalonia/Controls/Popup.axaml index 7a5208b..e8b6037 100644 --- a/src/Semi.Avalonia/Controls/Popup.axaml +++ b/src/Semi.Avalonia/Controls/Popup.axaml @@ -31,12 +31,14 @@ - + + + From c437e6c79c272969bb76eefb2215359e5f7a6549 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Tue, 24 Dec 2024 18:26:55 +0800 Subject: [PATCH 3/4] feat: remove useless style for flyout. --- src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml b/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml index ff1486a..61a7660 100644 --- a/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml +++ b/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml @@ -12,9 +12,6 @@ - - + - + \ No newline at end of file