mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
style<Launcher>: supports two size rules for tabs in titlebar - fixed width or size to content
This commit is contained in:
parent
e3a7abe776
commit
7b70951c93
6 changed files with 40 additions and 10 deletions
|
@ -381,6 +381,7 @@
|
|||
<sys:String x:Key="Text.Preference.General.Theme">Theme</sys:String>
|
||||
<sys:String x:Key="Text.Preference.General.MaxHistoryCommits">History Commits</sys:String>
|
||||
<sys:String x:Key="Text.Preference.General.RestoreTabs">Restore windows</sys:String>
|
||||
<sys:String x:Key="Text.Preference.General.UseFixedTabWidth">Use fixed tab width in titlebar</sys:String>
|
||||
<sys:String x:Key="Text.Preference.General.UseMacOSStyle">Use macOS style titlebar</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git">GIT</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git.Path">Install Path</sys:String>
|
||||
|
|
|
@ -380,6 +380,7 @@
|
|||
<sys:String x:Key="Text.Preference.General.Theme">主题</sys:String>
|
||||
<sys:String x:Key="Text.Preference.General.MaxHistoryCommits">最大历史提交数</sys:String>
|
||||
<sys:String x:Key="Text.Preference.General.RestoreTabs">启动时恢复上次打开的仓库</sys:String>
|
||||
<sys:String x:Key="Text.Preference.General.UseFixedTabWidth">使用固定宽度的标题栏标签</sys:String>
|
||||
<sys:String x:Key="Text.Preference.General.UseMacOSStyle">使用macOS风格的标题栏</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git">GIT配置</sys:String>
|
||||
<sys:String x:Key="Text.Preference.Git.Path">安装路径</sys:String>
|
||||
|
|
|
@ -71,6 +71,11 @@ namespace SourceGit.ViewModels {
|
|||
set => SetProperty(ref _restoreTabs, value);
|
||||
}
|
||||
|
||||
public bool UseFixedTabWidth {
|
||||
get => _useFixedTabWidth;
|
||||
set => SetProperty(ref _useFixedTabWidth, value);
|
||||
}
|
||||
|
||||
public bool UseMacOSStyle {
|
||||
get => _useMacOSStyle;
|
||||
set => SetProperty(ref _useMacOSStyle, value);
|
||||
|
@ -274,6 +279,7 @@ namespace SourceGit.ViewModels {
|
|||
private string _theme = "Default";
|
||||
private int _maxHistoryCommits = 20000;
|
||||
private bool _restoreTabs = false;
|
||||
private bool _useFixedTabWidth = true;
|
||||
private bool _useMacOSStyle = OperatingSystem.IsMacOS();
|
||||
private bool _useTwoColumnsLayoutInHistories = false;
|
||||
private bool _useCombinedTextDiff = true;
|
||||
|
|
|
@ -138,19 +138,17 @@
|
|||
</ContextMenu>
|
||||
</Border.ContextMenu>
|
||||
|
||||
<Grid Classes="launcher_pagetab_container" Width="200" Height="30" ColumnDefinitions="Auto,*,Auto" VerticalAlignment="Center">
|
||||
<Path Classes="launcher_pagetab_icon"
|
||||
Grid.Column="0"
|
||||
Width="12" Height="12" Margin="12,0,8,0"
|
||||
<v:LauncherTab UseFixedTabWidth="{Binding Source={x:Static vm:Preference.Instance}, Path=UseFixedTabWidth}" Height="30" ColumnDefinitions="Auto,*,Auto" VerticalAlignment="Center">
|
||||
<Path Grid.Column="0"
|
||||
Width="12" Height="12" Margin="12,0"
|
||||
Fill="{Binding Node.Bookmark, Converter={x:Static c:BookmarkConverters.ToBrush}}"
|
||||
StrokeThickness="{Binding Node.Bookmark, Converter={x:Static c:BookmarkConverters.ToStrokeThickness}}"
|
||||
Stroke="{DynamicResource Brush.FG1}"
|
||||
Data="{StaticResource Icons.Bookmark}"
|
||||
IsVisible="{Binding Node.IsRepository}"
|
||||
IsHitTestVisible="False"/>
|
||||
<Path Classes="launcher_pagetab_icon"
|
||||
Grid.Column="0"
|
||||
Width="12" Height="12" Margin="12,0,8,0"
|
||||
<Path Grid.Column="0"
|
||||
Width="12" Height="12" Margin="12,0"
|
||||
Fill="{DynamicResource Brush.FG1}"
|
||||
Data="{StaticResource Icons.Repositories}"
|
||||
IsVisible="{Binding !Node.IsRepository}"
|
||||
|
@ -171,7 +169,7 @@
|
|||
IsHitTestVisible="False"/>
|
||||
<Button Grid.Column="2"
|
||||
Classes="icon_button"
|
||||
Width="16" Height="16" Margin="8,0"
|
||||
Width="16" Height="16" Margin="12,0"
|
||||
Command="{Binding #me.DataContext.(vm:Launcher).CloseTab}"
|
||||
CommandParameter="{Binding}"
|
||||
ToolTip.Tip="{DynamicResource Text.PageTabBar.Tab.Close}">
|
||||
|
@ -186,7 +184,7 @@
|
|||
</MultiBinding>
|
||||
</Rectangle.IsVisible>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
</v:LauncherTab>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
|
|
@ -2,8 +2,27 @@ using Avalonia;
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using System;
|
||||
|
||||
namespace SourceGit.Views {
|
||||
public class LauncherTab : Grid {
|
||||
public static readonly StyledProperty<bool> UseFixedTabWidthProperty =
|
||||
AvaloniaProperty.Register<LauncherTab, bool>(nameof(UseFixedTabWidth), false);
|
||||
|
||||
public bool UseFixedTabWidth {
|
||||
get => GetValue(UseFixedTabWidthProperty);
|
||||
set => SetValue(UseFixedTabWidthProperty, value);
|
||||
}
|
||||
|
||||
protected override Type StyleKeyOverride => typeof(Grid);
|
||||
|
||||
static LauncherTab() {
|
||||
UseFixedTabWidthProperty.Changed.AddClassHandler<LauncherTab>((tab, ev) => {
|
||||
tab.Width = tab.UseFixedTabWidth ? 200.0 : double.NaN;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Launcher : Window, Models.INotificationReceiver {
|
||||
public Launcher() {
|
||||
DataContext = new ViewModels.Launcher();
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<TabItem.Header>
|
||||
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preference.General}"/>
|
||||
</TabItem.Header>
|
||||
<Grid Margin="8" RowDefinitions="32,32,32,32,32,Auto" ColumnDefinitions="Auto,*">
|
||||
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,Auto" ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.General.Locale}"
|
||||
HorizontalAlignment="Right"
|
||||
|
@ -135,6 +135,11 @@
|
|||
IsChecked="{Binding RestoreTabs, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
Height="32"
|
||||
Content="{DynamicResource Text.Preference.General.UseFixedTabWidth}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseFixedTabWidth, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
Height="32"
|
||||
Content="{DynamicResource Text.Preference.General.UseMacOSStyle}"
|
||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseMacOSStyle, Mode=TwoWay}"
|
||||
|
|
Loading…
Reference in a new issue