style<PageTabBar>: new style for page tab bar

This commit is contained in:
leo 2022-10-14 13:39:55 +08:00
parent 47bf5cbd8c
commit 80acfb6b1f
2 changed files with 40 additions and 15 deletions

View file

@ -7,7 +7,7 @@
xmlns:controls="clr-namespace:SourceGit.Views.Controls" xmlns:controls="clr-namespace:SourceGit.Views.Controls"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="28" d:DesignWidth="800"> d:DesignHeight="28" d:DesignWidth="800">
<Grid> <Grid Margin="6,4,0,0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
@ -19,10 +19,9 @@
Grid.Column="0" Grid.Column="0"
x:Name="leftScroller" x:Name="leftScroller"
Click="ScrollLeft" Click="ScrollLeft"
Width="18" Padding="5" Width="18" Padding="6"
HoverBackground="{DynamicResource Brush.Accent1}" HoverBackground="{DynamicResource Brush.NewPageHover}"
BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0"
BorderThickness="0,0,1,0"
Icon="{StaticResource Icon.ScrollLeft}" Icon="{StaticResource Icon.ScrollLeft}"
WindowChrome.IsHitTestVisibleInChrome="True" WindowChrome.IsHitTestVisibleInChrome="True"
Visibility="Collapsed"/> Visibility="Collapsed"/>
@ -35,7 +34,8 @@
VerticalScrollBarVisibility="Disabled"> VerticalScrollBarVisibility="Disabled">
<StackPanel Orientation="Horizontal" SizeChanged="CalcScrollerVisibilty"> <StackPanel Orientation="Horizontal" SizeChanged="CalcScrollerVisibilty">
<ListBox <ListBox
x:Name="container" x:Name="container"
BorderBrush="{DynamicResource Brush.Border0}"
ItemsSource="{Binding ElementName=me, Path=Tabs}" ItemsSource="{Binding ElementName=me, Path=Tabs}"
WindowChrome.IsHitTestVisibleInChrome="True" WindowChrome.IsHitTestVisibleInChrome="True"
SelectionChanged="SelectionChanged"> SelectionChanged="SelectionChanged">
@ -54,15 +54,15 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}"> <ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="Border" Background="Transparent" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,1,0"> <Border x:Name="Border" Background="Transparent" BorderBrush="Transparent" BorderThickness="1,1,1,0">
<StackPanel Margin="8,0" x:Name="Contents" Orientation="Horizontal" VerticalAlignment="Center" Opacity=".5" ToolTip="{Binding Tooltip}"> <StackPanel x:Name="Contents" Orientation="Horizontal" VerticalAlignment="Center" Opacity=".5" ToolTip="{Binding Tooltip}">
<controls:Bookmark <controls:Bookmark
Width="14" Height="14" Width="14" Height="14"
Margin="8,0,0,0"
IsNewPage="{Binding IsWelcomePage}" IsNewPage="{Binding IsWelcomePage}"
Color="{Binding Bookmark}"/> Color="{Binding Bookmark}"/>
<TextBlock <TextBlock
Grid.Column="1"
Margin="4,0" Margin="4,0"
Text="{Binding Title}"/> Text="{Binding Title}"/>
@ -73,14 +73,24 @@
ToolTip="{DynamicResource Text.Close}" ToolTip="{DynamicResource Text.Close}"
Icon="{StaticResource Icon.Close}" Icon="{StaticResource Icon.Close}"
HoverBackground="{DynamicResource Brush.NewPageHover}"/> HoverBackground="{DynamicResource Brush.NewPageHover}"/>
<Rectangle
x:Name="seperator"
Margin="4,2,0,0"
Width="1"
Fill="Transparent"/>
</StackPanel> </StackPanel>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True"> <Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Brush.Border0}"/>
<Setter TargetName="Border" Property="Background" Value="{DynamicResource Brush.Window}"/> <Setter TargetName="Border" Property="Background" Value="{DynamicResource Brush.Window}"/>
<Setter TargetName="Contents" Property="Opacity" Value="1"/> <Setter TargetName="Contents" Property="Opacity" Value="1"/>
</Trigger> </Trigger>
<DataTrigger Binding="{Binding IsSeperatorVisible}" Value="True">
<Setter TargetName="seperator" Property="Fill" Value="{DynamicResource Brush.FG2}"/>
</DataTrigger>
<MultiTrigger> <MultiTrigger>
<MultiTrigger.Conditions> <MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False"/> <Condition Property="IsSelected" Value="False"/>
@ -100,8 +110,7 @@
</ListBox> </ListBox>
<controls:IconButton <controls:IconButton
Width="20" Height="20" Width="16" Height="16" Margin="4,0,0,0" Padding="2"
Margin="4,0" Padding="4"
Icon="{StaticResource Icon.NewTab}" Icon="{StaticResource Icon.NewTab}"
HoverBackground="{DynamicResource Brush.NewPageHover}" HoverBackground="{DynamicResource Brush.NewPageHover}"
ToolTip="{DynamicResource Text.PageTabBar.New}" ToolTip="{DynamicResource Text.PageTabBar.New}"
@ -115,10 +124,9 @@
Grid.Column="2" Grid.Column="2"
x:Name="rightScroller" x:Name="rightScroller"
Click="ScrollRight" Click="ScrollRight"
Width="18" Padding="5" Width="18" Padding="6"
HoverBackground="{DynamicResource Brush.Accent1}" HoverBackground="{DynamicResource Brush.NewPageHover}"
BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0"
BorderThickness="1,0"
Icon="{StaticResource Icon.ScrollRight}" Icon="{StaticResource Icon.ScrollRight}"
WindowChrome.IsHitTestVisibleInChrome="True" WindowChrome.IsHitTestVisibleInChrome="True"
Visibility="Collapsed"/> Visibility="Collapsed"/>

View file

@ -33,6 +33,12 @@ namespace SourceGit.Views.Widgets {
get => bookmark; get => bookmark;
set => SetProperty(ref bookmark, value); set => SetProperty(ref bookmark, value);
} }
private bool isSeperatorVisible = false;
public bool IsSeperatorVisible {
get => isSeperatorVisible;
set => SetProperty(ref isSeperatorVisible, value);
}
} }
/// <summary> /// <summary>
@ -217,6 +223,17 @@ namespace SourceGit.Views.Widgets {
private void SelectionChanged(object sender, SelectionChangedEventArgs e) { private void SelectionChanged(object sender, SelectionChangedEventArgs e) {
var tab = container.SelectedItem as Tab; var tab = container.SelectedItem as Tab;
if (tab == null) return; if (tab == null) return;
for (int i = 0; i < Tabs.Count; i++) {
if (Tabs[i] == tab) {
tab.IsSeperatorVisible = false;
if (i > 0) Tabs[i - 1].IsSeperatorVisible = false;
} else {
Tabs[i].IsSeperatorVisible = true;
}
}
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, tab.Id)); RaiseEvent(new TabEventArgs(TabSelectedEvent, this, tab.Id));
} }