Skip to content

Commit 93fb4fc

Browse files
committed
ux: titlebar button position on macOS in full-screen mode
Signed-off-by: leo <longshuang@msn.cn>
1 parent 1a2dc87 commit 93fb4fc

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/Views/Launcher.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<!-- Caption Buttons (macOS) -->
3131
<v:MacOSTrafficLightsSpacer Grid.Column="0"
3232
Zoom="{Binding Source={x:Static vm:Preferences.Instance}, Path=Zoom, Mode=OneWay}"
33-
IsVisible="{Binding #ThisControl.HasLeftCaptionButton}"/>
33+
IsFullScreen="{Binding !#ThisControl.HasLeftCaptionButton, Mode=OneWay}"/>
3434

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

src/Views/MacOSTrafficLightsSpacer.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ public double Zoom
1818
set => SetAndRaise(ZoomProperty, ref _zoom, value);
1919
}
2020

21+
public static readonly DirectProperty<MacOSTrafficLightsSpacer, bool> IsFullScreenProperty =
22+
AvaloniaProperty.RegisterDirect<MacOSTrafficLightsSpacer, bool>(
23+
nameof(IsFullScreen),
24+
o => o.IsFullScreen,
25+
(o, v) => o.IsFullScreen = v);
26+
27+
public bool IsFullScreen
28+
{
29+
get => _isFullScreen;
30+
set => SetAndRaise(IsFullScreenProperty, ref _isFullScreen, value);
31+
}
32+
2133
public MacOSTrafficLightsSpacer()
2234
{
2335
IsHitTestVisible = false;
@@ -27,15 +39,19 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
2739
{
2840
base.OnPropertyChanged(change);
2941

30-
if (change.Property == ZoomProperty)
42+
if (change.Property == ZoomProperty || change.Property == IsFullScreenProperty)
3143
InvalidateMeasure();
3244
}
3345

3446
protected override Size MeasureOverride(Size availableSize)
3547
{
36-
return new Size(76.0 / Math.Max(_zoom, 1.0), 24.0);
48+
if (!OperatingSystem.IsMacOS())
49+
return new Size(0, 0);
50+
51+
return _isFullScreen ? new Size(4, 24) : new Size(76.0 / Math.Max(_zoom, 1.0), 24.0);
3752
}
3853

3954
private double _zoom = 1.0;
55+
private bool _isFullScreen = false;
4056
}
4157
}

0 commit comments

Comments
 (0)