From 625b5c716cef4b926c067f47ff35608128dcbd84 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 20 Nov 2001 13:53:21 +0000 Subject: [PATCH] put a g_object_ref() on a different line. 2001-11-20 Michael Natterer * app/core/gimp.c: put a g_object_ref() on a different line. * app/core/gimpdrawable-bucket-fill.c * app/core/gimpmodules.c: ne need to #include "core/..." here. * app/display/gimpdisplay-handlers.c: added debugging output because we have an image refcounting problem :( * app/display/gimpdisplayshell-handlers.c: fixed a signal disconnection. * app/tools/gimpbezierselecttool.[ch] * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpellipseselecttool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimprectselecttool.c * app/tools/gimpsmudgetool.c: get the tool's options via tool->tool_info->tool_options, not from the local statis pointer. Some minor cleanups & function reordering. * app/widgets/gimpdockbook.c: return TRUE from the notebook tabs' "button_press" handler, connect DND before cnnecting to "button_press" because we now stop it's emission. --- ChangeLog | 36 + app/core/gimp-modules.c | 12 +- app/core/gimp.c | 2 +- app/core/gimpdrawable-bucket-fill.c | 18 +- app/core/gimpimage-pick-color.c | 101 ++- app/core/gimpmodules.c | 12 +- app/display/gimpdisplay-handlers.c | 6 + app/display/gimpdisplayshell-handlers.c | 2 +- app/paint/gimpclone.c | 41 +- app/paint/gimpink.c | 1054 ++++++++++++----------- app/paint/gimpsmudge.c | 12 +- app/paint/gimpsourcecore.c | 41 +- app/tools/gimpbezierselecttool.c | 98 +-- app/tools/gimpbezierselecttool.h | 6 - app/tools/gimpblendtool.c | 37 +- app/tools/gimpbucketfilltool.c | 32 +- app/tools/gimpbycolorselecttool.c | 34 +- app/tools/gimpclonetool.c | 41 +- app/tools/gimpcolorpickertool.c | 101 ++- app/tools/gimpcroptool.c | 303 ++++--- app/tools/gimpellipseselecttool.c | 1 - app/tools/gimpfreeselecttool.c | 13 +- app/tools/gimpfuzzyselecttool.c | 55 +- app/tools/gimpinktool.c | 1054 ++++++++++++----------- app/tools/gimpiscissorstool.c | 69 +- app/tools/gimpmagnifytool.c | 253 +++--- app/tools/gimpmeasuretool.c | 50 +- app/tools/gimprectselecttool.c | 1 - app/tools/gimpregionselecttool.c | 55 +- app/tools/gimpsmudgetool.c | 12 +- app/tools/gimpsourcetool.c | 41 +- app/widgets/gimpdockbook.c | 43 +- libgimpmodule/gimpmoduledb.c | 12 +- 33 files changed, 1954 insertions(+), 1694 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24ad903c3c..a757b5d05d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,39 @@ +2001-11-20 Michael Natterer + + * app/core/gimp.c: put a g_object_ref() on a different line. + + * app/core/gimpdrawable-bucket-fill.c + * app/core/gimpmodules.c: ne need to #include "core/..." here. + + * app/display/gimpdisplay-handlers.c: added debugging output + because we have an image refcounting problem :( + + * app/display/gimpdisplayshell-handlers.c: fixed a signal + disconnection. + + * app/tools/gimpbezierselecttool.[ch] + * app/tools/gimpblendtool.c + * app/tools/gimpbucketfilltool.c + * app/tools/gimpbycolorselecttool.c + * app/tools/gimpclonetool.c + * app/tools/gimpcolorpickertool.c + * app/tools/gimpcroptool.c + * app/tools/gimpellipseselecttool.c + * app/tools/gimpfreeselecttool.c + * app/tools/gimpfuzzyselecttool.c + * app/tools/gimpinktool.c + * app/tools/gimpiscissorstool.c + * app/tools/gimpmagnifytool.c + * app/tools/gimpmeasuretool.c + * app/tools/gimprectselecttool.c + * app/tools/gimpsmudgetool.c: get the tool's options via + tool->tool_info->tool_options, not from the local statis pointer. + Some minor cleanups & function reordering. + + * app/widgets/gimpdockbook.c: return TRUE from the notebook tabs' + "button_press" handler, connect DND before cnnecting to + "button_press" because we now stop it's emission. + 2001-11-19 Daniel Egger * app/paint-funcs/paint-funcs.h: Added magic comment to prevent diff --git a/app/core/gimp-modules.c b/app/core/gimp-modules.c index 59d6d68b07..6ee7dcc35e 100644 --- a/app/core/gimp-modules.c +++ b/app/core/gimp-modules.c @@ -36,12 +36,12 @@ #include "core-types.h" -#include "core/gimp.h" -#include "core/gimpcoreconfig.h" -#include "core/gimpdatafiles.h" -#include "core/gimplist.h" -#include "core/gimpmoduleinfo.h" -#include "core/gimpmodules.h" +#include "gimp.h" +#include "gimpcoreconfig.h" +#include "gimpdatafiles.h" +#include "gimplist.h" +#include "gimpmoduleinfo.h" +#include "gimpmodules.h" #include "gimprc.h" diff --git a/app/core/gimp.c b/app/core/gimp.c index fa284a6e18..b4f9b82606 100644 --- a/app/core/gimp.c +++ b/app/core/gimp.c @@ -417,9 +417,9 @@ gimp_initialize (Gimp *gimp, */ context = gimp_create_context (gimp, "User", context); gimp_set_user_context (gimp, context); + g_object_unref (G_OBJECT (context)); gimp_set_current_context (gimp, context); - g_object_unref (G_OBJECT (context)); /* register all internal procedures */ (* status_callback) (_("Procedural Database"), NULL, -1); diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c index 26cd49361d..36fe4b0a62 100644 --- a/app/core/gimpdrawable-bucket-fill.c +++ b/app/core/gimpdrawable-bucket-fill.c @@ -30,15 +30,15 @@ #include "paint-funcs/paint-funcs.h" -#include "core/gimp.h" -#include "core/gimpchannel.h" -#include "core/gimpcontext.h" -#include "core/gimpdrawable.h" -#include "core/gimpdrawable-bucket-fill.h" -#include "core/gimpimage.h" -#include "core/gimpimage-contiguous-region.h" -#include "core/gimpimage-mask.h" -#include "core/gimppattern.h" +#include "gimp.h" +#include "gimpchannel.h" +#include "gimpcontext.h" +#include "gimpdrawable.h" +#include "gimpdrawable-bucket-fill.h" +#include "gimpimage.h" +#include "gimpimage-contiguous-region.h" +#include "gimpimage-mask.h" +#include "gimppattern.h" #include "gimprc.h" #include "undo.h" diff --git a/app/core/gimpimage-pick-color.c b/app/core/gimpimage-pick-color.c index 2689064b75..9d46adfe77 100644 --- a/app/core/gimpimage-pick-color.c +++ b/app/core/gimpimage-pick-color.c @@ -285,12 +285,15 @@ gimp_color_picker_tool_button_press (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpColorPickerTool *cp_tool; - GimpDisplayShell *shell; - gint off_x, off_y; + GimpColorPickerTool *cp_tool; + GimpColorPickerToolOptions *options; + GimpDisplayShell *shell; + gint off_x, off_y; cp_tool = GIMP_COLOR_PICKER_TOOL (tool); + options = (GimpColorPickerToolOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); /* Make the tool active and set it's gdisplay & drawable */ @@ -391,28 +394,30 @@ gimp_color_picker_tool_button_press (GimpTool *tool, */ if (state & GDK_SHIFT_MASK) { - gimp_color_picker_tool_info_update - (tool, pick_color_do (gdisp->gimage, tool->drawable, - coords->x, - coords->y, - gimp_color_picker_tool_options->sample_merged, - gimp_color_picker_tool_options->sample_average, - gimp_color_picker_tool_options->average_radius, - gimp_color_picker_tool_options->update_active, - COLOR_NEW)); + gimp_color_picker_tool_info_update (tool, + pick_color_do (gdisp->gimage, + tool->drawable, + coords->x, + coords->y, + options->sample_merged, + options->sample_average, + options->average_radius, + options->update_active, + COLOR_NEW)); update_type = COLOR_UPDATE_NEW; } else { - gimp_color_picker_tool_info_update - (tool, pick_color_do (gdisp->gimage, tool->drawable, - coords->x, - coords->y, - gimp_color_picker_tool_options->sample_merged, - gimp_color_picker_tool_options->sample_average, - gimp_color_picker_tool_options->average_radius, - gimp_color_picker_tool_options->update_active, - COLOR_UPDATE)); + gimp_color_picker_tool_info_update (tool, + pick_color_do (gdisp->gimage, + tool->drawable, + coords->x, + coords->y, + options->sample_merged, + options->sample_average, + options->average_radius, + options->update_active, + COLOR_UPDATE)); update_type = COLOR_UPDATE; } @@ -427,22 +432,26 @@ gimp_color_picker_tool_button_release (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpColorPickerTool *cp_tool; + GimpColorPickerTool *cp_tool; + GimpColorPickerToolOptions *options; + + cp_tool = GIMP_COLOR_PICKER_TOOL(tool); + + options = (GimpColorPickerToolOptions *) tool->tool_info->tool_options; gdk_pointer_ungrab (time); gdk_flush (); - cp_tool = GIMP_COLOR_PICKER_TOOL(tool); - - gimp_color_picker_tool_info_update - (tool, pick_color_do (gdisp->gimage, tool->drawable, - coords->x, - coords->y, - gimp_color_picker_tool_options->sample_merged, - gimp_color_picker_tool_options->sample_average, - gimp_color_picker_tool_options->average_radius, - gimp_color_picker_tool_options->update_active, - update_type)); + gimp_color_picker_tool_info_update (tool, + pick_color_do (gdisp->gimage, + tool->drawable, + coords->x, + coords->y, + options->sample_merged, + options->sample_average, + options->average_radius, + options->update_active, + update_type)); gimp_draw_tool_stop (GIMP_DRAW_TOOL (cp_tool)); @@ -456,11 +465,14 @@ gimp_color_picker_tool_motion (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpColorPickerTool *cp_tool; - gint off_x, off_y; + GimpColorPickerTool *cp_tool; + GimpColorPickerToolOptions *options; + gint off_x, off_y; cp_tool = GIMP_COLOR_PICKER_TOOL (tool); + options = (GimpColorPickerToolOptions *) tool->tool_info->tool_options; + gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage), @@ -469,15 +481,16 @@ gimp_color_picker_tool_motion (GimpTool *tool, cp_tool->centerx = coords->x - off_x; cp_tool->centery = coords->y - off_y; - gimp_color_picker_tool_info_update - (tool, pick_color_do (gdisp->gimage, tool->drawable, - coords->x, - coords->y, - gimp_color_picker_tool_options->sample_merged, - gimp_color_picker_tool_options->sample_average, - gimp_color_picker_tool_options->average_radius, - gimp_color_picker_tool_options->update_active, - update_type)); + gimp_color_picker_tool_info_update (tool, + pick_color_do (gdisp->gimage, + tool->drawable, + coords->x, + coords->y, + options->sample_merged, + options->sample_average, + options->average_radius, + options->update_active, + update_type)); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); } diff --git a/app/core/gimpmodules.c b/app/core/gimpmodules.c index 59d6d68b07..6ee7dcc35e 100644 --- a/app/core/gimpmodules.c +++ b/app/core/gimpmodules.c @@ -36,12 +36,12 @@ #include "core-types.h" -#include "core/gimp.h" -#include "core/gimpcoreconfig.h" -#include "core/gimpdatafiles.h" -#include "core/gimplist.h" -#include "core/gimpmoduleinfo.h" -#include "core/gimpmodules.h" +#include "gimp.h" +#include "gimpcoreconfig.h" +#include "gimpdatafiles.h" +#include "gimplist.h" +#include "gimpmoduleinfo.h" +#include "gimpmodules.h" #include "gimprc.h" diff --git a/app/display/gimpdisplay-handlers.c b/app/display/gimpdisplay-handlers.c index 5fc4fc9985..5651040c87 100644 --- a/app/display/gimpdisplay-handlers.c +++ b/app/display/gimpdisplay-handlers.c @@ -61,6 +61,9 @@ gimp_display_connect (GimpDisplay *gdisp, gimage->instance_count++; /* this is obsolete */ gimage->disp_count++; + g_print ("%s: gimage->ref_count before refing: %d\n", + G_GNUC_FUNCTION, G_OBJECT (gdisp->gimage)->ref_count); + g_object_ref (G_OBJECT (gimage)); g_signal_connect (G_OBJECT (gimage), "update", @@ -98,6 +101,9 @@ gimp_display_disconnect (GimpDisplay *gdisp) gdisp->gimage->disp_count--; + g_print ("%s: gimage->ref_count before unrefing: %d\n", + G_GNUC_FUNCTION, G_OBJECT (gdisp->gimage)->ref_count); + g_object_unref (G_OBJECT (gdisp->gimage)); gdisp->gimage = NULL; } diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c index 79ba615235..7dd322cdee 100644 --- a/app/display/gimpdisplayshell-handlers.c +++ b/app/display/gimpdisplayshell-handlers.c @@ -127,7 +127,7 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell) shell); g_signal_handlers_disconnect_by_func (G_OBJECT (gimage), - gimp_display_shell_update_title, + gimp_display_shell_update_title_handler, shell); } diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c index c1284b14cc..1d77cb2e1c 100644 --- a/app/paint/gimpclone.c +++ b/app/paint/gimpclone.c @@ -33,12 +33,13 @@ #include "paint-funcs/paint-funcs.h" #include "core/gimp.h" +#include "core/gimpbrush.h" +#include "core/gimpcontext.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimppattern.h" -#include "core/gimpcontext.h" -#include "core/gimpbrush.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" @@ -279,17 +280,22 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + GimpTool *tool; + GimpDrawTool *draw_tool; + CloneOptions *options; GimpDisplay *gdisp; GimpDisplay *src_gdisp; gint x1, y1, x2, y2; static gint orig_src_x, orig_src_y; - GimpDrawTool *draw_tool; GimpContext *context; - gdisp = (GimpDisplay *) tool_manager_get_active (drawable->gimage->gimp)->gdisp; - + tool = GIMP_TOOL (paint_tool); draw_tool = GIMP_DRAW_TOOL (paint_tool); + options = (CloneOptions *) tool->tool_info->tool_options; + + gdisp = tool->gdisp; + context = gimp_get_current_context (gdisp->gimage->gimp); switch (state) @@ -317,7 +323,7 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, dest_x = x1; dest_y = y1; - if (clone_options->aligned == ALIGN_REGISTERED) + if (options->aligned == ALIGN_REGISTERED) { offset_x = 0; offset_y = 0; @@ -333,8 +339,9 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, src_y = dest_y + offset_y; gimp_clone_tool_motion (paint_tool, drawable, src_drawable_, - clone_options->paint_options.pressure_options, - clone_options->type, offset_x, offset_y); + options->paint_options.pressure_options, + options->type, + offset_x, offset_y); } break; @@ -348,20 +355,21 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, src_y = paint_tool->cur_coords.y; first = TRUE; } - else if (clone_options->aligned == ALIGN_NO) + else if (options->aligned == ALIGN_NO) { first = TRUE; orig_src_x = src_x; orig_src_y = src_y; } - if (clone_options->type == PATTERN_CLONE) + + if (options->type == PATTERN_CLONE) if (! gimp_context_get_pattern (context)) g_message (_("No patterns available for this operation.")); break; case FINISH_PAINT: gimp_draw_tool_stop (draw_tool); - if (clone_options->aligned == ALIGN_NO && !first) + if (options->aligned == ALIGN_NO && !first) { src_x = orig_src_x; src_y = orig_src_y; @@ -405,10 +413,13 @@ gimp_clone_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + CloneOptions *options; GimpDisplayShell *shell; GimpLayer *layer; GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + options = (CloneOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); if ((layer = gimp_image_get_active_layer (gdisp->gimage))) @@ -432,7 +443,7 @@ gimp_clone_tool_cursor_update (GimpTool *tool, } } - if (clone_options->type == IMAGE_CLONE) + if (options->type == IMAGE_CLONE) { if (state & GDK_CONTROL_MASK) ctype = GIMP_CROSSHAIR_SMALL_CURSOR; @@ -451,7 +462,11 @@ gimp_clone_tool_cursor_update (GimpTool *tool, static void gimp_clone_tool_draw (GimpDrawTool *draw_tool) { - if (draw_tool->gc != NULL && clone_options->type == IMAGE_CLONE) + CloneOptions *options; + + options = (CloneOptions *) GIMP_TOOL (draw_tool)->tool_info->tool_options; + + if (draw_tool->gc != NULL && options->type == IMAGE_CLONE) { gdk_draw_line (draw_tool->win, draw_tool->gc, trans_tx - (TARGET_WIDTH >> 1), trans_ty, diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c index f91fe7d092..ede373ef2a 100644 --- a/app/paint/gimpink.c +++ b/app/paint/gimpink.c @@ -40,6 +40,7 @@ #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" @@ -122,31 +123,35 @@ static void gimp_ink_tool_init (GimpInkTool *tool); static void gimp_ink_tool_finalize (GObject *object); -static InkOptions * ink_options_new (void); -static void ink_options_reset (GimpToolOptions *tool_options); +static void gimp_ink_tool_control (GimpTool *tool, + ToolAction tool_action, + GimpDisplay *gdisp); +static void gimp_ink_tool_button_press (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp); +static void gimp_ink_tool_button_release (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp); +static void gimp_ink_tool_motion (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp); +static void gimp_ink_tool_cursor_update (GimpTool *tool, + GimpCoords *coords, + GdkModifierType state, + GimpDisplay *gdisp); -static void ink_control (GimpTool *tool, - ToolAction tool_action, - GimpDisplay *gdisp); -static void ink_button_press (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp); -static void ink_button_release (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp); -static void ink_motion (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp); -static void ink_cursor_update (GimpTool *tool, - GimpCoords *coords, - GdkModifierType state, - GimpDisplay *gdisp); +static Blob * ink_pen_ellipse (gdouble x_center, + gdouble y_center, + gdouble pressure, + gdouble xtilt, + gdouble ytilt, + gdouble velocity); static void time_smoother_add (GimpInkTool *ink_tool, guint32 value); @@ -216,6 +221,11 @@ static void brush_widget_motion_notify (GtkWidget *widget, GdkEventMotion *event, BrushWidget *brush_widget); +static InkOptions * ink_options_new (void); +static void ink_options_reset (GimpToolOptions *tool_options); +static void ink_type_update (GtkWidget *radio_button, + BlobFunc function); + /* local variables */ @@ -236,7 +246,7 @@ static TempBuf *canvas_buf = NULL; static GimpToolClass *parent_class = NULL; -/* functions */ +/* public functions */ void gimp_ink_tool_register (Gimp *gimp) @@ -280,6 +290,9 @@ gimp_ink_tool_get_type (void) return tool_type; } + +/* private functions */ + static void gimp_ink_tool_class_init (GimpInkToolClass *klass) { @@ -293,11 +306,11 @@ gimp_ink_tool_class_init (GimpInkToolClass *klass) object_class->finalize = gimp_ink_tool_finalize; - tool_class->control = ink_control; - tool_class->button_press = ink_button_press; - tool_class->button_release = ink_button_release; - tool_class->motion = ink_motion; - tool_class->cursor_update = ink_cursor_update; + tool_class->control = gimp_ink_tool_control; + tool_class->button_press = gimp_ink_tool_button_press; + tool_class->button_release = gimp_ink_tool_button_release; + tool_class->motion = gimp_ink_tool_motion; + tool_class->cursor_update = gimp_ink_tool_cursor_update; } static void @@ -339,300 +352,240 @@ gimp_ink_tool_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } -static void -ink_type_update (GtkWidget *radio_button, - BlobFunc function) +static void +gimp_ink_tool_control (GimpTool *tool, + ToolAction action, + GimpDisplay *gdisp) { - InkOptions *options = ink_options; + GimpInkTool *ink_tool; - if (GTK_TOGGLE_BUTTON (radio_button)->active) - options->function = function; + ink_tool = GIMP_INK_TOOL (tool); - gtk_widget_queue_draw (options->brush_w->widget); + switch (action) + { + case PAUSE: + break; + + case RESUME: + break; + + case HALT: + ink_cleanup (); + break; + + default: + break; + } } static void -ink_options_reset (GimpToolOptions *tool_options) +gimp_ink_tool_button_press (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp) { - InkOptions *options; + GimpInkTool *ink_tool; + GimpDisplayShell *shell; + GimpDrawable *drawable; + Blob *b; - options = (InkOptions *) tool_options; + ink_tool = GIMP_INK_TOOL (tool); - paint_options_reset (tool_options); + shell = GIMP_DISPLAY_SHELL (gdisp->shell); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->size_w), - options->size_d); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->sensitivity_w), - options->sensitivity_d); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->tilt_sensitivity_w), - options->tilt_sensitivity_d); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->vel_sensitivity_w), - options->vel_sensitivity_d); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->tilt_angle_w), - options->tilt_angle_d); - gtk_toggle_button_set_active (((options->function_d == blob_ellipse) ? - GTK_TOGGLE_BUTTON (options->function_w[0]) : - ((options->function_d == blob_square) ? - GTK_TOGGLE_BUTTON (options->function_w[1]) : - GTK_TOGGLE_BUTTON (options->function_w[2]))), - TRUE); - options->aspect = options->aspect_d; - options->angle = options->angle_d; - gtk_widget_queue_draw (options->brush_w->widget); + drawable = gimp_image_active_drawable (gdisp->gimage); + + ink_init (ink_tool, drawable, coords->x, coords->y); + + tool->state = ACTIVE; + tool->gdisp = gdisp; + tool->paused_count = 0; + + /* pause the current selection and grab the pointer */ + gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE); + + /* add motion memory if you press mod1 first ^ perfectmouse */ + if (((state & GDK_MOD1_MASK) != 0) != (gimprc.perfectmouse != 0)) + { + gdk_pointer_grab (shell->canvas->window, FALSE, + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, + NULL, NULL, time); + } + else + { + gdk_pointer_grab (shell->canvas->window, FALSE, + GDK_POINTER_MOTION_HINT_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, + NULL, NULL, time); + } + + b = ink_pen_ellipse (coords->x, + coords->y, + coords->pressure, + coords->xtilt, + coords->ytilt, + 10.0); + + ink_paste (ink_tool, drawable, b); + ink_tool->last_blob = b; + + time_smoother_init (ink_tool, time); + ink_tool->last_time = time; + dist_smoother_init (ink_tool, 0.0); + ink_tool->init_velocity = TRUE; + ink_tool->lastx = coords->x; + ink_tool->lasty = coords->y; + + gimp_display_flush_now (gdisp); } -static InkOptions * -ink_options_new (void) +static void +gimp_ink_tool_button_release (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp) { - InkOptions *options; - GtkWidget *table; - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *hbox2; - GtkWidget *radio_button; - GtkWidget *pixmap_widget; - GtkWidget *slider; - GtkWidget *frame; - GtkWidget *darea; - GdkPixmap *pixmap; + GimpInkTool *ink_tool; + GimpImage *gimage; - options = g_new0 (InkOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_INK_TOOL, - ink_options_reset); + ink_tool = GIMP_INK_TOOL (tool); - options->size = options->size_d = 4.4; - options->sensitivity = options->sensitivity_d = 1.0; - options->vel_sensitivity = options->vel_sensitivity_d = 0.8; - options->tilt_sensitivity = options->tilt_sensitivity_d = 0.4; - options->tilt_angle = options->tilt_angle_d = 0.0; - options->function = options->function_d = blob_ellipse; - options->aspect = options->aspect_d = 1.0; - options->angle = options->angle_d = 0.0; + gimage = gdisp->gimage; - /* the main vbox */ - vbox = gtk_vbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (((GimpToolOptions *) options)->main_vbox), vbox, - TRUE, TRUE, 0); - gtk_widget_show (vbox); + /* resume the current selection and ungrab the pointer */ + gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME); - /* adjust sliders */ - frame = gtk_frame_new (_("Adjustment")); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); - gtk_widget_show (frame); + gdk_pointer_ungrab (time); + gdk_flush (); - table = gtk_table_new (2, 2, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (table), 4); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - gtk_container_add (GTK_CONTAINER (frame), table); - gtk_widget_show (table); + /* Set tool state to inactive -- no longer painting */ + tool->state = INACTIVE; - /* size slider */ - options->size_w = - gtk_adjustment_new (options->size_d, 0.0, 20.0, 1.0, 2.0, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (options->size_w)); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, - _("Size:"), 1.0, 1.0, - slider, 1, FALSE); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + /* free the last blob */ + g_free (ink_tool->last_blob); + ink_tool->last_blob = NULL; - g_signal_connect (G_OBJECT (options->size_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->size); + ink_finish (ink_tool, gimp_image_active_drawable (gdisp->gimage)); + gdisplays_flush (); +} - /* angle adjust slider */ - options->tilt_angle_w = - gtk_adjustment_new (options->tilt_angle_d, -90.0, 90.0, 1, 10.0, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (options->tilt_angle_w)); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, - _("Angle:"), 1.0, 1.0, - slider, 1, FALSE); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); +static void +gimp_ink_tool_motion (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp) +{ + GimpInkTool *ink_tool; + GimpDrawable *drawable; + Blob *b, *blob_union; - g_signal_connect (G_OBJECT (options->tilt_angle_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->tilt_angle); - - /* sens sliders */ - frame = gtk_frame_new (_("Sensitivity")); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); - gtk_widget_show (frame); - - table = gtk_table_new (3, 2, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (table), 4); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - gtk_container_add (GTK_CONTAINER (frame), table); - gtk_widget_show (table); - - /* size sens slider */ - options->sensitivity_w = - gtk_adjustment_new (options->sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (options->sensitivity_w)); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, - _("Size:"), 1.0, 1.0, - slider, 1, FALSE); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); - - g_signal_connect (G_OBJECT (options->sensitivity_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->sensitivity); + gdouble velocity; + gdouble dist; + gdouble lasttime, thistime; - /* tilt sens slider */ - options->tilt_sensitivity_w = - gtk_adjustment_new (options->tilt_sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (options->tilt_sensitivity_w)); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, - _("Tilt:"), 1.0, 1.0, - slider, 1, FALSE); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + ink_tool = GIMP_INK_TOOL (tool); - g_signal_connect (G_OBJECT (options->tilt_sensitivity_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->tilt_sensitivity); + drawable = gimp_image_active_drawable (gdisp->gimage); - /* velocity sens slider */ - options->vel_sensitivity_w = - gtk_adjustment_new (options->vel_sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (options->vel_sensitivity_w)); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 3, - _("Speed:"), 1.0, 1.0, - slider, 1, FALSE); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + lasttime = ink_tool->last_time; - g_signal_connect (G_OBJECT (options->vel_sensitivity_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->vel_sensitivity); + time_smoother_add (ink_tool, time); + thistime = ink_tool->last_time = time_smoother_result (ink_tool); - /* bottom hbox */ - hbox = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); - gtk_widget_show (hbox); + /* The time resolution on X-based GDK motion events is + bloody awful, hence the use of the smoothing function. + Sadly this also means that there is always the chance of + having an indeterminite velocity since this event and + the previous several may still appear to issue at the same + instant. -ADM */ - /* Brush type radiobuttons */ - frame = gtk_frame_new (_("Type")); - gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); - gtk_widget_show (frame); + if (thistime == lasttime) + thistime = lasttime + 1; - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), hbox2); - - vbox = gtk_vbox_new (FALSE, 2); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (hbox2), vbox, FALSE, FALSE, 0); - gtk_widget_show (vbox); + if (ink_tool->init_velocity) + { + dist_smoother_init (ink_tool, + dist = sqrt ((ink_tool->lastx - coords->x) * + (ink_tool->lastx - coords->x) + + (ink_tool->lasty - coords->y) * + (ink_tool->lasty - coords->y))); + ink_tool->init_velocity = FALSE; + } + else + { + dist_smoother_add (ink_tool, + sqrt ((ink_tool->lastx - coords->x) * + (ink_tool->lastx - coords->x) + + (ink_tool->lasty - coords->y) * + (ink_tool->lasty - coords->y))); - pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), - gtk_widget_get_visual (vbox), - blob_ellipse); + dist = dist_smoother_result (ink_tool); + } - pixmap_widget = gtk_pixmap_new (pixmap, NULL); - gdk_drawable_unref (pixmap); - gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); + ink_tool->lastx = coords->x; + ink_tool->lasty = coords->y; - radio_button = gtk_radio_button_new (NULL); - gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); - gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); + velocity = 10.0 * sqrt ((dist) / (gdouble) (thistime - lasttime)); - g_signal_connect (G_OBJECT (radio_button), "toggled", - G_CALLBACK (ink_type_update), - (gpointer) blob_ellipse); + b = ink_pen_ellipse (coords->x, + coords->y, + coords->pressure, + coords->xtilt, + coords->ytilt, + velocity); + blob_union = blob_convex_union (ink_tool->last_blob, b); + g_free (ink_tool->last_blob); + ink_tool->last_blob = b; - options->function_w[0] = radio_button; + ink_paste (ink_tool, drawable, blob_union); + g_free (blob_union); - pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), - gtk_widget_get_visual (vbox), - blob_square); + gimp_display_flush_now (gdisp); +} - pixmap_widget = gtk_pixmap_new (pixmap, NULL); - gdk_drawable_unref (pixmap); - gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); +static void +gimp_ink_tool_cursor_update (GimpTool *tool, + GimpCoords *coords, + GdkModifierType state, + GimpDisplay *gdisp) +{ + GimpDisplayShell *shell; + GimpLayer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - radio_button = - gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button)); - gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); - gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); + shell = GIMP_DISPLAY_SHELL (gdisp->shell); - g_signal_connect (G_OBJECT (radio_button), "toggled", - G_CALLBACK (ink_type_update), - (gpointer) blob_square); - + if ((layer = gimp_image_get_active_layer (gdisp->gimage))) + { + gint off_x, off_y; - options->function_w[1] = radio_button; + gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y); - pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), - gtk_widget_get_visual (vbox), - blob_diamond); + if (coords->x >= off_x && + coords->y >= off_y && + coords->x < (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer))) && + coords->y < (off_y + gimp_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 = GIMP_MOUSE_CURSOR; + else if (gimage_mask_value (gdisp->gimage, coords->x, coords->y)) + ctype = GIMP_MOUSE_CURSOR; + } + } - pixmap_widget = gtk_pixmap_new (pixmap, NULL); - gdk_drawable_unref (pixmap); - gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); - - radio_button = - gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button)); - gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); - gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); - - g_signal_connect (G_OBJECT (radio_button), "toggled", - G_CALLBACK (ink_type_update), - (gpointer) blob_diamond); - - - options->function_w[2] = radio_button; - - /* Brush shape widget */ - frame = gtk_frame_new (_("Shape")); - gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); - gtk_widget_show (frame); - - vbox = gtk_vbox_new (FALSE, 2); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_container_add (GTK_CONTAINER (frame), vbox); - gtk_widget_show (vbox); - - frame = gtk_aspect_frame_new (NULL, 0.0, 0.5, 1.0, FALSE); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); - - options->brush_w = g_new (BrushWidget, 1); - options->brush_w->state = FALSE; - - darea = gtk_drawing_area_new(); - options->brush_w->widget = darea; - - gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 60, 60); - gtk_container_add (GTK_CONTAINER (frame), darea); - - gtk_widget_set_events (darea, - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK); - - g_signal_connect (G_OBJECT (darea), "button_press_event", - G_CALLBACK (brush_widget_button_press), - options->brush_w); - g_signal_connect (G_OBJECT (darea), "button_release_event", - G_CALLBACK (brush_widget_button_release), - options->brush_w); - g_signal_connect (G_OBJECT (darea), "motion_notify_event", - G_CALLBACK (brush_widget_motion_notify), - options->brush_w); - g_signal_connect (G_OBJECT (darea), "expose_event", - G_CALLBACK (brush_widget_expose), - options->brush_w); - g_signal_connect (G_OBJECT (darea), "realize", - G_CALLBACK (brush_widget_realize), - options->brush_w); - - gtk_widget_show_all (hbox); - - return options; + gimp_display_shell_install_tool_cursor (shell, + ctype, + GIMP_INK_TOOL_CURSOR, + GIMP_CURSOR_MODIFIER_NONE); } @@ -934,128 +887,6 @@ ink_pen_ellipse (gdouble x_center, -radmin*tsin, radmin*tcos); } -static void -ink_control (GimpTool *tool, - ToolAction action, - GimpDisplay *gdisp) -{ - GimpInkTool *ink_tool; - - ink_tool = GIMP_INK_TOOL (tool); - - switch (action) - { - case PAUSE: - break; - - case RESUME: - break; - - case HALT: - ink_cleanup (); - break; - - default: - break; - } -} - -static void -ink_button_press (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp) -{ - GimpInkTool *ink_tool; - GimpDisplayShell *shell; - GimpDrawable *drawable; - Blob *b; - - ink_tool = GIMP_INK_TOOL (tool); - - shell = GIMP_DISPLAY_SHELL (gdisp->shell); - - drawable = gimp_image_active_drawable (gdisp->gimage); - - ink_init (ink_tool, drawable, coords->x, coords->y); - - tool->state = ACTIVE; - tool->gdisp = gdisp; - tool->paused_count = 0; - - /* pause the current selection and grab the pointer */ - gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE); - - /* add motion memory if you press mod1 first ^ perfectmouse */ - if (((state & GDK_MOD1_MASK) != 0) != (gimprc.perfectmouse != 0)) - { - gdk_pointer_grab (shell->canvas->window, FALSE, - GDK_BUTTON1_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK, - NULL, NULL, time); - } - else - { - gdk_pointer_grab (shell->canvas->window, FALSE, - GDK_POINTER_MOTION_HINT_MASK | - GDK_BUTTON1_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK, - NULL, NULL, time); - } - - b = ink_pen_ellipse (coords->x, - coords->y, - coords->pressure, - coords->xtilt, - coords->ytilt, - 10.0); - - ink_paste (ink_tool, drawable, b); - ink_tool->last_blob = b; - - time_smoother_init (ink_tool, time); - ink_tool->last_time = time; - dist_smoother_init (ink_tool, 0.0); - ink_tool->init_velocity = TRUE; - ink_tool->lastx = coords->x; - ink_tool->lasty = coords->y; - - gimp_display_flush_now (gdisp); -} - -static void -ink_button_release (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp) -{ - GimpInkTool *ink_tool; - GimpImage *gimage; - - ink_tool = GIMP_INK_TOOL (tool); - - gimage = gdisp->gimage; - - /* resume the current selection and ungrab the pointer */ - gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME); - - gdk_pointer_ungrab (time); - gdk_flush (); - - /* Set tool state to inactive -- no longer painting */ - tool->state = INACTIVE; - - /* free the last blob */ - g_free (ink_tool->last_blob); - ink_tool->last_blob = NULL; - - ink_finish (ink_tool, gimp_image_active_drawable (gdisp->gimage)); - gdisplays_flush (); -} - - static void dist_smoother_init (GimpInkTool *ink_tool, gdouble initval) @@ -1137,122 +968,6 @@ time_smoother_add (GimpInkTool *ink_tool, ink_tool->ts_index = 0; } - -static void -ink_motion (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp) -{ - GimpInkTool *ink_tool; - GimpDrawable *drawable; - Blob *b, *blob_union; - - gdouble velocity; - gdouble dist; - gdouble lasttime, thistime; - - ink_tool = GIMP_INK_TOOL (tool); - - drawable = gimp_image_active_drawable (gdisp->gimage); - - lasttime = ink_tool->last_time; - - time_smoother_add (ink_tool, time); - thistime = ink_tool->last_time = time_smoother_result (ink_tool); - - /* The time resolution on X-based GDK motion events is - bloody awful, hence the use of the smoothing function. - Sadly this also means that there is always the chance of - having an indeterminite velocity since this event and - the previous several may still appear to issue at the same - instant. -ADM */ - - if (thistime == lasttime) - thistime = lasttime + 1; - - if (ink_tool->init_velocity) - { - dist_smoother_init (ink_tool, - dist = sqrt ((ink_tool->lastx - coords->x) * - (ink_tool->lastx - coords->x) + - (ink_tool->lasty - coords->y) * - (ink_tool->lasty - coords->y))); - ink_tool->init_velocity = FALSE; - } - else - { - dist_smoother_add (ink_tool, - sqrt ((ink_tool->lastx - coords->x) * - (ink_tool->lastx - coords->x) + - (ink_tool->lasty - coords->y) * - (ink_tool->lasty - coords->y))); - - dist = dist_smoother_result (ink_tool); - } - - ink_tool->lastx = coords->x; - ink_tool->lasty = coords->y; - - velocity = 10.0 * sqrt ((dist) / (gdouble) (thistime - lasttime)); - - b = ink_pen_ellipse (coords->x, - coords->y, - coords->pressure, - coords->xtilt, - coords->ytilt, - velocity); - - blob_union = blob_convex_union (ink_tool->last_blob, b); - g_free (ink_tool->last_blob); - ink_tool->last_blob = b; - - ink_paste (ink_tool, drawable, blob_union); - g_free (blob_union); - - gimp_display_flush_now (gdisp); -} - -static void -ink_cursor_update (GimpTool *tool, - GimpCoords *coords, - GdkModifierType state, - GimpDisplay *gdisp) -{ - GimpDisplayShell *shell; - GimpLayer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - - shell = GIMP_DISPLAY_SHELL (gdisp->shell); - - if ((layer = gimp_image_get_active_layer (gdisp->gimage))) - { - gint off_x, off_y; - - gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y); - - if (coords->x >= off_x && - coords->y >= off_y && - coords->x < (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer))) && - coords->y < (off_y + gimp_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 = GIMP_MOUSE_CURSOR; - else if (gimage_mask_value (gdisp->gimage, coords->x, coords->y)) - ctype = GIMP_MOUSE_CURSOR; - } - } - - gimp_display_shell_install_tool_cursor (shell, - ctype, - GIMP_INK_TOOL_CURSOR, - GIMP_CURSOR_MODIFIER_NONE); -} - static void ink_init (GimpInkTool *ink_tool, GimpDrawable *drawable, @@ -1703,3 +1418,302 @@ ink_set_canvas_tiles (gint x, } } } + + +/* tool options stuff */ + +static InkOptions * +ink_options_new (void) +{ + InkOptions *options; + GtkWidget *table; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *hbox2; + GtkWidget *radio_button; + GtkWidget *pixmap_widget; + GtkWidget *slider; + GtkWidget *frame; + GtkWidget *darea; + GdkPixmap *pixmap; + + options = g_new0 (InkOptions, 1); + paint_options_init ((PaintOptions *) options, + GIMP_TYPE_INK_TOOL, + ink_options_reset); + + options->size = options->size_d = 4.4; + options->sensitivity = options->sensitivity_d = 1.0; + options->vel_sensitivity = options->vel_sensitivity_d = 0.8; + options->tilt_sensitivity = options->tilt_sensitivity_d = 0.4; + options->tilt_angle = options->tilt_angle_d = 0.0; + options->function = options->function_d = blob_ellipse; + options->aspect = options->aspect_d = 1.0; + options->angle = options->angle_d = 0.0; + + /* the main vbox */ + vbox = gtk_vbox_new (FALSE, 2); + gtk_box_pack_start (GTK_BOX (((GimpToolOptions *) options)->main_vbox), vbox, + TRUE, TRUE, 0); + gtk_widget_show (vbox); + + /* adjust sliders */ + frame = gtk_frame_new (_("Adjustment")); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); + gtk_widget_show (frame); + + table = gtk_table_new (2, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); + + /* size slider */ + options->size_w = + gtk_adjustment_new (options->size_d, 0.0, 20.0, 1.0, 2.0, 0.0); + slider = gtk_hscale_new (GTK_ADJUSTMENT (options->size_w)); + gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Size:"), 1.0, 1.0, + slider, 1, FALSE); + gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + + g_signal_connect (G_OBJECT (options->size_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->size); + + /* angle adjust slider */ + options->tilt_angle_w = + gtk_adjustment_new (options->tilt_angle_d, -90.0, 90.0, 1, 10.0, 0.0); + slider = gtk_hscale_new (GTK_ADJUSTMENT (options->tilt_angle_w)); + gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Angle:"), 1.0, 1.0, + slider, 1, FALSE); + gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + + g_signal_connect (G_OBJECT (options->tilt_angle_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->tilt_angle); + + /* sens sliders */ + frame = gtk_frame_new (_("Sensitivity")); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); + gtk_widget_show (frame); + + table = gtk_table_new (3, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); + + /* size sens slider */ + options->sensitivity_w = + gtk_adjustment_new (options->sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); + slider = gtk_hscale_new (GTK_ADJUSTMENT (options->sensitivity_w)); + gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Size:"), 1.0, 1.0, + slider, 1, FALSE); + gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + + g_signal_connect (G_OBJECT (options->sensitivity_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->sensitivity); + + /* tilt sens slider */ + options->tilt_sensitivity_w = + gtk_adjustment_new (options->tilt_sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); + slider = gtk_hscale_new (GTK_ADJUSTMENT (options->tilt_sensitivity_w)); + gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, + _("Tilt:"), 1.0, 1.0, + slider, 1, FALSE); + gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + + g_signal_connect (G_OBJECT (options->tilt_sensitivity_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->tilt_sensitivity); + + /* velocity sens slider */ + options->vel_sensitivity_w = + gtk_adjustment_new (options->vel_sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); + slider = gtk_hscale_new (GTK_ADJUSTMENT (options->vel_sensitivity_w)); + gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 3, + _("Speed:"), 1.0, 1.0, + slider, 1, FALSE); + gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + + g_signal_connect (G_OBJECT (options->vel_sensitivity_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->vel_sensitivity); + + /* bottom hbox */ + hbox = gtk_hbox_new (FALSE, 2); + gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); + gtk_widget_show (hbox); + + /* Brush type radiobuttons */ + frame = gtk_frame_new (_("Type")); + gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); + gtk_widget_show (frame); + + hbox2 = gtk_hbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (frame), hbox2); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); + gtk_box_pack_start (GTK_BOX (hbox2), vbox, FALSE, FALSE, 0); + gtk_widget_show (vbox); + + pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), + gtk_widget_get_visual (vbox), + blob_ellipse); + + pixmap_widget = gtk_pixmap_new (pixmap, NULL); + gdk_drawable_unref (pixmap); + gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); + + radio_button = gtk_radio_button_new (NULL); + gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); + gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); + + g_signal_connect (G_OBJECT (radio_button), "toggled", + G_CALLBACK (ink_type_update), + (gpointer) blob_ellipse); + + + options->function_w[0] = radio_button; + + pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), + gtk_widget_get_visual (vbox), + blob_square); + + pixmap_widget = gtk_pixmap_new (pixmap, NULL); + gdk_drawable_unref (pixmap); + gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); + + radio_button = + gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button)); + gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); + gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); + + g_signal_connect (G_OBJECT (radio_button), "toggled", + G_CALLBACK (ink_type_update), + (gpointer) blob_square); + + + options->function_w[1] = radio_button; + + pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), + gtk_widget_get_visual (vbox), + blob_diamond); + + pixmap_widget = gtk_pixmap_new (pixmap, NULL); + gdk_drawable_unref (pixmap); + gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); + + radio_button = + gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button)); + gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); + gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); + + g_signal_connect (G_OBJECT (radio_button), "toggled", + G_CALLBACK (ink_type_update), + (gpointer) blob_diamond); + + + options->function_w[2] = radio_button; + + /* Brush shape widget */ + frame = gtk_frame_new (_("Shape")); + gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); + gtk_widget_show (frame); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); + + frame = gtk_aspect_frame_new (NULL, 0.0, 0.5, 1.0, FALSE); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); + + options->brush_w = g_new (BrushWidget, 1); + options->brush_w->state = FALSE; + + darea = gtk_drawing_area_new(); + options->brush_w->widget = darea; + + gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 60, 60); + gtk_container_add (GTK_CONTAINER (frame), darea); + + gtk_widget_set_events (darea, + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK); + + g_signal_connect (G_OBJECT (darea), "button_press_event", + G_CALLBACK (brush_widget_button_press), + options->brush_w); + g_signal_connect (G_OBJECT (darea), "button_release_event", + G_CALLBACK (brush_widget_button_release), + options->brush_w); + g_signal_connect (G_OBJECT (darea), "motion_notify_event", + G_CALLBACK (brush_widget_motion_notify), + options->brush_w); + g_signal_connect (G_OBJECT (darea), "expose_event", + G_CALLBACK (brush_widget_expose), + options->brush_w); + g_signal_connect (G_OBJECT (darea), "realize", + G_CALLBACK (brush_widget_realize), + options->brush_w); + + gtk_widget_show_all (hbox); + + return options; +} + +static void +ink_options_reset (GimpToolOptions *tool_options) +{ + InkOptions *options; + + options = (InkOptions *) tool_options; + + paint_options_reset (tool_options); + + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->size_w), + options->size_d); + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->sensitivity_w), + options->sensitivity_d); + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->tilt_sensitivity_w), + options->tilt_sensitivity_d); + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->vel_sensitivity_w), + options->vel_sensitivity_d); + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->tilt_angle_w), + options->tilt_angle_d); + gtk_toggle_button_set_active (((options->function_d == blob_ellipse) ? + GTK_TOGGLE_BUTTON (options->function_w[0]) : + ((options->function_d == blob_square) ? + GTK_TOGGLE_BUTTON (options->function_w[1]) : + GTK_TOGGLE_BUTTON (options->function_w[2]))), + TRUE); + options->aspect = options->aspect_d; + options->angle = options->angle_d; + gtk_widget_queue_draw (options->brush_w->widget); +} + +static void +ink_type_update (GtkWidget *radio_button, + BlobFunc function) +{ + InkOptions *options = ink_options; + + if (GTK_TOGGLE_BUTTON (radio_button)->active) + options->function = function; + + gtk_widget_queue_draw (options->brush_w->widget); +} diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c index 0f0b8df773..89a28c90f7 100644 --- a/app/paint/gimpsmudge.c +++ b/app/paint/gimpsmudge.c @@ -36,6 +36,7 @@ #include "core/gimpcontext.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "gimpsmudgetool.h" #include "paint_options.h" @@ -189,18 +190,23 @@ gimp_smudge_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + SmudgeOptions *options; + /* initialization fails if the user starts outside the drawable */ static gboolean initialized = FALSE; + options = (SmudgeOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + switch (state) { case MOTION_PAINT: - if (!initialized) + if (! initialized) initialized = gimp_smudge_tool_start (paint_tool, drawable); if (initialized) gimp_smudge_tool_motion (paint_tool, - smudge_options->paint_options.pressure_options, - smudge_options->rate, drawable); + options->paint_options.pressure_options, + options->rate, + drawable); break; case FINISH_PAINT: diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c index c1284b14cc..1d77cb2e1c 100644 --- a/app/paint/gimpsourcecore.c +++ b/app/paint/gimpsourcecore.c @@ -33,12 +33,13 @@ #include "paint-funcs/paint-funcs.h" #include "core/gimp.h" +#include "core/gimpbrush.h" +#include "core/gimpcontext.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimppattern.h" -#include "core/gimpcontext.h" -#include "core/gimpbrush.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" @@ -279,17 +280,22 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + GimpTool *tool; + GimpDrawTool *draw_tool; + CloneOptions *options; GimpDisplay *gdisp; GimpDisplay *src_gdisp; gint x1, y1, x2, y2; static gint orig_src_x, orig_src_y; - GimpDrawTool *draw_tool; GimpContext *context; - gdisp = (GimpDisplay *) tool_manager_get_active (drawable->gimage->gimp)->gdisp; - + tool = GIMP_TOOL (paint_tool); draw_tool = GIMP_DRAW_TOOL (paint_tool); + options = (CloneOptions *) tool->tool_info->tool_options; + + gdisp = tool->gdisp; + context = gimp_get_current_context (gdisp->gimage->gimp); switch (state) @@ -317,7 +323,7 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, dest_x = x1; dest_y = y1; - if (clone_options->aligned == ALIGN_REGISTERED) + if (options->aligned == ALIGN_REGISTERED) { offset_x = 0; offset_y = 0; @@ -333,8 +339,9 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, src_y = dest_y + offset_y; gimp_clone_tool_motion (paint_tool, drawable, src_drawable_, - clone_options->paint_options.pressure_options, - clone_options->type, offset_x, offset_y); + options->paint_options.pressure_options, + options->type, + offset_x, offset_y); } break; @@ -348,20 +355,21 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, src_y = paint_tool->cur_coords.y; first = TRUE; } - else if (clone_options->aligned == ALIGN_NO) + else if (options->aligned == ALIGN_NO) { first = TRUE; orig_src_x = src_x; orig_src_y = src_y; } - if (clone_options->type == PATTERN_CLONE) + + if (options->type == PATTERN_CLONE) if (! gimp_context_get_pattern (context)) g_message (_("No patterns available for this operation.")); break; case FINISH_PAINT: gimp_draw_tool_stop (draw_tool); - if (clone_options->aligned == ALIGN_NO && !first) + if (options->aligned == ALIGN_NO && !first) { src_x = orig_src_x; src_y = orig_src_y; @@ -405,10 +413,13 @@ gimp_clone_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + CloneOptions *options; GimpDisplayShell *shell; GimpLayer *layer; GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + options = (CloneOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); if ((layer = gimp_image_get_active_layer (gdisp->gimage))) @@ -432,7 +443,7 @@ gimp_clone_tool_cursor_update (GimpTool *tool, } } - if (clone_options->type == IMAGE_CLONE) + if (options->type == IMAGE_CLONE) { if (state & GDK_CONTROL_MASK) ctype = GIMP_CROSSHAIR_SMALL_CURSOR; @@ -451,7 +462,11 @@ gimp_clone_tool_cursor_update (GimpTool *tool, static void gimp_clone_tool_draw (GimpDrawTool *draw_tool) { - if (draw_tool->gc != NULL && clone_options->type == IMAGE_CLONE) + CloneOptions *options; + + options = (CloneOptions *) GIMP_TOOL (draw_tool)->tool_info->tool_options; + + if (draw_tool->gc != NULL && options->type == IMAGE_CLONE) { gdk_draw_line (draw_tool->win, draw_tool->gc, trans_tx - (TARGET_WIDTH >> 1), trans_ty, diff --git a/app/tools/gimpbezierselecttool.c b/app/tools/gimpbezierselecttool.c index d741b257e3..695722a50a 100644 --- a/app/tools/gimpbezierselecttool.c +++ b/app/tools/gimpbezierselecttool.c @@ -50,7 +50,6 @@ #include "gimpeditselectiontool.h" #include "gimpbezierselecttool.h" #include "selection_options.h" -#include "tool_options.h" #include "tool_manager.h" #include "app_procs.h" @@ -118,45 +117,6 @@ typedef struct gint found; } BezierCheckPnts; -/* the bezier selection tool options */ -static SelectionOptions *bezier_options = NULL; - -/* local variables */ -static BezierMatrix basis = -{ - { -1, 3, -3, 1 }, - { 3, -6, 3, 0 }, - { -3, 3, 0, 0 }, - { 1, 0, 0, 0 }, -}; - -/* -static BezierMatrix basis = -{ - { -1/6.0, 3/6.0, -3/6.0, 1/6.0 }, - { 3/6.0, -6/6.0, 3/6.0, 0 }, - { -3/6.0, 0, 3/6.0, 0 }, - { 1/6.0, 4/6.0, 1, 0 }, -}; -*/ - -/* Global Static Variable to maintain informations about the "context" */ -static GimpBezierSelectTool *curSel = NULL; -static GimpTool *curTool = NULL; -static GimpDisplay *curGdisp = NULL; -static GimpDrawTool *curCore = NULL; -static gint ModeEdit = EXTEND_NEW; - - -enum -{ - BEZIER_SELECT, - LAST_SIGNAL -}; - -static GimpSelectionToolClass *parent_class = NULL; - -static guint bezier_select_signals[LAST_SIGNAL] = { 0 }; static void gimp_bezier_select_tool_class_init (GimpBezierSelectToolClass *klass); static void gimp_bezier_select_tool_init (GimpBezierSelectTool *bezier_select); @@ -281,6 +241,37 @@ static void bezier_start_new_segment (GimpBezierSelectTool *bezier_sel, gint y); +/* local variables */ + +static BezierMatrix basis = +{ + { -1, 3, -3, 1 }, + { 3, -6, 3, 0 }, + { -3, 3, 0, 0 }, + { 1, 0, 0, 0 }, +}; + +/* +static BezierMatrix basis = +{ + { -1/6.0, 3/6.0, -3/6.0, 1/6.0 }, + { 3/6.0, -6/6.0, 3/6.0, 0 }, + { -3/6.0, 0, 3/6.0, 0 }, + { 1/6.0, 4/6.0, 1, 0 }, +}; +*/ + +/* Global Static Variable to maintain informations about the "context" */ +static GimpBezierSelectTool *curSel = NULL; +static GimpTool *curTool = NULL; +static GimpDisplay *curGdisp = NULL; +static GimpDrawTool *curCore = NULL; +static gint ModeEdit = EXTEND_NEW; + +static SelectionOptions *bezier_options = NULL; + +static GimpSelectionToolClass *parent_class = NULL; + /* Public functions */ @@ -342,19 +333,6 @@ gimp_bezier_select_tool_class_init (GimpBezierSelectToolClass *klass) parent_class = g_type_class_peek_parent (klass); - bezier_select_signals[BEZIER_SELECT] = - g_signal_new ("bezier_select", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GimpBezierSelectToolClass, bezier_select), - NULL, NULL, - gimp_cclosure_marshal_VOID__INT_INT_INT_INT, - G_TYPE_NONE, 4, - G_TYPE_INT, - G_TYPE_INT, - G_TYPE_INT, - G_TYPE_INT); - tool_class->button_press = gimp_bezier_select_tool_button_press; tool_class->button_release = gimp_bezier_select_tool_button_release; tool_class->motion = gimp_bezier_select_tool_motion; @@ -362,8 +340,6 @@ gimp_bezier_select_tool_class_init (GimpBezierSelectToolClass *klass) tool_class->cursor_update = gimp_bezier_select_tool_cursor_update; draw_tool_class->draw = bezier_select_draw; - - /* klass->bezier_select = gimp_bezier_select_tool_real_bezier_select; */ } static void @@ -3034,18 +3010,22 @@ bezier_to_sel_internal (GimpBezierSelectTool *bezier_sel, GimpDisplay *gdisp, ChannelOps op) { + SelectionOptions *sel_options; + + sel_options = (SelectionOptions *) GIMP_TOOL (bezier_sel)->tool_info->tool_options; + /* If we're antialiased, then recompute the mask... */ - if (bezier_options->antialias) + if (sel_options->antialias) bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, TRUE); gimp_image_mask_select_channel (gdisp->gimage, NULL, FALSE, bezier_sel->mask, op, - bezier_options->feather, - bezier_options->feather_radius, - bezier_options->feather_radius); + sel_options->feather, + sel_options->feather_radius, + sel_options->feather_radius); /* show selection on all views */ gdisplays_flush (); diff --git a/app/tools/gimpbezierselecttool.h b/app/tools/gimpbezierselecttool.h index 42dfaac040..64f214b0bb 100644 --- a/app/tools/gimpbezierselecttool.h +++ b/app/tools/gimpbezierselecttool.h @@ -90,12 +90,6 @@ struct _GimpBezierSelectTool struct _GimpBezierSelectToolClass { GimpSelectionToolClass parent_class; - - void (* bezier_select) (GimpBezierSelectTool *rect_tool, - gint x, - gint y, - gint w, - gint h); }; typedef void (* GimpBezierSelectPointsFunc) (GimpBezierSelectTool *bezier_sel, diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c index 1d481a55b4..970c973d84 100644 --- a/app/tools/gimpblendtool.c +++ b/app/tools/gimpblendtool.c @@ -294,9 +294,10 @@ gimp_blend_tool_button_release (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpImage *gimage; GimpBlendTool *blend_tool; + BlendOptions *options; GimpDisplayShell *shell; + GimpImage *gimage; #ifdef BLEND_UI_CALLS_VIA_PDB Argument *return_vals; gint nreturn_vals; @@ -306,6 +307,8 @@ gimp_blend_tool_button_release (GimpTool *tool, blend_tool = GIMP_BLEND_TOOL (tool); + options = (BlendOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); gimage = gdisp->gimage; @@ -331,15 +334,15 @@ gimp_blend_tool_button_release (GimpTool *tool, procedural_db_run_proc ("gimp_blend", &nreturn_vals, PDB_DRAWABLE, drawable_ID (gimp_image_active_drawable (gimage)), - PDB_INT32, (gint32) blend_options->blend_mode, - PDB_INT32, (gint32) PAINT_OPTIONS_GET_PAINT_MODE (blend_options), - PDB_INT32, (gint32) blend_options->gradient_type, - PDB_FLOAT, (gdouble) PAINT_OPTIONS_GET_OPACITY (blend_options) * 100, - PDB_FLOAT, (gdouble) blend_options->offset, - PDB_INT32, (gint32) blend_options->repeat, - PDB_INT32, (gint32) blend_options->supersample, - PDB_INT32, (gint32) blend_options->max_depth, - PDB_FLOAT, (gdouble) blend_options->threshold, + PDB_INT32, (gint32) options->blend_mode, + PDB_INT32, (gint32) PAINT_OPTIONS_GET_PAINT_MODE (options), + PDB_INT32, (gint32) options->gradient_type, + PDB_FLOAT, (gdouble) PAINT_OPTIONS_GET_OPACITY (options) * 100, + PDB_FLOAT, (gdouble) options->offset, + PDB_INT32, (gint32) options->repeat, + PDB_INT32, (gint32) options->supersample, + PDB_INT32, (gint32) options->max_depth, + PDB_FLOAT, (gdouble) options->threshold, PDB_FLOAT, (gdouble) blend_tool->startx, PDB_FLOAT, (gdouble) blend_tool->starty, PDB_FLOAT, (gdouble) blend_tool->endx, @@ -358,15 +361,15 @@ gimp_blend_tool_button_release (GimpTool *tool, progress = progress_start (gdisp, _("Blending..."), FALSE, NULL, NULL); gimp_drawable_blend (gimp_image_active_drawable (gimage), - blend_options->blend_mode, + options->blend_mode, gimp_context_get_paint_mode (gimp_get_current_context (gimage->gimp)), - blend_options->gradient_type, + options->gradient_type, gimp_context_get_opacity (gimp_get_current_context (gimage->gimp)), - blend_options->offset, - blend_options->repeat, - blend_options->supersample, - blend_options->max_depth, - blend_options->threshold, + options->offset, + options->repeat, + options->supersample, + options->max_depth, + options->threshold, blend_tool->startx, blend_tool->starty, blend_tool->endx, diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c index 3e13190b0f..712baefe84 100644 --- a/app/tools/gimpbucketfilltool.c +++ b/app/tools/gimpbucketfilltool.c @@ -31,6 +31,7 @@ #include "core/gimpdrawable-bucket-fill.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" +#include "core/gimptoolinfo.h" #include "pdb/procedural_db.h" @@ -191,16 +192,19 @@ gimp_bucket_fill_tool_button_press (GimpTool *tool, GimpDisplay *gdisp) { GimpBucketFillTool *bucket_tool; + BucketOptions *options; GimpDisplayShell *shell; bucket_tool = GIMP_BUCKET_FILL_TOOL (tool); + options = (BucketOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); bucket_tool->target_x = coords->x; bucket_tool->target_y = coords->y; - if (! bucket_options->sample_merged) + if (! options->sample_merged) { gint off_x, off_y; @@ -230,11 +234,14 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool, GimpDisplay *gdisp) { GimpBucketFillTool *bucket_tool; + BucketOptions *options; Argument *return_vals; gint nreturn_vals; bucket_tool = GIMP_BUCKET_FILL_TOOL (tool); + options = (BucketOptions *) tool->tool_info->tool_options; + gdk_pointer_ungrab (time); gdk_flush (); @@ -250,11 +257,11 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool, "gimp_bucket_fill", &nreturn_vals, GIMP_PDB_DRAWABLE, gimp_drawable_get_ID (gimp_image_active_drawable (gdisp->gimage)), - GIMP_PDB_INT32, (gint32) bucket_options->fill_mode, + GIMP_PDB_INT32, (gint32) options->fill_mode, GIMP_PDB_INT32, (gint32) gimp_context_get_paint_mode (context), GIMP_PDB_FLOAT, (gdouble) gimp_context_get_opacity (context) * 100, - GIMP_PDB_FLOAT, (gdouble) bucket_options->threshold, - GIMP_PDB_INT32, (gint32) bucket_options->sample_merged, + GIMP_PDB_FLOAT, (gdouble) options->threshold, + GIMP_PDB_INT32, (gint32) options->sample_merged, GIMP_PDB_FLOAT, (gdouble) bucket_tool->target_x, GIMP_PDB_FLOAT, (gdouble) bucket_tool->target_y, GIMP_PDB_END); @@ -277,19 +284,21 @@ gimp_bucket_fill_tool_modifier_key (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + BucketOptions *options; + + options = (BucketOptions *) tool->tool_info->tool_options; + if (key == GDK_CONTROL_MASK) { - switch (bucket_options->fill_mode) + switch (options->fill_mode) { case FG_BUCKET_FILL: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (bucket_options->fill_mode_w[BG_BUCKET_FILL]), - TRUE); + (GTK_TOGGLE_BUTTON (options->fill_mode_w[BG_BUCKET_FILL]), TRUE); break; case BG_BUCKET_FILL: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (bucket_options->fill_mode_w[FG_BUCKET_FILL]), - TRUE); + (GTK_TOGGLE_BUTTON (options->fill_mode_w[FG_BUCKET_FILL]), TRUE); break; default: break; @@ -303,12 +312,15 @@ gimp_bucket_fill_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + BucketOptions *options; GimpDisplayShell *shell; GimpLayer *layer; GdkCursorType ctype = GDK_TOP_LEFT_ARROW; GimpCursorModifier cmodifier = GIMP_CURSOR_MODIFIER_NONE; gint off_x, off_y; + options = (BucketOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); if ((layer = gimp_image_get_active_layer (gdisp->gimage))) @@ -328,7 +340,7 @@ gimp_bucket_fill_tool_cursor_update (GimpTool *tool, { ctype = GIMP_MOUSE_CURSOR; - switch (bucket_options->fill_mode) + switch (options->fill_mode) { case FG_BUCKET_FILL: cmodifier = GIMP_CURSOR_MODIFIER_FOREGROUND; diff --git a/app/tools/gimpbycolorselecttool.c b/app/tools/gimpbycolorselecttool.c index 1df5436684..52f30cabfc 100644 --- a/app/tools/gimpbycolorselecttool.c +++ b/app/tools/gimpbycolorselecttool.c @@ -33,13 +33,14 @@ #include "paint-funcs/paint-funcs.h" +#include "core/gimpchannel.h" +#include "core/gimpcontainer.h" #include "core/gimpdrawable.h" #include "core/gimpimage-contiguous-region.h" #include "core/gimpimage-mask.h" #include "core/gimpimage-mask-select.h" -#include "core/gimpchannel.h" -#include "core/gimpcontainer.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "widgets/gimpdnd.h" @@ -49,7 +50,6 @@ #include "gimpbycolorselecttool.h" #include "selection_options.h" -#include "tool_options.h" #include "tool_manager.h" #include "gimprc.h" @@ -313,11 +313,14 @@ by_color_select_button_press (GimpTool *tool, { GimpByColorSelectTool *by_color_sel; GimpDrawTool *draw_tool; + SelectionOptions *sel_options; GimpDisplayShell *shell; draw_tool = GIMP_DRAW_TOOL (tool); by_color_sel = GIMP_BY_COLOR_SELECT_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); tool->drawable = gimp_image_active_drawable (gdisp->gimage); @@ -331,7 +334,7 @@ by_color_select_button_press (GimpTool *tool, by_color_sel->x = coords->x; by_color_sel->y = coords->y; - if (! by_color_options->sample_merged) + if (! sel_options->sample_merged) { gint off_x, off_y; @@ -374,12 +377,15 @@ by_color_select_button_release (GimpTool *tool, GimpDisplay *gdisp) { GimpByColorSelectTool *by_color_sel; + SelectionOptions *sel_options; GimpDrawable *drawable; guchar *col; GimpRGB color; by_color_sel = GIMP_BY_COLOR_SELECT_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + drawable = gimp_image_active_drawable (gdisp->gimage); gdk_pointer_ungrab (time); @@ -395,7 +401,7 @@ by_color_select_button_release (GimpTool *tool, by_color_sel->y < gimp_drawable_height (drawable)) { /* Get the start color */ - if (by_color_options->sample_merged) + if (sel_options->sample_merged) { if (!(col = gimp_image_get_color_at (gdisp->gimage, by_color_sel->x, @@ -416,14 +422,14 @@ by_color_select_button_release (GimpTool *tool, /* select the area */ gimp_image_mask_select_by_color (gdisp->gimage, drawable, - by_color_options->sample_merged, + sel_options->sample_merged, &color, by_color_dialog->threshold, by_color_sel->operation, - by_color_options->antialias, - by_color_options->feather, - by_color_options->feather_radius, - by_color_options->feather_radius); + sel_options->antialias, + sel_options->feather, + sel_options->feather_radius, + sel_options->feather_radius); /* show selection on all views */ gdisplays_flush (); @@ -481,16 +487,19 @@ by_color_select_cursor_update (GimpTool *tool, GimpDisplay *gdisp) { GimpByColorSelectTool *by_col_sel; + SelectionOptions *sel_options; GimpDisplayShell *shell; GimpLayer *layer; by_col_sel = GIMP_BY_COLOR_SELECT_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); layer = gimp_image_pick_correlate_layer (gdisp->gimage, coords->x, coords->y); - if (by_color_options->sample_merged || + if (sel_options->sample_merged || (layer && layer == gdisp->gimage->active_layer)) { switch (by_col_sel->operation) @@ -992,7 +1001,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd, guchar *col; GimpRGB color; - if (!bcd->gimage) + if (! bcd->gimage) return; drawable = gimp_image_active_drawable (bcd->gimage); @@ -1081,6 +1090,7 @@ by_color_select_color_drop (GtkWidget *widget, ByColorDialog *bcd; bcd = (ByColorDialog*) data; + drawable = gimp_image_active_drawable (bcd->gimage); gimp_image_mask_select_by_color (bcd->gimage, drawable, diff --git a/app/tools/gimpclonetool.c b/app/tools/gimpclonetool.c index c1284b14cc..1d77cb2e1c 100644 --- a/app/tools/gimpclonetool.c +++ b/app/tools/gimpclonetool.c @@ -33,12 +33,13 @@ #include "paint-funcs/paint-funcs.h" #include "core/gimp.h" +#include "core/gimpbrush.h" +#include "core/gimpcontext.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimppattern.h" -#include "core/gimpcontext.h" -#include "core/gimpbrush.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" @@ -279,17 +280,22 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + GimpTool *tool; + GimpDrawTool *draw_tool; + CloneOptions *options; GimpDisplay *gdisp; GimpDisplay *src_gdisp; gint x1, y1, x2, y2; static gint orig_src_x, orig_src_y; - GimpDrawTool *draw_tool; GimpContext *context; - gdisp = (GimpDisplay *) tool_manager_get_active (drawable->gimage->gimp)->gdisp; - + tool = GIMP_TOOL (paint_tool); draw_tool = GIMP_DRAW_TOOL (paint_tool); + options = (CloneOptions *) tool->tool_info->tool_options; + + gdisp = tool->gdisp; + context = gimp_get_current_context (gdisp->gimage->gimp); switch (state) @@ -317,7 +323,7 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, dest_x = x1; dest_y = y1; - if (clone_options->aligned == ALIGN_REGISTERED) + if (options->aligned == ALIGN_REGISTERED) { offset_x = 0; offset_y = 0; @@ -333,8 +339,9 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, src_y = dest_y + offset_y; gimp_clone_tool_motion (paint_tool, drawable, src_drawable_, - clone_options->paint_options.pressure_options, - clone_options->type, offset_x, offset_y); + options->paint_options.pressure_options, + options->type, + offset_x, offset_y); } break; @@ -348,20 +355,21 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, src_y = paint_tool->cur_coords.y; first = TRUE; } - else if (clone_options->aligned == ALIGN_NO) + else if (options->aligned == ALIGN_NO) { first = TRUE; orig_src_x = src_x; orig_src_y = src_y; } - if (clone_options->type == PATTERN_CLONE) + + if (options->type == PATTERN_CLONE) if (! gimp_context_get_pattern (context)) g_message (_("No patterns available for this operation.")); break; case FINISH_PAINT: gimp_draw_tool_stop (draw_tool); - if (clone_options->aligned == ALIGN_NO && !first) + if (options->aligned == ALIGN_NO && !first) { src_x = orig_src_x; src_y = orig_src_y; @@ -405,10 +413,13 @@ gimp_clone_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + CloneOptions *options; GimpDisplayShell *shell; GimpLayer *layer; GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + options = (CloneOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); if ((layer = gimp_image_get_active_layer (gdisp->gimage))) @@ -432,7 +443,7 @@ gimp_clone_tool_cursor_update (GimpTool *tool, } } - if (clone_options->type == IMAGE_CLONE) + if (options->type == IMAGE_CLONE) { if (state & GDK_CONTROL_MASK) ctype = GIMP_CROSSHAIR_SMALL_CURSOR; @@ -451,7 +462,11 @@ gimp_clone_tool_cursor_update (GimpTool *tool, static void gimp_clone_tool_draw (GimpDrawTool *draw_tool) { - if (draw_tool->gc != NULL && clone_options->type == IMAGE_CLONE) + CloneOptions *options; + + options = (CloneOptions *) GIMP_TOOL (draw_tool)->tool_info->tool_options; + + if (draw_tool->gc != NULL && options->type == IMAGE_CLONE) { gdk_draw_line (draw_tool->win, draw_tool->gc, trans_tx - (TARGET_WIDTH >> 1), trans_ty, diff --git a/app/tools/gimpcolorpickertool.c b/app/tools/gimpcolorpickertool.c index 2689064b75..9d46adfe77 100644 --- a/app/tools/gimpcolorpickertool.c +++ b/app/tools/gimpcolorpickertool.c @@ -285,12 +285,15 @@ gimp_color_picker_tool_button_press (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpColorPickerTool *cp_tool; - GimpDisplayShell *shell; - gint off_x, off_y; + GimpColorPickerTool *cp_tool; + GimpColorPickerToolOptions *options; + GimpDisplayShell *shell; + gint off_x, off_y; cp_tool = GIMP_COLOR_PICKER_TOOL (tool); + options = (GimpColorPickerToolOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); /* Make the tool active and set it's gdisplay & drawable */ @@ -391,28 +394,30 @@ gimp_color_picker_tool_button_press (GimpTool *tool, */ if (state & GDK_SHIFT_MASK) { - gimp_color_picker_tool_info_update - (tool, pick_color_do (gdisp->gimage, tool->drawable, - coords->x, - coords->y, - gimp_color_picker_tool_options->sample_merged, - gimp_color_picker_tool_options->sample_average, - gimp_color_picker_tool_options->average_radius, - gimp_color_picker_tool_options->update_active, - COLOR_NEW)); + gimp_color_picker_tool_info_update (tool, + pick_color_do (gdisp->gimage, + tool->drawable, + coords->x, + coords->y, + options->sample_merged, + options->sample_average, + options->average_radius, + options->update_active, + COLOR_NEW)); update_type = COLOR_UPDATE_NEW; } else { - gimp_color_picker_tool_info_update - (tool, pick_color_do (gdisp->gimage, tool->drawable, - coords->x, - coords->y, - gimp_color_picker_tool_options->sample_merged, - gimp_color_picker_tool_options->sample_average, - gimp_color_picker_tool_options->average_radius, - gimp_color_picker_tool_options->update_active, - COLOR_UPDATE)); + gimp_color_picker_tool_info_update (tool, + pick_color_do (gdisp->gimage, + tool->drawable, + coords->x, + coords->y, + options->sample_merged, + options->sample_average, + options->average_radius, + options->update_active, + COLOR_UPDATE)); update_type = COLOR_UPDATE; } @@ -427,22 +432,26 @@ gimp_color_picker_tool_button_release (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpColorPickerTool *cp_tool; + GimpColorPickerTool *cp_tool; + GimpColorPickerToolOptions *options; + + cp_tool = GIMP_COLOR_PICKER_TOOL(tool); + + options = (GimpColorPickerToolOptions *) tool->tool_info->tool_options; gdk_pointer_ungrab (time); gdk_flush (); - cp_tool = GIMP_COLOR_PICKER_TOOL(tool); - - gimp_color_picker_tool_info_update - (tool, pick_color_do (gdisp->gimage, tool->drawable, - coords->x, - coords->y, - gimp_color_picker_tool_options->sample_merged, - gimp_color_picker_tool_options->sample_average, - gimp_color_picker_tool_options->average_radius, - gimp_color_picker_tool_options->update_active, - update_type)); + gimp_color_picker_tool_info_update (tool, + pick_color_do (gdisp->gimage, + tool->drawable, + coords->x, + coords->y, + options->sample_merged, + options->sample_average, + options->average_radius, + options->update_active, + update_type)); gimp_draw_tool_stop (GIMP_DRAW_TOOL (cp_tool)); @@ -456,11 +465,14 @@ gimp_color_picker_tool_motion (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { - GimpColorPickerTool *cp_tool; - gint off_x, off_y; + GimpColorPickerTool *cp_tool; + GimpColorPickerToolOptions *options; + gint off_x, off_y; cp_tool = GIMP_COLOR_PICKER_TOOL (tool); + options = (GimpColorPickerToolOptions *) tool->tool_info->tool_options; + gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage), @@ -469,15 +481,16 @@ gimp_color_picker_tool_motion (GimpTool *tool, cp_tool->centerx = coords->x - off_x; cp_tool->centery = coords->y - off_y; - gimp_color_picker_tool_info_update - (tool, pick_color_do (gdisp->gimage, tool->drawable, - coords->x, - coords->y, - gimp_color_picker_tool_options->sample_merged, - gimp_color_picker_tool_options->sample_average, - gimp_color_picker_tool_options->average_radius, - gimp_color_picker_tool_options->update_active, - update_type)); + gimp_color_picker_tool_info_update (tool, + pick_color_do (gdisp->gimage, + tool->drawable, + coords->x, + coords->y, + options->sample_merged, + options->sample_average, + options->average_radius, + options->update_active, + update_type)); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); } diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index dfc28de96a..82ccb1dcb4 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -32,13 +32,14 @@ #include "core/gimpimage.h" #include "core/gimpimage-crop.h" #include "core/gimpimage-mask.h" - -#include "gui/info-dialog.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" #include "display/gimpdisplayshell.h" +#include "gui/info-dialog.h" + #include "gimpcroptool.h" #include "gimpdrawtool.h" #include "gimptool.h" @@ -422,10 +423,13 @@ gimp_crop_tool_button_release (GimpTool *tool, GimpDisplay *gdisp) { GimpCropTool *crop; + CropOptions *options; GimpDisplayShell *shell; crop = GIMP_CROP_TOOL (tool); + options = (CropOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); gdk_pointer_ungrab (time); @@ -437,17 +441,17 @@ gimp_crop_tool_button_release (GimpTool *tool, { if (crop->function == CROPPING) { - if (crop_options->type == CROP_CROP) + if (options->type == CROP_CROP) crop_tool_crop_image (gdisp->gimage, crop->x1, crop->y1, crop->x2, crop->y2, - crop_options->layer_only, + options->layer_only, TRUE); else crop_tool_crop_image (gdisp->gimage, crop->x1, crop->y1, crop->x2, crop->y2, - crop_options->layer_only, + options->layer_only, FALSE); /* Finish the tool */ @@ -468,6 +472,7 @@ gimp_crop_tool_motion (GimpTool *tool, GimpDisplay *gdisp) { GimpCropTool *crop; + CropOptions *options; GimpDisplayShell *shell; GimpLayer *layer; gint x1, y1, x2, y2; @@ -478,6 +483,8 @@ gimp_crop_tool_motion (GimpTool *tool, crop = GIMP_CROP_TOOL (tool); + options = (CropOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); /* This is the only case when the motion events should be ignored-- @@ -502,7 +509,7 @@ gimp_crop_tool_motion (GimpTool *tool, gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); - if (crop_options->layer_only) + if (options->layer_only) { layer = gimp_image_get_active_layer (gdisp->gimage); gimp_drawable_offsets (GIMP_DRAWABLE (layer), &min_x, &min_y); @@ -519,7 +526,7 @@ gimp_crop_tool_motion (GimpTool *tool, switch (crop->function) { case CREATING: - if (! crop_options->allow_enlarge) + if (! options->allow_enlarge) { x1 = CLAMP (x1, min_x, max_x); y1 = CLAMP (y1, min_y, max_y); @@ -531,7 +538,7 @@ gimp_crop_tool_motion (GimpTool *tool, case RESIZING_LEFT: x1 = crop->x1 + inc_x; y1 = crop->y1 + inc_y; - if (! crop_options->allow_enlarge) + if (! options->allow_enlarge) { x1 = CLAMP (x1, min_x, max_x); y1 = CLAMP (y1, min_y, max_y); @@ -545,7 +552,7 @@ gimp_crop_tool_motion (GimpTool *tool, case RESIZING_RIGHT: x2 = crop->x2 + inc_x; y2 = crop->y2 + inc_y; - if (! crop_options->allow_enlarge) + if (! options->allow_enlarge) { x2 = CLAMP (x2, min_x, max_x); y2 = CLAMP (y2, min_y, max_y); @@ -556,8 +563,8 @@ gimp_crop_tool_motion (GimpTool *tool, crop->starty = cury; break; - case MOVING : - if (! crop_options->allow_enlarge) + case MOVING: + if (! options->allow_enlarge) { inc_x = CLAMP (inc_x, min_x - crop->x1, max_x - crop->x2); inc_y = CLAMP (inc_y, min_y - crop->y1, max_y - crop->y2); @@ -619,14 +626,17 @@ gimp_crop_tool_arrow_key (GimpTool *tool, GdkEventKey *kevent, GimpDisplay *gdisp) { - GimpLayer *layer; GimpCropTool *crop; + CropOptions *options; + GimpLayer *layer; gint inc_x, inc_y; gint min_x, min_y; gint max_x, max_y; crop = GIMP_CROP_TOOL (tool); + options = (CropOptions *) tool->tool_info->tool_options; + if (tool->state == ACTIVE) { inc_x = inc_y = 0; @@ -648,7 +658,7 @@ gimp_crop_tool_arrow_key (GimpTool *tool, gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); - if (crop_options->layer_only) + if (options->layer_only) { layer = gimp_image_get_active_layer (gdisp->gimage); gimp_drawable_offsets (GIMP_DRAWABLE (layer), &min_x, &min_y); @@ -666,7 +676,7 @@ gimp_crop_tool_arrow_key (GimpTool *tool, { crop->x2 = crop->x2 + inc_x; crop->y2 = crop->y2 + inc_y; - if (!crop_options->allow_enlarge) + if (! options->allow_enlarge) { crop->x2 = CLAMP (crop->x2, min_x, max_x); crop->y2 = CLAMP (crop->y2, min_y, max_y); @@ -676,7 +686,7 @@ gimp_crop_tool_arrow_key (GimpTool *tool, } else { - if (!crop_options->allow_enlarge) + if (! options->allow_enlarge) { inc_x = CLAMP (inc_x, -crop->x1, gdisp->gimage->width - crop->x2); @@ -702,34 +712,38 @@ gimp_crop_tool_modifier_key (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + CropOptions *options; + + options = (CropOptions *) tool->tool_info->tool_options; + if (state & GDK_MOD1_MASK) { - if (! crop_options->allow_enlarge) + if (! options->allow_enlarge) { gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (crop_options->allow_enlarge_w), TRUE); + (GTK_TOGGLE_BUTTON (options->allow_enlarge_w), TRUE); } } else { - if (crop_options->allow_enlarge) + if (options->allow_enlarge) { gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (crop_options->allow_enlarge_w), FALSE); + (GTK_TOGGLE_BUTTON (options->allow_enlarge_w), FALSE); } } if (key == GDK_CONTROL_MASK) { - switch (crop_options->type) + switch (options->type) { case CROP_CROP: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (crop_options->type_w[RESIZE_CROP]), TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[RESIZE_CROP]), TRUE); break; case RESIZE_CROP: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (crop_options->type_w[CROP_CROP]), TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[CROP_CROP]), TRUE); break; default: break; @@ -745,6 +759,7 @@ gimp_crop_tool_cursor_update (GimpTool *tool, { GimpCropTool *crop; GimpDrawTool *draw_tool; + CropOptions *options; GimpDisplayShell *shell; GdkCursorType ctype = GIMP_MOUSE_CURSOR; GimpCursorModifier cmodifier = GIMP_CURSOR_MODIFIER_NONE; @@ -752,6 +767,8 @@ gimp_crop_tool_cursor_update (GimpTool *tool, crop = GIMP_CROP_TOOL (tool); draw_tool = GIMP_DRAW_TOOL (tool); + options = (CropOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); if (tool->state == INACTIVE || @@ -801,7 +818,7 @@ gimp_crop_tool_cursor_update (GimpTool *tool, gimp_display_shell_install_tool_cursor (shell, ctype, - crop_options->type == CROP_CROP ? + options->type == CROP_CROP ? GIMP_CROP_TOOL_CURSOR : GIMP_RESIZE_TOOL_CURSOR, cmodifier); @@ -1091,19 +1108,26 @@ static void crop_crop_callback (GtkWidget *widget, gpointer data) { - GimpTool *tool; - GimpCropTool *crop; + GimpTool *tool; /* XXX active_tool is bad */ tool = tool_manager_get_active (the_gimp); - crop = GIMP_CROP_TOOL (tool); + if (GIMP_IS_CROP_TOOL (tool)) + { + GimpCropTool *crop; + CropOptions *options; - crop_tool_crop_image (tool->gdisp->gimage, - crop->x1, crop->y1, - crop->x2, crop->y2, - crop_options->layer_only, - TRUE); + crop = GIMP_CROP_TOOL (tool); + + options = (CropOptions *) tool->tool_info->tool_options; + + crop_tool_crop_image (tool->gdisp->gimage, + crop->x1, crop->y1, + crop->x2, crop->y2, + options->layer_only, + TRUE); + } /* Finish the tool */ crop_close_callback (NULL, NULL); @@ -1113,19 +1137,26 @@ static void crop_resize_callback (GtkWidget *widget, gpointer data) { - GimpTool *tool; - GimpCropTool *crop; + GimpTool *tool; /* XXX active_tool is bad */ tool = tool_manager_get_active (the_gimp); - crop = GIMP_CROP_TOOL (tool); + if (GIMP_IS_CROP_TOOL (tool)) + { + GimpCropTool *crop; + CropOptions *options; - crop_tool_crop_image (tool->gdisp->gimage, - crop->x1, crop->y1, - crop->x2, crop->y2, - crop_options->layer_only, - FALSE); + crop = GIMP_CROP_TOOL (tool); + + options = (CropOptions *) tool->tool_info->tool_options; + + crop_tool_crop_image (tool->gdisp->gimage, + crop->x1, crop->y1, + crop->x2, crop->y2, + options->layer_only, + FALSE); + } /* Finish the tool */ crop_close_callback (NULL, NULL); @@ -1140,122 +1171,140 @@ crop_close_callback (GtkWidget *widget, /* XXX active_tool is bad */ tool = tool_manager_get_active (the_gimp); - if (tool->state == ACTIVE) - gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool)); + if (GIMP_IS_CROP_TOOL (tool)) + { + if (tool->state == ACTIVE) + gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool)); + + tool->state = INACTIVE; + } info_dialog_popdown (crop_info); - - tool->state = INACTIVE; } static void crop_selection_callback (GtkWidget *widget, gpointer data) { - GimpTool *tool; - GimpCropTool *crop; - GimpLayer *layer; - GimpDisplay *gdisp; + GimpTool *tool; /* XXX active_tool is bad */ tool = tool_manager_get_active (the_gimp); - crop = GIMP_CROP_TOOL (tool); - - gdisp = tool->gdisp; - - gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); - - if (! gimage_mask_bounds (gdisp->gimage, - &crop->x1, &crop->y1, &crop->x2, &crop->y2)) + if (GIMP_IS_CROP_TOOL (tool)) { - if (crop_options->layer_only) - { - layer = gimp_image_get_active_layer (gdisp->gimage); - gimp_drawable_offsets (GIMP_DRAWABLE (layer), &crop->x1, &crop->y1); - crop->x2 = gimp_drawable_width (GIMP_DRAWABLE (layer)) + crop->x1; - crop->y2 = gimp_drawable_height (GIMP_DRAWABLE (layer)) + crop->y1; - } - else - { - crop->x1 = crop->y1 = 0; - crop->x2 = gdisp->gimage->width; - crop->y2 = gdisp->gimage->height; - } + GimpCropTool *crop; + CropOptions *options; + GimpLayer *layer; + GimpDisplay *gdisp; + + crop = GIMP_CROP_TOOL (tool); + + options = (CropOptions *) tool->tool_info->tool_options; + + gdisp = tool->gdisp; + + gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); + + if (! gimage_mask_bounds (gdisp->gimage, + &crop->x1, &crop->y1, &crop->x2, &crop->y2)) + { + if (options->layer_only) + { + layer = gimp_image_get_active_layer (gdisp->gimage); + gimp_drawable_offsets (GIMP_DRAWABLE (layer), + &crop->x1, &crop->y1); + crop->x2 = gimp_drawable_width (GIMP_DRAWABLE (layer)) + crop->x1; + crop->y2 = gimp_drawable_height (GIMP_DRAWABLE (layer)) + crop->y1; + } + else + { + crop->x1 = crop->y1 = 0; + crop->x2 = gdisp->gimage->width; + crop->y2 = gdisp->gimage->height; + } + } + + crop_recalc (tool, crop); + + gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); } - - crop_recalc (tool, crop); - - gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); } static void crop_automatic_callback (GtkWidget *widget, gpointer data) { - GimpTool *tool; - GimpCropTool *crop; - GimpDisplay *gdisp; - GimpDrawable *active_drawable; - gint offset_x, offset_y; - gint width, height; - gint x1, y1, x2, y2; - gint shrunk_x1; - gint shrunk_y1; - gint shrunk_x2; - gint shrunk_y2; + GimpTool *tool; /* FIXME: active_tool is bad */ tool = tool_manager_get_active (the_gimp); - crop = GIMP_CROP_TOOL (tool); - - gdisp = tool->gdisp; - - if (crop_options->layer_only) + if (GIMP_IS_CROP_TOOL (tool)) { - active_drawable = gimp_image_active_drawable (gdisp->gimage); + GimpCropTool *crop; + CropOptions *options; + GimpDisplay *gdisp; + GimpDrawable *active_drawable; + gint offset_x, offset_y; + gint width, height; + gint x1, y1, x2, y2; + gint shrunk_x1; + gint shrunk_y1; + gint shrunk_x2; + gint shrunk_y2; - if (! active_drawable) - return; + crop = GIMP_CROP_TOOL (tool); - width = gimp_drawable_width (GIMP_DRAWABLE (active_drawable)); - height = gimp_drawable_height (GIMP_DRAWABLE (active_drawable)); - gimp_drawable_offsets (GIMP_DRAWABLE (active_drawable), - &offset_x, &offset_y); + options = (CropOptions *) tool->tool_info->tool_options; + + gdisp = tool->gdisp; + + if (options->layer_only) + { + active_drawable = gimp_image_active_drawable (gdisp->gimage); + + if (! active_drawable) + return; + + width = gimp_drawable_width (GIMP_DRAWABLE (active_drawable)); + height = gimp_drawable_height (GIMP_DRAWABLE (active_drawable)); + gimp_drawable_offsets (GIMP_DRAWABLE (active_drawable), + &offset_x, &offset_y); + } + else + { + width = gdisp->gimage->width; + height = gdisp->gimage->height; + offset_x = 0; + offset_y = 0; + } + + x1 = crop->x1 - offset_x > 0 ? crop->x1 - offset_x : 0; + x2 = crop->x2 - offset_x < width ? crop->x2 - offset_x : width; + y1 = crop->y1 - offset_y > 0 ? crop->y1 - offset_y : 0; + y2 = crop->y2 - offset_y < height ? crop->y2 - offset_y : height; + + gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); + + if (gimp_image_crop_auto_shrink (gdisp->gimage, + x1, y1, x2, y2, + options->layer_only, + &shrunk_x1, + &shrunk_y1, + &shrunk_x2, + &shrunk_y2)) + { + crop->x1 = offset_x + shrunk_x1; + crop->x2 = offset_x + shrunk_x2; + crop->y1 = offset_y + shrunk_y1; + crop->y2 = offset_y + shrunk_y2; + + crop_recalc (tool, crop); + } + + gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); } - else - { - width = gdisp->gimage->width; - height = gdisp->gimage->height; - offset_x = 0; - offset_y = 0; - } - - x1 = crop->x1 - offset_x > 0 ? crop->x1 - offset_x : 0; - x2 = crop->x2 - offset_x < width ? crop->x2 - offset_x : width; - y1 = crop->y1 - offset_y > 0 ? crop->y1 - offset_y : 0; - y2 = crop->y2 - offset_y < height ? crop->y2 - offset_y : height; - - gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); - - if (gimp_image_crop_auto_shrink (gdisp->gimage, - x1, y1, x2, y2, - crop_options->layer_only, - &shrunk_x1, - &shrunk_y1, - &shrunk_x2, - &shrunk_y2)) - { - crop->x1 = offset_x + shrunk_x1; - crop->x2 = offset_x + shrunk_x2; - crop->y1 = offset_y + shrunk_y1; - crop->y2 = offset_y + shrunk_y2; - - crop_recalc (tool, crop); - } - - gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); } static void diff --git a/app/tools/gimpellipseselecttool.c b/app/tools/gimpellipseselecttool.c index 76b8633db3..b7b4ba780d 100644 --- a/app/tools/gimpellipseselecttool.c +++ b/app/tools/gimpellipseselecttool.c @@ -36,7 +36,6 @@ #include "gimpellipseselecttool.h" #include "selection_options.h" -#include "tool_options.h" #include "tool_manager.h" #include "libgimp/gimpintl.h" diff --git a/app/tools/gimpfreeselecttool.c b/app/tools/gimpfreeselecttool.c index c383ec2086..392bf4bd1a 100644 --- a/app/tools/gimpfreeselecttool.c +++ b/app/tools/gimpfreeselecttool.c @@ -33,6 +33,7 @@ #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimpimage-mask-select.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" @@ -41,7 +42,6 @@ #include "gimpeditselectiontool.h" #include "gimpfreeselecttool.h" #include "selection_options.h" -#include "tool_options.h" #include "tool_manager.h" #include "errors.h" @@ -245,9 +245,12 @@ gimp_free_select_tool_button_release (GimpTool *tool, GimpDisplay *gdisp) { GimpFreeSelectTool *free_sel; + SelectionOptions *sel_options; free_sel = GIMP_FREE_SELECT_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + gdk_pointer_ungrab (time); gdk_flush (); @@ -275,10 +278,10 @@ gimp_free_select_tool_button_release (GimpTool *tool, free_sel->num_points, free_sel->points, GIMP_SELECTION_TOOL (tool)->op, - free_options->antialias, - free_options->feather, - free_options->feather_radius, - free_options->feather_radius); + sel_options->antialias, + sel_options->feather, + sel_options->feather_radius, + sel_options->feather_radius); gdisplays_flush (); } diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c index 8e147a293c..3e7d6aad98 100644 --- a/app/tools/gimpfuzzyselecttool.c +++ b/app/tools/gimpfuzzyselecttool.c @@ -40,6 +40,7 @@ #include "core/gimpimage-contiguous-region.h" #include "core/gimpimage-mask.h" #include "core/gimpimage-mask-select.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" @@ -47,9 +48,7 @@ #include "gimpeditselectiontool.h" #include "gimpfuzzyselecttool.h" -#include "gimptool.h" #include "selection_options.h" -#include "tool_options.h" #include "tool_manager.h" #include "gimprc.h" @@ -215,17 +214,20 @@ gimp_fuzzy_select_tool_button_press (GimpTool *tool, GimpDisplay *gdisp) { GimpFuzzySelectTool *fuzzy_sel; + SelectionOptions *sel_options; GimpDisplayShell *shell; fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); fuzzy_sel->x = coords->x; fuzzy_sel->y = coords->y; fuzzy_sel->first_x = fuzzy_sel->x; fuzzy_sel->first_y = fuzzy_sel->y; - fuzzy_sel->first_threshold = fuzzy_options->threshold; + fuzzy_sel->first_threshold = sel_options->threshold; tool->state = ACTIVE; tool->gdisp = gdisp; @@ -262,10 +264,13 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool, GimpDisplay *gdisp) { GimpFuzzySelectTool *fuzzy_sel; + SelectionOptions *sel_options; GimpDrawable *drawable; fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + gdk_pointer_ungrab (time); gdk_flush (); @@ -279,12 +284,12 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool, gimp_image_mask_select_channel (gdisp->gimage, drawable, - fuzzy_options->sample_merged, + sel_options->sample_merged, fuzzy_sel->fuzzy_mask, GIMP_SELECTION_TOOL (tool)->op, - fuzzy_options->feather, - fuzzy_options->feather_radius, - fuzzy_options->feather_radius); + sel_options->feather, + sel_options->feather_radius, + sel_options->feather_radius); g_object_unref (G_OBJECT (fuzzy_sel->fuzzy_mask)); fuzzy_sel->fuzzy_mask = NULL; @@ -309,6 +314,7 @@ gimp_fuzzy_select_tool_motion (GimpTool *tool, { GimpFuzzySelectTool *fuzzy_sel; GimpSelectionTool *sel_tool; + SelectionOptions *sel_options; GdkSegment *new_segs; gint num_new_segs; gint diff_x, diff_y; @@ -319,6 +325,8 @@ gimp_fuzzy_select_tool_motion (GimpTool *tool, fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); sel_tool = GIMP_SELECTION_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + if (tool->state != ACTIVE) return; @@ -333,7 +341,7 @@ gimp_fuzzy_select_tool_motion (GimpTool *tool, diff = ((ABS (diff_x) > ABS (diff_y)) ? diff_x : diff_y) / 2.0; - gtk_adjustment_set_value (GTK_ADJUSTMENT (fuzzy_options->threshold_w), + gtk_adjustment_set_value (GTK_ADJUSTMENT (sel_options->threshold_w), fuzzy_sel->first_threshold + diff); /* calculate the new fuzzy boundary */ @@ -356,22 +364,25 @@ fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, GimpDisplay *gdisp, gint *nsegs) { - PixelRegion maskPR; - GimpChannel *new; - GdkSegment *segs; - BoundSeg *bsegs; - GimpDrawable *drawable; - gint i; - gint x, y; + SelectionOptions *sel_options; + PixelRegion maskPR; + GimpChannel *new; + GdkSegment *segs; + BoundSeg *bsegs; + GimpDrawable *drawable; + gint i; + gint x, y; - drawable = gimp_image_active_drawable (gdisp->gimage); + sel_options = (SelectionOptions *) GIMP_TOOL (fuzzy_sel)->tool_info->tool_options; + + drawable = gimp_image_active_drawable (gdisp->gimage); gimp_set_busy (gdisp->gimage->gimp); x = fuzzy_sel->x; y = fuzzy_sel->y; - if (! fuzzy_options->sample_merged) + if (! sel_options->sample_merged) { gint off_x, off_y; @@ -382,9 +393,9 @@ fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, } new = gimp_image_contiguous_region_by_seed (gdisp->gimage, drawable, - fuzzy_options->sample_merged, - fuzzy_options->antialias, - fuzzy_options->threshold, + sel_options->sample_merged, + sel_options->antialias, + sel_options->threshold, x, y); if (fuzzy_sel->fuzzy_mask) @@ -413,14 +424,14 @@ fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, gdisplay_transform_coords (gdisp, bsegs[i].x1, bsegs[i].y1, &x, &y, - ! fuzzy_options->sample_merged); + ! sel_options->sample_merged); segs[i].x1 = x; segs[i].y1 = y; gdisplay_transform_coords (gdisp, bsegs[i].x2, bsegs[i].y2, &x, &y, - ! fuzzy_options->sample_merged); + ! sel_options->sample_merged); segs[i].x2 = x; segs[i].y2 = y; } diff --git a/app/tools/gimpinktool.c b/app/tools/gimpinktool.c index f91fe7d092..ede373ef2a 100644 --- a/app/tools/gimpinktool.c +++ b/app/tools/gimpinktool.c @@ -40,6 +40,7 @@ #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" @@ -122,31 +123,35 @@ static void gimp_ink_tool_init (GimpInkTool *tool); static void gimp_ink_tool_finalize (GObject *object); -static InkOptions * ink_options_new (void); -static void ink_options_reset (GimpToolOptions *tool_options); +static void gimp_ink_tool_control (GimpTool *tool, + ToolAction tool_action, + GimpDisplay *gdisp); +static void gimp_ink_tool_button_press (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp); +static void gimp_ink_tool_button_release (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp); +static void gimp_ink_tool_motion (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp); +static void gimp_ink_tool_cursor_update (GimpTool *tool, + GimpCoords *coords, + GdkModifierType state, + GimpDisplay *gdisp); -static void ink_control (GimpTool *tool, - ToolAction tool_action, - GimpDisplay *gdisp); -static void ink_button_press (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp); -static void ink_button_release (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp); -static void ink_motion (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp); -static void ink_cursor_update (GimpTool *tool, - GimpCoords *coords, - GdkModifierType state, - GimpDisplay *gdisp); +static Blob * ink_pen_ellipse (gdouble x_center, + gdouble y_center, + gdouble pressure, + gdouble xtilt, + gdouble ytilt, + gdouble velocity); static void time_smoother_add (GimpInkTool *ink_tool, guint32 value); @@ -216,6 +221,11 @@ static void brush_widget_motion_notify (GtkWidget *widget, GdkEventMotion *event, BrushWidget *brush_widget); +static InkOptions * ink_options_new (void); +static void ink_options_reset (GimpToolOptions *tool_options); +static void ink_type_update (GtkWidget *radio_button, + BlobFunc function); + /* local variables */ @@ -236,7 +246,7 @@ static TempBuf *canvas_buf = NULL; static GimpToolClass *parent_class = NULL; -/* functions */ +/* public functions */ void gimp_ink_tool_register (Gimp *gimp) @@ -280,6 +290,9 @@ gimp_ink_tool_get_type (void) return tool_type; } + +/* private functions */ + static void gimp_ink_tool_class_init (GimpInkToolClass *klass) { @@ -293,11 +306,11 @@ gimp_ink_tool_class_init (GimpInkToolClass *klass) object_class->finalize = gimp_ink_tool_finalize; - tool_class->control = ink_control; - tool_class->button_press = ink_button_press; - tool_class->button_release = ink_button_release; - tool_class->motion = ink_motion; - tool_class->cursor_update = ink_cursor_update; + tool_class->control = gimp_ink_tool_control; + tool_class->button_press = gimp_ink_tool_button_press; + tool_class->button_release = gimp_ink_tool_button_release; + tool_class->motion = gimp_ink_tool_motion; + tool_class->cursor_update = gimp_ink_tool_cursor_update; } static void @@ -339,300 +352,240 @@ gimp_ink_tool_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } -static void -ink_type_update (GtkWidget *radio_button, - BlobFunc function) +static void +gimp_ink_tool_control (GimpTool *tool, + ToolAction action, + GimpDisplay *gdisp) { - InkOptions *options = ink_options; + GimpInkTool *ink_tool; - if (GTK_TOGGLE_BUTTON (radio_button)->active) - options->function = function; + ink_tool = GIMP_INK_TOOL (tool); - gtk_widget_queue_draw (options->brush_w->widget); + switch (action) + { + case PAUSE: + break; + + case RESUME: + break; + + case HALT: + ink_cleanup (); + break; + + default: + break; + } } static void -ink_options_reset (GimpToolOptions *tool_options) +gimp_ink_tool_button_press (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp) { - InkOptions *options; + GimpInkTool *ink_tool; + GimpDisplayShell *shell; + GimpDrawable *drawable; + Blob *b; - options = (InkOptions *) tool_options; + ink_tool = GIMP_INK_TOOL (tool); - paint_options_reset (tool_options); + shell = GIMP_DISPLAY_SHELL (gdisp->shell); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->size_w), - options->size_d); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->sensitivity_w), - options->sensitivity_d); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->tilt_sensitivity_w), - options->tilt_sensitivity_d); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->vel_sensitivity_w), - options->vel_sensitivity_d); - gtk_adjustment_set_value (GTK_ADJUSTMENT (options->tilt_angle_w), - options->tilt_angle_d); - gtk_toggle_button_set_active (((options->function_d == blob_ellipse) ? - GTK_TOGGLE_BUTTON (options->function_w[0]) : - ((options->function_d == blob_square) ? - GTK_TOGGLE_BUTTON (options->function_w[1]) : - GTK_TOGGLE_BUTTON (options->function_w[2]))), - TRUE); - options->aspect = options->aspect_d; - options->angle = options->angle_d; - gtk_widget_queue_draw (options->brush_w->widget); + drawable = gimp_image_active_drawable (gdisp->gimage); + + ink_init (ink_tool, drawable, coords->x, coords->y); + + tool->state = ACTIVE; + tool->gdisp = gdisp; + tool->paused_count = 0; + + /* pause the current selection and grab the pointer */ + gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE); + + /* add motion memory if you press mod1 first ^ perfectmouse */ + if (((state & GDK_MOD1_MASK) != 0) != (gimprc.perfectmouse != 0)) + { + gdk_pointer_grab (shell->canvas->window, FALSE, + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, + NULL, NULL, time); + } + else + { + gdk_pointer_grab (shell->canvas->window, FALSE, + GDK_POINTER_MOTION_HINT_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK, + NULL, NULL, time); + } + + b = ink_pen_ellipse (coords->x, + coords->y, + coords->pressure, + coords->xtilt, + coords->ytilt, + 10.0); + + ink_paste (ink_tool, drawable, b); + ink_tool->last_blob = b; + + time_smoother_init (ink_tool, time); + ink_tool->last_time = time; + dist_smoother_init (ink_tool, 0.0); + ink_tool->init_velocity = TRUE; + ink_tool->lastx = coords->x; + ink_tool->lasty = coords->y; + + gimp_display_flush_now (gdisp); } -static InkOptions * -ink_options_new (void) +static void +gimp_ink_tool_button_release (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp) { - InkOptions *options; - GtkWidget *table; - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *hbox2; - GtkWidget *radio_button; - GtkWidget *pixmap_widget; - GtkWidget *slider; - GtkWidget *frame; - GtkWidget *darea; - GdkPixmap *pixmap; + GimpInkTool *ink_tool; + GimpImage *gimage; - options = g_new0 (InkOptions, 1); - paint_options_init ((PaintOptions *) options, - GIMP_TYPE_INK_TOOL, - ink_options_reset); + ink_tool = GIMP_INK_TOOL (tool); - options->size = options->size_d = 4.4; - options->sensitivity = options->sensitivity_d = 1.0; - options->vel_sensitivity = options->vel_sensitivity_d = 0.8; - options->tilt_sensitivity = options->tilt_sensitivity_d = 0.4; - options->tilt_angle = options->tilt_angle_d = 0.0; - options->function = options->function_d = blob_ellipse; - options->aspect = options->aspect_d = 1.0; - options->angle = options->angle_d = 0.0; + gimage = gdisp->gimage; - /* the main vbox */ - vbox = gtk_vbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (((GimpToolOptions *) options)->main_vbox), vbox, - TRUE, TRUE, 0); - gtk_widget_show (vbox); + /* resume the current selection and ungrab the pointer */ + gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME); - /* adjust sliders */ - frame = gtk_frame_new (_("Adjustment")); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); - gtk_widget_show (frame); + gdk_pointer_ungrab (time); + gdk_flush (); - table = gtk_table_new (2, 2, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (table), 4); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - gtk_container_add (GTK_CONTAINER (frame), table); - gtk_widget_show (table); + /* Set tool state to inactive -- no longer painting */ + tool->state = INACTIVE; - /* size slider */ - options->size_w = - gtk_adjustment_new (options->size_d, 0.0, 20.0, 1.0, 2.0, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (options->size_w)); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, - _("Size:"), 1.0, 1.0, - slider, 1, FALSE); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + /* free the last blob */ + g_free (ink_tool->last_blob); + ink_tool->last_blob = NULL; - g_signal_connect (G_OBJECT (options->size_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->size); + ink_finish (ink_tool, gimp_image_active_drawable (gdisp->gimage)); + gdisplays_flush (); +} - /* angle adjust slider */ - options->tilt_angle_w = - gtk_adjustment_new (options->tilt_angle_d, -90.0, 90.0, 1, 10.0, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (options->tilt_angle_w)); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, - _("Angle:"), 1.0, 1.0, - slider, 1, FALSE); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); +static void +gimp_ink_tool_motion (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *gdisp) +{ + GimpInkTool *ink_tool; + GimpDrawable *drawable; + Blob *b, *blob_union; - g_signal_connect (G_OBJECT (options->tilt_angle_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->tilt_angle); - - /* sens sliders */ - frame = gtk_frame_new (_("Sensitivity")); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); - gtk_widget_show (frame); - - table = gtk_table_new (3, 2, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (table), 4); - gtk_container_set_border_width (GTK_CONTAINER (table), 2); - gtk_container_add (GTK_CONTAINER (frame), table); - gtk_widget_show (table); - - /* size sens slider */ - options->sensitivity_w = - gtk_adjustment_new (options->sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (options->sensitivity_w)); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, - _("Size:"), 1.0, 1.0, - slider, 1, FALSE); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); - - g_signal_connect (G_OBJECT (options->sensitivity_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->sensitivity); + gdouble velocity; + gdouble dist; + gdouble lasttime, thistime; - /* tilt sens slider */ - options->tilt_sensitivity_w = - gtk_adjustment_new (options->tilt_sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (options->tilt_sensitivity_w)); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, - _("Tilt:"), 1.0, 1.0, - slider, 1, FALSE); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + ink_tool = GIMP_INK_TOOL (tool); - g_signal_connect (G_OBJECT (options->tilt_sensitivity_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->tilt_sensitivity); + drawable = gimp_image_active_drawable (gdisp->gimage); - /* velocity sens slider */ - options->vel_sensitivity_w = - gtk_adjustment_new (options->vel_sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); - slider = gtk_hscale_new (GTK_ADJUSTMENT (options->vel_sensitivity_w)); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); - gimp_table_attach_aligned (GTK_TABLE (table), 0, 3, - _("Speed:"), 1.0, 1.0, - slider, 1, FALSE); - gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + lasttime = ink_tool->last_time; - g_signal_connect (G_OBJECT (options->vel_sensitivity_w), "value_changed", - G_CALLBACK (gimp_double_adjustment_update), - &options->vel_sensitivity); + time_smoother_add (ink_tool, time); + thistime = ink_tool->last_time = time_smoother_result (ink_tool); - /* bottom hbox */ - hbox = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); - gtk_widget_show (hbox); + /* The time resolution on X-based GDK motion events is + bloody awful, hence the use of the smoothing function. + Sadly this also means that there is always the chance of + having an indeterminite velocity since this event and + the previous several may still appear to issue at the same + instant. -ADM */ - /* Brush type radiobuttons */ - frame = gtk_frame_new (_("Type")); - gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); - gtk_widget_show (frame); + if (thistime == lasttime) + thistime = lasttime + 1; - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), hbox2); - - vbox = gtk_vbox_new (FALSE, 2); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_box_pack_start (GTK_BOX (hbox2), vbox, FALSE, FALSE, 0); - gtk_widget_show (vbox); + if (ink_tool->init_velocity) + { + dist_smoother_init (ink_tool, + dist = sqrt ((ink_tool->lastx - coords->x) * + (ink_tool->lastx - coords->x) + + (ink_tool->lasty - coords->y) * + (ink_tool->lasty - coords->y))); + ink_tool->init_velocity = FALSE; + } + else + { + dist_smoother_add (ink_tool, + sqrt ((ink_tool->lastx - coords->x) * + (ink_tool->lastx - coords->x) + + (ink_tool->lasty - coords->y) * + (ink_tool->lasty - coords->y))); - pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), - gtk_widget_get_visual (vbox), - blob_ellipse); + dist = dist_smoother_result (ink_tool); + } - pixmap_widget = gtk_pixmap_new (pixmap, NULL); - gdk_drawable_unref (pixmap); - gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); + ink_tool->lastx = coords->x; + ink_tool->lasty = coords->y; - radio_button = gtk_radio_button_new (NULL); - gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); - gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); + velocity = 10.0 * sqrt ((dist) / (gdouble) (thistime - lasttime)); - g_signal_connect (G_OBJECT (radio_button), "toggled", - G_CALLBACK (ink_type_update), - (gpointer) blob_ellipse); + b = ink_pen_ellipse (coords->x, + coords->y, + coords->pressure, + coords->xtilt, + coords->ytilt, + velocity); + blob_union = blob_convex_union (ink_tool->last_blob, b); + g_free (ink_tool->last_blob); + ink_tool->last_blob = b; - options->function_w[0] = radio_button; + ink_paste (ink_tool, drawable, blob_union); + g_free (blob_union); - pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), - gtk_widget_get_visual (vbox), - blob_square); + gimp_display_flush_now (gdisp); +} - pixmap_widget = gtk_pixmap_new (pixmap, NULL); - gdk_drawable_unref (pixmap); - gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); +static void +gimp_ink_tool_cursor_update (GimpTool *tool, + GimpCoords *coords, + GdkModifierType state, + GimpDisplay *gdisp) +{ + GimpDisplayShell *shell; + GimpLayer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - radio_button = - gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button)); - gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); - gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); + shell = GIMP_DISPLAY_SHELL (gdisp->shell); - g_signal_connect (G_OBJECT (radio_button), "toggled", - G_CALLBACK (ink_type_update), - (gpointer) blob_square); - + if ((layer = gimp_image_get_active_layer (gdisp->gimage))) + { + gint off_x, off_y; - options->function_w[1] = radio_button; + gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y); - pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), - gtk_widget_get_visual (vbox), - blob_diamond); + if (coords->x >= off_x && + coords->y >= off_y && + coords->x < (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer))) && + coords->y < (off_y + gimp_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 = GIMP_MOUSE_CURSOR; + else if (gimage_mask_value (gdisp->gimage, coords->x, coords->y)) + ctype = GIMP_MOUSE_CURSOR; + } + } - pixmap_widget = gtk_pixmap_new (pixmap, NULL); - gdk_drawable_unref (pixmap); - gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); - - radio_button = - gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button)); - gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); - gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); - - g_signal_connect (G_OBJECT (radio_button), "toggled", - G_CALLBACK (ink_type_update), - (gpointer) blob_diamond); - - - options->function_w[2] = radio_button; - - /* Brush shape widget */ - frame = gtk_frame_new (_("Shape")); - gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); - gtk_widget_show (frame); - - vbox = gtk_vbox_new (FALSE, 2); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); - gtk_container_add (GTK_CONTAINER (frame), vbox); - gtk_widget_show (vbox); - - frame = gtk_aspect_frame_new (NULL, 0.0, 0.5, 1.0, FALSE); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); - - options->brush_w = g_new (BrushWidget, 1); - options->brush_w->state = FALSE; - - darea = gtk_drawing_area_new(); - options->brush_w->widget = darea; - - gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 60, 60); - gtk_container_add (GTK_CONTAINER (frame), darea); - - gtk_widget_set_events (darea, - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK); - - g_signal_connect (G_OBJECT (darea), "button_press_event", - G_CALLBACK (brush_widget_button_press), - options->brush_w); - g_signal_connect (G_OBJECT (darea), "button_release_event", - G_CALLBACK (brush_widget_button_release), - options->brush_w); - g_signal_connect (G_OBJECT (darea), "motion_notify_event", - G_CALLBACK (brush_widget_motion_notify), - options->brush_w); - g_signal_connect (G_OBJECT (darea), "expose_event", - G_CALLBACK (brush_widget_expose), - options->brush_w); - g_signal_connect (G_OBJECT (darea), "realize", - G_CALLBACK (brush_widget_realize), - options->brush_w); - - gtk_widget_show_all (hbox); - - return options; + gimp_display_shell_install_tool_cursor (shell, + ctype, + GIMP_INK_TOOL_CURSOR, + GIMP_CURSOR_MODIFIER_NONE); } @@ -934,128 +887,6 @@ ink_pen_ellipse (gdouble x_center, -radmin*tsin, radmin*tcos); } -static void -ink_control (GimpTool *tool, - ToolAction action, - GimpDisplay *gdisp) -{ - GimpInkTool *ink_tool; - - ink_tool = GIMP_INK_TOOL (tool); - - switch (action) - { - case PAUSE: - break; - - case RESUME: - break; - - case HALT: - ink_cleanup (); - break; - - default: - break; - } -} - -static void -ink_button_press (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp) -{ - GimpInkTool *ink_tool; - GimpDisplayShell *shell; - GimpDrawable *drawable; - Blob *b; - - ink_tool = GIMP_INK_TOOL (tool); - - shell = GIMP_DISPLAY_SHELL (gdisp->shell); - - drawable = gimp_image_active_drawable (gdisp->gimage); - - ink_init (ink_tool, drawable, coords->x, coords->y); - - tool->state = ACTIVE; - tool->gdisp = gdisp; - tool->paused_count = 0; - - /* pause the current selection and grab the pointer */ - gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE); - - /* add motion memory if you press mod1 first ^ perfectmouse */ - if (((state & GDK_MOD1_MASK) != 0) != (gimprc.perfectmouse != 0)) - { - gdk_pointer_grab (shell->canvas->window, FALSE, - GDK_BUTTON1_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK, - NULL, NULL, time); - } - else - { - gdk_pointer_grab (shell->canvas->window, FALSE, - GDK_POINTER_MOTION_HINT_MASK | - GDK_BUTTON1_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK, - NULL, NULL, time); - } - - b = ink_pen_ellipse (coords->x, - coords->y, - coords->pressure, - coords->xtilt, - coords->ytilt, - 10.0); - - ink_paste (ink_tool, drawable, b); - ink_tool->last_blob = b; - - time_smoother_init (ink_tool, time); - ink_tool->last_time = time; - dist_smoother_init (ink_tool, 0.0); - ink_tool->init_velocity = TRUE; - ink_tool->lastx = coords->x; - ink_tool->lasty = coords->y; - - gimp_display_flush_now (gdisp); -} - -static void -ink_button_release (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp) -{ - GimpInkTool *ink_tool; - GimpImage *gimage; - - ink_tool = GIMP_INK_TOOL (tool); - - gimage = gdisp->gimage; - - /* resume the current selection and ungrab the pointer */ - gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME); - - gdk_pointer_ungrab (time); - gdk_flush (); - - /* Set tool state to inactive -- no longer painting */ - tool->state = INACTIVE; - - /* free the last blob */ - g_free (ink_tool->last_blob); - ink_tool->last_blob = NULL; - - ink_finish (ink_tool, gimp_image_active_drawable (gdisp->gimage)); - gdisplays_flush (); -} - - static void dist_smoother_init (GimpInkTool *ink_tool, gdouble initval) @@ -1137,122 +968,6 @@ time_smoother_add (GimpInkTool *ink_tool, ink_tool->ts_index = 0; } - -static void -ink_motion (GimpTool *tool, - GimpCoords *coords, - guint32 time, - GdkModifierType state, - GimpDisplay *gdisp) -{ - GimpInkTool *ink_tool; - GimpDrawable *drawable; - Blob *b, *blob_union; - - gdouble velocity; - gdouble dist; - gdouble lasttime, thistime; - - ink_tool = GIMP_INK_TOOL (tool); - - drawable = gimp_image_active_drawable (gdisp->gimage); - - lasttime = ink_tool->last_time; - - time_smoother_add (ink_tool, time); - thistime = ink_tool->last_time = time_smoother_result (ink_tool); - - /* The time resolution on X-based GDK motion events is - bloody awful, hence the use of the smoothing function. - Sadly this also means that there is always the chance of - having an indeterminite velocity since this event and - the previous several may still appear to issue at the same - instant. -ADM */ - - if (thistime == lasttime) - thistime = lasttime + 1; - - if (ink_tool->init_velocity) - { - dist_smoother_init (ink_tool, - dist = sqrt ((ink_tool->lastx - coords->x) * - (ink_tool->lastx - coords->x) + - (ink_tool->lasty - coords->y) * - (ink_tool->lasty - coords->y))); - ink_tool->init_velocity = FALSE; - } - else - { - dist_smoother_add (ink_tool, - sqrt ((ink_tool->lastx - coords->x) * - (ink_tool->lastx - coords->x) + - (ink_tool->lasty - coords->y) * - (ink_tool->lasty - coords->y))); - - dist = dist_smoother_result (ink_tool); - } - - ink_tool->lastx = coords->x; - ink_tool->lasty = coords->y; - - velocity = 10.0 * sqrt ((dist) / (gdouble) (thistime - lasttime)); - - b = ink_pen_ellipse (coords->x, - coords->y, - coords->pressure, - coords->xtilt, - coords->ytilt, - velocity); - - blob_union = blob_convex_union (ink_tool->last_blob, b); - g_free (ink_tool->last_blob); - ink_tool->last_blob = b; - - ink_paste (ink_tool, drawable, blob_union); - g_free (blob_union); - - gimp_display_flush_now (gdisp); -} - -static void -ink_cursor_update (GimpTool *tool, - GimpCoords *coords, - GdkModifierType state, - GimpDisplay *gdisp) -{ - GimpDisplayShell *shell; - GimpLayer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - - shell = GIMP_DISPLAY_SHELL (gdisp->shell); - - if ((layer = gimp_image_get_active_layer (gdisp->gimage))) - { - gint off_x, off_y; - - gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y); - - if (coords->x >= off_x && - coords->y >= off_y && - coords->x < (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer))) && - coords->y < (off_y + gimp_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 = GIMP_MOUSE_CURSOR; - else if (gimage_mask_value (gdisp->gimage, coords->x, coords->y)) - ctype = GIMP_MOUSE_CURSOR; - } - } - - gimp_display_shell_install_tool_cursor (shell, - ctype, - GIMP_INK_TOOL_CURSOR, - GIMP_CURSOR_MODIFIER_NONE); -} - static void ink_init (GimpInkTool *ink_tool, GimpDrawable *drawable, @@ -1703,3 +1418,302 @@ ink_set_canvas_tiles (gint x, } } } + + +/* tool options stuff */ + +static InkOptions * +ink_options_new (void) +{ + InkOptions *options; + GtkWidget *table; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *hbox2; + GtkWidget *radio_button; + GtkWidget *pixmap_widget; + GtkWidget *slider; + GtkWidget *frame; + GtkWidget *darea; + GdkPixmap *pixmap; + + options = g_new0 (InkOptions, 1); + paint_options_init ((PaintOptions *) options, + GIMP_TYPE_INK_TOOL, + ink_options_reset); + + options->size = options->size_d = 4.4; + options->sensitivity = options->sensitivity_d = 1.0; + options->vel_sensitivity = options->vel_sensitivity_d = 0.8; + options->tilt_sensitivity = options->tilt_sensitivity_d = 0.4; + options->tilt_angle = options->tilt_angle_d = 0.0; + options->function = options->function_d = blob_ellipse; + options->aspect = options->aspect_d = 1.0; + options->angle = options->angle_d = 0.0; + + /* the main vbox */ + vbox = gtk_vbox_new (FALSE, 2); + gtk_box_pack_start (GTK_BOX (((GimpToolOptions *) options)->main_vbox), vbox, + TRUE, TRUE, 0); + gtk_widget_show (vbox); + + /* adjust sliders */ + frame = gtk_frame_new (_("Adjustment")); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); + gtk_widget_show (frame); + + table = gtk_table_new (2, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); + + /* size slider */ + options->size_w = + gtk_adjustment_new (options->size_d, 0.0, 20.0, 1.0, 2.0, 0.0); + slider = gtk_hscale_new (GTK_ADJUSTMENT (options->size_w)); + gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Size:"), 1.0, 1.0, + slider, 1, FALSE); + gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + + g_signal_connect (G_OBJECT (options->size_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->size); + + /* angle adjust slider */ + options->tilt_angle_w = + gtk_adjustment_new (options->tilt_angle_d, -90.0, 90.0, 1, 10.0, 0.0); + slider = gtk_hscale_new (GTK_ADJUSTMENT (options->tilt_angle_w)); + gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Angle:"), 1.0, 1.0, + slider, 1, FALSE); + gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + + g_signal_connect (G_OBJECT (options->tilt_angle_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->tilt_angle); + + /* sens sliders */ + frame = gtk_frame_new (_("Sensitivity")); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); + gtk_widget_show (frame); + + table = gtk_table_new (3, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 2); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); + + /* size sens slider */ + options->sensitivity_w = + gtk_adjustment_new (options->sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); + slider = gtk_hscale_new (GTK_ADJUSTMENT (options->sensitivity_w)); + gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Size:"), 1.0, 1.0, + slider, 1, FALSE); + gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + + g_signal_connect (G_OBJECT (options->sensitivity_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->sensitivity); + + /* tilt sens slider */ + options->tilt_sensitivity_w = + gtk_adjustment_new (options->tilt_sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); + slider = gtk_hscale_new (GTK_ADJUSTMENT (options->tilt_sensitivity_w)); + gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, + _("Tilt:"), 1.0, 1.0, + slider, 1, FALSE); + gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + + g_signal_connect (G_OBJECT (options->tilt_sensitivity_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->tilt_sensitivity); + + /* velocity sens slider */ + options->vel_sensitivity_w = + gtk_adjustment_new (options->vel_sensitivity_d, 0.0, 1.0, 0.01, 0.1, 0.0); + slider = gtk_hscale_new (GTK_ADJUSTMENT (options->vel_sensitivity_w)); + gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 3, + _("Speed:"), 1.0, 1.0, + slider, 1, FALSE); + gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); + + g_signal_connect (G_OBJECT (options->vel_sensitivity_w), "value_changed", + G_CALLBACK (gimp_double_adjustment_update), + &options->vel_sensitivity); + + /* bottom hbox */ + hbox = gtk_hbox_new (FALSE, 2); + gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); + gtk_widget_show (hbox); + + /* Brush type radiobuttons */ + frame = gtk_frame_new (_("Type")); + gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); + gtk_widget_show (frame); + + hbox2 = gtk_hbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (frame), hbox2); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); + gtk_box_pack_start (GTK_BOX (hbox2), vbox, FALSE, FALSE, 0); + gtk_widget_show (vbox); + + pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), + gtk_widget_get_visual (vbox), + blob_ellipse); + + pixmap_widget = gtk_pixmap_new (pixmap, NULL); + gdk_drawable_unref (pixmap); + gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); + + radio_button = gtk_radio_button_new (NULL); + gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); + gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); + + g_signal_connect (G_OBJECT (radio_button), "toggled", + G_CALLBACK (ink_type_update), + (gpointer) blob_ellipse); + + + options->function_w[0] = radio_button; + + pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), + gtk_widget_get_visual (vbox), + blob_square); + + pixmap_widget = gtk_pixmap_new (pixmap, NULL); + gdk_drawable_unref (pixmap); + gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); + + radio_button = + gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button)); + gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); + gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); + + g_signal_connect (G_OBJECT (radio_button), "toggled", + G_CALLBACK (ink_type_update), + (gpointer) blob_square); + + + options->function_w[1] = radio_button; + + pixmap = blob_pixmap (gtk_widget_get_colormap (vbox), + gtk_widget_get_visual (vbox), + blob_diamond); + + pixmap_widget = gtk_pixmap_new (pixmap, NULL); + gdk_drawable_unref (pixmap); + gtk_misc_set_padding (GTK_MISC (pixmap_widget), 6, 0); + + radio_button = + gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button)); + gtk_container_add (GTK_CONTAINER (radio_button), pixmap_widget); + gtk_box_pack_start (GTK_BOX (vbox), radio_button, FALSE, FALSE, 0); + + g_signal_connect (G_OBJECT (radio_button), "toggled", + G_CALLBACK (ink_type_update), + (gpointer) blob_diamond); + + + options->function_w[2] = radio_button; + + /* Brush shape widget */ + frame = gtk_frame_new (_("Shape")); + gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); + gtk_widget_show (frame); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); + + frame = gtk_aspect_frame_new (NULL, 0.0, 0.5, 1.0, FALSE); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); + + options->brush_w = g_new (BrushWidget, 1); + options->brush_w->state = FALSE; + + darea = gtk_drawing_area_new(); + options->brush_w->widget = darea; + + gtk_drawing_area_size (GTK_DRAWING_AREA (darea), 60, 60); + gtk_container_add (GTK_CONTAINER (frame), darea); + + gtk_widget_set_events (darea, + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK); + + g_signal_connect (G_OBJECT (darea), "button_press_event", + G_CALLBACK (brush_widget_button_press), + options->brush_w); + g_signal_connect (G_OBJECT (darea), "button_release_event", + G_CALLBACK (brush_widget_button_release), + options->brush_w); + g_signal_connect (G_OBJECT (darea), "motion_notify_event", + G_CALLBACK (brush_widget_motion_notify), + options->brush_w); + g_signal_connect (G_OBJECT (darea), "expose_event", + G_CALLBACK (brush_widget_expose), + options->brush_w); + g_signal_connect (G_OBJECT (darea), "realize", + G_CALLBACK (brush_widget_realize), + options->brush_w); + + gtk_widget_show_all (hbox); + + return options; +} + +static void +ink_options_reset (GimpToolOptions *tool_options) +{ + InkOptions *options; + + options = (InkOptions *) tool_options; + + paint_options_reset (tool_options); + + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->size_w), + options->size_d); + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->sensitivity_w), + options->sensitivity_d); + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->tilt_sensitivity_w), + options->tilt_sensitivity_d); + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->vel_sensitivity_w), + options->vel_sensitivity_d); + gtk_adjustment_set_value (GTK_ADJUSTMENT (options->tilt_angle_w), + options->tilt_angle_d); + gtk_toggle_button_set_active (((options->function_d == blob_ellipse) ? + GTK_TOGGLE_BUTTON (options->function_w[0]) : + ((options->function_d == blob_square) ? + GTK_TOGGLE_BUTTON (options->function_w[1]) : + GTK_TOGGLE_BUTTON (options->function_w[2]))), + TRUE); + options->aspect = options->aspect_d; + options->angle = options->angle_d; + gtk_widget_queue_draw (options->brush_w->widget); +} + +static void +ink_type_update (GtkWidget *radio_button, + BlobFunc function) +{ + InkOptions *options = ink_options; + + if (GTK_TOGGLE_BUTTON (radio_button)->active) + options->function = function; + + gtk_widget_queue_draw (options->brush_w->widget); +} diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c index 1d51d82711..e3e4e86f7a 100644 --- a/app/tools/gimpiscissorstool.c +++ b/app/tools/gimpiscissorstool.c @@ -58,6 +58,7 @@ #include "core/gimpimage-mask.h" #include "core/gimpimage-mask-select.h" #include "core/gimpscanconvert.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" @@ -72,26 +73,6 @@ #include "libgimp/gimpintl.h" -struct _ICurve -{ - gint x1, y1; - gint x2, y2; - GPtrArray *points; -}; - - -typedef struct _IScissorsOptions IScissorsOptions; - -struct _IScissorsOptions -{ - SelectionOptions selection_options; -}; - - -/**********************************************/ -/* Intelligent scissors selection apparatus */ - - /* Other defines... */ #define MAX_GRADIENT 179.606 /* == sqrt(127^2 + 127^2) */ #define GRADIENT_SEARCH 32 /* how far to look when snapping to an edge */ @@ -123,7 +104,23 @@ struct _IScissorsOptions #define PIXEL_DIR(x) (x & 0x000000ff) -/* Local function prototypes */ +struct _ICurve +{ + gint x1, y1; + gint x2, y2; + GPtrArray *points; +}; + + +typedef struct _IScissorsOptions IScissorsOptions; + +struct _IScissorsOptions +{ + SelectionOptions selection_options; +}; + + +/* local function prototypes */ static void gimp_iscissors_tool_class_init (GimpIscissorsToolClass *klass); static void gimp_iscissors_tool_init (GimpIscissorsTool *iscissors); @@ -208,9 +205,6 @@ static GPtrArray * plot_pixels (GimpIscissorsTool *iscissors, /* static variables */ -static IScissorsOptions *iscissors_options = NULL; - - /* where to move on a given link direction */ static gint move[8][2] = { @@ -269,6 +263,8 @@ static gint direction_value[256][4]; static gboolean initialized = FALSE; static Tile *cur_tile = NULL; +static IScissorsOptions *iscissors_options = NULL; + static GimpDrawTool *parent_class = NULL; @@ -451,12 +447,15 @@ gimp_iscissors_tool_button_press (GimpTool *tool, GimpDisplay *gdisp) { GimpIscissorsTool *iscissors; + SelectionOptions *sel_options; GimpDisplayShell *shell; GimpDrawable *drawable; gboolean grab_pointer = FALSE; iscissors = GIMP_ISCISSORS_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); drawable = gimp_image_active_drawable (gdisp->gimage); @@ -508,7 +507,7 @@ gimp_iscissors_tool_button_press (GimpTool *tool, iscissors->state = SEED_ADJUSTMENT; iscissors->draw = DRAW_ACTIVE_CURVE; - if (((SelectionOptions *) iscissors_options)->interactive) + if (sel_options->interactive) iscissors->draw |= DRAW_LIVEWIRE; gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); @@ -530,9 +529,9 @@ gimp_iscissors_tool_button_press (GimpTool *tool, NULL, TRUE, iscissors->mask, iscissors->op, - ((SelectionOptions *) iscissors_options)->feather, - ((SelectionOptions *) iscissors_options)->feather_radius, - ((SelectionOptions *) iscissors_options)->feather_radius); + sel_options->feather, + sel_options->feather_radius, + sel_options->feather_radius); gimp_iscissors_tool_reset (iscissors); @@ -544,7 +543,7 @@ gimp_iscissors_tool_button_press (GimpTool *tool, iscissors->state = SEED_PLACEMENT; iscissors->draw = DRAW_CURRENT_SEED; - if (((SelectionOptions *) iscissors_options)->interactive) + if (sel_options->interactive) iscissors->draw |= DRAW_LIVEWIRE; grab_pointer = TRUE; @@ -617,10 +616,13 @@ gimp_iscissors_tool_button_release (GimpTool *tool, GimpDisplay *gdisp) { GimpIscissorsTool *iscissors; + SelectionOptions *sel_options; ICurve *curve; iscissors = GIMP_ISCISSORS_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + /* Make sure X didn't skip the button release event -- as it's known * to do */ @@ -635,12 +637,12 @@ gimp_iscissors_tool_button_release (GimpTool *tool, { case SEED_PLACEMENT: iscissors->draw = DRAW_CURVE | DRAW_CURRENT_SEED; - if (((SelectionOptions *) iscissors_options)->interactive) + if (sel_options->interactive) iscissors->draw |= DRAW_LIVEWIRE; break; case SEED_ADJUSTMENT: iscissors->draw = DRAW_CURVE | DRAW_ACTIVE_CURVE; - if (((SelectionOptions *) iscissors_options)->interactive) + if (sel_options->interactive) iscissors->draw |= DRAW_LIVEWIRE; break; default: @@ -733,9 +735,12 @@ gimp_iscissors_tool_motion (GimpTool *tool, GimpDisplay *gdisp) { GimpIscissorsTool *iscissors; + SelectionOptions *sel_options; iscissors = GIMP_ISCISSORS_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + if (tool->state != ACTIVE || iscissors->state == NO_ACTION) return; @@ -743,7 +748,7 @@ gimp_iscissors_tool_motion (GimpTool *tool, { iscissors->draw = DRAW_CURRENT_SEED; - if (((SelectionOptions *) iscissors_options)->interactive) + if (sel_options->interactive) iscissors->draw = DRAW_CURRENT_SEED | DRAW_LIVEWIRE; } else if (iscissors->state == SEED_ADJUSTMENT) diff --git a/app/tools/gimpmagnifytool.c b/app/tools/gimpmagnifytool.c index 2b8ad73bbc..ae90384c4c 100644 --- a/app/tools/gimpmagnifytool.c +++ b/app/tools/gimpmagnifytool.c @@ -27,6 +27,8 @@ #include "tools-types.h" +#include "core/gimptoolinfo.h" + #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" #include "display/gimpdisplayshell-scale.h" @@ -87,17 +89,15 @@ static void gimp_magnify_tool_cursor_update (GimpTool *tool, static void gimp_magnify_tool_draw (GimpDrawTool *draw_tool); +static void zoom_in (gint *src, + gint *dest, + gint scale); +static void zoom_out (gint *src, + gint *dest, + gint scale); -/* magnify utility functions */ -static void zoom_in (gint *src, - gint *dest, - gint scale); -static void zoom_out (gint *src, - gint *dest, - gint scale); - -static MagnifyOptions * magnify_options_new (void); -static void magnify_options_reset (GimpToolOptions *tool_options); +static MagnifyOptions * magnify_options_new (void); +static void magnify_options_reset (GimpToolOptions *tool_options); static MagnifyOptions *magnify_options = NULL; @@ -105,6 +105,8 @@ static MagnifyOptions *magnify_options = NULL; static GimpDrawToolClass *parent_class = NULL; +/* public functions */ + void gimp_magnify_tool_register (Gimp *gimp) { @@ -147,6 +149,9 @@ gimp_magnify_tool_get_type (void) return tool_type; } + +/* private functions */ + static void gimp_magnify_tool_class_init (GimpMagnifyToolClass *klass) { @@ -193,111 +198,6 @@ gimp_magnify_tool_init (GimpMagnifyTool *magnify_tool) tool->auto_snap_to = FALSE; /* Don't snap to guides */ } - -/* magnify tool options functions */ - -static void -magnify_options_reset (GimpToolOptions *tool_options) -{ - MagnifyOptions *options; - - options = (MagnifyOptions *) tool_options; - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_resize_w), - options->allow_resize_d); - - gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); -} - -static MagnifyOptions * -magnify_options_new (void) -{ - MagnifyOptions *options; - - GtkWidget *vbox; - GtkWidget *frame; - - /* the new magnify tool options structure */ - options = g_new0 (MagnifyOptions, 1); - - tool_options_init ((GimpToolOptions *) options, - magnify_options_reset); - - options->allow_resize_d = gimprc.resize_windows_on_zoom; - options->type_d = options->type = GIMP_ZOOM_IN; - - /* the main vbox */ - vbox = options->tool_options.main_vbox; - - /* the allow_resize toggle button */ - options->allow_resize_w = - gtk_check_button_new_with_label (_("Allow Window Resizing")); - g_signal_connect (G_OBJECT (options->allow_resize_w), "toggled", - G_CALLBACK (gimp_toggle_button_update), - &(gimprc.resize_windows_on_zoom)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_resize_w), - gimprc.resize_windows_on_zoom); - gtk_box_pack_start (GTK_BOX (vbox), - options->allow_resize_w, FALSE, FALSE, 0); - gtk_widget_show (options->allow_resize_w); - - /* tool toggle */ - frame = - gimp_radio_group_new2 (TRUE, _("Tool Toggle"), - G_CALLBACK (gimp_radio_button_update), - &options->type, - (gpointer) options->type, - - _("Zoom in"), (gpointer) GIMP_ZOOM_IN, - &options->type_w[0], - _("Zoom out"), (gpointer) GIMP_ZOOM_OUT, - &options->type_w[1], - - NULL); - - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - gtk_widget_show (frame); - - return options; -} - -/* magnify utility functions */ - -static void -zoom_in (gint *src, - gint *dest, - gint scale) -{ - while (scale--) - { - if (*src > 1) - (*src)--; - else - if (*dest < 0x10) - (*dest)++; - } -} - - -static void -zoom_out (gint *src, - gint *dest, - gint scale) -{ - while (scale--) - { - if (*dest > 1) - (*dest)--; - else - if (*src < 0x10) - (*src)++; - } -} - - -/* magnify action functions */ - static void gimp_magnify_tool_button_press (GimpTool *tool, GimpCoords *coords, @@ -337,6 +237,7 @@ gimp_magnify_tool_button_release (GimpTool *tool, GimpDisplay *gdisp) { GimpMagnifyTool *magnify; + MagnifyOptions *options; GimpDisplayShell *shell; gint win_width, win_height; gint width, height; @@ -346,6 +247,8 @@ gimp_magnify_tool_button_release (GimpTool *tool, magnify = GIMP_MAGNIFY_TOOL (tool); + options = (MagnifyOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell); gdk_pointer_ungrab (time); @@ -381,7 +284,7 @@ gimp_magnify_tool_button_release (GimpTool *tool, else scale = MIN ((width / w), (height / h)); - magnify->op = magnify_options->type; + magnify->op = options->type; switch (magnify->op) { @@ -435,17 +338,21 @@ gimp_magnify_tool_modifier_key (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + MagnifyOptions *options; + + options = (MagnifyOptions *) tool->tool_info->tool_options; + if (key == GDK_CONTROL_MASK) { - switch (magnify_options->type) + switch (options->type) { case GIMP_ZOOM_IN: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (magnify_options->type_w[GIMP_ZOOM_OUT]), TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[GIMP_ZOOM_OUT]), TRUE); break; case GIMP_ZOOM_OUT: gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON (magnify_options->type_w[GIMP_ZOOM_IN]), TRUE); + (GTK_TOGGLE_BUTTON (options->type_w[GIMP_ZOOM_IN]), TRUE); break; default: break; @@ -459,11 +366,14 @@ gimp_magnify_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + MagnifyOptions *options; GimpDisplayShell *shell; + options = (MagnifyOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); - if (magnify_options->type == GIMP_ZOOM_IN) + if (options->type == GIMP_ZOOM_IN) { gimp_display_shell_install_tool_cursor (shell, GIMP_ZOOM_CURSOR, @@ -494,3 +404,106 @@ gimp_magnify_tool_draw (GimpDrawTool *draw_tool) magnify->h, FALSE); } + + +/* magnify utility functions */ + +static void +zoom_in (gint *src, + gint *dest, + gint scale) +{ + while (scale--) + { + if (*src > 1) + (*src)--; + else + if (*dest < 0x10) + (*dest)++; + } +} + + +static void +zoom_out (gint *src, + gint *dest, + gint scale) +{ + while (scale--) + { + if (*dest > 1) + (*dest)--; + else + if (*src < 0x10) + (*src)++; + } +} + + +/* magnify tool options functions */ + +static MagnifyOptions * +magnify_options_new (void) +{ + MagnifyOptions *options; + + GtkWidget *vbox; + GtkWidget *frame; + + /* the new magnify tool options structure */ + options = g_new0 (MagnifyOptions, 1); + + tool_options_init ((GimpToolOptions *) options, + magnify_options_reset); + + options->allow_resize_d = gimprc.resize_windows_on_zoom; + options->type_d = options->type = GIMP_ZOOM_IN; + + /* the main vbox */ + vbox = options->tool_options.main_vbox; + + /* the allow_resize toggle button */ + options->allow_resize_w = + gtk_check_button_new_with_label (_("Allow Window Resizing")); + g_signal_connect (G_OBJECT (options->allow_resize_w), "toggled", + G_CALLBACK (gimp_toggle_button_update), + &(gimprc.resize_windows_on_zoom)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_resize_w), + gimprc.resize_windows_on_zoom); + gtk_box_pack_start (GTK_BOX (vbox), + options->allow_resize_w, FALSE, FALSE, 0); + gtk_widget_show (options->allow_resize_w); + + /* tool toggle */ + frame = + gimp_radio_group_new2 (TRUE, _("Tool Toggle"), + G_CALLBACK (gimp_radio_button_update), + &options->type, + (gpointer) options->type, + + _("Zoom in"), (gpointer) GIMP_ZOOM_IN, + &options->type_w[0], + _("Zoom out"), (gpointer) GIMP_ZOOM_OUT, + &options->type_w[1], + + NULL); + + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + return options; +} + +static void +magnify_options_reset (GimpToolOptions *tool_options) +{ + MagnifyOptions *options; + + options = (MagnifyOptions *) tool_options; + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_resize_w), + options->allow_resize_d); + + gtk_toggle_button_set_active + (GTK_TOGGLE_BUTTON (options->type_w[options->type_d]), TRUE); +} diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c index b77ef56f73..50d3ba415a 100644 --- a/app/tools/gimpmeasuretool.c +++ b/app/tools/gimpmeasuretool.c @@ -33,13 +33,14 @@ #include "gui/gui-types.h" #include "core/gimpimage.h" - -#include "gui/info-dialog.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" #include "display/gimpdisplayshell.h" +#include "gui/info-dialog.h" + #include "gimpdrawtool.h" #include "gimpmeasuretool.h" #include "tool_manager.h" @@ -248,11 +249,14 @@ gimp_measure_tool_button_press (GimpTool *tool, GimpDisplay *gdisp) { GimpMeasureTool *measure_tool; + MeasureOptions *options; GimpDisplayShell *shell; gint i; measure_tool = GIMP_MEASURE_TOOL (tool); + options = (MeasureOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); /* if we are changing displays, pop the statusbar of the old one */ @@ -402,9 +406,8 @@ gimp_measure_tool_button_press (GimpTool *tool, } /* create the info window if necessary */ - if (! measure_tool_info && - (measure_tool_options->use_info_window || - ! GTK_WIDGET_VISIBLE (shell->statusarea))) + if (! measure_tool_info && (options->use_info_window || + ! GTK_WIDGET_VISIBLE (shell->statusarea))) { measure_tool_info = info_dialog_new (_("Measure Tool"), tool_manager_help_func, NULL); @@ -462,6 +465,7 @@ gimp_measure_tool_motion (GimpTool *tool, GimpDisplay *gdisp) { GimpMeasureTool *measure_tool; + MeasureOptions *options; GimpDisplayShell *shell; gint ax, ay; gint bx, by; @@ -474,6 +478,8 @@ gimp_measure_tool_motion (GimpTool *tool, measure_tool = GIMP_MEASURE_TOOL (tool); + options = (MeasureOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); gimp_draw_tool_pause (GIMP_DRAW_TOOL(measure_tool)); @@ -606,14 +612,11 @@ gimp_measure_tool_motion (GimpTool *tool, g_snprintf (status_str, sizeof (status_str), "%.1f %s, %.2f %s", distance, _("pixels"), angle, _("degrees")); - - if (measure_tool_options) - { - g_snprintf (distance_buf, sizeof (distance_buf), "%.1f %s", - distance, _("pixels")); - g_snprintf (angle_buf, sizeof (angle_buf), "%.2f %s", - angle, _("degrees")); - } + + g_snprintf (distance_buf, sizeof (distance_buf), "%.1f %s", + distance, _("pixels")); + g_snprintf (angle_buf, sizeof (angle_buf), "%.2f %s", + angle, _("degrees")); } else /* show real world units */ { @@ -644,18 +647,15 @@ gimp_measure_tool_motion (GimpTool *tool, distance, angle); g_free (format_str); - if (measure_tool_options) - { - gchar *format_str = - g_strdup_printf ("%%.%df %s", - gimp_unit_get_digits (gdisp->gimage->unit), - gimp_unit_get_symbol (gdisp->gimage->unit)); - g_snprintf (distance_buf, sizeof (distance_buf), format_str, - distance); - g_snprintf (angle_buf, sizeof (angle_buf), "%.2f %s", - angle, _("degrees")); - g_free (format_str); - } + format_str = + g_strdup_printf ("%%.%df %s", + gimp_unit_get_digits (gdisp->gimage->unit), + gimp_unit_get_symbol (gdisp->gimage->unit)); + g_snprintf (distance_buf, sizeof (distance_buf), format_str, + distance); + g_snprintf (angle_buf, sizeof (angle_buf), "%.2f %s", + angle, _("degrees")); + g_free (format_str); } /* show info in statusbar */ diff --git a/app/tools/gimprectselecttool.c b/app/tools/gimprectselecttool.c index c8e98c1c10..46466d49ed 100644 --- a/app/tools/gimprectselecttool.c +++ b/app/tools/gimprectselecttool.c @@ -43,7 +43,6 @@ #include "gimpeditselectiontool.h" #include "gimprectselecttool.h" #include "selection_options.h" -#include "tool_options.h" #include "tool_manager.h" #include "floating_sel.h" diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c index 8e147a293c..3e7d6aad98 100644 --- a/app/tools/gimpregionselecttool.c +++ b/app/tools/gimpregionselecttool.c @@ -40,6 +40,7 @@ #include "core/gimpimage-contiguous-region.h" #include "core/gimpimage-mask.h" #include "core/gimpimage-mask-select.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplay-foreach.h" @@ -47,9 +48,7 @@ #include "gimpeditselectiontool.h" #include "gimpfuzzyselecttool.h" -#include "gimptool.h" #include "selection_options.h" -#include "tool_options.h" #include "tool_manager.h" #include "gimprc.h" @@ -215,17 +214,20 @@ gimp_fuzzy_select_tool_button_press (GimpTool *tool, GimpDisplay *gdisp) { GimpFuzzySelectTool *fuzzy_sel; + SelectionOptions *sel_options; GimpDisplayShell *shell; fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); fuzzy_sel->x = coords->x; fuzzy_sel->y = coords->y; fuzzy_sel->first_x = fuzzy_sel->x; fuzzy_sel->first_y = fuzzy_sel->y; - fuzzy_sel->first_threshold = fuzzy_options->threshold; + fuzzy_sel->first_threshold = sel_options->threshold; tool->state = ACTIVE; tool->gdisp = gdisp; @@ -262,10 +264,13 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool, GimpDisplay *gdisp) { GimpFuzzySelectTool *fuzzy_sel; + SelectionOptions *sel_options; GimpDrawable *drawable; fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + gdk_pointer_ungrab (time); gdk_flush (); @@ -279,12 +284,12 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool, gimp_image_mask_select_channel (gdisp->gimage, drawable, - fuzzy_options->sample_merged, + sel_options->sample_merged, fuzzy_sel->fuzzy_mask, GIMP_SELECTION_TOOL (tool)->op, - fuzzy_options->feather, - fuzzy_options->feather_radius, - fuzzy_options->feather_radius); + sel_options->feather, + sel_options->feather_radius, + sel_options->feather_radius); g_object_unref (G_OBJECT (fuzzy_sel->fuzzy_mask)); fuzzy_sel->fuzzy_mask = NULL; @@ -309,6 +314,7 @@ gimp_fuzzy_select_tool_motion (GimpTool *tool, { GimpFuzzySelectTool *fuzzy_sel; GimpSelectionTool *sel_tool; + SelectionOptions *sel_options; GdkSegment *new_segs; gint num_new_segs; gint diff_x, diff_y; @@ -319,6 +325,8 @@ gimp_fuzzy_select_tool_motion (GimpTool *tool, fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool); sel_tool = GIMP_SELECTION_TOOL (tool); + sel_options = (SelectionOptions *) tool->tool_info->tool_options; + if (tool->state != ACTIVE) return; @@ -333,7 +341,7 @@ gimp_fuzzy_select_tool_motion (GimpTool *tool, diff = ((ABS (diff_x) > ABS (diff_y)) ? diff_x : diff_y) / 2.0; - gtk_adjustment_set_value (GTK_ADJUSTMENT (fuzzy_options->threshold_w), + gtk_adjustment_set_value (GTK_ADJUSTMENT (sel_options->threshold_w), fuzzy_sel->first_threshold + diff); /* calculate the new fuzzy boundary */ @@ -356,22 +364,25 @@ fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, GimpDisplay *gdisp, gint *nsegs) { - PixelRegion maskPR; - GimpChannel *new; - GdkSegment *segs; - BoundSeg *bsegs; - GimpDrawable *drawable; - gint i; - gint x, y; + SelectionOptions *sel_options; + PixelRegion maskPR; + GimpChannel *new; + GdkSegment *segs; + BoundSeg *bsegs; + GimpDrawable *drawable; + gint i; + gint x, y; - drawable = gimp_image_active_drawable (gdisp->gimage); + sel_options = (SelectionOptions *) GIMP_TOOL (fuzzy_sel)->tool_info->tool_options; + + drawable = gimp_image_active_drawable (gdisp->gimage); gimp_set_busy (gdisp->gimage->gimp); x = fuzzy_sel->x; y = fuzzy_sel->y; - if (! fuzzy_options->sample_merged) + if (! sel_options->sample_merged) { gint off_x, off_y; @@ -382,9 +393,9 @@ fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, } new = gimp_image_contiguous_region_by_seed (gdisp->gimage, drawable, - fuzzy_options->sample_merged, - fuzzy_options->antialias, - fuzzy_options->threshold, + sel_options->sample_merged, + sel_options->antialias, + sel_options->threshold, x, y); if (fuzzy_sel->fuzzy_mask) @@ -413,14 +424,14 @@ fuzzy_select_calculate (GimpFuzzySelectTool *fuzzy_sel, gdisplay_transform_coords (gdisp, bsegs[i].x1, bsegs[i].y1, &x, &y, - ! fuzzy_options->sample_merged); + ! sel_options->sample_merged); segs[i].x1 = x; segs[i].y1 = y; gdisplay_transform_coords (gdisp, bsegs[i].x2, bsegs[i].y2, &x, &y, - ! fuzzy_options->sample_merged); + ! sel_options->sample_merged); segs[i].x2 = x; segs[i].y2 = y; } diff --git a/app/tools/gimpsmudgetool.c b/app/tools/gimpsmudgetool.c index 0f0b8df773..89a28c90f7 100644 --- a/app/tools/gimpsmudgetool.c +++ b/app/tools/gimpsmudgetool.c @@ -36,6 +36,7 @@ #include "core/gimpcontext.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" +#include "core/gimptoolinfo.h" #include "gimpsmudgetool.h" #include "paint_options.h" @@ -189,18 +190,23 @@ gimp_smudge_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + SmudgeOptions *options; + /* initialization fails if the user starts outside the drawable */ static gboolean initialized = FALSE; + options = (SmudgeOptions *) GIMP_TOOL (paint_tool)->tool_info->tool_options; + switch (state) { case MOTION_PAINT: - if (!initialized) + if (! initialized) initialized = gimp_smudge_tool_start (paint_tool, drawable); if (initialized) gimp_smudge_tool_motion (paint_tool, - smudge_options->paint_options.pressure_options, - smudge_options->rate, drawable); + options->paint_options.pressure_options, + options->rate, + drawable); break; case FINISH_PAINT: diff --git a/app/tools/gimpsourcetool.c b/app/tools/gimpsourcetool.c index c1284b14cc..1d77cb2e1c 100644 --- a/app/tools/gimpsourcetool.c +++ b/app/tools/gimpsourcetool.c @@ -33,12 +33,13 @@ #include "paint-funcs/paint-funcs.h" #include "core/gimp.h" +#include "core/gimpbrush.h" +#include "core/gimpcontext.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-mask.h" #include "core/gimppattern.h" -#include "core/gimpcontext.h" -#include "core/gimpbrush.h" +#include "core/gimptoolinfo.h" #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" @@ -279,17 +280,22 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, GimpDrawable *drawable, PaintState state) { + GimpTool *tool; + GimpDrawTool *draw_tool; + CloneOptions *options; GimpDisplay *gdisp; GimpDisplay *src_gdisp; gint x1, y1, x2, y2; static gint orig_src_x, orig_src_y; - GimpDrawTool *draw_tool; GimpContext *context; - gdisp = (GimpDisplay *) tool_manager_get_active (drawable->gimage->gimp)->gdisp; - + tool = GIMP_TOOL (paint_tool); draw_tool = GIMP_DRAW_TOOL (paint_tool); + options = (CloneOptions *) tool->tool_info->tool_options; + + gdisp = tool->gdisp; + context = gimp_get_current_context (gdisp->gimage->gimp); switch (state) @@ -317,7 +323,7 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, dest_x = x1; dest_y = y1; - if (clone_options->aligned == ALIGN_REGISTERED) + if (options->aligned == ALIGN_REGISTERED) { offset_x = 0; offset_y = 0; @@ -333,8 +339,9 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, src_y = dest_y + offset_y; gimp_clone_tool_motion (paint_tool, drawable, src_drawable_, - clone_options->paint_options.pressure_options, - clone_options->type, offset_x, offset_y); + options->paint_options.pressure_options, + options->type, + offset_x, offset_y); } break; @@ -348,20 +355,21 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool, src_y = paint_tool->cur_coords.y; first = TRUE; } - else if (clone_options->aligned == ALIGN_NO) + else if (options->aligned == ALIGN_NO) { first = TRUE; orig_src_x = src_x; orig_src_y = src_y; } - if (clone_options->type == PATTERN_CLONE) + + if (options->type == PATTERN_CLONE) if (! gimp_context_get_pattern (context)) g_message (_("No patterns available for this operation.")); break; case FINISH_PAINT: gimp_draw_tool_stop (draw_tool); - if (clone_options->aligned == ALIGN_NO && !first) + if (options->aligned == ALIGN_NO && !first) { src_x = orig_src_x; src_y = orig_src_y; @@ -405,10 +413,13 @@ gimp_clone_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *gdisp) { + CloneOptions *options; GimpDisplayShell *shell; GimpLayer *layer; GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + options = (CloneOptions *) tool->tool_info->tool_options; + shell = GIMP_DISPLAY_SHELL (gdisp->shell); if ((layer = gimp_image_get_active_layer (gdisp->gimage))) @@ -432,7 +443,7 @@ gimp_clone_tool_cursor_update (GimpTool *tool, } } - if (clone_options->type == IMAGE_CLONE) + if (options->type == IMAGE_CLONE) { if (state & GDK_CONTROL_MASK) ctype = GIMP_CROSSHAIR_SMALL_CURSOR; @@ -451,7 +462,11 @@ gimp_clone_tool_cursor_update (GimpTool *tool, static void gimp_clone_tool_draw (GimpDrawTool *draw_tool) { - if (draw_tool->gc != NULL && clone_options->type == IMAGE_CLONE) + CloneOptions *options; + + options = (CloneOptions *) GIMP_TOOL (draw_tool)->tool_info->tool_options; + + if (draw_tool->gc != NULL && options->type == IMAGE_CLONE) { gdk_draw_line (draw_tool->win, draw_tool->gc, trans_tx - (TARGET_WIDTH >> 1), trans_ty, diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c index 5b1b3b1af7..29323d2fcd 100644 --- a/app/widgets/gimpdockbook.c +++ b/app/widgets/gimpdockbook.c @@ -212,6 +212,28 @@ gimp_dockbook_add (GimpDockbook *dockbook, g_object_set_data (G_OBJECT (tab_widget), "gimp-dockable", dockable); + /* set the drag source *before* connecting button_press because we + * stop button_press emission by returning TRUE from the callback + */ + gtk_drag_source_set (GTK_WIDGET (tab_widget), + GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, + dialog_target_table, G_N_ELEMENTS (dialog_target_table), + GDK_ACTION_MOVE); + g_signal_connect (G_OBJECT (tab_widget), "drag_begin", + G_CALLBACK (gimp_dockbook_tab_drag_begin), + dockable); + g_signal_connect (G_OBJECT (tab_widget), "drag_end", + G_CALLBACK (gimp_dockbook_tab_drag_end), + dockable); + + gtk_drag_dest_set (GTK_WIDGET (tab_widget), + GTK_DEST_DEFAULT_ALL, + dialog_target_table, G_N_ELEMENTS (dialog_target_table), + GDK_ACTION_MOVE); + g_signal_connect (G_OBJECT (tab_widget), "drag_drop", + G_CALLBACK (gimp_dockbook_tab_drag_drop), + dockbook); + g_signal_connect (G_OBJECT (tab_widget), "button_press_event", G_CALLBACK (gimp_dockbook_tab_button_press), dockable); @@ -307,25 +329,6 @@ gimp_dockbook_add (GimpDockbook *dockbook, gtk_widget_show (GTK_WIDGET (dockable)); - gtk_drag_source_set (GTK_WIDGET (tab_widget), - GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, - dialog_target_table, G_N_ELEMENTS (dialog_target_table), - GDK_ACTION_MOVE); - g_signal_connect (G_OBJECT (tab_widget), "drag_begin", - G_CALLBACK (gimp_dockbook_tab_drag_begin), - dockable); - g_signal_connect (G_OBJECT (tab_widget), "drag_end", - G_CALLBACK (gimp_dockbook_tab_drag_end), - dockable); - - gtk_drag_dest_set (GTK_WIDGET (tab_widget), - GTK_DEST_DEFAULT_ALL, - dialog_target_table, G_N_ELEMENTS (dialog_target_table), - GDK_ACTION_MOVE); - g_signal_connect (G_OBJECT (tab_widget), "drag_drop", - G_CALLBACK (gimp_dockbook_tab_drag_drop), - dockbook); - dockable->dockbook = dockbook; gimp_dockable_set_context (dockable, dockbook->dock->context); @@ -484,7 +487,7 @@ gimp_dockbook_tab_button_press (GtkWidget *widget, 3, bevent->time); } - return FALSE; + return TRUE; } static void diff --git a/libgimpmodule/gimpmoduledb.c b/libgimpmodule/gimpmoduledb.c index 59d6d68b07..6ee7dcc35e 100644 --- a/libgimpmodule/gimpmoduledb.c +++ b/libgimpmodule/gimpmoduledb.c @@ -36,12 +36,12 @@ #include "core-types.h" -#include "core/gimp.h" -#include "core/gimpcoreconfig.h" -#include "core/gimpdatafiles.h" -#include "core/gimplist.h" -#include "core/gimpmoduleinfo.h" -#include "core/gimpmodules.h" +#include "gimp.h" +#include "gimpcoreconfig.h" +#include "gimpdatafiles.h" +#include "gimplist.h" +#include "gimpmoduleinfo.h" +#include "gimpmodules.h" #include "gimprc.h"