summaryrefslogtreecommitdiffstats
path: root/m_property.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-22 06:15:36 +0200
committerwm4 <wm4@nowhere>2012-10-12 10:10:31 +0200
commit45b432f4c32be5cab798a0658d9461b3a40a6d94 (patch)
tree3a460173adb5e79a648f1b04fb39d73ba4d6a721 /m_property.h
parent9939776e5ee70818d9cc4a5a7cd9f09da4239164 (diff)
downloadmpv-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.h')
-rw-r--r--m_property.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/m_property.h b/m_property.h
index 33bd7f3f7c..249a22e969 100644
--- a/m_property.h
+++ b/m_property.h
@@ -19,7 +19,9 @@
#ifndef MPLAYER_M_PROPERTY_H
#define MPLAYER_M_PROPERTY_H
-#include "m_option.h"
+#include <stdbool.h>
+
+struct m_option;
enum mp_property_action {
// Get the property type. This defines the fundamental data type read from
@@ -47,7 +49,7 @@ enum mp_property_action {
// Switch the property up/down by a given value.
// If unimplemented, the property wrapper uses the property type as
// fallback.
- // arg: double* (value to add to the property)
+ // arg: struct m_property_switch_arg*
M_PROPERTY_SWITCH,
// Set a new value from a string. The property wrapper parses this using the
@@ -62,16 +64,18 @@ enum mp_property_action {
M_PROPERTY_TO_STRING,
// Pass down an action to a sub-property.
- // arg: struct m_property_action*
+ // arg: struct m_property_action_arg*
M_PROPERTY_KEY_ACTION,
+};
- // Get wrap method.
- // arg: bool* (true: wrap/cycle, false: clamp)
- M_PROPERTY_GET_WRAP,
+// Argument for M_PROPERTY_SWITCH
+struct m_property_switch_arg {
+ double inc; // value to add to property, or cycle direction
+ bool wrap; // whether value should wrap around on over/underflow
};
// Argument for M_PROPERTY_KEY_ACTION
-struct m_property_action {
+struct m_property_action_arg {
const char* key;
int action;
void* arg;
@@ -103,7 +107,7 @@ int m_property_do(const struct m_option* prop_list, const char* property_name,
int action, void* arg, void *ctx);
// Print a list of properties.
-void m_properties_print_help_list(const m_option_t* list);
+void m_properties_print_help_list(const struct m_option* list);
// Expand a property string.
/* This function allows to print strings containing property values.