mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-28 23:54:59 +00:00
style<PageTabBar>: new style for page tab bar
This commit is contained in:
parent
80acfb6b1f
commit
c2517701cc
6 changed files with 105 additions and 37 deletions
|
@ -7,16 +7,25 @@
|
|||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="28" d:DesignWidth="800">
|
||||
<Grid Margin="6,4,0,0">
|
||||
<Grid Margin="0,4,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Seperator -->
|
||||
<Rectangle
|
||||
Grid.Column="0"
|
||||
x:Name="startSeperator"
|
||||
Width="1" Height="16" Margin="0,2,0,0"
|
||||
Fill="{DynamicResource Brush.FG2}"
|
||||
Opacity=".5"/>
|
||||
|
||||
<!-- Left Scroller -->
|
||||
<controls:IconButton
|
||||
Grid.Column="0"
|
||||
Grid.Column="1"
|
||||
x:Name="leftScroller"
|
||||
Click="ScrollLeft"
|
||||
Width="18" Padding="6"
|
||||
|
@ -25,10 +34,10 @@
|
|||
Icon="{StaticResource Icon.ScrollLeft}"
|
||||
WindowChrome.IsHitTestVisibleInChrome="True"
|
||||
Visibility="Collapsed"/>
|
||||
|
||||
|
||||
<!-- Tabs -->
|
||||
<ScrollViewer
|
||||
Grid.Column="1"
|
||||
Grid.Column="2"
|
||||
x:Name="scroller"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Disabled">
|
||||
|
@ -64,12 +73,13 @@
|
|||
|
||||
<TextBlock
|
||||
Margin="4,0"
|
||||
Width="80" MaxWidth="80" TextAlignment="Center"
|
||||
Text="{Binding Title}"/>
|
||||
|
||||
<controls:IconButton
|
||||
Click="CloseTab"
|
||||
Width="16" Height="16"
|
||||
Margin="4,0,0,0" Padding="4"
|
||||
Margin="0,0,0,0" Padding="4"
|
||||
ToolTip="{DynamicResource Text.Close}"
|
||||
Icon="{StaticResource Icon.Close}"
|
||||
HoverBackground="{DynamicResource Brush.NewPageHover}"/>
|
||||
|
@ -121,7 +131,7 @@
|
|||
|
||||
<!-- Right Scroller -->
|
||||
<controls:IconButton
|
||||
Grid.Column="2"
|
||||
Grid.Column="3"
|
||||
x:Name="rightScroller"
|
||||
Click="ScrollRight"
|
||||
Width="18" Padding="6"
|
||||
|
|
|
@ -189,11 +189,17 @@ namespace SourceGit.Views.Widgets {
|
|||
|
||||
private void CalcScrollerVisibilty(object sender, SizeChangedEventArgs e) {
|
||||
if ((sender as StackPanel).ActualWidth > scroller.ActualWidth) {
|
||||
startSeperator.Visibility = Visibility.Hidden;
|
||||
leftScroller.Visibility = Visibility.Visible;
|
||||
rightScroller.Visibility = Visibility.Visible;
|
||||
} else {
|
||||
leftScroller.Visibility = Visibility.Collapsed;
|
||||
rightScroller.Visibility = Visibility.Collapsed;
|
||||
if (container.SelectedIndex == 0) {
|
||||
startSeperator.Visibility = Visibility.Hidden;
|
||||
} else {
|
||||
startSeperator.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,17 +229,7 @@ namespace SourceGit.Views.Widgets {
|
|||
private void SelectionChanged(object sender, SelectionChangedEventArgs e) {
|
||||
var tab = container.SelectedItem as Tab;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UpdateSeperators(tab);
|
||||
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, tab.Id));
|
||||
}
|
||||
|
||||
|
@ -260,6 +256,7 @@ namespace SourceGit.Views.Widgets {
|
|||
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
|
||||
} else {
|
||||
Tabs.Remove(tab);
|
||||
UpdateSeperators(curTab);
|
||||
}
|
||||
RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id));
|
||||
}
|
||||
|
@ -366,5 +363,24 @@ namespace SourceGit.Views.Widgets {
|
|||
menu.IsOpen = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void UpdateSeperators(Tab actived) {
|
||||
int curIdx = 0;
|
||||
for (int i = 0; i < Tabs.Count; i++) {
|
||||
if (Tabs[i] == actived) {
|
||||
curIdx = i;
|
||||
actived.IsSeperatorVisible = false;
|
||||
if (i > 0) Tabs[i - 1].IsSeperatorVisible = false;
|
||||
} else {
|
||||
Tabs[i].IsSeperatorVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (leftScroller.Visibility == Visibility.Visible || curIdx == 0) {
|
||||
startSeperator.Visibility = Visibility.Hidden;
|
||||
} else {
|
||||
startSeperator.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue