Browse Source

Merge branch 'master' into template-part-attribute

pull/7854/head
Dariusz Komosiński 4 years ago
committed by GitHub
parent
commit
78ddf88e8f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      native/Avalonia.Native/src/OSX/controlhost.mm
  2. 9
      native/Avalonia.Native/src/OSX/window.mm
  3. 4
      packages/Avalonia/Avalonia.csproj
  4. 3
      samples/ControlCatalog.Android/ControlCatalog.Android.csproj
  5. 3
      samples/ControlCatalog/Pages/DialogsPage.xaml.cs
  6. 16
      src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs
  7. 11
      src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs
  8. 10
      src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj
  9. 52
      src/Android/Avalonia.AndroidTestApplication/MainActivity.cs
  10. 2
      src/Avalonia.Controls/Button.cs
  11. 10
      src/Avalonia.Controls/Platform/IPlatformNativeSurfaceHandle.cs
  12. 5
      src/Avalonia.Diagnostics/Diagnostics/DevToolsOptions.cs
  13. 2
      src/Avalonia.Diagnostics/Diagnostics/Views/LayoutExplorerView.axaml
  14. 13
      src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs
  15. 2
      src/Avalonia.MicroCom/Avalonia.MicroCom.csproj
  16. 2
      src/Avalonia.Themes.Default/Controls/ToggleSwitch.xaml
  17. 4
      src/Avalonia.Themes.Default/DefaultTheme.xaml
  18. 3
      src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml
  19. 2
      src/Avalonia.Themes.Fluent/Controls/ToggleSwitch.xaml
  20. 26
      src/Avalonia.X11/X11Window.cs
  21. 8
      src/Windows/Avalonia.Win32/WindowImpl.cs

3
native/Avalonia.Native/src/OSX/controlhost.mm

@ -36,7 +36,10 @@ public:
virtual void DestroyDefaultChild(void* child) override virtual void DestroyDefaultChild(void* child) override
{ {
// ARC will release the object for us // ARC will release the object for us
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-value"
(__bridge_transfer NSView*) child; (__bridge_transfer NSView*) child;
#pragma clang diagnostic pop
} }
}; };

9
native/Avalonia.Native/src/OSX/window.mm

@ -457,7 +457,8 @@ public:
} }
point = ConvertPointY(point); point = ConvertPointY(point);
auto viewPoint = [Window convertScreenToBase:ToNSPoint(point)]; NSRect convertRect = [Window convertRectToScreen:NSMakeRect(point.X, point.Y, 0.0, 0.0)];
auto viewPoint = NSMakePoint(convertRect.origin.x, convertRect.origin.y);
*ret = [View translateLocalPoint:ToAvnPoint(viewPoint)]; *ret = [View translateLocalPoint:ToAvnPoint(viewPoint)];
@ -477,7 +478,8 @@ public:
} }
auto cocoaViewPoint = ToNSPoint([View translateLocalPoint:point]); auto cocoaViewPoint = ToNSPoint([View translateLocalPoint:point]);
auto cocoaScreenPoint = [Window convertBaseToScreen:cocoaViewPoint]; NSRect convertRect = [Window convertRectToScreen:NSMakeRect(cocoaViewPoint.x, cocoaViewPoint.y, 0.0, 0.0)];
auto cocoaScreenPoint = NSPointFromCGPoint(NSMakePoint(convertRect.origin.x, convertRect.origin.y));
*ret = ConvertPointY(ToAvnPoint(cocoaScreenPoint)); *ret = ConvertPointY(ToAvnPoint(cocoaScreenPoint));
return S_OK; return S_OK;
@ -573,7 +575,8 @@ public:
if(!((nseventType >= NSEventTypeLeftMouseDown && nseventType <= NSEventTypeMouseExited) if(!((nseventType >= NSEventTypeLeftMouseDown && nseventType <= NSEventTypeMouseExited)
|| (nseventType >= NSEventTypeOtherMouseDown && nseventType <= NSEventTypeOtherMouseDragged))) || (nseventType >= NSEventTypeOtherMouseDown && nseventType <= NSEventTypeOtherMouseDragged)))
{ {
auto nspoint = [Window convertBaseToScreen: ToNSPoint(point)]; NSRect convertRect = [Window convertRectToScreen:NSMakeRect(point.X, point.Y, 0.0, 0.0)];
auto nspoint = NSMakePoint(convertRect.origin.x, convertRect.origin.y);
CGPoint cgpoint = NSPointToCGPoint(nspoint); CGPoint cgpoint = NSPointToCGPoint(nspoint);
auto cgevent = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, cgpoint, kCGMouseButtonLeft); auto cgevent = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, cgpoint, kCGMouseButtonLeft);
nsevent = [NSEvent eventWithCGEvent: cgevent]; nsevent = [NSEvent eventWithCGEvent: cgevent];

4
packages/Avalonia/Avalonia.csproj

@ -8,7 +8,9 @@
<ProjectReference Include="../../src/Avalonia.Remote.Protocol/Avalonia.Remote.Protocol.csproj" /> <ProjectReference Include="../../src/Avalonia.Remote.Protocol/Avalonia.Remote.Protocol.csproj" />
<ProjectReference Include="../../src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj" > <ProjectReference Include="../../src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj" >
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</ProjectReference> <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
</ProjectReference>
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>

3
samples/ControlCatalog.Android/ControlCatalog.Android.csproj

@ -21,8 +21,9 @@
<PropertyGroup Condition="'$(Configuration)'=='Release' and '$(TF_BUILD)' == ''"> <PropertyGroup Condition="'$(Configuration)'=='Release' and '$(TF_BUILD)' == ''">
<DebugSymbols>True</DebugSymbols> <DebugSymbols>True</DebugSymbols>
<RunAOTCompilation>False</RunAOTCompilation> <RunAOTCompilation>True</RunAOTCompilation>
<EnableLLVM>True</EnableLLVM> <EnableLLVM>True</EnableLLVM>
<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

3
samples/ControlCatalog/Pages/DialogsPage.xaml.cs

@ -157,7 +157,8 @@ namespace ControlCatalog.Pages
(button = new Button (button = new Button
{ {
HorizontalAlignment = HorizontalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center,
Content = "Click to close" Content = "Click to close",
IsDefault = true
}) })
} }
}, },

16
src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs

@ -2,18 +2,22 @@ using System;
using Android.Content; using Android.Content;
using Android.Graphics; using Android.Graphics;
using Android.OS; using Android.OS;
using Android.Runtime;
using Android.Util; using Android.Util;
using Android.Views; using Android.Views;
using Avalonia.Android.Platform.SkiaPlatform;
using Avalonia.Platform; using Avalonia.Platform;
namespace Avalonia.Android namespace Avalonia.Android
{ {
public abstract class InvalidationAwareSurfaceView : SurfaceView, ISurfaceHolderCallback, IPlatformHandle public abstract class InvalidationAwareSurfaceView : SurfaceView, ISurfaceHolderCallback, IPlatformNativeSurfaceHandle
{ {
bool _invalidateQueued; bool _invalidateQueued;
readonly object _lock = new object(); readonly object _lock = new object();
private readonly Handler _handler; private readonly Handler _handler;
IntPtr IPlatformHandle.Handle =>
AndroidFramebuffer.ANativeWindow_fromSurface(JNIEnv.Handle, Holder.Surface.Handle);
public InvalidationAwareSurfaceView(Context context) : base(context) public InvalidationAwareSurfaceView(Context context) : base(context)
{ {
@ -25,7 +29,7 @@ namespace Avalonia.Android
{ {
lock (_lock) lock (_lock)
{ {
if(_invalidateQueued) if (_invalidateQueued)
return; return;
_handler.Post(() => _handler.Post(() =>
{ {
@ -70,7 +74,7 @@ namespace Avalonia.Android
public void SurfaceDestroyed(ISurfaceHolder holder) public void SurfaceDestroyed(ISurfaceHolder holder)
{ {
Log.Info("AVALONIA", "Surface Destroyed"); Log.Info("AVALONIA", "Surface Destroyed");
} }
protected void DoDraw() protected void DoDraw()
@ -83,5 +87,9 @@ namespace Avalonia.Android
} }
protected abstract void Draw(); protected abstract void Draw();
public string HandleDescriptor => "SurfaceView"; public string HandleDescriptor => "SurfaceView";
public PixelSize Size => new PixelSize(Holder.SurfaceFrame.Width(), Holder.SurfaceFrame.Height());
public double Scaling => Resources.DisplayMetrics.Density;
} }
} }

11
src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Android.Content; using Android.Content;
using Android.Graphics; using Android.Graphics;
using Android.Runtime;
using Android.Views; using Android.Views;
using Android.Views.InputMethods; using Android.Views.InputMethods;
using Avalonia.Android.OpenGL; using Avalonia.Android.OpenGL;
@ -38,11 +37,10 @@ namespace Avalonia.Android.Platform.SkiaPlatform
_keyboardHelper = new AndroidKeyboardEventsHelper<TopLevelImpl>(this); _keyboardHelper = new AndroidKeyboardEventsHelper<TopLevelImpl>(this);
_touchHelper = new AndroidTouchEventsHelper<TopLevelImpl>(this, () => InputRoot, _touchHelper = new AndroidTouchEventsHelper<TopLevelImpl>(this, () => InputRoot,
GetAvaloniaPointFromEvent); GetAvaloniaPointFromEvent);
_gl = GlPlatformSurface.TryCreate(this); _gl = GlPlatformSurface.TryCreate(this);
_framebuffer = new FramebufferManager(this); _framebuffer = new FramebufferManager(this);
RenderScaling = (int)_view.Resources.DisplayMetrics.Density; RenderScaling = (int)_view.Scaling;
MaxClientSize = new PixelSize(_view.Resources.DisplayMetrics.WidthPixels, MaxClientSize = new PixelSize(_view.Resources.DisplayMetrics.WidthPixels,
_view.Resources.DisplayMetrics.HeightPixels).ToSize(RenderScaling); _view.Resources.DisplayMetrics.HeightPixels).ToSize(RenderScaling);
@ -77,7 +75,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform
public IPlatformHandle Handle => _view; public IPlatformHandle Handle => _view;
public IEnumerable<object> Surfaces => new object[] { _gl, _framebuffer }; public IEnumerable<object> Surfaces => new object[] { _gl, _framebuffer, Handle };
public IRenderer CreateRenderer(IRenderRoot root) => public IRenderer CreateRenderer(IRenderRoot root) =>
AndroidPlatform.Options.UseDeferredRendering AndroidPlatform.Options.UseDeferredRendering
@ -216,10 +214,9 @@ namespace Avalonia.Android.Platform.SkiaPlatform
public AcrylicPlatformCompensationLevels AcrylicCompensationLevels => new AcrylicPlatformCompensationLevels(1, 1, 1); public AcrylicPlatformCompensationLevels AcrylicCompensationLevels => new AcrylicPlatformCompensationLevels(1, 1, 1);
IntPtr EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo.Handle => IntPtr EglGlPlatformSurfaceBase.IEglWindowGlPlatformSurfaceInfo.Handle => ((IPlatformHandle)_view).Handle;
AndroidFramebuffer.ANativeWindow_fromSurface(JNIEnv.Handle, _view.Holder.Surface.Handle);
public PixelSize Size => new PixelSize(_view.Holder.SurfaceFrame.Width(), _view.Holder.SurfaceFrame.Height()); public PixelSize Size => _view.Size;
public double Scaling => RenderScaling; public double Scaling => RenderScaling;

10
src/Android/Avalonia.AndroidTestApplication/Avalonia.AndroidTestApplication.csproj

@ -11,12 +11,18 @@
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> <MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver>
<DebugType>portable</DebugType> <DebugType>portable</DebugType>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<AndroidResource Include="..\..\..\build\Assets\Icon.png">
<Link>Resources\drawable\Icon.png</Link>
</AndroidResource>
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release' and '$(TF_BUILD)' == ''"> <PropertyGroup Condition="'$(Configuration)'=='Release' and '$(TF_BUILD)' == ''">
<DebugSymbols>True</DebugSymbols> <DebugSymbols>True</DebugSymbols>
<RunAOTCompilation>True</RunAOTCompilation> <RunAOTCompilation>True</RunAOTCompilation>
<EnableLLVM>True</EnableLLVM> <EnableLLVM>True</EnableLLVM>
<!--<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>--> <AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

52
src/Android/Avalonia.AndroidTestApplication/MainActivity.cs

@ -1,9 +1,10 @@
using System; using System;
using Android.App; using Android.App;
using Android.Content.PM; using Android.Content.PM;
using Android.OS;
using Avalonia.Android; using Avalonia.Android;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Input.TextInput;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.Styling; using Avalonia.Styling;
@ -14,22 +15,15 @@ namespace Avalonia.AndroidTestApplication
[Activity(Label = "Main", [Activity(Label = "Main",
MainLauncher = true, MainLauncher = true,
Icon = "@drawable/icon", Icon = "@drawable/icon",
Theme = "@style/Theme.AppCompat.NoActionBar", Theme = "@style/Theme.AppCompat.NoActionBar",
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize,
LaunchMode = LaunchMode.SingleInstance/*, LaunchMode = LaunchMode.SingleInstance/*,
ScreenOrientation = ScreenOrientation.Landscape*/)] ScreenOrientation = ScreenOrientation.Landscape*/)]
public class MainBaseActivity : AvaloniaActivity public class MainActivity : AvaloniaActivity<App>
{ {
protected override void OnCreate(Bundle savedInstanceState) protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{ {
if (Avalonia.Application.Current == null) return base.CustomizeAppBuilder(builder);
{
AppBuilder.Configure<App>()
.UseAndroid()
.SetupWithoutStarting();
}
base.OnCreate(savedInstanceState);
Content = App.CreateSimpleWindow();
} }
} }
@ -37,13 +31,17 @@ namespace Avalonia.AndroidTestApplication
{ {
public override void Initialize() public override void Initialize()
{ {
Styles.Add(new DefaultTheme()); Styles.Add(new SimpleTheme(new Uri("avares://Avalonia.AndroidTestApplication")));
}
var baseLight = (IStyle)AvaloniaXamlLoader.Load(
new Uri("resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"));
Styles.Add(baseLight);
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime)
{
singleViewLifetime.MainView = CreateSimpleWindow();
}
base.OnFrameworkInitializationCompleted();
} }
// This provides a simple UI tree for testing input handling, drawing, etc // This provides a simple UI tree for testing input handling, drawing, etc
@ -76,12 +74,12 @@ namespace Avalonia.AndroidTestApplication
Foreground = Brushes.Black Foreground = Brushes.Black
}, },
CreateTextBox(Input.TextInput.TextInputContentType.Normal), CreateTextBox(TextInputContentType.Normal),
CreateTextBox(Input.TextInput.TextInputContentType.Password), CreateTextBox(TextInputContentType.Password),
CreateTextBox(Input.TextInput.TextInputContentType.Email), CreateTextBox(TextInputContentType.Email),
CreateTextBox(Input.TextInput.TextInputContentType.Url), CreateTextBox(TextInputContentType.Url),
CreateTextBox(Input.TextInput.TextInputContentType.Phone), CreateTextBox(TextInputContentType.Digits),
CreateTextBox(Input.TextInput.TextInputContentType.Number), CreateTextBox(TextInputContentType.Number),
} }
} }
}; };
@ -89,16 +87,16 @@ namespace Avalonia.AndroidTestApplication
return window; return window;
} }
private static TextBox CreateTextBox(Input.TextInput.TextInputContentType contentType) private static TextBox CreateTextBox(TextInputContentType contentType)
{ {
var textBox = new TextBox() var textBox = new TextBox()
{ {
Margin = new Thickness(20, 10), Margin = new Thickness(20, 10),
Watermark = contentType.ToString(), Watermark = contentType.ToString(),
BorderThickness = new Thickness(3), BorderThickness = new Thickness(3),
FontSize = 20 FontSize = 20,
[TextInputOptions.ContentTypeProperty] = contentType
}; };
textBox.TextInputOptionsQuery += (s, e) => { e.ContentType = contentType; };
return textBox; return textBox;
} }

2
src/Avalonia.Controls/Button.cs

@ -539,6 +539,7 @@ namespace Avalonia.Controls
if (e.Key == Key.Enter && IsVisible && IsEnabled) if (e.Key == Key.Enter && IsVisible && IsEnabled)
{ {
OnClick(); OnClick();
e.Handled = true;
} }
} }
@ -552,6 +553,7 @@ namespace Avalonia.Controls
if (e.Key == Key.Escape && IsVisible && IsEnabled) if (e.Key == Key.Escape && IsVisible && IsEnabled)
{ {
OnClick(); OnClick();
e.Handled = true;
} }
} }

10
src/Avalonia.Controls/Platform/IPlatformNativeSurfaceHandle.cs

@ -0,0 +1,10 @@
using System;
namespace Avalonia.Platform
{
public interface IPlatformNativeSurfaceHandle : IPlatformHandle
{
PixelSize Size { get; }
double Scaling { get; }
}
}

5
src/Avalonia.Diagnostics/Diagnostics/DevToolsOptions.cs

@ -41,5 +41,10 @@ namespace Avalonia.Diagnostics
/// <remarks>Default handler is <see cref="Screenshots.FilePickerHandler"/></remarks> /// <remarks>Default handler is <see cref="Screenshots.FilePickerHandler"/></remarks>
public IScreenshotHandler ScreenshotHandler { get; set; } public IScreenshotHandler ScreenshotHandler { get; set; }
= Convetions.DefaultScreenshotHandler; = Convetions.DefaultScreenshotHandler;
/// <summary>
/// Gets or sets whether DevTools should use the dark mode theme
/// </summary>
public bool UseDarkMode { get; set; }
} }
} }

2
src/Avalonia.Diagnostics/Diagnostics/Views/LayoutExplorerView.axaml

@ -15,6 +15,7 @@
<SolidColorBrush x:Key="PaddingHighlightBrush" Color="#CEDA8E" /> <SolidColorBrush x:Key="PaddingHighlightBrush" Color="#CEDA8E" />
<SolidColorBrush x:Key="SizeBackgroundBrush" Color="#88B2BD" /> <SolidColorBrush x:Key="SizeBackgroundBrush" Color="#88B2BD" />
<SolidColorBrush x:Key="SizeHighlightBrush" Color="#9ED0DC" /> <SolidColorBrush x:Key="SizeHighlightBrush" Color="#9ED0DC" />
<SolidColorBrush x:Key="ThicknessEditorForeground" Color="Black" />
</UserControl.Resources> </UserControl.Resources>
<Grid RowDefinitions="*,Auto"> <Grid RowDefinitions="*,Auto">
@ -46,6 +47,7 @@
<controls:ThicknessEditor Grid.Row="0" Grid.Column="0" Header="margin" VerticalAlignment="Top" <controls:ThicknessEditor Grid.Row="0" Grid.Column="0" Header="margin" VerticalAlignment="Top"
HorizontalAlignment="Center" HorizontalAlignment="Center"
TextBlock.Foreground="{StaticResource ThicknessEditorForeground}"
Background="{StaticResource MarginBackgroundBrush}" Background="{StaticResource MarginBackgroundBrush}"
Highlight="{StaticResource MarginHighlightBrush}" Highlight="{StaticResource MarginHighlightBrush}"
Thickness="{Binding MarginThickness}"> Thickness="{Binding MarginThickness}">

13
src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs

@ -11,6 +11,7 @@ using Avalonia.Input;
using Avalonia.Input.Raw; using Avalonia.Input.Raw;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.Styling; using Avalonia.Styling;
using Avalonia.Themes.Default;
using Avalonia.VisualTree; using Avalonia.VisualTree;
namespace Avalonia.Diagnostics.Views namespace Avalonia.Diagnostics.Views
@ -242,7 +243,17 @@ namespace Avalonia.Diagnostics.Views
private void RootClosed(object? sender, EventArgs e) => Close(); private void RootClosed(object? sender, EventArgs e) => Close();
public void SetOptions(DevToolsOptions options) => public void SetOptions(DevToolsOptions options)
{
(DataContext as MainViewModel)?.SetOptions(options); (DataContext as MainViewModel)?.SetOptions(options);
if (options.UseDarkMode)
{
if (Styles[0] is SimpleTheme st)
{
st.Mode = SimpleThemeMode.Dark;
}
}
}
} }
} }

2
src/Avalonia.MicroCom/Avalonia.MicroCom.csproj

@ -10,6 +10,8 @@
<ProjectReference Include="..\Avalonia.Build.Tasks\Avalonia.Build.Tasks.csproj"> <ProjectReference Include="..\Avalonia.Build.Tasks\Avalonia.Build.Tasks.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<ExcludeAssets>all</ExcludeAssets> <ExcludeAssets>all</ExcludeAssets>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="..\..\build\BuildTargets.targets" /> <Import Project="..\..\build\BuildTargets.targets" />

2
src/Avalonia.Themes.Default/Controls/ToggleSwitch.xaml

@ -254,7 +254,7 @@
<Style Selector="ToggleSwitch:disabled /template/ Border#OuterBorder"> <Style Selector="ToggleSwitch:disabled /template/ Border#OuterBorder">
<Setter Property="BorderBrush" Value="{DynamicResource ToggleSwitchStrokeOffDisabled}"/> <Setter Property="BorderBrush" Value="{DynamicResource ToggleSwitchStrokeOffDisabled}"/>
<Setter Property="Background" Value="{DynamicResource ToggleSwitchFillOffPressed}"/> <Setter Property="Background" Value="{DynamicResource ToggleSwitchFillOffDisabled}"/>
</Style> </Style>
<Style Selector="ToggleSwitch:disabled /template/ Ellipse#SwitchKnobOff"> <Style Selector="ToggleSwitch:disabled /template/ Ellipse#SwitchKnobOff">

4
src/Avalonia.Themes.Default/DefaultTheme.xaml

@ -3,8 +3,9 @@
x:Class="Avalonia.Themes.Default.DefaultTheme"> x:Class="Avalonia.Themes.Default.DefaultTheme">
<!-- Define ToolTip first so its styles can be overriden by other controls (e.g. TextBox) --> <!-- Define ToolTip first so its styles can be overriden by other controls (e.g. TextBox) -->
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/ToolTip.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/ToolTip.xaml"/>
<!-- PathIcon also needs to be defined early so it can be overriden by other styles (e.g. ComboBox) -->
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/PathIcon.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/DataValidationErrors.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/DataValidationErrors.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/FocusAdorner.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/FocusAdorner.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/Button.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/Button.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/Carousel.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/Carousel.xaml"/>
@ -22,7 +23,6 @@
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/ContextMenu.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/ContextMenu.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/MenuItem.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/MenuItem.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/OverlayPopupHost.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/OverlayPopupHost.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/PathIcon.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/PopupRoot.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/PopupRoot.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/ProgressBar.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/ProgressBar.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Controls/RadioButton.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Default/Controls/RadioButton.xaml"/>

3
src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml

@ -3,6 +3,8 @@
x:Class="Avalonia.Themes.Fluent.Controls.FluentControls"> x:Class="Avalonia.Themes.Fluent.Controls.FluentControls">
<!-- Define ToolTip first so its styles can be overriden by other controls (e.g. TextBox) --> <!-- Define ToolTip first so its styles can be overriden by other controls (e.g. TextBox) -->
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ToolTip.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ToolTip.xaml"/>
<!-- PathIcon also needs to be defined early so it can be overriden by other styles (e.g. ComboBox) -->
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/PathIcon.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/DataValidationErrors.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/FocusAdorner.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/FocusAdorner.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Button.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/Button.xaml"/>
@ -21,7 +23,6 @@
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ContextMenu.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ContextMenu.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/MenuItem.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/MenuItem.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/OverlayPopupHost.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/OverlayPopupHost.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/PathIcon.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/PopupRoot.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/PopupRoot.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ProgressBar.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/ProgressBar.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/RadioButton.xaml"/> <StyleInclude Source="avares://Avalonia.Themes.Fluent/Controls/RadioButton.xaml"/>

2
src/Avalonia.Themes.Fluent/Controls/ToggleSwitch.xaml

@ -220,7 +220,7 @@
<Style Selector="ToggleSwitch:disabled /template/ Border#OuterBorder"> <Style Selector="ToggleSwitch:disabled /template/ Border#OuterBorder">
<Setter Property="BorderBrush" Value="{DynamicResource ToggleSwitchStrokeOffDisabled}"/> <Setter Property="BorderBrush" Value="{DynamicResource ToggleSwitchStrokeOffDisabled}"/>
<Setter Property="Background" Value="{DynamicResource ToggleSwitchFillOffPressed}"/> <Setter Property="Background" Value="{DynamicResource ToggleSwitchFillOffDisabled}"/>
</Style> </Style>
<Style Selector="ToggleSwitch:disabled /template/ Ellipse#SwitchKnobOff"> <Style Selector="ToggleSwitch:disabled /template/ Ellipse#SwitchKnobOff">

26
src/Avalonia.X11/X11Window.cs

@ -134,8 +134,8 @@ namespace Avalonia.X11
SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr); SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr);
else else
_renderHandle = _handle; _renderHandle = _handle;
Handle = new PlatformHandle(_handle, "XID"); Handle = new SurfacePlatformHandle(this);
_realSize = new PixelSize(defaultWidth, defaultHeight); _realSize = new PixelSize(defaultWidth, defaultHeight);
platform.Windows[_handle] = OnEvent; platform.Windows[_handle] = OnEvent;
XEventMask ignoredMask = XEventMask.SubstructureRedirectMask XEventMask ignoredMask = XEventMask.SubstructureRedirectMask
@ -169,7 +169,9 @@ namespace Avalonia.X11
if (glx != null) if (glx != null)
surfaces.Insert(0, new GlxGlPlatformSurface(glx.Display, glx.DeferredContext, surfaces.Insert(0, new GlxGlPlatformSurface(glx.Display, glx.DeferredContext,
new SurfaceInfo(this, _x11.Display, _handle, _renderHandle))); new SurfaceInfo(this, _x11.Display, _handle, _renderHandle)));
surfaces.Add(Handle);
Surfaces = surfaces.ToArray(); Surfaces = surfaces.ToArray();
UpdateMotifHints(); UpdateMotifHints();
UpdateSizeHints(null); UpdateSizeHints(null);
@ -1142,5 +1144,23 @@ namespace Avalonia.X11
public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = new AcrylicPlatformCompensationLevels(1, 0.8, 0.8); public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = new AcrylicPlatformCompensationLevels(1, 0.8, 0.8);
public bool NeedsManagedDecorations => false; public bool NeedsManagedDecorations => false;
public class SurfacePlatformHandle : IPlatformNativeSurfaceHandle
{
private readonly X11Window _owner;
public PixelSize Size => _owner.ToPixelSize(_owner.ClientSize);
public double Scaling => _owner.RenderScaling;
public SurfacePlatformHandle(X11Window owner)
{
_owner = owner;
}
public IntPtr Handle => _owner._renderHandle;
public string? HandleDescriptor => "XID";
}
} }
} }

8
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -459,7 +459,7 @@ namespace Avalonia.Win32
} }
} }
public IEnumerable<object> Surfaces => new object[] { Handle, _gl, _framebuffer }; public IEnumerable<object> Surfaces => new object[] { (IPlatformNativeSurfaceHandle)Handle, _gl, _framebuffer };
public PixelPoint Position public PixelPoint Position
{ {
@ -1383,12 +1383,16 @@ namespace Avalonia.Win32
public ITextInputMethodImpl TextInputMethod => Imm32InputMethod.Current; public ITextInputMethodImpl TextInputMethod => Imm32InputMethod.Current;
private class WindowImplPlatformHandle : IPlatformHandle private class WindowImplPlatformHandle : IPlatformNativeSurfaceHandle
{ {
private readonly WindowImpl _owner; private readonly WindowImpl _owner;
public WindowImplPlatformHandle(WindowImpl owner) => _owner = owner; public WindowImplPlatformHandle(WindowImpl owner) => _owner = owner;
public IntPtr Handle => _owner.Hwnd; public IntPtr Handle => _owner.Hwnd;
public string HandleDescriptor => PlatformConstants.WindowHandleType; public string HandleDescriptor => PlatformConstants.WindowHandleType;
public PixelSize Size => PixelSize.FromSize(_owner.ClientSize, Scaling);
public double Scaling => _owner.RenderScaling;
} }
} }
} }

Loading…
Cancel
Save