mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 20:03:10 +02:00
command: slightly nicer OSD list formatting
For "current" markers on OSD properties like chapter-list. The marker is now an actual arrow instead of "> ", and non-current entries will have the same indentation as the current entry. While I'm not entirely sure about the new look of those lists, it's a bit better than the visual mess that was before.
This commit is contained in:
parent
485ae095f7
commit
05c398fb6c
@ -112,6 +112,13 @@ struct hook_handler {
|
|||||||
bool active; // hook is currently in progress (only 1 at a time for now)
|
bool active; // hook is currently in progress (only 1 at a time for now)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// U+279C HEAVY ROUND-TIPPED RIGHTWARDS ARROW
|
||||||
|
#define ARROW "\342\236\234"
|
||||||
|
#define ARROW_SP ARROW " "
|
||||||
|
|
||||||
|
const char list_current[] = OSD_ASS_0 ARROW_SP OSD_ASS_1;
|
||||||
|
const char list_normal[] = OSD_ASS_0 "{\\alpha&HFF}" ARROW_SP "{\\r}" OSD_ASS_1;
|
||||||
|
|
||||||
static int edit_filters(struct MPContext *mpctx, struct mp_log *log,
|
static int edit_filters(struct MPContext *mpctx, struct mp_log *log,
|
||||||
enum stream_type mediatype,
|
enum stream_type mediatype,
|
||||||
const char *cmd, const char *arg);
|
const char *cmd, const char *arg);
|
||||||
@ -870,10 +877,8 @@ static int mp_property_list_chapters(void *ctx, struct m_property *prop,
|
|||||||
char* time = mp_format_time(t, false);
|
char* time = mp_format_time(t, false);
|
||||||
res = talloc_asprintf_append(res, "%s", time);
|
res = talloc_asprintf_append(res, "%s", time);
|
||||||
talloc_free(time);
|
talloc_free(time);
|
||||||
char *m1 = "> ", *m2 = " <";
|
const char *m = n == cur ? list_current : list_normal;
|
||||||
if (n != cur)
|
res = talloc_asprintf_append(res, " %s%s\n", m, name);
|
||||||
m1 = m2 = "";
|
|
||||||
res = talloc_asprintf_append(res, " %s%s%s\n", m1, name, m2);
|
|
||||||
talloc_free(name);
|
talloc_free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -964,16 +969,13 @@ static int property_list_editions(void *ctx, struct m_property *prop,
|
|||||||
for (int n = 0; n < num_editions; n++) {
|
for (int n = 0; n < num_editions; n++) {
|
||||||
struct demux_edition *ed = &editions[n];
|
struct demux_edition *ed = &editions[n];
|
||||||
|
|
||||||
if (n == current)
|
res = talloc_strdup_append(res, n == current ? list_current
|
||||||
res = talloc_asprintf_append(res, "> ");
|
: list_normal);
|
||||||
res = talloc_asprintf_append(res, "%d: ", n);
|
res = talloc_asprintf_append(res, "%d: ", n);
|
||||||
char *title = mp_tags_get_str(ed->metadata, "title");
|
char *title = mp_tags_get_str(ed->metadata, "title");
|
||||||
if (!title)
|
if (!title)
|
||||||
title = "unnamed";
|
title = "unnamed";
|
||||||
res = talloc_asprintf_append(res, "'%s' ", title);
|
res = talloc_asprintf_append(res, "'%s'\n", title);
|
||||||
if (n == current)
|
|
||||||
res = talloc_asprintf_append(res, "<");
|
|
||||||
res = talloc_asprintf_append(res, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*(char **)arg = res;
|
*(char **)arg = res;
|
||||||
@ -2033,8 +2035,8 @@ static int property_list_tracks(void *ctx, struct m_property *prop,
|
|||||||
|
|
||||||
res = talloc_asprintf_append(res, "%s: ",
|
res = talloc_asprintf_append(res, "%s: ",
|
||||||
track_type_name(track->type));
|
track_type_name(track->type));
|
||||||
if (track->selected)
|
res = talloc_strdup_append(res,
|
||||||
res = talloc_asprintf_append(res, "> ");
|
track->selected ? list_current : list_normal);
|
||||||
res = talloc_asprintf_append(res, "(%d) ", track->user_tid);
|
res = talloc_asprintf_append(res, "(%d) ", track->user_tid);
|
||||||
if (track->title)
|
if (track->title)
|
||||||
res = talloc_asprintf_append(res, "'%s' ", track->title);
|
res = talloc_asprintf_append(res, "'%s' ", track->title);
|
||||||
@ -2042,8 +2044,6 @@ static int property_list_tracks(void *ctx, struct m_property *prop,
|
|||||||
res = talloc_asprintf_append(res, "(%s) ", track->lang);
|
res = talloc_asprintf_append(res, "(%s) ", track->lang);
|
||||||
if (track->is_external)
|
if (track->is_external)
|
||||||
res = talloc_asprintf_append(res, "(external) ");
|
res = talloc_asprintf_append(res, "(external) ");
|
||||||
if (track->selected)
|
|
||||||
res = talloc_asprintf_append(res, "<");
|
|
||||||
res = talloc_asprintf_append(res, "\n");
|
res = talloc_asprintf_append(res, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3145,11 +3145,9 @@ static int mp_property_playlist(void *ctx, struct m_property *prop,
|
|||||||
if (s[0])
|
if (s[0])
|
||||||
p = s;
|
p = s;
|
||||||
}
|
}
|
||||||
if (mpctx->playlist->current == e) {
|
const char *m = mpctx->playlist->current == e ?
|
||||||
res = talloc_asprintf_append(res, "> %s <\n", p);
|
list_current : list_normal;
|
||||||
} else {
|
res = talloc_asprintf_append(res, "%s%s\n", m, p);
|
||||||
res = talloc_asprintf_append(res, "%s\n", p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*(char **)arg = res;
|
*(char **)arg = res;
|
||||||
|
Loading…
Reference in New Issue
Block a user