summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-03 22:41:53 +0200
committerwm4 <wm4@nowhere>2016-05-03 22:41:53 +0200
commit05c398fb6c3a48c6a72b6b0706ea0156c46b146d (patch)
tree81304d1fb70fa9bc342611aae9f45ed48af4fc4a
parent485ae095f77a27bd3bca08b0e221dff14581e0d3 (diff)
downloadmpv-05c398fb6c3a48c6a72b6b0706ea0156c46b146d.tar.bz2
mpv-05c398fb6c3a48c6a72b6b0706ea0156c46b146d.tar.xz
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.
-rw-r--r--player/command.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/player/command.c b/player/command.c
index 1e21a0d59c..e6a3258741 100644
--- a/player/command.c
+++ b/player/command.c
@@ -112,6 +112,13 @@ struct hook_handler {
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,
enum stream_type mediatype,
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);
res = talloc_asprintf_append(res, "%s", time);
talloc_free(time);
- char *m1 = "> ", *m2 = " <";
- if (n != cur)
- m1 = m2 = "";
- res = talloc_asprintf_append(res, " %s%s%s\n", m1, name, m2);
+ const char *m = n == cur ? list_current : list_normal;
+ res = talloc_asprintf_append(res, " %s%s\n", m, 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++) {
struct demux_edition *ed = &editions[n];
- if (n == current)
- res = talloc_asprintf_append(res, "> ");
+ res = talloc_strdup_append(res, n == current ? list_current
+ : list_normal);
res = talloc_asprintf_append(res, "%d: ", n);
char *title = mp_tags_get_str(ed->metadata, "title");
if (!title)
title = "unnamed";
- res = talloc_asprintf_append(res, "'%s' ", title);
- if (n == current)
- res = talloc_asprintf_append(res, "<");
- res = talloc_asprintf_append(res, "\n");
+ res = talloc_asprintf_append(res, "'%s'\n", title);
}
*(char **)arg = res;
@@ -2033,8 +2035,8 @@ static int property_list_tracks(void *ctx, struct m_property *prop,
res = talloc_asprintf_append(res, "%s: ",
track_type_name(track->type));
- if (track->selected)
- res = talloc_asprintf_append(res, "> ");
+ res = talloc_strdup_append(res,
+ track->selected ? list_current : list_normal);
res = talloc_asprintf_append(res, "(%d) ", track->user_tid);
if (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);
if (track->is_external)
res = talloc_asprintf_append(res, "(external) ");
- if (track->selected)
- res = talloc_asprintf_append(res, "<");
res = talloc_asprintf_append(res, "\n");
}
@@ -3145,11 +3145,9 @@ static int mp_property_playlist(void *ctx, struct m_property *prop,
if (s[0])
p = s;
}
- if (mpctx->playlist->current == e) {
- res = talloc_asprintf_append(res, "> %s <\n", p);
- } else {
- res = talloc_asprintf_append(res, "%s\n", p);
- }
+ const char *m = mpctx->playlist->current == e ?
+ list_current : list_normal;
+ res = talloc_asprintf_append(res, "%s%s\n", m, p);
}
*(char **)arg = res;