Commit 9c4e6f4a authored by Sven Neumann's avatar Sven Neumann
Browse files

Special case the clone tool.


--Sven
parent aa9621e0
Sat May 15 14:11:46 MEST 1999 Sven Neumann <sven@gimp.org>
* app/clone.c
* app/paint_core.c: handle the clone tool differently (works as
usual without the line preview) until I figure out something
nicer.
Sat May 15 03:15:49 MEST 1999 Sven Neumann <sven@gimp.org>
* app/paint_core.c: Works even better if the cursor position is
......
......@@ -339,11 +339,49 @@ clone_paint_func (PaintCore *paint_core,
src_gdisp->canvas->window,
active_tool);
else if (state == MOTION_PAINT)
draw_core_resume (paint_core->core, active_tool);
draw_core_resume (paint_core->core, active_tool);
return NULL;
}
void
clone_cursor_update (tool, mevent, gdisp_ptr)
Tool *tool;
GdkEventMotion *mevent;
gpointer gdisp_ptr;
{
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
int x, y;
gdisp = (GDisplay *) gdisp_ptr;
gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y,
&x, &y, TRUE, FALSE);
if ((layer = gimage_get_active_layer (gdisp->gimage)))
{
int off_x, off_y;
drawable_offsets (GIMP_DRAWABLE(layer), &off_x, &off_y);
if (x >= off_x && y >= off_y &&
x < (off_x + drawable_width (GIMP_DRAWABLE(layer))) &&
y < (off_y + drawable_height (GIMP_DRAWABLE(layer))))
{
/* One more test--is there a selected region?
* if so, is cursor inside?
*/
if (gimage_mask_is_empty (gdisp->gimage))
ctype = GDK_PENCIL;
else if (gimage_mask_value (gdisp->gimage, x, y))
ctype = GDK_PENCIL;
}
}
gdisplay_install_tool_cursor (gdisp, ctype);
}
Tool *
tools_new_clone ()
{
......@@ -361,6 +399,9 @@ tools_new_clone ()
}
tool = paint_core_new (CLONE);
/* the clone tool provides its own cursor_update_function
until I figure out somethinh nicer -- Sven */
tool->cursor_update_func = clone_cursor_update;
private = (PaintCore *) tool->private;
private->paint_func = clone_paint_func;
......@@ -382,7 +423,7 @@ clone_draw (Tool *tool)
paint_core = (PaintCore *) tool->private;
if (clone_options->type == IMAGE_CLONE)
if (paint_core->core->gc != NULL && clone_options->type == IMAGE_CLONE)
{
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
......@@ -548,6 +589,7 @@ clone_motion (PaintCore *paint_core,
SOFT, CONSTANT);
}
static void
clone_line_image (GImage *dest,
GImage *src,
......
......@@ -339,11 +339,49 @@ clone_paint_func (PaintCore *paint_core,
src_gdisp->canvas->window,
active_tool);
else if (state == MOTION_PAINT)
draw_core_resume (paint_core->core, active_tool);
draw_core_resume (paint_core->core, active_tool);
return NULL;
}
void
clone_cursor_update (tool, mevent, gdisp_ptr)
Tool *tool;
GdkEventMotion *mevent;
gpointer gdisp_ptr;
{
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
int x, y;
gdisp = (GDisplay *) gdisp_ptr;
gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y,
&x, &y, TRUE, FALSE);
if ((layer = gimage_get_active_layer (gdisp->gimage)))
{
int off_x, off_y;
drawable_offsets (GIMP_DRAWABLE(layer), &off_x, &off_y);
if (x >= off_x && y >= off_y &&
x < (off_x + drawable_width (GIMP_DRAWABLE(layer))) &&
y < (off_y + drawable_height (GIMP_DRAWABLE(layer))))
{
/* One more test--is there a selected region?
* if so, is cursor inside?
*/
if (gimage_mask_is_empty (gdisp->gimage))
ctype = GDK_PENCIL;
else if (gimage_mask_value (gdisp->gimage, x, y))
ctype = GDK_PENCIL;
}
}
gdisplay_install_tool_cursor (gdisp, ctype);
}
Tool *
tools_new_clone ()
{
......@@ -361,6 +399,9 @@ tools_new_clone ()
}
tool = paint_core_new (CLONE);
/* the clone tool provides its own cursor_update_function
until I figure out somethinh nicer -- Sven */
tool->cursor_update_func = clone_cursor_update;
private = (PaintCore *) tool->private;
private->paint_func = clone_paint_func;
......@@ -382,7 +423,7 @@ clone_draw (Tool *tool)
paint_core = (PaintCore *) tool->private;
if (clone_options->type == IMAGE_CLONE)
if (paint_core->core->gc != NULL && clone_options->type == IMAGE_CLONE)
{
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
......@@ -548,6 +589,7 @@ clone_motion (PaintCore *paint_core,
SOFT, CONSTANT);
}
static void
clone_line_image (GImage *dest,
GImage *src,
......
......@@ -339,11 +339,49 @@ clone_paint_func (PaintCore *paint_core,
src_gdisp->canvas->window,
active_tool);
else if (state == MOTION_PAINT)
draw_core_resume (paint_core->core, active_tool);
draw_core_resume (paint_core->core, active_tool);
return NULL;
}
void
clone_cursor_update (tool, mevent, gdisp_ptr)
Tool *tool;
GdkEventMotion *mevent;
gpointer gdisp_ptr;
{
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
int x, y;
gdisp = (GDisplay *) gdisp_ptr;
gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y,
&x, &y, TRUE, FALSE);
if ((layer = gimage_get_active_layer (gdisp->gimage)))
{
int off_x, off_y;
drawable_offsets (GIMP_DRAWABLE(layer), &off_x, &off_y);
if (x >= off_x && y >= off_y &&
x < (off_x + drawable_width (GIMP_DRAWABLE(layer))) &&
y < (off_y + drawable_height (GIMP_DRAWABLE(layer))))
{
/* One more test--is there a selected region?
* if so, is cursor inside?
*/
if (gimage_mask_is_empty (gdisp->gimage))
ctype = GDK_PENCIL;
else if (gimage_mask_value (gdisp->gimage, x, y))
ctype = GDK_PENCIL;
}
}
gdisplay_install_tool_cursor (gdisp, ctype);
}
Tool *
tools_new_clone ()
{
......@@ -361,6 +399,9 @@ tools_new_clone ()
}
tool = paint_core_new (CLONE);
/* the clone tool provides its own cursor_update_function
until I figure out somethinh nicer -- Sven */
tool->cursor_update_func = clone_cursor_update;
private = (PaintCore *) tool->private;
private->paint_func = clone_paint_func;
......@@ -382,7 +423,7 @@ clone_draw (Tool *tool)
paint_core = (PaintCore *) tool->private;
if (clone_options->type == IMAGE_CLONE)
if (paint_core->core->gc != NULL && clone_options->type == IMAGE_CLONE)
{
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
......@@ -548,6 +589,7 @@ clone_motion (PaintCore *paint_core,
SOFT, CONSTANT);
}
static void
clone_line_image (GImage *dest,
GImage *src,
......
......@@ -242,7 +242,6 @@ paint_core_button_press (tool, bevent, gdisp_ptr)
paint_core->lastpressure = paint_core->curpressure;
paint_core->lastxtilt = paint_core->curxtilt;
paint_core->lastytilt = paint_core->curytilt;
;
}
else
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
......@@ -416,6 +415,7 @@ paint_core_control (tool, action, gdisp_ptr)
}
}
void
paint_core_draw (tool)
Tool * tool;
......@@ -470,6 +470,7 @@ paint_core_new (type)
private = (PaintCore *) g_malloc (sizeof (PaintCore));
private->core = draw_core_new (paint_core_draw);
private->pick_colors = FALSE;
tool->type = type;
......
......@@ -339,11 +339,49 @@ clone_paint_func (PaintCore *paint_core,
src_gdisp->canvas->window,
active_tool);
else if (state == MOTION_PAINT)
draw_core_resume (paint_core->core, active_tool);
draw_core_resume (paint_core->core, active_tool);
return NULL;
}
void
clone_cursor_update (tool, mevent, gdisp_ptr)
Tool *tool;
GdkEventMotion *mevent;
gpointer gdisp_ptr;
{
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
int x, y;
gdisp = (GDisplay *) gdisp_ptr;
gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y,
&x, &y, TRUE, FALSE);
if ((layer = gimage_get_active_layer (gdisp->gimage)))
{
int off_x, off_y;
drawable_offsets (GIMP_DRAWABLE(layer), &off_x, &off_y);
if (x >= off_x && y >= off_y &&
x < (off_x + drawable_width (GIMP_DRAWABLE(layer))) &&
y < (off_y + drawable_height (GIMP_DRAWABLE(layer))))
{
/* One more test--is there a selected region?
* if so, is cursor inside?
*/
if (gimage_mask_is_empty (gdisp->gimage))
ctype = GDK_PENCIL;
else if (gimage_mask_value (gdisp->gimage, x, y))
ctype = GDK_PENCIL;
}
}
gdisplay_install_tool_cursor (gdisp, ctype);
}
Tool *
tools_new_clone ()
{
......@@ -361,6 +399,9 @@ tools_new_clone ()
}
tool = paint_core_new (CLONE);
/* the clone tool provides its own cursor_update_function
until I figure out somethinh nicer -- Sven */
tool->cursor_update_func = clone_cursor_update;
private = (PaintCore *) tool->private;
private->paint_func = clone_paint_func;
......@@ -382,7 +423,7 @@ clone_draw (Tool *tool)
paint_core = (PaintCore *) tool->private;
if (clone_options->type == IMAGE_CLONE)
if (paint_core->core->gc != NULL && clone_options->type == IMAGE_CLONE)
{
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
......@@ -548,6 +589,7 @@ clone_motion (PaintCore *paint_core,
SOFT, CONSTANT);
}
static void
clone_line_image (GImage *dest,
GImage *src,
......
......@@ -339,11 +339,49 @@ clone_paint_func (PaintCore *paint_core,
src_gdisp->canvas->window,
active_tool);
else if (state == MOTION_PAINT)
draw_core_resume (paint_core->core, active_tool);
draw_core_resume (paint_core->core, active_tool);
return NULL;
}
void
clone_cursor_update (tool, mevent, gdisp_ptr)
Tool *tool;
GdkEventMotion *mevent;
gpointer gdisp_ptr;
{
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
int x, y;
gdisp = (GDisplay *) gdisp_ptr;
gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y,
&x, &y, TRUE, FALSE);
if ((layer = gimage_get_active_layer (gdisp->gimage)))
{
int off_x, off_y;
drawable_offsets (GIMP_DRAWABLE(layer), &off_x, &off_y);
if (x >= off_x && y >= off_y &&
x < (off_x + drawable_width (GIMP_DRAWABLE(layer))) &&
y < (off_y + drawable_height (GIMP_DRAWABLE(layer))))
{
/* One more test--is there a selected region?
* if so, is cursor inside?
*/
if (gimage_mask_is_empty (gdisp->gimage))
ctype = GDK_PENCIL;
else if (gimage_mask_value (gdisp->gimage, x, y))
ctype = GDK_PENCIL;
}
}
gdisplay_install_tool_cursor (gdisp, ctype);
}
Tool *
tools_new_clone ()
{
......@@ -361,6 +399,9 @@ tools_new_clone ()
}
tool = paint_core_new (CLONE);
/* the clone tool provides its own cursor_update_function
until I figure out somethinh nicer -- Sven */
tool->cursor_update_func = clone_cursor_update;
private = (PaintCore *) tool->private;
private->paint_func = clone_paint_func;
......@@ -382,7 +423,7 @@ clone_draw (Tool *tool)
paint_core = (PaintCore *) tool->private;
if (clone_options->type == IMAGE_CLONE)
if (paint_core->core->gc != NULL && clone_options->type == IMAGE_CLONE)
{
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
......@@ -548,6 +589,7 @@ clone_motion (PaintCore *paint_core,
SOFT, CONSTANT);
}
static void
clone_line_image (GImage *dest,
GImage *src,
......
......@@ -339,11 +339,49 @@ clone_paint_func (PaintCore *paint_core,
src_gdisp->canvas->window,
active_tool);
else if (state == MOTION_PAINT)
draw_core_resume (paint_core->core, active_tool);
draw_core_resume (paint_core->core, active_tool);
return NULL;
}
void
clone_cursor_update (tool, mevent, gdisp_ptr)
Tool *tool;
GdkEventMotion *mevent;
gpointer gdisp_ptr;
{
GDisplay *gdisp;
Layer *layer;
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
int x, y;
gdisp = (GDisplay *) gdisp_ptr;
gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y,
&x, &y, TRUE, FALSE);
if ((layer = gimage_get_active_layer (gdisp->gimage)))
{
int off_x, off_y;
drawable_offsets (GIMP_DRAWABLE(layer), &off_x, &off_y);
if (x >= off_x && y >= off_y &&
x < (off_x + drawable_width (GIMP_DRAWABLE(layer))) &&
y < (off_y + drawable_height (GIMP_DRAWABLE(layer))))
{
/* One more test--is there a selected region?
* if so, is cursor inside?
*/
if (gimage_mask_is_empty (gdisp->gimage))
ctype = GDK_PENCIL;
else if (gimage_mask_value (gdisp->gimage, x, y))
ctype = GDK_PENCIL;
}
}
gdisplay_install_tool_cursor (gdisp, ctype);
}
Tool *
tools_new_clone ()
{
......@@ -361,6 +399,9 @@ tools_new_clone ()
}
tool = paint_core_new (CLONE);
/* the clone tool provides its own cursor_update_function
until I figure out somethinh nicer -- Sven */
tool->cursor_update_func = clone_cursor_update;
private = (PaintCore *) tool->private;
private->paint_func = clone_paint_func;
......@@ -382,7 +423,7 @@ clone_draw (Tool *tool)
paint_core = (PaintCore *) tool->private;
if (clone_options->type == IMAGE_CLONE)
if (paint_core->core->gc != NULL && clone_options->type == IMAGE_CLONE)
{
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
......@@ -548,6 +589,7 @@ clone_motion (PaintCore *paint_core,
SOFT, CONSTANT);
}
static void
clone_line_image (GImage *dest,
GImage *src,
......
......@@ -242,7 +242,6 @@ paint_core_button_press (tool, bevent, gdisp_ptr)
paint_core->lastpressure = paint_core->curpressure;
paint_core->lastxtilt = paint_core->curxtilt;
paint_core->lastytilt = paint_core->curytilt;
;
}
else
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
......@@ -416,6 +415,7 @@ paint_core_control (tool, action, gdisp_ptr)
}
}
void
paint_core_draw (tool)
Tool * tool;
......@@ -470,6 +470,7 @@ paint_core_new (type)
private = (PaintCore *) g_malloc (sizeof (PaintCore));
private->core = draw_core_new (paint_core_draw);
private->pick_colors = FALSE;
tool->type = type;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment