diff --git a/DOCS/interface-changes/osdscale.txt b/DOCS/interface-changes/osdscale.txt new file mode 100644 index 0000000000000..38eec1afc8a09 --- /dev/null +++ b/DOCS/interface-changes/osdscale.txt @@ -0,0 +1,3 @@ +change `vidscale` script option type to string for osc.lua +change `vidscale` script option type to string for stats.lua +change `vidscale` default from `yes` to `auto` for osc.lua and stats.lua diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 8ef6a65a0e491..bc4dd56ad0c1d 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -4474,12 +4474,18 @@ OSD are always in actual pixels. The effect is that changing the window size won't change the OSD font size. + .. note:: + + For scripts which draw user interface elements, it is recommended to + respect the value of this option when deciding whether the elements + are scaled with window size or not. + ``--osd-shadow-color=`` See ``--sub-color``. Color used for OSD shadow. .. note:: - ignored when ``--osd-back-color`` is specified (or more exactly: when + Ignored when ``--osd-back-color`` is specified (or more exactly: when that option is not set to completely transparent). ``--osd-shadow-offset=`` diff --git a/DOCS/man/osc.rst b/DOCS/man/osc.rst index 0a9b54c5cfb25..dc8dad7c2ff6b 100644 --- a/DOCS/man/osc.rst +++ b/DOCS/man/osc.rst @@ -248,10 +248,12 @@ Configurable Options Scale factor of the OSC when fullscreen ``vidscale`` - Default: yes + Default: auto - Scale the OSC with the video - ``no`` tries to keep the OSC size constant as much as the window size allows + Scale the OSC with the video. + ``no`` tries to keep the OSC size constant as much as the window size allows. + ``auto`` scales the OSC with the OSD, which is scaled with the window or kept at a + constant size, depending on the ``--osd-scale-by-window`` option. ``valign`` Default: 0.8 diff --git a/DOCS/man/stats.rst b/DOCS/man/stats.rst index 8bc0a3c651837..30ce0796dfe8c 100644 --- a/DOCS/man/stats.rst +++ b/DOCS/man/stats.rst @@ -199,10 +199,12 @@ Configurable Options Color used for drawing graphs. ``vidscale`` - Default: yes + Default: auto 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). diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 6388c3e988eff..0859afc9ba603 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -14,7 +14,7 @@ local user_opts = { idlescreen = true, -- show mpv logo on idle scalewindowed = 1, -- scaling of the controller when windowed scalefullscreen = 1, -- scaling of the controller when fullscreen - vidscale = true, -- scale the controller with the video? + vidscale = "auto", -- scale the controller with the video? valign = 0.8, -- vertical alignment, -1 (top) to 1 (bottom) halign = 0, -- horizontal alignment, -1 (left) to 1 (right) barmargin = 0, -- vertical margin of top/bottombar @@ -1785,7 +1785,14 @@ function osc_init() scale = user_opts.scalewindowed end - if user_opts.vidscale then + local scale_with_video + if user_opts.vidscale == "auto" then + scale_with_video = mp.get_property_native("osd-scale-by-window") + else + scale_with_video = user_opts.vidscale == "yes" + end + + if scale_with_video then osc_param.unscaled_y = baseResY else osc_param.unscaled_y = display_h @@ -2844,6 +2851,7 @@ mp.observe_property("osd-dimensions", "native", function() -- we might have to worry about property update ordering) request_init_resize() end) +mp.observe_property('osd-scale-by-window', 'native', request_init_resize) -- mouse show/hide bindings mp.set_key_bindings({ diff --git a/player/lua/stats.lua b/player/lua/stats.lua index 1c9f1aac3734c..e58a7f5bb0485 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -60,7 +60,7 @@ local o = { shadow_y_offset = 0.0, shadow_color = "", alpha = "11", - vidscale = true, + vidscale = "auto", -- Custom header for ASS tags to style the text output. -- Specifying this will ignore the text style values above and just @@ -1353,10 +1353,17 @@ local function print_page(page, after_scroll) end end -local function update_scale(_, value) +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") + 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 @@ -1369,6 +1376,15 @@ local function update_scale(_, value) end end +local function handle_osd_height_update(_, value) + update_scale(value) +end + +local function handle_osd_scale_by_window_update() + local value = mp.get_property_native("osd-height") + update_scale(value) +end + local function clear_screen() if o.persistent_overlay then mp.set_osd_ass(0, 0, "") else mp.osd_message("", 0) end end @@ -1597,4 +1613,5 @@ if o.bindlist ~= "no" then end) end -mp.observe_property('osd-height', 'native', update_scale) +mp.observe_property('osd-height', 'native', handle_osd_height_update) +mp.observe_property('osd-scale-by-window', 'native', handle_osd_scale_by_window_update)