Browse Source

Updated AppBuilder to have a way to track names of the windowing and rendering subsystems.

pull/707/head
Jeremy Koritzinsky 10 years ago
parent
commit
397f0ad38b
  1. 41
      src/Avalonia.Controls/AppBuilderBase.cs
  2. 4
      src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs
  3. 3
      src/Gtk/Avalonia.Cairo/CairoPlatform.cs
  4. 3
      src/Gtk/Avalonia.Gtk/GtkPlatform.cs
  5. 3
      src/Skia/Avalonia.Skia/SkiaPlatform.cs
  6. 3
      src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs
  7. 3
      src/Windows/Avalonia.Win32/Win32Platform.cs
  8. 3
      src/iOS/Avalonia.iOS/iOSPlatform.cs

41
src/Avalonia.Controls/AppBuilderBase.cs

@ -21,7 +21,7 @@ namespace Avalonia.Controls
/// <summary> /// <summary>
/// Gets or sets a method to call the initialize the runtime platform services (e. g. AssetLoader) /// Gets or sets a method to call the initialize the runtime platform services (e. g. AssetLoader)
/// </summary> /// </summary>
public Action RuntimePlatformServices { get; set; } public Action RuntimePlatformServicesInitializer { get; set; }
/// <summary> /// <summary>
/// Gets or sets the <see cref="Application"/> instance being initialized. /// Gets or sets the <see cref="Application"/> instance being initialized.
@ -31,12 +31,22 @@ namespace Avalonia.Controls
/// <summary> /// <summary>
/// Gets or sets a method to call the initialize the windowing subsystem. /// Gets or sets a method to call the initialize the windowing subsystem.
/// </summary> /// </summary>
public Action WindowingSubsystem { get; set; } public Action WindowingSubsystemInitializer { get; set; }
/// <summary>
/// Gets or sets the name of the windowing subsystem to use.
/// </summary>
public string WindowingSubsystemName { get; set; }
/// <summary> /// <summary>
/// Gets or sets a method to call the initialize the windowing subsystem. /// Gets or sets a method to call the initialize the windowing subsystem.
/// </summary> /// </summary>
public Action RenderingSubsystem { get; set; } public Action RenderingSubsystemInitializer { get; set; }
/// <summary>
/// Gets or sets the name of the rendering subsystem to use.
/// </summary>
public string RenderingSubsystemName { get; set; }
/// <summary> /// <summary>
/// Gets or sets a method to call before <see cref="Start{TMainWindow}"/> is called on the /// Gets or sets a method to call before <see cref="Start{TMainWindow}"/> is called on the
@ -47,7 +57,7 @@ namespace Avalonia.Controls
protected AppBuilderBase(IRuntimePlatform platform, Action platformSevices) protected AppBuilderBase(IRuntimePlatform platform, Action platformSevices)
{ {
RuntimePlatform = platform; RuntimePlatform = platform;
RuntimePlatformServices = platformSevices; RuntimePlatformServicesInitializer = platformSevices;
} }
/// <summary> /// <summary>
@ -85,7 +95,12 @@ namespace Avalonia.Controls
/// <returns>An <typeparamref name="TAppBuilder"/> instance.</returns> /// <returns>An <typeparamref name="TAppBuilder"/> instance.</returns>
public TAppBuilder BeforeStarting(Action<TAppBuilder> callback) public TAppBuilder BeforeStarting(Action<TAppBuilder> callback)
{ {
BeforeStartCallback = callback; var oldCallback = BeforeStartCallback;
BeforeStartCallback = builder =>
{
oldCallback?.Invoke(builder);
callback(builder);
};
return Self; return Self;
} }
@ -121,7 +136,7 @@ namespace Avalonia.Controls
/// <returns>An <typeparamref name="TAppBuilder"/> instance.</returns> /// <returns>An <typeparamref name="TAppBuilder"/> instance.</returns>
public TAppBuilder UseWindowingSubsystem(Action initializer) public TAppBuilder UseWindowingSubsystem(Action initializer)
{ {
WindowingSubsystem = initializer; WindowingSubsystemInitializer = initializer;
return Self; return Self;
} }
@ -139,7 +154,7 @@ namespace Avalonia.Controls
/// <returns>An <typeparamref name="TAppBuilder"/> instance.</returns> /// <returns>An <typeparamref name="TAppBuilder"/> instance.</returns>
public TAppBuilder UseRenderingSubsystem(Action initializer) public TAppBuilder UseRenderingSubsystem(Action initializer)
{ {
RenderingSubsystem = initializer; RenderingSubsystemInitializer = initializer;
return Self; return Self;
} }
@ -170,25 +185,25 @@ namespace Avalonia.Controls
throw new InvalidOperationException("No App instance configured."); throw new InvalidOperationException("No App instance configured.");
} }
if (RuntimePlatformServices == null) if (RuntimePlatformServicesInitializer == null)
{ {
throw new InvalidOperationException("No runtime platform services configured."); throw new InvalidOperationException("No runtime platform services configured.");
} }
if (WindowingSubsystem == null) if (WindowingSubsystemInitializer == null)
{ {
throw new InvalidOperationException("No windowing system configured."); throw new InvalidOperationException("No windowing system configured.");
} }
if (RenderingSubsystem == null) if (RenderingSubsystemInitializer == null)
{ {
throw new InvalidOperationException("No rendering system configured."); throw new InvalidOperationException("No rendering system configured.");
} }
Instance.RegisterServices(); Instance.RegisterServices();
RuntimePlatformServices(); RuntimePlatformServicesInitializer();
WindowingSubsystem(); WindowingSubsystemInitializer();
RenderingSubsystem(); RenderingSubsystemInitializer();
Instance.Initialize(); Instance.Initialize();
} }
} }

4
src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs

@ -28,11 +28,15 @@ namespace Avalonia
{ {
UseRenderingSubsystem("Avalonia.Cairo"); UseRenderingSubsystem("Avalonia.Cairo");
UseWindowingSubsystem("Avalonia.Gtk"); UseWindowingSubsystem("Avalonia.Gtk");
WindowingSubsystemName = "Gtk";
RenderingSubsystemName = "Cairo";
} }
else else
{ {
UseRenderingSubsystem("Avalonia.Direct2D1"); UseRenderingSubsystem("Avalonia.Direct2D1");
UseWindowingSubsystem("Avalonia.Win32"); UseWindowingSubsystem("Avalonia.Win32");
WindowingSubsystemName = "Win32";
RenderingSubsystemName = "Direct2D1";
} }
return this; return this;
} }

3
src/Gtk/Avalonia.Cairo/CairoPlatform.cs

@ -14,7 +14,8 @@ namespace Avalonia
{ {
public static T UseCairo<T>(this T builder) where T : AppBuilderBase<T>, new() public static T UseCairo<T>(this T builder) where T : AppBuilderBase<T>, new()
{ {
builder.RenderingSubsystem = Avalonia.Cairo.CairoPlatform.Initialize; builder.RenderingSubsystemInitializer = Cairo.CairoPlatform.Initialize;
builder.RenderingSubsystemName = "Cairo";
return builder; return builder;
} }
} }

3
src/Gtk/Avalonia.Gtk/GtkPlatform.cs

@ -16,7 +16,8 @@ namespace Avalonia
{ {
public static T UseGtk<T>(this T builder) where T : AppBuilderBase<T>, new() public static T UseGtk<T>(this T builder) where T : AppBuilderBase<T>, new()
{ {
builder.WindowingSubsystem = Avalonia.Gtk.GtkPlatform.Initialize; builder.WindowingSubsystemInitializer = Gtk.GtkPlatform.Initialize;
builder.WindowingSubsystemName = "Gtk";
return builder; return builder;
} }
} }

3
src/Skia/Avalonia.Skia/SkiaPlatform.cs

@ -10,7 +10,8 @@ namespace Avalonia
{ {
public static T UseSkia<T>(this T builder) where T : AppBuilderBase<T>, new() public static T UseSkia<T>(this T builder) where T : AppBuilderBase<T>, new()
{ {
builder.RenderingSubsystem = Avalonia.Skia.SkiaPlatform.Initialize; builder.RenderingSubsystemInitializer = Avalonia.Skia.SkiaPlatform.Initialize;
builder.RenderingSubsystemName = "Skia";
return builder; return builder;
} }
} }

3
src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs

@ -14,7 +14,8 @@ namespace Avalonia
{ {
public static T UseDirect2D1<T>(this T builder) where T : AppBuilderBase<T>, new() public static T UseDirect2D1<T>(this T builder) where T : AppBuilderBase<T>, new()
{ {
builder.RenderingSubsystem = Avalonia.Direct2D1.Direct2D1Platform.Initialize; builder.RenderingSubsystemInitializer = Avalonia.Direct2D1.Direct2D1Platform.Initialize;
builder.RenderingSubsystemName = "Direct2D1";
return builder; return builder;
} }
} }

3
src/Windows/Avalonia.Win32/Win32Platform.cs

@ -23,7 +23,8 @@ namespace Avalonia
{ {
public static T UseWin32<T>(this T builder) where T : AppBuilderBase<T>, new() public static T UseWin32<T>(this T builder) where T : AppBuilderBase<T>, new()
{ {
builder.WindowingSubsystem = Avalonia.Win32.Win32Platform.Initialize; builder.WindowingSubsystemInitializer = Win32.Win32Platform.Initialize;
builder.WindowingSubsystemName = "Win32";
return builder; return builder;
} }
} }

3
src/iOS/Avalonia.iOS/iOSPlatform.cs

@ -15,7 +15,8 @@ namespace Avalonia
{ {
public static T UseiOS<T>(this T builder) where T : AppBuilderBase<T>, new() public static T UseiOS<T>(this T builder) where T : AppBuilderBase<T>, new()
{ {
builder.WindowingSubsystem = Avalonia.iOS.iOSPlatform.Initialize; builder.WindowingSubsystemInitializer = iOSPlatform.Initialize;
builder.WindowingSubsystemName = "iOS";
return builder; return builder;
} }

Loading…
Cancel
Save