-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
console.lua: improve the hovered item calculation with background-box
Follow up to c438732 which improved the calculation with the default outline-and-shadow. We can make the calculation accurate for background-box too without making semitransparent rectangle backgrounds overlap by disabling the shadow of selectable items, and drawing a single rectangle below the items. We could also calculate the height of each item to make them perfectly adjacent by rendering each one with compute_bounds, but that takes 15ms per render even on a new CPU, so 20 lines would take 300ms, which is too slow. The rectangle is as wide as the longest item. Even using compute_bounds once on the longest item on each render() slows it to the point of making updating the highlight while moving the mouse slower than with outline-and-shadow, especially on old hardware. So cache the width of the longest item when opening the console and update it when osd-dimensions change. The calculation is only done with background-box to not slow down outline-and-shadow unnecessarily, though it would be fine since it's only calculated on open, and therefore we also observe osd-border-style for the unlikely event that it changes during selection. Also increase the items' height to opts.font_size * 1.1 because it looks better with some margin between the items. It is possible to do it now because selectable items are drawn in separate ASS events in all border styles.
- Loading branch information
1 parent
5e9dbe4
commit 341173f
Showing
1 changed file
with
63 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters