mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-10-31 03:59:58 +01:00
Pad the top bar down on Windows instead of the right cluster
The 146px right margin pushed the version and social icons inwards on every window width. Padding the whole bar down by the caption height gives the OS buttons a strip of their own and leaves the cluster where it was; the strip drags the window, so the handler moves to the bar's border.
This commit is contained in:
@@ -21,19 +21,18 @@
|
|||||||
<DockPanel LastChildFill="True">
|
<DockPanel LastChildFill="True">
|
||||||
|
|
||||||
<!-- ── Top bar: logo, navigation and the right cluster in one row.
|
<!-- ── Top bar: logo, navigation and the right cluster in one row.
|
||||||
The OS minimise / maximise / close buttons render over its top-right
|
On Windows the OS caption buttons are drawn over the top of the
|
||||||
corner (see RightCluster). -->
|
extended client area, so TopBar is padded down to clear them
|
||||||
<Border DockPanel.Dock="Top"
|
(see the constructor); the free strip drags the window. -->
|
||||||
|
<Border x:Name="TopBar" DockPanel.Dock="Top"
|
||||||
Background="{StaticResource CarbonPanelBg}"
|
Background="{StaticResource CarbonPanelBg}"
|
||||||
BorderBrush="{StaticResource CarbonBorderLight}"
|
BorderBrush="{StaticResource CarbonBorderLight}"
|
||||||
BorderThickness="0,0,0,1">
|
BorderThickness="0,0,0,1"
|
||||||
|
PointerPressed="TitleBar_OnPointerPressed">
|
||||||
<Grid RowDefinitions="48">
|
<Grid RowDefinitions="48">
|
||||||
|
|
||||||
<!-- Logo + navigation (left) and the right cluster (right) -->
|
<!-- Logo + navigation (left) and the right cluster (right) -->
|
||||||
<!-- Drag-to-move handled by PointerPressed on parent grid -->
|
<Grid ColumnDefinitions="Auto,Auto,*,Auto" Background="Transparent">
|
||||||
<Grid ColumnDefinitions="Auto,Auto,*,Auto"
|
|
||||||
Background="Transparent"
|
|
||||||
PointerPressed="TitleBar_OnPointerPressed">
|
|
||||||
|
|
||||||
<!-- Logo -->
|
<!-- Logo -->
|
||||||
<Image Grid.Column="0" Source="/Assets/Logo/maszyna_white.png"
|
<Image Grid.Column="0" Source="/Assets/Logo/maszyna_white.png"
|
||||||
@@ -65,10 +64,8 @@
|
|||||||
HorizontalContentAlignment="Center" />
|
HorizontalContentAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Right cluster: version, language, social links. On Windows
|
<!-- Right cluster: version, language, social links. -->
|
||||||
the OS caption buttons are drawn over this corner, so the
|
<StackPanel Grid.Column="3" Orientation="Horizontal"
|
||||||
margin is widened in code-behind to clear them. -->
|
|
||||||
<StackPanel x:Name="RightCluster" Grid.Column="3" Orientation="Horizontal"
|
|
||||||
VerticalAlignment="Center" Margin="0,0,8,0" Spacing="4">
|
VerticalAlignment="Center" Margin="0,0,8,0" Spacing="4">
|
||||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center" Margin="0,0,8,0">
|
<StackPanel Orientation="Vertical" VerticalAlignment="Center" Margin="0,0,8,0">
|
||||||
<Label Content="{Binding [Version], Source={x:Static starterNg:App.Loc}}"
|
<Label Content="{Binding [Version], Source={x:Static starterNg:App.Loc}}"
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ namespace StarterNG;
|
|||||||
|
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
// Height of the caption strip the OS buttons live in.
|
||||||
|
private const int TitleBarHeight = 32;
|
||||||
|
|
||||||
private DateTime _openedUtc = DateTime.UtcNow;
|
private DateTime _openedUtc = DateTime.UtcNow;
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
@@ -33,13 +36,13 @@ public partial class MainWindow : Window
|
|||||||
// caption buttons, so only the two supported hints are set here (this
|
// caption buttons, so only the two supported hints are set here (this
|
||||||
// Avalonia build no longer exposes ExtendClientAreaChromeHints).
|
// Avalonia build no longer exposes ExtendClientAreaChromeHints).
|
||||||
ExtendClientAreaToDecorationsHint = true;
|
ExtendClientAreaToDecorationsHint = true;
|
||||||
ExtendClientAreaTitleBarHeightHint = 32;
|
ExtendClientAreaTitleBarHeightHint = TitleBarHeight;
|
||||||
|
|
||||||
// Windows draws the min / max / close buttons over the top-right corner of
|
// Windows draws the min / max / close buttons over the top of the extended
|
||||||
// the extended client area, on top of the version + social cluster. Keep
|
// client area, on top of the toolbar row. Push the bar down by the caption
|
||||||
// that corner free (3 buttons at the default 46px, plus a little air).
|
// height so they get a strip of their own.
|
||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
RightCluster.Margin = new Thickness(0, 0, 146, 0);
|
TopBar.Padding = new Thickness(0, TitleBarHeight, 0, 0);
|
||||||
|
|
||||||
PopulateLangCombo();
|
PopulateLangCombo();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user