committed by
GitHub
340 changed files with 9233 additions and 4908 deletions
@ -0,0 +1,5 @@ |
|||||
|
<ProjectConfiguration> |
||||
|
<Settings> |
||||
|
<IgnoreThisComponentCompletely>False</IgnoreThisComponentCompletely> |
||||
|
</Settings> |
||||
|
</ProjectConfiguration> |
||||
@ -0,0 +1,40 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids --> |
||||
|
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0002</DiagnosticId> |
||||
|
<Target>M:Avalonia.Headless.HeadlessWindowExtensions.DragDrop(Avalonia.Controls.TopLevel,Avalonia.Point,Avalonia.Input.Raw.RawDragEventType,Avalonia.Input.IDataObject,Avalonia.Input.DragDropEffects,Avalonia.Input.RawInputModifiers)</Target> |
||||
|
<Left>baseline/Avalonia.Headless/lib/net10.0/Avalonia.Headless.dll</Left> |
||||
|
<Right>current/Avalonia.Headless/lib/net10.0/Avalonia.Headless.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0002</DiagnosticId> |
||||
|
<Target>M:Avalonia.Headless.HeadlessWindowExtensions.KeyPress(Avalonia.Controls.TopLevel,Avalonia.Input.Key,Avalonia.Input.RawInputModifiers)</Target> |
||||
|
<Left>baseline/Avalonia.Headless/lib/net10.0/Avalonia.Headless.dll</Left> |
||||
|
<Right>current/Avalonia.Headless/lib/net10.0/Avalonia.Headless.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0002</DiagnosticId> |
||||
|
<Target>M:Avalonia.Headless.HeadlessWindowExtensions.KeyRelease(Avalonia.Controls.TopLevel,Avalonia.Input.Key,Avalonia.Input.RawInputModifiers)</Target> |
||||
|
<Left>baseline/Avalonia.Headless/lib/net10.0/Avalonia.Headless.dll</Left> |
||||
|
<Right>current/Avalonia.Headless/lib/net10.0/Avalonia.Headless.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0002</DiagnosticId> |
||||
|
<Target>M:Avalonia.Headless.HeadlessWindowExtensions.DragDrop(Avalonia.Controls.TopLevel,Avalonia.Point,Avalonia.Input.Raw.RawDragEventType,Avalonia.Input.IDataObject,Avalonia.Input.DragDropEffects,Avalonia.Input.RawInputModifiers)</Target> |
||||
|
<Left>baseline/Avalonia.Headless/lib/net8.0/Avalonia.Headless.dll</Left> |
||||
|
<Right>current/Avalonia.Headless/lib/net8.0/Avalonia.Headless.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0002</DiagnosticId> |
||||
|
<Target>M:Avalonia.Headless.HeadlessWindowExtensions.KeyPress(Avalonia.Controls.TopLevel,Avalonia.Input.Key,Avalonia.Input.RawInputModifiers)</Target> |
||||
|
<Left>baseline/Avalonia.Headless/lib/net8.0/Avalonia.Headless.dll</Left> |
||||
|
<Right>current/Avalonia.Headless/lib/net8.0/Avalonia.Headless.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0002</DiagnosticId> |
||||
|
<Target>M:Avalonia.Headless.HeadlessWindowExtensions.KeyRelease(Avalonia.Controls.TopLevel,Avalonia.Input.Key,Avalonia.Input.RawInputModifiers)</Target> |
||||
|
<Left>baseline/Avalonia.Headless/lib/net8.0/Avalonia.Headless.dll</Left> |
||||
|
<Right>current/Avalonia.Headless/lib/net8.0/Avalonia.Headless.dll</Right> |
||||
|
</Suppression> |
||||
|
</Suppressions> |
||||
@ -0,0 +1,100 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids --> |
||||
|
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0001</DiagnosticId> |
||||
|
<Target>T:Avalonia.Skia.ISkiaGpuRenderTarget2</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0001</DiagnosticId> |
||||
|
<Target>T:Avalonia.Skia.ISkiaGpuWithPlatformGraphicsContext</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0001</DiagnosticId> |
||||
|
<Target>T:Avalonia.Skia.ISkiaGpuRenderTarget2</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0001</DiagnosticId> |
||||
|
<Target>T:Avalonia.Skia.ISkiaGpuWithPlatformGraphicsContext</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0002</DiagnosticId> |
||||
|
<Target>M:Avalonia.Skia.ISkiaGpuRenderTarget.BeginRenderingSession</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0002</DiagnosticId> |
||||
|
<Target>M:Avalonia.Skia.ISkiaGpuRenderTarget.BeginRenderingSession</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0006</DiagnosticId> |
||||
|
<Target>M:Avalonia.Skia.ISkiaGpu.TryGetGrContext</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0006</DiagnosticId> |
||||
|
<Target>M:Avalonia.Skia.ISkiaGpuRenderTarget.BeginRenderingSession(System.Nullable{Avalonia.PixelSize})</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0006</DiagnosticId> |
||||
|
<Target>P:Avalonia.Skia.ISkiaGpu.PlatformGraphicsContext</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0006</DiagnosticId> |
||||
|
<Target>M:Avalonia.Skia.ISkiaGpu.TryGetGrContext</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0006</DiagnosticId> |
||||
|
<Target>M:Avalonia.Skia.ISkiaGpuRenderTarget.BeginRenderingSession(System.Nullable{Avalonia.PixelSize})</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0006</DiagnosticId> |
||||
|
<Target>P:Avalonia.Skia.ISkiaGpu.PlatformGraphicsContext</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0008</DiagnosticId> |
||||
|
<Target>T:Avalonia.Skia.ISkiaGpu</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0008</DiagnosticId> |
||||
|
<Target>T:Avalonia.Skia.ISkiaGpuWithPlatformGraphicsContext</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net10.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0008</DiagnosticId> |
||||
|
<Target>T:Avalonia.Skia.ISkiaGpu</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
<Suppression> |
||||
|
<DiagnosticId>CP0008</DiagnosticId> |
||||
|
<Target>T:Avalonia.Skia.ISkiaGpuWithPlatformGraphicsContext</Target> |
||||
|
<Left>baseline/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Left> |
||||
|
<Right>current/Avalonia.Skia/lib/net8.0/Avalonia.Skia.dll</Right> |
||||
|
</Suppression> |
||||
|
</Suppressions> |
||||
File diff suppressed because it is too large
@ -0,0 +1,45 @@ |
|||||
|
<UserControl xmlns="https://github.com/avaloniaui" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
||||
|
x:Class="ControlCatalog.Pages.BitmapCachePage"> |
||||
|
<DockPanel> |
||||
|
<DockPanel.Resources> |
||||
|
<BitmapCache x:Key="Cache"/> |
||||
|
<ScaleTransform x:Key="Transform" ScaleX="1" ScaleY="{Binding $self.ScaleX, Mode=OneWay}"/> |
||||
|
<TranslateTransform x:Key="SubPixelTransform"/> |
||||
|
</DockPanel.Resources> |
||||
|
<StackPanel DockPanel.Dock="Right" ZIndex="1"> |
||||
|
<TextBlock>Render at scale</TextBlock> |
||||
|
<Slider Minimum="0.1" Maximum="4" Value="{Binding Source={StaticResource Cache}, Path=RenderAtScale, Mode=TwoWay}" Width="200"/> |
||||
|
<TextBlock>Scale</TextBlock> |
||||
|
<Slider Minimum="0.1" Maximum="4" Value="{Binding Source={StaticResource Transform}, Path=ScaleX, Mode=TwoWay}" Width="200"/> |
||||
|
<CheckBox IsChecked="{Binding Source={StaticResource Cache}, Path=EnableClearType, Mode=TwoWay}">Enable clear type</CheckBox> |
||||
|
|
||||
|
<CheckBox IsChecked="{Binding Source={StaticResource Cache}, Path=SnapsToDevicePixels, Mode=TwoWay}">Snap to device pixels</CheckBox> |
||||
|
<TextBlock>Subpixel offset X</TextBlock> |
||||
|
<Slider Minimum="0" Maximum="1" Value="{Binding Source={StaticResource SubPixelTransform}, Path=X, Mode=TwoWay}" Width="200"/> |
||||
|
</StackPanel> |
||||
|
<Decorator RenderTransform="{StaticResource SubPixelTransform}"> |
||||
|
<Border Background="Beige" Margin="10" |
||||
|
RenderTransform="{StaticResource Transform}" |
||||
|
RenderTransformOrigin="0.5,0.5"> |
||||
|
<Border Margin="10" |
||||
|
CacheMode="{StaticResource Cache}" |
||||
|
TextElement.Foreground="Black"> |
||||
|
<Border |
||||
|
Margin="10" |
||||
|
BorderThickness="2" |
||||
|
BorderBrush="Black" |
||||
|
Background="White"> |
||||
|
<StackPanel> |
||||
|
<Slider MinWidth="200"/> |
||||
|
<TextBlock TextWrapping="Wrap">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</TextBlock> |
||||
|
</StackPanel> |
||||
|
</Border> |
||||
|
</Border> |
||||
|
</Border> |
||||
|
</Decorator> |
||||
|
</DockPanel> |
||||
|
</UserControl> |
||||
@ -0,0 +1,13 @@ |
|||||
|
using Avalonia; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace ControlCatalog.Pages; |
||||
|
|
||||
|
public partial class BitmapCachePage : UserControl |
||||
|
{ |
||||
|
public BitmapCachePage() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
} |
||||
|
} |
||||
@ -1,11 +0,0 @@ |
|||||
using System; |
|
||||
using Android.Views; |
|
||||
|
|
||||
namespace Avalonia.Android.Platform.Specific |
|
||||
{ |
|
||||
public interface IAndroidView |
|
||||
{ |
|
||||
[Obsolete("Use TopLevel.TryGetPlatformHandle instead, which can be casted to AndroidViewControlHandle.")] |
|
||||
View View { get; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,17 +0,0 @@ |
|||||
using System; |
|
||||
|
|
||||
namespace Avalonia.Animation.Easings; |
|
||||
|
|
||||
[Obsolete("Use SplineEasing instead")] |
|
||||
public sealed class CubicBezierEasing : IEasing |
|
||||
{ |
|
||||
private CubicBezierEasing() |
|
||||
{ |
|
||||
} |
|
||||
|
|
||||
public Point ControlPoint2 { get; set; } |
|
||||
public Point ControlPoint1 { get; set; } |
|
||||
|
|
||||
double IEasing.Ease(double progress) |
|
||||
=> throw new NotSupportedException(); |
|
||||
} |
|
||||
@ -1,10 +1,24 @@ |
|||||
using System; |
using System.Threading; |
||||
|
|
||||
namespace Avalonia.Controls |
namespace Avalonia.Controls; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents the event arguments of <see cref="IResourceHost.ResourcesChanged"/>.
|
||||
|
/// The <see cref="SequenceNumber"/> identifies the changes.
|
||||
|
/// </summary>
|
||||
|
/// <param name="SequenceNumber">The sequence number used to identify the changes.</param>
|
||||
|
/// <remarks>
|
||||
|
/// For performance reasons, this type is a struct.
|
||||
|
/// Avoid using a default instance of this type or its default constructor, call <see cref="Create"/> instead.
|
||||
|
/// </remarks>
|
||||
|
public readonly record struct ResourcesChangedEventArgs(int SequenceNumber) |
||||
{ |
{ |
||||
// TODO12: change this to be a struct, remove ResourcesChangedToken
|
private static int s_lastSequenceNumber; |
||||
public class ResourcesChangedEventArgs : EventArgs |
|
||||
{ |
/// <summary>
|
||||
public static new readonly ResourcesChangedEventArgs Empty = new ResourcesChangedEventArgs(); |
/// Creates a new instance of <see cref="ResourcesChangedEventArgs"/> with an auto-incremented sequence number.
|
||||
} |
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
public static ResourcesChangedEventArgs Create() |
||||
|
=> new(Interlocked.Increment(ref s_lastSequenceNumber)); |
||||
} |
} |
||||
|
|||||
@ -1,45 +0,0 @@ |
|||||
using System; |
|
||||
using Avalonia.LogicalTree; |
|
||||
|
|
||||
namespace Avalonia.Controls; |
|
||||
|
|
||||
internal static class ResourcesChangedHelper |
|
||||
{ |
|
||||
internal static void NotifyHostedResourcesChanged(this IResourceHost host, ResourcesChangedToken token) |
|
||||
{ |
|
||||
if (host is IResourceHost2 host2) |
|
||||
host2.NotifyHostedResourcesChanged(token); |
|
||||
else |
|
||||
host.NotifyHostedResourcesChanged(ResourcesChangedEventArgs.Empty); |
|
||||
} |
|
||||
|
|
||||
internal static void NotifyResourcesChanged(this ILogical logical, ResourcesChangedToken token) |
|
||||
{ |
|
||||
if (logical is StyledElement styledElement) |
|
||||
styledElement.NotifyResourcesChanged(token); |
|
||||
else |
|
||||
logical.NotifyResourcesChanged(ResourcesChangedEventArgs.Empty); |
|
||||
} |
|
||||
|
|
||||
internal static void SubscribeToResourcesChanged( |
|
||||
this IResourceHost host, |
|
||||
EventHandler<ResourcesChangedEventArgs> handler, |
|
||||
EventHandler<ResourcesChangedToken> handler2) |
|
||||
{ |
|
||||
if (host is IResourceHost2 host2) |
|
||||
host2.ResourcesChanged2 += handler2; |
|
||||
else |
|
||||
host.ResourcesChanged += handler; |
|
||||
} |
|
||||
|
|
||||
internal static void UnsubscribeFromResourcesChanged( |
|
||||
this IResourceHost host, |
|
||||
EventHandler<ResourcesChangedEventArgs> handler, |
|
||||
EventHandler<ResourcesChangedToken> handler2) |
|
||||
{ |
|
||||
if (host is IResourceHost2 host2) |
|
||||
host2.ResourcesChanged2 -= handler2; |
|
||||
else |
|
||||
host.ResourcesChanged -= handler; |
|
||||
} |
|
||||
} |
|
||||
@ -1,11 +0,0 @@ |
|||||
using System.Threading; |
|
||||
|
|
||||
namespace Avalonia.Controls; |
|
||||
|
|
||||
internal record struct ResourcesChangedToken(int SequenceNumber) |
|
||||
{ |
|
||||
private static int s_lastSequenceNumber; |
|
||||
|
|
||||
public static ResourcesChangedToken Create() |
|
||||
=> new(Interlocked.Increment(ref s_lastSequenceNumber)); |
|
||||
} |
|
||||
@ -0,0 +1,20 @@ |
|||||
|
using System; |
||||
|
using System.Reflection; |
||||
|
|
||||
|
namespace Avalonia.Data.Core.Parsers; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Stores reflection members used by <see cref="BindingExpressionVisitor{TIn}"/> outside of the
|
||||
|
/// generic class to avoid duplication for each generic instantiation.
|
||||
|
/// </summary>
|
||||
|
internal static class BindingExpressionVisitorMembers |
||||
|
{ |
||||
|
static BindingExpressionVisitorMembers() |
||||
|
{ |
||||
|
AvaloniaObjectIndexer = typeof(AvaloniaObject).GetProperty(CommonPropertyNames.IndexerName, [typeof(AvaloniaProperty)])!; |
||||
|
CreateDelegateMethod = typeof(MethodInfo).GetMethod(nameof(MethodInfo.CreateDelegate), [typeof(Type), typeof(object)])!; |
||||
|
} |
||||
|
|
||||
|
public static readonly PropertyInfo AvaloniaObjectIndexer; |
||||
|
public static readonly MethodInfo CreateDelegateMethod; |
||||
|
} |
||||
@ -1,12 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Text; |
|
||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace Avalonia.Diagnostics; |
|
||||
|
|
||||
internal static class ObsoletionMessages |
|
||||
{ |
|
||||
public const string MayBeRemovedInAvalonia12 = "This API may be removed in Avalonia 12. If you depend on this API, please open an issue with details of your use-case."; |
|
||||
} |
|
||||
@ -1,37 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using Avalonia.Metadata; |
|
||||
using Avalonia.Styling; |
|
||||
|
|
||||
namespace Avalonia.Diagnostics; |
|
||||
|
|
||||
[PrivateApi] |
|
||||
[Unstable("Use StyledElementExtensions.GetValueStoreDiagnostic() instead")] |
|
||||
public class StyleDiagnostics |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Currently applied styles.
|
|
||||
/// </summary>
|
|
||||
public IReadOnlyList<AppliedStyle> AppliedStyles { get; } |
|
||||
|
|
||||
public StyleDiagnostics(IReadOnlyList<AppliedStyle> appliedStyles) |
|
||||
{ |
|
||||
AppliedStyles = appliedStyles; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
[PrivateApi] |
|
||||
[Unstable("Use StyledElementExtensions.GetValueStoreDiagnostic() instead")] |
|
||||
public sealed class AppliedStyle |
|
||||
{ |
|
||||
private readonly StyleInstance _instance; |
|
||||
|
|
||||
internal AppliedStyle(StyleInstance instance) |
|
||||
{ |
|
||||
_instance = instance; |
|
||||
} |
|
||||
|
|
||||
public bool HasActivator => _instance.HasActivator; |
|
||||
public bool IsActive => _instance.IsActive(); |
|
||||
public StyleBase Style => (StyleBase)_instance.Source; |
|
||||
} |
|
||||
@ -1,24 +0,0 @@ |
|||||
using System; |
|
||||
using System.Linq; |
|
||||
using Avalonia.Metadata; |
|
||||
using Avalonia.Styling; |
|
||||
|
|
||||
namespace Avalonia.Diagnostics; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Defines diagnostic extensions on <see cref="StyledElement"/>s.
|
|
||||
/// </summary>
|
|
||||
[PrivateApi] |
|
||||
public static class StyledElementExtensions |
|
||||
{ |
|
||||
[Obsolete("Use AvaloniaObjectExtensions.GetValueStoreDiagnostic instead", true)] |
|
||||
public static StyleDiagnostics GetStyleDiagnostics(this StyledElement styledElement) |
|
||||
{ |
|
||||
var diagnostics = styledElement.GetValueStore().GetStoreDiagnostic(); |
|
||||
return new StyleDiagnostics(diagnostics.AppliedFrames |
|
||||
.OfType<StyleValueFrameDiagnostic>() |
|
||||
.Select(f => f.AsAppliedStyle()) |
|
||||
.ToArray()); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@ -1,8 +1,7 @@ |
|||||
using System; |
using System; |
||||
using System.Diagnostics.CodeAnalysis; |
using System.Diagnostics.CodeAnalysis; |
||||
|
|
||||
// TODO12: move to Avalonia namespace.
|
namespace Avalonia; |
||||
namespace Avalonia.Platform; |
|
||||
|
|
||||
public interface IOptionalFeatureProvider |
public interface IOptionalFeatureProvider |
||||
{ |
{ |
||||
@ -1,56 +1,11 @@ |
|||||
using System; |
using System; |
||||
using System.ComponentModel; |
|
||||
using Avalonia.Input.Platform; |
|
||||
|
|
||||
namespace Avalonia.Input |
namespace Avalonia.Input; |
||||
{ |
|
||||
public static class DataFormats |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Dataformat for plaintext
|
|
||||
/// </summary>
|
|
||||
[Obsolete($"Use {nameof(DataFormat)}.{nameof(DataFormat.Text)} instead.")] |
|
||||
public static readonly string Text = nameof(Text); |
|
||||
|
|
||||
/// <summary>
|
// TODO13: remove
|
||||
/// Dataformat for one or more files.
|
/// <summary>
|
||||
/// </summary>
|
/// This class does not do anything anymore.
|
||||
[Obsolete($"Use {nameof(DataFormat)}.{nameof(DataFormat.File)} instead.")] |
/// Use <see cref="DataFormat"/> instead.
|
||||
public static readonly string Files = nameof(Files); |
/// </summary>
|
||||
|
[Obsolete($"Use {nameof(DataFormat)} instead", true)] |
||||
/// <summary>
|
public static class DataFormats; |
||||
/// Dataformat for one or more filenames
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// This data format is supported only on desktop platforms.
|
|
||||
/// </remarks>
|
|
||||
[Obsolete($"Use {nameof(DataFormat)}.{nameof(DataFormat.File)} instead."), EditorBrowsable(EditorBrowsableState.Never)] |
|
||||
public static readonly string FileNames = nameof(FileNames); |
|
||||
|
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
|
||||
|
|
||||
internal static DataFormat ToDataFormat(string format) |
|
||||
{ |
|
||||
if (format == Text) |
|
||||
return DataFormat.Text; |
|
||||
|
|
||||
if (format == Files || format == FileNames) |
|
||||
return DataFormat.File; |
|
||||
|
|
||||
return DataFormat.CreateBytesPlatformFormat(format); |
|
||||
} |
|
||||
|
|
||||
internal static string ToString(DataFormat format) |
|
||||
{ |
|
||||
if (DataFormat.Text.Equals(format)) |
|
||||
return Text; |
|
||||
|
|
||||
if (DataFormat.File.Equals(format)) |
|
||||
return Files; |
|
||||
|
|
||||
return format.Identifier; |
|
||||
} |
|
||||
|
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
|
||||
} |
|
||||
} |
|
||||
|
|||||
@ -1,40 +1,11 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Generic; |
|
||||
|
|
||||
namespace Avalonia.Input |
namespace Avalonia.Input; |
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Specific and mutable implementation of the IDataObject interface.
|
|
||||
/// </summary>
|
|
||||
[Obsolete($"Use {nameof(DataTransfer)} instead")] |
|
||||
public class DataObject : IDataObject |
|
||||
{ |
|
||||
private readonly Dictionary<string, object> _items = new(); |
|
||||
|
|
||||
/// <inheritdoc />
|
// TODO13: remove
|
||||
public bool Contains(string dataFormat) |
/// <summary>
|
||||
{ |
/// This class does not do anything anymore.
|
||||
return _items.ContainsKey(dataFormat); |
/// Use <see cref="DataTransfer"/> instead.
|
||||
} |
/// </summary>
|
||||
|
[Obsolete($"Use {nameof(DataTransfer)} instead", true)] |
||||
/// <inheritdoc />
|
public sealed class DataObject; |
||||
public object? Get(string dataFormat) |
|
||||
{ |
|
||||
return _items.TryGetValue(dataFormat, out var item) ? item : null; |
|
||||
} |
|
||||
|
|
||||
/// <inheritdoc />
|
|
||||
public IEnumerable<string> GetDataFormats() |
|
||||
{ |
|
||||
return _items.Keys; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Sets a value to the internal store of the data object with <see cref="DataFormats"/> as a key.
|
|
||||
/// </summary>
|
|
||||
public void Set(string dataFormat, object value) |
|
||||
{ |
|
||||
_items[dataFormat] = value; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|||||
@ -1,54 +0,0 @@ |
|||||
using System.Collections.Generic; |
|
||||
using System.ComponentModel; |
|
||||
using System.Linq; |
|
||||
using Avalonia.Platform.Storage; |
|
||||
|
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
|
||||
|
|
||||
namespace Avalonia.Input |
|
||||
{ |
|
||||
// TODO12: remove
|
|
||||
public static class DataObjectExtensions |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Returns a list of files if the DataObject contains files or filenames.
|
|
||||
/// <seealso cref="DataFormats.Files"/>.
|
|
||||
/// </summary>
|
|
||||
/// <returns>
|
|
||||
/// Collection of storage items - files or folders. If format isn't available, returns null.
|
|
||||
/// </returns>
|
|
||||
public static IEnumerable<IStorageItem>? GetFiles(this IDataObject dataObject) |
|
||||
{ |
|
||||
return dataObject.Get(DataFormats.Files) as IEnumerable<IStorageItem>; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Returns a list of filenames if the DataObject contains filenames.
|
|
||||
/// <seealso cref="DataFormats.FileNames"/>
|
|
||||
/// </summary>
|
|
||||
/// <returns>
|
|
||||
/// Collection of file names. If format isn't available, returns null.
|
|
||||
/// </returns>
|
|
||||
[System.Obsolete("Use GetFiles, this method is supported only on desktop platforms."), EditorBrowsable(EditorBrowsableState.Never)] |
|
||||
public static IEnumerable<string>? GetFileNames(this IDataObject dataObject) |
|
||||
{ |
|
||||
return (dataObject.Get(DataFormats.FileNames) as IEnumerable<string>) |
|
||||
?? dataObject.GetFiles()? |
|
||||
.Select(f => f.TryGetLocalPath()) |
|
||||
.Where(p => !string.IsNullOrEmpty(p)) |
|
||||
.OfType<string>(); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Returns the dragged text if the DataObject contains any text.
|
|
||||
/// <seealso cref="DataFormats.Text"/>
|
|
||||
/// </summary>
|
|
||||
/// <returns>
|
|
||||
/// A text string. If format isn't available, returns null.
|
|
||||
/// </returns>
|
|
||||
public static string? GetText(this IDataObject dataObject) |
|
||||
{ |
|
||||
return dataObject.Get(DataFormats.Text) as string; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,32 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
|
|
||||
namespace Avalonia.Input |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Interface to access information about the data of a drag-and-drop operation.
|
|
||||
/// </summary>
|
|
||||
[Obsolete($"Use {nameof(IDataTransfer)} or {nameof(IAsyncDataTransfer)} instead")] |
|
||||
public interface IDataObject |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Lists all formats which are present in the DataObject.
|
|
||||
/// <seealso cref="DataFormats"/>
|
|
||||
/// </summary>
|
|
||||
IEnumerable<string> GetDataFormats(); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Checks whether a given DataFormat is present in this object
|
|
||||
/// <seealso cref="DataFormats"/>
|
|
||||
/// </summary>
|
|
||||
bool Contains(string dataFormat); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Tries to get the data of the given DataFormat.
|
|
||||
/// </summary>
|
|
||||
/// <returns>
|
|
||||
/// Object data. If format isn't available, returns null.
|
|
||||
/// </returns>
|
|
||||
object? Get(string dataFormat); |
|
||||
} |
|
||||
} |
|
||||
@ -1,76 +0,0 @@ |
|||||
using System; |
|
||||
using System.Diagnostics; |
|
||||
using System.IO; |
|
||||
using System.Text; |
|
||||
using Avalonia.Compatibility; |
|
||||
|
|
||||
namespace Avalonia.Input.Platform; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Wraps a legacy <see cref="IDataObject"/> into a <see cref="IDataTransferItem"/>.
|
|
||||
/// </summary>
|
|
||||
[Obsolete] |
|
||||
internal sealed class DataObjectToDataTransferItemWrapper( |
|
||||
IDataObject dataObject, |
|
||||
DataFormat[] formats, |
|
||||
string[] formatStrings) |
|
||||
: PlatformDataTransferItem |
|
||||
{ |
|
||||
private readonly IDataObject _dataObject = dataObject; |
|
||||
private readonly DataFormat[] _formats = formats; |
|
||||
private readonly string[] _formatStrings = formatStrings; |
|
||||
|
|
||||
protected override DataFormat[] ProvideFormats() |
|
||||
=> _formats; |
|
||||
|
|
||||
protected override object? TryGetRawCore(DataFormat format) |
|
||||
{ |
|
||||
var index = Array.IndexOf(Formats, format); |
|
||||
if (index < 0) |
|
||||
return null; |
|
||||
|
|
||||
// We should never have DataFormat.File here, it's been handled by DataObjectToDataTransferWrapper.
|
|
||||
Debug.Assert(!DataFormat.File.Equals(format)); |
|
||||
|
|
||||
var formatString = _formatStrings[index]; |
|
||||
var data = _dataObject.Get(formatString); |
|
||||
|
|
||||
if (DataFormat.Text.Equals(format)) |
|
||||
return Convert.ToString(data) ?? string.Empty; |
|
||||
|
|
||||
if (format is DataFormat<string>) |
|
||||
return Convert.ToString(data); |
|
||||
|
|
||||
if (format is DataFormat<byte[]>) |
|
||||
return ConvertLegacyDataToBytes(format, data); |
|
||||
|
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
private static byte[]? ConvertLegacyDataToBytes(DataFormat format, object? data) |
|
||||
{ |
|
||||
switch (data) |
|
||||
{ |
|
||||
case null: |
|
||||
return null; |
|
||||
|
|
||||
case byte[] bytes: |
|
||||
return bytes; |
|
||||
|
|
||||
case string str: |
|
||||
return OperatingSystemEx.IsWindows() || OperatingSystemEx.IsMacOS() || OperatingSystemEx.IsIOS() ? |
|
||||
Encoding.Unicode.GetBytes(str) : |
|
||||
Encoding.UTF8.GetBytes(str); |
|
||||
|
|
||||
case Stream stream: |
|
||||
var length = (int)(stream.Length - stream.Position); |
|
||||
var buffer = new byte[length]; |
|
||||
|
|
||||
stream.ReadExactly(buffer, 0, length); |
|
||||
return buffer; |
|
||||
|
|
||||
default: |
|
||||
return null; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,95 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Diagnostics; |
|
||||
using System.Diagnostics.CodeAnalysis; |
|
||||
using System.Linq; |
|
||||
using Avalonia.Platform.Storage; |
|
||||
using Avalonia.Platform.Storage.FileIO; |
|
||||
|
|
||||
namespace Avalonia.Input.Platform; |
|
||||
|
|
||||
#pragma warning disable CS0618 // Type or member is obsolete: usages of IDataObject and DataFormats
|
|
||||
|
|
||||
// TODO12: remove
|
|
||||
/// <summary>
|
|
||||
/// Wraps a legacy <see cref="IDataObject"/> into a <see cref="IDataTransfer"/>.
|
|
||||
/// </summary>
|
|
||||
[Obsolete] |
|
||||
internal sealed class DataObjectToDataTransferWrapper(IDataObject dataObject) |
|
||||
: PlatformDataTransfer |
|
||||
{ |
|
||||
public IDataObject DataObject { get; } = dataObject; |
|
||||
|
|
||||
protected override DataFormat[] ProvideFormats() |
|
||||
=> DataObject.GetDataFormats().Select(DataFormats.ToDataFormat).Distinct().ToArray(); |
|
||||
|
|
||||
protected override PlatformDataTransferItem[] ProvideItems() |
|
||||
{ |
|
||||
var items = new List<PlatformDataTransferItem>(); |
|
||||
var nonFileFormats = new List<DataFormat>(); |
|
||||
var nonFileFormatStrings = new List<string>(); |
|
||||
var hasFiles = false; |
|
||||
|
|
||||
foreach (var formatString in DataObject.GetDataFormats()) |
|
||||
{ |
|
||||
var format = DataFormats.ToDataFormat(formatString); |
|
||||
|
|
||||
if (formatString == DataFormats.Files) |
|
||||
{ |
|
||||
if (hasFiles) |
|
||||
continue; |
|
||||
|
|
||||
// This is not ideal as we're reading the filenames ahead of time to generate the appropriate items.
|
|
||||
// We don't really care about that for this legacy wrapper.
|
|
||||
if (DataObject.Get(formatString) is IEnumerable<IStorageItem> storageItems) |
|
||||
{ |
|
||||
hasFiles = true; |
|
||||
|
|
||||
foreach (var storageItem in storageItems) |
|
||||
items.Add(PlatformDataTransferItem.Create(DataFormat.File, storageItem)); |
|
||||
} |
|
||||
} |
|
||||
else if (formatString == DataFormats.FileNames) |
|
||||
{ |
|
||||
if (hasFiles) |
|
||||
continue; |
|
||||
|
|
||||
if (DataObject.Get(formatString) is IEnumerable<string> fileNames) |
|
||||
{ |
|
||||
hasFiles = true; |
|
||||
|
|
||||
foreach (var fileName in fileNames) |
|
||||
{ |
|
||||
if (StorageProviderHelpers.TryCreateBclStorageItem(fileName) is { } storageItem) |
|
||||
items.Add(PlatformDataTransferItem.Create(DataFormat.File, storageItem)); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
nonFileFormats.Add(format); |
|
||||
nonFileFormatStrings.Add(formatString); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (nonFileFormats.Count > 0) |
|
||||
{ |
|
||||
Debug.Assert(nonFileFormats.Count == nonFileFormatStrings.Count); |
|
||||
|
|
||||
// Single item containing all formats except for DataFormat.File.
|
|
||||
items.Add(new DataObjectToDataTransferItemWrapper( |
|
||||
DataObject, |
|
||||
nonFileFormats.ToArray(), |
|
||||
nonFileFormatStrings.ToArray())); |
|
||||
} |
|
||||
|
|
||||
return items.ToArray(); |
|
||||
} |
|
||||
|
|
||||
[SuppressMessage( |
|
||||
"ReSharper", |
|
||||
"SuspiciousTypeConversion.Global", |
|
||||
Justification = "IDisposable may be implemented externally by the IDataObject instance.")] |
|
||||
public override void Dispose() |
|
||||
=> (DataObject as IDisposable)?.Dispose(); |
|
||||
} |
|
||||
@ -1,42 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using Avalonia.Platform.Storage; |
|
||||
|
|
||||
namespace Avalonia.Input.Platform; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Wraps a <see cref="IDataTransfer"/> into a legacy <see cref="IDataObject"/>.
|
|
||||
/// </summary>
|
|
||||
[Obsolete] |
|
||||
internal sealed class DataTransferToDataObjectWrapper(IDataTransfer dataTransfer) : IDataObject |
|
||||
{ |
|
||||
public IDataTransfer DataTransfer { get; } = dataTransfer; |
|
||||
|
|
||||
public IEnumerable<string> GetDataFormats() |
|
||||
=> DataTransfer.Formats.Select(DataFormats.ToString); |
|
||||
|
|
||||
public bool Contains(string dataFormat) |
|
||||
=> DataTransfer.Contains(DataFormats.ToDataFormat(dataFormat)); |
|
||||
|
|
||||
public object? Get(string dataFormat) |
|
||||
{ |
|
||||
if (dataFormat == DataFormats.Text) |
|
||||
return DataTransfer.TryGetText(); |
|
||||
|
|
||||
if (dataFormat == DataFormats.Files) |
|
||||
return DataTransfer.TryGetFiles(); |
|
||||
|
|
||||
if (dataFormat == DataFormats.FileNames) |
|
||||
{ |
|
||||
return DataTransfer |
|
||||
.TryGetFiles() |
|
||||
?.Select(file => file.TryGetLocalPath()) |
|
||||
.Where(path => path is not null) |
|
||||
.ToArray(); |
|
||||
} |
|
||||
|
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -0,0 +1,114 @@ |
|||||
|
using Avalonia.Rendering.Composition; |
||||
|
using Avalonia.Rendering.Composition.Server; |
||||
|
|
||||
|
namespace Avalonia.Media; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents the behavior of caching a visual element or tree of elements as bitmap surfaces.
|
||||
|
/// </summary>
|
||||
|
public class BitmapCache : CacheMode |
||||
|
{ |
||||
|
private CompositionBitmapCache? _current; |
||||
|
|
||||
|
public static readonly StyledProperty<double> RenderAtScaleProperty = AvaloniaProperty.Register<BitmapCache, double>( |
||||
|
nameof(RenderAtScale), 1); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Use the RenderAtScale property to render the BitmapCache at a multiple of the normal bitmap size.
|
||||
|
/// The normal size is determined by the local size of the element.
|
||||
|
///
|
||||
|
/// Values greater than 1 increase the resolution of the bitmap relative to the native resolution of the element,
|
||||
|
/// and values less than 1 decrease the resolution.
|
||||
|
/// For example, if the RenderAtScale property is set to 2.0, and you apply a scale transform that
|
||||
|
/// enlarges the content by a factor of 2, the content will have the same visual quality as the same content
|
||||
|
/// with RenderAtScale set to 1.0 and a transform scale of 1.
|
||||
|
///
|
||||
|
/// When RenderAtScale is set to 0, no bitmap is rendered. Negative values are clamped to 0.
|
||||
|
///
|
||||
|
/// If you change this value, the cache is regenerated at the appropriate new resolution.
|
||||
|
/// </summary>
|
||||
|
public double RenderAtScale |
||||
|
{ |
||||
|
get => GetValue(RenderAtScaleProperty); |
||||
|
set => SetValue(RenderAtScaleProperty, value); |
||||
|
} |
||||
|
|
||||
|
public static readonly StyledProperty<bool> SnapsToDevicePixelsProperty = AvaloniaProperty.Register<BitmapCache, bool>( |
||||
|
nameof(SnapsToDevicePixels)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Set the SnapsToDevicePixels property when the cache displays content that requires pixel-alignment to render correctly.
|
||||
|
/// This is the case for text with subpixel antialiasing. If you set the EnableClearType property to true,
|
||||
|
/// consider setting SnapsToDevicePixels to true to ensure proper rendering.
|
||||
|
///
|
||||
|
/// When the SnapsToDevicePixels property is set to false,
|
||||
|
/// you can move and scale the cached element by a fraction of a pixel.
|
||||
|
///
|
||||
|
/// When the SnapsToDevicePixels property is set to true,
|
||||
|
/// the bitmap cache is aligned with pixel boundaries of the destination.
|
||||
|
/// If you move or scale the cached element by a fraction of a pixel,
|
||||
|
/// the bitmap snaps to the pixel grid
|
||||
|
/// . In this case, the top-left corner of the bitmap is rounded up and snapped to the pixel grid,
|
||||
|
/// but the bottom-right corner is on a fractional pixel boundary.
|
||||
|
/// </summary>
|
||||
|
public bool SnapsToDevicePixels |
||||
|
{ |
||||
|
get => GetValue(SnapsToDevicePixelsProperty); |
||||
|
set => SetValue(SnapsToDevicePixelsProperty, value); |
||||
|
} |
||||
|
|
||||
|
public static readonly StyledProperty<bool> EnableClearTypeProperty = AvaloniaProperty.Register<BitmapCache, bool>( |
||||
|
nameof(EnableClearType)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Set the EnableClearType property to allow subpixel text to be rendered in the cache.
|
||||
|
/// When the EnableClearType property is true, your application MUST render all
|
||||
|
/// of its subpixel text on an opaque background.
|
||||
|
///
|
||||
|
/// When the EnableClearType property is false, text in the cache is rendered with grayscale antialiasing.
|
||||
|
///
|
||||
|
/// ClearType text requires correct pixel alignment of rendered characters,
|
||||
|
/// so you should set the SnapsToDevicePixels property to true.
|
||||
|
/// If you do not set this property, the content may not blend correctly.
|
||||
|
///
|
||||
|
/// Use the EnableClearType property when you know the cache is rendered on pixel boundaries,
|
||||
|
/// so it is safe to cache ClearType text. This situation occurs commonly in text-scrolling scenarios.
|
||||
|
/// </summary>
|
||||
|
public bool EnableClearType |
||||
|
{ |
||||
|
get => GetValue(EnableClearTypeProperty); |
||||
|
set => SetValue(EnableClearTypeProperty, value); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) |
||||
|
{ |
||||
|
if (change.IsEffectiveValueChange && _current != null) |
||||
|
{ |
||||
|
if (change.Property == RenderAtScaleProperty) |
||||
|
_current.RenderAtScale = RenderAtScale; |
||||
|
else if (change.Property == SnapsToDevicePixelsProperty) |
||||
|
_current.SnapsToDevicePixels = SnapsToDevicePixels; |
||||
|
else if (change.Property == EnableClearTypeProperty) |
||||
|
_current.EnableClearType = EnableClearType; |
||||
|
} |
||||
|
|
||||
|
base.OnPropertyChanged(change); |
||||
|
} |
||||
|
|
||||
|
// We currently only allow visual to be attached to one compositor at a time, so keep it simple for now
|
||||
|
internal override CompositionCacheMode GetForCompositor(Compositor c) |
||||
|
{ |
||||
|
// TODO: Make it to be a multi-compositor resource once we support visuals being attached to multiple
|
||||
|
// compositor instances (e. g. referenced via visual brush from a different WASM toplevel).
|
||||
|
if(_current?.Compositor != c) |
||||
|
{ |
||||
|
_current = new CompositionBitmapCache(c, new ServerCompositionBitmapCache(c.Server)); |
||||
|
_current.EnableClearType = EnableClearType; |
||||
|
_current.RenderAtScale = RenderAtScale; |
||||
|
_current.SnapsToDevicePixels = SnapsToDevicePixels; |
||||
|
} |
||||
|
|
||||
|
return _current; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
using System; |
||||
|
using Avalonia.Rendering.Composition; |
||||
|
using Avalonia.Rendering.Composition.Drawing; |
||||
|
|
||||
|
namespace Avalonia.Media; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents cached content modes for graphics acceleration features.
|
||||
|
/// </summary>
|
||||
|
public abstract class CacheMode : StyledElement |
||||
|
{ |
||||
|
// We currently only allow visual to be attached to one compositor at a time, so keep it simple for now
|
||||
|
internal abstract CompositionCacheMode GetForCompositor(Compositor c); |
||||
|
|
||||
|
public static CacheMode Parse(string s) |
||||
|
{ |
||||
|
if(s == "BitmapCache") |
||||
|
return new BitmapCache(); |
||||
|
throw new ArgumentException("Unknown CacheMode: " + s); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Avalonia.Metadata; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Indicates that a property corresponds to a named parameter in the constructor.
|
||||
|
/// </summary>
|
||||
|
/// <param name="name">The name of the parameter in the constructor.</param>
|
||||
|
/// <remarks>This attribute is used for XAML.</remarks>
|
||||
|
[AttributeUsage(AttributeTargets.Property)] |
||||
|
public sealed class ConstructorArgumentAttribute(string name) : Attribute |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets the name of the parameter in the constructor.
|
||||
|
/// </summary>
|
||||
|
public string Name { get; } = name; |
||||
|
} |
||||
@ -0,0 +1,6 @@ |
|||||
|
namespace Avalonia.Platform; |
||||
|
|
||||
|
internal interface ISurfaceOrientation |
||||
|
{ |
||||
|
SurfaceOrientation Orientation { get; } |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
namespace Avalonia.Platform; |
||||
|
|
||||
|
public enum SurfaceOrientation |
||||
|
{ |
||||
|
Rotation0, |
||||
|
Rotation90, |
||||
|
Rotation180, |
||||
|
Rotation270, |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue