committed by
GitHub
310 changed files with 9763 additions and 5281 deletions
@ -0,0 +1,148 @@ |
|||
{ |
|||
"$schema": "http://json-schema.org/draft-04/schema#", |
|||
"title": "Build Schema", |
|||
"$ref": "#/definitions/build", |
|||
"definitions": { |
|||
"build": { |
|||
"type": "object", |
|||
"properties": { |
|||
"Configuration": { |
|||
"type": "string", |
|||
"description": "configuration" |
|||
}, |
|||
"Continue": { |
|||
"type": "boolean", |
|||
"description": "Indicates to continue a previously failed build attempt" |
|||
}, |
|||
"ForceNugetVersion": { |
|||
"type": "string", |
|||
"description": "force-nuget-version" |
|||
}, |
|||
"Help": { |
|||
"type": "boolean", |
|||
"description": "Shows the help text for this build assembly" |
|||
}, |
|||
"Host": { |
|||
"type": "string", |
|||
"description": "Host for execution. Default is 'automatic'", |
|||
"enum": [ |
|||
"AppVeyor", |
|||
"AzurePipelines", |
|||
"Bamboo", |
|||
"Bitbucket", |
|||
"Bitrise", |
|||
"GitHubActions", |
|||
"GitLab", |
|||
"Jenkins", |
|||
"Rider", |
|||
"SpaceAutomation", |
|||
"TeamCity", |
|||
"Terminal", |
|||
"TravisCI", |
|||
"VisualStudio", |
|||
"VSCode" |
|||
] |
|||
}, |
|||
"NoLogo": { |
|||
"type": "boolean", |
|||
"description": "Disables displaying the NUKE logo" |
|||
}, |
|||
"Partition": { |
|||
"type": "string", |
|||
"description": "Partition to use on CI" |
|||
}, |
|||
"Plan": { |
|||
"type": "boolean", |
|||
"description": "Shows the execution plan (HTML)" |
|||
}, |
|||
"Profile": { |
|||
"type": "array", |
|||
"description": "Defines the profiles to load", |
|||
"items": { |
|||
"type": "string" |
|||
} |
|||
}, |
|||
"Root": { |
|||
"type": "string", |
|||
"description": "Root directory during build execution" |
|||
}, |
|||
"Skip": { |
|||
"type": "array", |
|||
"description": "List of targets to be skipped. Empty list skips all dependencies", |
|||
"items": { |
|||
"type": "string", |
|||
"enum": [ |
|||
"CiAzureLinux", |
|||
"CiAzureOSX", |
|||
"CiAzureWindows", |
|||
"Clean", |
|||
"Compile", |
|||
"CompileHtmlPreviewer", |
|||
"CompileNative", |
|||
"CreateIntermediateNugetPackages", |
|||
"CreateNugetPackages", |
|||
"GenerateCppHeaders", |
|||
"Package", |
|||
"RunCoreLibsTests", |
|||
"RunDesignerTests", |
|||
"RunHtmlPreviewerTests", |
|||
"RunLeakTests", |
|||
"RunRenderTests", |
|||
"RunTests", |
|||
"ZipFiles" |
|||
] |
|||
} |
|||
}, |
|||
"SkipPreviewer": { |
|||
"type": "boolean", |
|||
"description": "skip-previewer" |
|||
}, |
|||
"SkipTests": { |
|||
"type": "boolean", |
|||
"description": "skip-tests" |
|||
}, |
|||
"Solution": { |
|||
"type": "string", |
|||
"description": "Path to a solution file that is automatically loaded. Default is Avalonia.sln" |
|||
}, |
|||
"Target": { |
|||
"type": "array", |
|||
"description": "List of targets to be invoked. Default is '{default_target}'", |
|||
"items": { |
|||
"type": "string", |
|||
"enum": [ |
|||
"CiAzureLinux", |
|||
"CiAzureOSX", |
|||
"CiAzureWindows", |
|||
"Clean", |
|||
"Compile", |
|||
"CompileHtmlPreviewer", |
|||
"CompileNative", |
|||
"CreateIntermediateNugetPackages", |
|||
"CreateNugetPackages", |
|||
"GenerateCppHeaders", |
|||
"Package", |
|||
"RunCoreLibsTests", |
|||
"RunDesignerTests", |
|||
"RunHtmlPreviewerTests", |
|||
"RunLeakTests", |
|||
"RunRenderTests", |
|||
"RunTests", |
|||
"ZipFiles" |
|||
] |
|||
} |
|||
}, |
|||
"Verbosity": { |
|||
"type": "string", |
|||
"description": "Logging verbosity during build execution. Default is 'Normal'", |
|||
"enum": [ |
|||
"Minimal", |
|||
"Normal", |
|||
"Quiet", |
|||
"Verbose" |
|||
] |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
{ |
|||
"$schema": "./build.schema.json", |
|||
"Solution": "" |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
:; set -eo pipefail |
|||
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) |
|||
:; ${SCRIPT_DIR}/build.sh "$@" |
|||
:; exit $? |
|||
|
|||
@ECHO OFF |
|||
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %* |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<EnableNETAnalyzers>true</EnableNETAnalyzers> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -1,14 +0,0 @@ |
|||
using System.IO; |
|||
using MicroCom.CodeGenerator; |
|||
using Nuke.Common; |
|||
|
|||
partial class Build : NukeBuild |
|||
{ |
|||
Target GenerateCppHeaders => _ => _.Executes(() => |
|||
{ |
|||
var file = MicroComCodeGenerator.Parse( |
|||
File.ReadAllText(RootDirectory / "src" / "Avalonia.Native" / "avn.idl")); |
|||
File.WriteAllText(RootDirectory / "native" / "Avalonia.Native" / "inc" / "avalonia-native.h", |
|||
file.GenerateCppHeader()); |
|||
}); |
|||
} |
|||
@ -1,41 +1,48 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> |
|||
<RootNamespace></RootNamespace> |
|||
<IsPackable>False</IsPackable> |
|||
<NoWarn>CS0649;CS0169</NoWarn> |
|||
<NoWarn>CS0649;CS0169;SYSLIB0011</NoWarn> |
|||
<NukeTelemetryVersion>1</NukeTelemetryVersion> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<Import Project="..\build\JetBrains.dotMemoryUnit.props" /> |
|||
<ItemGroup> |
|||
<PackageReference Include="Nuke.Common" Version="5.0.0" /> |
|||
<PackageReference Include="xunit.runner.console" Version="2.3.1" /> |
|||
<PackageReference Include="Nuke.Common" Version="6.2.1" /> |
|||
<PackageReference Include="vswhere" Version="2.6.7" Condition=" '$(OS)' == 'Windows_NT' " /> |
|||
<PackageReference Include="ILRepack.NETStandard" Version="2.0.4" /> |
|||
<PackageReference Include="MicroCom.CodeGenerator" Version="0.10.4" /> |
|||
<!-- Keep in sync with Avalonia.Build.Tasks --> |
|||
<PackageReference Include="Mono.Cecil" Version="0.11.2" /> |
|||
<PackageReference Include="Mono.Cecil" Version="0.11.4" /> |
|||
<PackageReference Include="SourceLink" Version="1.1.0" GeneratePathProperty="true" /> |
|||
<PackageReference Include="Microsoft.Build.Framework" Version="17.3.1" PrivateAssets="All" /> |
|||
<PackageReference Include="xunit.runner.console" Version="2.4.2"> |
|||
<PrivateAssets>all</PrivateAssets> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|||
</PackageReference> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<NukeMetadata Include="**\*.json" Exclude="bin\**;obj\**" /> |
|||
<NukeExternalFiles Include="**\*.*.ext" Exclude="bin\**;obj\**" /> |
|||
<None Remove="*.csproj.DotSettings;*.ref.*.txt" /> |
|||
|
|||
<!-- Common build related files --> |
|||
<None Include="..\build.ps1" /> |
|||
<None Include="..\build.sh" /> |
|||
<None Include="..\.nuke" /> |
|||
<None Include="..\global.json" Condition="Exists('..\global.json')" /> |
|||
<None Include="..\nuget.config" Condition="Exists('..\nuget.config')" /> |
|||
<None Include="..\Jenkinsfile" Condition="Exists('..\Jenkinsfile')" /> |
|||
<None Include="..\appveyor.yml" Condition="Exists('..\appveyor.yml')" /> |
|||
<None Include="..\.travis.yml" Condition="Exists('..\.travis.yml')" /> |
|||
<None Include="..\GitVersion.yml" Condition="Exists('..\GitVersion.yml')" /> |
|||
<Compile Remove="Numerge/**/*.*" /> |
|||
<Compile Include="Numerge/Numerge/**/*.cs" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<EmbeddedResource Include="$(NuGetPackageRoot)sourcelink/1.1.0/tools/pdbstr.exe"></EmbeddedResource> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="il-repack\ILRepack\Application.cs" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Folder Include="Numerge\Numerge.Console\" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
|
|||
@ -0,0 +1,17 @@ |
|||
using Avalonia; |
|||
using Avalonia.Web.Blazor; |
|||
|
|||
namespace ControlCatalog.Blazor.Web; |
|||
|
|||
public partial class App |
|||
{ |
|||
protected override void OnParametersSet() |
|||
{ |
|||
AppBuilder.Configure<ControlCatalog.App>() |
|||
.UseBlazor() |
|||
// .With(new SkiaOptions { CustomGpuFactory = null }) // uncomment to disable GPU/GL rendering
|
|||
.SetupWithSingleViewLifetime(); |
|||
|
|||
base.OnParametersSet(); |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> |
|||
<PropertyGroup> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier> |
|||
<Nullable>enable</Nullable> |
|||
<EmccTotalMemory>16777216</EmccTotalMemory> |
|||
<BlazorEnableTimeZoneSupport>false</BlazorEnableTimeZoneSupport> |
|||
<BlazorWebAssemblyPreserveCollationData>false</BlazorWebAssemblyPreserveCollationData> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0-rc.1.22427.2" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0-rc.1.22427.2" PrivateAssets="all" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Skia\Avalonia.Skia\Avalonia.Skia.csproj" /> |
|||
<ProjectReference Include="..\..\src\Web\Avalonia.Web.Blazor\Avalonia.Web.Blazor.csproj" /> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<Import Project="..\..\build\ReferenceCoreLibraries.props" /> |
|||
<Import Project="..\..\build\BuildTargets.targets" /> |
|||
|
|||
<Import Project="..\..\src\Web\Avalonia.Web\Avalonia.Web.props" /> |
|||
<Import Project="..\..\src\Web\Avalonia.Web\Avalonia.Web.targets" /> |
|||
|
|||
</Project> |
|||
|
|||
@ -0,0 +1,29 @@ |
|||
using System; |
|||
using System.Net.Http; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using ControlCatalog.Blazor.Web; |
|||
|
|||
public class Program |
|||
{ |
|||
public static async Task Main(string[] args) |
|||
{ |
|||
await CreateHostBuilder(args).Build().RunAsync(); |
|||
} |
|||
|
|||
public static WebAssemblyHostBuilder CreateHostBuilder(string[] args) |
|||
{ |
|||
var builder = WebAssemblyHostBuilder.CreateDefault(args); |
|||
|
|||
builder.RootComponents.Add<App>("#app"); |
|||
|
|||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
|||
|
|||
return builder; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
@ -1,20 +0,0 @@ |
|||
using Avalonia; |
|||
using Avalonia.Web.Blazor; |
|||
|
|||
namespace ControlCatalog.Web; |
|||
|
|||
public partial class App |
|||
{ |
|||
protected override void OnParametersSet() |
|||
{ |
|||
WebAppBuilder.Configure<ControlCatalog.App>() |
|||
.AfterSetup(_ => |
|||
{ |
|||
ControlCatalog.Pages.EmbedSample.Implementation = new EmbedSampleWeb(); |
|||
}) |
|||
.With(new SkiaOptions { CustomGpuFactory = null }) // uncomment to disable GPU/GL rendering
|
|||
.SetupWithSingleViewLifetime(); |
|||
|
|||
base.OnParametersSet(); |
|||
} |
|||
} |
|||
@ -1,34 +1,42 @@ |
|||
using System; |
|||
|
|||
using Avalonia; |
|||
using System.Runtime.InteropServices.JavaScript; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Web.Blazor; |
|||
using Avalonia.Web; |
|||
|
|||
using ControlCatalog.Pages; |
|||
|
|||
using Microsoft.JSInterop; |
|||
|
|||
namespace ControlCatalog.Web; |
|||
|
|||
public class EmbedSampleWeb : INativeDemoControl |
|||
{ |
|||
public IPlatformHandle CreateControl(bool isSecond, IPlatformHandle parent, Func<IPlatformHandle> createDefault) |
|||
{ |
|||
var runtime = AvaloniaLocator.Current.GetRequiredService<IJSInProcessRuntime>(); |
|||
|
|||
if (isSecond) |
|||
{ |
|||
var iframe = runtime.Invoke<IJSInProcessObjectReference>("document.createElement", "iframe"); |
|||
iframe.InvokeVoid("setAttribute", "src", "https://www.youtube.com/embed/kZCIporjJ70"); |
|||
var iframe = EmbedInterop.CreateElement("iframe"); |
|||
iframe.SetProperty("src", "https://www.youtube.com/embed/kZCIporjJ70"); |
|||
|
|||
return new JSObjectControlHandle(iframe); |
|||
} |
|||
else |
|||
{ |
|||
// window.createAppButton source is defined in "app.js" file.
|
|||
var button = runtime.Invoke<IJSInProcessObjectReference>("window.createAppButton"); |
|||
var defaultHandle = (JSObjectControlHandle)createDefault(); |
|||
|
|||
_ = JSHost.ImportAsync("embed.js", "./embed.js").ContinueWith(_ => |
|||
{ |
|||
EmbedInterop.AddAppButton(defaultHandle.Object); |
|||
}); |
|||
|
|||
return new JSObjectControlHandle(button); |
|||
return defaultHandle; |
|||
} |
|||
} |
|||
} |
|||
|
|||
internal static partial class EmbedInterop |
|||
{ |
|||
[JSImport("globalThis.document.createElement")] |
|||
public static partial JSObject CreateElement(string tagName); |
|||
|
|||
[JSImport("addAppButton", "embed.js")] |
|||
public static partial void AddAppButton(JSObject parentObject); |
|||
} |
|||
|
|||
|
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,6 @@ |
|||
<linker> |
|||
<assembly fullname="ControlCatalog" preserve="All" /> |
|||
<assembly fullname="ControlCatalog.Web" preserve="All" /> |
|||
<assembly fullname="Avalonia.Themes.Fluent" preserve="All" /> |
|||
<assembly fullname="Avalonia.Themes.Simple" preserve="All" /> |
|||
</linker> |
|||
@ -0,0 +1,49 @@ |
|||
#out { |
|||
height: 100vh; |
|||
width: 100vw |
|||
} |
|||
|
|||
#avalonia-splash { |
|||
position: relative; |
|||
height: 100%; |
|||
width: 100%; |
|||
color: whitesmoke; |
|||
background: #171C2C; |
|||
font-family: 'Nunito', sans-serif; |
|||
background-position: center; |
|||
background-size: cover; |
|||
background-repeat: no-repeat; |
|||
} |
|||
|
|||
#avalonia-splash a{ |
|||
color: whitesmoke; |
|||
text-decoration: none; |
|||
} |
|||
|
|||
.center { |
|||
display: flex; |
|||
justify-content: center; |
|||
height: 250px; |
|||
} |
|||
|
|||
.splash-close { |
|||
animation: slide 0.5s linear 1s forwards; |
|||
} |
|||
|
|||
@keyframes slide { |
|||
0% { |
|||
top: 0%; |
|||
} |
|||
|
|||
50% { |
|||
opacity: 80%; |
|||
} |
|||
|
|||
100% { |
|||
top: 100%; |
|||
overflow: hidden; |
|||
opacity: 0; |
|||
display: none; |
|||
visibility: collapse; |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
export function addAppButton(parent) { |
|||
var button = globalThis.document.createElement('button'); |
|||
button.innerText = 'Hello world'; |
|||
var clickCount = 0; |
|||
button.onclick = () => { |
|||
clickCount++; |
|||
button.innerText = 'Click count ' + clickCount; |
|||
}; |
|||
parent.appendChild(button); |
|||
return button; |
|||
} |
|||
|
After Width: | Height: | Size: 172 KiB |
@ -0,0 +1,31 @@ |
|||
<!DOCTYPE html> |
|||
<!-- Licensed to the .NET Foundation under one or more agreements. --> |
|||
<!-- The .NET Foundation licenses this file to you under the MIT license. --> |
|||
<html> |
|||
|
|||
<head> |
|||
<title>AvaloniaUI - ControlCatalog</title> |
|||
<meta charset="UTF-8"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|||
<link rel="modulepreload" href="./main.js" /> |
|||
<link rel="modulepreload" href="./dotnet.js" /> |
|||
<link rel="modulepreload" href="./avalonia.js" /> |
|||
<link rel="stylesheet" href="./app.css" /> |
|||
</head> |
|||
|
|||
<body style="margin: 0px"> |
|||
<div id="out"> |
|||
<div id="avalonia-splash"> |
|||
<div class="center"> |
|||
<h2>Powered by</h2> |
|||
<a class="navbar-brand" href="https://www.avaloniaui.net/" target="_blank"> |
|||
<img src="Logo.svg" alt="Avalonia Logo" width="30" height="24" /> |
|||
Avalonia |
|||
</a> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<script type='module' src="./main.js"></script> |
|||
</body> |
|||
|
|||
</html> |
|||
@ -0,0 +1,19 @@ |
|||
// Licensed to the .NET Foundation under one or more agreements.
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
|||
|
|||
import { dotnet } from './dotnet.js' |
|||
import { registerAvaloniaModule } from './avalonia.js'; |
|||
|
|||
const is_browser = typeof window != "undefined"; |
|||
if (!is_browser) throw new Error(`Expected to be running in a browser`); |
|||
|
|||
const dotnetRuntime = await dotnet |
|||
.withDiagnosticTracing(false) |
|||
.withApplicationArgumentsFromQuery() |
|||
.create(); |
|||
|
|||
await registerAvaloniaModule(dotnetRuntime); |
|||
|
|||
const config = dotnetRuntime.getConfig(); |
|||
|
|||
await dotnetRuntime.runMainAndExit(config.mainAssemblyName, ["dotnet", "is", "great!"]); |
|||
@ -0,0 +1,11 @@ |
|||
{ |
|||
"wasmHostProperties": { |
|||
"perHostConfig": [ |
|||
{ |
|||
"name": "browser", |
|||
"html-path": "index.html", |
|||
"Host": "browser" |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -1,105 +0,0 @@ |
|||
using Android.OS; |
|||
using AndroidX.AppCompat.App; |
|||
using Android.Content.Res; |
|||
using AndroidX.Lifecycle; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Controls; |
|||
using Android.Runtime; |
|||
using Android.App; |
|||
using Android.Content; |
|||
using System; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public abstract class AvaloniaActivity : AppCompatActivity |
|||
{ |
|||
internal class SingleViewLifetime : ISingleViewApplicationLifetime |
|||
{ |
|||
public AvaloniaView View { get; internal set; } |
|||
|
|||
public Control MainView |
|||
{ |
|||
get => (Control)View.Content; |
|||
set => View.Content = value; |
|||
} |
|||
} |
|||
|
|||
internal Action<int, Result, Intent> ActivityResult; |
|||
internal AvaloniaView View; |
|||
internal AvaloniaViewModel _viewModel; |
|||
|
|||
protected abstract AppBuilder CreateAppBuilder(); |
|||
|
|||
protected override void OnCreate(Bundle savedInstanceState) |
|||
{ |
|||
var builder = CreateAppBuilder(); |
|||
|
|||
|
|||
var lifetime = new SingleViewLifetime(); |
|||
|
|||
builder.AfterSetup(x => |
|||
{ |
|||
_viewModel = new ViewModelProvider(this).Get(Java.Lang.Class.FromType(typeof(AvaloniaViewModel))) as AvaloniaViewModel; |
|||
|
|||
View = new AvaloniaView(this); |
|||
if (_viewModel.Content != null) |
|||
{ |
|||
View.Content = _viewModel.Content; |
|||
} |
|||
|
|||
SetContentView(View); |
|||
lifetime.View = View; |
|||
|
|||
View.Prepare(); |
|||
}); |
|||
|
|||
builder.SetupWithLifetime(lifetime); |
|||
|
|||
base.OnCreate(savedInstanceState); |
|||
} |
|||
public object Content |
|||
{ |
|||
get |
|||
{ |
|||
return _viewModel.Content; |
|||
} |
|||
set |
|||
{ |
|||
_viewModel.Content = value; |
|||
if (View != null) |
|||
View.Content = value; |
|||
} |
|||
} |
|||
|
|||
public override void OnConfigurationChanged(Configuration newConfig) |
|||
{ |
|||
base.OnConfigurationChanged(newConfig); |
|||
} |
|||
|
|||
protected override void OnDestroy() |
|||
{ |
|||
View.Content = null; |
|||
|
|||
base.OnDestroy(); |
|||
} |
|||
|
|||
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) |
|||
{ |
|||
base.OnActivityResult(requestCode, resultCode, data); |
|||
|
|||
ActivityResult?.Invoke(requestCode, resultCode, data); |
|||
} |
|||
} |
|||
|
|||
public abstract class AvaloniaActivity<TApp> : AvaloniaActivity where TApp : Application, new() |
|||
{ |
|||
protected virtual AppBuilder CustomizeAppBuilder(AppBuilder builder) => builder.UseAndroid(); |
|||
|
|||
protected override AppBuilder CreateAppBuilder() |
|||
{ |
|||
var builder = AppBuilder.Configure<TApp>(); |
|||
|
|||
return CustomizeAppBuilder(builder); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
using System; |
|||
using Android.App; |
|||
using Android.Content; |
|||
using Android.Content.Res; |
|||
using Android.OS; |
|||
using Android.Runtime; |
|||
using AndroidX.AppCompat.App; |
|||
using AndroidX.Lifecycle; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public abstract class AvaloniaMainActivity : AppCompatActivity, IActivityResultHandler |
|||
{ |
|||
internal static object ViewContent; |
|||
|
|||
public Action<int, Result, Intent> ActivityResult { get; set; } |
|||
internal AvaloniaView View; |
|||
|
|||
protected override void OnCreate(Bundle savedInstanceState) |
|||
{ |
|||
View = new AvaloniaView(this); |
|||
if (ViewContent != null) |
|||
{ |
|||
View.Content = ViewContent; |
|||
} |
|||
|
|||
if (Avalonia.Application.Current.ApplicationLifetime is SingleViewLifetime lifetime) |
|||
{ |
|||
lifetime.View = View; |
|||
} |
|||
|
|||
base.OnCreate(savedInstanceState); |
|||
|
|||
SetContentView(View); |
|||
} |
|||
|
|||
public object Content |
|||
{ |
|||
get |
|||
{ |
|||
return ViewContent; |
|||
} |
|||
set |
|||
{ |
|||
ViewContent = value; |
|||
if (View != null) |
|||
View.Content = value; |
|||
} |
|||
} |
|||
|
|||
public override void OnConfigurationChanged(Configuration newConfig) |
|||
{ |
|||
base.OnConfigurationChanged(newConfig); |
|||
} |
|||
|
|||
protected override void OnDestroy() |
|||
{ |
|||
View.Content = null; |
|||
|
|||
base.OnDestroy(); |
|||
} |
|||
|
|||
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) |
|||
{ |
|||
base.OnActivityResult(requestCode, resultCode, data); |
|||
|
|||
ActivityResult?.Invoke(requestCode, resultCode, data); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
using Android.OS; |
|||
using AndroidX.AppCompat.App; |
|||
using AndroidX.Lifecycle; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public abstract class AvaloniaSplashActivity : AppCompatActivity |
|||
{ |
|||
protected abstract AppBuilder CreateAppBuilder(); |
|||
|
|||
protected override void OnCreate(Bundle? savedInstanceState) |
|||
{ |
|||
base.OnCreate(savedInstanceState); |
|||
|
|||
var builder = CreateAppBuilder(); |
|||
|
|||
var lifetime = new SingleViewLifetime(); |
|||
|
|||
builder.SetupWithLifetime(lifetime); |
|||
} |
|||
} |
|||
|
|||
public abstract class AvaloniaSplashActivity<TApp> : AvaloniaSplashActivity where TApp : Application, new() |
|||
{ |
|||
protected virtual AppBuilder CustomizeAppBuilder(AppBuilder builder) => builder.UseAndroid(); |
|||
|
|||
protected override AppBuilder CreateAppBuilder() |
|||
{ |
|||
var builder = AppBuilder.Configure<TApp>(); |
|||
|
|||
return CustomizeAppBuilder(builder); |
|||
} |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
internal class AvaloniaViewModel : AndroidX.Lifecycle.ViewModel |
|||
{ |
|||
public object Content { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using Android.App; |
|||
using Android.Content; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public interface IActivityResultHandler |
|||
{ |
|||
public Action<int, Result, Intent> ActivityResult { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
internal class SingleViewLifetime : ISingleViewApplicationLifetime |
|||
{ |
|||
private AvaloniaView _view; |
|||
|
|||
public AvaloniaView View |
|||
{ |
|||
get => _view; internal set |
|||
{ |
|||
if (_view != null) |
|||
{ |
|||
_view.Content = null; |
|||
_view.Dispose(); |
|||
} |
|||
_view = value; |
|||
_view.Content = MainView; |
|||
} |
|||
} |
|||
|
|||
public Control MainView { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace System; |
|||
|
|||
#if !NET6_0_OR_GREATER
|
|||
public static class StringCompatibilityExtensions |
|||
{ |
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public static bool Contains(this string str, char search) => |
|||
str.Contains(search.ToString()); |
|||
} |
|||
#endif
|
|||
@ -0,0 +1,58 @@ |
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// The font metrics is holding information about a font's ascent, descent, etc. in design em units.
|
|||
/// </summary>
|
|||
public readonly struct FontMetrics |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the font design units per em.
|
|||
/// </summary>
|
|||
public short DesignEmHeight { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// A <see cref="bool"/> value indicating whether all glyphs in the font have the same advancement.
|
|||
/// </summary>
|
|||
public bool IsFixedPitch { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended distance above the baseline in design em size.
|
|||
/// </summary>
|
|||
public int Ascent { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended distance under the baseline in design em size.
|
|||
/// </summary>
|
|||
public int Descent { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended additional space between two lines of text in design em size.
|
|||
/// </summary>
|
|||
public int LineGap { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended line spacing of a formed text line.
|
|||
/// </summary>
|
|||
public int LineSpacing => Descent - Ascent + LineGap; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the distance of the underline from the baseline in design em size.
|
|||
/// </summary>
|
|||
public int UnderlinePosition { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the thickness of the underline in design em size.
|
|||
/// </summary>
|
|||
public int UnderlineThickness { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the distance of the strikethrough from the baseline in design em size.
|
|||
/// </summary>
|
|||
public int StrikethroughPosition { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the thickness of the underline in design em size.
|
|||
/// </summary>
|
|||
public int StrikethroughThickness { get; init; } |
|||
} |
|||
} |
|||
@ -1,125 +0,0 @@ |
|||
using System; |
|||
using Avalonia.Platform; |
|||
|
|||
namespace Avalonia.Media |
|||
{ |
|||
public sealed class GlyphTypeface : IDisposable |
|||
{ |
|||
public GlyphTypeface(Typeface typeface) |
|||
: this(FontManager.Current.PlatformImpl.CreateGlyphTypeface(typeface)) |
|||
{ |
|||
} |
|||
|
|||
public GlyphTypeface(IGlyphTypefaceImpl platformImpl) |
|||
{ |
|||
PlatformImpl = platformImpl; |
|||
} |
|||
|
|||
public IGlyphTypefaceImpl PlatformImpl { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the font design units per em.
|
|||
/// </summary>
|
|||
public short DesignEmHeight => PlatformImpl.DesignEmHeight; |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended distance above the baseline in design em size.
|
|||
/// </summary>
|
|||
public int Ascent => PlatformImpl.Ascent; |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended distance under the baseline in design em size.
|
|||
/// </summary>
|
|||
public int Descent => PlatformImpl.Descent; |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended additional space between two lines of text in design em size.
|
|||
/// </summary>
|
|||
public int LineGap => PlatformImpl.LineGap; |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended line height.
|
|||
/// </summary>
|
|||
public int LineHeight => Descent - Ascent + LineGap; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the distance of the underline from the baseline in design em size.
|
|||
/// </summary>
|
|||
public int UnderlinePosition => PlatformImpl.UnderlinePosition; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the thickness of the underline in design em size.
|
|||
/// </summary>
|
|||
public int UnderlineThickness => PlatformImpl.UnderlineThickness; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the distance of the strikethrough from the baseline in design em size.
|
|||
/// </summary>
|
|||
public int StrikethroughPosition => PlatformImpl.StrikethroughPosition; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the thickness of the underline in design em size.
|
|||
/// </summary>
|
|||
public int StrikethroughThickness => PlatformImpl.StrikethroughThickness; |
|||
|
|||
/// <summary>
|
|||
/// A <see cref="bool"/> value indicating whether all glyphs in the font have the same advancement.
|
|||
/// </summary>
|
|||
public bool IsFixedPitch => PlatformImpl.IsFixedPitch; |
|||
|
|||
/// <summary>
|
|||
/// Returns an glyph index for the specified codepoint.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// Returns a replacement glyph if a glyph isn't found.
|
|||
/// </remarks>
|
|||
/// <param name="codepoint">The codepoint.</param>
|
|||
/// <returns>
|
|||
/// A glyph index.
|
|||
/// </returns>
|
|||
public ushort GetGlyph(uint codepoint) => PlatformImpl.GetGlyph(codepoint); |
|||
|
|||
/// <summary>
|
|||
/// Tries to get an glyph index for specified codepoint.
|
|||
/// </summary>
|
|||
/// <param name="codepoint">The codepoint.</param>
|
|||
/// <param name="glyph">A glyph index.</param>
|
|||
/// <returns>
|
|||
/// <c>true</c> if an glyph index was found, <c>false</c> otherwise.
|
|||
/// </returns>
|
|||
public bool TryGetGlyph(uint codepoint, out ushort glyph) |
|||
{ |
|||
glyph = PlatformImpl.GetGlyph(codepoint); |
|||
|
|||
return glyph != 0; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns an array of glyph indices. Codepoints that are not represented by the font are returned as <code>0</code>.
|
|||
/// </summary>
|
|||
/// <param name="codepoints">The codepoints to map.</param>
|
|||
/// <returns></returns>
|
|||
public ushort[] GetGlyphs(ReadOnlySpan<uint> codepoints) => PlatformImpl.GetGlyphs(codepoints); |
|||
|
|||
/// <summary>
|
|||
/// Returns the glyph advance for the specified glyph.
|
|||
/// </summary>
|
|||
/// <param name="glyph">The glyph.</param>
|
|||
/// <returns>
|
|||
/// The advance.
|
|||
/// </returns>
|
|||
public int GetGlyphAdvance(ushort glyph) => PlatformImpl.GetGlyphAdvance(glyph); |
|||
|
|||
/// <summary>
|
|||
/// Returns an array of glyph advances in design em size.
|
|||
/// </summary>
|
|||
/// <param name="glyphs">The glyph indices.</param>
|
|||
/// <returns></returns>
|
|||
public int[] GetGlyphAdvances(ReadOnlySpan<ushort> glyphs) => PlatformImpl.GetGlyphAdvances(glyphs); |
|||
|
|||
void IDisposable.Dispose() |
|||
{ |
|||
PlatformImpl?.Dispose(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,33 +1,33 @@ |
|||
namespace Avalonia.Media.TextFormatting |
|||
{ |
|||
/// <summary>
|
|||
/// A metric that holds information about font specific measurements.
|
|||
/// A metric that holds information about text specific measurements.
|
|||
/// </summary>
|
|||
public readonly struct FontMetrics |
|||
public readonly struct TextMetrics |
|||
{ |
|||
public FontMetrics(Typeface typeface, double fontRenderingEmSize) |
|||
public TextMetrics(Typeface typeface, double fontRenderingEmSize) |
|||
{ |
|||
var glyphTypeface = typeface.GlyphTypeface; |
|||
var fontMetrics = typeface.GlyphTypeface.Metrics; |
|||
|
|||
var scale = fontRenderingEmSize / glyphTypeface.DesignEmHeight; |
|||
var scale = fontRenderingEmSize / fontMetrics.DesignEmHeight; |
|||
|
|||
FontRenderingEmSize = fontRenderingEmSize; |
|||
|
|||
Ascent = glyphTypeface.Ascent * scale; |
|||
Ascent = fontMetrics.Ascent * scale; |
|||
|
|||
Descent = glyphTypeface.Descent * scale; |
|||
Descent = fontMetrics.Descent * scale; |
|||
|
|||
LineGap = glyphTypeface.LineGap * scale; |
|||
LineGap = fontMetrics.LineGap * scale; |
|||
|
|||
LineHeight = Descent - Ascent + LineGap; |
|||
|
|||
UnderlineThickness = glyphTypeface.UnderlineThickness * scale; |
|||
UnderlineThickness = fontMetrics.UnderlineThickness * scale; |
|||
|
|||
UnderlinePosition = glyphTypeface.UnderlinePosition * scale; |
|||
UnderlinePosition = fontMetrics.UnderlinePosition * scale; |
|||
|
|||
StrikethroughThickness = glyphTypeface.StrikethroughThickness * scale; |
|||
StrikethroughThickness = fontMetrics.StrikethroughThickness * scale; |
|||
|
|||
StrikethroughPosition = glyphTypeface.StrikethroughPosition * scale; |
|||
StrikethroughPosition = fontMetrics.StrikethroughPosition * scale; |
|||
} |
|||
|
|||
/// <summary>
|
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
using System.Drawing; |
|||
|
|||
namespace Avalonia.Platform |
|||
{ |
|||
public interface IGlyphRunBuffer |
|||
{ |
|||
Span<ushort> GlyphIndices { get; } |
|||
|
|||
IGlyphRunImpl Build(); |
|||
} |
|||
|
|||
public interface IHorizontalGlyphRunBuffer : IGlyphRunBuffer |
|||
{ |
|||
Span<float> GlyphPositions { get; } |
|||
} |
|||
|
|||
public interface IPositionedGlyphRunBuffer : IGlyphRunBuffer |
|||
{ |
|||
Span<PointF> GlyphPositions { get; } |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue