refactor: rewrite chromeless window (#634)

* use system chrome instead of custom caption button on macOS
* move `BeginMoveWindow` and `MaximizeOrRestoreWindow` to `ChromelessWindow`
* better supports for fullscreen mode on macOS
* redesign the layout of title bar for all windows

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-10-31 21:36:51 +08:00
parent 1999e4bf47
commit e3c0f7d496
No known key found for this signature in database
44 changed files with 222 additions and 664 deletions

View file

@ -71,9 +71,6 @@
<StreamGeometry x:Key="Icons.Loading">M512 0C233 0 7 223 0 500C6 258 190 64 416 64c230 0 416 200 416 448c0 53 43 96 96 96s96-43 96-96c0-283-229-512-512-512zm0 1023c279 0 505-223 512-500c-6 242-190 436-416 436c-230 0-416-200-416-448c0-53-43-96-96-96s-96 43-96 96c0 283 229 512 512 512z</StreamGeometry> <StreamGeometry x:Key="Icons.Loading">M512 0C233 0 7 223 0 500C6 258 190 64 416 64c230 0 416 200 416 448c0 53 43 96 96 96s96-43 96-96c0-283-229-512-512-512zm0 1023c279 0 505-223 512-500c-6 242-190 436-416 436c-230 0-416-200-416-448c0-53-43-96-96-96s-96 43-96 96c0 283 229 512 512 512z</StreamGeometry>
<StreamGeometry x:Key="Icons.Local">M976 0h-928A48 48 0 000 48v652a48 48 0 0048 48h416V928H200a48 48 0 000 96h624a48 48 0 000-96H560v-180h416a48 48 0 0048-48V48A48 48 0 00976 0zM928 652H96V96h832v556z</StreamGeometry> <StreamGeometry x:Key="Icons.Local">M976 0h-928A48 48 0 000 48v652a48 48 0 0048 48h416V928H200a48 48 0 000 96h624a48 48 0 000-96H560v-180h416a48 48 0 0048-48V48A48 48 0 00976 0zM928 652H96V96h832v556z</StreamGeometry>
<StreamGeometry x:Key="Icons.Lock">M832 464h-68V240a128 128 0 00-128-128h-248a128 128 0 00-128 128v224H192c-18 0-32 14-32 32v384c0 18 14 32 32 32h640c18 0 32-14 32-32v-384c0-18-14-32-32-32zm-292 237v53a8 8 0 01-8 8h-40a8 8 0 01-8-8v-53a48 48 0 1156 0zm152-237H332V240a56 56 0 0156-56h248a56 56 0 0156 56v224z</StreamGeometry> <StreamGeometry x:Key="Icons.Lock">M832 464h-68V240a128 128 0 00-128-128h-248a128 128 0 00-128 128v224H192c-18 0-32 14-32 32v384c0 18 14 32 32 32h640c18 0 32-14 32-32v-384c0-18-14-32-32-32zm-292 237v53a8 8 0 01-8 8h-40a8 8 0 01-8-8v-53a48 48 0 1156 0zm152-237H332V240a56 56 0 0156-56h248a56 56 0 0156 56v224z</StreamGeometry>
<StreamGeometry x:Key="Icons.MacOS.Close">M887 774 625 511l263-260c11-11 11-28 0-39l-75-75c-5-5-12-8-20-8-7 0-14 3-20 8L512 396 250 137c-5-5-12-8-20-8-7 0-14 3-20 8L136 212c-11 11-11 28 0 39l263 260L137 774c-5 5-8 12-8 20 0 7 3 14 8 20l75 75c5 5 12 8 20 8 7 0 14-3 20-8L512 626l261 262c5 5 12 8 20 8 7 0 14-3 20-8l75-75c5-5 8-12 8-20C895 786 892 779 887 774z</StreamGeometry>
<StreamGeometry x:Key="Icons.MacOS.Minimize">M1024 750v110c0 50-41 91-91 91h-841A92 92 0 010 859v-110C0 699 41 658 91 658h841c50 0 91 41 91 91z</StreamGeometry>
<StreamGeometry x:Key="Icons.MacOS.Maximize">M0 4 0 20 16 20 0 4M4 0 20 0 20 16 4 0z</StreamGeometry>
<StreamGeometry x:Key="Icons.Menu">M192 192m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM192 512m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM192 832m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM864 160H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32zM864 480H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32zM864 800H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32z</StreamGeometry> <StreamGeometry x:Key="Icons.Menu">M192 192m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM192 512m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM192 832m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM864 160H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32zM864 480H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32zM864 800H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32z</StreamGeometry>
<StreamGeometry x:Key="Icons.Merge">M824 645V307c0-56-46-102-102-102h-102V102l-154 154 154 154V307h102v338c-46 20-82 67-82 123 0 72 61 133 133 133 72 0 133-61 133-133 0-56-36-102-82-123zm-51 195c-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72s-31 72-72 72zM384 256c0-72-61-133-133-133-72 0-133 61-133 133 0 56 36 102 82 123v266C154 666 118 712 118 768c0 72 61 133 133 133 72 0 133-61 133-133 0-56-36-102-82-123V379C348 358 384 312 384 256zM323 768c0 41-31 72-72 72-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72zM251 328c-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72s-31 72-72 72z</StreamGeometry> <StreamGeometry x:Key="Icons.Merge">M824 645V307c0-56-46-102-102-102h-102V102l-154 154 154 154V307h102v338c-46 20-82 67-82 123 0 72 61 133 133 133 72 0 133-61 133-133 0-56-36-102-82-123zm-51 195c-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72s-31 72-72 72zM384 256c0-72-61-133-133-133-72 0-133 61-133 133 0 56 36 102 82 123v266C154 666 118 712 118 768c0 72 61 133 133 133 72 0 133-61 133-133 0-56-36-102-82-123V379C348 358 384 312 384 256zM323 768c0 41-31 72-72 72-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72zM251 328c-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72s-31 72-72 72z</StreamGeometry>
<StreamGeometry x:Key="Icons.Modified">M896 64H128C96 64 64 96 64 128v768c0 32 32 64 64 64h768c32 0 64-32 64-64V128c0-32-32-64-64-64z m-64 736c0 16-17 32-32 32H224c-18 0-32-12-32-32V224c0-16 16-32 32-32h576c15 0 32 16 32 32v576zM512 384c-71 0-128 57-128 128s57 128 128 128 128-57 128-128-57-128-128-128z</StreamGeometry> <StreamGeometry x:Key="Icons.Modified">M896 64H128C96 64 64 96 64 128v768c0 32 32 64 64 64h768c32 0 64-32 64-64V128c0-32-32-64-64-64z m-64 736c0 16-17 32-32 32H224c-18 0-32-12-32-32V224c0-16 16-32 32-32h576c15 0 32 16 32 32v576zM512 384c-71 0-128 57-128 128s57 128 128 128 128-57 128-128-57-128-128-128z</StreamGeometry>

View file

@ -15,30 +15,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,Auto,Auto"> <Grid RowDefinitions="Auto,Auto,Auto">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.AIAssist}" Data="{StaticResource Icons.AIAssist}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.AIAssistant}" Text="{DynamicResource Text.AIAssistant}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -4,7 +4,6 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Threading; using Avalonia.Threading;
namespace SourceGit.Views namespace SourceGit.Views
@ -55,11 +54,6 @@ namespace SourceGit.Views
_cancel.Cancel(); _cancel.Cancel();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void SetDescription(string message) private void SetDescription(string message)
{ {
Dispatcher.UIThread.Invoke(() => ProgressMessage.Text = message); Dispatcher.UIThread.Invoke(() => ProgressMessage.Text = message);

View file

@ -13,30 +13,23 @@
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
<Grid RowDefinitions="Auto,*"> <Grid RowDefinitions="Auto,*">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Info}" Data="{StaticResource Icons.Info}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3" <TextBlock Classes="bold"
Classes="bold"
Text="{DynamicResource Text.About}" Text="{DynamicResource Text.About}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -21,11 +21,6 @@ namespace SourceGit.Views
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void OnVisitAvaloniaUI(object _, PointerPressedEventArgs e) private void OnVisitAvaloniaUI(object _, PointerPressedEventArgs e)
{ {
Native.OS.OpenBrowser("https://www.avaloniaui.net/"); Native.OS.OpenBrowser("https://www.avaloniaui.net/");

View file

@ -13,30 +13,23 @@
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
<Grid RowDefinitions="Auto,*"> <Grid RowDefinitions="Auto,*">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Password}" Data="{StaticResource Icons.Password}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3" <TextBlock Classes="bold"
Classes="bold"
Text="{DynamicResource Text.Askpass}" Text="{DynamicResource Text.Askpass}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,7 +1,6 @@
using System; using System;
using Avalonia; using Avalonia;
using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
namespace SourceGit.Views namespace SourceGit.Views
@ -42,11 +41,6 @@ namespace SourceGit.Views
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void CloseWindow(object _1, RoutedEventArgs _2) private void CloseWindow(object _1, RoutedEventArgs _2)
{ {
Console.Out.WriteLine("No passphrase entered."); Console.Out.WriteLine("No passphrase entered.");

View file

@ -16,30 +16,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,*"> <Grid RowDefinitions="Auto,*">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.File.Ignore}" Data="{StaticResource Icons.File.Ignore}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.AssumeUnchanged}" Text="{DynamicResource Text.AssumeUnchanged}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,5 +1,4 @@
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
namespace SourceGit.Views namespace SourceGit.Views
@ -11,11 +10,6 @@ namespace SourceGit.Views
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void OnRemoveButtonClicked(object sender, RoutedEventArgs e) private void OnRemoveButtonClicked(object sender, RoutedEventArgs e)
{ {
if (DataContext is ViewModels.AssumeUnchangedManager vm && sender is Button button) if (DataContext is ViewModels.AssumeUnchangedManager vm && sender is Button button)

View file

@ -19,29 +19,26 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<!-- Bottom border --> <!-- Bottom border -->
<Border Grid.Column="0" Grid.ColumnSpan="4" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}"
DoubleTapped="MaximizeOrRestoreWindow" DoubleTapped="MaximizeOrRestoreWindow"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<!-- Caption Buttons (macOS) --> <Path Width="12" Height="12"
<Border Grid.Column="0" IsVisible="{OnPlatform False, macOS=True}"> Margin="10,0,0,0"
<v:CaptionButtonsMacOS/> HorizontalAlignment="Left"
</Border> Data="{StaticResource Icons.Blame}"
IsVisible="{OnPlatform True, macOS=False}"/>
<!-- Icon -->
<Path Grid.Column="1" Margin="8,0,0,0" Width="12" Height="12" Data="{StaticResource Icons.Blame}"/>
<!-- Title -->
<TextBlock Grid.Column="2" Margin="8,0,0,0" Text="{DynamicResource Text.Blame}" FontWeight="Bold" IsHitTestVisible="False" VerticalAlignment="Center"/>
<TextBlock Classes="bold"
Text="{DynamicResource Text.Blame}"
HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/>
<!-- Caption Buttons (Windows/Linux) --> <!-- Caption Buttons (Windows/Linux) -->
<Border Grid.Column="3" IsVisible="{OnPlatform True, macOS=False}"> <v:CaptionButtons HorizontalAlignment="Right" IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtons/>
</Border>
</Grid> </Grid>
<!-- File --> <!-- File -->

View file

@ -429,30 +429,12 @@ namespace SourceGit.Views
} }
public partial class Blame : ChromelessWindow public partial class Blame : ChromelessWindow
{ {
public Blame() public Blame()
{ {
InitializeComponent(); InitializeComponent();
} }
private void MaximizeOrRestoreWindow(object _, TappedEventArgs e)
{
if (WindowState == WindowState.Maximized)
WindowState = WindowState.Normal;
else
WindowState = WindowState.Maximized;
e.Handled = true;
}
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
if (e.ClickCount == 1)
BeginMoveDrag(e);
e.Handled = true;
}
protected override void OnClosed(EventArgs e) protected override void OnClosed(EventArgs e)
{ {
base.OnClosed(e); base.OnClosed(e);

View file

@ -21,29 +21,26 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<!-- Bottom border --> <!-- Bottom border -->
<Border Grid.Column="0" Grid.ColumnSpan="4" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}"
DoubleTapped="MaximizeOrRestoreWindow" DoubleTapped="MaximizeOrRestoreWindow"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<!-- Caption Buttons (macOS) --> <Path Width="12" Height="12"
<Border Grid.Column="0" IsVisible="{OnPlatform False, macOS=True}"> Margin="10,0,0,0"
<v:CaptionButtonsMacOS/> HorizontalAlignment="Left"
</Border> Data="{StaticResource Icons.Compare}"
IsVisible="{OnPlatform True, macOS=False}"/>
<!-- Icon -->
<Path Grid.Column="1" Margin="8,0,0,0" Width="12" Height="12" Data="{StaticResource Icons.Compare}"/>
<!-- Title -->
<TextBlock Grid.Column="2" Margin="8,0,0,0" Text="{DynamicResource Text.BranchCompare}" FontWeight="Bold" IsHitTestVisible="False" VerticalAlignment="Center"/>
<TextBlock Classes="bold"
Text="{DynamicResource Text.BranchCompare}"
HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/>
<!-- Caption Buttons (Windows/Linux) --> <!-- Caption Buttons (Windows/Linux) -->
<Border Grid.Column="3" IsVisible="{OnPlatform True, macOS=False}"> <v:CaptionButtons HorizontalAlignment="Right" IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtons/>
</Border>
</Grid> </Grid>
<!-- Compare Targets --> <!-- Compare Targets -->

View file

@ -4,30 +4,12 @@ using Avalonia.Input;
namespace SourceGit.Views namespace SourceGit.Views
{ {
public partial class BranchCompare : ChromelessWindow public partial class BranchCompare : ChromelessWindow
{ {
public BranchCompare() public BranchCompare()
{ {
InitializeComponent(); InitializeComponent();
} }
private void MaximizeOrRestoreWindow(object _, TappedEventArgs e)
{
if (WindowState == WindowState.Maximized)
WindowState = WindowState.Normal;
else
WindowState = WindowState.Maximized;
e.Handled = true;
}
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
if (e.ClickCount == 1)
BeginMoveDrag(e);
e.Handled = true;
}
private void OnChangeContextRequested(object sender, ContextRequestedEventArgs e) private void OnChangeContextRequested(object sender, ContextRequestedEventArgs e)
{ {
if (DataContext is ViewModels.BranchCompare vm && sender is ChangeCollectionView view) if (DataContext is ViewModels.BranchCompare vm && sender is ChangeCollectionView view)

View file

@ -1,159 +0,0 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.CaptionButtonsMacOS"
x:Name="ThisControl">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<Color x:Key="Color.MacOS.Close">#FFED6A5E</Color>
<Color x:Key="Color.MacOS.CloseFG">#FF69110A</Color>
<Color x:Key="Color.MacOS.ClosePressed">#FFB24F46</Color>
<Color x:Key="Color.MacOS.ClosePressedFG">#FF2E0402</Color>
<Color x:Key="Color.MacOS.Minimize">#FFF4BF4F</Color>
<Color x:Key="Color.MacOS.MinimizeFG">#FF8F591D</Color>
<Color x:Key="Color.MacOS.MinimizePressed">#FFB78F3A</Color>
<Color x:Key="Color.MacOS.MinimizePressedFG">#FF522A0A</Color>
<Color x:Key="Color.MacOS.Maximize">#FF61C554</Color>
<Color x:Key="Color.MacOS.MaximizeFG">#FF296017</Color>
<Color x:Key="Color.MacOS.MaximizePressed">#FF48943F</Color>
<Color x:Key="Color.MacOS.MaximizePressedFG">#FF102F07</Color>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<Color x:Key="Color.MacOS.Close">#FFED6A5E</Color>
<Color x:Key="Color.MacOS.CloseFG">#FF8C1A10</Color>
<Color x:Key="Color.MacOS.ClosePressed">#FFF09389</Color>
<Color x:Key="Color.MacOS.ClosePressedFG">#FF69120A</Color>
<Color x:Key="Color.MacOS.Minimize">#FFF4BF4F</Color>
<Color x:Key="Color.MacOS.MinimizeFG">#FF8F591D</Color>
<Color x:Key="Color.MacOS.MinimizePressed">#FFFBEB74</Color>
<Color x:Key="Color.MacOS.MinimizePressedFG">#FF705F1B</Color>
<Color x:Key="Color.MacOS.Maximize">#FF61C554</Color>
<Color x:Key="Color.MacOS.MaximizeFG">#FF296017</Color>
<Color x:Key="Color.MacOS.MaximizePressed">#FF86F37F</Color>
<Color x:Key="Color.MacOS.MaximizePressedFG">#FF2C681A</Color>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<SolidColorBrush x:Key="Brush.MacOS.Close" Color="{DynamicResource Color.MacOS.Close}"/>
<SolidColorBrush x:Key="Brush.MacOS.CloseFG" Color="{DynamicResource Color.MacOS.CloseFG}"/>
<SolidColorBrush x:Key="Brush.MacOS.ClosePressed" Color="{DynamicResource Color.MacOS.ClosePressed}"/>
<SolidColorBrush x:Key="Brush.MacOS.ClosePressedFG" Color="{DynamicResource Color.MacOS.ClosePressedFG}"/>
<SolidColorBrush x:Key="Brush.MacOS.Minimize" Color="{DynamicResource Color.MacOS.Minimize}"/>
<SolidColorBrush x:Key="Brush.MacOS.MinimizeFG" Color="{DynamicResource Color.MacOS.MinimizeFG}"/>
<SolidColorBrush x:Key="Brush.MacOS.MinimizePressed" Color="{DynamicResource Color.MacOS.MinimizePressed}"/>
<SolidColorBrush x:Key="Brush.MacOS.MinimizePressedFG" Color="{DynamicResource Color.MacOS.MinimizePressedFG}"/>
<SolidColorBrush x:Key="Brush.MacOS.Maximize" Color="{DynamicResource Color.MacOS.Maximize}"/>
<SolidColorBrush x:Key="Brush.MacOS.MaximizeFG" Color="{DynamicResource Color.MacOS.MaximizeFG}"/>
<SolidColorBrush x:Key="Brush.MacOS.MaximizePressed" Color="{DynamicResource Color.MacOS.MaximizePressed}"/>
<SolidColorBrush x:Key="Brush.MacOS.MaximizePressedFG" Color="{DynamicResource Color.MacOS.MaximizePressedFG}"/>
</ResourceDictionary>
</UserControl.Resources>
<UserControl.Styles>
<Style Selector="Button">
<Setter Property="Width" Value="24"/>
<Setter Property="Height" Value="24"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style Selector="Button /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="Button>Grid>Ellipse">
<Setter Property="Width" Value="14"/>
<Setter Property="Height" Value="14"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="StrokeThickness" Value=".5"/>
<Setter Property="Stroke" Value="#40000000"/>
</Style>
<Style Selector="Button.close>Grid>Ellipse">
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.Close}"/>
</Style>
<Style Selector="Button.minimize>Grid>Ellipse">
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.Minimize}"/>
</Style>
<Style Selector="Button.maximize>Grid>Ellipse">
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.Maximize}"/>
</Style>
<Style Selector="Button.close:pressed>Grid>Ellipse">
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.ClosePressed}"/>
</Style>
<Style Selector="Button.minimize:pressed>Grid>Ellipse">
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MinimizePressed}"/>
</Style>
<Style Selector="Button.maximize:pressed>Grid>Ellipse">
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MaximizePressed}"/>
</Style>
<Style Selector="Button>Grid>Path">
<Setter Property="Stretch" Value="Fill"/>
<Setter Property="Fill" Value="Black"/>
<Setter Property="IsVisible" Value="False"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style Selector="Button.close>Grid>Path">
<Setter Property="Width" Value="6"/>
<Setter Property="Height" Value="6"/>
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.CloseFG}"/>
<Setter Property="Data" Value="{StaticResource Icons.MacOS.Close}"/>
</Style>
<Style Selector="Button.minimize>Grid>Path">
<Setter Property="Width" Value="8"/>
<Setter Property="Height" Value="2"/>
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MinimizeFG}"/>
<Setter Property="Data" Value="{StaticResource Icons.MacOS.Minimize}"/>
</Style>
<Style Selector="Button.maximize>Grid>Path">
<Setter Property="Width" Value="6"/>
<Setter Property="Height" Value="6"/>
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MaximizeFG}"/>
<Setter Property="Data" Value="{StaticResource Icons.MacOS.Maximize}"/>
</Style>
<Style Selector="Button.close:pressed>Grid>Path">
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.ClosePressedFG}"/>
</Style>
<Style Selector="Button.minimize:pressed>Grid>Path">
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MinimizePressedFG}"/>
</Style>
<Style Selector="Button.maximize:pressed>Grid>Path">
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MaximizePressedFG}"/>
</Style>
<Style Selector="Grid.caption_button_box:pointerover>StackPanel>Button>Grid>Path">
<Setter Property="IsVisible" Value="True"/>
</Style>
</UserControl.Styles>
<Grid Classes="caption_button_box">
<StackPanel Orientation="Horizontal" Margin="8,0,0,0">
<Button Classes="close" Click="CloseWindow">
<Grid>
<Ellipse/>
<Path/>
</Grid>
</Button>
<Button Classes="minimize" Click="MinimizeWindow" IsVisible="{Binding !#ThisControl.IsCloseButtonOnly}">
<Grid>
<Ellipse/>
<Path/>
</Grid>
</Button>
<Button Classes="maximize" Click="MaximizeOrRestoreWindow" IsVisible="{Binding !#ThisControl.IsCloseButtonOnly}">
<Grid>
<Ellipse/>
<Path/>
</Grid>
</Button>
</StackPanel>
</Grid>
</UserControl>

View file

@ -1,49 +0,0 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.VisualTree;
namespace SourceGit.Views
{
public partial class CaptionButtonsMacOS : UserControl
{
public static readonly StyledProperty<bool> IsCloseButtonOnlyProperty =
AvaloniaProperty.Register<CaptionButtonsMacOS, bool>(nameof(IsCloseButtonOnly));
public bool IsCloseButtonOnly
{
get => GetValue(IsCloseButtonOnlyProperty);
set => SetValue(IsCloseButtonOnlyProperty, value);
}
public CaptionButtonsMacOS()
{
InitializeComponent();
}
private void MinimizeWindow(object _, RoutedEventArgs e)
{
var window = this.FindAncestorOfType<Window>();
if (window != null)
window.WindowState = WindowState.Minimized;
e.Handled = true;
}
private void MaximizeOrRestoreWindow(object _, RoutedEventArgs e)
{
var window = this.FindAncestorOfType<Window>();
if (window != null)
window.WindowState = window.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
e.Handled = true;
}
private void CloseWindow(object _, RoutedEventArgs e)
{
var window = this.FindAncestorOfType<Window>();
window?.Close();
e.Handled = true;
}
}
}

View file

@ -32,14 +32,35 @@ namespace SourceGit.Views
Classes.Add("custom_window_frame"); Classes.Add("custom_window_frame");
} }
} }
else else if (OperatingSystem.IsWindows())
{ {
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome; ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome;
ExtendClientAreaToDecorationsHint = true; ExtendClientAreaToDecorationsHint = true;
Classes.Add("fix_maximized_padding");
if (OperatingSystem.IsWindows())
Classes.Add("fix_maximized_padding");
} }
else
{
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.SystemChrome;
ExtendClientAreaToDecorationsHint = true;
}
}
public void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
if (e.ClickCount == 1)
BeginMoveDrag(e);
e.Handled = true;
}
public void MaximizeOrRestoreWindow(object _, TappedEventArgs e)
{
if (WindowState == WindowState.Maximized)
WindowState = WindowState.Normal;
else
WindowState = WindowState.Maximized;
e.Handled = true;
} }
protected override void OnApplyTemplate(TemplateAppliedEventArgs e) protected override void OnApplyTemplate(TemplateAppliedEventArgs e)

View file

@ -2,10 +2,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels" xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views" xmlns:v="using:SourceGit.Views"
xmlns:c="using:SourceGit.Converters"
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450"
x:Class="SourceGit.Views.ConfigureWorkspace" x:Class="SourceGit.Views.ConfigureWorkspace"
x:DataType="vm:ConfigureWorkspace" x:DataType="vm:ConfigureWorkspace"
@ -17,30 +15,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,Auto" MinWidth="494"> <Grid RowDefinitions="Auto,Auto" MinWidth="494">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Data="{StaticResource Icons.Workspace}"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Workspace}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.ConfigureWorkspace}" Text="{DynamicResource Text.ConfigureWorkspace}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,5 +1,4 @@
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input;
namespace SourceGit.Views namespace SourceGit.Views
{ {
@ -15,10 +14,5 @@ namespace SourceGit.Views
ViewModels.Preference.Instance.Save(); ViewModels.Preference.Instance.Save();
base.OnClosing(e); base.OnClosing(e);
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
} }
} }

View file

@ -15,30 +15,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,Auto,Auto"> <Grid RowDefinitions="Auto,Auto,Auto">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Data="{StaticResource Icons.Error}"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Error}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.Warn}" Text="{DynamicResource Text.Warn}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,4 +1,3 @@
using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
namespace SourceGit.Views namespace SourceGit.Views
@ -10,11 +9,6 @@ namespace SourceGit.Views
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void Sure(object _1, RoutedEventArgs _2) private void Sure(object _1, RoutedEventArgs _2)
{ {
if (DataContext is ViewModels.ConfirmCommitWithoutFiles vm) if (DataContext is ViewModels.ConfirmCommitWithoutFiles vm)

View file

@ -13,30 +13,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,*"> <Grid RowDefinitions="Auto,*">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Info}" Data="{StaticResource Icons.Info}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="Restart Required" Text="Restart Required"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,8 +1,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
namespace SourceGit.Views namespace SourceGit.Views
@ -14,11 +12,6 @@ namespace SourceGit.Views
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void CloseWindow(object _1, RoutedEventArgs _2) private void CloseWindow(object _1, RoutedEventArgs _2)
{ {
Console.Out.WriteLine("No passphrase entered."); Console.Out.WriteLine("No passphrase entered.");

View file

@ -5,7 +5,6 @@
xmlns:m="using:SourceGit.Models" xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels" xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views" xmlns:v="using:SourceGit.Views"
xmlns:c="using:SourceGit.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.ConventionalCommitMessageBuilder" x:Class="SourceGit.Views.ConventionalCommitMessageBuilder"
x:DataType="vm:ConventionalCommitMessageBuilder" x:DataType="vm:ConventionalCommitMessageBuilder"
@ -18,30 +17,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,Auto,Auto"> <Grid RowDefinitions="Auto,Auto,Auto">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Data="{StaticResource Icons.CommitMessageGenerator}"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.CommitMessageGenerator}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.ConventionalCommit}" Text="{DynamicResource Text.ConventionalCommit}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,4 +1,3 @@
using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
namespace SourceGit.Views namespace SourceGit.Views
@ -10,11 +9,6 @@ namespace SourceGit.Views
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void OnApplyClicked(object _, RoutedEventArgs e) private void OnApplyClicked(object _, RoutedEventArgs e)
{ {
if (DataContext is ViewModels.ConventionalCommitMessageBuilder builder) if (DataContext is ViewModels.ConventionalCommitMessageBuilder builder)

View file

@ -20,29 +20,26 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<!-- Bottom border --> <!-- Bottom border -->
<Border Grid.Column="0" Grid.ColumnSpan="4" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
DoubleTapped="MaximizeOrRestoreWindow" DoubleTapped="MaximizeOrRestoreWindow"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<!-- Caption Buttons (macOS) --> <Path Width="12" Height="12"
<Border Grid.Column="0" IsVisible="{OnPlatform False, macOS=True}"> Margin="10,0,0,0"
<v:CaptionButtonsMacOS/> HorizontalAlignment="Left"
</Border> Data="{StaticResource Icons.Histories}"
IsVisible="{OnPlatform True, macOS=False}"/>
<!-- Icon -->
<Path Grid.Column="1" Margin="8,0,0,0" Width="12" Height="12" Stretch="Uniform" Data="{StaticResource Icons.Histories}"/>
<!-- Title -->
<TextBlock Grid.Column="2" Margin="4,0,0,0" Text="{DynamicResource Text.FileHistory}" FontWeight="Bold" IsHitTestVisible="False" VerticalAlignment="Center"/>
<TextBlock Classes="bold"
Text="{DynamicResource Text.FileHistory}"
HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/>
<!-- Caption Buttons (Windows/Linux) --> <!-- Caption Buttons (Windows/Linux) -->
<Border Grid.Column="3" IsVisible="{OnPlatform True, macOS=False}"> <v:CaptionButtons HorizontalAlignment="Right" IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtons/>
</Border>
</Grid> </Grid>
<!-- Body --> <!-- Body -->

View file

@ -1,3 +1,6 @@
using System;
using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
@ -6,27 +9,29 @@ namespace SourceGit.Views
{ {
public partial class FileHistories : ChromelessWindow public partial class FileHistories : ChromelessWindow
{ {
public static readonly StyledProperty<bool> HasLeftCaptionButtonProperty =
AvaloniaProperty.Register<FileHistories, bool>(nameof(HasLeftCaptionButton));
public bool HasLeftCaptionButton
{
get => GetValue(HasLeftCaptionButtonProperty);
set => SetValue(HasLeftCaptionButtonProperty, value);
}
public FileHistories() public FileHistories()
{ {
if (OperatingSystem.IsMacOS())
HasLeftCaptionButton = true;
InitializeComponent(); InitializeComponent();
} }
private void MaximizeOrRestoreWindow(object _, TappedEventArgs e) protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{ {
if (WindowState == WindowState.Maximized) base.OnPropertyChanged(change);
WindowState = WindowState.Normal;
else if (change.Property == WindowStateProperty)
WindowState = WindowState.Maximized; HasLeftCaptionButton = WindowState != WindowState.FullScreen;
e.Handled = true;
}
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
if (e.ClickCount == 1)
BeginMoveDrag(e);
e.Handled = true;
} }
private void OnPressCommitSHA(object sender, PointerPressedEventArgs e) private void OnPressCommitSHA(object sender, PointerPressedEventArgs e)

View file

@ -15,30 +15,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,*"> <Grid RowDefinitions="Auto,*">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Hotkeys}" Data="{StaticResource Icons.Hotkeys}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.Hotkeys}" Text="{DynamicResource Text.Hotkeys}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,5 +1,3 @@
using Avalonia.Input;
namespace SourceGit.Views namespace SourceGit.Views
{ {
public partial class Hotkeys : ChromelessWindow public partial class Hotkeys : ChromelessWindow
@ -8,10 +6,5 @@ namespace SourceGit.Views
{ {
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
} }
} }

View file

@ -16,30 +16,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,Auto,*,Auto"> <Grid RowDefinitions="Auto,Auto,*,Auto">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.InteractiveRebase}" Data="{StaticResource Icons.InteractiveRebase}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.InteractiveRebase}" Text="{DynamicResource Text.InteractiveRebase}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -81,11 +81,6 @@ namespace SourceGit.Views
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void CloseWindow(object _1, RoutedEventArgs _2) private void CloseWindow(object _1, RoutedEventArgs _2)
{ {
Close(); Close();

View file

@ -16,30 +16,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,Auto,*"> <Grid RowDefinitions="Auto,Auto,*">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Lock}" Data="{StaticResource Icons.Lock}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.GitLFS.Locks.Title}" Text="{DynamicResource Text.GitLFS.Locks.Title}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,5 +1,4 @@
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
namespace SourceGit.Views namespace SourceGit.Views
@ -11,11 +10,6 @@ namespace SourceGit.Views
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void OnUnlockButtonClicked(object sender, RoutedEventArgs e) private void OnUnlockButtonClicked(object sender, RoutedEventArgs e)
{ {
if (DataContext is ViewModels.LFSLocks vm && sender is Button button) if (DataContext is ViewModels.LFSLocks vm && sender is Button button)

View file

@ -25,13 +25,11 @@
<Border Grid.Column="0" Grid.ColumnSpan="4" <Border Grid.Column="0" Grid.ColumnSpan="4"
Background="{DynamicResource Brush.TitleBar}" Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
DoubleTapped="OnTitleBarDoubleTapped" DoubleTapped="MaximizeOrRestoreWindow"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<!-- Caption Buttons (macOS) --> <!-- Caption Buttons (macOS) -->
<Border Grid.Column="0" VerticalAlignment="Stretch" Margin="2,0,8,3" IsVisible="{OnPlatform False, macOS=True}"> <Border Grid.Column="0" Width="72" IsVisible="{Binding #ThisControl.HasLeftCaptionButton}"/>
<v:CaptionButtonsMacOS VerticalAlignment="Bottom"/>
</Border>
<!-- Menu (Windows/Linux) --> <!-- Menu (Windows/Linux) -->
<Button Grid.Column="0" Classes="icon_button" VerticalAlignment="Bottom" Margin="6,0,2,3" IsVisible="{OnPlatform True, macOS=False}"> <Button Grid.Column="0" Classes="icon_button" VerticalAlignment="Bottom" Margin="6,0,2,3" IsVisible="{OnPlatform True, macOS=False}">

View file

@ -4,6 +4,7 @@ using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Platform;
using Avalonia.VisualTree; using Avalonia.VisualTree;
namespace SourceGit.Views namespace SourceGit.Views
@ -18,6 +19,15 @@ namespace SourceGit.Views
get => GetValue(CaptionHeightProperty); get => GetValue(CaptionHeightProperty);
set => SetValue(CaptionHeightProperty, value); set => SetValue(CaptionHeightProperty, value);
} }
public static readonly StyledProperty<bool> HasLeftCaptionButtonProperty =
AvaloniaProperty.Register<Launcher, bool>(nameof(HasLeftCaptionButton));
public bool HasLeftCaptionButton
{
get => GetValue(HasLeftCaptionButtonProperty);
set => SetValue(HasLeftCaptionButtonProperty, value);
}
public bool IsRightCaptionButtonsVisible public bool IsRightCaptionButtonsVisible
{ {
@ -38,10 +48,21 @@ namespace SourceGit.Views
Height = layout.LauncherHeight; Height = layout.LauncherHeight;
} }
if (UseSystemWindowFrame) if (OperatingSystem.IsMacOS())
{
HasLeftCaptionButton = true;
CaptionHeight = new GridLength(34);
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.SystemChrome |
ExtendClientAreaChromeHints.OSXThickTitleBar;
}
else if (UseSystemWindowFrame)
{
CaptionHeight = new GridLength(30); CaptionHeight = new GridLength(30);
}
else else
{
CaptionHeight = new GridLength(38); CaptionHeight = new GridLength(38);
}
InitializeComponent(); InitializeComponent();
} }
@ -55,9 +76,9 @@ namespace SourceGit.Views
{ {
base.OnOpened(e); base.OnOpened(e);
var layout = ViewModels.Preference.Instance.Layout; var state = ViewModels.Preference.Instance.Layout.LauncherWindowState;
if (layout.LauncherWindowState == WindowState.Maximized) if (state == WindowState.Maximized || state == WindowState.FullScreen)
WindowState = WindowState.Maximized; WindowState = state;
} }
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
@ -67,12 +88,11 @@ namespace SourceGit.Views
if (change.Property == WindowStateProperty) if (change.Property == WindowStateProperty)
{ {
var state = (WindowState)change.NewValue!; var state = (WindowState)change.NewValue!;
if (OperatingSystem.IsLinux() && UseSystemWindowFrame) if (!OperatingSystem.IsMacOS() && !UseSystemWindowFrame)
CaptionHeight = new GridLength(30); CaptionHeight = new GridLength(state == WindowState.Maximized ? 30 : 38);
else if (state == WindowState.Maximized)
CaptionHeight = new GridLength(OperatingSystem.IsMacOS() ? 34 : 30); if (OperatingSystem.IsMacOS())
else HasLeftCaptionButton = state != WindowState.FullScreen;
CaptionHeight = new GridLength(38);
ViewModels.Preference.Instance.Layout.LauncherWindowState = state; ViewModels.Preference.Instance.Layout.LauncherWindowState = state;
} }
@ -225,24 +245,6 @@ namespace SourceGit.Views
base.OnClosing(e); base.OnClosing(e);
} }
private void OnTitleBarDoubleTapped(object _, TappedEventArgs e)
{
if (WindowState == WindowState.Maximized)
WindowState = WindowState.Normal;
else
WindowState = WindowState.Maximized;
e.Handled = true;
}
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
if (e.ClickCount == 1)
BeginMoveDrag(e);
e.Handled = true;
}
private void OnOpenWorkspaceMenu(object sender, RoutedEventArgs e) private void OnOpenWorkspaceMenu(object sender, RoutedEventArgs e)
{ {
if (sender is Button btn && DataContext is ViewModels.Launcher launcher) if (sender is Button btn && DataContext is ViewModels.Launcher launcher)

View file

@ -17,30 +17,23 @@
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
<Grid RowDefinitions="Auto,Auto" MinWidth="600"> <Grid RowDefinitions="Auto,Auto" MinWidth="600">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Data="{StaticResource Icons.Settings}"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Settings}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.Preference}" Text="{DynamicResource Text.Preference}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
@ -166,11 +165,6 @@ namespace SourceGit.Views
base.OnClosing(e); base.OnClosing(e);
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private async void SelectThemeOverrideFile(object _, RoutedEventArgs e) private async void SelectThemeOverrideFile(object _, RoutedEventArgs e)
{ {
var options = new FilePickerOpenOptions() var options = new FilePickerOpenOptions()

View file

@ -16,30 +16,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,Auto"> <Grid RowDefinitions="Auto,Auto">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Data="{StaticResource Icons.Settings}"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Settings}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3" <TextBlock Classes="bold"
Classes="bold"
Text="{DynamicResource Text.Configure}" Text="{DynamicResource Text.Configure}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,5 +1,4 @@
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input;
namespace SourceGit.Views namespace SourceGit.Views
{ {
@ -15,10 +14,5 @@ namespace SourceGit.Views
(DataContext as ViewModels.RepositoryConfigure)?.Save(); (DataContext as ViewModels.RepositoryConfigure)?.Save();
base.OnClosing(e); base.OnClosing(e);
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
} }
} }

View file

@ -17,30 +17,23 @@
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="Auto,*"> <Grid RowDefinitions="Auto,*">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.SoftwareUpdate}" Data="{StaticResource Icons.SoftwareUpdate}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.SelfUpdate.Title}" Text="{DynamicResource Text.SelfUpdate.Title}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,5 +1,4 @@
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
namespace SourceGit.Views namespace SourceGit.Views
@ -11,11 +10,6 @@ namespace SourceGit.Views
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void CloseWindow(object _1, RoutedEventArgs _2) private void CloseWindow(object _1, RoutedEventArgs _2)
{ {
Close(); Close();

View file

@ -14,30 +14,23 @@
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
<Grid RowDefinitions="Auto,*"> <Grid RowDefinitions="Auto,*">
<!-- TitleBar --> <!-- TitleBar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Edit}" Data="{StaticResource Icons.Edit}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.CodeEditor}" Text="{DynamicResource Text.CodeEditor}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,7 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
namespace SourceGit.Views namespace SourceGit.Views
@ -40,11 +39,6 @@ namespace SourceGit.Views
App.Quit(_exitCode); App.Quit(_exitCode);
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
private void SaveAndClose(object _1, RoutedEventArgs _2) private void SaveAndClose(object _1, RoutedEventArgs _2)
{ {
File.WriteAllText(_file, Editor.Text); File.WriteAllText(_file, Editor.Text);

View file

@ -16,30 +16,23 @@
CanResize="False"> CanResize="False">
<Grid RowDefinitions="Auto,Auto,*"> <Grid RowDefinitions="Auto,Auto,*">
<!-- Title bar --> <!-- Title bar -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Height="30" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}"> <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
<Border Grid.Column="0" Grid.ColumnSpan="3" <Border Background="{DynamicResource Brush.TitleBar}"
Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
PointerPressed="BeginMoveWindow"/> PointerPressed="BeginMoveWindow"/>
<Path Grid.Column="0" <Path Width="14" Height="14"
Width="14" Height="14"
Margin="10,0,0,0" Margin="10,0,0,0"
HorizontalAlignment="Left"
Data="{StaticResource Icons.Statistics}" Data="{StaticResource Icons.Statistics}"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
<v:CaptionButtonsMacOS Grid.Column="0" <TextBlock Classes="bold"
Margin="0,2,0,0"
IsCloseButtonOnly="True"
IsVisible="{OnPlatform False, macOS=True}"/>
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
Classes="bold"
Text="{DynamicResource Text.Statistics}" Text="{DynamicResource Text.Statistics}"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
<v:CaptionButtons Grid.Column="2" <v:CaptionButtons HorizontalAlignment="Right"
IsCloseButtonOnly="True" IsCloseButtonOnly="True"
IsVisible="{OnPlatform True, macOS=False}"/> IsVisible="{OnPlatform True, macOS=False}"/>
</Grid> </Grid>

View file

@ -1,5 +1,3 @@
using Avalonia.Input;
namespace SourceGit.Views namespace SourceGit.Views
{ {
public partial class Statistics : ChromelessWindow public partial class Statistics : ChromelessWindow
@ -8,10 +6,5 @@ namespace SourceGit.Views
{ {
InitializeComponent(); InitializeComponent();
} }
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
BeginMoveDrag(e);
}
} }
} }