From 4c283d5f8dbfdd220015c9c4d661ec9b5a2ba6f7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 16 Feb 2015 20:03:56 +0100 Subject: osd: make it possible to have different subtitle vs. OSD defaults Until now, they used exactly the same defaults for the styling options. The defaults were shared, so it was impossible to have different defaults. Change this. This requires duplicating the full default struct, even for settings that are the same. The list of options is still shared, though. --- options/options.c | 2 +- sub/osd.c | 68 ++++++++++++++++++++++++++++++++++--------------------- sub/osd.h | 1 + 3 files changed, 44 insertions(+), 27 deletions(-) diff --git a/options/options.c b/options/options.c index a0674b6185..bba1f28a00 100644 --- a/options/options.c +++ b/options/options.c @@ -360,7 +360,7 @@ const m_option_t mp_opts[] = { OPT_FLOATRANGE("osd-bar-h", osd_bar_h, 0, 0.1, 50), OPT_SUBSTRUCT("osd", osd_style, osd_style_conf, 0), OPT_FLAG("use-text-osd", use_text_osd, CONF_GLOBAL), - OPT_SUBSTRUCT("sub-text", sub_text_style, osd_style_conf, 0), + OPT_SUBSTRUCT("sub-text", sub_text_style, sub_style_conf, 0), OPT_FLAG("sub-clear-on-seek", sub_clear_on_seek, 0), //---------------------- libao/libvo options ------------------------ diff --git a/sub/osd.c b/sub/osd.c index 1a9e7f5d23..02fbfadbfc 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -41,37 +41,53 @@ #include "video/mp_image.h" #include "video/mp_image_pool.h" -static const struct osd_style_opts osd_style_opts_def = { - .font = "sans-serif", - .font_size = 55, - .color = {255, 255, 255, 255}, - .border_color = {0, 0, 0, 255}, - .shadow_color = {240, 240, 240, 128}, - .border_size = 3, - .shadow_offset = 0, - .margin_x = 25, - .margin_y = 22, +#define OPT_BASE_STRUCT struct osd_style_opts +static const m_option_t style_opts[] = { + OPT_STRING("font", font, 0), + OPT_FLOATRANGE("font-size", font_size, 0, 1, 9000), + OPT_COLOR("color", color, 0), + OPT_COLOR("border-color", border_color, 0), + OPT_COLOR("shadow-color", shadow_color, 0), + OPT_COLOR("back-color", back_color, 0), + OPT_FLOATRANGE("border-size", border_size, 0, 0, 10), + OPT_FLOATRANGE("shadow-offset", shadow_offset, 0, 0, 10), + OPT_FLOATRANGE("spacing", spacing, 0, -10, 10), + OPT_INTRANGE("margin-x", margin_x, 0, 0, 300), + OPT_INTRANGE("margin-y", margin_y, 0, 0, 600), + OPT_FLOATRANGE("blur", blur, 0, 0, 20), + {0} }; -#define OPT_BASE_STRUCT struct osd_style_opts const struct m_sub_options osd_style_conf = { - .opts = (const m_option_t[]) { - OPT_STRING("font", font, 0), - OPT_FLOATRANGE("font-size", font_size, 0, 1, 9000), - OPT_COLOR("color", color, 0), - OPT_COLOR("border-color", border_color, 0), - OPT_COLOR("shadow-color", shadow_color, 0), - OPT_COLOR("back-color", back_color, 0), - OPT_FLOATRANGE("border-size", border_size, 0, 0, 10), - OPT_FLOATRANGE("shadow-offset", shadow_offset, 0, 0, 10), - OPT_FLOATRANGE("spacing", spacing, 0, -10, 10), - OPT_INTRANGE("margin-x", margin_x, 0, 0, 300), - OPT_INTRANGE("margin-y", margin_y, 0, 0, 600), - OPT_FLOATRANGE("blur", blur, 0, 0, 20), - {0} + .opts = style_opts, + .size = sizeof(struct osd_style_opts), + .defaults = &(const struct osd_style_opts){ + .font = "sans-serif", + .font_size = 55, + .color = {255, 255, 255, 255}, + .border_color = {0, 0, 0, 255}, + .shadow_color = {240, 240, 240, 128}, + .border_size = 3, + .shadow_offset = 0, + .margin_x = 25, + .margin_y = 22, }, +}; + +const struct m_sub_options sub_style_conf = { + .opts = style_opts, .size = sizeof(struct osd_style_opts), - .defaults = &osd_style_opts_def, + .defaults = &(const struct osd_style_opts){ + .font = "sans-serif", + .font_size = 55, + .color = {255, 255, 255, 255}, + .border_color = {0, 0, 0, 255}, + .shadow_color = {240, 240, 240, 128}, + .border_size = 3, + .shadow_offset = 0, + .margin_x = 25, + .margin_y = 22, + }, }; static bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b) diff --git a/sub/osd.h b/sub/osd.h index 015bae29e5..6b7e284f33 100644 --- a/sub/osd.h +++ b/sub/osd.h @@ -137,6 +137,7 @@ struct osd_style_opts { }; extern const struct m_sub_options osd_style_conf; +extern const struct m_sub_options sub_style_conf; struct osd_state; struct osd_object; -- cgit v1.2.3