Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hex Editor Display issues on linux #3925

Open
BigOlMate opened this issue May 20, 2024 · 3 comments
Open

Hex Editor Display issues on linux #3925

BigOlMate opened this issue May 20, 2024 · 3 comments
Labels
re: Multiplatform Relating to the Linux and macOS ports (Mono Framework, and eventually .NET Core) Repro: Affects 2.9.1 Repro: Could not reproduce The reporter hasn't given enough info, or the fix was made and not recorded Tool: Hex Editor

Comments

@BigOlMate
Copy link

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 2.9.1; Archlinux; Intel/NVIDIA
  • BizHawk dev build at 8aac335; Archlinux; Intel/NVIDIA

bizhawk_hexeditor_issues

@YoshiRulz YoshiRulz added re: Multiplatform Relating to the Linux and macOS ports (Mono Framework, and eventually .NET Core) Tool: Hex Editor Repro: Affects 2.9.1 Repro: Could not reproduce The reporter hasn't given enough info, or the fix was made and not recorded labels May 20, 2024
@BigOlMate
Copy link
Author

BigOlMate commented May 20, 2024

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
Copy link
Member

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
Copy link
Author

BigOlMate commented May 20, 2024

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>?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: Multiplatform Relating to the Linux and macOS ports (Mono Framework, and eventually .NET Core) Repro: Affects 2.9.1 Repro: Could not reproduce The reporter hasn't given enough info, or the fix was made and not recorded Tool: Hex Editor
Projects
None yet
Development

No branches or pull requests

2 participants