diff options
author | wm4 <wm4@nowhere> | 2012-09-22 06:15:36 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-12 10:10:31 +0200 |
commit | 45b432f4c32be5cab798a0658d9461b3a40a6d94 (patch) | |
tree | 3a460173adb5e79a648f1b04fb39d73ba4d6a721 /m_property.c | |
parent | 9939776e5ee70818d9cc4a5a7cd9f09da4239164 (diff) | |
download | mpv-45b432f4c32be5cab798a0658d9461b3a40a6d94.tar.bz2 mpv-45b432f4c32be5cab798a0658d9461b3a40a6d94.tar.xz |
commands: replace "switch" with "add" and "cycle"
Now it depends on the command whether a property wraps around, or stops
at min/max valid property value.
For practically all properties, it's quite unambiguous what the "switch"
command should have done, and there's technically no need to replace it
with these new commands. More over, most properties that cycle are
boolean anyway. But it seems more orthogonal to make the difference
explicit, rather than hardcoding it. Having different commands also
makes it more explicit to the user what these commands do, both just due
to the naming, and what wrapping policy is used. The code is simpler
too.
Diffstat (limited to 'm_property.c')
-rw-r--r-- | m_property.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/m_property.c b/m_property.c index 4952c3a29c..dc856966f3 100644 --- a/m_property.c +++ b/m_property.c @@ -44,7 +44,7 @@ static int do_action(const m_option_t *prop_list, const char *name, memcpy(base, name, len); base[len] = 0; prop = m_option_list_find(prop_list, base); - struct m_property_action ka = { + struct m_property_action_arg ka = { .key = sep + 1, .action = action, .arg = arg, @@ -105,6 +105,7 @@ int m_property_do(const m_option_t *prop_list, const char *name, return r; } case M_PROPERTY_SWITCH: { + struct m_property_switch_arg *sarg = arg; if ((r = do_action(prop_list, name, M_PROPERTY_SWITCH, arg, ctx)) != M_PROPERTY_NOT_IMPLEMENTED) return r; @@ -113,10 +114,7 @@ int m_property_do(const m_option_t *prop_list, const char *name, return M_PROPERTY_NOT_IMPLEMENTED; if ((r = do_action(prop_list, name, M_PROPERTY_GET, &val, ctx)) <= 0) return r; - bool wrap = opt.type == &m_option_type_choice || - opt.type == &m_option_type_flag; - do_action(prop_list, name, M_PROPERTY_GET_WRAP, &wrap, ctx); - opt.type->add(&opt, &val, *(double*)arg, wrap); + opt.type->add(&opt, &val, sarg->inc, sarg->wrap); r = do_action(prop_list, name, M_PROPERTY_SET, &val, ctx); m_option_free(&opt, &val); return r; |