Pārlūkot izejas kodu

Some ui fixes for macos

Krzysztof Krysiński 1 mēnesi atpakaļ
vecāks
revīzija
2e1790a52c

+ 1 - 8
src/PixiEditor/Views/Main/MainTitleBar.axaml

@@ -32,7 +32,7 @@
                     </StackPanel>
                 </dialogs:DialogTitleBar.AdditionalElement>
             </dialogs:DialogTitleBar>
-            <Panel DockPanel.Dock="Left"
+            <Panel DockPanel.Dock="Left" Name="LogoPanel"
                    HorizontalAlignment="Left" Width="20" Height="20">
                 <Panel.Margin>
                     <OnPlatform>
@@ -150,13 +150,6 @@
             </Panel>
 
             <StackPanel Orientation="Horizontal">
-                <StackPanel.Margin>
-                    <OnPlatform>
-                        <OnPlatform.macOS>
-                            <Thickness>95, 0, 0, 0</Thickness>
-                        </OnPlatform.macOS>
-                    </OnPlatform>
-                </StackPanel.Margin>
                 <xaml:Menu IsVisible="{OnPlatform macOS=false, Default=true}"
                            Margin="5, 0, 0, 0"
                            DockPanel.Dock="Left"

+ 17 - 0
src/PixiEditor/Views/Main/MainTitleBar.axaml.cs

@@ -12,6 +12,7 @@ public partial class MainTitleBar : UserControl
 {
 
     private MiniAnimationPlayer miniPlayer;
+    private Panel logoPanel;
     public MainTitleBar()
     {
         InitializeComponent();
@@ -26,6 +27,22 @@ public partial class MainTitleBar : UserControl
     {
         base.OnLoaded(e);
         miniPlayer = this.FindControl<MiniAnimationPlayer>("MiniPlayer");
+        logoPanel = this.FindControl<Panel>("LogoPanel");
+
+        if (IOperatingSystem.Current.IsMacOs && VisualRoot is Window window && logoPanel != null)
+        {
+            window.PropertyChanged += OnPropertyChanged;
+        }
+    }
+
+    private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
+    {
+        if (e.Property.Name == nameof(Window.WindowState) && logoPanel != null)
+        {
+            logoPanel.Margin = e.NewValue is WindowState and WindowState.FullScreen
+                ? new Thickness(10, 0, 0, 0)
+                : new Thickness(75, 0, 0, 0);
+        }
     }
 
     protected override void OnSizeChanged(SizeChangedEventArgs e)