From d966fd50c1b6b7fafb4e886708f14e4d7de8404d Mon Sep 17 00:00:00 2001 From: Sour Date: Wed, 26 Dec 2018 00:29:11 -0500 Subject: [PATCH] Debugger: Memory viewer - Allow word wrapping in label tooltips (prevents content from being cut off entirely) + improved popup display location --- GUI.NET/Debugger/Controls/ctrlHexViewer.cs | 7 ++++--- GUI.NET/Debugger/HexBox/HexBox.cs | 11 +++++++++++ GUI.NET/Debugger/TooltipForm.cs | 2 +- GUI.NET/Debugger/frmCodeTooltip.cs | 4 ++++ GUI.NET/Debugger/frmMemoryViewer.cs | 4 ++-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/GUI.NET/Debugger/Controls/ctrlHexViewer.cs b/GUI.NET/Debugger/Controls/ctrlHexViewer.cs index bc49b0ad..9dc80288 100644 --- a/GUI.NET/Debugger/Controls/ctrlHexViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlHexViewer.cs @@ -419,17 +419,18 @@ namespace Mesen.GUI.Debugger.Controls set { this.ctrlHexBox.ByteEditingMode = value; } } - public delegate void ByteMouseHoverHandler(int address); + public delegate void ByteMouseHoverHandler(int address, Point position); public event ByteMouseHoverHandler ByteMouseHover; private void ctrlHexBox_MouseMove(object sender, MouseEventArgs e) { BytePositionInfo bpi = ctrlHexBox.GetHexBytePositionInfo(e.Location); - ByteMouseHover?.Invoke((int)bpi.Index); + Point position = ctrlHexBox.GetBytePosition(bpi.Index); + ByteMouseHover?.Invoke((int)bpi.Index, new Point(position.X + (int)(ctrlHexBox.CharSize.Width * 2.5), position.Y + (int)(ctrlHexBox.CharSize.Height * 1.1))); } private void ctrlHexBox_MouseLeave(object sender, EventArgs e) { - ByteMouseHover?.Invoke(-1); + ByteMouseHover?.Invoke(-1, Point.Empty); } private void UpdateLocationLabel() diff --git a/GUI.NET/Debugger/HexBox/HexBox.cs b/GUI.NET/Debugger/HexBox/HexBox.cs index e1758f87..92de9c42 100644 --- a/GUI.NET/Debugger/HexBox/HexBox.cs +++ b/GUI.NET/Debugger/HexBox/HexBox.cs @@ -2953,6 +2953,17 @@ namespace Be.Windows.Forms UpdateScrollSize(); } + public Point GetBytePosition(long byteIndex) + { + if(byteIndex < _startByte) { + return Point.Empty; + } + + Point gp = GetGridBytePoint(byteIndex - _startByte); + PointF pos = GetBytePointF(gp); + return this.PointToScreen(new Point((int)pos.X, (int)pos.Y)); + } + PointF GetBytePointF(long byteIndex) { Point gp = GetGridBytePoint(byteIndex); diff --git a/GUI.NET/Debugger/TooltipForm.cs b/GUI.NET/Debugger/TooltipForm.cs index 08c4d5e4..17468b08 100644 --- a/GUI.NET/Debugger/TooltipForm.cs +++ b/GUI.NET/Debugger/TooltipForm.cs @@ -45,7 +45,7 @@ namespace Mesen.GUI.Debugger if(!this.Visible) { this._parentContainedFocus = focusTarget.ContainsFocus; - this.Location = _requestedLocation; + UpdateLocation(); this.Show(); } else { UpdateLocation(); diff --git a/GUI.NET/Debugger/frmCodeTooltip.cs b/GUI.NET/Debugger/frmCodeTooltip.cs index 9b41bf9b..767a9515 100644 --- a/GUI.NET/Debugger/frmCodeTooltip.cs +++ b/GUI.NET/Debugger/frmCodeTooltip.cs @@ -93,6 +93,10 @@ namespace Mesen.GUI.Debugger } tlpMain.ResumeLayout(); this.Width = this.tlpMain.Width; + if(this.Location.X + this.Width > _parentForm.ClientSize.Width) { + int maxWidth = _parentForm.ClientSize.Width - this.Location.X - 10; + this.tlpMain.MaximumSize = new Size(maxWidth, _parentForm.ClientSize.Height - 10); + } this.Height = this.tlpMain.Height; this.BringToFront(); diff --git a/GUI.NET/Debugger/frmMemoryViewer.cs b/GUI.NET/Debugger/frmMemoryViewer.cs index d0651364..481e58a9 100644 --- a/GUI.NET/Debugger/frmMemoryViewer.cs +++ b/GUI.NET/Debugger/frmMemoryViewer.cs @@ -558,7 +558,7 @@ namespace Mesen.GUI.Debugger private frmCodeTooltip _tooltip = null; private CodeLabel _lastLabelTooltip = null; private int _lastTooltipAddress = -1; - private void ctrlHexViewer_ByteMouseHover(int address) + private void ctrlHexViewer_ByteMouseHover(int address, Point position) { if(address < 0 || !mnuShowLabelInfoOnMouseOver.Checked) { if(_tooltip != null) { @@ -622,7 +622,7 @@ namespace Mesen.GUI.Debugger _tooltip = new frmCodeTooltip(this, values); _tooltip.FormClosed += (s, evt) => { _tooltip = null; }; - _tooltip.SetFormLocation(new Point(Cursor.Position.X + 10, Cursor.Position.Y + 10), ctrlHexViewer); + _tooltip.SetFormLocation(new Point(position.X, position.Y), ctrlHexViewer); _lastLabelTooltip = label; } } else {