fixed connected zoom and scroll that didn't work in some cases
authorVladimir Nadvornik <nadvornik@suse.cz>
Tue, 29 Apr 2008 17:52:12 +0000 (17:52 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Tue, 29 Apr 2008 17:52:12 +0000 (17:52 +0000)
http://sourceforge.net/tracker/index.php?func=detail&aid=1952429&group_id=222125&atid=1054680

src/image.c
src/image.h
src/layout_image.c
src/layout_image.h

index 365b3fe..a080ac3 100644 (file)
@@ -1294,6 +1294,11 @@ void image_change_fd(ImageWindow *imd, FileData *fd, gdouble zoom)
        image_change_real(imd, fd, NULL, NULL, zoom);
 }
 
+gint image_get_image_size(ImageWindow *imd, gint *width, gint *height)
+{
+       return pixbuf_renderer_get_image_size(PIXBUF_RENDERER(imd->pr), width, height);
+}
+
 GdkPixbuf *image_get_pixbuf(ImageWindow *imd)
 {
        return pixbuf_renderer_get_pixbuf((PixbufRenderer *)imd->pr);
index aa864c4..140449a 100644 (file)
@@ -61,6 +61,7 @@ void image_change_from_collection(ImageWindow *imd, CollectionData *cd, CollectI
 CollectionData *image_get_collection(ImageWindow *imd, CollectInfo **info);
 void image_change_from_image(ImageWindow *imd, ImageWindow *source);
 
+gint image_get_image_size(ImageWindow *imd, gint *width, gint *height);
 GdkPixbuf *image_get_pixbuf(ImageWindow *imd);
 
 /* manipulation */
index c6339e9..3662fca 100644 (file)
@@ -1046,9 +1046,28 @@ void layout_image_to_root(LayoutWindow *lw)
 
 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(LayoutWindow *lw, gdouble increment)
                }
 }
 
+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 @@ static void layout_image_scroll_cb(ImageWindow *imd, GdkScrollDirection directio
                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;
index acb6818..482cf61 100644 (file)
@@ -48,6 +48,7 @@ gint layout_image_get_index(LayoutWindow *lw);
 
 void layout_image_scroll(LayoutWindow *lw, gint x, gint y);
 void layout_image_zoom_adjust(LayoutWindow *lw, gdouble increment);
+void layout_image_zoom_adjust_at_point(LayoutWindow *lw, gdouble increment, gint x, gint y);
 void layout_image_zoom_set(LayoutWindow *lw, gdouble zoom);
 void layout_image_zoom_set_fill_geometry(LayoutWindow *lw, gint vertical);
 void layout_image_alter(LayoutWindow *lw, AlterType type);