colours: adjust layer brightness when transparent

Darken when light mode and lighten when dark mode for better visibility
This commit is contained in:
2 * r + 2 * t 2025-04-30 22:39:51 +10:00
parent 571721ff39
commit 232f299286

View file

@ -9,6 +9,7 @@ Singleton {
id: root id: root
property bool borders: true property bool borders: true
property bool light: false
readonly property Transparency transparency: Transparency {} readonly property Transparency transparency: Transparency {}
readonly property Rounding rounding: Rounding {} readonly property Rounding rounding: Rounding {}
readonly property Spacing spacing: Spacing {} readonly property Spacing spacing: Spacing {}
@ -20,7 +21,17 @@ Singleton {
function alpha(c: color, layer: bool): color { function alpha(c: color, layer: bool): color {
if (!transparency.enabled) if (!transparency.enabled)
return c; return c;
return Qt.rgba(c.r, c.g, c.b, layer ? transparency.layers : transparency.base); c = Qt.rgba(c.r, c.g, c.b, layer ? transparency.layers : transparency.base);
if (layer)
c.hsvValue = Math.max(0, Math.min(1, c.hslLightness + (light ? -0.2 : 0.1)));
return c;
}
FileView {
path: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/scheme/current-mode.txt`
watchChanges: true
onFileChanged: this.reload()
onLoaded: root.light = this.text() === "light"
} }
FileView { FileView {