diff options
author | wm4 <wm4@nowhere> | 2013-02-14 20:43:00 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-02-14 20:45:44 +0100 |
commit | e8181ed9fb9ea49e7def7a0a806b9d516a41168a (patch) | |
tree | 2a1d0676ff363cd4364251e4b052e9103a3e0998 /sub/osd_libass.c | |
parent | e4d52330affa61457e0b2676c3730110a8ebaa1d (diff) | |
download | mpv-e8181ed9fb9ea49e7def7a0a806b9d516a41168a.tar.bz2 mpv-e8181ed9fb9ea49e7def7a0a806b9d516a41168a.tar.xz |
osd: add --osd-bar-align-x/y options to control OSD bar position
Diffstat (limited to 'sub/osd_libass.c')
-rw-r--r-- | sub/osd_libass.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/sub/osd_libass.c b/sub/osd_libass.c index b34292ce16..4b695e62a2 100644 --- a/sub/osd_libass.c +++ b/sub/osd_libass.c @@ -155,10 +155,23 @@ static void update_osd(struct osd_state *osd, struct osd_object *obj) talloc_free(text); } +static int get_align(float val, int res, int *out_margin) +{ + *out_margin = FFMAX(0, (1.0 - fabs(val)) * res / 2); + if (fabs(val) < 0.1) + return 1; // centered + return val > 0 ? 2 : 0; // bottom / top (or right / left) +} + +static const int ass_align_x[3] = {1, 2, 3}; +static const int ass_align_y[3] = {4, 8, 0}; + #define OSDBAR_ELEMS 46 static void update_progbar(struct osd_state *osd, struct osd_object *obj) { + struct MPOpts *opts = osd->opts; + if (osd->progbar_type < 0) { clear_obj(obj); return; @@ -169,8 +182,12 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj) ASS_Style *style = obj->osd_track->styles + obj->osd_track->default_style; - style->Alignment = 10; // all centered - style->MarginL = style->MarginR = style->MarginV = 0; + int ax = get_align(opts->osd_bar_align_x, obj->osd_track->PlayResX, + &style->MarginR); + int ay = get_align(opts->osd_bar_align_y, obj->osd_track->PlayResY, + &style->MarginV); + style->Alignment = ass_align_x[ax] + ass_align_y[ay]; + style->MarginL = style->MarginR; // We need a fixed font size with respect to the OSD width. // Assume the OSD bar takes 2/3 of the OSD width at PlayResY=288 and |