浏览代码

Merge branch 'master' into volume_names_fixes

Jumar Macato 3 年之前
父节点
当前提交
2c178071f5
共有 29 个文件被更改,包括 139 次插入88 次删除
  1. 0 2
      build/CoreLibraries.props
  2. 1 0
      samples/BindingDemo/BindingDemo.csproj
  3. 2 0
      samples/ControlCatalog/ControlCatalog.csproj
  4. 6 0
      samples/ControlCatalog/Pages/TextBoxPage.xaml
  5. 2 1
      samples/IntegrationTestApp/IntegrationTestApp.csproj
  6. 1 0
      samples/PlatformSanityChecks/PlatformSanityChecks.csproj
  7. 3 0
      samples/Previewer/Previewer.csproj
  8. 1 0
      samples/RenderDemo/RenderDemo.csproj
  9. 1 0
      samples/Sandbox/Sandbox.csproj
  10. 1 0
      samples/VirtualizationDemo/VirtualizationDemo.csproj
  11. 1 0
      samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj
  12. 1 0
      samples/interop/NativeEmbedSample/NativeEmbedSample.csproj
  13. 2 3
      src/Avalonia.Base/DirectPropertyBase.cs
  14. 1 1
      src/Avalonia.Base/Input/InputElement.cs
  15. 3 5
      src/Avalonia.Base/StyledPropertyBase.cs
  16. 5 0
      src/Avalonia.Base/Styling/IStyleInstance.cs
  17. 6 4
      src/Avalonia.Base/Styling/PropertySetterInstance.cs
  18. 15 16
      src/Avalonia.Base/Styling/PropertySetterTemplateInstance.cs
  19. 0 9
      src/Avalonia.Base/Styling/Setter.cs
  20. 18 17
      src/Avalonia.Base/Styling/StyleInstance.cs
  21. 21 12
      src/Avalonia.Controls/Calendar/CalendarItem.cs
  22. 20 5
      src/Avalonia.Controls/Presenters/TextPresenter.cs
  23. 17 2
      src/Avalonia.Controls/TextBox.cs
  24. 2 1
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs
  25. 1 0
      src/Avalonia.Themes.Default/Controls/TextBox.xaml
  26. 1 0
      src/Avalonia.Themes.Fluent/Controls/TextBox.xaml
  27. 2 2
      tests/Avalonia.Base.UnitTests/Input/PointerOverTests.cs
  28. 4 7
      tests/Avalonia.Base.UnitTests/Styling/SetterTests.cs
  29. 1 1
      tests/Avalonia.Controls.UnitTests/CalendarTests.cs

+ 0 - 2
build/CoreLibraries.props

@@ -3,8 +3,6 @@
       <ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Base/Avalonia.Base.csproj" />
       <ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Controls/Avalonia.Controls.csproj" />
       <ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj" />
-      <ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj" />
-      <ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj" />
       <ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.OpenGL/Avalonia.OpenGL.csproj" />
       <ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Dialogs/Avalonia.Dialogs.csproj" />
       <ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Markup/Avalonia.Markup/Avalonia.Markup.csproj" />

+ 1 - 0
samples/BindingDemo/BindingDemo.csproj

@@ -5,6 +5,7 @@
   </PropertyGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
+    <ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj" />
     <ProjectReference Include="..\..\src\Linux\Avalonia.LinuxFramebuffer\Avalonia.LinuxFramebuffer.csproj" />
     <ProjectReference Include="..\MiniMvvm\MiniMvvm.csproj" />
   </ItemGroup>

+ 2 - 0
samples/ControlCatalog/ControlCatalog.csproj

@@ -25,6 +25,8 @@
     <ProjectReference Include="..\..\packages\Avalonia\Avalonia.csproj" />
     <ProjectReference Include="..\..\src\Avalonia.Controls.ColorPicker\Avalonia.Controls.ColorPicker.csproj" />
     <ProjectReference Include="..\..\src\Avalonia.Controls.DataGrid\Avalonia.Controls.DataGrid.csproj" />
+    <ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj" />
+    <ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
     <ProjectReference Include="..\MiniMvvm\MiniMvvm.csproj" />
     <ProjectReference Include="..\SampleControls\ControlSamples.csproj" />
   </ItemGroup>

+ 6 - 0
samples/ControlCatalog/Pages/TextBoxPage.xaml

@@ -66,6 +66,12 @@
                  FontFamily="Comic Sans MS"
                  InputMethod.IsInputMethodEnabled="False"
                  Foreground="Red"/>
+        <TextBox AcceptsReturn="True" 
+                 TextWrapping="Wrap" 
+                 Width="200" 
+                 Height="125"
+                 LineHeight="32"
+                 Text="Multiline TextBox with TextWrapping and increased LineHeight.&#xD;&#xD;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est." />
       </StackPanel>
       <StackPanel Orientation="Vertical" Spacing="8" Margin="8">
         <Label Classes="h2" Target="{Binding #firstResMFont}">res_m fonts</Label>

+ 2 - 1
samples/IntegrationTestApp/IntegrationTestApp.csproj

@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <OutputType>WinExe</OutputType>
     <TargetFramework>net6.0</TargetFramework>
@@ -18,6 +18,7 @@
 
   <ItemGroup>
     <ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
+    <ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
   </ItemGroup>
   
   <Import Project="..\..\build\BuildTargets.targets" />

+ 1 - 0
samples/PlatformSanityChecks/PlatformSanityChecks.csproj

@@ -7,6 +7,7 @@
 
   <ItemGroup>
     <ProjectReference Include="..\..\src\Avalonia.Desktop\Avalonia.Desktop.csproj" />
+    <ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj" />
     <ProjectReference Include="..\..\src\Avalonia.X11\Avalonia.X11.csproj" />
   </ItemGroup>
 

+ 3 - 0
samples/Previewer/Previewer.csproj

@@ -9,6 +9,9 @@
     </Compile>
     <EmbeddedResource Include="**\*.xaml" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj" />
+  </ItemGroup>
   
   <Import Project="..\..\build\SampleApp.props" />
   <Import Project="..\..\build\ReferenceCoreLibraries.props" />

+ 1 - 0
samples/RenderDemo/RenderDemo.csproj

@@ -12,6 +12,7 @@
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
+    <ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
     <ProjectReference Include="..\..\src\Linux\Avalonia.LinuxFramebuffer\Avalonia.LinuxFramebuffer.csproj" />
     <ProjectReference Include="..\MiniMvvm\MiniMvvm.csproj" />
     <ProjectReference Include="..\SampleControls\ControlSamples.csproj" />

+ 1 - 0
samples/Sandbox/Sandbox.csproj

@@ -10,6 +10,7 @@
     <ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
     <ProjectReference Include="..\..\src\Avalonia.Controls.ColorPicker\Avalonia.Controls.ColorPicker.csproj" />
     <ProjectReference Include="..\..\src\Avalonia.Controls.DataGrid\Avalonia.Controls.DataGrid.csproj" />
+    <ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
   </ItemGroup>
   
   <Import Project="..\..\build\SampleApp.props" />

+ 1 - 0
samples/VirtualizationDemo/VirtualizationDemo.csproj

@@ -5,6 +5,7 @@
   </PropertyGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
+    <ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj" />
     <ProjectReference Include="..\..\src\Linux\Avalonia.LinuxFramebuffer\Avalonia.LinuxFramebuffer.csproj" />
     <ProjectReference Include="..\MiniMvvm\MiniMvvm.csproj" />
   </ItemGroup>

+ 1 - 0
samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj

@@ -22,6 +22,7 @@
       </EmbeddedResource>
     </ItemGroup>
     <ItemGroup>
+        <ProjectReference Include="..\..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj" />
         <ProjectReference Include="..\..\..\src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj" />
         <ProjectReference Include="..\..\..\src\Windows\Avalonia.Win32\Avalonia.Win32.csproj" />
         <ProjectReference Include="..\..\MiniMvvm\MiniMvvm.csproj" />

+ 1 - 0
samples/interop/NativeEmbedSample/NativeEmbedSample.csproj

@@ -9,6 +9,7 @@
 
   <ItemGroup>
     <PackageReference Include="MonoMac.NetStandard" Version="0.0.4" />
+    <ProjectReference Include="..\..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj" />
     <ProjectReference Include="..\..\..\src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj" />
     <ProjectReference Include="..\..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
     <ProjectReference Include="..\..\..\src\Avalonia.X11\Avalonia.X11.csproj" />

+ 2 - 3
src/Avalonia.Base/DirectPropertyBase.cs

@@ -2,7 +2,6 @@
 using Avalonia.Data;
 using Avalonia.Reactive;
 using Avalonia.Styling;
-using Avalonia.Utilities;
 
 namespace Avalonia
 {
@@ -188,10 +187,10 @@ namespace Avalonia
             }
             else if (value is ITemplate template && !typeof(ITemplate).IsAssignableFrom(PropertyType))
             {
-                return new PropertySetterLazyInstance<TValue>(
+                return new PropertySetterTemplateInstance<TValue>(
                     target,
                     this,
-                    () => (TValue)template.Build());
+                    template);
             }
             else
             {

+ 1 - 1
src/Avalonia.Base/Input/InputElement.cs

@@ -144,7 +144,7 @@ namespace Avalonia.Input
         /// </summary>
         public static readonly RoutedEvent<PointerEventArgs> PointerMovedEvent =
             RoutedEvent.Register<InputElement, PointerEventArgs>(
-                "PointerMove",
+                "PointerMoved",
                 RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
 
         /// <summary>

+ 3 - 5
src/Avalonia.Base/StyledPropertyBase.cs

@@ -1,9 +1,7 @@
 using System;
-using System.Diagnostics;
 using Avalonia.Data;
 using Avalonia.Reactive;
 using Avalonia.Styling;
-using Avalonia.Utilities;
 
 namespace Avalonia
 {
@@ -12,7 +10,7 @@ namespace Avalonia
     /// </summary>
     public abstract class StyledPropertyBase<TValue> : AvaloniaProperty<TValue>, IStyledPropertyAccessor
     {
-        private bool _inherits;
+        private readonly bool _inherits;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="StyledPropertyBase{T}"/> class.
@@ -243,10 +241,10 @@ namespace Avalonia
             }
             else if (value is ITemplate template && !typeof(ITemplate).IsAssignableFrom(PropertyType))
             {
-                return new PropertySetterLazyInstance<TValue>(
+                return new PropertySetterTemplateInstance<TValue>(
                     target,
                     this,
-                    () => (TValue)template.Build());
+                    template);
             }
             else
             {

+ 5 - 0
src/Avalonia.Base/Styling/IStyleInstance.cs

@@ -14,6 +14,11 @@ namespace Avalonia.Styling
         /// </summary>
         IStyle Source { get; }
 
+        /// <summary>
+        /// Gets a value indicating whether this style has an activator.
+        /// </summary>
+        bool HasActivator { get; }
+        
         /// <summary>
         /// Gets a value indicating whether this style is active.
         /// </summary>

+ 6 - 4
src/Avalonia.Base/Styling/PropertySetterInstance.cs

@@ -44,7 +44,7 @@ namespace Avalonia.Styling
         {
             if (hasActivator)
             {
-                if (_styledProperty is object)
+                if (_styledProperty is not null)
                 {
                     _subscription = _target.Bind(_styledProperty, this, BindingPriority.StyleTrigger);
                 }
@@ -55,13 +55,15 @@ namespace Avalonia.Styling
             }
             else
             {
-                if (_styledProperty is object)
+                var target = (AvaloniaObject) _target;
+                
+                if (_styledProperty is not null)
                 {
-                    _subscription = _target.SetValue(_styledProperty!, _value, BindingPriority.Style);
+                    _subscription = target.SetValue(_styledProperty!, _value, BindingPriority.Style);
                 }
                 else
                 {
-                    _target.SetValue(_directProperty!, _value);
+                    target.SetValue(_directProperty!, _value);
                 }
             }
         }

+ 15 - 16
src/Avalonia.Base/Styling/PropertySetterLazyInstance.cs → src/Avalonia.Base/Styling/PropertySetterTemplateInstance.cs

@@ -11,42 +11,42 @@ namespace Avalonia.Styling
     /// evaluated.
     /// </summary>
     /// <typeparam name="T">The target property type.</typeparam>
-    internal class PropertySetterLazyInstance<T> : SingleSubscriberObservableBase<BindingValue<T>>,
+    internal class PropertySetterTemplateInstance<T> : SingleSubscriberObservableBase<BindingValue<T>>,
         ISetterInstance
     {
         private readonly IStyleable _target;
         private readonly StyledPropertyBase<T>? _styledProperty;
         private readonly DirectPropertyBase<T>? _directProperty;
-        private readonly Func<T> _valueFactory;
+        private readonly ITemplate _template;
         private BindingValue<T> _value;
         private IDisposable? _subscription;
         private bool _isActive;
 
-        public PropertySetterLazyInstance(
+        public PropertySetterTemplateInstance(
             IStyleable target,
             StyledPropertyBase<T> property,
-            Func<T> valueFactory)
+            ITemplate template)
         {
             _target = target;
             _styledProperty = property;
-            _valueFactory = valueFactory;
+            _template = template;
         }
 
-        public PropertySetterLazyInstance(
+        public PropertySetterTemplateInstance(
             IStyleable target,
             DirectPropertyBase<T> property,
-            Func<T> valueFactory)
+            ITemplate template)
         {
             _target = target;
             _directProperty = property;
-            _valueFactory = valueFactory;
+            _template = template;
         }
 
         public void Start(bool hasActivator)
         {
             _isActive = !hasActivator;
 
-            if (_styledProperty is object)
+            if (_styledProperty is not null)
             {
                 var priority = hasActivator ? BindingPriority.StyleTrigger : BindingPriority.Style;
                 _subscription = _target.Bind(_styledProperty, this, priority);
@@ -77,7 +77,7 @@ namespace Avalonia.Styling
 
         public override void Dispose()
         {
-            if (_subscription is object)
+            if (_subscription is not null)
             {
                 var sub = _subscription;
                 _subscription = null;
@@ -85,7 +85,7 @@ namespace Avalonia.Styling
             }
             else if (_isActive)
             {
-                if (_styledProperty is object)
+                if (_styledProperty is not null)
                 {
                     _target.ClearValue(_styledProperty);
                 }
@@ -101,22 +101,21 @@ namespace Avalonia.Styling
         protected override void Subscribed() => PublishNext();
         protected override void Unsubscribed() { }
 
-        private T GetValue()
+        private void EnsureTemplate()
         {
             if (_value.HasValue)
             {
-                return _value.Value;
+                return;
             }
 
-            _value = _valueFactory();
-            return _value.Value;
+            _value = (T) _template.Build();
         }
 
         private void PublishNext()
         {
             if (_isActive)
             {
-                GetValue();
+                EnsureTemplate();
                 PublishNext(_value);
             }
             else

+ 0 - 9
src/Avalonia.Base/Styling/Setter.cs

@@ -1,9 +1,7 @@
 using System;
 using Avalonia.Animation;
 using Avalonia.Data;
-using Avalonia.Data.Core;
 using Avalonia.Metadata;
-using Avalonia.Utilities;
 
 #nullable enable
 
@@ -70,12 +68,5 @@ namespace Avalonia.Styling
 
             return Property.CreateSetterInstance(target, Value);
         }
-
-        private struct SetterVisitorData
-        {
-            public IStyleable target;
-            public object? value;
-            public ISetterInstance? result;
-        }
     }
 }

+ 18 - 17
src/Avalonia.Base/Styling/StyleInstance.cs

@@ -11,10 +11,10 @@ namespace Avalonia.Styling
     /// <summary>
     /// A <see cref="Style"/> which has been instanced on a control.
     /// </summary>
-    internal class StyleInstance : IStyleInstance, IStyleActivatorSink
+    internal sealed class StyleInstance : IStyleInstance, IStyleActivatorSink
     {
-        private readonly List<ISetterInstance>? _setters;
-        private readonly List<IDisposable>? _animations;
+        private readonly ISetterInstance[]? _setters;
+        private readonly IDisposable[]? _animations;
         private readonly IStyleActivator? _activator;
         private readonly Subject<bool>? _animationTrigger;
 
@@ -30,41 +30,42 @@ namespace Avalonia.Styling
             _activator = activator;
             IsActive = _activator is null;
 
-            if (setters is object)
+            if (setters is not null)
             {
                 var setterCount = setters.Count;
 
-                _setters = new List<ISetterInstance>(setterCount);
+                _setters = new ISetterInstance[setterCount];
 
                 for (var i = 0; i < setterCount; ++i)
                 {
-                    _setters.Add(setters[i].Instance(Target));
+                    _setters[i] = setters[i].Instance(Target);
                 }
             }
 
-            if (animations is object && target is Animatable animatable)
+            if (animations is not null && target is Animatable animatable)
             {
                 var animationsCount = animations.Count;
 
-                _animations = new List<IDisposable>(animationsCount);
+                _animations = new IDisposable[animationsCount];
                 _animationTrigger = new Subject<bool>();
 
                 for (var i = 0; i < animationsCount; ++i)
                 {
-                    _animations.Add(animations[i].Apply(animatable, null, _animationTrigger));
+                    _animations[i] = animations[i].Apply(animatable, null, _animationTrigger);
                 }
             }
         }
 
+        public bool HasActivator => _activator is not null;
         public bool IsActive { get; private set; }
         public IStyle Source { get; }
         public IStyleable Target { get; }
 
         public void Start()
         {
-            var hasActivator = _activator is object;
+            var hasActivator = HasActivator;
 
-            if (_setters is object)
+            if (_setters is not null)
             {
                 foreach (var setter in _setters)
                 {
@@ -76,7 +77,7 @@ namespace Avalonia.Styling
             {
                 _activator!.Subscribe(this, 0);
             }
-            else if (_animationTrigger != null)
+            else if (_animationTrigger is not null)
             {
                 _animationTrigger.OnNext(true);
             }
@@ -84,7 +85,7 @@ namespace Avalonia.Styling
 
         public void Dispose()
         {
-            if (_setters is object)
+            if (_setters is not null)
             {
                 foreach (var setter in _setters)
                 {
@@ -92,11 +93,11 @@ namespace Avalonia.Styling
                 }
             }
 
-            if (_animations is object)
+            if (_animations is not null)
             {
-                foreach (var subscripion in _animations)
+                foreach (var subscription in _animations)
                 {
-                    subscripion.Dispose();
+                    subscription.Dispose();
                 }
             }
 
@@ -111,7 +112,7 @@ namespace Avalonia.Styling
 
                 _animationTrigger?.OnNext(value);
 
-                if (_setters is object)
+                if (_setters is not null)
                 {
                     if (IsActive)
                     {

+ 21 - 12
src/Avalonia.Controls/Calendar/CalendarItem.cs

@@ -7,6 +7,7 @@ using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Globalization;
+using Avalonia.Collections.Pooled;
 using Avalonia.Controls.Metadata;
 using Avalonia.Data;
 using Avalonia.Input;
@@ -172,13 +173,13 @@ namespace Avalonia.Controls.Primitives
             if (MonthView != null)
             {
                 var childCount = Calendar.RowsPerMonth + Calendar.RowsPerMonth * Calendar.ColumnsPerMonth;
-                var children = new List<IControl>(childCount);
+                using var children = new PooledList<IControl>(childCount);
 
                 for (int i = 0; i < Calendar.RowsPerMonth; i++)
                 {
                     if (_dayTitleTemplate != null)
                     {
-                        var cell = _dayTitleTemplate.Build();
+                        var cell = (Control) _dayTitleTemplate.Build();
                         cell.DataContext = string.Empty;
                         cell.SetValue(Grid.RowProperty, 0);
                         cell.SetValue(Grid.ColumnProperty, i);
@@ -186,11 +187,16 @@ namespace Avalonia.Controls.Primitives
                     }
                 }
 
+                EventHandler<PointerPressedEventArgs> cellMouseLeftButtonDown = Cell_MouseLeftButtonDown;
+                EventHandler<PointerReleasedEventArgs> cellMouseLeftButtonUp = Cell_MouseLeftButtonUp;
+                EventHandler<PointerEventArgs> cellMouseEnter = Cell_MouseEnter;
+                EventHandler<RoutedEventArgs> cellClick = Cell_Click;
+
                 for (int i = 1; i < Calendar.RowsPerMonth; i++)
                 {
                     for (int j = 0; j < Calendar.ColumnsPerMonth; j++)
                     {
-                        CalendarDayButton cell = new CalendarDayButton();
+                        var cell = new CalendarDayButton();
 
                         if (Owner != null)
                         {
@@ -198,10 +204,10 @@ namespace Avalonia.Controls.Primitives
                         }
                         cell.SetValue(Grid.RowProperty, i);
                         cell.SetValue(Grid.ColumnProperty, j);
-                        cell.CalendarDayButtonMouseDown += Cell_MouseLeftButtonDown;
-                        cell.CalendarDayButtonMouseUp += Cell_MouseLeftButtonUp;
-                        cell.PointerEnter += Cell_MouseEnter;
-                        cell.Click += Cell_Click;
+                        cell.CalendarDayButtonMouseDown += cellMouseLeftButtonDown;
+                        cell.CalendarDayButtonMouseUp += cellMouseLeftButtonUp;
+                        cell.PointerEnter += cellMouseEnter;
+                        cell.Click += cellClick;
                         children.Add(cell);
                     }
                 }
@@ -214,12 +220,15 @@ namespace Avalonia.Controls.Primitives
                 var childCount = Calendar.RowsPerYear * Calendar.ColumnsPerYear;
                 var children = new List<IControl>(childCount);
 
-                CalendarButton month;
+                EventHandler<PointerPressedEventArgs> monthCalendarButtonMouseDown = Month_CalendarButtonMouseDown;
+                EventHandler<PointerReleasedEventArgs> monthCalendarButtonMouseUp = Month_CalendarButtonMouseUp;
+                EventHandler<PointerEventArgs> monthMouseEnter = Month_MouseEnter;
+
                 for (int i = 0; i < Calendar.RowsPerYear; i++)
                 {
                     for (int j = 0; j < Calendar.ColumnsPerYear; j++)
                     {
-                        month = new CalendarButton();
+                        var month = new CalendarButton();
 
                         if (Owner != null)
                         {
@@ -227,9 +236,9 @@ namespace Avalonia.Controls.Primitives
                         }
                         month.SetValue(Grid.RowProperty, i);
                         month.SetValue(Grid.ColumnProperty, j);
-                        month.CalendarLeftMouseButtonDown += Month_CalendarButtonMouseDown;
-                        month.CalendarLeftMouseButtonUp += Month_CalendarButtonMouseUp;
-                        month.PointerEnter += Month_MouseEnter;
+                        month.CalendarLeftMouseButtonDown += monthCalendarButtonMouseDown;
+                        month.CalendarLeftMouseButtonUp += monthCalendarButtonMouseUp;
+                        month.PointerEnter += monthMouseEnter;
                         children.Add(month);
                     }
                 }

+ 20 - 5
src/Avalonia.Controls/Presenters/TextPresenter.cs

@@ -33,7 +33,7 @@ namespace Avalonia.Controls.Presenters
 
         public static readonly StyledProperty<IBrush?> CaretBrushProperty =
             AvaloniaProperty.Register<TextPresenter, IBrush?>(nameof(CaretBrush));
-
+        
         public static readonly DirectProperty<TextPresenter, int> SelectionStartProperty =
             TextBox.SelectionStartProperty.AddOwner<TextPresenter>(
                 o => o.SelectionStart,
@@ -43,7 +43,7 @@ namespace Avalonia.Controls.Presenters
             TextBox.SelectionEndProperty.AddOwner<TextPresenter>(
                 o => o.SelectionEnd,
                 (o, v) => o.SelectionEnd = v);
-
+        
         /// <summary>
         /// Defines the <see cref="Text"/> property.
         /// </summary>
@@ -65,6 +65,12 @@ namespace Avalonia.Controls.Presenters
         public static readonly StyledProperty<TextWrapping> TextWrappingProperty =
             TextBlock.TextWrappingProperty.AddOwner<TextPresenter>();
 
+        /// <summary>
+        /// Defines the <see cref="LineHeight"/> property.
+        /// </summary>
+        public static readonly StyledProperty<double> LineHeightProperty =
+            TextBlock.LineHeightProperty.AddOwner<TextPresenter>();
+        
         /// <summary>
         /// Defines the <see cref="Background"/> property.
         /// </summary>
@@ -179,6 +185,15 @@ namespace Avalonia.Controls.Presenters
             get => GetValue(TextWrappingProperty);
             set => SetValue(TextWrappingProperty, value);
         }
+        
+        /// <summary>
+        /// Gets or sets the line height. By default, this is set to <see cref="double.NaN"/>, which determines the appropriate height automatically.
+        /// </summary>
+        public double LineHeight
+        {
+            get => GetValue(LineHeightProperty);
+            set => SetValue(LineHeightProperty, value);
+        }
 
         /// <summary>
         /// Gets or sets the text alignment.
@@ -253,7 +268,7 @@ namespace Avalonia.Controls.Presenters
             get => GetValue(CaretBrushProperty);
             set => SetValue(CaretBrushProperty, value);
         }
-
+        
         public int SelectionStart
         {
             get
@@ -281,7 +296,7 @@ namespace Avalonia.Controls.Presenters
                 SetAndRaise(SelectionEndProperty, ref _selectionEnd, value);
             }
         }
-
+        
         protected override bool BypassFlowDirectionPolicies => true;
 
         /// <summary>
@@ -301,7 +316,7 @@ namespace Avalonia.Controls.Presenters
             
             var textLayout = new TextLayout(text, typeface, FontSize, foreground, TextAlignment,
                 TextWrapping, maxWidth: maxWidth, maxHeight: maxHeight, textStyleOverrides: textStyleOverrides, 
-                flowDirection: FlowDirection);
+                flowDirection: FlowDirection, lineHeight: LineHeight);
 
             return textLayout;
         }

+ 17 - 2
src/Avalonia.Controls/TextBox.cs

@@ -79,8 +79,8 @@ namespace Avalonia.Controls
             AvaloniaProperty.Register<TextBox, int>(nameof(MaxLength), defaultValue: 0);
 
         public static readonly StyledProperty<int> MaxLinesProperty =
-      AvaloniaProperty.Register<TextBox, int>(nameof(MaxLines), defaultValue: 0);
-
+            AvaloniaProperty.Register<TextBox, int>(nameof(MaxLines), defaultValue: 0);
+        
         public static readonly DirectProperty<TextBox, string?> TextProperty =
             TextBlock.TextProperty.AddOwnerWithDataValidation<TextBox>(
                 o => o.Text,
@@ -105,6 +105,12 @@ namespace Avalonia.Controls
 
         public static readonly StyledProperty<TextWrapping> TextWrappingProperty =
             TextBlock.TextWrappingProperty.AddOwner<TextBox>();
+        
+        /// <summary>
+        /// Defines see <see cref="TextPresenter.LineHeight"/> property.
+        /// </summary>
+        public static readonly StyledProperty<double> LineHeightProperty =
+            TextBlock.LineHeightProperty.AddOwner<TextBox>();
 
         public static readonly StyledProperty<string?> WatermarkProperty =
             AvaloniaProperty.Register<TextBox, string?>(nameof(Watermark));
@@ -358,6 +364,15 @@ namespace Avalonia.Controls
             get { return GetValue(MaxLinesProperty); }
             set { SetValue(MaxLinesProperty, value); }
         }
+        
+        /// <summary>
+        /// Gets or sets the line height.
+        /// </summary>
+        public double LineHeight
+        {
+            get { return GetValue(LineHeightProperty); }
+            set { SetValue(LineHeightProperty, value); }
+        }
 
         [Content]
         public string? Text

+ 2 - 1
src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs

@@ -60,7 +60,8 @@ namespace Avalonia.Diagnostics.ViewModels
 
                 var styleDiagnostics = styledElement.GetStyleDiagnostics();
 
-                foreach (var appliedStyle in styleDiagnostics.AppliedStyles)
+                // We need to place styles without activator first, such styles will be overwritten by ones with activators.
+                foreach (var appliedStyle in styleDiagnostics.AppliedStyles.OrderBy(s => s.HasActivator))
                 {
                     var styleSource = appliedStyle.Source;
 

+ 1 - 0
src/Avalonia.Themes.Default/Controls/TextBox.xaml

@@ -76,6 +76,7 @@
                                     SelectionEnd="{TemplateBinding SelectionEnd}"
                                     TextAlignment="{TemplateBinding TextAlignment}"
                                     TextWrapping="{TemplateBinding TextWrapping}"
+                                    LineHeight="{TemplateBinding LineHeight}"
                                     PasswordChar="{TemplateBinding PasswordChar}"
                                     RevealPassword="{TemplateBinding RevealPassword}"
                                     SelectionBrush="{TemplateBinding SelectionBrush}"

+ 1 - 0
src/Avalonia.Themes.Fluent/Controls/TextBox.xaml

@@ -89,6 +89,7 @@
                                       SelectionEnd="{TemplateBinding SelectionEnd}"
                                       TextAlignment="{TemplateBinding TextAlignment}"
                                       TextWrapping="{TemplateBinding TextWrapping}"
+                                      LineHeight="{TemplateBinding LineHeight}"
                                       PasswordChar="{TemplateBinding PasswordChar}"
                                       RevealPassword="{TemplateBinding RevealPassword}"
                                       SelectionBrush="{TemplateBinding SelectionBrush}"

+ 2 - 2
tests/Avalonia.Base.UnitTests/Input/PointerOverTests.cs

@@ -247,10 +247,10 @@ namespace Avalonia.Base.UnitTests.Input
                 new[]
                 {
                         ((object?)decorator, "PointerEnter"),
-                        (decorator, "PointerMove"),
+                        (decorator, "PointerMoved"),
                         (decorator, "PointerLeave"),
                         (canvas, "PointerEnter"),
-                        (canvas, "PointerMove")
+                        (canvas, "PointerMoved")
                 },
                 result);
         }

+ 4 - 7
tests/Avalonia.Base.UnitTests/Styling/SetterTests.cs

@@ -91,16 +91,13 @@ namespace Avalonia.Base.UnitTests.Styling
         [Fact]
         public void Setter_Should_Apply_Value_Without_Activator_With_Style_Priority()
         {
-            var control = new Mock<IStyleable>();
-            var style = Mock.Of<Style>();
+            var control = new Control();
             var setter = new Setter(TextBlock.TagProperty, "foo");
 
-            setter.Instance(control.Object).Start(false);
+            setter.Instance(control).Start(false);
 
-            control.Verify(x => x.SetValue(
-                TextBlock.TagProperty,
-                "foo",
-                BindingPriority.Style));
+            Assert.Equal("foo", control.Tag);
+            Assert.Equal(BindingPriority.Style, control.GetDiagnostic(TextBlock.TagProperty).Priority);
         }
 
         [Fact]

+ 1 - 1
tests/Avalonia.Controls.UnitTests/CalendarTests.cs

@@ -15,7 +15,7 @@ namespace Avalonia.Controls.UnitTests
                 first.Day == second.Day;
         }
 
-        [Fact(Skip ="FIX ME ASAP")]
+        [Fact]
         public void SelectedDatesChanged_Should_Fire_When_SelectedDate_Set()
         {
             bool handled = false;