From bd6d61c1724f16eae22ed8c117b17ec27923f19e Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sat, 30 May 2020 13:06:36 -0300 Subject: [PATCH 01/30] initial test of styling menus and context menus. --- src/Avalonia.Themes.Fluent/ContextMenu.xaml | 37 +++++++++++---------- src/Avalonia.Themes.Fluent/Menu.xaml | 2 +- src/Avalonia.Themes.Fluent/MenuItem.xaml | 37 ++++++++++++++++----- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ContextMenu.xaml b/src/Avalonia.Themes.Fluent/ContextMenu.xaml index 75f8f7c23d..9a583e2e30 100644 --- a/src/Avalonia.Themes.Fluent/ContextMenu.xaml +++ b/src/Avalonia.Themes.Fluent/ContextMenu.xaml @@ -1,22 +1,25 @@ \ No newline at end of file + diff --git a/src/Avalonia.Themes.Fluent/MenuItem.xaml b/src/Avalonia.Themes.Fluent/MenuItem.xaml index 314416cda0..d2586c6aa8 100644 --- a/src/Avalonia.Themes.Fluent/MenuItem.xaml +++ b/src/Avalonia.Themes.Fluent/MenuItem.xaml @@ -2,13 +2,23 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:conv="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls" xmlns:sys="clr-namespace:System;assembly=netstandard"> + + + + + + + + + + 12,9,12,12 - - - - - - - - - - + + + From c3fca8325f34ed240069db256ce9081e13c0b20a Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Thu, 11 Jun 2020 20:21:07 +0300 Subject: [PATCH 10/30] Add math utilities to compare single precision --- src/Avalonia.Base/Utilities/MathUtilities.cs | 85 ++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/src/Avalonia.Base/Utilities/MathUtilities.cs b/src/Avalonia.Base/Utilities/MathUtilities.cs index 3fb5f7a162..7949a62949 100644 --- a/src/Avalonia.Base/Utilities/MathUtilities.cs +++ b/src/Avalonia.Base/Utilities/MathUtilities.cs @@ -11,6 +11,8 @@ namespace Avalonia.Utilities // smallest such that 1.0+DoubleEpsilon != 1.0 private const double DoubleEpsilon = 2.2204460492503131e-016; + private const float FloatEpsilon = 1.192092896e-07F; + /// /// AreClose - Returns whether or not two doubles are "close". That is, whether or /// not they are within epsilon of each other. @@ -26,6 +28,21 @@ namespace Avalonia.Utilities return (-eps < delta) && (eps > delta); } + /// + /// AreClose - Returns whether or not two floats are "close". That is, whether or + /// not they are within epsilon of each other. + /// + /// The first float to compare. + /// The second float to compare. + public static bool AreClose(float value1, float value2) + { + //in case they are Infinities (then epsilon check does not work) + if (value1 == value2) return true; + float eps = (Math.Abs(value1) + Math.Abs(value2) + 10.0f) * FloatEpsilon; + float delta = value1 - value2; + return (-eps < delta) && (eps > delta); + } + /// /// LessThan - Returns whether or not the first double is less than the second double. /// That is, whether or not the first is strictly less than *and* not within epsilon of @@ -38,6 +55,18 @@ namespace Avalonia.Utilities return (value1 < value2) && !AreClose(value1, value2); } + /// + /// LessThan - Returns whether or not the first float is less than the second float. + /// That is, whether or not the first is strictly less than *and* not within epsilon of + /// the other number. + /// + /// The first single float to compare. + /// The second single float to compare. + public static bool LessThan(float value1, float value2) + { + return (value1 < value2) && !AreClose(value1, value2); + } + /// /// GreaterThan - Returns whether or not the first double is greater than the second double. /// That is, whether or not the first is strictly greater than *and* not within epsilon of @@ -50,6 +79,18 @@ namespace Avalonia.Utilities return (value1 > value2) && !AreClose(value1, value2); } + /// + /// GreaterThan - Returns whether or not the first float is greater than the second float. + /// That is, whether or not the first is strictly greater than *and* not within epsilon of + /// the other number. + /// + /// The first float to compare. + /// The second float to compare. + public static bool GreaterThan(float value1, float value2) + { + return (value1 > value2) && !AreClose(value1, value2); + } + /// /// LessThanOrClose - Returns whether or not the first double is less than or close to /// the second double. That is, whether or not the first is strictly less than or within @@ -62,6 +103,18 @@ namespace Avalonia.Utilities return (value1 < value2) || AreClose(value1, value2); } + /// + /// LessThanOrClose - Returns whether or not the first float is less than or close to + /// the second float. That is, whether or not the first is strictly less than or within + /// epsilon of the other number. + /// + /// The first float to compare. + /// The second float to compare. + public static bool LessThanOrClose(float value1, float value2) + { + return (value1 < value2) || AreClose(value1, value2); + } + /// /// GreaterThanOrClose - Returns whether or not the first double is greater than or close to /// the second double. That is, whether or not the first is strictly greater than or within @@ -74,6 +127,18 @@ namespace Avalonia.Utilities return (value1 > value2) || AreClose(value1, value2); } + /// + /// GreaterThanOrClose - Returns whether or not the first float is greater than or close to + /// the second float. That is, whether or not the first is strictly greater than or within + /// epsilon of the other number. + /// + /// The first float to compare. + /// The second float to compare. + public static bool GreaterThanOrClose(float value1, float value2) + { + return (value1 > value2) || AreClose(value1, value2); + } + /// /// IsOne - Returns whether or not the double is "close" to 1. Same as AreClose(double, 1), /// but this is faster. @@ -84,6 +149,16 @@ namespace Avalonia.Utilities return Math.Abs(value - 1.0) < 10.0 * DoubleEpsilon; } + /// + /// IsOne - Returns whether or not the float is "close" to 1. Same as AreClose(float, 1), + /// but this is faster. + /// + /// The float to compare to 1. + public static bool IsOne(float value) + { + return Math.Abs(value - 1.0f) < 10.0f * FloatEpsilon; + } + /// /// IsZero - Returns whether or not the double is "close" to 0. Same as AreClose(double, 0), /// but this is faster. @@ -94,6 +169,16 @@ namespace Avalonia.Utilities return Math.Abs(value) < 10.0 * DoubleEpsilon; } + /// + /// IsZero - Returns whether or not the float is "close" to 0. Same as AreClose(float, 0), + /// but this is faster. + /// + /// The float to compare to 0. + public static bool IsZero(float value) + { + return Math.Abs(value) < 10.0f * FloatEpsilon; + } + /// /// Clamps a value between a minimum and maximum value. /// From c4668f5ef3f57c639085a35b32e663ba78f5a440 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Thu, 11 Jun 2020 23:43:52 +0300 Subject: [PATCH 11/30] Add tests for float math utils --- .../Utilities/MathUtilitiesTests.cs | 85 ++++++++++++++----- 1 file changed, 62 insertions(+), 23 deletions(-) diff --git a/tests/Avalonia.Base.UnitTests/Utilities/MathUtilitiesTests.cs b/tests/Avalonia.Base.UnitTests/Utilities/MathUtilitiesTests.cs index a36b22fee2..0378a5b017 100644 --- a/tests/Avalonia.Base.UnitTests/Utilities/MathUtilitiesTests.cs +++ b/tests/Avalonia.Base.UnitTests/Utilities/MathUtilitiesTests.cs @@ -6,50 +6,89 @@ namespace Avalonia.Base.UnitTests.Utilities { public class MathUtilitiesTests { - [Fact] - public void Two_Equivalent_Double_Values_Are_Close() + private const double AnyValue = 42.42; + private readonly double _calculatedAnyValue; + private readonly double _one; + private readonly double _zero; + + public MathUtilitiesTests() { + _calculatedAnyValue = 0.0; + _one = 0.0; + _zero = 1.0; + const int N = 10; - var x = 42.42; - var y = 0.0; - var dx = x / N; + var dxAny = AnyValue / N; + var dxOne = 1.0 / N; + var dxZero = _zero / N; for (var i = 0; i < N; ++i) - y += dx; - var actual = MathUtilities.AreClose(x, y); + { + _calculatedAnyValue += dxAny; + _one += dxOne; + _zero -= dxZero; + } + } + + [Fact] + public void Two_Equivalent_Double_Values_Are_Close() + { + var actual = MathUtilities.AreClose(AnyValue, _calculatedAnyValue); Assert.True(actual); - Assert.Equal(x, Math.Round(y, 14)); + Assert.Equal(AnyValue, Math.Round(_calculatedAnyValue, 14)); + } + + [Fact] + public void Two_Equivalent_Single_Values_Are_Close() + { + var expectedValue = (float)AnyValue; + var actualValue = (float)_calculatedAnyValue; + + var actual = MathUtilities.AreClose(expectedValue, actualValue); + + Assert.True(actual); + Assert.Equal((float) Math.Round(expectedValue, 5), (float) Math.Round(actualValue, 4)); } [Fact] public void Calculated_Double_One_Is_One() { - const int N = 10; - var dx = 1.0 / N; - var x = 0.0; + var actual = MathUtilities.IsOne(_one); + + Assert.True(actual); + Assert.Equal(1.0, Math.Round(_one, 15)); + } + + [Fact] + public void Calculated_Single_One_Is_One() + { + var actualValue = (float)_one; - for (var i = 0; i < N; ++i) - x += dx; - var actual = MathUtilities.IsOne(x); + var actual = MathUtilities.IsOne(actualValue); Assert.True(actual); - Assert.Equal(1.0, Math.Round(x, 15)); + Assert.Equal(1.0f, (float) Math.Round(actualValue, 7)); } [Fact] public void Calculated_Double_Zero_Is_Zero() { - const int N = 10; - var x = 1.0; - var dx = x / N; - - for (var i = 0; i < N; ++i) - x -= dx; - var actual = MathUtilities.IsZero(x); + var actual = MathUtilities.IsZero(_zero); + + Assert.True(actual); + Assert.Equal(0.0, Math.Round(_zero, 15)); + } + + [Fact] + public void Calculated_Single_Zero_Is_Zero() + { + var actualValue = (float)_zero; + + var actual = MathUtilities.IsZero(actualValue); Assert.True(actual); - Assert.Equal(0.0, Math.Round(x, 15)); + Assert.Equal(0.0f, (float) Math.Round(actualValue, 7)); } [Fact] From 068257acd7afaba83c4e8827592d3fa17c7aa0d9 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 10 Jun 2020 19:51:58 -0400 Subject: [PATCH 12/30] Fluent RepeatButton --- .../Accents/FluentBaseDark.xaml | 14 +++ .../Accents/FluentBaseLight.xaml | 14 +++ .../Accents/FluentControlResourcesDark.xaml | 24 +++++ .../Accents/FluentControlResourcesLight.xaml | 24 +++++ src/Avalonia.Themes.Fluent/RepeatButton.xaml | 100 +++++++++++------- 5 files changed, 137 insertions(+), 39 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml index bb52c6eafb..48af051469 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml @@ -92,6 +92,20 @@ + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml index 614f1d184b..cb629e8783 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml @@ -93,6 +93,20 @@ + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index 70160ebb00..5bca7b644e 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -39,6 +39,30 @@ + + 1 + + + + + + + + + + + + + + + + + + + + + + 21 64 diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index f0abe9b77f..8d70ce4d02 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -39,6 +39,30 @@ + + 1 + + + + + + + + + + + + + + + + + + + + + + 21 64 diff --git a/src/Avalonia.Themes.Fluent/RepeatButton.xaml b/src/Avalonia.Themes.Fluent/RepeatButton.xaml index 702e4e6ebd..70ab8090f1 100644 --- a/src/Avalonia.Themes.Fluent/RepeatButton.xaml +++ b/src/Avalonia.Themes.Fluent/RepeatButton.xaml @@ -1,40 +1,62 @@ - - - - + + + + + + + + + + 8,5,8,6 + + + + + + + + + + From bf2bff9ebf0c1cb98cb1fab492d10c77f3e3bbbb Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 12 Jun 2020 21:44:25 -0400 Subject: [PATCH 13/30] Add resources for ToggleButton --- .../Accents/FluentBaseDark.xaml | 38 +++++++++++++ .../Accents/FluentBaseLight.xaml | 38 +++++++++++++ .../Accents/FluentControlResourcesDark.xaml | 57 +++++++++++++++++++ .../Accents/FluentControlResourcesLight.xaml | 57 +++++++++++++++++++ 4 files changed, 190 insertions(+) diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml index bb52c6eafb..b1af9727f0 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml @@ -92,6 +92,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml index 614f1d184b..e8a32dd527 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml @@ -93,6 +93,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index 70160ebb00..43b13cc400 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -39,6 +39,63 @@ + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 21 64 diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index f0abe9b77f..bc8da1e425 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -39,6 +39,63 @@ + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 21 64 From 8f01bd316591cff3baf91a456a6d20e4d37c3b02 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 12 Jun 2020 21:44:41 -0400 Subject: [PATCH 14/30] Add ToggleButton to ButtonPage example --- samples/ControlCatalog/Pages/ButtonPage.xaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/ControlCatalog/Pages/ButtonPage.xaml b/samples/ControlCatalog/Pages/ButtonPage.xaml index cc7553f6a0..7e945aeaa9 100644 --- a/samples/ControlCatalog/Pages/ButtonPage.xaml +++ b/samples/ControlCatalog/Pages/ButtonPage.xaml @@ -26,7 +26,8 @@ - + + From 19b1cdc46fc0b15ca476688cc165a2dffe53dcf2 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 12 Jun 2020 21:44:55 -0400 Subject: [PATCH 15/30] Fluent ToggleButton --- src/Avalonia.Themes.Fluent/ToggleButton.xaml | 113 +++++++++++++++---- 1 file changed, 92 insertions(+), 21 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ToggleButton.xaml b/src/Avalonia.Themes.Fluent/ToggleButton.xaml index 9e05c38eef..2e9bd4c825 100644 --- a/src/Avalonia.Themes.Fluent/ToggleButton.xaml +++ b/src/Avalonia.Themes.Fluent/ToggleButton.xaml @@ -1,38 +1,109 @@ - + + + + + + + + + + + + + 8,5,8,6 + - + + + + + + + + + + + + + + + + + + + - - \ No newline at end of file + From 0863b29d0924e43775a8666644bc59d917a81dc4 Mon Sep 17 00:00:00 2001 From: amwx Date: Thu, 11 Jun 2020 19:32:28 -0500 Subject: [PATCH 16/30] Rename existing DatePicker control --- samples/ControlCatalog/MainView.xaml | 3 +- ...rPage.xaml => CalendarDatePickerPage.xaml} | 18 +-- ...xaml.cs => CalendarDatePickerPage.xaml.cs} | 14 +- src/Avalonia.Controls/Calendar/Calendar.cs | 4 +- .../{DatePicker.cs => CalendarDatePicker.cs} | 134 +++++++++--------- .../Calendar/CalendarItem.cs | 4 +- .../CalendarDatePicker.xaml} | 4 +- src/Avalonia.Themes.Default/DefaultTheme.xaml | 2 +- .../CalendarDatePicker.xaml} | 4 +- src/Avalonia.Themes.Fluent/FluentTheme.xaml | 2 +- ...kerTests.cs => CalendarDatePickerTests.cs} | 14 +- 11 files changed, 102 insertions(+), 101 deletions(-) rename samples/ControlCatalog/Pages/{DatePickerPage.xaml => CalendarDatePickerPage.xaml} (75%) rename samples/ControlCatalog/Pages/{DatePickerPage.xaml.cs => CalendarDatePickerPage.xaml.cs} (57%) rename src/Avalonia.Controls/Calendar/{DatePicker.cs => CalendarDatePicker.cs} (87%) rename src/{Avalonia.Themes.Fluent/DatePicker.xaml => Avalonia.Themes.Default/CalendarDatePicker.xaml} (97%) rename src/{Avalonia.Themes.Default/DatePicker.xaml => Avalonia.Themes.Fluent/CalendarDatePicker.xaml} (97%) rename tests/Avalonia.Controls.UnitTests/{DatePickerTests.cs => CalendarDatePickerTests.cs} (90%) diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index 7956ee6169..af2d093bc7 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -29,7 +29,8 @@ ScrollViewer.HorizontalScrollBarVisibility="Disabled"> - + + + x:Class="ControlCatalog.Pages.CalendarDatePickerPage"> - DatePicker + CalendarDatePicker A control for selecting dates with a calendar drop-down - - - - - - - + diff --git a/samples/ControlCatalog/Pages/DatePickerPage.xaml.cs b/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml.cs similarity index 57% rename from samples/ControlCatalog/Pages/DatePickerPage.xaml.cs rename to samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml.cs index ef01887c9e..95bdeb363a 100644 --- a/samples/ControlCatalog/Pages/DatePickerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml.cs @@ -4,17 +4,17 @@ using System; namespace ControlCatalog.Pages { - public class DatePickerPage : UserControl + public class CalendarDatePickerPage : UserControl { - public DatePickerPage() + public CalendarDatePickerPage() { InitializeComponent(); - var dp1 = this.FindControl("DatePicker1"); - var dp2 = this.FindControl("DatePicker2"); - var dp3 = this.FindControl("DatePicker3"); - var dp4 = this.FindControl("DatePicker4"); - var dp5 = this.FindControl("DatePicker5"); + var dp1 = this.FindControl("DatePicker1"); + var dp2 = this.FindControl("DatePicker2"); + var dp3 = this.FindControl("DatePicker3"); + var dp4 = this.FindControl("DatePicker4"); + var dp5 = this.FindControl("DatePicker5"); dp1.SelectedDate = DateTime.Today; dp2.SelectedDate = DateTime.Today.AddDays(10); diff --git a/src/Avalonia.Controls/Calendar/Calendar.cs b/src/Avalonia.Controls/Calendar/Calendar.cs index 53c6a54b4d..4cf7db74d9 100644 --- a/src/Avalonia.Controls/Calendar/Calendar.cs +++ b/src/Avalonia.Controls/Calendar/Calendar.cs @@ -998,10 +998,10 @@ namespace Avalonia.Controls /// - /// Gets or sets a value indicating whether DatePicker should change its + /// Gets or sets a value indicating whether CalendarDatePicker should change its /// DisplayDate because of a SelectedDate change on its Calendar. /// - internal bool DatePickerDisplayDateFlag { get; set; } + internal bool CalendarDatePickerDisplayDateFlag { get; set; } internal CalendarDayButton FindDayButtonFromDay(DateTime day) { diff --git a/src/Avalonia.Controls/Calendar/DatePicker.cs b/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs similarity index 87% rename from src/Avalonia.Controls/Calendar/DatePicker.cs rename to src/Avalonia.Controls/Calendar/CalendarDatePicker.cs index 0f53dc1364..b987f065be 100644 --- a/src/Avalonia.Controls/Calendar/DatePicker.cs +++ b/src/Avalonia.Controls/Calendar/CalendarDatePicker.cs @@ -16,29 +16,29 @@ namespace Avalonia.Controls { /// /// Provides data for the - /// + /// /// event. /// - public class DatePickerDateValidationErrorEventArgs : EventArgs + public class CalendarDatePickerDateValidationErrorEventArgs : EventArgs { private bool _throwException; /// /// Initializes a new instance of the - /// + /// /// class. /// /// /// The initial exception from the - /// + /// /// event. /// /// /// The text that caused the - /// + /// /// event. /// - public DatePickerDateValidationErrorEventArgs(Exception exception, string text) + public CalendarDatePickerDateValidationErrorEventArgs(Exception exception, string text) { this.Text = text; this.Exception = exception; @@ -46,7 +46,7 @@ namespace Avalonia.Controls /// /// Gets the initial exception associated with the - /// + /// /// event. /// /// @@ -56,7 +56,7 @@ namespace Avalonia.Controls /// /// Gets the text that caused the - /// + /// /// event. /// /// @@ -66,7 +66,7 @@ namespace Avalonia.Controls /// /// Gets or sets a value indicating whether - /// + /// /// should be thrown. /// /// @@ -74,7 +74,7 @@ namespace Avalonia.Controls /// /// /// If set to true and - /// + /// /// is null. /// public bool ThrowException @@ -93,9 +93,9 @@ namespace Avalonia.Controls /// /// Specifies date formats for a - /// . + /// . /// - public enum DatePickerFormat + public enum CalendarDatePickerFormat { /// /// Specifies that the date should be displayed using unabbreviated days @@ -115,7 +115,7 @@ namespace Avalonia.Controls Custom = 2 } - public class DatePicker : TemplatedControl + public class CalendarDatePicker : TemplatedControl { private const string ElementTextBox = "PART_TextBox"; private const string ElementButton = "PART_Button"; @@ -154,59 +154,59 @@ namespace Avalonia.Controls /// public CalendarBlackoutDatesCollection BlackoutDates { get; private set; } - public static readonly DirectProperty DisplayDateProperty = - AvaloniaProperty.RegisterDirect( + public static readonly DirectProperty DisplayDateProperty = + AvaloniaProperty.RegisterDirect( nameof(DisplayDate), o => o.DisplayDate, (o, v) => o.DisplayDate = v); - public static readonly DirectProperty DisplayDateStartProperty = - AvaloniaProperty.RegisterDirect( + public static readonly DirectProperty DisplayDateStartProperty = + AvaloniaProperty.RegisterDirect( nameof(DisplayDateStart), o => o.DisplayDateStart, (o, v) => o.DisplayDateStart = v); - public static readonly DirectProperty DisplayDateEndProperty = - AvaloniaProperty.RegisterDirect( + public static readonly DirectProperty DisplayDateEndProperty = + AvaloniaProperty.RegisterDirect( nameof(DisplayDateEnd), o => o.DisplayDateEnd, (o, v) => o.DisplayDateEnd = v); public static readonly StyledProperty FirstDayOfWeekProperty = - AvaloniaProperty.Register(nameof(FirstDayOfWeek)); + AvaloniaProperty.Register(nameof(FirstDayOfWeek)); - public static readonly DirectProperty IsDropDownOpenProperty = - AvaloniaProperty.RegisterDirect( + public static readonly DirectProperty IsDropDownOpenProperty = + AvaloniaProperty.RegisterDirect( nameof(IsDropDownOpen), o => o.IsDropDownOpen, (o, v) => o.IsDropDownOpen = v); public static readonly StyledProperty IsTodayHighlightedProperty = - AvaloniaProperty.Register(nameof(IsTodayHighlighted)); - public static readonly DirectProperty SelectedDateProperty = - AvaloniaProperty.RegisterDirect( + AvaloniaProperty.Register(nameof(IsTodayHighlighted)); + public static readonly DirectProperty SelectedDateProperty = + AvaloniaProperty.RegisterDirect( nameof(SelectedDate), o => o.SelectedDate, (o, v) => o.SelectedDate = v); - public static readonly StyledProperty SelectedDateFormatProperty = - AvaloniaProperty.Register( + public static readonly StyledProperty SelectedDateFormatProperty = + AvaloniaProperty.Register( nameof(SelectedDateFormat), - defaultValue: DatePickerFormat.Short, + defaultValue: CalendarDatePickerFormat.Short, validate: IsValidSelectedDateFormat); public static readonly StyledProperty CustomDateFormatStringProperty = - AvaloniaProperty.Register( + AvaloniaProperty.Register( nameof(CustomDateFormatString), defaultValue: "d", validate: IsValidDateFormatString); - public static readonly DirectProperty TextProperty = - AvaloniaProperty.RegisterDirect( + public static readonly DirectProperty TextProperty = + AvaloniaProperty.RegisterDirect( nameof(Text), o => o.Text, (o, v) => o.Text = v); public static readonly StyledProperty WatermarkProperty = - TextBox.WatermarkProperty.AddOwner(); + TextBox.WatermarkProperty.AddOwner(); public static readonly StyledProperty UseFloatingWatermarkProperty = - TextBox.UseFloatingWatermarkProperty.AddOwner(); + TextBox.UseFloatingWatermarkProperty.AddOwner(); /// @@ -218,9 +218,9 @@ namespace Avalonia.Controls /// /// /// The specified date is not in the range defined by - /// + /// /// and - /// . + /// . /// public DateTime DisplayDate { @@ -320,7 +320,7 @@ namespace Avalonia.Controls /// /// An specified format is not valid. /// - public DatePickerFormat SelectedDateFormat + public CalendarDatePickerFormat SelectedDateFormat { get { return GetValue(SelectedDateFormatProperty); } set { SetValue(SelectedDateFormatProperty, value); } @@ -380,33 +380,33 @@ namespace Avalonia.Controls /// Occurs when /// is assigned a value that cannot be interpreted as a date. /// - public event EventHandler DateValidationError; + public event EventHandler DateValidationError; /// /// Occurs when the - /// + /// /// property is changed. /// public event EventHandler SelectedDateChanged; - static DatePicker() + static CalendarDatePicker() { - FocusableProperty.OverrideDefaultValue(true); - - DisplayDateProperty.Changed.AddClassHandler((x,e) => x.OnDisplayDateChanged(e)); - DisplayDateStartProperty.Changed.AddClassHandler((x,e) => x.OnDisplayDateStartChanged(e)); - DisplayDateEndProperty.Changed.AddClassHandler((x,e) => x.OnDisplayDateEndChanged(e)); - IsDropDownOpenProperty.Changed.AddClassHandler((x,e) => x.OnIsDropDownOpenChanged(e)); - SelectedDateProperty.Changed.AddClassHandler((x,e) => x.OnSelectedDateChanged(e)); - SelectedDateFormatProperty.Changed.AddClassHandler((x,e) => x.OnSelectedDateFormatChanged(e)); - CustomDateFormatStringProperty.Changed.AddClassHandler((x,e) => x.OnCustomDateFormatStringChanged(e)); - TextProperty.Changed.AddClassHandler((x,e) => x.OnTextChanged(e)); + FocusableProperty.OverrideDefaultValue(true); + + DisplayDateProperty.Changed.AddClassHandler((x,e) => x.OnDisplayDateChanged(e)); + DisplayDateStartProperty.Changed.AddClassHandler((x,e) => x.OnDisplayDateStartChanged(e)); + DisplayDateEndProperty.Changed.AddClassHandler((x,e) => x.OnDisplayDateEndChanged(e)); + IsDropDownOpenProperty.Changed.AddClassHandler((x,e) => x.OnIsDropDownOpenChanged(e)); + SelectedDateProperty.Changed.AddClassHandler((x,e) => x.OnSelectedDateChanged(e)); + SelectedDateFormatProperty.Changed.AddClassHandler((x,e) => x.OnSelectedDateFormatChanged(e)); + CustomDateFormatStringProperty.Changed.AddClassHandler((x,e) => x.OnCustomDateFormatStringChanged(e)); + TextProperty.Changed.AddClassHandler((x,e) => x.OnTextChanged(e)); } /// /// Initializes a new instance of the /// class. /// - public DatePicker() + public CalendarDatePicker() { FirstDayOfWeek = DateTimeHelper.GetCurrentDateFormat().FirstDayOfWeek; _defaultText = string.Empty; @@ -662,12 +662,12 @@ namespace Avalonia.Controls // change is coming from the Calendar UI itself, so, we // shouldn't change the DisplayDate since it will automatically // be changed by the Calendar - if ((day.Month != DisplayDate.Month || day.Year != DisplayDate.Year) && (_calendar == null || !_calendar.DatePickerDisplayDateFlag)) + if ((day.Month != DisplayDate.Month || day.Year != DisplayDate.Year) && (_calendar == null || !_calendar.CalendarDatePickerDisplayDateFlag)) { DisplayDate = day; } if(_calendar != null) - _calendar.DatePickerDisplayDateFlag = false; + _calendar.CalendarDatePickerDisplayDateFlag = false; } else { @@ -707,7 +707,7 @@ namespace Avalonia.Controls } private void OnCustomDateFormatStringChanged(AvaloniaPropertyChangedEventArgs e) { - if(SelectedDateFormat == DatePickerFormat.Custom) + if(SelectedDateFormat == CalendarDatePickerFormat.Custom) { OnDateFormatChanged(); } @@ -752,15 +752,15 @@ namespace Avalonia.Controls /// /// Raises the - /// + /// /// event. /// /// /// A - /// + /// /// that contains the event data. /// - protected virtual void OnDateValidationError(DatePickerDateValidationErrorEventArgs e) + protected virtual void OnDateValidationError(CalendarDatePickerDateValidationErrorEventArgs e) { DateValidationError?.Invoke(this, e); } @@ -959,7 +959,7 @@ namespace Avalonia.Controls } else { - var dateValidationError = new DatePickerDateValidationErrorEventArgs(new ArgumentOutOfRangeException(nameof(text), "SelectedDate value is not valid."), text); + var dateValidationError = new CalendarDatePickerDateValidationErrorEventArgs(new ArgumentOutOfRangeException(nameof(text), "SelectedDate value is not valid."), text); OnDateValidationError(dateValidationError); if (dateValidationError.ThrowException) @@ -970,7 +970,7 @@ namespace Avalonia.Controls } catch (FormatException ex) { - DatePickerDateValidationErrorEventArgs textParseError = new DatePickerDateValidationErrorEventArgs(ex, text); + CalendarDatePickerDateValidationErrorEventArgs textParseError = new CalendarDatePickerDateValidationErrorEventArgs(ex, text); OnDateValidationError(textParseError); if (textParseError.ThrowException) @@ -986,11 +986,11 @@ namespace Avalonia.Controls switch (SelectedDateFormat) { - case DatePickerFormat.Short: + case CalendarDatePickerFormat.Short: return string.Format(CultureInfo.CurrentCulture, d.ToString(dtfi.ShortDatePattern, dtfi)); - case DatePickerFormat.Long: + case CalendarDatePickerFormat.Long: return string.Format(CultureInfo.CurrentCulture, d.ToString(dtfi.LongDatePattern, dtfi)); - case DatePickerFormat.Custom: + case CalendarDatePickerFormat.Custom: return string.Format(CultureInfo.CurrentCulture, d.ToString(CustomDateFormatString, dtfi)); } return null; @@ -1118,12 +1118,12 @@ namespace Avalonia.Controls switch (SelectedDateFormat) { - case DatePickerFormat.Long: + case CalendarDatePickerFormat.Long: { watermarkText = string.Format(CultureInfo.CurrentCulture, watermarkFormat, dtfi.LongDatePattern.ToString()); break; } - case DatePickerFormat.Short: + case CalendarDatePickerFormat.Short: default: { watermarkText = string.Format(CultureInfo.CurrentCulture, watermarkFormat, dtfi.ShortDatePattern.ToString()); @@ -1139,11 +1139,11 @@ namespace Avalonia.Controls } } - private static bool IsValidSelectedDateFormat(DatePickerFormat value) + private static bool IsValidSelectedDateFormat(CalendarDatePickerFormat value) { - return value == DatePickerFormat.Long - || value == DatePickerFormat.Short - || value == DatePickerFormat.Custom; + return value == CalendarDatePickerFormat.Long + || value == CalendarDatePickerFormat.Short + || value == CalendarDatePickerFormat.Custom; } private static bool IsValidDateFormatString(string formatString) { diff --git a/src/Avalonia.Controls/Calendar/CalendarItem.cs b/src/Avalonia.Controls/Calendar/CalendarItem.cs index ece0ef97d9..0be7c4f67e 100644 --- a/src/Avalonia.Controls/Calendar/CalendarItem.cs +++ b/src/Avalonia.Controls/Calendar/CalendarItem.cs @@ -909,7 +909,7 @@ namespace Avalonia.Controls.Primitives case CalendarSelectionMode.SingleDate: { DateTime selectedDate = (DateTime)b.DataContext; - Owner.DatePickerDisplayDateFlag = true; + Owner.CalendarDatePickerDisplayDateFlag = true; if (Owner.SelectedDates.Count == 0) { Owner.SelectedDates.Add(selectedDate); @@ -981,7 +981,7 @@ namespace Avalonia.Controls.Primitives } case CalendarSelectionMode.SingleDate: { - Owner.DatePickerDisplayDateFlag = true; + Owner.CalendarDatePickerDisplayDateFlag = true; if (Owner.SelectedDates.Count == 0) { Owner.SelectedDates.Add(selectedDate); diff --git a/src/Avalonia.Themes.Fluent/DatePicker.xaml b/src/Avalonia.Themes.Default/CalendarDatePicker.xaml similarity index 97% rename from src/Avalonia.Themes.Fluent/DatePicker.xaml rename to src/Avalonia.Themes.Default/CalendarDatePicker.xaml index 7adb1c2d5f..bc1aba1a03 100644 --- a/src/Avalonia.Themes.Fluent/DatePicker.xaml +++ b/src/Avalonia.Themes.Default/CalendarDatePicker.xaml @@ -8,7 +8,7 @@ - - diff --git a/src/Avalonia.Themes.Default/DefaultTheme.xaml b/src/Avalonia.Themes.Default/DefaultTheme.xaml index 67279fca99..83da5d3142 100644 --- a/src/Avalonia.Themes.Default/DefaultTheme.xaml +++ b/src/Avalonia.Themes.Default/DefaultTheme.xaml @@ -45,7 +45,7 @@ - + diff --git a/src/Avalonia.Themes.Default/DatePicker.xaml b/src/Avalonia.Themes.Fluent/CalendarDatePicker.xaml similarity index 97% rename from src/Avalonia.Themes.Default/DatePicker.xaml rename to src/Avalonia.Themes.Fluent/CalendarDatePicker.xaml index 7adb1c2d5f..bc1aba1a03 100644 --- a/src/Avalonia.Themes.Default/DatePicker.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarDatePicker.xaml @@ -8,7 +8,7 @@ - - diff --git a/src/Avalonia.Themes.Fluent/FluentTheme.xaml b/src/Avalonia.Themes.Fluent/FluentTheme.xaml index a20f075e21..143b952163 100644 --- a/src/Avalonia.Themes.Fluent/FluentTheme.xaml +++ b/src/Avalonia.Themes.Fluent/FluentTheme.xaml @@ -44,7 +44,7 @@ - + diff --git a/tests/Avalonia.Controls.UnitTests/DatePickerTests.cs b/tests/Avalonia.Controls.UnitTests/CalendarDatePickerTests.cs similarity index 90% rename from tests/Avalonia.Controls.UnitTests/DatePickerTests.cs rename to tests/Avalonia.Controls.UnitTests/CalendarDatePickerTests.cs index 3d396a9726..f41a3e7581 100644 --- a/tests/Avalonia.Controls.UnitTests/DatePickerTests.cs +++ b/tests/Avalonia.Controls.UnitTests/CalendarDatePickerTests.cs @@ -15,7 +15,7 @@ using Xunit; namespace Avalonia.Controls.UnitTests { - public class DatePickerTests + public class CalendarDatePickerTests { private static bool CompareDates(DateTime first, DateTime second) { @@ -30,7 +30,7 @@ namespace Avalonia.Controls.UnitTests using (UnitTestApplication.Start(Services)) { bool handled = false; - DatePicker datePicker = CreateControl(); + CalendarDatePicker datePicker = CreateControl(); datePicker.SelectedDateChanged += (s,e) => { handled = true; @@ -47,7 +47,7 @@ namespace Avalonia.Controls.UnitTests { using (UnitTestApplication.Start(Services)) { - DatePicker datePicker = CreateControl(); + CalendarDatePicker datePicker = CreateControl(); datePicker.BlackoutDates.AddDatesInPast(); DateTime goodValue = DateTime.Today.AddDays(1); @@ -65,7 +65,7 @@ namespace Avalonia.Controls.UnitTests { using (UnitTestApplication.Start(Services)) { - DatePicker datePicker = CreateControl(); + CalendarDatePicker datePicker = CreateControl(); datePicker.SelectedDate = DateTime.Today.AddDays(5); Assert.ThrowsAny( @@ -76,10 +76,10 @@ namespace Avalonia.Controls.UnitTests private static TestServices Services => TestServices.MockThreadingInterface.With( standardCursorFactory: Mock.Of()); - private DatePicker CreateControl() + private CalendarDatePicker CreateControl() { var datePicker = - new DatePicker + new CalendarDatePicker { Template = CreateTemplate() }; @@ -90,7 +90,7 @@ namespace Avalonia.Controls.UnitTests private IControlTemplate CreateTemplate() { - return new FuncControlTemplate((control, scope) => + return new FuncControlTemplate((control, scope) => { var textBox = new TextBox From 969646e0c648f10a71028a7940e697fd7d7b9835 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 14 Jun 2020 13:50:45 -0300 Subject: [PATCH 17/30] fix slider. --- src/Avalonia.Themes.Fluent/Slider.xaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Slider.xaml b/src/Avalonia.Themes.Fluent/Slider.xaml index a57ea6cedd..539c448e0f 100644 --- a/src/Avalonia.Themes.Fluent/Slider.xaml +++ b/src/Avalonia.Themes.Fluent/Slider.xaml @@ -64,7 +64,7 @@ - + @@ -76,7 +76,7 @@ - + @@ -125,7 +125,7 @@ - + @@ -137,7 +137,7 @@ - + From 6dc0bab6e04bc9d4b7dad81fce2b526ad85992e4 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Sun, 14 Jun 2020 22:00:17 +0300 Subject: [PATCH 18/30] Fix default vertical slider with inverting move --- src/Avalonia.Themes.Default/Slider.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Themes.Default/Slider.xaml b/src/Avalonia.Themes.Default/Slider.xaml index b21cbf3650..1d48a946fc 100644 --- a/src/Avalonia.Themes.Default/Slider.xaml +++ b/src/Avalonia.Themes.Default/Slider.xaml @@ -46,7 +46,7 @@ - + From 71a234db9b8d01a78cf0da1f7cd758de3f18b84d Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 12 Jun 2020 04:46:10 -0400 Subject: [PATCH 19/30] Update MarginMultiplierConverter to support Thickness input --- .../Converters/MarginMultiplierConverter.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs b/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs index 54bd6bcf39..9f3a6da9da 100644 --- a/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs +++ b/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs @@ -18,10 +18,24 @@ namespace Avalonia.Controls.Converters public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (!(value is int depth)) - return new Thickness(0); - - return new Thickness(Left ? Indent * depth : 0, Top ? Indent * depth : 0, Right ? Indent * depth : 0, Bottom ? Indent * depth : 0); + if (value is int scalarDepth) + { + return new Thickness( + Left ? Indent * scalarDepth : 0, + Top ? Indent * scalarDepth : 0, + Right ? Indent * scalarDepth : 0, + Bottom ? Indent * scalarDepth : 0); + } + else if (value is Thickness thinknessDepth) + { + return new Thickness( + Left ? Indent * thinknessDepth.Left : 0, + Top ? Indent * thinknessDepth.Top : 0, + Right ? Indent * thinknessDepth.Right : 0, + Bottom ? Indent * thinknessDepth.Bottom : 0); + } + return new Thickness(0); + } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) From f3c555404a7036d8f89e38a6d63ab98c7470e113 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 12 Jun 2020 04:47:28 -0400 Subject: [PATCH 20/30] NumericUpDownPage example shouldn't set strict Width to elements --- samples/ControlCatalog/Pages/NumericUpDownPage.xaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml index e605a92da0..0d7e5da17f 100644 --- a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml +++ b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml @@ -50,22 +50,22 @@ Text: - + Minimum: + CultureInfo="{Binding #upDown.CultureInfo}" VerticalAlignment="Center" Margin="2" HorizontalAlignment="Center"/> Maximum: + CultureInfo="{Binding #upDown.CultureInfo}" VerticalAlignment="Center" Margin="2" HorizontalAlignment="Center"/> Increment: + Margin="2" HorizontalAlignment="Center"/> Value: + Margin="2" HorizontalAlignment="Center"/> @@ -73,7 +73,7 @@ Usage of NumericUpDown: From 475fed7e0ffb228042551841a86641a8a5fcb24c Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 12 Jun 2020 04:50:04 -0400 Subject: [PATCH 21/30] Hide HeaderContentPresenter from TextBox because it isn't supported --- src/Avalonia.Themes.Fluent/TextBox.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Avalonia.Themes.Fluent/TextBox.xaml b/src/Avalonia.Themes.Fluent/TextBox.xaml index e89cf2b49c..49fc4b59b0 100644 --- a/src/Avalonia.Themes.Fluent/TextBox.xaml +++ b/src/Avalonia.Themes.Fluent/TextBox.xaml @@ -27,6 +27,7 @@ Grid.ColumnSpan="2" TextBlock.FontWeight="Normal" TextBlock.Foreground="{DynamicResource TextControlHeaderForeground}" + IsVisible="False" Margin="{DynamicResource TextBoxTopHeaderMargin}" /> Date: Sun, 14 Jun 2020 15:28:38 -0400 Subject: [PATCH 22/30] Fix some Button selectors --- src/Avalonia.Themes.Fluent/Button.xaml | 8 ++++---- src/Avalonia.Themes.Fluent/RepeatButton.xaml | 2 +- src/Avalonia.Themes.Fluent/ToggleButton.xaml | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Button.xaml b/src/Avalonia.Themes.Fluent/Button.xaml index ee8060f823..345a74512c 100644 --- a/src/Avalonia.Themes.Fluent/Button.xaml +++ b/src/Avalonia.Themes.Fluent/Button.xaml @@ -54,16 +54,16 @@ - - - - - - - - - - - + - - - + From d8d19dd75abfdb4e5bbda2a65d7f56597361288f Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 12 Jun 2020 04:51:01 -0400 Subject: [PATCH 24/30] Initial Fluent NumericUpDown --- src/Avalonia.Themes.Fluent/NumericUpDown.xaml | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/NumericUpDown.xaml b/src/Avalonia.Themes.Fluent/NumericUpDown.xaml index 24cbb62908..08de50c6e3 100644 --- a/src/Avalonia.Themes.Fluent/NumericUpDown.xaml +++ b/src/Avalonia.Themes.Fluent/NumericUpDown.xaml @@ -1,38 +1,60 @@ - + + + + + + + + + + - - \ No newline at end of file + + From 0ac2468981bfefbaf3cfb0dc91f7733c7f7bbe00 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 14 Jun 2020 22:27:12 +0200 Subject: [PATCH 25/30] Fix typo in Track that was breaking layout for inverse horizontal tracks. --- src/Avalonia.Controls/Primitives/Track.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Primitives/Track.cs b/src/Avalonia.Controls/Primitives/Track.cs index 1db47a13e7..c91adaa26e 100644 --- a/src/Avalonia.Controls/Primitives/Track.cs +++ b/src/Avalonia.Controls/Primitives/Track.cs @@ -259,7 +259,7 @@ namespace Avalonia.Controls.Primitives CoerceLength(ref increaseButtonLength, arrangeSize.Width); CoerceLength(ref thumbLength, arrangeSize.Width); - offset = offset.WithY(isDirectionReversed ? increaseButtonLength + thumbLength : 0.0); + offset = offset.WithX(isDirectionReversed ? increaseButtonLength + thumbLength : 0.0); pieceSize = pieceSize.WithWidth(decreaseButtonLength); if (DecreaseButton != null) From 11190042ed258bf001ddf984336b5ffa2dc06f1e Mon Sep 17 00:00:00 2001 From: Max Katz Date: Sun, 14 Jun 2020 17:08:43 -0400 Subject: [PATCH 26/30] Add missed brushes for Fluent theme --- src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml | 3 +++ src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml b/src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml index 44318ffa8f..0bea6c5781 100644 --- a/src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml @@ -138,6 +138,9 @@ + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml b/src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml index e43a7ab4e7..ef296faa60 100644 --- a/src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml @@ -138,6 +138,9 @@ + + + From 0d685ac7d6d5570c691c4278fcb6f93c51306748 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 15 Jun 2020 02:11:33 -0400 Subject: [PATCH 27/30] Add :pressed :open :icon pseudoclasses to MenuItem --- src/Avalonia.Controls/MenuItem.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Avalonia.Controls/MenuItem.cs b/src/Avalonia.Controls/MenuItem.cs index b08519963b..912abc6de3 100644 --- a/src/Avalonia.Controls/MenuItem.cs +++ b/src/Avalonia.Controls/MenuItem.cs @@ -105,6 +105,7 @@ namespace Avalonia.Controls static MenuItem() { SelectableMixin.Attach(IsSelectedProperty); + PressedMixin.Attach(); CommandProperty.Changed.Subscribe(CommandChanged); FocusableProperty.OverrideDefaultValue(true); HeaderProperty.Changed.AddClassHandler((x, e) => x.HeaderChanged(e)); @@ -534,11 +535,13 @@ namespace Avalonia.Controls if (oldValue != null) { LogicalChildren.Remove(oldValue); + PseudoClasses.Remove(":icon"); } if (newValue != null) { LogicalChildren.Add(newValue); + PseudoClasses.Add(":icon"); } } @@ -566,11 +569,13 @@ namespace Avalonia.Controls { RaiseEvent(new RoutedEventArgs(SubmenuOpenedEvent)); IsSelected = true; + PseudoClasses.Add(":open"); } else { CloseSubmenus(); SelectedIndex = -1; + PseudoClasses.Remove(":open"); } } From edb7768ca269be2687bb796397c801fb54bb29b4 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 15 Jun 2020 02:11:42 -0400 Subject: [PATCH 28/30] Some MenuItem theme adjustments --- .../Accents/FluentControlResourcesDark.xaml | 56 +++- .../Accents/FluentControlResourcesLight.xaml | 54 +++- src/Avalonia.Themes.Fluent/Common.xaml | 6 + src/Avalonia.Themes.Fluent/ContextMenu.xaml | 58 +++- src/Avalonia.Themes.Fluent/Menu.xaml | 26 +- src/Avalonia.Themes.Fluent/MenuItem.xaml | 253 ++++++++++++------ src/Avalonia.Themes.Fluent/Separator.xaml | 12 +- 7 files changed, 351 insertions(+), 114 deletions(-) create mode 100644 src/Avalonia.Themes.Fluent/Common.xaml diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index cc35de185d..467f1f4ede 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -251,13 +251,56 @@ - 1 + 1 + 32 + 0,0 + + 12,0,0,0 + + 12,4,12,4 + + + + + + + + + + + + + + + + + + + + + + 11,9,11,10 11,4,11,7 1 - + + --> + --> + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index edbf68951f..a85b40893d 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -250,14 +250,57 @@ - 1 + 1 + 32 + 0,0 + + 12,0,0,0 + + 12,4,12,4 + + + + + + + + + + + + + + + + + + + + + 11,9,11,10 11,4,11,7 1 - + + --> + --> diff --git a/src/Avalonia.Themes.Fluent/Common.xaml b/src/Avalonia.Themes.Fluent/Common.xaml new file mode 100644 index 0000000000..e09e39d7cb --- /dev/null +++ b/src/Avalonia.Themes.Fluent/Common.xaml @@ -0,0 +1,6 @@ + + + diff --git a/src/Avalonia.Themes.Fluent/ContextMenu.xaml b/src/Avalonia.Themes.Fluent/ContextMenu.xaml index 9a583e2e30..44783a8dea 100644 --- a/src/Avalonia.Themes.Fluent/ContextMenu.xaml +++ b/src/Avalonia.Themes.Fluent/ContextMenu.xaml @@ -1,24 +1,60 @@ - - - - + + + + + + - + + - + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Separator.xaml b/src/Avalonia.Themes.Fluent/Separator.xaml index cf0db16ee6..dc968fe86c 100644 --- a/src/Avalonia.Themes.Fluent/Separator.xaml +++ b/src/Avalonia.Themes.Fluent/Separator.xaml @@ -4,17 +4,15 @@ - - - From dde9bebab1dd7a682b7758a7ef3eb47a04364374 Mon Sep 17 00:00:00 2001 From: ahopper Date: Mon, 15 Jun 2020 08:42:10 +0100 Subject: [PATCH 29/30] fix non zero minimum on slider --- src/Avalonia.Controls/Slider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index 64378a4eb2..fe1a4f5ac1 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -201,7 +201,7 @@ namespace Avalonia.Controls var invert = orient ? 0 : 1; var calcVal = Math.Abs(invert - logicalPos); var range = Maximum - Minimum; - var finalValue = calcVal * range; + var finalValue = calcVal * range + Minimum; Value = IsSnapToTickEnabled ? SnapToTick(finalValue) : finalValue; } From 752398188b3a83e50f6b5f3eb406b2f0abd4f76b Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Mon, 15 Jun 2020 06:06:43 -0400 Subject: [PATCH 30/30] Fix scroll events for legacy X11 --- src/Avalonia.X11/XI2Manager.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Avalonia.X11/XI2Manager.cs b/src/Avalonia.X11/XI2Manager.cs index 0734532d92..448635332c 100644 --- a/src/Avalonia.X11/XI2Manager.cs +++ b/src/Avalonia.X11/XI2Manager.cs @@ -237,6 +237,22 @@ namespace Avalonia.X11 RawPointerEventType.Move, ev.Position, ev.Modifiers)); } + if (ev.Type == XiEventType.XI_ButtonPress && ev.Button >= 4 && ev.Button <= 7 && !ev.Emulated) + { + Vector? scrollDelta = ev.Button switch + { + 4 => new Vector(0, 1), + 5 => new Vector(0, -1), + 6 => new Vector(1, 0), + 7 => new Vector(-1, 0), + _ => null + }; + + if (scrollDelta.HasValue) + client.ScheduleXI2Input(new RawMouseWheelEventArgs(client.MouseDevice, ev.Timestamp, + client.InputRoot, ev.Position, scrollDelta.Value, ev.Modifiers)); + } + if (ev.Type == XiEventType.XI_ButtonPress || ev.Type == XiEventType.XI_ButtonRelease) { var down = ev.Type == XiEventType.XI_ButtonPress;