diff --git a/shell/Ui/PanelSlider.qml b/shell/Ui/PanelSlider.qml index d7bf1303b438..69f1e4252ad3 100644 --- a/shell/Ui/PanelSlider.qml +++ b/shell/Ui/PanelSlider.qml @@ -18,6 +18,42 @@ Item { property real knobSize: Math.max(14, Math.round(Style.spacing.controlHeight * 0.38)) property real liveValue: value + // Used for a "muted"/disabled look. The knob's *color* is dimmed (blended + // toward the panel background) rather than its opacity, and stays fully + // opaque -- an opacity fade would make the knob semi-transparent and stop + // it from fully covering the fill/track boundary beneath it, letting that + // seam show through the middle of the knob. Blending the solid color + // instead keeps the knob 100% opaque (no seam). + // + // The dimmed fill line itself isn't a flat color -- it's the track (drawn + // at 0.5 opacity over the background) with the fill drawn on top of that + // (also at 0.5 opacity). Both trackColor and fillColor can carry their own + // alpha (trackColor especially -- Style.selectedFillFor(...) is typically + // a translucent color), so the *effective* alpha at each step is the + // color's own alpha times the Rectangle's 0.5 opacity, not just 0.5. We + // replicate that two-step over-compositing here (background -> track -> + // fill) so the muted knob lands on exactly the same composited color as + // the muted line, instead of reading brighter than it. + property bool dimmed: false + readonly property color _dimBackdrop: bar ? bar.background : "#101315" + + readonly property real _dimTrackAlpha: trackColor.a * 0.5 + readonly property real _dimFillAlpha: fillColor.a * 0.5 + + readonly property color _dimTrackOverBackdrop: Qt.rgba( + _dimBackdrop.r * (1 - _dimTrackAlpha) + trackColor.r * _dimTrackAlpha, + _dimBackdrop.g * (1 - _dimTrackAlpha) + trackColor.g * _dimTrackAlpha, + _dimBackdrop.b * (1 - _dimTrackAlpha) + trackColor.b * _dimTrackAlpha, + 1) + + readonly property color _dimmedLineColor: Qt.rgba( + _dimTrackOverBackdrop.r * (1 - _dimFillAlpha) + fillColor.r * _dimFillAlpha, + _dimTrackOverBackdrop.g * (1 - _dimFillAlpha) + fillColor.g * _dimFillAlpha, + _dimTrackOverBackdrop.b * (1 - _dimFillAlpha) + fillColor.b * _dimFillAlpha, + 1) + + readonly property color effectiveKnobColor: dimmed ? _dimmedLineColor : knobColor + // macOS-style notches. When > 1, that many evenly-spaced tick marks are cut // into the track (drawn in the panel background color, so only the part // crossing the track shows). Purely visual — snapping is the caller's job via @@ -49,6 +85,7 @@ Item { height: root.trackHeight radius: height / 2 color: root.trackColor + opacity: root.dimmed ? 0.5 : 1.0 } Rectangle { @@ -59,6 +96,7 @@ Item { radius: track.radius color: root.fillColor width: track.width * root.progress + opacity: root.dimmed ? 0.5 : 1.0 Behavior on width { enabled: !root.dragging @@ -74,6 +112,7 @@ Item { height: root.trackHeight + Style.space(4) radius: 1 color: root.tickColor + opacity: root.dimmed ? 0.5 : 1.0 anchors.verticalCenter: track.verticalCenter x: Math.max(0, Math.min(track.width - width, track.width * (index / (root.tickCount - 1)) - width / 2)) @@ -85,7 +124,7 @@ Item { width: root.knobSize height: root.knobSize radius: root.knobSize / 2 - color: root.knobColor + color: root.effectiveKnobColor borderSpec: Border.flat(root.bar ? root.bar.background : "#101315", Math.max(1, Style.space(2))) anchors.verticalCenter: track.verticalCenter x: Math.max(0, Math.min(track.width - width, track.width * root.progress - width / 2)) diff --git a/shell/plugins/panels/audio/Panel.qml b/shell/plugins/panels/audio/Panel.qml index 8dcdb86a936f..0229e3188aa4 100644 --- a/shell/plugins/panels/audio/Panel.qml +++ b/shell/plugins/panels/audio/Panel.qml @@ -121,6 +121,9 @@ Panel { // selected while a tuning still exists. property string volumeSinkName: "" + // Carry sub-notch touchpad deltas between wheel events. + property real wheelAccumulator: 0 + readonly property var volumeSink: { if (volumeSinkName === "" || !sink) return sink if (volumeSinkName === String(sink.name)) return sink @@ -395,13 +398,13 @@ Panel { if (selectedIndex < floor) selectedIndex = floor } - function outputIcon() { + function outputIcon(volume) { // Match the old Waybar pulseaudio glyph set. The Material Design speaker // icons render visually smaller in JetBrainsMono Nerd Font. if (!sink || !sink.audio) return "" if (isHeadphones(sink)) return "󰋋" if (outputMuted) return "" - var v = outputVolume + var v = volume === undefined ? outputVolume : volume if (v >= 0.67) return "" if (v >= 0.34) return "" if (v > 0) return "" @@ -421,8 +424,18 @@ Panel { } function setOutputVolume(v) { - if (!sink || !sink.audio) return - volumeSink.audio.volume = Math.max(0, Math.min(1, v)) + if (!volumeSink || !volumeSink.audio) return outputVolume + var volume = Math.max(0, Math.min(1, v)) + volumeSink.audio.volume = volume + return volume + } + + function showVolumeOsd(volume) { + if (!bar || !bar.shell) return + bar.shell.summon("omarchy.osd", JSON.stringify({ + icon: outputIcon(volume), + value: Math.round(volume * 100) + })) } function setInputVolume(v) { @@ -625,8 +638,12 @@ Panel { } onWheelMoved: function(delta) { - var step = 0.05 - root.setOutputVolume(root.outputVolume + (delta > 0 ? step : -step)) + if (!root.hasOutput) return + var wheel = Util.wheelSteps(root.wheelAccumulator, delta) + root.wheelAccumulator = wheel.remainder + if (wheel.steps === 0) return + var volume = root.setOutputVolume(root.outputVolume + wheel.steps * 0.05) + root.showVolumeOsd(volume) } } @@ -814,7 +831,7 @@ Panel { maximum: 1 step: 0.05 value: root.outputVolume - opacity: root.outputMuted ? 0.5 : 1.0 + dimmed: root.outputMuted enabled: !!root.sink onMoved: function(v) { root.setOutputVolume(v) } @@ -906,7 +923,7 @@ Panel { maximum: 1 step: 0.05 value: root.inputVolume - opacity: root.inputMuted ? 0.5 : 1.0 + dimmed: root.inputMuted enabled: !!root.source onMoved: function(v) { root.setInputVolume(v) } @@ -1193,7 +1210,7 @@ Panel { maximum: 1.5 step: 0.05 value: streamRow.streamVolume - opacity: streamRow.streamMuted ? 0.5 : 1.0 + dimmed: streamRow.streamMuted onMoved: function(v) { if (streamRow.node && streamRow.node.audio) streamRow.node.audio.volume = v