Skip to content

Commit

Permalink
{select,osc}.lua: add a miscellaneous menu
Browse files Browse the repository at this point in the history
Add a generic menu to bar layouts to provide discoverability for the
select menus to users who don't realize you can right click OSC buttons.

There's no space to add it in box layout.
  • Loading branch information
guidocella committed Dec 12, 2024
1 parent dbb3291 commit 353d5c2
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 6 deletions.
3 changes: 3 additions & 0 deletions DOCS/man/mpv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ g-b
g-r
Show the values of all properties.

MENU
Show a menu with miscellaneous entries.

(The following keys are valid if you have a keyboard with multimedia keys.)

PAUSE
Expand Down
13 changes: 12 additions & 1 deletion DOCS/man/osc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The Interface
::

+---------+----------+------------------------------------------+----------+
| pl prev | pl next | title | cache |
| pl prev | menu | pl next | title cache |
+------+--+---+------+---------+-----------+------+-------+-----+-----+----+
| play | skip | skip | time | seekbar | time | audio | sub | vol | fs |
| | back | frwd | elapsed | | left | | | | |
Expand All @@ -36,6 +36,11 @@ pl prev
right-click open the playlist selector
============= ================================================

menu
============= ================================================
left-click open the menu
============= ================================================

pl next
============= ================================================
left-click play next file in playlist
Expand Down Expand Up @@ -510,6 +515,12 @@ clicked. ``mbtn_mid`` commands are also triggered with ``shift+mbtn_left``.

``playlist_prev_mbtn_right_command=script-binding select/select-playlist; script-message-to osc osc-hide``

``menu_mbtn_left_command=script-binding select/menu; script-message-to osc osc-hide``

``menu_mbtn_mid_command=``

``menu_mbtn_right_command=``

``playlist_next_mbtn_left_command=playlist-next; show-text ${playlist} 3000``

``playlist_next_mbtn_mid_command=show-text ${playlist} 3000``
Expand Down
1 change: 1 addition & 0 deletions etc/input.conf
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
#g-d script-binding select/select-audio-device
#g-b script-binding select/select-binding
#g-r script-binding select/show-properties
#MENU script-binding select/menu

#Alt+KP1 add video-rotate -1 # rotate video counterclockwise by 1 degree
#Alt+KP5 set video-rotate 0 # reset rotation
Expand Down
24 changes: 19 additions & 5 deletions player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ local user_opts = {
playlist_prev_mbtn_mid_command = "show-text ${playlist} 3000",
playlist_prev_mbtn_right_command = "script-binding select/select-playlist; script-message-to osc osc-hide",

menu_mbtn_left_command = "script-binding select/menu; script-message-to osc osc-hide",
menu_mbtn_mid_command = "",
menu_mbtn_right_command = "",

playlist_next_mbtn_left_command = "playlist-next",
playlist_next_mbtn_mid_command = "show-text ${playlist} 3000",
playlist_next_mbtn_right_command = "script-binding select/select-playlist; script-message-to osc osc-hide",
Expand Down Expand Up @@ -1556,13 +1560,20 @@ local function bar_layout(direction)
lo.alpha[1] = user_opts.boxalpha


-- Playlist prev/next
-- Playlist prev
geo = { x = osc_geo.x + padX, y = line1,
an = 4, w = 18, h = 18 - padY }
lo = add_layout("playlist_prev")
lo.geometry = geo
lo.style = osc_styles.topButtonsBar

-- Menu
geo = { x = geo.x + geo.w + padX, y = geo.y, an = geo.an, w = geo.w, h = geo.h }
lo = add_layout("menu")
lo.geometry = geo
lo.style = osc_styles.topButtonsBar

-- Playlist next
geo = { x = geo.x + geo.w + padX, y = geo.y, an = geo.an, w = geo.w, h = geo.h }
lo = add_layout("playlist_next")
lo.geometry = geo
Expand Down Expand Up @@ -1775,16 +1786,19 @@ local function osc_init()
end
bind_mouse_buttons("title")

-- playlist buttons

-- prev
-- playlist prev
ne = new_element("playlist_prev", "button")

ne.content = "\238\132\144"
ne.enabled = (pl_pos > 1) or (loop ~= "no")
bind_mouse_buttons("playlist_prev")

--next
-- menu
ne = new_element("menu", "button")
ne.content = ""
bind_mouse_buttons("menu")

-- playlist next
ne = new_element("playlist_next", "button")

ne.content = "\238\132\129"
Expand Down
26 changes: 26 additions & 0 deletions player/lua/select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,29 @@ mp.add_key_binding(nil, "show-properties", function ()
end,
})
end)

mp.add_key_binding(nil, "menu", function ()
local menu = {
{"Subtitles", "script-binding select/select-sid"},
{"Audio tracks", "script-binding select/select-aid"},
{"Playlist", "script-binding select/select-playlist"},
{"Chapters", "script-binding select/select-chapter"},
{"Editions/Titles", "script-binding select/select-edition"},
{"Audio devices", "script-binding select/select-audio-device"},
}

local labels = {}
local commands = {}

for i, pair in ipairs(menu) do
labels[i], commands[i] = unpack(pair)
end

input.select({
prompt = "",
items = labels,
submit = function (i)
mp.command(commands[i])
end,
})
end)

0 comments on commit 353d5c2

Please sign in to comment.