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 grid colors for dark themes #2529

Merged
merged 1 commit into from
Oct 7, 2018

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Oct 2, 2018

Background

Windows (and by extension .NET, and by further extension Mono) has a color theming system with two main pairs of foreground/background colors:

Background Foreground Description
SystemColors.Control SystemColors.ControlText For "3D" controls like buttons or tabstrips
SystemColors.Window SystemColors.WindowText For editable controls like text boxes or grids

Problem

The mod list looks bad in Linux with a dark theme:

image

  • The grid header has black text on a dark gray background
  • The mod rows have light gray text on a white background

Cause

Mono's DataGridView has some bad defaults for its colors; the WindowText and ControlText colors are switched:

Cell Background Foreground
Header SystemColors.Control SystemColors.WindowText
Regular row SystemColors.Window SystemColors.ControlText

https://github.com/mono/mono/blob/f0921fd850b0c8e61d5954fa71471189d2a55447/mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridView.cs#L176-L177

https://github.com/mono/mono/blob/f0921fd850b0c8e61d5954fa71471189d2a55447/mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridView.cs#L191-L192

On a standard theme, both foreground colors are black, so this is not noticeable. On a dark theme, ControlText is light and Control is dark, so the mismatch is very apparent.

Submitted mono/mono#10944 to hopefully get this fixed upstream.

Changes

Luckily the defaults can be controlled by applications; now we:

  • Set the default cell style foreground color of the header to ControlText since it is a 3D control.
  • Set the default cell style foreground color of the normal rows to WindowText to make them match their background

This fixes part of #2525 (we can't fix the menu or toolbar unless mono/mono#10942 is merged).

image

Alternate approaches considered and not done

We could try to make the grid background dark instead of white. This would be done by setting it to SystemColors.Control. However, this would mess up non-dark themes, making the control the color of a button.

@HebaruSan HebaruSan added Easy This is easy to fix GUI Issues affecting the interactive GUI Pull request Mono Issues specific for Mono labels Oct 2, 2018
@politas politas merged commit 618bf90 into KSP-CKAN:master Oct 7, 2018
politas added a commit that referenced this pull request Oct 7, 2018
@HebaruSan HebaruSan deleted the fix/gui-grid-dark-colors branch October 7, 2018 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy This is easy to fix GUI Issues affecting the interactive GUI Mono Issues specific for Mono
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants