diff options
Diffstat (limited to 'osd.lua')
| -rw-r--r-- | osd.lua | 31 |
1 files changed, 26 insertions, 5 deletions
@@ -351,6 +351,19 @@ end function mt:redraw(state) local out = {} + -- to determine the area left for images, we use the computed bounds of + -- the rendered menu, which shifts when the cursor is moved to/from the + -- longest line. to prevent this, this table stores the menu options + -- with the cursor drawn on every line, which we then *invisibly* draw + -- behind the actual menu, resulting in static bounds. + -- + -- to avoid wasting space, we consider only the cursor icon, as the + -- goal here is to avoid images being resized as a result of simple + -- menu navigation. state changes with associated icons, such as + -- playing a file, may still change the computed bounds, as may + -- navigation which moves the viewport. + local out_max = {} + if state.depth > 1 then for i = 2, state.depth do out[#out+1] = self:menu_title(state.menus[i]) @@ -385,19 +398,27 @@ function mt:redraw(state) favourited = not not ( opt.id and state:favourited(opt.id)), } - out[#out+1] = self:option_icons(opt, info) .. - self:option_text(opt, info) .. + local str = self:option_text(opt, info) .. self:option_path(opt, info) + out[#out+1] = self:option_icons(opt, info) .. str if selected and opt.img_url then img = opt.img_url end + + info.selected = true + out_max[#out_max+1] = self:option_icons(opt, info) .. str end -- \q2 disables line wrapping - self.fg.data = '{\\q2\\fs' .. config.font_size .. - '\\pos(' .. self.padding .. ',' .. self.padding .. ')}' .. - table.concat(out, '\\N') + local pre = '{\\q2\\fs' .. config.font_size .. + '\\pos(' .. self.padding .. ',' .. self.padding .. ')}' + self.fg.data = pre .. table.concat(out, '\\N') + if img then + self.fg.data = self.fg.data .. '\n{\\alpha&HFF&}' .. + pre .. table.concat(out_max, '\\N') + end + self.bg.data = '{\\pos(0,0)\\alpha&H' .. config.bg_alpha .. '&\\c&H&}' .. draw_rect(0, 0, 7680, 720) |
