code_style: move BeginMoveWindow to ChromelessWindow

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-10-31 21:36:51 +08:00
parent 1999e4bf47
commit 74252df5b6
No known key found for this signature in database
44 changed files with 234 additions and 609 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.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.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.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>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -19,29 +19,24 @@
</Grid.RowDefinitions>
<!-- 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 -->
<Border Grid.Column="0" Grid.ColumnSpan="4"
Background="{DynamicResource Brush.TitleBar}"
<Border Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}"
DoubleTapped="MaximizeOrRestoreWindow"
PointerPressed="BeginMoveWindow"/>
<!-- Caption Buttons (macOS) -->
<Border Grid.Column="0" IsVisible="{OnPlatform False, macOS=True}">
<v:CaptionButtonsMacOS/>
</Border>
<!-- Icon -->
<Path Grid.Column="1" Margin="8,0,0,0" Width="12" Height="12" Data="{StaticResource Icons.Blame}"/>
<Border Width="72" HorizontalAlignment="Left" IsVisible="{Binding #ThisControl.HasLeftCaptionButton}"/>
<!-- Title -->
<TextBlock Grid.Column="2" Margin="8,0,0,0" Text="{DynamicResource Text.Blame}" FontWeight="Bold" IsHitTestVisible="False" VerticalAlignment="Center"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="False">
<Path Width="12" Height="12" Data="{StaticResource Icons.Blame}"/>
<TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.Blame}" FontWeight="Bold"/>
</StackPanel>
<!-- Caption Buttons (Windows/Linux) -->
<Border Grid.Column="3" IsVisible="{OnPlatform True, macOS=False}">
<v:CaptionButtons/>
</Border>
<v:CaptionButtons HorizontalAlignment="Right" IsVisible="{OnPlatform True, macOS=False}"/>
</Grid>
<!-- File -->

View file

@ -430,11 +430,31 @@ namespace SourceGit.Views
public partial class Blame : ChromelessWindow
{
public static readonly StyledProperty<bool> HasLeftCaptionButtonProperty =
AvaloniaProperty.Register<Blame, bool>(nameof(HasLeftCaptionButton));
public bool HasLeftCaptionButton
{
get => GetValue(HasLeftCaptionButtonProperty);
set => SetValue(HasLeftCaptionButtonProperty, value);
}
public Blame()
{
if (OperatingSystem.IsMacOS())
HasLeftCaptionButton = true;
InitializeComponent();
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == WindowStateProperty)
HasLeftCaptionButton = WindowState != WindowState.FullScreen;
}
private void MaximizeOrRestoreWindow(object _, TappedEventArgs e)
{
if (WindowState == WindowState.Maximized)
@ -445,14 +465,6 @@ namespace SourceGit.Views
e.Handled = true;
}
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
{
if (e.ClickCount == 1)
BeginMoveDrag(e);
e.Handled = true;
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);

View file

@ -21,29 +21,24 @@
</Grid.RowDefinitions>
<!-- 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 -->
<Border Grid.Column="0" Grid.ColumnSpan="4"
Background="{DynamicResource Brush.TitleBar}"
<Border Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}"
DoubleTapped="MaximizeOrRestoreWindow"
PointerPressed="BeginMoveWindow"/>
<!-- Caption Buttons (macOS) -->
<Border Grid.Column="0" IsVisible="{OnPlatform False, macOS=True}">
<v:CaptionButtonsMacOS/>
</Border>
<!-- Icon -->
<Path Grid.Column="1" Margin="8,0,0,0" Width="12" Height="12" Data="{StaticResource Icons.Compare}"/>
<Border Width="72" HorizontalAlignment="Left" IsVisible="{Binding #ThisControl.HasLeftCaptionButton}"/>
<!-- Title -->
<TextBlock Grid.Column="2" Margin="8,0,0,0" Text="{DynamicResource Text.BranchCompare}" FontWeight="Bold" IsHitTestVisible="False" VerticalAlignment="Center"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="False">
<Path Width="12" Height="12" Data="{StaticResource Icons.Compare}"/>
<TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.BranchCompare}" FontWeight="Bold"/>
</StackPanel>
<!-- Caption Buttons (Windows/Linux) -->
<Border Grid.Column="3" IsVisible="{OnPlatform True, macOS=False}">
<v:CaptionButtons/>
</Border>
<v:CaptionButtons HorizontalAlignment="Right" IsVisible="{OnPlatform True, macOS=False}"/>
</Grid>
<!-- Compare Targets -->

View file

@ -1,3 +1,6 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
@ -5,10 +8,30 @@ namespace SourceGit.Views
{
public partial class BranchCompare : ChromelessWindow
{
public static readonly StyledProperty<bool> HasLeftCaptionButtonProperty =
AvaloniaProperty.Register<BranchCompare, bool>(nameof(HasLeftCaptionButton));
public bool HasLeftCaptionButton
{
get => GetValue(HasLeftCaptionButtonProperty);
set => SetValue(HasLeftCaptionButtonProperty, value);
}
public BranchCompare()
{
if (OperatingSystem.IsMacOS())
HasLeftCaptionButton = true;
InitializeComponent();
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == WindowStateProperty)
HasLeftCaptionButton = WindowState != WindowState.FullScreen;
}
private void MaximizeOrRestoreWindow(object _, TappedEventArgs e)
{
@ -20,14 +43,6 @@ namespace SourceGit.Views
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)
{
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,25 @@ namespace SourceGit.Views
Classes.Add("custom_window_frame");
}
}
else
else if (OperatingSystem.IsWindows())
{
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome;
ExtendClientAreaToDecorationsHint = true;
if (OperatingSystem.IsWindows())
Classes.Add("fix_maximized_padding");
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;
}
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,29 +20,24 @@
</Grid.RowDefinitions>
<!-- 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 -->
<Border Grid.Column="0" Grid.ColumnSpan="4"
Background="{DynamicResource Brush.TitleBar}"
<Border Background="{DynamicResource Brush.TitleBar}"
BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
DoubleTapped="MaximizeOrRestoreWindow"
PointerPressed="BeginMoveWindow"/>
<!-- Caption Buttons (macOS) -->
<Border Grid.Column="0" IsVisible="{OnPlatform False, macOS=True}">
<v:CaptionButtonsMacOS/>
</Border>
<!-- Icon -->
<Path Grid.Column="1" Margin="8,0,0,0" Width="12" Height="12" Stretch="Uniform" Data="{StaticResource Icons.Histories}"/>
<Border Width="72" HorizontalAlignment="Left" IsVisible="{Binding #ThisControl.HasLeftCaptionButton}"/>
<!-- Title -->
<TextBlock Grid.Column="2" Margin="4,0,0,0" Text="{DynamicResource Text.FileHistory}" FontWeight="Bold" IsHitTestVisible="False" VerticalAlignment="Center"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="False">
<Path Width="12" Height="12" Stretch="Uniform" Data="{StaticResource Icons.Histories}"/>
<TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.FileHistory}" FontWeight="Bold"/>
</StackPanel>
<!-- Caption Buttons (Windows/Linux) -->
<Border Grid.Column="3" IsVisible="{OnPlatform True, macOS=False}">
<v:CaptionButtons/>
</Border>
<v:CaptionButtons HorizontalAlignment="Right" IsVisible="{OnPlatform True, macOS=False}"/>
</Grid>
<!-- Body -->

View file

@ -1,3 +1,6 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
@ -6,10 +9,30 @@ namespace SourceGit.Views
{
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()
{
if (OperatingSystem.IsMacOS())
HasLeftCaptionButton = true;
InitializeComponent();
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == WindowStateProperty)
HasLeftCaptionButton = WindowState != WindowState.FullScreen;
}
private void MaximizeOrRestoreWindow(object _, TappedEventArgs e)
{
@ -21,14 +44,6 @@ namespace SourceGit.Views
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)
{
if (sender is TextBlock { DataContext: Models.Commit commit } &&

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -29,9 +29,7 @@
PointerPressed="BeginMoveWindow"/>
<!-- Caption Buttons (macOS) -->
<Border Grid.Column="0" VerticalAlignment="Stretch" Margin="2,0,8,3" IsVisible="{OnPlatform False, macOS=True}">
<v:CaptionButtonsMacOS VerticalAlignment="Bottom"/>
</Border>
<Border Grid.Column="0" Width="72" IsVisible="{Binding #ThisControl.HasLeftCaptionButton}"/>
<!-- Menu (Windows/Linux) -->
<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.Input;
using Avalonia.Interactivity;
using Avalonia.Platform;
using Avalonia.VisualTree;
namespace SourceGit.Views
@ -18,6 +19,15 @@ namespace SourceGit.Views
get => GetValue(CaptionHeightProperty);
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
{
@ -41,7 +51,14 @@ namespace SourceGit.Views
if (UseSystemWindowFrame)
CaptionHeight = new GridLength(30);
else
CaptionHeight = new GridLength(38);
CaptionHeight = new GridLength(34);
if (OperatingSystem.IsMacOS())
{
HasLeftCaptionButton = true;
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.SystemChrome |
ExtendClientAreaChromeHints.OSXThickTitleBar;
}
InitializeComponent();
}
@ -69,10 +86,13 @@ namespace SourceGit.Views
var state = (WindowState)change.NewValue!;
if (OperatingSystem.IsLinux() && UseSystemWindowFrame)
CaptionHeight = new GridLength(30);
else if (state == WindowState.Maximized)
else if (state == WindowState.Maximized || state == WindowState.FullScreen)
CaptionHeight = new GridLength(OperatingSystem.IsMacOS() ? 34 : 30);
else
CaptionHeight = new GridLength(38);
CaptionHeight = new GridLength(34);
if (OperatingSystem.IsMacOS())
HasLeftCaptionButton = state != WindowState.FullScreen;
ViewModels.Preference.Instance.Layout.LauncherWindowState = state;
}
@ -235,14 +255,6 @@ namespace SourceGit.Views
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)
{
if (sender is Button btn && DataContext is ViewModels.Launcher launcher)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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