New wallpapers spread over the old one as noise-warped colonies in 4 px cells with a burning accent edge, drawn procedurally per change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
102 lines
4.2 KiB
QML
102 lines
4.2 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Wayland
|
|
import "../services"
|
|
import "../theme"
|
|
// qmllint disable uncreatable-type
|
|
PanelWindow {
|
|
id:root
|
|
required property var modelData
|
|
screen:modelData
|
|
anchors {top:true;bottom:true;left:true;right:true}
|
|
color:Theme.surface
|
|
exclusionMode:ExclusionMode.Ignore
|
|
WlrLayershell.layer:WlrLayer.Background
|
|
WlrLayershell.namespace:"glassMxrph-wallpaper"
|
|
mask:Region {}
|
|
readonly property string target:ConfigService.ready && ConfigService.data.wallpaper.byMonitor[root.modelData.name] ? "file://"+encodeURI(ConfigService.data.wallpaper.byMonitor[root.modelData.name]).replace(/#/g,"%23").replace(/\?/g,"%3F") : ""
|
|
// 0..1 while colonies of the new wallpaper eat through the old one.
|
|
property real progress:0
|
|
readonly property bool transitioning:incoming.source.toString()!==""
|
|
// The first wallpaper (and reduced motion) appears directly; later changes
|
|
// load into `incoming` and are revealed once decoded.
|
|
onTargetChanged:{
|
|
if(!shown.source.toString() || Theme.duration===0) {reveal.stop();incoming.source="";shown.source=target;}
|
|
else if(target===shown.source.toString()) {reveal.stop();incoming.source="";}
|
|
else {reveal.stop();progress=0;WallpaperService.revealLoading(modelData.name);incoming.source=target;}
|
|
}
|
|
Component.onCompleted:shown.source=target
|
|
function settle() {
|
|
if(!reveal.running && shown.status===Image.Ready && shown.source.toString()===incoming.source.toString())incoming.source="";
|
|
}
|
|
Image {
|
|
id:shown
|
|
anchors.fill:parent
|
|
sourceSize:Qt.size(parent.width,parent.height)
|
|
asynchronous:true
|
|
retainWhileLoading:true
|
|
fillMode:Image.PreserveAspectCrop
|
|
// Drop the overlay only once the base layer shows the new image.
|
|
onStatusChanged:root.settle()
|
|
}
|
|
// The incoming image is only a texture: the colonies shader draws the
|
|
// change over `shown` (shaders/colonies.frag).
|
|
Image {
|
|
id:incoming
|
|
visible:false
|
|
sourceSize:Qt.size(root.width,root.height)
|
|
asynchronous:true
|
|
fillMode:Image.PreserveAspectCrop
|
|
onStatusChanged:{
|
|
if(status===Image.Ready && source.toString())WallpaperService.revealReady(root.modelData.name);
|
|
else if(status===Image.Error)incoming.source="";
|
|
}
|
|
}
|
|
// PreserveAspectCrop decodes to cover the output, so the texture can be
|
|
// larger than the item on one axis: sample its centred window.
|
|
function crop(img) {
|
|
const iw=Math.max(img.implicitWidth,1),ih=Math.max(img.implicitHeight,1);
|
|
const s=Math.max(root.width/iw,root.height/ih);
|
|
const w=root.width/(iw*s),h=root.height/(ih*s);
|
|
return Qt.vector4d((1-w)/2,(1-h)/2,w,h);
|
|
}
|
|
ShaderEffect {
|
|
anchors.fill:parent
|
|
visible:root.transitioning && incoming.status===Image.Ready && root.progress>0
|
|
property var oldTex:shown
|
|
property var newTex:incoming
|
|
property real t:root.progress
|
|
property real sw:width
|
|
property real sh:height
|
|
property real cell:4
|
|
property real glow:0.9
|
|
property real seed:root.seed
|
|
property vector4d cropOld:root.crop(shown)
|
|
property vector4d cropNew:root.crop(incoming)
|
|
property color ember:root.ember
|
|
fragmentShader:Qt.resolvedUrl("shaders/colonies.frag.qsb")
|
|
}
|
|
// Captured when a change starts, so the burn keeps its colour even if the
|
|
// palette regenerates from the new wallpaper halfway through.
|
|
property real seed:0
|
|
property color ember:Theme.accentVivid
|
|
Connections {
|
|
target:WallpaperService
|
|
function onRevealSerialChanged() {
|
|
if(incoming.status===Image.Ready && incoming.source.toString() && !reveal.running && root.progress===0) {
|
|
root.seed=Math.random()*100;root.ember=Theme.accentVivid;reveal.restart();
|
|
}
|
|
}
|
|
}
|
|
NumberAnimation {
|
|
id:reveal
|
|
target:root;property:"progress"
|
|
from:0;to:1
|
|
// Linear time: the shader eases its own fronts.
|
|
duration:1800
|
|
easing.type:Easing.Linear
|
|
onFinished:{shown.source=incoming.source;Qt.callLater(root.settle);}
|
|
}
|
|
}
|