History

js: use osd-dimentions for mp.get_osd_{size,margins}

This matches lua's 11b9315b but with the lagacy field names which the js code used previously. Currently the property always returns an object (with dummy/last/null field values if there are no dimensions), but the code is ready for a future case where it might return null if there are no dimensions - at which case it will forward the null, breaking backward compatibility for a better API.

Avi Halachmi (:avih) committed 6 years ago

Commit 5e0875c1 parent f612de12 files · +7 −14Browse files

Showing the changes to player/javascript (1 of 2 files). Show all

Unified · Split

player/javascript/defaults.js+7−4
@@ -238,11 +238,14 @@ mp.set_osd_ass = function set_osd_ass(res_x, res_y, data) { · 237 unmodified lines
238238 return mp._legacy_overlay.update();
239239 }
240240
241+// the following return undefined on error, null passthrough, or legacy object
241242 mp.get_osd_size = function get_osd_size() {
242− var w = mp.get_property_number("osd-width", 0),
243− h = mp.get_property_number("osd-height", 0),
244− par = mp.get_property_number("osd-par", 0);
245− return {width: w, height: h, aspect: w / (h || 1) / (par || 1)};
243+ var d = mp.get_property_native("osd-dimensions");
244+ return d && {width: d.w, height: d.h, aspect: d.aspect};
245+}
246+mp.get_osd_margins = function get_osd_margins() {
247+ var d = mp.get_property_native("osd-dimensions");
248+ return d && {left: d.ml, right: d.mr, top: d.mt, bottom: d.mb};
246249 }
247250
248251 /**********************************************************************

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t