feature: allow to resize the width of AUTHOR column in histories (#203)

This commit is contained in:
leo 2024-07-09 16:29:41 +08:00
parent 738189393e
commit 06ba2fd733
No known key found for this signature in database
3 changed files with 73 additions and 27 deletions

View file

@ -18,19 +18,53 @@
SelectionMode="Extended" SelectionMode="Extended"
SelectedItem="{Binding AutoSelectedCommit, Mode=OneWay}" SelectedItem="{Binding AutoSelectedCommit, Mode=OneWay}"
CanUserReorderColumns="False" CanUserReorderColumns="False"
CanUserResizeColumns="False" CanUserResizeColumns="True"
CanUserSortColumns="False" CanUserSortColumns="False"
IsReadOnly="True" IsReadOnly="True"
HeadersVisibility="None" HeadersVisibility="Column"
Focusable="False" Focusable="False"
RowHeight="28" RowHeight="28"
ColumnHeaderHeight="28"
HorizontalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
LayoutUpdated="OnCommitDataGridLayoutUpdated" LayoutUpdated="OnCommitDataGridLayoutUpdated"
SelectionChanged="OnCommitDataGridSelectionChanged" SelectionChanged="OnCommitDataGridSelectionChanged"
ContextRequested="OnCommitDataGridContextRequested"> ContextRequested="OnCommitDataGridContextRequested">
<DataGrid.Styles>
<Style Selector="DataGridColumnHeader">
<Setter Property="MinHeight" Value="28"/>
<Setter Property="Template">
<ControlTemplate>
<Border Background="{DynamicResource Brush.Window}"
BorderBrush="{DynamicResource Brush.Border0}"
BorderThickness="0,0,0,1">
<Grid ColumnDefinitions="*,1">
<ContentControl x:Name="PART_ContentPresenter"
Grid.Column="0"
Margin="4,0"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalContentAlignment="Center"/>
<Rectangle Name="VerticalSeparator"
Grid.Column="1"
Width="1"
VerticalAlignment="Stretch"
Fill="{DynamicResource Brush.Border0}"
IsVisible="{TemplateBinding AreSeparatorsVisible}" />
</Grid>
</Border>
</ControlTemplate>
</Setter>
</Style>
</DataGrid.Styles>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTemplateColumn Width="*" Header="GRAPH"> <DataGridTemplateColumn Width="*" CanUserResize="True">
<DataGridTemplateColumn.Header>
<TextBlock Classes="group_header_label" Margin="0" Text="GRAPH &amp; SUBJECT"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="{x:Type m:Commit}"> <DataTemplate x:DataType="{x:Type m:Commit}">
<Border Margin="{Binding Margin}"> <Border Margin="{Binding Margin}">
@ -77,44 +111,53 @@
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<DataGridTemplateColumn Header="AVATAR"> <DataGridTemplateColumn CanUserResize="True" Width="120">
<DataGridTemplateColumn.Header>
<TextBlock Classes="group_header_label" Margin="0" Text="AUTHOR"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="{x:Type m:Commit}"> <DataTemplate x:DataType="{x:Type m:Commit}">
<v:Avatar Width="16" Height="16" <Grid ColumnDefinitions="Auto,*" Margin="8,0">
Margin="16,0,8,0" <v:Avatar Grid.Column="0"
VerticalAlignment="Center" Width="16" Height="16"
IsHitTestVisible="False" VerticalAlignment="Center"
User="{Binding Author}" IsHitTestVisible="False"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"/> User="{Binding Author}"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"/>
<TextBlock Grid.Column="1"
Classes="monospace"
Text="{Binding Author.Name}"
Margin="8,0,0,0"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
</Grid>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<DataGridTemplateColumn Header="AUTHOR"> <DataGridTemplateColumn CanUserResize="False" MinWidth="96">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.Header>
<DataTemplate x:DataType="{x:Type m:Commit}"> <TextBlock Classes="group_header_label" Margin="0" Text="SHA"/>
<TextBlock Classes="monospace" </DataGridTemplateColumn.Header>
Text="{Binding Author.Name}"
Margin="0,0,8,0"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="SHA">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="{x:Type m:Commit}"> <DataTemplate x:DataType="{x:Type m:Commit}">
<TextBlock Classes="monospace" <TextBlock Classes="monospace"
Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
Margin="12,0" Margin="8,0"
HorizontalAlignment="Center"
Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}" Opacity="{Binding IsMerged, Converter={x:Static c:BoolConverters.HalfIfFalse}}"
FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/> FontWeight="{Binding IsCurrentHead, Converter={x:Static c:BoolConverters.BoldIfTrue}}"/>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<DataGridTemplateColumn Header="TIME"> <DataGridTemplateColumn CanUserResize="False" MinWidth="156">
<DataGridTemplateColumn.Header>
<TextBlock Classes="group_header_label" Margin="0" Text="TIME"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="{x:Type m:Commit}"> <DataTemplate x:DataType="{x:Type m:Commit}">
<TextBlock Classes="monospace" <TextBlock Classes="monospace"

View file

@ -120,8 +120,11 @@ namespace SourceGit.Views
} }
} }
var headerHeight = grid.ColumnHeaderHeight;
startY -= headerHeight;
// Apply scroll offset. // Apply scroll offset.
context.PushClip(new Rect(Bounds.Left, Bounds.Top, grid.Columns[0].ActualWidth, Bounds.Height)); context.PushClip(new Rect(Bounds.Left, Bounds.Top + headerHeight, grid.Columns[0].ActualWidth, Bounds.Height));
context.PushTransform(Matrix.CreateTranslation(0, -startY)); context.PushTransform(Matrix.CreateTranslation(0, -startY));
// Calculate bounds. // Calculate bounds.

View file

@ -708,7 +708,7 @@
Command="{Binding AbortMerge}"/> Command="{Binding AbortMerge}"/>
</Grid> </Grid>
<Border Grid.Row="1" Background="{DynamicResource Brush.Window}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"> <Border Grid.Row="1" Background="{DynamicResource Brush.ToolBar}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}">
<Border.IsVisible> <Border.IsVisible>
<MultiBinding Converter="{x:Static BoolConverters.And}"> <MultiBinding Converter="{x:Static BoolConverters.And}">
<Binding Path="SelectedViewIndex" Converter="{x:Static c:IntConverters.IsZero}"/> <Binding Path="SelectedViewIndex" Converter="{x:Static c:IntConverters.IsZero}"/>