Skip to content

How to prevent content from overflowing the display area? #903

Answered by christoph-heinrich
IC0hO asked this question in Q&A
Discussion options

You must be logged in to vote

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…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@IC0hO
Comment options

@IC0hO
Comment options

@christoph-heinrich
Comment options

@IC0hO
Comment options

@christoph-heinrich
Comment options

Answer selected by IC0hO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants