From a82a93e3abba58e3457ddd40d54be03c573b6498 Mon Sep 17 00:00:00 2001 From: Ilya Glebov Date: Sat, 31 Jan 2026 16:03:00 +0100 Subject: [PATCH] Add mouse wheel volume control --- README.md | 1 + internal/ui/ui.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/README.md b/README.md index fe96c7c..9019399 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ somafm --help # Show help and config file path | `<` `>` | Previous / Next station | | `r` | Random station | | `←` `→` or `+` `-` | Volume up / down | +| `Scroll` | Volume (on volume bar) | | `m` | Mute / Unmute | | `f` | Toggle favorite | | `?` | Show help | diff --git a/internal/ui/ui.go b/internal/ui/ui.go index 2655d57..dde8ac5 100644 --- a/internal/ui/ui.go +++ b/internal/ui/ui.go @@ -381,6 +381,31 @@ func (ui *UI) setupUI() { } return ui.globalInputHandler(event) }) + + ui.app.SetMouseCapture(func(event *tcell.EventMouse, action tview.MouseAction) (*tcell.EventMouse, tview.MouseAction) { + if ui.pages.HasPage("modal") { + return event, action + } + + // Handle scroll on volume bar only + if ui.volumeView != nil { + mx, my := event.Position() + vx, vy, vw, vh := ui.volumeView.GetRect() + onVolumeBar := mx >= vx && mx < vx+vw && my >= vy && my < vy+vh + + if onVolumeBar { + switch action { + case tview.MouseScrollUp: + ui.adjustVolume(VolumeStep) + return nil, tview.MouseConsumed + case tview.MouseScrollDown: + ui.adjustVolume(-VolumeStep) + return nil, tview.MouseConsumed + } + } + } + return event, action + }) } func (ui *UI) createHeader() tview.Primitive {