diff --git a/native/Avalonia.Native/src/OSX/WindowImpl.mm b/native/Avalonia.Native/src/OSX/WindowImpl.mm index 104611eabc..925880534a 100644 --- a/native/Avalonia.Native/src/OSX/WindowImpl.mm +++ b/native/Avalonia.Native/src/OSX/WindowImpl.mm @@ -281,10 +281,13 @@ HRESULT WindowImpl::SetDecorations(SystemDecorations value) { case SystemDecorationsFull: [Window setHasShadow:YES]; - [Window setTitleVisibility:NSWindowTitleVisible]; - [Window setTitlebarAppearsTransparent:NO]; [Window setTitle:_lastTitle]; + if (!_isClientAreaExtended) { + [Window setTitleVisibility:NSWindowTitleVisible]; + [Window setTitlebarAppearsTransparent:NO]; + } + if (currentWindowState == Maximized) { auto newFrame = [Window contentRectForFrameRect:[Window frame]].size; @@ -611,7 +614,8 @@ void WindowImpl::UpdateStyle() { } bool wantsChrome = (_extendClientHints & AvnSystemChrome) || (_extendClientHints & AvnPreferSystemChrome); - bool hasTrafficLights = _isClientAreaExtended ? wantsChrome : _decorations == SystemDecorationsFull; + bool hasTrafficLights = (_decorations == SystemDecorationsFull) && + (_isClientAreaExtended ? wantsChrome : true); NSButton* closeButton = [Window standardWindowButton:NSWindowCloseButton]; NSButton* miniaturizeButton = [Window standardWindowButton:NSWindowMiniaturizeButton]; diff --git a/samples/ControlCatalog/Pages/ClipboardPage.xaml.cs b/samples/ControlCatalog/Pages/ClipboardPage.xaml.cs index ef3d2bbafa..b6b2ac7181 100644 --- a/samples/ControlCatalog/Pages/ClipboardPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ClipboardPage.xaml.cs @@ -1,16 +1,23 @@ using System; using System.Collections.Generic; - +using System.Linq; using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.Notifications; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Markup.Xaml; +using Avalonia.Platform; +using Avalonia.Platform.Storage; +using Avalonia.Platform.Storage.FileIO; namespace ControlCatalog.Pages { public partial class ClipboardPage : UserControl { + private INotificationManager? _notificationManager; + private INotificationManager NotificationManager => _notificationManager + ??= new WindowNotificationManager(TopLevel.GetTopLevel(this)!); public ClipboardPage() { InitializeComponent(); @@ -31,7 +38,7 @@ namespace ControlCatalog.Pages private async void PasteText(object? sender, RoutedEventArgs args) { - if(Application.Current!.Clipboard is { } clipboard) + if (Application.Current!.Clipboard is { } clipboard) { ClipboardContent.Text = await clipboard.GetTextAsync(); } @@ -59,15 +66,45 @@ namespace ControlCatalog.Pages { if (Application.Current!.Clipboard is { } clipboard) { - var files = (ClipboardContent.Text ?? String.Empty) - .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); - if (files.Length == 0) + var storageProvider = TopLevel.GetTopLevel(this)!.StorageProvider; + var filesPath = (ClipboardContent.Text ?? string.Empty) + .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); + if (filesPath.Length == 0) { return; } - var dataObject = new DataObject(); - dataObject.Set(DataFormats.FileNames, files); - await clipboard.SetDataObjectAsync(dataObject); + List invalidFile = new(filesPath.Length); + List files = new(filesPath.Length); + + for (int i = 0; i < filesPath.Length; i++) + { + var file = await storageProvider.TryGetFileFromPathAsync(filesPath[i]); + if (file is null) + { + invalidFile.Add(filesPath[i]); + } + else + { + files.Add(file); + } + } + + if (invalidFile.Count > 0) + { + NotificationManager.Show(new Notification("Warning", "There is one o more invalid path.", NotificationType.Warning)); + } + + if (files.Count > 0) + { + var dataObject = new DataObject(); + dataObject.Set(DataFormats.Files, files); + await clipboard.SetDataObjectAsync(dataObject); + NotificationManager.Show(new Notification("Success", "Copy completated.", NotificationType.Success)); + } + else + { + NotificationManager.Show(new Notification("Warning", "Any files to copy in Clipboard.", NotificationType.Warning)); + } } } @@ -75,8 +112,9 @@ namespace ControlCatalog.Pages { if (Application.Current!.Clipboard is { } clipboard) { - var fiels = await clipboard.GetDataAsync(DataFormats.FileNames) as IEnumerable; - ClipboardContent.Text = fiels != null ? string.Join(Environment.NewLine, fiels) : string.Empty; + var files = await clipboard.GetDataAsync(DataFormats.Files) as IEnumerable; + + ClipboardContent.Text = files != null ? string.Join(Environment.NewLine, files.Select(f => f.TryGetLocalPath() ?? f.Name)) : string.Empty; } } @@ -95,7 +133,7 @@ namespace ControlCatalog.Pages { await clipboard.ClearAsync(); } - + } } } diff --git a/samples/ControlCatalog/Pages/CustomDrawingExampleControl.cs b/samples/ControlCatalog/Pages/CustomDrawingExampleControl.cs index db74be7c08..549cf3d740 100644 --- a/samples/ControlCatalog/Pages/CustomDrawingExampleControl.cs +++ b/samples/ControlCatalog/Pages/CustomDrawingExampleControl.cs @@ -133,17 +133,17 @@ namespace ControlCatalog.Pages // 0,0 refers to the top-left of the control now. It is not prime time to draw gui stuff because it'll be under the world - var translateModifier = context.PushPreTransform(Avalonia.Matrix.CreateTranslation(new Avalonia.Vector(halfWidth, halfHeight))); + var translateModifier = context.PushTransform(Avalonia.Matrix.CreateTranslation(new Avalonia.Vector(halfWidth, halfHeight))); // now 0,0 refers to the ViewportCenter(X,Y). var rotationMatrix = Avalonia.Matrix.CreateRotation(Rotation); - var rotationModifier = context.PushPreTransform(rotationMatrix); + var rotationModifier = context.PushTransform(rotationMatrix); // everything is rotated but not scaled - var scaleModifier = context.PushPreTransform(Avalonia.Matrix.CreateScale(Scale, -Scale)); + var scaleModifier = context.PushTransform(Avalonia.Matrix.CreateScale(Scale, -Scale)); - var mapPositionModifier = context.PushPreTransform(Matrix.CreateTranslation(new Vector(-ViewportCenterX, -ViewportCenterY))); + var mapPositionModifier = context.PushTransform(Matrix.CreateTranslation(new Vector(-ViewportCenterX, -ViewportCenterY))); // now everything is rotated and scaled, and at the right position, now we're drawing strictly in world coordinates diff --git a/samples/IntegrationTestApp/MainWindow.axaml b/samples/IntegrationTestApp/MainWindow.axaml index 98be4f4911..95378ed717 100644 --- a/samples/IntegrationTestApp/MainWindow.axaml +++ b/samples/IntegrationTestApp/MainWindow.axaml @@ -151,6 +151,12 @@ Maximized FullScreen + + None + BorderOnly + Full + + ExtendClientAreaToDecorationsHint Can Resize diff --git a/samples/IntegrationTestApp/MainWindow.axaml.cs b/samples/IntegrationTestApp/MainWindow.axaml.cs index 19eb1d64b0..c9c7939c1c 100644 --- a/samples/IntegrationTestApp/MainWindow.axaml.cs +++ b/samples/IntegrationTestApp/MainWindow.axaml.cs @@ -68,6 +68,8 @@ namespace IntegrationTestApp var locationComboBox = this.GetControl("ShowWindowLocation"); var stateComboBox = this.GetControl("ShowWindowState"); var size = !string.IsNullOrWhiteSpace(sizeTextBox.Text) ? Size.Parse(sizeTextBox.Text) : (Size?)null; + var systemDecorations = this.GetControl("ShowWindowSystemDecorations"); + var extendClientArea = this.GetControl("ShowWindowExtendClientAreaToDecorationsHint"); var canResizeCheckBox = this.GetControl("ShowWindowCanResize"); var owner = (Window)this.GetVisualRoot()!; @@ -95,6 +97,8 @@ namespace IntegrationTestApp } sizeTextBox.Text = string.Empty; + window.ExtendClientAreaToDecorationsHint = extendClientArea.IsChecked ?? false; + window.SystemDecorations = (SystemDecorations)systemDecorations.SelectedIndex; window.WindowState = (WindowState)stateComboBox.SelectedIndex; switch (modeComboBox.SelectedIndex) @@ -158,7 +162,7 @@ namespace IntegrationTestApp var popup = new Popup { WindowManagerAddShadowHint = false, - PlacementMode = PlacementMode.AnchorAndGravity, + Placement = PlacementMode.AnchorAndGravity, PlacementAnchor = PopupAnchor.Top, PlacementGravity = PopupGravity.Bottom, Width= 200, diff --git a/samples/IntegrationTestApp/ShowWindowTest.axaml b/samples/IntegrationTestApp/ShowWindowTest.axaml index bd6910dd4d..720ff6c344 100644 --- a/samples/IntegrationTestApp/ShowWindowTest.axaml +++ b/samples/IntegrationTestApp/ShowWindowTest.axaml @@ -6,7 +6,7 @@ x:DataType="Window" Title="Show Window Test"> - + @@ -35,13 +35,25 @@ FullScreen - - + + + None + BorderOnly + Full + + + + ExtendClientAreaToDecorationsHint + + + + -