aboutsummaryrefslogtreecommitdiff
path: root/src/imv.c
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2019-08-25 17:59:55 +0200
committerHarry Jeffery <harry@exec64.co.uk>2019-08-25 21:28:33 +0100
commitcd67aca62d1c1169bb35e580e3f4d9ddf708235d (patch)
tree2eea85fe2d71ab75bea17adca058d7f8f4eefecd /src/imv.c
parentecc58e5ee237b6fad308e590317ff3fc5d3475fc (diff)
downloadimv-cd67aca62d1c1169bb35e580e3f4d9ddf708235d.tar.gz
Add initial_pan option to set the starting pan position
Diffstat (limited to 'src/imv.c')
-rw-r--r--src/imv.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/imv.c b/src/imv.c
index d8f8304..b12ed98 100644
--- a/src/imv.c
+++ b/src/imv.c
@@ -114,6 +114,10 @@ struct imv {
/* scale up / down images to match window, or actual size */
enum scaling_mode scaling_mode;
+ /* initial pan factor when opening new images */
+ bool custom_start_pan;
+ double initial_pan_x, initial_pan_y;
+
struct {
/* show a solid background colour, or chequerboard pattern */
enum background_type type;
@@ -670,6 +674,18 @@ static bool parse_upscaling_method(struct imv *imv, const char *method)
return false;
}
+static bool parse_initial_pan(struct imv *imv, const char *pan_params)
+{
+ char *next_val;
+ long int val_x = strtol(pan_params, &next_val, 10);
+ long int val_y = strtol(next_val, NULL, 10);
+
+ imv->custom_start_pan = true;
+ imv->initial_pan_x = (double)val_x / (double)100;
+ imv->initial_pan_y = (double)val_y / (double)100;
+ return true;
+}
+
static void *load_paths_from_stdin(void *data)
{
struct imv *imv = data;
@@ -1064,6 +1080,10 @@ static bool setup_window(struct imv *imv)
imv->view = imv_viewport_create(ww, wh, bw, bh);
}
+ if (imv->custom_start_pan) {
+ imv_viewport_set_default_pan_factor(imv->view, imv->initial_pan_x, imv->initial_pan_y);
+ }
+
/* put us in fullscren mode to begin with if requested */
imv_window_set_fullscreen(imv->window, imv->start_fullscreen);
@@ -1319,6 +1339,10 @@ static int handle_ini_value(void *user, const char *section, const char *name,
return parse_scaling_mode(imv, value);
}
+ if (!strcmp(name, "initial_pan")) {
+ return parse_initial_pan(imv, value);
+ }
+
if (!strcmp(name, "background")) {
if (!parse_bg(imv, value)) {
return false;