mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08: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
|
@ -24,7 +24,7 @@
|
||||||
<sys:String x:Key="Text.SSHKey">SSH Private Key :</sys:String>
|
<sys:String x:Key="Text.SSHKey">SSH Private Key :</sys:String>
|
||||||
<sys:String x:Key="Text.SSHKey.Placeholder">Private SSH key store path</sys:String>
|
<sys:String x:Key="Text.SSHKey.Placeholder">Private SSH key store path</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.About">ABOUT</sys:String>
|
<sys:String x:Key="Text.About">About</sys:String>
|
||||||
<sys:String x:Key="Text.About.Title">SourceGit - OPEN SOURCE GIT CLIENT</sys:String>
|
<sys:String x:Key="Text.About.Title">SourceGit - OPEN SOURCE GIT CLIENT</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.Apply">Patch</sys:String>
|
<sys:String x:Key="Text.Apply">Patch</sys:String>
|
||||||
|
@ -280,8 +280,7 @@
|
||||||
<sys:String x:Key="Text.Init.Tip">Invalid repository detected. Run `git init` under this path?</sys:String>
|
<sys:String x:Key="Text.Init.Tip">Invalid repository detected. Run `git init` under this path?</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.Launcher">Source Git</sys:String>
|
<sys:String x:Key="Text.Launcher">Source Git</sys:String>
|
||||||
<sys:String x:Key="Text.Launcher.Preference">PREFERENCE</sys:String>
|
<sys:String x:Key="Text.Launcher.Menu">Open Main Menu</sys:String>
|
||||||
<sys:String x:Key="Text.Launcher.About">ABOUT</sys:String>
|
|
||||||
<sys:String x:Key="Text.Launcher.Error">ERROR</sys:String>
|
<sys:String x:Key="Text.Launcher.Error">ERROR</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.PageTabBar.New">NEW PAGE</sys:String>
|
<sys:String x:Key="Text.PageTabBar.New">NEW PAGE</sys:String>
|
||||||
|
|
|
@ -279,8 +279,7 @@
|
||||||
<sys:String x:Key="Text.Init.Tip">点击【确定】将在此目录执行`git init`操作</sys:String>
|
<sys:String x:Key="Text.Init.Tip">点击【确定】将在此目录执行`git init`操作</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.Launcher">Source Git</sys:String>
|
<sys:String x:Key="Text.Launcher">Source Git</sys:String>
|
||||||
<sys:String x:Key="Text.Launcher.Preference">偏好设置</sys:String>
|
<sys:String x:Key="Text.Launcher.Menu">主菜单</sys:String>
|
||||||
<sys:String x:Key="Text.Launcher.About">关于</sys:String>
|
|
||||||
<sys:String x:Key="Text.Launcher.Error">出错了</sys:String>
|
<sys:String x:Key="Text.Launcher.Error">出错了</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.PageTabBar.New">新建空白页</sys:String>
|
<sys:String x:Key="Text.PageTabBar.New">新建空白页</sys:String>
|
||||||
|
|
|
@ -25,28 +25,34 @@
|
||||||
<!-- Titlebar -->
|
<!-- Titlebar -->
|
||||||
<Grid Grid.Row="0" Background="{DynamicResource Brush.TitleBar}">
|
<Grid Grid.Row="0" Background="{DynamicResource Brush.TitleBar}">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="32"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="300"/>
|
<ColumnDefinition Width="300"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<!-- Bottom border -->
|
<!-- Bottom border -->
|
||||||
<Rectangle Grid.Column="0" Grid.ColumnSpan="2" Fill="{DynamicResource Brush.Border0}" Height="1" VerticalAlignment="Bottom"/>
|
<Rectangle Grid.Column="0" Grid.ColumnSpan="4" Fill="{DynamicResource Brush.Border0}" Height="1" VerticalAlignment="Bottom"/>
|
||||||
|
|
||||||
|
<!-- Main Menu -->
|
||||||
|
<controls:IconButton
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="4,4,4,0"
|
||||||
|
Width="14"
|
||||||
|
Icon="{StaticResource Icon.List}"
|
||||||
|
ToolTip="{DynamicResource Text.Launcher.Menu}"
|
||||||
|
WindowChrome.IsHitTestVisibleInChrome="True"
|
||||||
|
Click="ToggleMainMenu"/>
|
||||||
|
|
||||||
<!-- Tabs -->
|
<!-- Tabs -->
|
||||||
<widgets:PageTabBar
|
<widgets:PageTabBar
|
||||||
Grid.Column="0"
|
Grid.Column="1"
|
||||||
x:Name="tabs"
|
x:Name="tabs"
|
||||||
TabAdd="OnTabAdding"
|
TabAdd="OnTabAdding"
|
||||||
TabSelected="OnTabSelected"
|
TabSelected="OnTabSelected"
|
||||||
TabClosed="OnTabClosed"/>
|
TabClosed="OnTabClosed"/>
|
||||||
|
|
||||||
<!-- Right controls -->
|
<!-- Right controls -->
|
||||||
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Height="27" WindowChrome.IsHitTestVisibleInChrome="True">
|
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Height="27" WindowChrome.IsHitTestVisibleInChrome="True">
|
||||||
<controls:IconButton Click="OpenPreference" Width="28" Padding="6" Icon="{StaticResource Icon.Preference}" ToolTip="{DynamicResource Text.Launcher.Preference}"/>
|
|
||||||
<controls:IconButton Click="OpenAbout" Width="28" Padding="6" Icon="{StaticResource Icon.Help}" ToolTip="{DynamicResource Text.Launcher.About}"/>
|
|
||||||
|
|
||||||
<Rectangle Margin="4,0" Width="1" Height="16" VerticalAlignment="Center" Fill="{DynamicResource Brush.Border2}"/>
|
|
||||||
|
|
||||||
<controls:IconButton Click="Minimize" Width="28" Padding="9" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
|
<controls:IconButton Click="Minimize" Width="28" Padding="9" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
|
||||||
<ToggleButton Style="{StaticResource Style.ToggleButton.MaxOrRestore}" Width="28" IsChecked="{Binding ElementName=me, Path=IsMaximized}"/>
|
<ToggleButton Style="{StaticResource Style.ToggleButton.MaxOrRestore}" Width="28" IsChecked="{Binding ElementName=me, Path=IsMaximized}"/>
|
||||||
<controls:IconButton Click="Quit" Width="28" Padding="9" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
|
<controls:IconButton Click="Quit" Width="28" Padding="9" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
|
||||||
|
|
|
@ -2,7 +2,11 @@ using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Controls.Primitives;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
namespace SourceGit.Views {
|
namespace SourceGit.Views {
|
||||||
|
|
||||||
|
@ -77,15 +81,49 @@ namespace SourceGit.Views {
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region RIGHT_COMMANDS
|
#region OPERATIONS
|
||||||
private void OpenPreference(object sender, RoutedEventArgs e) {
|
private void FillMenu(ContextMenu menu, string icon, string header, RoutedEventHandler onClick) {
|
||||||
var dialog = new Preference() { Owner = this };
|
var iconMode = new Path();
|
||||||
dialog.ShowDialog();
|
iconMode.Width = 12;
|
||||||
|
iconMode.Height = 12;
|
||||||
|
iconMode.Data = FindResource(icon) as Geometry;
|
||||||
|
iconMode.SetResourceReference(Path.FillProperty, "Brush.FG2");
|
||||||
|
|
||||||
|
var item = new MenuItem();
|
||||||
|
item.Icon = iconMode;
|
||||||
|
item.Header = App.Text(header);
|
||||||
|
item.Click += onClick;
|
||||||
|
|
||||||
|
menu.Items.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenAbout(object sender, RoutedEventArgs e) {
|
private void ToggleMainMenu(object sender, RoutedEventArgs e) {
|
||||||
|
var btn = (sender as Button);
|
||||||
|
if (btn.ContextMenu != null) {
|
||||||
|
btn.ContextMenu.IsOpen = true;
|
||||||
|
e.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var menu = new ContextMenu();
|
||||||
|
menu.Placement = PlacementMode.Bottom;
|
||||||
|
menu.PlacementTarget = btn;
|
||||||
|
menu.StaysOpen = false;
|
||||||
|
menu.Focusable = true;
|
||||||
|
|
||||||
|
FillMenu(menu, "Icon.Preference", "Preference", (o, ev) => {
|
||||||
|
var dialog = new Preference() { Owner = this };
|
||||||
|
dialog.ShowDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
FillMenu(menu, "Icon.Help", "About", (o, ev) => {
|
||||||
var dialog = new About() { Owner = this };
|
var dialog = new About() { Owner = this };
|
||||||
dialog.ShowDialog();
|
dialog.ShowDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
btn.ContextMenu = menu;
|
||||||
|
btn.ContextMenu.IsOpen = true;
|
||||||
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Minimize(object sender, RoutedEventArgs e) {
|
private void Minimize(object sender, RoutedEventArgs e) {
|
||||||
|
|
|
@ -7,16 +7,25 @@
|
||||||
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 Margin="6,4,0,0">
|
<Grid Margin="0,4,0,0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="1"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
</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 -->
|
<!-- Left Scroller -->
|
||||||
<controls:IconButton
|
<controls:IconButton
|
||||||
Grid.Column="0"
|
Grid.Column="1"
|
||||||
x:Name="leftScroller"
|
x:Name="leftScroller"
|
||||||
Click="ScrollLeft"
|
Click="ScrollLeft"
|
||||||
Width="18" Padding="6"
|
Width="18" Padding="6"
|
||||||
|
@ -28,7 +37,7 @@
|
||||||
|
|
||||||
<!-- Tabs -->
|
<!-- Tabs -->
|
||||||
<ScrollViewer
|
<ScrollViewer
|
||||||
Grid.Column="1"
|
Grid.Column="2"
|
||||||
x:Name="scroller"
|
x:Name="scroller"
|
||||||
HorizontalScrollBarVisibility="Hidden"
|
HorizontalScrollBarVisibility="Hidden"
|
||||||
VerticalScrollBarVisibility="Disabled">
|
VerticalScrollBarVisibility="Disabled">
|
||||||
|
@ -64,12 +73,13 @@
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="4,0"
|
Margin="4,0"
|
||||||
|
Width="80" MaxWidth="80" TextAlignment="Center"
|
||||||
Text="{Binding Title}"/>
|
Text="{Binding Title}"/>
|
||||||
|
|
||||||
<controls:IconButton
|
<controls:IconButton
|
||||||
Click="CloseTab"
|
Click="CloseTab"
|
||||||
Width="16" Height="16"
|
Width="16" Height="16"
|
||||||
Margin="4,0,0,0" Padding="4"
|
Margin="0,0,0,0" Padding="4"
|
||||||
ToolTip="{DynamicResource Text.Close}"
|
ToolTip="{DynamicResource Text.Close}"
|
||||||
Icon="{StaticResource Icon.Close}"
|
Icon="{StaticResource Icon.Close}"
|
||||||
HoverBackground="{DynamicResource Brush.NewPageHover}"/>
|
HoverBackground="{DynamicResource Brush.NewPageHover}"/>
|
||||||
|
@ -121,7 +131,7 @@
|
||||||
|
|
||||||
<!-- Right Scroller -->
|
<!-- Right Scroller -->
|
||||||
<controls:IconButton
|
<controls:IconButton
|
||||||
Grid.Column="2"
|
Grid.Column="3"
|
||||||
x:Name="rightScroller"
|
x:Name="rightScroller"
|
||||||
Click="ScrollRight"
|
Click="ScrollRight"
|
||||||
Width="18" Padding="6"
|
Width="18" Padding="6"
|
||||||
|
|
|
@ -189,11 +189,17 @@ namespace SourceGit.Views.Widgets {
|
||||||
|
|
||||||
private void CalcScrollerVisibilty(object sender, SizeChangedEventArgs e) {
|
private void CalcScrollerVisibilty(object sender, SizeChangedEventArgs e) {
|
||||||
if ((sender as StackPanel).ActualWidth > scroller.ActualWidth) {
|
if ((sender as StackPanel).ActualWidth > scroller.ActualWidth) {
|
||||||
|
startSeperator.Visibility = Visibility.Hidden;
|
||||||
leftScroller.Visibility = Visibility.Visible;
|
leftScroller.Visibility = Visibility.Visible;
|
||||||
rightScroller.Visibility = Visibility.Visible;
|
rightScroller.Visibility = Visibility.Visible;
|
||||||
} else {
|
} else {
|
||||||
leftScroller.Visibility = Visibility.Collapsed;
|
leftScroller.Visibility = Visibility.Collapsed;
|
||||||
rightScroller.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) {
|
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;
|
||||||
|
UpdateSeperators(tab);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,6 +256,7 @@ namespace SourceGit.Views.Widgets {
|
||||||
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
|
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
|
||||||
} else {
|
} else {
|
||||||
Tabs.Remove(tab);
|
Tabs.Remove(tab);
|
||||||
|
UpdateSeperators(curTab);
|
||||||
}
|
}
|
||||||
RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id));
|
RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id));
|
||||||
}
|
}
|
||||||
|
@ -366,5 +363,24 @@ namespace SourceGit.Views.Widgets {
|
||||||
menu.IsOpen = true;
|
menu.IsOpen = true;
|
||||||
e.Handled = 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…
Reference in a new issue