From e18aed318add6afe10b3c4db1ffb7dbd65b11e5a Mon Sep 17 00:00:00 2001 From: KRKT Date: Tue, 20 Aug 2024 14:16:49 +0800 Subject: [PATCH 1/9] Adapt to macOS UI Menu adaptation not yet completed --- TuneLab/UI/MainWindow/MainWindow.axaml.cs | 49 +++++++++++++++-------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/TuneLab/UI/MainWindow/MainWindow.axaml.cs b/TuneLab/UI/MainWindow/MainWindow.axaml.cs index 252e5e0..3bdd864 100644 --- a/TuneLab/UI/MainWindow/MainWindow.axaml.cs +++ b/TuneLab/UI/MainWindow/MainWindow.axaml.cs @@ -1,4 +1,4 @@ -using Avalonia; +using Avalonia; using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Media; @@ -30,6 +30,14 @@ public partial class MainWindow : Window public MainWindow() { InitializeComponent(); + // if macOS + if (PlatformHelper.GetOS() == "osx") + { + ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.PreferSystemChrome; + CustomTitleBar.Height = 28; + ExtendClientAreaTitleBarHeightHint = 28; + } + platform = Environment.OSVersion.Platform; WindowStartupLocation = WindowStartupLocation.CenterScreen; @@ -43,24 +51,28 @@ public MainWindow() Background = Style.BACK.ToBrush(); Content.Margin = new(1, 0); - var binimizeButton = new Button() { Width = 48, Height = 40 } - .AddContent(new() { Item = new BorderItem() { CornerRadius = 0 }, ColorSet = new() { HoveredColor = Colors.White.Opacity(0.2), PressedColor = Colors.White.Opacity(0.2) } }) - .AddContent(new() { Item = new IconItem() { Icon = Assets.WindowMin }, ColorSet = new() { Color = Style.TEXT_LIGHT.Opacity(0.7) } }); - binimizeButton.Clicked += () => WindowState = WindowState.Minimized; + // if not macOS + if (PlatformHelper.GetOS() != "osx") + { + var binimizeButton = new Button() { Width = 48, Height = 40 } + .AddContent(new() { Item = new BorderItem() { CornerRadius = 0 }, ColorSet = new() { HoveredColor = Colors.White.Opacity(0.2), PressedColor = Colors.White.Opacity(0.2) } }) + .AddContent(new() { Item = new IconItem() { Icon = Assets.WindowMin }, ColorSet = new() { Color = Style.TEXT_LIGHT.Opacity(0.7) } }); + binimizeButton.Clicked += () => WindowState = WindowState.Minimized; - maximizeButton = new Button() { Width = 48, Height = 40 } - .AddContent(new() { Item = new BorderItem() { CornerRadius = 0 }, ColorSet = new() { HoveredColor = Colors.White.Opacity(0.2), PressedColor = Colors.White.Opacity(0.2) } }) - .AddContent(maximizeIconContent); - maximizeButton.Clicked += () => WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; + maximizeButton = new Button() { Width = 48, Height = 40 } + .AddContent(new() { Item = new BorderItem() { CornerRadius = 0 }, ColorSet = new() { HoveredColor = Colors.White.Opacity(0.2), PressedColor = Colors.White.Opacity(0.2) } }) + .AddContent(maximizeIconContent); + maximizeButton.Clicked += () => WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; - var closeButton = new Button() { Width = 48, Height = 40 } - .AddContent(new() { Item = new BorderItem() { CornerRadius = 0 }, ColorSet = new() { HoveredColor = new(255, 232, 17, 35), PressedColor = new(255, 232, 17, 35) } }) - .AddContent(new() { Item = new IconItem() { Icon = Assets.WindowClose }, ColorSet = new() { Color = Style.TEXT_LIGHT.Opacity(0.7) } }); - closeButton.Clicked += () => Close(); + var closeButton = new Button() { Width = 48, Height = 40 } + .AddContent(new() { Item = new BorderItem() { CornerRadius = 0 }, ColorSet = new() { HoveredColor = new(255, 232, 17, 35), PressedColor = new(255, 232, 17, 35) } }) + .AddContent(new() { Item = new IconItem() { Icon = Assets.WindowClose }, ColorSet = new() { Color = Style.TEXT_LIGHT.Opacity(0.7) } }); + closeButton.Clicked += () => Close(); - WindowControl.Children.Add(binimizeButton); - WindowControl.Children.Add(maximizeButton); - WindowControl.Children.Add(closeButton); + WindowControl.Children.Add(binimizeButton); + WindowControl.Children.Add(maximizeButton); + WindowControl.Children.Add(closeButton); + } this.AttachWindowStateHandler(); @@ -69,7 +81,10 @@ public MainWindow() mEditor = new Editor(); mEditor.Document.ProjectNameChanged.Subscribe(UpdateTitle); mEditor.Document.StatusChanged += UpdateTitle; - MenuBar.Children.Add(mEditor.Menu); + + // if not macOS + if (PlatformHelper.GetOS() != "osx") + MenuBar.Children.Add(mEditor.Menu); var dockPanelEditor = new DockPanel(); From 8ab39233dfe7812141a1c356f0e2b9e47269d6e9 Mon Sep 17 00:00:00 2001 From: KRKT Date: Tue, 20 Aug 2024 15:31:11 +0800 Subject: [PATCH 2/9] Update TuneLab.csproj --- TuneLab/TuneLab.csproj | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/TuneLab/TuneLab.csproj b/TuneLab/TuneLab.csproj index ff4d063..b10a448 100644 --- a/TuneLab/TuneLab.csproj +++ b/TuneLab/TuneLab.csproj @@ -1,4 +1,4 @@ - + WinExe + TuneLab + TuneLab + app.tunelab.editor + 1.5.4 + 1.5.4 + APPL + ???? + TuneLab + + NSApplication + true @@ -37,6 +50,7 @@ + From da8a6f7b4de6db5b2f287de6a95ae08b30c26afe Mon Sep 17 00:00:00 2001 From: KRKT Date: Tue, 20 Aug 2024 15:31:50 +0800 Subject: [PATCH 3/9] Update TuneLab.Base.csproj --- TuneLab.Base/TuneLab.Base.csproj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/TuneLab.Base/TuneLab.Base.csproj b/TuneLab.Base/TuneLab.Base.csproj index fa71b7a..8c1cdaf 100644 --- a/TuneLab.Base/TuneLab.Base.csproj +++ b/TuneLab.Base/TuneLab.Base.csproj @@ -1,9 +1,14 @@ - + net8.0 enable enable + + 1.0.0 + + + From 6dc5e0746ba435882818fa563b3a552ee258df49 Mon Sep 17 00:00:00 2001 From: KRKT Date: Tue, 20 Aug 2024 15:32:37 +0800 Subject: [PATCH 4/9] Update ExtensionInstaller.csproj --- ExtensionInstaller/ExtensionInstaller.csproj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ExtensionInstaller/ExtensionInstaller.csproj b/ExtensionInstaller/ExtensionInstaller.csproj index 4305428..68b9caf 100644 --- a/ExtensionInstaller/ExtensionInstaller.csproj +++ b/ExtensionInstaller/ExtensionInstaller.csproj @@ -1,4 +1,4 @@ - + Exe @@ -6,6 +6,11 @@ enable enable ..\TuneLab\bin + + 1.0.0 + + + From 62d6d10d5d16fcb5a3c185d514052b618dac7c03 Mon Sep 17 00:00:00 2001 From: KRKT Date: Tue, 20 Aug 2024 15:33:04 +0800 Subject: [PATCH 5/9] Update TuneLab.Extensions.Voices.csproj --- TuneLab.Extensions.Voices/TuneLab.Extensions.Voices.csproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TuneLab.Extensions.Voices/TuneLab.Extensions.Voices.csproj b/TuneLab.Extensions.Voices/TuneLab.Extensions.Voices.csproj index 412f921..97a0f10 100644 --- a/TuneLab.Extensions.Voices/TuneLab.Extensions.Voices.csproj +++ b/TuneLab.Extensions.Voices/TuneLab.Extensions.Voices.csproj @@ -1,13 +1,16 @@ - + net8.0 enable enable + + 1.0.0 + From a3337d0df95e72996d9e433faf1f9b8c45530717 Mon Sep 17 00:00:00 2001 From: KRKT Date: Tue, 20 Aug 2024 15:33:25 +0800 Subject: [PATCH 6/9] Update TuneLab.Extensions.Formats.csproj --- TuneLab.Extensions.Formats/TuneLab.Extensions.Formats.csproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TuneLab.Extensions.Formats/TuneLab.Extensions.Formats.csproj b/TuneLab.Extensions.Formats/TuneLab.Extensions.Formats.csproj index 412f921..97a0f10 100644 --- a/TuneLab.Extensions.Formats/TuneLab.Extensions.Formats.csproj +++ b/TuneLab.Extensions.Formats/TuneLab.Extensions.Formats.csproj @@ -1,13 +1,16 @@ - + net8.0 enable enable + + 1.0.0 + From e71854912143dfc05d750ca62de97d27799d5584 Mon Sep 17 00:00:00 2001 From: KRKT Date: Tue, 20 Aug 2024 15:46:44 +0800 Subject: [PATCH 7/9] Fix Ext Install Error --- TuneLab/UI/MainWindow/Editor/Editor.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TuneLab/UI/MainWindow/Editor/Editor.cs b/TuneLab/UI/MainWindow/Editor/Editor.cs index 5d261c9..ef18823 100644 --- a/TuneLab/UI/MainWindow/Editor/Editor.cs +++ b/TuneLab/UI/MainWindow/Editor/Editor.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -40,6 +40,7 @@ namespace TuneLab.UI; internal class Editor : DockPanel, PianoWindow.IDependency, TrackWindow.IDependency { public Menu Menu { get; } + public NativeMenu NativeMenu { get; } public TrackWindow TrackWindow => mTrackWindow; public PianoWindow PianoWindow => mPianoWindow; public ProjectDocument Document => mDocument; @@ -646,7 +647,7 @@ public async void InstallExtensions(IEnumerable files) { List args = ["-restart"]; args.AddRange(installedExtension); - ProcessHelper.CreateProcess(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExtensionInstaller.exe"), args); + ProcessHelper.CreateProcess(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PlatformHelper.GetOS() == "win" ? "ExtensionInstaller.exe" : "ExtensionInstaller"), args); this.Window().Close(); }; dialog.AddButton("No".Tr(TC.Dialog), ButtonType.Primary); From 286891a04f5ca45bf24a054fc847726bd9df40c7 Mon Sep 17 00:00:00 2001 From: KRKT Date: Tue, 20 Aug 2024 16:23:46 +0800 Subject: [PATCH 8/9] Fix Ext Install Error --- ExtensionInstaller/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ExtensionInstaller/Program.cs b/ExtensionInstaller/Program.cs index 4fe5723..3135c6f 100644 --- a/ExtensionInstaller/Program.cs +++ b/ExtensionInstaller/Program.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.IO.Compression; using System.Runtime.InteropServices; using System.Text.Json; @@ -67,7 +67,7 @@ static void Main(string[] args) Console.WriteLine(name + " has been successfully installed!\n"); } - if (restart) Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TuneLab.exe")); + if (restart) Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "TuneLab.exe" : "TuneLab")); } catch (Exception ex) { From ecd310d041347074af2b07866aaadfa3d1b76743 Mon Sep 17 00:00:00 2001 From: KRKT Date: Tue, 20 Aug 2024 16:54:40 +0800 Subject: [PATCH 9/9] Disable font specification for non Windows platforms --- TuneLab/Program.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/TuneLab/Program.cs b/TuneLab/Program.cs index 1edde0d..3f25904 100644 --- a/TuneLab/Program.cs +++ b/TuneLab/Program.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.IO; using System.Linq; @@ -55,13 +55,16 @@ public static AppBuilder BuildAvaloniaApp() { GC.KeepAlive(typeof(Avalonia.Svg.Skia.SvgImageExtension).Assembly); GC.KeepAlive(typeof(Avalonia.Svg.Skia.Svg).Assembly); - return AppBuilder.Configure() + var appBuilder = AppBuilder.Configure() .UsePlatformDetect() .UseSkia() .WithInterFont() .LogToTrace() - .UseReactiveUI() - .With(new FontManagerOptions() + .UseReactiveUI(); + + if (PlatformHelper.GetOS() == "win") + { + return appBuilder.With(new FontManagerOptions() { FontFallbacks = [ @@ -70,5 +73,8 @@ public static AppBuilder BuildAvaloniaApp() new FontFallback() { FontFamily = "Microsoft YaHei" }, ] }); + } + + return appBuilder; } }