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