mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 11:44:59 +00:00
fix: tooltip did not hide after pointer move out (#1178)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
e76328ff38
commit
245de9b458
6 changed files with 41 additions and 23 deletions
|
@ -59,7 +59,14 @@
|
|||
FontFamily="{DynamicResource Fonts.Monospace}"
|
||||
FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorFontSize}"
|
||||
TabWidth="{Binding Source={x:Static vm:Preferences.Instance}, Path=EditorTabWidth}"
|
||||
BlameData="{Binding Data}"/>
|
||||
BlameData="{Binding Data}">
|
||||
<ToolTip.IsOpen>
|
||||
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||
<Binding Path="$self.IsPointerOver"/>
|
||||
<Binding Path="$self.(ToolTip.Tip)" Converter="{x:Static ObjectConverters.IsNotNull}"/>
|
||||
</MultiBinding>
|
||||
</ToolTip.IsOpen>
|
||||
</v:BlameTextEditor>
|
||||
|
||||
<!-- Not supported mask (for binary files) -->
|
||||
<StackPanel Orientation="Vertical"
|
||||
|
|
|
@ -180,7 +180,6 @@ namespace SourceGit.Views
|
|||
{
|
||||
var msg = blame.GetCommitMessage(info.CommitSHA);
|
||||
ToolTip.SetTip(this, msg);
|
||||
ToolTip.SetIsOpen(this, true);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -188,7 +187,7 @@ namespace SourceGit.Views
|
|||
}
|
||||
|
||||
Cursor = Cursor.Default;
|
||||
ToolTip.SetIsOpen(this, false);
|
||||
ToolTip.SetTip(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,13 @@
|
|||
PointerEntered="OnSHAPointerEntered"
|
||||
PointerPressed="OnSHAPressed"
|
||||
ToolTip.ShowDelay="0">
|
||||
<ToolTip.IsOpen>
|
||||
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||
<Binding Path="$self.IsPointerOver"/>
|
||||
<Binding Path="$self.(ToolTip.Tip)" Converter="{x:Static ObjectConverters.IsNotNull}"/>
|
||||
</MultiBinding>
|
||||
</ToolTip.IsOpen>
|
||||
|
||||
<TextBlock.DataTemplates>
|
||||
<DataTemplate DataType="m:Commit">
|
||||
<StackPanel MinWidth="400" Orientation="Vertical">
|
||||
|
@ -152,6 +159,13 @@
|
|||
PointerEntered="OnSHAPointerEntered"
|
||||
PointerPressed="OnSHAPressed"
|
||||
ToolTip.ShowDelay="0">
|
||||
<ToolTip.IsOpen>
|
||||
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||
<Binding Path="$self.IsPointerOver"/>
|
||||
<Binding Path="$self.(ToolTip.Tip)" Converter="{x:Static ObjectConverters.IsNotNull}"/>
|
||||
</MultiBinding>
|
||||
</ToolTip.IsOpen>
|
||||
|
||||
<TextBlock.DataTemplates>
|
||||
<DataTemplate DataType="m:Commit">
|
||||
<StackPanel MinWidth="400" Orientation="Vertical">
|
||||
|
|
|
@ -133,12 +133,7 @@ namespace SourceGit.Views
|
|||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
if (ctl.IsEffectivelyVisible && ctl.DataContext is string newSHA && newSHA == sha)
|
||||
{
|
||||
ToolTip.SetTip(ctl, c);
|
||||
|
||||
if (ctl.IsPointerOver)
|
||||
ToolTip.SetIsOpen(ctl, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ using System.Threading.Tasks;
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Documents;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
|
@ -24,6 +26,21 @@ namespace SourceGit.Views
|
|||
|
||||
protected override Type StyleKeyOverride => typeof(SelectableTextBlock);
|
||||
|
||||
public CommitMessagePresenter()
|
||||
{
|
||||
var bindings = new MultiBinding()
|
||||
{
|
||||
Converter = BoolConverters.And,
|
||||
Bindings = new[]
|
||||
{
|
||||
new Binding() { Path = "IsPointerOver", Source = this },
|
||||
new Binding() { Path = "(ToolTip.Tip)", Source = this, TypeResolver = (_, name) => name == "ToolTip" ? typeof(ToolTip) : null, Converter = ObjectConverters.IsNotNull },
|
||||
}
|
||||
};
|
||||
|
||||
Bind(ToolTip.IsOpenProperty, bindings);
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
||||
{
|
||||
base.OnPropertyChanged(change);
|
||||
|
@ -107,14 +124,9 @@ namespace SourceGit.Views
|
|||
|
||||
_lastHover = link;
|
||||
if (!link.IsCommitSHA)
|
||||
{
|
||||
ToolTip.SetTip(this, link.Link);
|
||||
ToolTip.SetIsOpen(this, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessHoverCommitLink(link);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -264,12 +276,7 @@ namespace SourceGit.Views
|
|||
// If we have already queried this SHA, just use it.
|
||||
if (_inlineCommits.TryGetValue(sha, out var exist))
|
||||
{
|
||||
if (exist != null)
|
||||
{
|
||||
ToolTip.SetTip(this, exist);
|
||||
ToolTip.SetIsOpen(this, true);
|
||||
}
|
||||
|
||||
ToolTip.SetTip(this, exist);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -294,10 +301,7 @@ namespace SourceGit.Views
|
|||
|
||||
// Make sure user still hovers the target SHA.
|
||||
if (_lastHover == link && c != null)
|
||||
{
|
||||
ToolTip.SetTip(this, c);
|
||||
ToolTip.SetIsOpen(this, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -144,7 +144,6 @@ namespace SourceGit.Views
|
|||
_lastHover = match;
|
||||
SetCurrentValue(CursorProperty, Cursor.Parse("Hand"));
|
||||
ToolTip.SetTip(this, match.Link);
|
||||
ToolTip.SetIsOpen(this, true);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue