mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
ux: change cursor to Hand
when hover a commit hash link (#522)
This commit is contained in:
parent
bb907deddb
commit
841a009a56
2 changed files with 44 additions and 2 deletions
|
@ -33,7 +33,7 @@ namespace SourceGit.Views
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var view = TextView;
|
var view = TextView;
|
||||||
if (view != null && view.VisualLinesValid)
|
if (view is { VisualLinesValid: true })
|
||||||
{
|
{
|
||||||
var typeface = view.CreateTypeface();
|
var typeface = view.CreateTypeface();
|
||||||
var underlinePen = new Pen(Brushes.DarkOrange);
|
var underlinePen = new Pen(Brushes.DarkOrange);
|
||||||
|
@ -142,12 +142,53 @@ namespace SourceGit.Views
|
||||||
return new Size(maxWidth, 0);
|
return new Size(maxWidth, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnPointerMoved(PointerEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnPointerMoved(e);
|
||||||
|
|
||||||
|
var view = TextView;
|
||||||
|
if (!e.Handled && view is { VisualLinesValid: true })
|
||||||
|
{
|
||||||
|
var pos = e.GetPosition(this);
|
||||||
|
var typeface = view.CreateTypeface();
|
||||||
|
|
||||||
|
foreach (var line in view.VisualLines)
|
||||||
|
{
|
||||||
|
if (line.IsDisposed || line.FirstDocumentLine == null || line.FirstDocumentLine.IsDeleted)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var lineNumber = line.FirstDocumentLine.LineNumber;
|
||||||
|
if (lineNumber >= _editor.BlameData.LineInfos.Count)
|
||||||
|
break;
|
||||||
|
|
||||||
|
var info = _editor.BlameData.LineInfos[lineNumber - 1];
|
||||||
|
var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - view.VerticalOffset;
|
||||||
|
var shaLink = new FormattedText(
|
||||||
|
info.CommitSHA,
|
||||||
|
CultureInfo.CurrentCulture,
|
||||||
|
FlowDirection.LeftToRight,
|
||||||
|
typeface,
|
||||||
|
_editor.FontSize,
|
||||||
|
Brushes.DarkOrange);
|
||||||
|
|
||||||
|
var rect = new Rect(0, y, shaLink.Width, shaLink.Height);
|
||||||
|
if (rect.Contains(pos))
|
||||||
|
{
|
||||||
|
Cursor = Cursor.Parse("Hand");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Cursor = Cursor.Default;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnPointerPressed(e);
|
base.OnPointerPressed(e);
|
||||||
|
|
||||||
var view = TextView;
|
var view = TextView;
|
||||||
if (!e.Handled && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed && view != null && view.VisualLinesValid)
|
if (!e.Handled && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed && view is { VisualLinesValid: true })
|
||||||
{
|
{
|
||||||
var pos = e.GetPosition(this);
|
var pos = e.GetPosition(this);
|
||||||
var typeface = view.CreateTypeface();
|
var typeface = view.CreateTypeface();
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<TextBlock Grid.Column="2"
|
<TextBlock Grid.Column="2"
|
||||||
Classes="primary"
|
Classes="primary"
|
||||||
Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
|
Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||||
|
Cursor="Hand"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
Foreground="DarkOrange"
|
Foreground="DarkOrange"
|
||||||
TextDecorations="Underline"
|
TextDecorations="Underline"
|
||||||
|
|
Loading…
Reference in a new issue