From a99963e3a0e4172d257ec63c3be765ac3086f389 Mon Sep 17 00:00:00 2001 From: amwx Date: Fri, 29 May 2020 04:08:07 -0500 Subject: [PATCH 01/13] Fluent Calendar style --- .../Accents/FluentControlResourcesDark.xaml | 28 ++ .../Accents/FluentControlResourcesLight.xaml | 28 ++ src/Avalonia.Themes.Fluent/Calendar.xaml | 13 +- .../CalendarButton.xaml | 124 ++++---- .../CalendarDayButton.xaml | 156 +++++----- src/Avalonia.Themes.Fluent/CalendarItem.xaml | 272 +++++++----------- 6 files changed, 321 insertions(+), 300 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index a0f3ef0d62..fd6203d82d 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -153,5 +153,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index ec4f35664c..436b8af3d6 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -153,5 +153,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Calendar.xaml b/src/Avalonia.Themes.Fluent/Calendar.xaml index 6bbee4ef17..2fbc705d83 100644 --- a/src/Avalonia.Themes.Fluent/Calendar.xaml +++ b/src/Avalonia.Themes.Fluent/Calendar.xaml @@ -7,11 +7,12 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Fluent/CalendarButton.xaml b/src/Avalonia.Themes.Fluent/CalendarButton.xaml index 3314534b3b..2ba4489204 100644 --- a/src/Avalonia.Themes.Fluent/CalendarButton.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarButton.xaml @@ -7,75 +7,99 @@ - - --> + + - - - - - - - + + + - - + + + + diff --git a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml index 2d79e62a75..1e5953ab2d 100644 --- a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml @@ -7,110 +7,102 @@ - - - - + --> - - - - - - - - - - - - - - - - + diff --git a/src/Avalonia.Themes.Fluent/CalendarItem.xaml b/src/Avalonia.Themes.Fluent/CalendarItem.xaml index dfd89ed82f..41f3fcbc1f 100644 --- a/src/Avalonia.Themes.Fluent/CalendarItem.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarItem.xaml @@ -8,176 +8,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - From 3b48112e1d3f44beaf0df52eb738554e3bd81e57 Mon Sep 17 00:00:00 2001 From: amwx Date: Fri, 29 May 2020 04:24:07 -0500 Subject: [PATCH 02/13] Fluent Calendar Style --- src/Avalonia.Themes.Fluent/Calendar.xaml | 2 +- src/Avalonia.Themes.Fluent/CalendarButton.xaml | 9 ++++++--- src/Avalonia.Themes.Fluent/CalendarDayButton.xaml | 14 ++++++-------- src/Avalonia.Themes.Fluent/CalendarItem.xaml | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Calendar.xaml b/src/Avalonia.Themes.Fluent/Calendar.xaml index 2fbc705d83..6ae334dbae 100644 --- a/src/Avalonia.Themes.Fluent/Calendar.xaml +++ b/src/Avalonia.Themes.Fluent/Calendar.xaml @@ -5,7 +5,7 @@ // All other rights reserved. --> - + - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Fluent/CalendarButton.xaml b/src/Avalonia.Themes.Fluent/CalendarButton.xaml index 3314534b3b..2ba4489204 100644 --- a/src/Avalonia.Themes.Fluent/CalendarButton.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarButton.xaml @@ -7,75 +7,99 @@ - - --> + + - - - - - - - + + + - - + + + + diff --git a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml index 2d79e62a75..1e5953ab2d 100644 --- a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml @@ -7,110 +7,102 @@ - - - - + --> - - - - - - - - - - - - - - - - + diff --git a/src/Avalonia.Themes.Fluent/CalendarItem.xaml b/src/Avalonia.Themes.Fluent/CalendarItem.xaml index dfd89ed82f..41f3fcbc1f 100644 --- a/src/Avalonia.Themes.Fluent/CalendarItem.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarItem.xaml @@ -8,176 +8,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - From 5065e6c072020860312c01053365105759c5e7eb Mon Sep 17 00:00:00 2001 From: amwx Date: Fri, 29 May 2020 04:24:07 -0500 Subject: [PATCH 04/13] Fluent Calendar Style --- src/Avalonia.Themes.Fluent/Calendar.xaml | 2 +- src/Avalonia.Themes.Fluent/CalendarButton.xaml | 9 ++++++--- src/Avalonia.Themes.Fluent/CalendarDayButton.xaml | 14 ++++++-------- src/Avalonia.Themes.Fluent/CalendarItem.xaml | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Calendar.xaml b/src/Avalonia.Themes.Fluent/Calendar.xaml index 2fbc705d83..6ae334dbae 100644 --- a/src/Avalonia.Themes.Fluent/Calendar.xaml +++ b/src/Avalonia.Themes.Fluent/Calendar.xaml @@ -5,7 +5,7 @@ // All other rights reserved. --> - + --> + + diff --git a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml index 4f6f5951d2..ff72044c93 100644 --- a/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarDayButton.xaml @@ -19,12 +19,14 @@ + + + BorderThickness="0" ClipToBounds="True"> + BorderBrush="{TemplateBinding BorderBrush}"/> - + + + --> + diff --git a/src/Avalonia.Themes.Fluent/CalendarItem.xaml b/src/Avalonia.Themes.Fluent/CalendarItem.xaml index 7e17ee7075..df17da84dc 100644 --- a/src/Avalonia.Themes.Fluent/CalendarItem.xaml +++ b/src/Avalonia.Themes.Fluent/CalendarItem.xaml @@ -61,6 +61,9 @@ + + 12 + 1 + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml index 5c6286a0bc..731ac1d0c7 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml @@ -313,5 +313,15 @@ + + + 12 + 1 + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml index 7364c339f1..d076df4cc9 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml @@ -343,5 +343,16 @@ + + + 12 + 1 + + + + + + + 8,5,8,7 diff --git a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml index 15e157f573..430e9f61cf 100644 --- a/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml +++ b/src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml @@ -343,5 +343,16 @@ + + + 12 + 1 + + + + + + + 8,5,8,7 From 1fa96f049c85b24cab9e57ff10a21d4790c4e1b4 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 3 Jun 2020 03:07:28 -0400 Subject: [PATCH 09/13] Implement ToolTip :open pseudo class --- src/Avalonia.Controls/ToolTip.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls/ToolTip.cs b/src/Avalonia.Controls/ToolTip.cs index 4ad5a6e60d..b458b15c64 100644 --- a/src/Avalonia.Controls/ToolTip.cs +++ b/src/Avalonia.Controls/ToolTip.cs @@ -204,13 +204,15 @@ namespace Avalonia.Controls private static void IsOpenChanged(AvaloniaPropertyChangedEventArgs e) { var control = (Control)e.Sender; + var newValue = (bool)e.NewValue; + ToolTip toolTip; - if ((bool)e.NewValue) + if (newValue) { var tip = GetTip(control); if (tip == null) return; - var toolTip = control.GetValue(ToolTipProperty); + toolTip = control.GetValue(ToolTipProperty); if (toolTip == null || (tip != toolTip && tip != toolTip.Content)) { toolTip?.Close(); @@ -223,9 +225,11 @@ namespace Avalonia.Controls } else { - var toolTip = control.GetValue(ToolTipProperty); + toolTip = control.GetValue(ToolTipProperty); toolTip?.Close(); } + + toolTip?.UpdatePseudoClasses(newValue); } private void Open(Control control) @@ -261,5 +265,10 @@ namespace Avalonia.Controls pr.PlatformImpl.SetWindowManagerAddShadowHint(hint); } } + + private void UpdatePseudoClasses(bool newValue) + { + PseudoClasses.Set(":open", newValue); + } } } From 5721702fadbd43619600d55fcfcd05c6be2956e6 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 3 Jun 2020 03:08:27 -0400 Subject: [PATCH 10/13] Fluent ToolTip style --- src/Avalonia.Themes.Fluent/ToolTip.xaml | 91 ++++++++++++++++++++----- 1 file changed, 74 insertions(+), 17 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ToolTip.xaml b/src/Avalonia.Themes.Fluent/ToolTip.xaml index 1fc0202dd3..f3c4266f77 100644 --- a/src/Avalonia.Themes.Fluent/ToolTip.xaml +++ b/src/Avalonia.Themes.Fluent/ToolTip.xaml @@ -1,17 +1,74 @@ - \ No newline at end of file + + + + + Hover Here + + + + + + ToolTip + A control which pops up a hint when a control is hovered + + + ToolTip bottom placement + + + + + + + + + + From d2a5f525dafd7d8310947a169320b817511ace5f Mon Sep 17 00:00:00 2001 From: Max Katz Date: Thu, 4 Jun 2020 22:20:31 -0400 Subject: [PATCH 11/13] Add text wrapping to Fluent ToolTip --- src/Avalonia.Themes.Fluent/ToolTip.xaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ToolTip.xaml b/src/Avalonia.Themes.Fluent/ToolTip.xaml index f3c4266f77..fa528ee6cf 100644 --- a/src/Avalonia.Themes.Fluent/ToolTip.xaml +++ b/src/Avalonia.Themes.Fluent/ToolTip.xaml @@ -8,7 +8,7 @@ Background="{DynamicResource ThemeAccentBrush}" Margin="5" Padding="50" - ToolTip.Tip="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."> + ToolTip.Tip="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."> Hover Here - + + + From bcd215e3db09e8c5a67774ff4b78599b2b9cf38b Mon Sep 17 00:00:00 2001 From: Max Katz Date: Thu, 4 Jun 2020 22:31:40 -0400 Subject: [PATCH 12/13] 150 ms opacity transition duration for ToolTip --- src/Avalonia.Themes.Fluent/ToolTip.xaml | 76 ++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/ToolTip.xaml b/src/Avalonia.Themes.Fluent/ToolTip.xaml index fa528ee6cf..cf6f32f9bc 100644 --- a/src/Avalonia.Themes.Fluent/ToolTip.xaml +++ b/src/Avalonia.Themes.Fluent/ToolTip.xaml @@ -1,39 +1,39 @@ - - + + Hover Here + + - Hover Here - - - - - - ToolTip - A control which pops up a hint when a control is hovered - - - ToolTip bottom placement - - + Grid.Row="0" + IsChecked="{Binding ElementName=Border, Path=(ToolTip.IsOpen)}" + Content="ToolTip Open" /> + + + + ToolTip + A control which pops up a hint when a control is hovered + + + ToolTip bottom placement + + - + - + From 53cb9d266d4f87789c30b37b55e6c5bf7cc095ae Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 5 Jun 2020 03:46:02 -0400 Subject: [PATCH 13/13] Add ToolTip :open pseudo class tests --- .../ToolTipTests.cs | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/ToolTipTests.cs b/tests/Avalonia.Controls.UnitTests/ToolTipTests.cs index dc5b574db7..34b37e7635 100644 --- a/tests/Avalonia.Controls.UnitTests/ToolTipTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ToolTipTests.cs @@ -102,5 +102,76 @@ namespace Avalonia.Controls.UnitTests Assert.True(ToolTip.GetIsOpen(target)); } } + + [Fact] + public void Open_Class_Should_Not_Initially_Be_Added() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var toolTip = new ToolTip(); + var window = new Window(); + + var decorator = new Decorator() + { + [ToolTip.TipProperty] = toolTip + }; + + window.Content = decorator; + + window.ApplyTemplate(); + window.Presenter.ApplyTemplate(); + + Assert.Empty(toolTip.Classes); + } + } + + [Fact] + public void Setting_IsOpen_Should_Add_Open_Class() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var toolTip = new ToolTip(); + var window = new Window(); + + var decorator = new Decorator() + { + [ToolTip.TipProperty] = toolTip + }; + + window.Content = decorator; + + window.ApplyTemplate(); + window.Presenter.ApplyTemplate(); + + ToolTip.SetIsOpen(decorator, true); + + Assert.Equal(new[] { ":open" }, toolTip.Classes); + } + } + + [Fact] + public void Clearing_IsOpen_Should_Remove_Open_Class() + { + using (UnitTestApplication.Start(TestServices.StyledWindow)) + { + var toolTip = new ToolTip(); + var window = new Window(); + + var decorator = new Decorator() + { + [ToolTip.TipProperty] = toolTip + }; + + window.Content = decorator; + + window.ApplyTemplate(); + window.Presenter.ApplyTemplate(); + + ToolTip.SetIsOpen(decorator, true); + ToolTip.SetIsOpen(decorator, false); + + Assert.Empty(toolTip.Classes); + } + } } }