Skip to content

Commit 36b3a51

Browse files
committed
ux: ignore zoom for left caption buttons on macOS
Signed-off-by: leo <[email protected]>
1 parent d0fe053 commit 36b3a51

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Views/ChromelessWindow.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ namespace SourceGit.Views
88
{
99
public class ChromelessWindow : Window
1010
{
11+
public static readonly StyledProperty<double> LeftCaptionButtonWidthProperty =
12+
AvaloniaProperty.Register<ChromelessWindow, double>(nameof(LeftCaptionButtonWidth), 72.0);
13+
14+
public double LeftCaptionButtonWidth
15+
{
16+
get => GetValue(LeftCaptionButtonWidthProperty);
17+
set => SetValue(LeftCaptionButtonWidthProperty, value);
18+
}
19+
1120
public bool UseSystemWindowFrame
1221
{
1322
get => Native.OS.UseSystemWindowFrame;
@@ -23,6 +32,7 @@ public bool CloseOnESC
2332

2433
public ChromelessWindow()
2534
{
35+
LeftCaptionButtonWidth = 72.0 / Math.Max(1.0, ViewModels.Preferences.Instance.Zoom);
2636
Focusable = true;
2737
Native.OS.SetupForWindow(this);
2838
}
@@ -113,12 +123,14 @@ protected override void OnKeyDown(KeyEventArgs e)
113123
{
114124
var zoom = Math.Min(ViewModels.Preferences.Instance.Zoom + 0.05, 2.5);
115125
ViewModels.Preferences.Instance.Zoom = zoom;
126+
LeftCaptionButtonWidth = 72.0 / zoom;
116127
e.Handled = true;
117128
}
118129
else if (e.Key == Key.OemMinus)
119130
{
120131
var zoom = Math.Max(ViewModels.Preferences.Instance.Zoom - 0.05, 1);
121132
ViewModels.Preferences.Instance.Zoom = zoom;
133+
LeftCaptionButtonWidth = 72.0 / zoom;
122134
e.Handled = true;
123135
}
124136
}

src/Views/Launcher.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
PointerPressed="BeginMoveWindow"/>
2929

3030
<!-- Caption Buttons (macOS) -->
31-
<Border Grid.Column="0" Width="72" IsVisible="{Binding #ThisControl.HasLeftCaptionButton}"/>
31+
<Border Grid.Column="0" Width="{Binding #ThisControl.LeftCaptionButtonWidth}" IsVisible="{Binding #ThisControl.HasLeftCaptionButton}"/>
3232

3333
<!-- Menu (Windows/Linux) -->
3434
<Button Grid.Column="0" Classes="icon_button" VerticalAlignment="Bottom" Margin="6,0,0,3" IsVisible="{OnPlatform True, macOS=False}">

0 commit comments

Comments
 (0)