diff src/layout_image.c @ 530:1d67ef911fa8

fixed connected zoom and scroll that didn't work in some cases http://sourceforge.net/tracker/index.php?func=detail&aid=1952429&group_id=222125&atid=1054680
author nadvornik
date Tue, 29 Apr 2008 17:52:12 +0000
parents 8815fea478ee
children 905688aa2317
line wrap: on
line diff
--- a/src/layout_image.c	Sun Apr 27 23:31:20 2008 +0000
+++ b/src/layout_image.c	Tue Apr 29 17:52:12 2008 +0000
@@ -1046,9 +1046,28 @@
 
 void layout_image_scroll(LayoutWindow *lw, gint x, gint y)
 {
+	gdouble dx, dy;
+	gint width, height, i;
 	if (!layout_valid(&lw)) return;
 
 	image_scroll(lw->image, x, y);
+
+	image_get_image_size(lw->image, &width, &height);
+	dx = (gdouble) x / width;
+	dy = (gdouble) y / height;
+	
+	for (i = 0; i < MAX_SPLIT_IMAGES; i++)
+		{
+		if (lw->split_images[i] && lw->split_images[i] != lw->image && lw->connect_scroll)
+			{
+			gdouble sx, sy;
+			image_get_scroll_center(lw->split_images[i], &sx, &sy);
+			sx += dx;
+			sy += dy;
+			image_set_scroll_center(lw->split_images[i], sx, sy);
+			}
+		}
+
 }
 
 void layout_image_zoom_adjust(LayoutWindow *lw, gdouble increment)
@@ -1065,6 +1084,20 @@
 		}
 }
 
+void layout_image_zoom_adjust_at_point(LayoutWindow *lw, gdouble increment, gint x, gint y)
+{
+	gint i;
+	if (!layout_valid(&lw)) return;
+
+	image_zoom_adjust_at_point(lw->image, increment, x, y);
+
+	for (i = 0; i < MAX_SPLIT_IMAGES; i++)
+		{
+		if (lw->split_images[i] && lw->split_images[i] != lw->image && lw->connect_zoom)
+			image_zoom_adjust_at_point(lw->split_images[i], increment, x, y);
+		}
+}
+
 void layout_image_zoom_set(LayoutWindow *lw, gdouble zoom)
 {
 	gint i;
@@ -1582,10 +1615,10 @@
 		switch (direction)
 			{
 			case GDK_SCROLL_UP:
-				image_zoom_adjust_at_point(imd, get_zoom_increment(), x, y);
+				layout_image_zoom_adjust_at_point(lw, get_zoom_increment(), x, y);
 				break;
 			case GDK_SCROLL_DOWN:
-				image_zoom_adjust_at_point(imd, -get_zoom_increment(), x, y);
+				layout_image_zoom_adjust_at_point(lw, -get_zoom_increment(), x, y);
 				break;
 			default:
 				break;