osd: always update already visible OSD bar on seeks

Seeks can be performed with OSD bar invisible (e.g. "osd-msg seek ..."
command), and then an already visible bar won't be updated. But the bar
will stick around until the OSD text is hidden. This is confusing, so
change it that the bar is updated. (Making the bar disappear on such
seeks would require much more changes, so we're lazy and go with this
commit.)
This commit is contained in:
wm4 2013-02-16 20:50:05 +01:00
parent 57879a2200
commit f897138c2d
3 changed files with 26 additions and 11 deletions

View File

@ -37,6 +37,8 @@
#define MAX_TERM_OSD_LEVEL 1
#define OSD_LEVEL_INVISIBLE 4
#define OSD_BAR_SEEK 256
struct MPContext;
void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,double max,double val);

View File

@ -1376,13 +1376,8 @@ static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx)
return NULL;
}
/**
* \brief Display the OSD bar.
*
* Display the OSD bar or fall back on a simple message.
*
*/
// type: mp_osd_font_codepoints, ASCII, or OSD_BAR_*
// name: fallback for terminal OSD
void set_osd_bar(struct MPContext *mpctx, int type, const char *name,
double min, double max, double val)
{
@ -1402,6 +1397,17 @@ void set_osd_bar(struct MPContext *mpctx, int type, const char *name,
name, ROUND(100 * (val - min) / (max - min)));
}
// Update a currently displayed bar of the same type, without resetting the
// timer.
static void update_osd_bar(struct MPContext *mpctx, int type,
double min, double max, double val)
{
if (mpctx->osd->progbar_type == type) {
mpctx->osd->progbar_value = 256 * (val - min) / (max - min);
vo_osd_changed(OSDTYPE_PROGBAR);
}
}
void set_osd_function(struct MPContext *mpctx, int osd_function)
{
mpctx->osd_function = osd_function;
@ -1467,8 +1473,10 @@ static void sadd_osd_status(char *buffer, int len, struct MPContext *mpctx,
// function, because multiple successive seek commands can be coalesced.
static void add_seek_osd_messages(struct MPContext *mpctx)
{
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR)
set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx));
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR) {
set_osd_bar(mpctx, OSD_BAR_SEEK, "Position", 0, 100,
get_percent_pos(mpctx));
}
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) {
mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1,
mpctx->opts.osd_duration);
@ -1539,6 +1547,9 @@ static void update_osd_msg(struct MPContext *mpctx)
sadd_osd_status(text, len, mpctx, osd_level == 3);
osd_set_text(osd, text);
if (msg && msg->show_position)
update_osd_bar(mpctx, OSD_BAR_SEEK, 0, 100, get_percent_pos(mpctx));
return;
}

View File

@ -204,9 +204,11 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj)
char *text = talloc_strdup(NULL, "{\\q2}");
if (osd->progbar_type >= 32) {
if (osd->progbar_type == 0 || osd->progbar_type >= 256) {
// no sym
} else if (osd->progbar_type >= 32) {
text = append_utf8_buffer(text, osd->progbar_type);
} else if (osd->progbar_type > 0) {
} else {
text = talloc_strdup_append_buffer(text, ASS_USE_OSD_FONT);
text = append_utf8_buffer(text, OSD_CODEPOINTS + osd->progbar_type);
text = talloc_strdup_append_buffer(text, "{\\r}");