style<Launcher>: hide tab close button by default

This commit is contained in:
leo 2020-10-30 12:05:52 +08:00
parent 3b7a030846
commit dbf5ffe01b
2 changed files with 40 additions and 32 deletions

View file

@ -70,7 +70,7 @@
<TabControl.ItemContainerStyle> <TabControl.ItemContainerStyle>
<Style TargetType="{x:Type TabItem}"> <Style TargetType="{x:Type TabItem}">
<Setter Property="AllowDrop" Value="True"/> <Setter Property="AllowDrop" Value="{Binding AllowDragDrop}"/>
<Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/> <Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/>
<Setter Property="Margin" Value="0"/> <Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/> <Setter Property="Padding" Value="0"/>
@ -104,14 +104,25 @@
Data="M 0,0 L 0,6 6,6 C 6,6 0,6 0,0 Z" Data="M 0,0 L 0,6 6,6 C 6,6 0,6 0,0 Z"
Fill="Transparent"/> Fill="Transparent"/>
<ContentPresenter <StackPanel Orientation="Horizontal" Margin="8,0" VerticalAlignment="Center">
x:Name="ContentSite" <Path Grid.Column="0" Width="14" Height="14" x:Name="Icon" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Git}"/>
VerticalAlignment="Center" HorizontalAlignment="Center"
TextElement.Foreground="{DynamicResource Brush.FG}" <ContentPresenter
TextElement.FontWeight="Bold" x:Name="ContentSite"
ContentSource="Header" VerticalAlignment="Center" HorizontalAlignment="Center"
Margin="4,0" TextElement.Foreground="{DynamicResource Brush.FG}"
RecognizesAccessKey="True" /> TextElement.FontWeight="Bold"
ContentSource="Header"
Margin="8,0"
RecognizesAccessKey="True" />
<Button x:Name="Closer" Background="Transparent" Grid.Column="2" Click="CloseRepo" Visibility="Hidden">
<Button.ToolTip>
<ToolTip Content="CLOSE" FontWeight="Normal"/>
</Button.ToolTip>
<Path Width="8" Height="8" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Close}"/>
</Button>
</StackPanel>
</Grid> </Grid>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True"> <Trigger Property="IsSelected" Value="True">
@ -121,6 +132,17 @@
<Setter TargetName="CornerLeft" Property="Fill" Value="{StaticResource Brush.BG1}"/> <Setter TargetName="CornerLeft" Property="Fill" Value="{StaticResource Brush.BG1}"/>
<Setter TargetName="CornerRight" Property="Fill" Value="{StaticResource Brush.BG1}"/> <Setter TargetName="CornerRight" Property="Fill" Value="{StaticResource Brush.BG1}"/>
</Trigger> </Trigger>
<Trigger Property="AllowDrop" Value="False">
<Setter TargetName="Icon" Property="Fill" Value="#FFF05133"/>
<Setter TargetName="Closer" Property="Visibility" Value="Collapsed"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="AllowDrop" Value="True"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter TargetName="Closer" Property="Visibility" Value="Visible"/>
</MultiTrigger>
<MultiTrigger> <MultiTrigger>
<MultiTrigger.Conditions> <MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False"/> <Condition Property="IsSelected" Value="False"/>
@ -140,28 +162,11 @@
<TabControl.ItemTemplate> <TabControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal" Margin="6,0" VerticalAlignment="Center"> <TextBlock Grid.Column="1" Text="{Binding Title}" Foreground="{StaticResource Brush.FG}" FontWeight="Bold">
<Path Grid.Column="0" Width="14" Height="14" x:Name="Icon" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Git}"/> <TextBlock.ToolTip>
<TextBlock Grid.Column="1" Text="{Binding Title}" Foreground="{StaticResource Brush.FG}" Margin="8,0,0,0" FontWeight="Bold"> <ToolTip Content="{Binding Tooltip}" FontWeight="Normal"/>
<TextBlock.ToolTip> </TextBlock.ToolTip>
<ToolTip Content="{Binding Tooltip}" FontWeight="Normal"/> </TextBlock>
</TextBlock.ToolTip>
</TextBlock>
<Button x:Name="Closer" Margin="8,0,0,0" Grid.Column="2" Click="CloseRepo">
<Button.ToolTip>
<ToolTip Content="CLOSE" FontWeight="Normal"/>
</Button.ToolTip>
<Path Width="8" Height="8" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Close}"/>
</Button>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Repo}" Value="{x:Null}">
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Git}"/>
<Setter TargetName="Icon" Property="Fill" Value="#FFF05133"/>
<Setter TargetName="Closer" Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate> </DataTemplate>
</TabControl.ItemTemplate> </TabControl.ItemTemplate>
</TabControl> </TabControl>

View file

@ -16,6 +16,7 @@ namespace SourceGit.UI {
public class Tab { public class Tab {
public string Title { get; set; } public string Title { get; set; }
public string Tooltip { get; set; } public string Tooltip { get; set; }
public bool AllowDragDrop { get; set; }
public bool IsActive { get; set; } public bool IsActive { get; set; }
public Git.Repository Repo { get; set; } public Git.Repository Repo { get; set; }
public object Page { get; set; } public object Page { get; set; }
@ -41,6 +42,7 @@ namespace SourceGit.UI {
var tab = new Tab() { var tab = new Tab() {
Title = repo.Parent == null ? repo.Name : $"{repo.Parent.Name} : {repo.Name}", Title = repo.Parent == null ? repo.Name : $"{repo.Parent.Name} : {repo.Name}",
Tooltip = repo.Path, Tooltip = repo.Path,
AllowDragDrop = true,
Repo = repo, Repo = repo,
Page = page, Page = page,
}; };
@ -54,6 +56,7 @@ namespace SourceGit.UI {
Tabs.Add(new Tab() { Tabs.Add(new Tab() {
Title = "SOURCE GIT", Title = "SOURCE GIT",
Tooltip = "Welcome Page", Tooltip = "Welcome Page",
AllowDragDrop = false,
Page = new Manager(), Page = new Manager(),
}); });