mirror of
https://github.com/mpv-player/mpv
synced 2024-12-28 01:52:19 +00:00
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:
parent
57879a2200
commit
f897138c2d
@ -37,6 +37,8 @@
|
|||||||
#define MAX_TERM_OSD_LEVEL 1
|
#define MAX_TERM_OSD_LEVEL 1
|
||||||
#define OSD_LEVEL_INVISIBLE 4
|
#define OSD_LEVEL_INVISIBLE 4
|
||||||
|
|
||||||
|
#define OSD_BAR_SEEK 256
|
||||||
|
|
||||||
struct MPContext;
|
struct MPContext;
|
||||||
|
|
||||||
void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,double max,double val);
|
void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,double max,double val);
|
||||||
|
@ -1376,13 +1376,8 @@ static mp_osd_msg_t *get_osd_msg(struct MPContext *mpctx)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// type: mp_osd_font_codepoints, ASCII, or OSD_BAR_*
|
||||||
* \brief Display the OSD bar.
|
// name: fallback for terminal OSD
|
||||||
*
|
|
||||||
* Display the OSD bar or fall back on a simple message.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
void set_osd_bar(struct MPContext *mpctx, int type, const char *name,
|
void set_osd_bar(struct MPContext *mpctx, int type, const char *name,
|
||||||
double min, double max, double val)
|
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)));
|
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)
|
void set_osd_function(struct MPContext *mpctx, int osd_function)
|
||||||
{
|
{
|
||||||
mpctx->osd_function = 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.
|
// function, because multiple successive seek commands can be coalesced.
|
||||||
static void add_seek_osd_messages(struct MPContext *mpctx)
|
static void add_seek_osd_messages(struct MPContext *mpctx)
|
||||||
{
|
{
|
||||||
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR)
|
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR) {
|
||||||
set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx));
|
set_osd_bar(mpctx, OSD_BAR_SEEK, "Position", 0, 100,
|
||||||
|
get_percent_pos(mpctx));
|
||||||
|
}
|
||||||
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) {
|
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) {
|
||||||
mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1,
|
mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1,
|
||||||
mpctx->opts.osd_duration);
|
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);
|
sadd_osd_status(text, len, mpctx, osd_level == 3);
|
||||||
|
|
||||||
osd_set_text(osd, text);
|
osd_set_text(osd, text);
|
||||||
|
|
||||||
|
if (msg && msg->show_position)
|
||||||
|
update_osd_bar(mpctx, OSD_BAR_SEEK, 0, 100, get_percent_pos(mpctx));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,9 +204,11 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj)
|
|||||||
|
|
||||||
char *text = talloc_strdup(NULL, "{\\q2}");
|
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);
|
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 = talloc_strdup_append_buffer(text, ASS_USE_OSD_FONT);
|
||||||
text = append_utf8_buffer(text, OSD_CODEPOINTS + osd->progbar_type);
|
text = append_utf8_buffer(text, OSD_CODEPOINTS + osd->progbar_type);
|
||||||
text = talloc_strdup_append_buffer(text, "{\\r}");
|
text = talloc_strdup_append_buffer(text, "{\\r}");
|
||||||
|
Loading…
Reference in New Issue
Block a user