mirror of https://github.com/GNOME/gimp.git
added a new function: gimp_zoom_preview_get_factor(), which is a proxy to
* libgimp/gimpzoompreview.[ch]: added a new function: gimp_zoom_preview_get_factor(), which is a proxy to get the zoom factor of the zoom model used by the zoom preview. Also renamed the zoom field of the private data of gimpzoompreview to model, since it is a gimpzoommodel. * libgimp/gimpui.def: added gimp_zoom_preview_get_factor. * plug-ins/common/nova.c: use gimp_zoom_preview_get_factor to correctly handle the position of the nova at various zoom level. There still are problems if there is a selection before when running this plugin.
This commit is contained in:
parent
9108905524
commit
66d00503a4
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2005-10-02 DindinX <dindinx@gimp.org>
|
||||
|
||||
* libgimp/gimpzoompreview.[ch]: added a new function:
|
||||
gimp_zoom_preview_get_factor(), which is a proxy to get the zoom
|
||||
factor of the zoom model used by the zoom preview.
|
||||
Also renamed the zoom field of the private data of gimpzoompreview to
|
||||
model, since it is a gimpzoommodel.
|
||||
|
||||
* libgimp/gimpui.def: added gimp_zoom_preview_get_factor.
|
||||
|
||||
* plug-ins/common/nova.c: use gimp_zoom_preview_get_factor to
|
||||
correctly handle the position of the nova at various zoom level.
|
||||
There still are problems if there is a selection before when running
|
||||
this plugin.
|
||||
|
||||
2005-10-02 Simon Budig <simon@gimp.org>
|
||||
|
||||
* app/vectors/gimpbezierstroke.c: fixed the bogus snaps. One
|
||||
|
|
|
@ -49,6 +49,7 @@ EXPORTS
|
|||
gimp_window_set_transient
|
||||
gimp_window_set_transient_for_display
|
||||
gimp_zoom_preview_get_drawable
|
||||
gimp_zoom_preview_get_factor
|
||||
gimp_zoom_preview_get_source
|
||||
gimp_zoom_preview_get_type
|
||||
gimp_zoom_preview_new
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef struct _GimpZoomPreviewPrivate GimpZoomPreviewPrivate;
|
|||
struct _GimpZoomPreviewPrivate
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
GimpZoomModel *zoom;
|
||||
GimpZoomModel *model;
|
||||
GdkRectangle extents;
|
||||
};
|
||||
|
||||
|
@ -99,9 +99,9 @@ gimp_zoom_preview_init (GimpZoomPreview *preview)
|
|||
GtkWidget *box;
|
||||
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
|
||||
|
||||
priv->zoom = gimp_zoom_model_new ();
|
||||
gimp_zoom_model_set_range (GIMP_ZOOM_MODEL (priv->zoom), 1.0, 256.0);
|
||||
g_signal_connect_swapped (priv->zoom, "zoomed",
|
||||
priv->model = gimp_zoom_model_new ();
|
||||
gimp_zoom_model_set_range (GIMP_ZOOM_MODEL (priv->model), 1.0, 256.0);
|
||||
g_signal_connect_swapped (priv->model, "zoomed",
|
||||
G_CALLBACK (gimp_zoom_preview_set_adjustments),
|
||||
preview);
|
||||
|
||||
|
@ -117,7 +117,7 @@ gimp_zoom_preview_init (GimpZoomPreview *preview)
|
|||
{
|
||||
GtkWidget *label;
|
||||
|
||||
label = gimp_prop_label_new (G_OBJECT (priv->zoom), "fraction");
|
||||
label = gimp_prop_label_new (G_OBJECT (priv->model), "fraction");
|
||||
gtk_misc_set_padding (GTK_MISC (label), 3, 3);
|
||||
gtk_box_pack_start (GTK_BOX (button_bar), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
@ -125,13 +125,13 @@ gimp_zoom_preview_init (GimpZoomPreview *preview)
|
|||
#endif
|
||||
|
||||
/* zoom out */
|
||||
button = gimp_zoom_button_new (priv->zoom,
|
||||
button = gimp_zoom_button_new (priv->model,
|
||||
GIMP_ZOOM_OUT, GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||
gtk_box_pack_start (GTK_BOX (button_bar), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
/* zoom in */
|
||||
button = gimp_zoom_button_new (priv->zoom,
|
||||
button = gimp_zoom_button_new (priv->model,
|
||||
GIMP_ZOOM_IN, GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||
gtk_box_pack_start (GTK_BOX (button_bar), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
@ -204,7 +204,7 @@ gimp_zoom_preview_size_allocate (GtkWidget *widget,
|
|||
GIMP_PREVIEW (preview)->width = MIN (width, allocation->width);
|
||||
GIMP_PREVIEW (preview)->height = MIN (height, allocation->height);
|
||||
|
||||
zoom_factor = gimp_zoom_model_get_factor (priv->zoom);
|
||||
zoom_factor = gimp_zoom_model_get_factor (priv->model);
|
||||
gimp_zoom_preview_set_adjustments (preview, zoom_factor, zoom_factor);
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ gimp_zoom_preview_get_source (GimpZoomPreview *preview,
|
|||
gdouble zoom_factor;
|
||||
GimpPreview *gimp_preview = GIMP_PREVIEW (preview);
|
||||
|
||||
zoom_factor = gimp_zoom_model_get_factor (priv->zoom);
|
||||
zoom_factor = gimp_zoom_model_get_factor (priv->model);
|
||||
*width = gimp_preview->width;
|
||||
*height = gimp_preview->height;
|
||||
|
||||
|
@ -296,7 +296,7 @@ gimp_zoom_preview_draw (GimpPreview *preview)
|
|||
drawable = priv->drawable;
|
||||
if (!drawable)
|
||||
return;
|
||||
zoom_factor = gimp_zoom_model_get_factor (priv->zoom);
|
||||
zoom_factor = gimp_zoom_model_get_factor (priv->model);
|
||||
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
|
@ -504,3 +504,11 @@ gimp_zoom_preview_get_drawable (GimpZoomPreview *preview)
|
|||
|
||||
return priv->drawable;
|
||||
}
|
||||
|
||||
gdouble
|
||||
gimp_zoom_preview_get_factor (GimpZoomPreview *preview)
|
||||
{
|
||||
GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (preview);
|
||||
|
||||
return gimp_zoom_model_get_factor (priv->model);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ guchar * gimp_zoom_preview_get_source (GimpZoomPreview *preview,
|
|||
gint *height,
|
||||
gint *bpp);
|
||||
GimpDrawable * gimp_zoom_preview_get_drawable (GimpZoomPreview *preview);
|
||||
gdouble gimp_zoom_preview_get_factor (GimpZoomPreview *preview);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -573,12 +573,19 @@ nova_center_coords_update (GimpSizeEntry *coords,
|
|||
static void
|
||||
nova_center_cursor_update (NovaCenter *center)
|
||||
{
|
||||
gint width, height;
|
||||
gint width, height;
|
||||
gdouble xoff, yoff;
|
||||
gdouble zoom;
|
||||
|
||||
gimp_preview_get_size (center->preview, &width, &height);
|
||||
xoff = center->preview->xoff;
|
||||
yoff = center->preview->yoff;
|
||||
zoom = gimp_zoom_preview_get_factor (GIMP_ZOOM_PREVIEW (center->preview));
|
||||
|
||||
center->curx = pvals.xcenter * width / center->drawable->width;
|
||||
center->cury = pvals.ycenter * height / center->drawable->height;
|
||||
center->curx = pvals.xcenter * width / center->drawable->width * zoom -
|
||||
xoff;
|
||||
center->cury = pvals.ycenter * height / center->drawable->height * zoom -
|
||||
yoff;
|
||||
|
||||
center->curx = CLAMP (center->curx, 0, width - 1);
|
||||
center->cury = CLAMP (center->cury, 0, height - 1);
|
||||
|
@ -622,18 +629,26 @@ nova_center_preview_events (GtkWidget *widget,
|
|||
GdkEvent *event,
|
||||
NovaCenter *center)
|
||||
{
|
||||
gint width, height;
|
||||
gint width, height;
|
||||
gint curx, cury;
|
||||
gdouble zoom;
|
||||
|
||||
gimp_preview_get_size (center->preview, &width, &height);
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_MOTION_NOTIFY:
|
||||
if (! (((GdkEventMotion *) event)->state & GDK_BUTTON1_MASK))
|
||||
if (! (((GdkEventMotion *) event)->state & GDK_BUTTON2_MASK))
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
gtk_widget_get_pointer (widget, ¢er->curx, ¢er->cury);
|
||||
if (((GdkEventButton *) event)->button != 2)
|
||||
break;
|
||||
gtk_widget_get_pointer (widget, &curx, &cury);
|
||||
|
||||
zoom = gimp_zoom_preview_get_factor (GIMP_ZOOM_PREVIEW (center->preview));
|
||||
center->curx = (curx + center->preview->xoff) / zoom;
|
||||
center->cury = (cury + center->preview->yoff) / zoom;
|
||||
|
||||
nova_center_cursor_draw (center);
|
||||
|
||||
|
@ -709,6 +724,7 @@ nova (GimpDrawable *drawable,
|
|||
GRand *gr;
|
||||
guchar *cache = NULL;
|
||||
gint width, height;
|
||||
gdouble zoom = 0.0;
|
||||
|
||||
gr = g_rand_new ();
|
||||
|
||||
|
@ -739,8 +755,11 @@ nova (GimpDrawable *drawable,
|
|||
{
|
||||
cache = gimp_zoom_preview_get_source (GIMP_ZOOM_PREVIEW (preview),
|
||||
&width, &height, &bpp);
|
||||
xc = (gdouble) pvals.xcenter * width / drawable->width;
|
||||
yc = (gdouble) pvals.ycenter * height / drawable->height;
|
||||
zoom = gimp_zoom_preview_get_factor (GIMP_ZOOM_PREVIEW (preview));
|
||||
xc = (gdouble) pvals.xcenter * width / drawable->width * zoom -
|
||||
preview->xoff;
|
||||
yc = (gdouble) pvals.ycenter * height / drawable->height * zoom -
|
||||
preview->yoff;
|
||||
|
||||
x1 = y1 = 0;
|
||||
x2 = width;
|
||||
|
@ -779,9 +798,9 @@ nova (GimpDrawable *drawable,
|
|||
for (col = 0, x = 0; col < x2; col++, x++)
|
||||
{
|
||||
u = (gdouble) (x - xc) /
|
||||
(pvals.radius * width / drawable->width);
|
||||
(pvals.radius * width / drawable->width * zoom);
|
||||
v = (gdouble) (y - yc) /
|
||||
(pvals.radius * height / drawable->height);
|
||||
(pvals.radius * height / drawable->height * zoom);
|
||||
l = sqrt (u * u + v * v);
|
||||
|
||||
/* This algorithm is still under construction. */
|
||||
|
|
Loading…
Reference in New Issue