Skip to content

Commit c247b03

Browse files
committed
feature: allow customized font size
1 parent 7ba7e58 commit c247b03

23 files changed

+137
-87
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Avalonia.Data.Converters;
2+
3+
namespace SourceGit.Converters
4+
{
5+
public static class FontSizeModifyConverters
6+
{
7+
public static FuncValueConverter<double, double> Increase =
8+
new FuncValueConverter<double, double>(v => v + 1.0);
9+
10+
public static FuncValueConverter<double, double> Decrease =
11+
new FuncValueConverter<double, double>(v => v - 1.0);
12+
}
13+
}

src/SourceGit/Resources/Locales.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SourceGit/Resources/Locales.en.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,4 +1296,7 @@
12961296
<data name="Text.Preference.General.MonospaceFont" xml:space="preserve">
12971297
<value>Monospace FontFamily</value>
12981298
</data>
1299+
<data name="Text.Preference.General.DefaultFontSize" xml:space="preserve">
1300+
<value>Default Font Size</value>
1301+
</data>
12991302
</root>

src/SourceGit/Resources/Locales.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,4 +1296,7 @@
12961296
<data name="Text.Preference.General.MonospaceFont" xml:space="preserve">
12971297
<value>Monospace FontFamily</value>
12981298
</data>
1299+
<data name="Text.Preference.General.DefaultFontSize" xml:space="preserve">
1300+
<value>Default Font Size</value>
1301+
</data>
12991302
</root>

src/SourceGit/Resources/Locales.zh.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,4 +1296,7 @@
12961296
<data name="Text.Preference.General.MonospaceFont" xml:space="preserve">
12971297
<value>等宽字体</value>
12981298
</data>
1299+
<data name="Text.Preference.General.DefaultFontSize" xml:space="preserve">
1300+
<value>默认字体大小</value>
1301+
</data>
12991302
</root>

src/SourceGit/Resources/Styles.axaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<Style Selector="ContentPresenter">
1919
<Setter Property="FontFamily" Value="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFont}"/>
20+
<Setter Property="FontSize" Value="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize}"/>
2021
</Style>
2122

2223
<Style Selector="Path">
@@ -58,7 +59,6 @@
5859
</Style>
5960

6061
<Style Selector="TextBlock">
61-
<Setter Property="FontSize" Value="13"/>
6262
<Setter Property="HorizontalAlignment" Value="Left"/>
6363
<Setter Property="VerticalAlignment" Value="Center"/>
6464
<Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/>
@@ -74,13 +74,11 @@
7474
</Style>
7575
<Style Selector="TextBlock.group_header_label">
7676
<Setter Property="Foreground" Value="{DynamicResource Brush.FG2}"/>
77-
<Setter Property="FontSize" Value="13"/>
7877
<Setter Property="FontWeight" Value="Bold"/>
7978
<Setter Property="Margin" Value="8,0,0,0"/>
8079
</Style>
8180
<Style Selector="TextBlock.info_label">
8281
<Setter Property="Foreground" Value="{DynamicResource Brush.FG2}"/>
83-
<Setter Property="FontSize" Value="13"/>
8482
<Setter Property="FontWeight" Value="Bold"/>
8583
<Setter Property="HorizontalAlignment" Value="Right"/>
8684
</Style>
@@ -103,7 +101,6 @@
103101
</Style>
104102

105103
<Style Selector="TextBox">
106-
<Setter Property="FontSize" Value="13"/>
107104
<Setter Property="CornerRadius" Value="0"/>
108105
<Setter Property="Padding" Value="4,0"/>
109106
<Setter Property="MinHeight" Value="16"/>
@@ -452,8 +449,7 @@
452449
Margin="0 5 0 0"
453450
Grid.Column="2"
454451
Grid.Row="2">
455-
<TextBlock Name="PART_MessageContent"
456-
FontSize="11" />
452+
<TextBlock Name="PART_MessageContent" FontSize="11" />
457453
</StackPanel>
458454
</Grid>
459455
</Border>
@@ -588,7 +584,6 @@
588584
<Setter Property="Height" Value="26"/>
589585
<Setter Property="Background" Value="Transparent" />
590586
<Setter Property="Foreground" Value="{DynamicResource Brush.FG1}" />
591-
<Setter Property="TextElement.FontSize" Value="12"/>
592587
<Setter Property="Template">
593588
<ControlTemplate>
594589
<Panel>
@@ -729,7 +724,6 @@
729724
<SolidColorBrush x:Key="ComboBoxDropDownBorderBrush" Color="{DynamicResource Color.Accent1}"/>
730725
</Style.Resources>
731726

732-
<Setter Property="TextElement.FontSize" Value="13"/>
733727
<Setter Property="MinHeight" Value="20"/>
734728
<Setter Property="VerticalAlignment" Value="Center"/>
735729
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border1}"/>

src/SourceGit/ViewModels/Preference.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ public FontFamily MonospaceFont
9696
set => SetProperty(ref _monospaceFont, value);
9797
}
9898

99+
public double DefaultFontSize
100+
{
101+
get => _defaultFontSize;
102+
set => SetProperty(ref _defaultFontSize, value);
103+
}
104+
99105
public string AvatarServer
100106
{
101107
get => Models.AvatarManager.SelectedServer;
@@ -379,6 +385,7 @@ private static bool RemoveNodeRecursive(RepositoryNode node, AvaloniaList<Reposi
379385
private string _theme = "Default";
380386
private FontFamily _defaultFont = null;
381387
private FontFamily _monospaceFont = null;
388+
private double _defaultFontSize = 13;
382389

383390
private int _maxHistoryCommits = 20000;
384391
private bool _restoreTabs = false;

src/SourceGit/Views/Blame.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
<!-- File -->
6161
<Border Grid.Row="1" Padding="8,0" Background="{DynamicResource Brush.Window}">
62-
<TextBlock Text="{Binding Title}" FontSize="12" VerticalAlignment="Center"/>
62+
<TextBlock Text="{Binding Title}" VerticalAlignment="Center"/>
6363
</Border>
6464

6565
<!-- Body -->
@@ -73,7 +73,6 @@
7373
Background="{DynamicResource Brush.Contents}"
7474
Foreground="{DynamicResource Brush.FG1}"
7575
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
76-
FontSize="12"
7776
BlameData="{Binding Data}"/>
7877

7978
<!-- Not supported mask (for binary files) -->

src/SourceGit/Views/CommitBaseInfo.axaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,27 @@
1818
<StackPanel Grid.Column="1" Margin="16,0,8,0" Orientation="Vertical">
1919
<TextBlock Classes="group_header_label" Margin="0" Text="{DynamicResource Text.CommitDetail.Info.Author}"/>
2020
<StackPanel Orientation="Horizontal" Margin="0,10,0,8">
21-
<SelectableTextBlock Text="{Binding Author.Name}" FontSize="12" Margin="2,0,8,0"/>
22-
<SelectableTextBlock Text="{Binding Author.Email}" FontSize="12" Foreground="{DynamicResource Brush.FG2}"/>
21+
<SelectableTextBlock Text="{Binding Author.Name}" Margin="2,0,8,0"/>
22+
<SelectableTextBlock Text="{Binding Author.Email}" Foreground="{DynamicResource Brush.FG2}"/>
2323
</StackPanel>
24-
<SelectableTextBlock Text="{Binding AuthorTimeStr}" Margin="2,0,0,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
24+
<SelectableTextBlock Text="{Binding AuthorTimeStr}"
25+
Margin="2,0,0,0"
26+
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:FontSizeModifyConverters.Decrease}}"
27+
Foreground="{DynamicResource Brush.FG2}"/>
2528
</StackPanel>
2629

2730
<!-- Committer -->
2831
<v:Avatar Grid.Column="2" Width="64" Height="64" HorizontalAlignment="Right" User="{Binding Committer}" IsVisible="{Binding IsCommitterVisible}"/>
2932
<StackPanel Grid.Column="3" Margin="16,0,8,0" Orientation="Vertical" IsVisible="{Binding IsCommitterVisible}">
3033
<TextBlock Classes="group_header_label" Margin="0" Text="{DynamicResource Text.CommitDetail.Info.Committer}"/>
3134
<StackPanel Orientation="Horizontal" Margin="0,10,0,8">
32-
<SelectableTextBlock Text="{Binding Committer.Name}" FontSize="12" Margin="2,0,8,0"/>
33-
<SelectableTextBlock Text="{Binding Committer.Email}" FontSize="12" Foreground="{DynamicResource Brush.FG2}"/>
35+
<SelectableTextBlock Text="{Binding Committer.Name}" Margin="2,0,8,0"/>
36+
<SelectableTextBlock Text="{Binding Committer.Email}" Foreground="{DynamicResource Brush.FG2}"/>
3437
</StackPanel>
35-
<SelectableTextBlock Text="{Binding CommitterTimeStr}" Margin="2,0,0,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
38+
<SelectableTextBlock Text="{Binding CommitterTimeStr}"
39+
Margin="2,0,0,0"
40+
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:FontSizeModifyConverters.Decrease}}"
41+
Foreground="{DynamicResource Brush.FG2}"/>
3642
</StackPanel>
3743
</Grid>
3844

@@ -43,7 +49,7 @@
4349
<Grid RowDefinitions="24,Auto,Auto,Auto" ColumnDefinitions="96,*">
4450
<!-- SHA -->
4551
<TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
46-
<SelectableTextBlock Grid.Row="0" Grid.Column="1" Text="{Binding SHA}" Margin="12,0,0,0" FontSize="12" VerticalAlignment="Center" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"/>
52+
<SelectableTextBlock Grid.Row="0" Grid.Column="1" Text="{Binding SHA}" Margin="12,0,0,0" VerticalAlignment="Center" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"/>
4753

4854
<!-- PARENTS -->
4955
<TextBlock Grid.Row="1" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"/>
@@ -58,7 +64,6 @@
5864
<DataTemplate>
5965
<TextBlock Classes="monospace"
6066
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
61-
FontSize="12"
6267
Foreground="DarkOrange"
6368
TextDecorations="Underline"
6469
Margin="0,0,16,0"
@@ -95,7 +100,7 @@
95100
<!-- Messages -->
96101
<TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Message}" VerticalAlignment="Top" Margin="0,4,0,0" />
97102
<ScrollViewer Grid.Row="3" Grid.Column="1" Margin="12,5,0,0" MaxHeight="100" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
98-
<SelectableTextBlock Text="{Binding FullMessage}" FontSize="12" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" TextWrapping="Wrap"/>
103+
<SelectableTextBlock Text="{Binding FullMessage}" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" TextWrapping="Wrap"/>
99104
</ScrollViewer>
100105
</Grid>
101106

src/SourceGit/Views/CommitChanges.axaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<!-- Search & Display Mode -->
2020
<Grid Grid.Row="0" ColumnDefinitions="*,24">
2121
<TextBox Grid.Column="0"
22-
FontSize="12"
2322
Height="26"
2423
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
2524
Background="Transparent"
@@ -75,7 +74,7 @@
7574
<DataGridTemplateColumn Width="*" Header="PATH">
7675
<DataGridTemplateColumn.CellTemplate>
7776
<DataTemplate>
78-
<TextBlock Classes="monospace" Text="{Binding Path}" Margin="4,0,0,0" FontSize="12"/>
77+
<TextBlock Classes="monospace" Text="{Binding Path}" Margin="4,0,0,0"/>
7978
</DataTemplate>
8079
</DataGridTemplateColumn.CellTemplate>
8180
</DataGridTemplateColumn>
@@ -110,15 +109,15 @@
110109
<DataGridTemplateColumn Header="FILE_NAME">
111110
<DataGridTemplateColumn.CellTemplate>
112111
<DataTemplate>
113-
<TextBlock Classes="monospace" Text="{Binding Path, Converter={x:Static c:PathConverters.PureFileName}}" Margin="4,0,0,0" FontSize="12"/>
112+
<TextBlock Classes="monospace" Text="{Binding Path, Converter={x:Static c:PathConverters.PureFileName}}" Margin="4,0,0,0"/>
114113
</DataTemplate>
115114
</DataGridTemplateColumn.CellTemplate>
116115
</DataGridTemplateColumn>
117116

118117
<DataGridTemplateColumn Header="FOLDER_PATH">
119118
<DataGridTemplateColumn.CellTemplate>
120119
<DataTemplate>
121-
<TextBlock Classes="monospace" Text="{Binding Path, Converter={x:Static c:PathConverters.PureDirectoryName}}" Margin="4,0,0,0" FontSize="12" Foreground="{DynamicResource Brush.FG2}"/>
120+
<TextBlock Classes="monospace" Text="{Binding Path, Converter={x:Static c:PathConverters.PureDirectoryName}}" Margin="4,0,0,0" Foreground="{DynamicResource Brush.FG2}"/>
122121
</DataTemplate>
123122
</DataGridTemplateColumn.CellTemplate>
124123
</DataGridTemplateColumn>
@@ -143,7 +142,7 @@
143142
<Grid Height="24" ColumnDefinitions="Auto,*">
144143
<Path Grid.Column="0" Classes="folder_icon" Width="14" Height="14" Margin="0,2,0,0" IsVisible="{Binding IsFolder}" Fill="Goldenrod" VerticalAlignment="Center"/>
145144
<v:ChangeStatusIcon Grid.Column="0" Width="14" Height="14" IsWorkingCopyChange="False" Change="{Binding Backend}" IsVisible="{Binding !IsFolder}"/>
146-
<TextBlock Grid.Column="1" Classes="monospace" Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}" FontSize="12" Margin="6,0,0,0"/>
145+
<TextBlock Grid.Column="1" Classes="monospace" Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}" Margin="6,0,0,0"/>
147146
</Grid>
148147
</TreeDataTemplate>
149148
</TreeView.ItemTemplate>

0 commit comments

Comments
 (0)