style<*>: small changes for borders and row heights

This commit is contained in:
leo 2021-04-06 14:57:47 +08:00
parent 41f538afce
commit 28bbb80364
4 changed files with 193 additions and 176 deletions

View file

@ -11,170 +11,173 @@
xmlns:converters="clr-namespace:SourceGit.Converters"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid x:Name="layout">
<Grid x:Name="layout" Background="{StaticResource Brush.CommitViewer}">
<!-- List Panel (SearchBar + DataGrid) -->
<Grid x:Name="commitListPanel" Background="{StaticResource Brush.Contents}" ClipToBounds="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Loading Tip -->
<Path x:Name="loading" Grid.RowSpan="2" Data="{StaticResource Icon.Loading}" RenderTransformOrigin=".5,.5">
<Path.RenderTransform>
<RotateTransform Angle="0"/>
</Path.RenderTransform>
<Border x:Name="commitListPanel" Background="{StaticResource Brush.CommitViewer}" BorderBrush="{StaticResource Brush.Border0}" SnapsToDevicePixels="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Path.Style>
<Style BasedOn="{StaticResource Style.Icon}" TargetType="{x:Type Path}">
<Setter Property="Width" Value="48"/>
<Setter Property="Height" Value="48"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Fill" Value="{StaticResource Brush.FG2}"/>
</Style>
</Path.Style>
</Path>
<!-- Loading Tip -->
<Path x:Name="loading" Grid.RowSpan="2" Data="{StaticResource Icon.Loading}" RenderTransformOrigin=".5,.5">
<Path.RenderTransform>
<RotateTransform Angle="0"/>
</Path.RenderTransform>
<!-- SearchBar -->
<Grid x:Name="searchBar" Margin="0,-32,0,0" Grid.Row="0">
<TextBox x:Name="txtSearch" Margin="4" Height="24" Padding="0,0,22,0" helpers:TextBoxHelper.Placeholder="{StaticResource Text.Histories.Search}" PreviewKeyDown="PreviewSearchKeyDown"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="8,0">
<Button ToolTip="{StaticResource Text.Histories.SearchClear}" Click="ClearSearch">
<Path Width="12" Height="12" Fill="{StaticResource Brush.FG2}" Data="{StaticResource Icon.Clear}"/>
</Button>
<Button Margin="8,0,0,0" ToolTip="{StaticResource Text.Close}" Click="HideSearchBarByButton">
<Path Width="12" Height="12" Fill="{StaticResource Brush.FG2}" Data="{StaticResource Icon.Up}"/>
</Button>
</StackPanel>
<Path.Style>
<Style BasedOn="{StaticResource Style.Icon}" TargetType="{x:Type Path}">
<Setter Property="Width" Value="48"/>
<Setter Property="Height" Value="48"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Fill" Value="{StaticResource Brush.FG2}"/>
</Style>
</Path.Style>
</Path>
<!-- SearchBar -->
<Grid x:Name="searchBar" Margin="0,-32,0,0" Grid.Row="0">
<TextBox x:Name="txtSearch" Margin="4" Height="24" Padding="0,0,22,0" helpers:TextBoxHelper.Placeholder="{StaticResource Text.Histories.Search}" PreviewKeyDown="PreviewSearchKeyDown"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="8,0">
<Button ToolTip="{StaticResource Text.Histories.SearchClear}" Click="ClearSearch">
<Path Width="12" Height="12" Fill="{StaticResource Brush.FG2}" Data="{StaticResource Icon.Clear}"/>
</Button>
<Button Margin="8,0,0,0" ToolTip="{StaticResource Text.Close}" Click="HideSearchBarByButton">
<Path Width="12" Height="12" Fill="{StaticResource Brush.FG2}" Data="{StaticResource Icon.Up}"/>
</Button>
</StackPanel>
</Grid>
<!-- Commit DataGrid -->
<DataGrid
Grid.Row="1"
x:Name="commitList"
RowHeight="{x:Static helpers:CommitGraphData.UNIT_HEIGHT}"
ScrollViewer.ScrollChanged="CommitListScrolled"
SelectionChanged="CommitSelectChanged"
SelectionUnit="FullRow">
<DataGrid.Resources>
<converters:IndentToMargin x:Key="CommitTitleMargin"/>
<Style x:Key="Style.DataGridText" TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="Consolas"/>
<Setter Property="Foreground" Value="{StaticResource Brush.FG1}"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Padding" Value="16,0"/>
</Style>
<Style x:Key="Style.DataGridText.NoPadding" TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="Consolas"/>
<Setter Property="Foreground" Value="{StaticResource Brush.FG1}"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTemplateColumn x:Name="commitGraphColumn" Width="*" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="{Binding GraphOffset, Converter={StaticResource CommitTitleMargin}}">
<ItemsControl x:Name="Decorator" ItemsSource="{Binding Decorators}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type git:Decorator}">
<Border x:Name="BG" Height="16" Margin="2,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="18"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="{StaticResource Brush.Decorator}">
<Path x:Name="Icon" Width="8" Data="{StaticResource Icon.Branch}"/>
</Border>
<TextBlock x:Name="Name" Grid.Column="1" Text="{Binding Name}" FontSize="11" Padding="4,0" Foreground="Black" VerticalAlignment="Center" TextWrapping="NoWrap"/>
</Grid>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Type}" Value="{x:Static git:DecoratorType.Tag}">
<Setter TargetName="BG" Property="Background" Value="#FF02C302"/>
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Tag}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="{x:Static git:DecoratorType.LocalBranchHead}">
<Setter TargetName="BG" Property="Background" Value="#FFFFB835"/>
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Branch}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="{x:Static git:DecoratorType.RemoteBranchHead}">
<Setter TargetName="BG" Property="Background" Value="#FFFFB835"/>
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Remote}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="{x:Static git:DecoratorType.CurrentBranchHead}">
<Setter TargetName="BG" Property="Background" Value="#FFFFB835"/>
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Check}"/>
<Setter TargetName="Icon" Property="Fill" Value="Orange"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Text="{Binding Subject}" VerticalAlignment="Center" Margin="2,0,0,0"/>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding HasDecorators}" Value="False">
<Setter TargetName="Decorator" Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="32" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<helpers:Avatar Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center" User="{Binding Committer}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Width="Auto" IsReadOnly="True" Binding="{Binding Committer.Name}" ElementStyle="{StaticResource Style.DataGridText.NoPadding}"/>
<DataGridTextColumn Width="84" IsReadOnly="True" Binding="{Binding ShortSHA}" ElementStyle="{StaticResource Style.DataGridText}"/>
<DataGridTextColumn Width="128" IsReadOnly="True" Binding="{Binding Committer.Time}" ElementStyle="{StaticResource Style.DataGridText.NoPadding}"/>
</DataGrid.Columns>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
<EventSetter Event="ContextMenuOpening" Handler="CommitContextMenuOpening"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsMerged}" Value="False">
<Setter Property="Opacity" Value=".4"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
</DataGrid>
<!-- Commit Graph -->
<Border x:Name="commitGraphContainer" Grid.Row="1" Width="{Binding ElementName=commitGraphColumn, Path=ActualWidth}" IsHitTestVisible="False" HorizontalAlignment="Left">
<helpers:CommitGraph
x:Name="commitGraph"
ClipToBounds="True"
Width="{Binding ElementName=commitGraphContainer, Path=ActualWidth}"
Height="{Binding ElementName=commitGraphContainer, Path=ActualHeight}"/>
</Border>
</Grid>
<!-- Commit DataGrid -->
<DataGrid
Grid.Row="1"
x:Name="commitList"
RowHeight="{x:Static helpers:CommitGraphData.UNIT_HEIGHT}"
ScrollViewer.ScrollChanged="CommitListScrolled"
SelectionChanged="CommitSelectChanged"
SelectionUnit="FullRow">
<DataGrid.Resources>
<converters:IndentToMargin x:Key="CommitTitleMargin"/>
<Style x:Key="Style.DataGridText" TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="Consolas"/>
<Setter Property="Foreground" Value="{StaticResource Brush.FG1}"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Padding" Value="16,0"/>
</Style>
<Style x:Key="Style.DataGridText.NoPadding" TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="Consolas"/>
<Setter Property="Foreground" Value="{StaticResource Brush.FG1}"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTemplateColumn x:Name="commitGraphColumn" Width="*" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="{Binding GraphOffset, Converter={StaticResource CommitTitleMargin}}">
<ItemsControl x:Name="Decorator" ItemsSource="{Binding Decorators}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type git:Decorator}">
<Border x:Name="BG" Height="16" Margin="2,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="18"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="{StaticResource Brush.Decorator}">
<Path x:Name="Icon" Width="8" Data="{StaticResource Icon.Branch}"/>
</Border>
<TextBlock x:Name="Name" Grid.Column="1" Text="{Binding Name}" FontSize="11" Padding="4,0" Foreground="Black" VerticalAlignment="Center" TextWrapping="NoWrap"/>
</Grid>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Type}" Value="{x:Static git:DecoratorType.Tag}">
<Setter TargetName="BG" Property="Background" Value="#FF02C302"/>
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Tag}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="{x:Static git:DecoratorType.LocalBranchHead}">
<Setter TargetName="BG" Property="Background" Value="#FFFFB835"/>
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Branch}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="{x:Static git:DecoratorType.RemoteBranchHead}">
<Setter TargetName="BG" Property="Background" Value="#FFFFB835"/>
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Remote}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="{x:Static git:DecoratorType.CurrentBranchHead}">
<Setter TargetName="BG" Property="Background" Value="#FFFFB835"/>
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Check}"/>
<Setter TargetName="Icon" Property="Fill" Value="Orange"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Text="{Binding Subject}" VerticalAlignment="Center" Margin="2,0,0,0"/>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding HasDecorators}" Value="False">
<Setter TargetName="Decorator" Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="32" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<helpers:Avatar Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center" User="{Binding Committer}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Width="Auto" IsReadOnly="True" Binding="{Binding Committer.Name}" ElementStyle="{StaticResource Style.DataGridText.NoPadding}"/>
<DataGridTextColumn Width="84" IsReadOnly="True" Binding="{Binding ShortSHA}" ElementStyle="{StaticResource Style.DataGridText}"/>
<DataGridTextColumn Width="128" IsReadOnly="True" Binding="{Binding Committer.Time}" ElementStyle="{StaticResource Style.DataGridText.NoPadding}"/>
</DataGrid.Columns>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
<EventSetter Event="ContextMenuOpening" Handler="CommitContextMenuOpening"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsMerged}" Value="False">
<Setter Property="Opacity" Value=".4"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
</DataGrid>
<!-- Commit Graph -->
<Border x:Name="commitGraphContainer" Grid.Row="1" Width="{Binding ElementName=commitGraphColumn, Path=ActualWidth}" ClipToBounds="True" IsHitTestVisible="False" HorizontalAlignment="Left">
<helpers:CommitGraph
x:Name="commitGraph"
Width="{Binding ElementName=commitGraphContainer, Path=ActualWidth}"
Height="{Binding ElementName=commitGraphContainer, Path=ActualHeight}"/>
</Border>
</Grid>
</Border>
<!-- Split -->
<GridSplitter x:Name="splitter" Background="{StaticResource Brush.CommitViewer}"/>
<GridSplitter x:Name="splitter" Background="Transparent"/>
<!-- Detail for selected commit -->
<Grid x:Name="commitDetailPanel" Background="{StaticResource Brush.CommitViewer}">
<Grid x:Name="commitDetailPanel">
<!-- Selected commit detail -->
<local:CommitViewer x:Name="commitViewer" Visibility="Collapsed"/>
@ -188,21 +191,21 @@
<Label x:Name="txtCounter" Visibility="Hidden" FontFamily="Consolas" Margin="0,16,0,0" FontSize="24" FontWeight="UltraBold" HorizontalAlignment="Center"/>
</StackPanel>
</Border>
<!-- Right-Top Buttons -->
<StackPanel
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,4,0,0"
Orientation="Horizontal">
<!-- Layout Switch -->
<ToggleButton
Style="{StaticResource Style.ToggleButton.Orientation}"
ToolTip="{StaticResource Text.Histories.DisplayMode}"
IsChecked="{Binding Source={x:Static sourcegit:App.Setting}, Path=UI.MoveCommitViewerRight, Mode=TwoWay}"
Checked="ChangeOrientation" Unchecked="ChangeOrientation"/>
<!-- Tips to Histories Panel -->
<Button Margin="4,0" ToolTip="{StaticResource Text.Histories.Guide}" Background="Transparent" Click="OpenGuide">
<Path Data="{StaticResource Icon.Info}" Fill="{StaticResource Brush.FG2}"/>

View file

@ -552,33 +552,37 @@ namespace SourceGit.UI {
layout.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1) });
layout.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star), MinWidth = 200 });
splitter.HorizontalAlignment = HorizontalAlignment.Center;
splitter.VerticalAlignment = VerticalAlignment.Stretch;
splitter.Width = 1;
splitter.Height = double.NaN;
commitListPanel.BorderThickness = new Thickness(0, 0, 1, 0);
Grid.SetRow(commitListPanel, 0);
Grid.SetRow(splitter, 0);
Grid.SetRow(commitDetailPanel, 0);
Grid.SetColumn(commitListPanel, 0);
Grid.SetColumn(splitter, 1);
Grid.SetColumn(commitDetailPanel, 2);
splitter.HorizontalAlignment = HorizontalAlignment.Center;
splitter.VerticalAlignment = VerticalAlignment.Stretch;
splitter.Width = 1;
splitter.Height = double.NaN;
} else {
layout.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star), MinHeight = 100 });
layout.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1) });
layout.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star), MinHeight = 100 });
splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
splitter.VerticalAlignment = VerticalAlignment.Center;
splitter.Width = double.NaN;
splitter.Height = 1;
commitListPanel.BorderThickness = new Thickness(0, 0, 0, 1);
Grid.SetRow(commitListPanel, 0);
Grid.SetRow(splitter, 1);
Grid.SetRow(commitDetailPanel, 2);
Grid.SetColumn(commitListPanel, 0);
Grid.SetColumn(splitter, 0);
Grid.SetColumn(commitDetailPanel, 0);
splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
splitter.VerticalAlignment = VerticalAlignment.Center;
splitter.Width = double.NaN;
splitter.Height = 1;
}
layout.InvalidateVisual();

View file

@ -18,15 +18,23 @@
<!-- Left panel -->
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="26"/>
<RowDefinition Height="*"/>
<RowDefinition Height="24"/>
<RowDefinition Height="26"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Stashes list toolbar -->
<Border Grid.Row="0" BorderBrush="{StaticResource Brush.Border0}" BorderThickness="0,0,0,1" SnapsToDevicePixels="True">
<Label Content="{StaticResource Text.Stashes.Stashes}" Foreground="{StaticResource Brush.FG2}" Margin="4,0,0,0" FontWeight="Bold"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Path Grid.Column="0" Width="12" Height="12" Margin="4,0" Stroke="{StaticResource Brush.FG2}" StrokeThickness="1" Data="{StaticResource Icon.List}" Fill="{StaticResource Brush.FG2}"/>
<Label Grid.Column="1" Content="{StaticResource Text.Stashes.Stashes}" Foreground="{StaticResource Brush.FG2}" Margin="0" FontWeight="Bold"/>
</Grid>
</Border>
<!-- Stashes list -->
@ -70,12 +78,14 @@
<Border Grid.Row="2" BorderBrush="{StaticResource Brush.Border0}" BorderThickness="0,1,0,1" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="{StaticResource Text.Stashes.Changes}" Foreground="{StaticResource Brush.FG2}" Margin="4,0,0,0" FontWeight="Bold"/>
<Label Grid.Column="1" Content="{StaticResource Text.Stashes.Changes.Tip}" Foreground="{StaticResource Brush.FG2}" FontSize="10"/>
<Path Grid.Column="0" Width="12" Height="12" Margin="4,0" Stroke="{StaticResource Brush.FG2}" StrokeThickness="1" Data="{StaticResource Icon.List}" Fill="{StaticResource Brush.FG2}"/>
<Label Grid.Column="1" Content="{StaticResource Text.Stashes.Changes}" Foreground="{StaticResource Brush.FG2}" Margin="0" FontWeight="Bold"/>
<Label Grid.Column="2" Content="{StaticResource Text.Stashes.Changes.Tip}" Foreground="{StaticResource Brush.FG2}" FontSize="10"/>
</Grid>
</Border>

View file

@ -36,9 +36,9 @@
<!-- Left -->
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="26"/>
<RowDefinition Height="*"/>
<RowDefinition Height="24"/>
<RowDefinition Height="26"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>