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.
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.
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
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.
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.
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.
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
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.