aboutsummaryrefslogtreecommitdiff
path: root/image.c
diff options
context:
space:
mode:
authorNick Hanley <nicholasjhanley@gmail.com>2022-01-15 17:51:31 -0500
committerGitHub <noreply@github.com>2022-01-15 18:51:31 -0400
commit2ac44709bd9a9ec8d3ab60a40a81ac7ca3ad1b57 (patch)
tree73221bb787569c4089930436ddc644490ccb2c18 /image.c
parent7a75c42b37b08f44c72f9a7c98eb6076967470fb (diff)
Add keybind to scroll to image center (#203)
There are keybinds for scrolling to the edges of an image but there's no way back to the center. This is particularly annoying while zooming.
Diffstat (limited to 'image.c')
-rw-r--r--image.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/image.c b/image.c
index 2c4eec1..6b30731 100644
--- a/image.c
+++ b/image.c
@@ -744,6 +744,14 @@ bool img_pan(img_t *img, direction_t dir, int d)
return false;
}
+bool img_pan_center(img_t *img)
+{
+ float x, y;
+ x = (img->win->w - img->w * img->zoom) / 2.0;
+ y = (img->win->h - img->h * img->zoom) / 2.0;
+ return img_pos(img, x, y);
+}
+
bool img_pan_edge(img_t *img, direction_t dir)
{
float ox, oy;