Display a tooltip over registers with their current value

This commit is contained in:
baldurk
2014-09-25 09:46:17 +01:00
parent 3bc3f7a902
commit 672bd14af9
3 changed files with 166 additions and 5 deletions
+26 -5
View File
@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
WeifenLuo.WinFormsUI.Docking.DockPanelSkin dockPanelSkin1 = new WeifenLuo.WinFormsUI.Docking.DockPanelSkin();
WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin autoHideStripSkin1 = new WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin();
WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient1 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient();
@@ -98,6 +99,8 @@
this.VarName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.Type = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.Value = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.variableHover = new System.Windows.Forms.ToolTip(this.components);
this.hoverTimer = new System.Windows.Forms.Timer(this.components);
this.outSig = new TreelistView.TreeListView();
this.inSig = new TreelistView.TreeListView();
this.variableRegs = new TreelistView.TreeListView();
@@ -213,20 +216,20 @@
// autosToolStripMenuItem
//
this.autosToolStripMenuItem.Name = "autosToolStripMenuItem";
this.autosToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.autosToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.autosToolStripMenuItem.Text = "Autos";
this.autosToolStripMenuItem.Click += new System.EventHandler(this.autosToolStripMenuItem_Click);
//
// resourcesToolStripMenuItem
//
this.resourcesToolStripMenuItem.Name = "resourcesToolStripMenuItem";
this.resourcesToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.resourcesToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.resourcesToolStripMenuItem.Text = "Resources";
//
// watchToolStripMenuItem
//
this.watchToolStripMenuItem.Name = "watchToolStripMenuItem";
this.watchToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.watchToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.watchToolStripMenuItem.Text = "Watch";
this.watchToolStripMenuItem.Click += new System.EventHandler(this.watchToolStripMenuItem_Click);
//
@@ -246,7 +249,7 @@
this.debuggingStrip.Location = new System.Drawing.Point(0, 0);
this.debuggingStrip.Margin = new System.Windows.Forms.Padding(0, 0, 12, 0);
this.debuggingStrip.Name = "debuggingStrip";
this.debuggingStrip.Size = new System.Drawing.Size(234, 25);
this.debuggingStrip.Size = new System.Drawing.Size(203, 25);
this.debuggingStrip.TabIndex = 0;
this.debuggingStrip.Text = "Debugging";
//
@@ -359,7 +362,7 @@
this.editStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.saveButton,
this.snippetDropDown});
this.editStrip.Location = new System.Drawing.Point(246, 0);
this.editStrip.Location = new System.Drawing.Point(215, 0);
this.editStrip.Name = "editStrip";
this.editStrip.Size = new System.Drawing.Size(55, 25);
this.editStrip.TabIndex = 2;
@@ -515,6 +518,22 @@
//
this.Value.Text = "Value";
//
// variableHover
//
this.variableHover.AutoPopDelay = 5000;
this.variableHover.InitialDelay = 1000;
this.variableHover.OwnerDraw = true;
this.variableHover.ReshowDelay = 100;
this.variableHover.UseAnimation = false;
this.variableHover.UseFading = false;
this.variableHover.Draw += new System.Windows.Forms.DrawToolTipEventHandler(this.variableHover_Draw);
this.variableHover.Popup += new System.Windows.Forms.PopupEventHandler(this.variableHover_Popup);
//
// hoverTimer
//
this.hoverTimer.Interval = 500;
this.hoverTimer.Tick += new System.EventHandler(this.hoverTimer_Tick);
//
// outSig
//
treeListColumn14.AutoSize = true;
@@ -715,5 +734,7 @@
private System.Windows.Forms.ColumnHeader VarName;
private System.Windows.Forms.ColumnHeader Type;
private System.Windows.Forms.ColumnHeader Value;
private System.Windows.Forms.ToolTip variableHover;
private System.Windows.Forms.Timer hoverTimer;
}
}
+134
View File
@@ -505,6 +505,8 @@ namespace renderdocui.Windows
m_DisassemblyView.Margins.Margin1.Mask = (int)m_DisassemblyView.Markers[BREAKPOINT_MARKER + 1].Mask;
m_DisassemblyView.Margins.Margin3.Mask &= ~((int)m_DisassemblyView.Markers[BREAKPOINT_MARKER + 1].Mask);
m_DisassemblyView.MouseMove += new MouseEventHandler(scintilla1_MouseMove);
m_DisassemblyView.Leave += new EventHandler(scintilla1_Leave);
m_DisassemblyView.KeyDown += new KeyEventHandler(scintilla1_DebuggingKeyDown);
watchRegs.Items.Add(new ListViewItem(new string[] { "", "", "" }));
@@ -611,6 +613,138 @@ namespace renderdocui.Windows
}
}
private Point m_HoverPos = Point.Empty;
private string m_HoverReg = "";
private ScintillaNET.Scintilla m_HoverScintilla = null;
void scintilla1_MouseMove(object sender, MouseEventArgs e)
{
if (m_Trace == null || m_Trace.states.Length == 0) return;
ScintillaNET.Scintilla scintilla1 = sender as ScintillaNET.Scintilla;
var pt = scintilla1.PointToClient(Cursor.Position);
if (pt.X == m_HoverPos.X && pt.Y == m_HoverPos.Y) return;
m_HoverPos = pt;
variableHover.Hide(scintilla1);
hoverTimer.Enabled = false;
m_HoverScintilla = null;
int pos = scintilla1.PositionFromPoint(pt.X, pt.Y);
string word = scintilla1.GetWordFromPosition(pos);
var match = Regex.Match(word, "^[rvo][0-9]+$");
if (match.Success)
{
m_HoverReg = word;
m_HoverScintilla = scintilla1;
hoverTimer.Enabled = true;
hoverTimer.Start();
}
}
void scintilla1_Leave(object sender, EventArgs e)
{
ScintillaNET.Scintilla scintilla1 = sender as ScintillaNET.Scintilla;
System.Diagnostics.Trace.WriteLine("leave");
variableHover.Hide(scintilla1);
hoverTimer.Enabled = false;
m_HoverScintilla = null;
m_HoverPos = Point.Empty;
}
private void hoverTimer_Tick(object sender, EventArgs e)
{
if (m_Trace == null || m_Trace.states.Length == 0) return;
hoverTimer.Enabled = false;
if (m_HoverScintilla != null && m_HoverReg != "")
{
var pt = m_HoverScintilla.PointToClient(Cursor.Position);
var state = m_Trace.states[CurrentStep];
string regtype = m_HoverReg.Substring(0, 1);
string regidx = m_HoverReg.Substring(1);
ShaderVariable[] vars = null;
if (regtype == "r")
{
vars = state.registers;
}
else if (regtype == "v")
{
vars = m_Trace.inputs;
}
else if (regtype == "o")
{
vars = state.outputs;
}
int regindex = -1;
if (vars != null && int.TryParse(regidx, out regindex))
{
if (regindex >= 0 && regindex < vars.Length)
{
ShaderVariable vr = vars[regindex];
var fmt =
@"{0,5} | X Y Z W" + Environment.NewLine +
@"----------------------------------------------------" + Environment.NewLine +
@"float | {1,10} {2,10} {3,10} {4,10}" + Environment.NewLine +
@"uint | {5,10} {6,10} {7,10} {8,10}" + Environment.NewLine +
@"int | {9,10} {10,10} {11,10} {12,10}";
var tooltip = String.Format(fmt, m_HoverReg,
Formatter.Format(vr.value.fv[0]), Formatter.Format(vr.value.fv[1]), Formatter.Format(vr.value.fv[2]), Formatter.Format(vr.value.fv[3]),
vr.value.uv[0], vr.value.uv[1], vr.value.uv[2], vr.value.uv[3],
vr.value.iv[0], vr.value.iv[1], vr.value.iv[2], vr.value.iv[3]);
variableHover.Show(tooltip, m_HoverScintilla,
m_HoverScintilla.ClientRectangle.Left + pt.X + 10, m_HoverScintilla.ClientRectangle.Top + pt.Y + 10);
}
}
}
}
private const int ToolTipFontSize = 9;
private void variableHover_Popup(object sender, PopupEventArgs e)
{
using (Font fw = new Font(FontFamily.GenericMonospace, ToolTipFontSize))
{
SizeF size = TextRenderer.MeasureText(variableHover.GetToolTip(m_HoverScintilla), fw);
e.ToolTipSize = new Size((int)size.Width, (int)size.Height);
}
}
private void variableHover_Draw(object sender, DrawToolTipEventArgs e)
{
using (Font fw = new Font(FontFamily.GenericMonospace, ToolTipFontSize))
{
var g = e.Graphics;
DrawToolTipEventArgs args = new DrawToolTipEventArgs(g, e.AssociatedWindow, e.AssociatedControl, e.Bounds, e.ToolTipText,
variableHover.BackColor, variableHover.ForeColor, fw);
args.DrawBackground();
args.DrawBorder();
args.DrawText(TextFormatFlags.TextBoxControl);
}
}
public void ShowErrors(string errs)
{
errors.Text = errs.Replace("\n", Environment.NewLine);
+6
View File
@@ -154,4 +154,10 @@
<metadata name="editStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>261, 17</value>
</metadata>
<metadata name="variableHover.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>354, 17</value>
</metadata>
<metadata name="hoverTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>474, 17</value>
</metadata>
</root>