Add event bookmarks to the event browser

This commit is contained in:
baldurk
2015-07-07 23:32:48 +02:00
parent a9b5fdbd31
commit 8e37133d69
4 changed files with 236 additions and 35 deletions
@@ -1000,17 +1000,23 @@ namespace TreelistView
Image icon = hoverNode != null && hoverNode == node ? GetHoverNodeBitmap(node) : GetNodeBitmap(node);
if (icon == null &&
(NodesSelection.Contains(node) || FocusedNode == node)
)
{
icon = SelectedImage;
}
Rectangle plusminusRect = glyphRect;
PaintCellBackground(dc, cellRect, node, col);
if (SelectedImage != null && (NodesSelection.Contains(node) || FocusedNode == node))
{
// center the image vertically
glyphRect.Y = cellRect.Y + (cellRect.Height / 2) - (SelectedImage.Height / 2);
glyphRect.X = cellRect.X;
glyphRect.Width = SelectedImage.Width;
glyphRect.Height = SelectedImage.Height;
PaintImage(dc, glyphRect, node, SelectedImage);
cellRect.X += (glyphRect.Width + 2);
cellRect.Width -= (glyphRect.Width + 2);
}
if (icon != null)
{
// center the image vertically
+67 -23
View File
@@ -34,10 +34,13 @@
TreelistView.TreeListColumn treeListColumn2 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("Drawcall", "Draw #")));
TreelistView.TreeListColumn treeListColumn3 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("Name", "Name")));
TreelistView.TreeListColumn treeListColumn4 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("Duration", "Duration (µs)")));
System.Windows.Forms.ToolStripLabel toolStripLabel4;
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
this.toolStripLabel2 = new System.Windows.Forms.ToolStripLabel();
this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
this.eventView = new TreelistView.TreeListView();
this.eventViewRightClick = new System.Windows.Forms.ContextMenuStrip(this.components);
this.selectVisibleColumnsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.findEventButton = new System.Windows.Forms.ToolStripButton();
@@ -52,17 +55,20 @@
this.findNext = new System.Windows.Forms.ToolStripButton();
this.findPrev = new System.Windows.Forms.ToolStripButton();
this.findHighlight = new System.Windows.Forms.Timer(this.components);
this.eventViewRightClick = new System.Windows.Forms.ContextMenuStrip(this.components);
this.selectVisibleColumnsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.bookmarkStrip = new System.Windows.Forms.ToolStrip();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toggleBookmark = new System.Windows.Forms.ToolStripButton();
toolStripLabel3 = new System.Windows.Forms.ToolStripLabel();
toolStripLabel4 = new System.Windows.Forms.ToolStripLabel();
this.toolStripContainer1.ContentPanel.SuspendLayout();
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
this.toolStripContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.eventView)).BeginInit();
this.eventViewRightClick.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.jumpStrip.SuspendLayout();
this.findStrip.SuspendLayout();
this.eventViewRightClick.SuspendLayout();
this.bookmarkStrip.SuspendLayout();
this.SuspendLayout();
//
// toolStripLabel3
@@ -92,7 +98,7 @@
// toolStripContainer1.ContentPanel
//
this.toolStripContainer1.ContentPanel.Controls.Add(this.eventView);
this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(285, 263);
this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(285, 238);
this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer1.LeftToolStripPanelVisible = false;
this.toolStripContainer1.Location = new System.Drawing.Point(0, 0);
@@ -107,6 +113,7 @@
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip1);
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.jumpStrip);
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.findStrip);
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.bookmarkStrip);
//
// eventView
//
@@ -133,7 +140,7 @@
this.eventView.Name = "eventView";
this.eventView.RowOptions.ShowHeader = false;
this.eventView.SelectedImage = global::renderdocui.Properties.Resources.flag_green;
this.eventView.Size = new System.Drawing.Size(285, 263);
this.eventView.Size = new System.Drawing.Size(285, 238);
this.eventView.TabIndex = 0;
this.eventView.TreeColumn = 2;
this.eventView.ViewOptions.HoverHandTreeColumn = false;
@@ -142,6 +149,21 @@
this.eventView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.eventView_AfterSelect);
this.eventView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.eventView_KeyDown);
//
// eventViewRightClick
//
this.eventViewRightClick.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.selectVisibleColumnsToolStripMenuItem});
this.eventViewRightClick.Name = "contextMenuStrip1";
this.eventViewRightClick.Size = new System.Drawing.Size(179, 26);
//
// selectVisibleColumnsToolStripMenuItem
//
this.selectVisibleColumnsToolStripMenuItem.Image = global::renderdocui.Properties.Resources.timeline_marker;
this.selectVisibleColumnsToolStripMenuItem.Name = "selectVisibleColumnsToolStripMenuItem";
this.selectVisibleColumnsToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.selectVisibleColumnsToolStripMenuItem.Text = "Select Visible Columns";
this.selectVisibleColumnsToolStripMenuItem.Click += new System.EventHandler(this.selectVisibleColumnsToolStripMenuItem_Click);
//
// toolStrip1
//
this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
@@ -152,7 +174,8 @@
this.findEventButton,
this.jumpEventButton,
this.timeDraws,
this.selectColumnsButton});
this.selectColumnsButton,
this.toggleBookmark});
this.toolStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
@@ -290,20 +313,41 @@
//
this.findHighlight.Interval = 400;
this.findHighlight.Tick += new System.EventHandler(this.findHighlight_Tick);
// eventViewRightClick
//
this.eventViewRightClick.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.selectVisibleColumnsToolStripMenuItem});
this.eventViewRightClick.Name = "contextMenuStrip1";
this.eventViewRightClick.Size = new System.Drawing.Size(179, 26);
// bookmarkStrip
//
// selectVisibleColumnsToolStripMenuItem
this.bookmarkStrip.Dock = System.Windows.Forms.DockStyle.None;
this.bookmarkStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.bookmarkStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
toolStripLabel4,
this.toolStripSeparator2});
this.bookmarkStrip.Location = new System.Drawing.Point(0, 75);
this.bookmarkStrip.Name = "bookmarkStrip";
this.bookmarkStrip.Size = new System.Drawing.Size(285, 25);
this.bookmarkStrip.Stretch = true;
this.bookmarkStrip.TabIndex = 3;
//
this.selectVisibleColumnsToolStripMenuItem.Image = global::renderdocui.Properties.Resources.timeline_marker;
this.selectVisibleColumnsToolStripMenuItem.Name = "selectVisibleColumnsToolStripMenuItem";
this.selectVisibleColumnsToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.selectVisibleColumnsToolStripMenuItem.Text = "Select Visible Columns";
this.selectVisibleColumnsToolStripMenuItem.Click += new System.EventHandler(this.selectVisibleColumnsToolStripMenuItem_Click);
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
//
// toolStripLabel4
//
toolStripLabel4.Image = global::renderdocui.Properties.Resources.asterisk_orange;
toolStripLabel4.Name = "toolStripLabel4";
toolStripLabel4.Size = new System.Drawing.Size(74, 22);
toolStripLabel4.Text = "Bookmarks";
//
// toggleBookmarkButton
//
this.toggleBookmark.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toggleBookmark.Image = global::renderdocui.Properties.Resources.asterisk_orange;
this.toggleBookmark.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toggleBookmark.Name = "toggleBookmarkButton";
this.toggleBookmark.Size = new System.Drawing.Size(23, 22);
this.toggleBookmark.Text = "Toggle Bookmark";
this.toggleBookmark.Click += new System.EventHandler(this.toggleBookmark_Click);
//
// EventBrowser
//
@@ -311,11 +355,6 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(285, 338);
this.Controls.Add(this.toolStripContainer1);
this.DockAreas = ((WeifenLuo.WinFormsUI.Docking.DockAreas)((((((WeifenLuo.WinFormsUI.Docking.DockAreas.Float | WeifenLuo.WinFormsUI.Docking.DockAreas.DockLeft)
| WeifenLuo.WinFormsUI.Docking.DockAreas.DockRight)
| WeifenLuo.WinFormsUI.Docking.DockAreas.DockTop)
| WeifenLuo.WinFormsUI.Docking.DockAreas.DockBottom)
| WeifenLuo.WinFormsUI.Docking.DockAreas.Document)));
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "EventBrowser";
this.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.DockLeft;
@@ -329,13 +368,15 @@
this.toolStripContainer1.ResumeLayout(false);
this.toolStripContainer1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.eventView)).EndInit();
this.eventViewRightClick.ResumeLayout(false);
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.jumpStrip.ResumeLayout(false);
this.jumpStrip.PerformLayout();
this.findStrip.ResumeLayout(false);
this.findStrip.PerformLayout();
this.eventViewRightClick.ResumeLayout(false);
this.bookmarkStrip.ResumeLayout(false);
this.bookmarkStrip.PerformLayout();
this.ResumeLayout(false);
}
@@ -362,6 +403,9 @@
private System.Windows.Forms.ContextMenuStrip eventViewRightClick;
private System.Windows.Forms.ToolStripMenuItem selectVisibleColumnsToolStripMenuItem;
private System.Windows.Forms.Timer findHighlight;
private System.Windows.Forms.ToolStrip bookmarkStrip;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripButton toggleBookmark;
}
}
+150 -5
View File
@@ -69,6 +69,7 @@ namespace renderdocui.Windows
core.Config.PreferredFont;
HideJumpAndFind();
ClearBookmarks();
m_Core = core;
@@ -84,6 +85,7 @@ namespace renderdocui.Windows
findEventButton.Enabled = false;
jumpEventButton.Enabled = false;
timeDraws.Enabled = false;
toggleBookmark.Enabled = false;
}
public class PersistData
@@ -363,9 +365,12 @@ namespace renderdocui.Windows
m_FrameNodes.Clear();
eventView.EndUpdate();
ClearBookmarks();
findEventButton.Enabled = false;
jumpEventButton.Enabled = false;
timeDraws.Enabled = false;
toggleBookmark.Enabled = false;
}
public void OnLogfileLoaded()
@@ -375,6 +380,9 @@ namespace renderdocui.Windows
findEventButton.Enabled = true;
jumpEventButton.Enabled = true;
timeDraws.Enabled = true;
toggleBookmark.Enabled = true;
ClearBookmarks();
eventView.BeginUpdate();
@@ -422,7 +430,7 @@ namespace renderdocui.Windows
eventView.EnsureVisible(n);
}
private bool SelectEvent(ref TreelistView.Node found, TreelistView.NodeCollection nodes, UInt32 frameID, UInt32 eventID)
private bool FindEventNode(ref TreelistView.Node found, TreelistView.NodeCollection nodes, UInt32 frameID, UInt32 eventID)
{
foreach (var n in nodes)
{
@@ -440,7 +448,7 @@ namespace renderdocui.Windows
if (n.Nodes.Count > 0)
{
bool exact = SelectEvent(ref found, n.Nodes, frameID, eventID);
bool exact = FindEventNode(ref found, n.Nodes, frameID, eventID);
if (exact) return true;
}
}
@@ -453,7 +461,7 @@ namespace renderdocui.Windows
if (eventView.Nodes.Count == 0) return false;
TreelistView.Node found = null;
SelectEvent(ref found, eventView.Nodes[0].Nodes, frameID, eventID);
FindEventNode(ref found, eventView.Nodes[0].Nodes, frameID, eventID);
if (found != null)
{
eventView.FocusedNode = found;
@@ -469,7 +477,8 @@ namespace renderdocui.Windows
{
foreach (var n in nodes)
{
n.Image = null;
if (!IsBookmarked((UInt32)n["EID"]))
n.Image = null;
if (n.Nodes.Count > 0)
{
@@ -498,7 +507,8 @@ namespace renderdocui.Windows
{
if (n["Name"].ToString().ToUpperInvariant().Contains(filter))
{
n.Image = global::renderdocui.Properties.Resources.find;
if (!IsBookmarked((UInt32)n["EID"]))
n.Image = global::renderdocui.Properties.Resources.find;
results++;
}
}
@@ -586,6 +596,8 @@ namespace renderdocui.Windows
{
SelectEvent(frameID, eventID);
HighlightBookmarks();
Invalidate();
}
@@ -600,6 +612,8 @@ namespace renderdocui.Windows
else
m_Core.SetEventID(this, 0, def.eventID);
}
HighlightBookmarks();
}
private void EventBrowser_Shown(object sender, EventArgs e)
@@ -649,6 +663,23 @@ namespace renderdocui.Windows
if(e.Control)
{
Keys[] digits = { Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5,
Keys.D6, Keys.D7, Keys.D8, Keys.D9, Keys.D0 };
for (int i = 0; i < 10; i++)
{
if (e.KeyCode == digits[i])
{
if (HasBookmark(i))
{
SelectEvent(0, GetBookmark(i));
}
}
}
if (e.KeyCode == Keys.B)
{
ToggleBookmark(m_Core.CurEvent);
}
if (e.KeyCode == Keys.G)
{
ShowJump();
@@ -935,6 +966,25 @@ namespace renderdocui.Windows
ShowJump();
}
private void bookmarkButton_Click(object sender, EventArgs e)
{
ToolStripButton but = sender as ToolStripButton;
if (but != null)
{
SelectEvent(0, (UInt32)but.Tag);
}
}
private void toggleBookmark_Click(object sender, EventArgs e)
{
DeferredEvent def = eventView.SelectedNode.Tag as DeferredEvent;
if (def != null)
{
ToggleBookmark(def.eventID);
}
}
private void timeDraws_Click(object sender, EventArgs e)
{
TimeDrawcalls();
@@ -954,5 +1004,100 @@ namespace renderdocui.Windows
{
m_Core.RemoveLogViewer(this);
}
private List<UInt32> m_Bookmark = new List<UInt32>();
private List<ToolStripButton> m_BookmarkButtons = new List<ToolStripButton>();
private bool IsBookmarked(UInt32 EID)
{
return m_Bookmark.Contains(EID);
}
private bool HasBookmark(int index)
{
return index >= 0 && index < m_Bookmark.Count;
}
private UInt32 GetBookmark(int index)
{
if (!HasBookmark(index))
return 0;
return m_Bookmark[index];
}
private void HighlightBookmarks()
{
foreach (var b in m_BookmarkButtons)
{
UInt32 EID = (UInt32)b.Tag;
if (m_Core.CurEvent == EID)
b.Checked = true;
else
b.Checked = false;
}
}
private void ClearBookmarks()
{
foreach(var b in m_BookmarkButtons)
bookmarkStrip.Items.Remove(b);
m_Bookmark.Clear();
m_BookmarkButtons.Clear();
bookmarkStrip.Visible = false;
}
private void ToggleBookmark(UInt32 EID)
{
int index = m_Bookmark.IndexOf(EID);
TreelistView.Node found = null;
FindEventNode(ref found, eventView.Nodes[0].Nodes, m_Core.CurFrame, EID);
while (found.NextSibling != null && found.NextSibling.Tag is DeferredEvent)
{
DeferredEvent def = found.NextSibling.Tag as DeferredEvent;
if (def.eventID == EID)
found = found.NextSibling;
else
break;
}
if (index >= 0)
{
bookmarkStrip.Items.Remove(m_BookmarkButtons[index]);
m_Bookmark.RemoveAt(index);
m_BookmarkButtons.RemoveAt(index);
found.Image = null;
}
else
{
ToolStripButton but = new ToolStripButton();
but.DisplayStyle = ToolStripItemDisplayStyle.Text;
but.Name = "bookmarkButton" + EID.ToString();
but.Text = EID.ToString();
but.Tag = EID;
but.Size = new Size(23, 22);
but.Click += new EventHandler(this.bookmarkButton_Click);
but.Checked = true;
bookmarkStrip.Items.Add(but);
found.Image = global::renderdocui.Properties.Resources.asterisk_orange;
m_Bookmark.Add(EID);
m_BookmarkButtons.Add(but);
}
bookmarkStrip.Visible = m_BookmarkButtons.Count > 0;
eventView.Invalidate();
}
}
}
+6
View File
@@ -132,6 +132,12 @@
<metadata name="findStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>116, 17</value>
</metadata>
<metadata name="bookmarkStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>573, 17</value>
</metadata>
<metadata name="toolStripLabel4.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="findHighlight.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>459, 17</value>
</metadata>