Browse Source

Merge branch 'master' into refactor/singlesubscriberobservablebase-internal

pull/11556/head
Max Katz 3 years ago
committed by GitHub
parent
commit
c302d82de3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      build/SharedVersion.props
  2. 4
      samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs
  3. 1
      samples/Sandbox/Sandbox.csproj
  4. 4
      src/Avalonia.Base/Input/AccessKeyHandler.cs
  5. 2
      src/Avalonia.Base/Input/IMainMenu.cs
  6. 46
      src/Avalonia.Base/Interactivity/RoutedPropertyChangedEventArgs.cs
  7. 1
      src/Avalonia.Base/Media/CharacterHit.cs
  8. 74
      src/Avalonia.Base/Media/TextFormatting/BidiReorderer.cs
  9. 10
      src/Avalonia.Base/Media/TextFormatting/IndexedTextRun.cs
  10. 2
      src/Avalonia.Base/Media/TextFormatting/TextBounds.cs
  11. 594
      src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs
  12. 2
      src/Avalonia.Build.Tasks/GenerateAvaloniaResourcesTask.cs
  13. 43
      src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs
  14. 90
      src/Avalonia.Controls/Border.cs
  15. 12
      src/Avalonia.Controls/ContextMenu.cs
  16. 2
      src/Avalonia.Controls/DateTimePickers/DatePickerPresenter.cs
  17. 4
      src/Avalonia.Controls/Menu.cs
  18. 28
      src/Avalonia.Controls/MenuBase.cs
  19. 4
      src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs
  20. 5
      src/Avalonia.Controls/Primitives/LightDismissOverlayLayer.cs
  21. 8
      src/Avalonia.Controls/Primitives/RangeBase.cs
  22. 47
      src/Avalonia.Controls/Primitives/RangeBaseValueChangedEventArgs.cs
  23. 284
      src/Avalonia.Controls/ProgressBar.cs
  24. 32
      src/Avalonia.Controls/Shapes/Shape.cs
  25. 11
      src/Avalonia.Controls/TextChangedEventArgs.cs
  26. 11
      src/Avalonia.Controls/TextChangingEventArgs.cs
  27. 3
      src/Avalonia.Themes.Fluent/Accents/BaseColorsPalette.xaml
  28. 3
      src/Avalonia.Themes.Fluent/Accents/BaseResources.xaml
  29. 3
      src/Avalonia.Themes.Fluent/Accents/FluentControlResources.xaml
  30. 2
      src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj
  31. 3
      src/Avalonia.Themes.Fluent/Controls/AdornerLayer.xaml
  32. 3
      src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml
  33. 3
      src/Avalonia.Themes.Fluent/Controls/Button.xaml
  34. 3
      src/Avalonia.Themes.Fluent/Controls/ButtonSpinner.xaml
  35. 3
      src/Avalonia.Themes.Fluent/Controls/Calendar.xaml
  36. 3
      src/Avalonia.Themes.Fluent/Controls/CalendarButton.xaml
  37. 3
      src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml
  38. 3
      src/Avalonia.Themes.Fluent/Controls/CalendarDayButton.xaml
  39. 3
      src/Avalonia.Themes.Fluent/Controls/CalendarItem.xaml
  40. 3
      src/Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml
  41. 3
      src/Avalonia.Themes.Fluent/Controls/Carousel.xaml
  42. 3
      src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml
  43. 3
      src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml
  44. 3
      src/Avalonia.Themes.Fluent/Controls/ComboBoxItem.xaml
  45. 3
      src/Avalonia.Themes.Fluent/Controls/ContentControl.xaml
  46. 3
      src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml
  47. 3
      src/Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml
  48. 3
      src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml
  49. 3
      src/Avalonia.Themes.Fluent/Controls/DateTimePickerShared.xaml
  50. 3
      src/Avalonia.Themes.Fluent/Controls/DropDownButton.xaml
  51. 3
      src/Avalonia.Themes.Fluent/Controls/EmbeddableControlRoot.xaml
  52. 3
      src/Avalonia.Themes.Fluent/Controls/Expander.xaml
  53. 3
      src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml
  54. 3
      src/Avalonia.Themes.Fluent/Controls/FlyoutPresenter.xaml
  55. 3
      src/Avalonia.Themes.Fluent/Controls/GridSplitter.xaml
  56. 3
      src/Avalonia.Themes.Fluent/Controls/ItemsControl.xaml
  57. 3
      src/Avalonia.Themes.Fluent/Controls/Label.xaml
  58. 3
      src/Avalonia.Themes.Fluent/Controls/ListBox.xaml
  59. 3
      src/Avalonia.Themes.Fluent/Controls/ListBoxItem.xaml
  60. 3
      src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml
  61. 3
      src/Avalonia.Themes.Fluent/Controls/Menu.xaml
  62. 3
      src/Avalonia.Themes.Fluent/Controls/MenuFlyoutPresenter.xaml
  63. 3
      src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml
  64. 3
      src/Avalonia.Themes.Fluent/Controls/MenuScrollViewer.xaml
  65. 3
      src/Avalonia.Themes.Fluent/Controls/NativeMenuBar.xaml
  66. 3
      src/Avalonia.Themes.Fluent/Controls/NotificationCard.xaml
  67. 3
      src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml
  68. 3
      src/Avalonia.Themes.Fluent/Controls/OverlayPopupHost.xaml
  69. 3
      src/Avalonia.Themes.Fluent/Controls/PathIcon.xaml
  70. 3
      src/Avalonia.Themes.Fluent/Controls/PopupRoot.xaml
  71. 3
      src/Avalonia.Themes.Fluent/Controls/ProgressBar.xaml
  72. 3
      src/Avalonia.Themes.Fluent/Controls/RadioButton.xaml
  73. 3
      src/Avalonia.Themes.Fluent/Controls/RefreshContainer.xaml
  74. 3
      src/Avalonia.Themes.Fluent/Controls/RefreshVisualizer.xaml
  75. 3
      src/Avalonia.Themes.Fluent/Controls/RepeatButton.xaml
  76. 3
      src/Avalonia.Themes.Fluent/Controls/ScrollBar.xaml
  77. 3
      src/Avalonia.Themes.Fluent/Controls/ScrollViewer.xaml
  78. 3
      src/Avalonia.Themes.Fluent/Controls/SelectableTextBlock.xaml
  79. 3
      src/Avalonia.Themes.Fluent/Controls/Separator.xaml
  80. 3
      src/Avalonia.Themes.Fluent/Controls/Slider.xaml
  81. 3
      src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml
  82. 3
      src/Avalonia.Themes.Fluent/Controls/SplitView.xaml
  83. 3
      src/Avalonia.Themes.Fluent/Controls/TabControl.xaml
  84. 3
      src/Avalonia.Themes.Fluent/Controls/TabItem.xaml
  85. 3
      src/Avalonia.Themes.Fluent/Controls/TabStrip.xaml
  86. 3
      src/Avalonia.Themes.Fluent/Controls/TabStripItem.xaml
  87. 3
      src/Avalonia.Themes.Fluent/Controls/TextBox.xaml
  88. 3
      src/Avalonia.Themes.Fluent/Controls/ThemeVariantScope.xaml
  89. 3
      src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml
  90. 3
      src/Avalonia.Themes.Fluent/Controls/TitleBar.xaml
  91. 3
      src/Avalonia.Themes.Fluent/Controls/ToggleButton.xaml
  92. 3
      src/Avalonia.Themes.Fluent/Controls/ToggleSwitch.xaml
  93. 3
      src/Avalonia.Themes.Fluent/Controls/ToolTip.xaml
  94. 3
      src/Avalonia.Themes.Fluent/Controls/TransitioningContentControl.xaml
  95. 3
      src/Avalonia.Themes.Fluent/Controls/TreeView.xaml
  96. 3
      src/Avalonia.Themes.Fluent/Controls/TreeViewItem.xaml
  97. 3
      src/Avalonia.Themes.Fluent/Controls/UserControl.xaml
  98. 3
      src/Avalonia.Themes.Fluent/Controls/Window.xaml
  99. 3
      src/Avalonia.Themes.Fluent/Controls/WindowNotificationManager.xaml
  100. 3
      src/Avalonia.Themes.Fluent/DensityStyles/Compact.xaml

2
build/SharedVersion.props

@ -4,7 +4,7 @@
<Product>Avalonia</Product>
<Version>11.0.999</Version>
<Authors>Avalonia Team</Authors>
<Copyright>Copyright 2022 &#169; The AvaloniaUI Project</Copyright>
<Copyright>Copyright 2013-$([System.DateTime]::Now.ToString(`yyyy`)) &#169; The AvaloniaUI Project</Copyright>
<PackageProjectUrl>https://avaloniaui.net</PackageProjectUrl>
<RepositoryUrl>https://github.com/AvaloniaUI/Avalonia/</RepositoryUrl>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

4
samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs

@ -19,8 +19,8 @@ namespace ControlCatalog.Pages
customContextRequestedBorder.AddHandler(ContextRequestedEvent, CustomContextRequested, RoutingStrategies.Tunnel);
var cancellableContextBorder = this.Get<Border>("CancellableContextBorder");
cancellableContextBorder.ContextMenu!.ContextMenuClosing += ContextFlyoutPage_Closing;
cancellableContextBorder.ContextMenu!.ContextMenuOpening += ContextFlyoutPage_Opening;
cancellableContextBorder.ContextMenu!.Closing += ContextFlyoutPage_Closing;
cancellableContextBorder.ContextMenu!.Opening += ContextFlyoutPage_Opening;
}
private ContextPageViewModel? _model;

1
samples/Sandbox/Sandbox.csproj

@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
<!-- <AvaloniaXamlIlDebuggerLaunch>true</AvaloniaXamlIlDebuggerLaunch>-->
</PropertyGroup>
<ItemGroup>

4
src/Avalonia.Base/Input/AccessKeyHandler.cs

@ -65,14 +65,14 @@ namespace Avalonia.Input
{
if (_mainMenu != null)
{
_mainMenu.MenuClosed -= MainMenuClosed;
_mainMenu.Closed -= MainMenuClosed;
}
_mainMenu = value;
if (_mainMenu != null)
{
_mainMenu.MenuClosed += MainMenuClosed;
_mainMenu.Closed += MainMenuClosed;
}
}
}

2
src/Avalonia.Base/Input/IMainMenu.cs

@ -26,6 +26,6 @@ namespace Avalonia.Input
/// <summary>
/// Occurs when the main menu closes.
/// </summary>
event EventHandler<RoutedEventArgs>? MenuClosed;
event EventHandler<RoutedEventArgs>? Closed;
}
}

46
src/Avalonia.Base/Interactivity/RoutedPropertyChangedEventArgs.cs

@ -1,46 +0,0 @@
namespace Avalonia.Interactivity
{
/// <summary>
/// Provides both old and new property values with a routed event.
/// </summary>
/// <typeparam name="T">The type of values.</typeparam>
public class RoutedPropertyChangedEventArgs<T> : RoutedEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="RoutedPropertyChangedEventArgs{T}"/> class.
/// </summary>
/// <param name="oldValue">The old property value.</param>
/// <param name="newValue">The new property value.</param>
/// <param name="routedEvent">The routed event associated with these event args.</param>
public RoutedPropertyChangedEventArgs(T oldValue, T newValue, RoutedEvent? routedEvent)
: base(routedEvent)
{
OldValue = oldValue;
NewValue = newValue;
}
/// <summary>
/// Initializes a new instance of the <see cref="RoutedPropertyChangedEventArgs{T}"/> class.
/// </summary>
/// <param name="oldValue">The old property value.</param>
/// <param name="newValue">The new property value.</param>
/// <param name="routedEvent">The routed event associated with these event args.</param>
/// <param name="source">The source object that raised the routed event.</param>
public RoutedPropertyChangedEventArgs(T oldValue, T newValue, RoutedEvent? routedEvent, object? source)
: base(routedEvent, source)
{
OldValue = oldValue;
NewValue = newValue;
}
/// <summary>
/// Gets the old value of the property.
/// </summary>
public T OldValue { get; init; }
/// <summary>
/// Gets the new value of the property.
/// </summary>
public T NewValue { get; init; }
}
}

1
src/Avalonia.Base/Media/CharacterHit.cs

@ -19,6 +19,7 @@ namespace Avalonia.Media
/// <param name="firstCharacterIndex">Index of the first character that got hit.</param>
/// <param name="trailingLength">In the case of a leading edge, this value is 0. In the case of a trailing edge,
/// this value is the number of code points until the next valid caret position.</param>
[DebuggerStepThrough]
public CharacterHit(int firstCharacterIndex, int trailingLength = 0)
{
FirstCharacterIndex = firstCharacterIndex;

74
src/Avalonia.Base/Media/TextFormatting/BidiReorderer.cs

@ -18,14 +18,14 @@ namespace Avalonia.Media.TextFormatting
public static BidiReorderer Instance
=> t_instance ??= new();
public void BidiReorder(Span<TextRun> textRuns, FlowDirection flowDirection)
public IndexedTextRun[] BidiReorder(Span<TextRun> textRuns, FlowDirection flowDirection, int firstTextSourceIndex)
{
Debug.Assert(_runs.Length == 0);
Debug.Assert(_ranges.Length == 0);
if (textRuns.IsEmpty)
{
return;
return Array.Empty<IndexedTextRun>();
}
try
@ -46,6 +46,22 @@ namespace Avalonia.Media.TextFormatting
// Reorder them into visual order.
var firstIndex = LinearReorder();
var indexedTextRuns = new IndexedTextRun[textRuns.Length];
for (var i = 0; i < textRuns.Length; i++)
{
var currentRun = textRuns[i];
indexedTextRuns[i] = new IndexedTextRun
{
TextRun = currentRun,
TextSourceCharacterIndex = firstTextSourceIndex,
RunIndex = i,
NextRunIndex = i + 1
};
firstTextSourceIndex += currentRun.Length;
}
// Now perform a recursive reversal of each run.
// From the highest level found in the text to the lowest odd level on each line, including intermediate levels
@ -76,7 +92,7 @@ namespace Avalonia.Media.TextFormatting
if (max == 0 || (min == max && (max & 1) == 0))
{
// Nothing to reverse.
return;
return indexedTextRuns;
}
// Now apply the reversal and replace the original contents.
@ -107,13 +123,25 @@ namespace Avalonia.Media.TextFormatting
var index = 0;
currentIndex = firstIndex;
while (currentIndex >= 0)
{
ref var current = ref _runs[currentIndex];
textRuns[index++] = current.Run;
textRuns[index] = current.Run;
var indexedRun = indexedTextRuns[index];
indexedRun.RunIndex = current.RunIndex;
indexedRun.NextRunIndex = current.NextRunIndex;
index++;
currentIndex = current.NextRunIndex;
}
return indexedTextRuns;
}
finally
{
@ -227,25 +255,6 @@ namespace Avalonia.Media.TextFormatting
return previousIndex;
}
private struct OrderedBidiRun
{
public OrderedBidiRun(int runIndex, TextRun run, sbyte level)
{
RunIndex = runIndex;
Run = run;
Level = level;
NextRunIndex = -1;
}
public int RunIndex { get; }
public sbyte Level { get; }
public TextRun Run { get; }
public int NextRunIndex { get; set; } // -1 if none
}
private struct BidiRange
{
public BidiRange(sbyte level, int leftRunIndex, int rightRunIndex, int previousRangeIndex)
@ -265,4 +274,23 @@ namespace Avalonia.Media.TextFormatting
public int PreviousRangeIndex { get; } // -1 if none
}
}
internal struct OrderedBidiRun
{
public OrderedBidiRun(int runIndex, TextRun run, sbyte level)
{
RunIndex = runIndex;
Run = run;
Level = level;
NextRunIndex = -1;
}
public int RunIndex { get; }
public sbyte Level { get; }
public TextRun Run { get; }
public int NextRunIndex { get; set; } // -1 if none
}
}

10
src/Avalonia.Base/Media/TextFormatting/IndexedTextRun.cs

@ -0,0 +1,10 @@
namespace Avalonia.Media.TextFormatting
{
internal class IndexedTextRun
{
public int TextSourceCharacterIndex { get; init; }
public int RunIndex { get; set; }
public int NextRunIndex { get; set; }
public TextRun? TextRun { get; init; }
}
}

2
src/Avalonia.Base/Media/TextFormatting/TextBounds.cs

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics;
namespace Avalonia.Media.TextFormatting
{
@ -10,6 +11,7 @@ namespace Avalonia.Media.TextFormatting
/// <summary>
/// Constructing TextBounds object
/// </summary>
[DebuggerStepThrough]
internal TextBounds(Rect bounds, FlowDirection flowDirection, IList<TextRunBounds> runBounds)
{
Rectangle = bounds;

594
src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs

@ -4,8 +4,12 @@ using Avalonia.Utilities;
namespace Avalonia.Media.TextFormatting
{
internal sealed class TextLineImpl : TextLine
internal class TextLineImpl : TextLine
{
internal static Comparer<TextBounds> TextBoundsComparer { get; } =
Comparer<TextBounds>.Create((x, y) => x.Rectangle.Left.CompareTo(y.Rectangle.Left));
private IReadOnlyList<IndexedTextRun>? _indexedTextRuns;
private readonly TextRun[] _textRuns;
private readonly double _paragraphWidth;
private readonly TextParagraphProperties _paragraphProperties;
@ -338,184 +342,169 @@ namespace Avalonia.Media.TextFormatting
/// <inheritdoc/>
public override double GetDistanceFromCharacterHit(CharacterHit characterHit)
{
var flowDirection = _paragraphProperties.FlowDirection;
var characterIndex = characterHit.FirstCharacterIndex + characterHit.TrailingLength;
var currentPosition = FirstTextSourceIndex;
var remainingLength = characterIndex - FirstTextSourceIndex;
var currentDistance = Start;
if (flowDirection == FlowDirection.LeftToRight)
if (_indexedTextRuns is null || _indexedTextRuns.Count == 0)
{
for (var index = 0; index < _textRuns.Length; index++)
{
var currentRun = _textRuns[index];
if (currentRun is ShapedTextRun shapedRun && !shapedRun.ShapedBuffer.IsLeftToRight)
{
var i = index;
var rightToLeftWidth = shapedRun.Size.Width;
while (i + 1 <= _textRuns.Length - 1)
{
var nextRun = _textRuns[i + 1];
if (nextRun is ShapedTextRun nextShapedRun && !nextShapedRun.ShapedBuffer.IsLeftToRight)
{
i++;
return Start;
}
rightToLeftWidth += nextShapedRun.Size.Width;
var characterIndex = Math.Min(
characterHit.FirstCharacterIndex + characterHit.TrailingLength,
FirstTextSourceIndex + Length);
continue;
}
var currentPosition = FirstTextSourceIndex;
break;
}
static FlowDirection GetDirection(TextRun textRun, FlowDirection currentDirection)
{
if (textRun is ShapedTextRun shapedTextRun)
{
return shapedTextRun.ShapedBuffer.IsLeftToRight ?
FlowDirection.LeftToRight :
FlowDirection.RightToLeft;
}
if (i > index)
{
while (i >= index)
{
currentRun = _textRuns[i];
return currentDirection;
}
if (currentRun is DrawableTextRun drawable)
{
rightToLeftWidth -= drawable.Size.Width;
}
IndexedTextRun FindIndexedRun()
{
var i = 0;
if (currentPosition + currentRun.Length >= characterIndex)
{
break;
}
IndexedTextRun currentIndexedRun = _indexedTextRuns[i];
currentPosition += currentRun.Length;
while(currentIndexedRun.TextSourceCharacterIndex != currentPosition)
{
if(i + 1 < _indexedTextRuns.Count)
{
i++;
remainingLength -= currentRun.Length;
currentIndexedRun = _indexedTextRuns[i];
}
}
i--;
}
return currentIndexedRun;
}
currentDistance += rightToLeftWidth;
}
}
double GetPreceedingDistance(int firstIndex)
{
var distance = 0.0;
if (currentPosition + currentRun.Length >= characterIndex &&
TryGetDistanceFromCharacterHit(currentRun, characterHit, currentPosition, remainingLength, flowDirection, out var distance, out _))
{
return Math.Max(0, currentDistance + distance);
}
for (var i = 0; i < firstIndex; i++)
{
var currentRun = _textRuns[i];
if (currentRun is DrawableTextRun drawableTextRun)
{
currentDistance += drawableTextRun.Size.Width;
distance += drawableTextRun.Size.Width;
}
//No hit hit found so we add the full width
currentPosition += currentRun.Length;
remainingLength -= currentRun.Length;
}
return distance;
}
else
TextRun? currentTextRun = null;
var currentIndexedRun = FindIndexedRun();
while (currentPosition < FirstTextSourceIndex + Length)
{
currentDistance += WidthIncludingTrailingWhitespace;
currentTextRun = currentIndexedRun.TextRun;
for (var index = _textRuns.Length - 1; index >= 0; index--)
if (currentTextRun == null)
{
var currentRun = _textRuns[index];
break;
}
if (TryGetDistanceFromCharacterHit(currentRun, characterHit, currentPosition, remainingLength,
flowDirection, out var distance, out var currentGlyphRun))
if (currentIndexedRun.TextSourceCharacterIndex + currentTextRun.Length <= characterHit.FirstCharacterIndex)
{
if (currentPosition + currentTextRun.Length < FirstTextSourceIndex + Length)
{
if (currentGlyphRun != null)
{
currentDistance -= currentGlyphRun.Bounds.Width;
}
currentPosition += currentTextRun.Length;
return currentDistance + distance;
}
currentIndexedRun = FindIndexedRun();
if (currentRun is DrawableTextRun drawableTextRun)
{
currentDistance -= drawableTextRun.Size.Width;
continue;
}
//No hit hit found so we add the full width
currentPosition += currentRun.Length;
remainingLength -= currentRun.Length;
}
break;
}
return Math.Max(0, currentDistance);
}
if (currentTextRun == null)
{
return 0;
}
private static bool TryGetDistanceFromCharacterHit(
TextRun currentRun,
CharacterHit characterHit,
int currentPosition,
int remainingLength,
FlowDirection flowDirection,
out double distance,
out GlyphRun? currentGlyphRun)
{
var characterIndex = characterHit.FirstCharacterIndex + characterHit.TrailingLength;
var isTrailingHit = characterHit.TrailingLength > 0;
var directionalWidth = 0.0;
var firstRunIndex = currentIndexedRun.RunIndex;
var lastRunIndex = firstRunIndex;
distance = 0;
currentGlyphRun = null;
var currentDirection = GetDirection(currentTextRun, _resolvedFlowDirection);
switch (currentRun)
var currentX = Start + GetPreceedingDistance(currentIndexedRun.RunIndex);
if (currentTextRun is DrawableTextRun currentDrawable)
{
case ShapedTextRun shapedTextCharacters:
{
currentGlyphRun = shapedTextCharacters.GlyphRun;
directionalWidth = currentDrawable.Size.Width;
}
if (currentPosition + remainingLength <= currentPosition + currentRun.Length)
{
characterHit = new CharacterHit(currentPosition + remainingLength);
if (currentTextRun is not TextEndOfLine)
{
if (currentDirection == FlowDirection.LeftToRight)
{
// Find consecutive runs of same direction
for (; lastRunIndex + 1 < _textRuns.Length; lastRunIndex++)
{
var nextRun = _textRuns[lastRunIndex + 1];
distance = currentGlyphRun.GetDistanceFromCharacterHit(characterHit);
var nextDirection = GetDirection(nextRun, currentDirection);
return true;
if (currentDirection != nextDirection)
{
break;
}
if (currentPosition + remainingLength == currentPosition + currentRun.Length && isTrailingHit)
if (nextRun is DrawableTextRun nextDrawable)
{
if (currentGlyphRun.IsLeftToRight || flowDirection == FlowDirection.RightToLeft)
{
distance = currentGlyphRun.Bounds.Width;
}
return true;
directionalWidth += nextDrawable.Size.Width;
}
break;
}
case DrawableTextRun drawableTextRun:
}
else
{
// Find consecutive runs of same direction
for (; firstRunIndex - 1 > 0; firstRunIndex--)
{
if (characterIndex == currentPosition)
var previousRun = _textRuns[firstRunIndex - 1];
var previousDirection = GetDirection(previousRun, currentDirection);
if (currentDirection != previousDirection)
{
return true;
break;
}
if (characterIndex == currentPosition + currentRun.Length)
if (previousRun is DrawableTextRun previousDrawable)
{
distance = drawableTextRun.Size.Width;
return true;
directionalWidth += previousDrawable.Size.Width;
currentX -= previousDrawable.Size.Width;
}
}
}
}
break;
switch (currentDirection)
{
case FlowDirection.RightToLeft:
{
return GetTextRunBoundsRightToLeft(firstRunIndex, lastRunIndex, currentX + directionalWidth, characterIndex,
currentPosition, 1, out _, out _).Rectangle.Right;
}
default:
{
return false;
return GetTextBoundsLeftToRight(firstRunIndex, lastRunIndex, currentX, characterIndex,
currentPosition, 1, out _, out _).Rectangle.Left;
}
}
return false;
}
/// <inheritdoc/>
@ -585,7 +574,7 @@ namespace Avalonia.Media.TextFormatting
public override IReadOnlyList<TextBounds> GetTextBounds(int firstTextSourceIndex, int textLength)
{
if (_textRuns.Length == 0)
if (_indexedTextRuns is null || _indexedTextRuns.Count == 0)
{
return Array.Empty<TextBounds>();
}
@ -607,303 +596,154 @@ namespace Avalonia.Media.TextFormatting
return currentDirection;
}
if (_paragraphProperties.FlowDirection == FlowDirection.LeftToRight)
IndexedTextRun FindIndexedRun()
{
var currentX = Start;
var i = 0;
for (int i = 0; i < _textRuns.Length; i++)
{
var currentRun = _textRuns[i];
IndexedTextRun currentIndexedRun = _indexedTextRuns[i];
var firstRunIndex = i;
var lastRunIndex = firstRunIndex;
var currentDirection = GetDirection(currentRun, FlowDirection.LeftToRight);
var directionalWidth = 0.0;
if (currentRun is DrawableTextRun currentDrawable)
while (currentIndexedRun.TextSourceCharacterIndex != currentPosition)
{
if (i + 1 < _indexedTextRuns.Count)
{
directionalWidth = currentDrawable.Size.Width;
}
i++;
// Find consecutive runs of same direction
for (; lastRunIndex + 1 < _textRuns.Length; lastRunIndex++)
{
var nextRun = _textRuns[lastRunIndex + 1];
currentIndexedRun = _indexedTextRuns[i];
}
}
var nextDirection = GetDirection(nextRun, currentDirection);
return currentIndexedRun;
}
if (currentDirection != nextDirection)
{
break;
}
double GetPreceedingDistance(int firstIndex)
{
var distance = 0.0;
if (nextRun is DrawableTextRun nextDrawable)
{
directionalWidth += nextDrawable.Size.Width;
}
}
for (var i = 0; i < firstIndex; i++)
{
var currentRun = _textRuns[i];
//Skip runs that are not part of the hit test range
switch (currentDirection)
if (currentRun is DrawableTextRun drawableTextRun)
{
case FlowDirection.RightToLeft:
{
for (; lastRunIndex >= firstRunIndex; lastRunIndex--)
{
currentRun = _textRuns[lastRunIndex];
distance += drawableTextRun.Size.Width;
}
}
if (currentPosition + currentRun.Length > firstTextSourceIndex)
{
break;
}
return distance;
}
currentPosition += currentRun.Length;
while (remainingLength > 0 && currentPosition < FirstTextSourceIndex + Length)
{
var currentIndexedRun = FindIndexedRun();
if (currentRun is DrawableTextRun drawableTextRun)
{
directionalWidth -= drawableTextRun.Size.Width;
currentX += drawableTextRun.Size.Width;
}
if (currentIndexedRun == null)
{
break;
}
if (lastRunIndex - 1 < 0)
{
break;
}
}
var directionalWidth = 0.0;
var firstRunIndex = currentIndexedRun.RunIndex;
var lastRunIndex = firstRunIndex;
var currentTextRun = currentIndexedRun.TextRun;
break;
}
default:
{
for (; firstRunIndex <= lastRunIndex; firstRunIndex++)
{
currentRun = _textRuns[firstRunIndex];
if (currentPosition + currentRun.Length > firstTextSourceIndex)
{
break;
}
if (currentTextRun == null)
{
break;
}
currentPosition += currentRun.Length;
var currentDirection = GetDirection(currentTextRun, _resolvedFlowDirection);
if (currentRun is DrawableTextRun drawableTextRun)
{
currentX += drawableTextRun.Size.Width;
directionalWidth -= drawableTextRun.Size.Width;
}
if (currentIndexedRun.TextSourceCharacterIndex + currentTextRun.Length <= firstTextSourceIndex)
{
currentPosition += currentTextRun.Length;
if (firstRunIndex + 1 == _textRuns.Length)
{
break;
}
}
continue;
}
break;
}
}
var currentX = Start + GetPreceedingDistance(currentIndexedRun.RunIndex);
i = lastRunIndex;
if (currentTextRun is DrawableTextRun currentDrawable)
{
directionalWidth = currentDrawable.Size.Width;
}
//Possible overlap at runs of different direction
if (directionalWidth == 0 && i < _textRuns.Length - 1)
if (currentTextRun is not TextEndOfLine)
{
if (currentDirection == FlowDirection.LeftToRight)
{
//In case a run only contains a linebreak we don't want to skip it.
if (currentRun is ShapedTextRun shaped)
{
if (currentRun.Length - shaped.GlyphRun.Metrics.NewLineLength > 0)
{
continue;
}
}
else
// Find consecutive runs of same direction
for (; lastRunIndex + 1 < _textRuns.Length; lastRunIndex++)
{
continue;
}
}
var nextRun = _textRuns[lastRunIndex + 1];
int coveredLength;
TextBounds? textBounds;
var nextDirection = GetDirection(nextRun, currentDirection);
switch (currentDirection)
{
case FlowDirection.RightToLeft:
if (currentDirection != nextDirection)
{
textBounds = GetTextRunBoundsRightToLeft(firstRunIndex, lastRunIndex, currentX + directionalWidth, firstTextSourceIndex,
currentPosition, remainingLength, out coveredLength, out currentPosition);
currentX += directionalWidth;
break;
}
default:
{
textBounds = GetTextBoundsLeftToRight(firstRunIndex, lastRunIndex, currentX, firstTextSourceIndex,
currentPosition, remainingLength, out coveredLength, out currentPosition);
currentX = textBounds.Rectangle.Right;
break;
if (nextRun is DrawableTextRun nextDrawable)
{
directionalWidth += nextDrawable.Size.Width;
}
}
}
if (coveredLength > 0)
{
result.Add(textBounds);
remainingLength -= coveredLength;
}
if (remainingLength <= 0)
{
break;
}
}
}
else
{
var currentX = Start + WidthIncludingTrailingWhitespace;
for (int i = _textRuns.Length - 1; i >= 0; i--)
{
var currentRun = _textRuns[i];
var firstRunIndex = i;
var lastRunIndex = firstRunIndex;
var currentDirection = GetDirection(currentRun, FlowDirection.RightToLeft);
var directionalWidth = 0.0;
if (currentRun is DrawableTextRun currentDrawable)
{
directionalWidth = currentDrawable.Size.Width;
}
// Find consecutive runs of same direction
for (; firstRunIndex - 1 > 0; firstRunIndex--)
else
{
var previousRun = _textRuns[firstRunIndex - 1];
var previousDirection = GetDirection(previousRun, currentDirection);
if (currentDirection != previousDirection)
// Find consecutive runs of same direction
for (; firstRunIndex - 1 > 0; firstRunIndex--)
{
break;
}
var previousRun = _textRuns[firstRunIndex - 1];
if (currentRun is DrawableTextRun previousDrawable)
{
directionalWidth += previousDrawable.Size.Width;
}
}
var previousDirection = GetDirection(previousRun, currentDirection);
//Skip runs that are not part of the hit test range
switch (currentDirection)
{
case FlowDirection.RightToLeft:
if (currentDirection != previousDirection)
{
for (; lastRunIndex >= firstRunIndex; lastRunIndex--)
{
currentRun = _textRuns[lastRunIndex];
if (currentPosition + currentRun.Length <= firstTextSourceIndex)
{
currentPosition += currentRun.Length;
if (currentRun is DrawableTextRun drawableTextRun)
{
currentX -= drawableTextRun.Size.Width;
directionalWidth -= drawableTextRun.Size.Width;
}
continue;
}
break;
}
break;
}
default:
{
for (; firstRunIndex <= lastRunIndex; firstRunIndex++)
{
currentRun = _textRuns[firstRunIndex];
if (currentPosition + currentRun.Length <= firstTextSourceIndex)
{
currentPosition += currentRun.Length;
if (currentRun is DrawableTextRun drawableTextRun)
{
currentX += drawableTextRun.Size.Width;
directionalWidth -= drawableTextRun.Size.Width;
}
continue;
}
break;
}
if (previousRun is DrawableTextRun previousDrawable)
{
directionalWidth += previousDrawable.Size.Width;
break;
currentX -= previousDrawable.Size.Width;
}
}
}
}
i = firstRunIndex;
int coveredLength;
TextBounds? textBounds;
//Possible overlap at runs of different direction
if (directionalWidth == 0 && i > 0)
{
//In case a run only contains a linebreak we don't want to skip it.
if (currentRun is ShapedTextRun shaped)
switch (currentDirection)
{
case FlowDirection.RightToLeft:
{
if (currentRun.Length - shaped.GlyphRun.Metrics.NewLineLength > 0)
{
continue;
}
textBounds = GetTextRunBoundsRightToLeft(firstRunIndex, lastRunIndex, currentX + directionalWidth, firstTextSourceIndex,
currentPosition, remainingLength, out coveredLength, out currentPosition);
break;
}
else
default:
{
continue;
}
}
int coveredLength;
TextBounds? textBounds;
switch (currentDirection)
{
case FlowDirection.LeftToRight:
{
textBounds = GetTextBoundsLeftToRight(firstRunIndex, lastRunIndex, currentX - directionalWidth, firstTextSourceIndex,
currentPosition, remainingLength, out coveredLength, out currentPosition);
currentX -= directionalWidth;
break;
}
default:
{
textBounds = GetTextRunBoundsRightToLeft(firstRunIndex, lastRunIndex, currentX, firstTextSourceIndex,
currentPosition, remainingLength, out coveredLength, out currentPosition);
currentX = textBounds.Rectangle.Left;
textBounds = GetTextBoundsLeftToRight(firstRunIndex, lastRunIndex, currentX, firstTextSourceIndex,
currentPosition, remainingLength, out coveredLength, out currentPosition);
break;
}
}
break;
}
}
//Visual order is always left to right so we need to insert
result.Insert(0, textBounds);
if (coveredLength > 0)
{
result.Add(textBounds);
remainingLength -= coveredLength;
if (remainingLength <= 0)
{
break;
}
}
}
result.Sort(TextBoundsComparer);
return result;
}
@ -1164,7 +1004,7 @@ namespace Avalonia.Media.TextFormatting
_textLineBreak = new TextLineBreak(textEndOfLine);
}
BidiReorderer.Instance.BidiReorder(_textRuns, _resolvedFlowDirection);
_indexedTextRuns = BidiReorderer.Instance.BidiReorder(_textRuns, _paragraphProperties.FlowDirection, FirstTextSourceIndex);
}
/// <summary>
@ -1211,13 +1051,6 @@ namespace Avalonia.Media.TextFormatting
return true;
}
//var characterIndex = codepointIndex - shapedRun.Text.Start;
//if (characterIndex < 0 && shapedRun.ShapedBuffer.IsLeftToRight)
//{
// foundCharacterHit = new CharacterHit(foundCharacterHit.FirstCharacterIndex);
//}
nextCharacterHit = isAtEnd || characterHit.TrailingLength != 0 ?
foundCharacterHit :
new CharacterHit(foundCharacterHit.FirstCharacterIndex + foundCharacterHit.TrailingLength);
@ -1556,8 +1389,8 @@ namespace Avalonia.Media.TextFormatting
TrailingWhitespaceLength = trailingWhitespaceLength,
Width = width,
WidthIncludingTrailingWhitespace = widthIncludingWhitespace,
OverhangLeading= overhangLeading,
OverhangTrailing= overhangTrailing,
OverhangLeading = overhangLeading,
OverhangTrailing = overhangTrailing,
OverhangAfter = overhangAfter
};
}
@ -1615,8 +1448,7 @@ namespace Avalonia.Media.TextFormatting
return Math.Max(0, start);
case TextAlignment.Right:
return Math.Max(0, _paragraphWidth - width);
return Math.Max(0, _paragraphWidth - widthIncludingTrailingWhitespace);
default:
return 0;
}

2
src/Avalonia.Build.Tasks/GenerateAvaloniaResourcesTask.cs

@ -127,7 +127,7 @@ namespace Avalonia.Build.Tasks
public bool Execute()
{
Enum.TryParse<MessageImportance>(ReportImportance, out _reportImportance);
Enum.TryParse(ReportImportance, true, out _reportImportance);
BuildEngine.LogMessage($"GenerateAvaloniaResourcesTask -> Root: {Root}, {Resources?.Count()} resources, Output:{Output}", _reportImportance < MessageImportance.Low ? MessageImportance.High : _reportImportance);
var resources = BuildResourceSources();

43
src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs

@ -288,6 +288,24 @@ namespace Avalonia.Build.Tasks
if (precompileText != "true")
throw new XamlParseException("Invalid value for x:Precompile", precompileDirective);
}
var classModifierDirective = initialRoot.Children.OfType<XamlAstXmlDirective>()
.FirstOrDefault(d => d.Namespace == XamlNamespaces.Xaml2006 && d.Name == "ClassModifier");
bool? classModifierPublic = null;
if (classModifierDirective != null)
{
var classModifierText = (classModifierDirective.Values[0] as XamlAstTextNode)?.Text.Trim()
.ToLowerInvariant();
if ("Public".Equals(classModifierText, StringComparison.OrdinalIgnoreCase))
classModifierPublic = true;
// XAML spec uses "Public" and "NotPublic" values,
// When WPF documentation uses "public" and "internal".
else if ("NotPublic".Equals(classModifierText, StringComparison.OrdinalIgnoreCase)
|| "Internal".Equals(classModifierText, StringComparison.OrdinalIgnoreCase))
classModifierPublic = false;
else
throw new XamlParseException("Invalid value for x:ClassModifier. Expected value are: Public, NotPublic (internal).", precompileDirective);
}
var classDirective = initialRoot.Children.OfType<XamlAstXmlDirective>()
.FirstOrDefault(d => d.Namespace == XamlNamespaces.Xaml2006 && d.Name == "Class");
@ -297,8 +315,21 @@ namespace Avalonia.Build.Tasks
if (classDirective.Values.Count != 1 || !(classDirective.Values[0] is XamlAstTextNode tn))
throw new XamlParseException("x:Class should have a string value", classDirective);
classType = typeSystem.TargetAssembly.FindType(tn.Text);
if (classType == null)
throw new XamlParseException($"Unable to find type `{tn.Text}`", classDirective);
var isClassPublic = typeSystem.GetTypeReference(classType).Resolve().IsPublic;
classModifierPublic ??= isClassPublic;
// We do not really need x:ClassModifier support for x:Class, but we can at least use it for validation here.
if (classModifierPublic != isClassPublic)
{
throw new XamlParseException(
"XAML file x:ClassModifier doesn't match the x:Class type modifiers.",
precompileDirective);
}
compiler.OverrideRootType(parsed,
new XamlAstClrTypeReference(classDirective, classType, false));
initialRoot.Children.Remove(classDirective);
@ -312,6 +343,8 @@ namespace Avalonia.Build.Tasks
var classTypeDefinition =
classType == null ? null : typeSystem.GetTypeReference(classType).Resolve();
// All XAML files are public by default.
classModifierPublic ??= true;
var populateBuilder = classTypeDefinition == null ?
builder :
@ -319,10 +352,11 @@ namespace Avalonia.Build.Tasks
((List<XamlDocumentResource>)parsedXamlDocuments).Add(new XamlDocumentResource(
parsed, res.Uri, res, classType,
classModifierPublic.Value,
populateBuilder,
compiler.DefinePopulateMethod(populateBuilder, parsed, populateName,
classTypeDefinition == null),
buildName == null ? null : compiler.DefineBuildMethod(builder, parsed, buildName, true)));
classTypeDefinition == null && classModifierPublic.Value),
buildName == null ? null : compiler.DefineBuildMethod(builder, parsed, buildName, classModifierPublic.Value)));
}
catch (Exception e)
{
@ -368,7 +402,7 @@ namespace Avalonia.Build.Tasks
document.PopulateMethod,
document.BuildMethod,
builder.DefineSubType(compilerConfig.WellKnownTypes.Object, "NamespaceInfo:" + res.Name,
true),
document.IsPublic),
(closureName, closureBaseType) =>
populateBuilder.DefineSubType(closureBaseType, closureName, false),
(closureName, returnType, parameterTypes) =>
@ -502,7 +536,8 @@ namespace Avalonia.Build.Tasks
}
if (document.BuildMethod != null || classTypeDefinition != null)
if (document.IsPublic
&& (document.BuildMethod != null || classTypeDefinition != null))
{
var compiledBuildMethod = document.BuildMethod == null ?
null :

90
src/Avalonia.Controls/Border.cs

@ -47,30 +47,6 @@ namespace Avalonia.Controls
public static readonly StyledProperty<BoxShadows> BoxShadowProperty =
AvaloniaProperty.Register<Border, BoxShadows>(nameof(BoxShadow));
/// <summary>
/// Defines the <see cref="BorderDashOffset"/> property.
/// </summary>
public static readonly StyledProperty<double> BorderDashOffsetProperty =
AvaloniaProperty.Register<Border, double>(nameof(BorderDashOffset));
/// <summary>
/// Defines the <see cref="BorderDashArray"/> property.
/// </summary>
public static readonly StyledProperty<AvaloniaList<double>?> BorderDashArrayProperty =
AvaloniaProperty.Register<Border, AvaloniaList<double>?>(nameof(BorderDashArray));
/// <summary>
/// Defines the <see cref="BorderLineCap"/> property.
/// </summary>
public static readonly StyledProperty<PenLineCap> BorderLineCapProperty =
AvaloniaProperty.Register<Border, PenLineCap>(nameof(BorderLineCap), PenLineCap.Flat);
/// <summary>
/// Defines the <see cref="BorderLineJoin"/> property.
/// </summary>
public static readonly StyledProperty<PenLineJoin> BorderLineJoinProperty =
AvaloniaProperty.Register<Border, PenLineJoin>(nameof(BorderLineJoin), PenLineJoin.Miter);
private readonly BorderRenderHelper _borderRenderHelper = new BorderRenderHelper();
private Thickness? _layoutThickness;
private double _scale;
@ -86,10 +62,6 @@ namespace Avalonia.Controls
BorderBrushProperty,
BorderThicknessProperty,
CornerRadiusProperty,
BorderDashArrayProperty,
BorderLineCapProperty,
BorderLineJoinProperty,
BorderDashOffsetProperty,
BoxShadowProperty);
AffectsMeasure<Border>(BorderThicknessProperty);
}
@ -115,8 +87,8 @@ namespace Avalonia.Controls
/// </summary>
public IBrush? Background
{
get { return GetValue(BackgroundProperty); }
set { SetValue(BackgroundProperty, value); }
get => GetValue(BackgroundProperty);
set => SetValue(BackgroundProperty, value);
}
/// <summary>
@ -124,17 +96,8 @@ namespace Avalonia.Controls
/// </summary>
public IBrush? BorderBrush
{
get { return GetValue(BorderBrushProperty); }
set { SetValue(BorderBrushProperty, value); }
}
/// <summary>
/// Gets or sets a collection of <see cref="double"/> values that indicate the pattern of dashes and gaps that is used to outline shapes.
/// </summary>
public AvaloniaList<double>? BorderDashArray
{
get { return GetValue(BorderDashArrayProperty); }
set { SetValue(BorderDashArrayProperty, value); }
get => GetValue(BorderBrushProperty);
set => SetValue(BorderBrushProperty, value);
}
/// <summary>
@ -142,35 +105,8 @@ namespace Avalonia.Controls
/// </summary>
public Thickness BorderThickness
{
get { return GetValue(BorderThicknessProperty); }
set { SetValue(BorderThicknessProperty, value); }
}
/// <summary>
/// Gets or sets a value that specifies the distance within the dash pattern where a dash begins.
/// </summary>
public double BorderDashOffset
{
get { return GetValue(BorderDashOffsetProperty); }
set { SetValue(BorderDashOffsetProperty, value); }
}
/// <summary>
/// Gets or sets a <see cref="PenLineCap"/> enumeration value that describes the shape at the ends of a line.
/// </summary>
public PenLineCap BorderLineCap
{
get { return GetValue(BorderLineCapProperty); }
set { SetValue(BorderLineCapProperty, value); }
}
/// <summary>
/// Gets or sets a <see cref="PenLineJoin"/> enumeration value that specifies the type of join that is used at the vertices of a Shape.
/// </summary>
public PenLineJoin BorderLineJoin
{
get { return GetValue(BorderLineJoinProperty); }
set { SetValue(BorderLineJoinProperty, value); }
get => GetValue(BorderThicknessProperty);
set => SetValue(BorderThicknessProperty, value);
}
/// <summary>
@ -178,8 +114,8 @@ namespace Avalonia.Controls
/// </summary>
public CornerRadius CornerRadius
{
get { return GetValue(CornerRadiusProperty); }
set { SetValue(CornerRadiusProperty, value); }
get => GetValue(CornerRadiusProperty);
set => SetValue(CornerRadiusProperty, value);
}
/// <summary>
@ -227,8 +163,14 @@ namespace Avalonia.Controls
/// <param name="context">The drawing context.</param>
public sealed override void Render(DrawingContext context)
{
_borderRenderHelper.Render(context, Bounds.Size, LayoutThickness, CornerRadius, Background, BorderBrush,
BoxShadow, BorderDashOffset, BorderLineCap, BorderLineJoin, BorderDashArray);
_borderRenderHelper.Render(
context,
Bounds.Size,
LayoutThickness,
CornerRadius,
Background,
BorderBrush,
BoxShadow);
}
/// <summary>

12
src/Avalonia.Controls/ContextMenu.cs

@ -196,14 +196,14 @@ namespace Avalonia.Controls
/// <see cref="P:Avalonia.Controls.ContextMenu.IsOpen" />
/// property is changing from false to true.
/// </summary>
public event CancelEventHandler? ContextMenuOpening;
public event CancelEventHandler? Opening;
/// <summary>
/// Occurs when the value of the
/// <see cref="P:Avalonia.Controls.ContextMenu.IsOpen" />
/// property is changing from true to false.
/// </summary>
public event CancelEventHandler? ContextMenuClosing;
public event CancelEventHandler? Closing;
/// <summary>
/// Called when the <see cref="Control.ContextMenu"/> property changes on a control.
@ -353,7 +353,7 @@ namespace Avalonia.Controls
RaiseEvent(new RoutedEventArgs
{
RoutedEvent = MenuOpenedEvent,
RoutedEvent = OpenedEvent,
Source = this,
});
}
@ -394,7 +394,7 @@ namespace Avalonia.Controls
RaiseEvent(new RoutedEventArgs
{
RoutedEvent = MenuClosedEvent,
RoutedEvent = ClosedEvent,
Source = this,
});
@ -446,14 +446,14 @@ namespace Avalonia.Controls
private bool CancelClosing()
{
var eventArgs = new CancelEventArgs();
ContextMenuClosing?.Invoke(this, eventArgs);
Closing?.Invoke(this, eventArgs);
return eventArgs.Cancel;
}
private bool CancelOpening()
{
var eventArgs = new CancelEventArgs();
ContextMenuOpening?.Invoke(this, eventArgs);
Opening?.Invoke(this, eventArgs);
return eventArgs.Cancel;
}
}

2
src/Avalonia.Controls/DateTimePickers/DatePickerPresenter.cs

@ -367,11 +367,11 @@ namespace Avalonia.Controls
var dt = Date;
if (DayVisible)
{
_daySelector.FormatDate = dt.Date;
var maxDays = _calendar.GetDaysInMonth(dt.Year, dt.Month);
_daySelector.MaximumValue = maxDays;
_daySelector.MinimumValue = 1;
_daySelector.SelectedValue = dt.Day;
_daySelector.FormatDate = dt.Date;
}
if (MonthVisible)

4
src/Avalonia.Controls/Menu.cs

@ -60,7 +60,7 @@ namespace Avalonia.Controls
RaiseEvent(new RoutedEventArgs
{
RoutedEvent = MenuClosedEvent,
RoutedEvent = ClosedEvent,
Source = this,
});
}
@ -77,7 +77,7 @@ namespace Avalonia.Controls
RaiseEvent(new RoutedEventArgs
{
RoutedEvent = MenuOpenedEvent,
RoutedEvent = OpenedEvent,
Source = this,
});
}

28
src/Avalonia.Controls/MenuBase.cs

@ -25,16 +25,16 @@ namespace Avalonia.Controls
o => o.IsOpen);
/// <summary>
/// Defines the <see cref="MenuOpened"/> event.
/// Defines the <see cref="Opened"/> event.
/// </summary>
public static readonly RoutedEvent<RoutedEventArgs> MenuOpenedEvent =
RoutedEvent.Register<MenuBase, RoutedEventArgs>(nameof(MenuOpened), RoutingStrategies.Bubble);
public static readonly RoutedEvent<RoutedEventArgs> OpenedEvent =
RoutedEvent.Register<MenuBase, RoutedEventArgs>(nameof(Opened), RoutingStrategies.Bubble);
/// <summary>
/// Defines the <see cref="MenuClosed"/> event.
/// Defines the <see cref="Closed"/> event.
/// </summary>
public static readonly RoutedEvent<RoutedEventArgs> MenuClosedEvent =
RoutedEvent.Register<MenuBase, RoutedEventArgs>(nameof(MenuClosed), RoutingStrategies.Bubble);
public static readonly RoutedEvent<RoutedEventArgs> ClosedEvent =
RoutedEvent.Register<MenuBase, RoutedEventArgs>(nameof(Closed), RoutingStrategies.Bubble);
private bool _isOpen;
@ -68,8 +68,8 @@ namespace Avalonia.Controls
/// </summary>
public bool IsOpen
{
get { return _isOpen; }
protected set { SetAndRaise(IsOpenProperty, ref _isOpen, value); }
get => _isOpen;
protected set => SetAndRaise(IsOpenProperty, ref _isOpen, value);
}
/// <inheritdoc/>
@ -105,19 +105,19 @@ namespace Avalonia.Controls
/// <summary>
/// Occurs when a <see cref="Menu"/> is opened.
/// </summary>
public event EventHandler<RoutedEventArgs>? MenuOpened
public event EventHandler<RoutedEventArgs>? Opened
{
add { AddHandler(MenuOpenedEvent, value); }
remove { RemoveHandler(MenuOpenedEvent, value); }
add => AddHandler(OpenedEvent, value);
remove => RemoveHandler(OpenedEvent, value);
}
/// <summary>
/// Occurs when a <see cref="Menu"/> is closed.
/// </summary>
public event EventHandler<RoutedEventArgs>? MenuClosed
public event EventHandler<RoutedEventArgs>? Closed
{
add { AddHandler(MenuClosedEvent, value); }
remove { RemoveHandler(MenuClosedEvent, value); }
add => AddHandler(ClosedEvent, value);
remove => RemoveHandler(ClosedEvent, value);
}
/// <summary>

4
src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs

@ -290,7 +290,7 @@ namespace Avalonia.Controls.Platform
Menu.PointerPressed += PointerPressed;
Menu.PointerReleased += PointerReleased;
Menu.AddHandler(AccessKeyHandler.AccessKeyPressedEvent, AccessKeyPressed);
Menu.AddHandler(MenuBase.MenuOpenedEvent, MenuOpened);
Menu.AddHandler(MenuBase.OpenedEvent, MenuOpened);
Menu.AddHandler(MenuItem.PointerEnteredItemEvent, PointerEntered);
Menu.AddHandler(MenuItem.PointerExitedItemEvent, PointerExited);
Menu.AddHandler(InputElement.PointerMovedEvent, PointerMoved);
@ -326,7 +326,7 @@ namespace Avalonia.Controls.Platform
Menu.PointerPressed -= PointerPressed;
Menu.PointerReleased -= PointerReleased;
Menu.RemoveHandler(AccessKeyHandler.AccessKeyPressedEvent, AccessKeyPressed);
Menu.RemoveHandler(MenuBase.MenuOpenedEvent, MenuOpened);
Menu.RemoveHandler(MenuBase.OpenedEvent, MenuOpened);
Menu.RemoveHandler(MenuItem.PointerEnteredItemEvent, PointerEntered);
Menu.RemoveHandler(MenuItem.PointerExitedItemEvent, PointerExited);
Menu.RemoveHandler(InputElement.PointerMovedEvent, PointerMoved);

5
src/Avalonia.Controls/Primitives/LightDismissOverlayLayer.cs

@ -46,13 +46,12 @@ namespace Avalonia.Controls.Primitives
return manager?.LightDismissOverlayLayer;
}
/// <inheritdoc />
public bool HitTest(Point point)
{
if (InputPassThroughElement is Visual v)
{
var hit = ((Visual?)VisualRoot)?.GetVisualAt(point, x => x != this);
if (hit is object)
if (VisualRoot is IInputElement ie && ie.InputHitTest(point, x => x != this) is Visual hit)
{
return !v.IsVisualAncestorOf(hit);
}

8
src/Avalonia.Controls/Primitives/RangeBase.cs

@ -45,14 +45,14 @@ namespace Avalonia.Controls.Primitives
/// <summary>
/// Defines the <see cref="ValueChanged"/> event.
/// </summary>
public static readonly RoutedEvent<RoutedPropertyChangedEventArgs<double>> ValueChangedEvent =
RoutedEvent.Register<RangeBase, RoutedPropertyChangedEventArgs<double>>(
public static readonly RoutedEvent<RangeBaseValueChangedEventArgs> ValueChangedEvent =
RoutedEvent.Register<RangeBase, RangeBaseValueChangedEventArgs>(
nameof(ValueChanged), RoutingStrategies.Bubble);
/// <summary>
/// Occurs when the <see cref="Value"/> property changes.
/// </summary>
public event EventHandler<RoutedPropertyChangedEventArgs<double>>? ValueChanged
public event EventHandler<RangeBaseValueChangedEventArgs>? ValueChanged
{
add => AddHandler(ValueChangedEvent, value);
remove => RemoveHandler(ValueChangedEvent, value);
@ -163,7 +163,7 @@ namespace Avalonia.Controls.Primitives
}
else if (change.Property == ValueProperty)
{
var valueChangedEventArgs = new RoutedPropertyChangedEventArgs<double>(
var valueChangedEventArgs = new RangeBaseValueChangedEventArgs(
change.GetOldValue<double>(),
change.GetNewValue<double>(),
ValueChangedEvent);

47
src/Avalonia.Controls/Primitives/RangeBaseValueChangedEventArgs.cs

@ -0,0 +1,47 @@
using Avalonia.Interactivity;
namespace Avalonia.Controls.Primitives
{
/// <summary>
/// Provides data specific to a <see cref="RangeBase.ValueChanged"/> event.
/// </summary>
public class RangeBaseValueChangedEventArgs : RoutedEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="RangeBaseValueChangedEventArgs"/> class.
/// </summary>
/// <param name="oldValue">The old value of the range value property.</param>
/// <param name="newValue">The new value of the range value property.</param>
/// <param name="routedEvent">The routed event associated with these event args.</param>
public RangeBaseValueChangedEventArgs(double oldValue, double newValue, RoutedEvent? routedEvent)
: base(routedEvent)
{
OldValue = oldValue;
NewValue = newValue;
}
/// <summary>
/// Initializes a new instance of the <see cref="RangeBaseValueChangedEventArgs"/> class.
/// </summary>
/// <param name="oldValue">The old value of the range value property.</param>
/// <param name="newValue">The new value of the range value property.</param>
/// <param name="routedEvent">The routed event associated with these event args.</param>
/// <param name="source">The source object that raised the routed event.</param>
public RangeBaseValueChangedEventArgs(double oldValue, double newValue, RoutedEvent? routedEvent, object? source)
: base(routedEvent, source)
{
OldValue = oldValue;
NewValue = newValue;
}
/// <summary>
/// Gets the old value of the range value property.
/// </summary>
public double OldValue { get; init; }
/// <summary>
/// Gets the new value of the range value property.
/// </summary>
public double NewValue { get; init; }
}
}

284
src/Avalonia.Controls/ProgressBar.cs

@ -31,77 +31,157 @@ namespace Avalonia.Controls
private double _containerAnimationEndPosition;
private double _container2AnimationStartPosition;
private double _container2AnimationEndPosition;
public static readonly DirectProperty<ProgressBarTemplateSettings, double> ContainerAnimationStartPositionProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(ContainerAnimationStartPosition),
p => p.ContainerAnimationStartPosition,
(p, o) => p.ContainerAnimationStartPosition = o, 0d);
public static readonly DirectProperty<ProgressBarTemplateSettings, double> ContainerAnimationEndPositionProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(ContainerAnimationEndPosition),
p => p.ContainerAnimationEndPosition,
(p, o) => p.ContainerAnimationEndPosition = o, 0d);
public static readonly DirectProperty<ProgressBarTemplateSettings, double> Container2AnimationStartPositionProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(Container2AnimationStartPosition),
p => p.Container2AnimationStartPosition,
(p, o) => p.Container2AnimationStartPosition = o, 0d);
public static readonly DirectProperty<ProgressBarTemplateSettings, double> Container2AnimationEndPositionProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(Container2AnimationEndPosition),
p => p.Container2AnimationEndPosition,
(p, o) => p.Container2AnimationEndPosition = o);
private double _indeterminateStartingOffset;
private double _indeterminateEndingOffset;
/// <summary>
/// Defines the <see cref="ContainerAnimationStartPosition"/> property.
/// </summary>
public static readonly DirectProperty<ProgressBarTemplateSettings, double>
ContainerAnimationStartPositionProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(ContainerAnimationStartPosition),
p => p.ContainerAnimationStartPosition,
(p, o) => p.ContainerAnimationStartPosition = o);
/// <summary>
/// Defines the <see cref="ContainerAnimationEndPosition"/> property.
/// </summary>
public static readonly DirectProperty<ProgressBarTemplateSettings, double>
ContainerAnimationEndPositionProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(ContainerAnimationEndPosition),
p => p.ContainerAnimationEndPosition,
(p, o) => p.ContainerAnimationEndPosition = o);
/// <summary>
/// Defines the <see cref="Container2AnimationStartPosition"/> property.
/// </summary>
public static readonly DirectProperty<ProgressBarTemplateSettings, double>
Container2AnimationStartPositionProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(Container2AnimationStartPosition),
p => p.Container2AnimationStartPosition,
(p, o) => p.Container2AnimationStartPosition = o);
/// <summary>
/// Defines the <see cref="Container2AnimationEndPosition"/> property.
/// </summary>
public static readonly DirectProperty<ProgressBarTemplateSettings, double>
Container2AnimationEndPositionProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(Container2AnimationEndPosition),
p => p.Container2AnimationEndPosition,
(p, o) => p.Container2AnimationEndPosition = o);
/// <summary>
/// Defines the <see cref="Container2Width"/> property.
/// </summary>
public static readonly DirectProperty<ProgressBarTemplateSettings, double> Container2WidthProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(Container2Width),
p => p.Container2Width,
(p, o) => p.Container2Width = o);
/// <summary>
/// Defines the <see cref="ContainerWidth"/> property.
/// </summary>
public static readonly DirectProperty<ProgressBarTemplateSettings, double> ContainerWidthProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(ContainerWidth),
p => p.ContainerWidth,
(p, o) => p.ContainerWidth = o);
/// <summary>
/// Defines the <see cref="IndeterminateStartingOffset"/> property.
/// </summary>
public static readonly DirectProperty<ProgressBarTemplateSettings, double> IndeterminateStartingOffsetProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(IndeterminateStartingOffset),
p => p.IndeterminateStartingOffset,
(p, o) => p.IndeterminateStartingOffset = o);
/// <summary>
/// Defines the <see cref="IndeterminateEndingOffset"/> property.
/// </summary>
public static readonly DirectProperty<ProgressBarTemplateSettings, double> IndeterminateEndingOffsetProperty =
AvaloniaProperty.RegisterDirect<ProgressBarTemplateSettings, double>(
nameof(IndeterminateEndingOffset),
p => p.IndeterminateEndingOffset,
(p, o) => p.IndeterminateEndingOffset = o);
/// <summary>
/// Used by <see cref="Avalonia.Themes.Fluent"/> to define the first indeterminate indicator's width.
/// </summary>
public double ContainerWidth
{
get => _containerWidth;
set => SetAndRaise(ContainerWidthProperty, ref _containerWidth, value);
}
/// <summary>
/// Used by <see cref="Avalonia.Themes.Fluent"/> to define the second indeterminate indicator's width.
/// </summary>
public double Container2Width
{
get => _container2Width;
set => SetAndRaise(Container2WidthProperty, ref _container2Width, value);
}
/// <summary>
/// Used by <see cref="Avalonia.Themes.Fluent"/> to define the first indeterminate indicator's start position when animated.
/// </summary>
public double ContainerAnimationStartPosition
{
get => _containerAnimationStartPosition;
set => SetAndRaise(ContainerAnimationStartPositionProperty, ref _containerAnimationStartPosition, value);
set => SetAndRaise(ContainerAnimationStartPositionProperty, ref _containerAnimationStartPosition,
value);
}
/// <summary>
/// Used by <see cref="Avalonia.Themes.Fluent"/> to define the first indeterminate indicator's end position when animated.
/// </summary>
public double ContainerAnimationEndPosition
{
get => _containerAnimationEndPosition;
set => SetAndRaise(ContainerAnimationEndPositionProperty, ref _containerAnimationEndPosition, value);
}
/// <summary>
/// Used by <see cref="Avalonia.Themes.Fluent"/> to define the second indeterminate indicator's start position when animated.
/// </summary>
public double Container2AnimationStartPosition
{
get => _container2AnimationStartPosition;
set => SetAndRaise(Container2AnimationStartPositionProperty, ref _container2AnimationStartPosition, value);
set => SetAndRaise(Container2AnimationStartPositionProperty, ref _container2AnimationStartPosition,
value);
}
public double Container2Width
/// <summary>
/// Used by <see cref="Avalonia.Themes.Fluent"/> to define the second indeterminate indicator's end position when animated.
/// </summary>
public double Container2AnimationEndPosition
{
get => _container2Width;
set => SetAndRaise(Container2WidthProperty, ref _container2Width, value);
get => _container2AnimationEndPosition;
set => SetAndRaise(Container2AnimationEndPositionProperty, ref _container2AnimationEndPosition, value);
}
public double ContainerWidth
/// <summary>
/// Used by <see cref="Avalonia.Themes.Simple"/> to define the starting point of its indeterminate animation.
/// </summary>
public double IndeterminateStartingOffset
{
get => _containerWidth;
set => SetAndRaise(ContainerWidthProperty, ref _containerWidth, value);
get => _indeterminateStartingOffset;
set => SetAndRaise(IndeterminateStartingOffsetProperty, ref _indeterminateStartingOffset, value);
}
public double Container2AnimationEndPosition
/// <summary>
/// Used by <see cref="Avalonia.Themes.Simple"/> to define the ending point of its indeterminate animation.
/// </summary>
public double IndeterminateEndingOffset
{
get => _container2AnimationEndPosition;
set => SetAndRaise(Container2AnimationEndPositionProperty, ref _container2AnimationEndPosition, value);
get => _indeterminateEndingOffset;
set => SetAndRaise(IndeterminateEndingOffsetProperty, ref _indeterminateEndingOffset, value);
}
}
@ -131,7 +211,7 @@ namespace Avalonia.Controls
/// Defines the <see cref="Orientation"/> property.
/// </summary>
public static readonly StyledProperty<Orientation> OrientationProperty =
AvaloniaProperty.Register<ProgressBar, Orientation>(nameof(Orientation), Orientation.Horizontal);
AvaloniaProperty.Register<ProgressBar, Orientation>(nameof(Orientation));
/// <summary>
/// Defines the <see cref="Percentage"/> property.
@ -141,18 +221,6 @@ namespace Avalonia.Controls
nameof(Percentage),
o => o.Percentage);
/// <summary>
/// Defines the <see cref="IndeterminateStartingOffset"/> property.
/// </summary>
public static readonly StyledProperty<double> IndeterminateStartingOffsetProperty =
AvaloniaProperty.Register<ProgressBar, double>(nameof(IndeterminateStartingOffset));
/// <summary>
/// Defines the <see cref="IndeterminateEndingOffset"/> property.
/// </summary>
public static readonly StyledProperty<double> IndeterminateEndingOffsetProperty =
AvaloniaProperty.Register<ProgressBar, double>(nameof(IndeterminateEndingOffset));
/// <summary>
/// Gets the overall percentage complete of the progress
/// </summary>
@ -162,30 +230,13 @@ namespace Avalonia.Controls
/// </remarks>
public double Percentage
{
get { return _percentage; }
get => _percentage;
private set { SetAndRaise(PercentageProperty, ref _percentage, value); }
}
public double IndeterminateStartingOffset
{
get => GetValue(IndeterminateStartingOffsetProperty);
set => SetValue(IndeterminateStartingOffsetProperty, value);
}
public double IndeterminateEndingOffset
{
get => GetValue(IndeterminateEndingOffsetProperty);
set => SetValue(IndeterminateEndingOffsetProperty, value);
}
static ProgressBar()
{
ValueProperty.OverrideMetadata<ProgressBar>(new(defaultBindingMode: BindingMode.OneWay));
ValueProperty.Changed.AddClassHandler<ProgressBar>((x, e) => x.UpdateIndicatorWhenPropChanged(e));
MinimumProperty.Changed.AddClassHandler<ProgressBar>((x, e) => x.UpdateIndicatorWhenPropChanged(e));
MaximumProperty.Changed.AddClassHandler<ProgressBar>((x, e) => x.UpdateIndicatorWhenPropChanged(e));
IsIndeterminateProperty.Changed.AddClassHandler<ProgressBar>((x, e) => x.UpdateIndicatorWhenPropChanged(e));
OrientationProperty.Changed.AddClassHandler<ProgressBar>((x, e) => x.UpdateIndicatorWhenPropChanged(e));
}
/// <summary>
@ -251,6 +302,15 @@ namespace Avalonia.Controls
{
base.OnPropertyChanged(change);
if (change.Property == ValueProperty ||
change.Property == MinimumProperty ||
change.Property == MaximumProperty ||
change.Property == IsIndeterminateProperty ||
change.Property == OrientationProperty)
{
UpdateIndicator();
}
if (change.Property == IsIndeterminateProperty)
{
UpdatePseudoClasses(change.GetNewValue<bool>(), null);
@ -286,64 +346,50 @@ namespace Avalonia.Controls
// Gets the size of the parent indicator container
var barSize = _indicator?.VisualParent?.Bounds.Size ?? Bounds.Size;
if (_indicator != null)
if (_indicator == null) return;
if (IsIndeterminate)
{
if (IsIndeterminate)
{
// Pulled from ModernWPF.
// Pulled from ModernWPF.
var dim = Orientation == Orientation.Horizontal ? barSize.Width : barSize.Height;
var barIndicatorWidth = dim * 0.4; // Indicator width at 40% of ProgressBar
var barIndicatorWidth2 = dim * 0.6; // Indicator width at 60% of ProgressBar
var dim = Orientation == Orientation.Horizontal ? barSize.Width : barSize.Height;
var barIndicatorWidth = dim * 0.4; // Indicator width at 40% of ProgressBar
var barIndicatorWidth2 = dim * 0.6; // Indicator width at 60% of ProgressBar
TemplateSettings.ContainerWidth = barIndicatorWidth;
TemplateSettings.Container2Width = barIndicatorWidth2;
TemplateSettings.ContainerWidth = barIndicatorWidth;
TemplateSettings.Container2Width = barIndicatorWidth2;
TemplateSettings.ContainerAnimationStartPosition = barIndicatorWidth * -1.8; // Position at -180%
TemplateSettings.ContainerAnimationEndPosition = barIndicatorWidth * 3.0; // Position at 300%
TemplateSettings.ContainerAnimationStartPosition = barIndicatorWidth * -1.8; // Position at -180%
TemplateSettings.ContainerAnimationEndPosition = barIndicatorWidth * 3.0; // Position at 300%
TemplateSettings.Container2AnimationStartPosition = barIndicatorWidth2 * -1.5; // Position at -150%
TemplateSettings.Container2AnimationEndPosition = barIndicatorWidth2 * 1.66; // Position at 166%
TemplateSettings.Container2AnimationStartPosition = barIndicatorWidth2 * -1.5; // Position at -150%
TemplateSettings.Container2AnimationEndPosition = barIndicatorWidth2 * 1.66; // Position at 166%
// Remove these properties when we switch to fluent as default and removed the old one.
SetCurrentValue(IndeterminateStartingOffsetProperty,-dim);
SetCurrentValue(IndeterminateEndingOffsetProperty,dim);
TemplateSettings.IndeterminateStartingOffset = -dim;
TemplateSettings.IndeterminateEndingOffset = dim;
}
else
{
var percent = Math.Abs(Maximum - Minimum) < double.Epsilon ?
1.0 :
(Value - Minimum) / (Maximum - Minimum);
var padding = Padding;
var rectangle = new RectangleGeometry(
new Rect(
padding.Left,
padding.Top,
barSize.Width - (padding.Right + padding.Left),
barSize.Height - (padding.Bottom + padding.Top)
));
// When the Orientation changed, the indicator's Width or Height should set to double.NaN.
// Indicator size calculation should consider the ProgressBar's Padding property setting
if (Orientation == Orientation.Horizontal)
{
_indicator.Width = (barSize.Width - _indicator.Margin.Left - _indicator.Margin.Right) * percent;
_indicator.Height = double.NaN;
}
else
{
double percent = Maximum == Minimum ? 1.0 : (Value - Minimum) / (Maximum - Minimum);
// When the Orientation changed, the indicator's Width or Height should set to double.NaN.
// Indicator size calculation should consider the ProgressBar's Padding property setting
if (Orientation == Orientation.Horizontal)
{
_indicator.Width = (barSize.Width - _indicator.Margin.Left - _indicator.Margin.Right) * percent;
_indicator.Height = double.NaN;
}
else
{
_indicator.Width = double.NaN;
_indicator.Height = (barSize.Height - _indicator.Margin.Top - _indicator.Margin.Bottom) * percent;
}
Percentage = percent * 100;
_indicator.Width = double.NaN;
_indicator.Height = (barSize.Height - _indicator.Margin.Top - _indicator.Margin.Bottom) *
percent;
}
}
}
private void UpdateIndicatorWhenPropChanged(AvaloniaPropertyChangedEventArgs e)
{
UpdateIndicator();
Percentage = percent * 100;
}
}
private void UpdatePseudoClasses(
@ -355,11 +401,9 @@ namespace Avalonia.Controls
PseudoClasses.Set(":indeterminate", isIndeterminate.Value);
}
if (o.HasValue)
{
PseudoClasses.Set(":vertical", o == Orientation.Vertical);
PseudoClasses.Set(":horizontal", o == Orientation.Horizontal);
}
if (!o.HasValue) return;
PseudoClasses.Set(":vertical", o == Orientation.Vertical);
PseudoClasses.Set(":horizontal", o == Orientation.Horizontal);
}
}
}

32
src/Avalonia.Controls/Shapes/Shape.cs

@ -126,8 +126,8 @@ namespace Avalonia.Controls.Shapes
/// </summary>
public IBrush? Fill
{
get { return GetValue(FillProperty); }
set { SetValue(FillProperty, value); }
get => GetValue(FillProperty);
set => SetValue(FillProperty, value);
}
/// <summary>
@ -135,8 +135,8 @@ namespace Avalonia.Controls.Shapes
/// </summary>
public Stretch Stretch
{
get { return GetValue(StretchProperty); }
set { SetValue(StretchProperty, value); }
get => GetValue(StretchProperty);
set => SetValue(StretchProperty, value);
}
/// <summary>
@ -144,8 +144,8 @@ namespace Avalonia.Controls.Shapes
/// </summary>
public IBrush? Stroke
{
get { return GetValue(StrokeProperty); }
set { SetValue(StrokeProperty, value); }
get => GetValue(StrokeProperty);
set => SetValue(StrokeProperty, value);
}
/// <summary>
@ -153,8 +153,8 @@ namespace Avalonia.Controls.Shapes
/// </summary>
public AvaloniaList<double>? StrokeDashArray
{
get { return GetValue(StrokeDashArrayProperty); }
set { SetValue(StrokeDashArrayProperty, value); }
get => GetValue(StrokeDashArrayProperty);
set => SetValue(StrokeDashArrayProperty, value);
}
/// <summary>
@ -162,8 +162,8 @@ namespace Avalonia.Controls.Shapes
/// </summary>
public double StrokeDashOffset
{
get { return GetValue(StrokeDashOffsetProperty); }
set { SetValue(StrokeDashOffsetProperty, value); }
get => GetValue(StrokeDashOffsetProperty);
set => SetValue(StrokeDashOffsetProperty, value);
}
/// <summary>
@ -171,8 +171,8 @@ namespace Avalonia.Controls.Shapes
/// </summary>
public double StrokeThickness
{
get { return GetValue(StrokeThicknessProperty); }
set { SetValue(StrokeThicknessProperty, value); }
get => GetValue(StrokeThicknessProperty);
set => SetValue(StrokeThicknessProperty, value);
}
/// <summary>
@ -180,8 +180,8 @@ namespace Avalonia.Controls.Shapes
/// </summary>
public PenLineCap StrokeLineCap
{
get { return GetValue(StrokeLineCapProperty); }
set { SetValue(StrokeLineCapProperty, value); }
get => GetValue(StrokeLineCapProperty);
set => SetValue(StrokeLineCapProperty, value);
}
/// <summary>
@ -189,8 +189,8 @@ namespace Avalonia.Controls.Shapes
/// </summary>
public PenLineJoin StrokeJoin
{
get { return GetValue(StrokeJoinProperty); }
set { SetValue(StrokeJoinProperty, value); }
get => GetValue(StrokeJoinProperty);
set => SetValue(StrokeJoinProperty, value);
}
public sealed override void Render(DrawingContext context)

11
src/Avalonia.Controls/TextChangedEventArgs.cs

@ -3,15 +3,24 @@
namespace Avalonia.Controls
{
/// <summary>
/// Provides data specific to a TextChanged event.
/// Provides data specific to a <see cref="TextBox.TextChanged"/> event.
/// </summary>
public class TextChangedEventArgs : RoutedEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="TextChangedEventArgs"/> class.
/// </summary>
/// <param name="routedEvent">The routed event associated with these event args.</param>
public TextChangedEventArgs(RoutedEvent? routedEvent)
: base (routedEvent)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="TextChangedEventArgs"/> class.
/// </summary>
/// <param name="routedEvent">The routed event associated with these event args.</param>
/// <param name="source">The source object that raised the routed event.</param>
public TextChangedEventArgs(RoutedEvent? routedEvent, Interactive? source)
: base(routedEvent, source)
{

11
src/Avalonia.Controls/TextChangingEventArgs.cs

@ -3,15 +3,24 @@
namespace Avalonia.Controls
{
/// <summary>
/// Provides data specific to a TextChanging event.
/// Provides data specific to a <see cref="TextBox.TextChanging"/> event.
/// </summary>
public class TextChangingEventArgs : RoutedEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="TextChangingEventArgs"/> class.
/// </summary>
/// <param name="routedEvent">The routed event associated with these event args.</param>
public TextChangingEventArgs(RoutedEvent? routedEvent)
: base (routedEvent)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="TextChangingEventArgs"/> class.
/// </summary>
/// <param name="routedEvent">The routed event associated with these event args.</param>
/// <param name="source">The source object that raised the routed event.</param>
public TextChangingEventArgs(RoutedEvent? routedEvent, Interactive? source)
: base(routedEvent, source)
{

3
src/Avalonia.Themes.Fluent/Accents/BaseColorsPalette.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<!-- https://docs.microsoft.com/en-us/previous-versions/windows/apps/dn518235(v=win.10)?redirectedfrom=MSDN -->
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">

3
src/Avalonia.Themes.Fluent/Accents/BaseResources.xaml

@ -1,7 +1,8 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System"
xmlns:converters="using:Avalonia.Controls.Converters">
xmlns:converters="using:Avalonia.Controls.Converters"
x:ClassModifier="internal">
<FontFamily x:Key="ContentControlThemeFontFamily">fonts:Inter#Inter, $Default</FontFamily>
<sys:Double x:Key="ControlContentThemeFontSize">14</sys:Double>

3
src/Avalonia.Themes.Fluent/Accents/FluentControlResources.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<!-- Resources for Button.xaml -->

2
src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj

@ -1,8 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<!-- NativeMenuBar uses ReflectionBinding -->
<NoWarn>$(NoWarn);IL2026</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" />

3
src/Avalonia.Themes.Fluent/Controls/AdornerLayer.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Thickness x:Key="SystemControlFocusVisualMargin">0</Thickness>
<Thickness x:Key="SystemControlFocusVisualPrimaryThickness">2</Thickness>
<Thickness x:Key="SystemControlFocusVisualSecondaryThickness">1</Thickness>

3
src/Avalonia.Themes.Fluent/Controls/AutoCompleteBox.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:generic="using:System.Collections.Generic">
xmlns:generic="using:System.Collections.Generic"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<AutoCompleteBox Width="200">

3
src/Avalonia.Themes.Fluent/Controls/Button.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/ButtonSpinner.xaml

@ -1,7 +1,8 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System"
xmlns:converters="using:Avalonia.Controls.Converters">
xmlns:converters="using:Avalonia.Controls.Converters"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/Calendar.xaml

@ -6,7 +6,8 @@
-->
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<Calendar />

3
src/Avalonia.Themes.Fluent/Controls/CalendarButton.xaml

@ -5,7 +5,8 @@
// All other rights reserved.
-->
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/CalendarDatePicker.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System">
xmlns:sys="using:System"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Margin="20, 20, 20, 200">
<CalendarDatePicker Width="200" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" />

3
src/Avalonia.Themes.Fluent/Controls/CalendarDayButton.xaml

@ -5,7 +5,8 @@
// All other rights reserved.
-->
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/CalendarItem.xaml

@ -6,7 +6,8 @@
-->
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System">
xmlns:sys="using:System"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<Calendar DisplayDate="2000-01-01">

3
src/Avalonia.Themes.Fluent/Controls/CaptionButtons.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/Carousel.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type Carousel}" TargetType="Carousel">
<Setter Property="Template">
<ControlTemplate>

3
src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/ComboBox.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System">
xmlns:sys="using:System"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="10">

3
src/Avalonia.Themes.Fluent/Controls/ComboBoxItem.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<Border Background="{DynamicResource ComboBoxDropDownBackground}" BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}" BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}" Margin="0,-1,0,-1" Padding="{DynamicResource ComboBoxDropdownBorderPadding}" CornerRadius="{DynamicResource OverlayCornerRadius}">

3
src/Avalonia.Themes.Fluent/Controls/ContentControl.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type ContentControl}" TargetType="ContentControl">
<Setter Property="Template">
<ControlTemplate>

3
src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Background="{DynamicResource SystemAccentColor}"
Margin="16"

3
src/Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml

@ -1,7 +1,8 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System"
xmlns:collections="using:System.Collections">
xmlns:collections="using:System.Collections"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/DatePicker.xaml

@ -7,7 +7,8 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System">
xmlns:sys="using:System"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20" Height="500">
<StackPanel Spacing="20" VerticalAlignment="Center">

3
src/Avalonia.Themes.Fluent/Controls/DateTimePickerShared.xaml

@ -6,7 +6,8 @@
-->
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20" Width="200">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/DropDownButton.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/EmbeddableControlRoot.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type EmbeddableControlRoot}" TargetType="EmbeddableControlRoot">
<Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}"/>
<Setter Property="Background" Value="{DynamicResource SystemRegionBrush}"/>

3
src/Avalonia.Themes.Fluent/Controls/Expander.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">

3
src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml

@ -1,6 +1,7 @@
<Styles
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Styles.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

3
src/Avalonia.Themes.Fluent/Controls/FlyoutPresenter.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Thickness x:Key="FlyoutBorderThemeThickness">1</Thickness>
<ControlTheme x:Key="{x:Type FlyoutPresenter}" TargetType="FlyoutPresenter">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />

3
src/Avalonia.Themes.Fluent/Controls/GridSplitter.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type GridSplitter}" TargetType="GridSplitter">
<Setter Property="Focusable" Value="True" />
<Setter Property="MinWidth" Value="6" />

3
src/Avalonia.Themes.Fluent/Controls/ItemsControl.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type ItemsControl}" TargetType="ItemsControl">
<Setter Property="Template">
<ControlTemplate>

3
src/Avalonia.Themes.Fluent/Controls/Label.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type Label}" TargetType="Label">
<Setter Property="Padding" Value="3"/>

3
src/Avalonia.Themes.Fluent/Controls/ListBox.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<ListBox>

3
src/Avalonia.Themes.Fluent/Controls/ListBoxItem.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="0">
<ListBox>

3
src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml

@ -1,7 +1,8 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dialogs="using:Avalonia.Dialogs"
xmlns:internal="using:Avalonia.Dialogs.Internal">
xmlns:internal="using:Avalonia.Dialogs.Internal"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20" Width="800" Height="500">
<dialogs:ManagedFileChooser/>

3
src/Avalonia.Themes.Fluent/Controls/Menu.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<Menu>

3
src/Avalonia.Themes.Fluent/Controls/MenuFlyoutPresenter.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type MenuFlyoutPresenter}" TargetType="MenuFlyoutPresenter">
<Setter Property="Background" Value="{DynamicResource MenuFlyoutPresenterBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderBrush}" />

3
src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="using:Avalonia.Controls.Converters">
xmlns:conv="using:Avalonia.Controls.Converters"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20" Width="320">
<StackPanel Spacing="20" HorizontalAlignment="Left">

3
src/Avalonia.Themes.Fluent/Controls/MenuScrollViewer.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Avalonia.Controls.Converters">
xmlns:converters="using:Avalonia.Controls.Converters"
x:ClassModifier="internal">
<Design.PreviewWith>
<ScrollViewer Theme="{DynamicResource FluentMenuScrollViewer}" Width="200" Height="200">

3
src/Avalonia.Themes.Fluent/Controls/NativeMenuBar.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Avalonia.Themes.Fluent">
xmlns:local="using:Avalonia.Themes.Fluent"
x:ClassModifier="internal">
<local:IBitmapToImageConverter x:Key="AvaloniaThemesFluentNativeMenuBarIBitmapToImageConverter"/>
<ControlTheme x:Key="{x:Type NativeMenuBar}" TargetType="NativeMenuBar">
<Setter Property="Template">

3
src/Avalonia.Themes.Fluent/Controls/NotificationCard.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="0" Background="White">
<NotificationCard Content="Testing" />

3
src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/OverlayPopupHost.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type OverlayPopupHost}" TargetType="OverlayPopupHost">
<Setter Property="Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}"/>
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}"/>

3
src/Avalonia.Themes.Fluent/Controls/PathIcon.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<StackPanel>
<StackPanel.Resources>

3
src/Avalonia.Themes.Fluent/Controls/PopupRoot.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type PopupRoot}" TargetType="PopupRoot">
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="TransparencyLevelHint" Value="Transparent" />

3
src/Avalonia.Themes.Fluent/Controls/ProgressBar.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Avalonia.Controls.Converters">
xmlns:converters="using:Avalonia.Controls.Converters"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Orientation="Horizontal" Spacing="10">

3
src/Avalonia.Themes.Fluent/Controls/RadioButton.xaml

@ -1,4 +1,5 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="10">

3
src/Avalonia.Themes.Fluent/Controls/RefreshContainer.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type RefreshContainer}"
TargetType="RefreshContainer">
<Setter Property="Template">

3
src/Avalonia.Themes.Fluent/Controls/RefreshVisualizer.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type RefreshVisualizer}"
TargetType="RefreshVisualizer">
<Setter Property="IsTabStop" Value="False"/>

3
src/Avalonia.Themes.Fluent/Controls/RepeatButton.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/ScrollBar.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Orientation="Horizontal" Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/ScrollViewer.xaml

@ -1,6 +1,7 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<ScrollViewer Width="200" Height="200"
HorizontalScrollBarVisibility="Auto">

3
src/Avalonia.Themes.Fluent/Controls/SelectableTextBlock.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<SelectableTextBlock Text="Preview" />
</Design.PreviewWith>

3
src/Avalonia.Themes.Fluent/Controls/Separator.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type Separator}" TargetType="Separator">
<Setter Property="Background" Value="{DynamicResource SystemControlForegroundBaseMediumLowBrush}" />
<Setter Property="Focusable" Value="False" />

3
src/Avalonia.Themes.Fluent/Controls/Slider.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System">
xmlns:sys="using:System"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Margin="20" Width="400" Height="600">
<DockPanel LastChildFill="True">

3
src/Avalonia.Themes.Fluent/Controls/SplitButton.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Avalonia.Controls.Converters">
xmlns:converters="using:Avalonia.Controls.Converters"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="60">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/SplitView.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System">
xmlns:sys="using:System"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Width="400" Height="400">
<SplitView DisplayMode="Inline"

3
src/Avalonia.Themes.Fluent/Controls/TabControl.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Width="400">
<TabControl>

3
src/Avalonia.Themes.Fluent/Controls/TabItem.xaml

@ -1,6 +1,7 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/TabStrip.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<TabStrip>

3
src/Avalonia.Themes.Fluent/Controls/TabStripItem.xaml

@ -1,6 +1,7 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/TextBox.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/ThemeVariantScope.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type ThemeVariantScope}"
TargetType="ThemeVariantScope">
<Setter Property="TextElement.Foreground" Value="{DynamicResource SystemControlForegroundBaseHighBrush}"/>

3
src/Avalonia.Themes.Fluent/Controls/TimePicker.xaml

@ -7,7 +7,8 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System">
xmlns:sys="using:System"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20" Height="500">
<StackPanel Spacing="20" VerticalAlignment="Center">

3
src/Avalonia.Themes.Fluent/Controls/TitleBar.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Height="30" Width="300">
<TitleBar Background="SkyBlue" Foreground="Black" />

3
src/Avalonia.Themes.Fluent/Controls/ToggleButton.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/ToggleSwitch.xaml

@ -1,6 +1,7 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<StackPanel Margin="20" Width="250" Spacing="24">
<StackPanel Spacing="12" >

3
src/Avalonia.Themes.Fluent/Controls/ToolTip.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System">
xmlns:sys="using:System"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/TransitioningContentControl.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type TransitioningContentControl}" TargetType="TransitioningContentControl">
<Setter Property="Template">
<ControlTemplate>

3
src/Avalonia.Themes.Fluent/Controls/TreeView.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Spacing="20">

3
src/Avalonia.Themes.Fluent/Controls/TreeViewItem.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Avalonia.Controls.Converters">
xmlns:converters="using:Avalonia.Controls.Converters"
x:ClassModifier="internal">
<Design.PreviewWith>
<Border Padding="20"

3
src/Avalonia.Themes.Fluent/Controls/UserControl.xaml

@ -1,6 +1,7 @@
<Style xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Selector=":is(UserControl)">
Selector=":is(UserControl)"
x:ClassModifier="internal">
<Style.Resources>
<ControlTheme x:Key="FluentUserControl" TargetType="UserControl">
<Setter Property="Template">

3
src/Avalonia.Themes.Fluent/Controls/Window.xaml

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type Window}" TargetType="Window">
<Setter Property="Background" Value="{DynamicResource SystemRegionBrush}"/>
<Setter Property="TransparencyBackgroundFallback" Value="{DynamicResource SystemControlBackgroundAltHighBrush}" />

3
src/Avalonia.Themes.Fluent/Controls/WindowNotificationManager.xaml

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:DataType="WindowNotificationManager">
x:DataType="WindowNotificationManager"
x:ClassModifier="internal">
<ControlTheme x:Key="{x:Type WindowNotificationManager}" TargetType="WindowNotificationManager">
<Setter Property="Margin" Value="0 0" />
<Setter Property="Template">

3
src/Avalonia.Themes.Fluent/DensityStyles/Compact.xaml

@ -1,5 +1,6 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">
<Style Selector="TextBlock" >
<Setter Property="FontSize" Value="14" />
</Style>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save