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

Obey system colors for dark theme support #2937

Merged
merged 3 commits into from
Jan 8, 2020

Conversation

HebaruSan
Copy link
Member

Problem

You can configure the legacy system colors on Windows to change how WinForms apps display. In Windows 7:

  1. Right click desktop
  2. Personalize
  3. Window Color (in the bottom middle)
  4. Advanced appearance settings...
  5. Choose the colors that you want to use

CKAN doesn't look very good in this mode:

bad

Note that it looks OK if you choose one of the more extreme "high contrast" themes, but these also change your window borders and everything else, so it's not a great solution:

high contrast

Causes

  • A number of the WinForms controls default to a hard coded style instead of obeying the system theme
  • The status bar needed its BackColor/ForeColor properties set

Changes

  • The mod list has visual styles turned off and its header color set to obey the system colors
  • ThemedListView and ThemedTabControl classes are created as drop-in replacements for ListView and TabControl but tweaked to obey system colors
  • The status bar's BackColor and ForeColor are set

This makes dark themes on Windows look better:

better

It also results in a minor degradation of appearance in a normal theme because the gradients for inactive tabs and list headers are suppressed:

light

Needs to be tested on Linux. I think it should look the same, but there could be surprises.

Fixes #2881.

@HebaruSan HebaruSan added Enhancement New features or functionality GUI Issues affecting the interactive GUI Pull request Windows Issues specific for Windows labels Nov 30, 2019
@DasSkelett
Copy link
Member

DasSkelett commented Jan 7, 2020

On Linux, it is now really hard to recognize the active tab in the tab panels:

grafik
grafik
grafik

@HebaruSan
Copy link
Member Author

I guess .NET considers the tab's "bounds" to be the space inside the border, while Mono considers it to include the border? Fix pushed, need to test in Windows. Hopefully we don't have to put Platform.IsMono checks in here to make it work on both.

@HebaruSan
Copy link
Member Author

Worse than I hoped, better than I feared; there's a terrible looking 1px line under the tabs now in Windows:

image

... but otherwise it's serviceable. Hopefully translating the box down 1px will solve that.

@HebaruSan
Copy link
Member Author

Yup, offsetting down by 1 worked.

Copy link
Member

@DasSkelett DasSkelett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay again now.
Did not test on Windows, but your screenshots on W7 look good.
According to this article, W10 users have to do some registry editing to change the colours: https://winaero.com/blog/change-window-background-color-in-windows-10/
Maybe someone will try it out one day and report if it works too.

@HebaruSan HebaruSan merged commit f9ad915 into KSP-CKAN:master Jan 8, 2020
@HebaruSan HebaruSan deleted the fix/dark-theme branch January 8, 2020 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New features or functionality GUI Issues affecting the interactive GUI Windows Issues specific for Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Dark mode
2 participants