Browse Source

Fix #2831: Popup/Tooltip scaling on multi-monitor multi-DPI setups.

pull/2843/head
Siegfried Pammer 3 years ago
parent
commit
bfe3914a5e
  1. 14
      ILSpy/TextView/DecompilerTextView.cs

14
ILSpy/TextView/DecompilerTextView.cs

@ -231,6 +231,8 @@ namespace ICSharpCode.ILSpy.TextView
{ {
var popupPosition = GetPopupPosition(e); var popupPosition = GetPopupPosition(e);
popupToolTip.Closed += ToolTipClosed; popupToolTip.Closed += ToolTipClosed;
popupToolTip.Placement = PlacementMode.Relative;
popupToolTip.PlacementTarget = this;
popupToolTip.HorizontalOffset = popupPosition.X; popupToolTip.HorizontalOffset = popupPosition.X;
popupToolTip.VerticalOffset = popupPosition.Y; popupToolTip.VerticalOffset = popupPosition.Y;
popupToolTip.StaysOpen = true; // We will close it ourselves popupToolTip.StaysOpen = true; // We will close it ourselves
@ -282,23 +284,19 @@ namespace ICSharpCode.ILSpy.TextView
Point GetPopupPosition(MouseEventArgs mouseArgs) Point GetPopupPosition(MouseEventArgs mouseArgs)
{ {
Point mousePos = mouseArgs.GetPosition(this); Point mousePos = mouseArgs.GetPosition(this);
Point positionInPixels;
// align Popup with line bottom // align Popup with line bottom
TextViewPosition? logicalPos = textEditor.GetPositionFromPoint(mousePos); TextViewPosition? logicalPos = textEditor.GetPositionFromPoint(mousePos);
if (logicalPos.HasValue) if (logicalPos.HasValue)
{ {
var textView = textEditor.TextArea.TextView; var textView = textEditor.TextArea.TextView;
positionInPixels = return textView.GetVisualPosition(logicalPos.Value, VisualYPosition.LineBottom)
textView.PointToScreen( - textView.ScrollOffset
textView.GetVisualPosition(logicalPos.Value, VisualYPosition.LineBottom) - textView.ScrollOffset); + new Vector(-4, 0);
positionInPixels.X -= 4;
} }
else else
{ {
positionInPixels = PointToScreen(mousePos + new Vector(-4, 6)); return mousePos + new Vector(-4, 6);
} }
// use device independent units, because Popup Left/Top are in independent units
return positionInPixels.TransformFromDevice(this);
} }
void TextViewMouseHoverStopped(object sender, MouseEventArgs e) void TextViewMouseHoverStopped(object sender, MouseEventArgs e)

Loading…
Cancel
Save