summaryrefslogtreecommitdiffstats
path: root/core/m_option.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-17 19:58:57 +0100
committerwm4 <wm4@nowhere>2012-11-20 18:00:15 +0100
commitd23b620a89e88b0ec0d6a66c7f05c2e461579647 (patch)
tree1d0719823527f5789aab4ae26cfa4ddcf72d9096 /core/m_option.h
parentdcd2435e795eefe687c23b5b74da430525ad8c00 (diff)
downloadmpv-d23b620a89e88b0ec0d6a66c7f05c2e461579647.tar.bz2
mpv-d23b620a89e88b0ec0d6a66c7f05c2e461579647.tar.xz
m_option: add color option type
This accepts HTML-style hex colors in the form #RRGGBB. It's also possible to provide an alpha component with #AARRGGBB. Each 2-digit group is a hex number, which gives the color value from 0-255 (e.g. There is existing code in subassconvert.c, which parses HTML-style color values in SRT subs. This is not used: it's probably better if option parsing is completely separate from code specific to certain subtitle formats, even if a little code is duplicated.
Diffstat (limited to 'core/m_option.h')
-rw-r--r--core/m_option.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/m_option.h b/core/m_option.h
index ed9cc33f5f..20bcfba1c2 100644
--- a/core/m_option.h
+++ b/core/m_option.h
@@ -54,6 +54,7 @@ extern const m_option_type_t m_option_type_subconfig;
extern const m_option_type_t m_option_type_subconfig_struct;
extern const m_option_type_t m_option_type_imgfmt;
extern const m_option_type_t m_option_type_afmt;
+extern const m_option_type_t m_option_type_color;
// Callback used by m_option_type_print_func options.
typedef int (*m_opt_func_full_t)(const m_option_t *, const char *, const char *);
@@ -71,6 +72,10 @@ struct m_rel_time {
enum m_rel_time_type type;
};
+struct m_color {
+ uint8_t r, g, b, a;
+};
+
// Extra definition needed for \ref m_option_type_obj_settings_list options.
typedef struct {
// Pointer to an array of pointer to some object type description struct.
@@ -198,6 +203,7 @@ union m_option_value {
m_obj_settings_t *obj_settings_list;
double time;
struct m_rel_time rel_time;
+ struct m_color color;
};
////////////////////////////////////////////////////////////////////////////
@@ -511,6 +517,7 @@ static inline void m_option_free(const m_option_t *opt, void *dst)
#define OPT_CHOICE_OR_INT_(optname, varname, flags, minval, maxval, choices, ...) OPT_GENERAL(optname, varname, (flags) | CONF_RANGE, .min = minval, .max = maxval, M_CHOICES(choices), __VA_ARGS__)
#define OPT_TIME(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_time)
#define OPT_REL_TIME(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_rel_time)
+#define OPT_COLOR(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_color)
#define OPT_TRACKCHOICE(name, var) OPT_CHOICE_OR_INT(name, var, 0, 0, 8190, ({"no", -2}, {"auto", -1}))