From b1852e91ed8e1c5b3b30f02fa1c60764da44b6ac Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 17 Sep 2012 20:54:45 +0300 Subject: [PATCH] commands: remove separate direction arg from step commands In the internal property API for modifying a value up/down, there was both a step size parameter and separate STEP_UP / STEP_DOWN operations. This was mostly redundant; anything communicated with the latter distinction can be communicated with a negative step size. Combine the M_PROPERTY_STEP_UP and M_PROPERTY_STEP_DOWN operations into a single M_PROPERTY_STEP operation. This is mostly an internal change, but there is at least one user-visible difference: the step_property and step_property_osd commands no longer have an optional third argument to indicate direction. I think this feature was not commonly used. --- DOCS/tech/slave.txt | 7 +- command.c | 191 +++++++++++++++++++--------------------------------- input/input.c | 4 +- m_property.c | 20 ++---- m_property.h | 11 +-- 5 files changed, 82 insertions(+), 151 deletions(-) diff --git a/DOCS/tech/slave.txt b/DOCS/tech/slave.txt index 6bb1dc53c4..8bc8c9a970 100644 --- a/DOCS/tech/slave.txt +++ b/DOCS/tech/slave.txt @@ -308,12 +308,11 @@ speed_mult speed_set Set the speed to . -step_property [value] [direction] +step_property [value] Change a property by value, or increase by a default if value is - not given or zero. The direction is reversed if direction is less - than zero. + not given. -step_property_osd [value] [direction] +step_property_osd [value] Same as above, but show the new value on the OSD in the standard manner defined for that property (if any). diff --git a/command.c b/command.c index a190cdd1c1..0f13ed691c 100644 --- a/command.c +++ b/command.c @@ -238,7 +238,7 @@ static int mp_property_generic_option(struct m_option *prop, int action, case M_PROPERTY_SET: m_option_copy(opt, valptr, arg); return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP: if (opt->type == &m_option_type_choice) { int v = *(int *) valptr; int best = v; @@ -293,10 +293,8 @@ static int mp_property_playback_speed(m_option_t *prop, int action, return M_PROPERTY_ERROR; opts->playback_speed = *(float *) arg; goto set; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: - opts->playback_speed += (arg ? *(float *) arg : 0.1) * - (action == M_PROPERTY_STEP_DOWN ? -1 : 1); + case M_PROPERTY_STEP: + opts->playback_speed += (arg ? *(float *) arg : 0.1); set: M_PROPERTY_CLAMP(prop, opts->playback_speed); if (opts->playback_speed == orig_speed) @@ -446,11 +444,9 @@ static int mp_property_percent_pos(m_option_t *prop, int action, M_PROPERTY_CLAMP(prop, *(int *)arg); pos = *(int *)arg; break; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: pos = get_percent_pos(mpctx); - pos += (arg ? *(int *)arg : 10) * - (action == M_PROPERTY_STEP_UP ? 1 : -1); + pos += (arg ? *(int *)arg : 10); M_PROPERTY_CLAMP(prop, pos); break; default: @@ -475,10 +471,8 @@ static int mp_property_time_pos(m_option_t *prop, int action, M_PROPERTY_CLAMP(prop, *(double *)arg); queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, 0); return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: - queue_seek(mpctx, MPSEEK_RELATIVE, (arg ? *(double *)arg : 10.0) * - (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0), 0); + case M_PROPERTY_STEP: + queue_seek(mpctx, MPSEEK_RELATIVE, (arg ? *(double *)arg : 10.0), 0); return M_PROPERTY_OK; } return m_property_time_ro(prop, action, arg, get_current_time(mpctx)); @@ -520,10 +514,8 @@ static int mp_property_chapter(m_option_t *prop, int action, void *arg, step_all = *(int *)arg - chapter; chapter += step_all; break; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: { - step_all = (arg && *(int *)arg != 0 ? *(int *)arg : 1) - * (action == M_PROPERTY_STEP_UP ? 1 : -1); + case M_PROPERTY_STEP: { + step_all = (arg && *(int *)arg != 0 ? *(int *)arg : 1); chapter += step_all; if (chapter < 0) chapter = 0; @@ -595,14 +587,12 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg, angle = *(int *)arg; M_PROPERTY_CLAMP(prop, angle); break; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: { + case M_PROPERTY_STEP: { int step = 0; if (arg) step = *(int *)arg; if (!step) step = 1; - step *= (action == M_PROPERTY_STEP_UP ? 1 : -1); angle += step; if (angle < 1) //cycle angle = angles; @@ -681,8 +671,7 @@ static int mp_property_pause(m_option_t *prop, int action, void *arg, return M_PROPERTY_ERROR; if (mpctx->paused == (bool) * (int *)arg) return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: if (mpctx->paused) { unpause_player(mpctx); } else { @@ -716,35 +705,21 @@ static int mp_property_volume(m_option_t *prop, int action, void *arg, mixer_getbothvolume(&mpctx->mixer, &vol); return m_property_float_range(prop, action, arg, &vol); } - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: - case M_PROPERTY_SET: - break; - default: - return M_PROPERTY_NOT_IMPLEMENTED; - } - - switch (action) { case M_PROPERTY_SET: if (!arg) return M_PROPERTY_ERROR; M_PROPERTY_CLAMP(prop, *(float *) arg); mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg); return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP: if (arg && *(float *) arg <= 0) mixer_decvolume(&mpctx->mixer); else mixer_incvolume(&mpctx->mixer); return M_PROPERTY_OK; - case M_PROPERTY_STEP_DOWN: - if (arg && *(float *) arg <= 0) - mixer_incvolume(&mpctx->mixer); - else - mixer_decvolume(&mpctx->mixer); - return M_PROPERTY_OK; + default: + return M_PROPERTY_NOT_IMPLEMENTED; } - return M_PROPERTY_NOT_IMPLEMENTED; } /// Mute (RW) @@ -761,8 +736,7 @@ static int mp_property_mute(m_option_t *prop, int action, void *arg, return M_PROPERTY_ERROR; mixer_setmute(&mpctx->mixer, *(int *) arg); return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: mixer_setmute(&mpctx->mixer, !mixer_getmute(&mpctx->mixer)); return M_PROPERTY_OK; default: @@ -779,8 +753,7 @@ static int mp_property_audio_delay(m_option_t *prop, int action, return M_PROPERTY_UNAVAILABLE; switch (action) { case M_PROPERTY_SET: - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: { + case M_PROPERTY_STEP: { int ret; float delay = audio_delay; ret = m_property_delay(prop, action, arg, &audio_delay); @@ -896,11 +869,9 @@ static int mp_property_balance(m_option_t *prop, int action, void *arg, } return M_PROPERTY_OK; } - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: mixer_getbalance(&mpctx->mixer, &bal); - bal += (arg ? *(float *)arg : .1f) * - (action == M_PROPERTY_STEP_UP ? 1.f : -1.f); + bal += (arg ? *(float *)arg : .1f); M_PROPERTY_CLAMP(prop, bal); mixer_setbalance(&mpctx->mixer, bal); return M_PROPERTY_OK; @@ -967,7 +938,7 @@ static int mp_property_audio(m_option_t *prop, int action, void *arg, } return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP: case M_PROPERTY_SET: if (action == M_PROPERTY_SET && arg) tmp = *((int *) arg); @@ -1019,7 +990,7 @@ static int mp_property_video(m_option_t *prop, int action, void *arg, } return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP: case M_PROPERTY_SET: if (action == M_PROPERTY_SET && arg) tmp = *((int *) arg); @@ -1050,7 +1021,7 @@ static int mp_property_program(m_option_t *prop, int action, void *arg, demux_program_t prog; switch (action) { - case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP: case M_PROPERTY_SET: if (action == M_PROPERTY_SET && arg) prog.progid = *((int *) arg); @@ -1090,8 +1061,7 @@ static int mp_property_fullscreen(m_option_t *prop, int action, void *arg, M_PROPERTY_CLAMP(prop, *(int *) arg); if (vo_fs == !!*(int *) arg) return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: if (mpctx->video_out->config_ok) vo_control(mpctx->video_out, VOCTRL_FULLSCREEN, 0); mpctx->opts.fullscreen = vo_fs; @@ -1121,8 +1091,7 @@ static int mp_property_deinterlace(m_option_t *prop, int action, M_PROPERTY_CLAMP(prop, *(int *) arg); vf->control(vf, VFCTRL_SET_DEINTERLACE, arg); return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: vf->control(vf, VFCTRL_GET_DEINTERLACE, &deinterlace); deinterlace = !deinterlace; vf->control(vf, VFCTRL_SET_DEINTERLACE, &deinterlace); @@ -1140,8 +1109,7 @@ static int colormatrix_property_helper(m_option_t *prop, int action, // testing for an actual change is too much effort switch (action) { case M_PROPERTY_SET: - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: if (mpctx->sh_video) set_video_colorspace(mpctx->sh_video); break; @@ -1294,10 +1262,8 @@ static int mp_property_panscan(m_option_t *prop, int action, void *arg, vo_panscan = *(float *) arg; vo_control(mpctx->video_out, VOCTRL_SET_PANSCAN, NULL); return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: - vo_panscan += (arg ? *(float *) arg : 0.1) * - (action == M_PROPERTY_STEP_DOWN ? -1 : 1); + case M_PROPERTY_STEP: + vo_panscan += (arg ? *(float *) arg : 0.1); if (vo_panscan > 1) vo_panscan = 1; else if (vo_panscan < 0) @@ -1326,8 +1292,7 @@ static int mp_property_vo_flag(m_option_t *prop, int action, void *arg, M_PROPERTY_CLAMP(prop, *(int *) arg); if (*vo_var == !!*(int *) arg) return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: if (mpctx->video_out->config_ok) vo_control(mpctx->video_out, vo_ctrl, 0); return M_PROPERTY_OK; @@ -1415,10 +1380,8 @@ static int mp_property_gamma(m_option_t *prop, int action, void *arg, return M_PROPERTY_OK; } break; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: - *gamma += (arg ? *(int *) arg : 1) * - (action == M_PROPERTY_STEP_DOWN ? -1 : 1); + case M_PROPERTY_STEP: + *gamma += (arg ? *(int *) arg : 1); M_PROPERTY_CLAMP(prop, *gamma); r = set_video_colors(mpctx->sh_video, prop->name, *gamma); if (r <= 0) @@ -1549,8 +1512,7 @@ static int mp_property_sub_pos(m_option_t *prop, int action, void *arg, case M_PROPERTY_SET: if (!arg) return M_PROPERTY_ERROR; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: vo_osd_changed(OSDTYPE_SUBTITLE); default: return m_property_int_range(prop, action, arg, &sub_pos); @@ -1664,15 +1626,16 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg, *(int *) arg = global_sub_size - 1; mpctx->global_sub_pos = *(int *) arg; break; - case M_PROPERTY_STEP_UP: - mpctx->global_sub_pos += 2; - mpctx->global_sub_pos = - (mpctx->global_sub_pos % (global_sub_size + 1)) - 1; - break; - case M_PROPERTY_STEP_DOWN: - mpctx->global_sub_pos += global_sub_size + 1; - mpctx->global_sub_pos = - (mpctx->global_sub_pos % (global_sub_size + 1)) - 1; + case M_PROPERTY_STEP: + if (!arg || *(int *)arg >= 0) { + mpctx->global_sub_pos += 2; + mpctx->global_sub_pos = + (mpctx->global_sub_pos % (global_sub_size + 1)) - 1; + } else { + mpctx->global_sub_pos += global_sub_size + 1; + mpctx->global_sub_pos = + (mpctx->global_sub_pos % (global_sub_size + 1)) - 1; + } break; default: return M_PROPERTY_NOT_IMPLEMENTED; @@ -1807,10 +1770,8 @@ static int mp_property_sub_source(m_option_t *prop, int action, void *arg, mpctx->global_sub_pos = new_pos; } break; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: { - int step_all = (arg && *(int *)arg != 0 ? *(int *)arg : 1) - * (action == M_PROPERTY_STEP_UP ? 1 : -1); + case M_PROPERTY_STEP: { + int step_all = (arg && *(int *)arg != 0 ? *(int *)arg : 1); int step = (step_all > 0) ? 1 : -1; int cur_source = sub_source(mpctx); source = cur_source; @@ -1836,7 +1797,7 @@ static int mp_property_sub_source(m_option_t *prop, int action, void *arg, return M_PROPERTY_NOT_IMPLEMENTED; } --mpctx->global_sub_pos; - return mp_property_sub(prop, M_PROPERTY_STEP_UP, NULL, mpctx); + return mp_property_sub(prop, M_PROPERTY_STEP, NULL, mpctx); } /// Selected subtitles from specific source (RW) @@ -1896,10 +1857,8 @@ static int mp_property_sub_by_type(m_option_t *prop, int action, void *arg, } else new_pos = -1; break; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: { - int step_all = (arg && *(int *)arg != 0 ? *(int *)arg : 1) - * (action == M_PROPERTY_STEP_UP ? 1 : -1); + case M_PROPERTY_STEP: { + int step_all = (arg && *(int *)arg != 0 ? *(int *)arg : 1); int step = (step_all > 0) ? 1 : -1; int max_sub_pos_for_source = -1; if (!is_cur_source) @@ -1963,8 +1922,7 @@ static int mp_property_sub_alignment(m_option_t *prop, int action, case M_PROPERTY_SET: if (!arg) return M_PROPERTY_ERROR; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: vo_osd_changed(OSDTYPE_SUBTITLE); default: return m_property_choice(prop, action, arg, &sub_alignment); @@ -1984,8 +1942,7 @@ static int mp_property_sub_visibility(m_option_t *prop, int action, case M_PROPERTY_SET: if (!arg) return M_PROPERTY_ERROR; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: vo_osd_changed(OSDTYPE_SUBTITLE); if (vo_spudec) vo_osd_changed(OSDTYPE_SPU); @@ -2007,8 +1964,7 @@ static int mp_property_ass_use_margins(m_option_t *prop, int action, case M_PROPERTY_SET: if (!arg) return M_PROPERTY_ERROR; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: vo_osd_changed(OSDTYPE_SUBTITLE); default: return m_property_flag(prop, action, arg, &opts->ass_use_margins); @@ -2025,8 +1981,7 @@ static int mp_property_ass_vsfilter_aspect_compat(m_option_t *prop, int action, case M_PROPERTY_SET: if (!arg) return M_PROPERTY_ERROR; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: vo_osd_changed(OSDTYPE_SUBTITLE); default: return m_property_flag(prop, action, arg, @@ -2047,8 +2002,7 @@ static int mp_property_sub_forced_only(m_option_t *prop, int action, case M_PROPERTY_SET: if (!arg) return M_PROPERTY_ERROR; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: m_property_flag(prop, action, arg, &forced_subs_only); spudec_set_forced_subs_only(vo_spudec, forced_subs_only); return M_PROPERTY_OK; @@ -2074,15 +2028,12 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg, text_font_scale_factor = *(float *) arg; vo_osd_changed(OSDTYPE_SUBTITLE); return M_PROPERTY_OK; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: if (opts->ass_enabled) { - opts->ass_font_scale += (arg ? *(float *) arg : 0.1) * - (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0); + opts->ass_font_scale += (arg ? *(float *) arg : 0.1); M_PROPERTY_CLAMP(prop, opts->ass_font_scale); } - text_font_scale_factor += (arg ? *(float *) arg : 0.1) * - (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0); + text_font_scale_factor += (arg ? *(float *) arg : 0.1); M_PROPERTY_CLAMP(prop, text_font_scale_factor); vo_osd_changed(OSDTYPE_SUBTITLE); return M_PROPERTY_OK; @@ -2114,13 +2065,11 @@ static int mp_property_tv_color(m_option_t *prop, int action, void *arg, return tv_set_color_options(tvh, prop->offset, *(int *) arg); case M_PROPERTY_GET: return tv_get_color_options(tvh, prop->offset, arg); - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: if ((r = tv_get_color_options(tvh, prop->offset, &val)) >= 0) { if (!r) return M_PROPERTY_ERROR; - val += (arg ? *(int *) arg : 1) * - (action == M_PROPERTY_STEP_DOWN ? -1 : 1); + val += (arg ? *(int *) arg : 1); M_PROPERTY_CLAMP(prop, val); return tv_set_color_options(tvh, prop->offset, val); } @@ -2159,11 +2108,9 @@ static int mp_property_teletext_common(m_option_t *prop, int action, void *arg, result = teletext_control(mpctx->demuxer->teletext, base_ioctl + 1, arg); break; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: result = teletext_control(mpctx->demuxer->teletext, base_ioctl, &val); - val += (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? - -1 : 1); + val += (arg ? *(int *) arg : 1); result = teletext_control(mpctx->demuxer->teletext, base_ioctl + 1, &val); break; @@ -2201,11 +2148,9 @@ static int mp_property_teletext_page(m_option_t *prop, int action, void *arg, if (!mpctx->demuxer->teletext) return M_PROPERTY_UNAVAILABLE; switch (action) { - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: //This should be handled separately - val = (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? - -1 : 1); + val = (arg ? *(int *) arg : 1); result = teletext_control(mpctx->demuxer->teletext, TV_VBI_CONTROL_STEP_PAGE, &val); break; @@ -2638,14 +2583,16 @@ static bool set_property_command(MPContext *mpctx, mp_cmd_t *cmd) // set to value if (cmd->nargs > 0 && cmd->args[0].v.i >= prop->min) r = mp_property_do(pname, M_PROPERTY_SET, &cmd->args[0].v.i, mpctx); - else if (cmd->nargs > 0) - r = mp_property_do(pname, M_PROPERTY_STEP_DOWN, NULL, mpctx); - else - r = mp_property_do(pname, M_PROPERTY_STEP_UP, NULL, mpctx); + else { + int dir = 1; + if (cmd->nargs > 0) + dir = -1; + r = mp_property_do(pname, M_PROPERTY_STEP, &dir, mpctx); + } } else if (cmd->args[1].v.i) //set r = mp_property_do(pname, M_PROPERTY_SET, &cmd->args[0].v, mpctx); else // adjust - r = mp_property_do(pname, M_PROPERTY_STEP_UP, &cmd->args[0].v, mpctx); + r = mp_property_do(pname, M_PROPERTY_STEP, &cmd->args[0].v, mpctx); if (r <= 0) return 1; @@ -2834,9 +2781,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) "Ignoring step size stepping property '%s'.\n", cmd->args[0].v.s); } - r = mp_property_do(cmd->args[0].v.s, - cmd->args[2].v.i < 0 ? - M_PROPERTY_STEP_DOWN : M_PROPERTY_STEP_UP, + r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_STEP, arg, mpctx); step_prop_err: if (r == M_PROPERTY_UNKNOWN) @@ -2905,7 +2850,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) case MP_CMD_SPEED_INCR: { float v = cmd->args[0].v.f; - mp_property_do("speed", M_PROPERTY_STEP_UP, &v, mpctx); + mp_property_do("speed", M_PROPERTY_STEP, &v, mpctx); show_property_osd(mpctx, "speed"); break; } diff --git a/input/input.c b/input/input.c index af78314153..f78630a0d9 100644 --- a/input/input.c +++ b/input/input.c @@ -209,8 +209,8 @@ static const mp_cmd_t mp_cmds[] = { { MP_CMD_SET_PROPERTY, "set_property", { ARG_STRING, ARG_STRING } }, { MP_CMD_SET_PROPERTY_OSD, "set_property_osd", { ARG_STRING, ARG_STRING } }, { MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } }, - { MP_CMD_STEP_PROPERTY, "step_property", { ARG_STRING, OARG_FLOAT(0), OARG_INT(0) } }, - { MP_CMD_STEP_PROPERTY_OSD, "step_property_osd", { ARG_STRING, OARG_FLOAT(0), OARG_INT(0) } }, + { MP_CMD_STEP_PROPERTY, "step_property", { ARG_STRING, OARG_FLOAT(0) } }, + { MP_CMD_STEP_PROPERTY_OSD, "step_property_osd", { ARG_STRING, OARG_FLOAT(0) } }, { MP_CMD_SEEK_CHAPTER, "seek_chapter", { ARG_INT, OARG_INT(0) } }, { MP_CMD_SET_MOUSE_POS, "set_mouse_pos", { ARG_INT, ARG_INT } }, diff --git a/m_property.c b/m_property.c index 762ad73b7d..2c9f7237b2 100644 --- a/m_property.c +++ b/m_property.c @@ -260,10 +260,8 @@ int m_property_int_range(const m_option_t *prop, int action, M_PROPERTY_CLAMP(prop, *(int *)arg); *var = *(int *)arg; return 1; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: - *var += (arg ? *(int *)arg : 1) * - (action == M_PROPERTY_STEP_DOWN ? -1 : 1); + case M_PROPERTY_STEP: + *var += (arg ? *(int *)arg : 1); M_PROPERTY_CLAMP(prop, *var); return 1; } @@ -274,9 +272,8 @@ int m_property_choice(const m_option_t *prop, int action, void *arg, int *var) { switch (action) { - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: - *var += action == M_PROPERTY_STEP_UP ? 1 : prop->max; + case M_PROPERTY_STEP: + *var += (!arg || *(int *)arg >= 0) ? 1 : prop->max; *var %= (int)prop->max + 1; return 1; } @@ -301,8 +298,7 @@ int m_property_flag(const m_option_t *prop, int action, void *arg, int *var) { switch (action) { - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: + case M_PROPERTY_STEP: *var = *var == prop->min ? prop->max : prop->min; return 1; case M_PROPERTY_PRINT: @@ -339,10 +335,8 @@ int m_property_float_range(const m_option_t *prop, int action, M_PROPERTY_CLAMP(prop, *(float *)arg); *var = *(float *)arg; return 1; - case M_PROPERTY_STEP_UP: - case M_PROPERTY_STEP_DOWN: - *var += (arg ? *(float *)arg : 0.1) * - (action == M_PROPERTY_STEP_DOWN ? -1 : 1); + case M_PROPERTY_STEP: + *var += (arg ? *(float *)arg : 0.1); M_PROPERTY_CLAMP(prop, *var); return 1; } diff --git a/m_property.h b/m_property.h index 0a94b26335..1e377f8dc2 100644 --- a/m_property.h +++ b/m_property.h @@ -58,17 +58,10 @@ */ #define M_PROPERTY_PARSE 3 -/// Increment the current value. -/** The sign of the argument is also taken into account if applicable. - * \param arg Pointer to a variable of the right type or NULL. - */ -#define M_PROPERTY_STEP_UP 4 - -/// Decrement the current value. -/** The sign of the argument is also taken into account if applicable. +/* * \param arg Pointer to a variable of the right type or NULL. */ -#define M_PROPERTY_STEP_DOWN 5 +#define M_PROPERTY_STEP 4 /// Get a string containg a parsable representation. /** Set the variable to a newly allocated string or NULL. -- 2.11.4.GIT