From 605ede79945df03ff6efb7a50304e5d0dd09381e Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Tue, 26 May 2020 12:07:31 +0200 Subject: [PATCH 01/93] Fix invalid navigation direction for Tab. --- src/Avalonia.Input/NavigationDirection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Input/NavigationDirection.cs b/src/Avalonia.Input/NavigationDirection.cs index 34bedac141..9b9af0b0a6 100644 --- a/src/Avalonia.Input/NavigationDirection.cs +++ b/src/Avalonia.Input/NavigationDirection.cs @@ -102,7 +102,7 @@ namespace Avalonia.Input switch (key) { case Key.Tab: - return (modifiers & KeyModifiers.Shift) != 0 ? + return (modifiers & KeyModifiers.Shift) == 0 ? NavigationDirection.Next : NavigationDirection.Previous; case Key.Up: return NavigationDirection.Up; From b99184b815e2ec05dd770c6eb4f7a153543c71db Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 28 May 2020 17:20:53 -0300 Subject: [PATCH 02/93] Add resources for listbox. --- .../Accents/FluentBaseDark.xaml | 18 ++++++++++++++++++ .../Accents/FluentBaseLight.xaml | 18 ++++++++++++++++++ .../Accents/FluentControlResourcesDark.xaml | 18 ++++++++++++++++++ .../Accents/FluentControlResourcesLight.xaml | 18 ++++++++++++++++++ 4 files changed, 72 insertions(+) diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml index ed6f56b211..292870c3cf 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml @@ -85,6 +85,24 @@ + + 0 + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml index ac7b792a9a..f734e1eff8 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml @@ -86,6 +86,24 @@ + + 0 + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index a0f3ef0d62..3f9dc68383 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -39,6 +39,24 @@ + + 0 + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index ec4f35664c..46b8f4422c 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -39,6 +39,24 @@ + + 0 + + + + + + + + + + + + + + + + From 6e55912c75c6af942d0e59e34cf04948feb9f553 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 28 May 2020 17:33:36 -0300 Subject: [PATCH 03/93] fully ported listbox and listbox items --- src/Avalonia.Themes.Fluent/ListBox.xaml | 70 +++++++++------- src/Avalonia.Themes.Fluent/ListBoxItem.xaml | 90 +++++++++++++++++---- 2 files changed, 114 insertions(+), 46 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ListBox.xaml b/src/Avalonia.Themes.Fluent/ListBox.xaml index e91d8a6772..7a87387de8 100644 --- a/src/Avalonia.Themes.Fluent/ListBox.xaml +++ b/src/Avalonia.Themes.Fluent/ListBox.xaml @@ -1,31 +1,43 @@ - - + + + + Test + Test + Test + Test + + + + + diff --git a/src/Avalonia.Themes.Fluent/ListBoxItem.xaml b/src/Avalonia.Themes.Fluent/ListBoxItem.xaml index 19a6e3d4ec..430d3c5468 100644 --- a/src/Avalonia.Themes.Fluent/ListBoxItem.xaml +++ b/src/Avalonia.Themes.Fluent/ListBoxItem.xaml @@ -1,12 +1,27 @@ - + + + + + Disabled + Test + Test + + + + + 12,9,12,12 + - + + + + + + + + + + + + + + + - - - + + + + - - + From 01c327d3bfb6538a1c08716471974d55c981a74e Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 28 May 2020 17:34:00 -0300 Subject: [PATCH 04/93] Add pressed pseudo class to ListBoxItem. --- src/Avalonia.Controls/ListBoxItem.cs | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Avalonia.Controls/ListBoxItem.cs b/src/Avalonia.Controls/ListBoxItem.cs index 199c9e0ff8..46a7ccec0b 100644 --- a/src/Avalonia.Controls/ListBoxItem.cs +++ b/src/Avalonia.Controls/ListBoxItem.cs @@ -1,4 +1,5 @@ using Avalonia.Controls.Mixins; +using Avalonia.Input; namespace Avalonia.Controls { @@ -30,5 +31,34 @@ namespace Avalonia.Controls get { return GetValue(IsSelectedProperty); } set { SetValue(IsSelectedProperty, value); } } + + protected override void OnPointerPressed(PointerPressedEventArgs e) + { + base.OnPointerPressed(e); + + if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) + { + UpdatePseudoClasses(true); + } + } + + protected override void OnPointerReleased(PointerReleasedEventArgs e) + { + base.OnPointerReleased(e); + + UpdatePseudoClasses(false); + } + + protected override void OnPointerCaptureLost(PointerCaptureLostEventArgs e) + { + base.OnPointerCaptureLost(e); + + UpdatePseudoClasses(false); + } + + private void UpdatePseudoClasses(bool isPressed) + { + PseudoClasses.Set(":pressed", isPressed); + } } } From c961df9ee1e04f8ef39905ed9c866f1173edb051 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 28 May 2020 19:34:53 -0300 Subject: [PATCH 05/93] fix unit for listbox test. --- .../Primitives/SelectingItemsControlTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs index 04d0ac0a7a..fe9c7b1261 100644 --- a/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs @@ -994,7 +994,7 @@ namespace Avalonia.Controls.UnitTests.Primitives target.Presenter.ApplyTemplate(); _helper.Down((Interactive)target.Presenter.Panel.Children[3]); - Assert.Equal(new[] { ":selected" }, target.Presenter.Panel.Children[3].Classes); + Assert.Equal(new[] { ":pressed", ":selected" }, target.Presenter.Panel.Children[3].Classes); } [Fact] From 229c8b7f12762ce4f37c241c13c15e50bde83c1b Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Fri, 29 May 2020 00:36:15 +0200 Subject: [PATCH 06/93] Benchmark and simple optimization for INPC accessor. --- .../Plugins/InpcPropertyAccessorPlugin.cs | 8 ++- .../Data/PropertyAccessorBenchmarks.cs | 57 +++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 tests/Avalonia.Benchmarks/Data/PropertyAccessorBenchmarks.cs diff --git a/src/Avalonia.Base/Data/Core/Plugins/InpcPropertyAccessorPlugin.cs b/src/Avalonia.Base/Data/Core/Plugins/InpcPropertyAccessorPlugin.cs index f2ed86d2aa..84ef0fb695 100644 --- a/src/Avalonia.Base/Data/Core/Plugins/InpcPropertyAccessorPlugin.cs +++ b/src/Avalonia.Base/Data/Core/Plugins/InpcPropertyAccessorPlugin.cs @@ -1,7 +1,5 @@ using System; using System.ComponentModel; -using System.Linq; -using System.Reactive.Linq; using System.Reflection; using Avalonia.Utilities; @@ -31,7 +29,11 @@ namespace Avalonia.Data.Core.Plugins Contract.Requires(propertyName != null); reference.TryGetTarget(out object instance); - var p = instance.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name == propertyName); + + const BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Public | + BindingFlags.Static | BindingFlags.Instance; + + var p = instance.GetType().GetProperty(propertyName, bindingFlags); if (p != null) { diff --git a/tests/Avalonia.Benchmarks/Data/PropertyAccessorBenchmarks.cs b/tests/Avalonia.Benchmarks/Data/PropertyAccessorBenchmarks.cs new file mode 100644 index 0000000000..5c2502422a --- /dev/null +++ b/tests/Avalonia.Benchmarks/Data/PropertyAccessorBenchmarks.cs @@ -0,0 +1,57 @@ +using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using Avalonia.Data.Core.Plugins; +using BenchmarkDotNet.Attributes; +using JetBrains.Annotations; + +namespace Avalonia.Benchmarks.Data +{ + [MemoryDiagnoser, InProcess] + public class PropertyAccessorBenchmarks + { + private readonly InpcPropertyAccessorPlugin _plugin = new InpcPropertyAccessorPlugin(); + private readonly TestObject _targetStrongRef = new TestObject(); + private readonly WeakReference _targetWeakRef; + + public PropertyAccessorBenchmarks() + { + _targetWeakRef = new WeakReference(_targetStrongRef); + } + + [Benchmark] + public void InpcAccessor() + { + _plugin.Start(_targetWeakRef, nameof(TestObject.Test)); + } + + private class TestObject : INotifyPropertyChanged + { + private string _test; + + public string Test + { + get => _test; + set + { + if (_test == value) + { + return; + } + + _test = value; + + OnPropertyChanged(); + } + } + + public event PropertyChangedEventHandler PropertyChanged; + + [NotifyPropertyChangedInvocator] + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } + } +} From aa934c81f6f613935683615e25073ed45af93a93 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 28 May 2020 11:39:59 +0800 Subject: [PATCH 07/93] Porting resources --- .../Accents/FluentBaseDark.xaml | 28 +++++++++- .../Accents/FluentBaseLight.xaml | 28 +++++++++- .../Accents/FluentControlResourcesDark.xaml | 55 ++++++++++++++++++- .../Accents/FluentControlResourcesLight.xaml | 55 ++++++++++++++++++- 4 files changed, 154 insertions(+), 12 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml index 292870c3cf..e8e4c96786 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml @@ -1,6 +1,6 @@ - diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml index f734e1eff8..b693df38f4 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml @@ -1,6 +1,6 @@ - diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index 3f9dc68383..1de481b40b 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -1,6 +1,6 @@ - diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index 46b8f4422c..1b755c133d 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -1,6 +1,6 @@ - From cbc94cd708662b603572a91dcd639cbbf050235d Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 28 May 2020 12:04:45 +0800 Subject: [PATCH 08/93] WIP --- src/Avalonia.Themes.Default/Slider.xaml | 329 ++++++++++++++++++------ 1 file changed, 246 insertions(+), 83 deletions(-) diff --git a/src/Avalonia.Themes.Default/Slider.xaml b/src/Avalonia.Themes.Default/Slider.xaml index b21cbf3650..f9857be906 100644 --- a/src/Avalonia.Themes.Default/Slider.xaml +++ b/src/Avalonia.Themes.Default/Slider.xaml @@ -1,93 +1,256 @@ - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + From e4ff69e0c724fffc4455a0f940ce1b9b5a71c3da Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 28 May 2020 12:12:26 +0800 Subject: [PATCH 09/93] swap --- src/Avalonia.Themes.Default/Slider.xaml | 331 ++++++------------------ src/Avalonia.Themes.Fluent/Slider.xaml | 329 +++++++++++++++++------ 2 files changed, 330 insertions(+), 330 deletions(-) diff --git a/src/Avalonia.Themes.Default/Slider.xaml b/src/Avalonia.Themes.Default/Slider.xaml index f9857be906..9196663dd0 100644 --- a/src/Avalonia.Themes.Default/Slider.xaml +++ b/src/Avalonia.Themes.Default/Slider.xaml @@ -1,256 +1,93 @@ - - - 0,0,0,4 - 15 - 15 - 32 - 32 - 10 - 20 - 20 - 20 - 20 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - + + \ No newline at end of file diff --git a/src/Avalonia.Themes.Fluent/Slider.xaml b/src/Avalonia.Themes.Fluent/Slider.xaml index b21cbf3650..f9857be906 100644 --- a/src/Avalonia.Themes.Fluent/Slider.xaml +++ b/src/Avalonia.Themes.Fluent/Slider.xaml @@ -1,93 +1,256 @@ - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + From b689ba3c6d23b6f7710f944196a74c04a0b47ab0 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 28 May 2020 14:21:04 +0800 Subject: [PATCH 10/93] port visual states --- src/Avalonia.Themes.Fluent/Slider.xaml | 266 +++++++++++-------------- 1 file changed, 116 insertions(+), 150 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Slider.xaml b/src/Avalonia.Themes.Fluent/Slider.xaml index f9857be906..014095b924 100644 --- a/src/Avalonia.Themes.Fluent/Slider.xaml +++ b/src/Avalonia.Themes.Fluent/Slider.xaml @@ -1,5 +1,4 @@ - + 0,0,0,4 15 @@ -12,8 +11,7 @@ 20 20 - - + - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + - - - - - + + - + - - - - - + + - - + + - - - - - - - - - - - From f255f2685e0eba530b4b0f8bcc0b77eb0c94ce49 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 28 May 2020 15:13:32 +0800 Subject: [PATCH 11/93] try making slider work --- src/Avalonia.Controls/Slider.cs | 15 +- src/Avalonia.Themes.Fluent/Slider.xaml | 207 +++++++++--------- src/Avalonia.Visuals/Media/Color.cs | 2 + .../Media/ColorToSolidColorBrushConverter.cs | 36 +++ 4 files changed, 148 insertions(+), 112 deletions(-) create mode 100644 src/Avalonia.Visuals/Media/ColorToSolidColorBrushConverter.cs diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index e92c8faf20..9faf77d445 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -94,9 +94,18 @@ namespace Avalonia.Controls _increaseButton.Click -= IncreaseClick; } - _decreaseButton = e.NameScope.Find