Skip to content

Make status-bar volume slider clickable and focus-independent#12

Merged
bubio merged 1 commit into
mainfrom
fix-statusbar-volume-slider
Jun 10, 2026
Merged

Make status-bar volume slider clickable and focus-independent#12
bubio merged 1 commit into
mainfrom
fix-statusbar-volume-slider

Conversation

@bubio

@bubio bubio commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

ステータスバーの音量スライダーが操作できない問題を修正しました。

原因は2つ重なっていました。

  • Nuklear 標準の nk_slide_float小さなツマミを掴んでドラッグしている間しか値が変わらない仕様で、レールのクリックは無反応。さらに音量100(既定値)ではツマミがセル右端に張り付き、ほぼ掴めない。
  • nk_slide_floatNK_WINDOW_ROM を尊重するため、ステータスバーが最前面でない(ダイアログ表示中など)と入力が無効化される。隣のミュートアイコンは ctx.input を直接読むため動き続け、「アイコンは効くがスライダーだけ効かない」状態になっていた。

修正として、ミュートアイコンと同じく ctx.input を直接ポーリングする自前トラックに置き換えました。

  • バー上のどこをクリック/ドラッグしても、ポインタの x 座標から音量を設定(クリック即ジャンプ+ドラッグ追従)
  • nk_input_has_mouse_click_down_in_rect でセル内開始の押下のみ拾うため、縦に少しずれても掴み続けられる
  • ctx.input 直読みのためウィンドウのフォーカス/ROM 状態の影響を受けない
  • レール+塗り+ツマミ円を手描きし、0/100 でもはみ出さないよう左右に余白

Test plan

  • zig build がエラーなく通る
  • 起動してバー上の任意位置クリックで音量がその位置に設定される
  • ドラッグで音量が連続的に追従する
  • ダイアログ表示後もスライダーが操作できる
  • ミュートアイコンとの相互動作(ミュート→スライダー操作で復帰)に問題がない

The volume control used Nuklear's nk_slide_float, which only changes
value while dragging its small knob (track clicks are ignored, and at
full volume the knob is jammed against the right edge, nearly impossible
to grab). It also went read-only whenever the status-bar window was not
the top window, e.g. while a dialog was open, since nk_slider_float honors
NK_WINDOW_ROM. The neighboring mute icon kept working because it polls
ctx.input directly, producing the "icon works but slider doesn't" symptom.

Replace it with a hand-drawn track hit-tested via ctx.input, mirroring the
mute icon: a click or drag anywhere along the bar sets the level, drag
keeps tracking once started in the cell, and the control is unaffected by
window focus/ROM state.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bubio bubio merged commit f830bb8 into main Jun 10, 2026
3 checks passed
@bubio bubio deleted the fix-statusbar-volume-slider branch June 10, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant