-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
base: master
Are you sure you want to change the base?
.net9 dark theme #12111
Conversation
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? |
public bool IsDarkTheme => | ||
Theme.GetNonEmptyColor(KnownColor.Window).GetBrightness() < 0.5; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
The comment was for screenshots. |
d69304a
to
a2be5d3
Compare
6c5df92
to
e95029b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
|
||
public static bool IsLightTheme() | ||
public static bool IsDarkTheme() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use Application.IsDarkModeEnabled
?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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).
default could set darkmode if enabled for apps when this is no longer experimental. Not in this PR... |
57a4cb4
to
9816c4f
Compare
9816c4f
to
30620db
Compare
30620db
to
bd7d796
Compare
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
bd7d796
to
06a4686
Compare
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
Still to do - many the same in ge 3 dark mode
FileStatusList
): UseTreeView
#12116. Tracked in [Dark Mode] TabControl is not in dark mode after enabled SystemColorMode.Dark dotnet/winforms#11953 ListView to be replaced.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
Ansi colors, mostly readable
Example of Flat style (as in the PR) vs Standard.
Example of light tooltip
Some icons may need adjustment:
A few usages of ListView that is not FileStatusList use ListView header
Keep as this for now?
Icons for the FileStatusList
Test methodology
Very brief usage
Test environment(s)
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.