sourcegit/src/Views/Widgets/PageTabBar.xaml

162 lines
9 KiB
Text
Raw Normal View History

2021-04-29 05:05:55 -07:00
<UserControl x:Class="SourceGit.Views.Widgets.PageTabBar"
x:Name="me"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
xmlns:converters="clr-namespace:SourceGit.Views.Converters"
2021-04-29 05:05:55 -07:00
mc:Ignorable="d"
d:DesignHeight="28" d:DesignWidth="800">
<Grid Margin="0,4,0,0">
2021-04-29 05:05:55 -07:00
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1"/>
2021-04-29 05:05:55 -07:00
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- Seperator -->
<Rectangle
Grid.Column="0"
x:Name="startSeperator"
2022-10-19 00:28:01 -07:00
Width="1" Height="16"
Fill="{DynamicResource Brush.FG2}"
Opacity=".5"/>
2021-04-29 05:05:55 -07:00
<!-- Left Scroller -->
<controls:IconButton
Grid.Column="1"
2021-04-29 05:05:55 -07:00
x:Name="leftScroller"
Click="ScrollLeft"
Width="18" Padding="6"
2022-10-25 06:50:58 -07:00
HoverBackground="{DynamicResource Brush.TabButtonHover}"
BorderThickness="0"
2021-04-29 05:05:55 -07:00
Icon="{StaticResource Icon.ScrollLeft}"
WindowChrome.IsHitTestVisibleInChrome="True"
Visibility="Collapsed"/>
2021-04-29 05:05:55 -07:00
<!-- Tabs -->
<ScrollViewer
Grid.Column="2"
2021-04-29 05:05:55 -07:00
x:Name="scroller"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Disabled">
<StackPanel Orientation="Horizontal" SizeChanged="CalcScrollerVisibilty">
<ListBox
x:Name="container"
BorderBrush="{DynamicResource Brush.Border0}"
2021-04-29 05:05:55 -07:00
ItemsSource="{Binding ElementName=me, Path=Tabs}"
WindowChrome.IsHitTestVisibleInChrome="True"
SelectionChanged="SelectionChanged">
<ListBox.Resources>
<converters:IntToBookmarkBrush x:Key="IntToBookmarkBrush"/>
<converters:BoolToCollapsed x:Key="BoolToCollapsed"/>
</ListBox.Resources>
2021-04-29 05:05:55 -07:00
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<EventSetter Event="ContextMenuOpening" Handler="OnTabContextMenuOpening" />
<EventSetter Event="MouseMove" Handler="OnMouseMove"/>
<EventSetter Event="DragOver" Handler="OnDragOver"/>
<EventSetter Event="Drop" Handler="OnDrop"/>
<EventSetter Event="GiveFeedback" Handler="OnGiveFeedback"/>
2021-04-29 05:05:55 -07:00
<Setter Property="AllowDrop" Value="True"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
2021-04-29 05:05:55 -07:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="Border" Background="Transparent" BorderBrush="Transparent" BorderThickness="1,1,1,0">
<Grid x:Name="Contents" Width="160" VerticalAlignment="Center" Opacity=".5" ToolTip="{Binding Tooltip}">
<Path
Width="8" Margin="8,0,0,0"
HorizontalAlignment="Left"
Fill="{Binding Bookmark, Converter={StaticResource IntToBookmarkBrush}}"
Visibility="{Binding IsRepository, Converter={StaticResource BoolToCollapsed}}">
<Path.Data>
<EllipseGeometry Center="0,0" RadiusX="14" RadiusY="14"/>
</Path.Data>
</Path>
<TextBlock Margin="32,0" HorizontalAlignment="Stretch" TextAlignment="Center" Text="{Binding Title}"/>
2021-06-15 02:35:37 -07:00
2021-04-29 05:05:55 -07:00
<controls:IconButton
Click="CloseTab"
x:Name="closer"
2021-04-29 05:05:55 -07:00
Width="16" Height="16"
Margin="0,1,8,0" Padding="4"
ToolTip="{DynamicResource Text.Close}"
2021-04-29 05:05:55 -07:00
Icon="{StaticResource Icon.Close}"
2022-10-25 06:50:58 -07:00
HoverBackground="{DynamicResource Brush.TabButtonHover}"
Visibility="Hidden"
HorizontalAlignment="Right"/>
<Rectangle
x:Name="seperator"
2022-10-19 00:28:01 -07:00
Margin="4,0,0,0"
Width="1"
Fill="Transparent"
HorizontalAlignment="Right"/>
</Grid>
2021-04-29 05:05:55 -07:00
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Brush.Border0}"/>
<Setter TargetName="Border" Property="Background" Value="{DynamicResource Brush.Window}"/>
2021-04-29 05:05:55 -07:00
<Setter TargetName="Contents" Property="Opacity" Value="1"/>
<Setter TargetName="closer" Property="Visibility" Value="Visible"/>
2021-04-29 05:05:55 -07:00
</Trigger>
<DataTrigger Binding="{Binding IsSeperatorVisible}" Value="True">
<Setter TargetName="seperator" Property="Fill" Value="{DynamicResource Brush.FG2}"/>
</DataTrigger>
2021-04-29 05:05:55 -07:00
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter TargetName="Contents" Property="Opacity" Value=".85"/>
<Setter TargetName="closer" Property="Visibility" Value="Visible"/>
2021-04-29 05:05:55 -07:00
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<Button
Width="16" Height="16" Margin="8,0,0,0"
Background="Transparent"
BorderThickness="0"
ToolTip="{DynamicResource Text.PageTabBar.New}"
2021-04-29 05:05:55 -07:00
Click="NewTab"
WindowChrome.IsHitTestVisibleInChrome="True">
<Path Width="12" Data="{StaticResource Icon.NewTab}" Fill="{DynamicResource Brush.FG1}"/>
</Button>
2021-04-29 05:05:55 -07:00
</StackPanel>
</ScrollViewer>
<!-- Right Scroller -->
<controls:IconButton
Grid.Column="3"
2021-04-29 05:05:55 -07:00
x:Name="rightScroller"
Click="ScrollRight"
Width="18" Padding="6"
2022-10-25 06:50:58 -07:00
HoverBackground="{DynamicResource Brush.TabButtonHover}"
BorderThickness="0"
2021-04-29 05:05:55 -07:00
Icon="{StaticResource Icon.ScrollRight}"
WindowChrome.IsHitTestVisibleInChrome="True"
Visibility="Collapsed"/>
</Grid>
</UserControl>