Fixed incorrect logic that caused perfect-but-slow pointer tracking to be

2004-06-12  Philip Lafleur  <plafleur@cvs.gnome.org>

	* app/display/gimpdisplayshell-callbacks.c: Fixed incorrect logic that
	caused perfect-but-slow pointer tracking to be used in tools that
	don't request exact mode.

	* app/display/Makefile.am:
	* app/display/gimpdisplayshell-appearance.[ch]:
	* app/display/gimpdisplayshell-callbacks.c:
	* app/display/gimpdisplayshell.[ch]:
	* app/display/gimpdisplayshell-preview.[ch]: added
	* app/tools/gimpperspectivetool.c:
	* app/tools/gimprotatetool.c:
	* app/tools/gimpscaletool.c:
	* app/tools/gimpsheartool.c:
	* app/tools/gimptransformoptions.[ch]:
	* app/tools/gimptransformtool.[ch]: Implemented live transformation
	previews, available through tool options. Fixes bug #108172.
This commit is contained in:
Philip Lafleur 2004-06-13 01:37:29 +00:00 committed by Philip Lafleur
parent c28d70ce00
commit afb3f5c16c
17 changed files with 883 additions and 70 deletions

View File

@ -1,3 +1,22 @@
2004-06-12 Philip Lafleur <plafleur@cvs.gnome.org>
* app/display/gimpdisplayshell-callbacks.c: Fixed incorrect logic that
caused perfect-but-slow pointer tracking to be used in tools that
don't request exact mode.
* app/display/Makefile.am:
* app/display/gimpdisplayshell-appearance.[ch]:
* app/display/gimpdisplayshell-callbacks.c:
* app/display/gimpdisplayshell.[ch]:
* app/display/gimpdisplayshell-preview.[ch]: added
* app/tools/gimpperspectivetool.c:
* app/tools/gimprotatetool.c:
* app/tools/gimpscaletool.c:
* app/tools/gimpsheartool.c:
* app/tools/gimptransformoptions.[ch]:
* app/tools/gimptransformtool.[ch]: Implemented live transformation
previews, available through tool options. Fixes bug #108172.
2004-06-13 Sven Neumann <sven@gimp.org>
* app/core/gimpdrawable-blend.c (gradient_render_pixel): inline

View File

@ -48,6 +48,8 @@ libappdisplay_a_sources = \
gimpdisplayshell-filter-dialog.h \
gimpdisplayshell-layer-select.c \
gimpdisplayshell-layer-select.h \
gimpdisplayshell-preview.c \
gimpdisplayshell-preview.h \
gimpdisplayshell-render.c \
gimpdisplayshell-render.h \
gimpdisplayshell-scale.c \

View File

@ -319,6 +319,23 @@ gimp_display_shell_get_show_layer (GimpDisplayShell *shell)
return GET_OPTIONS (shell)->show_layer_boundary;
}
void
gimp_display_shell_set_show_transform (GimpDisplayShell *shell,
gboolean show)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
shell->show_transform_preview = show;
}
gboolean
gimp_display_shell_get_show_transform (GimpDisplayShell *shell)
{
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
return shell->show_transform_preview;
}
void
gimp_display_shell_set_show_grid (GimpDisplayShell *shell,
gboolean show)

View File

@ -48,6 +48,10 @@ void gimp_display_shell_set_show_layer (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_layer (GimpDisplayShell *shell);
void gimp_display_shell_set_show_transform (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_transform (GimpDisplayShell *shell);
void gimp_display_shell_set_show_grid (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_grid (GimpDisplayShell *shell);

View File

@ -61,6 +61,7 @@
#include "gimpdisplayshell-cursor.h"
#include "gimpdisplayshell-draw.h"
#include "gimpdisplayshell-layer-select.h"
#include "gimpdisplayshell-preview.h"
#include "gimpdisplayshell-render.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
@ -394,6 +395,9 @@ gimp_display_shell_canvas_expose (GtkWidget *widget,
g_free (rects);
/* draw the transform tool preview */
gimp_display_shell_preview_transform (shell);
/* draw the guides */
gimp_display_shell_draw_guides (shell);
@ -674,7 +678,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
event_mask = (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK);
if (active_tool &&
(! GIMP_DISPLAY_CONFIG (gimp->config)->perfect_mouse &&
(! GIMP_DISPLAY_CONFIG (gimp->config)->perfect_mouse ||
(gimp_tool_control_motion_mode (active_tool->control) !=
GIMP_MOTION_MODE_EXACT)))
{

View File

@ -0,0 +1,573 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "display-types.h"
#include "tools/tools-types.h"
#include "core/gimpimage.h"
#include "core/gimpdrawable.h"
#include "base/tile-manager.h"
#include "tools/gimptransformtool.h"
#include "tools/tool_manager.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-appearance.h"
#include "gimpdisplayshell-preview.h"
#include "gimpdisplayshell-transform.h"
/* local function prototypes */
static void gimp_display_shell_draw_quad (GimpDrawable *texture,
GdkDrawable *dest,
gint *x,
gint *y,
gfloat *u,
gfloat *v);
static void gimp_display_shell_draw_quad_row (GimpDrawable *texture,
GdkDrawable *dest,
GdkPixbuf *row,
gint x1,
gfloat u1,
gfloat v1,
gint x2,
gfloat u2,
gfloat v2,
gint y);
static void gimp_display_shell_trace_quad_edge (gint *dest,
gint x1,
gint y1,
gint x2,
gint y2);
/* public functions */
void
gimp_display_shell_preview_transform (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (gimp_display_shell_get_show_transform (shell))
{
GimpTool *tool;
GimpTransformTool *tr_tool;
gdouble z1, z2, z3, z4;
tool = tool_manager_get_active (shell->gdisp->gimage->gimp);
if (! GIMP_IS_TRANSFORM_TOOL (tool))
return;
tr_tool = GIMP_TRANSFORM_TOOL (tool);
if (! tr_tool->use_grid)
return;
z1 = ((tr_tool->tx2 - tr_tool->tx1) * (tr_tool->ty4 - tr_tool->ty1) -
(tr_tool->tx4 - tr_tool->tx1) * (tr_tool->ty2 - tr_tool->ty1));
z2 = ((tr_tool->tx4 - tr_tool->tx1) * (tr_tool->ty3 - tr_tool->ty1) -
(tr_tool->tx3 - tr_tool->tx1) * (tr_tool->ty4 - tr_tool->ty1));
z3 = ((tr_tool->tx4 - tr_tool->tx2) * (tr_tool->ty3 - tr_tool->ty2) -
(tr_tool->tx3 - tr_tool->tx2) * (tr_tool->ty4 - tr_tool->ty2));
z4 = ((tr_tool->tx3 - tr_tool->tx2) * (tr_tool->ty1 - tr_tool->ty2) -
(tr_tool->tx1 - tr_tool->tx2) * (tr_tool->ty3 - tr_tool->ty2));
/* only draw convex polygons */
if ((z1 * z2 > 0) && (z3 * z4 > 0))
{
gdouble dx [4];
gdouble dy [4];
gint x [4];
gint y [4];
gfloat u [4] = {0, 1, 0, 1};
gfloat v [4] = {0, 0, 1, 1};
gint i;
gimp_display_shell_transform_xy_f (shell, tr_tool->tx1, tr_tool->ty1,
dx + 0, dy + 0, FALSE);
gimp_display_shell_transform_xy_f (shell, tr_tool->tx2, tr_tool->ty2,
dx + 1, dy + 1, FALSE);
gimp_display_shell_transform_xy_f (shell, tr_tool->tx3, tr_tool->ty3,
dx + 2, dy + 2, FALSE);
gimp_display_shell_transform_xy_f (shell, tr_tool->tx4, tr_tool->ty4,
dx + 3, dy + 3, FALSE);
for (i = 0; i < 4; i++)
{
x [i] = (gint) dx [i];
y [i] = (gint) dy [i];
}
gimp_display_shell_draw_quad (tool->drawable,
GDK_DRAWABLE (GTK_WIDGET (shell->canvas)->window),
x, y, u, v);
}
}
}
/* private functions */
static void
gimp_display_shell_draw_quad (GimpDrawable *texture,
GdkDrawable *dest,
gint *x,
gint *y,
gfloat *u, /* texture coords */
gfloat *v) /* 0.0 ... 1.0 */
{
GdkPixbuf *row;
gint dwidth, dheight; /* clip boundary */
gint j, k;
gint ry;
gint *l_edge, *r_edge; /* arrays holding x-coords of edge pixels */
gint *left, *right;
gfloat dul, dvl, dur, dvr; /* left and right texture coord deltas */
gfloat u_l, v_l, u_r, v_r; /* left and right texture coord pairs */
if (! GIMP_IS_DRAWABLE (texture) ||
! GDK_IS_DRAWABLE (dest))
return;
g_return_if_fail (x != NULL && y != NULL && u != NULL && v != NULL);
left = right = NULL;
dul = dvl = dur = dvr = 0;
u_l = v_l = u_r = v_r = 0;
gdk_drawable_get_size (dest, &dwidth, &dheight);
/* is the preview in the window? */
{
gboolean in_window_x, in_window_y;
in_window_x = in_window_y = FALSE;
for (j = 0; j < 4; j++)
{
if (x [j] >= 0)
in_window_x = TRUE;
if (y [j] >= 0)
in_window_y = TRUE;
}
if (! (in_window_x && in_window_y))
return;
in_window_x = in_window_y = FALSE;
for (j = 0; j < 4; j++)
{
if (x [j] < dwidth)
in_window_x = TRUE;
if (y [j] < dheight)
in_window_y = TRUE;
}
if (! (in_window_x && in_window_y))
return;
}
row = gdk_pixbuf_new (GDK_COLORSPACE_RGB, gimp_drawable_has_alpha (texture),
8, dwidth, 1);
if (row == NULL) return;
/* scale texture coords to fit the source drawable */
for (j = 0; j < 4; j++)
{
u [j] *= tile_manager_width (texture->tiles);
v [j] *= tile_manager_height (texture->tiles);
}
/* sort vertices in order of y-coordinate */
for (j = 0; j < 4; j++)
for (k = j + 1; k < 4; k++)
if (y [k] < y [j])
{
gint tmp;
gfloat ftmp;
tmp = y [k]; y [k] = y [j]; y [j] = tmp;
tmp = x [k]; x [k] = x [j]; x [j] = tmp;
ftmp = u [k]; u [k] = u [j]; u [j] = ftmp;
ftmp = v [k]; v [k] = v [j]; v [j] = ftmp;
}
if (y [3] == y [0])
return;
l_edge = g_malloc ((y [3] - y [0]) * sizeof (gint));
r_edge = g_malloc ((y [3] - y [0]) * sizeof (gint));
/* draw the quad */
#define QUAD_TRACE_L_EDGE(a, b) \
if (y [a] != y [b]) \
{ \
gimp_display_shell_trace_quad_edge (l_edge, \
x [a], y [a], \
x [b], y [b]); \
left = l_edge; \
dul = (u [b] - u [a]) / (y [b] - y [a]); \
dvl = (v [b] - v [a]) / (y [b] - y [a]); \
u_l = u [a]; \
v_l = v [a]; \
}
#define QUAD_TRACE_R_EDGE(a, b) \
if (y [a] != y [b]) \
{ \
gimp_display_shell_trace_quad_edge (r_edge, \
x [a], y [a], \
x [b], y [b]); \
right = r_edge; \
dur = (u [b] - u [a]) / (y [b] - y [a]); \
dvr = (v [b] - v [a]) / (y [b] - y [a]); \
u_r = u [a]; \
v_r = v [a]; \
}
#define QUAD_DRAW_SECTION(a, b) \
if (y [a] != y [b]) \
for (ry = y [a]; ry < y [b]; ry++) \
{ \
if (ry >= 0 && ry < dheight) \
gimp_display_shell_draw_quad_row (texture, dest, row, \
*left, u_l, v_l, \
*right, u_r, v_r, \
ry); \
left ++; \
right ++; \
u_l += dul; \
v_l += dvl; \
u_r += dur; \
v_r += dvr; \
} \
if (((x [0] > x [1]) && (x [3] > x [2])) ||
((x [0] < x [1]) && (x [3] < x [2])))
{
/*
* v0
* |--__
* _____ |....--_ v1 ____
* | |
* | |
* _____ |.....__| ______
* |__--- v2
* v3
*/
QUAD_TRACE_L_EDGE (0, 3);
QUAD_TRACE_R_EDGE (0, 1);
QUAD_DRAW_SECTION (0, 1); /* top section */
QUAD_TRACE_R_EDGE (1, 2);
QUAD_DRAW_SECTION (1, 2); /* middle section */
QUAD_TRACE_R_EDGE (2, 3);
QUAD_DRAW_SECTION (2, 3); /* bottom section */
}
else
{
/*
* v0
* /-___
* -------- /.....-- v1 ---
* / /
* ___ v2 /__...../________
* ---_/
* v3
*/
QUAD_TRACE_L_EDGE (0, 2);
QUAD_TRACE_R_EDGE (0, 1);
QUAD_DRAW_SECTION (0, 1); /* top section */
QUAD_TRACE_R_EDGE (1, 3);
QUAD_DRAW_SECTION (1, 2); /* middle section */
QUAD_TRACE_L_EDGE (2, 3);
QUAD_DRAW_SECTION (2, 3); /* bottom section */
}
#undef QUAD_TRACE_L_EDGE
#undef QUAD_TRACE_R_EDGE
#undef QUAD_DRAW_SECTION
g_object_unref (row);
g_free (l_edge);
g_free (r_edge);
}
static void
gimp_display_shell_draw_quad_row (GimpDrawable *texture,
GdkDrawable *dest,
GdkPixbuf *row,
gint x1,
gfloat u1,
gfloat v1,
gint x2,
gfloat u2,
gfloat v2,
gint y)
{
TileManager *tiles;
guchar *pptr;
gchar bytes;
gfloat u, v;
gfloat du, dv;
gint dx;
guchar pixel [4];
guchar *cmap;
gint offset;
if (! (x2 - x1))
return;
g_return_if_fail (GIMP_IS_DRAWABLE (texture));
g_return_if_fail (GDK_IS_DRAWABLE (dest));
g_return_if_fail (GDK_IS_PIXBUF (row));
g_return_if_fail (gdk_pixbuf_get_bits_per_sample (row) == 8);
g_return_if_fail (gdk_pixbuf_get_colorspace (row) == GDK_COLORSPACE_RGB);
g_return_if_fail (gdk_pixbuf_get_has_alpha (row) ==
gimp_drawable_has_alpha (texture));
bytes = gdk_pixbuf_get_n_channels (row);
pptr = gdk_pixbuf_get_pixels (row);
tiles = gimp_drawable_data (texture);
if (x1 > x2)
{
gint tmp;
gfloat ftmp;
tmp = x2; x2 = x1; x1 = tmp;
ftmp = u2; u2 = u1; u1 = ftmp;
ftmp = v2; v2 = v1; v1 = ftmp;
}
u = u1;
v = v1;
du = (u2 - u1) / (x2 - x1);
dv = (v2 - v1) / (x2 - x1);
/* don't calculate unseen pixels */
if (x1 < 0)
{
u += du * (0 - x1);
v += dv * (0 - x1);
x1 = 0;
}
else if (x1 > gdk_pixbuf_get_width (row))
return;
if (x2 < 0)
return;
else if (x2 > gdk_pixbuf_get_width (row))
x2 = gdk_pixbuf_get_width (row);
dx = x2 - x1;
switch (gimp_drawable_type (texture))
{
case GIMP_INDEXED_IMAGE:
cmap = gimp_drawable_cmap (texture);
while (dx --)
{
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
offset = pixel [0] + pixel [0] + pixel [0];
*pptr++ = cmap [offset];
*pptr++ = cmap [offset + 1];
*pptr++ = cmap [offset + 2];
u += du;
v += dv;
}
break;
case GIMP_INDEXEDA_IMAGE:
cmap = gimp_drawable_cmap (texture);
while (dx --)
{
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
offset = pixel [0] + pixel [0] + pixel [0];
*pptr++ = cmap [offset];
*pptr++ = cmap [offset + 1];
*pptr++ = cmap [offset + 2];
*pptr++ = pixel [1];
u += du;
v += dv;
}
break;
case GIMP_GRAY_IMAGE:
while (dx --)
{
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
*pptr++ = pixel [0];
*pptr++ = pixel [0];
*pptr++ = pixel [0];
u += du;
v += dv;
}
break;
case GIMP_GRAYA_IMAGE:
while (dx --)
{
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
*pptr++ = pixel [0];
*pptr++ = pixel [0];
*pptr++ = pixel [0];
*pptr++ = pixel [1];
u += du;
v += dv;
}
break;
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
while (dx --)
{
read_pixel_data_1 (tiles, (gint) u, (gint) v, pptr);
pptr += bytes;
u += du;
v += dv;
}
break;
default:
return;
}
gdk_draw_pixbuf (dest, NULL, row, 0, 0, x1, y, x2 - x1, 1,
GDK_RGB_DITHER_NONE, 0, 0);
}
static void
gimp_display_shell_trace_quad_edge (gint *dest,
gint x1,
gint y1,
gint x2,
gint y2)
{
const gint dy = y2 - y1;
gint dx;
gchar xdir;
gint errorterm;
gint b;
gint *dptr;
if (dy == 0)
return;
g_return_if_fail (dest != NULL);
b = 0;
errorterm = 0;
dptr = dest;
if (x2 < x1)
{
dx = x1 - x2;
xdir = -1;
}
else
{
dx = x2 - x1;
xdir = 1;
}
if (dx >= dy)
{
b = dy;
while (b --)
{
*dptr = x1;
errorterm += dx;
while (errorterm > dy)
{
x1 += xdir;
errorterm -= dy;
}
dptr ++;
}
}
else if (dy >= dx)
{
b = dy;
while (b --)
{
*dptr = x1;
errorterm += dx;
if (errorterm > dy)
{
x1 += xdir;
errorterm -= dy;
}
dptr ++;
}
}
else if (dx == 0)
{
b = dy;
while (b --)
{
*dptr = x1;
dptr ++;
}
}
else /* dy == dx */
{
b = dy;
while (b --)
{
*dptr = x1;
x1 += xdir;
dptr ++;
}
}
}

View File

@ -0,0 +1,26 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_SHELL_PREVIEW_H__
#define __GIMP_DISPLAY_SHELL_PREVIEW_H__
void gimp_display_shell_preview_transform (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_PREVIEW_H__ */

View File

@ -233,92 +233,94 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
static void
gimp_display_shell_init (GimpDisplayShell *shell)
{
shell->gdisp = NULL;
shell->gdisp = NULL;
shell->menubar_manager = NULL;
shell->popup_manager = NULL;
shell->menubar_manager = NULL;
shell->popup_manager = NULL;
shell->unit = GIMP_UNIT_PIXEL;
shell->unit = GIMP_UNIT_PIXEL;
shell->scale = 1.0;
shell->other_scale = 0.0;
shell->dot_for_dot = TRUE;
shell->scale = 1.0;
shell->other_scale = 0.0;
shell->dot_for_dot = TRUE;
shell->offset_x = 0;
shell->offset_y = 0;
shell->offset_x = 0;
shell->offset_y = 0;
shell->disp_width = 0;
shell->disp_height = 0;
shell->disp_xoffset = 0;
shell->disp_yoffset = 0;
shell->disp_width = 0;
shell->disp_height = 0;
shell->disp_xoffset = 0;
shell->disp_yoffset = 0;
shell->proximity = FALSE;
shell->snap_to_guides = TRUE;
shell->snap_to_grid = FALSE;
shell->proximity = FALSE;
shell->snap_to_guides = TRUE;
shell->snap_to_grid = FALSE;
shell->select = NULL;
shell->select = NULL;
shell->hsbdata = NULL;
shell->vsbdata = NULL;
shell->hsbdata = NULL;
shell->vsbdata = NULL;
shell->canvas = NULL;
shell->grid_gc = NULL;
shell->canvas = NULL;
shell->grid_gc = NULL;
shell->hsb = NULL;
shell->vsb = NULL;
shell->qmask = NULL;
shell->hrule = NULL;
shell->vrule = NULL;
shell->origin = NULL;
shell->hsb = NULL;
shell->vsb = NULL;
shell->qmask = NULL;
shell->hrule = NULL;
shell->vrule = NULL;
shell->origin = NULL;
shell->statusbar = NULL;
shell->statusbar = NULL;
shell->render_buf = g_malloc (GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH *
shell->render_buf = g_malloc (GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH *
GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT *
3);
shell->icon_size = 32;
shell->icon_idle_id = 0;
shell->icon_size = 32;
shell->icon_idle_id = 0;
shell->current_cursor = (GdkCursorType) -1;
shell->tool_cursor = GIMP_TOOL_CURSOR_NONE;
shell->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
shell->current_cursor = (GdkCursorType) -1;
shell->tool_cursor = GIMP_TOOL_CURSOR_NONE;
shell->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
shell->override_cursor = (GdkCursorType) -1;
shell->using_override_cursor = FALSE;
shell->override_cursor = (GdkCursorType) -1;
shell->using_override_cursor = FALSE;
shell->draw_cursor = FALSE;
shell->have_cursor = FALSE;
shell->cursor_x = 0;
shell->cursor_y = 0;
shell->draw_cursor = FALSE;
shell->have_cursor = FALSE;
shell->cursor_x = 0;
shell->cursor_y = 0;
shell->padding_button = NULL;
shell->nav_ebox = NULL;
shell->show_transform_preview = FALSE;
shell->warning_dialog = NULL;
shell->info_dialog = NULL;
shell->scale_dialog = NULL;
shell->nav_popup = NULL;
shell->grid_dialog = NULL;
shell->padding_button = NULL;
shell->nav_ebox = NULL;
shell->filter_stack = NULL;
shell->filter_idle_id = 0;
shell->filters_dialog = NULL;
shell->warning_dialog = NULL;
shell->info_dialog = NULL;
shell->scale_dialog = NULL;
shell->nav_popup = NULL;
shell->grid_dialog = NULL;
shell->window_state = 0;
shell->filter_stack = NULL;
shell->filter_idle_id = 0;
shell->filters_dialog = NULL;
shell->paused_count = 0;
shell->window_state = 0;
shell->options =
shell->paused_count = 0;
shell->options =
g_object_new (GIMP_TYPE_DISPLAY_OPTIONS, NULL);
shell->fullscreen_options =
shell->fullscreen_options =
g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_FULLSCREEN, NULL);
shell->space_pressed = FALSE;
shell->space_release_pending = FALSE;
shell->scrolling = FALSE;
shell->scroll_start_x = 0;
shell->scroll_start_y = 0;
shell->space_pressed = FALSE;
shell->space_release_pending = FALSE;
shell->scrolling = FALSE;
shell->scroll_start_x = 0;
shell->scroll_start_y = 0;
shell->button_press_before_focus = FALSE;
gtk_window_set_role (GTK_WINDOW (shell), "gimp-image-window");

View File

@ -130,6 +130,8 @@ struct _GimpDisplayShell
gint cursor_x; /* software cursor X value */
gint cursor_y; /* software cursor Y value */
gboolean show_transform_preview;
GtkWidget *padding_button; /* GimpColorPanel in the NE corner */
GtkWidget *nav_ebox; /* GtkEventBox on the SE corner */

View File

@ -209,6 +209,8 @@ gimp_perspective_tool_motion (GimpTransformTool *transform_tool,
default:
break;
}
gimp_transform_tool_expose_preview (transform_tool);
}
static void

View File

@ -270,6 +270,8 @@ gimp_rotate_tool_motion (GimpTransformTool *tr_tool,
tr_tool->cx = tr_tool->curx;
tr_tool->cy = tr_tool->cury;
gimp_transform_tool_expose_preview (tr_tool);
return;
}
@ -317,6 +319,8 @@ gimp_rotate_tool_motion (GimpTransformTool *tr_tool,
{
tr_tool->trans_info[ANGLE] = tr_tool->trans_info[REAL_ANGLE];
}
gimp_transform_tool_expose_preview (tr_tool);
}
static void
@ -372,6 +376,8 @@ rotate_angle_changed (GtkWidget *widget,
gimp_rotate_tool_recalc (tr_tool, GIMP_TOOL (tr_tool)->gdisp);
gimp_transform_tool_expose_preview (tr_tool);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tr_tool));
}
@ -400,6 +406,8 @@ rotate_center_changed (GtkWidget *widget,
gimp_rotate_tool_recalc (tr_tool, GIMP_TOOL (tr_tool)->gdisp);
gimp_transform_tool_expose_preview (tr_tool);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tr_tool));
}
}

View File

@ -320,6 +320,9 @@ gimp_scale_tool_motion (GimpTransformTool *tr_tool,
tr_tool->trans_info[Y2] += diff_y;
tr_tool->trans_info[X3] += diff_x;
tr_tool->trans_info[Y3] += diff_y;
gimp_transform_tool_expose_preview (tr_tool);
return;
default:
@ -377,6 +380,8 @@ gimp_scale_tool_motion (GimpTransformTool *tr_tool,
*y1 = *y2 - dir_y * h;
*x1 = *x2 - dir_x * w;
}
gimp_transform_tool_expose_preview (tr_tool);
}
static void
@ -491,6 +496,8 @@ gimp_scale_tool_size_changed (GtkWidget *widget,
gimp_scale_tool_recalc (tr_tool, GIMP_TOOL (tr_tool)->gdisp);
gimp_transform_tool_expose_preview (tr_tool);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tr_tool));
}
}

View File

@ -262,6 +262,8 @@ gimp_shear_tool_motion (GimpTransformTool *tr_tool,
break;
}
}
gimp_transform_tool_expose_preview (tr_tool);
}
static void
@ -318,6 +320,8 @@ shear_x_mag_changed (GtkWidget *widget,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tr_tool));
}
gimp_transform_tool_expose_preview (tr_tool);
}
static void
@ -338,4 +342,6 @@ shear_y_mag_changed (GtkWidget *widget,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tr_tool));
}
gimp_transform_tool_expose_preview (tr_tool);
}

View File

@ -51,6 +51,7 @@ enum
PROP_SUPERSAMPLE,
PROP_RECURSION_LEVEL,
PROP_CLIP,
PROP_SHOW_PREVIEW,
PROP_GRID_TYPE,
PROP_GRID_SIZE,
PROP_CONSTRAIN_1,
@ -162,6 +163,10 @@ gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
"clip", NULL,
FALSE,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_PREVIEW,
"show-preview", NULL,
FALSE,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRID_TYPE,
"grid-type", NULL,
GIMP_TYPE_TRANSFORM_GRID_TYPE,
@ -216,6 +221,9 @@ gimp_transform_options_set_property (GObject *object,
case PROP_CLIP:
options->clip = g_value_get_boolean (value);
break;
case PROP_SHOW_PREVIEW:
options->show_preview = g_value_get_boolean (value);
break;
case PROP_GRID_TYPE:
options->grid_type = g_value_get_enum (value);
break;
@ -264,6 +272,9 @@ gimp_transform_options_get_property (GObject *object,
case PROP_CLIP:
g_value_set_boolean (value, options->clip);
break;
case PROP_SHOW_PREVIEW:
g_value_set_boolean (value, options->show_preview);
break;
case PROP_GRID_TYPE:
g_value_set_enum (value, options->grid_type);
break;
@ -359,6 +370,11 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the preview toggle button */
button = gimp_prop_check_button_new (config, "show-preview", _("Preview"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the grid frame */
frame = gimp_frame_new (NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

View File

@ -44,6 +44,7 @@ struct _GimpTransformOptions
gboolean supersample;
gint recursion_level;
gboolean clip;
gboolean show_preview;
GimpTransformGridType grid_type;
gint grid_size;
gboolean constrain_1;

View File

@ -49,6 +49,9 @@
#include "display/gimpdisplay.h"
#include "display/gimpprogress.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-appearance.h"
#include "display/gimpdisplayshell-transform.h"
#ifdef __GNUC__
#warning FIXME #include "gui/gui-types.h"
@ -137,13 +140,15 @@ static void gimp_transform_tool_response (GtkWidget *widget,
gint response_id,
GimpTransformTool *tr_tool);
static void gimp_transform_tool_notify_type (GimpTransformOptions *options,
GParamSpec *pspec,
GimpTransformTool *tr_tool);
static void gimp_transform_tool_notify_grid (GimpTransformOptions *options,
GParamSpec *pspec,
GimpTransformTool *tr_tool);
static void gimp_transform_tool_notify_type (GimpTransformOptions *options,
GParamSpec *pspec,
GimpTransformTool *tr_tool);
static void gimp_transform_tool_notify_grid (GimpTransformOptions *options,
GParamSpec *pspec,
GimpTransformTool *tr_tool);
static void gimp_transform_tool_notify_preview (GimpTransformOptions *options,
GParamSpec *pspec,
GimpTransformTool *tr_tool);
static GimpDrawToolClass *parent_class = NULL;
@ -287,6 +292,10 @@ gimp_transform_tool_constructor (GType type,
"notify::grid-size",
G_CALLBACK (gimp_transform_tool_notify_grid),
tr_tool, 0);
g_signal_connect_object (tool->tool_info->tool_options,
"notify::show-preview",
G_CALLBACK (gimp_transform_tool_notify_preview),
tr_tool, 0);
}
return object;
@ -742,14 +751,14 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
k = tr_tool->ngx + tr_tool->ngy;
for (i = 0, gci = 0; i < k; i++, gci += 4)
{
{
gimp_draw_tool_draw_line (draw_tool,
tr_tool->tgrid_coords[gci],
tr_tool->tgrid_coords[gci + 1],
tr_tool->tgrid_coords[gci + 2],
tr_tool->tgrid_coords[gci + 3],
FALSE);
}
}
}
/* draw the tool handles */
@ -1105,11 +1114,92 @@ gimp_transform_tool_transform_bounding_box (GimpTransformTool *tr_tool)
}
}
void
gimp_transform_tool_expose_preview (GimpTransformTool *tr_tool)
{
static gint last_x = 0,
last_y = 0,
last_w = 0,
last_h = 0;
GimpDisplayShell *shell;
GimpTransformOptions *options;
gdouble dx [4], dy [4];
gint area_x, area_y, area_w, area_h;
gint i;
g_return_if_fail (GIMP_IS_TRANSFORM_TOOL (tr_tool));
options = GIMP_TRANSFORM_OPTIONS (GIMP_TOOL (tr_tool)->tool_info->tool_options);
if (! (tr_tool->use_grid && options->show_preview))
return;
g_return_if_fail (GIMP_IS_DISPLAY (GIMP_DRAW_TOOL (tr_tool)->gdisp));
shell = GIMP_DISPLAY_SHELL (GIMP_DRAW_TOOL (tr_tool)->gdisp->shell);
gimp_display_shell_transform_xy_f (shell, tr_tool->tx1, tr_tool->ty1,
dx + 0, dy + 0, FALSE);
gimp_display_shell_transform_xy_f (shell, tr_tool->tx2, tr_tool->ty2,
dx + 1, dy + 1, FALSE);
gimp_display_shell_transform_xy_f (shell, tr_tool->tx3, tr_tool->ty3,
dx + 2, dy + 2, FALSE);
gimp_display_shell_transform_xy_f (shell, tr_tool->tx4, tr_tool->ty4,
dx + 3, dy + 3, FALSE);
/* find bounding box around preview */
area_x = area_w = (gint) dx [0];
area_y = area_h = (gint) dy [0];
for (i = 1; i < 4; i++)
{
if (dx [i] < area_x)
area_x = (gint) dx [i];
else if (dx [i] > area_w)
area_w = (gint) dx [i];
if (dy [i] < area_y)
area_y = (gint) dy [i];
else if (dy [i] > area_h)
area_h = (gint) dy [i];
}
area_w -= area_x;
area_h -= area_y;
gimp_display_shell_expose_area (shell,
MIN (area_x, last_x),
MIN (area_y, last_y),
MAX (area_w, last_w) + ABS (last_x - area_x),
MAX (area_h, last_h) + ABS (last_y - area_y));
/* area of last preview must be re-exposed to avoid leaving artifacts */
last_x = area_x;
last_y = area_y;
last_w = area_w;
last_h = area_h;
}
static void
gimp_transform_tool_halt (GimpTransformTool *tr_tool)
{
GimpTool *tool = GIMP_TOOL (tr_tool);
if (GIMP_IS_DISPLAY (GIMP_DRAW_TOOL (tr_tool)->gdisp))
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (GIMP_DRAW_TOOL (tr_tool)->gdisp->shell);
if (gimp_display_shell_get_show_transform (shell))
{
gimp_display_shell_set_show_transform (shell, FALSE);
/* get rid of preview artifacts left outside the drawable's area */
gimp_transform_tool_expose_preview (tr_tool);
}
}
if (tr_tool->original)
{
tile_manager_unref (tr_tool->original);
@ -1328,6 +1418,12 @@ static void
gimp_transform_tool_prepare (GimpTransformTool *tr_tool,
GimpDisplay *gdisp)
{
GimpTransformOptions *options;
options = GIMP_TRANSFORM_OPTIONS (GIMP_TOOL (tr_tool)->tool_info->tool_options);
gimp_display_shell_set_show_transform (GIMP_DISPLAY_SHELL (gdisp->shell),
options->show_preview);
if (tr_tool->info_dialog)
{
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (tr_tool->info_dialog->shell),
@ -1373,6 +1469,9 @@ gimp_transform_tool_response (GtkWidget *widget,
/* recalculate the tool's transformation matrix */
gimp_transform_tool_recalc (tr_tool, tool->gdisp);
/* update preview */
gimp_transform_tool_expose_preview (tr_tool);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
break;
@ -1422,3 +1521,28 @@ gimp_transform_tool_notify_grid (GimpTransformOptions *options,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tr_tool));
}
static void
gimp_transform_tool_notify_preview (GimpTransformOptions *options,
GParamSpec *pspec,
GimpTransformTool *tr_tool)
{
GimpDisplayShell *shell;
gboolean show_preview;
if (! GIMP_IS_DISPLAY (GIMP_DRAW_TOOL (tr_tool)->gdisp))
return;
shell = GIMP_DISPLAY_SHELL (GIMP_DRAW_TOOL (tr_tool)->gdisp->shell);
gimp_display_shell_set_show_transform (shell, options->show_preview);
/* expose area to clean up if preview is being turned off */
show_preview = options->show_preview;
options->show_preview = TRUE;
gimp_transform_tool_expose_preview (tr_tool);
options->show_preview = show_preview;
}

View File

@ -120,6 +120,6 @@ struct _GimpTransformToolClass
GType gimp_transform_tool_get_type (void) G_GNUC_CONST;
void gimp_transform_tool_transform_bounding_box (GimpTransformTool *tr_tool);
void gimp_transform_tool_expose_preview (GimpTransformTool *tr_tool);
#endif /* __GIMP_TRANSFORM_TOOL_H__ */