summaryrefslogtreecommitdiffstats
path: root/player/lua
diff options
context:
space:
mode:
authorRicardo Constantino <wiiaboo@gmail.com>2017-01-26 23:03:16 +0000
committerRicardo Constantino <wiiaboo@gmail.com>2017-01-31 18:54:40 +0000
commit9831d3ada6e9fbf3ae4894d7abacdfdb44730ef4 (patch)
tree8eece02a1e86f3fb9c7076cab25f48ce94246855 /player/lua
parentee000f213375f7284d292b83161195b4eb081701 (diff)
downloadmpv-9831d3ada6e9fbf3ae4894d7abacdfdb44730ef4.tar.bz2
mpv-9831d3ada6e9fbf3ae4894d7abacdfdb44730ef4.tar.xz
osc: box: clip with ellipsis after too much stretching
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/osc.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index 13ce3ff418..bc4226abba 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -658,8 +658,15 @@ function render_elements(master_ass)
end
local maxchars = element.layout.button.maxchars
-
if not (maxchars == nil) and (#buttontext > maxchars) then
+ if (#buttontext > maxchars+20) then
+ while (#buttontext > maxchars+20) do
+ buttontext = buttontext:gsub(".[\128-\191]*$", "")
+ end
+ buttontext = buttontext .. "..."
+ end
+ local _, nchars2 = buttontext:gsub(".[\128-\191]*", "")
+ local stretch = (maxchars/#buttontext)*100
buttontext = string.format("{\\fscx%f}",
(maxchars/#buttontext)*100) .. buttontext
end
@@ -944,7 +951,7 @@ layouts["box"] = function ()
lo = add_layout("title")
lo.geometry = {x = posX, y = titlerowY, an = 8, w = 496, h = 12}
lo.style = osc_styles.vidtitle
- lo.button.maxchars = 90
+ lo.button.maxchars = 80
lo = add_layout("pl_prev")
lo.geometry =