feature: auto scrolling while seleting text in commit message (#394)

This commit is contained in:
leo 2024-08-27 14:47:20 +08:00
parent 551ea883ff
commit 959805d63c
No known key found for this signature in database
2 changed files with 23 additions and 5 deletions

View file

@ -114,7 +114,23 @@ namespace SourceGit.Views
{
base.OnPointerMoved(e);
if (e.Pointer.Captured == null && _matches != null)
if (e.Pointer.Captured == this)
{
var relativeSelfY = e.GetPosition(this).Y;
if (relativeSelfY <= 0 || relativeSelfY > Bounds.Height)
return;
var scrollViewer = this.FindAncestorOfType<ScrollViewer>();
if (scrollViewer != null)
{
var relativeY = e.GetPosition(scrollViewer).Y;
if (relativeY <= 8)
scrollViewer.LineUp();
else if (relativeY >= scrollViewer.Bounds.Height - 8)
scrollViewer.LineDown();
}
}
else if (_matches != null)
{
var point = e.GetPosition(this) - new Point(Padding.Left, Padding.Top);
var x = Math.Min(Math.Max(point.X, 0), Math.Max(TextLayout.WidthIncludingTrailingWhitespace, 0));

View file

@ -48,10 +48,12 @@
</DataTemplate>
<DataTemplate DataType="m:RevisionSubmodule">
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" Margin="8,8,8,0">
<TextBlock Text="{DynamicResource Text.CommitDetail.Files.Submodule}" FontSize="18" FontWeight="Bold" HorizontalAlignment="Center" Foreground="{DynamicResource Brush.FG2}"/>
<v:CommitBaseInfo Margin="0,16,0,0" Content="{Binding Commit}" Message="{Binding FullMessage}"/>
</StackPanel>
<Grid RowDefinitions="Auto,*" Margin="8,0">
<TextBlock Grid.Row="0" Margin="0,8,0,0" Text="{DynamicResource Text.CommitDetail.Files.Submodule}" FontSize="18" FontWeight="Bold" HorizontalAlignment="Center" Foreground="{DynamicResource Brush.FG2}"/>
<ScrollViewer Grid.Row="1" Margin="0,16,0,0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<v:CommitBaseInfo Content="{Binding Commit}" Message="{Binding FullMessage}"/>
</ScrollViewer>
</Grid>
</DataTemplate>
</UserControl.DataTemplates>
</UserControl>