Debugger: Event Viewer - Added 2x and compact mode buttons

This commit is contained in:
Sour 2019-02-02 00:25:47 -05:00
parent e758398b8f
commit 9bdea323ee
6 changed files with 201 additions and 101 deletions

View file

@ -151,7 +151,6 @@ namespace Mesen.GUI.Config
public WatchFormatStyle WatchFormat = WatchFormatStyle.Hex;
public bool ShowBreakpointLabels = true;
public Size EventViewerSize = new Size(0, 0);
public Point EventViewerLocation;
public bool EventViewerRefreshOnBreak = true;
public bool EventViewerShowPpuRegisterWrites = true;

View file

@ -1,4 +1,6 @@
namespace Mesen.GUI.Debugger.Controls
using Mesen.GUI.Controls;
namespace Mesen.GUI.Debugger.Controls
{
partial class ctrlEventViewerPpuView
{
@ -28,7 +30,7 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.picPicture = new System.Windows.Forms.PictureBox();
this.picPicture = new Mesen.GUI.Controls.ctrlMesenPictureBox();
this.tmrOverlay = new System.Windows.Forms.Timer(this.components);
((System.ComponentModel.ISupportInitialize)(this.picPicture)).BeginInit();
this.SuspendLayout();
@ -37,6 +39,7 @@
//
this.picPicture.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picPicture.Cursor = System.Windows.Forms.Cursors.Default;
this.picPicture.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
this.picPicture.Location = new System.Drawing.Point(1, 1);
this.picPicture.Margin = new System.Windows.Forms.Padding(0);
this.picPicture.Name = "picPicture";
@ -66,7 +69,7 @@
#endregion
private System.Windows.Forms.PictureBox picPicture;
private ctrlMesenPictureBox picPicture;
private System.Windows.Forms.Timer tmrOverlay;
}
}

View file

@ -15,8 +15,10 @@ using System.Collections.ObjectModel;
namespace Mesen.GUI.Debugger.Controls
{
public partial class ctrlEventViewerPpuView : BaseControl
public partial class ctrlEventViewerPpuView : BaseControl, ICompactControl
{
public event EventHandler OnPictureResized;
private DebugState _state = new DebugState();
private Point _lastPos = new Point(-1, -1);
private bool _needUpdate = false;
@ -28,6 +30,7 @@ namespace Mesen.GUI.Debugger.Controls
private Dictionary<int, List<DebugEventInfo>> _debugEventsByCycle = new Dictionary<int, List<DebugEventInfo>>();
private List<DebugEventInfo> _debugEvents = new List<DebugEventInfo>();
private Font _overlayFont;
private double _scale = 1;
public ctrlEventViewerPpuView()
{
@ -119,10 +122,11 @@ namespace Mesen.GUI.Debugger.Controls
_displayBitmap = new Bitmap(682, picHeight);
}
this.picPicture.Width = _eventBitmap.Width + 2;
this.picPicture.Height = _eventBitmap.Height + 2;
this.Width = this.picPicture.Width + 2;
this.Height = this.picPicture.Height + 22;
Size picSize = new Size((int)((_eventBitmap.Width * _scale) + 2), (int)((_eventBitmap.Height * _scale) + 2));
if(picSize != this.picPicture.Size) {
this.picPicture.Size = picSize;
this.OnPictureResized?.Invoke(this, EventArgs.Empty);
}
var d = ConfigManager.Config.DebugInfo;
@ -204,8 +208,8 @@ namespace Mesen.GUI.Debugger.Controls
private void UpdateOverlay(Point p)
{
int x = p.X / 2 * 2;
int y = p.Y / 2 * 2;
int x = (int)(p.X / 2 * 2 / _scale);
int y = (int)(p.Y / 2 * 2 / _scale);
if(_lastPos.X == x && _lastPos.Y == y) {
//Same x,y location, no need to update
@ -330,10 +334,10 @@ namespace Mesen.GUI.Debugger.Controls
break;
}
UpdateOverlay(new Point(debugEvent.Cycle * 2, (debugEvent.Scanline + 1) * 2));
UpdateOverlay(new Point((int)(debugEvent.Cycle * 2 * _scale), (int)((debugEvent.Scanline + 1) * 2 * _scale)));
Form parentForm = this.FindForm();
_tooltip = new frmCodeTooltip(parentForm, values);
_tooltip = new frmCodeTooltip(parentForm, values, null, null, null, 10);
_tooltip.FormClosed += (s, evt) => { _tooltip = null; };
Point location = PointToScreen(e.Location);
location.Offset(10, 10);
@ -374,5 +378,16 @@ namespace Mesen.GUI.Debugger.Controls
{
UpdateDisplay(false);
}
public Size GetCompactSize(bool includeMargins)
{
return picPicture.Size + picPicture.Margin.Size;
}
public void ScaleImage(double scale)
{
_scale *= scale;
picPicture.Size = new Size((int)(picPicture.Width * scale), (int)(picPicture.Height * scale));
}
}
}

View file

@ -20,14 +20,16 @@ namespace Mesen.GUI.Debugger
private AddressTypeInfo _previewAddress;
private CodeInfo _code;
private Ld65DbgImporter _symbolProvider;
private int _showOnLeftOffset;
protected override bool ShowWithoutActivation
{
get { return true; }
}
public frmCodeTooltip(Form parent, Dictionary<string, string> values, AddressTypeInfo previewAddress = null, CodeInfo code = null, Ld65DbgImporter symbolProvider = null)
public frmCodeTooltip(Form parent, Dictionary<string, string> values, AddressTypeInfo previewAddress = null, CodeInfo code = null, Ld65DbgImporter symbolProvider = null, int showOnLeftOffset = 0)
{
_showOnLeftOffset = showOnLeftOffset;
_parentForm = parent;
_values = values;
_previewAddress = previewAddress;
@ -62,7 +64,11 @@ namespace Mesen.GUI.Debugger
lbl.Font = new Font(BaseControl.MonospaceFontFamily, 10);
lbl.Margin = new Padding(2);
lbl.Text = kvp.Value;
lbl.Size = new Size(maxLabelWidth, 10);
if(_showOnLeftOffset == 0) {
lbl.Size = new Size(maxLabelWidth, 10);
} else {
lbl.Size = new Size(500, 10);
}
tlpLabels.Controls.Add(lbl, 1, i);
i++;
@ -92,17 +98,22 @@ 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) {
int maxWidth = _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(_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);
}
}
this.Height = this.tlpMain.Height;
this.BringToFront();
base.OnLoad(e);
panel.BackColor = ThemeHelper.IsDark ? ThemeHelper.Theme.FormBgColor : SystemColors.Info;
}
}

View file

@ -33,8 +33,6 @@
{
this.tabMain = new System.Windows.Forms.TabControl();
this.tpgPpuView = new System.Windows.Forms.TabPage();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.panel1 = new System.Windows.Forms.Panel();
this.ctrlEventViewerPpuView = new Mesen.GUI.Debugger.Controls.ctrlEventViewerPpuView();
this.grpShow = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
@ -46,6 +44,7 @@
this.chkShowPpuRegisterWrites = new System.Windows.Forms.CheckBox();
this.chkShowMapperRegisterWrites = new System.Windows.Forms.CheckBox();
this.chkShowSpriteZero = new System.Windows.Forms.CheckBox();
this.chkShowPreviousFrameEvents = new System.Windows.Forms.CheckBox();
this.tpgListView = new System.Windows.Forms.TabPage();
this.ctrlEventViewerListView = new Mesen.GUI.Debugger.Controls.ctrlEventViewerListView();
this.menuStrip1 = new Mesen.GUI.Controls.ctrlMesenMenuStrip();
@ -55,11 +54,10 @@
this.mnuConfigureColors = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.mnuRefreshOnBreak = new System.Windows.Forms.ToolStripMenuItem();
this.chkShowPreviousFrameEvents = new System.Windows.Forms.CheckBox();
this.chkToggleZoom = new System.Windows.Forms.CheckBox();
this.btnToggleView = new System.Windows.Forms.Button();
this.tabMain.SuspendLayout();
this.tpgPpuView.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.panel1.SuspendLayout();
this.grpShow.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.tpgListView.SuspendLayout();
@ -80,7 +78,8 @@
//
// tpgPpuView
//
this.tpgPpuView.Controls.Add(this.tableLayoutPanel1);
this.tpgPpuView.Controls.Add(this.grpShow);
this.tpgPpuView.Controls.Add(this.ctrlEventViewerPpuView);
this.tpgPpuView.Location = new System.Drawing.Point(4, 22);
this.tpgPpuView.Name = "tpgPpuView";
this.tpgPpuView.Padding = new System.Windows.Forms.Padding(3);
@ -89,50 +88,22 @@
this.tpgPpuView.Text = "PPU View";
this.tpgPpuView.UseVisualStyleBackColor = true;
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.grpShow, 1, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 532F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(915, 532);
this.tableLayoutPanel1.TabIndex = 2;
//
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.Controls.Add(this.ctrlEventViewerPpuView);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Margin = new System.Windows.Forms.Padding(0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(705, 532);
this.panel1.TabIndex = 1;
//
// ctrlEventViewerPpuView
//
this.ctrlEventViewerPpuView.Location = new System.Drawing.Point(0, 0);
this.ctrlEventViewerPpuView.Margin = new System.Windows.Forms.Padding(0);
this.ctrlEventViewerPpuView.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
this.ctrlEventViewerPpuView.Name = "ctrlEventViewerPpuView";
this.ctrlEventViewerPpuView.Size = new System.Drawing.Size(685, 530);
this.ctrlEventViewerPpuView.Size = new System.Drawing.Size(685, 532);
this.ctrlEventViewerPpuView.TabIndex = 0;
this.ctrlEventViewerPpuView.SizeChanged += new System.EventHandler(this.ctrlEventViewerPpuView_SizeChanged);
this.ctrlEventViewerPpuView.OnPictureResized += new System.EventHandler(this.ctrlEventViewerPpuView_OnPictureResized);
//
// grpShow
//
this.grpShow.Controls.Add(this.tableLayoutPanel2);
this.grpShow.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpShow.Location = new System.Drawing.Point(708, 3);
this.grpShow.Dock = System.Windows.Forms.DockStyle.Right;
this.grpShow.Location = new System.Drawing.Point(694, 3);
this.grpShow.Name = "grpShow";
this.grpShow.Size = new System.Drawing.Size(204, 526);
this.grpShow.Size = new System.Drawing.Size(224, 532);
this.grpShow.TabIndex = 3;
this.grpShow.TabStop = false;
this.grpShow.Text = "Show...";
@ -166,7 +137,7 @@
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(198, 507);
this.tableLayoutPanel2.Size = new System.Drawing.Size(218, 513);
this.tableLayoutPanel2.TabIndex = 2;
//
// chkBreakpoints
@ -265,6 +236,18 @@
this.chkShowSpriteZero.UseVisualStyleBackColor = true;
this.chkShowSpriteZero.Click += new System.EventHandler(this.chkShowSpriteZero_Click);
//
// chkShowPreviousFrameEvents
//
this.chkShowPreviousFrameEvents.AutoSize = true;
this.tableLayoutPanel2.SetColumnSpan(this.chkShowPreviousFrameEvents, 2);
this.chkShowPreviousFrameEvents.Location = new System.Drawing.Point(3, 187);
this.chkShowPreviousFrameEvents.Name = "chkShowPreviousFrameEvents";
this.chkShowPreviousFrameEvents.Size = new System.Drawing.Size(167, 17);
this.chkShowPreviousFrameEvents.TabIndex = 8;
this.chkShowPreviousFrameEvents.Text = "Show previous frame\'s events";
this.chkShowPreviousFrameEvents.UseVisualStyleBackColor = true;
this.chkShowPreviousFrameEvents.Click += new System.EventHandler(this.chkShowPreviousFrameEvents_Click);
//
// tpgListView
//
this.tpgListView.Controls.Add(this.ctrlEventViewerListView);
@ -307,7 +290,7 @@
//
this.mnuClose.Image = global::Mesen.GUI.Properties.Resources.Exit;
this.mnuClose.Name = "mnuClose";
this.mnuClose.Size = new System.Drawing.Size(152, 22);
this.mnuClose.Size = new System.Drawing.Size(103, 22);
this.mnuClose.Text = "Close";
this.mnuClose.Click += new System.EventHandler(this.mnuClose_Click);
//
@ -342,32 +325,45 @@
this.mnuRefreshOnBreak.Text = "Refresh on pause/break";
this.mnuRefreshOnBreak.Click += new System.EventHandler(this.mnuRefreshOnBreak_Click);
//
// chkShowPreviousFrameEvents
// chkToggleZoom
//
this.chkShowPreviousFrameEvents.AutoSize = true;
this.tableLayoutPanel2.SetColumnSpan(this.chkShowPreviousFrameEvents, 2);
this.chkShowPreviousFrameEvents.Location = new System.Drawing.Point(3, 187);
this.chkShowPreviousFrameEvents.Name = "chkShowPreviousFrameEvents";
this.chkShowPreviousFrameEvents.Size = new System.Drawing.Size(167, 17);
this.chkShowPreviousFrameEvents.TabIndex = 8;
this.chkShowPreviousFrameEvents.Text = "Show previous frame\'s events";
this.chkShowPreviousFrameEvents.UseVisualStyleBackColor = true;
this.chkShowPreviousFrameEvents.Click += new System.EventHandler(this.chkShowPreviousFrameEvents_Click);
this.chkToggleZoom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chkToggleZoom.Appearance = System.Windows.Forms.Appearance.Button;
this.chkToggleZoom.AutoCheck = false;
this.chkToggleZoom.Image = global::Mesen.GUI.Properties.Resources.Zoom2x;
this.chkToggleZoom.Location = new System.Drawing.Point(867, 1);
this.chkToggleZoom.Name = "chkToggleZoom";
this.chkToggleZoom.Size = new System.Drawing.Size(27, 22);
this.chkToggleZoom.TabIndex = 8;
this.chkToggleZoom.UseVisualStyleBackColor = true;
this.chkToggleZoom.Click += new System.EventHandler(this.chkToggleZoom_Click);
//
// btnToggleView
//
this.btnToggleView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnToggleView.Image = global::Mesen.GUI.Properties.Resources.Collapse;
this.btnToggleView.Location = new System.Drawing.Point(900, 1);
this.btnToggleView.Name = "btnToggleView";
this.btnToggleView.Size = new System.Drawing.Size(27, 22);
this.btnToggleView.TabIndex = 7;
this.btnToggleView.UseVisualStyleBackColor = true;
this.btnToggleView.Click += new System.EventHandler(this.btnToggleView_Click);
//
// frmEventViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(929, 588);
this.Controls.Add(this.chkToggleZoom);
this.Controls.Add(this.btnToggleView);
this.Controls.Add(this.tabMain);
this.Controls.Add(this.menuStrip1);
this.MinimumSize = new System.Drawing.Size(945, 627);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "frmEventViewer";
this.Text = "Event Viewer";
this.tabMain.ResumeLayout(false);
this.tpgPpuView.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.grpShow.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
@ -388,8 +384,6 @@
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mnuClose;
private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.CheckBox chkShowMapperRegisterReads;
private System.Windows.Forms.CheckBox chkShowNmi;
@ -406,5 +400,7 @@
private System.Windows.Forms.TabPage tpgListView;
private Controls.ctrlEventViewerListView ctrlEventViewerListView;
private System.Windows.Forms.CheckBox chkShowPreviousFrameEvents;
private System.Windows.Forms.CheckBox chkToggleZoom;
private System.Windows.Forms.Button btnToggleView;
}
}

View file

@ -18,21 +18,14 @@ namespace Mesen.GUI.Debugger
private InteropEmu.NotificationListener _notifListener;
private bool _inListViewTab = false;
private bool _refreshing = false;
private bool _isZoomed = false;
private bool _isCompact = false;
private Size _originalSize;
private Size _previousPictureSize;
public frmEventViewer()
{
InitializeComponent();
this.mnuRefreshOnBreak.Checked = ConfigManager.Config.DebugInfo.EventViewerRefreshOnBreak;
this.chkShowPpuRegisterWrites.Checked = ConfigManager.Config.DebugInfo.EventViewerShowPpuRegisterWrites;
this.chkShowPpuRegisterReads.Checked = ConfigManager.Config.DebugInfo.EventViewerShowPpuRegisterReads;
this.chkShowIrq.Checked = ConfigManager.Config.DebugInfo.EventViewerShowIrq;
this.chkShowNmi.Checked = ConfigManager.Config.DebugInfo.EventViewerShowNmi;
this.chkShowSpriteZero.Checked = ConfigManager.Config.DebugInfo.EventViewerShowSpriteZeroHit;
this.chkShowMapperRegisterWrites.Checked = ConfigManager.Config.DebugInfo.EventViewerShowMapperRegisterWrites;
this.chkShowMapperRegisterReads.Checked = ConfigManager.Config.DebugInfo.EventViewerShowMapperRegisterReads;
this.chkBreakpoints.Checked = ConfigManager.Config.DebugInfo.EventViewerShowMarkedBreakpoints;
this.chkShowPreviousFrameEvents.Checked = ConfigManager.Config.DebugInfo.EventViewerShowPreviousFrameEvents;
}
protected override void OnLoad(EventArgs e)
@ -40,14 +33,38 @@ namespace Mesen.GUI.Debugger
base.OnLoad(e);
if(!this.DesignMode) {
this.mnuRefreshOnBreak.Checked = ConfigManager.Config.DebugInfo.EventViewerRefreshOnBreak;
this.chkShowPpuRegisterWrites.Checked = ConfigManager.Config.DebugInfo.EventViewerShowPpuRegisterWrites;
this.chkShowPpuRegisterReads.Checked = ConfigManager.Config.DebugInfo.EventViewerShowPpuRegisterReads;
this.chkShowIrq.Checked = ConfigManager.Config.DebugInfo.EventViewerShowIrq;
this.chkShowNmi.Checked = ConfigManager.Config.DebugInfo.EventViewerShowNmi;
this.chkShowSpriteZero.Checked = ConfigManager.Config.DebugInfo.EventViewerShowSpriteZeroHit;
this.chkShowMapperRegisterWrites.Checked = ConfigManager.Config.DebugInfo.EventViewerShowMapperRegisterWrites;
this.chkShowMapperRegisterReads.Checked = ConfigManager.Config.DebugInfo.EventViewerShowMapperRegisterReads;
this.chkBreakpoints.Checked = ConfigManager.Config.DebugInfo.EventViewerShowMarkedBreakpoints;
this.chkShowPreviousFrameEvents.Checked = ConfigManager.Config.DebugInfo.EventViewerShowPreviousFrameEvents;
string toggleViewTooltip = "Toggle Compact/Normal View";
if(ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleView != Keys.None) {
toggleViewTooltip += " (" + DebuggerShortcutsConfig.GetShortcutDisplay(ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleView) + ")";
}
this.toolTip.SetToolTip(this.btnToggleView, toggleViewTooltip);
string toggleZoomTooltip = "Toggle 2x Zoom";
if(ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleZoom != Keys.None) {
toggleZoomTooltip += " (" + DebuggerShortcutsConfig.GetShortcutDisplay(ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleZoom) + ")";
}
this.toolTip.SetToolTip(this.chkToggleZoom, toggleZoomTooltip);
_previousPictureSize = ctrlEventViewerPpuView.Size;
this.GetData();
this.RefreshViewer();
DebugWorkspaceManager.GetWorkspace();
if(!ConfigManager.Config.DebugInfo.EventViewerSize.IsEmpty) {
if(!ConfigManager.Config.DebugInfo.EventViewerLocation.IsEmpty) {
this.StartPosition = FormStartPosition.Manual;
this.Size = ConfigManager.Config.DebugInfo.EventViewerSize;
this.Location = ConfigManager.Config.DebugInfo.EventViewerLocation;
}
@ -60,10 +77,21 @@ namespace Mesen.GUI.Debugger
{
base.OnFormClosing(e);
this._notifListener.OnNotification -= this._notifListener_OnNotification;
ConfigManager.Config.DebugInfo.EventViewerSize = this.WindowState != FormWindowState.Normal ? this.RestoreBounds.Size : this.Size;
ConfigManager.Config.DebugInfo.EventViewerLocation = this.WindowState != FormWindowState.Normal ? this.RestoreBounds.Location : this.Location;
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleZoom) {
ToggleZoom();
return true;
} else if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleView) {
ToggleView();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
private void _notifListener_OnNotification(InteropEmu.NotificationEventArgs e)
{
switch(e.NotificationType) {
@ -199,19 +227,67 @@ namespace Mesen.GUI.Debugger
}
}
private void ctrlEventViewerPpuView_SizeChanged(object sender, EventArgs e)
private void ctrlEventViewerPpuView_OnPictureResized(object sender, EventArgs e)
{
int newWidth = ctrlEventViewerPpuView.Width + 20;
int widthDiff = newWidth - panel1.Width;
panel1.Width = newWidth;
Size picSize = ctrlEventViewerPpuView.GetCompactSize(false);
this.Size += (picSize - _previousPictureSize);
_originalSize += (picSize - _previousPictureSize);
ctrlEventViewerPpuView.Size += (picSize - _previousPictureSize);
_previousPictureSize = picSize;
}
int newHeight = ctrlEventViewerPpuView.Height + 5 + (Program.IsMono ? 5 : 0);
int heightDiff = newHeight - panel1.Height;
panel1.Height = newHeight;
private void ToggleView()
{
if(!_isCompact) {
_isCompact = true;
_originalSize = this.Size;
int minWidth = this.MinimumSize.Width + widthDiff;
int minHeight = this.MinimumSize.Height + heightDiff;
this.MinimumSize = new Size(minWidth, Math.Min(800, minHeight));
this.ClientSize = ctrlEventViewerPpuView.GetCompactSize(false) + new Size(3, menuStrip1.Height + 3);
this.Controls.Add(ctrlEventViewerPpuView);
ctrlEventViewerPpuView.BringToFront();
ctrlEventViewerPpuView.Dock = DockStyle.Fill;
tabMain.Visible = false;
} else {
_isCompact = false;
this.Size = _originalSize;
ctrlEventViewerPpuView.Dock = DockStyle.None;
ctrlEventViewerPpuView.Size = ctrlEventViewerPpuView.GetCompactSize(false);
tabMain.Visible = true;
tpgPpuView.Controls.Add(ctrlEventViewerPpuView);
}
btnToggleView.Image = _isCompact ? Properties.Resources.Expand : Properties.Resources.Collapse;
RefreshViewer();
}
private void ToggleZoom()
{
ICompactControl ctrl = ctrlEventViewerPpuView;
if(!_isZoomed) {
Size pictureSize = ctrl.GetCompactSize(false);
ctrl.ScaleImage(2);
_isZoomed = true;
} else {
Size pictureSize = ctrl.GetCompactSize(false);
Size halfSize = new Size(pictureSize.Width / 2, pictureSize.Height / 2);
ctrl.ScaleImage(0.5);
_isZoomed = false;
}
chkToggleZoom.Checked = _isZoomed;
RefreshViewer();
}
private void btnToggleView_Click(object sender, EventArgs e)
{
ToggleView();
}
private void chkToggleZoom_Click(object sender, EventArgs e)
{
ToggleZoom();
}
}
}