Grey title bar for grey theme

This commit is contained in:
Natsumi
2026-01-31 06:33:12 +13:00
committed by pa
parent 916a0f94db
commit 7c24e2038d
2 changed files with 26 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
@@ -24,15 +24,19 @@ namespace VRCX
/// <summary> /// <summary>
/// Private holder of current theme /// Private holder of current theme
/// </summary> /// </summary>
private static int currentTheme; private static int currentTheme = -1;
/// <summary> /// <summary>
/// Sets the global theme of the app /// Sets the global theme of the app
/// Light = 0 /// Light = 0
/// Dark = 1 /// Dark = 1
/// Midnight = 2
/// </summary> /// </summary>
public static void SetGlobalTheme(int theme) public static void SetGlobalTheme(int theme)
{ {
if (currentTheme == theme)
return;
currentTheme = theme; currentTheme = theme;
//Make a seperate list for all current forms (causes issues otherwise) //Make a seperate list for all current forms (causes issues otherwise)
@@ -91,18 +95,20 @@ namespace VRCX
private static void SetThemeToGlobal(IntPtr handle) private static void SetThemeToGlobal(IntPtr handle)
{ {
int whiteColor = 0xFFFFFF; var whiteColor = 0xFFFFFF;
int blackColor = 0x000000; var blackColor = 0x000000;
if (GetTheme(handle) != currentTheme) var greyColor = 0x2B2B2B;
{
if (PInvoke.DwmSetWindowAttribute(handle, DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1, ref currentTheme, sizeof(int)) != 0) var isDark = currentTheme > 0 ? 1 : 0;
PInvoke.DwmSetWindowAttribute(handle, DWMWA_USE_IMMERSIVE_DARK_MODE, ref currentTheme, sizeof(int)); if (PInvoke.DwmSetWindowAttribute(handle, DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1, ref isDark, sizeof(int)) != 0)
PInvoke.DwmSetWindowAttribute(handle, DWMWA_USE_IMMERSIVE_DARK_MODE, ref isDark, sizeof(int));
if (currentTheme == 1) if (currentTheme == 2)
PInvoke.DwmSetWindowAttribute(handle, DWMWA_CAPTION_COLOR, ref blackColor, sizeof(int)); PInvoke.DwmSetWindowAttribute(handle, DWMWA_CAPTION_COLOR, ref blackColor, sizeof(int));
else else if (currentTheme == 1)
PInvoke.DwmSetWindowAttribute(handle, DWMWA_CAPTION_COLOR, ref whiteColor, sizeof(int)); PInvoke.DwmSetWindowAttribute(handle, DWMWA_CAPTION_COLOR, ref greyColor, sizeof(int));
} else
PInvoke.DwmSetWindowAttribute(handle, DWMWA_CAPTION_COLOR, ref whiteColor, sizeof(int));
} }
private static int GetTheme(IntPtr handle) private static int GetTheme(IntPtr handle)

View File

@@ -106,18 +106,6 @@ function systemIsDarkMode() {
return window.matchMedia('(prefers-color-scheme: dark)').matches; return window.matchMedia('(prefers-color-scheme: dark)').matches;
} }
/**
*
* @param {boolean}isDark
*/
function changeAppDarkStyle(isDark) {
if (isDark) {
AppApi.ChangeTheme(1);
} else {
AppApi.ChangeTheme(0);
}
}
function applyThemeFonts(themeKey, fontLinks = []) { function applyThemeFonts(themeKey, fontLinks = []) {
document document
.querySelectorAll('link[data-theme-font]') .querySelectorAll('link[data-theme-font]')
@@ -247,7 +235,13 @@ function changeAppThemeStyle(themeMode) {
} else { } else {
document.documentElement.classList.remove('dark'); document.documentElement.classList.remove('dark');
} }
changeAppDarkStyle(themeConfig.isDark); if (themeConfig.name === 'Midnight') {
AppApi.ChangeTheme(2);
} else if (themeConfig.isDark) {
AppApi.ChangeTheme(1);
} else {
AppApi.ChangeTheme(0);
}
return { isDark: themeConfig.isDark }; return { isDark: themeConfig.isDark };
@@ -462,7 +456,6 @@ function redirectToToolsTab() {
export { export {
systemIsDarkMode, systemIsDarkMode,
changeAppDarkStyle,
changeAppThemeStyle, changeAppThemeStyle,
useThemeColor, useThemeColor,
applyThemeColor, applyThemeColor,