summaryrefslogtreecommitdiffstats
path: root/sub/osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-13 00:19:17 +0100
committerwm4 <wm4@nowhere>2013-12-13 00:19:17 +0100
commitb0bd93cbc18032dde6abb42cbc3068e906622e48 (patch)
treec645527986f85a5ea735ff81c2fcd0115651489b /sub/osd.c
parent88432b817d0ca115ff97ec76065f1dabcb5f9137 (diff)
downloadmpv-b0bd93cbc18032dde6abb42cbc3068e906622e48.tar.bz2
mpv-b0bd93cbc18032dde6abb42cbc3068e906622e48.tar.xz
dvdnav: support mouse interaction
Diffstat (limited to 'sub/osd.c')
-rw-r--r--sub/osd.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sub/osd.c b/sub/osd.c
index ab3764cb00..a1daa1b390 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -325,6 +325,23 @@ void osd_object_get_scale_factor(struct osd_state *osd, struct osd_object *obj,
*sh = nh / (double)obj->vo_res.h;
}
+// Turn *x and *y, which are given in OSD coordinates, to video coordinates.
+// frame_w and frame_h give the dimensions of the original, unscaled video.
+// (This gives correct results only after the OSD has been updated after a
+// resize or video reconfig.)
+void osd_coords_to_video(struct osd_state *osd, int frame_w, int frame_h,
+ int *x, int *y)
+{
+ struct mp_osd_res res = osd->objs[OSDTYPE_OSD]->vo_res;
+ int vidw = res.w - res.ml - res.mr;
+ int vidh = res.h - res.mt - res.mb;
+ double xscale = (double)vidw / frame_w;
+ double yscale = (double)vidh / frame_h;
+ // The OSD size + margins make up the scaled rectangle of the video.
+ *x = (*x - res.ml) / xscale;
+ *y = (*y - res.mt) / yscale;
+}
+
// Position the subbitmaps in imgs on the screen. Basically, this fits the
// subtitle canvas (of size frame_w x frame_h) onto the screen, such that it
// fills the whole video area (especially if the video is magnified, e.g. on