diff options
author | Bert <ber.t@gmx.com> | 2011-01-29 22:37:40 +0100 |
---|---|---|
committer | Bert <ber.t@gmx.com> | 2011-01-29 22:37:40 +0100 |
commit | c52c4fa69e2a6a58813fe35a5c4a1fe23661db03 (patch) | |
tree | 6ddefe9122c481495caceec023a79786e5412b84 /image.c | |
parent | 4ab4be31a7fed20c2d1bde4b76c1d22bfd4312aa (diff) |
Mouse-panning while pressing button2
Diffstat (limited to 'image.c')
-rw-r--r-- | image.c | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -230,7 +230,7 @@ int img_zoom_out(img_t *img) { return 0; } -int img_pan(img_t *img, win_t *win, pandir_t dir) { +int img_move(img_t *img, win_t *win, int dx, int dy) { int ox, oy; if (!img || !win) @@ -239,24 +239,30 @@ int img_pan(img_t *img, win_t *win, pandir_t dir) { ox = img->x; oy = img->y; + img->x += dx; + img->y += dy; + + img_check_pan(img, win); + + return ox != img->x || oy != img->y; +} + +int img_pan(img_t *img, win_t *win, pandir_t dir) { + if (!img || !win) + return 0; + switch (dir) { case PAN_LEFT: - img->x += win->w / 5; - break; + return img_move(img, win, win->w / 5, 0); case PAN_RIGHT: - img->x -= win->w / 5; - break; + return img_move(img, win, -win->w / 5, 0); case PAN_UP: - img->y += win->h / 5; - break; + return img_move(img, win, 0, win->h / 5); case PAN_DOWN: - img->y -= win->h / 5; - break; + return img_move(img, win, 0, -win->h / 5); } - img_check_pan(img, win); - - return ox != img->x || oy != img->y; + return 0; } int img_rotate(img_t *img, win_t *win, int d) { |