mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
Change the way to show only space or no changes in DiffViewer
This commit is contained in:
parent
e08b7024fc
commit
087b147dd9
4 changed files with 34 additions and 24 deletions
|
@ -223,15 +223,7 @@ namespace SourceGit.Git {
|
|||
rs.Add(current);
|
||||
rs.Fit();
|
||||
|
||||
if (rs.IsBinary) {
|
||||
rs.Blocks.Clear();
|
||||
} else if (rs.Blocks.Count == 0) {
|
||||
var b = new Block();
|
||||
b.Mode = LineMode.Indicator;
|
||||
b.Append("NO CHANGES OR ONLY WHITESPACE CHANGES!!!");
|
||||
rs.Blocks.Add(b);
|
||||
}
|
||||
|
||||
if (rs.IsBinary) rs.Blocks.Clear();
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<!-- Enable WindowChrome Feature -->
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome UseAeroCaptionButtons="False" CornerRadius="0" CaptionHeight="32" GlassFrameThickness="0 0 0 1" ResizeBorderThickness="8" NonClientFrameEdges="None" />
|
||||
<WindowChrome UseAeroCaptionButtons="False" CornerRadius="0" CaptionHeight="32"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<!-- Window Layout -->
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<Border BorderThickness="1" BorderBrush="{StaticResource Brush.Border2}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="26"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
@ -24,7 +24,9 @@
|
|||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1" ClipToBounds="True">
|
||||
<Path x:Name="loading" Grid.Row="0" HorizontalAlignment="Left" Width="10" Height="10" Margin="8,0" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Loading}" Visibility="Collapsed"/>
|
||||
|
||||
<Grid x:Name="textChange" Grid.Row="1" ClipToBounds="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="100"/>
|
||||
<ColumnDefinition Width="2"/>
|
||||
|
@ -128,7 +130,7 @@
|
|||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Border x:Name="sizer" Grid.Row="1" ClipToBounds="True" Background="{StaticResource Brush.BG3}" Visibility="Collapsed">
|
||||
<Border x:Name="sizeChange" Grid.Row="1" ClipToBounds="True" Background="{StaticResource Brush.BG3}" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
|
||||
<Label Content="BINARY DIFF" Margin="0,0,0,32" FontSize="18" FontWeight="UltraBold" Foreground="{StaticResource Brush.FG2}" HorizontalAlignment="Center"/>
|
||||
<Path Width="64" Height="64" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Binary}" Fill="{StaticResource Brush.FG2}"/>
|
||||
|
@ -151,16 +153,19 @@
|
|||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="noChange" Grid.Row="1" Background="{StaticResource Brush.BG3}" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center" Opacity=".2">
|
||||
<Path Width="64" Height="64" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Check}"/>
|
||||
<Label Margin="0,8,0,0" Content="SAME OR ONLY EOL CHANGES" FontSize="18" FontWeight="UltraBold" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="mask" Grid.RowSpan="2" Background="{StaticResource Brush.BG3}" Visibility="Collapsed">
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center" Opacity=".2">
|
||||
<Path Width="64" Height="64" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Diff}"/>
|
||||
<Label Margin="0,8,0,0" Content="SELECT FILE TO VIEW CHANGES" FontSize="18" FontWeight="UltraBold" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border x:Name="loading" Grid.RowSpan="2" Background="{StaticResource Brush.BG3}" Visibility="Collapsed">
|
||||
<Label Content="LOADING ..." FontSize="18" FontWeight="UltraBold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{StaticResource Brush.FG2}"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
|
|
@ -38,7 +38,6 @@ namespace SourceGit.UI {
|
|||
/// </summary>
|
||||
public void Reset() {
|
||||
mask.Visibility = Visibility.Visible;
|
||||
sizer.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -50,7 +49,10 @@ namespace SourceGit.UI {
|
|||
SetTitle(opts.Path, opts.OrgPath);
|
||||
|
||||
loading.Visibility = Visibility.Visible;
|
||||
sizer.Visibility = Visibility.Collapsed;
|
||||
mask.Visibility = Visibility.Collapsed;
|
||||
textChange.Visibility = Visibility.Collapsed;
|
||||
sizeChange.Visibility = Visibility.Collapsed;
|
||||
noChange.Visibility = Visibility.Collapsed;
|
||||
|
||||
Task.Run(() => {
|
||||
var args = $"{opts.ExtraArgs} ";
|
||||
|
@ -62,9 +64,11 @@ namespace SourceGit.UI {
|
|||
var rs = Git.Diff.Run(repo, args);
|
||||
if (rs.IsBinary) {
|
||||
SetSizeChangeData(Git.Diff.GetSizeChange(repo, opts.RevisionRange, opts.Path, opts.OrgPath));
|
||||
} else {
|
||||
} else if (rs.Blocks.Count > 0) {
|
||||
SetData(rs);
|
||||
}
|
||||
} else {
|
||||
SetSame();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -91,13 +95,22 @@ namespace SourceGit.UI {
|
|||
private void SetSizeChangeData(Git.Diff.BinaryChange bc) {
|
||||
Dispatcher.Invoke(() => {
|
||||
loading.Visibility = Visibility.Collapsed;
|
||||
mask.Visibility = Visibility.Collapsed;
|
||||
sizer.Visibility = Visibility.Visible;
|
||||
sizeChange.Visibility = Visibility.Visible;
|
||||
txtNewSize.Content = $"{bc.Size} Bytes";
|
||||
txtOldSize.Content = $"{bc.PreSize} Bytes";
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show no changes or only eol changes.
|
||||
/// </summary>
|
||||
private void SetSame() {
|
||||
Dispatcher.Invoke(() => {
|
||||
loading.Visibility = Visibility.Collapsed;
|
||||
noChange.Visibility = Visibility.Visible;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show diff content.
|
||||
/// </summary>
|
||||
|
@ -105,7 +118,7 @@ namespace SourceGit.UI {
|
|||
private void SetData(Git.Diff.Result rs) {
|
||||
Dispatcher.Invoke(() => {
|
||||
loading.Visibility = Visibility.Collapsed;
|
||||
mask.Visibility = Visibility.Collapsed;
|
||||
textChange.Visibility = Visibility.Visible;
|
||||
|
||||
minWidth = Math.Max(leftText.ActualWidth, rightText.ActualWidth) - 16;
|
||||
|
||||
|
|
Loading…
Reference in a new issue