Skip to content

Commit

Permalink
osc.lua: open select.lua by middle clicking buttons
Browse files Browse the repository at this point in the history
8bf5548 added mouse support to selectors, so open them from OSC
buttons.
  • Loading branch information
guidocella committed Oct 8, 2024
1 parent 8bf5548 commit 36032f5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
19 changes: 14 additions & 5 deletions DOCS/man/osc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ pl prev
============= ================================================
left-click play previous file in playlist
right-click show playlist
shift+L-click show playlist
middle-click open the playlist selector
shift+L-click open the playlist selector
============= ================================================

pl next
============= ================================================
left-click play next file in playlist
right-click show playlist
shift+L-click show playlist
middle-click open the playlist selector
shift+L-click open the playlist selector
============= ================================================

title
Expand All @@ -49,6 +51,8 @@ title
============= ================================================
left-click show playlist position and length and full title
right-click show filename
middle-click open the playlist selector
shift+L-click open the playlist selector
============= ================================================

cache
Expand All @@ -63,14 +67,16 @@ skip back
============= ================================================
left-click go to beginning of chapter / previous chapter
right-click show chapters
shift+L-click show chapters
middle-click open the chapter selector
shift+L-click open the chapter selector
============= ================================================

skip frwd
============= ================================================
left-click go to next chapter
right-click show chapters
shift+L-click show chapters
middle-click open the chapter selector
shift+L-click open the chapter selector
============= ================================================

time elapsed
Expand Down Expand Up @@ -101,14 +107,17 @@ audio and sub
============= ================================================
left-click cycle audio/sub tracks forward
right-click cycle audio/sub tracks backwards
shift+L-click show available audio/sub tracks
mouse wheel cycle audio/sub tracks forward/backwards
middle-click open the audio/sub track selector
shift+L-click open the audio/sub track selector
============= ================================================

vol
============= ================================================
left-click toggle mute
mouse wheel volume up/down
middle-click open the audio device selector
shift+L-click open the audio device selector
============= ================================================

fs
Expand Down
41 changes: 27 additions & 14 deletions player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,22 @@ layouts["topbar"] = function()
end


local function osc_visible(visible)
if state.osc_visible ~= visible then
state.osc_visible = visible
update_margins()
end
request_tick()
end

local function open_selector(type)
mp.command("script-binding select/select-" .. type)

if user_opts.visibility == "auto" then
osc_visible(false)
end
end

local function osc_init()
msg.debug("osc_init")

Expand Down Expand Up @@ -1925,6 +1941,9 @@ local function osc_init()
show_message(title)
end

ne.eventresponder["shift+mbtn_left_up"] =
function () open_selector("playlist") end

ne.eventresponder["mbtn_right_up"] =
function () show_message(mp.get_property_osd("filename")) end

Expand All @@ -1943,7 +1962,7 @@ local function osc_init()
end
end
ne.eventresponder["shift+mbtn_left_up"] =
function () show_message(get_playlist(), 3) end
function () open_selector("playlist") end
ne.eventresponder["mbtn_right_up"] =
function () show_message(get_playlist(), 3) end

Expand All @@ -1960,7 +1979,7 @@ local function osc_init()
end
end
ne.eventresponder["shift+mbtn_left_up"] =
function () show_message(get_playlist(), 3) end
function () open_selector("playlist") end
ne.eventresponder["mbtn_right_up"] =
function () show_message(get_playlist(), 3) end

Expand Down Expand Up @@ -2021,7 +2040,7 @@ local function osc_init()
end
end
ne.eventresponder["shift+mbtn_left_up"] =
function () show_message(get_chapterlist(), 3) end
function () open_selector("chapter") end
ne.eventresponder["mbtn_right_up"] =
function () show_message(get_chapterlist(), 3) end

Expand All @@ -2038,7 +2057,7 @@ local function osc_init()
end
end
ne.eventresponder["shift+mbtn_left_up"] =
function () show_message(get_chapterlist(), 3) end
function () open_selector("chapter") end
ne.eventresponder["mbtn_right_up"] =
function () show_message(get_chapterlist(), 3) end

Expand All @@ -2062,7 +2081,7 @@ local function osc_init()
ne.eventresponder["mbtn_right_up"] =
function () set_track("audio", -1) end
ne.eventresponder["shift+mbtn_left_down"] =
function () show_message(get_tracklist("audio"), 2) end
function () open_selector("aid") end

if user_opts.scrollcontrols then
ne.eventresponder["wheel_down_press"] =
Expand All @@ -2088,7 +2107,7 @@ local function osc_init()
ne.eventresponder["mbtn_right_up"] =
function () set_track("sub", -1) end
ne.eventresponder["shift+mbtn_left_down"] =
function () show_message(get_tracklist("sub"), 2) end
function () open_selector("sid") end

if user_opts.scrollcontrols then
ne.eventresponder["wheel_down_press"] =
Expand Down Expand Up @@ -2274,6 +2293,8 @@ local function osc_init()
end
ne.eventresponder["mbtn_left_up"] =
function () mp.commandv("cycle", "mute") end
ne.eventresponder["shift+mbtn_left_up"] =
function () mp.command("script-binding select/select-audio-device") end

if user_opts.scrollcontrols then
ne.eventresponder["wheel_up_press"] =
Expand All @@ -2297,14 +2318,6 @@ local function osc_init()
update_margins()
end

local function osc_visible(visible)
if state.osc_visible ~= visible then
state.osc_visible = visible
update_margins()
end
request_tick()
end

local function show_osc()
-- show when disabled can happen (e.g. mouse_move) due to async/delayed unbinding
if not state.enabled then return end
Expand Down

0 comments on commit 36032f5

Please sign in to comment.