diff --git a/src/BizHawk.Client.EmuHawk/FormBase.cs b/src/BizHawk.Client.EmuHawk/FormBase.cs index 3c238d54bb..8add78e0df 100644 --- a/src/BizHawk.Client.EmuHawk/FormBase.cs +++ b/src/BizHawk.Client.EmuHawk/FormBase.cs @@ -2,14 +2,33 @@ using System; using System.ComponentModel; +using System.Drawing; using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Common; +using BizHawk.WinForms.Controls; namespace BizHawk.Client.EmuHawk { public class FormBase : Form { + /// + /// Under Mono, SystemColors.Control returns an ugly beige.
+ /// This method recursively replaces the of the given (can be a ) with + /// iff they have the default of SystemColors.Control.
+ /// (Also adds a custom to ToolStrips to change their colors.) + ///
+ public static void FixBackColorOnControls(Control control) + { + if (control.BackColor == SystemColors.Control) control.BackColor = Color.WhiteSmoke; + foreach (Control c1 in control.Controls) + { + if (c1 is ToolStrip ts) ts.Renderer = new ToolStripProfessionalRenderer(new LinuxColorTable()); + else FixBackColorOnControls(c1); + } + } + private string? _windowTitleStatic; public virtual bool BlocksInputWhenFocused { get; } = true; @@ -33,6 +52,7 @@ namespace BizHawk.Client.EmuHawk protected override void OnLoad(EventArgs e) { base.OnLoad(e); + if (OSTailoredCode.IsUnixHost) FixBackColorOnControls(this); UpdateWindowTitle(); } diff --git a/src/BizHawk.WinForms.Controls/MenuEx/LinuxColorTable.cs b/src/BizHawk.WinForms.Controls/MenuEx/LinuxColorTable.cs new file mode 100644 index 0000000000..bca3fab482 --- /dev/null +++ b/src/BizHawk.WinForms.Controls/MenuEx/LinuxColorTable.cs @@ -0,0 +1,16 @@ +#nullable enable + +using System.Drawing; +using System.Windows.Forms; + +namespace BizHawk.WinForms.Controls +{ + public sealed class LinuxColorTable : ProfessionalColorTable + { + public override Color MenuStripGradientBegin { get; } = Color.WhiteSmoke; + + public override Color ToolStripDropDownBackground { get; } = Color.WhiteSmoke; + + public override Color ToolStripGradientEnd { get; } = Color.WhiteSmoke; + } +}