aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2019-08-25 12:15:16 +0200
committerHarry Jeffery <harry@exec64.co.uk>2019-08-25 19:18:16 +0100
commit3bc2f66dc432d195811ed3c7b4f0d9d7d71f2b00 (patch)
tree2a5b47fe8a8038ae52543222873540f36d2f5225
parent11d24cbe669b37ee7a126a66a6348b12f47ce476 (diff)
downloadimv-3bc2f66dc432d195811ed3c7b4f0d9d7d71f2b00.tar.gz
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.
-rw-r--r--doc/imv.1.txt4
-rw-r--r--files/imv_config1
-rw-r--r--src/imv.c34
3 files changed, 32 insertions, 7 deletions
diff --git a/doc/imv.1.txt b/doc/imv.1.txt
index 5d4ec2b..ad42658 100644
--- a/doc/imv.1.txt
+++ b/doc/imv.1.txt
@@ -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'.
diff --git a/files/imv_config b/files/imv_config
index abcdf24..11a2013 100644
--- a/files/imv_config
+++ b/files/imv_config
@@ -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
diff --git a/src/imv.c b/src/imv.c
index 8b57926..d8f8304 100644
--- a/src/imv.c
+++ b/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;