Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,11 @@ default, you must create it manually.
},
"enabled": true,
"visualiser": {
"blur": false,
"enabled": false,
"autoHide": true,
"blur": true,
"smoothing": 1,
"curvature": 0,
"rounding": 1,
"spacing": 1
}
Expand Down
4 changes: 3 additions & 1 deletion config/BackgroundConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ JsonObject {
component Visualiser: JsonObject {
property bool enabled: false
property bool autoHide: true
property bool blur: false
property bool blur: true
property int curvature: 1
property real smoothing: 0.6
property real rounding: 1
property real spacing: 1
}
Expand Down
178 changes: 69 additions & 109 deletions modules/background/Visualiser.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,146 +5,106 @@ import qs.services
import qs.config
import Caelestia.Services
import Quickshell
import Quickshell.Widgets
import QtQuick
import QtQuick.Effects
import Caelestia.Internal

Item {
id: root
anchors.fill: parent

required property ShellScreen screen
required property Wallpaper wallpaper

readonly property bool shouldBeActive: Config.background.visualiser.enabled && (!Config.background.visualiser.autoHide || (Hypr.monitorFor(screen)?.activeWorkspace?.toplevels?.values.every(t => t.lastIpcObject?.floating) ?? true))
property real offset: shouldBeActive ? 0 : screen.height * 0.2

opacity: shouldBeActive ? 1 : 0

Loader {
anchors.fill: parent
active: root.opacity > 0 && Config.background.visualiser.blur

sourceComponent: MultiEffect {
source: root.wallpaper
maskSource: wrapper
maskEnabled: true
blurEnabled: true
blur: 1
blurMax: 32
autoPaddingEnabled: false
}
Behavior on opacity {
Anim {}
}

Item {
id: wrapper

anchors.fill: parent
layer.enabled: true
readonly property bool shouldLoadBars: root.opacity > 0

Loader {
anchors.fill: parent
anchors.topMargin: root.offset
anchors.bottomMargin: -root.offset

active: root.opacity > 0

sourceComponent: Item {
ServiceRef {
service: Audio.cava
}

Item {
id: content

anchors.fill: parent
anchors.margins: Config.border.thickness
anchors.leftMargin: Visibilities.bars.get(root.screen).exclusiveZone + Appearance.spacing.small * Config.background.visualiser.spacing

Side {
content: content
}
Side {
content: content
isRight: true
}

Behavior on anchors.leftMargin {
Anim {}
}
}
}
}
ServiceRef {
id: cavaRefVis
service: Audio.cava
}

Behavior on offset {
Anim {}
ShaderEffectSource {
id: wallpaperSource
sourceItem: root.wallpaper
live: true
}

Behavior on opacity {
Anim {}
ShaderEffectSource {
id: barsSource
sourceItem: barsLoader
live: true
}

component Side: Repeater {
id: side

required property Item content
property bool isRight
property color barColorTop: Qt.alpha(Colours.palette.m3primary, 0.7)
property color barColorBottom: Qt.alpha(Colours.palette.m3inversePrimary, 0.7)

model: Config.services.visualiserBars

ClippingRectangle {
id: bar

required property int modelData
property real value: Math.max(0, Math.min(1, Audio.cava.values[side.isRight ? modelData : side.count - modelData - 1]))

clip: true

x: modelData * ((side.content.width * 0.4) / Config.services.visualiserBars) + (side.isRight ? side.content.width * 0.6 : 0)
implicitWidth: (side.content.width * 0.4) / Config.services.visualiserBars - Appearance.spacing.small * Config.background.visualiser.spacing

y: side.content.height - height
implicitHeight: bar.value * side.content.height * 0.4

color: "transparent"
topLeftRadius: Appearance.rounding.small * Config.background.visualiser.rounding
topRightRadius: Appearance.rounding.small * Config.background.visualiser.rounding
Behavior on barColorTop {
CAnim {}
}
Behavior on barColorBottom {
CAnim {}
}

Rectangle {
topLeftRadius: parent.topLeftRadius
topRightRadius: parent.topRightRadius
property real barRadius: Appearance.rounding.small * Config.background.visualiser.rounding

gradient: Gradient {
orientation: Gradient.Vertical
Loader {
anchors.fill: parent
active: root.shouldLoadBars && Config.background.visualiser.blur && barsLoader.item

GradientStop {
position: 0
color: Qt.alpha(Colours.palette.m3primary, 0.7)
sourceComponent: MultiEffect {
source: wallpaperSource
maskSource: barsSource
maskEnabled: true
maskSpreadAtMax: 0
maskSpreadAtMin: 0
maskThresholdMin: 0.67
blurEnabled: true
blur: 1
blurMax: 32
autoPaddingEnabled: false
shadowEnabled: false
}
}

Behavior on color {
CAnim {}
}
}
GradientStop {
position: 1
color: Qt.alpha(Colours.palette.m3inversePrimary, 0.7)
Loader {
id: barsLoader
anchors.fill: parent
active: root.shouldLoadBars

Behavior on color {
CAnim {}
}
}
}
sourceComponent: Item {
anchors.fill: parent
anchors.topMargin: Config.border.thickness + root.offset
anchors.bottomMargin: Config.border.thickness - root.offset
anchors.leftMargin: Visibilities.bars.get(root.screen).exclusiveZone + Appearance.spacing.small * Config.background.visualiser.spacing
anchors.margins: Config.border.thickness

anchors.left: parent.left
anchors.right: parent.right
y: parent.height - height
implicitHeight: side.content.height * 0.4
Behavior on anchors.topMargin {
Anim {}
}
Behavior on anchors.bottomMargin {
Anim {}
}

Behavior on value {
Anim {
duration: Appearance.anim.durations.small
}
VisualiserBars {

anchors.fill: parent
barCount: Config.services.visualiserBars
spacing: Appearance.spacing.small * Config.background.visualiser.spacing
smoothing: Config.background.visualiser.smoothing
curvature: Config.background.visualiser.curvature
barRadius: Appearance.rounding.small * Config.background.visualiser.rounding
barColorTop: root.barColorTop
barColorBottom: root.barColorBottom
animationDuration: Appearance.anim.durations.small
audioValues: Audio.cava.values
}
}
}
Expand Down
1 change: 1 addition & 0 deletions plugin/src/Caelestia/Internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ qml_module(caelestia-internal
hyprdevices.hpp hyprdevices.cpp
hyprextras.hpp hyprextras.cpp
logindmanager.hpp logindmanager.cpp
visualiserbars.hpp visualiserbars.cpp
LIBRARIES
Qt::Gui
Qt::Quick
Expand Down
Loading