Browse Source
Merge branch 'master' into fixes/TextLineCharacterHit
pull/4524/head
danwalmsley
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
22 additions and
13 deletions
-
src/Avalonia.Native/AvaloniaNativePlatform.cs
-
src/Avalonia.Native/WindowImplBase.cs
-
src/Avalonia.Visuals/Media/GlyphRun.cs
-
src/Avalonia.Visuals/Rendering/SceneGraph/GlyphRunNode.cs
-
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlDataContextTypeTransformer.cs
-
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs
|
|
|
@ -110,11 +110,20 @@ namespace Avalonia.Native |
|
|
|
.Bind<ISystemDialogImpl>().ToConstant(new SystemDialogs(_factory.CreateSystemDialogs())) |
|
|
|
.Bind<PlatformHotkeyConfiguration>().ToConstant(new PlatformHotkeyConfiguration(KeyModifiers.Meta)) |
|
|
|
.Bind<IMountedVolumeInfoProvider>().ToConstant(new MacOSMountedVolumeInfoProvider()) |
|
|
|
.Bind<IPlatformDragSource>().ToConstant(new AvaloniaNativeDragSource(_factory)) |
|
|
|
; |
|
|
|
.Bind<IPlatformDragSource>().ToConstant(new AvaloniaNativeDragSource(_factory)); |
|
|
|
|
|
|
|
if (_options.UseGpu) |
|
|
|
AvaloniaLocator.CurrentMutable.Bind<IWindowingPlatformGlFeature>() |
|
|
|
.ToConstant(_glFeature = new GlPlatformFeature(_factory.ObtainGlDisplay())); |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
AvaloniaLocator.CurrentMutable.Bind<IWindowingPlatformGlFeature>() |
|
|
|
.ToConstant(_glFeature = new GlPlatformFeature(_factory.ObtainGlDisplay())); |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
// ignored
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public IWindowImpl CreateWindow() |
|
|
|
|
|
|
|
@ -351,12 +351,12 @@ namespace Avalonia.Native |
|
|
|
|
|
|
|
public Point PointToClient(PixelPoint point) |
|
|
|
{ |
|
|
|
return _native.PointToClient(point.ToAvnPoint()).ToAvaloniaPoint(); |
|
|
|
return _native?.PointToClient(point.ToAvnPoint()).ToAvaloniaPoint() ?? default; |
|
|
|
} |
|
|
|
|
|
|
|
public PixelPoint PointToScreen(Point point) |
|
|
|
{ |
|
|
|
return _native.PointToScreen(point.ToAvnPoint()).ToAvaloniaPixelPoint(); |
|
|
|
return _native?.PointToScreen(point.ToAvnPoint()).ToAvaloniaPixelPoint() ?? default; |
|
|
|
} |
|
|
|
|
|
|
|
public void Hide() |
|
|
|
|
|
|
|
@ -555,7 +555,7 @@ namespace Avalonia.Media |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return new Rect(0, 0, width, height); |
|
|
|
return new Rect(0, GlyphTypeface.Ascent * Scale, width, height); |
|
|
|
} |
|
|
|
|
|
|
|
private void Set<T>(ref T field, T value) |
|
|
|
@ -595,8 +595,6 @@ namespace Avalonia.Media |
|
|
|
_glyphRunImpl = platformRenderInterface.CreateGlyphRun(this, out var width); |
|
|
|
|
|
|
|
var height = (GlyphTypeface.Descent - GlyphTypeface.Ascent + GlyphTypeface.LineGap) * Scale; |
|
|
|
|
|
|
|
_bounds = new Rect(0, 0, width, height); |
|
|
|
} |
|
|
|
|
|
|
|
void IDisposable.Dispose() |
|
|
|
|
|
|
|
@ -25,7 +25,7 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
|
GlyphRun glyphRun, |
|
|
|
Point baselineOrigin, |
|
|
|
IDictionary<IVisual, Scene> childScenes = null) |
|
|
|
: base(glyphRun.Bounds, transform) |
|
|
|
: base(glyphRun.Bounds.Translate(baselineOrigin), transform) |
|
|
|
{ |
|
|
|
Transform = transform; |
|
|
|
Foreground = foreground?.ToImmutable(); |
|
|
|
|
|
|
|
@ -24,7 +24,6 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers |
|
|
|
{ |
|
|
|
AvaloniaXamlIlDataContextTypeMetadataNode inferredDataContextTypeNode = null; |
|
|
|
AvaloniaXamlIlDataContextTypeMetadataNode directiveDataContextTypeNode = null; |
|
|
|
bool isDataTemplate = on.Type.GetClrType().Equals(context.GetAvaloniaTypes().DataTemplate); |
|
|
|
|
|
|
|
for (int i = 0; i < on.Children.Count; ++i) |
|
|
|
{ |
|
|
|
@ -57,7 +56,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers |
|
|
|
{ |
|
|
|
inferredDataContextTypeNode = ParseDataContext(context, on, obj); |
|
|
|
} |
|
|
|
else if(isDataTemplate |
|
|
|
else if(context.GetAvaloniaTypes().DataTemplate.IsAssignableFrom(on.Type.GetClrType()) |
|
|
|
&& pa.Property.Name == "DataType" |
|
|
|
&& pa.Values[0] is XamlTypeExtensionNode dataTypeNode) |
|
|
|
{ |
|
|
|
@ -70,7 +69,8 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers |
|
|
|
// do more specialized inference
|
|
|
|
if (directiveDataContextTypeNode is null) |
|
|
|
{ |
|
|
|
if (isDataTemplate && inferredDataContextTypeNode is null) |
|
|
|
if (context.GetAvaloniaTypes().IDataTemplate.IsAssignableFrom(on.Type.GetClrType()) |
|
|
|
&& inferredDataContextTypeNode is null) |
|
|
|
{ |
|
|
|
// Infer data type from collection binding on a control that displays items.
|
|
|
|
var parentObject = context.ParentNodes().OfType<XamlAstConstructableObjectNode>().FirstOrDefault(); |
|
|
|
|
|
|
|
@ -41,6 +41,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers |
|
|
|
public IXamlType ResolveByNameExtension { get; } |
|
|
|
|
|
|
|
public IXamlType DataTemplate { get; } |
|
|
|
public IXamlType IDataTemplate { get; } |
|
|
|
public IXamlType IItemsPresenterHost { get; } |
|
|
|
public IXamlType ItemsRepeater { get; } |
|
|
|
public IXamlType ReflectionBindingExtension { get; } |
|
|
|
@ -98,6 +99,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers |
|
|
|
CompiledBindingExtension = cfg.TypeSystem.GetType("Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindingExtension"); |
|
|
|
ResolveByNameExtension = cfg.TypeSystem.GetType("Avalonia.Markup.Xaml.MarkupExtensions.ResolveByNameExtension"); |
|
|
|
DataTemplate = cfg.TypeSystem.GetType("Avalonia.Markup.Xaml.Templates.DataTemplate"); |
|
|
|
IDataTemplate = cfg.TypeSystem.GetType("Avalonia.Controls.Templates.IDataTemplate"); |
|
|
|
IItemsPresenterHost = cfg.TypeSystem.GetType("Avalonia.Controls.Presenters.IItemsPresenterHost"); |
|
|
|
ItemsRepeater = cfg.TypeSystem.GetType("Avalonia.Controls.ItemsRepeater"); |
|
|
|
ReflectionBindingExtension = cfg.TypeSystem.GetType("Avalonia.Markup.Xaml.MarkupExtensions.ReflectionBindingExtension"); |
|
|
|
|