TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.19k stars 384 forks source link

Hex Editor Display issues on linux #3925

Open BigOlMate opened 5 months ago

BigOlMate commented 5 months ago

Summary

Issues:

  1. Hex Editor container is too thin to display the entire hex editor.
  2. The selection overlay for selected bytes is too tall, meaning that multi-line selections especially are quite buggy looking.

Occurs on all cores I've tried, on stable and master

Repro

  1. load any core
  2. load any rom
  3. open the hex editor

Host env.

bizhawk_hexeditor_issues

BigOlMate commented 5 months ago

I have a local fix but I'm having issues with my SSH keys for this acc. Here's my diff. My only guess is this is some DPI/font issue.

My thought is if this code is DPI dependent, then that could change the meaningful value of both the MaximumSize and the MAGIC_FIX_NUMBER_H

I also figure that changing the maximum width of the hex editor to be very large is pretty safe. And that the MAGIC_FIX_NUMBER_H seems to be just the line height which we can calculate same as the glyph padding where font width is set.

diff --git a/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.Designer.cs b/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.Designer.cs
index cad33f5aa..3ae7b8c1a 100644
--- a/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.Designer.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.Designer.cs
@@ -417,7 +417,7 @@ namespace BizHawk.Client.EmuHawk
                        this.MemoryViewerBox.Controls.Add(this.AddressesLabel);
                        this.MemoryViewerBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        this.MemoryViewerBox.Location = new System.Drawing.Point(12, 27);
-                       this.MemoryViewerBox.MaximumSize = new System.Drawing.Size(600, 1024);
+                       this.MemoryViewerBox.MaximumSize = new System.Drawing.Size(1920, 1024);^M
                        this.MemoryViewerBox.MinimumSize = new System.Drawing.Size(260, 180);
                        this.MemoryViewerBox.Name = "MemoryViewerBox";
                        this.MemoryViewerBox.Size = new System.Drawing.Size(560, 262);
@@ -552,4 +552,4 @@ namespace BizHawk.Client.EmuHawk
                private BizHawk.WinForms.Controls.ToolStripMenuItemEx ExportMenuItem;
                private BizHawk.WinForms.Controls.ToolStripMenuItemEx importAsBinaryToolStripMenuItem;
        }
-}
\ No newline at end of file
+}^M
diff --git a/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs
index df99162fc..f9a92a8a0 100644
--- a/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs
@@ -169,10 +169,9 @@ namespace BizHawk.Client.EmuHawk
                        // character so we'll see how much the width increases on the second character.
                        var fontSize1 = TextRenderer.MeasureText("0", font);
                        var fontSize2 = TextRenderer.MeasureText("00", font);
+                       var fontSize3 = TextRenderer.MeasureText("0\n0", font);^M
                        _fontWidth = fontSize2.Width - fontSize1.Width;
-                       _fontHeight = fontSize1.Height;
-                       const int MAGIC_FIX_NUMBER_H = 4; // don't wanna know
-                       if (OSTailoredCode.IsUnixHost) _fontHeight -= MAGIC_FIX_NUMBER_H;
+                       _fontHeight = fontSize3.Height - fontSize1.Height;^M

                        InitializeComponent();
                        Icon = ToolIcon;
YoshiRulz commented 5 months ago

CNR. The GroupBox is meant to resize itself with the window up to a max. which is generously sized. And the selection box has been tweaked for Mono edit: as you've found. I wouldn't be surprised if it was a display scaling issue. screencap

BigOlMate commented 5 months ago

Fwiw here's a side-by-side with my diff applied on the right. emuhawk_issues

I only just noticed but on the broken one, the container is scaled with the window, just it's done so incorrectly. So this must be a scaling issue.

Edit:

Tried changing DPI, no dice.

I'm not really familiar with C# especially winforms stuff, so forgive my ignorance if not; but could we dynamically resize the GroupBox based off the fontWidth * <characters in the hexview + ascii view>?

YoshiRulz commented 3 months ago

Could you try this?

-const int MAGIC_FIX_NUMBER_H = 4;
+var MAGIC_FIX_NUMBER_H = UIHelper.ScaleY(4);