Browse Source

Merge branch 'master' into master

pull/9674/head
M. Tomecki 4 years ago
committed by GitHub
parent
commit
3768fa8048
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Avalonia.Base/Media/UnicodeRange.cs
  2. 1
      src/Avalonia.Base/Platform/ITextShaperImpl.cs
  3. 2
      src/Avalonia.Base/Rendering/DeferredRenderer.cs
  4. 2
      src/Avalonia.Base/Rendering/ImmediateRenderer.cs
  5. 24
      src/Avalonia.Build.Tasks/GenerateAvaloniaResourcesTask.cs
  6. 4
      src/Avalonia.Controls/Selection/SelectedItems.cs
  7. 2
      src/Avalonia.Remote.Protocol/MetsysBson.cs
  8. 1
      src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml
  9. 1
      src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml
  10. 7
      src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml
  11. 14
      src/Avalonia.Themes.Simple/Controls/ManagedFileChooser.xaml
  12. 1
      src/Skia/Avalonia.Skia/Helpers/ImageSavingHelper.cs
  13. 28
      src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs
  14. 19
      tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Single.cs

2
src/Avalonia.Base/Media/UnicodeRange.cs

@ -104,7 +104,7 @@ namespace Avalonia.Media
public readonly record struct UnicodeRangeSegment
{
private static Regex s_regex = new Regex(@"^(?:[uU]\+)?(?:([0-9a-fA-F](?:[0-9a-fA-F?]{1,5})?))$");
private static Regex s_regex = new Regex(@"^(?:[uU]\+)?(?:([0-9a-fA-F](?:[0-9a-fA-F?]{1,5})?))$", RegexOptions.Compiled);
public UnicodeRangeSegment(int start, int end)
{

1
src/Avalonia.Base/Platform/ITextShaperImpl.cs

@ -13,6 +13,7 @@ namespace Avalonia.Platform
/// Shapes the specified region within the text and returns a shaped buffer.
/// </summary>
/// <param name="text">The text buffer.</param>
/// <param name="length">The length of text.</param>
/// <param name="options">Text shaper options to customize the shaping process.</param>
/// <returns>A shaped glyph run.</returns>
ShapedBuffer ShapeText(CharacterBufferReference text, int length, TextShaperOptions options);

2
src/Avalonia.Base/Rendering/DeferredRenderer.cs

@ -49,6 +49,8 @@ namespace Avalonia.Rendering
/// </summary>
/// <param name="root">The control to render.</param>
/// <param name="renderLoop">The render loop.</param>
/// <param name="renderTargetFactory">The target render factory.</param>
/// <param name="renderInterface">The Platform Render Context.</param>
/// <param name="sceneBuilder">The scene builder to use. Optional.</param>
/// <param name="dispatcher">The dispatcher to use. Optional.</param>
/// <param name="rendererLock">Lock object used before trying to access render target</param>

2
src/Avalonia.Base/Rendering/ImmediateRenderer.cs

@ -30,6 +30,8 @@ namespace Avalonia.Rendering
/// Initializes a new instance of the <see cref="ImmediateRenderer"/> class.
/// </summary>
/// <param name="root">The control to render.</param>
/// <param name="renderTargetFactory">The target render factory.</param>
/// <param name="renderContext">The render contex.</param>
public ImmediateRenderer(Visual root, Func<IRenderTarget> renderTargetFactory,
PlatformRenderInterfaceContextManager? renderContext = null)
{

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

@ -7,7 +7,7 @@ using System.Text;
using Avalonia.Markup.Xaml.PortableXaml;
using Avalonia.Utilities;
using Microsoft.Build.Framework;
using SPath=System.IO.Path;
using SPath = System.IO.Path;
namespace Avalonia.Build.Tasks
{
public class GenerateAvaloniaResourcesTask : ITask
@ -30,12 +30,17 @@ namespace Avalonia.Build.Tasks
private byte[] _data;
private string _sourcePath;
public Source(string relativePath, string root)
public Source(ITaskItem avaloniaResourceItem, string root)
{
root = SPath.GetFullPath(root);
Path = "/" + relativePath.Replace('\\', '/');
var relativePath = avaloniaResourceItem.ItemSpec;
_sourcePath = SPath.Combine(root, relativePath);
Size = (int)new FileInfo(_sourcePath).Length;
var link = avaloniaResourceItem.GetMetadata("Link");
var path = !string.IsNullOrEmpty(link)
? link
: relativePath;
Path = "/" + path.Replace('\\', '/');
}
public string SystemPath => _sourcePath ?? Path;
@ -65,8 +70,7 @@ namespace Avalonia.Build.Tasks
List<Source> BuildResourceSources()
=> Resources.Select(r =>
{
var src = new Source(r.ItemSpec, Root);
var src = new Source(r, Root);
BuildEngine.LogMessage(FormattableString.Invariant($"avares -> name:{src.Path}, path: {src.SystemPath}, size:{src.Size}, ItemSpec:{r.ItemSpec}"), _reportImportance);
return src;
}).ToList();
@ -93,15 +97,15 @@ namespace Avalonia.Build.Tasks
ms.CopyTo(output);
foreach (var s in sources)
{
using(var input = s.Open())
using (var input = s.Open())
input.CopyTo(output);
}
}
private bool PreProcessXamlFiles(List<Source> sources)
{
var typeToXamlIndex = new Dictionary<string, string>();
var typeToXamlIndex = new Dictionary<string, string>();
foreach (var s in sources.ToArray())
{
if (s.Path.ToLowerInvariant().EndsWith(".xaml") || s.Path.ToLowerInvariant().EndsWith(".paml") || s.Path.ToLowerInvariant().EndsWith(".axaml"))
@ -111,7 +115,7 @@ namespace Avalonia.Build.Tasks
{
info = XamlFileInfo.Parse(s.ReadAsString());
}
catch(Exception e)
catch (Exception e)
{
BuildEngine.LogError(BuildEngineErrorCode.InvalidXAML, s.SystemPath, "File doesn't contain valid XAML: " + e);
return false;
@ -121,7 +125,7 @@ namespace Avalonia.Build.Tasks
{
if (typeToXamlIndex.ContainsKey(info.XClass))
{
BuildEngine.LogError(BuildEngineErrorCode.DuplicateXClass, s.SystemPath,
$"Duplicate x:Class directive, {info.XClass} is already used in {typeToXamlIndex[info.XClass]}");
return false;

4
src/Avalonia.Controls/Selection/SelectedItems.cs

@ -35,9 +35,9 @@ namespace Avalonia.Controls.Selection
{
return _owner.SelectedItem;
}
else if (Items is object)
else if (Items is not null && Ranges is not null)
{
return Items[index];
return Items[IndexRange.GetAt(Ranges, index)];
}
else
{

2
src/Avalonia.Remote.Protocol/MetsysBson.cs

@ -1370,7 +1370,7 @@ namespace Metsys.Bson
var pattern = ReadName();
var optionsString = ReadName();
var options = RegexOptions.None;
var options = RegexOptions.Compiled;
if (optionsString.Contains('e')) options = options | RegexOptions.ECMAScript;
if (optionsString.Contains('i')) options = options | RegexOptions.IgnoreCase;
if (optionsString.Contains('l')) options = options | RegexOptions.CultureInvariant;

1
src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml

@ -36,6 +36,7 @@
<SolidColorBrush x:Key="SystemControlBackgroundAltMediumHighBrush" Color="{StaticResource SystemAltMediumHighColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundAltMediumBrush" Color="{StaticResource SystemAltMediumColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundAltMediumLowBrush" Color="{StaticResource SystemAltMediumLowColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundAltLowBrush" Color="{StaticResource SystemAltLowColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundBaseHighBrush" Color="{StaticResource SystemBaseHighColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundBaseLowBrush" Color="{StaticResource SystemBaseLowColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundBaseMediumBrush" Color="{StaticResource SystemBaseMediumColor}" />

1
src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml

@ -36,6 +36,7 @@
<SolidColorBrush x:Key="SystemControlBackgroundAltMediumHighBrush" Color="{StaticResource SystemAltMediumHighColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundAltMediumBrush" Color="{StaticResource SystemAltMediumColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundAltMediumLowBrush" Color="{StaticResource SystemAltMediumLowColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundAltLowBrush" Color="{StaticResource SystemAltLowColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundBaseHighBrush" Color="{StaticResource SystemBaseHighColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundBaseLowBrush" Color="{StaticResource SystemBaseLowColor}" />
<SolidColorBrush x:Key="SystemControlBackgroundBaseMediumBrush" Color="{StaticResource SystemBaseMediumColor}" />

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

@ -153,9 +153,13 @@
<DockPanel x:Name="NavBar" DockPanel.Dock="Top" Margin="8,5,8,0" VerticalAlignment="Center">
<Rectangle Fill="{DynamicResource SystemControlHighlightAltBaseMediumLowBrush}" Height="1" Margin="0,5,0,0" DockPanel.Dock="Bottom"/>
<DockPanel Margin="4,0">
<Button Command="{Binding GoUp}" DockPanel.Dock="Left">
<Button Command="{Binding GoUp}" DockPanel.Dock="Left" Margin="0,0,8,0">
<Path Data="M 0 7 L 7 0 L 14 7 M 7 0 L 7 16" Stroke="{CompiledBinding $parent[Button].Foreground}" StrokeThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,1,0,-1"/>
</Button>
<Button Command="{Binding Refresh}" DockPanel.Dock="Right" Margin="8,0,0,0">
<Path Data="M18.62 3.32c.39 0 .7.29.76.66v3c0 .39-.28.7-.66.76h-3a.77.77 0 0 1-.1-1.52h1.08a7.42 7.42 0 1 0 2.65 4.37.77.77 0 1 1 1.5-.3 8.94 8.94 0 1 1-3-5.12V4.09c0-.43.35-.77.77-.77Z"
Fill="{CompiledBinding $parent[Button].Foreground}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="-2,-4,0,0"/>
</Button>
<TextBox x:Name="Location" Text="{Binding Location}">
<TextBox.KeyBindings>
<KeyBinding Command="{Binding EnterPressed}" Gesture="Enter"/>
@ -322,7 +326,6 @@
<Style Selector="^ /template/ DockPanel#NavBar Button">
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Width" Value="40"/>
<Setter Property="Margin" Value="0,0,8,0"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style Selector="^ /template/ DockPanel#NavBar Button:not(:pointerover):not(:pressed)">

14
src/Avalonia.Themes.Simple/Controls/ManagedFileChooser.xaml

@ -11,6 +11,12 @@
<GeometryDrawing Brush="#FF00529C" Geometry="F1M8,11L5,8 2,11 2,13 4,11 4,15 6,15 6,11 8,13z" />
<GeometryDrawing Brush="#FFF0EFF1" Geometry="F1M8.0001,1.9996L7.5001,3.0006 14.0001,3.0006 14.0001,1.9996z" />
</DrawingGroup>
<DrawingGroup x:Key="Refresh">
<GeometryDrawing Brush="#FFF6F6F6"
Geometry="F1M13.5049,7.3896L13.2339,6.2646 9.9299,7.5886 10.0729,8.3896C10.0909,8.4906 10.1079,8.5926 10.1079,8.6976 10.1079,9.8596 9.1619,10.8046 7.9999,10.8046 6.8369,10.8046 5.8909,9.8596 5.8909,8.6976 5.8909,7.8966 6.3399,7.1996 6.9999,6.8426L6.9999,9.4986 12.6789,4.8156 8.0569,0.9996 6.9999,0.9996 6.9999,3.1266C4.3539,3.6006 2.3389,5.9176 2.3389,8.6976 2.3389,11.8186 4.8789,14.3586 7.9999,14.3586 11.1209,14.3586 13.6609,11.8186 13.6609,8.6976 13.6609,8.2626 13.6089,7.8226 13.5049,7.3896" />
<GeometryDrawing Brush="#FF414141"
Geometry="F1M12.5322,7.623L11.0572,8.214C11.0862,8.372 11.1072,8.533 11.1072,8.697 11.1072,10.415 9.7172,11.805 8.0002,11.805 6.2852,11.805 4.8912,10.415 4.8912,8.697 4.8912,6.983 6.2852,5.59 8.0002,5.59L8.0002,7.378 11.1072,4.815 8.0002,2.25 8.0002,4.039C5.4262,4.039 3.3392,6.123 3.3392,8.697 3.3392,11.27 5.4262,13.358 8.0002,13.358 10.5762,13.358 12.6612,11.27 12.6612,8.697 12.6612,8.327 12.6152,7.969 12.5322,7.623" />
</DrawingGroup>
<internal:ResourceSelectorConverter x:Key="Icons">
<DrawingGroup x:Key="Icon_Folder">
<GeometryDrawing Brush="#00FFFFFF" Geometry="F1M0,0L16,0 16,16 0,16z" />
@ -54,6 +60,14 @@
</Image>
</Button>
</internal:ChildFitter>
<internal:ChildFitter Width="{Binding ElementName=Location, Path=Bounds.Height}"
DockPanel.Dock="Right">
<Button Command="{Binding Refresh}">
<Image Stretch="Fill">
<DrawingImage Drawing="{StaticResource Refresh}" />
</Image>
</Button>
</internal:ChildFitter>
<TextBox x:Name="Location"
Margin="0,0,5,0"
Text="{Binding Location}">

1
src/Skia/Avalonia.Skia/Helpers/ImageSavingHelper.cs

@ -34,6 +34,7 @@ namespace Avalonia.Skia.Helpers
/// Save Skia image to a stream.
/// </summary>
/// <param name="image">Image to save</param>
/// <param name="stream">The output stream to save the image.</param>
/// <param name="quality">
/// The optional quality for PNG compression.
/// The quality value is interpreted from 0 - 100. If quality is null

28
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

@ -134,13 +134,18 @@ namespace Avalonia.Win32
case WindowsMessage.WM_KEYDOWN:
case WindowsMessage.WM_SYSKEYDOWN:
{
e = new RawKeyEventArgs(
WindowsKeyboardDevice.Instance,
timestamp,
_owner,
RawKeyEventType.KeyDown,
KeyInterop.KeyFromVirtualKey(ToInt32(wParam), ToInt32(lParam)),
WindowsKeyboardDevice.Instance.Modifiers);
var key = KeyInterop.KeyFromVirtualKey(ToInt32(wParam), ToInt32(lParam));
if (key != Key.None)
{
e = new RawKeyEventArgs(
WindowsKeyboardDevice.Instance,
timestamp,
_owner,
RawKeyEventType.KeyDown,
key,
WindowsKeyboardDevice.Instance.Modifiers);
}
break;
}
@ -159,13 +164,18 @@ namespace Avalonia.Win32
case WindowsMessage.WM_KEYUP:
case WindowsMessage.WM_SYSKEYUP:
{
e = new RawKeyEventArgs(
var key = KeyInterop.KeyFromVirtualKey(ToInt32(wParam), ToInt32(lParam));
if (key != Key.None)
{
e = new RawKeyEventArgs(
WindowsKeyboardDevice.Instance,
timestamp,
_owner,
RawKeyEventType.KeyUp,
KeyInterop.KeyFromVirtualKey(ToInt32(wParam), ToInt32(lParam)),
key,
WindowsKeyboardDevice.Instance.Modifiers);
}
break;
}
case WindowsMessage.WM_CHAR:

19
tests/Avalonia.Controls.UnitTests/Selection/SelectionModelTests_Single.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Specialized;
using System.Linq;
using Avalonia.Collections;
using Avalonia.Controls.Selection;
using Avalonia.Controls.Utils;
@ -1144,6 +1145,24 @@ namespace Avalonia.Controls.UnitTests.Selection
Assert.Equal(new[] { "foo" }, target.SelectedItems);
Assert.Equal(0, target.AnchorIndex);
}
[Fact]
public void SelectedItems_Indexer_Is_Correct()
{
// Issue #7974
var target = CreateTarget();
var raised = 0;
target.SelectionChanged += (s, e) =>
{
Assert.Equal("bar", e.SelectedItems.First());
Assert.Equal("bar", e.SelectedItems[0]);
++raised;
};
target.Select(1);
Assert.Equal(1, raised);
}
}
public class BatchUpdate

Loading…
Cancel
Save