summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2013-02-12 20:24:30 +0100
committerDaniel Friesel <derf@finalrewind.org>2013-02-12 20:24:30 +0100
commit2bb1b9e35cd1984e8e5529873bcf0713058914b4 (patch)
tree8c13305358c73993f6b7a3450ab0430b36fdc6d0 /src
parentacae8f069e69a7abd34910820c58570bf7b3d89f (diff)
patch by sdaau: button bindings for zoom in / out
Diffstat (limited to 'src')
-rw-r--r--src/events.c60
-rw-r--r--src/options.h2
2 files changed, 62 insertions, 0 deletions
diff --git a/src/events.c b/src/events.c
index dcd1aa1..fadae9b 100644
--- a/src/events.c
+++ b/src/events.c
@@ -152,6 +152,10 @@ void init_buttonbindings(void)
cur_bb = &buttons.blur;
else if (!strcmp(action, "rotate"))
cur_bb = &buttons.rotate;
+ else if (!strcmp(action, "zoom_in"))
+ cur_bb = &buttons.zoom_in;
+ else if (!strcmp(action, "zoom_out"))
+ cur_bb = &buttons.zoom_out;
else
weprintf("buttons: Invalid action: %s", action);
@@ -246,6 +250,62 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
winwid->im_click_offset_y = (winwid->click_offset_y
- winwid->im_y) / winwid->old_zoom;
+ } else if (feh_is_bb(&buttons.zoom_in, button, state)) {
+ D(("Zoom_In Button Press event\n"));
+ D(("click offset is %d,%d\n", ev->xbutton.x, ev->xbutton.y));
+ winwid->click_offset_x = ev->xbutton.x;
+ winwid->click_offset_y = ev->xbutton.y;
+ winwid->old_zoom = winwid->zoom;
+
+ /* required to adjust the image position in zoom mode */
+ winwid->im_click_offset_x = (winwid->click_offset_x
+ - winwid->im_x) / winwid->old_zoom;
+ winwid->im_click_offset_y = (winwid->click_offset_y
+ - winwid->im_y) / winwid->old_zoom;
+
+ /* copied from zoom_in, keyevents.c */
+ winwid->zoom = winwid->zoom * 1.25;
+
+ if (winwid->zoom > ZOOM_MAX)
+ winwid->zoom = ZOOM_MAX;
+
+ /* copied from below (ZOOM, feh_event_handle_MotionNotify) */
+ winwid->im_x = winwid->click_offset_x
+ - (winwid->im_click_offset_x * winwid->zoom);
+ winwid->im_y = winwid->click_offset_y
+ - (winwid->im_click_offset_y * winwid->zoom);
+
+ winwidget_sanitise_offsets(winwid);
+ winwidget_render_image(winwid, 0, 0);
+
+ } else if (feh_is_bb(&buttons.zoom_out, button, state)) {
+ D(("Zoom_Out Button Press event\n"));
+ D(("click offset is %d,%d\n", ev->xbutton.x, ev->xbutton.y));
+ winwid->click_offset_x = ev->xbutton.x;
+ winwid->click_offset_y = ev->xbutton.y;
+ winwid->old_zoom = winwid->zoom;
+
+ /* required to adjust the image position in zoom mode */
+ winwid->im_click_offset_x = (winwid->click_offset_x
+ - winwid->im_x) / winwid->old_zoom;
+ winwid->im_click_offset_y = (winwid->click_offset_y
+ - winwid->im_y) / winwid->old_zoom;
+
+ /* copied from zoom_out, keyevents.c */
+ winwid->zoom = winwid->zoom * 0.80;
+
+ if (winwid->zoom < ZOOM_MIN)
+ winwid->zoom = ZOOM_MIN;
+
+ /* copied from below (ZOOM, feh_event_handle_MotionNotify) */
+ winwid->im_x = winwid->click_offset_x
+ - (winwid->im_click_offset_x * winwid->zoom);
+ winwid->im_y = winwid->click_offset_y
+ - (winwid->im_click_offset_y * winwid->zoom);
+
+ winwidget_sanitise_offsets(winwid);
+ winwidget_render_image(winwid, 0, 0);
+
} else if (feh_is_bb(&buttons.reload, button, state)) {
D(("Reload Button Press event\n"));
feh_reload_image(winwid, 0, 1);
diff --git a/src/options.h b/src/options.h
index f3f49eb..27d3d38 100644
--- a/src/options.h
+++ b/src/options.h
@@ -207,6 +207,8 @@ struct __fehbb {
struct __fehbutton menu;
struct __fehbutton blur;
struct __fehbutton rotate;
+ struct __fehbutton zoom_in;
+ struct __fehbutton zoom_out;
};
void init_parse_options(int argc, char **argv);