diff --git a/GUI.NET/Debugger/Controls/ctrlHexViewer.Designer.cs b/GUI.NET/Debugger/Controls/ctrlHexViewer.Designer.cs index 8d450805..f33c9780 100644 --- a/GUI.NET/Debugger/Controls/ctrlHexViewer.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlHexViewer.Designer.cs @@ -28,7 +28,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.tlpMain = new System.Windows.Forms.TableLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.lblNumberOfColumns = new System.Windows.Forms.Label(); this.cboNumberColumns = new System.Windows.Forms.ComboBox(); @@ -44,7 +44,7 @@ this.chkMatchCase = new System.Windows.Forms.CheckBox(); this.ctrlHexBox = new Be.Windows.Forms.HexBox(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); - this.tableLayoutPanel1.SuspendLayout(); + this.tlpMain.SuspendLayout(); this.flowLayoutPanel1.SuspendLayout(); this.panelSearch.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); @@ -54,22 +54,22 @@ this.flowLayoutPanel2.SuspendLayout(); this.SuspendLayout(); // - // tableLayoutPanel1 + // tlpMain // - this.tableLayoutPanel1.ColumnCount = 1; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.panelSearch, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.ctrlHexBox, 0, 1); - this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 3; - 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.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.Size = new System.Drawing.Size(543, 309); - this.tableLayoutPanel1.TabIndex = 0; + this.tlpMain.ColumnCount = 1; + this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tlpMain.Controls.Add(this.flowLayoutPanel1, 0, 0); + this.tlpMain.Controls.Add(this.panelSearch, 0, 2); + this.tlpMain.Controls.Add(this.ctrlHexBox, 0, 1); + this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.tlpMain.Location = new System.Drawing.Point(0, 0); + this.tlpMain.Name = "tlpMain"; + this.tlpMain.RowCount = 3; + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tlpMain.Size = new System.Drawing.Size(543, 309); + this.tlpMain.TabIndex = 0; // // flowLayoutPanel1 // @@ -262,11 +262,11 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.tableLayoutPanel1); + this.Controls.Add(this.tlpMain); this.Name = "ctrlHexViewer"; this.Size = new System.Drawing.Size(543, 309); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); + this.tlpMain.ResumeLayout(false); + this.tlpMain.PerformLayout(); this.flowLayoutPanel1.ResumeLayout(false); this.flowLayoutPanel1.PerformLayout(); this.panelSearch.ResumeLayout(false); @@ -283,7 +283,7 @@ #endregion - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.TableLayoutPanel tlpMain; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.Label lblNumberOfColumns; private System.Windows.Forms.ComboBox cboNumberColumns; diff --git a/GUI.NET/Debugger/Controls/ctrlHexViewer.cs b/GUI.NET/Debugger/Controls/ctrlHexViewer.cs index 05929f19..d0fa3bb2 100644 --- a/GUI.NET/Debugger/Controls/ctrlHexViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlHexViewer.cs @@ -143,6 +143,12 @@ namespace Mesen.GUI.Debugger.Controls bool focus = !this.panelSearch.Visible; this.panelSearch.Visible = true; + + if(Program.IsMono) { + //Mono doesn't resize the TLP properly for some reason when set to autosize + this.tlpMain.RowStyles[2].SizeType = System.Windows.Forms.SizeType.Absolute; + this.tlpMain.RowStyles[2].Height = 30; + } if(focus || forceFocus) { this.cboSearch.Focus(); this.cboSearch.SelectAll(); @@ -152,6 +158,11 @@ namespace Mesen.GUI.Debugger.Controls private void CloseSearchBox() { this.panelSearch.Visible = false; + if(Program.IsMono) { + //Mono doesn't resize the TLP properly for some reason when set to autosize + this.tlpMain.RowStyles[2].SizeType = System.Windows.Forms.SizeType.Absolute; + this.tlpMain.RowStyles[2].Height = 0; + } this.Focus(); } diff --git a/GUI.NET/Debugger/Controls/ctrlNametableViewer.Designer.cs b/GUI.NET/Debugger/Controls/ctrlNametableViewer.Designer.cs index 947f4b7c..1cc68c02 100644 --- a/GUI.NET/Debugger/Controls/ctrlNametableViewer.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlNametableViewer.Designer.cs @@ -96,7 +96,7 @@ this.grpTileInfo.Controls.Add(this.tableLayoutPanel2); this.grpTileInfo.Location = new System.Drawing.Point(519, 3); this.grpTileInfo.Name = "grpTileInfo"; - this.grpTileInfo.Size = new System.Drawing.Size(175, 301); + this.grpTileInfo.Size = new System.Drawing.Size(175, 330); this.grpTileInfo.TabIndex = 4; this.grpTileInfo.TabStop = false; this.grpTileInfo.Text = "Tile Info"; diff --git a/GUI.NET/Debugger/Controls/ctrlScrollableTextbox.cs b/GUI.NET/Debugger/Controls/ctrlScrollableTextbox.cs index f0885436..455b17cb 100644 --- a/GUI.NET/Debugger/Controls/ctrlScrollableTextbox.cs +++ b/GUI.NET/Debugger/Controls/ctrlScrollableTextbox.cs @@ -51,6 +51,11 @@ namespace Mesen.GUI.Debugger { InitializeComponent(); + if(Program.IsMono) { + this.panelSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left))); + this.panelSearch.Location = new System.Drawing.Point(this.Width - this.panelSearch.Width - 20, -1); + } + this.ctrlTextbox.ShowLineNumbers = true; this.ctrlTextbox.ShowLineInHex = true; this.ctrlTextbox.Font = new System.Drawing.Font(BaseControl.MonospaceFontFamily, 13F); @@ -64,6 +69,14 @@ namespace Mesen.GUI.Debugger new ToolTip().SetToolTip(picSearchPrevious, "Find Previous (Shift-F3)"); } + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + if(Program.IsMono) { + this.panelSearch.Location = new System.Drawing.Point(this.Width - this.panelSearch.Width - 20, -1); + } + } + public float FontSize { get { return this.ctrlTextbox.Font.SizeInPoints; } diff --git a/GUI.NET/Debugger/Controls/ctrlTextbox.cs b/GUI.NET/Debugger/Controls/ctrlTextbox.cs index 2b943210..948595c0 100644 --- a/GUI.NET/Debugger/Controls/ctrlTextbox.cs +++ b/GUI.NET/Debugger/Controls/ctrlTextbox.cs @@ -302,6 +302,7 @@ namespace Mesen.GUI.Debugger string line = _contents[i].ToLowerInvariant(); if(line.Contains(this._searchString)) { this.ScrollToLineIndex(i); + this.Invalidate(); return true; } @@ -407,7 +408,7 @@ namespace Mesen.GUI.Debugger private int GetMargin(Graphics g, bool getExtendedMargin) { int marginWidth = getExtendedMargin && this.ShowContentNotes && this.ShowSingleContentLineNotes ? _marginWidth + _extendedMarginWidth : _marginWidth; - return (this.ShowLineNumbers ? (int)(g.MeasureString("".PadLeft(marginWidth, 'W'), this.Font).Width) : 0) - 1; + return (this.ShowLineNumbers ? (int)(g.MeasureString("".PadLeft(marginWidth, 'W'), this.Font, int.MaxValue, StringFormat.GenericTypographic).Width) : 0) - 1; } public int GetLineIndexAtPosition(int yPos) @@ -445,7 +446,7 @@ namespace Mesen.GUI.Debugger int previousWidth = 0; for(int i = 0, len = text.Length; i < len; i++) { - int width = (int)g.MeasureString(text.Substring(0, i+1), this.Font).Width; + int width = (int)g.MeasureString(text.Substring(0, i+1), this.Font, int.MaxValue, StringFormat.GenericTypographic).Width; if(width >= positionX && previousWidth <= positionX) { charIndex = i; return true; @@ -642,7 +643,7 @@ namespace Mesen.GUI.Debugger { if(_contents.Length > _maxLineWidthIndex) { using(Graphics g = this.CreateGraphics()) { - _maxLineWidth = (LineIndentations != null ? LineIndentations[_maxLineWidthIndex] : 0) + g.MeasureString(GetFullWidthString(_maxLineWidthIndex), this.Font).Width; + _maxLineWidth = (LineIndentations != null ? LineIndentations[_maxLineWidthIndex] : 0) + g.MeasureString(GetFullWidthString(_maxLineWidthIndex), this.Font, int.MaxValue, StringFormat.GenericTypographic).Width; HorizontalScrollWidth = (int)(Math.Max(0, HorizontalScrollFactor + _maxLineWidth - (this.Width - GetMargin(g, true))) / HorizontalScrollFactor); } } @@ -780,8 +781,8 @@ namespace Mesen.GUI.Debugger string addressString = this.Addressing?[currentLine]; string commentString = this.Comments?[currentLine]; - float codeStringLength = g.MeasureString(codeString, this.Font).Width; - float addressStringLength = g.MeasureString(addressString, this.Font).Width; + float codeStringLength = g.MeasureString(codeString, this.Font, int.MaxValue, StringFormat.GenericTypographic).Width; + float addressStringLength = g.MeasureString(addressString, this.Font, int.MaxValue, StringFormat.GenericTypographic).Width; if(currentLine >= this.SelectionStart && currentLine <= this.SelectionStart + this.SelectionLength) { //Highlight current line @@ -828,18 +829,18 @@ namespace Mesen.GUI.Debugger } else { lineNumber = _lineNumberNotes[currentLine]; } - float width = g.MeasureString(lineNumber, this.Font).Width; - g.DrawString(lineNumber, this.Font, Brushes.Gray, marginLeft - width, positionY); + float width = g.MeasureString(lineNumber, this.Font, int.MaxValue, StringFormat.GenericTypographic).Width; + g.DrawString(lineNumber, this.Font, Brushes.Gray, marginLeft - width, positionY, StringFormat.GenericTypographic); } else { //Display line number string lineNumber = _lineNumbers[currentLine] >= 0 ? _lineNumbers[currentLine].ToString(_showLineInHex ? "X4" : "") : ".."; - float width = g.MeasureString(lineNumber, this.Font).Width; - g.DrawString(lineNumber, this.Font, Brushes.Gray, marginLeft - width, positionY); + float width = g.MeasureString(lineNumber, this.Font, int.MaxValue, StringFormat.GenericTypographic).Width; + g.DrawString(lineNumber, this.Font, Brushes.Gray, marginLeft - width, positionY, StringFormat.GenericTypographic); if(this.ShowLineNumberNotes && !this.ShowSingleLineLineNumberNotes) { //Display line note below line number - width = g.MeasureString(_lineNumberNotes[currentLine], _noteFont).Width; - g.DrawString(_lineNumberNotes[currentLine], _noteFont, Brushes.Gray, marginLeft - width, positionY+this.Font.Size+3); + width = g.MeasureString(_lineNumberNotes[currentLine], _noteFont, int.MaxValue, StringFormat.GenericTypographic).Width; + g.DrawString(_lineNumberNotes[currentLine], _noteFont, Brushes.Gray, marginLeft - width, positionY+this.Font.Size+3, StringFormat.GenericTypographic); } } } @@ -851,25 +852,25 @@ namespace Mesen.GUI.Debugger //Draw block start g.TranslateTransform(HorizontalScrollPosition * HorizontalScrollFactor, 0); string text = codeString.Substring(2, codeString.Length - 4); - float textLength = g.MeasureString(text, this._noteFont).Width; - g.DrawString(text, this._noteFont, fgBrush, (marginLeft + this.Width - textLength) / 2, positionY); + float textLength = g.MeasureString(text, this._noteFont, int.MaxValue, StringFormat.GenericTypographic).Width; + g.DrawString(text, this._noteFont, fgBrush, (marginLeft + this.Width - textLength) / 2, positionY, StringFormat.GenericTypographic); g.DrawLine(Pens.Black, marginLeft, positionY+lineHeight-2, marginLeft+this.Width, positionY+lineHeight-2); g.TranslateTransform(-HorizontalScrollPosition * HorizontalScrollFactor, 0); } else if(codeString.StartsWith("__") && codeString.EndsWith("__")) { //Draw block end g.TranslateTransform(HorizontalScrollPosition * HorizontalScrollFactor, 0); string text = codeString.Substring(2, codeString.Length - 4); - float textLength = g.MeasureString(text, this._noteFont).Width; - g.DrawString(text, this._noteFont, fgBrush, (marginLeft + this.Width - textLength) / 2, positionY + 4); + float textLength = g.MeasureString(text, this._noteFont, int.MaxValue, StringFormat.GenericTypographic).Width; + g.DrawString(text, this._noteFont, fgBrush, (marginLeft + this.Width - textLength) / 2, positionY + 4, StringFormat.GenericTypographic); g.DrawLine(Pens.Black, marginLeft, positionY+2, marginLeft+this.Width, positionY+2); g.TranslateTransform(-HorizontalScrollPosition * HorizontalScrollFactor, 0); } else { //Draw line content - g.DrawString(codeString, this.Font, fgBrush, marginLeft, positionY); + g.DrawString(codeString, this.Font, fgBrush, marginLeft, positionY, StringFormat.GenericTypographic); if(!string.IsNullOrWhiteSpace(addressString)) { using(Brush addressBrush = new SolidBrush(Color.SteelBlue)) { - g.DrawString(addressString, this.Font, addressBrush, marginLeft + codeStringLength - 4, positionY); + g.DrawString(addressString, this.Font, addressBrush, marginLeft + codeStringLength, positionY, StringFormat.GenericTypographic); } } @@ -880,12 +881,12 @@ namespace Mesen.GUI.Debugger //Draw comment left-aligned, next to the margin when there is no code on the line padding = 0; } - g.DrawString(commentString.PadLeft(padding+commentString.Length), this.Font, commentBrush, marginLeft, positionY); + g.DrawString(commentString.PadLeft(padding+commentString.Length), this.Font, commentBrush, marginLeft, positionY, StringFormat.GenericTypographic); } } if(this.ShowContentNotes && !this.ShowSingleContentLineNotes) { - g.DrawString(_contentNotes[currentLine], _noteFont, Brushes.Gray, marginLeft, positionY + this.Font.Size+3); + g.DrawString(_contentNotes[currentLine], _noteFont, Brushes.Gray, marginLeft, positionY + this.Font.Size+3, StringFormat.GenericTypographic); } this.DrawHighlightedSearchString(g, codeString, marginLeft, positionY); this.DrawHighlightedCompareString(g, codeString, currentLine, marginLeft, positionY); @@ -946,7 +947,7 @@ namespace Mesen.GUI.Debugger } } - g.DrawString(sb.ToString(), new Font(this.Font, FontStyle.Bold), Brushes.Red, marginLeft, positionY); + g.DrawString(sb.ToString(), new Font(this.Font, FontStyle.Bold), Brushes.Red, marginLeft, positionY, StringFormat.GenericTypographic); } } } @@ -956,29 +957,27 @@ namespace Mesen.GUI.Debugger int searchIndex; if(!string.IsNullOrWhiteSpace(this._searchString) && (searchIndex = lineText.ToLowerInvariant().IndexOf(this._searchString)) >= 0) { //Draw colored search string - int previousSearchIndex = -this._searchString.Length; string lowerCaseText = lineText.ToLowerInvariant(); - StringBuilder sb = new StringBuilder(); - StringBuilder sbBackground = new StringBuilder(); - do { - sb.Append(string.Empty.PadLeft(searchIndex - previousSearchIndex - this._searchString.Length)); - sbBackground.Append(string.Empty.PadLeft(searchIndex - previousSearchIndex - this._searchString.Length)); - - sb.Append(lineText.Substring(searchIndex, this._searchString.Length)); - sbBackground.Append(string.Empty.PadLeft(this._searchString.Length, '█')); - previousSearchIndex = searchIndex; - searchIndex = lowerCaseText.IndexOf(this._searchString, searchIndex + this._searchString.Length); - } while(searchIndex >= 0); + Action draw = (bool forBackground) => { + int index = searchIndex; + do { + string padding = string.Empty.PadLeft(index, 'A'); + string highlightedText = lineText.Substring(index, this._searchString.Length); + index = lowerCaseText.IndexOf(this._searchString, index + this._searchString.Length); - string drawSearchString = sb.ToString(); - string drawSearchStringBg = sbBackground.ToString(); + SizeF size = g.MeasureString(highlightedText, this.Font, int.MaxValue, StringFormat.GenericTypographic); + SizeF offsetSize = g.MeasureString(padding, this.Font, int.MaxValue, StringFormat.GenericTypographic); + if(forBackground) { + g.FillRectangle(Brushes.CornflowerBlue, marginLeft + offsetSize.Width, positionY + 1, size.Width + 1, size.Height - 2); + } else { + g.DrawString(highlightedText, this.Font, Brushes.White, marginLeft + offsetSize.Width + 1, positionY, StringFormat.GenericTypographic); + } + } while(index >= 0); + }; - using(Brush selBrush = new SolidBrush(Color.White), selBgBrush = new SolidBrush(Color.CornflowerBlue)) { - g.DrawString(drawSearchStringBg, this.Font, selBgBrush, marginLeft-1, positionY); - g.DrawString(drawSearchStringBg, this.Font, selBgBrush, marginLeft+1, positionY); - g.DrawString(drawSearchString, this.Font, selBrush, marginLeft, positionY); - } + draw(true); + draw(false); } } @@ -989,7 +988,7 @@ namespace Mesen.GUI.Debugger this.DrawLineNumber(g, currentLine, regularMargin, positionY); } if(this.ShowContentNotes && this.ShowSingleContentLineNotes) { - g.DrawString(_contentNotes[currentLine], this.Font, Brushes.Gray, regularMargin + 6, positionY); + g.DrawString(_contentNotes[currentLine], this.Font, Brushes.Gray, regularMargin + 6, positionY, StringFormat.GenericTypographic); } //Adjust background color highlights based on number of spaces in front of content @@ -1004,6 +1003,7 @@ namespace Mesen.GUI.Debugger protected override void OnPaint(PaintEventArgs pe) { int lineHeight = this.LineHeight; + pe.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; pe.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; Rectangle rect = this.ClientRectangle; pe.Graphics.FillRectangle(Brushes.White, rect); diff --git a/GUI.NET/Debugger/frmDebugger.cs b/GUI.NET/Debugger/frmDebugger.cs index db11b22d..d8e762a7 100644 --- a/GUI.NET/Debugger/frmDebugger.cs +++ b/GUI.NET/Debugger/frmDebugger.cs @@ -35,6 +35,11 @@ namespace Mesen.GUI.Debugger protected override void OnLoad(EventArgs e) { base.OnLoad(e); + + if(Program.IsMono) { + //This doesn't work in Mono (menu is blank) - hide it for now + mnuCode.Visible = false; + } ctrlConsoleStatus.OnStateChanged += ctrlConsoleStatus_OnStateChanged; LabelManager.OnLabelUpdated += LabelManager_OnLabelUpdated;