1
0
Fork 1
mirror of https://github.com/zen-browser/desktop.git synced 2025-07-07 23:00:01 +02:00

feat: Added legacy version for gradients picker, b=no-bug, c=common, workspaces

This commit is contained in:
mr. m 2025-07-01 01:30:04 +02:00
parent 0df0d16fa4
commit 4f049111b1
No known key found for this signature in database
GPG key ID: 928E01ED4C97749F
2 changed files with 17 additions and 4 deletions

View file

@ -57,6 +57,7 @@ class nsZenUIMigration {
); );
const theme = Services.prefs.getIntPref('layout.css.prefers-color-scheme.content-override', 0); const theme = Services.prefs.getIntPref('layout.css.prefers-color-scheme.content-override', 0);
Services.prefs.setIntPref('zen.view.window.scheme', theme); Services.prefs.setIntPref('zen.view.window.scheme', theme);
Services.prefs.setIntPref('zen.theme.gradient-legacy-version', 0);
} }
} }

View file

@ -75,6 +75,9 @@
}); });
this.dragStartPosition = null; this.dragStartPosition = null;
this.isLegacyVersion =
Services.prefs.getIntPref('zen.theme.gradient-legacy-version', 1) === 0;
ChromeUtils.defineLazyGetter(this, 'panel', () => ChromeUtils.defineLazyGetter(this, 'panel', () =>
document.getElementById('PanelUI-zen-gradient-generator') document.getElementById('PanelUI-zen-gradient-generator')
); );
@ -203,7 +206,7 @@
this.useAlgo = algo; this.useAlgo = algo;
this.#currentLightness = lightness; this.#currentLightness = lightness;
dots = this.calculateCompliments(dots, 'update', this.useAlgo); dots = this.calculateCompliments(dots, 'update', this.useAlgo);
this.handleColorPositions(dots); this.handleColorPositions(dots, true);
this.updateCurrentWorkspace(); this.updateCurrentWorkspace();
}); });
} }
@ -702,10 +705,15 @@
return updatedDots; return updatedDots;
} }
handleColorPositions(colorPositions) { handleColorPositions(colorPositions, ignoreLegacy = false) {
colorPositions.sort((a, b) => a.ID - b.ID); colorPositions.sort((a, b) => a.ID - b.ID);
const existingPrimaryDot = this.dots.find((d) => d.ID === 0); const existingPrimaryDot = this.dots.find((d) => d.ID === 0);
if (this.isLegacyVersion && !ignoreLegacy) {
this.isLegacyVersion = false;
Services.prefs.setIntPref('zen.theme.gradient-legacy-version', 1);
}
if (existingPrimaryDot) { if (existingPrimaryDot) {
existingPrimaryDot.element.style.zIndex = 999; existingPrimaryDot.element.style.zIndex = 999;
const colorFromPos = this.getColorFromPosition( const colorFromPos = this.getColorFromPosition(
@ -981,7 +989,10 @@
// The more transparent, the more white the color will be blended with. In order words, // The more transparent, the more white the color will be blended with. In order words,
// make the transparency relative to these 2 ends. // make the transparency relative to these 2 ends.
// e.g. 0% opacity becomes 60% blend, 100% opacity becomes 100% blend // e.g. 0% opacity becomes 60% blend, 100% opacity becomes 100% blend
const blendPercentage = Math.max(30, 30 + opacity * 70); let blendPercentage = Math.max(30, 30 + opacity * 70);
if (this.isLegacyVersion) {
blendPercentage = 100; // Legacy version always blends to 100%
}
return colors.map((color) => ({ return colors.map((color) => ({
c: color.isCustom ? color.c : this.blendColors(color.c, colorToBlend, blendPercentage), c: color.isCustom ? color.c : this.blendColors(color.c, colorToBlend, blendPercentage),
isCustom: color.isCustom, isCustom: color.isCustom,
@ -1448,8 +1459,9 @@
`rgb(${dominantColor[0]}, ${dominantColor[1]}, ${dominantColor[2]})` `rgb(${dominantColor[0]}, ${dominantColor[1]}, ${dominantColor[2]})`
) )
); );
browser.gZenThemePicker.isLegacyVersion = this.isLegacyVersion;
let isDarkMode = this.isDarkMode; let isDarkMode = this.isDarkMode;
if (!isDefaultTheme) { if (!isDefaultTheme && !this.isLegacyVersion) {
// Check for the primary color // Check for the primary color
isDarkMode = browser.gZenThemePicker.shouldBeDarkMode(dominantColor); isDarkMode = browser.gZenThemePicker.shouldBeDarkMode(dominantColor);
browser.document.documentElement.setAttribute('zen-should-be-dark-mode', isDarkMode); browser.document.documentElement.setAttribute('zen-should-be-dark-mode', isDarkMode);