From a96341498a1286075ad8b8729baa49d2c3f1f19a Mon Sep 17 00:00:00 2001 From: rabbitism Date: Thu, 16 May 2024 23:22:43 +0800 Subject: [PATCH 1/2] fix: ensure indicator is visibility upon loaded. --- .../ViewModels/SelectionListDemoViewModel.cs | 1 + src/Ursa/Controls/SelectionList/SelectionList.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/demo/Ursa.Demo/ViewModels/SelectionListDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/SelectionListDemoViewModel.cs index 3711edd..b05b20f 100644 --- a/demo/Ursa.Demo/ViewModels/SelectionListDemoViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/SelectionListDemoViewModel.cs @@ -14,6 +14,7 @@ public partial class SelectionListDemoViewModel: ObservableObject { "Ding", "Otter", "Husky", "Mr. 17", "Cass" }; + SelectedItem = Items[0]; } public void Clear() diff --git a/src/Ursa/Controls/SelectionList/SelectionList.cs b/src/Ursa/Controls/SelectionList/SelectionList.cs index ba102cc..916a446 100644 --- a/src/Ursa/Controls/SelectionList/SelectionList.cs +++ b/src/Ursa/Controls/SelectionList/SelectionList.cs @@ -7,6 +7,7 @@ using Avalonia.Controls.Primitives; using Avalonia.Controls.Selection; using Avalonia.Controls.Templates; using Avalonia.Input; +using Avalonia.Interactivity; using Avalonia.Rendering.Composition; using Avalonia.Rendering.Composition.Animations; using Irihi.Avalonia.Shared.Helpers; @@ -95,6 +96,18 @@ public class SelectionList: SelectingItemsControl EnsureIndicatorAnimation(); } + protected override void OnLoaded(RoutedEventArgs e) + { + base.OnLoaded(e); + if(_indicator is not null && SelectedItem is not null) + { + var container = ContainerFromItem(SelectedItem); + if (container is null) return; + _indicator.Opacity = 1; + _indicator.Arrange(container.Bounds); + } + } + private void EnsureIndicatorAnimation() { if (_indicator is not null) From f453801f594a226729728b2e7cb4c53e87af9f3d Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sun, 12 May 2024 18:57:44 +0800 Subject: [PATCH 2/2] feat: fix oversize dialog. --- demo/Ursa.Demo/Dialogs/PlainDialog.axaml | 1 + demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs | 13 +++++++++++++ .../OverlayShared/OverlayDialogHost.Dialog.cs | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/demo/Ursa.Demo/Dialogs/PlainDialog.axaml b/demo/Ursa.Demo/Dialogs/PlainDialog.axaml index 89dbb0d..8543273 100644 --- a/demo/Ursa.Demo/Dialogs/PlainDialog.axaml +++ b/demo/Ursa.Demo/Dialogs/PlainDialog.axaml @@ -9,5 +9,6 @@ x:Class="Ursa.Demo.Dialogs.PlainDialog"> + diff --git a/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs b/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs index 2e199a6..feb199d 100644 --- a/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs +++ b/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs @@ -12,4 +12,17 @@ public class PlainDialogViewModel: ObservableObject get => _date; set => SetProperty(ref _date, value); } + + private string? _text; + public string? Text + { + get => _text; + set => SetProperty(ref _text, value); + } + + public PlainDialogViewModel() + { + Text = + "千古悠悠 有多少冤魂嗟叹 空怅望人寰无限 丛生哀怨 泣血蝇虫笑苍天 孤帆叠影锁白链 残月升骤起烈烈风 尽吹散 尽吹散 尽吹散 滂沱雨无底涧 涉激流登彼岸 奋力拨云间消得雾患 社稷安抚臣子心 长驱鬼魅不休战 看斜阳照大地阡陌 从头转"; + } } \ No newline at end of file diff --git a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Dialog.cs b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Dialog.cs index f219815..499d998 100644 --- a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Dialog.cs +++ b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Dialog.cs @@ -22,6 +22,8 @@ public partial class OverlayDialogHost SetTop(control, 0); return; } + control.MaxWidth = newSize.Width; + control.MaxHeight = newSize.Height; var width = newSize.Width - control.Bounds.Width; var height = newSize.Height - control.Bounds.Height; var newLeft = width * control.HorizontalOffsetRatio??0; @@ -97,6 +99,8 @@ public partial class OverlayDialogHost control.Width = Bounds.Width; control.Height = Bounds.Height; } + control.MaxWidth = Bounds.Width; + control.MaxHeight = Bounds.Height; control.Measure(this.Bounds.Size); control.Arrange(new Rect(control.DesiredSize)); SetToPosition(control); @@ -154,6 +158,8 @@ public partial class OverlayDialogHost control.Width = Bounds.Width; control.Height = Bounds.Height; } + control.MaxWidth = Bounds.Width; + control.MaxHeight = Bounds.Height; control.Measure(this.Bounds.Size); control.Arrange(new Rect(control.DesiredSize)); SetToPosition(control);