342 Commits

Author SHA1 Message Date
kamperemu 8cc65c838e osc.lua: add box width option for box and slimbox layouts
osc.lua: add slimbox width option and preserve width values for box slimbox

docs: update default box and slimbox width values in OSC configuration

docs: add `boxwidth` and `slimboxwidth` script options to osc
2026-04-29 07:22:14 +02:00
Guido Cella 05b327c723 osc.lua: use the cached chapter_list instead or retrieving chapters 2026-04-26 08:56:24 +02:00
Guido Cella 3183ea9980 osc.lua: always observe duration
Currently the duration observer is toggled in multiple places to not
call request_init unecessarily. It is much simpler to always observe it
and call request_init conditionally in the callback. This also allows
reusing the cached value throughout the OSC.

Note that dividing by 0 is not an error in Lua so there is no need to
check for both 0 and nil.
2026-04-26 00:20:33 +02:00
Guido Cella 9ce79bcaa0 osc.lua: hide thumbnails when setting visibility to never
And also when using script-message osc-hide.
2026-04-25 20:03:10 +02:00
Guido Cella 47a8a47b31 osc.lua: don't write to user-data on every render
Only update hover-sec when there is a big enough change to not spam the
log with -v.
2026-04-25 20:03:10 +02:00
nanahi 531fe5a43e osc.lua: make window control buttons action customizable
Use bind_mouse_buttons helper. This makes it possible to bind custom
actions, such as right click X button to quit with watch later.
2026-04-21 18:19:18 +02:00
nanahi d9e8e0bdf6 osc.lua: add option to configure skip_forward/backward buttons
This adds _down_command support to bind_mouse_buttons so it can be
used to bind button down actions like mbtn_left_down, and let forward
and backward buttons use bind_mouse_buttons. This makes mouse button
down actions customizable.
2026-04-21 18:19:18 +02:00
nanahi b3e6506d10 osc.lua: fix frame stepping with skip_backward/forward buttons
The event responder must have up, down, or press suffix, but
940ab99055 removed it for frame stepping
function, making it unusable. Fix this by using the down suffix.

Fixes: 940ab99055
2026-04-21 18:19:18 +02:00
Guido Cella 5921fe50bb osc.lua: use the cached chapter-list for chapter markers
When 0197729949 added state.chapter_list this call was not updated to
use the cached value, but there is no reason not to use it, especially
now that more cached properties are used.
2026-04-20 21:57:05 +02:00
Guido Cella fb8c933d4d osc.lua: cache observed properties
For properties that were already being observed but still retrieved over
and over, cache their values using the new observe_cached().

osd-dimensions observer said that if cached we may have to worry about
property ordering but it seems to work fine. It is nice to cache it
because it was the property retrieved the most frequently, in 5
different places.
2026-04-20 21:53:57 +02:00
Guido Cella 0b2c08ba8d osc.lua: show the first selected audio track id with --lavfi-complex
Similar to current-tracks, when the selected audio track is combined
with another one or with an ffmpeg filter, show the first selected track
id instead of "-".

This was requested by a user on IRC.

Also avoid fetching aid and sid on each render.
2026-04-18 17:41:54 +02:00
NRK 09d075f475 osc: define and add support for "preview" api
this adds a "standard" api for ui scripts and thumbnailers to
communicate with each other, based on the simple thumbfast api
[0].

the api works as follows:

* To issue a thumbnail draw command, the UI script will set the
  property `user-data/osc/draw-preview`.
* To clear the thumbnail, the UI script will set the previously
  mentioned property to `nil`.

a more ideal api would make it so that the thumbnailer script
only generates the thumbnail and doesn't need to draw at all.
but such api is vastly more complex [4] and would require a lot
more work and maintenance on mpv's side.

this is a decent enough api that allows arbitrary thumbnailers
and ui scripts to communicate between each other and work
together, while being simple enough that it can be supported
without too much maintenance.

this change has been tested with work with thumbfast [1]. and
for demonstration that this api can be useful outside of osc, it
has also been tested to work on mfpbar's thumbnailer branch [2].

the code to determine thumbnail x,y is based on the osc fork
inside of thumbfast [3].

[0]: https://github.com/po5/thumbfast?tab=readme-ov-file#for-ui-developers-how-to-add-thumbfast-support-to-your-script
[1]: https://github.com/po5/thumbfast/pull/173
[2]: https://codeberg.org/NRK/mpv-toolbox/src/branch/thumbnailer/mfpbar
[3]: https://github.com/po5/thumbfast/tree/vanilla-osc
[4]: https://github.com/mpv-player/mpv/discussions/17654
2026-04-17 20:36:48 +02:00
Guido Cella 8da99f778f osc.lua: set no_video correctly
Fixes f4197a5ce0.
2026-04-17 20:28:42 +02:00
Guido Cella f4197a5ce0 osc.lua: merge the current-tracks/video observer into track-list's
Reuse the new track-list observer callback to check whether there is a
video track.
2026-04-17 20:19:28 +02:00
Guido Cella 15e5af0868 osc.lua: add observe_cached() helper
This removes code repetition and will make caching more properties
easier.

Some state fields are renamed to have the same name as the property.
2026-04-17 20:05:46 +02:00
Guido Cella 18f83bc43e osc.lua: make buttons clickable from the horizontal edges
Since changing the width and alignment of buttons shrinks them or messes
up the layout, manually override the hitbox of buttons at the edges.

Fixes #9791.
2026-04-17 18:33:11 +02:00
Kacper Michajłow 7ba2e1d713 osc.lua: reduce floatingalpha a little
Alpha blending is done in gamma light of the target, when the overlay is
drawn. Depending on VO and target format, the alpha value can act quite
differently.

Lower it a little to avoid excessive transparency in some cases. This
should be fixed or workaround in better way, but for now just adjust the
value.
2026-04-17 18:32:29 +02:00
Kacper Michajłow 8010ea49c9 osc.lua: fix track indexing
track-list/N is not required to match aid/vid. They are encoded as
track-list/N/id.

This fixes changes in 1a558bf5c2 where it
was asumed that track id is the same in track-list, which is not true,
in general sense.
2026-04-17 18:30:43 +02:00
Kacper Michajłow c865008e65 mpv-osd-symbols: center fluent icons only vertically
Makes it nicer for speaker icon to not move around on different volume
levels. Also remove scaling, it was not needed.

This required to rewrite the exclamation mark drawing code, made it look
similar to old icon now.
2026-04-16 19:03:47 +02:00
Guido Cella 266cb79f38 osc.lua: make all the height of bar lines clickable
There is an area between the 2 lines of bottombar and topbar that is not
clickable, e.g. between the menu and play_pause icons. Make it all
clickable so it's easier to click buttons.

This also allows clicking from the bottom in slimbottombar and from the
top in topbottombar.
2026-04-08 20:32:48 +02:00
Guido Cella c9d2f17a98 osc.lua: allow clicking window controls from the top
Window controls are not clickable from the very top of the window, they
have a margin to the top that makes them harder to click. Make them
clickable also from the very top to make them easier to activate.

The close button with the default windowcontrols_alignment=right
specifically is already clickable from the rightmost part of the window.

Partial fix of #9791 (other buttons also need to be updated).
2026-04-08 20:32:48 +02:00
Kacper Michajłow bed0f49729 osc.lua: show window controls in idle 2026-04-01 16:07:27 +02:00
Kacper Michajłow 39302caae4 osc.lua: use window title for window controls from mpv core 2026-04-01 16:07:27 +02:00
Kacper Michajłow ef7bced028 osc.lua: make title wider in floating layout
We don't put anything else on title line, so we don't need reserved
space as with other layouts.
2026-03-24 19:24:49 +01:00
Dudemanguy e84ac3760c Revert "osc.lua: fix window controls showing in fullscreen"
Decoupling fullscreen behavior from the generalized border logic
increases the complexity and also inherently changes the behavior in a
way that is not neccesarily desirable. People in IRC notably were
confused about the window controls not being shown in fullscreen because
of this change. We could default the option to yes, but then there will
likely be people confused as to why they suddenly now have the controls
when it wasn't there previously. The best way to avoid all this is just
undo it. If someone wants special fullscreen behavior with
windowcontrols, this can be done with auto profiles already. There's not
much utility in having a separate option.

This reverts commit 3b66428152.
2026-03-20 14:44:03 +00:00
Kacper Michajłow 44f06c6dd0 osc.lua: fix typo
oops...

Fixes: 6bf5a6ca7c
2026-03-13 20:12:53 +01:00
Kacper Michajłow 88e741a019 osc.lua: use fluent icons by default for floating layout
Floating layout is more rounded comparet to square bar layout, so fluent
icons are better match here.
2026-03-13 19:16:47 +01:00
Kacper Michajłow 6bf5a6ca7c osc.lua: add floating layout 2026-03-13 19:16:47 +01:00
Kacper Michajłow 8bf384fe6d osc.lua: add osc-icon_style option 2026-03-13 19:14:39 +01:00
Kacper Michajłow 27b0979b6b osc.lua: set sub_margins to no
Subtitles are complex subsystem, let's leave the choice to move them
with margin on user.
2026-03-13 15:10:21 +01:00
Kacper Michajłow 0f37c2abef osc.lua: use dedicated options to control SUB/OSD offset
There is concern that with certain user options or script the value of
`{sub,osd}-margin-y` value may be persisted or overwrite user option
when it's changed while OSD is visible and offset is applied.

Fix this by using dedicated option.
2026-03-13 15:10:21 +01:00
Guido Cella ad9374d03e osc.lua: move {audio,sub}_track_count into state 2026-03-12 15:58:21 +01:00
Guido Cella 6da164452a osc.lua: update track state only when track-list changes
There is no need to retrieve track-list on every osc_init().

Also remove the outdated comment.
2026-03-12 15:58:21 +01:00
Sam 11440741cb osc.lua: remove pause_state() 2026-03-12 10:50:11 +01:00
Kacper Michajłow 79bf5d2684 osc.lua: increase deadzoneszie to 0.75
This allows to retain deadzone in the middle of the screen when both top
and bottom bars are enabled. We also doesn't have to show bars that
early before moving mouse down.
2026-03-12 00:02:41 +01:00
Kacper Michajłow 3b66428152 osc.lua: fix window controls showing in fullscreen
If `no-border` or `no-title-bar` was used, window controls would enable
also in fullscreen, this was inconsistent, as window decorations are not
visible ragardless of those options in fullscreen mode.
2026-03-12 00:02:17 +01:00
Guido Cella 44dec05a29 osc.lua: don't retrieve display-fps at startup
There is no advantage since is it never available at startup, so speed
up the startup by not retrieving it.
2026-03-11 14:58:09 +01:00
Kacper Michajłow 7b2feb9429 osc.lua: add osd-margin option
Fixes: #17539
2026-03-10 19:45:03 +01:00
Kacper Michajłow e1e6eb8b6e osc.lua: add sub-margin option 2026-03-10 19:45:03 +01:00
Kacper Michajłow aa8966a50f osc.lua: add dynamic_margins option 2026-03-10 19:45:03 +01:00
Kacper Michajłow d4625c7db6 osc.lua: fix always visibility 2026-03-10 19:45:03 +01:00
Kacper Michajłow 88ac54b95d osc.lua: hide osc or wc when leaving its area
Those zones use input sections, but in OSC we allow them to overlap. So,
we might switch to the other section, after which point we won't get
mouse_leave event that would hide the bar for the other section.

This makes hidding/showing WC and OSC more consistent.
2026-03-10 08:56:23 +01:00
nanahi 1f430f8ce3 osc.lua: always wipe osc when idle
Prevents osc lingering when entering idle.
2026-03-10 08:31:15 +01:00
nanahi 9bb5a0b705 osc.lua: add audioonlyscreen script option
Allows rendering mpv logo when there is no video, instead of
black screen. osc is still available at the same time for playback
control.
2026-03-08 13:07:37 +01:00
nanahi 276710318f osc.lua: make logo centered 2026-03-08 13:07:37 +01:00
nanahi 107b5bee0a osc.lua: render logo and osc on separate layers
Allows rendering logo and osc at the same time to be used by the next
commit.
2026-03-08 13:07:37 +01:00
Kacper Michajłow 9548ec5531 osc.lua: avoid use of goto
For Lua 5.1 compatibility.
2026-03-07 07:28:13 +01:00
Kacper Michajłow 45019b21bf osc.lua: clean areas autohide
Fixes some corner cases with showing/hiding zones.
2026-03-05 16:34:22 +01:00
Kacper Michajłow eda3b89278 osc.lua: make top/bottom bar show independently on mouse proximity
Controlled by `windowcontrols_independent` opt.
2026-03-05 12:44:11 +01:00
nanahi fc7f6e0208 osc.lua: fix mouse position init
get_virt_mouse_pos() can return dummy -1, -1 in some cases, for example
when mouse is not considered "in" the area. render() is called
immediately and sets the initial mouse position to -1, -1 when the first
tick happens.

When starting player and mouse is already on the window but not moved,
then move the mouse, the mouse_move handler thinks that the mouse moved
from -1, -1 to the current position, triggering showing even when the
amount moved is less than osc-minmousemove.

Fix this by not letting render() init mouse position if the position is
dummy -1.
2026-02-28 22:39:24 +01:00