Skip to content

Commit

Permalink
stats.lua: add add auto value to vidscale option
Browse files Browse the repository at this point in the history
This adds auto to vidscale script option, which lets the scale be
inherited from OSD --osd-scale-by-window option.
  • Loading branch information
na-na-hi committed May 16, 2024
1 parent 0dfc186 commit 9516277
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions DOCS/interface-changes/osdscale.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
change `vidscale` script option type to string for osc.lua
change `vidscale` script option type to string for stats.lua
2 changes: 2 additions & 0 deletions DOCS/man/stats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ Configurable Options

Scale the text and graphs with the video.
``no`` tries to keep the sizes constant.
``auto`` scales the text and graphs with the OSD, which is scaled with the
window or kept at a constant size, depending on the ``--osd-scale-by-window`` option.

Note: colors are given as hexadecimal values and use ASS tag order: BBGGRR
(blue green red).
Expand Down
11 changes: 9 additions & 2 deletions player/lua/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ local o = {
shadow_y_offset = 0.0,
shadow_color = "",
alpha = "11",
vidscale = true,
vidscale = "yes",

-- Custom header for ASS tags to style the text output.
-- Specifying this will ignore the text style values above and just
Expand Down Expand Up @@ -1354,9 +1354,16 @@ local function print_page(page, after_scroll)
end

local function update_scale(_, value)
local scale_with_video
if o.vidscale == "auto" then
scale_with_video = mp.get_property_native("osd-scale-by-window") == true
else
scale_with_video = o.vidscale == "yes"
end

-- Calculate scaled metrics.
local scale = 1
if not o.vidscale and value > 0 then
if not scale_with_video and value > 0 then
scale = 720 / value
end
font_size = o.font_size * scale
Expand Down

0 comments on commit 9516277

Please sign in to comment.