style<Dashboard>: move histories layout direction button to dashboard toolbar

This commit is contained in:
leo 2021-10-08 17:06:04 +08:00
parent 7c44c0a840
commit 902e28c41c
5 changed files with 27 additions and 47 deletions

View file

@ -82,17 +82,18 @@
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Opacity" Value=".8"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid Background="Transparent">
<Path
x:Name="Icon"
x:Name="Icon"
Style="{DynamicResource Style.Icon}"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Fill="{TemplateBinding Foreground}"
Fill="{DynamicResource Brush.FG1}"
Data="{DynamicResource Icon.Orientation}"
RenderTransformOrigin=".5,.5">
<Path.RenderTransform>
@ -109,33 +110,8 @@
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Style.ToggleButton.CommitGraphMode" TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid Background="Transparent">
<Path
x:Name="Icon"
Style="{DynamicResource Style.Icon}"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Fill="{TemplateBinding Foreground}"
Data="{DynamicResource Icon.Curve}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Icon" Property="Data" Value="{DynamicResource Icon.Polyline}"/>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

View file

@ -4,6 +4,7 @@
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:models="clr-namespace:SourceGit.Models"
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
xmlns:converters="clr-namespace:SourceGit.Views.Converters"
mc:Ignorable="d"
@ -13,7 +14,11 @@
<RowDefinition Height="32"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.Resources>
<converters:InverseBool x:Key="InverseBool"/>
</Grid.Resources>
<!-- Toolbar -->
<Border Grid.Row="0" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1">
<Grid>
@ -93,8 +98,15 @@
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
<ToggleButton
Width="16" Height="16"
Style="{StaticResource Style.ToggleButton.SplitDirection}"
ToolTip="{DynamicResource Text.Histories.DisplayMode}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Window.MoveCommitInfoRight, Mode=TwoWay, Converter={StaticResource InverseBool}}"
Checked="ChangeOrientation" Unchecked="ChangeOrientation"/>
<controls:IconButton
Margin="8,0"
Margin="12,0,8,0"
Padding="0,8"
Icon="{DynamicResource Icon.Setting}"
ToolTip="{DynamicResource Text.Dashboard.Configure}"

View file

@ -400,6 +400,12 @@ namespace SourceGit.Views.Widgets {
(pages.Get("histories") as Histories).ToggleSearch();
}
private void ChangeOrientation(object sender, RoutedEventArgs e) {
if (!IsLoaded) return;
(pages.Get("histories") as Histories)?.ChangeOrientation();
}
private void OpenConfigure(object sender, RoutedEventArgs e) {
new Popups.Configure(repo.Path).Show();
e.Handled = true;

View file

@ -12,7 +12,6 @@
<Grid x:Name="layout">
<Grid.Resources>
<converters:BoolToCollapsed x:Key="BoolToCollapsed"/>
<converters:InverseBool x:Key="InverseBool"/>
</Grid.Resources>
<Border x:Name="commitListPanel" Background="{DynamicResource Brush.Contents}">
@ -163,7 +162,6 @@
<GridSplitter x:Name="splitter" Background="{DynamicResource Brush.Border0}"/>
<Grid x:Name="inspector">
<!-- Commit Detail -->
<widgets:CommitDetail x:Name="commitDetail"/>
@ -190,18 +188,6 @@
</StackPanel>
</StackPanel>
</Border>
<!-- Right Top Button -->
<ToggleButton
HorizontalAlignment="Right"
VerticalAlignment="Top"
Style="{StaticResource Style.ToggleButton.SplitDirection}"
Foreground="{DynamicResource Brush.FG2}"
Width="16" Height="16"
Margin="0,6,8,0"
ToolTip="{DynamicResource Text.Histories.DisplayMode}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Window.MoveCommitInfoRight, Mode=TwoWay, Converter={StaticResource InverseBool}}"
Checked="ChangeOrientation" Unchecked="ChangeOrientation"/>
</Grid>
</Grid>
</UserControl>

View file

@ -21,7 +21,7 @@ namespace SourceGit.Views.Widgets {
this.repo = repo;
InitializeComponent();
ChangeOrientation(null, null);
ChangeOrientation();
Unloaded += (o, e) => {
cachedCommits.Clear();
@ -103,7 +103,7 @@ namespace SourceGit.Views.Widgets {
#endregion
#region LAYOUT
private void ChangeOrientation(object sender, RoutedEventArgs e) {
public void ChangeOrientation() {
if (layout == null || commitListPanel == null || inspector == null || splitter == null) return;
layout.RowDefinitions.Clear();