1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-27 05:39:21 +00:00

options: add option to control OSD bar marker style

This adds --osd-bar-marker-style option which can be used to
customize OSD bar marker style. In addition to the existing triangle
style, a new style option is added to draw markers as lines.
This commit is contained in:
nanahi 2024-10-26 10:30:31 -04:00 committed by Kacper Michajłow
parent ea8ac49f11
commit c6883c4a56
5 changed files with 29 additions and 11 deletions

View File

@ -1 +1,2 @@
add `--osd-bar-marker-scale` and `--osd-bar-marker-min-size` options
add `--osd-bar-marker-style` option

View File

@ -4522,6 +4522,13 @@ OSD
Default: 1.6.
``--osd-bar-marker-style=<none|triangle|line>``
Set the OSD bar marker style.
:none: Don't draw markers.
:triangle: Draw markers as triangles (default).
:line: Draw markers as lines.
``--osd-blur=<0..20.0>``
Gaussian blur factor applied to the OSD font border.
0 means no blur applied (default).

View File

@ -417,6 +417,8 @@ const struct m_sub_options mp_osd_render_sub_opts = {
{"osd-bar-border-size", OPT_ALIAS("osd-bar-outline-size")},
{"osd-bar-marker-scale", OPT_FLOAT(osd_bar_marker_scale), M_RANGE(0, 100.0)},
{"osd-bar-marker-min-size", OPT_FLOAT(osd_bar_marker_min_size), M_RANGE(0, 1000.0)},
{"osd-bar-marker-style", OPT_CHOICE(osd_bar_marker_style,
{"none", 0}, {"triangle", 1}, {"line", 2})},
{"osd", OPT_SUBSTRUCT(osd_style, osd_style_conf)},
{"osd-scale", OPT_FLOAT(osd_scale), M_RANGE(0, 100)},
{"osd-scale-by-window", OPT_BOOL(osd_scale_by_window)},
@ -431,6 +433,7 @@ const struct m_sub_options mp_osd_render_sub_opts = {
.osd_bar_outline_size = 0.5,
.osd_bar_marker_scale = 1.3,
.osd_bar_marker_min_size = 1.6,
.osd_bar_marker_style = 1,
.osd_scale = 1,
.osd_scale_by_window = true,
},

View File

@ -152,6 +152,7 @@ struct mp_osd_render_opts {
float osd_bar_outline_size;
float osd_bar_marker_scale;
float osd_bar_marker_min_size;
int osd_bar_marker_style;
float osd_scale;
bool osd_scale_by_window;
struct osd_style_opts *osd_style;

View File

@ -469,19 +469,25 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj)
ass_draw_rect_ccw(d, 0, 0, width, height);
// chapter marks
for (int n = 0; n < obj->progbar_state.num_stops; n++) {
float s = obj->progbar_state.stops[n] * width;
float size = MPMAX(border * osd->opts->osd_bar_marker_scale,
osd->opts->osd_bar_marker_min_size);
if (osd->opts->osd_bar_marker_style) {
for (int n = 0; n < obj->progbar_state.num_stops; n++) {
float s = obj->progbar_state.stops[n] * width;
float size = MPMAX(border * osd->opts->osd_bar_marker_scale,
osd->opts->osd_bar_marker_min_size);
if (s > size && s < width - size) {
ass_draw_move_to(d, s + size, 0);
ass_draw_line_to(d, s, size);
ass_draw_line_to(d, s - size, 0);
if (osd->opts->osd_bar_marker_style == 2 &&
s > size / 2 && s < width - size / 2)
{ // line
ass_draw_rect_cw(d, s - size / 2, 0, s + size / 2, height);
} else if (s > size && s < width - size) { //triangle
ass_draw_move_to(d, s + size, 0);
ass_draw_line_to(d, s, size);
ass_draw_line_to(d, s - size, 0);
ass_draw_move_to(d, s - size, height);
ass_draw_line_to(d, s, height - size);
ass_draw_line_to(d, s + size, height);
ass_draw_move_to(d, s - size, height);
ass_draw_line_to(d, s, height - size);
ass_draw_line_to(d, s + size, height);
}
}
}