Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{select,osc}.lua: add a miscellaneous menu #15499

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 16 additions & 0 deletions TOOLS/mpv-osd-symbols.sfdir/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Steps to add new icons:

- Install `fontforge`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Install `fontforge`
- Install [FontForge](https://fontforge.org/en-US/)

- Install the last freely licensed version of symbola (`ttf-symbola-free` in the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this step from readme, source font for symbols can be different. You can mention in separate paragraph, that some glyphs in are extracted from symbola font.

AUR)
- `fontforge /usr/share/fonts/TTF/Symbola.ttf TOOLS/mpv-osd-symbols.sfdir`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Load a font and the project directory, for example: fontforge Symbola.ttf TOOLS/mpv-osd-symbols.sfdir

- Check the Unicode hex value of the desired character (`g-a` in vim)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't there symbol table in FontForge? I think I've seen it.

- Scroll until that value in the Symbola window and click it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Scroll until that value in the Symbola window and click it
- Scroll until that value in the font window and click it

- Press Ctrl+c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe the action, for example. Not only "press".

- Copy selected glyph (Ctrl+C)

- Focus the window with TOOLS/mpv-osd-symbols.sfdir
- Click an unused character slot
- Press Ctrl+v
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Press Ctrl+v
- Paste the glyph (Ctrl+v)

- Press Ctrl+s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Save

- Close fontforge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step is probably not really needed to explain

- Figure out the Lua sequence of the new character by copying that of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instruction unclear. Either don't say anything and expect it is clear, or make it explicit.

I think what you are saying here, is to convert Unicode code point to utf-8 chars.

previous character and incrementing the last 3 digits
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also mention TOOLS/gen-osd-font.sh which is used to generate osd_font.otf. I understand that you did that in GUI?

6 changes: 3 additions & 3 deletions TOOLS/mpv-osd-symbols.sfdir/font.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SplineFontDB: 3.0
SplineFontDB: 3.2
FontName: mpv-osd-symbols-Regular
FullName: mpv-osd-symbols Regular
FamilyName: mpv-osd-symbols
Expand All @@ -22,7 +22,7 @@ OS2Version: 3
OS2_WeightWidthSlopeOnly: 0
OS2_UseTypoMetrics: 0
CreationTime: 1408646554
ModificationTime: 1576096543
ModificationTime: 1735420479
PfmFamily: 81
TTFWeight: 400
TTFWidth: 5
Expand Down Expand Up @@ -63,7 +63,7 @@ NameList: AGL For New Fonts
DisplaySize: -72
AntiAlias: 1
FitToEm: 0
WinInfo: 57600 8 2
WinInfo: 57540 14 11
BeginPrivate: 8
BlueValues 31 [-10 0 640 650 720 730 800 810]
BlueScale 5 0.037
Expand Down
2 changes: 1 addition & 1 deletion TOOLS/mpv-osd-symbols.sfdir/uniE00D.glyph
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
StartChar: uniE00D
Encoding: 57357 57357 34
Width: 880
Flags: HWO
Flags: HW
HStem: 780 20G<200 200>
VStem: 200 375<400 400 400 800>
LayerCount: 2
Expand Down
25 changes: 25 additions & 0 deletions TOOLS/mpv-osd-symbols.sfdir/uniE102.glyph
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
StartChar: uniE102
Encoding: 57602 57602 35
Width: 2048
VWidth: 2048
Flags: HW
LayerCount: 2
Fore
SplineSet
1724 1060 m 1
324 1060 l 1
324 1252 l 1
1724 1252 l 1
1724 1060 l 1
1724 636 m 1
324 636 l 1
324 828 l 1
1724 828 l 1
1724 636 l 1
1724 212 m 1
324 212 l 1
324 404 l 1
1724 404 l 1
1724 212 l 1
EndSplineSet
EndChar
2 changes: 1 addition & 1 deletion TOOLS/mpv-osd-symbols.sfdir/uniE10A.glyph
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ StartChar: uniE10A
Encoding: 57610 57610 23
Width: 1977
GlyphClass: 2
Flags: HMWO
Flags: HMW
HStem: 242 248<2 155 2 156>
LayerCount: 2
Fore
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 = "\238\132\130"
bind_mouse_buttons("menu")

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

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

mp.add_key_binding(nil, "menu", function ()
local sub_track_count = 0
local audio_track_count = 0
local video_track_count = 0
local text_sub_selected = false

local image_sub_codecs = {["dvd_subtitle"] = true, ["hdmv_pgs_subtitle"] = true}

for _, track in pairs(mp.get_property_native("track-list")) do
if track.type == "sub" then
sub_track_count = sub_track_count + 1
if track["main-selection"] == 0 and not image_sub_codecs[track.codec] then
text_sub_selected = true
end
elseif track.type == "audio" then
audio_track_count = audio_track_count + 1
elseif track.type == "video" then
video_track_count = video_track_count + 1
end
end

local menu = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this list all select? Especially why vid select is hidden?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I saw uosc doesn't have it so I didn't if it's worth adding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I saw uosc doesn't have it so I didn't if it's worth adding.

Of course they has it. In UOSC each button is dynamic and show only when needed. See https://github.com/tomasklaen/uosc/blob/6a1c0e9c6e7e9e43cda1c1ea3e44a911fae45927/src/uosc.conf#L83C1-L83C211 specifically, <has_many_video>video.

This menu could do this too, to not show items that goes nowhere.

{"Subtitles", "script-binding select/select-sid", sub_track_count > 0},
{"Secondary subtitles", "script-binding select/select-secondary-sid", sub_track_count > 1},
{"Subtitle lines", "script-binding select/select-subtitle-line", text_sub_selected},
{"Audio tracks", "script-binding select/select-aid", audio_track_count > 1},
{"Video tracks", "script-binding select/select-vid", video_track_count > 1},
{"Playlist", "script-binding select/select-playlist",
mp.get_property_native("playlist-count") > 1},
{"Chapters", "script-binding select/select-chapter", mp.get_property("chapter")},
{"Editions/Titles", "script-binding select/select-edition",
mp.get_property_native("edition-list/count", 0) > 1},
{"Audio devices", "script-binding select/select-audio-device", audio_track_count > 0},
{"Key bindings", "script-binding select/select-binding", true},
}

local labels = {}
local commands = {}

for _, entry in ipairs(menu) do
if entry[3] then
labels[#labels + 1] = entry[1]
commands[#commands + 1] = entry[2]
end
end

input.select({
prompt = "",
items = labels,
submit = function (i)
mp.command(commands[i])
end,
})
end)
Binary file modified sub/osd_font.otf
Binary file not shown.
Loading