ImageWindow *imd = data;
gint width, height;
- printf("drag_cb %p\n", imd->func_drag);
pixbuf_renderer_get_scaled_size(pr, &width, &height);
if (imd->func_drag)
pixbuf_renderer_move(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr));
}
-void image_get_scroll_center(ImageWindow *imd, gfloat *x, gfloat *y)
-{
- gint src_width, src_height;
- gint src_x, src_y;
- GdkRectangle src_rect;
-
- pixbuf_renderer_get_virtual_rect(PIXBUF_RENDERER(imd->pr), &src_rect);
- pixbuf_renderer_get_scaled_size(PIXBUF_RENDERER(imd->pr), &src_width, &src_height);
-
- src_x = src_rect.x + src_rect.width / 2;
- src_y = src_rect.y + src_rect.height / 2;
-
- *x = (gfloat)src_x / src_width;
- *y = (gfloat)src_y / src_height;
-}
-
-void image_set_scroll_center(ImageWindow *imd, gfloat x, gfloat y)
-{
- gint dst_width, dst_height;
- gfloat dst_x, dst_y;
- gfloat dst_scale = pixbuf_renderer_zoom_get_scale(PIXBUF_RENDERER(imd->pr));
-
- pixbuf_renderer_get_scaled_size(PIXBUF_RENDERER(imd->pr), &dst_width, &dst_height);
-
- dst_x = x * dst_width;
- dst_y = y * dst_height;
-
- image_scroll_to_point(imd, dst_x / dst_scale, dst_y / dst_scale, 0.5, 0.5);
-}
-
-
-void image_sync_zoom_from_image(ImageWindow *imd, ImageWindow *source)
-{
- image_zoom_set(imd, image_zoom_get(source));
-}
-
-
-
/* manipulation */
void image_area_changed(ImageWindow *imd, gint x, gint y, gint width, gint height)
pixbuf_renderer_scroll_to_point((PixbufRenderer *)imd->pr, x, y, x_align, y_align);
}
+void image_get_scroll_center(ImageWindow *imd, gdouble *x, gdouble *y)
+{
+ pixbuf_renderer_get_scroll_center(PIXBUF_RENDERER(imd->pr), x, y);
+}
+
+void image_set_scroll_center(ImageWindow *imd, gdouble x, gdouble y)
+{
+ pixbuf_renderer_set_scroll_center(PIXBUF_RENDERER(imd->pr), x, y);
+}
+
+
+
void image_alter(ImageWindow *imd, AlterType type)
{
if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return;
GdkPixbuf *image_get_pixbuf(ImageWindow *imd);
-
-void image_get_scroll_center(ImageWindow *imd, gfloat *x, gfloat *y);
-void image_set_scroll_center(ImageWindow *imd, gfloat x, gfloat y);
-
-void image_sync_zoom_from_image(ImageWindow *imd, ImageWindow *source);
/* manipulation */
void image_area_changed(ImageWindow *imd, gint x, gint y, gint width, gint height);
void image_reload(ImageWindow *imd);
void image_scroll(ImageWindow *imd, gint x, gint y);
void image_scroll_to_point(ImageWindow *imd, gint x, gint y,
gdouble x_align, gdouble y_align);
+void image_get_scroll_center(ImageWindow *imd, gdouble *x, gdouble *y);
+void image_set_scroll_center(ImageWindow *imd, gdouble x, gdouble y);
void image_alter(ImageWindow *imd, AlterType type);
/* zoom */
void layout_image_set_path(LayoutWindow *lw, const gchar *path)
{
- gfloat sx, sy;
+ gdouble sx, sy;
if (!layout_valid(&lw)) return;
image_get_scroll_center(lw->image, &sx, &sy);
if (lw->split_images[i] && lw->split_images[i] != imd)
if (lw->connect_scroll)
{
- gfloat sx, sy;
- if (!(state & GDK_CONTROL_MASK))
+ gdouble sx, sy;
+ if (state & GDK_CONTROL_MASK)
{
image_get_scroll_center(imd, &sx, &sy);
}
}
}
-static gint layout_image_mouse_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
-{
-
- printf("mouse press\n");
-
-}
-
static void layout_image_button_inactive_cb(ImageWindow *imd, gint button, guint32 time,
gdouble x, gdouble y, guint state, gpointer data)
{
if (i != -1)
{
- printf("image activate %d\n", i);
layout_image_activate(lw, i);
}
gint i = image_idx(lw, imd);
- printf("drag inacive\n");
if (i != -1)
{
- printf("image activate %d\n", i);
layout_image_activate(lw, i);
}
gtk_widget_ref(lw->split_images[i]->widget);
- g_signal_connect(G_OBJECT(lw->split_images[i]->widget), "button_press_event",
- G_CALLBACK(layout_image_mouse_press_cb), lw);
-
-
if (black_window_background) image_background_set_black(lw->split_images[i], TRUE);
image_auto_refresh(lw->image, 0);
pixbuf_renderer_scroll(pr, px, py);
}
+/* get or set coordinates of viewport center in the image, in range 0.0 - 1.0 */
+
+void pixbuf_renderer_get_scroll_center(PixbufRenderer *pr, gdouble *x, gdouble *y)
+{
+ gint src_x, src_y;
+
+ src_x = pr->x_scroll + pr->vis_width / 2;
+ src_y = pr->y_scroll + pr->vis_height / 2;
+
+ *x = (gdouble)src_x / pr->width;
+ *y = (gdouble)src_y / pr->height;
+}
+
+void pixbuf_renderer_set_scroll_center(PixbufRenderer *pr, gdouble x, gdouble y)
+{
+ gdouble dst_x, dst_y;
+
+ dst_x = x * pr->width - pr->vis_width / 2 - pr->x_scroll + CLAMP(pr->subpixel_x_scroll, -1.0, 1.0);
+ dst_y = y * pr->height - pr->vis_height / 2 - pr->y_scroll + CLAMP(pr->subpixel_y_scroll, -1.0, 1.0);
+
+ pr->subpixel_x_scroll = dst_x - (int)dst_x;
+ pr->subpixel_y_scroll = dst_y - (int)dst_y;
+
+ pixbuf_renderer_scroll(pr, (int)dst_x, (int)dst_y);
+}
+
+
/*
*-------------------------------------------------------------------
* mouse
gint x_scroll; /* scroll offset of image (into width, height to start drawing) */
gint y_scroll;
+ gdouble subpixel_x_scroll; /* subpixel scroll alignment, used to prevent acumulation of rounding errors */
+ gdouble subpixel_y_scroll;
+
gdouble zoom_min;
gdouble zoom_max;
gdouble zoom; /* zoom we want (0 is auto) */
void pixbuf_renderer_scroll_to_point(PixbufRenderer *pr, gint x, gint y,
gdouble x_align, gdouble y_align);
+void pixbuf_renderer_get_scroll_center(PixbufRenderer *pr, gdouble *x, gdouble *y);
+void pixbuf_renderer_set_scroll_center(PixbufRenderer *pr, gdouble x, gdouble y);
/* zoom */
void pixbuf_renderer_zoom_adjust(PixbufRenderer *pr, gdouble increment);