From c3f01b696b5770e68e443fccad436e893c9c8010 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Tue, 21 Jul 2020 16:22:35 +0200 Subject: [PATCH 01/74] Make sure we always hit the outer sides at the start/end --- src/Avalonia.Visuals/Media/CharacterHit.cs | 2 + .../Media/TextFormatting/TextLineImpl.cs | 18 ++++- .../Media/TextFormatting/TextLineTests.cs | 75 ++++++++++++++++++- 3 files changed, 89 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Visuals/Media/CharacterHit.cs b/src/Avalonia.Visuals/Media/CharacterHit.cs index ba691dad6ef..f018b2d8a9c 100644 --- a/src/Avalonia.Visuals/Media/CharacterHit.cs +++ b/src/Avalonia.Visuals/Media/CharacterHit.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; namespace Avalonia.Media { @@ -9,6 +10,7 @@ namespace Avalonia.Media /// The CharacterHit structure provides information about the index of the first /// character that got hit as well as information about leading or trailing edge. /// + [DebuggerDisplay("CharacterHit({FirstCharacterIndex}, {TrailingLength})")] public readonly struct CharacterHit : IEquatable { /// diff --git a/src/Avalonia.Visuals/Media/TextFormatting/TextLineImpl.cs b/src/Avalonia.Visuals/Media/TextFormatting/TextLineImpl.cs index f73a7be759a..435752160e2 100644 --- a/src/Avalonia.Visuals/Media/TextFormatting/TextLineImpl.cs +++ b/src/Avalonia.Visuals/Media/TextFormatting/TextLineImpl.cs @@ -236,7 +236,7 @@ private bool TryFindNextCharacterHit(CharacterHit characterHit, out CharacterHit var codepointIndex = characterHit.FirstCharacterIndex + characterHit.TrailingLength; - if (codepointIndex >= TextRange.Start + TextRange.Length) + if (codepointIndex > TextRange.End) { return false; // Cannot go forward anymore } @@ -249,11 +249,14 @@ private bool TryFindNextCharacterHit(CharacterHit characterHit, out CharacterHit var foundCharacterHit = run.GlyphRun.FindNearestCharacterHit(characterHit.FirstCharacterIndex + characterHit.TrailingLength, out _); - nextCharacterHit = characterHit.TrailingLength != 0 ? + var isAtEnd = foundCharacterHit.FirstCharacterIndex + foundCharacterHit.TrailingLength == + TextRange.Length; + + nextCharacterHit = isAtEnd || characterHit.TrailingLength != 0 ? foundCharacterHit : new CharacterHit(foundCharacterHit.FirstCharacterIndex + foundCharacterHit.TrailingLength); - if (nextCharacterHit.FirstCharacterIndex > characterHit.FirstCharacterIndex) + if (isAtEnd || nextCharacterHit.FirstCharacterIndex > characterHit.FirstCharacterIndex) { return true; } @@ -272,6 +275,13 @@ private bool TryFindNextCharacterHit(CharacterHit characterHit, out CharacterHit /// private bool TryFindPreviousCharacterHit(CharacterHit characterHit, out CharacterHit previousCharacterHit) { + if (characterHit.FirstCharacterIndex == TextRange.Start) + { + previousCharacterHit = new CharacterHit(TextRange.Start); + + return true; + } + previousCharacterHit = characterHit; var codepointIndex = characterHit.FirstCharacterIndex + characterHit.TrailingLength; @@ -354,7 +364,7 @@ internal static ShapedTextCharacters CreateShapedSymbol(TextRun textRun) return new ShapedTextCharacters(glyphRun, textRun.Properties); } - + /// /// Gets the shaped width of specified shaped text characters. /// diff --git a/tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs b/tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs index 09cbf3bf08d..575a58f337c 100644 --- a/tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs +++ b/tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using Avalonia.Media; using Avalonia.Media.TextFormatting; @@ -101,7 +102,7 @@ public void Should_Get_Previous_Caret_CharacterHit(string text) Assert.Equal(firstCharacterHit.FirstCharacterIndex, previousCharacterHit.FirstCharacterIndex); - Assert.Equal(firstCharacterHit.TrailingLength, previousCharacterHit.TrailingLength); + Assert.Equal(0, previousCharacterHit.TrailingLength); previousCharacterHit = new CharacterHit(clusters[^1], text.Length - clusters[^1]); @@ -119,7 +120,7 @@ public void Should_Get_Previous_Caret_CharacterHit(string text) Assert.Equal(firstCharacterHit.FirstCharacterIndex, previousCharacterHit.FirstCharacterIndex); - Assert.Equal(firstCharacterHit.TrailingLength, previousCharacterHit.TrailingLength); + Assert.Equal(0, previousCharacterHit.TrailingLength); } } @@ -272,6 +273,76 @@ public void Should_Collapse_Line(string text, int numberOfCharacters, TextCollap } } + [Fact] + public void TestNext() + { + using (Start()) + { + var defaultProperties = new GenericTextRunProperties(Typeface.Default); + + var textSource = new SingleBufferTextSource("Text from memory", defaultProperties); + + var formatter = new TextFormatterImpl(); + + var textLine = + formatter.FormatLine(textSource, 0, double.PositiveInfinity, + new GenericTextParagraphProperties(defaultProperties)); + + var characterHits = new List(); + + var currentCharacterHit = new CharacterHit(0); + + characterHits.Add(currentCharacterHit); + + var nextCharacterHit = textLine.GetNextCaretCharacterHit(currentCharacterHit); + + while (nextCharacterHit != currentCharacterHit) + { + currentCharacterHit = nextCharacterHit; + + characterHits.Add(currentCharacterHit); + + nextCharacterHit = textLine.GetNextCaretCharacterHit(currentCharacterHit); + } + } + } + + [Fact] + public void TestPrevious() + { + using (Start()) + { + var defaultProperties = new GenericTextRunProperties(Typeface.Default); + + var text = "Text from memory"; + + var textSource = new SingleBufferTextSource(text, defaultProperties); + + var formatter = new TextFormatterImpl(); + + var textLine = + formatter.FormatLine(textSource, 0, double.PositiveInfinity, + new GenericTextParagraphProperties(defaultProperties)); + + var characterHits = new List(); + + var currentCharacterHit = new CharacterHit(text.Length); + + characterHits.Add(currentCharacterHit); + + var nextCharacterHit = textLine.GetPreviousCaretCharacterHit(currentCharacterHit); + + while (nextCharacterHit != currentCharacterHit) + { + currentCharacterHit = nextCharacterHit; + + characterHits.Add(currentCharacterHit); + + nextCharacterHit = textLine.GetPreviousCaretCharacterHit(currentCharacterHit); + } + } + } + private static IDisposable Start() { var disposable = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface From f00219379cba4717f2abda16fbc8d9a7ed94481b Mon Sep 17 00:00:00 2001 From: Maksym Katsydan Date: Tue, 21 Jul 2020 19:48:48 -0400 Subject: [PATCH 02/74] Detailed MenuPage examples --- samples/ControlCatalog/Pages/MenuPage.xaml | 31 +++++++++++++++- .../ViewModels/MenuPageViewModel.cs | 36 ++++++++++--------- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/samples/ControlCatalog/Pages/MenuPage.xaml b/samples/ControlCatalog/Pages/MenuPage.xaml index de9ea34e80a..e9d2301e897 100644 --- a/samples/ControlCatalog/Pages/MenuPage.xaml +++ b/samples/ControlCatalog/Pages/MenuPage.xaml @@ -20,7 +20,9 @@ - + + + @@ -52,6 +54,33 @@ + + + + Mixed + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ControlCatalog/ViewModels/MenuPageViewModel.cs b/samples/ControlCatalog/ViewModels/MenuPageViewModel.cs index dc9c4a8f49b..9e7ae8b716f 100644 --- a/samples/ControlCatalog/ViewModels/MenuPageViewModel.cs +++ b/samples/ControlCatalog/ViewModels/MenuPageViewModel.cs @@ -17,6 +17,23 @@ public MenuPageViewModel() SaveCommand = ReactiveCommand.Create(Save, Observable.Return(false)); OpenRecentCommand = ReactiveCommand.Create(OpenRecent); + var recentItems = new[] + { + new MenuItemViewModel + { + Header = "File1.txt", + Command = OpenRecentCommand, + CommandParameter = @"c:\foo\File1.txt" + }, + new MenuItemViewModel + { + Header = "File2.txt", + Command = OpenRecentCommand, + CommandParameter = @"c:\foo\File2.txt" + }, + }; + + RecentItems = recentItems; MenuItems = new[] { new MenuItemViewModel @@ -24,27 +41,13 @@ public MenuPageViewModel() Header = "_File", Items = new[] { - new MenuItemViewModel { Header = "_Open...", Command = OpenCommand }, + new MenuItemViewModel { Header = "O_pen...", Command = OpenCommand }, new MenuItemViewModel { Header = "Save", Command = SaveCommand }, new MenuItemViewModel { Header = "-" }, new MenuItemViewModel { Header = "Recent", - Items = new[] - { - new MenuItemViewModel - { - Header = "File1.txt", - Command = OpenRecentCommand, - CommandParameter = @"c:\foo\File1.txt" - }, - new MenuItemViewModel - { - Header = "File2.txt", - Command = OpenRecentCommand, - CommandParameter = @"c:\foo\File2.txt" - }, - } + Items = recentItems }, } }, @@ -61,6 +64,7 @@ public MenuPageViewModel() } public IReadOnlyList MenuItems { get; set; } + public IReadOnlyList RecentItems { get; set; } public ReactiveCommand OpenCommand { get; } public ReactiveCommand SaveCommand { get; } public ReactiveCommand OpenRecentCommand { get; } From 3c444dc279fe8a030d489315ddc8888b21140a2e Mon Sep 17 00:00:00 2001 From: Maksym Katsydan Date: Tue, 21 Jul 2020 19:49:58 -0400 Subject: [PATCH 03/74] Fix MenuItem:pressed state --- src/Avalonia.Themes.Fluent/MenuItem.xaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/MenuItem.xaml b/src/Avalonia.Themes.Fluent/MenuItem.xaml index fbb994e90c4..4899bf264f4 100644 --- a/src/Avalonia.Themes.Fluent/MenuItem.xaml +++ b/src/Avalonia.Themes.Fluent/MenuItem.xaml @@ -183,10 +183,10 @@ - + @@ -212,14 +212,15 @@ - - - From 5e2c641f02f0c6d4382ed1a040c86c5576d825ca Mon Sep 17 00:00:00 2001 From: Maksym Katsydan Date: Tue, 21 Jul 2020 20:21:13 -0400 Subject: [PATCH 04/74] Move Popup in Fluent MenuItem to another parent node and add MenuFlyoutSubItemPopupHorizontalOffset --- src/Avalonia.Themes.Fluent/MenuItem.xaml | 155 ++++++++++++----------- 1 file changed, 79 insertions(+), 76 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/MenuItem.xaml b/src/Avalonia.Themes.Fluent/MenuItem.xaml index 4899bf264f4..0442c38025b 100644 --- a/src/Avalonia.Themes.Fluent/MenuItem.xaml +++ b/src/Avalonia.Themes.Fluent/MenuItem.xaml @@ -40,6 +40,7 @@ + -4 0,4,0,4 0,0,12,0 24,0,0,0 @@ -54,83 +55,85 @@ - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + From bb46dee949714829a7515e0637c1f32b5061c61d Mon Sep 17 00:00:00 2001 From: Maksym Katsydan Date: Tue, 21 Jul 2020 20:48:07 -0400 Subject: [PATCH 05/74] MenuBar item header should be centered --- src/Avalonia.Themes.Fluent/Menu.xaml | 8 +++++--- src/Avalonia.Themes.Fluent/MenuItem.xaml | 9 ++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Menu.xaml b/src/Avalonia.Themes.Fluent/Menu.xaml index 5f22f77d189..cf647ec64a4 100644 --- a/src/Avalonia.Themes.Fluent/Menu.xaml +++ b/src/Avalonia.Themes.Fluent/Menu.xaml @@ -10,11 +10,13 @@ - - 32 + + 32 + 12,0,12,0 + - + @@ -187,7 +189,12 @@ + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - From 836a4d88c89c227f98b82abe38510ddb469cce36 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sat, 25 Jul 2020 20:37:45 +0200 Subject: [PATCH 45/74] Add missing style include for TitleBar in default theme. --- src/Avalonia.Themes.Default/DefaultTheme.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Avalonia.Themes.Default/DefaultTheme.xaml b/src/Avalonia.Themes.Default/DefaultTheme.xaml index 97cff5d94be..4e63d1d2238 100644 --- a/src/Avalonia.Themes.Default/DefaultTheme.xaml +++ b/src/Avalonia.Themes.Default/DefaultTheme.xaml @@ -37,6 +37,7 @@ + From 027783e3decf635ba2ba38033355563ebdfa832f Mon Sep 17 00:00:00 2001 From: Anton Mitsengendler Date: Sun, 26 Jul 2020 01:26:36 +0300 Subject: [PATCH 46/74] Added ComboBox placeholder to default theme template --- src/Avalonia.Themes.Default/ComboBox.xaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Themes.Default/ComboBox.xaml b/src/Avalonia.Themes.Default/ComboBox.xaml index ae5b902ae8c..8ee818bad28 100644 --- a/src/Avalonia.Themes.Default/ComboBox.xaml +++ b/src/Avalonia.Themes.Default/ComboBox.xaml @@ -1,4 +1,5 @@ - + @@ -24,6 +25,7 @@ + + Date: Sun, 26 Jul 2020 13:18:43 +0200 Subject: [PATCH 47/74] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 19a9a8420dc..c1bf5bbfde4 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/AvaloniaUI/Avalonia?utm_campaign=pr-badge&utm_content=badge&utm_medium=badge&utm_source=badge) [![Build Status](https://dev.azure.com/AvaloniaUI/AvaloniaUI/_apis/build/status/AvaloniaUI.Avalonia)](https://dev.azure.com/AvaloniaUI/AvaloniaUI/_build/latest?definitionId=4) [![Backers on Open Collective](https://opencollective.com/Avalonia/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/Avalonia/sponsors/badge.svg)](#sponsors) ![License](https://img.shields.io/github/license/avaloniaui/avalonia.svg) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/AvaloniaUI/Avalonia?utm_campaign=pr-badge&utm_content=badge&utm_medium=badge&utm_source=badge) [![Discord](https://img.shields.io/badge/discord-join%20chat-46BC99)]( https://aka.ms/dotnet-discord) [![Build Status](https://dev.azure.com/AvaloniaUI/AvaloniaUI/_apis/build/status/AvaloniaUI.Avalonia)](https://dev.azure.com/AvaloniaUI/AvaloniaUI/_build/latest?definitionId=4) [![Backers on Open Collective](https://opencollective.com/Avalonia/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/Avalonia/sponsors/badge.svg)](#sponsors) ![License](https://img.shields.io/github/license/avaloniaui/avalonia.svg)
[![NuGet](https://img.shields.io/nuget/v/Avalonia.svg)](https://www.nuget.org/packages/Avalonia) [![downloads](https://img.shields.io/nuget/dt/avalonia)](https://www.nuget.org/packages/Avalonia) [![MyGet](https://img.shields.io/myget/avalonia-ci/vpre/Avalonia.svg?label=myget)](https://www.myget.org/gallery/avalonia-ci) ![Size](https://img.shields.io/github/repo-size/avaloniaui/avalonia.svg) From b04a1f78646099fa6f2a3dd4026ff2e7697d61cb Mon Sep 17 00:00:00 2001 From: Anton Mitsengendler Date: Sun, 26 Jul 2020 22:12:39 +0300 Subject: [PATCH 48/74] Changed resource name for a default placeholder foreground Added template binding for the placeholder foreground property to make it customizable from user code --- src/Avalonia.Themes.Default/ComboBox.xaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Themes.Default/ComboBox.xaml b/src/Avalonia.Themes.Default/ComboBox.xaml index 8ee818bad28..0fd6b144a4d 100644 --- a/src/Avalonia.Themes.Default/ComboBox.xaml +++ b/src/Avalonia.Themes.Default/ComboBox.xaml @@ -25,7 +25,7 @@ - + Date: Mon, 27 Jul 2020 16:03:16 +0300 Subject: [PATCH 49/74] Enabled custom renderer factory for X11 and macOS --- src/Avalonia.Native/WindowImplBase.cs | 10 +++++++++- src/Avalonia.X11/X11Window.cs | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Native/WindowImplBase.cs b/src/Avalonia.Native/WindowImplBase.cs index 42eecc36ea6..4b13666eddb 100644 --- a/src/Avalonia.Native/WindowImplBase.cs +++ b/src/Avalonia.Native/WindowImplBase.cs @@ -300,7 +300,15 @@ public void Resize(Size clientSize) public IRenderer CreateRenderer(IRenderRoot root) { if (_deferredRendering) - return new DeferredRenderer(root, AvaloniaLocator.Current.GetService()); + { + var loop = AvaloniaLocator.Current.GetService(); + var customRendererFactory = AvaloniaLocator.Current.GetService(); + + if (customRendererFactory != null) + return customRendererFactory.Create(root, loop); + return new DeferredRenderer(root, loop); + } + return new ImmediateRenderer(root); } diff --git a/src/Avalonia.X11/X11Window.cs b/src/Avalonia.X11/X11Window.cs index c24abcd2302..0c0b942bcd8 100644 --- a/src/Avalonia.X11/X11Window.cs +++ b/src/Avalonia.X11/X11Window.cs @@ -331,6 +331,11 @@ public Action TransparencyLevelChanged public IRenderer CreateRenderer(IRenderRoot root) { var loop = AvaloniaLocator.Current.GetService(); + var customRendererFactory = AvaloniaLocator.Current.GetService(); + + if (customRendererFactory != null) + return customRendererFactory.Create(root, loop); + return _platform.Options.UseDeferredRendering ? new DeferredRenderer(root, loop) : (IRenderer)new X11ImmediateRendererProxy(root, loop); From 8ac2e525ada5f667d77774dd5880efcbd7fc1bea Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 27 Jul 2020 16:03:40 +0300 Subject: [PATCH 50/74] Expose SKSurface from ISkiaDrawingContextImpl --- src/Skia/Avalonia.Skia/DrawingContextImpl.cs | 8 +++++--- src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs | 2 +- src/Skia/Avalonia.Skia/Gpu/ISkiaGpuRenderSession.cs | 2 +- src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs | 2 +- src/Skia/Avalonia.Skia/Gpu/SkiaGpuRenderTarget.cs | 2 +- src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs | 1 + src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs index d818e683c39..b93d0f88686 100644 --- a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs +++ b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs @@ -44,7 +44,7 @@ public struct CreateInfo /// /// Canvas to draw to. /// - public SKCanvas Canvas; + public SKSurface Surface; /// /// Dpi of drawings. @@ -81,8 +81,8 @@ public DrawingContextImpl(CreateInfo createInfo, params IDisposable[] disposable _grContext = createInfo.GrContext; if (_grContext != null) Monitor.Enter(_grContext); - - Canvas = createInfo.Canvas; + Surface = createInfo.Surface; + Canvas = createInfo.Surface.Canvas; if (Canvas == null) { @@ -102,8 +102,10 @@ public DrawingContextImpl(CreateInfo createInfo, params IDisposable[] disposable /// Skia canvas. /// public SKCanvas Canvas { get; } + public SKSurface Surface { get; } SKCanvas ISkiaDrawingContextImpl.SkCanvas => Canvas; + SKSurface ISkiaDrawingContextImpl.SkSurface => Surface; GRContext ISkiaDrawingContextImpl.GrContext => _grContext; /// diff --git a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs index 8b04676b09c..8d35d27a816 100644 --- a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs @@ -52,7 +52,7 @@ public IDrawingContextImpl CreateDrawingContext(IVisualBrushRenderer visualBrush var createInfo = new DrawingContextImpl.CreateInfo { - Canvas = canvas, + Surface = _framebufferSurface, Dpi = framebuffer.Dpi, VisualBrushRenderer = visualBrushRenderer, DisableTextLcdRendering = true diff --git a/src/Skia/Avalonia.Skia/Gpu/ISkiaGpuRenderSession.cs b/src/Skia/Avalonia.Skia/Gpu/ISkiaGpuRenderSession.cs index c54d1bd8594..a4e2bfed521 100644 --- a/src/Skia/Avalonia.Skia/Gpu/ISkiaGpuRenderSession.cs +++ b/src/Skia/Avalonia.Skia/Gpu/ISkiaGpuRenderSession.cs @@ -16,7 +16,7 @@ public interface ISkiaGpuRenderSession : IDisposable /// /// Canvas that will be used to render. /// - SKCanvas Canvas { get; } + SKSurface SkSurface { get; } /// /// Scaling factor. diff --git a/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs b/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs index e0b7019672f..2bb739f3726 100644 --- a/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/Gpu/OpenGl/GlRenderTarget.cs @@ -49,7 +49,7 @@ public void Dispose() } public GRContext GrContext { get; } - public SKCanvas Canvas => _surface.Canvas; + public SKSurface SkSurface => _surface; public double ScaleFactor => _glSession.Scaling; } diff --git a/src/Skia/Avalonia.Skia/Gpu/SkiaGpuRenderTarget.cs b/src/Skia/Avalonia.Skia/Gpu/SkiaGpuRenderTarget.cs index 94e513b2fde..ef5da5eb082 100644 --- a/src/Skia/Avalonia.Skia/Gpu/SkiaGpuRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/Gpu/SkiaGpuRenderTarget.cs @@ -27,7 +27,7 @@ public IDrawingContextImpl CreateDrawingContext(IVisualBrushRenderer visualBrush var nfo = new DrawingContextImpl.CreateInfo { GrContext = session.GrContext, - Canvas = session.Canvas, + Surface = session.SkSurface, Dpi = SkiaPlatform.DefaultDpi * session.ScaleFactor, VisualBrushRenderer = visualBrushRenderer, DisableTextLcdRendering = true diff --git a/src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs b/src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs index a9b91384d7f..38fa5a5253d 100644 --- a/src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs +++ b/src/Skia/Avalonia.Skia/ISkiaDrawingContextImpl.cs @@ -7,5 +7,6 @@ public interface ISkiaDrawingContextImpl : IDrawingContextImpl { SKCanvas SkCanvas { get; } GRContext GrContext { get; } + SKSurface SkSurface { get; } } } diff --git a/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs b/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs index 588f7bee6c9..27b29c6e1e6 100644 --- a/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs @@ -70,7 +70,7 @@ public IDrawingContextImpl CreateDrawingContext(IVisualBrushRenderer visualBrush var createInfo = new DrawingContextImpl.CreateInfo { - Canvas = _canvas, + Surface = _surface, Dpi = Dpi, VisualBrushRenderer = visualBrushRenderer, DisableTextLcdRendering = _disableLcdRendering, From 2bec4c14c5b77bf2b94f5943d311d18b78d2ce1b Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Mon, 27 Jul 2020 15:14:10 +0200 Subject: [PATCH 51/74] Fixes SKFontStyleSlant to FontStyle conversion --- src/Avalonia.Visuals/Media/FontStyle.cs | 8 ++++---- src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs | 3 ++- src/Skia/Avalonia.Skia/SkiaSharpExtensions.cs | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Visuals/Media/FontStyle.cs b/src/Avalonia.Visuals/Media/FontStyle.cs index cbc92b1a9f8..b9d04bf9ff0 100644 --- a/src/Avalonia.Visuals/Media/FontStyle.cs +++ b/src/Avalonia.Visuals/Media/FontStyle.cs @@ -11,13 +11,13 @@ public enum FontStyle Normal, /// - /// An oblique font. + /// An italic font. /// - Oblique, + Italic, /// - /// An italic font. + /// An oblique font. /// - Italic, + Oblique } } diff --git a/src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs b/src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs index d36baf331db..7ca44e72827 100644 --- a/src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs +++ b/src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs @@ -56,7 +56,8 @@ private static SKTypefaceCollection CreateCustomFontCollection(FontFamily fontFa continue; } - var key = new FontKey(fontFamily.Name, (FontStyle)typeface.FontSlant, (FontWeight)typeface.FontWeight); + var key = new FontKey(fontFamily.Name, typeface.FontSlant.ToAvalonia(), + (FontWeight)typeface.FontWeight); typeFaceCollection.AddTypeface(key, typeface); } diff --git a/src/Skia/Avalonia.Skia/SkiaSharpExtensions.cs b/src/Skia/Avalonia.Skia/SkiaSharpExtensions.cs index ec7e0a67ed9..1e772ef0673 100644 --- a/src/Skia/Avalonia.Skia/SkiaSharpExtensions.cs +++ b/src/Skia/Avalonia.Skia/SkiaSharpExtensions.cs @@ -138,6 +138,17 @@ public static TextAlignment ToAvalonia(this SKTextAlign a) } } + public static FontStyle ToAvalonia(this SKFontStyleSlant slant) + { + return slant switch + { + SKFontStyleSlant.Upright => FontStyle.Normal, + SKFontStyleSlant.Italic => FontStyle.Italic, + SKFontStyleSlant.Oblique => FontStyle.Oblique, + _ => throw new ArgumentOutOfRangeException(nameof (slant), slant, null) + }; + } + public static SKPath Clone(this SKPath src) { return src != null ? new SKPath(src) : null; From 54553b44d39d7e32d7980da4b7d9276bdbd69b94 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Mon, 27 Jul 2020 16:48:41 +0200 Subject: [PATCH 52/74] Make npm silent --- nukebuild/Build.cs | 4 +++- .../Remote/HtmlTransport/webapp/webpack.config.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index fe877dc49c3..fbfbf47e1bd 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -128,7 +128,9 @@ IReadOnlyCollection MsBuildCommon( { var webappDir = RootDirectory / "src" / "Avalonia.DesignerSupport" / "Remote" / "HtmlTransport" / "webapp"; - NpmTasks.NpmInstall(c => c.SetWorkingDirectory(webappDir)); + NpmTasks.NpmInstall(c => c + .SetWorkingDirectory(webappDir) + .SetArgumentConfigurator(a => a.Add("--silent"))); NpmTasks.NpmRun(c => c .SetWorkingDirectory(webappDir) .SetCommand("dist")); diff --git a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/webpack.config.js b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/webpack.config.js index 3057f269a59..3750351165f 100644 --- a/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/webpack.config.js +++ b/src/Avalonia.DesignerSupport/Remote/HtmlTransport/webapp/webpack.config.js @@ -93,7 +93,7 @@ const config = { plugins: [ new Printer(), - new CleanWebpackPlugin([path.resolve(__dirname, 'build')]), + new CleanWebpackPlugin([path.resolve(__dirname, 'build')], { verbose: false }), new MiniCssExtractPlugin({ filename: "[name].[chunkhash]h" + ".css", From 8e1443384f5b8323178a5102e3fcdb1891008f5f Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Mon, 27 Jul 2020 17:25:33 +0200 Subject: [PATCH 53/74] Add app compat baseline --- src/Avalonia.Visuals/ApiCompatBaseline.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/Avalonia.Visuals/ApiCompatBaseline.txt diff --git a/src/Avalonia.Visuals/ApiCompatBaseline.txt b/src/Avalonia.Visuals/ApiCompatBaseline.txt new file mode 100644 index 00000000000..00618448a2c --- /dev/null +++ b/src/Avalonia.Visuals/ApiCompatBaseline.txt @@ -0,0 +1,4 @@ +Compat issues with assembly Avalonia.Visuals: +EnumValuesMustMatch : Enum value 'Avalonia.Media.FontStyle Avalonia.Media.FontStyle.Italic' is (System.Int32)1 in the implementation but (System.Int32)2 in the contract. +EnumValuesMustMatch : Enum value 'Avalonia.Media.FontStyle Avalonia.Media.FontStyle.Oblique' is (System.Int32)2 in the implementation but (System.Int32)1 in the contract. +Total Issues: 2 From 385dd5227155342ed5c1fb142bcbfcce21312584 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 27 Jul 2020 13:33:15 -0300 Subject: [PATCH 54/74] remove apicompat from backend impl checks. --- .../Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj | 3 +-- src/Skia/Avalonia.Skia/Avalonia.Skia.csproj | 3 +-- src/Windows/Avalonia.Win32/Avalonia.Win32.csproj | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj b/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj index 22599200bc4..48095a4c25b 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj +++ b/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj @@ -7,6 +7,5 @@ - - + diff --git a/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj b/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj index ef955eb8be4..ac029f10624 100644 --- a/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj +++ b/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj @@ -16,6 +16,5 @@ - - + diff --git a/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj b/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj index bcbdde322cb..7fc24d4d3db 100644 --- a/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj +++ b/src/Windows/Avalonia.Win32/Avalonia.Win32.csproj @@ -8,6 +8,5 @@ - - + From 307ab82292bf4eed46e390e7d77def7acc28cbcb Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 27 Jul 2020 13:37:01 -0300 Subject: [PATCH 55/74] remove opengl apicompat checks. --- src/Avalonia.OpenGL/Avalonia.OpenGL.csproj | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Avalonia.OpenGL/Avalonia.OpenGL.csproj b/src/Avalonia.OpenGL/Avalonia.OpenGL.csproj index 2e23f24deb3..d761e60c074 100644 --- a/src/Avalonia.OpenGL/Avalonia.OpenGL.csproj +++ b/src/Avalonia.OpenGL/Avalonia.OpenGL.csproj @@ -9,7 +9,5 @@ - - - + From d759435c05a089086484d664752b5a35297e903d Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Mon, 27 Jul 2020 21:52:51 +0300 Subject: [PATCH 56/74] Reverts changing colors for default theme by '36c5ad4621d372cf932f1259c77a23c4d1cb6962' --- src/Avalonia.Themes.Default/TitleBar.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Themes.Default/TitleBar.xaml b/src/Avalonia.Themes.Default/TitleBar.xaml index 4dba5b4ba4e..7f8ed240769 100644 --- a/src/Avalonia.Themes.Default/TitleBar.xaml +++ b/src/Avalonia.Themes.Default/TitleBar.xaml @@ -5,7 +5,7 @@