Skip to content

Commit e19d025

Browse files
committed
code_review: PR #431
* move resources and styles for macOS caption button to `CaptionButtonsMacOS` because it is never used by others and should not been changed * add `IsCloseButtonOnly` property to `CaptionButtons` and `CaptionButtonsMacOS` and replace the controls in windows
1 parent e3ee07b commit e19d025

25 files changed

+267
-337
lines changed

src/Resources/Styles.axaml

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -429,85 +429,6 @@
429429
<Setter Property="Stroke" Value="Red"/>
430430
</Style>
431431

432-
<Style Selector="Button.caption_button_macos">
433-
<Setter Property="Width" Value="24"/>
434-
<Setter Property="Height" Value="24"/>
435-
<Setter Property="BorderThickness" Value="0"/>
436-
<Setter Property="VerticalAlignment" Value="Center"/>
437-
</Style>
438-
<Style Selector="Button.caption_button_macos:nth-child(1)">
439-
<Setter Property="Margin" Value="6,0,0,0"/>
440-
</Style>
441-
<Style Selector="Button.caption_button_macos Ellipse">
442-
<Setter Property="Width" Value="14"/>
443-
<Setter Property="Height" Value="14"/>
444-
<Setter Property="VerticalAlignment" Value="Center"/>
445-
<Setter Property="StrokeThickness" Value=".5"/>
446-
<Setter Property="Stroke" Value="#40000000"/>
447-
</Style>
448-
<Style Selector="Button.caption_button_macos.close Ellipse">
449-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.Close}"/>
450-
</Style>
451-
<Style Selector="Button.caption_button_macos.minimize Ellipse">
452-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.Minimize}"/>
453-
</Style>
454-
<Style Selector="Button.caption_button_macos.maximize Ellipse">
455-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.Maximize}"/>
456-
</Style>
457-
<Style Selector="Button.caption_button_macos.close:pressed Ellipse">
458-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.ClosePressed}"/>
459-
</Style>
460-
<Style Selector="Button.caption_button_macos.minimize:pressed Ellipse">
461-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MinimizePressed}"/>
462-
</Style>
463-
<Style Selector="Button.caption_button_macos.maximize:pressed Ellipse">
464-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MaximizePressed}"/>
465-
</Style>
466-
<Style Selector="Button.caption_button_macos Path">
467-
<Setter Property="Width" Value="8"/>
468-
<Setter Property="Height" Value="8"/>
469-
<Setter Property="Stretch" Value="Fill"/>
470-
<Setter Property="Fill" Value="Black"/>
471-
<Setter Property="IsVisible" Value="False"/>
472-
<Setter Property="VerticalAlignment" Value="Center"/>
473-
</Style>
474-
<Style Selector="Button.caption_button_macos.close Path">
475-
<Setter Property="Width" Value="6"/>
476-
<Setter Property="Height" Value="6"/>
477-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.CloseFG}"/>
478-
<Setter Property="Data" Value="{StaticResource Icons.MacOS.Close}"/>
479-
</Style>
480-
<Style Selector="Button.caption_button_macos.minimize Path">
481-
<Setter Property="Width" Value="8"/>
482-
<Setter Property="Height" Value="2"/>
483-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MinimizeFG}"/>
484-
<Setter Property="Data" Value="{StaticResource Icons.MacOS.Minimize}"/>
485-
</Style>
486-
<Style Selector="Button.caption_button_macos.maximize Path">
487-
<Setter Property="Width" Value="6"/>
488-
<Setter Property="Height" Value="6"/>
489-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MaximizeFG}"/>
490-
<Setter Property="Data" Value="{StaticResource Icons.MacOS.Maximize}"/>
491-
</Style>
492-
<Style Selector="Button.caption_button_macos.close:pressed Path">
493-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.ClosePressedFG}"/>
494-
</Style>
495-
<Style Selector="Button.caption_button_macos.minimize:pressed Path">
496-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MinimizePressedFG}"/>
497-
</Style>
498-
<Style Selector="Button.caption_button_macos.maximize:pressed Path">
499-
<Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MaximizePressedFG}"/>
500-
</Style>
501-
<Style Selector="Grid.caption_button_box:pointerover Button.caption_button_macos Path">
502-
<Setter Property="IsVisible" Value="True"/>
503-
</Style>
504-
<Style Selector="Button.caption_button_macos /template/ ContentPresenter#PART_ContentPresenter">
505-
<Setter Property="Background" Value="Transparent"/>
506-
</Style>
507-
<Style Selector="Button.caption_button_macos:pointerover /template/ ContentPresenter#PART_ContentPresenter">
508-
<Setter Property="Background" Value="Transparent"/>
509-
</Style>
510-
511432
<Style Selector="Button.caption_button">
512433
<Setter Property="Width" Value="48"/>
513434
<Setter Property="BorderThickness" Value="0"/>

src/Resources/Themes.axaml

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
33
<ResourceDictionary.ThemeDictionaries>
44
<ResourceDictionary x:Key="Light">
5-
<Color x:Key="Color.MacOS.Close">#FFED6A5E</Color>
6-
<Color x:Key="Color.MacOS.CloseFG">#FF69110A</Color>
7-
<Color x:Key="Color.MacOS.ClosePressed">#FFB24F46</Color>
8-
<Color x:Key="Color.MacOS.ClosePressedFG">#FF2E0402</Color>
9-
<Color x:Key="Color.MacOS.Minimize">#FFF4BF4F</Color>
10-
<Color x:Key="Color.MacOS.MinimizeFG">#FF8F591D</Color>
11-
<Color x:Key="Color.MacOS.MinimizePressed">#FFB78F3A</Color>
12-
<Color x:Key="Color.MacOS.MinimizePressedFG">#FF522A0A</Color>
13-
<Color x:Key="Color.MacOS.Maximize">#FF61C554</Color>
14-
<Color x:Key="Color.MacOS.MaximizeFG">#FF296017</Color>
15-
<Color x:Key="Color.MacOS.MaximizePressed">#FF48943F</Color>
16-
<Color x:Key="Color.MacOS.MaximizePressedFG">#FF102F07</Color>
175
<Color x:Key="Color.Window">#FFF0F5F9</Color>
186
<Color x:Key="Color.WindowBorder">#00000000</Color>
197
<Color x:Key="Color.TitleBar">#FFCFDEEA</Color>
@@ -46,18 +34,6 @@
4634
</ResourceDictionary>
4735

4836
<ResourceDictionary x:Key="Dark">
49-
<Color x:Key="Color.MacOS.Close">#FFED6A5E</Color>
50-
<Color x:Key="Color.MacOS.CloseFG">#FF8C1A10</Color>
51-
<Color x:Key="Color.MacOS.ClosePressed">#FFF09389</Color>
52-
<Color x:Key="Color.MacOS.ClosePressedFG">#FF69120A</Color>
53-
<Color x:Key="Color.MacOS.Minimize">#FFF4BF4F</Color>
54-
<Color x:Key="Color.MacOS.MinimizeFG">#FF8F591D</Color>
55-
<Color x:Key="Color.MacOS.MinimizePressed">#FFFBEB74</Color>
56-
<Color x:Key="Color.MacOS.MinimizePressedFG">#FF705F1B</Color>
57-
<Color x:Key="Color.MacOS.Maximize">#FF61C554</Color>
58-
<Color x:Key="Color.MacOS.MaximizeFG">#FF296017</Color>
59-
<Color x:Key="Color.MacOS.MaximizePressed">#FF86F37F</Color>
60-
<Color x:Key="Color.MacOS.MaximizePressedFG">#FF2C681A</Color>
6137
<Color x:Key="Color.Window">#FF252525</Color>
6238
<Color x:Key="Color.WindowBorder">#FF444444</Color>
6339
<Color x:Key="Color.TitleBar">#FF1F1F1F</Color>
@@ -89,19 +65,7 @@
8965
<Color x:Key="Color.Link">#4DAAFC</Color>
9066
</ResourceDictionary>
9167
</ResourceDictionary.ThemeDictionaries>
92-
93-
<SolidColorBrush x:Key="Brush.MacOS.Close" Color="{DynamicResource Color.MacOS.Close}"/>
94-
<SolidColorBrush x:Key="Brush.MacOS.CloseFG" Color="{DynamicResource Color.MacOS.CloseFG}"/>
95-
<SolidColorBrush x:Key="Brush.MacOS.ClosePressed" Color="{DynamicResource Color.MacOS.ClosePressed}"/>
96-
<SolidColorBrush x:Key="Brush.MacOS.ClosePressedFG" Color="{DynamicResource Color.MacOS.ClosePressedFG}"/>
97-
<SolidColorBrush x:Key="Brush.MacOS.Minimize" Color="{DynamicResource Color.MacOS.Minimize}"/>
98-
<SolidColorBrush x:Key="Brush.MacOS.MinimizeFG" Color="{DynamicResource Color.MacOS.MinimizeFG}"/>
99-
<SolidColorBrush x:Key="Brush.MacOS.MinimizePressed" Color="{DynamicResource Color.MacOS.MinimizePressed}"/>
100-
<SolidColorBrush x:Key="Brush.MacOS.MinimizePressedFG" Color="{DynamicResource Color.MacOS.MinimizePressedFG}"/>
101-
<SolidColorBrush x:Key="Brush.MacOS.Maximize" Color="{DynamicResource Color.MacOS.Maximize}"/>
102-
<SolidColorBrush x:Key="Brush.MacOS.MaximizeFG" Color="{DynamicResource Color.MacOS.MaximizeFG}"/>
103-
<SolidColorBrush x:Key="Brush.MacOS.MaximizePressed" Color="{DynamicResource Color.MacOS.MaximizePressed}"/>
104-
<SolidColorBrush x:Key="Brush.MacOS.MaximizePressedFG" Color="{DynamicResource Color.MacOS.MaximizePressedFG}"/>
68+
10569
<SolidColorBrush x:Key="Brush.Window" Color="{DynamicResource Color.Window}"/>
10670
<SolidColorBrush x:Key="Brush.WindowBorder" Color="{DynamicResource Color.WindowBorder}"/>
10771
<SolidColorBrush x:Key="Brush.TitleBar" Color="{DynamicResource Color.TitleBar}"/>

src/Views/About.axaml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,21 @@
2424
Margin="10,0,0,0"
2525
Data="{StaticResource Icons.Info}"
2626
IsVisible="{OnPlatform True, macOS=False}"/>
27-
28-
<Grid Grid.Column="0" Classes="caption_button_box" Margin="2,4,0,0" IsVisible="{OnPlatform False, macOS=True}">
29-
<Button Classes="caption_button_macos close" Click="CloseWindow">
30-
<Grid>
31-
<Ellipse/>
32-
<Path/>
33-
</Grid>
34-
</Button>
35-
</Grid>
27+
28+
<v:CaptionButtonsMacOS Grid.Column="0"
29+
Margin="0,2,0,0"
30+
IsCloseButtonOnly="True"
31+
IsVisible="{OnPlatform False, macOS=True}"/>
3632

3733
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
3834
Classes="bold"
3935
Text="{DynamicResource Text.About}"
4036
HorizontalAlignment="Center" VerticalAlignment="Center"
4137
IsHitTestVisible="False"/>
42-
43-
<Button Grid.Column="2"
44-
Classes="caption_button"
45-
Click="CloseWindow"
46-
IsVisible="{OnPlatform True, macOS=False}">
47-
<Path Data="{StaticResource Icons.Window.Close}"/>
48-
</Button>
38+
39+
<v:CaptionButtons Grid.Column="2"
40+
IsCloseButtonOnly="True"
41+
IsVisible="{OnPlatform True, macOS=False}"/>
4942
</Grid>
5043

5144
<Grid Grid.Row="1" ColumnDefinitions="Auto,*">

src/Views/About.axaml.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System.Reflection;
2-
32
using Avalonia.Input;
4-
using Avalonia.Interactivity;
53

64
namespace SourceGit.Views
75
{
@@ -28,11 +26,6 @@ private void BeginMoveWindow(object _, PointerPressedEventArgs e)
2826
BeginMoveDrag(e);
2927
}
3028

31-
private void CloseWindow(object _1, RoutedEventArgs _2)
32-
{
33-
Close();
34-
}
35-
3629
private void OnVisitAvaloniaUI(object _, PointerPressedEventArgs e)
3730
{
3831
Native.OS.OpenBrowser("https://www.avaloniaui.net/");

src/Views/Askpass.axaml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,21 @@
2424
Margin="10,0,0,0"
2525
Data="{StaticResource Icons.Password}"
2626
IsVisible="{OnPlatform True, macOS=False}"/>
27-
28-
<Grid Grid.Column="0" Classes="caption_button_box" Margin="2,4,0,0" IsVisible="{OnPlatform False, macOS=True}">
29-
<Button Classes="caption_button_macos close" Click="CloseWindow">
30-
<Grid>
31-
<Ellipse/>
32-
<Path/>
33-
</Grid>
34-
</Button>
35-
</Grid>
27+
28+
<v:CaptionButtonsMacOS Grid.Column="0"
29+
Margin="0,2,0,0"
30+
IsCloseButtonOnly="True"
31+
IsVisible="{OnPlatform False, macOS=True}"/>
3632

3733
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
3834
Classes="bold"
3935
Text="{DynamicResource Text.Askpass}"
4036
HorizontalAlignment="Center" VerticalAlignment="Center"
4137
IsHitTestVisible="False"/>
4238

43-
<Button Grid.Column="2"
44-
Classes="caption_button"
45-
Click="CloseWindow"
46-
IsVisible="{OnPlatform True, macOS=False}">
47-
<Path Data="{StaticResource Icons.Window.Close}"/>
48-
</Button>
39+
<v:CaptionButtons Grid.Column="2"
40+
IsCloseButtonOnly="True"
41+
IsVisible="{OnPlatform True, macOS=False}"/>
4942
</Grid>
5043

5144
<StackPanel Grid.Row="1" Margin="0,16" Orientation="Vertical">

src/Views/AssumeUnchangedManager.axaml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,20 @@
2828
Data="{StaticResource Icons.File.Ignore}"
2929
IsVisible="{OnPlatform True, macOS=False}"/>
3030

31-
<Grid Grid.Column="0" Classes="caption_button_box" Margin="2,4,0,0" IsVisible="{OnPlatform False, macOS=True}">
32-
<Button Classes="caption_button_macos close" Click="CloseWindow">
33-
<Grid>
34-
<Ellipse/>
35-
<Path/>
36-
</Grid>
37-
</Button>
38-
</Grid>
31+
<v:CaptionButtonsMacOS Grid.Column="0"
32+
Margin="0,2,0,0"
33+
IsCloseButtonOnly="True"
34+
IsVisible="{OnPlatform False, macOS=True}"/>
3935

4036
<TextBlock Grid.Column="0" Grid.ColumnSpan="3"
4137
Classes="bold"
4238
Text="{DynamicResource Text.AssumeUnchanged}"
4339
HorizontalAlignment="Center" VerticalAlignment="Center"
4440
IsHitTestVisible="False"/>
4541

46-
<Button Grid.Column="2"
47-
Classes="caption_button"
48-
Click="CloseWindow"
49-
IsVisible="{OnPlatform True, macOS=False}">
50-
<Path Data="{StaticResource Icons.Window.Close}"/>
51-
</Button>
42+
<v:CaptionButtons Grid.Column="2"
43+
IsCloseButtonOnly="True"
44+
IsVisible="{OnPlatform True, macOS=False}"/>
5245
</Grid>
5346

5447
<!-- Unchanged Files -->

src/Views/AssumeUnchangedManager.axaml.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ private void BeginMoveWindow(object _, PointerPressedEventArgs e)
1616
BeginMoveDrag(e);
1717
}
1818

19-
private void CloseWindow(object _1, RoutedEventArgs _2)
20-
{
21-
Close();
22-
}
23-
2419
private void OnRemoveButtonClicked(object sender, RoutedEventArgs e)
2520
{
2621
if (DataContext is ViewModels.AssumeUnchangedManager vm && sender is Button button)

src/Views/CaptionButtons.axaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Avalonia;
12
using Avalonia.Controls;
23
using Avalonia.Interactivity;
34
using Avalonia.VisualTree;
@@ -6,6 +7,15 @@ namespace SourceGit.Views
67
{
78
public partial class CaptionButtons : UserControl
89
{
10+
public static readonly StyledProperty<bool> IsCloseButtonOnlyProperty =
11+
AvaloniaProperty.Register<CaptionButtons, bool>(nameof(IsCloseButtonOnly));
12+
13+
public bool IsCloseButtonOnly
14+
{
15+
get => GetValue(IsCloseButtonOnlyProperty);
16+
set => SetValue(IsCloseButtonOnlyProperty, value);
17+
}
18+
919
public CaptionButtons()
1020
{
1121
InitializeComponent();

0 commit comments

Comments
 (0)