From 5f88fa8cc63b5fa597379d10b62a6e37f432d018 Mon Sep 17 00:00:00 2001 From: Sour Date: Mon, 21 Jan 2019 14:38:38 -0500 Subject: [PATCH] Debugger: PPU Viewer - Add 2x zoom toggle --- GUI.NET/Config/DebuggerShortcutsConfig.cs | 2 + GUI.NET/Controls/ctrlMesenPictureBox.cs | 16 + .../Controls/ctrlChrViewer.Designer.cs | 322 +++++++++--------- GUI.NET/Debugger/Controls/ctrlChrViewer.cs | 14 +- .../Controls/ctrlNametableViewer.Designer.cs | 53 ++- .../Debugger/Controls/ctrlNametableViewer.cs | 9 +- .../Controls/ctrlPaletteViewer.Designer.cs | 26 +- .../Debugger/Controls/ctrlPaletteViewer.cs | 18 +- .../Controls/ctrlSpriteViewer.Designer.cs | 17 +- GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs | 81 +++-- GUI.NET/Debugger/frmDbgPreferences.cs | 1 + GUI.NET/Debugger/frmPpuViewer.Designer.cs | 59 ++-- GUI.NET/Debugger/frmPpuViewer.cs | 69 +++- GUI.NET/Debugger/frmPpuViewer.resx | 2 +- GUI.NET/GUI.NET.csproj | 4 + GUI.NET/Properties/Resources.Designer.cs | 10 + GUI.NET/Properties/Resources.resx | 3 + GUI.NET/Resources/Zoom2x.png | Bin 0 -> 401 bytes 18 files changed, 428 insertions(+), 278 deletions(-) create mode 100644 GUI.NET/Controls/ctrlMesenPictureBox.cs create mode 100644 GUI.NET/Resources/Zoom2x.png diff --git a/GUI.NET/Config/DebuggerShortcutsConfig.cs b/GUI.NET/Config/DebuggerShortcutsConfig.cs index 55aa375e..59d54515 100644 --- a/GUI.NET/Config/DebuggerShortcutsConfig.cs +++ b/GUI.NET/Config/DebuggerShortcutsConfig.cs @@ -56,6 +56,8 @@ namespace Mesen.GUI.Config [ShortcutName("PPU Viewer: Toggle View")] public XmlKeys PpuViewer_ToggleView = Keys.Control | Keys.Q; + [ShortcutName("PPU Viewer: Toggle Zoom")] + public XmlKeys PpuViewer_ToggleZoom = Keys.Control | Keys.W; [ShortcutName("Edit in Memory Viewer")] public XmlKeys CodeWindow_EditInMemoryViewer = Keys.F1; diff --git a/GUI.NET/Controls/ctrlMesenPictureBox.cs b/GUI.NET/Controls/ctrlMesenPictureBox.cs new file mode 100644 index 00000000..1e3ec2ea --- /dev/null +++ b/GUI.NET/Controls/ctrlMesenPictureBox.cs @@ -0,0 +1,16 @@ +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +namespace Mesen.GUI.Controls +{ + public class ctrlMesenPictureBox : PictureBox + { + public InterpolationMode InterpolationMode { get; set; } + + protected override void OnPaint(PaintEventArgs paintEventArgs) + { + paintEventArgs.Graphics.InterpolationMode = InterpolationMode; + base.OnPaint(paintEventArgs); + } + } +} diff --git a/GUI.NET/Debugger/Controls/ctrlChrViewer.Designer.cs b/GUI.NET/Debugger/Controls/ctrlChrViewer.Designer.cs index ddc4554b..2ec6550c 100644 --- a/GUI.NET/Debugger/Controls/ctrlChrViewer.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlChrViewer.Designer.cs @@ -30,7 +30,15 @@ namespace Mesen.GUI.Debugger.Controls private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); + this.tlpMain = new System.Windows.Forms.TableLayoutPanel(); + this.picChrBank1 = new Mesen.GUI.Controls.ctrlMesenPictureBox(); + this.ctxMenu = new Mesen.GUI.Controls.ctrlMesenContextMenuStrip(this.components); + this.mnuEditInMemoryViewer = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); + this.mnuCopyHdPack = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); + this.mnuCopyToClipboard = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuExportToPng = new System.Windows.Forms.ToolStripMenuItem(); this.grpDisplayOptions = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.chkShowSingleColorTilesInGrayscale = new System.Windows.Forms.CheckBox(); @@ -38,7 +46,6 @@ namespace Mesen.GUI.Debugger.Controls this.lblPalette = new System.Windows.Forms.Label(); this.cboPalette = new System.Windows.Forms.ComboBox(); this.picPaletteTooltip = new System.Windows.Forms.PictureBox(); - this.chkLargeSprites = new System.Windows.Forms.CheckBox(); this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel(); this.lblChrSelection = new System.Windows.Forms.Label(); this.cboChrSelection = new System.Windows.Forms.ComboBox(); @@ -46,6 +53,8 @@ namespace Mesen.GUI.Debugger.Controls this.lblHighlight = new System.Windows.Forms.Label(); this.cboHighlightType = new System.Windows.Forms.ComboBox(); this.chkAutoPalette = new System.Windows.Forms.CheckBox(); + this.chkLargeSprites = new System.Windows.Forms.CheckBox(); + this.picChrBank2 = new Mesen.GUI.Controls.ctrlMesenPictureBox(); this.grpTileInfo = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); this.txtTileAddress = new System.Windows.Forms.TextBox(); @@ -58,60 +67,121 @@ namespace Mesen.GUI.Debugger.Controls this.picColorTooltip = new System.Windows.Forms.PictureBox(); this.picTileTooltip = new System.Windows.Forms.PictureBox(); this.ctrlTilePalette = new Mesen.GUI.Debugger.Controls.ctrlTilePalette(); - this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); - this.picChrBank1 = new System.Windows.Forms.PictureBox(); - this.ctxMenu = new Mesen.GUI.Controls.ctrlMesenContextMenuStrip(this.components); - this.mnuEditInMemoryViewer = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); - this.mnuCopyHdPack = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); - this.mnuCopyToClipboard = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuExportToPng = new System.Windows.Forms.ToolStripMenuItem(); - this.picChrBank2 = new System.Windows.Forms.PictureBox(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); - this.tableLayoutPanel3.SuspendLayout(); + this.tlpMain.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picChrBank1)).BeginInit(); + this.ctxMenu.SuspendLayout(); this.grpDisplayOptions.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.flowLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picPaletteTooltip)).BeginInit(); this.flowLayoutPanel2.SuspendLayout(); this.flpHighlight.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picChrBank2)).BeginInit(); this.grpTileInfo.SuspendLayout(); this.tableLayoutPanel4.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picTile)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picColorTooltip)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picTileTooltip)).BeginInit(); - this.tableLayoutPanel2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.picChrBank1)).BeginInit(); - this.ctxMenu.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.picChrBank2)).BeginInit(); this.SuspendLayout(); // - // tableLayoutPanel3 + // tlpMain // - this.tableLayoutPanel3.ColumnCount = 2; - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel3.Controls.Add(this.grpDisplayOptions, 1, 1); - this.tableLayoutPanel3.Controls.Add(this.grpTileInfo, 1, 0); - this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel2, 0, 0); - this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel3.Name = "tableLayoutPanel3"; - this.tableLayoutPanel3.RowCount = 2; - this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(534, 525); - this.tableLayoutPanel3.TabIndex = 3; + this.tlpMain.ColumnCount = 2; + this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tlpMain.Controls.Add(this.picChrBank1, 0, 0); + this.tlpMain.Controls.Add(this.grpDisplayOptions, 1, 1); + this.tlpMain.Controls.Add(this.picChrBank2, 0, 1); + this.tlpMain.Controls.Add(this.grpTileInfo, 1, 0); + this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.tlpMain.Location = new System.Drawing.Point(0, 0); + this.tlpMain.Name = "tlpMain"; + this.tlpMain.RowCount = 2; + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tlpMain.Size = new System.Drawing.Size(701, 522); + this.tlpMain.TabIndex = 3; + // + // picChrBank1 + // + this.picChrBank1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picChrBank1.ContextMenuStrip = this.ctxMenu; + this.picChrBank1.Cursor = System.Windows.Forms.Cursors.Hand; + this.picChrBank1.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; + this.picChrBank1.Location = new System.Drawing.Point(1, 1); + this.picChrBank1.Margin = new System.Windows.Forms.Padding(1); + this.picChrBank1.Name = "picChrBank1"; + this.picChrBank1.Size = new System.Drawing.Size(258, 258); + this.picChrBank1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.picChrBank1.TabIndex = 0; + this.picChrBank1.TabStop = false; + this.picChrBank1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picChrBank_MouseDown); + this.picChrBank1.MouseEnter += new System.EventHandler(this.picChrBank_MouseEnter); + this.picChrBank1.MouseLeave += new System.EventHandler(this.picChrBank_MouseLeave); + this.picChrBank1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picChrBank_MouseMove); + // + // ctxMenu + // + this.ctxMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuEditInMemoryViewer, + this.toolStripMenuItem2, + this.mnuCopyHdPack, + this.toolStripMenuItem1, + this.mnuCopyToClipboard, + this.mnuExportToPng}); + this.ctxMenu.Name = "ctxMenu"; + this.ctxMenu.Size = new System.Drawing.Size(222, 104); + this.ctxMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ctxMenu_Opening); + // + // mnuEditInMemoryViewer + // + this.mnuEditInMemoryViewer.Image = global::Mesen.GUI.Properties.Resources.CheatCode; + this.mnuEditInMemoryViewer.Name = "mnuEditInMemoryViewer"; + this.mnuEditInMemoryViewer.Size = new System.Drawing.Size(221, 22); + this.mnuEditInMemoryViewer.Text = "Edit in Memory Viewer"; + this.mnuEditInMemoryViewer.Click += new System.EventHandler(this.mnuEditInMemoryViewer_Click); + // + // toolStripMenuItem2 + // + this.toolStripMenuItem2.Name = "toolStripMenuItem2"; + this.toolStripMenuItem2.Size = new System.Drawing.Size(218, 6); + // + // mnuCopyHdPack + // + this.mnuCopyHdPack.Name = "mnuCopyHdPack"; + this.mnuCopyHdPack.Size = new System.Drawing.Size(221, 22); + this.mnuCopyHdPack.Text = "Copy Tile (HD Pack Format)"; + this.mnuCopyHdPack.Click += new System.EventHandler(this.mnuCopyHdPack_Click); + // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(218, 6); + // + // mnuCopyToClipboard + // + this.mnuCopyToClipboard.Image = global::Mesen.GUI.Properties.Resources.Copy; + this.mnuCopyToClipboard.Name = "mnuCopyToClipboard"; + this.mnuCopyToClipboard.Size = new System.Drawing.Size(221, 22); + this.mnuCopyToClipboard.Text = "Copy image to clipboard"; + this.mnuCopyToClipboard.Click += new System.EventHandler(this.mnuCopyToClipboard_Click); + // + // mnuExportToPng + // + this.mnuExportToPng.Image = global::Mesen.GUI.Properties.Resources.Export; + this.mnuExportToPng.Name = "mnuExportToPng"; + this.mnuExportToPng.Size = new System.Drawing.Size(221, 22); + this.mnuExportToPng.Text = "Export image to PNG"; + this.mnuExportToPng.Click += new System.EventHandler(this.mnuExportToPng_Click); // // grpDisplayOptions // this.grpDisplayOptions.Controls.Add(this.tableLayoutPanel1); - this.grpDisplayOptions.Dock = System.Windows.Forms.DockStyle.Top; - this.grpDisplayOptions.Location = new System.Drawing.Point(269, 300); + this.grpDisplayOptions.Location = new System.Drawing.Point(263, 263); this.grpDisplayOptions.Name = "grpDisplayOptions"; - this.grpDisplayOptions.Size = new System.Drawing.Size(264, 175); + this.grpDisplayOptions.Size = new System.Drawing.Size(435, 175); this.grpDisplayOptions.TabIndex = 4; this.grpDisplayOptions.TabStop = false; this.grpDisplayOptions.Text = "Display Options"; @@ -122,10 +192,10 @@ namespace Mesen.GUI.Debugger.Controls this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.Controls.Add(this.chkShowSingleColorTilesInGrayscale, 0, 5); this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 1); - this.tableLayoutPanel1.Controls.Add(this.chkLargeSprites, 0, 3); this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel2, 0, 0); this.tableLayoutPanel1.Controls.Add(this.flpHighlight, 0, 2); this.tableLayoutPanel1.Controls.Add(this.chkAutoPalette, 0, 4); + this.tableLayoutPanel1.Controls.Add(this.chkLargeSprites, 0, 3); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 16); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; @@ -136,7 +206,7 @@ namespace Mesen.GUI.Debugger.Controls this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(258, 156); + this.tableLayoutPanel1.Size = new System.Drawing.Size(429, 156); this.tableLayoutPanel1.TabIndex = 6; // // chkShowSingleColorTilesInGrayscale @@ -159,7 +229,7 @@ namespace Mesen.GUI.Debugger.Controls this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 27); this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(258, 27); + this.flowLayoutPanel1.Size = new System.Drawing.Size(429, 27); this.flowLayoutPanel1.TabIndex = 5; // // lblPalette @@ -204,17 +274,6 @@ namespace Mesen.GUI.Debugger.Controls this.picPaletteTooltip.TabIndex = 16; this.picPaletteTooltip.TabStop = false; // - // chkLargeSprites - // - this.chkLargeSprites.AutoSize = true; - this.chkLargeSprites.Location = new System.Drawing.Point(3, 84); - this.chkLargeSprites.Name = "chkLargeSprites"; - this.chkLargeSprites.Size = new System.Drawing.Size(133, 17); - this.chkLargeSprites.TabIndex = 2; - this.chkLargeSprites.Text = "Display as 8x16 sprites"; - this.chkLargeSprites.UseVisualStyleBackColor = true; - this.chkLargeSprites.CheckedChanged += new System.EventHandler(this.chkLargeSprites_CheckedChanged); - // // flowLayoutPanel2 // this.flowLayoutPanel2.Controls.Add(this.lblChrSelection); @@ -223,7 +282,7 @@ namespace Mesen.GUI.Debugger.Controls this.flowLayoutPanel2.Location = new System.Drawing.Point(0, 0); this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(0); this.flowLayoutPanel2.Name = "flowLayoutPanel2"; - this.flowLayoutPanel2.Size = new System.Drawing.Size(258, 27); + this.flowLayoutPanel2.Size = new System.Drawing.Size(429, 27); this.flowLayoutPanel2.TabIndex = 6; // // lblChrSelection @@ -255,7 +314,7 @@ namespace Mesen.GUI.Debugger.Controls this.flpHighlight.Location = new System.Drawing.Point(0, 54); this.flpHighlight.Margin = new System.Windows.Forms.Padding(0); this.flpHighlight.Name = "flpHighlight"; - this.flpHighlight.Size = new System.Drawing.Size(258, 27); + this.flpHighlight.Size = new System.Drawing.Size(429, 27); this.flpHighlight.TabIndex = 7; // // lblHighlight @@ -293,13 +352,41 @@ namespace Mesen.GUI.Debugger.Controls this.chkAutoPalette.UseVisualStyleBackColor = true; this.chkAutoPalette.CheckedChanged += new System.EventHandler(this.chkAutoPalette_CheckedChanged); // + // chkLargeSprites + // + this.chkLargeSprites.AutoSize = true; + this.chkLargeSprites.Location = new System.Drawing.Point(3, 84); + this.chkLargeSprites.Name = "chkLargeSprites"; + this.chkLargeSprites.Size = new System.Drawing.Size(133, 17); + this.chkLargeSprites.TabIndex = 2; + this.chkLargeSprites.Text = "Display as 8x16 sprites"; + this.chkLargeSprites.UseVisualStyleBackColor = true; + this.chkLargeSprites.CheckedChanged += new System.EventHandler(this.chkLargeSprites_CheckedChanged); + // + // picChrBank2 + // + this.picChrBank2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picChrBank2.ContextMenuStrip = this.ctxMenu; + this.picChrBank2.Cursor = System.Windows.Forms.Cursors.Hand; + this.picChrBank2.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; + this.picChrBank2.Location = new System.Drawing.Point(1, 261); + this.picChrBank2.Margin = new System.Windows.Forms.Padding(1); + this.picChrBank2.Name = "picChrBank2"; + this.picChrBank2.Size = new System.Drawing.Size(258, 258); + this.picChrBank2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.picChrBank2.TabIndex = 1; + this.picChrBank2.TabStop = false; + this.picChrBank2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picChrBank_MouseDown); + this.picChrBank2.MouseEnter += new System.EventHandler(this.picChrBank_MouseEnter); + this.picChrBank2.MouseLeave += new System.EventHandler(this.picChrBank_MouseLeave); + this.picChrBank2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picChrBank_MouseMove); + // // grpTileInfo // this.grpTileInfo.Controls.Add(this.tableLayoutPanel4); - this.grpTileInfo.Dock = System.Windows.Forms.DockStyle.Top; - this.grpTileInfo.Location = new System.Drawing.Point(269, 3); + this.grpTileInfo.Location = new System.Drawing.Point(263, 3); this.grpTileInfo.Name = "grpTileInfo"; - this.grpTileInfo.Size = new System.Drawing.Size(264, 291); + this.grpTileInfo.Size = new System.Drawing.Size(435, 254); this.grpTileInfo.TabIndex = 4; this.grpTileInfo.TabStop = false; this.grpTileInfo.Text = "Tile Info"; @@ -329,7 +416,7 @@ namespace Mesen.GUI.Debugger.Controls this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel4.Size = new System.Drawing.Size(258, 272); + this.tableLayoutPanel4.Size = new System.Drawing.Size(429, 235); this.tableLayoutPanel4.TabIndex = 0; // // txtTileAddress @@ -435,109 +522,6 @@ namespace Mesen.GUI.Debugger.Controls this.ctrlTilePalette.Size = new System.Drawing.Size(130, 34); this.ctrlTilePalette.TabIndex = 17; // - // tableLayoutPanel2 - // - this.tableLayoutPanel2.ColumnCount = 1; - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.Controls.Add(this.picChrBank1, 0, 0); - this.tableLayoutPanel2.Controls.Add(this.picChrBank2, 0, 1); - this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3); - this.tableLayoutPanel2.Name = "tableLayoutPanel2"; - this.tableLayoutPanel2.RowCount = 2; - this.tableLayoutPanel3.SetRowSpan(this.tableLayoutPanel2, 2); - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(260, 520); - this.tableLayoutPanel2.TabIndex = 7; - // - // picChrBank1 - // - this.picChrBank1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.picChrBank1.ContextMenuStrip = this.ctxMenu; - this.picChrBank1.Cursor = System.Windows.Forms.Cursors.Hand; - this.picChrBank1.Location = new System.Drawing.Point(1, 1); - this.picChrBank1.Margin = new System.Windows.Forms.Padding(1); - this.picChrBank1.Name = "picChrBank1"; - this.picChrBank1.Size = new System.Drawing.Size(258, 258); - this.picChrBank1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.picChrBank1.TabIndex = 0; - this.picChrBank1.TabStop = false; - this.picChrBank1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picChrBank_MouseDown); - this.picChrBank1.MouseEnter += new System.EventHandler(this.picChrBank_MouseEnter); - this.picChrBank1.MouseLeave += new System.EventHandler(this.picChrBank_MouseLeave); - this.picChrBank1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picChrBank_MouseMove); - // - // ctxMenu - // - this.ctxMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuEditInMemoryViewer, - this.toolStripMenuItem2, - this.mnuCopyHdPack, - this.toolStripMenuItem1, - this.mnuCopyToClipboard, - this.mnuExportToPng}); - this.ctxMenu.Name = "ctxMenu"; - this.ctxMenu.Size = new System.Drawing.Size(222, 104); - this.ctxMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ctxMenu_Opening); - // - // mnuEditInMemoryViewer - // - this.mnuEditInMemoryViewer.Image = global::Mesen.GUI.Properties.Resources.CheatCode; - this.mnuEditInMemoryViewer.Name = "mnuEditInMemoryViewer"; - this.mnuEditInMemoryViewer.Size = new System.Drawing.Size(221, 22); - this.mnuEditInMemoryViewer.Text = "Edit in Memory Viewer"; - this.mnuEditInMemoryViewer.Click += new System.EventHandler(this.mnuEditInMemoryViewer_Click); - // - // toolStripMenuItem2 - // - this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(218, 6); - // - // mnuCopyHdPack - // - this.mnuCopyHdPack.Name = "mnuCopyHdPack"; - this.mnuCopyHdPack.Size = new System.Drawing.Size(221, 22); - this.mnuCopyHdPack.Text = "Copy Tile (HD Pack Format)"; - this.mnuCopyHdPack.Click += new System.EventHandler(this.mnuCopyHdPack_Click); - // - // toolStripMenuItem1 - // - this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(218, 6); - // - // mnuCopyToClipboard - // - this.mnuCopyToClipboard.Image = global::Mesen.GUI.Properties.Resources.Copy; - this.mnuCopyToClipboard.Name = "mnuCopyToClipboard"; - this.mnuCopyToClipboard.Size = new System.Drawing.Size(221, 22); - this.mnuCopyToClipboard.Text = "Copy image to clipboard"; - this.mnuCopyToClipboard.Click += new System.EventHandler(this.mnuCopyToClipboard_Click); - // - // mnuExportToPng - // - this.mnuExportToPng.Image = global::Mesen.GUI.Properties.Resources.Export; - this.mnuExportToPng.Name = "mnuExportToPng"; - this.mnuExportToPng.Size = new System.Drawing.Size(221, 22); - this.mnuExportToPng.Text = "Export image to PNG"; - this.mnuExportToPng.Click += new System.EventHandler(this.mnuExportToPng_Click); - // - // picChrBank2 - // - this.picChrBank2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.picChrBank2.ContextMenuStrip = this.ctxMenu; - this.picChrBank2.Cursor = System.Windows.Forms.Cursors.Hand; - this.picChrBank2.Location = new System.Drawing.Point(1, 261); - this.picChrBank2.Margin = new System.Windows.Forms.Padding(1); - this.picChrBank2.Name = "picChrBank2"; - this.picChrBank2.Size = new System.Drawing.Size(258, 258); - this.picChrBank2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.picChrBank2.TabIndex = 1; - this.picChrBank2.TabStop = false; - this.picChrBank2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picChrBank_MouseDown); - this.picChrBank2.MouseEnter += new System.EventHandler(this.picChrBank_MouseEnter); - this.picChrBank2.MouseLeave += new System.EventHandler(this.picChrBank_MouseLeave); - this.picChrBank2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picChrBank_MouseMove); - // // toolTip // this.toolTip.AutoPopDelay = 32700; @@ -548,10 +532,12 @@ namespace Mesen.GUI.Debugger.Controls // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.tableLayoutPanel3); + this.Controls.Add(this.tlpMain); this.Name = "ctrlChrViewer"; - this.Size = new System.Drawing.Size(534, 525); - this.tableLayoutPanel3.ResumeLayout(false); + this.Size = new System.Drawing.Size(701, 522); + this.tlpMain.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.picChrBank1)).EndInit(); + this.ctxMenu.ResumeLayout(false); this.grpDisplayOptions.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); @@ -562,24 +548,21 @@ namespace Mesen.GUI.Debugger.Controls this.flowLayoutPanel2.PerformLayout(); this.flpHighlight.ResumeLayout(false); this.flpHighlight.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picChrBank2)).EndInit(); this.grpTileInfo.ResumeLayout(false); this.tableLayoutPanel4.ResumeLayout(false); this.tableLayoutPanel4.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.picTile)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picColorTooltip)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picTileTooltip)).EndInit(); - this.tableLayoutPanel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.picChrBank1)).EndInit(); - this.ctxMenu.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.picChrBank2)).EndInit(); this.ResumeLayout(false); } #endregion - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; - private System.Windows.Forms.PictureBox picChrBank1; + private System.Windows.Forms.TableLayoutPanel tlpMain; + private ctrlMesenPictureBox picChrBank1; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.Label lblPalette; private System.Windows.Forms.ComboBox cboPalette; @@ -599,8 +582,7 @@ namespace Mesen.GUI.Debugger.Controls private System.Windows.Forms.Label label6; private System.Windows.Forms.TextBox txtTileIndex; private System.Windows.Forms.PictureBox picTile; - private System.Windows.Forms.PictureBox picChrBank2; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private ctrlMesenPictureBox picChrBank2; private System.Windows.Forms.GroupBox grpDisplayOptions; private System.Windows.Forms.Label label3; private System.Windows.Forms.PictureBox picColorTooltip; diff --git a/GUI.NET/Debugger/Controls/ctrlChrViewer.cs b/GUI.NET/Debugger/Controls/ctrlChrViewer.cs index ebff4710..a85eafdd 100644 --- a/GUI.NET/Debugger/Controls/ctrlChrViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlChrViewer.cs @@ -66,9 +66,19 @@ namespace Mesen.GUI.Debugger.Controls } } - public Size GetCompactSize() + public Size GetCompactSize(bool includeMargins) { - return new Size(picChrBank1.Width, picChrBank1.Height * 2 + picChrBank1.Margin.Bottom * 2); + int margins = includeMargins ? (picChrBank1.Margin.Bottom + picChrBank2.Margin.Top) : 0; + return new Size(picChrBank1.Width, picChrBank1.Height * 2 + margins); + } + + public void ScaleImage(double scale) + { + picChrBank1.Size = new Size((int)(picChrBank1.Width * scale), (int)(picChrBank1.Height * scale)); + picChrBank2.Size = new Size((int)(picChrBank2.Width * scale), (int)(picChrBank2.Height * scale)); + + picChrBank1.InterpolationMode = scale > 1 ? InterpolationMode.NearestNeighbor : InterpolationMode.Default; + picChrBank2.InterpolationMode = scale > 1 ? InterpolationMode.NearestNeighbor : InterpolationMode.Default; } protected override void OnLoad(EventArgs e) diff --git a/GUI.NET/Debugger/Controls/ctrlNametableViewer.Designer.cs b/GUI.NET/Debugger/Controls/ctrlNametableViewer.Designer.cs index 7f9edba1..61b24f67 100644 --- a/GUI.NET/Debugger/Controls/ctrlNametableViewer.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlNametableViewer.Designer.cs @@ -31,7 +31,7 @@ namespace Mesen.GUI.Debugger.Controls { this.components = new System.ComponentModel.Container(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.picNametable = new System.Windows.Forms.PictureBox(); + this.picNametable = new Mesen.GUI.Controls.ctrlMesenPictureBox(); this.ctxMenu = new Mesen.GUI.Controls.ctrlMesenContextMenuStrip(this.components); this.mnuAddBreakpoint = new System.Windows.Forms.ToolStripMenuItem(); this.mnuEditInMemoryViewer = new System.Windows.Forms.ToolStripMenuItem(); @@ -65,6 +65,7 @@ namespace Mesen.GUI.Debugger.Controls this.ctrlTilePalette = new Mesen.GUI.Debugger.Controls.ctrlTilePalette(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.chkShowPpuScrollOverlay = new System.Windows.Forms.CheckBox(); + this.chkShowAttributeColorsOnly = new System.Windows.Forms.CheckBox(); this.chkShowTileGrid = new System.Windows.Forms.CheckBox(); this.chkShowAttributeGrid = new System.Windows.Forms.CheckBox(); this.chkUseGrayscalePalette = new System.Windows.Forms.CheckBox(); @@ -76,7 +77,6 @@ namespace Mesen.GUI.Debugger.Controls this.chkHighlightAttributeUpdates = new System.Windows.Forms.CheckBox(); this.lblHighlight = new System.Windows.Forms.Label(); this.chkIgnoreRedundantWrites = new System.Windows.Forms.CheckBox(); - this.chkShowAttributeColorsOnly = new System.Windows.Forms.CheckBox(); this.tableLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picNametable)).BeginInit(); this.ctxMenu.SuspendLayout(); @@ -96,7 +96,6 @@ namespace Mesen.GUI.Debugger.Controls this.tableLayoutPanel1.Controls.Add(this.grpTileInfo, 1, 0); this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 1, 1); this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.chkIgnoreRedundantWrites, 0, 3); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; @@ -105,13 +104,14 @@ namespace Mesen.GUI.Debugger.Controls this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(697, 530); + this.tableLayoutPanel1.Size = new System.Drawing.Size(701, 530); this.tableLayoutPanel1.TabIndex = 2; // // picNametable // this.picNametable.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.picNametable.ContextMenuStrip = this.ctxMenu; + this.picNametable.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; this.picNametable.Location = new System.Drawing.Point(4, 4); this.picNametable.Margin = new System.Windows.Forms.Padding(4, 4, 4, 0); this.picNametable.Name = "picNametable"; @@ -208,11 +208,10 @@ namespace Mesen.GUI.Debugger.Controls // // grpTileInfo // - this.grpTileInfo.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.grpTileInfo.Controls.Add(this.tableLayoutPanel2); this.grpTileInfo.Location = new System.Drawing.Point(525, 3); this.grpTileInfo.Name = "grpTileInfo"; - this.grpTileInfo.Size = new System.Drawing.Size(169, 345); + this.grpTileInfo.Size = new System.Drawing.Size(173, 345); this.grpTileInfo.TabIndex = 4; this.grpTileInfo.TabStop = false; this.grpTileInfo.Text = "Tile Info"; @@ -259,7 +258,7 @@ namespace Mesen.GUI.Debugger.Controls this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); 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.Size = new System.Drawing.Size(163, 326); + this.tableLayoutPanel2.Size = new System.Drawing.Size(167, 326); this.tableLayoutPanel2.TabIndex = 0; // // txtPpuAddress @@ -447,15 +446,12 @@ namespace Mesen.GUI.Debugger.Controls // // flowLayoutPanel1 // - this.flowLayoutPanel1.AutoSize = true; - this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.flowLayoutPanel1.Controls.Add(this.chkShowPpuScrollOverlay); this.flowLayoutPanel1.Controls.Add(this.chkShowAttributeColorsOnly); this.flowLayoutPanel1.Controls.Add(this.chkShowTileGrid); this.flowLayoutPanel1.Controls.Add(this.chkShowAttributeGrid); this.flowLayoutPanel1.Controls.Add(this.chkUseGrayscalePalette); this.flowLayoutPanel1.Controls.Add(this.chkHighlightChrTile); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel1.Location = new System.Drawing.Point(522, 351); this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; @@ -474,6 +470,17 @@ namespace Mesen.GUI.Debugger.Controls this.chkShowPpuScrollOverlay.UseVisualStyleBackColor = true; this.chkShowPpuScrollOverlay.Click += new System.EventHandler(this.chkShowScrollWindow_Click); // + // chkShowAttributeColorsOnly + // + this.chkShowAttributeColorsOnly.AutoSize = true; + this.chkShowAttributeColorsOnly.Location = new System.Drawing.Point(3, 26); + this.chkShowAttributeColorsOnly.Name = "chkShowAttributeColorsOnly"; + this.chkShowAttributeColorsOnly.Size = new System.Drawing.Size(147, 17); + this.chkShowAttributeColorsOnly.TabIndex = 6; + this.chkShowAttributeColorsOnly.Text = "Show attribute colors only"; + this.chkShowAttributeColorsOnly.UseVisualStyleBackColor = true; + this.chkShowAttributeColorsOnly.Click += new System.EventHandler(this.chkShowAttributeColorsOnly_Click); + // // chkShowTileGrid // this.chkShowTileGrid.AutoSize = true; @@ -531,14 +538,15 @@ namespace Mesen.GUI.Debugger.Controls this.tableLayoutPanel3.Controls.Add(this.lblMirroringType, 1, 0); this.tableLayoutPanel3.Controls.Add(this.chkHighlightTileUpdates, 4, 0); this.tableLayoutPanel3.Controls.Add(this.chkHighlightAttributeUpdates, 5, 0); + this.tableLayoutPanel3.Controls.Add(this.chkIgnoreRedundantWrites, 4, 1); this.tableLayoutPanel3.Controls.Add(this.lblHighlight, 3, 0); - this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 486); this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel3.Name = "tableLayoutPanel3"; - this.tableLayoutPanel3.RowCount = 1; + this.tableLayoutPanel3.RowCount = 2; this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(522, 20); + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel3.Size = new System.Drawing.Size(522, 40); this.tableLayoutPanel3.TabIndex = 6; // // lblMirroring @@ -602,7 +610,8 @@ namespace Mesen.GUI.Debugger.Controls // this.chkIgnoreRedundantWrites.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.chkIgnoreRedundantWrites.AutoSize = true; - this.chkIgnoreRedundantWrites.Location = new System.Drawing.Point(332, 507); + this.tableLayoutPanel3.SetColumnSpan(this.chkIgnoreRedundantWrites, 2); + this.chkIgnoreRedundantWrites.Location = new System.Drawing.Point(332, 21); this.chkIgnoreRedundantWrites.Margin = new System.Windows.Forms.Padding(3, 1, 3, 0); this.chkIgnoreRedundantWrites.Name = "chkIgnoreRedundantWrites"; this.chkIgnoreRedundantWrites.Size = new System.Drawing.Size(187, 17); @@ -611,26 +620,14 @@ namespace Mesen.GUI.Debugger.Controls this.chkIgnoreRedundantWrites.UseVisualStyleBackColor = true; this.chkIgnoreRedundantWrites.Click += new System.EventHandler(this.chkIgnoreRedundantWrites_Click); // - // chkShowAttributeColorsOnly - // - this.chkShowAttributeColorsOnly.AutoSize = true; - this.chkShowAttributeColorsOnly.Location = new System.Drawing.Point(3, 26); - this.chkShowAttributeColorsOnly.Name = "chkShowAttributeColorsOnly"; - this.chkShowAttributeColorsOnly.Size = new System.Drawing.Size(147, 17); - this.chkShowAttributeColorsOnly.TabIndex = 6; - this.chkShowAttributeColorsOnly.Text = "Show attribute colors only"; - this.chkShowAttributeColorsOnly.UseVisualStyleBackColor = true; - this.chkShowAttributeColorsOnly.Click += new System.EventHandler(this.chkShowAttributeColorsOnly_Click); - // // ctrlNametableViewer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.tableLayoutPanel1); this.Name = "ctrlNametableViewer"; - this.Size = new System.Drawing.Size(697, 530); + this.Size = new System.Drawing.Size(701, 530); this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.picNametable)).EndInit(); this.ctxMenu.ResumeLayout(false); this.grpTileInfo.ResumeLayout(false); @@ -649,7 +646,7 @@ namespace Mesen.GUI.Debugger.Controls #endregion private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.PictureBox picNametable; + private ctrlMesenPictureBox picNametable; private System.Windows.Forms.GroupBox grpTileInfo; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; private System.Windows.Forms.TextBox txtPaletteAddress; diff --git a/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs b/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs index a6c77495..fd9bb125 100644 --- a/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs @@ -11,6 +11,7 @@ using System.Runtime.InteropServices; using Mesen.GUI.Config; using Mesen.GUI.Controls; using Mesen.GUI.Forms; +using System.Drawing.Drawing2D; namespace Mesen.GUI.Debugger.Controls { @@ -67,11 +68,17 @@ namespace Mesen.GUI.Debugger.Controls } } - public Size GetCompactSize() + public Size GetCompactSize(bool includeMargins) { return new Size(picNametable.Width, picNametable.Height); } + public void ScaleImage(double scale) + { + picNametable.Size = new Size((int)(picNametable.Width * scale), (int)(picNametable.Height * scale)); + picNametable.InterpolationMode = scale > 1 ? InterpolationMode.NearestNeighbor : InterpolationMode.Default; + } + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if(ctxMenu.ProcessCommandKey(ref msg, keyData)) { diff --git a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.Designer.cs b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.Designer.cs index 1a8b0d8e..ad9fca26 100644 --- a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.Designer.cs @@ -1,4 +1,6 @@ -namespace Mesen.GUI.Debugger.Controls +using Mesen.GUI.Controls; + +namespace Mesen.GUI.Debugger.Controls { partial class ctrlPaletteViewer { @@ -42,11 +44,11 @@ this.txtColorCodeRgb = new System.Windows.Forms.TextBox(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.lblPaletteSprites = new System.Windows.Forms.Label(); - this.picPaletteSprites = new System.Windows.Forms.PictureBox(); + this.picPaletteSprites = new Mesen.GUI.Controls.ctrlMesenPictureBox(); this.ctxMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.mnuCopyHexColor = new System.Windows.Forms.ToolStripMenuItem(); this.mnuCopyRgbColor = new System.Windows.Forms.ToolStripMenuItem(); - this.picPaletteBg = new System.Windows.Forms.PictureBox(); + this.picPaletteBg = new Mesen.GUI.Controls.ctrlMesenPictureBox(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.picHelp = new System.Windows.Forms.PictureBox(); this.lblClickColorHint = new System.Windows.Forms.Label(); @@ -65,11 +67,10 @@ // grpColorInfo // this.grpColorInfo.Controls.Add(this.tableLayoutPanel4); - this.grpColorInfo.Dock = System.Windows.Forms.DockStyle.Fill; this.grpColorInfo.Location = new System.Drawing.Point(273, 3); this.grpColorInfo.Name = "grpColorInfo"; this.tableLayoutPanel3.SetRowSpan(this.grpColorInfo, 3); - this.grpColorInfo.Size = new System.Drawing.Size(406, 305); + this.grpColorInfo.Size = new System.Drawing.Size(425, 205); this.grpColorInfo.TabIndex = 4; this.grpColorInfo.TabStop = false; this.grpColorInfo.Text = "Color Info"; @@ -89,7 +90,6 @@ this.tableLayoutPanel4.Controls.Add(this.label1, 0, 4); this.tableLayoutPanel4.Controls.Add(this.txtColorCodeHex, 1, 3); this.tableLayoutPanel4.Controls.Add(this.txtColorCodeRgb, 1, 4); - this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 16); this.tableLayoutPanel4.Name = "tableLayoutPanel4"; this.tableLayoutPanel4.RowCount = 6; @@ -99,7 +99,7 @@ this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel4.Size = new System.Drawing.Size(400, 286); + this.tableLayoutPanel4.Size = new System.Drawing.Size(382, 183); this.tableLayoutPanel4.TabIndex = 0; // // txtPaletteAddress @@ -217,7 +217,7 @@ this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(682, 311); + this.tableLayoutPanel3.Size = new System.Drawing.Size(701, 311); this.tableLayoutPanel3.TabIndex = 3; // // lblPaletteSprites @@ -236,6 +236,7 @@ this.picPaletteSprites.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.picPaletteSprites.ContextMenuStrip = this.ctxMenu; this.picPaletteSprites.Cursor = System.Windows.Forms.Cursors.Hand; + this.picPaletteSprites.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; this.picPaletteSprites.Location = new System.Drawing.Point(138, 4); this.picPaletteSprites.Margin = new System.Windows.Forms.Padding(2, 4, 2, 4); this.picPaletteSprites.Name = "picPaletteSprites"; @@ -272,6 +273,7 @@ this.picPaletteBg.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.picPaletteBg.ContextMenuStrip = this.ctxMenu; this.picPaletteBg.Cursor = System.Windows.Forms.Cursors.Hand; + this.picPaletteBg.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; this.picPaletteBg.Location = new System.Drawing.Point(4, 4); this.picPaletteBg.Margin = new System.Windows.Forms.Padding(4, 4, 2, 4); this.picPaletteBg.Name = "picPaletteBg"; @@ -284,12 +286,10 @@ // // flowLayoutPanel1 // - this.flowLayoutPanel1.AutoSize = true; this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.tableLayoutPanel3.SetColumnSpan(this.flowLayoutPanel1, 2); this.flowLayoutPanel1.Controls.Add(this.picHelp); this.flowLayoutPanel1.Controls.Add(this.lblClickColorHint); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top; this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 154); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Size = new System.Drawing.Size(264, 26); @@ -332,7 +332,7 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.tableLayoutPanel3); this.Name = "ctrlPaletteViewer"; - this.Size = new System.Drawing.Size(682, 311); + this.Size = new System.Drawing.Size(701, 311); this.grpColorInfo.ResumeLayout(false); this.tableLayoutPanel4.ResumeLayout(false); this.tableLayoutPanel4.PerformLayout(); @@ -351,7 +351,7 @@ #endregion - private System.Windows.Forms.PictureBox picPaletteBg; + private ctrlMesenPictureBox picPaletteBg; private System.Windows.Forms.GroupBox grpColorInfo; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4; private System.Windows.Forms.TextBox txtPaletteAddress; @@ -371,7 +371,7 @@ private System.Windows.Forms.ContextMenuStrip ctxMenu; private System.Windows.Forms.ToolStripMenuItem mnuCopyHexColor; private System.Windows.Forms.ToolStripMenuItem mnuCopyRgbColor; - private System.Windows.Forms.PictureBox picPaletteSprites; + private ctrlMesenPictureBox picPaletteSprites; private System.Windows.Forms.Label lblBgPalette; private System.Windows.Forms.Label lblPaletteSprites; } diff --git a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs index b45837bc..e8ca2313 100644 --- a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using System.Runtime.InteropServices; using Mesen.GUI.Controls; using Mesen.GUI.Forms; +using System.Drawing.Drawing2D; namespace Mesen.GUI.Debugger.Controls { @@ -24,9 +25,18 @@ namespace Mesen.GUI.Debugger.Controls InitializeComponent(); } - public Size GetCompactSize() + public Size GetCompactSize(bool includeMargins) { - return new Size(picPaletteBg.Width * 2 + picPaletteBg.Margin.Right * 2, picPaletteBg.Height); + int margins = includeMargins ? (picPaletteBg.Margin.Right + picPaletteSprites.Margin.Left) : 0; + return new Size(picPaletteBg.Width * 2 + margins, picPaletteBg.Height); + } + + public void ScaleImage(double scale) + { + picPaletteBg.Size = new Size((int)(picPaletteBg.Width * scale), (int)(picPaletteBg.Height * scale)); + picPaletteSprites.Size = new Size((int)(picPaletteSprites.Width * scale), (int)(picPaletteSprites.Height * scale)); + picPaletteBg.InterpolationMode = scale > 1 ? InterpolationMode.NearestNeighbor : InterpolationMode.Default; + picPaletteSprites.InterpolationMode = scale > 1 ? InterpolationMode.NearestNeighbor : InterpolationMode.Default; } public void GetData() @@ -80,8 +90,8 @@ namespace Mesen.GUI.Debugger.Controls private void picPalette_MouseMove(object sender, MouseEventArgs e) { - int tileX = Math.Max(0, Math.Min(e.X * 128 / (picPaletteBg.Width - 2) / 32, 31)); - int tileY = Math.Max(0, Math.Min(e.Y * 128 / (picPaletteBg.Height - 2) / 32, 31)); + int tileX = Math.Max(0, Math.Min(e.X * 128 / (picPaletteBg.Width - 2) / 32, 3)); + int tileY = Math.Max(0, Math.Min(e.Y * 128 / (picPaletteBg.Height - 2) / 32, 3)); int paletteIndex = tileY * 4 + tileX + (sender == picPaletteSprites ? 16 : 0); diff --git a/GUI.NET/Debugger/Controls/ctrlSpriteViewer.Designer.cs b/GUI.NET/Debugger/Controls/ctrlSpriteViewer.Designer.cs index 090fcf0a..1ec3f2c4 100644 --- a/GUI.NET/Debugger/Controls/ctrlSpriteViewer.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlSpriteViewer.Designer.cs @@ -36,7 +36,7 @@ namespace Mesen.GUI.Debugger.Controls this.lblPalette = new System.Windows.Forms.Label(); this.txtSpriteIndex = new System.Windows.Forms.TextBox(); this.lblSpriteIndex = new System.Windows.Forms.Label(); - this.picPreview = new System.Windows.Forms.PictureBox(); + this.picPreview = new Mesen.GUI.Controls.ctrlMesenPictureBox(); this.ctxMenu = new Mesen.GUI.Controls.ctrlMesenContextMenuStrip(this.components); this.mnuEditInMemoryViewer = new System.Windows.Forms.ToolStripMenuItem(); this.mnuShowInChrViewer = new System.Windows.Forms.ToolStripMenuItem(); @@ -63,7 +63,7 @@ namespace Mesen.GUI.Debugger.Controls this.lblTile = new System.Windows.Forms.Label(); this.picTile = new System.Windows.Forms.PictureBox(); this.chkDisplaySpriteOutlines = new System.Windows.Forms.CheckBox(); - this.picSprites = new System.Windows.Forms.PictureBox(); + this.picSprites = new Mesen.GUI.Controls.ctrlMesenPictureBox(); this.tlpMain.SuspendLayout(); this.grpSpriteInfo.SuspendLayout(); this.tlpInfo.SuspendLayout(); @@ -94,7 +94,7 @@ namespace Mesen.GUI.Debugger.Controls // grpSpriteInfo // this.grpSpriteInfo.Controls.Add(this.tlpInfo); - this.grpSpriteInfo.Dock = System.Windows.Forms.DockStyle.Fill; + this.grpSpriteInfo.Dock = System.Windows.Forms.DockStyle.Top; this.grpSpriteInfo.Location = new System.Drawing.Point(269, 3); this.grpSpriteInfo.Name = "grpSpriteInfo"; this.tlpMain.SetRowSpan(this.grpSpriteInfo, 2); @@ -179,7 +179,9 @@ namespace Mesen.GUI.Debugger.Controls this.picPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.tlpInfo.SetColumnSpan(this.picPreview, 4); this.picPreview.ContextMenuStrip = this.ctxMenu; - this.picPreview.Location = new System.Drawing.Point(75, 231); + this.picPreview.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; + this.picPreview.Location = new System.Drawing.Point(76, 232); + this.picPreview.Margin = new System.Windows.Forms.Padding(4); this.picPreview.Name = "picPreview"; this.picPreview.Size = new System.Drawing.Size(258, 242); this.picPreview.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -439,7 +441,7 @@ namespace Mesen.GUI.Debugger.Controls // this.chkDisplaySpriteOutlines.AutoSize = true; this.tlpInfo.SetColumnSpan(this.chkDisplaySpriteOutlines, 4); - this.chkDisplaySpriteOutlines.Location = new System.Drawing.Point(3, 479); + this.chkDisplaySpriteOutlines.Location = new System.Drawing.Point(3, 481); this.chkDisplaySpriteOutlines.Name = "chkDisplaySpriteOutlines"; this.chkDisplaySpriteOutlines.Size = new System.Drawing.Size(227, 17); this.chkDisplaySpriteOutlines.TabIndex = 27; @@ -451,6 +453,7 @@ namespace Mesen.GUI.Debugger.Controls // this.picSprites.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.picSprites.ContextMenuStrip = this.ctxMenu; + this.picSprites.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; this.picSprites.Location = new System.Drawing.Point(4, 4); this.picSprites.Margin = new System.Windows.Forms.Padding(4); this.picSprites.Name = "picSprites"; @@ -488,7 +491,7 @@ namespace Mesen.GUI.Debugger.Controls #endregion private System.Windows.Forms.TableLayoutPanel tlpMain; - private System.Windows.Forms.PictureBox picSprites; + private ctrlMesenPictureBox picSprites; private System.Windows.Forms.GroupBox grpSpriteInfo; private System.Windows.Forms.TableLayoutPanel tlpInfo; private System.Windows.Forms.TextBox txtTileAddress; @@ -504,7 +507,7 @@ namespace Mesen.GUI.Debugger.Controls private System.Windows.Forms.Label lblPaletteAddr; private System.Windows.Forms.Label lblPosition; private System.Windows.Forms.CheckBox chkBackgroundPriority; - private System.Windows.Forms.PictureBox picPreview; + private ctrlMesenPictureBox picPreview; private System.Windows.Forms.Label lblScreenPreview; private System.Windows.Forms.Label lblSpriteIndex; private System.Windows.Forms.TextBox txtSpriteIndex; diff --git a/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs b/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs index f7ba1495..96756413 100644 --- a/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs @@ -12,6 +12,7 @@ using Mesen.GUI.Controls; using System.Drawing.Imaging; using Mesen.GUI.Config; using Mesen.GUI.Forms; +using System.Drawing.Drawing2D; namespace Mesen.GUI.Debugger.Controls { @@ -39,23 +40,44 @@ namespace Mesen.GUI.Debugger.Controls private bool _firstDraw = true; private int _originalSpriteHeight = 0; private int _originalTileHeight = 0; + private Size _originalPreviewSize; + private double _scale = 1; public ctrlSpriteViewer() { InitializeComponent(); - picPreview.Image = new Bitmap(256, 240, PixelFormat.Format32bppArgb); - picSprites.Image = new Bitmap(256, 512, PixelFormat.Format32bppArgb); + if(!IsDesignMode) { + picPreview.Image = new Bitmap(256, 240, PixelFormat.Format32bppArgb); + picSprites.Image = new Bitmap(256, 512, PixelFormat.Format32bppArgb); - chkDisplaySpriteOutlines.Checked = ConfigManager.Config.DebugInfo.SpriteViewerDisplaySpriteOutlines; + chkDisplaySpriteOutlines.Checked = ConfigManager.Config.DebugInfo.SpriteViewerDisplaySpriteOutlines; - _originalSpriteHeight = picSprites.Height; - _originalTileHeight = picTile.Height; + _originalSpriteHeight = picSprites.Height; + _originalTileHeight = picTile.Height; + _originalPreviewSize = picPreview.Size; + } } - public Size GetCompactSize() + public Size GetCompactSize(bool includeMargins) { - return new Size(picSprites.Width, _prevLargeSprites ? picSprites.Height : (picSprites.Height + picPreview.Height + picPreview.Margin.Top + picSprites.Margin.Bottom)); + return new Size(picSprites.Width, _prevLargeSprites ? picSprites.Height : (picSprites.Height * 2)); + } + + public void ScaleImage(double scale) + { + _scale *= scale; + + picSprites.Size = new Size((int)(picSprites.Width * scale), (int)(picSprites.Height * scale)); + if(_largeSprites) { + picPreview.Size = _originalPreviewSize; + } else { + picPreview.Size = new Size((int)(_originalPreviewSize.Width * _scale), (int)(_originalPreviewSize.Height * _scale)); + } + _originalSpriteHeight = (int)(_originalSpriteHeight * scale); + + picSprites.InterpolationMode = scale > 1 ? InterpolationMode.NearestNeighbor : InterpolationMode.Default; + picPreview.InterpolationMode = scale > 1 ? InterpolationMode.NearestNeighbor : InterpolationMode.Default; } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) @@ -122,25 +144,7 @@ namespace Mesen.GUI.Debugger.Controls } if(_prevLargeSprites != _largeSprites) { - if(_largeSprites) { - picSprites.Image = new Bitmap(256, 512, PixelFormat.Format32bppArgb); - picSprites.Height = _originalSpriteHeight; - picTile.Height = _originalTileHeight; - - tlpMain.SetRowSpan(picSprites, 2); - tlpMain.SetColumnSpan(picPreview, 4); - tlpInfo.Controls.Add(picPreview, 1, 5); - lblScreenPreview.Visible = true; - } else { - picSprites.Image = new Bitmap(256, 256, PixelFormat.Format32bppArgb); - picSprites.Height = (_originalSpriteHeight - 2) / 2 + 2; - picTile.Height = (_originalTileHeight - 2) / 2 + 2; - - tlpMain.SetRowSpan(picSprites, 1); - tlpMain.SetColumnSpan(picPreview, 1); - tlpMain.Controls.Add(picPreview, 0, 1); - lblScreenPreview.Visible = false; - } + ToggleSpriteMode(); _prevLargeSprites = _largeSprites; } @@ -160,6 +164,31 @@ namespace Mesen.GUI.Debugger.Controls DrawHud(); } + private void ToggleSpriteMode() + { + if(_largeSprites) { + picSprites.Image = new Bitmap(256, 512, PixelFormat.Format32bppArgb); + picSprites.Height = _originalSpriteHeight; + picTile.Height = _originalTileHeight; + picPreview.Size = _originalPreviewSize; + + tlpMain.SetRowSpan(picSprites, 2); + tlpMain.SetColumnSpan(picPreview, 4); + tlpInfo.Controls.Add(picPreview, 1, 5); + lblScreenPreview.Visible = true; + } else { + picSprites.Image = new Bitmap(256, 256, PixelFormat.Format32bppArgb); + picSprites.Height = (_originalSpriteHeight - 2) / 2 + 2; + picTile.Height = (_originalTileHeight - 2) / 2 + 2; + picPreview.Size = new Size((int)(_originalPreviewSize.Width * _scale), (int)(_originalPreviewSize.Height * _scale)); + + tlpMain.SetRowSpan(picSprites, 1); + tlpMain.SetColumnSpan(picPreview, 1); + tlpMain.Controls.Add(picPreview, 0, 1); + lblScreenPreview.Visible = false; + } + } + private void DrawHud() { using(Graphics g = Graphics.FromImage(picSprites.Image)) { diff --git a/GUI.NET/Debugger/frmDbgPreferences.cs b/GUI.NET/Debugger/frmDbgPreferences.cs index 56a90740..a7ecd0bb 100644 --- a/GUI.NET/Debugger/frmDbgPreferences.cs +++ b/GUI.NET/Debugger/frmDbgPreferences.cs @@ -40,6 +40,7 @@ namespace Mesen.GUI.Debugger GetMember(nameof(DebuggerShortcutsConfig.CodeWindow_EditInMemoryViewer)), GetMember(nameof(DebuggerShortcutsConfig.MemoryViewer_ViewInDisassembly)), GetMember(nameof(DebuggerShortcutsConfig.PpuViewer_ToggleView)), + GetMember(nameof(DebuggerShortcutsConfig.PpuViewer_ToggleZoom)), GetMember(nameof(DebuggerShortcutsConfig.OpenApuViewer)), GetMember(nameof(DebuggerShortcutsConfig.OpenAssembler)), diff --git a/GUI.NET/Debugger/frmPpuViewer.Designer.cs b/GUI.NET/Debugger/frmPpuViewer.Designer.cs index d7f1326c..619665e7 100644 --- a/GUI.NET/Debugger/frmPpuViewer.Designer.cs +++ b/GUI.NET/Debugger/frmPpuViewer.Designer.cs @@ -33,7 +33,7 @@ namespace Mesen.GUI.Debugger /// private void InitializeComponent() { - this.menuStrip1 = new Mesen.GUI.Controls.ctrlMesenMenuStrip(); + this.menuStrip = new Mesen.GUI.Controls.ctrlMesenMenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mnuClose = new System.Windows.Forms.ToolStripMenuItem(); this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -45,6 +45,7 @@ namespace Mesen.GUI.Debugger this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.mnuAutoRefresh = new System.Windows.Forms.ToolStripMenuItem(); this.mnuRefreshOnBreak = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuShowInformationOverlay = new System.Windows.Forms.ToolStripMenuItem(); this.tabMain = new System.Windows.Forms.TabControl(); this.tpgNametableViewer = new System.Windows.Forms.TabPage(); this.ctrlNametableViewer = new Mesen.GUI.Debugger.Controls.ctrlNametableViewer(); @@ -56,8 +57,8 @@ namespace Mesen.GUI.Debugger this.ctrlPaletteViewer = new Mesen.GUI.Debugger.Controls.ctrlPaletteViewer(); this.ctrlScanlineCycle = new Mesen.GUI.Debugger.Controls.ctrlScanlineCycleSelect(); this.btnToggleView = new System.Windows.Forms.Button(); - this.mnuShowInformationOverlay = new System.Windows.Forms.ToolStripMenuItem(); - this.menuStrip1.SuspendLayout(); + this.chkToggleZoom = new System.Windows.Forms.CheckBox(); + this.menuStrip.SuspendLayout(); this.tabMain.SuspendLayout(); this.tpgNametableViewer.SuspendLayout(); this.tpgChrViewer.SuspendLayout(); @@ -65,16 +66,16 @@ namespace Mesen.GUI.Debugger this.tpgPaletteViewer.SuspendLayout(); this.SuspendLayout(); // - // menuStrip1 + // menuStrip // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem, this.viewToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(709, 24); - this.menuStrip1.TabIndex = 2; - this.menuStrip1.Text = "menuStrip1"; + this.menuStrip.Location = new System.Drawing.Point(0, 0); + this.menuStrip.Name = "menuStrip"; + this.menuStrip.Size = new System.Drawing.Size(709, 24); + this.menuStrip.TabIndex = 2; + this.menuStrip.Text = "menuStrip1"; // // fileToolStripMenuItem // @@ -168,6 +169,14 @@ namespace Mesen.GUI.Debugger this.mnuRefreshOnBreak.Text = "Refresh on pause/break"; this.mnuRefreshOnBreak.Click += new System.EventHandler(this.mnuRefreshOnBreak_Click); // + // mnuShowInformationOverlay + // + this.mnuShowInformationOverlay.CheckOnClick = true; + this.mnuShowInformationOverlay.Name = "mnuShowInformationOverlay"; + this.mnuShowInformationOverlay.Size = new System.Drawing.Size(210, 22); + this.mnuShowInformationOverlay.Text = "Show information overlay"; + this.mnuShowInformationOverlay.Click += new System.EventHandler(this.mnuShowInformationOverlay_Click); + // // tabMain // this.tabMain.Controls.Add(this.tpgNametableViewer); @@ -199,7 +208,6 @@ namespace Mesen.GUI.Debugger this.ctrlNametableViewer.Name = "ctrlNametableViewer"; this.ctrlNametableViewer.Size = new System.Drawing.Size(701, 527); this.ctrlNametableViewer.TabIndex = 0; - this.ctrlNametableViewer.OnSelectChrTile += this.ctrlNametableViewer_OnSelectChrTile; // // tpgChrViewer // @@ -275,30 +283,36 @@ namespace Mesen.GUI.Debugger this.btnToggleView.UseVisualStyleBackColor = true; this.btnToggleView.Click += new System.EventHandler(this.btnToggleView_Click); // - // mnuShowInformationOverlay + // chkToggleZoom // - this.mnuShowInformationOverlay.CheckOnClick = true; - this.mnuShowInformationOverlay.Name = "mnuShowInformationOverlay"; - this.mnuShowInformationOverlay.Size = new System.Drawing.Size(210, 22); - this.mnuShowInformationOverlay.Text = "Show information overlay"; - this.mnuShowInformationOverlay.Click += new System.EventHandler(this.mnuShowInformationOverlay_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(647, 1); + this.chkToggleZoom.Name = "chkToggleZoom"; + this.chkToggleZoom.Size = new System.Drawing.Size(27, 22); + this.chkToggleZoom.TabIndex = 6; + this.chkToggleZoom.UseVisualStyleBackColor = true; + this.chkToggleZoom.Click += new System.EventHandler(this.chkToggleZoom_Click); // // frmPpuViewer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(709, 605); + this.Controls.Add(this.chkToggleZoom); this.Controls.Add(this.btnToggleView); this.Controls.Add(this.tabMain); - this.Controls.Add(this.menuStrip1); + this.Controls.Add(this.menuStrip); this.Controls.Add(this.ctrlScanlineCycle); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MainMenuStrip = this.menuStrip1; + this.MainMenuStrip = this.menuStrip; this.MaximizeBox = false; this.Name = "frmPpuViewer"; this.Text = "PPU Viewer"; - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); this.tabMain.ResumeLayout(false); this.tpgNametableViewer.ResumeLayout(false); this.tpgChrViewer.ResumeLayout(false); @@ -311,7 +325,7 @@ namespace Mesen.GUI.Debugger #endregion - private Mesen.GUI.Controls.ctrlMesenMenuStrip menuStrip1; + private Mesen.GUI.Controls.ctrlMesenMenuStrip menuStrip; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem mnuClose; private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; @@ -335,5 +349,6 @@ namespace Mesen.GUI.Debugger private System.Windows.Forms.ToolStripMenuItem mnuAutoRefreshHigh; private System.Windows.Forms.Button btnToggleView; private System.Windows.Forms.ToolStripMenuItem mnuShowInformationOverlay; + private System.Windows.Forms.CheckBox chkToggleZoom; } } \ No newline at end of file diff --git a/GUI.NET/Debugger/frmPpuViewer.cs b/GUI.NET/Debugger/frmPpuViewer.cs index ab0dd195..bc54f5d3 100644 --- a/GUI.NET/Debugger/frmPpuViewer.cs +++ b/GUI.NET/Debugger/frmPpuViewer.cs @@ -14,7 +14,8 @@ namespace Mesen.GUI.Debugger private TabPage _selectedTab; private bool _refreshing = false; private Size _originalSize; - private bool _isCompact; + private bool _isCompact = false; + private bool _isZoomed = false; private PpuViewerMode _mode; private static int _nextPpuViewerId = 0; @@ -27,6 +28,11 @@ namespace Mesen.GUI.Debugger _ppuViewerId = GetNextPpuViewerId(); _mode = mode; + if(Program.IsMono) { + btnToggleView.Top -= 1; + chkToggleZoom.Top -= 1; + } + this._selectedTab = this.tpgNametableViewer; this.mnuAutoRefresh.Checked = ConfigManager.Config.DebugInfo.PpuAutoRefresh; this.mnuRefreshOnBreak.Checked = ConfigManager.Config.DebugInfo.PpuRefreshOnBreak; @@ -84,6 +90,12 @@ namespace Mesen.GUI.Debugger } 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); + _selectedTab = tabMain.SelectedTab; if(_mode != PpuViewerMode.Combined) { TabPage page = _selectedTab; @@ -209,16 +221,59 @@ namespace Mesen.GUI.Debugger private void tabMain_SelectedIndexChanged(object sender, EventArgs e) { + bool wasZoomedIn = _isZoomed; + if(wasZoomedIn) { + this.ToggleZoom(); + } + this._selectedTab = this.tabMain.SelectedTab; + + if(wasZoomedIn) { + this.ToggleZoom(); + } + if(InteropEmu.DebugIsExecutionStopped()) { //Refresh data when changing tabs when not running this.RefreshViewers(); } } + private void ToggleZoom() + { + ICompactControl ctrl = null; + if(_selectedTab == tpgChrViewer) { + ctrl = ctrlChrViewer; + } else if(_selectedTab == tpgPaletteViewer) { + ctrl = ctrlPaletteViewer; + } else if(_selectedTab == tpgSpriteViewer) { + ctrl = ctrlSpriteViewer; + } else if(_selectedTab == tpgNametableViewer) { + ctrl = ctrlNametableViewer; + } + + if(!_isZoomed) { + Size pictureSize = ctrl.GetCompactSize(false); + this.Size += pictureSize; + _originalSize += pictureSize; + ctrl.ScaleImage(2); + _isZoomed = true; + } else { + Size pictureSize = ctrl.GetCompactSize(false); + Size halfSize = new Size(pictureSize.Width / 2, pictureSize.Height / 2); + this.Size -= halfSize; + _originalSize -= halfSize; + ctrl.ScaleImage(0.5); + _isZoomed = false; + } + chkToggleZoom.Checked = _isZoomed; + } + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { - if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleView) { + if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleZoom) { + ToggleZoom(); + return true; + } else if(keyData == ConfigManager.Config.DebugInfo.Shortcuts.PpuViewer_ToggleView) { ToggleView(); return true; } @@ -323,7 +378,7 @@ namespace Mesen.GUI.Debugger _isCompact = true; _originalSize = this.Size; - Size size = control.GetCompactSize(); + Size size = control.GetCompactSize(true); int widthDiff = ((Control)control).Width - size.Width; int heightDiff = ((Control)control).Height - size.Height; @@ -365,6 +420,11 @@ namespace Mesen.GUI.Debugger { ToggleView(); } + + private void chkToggleZoom_Click(object sender, EventArgs e) + { + ToggleZoom(); + } } public enum PpuViewerMode @@ -378,6 +438,7 @@ namespace Mesen.GUI.Debugger public interface ICompactControl { - Size GetCompactSize(); + Size GetCompactSize(bool includeMargins); + void ScaleImage(double scale); } } diff --git a/GUI.NET/Debugger/frmPpuViewer.resx b/GUI.NET/Debugger/frmPpuViewer.resx index e83821e0..d9e4e523 100644 --- a/GUI.NET/Debugger/frmPpuViewer.resx +++ b/GUI.NET/Debugger/frmPpuViewer.resx @@ -120,7 +120,7 @@ 17, 17 - + 107, 17 \ No newline at end of file diff --git a/GUI.NET/GUI.NET.csproj b/GUI.NET/GUI.NET.csproj index 645f4d77..60cf8ab8 100644 --- a/GUI.NET/GUI.NET.csproj +++ b/GUI.NET/GUI.NET.csproj @@ -285,6 +285,9 @@ Component + + Component + Component @@ -1257,6 +1260,7 @@ + diff --git a/GUI.NET/Properties/Resources.Designer.cs b/GUI.NET/Properties/Resources.Designer.cs index 119dfcdd..a0285021 100644 --- a/GUI.NET/Properties/Resources.Designer.cs +++ b/GUI.NET/Properties/Resources.Designer.cs @@ -1129,5 +1129,15 @@ namespace Mesen.GUI.Properties { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Zoom2x { + get { + object obj = ResourceManager.GetObject("Zoom2x", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/GUI.NET/Properties/Resources.resx b/GUI.NET/Properties/Resources.resx index 662ac3b1..fc4a76ed 100644 --- a/GUI.NET/Properties/Resources.resx +++ b/GUI.NET/Properties/Resources.resx @@ -439,4 +439,7 @@ ..\Resources\Expand.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Zoom2x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/GUI.NET/Resources/Zoom2x.png b/GUI.NET/Resources/Zoom2x.png new file mode 100644 index 0000000000000000000000000000000000000000..6efb699843afe748add120f6c250c80963f2ca0d GIT binary patch literal 401 zcmV;C0dD?@P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02y>eSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E-^XO*0N*(0099>L_t(IPo>hYP6I&@$MLZh6*Vn_7eF)@ zQbS1UN`k=k1)6Fepx6cs3V}jY73%655)6`%zClyf1XY0nfjYjkorSq(36x&)x%=(R z+$Q%&@;u*4vbc%wAX3Hw_WZzaRwt1QXo#LsTOUqYokTv6S)P v|3n9`sMrl9EYJ_@xYK_ni