diff options
author | Anton Älgmyr <anton@algmyr.se> | 2020-03-11 01:01:40 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2020-06-12 01:00:10 +0100 |
commit | a71709b889743bddc4f48a8f13a34a5075ca8ff7 (patch) | |
tree | 0ce957376ebcffeb184eb22edc5ef52383d1d02d /src/imv.c | |
parent | f968eb420c8d30d45adc1f668c15c29f5b9ee87d (diff) | |
download | imv-a71709b889743bddc4f48a8f13a34a5075ca8ff7.tar.gz |
Unify rotation commands, reset transformation properly
Diffstat (limited to 'src/imv.c')
-rw-r--r-- | src/imv.c | 25 |
1 files changed, 9 insertions, 16 deletions
@@ -180,7 +180,6 @@ static void command_prev(struct list *args, const char *argstr, void *data); static void command_goto(struct list *args, const char *argstr, void *data); static void command_zoom(struct list *args, const char *argstr, void *data); static void command_rotate(struct list *args, const char *argstr, void *data); -static void command_rotate_to(struct list *args, const char *argstr, void *data); static void command_flip(struct list *args, const char *argstr, void *data); static void command_open(struct list *args, const char *argstr, void *data); static void command_close(struct list *args, const char *argstr, void *data); @@ -501,7 +500,6 @@ struct imv *imv_create(void) imv_command_register(imv->commands, "goto", &command_goto); imv_command_register(imv->commands, "zoom", &command_zoom); imv_command_register(imv->commands, "rotate", &command_rotate); - imv_command_register(imv->commands, "rotate_to", &command_rotate_to); imv_command_register(imv->commands, "flip", &command_flip); imv_command_register(imv->commands, "open", &command_open); imv_command_register(imv->commands, "close", &command_close); @@ -1512,19 +1510,14 @@ static void command_rotate(struct list *args, const char *argstr, void *data) { (void)argstr; struct imv *imv = data; - if (args->len == 2) { - double degrees = strtod(args->items[1], NULL); - imv_viewport_rotate(imv->view, degrees); - } -} - -static void command_rotate_to(struct list *args, const char *argstr, void *data) -{ - (void)argstr; - struct imv *imv = data; - if (args->len == 2) { - double degrees = strtod(args->items[1], NULL); - imv_viewport_rotate_to(imv->view, degrees); + if (args->len == 3) { + if (!strcmp(args->items[1], "by")) { + double degrees = strtod(args->items[2], NULL); + imv_viewport_rotate_by(imv->view, degrees); + } else if (!strcmp(args->items[1], "to")) { + double degrees = strtod(args->items[2], NULL); + imv_viewport_rotate_to(imv->view, degrees); + } } } @@ -1628,7 +1621,7 @@ static void command_reset(struct list *args, const char *argstr, void *data) (void)args; (void)argstr; struct imv *imv = data; - imv_viewport_rotate_to(imv->view, 0); + imv_viewport_reset_transform(imv->view); imv->need_rescale = true; imv->need_redraw = true; } |