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

Fix toolbar background colors for dark themes #2541

Merged
merged 1 commit into from
Oct 21, 2018

Conversation

HebaruSan
Copy link
Member

Problem

CKAN's toolbars are hideous with a dark theme:

screenshot

Cause

See mono/mono#11287; Mono is trying to use SystemColors.ButtonFace for the left edge of a toolstrip, fading to a hard coded light color with a linear gradient. But Mono doesn't load ButtonFace from the system settings, instead leaving it with a compile time default.

Upstream fix

mono/mono#11287 is trying to fix this in Mono by switching from ButtonFace to SystemColors.Control, which is set by Mono's theme loader. However, there are some downsides:

  • Even with the fix, the default toolstrip renderer still uses an ugly gradient to a hard coded light color at the right edge
  • That fix won't reach users until Mono puts out a new release and users upgrade to it (assuming it gets merged)

upstream

Changes

Luckily this part of Mono is 90% customization / overrides / defaults / etc., so there are plenty of hooks here for us to make it work however we want. When Mono wants to draw a control, it first checks whether that control has a .Renderer property, and if it does, it delegates the drawing to that object. Now we populate that property with our own renderer that just draws the background color normally. This looks better than the renderer built into Mono, even after the other fix, and will work for all users regardless of their version of Mono.

image

Fixes #2525.

@HebaruSan HebaruSan added GUI Issues affecting the interactive GUI Pull request Mono Issues specific for Mono Bug labels Oct 19, 2018
@Olympic1
Copy link
Member

Olympic1 commented Oct 21, 2018

Looks good. Could it be possible to also fix the checkboxes?

@HebaruSan
Copy link
Member Author

The Mono code for this is extremely obfuscated, but as far as I can tell so far, no, the visual style of those checkboxes is inaccessible to modification by applications. The core drawing code gets the backcolor from a reference to a full checkbox control, which doesn't exist for the grid, so a wrapper layer around that creates a temporary checkbox control from scratch using defaults that we can't change.

(It's kind of impressive how little is accomplished here with so much code. At least 8 Mono source files are involved in providing this degree of non-flexibility.)

@Olympic1 Olympic1 merged commit 084e127 into KSP-CKAN:master Oct 21, 2018
@HebaruSan HebaruSan deleted the fix/toolstrip-background branch October 21, 2018 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug GUI Issues affecting the interactive GUI Mono Issues specific for Mono Pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CKAN theme usage
2 participants