mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
command: shorten long playlists on OSD
A hacky, convoluted, half-working mess that attempts to cut off overlong playlists. It does so by relying on the ASS formatting rule that the font size is specified in the virtual PlayResY resolution. This means we can (normally) easily tell how many lines fit on the screen. On the other hand, this does not work if the text is wrapped. This as a kludge until a Better™ solution is available.
This commit is contained in:
@@ -201,6 +201,7 @@ void osd_rescale_bitmaps(struct sub_bitmaps *imgs, int frame_w, int frame_h,
|
||||
// defined in osd_libass.c and osd_dummy.c
|
||||
void osd_set_external(struct osd_state *osd, void *id, int res_x, int res_y,
|
||||
char *text);
|
||||
void osd_get_text_size(struct osd_state *osd, int *out_screen_h, int *out_font_h);
|
||||
void osd_get_function_sym(char *buffer, size_t buffer_size, int osd_function);
|
||||
|
||||
#endif /* MPLAYER_SUB_H */
|
||||
|
||||
@@ -28,3 +28,9 @@ void osd_set_external(struct osd_state *osd, void *id, int res_x, int res_y,
|
||||
char *text)
|
||||
{
|
||||
}
|
||||
|
||||
void osd_get_text_size(struct osd_state *osd, int *out_screen_h, int *out_font_h)
|
||||
{
|
||||
*out_screen_h = 0;
|
||||
*out_font_h = 0;
|
||||
}
|
||||
|
||||
@@ -219,13 +219,10 @@ static ASS_Event *add_osd_ass_event_escaped(ASS_Track *track, const char *style,
|
||||
return e;
|
||||
}
|
||||
|
||||
static void update_osd_text(struct osd_state *osd, struct osd_object *obj)
|
||||
static ASS_Style *prepare_osd_ass(struct osd_state *osd, struct osd_object *obj)
|
||||
{
|
||||
struct MPOpts *opts = osd->opts;
|
||||
|
||||
if (!obj->text[0])
|
||||
return;
|
||||
|
||||
create_ass_track(osd, obj, &obj->ass, 0, 0);
|
||||
|
||||
struct osd_style_opts font = *opts->osd_style;
|
||||
@@ -236,10 +233,31 @@ static void update_osd_text(struct osd_state *osd, struct osd_object *obj)
|
||||
if (!opts->osd_scale_by_window)
|
||||
playresy *= 720.0 / obj->vo_res.h;
|
||||
|
||||
mp_ass_set_style(get_style(&obj->ass, "OSD"), playresy, &font);
|
||||
ASS_Style *style = get_style(&obj->ass, "OSD");
|
||||
mp_ass_set_style(style, playresy, &font);
|
||||
return style;
|
||||
}
|
||||
|
||||
static void update_osd_text(struct osd_state *osd, struct osd_object *obj)
|
||||
{
|
||||
|
||||
if (!obj->text[0])
|
||||
return;
|
||||
|
||||
prepare_osd_ass(osd, obj);
|
||||
add_osd_ass_event_escaped(obj->ass.track, "OSD", obj->text);
|
||||
}
|
||||
|
||||
void osd_get_text_size(struct osd_state *osd, int *out_screen_h, int *out_font_h)
|
||||
{
|
||||
pthread_mutex_lock(&osd->lock);
|
||||
struct osd_object *obj = osd->objs[OSDTYPE_OSD];
|
||||
ASS_Style *style = prepare_osd_ass(osd, obj);
|
||||
*out_screen_h = obj->ass.track->PlayResY - style->MarginV;
|
||||
*out_font_h = style->FontSize;
|
||||
pthread_mutex_unlock(&osd->lock);
|
||||
}
|
||||
|
||||
// align: -1 .. +1
|
||||
// frame: size of the containing area
|
||||
// obj: size of the object that should be positioned inside the area
|
||||
|
||||
Reference in New Issue
Block a user