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

.net9 dark theme #12111

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft

Conversation

gerhardol
Copy link
Member

@gerhardol gerhardol commented Dec 22, 2024

Depends on #12064 #12113 #12115 #12116 #12117 #12118
Maybe a 5.2 first?

Proposed changes

This is a WIP PR for theming with dotnet/winforms#11857
This is not as good looking as what @NikolayXHD did for GE 3.x, but it follows the standard Windows dark mode.
There are many limitations and issues in dotnet/winforms#11857 still, it
is a later call to use this now or not.
The standard theme is not modified by this PR.

The first commits are cleanups and could be separated.

This PR has a number of tweaks to the setup to make this mostly usable, there are a number of issues still.
This is a very preliminary summary of the status, to be added close to screenshots later.

What is mostly fixed

  • Terminal colors that are used in diff etc are mostly adjusted. There may be changes.
  • Grid colors are mostly adjusted
  • Hardcoded colors are adapted to the theme (should have been done before too)
  • Buttons in 100% dpi with standard style are bright. There is fix for them (special fix for some), but standard style do not look great. Flat style looks better, applied for dark mode only now. [Dark Mode] Button with FlatStyle 'Standard' is not in dark mode on 100% dpi after enabled SystemColorMode.Dark dotnet/winforms#11949
  • Headers for ListViews columns are generally overridden
  • Scrollbars are mostly fixed (some were bright initially)
  • Settings->Color->Folder SplitButton bright

Still to do - many the same in ge 3 dark mode

  • ListView group headers like for remotes and ind the dashboard is unreadable. FileStatusList is changed in feat(FileStatusList): Use TreeView #12116. Tracked in [Dark Mode] TabControl is not in dark mode after enabled SystemColorMode.Dark dotnet/winforms#11953 ListView to be replaced.
  • Some adapted colors like Reset is a little muted, add specific colors? Cleanup the adaption in general?
  • Add some kind of disclaimer for dark mode - at least that it is experimental in .net9. Win10 (and Win11 23H2?) is not expected to fully work too
  • Some issues seen below may be improved
  • tooltips and various other like disabled text boxes are bright, no dramatic issue (also reported)
  • Forms extending from GitExtensionsForm are much darker than the "modern" forms based on GitExtensionsDialog. This applies to for instance Settings and FindInFile, total of 20 forms. There is a difference for the light theme too, but the difference is bigger for dark mode. Certainly not in this PR.
  • Syntax highlighting in the editor looks bad. The colors are adapted, there is no way to set specific colors (or use system colors?).

The ListView unreadable text is very annoying but I believe the text is in such forms that this can be accepted.
There will need to more color tweaking.

Contrast is generally quite low though, most of this in the WinForms colors.
Some overrides were already implemented, like for dotnet/winforms#11953

Mostly run on Win11, a few visuals on Win10 (Numeric up/down and a few listview (?) scrollbars light).

The GE3.x hooks are removed. It is not expected that such hooks will work, wait for .net10 if this is not accepted.
The darksilver theme was removed, it would be the same as the dark theme as system colors cannot be changed.
Similar highcontrast_dark was removed, not needed.
Invariant theme system colors are hardcoded, required to adjust colors.

I will appreciate if someone that is better in design and override .NET painting (.NET and GUI is not my strength, this is a hobby!) joins.

Some of the commits in this PR may be separated to individual PRs.

Screenshots

Not updated with the latest changes

Should this show GE 3.x/5.1/DarkMode?

For now some visual style examples and issues

General look, see the unreadable FileStatusList group text
image

Ansi colors, mostly readable
image

Example of Flat style (as in the PR) vs Standard.
image
image

Example of light tooltip
image

Some icons may need adjustment:
image

A few usages of ListView that is not FileStatusList use ListView header
Keep as this for now?
image

Icons for the FileStatusList
image
image
image

image
image
image
image

Test methodology

Very brief usage

Test environment(s)

  • Git Extensions 33.33.33
  • Git 2.47.1.windows.1
  • Microsoft Windows NT 10.0.26100.0
  • .NET 9.0.0
  • DPI 96dpi (no scaling)
  • Portable: False
  • Microsoft.WindowsDesktop.App Versions
    Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Merge strategy

Rebase merge (PR submitter must change the commit message for the last commit).


✒️ I contribute this code under The Developer Certificate of Origin.

@RussKie
Copy link
Member

RussKie commented Dec 23, 2024

Should this be GE 3.x/5.1/DarkMode?

I think this should be a dedicated branch, until it's deemed satisfactory/release-ready. Dark mode could be enabled via the settings, couldn't it?

Comment on lines 30 to 31
public bool IsDarkTheme =>
Theme.GetNonEmptyColor(KnownColor.Window).GetBrightness() < 0.5;
Copy link
Member

Choose a reason for hiding this comment

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

There's a dedicated API in Windows Forms for that, isn't there?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is to know if the theme is dark, this is what was there.
I considered adding a specific color just to enable or a special setting to enable. We want to enable dark mode separate from the system for some time, there will be many visuals.

If we go with .net9 this can be merged if the most severe issues are fixed as experimental, there may be designers helping...
But also that will take a long time to get to.

@gerhardol
Copy link
Member Author

Should this be GE 3.x/5.1/DarkMode?

I think this should be a dedicated branch, until it's deemed satisfactory/release-ready. Dark mode could be enabled via the settings, couldn't it?

The comment was for screenshots.
As in the other comment, the invariant theme is not changed by this pr.

@gerhardol gerhardol force-pushed the feature/net9-theming branch 5 times, most recently from d69304a to a2be5d3 Compare December 26, 2024 18:41
@gerhardol gerhardol changed the title WIP net9 theming .net9 dark theme Dec 26, 2024
@gerhardol gerhardol force-pushed the feature/net9-theming branch 2 times, most recently from 6c5df92 to e95029b Compare December 27, 2024 22:47
Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

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

🚀

src/app/GitExtensions/Project.Publish.targets Show resolved Hide resolved

public static bool IsLightTheme()
public static bool IsDarkTheme()
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

The short answer is that ThemeModule.IsDarkTheme cannot be used in Dashboard (where this is used).
I have mostly used Application.IsDarkModeEnabled for consequences of using the experimental dark mode, like overriding buttons to FlatStyle and ThemeModule.IsDarkTheme for other color relatded changes.
It is not exactly the same.

If the concept of theming is narrowed to light/dark for system colors (as WinForms supports) and custom for GE colors, then only Application.IsDarkModeEnabled could be used in all situations.
Then I would like to suppress WFO5001 globally too. I really hope that dark mode is not removed even if all quirks are not fixed for .net10 ((just two issues that I know of remains so GE could live with the current support.) Thanks to .NET engineers that fixed this in the final hours...

@@ -46,7 +48,7 @@ private void InitializeComponent()
// pnlLeft
//
pnlLeft.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
pnlLeft.BackColor = Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(228)))), ((int)(((byte)(235)))));
pnlLeft.BackColor = Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(228)))), ((int)(((byte)(235))))).AdaptBackColor();
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't be manually changing the designer files, as these will get overwritten once we open the form in the designer.

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, the color assign in itself is removed too, so not a difference.
Normally, you need to revert every change by the designer anyway.
I am not sure if something like Remove.ImageTransparentColor = Color.Magenta.AdaptBackColor();even need to be changed.
It was easiest to change all occurrences for now, to find the usages.

I would have preferred to split this PR in several sequiential PRs, but there will be feedback back for some time.
There are some blockers (.net in AppVeyor, FileStatusList use TreeView and likely a 5.2 release) before this is ready to merge anyway. But I find this very usable in normal work.

}
}
};
#endif

HighDpiMouseCursors.Enable();
Copy link
Member

Choose a reason for hiding this comment

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

I was kind of expecting we'd be calling Application.SetColorMode API on line 45 depending on the user selection:

Application.SetColorMode(SystemColorMode);

Copy link
Member Author

@gerhardol gerhardol Dec 28, 2024

Choose a reason for hiding this comment

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

I just added a TODO for the Dashboard, to be cleaned up. That works well enough for now.
Edit: SetColorMode is set in src/app/GitUI/Theming/ThemeModule.cs, also for Dashboard.

There is no dark mode for Bug reporter, but there is no dark mode in any popup in .net9, so that is consistent (that may be changed in .net10, then BugReporter should maybe be changed too).

@gerhardol
Copy link
Member Author

Dark mode could be enabled via the settings, couldn't it?

default could set darkmode if enabled for apps when this is no longer experimental. Not in this PR...

@gerhardol gerhardol force-pushed the feature/net9-theming branch 3 times, most recently from 57a4cb4 to 9816c4f Compare December 30, 2024 12:53
@gerhardol gerhardol force-pushed the feature/net9-theming branch from 9816c4f to 30620db Compare January 2, 2025 11:30
suppress VSTHRD103,WFO1000
Remove the EasyHook handling that was required for theming in
GE v3.x with .NET framework v4. This solution has has not
worked since GE v4, that use .NET core (.net6 and later).
.net9 has experimental support for dark mode that can enable
the use of dark mode.

The activation of hooking was disabled by the define SUPPORT_THEME_HOOKS.
A number of unused methods was used too,
as well as the EasyHooks submodule.

The .net9 solution do not allow customization of system colors,
so overrides were removed from the themes.
As the darksilver theme mostly changed system colors, it was removed.

The invariant theme system colors is required by theming to adjust
colors and still requires the system colors.
The color for MenuHighlight was corrected in the invaiant theme.
ButtonFace, ButtonHighlight, ButtonShadow was assumed to be
duplicates of Control* colors, this was not corrrect and the handling
was removed.

The workaround for dark header was removed too.
MakeBackgroundDarkerBy must adjust the the current theme,
not the default/invariant theme color.

Add some documentation.
Remove unused methods.
Group the methods by name.
The default Color.Transparant is used in the GE icons.
When set, it was mostly Color.Magenta and that is not used
by GE icons as well the few other colors.
Prepare for theming by adopting hardcoded colors to theme colors.

Some colors set in Designer updated in the forms.
Remove the native Win override to use "explorer" theme,
part of gitextensions#4491.
This seem to affect the TreeView selected item.
(ListView already changed).
Some ThemeFix no longer needed for theming with .net9.
For ListBox BorderStyle.Fixed3D does not look great in dark mode but is
rendered correctly and not overridden.
Basic adaption of .net9 dark app mode.
The themeing is adopted to use Windows dark app mode enabled in .net9.
The theming engine does not allow override of any system colors.

The GE 3.x dark theme are adjusted to
be mostly working with SystemColorMode.Dark.
This is incomplete, a number of overrides and tuning still needed.

highconstrast_dark theme was removed, no longer needed
@gerhardol gerhardol force-pushed the feature/net9-theming branch from bd7d796 to 06a4686 Compare January 4, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants