1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-01 19:18:28 -04:00

cava: more optimizations for visualizer

related #2863
This commit is contained in:
bbedward
2026-07-14 14:29:18 -04:00
parent 2c5a1a2804
commit c3fa7b2e1d
2 changed files with 12 additions and 6 deletions
@@ -50,10 +50,15 @@ Item {
return; return;
const n = i => { const n = i => {
const x = v[i]; const x = v[i];
return x <= 0 ? 0 : x >= 100 ? 1 : Math.sqrt(x * 0.01); const level = x <= 0 ? 0 : x >= 100 ? 1 : Math.sqrt(x * 0.01);
return Math.round(level * 32) / 32;
}; };
bars.bandsA = Qt.vector4d(n(0), n(1), n(2), n(3)); const a = Qt.vector4d(n(0), n(1), n(2), n(3));
bars.bandsB = Qt.vector2d(n(4), n(5)); const b = Qt.vector2d(n(4), n(5));
if (a == bars.bandsA && b == bars.bandsB)
return;
bars.bandsA = a;
bars.bandsB = b;
} }
} }
+4 -3
View File
@@ -342,6 +342,7 @@ BasePill {
StyledText { StyledText {
id: mediaText id: mediaText
readonly property bool onScreen: Window.window?.visible ?? false
property bool needsScrolling: implicitWidth > textContainer.width && SettingsData.scrollTitleEnabled property bool needsScrolling: implicitWidth > textContainer.width && SettingsData.scrollTitleEnabled
property real scrollOffset: 0 property real scrollOffset: 0
property real textShift: 0 property real textShift: 0
@@ -351,20 +352,20 @@ BasePill {
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale, root.barConfig?.maximizeWidgetText) font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale, root.barConfig?.maximizeWidgetText)
color: Theme.widgetTextColor color: Theme.widgetTextColor
wrapMode: Text.NoWrap wrapMode: Text.NoWrap
x: (needsScrolling ? -scrollOffset : 0) + textShift x: Math.round((needsScrolling ? -scrollOffset : 0) + textShift)
opacity: 1 opacity: 1
onTextChanged: { onTextChanged: {
scrollOffset = 0; scrollOffset = 0;
textShift = 0; textShift = 0;
scrollAnimation.restart();
textChangeAnimation.restart(); textChangeAnimation.restart();
} }
SequentialAnimation { SequentialAnimation {
id: scrollAnimation id: scrollAnimation
running: mediaText.needsScrolling && textContainer.visible running: mediaText.needsScrolling && textContainer.visible && mediaText.onScreen && root._isPlaying
loops: Animation.Infinite loops: Animation.Infinite
onStopped: mediaText.scrollOffset = 0
PauseAnimation { PauseAnimation {
duration: 2000 duration: 2000