mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2025-12-06 06:36:15 +00:00
Audioviz effects: minimal signal option for a better look in the bar
This commit is contained in:
@@ -8,6 +8,10 @@ Item {
|
||||
property int strokeWidth: 0
|
||||
property var values: []
|
||||
|
||||
// Minimum signal properties
|
||||
property bool showMinimumSignal: false
|
||||
property real minimumSignalValue: 0.05 // Default to 5% of height
|
||||
|
||||
// Pre compute horizontal mirroring
|
||||
readonly property int valuesCount: values.length
|
||||
readonly property int totalBars: valuesCount * 2
|
||||
@@ -22,7 +26,8 @@ Item {
|
||||
property int valueIndex: index < root.valuesCount ? root.valuesCount - 1 - index // Mirrored half
|
||||
: index - root.valuesCount // Normal half
|
||||
|
||||
property real amp: root.values[valueIndex]
|
||||
property real rawAmp: root.values[valueIndex]
|
||||
property real amp: (root.showMinimumSignal && rawAmp === 0) ? root.minimumSignalValue : rawAmp
|
||||
|
||||
color: root.fillColor
|
||||
border.color: root.strokeColor
|
||||
|
||||
@@ -8,6 +8,10 @@ Item {
|
||||
property int strokeWidth: 0
|
||||
property var values: []
|
||||
|
||||
// Minimum signal properties
|
||||
property bool showMinimumSignal: false
|
||||
property real minimumSignalValue: 0.05 // Default to 5% of height
|
||||
|
||||
// Pre-compute mirroring
|
||||
readonly property int valuesCount: values.length
|
||||
readonly property int totalBars: valuesCount * 2
|
||||
@@ -24,7 +28,8 @@ Item {
|
||||
property int valueIndex: index < root.valuesCount ? root.valuesCount - 1 - index // Mirrored half
|
||||
: index - root.valuesCount // Normal half
|
||||
|
||||
property real amp: root.values[valueIndex]
|
||||
property real rawAmp: root.values[valueIndex]
|
||||
property real amp: (root.showMinimumSignal && rawAmp === 0) ? root.minimumSignalValue : rawAmp
|
||||
|
||||
property real barHeight: root.height * amp
|
||||
|
||||
|
||||
@@ -8,12 +8,18 @@ Item {
|
||||
property int strokeWidth: 0
|
||||
property var values: []
|
||||
|
||||
// Minimum signal properties
|
||||
property bool showMinimumSignal: false
|
||||
property real minimumSignalValue: 0.05 // Default to 5% of height
|
||||
|
||||
// Redraw when necessary
|
||||
onWidthChanged: canvas.requestPaint()
|
||||
onHeightChanged: canvas.requestPaint()
|
||||
onValuesChanged: canvas.requestPaint()
|
||||
onFillColorChanged: canvas.requestPaint()
|
||||
onStrokeColorChanged: canvas.requestPaint()
|
||||
onShowMinimumSignalChanged: canvas.requestPaint()
|
||||
onMinimumSignalValueChanged: canvas.requestPaint()
|
||||
|
||||
Canvas {
|
||||
id: canvas
|
||||
@@ -28,9 +34,14 @@ Item {
|
||||
return
|
||||
}
|
||||
|
||||
// Apply minimum signal if enabled
|
||||
var processedValues = values.map(function (v) {
|
||||
return (root.showMinimumSignal && v === 0) ? root.minimumSignalValue : v
|
||||
})
|
||||
|
||||
// Create the mirrored values
|
||||
const partToMirror = values.slice(1).reverse()
|
||||
const mirroredValues = partToMirror.concat(values)
|
||||
const partToMirror = processedValues.slice(1).reverse()
|
||||
const mirroredValues = partToMirror.concat(processedValues)
|
||||
|
||||
if (mirroredValues.length < 2) {
|
||||
return
|
||||
|
||||
@@ -89,18 +89,13 @@ Item {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
|
||||
onClicked: mouse => {
|
||||
console.log("CavaVisualizer clicked! Current type:", currentVisualizerType)
|
||||
const types = ["linear", "mirrored", "wave"]
|
||||
const currentIndex = types.indexOf(currentVisualizerType)
|
||||
const nextIndex = (currentIndex + 1) % types.length
|
||||
const newType = types[nextIndex]
|
||||
|
||||
console.log("Switching from", currentVisualizerType, "to", newType)
|
||||
|
||||
// Update settings directly
|
||||
Settings.data.audio.visualizerType = newType
|
||||
|
||||
console.log("Settings saved")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +111,7 @@ Item {
|
||||
LinearSpectrum {
|
||||
anchors.fill: parent
|
||||
values: CavaService.values
|
||||
showMinimumSignal: true
|
||||
fillColor: Color.mPrimary
|
||||
}
|
||||
}
|
||||
@@ -125,6 +121,7 @@ Item {
|
||||
MirroredSpectrum {
|
||||
anchors.fill: parent
|
||||
values: CavaService.values
|
||||
showMinimumSignal: true
|
||||
fillColor: Color.mPrimary
|
||||
}
|
||||
}
|
||||
@@ -134,6 +131,7 @@ Item {
|
||||
WaveSpectrum {
|
||||
anchors.fill: parent
|
||||
values: CavaService.values
|
||||
showMinimumSignal: true
|
||||
fillColor: Color.mPrimary
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user