Add upscaling method command
This works the same way as the existing scale command except that it changes the upscaling method. Also did some code reduction on the scaling command.
This commit is contained in:
parent
11d24cbe66
commit
3bc2f66dc4
|
@ -136,6 +136,10 @@ Commands can be entered by pressing *:*. imv supports the following commands:
|
|||
Set the current scaling mode. Setting the mode to 'next' advances it to the
|
||||
next mode in the list.
|
||||
|
||||
*upscaling* <linear|nearest_neighbour|next>::
|
||||
Set the current upscaling method. Setting the method to 'next' advances it to the
|
||||
next method in the list.
|
||||
|
||||
*slideshow* <+amount|-amount|duration>::
|
||||
Increase or decrease the slideshow duration by the given amount in seconds,
|
||||
or set its duration directly. Aliased to 'ss'.
|
||||
|
|
|
@ -45,6 +45,7 @@ d = overlay
|
|||
p = exec echo $imv_current_file
|
||||
c = center
|
||||
s = scaling next
|
||||
<Shift+S> = upscaling next
|
||||
a = zoom actual
|
||||
r = reset
|
||||
|
||||
|
|
34
src/imv.c
34
src/imv.c
|
@ -190,6 +190,7 @@ static void command_reset(struct list *args, const char *argstr, void *data);
|
|||
static void command_next_frame(struct list *args, const char *argstr, void *data);
|
||||
static void command_toggle_playing(struct list *args, const char *argstr, void *data);
|
||||
static void command_set_scaling_mode(struct list *args, const char *argstr, void *data);
|
||||
static void command_set_upscaling_method(struct list *args, const char *argstr, void *data);
|
||||
static void command_set_slideshow_duration(struct list *args, const char *argstr, void *data);
|
||||
static void command_set_background(struct list *args, const char *argstr, void *data);
|
||||
static void command_bind(struct list *args, const char *argstr, void *data);
|
||||
|
@ -518,6 +519,7 @@ struct imv *imv_create(void)
|
|||
imv_command_register(imv->commands, "next_frame", &command_next_frame);
|
||||
imv_command_register(imv->commands, "toggle_playing", &command_toggle_playing);
|
||||
imv_command_register(imv->commands, "scaling", &command_set_scaling_mode);
|
||||
imv_command_register(imv->commands, "upscaling", &command_set_upscaling_method);
|
||||
imv_command_register(imv->commands, "slideshow", &command_set_slideshow_duration);
|
||||
imv_command_register(imv->commands, "background", &command_set_background);
|
||||
imv_command_register(imv->commands, "bind", &command_bind);
|
||||
|
@ -554,6 +556,7 @@ struct imv *imv_create(void)
|
|||
add_bind(imv, "o", "zoom -1");
|
||||
add_bind(imv, "c", "center");
|
||||
add_bind(imv, "s", "scaling next");
|
||||
add_bind(imv, "<Shift+S>", "upscaling next");
|
||||
add_bind(imv, "a", "zoom actual");
|
||||
add_bind(imv, "r", "reset");
|
||||
add_bind(imv, "<period>", "next_frame");
|
||||
|
@ -1599,13 +1602,7 @@ static void command_set_scaling_mode(struct list *args, const char *argstr, void
|
|||
if (!strcmp(mode, "next")) {
|
||||
imv->scaling_mode++;
|
||||
imv->scaling_mode %= SCALING_MODE_COUNT;
|
||||
} else if (!strcmp(mode, "none")) {
|
||||
imv->scaling_mode = SCALING_NONE;
|
||||
} else if (!strcmp(mode, "shrink")) {
|
||||
imv->scaling_mode = SCALING_DOWN;
|
||||
} else if (!strcmp(mode, "full")) {
|
||||
imv->scaling_mode = SCALING_FULL;
|
||||
} else {
|
||||
} else if (!parse_scaling_mode(imv, mode)) {
|
||||
/* no changes, don't bother to redraw */
|
||||
return;
|
||||
}
|
||||
|
@ -1614,6 +1611,29 @@ static void command_set_scaling_mode(struct list *args, const char *argstr, void
|
|||
imv->need_redraw = true;
|
||||
}
|
||||
|
||||
static void command_set_upscaling_method(struct list *args, const char *argstr, void *data)
|
||||
{
|
||||
(void)args;
|
||||
(void)argstr;
|
||||
struct imv *imv = data;
|
||||
|
||||
if (args->len != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char *mode = args->items[1];
|
||||
|
||||
if (!strcmp(mode, "next")) {
|
||||
imv->upscaling_method++;
|
||||
imv->upscaling_method %= UPSCALING_METHOD_COUNT;
|
||||
} else if (!parse_upscaling_method(imv, mode)) {
|
||||
/* no changes, don't bother to redraw */
|
||||
return;
|
||||
}
|
||||
|
||||
imv->need_redraw = true;
|
||||
}
|
||||
|
||||
static void command_set_slideshow_duration(struct list *args, const char *argstr, void *data)
|
||||
{
|
||||
(void)argstr;
|
||||
|
|
Loading…
Reference in a new issue