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

[Feature] Dark mode #2881

Closed
Brettdah opened this issue Oct 5, 2019 · 5 comments · Fixed by mono/mono#17888 or #2937
Closed

[Feature] Dark mode #2881

Brettdah opened this issue Oct 5, 2019 · 5 comments · Fixed by mono/mono#17888 or #2937
Labels
Enhancement New features or functionality GUI Issues affecting the interactive GUI

Comments

@Brettdah
Copy link

Brettdah commented Oct 5, 2019

Suggestions

It should be great if you could add a dark mode for the main windows late at night the window is killing my eyes ;)

Edit :
Oopsy may by the GUI redisign could be enough ;)
#2848

@DasSkelett DasSkelett added Enhancement New features or functionality GUI Issues affecting the interactive GUI labels Oct 5, 2019
@DasSkelett
Copy link
Member

DasSkelett commented Oct 5, 2019

I'm not sure on the Windows side of things, but on Linux Mono took the active GTK theme, so a dark theme was possible (and indeed used by me and @HebaruSan and maybe others).
But with the release of Mono 6 it broke again (after @HebaruSan contributed multiple commits to Mono to make it work before), and Mono ignores the active theme again, thus you only have the standard white theme.

I think Windows added some darkmode functionality in the last couple of updates, but I don't know if it is only for UWPs or if you can somehow use it in .NET apps too, or if it was only for their preinstalled UWPs (like the Settings).

@HebaruSan
Copy link
Member

HebaruSan commented Nov 23, 2019

As stated, the loss of dark mode on Linux is a Mono issue (presumably an unintentional bug), but we've helped them fix things before. Investigation notes for that:

  • It does still try to load the GTK colors in X11DesktopColors's static constructor

    • In fact it gets all the way through that block of code
    • However, when it saves the values to the theme, it doesn't stick:
      Style bg 0: 56,60,74          (value direct from GTK)
      Bg: 56,60,74,255              (value converted to .Net Color format)
      Button face: 240,240,240,255  (value retrieved from theme after set)
      
  • Application.VisualStylesEnabled is inconsistently false when ThemeEngine's static constructor runs

    • Which makes it use a ThemeWin32Classic instead of ThemeVisualStyles
    • This despite our call to Application.EnableVisualStyles();
      • Which sets visual_styles_enabled to true
      • And nothing sets it back
    • Other times, it's true, and a ThemeVisualStyles is used, and the colors still don't work
    • ThemeVisualStyles inherits from ThemeWin32Classic inherits from Theme, and the color properties are in that third class anyway, so VisualStylesEnabled has no significance
  • The color properties on Theme are implemented with some asymmetry: the get returns SystemColors.Whatever, while the set calls SetSystemColors, which works by calling System.Drawing.KnownColors.Update

    • System.Drawing.KnownColors tracks a big array of color values, and Update sets values in that array
    • The SystemColors class doesn't have source in the Mono repo, meaning it may be part of the "reference assemblies" instead

So it looks like the implementation of SystemColors was changed from one that consults KnownColors to one that does not.

akoeplinger pushed a commit to mono/mono that referenced this issue Nov 27, 2019
## Background

In Mono 5 and earlier, the active GTK or KDE theme would be sourced for system colors, allowing dark themes to be obeyed:

![image](https://user-images.githubusercontent.com/1559108/69486043-f3bf0500-0e0c-11ea-9b29-1654ba4e6d9a.png)

This allowed WinForms apps to blend in and look more like native apps.

## Problem

In Mono 6, this capability was lost (as noted in passing in #14325). WinForms apps now only look like this, regardless of the system color settings:

![image](https://user-images.githubusercontent.com/1559108/69486114-dccce280-0e0d-11ea-8107-fe1653b2d816.png)

This looks somewhat jarring and worse than previous Mono releases, for users with a dark system theme.

## Cause

During load of the system settings (in the static constructor of `X11DesktopColors`), `Theme.SetSystemColors` passes system color data to `System.Drawing.KnownColors.Update`, which populates them into `System.Drawing.KnownColors.ArgbValues`. In Mono 5 and earlier, this flowed through to the visible UI.

It seems that as of Mono 6, this table no longer affects the visible WinForms UI (although it is still being updated!). Instead, a same-but-different table in `System.Drawing.KnownColorTable` drives the system colors now. I was not able to identify the commit in which this change was made.

## Changes

Now `Theme.SetSystemColors` accesses `System.Drawing.KnownColorTable.s_colorTable` instead, and WinForms apps once again obey GTK and KDE themes:

![image](https://user-images.githubusercontent.com/1559108/69486043-f3bf0500-0e0c-11ea-9b29-1654ba4e6d9a.png)

Fixes KSP-CKAN/CKAN#2881.
@HebaruSan
Copy link
Member

My fix for Mono was accepted, so Linux users should have dark mode again at some point in the hopefully not-too-distant future.

Windows users already have access to dark theming via the standard/classical desktop theme color settings:

image

In Windows 7:

  1. Right click desktop
  2. Personalize
  3. In the list of themes find the section at the bottom called "Basic and High Contrast Themes"
  4. Choose High Contrast Black
  5. Launch CKAN!

Yes, this will change the color of all your apps and taskbar and so on. I'm looking into a way around that now, there should be some way to combine this with the more modern Aero theming.

@HebaruSan
Copy link
Member

HebaruSan commented Nov 29, 2019

OK, partial success with this method (it seems that not quite every color is theme-able):

  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
  6. Launch CKAN!

image

I'm going to see whether we can do anything at the application level to improve upon that, maybe there are a few hard coded colors left in there somewhere...

@HebaruSan
Copy link
Member

Well, we can do significantly better in a dark theme context, but it requires turning off the "visual style" setting that gives the grid headers and inactive tabs a gradient. The result is a more Windows 95-98 look when NOT in a dark theme:

image

image

sancheolz pushed a commit to sancheolz/mono that referenced this issue Jan 14, 2020
## Background

In Mono 5 and earlier, the active GTK or KDE theme would be sourced for system colors, allowing dark themes to be obeyed:

![image](https://user-images.githubusercontent.com/1559108/69486043-f3bf0500-0e0c-11ea-9b29-1654ba4e6d9a.png)

This allowed WinForms apps to blend in and look more like native apps.

## Problem

In Mono 6, this capability was lost (as noted in passing in mono#14325). WinForms apps now only look like this, regardless of the system color settings:

![image](https://user-images.githubusercontent.com/1559108/69486114-dccce280-0e0d-11ea-8107-fe1653b2d816.png)

This looks somewhat jarring and worse than previous Mono releases, for users with a dark system theme.

## Cause

During load of the system settings (in the static constructor of `X11DesktopColors`), `Theme.SetSystemColors` passes system color data to `System.Drawing.KnownColors.Update`, which populates them into `System.Drawing.KnownColors.ArgbValues`. In Mono 5 and earlier, this flowed through to the visible UI.

It seems that as of Mono 6, this table no longer affects the visible WinForms UI (although it is still being updated!). Instead, a same-but-different table in `System.Drawing.KnownColorTable` drives the system colors now. I was not able to identify the commit in which this change was made.

## Changes

Now `Theme.SetSystemColors` accesses `System.Drawing.KnownColorTable.s_colorTable` instead, and WinForms apps once again obey GTK and KDE themes:

![image](https://user-images.githubusercontent.com/1559108/69486043-f3bf0500-0e0c-11ea-9b29-1654ba4e6d9a.png)

Fixes KSP-CKAN/CKAN#2881.
jonpryor pushed a commit to dotnet/android that referenced this issue Jan 30, 2020
Changes: mono/api-snapshot@6f14e43...8ea1d66

	$ git diff --shortstat 6f14e433...8ea1d663
	 21 files changed, 719 insertions(+), 444 deletions(-)

Changes: mono/boringssl@4ca62c5...d7b108e

	$ git diff --shortstat 4ca62c57...d7b108ee
	 1 file changed, 1 insertion(+)

Changes: dotnet/cecil@cb6c1ca...a6a7f5c

	$ git diff --shortstat cb6c1ca9...a6a7f5c0
	 47 files changed, 587 insertions(+), 444 deletions(-)

Changes: mono/corefx@10a41e9...5940515

	$ git diff --shortstat 10a41e9f...59405155
	 55 files changed, 1382 insertions(+), 369 deletions(-)

Changes: mono/mono@18920a8...2edccc5

	$ git diff --shortstat 18920a83...2edccc52
        1393 files changed, 44742 insertions(+), 90381 deletions(-)

Context: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1005448
Context: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1005448
Context: KSP-CKAN/CKAN#2881
Context: mono/mono#10559
Context: mono/mono#12249
Context: mono/mono#12337
Context: mono/mono#12995
Context: mono/mono#13777
Context: mono/mono#15006
Context: mono/mono#15010
Context: mono/mono#15181
Context: mono/mono#15805
Context: mono/mono#15845
Context: mono/mono#16026
Context: mono/mono#16206
Context: mono/mono#16410
Context: mono/mono#16513
Context: mono/mono#16557
Context: mono/mono#16588
Context: mono/mono#16632
Context: mono/mono#16701
Context: mono/mono#16778
Context: mono/mono#17053
Context: mono/mono#17084
Context: mono/mono#17133
Context: mono/mono#17151
Context: mono/mono#17161
Context: mono/mono#17190
Context: mono/mono#17278
Context: mono/mono#17278
Context: mono/mono#17317
Context: mono/mono#17367
Context: mono/mono#17389
Context: mono/mono#17546
Context: mono/mono#17549
Context: mono/mono#17569
Context: mono/mono#17601
Context: mono/mono#17665
Context: mono/mono#17687
Context: mono/mono#17737
Context: mono/mono#17790
Context: mono/mono#17869
Context: mono/mono#17878
Context: mono/mono#17916
Context: mono/mono#17924
Context: mono/mono#17926
Context: mono/mono#17931
Context: mono/mono#18213
Context: mono/mono#18221
Context: mono/mono#18273
Context: mono/mono#18276
Context: mono/mono#18317
Context: mono/mono#18388
Context: mono/mono#18455
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants