Skip to content

Commit

Permalink
fixed connected zoom and scroll that didn't work in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Apr 29, 2008
1 parent 6e5e4f7 commit 76b0903
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
37 changes: 35 additions & 2 deletions src/layout_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/layout_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 76b0903

Please sign in to comment.