From 4e6e2a083a10173917154529b79b8aba18ab0023 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Sat, 15 Jun 2024 21:57:10 +0800 Subject: [PATCH 01/16] feat: initialize. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 9 +++++ demo/Ursa.Demo/Pages/AvatarDemo.axaml.cs | 13 +++++++ .../ViewModels/AvatarDemoViewModel.cs | 6 +++ .../Ursa.Demo/ViewModels/MainViewViewModel.cs | 1 + demo/Ursa.Demo/ViewModels/MenuViewModel.cs | 2 + src/Ursa.Themes.Semi/Controls/Avatar.axaml | 7 ++++ src/Ursa.Themes.Semi/Controls/_index.axaml | 1 + src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml | 2 + src/Ursa.Themes.Semi/Themes/Dark/_index.axaml | 1 + .../Themes/Light/Avatar.axaml | 2 + .../Themes/Light/_index.axaml | 1 + .../Themes/Shared/Avatar.axaml | 2 + .../Themes/Shared/_index.axaml | 1 + src/Ursa/Controls/Avatar/Avatar.cs | 38 +++++++++++++++++++ src/Ursa/Controls/Avatar/AvatarGroup.cs | 33 ++++++++++++++++ 15 files changed, 119 insertions(+) create mode 100644 demo/Ursa.Demo/Pages/AvatarDemo.axaml create mode 100644 demo/Ursa.Demo/Pages/AvatarDemo.axaml.cs create mode 100644 demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs create mode 100644 src/Ursa.Themes.Semi/Controls/Avatar.axaml create mode 100644 src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml create mode 100644 src/Ursa.Themes.Semi/Themes/Light/Avatar.axaml create mode 100644 src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml create mode 100644 src/Ursa/Controls/Avatar/Avatar.cs create mode 100644 src/Ursa/Controls/Avatar/AvatarGroup.cs diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml new file mode 100644 index 0000000..be6ed45 --- /dev/null +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml.cs b/demo/Ursa.Demo/Pages/AvatarDemo.axaml.cs new file mode 100644 index 0000000..5bc2485 --- /dev/null +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Ursa.Demo.Pages; + +public partial class AvatarDemo : UserControl +{ + public AvatarDemo() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs new file mode 100644 index 0000000..cf968aa --- /dev/null +++ b/demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs @@ -0,0 +1,6 @@ +namespace Ursa.Demo.ViewModels; + +public class AvatarDemoViewModel: ViewModelBase +{ + +} \ No newline at end of file diff --git a/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs b/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs index 1baf568..d995db0 100644 --- a/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs @@ -25,6 +25,7 @@ public class MainViewViewModel : ViewModelBase Content = s switch { MenuKeys.MenuKeyIntroduction => new IntroductionDemoViewModel(), + MenuKeys.MenuKeyAvatar => new AvatarDemoViewModel(), MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(), MenuKeys.MenuKeyBanner => new BannerDemoViewModel(), MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(), diff --git a/demo/Ursa.Demo/ViewModels/MenuViewModel.cs b/demo/Ursa.Demo/ViewModels/MenuViewModel.cs index e196a85..c839bfb 100644 --- a/demo/Ursa.Demo/ViewModels/MenuViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/MenuViewModel.cs @@ -12,6 +12,7 @@ public class MenuViewModel: ViewModelBase { new() { MenuHeader = "Introduction", Key = MenuKeys.MenuKeyIntroduction, IsSeparator = false }, new() { MenuHeader = "Controls", IsSeparator = true }, + new() { MenuHeader = "Avatar", Key = MenuKeys.MenuKeyAvatar, Status = "WIP"}, new() { MenuHeader = "Badge", Key = MenuKeys.MenuKeyBadge }, new() { MenuHeader = "Banner", Key = MenuKeys.MenuKeyBanner }, new() { MenuHeader = "Breadcrumb", Key = MenuKeys.MenuKeyBreadcrumb }, @@ -59,6 +60,7 @@ public class MenuViewModel: ViewModelBase public static class MenuKeys { public const string MenuKeyIntroduction = "Introduction"; + public const string MenuKeyAvatar = "Avatar"; public const string MenuKeyBadge = "Badge"; public const string MenuKeyBanner = "Banner"; public const string MenuKeyButtonGroup = "ButtonGroup"; diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml new file mode 100644 index 0000000..5324a77 --- /dev/null +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/_index.axaml b/src/Ursa.Themes.Semi/Controls/_index.axaml index 4d7ae82..9e4a4ba 100644 --- a/src/Ursa.Themes.Semi/Controls/_index.axaml +++ b/src/Ursa.Themes.Semi/Controls/_index.axaml @@ -1,6 +1,7 @@ + diff --git a/src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml b/src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml new file mode 100644 index 0000000..c9ef25a --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml @@ -0,0 +1,2 @@ + + diff --git a/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml b/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml index 86727f2..cf02f07 100644 --- a/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml @@ -1,6 +1,7 @@ + diff --git a/src/Ursa.Themes.Semi/Themes/Light/Avatar.axaml b/src/Ursa.Themes.Semi/Themes/Light/Avatar.axaml new file mode 100644 index 0000000..c9ef25a --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Light/Avatar.axaml @@ -0,0 +1,2 @@ + + diff --git a/src/Ursa.Themes.Semi/Themes/Light/_index.axaml b/src/Ursa.Themes.Semi/Themes/Light/_index.axaml index 86727f2..cf02f07 100644 --- a/src/Ursa.Themes.Semi/Themes/Light/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Light/_index.axaml @@ -1,6 +1,7 @@ + diff --git a/src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml b/src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml new file mode 100644 index 0000000..c9ef25a --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml @@ -0,0 +1,2 @@ + + diff --git a/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml b/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml index 5350d09..a11acac 100644 --- a/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml @@ -1,6 +1,7 @@ + diff --git a/src/Ursa/Controls/Avatar/Avatar.cs b/src/Ursa/Controls/Avatar/Avatar.cs new file mode 100644 index 0000000..d10361e --- /dev/null +++ b/src/Ursa/Controls/Avatar/Avatar.cs @@ -0,0 +1,38 @@ +using Avalonia; +using Avalonia.Controls; + +namespace Ursa.Controls; + +public class Avatar : Button +{ + public const string PART_TopPresenter = "PART_TopPresenter"; + public const string PART_BottomPresenter = "PART_BottomPresenter"; + public const string PART_HoverMask = "PART_HoverMask"; + + public static readonly StyledProperty ContentMotionProperty = AvaloniaProperty.Register( + nameof(ContentMotion)); + + public static readonly StyledProperty GapProperty = AvaloniaProperty.Register( + nameof(Gap)); + + public static readonly StyledProperty SourceProperty = AvaloniaProperty.Register( + nameof(Source)); + + public bool ContentMotion + { + get => GetValue(ContentMotionProperty); + set => SetValue(ContentMotionProperty, value); + } + + public double Gap + { + get => GetValue(GapProperty); + set => SetValue(GapProperty, value); + } + + public string Source + { + get => GetValue(SourceProperty); + set => SetValue(SourceProperty, value); + } +} \ No newline at end of file diff --git a/src/Ursa/Controls/Avatar/AvatarGroup.cs b/src/Ursa/Controls/Avatar/AvatarGroup.cs new file mode 100644 index 0000000..60e86b7 --- /dev/null +++ b/src/Ursa/Controls/Avatar/AvatarGroup.cs @@ -0,0 +1,33 @@ +using Avalonia; +using Avalonia.Controls; + +namespace Ursa.Controls; + +public class AvatarGroup : ItemsControl +{ + public const string PART_RenderMore = "PART_RenderMore"; + + public static readonly StyledProperty MaxCountProperty = AvaloniaProperty.Register( + nameof(MaxCount)); + + public static readonly StyledProperty OverlapFromProperty = AvaloniaProperty.Register( + nameof(OverlapFrom)); + + public int MaxCount + { + get => GetValue(MaxCountProperty); + set => SetValue(MaxCountProperty, value); + } + + public OverlapFromType OverlapFrom + { + get => GetValue(OverlapFromProperty); + set => SetValue(OverlapFromProperty, value); + } +} + +public enum OverlapFromType +{ + Start, + End +} \ No newline at end of file From 8cbe044953649c11680801a4db0629c78626ecef Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Tue, 18 Jun 2024 22:51:50 +0800 Subject: [PATCH 02/16] feat: basic shape. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 9 ++++++- .../ViewModels/AvatarDemoViewModel.cs | 16 +++++++++--- src/Ursa.Themes.Semi/Controls/Avatar.axaml | 26 ++++++++++++++++++- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index be6ed45..620d1bf 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -3,7 +3,14 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:u="https://irihi.tech/ursa" + xmlns:vm="clr-namespace:Ursa.Demo.ViewModels" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Ursa.Demo.Pages.AvatarDemo"> - + + + + + + \ No newline at end of file diff --git a/demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs index cf968aa..6717d41 100644 --- a/demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs @@ -1,6 +1,16 @@ -namespace Ursa.Demo.ViewModels; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; -public class AvatarDemoViewModel: ViewModelBase +namespace Ursa.Demo.ViewModels; + +public partial class AvatarDemoViewModel : ViewModelBase { - + [ObservableProperty] private string _content = "AS"; + [ObservableProperty] private bool _canClick = true; + + [RelayCommand(CanExecute = nameof(CanClick))] + private void Click() + { + Content = "BM"; + } } \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml index 5324a77..3352ca3 100644 --- a/src/Ursa.Themes.Semi/Controls/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -2,6 +2,30 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:u="https://irihi.tech/ursa"> - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 395d67500a40930fdbfe46fcaad512974b10fa2a Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Wed, 19 Jun 2024 00:18:56 +0800 Subject: [PATCH 03/16] feat: Source & HoverMask. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 23 ++++++++++++++++++++-- src/Ursa.Themes.Semi/Controls/Avatar.axaml | 16 ++++++++++++++- src/Ursa/Controls/Avatar/Avatar.cs | 17 ++++++++++++++-- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index 620d1bf..3fbab78 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -9,8 +9,27 @@ - + + M7.44721 3.10557C7.786 2.428 8.47852 2 9.23607 2H14.7639C15.5215 2 16.214 2.428 16.5528 3.10557L17.5 5H20C21.6569 5 23 6.34315 23 8V18C23 19.6569 21.6569 21 20 21H4C2.34315 21 1 19.6569 1 18V8C1 6.34315 2.34315 5 4 5H6.5L7.44721 3.10557ZM9 13C9 11.3431 10.3431 10 12 10C13.6569 10 15 11.3431 15 13C15 14.6569 13.6569 16 12 16C10.3431 16 9 14.6569 9 13ZM12 8C9.23858 8 7 10.2386 7 13C7 15.7614 9.23858 18 12 18C14.7614 18 17 15.7614 17 13C17 10.2386 14.7614 8 12 8Z + + + Command="{Binding ClickCommand}" /> + + + + + + + + + + + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml index 3352ca3..5040e88 100644 --- a/src/Ursa.Themes.Semi/Controls/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -12,13 +12,24 @@ - + + + @@ -26,6 +37,9 @@ + \ No newline at end of file diff --git a/src/Ursa/Controls/Avatar/Avatar.cs b/src/Ursa/Controls/Avatar/Avatar.cs index d10361e..d198aa1 100644 --- a/src/Ursa/Controls/Avatar/Avatar.cs +++ b/src/Ursa/Controls/Avatar/Avatar.cs @@ -1,8 +1,12 @@ using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.Metadata; +using Avalonia.Controls.Presenters; +using Avalonia.Media; namespace Ursa.Controls; +[TemplatePart(PART_HoverMask, typeof(ContentPresenter))] public class Avatar : Button { public const string PART_TopPresenter = "PART_TopPresenter"; @@ -15,9 +19,12 @@ public class Avatar : Button public static readonly StyledProperty GapProperty = AvaloniaProperty.Register( nameof(Gap)); - public static readonly StyledProperty SourceProperty = AvaloniaProperty.Register( + public static readonly StyledProperty SourceProperty = AvaloniaProperty.Register( nameof(Source)); + public static readonly StyledProperty HoverMaskProperty = AvaloniaProperty.Register( + nameof(HoverMask)); + public bool ContentMotion { get => GetValue(ContentMotionProperty); @@ -30,9 +37,15 @@ public class Avatar : Button set => SetValue(GapProperty, value); } - public string Source + public IImage? Source { get => GetValue(SourceProperty); set => SetValue(SourceProperty, value); } + + public object? HoverMask + { + get => GetValue(HoverMaskProperty); + set => SetValue(HoverMaskProperty, value); + } } \ No newline at end of file From 0cd2e41bec63f6d79b5b5ac26bcdd5720e2ca18c Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Wed, 19 Jun 2024 00:54:14 +0800 Subject: [PATCH 04/16] feat: color & size. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 69 +++++++++++++----- src/Ursa.Themes.Semi/Controls/Avatar.axaml | 85 +++++++++++++++++++++- 2 files changed, 132 insertions(+), 22 deletions(-) diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index 3fbab78..e5aac1a 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -12,24 +12,55 @@ M7.44721 3.10557C7.786 2.428 8.47852 2 9.23607 2H14.7639C15.5215 2 16.214 2.428 16.5528 3.10557L17.5 5H20C21.6569 5 23 6.34315 23 8V18C23 19.6569 21.6569 21 20 21H4C2.34315 21 1 19.6569 1 18V8C1 6.34315 2.34315 5 4 5H6.5L7.44721 3.10557ZM9 13C9 11.3431 10.3431 10 12 10C13.6569 10 15 11.3431 15 13C15 14.6569 13.6569 16 12 16C10.3431 16 9 14.6569 9 13ZM12 8C9.23858 8 7 10.2386 7 13C7 15.7614 9.23858 18 12 18C14.7614 18 17 15.7614 17 13C17 10.2386 14.7614 8 12 8Z - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml index 5040e88..4c353f7 100644 --- a/src/Ursa.Themes.Semi/Controls/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -4,10 +4,11 @@ xmlns:u="https://irihi.tech/ursa"> - + - + + @@ -38,7 +39,85 @@ + + + + + + + + + + + + + + + + + + + + + + + From 83c4e075791edbeeab8c5777b61e733b1ad16ebf Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Wed, 19 Jun 2024 13:44:10 +0800 Subject: [PATCH 05/16] feat: Clip. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 2 ++ src/Ursa.Themes.Semi/Controls/Avatar.axaml | 17 +++++++++++++--- src/Ursa/Converters/DivideByTwoConverter.cs | 22 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/Ursa/Converters/DivideByTwoConverter.cs diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index e5aac1a..f8459f5 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -34,6 +34,8 @@ + + diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml index 4c353f7..0714791 100644 --- a/src/Ursa.Themes.Semi/Controls/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -1,7 +1,9 @@  + xmlns:u="https://irihi.tech/ursa" + xmlns:converters="clr-namespace:Ursa.Converters;assembly=Ursa"> + @@ -13,12 +15,21 @@ + + + + + IsVisible="{TemplateBinding Source, Converter={x:Static ObjectConverters.IsNull}}" /> Date: Thu, 20 Jun 2024 16:14:05 +0800 Subject: [PATCH 06/16] feat: simple avatar group. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 9 +++++++++ src/Ursa.Themes.Semi/Controls/Avatar.axaml | 13 +++++++++---- src/Ursa/Controls/Avatar/AvatarGroup.cs | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index f8459f5..a561b3b 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -64,5 +64,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml index 0714791..0f5676c 100644 --- a/src/Ursa.Themes.Semi/Controls/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -21,9 +21,7 @@ RadiusX="{Binding #PART_Ellipse.Bounds.Width, Converter={StaticResource DivideByTwoConverter}}" RadiusY="{Binding #PART_Ellipse.Bounds.Height, Converter={StaticResource DivideByTwoConverter}}" /> - + @@ -131,5 +129,12 @@ - + + + + + + + + \ No newline at end of file diff --git a/src/Ursa/Controls/Avatar/AvatarGroup.cs b/src/Ursa/Controls/Avatar/AvatarGroup.cs index 60e86b7..300a3f6 100644 --- a/src/Ursa/Controls/Avatar/AvatarGroup.cs +++ b/src/Ursa/Controls/Avatar/AvatarGroup.cs @@ -1,5 +1,7 @@ using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.Templates; +using Avalonia.Layout; namespace Ursa.Controls; @@ -7,11 +9,15 @@ public class AvatarGroup : ItemsControl { public const string PART_RenderMore = "PART_RenderMore"; + private static readonly FuncTemplate DefaultPanel = + new(() => new StackPanel { Orientation = Orientation.Horizontal }); + public static readonly StyledProperty MaxCountProperty = AvaloniaProperty.Register( nameof(MaxCount)); - public static readonly StyledProperty OverlapFromProperty = AvaloniaProperty.Register( - nameof(OverlapFrom)); + public static readonly StyledProperty OverlapFromProperty = + AvaloniaProperty.Register( + nameof(OverlapFrom)); public int MaxCount { @@ -24,6 +30,11 @@ public class AvatarGroup : ItemsControl get => GetValue(OverlapFromProperty); set => SetValue(OverlapFromProperty, value); } + + static AvatarGroup() + { + ItemsPanelProperty.OverrideDefaultValue(DefaultPanel); + } } public enum OverlapFromType From f7a5032f8d395985d31b72eaeb2eb94e5805a0d5 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:38:20 +0800 Subject: [PATCH 07/16] feat: simple AvatarGroupPanel. --- src/Ursa/Controls/Avatar/AvatarGroup.cs | 3 +- src/Ursa/Controls/Avatar/AvatarGroupPanel.cs | 46 ++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/Ursa/Controls/Avatar/AvatarGroupPanel.cs diff --git a/src/Ursa/Controls/Avatar/AvatarGroup.cs b/src/Ursa/Controls/Avatar/AvatarGroup.cs index 300a3f6..d2f236a 100644 --- a/src/Ursa/Controls/Avatar/AvatarGroup.cs +++ b/src/Ursa/Controls/Avatar/AvatarGroup.cs @@ -1,7 +1,6 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Templates; -using Avalonia.Layout; namespace Ursa.Controls; @@ -10,7 +9,7 @@ public class AvatarGroup : ItemsControl public const string PART_RenderMore = "PART_RenderMore"; private static readonly FuncTemplate DefaultPanel = - new(() => new StackPanel { Orientation = Orientation.Horizontal }); + new(() => new AvatarGroupPanel()); public static readonly StyledProperty MaxCountProperty = AvaloniaProperty.Register( nameof(MaxCount)); diff --git a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs new file mode 100644 index 0000000..324f523 --- /dev/null +++ b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs @@ -0,0 +1,46 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Interactivity; + +namespace Ursa.Controls; + +public class AvatarGroupPanel : Panel +{ + protected override Size MeasureOverride(Size availableSize) + { + Size size = new Size(); + availableSize = availableSize.WithWidth(double.PositiveInfinity); + var children = Children; + foreach (var child in children) + { + child.Measure(availableSize); + Size desiredSize = child.DesiredSize; + size = size.WithWidth(size.Width + desiredSize.Width); + size = size.WithHeight(Math.Max(size.Height, desiredSize.Height)); + } + + size = size.WithWidth(size.Width); + return size; + } + + protected override Size ArrangeOverride(Size finalSize) + { + Rect rect = new Rect(finalSize); + double num = 0d; + var children = Children; + foreach (var child in children) + { + Size desiredSize = child.DesiredSize; + double width = desiredSize.Width; + double height = Math.Max(desiredSize.Height, finalSize.Height); + rect = rect.WithX(rect.X + num); + rect = rect.WithWidth(width); + rect = rect.WithHeight(height); + num = width; + child.Arrange(rect); + } + + RaiseEvent(new RoutedEventArgs(StackPanel.HorizontalSnapPointsChangedEvent)); + return finalSize; + } +} \ No newline at end of file From abb9ec51bb8821e6b92af5f244daf9bc03619244 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Thu, 20 Jun 2024 20:54:02 +0800 Subject: [PATCH 08/16] feat: stack elements. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 1 + src/Ursa/Controls/Avatar/AvatarGroup.cs | 3 +-- src/Ursa/Controls/Avatar/AvatarGroupPanel.cs | 15 ++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index a561b3b..bf36a75 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -72,6 +72,7 @@ + \ No newline at end of file diff --git a/src/Ursa/Controls/Avatar/AvatarGroup.cs b/src/Ursa/Controls/Avatar/AvatarGroup.cs index d2f236a..fbd4e84 100644 --- a/src/Ursa/Controls/Avatar/AvatarGroup.cs +++ b/src/Ursa/Controls/Avatar/AvatarGroup.cs @@ -8,8 +8,7 @@ public class AvatarGroup : ItemsControl { public const string PART_RenderMore = "PART_RenderMore"; - private static readonly FuncTemplate DefaultPanel = - new(() => new AvatarGroupPanel()); + private static readonly FuncTemplate DefaultPanel = new(() => new AvatarGroupPanel()); public static readonly StyledProperty MaxCountProperty = AvaloniaProperty.Register( nameof(MaxCount)); diff --git a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs index 324f523..4f02108 100644 --- a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs +++ b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs @@ -11,12 +11,13 @@ public class AvatarGroupPanel : Panel Size size = new Size(); availableSize = availableSize.WithWidth(double.PositiveInfinity); var children = Children; - foreach (var child in children) + if (children.Count > 0) { - child.Measure(availableSize); - Size desiredSize = child.DesiredSize; - size = size.WithWidth(size.Width + desiredSize.Width); - size = size.WithHeight(Math.Max(size.Height, desiredSize.Height)); + children[0].Measure(availableSize); + Size first = children[0].DesiredSize; + var width = first.Width + first.Width * (children.Count - 1) * 0.75; + size = size.WithWidth(width); + size = size.WithHeight(first.Height); } size = size.WithWidth(size.Width); @@ -30,17 +31,17 @@ public class AvatarGroupPanel : Panel var children = Children; foreach (var child in children) { + child.Measure(finalSize); Size desiredSize = child.DesiredSize; double width = desiredSize.Width; double height = Math.Max(desiredSize.Height, finalSize.Height); rect = rect.WithX(rect.X + num); rect = rect.WithWidth(width); rect = rect.WithHeight(height); - num = width; + num = width * 0.75; child.Arrange(rect); } - RaiseEvent(new RoutedEventArgs(StackPanel.HorizontalSnapPointsChangedEvent)); return finalSize; } } \ No newline at end of file From c49be02e829cf06bdbbe804908957e14367e8bb8 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Thu, 20 Jun 2024 21:40:47 +0800 Subject: [PATCH 09/16] feat: OverlapFormType. --- src/Ursa/Controls/Avatar/AvatarGroup.cs | 2 +- src/Ursa/Controls/Avatar/AvatarGroupPanel.cs | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Ursa/Controls/Avatar/AvatarGroup.cs b/src/Ursa/Controls/Avatar/AvatarGroup.cs index fbd4e84..340b2c6 100644 --- a/src/Ursa/Controls/Avatar/AvatarGroup.cs +++ b/src/Ursa/Controls/Avatar/AvatarGroup.cs @@ -15,7 +15,7 @@ public class AvatarGroup : ItemsControl public static readonly StyledProperty OverlapFromProperty = AvaloniaProperty.Register( - nameof(OverlapFrom)); + nameof(OverlapFrom), defaultValue: OverlapFromType.Start); public int MaxCount { diff --git a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs index 4f02108..cfc24fb 100644 --- a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs +++ b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs @@ -1,6 +1,6 @@ using Avalonia; using Avalonia.Controls; -using Avalonia.Interactivity; +using Avalonia.LogicalTree; namespace Ursa.Controls; @@ -28,18 +28,25 @@ public class AvatarGroupPanel : Panel { Rect rect = new Rect(finalSize); double num = 0d; + var group = this.GetLogicalAncestors().OfType().FirstOrDefault(); + var overlapFrom = group?.OverlapFrom; var children = Children; - foreach (var child in children) + for (var i = 0; i < children.Count; i++) { - child.Measure(finalSize); - Size desiredSize = child.DesiredSize; + if (overlapFrom is OverlapFromType.Start) + { + children[i].ZIndex = children.Count - i; + } + + children[i].Measure(finalSize); + Size desiredSize = children[i].DesiredSize; double width = desiredSize.Width; double height = Math.Max(desiredSize.Height, finalSize.Height); rect = rect.WithX(rect.X + num); rect = rect.WithWidth(width); rect = rect.WithHeight(height); num = width * 0.75; - child.Arrange(rect); + children[i].Arrange(rect); } return finalSize; From 29dab32b921dd4984cd3406064cd40afec7b6abb Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Sun, 23 Jun 2024 22:01:01 +0800 Subject: [PATCH 10/16] feat: maxCount. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 2 +- src/Ursa/Controls/Avatar/AvatarGroup.cs | 4 +-- src/Ursa/Controls/Avatar/AvatarGroupPanel.cs | 37 +++++++++++++++----- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index bf36a75..7605f6b 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -65,7 +65,7 @@ - + diff --git a/src/Ursa/Controls/Avatar/AvatarGroup.cs b/src/Ursa/Controls/Avatar/AvatarGroup.cs index 340b2c6..0609367 100644 --- a/src/Ursa/Controls/Avatar/AvatarGroup.cs +++ b/src/Ursa/Controls/Avatar/AvatarGroup.cs @@ -10,14 +10,14 @@ public class AvatarGroup : ItemsControl private static readonly FuncTemplate DefaultPanel = new(() => new AvatarGroupPanel()); - public static readonly StyledProperty MaxCountProperty = AvaloniaProperty.Register( + public static readonly StyledProperty MaxCountProperty = AvaloniaProperty.Register( nameof(MaxCount)); public static readonly StyledProperty OverlapFromProperty = AvaloniaProperty.Register( nameof(OverlapFrom), defaultValue: OverlapFromType.Start); - public int MaxCount + public int? MaxCount { get => GetValue(MaxCountProperty); set => SetValue(MaxCountProperty, value); diff --git a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs index cfc24fb..9ad3e97 100644 --- a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs +++ b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs @@ -11,16 +11,19 @@ public class AvatarGroupPanel : Panel Size size = new Size(); availableSize = availableSize.WithWidth(double.PositiveInfinity); var children = Children; - if (children.Count > 0) + if (children.Count <= 0) return size; + children[0].Measure(availableSize); + Size first = children[0].DesiredSize; + var group = this.GetLogicalAncestors().OfType().FirstOrDefault(); + var count = children.Count; + if (group?.MaxCount is not null && group.MaxCount >= 0) { - children[0].Measure(availableSize); - Size first = children[0].DesiredSize; - var width = first.Width + first.Width * (children.Count - 1) * 0.75; - size = size.WithWidth(width); - size = size.WithHeight(first.Height); + count = group.MaxCount.Value + 1; } - size = size.WithWidth(size.Width); + var width = first.Width + first.Width * (count - 1) * 0.75; + size = size.WithWidth(width); + size = size.WithHeight(first.Height); return size; } @@ -28,10 +31,18 @@ public class AvatarGroupPanel : Panel { Rect rect = new Rect(finalSize); double num = 0d; + var children = Children; var group = this.GetLogicalAncestors().OfType().FirstOrDefault(); var overlapFrom = group?.OverlapFrom; - var children = Children; - for (var i = 0; i < children.Count; i++) + int? maxCount = null; + var count = children.Count; + if (group?.MaxCount is not null && group.MaxCount >= 0) + { + maxCount = group.MaxCount; + count = maxCount.Value + 1; + } + + for (var i = 0; i < count; i++) { if (overlapFrom is OverlapFromType.Start) { @@ -49,6 +60,14 @@ public class AvatarGroupPanel : Panel children[i].Arrange(rect); } + if (maxCount is not null && children.Count > 0) + { + if (children[maxCount.Value] is Avatar avatar) + { + avatar.Content = $"+{children.Count - maxCount}"; + } + } + return finalSize; } } \ No newline at end of file From e3c85d80ef144c9aa17f18a06f2bd1ad48f3aca8 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Mon, 24 Jun 2024 15:58:26 +0800 Subject: [PATCH 11/16] feat: square. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 9 +++ src/Ursa.Themes.Semi/Controls/Avatar.axaml | 74 +++++++++++++--------- 2 files changed, 52 insertions(+), 31 deletions(-) diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index 7605f6b..43b2a5f 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -64,6 +64,15 @@ + + + + + + + + + diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml index 0f5676c..2651563 100644 --- a/src/Ursa.Themes.Semi/Controls/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -12,39 +12,40 @@ + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + From 2ad7aa62d5a72c9f77aa3a90d20badd286ab6857 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Mon, 24 Jun 2024 23:07:04 +0800 Subject: [PATCH 12/16] feat: prepare for RenderMore. --- src/Ursa/Controls/Avatar/AvatarGroupPanel.cs | 35 ++++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs index 9ad3e97..40620d8 100644 --- a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs +++ b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs @@ -8,23 +8,22 @@ public class AvatarGroupPanel : Panel { protected override Size MeasureOverride(Size availableSize) { - Size size = new Size(); - availableSize = availableSize.WithWidth(double.PositiveInfinity); var children = Children; - if (children.Count <= 0) return size; + if (children.Count <= 0) return new Size(); + + availableSize = availableSize.WithWidth(double.PositiveInfinity); children[0].Measure(availableSize); Size first = children[0].DesiredSize; var group = this.GetLogicalAncestors().OfType().FirstOrDefault(); + var maxCount = group?.MaxCount; var count = children.Count; - if (group?.MaxCount is not null && group.MaxCount >= 0) + if (maxCount >= 0 && maxCount < count) { - count = group.MaxCount.Value + 1; + count = maxCount.Value + 1; } var width = first.Width + first.Width * (count - 1) * 0.75; - size = size.WithWidth(width); - size = size.WithHeight(first.Height); - return size; + return new Size(width, first.Height); } protected override Size ArrangeOverride(Size finalSize) @@ -34,19 +33,14 @@ public class AvatarGroupPanel : Panel var children = Children; var group = this.GetLogicalAncestors().OfType().FirstOrDefault(); var overlapFrom = group?.OverlapFrom; - int? maxCount = null; - var count = children.Count; - if (group?.MaxCount is not null && group.MaxCount >= 0) - { - maxCount = group.MaxCount; - count = maxCount.Value + 1; - } - + var maxCount = group?.MaxCount; + var childrenCount = children.Count; + var count = maxCount < childrenCount ? maxCount.Value : childrenCount; for (var i = 0; i < count; i++) { if (overlapFrom is OverlapFromType.Start) { - children[i].ZIndex = children.Count - i; + children[i].ZIndex = childrenCount - i; } children[i].Measure(finalSize); @@ -60,12 +54,9 @@ public class AvatarGroupPanel : Panel children[i].Arrange(rect); } - if (maxCount is not null && children.Count > 0) + if (maxCount is not null) { - if (children[maxCount.Value] is Avatar avatar) - { - avatar.Content = $"+{children.Count - maxCount}"; - } + //TODO: RenderMore } return finalSize; From 4e08c2a38dae07f8b88f886c3d02ac09c639f594 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:12:30 +0800 Subject: [PATCH 13/16] feat: remove unimplemented features. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 10 --- src/Ursa.Themes.Semi/Controls/Avatar.axaml | 14 +---- src/Ursa/Controls/Avatar/Avatar.cs | 25 -------- src/Ursa/Controls/Avatar/AvatarGroup.cs | 42 ------------- src/Ursa/Controls/Avatar/AvatarGroupPanel.cs | 64 -------------------- 5 files changed, 1 insertion(+), 154 deletions(-) delete mode 100644 src/Ursa/Controls/Avatar/AvatarGroup.cs delete mode 100644 src/Ursa/Controls/Avatar/AvatarGroupPanel.cs diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index 43b2a5f..9f5ba46 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -73,15 +73,5 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml index 2651563..10607dc 100644 --- a/src/Ursa.Themes.Semi/Controls/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -33,17 +33,13 @@ HorizontalContentAlignment="Center" VerticalContentAlignment="Center" /> - - - - @@ -141,12 +137,4 @@ - - - - - - - - \ No newline at end of file diff --git a/src/Ursa/Controls/Avatar/Avatar.cs b/src/Ursa/Controls/Avatar/Avatar.cs index d198aa1..a3d134c 100644 --- a/src/Ursa/Controls/Avatar/Avatar.cs +++ b/src/Ursa/Controls/Avatar/Avatar.cs @@ -1,42 +1,17 @@ using Avalonia; using Avalonia.Controls; -using Avalonia.Controls.Metadata; -using Avalonia.Controls.Presenters; using Avalonia.Media; namespace Ursa.Controls; -[TemplatePart(PART_HoverMask, typeof(ContentPresenter))] public class Avatar : Button { - public const string PART_TopPresenter = "PART_TopPresenter"; - public const string PART_BottomPresenter = "PART_BottomPresenter"; - public const string PART_HoverMask = "PART_HoverMask"; - - public static readonly StyledProperty ContentMotionProperty = AvaloniaProperty.Register( - nameof(ContentMotion)); - - public static readonly StyledProperty GapProperty = AvaloniaProperty.Register( - nameof(Gap)); - public static readonly StyledProperty SourceProperty = AvaloniaProperty.Register( nameof(Source)); public static readonly StyledProperty HoverMaskProperty = AvaloniaProperty.Register( nameof(HoverMask)); - public bool ContentMotion - { - get => GetValue(ContentMotionProperty); - set => SetValue(ContentMotionProperty, value); - } - - public double Gap - { - get => GetValue(GapProperty); - set => SetValue(GapProperty, value); - } - public IImage? Source { get => GetValue(SourceProperty); diff --git a/src/Ursa/Controls/Avatar/AvatarGroup.cs b/src/Ursa/Controls/Avatar/AvatarGroup.cs deleted file mode 100644 index 0609367..0000000 --- a/src/Ursa/Controls/Avatar/AvatarGroup.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Avalonia; -using Avalonia.Controls; -using Avalonia.Controls.Templates; - -namespace Ursa.Controls; - -public class AvatarGroup : ItemsControl -{ - public const string PART_RenderMore = "PART_RenderMore"; - - private static readonly FuncTemplate DefaultPanel = new(() => new AvatarGroupPanel()); - - public static readonly StyledProperty MaxCountProperty = AvaloniaProperty.Register( - nameof(MaxCount)); - - public static readonly StyledProperty OverlapFromProperty = - AvaloniaProperty.Register( - nameof(OverlapFrom), defaultValue: OverlapFromType.Start); - - public int? MaxCount - { - get => GetValue(MaxCountProperty); - set => SetValue(MaxCountProperty, value); - } - - public OverlapFromType OverlapFrom - { - get => GetValue(OverlapFromProperty); - set => SetValue(OverlapFromProperty, value); - } - - static AvatarGroup() - { - ItemsPanelProperty.OverrideDefaultValue(DefaultPanel); - } -} - -public enum OverlapFromType -{ - Start, - End -} \ No newline at end of file diff --git a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs b/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs deleted file mode 100644 index 40620d8..0000000 --- a/src/Ursa/Controls/Avatar/AvatarGroupPanel.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Avalonia; -using Avalonia.Controls; -using Avalonia.LogicalTree; - -namespace Ursa.Controls; - -public class AvatarGroupPanel : Panel -{ - protected override Size MeasureOverride(Size availableSize) - { - var children = Children; - if (children.Count <= 0) return new Size(); - - availableSize = availableSize.WithWidth(double.PositiveInfinity); - children[0].Measure(availableSize); - Size first = children[0].DesiredSize; - var group = this.GetLogicalAncestors().OfType().FirstOrDefault(); - var maxCount = group?.MaxCount; - var count = children.Count; - if (maxCount >= 0 && maxCount < count) - { - count = maxCount.Value + 1; - } - - var width = first.Width + first.Width * (count - 1) * 0.75; - return new Size(width, first.Height); - } - - protected override Size ArrangeOverride(Size finalSize) - { - Rect rect = new Rect(finalSize); - double num = 0d; - var children = Children; - var group = this.GetLogicalAncestors().OfType().FirstOrDefault(); - var overlapFrom = group?.OverlapFrom; - var maxCount = group?.MaxCount; - var childrenCount = children.Count; - var count = maxCount < childrenCount ? maxCount.Value : childrenCount; - for (var i = 0; i < count; i++) - { - if (overlapFrom is OverlapFromType.Start) - { - children[i].ZIndex = childrenCount - i; - } - - children[i].Measure(finalSize); - Size desiredSize = children[i].DesiredSize; - double width = desiredSize.Width; - double height = Math.Max(desiredSize.Height, finalSize.Height); - rect = rect.WithX(rect.X + num); - rect = rect.WithWidth(width); - rect = rect.WithHeight(height); - num = width * 0.75; - children[i].Arrange(rect); - } - - if (maxCount is not null) - { - //TODO: RenderMore - } - - return finalSize; - } -} \ No newline at end of file From 52845ebae84904b8c4573dede4b6b66cc37501c2 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:27:17 +0800 Subject: [PATCH 14/16] feat: extract colors. --- src/Ursa.Themes.Semi/Controls/Avatar.axaml | 36 +++++++++---------- src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml | 19 +++++++++- .../Themes/Light/Avatar.axaml | 19 +++++++++- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml index 10607dc..89ac448 100644 --- a/src/Ursa.Themes.Semi/Controls/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -5,8 +5,8 @@ xmlns:converters="clr-namespace:Ursa.Converters;assembly=Ursa"> - - + + @@ -50,52 +50,52 @@ Converter={x:Static ObjectConverters.IsNotNull}}" /> diff --git a/src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml b/src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml index c9ef25a..ebd81a4 100644 --- a/src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml @@ -1,2 +1,29 @@  - + 600 + 100 + + 3 + + 20 + 10 + + 24 + 10 + + 32 + 12 + + 40 + 18 + + 48 + 20 + + 72 + 32 + 6 + + 128 + 64 + 12 + \ No newline at end of file From a95d06a44492f46f0828c398ba3adf329f4b5ded Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:48:36 +0800 Subject: [PATCH 16/16] fix: fix HoverMask and Image order. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 29 ++++++++++++++++++---- src/Ursa.Themes.Semi/Controls/Avatar.axaml | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index 9f5ba46..1a07543 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -25,10 +25,14 @@ - - + + @@ -71,7 +75,22 @@ - + + + + + + + + + + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml index f36d22e..4fe9705 100644 --- a/src/Ursa.Themes.Semi/Controls/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -32,6 +32,7 @@ Content="{TemplateBinding Content}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" /> + -