Debugger: Event Viewer - Fixed tooltip display issues
This commit is contained in:
parent
642f72a2f9
commit
6d6c17745f
7 changed files with 81 additions and 134 deletions
|
@ -20,7 +20,6 @@ namespace Mesen.GUI.Debugger
|
|||
private int _baseHeight = 262 * 2;
|
||||
|
||||
private EntityBinder _entityBinder = new EntityBinder();
|
||||
private frmInfoTooltip _tooltip = null;
|
||||
private Point _lastPos = new Point(-1, -1);
|
||||
private bool _needUpdate = false;
|
||||
private Bitmap _screenBitmap = null;
|
||||
|
@ -148,7 +147,7 @@ namespace Mesen.GUI.Debugger
|
|||
y = _lastPos.Y + 5;
|
||||
}
|
||||
|
||||
g.DrawOutlinedString(location, _overlayFont, Brushes.Black, Brushes.White, x, y);
|
||||
g.DrawOutlinedString(location, _overlayFont, Brushes.Black, Brushes.White, x*2, y*2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,10 +157,9 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private void UpdateOverlay(Point p)
|
||||
{
|
||||
int x = ((p.X & ~0x01) / (_zoomed ? 2 : 1)) & ~0x01;
|
||||
int y = ((p.Y & ~0x01) / (_zoomed ? 2 : 1)) & ~0x01;
|
||||
Point pos = GetCycleScanline(p);
|
||||
|
||||
if(_lastPos.X == x && _lastPos.Y == y) {
|
||||
if(_lastPos == pos) {
|
||||
//Same x,y location, no need to update
|
||||
return;
|
||||
}
|
||||
|
@ -169,13 +167,13 @@ namespace Mesen.GUI.Debugger
|
|||
using(Graphics g = Graphics.FromImage(_overlayBitmap)) {
|
||||
g.Clear(Color.Transparent);
|
||||
using(Pen bg = new Pen(Color.FromArgb(128, Color.LightGray))) {
|
||||
g.DrawRectangle(bg, x - 1, 0, 3, _overlayBitmap.Height);
|
||||
g.DrawRectangle(bg, 0, y - 1, _overlayBitmap.Width, 3);
|
||||
g.DrawRectangle(bg, pos.X * 2 - 1, 0, 3, _overlayBitmap.Height);
|
||||
g.DrawRectangle(bg, 0, pos.Y * 2 - 1, _overlayBitmap.Width, 3);
|
||||
}
|
||||
}
|
||||
|
||||
_needUpdate = true;
|
||||
_lastPos = new Point(x, y);
|
||||
_lastPos = pos;
|
||||
}
|
||||
|
||||
private void ClearOverlay()
|
||||
|
@ -187,13 +185,23 @@ namespace Mesen.GUI.Debugger
|
|||
_lastPos = new Point(-1, -1);
|
||||
}
|
||||
|
||||
private Point GetCycleScanline(Point location)
|
||||
{
|
||||
return new Point(
|
||||
((location.X & ~0x01) / (_zoomed ? 2 : 1)) / 2,
|
||||
((location.Y & ~0x01) / (_zoomed ? 2 : 1)) / 2
|
||||
);
|
||||
}
|
||||
|
||||
private void picPicture_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
int cycle = ((e.X & ~0x01) / (_zoomed ? 2 : 1)) / 2;
|
||||
int scanline = ((e.Y & ~0x01) / (_zoomed ? 2 : 1)) / 2;
|
||||
Point pos = GetCycleScanline(e.Location);
|
||||
if(_lastPos == pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions();
|
||||
DebugEventInfo evt = DebugApi.GetEventViewerEvent((UInt16)scanline, (UInt16)cycle, options);
|
||||
DebugEventInfo evt = DebugApi.GetEventViewerEvent((UInt16)pos.Y, (UInt16)pos.X, options);
|
||||
if(evt.ProgramCounter == 0xFFFFFFFF) {
|
||||
ResetTooltip();
|
||||
UpdateOverlay(e.Location);
|
||||
|
@ -232,21 +240,14 @@ namespace Mesen.GUI.Debugger
|
|||
double scale = _zoomed ? 2 : 1;
|
||||
UpdateOverlay(new Point((int)(evt.Cycle * 2 * scale), (int)(evt.Scanline * 2 * scale)));
|
||||
|
||||
ResetTooltip();
|
||||
Form parentForm = this.FindForm();
|
||||
_tooltip = new frmInfoTooltip(parentForm, values, 10);
|
||||
_tooltip.FormClosed += (s, ev) => { _tooltip = null; };
|
||||
Point location = picViewer.PointToScreen(e.Location);
|
||||
location.Offset(10, 10);
|
||||
_tooltip.SetFormLocation(location, this);
|
||||
Point location = parentForm.PointToClient(picViewer.PointToScreen(e.Location));
|
||||
BaseForm.GetPopupTooltip(parentForm).SetTooltip(location, values);
|
||||
}
|
||||
|
||||
private void ResetTooltip()
|
||||
{
|
||||
if(_tooltip != null) {
|
||||
_tooltip.Close();
|
||||
_tooltip = null;
|
||||
}
|
||||
BaseForm.GetPopupTooltip(this.FindForm()).Visible = false;
|
||||
}
|
||||
|
||||
private void picPicture_MouseLeave(object sender, EventArgs e)
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
using Mesen.GUI.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Mesen.GUI.Debugger
|
||||
{
|
||||
public class TooltipForm : BaseForm
|
||||
{
|
||||
protected Form _parentForm;
|
||||
private Point _requestedLocation;
|
||||
private bool _parentContainedFocus = false;
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
if(!DesignMode) {
|
||||
UpdateLocation();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateLocation()
|
||||
{
|
||||
Point p = _requestedLocation;
|
||||
if(p.Y + this.Height > _parentForm.ClientSize.Height) {
|
||||
this.Location = new Point(p.X, _parentForm.ClientSize.Height - this.Height);
|
||||
} else {
|
||||
this.Location = p;
|
||||
}
|
||||
}
|
||||
|
||||
public bool NeedRestoreFocus
|
||||
{
|
||||
get { return _parentContainedFocus; }
|
||||
}
|
||||
|
||||
public void SetFormLocation(Point screenLocation, Control focusTarget)
|
||||
{
|
||||
_requestedLocation = _parentForm.PointToClient(screenLocation);
|
||||
|
||||
if(!this.Visible) {
|
||||
this._parentContainedFocus = focusTarget.ContainsFocus;
|
||||
UpdateLocation();
|
||||
this.Show();
|
||||
} else {
|
||||
UpdateLocation();
|
||||
}
|
||||
|
||||
if(Program.IsMono) {
|
||||
focusTarget.Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
namespace Mesen.GUI.Debugger
|
||||
{
|
||||
partial class frmInfoTooltip
|
||||
partial class ctrlTooltip
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
|
@ -61,23 +61,15 @@
|
|||
this.tlpMain.Size = new System.Drawing.Size(8, 8);
|
||||
this.tlpMain.TabIndex = 0;
|
||||
//
|
||||
// frmCodeTooltip
|
||||
// ctrlTooltip
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoSize = true;
|
||||
this.ClientSize = new System.Drawing.Size(10, 10);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.panel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "frmCodeTooltip";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "frmCodeTooltip";
|
||||
this.Name = "ctrlTooltip";
|
||||
this.Text = "ctrlTooltip";
|
||||
this.panel.ResumeLayout(false);
|
||||
this.panel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
|
@ -13,34 +13,38 @@ using Mesen.GUI.Debugger.Controls;
|
|||
|
||||
namespace Mesen.GUI.Debugger
|
||||
{
|
||||
public partial class frmInfoTooltip : TooltipForm
|
||||
public partial class ctrlTooltip : UserControl
|
||||
{
|
||||
private Dictionary<string, string> _values;
|
||||
private int _showOnLeftOffset;
|
||||
private Form _parentForm;
|
||||
|
||||
protected override bool ShowWithoutActivation
|
||||
public ctrlTooltip()
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public frmInfoTooltip(Form parent, Dictionary<string, string> values, int showOnLeftOffset = 0)
|
||||
{
|
||||
_showOnLeftOffset = showOnLeftOffset;
|
||||
_parentForm = parent;
|
||||
_values = values;
|
||||
InitializeComponent();
|
||||
this.TopLevel = false;
|
||||
this.Parent = _parentForm;
|
||||
_parentForm.Controls.Add(this);
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
public void SetTooltip(Point location, Dictionary<string, string> values)
|
||||
{
|
||||
_parentForm = this.FindForm();
|
||||
_values = values;
|
||||
location.Offset(5, 5);
|
||||
Location = location;
|
||||
|
||||
UpdateContentLayout();
|
||||
|
||||
this.Visible = true;
|
||||
}
|
||||
|
||||
private void UpdateContentLayout()
|
||||
{
|
||||
tlpMain.SuspendLayout();
|
||||
|
||||
TableLayoutPanel tlpLabels = new TableLayoutPanel();
|
||||
tlpLabels.SuspendLayout();
|
||||
tlpLabels.AutoSize = true;
|
||||
this.Size = new Size(1, 1);
|
||||
tlpMain.Size = new Size(1, 1);
|
||||
tlpMain.Controls.Clear();
|
||||
tlpMain.Controls.Add(tlpLabels, 0, 0);
|
||||
int i = 0;
|
||||
int maxLabelWidth = (_parentForm.ClientSize.Width - this.Location.X - 150);
|
||||
|
@ -57,11 +61,7 @@ namespace Mesen.GUI.Debugger
|
|||
lbl.Font = new Font(BaseControl.MonospaceFontFamily, 10);
|
||||
lbl.Margin = new Padding(2);
|
||||
lbl.Text = kvp.Value;
|
||||
if(_showOnLeftOffset == 0) {
|
||||
lbl.Size = new Size(maxLabelWidth, 10);
|
||||
} else {
|
||||
lbl.Size = new Size(500, 10);
|
||||
}
|
||||
tlpLabels.Controls.Add(lbl, 1, i);
|
||||
|
||||
i++;
|
||||
|
@ -70,19 +70,16 @@ namespace Mesen.GUI.Debugger
|
|||
tlpLabels.ResumeLayout();
|
||||
tlpMain.ResumeLayout();
|
||||
|
||||
base.OnLoad(e);
|
||||
|
||||
this.Width = this.tlpMain.Width;
|
||||
if(this.Location.X + this.Width > _parentForm.ClientSize.Width) {
|
||||
if(_showOnLeftOffset > 0) {
|
||||
this.Left -= this.Width + _showOnLeftOffset * 2;
|
||||
} else {
|
||||
int maxWidth = Math.Max(10, _parentForm.ClientSize.Width - this.Location.X - 10);
|
||||
this.tlpMain.MaximumSize = new Size(maxWidth, _parentForm.ClientSize.Height - 10);
|
||||
this.MaximumSize = new Size(maxWidth, _parentForm.ClientSize.Height - 10);
|
||||
}
|
||||
if(this.Left + this.Width > _parentForm.ClientSize.Width) {
|
||||
this.Left = this.Left - this.Width - 5;
|
||||
}
|
||||
|
||||
this.Height = this.tlpMain.Height;
|
||||
if(this.Height + this.Top > _parentForm.ClientSize.Height) {
|
||||
this.Top = _parentForm.ClientSize.Height - this.Height - 5;
|
||||
}
|
||||
|
||||
this.BringToFront();
|
||||
|
||||
panel.BackColor = SystemColors.Info;
|
|
@ -1,4 +1,5 @@
|
|||
using Mesen.GUI.Config;
|
||||
using Mesen.GUI.Debugger;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
@ -19,6 +20,7 @@ namespace Mesen.GUI.Forms
|
|||
private System.ComponentModel.IContainer components;
|
||||
private bool _iconSet = false;
|
||||
protected int _inMenu = 0;
|
||||
private ctrlTooltip ctrlTooltip;
|
||||
private static Timer _tmrUpdateBackground;
|
||||
//private static bool _needResume = false;
|
||||
|
||||
|
@ -29,6 +31,11 @@ namespace Mesen.GUI.Forms
|
|||
|
||||
protected virtual bool IsConfigForm { get { return false; } }
|
||||
|
||||
public static ctrlTooltip GetPopupTooltip(Form form)
|
||||
{
|
||||
return (form as BaseForm).ctrlTooltip;
|
||||
}
|
||||
|
||||
public static void StartBackgroundTimer()
|
||||
{
|
||||
_tmrUpdateBackground = new Timer();
|
||||
|
@ -202,6 +209,7 @@ namespace Mesen.GUI.Forms
|
|||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.ctrlTooltip = new Mesen.GUI.Debugger.ctrlTooltip();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// toolTip
|
||||
|
@ -211,10 +219,22 @@ namespace Mesen.GUI.Forms
|
|||
this.toolTip.InitialDelay = 10;
|
||||
this.toolTip.ReshowDelay = 10;
|
||||
//
|
||||
// ctrlTooltip
|
||||
//
|
||||
this.ctrlTooltip.AutoSize = true;
|
||||
this.ctrlTooltip.Location = new System.Drawing.Point(77, 89);
|
||||
this.ctrlTooltip.Name = "ctrlTooltip";
|
||||
this.ctrlTooltip.Size = new System.Drawing.Size(97, 83);
|
||||
this.ctrlTooltip.TabIndex = 0;
|
||||
this.ctrlTooltip.Visible = false;
|
||||
//
|
||||
// BaseForm
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(284, 261);
|
||||
this.Controls.Add(this.ctrlTooltip);
|
||||
this.Name = "BaseForm";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
19
UI/UI.csproj
19
UI/UI.csproj
|
@ -319,6 +319,12 @@
|
|||
<DependentUpon>frmSpriteViewer.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\PpuViewer\SpriteInfo.cs" />
|
||||
<Compile Include="Debugger\Tooltips\ctrlTooltip.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\Tooltips\ctrlTooltip.Designer.cs">
|
||||
<DependentUpon>ctrlTooltip.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\Workspace\DebugWorkspace.cs" />
|
||||
<Compile Include="Debugger\Config\EventViewerInfo.cs" />
|
||||
<Compile Include="Debugger\Config\HexEditorInfo.cs" />
|
||||
|
@ -561,15 +567,6 @@
|
|||
<Compile Include="Debugger\HexBox\Util.cs" />
|
||||
<Compile Include="Debugger\MemoryTools\TblLoader.cs" />
|
||||
<Compile Include="Debugger\DebugWindowManager.cs" />
|
||||
<Compile Include="Debugger\Tooltips\frmInfoTooltip.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\Tooltips\frmInfoTooltip.Designer.cs">
|
||||
<DependentUpon>frmInfoTooltip.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\Tooltips\TooltipForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\WatchManager.cs" />
|
||||
<Compile Include="Debugger\Workspace\DebugWorkspaceManager.cs" />
|
||||
<Compile Include="Emulation\CursorManager.cs" />
|
||||
|
@ -863,8 +860,8 @@
|
|||
<EmbeddedResource Include="Debugger\HexBox\HexBox.resx">
|
||||
<DependentUpon>HexBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Debugger\Tooltips\frmInfoTooltip.resx">
|
||||
<DependentUpon>frmInfoTooltip.cs</DependentUpon>
|
||||
<EmbeddedResource Include="Debugger\Tooltips\ctrlTooltip.resx">
|
||||
<DependentUpon>ctrlTooltip.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\BaseConfigForm.resx">
|
||||
<DependentUpon>BaseConfigForm.cs</DependentUpon>
|
||||
|
|
Loading…
Add table
Reference in a new issue