Wed Apr 1 11:10:15 EST 1998 Matthew Wilson <msw@gimp.org

* app/brightness_contrast.c
	* app/by_color_select.c
	* app/color_balance.c
	* app/color_picker.c
	* app/curves.c
	* app/histogram_tool.c
	* app/hue_saturation.c
	* app/levels.c
	* app/posterize.c
	* app/threshold.c
	* app/transform_core.c: modified to call the cancel callback
	instead of the ok callback when freed.  modified to save the
	last used drawable so that we might be able to check later
	and restart the tool if need be.

	* app/disp_callbacks.c
	* app/gimage.c: modified tool restart/destruction code

	* app/tools.c
	* app/tools.h: added tools_initialize, made changes to
	be able save the last used drawable in the tool.

--Matt
This commit is contained in:
Matt Wilson 1998-04-02 04:51:44 +00:00
parent 97297cb810
commit f75645a26c
42 changed files with 593 additions and 59 deletions

View File

@ -1,3 +1,27 @@
Wed Apr 1 11:10:15 EST 1998 Matthew Wilson <msw@gimp.org
* app/brightness_contrast.c
* app/by_color_select.c
* app/color_balance.c
* app/color_picker.c
* app/curves.c
* app/histogram_tool.c
* app/hue_saturation.c
* app/levels.c
* app/posterize.c
* app/threshold.c
* app/transform_core.c: modified to call the cancel callback
instead of the ok callback when freed. modified to save the
last used drawable so that we might be able to check later
and restart the tool if need be.
* app/disp_callbacks.c
* app/gimage.c: modified tool restart/destruction code
* app/tools.c
* app/tools.h: added tools_initialize, made changes to
be able save the last used drawable in the tool.
Wed Apr 1 23:14:42 MEST 1998 Sven Neumann <sven@gimp.org> Wed Apr 1 23:14:42 MEST 1998 Sven Neumann <sven@gimp.org>
* configure.in: added checks for print-systems as suggested by * configure.in: added checks for print-systems as suggested by

View File

@ -206,6 +206,10 @@ color_balance_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -286,6 +290,8 @@ tools_new_color_balance ()
tool->cursor_update_func = color_balance_cursor_update; tool->cursor_update_func = color_balance_cursor_update;
tool->control_func = color_balance_control; tool->control_func = color_balance_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -299,7 +305,7 @@ tools_free_color_balance (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (color_balance_dialog) if (color_balance_dialog)
color_balance_ok_callback (NULL, (gpointer) color_balance_dialog); color_balance_cancel_callback (NULL, (gpointer) color_balance_dialog);
g_free (color_bal); g_free (color_bal);
} }

View File

@ -207,6 +207,10 @@ curves_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -287,6 +291,8 @@ tools_new_curves ()
tool->cursor_update_func = curves_cursor_update; tool->cursor_update_func = curves_cursor_update;
tool->control_func = curves_control; tool->control_func = curves_control;
tool->preserve = TRUE; tool->preserve = TRUE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -300,7 +306,7 @@ tools_free_curves (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (curves_dialog) if (curves_dialog)
curves_ok_callback (NULL, (gpointer) curves_dialog); curves_cancel_callback (NULL, (gpointer) curves_dialog);
g_free (_curves); g_free (_curves);
} }

View File

@ -250,6 +250,10 @@ hue_saturation_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -330,6 +334,8 @@ tools_new_hue_saturation ()
tool->cursor_update_func = hue_saturation_cursor_update; tool->cursor_update_func = hue_saturation_cursor_update;
tool->control_func = hue_saturation_control; tool->control_func = hue_saturation_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -343,7 +349,7 @@ tools_free_hue_saturation (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (hue_saturation_dialog) if (hue_saturation_dialog)
hue_saturation_ok_callback (NULL, (gpointer) hue_saturation_dialog); hue_saturation_cancel_callback (NULL, (gpointer) hue_saturation_dialog);
g_free (color_bal); g_free (color_bal);
} }

View File

@ -225,6 +225,10 @@ threshold_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -270,7 +274,9 @@ threshold_control (Tool *tool,
case HALT : case HALT :
if (threshold_dialog) if (threshold_dialog)
{ {
active_tool->preserve = TRUE;
image_map_abort (threshold_dialog->image_map); image_map_abort (threshold_dialog->image_map);
active_tool->preserve = FALSE;
threshold_dialog->image_map = NULL; threshold_dialog->image_map = NULL;
threshold_cancel_callback (NULL, (gpointer) threshold_dialog); threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
} }
@ -309,6 +315,7 @@ tools_new_threshold ()
tool->arrow_keys_func = standard_arrow_keys_func; tool->arrow_keys_func = standard_arrow_keys_func;
tool->cursor_update_func = threshold_cursor_update; tool->cursor_update_func = threshold_cursor_update;
tool->control_func = threshold_control; tool->control_func = threshold_control;
tool->preserve = FALSE;
return tool; return tool;
} }
@ -322,7 +329,7 @@ tools_free_threshold (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (threshold_dialog) if (threshold_dialog)
threshold_ok_callback (NULL, (gpointer) threshold_dialog); threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
g_free (thresh); g_free (thresh);
} }
@ -496,12 +503,15 @@ threshold_ok_callback (GtkWidget *widget,
if (GTK_WIDGET_VISIBLE (td->shell)) if (GTK_WIDGET_VISIBLE (td->shell))
gtk_widget_hide (td->shell); gtk_widget_hide (td->shell);
active_tool->preserve = TRUE;
if (!td->preview) if (!td->preview)
image_map_apply (td->image_map, threshold, (void *) td); image_map_apply (td->image_map, threshold, (void *) td);
if (td->image_map) if (td->image_map)
image_map_commit (td->image_map); image_map_commit (td->image_map);
active_tool->preserve = FALSE;
td->image_map = NULL; td->image_map = NULL;
} }
@ -527,7 +537,9 @@ threshold_cancel_callback (GtkWidget *widget,
if (td->image_map) if (td->image_map)
{ {
active_tool->preserve = TRUE;
image_map_abort (td->image_map); image_map_abort (td->image_map);
active_tool->preserve = FALSE;
gdisplays_flush (); gdisplays_flush ();
} }

View File

@ -176,6 +176,10 @@ brightness_contrast_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -253,6 +257,8 @@ tools_new_brightness_contrast ()
tool->cursor_update_func = brightness_contrast_cursor_update; tool->cursor_update_func = brightness_contrast_cursor_update;
tool->control_func = brightness_contrast_control; tool->control_func = brightness_contrast_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -266,7 +272,7 @@ tools_free_brightness_contrast (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (brightness_contrast_dialog) if (brightness_contrast_dialog)
brightness_contrast_ok_callback (NULL, (gpointer) brightness_contrast_dialog); brightness_contrast_cancel_callback (NULL, (gpointer) brightness_contrast_dialog);
g_free (bc); g_free (bc);
} }

View File

@ -292,6 +292,8 @@ by_color_select_button_press (Tool *tool,
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
by_color_sel = (ByColorSelect *) tool->private; by_color_sel = (ByColorSelect *) tool->private;
tool->drawable = gimage_active_drawable (gdisp->gimage);
if (!by_color_dialog) if (!by_color_dialog)
return; return;
@ -477,6 +479,8 @@ tools_new_by_color_select ()
tool->arrow_keys_func = standard_arrow_keys_func; tool->arrow_keys_func = standard_arrow_keys_func;
tool->cursor_update_func = by_color_select_cursor_update; tool->cursor_update_func = by_color_select_cursor_update;
tool->control_func = by_color_select_control; tool->control_func = by_color_select_control;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }

View File

@ -206,6 +206,10 @@ color_balance_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -286,6 +290,8 @@ tools_new_color_balance ()
tool->cursor_update_func = color_balance_cursor_update; tool->cursor_update_func = color_balance_cursor_update;
tool->control_func = color_balance_control; tool->control_func = color_balance_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -299,7 +305,7 @@ tools_free_color_balance (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (color_balance_dialog) if (color_balance_dialog)
color_balance_ok_callback (NULL, (gpointer) color_balance_dialog); color_balance_cancel_callback (NULL, (gpointer) color_balance_dialog);
g_free (color_bal); g_free (color_bal);
} }

View File

@ -207,6 +207,10 @@ curves_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -287,6 +291,8 @@ tools_new_curves ()
tool->cursor_update_func = curves_cursor_update; tool->cursor_update_func = curves_cursor_update;
tool->control_func = curves_control; tool->control_func = curves_control;
tool->preserve = TRUE; tool->preserve = TRUE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -300,7 +306,7 @@ tools_free_curves (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (curves_dialog) if (curves_dialog)
curves_ok_callback (NULL, (gpointer) curves_dialog); curves_cancel_callback (NULL, (gpointer) curves_dialog);
g_free (_curves); g_free (_curves);
} }

View File

@ -66,7 +66,7 @@ gint
gdisplay_canvas_events (GtkWidget *canvas, gdisplay_canvas_events (GtkWidget *canvas,
GdkEvent *event) GdkEvent *event)
{ {
GDisplay *gdisp, *tool_gdisp; GDisplay *gdisp;
GdkEventExpose *eevent; GdkEventExpose *eevent;
GdkEventMotion *mevent; GdkEventMotion *mevent;
GdkEventButton *bevent; GdkEventButton *bevent;
@ -147,11 +147,13 @@ gdisplay_canvas_events (GtkWidget *canvas,
bevent->x = tx; bevent->x = tx;
bevent->y = ty; bevent->y = ty;
} }
/* Reset the current tool if we're changing displays... */ /* Reset the current tool if we're changing drawables... */
tool_gdisp = active_tool->gdisp_ptr;
if (tool_gdisp) if (active_tool->drawable)
if (tool_gdisp->ID != gdisp->ID && !active_tool->preserve) if ((drawable_ID(gimage_active_drawable(gdisp->gimage)) !=
tools_select(active_tool->type); drawable_ID(GIMP_DRAWABLE(active_tool->drawable))) &&
!active_tool->preserve)
tools_initialize (active_tool->type, gdisp);
(* active_tool->button_press_func) (active_tool, bevent, gdisp); (* active_tool->button_press_func) (active_tool, bevent, gdisp);
} }
break; break;

View File

@ -66,7 +66,7 @@ gint
gdisplay_canvas_events (GtkWidget *canvas, gdisplay_canvas_events (GtkWidget *canvas,
GdkEvent *event) GdkEvent *event)
{ {
GDisplay *gdisp, *tool_gdisp; GDisplay *gdisp;
GdkEventExpose *eevent; GdkEventExpose *eevent;
GdkEventMotion *mevent; GdkEventMotion *mevent;
GdkEventButton *bevent; GdkEventButton *bevent;
@ -147,11 +147,13 @@ gdisplay_canvas_events (GtkWidget *canvas,
bevent->x = tx; bevent->x = tx;
bevent->y = ty; bevent->y = ty;
} }
/* Reset the current tool if we're changing displays... */ /* Reset the current tool if we're changing drawables... */
tool_gdisp = active_tool->gdisp_ptr;
if (tool_gdisp) if (active_tool->drawable)
if (tool_gdisp->ID != gdisp->ID && !active_tool->preserve) if ((drawable_ID(gimage_active_drawable(gdisp->gimage)) !=
tools_select(active_tool->type); drawable_ID(GIMP_DRAWABLE(active_tool->drawable))) &&
!active_tool->preserve)
tools_initialize (active_tool->type, gdisp);
(* active_tool->button_press_func) (active_tool, bevent, gdisp); (* active_tool->button_press_func) (active_tool, bevent, gdisp);
} }
break; break;

View File

@ -66,7 +66,7 @@ gint
gdisplay_canvas_events (GtkWidget *canvas, gdisplay_canvas_events (GtkWidget *canvas,
GdkEvent *event) GdkEvent *event)
{ {
GDisplay *gdisp, *tool_gdisp; GDisplay *gdisp;
GdkEventExpose *eevent; GdkEventExpose *eevent;
GdkEventMotion *mevent; GdkEventMotion *mevent;
GdkEventButton *bevent; GdkEventButton *bevent;
@ -147,11 +147,13 @@ gdisplay_canvas_events (GtkWidget *canvas,
bevent->x = tx; bevent->x = tx;
bevent->y = ty; bevent->y = ty;
} }
/* Reset the current tool if we're changing displays... */ /* Reset the current tool if we're changing drawables... */
tool_gdisp = active_tool->gdisp_ptr;
if (tool_gdisp) if (active_tool->drawable)
if (tool_gdisp->ID != gdisp->ID && !active_tool->preserve) if ((drawable_ID(gimage_active_drawable(gdisp->gimage)) !=
tools_select(active_tool->type); drawable_ID(GIMP_DRAWABLE(active_tool->drawable))) &&
!active_tool->preserve)
tools_initialize (active_tool->type, gdisp);
(* active_tool->button_press_func) (active_tool, bevent, gdisp); (* active_tool->button_press_func) (active_tool, bevent, gdisp);
} }
break; break;

View File

@ -2625,16 +2625,20 @@ int
gimage_dirty (GImage *gimage) gimage_dirty (GImage *gimage)
{ {
GDisplay *gdisp; GDisplay *gdisp;
if (gimage->dirty < 0) if (gimage->dirty < 0)
gimage->dirty = 2; gimage->dirty = 2;
else else
gimage->dirty ++; gimage->dirty ++;
if (active_tool) { if (active_tool && !active_tool->preserve) {
gdisp = active_tool->gdisp_ptr; gdisp = active_tool->gdisp_ptr;
if (gdisp) if (gdisp)
if ((gdisp->gimage == gimage) && (!active_tool->preserve)) if (gdisp->gimage->ID == gimage->ID)
tools_select (active_tool->type); tools_initialize (active_tool->type, gdisp);
else
active_tool_control(DESTROY, gdisp);
else
active_tool_control(DESTROY, gdisp);
} }
return gimage->dirty; return gimage->dirty;
} }

View File

@ -287,6 +287,10 @@ histogram_tool_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -370,7 +374,7 @@ tools_free_histogram_tool (Tool *tool)
/* Close the histogram dialog */ /* Close the histogram dialog */
if (histogram_tool_dialog) if (histogram_tool_dialog)
histogram_tool_ok_callback (NULL, (gpointer) histogram_tool_dialog); histogram_tool_cancel_callback (NULL, (gpointer) histogram_tool_dialog);
g_free (hist); g_free (hist);
} }

View File

@ -250,6 +250,10 @@ hue_saturation_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -330,6 +334,8 @@ tools_new_hue_saturation ()
tool->cursor_update_func = hue_saturation_cursor_update; tool->cursor_update_func = hue_saturation_cursor_update;
tool->control_func = hue_saturation_control; tool->control_func = hue_saturation_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -343,7 +349,7 @@ tools_free_hue_saturation (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (hue_saturation_dialog) if (hue_saturation_dialog)
hue_saturation_ok_callback (NULL, (gpointer) hue_saturation_dialog); hue_saturation_cancel_callback (NULL, (gpointer) hue_saturation_dialog);
g_free (color_bal); g_free (color_bal);
} }

View File

@ -301,6 +301,10 @@ levels_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -381,6 +385,8 @@ tools_new_levels ()
tool->cursor_update_func = levels_cursor_update; tool->cursor_update_func = levels_cursor_update;
tool->control_func = levels_control; tool->control_func = levels_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -394,7 +400,7 @@ tools_free_levels (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (levels_dialog) if (levels_dialog)
levels_ok_callback (NULL, (gpointer) levels_dialog); levels_cancel_callback (NULL, (gpointer) levels_dialog);
g_free (_levels); g_free (_levels);
} }

View File

@ -131,6 +131,10 @@ posterize_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -218,6 +222,8 @@ tools_new_posterize ()
tool->cursor_update_func = posterize_cursor_update; tool->cursor_update_func = posterize_cursor_update;
tool->control_func = posterize_control; tool->control_func = posterize_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -231,7 +237,7 @@ tools_free_posterize (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (posterize_dialog) if (posterize_dialog)
posterize_ok_callback (NULL, (gpointer) posterize_dialog); posterize_cancel_callback (NULL, (gpointer) posterize_dialog);
g_free (post); g_free (post);
} }

View File

@ -225,6 +225,10 @@ threshold_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -270,7 +274,9 @@ threshold_control (Tool *tool,
case HALT : case HALT :
if (threshold_dialog) if (threshold_dialog)
{ {
active_tool->preserve = TRUE;
image_map_abort (threshold_dialog->image_map); image_map_abort (threshold_dialog->image_map);
active_tool->preserve = FALSE;
threshold_dialog->image_map = NULL; threshold_dialog->image_map = NULL;
threshold_cancel_callback (NULL, (gpointer) threshold_dialog); threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
} }
@ -309,6 +315,7 @@ tools_new_threshold ()
tool->arrow_keys_func = standard_arrow_keys_func; tool->arrow_keys_func = standard_arrow_keys_func;
tool->cursor_update_func = threshold_cursor_update; tool->cursor_update_func = threshold_cursor_update;
tool->control_func = threshold_control; tool->control_func = threshold_control;
tool->preserve = FALSE;
return tool; return tool;
} }
@ -322,7 +329,7 @@ tools_free_threshold (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (threshold_dialog) if (threshold_dialog)
threshold_ok_callback (NULL, (gpointer) threshold_dialog); threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
g_free (thresh); g_free (thresh);
} }
@ -496,12 +503,15 @@ threshold_ok_callback (GtkWidget *widget,
if (GTK_WIDGET_VISIBLE (td->shell)) if (GTK_WIDGET_VISIBLE (td->shell))
gtk_widget_hide (td->shell); gtk_widget_hide (td->shell);
active_tool->preserve = TRUE;
if (!td->preview) if (!td->preview)
image_map_apply (td->image_map, threshold, (void *) td); image_map_apply (td->image_map, threshold, (void *) td);
if (td->image_map) if (td->image_map)
image_map_commit (td->image_map); image_map_commit (td->image_map);
active_tool->preserve = FALSE;
td->image_map = NULL; td->image_map = NULL;
} }
@ -527,7 +537,9 @@ threshold_cancel_callback (GtkWidget *widget,
if (td->image_map) if (td->image_map)
{ {
active_tool->preserve = TRUE;
image_map_abort (td->image_map); image_map_abort (td->image_map);
active_tool->preserve = FALSE;
gdisplays_flush (); gdisplays_flush ();
} }

View File

@ -363,10 +363,153 @@ tools_select (ToolType type)
*/ */
active_tool->paused_count = 0; active_tool->paused_count = 0;
active_tool->gdisp_ptr = NULL; active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
active_tool->ID = global_tool_ID++; active_tool->ID = global_tool_ID++;
active_tool_type = active_tool->type; active_tool_type = active_tool->type;
} }
void
tools_initialize (ToolType type, GDisplay *gdisp_ptr)
{
GDisplay *gdisp;
/* If you're wondering... only these dialog type tools have init functions */
gdisp = gdisp_ptr;
if (active_tool)
active_tool_free ();
switch (type)
{
case RECT_SELECT:
active_tool = tools_new_rect_select ();
break;
case ELLIPSE_SELECT:
active_tool = tools_new_ellipse_select ();
break;
case FREE_SELECT:
active_tool = tools_new_free_select ();
break;
case FUZZY_SELECT:
active_tool = tools_new_fuzzy_select ();
break;
case BEZIER_SELECT:
active_tool = tools_new_bezier_select ();
break;
case ISCISSORS:
active_tool = tools_new_iscissors ();
break;
case MOVE:
active_tool = tools_new_move_tool ();
break;
case MAGNIFY:
active_tool = tools_new_magnify ();
break;
case CROP:
active_tool = tools_new_crop ();
break;
case ROTATE:
active_tool = tools_new_transform_tool ();
break;
case SCALE:
active_tool = tools_new_transform_tool ();
break;
case SHEAR:
active_tool = tools_new_transform_tool ();
break;
case PERSPECTIVE:
active_tool = tools_new_transform_tool ();
break;
case FLIP_HORZ:
active_tool = tools_new_flip ();
break;
case FLIP_VERT:
active_tool = tools_new_flip ();
break;
case TEXT:
active_tool = tools_new_text ();
break;
case COLOR_PICKER:
active_tool = tools_new_color_picker ();
break;
case BUCKET_FILL:
active_tool = tools_new_bucket_fill ();
break;
case BLEND:
active_tool = tools_new_blend ();
break;
case PENCIL:
active_tool = tools_new_pencil ();
break;
case PAINTBRUSH:
active_tool = tools_new_paintbrush ();
break;
case ERASER:
active_tool = tools_new_eraser ();
break;
case AIRBRUSH:
active_tool = tools_new_airbrush ();
break;
case CLONE:
active_tool = tools_new_clone ();
break;
case CONVOLVE:
active_tool = tools_new_convolve ();
break;
case BY_COLOR_SELECT:
active_tool = tools_new_by_color_select ();
by_color_select_initialize (gdisp);
break;
case COLOR_BALANCE:
active_tool = tools_new_color_balance ();
color_balance_initialize (gdisp);
break;
case BRIGHTNESS_CONTRAST:
active_tool = tools_new_brightness_contrast ();
brightness_contrast_initialize (gdisp);
break;
case HUE_SATURATION:
active_tool = tools_new_hue_saturation ();
hue_saturation_initialize (gdisp);
break;
case POSTERIZE:
active_tool = tools_new_posterize ();
posterize_initialize (gdisp);
break;
case THRESHOLD:
active_tool = tools_new_threshold ();
threshold_initialize (gdisp);
break;
case CURVES:
active_tool = tools_new_curves ();
curves_initialize (gdisp);
break;
case LEVELS:
active_tool = tools_new_levels ();
levels_initialize (gdisp);
break;
case HISTOGRAM:
active_tool = tools_new_histogram_tool ();
histogram_tool_initialize (gdisp);
break;
default:
return;
}
/* Show the options for the active tool
*/
if (tool_info[(int) active_tool->type].tool_options)
gtk_widget_show (tool_info[(int) active_tool->type].tool_options);
gtk_container_enable_resize (GTK_CONTAINER (options_shell));
/* Set the paused count variable to 0
*/
active_tool->drawable = gimage_active_drawable (gdisp->gimage);
active_tool->gdisp_ptr = NULL;
active_tool->ID = global_tool_ID++;
active_tool_type = active_tool->type;
}
void void
tools_options_dialog_new () tools_options_dialog_new ()
@ -503,6 +646,10 @@ active_tool_control (int action,
active_tool->state = INACTIVE; active_tool->state = INACTIVE;
(* active_tool->control_func) (active_tool, action, gdisp_ptr); (* active_tool->control_func) (active_tool, action, gdisp_ptr);
break; break;
case DESTROY :
active_tool_free();
gtk_widget_hide (options_shell);
break;
} }
} }
else if (action == HALT) else if (action == HALT)

View File

@ -19,7 +19,7 @@
#define __TOOLS_H__ #define __TOOLS_H__
#include "layer.h" #include "layer.h"
#include "gdisplay.h"
/* The possible states for tools */ /* The possible states for tools */
#define INACTIVE 0 #define INACTIVE 0
@ -108,6 +108,8 @@ struct _tool
int auto_snap_to; /* should the mouse snap to guides automatically */ int auto_snap_to; /* should the mouse snap to guides automatically */
void * private; /* Tool-specific information */ void * private; /* Tool-specific information */
void * gdisp_ptr; /* pointer to currently active gdisp */ void * gdisp_ptr; /* pointer to currently active gdisp */
void * drawable; /* pointer to the drawable that was
active when the tool was created */
int ID; /* unique tool ID */ int ID; /* unique tool ID */
int preserve; /* Perserve this tool through the current image changes */ int preserve; /* Perserve this tool through the current image changes */
@ -139,6 +141,7 @@ extern ToolInfo tool_info[];
/* Function declarations */ /* Function declarations */
void tools_select (ToolType); void tools_select (ToolType);
void tools_initialize (ToolType, GDisplay *);
void tools_options_dialog_new (void); void tools_options_dialog_new (void);
void tools_options_dialog_show (void); void tools_options_dialog_show (void);
void tools_options_dialog_free (void); void tools_options_dialog_free (void);

View File

@ -176,6 +176,10 @@ brightness_contrast_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -253,6 +257,8 @@ tools_new_brightness_contrast ()
tool->cursor_update_func = brightness_contrast_cursor_update; tool->cursor_update_func = brightness_contrast_cursor_update;
tool->control_func = brightness_contrast_control; tool->control_func = brightness_contrast_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -266,7 +272,7 @@ tools_free_brightness_contrast (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (brightness_contrast_dialog) if (brightness_contrast_dialog)
brightness_contrast_ok_callback (NULL, (gpointer) brightness_contrast_dialog); brightness_contrast_cancel_callback (NULL, (gpointer) brightness_contrast_dialog);
g_free (bc); g_free (bc);
} }

View File

@ -292,6 +292,8 @@ by_color_select_button_press (Tool *tool,
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
by_color_sel = (ByColorSelect *) tool->private; by_color_sel = (ByColorSelect *) tool->private;
tool->drawable = gimage_active_drawable (gdisp->gimage);
if (!by_color_dialog) if (!by_color_dialog)
return; return;
@ -477,6 +479,8 @@ tools_new_by_color_select ()
tool->arrow_keys_func = standard_arrow_keys_func; tool->arrow_keys_func = standard_arrow_keys_func;
tool->cursor_update_func = by_color_select_cursor_update; tool->cursor_update_func = by_color_select_cursor_update;
tool->control_func = by_color_select_control; tool->control_func = by_color_select_control;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }

View File

@ -206,6 +206,10 @@ color_balance_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -286,6 +290,8 @@ tools_new_color_balance ()
tool->cursor_update_func = color_balance_cursor_update; tool->cursor_update_func = color_balance_cursor_update;
tool->control_func = color_balance_control; tool->control_func = color_balance_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -299,7 +305,7 @@ tools_free_color_balance (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (color_balance_dialog) if (color_balance_dialog)
color_balance_ok_callback (NULL, (gpointer) color_balance_dialog); color_balance_cancel_callback (NULL, (gpointer) color_balance_dialog);
g_free (color_bal); g_free (color_bal);
} }

View File

@ -207,6 +207,10 @@ curves_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -287,6 +291,8 @@ tools_new_curves ()
tool->cursor_update_func = curves_cursor_update; tool->cursor_update_func = curves_cursor_update;
tool->control_func = curves_control; tool->control_func = curves_control;
tool->preserve = TRUE; tool->preserve = TRUE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -300,7 +306,7 @@ tools_free_curves (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (curves_dialog) if (curves_dialog)
curves_ok_callback (NULL, (gpointer) curves_dialog); curves_cancel_callback (NULL, (gpointer) curves_dialog);
g_free (_curves); g_free (_curves);
} }

View File

@ -176,6 +176,10 @@ brightness_contrast_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -253,6 +257,8 @@ tools_new_brightness_contrast ()
tool->cursor_update_func = brightness_contrast_cursor_update; tool->cursor_update_func = brightness_contrast_cursor_update;
tool->control_func = brightness_contrast_control; tool->control_func = brightness_contrast_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -266,7 +272,7 @@ tools_free_brightness_contrast (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (brightness_contrast_dialog) if (brightness_contrast_dialog)
brightness_contrast_ok_callback (NULL, (gpointer) brightness_contrast_dialog); brightness_contrast_cancel_callback (NULL, (gpointer) brightness_contrast_dialog);
g_free (bc); g_free (bc);
} }

View File

@ -292,6 +292,8 @@ by_color_select_button_press (Tool *tool,
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
by_color_sel = (ByColorSelect *) tool->private; by_color_sel = (ByColorSelect *) tool->private;
tool->drawable = gimage_active_drawable (gdisp->gimage);
if (!by_color_dialog) if (!by_color_dialog)
return; return;
@ -477,6 +479,8 @@ tools_new_by_color_select ()
tool->arrow_keys_func = standard_arrow_keys_func; tool->arrow_keys_func = standard_arrow_keys_func;
tool->cursor_update_func = by_color_select_cursor_update; tool->cursor_update_func = by_color_select_cursor_update;
tool->control_func = by_color_select_control; tool->control_func = by_color_select_control;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }

View File

@ -206,6 +206,10 @@ color_balance_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -286,6 +290,8 @@ tools_new_color_balance ()
tool->cursor_update_func = color_balance_cursor_update; tool->cursor_update_func = color_balance_cursor_update;
tool->control_func = color_balance_control; tool->control_func = color_balance_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -299,7 +305,7 @@ tools_free_color_balance (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (color_balance_dialog) if (color_balance_dialog)
color_balance_ok_callback (NULL, (gpointer) color_balance_dialog); color_balance_cancel_callback (NULL, (gpointer) color_balance_dialog);
g_free (color_bal); g_free (color_bal);
} }

View File

@ -207,6 +207,10 @@ curves_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -287,6 +291,8 @@ tools_new_curves ()
tool->cursor_update_func = curves_cursor_update; tool->cursor_update_func = curves_cursor_update;
tool->control_func = curves_control; tool->control_func = curves_control;
tool->preserve = TRUE; tool->preserve = TRUE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -300,7 +306,7 @@ tools_free_curves (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (curves_dialog) if (curves_dialog)
curves_ok_callback (NULL, (gpointer) curves_dialog); curves_cancel_callback (NULL, (gpointer) curves_dialog);
g_free (_curves); g_free (_curves);
} }

View File

@ -287,6 +287,10 @@ histogram_tool_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -370,7 +374,7 @@ tools_free_histogram_tool (Tool *tool)
/* Close the histogram dialog */ /* Close the histogram dialog */
if (histogram_tool_dialog) if (histogram_tool_dialog)
histogram_tool_ok_callback (NULL, (gpointer) histogram_tool_dialog); histogram_tool_cancel_callback (NULL, (gpointer) histogram_tool_dialog);
g_free (hist); g_free (hist);
} }

View File

@ -250,6 +250,10 @@ hue_saturation_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -330,6 +334,8 @@ tools_new_hue_saturation ()
tool->cursor_update_func = hue_saturation_cursor_update; tool->cursor_update_func = hue_saturation_cursor_update;
tool->control_func = hue_saturation_control; tool->control_func = hue_saturation_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -343,7 +349,7 @@ tools_free_hue_saturation (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (hue_saturation_dialog) if (hue_saturation_dialog)
hue_saturation_ok_callback (NULL, (gpointer) hue_saturation_dialog); hue_saturation_cancel_callback (NULL, (gpointer) hue_saturation_dialog);
g_free (color_bal); g_free (color_bal);
} }

View File

@ -301,6 +301,10 @@ levels_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -381,6 +385,8 @@ tools_new_levels ()
tool->cursor_update_func = levels_cursor_update; tool->cursor_update_func = levels_cursor_update;
tool->control_func = levels_control; tool->control_func = levels_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -394,7 +400,7 @@ tools_free_levels (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (levels_dialog) if (levels_dialog)
levels_ok_callback (NULL, (gpointer) levels_dialog); levels_cancel_callback (NULL, (gpointer) levels_dialog);
g_free (_levels); g_free (_levels);
} }

View File

@ -131,6 +131,10 @@ posterize_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -218,6 +222,8 @@ tools_new_posterize ()
tool->cursor_update_func = posterize_cursor_update; tool->cursor_update_func = posterize_cursor_update;
tool->control_func = posterize_control; tool->control_func = posterize_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -231,7 +237,7 @@ tools_free_posterize (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (posterize_dialog) if (posterize_dialog)
posterize_ok_callback (NULL, (gpointer) posterize_dialog); posterize_cancel_callback (NULL, (gpointer) posterize_dialog);
g_free (post); g_free (post);
} }

View File

@ -225,6 +225,10 @@ threshold_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -270,7 +274,9 @@ threshold_control (Tool *tool,
case HALT : case HALT :
if (threshold_dialog) if (threshold_dialog)
{ {
active_tool->preserve = TRUE;
image_map_abort (threshold_dialog->image_map); image_map_abort (threshold_dialog->image_map);
active_tool->preserve = FALSE;
threshold_dialog->image_map = NULL; threshold_dialog->image_map = NULL;
threshold_cancel_callback (NULL, (gpointer) threshold_dialog); threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
} }
@ -309,6 +315,7 @@ tools_new_threshold ()
tool->arrow_keys_func = standard_arrow_keys_func; tool->arrow_keys_func = standard_arrow_keys_func;
tool->cursor_update_func = threshold_cursor_update; tool->cursor_update_func = threshold_cursor_update;
tool->control_func = threshold_control; tool->control_func = threshold_control;
tool->preserve = FALSE;
return tool; return tool;
} }
@ -322,7 +329,7 @@ tools_free_threshold (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (threshold_dialog) if (threshold_dialog)
threshold_ok_callback (NULL, (gpointer) threshold_dialog); threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
g_free (thresh); g_free (thresh);
} }
@ -496,12 +503,15 @@ threshold_ok_callback (GtkWidget *widget,
if (GTK_WIDGET_VISIBLE (td->shell)) if (GTK_WIDGET_VISIBLE (td->shell))
gtk_widget_hide (td->shell); gtk_widget_hide (td->shell);
active_tool->preserve = TRUE;
if (!td->preview) if (!td->preview)
image_map_apply (td->image_map, threshold, (void *) td); image_map_apply (td->image_map, threshold, (void *) td);
if (td->image_map) if (td->image_map)
image_map_commit (td->image_map); image_map_commit (td->image_map);
active_tool->preserve = FALSE;
td->image_map = NULL; td->image_map = NULL;
} }
@ -527,7 +537,9 @@ threshold_cancel_callback (GtkWidget *widget,
if (td->image_map) if (td->image_map)
{ {
active_tool->preserve = TRUE;
image_map_abort (td->image_map); image_map_abort (td->image_map);
active_tool->preserve = FALSE;
gdisplays_flush (); gdisplays_flush ();
} }

View File

@ -287,6 +287,10 @@ histogram_tool_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -370,7 +374,7 @@ tools_free_histogram_tool (Tool *tool)
/* Close the histogram dialog */ /* Close the histogram dialog */
if (histogram_tool_dialog) if (histogram_tool_dialog)
histogram_tool_ok_callback (NULL, (gpointer) histogram_tool_dialog); histogram_tool_cancel_callback (NULL, (gpointer) histogram_tool_dialog);
g_free (hist); g_free (hist);
} }

View File

@ -250,6 +250,10 @@ hue_saturation_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -330,6 +334,8 @@ tools_new_hue_saturation ()
tool->cursor_update_func = hue_saturation_cursor_update; tool->cursor_update_func = hue_saturation_cursor_update;
tool->control_func = hue_saturation_control; tool->control_func = hue_saturation_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -343,7 +349,7 @@ tools_free_hue_saturation (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (hue_saturation_dialog) if (hue_saturation_dialog)
hue_saturation_ok_callback (NULL, (gpointer) hue_saturation_dialog); hue_saturation_cancel_callback (NULL, (gpointer) hue_saturation_dialog);
g_free (color_bal); g_free (color_bal);
} }

View File

@ -301,6 +301,10 @@ levels_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -381,6 +385,8 @@ tools_new_levels ()
tool->cursor_update_func = levels_cursor_update; tool->cursor_update_func = levels_cursor_update;
tool->control_func = levels_control; tool->control_func = levels_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -394,7 +400,7 @@ tools_free_levels (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (levels_dialog) if (levels_dialog)
levels_ok_callback (NULL, (gpointer) levels_dialog); levels_cancel_callback (NULL, (gpointer) levels_dialog);
g_free (_levels); g_free (_levels);
} }

View File

@ -131,6 +131,10 @@ posterize_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -218,6 +222,8 @@ tools_new_posterize ()
tool->cursor_update_func = posterize_cursor_update; tool->cursor_update_func = posterize_cursor_update;
tool->control_func = posterize_control; tool->control_func = posterize_control;
tool->preserve = FALSE; tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool; return tool;
} }
@ -231,7 +237,7 @@ tools_free_posterize (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (posterize_dialog) if (posterize_dialog)
posterize_ok_callback (NULL, (gpointer) posterize_dialog); posterize_cancel_callback (NULL, (gpointer) posterize_dialog);
g_free (post); g_free (post);
} }

View File

@ -225,6 +225,10 @@ threshold_button_press (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
} }
static void static void
@ -270,7 +274,9 @@ threshold_control (Tool *tool,
case HALT : case HALT :
if (threshold_dialog) if (threshold_dialog)
{ {
active_tool->preserve = TRUE;
image_map_abort (threshold_dialog->image_map); image_map_abort (threshold_dialog->image_map);
active_tool->preserve = FALSE;
threshold_dialog->image_map = NULL; threshold_dialog->image_map = NULL;
threshold_cancel_callback (NULL, (gpointer) threshold_dialog); threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
} }
@ -309,6 +315,7 @@ tools_new_threshold ()
tool->arrow_keys_func = standard_arrow_keys_func; tool->arrow_keys_func = standard_arrow_keys_func;
tool->cursor_update_func = threshold_cursor_update; tool->cursor_update_func = threshold_cursor_update;
tool->control_func = threshold_control; tool->control_func = threshold_control;
tool->preserve = FALSE;
return tool; return tool;
} }
@ -322,7 +329,7 @@ tools_free_threshold (Tool *tool)
/* Close the color select dialog */ /* Close the color select dialog */
if (threshold_dialog) if (threshold_dialog)
threshold_ok_callback (NULL, (gpointer) threshold_dialog); threshold_cancel_callback (NULL, (gpointer) threshold_dialog);
g_free (thresh); g_free (thresh);
} }
@ -496,12 +503,15 @@ threshold_ok_callback (GtkWidget *widget,
if (GTK_WIDGET_VISIBLE (td->shell)) if (GTK_WIDGET_VISIBLE (td->shell))
gtk_widget_hide (td->shell); gtk_widget_hide (td->shell);
active_tool->preserve = TRUE;
if (!td->preview) if (!td->preview)
image_map_apply (td->image_map, threshold, (void *) td); image_map_apply (td->image_map, threshold, (void *) td);
if (td->image_map) if (td->image_map)
image_map_commit (td->image_map); image_map_commit (td->image_map);
active_tool->preserve = FALSE;
td->image_map = NULL; td->image_map = NULL;
} }
@ -527,7 +537,9 @@ threshold_cancel_callback (GtkWidget *widget,
if (td->image_map) if (td->image_map)
{ {
active_tool->preserve = TRUE;
image_map_abort (td->image_map); image_map_abort (td->image_map);
active_tool->preserve = FALSE;
gdisplays_flush (); gdisplays_flush ();
} }

View File

@ -363,10 +363,153 @@ tools_select (ToolType type)
*/ */
active_tool->paused_count = 0; active_tool->paused_count = 0;
active_tool->gdisp_ptr = NULL; active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
active_tool->ID = global_tool_ID++; active_tool->ID = global_tool_ID++;
active_tool_type = active_tool->type; active_tool_type = active_tool->type;
} }
void
tools_initialize (ToolType type, GDisplay *gdisp_ptr)
{
GDisplay *gdisp;
/* If you're wondering... only these dialog type tools have init functions */
gdisp = gdisp_ptr;
if (active_tool)
active_tool_free ();
switch (type)
{
case RECT_SELECT:
active_tool = tools_new_rect_select ();
break;
case ELLIPSE_SELECT:
active_tool = tools_new_ellipse_select ();
break;
case FREE_SELECT:
active_tool = tools_new_free_select ();
break;
case FUZZY_SELECT:
active_tool = tools_new_fuzzy_select ();
break;
case BEZIER_SELECT:
active_tool = tools_new_bezier_select ();
break;
case ISCISSORS:
active_tool = tools_new_iscissors ();
break;
case MOVE:
active_tool = tools_new_move_tool ();
break;
case MAGNIFY:
active_tool = tools_new_magnify ();
break;
case CROP:
active_tool = tools_new_crop ();
break;
case ROTATE:
active_tool = tools_new_transform_tool ();
break;
case SCALE:
active_tool = tools_new_transform_tool ();
break;
case SHEAR:
active_tool = tools_new_transform_tool ();
break;
case PERSPECTIVE:
active_tool = tools_new_transform_tool ();
break;
case FLIP_HORZ:
active_tool = tools_new_flip ();
break;
case FLIP_VERT:
active_tool = tools_new_flip ();
break;
case TEXT:
active_tool = tools_new_text ();
break;
case COLOR_PICKER:
active_tool = tools_new_color_picker ();
break;
case BUCKET_FILL:
active_tool = tools_new_bucket_fill ();
break;
case BLEND:
active_tool = tools_new_blend ();
break;
case PENCIL:
active_tool = tools_new_pencil ();
break;
case PAINTBRUSH:
active_tool = tools_new_paintbrush ();
break;
case ERASER:
active_tool = tools_new_eraser ();
break;
case AIRBRUSH:
active_tool = tools_new_airbrush ();
break;
case CLONE:
active_tool = tools_new_clone ();
break;
case CONVOLVE:
active_tool = tools_new_convolve ();
break;
case BY_COLOR_SELECT:
active_tool = tools_new_by_color_select ();
by_color_select_initialize (gdisp);
break;
case COLOR_BALANCE:
active_tool = tools_new_color_balance ();
color_balance_initialize (gdisp);
break;
case BRIGHTNESS_CONTRAST:
active_tool = tools_new_brightness_contrast ();
brightness_contrast_initialize (gdisp);
break;
case HUE_SATURATION:
active_tool = tools_new_hue_saturation ();
hue_saturation_initialize (gdisp);
break;
case POSTERIZE:
active_tool = tools_new_posterize ();
posterize_initialize (gdisp);
break;
case THRESHOLD:
active_tool = tools_new_threshold ();
threshold_initialize (gdisp);
break;
case CURVES:
active_tool = tools_new_curves ();
curves_initialize (gdisp);
break;
case LEVELS:
active_tool = tools_new_levels ();
levels_initialize (gdisp);
break;
case HISTOGRAM:
active_tool = tools_new_histogram_tool ();
histogram_tool_initialize (gdisp);
break;
default:
return;
}
/* Show the options for the active tool
*/
if (tool_info[(int) active_tool->type].tool_options)
gtk_widget_show (tool_info[(int) active_tool->type].tool_options);
gtk_container_enable_resize (GTK_CONTAINER (options_shell));
/* Set the paused count variable to 0
*/
active_tool->drawable = gimage_active_drawable (gdisp->gimage);
active_tool->gdisp_ptr = NULL;
active_tool->ID = global_tool_ID++;
active_tool_type = active_tool->type;
}
void void
tools_options_dialog_new () tools_options_dialog_new ()
@ -503,6 +646,10 @@ active_tool_control (int action,
active_tool->state = INACTIVE; active_tool->state = INACTIVE;
(* active_tool->control_func) (active_tool, action, gdisp_ptr); (* active_tool->control_func) (active_tool, action, gdisp_ptr);
break; break;
case DESTROY :
active_tool_free();
gtk_widget_hide (options_shell);
break;
} }
} }
else if (action == HALT) else if (action == HALT)

View File

@ -19,7 +19,7 @@
#define __TOOLS_H__ #define __TOOLS_H__
#include "layer.h" #include "layer.h"
#include "gdisplay.h"
/* The possible states for tools */ /* The possible states for tools */
#define INACTIVE 0 #define INACTIVE 0
@ -108,6 +108,8 @@ struct _tool
int auto_snap_to; /* should the mouse snap to guides automatically */ int auto_snap_to; /* should the mouse snap to guides automatically */
void * private; /* Tool-specific information */ void * private; /* Tool-specific information */
void * gdisp_ptr; /* pointer to currently active gdisp */ void * gdisp_ptr; /* pointer to currently active gdisp */
void * drawable; /* pointer to the drawable that was
active when the tool was created */
int ID; /* unique tool ID */ int ID; /* unique tool ID */
int preserve; /* Perserve this tool through the current image changes */ int preserve; /* Perserve this tool through the current image changes */
@ -139,6 +141,7 @@ extern ToolInfo tool_info[];
/* Function declarations */ /* Function declarations */
void tools_select (ToolType); void tools_select (ToolType);
void tools_initialize (ToolType, GDisplay *);
void tools_options_dialog_new (void); void tools_options_dialog_new (void);
void tools_options_dialog_show (void); void tools_options_dialog_show (void);
void tools_options_dialog_free (void); void tools_options_dialog_free (void);

View File

@ -83,6 +83,8 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
transform_core = (TransformCore *) tool->private; transform_core = (TransformCore *) tool->private;
tool->drawable = gimage_active_drawable (gdisp->gimage);
/* Save the current transformation info */ /* Save the current transformation info */
for (i = 0; i < TRAN_INFO_SIZE; i++) for (i = 0; i < TRAN_INFO_SIZE; i++)
old_trans_info [i] = transform_core->trans_info [i]; old_trans_info [i] = transform_core->trans_info [i];
@ -517,7 +519,6 @@ transform_core_new (type, interactive)
tool->state = INACTIVE; tool->state = INACTIVE;
tool->scroll_lock = 1; /* Do not allow scrolling */ tool->scroll_lock = 1; /* Do not allow scrolling */
tool->auto_snap_to = TRUE; tool->auto_snap_to = TRUE;
tool->gdisp_ptr = NULL;
tool->private = (void *) private; tool->private = (void *) private;
tool->preserve = FALSE; /* Destroy when the image is dirtied. */ tool->preserve = FALSE; /* Destroy when the image is dirtied. */

View File

@ -83,6 +83,8 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
transform_core = (TransformCore *) tool->private; transform_core = (TransformCore *) tool->private;
tool->drawable = gimage_active_drawable (gdisp->gimage);
/* Save the current transformation info */ /* Save the current transformation info */
for (i = 0; i < TRAN_INFO_SIZE; i++) for (i = 0; i < TRAN_INFO_SIZE; i++)
old_trans_info [i] = transform_core->trans_info [i]; old_trans_info [i] = transform_core->trans_info [i];
@ -517,7 +519,6 @@ transform_core_new (type, interactive)
tool->state = INACTIVE; tool->state = INACTIVE;
tool->scroll_lock = 1; /* Do not allow scrolling */ tool->scroll_lock = 1; /* Do not allow scrolling */
tool->auto_snap_to = TRUE; tool->auto_snap_to = TRUE;
tool->gdisp_ptr = NULL;
tool->private = (void *) private; tool->private = (void *) private;
tool->preserve = FALSE; /* Destroy when the image is dirtied. */ tool->preserve = FALSE; /* Destroy when the image is dirtied. */