Debugger: Allow sort on label list + small tweaks
This commit is contained in:
parent
0007ca3e40
commit
34ee1dd0d6
2 changed files with 83 additions and 42 deletions
82
GUI.NET/Debugger/Controls/ctrlLabelList.Designer.cs
generated
82
GUI.NET/Debugger/Controls/ctrlLabelList.Designer.cs
generated
|
@ -28,55 +28,19 @@
|
|||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.lstLabels = new Mesen.GUI.Controls.DoubleBufferedListView();
|
||||
this.colFunctionLabel = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.colFunctionAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.colMemoryAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.mnuAdd = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuEdit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuDelete = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuFindOccurrences = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.lstLabels = new Mesen.GUI.Controls.DoubleBufferedListView();
|
||||
this.colFunctionLabel = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.colFunctionAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.colMemoryAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.contextMenu.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lstLabels
|
||||
//
|
||||
this.lstLabels.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.colFunctionLabel,
|
||||
this.colFunctionAddress,
|
||||
this.colMemoryAddress});
|
||||
this.lstLabels.ContextMenuStrip = this.contextMenu;
|
||||
this.lstLabels.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lstLabels.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lstLabels.FullRowSelect = true;
|
||||
this.lstLabels.GridLines = true;
|
||||
this.lstLabels.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
||||
this.lstLabels.HideSelection = false;
|
||||
this.lstLabels.Location = new System.Drawing.Point(0, 0);
|
||||
this.lstLabels.Name = "lstLabels";
|
||||
this.lstLabels.Size = new System.Drawing.Size(275, 112);
|
||||
this.lstLabels.TabIndex = 2;
|
||||
this.lstLabels.UseCompatibleStateImageBehavior = false;
|
||||
this.lstLabels.View = System.Windows.Forms.View.Details;
|
||||
this.lstLabels.DoubleClick += new System.EventHandler(this.lstLabels_DoubleClick);
|
||||
//
|
||||
// colFunctionLabel
|
||||
//
|
||||
this.colFunctionLabel.Text = "Label";
|
||||
this.colFunctionLabel.Width = 136;
|
||||
//
|
||||
// colFunctionAddress
|
||||
//
|
||||
this.colFunctionAddress.Text = "Address";
|
||||
this.colFunctionAddress.Width = 62;
|
||||
//
|
||||
// colMemoryAddress
|
||||
//
|
||||
this.colMemoryAddress.Text = "ROM Addr.";
|
||||
this.colMemoryAddress.Width = 71;
|
||||
//
|
||||
// contextMenu
|
||||
//
|
||||
this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
|
@ -86,7 +50,7 @@
|
|||
this.toolStripMenuItem1,
|
||||
this.mnuFindOccurrences});
|
||||
this.contextMenu.Name = "contextMenu";
|
||||
this.contextMenu.Size = new System.Drawing.Size(167, 120);
|
||||
this.contextMenu.Size = new System.Drawing.Size(167, 98);
|
||||
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.mnuActions_Opening);
|
||||
//
|
||||
// mnuAdd
|
||||
|
@ -124,6 +88,42 @@
|
|||
this.mnuFindOccurrences.Text = "Find Occurrences";
|
||||
this.mnuFindOccurrences.Click += new System.EventHandler(this.mnuFindOccurrences_Click);
|
||||
//
|
||||
// lstLabels
|
||||
//
|
||||
this.lstLabels.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.colFunctionLabel,
|
||||
this.colFunctionAddress,
|
||||
this.colMemoryAddress});
|
||||
this.lstLabels.ContextMenuStrip = this.contextMenu;
|
||||
this.lstLabels.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lstLabels.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lstLabels.FullRowSelect = true;
|
||||
this.lstLabels.GridLines = true;
|
||||
this.lstLabels.HideSelection = false;
|
||||
this.lstLabels.Location = new System.Drawing.Point(0, 0);
|
||||
this.lstLabels.Name = "lstLabels";
|
||||
this.lstLabels.Size = new System.Drawing.Size(275, 112);
|
||||
this.lstLabels.TabIndex = 2;
|
||||
this.lstLabels.UseCompatibleStateImageBehavior = false;
|
||||
this.lstLabels.View = System.Windows.Forms.View.Details;
|
||||
this.lstLabels.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lstLabels_ColumnClick);
|
||||
this.lstLabels.DoubleClick += new System.EventHandler(this.lstLabels_DoubleClick);
|
||||
//
|
||||
// colFunctionLabel
|
||||
//
|
||||
this.colFunctionLabel.Text = "Label";
|
||||
this.colFunctionLabel.Width = 136;
|
||||
//
|
||||
// colFunctionAddress
|
||||
//
|
||||
this.colFunctionAddress.Text = "Cpu Addr";
|
||||
this.colFunctionAddress.Width = 57;
|
||||
//
|
||||
// colMemoryAddress
|
||||
//
|
||||
this.colMemoryAddress.Text = "ROM Addr.";
|
||||
this.colMemoryAddress.Width = 84;
|
||||
//
|
||||
// ctrlLabelList
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
|
|
@ -17,9 +17,30 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
public event EventHandler OnLabelSelected;
|
||||
private List<ListViewItem> _listItems = new List<ListViewItem>();
|
||||
|
||||
private class LabelComparer : IComparer
|
||||
{
|
||||
private int _columnIndex;
|
||||
private bool _sortOrder;
|
||||
public LabelComparer(int columnIndex, bool sortOrder)
|
||||
{
|
||||
_columnIndex = columnIndex;
|
||||
_sortOrder = sortOrder;
|
||||
}
|
||||
|
||||
public int Compare(object x, object y)
|
||||
{
|
||||
if(_sortOrder) {
|
||||
return String.Compare(((ListViewItem)y).SubItems[_columnIndex].Text, ((ListViewItem)x).SubItems[_columnIndex].Text);
|
||||
} else {
|
||||
return String.Compare(((ListViewItem)x).SubItems[_columnIndex].Text, ((ListViewItem)y).SubItems[_columnIndex].Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ctrlLabelList()
|
||||
{
|
||||
InitializeComponent();
|
||||
lstLabels.ListViewItemSorter = new LabelComparer(0, false);
|
||||
}
|
||||
|
||||
public static void EditLabel(UInt32 address, AddressType type)
|
||||
|
@ -85,7 +106,16 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
item.ForeColor = Color.Gray;
|
||||
item.Font = new Font(item.Font, FontStyle.Italic);
|
||||
}
|
||||
item.SubItems.Add("$" + label.Address.ToString("X4"));
|
||||
string absAddress = string.Empty;
|
||||
switch(label.AddressType) {
|
||||
case AddressType.InternalRam: absAddress += "RAM: "; break;
|
||||
case AddressType.PrgRom: absAddress += "PRG: "; break;
|
||||
case AddressType.Register: absAddress += "REG: "; break;
|
||||
case AddressType.SaveRam: absAddress += "SRAM: "; break;
|
||||
case AddressType.WorkRam: absAddress += "WRAM: "; break;
|
||||
}
|
||||
absAddress += "$" + label.Address.ToString("X4");
|
||||
item.SubItems.Add(absAddress);
|
||||
item.SubItems[1].Tag = label;
|
||||
|
||||
item.Tag = relativeAddress;
|
||||
|
@ -146,5 +176,16 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
{
|
||||
OnFindOccurrence?.Invoke(lstLabels.SelectedItems[0].SubItems[1].Tag, null);
|
||||
}
|
||||
|
||||
int _prevSortColumn = 0;
|
||||
bool _descSort = false;
|
||||
private void lstLabels_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||
{
|
||||
if(_prevSortColumn == e.Column) {
|
||||
_descSort = !_descSort;
|
||||
}
|
||||
lstLabels.ListViewItemSorter = new LabelComparer(e.Column, _descSort);
|
||||
_prevSortColumn = e.Column;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue