How to prevent content from overflowing the display area? #903
-
I am currently reading the code to understand and learn. I want to know how to display chapters on the timeline, and during mouse movement, the chapter content does not exceed the osc display area. Other oscs like [mpv-osc-tethys]do not have such good effects, if the chapter is too long it will overflow the display area. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
We have a fairly accurate estimation of how much space text takes up thanks to compute_bounds, and with that we can clamp the position of the chapter popup. If you want to read the relevant code, it's in text.lua. Beware that |
Beta Was this translation helpful? Give feedback.
We have a fairly accurate estimation of how much space text takes up thanks to compute_bounds, and with that we can clamp the position of the chapter popup.
If you want to read the relevant code, it's in text.lua.
Beware that
compute_bounds
is fairly slow, but when the overlay is hidden it's much faster for some reason (I think when it's hidden mpv doesn't wait for a frame redraw, but I've never checked the code to confirm). Combine that with some caching and it's usable.Furthermore by default we don't measure whole strings, but instead individual characters and then compute string length from that, which makes it a little bit less accurate, but it's much faster when a lot of new strings…