History

osc.lua: add visibility_modes script opt

This allows users to choose what visibility modes they want to cycle through when calling the osc-visibilty cycle script binding.

Dudemanguy committed 1 year ago

Commit 8d665ac1 parent fd4aa9b3 files · +25 −6Browse files

Unified · Split

3 files
  1. DOCS/interface-changes/osc-script-messages.txt +1 −0
  2. DOCS/man/osc.rst +6 −0
  3. player/lua/osc.lua +18 −6
DOCS/interface-changes/osc-script-messages.txt+1−0
@@ -2,3 +2,4 @@ deprecate `osc-message` script message in favor of `show-text` command · 1 unmodified line
22 deprecate `osc-chapterlist` script message in favor of `show-text ${chapter-list}`
33 deprecate `osc-playlist` script message in favor of `show-text ${playlist}`
44 deprecate `osc-tracklist` script message in favor of `show-text ${track-list}`
5+add `visibility_modes` script-opt to osc
DOCS/man/osc.rst+6−0
@@ -358,6 +358,12 @@ Configurable Options · 357 unmodified lines
358358
359359 Also supports ``never`` and ``always``
360360
361+``visibility_modes``
362+ Default: never_auto_always
363+
364+ The list of visibility modes to cycle through when calling the
365+ osc-visibility cycle script message. Modes are separated by ``_``.
366+
361367 ``boxmaxchars``
362368 Default: 80
363369
player/lua/osc.lua+18−6
@@ -44,6 +44,7 @@ local user_opts = { · 43 unmodified lines
4444 timems = false, -- display timecodes with milliseconds?
4545 tcspace = 100, -- timecode spacing (compensate font size estimation)
4646 visibility = "auto", -- only used at init to set visibility_mode(...)
47+ visibility_modes = "never_auto_always", -- visibility modes to cycle through
4748 boxmaxchars = 80, -- title crop threshold for box layout
4849 boxvideo = false, -- apply osc_param.video_margins to video
4950 windowcontrols = "auto", -- whether to show window controls
@@ -255,6 +256,7 @@ local state = { · 205 unmodified lines
255256 maximized = false,
256257 osd = mp.create_osd_overlay("ass-events"),
257258 chapter_list = {}, -- sorted by time
259+ visibility_modes = {}, -- visibility_modes to cycle through
258260 osc_message_warned = false, -- deprecation warnings
259261 osc_chapterlist_warned = false,
260262 osc_playlist_warned = false,
@@ -2774,12 +2776,14 @@ end · 2513 unmodified lines
27742776 -- the modes only affect internal variables and not stored on its own.
27752777 local function visibility_mode(mode, no_osd)
27762778 if mode == "cycle" then
2777− if not state.enabled then
2778− mode = "auto"
2779− elseif user_opts.visibility ~= "always" then
2780− mode = "always"
2781− else
2782− mode = "never"
2779+ for i, allowed_mode in ipairs(state.visibility_modes) do
2780+ if i == #state.visibility_modes then
2781+ mode = state.visibility_modes[1]
2782+ break
2783+ elseif user_opts.visibility == allowed_mode then
2784+ mode = state.visibility_modes[i + 1]
2785+ break
2786+ end
27832787 end
27842788 end
27852789
@@ -2907,6 +2911,14 @@ local function validate_user_opts() · 121 unmodified lines
29072911 msg.warn("'" .. color .. "' is not a valid color")
29082912 end
29092913 end
2914+
2915+ for str in string.gmatch(user_opts.visibility_modes, "([^_]+)") do
2916+ if str ~= "auto" and str ~= "always" and str ~= "never" then
2917+ msg.warn("Ignoring unknown visibility mode '" .. str .."' in list")
2918+ else
2919+ table.insert(state.visibility_modes, str)
2920+ end
2921+ end
29102922 end
29112923
29122924 -- read options from config and command-line

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t