From 2db8881557acaefe6c3572cb757ad361f1c84d4d Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 31 Dec 2000 04:07:42 +0000 Subject: [PATCH] app/airbrush.[ch] app/bezier_select.c app/bezier_selectP.h app/blend.[ch] 2000-12-31 Michael Natterer * app/airbrush.[ch] * app/bezier_select.c * app/bezier_selectP.h * app/blend.[ch] * app/boundary.h * app/brightness_contrast.[ch] * app/bucket_fill.c * app/by_color_select.c * app/clone.[ch] * app/color_balance.c * app/color_picker.c * app/commands.c * app/convolve.[ch] * app/crop.c * app/crop.h * app/curves.c * app/dodgeburn.[ch] * app/edit_selection.[ch] * app/ellipse_select.c * app/eraser.[ch] * app/flip_tool.[ch] * app/free_select.[ch] * app/fuzzy_select.[ch] * app/gdisplay.c * app/gimage.c * app/histogram_tool.[ch] * app/hue_saturation.[ch] * app/image_map.[ch] * app/ink.[ch] * app/iscissors.c * app/levels.c * app/magnify.[ch] * app/move.c * app/nav_window.[ch] * app/paint_core.[ch] * app/paintbrush.[ch] * app/path_bezier.[ch] * app/path_tool.c * app/pencil.[ch] * app/perspective_tool.[ch] * app/posterize.c * app/rect_select.[ch] * app/rotate_tool.[ch] * app/scale_tool.[ch] * app/selection.[ch] * app/shear_tool.[ch] * app/smudge.[ch] * app/text_tool.[ch] * app/threshold.c * app/tools.[ch] * app/transform_core.[ch]: removed the "gdisp_ptr" madness and useless casts all over the place. Introduced a "PaintState" enum instead of #define's. Various cleanups. --- ChangeLog | 56 ++++ app/actions/help-commands.c | 11 +- app/airbrush.c | 37 ++- app/airbrush.h | 20 +- app/base/boundary.h | 3 - app/base/color-balance.c | 54 ++-- app/base/curves.c | 141 ++++++---- app/base/hue-saturation.c | 65 +++-- app/base/hue-saturation.h | 1 + app/base/threshold.c | 60 +++-- app/bezier_select.c | 185 +++++++------ app/bezier_selectP.h | 2 +- app/blend.c | 69 ++--- app/blend.h | 36 +-- app/boundary.h | 3 - app/brightness_contrast.c | 24 +- app/brightness_contrast.h | 6 +- app/bucket_fill.c | 103 +++---- app/by_color_select.c | 134 ++++++---- app/clone.c | 132 +++++---- app/clone.h | 26 +- app/color_balance.c | 54 ++-- app/color_picker.c | 96 +++---- app/commands.c | 11 +- app/convolve.c | 100 ++++--- app/convolve.h | 24 +- app/core/gimpdrawable-blend.c | 69 ++--- app/core/gimpimagemap.c | 8 +- app/core/gimpimagemap.h | 4 +- app/core/gimpprojection.c | 4 +- app/crop.c | 322 +++++++++++----------- app/crop.h | 14 +- app/curves.c | 141 ++++++---- app/display/gimpdisplay-selection.c | 37 ++- app/display/gimpdisplay-selection.h | 83 +++--- app/display/gimpdisplay.c | 4 +- app/display/gimpdisplayshell-selection.c | 37 ++- app/display/gimpdisplayshell-selection.h | 83 +++--- app/display/gimpnavigationeditor.c | 119 ++++----- app/display/gimpnavigationview.c | 119 ++++----- app/dodgeburn.c | 210 ++++++++------- app/dodgeburn.h | 23 +- app/edit_selection.c | 35 +-- app/edit_selection.h | 28 +- app/ellipse_select.c | 6 +- app/eraser.c | 54 ++-- app/eraser.h | 25 +- app/flip_tool.c | 29 +- app/flip_tool.h | 4 - app/free_select.c | 41 +-- app/free_select.h | 13 - app/fuzzy_select.c | 77 +++--- app/fuzzy_select.h | 14 +- app/gdisplay.c | 4 +- app/gimage.c | 8 +- app/gui/commands.c | 11 +- app/gui/help-commands.c | 11 +- app/histogram_tool.c | 51 ++-- app/histogram_tool.h | 1 + app/hue_saturation.c | 65 +++-- app/hue_saturation.h | 1 + app/image_map.c | 8 +- app/image_map.h | 4 +- app/ink.c | 325 ++++++++++++----------- app/ink.h | 1 + app/iscissors.c | 187 ++++++------- app/levels.c | 96 ++++--- app/magnify.c | 94 +++---- app/measure.c | 101 ++++--- app/move.c | 78 +++--- app/nav_window.c | 119 ++++----- app/nav_window.h | 2 +- app/paint/gimpairbrush.c | 37 ++- app/paint/gimpairbrush.h | 20 +- app/paint/gimpclone.c | 132 +++++---- app/paint/gimpclone.h | 26 +- app/paint/gimpconvolve.c | 100 ++++--- app/paint/gimpconvolve.h | 24 +- app/paint/gimpdodgeburn.c | 210 ++++++++------- app/paint/gimpdodgeburn.h | 23 +- app/paint/gimperaser.c | 54 ++-- app/paint/gimperaser.h | 25 +- app/paint/gimpink.c | 325 ++++++++++++----------- app/paint/gimpink.h | 1 + app/paint/gimppencil.c | 24 +- app/paint/gimppencil.h | 9 +- app/paint/gimpsmudge.c | 95 ++++--- app/paint/gimpsmudge.h | 18 +- app/paint/gimpsourcecore.c | 132 +++++---- app/paint/gimpsourcecore.h | 26 +- app/paint_core.c | 131 +++++---- app/paint_core.h | 116 ++++---- app/paintbrush.c | 40 +-- app/paintbrush.h | 3 - app/path_bezier.c | 2 +- app/path_curves.c | 2 +- app/path_tool.c | 28 +- app/pencil.c | 24 +- app/pencil.h | 9 +- app/perspective_tool.c | 39 +-- app/perspective_tool.h | 3 - app/posterize.c | 41 +-- app/rect_select.c | 95 +++---- app/rect_select.h | 14 +- app/rotate_tool.c | 58 ++-- app/rotate_tool.h | 3 - app/scale_tool.c | 63 +++-- app/scale_tool.h | 3 - app/selection.c | 37 ++- app/selection.h | 83 +++--- app/shear_tool.c | 56 ++-- app/shear_tool.h | 3 - app/smudge.c | 95 ++++--- app/smudge.h | 18 +- app/text_tool.c | 92 ++++--- app/text_tool.h | 4 +- app/threshold.c | 60 +++-- app/tools.c | 39 ++- app/tools.h | 106 +++++--- app/tools/airbrush.c | 37 ++- app/tools/airbrush.h | 20 +- app/tools/bezier_select.c | 185 +++++++------ app/tools/bezier_selectP.h | 2 +- app/tools/blend.c | 69 ++--- app/tools/blend.h | 36 +-- app/tools/brightness_contrast.c | 24 +- app/tools/brightness_contrast.h | 6 +- app/tools/bucket_fill.c | 103 +++---- app/tools/by_color_select.c | 134 ++++++---- app/tools/clone.c | 132 +++++---- app/tools/clone.h | 26 +- app/tools/color_balance.c | 54 ++-- app/tools/color_picker.c | 96 +++---- app/tools/convolve.c | 100 ++++--- app/tools/convolve.h | 24 +- app/tools/crop.c | 322 +++++++++++----------- app/tools/crop.h | 14 +- app/tools/curves.c | 141 ++++++---- app/tools/dodgeburn.c | 210 ++++++++------- app/tools/dodgeburn.h | 23 +- app/tools/edit_selection.c | 35 +-- app/tools/edit_selection.h | 28 +- app/tools/ellipse_select.c | 6 +- app/tools/eraser.c | 54 ++-- app/tools/eraser.h | 25 +- app/tools/flip_tool.c | 29 +- app/tools/flip_tool.h | 4 - app/tools/free_select.c | 41 +-- app/tools/free_select.h | 13 - app/tools/fuzzy_select.c | 77 +++--- app/tools/fuzzy_select.h | 14 +- app/tools/gimpairbrushtool.c | 37 ++- app/tools/gimpairbrushtool.h | 20 +- app/tools/gimpblendtool.c | 69 ++--- app/tools/gimpblendtool.h | 36 +-- app/tools/gimpbrightnesscontrasttool.c | 24 +- app/tools/gimpbrightnesscontrasttool.h | 6 +- app/tools/gimpbucketfilltool.c | 103 +++---- app/tools/gimpbycolorselecttool.c | 134 ++++++---- app/tools/gimpclonetool.c | 132 +++++---- app/tools/gimpclonetool.h | 26 +- app/tools/gimpcolorbalancetool.c | 54 ++-- app/tools/gimpconvolvetool.c | 100 ++++--- app/tools/gimpconvolvetool.h | 24 +- app/tools/gimpcroptool.c | 322 +++++++++++----------- app/tools/gimpcroptool.h | 14 +- app/tools/gimpcurvestool.c | 141 ++++++---- app/tools/gimpdodgeburntool.c | 210 ++++++++------- app/tools/gimpdodgeburntool.h | 23 +- app/tools/gimpeditselectiontool.c | 35 +-- app/tools/gimpeditselectiontool.h | 28 +- app/tools/gimpellipseselecttool.c | 6 +- app/tools/gimperasertool.c | 54 ++-- app/tools/gimperasertool.h | 25 +- app/tools/gimpfliptool.c | 29 +- app/tools/gimpfliptool.h | 4 - app/tools/gimpfreeselecttool.c | 41 +-- app/tools/gimpfreeselecttool.h | 13 - app/tools/gimpfuzzyselecttool.c | 77 +++--- app/tools/gimpfuzzyselecttool.h | 14 +- app/tools/gimphistogramtool.c | 51 ++-- app/tools/gimphistogramtool.h | 1 + app/tools/gimphuesaturationtool.c | 65 +++-- app/tools/gimphuesaturationtool.h | 1 + app/tools/gimpinktool.c | 325 ++++++++++++----------- app/tools/gimpinktool.h | 1 + app/tools/gimpiscissorstool.c | 187 ++++++------- app/tools/gimplevelstool.c | 96 ++++--- app/tools/gimpmagnifytool.c | 94 +++---- app/tools/gimpmeasuretool.c | 101 ++++--- app/tools/gimpmovetool.c | 78 +++--- app/tools/gimppenciltool.c | 24 +- app/tools/gimppenciltool.h | 9 +- app/tools/gimpperspectivetool.c | 39 +-- app/tools/gimpperspectivetool.h | 3 - app/tools/gimpposterizetool.c | 41 +-- app/tools/gimprectselecttool.c | 95 +++---- app/tools/gimprectselecttool.h | 14 +- app/tools/gimpregionselecttool.c | 77 +++--- app/tools/gimpregionselecttool.h | 14 +- app/tools/gimprotatetool.c | 58 ++-- app/tools/gimprotatetool.h | 3 - app/tools/gimpscaletool.c | 63 +++-- app/tools/gimpscaletool.h | 3 - app/tools/gimpsheartool.c | 56 ++-- app/tools/gimpsheartool.h | 3 - app/tools/gimpsmudgetool.c | 95 ++++--- app/tools/gimpsmudgetool.h | 18 +- app/tools/gimpsourcetool.c | 132 +++++---- app/tools/gimpsourcetool.h | 26 +- app/tools/gimptexttool.c | 92 ++++--- app/tools/gimptexttool.h | 4 +- app/tools/gimpthresholdtool.c | 60 +++-- app/tools/histogram_tool.c | 51 ++-- app/tools/histogram_tool.h | 1 + app/tools/hue_saturation.c | 65 +++-- app/tools/hue_saturation.h | 1 + app/tools/ink.c | 325 ++++++++++++----------- app/tools/ink.h | 1 + app/tools/iscissors.c | 187 ++++++------- app/tools/levels.c | 96 ++++--- app/tools/magnify.c | 94 +++---- app/tools/measure.c | 101 ++++--- app/tools/move.c | 78 +++--- app/tools/paint_core.c | 131 +++++---- app/tools/paint_core.h | 116 ++++---- app/tools/paintbrush.c | 40 +-- app/tools/paintbrush.h | 3 - app/tools/path_tool.c | 28 +- app/tools/pencil.c | 24 +- app/tools/pencil.h | 9 +- app/tools/perspective_tool.c | 39 +-- app/tools/perspective_tool.h | 3 - app/tools/posterize.c | 41 +-- app/tools/rect_select.c | 95 +++---- app/tools/rect_select.h | 14 +- app/tools/rotate_tool.c | 58 ++-- app/tools/rotate_tool.h | 3 - app/tools/scale_tool.c | 63 +++-- app/tools/scale_tool.h | 3 - app/tools/shear_tool.c | 56 ++-- app/tools/shear_tool.h | 3 - app/tools/smudge.c | 95 ++++--- app/tools/smudge.h | 18 +- app/tools/text_tool.c | 92 ++++--- app/tools/text_tool.h | 4 +- app/tools/threshold.c | 60 +++-- app/tools/tools.c | 39 ++- app/tools/tools.h | 106 +++++--- app/tools/transform_core.c | 184 +++++++------ app/tools/transform_core.h | 44 +-- app/transform_core.c | 184 +++++++------ app/transform_core.h | 44 +-- 253 files changed, 8070 insertions(+), 7114 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54e2801ffc..031a5f26ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,59 @@ +2000-12-31 Michael Natterer + + * app/airbrush.[ch] + * app/bezier_select.c + * app/bezier_selectP.h + * app/blend.[ch] + * app/boundary.h + * app/brightness_contrast.[ch] + * app/bucket_fill.c + * app/by_color_select.c + * app/clone.[ch] + * app/color_balance.c + * app/color_picker.c + * app/commands.c + * app/convolve.[ch] + * app/crop.c + * app/crop.h + * app/curves.c + * app/dodgeburn.[ch] + * app/edit_selection.[ch] + * app/ellipse_select.c + * app/eraser.[ch] + * app/flip_tool.[ch] + * app/free_select.[ch] + * app/fuzzy_select.[ch] + * app/gdisplay.c + * app/gimage.c + * app/histogram_tool.[ch] + * app/hue_saturation.[ch] + * app/image_map.[ch] + * app/ink.[ch] + * app/iscissors.c + * app/levels.c + * app/magnify.[ch] + * app/move.c + * app/nav_window.[ch] + * app/paint_core.[ch] + * app/paintbrush.[ch] + * app/path_bezier.[ch] + * app/path_tool.c + * app/pencil.[ch] + * app/perspective_tool.[ch] + * app/posterize.c + * app/rect_select.[ch] + * app/rotate_tool.[ch] + * app/scale_tool.[ch] + * app/selection.[ch] + * app/shear_tool.[ch] + * app/smudge.[ch] + * app/text_tool.[ch] + * app/threshold.c + * app/tools.[ch] + * app/transform_core.[ch]: removed the "gdisp_ptr" madness and + useless casts all over the place. Introduced a "PaintState" enum + instead of #define's. Various cleanups. + 2000-12-30 Michael Natterer One more 17C3 commit ... diff --git a/app/actions/help-commands.c b/app/actions/help-commands.c index 01f3a86d85..f534a7c2bd 100644 --- a/app/actions/help-commands.c +++ b/app/actions/help-commands.c @@ -1080,11 +1080,12 @@ tools_select_cmd_callback (GtkWidget *widget, gpointer callback_data, guint callback_action) { - ToolType tool_type; - GDisplay *gdisp; - gdisp = gdisplay_active (); + ToolType tool_type; + GDisplay *gdisp; tool_type = (ToolType) callback_action; + gdisp = gdisplay_active (); + gimp_context_set_tool (gimp_context_get_user (), tool_type); @@ -1101,12 +1102,12 @@ tools_select_cmd_callback (GtkWidget *widget, active_tool->drawable = gimp_image_active_drawable (gdisp->gimage); } - /* setting the gdisp_ptr here is a HACK to allow the tools' + /* setting the tool->gdisp here is a HACK to allow the tools' * dialog windows being hidden if the tool was selected from * a tear-off-menu and there was no mouse click in the display * before deleting it */ - active_tool->gdisp_ptr = gdisp; + active_tool->gdisp = gdisp; } /***** Filters *****/ diff --git a/app/airbrush.c b/app/airbrush.c index 29ad1d4f90..0289996769 100644 --- a/app/airbrush.c +++ b/app/airbrush.c @@ -77,6 +77,16 @@ struct _AirbrushOptions }; +/* local function prototypes */ + +static gpointer airbrush_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static gpointer airbrush_non_gui_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + + /* the airbrush tool options */ static AirbrushOptions *airbrush_options = NULL; @@ -189,13 +199,13 @@ tools_new_airbrush (void) return tool; } -void * +static gpointer airbrush_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { GimpBrush *brush; - gdouble rate; + gdouble rate; if (!drawable) return NULL; @@ -357,10 +367,10 @@ airbrush_motion (PaintCore *paint_core, SOFT, scale, mode); } -static void * +static gpointer airbrush_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { airbrush_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_pressure, non_gui_incremental); @@ -370,8 +380,8 @@ airbrush_non_gui_paint_func (PaintCore *paint_core, gboolean airbrush_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { AirbrushOptions *options = airbrush_options; gdouble pressure = AIRBRUSH_PRESSURE_DEFAULT; @@ -384,11 +394,11 @@ airbrush_non_gui_default (GimpDrawable *drawable, gboolean airbrush_non_gui (GimpDrawable *drawable, - double pressure, - int num_strokes, - double *stroke_array) + gdouble pressure, + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -419,8 +429,9 @@ airbrush_non_gui (GimpDrawable *drawable, /* Cleanup */ paint_core_cleanup (); + return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/airbrush.h b/app/airbrush.h index ea4e64954b..6eb5528f0f 100644 --- a/app/airbrush.h +++ b/app/airbrush.h @@ -20,18 +20,16 @@ #define __AIRBRUSH_H__ -void * airbrush_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean airbrush_non_gui (GimpDrawable *, - gdouble, - gint, - gdouble *); -gboolean airbrush_non_gui_default (GimpDrawable *, - gint, - gdouble *); +gboolean airbrush_non_gui (GimpDrawable *drawable, + gdouble pressure, + gint num_strokes, + gdouble *stroke_array); +gboolean airbrush_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); + Tool * tools_new_airbrush (void); -void tools_free_airbrush (Tool *); +void tools_free_airbrush (Tool *tool); #endif /* __AIRBRUSH_H__ */ diff --git a/app/base/boundary.h b/app/base/boundary.h index 8ccd3cf3f0..5fbebf1a80 100644 --- a/app/base/boundary.h +++ b/app/base/boundary.h @@ -20,9 +20,6 @@ #define __BOUNDARY_H__ -#include "paint_funcs.h" - - typedef enum { WithinBounds, diff --git a/app/base/color-balance.c b/app/base/color-balance.c index b74246cfdc..87b62926bc 100644 --- a/app/base/color-balance.c +++ b/app/base/color-balance.c @@ -62,21 +62,33 @@ static ColorBalanceDialog *color_balance_dialog = NULL; /* color balance action functions */ -static void color_balance_control (Tool *, ToolAction, gpointer); +static void color_balance_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static ColorBalanceDialog * color_balance_dialog_new (void); -static void color_balance_update (ColorBalanceDialog *, int); -static void color_balance_preview (ColorBalanceDialog *); -static void color_balance_reset_callback (GtkWidget *, gpointer); -static void color_balance_ok_callback (GtkWidget *, gpointer); -static void color_balance_cancel_callback (GtkWidget *, gpointer); -static void color_balance_range_callback (GtkWidget *, gpointer); -static void color_balance_preserve_update (GtkWidget *, gpointer); -static void color_balance_preview_update (GtkWidget *, gpointer); -static void color_balance_cr_adjustment_update (GtkAdjustment *, gpointer); -static void color_balance_mg_adjustment_update (GtkAdjustment *, gpointer); -static void color_balance_yb_adjustment_update (GtkAdjustment *, gpointer); +static void color_balance_update (ColorBalanceDialog *cbd, + gint ); +static void color_balance_preview (ColorBalanceDialog *cbd); +static void color_balance_reset_callback (GtkWidget *widget, + gpointer data); +static void color_balance_ok_callback (GtkWidget *widget, + gpointer data); +static void color_balance_cancel_callback (GtkWidget *widget, + gpointer data); +static void color_balance_range_callback (GtkWidget *widget, + gpointer data); +static void color_balance_preserve_update (GtkWidget *widget, + gpointer data); +static void color_balance_preview_update (GtkWidget *widget, + gpointer data); +static void color_balance_cr_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void color_balance_mg_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void color_balance_yb_adjustment_update (GtkAdjustment *adj, + gpointer data); /* color balance machinery */ @@ -86,12 +98,12 @@ color_balance (PixelRegion *srcPR, void *data) { ColorBalanceDialog *cbd; - guchar *src, *s; - guchar *dest, *d; - gint alpha; - gint r, g, b; - gint r_n, g_n, b_n; - gint w, h; + guchar *src, *s; + guchar *dest, *d; + gboolean alpha; + gint r, g, b; + gint r_n, g_n, b_n; + gint w, h; cbd = (ColorBalanceDialog *) data; @@ -143,7 +155,7 @@ color_balance (PixelRegion *srcPR, static void color_balance_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { ColorBalance * color_bal; @@ -599,7 +611,7 @@ color_balance_ok_callback (GtkWidget *widget, cbd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -623,7 +635,7 @@ color_balance_cancel_callback (GtkWidget *widget, cbd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/base/curves.c b/app/base/curves.c index 7ba6f1ab76..fe3a945fc7 100644 --- a/app/base/curves.c +++ b/app/base/curves.c @@ -108,40 +108,72 @@ static CRMatrix CR_basis = /* curves action functions */ -static void curves_button_press (Tool *, GdkEventButton *, gpointer); -static void curves_button_release (Tool *, GdkEventButton *, gpointer); -static void curves_motion (Tool *, GdkEventMotion *, gpointer); -static void curves_control (Tool *, ToolAction, gpointer); +static void curves_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void curves_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void curves_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void curves_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); -static CurvesDialog * curves_dialog_new (void); +static CurvesDialog * curves_dialog_new (void); -static void curves_update (CurvesDialog *, int); -static void curves_plot_curve (CurvesDialog *, int, int, int, int); -static void curves_preview (CurvesDialog *); +static void curves_update (CurvesDialog *cd, + gint ); +static void curves_plot_curve (CurvesDialog *cd, + gint , + gint , + gint , + gint ); +static void curves_preview (CurvesDialog *cd); -static void curves_channel_callback (GtkWidget *, gpointer); +static void curves_channel_callback (GtkWidget *widget, + gpointer data); -static void curves_smooth_callback (GtkWidget *, gpointer); -static void curves_free_callback (GtkWidget *, gpointer); +static void curves_smooth_callback (GtkWidget *widget, + gpointer data); +static void curves_free_callback (GtkWidget *widget, + gpointer data); -static void curves_channel_reset (int); -static void curves_reset_callback (GtkWidget *, gpointer); -static void curves_ok_callback (GtkWidget *, gpointer); -static void curves_cancel_callback (GtkWidget *, gpointer); -static void curves_load_callback (GtkWidget *, gpointer); -static void curves_save_callback (GtkWidget *, gpointer); -static void curves_preview_update (GtkWidget *, gpointer); -static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static gint curves_graph_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static void curves_CR_compose (CRMatrix, CRMatrix, CRMatrix); +static void curves_channel_reset (gint ); +static void curves_reset_callback (GtkWidget *widget, + gpointer data); +static void curves_ok_callback (GtkWidget *widget, + gpointer data); +static void curves_cancel_callback (GtkWidget *widget, + gpointer data); +static void curves_load_callback (GtkWidget *widget, + gpointer data); +static void curves_save_callback (GtkWidget *widget, + gpointer data); +static void curves_preview_update (GtkWidget *widget, + gpointer data); +static gint curves_xrange_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static gint curves_yrange_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static gint curves_graph_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static void curves_CR_compose (CRMatrix , + CRMatrix , + CRMatrix ); -static void file_dialog_create (GtkWidget *); -static void file_dialog_ok_callback (GtkWidget *, gpointer); -static void file_dialog_cancel_callback (GtkWidget *, gpointer); +static void file_dialog_create (GtkWidget *widget); +static void file_dialog_ok_callback (GtkWidget *widget, + gpointer data); +static void file_dialog_cancel_callback (GtkWidget *widget, + gpointer data); -static gboolean curves_read_from_file (FILE *f); -static void curves_write_to_file (FILE *f); +static gboolean curves_read_from_file (FILE *f); +static void curves_write_to_file (FILE *f); /* curves machinery */ @@ -152,10 +184,10 @@ curves_lut_func (CurvesDialog *cd, gint channel, gfloat value) { - gfloat f; - gint index; + gfloat f; + gint index; gdouble inten; - gint j; + gint j; if (nchannels == 1) j = 0; @@ -197,15 +229,15 @@ curves_colour_update (Tool *tool, gint x, gint y) { - guchar *color; - gint offx; - gint offy; - gint maxval; + guchar *color; + gint offx; + gint offy; + gint maxval; gboolean has_alpha; gboolean is_indexed; GimpImageType sample_type; - if(!tool || tool->state != ACTIVE) + if (!tool || tool->state != ACTIVE) return; drawable_offsets (drawable, &offx, &offy); @@ -213,7 +245,7 @@ curves_colour_update (Tool *tool, x -= offx; y -= offy; - if (!(color = image_map_get_color_at(curves_dialog->image_map, x, y))) + if (!(color = image_map_get_color_at (curves_dialog->image_map, x, y))) return; sample_type = gimp_drawable_type (drawable); @@ -283,16 +315,14 @@ curves_add_point (GimpDrawable *drawable, static void curves_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; - GDisplay *gdisp; + gint x, y; GimpDrawable *drawable; - gdisp = gdisp_ptr; drawable = gimp_image_active_drawable (gdisp->gimage); - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; if (drawable != tool->drawable) { @@ -318,20 +348,18 @@ curves_button_press (Tool *tool, static void curves_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; + gint x, y; GimpDrawable *drawable; - GDisplay *gdisp; - gdisp = (GDisplay *) gdisp_ptr; - - if(!curves_dialog || - !gdisp || - !(drawable = gimp_image_active_drawable (gdisp->gimage))) + if (! curves_dialog || + ! gdisp || + ! (drawable = gimp_image_active_drawable (gdisp->gimage))) return; - gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE); + gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, + FALSE, FALSE); curves_colour_update (tool, gdisp, drawable, x, y); if (bevent->state & GDK_SHIFT_MASK) @@ -355,14 +383,11 @@ curves_button_release (Tool *tool, static void curves_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; - GDisplay *gdisp; + gint x, y; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; - if (! curves_dialog || ! gdisp || ! (drawable = gimp_image_active_drawable (gdisp->gimage))) @@ -376,7 +401,7 @@ curves_motion (Tool *tool, static void curves_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -1279,7 +1304,7 @@ curves_ok_callback (GtkWidget *widget, cd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -1303,7 +1328,7 @@ curves_cancel_callback (GtkWidget *widget, cd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/base/hue-saturation.c b/app/base/hue-saturation.c index 0caf2f0a6f..fde7e3de2b 100644 --- a/app/base/hue-saturation.c +++ b/app/base/hue-saturation.c @@ -43,8 +43,8 @@ #define HUE_PARTITION_MASK GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK #define SLIDER_WIDTH 200 -#define DA_WIDTH 40 -#define DA_HEIGHT 20 +#define DA_WIDTH 40 +#define DA_HEIGHT 20 #define HUE_PARTITION 0x0 #define HUE_SLIDER 0x1 @@ -62,6 +62,38 @@ struct _HueSaturation gint x, y; /* coords for last mouse click */ }; + +/* hue saturation action functions */ +static void hue_saturation_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static HueSaturationDialog * hue_saturation_dialog_new (void); + +static void hue_saturation_update (HueSaturationDialog *hsd, + gint); +static void hue_saturation_preview (HueSaturationDialog *hsd); +static void hue_saturation_reset_callback (GtkWidget *, + gpointer); +static void hue_saturation_ok_callback (GtkWidget *, + gpointer); +static void hue_saturation_cancel_callback (GtkWidget *, + gpointer); +static void hue_saturation_partition_callback (GtkWidget *, + gpointer); +static void hue_saturation_preview_update (GtkWidget *, + gpointer); +static void hue_saturation_hue_adjustment_update (GtkAdjustment *, + gpointer); +static void hue_saturation_lightness_adjustment_update (GtkAdjustment *, + gpointer); +static void hue_saturation_saturation_adjustment_update (GtkAdjustment *, + gpointer); +static gint hue_saturation_hue_partition_events (GtkWidget *, + GdkEvent *, + HueSaturationDialog *hsd); + + /* the hue-saturation tool options */ static ToolOptions *hue_saturation_options = NULL; @@ -82,27 +114,6 @@ static gint default_colors[6][3] = { 255, 0, 255 } }; -/* hue saturation action functions */ -static void hue_saturation_control (Tool *, ToolAction, gpointer); - -static HueSaturationDialog * hue_saturation_dialog_new (void); - -static void hue_saturation_update (HueSaturationDialog *, - gint); -static void hue_saturation_preview (HueSaturationDialog *); -static void hue_saturation_reset_callback (GtkWidget *, gpointer); -static void hue_saturation_ok_callback (GtkWidget *, gpointer); -static void hue_saturation_cancel_callback (GtkWidget *, gpointer); -static void hue_saturation_partition_callback (GtkWidget *, gpointer); -static void hue_saturation_preview_update (GtkWidget *, gpointer); -static void hue_saturation_hue_adjustment_update (GtkAdjustment *, - gpointer); -static void hue_saturation_lightness_adjustment_update (GtkAdjustment *, - gpointer); -static void hue_saturation_saturation_adjustment_update (GtkAdjustment *, - gpointer); -static gint hue_saturation_hue_partition_events (GtkWidget *, GdkEvent *, - HueSaturationDialog *); /* hue saturation machinery */ @@ -223,7 +234,7 @@ hue_saturation (PixelRegion *srcPR, static void hue_saturation_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -691,7 +702,7 @@ hue_saturation_ok_callback (GtkWidget *widget, active_tool->preserve = TRUE; if (!hsd->preview) - image_map_apply (hsd->image_map, hue_saturation, (void *) hsd); + image_map_apply (hsd->image_map, hue_saturation, (gpointer) hsd); if (hsd->image_map) image_map_commit (hsd->image_map); @@ -700,7 +711,7 @@ hue_saturation_ok_callback (GtkWidget *widget, hsd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -724,7 +735,7 @@ hue_saturation_cancel_callback (GtkWidget *widget, hsd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/base/hue-saturation.h b/app/base/hue-saturation.h index 80ee176884..5fec88fa53 100644 --- a/app/base/hue-saturation.h +++ b/app/base/hue-saturation.h @@ -54,6 +54,7 @@ struct _HueSaturationDialog gboolean preview; }; + Tool * tools_new_hue_saturation (void); void tools_free_hue_saturation (Tool *tool); diff --git a/app/base/threshold.c b/app/base/threshold.c index 90d6cea647..5fefd450c6 100644 --- a/app/base/threshold.c +++ b/app/base/threshold.c @@ -56,36 +56,50 @@ struct _Threshold gint x, y; /* coords for last mouse click */ }; + +/* threshold action functions */ +static void threshold_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static ThresholdDialog * threshold_dialog_new (void); + +static void threshold_update (ThresholdDialog *td, + gint update); +static void threshold_preview (ThresholdDialog *td); +static void threshold_reset_callback (GtkWidget *widget, + gpointer data); +static void threshold_ok_callback (GtkWidget *widget, + gpointer data); +static void threshold_cancel_callback (GtkWidget *widget, + gpointer data); +static void threshold_preview_update (GtkWidget *widget, + gpointer data); +static void threshold_low_threshold_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void threshold_high_threshold_adjustment_update (GtkAdjustment *adj, + gpointer data); + +static void threshold (PixelRegion *, + PixelRegion *, + gpointer ); +static void threshold_histogram_range (HistogramWidget *, + gint , + gint , + gpointer ); + + /* the threshold tool options */ static ToolOptions *threshold_options = NULL; /* the threshold tool dialog */ static ThresholdDialog *threshold_dialog = NULL; -/* threshold action functions */ -static void threshold_control (Tool *, ToolAction, gpointer); -static ThresholdDialog * threshold_dialog_new (void); - -static void threshold_update (ThresholdDialog *, - gint); -static void threshold_preview (ThresholdDialog *); -static void threshold_reset_callback (GtkWidget *, gpointer); -static void threshold_ok_callback (GtkWidget *, gpointer); -static void threshold_cancel_callback (GtkWidget *, gpointer); -static void threshold_preview_update (GtkWidget *, gpointer); -static void threshold_low_threshold_adjustment_update (GtkAdjustment *, - gpointer); -static void threshold_high_threshold_adjustment_update (GtkAdjustment *, - gpointer); - -static void threshold (PixelRegion *, PixelRegion *, void *); -static void threshold_histogram_range (HistogramWidget *, gint, gint, - gpointer); /* threshold machinery */ void -threshold_2 (void *data, +threshold_2 (gpointer data, PixelRegion *srcPR, PixelRegion *destPR) { @@ -152,7 +166,7 @@ threshold (PixelRegion *srcPR, static void threshold_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -453,7 +467,7 @@ threshold_ok_callback (GtkWidget *widget, td->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -477,7 +491,7 @@ threshold_cancel_callback (GtkWidget *widget, gdisplays_flush (); } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/bezier_select.c b/app/bezier_select.c index b29fb669c3..a6ff254142 100644 --- a/app/bezier_select.c +++ b/app/bezier_select.c @@ -119,19 +119,19 @@ typedef struct static void bezier_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr); + GDisplay *gdisp); static void bezier_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr); + GDisplay *gdisp); static void bezier_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); static void bezier_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr); + GDisplay *gdisp); static void bezier_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); static void bezier_select_draw (Tool *tool); static void bezier_offset_point (BezierPoint *pt, @@ -308,22 +308,19 @@ tools_free_bezier_select (Tool *tool) } gint -bezier_select_load (void *gdisp_ptr, +bezier_select_load (GDisplay *gdisp, BezierPoint *pts, gint num_pts, gint closed) { - GDisplay *gdisp; Tool *tool; BezierSelect *bezier_sel; - gdisp = (GDisplay *) gdisp_ptr; - /* select the bezier tool */ gimp_context_set_tool (gimp_context_get_user (), BEZIER_SELECT); tool = active_tool; tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; bezier_sel = (BezierSelect *) tool->private; bezier_sel->points = pts; @@ -333,7 +330,7 @@ bezier_select_load (void *gdisp_ptr, bezier_sel->state = BEZIER_EDIT; bezier_sel->draw = BEZIER_DRAW_ALL; - bezier_convert (bezier_sel, tool->gdisp_ptr, SUBDIVIDE, FALSE); + bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, FALSE); draw_core_start (bezier_sel->core, gdisp->canvas->window, tool); @@ -966,9 +963,8 @@ bezier_start_new_segment (BezierSelect *bezier_sel, static void bezier_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; BezierSelect *bezier_sel; BezierPoint *points; BezierPoint *start_pt; @@ -978,8 +974,6 @@ bezier_select_button_press (Tool *tool, gint x, y; gint halfwidth, dummy; - gdisp = (GDisplay *) gdisp_ptr; - tool->drawable = gimp_image_active_drawable (gdisp->gimage); bezier_sel = tool->private; @@ -987,12 +981,12 @@ bezier_select_button_press (Tool *tool, if (bezier_options->extend) { - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; } else { /* If the tool was being used in another image...reset it */ - if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp != tool->gdisp) { draw_core_stop (bezier_sel->core, tool); bezier_select_reset (bezier_sel); @@ -1008,8 +1002,8 @@ bezier_select_button_press (Tool *tool, curTool = active_tool; curSel = curTool->private; - curGdisp = (GDisplay *) gdisp_ptr; - active_tool->gdisp_ptr = gdisp_ptr; + curGdisp = (GDisplay *) gdisp; + active_tool->gdisp = gdisp; curCore = bezier_sel->core; switch (bezier_sel->state) @@ -1019,19 +1013,19 @@ bezier_select_button_press (Tool *tool, break; grab_pointer = TRUE; - tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->state = ACTIVE; + tool->gdisp = gdisp; /* if (bevent->state & GDK_MOD1_MASK) */ /* { */ -/* init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); */ +/* init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); */ /* break; */ /* } */ /* else if (!(bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK)) */ /* if (! (layer_is_floating_sel (gimp_image_get_active_layer (gdisp->gimage))) && */ /* gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY) */ /* { */ -/* init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); */ +/* init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); */ /* break; */ /* } */ @@ -1079,7 +1073,7 @@ bezier_select_button_press (Tool *tool, { paths_dialog_set_default_op (); /* recursive call */ - bezier_select_button_press (tool, bevent, gdisp_ptr); + bezier_select_button_press (tool, bevent, gdisp); } return; } @@ -1120,7 +1114,7 @@ bezier_select_button_press (Tool *tool, { paths_dialog_set_default_op (); /* recursive call */ - bezier_select_button_press (tool, bevent, gdisp_ptr); + bezier_select_button_press (tool, bevent, gdisp); } return; } @@ -1150,7 +1144,7 @@ bezier_select_button_press (Tool *tool, { paths_dialog_set_default_op (); /* recursive call */ - bezier_select_button_press (tool, bevent, gdisp_ptr); + bezier_select_button_press (tool, bevent, gdisp); } return; } @@ -1303,12 +1297,12 @@ bezier_select_button_press (Tool *tool, static void bezier_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; BezierSelect *bezier_sel; - gdisp = tool->gdisp_ptr; + gdisp = tool->gdisp; + bezier_sel = tool->private; bezier_sel->state &= ~(BEZIER_DRAG); @@ -1316,7 +1310,7 @@ bezier_select_button_release (Tool *tool, gdk_flush (); if (bezier_sel->closed) - bezier_convert (bezier_sel, tool->gdisp_ptr, SUBDIVIDE, FALSE); + bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, FALSE); /* Here ?*/ paths_newpoint_current (bezier_sel,gdisp); @@ -1381,11 +1375,10 @@ bez_copy_points (BezierSelect *tobez, static void bezier_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { static gint lastx, lasty; - GDisplay *gdisp; BezierSelect *bezier_sel; BezierPoint *anchor; BezierPoint *opposite_control; @@ -1396,7 +1389,6 @@ bezier_select_motion (Tool *tool, if (tool->state != ACTIVE) return; - gdisp = gdisp_ptr; bezier_sel = tool->private; if (!bezier_sel->cur_anchor || !bezier_sel->cur_control) @@ -1726,9 +1718,8 @@ bezier_point_on_curve (GDisplay *gdisp, static void bezier_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; BezierSelect *bezier_sel; gboolean on_curve; gboolean on_control_pnt; @@ -1736,11 +1727,9 @@ bezier_select_cursor_update (Tool *tool, gint halfwidth, dummy; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; - bezier_sel = tool->private; - if (gdisp != tool->gdisp_ptr || bezier_sel->core->draw_state == INVISIBLE) + if (gdisp != tool->gdisp || bezier_sel->core->draw_state == INVISIBLE) { gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_CURSOR, BEZIER_SELECT, @@ -1929,7 +1918,7 @@ bezier_select_cursor_update (Tool *tool, static void bezier_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { BezierSelect * bezier_sel; @@ -2016,10 +2005,10 @@ bezier_select_draw (Tool *tool) GDisplay *gdisp; BezierSelect *bezier_sel; - gdisp = tool->gdisp_ptr; + gdisp = tool->gdisp; bezier_sel = tool->private; - bezier_draw(gdisp,bezier_sel); + bezier_draw (gdisp, bezier_sel); } @@ -2447,17 +2436,17 @@ bezier_convert (BezierSelect *bezier_sel, gint subdivisions, gboolean antialias) { - PixelRegion maskPR; - BezierPoint * points; - BezierPoint * start_pt; - BezierPoint * next_curve; - GSList * list; - unsigned char *buf, *b; - int draw_type; - int * vals, val; - int start, end; - int x, x2, w; - int i, j; + PixelRegion maskPR; + BezierPoint *points; + BezierPoint *start_pt; + BezierPoint *next_curve; + GSList *list; + guchar *buf, *b; + gint draw_type; + gint *vals, val; + gint start, end; + gint x, x2, w; + gint i, j; if (!bezier_sel->closed) gimp_fatal_error ("bezier_convert(): tried to convert an open bezier curve"); @@ -2622,16 +2611,16 @@ bezier_convert_points (BezierSelect *bezier_sel, } static void -bezier_convert_line (GSList ** scanlines, - int x1, - int y1, - int x2, - int y2) +bezier_convert_line (GSList **scanlines, + gint x1, + gint y1, + gint x2, + gint y2) { - int dx, dy; - int error, inc; - int tmp; - double slope; + gint dx, dy; + gint error, inc; + gint tmp; + gdouble slope; if (y1 == y2) return; @@ -2739,11 +2728,11 @@ bezier_convert_line (GSList ** scanlines, } static GSList * -bezier_insert_in_list (GSList * list, - int x) +bezier_insert_in_list (GSList *list, + gint x) { - GSList * orig = list; - GSList * rest; + GSList *orig = list; + GSList *rest; if (!list) return g_slist_prepend (list, (void *) ((long) x)); @@ -2770,21 +2759,22 @@ bezier_insert_in_list (GSList * list, } gboolean -bezier_tool_selected() +bezier_tool_selected (void) { - return(active_tool && - active_tool->type == BEZIER_SELECT && - active_tool->state == ACTIVE); + return (active_tool && + active_tool->type == BEZIER_SELECT && + active_tool->state == ACTIVE); } void -bezier_paste_bezierselect_to_current(GDisplay *gdisp,BezierSelect *bsel) +bezier_paste_bezierselect_to_current (GDisplay *gdisp, + BezierSelect *bsel) { BezierPoint *pts; - gint i; - Tool * tool; - BezierPoint *bpnt = NULL; - int need_move = 0; + gint i; + Tool *tool; + BezierPoint *bpnt = NULL; + gint need_move = 0; /* g_print ("bezier_paste_bezierselect_to_current::\n"); */ /* printSel(bsel); */ @@ -2794,22 +2784,22 @@ bezier_paste_bezierselect_to_current(GDisplay *gdisp,BezierSelect *bsel) active_tool->type == BEZIER_SELECT && active_tool->state == ACTIVE) { - BezierSelect *bezier_sel = (BezierSelect*)active_tool->private; + BezierSelect *bezier_sel = (BezierSelect *) active_tool->private; if(bezier_sel) { - draw_core_stop ( curSel->core, active_tool ); + draw_core_stop (curSel->core, active_tool); bezier_select_reset (bezier_sel); } } gimp_context_set_tool (gimp_context_get_user (), BEZIER_SELECT); active_tool->paused_count = 0; - active_tool->gdisp_ptr = gdisp; - active_tool->drawable = gimp_image_active_drawable (gdisp->gimage); + active_tool->gdisp = gdisp; + active_tool->drawable = gimp_image_active_drawable (gdisp->gimage); tool = active_tool; - bezier_select_reset( curSel ); + bezier_select_reset (curSel); draw_core_start (curSel->core, gdisp->canvas->window, tool); @@ -2817,20 +2807,22 @@ bezier_paste_bezierselect_to_current(GDisplay *gdisp,BezierSelect *bsel) pts = (BezierPoint *) bsel->points; - for (i=0; i< bsel->num_points; i++) + for (i = 0; i < bsel->num_points; i++) { - if(need_move) + if (need_move) { - bezier_add_point( curSel, BEZIER_MOVE, pts->x, pts->y); + bezier_add_point (curSel, BEZIER_MOVE, pts->x, pts->y); need_move = 0; } else - bezier_add_point( curSel, pts->type, pts->x, pts->y); + { + bezier_add_point (curSel, pts->type, pts->x, pts->y); + } - if(bpnt == NULL) + if (bpnt == NULL) bpnt = curSel->last_point; - if(pts->next_curve) + if (pts->next_curve) { /* g_print ("bezier_paste_bezierselect_to_current:: Close last curve off \n"); */ curSel->last_point->next = bpnt; @@ -2847,21 +2839,21 @@ bezier_paste_bezierselect_to_current(GDisplay *gdisp,BezierSelect *bsel) } } - if ( bsel->closed ) + if (bsel->closed) { curSel->last_point->next = bpnt; bpnt->prev = curSel->last_point; curSel->cur_anchor = curSel->points; curSel->cur_control = curSel->points->next; curSel->closed = 1; - if (curTool->gdisp_ptr) - bezier_convert(curSel, curTool->gdisp_ptr, SUBDIVIDE, FALSE); + if (curTool->gdisp) + bezier_convert (curSel, curTool->gdisp, SUBDIVIDE, FALSE); } /* g_print ("After pasting...\n"); */ /* printSel(curSel); */ - if(bsel->num_points == 0) + if (bsel->num_points == 0) { curSel->state = BEZIER_START; curSel->draw = 0; @@ -2876,17 +2868,17 @@ bezier_paste_bezierselect_to_current(GDisplay *gdisp,BezierSelect *bsel) } static void -bezier_to_sel_internal(BezierSelect *bezier_sel, - Tool *tool, - GDisplay *gdisp, - gint op, - gint replace) +bezier_to_sel_internal (BezierSelect *bezier_sel, + Tool *tool, + GDisplay *gdisp, + gint op, + gint replace) { /* If we're antialiased, then recompute the * mask... */ if (bezier_options->antialias) - bezier_convert (bezier_sel, tool->gdisp_ptr, SUBDIVIDE, TRUE); + bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, TRUE); /* if (!bezier_options->extend) */ /* { */ @@ -3156,7 +3148,8 @@ test_add_point_on_segment (BezierSelect *bezier_sel, return FALSE; } -void bezier_select_mode(gint mode) +void +bezier_select_mode (gint mode) { ModeEdit = mode; } diff --git a/app/bezier_selectP.h b/app/bezier_selectP.h index 1e5368541e..87b76aec96 100644 --- a/app/bezier_selectP.h +++ b/app/bezier_selectP.h @@ -81,7 +81,7 @@ typedef void (* BezierPointsFunc) (BezierSelect *bezier_sel, gpointer data); /* Functions */ -gint bezier_select_load (void *gdisp_ptr, +gint bezier_select_load (GDisplay *gdisp, BezierPoint *points, gint n_points, gint closed); diff --git a/app/blend.c b/app/blend.c index ebb5915c43..7826c7681f 100644 --- a/app/blend.c +++ b/app/blend.c @@ -162,13 +162,24 @@ static guint blend_n_targets = (sizeof (blend_target_table) / /* local function prototypes */ -static void gradient_type_callback (GtkWidget *, gpointer); +static void gradient_type_callback (GtkWidget *widget, + gpointer data); -static void blend_button_press (Tool *, GdkEventButton *, gpointer); -static void blend_button_release (Tool *, GdkEventButton *, gpointer); -static void blend_motion (Tool *, GdkEventMotion *, gpointer); -static void blend_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void blend_control (Tool *, ToolAction, gpointer); +static void blend_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void blend_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void blend_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void blend_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void blend_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static void blend_options_drop_gradient (GtkWidget *, gradient_t *, gpointer); static void blend_options_drop_tool (GtkWidget *, ToolType, gpointer); @@ -432,12 +443,10 @@ blend_options_new (void) static void blend_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BlendTool * blend_tool; + BlendTool *blend_tool; - gdisp = (GDisplay *) gdisp_ptr; blend_tool = (BlendTool *) tool->private; switch (drawable_type (gimp_image_active_drawable (gdisp->gimage))) @@ -463,7 +472,7 @@ blend_button_press (Tool *tool, GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; /* initialize the statusbar display */ @@ -477,19 +486,17 @@ blend_button_press (Tool *tool, static void blend_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - GImage * gimage; - BlendTool * blend_tool; + GImage *gimage; + BlendTool *blend_tool; #ifdef BLEND_UI_CALLS_VIA_PDB - Argument *return_vals; + Argument *return_vals; int nreturn_vals; #else gimp_progress *progress; #endif - gdisp = (GDisplay *) gdisp_ptr; gimage = gdisp->gimage; blend_tool = (BlendTool *) tool->private; @@ -568,13 +575,11 @@ blend_button_release (Tool *tool, static void blend_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BlendTool * blend_tool; - gchar vector[STATUSBAR_SIZE]; + BlendTool *blend_tool; + gchar vector[STATUSBAR_SIZE]; - gdisp = (GDisplay *) gdisp_ptr; blend_tool = (BlendTool *) tool->private; /* undraw the current tool */ @@ -642,12 +647,8 @@ blend_motion (Tool *tool, static void blend_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - - gdisp = (GDisplay *) gdisp_ptr; - switch (drawable_type (gimp_image_active_drawable (gdisp->gimage))) { case INDEXED_GIMAGE: @@ -669,16 +670,16 @@ blend_cursor_update (Tool *tool, static void blend_draw (Tool *tool) { - GDisplay * gdisp; - BlendTool * blend_tool; - int tx1, ty1, tx2, ty2; + BlendTool *blend_tool; + gint tx1, ty1, tx2, ty2; - gdisp = (GDisplay *) tool->gdisp_ptr; blend_tool = (BlendTool *) tool->private; - gdisplay_transform_coords (gdisp, blend_tool->startx, blend_tool->starty, + gdisplay_transform_coords (tool->gdisp, + blend_tool->startx, blend_tool->starty, &tx1, &ty1, 1); - gdisplay_transform_coords (gdisp, blend_tool->endx, blend_tool->endy, + gdisplay_transform_coords (tool->gdisp, + blend_tool->endx, blend_tool->endy, &tx2, &ty2, 1); /* Draw start target */ @@ -705,7 +706,7 @@ blend_draw (Tool *tool) static void blend_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { BlendTool * blend_tool; diff --git a/app/blend.h b/app/blend.h index 3c25e17344..2838ce36b6 100644 --- a/app/blend.h +++ b/app/blend.h @@ -53,26 +53,26 @@ typedef enum REPEAT_LAST /*< skip >*/ } RepeatMode; -void blend (GimpImage *, - GimpDrawable *, - BlendMode, - gint, - GradientType, - gdouble, - gdouble, - RepeatMode, - gint, - gint, - gdouble, - gdouble, - gdouble, - gdouble, - gdouble, - progress_func_t, - gpointer); +void blend (GimpImage *gimage, + GimpDrawable *drawable, + BlendMode blend_mode, + gint paint_mode, + GradientType gradient_type, + gdouble opacity, + gdouble offset, + RepeatMode repeat, + gint supersample, + gint max_depth, + gdouble threshold, + gdouble startx, + gdouble starty, + gdouble endx, + gdouble endy, + progress_func_t progress_callback, + gpointer progress_data); Tool * tools_new_blend (void); -void tools_free_blend (Tool *tool); +void tools_free_blend (Tool *tool); #endif /* __BLEND_H__ */ diff --git a/app/boundary.h b/app/boundary.h index 8ccd3cf3f0..5fbebf1a80 100644 --- a/app/boundary.h +++ b/app/boundary.h @@ -20,9 +20,6 @@ #define __BOUNDARY_H__ -#include "paint_funcs.h" - - typedef enum { WithinBounds, diff --git a/app/brightness_contrast.c b/app/brightness_contrast.c index 20a16dcbc3..51bf5d9f4b 100644 --- a/app/brightness_contrast.c +++ b/app/brightness_contrast.c @@ -83,7 +83,9 @@ static BrightnessContrastDialog *brightness_contrast_dialog = NULL; /* brightness contrast action functions */ -static void brightness_contrast_control (Tool *, ToolAction, gpointer); +static void brightness_contrast_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static BrightnessContrastDialog * brightness_contrast_dialog_new (void); @@ -104,7 +106,7 @@ static void brightness_contrast_contrast_adjustment_update (GtkAdjustment *, static void brightness_contrast_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -393,13 +395,13 @@ brightness_contrast_ok_callback (GtkWidget *widget, active_tool->preserve = TRUE; if (!bcd->preview) - { - brightness_contrast_lut_setup (bcd->lut, bcd->brightness / 255.0, - bcd->contrast / 127.0, - gimp_drawable_bytes (bcd->drawable)); - image_map_apply (bcd->image_map, (ImageMapApplyFunc) gimp_lut_process_2, - (void *) bcd->lut); - } + { + brightness_contrast_lut_setup (bcd->lut, bcd->brightness / 255.0, + bcd->contrast / 127.0, + gimp_drawable_bytes (bcd->drawable)); + image_map_apply (bcd->image_map, (ImageMapApplyFunc) gimp_lut_process_2, + (void *) bcd->lut); + } if (bcd->image_map) image_map_commit (bcd->image_map); @@ -408,7 +410,7 @@ brightness_contrast_ok_callback (GtkWidget *widget, bcd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -432,7 +434,7 @@ brightness_contrast_cancel_callback (GtkWidget *widget, gdisplays_flush (); } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/brightness_contrast.h b/app/brightness_contrast.h index 41e909dc68..9cd9077287 100644 --- a/app/brightness_contrast.h +++ b/app/brightness_contrast.h @@ -20,12 +20,12 @@ #define __BRIGHTNESS_CONTRAST_H__ -Tool * tools_new_brightness_contrast (void); -void tools_free_brightness_contrast (Tool *tool); +Tool * tools_new_brightness_contrast (void); +void tools_free_brightness_contrast (Tool *tool); void brightness_contrast_dialog_hide (void); -void brightness_contrast_initialize (GDisplay *gdisp); +void brightness_contrast_initialize (GDisplay *gdisp); #endif /* __BRIGHTNESS_CONTRAST_H__ */ diff --git a/app/bucket_fill.c b/app/bucket_fill.c index d227994b71..3a32810872 100644 --- a/app/bucket_fill.c +++ b/app/bucket_fill.c @@ -85,14 +85,30 @@ static BucketOptions *bucket_options = NULL; /* local function prototypes */ -static void bucket_fill_button_press (Tool *, GdkEventButton *, gpointer); -static void bucket_fill_button_release (Tool *, GdkEventButton *, gpointer); -static void bucket_fill_cursor_update (Tool *, GdkEventMotion *, gpointer); +static void bucket_fill_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void bucket_fill_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void bucket_fill_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); -static void bucket_fill_line_color (guchar *, guchar *, guchar *, - gboolean, gint, gint); -static void bucket_fill_line_pattern (guchar *, guchar *, TempBuf *, - gboolean, gint, gint, gint, gint); +static void bucket_fill_line_color (guchar *, + guchar *, + guchar *, + gboolean , + gint , + gint ); +static void bucket_fill_line_pattern (guchar *, + guchar *, + TempBuf *, + gboolean , + gint , + gint , + gint , + gint ); /* functions */ @@ -123,7 +139,7 @@ bucket_options_new (void) GtkWidget *frame; /* the new bucket fill tool options structure */ - options = (BucketOptions *) g_malloc (sizeof (BucketOptions)); + options = g_new (BucketOptions, 1); paint_options_init ((PaintOptions *) options, BUCKET_FILL, bucket_options_reset); @@ -194,13 +210,11 @@ bucket_options_new (void) static void bucket_fill_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BucketTool * bucket_tool; - gboolean use_offsets; + BucketTool *bucket_tool; + gboolean use_offsets; - gdisp = (GDisplay *) gdisp_ptr; bucket_tool = (BucketTool *) tool->private; use_offsets = (bucket_options->sample_merged) ? FALSE : TRUE; @@ -217,21 +231,19 @@ bucket_fill_button_press (Tool *tool, NULL, NULL, bevent->time); /* Make the tool active and set the gdisplay which owns it */ - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; } static void bucket_fill_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BucketTool * bucket_tool; - Argument *return_vals; - gint nreturn_vals; + BucketTool *bucket_tool; + Argument *return_vals; + gint nreturn_vals; - gdisp = (GDisplay *) gdisp_ptr; bucket_tool = (BucketTool *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -267,16 +279,13 @@ bucket_fill_button_release (Tool *tool, static void bucket_fill_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - CursorModifier cmodifier = CURSOR_MODIFIER_NONE; - gint x, y; - gint off_x, off_y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + CursorModifier cmodifier = CURSOR_MODIFIER_NONE; + gint x, y; + gint off_x, off_y; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -321,7 +330,7 @@ bucket_fill_cursor_update (Tool *tool, static void bucket_fill_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -359,14 +368,14 @@ bucket_fill (GimpImage *gimage, TileManager *buf_tiles; PixelRegion bufPR, maskPR; Channel *mask = NULL; - gint bytes; - gboolean has_alpha; - gint x1, y1, x2, y2; - guchar col [MAX_CHANNELS]; - guchar *d1, *d2; - GPattern *pattern; - TempBuf *pat_buf; - gboolean new_buf = FALSE; + gint bytes; + gboolean has_alpha; + gint x1, y1, x2, y2; + guchar col [MAX_CHANNELS]; + guchar *d1, *d2; + GPattern *pattern; + TempBuf *pat_buf; + gboolean new_buf = FALSE; pat_buf = NULL; @@ -433,7 +442,7 @@ bucket_fill (GimpImage *gimage, /* make sure we handle the mask correctly if it was sample-merged */ if (sample_merged) { - int off_x, off_y; + gint off_x, off_y; /* Limit the channel bounds to the drawable's extents */ drawable_offsets (drawable, &off_x, &off_y); @@ -533,8 +542,8 @@ bucket_fill_line_pattern (guchar *buf, gint width) { guchar *pat, *p; - gint alpha, b; - gint i; + gint alpha, b; + gint i; /* Get a pointer to the appropriate scanline of the pattern buffer */ pat = temp_buf_data (pattern) + @@ -571,8 +580,8 @@ bucket_fill_region (BucketFillMode fill_mode, gboolean has_alpha) { guchar *s, *m; - gint y; - void *pr; + gint y; + void *pr; for (pr = pixel_regions_register (2, bufPR, maskPR); pr != NULL; @@ -612,8 +621,8 @@ bucket_fill_region (BucketFillMode fill_mode, Tool * tools_new_bucket_fill (void) { - Tool * tool; - BucketTool * private; + Tool *tool; + BucketTool *private; /* The tool options */ if (! bucket_options) @@ -630,7 +639,7 @@ tools_new_bucket_fill (void) tool->scroll_lock = TRUE; /* Disallow scrolling */ - tool->private = (void *) private; + tool->private = (gpointer) private; tool->button_press_func = bucket_fill_button_press; tool->button_release_func = bucket_fill_button_release; @@ -643,7 +652,7 @@ tools_new_bucket_fill (void) void tools_free_bucket_fill (Tool *tool) { - BucketTool * bucket_tool; + BucketTool *bucket_tool; bucket_tool = (BucketTool *) tool->private; diff --git a/app/by_color_select.c b/app/by_color_select.c index 45210650c9..b8bd885d7a 100644 --- a/app/by_color_select.c +++ b/app/by_color_select.c @@ -82,6 +82,7 @@ struct _ByColorDialog GImage *gimage; /* gimage which is currently under examination */ }; + /* the by color selection tool options */ static SelectionOptions * by_color_options = NULL; @@ -93,43 +94,71 @@ static GtkTargetEntry by_color_select_targets[] = { GIMP_TARGET_COLOR }; -static guint n_by_color_select_targets = (sizeof (by_color_select_targets) / - sizeof (by_color_select_targets[0])); +static guint n_by_color_select_targets = (sizeof (by_color_select_targets) / + sizeof (by_color_select_targets[0])); -static void by_color_select_color_drop (GtkWidget *widget, - guchar r, - guchar g, - guchar b, - gpointer data); + +static void by_color_select_color_drop (GtkWidget *widget, + guchar r, + guchar g, + guchar b, + gpointer data); /* by_color select action functions */ -static void by_color_select_button_press (Tool *, GdkEventButton *, gpointer); -static void by_color_select_button_release (Tool *, GdkEventButton *, gpointer); -static void by_color_select_modifier_update (Tool *, GdkEventKey * , gpointer); -static void by_color_select_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void by_color_select_oper_update (Tool *, GdkEventMotion *, gpointer); -static void by_color_select_control (Tool *, ToolAction, gpointer); +static void by_color_select_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void by_color_select_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void by_color_select_modifier_update (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void by_color_select_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void by_color_select_oper_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void by_color_select_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); -static ByColorDialog * by_color_select_dialog_new (void); +static ByColorDialog * by_color_select_dialog_new (void); -static void by_color_select_render (ByColorDialog *, GImage *); -static void by_color_select_draw (ByColorDialog *, GImage *); -static gint by_color_select_preview_events (GtkWidget *, +static void by_color_select_render (ByColorDialog *, + GImage *); +static void by_color_select_draw (ByColorDialog *, + GImage *); +static gint by_color_select_preview_events (GtkWidget *, GdkEventButton *, - ByColorDialog *); -static void by_color_select_invert_callback (GtkWidget *, gpointer); -static void by_color_select_select_all_callback (GtkWidget *, gpointer); -static void by_color_select_select_none_callback (GtkWidget *, gpointer); -static void by_color_select_reset_callback (GtkWidget *, gpointer); -static void by_color_select_close_callback (GtkWidget *, gpointer); -static void by_color_select_preview_button_press (ByColorDialog *, + ByColorDialog *); +static void by_color_select_invert_callback (GtkWidget *, + gpointer ); +static void by_color_select_select_all_callback (GtkWidget *, + gpointer ); +static void by_color_select_select_none_callback (GtkWidget *, + gpointer ); +static void by_color_select_reset_callback (GtkWidget *, + gpointer ); +static void by_color_select_close_callback (GtkWidget *, + gpointer ); +static void by_color_select_preview_button_press (ByColorDialog *, GdkEventButton *); -static gint is_pixel_sufficiently_different (guchar *, guchar *, - gint, gint, gint, gint); -static Channel * by_color_select_color (GImage *, GimpDrawable *, - guchar *, gint, gint, gint); +static gint is_pixel_sufficiently_different (guchar *, + guchar *, + gint , + gint , + gint , + gint ); +static Channel * by_color_select_color (GImage *, + GimpDrawable *, + guchar *, + gint , + gint , + gint ); /* by_color selection machinery */ @@ -196,18 +225,18 @@ by_color_select_color (GImage *gimage, * use the same antialiasing scheme as in fuzzy_select. Modify the gimage's * mask to reflect the additional selection */ - Channel *mask; - PixelRegion imagePR, maskPR; - guchar *image_data; - guchar *mask_data; - guchar *idata, *mdata; - guchar rgb[MAX_CHANNELS]; - gint has_alpha, indexed; - gint width, height; - gint bytes, color_bytes, alpha; - gint i, j; - void * pr; - gint d_type; + Channel *mask; + PixelRegion imagePR, maskPR; + guchar *image_data; + guchar *mask_data; + guchar *idata, *mdata; + guchar rgb[MAX_CHANNELS]; + gint has_alpha, indexed; + gint width, height; + gint bytes, color_bytes, alpha; + gint i, j; + gpointer pr; + gint d_type; /* Get the image information */ if (sample_merged) @@ -342,12 +371,10 @@ by_color_select (GImage *gimage, static void by_color_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; ByColorSelect *by_color_sel; - gdisp = (GDisplay *) gdisp_ptr; by_color_sel = (ByColorSelect *) tool->private; tool->drawable = gimp_image_active_drawable (gdisp->gimage); @@ -359,7 +386,7 @@ by_color_select_button_press (Tool *tool, by_color_sel->y = bevent->y; tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; /* Make sure the "by color" select dialog is visible */ if (! GTK_WIDGET_VISIBLE (by_color_dialog->shell)) @@ -393,16 +420,14 @@ by_color_select_button_press (Tool *tool, static void by_color_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_color_sel; - GDisplay *gdisp; gint x, y; GimpDrawable *drawable; guchar *color; gint use_offsets; - gdisp = (GDisplay *) gdisp_ptr; by_color_sel = (ByColorSelect *) tool->private; drawable = gimp_image_active_drawable (gdisp->gimage); @@ -456,14 +481,12 @@ by_color_select_button_release (Tool *tool, static void by_color_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_col_sel; - GDisplay *gdisp; Layer *layer; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; by_col_sel = (ByColorSelect *) tool->private; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, @@ -551,7 +574,7 @@ by_color_select_update_op_state (ByColorSelect *by_col_sel, static void by_color_select_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_col_sel; gint state; @@ -584,26 +607,25 @@ by_color_select_modifier_update (Tool *tool, break; } - by_color_select_update_op_state (by_col_sel, state, (GDisplay *) gdisp_ptr); + by_color_select_update_op_state (by_col_sel, state, gdisp); } static void by_color_select_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_col_sel; by_col_sel = (ByColorSelect *) tool->private; - by_color_select_update_op_state (by_col_sel, mevent->state, - (GDisplay *) gdisp_ptr); + by_color_select_update_op_state (by_col_sel, mevent->state, gdisp); } static void by_color_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { diff --git a/app/clone.c b/app/clone.c index 7c16c6f684..320e2c7725 100644 --- a/app/clone.c +++ b/app/clone.c @@ -79,37 +79,59 @@ struct _CloneOptions }; +/* forward function declarations */ + +static gpointer clone_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void clone_draw (Tool *tool); +static void clone_motion (PaintCore *paint_core, + GimpDrawable *drawable, + GimpDrawable *src_drawable, + PaintPressureOptions *pressure_options, + CloneType type, + gint offset_x, + gint offset_y); +static void clone_line_image (GImage *dest, + GImage *src, + GimpDrawable *d_drawable, + GimpDrawable *s_drawable, + guchar *s, + guchar *d, + gint has_alpha, + gint src_bytes, + gint dest_bytes, + gint width); +static void clone_line_pattern (GImage *dest, + GimpDrawable *drawable, + GPattern *pattern, + guchar *d, + gint x, + gint y, + gint bytes, + gint width); + + /* the clone tool options */ static CloneOptions *clone_options = NULL; /* local variables */ -static int src_x = 0; /* */ -static int src_y = 0; /* position of clone src */ -static int dest_x = 0; /* */ -static int dest_y = 0; /* position of clone src */ -static int offset_x = 0; /* */ -static int offset_y = 0; /* offset for cloning */ -static int first = TRUE; -static int trans_tx, trans_ty; /* transformed target */ +static gint src_x = 0; /* */ +static gint src_y = 0; /* position of clone src */ +static gint dest_x = 0; /* */ +static gint dest_y = 0; /* position of clone src */ +static gint offset_x = 0; /* */ +static gint offset_y = 0; /* offset for cloning */ +static gint first = TRUE; +static gint trans_tx, trans_ty; /* transformed target */ static GDisplay *the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable *src_drawable_ = NULL; /* source drawable */ static GimpDrawable *non_gui_src_drawable; -static int non_gui_offset_x; -static int non_gui_offset_y; +static gint non_gui_offset_x; +static gint non_gui_offset_y; static CloneType non_gui_type; -/* forward function declarations */ - -static void clone_draw (Tool *); -static void clone_motion (PaintCore *, GimpDrawable *, GimpDrawable *, - PaintPressureOptions *, CloneType, int, int); -static void clone_line_image (GImage *, GImage *, GimpDrawable *, - GimpDrawable *, unsigned char *, - unsigned char *, int, int, int, int); -static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, - unsigned char *, int, int, int, int); - /* functions */ @@ -128,8 +150,8 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *frame; /* the new clone tool options structure */ options = g_new (CloneOptions, 1); @@ -202,23 +224,24 @@ clone_set_src_drawable (GimpDrawable *drawable) } } -void * +static gpointer clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - gint state) + PaintState state) { - GDisplay * gdisp; - GDisplay * src_gdisp; - int x1, y1, x2, y2; - static int orig_src_x, orig_src_y; + GDisplay *gdisp; + GDisplay *src_gdisp; + gint x1, y1, x2, y2; + static gint orig_src_x, orig_src_y; - gdisp = (GDisplay *) active_tool->gdisp_ptr; + gdisp = (GDisplay *) active_tool->gdisp; switch (state) { case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; @@ -320,14 +343,11 @@ clone_paint_func (PaintCore *paint_core, void clone_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + gint x, y; gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y, &x, &y, TRUE, FALSE); @@ -661,10 +681,10 @@ clone_line_pattern (GImage *dest, } } -static void * -clone_non_gui_paint_func (PaintCore *paint_core, +static gpointer +clone_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { clone_motion (paint_core, drawable, non_gui_src_drawable, &non_gui_pressure_options, @@ -675,16 +695,16 @@ clone_non_gui_paint_func (PaintCore *paint_core, gboolean clone_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { GimpDrawable *src_drawable = NULL; CloneType clone_type = CLONE_DEFAULT_TYPE; - double local_src_x = 0.0; - double local_src_y = 0.0; + gdouble local_src_x = 0.0; + gdouble local_src_y = 0.0; CloneOptions *options = clone_options; - - if(options) + + if (options) { clone_type = options->type; src_drawable = src_drawable_; @@ -692,23 +712,23 @@ clone_non_gui_default (GimpDrawable *drawable, local_src_y = src_y; } - return clone_non_gui(drawable, - src_drawable, - clone_type, - local_src_x,local_src_y, - num_strokes,stroke_array); + return clone_non_gui (drawable, + src_drawable, + clone_type, + local_src_x,local_src_y, + num_strokes, stroke_array); } gboolean clone_non_gui (GimpDrawable *drawable, GimpDrawable *src_drawable, CloneType clone_type, - double src_x, - double src_y, - int num_strokes, - double *stroke_array) + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) diff --git a/app/clone.h b/app/clone.h index 0433bc488e..fcc2f1d247 100644 --- a/app/clone.h +++ b/app/clone.h @@ -26,21 +26,19 @@ typedef enum PATTERN_CLONE } CloneType; -void * clone_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean clone_non_gui (GimpDrawable *, - GimpDrawable *, - CloneType, - gdouble, - gdouble, - gint, - gdouble *); -gboolean clone_non_gui_default (GimpDrawable *, - gint, - gdouble *); + +gboolean clone_non_gui (GimpDrawable *drawable, + GimpDrawable *src_drawable, + CloneType clone_type, + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array); +gboolean clone_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_clone (void); -void tools_free_clone (Tool *); +void tools_free_clone (Tool *tool); #endif /* __CLONE_H__ */ diff --git a/app/color_balance.c b/app/color_balance.c index b74246cfdc..87b62926bc 100644 --- a/app/color_balance.c +++ b/app/color_balance.c @@ -62,21 +62,33 @@ static ColorBalanceDialog *color_balance_dialog = NULL; /* color balance action functions */ -static void color_balance_control (Tool *, ToolAction, gpointer); +static void color_balance_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static ColorBalanceDialog * color_balance_dialog_new (void); -static void color_balance_update (ColorBalanceDialog *, int); -static void color_balance_preview (ColorBalanceDialog *); -static void color_balance_reset_callback (GtkWidget *, gpointer); -static void color_balance_ok_callback (GtkWidget *, gpointer); -static void color_balance_cancel_callback (GtkWidget *, gpointer); -static void color_balance_range_callback (GtkWidget *, gpointer); -static void color_balance_preserve_update (GtkWidget *, gpointer); -static void color_balance_preview_update (GtkWidget *, gpointer); -static void color_balance_cr_adjustment_update (GtkAdjustment *, gpointer); -static void color_balance_mg_adjustment_update (GtkAdjustment *, gpointer); -static void color_balance_yb_adjustment_update (GtkAdjustment *, gpointer); +static void color_balance_update (ColorBalanceDialog *cbd, + gint ); +static void color_balance_preview (ColorBalanceDialog *cbd); +static void color_balance_reset_callback (GtkWidget *widget, + gpointer data); +static void color_balance_ok_callback (GtkWidget *widget, + gpointer data); +static void color_balance_cancel_callback (GtkWidget *widget, + gpointer data); +static void color_balance_range_callback (GtkWidget *widget, + gpointer data); +static void color_balance_preserve_update (GtkWidget *widget, + gpointer data); +static void color_balance_preview_update (GtkWidget *widget, + gpointer data); +static void color_balance_cr_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void color_balance_mg_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void color_balance_yb_adjustment_update (GtkAdjustment *adj, + gpointer data); /* color balance machinery */ @@ -86,12 +98,12 @@ color_balance (PixelRegion *srcPR, void *data) { ColorBalanceDialog *cbd; - guchar *src, *s; - guchar *dest, *d; - gint alpha; - gint r, g, b; - gint r_n, g_n, b_n; - gint w, h; + guchar *src, *s; + guchar *dest, *d; + gboolean alpha; + gint r, g, b; + gint r_n, g_n, b_n; + gint w, h; cbd = (ColorBalanceDialog *) data; @@ -143,7 +155,7 @@ color_balance (PixelRegion *srcPR, static void color_balance_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { ColorBalance * color_bal; @@ -599,7 +611,7 @@ color_balance_ok_callback (GtkWidget *widget, cbd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -623,7 +635,7 @@ color_balance_cancel_callback (GtkWidget *widget, cbd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/color_picker.c b/app/color_picker.c index 17fda5b902..1bd0efe8d9 100644 --- a/app/color_picker.c +++ b/app/color_picker.c @@ -100,24 +100,36 @@ static gchar hex_buf [MAX_INFO_BUF]; /* local function prototypes */ -static void color_picker_button_press (Tool *, GdkEventButton *, gpointer); -static void color_picker_button_release (Tool *, GdkEventButton *, gpointer); -static void color_picker_motion (Tool *, GdkEventMotion *, gpointer); -static void color_picker_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void color_picker_control (Tool *, ToolAction, gpointer); +static void color_picker_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void color_picker_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void color_picker_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void color_picker_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void color_picker_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); -static void color_picker_info_window_close_callback (GtkWidget *, gpointer); -static void color_picker_info_update (Tool *, gboolean); +static void color_picker_info_window_close_callback (GtkWidget *widget, + gpointer data); +static void color_picker_info_update (Tool *tool, + gboolean valid); -static gboolean pick_color_do (GimpImage *gimage, - GimpDrawable *drawable, - gint x, - gint y, - gboolean sample_merged, - gboolean sample_average, - gdouble average_radius, - gboolean update_active, - gint final); +static gboolean pick_color_do (GimpImage *gimage, + GimpDrawable *drawable, + gint x, + gint y, + gboolean sample_merged, + gboolean sample_average, + gdouble average_radius, + gboolean update_active, + gint final); /* functions */ @@ -235,19 +247,17 @@ color_picker_options_new (void) static void color_picker_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; ColorPickerTool *cp_tool; - gint x, y; + gint x, y; - gdisp = (GDisplay *) gdisp_ptr; cp_tool = (ColorPickerTool *) tool->private; /* Make the tool active and set it's gdisplay & drawable */ - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->drawable = gimp_image_active_drawable (gdisp->gimage); - tool->state = ACTIVE; + tool->state = ACTIVE; /* create the info dialog if it doesn't exist */ if (! color_picker_info) @@ -356,15 +366,14 @@ color_picker_button_press (Tool *tool, static void color_picker_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; ColorPickerTool *cp_tool; - gint x, y; + gint x, y; gdk_pointer_ungrab (bevent->time); gdk_flush (); - gdisp = (GDisplay *) gdisp_ptr; + cp_tool = (ColorPickerTool *) tool->private; /* First, transform the coordinates to gimp image space */ @@ -386,13 +395,11 @@ color_picker_button_release (Tool *tool, static void color_picker_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; ColorPickerTool *cp_tool; - gint x, y; + gint x, y; - gdisp = (GDisplay *) gdisp_ptr; cp_tool = (ColorPickerTool *) tool->private; /* undraw the current tool */ @@ -421,13 +428,10 @@ color_picker_motion (Tool *tool, static void color_picker_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; - gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -446,9 +450,9 @@ color_picker_cursor_update (Tool *tool, static void color_picker_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { - ColorPickerTool * cp_tool; + ColorPickerTool *cp_tool; cp_tool = (ColorPickerTool *) tool->private; @@ -594,25 +598,23 @@ pick_color (GimpImage *gimage, static void colorpicker_draw (Tool *tool) { - GDisplay * gdisp; - ColorPickerTool * cp_tool; - gint tx, ty; - gint radiusx, radiusy; - gint cx, cy; + ColorPickerTool *cp_tool; + gint tx, ty; + gint radiusx, radiusy; + gint cx, cy; if (! color_picker_options->sample_average) return; - gdisp = (GDisplay *) tool->gdisp_ptr; cp_tool = (ColorPickerTool *) tool->private; - gdisplay_transform_coords (gdisp, cp_tool->centerx, cp_tool->centery, + gdisplay_transform_coords (tool->gdisp, cp_tool->centerx, cp_tool->centery, &tx, &ty, TRUE); - radiusx = SCALEX (gdisp, color_picker_options->average_radius); - radiusy = SCALEY (gdisp, color_picker_options->average_radius); - cx = SCALEX (gdisp, 1); - cy = SCALEY (gdisp, 1); + radiusx = SCALEX (tool->gdisp, color_picker_options->average_radius); + radiusy = SCALEY (tool->gdisp, color_picker_options->average_radius); + cx = SCALEX (tool->gdisp, 1); + cy = SCALEY (tool->gdisp, 1); /* Draw the circle around the collecting area */ gdk_draw_rectangle (cp_tool->core->win, cp_tool->core->gc, 0, diff --git a/app/commands.c b/app/commands.c index 01f3a86d85..f534a7c2bd 100644 --- a/app/commands.c +++ b/app/commands.c @@ -1080,11 +1080,12 @@ tools_select_cmd_callback (GtkWidget *widget, gpointer callback_data, guint callback_action) { - ToolType tool_type; - GDisplay *gdisp; - gdisp = gdisplay_active (); + ToolType tool_type; + GDisplay *gdisp; tool_type = (ToolType) callback_action; + gdisp = gdisplay_active (); + gimp_context_set_tool (gimp_context_get_user (), tool_type); @@ -1101,12 +1102,12 @@ tools_select_cmd_callback (GtkWidget *widget, active_tool->drawable = gimp_image_active_drawable (gdisp->gimage); } - /* setting the gdisp_ptr here is a HACK to allow the tools' + /* setting the tool->gdisp here is a HACK to allow the tools' * dialog windows being hidden if the tool was selected from * a tear-off-menu and there was no mouse click in the display * before deleting it */ - active_tool->gdisp_ptr = gdisp; + active_tool->gdisp = gdisp; } /***** Filters *****/ diff --git a/app/convolve.c b/app/convolve.c index bcf8bd2580..e8df499d63 100644 --- a/app/convolve.c +++ b/app/convolve.c @@ -82,6 +82,28 @@ struct _ConvolveOptions }; +/* forward function declarations */ +static void calculate_matrix (ConvolveType type, + gdouble rate); +static void integer_matrix (gfloat *source, + gint *dest, + gint size); +static void copy_matrix (gfloat *src, + gfloat *dest, + gint size); +static gint sum_matrix (gint *matrix, + gint size); + +static gpointer convolve_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void convolve_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + ConvolveType type, + gdouble rate); + + /* the convolve tool options */ static ConvolveOptions * convolve_options = NULL; @@ -121,19 +143,8 @@ static gfloat sharpen_matrix [25] = }; -/* forward function declarations */ -static void calculate_matrix (ConvolveType, double); -static void integer_matrix (float *, int *, int); -static void copy_matrix (float *, float *, int); -static int sum_matrix (int *, int); - -static void convolve_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, - ConvolveType, double); - /* functions */ - static void convolve_options_reset (void) { @@ -205,10 +216,10 @@ convolve_options_new (void) return options; } -void * +static gpointer convolve_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -217,6 +228,9 @@ convolve_paint_func (PaintCore *paint_core, convolve_options->paint_options.pressure_options, convolve_options->type, convolve_options->rate); break; + + default: + break; } return NULL; @@ -225,7 +239,7 @@ convolve_paint_func (PaintCore *paint_core, static void convolve_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -282,18 +296,18 @@ convolve_modifier_key_func (Tool *tool, static void convolve_cursor_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE); - paint_core_cursor_update (tool, mevent, gdisp_ptr); + paint_core_cursor_update (tool, mevent, gdisp); } Tool * tools_new_convolve (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! convolve_options) @@ -570,34 +584,34 @@ calculate_matrix (ConvolveType type, } static void -integer_matrix (float *source, - int *dest, - int size) +integer_matrix (gfloat *source, + gint *dest, + gint size) { - int i; + gint i; #define PRECISION 10000 for (i = 0; i < size*size; i++) - *dest++ = (int) (*source ++ * PRECISION); + *dest++ = (gint) (*source ++ * PRECISION); } static void -copy_matrix (float *src, - float *dest, - int size) +copy_matrix (gfloat *src, + gfloat *dest, + gint size) { - int i; + gint i; for (i = 0; i < size*size; i++) *dest++ = *src++; } static int -sum_matrix (int *matrix, - int size) +sum_matrix (gint *matrix, + gint size) { - int sum = 0; + gint sum = 0; size *= size; @@ -608,10 +622,10 @@ sum_matrix (int *matrix, } -static void * -convolve_non_gui_paint_func (PaintCore *paint_core, +static gpointer +convolve_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { convolve_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_type, non_gui_rate); @@ -621,11 +635,11 @@ convolve_non_gui_paint_func (PaintCore *paint_core, gboolean convolve_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - double rate = DEFAULT_CONVOLVE_RATE; - ConvolveType type = DEFAULT_CONVOLVE_TYPE; + gdouble rate = DEFAULT_CONVOLVE_RATE; + ConvolveType type = DEFAULT_CONVOLVE_TYPE; ConvolveOptions *options = convolve_options; if (options) @@ -641,17 +655,17 @@ gboolean convolve_non_gui (GimpDrawable *drawable, double rate, ConvolveType type, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) { /* Set the paint core's paint func */ non_gui_paint_core.paint_func = convolve_non_gui_paint_func; - + non_gui_type = type; non_gui_rate = rate; @@ -678,6 +692,6 @@ convolve_non_gui (GimpDrawable *drawable, paint_core_cleanup (); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/convolve.h b/app/convolve.h index 3a6058ef5c..1e07c92d36 100644 --- a/app/convolve.h +++ b/app/convolve.h @@ -28,19 +28,17 @@ typedef enum } ConvolveType; -void * convolve_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean convolve_non_gui (GimpDrawable *, - gdouble , - ConvolveType , - gint , - gdouble *); -gboolean convolve_non_gui_default (GimpDrawable *, - gint , - gdouble *); -Tool * tools_new_convolve (void ); -void tools_free_convolve (Tool *); +gboolean convolve_non_gui (GimpDrawable *drawable, + gdouble rate, + ConvolveType type, + gint num_strokes, + gdouble *stroke_array); +gboolean convolve_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); + +Tool * tools_new_convolve (void); +void tools_free_convolve (Tool *tool); #endif /* __CONVOLVE_H__ */ diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c index ebb5915c43..7826c7681f 100644 --- a/app/core/gimpdrawable-blend.c +++ b/app/core/gimpdrawable-blend.c @@ -162,13 +162,24 @@ static guint blend_n_targets = (sizeof (blend_target_table) / /* local function prototypes */ -static void gradient_type_callback (GtkWidget *, gpointer); +static void gradient_type_callback (GtkWidget *widget, + gpointer data); -static void blend_button_press (Tool *, GdkEventButton *, gpointer); -static void blend_button_release (Tool *, GdkEventButton *, gpointer); -static void blend_motion (Tool *, GdkEventMotion *, gpointer); -static void blend_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void blend_control (Tool *, ToolAction, gpointer); +static void blend_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void blend_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void blend_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void blend_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void blend_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static void blend_options_drop_gradient (GtkWidget *, gradient_t *, gpointer); static void blend_options_drop_tool (GtkWidget *, ToolType, gpointer); @@ -432,12 +443,10 @@ blend_options_new (void) static void blend_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BlendTool * blend_tool; + BlendTool *blend_tool; - gdisp = (GDisplay *) gdisp_ptr; blend_tool = (BlendTool *) tool->private; switch (drawable_type (gimp_image_active_drawable (gdisp->gimage))) @@ -463,7 +472,7 @@ blend_button_press (Tool *tool, GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; /* initialize the statusbar display */ @@ -477,19 +486,17 @@ blend_button_press (Tool *tool, static void blend_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - GImage * gimage; - BlendTool * blend_tool; + GImage *gimage; + BlendTool *blend_tool; #ifdef BLEND_UI_CALLS_VIA_PDB - Argument *return_vals; + Argument *return_vals; int nreturn_vals; #else gimp_progress *progress; #endif - gdisp = (GDisplay *) gdisp_ptr; gimage = gdisp->gimage; blend_tool = (BlendTool *) tool->private; @@ -568,13 +575,11 @@ blend_button_release (Tool *tool, static void blend_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BlendTool * blend_tool; - gchar vector[STATUSBAR_SIZE]; + BlendTool *blend_tool; + gchar vector[STATUSBAR_SIZE]; - gdisp = (GDisplay *) gdisp_ptr; blend_tool = (BlendTool *) tool->private; /* undraw the current tool */ @@ -642,12 +647,8 @@ blend_motion (Tool *tool, static void blend_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - - gdisp = (GDisplay *) gdisp_ptr; - switch (drawable_type (gimp_image_active_drawable (gdisp->gimage))) { case INDEXED_GIMAGE: @@ -669,16 +670,16 @@ blend_cursor_update (Tool *tool, static void blend_draw (Tool *tool) { - GDisplay * gdisp; - BlendTool * blend_tool; - int tx1, ty1, tx2, ty2; + BlendTool *blend_tool; + gint tx1, ty1, tx2, ty2; - gdisp = (GDisplay *) tool->gdisp_ptr; blend_tool = (BlendTool *) tool->private; - gdisplay_transform_coords (gdisp, blend_tool->startx, blend_tool->starty, + gdisplay_transform_coords (tool->gdisp, + blend_tool->startx, blend_tool->starty, &tx1, &ty1, 1); - gdisplay_transform_coords (gdisp, blend_tool->endx, blend_tool->endy, + gdisplay_transform_coords (tool->gdisp, + blend_tool->endx, blend_tool->endy, &tx2, &ty2, 1); /* Draw start target */ @@ -705,7 +706,7 @@ blend_draw (Tool *tool) static void blend_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { BlendTool * blend_tool; diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c index 7d6df05d34..72a9c1e6c7 100644 --- a/app/core/gimpimagemap.c +++ b/app/core/gimpimagemap.c @@ -107,16 +107,16 @@ image_map_do (gpointer data) } ImageMap -image_map_create (void *gdisp_ptr, +image_map_create (GDisplay *gdisp, GimpDrawable *drawable) { _ImageMap *_image_map; _image_map = g_new (_ImageMap, 1); - _image_map->gdisp = (GDisplay *) gdisp_ptr; - _image_map->drawable = drawable; + _image_map->gdisp = gdisp; + _image_map->drawable = drawable; _image_map->undo_tiles = NULL; - _image_map->state = WAITING; + _image_map->state = WAITING; /* Interactive tools based on image_map disable the undo stack */ /* to avert any unintented undo interaction through the UI */ diff --git a/app/core/gimpimagemap.h b/app/core/gimpimagemap.h index 8af03f09a8..d868cd2ff3 100644 --- a/app/core/gimpimagemap.h +++ b/app/core/gimpimagemap.h @@ -26,8 +26,8 @@ * MUST be followed with an image_map_commit or an image_map_abort call * The image map is no longer valid after a call to commit or abort. */ -ImageMap image_map_create (void *, - GimpDrawable *); +ImageMap image_map_create (GDisplay *gdisp, + GimpDrawable *drawable); void image_map_apply (ImageMap, ImageMapApplyFunc, void *); diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 1f09287c71..2a14c8b7f4 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -375,10 +375,10 @@ gdisplay_delete (GDisplay *gdisp) /* clear out the pointer to this gdisp from the active tool */ if (active_tool && - active_tool->gdisp_ptr == gdisp) + active_tool->gdisp == gdisp) { active_tool->drawable = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; } /* free the selection structure */ diff --git a/app/crop.c b/app/crop.c index a792147af9..5f78ff5925 100644 --- a/app/crop.c +++ b/app/crop.c @@ -121,25 +121,49 @@ static GtkWidget *size_sizeentry; /* Crop type functions */ -static void crop_button_press (Tool *, GdkEventButton *, gpointer); -static void crop_button_release (Tool *, GdkEventButton *, gpointer); -static void crop_motion (Tool *, GdkEventMotion *, gpointer); -static void crop_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void crop_control (Tool *, ToolAction, gpointer); -static void crop_arrow_keys_func (Tool *, GdkEventKey *, gpointer); -static void crop_modifier_key_func (Tool *, GdkEventKey *, gpointer); +static void crop_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void crop_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void crop_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void crop_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void crop_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); +static void crop_arrow_keys_func (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void crop_modifier_key_func (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); /* Crop helper functions */ -static void crop_recalc (Tool *, Crop *); -static void crop_start (Tool *, Crop *); -static void crop_adjust_guides (GImage *, int, int, int, int); +static void crop_recalc (Tool *tool, + Crop *crop); +static void crop_start (Tool *tool, + Crop *crop); +static void crop_adjust_guides (GImage *gimage, + gint x1, + gint y1, + gint x2, + gint y2); /* Crop dialog functions */ -static void crop_info_update (Tool *); -static void crop_info_create (Tool *); -static void crop_crop_callback (GtkWidget *, gpointer); -static void crop_resize_callback (GtkWidget *, gpointer); -static void crop_close_callback (GtkWidget *, gpointer); +static void crop_info_update (Tool *tool); +static void crop_info_create (Tool *tool); +static void crop_crop_callback (GtkWidget *widget, + gpointer data); +static void crop_resize_callback (GtkWidget *widget, + gpointer data); +static void crop_close_callback (GtkWidget *widget, + gpointer data); + /* Crop area-select functions */ typedef enum @@ -149,19 +173,40 @@ typedef enum AUTO_CROP_COLOR = 2 } AutoCropType; -typedef guchar * (*GetColorFunc) (GtkObject *, int, int); -typedef AutoCropType (*ColorsEqualFunc) (guchar *, guchar *, int); -static void crop_selection_callback (GtkWidget *, gpointer); -static void crop_automatic_callback (GtkWidget *, gpointer); -static AutoCropType crop_guess_bgcolor (GtkObject *, GetColorFunc, - int, int, guchar *, int, int, int, int); -static int crop_colors_equal (guchar *, guchar *, int); -static int crop_colors_alpha (guchar *, guchar *, int); +typedef guchar * (* GetColorFunc) (GtkObject *, + gint , + gint ); +typedef AutoCropType (* ColorsEqualFunc) (guchar *, + guchar *, + gint ); + +static void crop_selection_callback (GtkWidget *widget, + gpointer data); +static void crop_automatic_callback (GtkWidget *widget, + gpointer data); +static AutoCropType crop_guess_bgcolor (GtkObject *, + GetColorFunc, + gint , + gint , + guchar *, + gint , + gint , + gint , + gint ); +static gint crop_colors_equal (guchar *, + guchar *, + gint ); +static gint crop_colors_alpha (guchar *, + guchar *, + gint ); + /* Crop dialog callback funtions */ -static void crop_orig_changed (GtkWidget *, gpointer); -static void crop_size_changed (GtkWidget *, gpointer); +static void crop_orig_changed (GtkWidget *widget, + gpointer data); +static void crop_size_changed (GtkWidget *widget, + gpointer data); /* Functions */ @@ -182,8 +227,8 @@ static CropOptions * crop_options_new (void) { CropOptions *options; - GtkWidget *vbox; - GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *frame; /* the new crop tool options structure */ options = g_new (CropOptions, 1); @@ -241,16 +286,14 @@ crop_options_new (void) static void crop_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - Crop * crop; - GDisplay * gdisp; + Crop *crop; - gdisp = (GDisplay *) gdisp_ptr; crop = (Crop *) tool->private; if (tool->state == INACTIVE || - gdisp_ptr != tool->gdisp_ptr) + gdisp != tool->gdisp) { crop->function = CREATING; } @@ -291,7 +334,7 @@ crop_button_press (Tool *tool, if (tool->state == ACTIVE) draw_core_stop (crop->core, tool); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->drawable = gimp_image_active_drawable (gdisp->gimage); gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, @@ -318,13 +361,11 @@ crop_button_press (Tool *tool, static void crop_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - Crop * crop; - GDisplay *gdisp; + Crop *crop; crop = (Crop *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; gdk_pointer_ungrab (bevent->time); gdk_flush (); @@ -352,13 +393,15 @@ crop_button_release (Tool *tool, static void crop_adjust_guides (GImage *gimage, - int x1, int y1, - int x2, int y2) + gint x1, + gint y1, + gint x2, + gint y2) { - GList * glist; - Guide * guide; - gboolean remove_guide; + GList *glist; + Guide *guide; + gboolean remove_guide; for (glist = gimage->guides; glist; glist = g_list_next (glist)) { @@ -407,19 +450,17 @@ crop_adjust_guides (GImage *gimage, static void crop_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - Crop *crop; - GDisplay *gdisp; - Layer *layer; - gint x1, y1, x2, y2; - gint curx, cury; - gint inc_x, inc_y; - gchar size[STATUSBAR_SIZE]; - gint min_x, min_y, max_x, max_y; + Crop *crop; + Layer *layer; + gint x1, y1, x2, y2; + gint curx, cury; + gint inc_x, inc_y; + gchar size[STATUSBAR_SIZE]; + gint min_x, min_y, max_x, max_y; crop = (Crop *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; /* This is the only case when the motion events should be ignored-- we're just waiting for the button release event to crop the image */ @@ -554,19 +595,17 @@ crop_motion (Tool *tool, static void crop_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Crop *crop; + Crop *crop; GdkCursorType ctype = GIMP_MOUSE_CURSOR; CursorModifier cmodifier = CURSOR_MODIFIER_NONE; - gdisp = (GDisplay *) gdisp_ptr; crop = (Crop *) tool->private; if (tool->state == INACTIVE || - (tool->state == ACTIVE && tool->gdisp_ptr != gdisp_ptr)) + (tool->state == ACTIVE && tool->gdisp != gdisp)) { ctype = GIMP_CROSSHAIR_SMALL_CURSOR; } @@ -605,16 +644,13 @@ crop_cursor_update (Tool *tool, static void crop_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - Crop *crop; - gint inc_x, inc_y; - gint min_x, min_y; - gint max_x, max_y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + Crop *crop; + gint inc_x, inc_y; + gint min_x, min_y; + gint max_x, max_y; if (tool->state == ACTIVE) { @@ -687,7 +723,7 @@ crop_arrow_keys_func (Tool *tool, static void crop_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -712,7 +748,7 @@ crop_modifier_key_func (Tool *tool, static void crop_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { Crop *crop; @@ -741,19 +777,17 @@ crop_control (Tool *tool, void crop_draw (Tool *tool) { - Crop *crop; - GDisplay *gdisp; + Crop *crop; - gdisp = (GDisplay *) tool->gdisp_ptr; - crop = (Crop *) tool->private; + crop = (Crop *) tool->private; #define SRW 10 #define SRH 10 gdk_draw_line (crop->core->win, crop->core->gc, - crop->x1, crop->y1, gdisp->disp_width, crop->y1); + crop->x1, crop->y1, tool->gdisp->disp_width, crop->y1); gdk_draw_line (crop->core->win, crop->core->gc, - crop->x1, crop->y1, crop->x1, gdisp->disp_height); + crop->x1, crop->y1, crop->x1, tool->gdisp->disp_height); gdk_draw_line (crop->core->win, crop->core->gc, crop->x2, crop->y2, 0, crop->y2); gdk_draw_line (crop->core->win, crop->core->gc, @@ -843,10 +877,10 @@ crop_image (GImage *gimage, Channel *channel; GList *guide_list_ptr; GSList *list; - gint width, height; - gint lx1, ly1, lx2, ly2; - gint off_x, off_y; - gint doff_x, doff_y; + gint width, height; + gint lx1, ly1, lx2, ly2; + gint off_x, off_y; + gint doff_x, doff_y; width = x2 - x1; height = y2 - y1; @@ -978,13 +1012,9 @@ static void crop_recalc (Tool *tool, Crop *crop) { - GDisplay *gdisp; - - gdisp = (GDisplay *) tool->gdisp_ptr; - - gdisplay_transform_coords (gdisp, crop->tx1, crop->ty1, + gdisplay_transform_coords (tool->gdisp, crop->tx1, crop->ty1, &crop->x1, &crop->y1, FALSE); - gdisplay_transform_coords (gdisp, crop->tx2, crop->ty2, + gdisplay_transform_coords (tool->gdisp, crop->tx2, crop->ty2, &crop->x2, &crop->y2, FALSE); } @@ -993,9 +1023,6 @@ crop_start (Tool *tool, Crop *crop) { static GDisplay *old_gdisp = NULL; - GDisplay *gdisp; - - gdisp = (GDisplay *) tool->gdisp_ptr; crop_recalc (tool, crop); @@ -1006,33 +1033,33 @@ crop_start (Tool *tool, gtk_signal_handler_block_by_data (GTK_OBJECT (size_sizeentry), crop_info); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 0, - gdisp->gimage->xresolution, FALSE); + tool->gdisp->gimage->xresolution, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 1, - gdisp->gimage->yresolution, FALSE); + tool->gdisp->gimage->yresolution, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 0, - 0, gdisp->gimage->width); + 0, tool->gdisp->gimage->width); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 1, - 0, gdisp->gimage->height); + 0, tool->gdisp->gimage->height); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 0, - gdisp->gimage->xresolution, FALSE); + tool->gdisp->gimage->xresolution, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 1, - gdisp->gimage->yresolution, FALSE); + tool->gdisp->gimage->yresolution, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 0, - 0, gdisp->gimage->width); + 0, tool->gdisp->gimage->width); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 1, - 0, gdisp->gimage->height); + 0, tool->gdisp->gimage->height); - if (old_gdisp != gdisp) + if (old_gdisp != tool->gdisp) { gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry), - gdisp->gimage->unit) ; + tool->gdisp->gimage->unit) ; gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_sizeentry), - gdisp->gimage->unit); + tool->gdisp->gimage->unit); - if (gdisp->dot_for_dot) + if (tool->gdisp->dot_for_dot) { gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry), GIMP_UNIT_PIXEL); @@ -1044,15 +1071,16 @@ crop_start (Tool *tool, gtk_signal_handler_unblock_by_data (GTK_OBJECT (size_sizeentry), crop_info); gtk_signal_handler_unblock_by_data (GTK_OBJECT (origin_sizeentry), crop_info); - old_gdisp = gdisp; + old_gdisp = tool->gdisp; /* initialize the statusbar display */ crop->context_id = - gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "crop"); - gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), + gtk_statusbar_get_context_id (GTK_STATUSBAR (tool->gdisp->statusbar), + "crop"); + gtk_statusbar_push (GTK_STATUSBAR (tool->gdisp->statusbar), crop->context_id, _("Crop: 0 x 0")); - draw_core_start (crop->core, gdisp->canvas->window, tool); + draw_core_start (crop->core, tool->gdisp->canvas->window, tool); } @@ -1068,7 +1096,7 @@ crop_info_create (Tool *tool) GtkWidget *bbox; GtkWidget *button; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = (GDisplay *) tool->gdisp; /* create the info dialog */ crop_info = info_dialog_new (_("Crop & Resize Information"), @@ -1147,11 +1175,9 @@ crop_info_create (Tool *tool) static void crop_info_update (Tool *tool) { - Crop *crop; - GDisplay *gdisp; + Crop *crop; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; orig_vals[0] = crop->tx1; orig_vals[1] = crop->ty1; @@ -1166,15 +1192,13 @@ static void crop_crop_callback (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; + Tool *tool; + Crop *crop; tool = active_tool; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; - crop_image (gdisp->gimage, + crop_image (tool->gdisp->gimage, crop->tx1, crop->ty1, crop->tx2, crop->ty2, crop_options->layer_only, @@ -1188,15 +1212,13 @@ static void crop_resize_callback (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; + Tool *tool; + Crop *crop; tool = active_tool; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; - crop_image (gdisp->gimage, + crop_image (tool->gdisp->gimage, crop->tx1, crop->ty1, crop->tx2, crop->ty2, crop_options->layer_only, @@ -1221,9 +1243,9 @@ crop_close_callback (GtkWidget *widget, info_dialog_popdown (crop_info); - tool->gdisp_ptr = NULL; + tool->gdisp = NULL; tool->drawable = NULL; - tool->state = INACTIVE; + tool->state = INACTIVE; } static void @@ -1235,9 +1257,9 @@ crop_selection_callback (GtkWidget *widget, Layer *layer; GDisplay *gdisp; - tool = active_tool; - crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; + tool = active_tool; + crop = (Crop *) tool->private; + gdisp = tool->gdisp; draw_core_pause (crop->core, tool); if (! gimage_mask_bounds (gdisp->gimage, @@ -1266,24 +1288,24 @@ static void crop_automatic_callback (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; - GimpDrawable *active_drawable = NULL; - GetColorFunc get_color_func; - ColorsEqualFunc colors_equal_func; - GtkObject *get_color_obj; - guchar bgcolor[4] = {0, 0, 0, 0}; - gboolean has_alpha = FALSE; - PixelRegion PR; - guchar *buffer = NULL; - gint offset_x, offset_y, width, height, bytes; - gint x, y, abort; - gint x1, y1, x2, y2; + Tool *tool; + Crop *crop; + GDisplay *gdisp; + GimpDrawable *active_drawable = NULL; + GetColorFunc get_color_func; + ColorsEqualFunc colors_equal_func; + GtkObject *get_color_obj; + guchar bgcolor[4] = {0, 0, 0, 0}; + gboolean has_alpha = FALSE; + PixelRegion PR; + guchar *buffer = NULL; + gint offset_x, offset_y, width, height, bytes; + gint x, y, abort; + gint x1, y1, x2, y2; tool = active_tool; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; draw_core_pause (crop->core, tool); gimp_add_busy_cursors (); @@ -1516,18 +1538,17 @@ static void crop_orig_changed (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; - gint ox; - gint oy; + Tool *tool; + Crop *crop; + gint ox; + gint oy; tool = active_tool; if (tool && active_tool->type == CROP) { - gdisp = (GDisplay *) tool->gdisp_ptr; - crop = (Crop *) tool->private; + crop = (Crop *) tool->private; + ox = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); oy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); @@ -1549,18 +1570,17 @@ static void crop_size_changed (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; - gint sx; - gint sy; + Tool *tool; + Crop *crop; + gint sx; + gint sy; tool = active_tool; if (tool && active_tool->type == CROP) { - gdisp = (GDisplay *) tool->gdisp_ptr; - crop = (Crop *) tool->private; + crop = (Crop *) tool->private; + sx = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0); sy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1); diff --git a/app/crop.h b/app/crop.h index b698b95634..fe7d35d34d 100644 --- a/app/crop.h +++ b/app/crop.h @@ -29,17 +29,15 @@ typedef enum void crop_draw (Tool *tool); void crop_image (GimpImage *gimage, - gint, - gint, - gint, - gint, - gint, - gint); + gint x1, + gint y1, + gint x2, + gint y2, + gboolean layer_only, + gboolean crop_layers); Tool * tools_new_crop (void); void tools_free_crop (Tool *tool); #endif /* __CROP_H__ */ - - diff --git a/app/curves.c b/app/curves.c index 7ba6f1ab76..fe3a945fc7 100644 --- a/app/curves.c +++ b/app/curves.c @@ -108,40 +108,72 @@ static CRMatrix CR_basis = /* curves action functions */ -static void curves_button_press (Tool *, GdkEventButton *, gpointer); -static void curves_button_release (Tool *, GdkEventButton *, gpointer); -static void curves_motion (Tool *, GdkEventMotion *, gpointer); -static void curves_control (Tool *, ToolAction, gpointer); +static void curves_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void curves_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void curves_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void curves_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); -static CurvesDialog * curves_dialog_new (void); +static CurvesDialog * curves_dialog_new (void); -static void curves_update (CurvesDialog *, int); -static void curves_plot_curve (CurvesDialog *, int, int, int, int); -static void curves_preview (CurvesDialog *); +static void curves_update (CurvesDialog *cd, + gint ); +static void curves_plot_curve (CurvesDialog *cd, + gint , + gint , + gint , + gint ); +static void curves_preview (CurvesDialog *cd); -static void curves_channel_callback (GtkWidget *, gpointer); +static void curves_channel_callback (GtkWidget *widget, + gpointer data); -static void curves_smooth_callback (GtkWidget *, gpointer); -static void curves_free_callback (GtkWidget *, gpointer); +static void curves_smooth_callback (GtkWidget *widget, + gpointer data); +static void curves_free_callback (GtkWidget *widget, + gpointer data); -static void curves_channel_reset (int); -static void curves_reset_callback (GtkWidget *, gpointer); -static void curves_ok_callback (GtkWidget *, gpointer); -static void curves_cancel_callback (GtkWidget *, gpointer); -static void curves_load_callback (GtkWidget *, gpointer); -static void curves_save_callback (GtkWidget *, gpointer); -static void curves_preview_update (GtkWidget *, gpointer); -static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static gint curves_graph_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static void curves_CR_compose (CRMatrix, CRMatrix, CRMatrix); +static void curves_channel_reset (gint ); +static void curves_reset_callback (GtkWidget *widget, + gpointer data); +static void curves_ok_callback (GtkWidget *widget, + gpointer data); +static void curves_cancel_callback (GtkWidget *widget, + gpointer data); +static void curves_load_callback (GtkWidget *widget, + gpointer data); +static void curves_save_callback (GtkWidget *widget, + gpointer data); +static void curves_preview_update (GtkWidget *widget, + gpointer data); +static gint curves_xrange_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static gint curves_yrange_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static gint curves_graph_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static void curves_CR_compose (CRMatrix , + CRMatrix , + CRMatrix ); -static void file_dialog_create (GtkWidget *); -static void file_dialog_ok_callback (GtkWidget *, gpointer); -static void file_dialog_cancel_callback (GtkWidget *, gpointer); +static void file_dialog_create (GtkWidget *widget); +static void file_dialog_ok_callback (GtkWidget *widget, + gpointer data); +static void file_dialog_cancel_callback (GtkWidget *widget, + gpointer data); -static gboolean curves_read_from_file (FILE *f); -static void curves_write_to_file (FILE *f); +static gboolean curves_read_from_file (FILE *f); +static void curves_write_to_file (FILE *f); /* curves machinery */ @@ -152,10 +184,10 @@ curves_lut_func (CurvesDialog *cd, gint channel, gfloat value) { - gfloat f; - gint index; + gfloat f; + gint index; gdouble inten; - gint j; + gint j; if (nchannels == 1) j = 0; @@ -197,15 +229,15 @@ curves_colour_update (Tool *tool, gint x, gint y) { - guchar *color; - gint offx; - gint offy; - gint maxval; + guchar *color; + gint offx; + gint offy; + gint maxval; gboolean has_alpha; gboolean is_indexed; GimpImageType sample_type; - if(!tool || tool->state != ACTIVE) + if (!tool || tool->state != ACTIVE) return; drawable_offsets (drawable, &offx, &offy); @@ -213,7 +245,7 @@ curves_colour_update (Tool *tool, x -= offx; y -= offy; - if (!(color = image_map_get_color_at(curves_dialog->image_map, x, y))) + if (!(color = image_map_get_color_at (curves_dialog->image_map, x, y))) return; sample_type = gimp_drawable_type (drawable); @@ -283,16 +315,14 @@ curves_add_point (GimpDrawable *drawable, static void curves_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; - GDisplay *gdisp; + gint x, y; GimpDrawable *drawable; - gdisp = gdisp_ptr; drawable = gimp_image_active_drawable (gdisp->gimage); - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; if (drawable != tool->drawable) { @@ -318,20 +348,18 @@ curves_button_press (Tool *tool, static void curves_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; + gint x, y; GimpDrawable *drawable; - GDisplay *gdisp; - gdisp = (GDisplay *) gdisp_ptr; - - if(!curves_dialog || - !gdisp || - !(drawable = gimp_image_active_drawable (gdisp->gimage))) + if (! curves_dialog || + ! gdisp || + ! (drawable = gimp_image_active_drawable (gdisp->gimage))) return; - gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE); + gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, + FALSE, FALSE); curves_colour_update (tool, gdisp, drawable, x, y); if (bevent->state & GDK_SHIFT_MASK) @@ -355,14 +383,11 @@ curves_button_release (Tool *tool, static void curves_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; - GDisplay *gdisp; + gint x, y; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; - if (! curves_dialog || ! gdisp || ! (drawable = gimp_image_active_drawable (gdisp->gimage))) @@ -376,7 +401,7 @@ curves_motion (Tool *tool, static void curves_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -1279,7 +1304,7 @@ curves_ok_callback (GtkWidget *widget, cd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -1303,7 +1328,7 @@ curves_cancel_callback (GtkWidget *widget, cd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/display/gimpdisplay-selection.c b/app/display/gimpdisplay-selection.c index 2810e66f0c..41de9d2267 100644 --- a/app/display/gimpdisplay-selection.c +++ b/app/display/gimpdisplay-selection.c @@ -499,20 +499,17 @@ selection_march_ants (gpointer data) Selection * selection_create (GdkWindow *win, - gpointer gdisp_ptr, - int size, - int width, - int speed) + GDisplay *gdisp, + gint size, + gint width, + gint speed) { - GdkColor fg, bg; - GDisplay *gdisp; - Selection * new; - int base_type; - int i; + GdkColor fg, bg; + Selection *new; + gint base_type; + gint i; - gdisp = (GDisplay *) gdisp_ptr; - - new = (Selection *) g_malloc (sizeof (Selection)); + new = g_new (Selection, 1); base_type = gimp_image_base_type (gdisp->gimage); if (cycled_marching_ants) @@ -532,7 +529,7 @@ selection_create (GdkWindow *win, } new->win = win; - new->gdisp = gdisp_ptr; + new->gdisp = gdisp; new->segs_in = NULL; new->segs_out = NULL; new->segs_layer = NULL; @@ -563,8 +560,8 @@ selection_create (GdkWindow *win, else { /* get black and white pixels for this gdisplay */ - fg.pixel = gdisplay_black_pixel ((GDisplay *) gdisp_ptr); - bg.pixel = gdisplay_white_pixel ((GDisplay *) gdisp_ptr); + fg.pixel = gdisplay_black_pixel (gdisp); + bg.pixel = gdisplay_white_pixel (gdisp); gdk_gc_set_foreground (new->gc_in, &fg); gdk_gc_set_background (new->gc_in, &bg); @@ -581,8 +578,8 @@ selection_create (GdkWindow *win, #endif /* Setup 2nd & 3rd GCs */ - fg.pixel = gdisplay_white_pixel ((GDisplay *) gdisp_ptr); - bg.pixel = gdisplay_gray_pixel ((GDisplay *) gdisp_ptr); + fg.pixel = gdisplay_white_pixel (gdisp); + bg.pixel = gdisplay_gray_pixel (gdisp); /* create a new graphics context */ new->gc_out = gdk_gc_new (new->win); @@ -592,8 +589,8 @@ selection_create (GdkWindow *win, gdk_gc_set_line_attributes (new->gc_out, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER); /* get black and color pixels for this gdisplay */ - fg.pixel = gdisplay_black_pixel ((GDisplay *) gdisp_ptr); - bg.pixel = gdisplay_color_pixel ((GDisplay *) gdisp_ptr); + fg.pixel = gdisplay_black_pixel (gdisp); + bg.pixel = gdisplay_color_pixel (gdisp); /* create a new graphics context */ new->gc_layer = gdk_gc_new (new->win); @@ -719,7 +716,7 @@ selection_layer_invis (Selection *select) void selection_hide (Selection *select, - void *gdisp_ptr) + GDisplay *gdisp) { selection_invis (select); selection_layer_invis (select); diff --git a/app/display/gimpdisplay-selection.h b/app/display/gimpdisplay-selection.h index 08a5d7698c..2f9ded2b34 100644 --- a/app/display/gimpdisplay-selection.h +++ b/app/display/gimpdisplay-selection.h @@ -19,57 +19,60 @@ #ifndef __SELECTION_H__ #define __SELECTION_H__ + struct _Selection { /* This information is for maintaining the selection's appearance */ - GdkWindow * win; /* Window to draw to */ - void * gdisp; /* GDisplay that owns the selection */ - GdkGC * gc_in; /* GC for drawing selection outline */ - GdkGC * gc_out; /* GC for selected regions outside current layer */ - GdkGC * gc_layer; /* GC for current layer outline */ + GdkWindow *win; /* Window to draw to */ + GDisplay *gdisp; /* GDisplay that owns the selection */ + GdkGC *gc_in; /* GC for drawing selection outline */ + GdkGC *gc_out; /* GC for selected regions outside + * current layer */ + GdkGC *gc_layer; /* GC for current layer outline */ /* This information is for drawing the marching ants around the border */ - GdkSegment * segs_in; /* gdk segments of area boundary */ - GdkSegment * segs_out; /* gdk segments of area boundary */ - GdkSegment * segs_layer; /* gdk segments of area boundary */ - gint num_segs_in; /* number of segments in segs1 */ - gint num_segs_out; /* number of segments in segs2 */ - gint num_segs_layer; /* number of segments in segs3 */ - gint index_in; /* index of current stipple pattern */ - gint index_out; /* index of current stipple pattern */ - gint index_layer; /* index of current stipple pattern */ - gint state; /* internal drawing state */ - gint paused; /* count of pause requests */ - gint recalc; /* flag to recalculate the selection */ - gint speed; /* speed of marching ants */ - gint hidden; /* is the selection hidden? */ - gint timer; /* timer for successive draws */ - gint cycle; /* color cycling turned on */ - GdkPixmap * cycle_pix; /* cycling pixmap */ + GdkSegment *segs_in; /* gdk segments of area boundary */ + GdkSegment *segs_out; /* gdk segments of area boundary */ + GdkSegment *segs_layer; /* gdk segments of area boundary */ + gint num_segs_in; /* number of segments in segs1 */ + gint num_segs_out; /* number of segments in segs2 */ + gint num_segs_layer; /* number of segments in segs3 */ + gint index_in; /* index of current stipple pattern */ + gint index_out; /* index of current stipple pattern */ + gint index_layer; /* index of current stipple pattern */ + gint state; /* internal drawing state */ + gint paused; /* count of pause requests */ + gint recalc; /* flag to recalculate the selection */ + gint speed; /* speed of marching ants */ + gint hidden; /* is the selection hidden? */ + gint timer; /* timer for successive draws */ + gint cycle; /* color cycling turned on */ + GdkPixmap *cycle_pix; /* cycling pixmap */ /* These are used only if USE_XDRAWPOINTS is defined. */ - GdkPoint * points_in[8]; /* points of segs_in for fast ants */ - gint num_points_in[8]; /* number of points in points_in */ - GdkGC * gc_white; /* gc for drawing white points */ - GdkGC * gc_black; /* gc for drawing black points */ + GdkPoint *points_in[8]; /* points of segs_in for fast ants */ + gint num_points_in[8]; /* number of points in points_in */ + GdkGC *gc_white; /* gc for drawing white points */ + GdkGC *gc_black; /* gc for drawing black points */ }; + /* Function declarations */ -Selection * selection_create (GdkWindow *, - gpointer , - gint , - gint , - gint ); -void selection_pause (Selection *); -void selection_resume (Selection *); -void selection_start (Selection *, - gint ); -void selection_invis (Selection *); -void selection_layer_invis (Selection *); -void selection_hide (Selection *, - gpointer ); -void selection_free (Selection *); +Selection * selection_create (GdkWindow *win, + GDisplay *disp, + gint size, + gint width, + gint speed); +void selection_pause (Selection *select); +void selection_resume (Selection *select); +void selection_start (Selection *select, + gint recalc); +void selection_invis (Selection *select); +void selection_layer_invis (Selection *select); +void selection_hide (Selection *select, + GDisplay *gdisp); +void selection_free (Selection *select); #endif /* __SELECTION_H__ */ diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index 1f09287c71..2a14c8b7f4 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -375,10 +375,10 @@ gdisplay_delete (GDisplay *gdisp) /* clear out the pointer to this gdisp from the active tool */ if (active_tool && - active_tool->gdisp_ptr == gdisp) + active_tool->gdisp == gdisp) { active_tool->drawable = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; } /* free the selection structure */ diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c index 2810e66f0c..41de9d2267 100644 --- a/app/display/gimpdisplayshell-selection.c +++ b/app/display/gimpdisplayshell-selection.c @@ -499,20 +499,17 @@ selection_march_ants (gpointer data) Selection * selection_create (GdkWindow *win, - gpointer gdisp_ptr, - int size, - int width, - int speed) + GDisplay *gdisp, + gint size, + gint width, + gint speed) { - GdkColor fg, bg; - GDisplay *gdisp; - Selection * new; - int base_type; - int i; + GdkColor fg, bg; + Selection *new; + gint base_type; + gint i; - gdisp = (GDisplay *) gdisp_ptr; - - new = (Selection *) g_malloc (sizeof (Selection)); + new = g_new (Selection, 1); base_type = gimp_image_base_type (gdisp->gimage); if (cycled_marching_ants) @@ -532,7 +529,7 @@ selection_create (GdkWindow *win, } new->win = win; - new->gdisp = gdisp_ptr; + new->gdisp = gdisp; new->segs_in = NULL; new->segs_out = NULL; new->segs_layer = NULL; @@ -563,8 +560,8 @@ selection_create (GdkWindow *win, else { /* get black and white pixels for this gdisplay */ - fg.pixel = gdisplay_black_pixel ((GDisplay *) gdisp_ptr); - bg.pixel = gdisplay_white_pixel ((GDisplay *) gdisp_ptr); + fg.pixel = gdisplay_black_pixel (gdisp); + bg.pixel = gdisplay_white_pixel (gdisp); gdk_gc_set_foreground (new->gc_in, &fg); gdk_gc_set_background (new->gc_in, &bg); @@ -581,8 +578,8 @@ selection_create (GdkWindow *win, #endif /* Setup 2nd & 3rd GCs */ - fg.pixel = gdisplay_white_pixel ((GDisplay *) gdisp_ptr); - bg.pixel = gdisplay_gray_pixel ((GDisplay *) gdisp_ptr); + fg.pixel = gdisplay_white_pixel (gdisp); + bg.pixel = gdisplay_gray_pixel (gdisp); /* create a new graphics context */ new->gc_out = gdk_gc_new (new->win); @@ -592,8 +589,8 @@ selection_create (GdkWindow *win, gdk_gc_set_line_attributes (new->gc_out, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER); /* get black and color pixels for this gdisplay */ - fg.pixel = gdisplay_black_pixel ((GDisplay *) gdisp_ptr); - bg.pixel = gdisplay_color_pixel ((GDisplay *) gdisp_ptr); + fg.pixel = gdisplay_black_pixel (gdisp); + bg.pixel = gdisplay_color_pixel (gdisp); /* create a new graphics context */ new->gc_layer = gdk_gc_new (new->win); @@ -719,7 +716,7 @@ selection_layer_invis (Selection *select) void selection_hide (Selection *select, - void *gdisp_ptr) + GDisplay *gdisp) { selection_invis (select); selection_layer_invis (select); diff --git a/app/display/gimpdisplayshell-selection.h b/app/display/gimpdisplayshell-selection.h index 08a5d7698c..2f9ded2b34 100644 --- a/app/display/gimpdisplayshell-selection.h +++ b/app/display/gimpdisplayshell-selection.h @@ -19,57 +19,60 @@ #ifndef __SELECTION_H__ #define __SELECTION_H__ + struct _Selection { /* This information is for maintaining the selection's appearance */ - GdkWindow * win; /* Window to draw to */ - void * gdisp; /* GDisplay that owns the selection */ - GdkGC * gc_in; /* GC for drawing selection outline */ - GdkGC * gc_out; /* GC for selected regions outside current layer */ - GdkGC * gc_layer; /* GC for current layer outline */ + GdkWindow *win; /* Window to draw to */ + GDisplay *gdisp; /* GDisplay that owns the selection */ + GdkGC *gc_in; /* GC for drawing selection outline */ + GdkGC *gc_out; /* GC for selected regions outside + * current layer */ + GdkGC *gc_layer; /* GC for current layer outline */ /* This information is for drawing the marching ants around the border */ - GdkSegment * segs_in; /* gdk segments of area boundary */ - GdkSegment * segs_out; /* gdk segments of area boundary */ - GdkSegment * segs_layer; /* gdk segments of area boundary */ - gint num_segs_in; /* number of segments in segs1 */ - gint num_segs_out; /* number of segments in segs2 */ - gint num_segs_layer; /* number of segments in segs3 */ - gint index_in; /* index of current stipple pattern */ - gint index_out; /* index of current stipple pattern */ - gint index_layer; /* index of current stipple pattern */ - gint state; /* internal drawing state */ - gint paused; /* count of pause requests */ - gint recalc; /* flag to recalculate the selection */ - gint speed; /* speed of marching ants */ - gint hidden; /* is the selection hidden? */ - gint timer; /* timer for successive draws */ - gint cycle; /* color cycling turned on */ - GdkPixmap * cycle_pix; /* cycling pixmap */ + GdkSegment *segs_in; /* gdk segments of area boundary */ + GdkSegment *segs_out; /* gdk segments of area boundary */ + GdkSegment *segs_layer; /* gdk segments of area boundary */ + gint num_segs_in; /* number of segments in segs1 */ + gint num_segs_out; /* number of segments in segs2 */ + gint num_segs_layer; /* number of segments in segs3 */ + gint index_in; /* index of current stipple pattern */ + gint index_out; /* index of current stipple pattern */ + gint index_layer; /* index of current stipple pattern */ + gint state; /* internal drawing state */ + gint paused; /* count of pause requests */ + gint recalc; /* flag to recalculate the selection */ + gint speed; /* speed of marching ants */ + gint hidden; /* is the selection hidden? */ + gint timer; /* timer for successive draws */ + gint cycle; /* color cycling turned on */ + GdkPixmap *cycle_pix; /* cycling pixmap */ /* These are used only if USE_XDRAWPOINTS is defined. */ - GdkPoint * points_in[8]; /* points of segs_in for fast ants */ - gint num_points_in[8]; /* number of points in points_in */ - GdkGC * gc_white; /* gc for drawing white points */ - GdkGC * gc_black; /* gc for drawing black points */ + GdkPoint *points_in[8]; /* points of segs_in for fast ants */ + gint num_points_in[8]; /* number of points in points_in */ + GdkGC *gc_white; /* gc for drawing white points */ + GdkGC *gc_black; /* gc for drawing black points */ }; + /* Function declarations */ -Selection * selection_create (GdkWindow *, - gpointer , - gint , - gint , - gint ); -void selection_pause (Selection *); -void selection_resume (Selection *); -void selection_start (Selection *, - gint ); -void selection_invis (Selection *); -void selection_layer_invis (Selection *); -void selection_hide (Selection *, - gpointer ); -void selection_free (Selection *); +Selection * selection_create (GdkWindow *win, + GDisplay *disp, + gint size, + gint width, + gint speed); +void selection_pause (Selection *select); +void selection_resume (Selection *select); +void selection_start (Selection *select, + gint recalc); +void selection_invis (Selection *select); +void selection_layer_invis (Selection *select); +void selection_hide (Selection *select, + GDisplay *gdisp); +void selection_free (Selection *select); #endif /* __SELECTION_H__ */ diff --git a/app/display/gimpnavigationeditor.c b/app/display/gimpnavigationeditor.c index 6f434f3e1a..6b259f442b 100644 --- a/app/display/gimpnavigationeditor.c +++ b/app/display/gimpnavigationeditor.c @@ -77,6 +77,7 @@ typedef enum #define PREVIEW_UPDATE_TIMEOUT 1100 typedef struct _NavWinData NavWinData; + struct _NavWinData { NavWinType ptype; @@ -88,7 +89,7 @@ struct _NavWinData GtkWidget *zoom_label; GtkObject *zoom_adjustment; GtkWidget *preview; - void *gdisp_ptr; /* I'm not happy 'bout this one */ + GDisplay *gdisp; /* I'm not happy 'bout this one */ GdkGC *gc; gint dispx; /* x pos of top left corner of display area */ gint dispy; /* y pos of top left corner of display area */ @@ -251,10 +252,6 @@ nav_window_draw_sqr (NavWinData *iwd, gint w, gint h) { - GDisplay *gdisp; - - gdisp = (GDisplay *) iwd->gdisp_ptr; - gdk_gc_set_function (iwd->gc, GDK_INVERT); if (undraw) @@ -307,7 +304,7 @@ set_size_data (NavWinData *iwd) GDisplay *gdisp; GimpImage *gimage; - gdisp = (GDisplay *)(iwd->gdisp_ptr); + gdisp = iwd->gdisp; gimage = gdisp->gimage; sel_width = gimage->width; @@ -345,9 +342,6 @@ create_preview_widget (NavWinData *iwd) GtkWidget *hbox; GtkWidget *image; GtkWidget *frame; - GDisplay *gdisp; - - gdisp = (GDisplay *)(iwd->gdisp_ptr); hbox = gtk_hbox_new (FALSE,0); iwd->previewBox = hbox; @@ -406,7 +400,7 @@ update_real_view (NavWinData *iwd, gint xpnt; gint ypnt; - gdisp = (GDisplay *) iwd->gdisp_ptr; + gdisp = iwd->gdisp; xratio = SCALEFACTOR_X (gdisp); yratio = SCALEFACTOR_Y (gdisp); @@ -433,7 +427,7 @@ update_real_view (NavWinData *iwd, yoffset = ypnt - gdisp->offset_y; iwd->block_window_marker = TRUE; - scroll_display (iwd->gdisp_ptr, xoffset, yoffset); + scroll_display (iwd->gdisp, xoffset, yoffset); iwd->block_window_marker = FALSE; } @@ -454,10 +448,8 @@ nav_window_update_preview (NavWinData *iwd) gimp_add_busy_cursors (); - gdisp = (GDisplay *) iwd->gdisp_ptr; - - /* Calculate preview size */ - gimage = ((GDisplay *) (iwd->gdisp_ptr))->gimage; + gdisp = iwd->gdisp; + gimage = gdisp->gimage; /* Min size is 2 */ pwidth = iwd->pwidth; @@ -615,10 +607,8 @@ nav_window_update_preview_blank (NavWinData *iwd) GimpImage *gimage; GDisplay *gdisp; - gdisp = (GDisplay *) iwd->gdisp_ptr; - - /* Calculate preview size */ - gimage = ((GDisplay *) (iwd->gdisp_ptr))->gimage; + gdisp = iwd->gdisp; + gimage = gdisp->gimage; #endif /* 0 */ @@ -670,9 +660,9 @@ update_zoom_label (NavWinData *iwd) /* Update the zoom scale string */ g_snprintf (scale_str, MAX_SCALE_BUF, "%d:%d", - SCALEDEST (((GDisplay *)iwd->gdisp_ptr)), - SCALESRC (((GDisplay *)iwd->gdisp_ptr))); - + SCALEDEST (iwd->gdisp), + SCALESRC (iwd->gdisp)); + gtk_label_set_text (GTK_LABEL (iwd->zoom_label), scale_str); } @@ -689,8 +679,8 @@ update_zoom_adjustment (NavWinData *iwd) adj = GTK_ADJUSTMENT (iwd->zoom_adjustment); f = - ((gdouble) SCALEDEST (((GDisplay *) iwd->gdisp_ptr))) / - ((gdouble) SCALESRC (((GDisplay *) iwd->gdisp_ptr))); + ((gdouble) SCALEDEST (iwd->gdisp)) / + ((gdouble) SCALESRC (iwd->gdisp)); if (f < 1.0) { @@ -782,7 +772,7 @@ nav_window_preview_events (GtkWidget *widget, if(!iwd || iwd->frozen == TRUE) return FALSE; - gdisp = (GDisplay *) iwd->gdisp_ptr; + gdisp = iwd->gdisp; switch (event->type) { @@ -998,7 +988,7 @@ nav_window_expose_events (GtkWidget *widget, if(!iwd || iwd->frozen == TRUE) return FALSE; - gdisp = (GDisplay *) iwd->gdisp_ptr; + gdisp = iwd->gdisp; switch (event->type) { @@ -1025,12 +1015,12 @@ nav_window_expose_events (GtkWidget *widget, static gint nav_preview_update_do (NavWinData *iwd) { - /* If the gdisp_ptr has gone then don't do anything in this timer */ - if (!iwd->gdisp_ptr) + /* If the gdisp has gone then don't do anything in this timer */ + if (!iwd->gdisp) return FALSE; nav_window_update_preview (iwd); - nav_window_disp_area (iwd, iwd->gdisp_ptr); + nav_window_disp_area (iwd, iwd->gdisp); gtk_widget_queue_draw (iwd->preview); iwd->installedDirtyTimer = FALSE; @@ -1076,16 +1066,13 @@ navwindow_zoomin (GtkWidget *widget, gpointer data) { NavWinData *iwd; - GDisplay *gdisp; - iwd = (NavWinData *)data; + iwd = (NavWinData *) data; if(!iwd || iwd->frozen == TRUE) return; - gdisp = (GDisplay *) iwd->gdisp_ptr; - - change_scale (gdisp, ZOOMIN); + change_scale (iwd->gdisp, ZOOMIN); } static void @@ -1093,16 +1080,13 @@ navwindow_zoomout (GtkWidget *widget, gpointer data) { NavWinData *iwd; - GDisplay *gdisp; iwd = (NavWinData *)data; if (!iwd || iwd->frozen == TRUE) return; - gdisp = (GDisplay *) iwd->gdisp_ptr; - - change_scale (gdisp, ZOOMOUT); + change_scale (iwd->gdisp, ZOOMOUT); } static void @@ -1110,7 +1094,6 @@ zoom_adj_changed (GtkAdjustment *adj, gpointer data) { NavWinData *iwd; - GDisplay *gdisp; gint scalesrc; gint scaledest; @@ -1119,8 +1102,6 @@ zoom_adj_changed (GtkAdjustment *adj, if (!iwd || iwd->frozen == TRUE) return; - gdisp = (GDisplay *) iwd->gdisp_ptr; - if (adj->value < 0.0) { scalesrc = abs ((gint) adj->value - 1); @@ -1133,7 +1114,7 @@ zoom_adj_changed (GtkAdjustment *adj, } iwd->block_adj_sig = TRUE; - change_scale (gdisp, (scaledest * 100) + scalesrc); + change_scale (iwd->gdisp, (scaledest * 100) + scalesrc); iwd->block_adj_sig = FALSE; } @@ -1168,8 +1149,8 @@ nav_create_button_area (InfoDialog *info_win) /* user zoom ratio */ g_snprintf (scale_str, MAX_SCALE_BUF, "%d:%d", - SCALEDEST (((GDisplay *)iwd->gdisp_ptr)), - SCALESRC (((GDisplay *)iwd->gdisp_ptr))); + SCALEDEST (iwd->gdisp), + SCALESRC (iwd->gdisp)); label1 = gtk_label_new (scale_str); gtk_widget_show (label1); @@ -1256,12 +1237,12 @@ info_window_image_preview_new (InfoDialog *info_win) } NavWinData * -create_dummy_iwd (void *gdisp_ptr, +create_dummy_iwd (GDisplay *gdisp, NavWinType ptype) { NavWinData *iwd; - iwd = (NavWinData *) g_malloc (sizeof (NavWinData)); + iwd = g_new (NavWinData, 1); iwd->ptype = ptype; iwd->info_win = NULL; iwd->showingPreview = TRUE; @@ -1269,7 +1250,7 @@ create_dummy_iwd (void *gdisp_ptr, iwd->preview = NULL; iwd->zoom_label = NULL; iwd->zoom_adjustment = NULL; - iwd->gdisp_ptr = gdisp_ptr; + iwd->gdisp = gdisp; iwd->dispx = -1; iwd->dispy = -1; iwd->dispwidth = -1; @@ -1299,7 +1280,7 @@ create_dummy_iwd (void *gdisp_ptr, static InfoDialog *nav_window_auto = NULL; static gchar * -nav_window_title(GDisplay *gdisp) +nav_window_title (GDisplay *gdisp) { gchar *title; gchar *title_buf; @@ -1326,8 +1307,8 @@ nav_window_change_display (GimpContext *context, /* NOT USED */ NavWinData *iwd; gchar *title_buf; - iwd = (NavWinData *)nav_window_auto->user_data; - old_gdisp = (GDisplay *) iwd->gdisp_ptr; + iwd = (NavWinData *) nav_window_auto->user_data; + old_gdisp = iwd->gdisp; if (!nav_window_auto || gdisp == old_gdisp || !gdisp) { @@ -1347,7 +1328,7 @@ nav_window_change_display (GimpContext *context, /* NOT USED */ if (gimage && gimp_set_have (image_context, gimage)) { - iwd->gdisp_ptr = gdisp; + iwd->gdisp = gdisp; /* Update preview to new display */ nav_window_preview_resized (nav_window_auto); @@ -1382,9 +1363,10 @@ nav_window_follow_auto (void) if (!gdisp) return; - if(!nav_window_auto) + if (!nav_window_auto) { - nav_window_auto = nav_window_create ((void *) gdisp); + nav_window_auto = nav_window_create (gdisp); + gtk_signal_connect (GTK_OBJECT (gimp_context_get_user ()), "display_changed", GTK_SIGNAL_FUNC (nav_window_change_display), @@ -1400,20 +1382,17 @@ nav_window_follow_auto (void) InfoDialog * -nav_window_create (void *gdisp_ptr) +nav_window_create (GDisplay *gdisp) { InfoDialog *info_win; - GDisplay *gdisp; NavWinData *iwd; GtkWidget *container; gchar *title_buf; GimpImageBaseType type; - gdisp = (GDisplay *) gdisp_ptr; - type = gimp_image_base_type (gdisp->gimage); - title_buf = nav_window_title(gdisp); + title_buf = nav_window_title (gdisp); info_win = info_dialog_new (title_buf, gimp_standard_help_func, @@ -1434,7 +1413,7 @@ nav_window_create (void *gdisp_ptr) (GtkSignalFunc) nav_window_destroy_callback, info_win); - iwd = create_dummy_iwd (gdisp_ptr, NAV_WINDOW); + iwd = create_dummy_iwd (gdisp, NAV_WINDOW); info_win->user_data = iwd; iwd->info_win = info_win; @@ -1501,7 +1480,7 @@ nav_window_update_window_marker (InfoDialog *info_win) iwd->dispwidth, iwd->dispheight); /* Update to new size */ - nav_window_disp_area (iwd, iwd->gdisp_ptr); + nav_window_disp_area (iwd, iwd->gdisp); /* and redraw */ nav_window_draw_sqr (iwd, @@ -1563,14 +1542,14 @@ nav_window_get_gdisp (void) for (listPtr = list; listPtr; listPtr = g_slist_next (listPtr)) { gimage = GIMP_IMAGE (listPtr->data); - gdisp = gdisplays_check_valid (NULL,gimage); + gdisp = gdisplays_check_valid (NULL, gimage); if (gdisp) break; } g_slist_free (list); - return (gdisp); + return gdisp; } @@ -1589,12 +1568,12 @@ nav_window_free (GDisplay *del_gdisp, { if (nav_window_auto != NULL) { - GDisplay * gdisp; + GDisplay *gdisp; iwd = (NavWinData *) nav_window_auto->user_data; /* Only freeze if we are displaying the image we have deleted */ - if ((GDisplay *) iwd->gdisp_ptr != del_gdisp) + if (iwd->gdisp != del_gdisp) return; if (iwd->timer_id) @@ -1605,7 +1584,9 @@ nav_window_free (GDisplay *del_gdisp, gdisp = nav_window_get_gdisp (); if (gdisp) - nav_window_change_display (NULL, gdisp, NULL); + { + nav_window_change_display (NULL, gdisp, NULL); + } else { /* Clear window and freeze */ @@ -1615,7 +1596,7 @@ nav_window_free (GDisplay *del_gdisp, _("Navigation: No Image")); gtk_widget_set_sensitive (nav_window_auto->vbox, FALSE); - iwd->gdisp_ptr = NULL; + iwd->gdisp = NULL; gtk_widget_hide (GTK_WIDGET (nav_window_auto->shell)); } } @@ -1651,7 +1632,7 @@ nav_popup_click_handler (GtkWidget *widget, bevent = (GdkEventButton *)event; - if(!gdisp->nav_popup) + if (! gdisp->nav_popup) { /* popup a simplfied window with the nav box in it */ GtkWidget *frame; @@ -1674,14 +1655,14 @@ nav_popup_click_handler (GtkWidget *widget, gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_object_set_data (GTK_OBJECT (gdisp->nav_popup),"navpop_prt", (gpointer) iwp); - nav_window_disp_area (iwp, iwp->gdisp_ptr); + nav_window_disp_area (iwp, iwp->gdisp); } else { gtk_widget_hide (gdisp->nav_popup); iwp = (NavWinData *) gtk_object_get_data (GTK_OBJECT (gdisp->nav_popup), "navpop_prt"); - nav_window_disp_area (iwp, iwp->gdisp_ptr); + nav_window_disp_area (iwp, iwp->gdisp); nav_window_update_preview (iwp); } diff --git a/app/display/gimpnavigationview.c b/app/display/gimpnavigationview.c index 6f434f3e1a..6b259f442b 100644 --- a/app/display/gimpnavigationview.c +++ b/app/display/gimpnavigationview.c @@ -77,6 +77,7 @@ typedef enum #define PREVIEW_UPDATE_TIMEOUT 1100 typedef struct _NavWinData NavWinData; + struct _NavWinData { NavWinType ptype; @@ -88,7 +89,7 @@ struct _NavWinData GtkWidget *zoom_label; GtkObject *zoom_adjustment; GtkWidget *preview; - void *gdisp_ptr; /* I'm not happy 'bout this one */ + GDisplay *gdisp; /* I'm not happy 'bout this one */ GdkGC *gc; gint dispx; /* x pos of top left corner of display area */ gint dispy; /* y pos of top left corner of display area */ @@ -251,10 +252,6 @@ nav_window_draw_sqr (NavWinData *iwd, gint w, gint h) { - GDisplay *gdisp; - - gdisp = (GDisplay *) iwd->gdisp_ptr; - gdk_gc_set_function (iwd->gc, GDK_INVERT); if (undraw) @@ -307,7 +304,7 @@ set_size_data (NavWinData *iwd) GDisplay *gdisp; GimpImage *gimage; - gdisp = (GDisplay *)(iwd->gdisp_ptr); + gdisp = iwd->gdisp; gimage = gdisp->gimage; sel_width = gimage->width; @@ -345,9 +342,6 @@ create_preview_widget (NavWinData *iwd) GtkWidget *hbox; GtkWidget *image; GtkWidget *frame; - GDisplay *gdisp; - - gdisp = (GDisplay *)(iwd->gdisp_ptr); hbox = gtk_hbox_new (FALSE,0); iwd->previewBox = hbox; @@ -406,7 +400,7 @@ update_real_view (NavWinData *iwd, gint xpnt; gint ypnt; - gdisp = (GDisplay *) iwd->gdisp_ptr; + gdisp = iwd->gdisp; xratio = SCALEFACTOR_X (gdisp); yratio = SCALEFACTOR_Y (gdisp); @@ -433,7 +427,7 @@ update_real_view (NavWinData *iwd, yoffset = ypnt - gdisp->offset_y; iwd->block_window_marker = TRUE; - scroll_display (iwd->gdisp_ptr, xoffset, yoffset); + scroll_display (iwd->gdisp, xoffset, yoffset); iwd->block_window_marker = FALSE; } @@ -454,10 +448,8 @@ nav_window_update_preview (NavWinData *iwd) gimp_add_busy_cursors (); - gdisp = (GDisplay *) iwd->gdisp_ptr; - - /* Calculate preview size */ - gimage = ((GDisplay *) (iwd->gdisp_ptr))->gimage; + gdisp = iwd->gdisp; + gimage = gdisp->gimage; /* Min size is 2 */ pwidth = iwd->pwidth; @@ -615,10 +607,8 @@ nav_window_update_preview_blank (NavWinData *iwd) GimpImage *gimage; GDisplay *gdisp; - gdisp = (GDisplay *) iwd->gdisp_ptr; - - /* Calculate preview size */ - gimage = ((GDisplay *) (iwd->gdisp_ptr))->gimage; + gdisp = iwd->gdisp; + gimage = gdisp->gimage; #endif /* 0 */ @@ -670,9 +660,9 @@ update_zoom_label (NavWinData *iwd) /* Update the zoom scale string */ g_snprintf (scale_str, MAX_SCALE_BUF, "%d:%d", - SCALEDEST (((GDisplay *)iwd->gdisp_ptr)), - SCALESRC (((GDisplay *)iwd->gdisp_ptr))); - + SCALEDEST (iwd->gdisp), + SCALESRC (iwd->gdisp)); + gtk_label_set_text (GTK_LABEL (iwd->zoom_label), scale_str); } @@ -689,8 +679,8 @@ update_zoom_adjustment (NavWinData *iwd) adj = GTK_ADJUSTMENT (iwd->zoom_adjustment); f = - ((gdouble) SCALEDEST (((GDisplay *) iwd->gdisp_ptr))) / - ((gdouble) SCALESRC (((GDisplay *) iwd->gdisp_ptr))); + ((gdouble) SCALEDEST (iwd->gdisp)) / + ((gdouble) SCALESRC (iwd->gdisp)); if (f < 1.0) { @@ -782,7 +772,7 @@ nav_window_preview_events (GtkWidget *widget, if(!iwd || iwd->frozen == TRUE) return FALSE; - gdisp = (GDisplay *) iwd->gdisp_ptr; + gdisp = iwd->gdisp; switch (event->type) { @@ -998,7 +988,7 @@ nav_window_expose_events (GtkWidget *widget, if(!iwd || iwd->frozen == TRUE) return FALSE; - gdisp = (GDisplay *) iwd->gdisp_ptr; + gdisp = iwd->gdisp; switch (event->type) { @@ -1025,12 +1015,12 @@ nav_window_expose_events (GtkWidget *widget, static gint nav_preview_update_do (NavWinData *iwd) { - /* If the gdisp_ptr has gone then don't do anything in this timer */ - if (!iwd->gdisp_ptr) + /* If the gdisp has gone then don't do anything in this timer */ + if (!iwd->gdisp) return FALSE; nav_window_update_preview (iwd); - nav_window_disp_area (iwd, iwd->gdisp_ptr); + nav_window_disp_area (iwd, iwd->gdisp); gtk_widget_queue_draw (iwd->preview); iwd->installedDirtyTimer = FALSE; @@ -1076,16 +1066,13 @@ navwindow_zoomin (GtkWidget *widget, gpointer data) { NavWinData *iwd; - GDisplay *gdisp; - iwd = (NavWinData *)data; + iwd = (NavWinData *) data; if(!iwd || iwd->frozen == TRUE) return; - gdisp = (GDisplay *) iwd->gdisp_ptr; - - change_scale (gdisp, ZOOMIN); + change_scale (iwd->gdisp, ZOOMIN); } static void @@ -1093,16 +1080,13 @@ navwindow_zoomout (GtkWidget *widget, gpointer data) { NavWinData *iwd; - GDisplay *gdisp; iwd = (NavWinData *)data; if (!iwd || iwd->frozen == TRUE) return; - gdisp = (GDisplay *) iwd->gdisp_ptr; - - change_scale (gdisp, ZOOMOUT); + change_scale (iwd->gdisp, ZOOMOUT); } static void @@ -1110,7 +1094,6 @@ zoom_adj_changed (GtkAdjustment *adj, gpointer data) { NavWinData *iwd; - GDisplay *gdisp; gint scalesrc; gint scaledest; @@ -1119,8 +1102,6 @@ zoom_adj_changed (GtkAdjustment *adj, if (!iwd || iwd->frozen == TRUE) return; - gdisp = (GDisplay *) iwd->gdisp_ptr; - if (adj->value < 0.0) { scalesrc = abs ((gint) adj->value - 1); @@ -1133,7 +1114,7 @@ zoom_adj_changed (GtkAdjustment *adj, } iwd->block_adj_sig = TRUE; - change_scale (gdisp, (scaledest * 100) + scalesrc); + change_scale (iwd->gdisp, (scaledest * 100) + scalesrc); iwd->block_adj_sig = FALSE; } @@ -1168,8 +1149,8 @@ nav_create_button_area (InfoDialog *info_win) /* user zoom ratio */ g_snprintf (scale_str, MAX_SCALE_BUF, "%d:%d", - SCALEDEST (((GDisplay *)iwd->gdisp_ptr)), - SCALESRC (((GDisplay *)iwd->gdisp_ptr))); + SCALEDEST (iwd->gdisp), + SCALESRC (iwd->gdisp)); label1 = gtk_label_new (scale_str); gtk_widget_show (label1); @@ -1256,12 +1237,12 @@ info_window_image_preview_new (InfoDialog *info_win) } NavWinData * -create_dummy_iwd (void *gdisp_ptr, +create_dummy_iwd (GDisplay *gdisp, NavWinType ptype) { NavWinData *iwd; - iwd = (NavWinData *) g_malloc (sizeof (NavWinData)); + iwd = g_new (NavWinData, 1); iwd->ptype = ptype; iwd->info_win = NULL; iwd->showingPreview = TRUE; @@ -1269,7 +1250,7 @@ create_dummy_iwd (void *gdisp_ptr, iwd->preview = NULL; iwd->zoom_label = NULL; iwd->zoom_adjustment = NULL; - iwd->gdisp_ptr = gdisp_ptr; + iwd->gdisp = gdisp; iwd->dispx = -1; iwd->dispy = -1; iwd->dispwidth = -1; @@ -1299,7 +1280,7 @@ create_dummy_iwd (void *gdisp_ptr, static InfoDialog *nav_window_auto = NULL; static gchar * -nav_window_title(GDisplay *gdisp) +nav_window_title (GDisplay *gdisp) { gchar *title; gchar *title_buf; @@ -1326,8 +1307,8 @@ nav_window_change_display (GimpContext *context, /* NOT USED */ NavWinData *iwd; gchar *title_buf; - iwd = (NavWinData *)nav_window_auto->user_data; - old_gdisp = (GDisplay *) iwd->gdisp_ptr; + iwd = (NavWinData *) nav_window_auto->user_data; + old_gdisp = iwd->gdisp; if (!nav_window_auto || gdisp == old_gdisp || !gdisp) { @@ -1347,7 +1328,7 @@ nav_window_change_display (GimpContext *context, /* NOT USED */ if (gimage && gimp_set_have (image_context, gimage)) { - iwd->gdisp_ptr = gdisp; + iwd->gdisp = gdisp; /* Update preview to new display */ nav_window_preview_resized (nav_window_auto); @@ -1382,9 +1363,10 @@ nav_window_follow_auto (void) if (!gdisp) return; - if(!nav_window_auto) + if (!nav_window_auto) { - nav_window_auto = nav_window_create ((void *) gdisp); + nav_window_auto = nav_window_create (gdisp); + gtk_signal_connect (GTK_OBJECT (gimp_context_get_user ()), "display_changed", GTK_SIGNAL_FUNC (nav_window_change_display), @@ -1400,20 +1382,17 @@ nav_window_follow_auto (void) InfoDialog * -nav_window_create (void *gdisp_ptr) +nav_window_create (GDisplay *gdisp) { InfoDialog *info_win; - GDisplay *gdisp; NavWinData *iwd; GtkWidget *container; gchar *title_buf; GimpImageBaseType type; - gdisp = (GDisplay *) gdisp_ptr; - type = gimp_image_base_type (gdisp->gimage); - title_buf = nav_window_title(gdisp); + title_buf = nav_window_title (gdisp); info_win = info_dialog_new (title_buf, gimp_standard_help_func, @@ -1434,7 +1413,7 @@ nav_window_create (void *gdisp_ptr) (GtkSignalFunc) nav_window_destroy_callback, info_win); - iwd = create_dummy_iwd (gdisp_ptr, NAV_WINDOW); + iwd = create_dummy_iwd (gdisp, NAV_WINDOW); info_win->user_data = iwd; iwd->info_win = info_win; @@ -1501,7 +1480,7 @@ nav_window_update_window_marker (InfoDialog *info_win) iwd->dispwidth, iwd->dispheight); /* Update to new size */ - nav_window_disp_area (iwd, iwd->gdisp_ptr); + nav_window_disp_area (iwd, iwd->gdisp); /* and redraw */ nav_window_draw_sqr (iwd, @@ -1563,14 +1542,14 @@ nav_window_get_gdisp (void) for (listPtr = list; listPtr; listPtr = g_slist_next (listPtr)) { gimage = GIMP_IMAGE (listPtr->data); - gdisp = gdisplays_check_valid (NULL,gimage); + gdisp = gdisplays_check_valid (NULL, gimage); if (gdisp) break; } g_slist_free (list); - return (gdisp); + return gdisp; } @@ -1589,12 +1568,12 @@ nav_window_free (GDisplay *del_gdisp, { if (nav_window_auto != NULL) { - GDisplay * gdisp; + GDisplay *gdisp; iwd = (NavWinData *) nav_window_auto->user_data; /* Only freeze if we are displaying the image we have deleted */ - if ((GDisplay *) iwd->gdisp_ptr != del_gdisp) + if (iwd->gdisp != del_gdisp) return; if (iwd->timer_id) @@ -1605,7 +1584,9 @@ nav_window_free (GDisplay *del_gdisp, gdisp = nav_window_get_gdisp (); if (gdisp) - nav_window_change_display (NULL, gdisp, NULL); + { + nav_window_change_display (NULL, gdisp, NULL); + } else { /* Clear window and freeze */ @@ -1615,7 +1596,7 @@ nav_window_free (GDisplay *del_gdisp, _("Navigation: No Image")); gtk_widget_set_sensitive (nav_window_auto->vbox, FALSE); - iwd->gdisp_ptr = NULL; + iwd->gdisp = NULL; gtk_widget_hide (GTK_WIDGET (nav_window_auto->shell)); } } @@ -1651,7 +1632,7 @@ nav_popup_click_handler (GtkWidget *widget, bevent = (GdkEventButton *)event; - if(!gdisp->nav_popup) + if (! gdisp->nav_popup) { /* popup a simplfied window with the nav box in it */ GtkWidget *frame; @@ -1674,14 +1655,14 @@ nav_popup_click_handler (GtkWidget *widget, gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_object_set_data (GTK_OBJECT (gdisp->nav_popup),"navpop_prt", (gpointer) iwp); - nav_window_disp_area (iwp, iwp->gdisp_ptr); + nav_window_disp_area (iwp, iwp->gdisp); } else { gtk_widget_hide (gdisp->nav_popup); iwp = (NavWinData *) gtk_object_get_data (GTK_OBJECT (gdisp->nav_popup), "navpop_prt"); - nav_window_disp_area (iwp, iwp->gdisp_ptr); + nav_window_disp_area (iwp, iwp->gdisp); nav_window_update_preview (iwp); } diff --git a/app/dodgeburn.c b/app/dodgeburn.c index 8ffe8968ce..396945d3b3 100644 --- a/app/dodgeburn.c +++ b/app/dodgeburn.c @@ -44,6 +44,12 @@ #include "libgimp/gimpintl.h" +/* Default values */ + +#define DODGEBURN_DEFAULT_TYPE DODGE +#define DODGEBURN_DEFAULT_EXPOSURE 50.0 +#define DODGEBURN_DEFAULT_MODE DODGEBURN_HIGHLIGHTS + /* the dodgeburn structures */ typedef struct _DodgeBurnOptions DodgeBurnOptions; @@ -67,36 +73,49 @@ struct _DodgeBurnOptions GimpLut *lut; }; -static void -dodgeburn_make_luts (PaintCore *, double, DodgeBurnType, DodgeBurnMode, - GimpLut *, GimpDrawable *); -static gfloat dodgeburn_highlights_lut_func (void *, int, int, gfloat); -static gfloat dodgeburn_midtones_lut_func (void *, int, int, gfloat); -static gfloat dodgeburn_shadows_lut_func (void *, int, int, gfloat); +static gpointer dodgeburn_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + +static void dodgeburn_make_luts (PaintCore *paint_cure, + gdouble db_exposure, + DodgeBurnType type, + DodgeBurnMode mode, + GimpLut *lut, + GimpDrawable *drawable); + +static gfloat dodgeburn_highlights_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); +static gfloat dodgeburn_midtones_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); +static gfloat dodgeburn_shadows_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); + +static void dodgeburn_motion (PaintCore *paint_core, + PaintPressureOptions *pressure_options, + gdouble dodgeburn_exposure, + GimpLut *lut, + GimpDrawable *drawable); +static void dodgeburn_init (PaintCore *paint_cure, + GimpDrawable *drawable); +static void dodgeburn_finish (PaintCore *paint_core, + GimpDrawable *drawable); -/* The dodge burn lookup tables */ -gfloat dodgeburn_highlights (void *, int, int, gfloat); -gfloat dodgeburn_midtones (void *, int, int, gfloat); -gfloat dodgeburn_shadows (void *, int, int, gfloat); /* the dodgeburn tool options */ static DodgeBurnOptions * dodgeburn_options = NULL; /* Non gui function */ -static double non_gui_exposure; +static gdouble non_gui_exposure; static GimpLut *non_gui_lut; -/* Default values */ -#define DODGEBURN_DEFAULT_TYPE DODGE -#define DODGEBURN_DEFAULT_EXPOSURE 50.0 -#define DODGEBURN_DEFAULT_MODE DODGEBURN_HIGHLIGHTS - -static void dodgeburn_motion (PaintCore *, - PaintPressureOptions *, - double, GimpLut *, GimpDrawable *); -static void dodgeburn_init (PaintCore *, GimpDrawable *); -static void dodgeburn_finish (PaintCore *, GimpDrawable *); /* functions */ @@ -198,24 +217,29 @@ dodgeburn_options_new (void) return options; } -void * +static gpointer dodgeburn_paint_func (PaintCore *paint_core, - GimpDrawable *drawable, - int state) + GimpDrawable *drawable, + PaintState state) { switch (state) { case INIT_PAINT: dodgeburn_init (paint_core, drawable); break; + case MOTION_PAINT: dodgeburn_motion (paint_core, dodgeburn_options->paint_options.pressure_options, dodgeburn_options->exposure, dodgeburn_options->lut, drawable); break; + case FINISH_PAINT: dodgeburn_finish (paint_core, drawable); break; + + default: + break; } return NULL; @@ -238,7 +262,8 @@ dodgeburn_init (PaintCore *paint_core, GimpDrawable *drawable) { /* Here we create the luts to do the painting with.*/ - dodgeburn_options->lut = gimp_lut_new(); + dodgeburn_options->lut = gimp_lut_new (); + dodgeburn_make_luts (paint_core, dodgeburn_options->exposure, dodgeburn_options->type, @@ -249,17 +274,17 @@ dodgeburn_init (PaintCore *paint_core, static void dodgeburn_make_luts (PaintCore *paint_core, - double db_exposure, + gdouble db_exposure, DodgeBurnType type, DodgeBurnMode mode, GimpLut *lut, GimpDrawable *drawable) { - GimpLutFunc lut_func; - int nchannels = gimp_drawable_bytes (drawable); + GimpLutFunc lut_func; + gint nchannels = gimp_drawable_bytes (drawable); static gfloat exposure; - exposure = (db_exposure) / 100.0; + exposure = db_exposure / 100.0; /* make the exposure negative if burn for luts*/ if (type == BURN) @@ -281,15 +306,15 @@ dodgeburn_make_luts (PaintCore *paint_core, break; } - gimp_lut_setup_exact (lut, - lut_func, (void *)&exposure, - nchannels); + gimp_lut_setup_exact (lut, + lut_func, (gpointer) &exposure, + nchannels); } static void dodgeburn_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -317,7 +342,7 @@ dodgeburn_modifier_key_func (Tool *tool, break; case GDK_Control_L: case GDK_Control_R: - if ( !(kevent->state & GDK_SHIFT_MASK) ) /* shift enables line draw mode */ + if (! (kevent->state & GDK_SHIFT_MASK)) /* shift enables line draw mode */ { switch (dodgeburn_options->type) { @@ -342,18 +367,18 @@ dodgeburn_modifier_key_func (Tool *tool, static void dodgeburn_cursor_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->toggled = (dodgeburn_options->type == BURN); - paint_core_cursor_update (tool, mevent, gdisp_ptr); + paint_core_cursor_update (tool, mevent, gdisp); } Tool * tools_new_dodgeburn (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! dodgeburn_options) @@ -420,25 +445,26 @@ dodgeburn_motion (PaintCore *paint_core, no paint from this stroke yet) */ { - gint x1, y1, x2, y2; - x1 = CLAMP (area->x, 0, drawable_width (drawable)); - y1 = CLAMP (area->y, 0, drawable_height (drawable)); - x2 = CLAMP (area->x + area->width, 0, drawable_width (drawable)); - y2 = CLAMP (area->y + area->height, 0, drawable_height (drawable)); + gint x1, y1, x2, y2; - if (!(x2 - x1) || !(y2 - y1)) - return; + x1 = CLAMP (area->x, 0, drawable_width (drawable)); + y1 = CLAMP (area->y, 0, drawable_height (drawable)); + x2 = CLAMP (area->x + area->width, 0, drawable_width (drawable)); + y2 = CLAMP (area->y + area->height, 0, drawable_height (drawable)); - /* get the original untouched image */ - orig = paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2); - srcPR.bytes = orig->bytes; - srcPR.x = 0; - srcPR.y = 0; - srcPR.w = x2 - x1; - srcPR.h = y2 - y1; - srcPR.rowstride = srcPR.bytes * orig->width; - srcPR.data = temp_buf_data (orig); - } + if (!(x2 - x1) || !(y2 - y1)) + return; + + /* get the original untouched image */ + orig = paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2); + srcPR.bytes = orig->bytes; + srcPR.x = 0; + srcPR.y = 0; + srcPR.w = x2 - x1; + srcPR.h = y2 - y1; + srcPR.rowstride = srcPR.bytes * orig->width; + srcPR.data = temp_buf_data (orig); + } /* tempPR will hold the dodgeburned region*/ tempPR.bytes = srcPR.bytes; @@ -482,10 +508,10 @@ dodgeburn_motion (PaintCore *paint_core, g_free (temp_data); } -static void * +static gpointer dodgeburn_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { dodgeburn_motion (paint_core, &non_gui_pressure_options, non_gui_exposure, non_gui_lut, drawable); @@ -495,13 +521,13 @@ dodgeburn_non_gui_paint_func (PaintCore *paint_core, gboolean dodgeburn_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - double exposure = DODGEBURN_DEFAULT_TYPE; - DodgeBurnType type = DODGEBURN_DEFAULT_TYPE; - DodgeBurnMode mode = DODGEBURN_DEFAULT_MODE; - DodgeBurnOptions *options = dodgeburn_options; + gdouble exposure = DODGEBURN_DEFAULT_TYPE; + DodgeBurnType type = DODGEBURN_DEFAULT_TYPE; + DodgeBurnMode mode = DODGEBURN_DEFAULT_MODE; + DodgeBurnOptions *options = dodgeburn_options; if (options) { @@ -510,18 +536,19 @@ dodgeburn_non_gui_default (GimpDrawable *drawable, mode = dodgeburn_options->mode; } - return dodgeburn_non_gui (drawable, exposure, type, mode, num_strokes, stroke_array); + return dodgeburn_non_gui (drawable, exposure, type, mode, + num_strokes, stroke_array); } gboolean dodgeburn_non_gui (GimpDrawable *drawable, - double exposure, + gdouble exposure, DodgeBurnType type, DodgeBurnMode mode, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -569,15 +596,15 @@ dodgeburn_non_gui (GimpDrawable *drawable, } static gfloat -dodgeburn_highlights_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_highlights_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat factor = 1.0 + exposure * (.333333); - + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat factor = 1.0 + exposure * (.333333); + if ((nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) return value; @@ -586,14 +613,14 @@ dodgeburn_highlights_lut_func (void *user_data, } static gfloat -dodgeburn_midtones_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_midtones_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat factor; + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat factor; if ((nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) @@ -603,19 +630,20 @@ dodgeburn_midtones_lut_func (void *user_data, factor = 1.0 - exposure * (.333333); else factor = 1/(1.0 + exposure); + return pow (value, factor); } static gfloat -dodgeburn_shadows_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_shadows_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat new_value; - gfloat factor; + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat new_value; + gfloat factor; if ( (nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) diff --git a/app/dodgeburn.h b/app/dodgeburn.h index 341fe445ea..edd02ba64d 100644 --- a/app/dodgeburn.h +++ b/app/dodgeburn.h @@ -34,21 +34,18 @@ typedef enum } DodgeBurnMode; -void * dodgeburn_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean dodgeburn_non_gui (GimpDrawable *, - gdouble, - DodgeBurnType, - DodgeBurnMode, - gint, - gdouble *); -gboolean dodgeburn_non_gui_default (GimpDrawable *, - gint, - gdouble *); +gboolean dodgeburn_non_gui (GimpDrawable *drawable, + gdouble exposure, + DodgeBurnType type, + DodgeBurnMode mode, + gint num_strokes, + gdouble *stroke_array); +gboolean dodgeburn_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_dodgeburn (void); -void tools_free_dodgeburn (Tool *); +void tools_free_dodgeburn (Tool *tool); #endif /* __DODGEBURN_H__ */ diff --git a/app/edit_selection.c b/app/edit_selection.c index ab759aa00c..dd68019c65 100644 --- a/app/edit_selection.c +++ b/app/edit_selection.c @@ -127,15 +127,12 @@ edit_selection_snap (GDisplay *gdisp, void init_edit_selection (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, GdkEventButton *bevent, EditType edit_type) { - GDisplay *gdisp; Layer *layer; - gint x, y; - - gdisp = (GDisplay *) gdisp_ptr; + gint x, y; undo_push_group_start (gdisp->gimage, LAYER_DISPLACE_UNDO); @@ -218,15 +215,12 @@ init_edit_selection (Tool *tool, void edit_selection_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { gint x; gint y; - GDisplay *gdisp; Layer *layer; - gdisp = (GDisplay *) gdisp_ptr; - /* resume the current selection and ungrab the pointer */ selection_resume (gdisp->select); @@ -312,11 +306,10 @@ edit_selection_button_release (Tool *tool, void edit_selection_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - gchar offset[STATUSBAR_SIZE]; - gdouble lastmotion_x, lastmotion_y; + gchar offset[STATUSBAR_SIZE]; + gdouble lastmotion_x, lastmotion_y; if (tool->state != ACTIVE) { @@ -324,8 +317,6 @@ edit_selection_motion (Tool *tool, return; } - gdisp = (GDisplay *) gdisp_ptr; - gdk_flush (); draw_core_pause (edit_select.core, tool); @@ -521,7 +512,7 @@ edit_selection_draw (Tool *tool) gint off_x, off_y; GdkSegment *segs_copy; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; select = gdisp->select; switch (edit_select.edit_type) @@ -637,7 +628,7 @@ edit_selection_draw (Tool *tool) void edit_selection_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -663,11 +654,8 @@ edit_selection_control (Tool *tool, void edit_selection_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - - gdisp = (GDisplay *) gdisp_ptr; gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_CURSOR, TOOL_TYPE_NONE, CURSOR_MODIFIER_MOVE, @@ -770,10 +758,9 @@ process_event_queue_keys (GdkEventKey *kevent, void edit_sel_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { gint inc_x, inc_y, mask_inc_x, mask_inc_y; - GDisplay *gdisp; Layer *layer; Layer *floating_layer; GSList *layer_list; @@ -781,8 +768,6 @@ edit_sel_arrow_keys_func (Tool *tool, layer = NULL; - gdisp = (GDisplay *) gdisp_ptr; - inc_x = process_event_queue_keys (kevent, GDK_Left, 0, -1, diff --git a/app/edit_selection.h b/app/edit_selection.h index c1e8914d71..1486849289 100644 --- a/app/edit_selection.h +++ b/app/edit_selection.h @@ -30,26 +30,26 @@ typedef enum void init_edit_selection (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, GdkEventButton *bevent, EditType edit_type); -void edit_selection_button_release (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -void edit_selection_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); -void edit_selection_control (Tool *tool, - ToolAction action, - gpointer gdisp_ptr); -void edit_selection_cursor_update (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); +void edit_selection_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void edit_selection_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +void edit_selection_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); +void edit_selection_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); void edit_selection_draw (Tool *tool); void edit_sel_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr); + GDisplay *gdisp); #endif /* __EDIT_SELECTION_H__ */ diff --git a/app/ellipse_select.c b/app/ellipse_select.c index b65dd27a06..a4235d237a 100644 --- a/app/ellipse_select.c +++ b/app/ellipse_select.c @@ -93,12 +93,10 @@ ellipse_select (GimpImage *gimage, void ellipse_select_draw (Tool *tool) { - GDisplay *gdisp; EllipseSelect *ellipse_sel; gint x1, y1; gint x2, y2; - gdisp = (GDisplay *) tool->gdisp_ptr; ellipse_sel = (EllipseSelect *) tool->private; x1 = MIN (ellipse_sel->x, ellipse_sel->x + ellipse_sel->w); @@ -106,8 +104,8 @@ ellipse_select_draw (Tool *tool) x2 = MAX (ellipse_sel->x, ellipse_sel->x + ellipse_sel->w); y2 = MAX (ellipse_sel->y, ellipse_sel->y + ellipse_sel->h); - gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); - gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); + gdisplay_transform_coords (tool->gdisp, x1, y1, &x1, &y1, 0); + gdisplay_transform_coords (tool->gdisp, x2, y2, &x2, &y2, 0); gdk_draw_arc (ellipse_sel->core->win, ellipse_sel->core->gc, 0, diff --git a/app/eraser.c b/app/eraser.c index 1ffa616c08..5467be7ede 100644 --- a/app/eraser.c +++ b/app/eraser.c @@ -42,7 +42,7 @@ #include "libgimp/gimpintl.h" -/* Defaults */ +/* Defaults */ #define ERASER_DEFAULT_HARD FALSE #define ERASER_DEFAULT_INCREMENTAL FALSE #define ERASER_DEFAULT_ANTI_ERASE FALSE @@ -50,6 +50,7 @@ /* the eraser structures */ typedef struct _EraserOptions EraserOptions; + struct _EraserOptions { PaintOptions paint_options; @@ -64,6 +65,18 @@ struct _EraserOptions }; +/* forward function declarations */ +static gpointer eraser_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void eraser_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + gboolean hard, + gboolean incremental, + gboolean anti_erase); + + /* the eraser tool options */ static EraserOptions *eraser_options = NULL; @@ -72,11 +85,6 @@ static gboolean non_gui_hard; static gboolean non_gui_incremental; static gboolean non_gui_anti_erase; -/* forward function declarations */ -static void eraser_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, - gboolean, gboolean, gboolean); - /* functions */ @@ -137,7 +145,7 @@ eraser_options_new (void) static void eraser_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -164,10 +172,10 @@ eraser_modifier_key_func (Tool *tool, } -void * +static gpointer eraser_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -196,8 +204,8 @@ eraser_paint_func (PaintCore *paint_core, Tool * tools_new_eraser (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! eraser_options) @@ -274,10 +282,10 @@ eraser_motion (PaintCore *paint_core, } -static void * +static gpointer eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { eraser_motion (paint_core, drawable, &non_gui_pressure_options, @@ -288,8 +296,8 @@ eraser_non_gui_paint_func (PaintCore *paint_core, gboolean eraser_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gboolean hardness = ERASER_DEFAULT_HARD; gboolean method = ERASER_DEFAULT_INCREMENTAL; @@ -310,13 +318,13 @@ eraser_non_gui_default (GimpDrawable *drawable, gboolean eraser_non_gui (GimpDrawable *drawable, - int num_strokes, - double *stroke_array, - int hardness, - int method, - int anti_erase) + gint num_strokes, + gdouble *stroke_array, + gint hardness, + gint method, + gboolean anti_erase) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -351,6 +359,6 @@ eraser_non_gui (GimpDrawable *drawable, paint_core_cleanup (); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/eraser.h b/app/eraser.h index 5a94a4c044..35eb35d4e2 100644 --- a/app/eraser.h +++ b/app/eraser.h @@ -20,21 +20,18 @@ #define __ERASER_H__ -void * eraser_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean eraser_non_gui (GimpDrawable *, - gint , - gdouble *, - gint , - gint , - gint ); -gboolean eraser_non_gui_default (GimpDrawable *, - gint , - gdouble *); +gboolean eraser_non_gui (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array, + gint hardness, + gint method, + gboolean anti_erase); +gboolean eraser_non_gui_default (GimpDrawable *paint_core, + gint num_strokes, + gdouble *stroke_array); -Tool * tools_new_eraser (void ); -void tools_free_eraser (Tool *); +Tool * tools_new_eraser (void); +void tools_free_eraser (Tool *tool); #endif /* __ERASER_H__ */ diff --git a/app/flip_tool.c b/app/flip_tool.c index c6db3abda3..b3ff8eba49 100644 --- a/app/flip_tool.c +++ b/app/flip_tool.c @@ -61,6 +61,16 @@ struct _FlipOptions GtkWidget *type_w[2]; }; + +/* local function prototypes */ + +static TileManager * flip_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + + +/* private variables */ + static FlipOptions *flip_options = NULL; /* functions */ @@ -117,7 +127,7 @@ flip_options_new (void) static void flip_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -139,17 +149,15 @@ flip_modifier_key_func (Tool *tool, break; } } - -TileManager * + +static TileManager * flip_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { TransformCore *transform_core; - GDisplay *gdisp; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (state) { @@ -179,14 +187,11 @@ flip_tool_transform (Tool *tool, static void flip_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; GimpDrawable *drawable; GdkCursorType ctype = GIMP_BAD_CURSOR; - gdisp = (GDisplay *) gdisp_ptr; - if ((drawable = gimp_image_active_drawable (gdisp->gimage))) { gint x, y; @@ -231,10 +236,10 @@ tools_new_flip (void) tools_register (FLIP, (ToolOptions *) flip_options); } - tool = transform_core_new (FLIP, FALSE); + tool = transform_core_new (FLIP, FALSE); private = tool->private; - private->trans_func = flip_tool_transform; + private->trans_func = flip_tool_transform; private->trans_info[FLIP_INFO] = -1.0; tool->modifier_key_func = flip_modifier_key_func; diff --git a/app/flip_tool.h b/app/flip_tool.h index 0f74a6bb3b..b0d3fe71c0 100644 --- a/app/flip_tool.h +++ b/app/flip_tool.h @@ -20,10 +20,6 @@ #define __FLIP_TOOL_H__ -TileManager * flip_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); - TileManager * flip_tool_flip (GimpImage *gimage, GimpDrawable *drawable, TileManager *orig, diff --git a/app/free_select.c b/app/free_select.c index fb7de4eb17..911826a8b6 100644 --- a/app/free_select.c +++ b/app/free_select.c @@ -51,6 +51,7 @@ /* the free selection structures */ typedef struct _FreeSelect FreeSelect; + struct _FreeSelect { DrawCore *core; /* Core select object */ @@ -65,6 +66,18 @@ struct _FreeSelect }; +/* local function prototypes */ + +static void free_select_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void free_select_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void free_select_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); + /* the free selection tool options */ static SelectionOptions * free_options = NULL; @@ -157,15 +170,13 @@ free_select (GImage *gimage, } } -void +static void free_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; FreeSelect *free_sel; - gdisp = (GDisplay *) gdisp_ptr; free_sel = (FreeSelect *) tool->private; gdk_pointer_grab (gdisp->canvas->window, FALSE, @@ -175,15 +186,15 @@ free_select_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; switch (free_sel->op) { case SELECTION_MOVE_MASK: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; case SELECTION_MOVE: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; default: break; @@ -197,17 +208,15 @@ free_select_button_press (Tool *tool, tool); } -void +static void free_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FreeSelect *free_sel; ScanConvertPoint *pts; - GDisplay *gdisp; gint i; - gdisp = (GDisplay *) gdisp_ptr; free_sel = (FreeSelect *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -251,15 +260,13 @@ free_select_button_release (Tool *tool, } } -void +static void free_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FreeSelect *free_sel; - GDisplay *gdisp; - gdisp = (GDisplay *) gdisp_ptr; free_sel = (FreeSelect *) tool->private; /* needed for immediate cursor update on modifier event */ @@ -273,7 +280,7 @@ free_select_motion (Tool *tool, { free_sel->op = SELECTION_REPLACE; - rect_select_cursor_update (tool, mevent, gdisp_ptr); + rect_select_cursor_update (tool, mevent, gdisp); } if (add_point (free_sel->num_pts, mevent->x, mevent->y)) @@ -291,7 +298,7 @@ free_select_motion (Tool *tool, static void free_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { FreeSelect *free_sel; diff --git a/app/free_select.h b/app/free_select.h index 98fd07dfd1..11b148c231 100644 --- a/app/free_select.h +++ b/app/free_select.h @@ -20,19 +20,6 @@ #define __FREE_SELECT_H__ -/* free select action functions */ - -void free_select_button_press (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -void free_select_button_release (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -void free_select_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); - - /* free select functions */ void free_select (GimpImage *gimage, diff --git a/app/fuzzy_select.c b/app/fuzzy_select.c index 906acff785..8180462164 100644 --- a/app/fuzzy_select.c +++ b/app/fuzzy_select.c @@ -71,6 +71,27 @@ struct _FuzzySelect }; +/* fuzzy select action functions */ +static void fuzzy_select_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void fuzzy_select_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void fuzzy_select_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void fuzzy_select_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void fuzzy_select_draw (Tool *tool); + +static GdkSegment * fuzzy_select_calculate (Tool *tool, + GDisplay *gdisp, + gint *nsegs); + + /* the fuzzy selection tool options */ static SelectionOptions *fuzzy_options = NULL; @@ -81,18 +102,6 @@ static gint num_segs = 0; Channel * fuzzy_mask = NULL; -/* fuzzy select action functions */ -static void fuzzy_select_button_press (Tool *, GdkEventButton *, gpointer); -static void fuzzy_select_button_release (Tool *, GdkEventButton *, gpointer); -static void fuzzy_select_motion (Tool *, GdkEventMotion *, gpointer); -static void fuzzy_select_control (Tool *, ToolAction, gpointer); - -static void fuzzy_select_draw (Tool *); - -/* fuzzy select action functions */ -static GdkSegment * fuzzy_select_calculate (Tool *, void *, int *); - - /*************************************/ /* Fuzzy selection apparatus */ @@ -390,12 +399,10 @@ fuzzy_select (GImage *gimage, static void fuzzy_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; FuzzySelect *fuzzy_sel; - gdisp = (GDisplay *) gdisp_ptr; fuzzy_sel = (FuzzySelect *) tool->private; fuzzy_sel->x = bevent->x; @@ -411,21 +418,21 @@ fuzzy_select_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; if (fuzzy_sel->op == SELECTION_MOVE_MASK) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; } else if (fuzzy_sel->op == SELECTION_MOVE) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; } /* calculate the region boundary */ - segs = fuzzy_select_calculate (tool, gdisp_ptr, &num_segs); + segs = fuzzy_select_calculate (tool, gdisp, &num_segs); draw_core_start (fuzzy_sel->core, gdisp->canvas->window, @@ -435,13 +442,11 @@ fuzzy_select_button_press (Tool *tool, static void fuzzy_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; - GDisplay *gdisp; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; fuzzy_sel = (FuzzySelect *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -471,13 +476,13 @@ fuzzy_select_button_release (Tool *tool, static void fuzzy_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; GdkSegment *new_segs; - gint num_new_segs; - gint diff_x, diff_y; - gdouble diff; + gint num_new_segs; + gint diff_x, diff_y; + gdouble diff; static guint last_time = 0; @@ -505,7 +510,7 @@ fuzzy_select_motion (Tool *tool, fuzzy_sel->first_threshold + diff); /* calculate the new fuzzy boundary */ - new_segs = fuzzy_select_calculate (tool, gdisp_ptr, &num_new_segs); + new_segs = fuzzy_select_calculate (tool, gdisp, &num_new_segs); /* stop the current boundary */ draw_core_pause (fuzzy_sel->core, tool); @@ -522,24 +527,22 @@ fuzzy_select_motion (Tool *tool, static GdkSegment * -fuzzy_select_calculate (Tool *tool, - void *gdisp_ptr, - gint *nsegs) +fuzzy_select_calculate (Tool *tool, + GDisplay *gdisp, + gint *nsegs) { PixelRegion maskPR; FuzzySelect *fuzzy_sel; - GDisplay *gdisp; Channel *new; GdkSegment *segs; BoundSeg *bsegs; GimpDrawable *drawable; - gint i; - gint x, y; - gboolean use_offsets; + gint i; + gint x, y; + gboolean use_offsets; fuzzy_sel = (FuzzySelect *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; - drawable = gimp_image_active_drawable (gdisp->gimage); + drawable = gimp_image_active_drawable (gdisp->gimage); gimp_add_busy_cursors (); @@ -605,7 +608,7 @@ fuzzy_select_draw (Tool *tool) static void fuzzy_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; diff --git a/app/fuzzy_select.h b/app/fuzzy_select.h index 0211a4b81f..42533a19db 100644 --- a/app/fuzzy_select.h +++ b/app/fuzzy_select.h @@ -20,14 +20,6 @@ #define __FUZZY_SELECT_H__ -extern Channel *fuzzy_mask; - - -/* fuzzy select functions */ -Tool * tools_new_fuzzy_select (void); -void tools_free_fuzzy_select (Tool *tool); - -/* functions */ Channel * find_contiguous_region (GimpImage *gimage, GimpDrawable *drawable, gboolean antialias, @@ -41,5 +33,11 @@ void fuzzy_select (GimpImage *gimage, gboolean feather, gdouble feather_radius); +Tool * tools_new_fuzzy_select (void); +void tools_free_fuzzy_select (Tool *tool); + + +extern Channel *fuzzy_mask; + #endif /* __FUZZY_SELECT_H__ */ diff --git a/app/gdisplay.c b/app/gdisplay.c index 1f09287c71..2a14c8b7f4 100644 --- a/app/gdisplay.c +++ b/app/gdisplay.c @@ -375,10 +375,10 @@ gdisplay_delete (GDisplay *gdisp) /* clear out the pointer to this gdisp from the active tool */ if (active_tool && - active_tool->gdisp_ptr == gdisp) + active_tool->gdisp == gdisp) { active_tool->drawable = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; } /* free the selection structure */ diff --git a/app/gimage.c b/app/gimage.c index d8c3df7424..76538373dd 100644 --- a/app/gimage.c +++ b/app/gimage.c @@ -123,9 +123,9 @@ gimage_invalidate_previews (void) static void gimage_dirty_handler (GimpImage *gimage) { - if (active_tool && !active_tool->preserve) + if (active_tool && ! active_tool->preserve) { - GDisplay* gdisp = active_tool->gdisp_ptr; + GDisplay* gdisp = active_tool->gdisp; if (gdisp) { @@ -149,8 +149,8 @@ gimlist_cb (gpointer image, gint gimage_image_count (void) { - GSList *list=NULL; - gint num_images = 0; + GSList *list = NULL; + gint num_images = 0; gimage_foreach (gimlist_cb, &list); num_images = g_slist_length (list); diff --git a/app/gui/commands.c b/app/gui/commands.c index 01f3a86d85..f534a7c2bd 100644 --- a/app/gui/commands.c +++ b/app/gui/commands.c @@ -1080,11 +1080,12 @@ tools_select_cmd_callback (GtkWidget *widget, gpointer callback_data, guint callback_action) { - ToolType tool_type; - GDisplay *gdisp; - gdisp = gdisplay_active (); + ToolType tool_type; + GDisplay *gdisp; tool_type = (ToolType) callback_action; + gdisp = gdisplay_active (); + gimp_context_set_tool (gimp_context_get_user (), tool_type); @@ -1101,12 +1102,12 @@ tools_select_cmd_callback (GtkWidget *widget, active_tool->drawable = gimp_image_active_drawable (gdisp->gimage); } - /* setting the gdisp_ptr here is a HACK to allow the tools' + /* setting the tool->gdisp here is a HACK to allow the tools' * dialog windows being hidden if the tool was selected from * a tear-off-menu and there was no mouse click in the display * before deleting it */ - active_tool->gdisp_ptr = gdisp; + active_tool->gdisp = gdisp; } /***** Filters *****/ diff --git a/app/gui/help-commands.c b/app/gui/help-commands.c index 01f3a86d85..f534a7c2bd 100644 --- a/app/gui/help-commands.c +++ b/app/gui/help-commands.c @@ -1080,11 +1080,12 @@ tools_select_cmd_callback (GtkWidget *widget, gpointer callback_data, guint callback_action) { - ToolType tool_type; - GDisplay *gdisp; - gdisp = gdisplay_active (); + ToolType tool_type; + GDisplay *gdisp; tool_type = (ToolType) callback_action; + gdisp = gdisplay_active (); + gimp_context_set_tool (gimp_context_get_user (), tool_type); @@ -1101,12 +1102,12 @@ tools_select_cmd_callback (GtkWidget *widget, active_tool->drawable = gimp_image_active_drawable (gdisp->gimage); } - /* setting the gdisp_ptr here is a HACK to allow the tools' + /* setting the tool->gdisp here is a HACK to allow the tools' * dialog windows being hidden if the tool was selected from * a tear-off-menu and there was no mouse click in the display * before deleting it */ - active_tool->gdisp_ptr = gdisp; + active_tool->gdisp = gdisp; } /***** Filters *****/ diff --git a/app/histogram_tool.c b/app/histogram_tool.c index 5cb56d168f..2545e1e05a 100644 --- a/app/histogram_tool.c +++ b/app/histogram_tool.c @@ -51,23 +51,32 @@ struct _HistogramTool gint x, y; /* coords for last mouse click */ }; + +/* histogram_tool action functions */ +static void histogram_tool_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static HistogramToolDialog * histogram_tool_dialog_new (void); + +static void histogram_tool_close_callback (GtkWidget *widget, + gpointer data); +static void histogram_tool_channel_callback (GtkWidget *widget, + gpointer data); +static void histogram_tool_gradient_draw (GtkWidget *gdisp, + gint channel); + +static void histogram_tool_dialog_update (HistogramToolDialog *htd, + gint start, + gint end); + + /* the histogram tool options */ static ToolOptions * histogram_tool_options = NULL; /* the histogram tool dialog */ static HistogramToolDialog * histogram_tool_dialog = NULL; -/* histogram_tool action functions */ -static void histogram_tool_control (Tool *, ToolAction, gpointer); - -static HistogramToolDialog * histogram_tool_dialog_new (void); - -static void histogram_tool_close_callback (GtkWidget *, gpointer); -static void histogram_tool_channel_callback (GtkWidget *, gpointer); -static void histogram_tool_gradient_draw (GtkWidget *, gint); - -static void histogram_tool_dialog_update (HistogramToolDialog *, - gint, gint); /* histogram_tool machinery */ @@ -78,13 +87,13 @@ histogram_tool_histogram_range (HistogramWidget *widget, gpointer data) { HistogramToolDialog *htd; - gdouble pixels; - gdouble count; + gdouble pixels; + gdouble count; htd = (HistogramToolDialog *) data; if (htd == NULL || htd->hist == NULL || - gimp_histogram_nchannels(htd->hist) <= 0) + gimp_histogram_nchannels (htd->hist) <= 0) return; pixels = gimp_histogram_get_count (htd->hist, 0, 255); @@ -148,7 +157,7 @@ histogram_tool_dialog_update (HistogramToolDialog *htd, static void histogram_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -171,8 +180,8 @@ histogram_tool_control (Tool *tool, Tool * tools_new_histogram_tool (void) { - Tool * tool; - HistogramTool * private; + Tool *tool; + HistogramTool *private; /* The tool options */ if (! histogram_tool_options) @@ -181,7 +190,7 @@ tools_new_histogram_tool (void) tools_register (HISTOGRAM, histogram_tool_options); } - tool = tools_new_tool (HISTOGRAM); + tool = tools_new_tool (HISTOGRAM); private = g_new0 (HistogramTool, 1); tool->scroll_lock = TRUE; /* Disallow scrolling */ @@ -402,7 +411,7 @@ histogram_tool_close_callback (GtkWidget *widget, gimp_dialog_hide (htd->shell); - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -426,7 +435,7 @@ histogram_tool_gradient_draw (GtkWidget *gradient, { guchar buf[HISTOGRAM_WIDTH * 3]; guchar r, g, b; - gint i; + gint i; r = g = b = 0; switch (channel) @@ -458,5 +467,3 @@ histogram_tool_gradient_draw (GtkWidget *gradient, gtk_widget_queue_draw (gradient); } - - diff --git a/app/histogram_tool.h b/app/histogram_tool.h index 825d44e25a..ae4076b462 100644 --- a/app/histogram_tool.h +++ b/app/histogram_tool.h @@ -48,6 +48,7 @@ struct _HistogramToolDialog gint color; }; + /* histogram_tool functions */ Tool * tools_new_histogram_tool (void); void tools_free_histogram_tool (Tool *tool); diff --git a/app/hue_saturation.c b/app/hue_saturation.c index 0caf2f0a6f..fde7e3de2b 100644 --- a/app/hue_saturation.c +++ b/app/hue_saturation.c @@ -43,8 +43,8 @@ #define HUE_PARTITION_MASK GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK #define SLIDER_WIDTH 200 -#define DA_WIDTH 40 -#define DA_HEIGHT 20 +#define DA_WIDTH 40 +#define DA_HEIGHT 20 #define HUE_PARTITION 0x0 #define HUE_SLIDER 0x1 @@ -62,6 +62,38 @@ struct _HueSaturation gint x, y; /* coords for last mouse click */ }; + +/* hue saturation action functions */ +static void hue_saturation_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static HueSaturationDialog * hue_saturation_dialog_new (void); + +static void hue_saturation_update (HueSaturationDialog *hsd, + gint); +static void hue_saturation_preview (HueSaturationDialog *hsd); +static void hue_saturation_reset_callback (GtkWidget *, + gpointer); +static void hue_saturation_ok_callback (GtkWidget *, + gpointer); +static void hue_saturation_cancel_callback (GtkWidget *, + gpointer); +static void hue_saturation_partition_callback (GtkWidget *, + gpointer); +static void hue_saturation_preview_update (GtkWidget *, + gpointer); +static void hue_saturation_hue_adjustment_update (GtkAdjustment *, + gpointer); +static void hue_saturation_lightness_adjustment_update (GtkAdjustment *, + gpointer); +static void hue_saturation_saturation_adjustment_update (GtkAdjustment *, + gpointer); +static gint hue_saturation_hue_partition_events (GtkWidget *, + GdkEvent *, + HueSaturationDialog *hsd); + + /* the hue-saturation tool options */ static ToolOptions *hue_saturation_options = NULL; @@ -82,27 +114,6 @@ static gint default_colors[6][3] = { 255, 0, 255 } }; -/* hue saturation action functions */ -static void hue_saturation_control (Tool *, ToolAction, gpointer); - -static HueSaturationDialog * hue_saturation_dialog_new (void); - -static void hue_saturation_update (HueSaturationDialog *, - gint); -static void hue_saturation_preview (HueSaturationDialog *); -static void hue_saturation_reset_callback (GtkWidget *, gpointer); -static void hue_saturation_ok_callback (GtkWidget *, gpointer); -static void hue_saturation_cancel_callback (GtkWidget *, gpointer); -static void hue_saturation_partition_callback (GtkWidget *, gpointer); -static void hue_saturation_preview_update (GtkWidget *, gpointer); -static void hue_saturation_hue_adjustment_update (GtkAdjustment *, - gpointer); -static void hue_saturation_lightness_adjustment_update (GtkAdjustment *, - gpointer); -static void hue_saturation_saturation_adjustment_update (GtkAdjustment *, - gpointer); -static gint hue_saturation_hue_partition_events (GtkWidget *, GdkEvent *, - HueSaturationDialog *); /* hue saturation machinery */ @@ -223,7 +234,7 @@ hue_saturation (PixelRegion *srcPR, static void hue_saturation_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -691,7 +702,7 @@ hue_saturation_ok_callback (GtkWidget *widget, active_tool->preserve = TRUE; if (!hsd->preview) - image_map_apply (hsd->image_map, hue_saturation, (void *) hsd); + image_map_apply (hsd->image_map, hue_saturation, (gpointer) hsd); if (hsd->image_map) image_map_commit (hsd->image_map); @@ -700,7 +711,7 @@ hue_saturation_ok_callback (GtkWidget *widget, hsd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -724,7 +735,7 @@ hue_saturation_cancel_callback (GtkWidget *widget, hsd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/hue_saturation.h b/app/hue_saturation.h index 80ee176884..5fec88fa53 100644 --- a/app/hue_saturation.h +++ b/app/hue_saturation.h @@ -54,6 +54,7 @@ struct _HueSaturationDialog gboolean preview; }; + Tool * tools_new_hue_saturation (void); void tools_free_hue_saturation (Tool *tool); diff --git a/app/image_map.c b/app/image_map.c index 7d6df05d34..72a9c1e6c7 100644 --- a/app/image_map.c +++ b/app/image_map.c @@ -107,16 +107,16 @@ image_map_do (gpointer data) } ImageMap -image_map_create (void *gdisp_ptr, +image_map_create (GDisplay *gdisp, GimpDrawable *drawable) { _ImageMap *_image_map; _image_map = g_new (_ImageMap, 1); - _image_map->gdisp = (GDisplay *) gdisp_ptr; - _image_map->drawable = drawable; + _image_map->gdisp = gdisp; + _image_map->drawable = drawable; _image_map->undo_tiles = NULL; - _image_map->state = WAITING; + _image_map->state = WAITING; /* Interactive tools based on image_map disable the undo stack */ /* to avert any unintented undo interaction through the UI */ diff --git a/app/image_map.h b/app/image_map.h index 8af03f09a8..d868cd2ff3 100644 --- a/app/image_map.h +++ b/app/image_map.h @@ -26,8 +26,8 @@ * MUST be followed with an image_map_commit or an image_map_abort call * The image map is no longer valid after a call to commit or abort. */ -ImageMap image_map_create (void *, - GimpDrawable *); +ImageMap image_map_create (GDisplay *gdisp, + GimpDrawable *drawable); void image_map_apply (ImageMap, ImageMapApplyFunc, void *); diff --git a/app/ink.c b/app/ink.c index 3673948f53..cf59f94716 100644 --- a/app/ink.c +++ b/app/ink.c @@ -57,7 +57,13 @@ /* the Ink structures */ -typedef Blob *(*BlobFunc) (gdouble, gdouble, gdouble, gdouble, gdouble, gdouble); +typedef Blob * (* BlobFunc) (gdouble, + gdouble, + gdouble, + gdouble, + gdouble, + gdouble); + typedef struct _InkTool InkTool; @@ -88,8 +94,8 @@ typedef struct _BrushWidget BrushWidget; struct _BrushWidget { - GtkWidget *widget; - gboolean state; + GtkWidget *widget; + gboolean state; }; typedef struct _InkOptions InkOptions; @@ -130,95 +136,109 @@ struct _InkOptions }; -/* the ink tool options */ -static InkOptions * ink_options = NULL; +/* local function prototypes */ + +static void ink_button_press (Tool *tool, + GdkEventButton *mevent, + GDisplay *gdisp); +static void ink_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void ink_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void ink_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void ink_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void time_smoother_add (InkTool *ink_tool, + guint32 value); +static gdouble time_smoother_result (InkTool *ink_tool); +static void time_smoother_init (InkTool *ink_tool, + guint32 initval); +static void dist_smoother_add (InkTool *ink_tool, + gdouble value); +static gdouble dist_smoother_result (InkTool *ink_tool); +static void dist_smoother_init (InkTool *ink_tool, + gdouble initval); + +static void ink_init (InkTool *ink_tool, + GimpDrawable *drawable, + gdouble x, + gdouble y); +static void ink_finish (InkTool *ink_tool, + GimpDrawable *drawable, + gint tool_id); +static void ink_cleanup (void); + +static void ink_type_update (GtkWidget *radio_button, + BlobFunc function); +static GdkPixmap * blob_pixmap (GdkColormap *colormap, + GdkVisual *visual, + BlobFunc function); +static void paint_blob (GdkDrawable *drawable, + GdkGC *gc, + Blob *blob); + +/* Rendering functions */ +static void ink_set_paint_area (InkTool *ink_tool, + GimpDrawable *drawable, + Blob *blob); +static void ink_paste (InkTool *ink_tool, + GimpDrawable *drawable, + Blob *blob); + +static void ink_to_canvas_tiles (InkTool *ink_tool, + Blob *blob, + guchar *color); + +static void ink_set_undo_tiles (GimpDrawable *drawable, + gint x, + gint y, + gint w, + gint h); +static void ink_set_canvas_tiles (gint x, + gint y, + gint w, + gint h); + +/* Brush pseudo-widget callbacks */ +static void brush_widget_active_rect (BrushWidget *brush_widget, + GtkWidget *widget, + GdkRectangle *rect); +static void brush_widget_realize (GtkWidget *widget); +static void brush_widget_expose (GtkWidget *widget, + GdkEventExpose *event, + BrushWidget *brush_widget); +static void brush_widget_button_press (GtkWidget *widget, + GdkEventButton *event, + BrushWidget *brush_widget); +static void brush_widget_button_release (GtkWidget *widget, + GdkEventButton *event, + BrushWidget *brush_widget); +static void brush_widget_motion_notify (GtkWidget *widget, + GdkEventMotion *event, + BrushWidget *brush_widget); + /* local variables */ +/* the ink tool options */ +static InkOptions *ink_options = NULL; + /* undo blocks variables */ -static TileManager * undo_tiles = NULL; +static TileManager *undo_tiles = NULL; /* Tiles used to render the stroke at 1 byte/pp */ -static TileManager * canvas_tiles = NULL; +static TileManager *canvas_tiles = NULL; /* Flat buffer that is used to used to render the dirty region * for composition onto the destination drawable */ -static TempBuf * canvas_buf = NULL; - - -/* local function prototypes */ - -static void ink_button_press (Tool *, GdkEventButton *, gpointer); -static void ink_button_release (Tool *, GdkEventButton *, gpointer); -static void ink_motion (Tool *, GdkEventMotion *, gpointer); -static void ink_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void ink_control (Tool *, ToolAction, gpointer); - -static void time_smoother_add (InkTool* ink_tool, guint32 value); -static gdouble time_smoother_result (InkTool* ink_tool); -static void time_smoother_init (InkTool* ink_tool, guint32 initval); -static void dist_smoother_add (InkTool* ink_tool, gdouble value); -static gdouble dist_smoother_result (InkTool* ink_tool); -static void dist_smoother_init (InkTool* ink_tool, gdouble initval); - -static void ink_init (InkTool *ink_tool, - GimpDrawable *drawable, - double x, - double y); -static void ink_finish (InkTool *ink_tool, - GimpDrawable *drawable, - int tool_id); -static void ink_cleanup (void); - -static void ink_type_update (GtkWidget *radio_button, - BlobFunc function); -static GdkPixmap *blob_pixmap (GdkColormap *colormap, - GdkVisual *visual, - BlobFunc function); -static void paint_blob (GdkDrawable *drawable, - GdkGC *gc, - Blob *blob); - -/* Rendering functions */ -static void ink_set_paint_area (InkTool *ink_tool, - GimpDrawable *drawable, - Blob *blob); -static void ink_paste (InkTool *ink_tool, - GimpDrawable *drawable, - Blob *blob); - -static void ink_to_canvas_tiles (InkTool *ink_tool, - Blob *blob, - guchar *color); - -static void ink_set_undo_tiles (GimpDrawable *drawable, - int x, - int y, - int w, - int h); -static void ink_set_canvas_tiles(int x, - int y, - int w, - int h); - -/* Brush pseudo-widget callbacks */ -static void brush_widget_active_rect (BrushWidget *brush_widget, - GtkWidget *w, - GdkRectangle *rect); -static void brush_widget_realize (GtkWidget *w); -static void brush_widget_expose (GtkWidget *w, - GdkEventExpose *event, - BrushWidget *brush_widget); -static void brush_widget_button_press (GtkWidget *w, - GdkEventButton *event, - BrushWidget *brush_widget); -static void brush_widget_button_release (GtkWidget *w, - GdkEventButton *event, - BrushWidget *brush_widget); -static void brush_widget_motion_notify (GtkWidget *w, - GdkEventMotion *event, - BrushWidget *brush_widget); +static TempBuf *canvas_buf = NULL; /* functions */ @@ -798,15 +818,13 @@ ink_pen_ellipse (gdouble x_center, gdouble y_center, static void ink_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { gdouble x, y; - GDisplay *gdisp; InkTool *ink_tool; GimpDrawable *drawable; Blob *b; - gdisp = (GDisplay *) gdisp_ptr; ink_tool = (InkTool *) tool->private; /* Keep the coordinates of the target */ @@ -816,8 +834,8 @@ ink_button_press (Tool *tool, ink_init (ink_tool, drawable, x, y); - tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->state = ACTIVE; + tool->gdisp = gdisp; tool->paused_count = 0; /* pause the current selection and grab the pointer */ @@ -834,7 +852,7 @@ ink_button_press (Tool *tool, GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; b = ink_pen_ellipse (x, y, @@ -856,14 +874,12 @@ ink_button_press (Tool *tool, static void ink_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - GImage * gimage; - InkTool * ink_tool; + GImage *gimage; + InkTool *ink_tool; - gdisp = (GDisplay *) gdisp_ptr; - gimage = gdisp->gimage; + gimage = gdisp->gimage; ink_tool = (InkTool *) tool->private; /* resume the current selection and ungrab the pointer */ @@ -965,21 +981,18 @@ time_smoother_add (InkTool* ink_tool, guint32 value) static void ink_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - InkTool *ink_tool; + InkTool *ink_tool; GimpDrawable *drawable; - Blob *b, *blob_union; + Blob *b, *blob_union; - double x, y; - double pressure; - double velocity; - double dist; + gdouble x, y; + gdouble pressure; + gdouble velocity; + gdouble dist; gdouble lasttime, thistime; - - gdisp = (GDisplay *) gdisp_ptr; ink_tool = (InkTool *) tool->private; gdisplay_untransform_coords_f (gdisp, mevent->x, mevent->y, &x, &y, TRUE); @@ -1034,14 +1047,11 @@ ink_motion (Tool *tool, static void ink_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + gint x, y; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -1073,7 +1083,7 @@ ink_cursor_update (Tool *tool, static void ink_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { InkTool *ink_tool; @@ -1099,8 +1109,10 @@ ink_control (Tool *tool, } static void -ink_init (InkTool *ink_tool, GimpDrawable *drawable, - double x, double y) +ink_init (InkTool *ink_tool, + GimpDrawable *drawable, + gdouble x, + gdouble y) { /* free the block structures */ if (undo_tiles) @@ -1123,7 +1135,9 @@ ink_init (InkTool *ink_tool, GimpDrawable *drawable, } static void -ink_finish (InkTool *ink_tool, GimpDrawable *drawable, int tool_id) +ink_finish (InkTool *ink_tool, + GimpDrawable *drawable, + gint tool_id) { /* push an undo */ drawable_apply_image (drawable, ink_tool->x1, ink_tool->y1, @@ -1178,9 +1192,9 @@ ink_set_paint_area (InkTool *ink_tool, GimpDrawable *drawable, Blob *blob) { - int x, y, width, height; - int x1, y1, x2, y2; - int bytes; + gint x, y, width, height; + gint x1, y1, x2, y2; + gint bytes; blob_bounds (blob, &x, &y, &width, &height); @@ -1203,10 +1217,12 @@ enum { ROW_START, ROW_STOP }; /* The insertion sort here, for SUBSAMPLE = 8, tends to beat out * qsort() by 4x with CFLAGS=-O2, 2x with CFLAGS=-g */ -static void insert_sort (int *data, int n) +static void +insert_sort (gint *data, + gint n) { - int i, j, k; - int tmp1, tmp2; + gint i, j, k; + gint tmp1, tmp2; for (i=2; i<2*n; i+=2) { @@ -1230,7 +1246,7 @@ static void insert_sort (int *data, int n) static void fill_run (guchar *dest, guchar alpha, - int w) + gint w) { if (alpha == 255) { @@ -1247,17 +1263,20 @@ fill_run (guchar *dest, } static void -render_blob_line (Blob *blob, guchar *dest, - int x, int y, int width) +render_blob_line (Blob *blob, + guchar *dest, + gint x, + gint y, + gint width) { - int buf[4*SUBSAMPLE]; - int *data = buf; - int n = 0; - int i, j; - int current = 0; /* number of filled rows at this point - * in the scan line */ - - int last_x; + gint buf[4*SUBSAMPLE]; + gint *data = buf; + gint n = 0; + gint i, j; + gint current = 0; /* number of filled rows at this point + * in the scan line + */ + gint last_x; /* Sort start and ends for all lines */ @@ -1309,8 +1328,8 @@ render_blob_line (Blob *blob, guchar *dest, last_x = 0; for (i=0; icore = draw_core_new (ink_no_draw); + private->core = draw_core_new (ink_no_draw); private->last_blob = NULL; tool->private = private; @@ -1570,7 +1593,7 @@ tools_new_ink (void) void tools_free_ink (Tool *tool) { - InkTool * ink_tool; + InkTool *ink_tool; ink_tool = (InkTool *) tool->private; diff --git a/app/ink.h b/app/ink.h index 3dfb214846..9c35db1c6b 100644 --- a/app/ink.h +++ b/app/ink.h @@ -23,6 +23,7 @@ Tool * tools_new_ink (void); void tools_free_ink (Tool *tool); + /* Procedure definition and marshalling function */ extern ProcRecord ink_proc; diff --git a/app/iscissors.c b/app/iscissors.c index cf075959c2..793f3b32f3 100644 --- a/app/iscissors.c +++ b/app/iscissors.c @@ -133,6 +133,7 @@ struct _iscissors }; typedef struct _IScissorsOptions IScissorsOptions; + struct _IScissorsOptions { SelectionOptions selection_options; @@ -187,7 +188,7 @@ struct _IScissorsOptions /* static variables */ /* where to move on a given link direction */ -static int move [8][2] = +static gint move [8][2] = { { 1, 0 }, { 0, 1 }, @@ -271,57 +272,72 @@ static IScissorsOptions *iscissors_options = NULL; /***********************************************************************/ /* Local function prototypes */ -static void iscissors_button_press (Tool *, GdkEventButton *, gpointer); -static void iscissors_button_release (Tool *, GdkEventButton *, gpointer); -static void iscissors_motion (Tool *, GdkEventMotion *, gpointer); -static void iscissors_oper_update (Tool *, GdkEventMotion *, gpointer); -static void iscissors_modifier_update (Tool *, GdkEventKey *, gpointer); -static void iscissors_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void iscissors_control (Tool *, ToolAction, gpointer); +static void iscissors_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void iscissors_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void iscissors_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void iscissors_oper_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void iscissors_modifier_update (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void iscissors_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void iscissors_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); -static void iscissors_reset (Iscissors *iscissors); -static void iscissors_draw (Tool *tool); +static void iscissors_reset (Iscissors *iscissors); +static void iscissors_draw (Tool *tool); -static TileManager * gradient_map_new (GImage *gimage); +static TileManager * gradient_map_new (GImage *gimage); -static void find_optimal_path (TileManager *gradient_map, - TempBuf *dp_buf, - gint x1, - gint y1, - gint x2, - gint y2, - gint xs, - gint ys); -static void find_max_gradient (Iscissors *iscissors, - GImage *gimage, - gint *x, - gint *y); -static void calculate_curve (Tool *tool, - ICurve *curve); -static void iscissors_draw_curve (GDisplay *gdisp, - Iscissors *iscissors, - ICurve *curve); -static void iscissors_free_icurves (GSList *list); -static void iscissors_free_buffers (Iscissors *iscissors); +static void find_optimal_path (TileManager *gradient_map, + TempBuf *dp_buf, + gint x1, + gint y1, + gint x2, + gint y2, + gint xs, + gint ys); +static void find_max_gradient (Iscissors *iscissors, + GImage *gimage, + gint *x, + gint *y); +static void calculate_curve (Tool *tool, + ICurve *curve); +static void iscissors_draw_curve (GDisplay *gdisp, + Iscissors *iscissors, + ICurve *curve); +static void iscissors_free_icurves (GSList *list); +static void iscissors_free_buffers (Iscissors *iscissors); -static gint mouse_over_vertex (Iscissors *iscissors, - gint x, - gint y); -static gboolean clicked_on_vertex (Tool *tool); -static GSList * mouse_over_curve (Iscissors *iscissors, - gint x, - gint y); -static gboolean clicked_on_curve (Tool *tool); +static gint mouse_over_vertex (Iscissors *iscissors, + gint x, + gint y); +static gboolean clicked_on_vertex (Tool *tool); +static GSList * mouse_over_curve (Iscissors *iscissors, + gint x, + gint y); +static gboolean clicked_on_curve (Tool *tool); static void precalculate_arrays (void); -static GPtrArray * plot_pixels (Iscissors *iscissors, - TempBuf *dp_buf, - gint x1, - gint y1, - gint xs, - gint ys, - gint xe, - gint ye); +static GPtrArray * plot_pixels (Iscissors *iscissors, + TempBuf *dp_buf, + gint x1, + gint y1, + gint xs, + gint ys, + gint xe, + gint ye); + static void iscissors_options_reset (void) @@ -412,23 +428,21 @@ tools_free_iscissors (Tool *tool) static void iscissors_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; GimpDrawable *drawable; Iscissors *iscissors; gboolean grab_pointer = FALSE; - gdisp = (GDisplay *) gdisp_ptr; iscissors = (Iscissors *) tool->private; - drawable = gimp_image_active_drawable (gdisp->gimage); + drawable = gimp_image_active_drawable (gdisp->gimage); gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &iscissors->x, &iscissors->y, FALSE, FALSE); /* If the tool was being used in another image...reset it */ - if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp != tool->gdisp) { /*iscissors->draw = DRAW_CURVE; XXX? */ draw_core_stop (iscissors->core, tool); @@ -436,19 +450,19 @@ iscissors_button_press (Tool *tool, } tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; switch (iscissors->state) { case NO_ACTION: #if 0 /* XXX what's this supposed to do? */ - if (!(bevent->state & GDK_SHIFT_MASK) && - !(bevent->state & GDK_CONTROL_MASK)) - if (selection_point_inside (gdisp->select, gdisp_ptr, + if (! (bevent->state & GDK_SHIFT_MASK) && + ! (bevent->state & GDK_CONTROL_MASK)) + if (selection_point_inside (gdisp->select, gdisp, bevent->x, bevent->y)) { - init_edit_selection (tool, gdisp->select, gdisp_ptr, + init_edit_selection (tool, gdisp->select, gdisp, bevent->x, bevent->y); return; } @@ -534,17 +548,16 @@ iscissors_button_press (Tool *tool, static void iscissors_convert (Iscissors *iscissors, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp = (GDisplay *) gdisp_ptr; ScanConverter *sc; ScanConvertPoint *pts; - guint npts; - GSList *list; - ICurve *icurve; - guint packed; - gint i; - gint index; + guint npts; + GSList *list; + ICurve *icurve; + guint packed; + gint i; + gint index; sc = scan_converter_new (gdisp->gimage->width, gdisp->gimage->height, 1); @@ -583,13 +596,11 @@ iscissors_convert (Iscissors *iscissors, static void iscissors_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; ICurve *curve; - gdisp = (GDisplay *) gdisp_ptr; iscissors = (Iscissors *) tool->private; TRC (("iscissors_button_release\n")); @@ -694,18 +705,16 @@ iscissors_button_release (Tool *tool, /* convert the curves into a region */ if (iscissors->connected) - iscissors_convert (iscissors, gdisp_ptr); + iscissors_convert (iscissors, gdisp); } static void iscissors_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; - gdisp = (GDisplay *) gdisp_ptr; iscissors = (Iscissors *) tool->private; if (tool->state != ACTIVE || iscissors->state == NO_ACTION) @@ -763,16 +772,16 @@ iscissors_motion (Tool *tool, static void iscissors_draw (Tool *tool) { - GDisplay *gdisp; + GDisplay *gdisp; Iscissors *iscissors; - ICurve *curve; - GSList *list; - int tx1, ty1, tx2, ty2; - int txn, tyn; + ICurve *curve; + GSList *list; + gint tx1, ty1, tx2, ty2; + gint txn, tyn; TRC (("iscissors_draw\n")); - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; iscissors = (Iscissors *) tool->private; gdisplay_transform_coords (gdisp, iscissors->ix, iscissors->iy, &tx1, &ty1, @@ -900,14 +909,12 @@ iscissors_draw_curve (GDisplay *gdisp, static void iscissors_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; gint x, y; iscissors = (Iscissors *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -954,7 +961,7 @@ iscissors_oper_update (Tool *tool, static void iscissors_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; SelectOps op; @@ -997,13 +1004,11 @@ iscissors_modifier_update (Tool *tool, static void iscissors_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; iscissors = (Iscissors *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (iscissors->op) { @@ -1073,7 +1078,7 @@ iscissors_cursor_update (Tool *tool, static void iscissors_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors * iscissors; Iscissors_draw draw; @@ -1409,11 +1414,11 @@ calculate_curve (Tool *tool, { GDisplay *gdisp; Iscissors *iscissors; - gint x, y, dir; - gint xs, ys, xe, ye; - gint x1, y1, x2, y2; - gint width, height; - gint ewidth, eheight; + gint x, y, dir; + gint xs, ys, xe, ye; + gint x1, y1, x2, y2; + gint width, height; + gint ewidth, eheight; TRC (("calculate_curve(%p, %p)\n", tool, curve)); @@ -1427,7 +1432,7 @@ calculate_curve (Tool *tool, * structure. */ - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; iscissors = (Iscissors *) tool->private; /* Get the bounding box */ diff --git a/app/levels.c b/app/levels.c index 7814babaaa..adcf1c9641 100644 --- a/app/levels.c +++ b/app/levels.c @@ -46,6 +46,7 @@ #include "libgimp/gimpintl.h" + #define LOW_INPUT 0x1 #define GAMMA 0x2 #define HIGH_INPUT 0x4 @@ -72,6 +73,7 @@ GDK_BUTTON1_MOTION_MASK | \ GDK_POINTER_MOTION_HINT_MASK + /* the levels structures */ typedef struct _Levels Levels; @@ -121,6 +123,61 @@ struct _LevelsDialog GimpLut *lut; }; + +/* levels action functions */ +static void levels_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static LevelsDialog * levels_dialog_new (void); + +static void levels_calculate_transfers (LevelsDialog *ld); +static void levels_update (LevelsDialog *ld, + gint channel); +static void levels_preview (LevelsDialog *ld); +static void levels_channel_callback (GtkWidget *widget, + gpointer data); +static void levels_reset_callback (GtkWidget *widget, + gpointer data); +static void levels_ok_callback (GtkWidget *widget, + gpointer data); +static void levels_cancel_callback (GtkWidget *widget, + gpointer data); +static void levels_auto_callback (GtkWidget *widget, + gpointer data); +static void levels_load_callback (GtkWidget *widget, + gpointer data); +static void levels_save_callback (GtkWidget *widget, + gpointer data); +static void levels_preview_update (GtkWidget *widget, + gpointer data); +static void levels_low_input_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_gamma_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_high_input_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_low_output_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_high_output_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static gint levels_input_da_events (GtkWidget *widget, + GdkEvent *event, + LevelsDialog *ld); +static gint levels_output_da_events (GtkWidget *widget, + GdkEvent *event, + LevelsDialog *ld); + +static void file_dialog_create (GtkWidget *widget); +static void file_dialog_ok_callback (GtkWidget *widget, + gpointer data); +static void file_dialog_cancel_callback (GtkWidget *widget, + gpointer data); + +static gboolean levels_read_from_file (FILE *f); +static void levels_write_to_file (FILE *f); + + /* the levels tool options */ static ToolOptions *levels_options = NULL; @@ -133,46 +190,13 @@ static gboolean load_save; static GtkWidget *color_option_items[5]; -/* levels action functions */ -static void levels_control (Tool *, ToolAction, gpointer); - -static LevelsDialog * levels_dialog_new (void); - -static void levels_calculate_transfers (LevelsDialog *); -static void levels_update (LevelsDialog *, gint); -static void levels_preview (LevelsDialog *); -static void levels_channel_callback (GtkWidget *, gpointer); -static void levels_reset_callback (GtkWidget *, gpointer); -static void levels_ok_callback (GtkWidget *, gpointer); -static void levels_cancel_callback (GtkWidget *, gpointer); -static void levels_auto_callback (GtkWidget *, gpointer); -static void levels_load_callback (GtkWidget *, gpointer); -static void levels_save_callback (GtkWidget *, gpointer); -static void levels_preview_update (GtkWidget *, gpointer); -static void levels_low_input_adjustment_update (GtkAdjustment *, gpointer); -static void levels_gamma_adjustment_update (GtkAdjustment *, gpointer); -static void levels_high_input_adjustment_update (GtkAdjustment *, gpointer); -static void levels_low_output_adjustment_update (GtkAdjustment *, gpointer); -static void levels_high_output_adjustment_update (GtkAdjustment *, gpointer); -static gint levels_input_da_events (GtkWidget *, GdkEvent *, - LevelsDialog *); -static gint levels_output_da_events (GtkWidget *, GdkEvent *, - LevelsDialog *); - -static void file_dialog_create (GtkWidget *); -static void file_dialog_ok_callback (GtkWidget *, gpointer); -static void file_dialog_cancel_callback (GtkWidget *, gpointer); - -static gboolean levels_read_from_file (FILE *f); -static void levels_write_to_file (FILE *f); - /* levels action functions */ static void levels_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -1028,7 +1052,7 @@ levels_ok_callback (GtkWidget *widget, ld->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -1052,7 +1076,7 @@ levels_cancel_callback (GtkWidget *widget, ld->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/magnify.c b/app/magnify.c index 25a9e8c90c..1d60a74324 100644 --- a/app/magnify.c +++ b/app/magnify.c @@ -70,25 +70,37 @@ struct _MagnifyOptions }; -/* the magnify tool options */ -static MagnifyOptions *magnify_options = NULL; - - /* magnify action functions */ -static void magnify_button_press (Tool *, GdkEventButton *, gpointer); -static void magnify_button_release (Tool *, GdkEventButton *, gpointer); -static void magnify_motion (Tool *, GdkEventMotion *, gpointer); -static void magnify_modifier_update (Tool *, GdkEventKey *, gpointer); -static void magnify_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void magnify_control (Tool *, ToolAction, gpointer); +static void magnify_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void magnify_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void magnify_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void magnify_modifier_update (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void magnify_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void magnify_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); /* magnify utility functions */ -static void zoom_in (gint *src, - gint *dest, - gint scale); -static void zoom_out (gint *src, - gint *dest, - gint scale); +static void zoom_in (gint *src, + gint *dest, + gint scale); +static void zoom_out (gint *src, + gint *dest, + gint scale); + + +/* the magnify tool options */ +static MagnifyOptions *magnify_options = NULL; /* magnify tool options functions */ @@ -193,13 +205,11 @@ zoom_out (gint *src, static void magnify_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; Magnify *magnify; - gint x, y; + gint x, y; - gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, TRUE, 0); @@ -216,7 +226,7 @@ magnify_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; draw_core_start (magnify->core, gdisp->canvas->window, @@ -227,17 +237,15 @@ magnify_button_press (Tool *tool, static void magnify_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Magnify *magnify; - GDisplay *gdisp; - gint win_width, win_height; - gint width, height; - gint scalesrc, scaledest; - gint scale; - gint x1, y1, x2, y2, w, h; + gint win_width, win_height; + gint width, height; + gint scalesrc, scaledest; + gint scale; + gint x1, y1, x2, y2, w, h; - gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -297,16 +305,14 @@ magnify_button_release (Tool *tool, static void magnify_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Magnify *magnify; - GDisplay *gdisp; - gint x, y; + gint x, y; if (tool->state != ACTIVE) return; - gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; draw_core_pause (magnify->core, tool); @@ -322,7 +328,7 @@ magnify_motion (Tool *tool, static void magnify_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -344,12 +350,8 @@ magnify_modifier_update (Tool *tool, static void magnify_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - - gdisp = (GDisplay *) gdisp_ptr; - if (magnify_options->type == ZOOMIN) { gdisplay_install_tool_cursor (gdisp, GIMP_ZOOM_CURSOR, @@ -370,11 +372,9 @@ magnify_cursor_update (Tool *tool, void magnify_draw (Tool *tool) { - GDisplay *gdisp; Magnify *magnify; - gint x1, y1, x2, y2; + gint x1, y1, x2, y2; - gdisp = (GDisplay *) tool->gdisp_ptr; magnify = (Magnify *) tool->private; x1 = MIN (magnify->x, magnify->x + magnify->w); @@ -382,8 +382,8 @@ magnify_draw (Tool *tool) x2 = MAX (magnify->x, magnify->x + magnify->w); y2 = MAX (magnify->y, magnify->y + magnify->h); - gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); - gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); + gdisplay_transform_coords (tool->gdisp, x1, y1, &x1, &y1, 0); + gdisplay_transform_coords (tool->gdisp, x2, y2, &x2, &y2, 0); gdk_draw_rectangle (magnify->core->win, magnify->core->gc, 0, x1, y1, (x2 - x1), (y2 - y1)); @@ -393,7 +393,7 @@ magnify_draw (Tool *tool) static void magnify_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { Magnify *magnify; @@ -422,7 +422,7 @@ magnify_control (Tool *tool, Tool * tools_new_magnify (void) { - Tool *tool; + Tool *tool; Magnify *private; /* The tool options */ @@ -432,7 +432,7 @@ tools_new_magnify (void) tools_register (MAGNIFY, (ToolOptions *) magnify_options); } - tool = tools_new_tool (MAGNIFY); + tool = tools_new_tool (MAGNIFY); private = g_new0 (Magnify, 1); private->core = draw_core_new (magnify_draw); diff --git a/app/measure.c b/app/measure.c index 4e12bec9e5..70bf89a35c 100644 --- a/app/measure.c +++ b/app/measure.c @@ -47,6 +47,9 @@ #define ARC_RADIUS_2 1100 #define STATUSBAR_SIZE 128 +/* maximum information buffer size */ +#define MAX_INFO_BUF 16 + /* possible measure functions */ typedef enum { @@ -89,8 +92,27 @@ struct _MeasureOptions }; -/* maximum information buffer size */ -#define MAX_INFO_BUF 16 +/* local function prototypes */ +static void measure_tool_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void measure_tool_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void measure_tool_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void measure_tool_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void measure_tool_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); + +static void measure_tool_info_window_close_callback (GtkWidget *widget, + gpointer data); +static void measure_tool_info_update (void); + static MeasureOptions *measure_tool_options = NULL; @@ -100,28 +122,6 @@ static gchar distance_buf[MAX_INFO_BUF]; static gchar angle_buf[MAX_INFO_BUF]; -/* local function prototypes */ -static void measure_tool_button_press (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -static void measure_tool_button_release (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -static void measure_tool_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); -static void measure_tool_cursor_update (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); -static void measure_tool_control (Tool *tool, - ToolAction action, - gpointer gdisp_ptr); - -static void measure_tool_info_window_close_callback (GtkWidget *widget, - gpointer data); -static void measure_tool_info_update (void); - - static void measure_tool_options_reset (void) { @@ -195,21 +195,19 @@ measure_get_angle (gint dx, static void measure_tool_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; gint x[3]; gint y[3]; gint i; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; /* if we are changing displays, pop the statusbar of the old one */ - if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp != tool->gdisp) { - GDisplay *old_gdisp = tool->gdisp_ptr; + GDisplay *old_gdisp = tool->gdisp; gtk_statusbar_pop (GTK_STATUSBAR (old_gdisp->statusbar), measure_tool->context_id); @@ -219,7 +217,7 @@ measure_tool_button_press (Tool *tool, measure_tool->function = CREATING; - if (tool->state == ACTIVE && gdisp_ptr == tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp == tool->gdisp) { /* if the cursor is in one of the handles, * the new function will be moving or adding a new point or guide @@ -334,7 +332,7 @@ measure_tool_button_press (Tool *tool, measure_tool->function = ADDING; /* set the gdisplay */ - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; /* start drawing the measure tool */ draw_core_start (measure_tool->core, gdisp->canvas->window, tool); @@ -378,12 +376,10 @@ measure_tool_button_press (Tool *tool, static void measure_tool_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; measure_tool->function = FINISHED; @@ -395,9 +391,8 @@ measure_tool_button_release (Tool *tool, static void measure_tool_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; gint x, y; gint ax, ay; @@ -409,7 +404,6 @@ measure_tool_motion (Tool *tool, gdouble distance; gchar status_str[STATUSBAR_SIZE]; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; /* undraw the current tool */ @@ -607,22 +601,20 @@ measure_tool_motion (Tool *tool, static void measure_tool_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - MeasureTool *measure_tool; - GDisplay *gdisp; - gint x[3]; - gint y[3]; - gint i; - gboolean in_handle = FALSE; + MeasureTool *measure_tool; + gint x[3]; + gint y[3]; + gint i; + gboolean in_handle = FALSE; GdkCursorType ctype = GIMP_CROSSHAIR_SMALL_CURSOR; CursorModifier cmodifier = CURSOR_MODIFIER_NONE; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; - if (tool->state == ACTIVE && tool->gdisp_ptr == gdisp_ptr) + if (tool->state == ACTIVE && tool->gdisp == gdisp) { for (i = 0; i < measure_tool->num_points; i++) { @@ -674,7 +666,6 @@ measure_tool_cursor_update (Tool *tool, static void measure_tool_draw (Tool *tool) { - GDisplay *gdisp; MeasureTool *measure_tool; gint x[3]; gint y[3]; @@ -682,12 +673,12 @@ measure_tool_draw (Tool *tool) gint angle1, angle2; gint draw_arc = 0; - gdisp = (GDisplay *) tool->gdisp_ptr; measure_tool = (MeasureTool *) tool->private; for (i = 0; i < measure_tool->num_points; i++) { - gdisplay_transform_coords (gdisp, measure_tool->x[i], measure_tool->y[i], + gdisplay_transform_coords (tool->gdisp, + measure_tool->x[i], measure_tool->y[i], &x[i], &y[i], FALSE); if (i == 0 && measure_tool->num_points == 3) { @@ -745,12 +736,10 @@ measure_tool_draw (Tool *tool) static void measure_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; - gdisp = (GDisplay *) tool->gdisp_ptr; measure_tool = (MeasureTool *) tool->private; switch (action) @@ -764,7 +753,8 @@ measure_tool_control (Tool *tool, break; case HALT: - gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), measure_tool->context_id); + gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), + measure_tool->context_id); draw_core_stop (measure_tool->core, tool); tool->state = INACTIVE; break; @@ -825,15 +815,13 @@ tools_new_measure_tool (void) void tools_free_measure_tool (Tool *tool) { - GDisplay *gdisp; MeasureTool *measure_tool; measure_tool = (MeasureTool *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; if (tool->state == ACTIVE) { - gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), + gtk_statusbar_pop (GTK_STATUSBAR (tool->gdisp->statusbar), measure_tool->context_id); draw_core_stop (measure_tool->core, tool); } @@ -845,5 +833,6 @@ tools_free_measure_tool (Tool *tool) info_dialog_free (measure_tool_info); measure_tool_info = NULL; } + g_free (measure_tool); } diff --git a/app/move.c b/app/move.c index 3b8e416564..1818da444b 100644 --- a/app/move.c +++ b/app/move.c @@ -45,6 +45,7 @@ /* the move structures */ typedef struct _MoveTool MoveTool; + struct _MoveTool { Layer *layer; @@ -53,6 +54,26 @@ struct _MoveTool }; +/* move tool action functions */ +static void move_tool_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void move_tool_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void move_tool_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void move_tool_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void move_tool_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void move_create_gc (GDisplay *gdisp); + + /* the move tool options */ static ToolOptions *move_options = NULL; @@ -60,48 +81,37 @@ static ToolOptions *move_options = NULL; static GdkGC *move_gc = NULL; -/* move tool action functions */ -static void move_tool_button_press (Tool *, GdkEventButton *, gpointer); -static void move_tool_button_release (Tool *, GdkEventButton *, gpointer); -static void move_tool_motion (Tool *, GdkEventMotion *, gpointer); -static void move_tool_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void move_tool_control (Tool *, ToolAction, gpointer); - -static void move_create_gc (GDisplay *gdisp); - - /* move action functions */ static void move_tool_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MoveTool *move; Layer *layer; Guide *guide; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; move = (MoveTool *) tool->private; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; move->layer = NULL; move->guide = NULL; move->disp = NULL; - gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE); + gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, + FALSE, FALSE); if (bevent->state & GDK_MOD1_MASK && !gimage_mask_is_empty (gdisp->gimage)) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); tool->state = ACTIVE; } else if (bevent->state & GDK_SHIFT_MASK) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_LAYER_TRANSLATE); tool->state = ACTIVE; } else @@ -138,7 +148,7 @@ move_tool_button_press (Tool *tool, else { gimp_image_set_active_layer (gdisp->gimage, layer); - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_LAYER_TRANSLATE); } tool->state = ACTIVE; } @@ -202,15 +212,13 @@ move_draw_guide (GDisplay *gdisp, static void move_tool_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; - GDisplay *gdisp; gboolean delete_guide; gint x1, y1; gint x2, y2; - gdisp = (GDisplay *) gdisp_ptr; move = (MoveTool *) tool->private; gdk_flush (); @@ -259,7 +267,7 @@ move_tool_button_release (Tool *tool, } else { - move_tool_motion (tool, NULL, gdisp_ptr); + move_tool_motion (tool, NULL, gdisp); } selection_resume (gdisp->select); @@ -285,15 +293,13 @@ move_tool_button_release (Tool *tool, static void move_tool_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; - GDisplay *gdisp; gint x, y; move = (MoveTool *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; if (move->guide) { @@ -323,16 +329,14 @@ move_tool_motion (Tool *tool, static void move_tool_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; - GDisplay *gdisp; Guide *guide; Layer *layer; gint x, y; move = (MoveTool *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -357,7 +361,7 @@ move_tool_cursor_update (Tool *tool, if (gdisp->draw_guides && (guide = gdisplay_find_guide (gdisp, mevent->x, mevent->y))) { - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; gdisplay_install_tool_cursor (gdisp, GDK_HAND2, TOOL_TYPE_NONE, CURSOR_MODIFIER_HAND, @@ -372,10 +376,10 @@ move_tool_cursor_update (Tool *tool, gdisplay_draw_guide (gdisp, move->guide, FALSE); } - gdisp = gdisp_ptr; + gdisp = gdisp; gdisplay_draw_guide (gdisp, guide, TRUE); move->guide = guide; - move->disp = gdisp; + move->disp = gdisp; } } else if ((layer = gimp_image_pick_correlate_layer (gdisp->gimage, x, y))) @@ -412,7 +416,7 @@ move_tool_cursor_update (Tool *tool, static void move_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; @@ -425,7 +429,7 @@ move_tool_control (Tool *tool, case RESUME: if (move->guide) - gdisplay_draw_guide (gdisp_ptr, move->guide, TRUE); + gdisplay_draw_guide (gdisp, move->guide, TRUE); break; case HALT: @@ -458,7 +462,7 @@ move_tool_start_hguide (Tool *tool, selection_pause (gdisp->select); - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->scroll_lock = TRUE; private = tool->private; @@ -482,7 +486,7 @@ move_tool_start_vguide (Tool *tool, selection_pause (gdisp->select); - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->scroll_lock = TRUE; private = tool->private; @@ -539,10 +543,10 @@ tools_free_move_tool (Tool *tool) move = (MoveTool *) tool->private; - if (tool->gdisp_ptr) + if (tool->gdisp) { if (move->guide) - gdisplay_draw_guide (tool->gdisp_ptr, move->guide, FALSE); + gdisplay_draw_guide (tool->gdisp, move->guide, FALSE); } g_free (move); diff --git a/app/nav_window.c b/app/nav_window.c index 6f434f3e1a..6b259f442b 100644 --- a/app/nav_window.c +++ b/app/nav_window.c @@ -77,6 +77,7 @@ typedef enum #define PREVIEW_UPDATE_TIMEOUT 1100 typedef struct _NavWinData NavWinData; + struct _NavWinData { NavWinType ptype; @@ -88,7 +89,7 @@ struct _NavWinData GtkWidget *zoom_label; GtkObject *zoom_adjustment; GtkWidget *preview; - void *gdisp_ptr; /* I'm not happy 'bout this one */ + GDisplay *gdisp; /* I'm not happy 'bout this one */ GdkGC *gc; gint dispx; /* x pos of top left corner of display area */ gint dispy; /* y pos of top left corner of display area */ @@ -251,10 +252,6 @@ nav_window_draw_sqr (NavWinData *iwd, gint w, gint h) { - GDisplay *gdisp; - - gdisp = (GDisplay *) iwd->gdisp_ptr; - gdk_gc_set_function (iwd->gc, GDK_INVERT); if (undraw) @@ -307,7 +304,7 @@ set_size_data (NavWinData *iwd) GDisplay *gdisp; GimpImage *gimage; - gdisp = (GDisplay *)(iwd->gdisp_ptr); + gdisp = iwd->gdisp; gimage = gdisp->gimage; sel_width = gimage->width; @@ -345,9 +342,6 @@ create_preview_widget (NavWinData *iwd) GtkWidget *hbox; GtkWidget *image; GtkWidget *frame; - GDisplay *gdisp; - - gdisp = (GDisplay *)(iwd->gdisp_ptr); hbox = gtk_hbox_new (FALSE,0); iwd->previewBox = hbox; @@ -406,7 +400,7 @@ update_real_view (NavWinData *iwd, gint xpnt; gint ypnt; - gdisp = (GDisplay *) iwd->gdisp_ptr; + gdisp = iwd->gdisp; xratio = SCALEFACTOR_X (gdisp); yratio = SCALEFACTOR_Y (gdisp); @@ -433,7 +427,7 @@ update_real_view (NavWinData *iwd, yoffset = ypnt - gdisp->offset_y; iwd->block_window_marker = TRUE; - scroll_display (iwd->gdisp_ptr, xoffset, yoffset); + scroll_display (iwd->gdisp, xoffset, yoffset); iwd->block_window_marker = FALSE; } @@ -454,10 +448,8 @@ nav_window_update_preview (NavWinData *iwd) gimp_add_busy_cursors (); - gdisp = (GDisplay *) iwd->gdisp_ptr; - - /* Calculate preview size */ - gimage = ((GDisplay *) (iwd->gdisp_ptr))->gimage; + gdisp = iwd->gdisp; + gimage = gdisp->gimage; /* Min size is 2 */ pwidth = iwd->pwidth; @@ -615,10 +607,8 @@ nav_window_update_preview_blank (NavWinData *iwd) GimpImage *gimage; GDisplay *gdisp; - gdisp = (GDisplay *) iwd->gdisp_ptr; - - /* Calculate preview size */ - gimage = ((GDisplay *) (iwd->gdisp_ptr))->gimage; + gdisp = iwd->gdisp; + gimage = gdisp->gimage; #endif /* 0 */ @@ -670,9 +660,9 @@ update_zoom_label (NavWinData *iwd) /* Update the zoom scale string */ g_snprintf (scale_str, MAX_SCALE_BUF, "%d:%d", - SCALEDEST (((GDisplay *)iwd->gdisp_ptr)), - SCALESRC (((GDisplay *)iwd->gdisp_ptr))); - + SCALEDEST (iwd->gdisp), + SCALESRC (iwd->gdisp)); + gtk_label_set_text (GTK_LABEL (iwd->zoom_label), scale_str); } @@ -689,8 +679,8 @@ update_zoom_adjustment (NavWinData *iwd) adj = GTK_ADJUSTMENT (iwd->zoom_adjustment); f = - ((gdouble) SCALEDEST (((GDisplay *) iwd->gdisp_ptr))) / - ((gdouble) SCALESRC (((GDisplay *) iwd->gdisp_ptr))); + ((gdouble) SCALEDEST (iwd->gdisp)) / + ((gdouble) SCALESRC (iwd->gdisp)); if (f < 1.0) { @@ -782,7 +772,7 @@ nav_window_preview_events (GtkWidget *widget, if(!iwd || iwd->frozen == TRUE) return FALSE; - gdisp = (GDisplay *) iwd->gdisp_ptr; + gdisp = iwd->gdisp; switch (event->type) { @@ -998,7 +988,7 @@ nav_window_expose_events (GtkWidget *widget, if(!iwd || iwd->frozen == TRUE) return FALSE; - gdisp = (GDisplay *) iwd->gdisp_ptr; + gdisp = iwd->gdisp; switch (event->type) { @@ -1025,12 +1015,12 @@ nav_window_expose_events (GtkWidget *widget, static gint nav_preview_update_do (NavWinData *iwd) { - /* If the gdisp_ptr has gone then don't do anything in this timer */ - if (!iwd->gdisp_ptr) + /* If the gdisp has gone then don't do anything in this timer */ + if (!iwd->gdisp) return FALSE; nav_window_update_preview (iwd); - nav_window_disp_area (iwd, iwd->gdisp_ptr); + nav_window_disp_area (iwd, iwd->gdisp); gtk_widget_queue_draw (iwd->preview); iwd->installedDirtyTimer = FALSE; @@ -1076,16 +1066,13 @@ navwindow_zoomin (GtkWidget *widget, gpointer data) { NavWinData *iwd; - GDisplay *gdisp; - iwd = (NavWinData *)data; + iwd = (NavWinData *) data; if(!iwd || iwd->frozen == TRUE) return; - gdisp = (GDisplay *) iwd->gdisp_ptr; - - change_scale (gdisp, ZOOMIN); + change_scale (iwd->gdisp, ZOOMIN); } static void @@ -1093,16 +1080,13 @@ navwindow_zoomout (GtkWidget *widget, gpointer data) { NavWinData *iwd; - GDisplay *gdisp; iwd = (NavWinData *)data; if (!iwd || iwd->frozen == TRUE) return; - gdisp = (GDisplay *) iwd->gdisp_ptr; - - change_scale (gdisp, ZOOMOUT); + change_scale (iwd->gdisp, ZOOMOUT); } static void @@ -1110,7 +1094,6 @@ zoom_adj_changed (GtkAdjustment *adj, gpointer data) { NavWinData *iwd; - GDisplay *gdisp; gint scalesrc; gint scaledest; @@ -1119,8 +1102,6 @@ zoom_adj_changed (GtkAdjustment *adj, if (!iwd || iwd->frozen == TRUE) return; - gdisp = (GDisplay *) iwd->gdisp_ptr; - if (adj->value < 0.0) { scalesrc = abs ((gint) adj->value - 1); @@ -1133,7 +1114,7 @@ zoom_adj_changed (GtkAdjustment *adj, } iwd->block_adj_sig = TRUE; - change_scale (gdisp, (scaledest * 100) + scalesrc); + change_scale (iwd->gdisp, (scaledest * 100) + scalesrc); iwd->block_adj_sig = FALSE; } @@ -1168,8 +1149,8 @@ nav_create_button_area (InfoDialog *info_win) /* user zoom ratio */ g_snprintf (scale_str, MAX_SCALE_BUF, "%d:%d", - SCALEDEST (((GDisplay *)iwd->gdisp_ptr)), - SCALESRC (((GDisplay *)iwd->gdisp_ptr))); + SCALEDEST (iwd->gdisp), + SCALESRC (iwd->gdisp)); label1 = gtk_label_new (scale_str); gtk_widget_show (label1); @@ -1256,12 +1237,12 @@ info_window_image_preview_new (InfoDialog *info_win) } NavWinData * -create_dummy_iwd (void *gdisp_ptr, +create_dummy_iwd (GDisplay *gdisp, NavWinType ptype) { NavWinData *iwd; - iwd = (NavWinData *) g_malloc (sizeof (NavWinData)); + iwd = g_new (NavWinData, 1); iwd->ptype = ptype; iwd->info_win = NULL; iwd->showingPreview = TRUE; @@ -1269,7 +1250,7 @@ create_dummy_iwd (void *gdisp_ptr, iwd->preview = NULL; iwd->zoom_label = NULL; iwd->zoom_adjustment = NULL; - iwd->gdisp_ptr = gdisp_ptr; + iwd->gdisp = gdisp; iwd->dispx = -1; iwd->dispy = -1; iwd->dispwidth = -1; @@ -1299,7 +1280,7 @@ create_dummy_iwd (void *gdisp_ptr, static InfoDialog *nav_window_auto = NULL; static gchar * -nav_window_title(GDisplay *gdisp) +nav_window_title (GDisplay *gdisp) { gchar *title; gchar *title_buf; @@ -1326,8 +1307,8 @@ nav_window_change_display (GimpContext *context, /* NOT USED */ NavWinData *iwd; gchar *title_buf; - iwd = (NavWinData *)nav_window_auto->user_data; - old_gdisp = (GDisplay *) iwd->gdisp_ptr; + iwd = (NavWinData *) nav_window_auto->user_data; + old_gdisp = iwd->gdisp; if (!nav_window_auto || gdisp == old_gdisp || !gdisp) { @@ -1347,7 +1328,7 @@ nav_window_change_display (GimpContext *context, /* NOT USED */ if (gimage && gimp_set_have (image_context, gimage)) { - iwd->gdisp_ptr = gdisp; + iwd->gdisp = gdisp; /* Update preview to new display */ nav_window_preview_resized (nav_window_auto); @@ -1382,9 +1363,10 @@ nav_window_follow_auto (void) if (!gdisp) return; - if(!nav_window_auto) + if (!nav_window_auto) { - nav_window_auto = nav_window_create ((void *) gdisp); + nav_window_auto = nav_window_create (gdisp); + gtk_signal_connect (GTK_OBJECT (gimp_context_get_user ()), "display_changed", GTK_SIGNAL_FUNC (nav_window_change_display), @@ -1400,20 +1382,17 @@ nav_window_follow_auto (void) InfoDialog * -nav_window_create (void *gdisp_ptr) +nav_window_create (GDisplay *gdisp) { InfoDialog *info_win; - GDisplay *gdisp; NavWinData *iwd; GtkWidget *container; gchar *title_buf; GimpImageBaseType type; - gdisp = (GDisplay *) gdisp_ptr; - type = gimp_image_base_type (gdisp->gimage); - title_buf = nav_window_title(gdisp); + title_buf = nav_window_title (gdisp); info_win = info_dialog_new (title_buf, gimp_standard_help_func, @@ -1434,7 +1413,7 @@ nav_window_create (void *gdisp_ptr) (GtkSignalFunc) nav_window_destroy_callback, info_win); - iwd = create_dummy_iwd (gdisp_ptr, NAV_WINDOW); + iwd = create_dummy_iwd (gdisp, NAV_WINDOW); info_win->user_data = iwd; iwd->info_win = info_win; @@ -1501,7 +1480,7 @@ nav_window_update_window_marker (InfoDialog *info_win) iwd->dispwidth, iwd->dispheight); /* Update to new size */ - nav_window_disp_area (iwd, iwd->gdisp_ptr); + nav_window_disp_area (iwd, iwd->gdisp); /* and redraw */ nav_window_draw_sqr (iwd, @@ -1563,14 +1542,14 @@ nav_window_get_gdisp (void) for (listPtr = list; listPtr; listPtr = g_slist_next (listPtr)) { gimage = GIMP_IMAGE (listPtr->data); - gdisp = gdisplays_check_valid (NULL,gimage); + gdisp = gdisplays_check_valid (NULL, gimage); if (gdisp) break; } g_slist_free (list); - return (gdisp); + return gdisp; } @@ -1589,12 +1568,12 @@ nav_window_free (GDisplay *del_gdisp, { if (nav_window_auto != NULL) { - GDisplay * gdisp; + GDisplay *gdisp; iwd = (NavWinData *) nav_window_auto->user_data; /* Only freeze if we are displaying the image we have deleted */ - if ((GDisplay *) iwd->gdisp_ptr != del_gdisp) + if (iwd->gdisp != del_gdisp) return; if (iwd->timer_id) @@ -1605,7 +1584,9 @@ nav_window_free (GDisplay *del_gdisp, gdisp = nav_window_get_gdisp (); if (gdisp) - nav_window_change_display (NULL, gdisp, NULL); + { + nav_window_change_display (NULL, gdisp, NULL); + } else { /* Clear window and freeze */ @@ -1615,7 +1596,7 @@ nav_window_free (GDisplay *del_gdisp, _("Navigation: No Image")); gtk_widget_set_sensitive (nav_window_auto->vbox, FALSE); - iwd->gdisp_ptr = NULL; + iwd->gdisp = NULL; gtk_widget_hide (GTK_WIDGET (nav_window_auto->shell)); } } @@ -1651,7 +1632,7 @@ nav_popup_click_handler (GtkWidget *widget, bevent = (GdkEventButton *)event; - if(!gdisp->nav_popup) + if (! gdisp->nav_popup) { /* popup a simplfied window with the nav box in it */ GtkWidget *frame; @@ -1674,14 +1655,14 @@ nav_popup_click_handler (GtkWidget *widget, gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_object_set_data (GTK_OBJECT (gdisp->nav_popup),"navpop_prt", (gpointer) iwp); - nav_window_disp_area (iwp, iwp->gdisp_ptr); + nav_window_disp_area (iwp, iwp->gdisp); } else { gtk_widget_hide (gdisp->nav_popup); iwp = (NavWinData *) gtk_object_get_data (GTK_OBJECT (gdisp->nav_popup), "navpop_prt"); - nav_window_disp_area (iwp, iwp->gdisp_ptr); + nav_window_disp_area (iwp, iwp->gdisp); nav_window_update_preview (iwp); } diff --git a/app/nav_window.h b/app/nav_window.h index 8669dc4a1e..6ca8a902c4 100644 --- a/app/nav_window.h +++ b/app/nav_window.h @@ -21,7 +21,7 @@ #define __NAV_WINDOW_H__ -InfoDialog * nav_window_create (gpointer ); +InfoDialog * nav_window_create (GDisplay *gdisp); void nav_window_free (GDisplay *gdisp, InfoDialog *idialog); void nav_window_update_window_marker (InfoDialog *idialog); diff --git a/app/paint/gimpairbrush.c b/app/paint/gimpairbrush.c index 29ad1d4f90..0289996769 100644 --- a/app/paint/gimpairbrush.c +++ b/app/paint/gimpairbrush.c @@ -77,6 +77,16 @@ struct _AirbrushOptions }; +/* local function prototypes */ + +static gpointer airbrush_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static gpointer airbrush_non_gui_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + + /* the airbrush tool options */ static AirbrushOptions *airbrush_options = NULL; @@ -189,13 +199,13 @@ tools_new_airbrush (void) return tool; } -void * +static gpointer airbrush_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { GimpBrush *brush; - gdouble rate; + gdouble rate; if (!drawable) return NULL; @@ -357,10 +367,10 @@ airbrush_motion (PaintCore *paint_core, SOFT, scale, mode); } -static void * +static gpointer airbrush_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { airbrush_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_pressure, non_gui_incremental); @@ -370,8 +380,8 @@ airbrush_non_gui_paint_func (PaintCore *paint_core, gboolean airbrush_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { AirbrushOptions *options = airbrush_options; gdouble pressure = AIRBRUSH_PRESSURE_DEFAULT; @@ -384,11 +394,11 @@ airbrush_non_gui_default (GimpDrawable *drawable, gboolean airbrush_non_gui (GimpDrawable *drawable, - double pressure, - int num_strokes, - double *stroke_array) + gdouble pressure, + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -419,8 +429,9 @@ airbrush_non_gui (GimpDrawable *drawable, /* Cleanup */ paint_core_cleanup (); + return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/paint/gimpairbrush.h b/app/paint/gimpairbrush.h index ea4e64954b..6eb5528f0f 100644 --- a/app/paint/gimpairbrush.h +++ b/app/paint/gimpairbrush.h @@ -20,18 +20,16 @@ #define __AIRBRUSH_H__ -void * airbrush_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean airbrush_non_gui (GimpDrawable *, - gdouble, - gint, - gdouble *); -gboolean airbrush_non_gui_default (GimpDrawable *, - gint, - gdouble *); +gboolean airbrush_non_gui (GimpDrawable *drawable, + gdouble pressure, + gint num_strokes, + gdouble *stroke_array); +gboolean airbrush_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); + Tool * tools_new_airbrush (void); -void tools_free_airbrush (Tool *); +void tools_free_airbrush (Tool *tool); #endif /* __AIRBRUSH_H__ */ diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c index 7c16c6f684..320e2c7725 100644 --- a/app/paint/gimpclone.c +++ b/app/paint/gimpclone.c @@ -79,37 +79,59 @@ struct _CloneOptions }; +/* forward function declarations */ + +static gpointer clone_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void clone_draw (Tool *tool); +static void clone_motion (PaintCore *paint_core, + GimpDrawable *drawable, + GimpDrawable *src_drawable, + PaintPressureOptions *pressure_options, + CloneType type, + gint offset_x, + gint offset_y); +static void clone_line_image (GImage *dest, + GImage *src, + GimpDrawable *d_drawable, + GimpDrawable *s_drawable, + guchar *s, + guchar *d, + gint has_alpha, + gint src_bytes, + gint dest_bytes, + gint width); +static void clone_line_pattern (GImage *dest, + GimpDrawable *drawable, + GPattern *pattern, + guchar *d, + gint x, + gint y, + gint bytes, + gint width); + + /* the clone tool options */ static CloneOptions *clone_options = NULL; /* local variables */ -static int src_x = 0; /* */ -static int src_y = 0; /* position of clone src */ -static int dest_x = 0; /* */ -static int dest_y = 0; /* position of clone src */ -static int offset_x = 0; /* */ -static int offset_y = 0; /* offset for cloning */ -static int first = TRUE; -static int trans_tx, trans_ty; /* transformed target */ +static gint src_x = 0; /* */ +static gint src_y = 0; /* position of clone src */ +static gint dest_x = 0; /* */ +static gint dest_y = 0; /* position of clone src */ +static gint offset_x = 0; /* */ +static gint offset_y = 0; /* offset for cloning */ +static gint first = TRUE; +static gint trans_tx, trans_ty; /* transformed target */ static GDisplay *the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable *src_drawable_ = NULL; /* source drawable */ static GimpDrawable *non_gui_src_drawable; -static int non_gui_offset_x; -static int non_gui_offset_y; +static gint non_gui_offset_x; +static gint non_gui_offset_y; static CloneType non_gui_type; -/* forward function declarations */ - -static void clone_draw (Tool *); -static void clone_motion (PaintCore *, GimpDrawable *, GimpDrawable *, - PaintPressureOptions *, CloneType, int, int); -static void clone_line_image (GImage *, GImage *, GimpDrawable *, - GimpDrawable *, unsigned char *, - unsigned char *, int, int, int, int); -static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, - unsigned char *, int, int, int, int); - /* functions */ @@ -128,8 +150,8 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *frame; /* the new clone tool options structure */ options = g_new (CloneOptions, 1); @@ -202,23 +224,24 @@ clone_set_src_drawable (GimpDrawable *drawable) } } -void * +static gpointer clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - gint state) + PaintState state) { - GDisplay * gdisp; - GDisplay * src_gdisp; - int x1, y1, x2, y2; - static int orig_src_x, orig_src_y; + GDisplay *gdisp; + GDisplay *src_gdisp; + gint x1, y1, x2, y2; + static gint orig_src_x, orig_src_y; - gdisp = (GDisplay *) active_tool->gdisp_ptr; + gdisp = (GDisplay *) active_tool->gdisp; switch (state) { case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; @@ -320,14 +343,11 @@ clone_paint_func (PaintCore *paint_core, void clone_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + gint x, y; gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y, &x, &y, TRUE, FALSE); @@ -661,10 +681,10 @@ clone_line_pattern (GImage *dest, } } -static void * -clone_non_gui_paint_func (PaintCore *paint_core, +static gpointer +clone_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { clone_motion (paint_core, drawable, non_gui_src_drawable, &non_gui_pressure_options, @@ -675,16 +695,16 @@ clone_non_gui_paint_func (PaintCore *paint_core, gboolean clone_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { GimpDrawable *src_drawable = NULL; CloneType clone_type = CLONE_DEFAULT_TYPE; - double local_src_x = 0.0; - double local_src_y = 0.0; + gdouble local_src_x = 0.0; + gdouble local_src_y = 0.0; CloneOptions *options = clone_options; - - if(options) + + if (options) { clone_type = options->type; src_drawable = src_drawable_; @@ -692,23 +712,23 @@ clone_non_gui_default (GimpDrawable *drawable, local_src_y = src_y; } - return clone_non_gui(drawable, - src_drawable, - clone_type, - local_src_x,local_src_y, - num_strokes,stroke_array); + return clone_non_gui (drawable, + src_drawable, + clone_type, + local_src_x,local_src_y, + num_strokes, stroke_array); } gboolean clone_non_gui (GimpDrawable *drawable, GimpDrawable *src_drawable, CloneType clone_type, - double src_x, - double src_y, - int num_strokes, - double *stroke_array) + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) diff --git a/app/paint/gimpclone.h b/app/paint/gimpclone.h index 0433bc488e..fcc2f1d247 100644 --- a/app/paint/gimpclone.h +++ b/app/paint/gimpclone.h @@ -26,21 +26,19 @@ typedef enum PATTERN_CLONE } CloneType; -void * clone_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean clone_non_gui (GimpDrawable *, - GimpDrawable *, - CloneType, - gdouble, - gdouble, - gint, - gdouble *); -gboolean clone_non_gui_default (GimpDrawable *, - gint, - gdouble *); + +gboolean clone_non_gui (GimpDrawable *drawable, + GimpDrawable *src_drawable, + CloneType clone_type, + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array); +gboolean clone_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_clone (void); -void tools_free_clone (Tool *); +void tools_free_clone (Tool *tool); #endif /* __CLONE_H__ */ diff --git a/app/paint/gimpconvolve.c b/app/paint/gimpconvolve.c index bcf8bd2580..e8df499d63 100644 --- a/app/paint/gimpconvolve.c +++ b/app/paint/gimpconvolve.c @@ -82,6 +82,28 @@ struct _ConvolveOptions }; +/* forward function declarations */ +static void calculate_matrix (ConvolveType type, + gdouble rate); +static void integer_matrix (gfloat *source, + gint *dest, + gint size); +static void copy_matrix (gfloat *src, + gfloat *dest, + gint size); +static gint sum_matrix (gint *matrix, + gint size); + +static gpointer convolve_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void convolve_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + ConvolveType type, + gdouble rate); + + /* the convolve tool options */ static ConvolveOptions * convolve_options = NULL; @@ -121,19 +143,8 @@ static gfloat sharpen_matrix [25] = }; -/* forward function declarations */ -static void calculate_matrix (ConvolveType, double); -static void integer_matrix (float *, int *, int); -static void copy_matrix (float *, float *, int); -static int sum_matrix (int *, int); - -static void convolve_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, - ConvolveType, double); - /* functions */ - static void convolve_options_reset (void) { @@ -205,10 +216,10 @@ convolve_options_new (void) return options; } -void * +static gpointer convolve_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -217,6 +228,9 @@ convolve_paint_func (PaintCore *paint_core, convolve_options->paint_options.pressure_options, convolve_options->type, convolve_options->rate); break; + + default: + break; } return NULL; @@ -225,7 +239,7 @@ convolve_paint_func (PaintCore *paint_core, static void convolve_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -282,18 +296,18 @@ convolve_modifier_key_func (Tool *tool, static void convolve_cursor_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE); - paint_core_cursor_update (tool, mevent, gdisp_ptr); + paint_core_cursor_update (tool, mevent, gdisp); } Tool * tools_new_convolve (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! convolve_options) @@ -570,34 +584,34 @@ calculate_matrix (ConvolveType type, } static void -integer_matrix (float *source, - int *dest, - int size) +integer_matrix (gfloat *source, + gint *dest, + gint size) { - int i; + gint i; #define PRECISION 10000 for (i = 0; i < size*size; i++) - *dest++ = (int) (*source ++ * PRECISION); + *dest++ = (gint) (*source ++ * PRECISION); } static void -copy_matrix (float *src, - float *dest, - int size) +copy_matrix (gfloat *src, + gfloat *dest, + gint size) { - int i; + gint i; for (i = 0; i < size*size; i++) *dest++ = *src++; } static int -sum_matrix (int *matrix, - int size) +sum_matrix (gint *matrix, + gint size) { - int sum = 0; + gint sum = 0; size *= size; @@ -608,10 +622,10 @@ sum_matrix (int *matrix, } -static void * -convolve_non_gui_paint_func (PaintCore *paint_core, +static gpointer +convolve_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { convolve_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_type, non_gui_rate); @@ -621,11 +635,11 @@ convolve_non_gui_paint_func (PaintCore *paint_core, gboolean convolve_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - double rate = DEFAULT_CONVOLVE_RATE; - ConvolveType type = DEFAULT_CONVOLVE_TYPE; + gdouble rate = DEFAULT_CONVOLVE_RATE; + ConvolveType type = DEFAULT_CONVOLVE_TYPE; ConvolveOptions *options = convolve_options; if (options) @@ -641,17 +655,17 @@ gboolean convolve_non_gui (GimpDrawable *drawable, double rate, ConvolveType type, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) { /* Set the paint core's paint func */ non_gui_paint_core.paint_func = convolve_non_gui_paint_func; - + non_gui_type = type; non_gui_rate = rate; @@ -678,6 +692,6 @@ convolve_non_gui (GimpDrawable *drawable, paint_core_cleanup (); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/paint/gimpconvolve.h b/app/paint/gimpconvolve.h index 3a6058ef5c..1e07c92d36 100644 --- a/app/paint/gimpconvolve.h +++ b/app/paint/gimpconvolve.h @@ -28,19 +28,17 @@ typedef enum } ConvolveType; -void * convolve_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean convolve_non_gui (GimpDrawable *, - gdouble , - ConvolveType , - gint , - gdouble *); -gboolean convolve_non_gui_default (GimpDrawable *, - gint , - gdouble *); -Tool * tools_new_convolve (void ); -void tools_free_convolve (Tool *); +gboolean convolve_non_gui (GimpDrawable *drawable, + gdouble rate, + ConvolveType type, + gint num_strokes, + gdouble *stroke_array); +gboolean convolve_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); + +Tool * tools_new_convolve (void); +void tools_free_convolve (Tool *tool); #endif /* __CONVOLVE_H__ */ diff --git a/app/paint/gimpdodgeburn.c b/app/paint/gimpdodgeburn.c index 8ffe8968ce..396945d3b3 100644 --- a/app/paint/gimpdodgeburn.c +++ b/app/paint/gimpdodgeburn.c @@ -44,6 +44,12 @@ #include "libgimp/gimpintl.h" +/* Default values */ + +#define DODGEBURN_DEFAULT_TYPE DODGE +#define DODGEBURN_DEFAULT_EXPOSURE 50.0 +#define DODGEBURN_DEFAULT_MODE DODGEBURN_HIGHLIGHTS + /* the dodgeburn structures */ typedef struct _DodgeBurnOptions DodgeBurnOptions; @@ -67,36 +73,49 @@ struct _DodgeBurnOptions GimpLut *lut; }; -static void -dodgeburn_make_luts (PaintCore *, double, DodgeBurnType, DodgeBurnMode, - GimpLut *, GimpDrawable *); -static gfloat dodgeburn_highlights_lut_func (void *, int, int, gfloat); -static gfloat dodgeburn_midtones_lut_func (void *, int, int, gfloat); -static gfloat dodgeburn_shadows_lut_func (void *, int, int, gfloat); +static gpointer dodgeburn_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + +static void dodgeburn_make_luts (PaintCore *paint_cure, + gdouble db_exposure, + DodgeBurnType type, + DodgeBurnMode mode, + GimpLut *lut, + GimpDrawable *drawable); + +static gfloat dodgeburn_highlights_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); +static gfloat dodgeburn_midtones_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); +static gfloat dodgeburn_shadows_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); + +static void dodgeburn_motion (PaintCore *paint_core, + PaintPressureOptions *pressure_options, + gdouble dodgeburn_exposure, + GimpLut *lut, + GimpDrawable *drawable); +static void dodgeburn_init (PaintCore *paint_cure, + GimpDrawable *drawable); +static void dodgeburn_finish (PaintCore *paint_core, + GimpDrawable *drawable); -/* The dodge burn lookup tables */ -gfloat dodgeburn_highlights (void *, int, int, gfloat); -gfloat dodgeburn_midtones (void *, int, int, gfloat); -gfloat dodgeburn_shadows (void *, int, int, gfloat); /* the dodgeburn tool options */ static DodgeBurnOptions * dodgeburn_options = NULL; /* Non gui function */ -static double non_gui_exposure; +static gdouble non_gui_exposure; static GimpLut *non_gui_lut; -/* Default values */ -#define DODGEBURN_DEFAULT_TYPE DODGE -#define DODGEBURN_DEFAULT_EXPOSURE 50.0 -#define DODGEBURN_DEFAULT_MODE DODGEBURN_HIGHLIGHTS - -static void dodgeburn_motion (PaintCore *, - PaintPressureOptions *, - double, GimpLut *, GimpDrawable *); -static void dodgeburn_init (PaintCore *, GimpDrawable *); -static void dodgeburn_finish (PaintCore *, GimpDrawable *); /* functions */ @@ -198,24 +217,29 @@ dodgeburn_options_new (void) return options; } -void * +static gpointer dodgeburn_paint_func (PaintCore *paint_core, - GimpDrawable *drawable, - int state) + GimpDrawable *drawable, + PaintState state) { switch (state) { case INIT_PAINT: dodgeburn_init (paint_core, drawable); break; + case MOTION_PAINT: dodgeburn_motion (paint_core, dodgeburn_options->paint_options.pressure_options, dodgeburn_options->exposure, dodgeburn_options->lut, drawable); break; + case FINISH_PAINT: dodgeburn_finish (paint_core, drawable); break; + + default: + break; } return NULL; @@ -238,7 +262,8 @@ dodgeburn_init (PaintCore *paint_core, GimpDrawable *drawable) { /* Here we create the luts to do the painting with.*/ - dodgeburn_options->lut = gimp_lut_new(); + dodgeburn_options->lut = gimp_lut_new (); + dodgeburn_make_luts (paint_core, dodgeburn_options->exposure, dodgeburn_options->type, @@ -249,17 +274,17 @@ dodgeburn_init (PaintCore *paint_core, static void dodgeburn_make_luts (PaintCore *paint_core, - double db_exposure, + gdouble db_exposure, DodgeBurnType type, DodgeBurnMode mode, GimpLut *lut, GimpDrawable *drawable) { - GimpLutFunc lut_func; - int nchannels = gimp_drawable_bytes (drawable); + GimpLutFunc lut_func; + gint nchannels = gimp_drawable_bytes (drawable); static gfloat exposure; - exposure = (db_exposure) / 100.0; + exposure = db_exposure / 100.0; /* make the exposure negative if burn for luts*/ if (type == BURN) @@ -281,15 +306,15 @@ dodgeburn_make_luts (PaintCore *paint_core, break; } - gimp_lut_setup_exact (lut, - lut_func, (void *)&exposure, - nchannels); + gimp_lut_setup_exact (lut, + lut_func, (gpointer) &exposure, + nchannels); } static void dodgeburn_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -317,7 +342,7 @@ dodgeburn_modifier_key_func (Tool *tool, break; case GDK_Control_L: case GDK_Control_R: - if ( !(kevent->state & GDK_SHIFT_MASK) ) /* shift enables line draw mode */ + if (! (kevent->state & GDK_SHIFT_MASK)) /* shift enables line draw mode */ { switch (dodgeburn_options->type) { @@ -342,18 +367,18 @@ dodgeburn_modifier_key_func (Tool *tool, static void dodgeburn_cursor_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->toggled = (dodgeburn_options->type == BURN); - paint_core_cursor_update (tool, mevent, gdisp_ptr); + paint_core_cursor_update (tool, mevent, gdisp); } Tool * tools_new_dodgeburn (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! dodgeburn_options) @@ -420,25 +445,26 @@ dodgeburn_motion (PaintCore *paint_core, no paint from this stroke yet) */ { - gint x1, y1, x2, y2; - x1 = CLAMP (area->x, 0, drawable_width (drawable)); - y1 = CLAMP (area->y, 0, drawable_height (drawable)); - x2 = CLAMP (area->x + area->width, 0, drawable_width (drawable)); - y2 = CLAMP (area->y + area->height, 0, drawable_height (drawable)); + gint x1, y1, x2, y2; - if (!(x2 - x1) || !(y2 - y1)) - return; + x1 = CLAMP (area->x, 0, drawable_width (drawable)); + y1 = CLAMP (area->y, 0, drawable_height (drawable)); + x2 = CLAMP (area->x + area->width, 0, drawable_width (drawable)); + y2 = CLAMP (area->y + area->height, 0, drawable_height (drawable)); - /* get the original untouched image */ - orig = paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2); - srcPR.bytes = orig->bytes; - srcPR.x = 0; - srcPR.y = 0; - srcPR.w = x2 - x1; - srcPR.h = y2 - y1; - srcPR.rowstride = srcPR.bytes * orig->width; - srcPR.data = temp_buf_data (orig); - } + if (!(x2 - x1) || !(y2 - y1)) + return; + + /* get the original untouched image */ + orig = paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2); + srcPR.bytes = orig->bytes; + srcPR.x = 0; + srcPR.y = 0; + srcPR.w = x2 - x1; + srcPR.h = y2 - y1; + srcPR.rowstride = srcPR.bytes * orig->width; + srcPR.data = temp_buf_data (orig); + } /* tempPR will hold the dodgeburned region*/ tempPR.bytes = srcPR.bytes; @@ -482,10 +508,10 @@ dodgeburn_motion (PaintCore *paint_core, g_free (temp_data); } -static void * +static gpointer dodgeburn_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { dodgeburn_motion (paint_core, &non_gui_pressure_options, non_gui_exposure, non_gui_lut, drawable); @@ -495,13 +521,13 @@ dodgeburn_non_gui_paint_func (PaintCore *paint_core, gboolean dodgeburn_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - double exposure = DODGEBURN_DEFAULT_TYPE; - DodgeBurnType type = DODGEBURN_DEFAULT_TYPE; - DodgeBurnMode mode = DODGEBURN_DEFAULT_MODE; - DodgeBurnOptions *options = dodgeburn_options; + gdouble exposure = DODGEBURN_DEFAULT_TYPE; + DodgeBurnType type = DODGEBURN_DEFAULT_TYPE; + DodgeBurnMode mode = DODGEBURN_DEFAULT_MODE; + DodgeBurnOptions *options = dodgeburn_options; if (options) { @@ -510,18 +536,19 @@ dodgeburn_non_gui_default (GimpDrawable *drawable, mode = dodgeburn_options->mode; } - return dodgeburn_non_gui (drawable, exposure, type, mode, num_strokes, stroke_array); + return dodgeburn_non_gui (drawable, exposure, type, mode, + num_strokes, stroke_array); } gboolean dodgeburn_non_gui (GimpDrawable *drawable, - double exposure, + gdouble exposure, DodgeBurnType type, DodgeBurnMode mode, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -569,15 +596,15 @@ dodgeburn_non_gui (GimpDrawable *drawable, } static gfloat -dodgeburn_highlights_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_highlights_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat factor = 1.0 + exposure * (.333333); - + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat factor = 1.0 + exposure * (.333333); + if ((nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) return value; @@ -586,14 +613,14 @@ dodgeburn_highlights_lut_func (void *user_data, } static gfloat -dodgeburn_midtones_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_midtones_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat factor; + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat factor; if ((nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) @@ -603,19 +630,20 @@ dodgeburn_midtones_lut_func (void *user_data, factor = 1.0 - exposure * (.333333); else factor = 1/(1.0 + exposure); + return pow (value, factor); } static gfloat -dodgeburn_shadows_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_shadows_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat new_value; - gfloat factor; + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat new_value; + gfloat factor; if ( (nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) diff --git a/app/paint/gimpdodgeburn.h b/app/paint/gimpdodgeburn.h index 341fe445ea..edd02ba64d 100644 --- a/app/paint/gimpdodgeburn.h +++ b/app/paint/gimpdodgeburn.h @@ -34,21 +34,18 @@ typedef enum } DodgeBurnMode; -void * dodgeburn_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean dodgeburn_non_gui (GimpDrawable *, - gdouble, - DodgeBurnType, - DodgeBurnMode, - gint, - gdouble *); -gboolean dodgeburn_non_gui_default (GimpDrawable *, - gint, - gdouble *); +gboolean dodgeburn_non_gui (GimpDrawable *drawable, + gdouble exposure, + DodgeBurnType type, + DodgeBurnMode mode, + gint num_strokes, + gdouble *stroke_array); +gboolean dodgeburn_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_dodgeburn (void); -void tools_free_dodgeburn (Tool *); +void tools_free_dodgeburn (Tool *tool); #endif /* __DODGEBURN_H__ */ diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c index 1ffa616c08..5467be7ede 100644 --- a/app/paint/gimperaser.c +++ b/app/paint/gimperaser.c @@ -42,7 +42,7 @@ #include "libgimp/gimpintl.h" -/* Defaults */ +/* Defaults */ #define ERASER_DEFAULT_HARD FALSE #define ERASER_DEFAULT_INCREMENTAL FALSE #define ERASER_DEFAULT_ANTI_ERASE FALSE @@ -50,6 +50,7 @@ /* the eraser structures */ typedef struct _EraserOptions EraserOptions; + struct _EraserOptions { PaintOptions paint_options; @@ -64,6 +65,18 @@ struct _EraserOptions }; +/* forward function declarations */ +static gpointer eraser_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void eraser_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + gboolean hard, + gboolean incremental, + gboolean anti_erase); + + /* the eraser tool options */ static EraserOptions *eraser_options = NULL; @@ -72,11 +85,6 @@ static gboolean non_gui_hard; static gboolean non_gui_incremental; static gboolean non_gui_anti_erase; -/* forward function declarations */ -static void eraser_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, - gboolean, gboolean, gboolean); - /* functions */ @@ -137,7 +145,7 @@ eraser_options_new (void) static void eraser_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -164,10 +172,10 @@ eraser_modifier_key_func (Tool *tool, } -void * +static gpointer eraser_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -196,8 +204,8 @@ eraser_paint_func (PaintCore *paint_core, Tool * tools_new_eraser (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! eraser_options) @@ -274,10 +282,10 @@ eraser_motion (PaintCore *paint_core, } -static void * +static gpointer eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { eraser_motion (paint_core, drawable, &non_gui_pressure_options, @@ -288,8 +296,8 @@ eraser_non_gui_paint_func (PaintCore *paint_core, gboolean eraser_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gboolean hardness = ERASER_DEFAULT_HARD; gboolean method = ERASER_DEFAULT_INCREMENTAL; @@ -310,13 +318,13 @@ eraser_non_gui_default (GimpDrawable *drawable, gboolean eraser_non_gui (GimpDrawable *drawable, - int num_strokes, - double *stroke_array, - int hardness, - int method, - int anti_erase) + gint num_strokes, + gdouble *stroke_array, + gint hardness, + gint method, + gboolean anti_erase) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -351,6 +359,6 @@ eraser_non_gui (GimpDrawable *drawable, paint_core_cleanup (); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/paint/gimperaser.h b/app/paint/gimperaser.h index 5a94a4c044..35eb35d4e2 100644 --- a/app/paint/gimperaser.h +++ b/app/paint/gimperaser.h @@ -20,21 +20,18 @@ #define __ERASER_H__ -void * eraser_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean eraser_non_gui (GimpDrawable *, - gint , - gdouble *, - gint , - gint , - gint ); -gboolean eraser_non_gui_default (GimpDrawable *, - gint , - gdouble *); +gboolean eraser_non_gui (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array, + gint hardness, + gint method, + gboolean anti_erase); +gboolean eraser_non_gui_default (GimpDrawable *paint_core, + gint num_strokes, + gdouble *stroke_array); -Tool * tools_new_eraser (void ); -void tools_free_eraser (Tool *); +Tool * tools_new_eraser (void); +void tools_free_eraser (Tool *tool); #endif /* __ERASER_H__ */ diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c index 3673948f53..cf59f94716 100644 --- a/app/paint/gimpink.c +++ b/app/paint/gimpink.c @@ -57,7 +57,13 @@ /* the Ink structures */ -typedef Blob *(*BlobFunc) (gdouble, gdouble, gdouble, gdouble, gdouble, gdouble); +typedef Blob * (* BlobFunc) (gdouble, + gdouble, + gdouble, + gdouble, + gdouble, + gdouble); + typedef struct _InkTool InkTool; @@ -88,8 +94,8 @@ typedef struct _BrushWidget BrushWidget; struct _BrushWidget { - GtkWidget *widget; - gboolean state; + GtkWidget *widget; + gboolean state; }; typedef struct _InkOptions InkOptions; @@ -130,95 +136,109 @@ struct _InkOptions }; -/* the ink tool options */ -static InkOptions * ink_options = NULL; +/* local function prototypes */ + +static void ink_button_press (Tool *tool, + GdkEventButton *mevent, + GDisplay *gdisp); +static void ink_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void ink_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void ink_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void ink_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void time_smoother_add (InkTool *ink_tool, + guint32 value); +static gdouble time_smoother_result (InkTool *ink_tool); +static void time_smoother_init (InkTool *ink_tool, + guint32 initval); +static void dist_smoother_add (InkTool *ink_tool, + gdouble value); +static gdouble dist_smoother_result (InkTool *ink_tool); +static void dist_smoother_init (InkTool *ink_tool, + gdouble initval); + +static void ink_init (InkTool *ink_tool, + GimpDrawable *drawable, + gdouble x, + gdouble y); +static void ink_finish (InkTool *ink_tool, + GimpDrawable *drawable, + gint tool_id); +static void ink_cleanup (void); + +static void ink_type_update (GtkWidget *radio_button, + BlobFunc function); +static GdkPixmap * blob_pixmap (GdkColormap *colormap, + GdkVisual *visual, + BlobFunc function); +static void paint_blob (GdkDrawable *drawable, + GdkGC *gc, + Blob *blob); + +/* Rendering functions */ +static void ink_set_paint_area (InkTool *ink_tool, + GimpDrawable *drawable, + Blob *blob); +static void ink_paste (InkTool *ink_tool, + GimpDrawable *drawable, + Blob *blob); + +static void ink_to_canvas_tiles (InkTool *ink_tool, + Blob *blob, + guchar *color); + +static void ink_set_undo_tiles (GimpDrawable *drawable, + gint x, + gint y, + gint w, + gint h); +static void ink_set_canvas_tiles (gint x, + gint y, + gint w, + gint h); + +/* Brush pseudo-widget callbacks */ +static void brush_widget_active_rect (BrushWidget *brush_widget, + GtkWidget *widget, + GdkRectangle *rect); +static void brush_widget_realize (GtkWidget *widget); +static void brush_widget_expose (GtkWidget *widget, + GdkEventExpose *event, + BrushWidget *brush_widget); +static void brush_widget_button_press (GtkWidget *widget, + GdkEventButton *event, + BrushWidget *brush_widget); +static void brush_widget_button_release (GtkWidget *widget, + GdkEventButton *event, + BrushWidget *brush_widget); +static void brush_widget_motion_notify (GtkWidget *widget, + GdkEventMotion *event, + BrushWidget *brush_widget); + /* local variables */ +/* the ink tool options */ +static InkOptions *ink_options = NULL; + /* undo blocks variables */ -static TileManager * undo_tiles = NULL; +static TileManager *undo_tiles = NULL; /* Tiles used to render the stroke at 1 byte/pp */ -static TileManager * canvas_tiles = NULL; +static TileManager *canvas_tiles = NULL; /* Flat buffer that is used to used to render the dirty region * for composition onto the destination drawable */ -static TempBuf * canvas_buf = NULL; - - -/* local function prototypes */ - -static void ink_button_press (Tool *, GdkEventButton *, gpointer); -static void ink_button_release (Tool *, GdkEventButton *, gpointer); -static void ink_motion (Tool *, GdkEventMotion *, gpointer); -static void ink_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void ink_control (Tool *, ToolAction, gpointer); - -static void time_smoother_add (InkTool* ink_tool, guint32 value); -static gdouble time_smoother_result (InkTool* ink_tool); -static void time_smoother_init (InkTool* ink_tool, guint32 initval); -static void dist_smoother_add (InkTool* ink_tool, gdouble value); -static gdouble dist_smoother_result (InkTool* ink_tool); -static void dist_smoother_init (InkTool* ink_tool, gdouble initval); - -static void ink_init (InkTool *ink_tool, - GimpDrawable *drawable, - double x, - double y); -static void ink_finish (InkTool *ink_tool, - GimpDrawable *drawable, - int tool_id); -static void ink_cleanup (void); - -static void ink_type_update (GtkWidget *radio_button, - BlobFunc function); -static GdkPixmap *blob_pixmap (GdkColormap *colormap, - GdkVisual *visual, - BlobFunc function); -static void paint_blob (GdkDrawable *drawable, - GdkGC *gc, - Blob *blob); - -/* Rendering functions */ -static void ink_set_paint_area (InkTool *ink_tool, - GimpDrawable *drawable, - Blob *blob); -static void ink_paste (InkTool *ink_tool, - GimpDrawable *drawable, - Blob *blob); - -static void ink_to_canvas_tiles (InkTool *ink_tool, - Blob *blob, - guchar *color); - -static void ink_set_undo_tiles (GimpDrawable *drawable, - int x, - int y, - int w, - int h); -static void ink_set_canvas_tiles(int x, - int y, - int w, - int h); - -/* Brush pseudo-widget callbacks */ -static void brush_widget_active_rect (BrushWidget *brush_widget, - GtkWidget *w, - GdkRectangle *rect); -static void brush_widget_realize (GtkWidget *w); -static void brush_widget_expose (GtkWidget *w, - GdkEventExpose *event, - BrushWidget *brush_widget); -static void brush_widget_button_press (GtkWidget *w, - GdkEventButton *event, - BrushWidget *brush_widget); -static void brush_widget_button_release (GtkWidget *w, - GdkEventButton *event, - BrushWidget *brush_widget); -static void brush_widget_motion_notify (GtkWidget *w, - GdkEventMotion *event, - BrushWidget *brush_widget); +static TempBuf *canvas_buf = NULL; /* functions */ @@ -798,15 +818,13 @@ ink_pen_ellipse (gdouble x_center, gdouble y_center, static void ink_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { gdouble x, y; - GDisplay *gdisp; InkTool *ink_tool; GimpDrawable *drawable; Blob *b; - gdisp = (GDisplay *) gdisp_ptr; ink_tool = (InkTool *) tool->private; /* Keep the coordinates of the target */ @@ -816,8 +834,8 @@ ink_button_press (Tool *tool, ink_init (ink_tool, drawable, x, y); - tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->state = ACTIVE; + tool->gdisp = gdisp; tool->paused_count = 0; /* pause the current selection and grab the pointer */ @@ -834,7 +852,7 @@ ink_button_press (Tool *tool, GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; b = ink_pen_ellipse (x, y, @@ -856,14 +874,12 @@ ink_button_press (Tool *tool, static void ink_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - GImage * gimage; - InkTool * ink_tool; + GImage *gimage; + InkTool *ink_tool; - gdisp = (GDisplay *) gdisp_ptr; - gimage = gdisp->gimage; + gimage = gdisp->gimage; ink_tool = (InkTool *) tool->private; /* resume the current selection and ungrab the pointer */ @@ -965,21 +981,18 @@ time_smoother_add (InkTool* ink_tool, guint32 value) static void ink_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - InkTool *ink_tool; + InkTool *ink_tool; GimpDrawable *drawable; - Blob *b, *blob_union; + Blob *b, *blob_union; - double x, y; - double pressure; - double velocity; - double dist; + gdouble x, y; + gdouble pressure; + gdouble velocity; + gdouble dist; gdouble lasttime, thistime; - - gdisp = (GDisplay *) gdisp_ptr; ink_tool = (InkTool *) tool->private; gdisplay_untransform_coords_f (gdisp, mevent->x, mevent->y, &x, &y, TRUE); @@ -1034,14 +1047,11 @@ ink_motion (Tool *tool, static void ink_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + gint x, y; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -1073,7 +1083,7 @@ ink_cursor_update (Tool *tool, static void ink_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { InkTool *ink_tool; @@ -1099,8 +1109,10 @@ ink_control (Tool *tool, } static void -ink_init (InkTool *ink_tool, GimpDrawable *drawable, - double x, double y) +ink_init (InkTool *ink_tool, + GimpDrawable *drawable, + gdouble x, + gdouble y) { /* free the block structures */ if (undo_tiles) @@ -1123,7 +1135,9 @@ ink_init (InkTool *ink_tool, GimpDrawable *drawable, } static void -ink_finish (InkTool *ink_tool, GimpDrawable *drawable, int tool_id) +ink_finish (InkTool *ink_tool, + GimpDrawable *drawable, + gint tool_id) { /* push an undo */ drawable_apply_image (drawable, ink_tool->x1, ink_tool->y1, @@ -1178,9 +1192,9 @@ ink_set_paint_area (InkTool *ink_tool, GimpDrawable *drawable, Blob *blob) { - int x, y, width, height; - int x1, y1, x2, y2; - int bytes; + gint x, y, width, height; + gint x1, y1, x2, y2; + gint bytes; blob_bounds (blob, &x, &y, &width, &height); @@ -1203,10 +1217,12 @@ enum { ROW_START, ROW_STOP }; /* The insertion sort here, for SUBSAMPLE = 8, tends to beat out * qsort() by 4x with CFLAGS=-O2, 2x with CFLAGS=-g */ -static void insert_sort (int *data, int n) +static void +insert_sort (gint *data, + gint n) { - int i, j, k; - int tmp1, tmp2; + gint i, j, k; + gint tmp1, tmp2; for (i=2; i<2*n; i+=2) { @@ -1230,7 +1246,7 @@ static void insert_sort (int *data, int n) static void fill_run (guchar *dest, guchar alpha, - int w) + gint w) { if (alpha == 255) { @@ -1247,17 +1263,20 @@ fill_run (guchar *dest, } static void -render_blob_line (Blob *blob, guchar *dest, - int x, int y, int width) +render_blob_line (Blob *blob, + guchar *dest, + gint x, + gint y, + gint width) { - int buf[4*SUBSAMPLE]; - int *data = buf; - int n = 0; - int i, j; - int current = 0; /* number of filled rows at this point - * in the scan line */ - - int last_x; + gint buf[4*SUBSAMPLE]; + gint *data = buf; + gint n = 0; + gint i, j; + gint current = 0; /* number of filled rows at this point + * in the scan line + */ + gint last_x; /* Sort start and ends for all lines */ @@ -1309,8 +1328,8 @@ render_blob_line (Blob *blob, guchar *dest, last_x = 0; for (i=0; icore = draw_core_new (ink_no_draw); + private->core = draw_core_new (ink_no_draw); private->last_blob = NULL; tool->private = private; @@ -1570,7 +1593,7 @@ tools_new_ink (void) void tools_free_ink (Tool *tool) { - InkTool * ink_tool; + InkTool *ink_tool; ink_tool = (InkTool *) tool->private; diff --git a/app/paint/gimpink.h b/app/paint/gimpink.h index 3dfb214846..9c35db1c6b 100644 --- a/app/paint/gimpink.h +++ b/app/paint/gimpink.h @@ -23,6 +23,7 @@ Tool * tools_new_ink (void); void tools_free_ink (Tool *tool); + /* Procedure definition and marshalling function */ extern ProcRecord ink_proc; diff --git a/app/paint/gimppencil.c b/app/paint/gimppencil.c index 860d3da779..345a2a855b 100644 --- a/app/paint/gimppencil.c +++ b/app/paint/gimppencil.c @@ -40,6 +40,8 @@ #include "tool_options.h" +#define PENCIL_INCREMENTAL_DEFAULT FALSE + /* the pencil tool options */ typedef struct _PencilOptions PencilOptions; @@ -48,23 +50,29 @@ struct _PencilOptions PaintOptions paint_options; }; -static PencilOptions *pencil_options = NULL; /* forward function declarations */ -static void pencil_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, gboolean); +static void pencil_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + gboolean ); +static gpointer pencil_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + + +static PencilOptions *pencil_options = NULL; static gboolean non_gui_incremental = FALSE; static void pencil_options_reset (void); -#define PENCIL_INCREMENTAL_DEFAULT FALSE /* functions */ -void * +gpointer pencil_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -203,10 +211,10 @@ pencil_motion (PaintCore *paint_core, HARD, scale, paint_appl_mode); } -static void * +static gpointer pencil_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { pencil_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_incremental); diff --git a/app/paint/gimppencil.h b/app/paint/gimppencil.h index 5bdadd451c..888d3832ea 100644 --- a/app/paint/gimppencil.h +++ b/app/paint/gimppencil.h @@ -20,12 +20,9 @@ #define __PENCIL_H__ -void * pencil_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean pencil_non_gui (GimpDrawable *, - gint , - gdouble *); +gboolean pencil_non_gui (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_pencil (void); void tools_free_pencil (Tool *tool); diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c index 26bdff458e..3aae2073cb 100644 --- a/app/paint/gimpsmudge.c +++ b/app/paint/gimpsmudge.c @@ -63,30 +63,40 @@ struct _SmudgeOptions GtkObject *rate_w; }; + +/* function prototypes */ +static gpointer smudge_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void smudge_motion (PaintCore *paint_core, + PaintPressureOptions *pressure_options, + gdouble smudge_rate, + GimpDrawable *drawable); +static gboolean smudge_init (PaintCore *paint_core, + GimpDrawable *drawable); +static void smudge_finish (PaintCore *paint_core, + GimpDrawable *drawable); + +static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, + gint *x, + gint *y, + gint *w, + gint *h); +static void smudge_allocate_accum_buffer (gint w, + gint h, + gint bytes, + guchar *do_fill); + + +/* local variables */ static PixelRegion accumPR; static guchar *accum_data; /* the smudge tool options */ static SmudgeOptions * smudge_options = NULL; -/* local variables */ static gdouble non_gui_rate; -/* function prototypes */ -static void smudge_motion (PaintCore *, PaintPressureOptions *, - gdouble, GimpDrawable *); -static gboolean smudge_init (PaintCore *, GimpDrawable *); -static void smudge_finish (PaintCore *, GimpDrawable *); - -static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, - gint *x, - gint *y, - gint *w, - gint *h); -static void smudge_allocate_accum_buffer (gint w, - gint h, - gint bytes, - guchar *do_fill); static void smudge_options_reset (void) @@ -143,10 +153,10 @@ smudge_options_new (void) return options; } -void * +static gpointer smudge_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { /* initialization fails if the user starts outside the drawable */ static gboolean initialized = FALSE; @@ -157,13 +167,18 @@ smudge_paint_func (PaintCore *paint_core, if (!initialized) initialized = smudge_init (paint_core, drawable); if (initialized) - smudge_motion (paint_core, smudge_options->paint_options.pressure_options, + smudge_motion (paint_core, + smudge_options->paint_options.pressure_options, smudge_options->rate, drawable); break; + case FINISH_PAINT: smudge_finish (paint_core, drawable); initialized = FALSE; break; + + default: + break; } return NULL; @@ -198,12 +213,12 @@ static gboolean smudge_init (PaintCore *paint_core, GimpDrawable *drawable) { - GImage *gimage; - TempBuf *area; + GImage *gimage; + TempBuf *area; PixelRegion srcPR; - gint x, y, w, h; - gint was_clipped; - guchar *do_fill = NULL; + gint x, y, w, h; + gint was_clipped; + guchar *do_fill = NULL; if (! (gimage = drawable_gimage (drawable))) return FALSE; @@ -239,7 +254,7 @@ smudge_init (PaintCore *paint_core, do_fill = gimp_drawable_get_color_at (drawable, CLAMP ((gint) paint_core->curx, 0, gimp_drawable_width (drawable) - 1), CLAMP ((gint) paint_core->cury, 0, gimp_drawable_height (drawable) - 1)); - + smudge_allocate_accum_buffer (w, h, gimp_drawable_bytes (drawable), do_fill); accumPR.x = area->x - x; @@ -277,7 +292,7 @@ smudge_allocate_accum_buffer (gint w, gint h, gint bytes, guchar *do_fill) -{ +{ /* Allocate the accumulation buffer */ accumPR.bytes = bytes; accum_data = g_malloc (w * h * bytes); @@ -332,12 +347,12 @@ smudge_motion (PaintCore *paint_core, gdouble smudge_rate, GimpDrawable *drawable) { - GImage *gimage; - TempBuf * area; - PixelRegion srcPR, destPR, tempPR; - gdouble rate; - gint opacity; - gint x,y,w,h; + GImage *gimage; + TempBuf *area; + PixelRegion srcPR, destPR, tempPR; + gdouble rate; + gint opacity; + gint x, y, w, h; if (! (gimage = drawable_gimage (drawable))) return; @@ -425,10 +440,10 @@ smudge_motion (PaintCore *paint_core, 1.0, INCREMENTAL); } -static void * +static gpointer smudge_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { smudge_motion (paint_core, &non_gui_pressure_options, non_gui_rate, drawable); @@ -437,8 +452,8 @@ smudge_non_gui_paint_func (PaintCore *paint_core, gboolean smudge_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gdouble rate = SMUDGE_DEFAULT_RATE; SmudgeOptions *options = smudge_options; @@ -452,8 +467,8 @@ smudge_non_gui_default (GimpDrawable *drawable, gboolean smudge_non_gui (GimpDrawable *drawable, gdouble rate, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gint i; @@ -493,6 +508,6 @@ smudge_non_gui (GimpDrawable *drawable, smudge_finish (&non_gui_paint_core, drawable); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/paint/gimpsmudge.h b/app/paint/gimpsmudge.h index a87d0ffe60..0ea9609198 100644 --- a/app/paint/gimpsmudge.h +++ b/app/paint/gimpsmudge.h @@ -33,16 +33,14 @@ typedef enum SMUDGE_MODE_SHADOWS } SmudgeMode; -void * smudge_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean smudge_non_gui (GimpDrawable *, - gdouble , - gint , - gdouble *); -gboolean smudge_non_gui_default (GimpDrawable *, - gint , - gdouble *); + +gboolean smudge_non_gui (GimpDrawable *drawable, + gdouble rate, + gint num_strokes, + gdouble *stroke_array); +gboolean smudge_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_smudge (void); void tools_free_smudge (Tool *tool); diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c index 7c16c6f684..320e2c7725 100644 --- a/app/paint/gimpsourcecore.c +++ b/app/paint/gimpsourcecore.c @@ -79,37 +79,59 @@ struct _CloneOptions }; +/* forward function declarations */ + +static gpointer clone_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void clone_draw (Tool *tool); +static void clone_motion (PaintCore *paint_core, + GimpDrawable *drawable, + GimpDrawable *src_drawable, + PaintPressureOptions *pressure_options, + CloneType type, + gint offset_x, + gint offset_y); +static void clone_line_image (GImage *dest, + GImage *src, + GimpDrawable *d_drawable, + GimpDrawable *s_drawable, + guchar *s, + guchar *d, + gint has_alpha, + gint src_bytes, + gint dest_bytes, + gint width); +static void clone_line_pattern (GImage *dest, + GimpDrawable *drawable, + GPattern *pattern, + guchar *d, + gint x, + gint y, + gint bytes, + gint width); + + /* the clone tool options */ static CloneOptions *clone_options = NULL; /* local variables */ -static int src_x = 0; /* */ -static int src_y = 0; /* position of clone src */ -static int dest_x = 0; /* */ -static int dest_y = 0; /* position of clone src */ -static int offset_x = 0; /* */ -static int offset_y = 0; /* offset for cloning */ -static int first = TRUE; -static int trans_tx, trans_ty; /* transformed target */ +static gint src_x = 0; /* */ +static gint src_y = 0; /* position of clone src */ +static gint dest_x = 0; /* */ +static gint dest_y = 0; /* position of clone src */ +static gint offset_x = 0; /* */ +static gint offset_y = 0; /* offset for cloning */ +static gint first = TRUE; +static gint trans_tx, trans_ty; /* transformed target */ static GDisplay *the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable *src_drawable_ = NULL; /* source drawable */ static GimpDrawable *non_gui_src_drawable; -static int non_gui_offset_x; -static int non_gui_offset_y; +static gint non_gui_offset_x; +static gint non_gui_offset_y; static CloneType non_gui_type; -/* forward function declarations */ - -static void clone_draw (Tool *); -static void clone_motion (PaintCore *, GimpDrawable *, GimpDrawable *, - PaintPressureOptions *, CloneType, int, int); -static void clone_line_image (GImage *, GImage *, GimpDrawable *, - GimpDrawable *, unsigned char *, - unsigned char *, int, int, int, int); -static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, - unsigned char *, int, int, int, int); - /* functions */ @@ -128,8 +150,8 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *frame; /* the new clone tool options structure */ options = g_new (CloneOptions, 1); @@ -202,23 +224,24 @@ clone_set_src_drawable (GimpDrawable *drawable) } } -void * +static gpointer clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - gint state) + PaintState state) { - GDisplay * gdisp; - GDisplay * src_gdisp; - int x1, y1, x2, y2; - static int orig_src_x, orig_src_y; + GDisplay *gdisp; + GDisplay *src_gdisp; + gint x1, y1, x2, y2; + static gint orig_src_x, orig_src_y; - gdisp = (GDisplay *) active_tool->gdisp_ptr; + gdisp = (GDisplay *) active_tool->gdisp; switch (state) { case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; @@ -320,14 +343,11 @@ clone_paint_func (PaintCore *paint_core, void clone_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + gint x, y; gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y, &x, &y, TRUE, FALSE); @@ -661,10 +681,10 @@ clone_line_pattern (GImage *dest, } } -static void * -clone_non_gui_paint_func (PaintCore *paint_core, +static gpointer +clone_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { clone_motion (paint_core, drawable, non_gui_src_drawable, &non_gui_pressure_options, @@ -675,16 +695,16 @@ clone_non_gui_paint_func (PaintCore *paint_core, gboolean clone_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { GimpDrawable *src_drawable = NULL; CloneType clone_type = CLONE_DEFAULT_TYPE; - double local_src_x = 0.0; - double local_src_y = 0.0; + gdouble local_src_x = 0.0; + gdouble local_src_y = 0.0; CloneOptions *options = clone_options; - - if(options) + + if (options) { clone_type = options->type; src_drawable = src_drawable_; @@ -692,23 +712,23 @@ clone_non_gui_default (GimpDrawable *drawable, local_src_y = src_y; } - return clone_non_gui(drawable, - src_drawable, - clone_type, - local_src_x,local_src_y, - num_strokes,stroke_array); + return clone_non_gui (drawable, + src_drawable, + clone_type, + local_src_x,local_src_y, + num_strokes, stroke_array); } gboolean clone_non_gui (GimpDrawable *drawable, GimpDrawable *src_drawable, CloneType clone_type, - double src_x, - double src_y, - int num_strokes, - double *stroke_array) + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) diff --git a/app/paint/gimpsourcecore.h b/app/paint/gimpsourcecore.h index 0433bc488e..fcc2f1d247 100644 --- a/app/paint/gimpsourcecore.h +++ b/app/paint/gimpsourcecore.h @@ -26,21 +26,19 @@ typedef enum PATTERN_CLONE } CloneType; -void * clone_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean clone_non_gui (GimpDrawable *, - GimpDrawable *, - CloneType, - gdouble, - gdouble, - gint, - gdouble *); -gboolean clone_non_gui_default (GimpDrawable *, - gint, - gdouble *); + +gboolean clone_non_gui (GimpDrawable *drawable, + GimpDrawable *src_drawable, + CloneType clone_type, + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array); +gboolean clone_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_clone (void); -void tools_free_clone (Tool *); +void tools_free_clone (Tool *tool); #endif /* __CLONE_H__ */ diff --git a/app/paint_core.c b/app/paint_core.c index b6ca82f003..bf257188ff 100644 --- a/app/paint_core.c +++ b/app/paint_core.c @@ -196,18 +196,16 @@ paint_core_sample_color (GimpDrawable *drawable, void -paint_core_button_press (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr) +paint_core_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp) { PaintCore *paint_core; - GDisplay *gdisp; GimpBrush *current_brush; gboolean draw_line; gdouble x, y; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; paint_core = (PaintCore *) tool->private; g_return_if_fail (gdisp != NULL); @@ -230,7 +228,7 @@ paint_core_button_press (Tool *tool, #endif /* GTK_HAVE_SIX_VALUATORS */ paint_core->state = bevent->state; - if (gdisp_ptr != tool->gdisp_ptr || + if (gdisp != tool->gdisp || paint_core->context_id < 1) { /* initialize the statusbar display */ @@ -239,7 +237,7 @@ paint_core_button_press (Tool *tool, } /* if this is a new image, reinit the core vals */ - if ((gdisp_ptr != tool->gdisp_ptr) || ! (bevent->state & GDK_SHIFT_MASK)) + if ((gdisp != tool->gdisp) || ! (bevent->state & GDK_SHIFT_MASK)) { /* initialize some values */ paint_core->startx = paint_core->lastx = paint_core->curx = x; @@ -295,7 +293,7 @@ paint_core_button_press (Tool *tool, } tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->paused_count = 0; /* pause the current selection and grab the pointer */ @@ -369,7 +367,7 @@ paint_core_button_press (Tool *tool, if (paint_core->flags & TOOL_TRACES_ON_WINDOW) (* paint_core->paint_func) (paint_core, drawable, PRETRACE_PAINT); - + gdisplay_flush_now (gdisp); if (paint_core->flags & TOOL_TRACES_ON_WINDOW) @@ -382,14 +380,12 @@ paint_core_button_press (Tool *tool, void paint_core_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; GImage *gimage; PaintCore *paint_core; - gdisp = (GDisplay *) gdisp_ptr; - gimage = gdisp->gimage; + gimage = gdisp->gimage; paint_core = (PaintCore *) tool->private; /* resume the current selection and ungrab the pointer */ @@ -415,14 +411,12 @@ paint_core_button_release (Tool *tool, } void -paint_core_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr) +paint_core_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp) { - GDisplay *gdisp; PaintCore *paint_core; - gdisp = (GDisplay *) gdisp_ptr; paint_core = (PaintCore *) tool->private; gdisplay_untransform_coords_f (gdisp, (double) mevent->x, (double) mevent->y, @@ -470,11 +464,10 @@ paint_core_motion (Tool *tool, } void -paint_core_cursor_update (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr) +paint_core_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp) { - GDisplay *gdisp; Layer *layer; PaintCore *paint_core; gint x, y; @@ -484,14 +477,12 @@ paint_core_cursor_update (Tool *tool, CursorModifier cmodifier = CURSOR_MODIFIER_NONE; gboolean ctoggle = FALSE; - gdisp = (GDisplay *) gdisp_ptr; paint_core = (PaintCore *) tool->private; /* undraw the current tool */ draw_core_pause (paint_core->core, tool); - if (gdisp_ptr != tool->gdisp_ptr || - paint_core->context_id < 1) + if (gdisp != tool->gdisp || paint_core->context_id < 1) { /* initialize the statusbar display */ paint_core->context_id = @@ -504,16 +495,16 @@ paint_core_cursor_update (Tool *tool, if ((layer = gimp_image_get_active_layer (gdisp->gimage))) { /* If shift is down and this is not the first paint stroke, draw a line */ - if (gdisp_ptr == tool->gdisp_ptr && (mevent->state & GDK_SHIFT_MASK)) + if (gdisp == tool->gdisp && (mevent->state & GDK_SHIFT_MASK)) { gdouble dx, dy, d; - ctype = GDK_PENCIL; + ctype = GDK_PENCIL; /* Get the current coordinates */ - gdisplay_untransform_coords_f (gdisp, - (double) mevent->x, + gdisplay_untransform_coords_f (gdisp, + (double) mevent->x, (double) mevent->y, - &paint_core->curx, + &paint_core->curx, &paint_core->cury, TRUE); dx = paint_core->curx - paint_core->lastx; @@ -527,7 +518,7 @@ paint_core_cursor_update (Tool *tool, gint tangens2[6] = { 34, 106, 196, 334, 618, 1944 }; gint cosinus[7] = { 256, 247, 222, 181, 128, 66, 0 }; gint i, radius, frac; - + if (idy) { radius = sqrt (SQR (idx) + SQR (idy)); @@ -640,17 +631,15 @@ paint_core_cursor_update (Tool *tool, } void -paint_core_control (Tool *tool, - ToolAction action, - gpointer gdisp_ptr) +paint_core_control (Tool *tool, + ToolAction action, + GDisplay *gdisp) { PaintCore *paint_core; - GDisplay *gdisp; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; paint_core = (PaintCore *) tool->private; - drawable = gimp_image_active_drawable (gdisp->gimage); + drawable = gimp_image_active_drawable (gdisp->gimage); switch (action) { @@ -684,7 +673,7 @@ paint_core_draw (Tool *tool) and we don't care about a redraw */ if (paint_core->core->gc != NULL) { - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; gdisplay_transform_coords (gdisp, paint_core->lastx, paint_core->lasty, &tx1, &ty1, 1); @@ -853,10 +842,9 @@ paint_core_interpolate (PaintCore *paint_core, { GimpBrush *current_brush; GimpVector2 delta; -#ifdef GTK_HAVE_SIX_VALUATORS - gdouble dpressure, dxtilt, dytilt, dwheel; -#else /* !GTK_HAVE_SIX_VALUATORS */ gdouble dpressure, dxtilt, dytilt; +#ifdef GTK_HAVE_SIX_VALUATORS + gdouble dwheel; #endif /* GTK_HAVE_SIX_VALUATORS */ /* double spacing; */ /* double lastscale, curscale; */ @@ -888,7 +876,7 @@ paint_core_interpolate (PaintCore *paint_core, #endif /* GTK_HAVE_SIX_VALUATORS */ return; -/* calculate the distance traveled in the coordinate space of the brush */ + /* calculate the distance traveled in the coordinate space of the brush */ mag = gimp_vector2_length (&(paint_core->brush->x_axis)); xd = gimp_vector2_inner_product (&delta, &(paint_core->brush->x_axis)) / (mag*mag); @@ -897,11 +885,11 @@ paint_core_interpolate (PaintCore *paint_core, yd = gimp_vector2_inner_product (&delta, &(paint_core->brush->y_axis)) / (mag*mag); - dist = 0.5 * sqrt (xd*xd + yd*yd); - total = dist + paint_core->distance; + dist = 0.5 * sqrt (xd*xd + yd*yd); + total = dist + paint_core->distance; initial = paint_core->distance; - pixel_dist = gimp_vector2_length (&delta); + pixel_dist = gimp_vector2_length (&delta); pixel_initial = paint_core->pixel_dist; /* FIXME: need to adapt the spacing to the size */ @@ -911,9 +899,9 @@ paint_core_interpolate (PaintCore *paint_core, while (paint_core->distance < total) { - n = (int) (paint_core->distance / paint_core->spacing + 1.0 + EPSILON); + n = (gint) (paint_core->distance / paint_core->spacing + 1.0 + EPSILON); left = n * paint_core->spacing - paint_core->distance; - + paint_core->distance += left; if (paint_core->distance <= (total+EPSILON)) @@ -943,6 +931,7 @@ paint_core_interpolate (PaintCore *paint_core, paint_core->brush = current_brush; } } + paint_core->distance = total; paint_core->pixel_dist = pixel_initial + pixel_dist; paint_core->curx = paint_core->lastx + delta.x; @@ -1190,7 +1179,8 @@ paint_core_paste_canvas (PaintCore *paint_core, MaskBuf *brush_mask; /* get the brush mask */ - brush_mask = paint_core_get_brush_mask (paint_core, brush_hardness, brush_scale); + brush_mask = paint_core_get_brush_mask (paint_core, + brush_hardness, brush_scale); /* paste the canvas buf */ paint_core_paste (paint_core, brush_mask, drawable, @@ -1255,9 +1245,9 @@ paint_core_calculate_brush_size (MaskBuf *mask, ratio = 1 / 16; else ratio = sqrt (scale); - - *width = MAX ((gint)(mask->width * ratio + 0.5), 1); - *height = MAX ((gint)(mask->height * ratio + 0.5), 1); + + *width = MAX ((gint) (mask->width * ratio + 0.5), 1); + *height = MAX ((gint) (mask->height * ratio + 0.5), 1); } } @@ -1279,12 +1269,12 @@ paint_core_subsample_mask (MaskBuf *mask, gint r, s; x += (x < 0) ? mask->width : 0; - left = x - floor(x); - index1 = (int) (left * (gdouble)(SUBSAMPLE + 1)); + left = x - floor (x); + index1 = (gint) (left * (gdouble) (SUBSAMPLE + 1)); y += (y < 0) ? mask->height : 0; - left = y - floor(y); - index2 = (int) (left * (gdouble)(SUBSAMPLE + 1)); + left = y - floor (y); + index2 = (gint) (left * (gdouble) (SUBSAMPLE + 1)); kernel = subsample[index2][index1]; @@ -1307,7 +1297,7 @@ paint_core_subsample_mask (MaskBuf *mask, last_brush_mask = mask; cache_invalid = FALSE; } - + dest = kernel_brushes[index2][index1] = mask_buf_new (mask->width + 2, mask->height + 2); @@ -1416,9 +1406,10 @@ paint_core_pressurize_mask (MaskBuf *brush_mask, } #else /* ! FANCY_PRESSURE */ - for (i=0;i<256;i++) + for (i = 0; i < 256; i++) { - int tmp = (pressure/0.5)*i; + gint tmp = (pressure / 0.5) * i; + if (tmp > 255) mapi[i] = 255; else @@ -1430,7 +1421,7 @@ paint_core_pressurize_mask (MaskBuf *brush_mask, /* Now convert the brush */ source = mask_buf_data (subsample_mask); - dest = mask_buf_data (pressure_brush); + dest = mask_buf_data (pressure_brush); i = subsample_mask->width * subsample_mask->height; while (i--) @@ -1527,13 +1518,13 @@ paint_core_scale_pixmap (MaskBuf *brush_mask, scale = CLAMP (scale, 0.0, 1.0); - if (scale == 0.0) + if (scale == 0.0) return NULL; if (scale == 1.0) return brush_mask; - paint_core_calculate_brush_size (brush_mask, scale, + paint_core_calculate_brush_size (brush_mask, scale, &dest_width, &dest_height); if (brush_mask == last_brush && !cache_invalid && @@ -1568,13 +1559,15 @@ paint_core_get_brush_mask (PaintCore *paint_core, switch (brush_hardness) { case SOFT: - mask = paint_core_subsample_mask (mask, paint_core->curx, paint_core->cury); + mask = paint_core_subsample_mask (mask, + paint_core->curx, paint_core->cury); break; case HARD: mask = paint_core_solidify_mask (mask); break; case PRESSURE: - mask = paint_core_pressurize_mask (mask, paint_core->curx, paint_core->cury, + mask = paint_core_pressurize_mask (mask, + paint_core->curx, paint_core->cury, paint_core->curpressure); break; default: @@ -1623,8 +1616,10 @@ paint_core_paste (PaintCore *paint_core, /* Otherwise: * combine the canvas buf and the brush mask to the canvas buf */ - else /* mode != CONSTANT */ - brush_to_canvas_buf (paint_core, brush_mask, brush_opacity); + else + { + brush_to_canvas_buf (paint_core, brush_mask, brush_opacity); + } /* intialize canvas buf source pixel regions */ srcPR.bytes = canvas_buf->bytes; @@ -1678,7 +1673,7 @@ paint_core_replace (PaintCore *paint_core, gint offx; gint offy; - if (!drawable_has_alpha (drawable)) + if (! drawable_has_alpha (drawable)) { paint_core_paste (paint_core, brush_mask, drawable, brush_opacity, image_opacity, NORMAL_MODE, @@ -1711,7 +1706,7 @@ paint_core_replace (PaintCore *paint_core, canvas_buf->x, canvas_buf->y, canvas_buf->width, canvas_buf->height, FALSE); } - else + else { /* The mask is just the brush mask */ maskPR.bytes = 1; @@ -1722,7 +1717,7 @@ paint_core_replace (PaintCore *paint_core, maskPR.rowstride = maskPR.bytes * brush_mask->width; maskPR.data = mask_buf_data (brush_mask); } - + /* intialize canvas buf source pixel regions */ srcPR.bytes = canvas_buf->bytes; srcPR.x = 0; diff --git a/app/paint_core.h b/app/paint_core.h index bc6ade3edd..9621bdef3f 100644 --- a/app/paint_core.h +++ b/app/paint_core.h @@ -22,13 +22,16 @@ /* the different states that the painting function can be called with */ -#define INIT_PAINT 0 /* Setup PaintFunc internals */ -#define MOTION_PAINT 1 /* PaintFunc performs motion-related rendering */ -#define PAUSE_PAINT 2 /* Unused. Reserved */ -#define RESUME_PAINT 3 /* Unused. Reserved */ -#define FINISH_PAINT 4 /* Cleanup and/or reset PaintFunc operation */ -#define PRETRACE_PAINT 5 /* PaintFunc performs window tracing activity prior to rendering */ -#define POSTTRACE_PAINT 6 /* PaintFunc performs window tracing activity following rendering */ +typedef enum /*< skip >*/ +{ + INIT_PAINT, /* Setup PaintFunc internals */ + MOTION_PAINT, /* PaintFunc performs motion-related rendering */ + PAUSE_PAINT, /* Unused. Reserved */ + RESUME_PAINT, /* Unused. Reserved */ + FINISH_PAINT, /* Cleanup and/or reset PaintFunc operation */ + PRETRACE_PAINT, /* PaintFunc performs window tracing activity prior to rendering */ + POSTTRACE_PAINT /* PaintFunc performs window tracing activity following rendering */ +} PaintState; typedef enum /*< skip >*/ { @@ -44,54 +47,56 @@ typedef enum /*< skip >*/ */ } ToolFlags; -typedef void * (* PaintFunc) (PaintCore *, GimpDrawable *, int); +typedef gpointer (* PaintFunc) (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState paint_state); struct _PaintCore { - DrawCore * core; /* Core select object */ + DrawCore * core; /* Core select object */ - double startx; /* starting x coord */ - double starty; /* starting y coord */ - double startpressure; /* starting pressure */ - double startxtilt; /* starting xtilt */ - double startytilt; /* starting ytilt */ + gdouble startx; /* starting x coord */ + gdouble starty; /* starting y coord */ + gdouble startpressure; /* starting pressure */ + gdouble startxtilt; /* starting xtilt */ + gdouble startytilt; /* starting ytilt */ #ifdef GTK_HAVE_SIX_VALUATORS - double startwheel; /* starting wheel */ + gdouble startwheel; /* starting wheel */ #endif /* GTK_HAVE_SIX_VALUATORS */ - double curx; /* current x coord */ - double cury; /* current y coord */ - double curpressure; /* current pressure */ - double curxtilt; /* current xtilt */ - double curytilt; /* current ytilt */ + gdouble curx; /* current x coord */ + gdouble cury; /* current y coord */ + gdouble curpressure; /* current pressure */ + gdouble curxtilt; /* current xtilt */ + gdouble curytilt; /* current ytilt */ #ifdef GTK_HAVE_SIX_VALUATORS - double curwheel; /* current wheel */ + gdouble curwheel; /* current wheel */ #endif /* GTK_HAVE_SIX_VALUATORS */ - double lastx; /* last x coord */ - double lasty; /* last y coord */ - double lastpressure; /* last pressure */ - double lastxtilt; /* last xtilt */ - double lastytilt; /* last ytilt */ + gdouble lastx; /* last x coord */ + gdouble lasty; /* last y coord */ + gdouble lastpressure; /* last pressure */ + gdouble lastxtilt; /* last xtilt */ + gdouble lastytilt; /* last ytilt */ #ifdef GTK_HAVE_SIX_VALUATORS - double lastwheel; /* last wheel */ + gdouble lastwheel; /* last wheel */ #endif /* GTK_HAVE_SIX_VALUATORS */ - int state; /* state of buttons and keys */ + gint state; /* state of buttons and keys */ - double distance; /* distance traveled by brush */ - double pixel_dist; /* distance in pixels */ - double spacing; /* spacing */ + gdouble distance; /* distance traveled by brush */ + gdouble pixel_dist; /* distance in pixels */ + gdouble spacing; /* spacing */ - int x1, y1; /* image space coordinate */ - int x2, y2; /* image space coords */ + gint x1, y1; /* image space coordinate */ + gint x2, y2; /* image space coords */ - GimpBrush * brush; /* current brush */ + GimpBrush * brush; /* current brush */ PaintFunc paint_func; /* painting function */ - int pick_colors; /* pick color if ctrl or alt is pressed */ - int pick_state; /* was ctrl or alt pressed when clicked? */ + gboolean pick_colors; /* pick color if ctrl or alt is pressed */ + gboolean pick_state; /* was ctrl or alt pressed when clicked? */ ToolFlags flags; /* tool flags, see ToolFlags above */ guint context_id; /* for the statusbar */ @@ -100,30 +105,38 @@ struct _PaintCore extern PaintCore non_gui_paint_core; /* Special undo type */ -typedef struct _paint_undo PaintUndo; +typedef struct _PaintUndo PaintUndo; -struct _paint_undo +struct _PaintUndo { - int tool_ID; - double lastx; - double lasty; - double lastpressure; - double lastxtilt; - double lastytilt; + gint tool_ID; + gdouble lastx; + gdouble lasty; + gdouble lastpressure; + gdouble lastxtilt; + gdouble lastytilt; #ifdef GTK_HAVE_SIX_VALUATORS - double lastwheel; + gdouble lastwheel; #endif /* GTK_HAVE_SIX_VALUATORS */ }; /* paint tool action functions */ -void paint_core_button_press (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr); -void paint_core_button_release (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr); -void paint_core_motion (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr); -void paint_core_cursor_update (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr); +void paint_core_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void paint_core_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void paint_core_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +void paint_core_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); void paint_core_control (Tool *tool, - ToolAction action, - gpointer gdisp_ptr); + ToolAction action, + GDisplay *gdisp); /* paint tool functions */ void paint_core_no_draw (Tool *tool); @@ -180,4 +193,5 @@ void paint_core_color_area_with_pixmap (PaintCore *paint_core, gdouble scale, BrushApplicationMode mode); + #endif /* __PAINT_CORE_H__ */ diff --git a/app/paintbrush.c b/app/paintbrush.c index 25d9ff065e..da15b92719 100644 --- a/app/paintbrush.c +++ b/app/paintbrush.c @@ -62,6 +62,7 @@ /* the paintbrush structures */ typedef struct _PaintbrushOptions PaintbrushOptions; + struct _PaintbrushOptions { PaintOptions paint_options; @@ -108,13 +109,16 @@ static GimpUnit non_gui_gradient_unit; /* forward function declarations */ -static void paintbrush_motion (PaintCore *, - GimpDrawable *, - PaintPressureOptions *, - gdouble, - gdouble, - PaintApplicationMode, - GradientPaintMode); +static void paintbrush_motion (PaintCore *, + GimpDrawable *, + PaintPressureOptions *, + gdouble , + gdouble , + PaintApplicationMode , + GradientPaintMode ); +static gpointer paintbrush_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); /* functions */ @@ -125,7 +129,7 @@ paintbrush_gradient_toggle_callback (GtkWidget *widget, { PaintbrushOptions *options = paintbrush_options; - static int incremental_save = FALSE; + static gboolean incremental_save = FALSE; gimp_toggle_button_update (widget, data); @@ -147,8 +151,8 @@ static void paintbrush_options_reset (void) { PaintbrushOptions *options = paintbrush_options; - GtkWidget *spinbutton; - gint digits; + GtkWidget *spinbutton; + gint digits; paint_options_reset ((PaintOptions *) options); @@ -358,10 +362,10 @@ paintbrush_options_new (void) #define TIMED_BRUSH 0 -void * +static gpointer paintbrush_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { GDisplay *gdisp = gdisplay_active (); double fade_out; @@ -584,15 +588,15 @@ paintbrush_motion (PaintCore *paint_core, } -static void * +static gpointer paintbrush_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { - GImage *gimage; - double fade_out; - double gradient_length; - double unit_factor; + GImage *gimage; + gdouble fade_out; + gdouble gradient_length; + gdouble unit_factor; if (! (gimage = drawable_gimage (drawable))) return NULL; diff --git a/app/paintbrush.h b/app/paintbrush.h index ee55408ed8..4ce8b274a9 100644 --- a/app/paintbrush.h +++ b/app/paintbrush.h @@ -20,9 +20,6 @@ #define __PAINTBRUSH_H__ -void * paintbrush_paint_func (PaintCore *, - GimpDrawable *, - gint ); gboolean paintbrush_non_gui (GimpDrawable *, gint , gdouble *, diff --git a/app/path_bezier.c b/app/path_bezier.c index 528501e212..1c890119e2 100644 --- a/app/path_bezier.c +++ b/app/path_bezier.c @@ -77,7 +77,7 @@ path_bezier_draw_handles (Tool *tool, { PathTool *path_tool = (PathTool *) (tool->private); PathBezierData *data = (PathBezierData *) segment->data; - GDisplay * gdisp = tool->gdisp_ptr; + GDisplay * gdisp = tool->gdisp; gint sx, sy, hx, hy; diff --git a/app/path_curves.c b/app/path_curves.c index 0e34aad0b0..63fab6f05f 100644 --- a/app/path_curves.c +++ b/app/path_curves.c @@ -155,7 +155,7 @@ path_curve_draw_segment (Tool *tool, numpts = path_curve_get_points (((PathTool *) tool->private), segment, coordinates, 100, 0, 1); for (index=0; index < numpts; index++) { - gdisplay_transform_coords (tool->gdisp_ptr, + gdisplay_transform_coords (tool->gdisp, coordinates[index].x, coordinates[index].y, &x, &y, FALSE); diff --git a/app/path_tool.c b/app/path_tool.c index 252d4183d3..f25924ddaa 100644 --- a/app/path_tool.c +++ b/app/path_tool.c @@ -755,9 +755,8 @@ path_tool_cursor_position (Tool *tool, void path_tool_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; PathTool * path_tool; gint grab_pointer=0; gint x, y, halfwidth, dummy; @@ -766,9 +765,8 @@ path_tool_button_press (Tool *tool, fprintf (stderr, "path_tool_button_press\n"); #endif PATH_TOOL_DEBUG - gdisp = (GDisplay *) gdisp_ptr; path_tool = (PathTool *) tool->private; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; /* Transform window-coordinates to canvas-coordinates */ gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, TRUE, 0); @@ -1099,16 +1097,14 @@ path_tool_button_press_curve (Tool *tool, void path_tool_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; PathTool * path_tool; #ifdef PATH_TOOL_DEBUG fprintf (stderr, "path_tool_button_release\n"); #endif PATH_TOOL_DEBUG - gdisp = (GDisplay *) gdisp_ptr; path_tool = (PathTool *) tool->private; path_tool->state &= ~PATH_TOOL_DRAG; @@ -1125,14 +1121,12 @@ path_tool_button_release (Tool *tool, void path_tool_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; PathTool * path_tool; if (gtk_events_pending()) return; - gdisp = (GDisplay *) gdisp_ptr; path_tool = (PathTool *) tool->private; switch (path_tool->click_type) { @@ -1314,10 +1308,9 @@ path_tool_motion_curve (Tool *tool, void path_tool_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { PathTool *path_tool; - GDisplay *gdisp; gint x, y, halfwidth, dummy, cursor_location; #ifdef PATH_TOOL_DEBUG @@ -1325,7 +1318,6 @@ path_tool_cursor_update (Tool *tool, */ #endif PATH_TOOL_DEBUG - gdisp = (GDisplay *) gdisp_ptr; path_tool = (PathTool *) tool->private; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, TRUE, 0); @@ -1361,16 +1353,14 @@ path_tool_cursor_update (Tool *tool, void path_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; PathTool * path_tool; #ifdef PATH_TOOL_DEBUG fprintf (stderr, "path_tool_control\n"); #endif PATH_TOOL_DEBUG - gdisp = (GDisplay *) tool->gdisp_ptr; path_tool = (PathTool *) tool->private; switch (action) @@ -1462,7 +1452,7 @@ tools_free_path_tool (Tool *tool) fprintf (stderr, "tools_free_path_tool start\n"); #endif PATH_TOOL_DEBUG path_tool = (PathTool *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; if (tool->state == ACTIVE) { @@ -1850,7 +1840,7 @@ path_tool_draw_helper (Path *path, return; } - gdisp = tool->gdisp_ptr; + gdisp = tool->gdisp; path_tool = (PathTool *) tool->private; core = path_tool->core; @@ -1894,7 +1884,7 @@ path_tool_draw (Tool *tool) fprintf (stderr, "path_tool_draw\n"); #endif PATH_TOOL_DEBUG - gdisp = tool->gdisp_ptr; + gdisp = tool->gdisp; path_tool = tool->private; cur_path = path_tool->cur_path; diff --git a/app/pencil.c b/app/pencil.c index 860d3da779..345a2a855b 100644 --- a/app/pencil.c +++ b/app/pencil.c @@ -40,6 +40,8 @@ #include "tool_options.h" +#define PENCIL_INCREMENTAL_DEFAULT FALSE + /* the pencil tool options */ typedef struct _PencilOptions PencilOptions; @@ -48,23 +50,29 @@ struct _PencilOptions PaintOptions paint_options; }; -static PencilOptions *pencil_options = NULL; /* forward function declarations */ -static void pencil_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, gboolean); +static void pencil_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + gboolean ); +static gpointer pencil_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + + +static PencilOptions *pencil_options = NULL; static gboolean non_gui_incremental = FALSE; static void pencil_options_reset (void); -#define PENCIL_INCREMENTAL_DEFAULT FALSE /* functions */ -void * +gpointer pencil_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -203,10 +211,10 @@ pencil_motion (PaintCore *paint_core, HARD, scale, paint_appl_mode); } -static void * +static gpointer pencil_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { pencil_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_incremental); diff --git a/app/pencil.h b/app/pencil.h index 5bdadd451c..888d3832ea 100644 --- a/app/pencil.h +++ b/app/pencil.h @@ -20,12 +20,9 @@ #define __PENCIL_H__ -void * pencil_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean pencil_non_gui (GimpDrawable *, - gint , - gdouble *); +gboolean pencil_non_gui (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_pencil (void); void tools_free_pencil (Tool *tool); diff --git a/app/perspective_tool.c b/app/perspective_tool.c index 166e4fb6fa..05af32400c 100644 --- a/app/perspective_tool.c +++ b/app/perspective_tool.c @@ -41,23 +41,28 @@ #include "libgimp/gimpintl.h" +/* forward function declarations */ +static TileManager * perspective_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); +static void perspective_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void perspective_tool_motion (Tool *tool, + GDisplay *gdisp); +static void perspective_info_update (Tool *tool); + + /* storage for information dialog fields */ static gchar matrix_row_buf [3][MAX_INFO_BUF]; -/* forward function declarations */ -static void perspective_tool_recalc (Tool *, void *); -static void perspective_tool_motion (Tool *, void *); -static void perspective_info_update (Tool *); -TileManager * +static TileManager * perspective_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { - GDisplay *gdisp; TransformCore *transform_core; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; switch (state) @@ -89,12 +94,12 @@ perspective_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - perspective_tool_motion (tool, gdisp_ptr); - perspective_tool_recalc (tool, gdisp_ptr); + perspective_tool_motion (tool, gdisp); + perspective_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - perspective_tool_recalc (tool, gdisp_ptr); + perspective_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -173,14 +178,12 @@ perspective_info_update (Tool *tool) } static void -perspective_tool_motion (Tool *tool, - void *gdisp_ptr) +perspective_tool_motion (Tool *tool, + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; gint diff_x, diff_y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; diff_x = transform_core->curx - transform_core->lastx; @@ -210,16 +213,14 @@ perspective_tool_motion (Tool *tool, } static void -perspective_tool_recalc (Tool *tool, - void *gdisp_ptr) +perspective_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; GimpMatrix3 m; gdouble cx, cy; gdouble scalex, scaley; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; /* determine the perspective transform that maps from diff --git a/app/perspective_tool.h b/app/perspective_tool.h index 611a85ecc1..39f31518ab 100644 --- a/app/perspective_tool.h +++ b/app/perspective_tool.h @@ -20,9 +20,6 @@ #define __PERSPECTIVE_TOOL_H__ -TileManager * perspective_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * perspective_tool_perspective (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/posterize.c b/app/posterize.c index c8c7cc728b..10b8b7722d 100644 --- a/app/posterize.c +++ b/app/posterize.c @@ -64,6 +64,27 @@ struct _PosterizeDialog GimpLut *lut; }; + +/* posterize action functions */ +static void posterize_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static PosterizeDialog * posterize_dialog_new (void); + +static void posterize_preview (PosterizeDialog *pd); +static void posterize_reset_callback (GtkWidget *widget, + gpointer data); +static void posterize_ok_callback (GtkWidget *widget, + gpointer data); +static void posterize_cancel_callback (GtkWidget *widget, + gpointer data); +static void posterize_preview_update (GtkWidget *widget, + gpointer data); +static void posterize_levels_adjustment_update (GtkAdjustment *adjustment, + gpointer data); + + /* the posterize tool options */ static ToolOptions *posterize_options = NULL; @@ -71,24 +92,12 @@ static ToolOptions *posterize_options = NULL; static PosterizeDialog *posterize_dialog = NULL; -/* posterize action functions */ -static void posterize_control (Tool *, ToolAction, gpointer); - -static PosterizeDialog * posterize_dialog_new (void); - -static void posterize_preview (PosterizeDialog *); -static void posterize_reset_callback (GtkWidget *, gpointer); -static void posterize_ok_callback (GtkWidget *, gpointer); -static void posterize_cancel_callback (GtkWidget *, gpointer); -static void posterize_preview_update (GtkWidget *, gpointer); -static void posterize_levels_adjustment_update (GtkAdjustment *, gpointer); - /* posterize select action functions */ static void posterize_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -311,7 +320,7 @@ posterize_ok_callback (GtkWidget *widget, posterize_lut_setup( pd->lut, pd->levels, gimp_drawable_bytes (pd->drawable)); image_map_apply (pd->image_map, (ImageMapApplyFunc) gimp_lut_process_2, - (void *) pd->lut); + (gpointer) pd->lut); } if (pd->image_map) @@ -321,7 +330,7 @@ posterize_ok_callback (GtkWidget *widget, pd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -345,7 +354,7 @@ posterize_cancel_callback (GtkWidget *widget, gdisplays_flush (); } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/rect_select.c b/app/rect_select.c index 3dbca9e287..f7e6e21845 100644 --- a/app/rect_select.c +++ b/app/rect_select.c @@ -48,26 +48,29 @@ #define STATUSBAR_SIZE 128 +extern void ellipse_select (GimpImage *gimage, + gint x, + gint y, + gint w, + gint h, + SelectOps op, + gboolean antialias, + gboolean feather, + gdouble feather_radius); + +static void selection_tool_update_op_state (RectSelect *rect_sel, + gint x, + gint y, + gint state, + GDisplay *gdisp); + + /* the rectangular selection tool options */ static SelectionOptions *rect_options = NULL; /* in gimp, ellipses are rectangular, too ;) */ extern SelectionOptions *ellipse_options; -extern void ellipse_select (GimpImage *gimage, - gint x, - gint y, - gint w, - gint h, - SelectOps op, - gboolean antialias, - gboolean feather, - gdouble feather_radius); -static void selection_tool_update_op_state (RectSelect *rect_sel, - gint x, - gint y, - gint state, - GDisplay *gdisp); /*************************************/ /* Rectangular selection apparatus */ @@ -117,16 +120,14 @@ rect_select (GimpImage *gimage, void rect_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; RectSelect *rect_sel; gchar select_mode[STATUSBAR_SIZE]; gint x, y; GimpUnit unit = GIMP_UNIT_PIXEL; gdouble unit_factor; - gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, TRUE, 0); @@ -185,15 +186,15 @@ rect_select_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; switch (rect_sel->op) { case SELECTION_MOVE_MASK: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; case SELECTION_MOVE: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; default: break; @@ -228,15 +229,13 @@ rect_select_button_press (Tool *tool, void rect_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - GDisplay *gdisp; - gint x1, y1; - gint x2, y2; - gint w, h; + gint x1, y1; + gint x2, y2; + gint w, h; - gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -301,18 +300,16 @@ rect_select_button_release (Tool *tool, void rect_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - GDisplay *gdisp; - gchar size[STATUSBAR_SIZE]; - gint ox, oy; - gint x, y; - gint w, h, s; - gint tw, th; - gdouble ratio; + gchar size[STATUSBAR_SIZE]; + gint ox, oy; + gint x, y; + gint w, h, s; + gint tw, th; + gdouble ratio; - gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; /* needed for immediate cursor update on modifier event */ @@ -326,7 +323,7 @@ rect_select_motion (Tool *tool, { rect_sel->op = SELECTION_REPLACE; - rect_select_cursor_update (tool, mevent, gdisp_ptr); + rect_select_cursor_update (tool, mevent, gdisp); } draw_core_pause (rect_sel->core, tool); @@ -472,12 +469,10 @@ rect_select_motion (Tool *tool, void rect_select_draw (Tool *tool) { - GDisplay *gdisp; RectSelect *rect_sel; - gint x1, y1; - gint x2, y2; + gint x1, y1; + gint x2, y2; - gdisp = (GDisplay *) tool->gdisp_ptr; rect_sel = (RectSelect *) tool->private; x1 = MIN (rect_sel->x, rect_sel->x + rect_sel->w); @@ -485,8 +480,8 @@ rect_select_draw (Tool *tool) x2 = MAX (rect_sel->x, rect_sel->x + rect_sel->w); y2 = MAX (rect_sel->y, rect_sel->y + rect_sel->h); - gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); - gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); + gdisplay_transform_coords (tool->gdisp, x1, y1, &x1, &y1, 0); + gdisplay_transform_coords (tool->gdisp, x2, y2, &x2, &y2, 0); gdk_draw_rectangle (rect_sel->core->win, rect_sel->core->gc, 0, @@ -553,7 +548,7 @@ selection_tool_update_op_state (RectSelect *rect_sel, void rect_select_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; @@ -565,16 +560,16 @@ rect_select_oper_update (Tool *tool, selection_tool_update_op_state (rect_sel, rect_sel->current_x, rect_sel->current_y, - mevent->state, gdisp_ptr); + mevent->state, gdisp); } void rect_select_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - gint state; + gint state; state = kevent->state; @@ -606,19 +601,17 @@ rect_select_modifier_update (Tool *tool, selection_tool_update_op_state (rect_sel, rect_sel->current_x, rect_sel->current_y, - state, gdisp_ptr); + state, gdisp); } void rect_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - GDisplay *gdisp; rect_sel = (RectSelect *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (rect_sel->op) { @@ -670,7 +663,7 @@ rect_select_cursor_update (Tool *tool, void rect_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; diff --git a/app/rect_select.h b/app/rect_select.h index ffc764b9db..4ea51d7378 100644 --- a/app/rect_select.h +++ b/app/rect_select.h @@ -23,25 +23,25 @@ /* rect select action functions */ void rect_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_control (Tool *tool, ToolAction tool_action, - gpointer gdisp_ptr); + GDisplay *gdisp); /* rect select functions */ void rect_select_draw (Tool *tool); diff --git a/app/rotate_tool.c b/app/rotate_tool.c index 75b33552d7..ff0c059f18 100644 --- a/app/rotate_tool.c +++ b/app/rotate_tool.c @@ -55,34 +55,42 @@ #define EPSILON 0.018 /* ~ 1 degree */ #define FIFTEEN_DEG (G_PI / 12.0) + +/* forward function declarations */ +static TileManager * rotate_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + +static void rotate_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void rotate_tool_motion (Tool *tool, + GDisplay *gdisp); +static void rotate_info_update (Tool *tool); + +static void rotate_angle_changed (GtkWidget *entry, + gpointer data); +static void rotate_center_changed (GtkWidget *entry, + gpointer data); + + /* variables local to this file */ static gdouble angle_val; static gdouble center_vals[2]; /* needed for size update */ -static GtkWidget *sizeentry; +static GtkWidget *sizeentry = NULL; -/* forward function declarations */ -static void rotate_tool_recalc (Tool *, void *); -static void rotate_tool_motion (Tool *, void *); -static void rotate_info_update (Tool *); -/* callback functions for the info dialog sizeentries */ -static void rotate_angle_changed (GtkWidget *entry, gpointer data); -static void rotate_center_changed (GtkWidget *entry, gpointer data); - -TileManager * +static TileManager * rotate_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { TransformCore *transform_core; - GDisplay *gdisp; GtkWidget *widget; GtkWidget *spinbutton2; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (state) { @@ -174,12 +182,12 @@ rotate_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - rotate_tool_motion (tool, gdisp_ptr); - rotate_tool_recalc (tool, gdisp_ptr); + rotate_tool_motion (tool, gdisp); + rotate_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - rotate_tool_recalc (tool, gdisp_ptr); + rotate_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -246,7 +254,6 @@ rotate_angle_changed (GtkWidget *widget, gpointer data) { Tool *tool; - GDisplay *gdisp; TransformCore *transform_core; gdouble value; @@ -254,7 +261,6 @@ rotate_angle_changed (GtkWidget *widget, if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; value = gimp_deg_to_rad (GTK_ADJUSTMENT (widget)->value); @@ -263,7 +269,7 @@ rotate_angle_changed (GtkWidget *widget, { draw_core_pause (transform_core->core, tool); transform_core->trans_info[ANGLE] = value; - rotate_tool_recalc (tool, gdisp); + rotate_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } @@ -274,7 +280,6 @@ rotate_center_changed (GtkWidget *widget, gpointer data) { Tool *tool; - GDisplay *gdisp; TransformCore *transform_core; gint cx; gint cy; @@ -283,7 +288,6 @@ rotate_center_changed (GtkWidget *widget, if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; cx = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); @@ -295,15 +299,15 @@ rotate_center_changed (GtkWidget *widget, draw_core_pause (transform_core->core, tool); transform_core->cx = cx; transform_core->cy = cy; - rotate_tool_recalc (tool, gdisp); + rotate_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } } static void -rotate_tool_motion (Tool *tool, - void *gdisp_ptr) +rotate_tool_motion (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; gdouble angle1, angle2, angle; @@ -361,14 +365,12 @@ rotate_tool_motion (Tool *tool, } static void -rotate_tool_recalc (Tool *tool, - void *gdisp_ptr) +rotate_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; gdouble cx, cy; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; cx = transform_core->cx; diff --git a/app/rotate_tool.h b/app/rotate_tool.h index a466d1411d..1411efe643 100644 --- a/app/rotate_tool.h +++ b/app/rotate_tool.h @@ -20,9 +20,6 @@ #define __ROTATE_TOOL_H__ -TileManager * rotate_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * rotate_tool_rotate (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/scale_tool.c b/app/scale_tool.c index edce4cd856..14353f7e11 100644 --- a/app/scale_tool.c +++ b/app/scale_tool.c @@ -46,6 +46,23 @@ #include "libgimp/gimpintl.h" +/* forward function declarations */ +static TileManager * scale_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + +static void scale_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void scale_tool_motion (Tool *tool, + GDisplay *gdisp); +static void scale_info_update (Tool *tool); + +static void scale_size_changed (GtkWidget *widget, + gpointer data); +static void scale_unit_changed (GtkWidget *widget, + gpointer data); + + /* storage for information dialog fields */ static gchar orig_width_buf[MAX_INFO_BUF]; static gchar orig_height_buf[MAX_INFO_BUF]; @@ -54,27 +71,17 @@ static gchar x_ratio_buf[MAX_INFO_BUF]; static gchar y_ratio_buf[MAX_INFO_BUF]; /* needed for original size unit update */ -static GtkWidget *sizeentry; +static GtkWidget *sizeentry = NULL; -/* forward function declarations */ -static void scale_tool_recalc (Tool *, void *); -static void scale_tool_motion (Tool *, void *); -static void scale_info_update (Tool *); -/* callback functions for the info dialog fields */ -static void scale_size_changed (GtkWidget *widget, gpointer data); -static void scale_unit_changed (GtkWidget *widget, gpointer data); - -TileManager * +static TileManager * scale_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { - GDisplay *gdisp; TransformCore *transform_core; GtkWidget *spinbutton; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; switch (state) @@ -163,12 +170,12 @@ scale_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - scale_tool_motion (tool, gdisp_ptr); - scale_tool_recalc (tool, gdisp_ptr); + scale_tool_motion (tool, gdisp); + scale_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - scale_tool_recalc (tool, gdisp_ptr); + scale_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -218,7 +225,6 @@ tools_free_scale_tool (Tool *tool) static void scale_info_update (Tool *tool) { - GDisplay *gdisp; TransformCore *transform_core; gdouble ratio_x, ratio_y; gint x1, y1, x2, y2, x3, y3, x4, y4; @@ -228,9 +234,8 @@ scale_info_update (Tool *tool) static GimpUnit label_unit = GIMP_UNIT_PIXEL; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; - unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));; + unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));; /* Find original sizes */ x1 = transform_core->x1; @@ -249,9 +254,9 @@ scale_info_update (Tool *tool) gimp_unit_get_digits (label_unit) + 1, gimp_unit_get_symbol (label_unit)); g_snprintf (orig_width_buf, MAX_INFO_BUF, format_buf, - (x2 - x1) * unit_factor / gdisp->gimage->xresolution); + (x2 - x1) * unit_factor / tool->gdisp->gimage->xresolution); g_snprintf (orig_height_buf, MAX_INFO_BUF, format_buf, - (y2 - y1) * unit_factor / gdisp->gimage->yresolution); + (y2 - y1) * unit_factor / tool->gdisp->gimage->yresolution); } else /* unit == GIMP_UNIT_PIXEL */ { @@ -288,7 +293,6 @@ scale_size_changed (GtkWidget *widget, { Tool *tool; TransformCore *transform_core; - GDisplay *gdisp; gint width; gint height; @@ -296,7 +300,6 @@ scale_size_changed (GtkWidget *widget, if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); @@ -312,7 +315,7 @@ scale_size_changed (GtkWidget *widget, transform_core->trans_info[X0] + width; transform_core->trans_info[Y1] = transform_core->trans_info[Y0] + height; - scale_tool_recalc (tool, gdisp); + scale_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } @@ -326,10 +329,9 @@ scale_unit_changed (GtkWidget *widget, } static void -scale_tool_motion (Tool *tool, - void *gdisp_ptr) +scale_tool_motion (Tool *tool, + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; gdouble ratio; gdouble *x1; @@ -340,7 +342,6 @@ scale_tool_motion (Tool *tool, gint dir_x, dir_y; gint diff_x, diff_y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; diff_x = transform_core->curx - transform_core->lastx; @@ -435,17 +436,15 @@ scale_tool_motion (Tool *tool, } static void -scale_tool_recalc (Tool *tool, - void *gdisp_ptr) +scale_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; gint x1, y1, x2, y2; gint diffx, diffy; gint cx, cy; gdouble scalex, scaley; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; x1 = (int) transform_core->trans_info [X0]; diff --git a/app/scale_tool.h b/app/scale_tool.h index 93aeac2cd6..2de517460f 100644 --- a/app/scale_tool.h +++ b/app/scale_tool.h @@ -20,9 +20,6 @@ #define __SCALE_TOOL_H__ -TileManager * scale_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * scale_tool_scale (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/selection.c b/app/selection.c index 2810e66f0c..41de9d2267 100644 --- a/app/selection.c +++ b/app/selection.c @@ -499,20 +499,17 @@ selection_march_ants (gpointer data) Selection * selection_create (GdkWindow *win, - gpointer gdisp_ptr, - int size, - int width, - int speed) + GDisplay *gdisp, + gint size, + gint width, + gint speed) { - GdkColor fg, bg; - GDisplay *gdisp; - Selection * new; - int base_type; - int i; + GdkColor fg, bg; + Selection *new; + gint base_type; + gint i; - gdisp = (GDisplay *) gdisp_ptr; - - new = (Selection *) g_malloc (sizeof (Selection)); + new = g_new (Selection, 1); base_type = gimp_image_base_type (gdisp->gimage); if (cycled_marching_ants) @@ -532,7 +529,7 @@ selection_create (GdkWindow *win, } new->win = win; - new->gdisp = gdisp_ptr; + new->gdisp = gdisp; new->segs_in = NULL; new->segs_out = NULL; new->segs_layer = NULL; @@ -563,8 +560,8 @@ selection_create (GdkWindow *win, else { /* get black and white pixels for this gdisplay */ - fg.pixel = gdisplay_black_pixel ((GDisplay *) gdisp_ptr); - bg.pixel = gdisplay_white_pixel ((GDisplay *) gdisp_ptr); + fg.pixel = gdisplay_black_pixel (gdisp); + bg.pixel = gdisplay_white_pixel (gdisp); gdk_gc_set_foreground (new->gc_in, &fg); gdk_gc_set_background (new->gc_in, &bg); @@ -581,8 +578,8 @@ selection_create (GdkWindow *win, #endif /* Setup 2nd & 3rd GCs */ - fg.pixel = gdisplay_white_pixel ((GDisplay *) gdisp_ptr); - bg.pixel = gdisplay_gray_pixel ((GDisplay *) gdisp_ptr); + fg.pixel = gdisplay_white_pixel (gdisp); + bg.pixel = gdisplay_gray_pixel (gdisp); /* create a new graphics context */ new->gc_out = gdk_gc_new (new->win); @@ -592,8 +589,8 @@ selection_create (GdkWindow *win, gdk_gc_set_line_attributes (new->gc_out, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER); /* get black and color pixels for this gdisplay */ - fg.pixel = gdisplay_black_pixel ((GDisplay *) gdisp_ptr); - bg.pixel = gdisplay_color_pixel ((GDisplay *) gdisp_ptr); + fg.pixel = gdisplay_black_pixel (gdisp); + bg.pixel = gdisplay_color_pixel (gdisp); /* create a new graphics context */ new->gc_layer = gdk_gc_new (new->win); @@ -719,7 +716,7 @@ selection_layer_invis (Selection *select) void selection_hide (Selection *select, - void *gdisp_ptr) + GDisplay *gdisp) { selection_invis (select); selection_layer_invis (select); diff --git a/app/selection.h b/app/selection.h index 08a5d7698c..2f9ded2b34 100644 --- a/app/selection.h +++ b/app/selection.h @@ -19,57 +19,60 @@ #ifndef __SELECTION_H__ #define __SELECTION_H__ + struct _Selection { /* This information is for maintaining the selection's appearance */ - GdkWindow * win; /* Window to draw to */ - void * gdisp; /* GDisplay that owns the selection */ - GdkGC * gc_in; /* GC for drawing selection outline */ - GdkGC * gc_out; /* GC for selected regions outside current layer */ - GdkGC * gc_layer; /* GC for current layer outline */ + GdkWindow *win; /* Window to draw to */ + GDisplay *gdisp; /* GDisplay that owns the selection */ + GdkGC *gc_in; /* GC for drawing selection outline */ + GdkGC *gc_out; /* GC for selected regions outside + * current layer */ + GdkGC *gc_layer; /* GC for current layer outline */ /* This information is for drawing the marching ants around the border */ - GdkSegment * segs_in; /* gdk segments of area boundary */ - GdkSegment * segs_out; /* gdk segments of area boundary */ - GdkSegment * segs_layer; /* gdk segments of area boundary */ - gint num_segs_in; /* number of segments in segs1 */ - gint num_segs_out; /* number of segments in segs2 */ - gint num_segs_layer; /* number of segments in segs3 */ - gint index_in; /* index of current stipple pattern */ - gint index_out; /* index of current stipple pattern */ - gint index_layer; /* index of current stipple pattern */ - gint state; /* internal drawing state */ - gint paused; /* count of pause requests */ - gint recalc; /* flag to recalculate the selection */ - gint speed; /* speed of marching ants */ - gint hidden; /* is the selection hidden? */ - gint timer; /* timer for successive draws */ - gint cycle; /* color cycling turned on */ - GdkPixmap * cycle_pix; /* cycling pixmap */ + GdkSegment *segs_in; /* gdk segments of area boundary */ + GdkSegment *segs_out; /* gdk segments of area boundary */ + GdkSegment *segs_layer; /* gdk segments of area boundary */ + gint num_segs_in; /* number of segments in segs1 */ + gint num_segs_out; /* number of segments in segs2 */ + gint num_segs_layer; /* number of segments in segs3 */ + gint index_in; /* index of current stipple pattern */ + gint index_out; /* index of current stipple pattern */ + gint index_layer; /* index of current stipple pattern */ + gint state; /* internal drawing state */ + gint paused; /* count of pause requests */ + gint recalc; /* flag to recalculate the selection */ + gint speed; /* speed of marching ants */ + gint hidden; /* is the selection hidden? */ + gint timer; /* timer for successive draws */ + gint cycle; /* color cycling turned on */ + GdkPixmap *cycle_pix; /* cycling pixmap */ /* These are used only if USE_XDRAWPOINTS is defined. */ - GdkPoint * points_in[8]; /* points of segs_in for fast ants */ - gint num_points_in[8]; /* number of points in points_in */ - GdkGC * gc_white; /* gc for drawing white points */ - GdkGC * gc_black; /* gc for drawing black points */ + GdkPoint *points_in[8]; /* points of segs_in for fast ants */ + gint num_points_in[8]; /* number of points in points_in */ + GdkGC *gc_white; /* gc for drawing white points */ + GdkGC *gc_black; /* gc for drawing black points */ }; + /* Function declarations */ -Selection * selection_create (GdkWindow *, - gpointer , - gint , - gint , - gint ); -void selection_pause (Selection *); -void selection_resume (Selection *); -void selection_start (Selection *, - gint ); -void selection_invis (Selection *); -void selection_layer_invis (Selection *); -void selection_hide (Selection *, - gpointer ); -void selection_free (Selection *); +Selection * selection_create (GdkWindow *win, + GDisplay *disp, + gint size, + gint width, + gint speed); +void selection_pause (Selection *select); +void selection_resume (Selection *select); +void selection_start (Selection *select, + gint recalc); +void selection_invis (Selection *select); +void selection_layer_invis (Selection *select); +void selection_hide (Selection *select, + GDisplay *gdisp); +void selection_free (Selection *select); #endif /* __SELECTION_H__ */ diff --git a/app/shear_tool.c b/app/shear_tool.c index 279332b28d..99be358f45 100644 --- a/app/shear_tool.c +++ b/app/shear_tool.c @@ -54,29 +54,37 @@ /* the minimum movement before direction of shear can be determined (pixels) */ #define MIN_MOVE 5 + +/* forward function declarations */ +static TileManager * shear_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + +static void shear_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void shear_tool_motion (Tool *tool, + GDisplay *gdisp); +static void shear_info_update (Tool *tool); + +static void shear_x_mag_changed (GtkWidget *widget, + gpointer data); +static void shear_y_mag_changed (GtkWidget *widget, + gpointer data); + + /* variables local to this file */ static gdouble xshear_val; static gdouble yshear_val; -/* forward function declarations */ -static void shear_tool_recalc (Tool *, void *); -static void shear_tool_motion (Tool *, void *); -static void shear_info_update (Tool *); -/* Info dialog callback funtions */ -static void shear_x_mag_changed (GtkWidget *widget, gpointer data); -static void shear_y_mag_changed (GtkWidget *widget, gpointer data); - -TileManager * +static TileManager * shear_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { TransformCore *transform_core; - GDisplay *gdisp; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (state) { @@ -108,12 +116,12 @@ shear_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - shear_tool_motion (tool, gdisp_ptr); - shear_tool_recalc (tool, gdisp_ptr); + shear_tool_motion (tool, gdisp); + shear_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - shear_tool_recalc (tool, gdisp_ptr); + shear_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -175,14 +183,12 @@ shear_x_mag_changed (GtkWidget *widget, { Tool *tool; TransformCore *transform_core; - GDisplay *gdisp; gint value; tool = (Tool *) data; if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; value = GTK_ADJUSTMENT (widget)->value; @@ -191,7 +197,7 @@ shear_x_mag_changed (GtkWidget *widget, { draw_core_pause (transform_core->core, tool); transform_core->trans_info[XSHEAR] = value; - shear_tool_recalc (tool, gdisp); + shear_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } @@ -203,14 +209,12 @@ shear_y_mag_changed (GtkWidget *widget, { Tool *tool; TransformCore *transform_core; - GDisplay *gdisp; gint value; tool = (Tool *) data; if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; value = GTK_ADJUSTMENT (widget)->value; @@ -219,15 +223,15 @@ shear_y_mag_changed (GtkWidget *widget, { draw_core_pause (transform_core->core, tool); transform_core->trans_info[YSHEAR] = value; - shear_tool_recalc (tool, gdisp); + shear_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } } static void -shear_tool_motion (Tool *tool, - void *gdisp_ptr) +shear_tool_motion (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; gint diffx, diffy; @@ -302,15 +306,13 @@ shear_tool_motion (Tool *tool, } static void -shear_tool_recalc (Tool *tool, - void *gdisp_ptr) +shear_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; gfloat width, height; gfloat cx, cy; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; cx = (transform_core->x1 + transform_core->x2) / 2.0; diff --git a/app/shear_tool.h b/app/shear_tool.h index 1dd07ad975..3b1a0e381c 100644 --- a/app/shear_tool.h +++ b/app/shear_tool.h @@ -20,9 +20,6 @@ #define __SHEAR_TOOL_H__ -TileManager * shear_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * shear_tool_shear (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/smudge.c b/app/smudge.c index 26bdff458e..3aae2073cb 100644 --- a/app/smudge.c +++ b/app/smudge.c @@ -63,30 +63,40 @@ struct _SmudgeOptions GtkObject *rate_w; }; + +/* function prototypes */ +static gpointer smudge_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void smudge_motion (PaintCore *paint_core, + PaintPressureOptions *pressure_options, + gdouble smudge_rate, + GimpDrawable *drawable); +static gboolean smudge_init (PaintCore *paint_core, + GimpDrawable *drawable); +static void smudge_finish (PaintCore *paint_core, + GimpDrawable *drawable); + +static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, + gint *x, + gint *y, + gint *w, + gint *h); +static void smudge_allocate_accum_buffer (gint w, + gint h, + gint bytes, + guchar *do_fill); + + +/* local variables */ static PixelRegion accumPR; static guchar *accum_data; /* the smudge tool options */ static SmudgeOptions * smudge_options = NULL; -/* local variables */ static gdouble non_gui_rate; -/* function prototypes */ -static void smudge_motion (PaintCore *, PaintPressureOptions *, - gdouble, GimpDrawable *); -static gboolean smudge_init (PaintCore *, GimpDrawable *); -static void smudge_finish (PaintCore *, GimpDrawable *); - -static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, - gint *x, - gint *y, - gint *w, - gint *h); -static void smudge_allocate_accum_buffer (gint w, - gint h, - gint bytes, - guchar *do_fill); static void smudge_options_reset (void) @@ -143,10 +153,10 @@ smudge_options_new (void) return options; } -void * +static gpointer smudge_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { /* initialization fails if the user starts outside the drawable */ static gboolean initialized = FALSE; @@ -157,13 +167,18 @@ smudge_paint_func (PaintCore *paint_core, if (!initialized) initialized = smudge_init (paint_core, drawable); if (initialized) - smudge_motion (paint_core, smudge_options->paint_options.pressure_options, + smudge_motion (paint_core, + smudge_options->paint_options.pressure_options, smudge_options->rate, drawable); break; + case FINISH_PAINT: smudge_finish (paint_core, drawable); initialized = FALSE; break; + + default: + break; } return NULL; @@ -198,12 +213,12 @@ static gboolean smudge_init (PaintCore *paint_core, GimpDrawable *drawable) { - GImage *gimage; - TempBuf *area; + GImage *gimage; + TempBuf *area; PixelRegion srcPR; - gint x, y, w, h; - gint was_clipped; - guchar *do_fill = NULL; + gint x, y, w, h; + gint was_clipped; + guchar *do_fill = NULL; if (! (gimage = drawable_gimage (drawable))) return FALSE; @@ -239,7 +254,7 @@ smudge_init (PaintCore *paint_core, do_fill = gimp_drawable_get_color_at (drawable, CLAMP ((gint) paint_core->curx, 0, gimp_drawable_width (drawable) - 1), CLAMP ((gint) paint_core->cury, 0, gimp_drawable_height (drawable) - 1)); - + smudge_allocate_accum_buffer (w, h, gimp_drawable_bytes (drawable), do_fill); accumPR.x = area->x - x; @@ -277,7 +292,7 @@ smudge_allocate_accum_buffer (gint w, gint h, gint bytes, guchar *do_fill) -{ +{ /* Allocate the accumulation buffer */ accumPR.bytes = bytes; accum_data = g_malloc (w * h * bytes); @@ -332,12 +347,12 @@ smudge_motion (PaintCore *paint_core, gdouble smudge_rate, GimpDrawable *drawable) { - GImage *gimage; - TempBuf * area; - PixelRegion srcPR, destPR, tempPR; - gdouble rate; - gint opacity; - gint x,y,w,h; + GImage *gimage; + TempBuf *area; + PixelRegion srcPR, destPR, tempPR; + gdouble rate; + gint opacity; + gint x, y, w, h; if (! (gimage = drawable_gimage (drawable))) return; @@ -425,10 +440,10 @@ smudge_motion (PaintCore *paint_core, 1.0, INCREMENTAL); } -static void * +static gpointer smudge_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { smudge_motion (paint_core, &non_gui_pressure_options, non_gui_rate, drawable); @@ -437,8 +452,8 @@ smudge_non_gui_paint_func (PaintCore *paint_core, gboolean smudge_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gdouble rate = SMUDGE_DEFAULT_RATE; SmudgeOptions *options = smudge_options; @@ -452,8 +467,8 @@ smudge_non_gui_default (GimpDrawable *drawable, gboolean smudge_non_gui (GimpDrawable *drawable, gdouble rate, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gint i; @@ -493,6 +508,6 @@ smudge_non_gui (GimpDrawable *drawable, smudge_finish (&non_gui_paint_core, drawable); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/smudge.h b/app/smudge.h index a87d0ffe60..0ea9609198 100644 --- a/app/smudge.h +++ b/app/smudge.h @@ -33,16 +33,14 @@ typedef enum SMUDGE_MODE_SHADOWS } SmudgeMode; -void * smudge_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean smudge_non_gui (GimpDrawable *, - gdouble , - gint , - gdouble *); -gboolean smudge_non_gui_default (GimpDrawable *, - gint , - gdouble *); + +gboolean smudge_non_gui (GimpDrawable *drawable, + gdouble rate, + gint num_strokes, + gdouble *stroke_array); +gboolean smudge_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_smudge (void); void tools_free_smudge (Tool *tool); diff --git a/app/text_tool.c b/app/text_tool.c index 33fd430364..3b1885d073 100644 --- a/app/text_tool.c +++ b/app/text_tool.c @@ -81,9 +81,9 @@ typedef struct _TextTool TextTool; struct _TextTool { - gint click_x; - gint click_y; - void *gdisp_ptr; + gint click_x; + gint click_y; + GDisplay *gdisp; }; typedef struct _TextOptions TextOptions; @@ -106,6 +106,39 @@ struct _TextOptions }; +static void text_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void text_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void text_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void text_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void text_dialog_create (void); +static void text_dialog_ok_callback (GtkWidget *widget, + gpointer data); +static void text_dialog_cancel_callback (GtkWidget *widget, + gpointer data); +static gint text_dialog_delete_callback (GtkWidget *widget, + GdkEvent *event, + gpointer data); + +static void text_init_render (TextTool *text_tool); +static void text_gdk_image_to_region (GdkImage *image, + gint , + PixelRegion *); +static void text_size_multiply (gchar **fontname, + gint size); +static void text_set_resolution (gchar **fontname, + gdouble xres, + gdouble yres); + + /* the text tool options */ static TextOptions *text_options = NULL; @@ -114,25 +147,6 @@ static TextTool *the_text_tool = NULL; static GtkWidget *text_tool_shell = NULL; -static void text_button_press (Tool *, GdkEventButton *, gpointer); -static void text_button_release (Tool *, GdkEventButton *, gpointer); -static void text_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void text_control (Tool *, ToolAction, gpointer); - -static void text_dialog_create (void); -static void text_dialog_ok_callback (GtkWidget *, gpointer); -static void text_dialog_cancel_callback (GtkWidget *, gpointer); -static gint text_dialog_delete_callback (GtkWidget *, GdkEvent *, gpointer); - -static void text_init_render (TextTool *); -static void text_gdk_image_to_region (GdkImage *, gint, PixelRegion *); -static void text_size_multiply (gchar **fontname, gint); -static void text_set_resolution (gchar **fontname, gdouble, gdouble); - -/* Layer * text_render (GImage *, GimpDrawable *, */ -/* gint, gint, gchar *, gchar *, gint, gint); */ - - /* functions */ static void @@ -304,19 +318,16 @@ text_call_gdyntext (GDisplay *gdisp) static void text_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; + Layer *layer; TextTool *text_tool; - gdisp = gdisp_ptr; - - text_tool = tool->private; - text_tool->gdisp_ptr = gdisp_ptr; + text_tool = tool->private; + text_tool->gdisp = gdisp; tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &text_tool->click_x, &text_tool->click_y, @@ -328,7 +339,7 @@ text_button_press (Tool *tool, /* If there is a floating selection, and this aint it, use the move tool */ if (layer_is_floating_sel (layer)) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_LAYER_TRANSLATE); return; } @@ -348,7 +359,7 @@ text_button_press (Tool *tool, static void text_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->state = INACTIVE; } @@ -356,13 +367,10 @@ text_button_release (Tool *tool, static void text_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; Layer *layer; - gint x, y; - - gdisp = (GDisplay *) gdisp_ptr; + gint x, y; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -387,7 +395,7 @@ text_cursor_update (Tool *tool, static void text_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -467,16 +475,16 @@ static void text_init_render (TextTool *text_tool) { GDisplay *gdisp; - gchar *fontname; - gchar *text; - gboolean antialias = text_options->antialias; + gchar *fontname; + gchar *text; + gboolean antialias = text_options->antialias; fontname = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG (text_tool_shell)); if (!fontname) return; - gdisp = (GDisplay *) text_tool->gdisp_ptr; + gdisp = text_tool->gdisp; /* override the user's antialias setting if this is an indexed image */ if (gimp_image_base_type (gdisp->gimage) == INDEXED) diff --git a/app/text_tool.h b/app/text_tool.h index 32deef8d3c..41633d6c35 100644 --- a/app/text_tool.h +++ b/app/text_tool.h @@ -20,14 +20,14 @@ #define __TEXT_TOOL_H__ +#define SUPERSAMPLE 3 + typedef enum { PIXELS, POINTS } SizeType; -#define SUPERSAMPLE 3 - Tool * tools_new_text (void); void tools_free_text (Tool *tool); diff --git a/app/threshold.c b/app/threshold.c index 90d6cea647..5fefd450c6 100644 --- a/app/threshold.c +++ b/app/threshold.c @@ -56,36 +56,50 @@ struct _Threshold gint x, y; /* coords for last mouse click */ }; + +/* threshold action functions */ +static void threshold_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static ThresholdDialog * threshold_dialog_new (void); + +static void threshold_update (ThresholdDialog *td, + gint update); +static void threshold_preview (ThresholdDialog *td); +static void threshold_reset_callback (GtkWidget *widget, + gpointer data); +static void threshold_ok_callback (GtkWidget *widget, + gpointer data); +static void threshold_cancel_callback (GtkWidget *widget, + gpointer data); +static void threshold_preview_update (GtkWidget *widget, + gpointer data); +static void threshold_low_threshold_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void threshold_high_threshold_adjustment_update (GtkAdjustment *adj, + gpointer data); + +static void threshold (PixelRegion *, + PixelRegion *, + gpointer ); +static void threshold_histogram_range (HistogramWidget *, + gint , + gint , + gpointer ); + + /* the threshold tool options */ static ToolOptions *threshold_options = NULL; /* the threshold tool dialog */ static ThresholdDialog *threshold_dialog = NULL; -/* threshold action functions */ -static void threshold_control (Tool *, ToolAction, gpointer); -static ThresholdDialog * threshold_dialog_new (void); - -static void threshold_update (ThresholdDialog *, - gint); -static void threshold_preview (ThresholdDialog *); -static void threshold_reset_callback (GtkWidget *, gpointer); -static void threshold_ok_callback (GtkWidget *, gpointer); -static void threshold_cancel_callback (GtkWidget *, gpointer); -static void threshold_preview_update (GtkWidget *, gpointer); -static void threshold_low_threshold_adjustment_update (GtkAdjustment *, - gpointer); -static void threshold_high_threshold_adjustment_update (GtkAdjustment *, - gpointer); - -static void threshold (PixelRegion *, PixelRegion *, void *); -static void threshold_histogram_range (HistogramWidget *, gint, gint, - gpointer); /* threshold machinery */ void -threshold_2 (void *data, +threshold_2 (gpointer data, PixelRegion *srcPR, PixelRegion *destPR) { @@ -152,7 +166,7 @@ threshold (PixelRegion *srcPR, static void threshold_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -453,7 +467,7 @@ threshold_ok_callback (GtkWidget *widget, td->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -477,7 +491,7 @@ threshold_cancel_callback (GtkWidget *widget, gdisplays_flush (); } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools.c b/app/tools.c index 19fce25e8b..5bd8ec119a 100644 --- a/app/tools.c +++ b/app/tools.c @@ -1324,17 +1324,17 @@ tools_initialize (ToolType tool_type, active_tool->drawable = gimp_image_active_drawable (gdisp->gimage); } - /* don't set gdisp_ptr here! (see commands.c) */ + /* don't set tool->gdisp here! (see commands.c) */ } void active_tool_control (ToolAction action, - void *gdisp_ptr) + GDisplay *gdisp) { if (active_tool) { - if (active_tool->gdisp_ptr == gdisp_ptr) + if (active_tool->gdisp == gdisp) { switch (action) { @@ -1344,7 +1344,7 @@ active_tool_control (ToolAction action, if (! active_tool->paused_count) { active_tool->state = PAUSED; - (* active_tool->control_func) (active_tool, action, gdisp_ptr); + (* active_tool->control_func) (active_tool, action, gdisp); } } active_tool->paused_count++; @@ -1357,14 +1357,14 @@ active_tool_control (ToolAction action, if (! active_tool->paused_count) { active_tool->state = ACTIVE; - (* active_tool->control_func) (active_tool, action, gdisp_ptr); + (* active_tool->control_func) (active_tool, action, gdisp); } } break; case HALT : active_tool->state = INACTIVE; - (* active_tool->control_func) (active_tool, action, gdisp_ptr); + (* active_tool->control_func) (active_tool, action, gdisp); break; case DESTROY : @@ -1388,52 +1388,45 @@ active_tool_control (ToolAction action, static void standard_button_press_func (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - - gdisp = gdisp_ptr; - - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->drawable = gimp_image_active_drawable (gdisp->gimage); } static void standard_button_release_func (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { } static void standard_motion_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { } static void standard_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { } static void standard_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { } static void standard_cursor_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - - gdisp = (GDisplay *) gdisp_ptr; gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW, TOOL_TYPE_NONE, CURSOR_MODIFIER_NONE, @@ -1443,14 +1436,14 @@ standard_cursor_update_func (Tool *tool, static void standard_operator_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { } static void standard_control_func (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { } @@ -1475,7 +1468,7 @@ tools_new_tool (ToolType tool_type) tool->auto_snap_to = TRUE; /* Snap to guides */ tool->preserve = TRUE; /* Preserve tool across drawable changes */ - tool->gdisp_ptr = NULL; + tool->gdisp = NULL; tool->drawable = NULL; tool->toggled = FALSE; diff --git a/app/tools.h b/app/tools.h index a76ce57814..6058153c52 100644 --- a/app/tools.h +++ b/app/tools.h @@ -29,41 +29,58 @@ #define NON_ACTIVE_LAYER (1 << 2) /* Tool action function declarations */ -typedef void (* ButtonPressFunc) (Tool *, GdkEventButton *, gpointer); -typedef void (* ButtonReleaseFunc) (Tool *, GdkEventButton *, gpointer); -typedef void (* MotionFunc) (Tool *, GdkEventMotion *, gpointer); -typedef void (* ArrowKeysFunc) (Tool *, GdkEventKey *, gpointer); -typedef void (* ModifierKeyFunc) (Tool *, GdkEventKey *, gpointer); -typedef void (* CursorUpdateFunc) (Tool *, GdkEventMotion *, gpointer); -typedef void (* OperUpdateFunc) (Tool *, GdkEventMotion *, gpointer); -typedef void (* ToolCtlFunc) (Tool *, ToolAction, gpointer); +typedef void (* ButtonPressFunc) (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +typedef void (* ButtonReleaseFunc) (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +typedef void (* MotionFunc) (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +typedef void (* ArrowKeysFunc) (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +typedef void (* ModifierKeyFunc) (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +typedef void (* CursorUpdateFunc) (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +typedef void (* OperUpdateFunc) (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +typedef void (* ToolCtlFunc) (Tool *tool, + ToolAction action, + GDisplay *gdisp); /* ToolInfo function declarations */ typedef Tool * (* ToolInfoNewFunc) (void); -typedef void (* ToolInfoFreeFunc) (Tool *); -typedef void (* ToolInfoInitFunc) (GDisplay *); +typedef void (* ToolInfoFreeFunc) (Tool *tool); +typedef void (* ToolInfoInitFunc) (GDisplay *gdisp); /* The types of tools... */ struct _Tool { /* Data */ - ToolType type; /* Tool type */ - gint ID; /* unique tool ID */ + ToolType type; /* Tool type */ + gint ID; /* unique tool ID */ - ToolState state; /* state of tool activity */ - gint paused_count; /* paused control count */ - gboolean scroll_lock; /* allow scrolling or not */ - gboolean auto_snap_to; /* snap to guides automatically */ + ToolState state; /* state of tool activity */ + gint paused_count; /* paused control count */ + gboolean scroll_lock; /* allow scrolling or not */ + gboolean auto_snap_to; /* snap to guides automatically */ - gboolean preserve; /* Preserve this tool across drawable changes */ - void *gdisp_ptr; /* pointer to currently active gdisp */ - void *drawable; /* pointer to the tool's current drawable */ + gboolean preserve; /* Preserve this tool across drawable changes */ + GDisplay *gdisp; /* pointer to currently active gdisp */ + GimpDrawable *drawable; /* pointer to the tool's current drawable */ - gboolean toggled; /* Bad hack to let the paint_core show the */ - /* right toggle cursors */ + gboolean toggled; /* Bad hack to let the paint_core show the + * right toggle cursors + */ - void *private; /* Tool-specific information */ + gpointer private; /* Tool-specific information */ /* Action functions */ ButtonPressFunc button_press_func; @@ -98,7 +115,7 @@ struct _ToolInfo ToolInfoFreeFunc free_func; ToolInfoInitFunc init_func; - GtkWidget *tool_widget; + GtkWidget *tool_widget; GimpContext *tool_context; @@ -106,34 +123,37 @@ struct _ToolInfo BitmapCursor toggle_cursor; }; -/* Global Data Structures */ -extern Tool * active_tool; -extern ToolInfo tool_info[]; -extern gint num_tools; /* Function declarations */ -Tool * tools_new_tool (ToolType tool_type); +Tool * tools_new_tool (ToolType tool_type); -void tools_select (ToolType tool_type); -void tools_initialize (ToolType tool_type, - GDisplay *gdisplay); +void tools_select (ToolType tool_type); +void tools_initialize (ToolType tool_type, + GDisplay *gdisplay); -void active_tool_control (ToolAction action, - void *gdisp_ptr); +void active_tool_control (ToolAction action, + GDisplay *gdisp); -void tools_help_func (const gchar *help_data); +void tools_help_func (const gchar *help_data); -void tools_register (ToolType tool_type, - ToolOptions *tool_options); +void tools_register (ToolType tool_type, + ToolOptions *tool_options); -void tool_options_dialog_new (void); -void tool_options_dialog_show (void); -void tool_options_dialog_free (void); +void tool_options_dialog_new (void); +void tool_options_dialog_show (void); +void tool_options_dialog_free (void); -gchar * tool_active_PDB_string (void); +gchar * tool_active_PDB_string (void); + +/* don't unref these pixmaps, they are static! */ +GdkPixmap * tool_get_pixmap (ToolType tool_type); +GdkBitmap * tool_get_mask (ToolType tool_type); + + +/* Global Data Structures */ +extern Tool *active_tool; +extern ToolInfo tool_info[]; +extern gint num_tools; -/* don't unref this pixmaps, they are static! */ -GdkPixmap * tool_get_pixmap (ToolType tool_type); -GdkBitmap * tool_get_mask (ToolType tool_type); #endif /* __TOOLS_H__ */ diff --git a/app/tools/airbrush.c b/app/tools/airbrush.c index 29ad1d4f90..0289996769 100644 --- a/app/tools/airbrush.c +++ b/app/tools/airbrush.c @@ -77,6 +77,16 @@ struct _AirbrushOptions }; +/* local function prototypes */ + +static gpointer airbrush_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static gpointer airbrush_non_gui_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + + /* the airbrush tool options */ static AirbrushOptions *airbrush_options = NULL; @@ -189,13 +199,13 @@ tools_new_airbrush (void) return tool; } -void * +static gpointer airbrush_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { GimpBrush *brush; - gdouble rate; + gdouble rate; if (!drawable) return NULL; @@ -357,10 +367,10 @@ airbrush_motion (PaintCore *paint_core, SOFT, scale, mode); } -static void * +static gpointer airbrush_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { airbrush_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_pressure, non_gui_incremental); @@ -370,8 +380,8 @@ airbrush_non_gui_paint_func (PaintCore *paint_core, gboolean airbrush_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { AirbrushOptions *options = airbrush_options; gdouble pressure = AIRBRUSH_PRESSURE_DEFAULT; @@ -384,11 +394,11 @@ airbrush_non_gui_default (GimpDrawable *drawable, gboolean airbrush_non_gui (GimpDrawable *drawable, - double pressure, - int num_strokes, - double *stroke_array) + gdouble pressure, + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -419,8 +429,9 @@ airbrush_non_gui (GimpDrawable *drawable, /* Cleanup */ paint_core_cleanup (); + return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/tools/airbrush.h b/app/tools/airbrush.h index ea4e64954b..6eb5528f0f 100644 --- a/app/tools/airbrush.h +++ b/app/tools/airbrush.h @@ -20,18 +20,16 @@ #define __AIRBRUSH_H__ -void * airbrush_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean airbrush_non_gui (GimpDrawable *, - gdouble, - gint, - gdouble *); -gboolean airbrush_non_gui_default (GimpDrawable *, - gint, - gdouble *); +gboolean airbrush_non_gui (GimpDrawable *drawable, + gdouble pressure, + gint num_strokes, + gdouble *stroke_array); +gboolean airbrush_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); + Tool * tools_new_airbrush (void); -void tools_free_airbrush (Tool *); +void tools_free_airbrush (Tool *tool); #endif /* __AIRBRUSH_H__ */ diff --git a/app/tools/bezier_select.c b/app/tools/bezier_select.c index b29fb669c3..a6ff254142 100644 --- a/app/tools/bezier_select.c +++ b/app/tools/bezier_select.c @@ -119,19 +119,19 @@ typedef struct static void bezier_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr); + GDisplay *gdisp); static void bezier_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr); + GDisplay *gdisp); static void bezier_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); static void bezier_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr); + GDisplay *gdisp); static void bezier_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); static void bezier_select_draw (Tool *tool); static void bezier_offset_point (BezierPoint *pt, @@ -308,22 +308,19 @@ tools_free_bezier_select (Tool *tool) } gint -bezier_select_load (void *gdisp_ptr, +bezier_select_load (GDisplay *gdisp, BezierPoint *pts, gint num_pts, gint closed) { - GDisplay *gdisp; Tool *tool; BezierSelect *bezier_sel; - gdisp = (GDisplay *) gdisp_ptr; - /* select the bezier tool */ gimp_context_set_tool (gimp_context_get_user (), BEZIER_SELECT); tool = active_tool; tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; bezier_sel = (BezierSelect *) tool->private; bezier_sel->points = pts; @@ -333,7 +330,7 @@ bezier_select_load (void *gdisp_ptr, bezier_sel->state = BEZIER_EDIT; bezier_sel->draw = BEZIER_DRAW_ALL; - bezier_convert (bezier_sel, tool->gdisp_ptr, SUBDIVIDE, FALSE); + bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, FALSE); draw_core_start (bezier_sel->core, gdisp->canvas->window, tool); @@ -966,9 +963,8 @@ bezier_start_new_segment (BezierSelect *bezier_sel, static void bezier_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; BezierSelect *bezier_sel; BezierPoint *points; BezierPoint *start_pt; @@ -978,8 +974,6 @@ bezier_select_button_press (Tool *tool, gint x, y; gint halfwidth, dummy; - gdisp = (GDisplay *) gdisp_ptr; - tool->drawable = gimp_image_active_drawable (gdisp->gimage); bezier_sel = tool->private; @@ -987,12 +981,12 @@ bezier_select_button_press (Tool *tool, if (bezier_options->extend) { - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; } else { /* If the tool was being used in another image...reset it */ - if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp != tool->gdisp) { draw_core_stop (bezier_sel->core, tool); bezier_select_reset (bezier_sel); @@ -1008,8 +1002,8 @@ bezier_select_button_press (Tool *tool, curTool = active_tool; curSel = curTool->private; - curGdisp = (GDisplay *) gdisp_ptr; - active_tool->gdisp_ptr = gdisp_ptr; + curGdisp = (GDisplay *) gdisp; + active_tool->gdisp = gdisp; curCore = bezier_sel->core; switch (bezier_sel->state) @@ -1019,19 +1013,19 @@ bezier_select_button_press (Tool *tool, break; grab_pointer = TRUE; - tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->state = ACTIVE; + tool->gdisp = gdisp; /* if (bevent->state & GDK_MOD1_MASK) */ /* { */ -/* init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); */ +/* init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); */ /* break; */ /* } */ /* else if (!(bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK)) */ /* if (! (layer_is_floating_sel (gimp_image_get_active_layer (gdisp->gimage))) && */ /* gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY) */ /* { */ -/* init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); */ +/* init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); */ /* break; */ /* } */ @@ -1079,7 +1073,7 @@ bezier_select_button_press (Tool *tool, { paths_dialog_set_default_op (); /* recursive call */ - bezier_select_button_press (tool, bevent, gdisp_ptr); + bezier_select_button_press (tool, bevent, gdisp); } return; } @@ -1120,7 +1114,7 @@ bezier_select_button_press (Tool *tool, { paths_dialog_set_default_op (); /* recursive call */ - bezier_select_button_press (tool, bevent, gdisp_ptr); + bezier_select_button_press (tool, bevent, gdisp); } return; } @@ -1150,7 +1144,7 @@ bezier_select_button_press (Tool *tool, { paths_dialog_set_default_op (); /* recursive call */ - bezier_select_button_press (tool, bevent, gdisp_ptr); + bezier_select_button_press (tool, bevent, gdisp); } return; } @@ -1303,12 +1297,12 @@ bezier_select_button_press (Tool *tool, static void bezier_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; BezierSelect *bezier_sel; - gdisp = tool->gdisp_ptr; + gdisp = tool->gdisp; + bezier_sel = tool->private; bezier_sel->state &= ~(BEZIER_DRAG); @@ -1316,7 +1310,7 @@ bezier_select_button_release (Tool *tool, gdk_flush (); if (bezier_sel->closed) - bezier_convert (bezier_sel, tool->gdisp_ptr, SUBDIVIDE, FALSE); + bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, FALSE); /* Here ?*/ paths_newpoint_current (bezier_sel,gdisp); @@ -1381,11 +1375,10 @@ bez_copy_points (BezierSelect *tobez, static void bezier_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { static gint lastx, lasty; - GDisplay *gdisp; BezierSelect *bezier_sel; BezierPoint *anchor; BezierPoint *opposite_control; @@ -1396,7 +1389,6 @@ bezier_select_motion (Tool *tool, if (tool->state != ACTIVE) return; - gdisp = gdisp_ptr; bezier_sel = tool->private; if (!bezier_sel->cur_anchor || !bezier_sel->cur_control) @@ -1726,9 +1718,8 @@ bezier_point_on_curve (GDisplay *gdisp, static void bezier_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; BezierSelect *bezier_sel; gboolean on_curve; gboolean on_control_pnt; @@ -1736,11 +1727,9 @@ bezier_select_cursor_update (Tool *tool, gint halfwidth, dummy; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; - bezier_sel = tool->private; - if (gdisp != tool->gdisp_ptr || bezier_sel->core->draw_state == INVISIBLE) + if (gdisp != tool->gdisp || bezier_sel->core->draw_state == INVISIBLE) { gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_CURSOR, BEZIER_SELECT, @@ -1929,7 +1918,7 @@ bezier_select_cursor_update (Tool *tool, static void bezier_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { BezierSelect * bezier_sel; @@ -2016,10 +2005,10 @@ bezier_select_draw (Tool *tool) GDisplay *gdisp; BezierSelect *bezier_sel; - gdisp = tool->gdisp_ptr; + gdisp = tool->gdisp; bezier_sel = tool->private; - bezier_draw(gdisp,bezier_sel); + bezier_draw (gdisp, bezier_sel); } @@ -2447,17 +2436,17 @@ bezier_convert (BezierSelect *bezier_sel, gint subdivisions, gboolean antialias) { - PixelRegion maskPR; - BezierPoint * points; - BezierPoint * start_pt; - BezierPoint * next_curve; - GSList * list; - unsigned char *buf, *b; - int draw_type; - int * vals, val; - int start, end; - int x, x2, w; - int i, j; + PixelRegion maskPR; + BezierPoint *points; + BezierPoint *start_pt; + BezierPoint *next_curve; + GSList *list; + guchar *buf, *b; + gint draw_type; + gint *vals, val; + gint start, end; + gint x, x2, w; + gint i, j; if (!bezier_sel->closed) gimp_fatal_error ("bezier_convert(): tried to convert an open bezier curve"); @@ -2622,16 +2611,16 @@ bezier_convert_points (BezierSelect *bezier_sel, } static void -bezier_convert_line (GSList ** scanlines, - int x1, - int y1, - int x2, - int y2) +bezier_convert_line (GSList **scanlines, + gint x1, + gint y1, + gint x2, + gint y2) { - int dx, dy; - int error, inc; - int tmp; - double slope; + gint dx, dy; + gint error, inc; + gint tmp; + gdouble slope; if (y1 == y2) return; @@ -2739,11 +2728,11 @@ bezier_convert_line (GSList ** scanlines, } static GSList * -bezier_insert_in_list (GSList * list, - int x) +bezier_insert_in_list (GSList *list, + gint x) { - GSList * orig = list; - GSList * rest; + GSList *orig = list; + GSList *rest; if (!list) return g_slist_prepend (list, (void *) ((long) x)); @@ -2770,21 +2759,22 @@ bezier_insert_in_list (GSList * list, } gboolean -bezier_tool_selected() +bezier_tool_selected (void) { - return(active_tool && - active_tool->type == BEZIER_SELECT && - active_tool->state == ACTIVE); + return (active_tool && + active_tool->type == BEZIER_SELECT && + active_tool->state == ACTIVE); } void -bezier_paste_bezierselect_to_current(GDisplay *gdisp,BezierSelect *bsel) +bezier_paste_bezierselect_to_current (GDisplay *gdisp, + BezierSelect *bsel) { BezierPoint *pts; - gint i; - Tool * tool; - BezierPoint *bpnt = NULL; - int need_move = 0; + gint i; + Tool *tool; + BezierPoint *bpnt = NULL; + gint need_move = 0; /* g_print ("bezier_paste_bezierselect_to_current::\n"); */ /* printSel(bsel); */ @@ -2794,22 +2784,22 @@ bezier_paste_bezierselect_to_current(GDisplay *gdisp,BezierSelect *bsel) active_tool->type == BEZIER_SELECT && active_tool->state == ACTIVE) { - BezierSelect *bezier_sel = (BezierSelect*)active_tool->private; + BezierSelect *bezier_sel = (BezierSelect *) active_tool->private; if(bezier_sel) { - draw_core_stop ( curSel->core, active_tool ); + draw_core_stop (curSel->core, active_tool); bezier_select_reset (bezier_sel); } } gimp_context_set_tool (gimp_context_get_user (), BEZIER_SELECT); active_tool->paused_count = 0; - active_tool->gdisp_ptr = gdisp; - active_tool->drawable = gimp_image_active_drawable (gdisp->gimage); + active_tool->gdisp = gdisp; + active_tool->drawable = gimp_image_active_drawable (gdisp->gimage); tool = active_tool; - bezier_select_reset( curSel ); + bezier_select_reset (curSel); draw_core_start (curSel->core, gdisp->canvas->window, tool); @@ -2817,20 +2807,22 @@ bezier_paste_bezierselect_to_current(GDisplay *gdisp,BezierSelect *bsel) pts = (BezierPoint *) bsel->points; - for (i=0; i< bsel->num_points; i++) + for (i = 0; i < bsel->num_points; i++) { - if(need_move) + if (need_move) { - bezier_add_point( curSel, BEZIER_MOVE, pts->x, pts->y); + bezier_add_point (curSel, BEZIER_MOVE, pts->x, pts->y); need_move = 0; } else - bezier_add_point( curSel, pts->type, pts->x, pts->y); + { + bezier_add_point (curSel, pts->type, pts->x, pts->y); + } - if(bpnt == NULL) + if (bpnt == NULL) bpnt = curSel->last_point; - if(pts->next_curve) + if (pts->next_curve) { /* g_print ("bezier_paste_bezierselect_to_current:: Close last curve off \n"); */ curSel->last_point->next = bpnt; @@ -2847,21 +2839,21 @@ bezier_paste_bezierselect_to_current(GDisplay *gdisp,BezierSelect *bsel) } } - if ( bsel->closed ) + if (bsel->closed) { curSel->last_point->next = bpnt; bpnt->prev = curSel->last_point; curSel->cur_anchor = curSel->points; curSel->cur_control = curSel->points->next; curSel->closed = 1; - if (curTool->gdisp_ptr) - bezier_convert(curSel, curTool->gdisp_ptr, SUBDIVIDE, FALSE); + if (curTool->gdisp) + bezier_convert (curSel, curTool->gdisp, SUBDIVIDE, FALSE); } /* g_print ("After pasting...\n"); */ /* printSel(curSel); */ - if(bsel->num_points == 0) + if (bsel->num_points == 0) { curSel->state = BEZIER_START; curSel->draw = 0; @@ -2876,17 +2868,17 @@ bezier_paste_bezierselect_to_current(GDisplay *gdisp,BezierSelect *bsel) } static void -bezier_to_sel_internal(BezierSelect *bezier_sel, - Tool *tool, - GDisplay *gdisp, - gint op, - gint replace) +bezier_to_sel_internal (BezierSelect *bezier_sel, + Tool *tool, + GDisplay *gdisp, + gint op, + gint replace) { /* If we're antialiased, then recompute the * mask... */ if (bezier_options->antialias) - bezier_convert (bezier_sel, tool->gdisp_ptr, SUBDIVIDE, TRUE); + bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, TRUE); /* if (!bezier_options->extend) */ /* { */ @@ -3156,7 +3148,8 @@ test_add_point_on_segment (BezierSelect *bezier_sel, return FALSE; } -void bezier_select_mode(gint mode) +void +bezier_select_mode (gint mode) { ModeEdit = mode; } diff --git a/app/tools/bezier_selectP.h b/app/tools/bezier_selectP.h index 1e5368541e..87b76aec96 100644 --- a/app/tools/bezier_selectP.h +++ b/app/tools/bezier_selectP.h @@ -81,7 +81,7 @@ typedef void (* BezierPointsFunc) (BezierSelect *bezier_sel, gpointer data); /* Functions */ -gint bezier_select_load (void *gdisp_ptr, +gint bezier_select_load (GDisplay *gdisp, BezierPoint *points, gint n_points, gint closed); diff --git a/app/tools/blend.c b/app/tools/blend.c index ebb5915c43..7826c7681f 100644 --- a/app/tools/blend.c +++ b/app/tools/blend.c @@ -162,13 +162,24 @@ static guint blend_n_targets = (sizeof (blend_target_table) / /* local function prototypes */ -static void gradient_type_callback (GtkWidget *, gpointer); +static void gradient_type_callback (GtkWidget *widget, + gpointer data); -static void blend_button_press (Tool *, GdkEventButton *, gpointer); -static void blend_button_release (Tool *, GdkEventButton *, gpointer); -static void blend_motion (Tool *, GdkEventMotion *, gpointer); -static void blend_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void blend_control (Tool *, ToolAction, gpointer); +static void blend_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void blend_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void blend_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void blend_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void blend_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static void blend_options_drop_gradient (GtkWidget *, gradient_t *, gpointer); static void blend_options_drop_tool (GtkWidget *, ToolType, gpointer); @@ -432,12 +443,10 @@ blend_options_new (void) static void blend_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BlendTool * blend_tool; + BlendTool *blend_tool; - gdisp = (GDisplay *) gdisp_ptr; blend_tool = (BlendTool *) tool->private; switch (drawable_type (gimp_image_active_drawable (gdisp->gimage))) @@ -463,7 +472,7 @@ blend_button_press (Tool *tool, GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; /* initialize the statusbar display */ @@ -477,19 +486,17 @@ blend_button_press (Tool *tool, static void blend_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - GImage * gimage; - BlendTool * blend_tool; + GImage *gimage; + BlendTool *blend_tool; #ifdef BLEND_UI_CALLS_VIA_PDB - Argument *return_vals; + Argument *return_vals; int nreturn_vals; #else gimp_progress *progress; #endif - gdisp = (GDisplay *) gdisp_ptr; gimage = gdisp->gimage; blend_tool = (BlendTool *) tool->private; @@ -568,13 +575,11 @@ blend_button_release (Tool *tool, static void blend_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BlendTool * blend_tool; - gchar vector[STATUSBAR_SIZE]; + BlendTool *blend_tool; + gchar vector[STATUSBAR_SIZE]; - gdisp = (GDisplay *) gdisp_ptr; blend_tool = (BlendTool *) tool->private; /* undraw the current tool */ @@ -642,12 +647,8 @@ blend_motion (Tool *tool, static void blend_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - - gdisp = (GDisplay *) gdisp_ptr; - switch (drawable_type (gimp_image_active_drawable (gdisp->gimage))) { case INDEXED_GIMAGE: @@ -669,16 +670,16 @@ blend_cursor_update (Tool *tool, static void blend_draw (Tool *tool) { - GDisplay * gdisp; - BlendTool * blend_tool; - int tx1, ty1, tx2, ty2; + BlendTool *blend_tool; + gint tx1, ty1, tx2, ty2; - gdisp = (GDisplay *) tool->gdisp_ptr; blend_tool = (BlendTool *) tool->private; - gdisplay_transform_coords (gdisp, blend_tool->startx, blend_tool->starty, + gdisplay_transform_coords (tool->gdisp, + blend_tool->startx, blend_tool->starty, &tx1, &ty1, 1); - gdisplay_transform_coords (gdisp, blend_tool->endx, blend_tool->endy, + gdisplay_transform_coords (tool->gdisp, + blend_tool->endx, blend_tool->endy, &tx2, &ty2, 1); /* Draw start target */ @@ -705,7 +706,7 @@ blend_draw (Tool *tool) static void blend_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { BlendTool * blend_tool; diff --git a/app/tools/blend.h b/app/tools/blend.h index 3c25e17344..2838ce36b6 100644 --- a/app/tools/blend.h +++ b/app/tools/blend.h @@ -53,26 +53,26 @@ typedef enum REPEAT_LAST /*< skip >*/ } RepeatMode; -void blend (GimpImage *, - GimpDrawable *, - BlendMode, - gint, - GradientType, - gdouble, - gdouble, - RepeatMode, - gint, - gint, - gdouble, - gdouble, - gdouble, - gdouble, - gdouble, - progress_func_t, - gpointer); +void blend (GimpImage *gimage, + GimpDrawable *drawable, + BlendMode blend_mode, + gint paint_mode, + GradientType gradient_type, + gdouble opacity, + gdouble offset, + RepeatMode repeat, + gint supersample, + gint max_depth, + gdouble threshold, + gdouble startx, + gdouble starty, + gdouble endx, + gdouble endy, + progress_func_t progress_callback, + gpointer progress_data); Tool * tools_new_blend (void); -void tools_free_blend (Tool *tool); +void tools_free_blend (Tool *tool); #endif /* __BLEND_H__ */ diff --git a/app/tools/brightness_contrast.c b/app/tools/brightness_contrast.c index 20a16dcbc3..51bf5d9f4b 100644 --- a/app/tools/brightness_contrast.c +++ b/app/tools/brightness_contrast.c @@ -83,7 +83,9 @@ static BrightnessContrastDialog *brightness_contrast_dialog = NULL; /* brightness contrast action functions */ -static void brightness_contrast_control (Tool *, ToolAction, gpointer); +static void brightness_contrast_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static BrightnessContrastDialog * brightness_contrast_dialog_new (void); @@ -104,7 +106,7 @@ static void brightness_contrast_contrast_adjustment_update (GtkAdjustment *, static void brightness_contrast_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -393,13 +395,13 @@ brightness_contrast_ok_callback (GtkWidget *widget, active_tool->preserve = TRUE; if (!bcd->preview) - { - brightness_contrast_lut_setup (bcd->lut, bcd->brightness / 255.0, - bcd->contrast / 127.0, - gimp_drawable_bytes (bcd->drawable)); - image_map_apply (bcd->image_map, (ImageMapApplyFunc) gimp_lut_process_2, - (void *) bcd->lut); - } + { + brightness_contrast_lut_setup (bcd->lut, bcd->brightness / 255.0, + bcd->contrast / 127.0, + gimp_drawable_bytes (bcd->drawable)); + image_map_apply (bcd->image_map, (ImageMapApplyFunc) gimp_lut_process_2, + (void *) bcd->lut); + } if (bcd->image_map) image_map_commit (bcd->image_map); @@ -408,7 +410,7 @@ brightness_contrast_ok_callback (GtkWidget *widget, bcd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -432,7 +434,7 @@ brightness_contrast_cancel_callback (GtkWidget *widget, gdisplays_flush (); } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/brightness_contrast.h b/app/tools/brightness_contrast.h index 41e909dc68..9cd9077287 100644 --- a/app/tools/brightness_contrast.h +++ b/app/tools/brightness_contrast.h @@ -20,12 +20,12 @@ #define __BRIGHTNESS_CONTRAST_H__ -Tool * tools_new_brightness_contrast (void); -void tools_free_brightness_contrast (Tool *tool); +Tool * tools_new_brightness_contrast (void); +void tools_free_brightness_contrast (Tool *tool); void brightness_contrast_dialog_hide (void); -void brightness_contrast_initialize (GDisplay *gdisp); +void brightness_contrast_initialize (GDisplay *gdisp); #endif /* __BRIGHTNESS_CONTRAST_H__ */ diff --git a/app/tools/bucket_fill.c b/app/tools/bucket_fill.c index d227994b71..3a32810872 100644 --- a/app/tools/bucket_fill.c +++ b/app/tools/bucket_fill.c @@ -85,14 +85,30 @@ static BucketOptions *bucket_options = NULL; /* local function prototypes */ -static void bucket_fill_button_press (Tool *, GdkEventButton *, gpointer); -static void bucket_fill_button_release (Tool *, GdkEventButton *, gpointer); -static void bucket_fill_cursor_update (Tool *, GdkEventMotion *, gpointer); +static void bucket_fill_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void bucket_fill_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void bucket_fill_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); -static void bucket_fill_line_color (guchar *, guchar *, guchar *, - gboolean, gint, gint); -static void bucket_fill_line_pattern (guchar *, guchar *, TempBuf *, - gboolean, gint, gint, gint, gint); +static void bucket_fill_line_color (guchar *, + guchar *, + guchar *, + gboolean , + gint , + gint ); +static void bucket_fill_line_pattern (guchar *, + guchar *, + TempBuf *, + gboolean , + gint , + gint , + gint , + gint ); /* functions */ @@ -123,7 +139,7 @@ bucket_options_new (void) GtkWidget *frame; /* the new bucket fill tool options structure */ - options = (BucketOptions *) g_malloc (sizeof (BucketOptions)); + options = g_new (BucketOptions, 1); paint_options_init ((PaintOptions *) options, BUCKET_FILL, bucket_options_reset); @@ -194,13 +210,11 @@ bucket_options_new (void) static void bucket_fill_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BucketTool * bucket_tool; - gboolean use_offsets; + BucketTool *bucket_tool; + gboolean use_offsets; - gdisp = (GDisplay *) gdisp_ptr; bucket_tool = (BucketTool *) tool->private; use_offsets = (bucket_options->sample_merged) ? FALSE : TRUE; @@ -217,21 +231,19 @@ bucket_fill_button_press (Tool *tool, NULL, NULL, bevent->time); /* Make the tool active and set the gdisplay which owns it */ - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; } static void bucket_fill_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BucketTool * bucket_tool; - Argument *return_vals; - gint nreturn_vals; + BucketTool *bucket_tool; + Argument *return_vals; + gint nreturn_vals; - gdisp = (GDisplay *) gdisp_ptr; bucket_tool = (BucketTool *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -267,16 +279,13 @@ bucket_fill_button_release (Tool *tool, static void bucket_fill_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - CursorModifier cmodifier = CURSOR_MODIFIER_NONE; - gint x, y; - gint off_x, off_y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + CursorModifier cmodifier = CURSOR_MODIFIER_NONE; + gint x, y; + gint off_x, off_y; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -321,7 +330,7 @@ bucket_fill_cursor_update (Tool *tool, static void bucket_fill_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -359,14 +368,14 @@ bucket_fill (GimpImage *gimage, TileManager *buf_tiles; PixelRegion bufPR, maskPR; Channel *mask = NULL; - gint bytes; - gboolean has_alpha; - gint x1, y1, x2, y2; - guchar col [MAX_CHANNELS]; - guchar *d1, *d2; - GPattern *pattern; - TempBuf *pat_buf; - gboolean new_buf = FALSE; + gint bytes; + gboolean has_alpha; + gint x1, y1, x2, y2; + guchar col [MAX_CHANNELS]; + guchar *d1, *d2; + GPattern *pattern; + TempBuf *pat_buf; + gboolean new_buf = FALSE; pat_buf = NULL; @@ -433,7 +442,7 @@ bucket_fill (GimpImage *gimage, /* make sure we handle the mask correctly if it was sample-merged */ if (sample_merged) { - int off_x, off_y; + gint off_x, off_y; /* Limit the channel bounds to the drawable's extents */ drawable_offsets (drawable, &off_x, &off_y); @@ -533,8 +542,8 @@ bucket_fill_line_pattern (guchar *buf, gint width) { guchar *pat, *p; - gint alpha, b; - gint i; + gint alpha, b; + gint i; /* Get a pointer to the appropriate scanline of the pattern buffer */ pat = temp_buf_data (pattern) + @@ -571,8 +580,8 @@ bucket_fill_region (BucketFillMode fill_mode, gboolean has_alpha) { guchar *s, *m; - gint y; - void *pr; + gint y; + void *pr; for (pr = pixel_regions_register (2, bufPR, maskPR); pr != NULL; @@ -612,8 +621,8 @@ bucket_fill_region (BucketFillMode fill_mode, Tool * tools_new_bucket_fill (void) { - Tool * tool; - BucketTool * private; + Tool *tool; + BucketTool *private; /* The tool options */ if (! bucket_options) @@ -630,7 +639,7 @@ tools_new_bucket_fill (void) tool->scroll_lock = TRUE; /* Disallow scrolling */ - tool->private = (void *) private; + tool->private = (gpointer) private; tool->button_press_func = bucket_fill_button_press; tool->button_release_func = bucket_fill_button_release; @@ -643,7 +652,7 @@ tools_new_bucket_fill (void) void tools_free_bucket_fill (Tool *tool) { - BucketTool * bucket_tool; + BucketTool *bucket_tool; bucket_tool = (BucketTool *) tool->private; diff --git a/app/tools/by_color_select.c b/app/tools/by_color_select.c index 45210650c9..b8bd885d7a 100644 --- a/app/tools/by_color_select.c +++ b/app/tools/by_color_select.c @@ -82,6 +82,7 @@ struct _ByColorDialog GImage *gimage; /* gimage which is currently under examination */ }; + /* the by color selection tool options */ static SelectionOptions * by_color_options = NULL; @@ -93,43 +94,71 @@ static GtkTargetEntry by_color_select_targets[] = { GIMP_TARGET_COLOR }; -static guint n_by_color_select_targets = (sizeof (by_color_select_targets) / - sizeof (by_color_select_targets[0])); +static guint n_by_color_select_targets = (sizeof (by_color_select_targets) / + sizeof (by_color_select_targets[0])); -static void by_color_select_color_drop (GtkWidget *widget, - guchar r, - guchar g, - guchar b, - gpointer data); + +static void by_color_select_color_drop (GtkWidget *widget, + guchar r, + guchar g, + guchar b, + gpointer data); /* by_color select action functions */ -static void by_color_select_button_press (Tool *, GdkEventButton *, gpointer); -static void by_color_select_button_release (Tool *, GdkEventButton *, gpointer); -static void by_color_select_modifier_update (Tool *, GdkEventKey * , gpointer); -static void by_color_select_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void by_color_select_oper_update (Tool *, GdkEventMotion *, gpointer); -static void by_color_select_control (Tool *, ToolAction, gpointer); +static void by_color_select_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void by_color_select_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void by_color_select_modifier_update (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void by_color_select_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void by_color_select_oper_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void by_color_select_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); -static ByColorDialog * by_color_select_dialog_new (void); +static ByColorDialog * by_color_select_dialog_new (void); -static void by_color_select_render (ByColorDialog *, GImage *); -static void by_color_select_draw (ByColorDialog *, GImage *); -static gint by_color_select_preview_events (GtkWidget *, +static void by_color_select_render (ByColorDialog *, + GImage *); +static void by_color_select_draw (ByColorDialog *, + GImage *); +static gint by_color_select_preview_events (GtkWidget *, GdkEventButton *, - ByColorDialog *); -static void by_color_select_invert_callback (GtkWidget *, gpointer); -static void by_color_select_select_all_callback (GtkWidget *, gpointer); -static void by_color_select_select_none_callback (GtkWidget *, gpointer); -static void by_color_select_reset_callback (GtkWidget *, gpointer); -static void by_color_select_close_callback (GtkWidget *, gpointer); -static void by_color_select_preview_button_press (ByColorDialog *, + ByColorDialog *); +static void by_color_select_invert_callback (GtkWidget *, + gpointer ); +static void by_color_select_select_all_callback (GtkWidget *, + gpointer ); +static void by_color_select_select_none_callback (GtkWidget *, + gpointer ); +static void by_color_select_reset_callback (GtkWidget *, + gpointer ); +static void by_color_select_close_callback (GtkWidget *, + gpointer ); +static void by_color_select_preview_button_press (ByColorDialog *, GdkEventButton *); -static gint is_pixel_sufficiently_different (guchar *, guchar *, - gint, gint, gint, gint); -static Channel * by_color_select_color (GImage *, GimpDrawable *, - guchar *, gint, gint, gint); +static gint is_pixel_sufficiently_different (guchar *, + guchar *, + gint , + gint , + gint , + gint ); +static Channel * by_color_select_color (GImage *, + GimpDrawable *, + guchar *, + gint , + gint , + gint ); /* by_color selection machinery */ @@ -196,18 +225,18 @@ by_color_select_color (GImage *gimage, * use the same antialiasing scheme as in fuzzy_select. Modify the gimage's * mask to reflect the additional selection */ - Channel *mask; - PixelRegion imagePR, maskPR; - guchar *image_data; - guchar *mask_data; - guchar *idata, *mdata; - guchar rgb[MAX_CHANNELS]; - gint has_alpha, indexed; - gint width, height; - gint bytes, color_bytes, alpha; - gint i, j; - void * pr; - gint d_type; + Channel *mask; + PixelRegion imagePR, maskPR; + guchar *image_data; + guchar *mask_data; + guchar *idata, *mdata; + guchar rgb[MAX_CHANNELS]; + gint has_alpha, indexed; + gint width, height; + gint bytes, color_bytes, alpha; + gint i, j; + gpointer pr; + gint d_type; /* Get the image information */ if (sample_merged) @@ -342,12 +371,10 @@ by_color_select (GImage *gimage, static void by_color_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; ByColorSelect *by_color_sel; - gdisp = (GDisplay *) gdisp_ptr; by_color_sel = (ByColorSelect *) tool->private; tool->drawable = gimp_image_active_drawable (gdisp->gimage); @@ -359,7 +386,7 @@ by_color_select_button_press (Tool *tool, by_color_sel->y = bevent->y; tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; /* Make sure the "by color" select dialog is visible */ if (! GTK_WIDGET_VISIBLE (by_color_dialog->shell)) @@ -393,16 +420,14 @@ by_color_select_button_press (Tool *tool, static void by_color_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_color_sel; - GDisplay *gdisp; gint x, y; GimpDrawable *drawable; guchar *color; gint use_offsets; - gdisp = (GDisplay *) gdisp_ptr; by_color_sel = (ByColorSelect *) tool->private; drawable = gimp_image_active_drawable (gdisp->gimage); @@ -456,14 +481,12 @@ by_color_select_button_release (Tool *tool, static void by_color_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_col_sel; - GDisplay *gdisp; Layer *layer; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; by_col_sel = (ByColorSelect *) tool->private; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, @@ -551,7 +574,7 @@ by_color_select_update_op_state (ByColorSelect *by_col_sel, static void by_color_select_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_col_sel; gint state; @@ -584,26 +607,25 @@ by_color_select_modifier_update (Tool *tool, break; } - by_color_select_update_op_state (by_col_sel, state, (GDisplay *) gdisp_ptr); + by_color_select_update_op_state (by_col_sel, state, gdisp); } static void by_color_select_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_col_sel; by_col_sel = (ByColorSelect *) tool->private; - by_color_select_update_op_state (by_col_sel, mevent->state, - (GDisplay *) gdisp_ptr); + by_color_select_update_op_state (by_col_sel, mevent->state, gdisp); } static void by_color_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { diff --git a/app/tools/clone.c b/app/tools/clone.c index 7c16c6f684..320e2c7725 100644 --- a/app/tools/clone.c +++ b/app/tools/clone.c @@ -79,37 +79,59 @@ struct _CloneOptions }; +/* forward function declarations */ + +static gpointer clone_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void clone_draw (Tool *tool); +static void clone_motion (PaintCore *paint_core, + GimpDrawable *drawable, + GimpDrawable *src_drawable, + PaintPressureOptions *pressure_options, + CloneType type, + gint offset_x, + gint offset_y); +static void clone_line_image (GImage *dest, + GImage *src, + GimpDrawable *d_drawable, + GimpDrawable *s_drawable, + guchar *s, + guchar *d, + gint has_alpha, + gint src_bytes, + gint dest_bytes, + gint width); +static void clone_line_pattern (GImage *dest, + GimpDrawable *drawable, + GPattern *pattern, + guchar *d, + gint x, + gint y, + gint bytes, + gint width); + + /* the clone tool options */ static CloneOptions *clone_options = NULL; /* local variables */ -static int src_x = 0; /* */ -static int src_y = 0; /* position of clone src */ -static int dest_x = 0; /* */ -static int dest_y = 0; /* position of clone src */ -static int offset_x = 0; /* */ -static int offset_y = 0; /* offset for cloning */ -static int first = TRUE; -static int trans_tx, trans_ty; /* transformed target */ +static gint src_x = 0; /* */ +static gint src_y = 0; /* position of clone src */ +static gint dest_x = 0; /* */ +static gint dest_y = 0; /* position of clone src */ +static gint offset_x = 0; /* */ +static gint offset_y = 0; /* offset for cloning */ +static gint first = TRUE; +static gint trans_tx, trans_ty; /* transformed target */ static GDisplay *the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable *src_drawable_ = NULL; /* source drawable */ static GimpDrawable *non_gui_src_drawable; -static int non_gui_offset_x; -static int non_gui_offset_y; +static gint non_gui_offset_x; +static gint non_gui_offset_y; static CloneType non_gui_type; -/* forward function declarations */ - -static void clone_draw (Tool *); -static void clone_motion (PaintCore *, GimpDrawable *, GimpDrawable *, - PaintPressureOptions *, CloneType, int, int); -static void clone_line_image (GImage *, GImage *, GimpDrawable *, - GimpDrawable *, unsigned char *, - unsigned char *, int, int, int, int); -static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, - unsigned char *, int, int, int, int); - /* functions */ @@ -128,8 +150,8 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *frame; /* the new clone tool options structure */ options = g_new (CloneOptions, 1); @@ -202,23 +224,24 @@ clone_set_src_drawable (GimpDrawable *drawable) } } -void * +static gpointer clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - gint state) + PaintState state) { - GDisplay * gdisp; - GDisplay * src_gdisp; - int x1, y1, x2, y2; - static int orig_src_x, orig_src_y; + GDisplay *gdisp; + GDisplay *src_gdisp; + gint x1, y1, x2, y2; + static gint orig_src_x, orig_src_y; - gdisp = (GDisplay *) active_tool->gdisp_ptr; + gdisp = (GDisplay *) active_tool->gdisp; switch (state) { case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; @@ -320,14 +343,11 @@ clone_paint_func (PaintCore *paint_core, void clone_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + gint x, y; gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y, &x, &y, TRUE, FALSE); @@ -661,10 +681,10 @@ clone_line_pattern (GImage *dest, } } -static void * -clone_non_gui_paint_func (PaintCore *paint_core, +static gpointer +clone_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { clone_motion (paint_core, drawable, non_gui_src_drawable, &non_gui_pressure_options, @@ -675,16 +695,16 @@ clone_non_gui_paint_func (PaintCore *paint_core, gboolean clone_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { GimpDrawable *src_drawable = NULL; CloneType clone_type = CLONE_DEFAULT_TYPE; - double local_src_x = 0.0; - double local_src_y = 0.0; + gdouble local_src_x = 0.0; + gdouble local_src_y = 0.0; CloneOptions *options = clone_options; - - if(options) + + if (options) { clone_type = options->type; src_drawable = src_drawable_; @@ -692,23 +712,23 @@ clone_non_gui_default (GimpDrawable *drawable, local_src_y = src_y; } - return clone_non_gui(drawable, - src_drawable, - clone_type, - local_src_x,local_src_y, - num_strokes,stroke_array); + return clone_non_gui (drawable, + src_drawable, + clone_type, + local_src_x,local_src_y, + num_strokes, stroke_array); } gboolean clone_non_gui (GimpDrawable *drawable, GimpDrawable *src_drawable, CloneType clone_type, - double src_x, - double src_y, - int num_strokes, - double *stroke_array) + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) diff --git a/app/tools/clone.h b/app/tools/clone.h index 0433bc488e..fcc2f1d247 100644 --- a/app/tools/clone.h +++ b/app/tools/clone.h @@ -26,21 +26,19 @@ typedef enum PATTERN_CLONE } CloneType; -void * clone_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean clone_non_gui (GimpDrawable *, - GimpDrawable *, - CloneType, - gdouble, - gdouble, - gint, - gdouble *); -gboolean clone_non_gui_default (GimpDrawable *, - gint, - gdouble *); + +gboolean clone_non_gui (GimpDrawable *drawable, + GimpDrawable *src_drawable, + CloneType clone_type, + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array); +gboolean clone_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_clone (void); -void tools_free_clone (Tool *); +void tools_free_clone (Tool *tool); #endif /* __CLONE_H__ */ diff --git a/app/tools/color_balance.c b/app/tools/color_balance.c index b74246cfdc..87b62926bc 100644 --- a/app/tools/color_balance.c +++ b/app/tools/color_balance.c @@ -62,21 +62,33 @@ static ColorBalanceDialog *color_balance_dialog = NULL; /* color balance action functions */ -static void color_balance_control (Tool *, ToolAction, gpointer); +static void color_balance_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static ColorBalanceDialog * color_balance_dialog_new (void); -static void color_balance_update (ColorBalanceDialog *, int); -static void color_balance_preview (ColorBalanceDialog *); -static void color_balance_reset_callback (GtkWidget *, gpointer); -static void color_balance_ok_callback (GtkWidget *, gpointer); -static void color_balance_cancel_callback (GtkWidget *, gpointer); -static void color_balance_range_callback (GtkWidget *, gpointer); -static void color_balance_preserve_update (GtkWidget *, gpointer); -static void color_balance_preview_update (GtkWidget *, gpointer); -static void color_balance_cr_adjustment_update (GtkAdjustment *, gpointer); -static void color_balance_mg_adjustment_update (GtkAdjustment *, gpointer); -static void color_balance_yb_adjustment_update (GtkAdjustment *, gpointer); +static void color_balance_update (ColorBalanceDialog *cbd, + gint ); +static void color_balance_preview (ColorBalanceDialog *cbd); +static void color_balance_reset_callback (GtkWidget *widget, + gpointer data); +static void color_balance_ok_callback (GtkWidget *widget, + gpointer data); +static void color_balance_cancel_callback (GtkWidget *widget, + gpointer data); +static void color_balance_range_callback (GtkWidget *widget, + gpointer data); +static void color_balance_preserve_update (GtkWidget *widget, + gpointer data); +static void color_balance_preview_update (GtkWidget *widget, + gpointer data); +static void color_balance_cr_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void color_balance_mg_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void color_balance_yb_adjustment_update (GtkAdjustment *adj, + gpointer data); /* color balance machinery */ @@ -86,12 +98,12 @@ color_balance (PixelRegion *srcPR, void *data) { ColorBalanceDialog *cbd; - guchar *src, *s; - guchar *dest, *d; - gint alpha; - gint r, g, b; - gint r_n, g_n, b_n; - gint w, h; + guchar *src, *s; + guchar *dest, *d; + gboolean alpha; + gint r, g, b; + gint r_n, g_n, b_n; + gint w, h; cbd = (ColorBalanceDialog *) data; @@ -143,7 +155,7 @@ color_balance (PixelRegion *srcPR, static void color_balance_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { ColorBalance * color_bal; @@ -599,7 +611,7 @@ color_balance_ok_callback (GtkWidget *widget, cbd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -623,7 +635,7 @@ color_balance_cancel_callback (GtkWidget *widget, cbd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/color_picker.c b/app/tools/color_picker.c index 17fda5b902..1bd0efe8d9 100644 --- a/app/tools/color_picker.c +++ b/app/tools/color_picker.c @@ -100,24 +100,36 @@ static gchar hex_buf [MAX_INFO_BUF]; /* local function prototypes */ -static void color_picker_button_press (Tool *, GdkEventButton *, gpointer); -static void color_picker_button_release (Tool *, GdkEventButton *, gpointer); -static void color_picker_motion (Tool *, GdkEventMotion *, gpointer); -static void color_picker_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void color_picker_control (Tool *, ToolAction, gpointer); +static void color_picker_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void color_picker_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void color_picker_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void color_picker_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void color_picker_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); -static void color_picker_info_window_close_callback (GtkWidget *, gpointer); -static void color_picker_info_update (Tool *, gboolean); +static void color_picker_info_window_close_callback (GtkWidget *widget, + gpointer data); +static void color_picker_info_update (Tool *tool, + gboolean valid); -static gboolean pick_color_do (GimpImage *gimage, - GimpDrawable *drawable, - gint x, - gint y, - gboolean sample_merged, - gboolean sample_average, - gdouble average_radius, - gboolean update_active, - gint final); +static gboolean pick_color_do (GimpImage *gimage, + GimpDrawable *drawable, + gint x, + gint y, + gboolean sample_merged, + gboolean sample_average, + gdouble average_radius, + gboolean update_active, + gint final); /* functions */ @@ -235,19 +247,17 @@ color_picker_options_new (void) static void color_picker_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; ColorPickerTool *cp_tool; - gint x, y; + gint x, y; - gdisp = (GDisplay *) gdisp_ptr; cp_tool = (ColorPickerTool *) tool->private; /* Make the tool active and set it's gdisplay & drawable */ - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->drawable = gimp_image_active_drawable (gdisp->gimage); - tool->state = ACTIVE; + tool->state = ACTIVE; /* create the info dialog if it doesn't exist */ if (! color_picker_info) @@ -356,15 +366,14 @@ color_picker_button_press (Tool *tool, static void color_picker_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; ColorPickerTool *cp_tool; - gint x, y; + gint x, y; gdk_pointer_ungrab (bevent->time); gdk_flush (); - gdisp = (GDisplay *) gdisp_ptr; + cp_tool = (ColorPickerTool *) tool->private; /* First, transform the coordinates to gimp image space */ @@ -386,13 +395,11 @@ color_picker_button_release (Tool *tool, static void color_picker_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; ColorPickerTool *cp_tool; - gint x, y; + gint x, y; - gdisp = (GDisplay *) gdisp_ptr; cp_tool = (ColorPickerTool *) tool->private; /* undraw the current tool */ @@ -421,13 +428,10 @@ color_picker_motion (Tool *tool, static void color_picker_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; - gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -446,9 +450,9 @@ color_picker_cursor_update (Tool *tool, static void color_picker_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { - ColorPickerTool * cp_tool; + ColorPickerTool *cp_tool; cp_tool = (ColorPickerTool *) tool->private; @@ -594,25 +598,23 @@ pick_color (GimpImage *gimage, static void colorpicker_draw (Tool *tool) { - GDisplay * gdisp; - ColorPickerTool * cp_tool; - gint tx, ty; - gint radiusx, radiusy; - gint cx, cy; + ColorPickerTool *cp_tool; + gint tx, ty; + gint radiusx, radiusy; + gint cx, cy; if (! color_picker_options->sample_average) return; - gdisp = (GDisplay *) tool->gdisp_ptr; cp_tool = (ColorPickerTool *) tool->private; - gdisplay_transform_coords (gdisp, cp_tool->centerx, cp_tool->centery, + gdisplay_transform_coords (tool->gdisp, cp_tool->centerx, cp_tool->centery, &tx, &ty, TRUE); - radiusx = SCALEX (gdisp, color_picker_options->average_radius); - radiusy = SCALEY (gdisp, color_picker_options->average_radius); - cx = SCALEX (gdisp, 1); - cy = SCALEY (gdisp, 1); + radiusx = SCALEX (tool->gdisp, color_picker_options->average_radius); + radiusy = SCALEY (tool->gdisp, color_picker_options->average_radius); + cx = SCALEX (tool->gdisp, 1); + cy = SCALEY (tool->gdisp, 1); /* Draw the circle around the collecting area */ gdk_draw_rectangle (cp_tool->core->win, cp_tool->core->gc, 0, diff --git a/app/tools/convolve.c b/app/tools/convolve.c index bcf8bd2580..e8df499d63 100644 --- a/app/tools/convolve.c +++ b/app/tools/convolve.c @@ -82,6 +82,28 @@ struct _ConvolveOptions }; +/* forward function declarations */ +static void calculate_matrix (ConvolveType type, + gdouble rate); +static void integer_matrix (gfloat *source, + gint *dest, + gint size); +static void copy_matrix (gfloat *src, + gfloat *dest, + gint size); +static gint sum_matrix (gint *matrix, + gint size); + +static gpointer convolve_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void convolve_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + ConvolveType type, + gdouble rate); + + /* the convolve tool options */ static ConvolveOptions * convolve_options = NULL; @@ -121,19 +143,8 @@ static gfloat sharpen_matrix [25] = }; -/* forward function declarations */ -static void calculate_matrix (ConvolveType, double); -static void integer_matrix (float *, int *, int); -static void copy_matrix (float *, float *, int); -static int sum_matrix (int *, int); - -static void convolve_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, - ConvolveType, double); - /* functions */ - static void convolve_options_reset (void) { @@ -205,10 +216,10 @@ convolve_options_new (void) return options; } -void * +static gpointer convolve_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -217,6 +228,9 @@ convolve_paint_func (PaintCore *paint_core, convolve_options->paint_options.pressure_options, convolve_options->type, convolve_options->rate); break; + + default: + break; } return NULL; @@ -225,7 +239,7 @@ convolve_paint_func (PaintCore *paint_core, static void convolve_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -282,18 +296,18 @@ convolve_modifier_key_func (Tool *tool, static void convolve_cursor_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE); - paint_core_cursor_update (tool, mevent, gdisp_ptr); + paint_core_cursor_update (tool, mevent, gdisp); } Tool * tools_new_convolve (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! convolve_options) @@ -570,34 +584,34 @@ calculate_matrix (ConvolveType type, } static void -integer_matrix (float *source, - int *dest, - int size) +integer_matrix (gfloat *source, + gint *dest, + gint size) { - int i; + gint i; #define PRECISION 10000 for (i = 0; i < size*size; i++) - *dest++ = (int) (*source ++ * PRECISION); + *dest++ = (gint) (*source ++ * PRECISION); } static void -copy_matrix (float *src, - float *dest, - int size) +copy_matrix (gfloat *src, + gfloat *dest, + gint size) { - int i; + gint i; for (i = 0; i < size*size; i++) *dest++ = *src++; } static int -sum_matrix (int *matrix, - int size) +sum_matrix (gint *matrix, + gint size) { - int sum = 0; + gint sum = 0; size *= size; @@ -608,10 +622,10 @@ sum_matrix (int *matrix, } -static void * -convolve_non_gui_paint_func (PaintCore *paint_core, +static gpointer +convolve_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { convolve_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_type, non_gui_rate); @@ -621,11 +635,11 @@ convolve_non_gui_paint_func (PaintCore *paint_core, gboolean convolve_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - double rate = DEFAULT_CONVOLVE_RATE; - ConvolveType type = DEFAULT_CONVOLVE_TYPE; + gdouble rate = DEFAULT_CONVOLVE_RATE; + ConvolveType type = DEFAULT_CONVOLVE_TYPE; ConvolveOptions *options = convolve_options; if (options) @@ -641,17 +655,17 @@ gboolean convolve_non_gui (GimpDrawable *drawable, double rate, ConvolveType type, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) { /* Set the paint core's paint func */ non_gui_paint_core.paint_func = convolve_non_gui_paint_func; - + non_gui_type = type; non_gui_rate = rate; @@ -678,6 +692,6 @@ convolve_non_gui (GimpDrawable *drawable, paint_core_cleanup (); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/tools/convolve.h b/app/tools/convolve.h index 3a6058ef5c..1e07c92d36 100644 --- a/app/tools/convolve.h +++ b/app/tools/convolve.h @@ -28,19 +28,17 @@ typedef enum } ConvolveType; -void * convolve_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean convolve_non_gui (GimpDrawable *, - gdouble , - ConvolveType , - gint , - gdouble *); -gboolean convolve_non_gui_default (GimpDrawable *, - gint , - gdouble *); -Tool * tools_new_convolve (void ); -void tools_free_convolve (Tool *); +gboolean convolve_non_gui (GimpDrawable *drawable, + gdouble rate, + ConvolveType type, + gint num_strokes, + gdouble *stroke_array); +gboolean convolve_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); + +Tool * tools_new_convolve (void); +void tools_free_convolve (Tool *tool); #endif /* __CONVOLVE_H__ */ diff --git a/app/tools/crop.c b/app/tools/crop.c index a792147af9..5f78ff5925 100644 --- a/app/tools/crop.c +++ b/app/tools/crop.c @@ -121,25 +121,49 @@ static GtkWidget *size_sizeentry; /* Crop type functions */ -static void crop_button_press (Tool *, GdkEventButton *, gpointer); -static void crop_button_release (Tool *, GdkEventButton *, gpointer); -static void crop_motion (Tool *, GdkEventMotion *, gpointer); -static void crop_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void crop_control (Tool *, ToolAction, gpointer); -static void crop_arrow_keys_func (Tool *, GdkEventKey *, gpointer); -static void crop_modifier_key_func (Tool *, GdkEventKey *, gpointer); +static void crop_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void crop_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void crop_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void crop_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void crop_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); +static void crop_arrow_keys_func (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void crop_modifier_key_func (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); /* Crop helper functions */ -static void crop_recalc (Tool *, Crop *); -static void crop_start (Tool *, Crop *); -static void crop_adjust_guides (GImage *, int, int, int, int); +static void crop_recalc (Tool *tool, + Crop *crop); +static void crop_start (Tool *tool, + Crop *crop); +static void crop_adjust_guides (GImage *gimage, + gint x1, + gint y1, + gint x2, + gint y2); /* Crop dialog functions */ -static void crop_info_update (Tool *); -static void crop_info_create (Tool *); -static void crop_crop_callback (GtkWidget *, gpointer); -static void crop_resize_callback (GtkWidget *, gpointer); -static void crop_close_callback (GtkWidget *, gpointer); +static void crop_info_update (Tool *tool); +static void crop_info_create (Tool *tool); +static void crop_crop_callback (GtkWidget *widget, + gpointer data); +static void crop_resize_callback (GtkWidget *widget, + gpointer data); +static void crop_close_callback (GtkWidget *widget, + gpointer data); + /* Crop area-select functions */ typedef enum @@ -149,19 +173,40 @@ typedef enum AUTO_CROP_COLOR = 2 } AutoCropType; -typedef guchar * (*GetColorFunc) (GtkObject *, int, int); -typedef AutoCropType (*ColorsEqualFunc) (guchar *, guchar *, int); -static void crop_selection_callback (GtkWidget *, gpointer); -static void crop_automatic_callback (GtkWidget *, gpointer); -static AutoCropType crop_guess_bgcolor (GtkObject *, GetColorFunc, - int, int, guchar *, int, int, int, int); -static int crop_colors_equal (guchar *, guchar *, int); -static int crop_colors_alpha (guchar *, guchar *, int); +typedef guchar * (* GetColorFunc) (GtkObject *, + gint , + gint ); +typedef AutoCropType (* ColorsEqualFunc) (guchar *, + guchar *, + gint ); + +static void crop_selection_callback (GtkWidget *widget, + gpointer data); +static void crop_automatic_callback (GtkWidget *widget, + gpointer data); +static AutoCropType crop_guess_bgcolor (GtkObject *, + GetColorFunc, + gint , + gint , + guchar *, + gint , + gint , + gint , + gint ); +static gint crop_colors_equal (guchar *, + guchar *, + gint ); +static gint crop_colors_alpha (guchar *, + guchar *, + gint ); + /* Crop dialog callback funtions */ -static void crop_orig_changed (GtkWidget *, gpointer); -static void crop_size_changed (GtkWidget *, gpointer); +static void crop_orig_changed (GtkWidget *widget, + gpointer data); +static void crop_size_changed (GtkWidget *widget, + gpointer data); /* Functions */ @@ -182,8 +227,8 @@ static CropOptions * crop_options_new (void) { CropOptions *options; - GtkWidget *vbox; - GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *frame; /* the new crop tool options structure */ options = g_new (CropOptions, 1); @@ -241,16 +286,14 @@ crop_options_new (void) static void crop_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - Crop * crop; - GDisplay * gdisp; + Crop *crop; - gdisp = (GDisplay *) gdisp_ptr; crop = (Crop *) tool->private; if (tool->state == INACTIVE || - gdisp_ptr != tool->gdisp_ptr) + gdisp != tool->gdisp) { crop->function = CREATING; } @@ -291,7 +334,7 @@ crop_button_press (Tool *tool, if (tool->state == ACTIVE) draw_core_stop (crop->core, tool); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->drawable = gimp_image_active_drawable (gdisp->gimage); gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, @@ -318,13 +361,11 @@ crop_button_press (Tool *tool, static void crop_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - Crop * crop; - GDisplay *gdisp; + Crop *crop; crop = (Crop *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; gdk_pointer_ungrab (bevent->time); gdk_flush (); @@ -352,13 +393,15 @@ crop_button_release (Tool *tool, static void crop_adjust_guides (GImage *gimage, - int x1, int y1, - int x2, int y2) + gint x1, + gint y1, + gint x2, + gint y2) { - GList * glist; - Guide * guide; - gboolean remove_guide; + GList *glist; + Guide *guide; + gboolean remove_guide; for (glist = gimage->guides; glist; glist = g_list_next (glist)) { @@ -407,19 +450,17 @@ crop_adjust_guides (GImage *gimage, static void crop_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - Crop *crop; - GDisplay *gdisp; - Layer *layer; - gint x1, y1, x2, y2; - gint curx, cury; - gint inc_x, inc_y; - gchar size[STATUSBAR_SIZE]; - gint min_x, min_y, max_x, max_y; + Crop *crop; + Layer *layer; + gint x1, y1, x2, y2; + gint curx, cury; + gint inc_x, inc_y; + gchar size[STATUSBAR_SIZE]; + gint min_x, min_y, max_x, max_y; crop = (Crop *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; /* This is the only case when the motion events should be ignored-- we're just waiting for the button release event to crop the image */ @@ -554,19 +595,17 @@ crop_motion (Tool *tool, static void crop_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Crop *crop; + Crop *crop; GdkCursorType ctype = GIMP_MOUSE_CURSOR; CursorModifier cmodifier = CURSOR_MODIFIER_NONE; - gdisp = (GDisplay *) gdisp_ptr; crop = (Crop *) tool->private; if (tool->state == INACTIVE || - (tool->state == ACTIVE && tool->gdisp_ptr != gdisp_ptr)) + (tool->state == ACTIVE && tool->gdisp != gdisp)) { ctype = GIMP_CROSSHAIR_SMALL_CURSOR; } @@ -605,16 +644,13 @@ crop_cursor_update (Tool *tool, static void crop_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - Crop *crop; - gint inc_x, inc_y; - gint min_x, min_y; - gint max_x, max_y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + Crop *crop; + gint inc_x, inc_y; + gint min_x, min_y; + gint max_x, max_y; if (tool->state == ACTIVE) { @@ -687,7 +723,7 @@ crop_arrow_keys_func (Tool *tool, static void crop_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -712,7 +748,7 @@ crop_modifier_key_func (Tool *tool, static void crop_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { Crop *crop; @@ -741,19 +777,17 @@ crop_control (Tool *tool, void crop_draw (Tool *tool) { - Crop *crop; - GDisplay *gdisp; + Crop *crop; - gdisp = (GDisplay *) tool->gdisp_ptr; - crop = (Crop *) tool->private; + crop = (Crop *) tool->private; #define SRW 10 #define SRH 10 gdk_draw_line (crop->core->win, crop->core->gc, - crop->x1, crop->y1, gdisp->disp_width, crop->y1); + crop->x1, crop->y1, tool->gdisp->disp_width, crop->y1); gdk_draw_line (crop->core->win, crop->core->gc, - crop->x1, crop->y1, crop->x1, gdisp->disp_height); + crop->x1, crop->y1, crop->x1, tool->gdisp->disp_height); gdk_draw_line (crop->core->win, crop->core->gc, crop->x2, crop->y2, 0, crop->y2); gdk_draw_line (crop->core->win, crop->core->gc, @@ -843,10 +877,10 @@ crop_image (GImage *gimage, Channel *channel; GList *guide_list_ptr; GSList *list; - gint width, height; - gint lx1, ly1, lx2, ly2; - gint off_x, off_y; - gint doff_x, doff_y; + gint width, height; + gint lx1, ly1, lx2, ly2; + gint off_x, off_y; + gint doff_x, doff_y; width = x2 - x1; height = y2 - y1; @@ -978,13 +1012,9 @@ static void crop_recalc (Tool *tool, Crop *crop) { - GDisplay *gdisp; - - gdisp = (GDisplay *) tool->gdisp_ptr; - - gdisplay_transform_coords (gdisp, crop->tx1, crop->ty1, + gdisplay_transform_coords (tool->gdisp, crop->tx1, crop->ty1, &crop->x1, &crop->y1, FALSE); - gdisplay_transform_coords (gdisp, crop->tx2, crop->ty2, + gdisplay_transform_coords (tool->gdisp, crop->tx2, crop->ty2, &crop->x2, &crop->y2, FALSE); } @@ -993,9 +1023,6 @@ crop_start (Tool *tool, Crop *crop) { static GDisplay *old_gdisp = NULL; - GDisplay *gdisp; - - gdisp = (GDisplay *) tool->gdisp_ptr; crop_recalc (tool, crop); @@ -1006,33 +1033,33 @@ crop_start (Tool *tool, gtk_signal_handler_block_by_data (GTK_OBJECT (size_sizeentry), crop_info); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 0, - gdisp->gimage->xresolution, FALSE); + tool->gdisp->gimage->xresolution, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 1, - gdisp->gimage->yresolution, FALSE); + tool->gdisp->gimage->yresolution, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 0, - 0, gdisp->gimage->width); + 0, tool->gdisp->gimage->width); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 1, - 0, gdisp->gimage->height); + 0, tool->gdisp->gimage->height); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 0, - gdisp->gimage->xresolution, FALSE); + tool->gdisp->gimage->xresolution, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 1, - gdisp->gimage->yresolution, FALSE); + tool->gdisp->gimage->yresolution, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 0, - 0, gdisp->gimage->width); + 0, tool->gdisp->gimage->width); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 1, - 0, gdisp->gimage->height); + 0, tool->gdisp->gimage->height); - if (old_gdisp != gdisp) + if (old_gdisp != tool->gdisp) { gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry), - gdisp->gimage->unit) ; + tool->gdisp->gimage->unit) ; gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_sizeentry), - gdisp->gimage->unit); + tool->gdisp->gimage->unit); - if (gdisp->dot_for_dot) + if (tool->gdisp->dot_for_dot) { gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry), GIMP_UNIT_PIXEL); @@ -1044,15 +1071,16 @@ crop_start (Tool *tool, gtk_signal_handler_unblock_by_data (GTK_OBJECT (size_sizeentry), crop_info); gtk_signal_handler_unblock_by_data (GTK_OBJECT (origin_sizeentry), crop_info); - old_gdisp = gdisp; + old_gdisp = tool->gdisp; /* initialize the statusbar display */ crop->context_id = - gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "crop"); - gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), + gtk_statusbar_get_context_id (GTK_STATUSBAR (tool->gdisp->statusbar), + "crop"); + gtk_statusbar_push (GTK_STATUSBAR (tool->gdisp->statusbar), crop->context_id, _("Crop: 0 x 0")); - draw_core_start (crop->core, gdisp->canvas->window, tool); + draw_core_start (crop->core, tool->gdisp->canvas->window, tool); } @@ -1068,7 +1096,7 @@ crop_info_create (Tool *tool) GtkWidget *bbox; GtkWidget *button; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = (GDisplay *) tool->gdisp; /* create the info dialog */ crop_info = info_dialog_new (_("Crop & Resize Information"), @@ -1147,11 +1175,9 @@ crop_info_create (Tool *tool) static void crop_info_update (Tool *tool) { - Crop *crop; - GDisplay *gdisp; + Crop *crop; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; orig_vals[0] = crop->tx1; orig_vals[1] = crop->ty1; @@ -1166,15 +1192,13 @@ static void crop_crop_callback (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; + Tool *tool; + Crop *crop; tool = active_tool; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; - crop_image (gdisp->gimage, + crop_image (tool->gdisp->gimage, crop->tx1, crop->ty1, crop->tx2, crop->ty2, crop_options->layer_only, @@ -1188,15 +1212,13 @@ static void crop_resize_callback (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; + Tool *tool; + Crop *crop; tool = active_tool; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; - crop_image (gdisp->gimage, + crop_image (tool->gdisp->gimage, crop->tx1, crop->ty1, crop->tx2, crop->ty2, crop_options->layer_only, @@ -1221,9 +1243,9 @@ crop_close_callback (GtkWidget *widget, info_dialog_popdown (crop_info); - tool->gdisp_ptr = NULL; + tool->gdisp = NULL; tool->drawable = NULL; - tool->state = INACTIVE; + tool->state = INACTIVE; } static void @@ -1235,9 +1257,9 @@ crop_selection_callback (GtkWidget *widget, Layer *layer; GDisplay *gdisp; - tool = active_tool; - crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; + tool = active_tool; + crop = (Crop *) tool->private; + gdisp = tool->gdisp; draw_core_pause (crop->core, tool); if (! gimage_mask_bounds (gdisp->gimage, @@ -1266,24 +1288,24 @@ static void crop_automatic_callback (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; - GimpDrawable *active_drawable = NULL; - GetColorFunc get_color_func; - ColorsEqualFunc colors_equal_func; - GtkObject *get_color_obj; - guchar bgcolor[4] = {0, 0, 0, 0}; - gboolean has_alpha = FALSE; - PixelRegion PR; - guchar *buffer = NULL; - gint offset_x, offset_y, width, height, bytes; - gint x, y, abort; - gint x1, y1, x2, y2; + Tool *tool; + Crop *crop; + GDisplay *gdisp; + GimpDrawable *active_drawable = NULL; + GetColorFunc get_color_func; + ColorsEqualFunc colors_equal_func; + GtkObject *get_color_obj; + guchar bgcolor[4] = {0, 0, 0, 0}; + gboolean has_alpha = FALSE; + PixelRegion PR; + guchar *buffer = NULL; + gint offset_x, offset_y, width, height, bytes; + gint x, y, abort; + gint x1, y1, x2, y2; tool = active_tool; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; draw_core_pause (crop->core, tool); gimp_add_busy_cursors (); @@ -1516,18 +1538,17 @@ static void crop_orig_changed (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; - gint ox; - gint oy; + Tool *tool; + Crop *crop; + gint ox; + gint oy; tool = active_tool; if (tool && active_tool->type == CROP) { - gdisp = (GDisplay *) tool->gdisp_ptr; - crop = (Crop *) tool->private; + crop = (Crop *) tool->private; + ox = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); oy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); @@ -1549,18 +1570,17 @@ static void crop_size_changed (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; - gint sx; - gint sy; + Tool *tool; + Crop *crop; + gint sx; + gint sy; tool = active_tool; if (tool && active_tool->type == CROP) { - gdisp = (GDisplay *) tool->gdisp_ptr; - crop = (Crop *) tool->private; + crop = (Crop *) tool->private; + sx = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0); sy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1); diff --git a/app/tools/crop.h b/app/tools/crop.h index b698b95634..fe7d35d34d 100644 --- a/app/tools/crop.h +++ b/app/tools/crop.h @@ -29,17 +29,15 @@ typedef enum void crop_draw (Tool *tool); void crop_image (GimpImage *gimage, - gint, - gint, - gint, - gint, - gint, - gint); + gint x1, + gint y1, + gint x2, + gint y2, + gboolean layer_only, + gboolean crop_layers); Tool * tools_new_crop (void); void tools_free_crop (Tool *tool); #endif /* __CROP_H__ */ - - diff --git a/app/tools/curves.c b/app/tools/curves.c index 7ba6f1ab76..fe3a945fc7 100644 --- a/app/tools/curves.c +++ b/app/tools/curves.c @@ -108,40 +108,72 @@ static CRMatrix CR_basis = /* curves action functions */ -static void curves_button_press (Tool *, GdkEventButton *, gpointer); -static void curves_button_release (Tool *, GdkEventButton *, gpointer); -static void curves_motion (Tool *, GdkEventMotion *, gpointer); -static void curves_control (Tool *, ToolAction, gpointer); +static void curves_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void curves_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void curves_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void curves_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); -static CurvesDialog * curves_dialog_new (void); +static CurvesDialog * curves_dialog_new (void); -static void curves_update (CurvesDialog *, int); -static void curves_plot_curve (CurvesDialog *, int, int, int, int); -static void curves_preview (CurvesDialog *); +static void curves_update (CurvesDialog *cd, + gint ); +static void curves_plot_curve (CurvesDialog *cd, + gint , + gint , + gint , + gint ); +static void curves_preview (CurvesDialog *cd); -static void curves_channel_callback (GtkWidget *, gpointer); +static void curves_channel_callback (GtkWidget *widget, + gpointer data); -static void curves_smooth_callback (GtkWidget *, gpointer); -static void curves_free_callback (GtkWidget *, gpointer); +static void curves_smooth_callback (GtkWidget *widget, + gpointer data); +static void curves_free_callback (GtkWidget *widget, + gpointer data); -static void curves_channel_reset (int); -static void curves_reset_callback (GtkWidget *, gpointer); -static void curves_ok_callback (GtkWidget *, gpointer); -static void curves_cancel_callback (GtkWidget *, gpointer); -static void curves_load_callback (GtkWidget *, gpointer); -static void curves_save_callback (GtkWidget *, gpointer); -static void curves_preview_update (GtkWidget *, gpointer); -static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static gint curves_graph_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static void curves_CR_compose (CRMatrix, CRMatrix, CRMatrix); +static void curves_channel_reset (gint ); +static void curves_reset_callback (GtkWidget *widget, + gpointer data); +static void curves_ok_callback (GtkWidget *widget, + gpointer data); +static void curves_cancel_callback (GtkWidget *widget, + gpointer data); +static void curves_load_callback (GtkWidget *widget, + gpointer data); +static void curves_save_callback (GtkWidget *widget, + gpointer data); +static void curves_preview_update (GtkWidget *widget, + gpointer data); +static gint curves_xrange_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static gint curves_yrange_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static gint curves_graph_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static void curves_CR_compose (CRMatrix , + CRMatrix , + CRMatrix ); -static void file_dialog_create (GtkWidget *); -static void file_dialog_ok_callback (GtkWidget *, gpointer); -static void file_dialog_cancel_callback (GtkWidget *, gpointer); +static void file_dialog_create (GtkWidget *widget); +static void file_dialog_ok_callback (GtkWidget *widget, + gpointer data); +static void file_dialog_cancel_callback (GtkWidget *widget, + gpointer data); -static gboolean curves_read_from_file (FILE *f); -static void curves_write_to_file (FILE *f); +static gboolean curves_read_from_file (FILE *f); +static void curves_write_to_file (FILE *f); /* curves machinery */ @@ -152,10 +184,10 @@ curves_lut_func (CurvesDialog *cd, gint channel, gfloat value) { - gfloat f; - gint index; + gfloat f; + gint index; gdouble inten; - gint j; + gint j; if (nchannels == 1) j = 0; @@ -197,15 +229,15 @@ curves_colour_update (Tool *tool, gint x, gint y) { - guchar *color; - gint offx; - gint offy; - gint maxval; + guchar *color; + gint offx; + gint offy; + gint maxval; gboolean has_alpha; gboolean is_indexed; GimpImageType sample_type; - if(!tool || tool->state != ACTIVE) + if (!tool || tool->state != ACTIVE) return; drawable_offsets (drawable, &offx, &offy); @@ -213,7 +245,7 @@ curves_colour_update (Tool *tool, x -= offx; y -= offy; - if (!(color = image_map_get_color_at(curves_dialog->image_map, x, y))) + if (!(color = image_map_get_color_at (curves_dialog->image_map, x, y))) return; sample_type = gimp_drawable_type (drawable); @@ -283,16 +315,14 @@ curves_add_point (GimpDrawable *drawable, static void curves_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; - GDisplay *gdisp; + gint x, y; GimpDrawable *drawable; - gdisp = gdisp_ptr; drawable = gimp_image_active_drawable (gdisp->gimage); - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; if (drawable != tool->drawable) { @@ -318,20 +348,18 @@ curves_button_press (Tool *tool, static void curves_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; + gint x, y; GimpDrawable *drawable; - GDisplay *gdisp; - gdisp = (GDisplay *) gdisp_ptr; - - if(!curves_dialog || - !gdisp || - !(drawable = gimp_image_active_drawable (gdisp->gimage))) + if (! curves_dialog || + ! gdisp || + ! (drawable = gimp_image_active_drawable (gdisp->gimage))) return; - gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE); + gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, + FALSE, FALSE); curves_colour_update (tool, gdisp, drawable, x, y); if (bevent->state & GDK_SHIFT_MASK) @@ -355,14 +383,11 @@ curves_button_release (Tool *tool, static void curves_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; - GDisplay *gdisp; + gint x, y; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; - if (! curves_dialog || ! gdisp || ! (drawable = gimp_image_active_drawable (gdisp->gimage))) @@ -376,7 +401,7 @@ curves_motion (Tool *tool, static void curves_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -1279,7 +1304,7 @@ curves_ok_callback (GtkWidget *widget, cd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -1303,7 +1328,7 @@ curves_cancel_callback (GtkWidget *widget, cd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/dodgeburn.c b/app/tools/dodgeburn.c index 8ffe8968ce..396945d3b3 100644 --- a/app/tools/dodgeburn.c +++ b/app/tools/dodgeburn.c @@ -44,6 +44,12 @@ #include "libgimp/gimpintl.h" +/* Default values */ + +#define DODGEBURN_DEFAULT_TYPE DODGE +#define DODGEBURN_DEFAULT_EXPOSURE 50.0 +#define DODGEBURN_DEFAULT_MODE DODGEBURN_HIGHLIGHTS + /* the dodgeburn structures */ typedef struct _DodgeBurnOptions DodgeBurnOptions; @@ -67,36 +73,49 @@ struct _DodgeBurnOptions GimpLut *lut; }; -static void -dodgeburn_make_luts (PaintCore *, double, DodgeBurnType, DodgeBurnMode, - GimpLut *, GimpDrawable *); -static gfloat dodgeburn_highlights_lut_func (void *, int, int, gfloat); -static gfloat dodgeburn_midtones_lut_func (void *, int, int, gfloat); -static gfloat dodgeburn_shadows_lut_func (void *, int, int, gfloat); +static gpointer dodgeburn_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + +static void dodgeburn_make_luts (PaintCore *paint_cure, + gdouble db_exposure, + DodgeBurnType type, + DodgeBurnMode mode, + GimpLut *lut, + GimpDrawable *drawable); + +static gfloat dodgeburn_highlights_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); +static gfloat dodgeburn_midtones_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); +static gfloat dodgeburn_shadows_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); + +static void dodgeburn_motion (PaintCore *paint_core, + PaintPressureOptions *pressure_options, + gdouble dodgeburn_exposure, + GimpLut *lut, + GimpDrawable *drawable); +static void dodgeburn_init (PaintCore *paint_cure, + GimpDrawable *drawable); +static void dodgeburn_finish (PaintCore *paint_core, + GimpDrawable *drawable); -/* The dodge burn lookup tables */ -gfloat dodgeburn_highlights (void *, int, int, gfloat); -gfloat dodgeburn_midtones (void *, int, int, gfloat); -gfloat dodgeburn_shadows (void *, int, int, gfloat); /* the dodgeburn tool options */ static DodgeBurnOptions * dodgeburn_options = NULL; /* Non gui function */ -static double non_gui_exposure; +static gdouble non_gui_exposure; static GimpLut *non_gui_lut; -/* Default values */ -#define DODGEBURN_DEFAULT_TYPE DODGE -#define DODGEBURN_DEFAULT_EXPOSURE 50.0 -#define DODGEBURN_DEFAULT_MODE DODGEBURN_HIGHLIGHTS - -static void dodgeburn_motion (PaintCore *, - PaintPressureOptions *, - double, GimpLut *, GimpDrawable *); -static void dodgeburn_init (PaintCore *, GimpDrawable *); -static void dodgeburn_finish (PaintCore *, GimpDrawable *); /* functions */ @@ -198,24 +217,29 @@ dodgeburn_options_new (void) return options; } -void * +static gpointer dodgeburn_paint_func (PaintCore *paint_core, - GimpDrawable *drawable, - int state) + GimpDrawable *drawable, + PaintState state) { switch (state) { case INIT_PAINT: dodgeburn_init (paint_core, drawable); break; + case MOTION_PAINT: dodgeburn_motion (paint_core, dodgeburn_options->paint_options.pressure_options, dodgeburn_options->exposure, dodgeburn_options->lut, drawable); break; + case FINISH_PAINT: dodgeburn_finish (paint_core, drawable); break; + + default: + break; } return NULL; @@ -238,7 +262,8 @@ dodgeburn_init (PaintCore *paint_core, GimpDrawable *drawable) { /* Here we create the luts to do the painting with.*/ - dodgeburn_options->lut = gimp_lut_new(); + dodgeburn_options->lut = gimp_lut_new (); + dodgeburn_make_luts (paint_core, dodgeburn_options->exposure, dodgeburn_options->type, @@ -249,17 +274,17 @@ dodgeburn_init (PaintCore *paint_core, static void dodgeburn_make_luts (PaintCore *paint_core, - double db_exposure, + gdouble db_exposure, DodgeBurnType type, DodgeBurnMode mode, GimpLut *lut, GimpDrawable *drawable) { - GimpLutFunc lut_func; - int nchannels = gimp_drawable_bytes (drawable); + GimpLutFunc lut_func; + gint nchannels = gimp_drawable_bytes (drawable); static gfloat exposure; - exposure = (db_exposure) / 100.0; + exposure = db_exposure / 100.0; /* make the exposure negative if burn for luts*/ if (type == BURN) @@ -281,15 +306,15 @@ dodgeburn_make_luts (PaintCore *paint_core, break; } - gimp_lut_setup_exact (lut, - lut_func, (void *)&exposure, - nchannels); + gimp_lut_setup_exact (lut, + lut_func, (gpointer) &exposure, + nchannels); } static void dodgeburn_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -317,7 +342,7 @@ dodgeburn_modifier_key_func (Tool *tool, break; case GDK_Control_L: case GDK_Control_R: - if ( !(kevent->state & GDK_SHIFT_MASK) ) /* shift enables line draw mode */ + if (! (kevent->state & GDK_SHIFT_MASK)) /* shift enables line draw mode */ { switch (dodgeburn_options->type) { @@ -342,18 +367,18 @@ dodgeburn_modifier_key_func (Tool *tool, static void dodgeburn_cursor_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->toggled = (dodgeburn_options->type == BURN); - paint_core_cursor_update (tool, mevent, gdisp_ptr); + paint_core_cursor_update (tool, mevent, gdisp); } Tool * tools_new_dodgeburn (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! dodgeburn_options) @@ -420,25 +445,26 @@ dodgeburn_motion (PaintCore *paint_core, no paint from this stroke yet) */ { - gint x1, y1, x2, y2; - x1 = CLAMP (area->x, 0, drawable_width (drawable)); - y1 = CLAMP (area->y, 0, drawable_height (drawable)); - x2 = CLAMP (area->x + area->width, 0, drawable_width (drawable)); - y2 = CLAMP (area->y + area->height, 0, drawable_height (drawable)); + gint x1, y1, x2, y2; - if (!(x2 - x1) || !(y2 - y1)) - return; + x1 = CLAMP (area->x, 0, drawable_width (drawable)); + y1 = CLAMP (area->y, 0, drawable_height (drawable)); + x2 = CLAMP (area->x + area->width, 0, drawable_width (drawable)); + y2 = CLAMP (area->y + area->height, 0, drawable_height (drawable)); - /* get the original untouched image */ - orig = paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2); - srcPR.bytes = orig->bytes; - srcPR.x = 0; - srcPR.y = 0; - srcPR.w = x2 - x1; - srcPR.h = y2 - y1; - srcPR.rowstride = srcPR.bytes * orig->width; - srcPR.data = temp_buf_data (orig); - } + if (!(x2 - x1) || !(y2 - y1)) + return; + + /* get the original untouched image */ + orig = paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2); + srcPR.bytes = orig->bytes; + srcPR.x = 0; + srcPR.y = 0; + srcPR.w = x2 - x1; + srcPR.h = y2 - y1; + srcPR.rowstride = srcPR.bytes * orig->width; + srcPR.data = temp_buf_data (orig); + } /* tempPR will hold the dodgeburned region*/ tempPR.bytes = srcPR.bytes; @@ -482,10 +508,10 @@ dodgeburn_motion (PaintCore *paint_core, g_free (temp_data); } -static void * +static gpointer dodgeburn_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { dodgeburn_motion (paint_core, &non_gui_pressure_options, non_gui_exposure, non_gui_lut, drawable); @@ -495,13 +521,13 @@ dodgeburn_non_gui_paint_func (PaintCore *paint_core, gboolean dodgeburn_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - double exposure = DODGEBURN_DEFAULT_TYPE; - DodgeBurnType type = DODGEBURN_DEFAULT_TYPE; - DodgeBurnMode mode = DODGEBURN_DEFAULT_MODE; - DodgeBurnOptions *options = dodgeburn_options; + gdouble exposure = DODGEBURN_DEFAULT_TYPE; + DodgeBurnType type = DODGEBURN_DEFAULT_TYPE; + DodgeBurnMode mode = DODGEBURN_DEFAULT_MODE; + DodgeBurnOptions *options = dodgeburn_options; if (options) { @@ -510,18 +536,19 @@ dodgeburn_non_gui_default (GimpDrawable *drawable, mode = dodgeburn_options->mode; } - return dodgeburn_non_gui (drawable, exposure, type, mode, num_strokes, stroke_array); + return dodgeburn_non_gui (drawable, exposure, type, mode, + num_strokes, stroke_array); } gboolean dodgeburn_non_gui (GimpDrawable *drawable, - double exposure, + gdouble exposure, DodgeBurnType type, DodgeBurnMode mode, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -569,15 +596,15 @@ dodgeburn_non_gui (GimpDrawable *drawable, } static gfloat -dodgeburn_highlights_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_highlights_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat factor = 1.0 + exposure * (.333333); - + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat factor = 1.0 + exposure * (.333333); + if ((nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) return value; @@ -586,14 +613,14 @@ dodgeburn_highlights_lut_func (void *user_data, } static gfloat -dodgeburn_midtones_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_midtones_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat factor; + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat factor; if ((nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) @@ -603,19 +630,20 @@ dodgeburn_midtones_lut_func (void *user_data, factor = 1.0 - exposure * (.333333); else factor = 1/(1.0 + exposure); + return pow (value, factor); } static gfloat -dodgeburn_shadows_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_shadows_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat new_value; - gfloat factor; + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat new_value; + gfloat factor; if ( (nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) diff --git a/app/tools/dodgeburn.h b/app/tools/dodgeburn.h index 341fe445ea..edd02ba64d 100644 --- a/app/tools/dodgeburn.h +++ b/app/tools/dodgeburn.h @@ -34,21 +34,18 @@ typedef enum } DodgeBurnMode; -void * dodgeburn_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean dodgeburn_non_gui (GimpDrawable *, - gdouble, - DodgeBurnType, - DodgeBurnMode, - gint, - gdouble *); -gboolean dodgeburn_non_gui_default (GimpDrawable *, - gint, - gdouble *); +gboolean dodgeburn_non_gui (GimpDrawable *drawable, + gdouble exposure, + DodgeBurnType type, + DodgeBurnMode mode, + gint num_strokes, + gdouble *stroke_array); +gboolean dodgeburn_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_dodgeburn (void); -void tools_free_dodgeburn (Tool *); +void tools_free_dodgeburn (Tool *tool); #endif /* __DODGEBURN_H__ */ diff --git a/app/tools/edit_selection.c b/app/tools/edit_selection.c index ab759aa00c..dd68019c65 100644 --- a/app/tools/edit_selection.c +++ b/app/tools/edit_selection.c @@ -127,15 +127,12 @@ edit_selection_snap (GDisplay *gdisp, void init_edit_selection (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, GdkEventButton *bevent, EditType edit_type) { - GDisplay *gdisp; Layer *layer; - gint x, y; - - gdisp = (GDisplay *) gdisp_ptr; + gint x, y; undo_push_group_start (gdisp->gimage, LAYER_DISPLACE_UNDO); @@ -218,15 +215,12 @@ init_edit_selection (Tool *tool, void edit_selection_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { gint x; gint y; - GDisplay *gdisp; Layer *layer; - gdisp = (GDisplay *) gdisp_ptr; - /* resume the current selection and ungrab the pointer */ selection_resume (gdisp->select); @@ -312,11 +306,10 @@ edit_selection_button_release (Tool *tool, void edit_selection_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - gchar offset[STATUSBAR_SIZE]; - gdouble lastmotion_x, lastmotion_y; + gchar offset[STATUSBAR_SIZE]; + gdouble lastmotion_x, lastmotion_y; if (tool->state != ACTIVE) { @@ -324,8 +317,6 @@ edit_selection_motion (Tool *tool, return; } - gdisp = (GDisplay *) gdisp_ptr; - gdk_flush (); draw_core_pause (edit_select.core, tool); @@ -521,7 +512,7 @@ edit_selection_draw (Tool *tool) gint off_x, off_y; GdkSegment *segs_copy; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; select = gdisp->select; switch (edit_select.edit_type) @@ -637,7 +628,7 @@ edit_selection_draw (Tool *tool) void edit_selection_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -663,11 +654,8 @@ edit_selection_control (Tool *tool, void edit_selection_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - - gdisp = (GDisplay *) gdisp_ptr; gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_CURSOR, TOOL_TYPE_NONE, CURSOR_MODIFIER_MOVE, @@ -770,10 +758,9 @@ process_event_queue_keys (GdkEventKey *kevent, void edit_sel_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { gint inc_x, inc_y, mask_inc_x, mask_inc_y; - GDisplay *gdisp; Layer *layer; Layer *floating_layer; GSList *layer_list; @@ -781,8 +768,6 @@ edit_sel_arrow_keys_func (Tool *tool, layer = NULL; - gdisp = (GDisplay *) gdisp_ptr; - inc_x = process_event_queue_keys (kevent, GDK_Left, 0, -1, diff --git a/app/tools/edit_selection.h b/app/tools/edit_selection.h index c1e8914d71..1486849289 100644 --- a/app/tools/edit_selection.h +++ b/app/tools/edit_selection.h @@ -30,26 +30,26 @@ typedef enum void init_edit_selection (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, GdkEventButton *bevent, EditType edit_type); -void edit_selection_button_release (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -void edit_selection_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); -void edit_selection_control (Tool *tool, - ToolAction action, - gpointer gdisp_ptr); -void edit_selection_cursor_update (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); +void edit_selection_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void edit_selection_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +void edit_selection_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); +void edit_selection_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); void edit_selection_draw (Tool *tool); void edit_sel_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr); + GDisplay *gdisp); #endif /* __EDIT_SELECTION_H__ */ diff --git a/app/tools/ellipse_select.c b/app/tools/ellipse_select.c index b65dd27a06..a4235d237a 100644 --- a/app/tools/ellipse_select.c +++ b/app/tools/ellipse_select.c @@ -93,12 +93,10 @@ ellipse_select (GimpImage *gimage, void ellipse_select_draw (Tool *tool) { - GDisplay *gdisp; EllipseSelect *ellipse_sel; gint x1, y1; gint x2, y2; - gdisp = (GDisplay *) tool->gdisp_ptr; ellipse_sel = (EllipseSelect *) tool->private; x1 = MIN (ellipse_sel->x, ellipse_sel->x + ellipse_sel->w); @@ -106,8 +104,8 @@ ellipse_select_draw (Tool *tool) x2 = MAX (ellipse_sel->x, ellipse_sel->x + ellipse_sel->w); y2 = MAX (ellipse_sel->y, ellipse_sel->y + ellipse_sel->h); - gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); - gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); + gdisplay_transform_coords (tool->gdisp, x1, y1, &x1, &y1, 0); + gdisplay_transform_coords (tool->gdisp, x2, y2, &x2, &y2, 0); gdk_draw_arc (ellipse_sel->core->win, ellipse_sel->core->gc, 0, diff --git a/app/tools/eraser.c b/app/tools/eraser.c index 1ffa616c08..5467be7ede 100644 --- a/app/tools/eraser.c +++ b/app/tools/eraser.c @@ -42,7 +42,7 @@ #include "libgimp/gimpintl.h" -/* Defaults */ +/* Defaults */ #define ERASER_DEFAULT_HARD FALSE #define ERASER_DEFAULT_INCREMENTAL FALSE #define ERASER_DEFAULT_ANTI_ERASE FALSE @@ -50,6 +50,7 @@ /* the eraser structures */ typedef struct _EraserOptions EraserOptions; + struct _EraserOptions { PaintOptions paint_options; @@ -64,6 +65,18 @@ struct _EraserOptions }; +/* forward function declarations */ +static gpointer eraser_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void eraser_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + gboolean hard, + gboolean incremental, + gboolean anti_erase); + + /* the eraser tool options */ static EraserOptions *eraser_options = NULL; @@ -72,11 +85,6 @@ static gboolean non_gui_hard; static gboolean non_gui_incremental; static gboolean non_gui_anti_erase; -/* forward function declarations */ -static void eraser_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, - gboolean, gboolean, gboolean); - /* functions */ @@ -137,7 +145,7 @@ eraser_options_new (void) static void eraser_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -164,10 +172,10 @@ eraser_modifier_key_func (Tool *tool, } -void * +static gpointer eraser_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -196,8 +204,8 @@ eraser_paint_func (PaintCore *paint_core, Tool * tools_new_eraser (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! eraser_options) @@ -274,10 +282,10 @@ eraser_motion (PaintCore *paint_core, } -static void * +static gpointer eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { eraser_motion (paint_core, drawable, &non_gui_pressure_options, @@ -288,8 +296,8 @@ eraser_non_gui_paint_func (PaintCore *paint_core, gboolean eraser_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gboolean hardness = ERASER_DEFAULT_HARD; gboolean method = ERASER_DEFAULT_INCREMENTAL; @@ -310,13 +318,13 @@ eraser_non_gui_default (GimpDrawable *drawable, gboolean eraser_non_gui (GimpDrawable *drawable, - int num_strokes, - double *stroke_array, - int hardness, - int method, - int anti_erase) + gint num_strokes, + gdouble *stroke_array, + gint hardness, + gint method, + gboolean anti_erase) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -351,6 +359,6 @@ eraser_non_gui (GimpDrawable *drawable, paint_core_cleanup (); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/tools/eraser.h b/app/tools/eraser.h index 5a94a4c044..35eb35d4e2 100644 --- a/app/tools/eraser.h +++ b/app/tools/eraser.h @@ -20,21 +20,18 @@ #define __ERASER_H__ -void * eraser_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean eraser_non_gui (GimpDrawable *, - gint , - gdouble *, - gint , - gint , - gint ); -gboolean eraser_non_gui_default (GimpDrawable *, - gint , - gdouble *); +gboolean eraser_non_gui (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array, + gint hardness, + gint method, + gboolean anti_erase); +gboolean eraser_non_gui_default (GimpDrawable *paint_core, + gint num_strokes, + gdouble *stroke_array); -Tool * tools_new_eraser (void ); -void tools_free_eraser (Tool *); +Tool * tools_new_eraser (void); +void tools_free_eraser (Tool *tool); #endif /* __ERASER_H__ */ diff --git a/app/tools/flip_tool.c b/app/tools/flip_tool.c index c6db3abda3..b3ff8eba49 100644 --- a/app/tools/flip_tool.c +++ b/app/tools/flip_tool.c @@ -61,6 +61,16 @@ struct _FlipOptions GtkWidget *type_w[2]; }; + +/* local function prototypes */ + +static TileManager * flip_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + + +/* private variables */ + static FlipOptions *flip_options = NULL; /* functions */ @@ -117,7 +127,7 @@ flip_options_new (void) static void flip_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -139,17 +149,15 @@ flip_modifier_key_func (Tool *tool, break; } } - -TileManager * + +static TileManager * flip_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { TransformCore *transform_core; - GDisplay *gdisp; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (state) { @@ -179,14 +187,11 @@ flip_tool_transform (Tool *tool, static void flip_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; GimpDrawable *drawable; GdkCursorType ctype = GIMP_BAD_CURSOR; - gdisp = (GDisplay *) gdisp_ptr; - if ((drawable = gimp_image_active_drawable (gdisp->gimage))) { gint x, y; @@ -231,10 +236,10 @@ tools_new_flip (void) tools_register (FLIP, (ToolOptions *) flip_options); } - tool = transform_core_new (FLIP, FALSE); + tool = transform_core_new (FLIP, FALSE); private = tool->private; - private->trans_func = flip_tool_transform; + private->trans_func = flip_tool_transform; private->trans_info[FLIP_INFO] = -1.0; tool->modifier_key_func = flip_modifier_key_func; diff --git a/app/tools/flip_tool.h b/app/tools/flip_tool.h index 0f74a6bb3b..b0d3fe71c0 100644 --- a/app/tools/flip_tool.h +++ b/app/tools/flip_tool.h @@ -20,10 +20,6 @@ #define __FLIP_TOOL_H__ -TileManager * flip_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); - TileManager * flip_tool_flip (GimpImage *gimage, GimpDrawable *drawable, TileManager *orig, diff --git a/app/tools/free_select.c b/app/tools/free_select.c index fb7de4eb17..911826a8b6 100644 --- a/app/tools/free_select.c +++ b/app/tools/free_select.c @@ -51,6 +51,7 @@ /* the free selection structures */ typedef struct _FreeSelect FreeSelect; + struct _FreeSelect { DrawCore *core; /* Core select object */ @@ -65,6 +66,18 @@ struct _FreeSelect }; +/* local function prototypes */ + +static void free_select_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void free_select_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void free_select_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); + /* the free selection tool options */ static SelectionOptions * free_options = NULL; @@ -157,15 +170,13 @@ free_select (GImage *gimage, } } -void +static void free_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; FreeSelect *free_sel; - gdisp = (GDisplay *) gdisp_ptr; free_sel = (FreeSelect *) tool->private; gdk_pointer_grab (gdisp->canvas->window, FALSE, @@ -175,15 +186,15 @@ free_select_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; switch (free_sel->op) { case SELECTION_MOVE_MASK: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; case SELECTION_MOVE: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; default: break; @@ -197,17 +208,15 @@ free_select_button_press (Tool *tool, tool); } -void +static void free_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FreeSelect *free_sel; ScanConvertPoint *pts; - GDisplay *gdisp; gint i; - gdisp = (GDisplay *) gdisp_ptr; free_sel = (FreeSelect *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -251,15 +260,13 @@ free_select_button_release (Tool *tool, } } -void +static void free_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FreeSelect *free_sel; - GDisplay *gdisp; - gdisp = (GDisplay *) gdisp_ptr; free_sel = (FreeSelect *) tool->private; /* needed for immediate cursor update on modifier event */ @@ -273,7 +280,7 @@ free_select_motion (Tool *tool, { free_sel->op = SELECTION_REPLACE; - rect_select_cursor_update (tool, mevent, gdisp_ptr); + rect_select_cursor_update (tool, mevent, gdisp); } if (add_point (free_sel->num_pts, mevent->x, mevent->y)) @@ -291,7 +298,7 @@ free_select_motion (Tool *tool, static void free_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { FreeSelect *free_sel; diff --git a/app/tools/free_select.h b/app/tools/free_select.h index 98fd07dfd1..11b148c231 100644 --- a/app/tools/free_select.h +++ b/app/tools/free_select.h @@ -20,19 +20,6 @@ #define __FREE_SELECT_H__ -/* free select action functions */ - -void free_select_button_press (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -void free_select_button_release (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -void free_select_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); - - /* free select functions */ void free_select (GimpImage *gimage, diff --git a/app/tools/fuzzy_select.c b/app/tools/fuzzy_select.c index 906acff785..8180462164 100644 --- a/app/tools/fuzzy_select.c +++ b/app/tools/fuzzy_select.c @@ -71,6 +71,27 @@ struct _FuzzySelect }; +/* fuzzy select action functions */ +static void fuzzy_select_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void fuzzy_select_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void fuzzy_select_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void fuzzy_select_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void fuzzy_select_draw (Tool *tool); + +static GdkSegment * fuzzy_select_calculate (Tool *tool, + GDisplay *gdisp, + gint *nsegs); + + /* the fuzzy selection tool options */ static SelectionOptions *fuzzy_options = NULL; @@ -81,18 +102,6 @@ static gint num_segs = 0; Channel * fuzzy_mask = NULL; -/* fuzzy select action functions */ -static void fuzzy_select_button_press (Tool *, GdkEventButton *, gpointer); -static void fuzzy_select_button_release (Tool *, GdkEventButton *, gpointer); -static void fuzzy_select_motion (Tool *, GdkEventMotion *, gpointer); -static void fuzzy_select_control (Tool *, ToolAction, gpointer); - -static void fuzzy_select_draw (Tool *); - -/* fuzzy select action functions */ -static GdkSegment * fuzzy_select_calculate (Tool *, void *, int *); - - /*************************************/ /* Fuzzy selection apparatus */ @@ -390,12 +399,10 @@ fuzzy_select (GImage *gimage, static void fuzzy_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; FuzzySelect *fuzzy_sel; - gdisp = (GDisplay *) gdisp_ptr; fuzzy_sel = (FuzzySelect *) tool->private; fuzzy_sel->x = bevent->x; @@ -411,21 +418,21 @@ fuzzy_select_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; if (fuzzy_sel->op == SELECTION_MOVE_MASK) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; } else if (fuzzy_sel->op == SELECTION_MOVE) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; } /* calculate the region boundary */ - segs = fuzzy_select_calculate (tool, gdisp_ptr, &num_segs); + segs = fuzzy_select_calculate (tool, gdisp, &num_segs); draw_core_start (fuzzy_sel->core, gdisp->canvas->window, @@ -435,13 +442,11 @@ fuzzy_select_button_press (Tool *tool, static void fuzzy_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; - GDisplay *gdisp; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; fuzzy_sel = (FuzzySelect *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -471,13 +476,13 @@ fuzzy_select_button_release (Tool *tool, static void fuzzy_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; GdkSegment *new_segs; - gint num_new_segs; - gint diff_x, diff_y; - gdouble diff; + gint num_new_segs; + gint diff_x, diff_y; + gdouble diff; static guint last_time = 0; @@ -505,7 +510,7 @@ fuzzy_select_motion (Tool *tool, fuzzy_sel->first_threshold + diff); /* calculate the new fuzzy boundary */ - new_segs = fuzzy_select_calculate (tool, gdisp_ptr, &num_new_segs); + new_segs = fuzzy_select_calculate (tool, gdisp, &num_new_segs); /* stop the current boundary */ draw_core_pause (fuzzy_sel->core, tool); @@ -522,24 +527,22 @@ fuzzy_select_motion (Tool *tool, static GdkSegment * -fuzzy_select_calculate (Tool *tool, - void *gdisp_ptr, - gint *nsegs) +fuzzy_select_calculate (Tool *tool, + GDisplay *gdisp, + gint *nsegs) { PixelRegion maskPR; FuzzySelect *fuzzy_sel; - GDisplay *gdisp; Channel *new; GdkSegment *segs; BoundSeg *bsegs; GimpDrawable *drawable; - gint i; - gint x, y; - gboolean use_offsets; + gint i; + gint x, y; + gboolean use_offsets; fuzzy_sel = (FuzzySelect *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; - drawable = gimp_image_active_drawable (gdisp->gimage); + drawable = gimp_image_active_drawable (gdisp->gimage); gimp_add_busy_cursors (); @@ -605,7 +608,7 @@ fuzzy_select_draw (Tool *tool) static void fuzzy_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; diff --git a/app/tools/fuzzy_select.h b/app/tools/fuzzy_select.h index 0211a4b81f..42533a19db 100644 --- a/app/tools/fuzzy_select.h +++ b/app/tools/fuzzy_select.h @@ -20,14 +20,6 @@ #define __FUZZY_SELECT_H__ -extern Channel *fuzzy_mask; - - -/* fuzzy select functions */ -Tool * tools_new_fuzzy_select (void); -void tools_free_fuzzy_select (Tool *tool); - -/* functions */ Channel * find_contiguous_region (GimpImage *gimage, GimpDrawable *drawable, gboolean antialias, @@ -41,5 +33,11 @@ void fuzzy_select (GimpImage *gimage, gboolean feather, gdouble feather_radius); +Tool * tools_new_fuzzy_select (void); +void tools_free_fuzzy_select (Tool *tool); + + +extern Channel *fuzzy_mask; + #endif /* __FUZZY_SELECT_H__ */ diff --git a/app/tools/gimpairbrushtool.c b/app/tools/gimpairbrushtool.c index 29ad1d4f90..0289996769 100644 --- a/app/tools/gimpairbrushtool.c +++ b/app/tools/gimpairbrushtool.c @@ -77,6 +77,16 @@ struct _AirbrushOptions }; +/* local function prototypes */ + +static gpointer airbrush_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static gpointer airbrush_non_gui_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + + /* the airbrush tool options */ static AirbrushOptions *airbrush_options = NULL; @@ -189,13 +199,13 @@ tools_new_airbrush (void) return tool; } -void * +static gpointer airbrush_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { GimpBrush *brush; - gdouble rate; + gdouble rate; if (!drawable) return NULL; @@ -357,10 +367,10 @@ airbrush_motion (PaintCore *paint_core, SOFT, scale, mode); } -static void * +static gpointer airbrush_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { airbrush_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_pressure, non_gui_incremental); @@ -370,8 +380,8 @@ airbrush_non_gui_paint_func (PaintCore *paint_core, gboolean airbrush_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { AirbrushOptions *options = airbrush_options; gdouble pressure = AIRBRUSH_PRESSURE_DEFAULT; @@ -384,11 +394,11 @@ airbrush_non_gui_default (GimpDrawable *drawable, gboolean airbrush_non_gui (GimpDrawable *drawable, - double pressure, - int num_strokes, - double *stroke_array) + gdouble pressure, + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -419,8 +429,9 @@ airbrush_non_gui (GimpDrawable *drawable, /* Cleanup */ paint_core_cleanup (); + return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/tools/gimpairbrushtool.h b/app/tools/gimpairbrushtool.h index ea4e64954b..6eb5528f0f 100644 --- a/app/tools/gimpairbrushtool.h +++ b/app/tools/gimpairbrushtool.h @@ -20,18 +20,16 @@ #define __AIRBRUSH_H__ -void * airbrush_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean airbrush_non_gui (GimpDrawable *, - gdouble, - gint, - gdouble *); -gboolean airbrush_non_gui_default (GimpDrawable *, - gint, - gdouble *); +gboolean airbrush_non_gui (GimpDrawable *drawable, + gdouble pressure, + gint num_strokes, + gdouble *stroke_array); +gboolean airbrush_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); + Tool * tools_new_airbrush (void); -void tools_free_airbrush (Tool *); +void tools_free_airbrush (Tool *tool); #endif /* __AIRBRUSH_H__ */ diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c index ebb5915c43..7826c7681f 100644 --- a/app/tools/gimpblendtool.c +++ b/app/tools/gimpblendtool.c @@ -162,13 +162,24 @@ static guint blend_n_targets = (sizeof (blend_target_table) / /* local function prototypes */ -static void gradient_type_callback (GtkWidget *, gpointer); +static void gradient_type_callback (GtkWidget *widget, + gpointer data); -static void blend_button_press (Tool *, GdkEventButton *, gpointer); -static void blend_button_release (Tool *, GdkEventButton *, gpointer); -static void blend_motion (Tool *, GdkEventMotion *, gpointer); -static void blend_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void blend_control (Tool *, ToolAction, gpointer); +static void blend_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void blend_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void blend_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void blend_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void blend_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static void blend_options_drop_gradient (GtkWidget *, gradient_t *, gpointer); static void blend_options_drop_tool (GtkWidget *, ToolType, gpointer); @@ -432,12 +443,10 @@ blend_options_new (void) static void blend_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BlendTool * blend_tool; + BlendTool *blend_tool; - gdisp = (GDisplay *) gdisp_ptr; blend_tool = (BlendTool *) tool->private; switch (drawable_type (gimp_image_active_drawable (gdisp->gimage))) @@ -463,7 +472,7 @@ blend_button_press (Tool *tool, GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; /* initialize the statusbar display */ @@ -477,19 +486,17 @@ blend_button_press (Tool *tool, static void blend_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - GImage * gimage; - BlendTool * blend_tool; + GImage *gimage; + BlendTool *blend_tool; #ifdef BLEND_UI_CALLS_VIA_PDB - Argument *return_vals; + Argument *return_vals; int nreturn_vals; #else gimp_progress *progress; #endif - gdisp = (GDisplay *) gdisp_ptr; gimage = gdisp->gimage; blend_tool = (BlendTool *) tool->private; @@ -568,13 +575,11 @@ blend_button_release (Tool *tool, static void blend_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BlendTool * blend_tool; - gchar vector[STATUSBAR_SIZE]; + BlendTool *blend_tool; + gchar vector[STATUSBAR_SIZE]; - gdisp = (GDisplay *) gdisp_ptr; blend_tool = (BlendTool *) tool->private; /* undraw the current tool */ @@ -642,12 +647,8 @@ blend_motion (Tool *tool, static void blend_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - - gdisp = (GDisplay *) gdisp_ptr; - switch (drawable_type (gimp_image_active_drawable (gdisp->gimage))) { case INDEXED_GIMAGE: @@ -669,16 +670,16 @@ blend_cursor_update (Tool *tool, static void blend_draw (Tool *tool) { - GDisplay * gdisp; - BlendTool * blend_tool; - int tx1, ty1, tx2, ty2; + BlendTool *blend_tool; + gint tx1, ty1, tx2, ty2; - gdisp = (GDisplay *) tool->gdisp_ptr; blend_tool = (BlendTool *) tool->private; - gdisplay_transform_coords (gdisp, blend_tool->startx, blend_tool->starty, + gdisplay_transform_coords (tool->gdisp, + blend_tool->startx, blend_tool->starty, &tx1, &ty1, 1); - gdisplay_transform_coords (gdisp, blend_tool->endx, blend_tool->endy, + gdisplay_transform_coords (tool->gdisp, + blend_tool->endx, blend_tool->endy, &tx2, &ty2, 1); /* Draw start target */ @@ -705,7 +706,7 @@ blend_draw (Tool *tool) static void blend_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { BlendTool * blend_tool; diff --git a/app/tools/gimpblendtool.h b/app/tools/gimpblendtool.h index 3c25e17344..2838ce36b6 100644 --- a/app/tools/gimpblendtool.h +++ b/app/tools/gimpblendtool.h @@ -53,26 +53,26 @@ typedef enum REPEAT_LAST /*< skip >*/ } RepeatMode; -void blend (GimpImage *, - GimpDrawable *, - BlendMode, - gint, - GradientType, - gdouble, - gdouble, - RepeatMode, - gint, - gint, - gdouble, - gdouble, - gdouble, - gdouble, - gdouble, - progress_func_t, - gpointer); +void blend (GimpImage *gimage, + GimpDrawable *drawable, + BlendMode blend_mode, + gint paint_mode, + GradientType gradient_type, + gdouble opacity, + gdouble offset, + RepeatMode repeat, + gint supersample, + gint max_depth, + gdouble threshold, + gdouble startx, + gdouble starty, + gdouble endx, + gdouble endy, + progress_func_t progress_callback, + gpointer progress_data); Tool * tools_new_blend (void); -void tools_free_blend (Tool *tool); +void tools_free_blend (Tool *tool); #endif /* __BLEND_H__ */ diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c index 20a16dcbc3..51bf5d9f4b 100644 --- a/app/tools/gimpbrightnesscontrasttool.c +++ b/app/tools/gimpbrightnesscontrasttool.c @@ -83,7 +83,9 @@ static BrightnessContrastDialog *brightness_contrast_dialog = NULL; /* brightness contrast action functions */ -static void brightness_contrast_control (Tool *, ToolAction, gpointer); +static void brightness_contrast_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static BrightnessContrastDialog * brightness_contrast_dialog_new (void); @@ -104,7 +106,7 @@ static void brightness_contrast_contrast_adjustment_update (GtkAdjustment *, static void brightness_contrast_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -393,13 +395,13 @@ brightness_contrast_ok_callback (GtkWidget *widget, active_tool->preserve = TRUE; if (!bcd->preview) - { - brightness_contrast_lut_setup (bcd->lut, bcd->brightness / 255.0, - bcd->contrast / 127.0, - gimp_drawable_bytes (bcd->drawable)); - image_map_apply (bcd->image_map, (ImageMapApplyFunc) gimp_lut_process_2, - (void *) bcd->lut); - } + { + brightness_contrast_lut_setup (bcd->lut, bcd->brightness / 255.0, + bcd->contrast / 127.0, + gimp_drawable_bytes (bcd->drawable)); + image_map_apply (bcd->image_map, (ImageMapApplyFunc) gimp_lut_process_2, + (void *) bcd->lut); + } if (bcd->image_map) image_map_commit (bcd->image_map); @@ -408,7 +410,7 @@ brightness_contrast_ok_callback (GtkWidget *widget, bcd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -432,7 +434,7 @@ brightness_contrast_cancel_callback (GtkWidget *widget, gdisplays_flush (); } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/gimpbrightnesscontrasttool.h b/app/tools/gimpbrightnesscontrasttool.h index 41e909dc68..9cd9077287 100644 --- a/app/tools/gimpbrightnesscontrasttool.h +++ b/app/tools/gimpbrightnesscontrasttool.h @@ -20,12 +20,12 @@ #define __BRIGHTNESS_CONTRAST_H__ -Tool * tools_new_brightness_contrast (void); -void tools_free_brightness_contrast (Tool *tool); +Tool * tools_new_brightness_contrast (void); +void tools_free_brightness_contrast (Tool *tool); void brightness_contrast_dialog_hide (void); -void brightness_contrast_initialize (GDisplay *gdisp); +void brightness_contrast_initialize (GDisplay *gdisp); #endif /* __BRIGHTNESS_CONTRAST_H__ */ diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c index d227994b71..3a32810872 100644 --- a/app/tools/gimpbucketfilltool.c +++ b/app/tools/gimpbucketfilltool.c @@ -85,14 +85,30 @@ static BucketOptions *bucket_options = NULL; /* local function prototypes */ -static void bucket_fill_button_press (Tool *, GdkEventButton *, gpointer); -static void bucket_fill_button_release (Tool *, GdkEventButton *, gpointer); -static void bucket_fill_cursor_update (Tool *, GdkEventMotion *, gpointer); +static void bucket_fill_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void bucket_fill_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void bucket_fill_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); -static void bucket_fill_line_color (guchar *, guchar *, guchar *, - gboolean, gint, gint); -static void bucket_fill_line_pattern (guchar *, guchar *, TempBuf *, - gboolean, gint, gint, gint, gint); +static void bucket_fill_line_color (guchar *, + guchar *, + guchar *, + gboolean , + gint , + gint ); +static void bucket_fill_line_pattern (guchar *, + guchar *, + TempBuf *, + gboolean , + gint , + gint , + gint , + gint ); /* functions */ @@ -123,7 +139,7 @@ bucket_options_new (void) GtkWidget *frame; /* the new bucket fill tool options structure */ - options = (BucketOptions *) g_malloc (sizeof (BucketOptions)); + options = g_new (BucketOptions, 1); paint_options_init ((PaintOptions *) options, BUCKET_FILL, bucket_options_reset); @@ -194,13 +210,11 @@ bucket_options_new (void) static void bucket_fill_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BucketTool * bucket_tool; - gboolean use_offsets; + BucketTool *bucket_tool; + gboolean use_offsets; - gdisp = (GDisplay *) gdisp_ptr; bucket_tool = (BucketTool *) tool->private; use_offsets = (bucket_options->sample_merged) ? FALSE : TRUE; @@ -217,21 +231,19 @@ bucket_fill_button_press (Tool *tool, NULL, NULL, bevent->time); /* Make the tool active and set the gdisplay which owns it */ - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; } static void bucket_fill_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - BucketTool * bucket_tool; - Argument *return_vals; - gint nreturn_vals; + BucketTool *bucket_tool; + Argument *return_vals; + gint nreturn_vals; - gdisp = (GDisplay *) gdisp_ptr; bucket_tool = (BucketTool *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -267,16 +279,13 @@ bucket_fill_button_release (Tool *tool, static void bucket_fill_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - CursorModifier cmodifier = CURSOR_MODIFIER_NONE; - gint x, y; - gint off_x, off_y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + CursorModifier cmodifier = CURSOR_MODIFIER_NONE; + gint x, y; + gint off_x, off_y; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -321,7 +330,7 @@ bucket_fill_cursor_update (Tool *tool, static void bucket_fill_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -359,14 +368,14 @@ bucket_fill (GimpImage *gimage, TileManager *buf_tiles; PixelRegion bufPR, maskPR; Channel *mask = NULL; - gint bytes; - gboolean has_alpha; - gint x1, y1, x2, y2; - guchar col [MAX_CHANNELS]; - guchar *d1, *d2; - GPattern *pattern; - TempBuf *pat_buf; - gboolean new_buf = FALSE; + gint bytes; + gboolean has_alpha; + gint x1, y1, x2, y2; + guchar col [MAX_CHANNELS]; + guchar *d1, *d2; + GPattern *pattern; + TempBuf *pat_buf; + gboolean new_buf = FALSE; pat_buf = NULL; @@ -433,7 +442,7 @@ bucket_fill (GimpImage *gimage, /* make sure we handle the mask correctly if it was sample-merged */ if (sample_merged) { - int off_x, off_y; + gint off_x, off_y; /* Limit the channel bounds to the drawable's extents */ drawable_offsets (drawable, &off_x, &off_y); @@ -533,8 +542,8 @@ bucket_fill_line_pattern (guchar *buf, gint width) { guchar *pat, *p; - gint alpha, b; - gint i; + gint alpha, b; + gint i; /* Get a pointer to the appropriate scanline of the pattern buffer */ pat = temp_buf_data (pattern) + @@ -571,8 +580,8 @@ bucket_fill_region (BucketFillMode fill_mode, gboolean has_alpha) { guchar *s, *m; - gint y; - void *pr; + gint y; + void *pr; for (pr = pixel_regions_register (2, bufPR, maskPR); pr != NULL; @@ -612,8 +621,8 @@ bucket_fill_region (BucketFillMode fill_mode, Tool * tools_new_bucket_fill (void) { - Tool * tool; - BucketTool * private; + Tool *tool; + BucketTool *private; /* The tool options */ if (! bucket_options) @@ -630,7 +639,7 @@ tools_new_bucket_fill (void) tool->scroll_lock = TRUE; /* Disallow scrolling */ - tool->private = (void *) private; + tool->private = (gpointer) private; tool->button_press_func = bucket_fill_button_press; tool->button_release_func = bucket_fill_button_release; @@ -643,7 +652,7 @@ tools_new_bucket_fill (void) void tools_free_bucket_fill (Tool *tool) { - BucketTool * bucket_tool; + BucketTool *bucket_tool; bucket_tool = (BucketTool *) tool->private; diff --git a/app/tools/gimpbycolorselecttool.c b/app/tools/gimpbycolorselecttool.c index 45210650c9..b8bd885d7a 100644 --- a/app/tools/gimpbycolorselecttool.c +++ b/app/tools/gimpbycolorselecttool.c @@ -82,6 +82,7 @@ struct _ByColorDialog GImage *gimage; /* gimage which is currently under examination */ }; + /* the by color selection tool options */ static SelectionOptions * by_color_options = NULL; @@ -93,43 +94,71 @@ static GtkTargetEntry by_color_select_targets[] = { GIMP_TARGET_COLOR }; -static guint n_by_color_select_targets = (sizeof (by_color_select_targets) / - sizeof (by_color_select_targets[0])); +static guint n_by_color_select_targets = (sizeof (by_color_select_targets) / + sizeof (by_color_select_targets[0])); -static void by_color_select_color_drop (GtkWidget *widget, - guchar r, - guchar g, - guchar b, - gpointer data); + +static void by_color_select_color_drop (GtkWidget *widget, + guchar r, + guchar g, + guchar b, + gpointer data); /* by_color select action functions */ -static void by_color_select_button_press (Tool *, GdkEventButton *, gpointer); -static void by_color_select_button_release (Tool *, GdkEventButton *, gpointer); -static void by_color_select_modifier_update (Tool *, GdkEventKey * , gpointer); -static void by_color_select_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void by_color_select_oper_update (Tool *, GdkEventMotion *, gpointer); -static void by_color_select_control (Tool *, ToolAction, gpointer); +static void by_color_select_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void by_color_select_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void by_color_select_modifier_update (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void by_color_select_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void by_color_select_oper_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void by_color_select_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); -static ByColorDialog * by_color_select_dialog_new (void); +static ByColorDialog * by_color_select_dialog_new (void); -static void by_color_select_render (ByColorDialog *, GImage *); -static void by_color_select_draw (ByColorDialog *, GImage *); -static gint by_color_select_preview_events (GtkWidget *, +static void by_color_select_render (ByColorDialog *, + GImage *); +static void by_color_select_draw (ByColorDialog *, + GImage *); +static gint by_color_select_preview_events (GtkWidget *, GdkEventButton *, - ByColorDialog *); -static void by_color_select_invert_callback (GtkWidget *, gpointer); -static void by_color_select_select_all_callback (GtkWidget *, gpointer); -static void by_color_select_select_none_callback (GtkWidget *, gpointer); -static void by_color_select_reset_callback (GtkWidget *, gpointer); -static void by_color_select_close_callback (GtkWidget *, gpointer); -static void by_color_select_preview_button_press (ByColorDialog *, + ByColorDialog *); +static void by_color_select_invert_callback (GtkWidget *, + gpointer ); +static void by_color_select_select_all_callback (GtkWidget *, + gpointer ); +static void by_color_select_select_none_callback (GtkWidget *, + gpointer ); +static void by_color_select_reset_callback (GtkWidget *, + gpointer ); +static void by_color_select_close_callback (GtkWidget *, + gpointer ); +static void by_color_select_preview_button_press (ByColorDialog *, GdkEventButton *); -static gint is_pixel_sufficiently_different (guchar *, guchar *, - gint, gint, gint, gint); -static Channel * by_color_select_color (GImage *, GimpDrawable *, - guchar *, gint, gint, gint); +static gint is_pixel_sufficiently_different (guchar *, + guchar *, + gint , + gint , + gint , + gint ); +static Channel * by_color_select_color (GImage *, + GimpDrawable *, + guchar *, + gint , + gint , + gint ); /* by_color selection machinery */ @@ -196,18 +225,18 @@ by_color_select_color (GImage *gimage, * use the same antialiasing scheme as in fuzzy_select. Modify the gimage's * mask to reflect the additional selection */ - Channel *mask; - PixelRegion imagePR, maskPR; - guchar *image_data; - guchar *mask_data; - guchar *idata, *mdata; - guchar rgb[MAX_CHANNELS]; - gint has_alpha, indexed; - gint width, height; - gint bytes, color_bytes, alpha; - gint i, j; - void * pr; - gint d_type; + Channel *mask; + PixelRegion imagePR, maskPR; + guchar *image_data; + guchar *mask_data; + guchar *idata, *mdata; + guchar rgb[MAX_CHANNELS]; + gint has_alpha, indexed; + gint width, height; + gint bytes, color_bytes, alpha; + gint i, j; + gpointer pr; + gint d_type; /* Get the image information */ if (sample_merged) @@ -342,12 +371,10 @@ by_color_select (GImage *gimage, static void by_color_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; ByColorSelect *by_color_sel; - gdisp = (GDisplay *) gdisp_ptr; by_color_sel = (ByColorSelect *) tool->private; tool->drawable = gimp_image_active_drawable (gdisp->gimage); @@ -359,7 +386,7 @@ by_color_select_button_press (Tool *tool, by_color_sel->y = bevent->y; tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; /* Make sure the "by color" select dialog is visible */ if (! GTK_WIDGET_VISIBLE (by_color_dialog->shell)) @@ -393,16 +420,14 @@ by_color_select_button_press (Tool *tool, static void by_color_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_color_sel; - GDisplay *gdisp; gint x, y; GimpDrawable *drawable; guchar *color; gint use_offsets; - gdisp = (GDisplay *) gdisp_ptr; by_color_sel = (ByColorSelect *) tool->private; drawable = gimp_image_active_drawable (gdisp->gimage); @@ -456,14 +481,12 @@ by_color_select_button_release (Tool *tool, static void by_color_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_col_sel; - GDisplay *gdisp; Layer *layer; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; by_col_sel = (ByColorSelect *) tool->private; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, @@ -551,7 +574,7 @@ by_color_select_update_op_state (ByColorSelect *by_col_sel, static void by_color_select_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_col_sel; gint state; @@ -584,26 +607,25 @@ by_color_select_modifier_update (Tool *tool, break; } - by_color_select_update_op_state (by_col_sel, state, (GDisplay *) gdisp_ptr); + by_color_select_update_op_state (by_col_sel, state, gdisp); } static void by_color_select_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { ByColorSelect *by_col_sel; by_col_sel = (ByColorSelect *) tool->private; - by_color_select_update_op_state (by_col_sel, mevent->state, - (GDisplay *) gdisp_ptr); + by_color_select_update_op_state (by_col_sel, mevent->state, gdisp); } static void by_color_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { diff --git a/app/tools/gimpclonetool.c b/app/tools/gimpclonetool.c index 7c16c6f684..320e2c7725 100644 --- a/app/tools/gimpclonetool.c +++ b/app/tools/gimpclonetool.c @@ -79,37 +79,59 @@ struct _CloneOptions }; +/* forward function declarations */ + +static gpointer clone_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void clone_draw (Tool *tool); +static void clone_motion (PaintCore *paint_core, + GimpDrawable *drawable, + GimpDrawable *src_drawable, + PaintPressureOptions *pressure_options, + CloneType type, + gint offset_x, + gint offset_y); +static void clone_line_image (GImage *dest, + GImage *src, + GimpDrawable *d_drawable, + GimpDrawable *s_drawable, + guchar *s, + guchar *d, + gint has_alpha, + gint src_bytes, + gint dest_bytes, + gint width); +static void clone_line_pattern (GImage *dest, + GimpDrawable *drawable, + GPattern *pattern, + guchar *d, + gint x, + gint y, + gint bytes, + gint width); + + /* the clone tool options */ static CloneOptions *clone_options = NULL; /* local variables */ -static int src_x = 0; /* */ -static int src_y = 0; /* position of clone src */ -static int dest_x = 0; /* */ -static int dest_y = 0; /* position of clone src */ -static int offset_x = 0; /* */ -static int offset_y = 0; /* offset for cloning */ -static int first = TRUE; -static int trans_tx, trans_ty; /* transformed target */ +static gint src_x = 0; /* */ +static gint src_y = 0; /* position of clone src */ +static gint dest_x = 0; /* */ +static gint dest_y = 0; /* position of clone src */ +static gint offset_x = 0; /* */ +static gint offset_y = 0; /* offset for cloning */ +static gint first = TRUE; +static gint trans_tx, trans_ty; /* transformed target */ static GDisplay *the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable *src_drawable_ = NULL; /* source drawable */ static GimpDrawable *non_gui_src_drawable; -static int non_gui_offset_x; -static int non_gui_offset_y; +static gint non_gui_offset_x; +static gint non_gui_offset_y; static CloneType non_gui_type; -/* forward function declarations */ - -static void clone_draw (Tool *); -static void clone_motion (PaintCore *, GimpDrawable *, GimpDrawable *, - PaintPressureOptions *, CloneType, int, int); -static void clone_line_image (GImage *, GImage *, GimpDrawable *, - GimpDrawable *, unsigned char *, - unsigned char *, int, int, int, int); -static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, - unsigned char *, int, int, int, int); - /* functions */ @@ -128,8 +150,8 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *frame; /* the new clone tool options structure */ options = g_new (CloneOptions, 1); @@ -202,23 +224,24 @@ clone_set_src_drawable (GimpDrawable *drawable) } } -void * +static gpointer clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - gint state) + PaintState state) { - GDisplay * gdisp; - GDisplay * src_gdisp; - int x1, y1, x2, y2; - static int orig_src_x, orig_src_y; + GDisplay *gdisp; + GDisplay *src_gdisp; + gint x1, y1, x2, y2; + static gint orig_src_x, orig_src_y; - gdisp = (GDisplay *) active_tool->gdisp_ptr; + gdisp = (GDisplay *) active_tool->gdisp; switch (state) { case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; @@ -320,14 +343,11 @@ clone_paint_func (PaintCore *paint_core, void clone_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + gint x, y; gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y, &x, &y, TRUE, FALSE); @@ -661,10 +681,10 @@ clone_line_pattern (GImage *dest, } } -static void * -clone_non_gui_paint_func (PaintCore *paint_core, +static gpointer +clone_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { clone_motion (paint_core, drawable, non_gui_src_drawable, &non_gui_pressure_options, @@ -675,16 +695,16 @@ clone_non_gui_paint_func (PaintCore *paint_core, gboolean clone_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { GimpDrawable *src_drawable = NULL; CloneType clone_type = CLONE_DEFAULT_TYPE; - double local_src_x = 0.0; - double local_src_y = 0.0; + gdouble local_src_x = 0.0; + gdouble local_src_y = 0.0; CloneOptions *options = clone_options; - - if(options) + + if (options) { clone_type = options->type; src_drawable = src_drawable_; @@ -692,23 +712,23 @@ clone_non_gui_default (GimpDrawable *drawable, local_src_y = src_y; } - return clone_non_gui(drawable, - src_drawable, - clone_type, - local_src_x,local_src_y, - num_strokes,stroke_array); + return clone_non_gui (drawable, + src_drawable, + clone_type, + local_src_x,local_src_y, + num_strokes, stroke_array); } gboolean clone_non_gui (GimpDrawable *drawable, GimpDrawable *src_drawable, CloneType clone_type, - double src_x, - double src_y, - int num_strokes, - double *stroke_array) + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) diff --git a/app/tools/gimpclonetool.h b/app/tools/gimpclonetool.h index 0433bc488e..fcc2f1d247 100644 --- a/app/tools/gimpclonetool.h +++ b/app/tools/gimpclonetool.h @@ -26,21 +26,19 @@ typedef enum PATTERN_CLONE } CloneType; -void * clone_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean clone_non_gui (GimpDrawable *, - GimpDrawable *, - CloneType, - gdouble, - gdouble, - gint, - gdouble *); -gboolean clone_non_gui_default (GimpDrawable *, - gint, - gdouble *); + +gboolean clone_non_gui (GimpDrawable *drawable, + GimpDrawable *src_drawable, + CloneType clone_type, + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array); +gboolean clone_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_clone (void); -void tools_free_clone (Tool *); +void tools_free_clone (Tool *tool); #endif /* __CLONE_H__ */ diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c index b74246cfdc..87b62926bc 100644 --- a/app/tools/gimpcolorbalancetool.c +++ b/app/tools/gimpcolorbalancetool.c @@ -62,21 +62,33 @@ static ColorBalanceDialog *color_balance_dialog = NULL; /* color balance action functions */ -static void color_balance_control (Tool *, ToolAction, gpointer); +static void color_balance_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); static ColorBalanceDialog * color_balance_dialog_new (void); -static void color_balance_update (ColorBalanceDialog *, int); -static void color_balance_preview (ColorBalanceDialog *); -static void color_balance_reset_callback (GtkWidget *, gpointer); -static void color_balance_ok_callback (GtkWidget *, gpointer); -static void color_balance_cancel_callback (GtkWidget *, gpointer); -static void color_balance_range_callback (GtkWidget *, gpointer); -static void color_balance_preserve_update (GtkWidget *, gpointer); -static void color_balance_preview_update (GtkWidget *, gpointer); -static void color_balance_cr_adjustment_update (GtkAdjustment *, gpointer); -static void color_balance_mg_adjustment_update (GtkAdjustment *, gpointer); -static void color_balance_yb_adjustment_update (GtkAdjustment *, gpointer); +static void color_balance_update (ColorBalanceDialog *cbd, + gint ); +static void color_balance_preview (ColorBalanceDialog *cbd); +static void color_balance_reset_callback (GtkWidget *widget, + gpointer data); +static void color_balance_ok_callback (GtkWidget *widget, + gpointer data); +static void color_balance_cancel_callback (GtkWidget *widget, + gpointer data); +static void color_balance_range_callback (GtkWidget *widget, + gpointer data); +static void color_balance_preserve_update (GtkWidget *widget, + gpointer data); +static void color_balance_preview_update (GtkWidget *widget, + gpointer data); +static void color_balance_cr_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void color_balance_mg_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void color_balance_yb_adjustment_update (GtkAdjustment *adj, + gpointer data); /* color balance machinery */ @@ -86,12 +98,12 @@ color_balance (PixelRegion *srcPR, void *data) { ColorBalanceDialog *cbd; - guchar *src, *s; - guchar *dest, *d; - gint alpha; - gint r, g, b; - gint r_n, g_n, b_n; - gint w, h; + guchar *src, *s; + guchar *dest, *d; + gboolean alpha; + gint r, g, b; + gint r_n, g_n, b_n; + gint w, h; cbd = (ColorBalanceDialog *) data; @@ -143,7 +155,7 @@ color_balance (PixelRegion *srcPR, static void color_balance_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { ColorBalance * color_bal; @@ -599,7 +611,7 @@ color_balance_ok_callback (GtkWidget *widget, cbd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -623,7 +635,7 @@ color_balance_cancel_callback (GtkWidget *widget, cbd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/gimpconvolvetool.c b/app/tools/gimpconvolvetool.c index bcf8bd2580..e8df499d63 100644 --- a/app/tools/gimpconvolvetool.c +++ b/app/tools/gimpconvolvetool.c @@ -82,6 +82,28 @@ struct _ConvolveOptions }; +/* forward function declarations */ +static void calculate_matrix (ConvolveType type, + gdouble rate); +static void integer_matrix (gfloat *source, + gint *dest, + gint size); +static void copy_matrix (gfloat *src, + gfloat *dest, + gint size); +static gint sum_matrix (gint *matrix, + gint size); + +static gpointer convolve_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void convolve_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + ConvolveType type, + gdouble rate); + + /* the convolve tool options */ static ConvolveOptions * convolve_options = NULL; @@ -121,19 +143,8 @@ static gfloat sharpen_matrix [25] = }; -/* forward function declarations */ -static void calculate_matrix (ConvolveType, double); -static void integer_matrix (float *, int *, int); -static void copy_matrix (float *, float *, int); -static int sum_matrix (int *, int); - -static void convolve_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, - ConvolveType, double); - /* functions */ - static void convolve_options_reset (void) { @@ -205,10 +216,10 @@ convolve_options_new (void) return options; } -void * +static gpointer convolve_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -217,6 +228,9 @@ convolve_paint_func (PaintCore *paint_core, convolve_options->paint_options.pressure_options, convolve_options->type, convolve_options->rate); break; + + default: + break; } return NULL; @@ -225,7 +239,7 @@ convolve_paint_func (PaintCore *paint_core, static void convolve_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -282,18 +296,18 @@ convolve_modifier_key_func (Tool *tool, static void convolve_cursor_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE); - paint_core_cursor_update (tool, mevent, gdisp_ptr); + paint_core_cursor_update (tool, mevent, gdisp); } Tool * tools_new_convolve (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! convolve_options) @@ -570,34 +584,34 @@ calculate_matrix (ConvolveType type, } static void -integer_matrix (float *source, - int *dest, - int size) +integer_matrix (gfloat *source, + gint *dest, + gint size) { - int i; + gint i; #define PRECISION 10000 for (i = 0; i < size*size; i++) - *dest++ = (int) (*source ++ * PRECISION); + *dest++ = (gint) (*source ++ * PRECISION); } static void -copy_matrix (float *src, - float *dest, - int size) +copy_matrix (gfloat *src, + gfloat *dest, + gint size) { - int i; + gint i; for (i = 0; i < size*size; i++) *dest++ = *src++; } static int -sum_matrix (int *matrix, - int size) +sum_matrix (gint *matrix, + gint size) { - int sum = 0; + gint sum = 0; size *= size; @@ -608,10 +622,10 @@ sum_matrix (int *matrix, } -static void * -convolve_non_gui_paint_func (PaintCore *paint_core, +static gpointer +convolve_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { convolve_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_type, non_gui_rate); @@ -621,11 +635,11 @@ convolve_non_gui_paint_func (PaintCore *paint_core, gboolean convolve_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - double rate = DEFAULT_CONVOLVE_RATE; - ConvolveType type = DEFAULT_CONVOLVE_TYPE; + gdouble rate = DEFAULT_CONVOLVE_RATE; + ConvolveType type = DEFAULT_CONVOLVE_TYPE; ConvolveOptions *options = convolve_options; if (options) @@ -641,17 +655,17 @@ gboolean convolve_non_gui (GimpDrawable *drawable, double rate, ConvolveType type, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) { /* Set the paint core's paint func */ non_gui_paint_core.paint_func = convolve_non_gui_paint_func; - + non_gui_type = type; non_gui_rate = rate; @@ -678,6 +692,6 @@ convolve_non_gui (GimpDrawable *drawable, paint_core_cleanup (); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/tools/gimpconvolvetool.h b/app/tools/gimpconvolvetool.h index 3a6058ef5c..1e07c92d36 100644 --- a/app/tools/gimpconvolvetool.h +++ b/app/tools/gimpconvolvetool.h @@ -28,19 +28,17 @@ typedef enum } ConvolveType; -void * convolve_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean convolve_non_gui (GimpDrawable *, - gdouble , - ConvolveType , - gint , - gdouble *); -gboolean convolve_non_gui_default (GimpDrawable *, - gint , - gdouble *); -Tool * tools_new_convolve (void ); -void tools_free_convolve (Tool *); +gboolean convolve_non_gui (GimpDrawable *drawable, + gdouble rate, + ConvolveType type, + gint num_strokes, + gdouble *stroke_array); +gboolean convolve_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); + +Tool * tools_new_convolve (void); +void tools_free_convolve (Tool *tool); #endif /* __CONVOLVE_H__ */ diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index a792147af9..5f78ff5925 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -121,25 +121,49 @@ static GtkWidget *size_sizeentry; /* Crop type functions */ -static void crop_button_press (Tool *, GdkEventButton *, gpointer); -static void crop_button_release (Tool *, GdkEventButton *, gpointer); -static void crop_motion (Tool *, GdkEventMotion *, gpointer); -static void crop_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void crop_control (Tool *, ToolAction, gpointer); -static void crop_arrow_keys_func (Tool *, GdkEventKey *, gpointer); -static void crop_modifier_key_func (Tool *, GdkEventKey *, gpointer); +static void crop_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void crop_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void crop_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void crop_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void crop_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); +static void crop_arrow_keys_func (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void crop_modifier_key_func (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); /* Crop helper functions */ -static void crop_recalc (Tool *, Crop *); -static void crop_start (Tool *, Crop *); -static void crop_adjust_guides (GImage *, int, int, int, int); +static void crop_recalc (Tool *tool, + Crop *crop); +static void crop_start (Tool *tool, + Crop *crop); +static void crop_adjust_guides (GImage *gimage, + gint x1, + gint y1, + gint x2, + gint y2); /* Crop dialog functions */ -static void crop_info_update (Tool *); -static void crop_info_create (Tool *); -static void crop_crop_callback (GtkWidget *, gpointer); -static void crop_resize_callback (GtkWidget *, gpointer); -static void crop_close_callback (GtkWidget *, gpointer); +static void crop_info_update (Tool *tool); +static void crop_info_create (Tool *tool); +static void crop_crop_callback (GtkWidget *widget, + gpointer data); +static void crop_resize_callback (GtkWidget *widget, + gpointer data); +static void crop_close_callback (GtkWidget *widget, + gpointer data); + /* Crop area-select functions */ typedef enum @@ -149,19 +173,40 @@ typedef enum AUTO_CROP_COLOR = 2 } AutoCropType; -typedef guchar * (*GetColorFunc) (GtkObject *, int, int); -typedef AutoCropType (*ColorsEqualFunc) (guchar *, guchar *, int); -static void crop_selection_callback (GtkWidget *, gpointer); -static void crop_automatic_callback (GtkWidget *, gpointer); -static AutoCropType crop_guess_bgcolor (GtkObject *, GetColorFunc, - int, int, guchar *, int, int, int, int); -static int crop_colors_equal (guchar *, guchar *, int); -static int crop_colors_alpha (guchar *, guchar *, int); +typedef guchar * (* GetColorFunc) (GtkObject *, + gint , + gint ); +typedef AutoCropType (* ColorsEqualFunc) (guchar *, + guchar *, + gint ); + +static void crop_selection_callback (GtkWidget *widget, + gpointer data); +static void crop_automatic_callback (GtkWidget *widget, + gpointer data); +static AutoCropType crop_guess_bgcolor (GtkObject *, + GetColorFunc, + gint , + gint , + guchar *, + gint , + gint , + gint , + gint ); +static gint crop_colors_equal (guchar *, + guchar *, + gint ); +static gint crop_colors_alpha (guchar *, + guchar *, + gint ); + /* Crop dialog callback funtions */ -static void crop_orig_changed (GtkWidget *, gpointer); -static void crop_size_changed (GtkWidget *, gpointer); +static void crop_orig_changed (GtkWidget *widget, + gpointer data); +static void crop_size_changed (GtkWidget *widget, + gpointer data); /* Functions */ @@ -182,8 +227,8 @@ static CropOptions * crop_options_new (void) { CropOptions *options; - GtkWidget *vbox; - GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *frame; /* the new crop tool options structure */ options = g_new (CropOptions, 1); @@ -241,16 +286,14 @@ crop_options_new (void) static void crop_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - Crop * crop; - GDisplay * gdisp; + Crop *crop; - gdisp = (GDisplay *) gdisp_ptr; crop = (Crop *) tool->private; if (tool->state == INACTIVE || - gdisp_ptr != tool->gdisp_ptr) + gdisp != tool->gdisp) { crop->function = CREATING; } @@ -291,7 +334,7 @@ crop_button_press (Tool *tool, if (tool->state == ACTIVE) draw_core_stop (crop->core, tool); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->drawable = gimp_image_active_drawable (gdisp->gimage); gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, @@ -318,13 +361,11 @@ crop_button_press (Tool *tool, static void crop_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - Crop * crop; - GDisplay *gdisp; + Crop *crop; crop = (Crop *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; gdk_pointer_ungrab (bevent->time); gdk_flush (); @@ -352,13 +393,15 @@ crop_button_release (Tool *tool, static void crop_adjust_guides (GImage *gimage, - int x1, int y1, - int x2, int y2) + gint x1, + gint y1, + gint x2, + gint y2) { - GList * glist; - Guide * guide; - gboolean remove_guide; + GList *glist; + Guide *guide; + gboolean remove_guide; for (glist = gimage->guides; glist; glist = g_list_next (glist)) { @@ -407,19 +450,17 @@ crop_adjust_guides (GImage *gimage, static void crop_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - Crop *crop; - GDisplay *gdisp; - Layer *layer; - gint x1, y1, x2, y2; - gint curx, cury; - gint inc_x, inc_y; - gchar size[STATUSBAR_SIZE]; - gint min_x, min_y, max_x, max_y; + Crop *crop; + Layer *layer; + gint x1, y1, x2, y2; + gint curx, cury; + gint inc_x, inc_y; + gchar size[STATUSBAR_SIZE]; + gint min_x, min_y, max_x, max_y; crop = (Crop *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; /* This is the only case when the motion events should be ignored-- we're just waiting for the button release event to crop the image */ @@ -554,19 +595,17 @@ crop_motion (Tool *tool, static void crop_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Crop *crop; + Crop *crop; GdkCursorType ctype = GIMP_MOUSE_CURSOR; CursorModifier cmodifier = CURSOR_MODIFIER_NONE; - gdisp = (GDisplay *) gdisp_ptr; crop = (Crop *) tool->private; if (tool->state == INACTIVE || - (tool->state == ACTIVE && tool->gdisp_ptr != gdisp_ptr)) + (tool->state == ACTIVE && tool->gdisp != gdisp)) { ctype = GIMP_CROSSHAIR_SMALL_CURSOR; } @@ -605,16 +644,13 @@ crop_cursor_update (Tool *tool, static void crop_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - Crop *crop; - gint inc_x, inc_y; - gint min_x, min_y; - gint max_x, max_y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + Crop *crop; + gint inc_x, inc_y; + gint min_x, min_y; + gint max_x, max_y; if (tool->state == ACTIVE) { @@ -687,7 +723,7 @@ crop_arrow_keys_func (Tool *tool, static void crop_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -712,7 +748,7 @@ crop_modifier_key_func (Tool *tool, static void crop_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { Crop *crop; @@ -741,19 +777,17 @@ crop_control (Tool *tool, void crop_draw (Tool *tool) { - Crop *crop; - GDisplay *gdisp; + Crop *crop; - gdisp = (GDisplay *) tool->gdisp_ptr; - crop = (Crop *) tool->private; + crop = (Crop *) tool->private; #define SRW 10 #define SRH 10 gdk_draw_line (crop->core->win, crop->core->gc, - crop->x1, crop->y1, gdisp->disp_width, crop->y1); + crop->x1, crop->y1, tool->gdisp->disp_width, crop->y1); gdk_draw_line (crop->core->win, crop->core->gc, - crop->x1, crop->y1, crop->x1, gdisp->disp_height); + crop->x1, crop->y1, crop->x1, tool->gdisp->disp_height); gdk_draw_line (crop->core->win, crop->core->gc, crop->x2, crop->y2, 0, crop->y2); gdk_draw_line (crop->core->win, crop->core->gc, @@ -843,10 +877,10 @@ crop_image (GImage *gimage, Channel *channel; GList *guide_list_ptr; GSList *list; - gint width, height; - gint lx1, ly1, lx2, ly2; - gint off_x, off_y; - gint doff_x, doff_y; + gint width, height; + gint lx1, ly1, lx2, ly2; + gint off_x, off_y; + gint doff_x, doff_y; width = x2 - x1; height = y2 - y1; @@ -978,13 +1012,9 @@ static void crop_recalc (Tool *tool, Crop *crop) { - GDisplay *gdisp; - - gdisp = (GDisplay *) tool->gdisp_ptr; - - gdisplay_transform_coords (gdisp, crop->tx1, crop->ty1, + gdisplay_transform_coords (tool->gdisp, crop->tx1, crop->ty1, &crop->x1, &crop->y1, FALSE); - gdisplay_transform_coords (gdisp, crop->tx2, crop->ty2, + gdisplay_transform_coords (tool->gdisp, crop->tx2, crop->ty2, &crop->x2, &crop->y2, FALSE); } @@ -993,9 +1023,6 @@ crop_start (Tool *tool, Crop *crop) { static GDisplay *old_gdisp = NULL; - GDisplay *gdisp; - - gdisp = (GDisplay *) tool->gdisp_ptr; crop_recalc (tool, crop); @@ -1006,33 +1033,33 @@ crop_start (Tool *tool, gtk_signal_handler_block_by_data (GTK_OBJECT (size_sizeentry), crop_info); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 0, - gdisp->gimage->xresolution, FALSE); + tool->gdisp->gimage->xresolution, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 1, - gdisp->gimage->yresolution, FALSE); + tool->gdisp->gimage->yresolution, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 0, - 0, gdisp->gimage->width); + 0, tool->gdisp->gimage->width); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 1, - 0, gdisp->gimage->height); + 0, tool->gdisp->gimage->height); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 0, - gdisp->gimage->xresolution, FALSE); + tool->gdisp->gimage->xresolution, FALSE); gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 1, - gdisp->gimage->yresolution, FALSE); + tool->gdisp->gimage->yresolution, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 0, - 0, gdisp->gimage->width); + 0, tool->gdisp->gimage->width); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 1, - 0, gdisp->gimage->height); + 0, tool->gdisp->gimage->height); - if (old_gdisp != gdisp) + if (old_gdisp != tool->gdisp) { gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry), - gdisp->gimage->unit) ; + tool->gdisp->gimage->unit) ; gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_sizeentry), - gdisp->gimage->unit); + tool->gdisp->gimage->unit); - if (gdisp->dot_for_dot) + if (tool->gdisp->dot_for_dot) { gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry), GIMP_UNIT_PIXEL); @@ -1044,15 +1071,16 @@ crop_start (Tool *tool, gtk_signal_handler_unblock_by_data (GTK_OBJECT (size_sizeentry), crop_info); gtk_signal_handler_unblock_by_data (GTK_OBJECT (origin_sizeentry), crop_info); - old_gdisp = gdisp; + old_gdisp = tool->gdisp; /* initialize the statusbar display */ crop->context_id = - gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "crop"); - gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), + gtk_statusbar_get_context_id (GTK_STATUSBAR (tool->gdisp->statusbar), + "crop"); + gtk_statusbar_push (GTK_STATUSBAR (tool->gdisp->statusbar), crop->context_id, _("Crop: 0 x 0")); - draw_core_start (crop->core, gdisp->canvas->window, tool); + draw_core_start (crop->core, tool->gdisp->canvas->window, tool); } @@ -1068,7 +1096,7 @@ crop_info_create (Tool *tool) GtkWidget *bbox; GtkWidget *button; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = (GDisplay *) tool->gdisp; /* create the info dialog */ crop_info = info_dialog_new (_("Crop & Resize Information"), @@ -1147,11 +1175,9 @@ crop_info_create (Tool *tool) static void crop_info_update (Tool *tool) { - Crop *crop; - GDisplay *gdisp; + Crop *crop; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; orig_vals[0] = crop->tx1; orig_vals[1] = crop->ty1; @@ -1166,15 +1192,13 @@ static void crop_crop_callback (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; + Tool *tool; + Crop *crop; tool = active_tool; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; - crop_image (gdisp->gimage, + crop_image (tool->gdisp->gimage, crop->tx1, crop->ty1, crop->tx2, crop->ty2, crop_options->layer_only, @@ -1188,15 +1212,13 @@ static void crop_resize_callback (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; + Tool *tool; + Crop *crop; tool = active_tool; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; - crop_image (gdisp->gimage, + crop_image (tool->gdisp->gimage, crop->tx1, crop->ty1, crop->tx2, crop->ty2, crop_options->layer_only, @@ -1221,9 +1243,9 @@ crop_close_callback (GtkWidget *widget, info_dialog_popdown (crop_info); - tool->gdisp_ptr = NULL; + tool->gdisp = NULL; tool->drawable = NULL; - tool->state = INACTIVE; + tool->state = INACTIVE; } static void @@ -1235,9 +1257,9 @@ crop_selection_callback (GtkWidget *widget, Layer *layer; GDisplay *gdisp; - tool = active_tool; - crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; + tool = active_tool; + crop = (Crop *) tool->private; + gdisp = tool->gdisp; draw_core_pause (crop->core, tool); if (! gimage_mask_bounds (gdisp->gimage, @@ -1266,24 +1288,24 @@ static void crop_automatic_callback (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; - GimpDrawable *active_drawable = NULL; - GetColorFunc get_color_func; - ColorsEqualFunc colors_equal_func; - GtkObject *get_color_obj; - guchar bgcolor[4] = {0, 0, 0, 0}; - gboolean has_alpha = FALSE; - PixelRegion PR; - guchar *buffer = NULL; - gint offset_x, offset_y, width, height, bytes; - gint x, y, abort; - gint x1, y1, x2, y2; + Tool *tool; + Crop *crop; + GDisplay *gdisp; + GimpDrawable *active_drawable = NULL; + GetColorFunc get_color_func; + ColorsEqualFunc colors_equal_func; + GtkObject *get_color_obj; + guchar bgcolor[4] = {0, 0, 0, 0}; + gboolean has_alpha = FALSE; + PixelRegion PR; + guchar *buffer = NULL; + gint offset_x, offset_y, width, height, bytes; + gint x, y, abort; + gint x1, y1, x2, y2; tool = active_tool; crop = (Crop *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; draw_core_pause (crop->core, tool); gimp_add_busy_cursors (); @@ -1516,18 +1538,17 @@ static void crop_orig_changed (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; - gint ox; - gint oy; + Tool *tool; + Crop *crop; + gint ox; + gint oy; tool = active_tool; if (tool && active_tool->type == CROP) { - gdisp = (GDisplay *) tool->gdisp_ptr; - crop = (Crop *) tool->private; + crop = (Crop *) tool->private; + ox = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); oy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1)); @@ -1549,18 +1570,17 @@ static void crop_size_changed (GtkWidget *widget, gpointer data) { - Tool *tool; - Crop *crop; - GDisplay *gdisp; - gint sx; - gint sy; + Tool *tool; + Crop *crop; + gint sx; + gint sy; tool = active_tool; if (tool && active_tool->type == CROP) { - gdisp = (GDisplay *) tool->gdisp_ptr; - crop = (Crop *) tool->private; + crop = (Crop *) tool->private; + sx = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0); sy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1); diff --git a/app/tools/gimpcroptool.h b/app/tools/gimpcroptool.h index b698b95634..fe7d35d34d 100644 --- a/app/tools/gimpcroptool.h +++ b/app/tools/gimpcroptool.h @@ -29,17 +29,15 @@ typedef enum void crop_draw (Tool *tool); void crop_image (GimpImage *gimage, - gint, - gint, - gint, - gint, - gint, - gint); + gint x1, + gint y1, + gint x2, + gint y2, + gboolean layer_only, + gboolean crop_layers); Tool * tools_new_crop (void); void tools_free_crop (Tool *tool); #endif /* __CROP_H__ */ - - diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index 7ba6f1ab76..fe3a945fc7 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -108,40 +108,72 @@ static CRMatrix CR_basis = /* curves action functions */ -static void curves_button_press (Tool *, GdkEventButton *, gpointer); -static void curves_button_release (Tool *, GdkEventButton *, gpointer); -static void curves_motion (Tool *, GdkEventMotion *, gpointer); -static void curves_control (Tool *, ToolAction, gpointer); +static void curves_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void curves_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void curves_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void curves_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); -static CurvesDialog * curves_dialog_new (void); +static CurvesDialog * curves_dialog_new (void); -static void curves_update (CurvesDialog *, int); -static void curves_plot_curve (CurvesDialog *, int, int, int, int); -static void curves_preview (CurvesDialog *); +static void curves_update (CurvesDialog *cd, + gint ); +static void curves_plot_curve (CurvesDialog *cd, + gint , + gint , + gint , + gint ); +static void curves_preview (CurvesDialog *cd); -static void curves_channel_callback (GtkWidget *, gpointer); +static void curves_channel_callback (GtkWidget *widget, + gpointer data); -static void curves_smooth_callback (GtkWidget *, gpointer); -static void curves_free_callback (GtkWidget *, gpointer); +static void curves_smooth_callback (GtkWidget *widget, + gpointer data); +static void curves_free_callback (GtkWidget *widget, + gpointer data); -static void curves_channel_reset (int); -static void curves_reset_callback (GtkWidget *, gpointer); -static void curves_ok_callback (GtkWidget *, gpointer); -static void curves_cancel_callback (GtkWidget *, gpointer); -static void curves_load_callback (GtkWidget *, gpointer); -static void curves_save_callback (GtkWidget *, gpointer); -static void curves_preview_update (GtkWidget *, gpointer); -static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static gint curves_graph_events (GtkWidget *, GdkEvent *, CurvesDialog *); -static void curves_CR_compose (CRMatrix, CRMatrix, CRMatrix); +static void curves_channel_reset (gint ); +static void curves_reset_callback (GtkWidget *widget, + gpointer data); +static void curves_ok_callback (GtkWidget *widget, + gpointer data); +static void curves_cancel_callback (GtkWidget *widget, + gpointer data); +static void curves_load_callback (GtkWidget *widget, + gpointer data); +static void curves_save_callback (GtkWidget *widget, + gpointer data); +static void curves_preview_update (GtkWidget *widget, + gpointer data); +static gint curves_xrange_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static gint curves_yrange_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static gint curves_graph_events (GtkWidget *widget, + GdkEvent *event, + CurvesDialog *cd); +static void curves_CR_compose (CRMatrix , + CRMatrix , + CRMatrix ); -static void file_dialog_create (GtkWidget *); -static void file_dialog_ok_callback (GtkWidget *, gpointer); -static void file_dialog_cancel_callback (GtkWidget *, gpointer); +static void file_dialog_create (GtkWidget *widget); +static void file_dialog_ok_callback (GtkWidget *widget, + gpointer data); +static void file_dialog_cancel_callback (GtkWidget *widget, + gpointer data); -static gboolean curves_read_from_file (FILE *f); -static void curves_write_to_file (FILE *f); +static gboolean curves_read_from_file (FILE *f); +static void curves_write_to_file (FILE *f); /* curves machinery */ @@ -152,10 +184,10 @@ curves_lut_func (CurvesDialog *cd, gint channel, gfloat value) { - gfloat f; - gint index; + gfloat f; + gint index; gdouble inten; - gint j; + gint j; if (nchannels == 1) j = 0; @@ -197,15 +229,15 @@ curves_colour_update (Tool *tool, gint x, gint y) { - guchar *color; - gint offx; - gint offy; - gint maxval; + guchar *color; + gint offx; + gint offy; + gint maxval; gboolean has_alpha; gboolean is_indexed; GimpImageType sample_type; - if(!tool || tool->state != ACTIVE) + if (!tool || tool->state != ACTIVE) return; drawable_offsets (drawable, &offx, &offy); @@ -213,7 +245,7 @@ curves_colour_update (Tool *tool, x -= offx; y -= offy; - if (!(color = image_map_get_color_at(curves_dialog->image_map, x, y))) + if (!(color = image_map_get_color_at (curves_dialog->image_map, x, y))) return; sample_type = gimp_drawable_type (drawable); @@ -283,16 +315,14 @@ curves_add_point (GimpDrawable *drawable, static void curves_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; - GDisplay *gdisp; + gint x, y; GimpDrawable *drawable; - gdisp = gdisp_ptr; drawable = gimp_image_active_drawable (gdisp->gimage); - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; if (drawable != tool->drawable) { @@ -318,20 +348,18 @@ curves_button_press (Tool *tool, static void curves_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; + gint x, y; GimpDrawable *drawable; - GDisplay *gdisp; - gdisp = (GDisplay *) gdisp_ptr; - - if(!curves_dialog || - !gdisp || - !(drawable = gimp_image_active_drawable (gdisp->gimage))) + if (! curves_dialog || + ! gdisp || + ! (drawable = gimp_image_active_drawable (gdisp->gimage))) return; - gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE); + gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, + FALSE, FALSE); curves_colour_update (tool, gdisp, drawable, x, y); if (bevent->state & GDK_SHIFT_MASK) @@ -355,14 +383,11 @@ curves_button_release (Tool *tool, static void curves_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - gint x, y; - GDisplay *gdisp; + gint x, y; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; - if (! curves_dialog || ! gdisp || ! (drawable = gimp_image_active_drawable (gdisp->gimage))) @@ -376,7 +401,7 @@ curves_motion (Tool *tool, static void curves_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -1279,7 +1304,7 @@ curves_ok_callback (GtkWidget *widget, cd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -1303,7 +1328,7 @@ curves_cancel_callback (GtkWidget *widget, cd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/gimpdodgeburntool.c b/app/tools/gimpdodgeburntool.c index 8ffe8968ce..396945d3b3 100644 --- a/app/tools/gimpdodgeburntool.c +++ b/app/tools/gimpdodgeburntool.c @@ -44,6 +44,12 @@ #include "libgimp/gimpintl.h" +/* Default values */ + +#define DODGEBURN_DEFAULT_TYPE DODGE +#define DODGEBURN_DEFAULT_EXPOSURE 50.0 +#define DODGEBURN_DEFAULT_MODE DODGEBURN_HIGHLIGHTS + /* the dodgeburn structures */ typedef struct _DodgeBurnOptions DodgeBurnOptions; @@ -67,36 +73,49 @@ struct _DodgeBurnOptions GimpLut *lut; }; -static void -dodgeburn_make_luts (PaintCore *, double, DodgeBurnType, DodgeBurnMode, - GimpLut *, GimpDrawable *); -static gfloat dodgeburn_highlights_lut_func (void *, int, int, gfloat); -static gfloat dodgeburn_midtones_lut_func (void *, int, int, gfloat); -static gfloat dodgeburn_shadows_lut_func (void *, int, int, gfloat); +static gpointer dodgeburn_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + +static void dodgeburn_make_luts (PaintCore *paint_cure, + gdouble db_exposure, + DodgeBurnType type, + DodgeBurnMode mode, + GimpLut *lut, + GimpDrawable *drawable); + +static gfloat dodgeburn_highlights_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); +static gfloat dodgeburn_midtones_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); +static gfloat dodgeburn_shadows_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value); + +static void dodgeburn_motion (PaintCore *paint_core, + PaintPressureOptions *pressure_options, + gdouble dodgeburn_exposure, + GimpLut *lut, + GimpDrawable *drawable); +static void dodgeburn_init (PaintCore *paint_cure, + GimpDrawable *drawable); +static void dodgeburn_finish (PaintCore *paint_core, + GimpDrawable *drawable); -/* The dodge burn lookup tables */ -gfloat dodgeburn_highlights (void *, int, int, gfloat); -gfloat dodgeburn_midtones (void *, int, int, gfloat); -gfloat dodgeburn_shadows (void *, int, int, gfloat); /* the dodgeburn tool options */ static DodgeBurnOptions * dodgeburn_options = NULL; /* Non gui function */ -static double non_gui_exposure; +static gdouble non_gui_exposure; static GimpLut *non_gui_lut; -/* Default values */ -#define DODGEBURN_DEFAULT_TYPE DODGE -#define DODGEBURN_DEFAULT_EXPOSURE 50.0 -#define DODGEBURN_DEFAULT_MODE DODGEBURN_HIGHLIGHTS - -static void dodgeburn_motion (PaintCore *, - PaintPressureOptions *, - double, GimpLut *, GimpDrawable *); -static void dodgeburn_init (PaintCore *, GimpDrawable *); -static void dodgeburn_finish (PaintCore *, GimpDrawable *); /* functions */ @@ -198,24 +217,29 @@ dodgeburn_options_new (void) return options; } -void * +static gpointer dodgeburn_paint_func (PaintCore *paint_core, - GimpDrawable *drawable, - int state) + GimpDrawable *drawable, + PaintState state) { switch (state) { case INIT_PAINT: dodgeburn_init (paint_core, drawable); break; + case MOTION_PAINT: dodgeburn_motion (paint_core, dodgeburn_options->paint_options.pressure_options, dodgeburn_options->exposure, dodgeburn_options->lut, drawable); break; + case FINISH_PAINT: dodgeburn_finish (paint_core, drawable); break; + + default: + break; } return NULL; @@ -238,7 +262,8 @@ dodgeburn_init (PaintCore *paint_core, GimpDrawable *drawable) { /* Here we create the luts to do the painting with.*/ - dodgeburn_options->lut = gimp_lut_new(); + dodgeburn_options->lut = gimp_lut_new (); + dodgeburn_make_luts (paint_core, dodgeburn_options->exposure, dodgeburn_options->type, @@ -249,17 +274,17 @@ dodgeburn_init (PaintCore *paint_core, static void dodgeburn_make_luts (PaintCore *paint_core, - double db_exposure, + gdouble db_exposure, DodgeBurnType type, DodgeBurnMode mode, GimpLut *lut, GimpDrawable *drawable) { - GimpLutFunc lut_func; - int nchannels = gimp_drawable_bytes (drawable); + GimpLutFunc lut_func; + gint nchannels = gimp_drawable_bytes (drawable); static gfloat exposure; - exposure = (db_exposure) / 100.0; + exposure = db_exposure / 100.0; /* make the exposure negative if burn for luts*/ if (type == BURN) @@ -281,15 +306,15 @@ dodgeburn_make_luts (PaintCore *paint_core, break; } - gimp_lut_setup_exact (lut, - lut_func, (void *)&exposure, - nchannels); + gimp_lut_setup_exact (lut, + lut_func, (gpointer) &exposure, + nchannels); } static void dodgeburn_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -317,7 +342,7 @@ dodgeburn_modifier_key_func (Tool *tool, break; case GDK_Control_L: case GDK_Control_R: - if ( !(kevent->state & GDK_SHIFT_MASK) ) /* shift enables line draw mode */ + if (! (kevent->state & GDK_SHIFT_MASK)) /* shift enables line draw mode */ { switch (dodgeburn_options->type) { @@ -342,18 +367,18 @@ dodgeburn_modifier_key_func (Tool *tool, static void dodgeburn_cursor_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->toggled = (dodgeburn_options->type == BURN); - paint_core_cursor_update (tool, mevent, gdisp_ptr); + paint_core_cursor_update (tool, mevent, gdisp); } Tool * tools_new_dodgeburn (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! dodgeburn_options) @@ -420,25 +445,26 @@ dodgeburn_motion (PaintCore *paint_core, no paint from this stroke yet) */ { - gint x1, y1, x2, y2; - x1 = CLAMP (area->x, 0, drawable_width (drawable)); - y1 = CLAMP (area->y, 0, drawable_height (drawable)); - x2 = CLAMP (area->x + area->width, 0, drawable_width (drawable)); - y2 = CLAMP (area->y + area->height, 0, drawable_height (drawable)); + gint x1, y1, x2, y2; - if (!(x2 - x1) || !(y2 - y1)) - return; + x1 = CLAMP (area->x, 0, drawable_width (drawable)); + y1 = CLAMP (area->y, 0, drawable_height (drawable)); + x2 = CLAMP (area->x + area->width, 0, drawable_width (drawable)); + y2 = CLAMP (area->y + area->height, 0, drawable_height (drawable)); - /* get the original untouched image */ - orig = paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2); - srcPR.bytes = orig->bytes; - srcPR.x = 0; - srcPR.y = 0; - srcPR.w = x2 - x1; - srcPR.h = y2 - y1; - srcPR.rowstride = srcPR.bytes * orig->width; - srcPR.data = temp_buf_data (orig); - } + if (!(x2 - x1) || !(y2 - y1)) + return; + + /* get the original untouched image */ + orig = paint_core_get_orig_image (paint_core, drawable, x1, y1, x2, y2); + srcPR.bytes = orig->bytes; + srcPR.x = 0; + srcPR.y = 0; + srcPR.w = x2 - x1; + srcPR.h = y2 - y1; + srcPR.rowstride = srcPR.bytes * orig->width; + srcPR.data = temp_buf_data (orig); + } /* tempPR will hold the dodgeburned region*/ tempPR.bytes = srcPR.bytes; @@ -482,10 +508,10 @@ dodgeburn_motion (PaintCore *paint_core, g_free (temp_data); } -static void * +static gpointer dodgeburn_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { dodgeburn_motion (paint_core, &non_gui_pressure_options, non_gui_exposure, non_gui_lut, drawable); @@ -495,13 +521,13 @@ dodgeburn_non_gui_paint_func (PaintCore *paint_core, gboolean dodgeburn_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - double exposure = DODGEBURN_DEFAULT_TYPE; - DodgeBurnType type = DODGEBURN_DEFAULT_TYPE; - DodgeBurnMode mode = DODGEBURN_DEFAULT_MODE; - DodgeBurnOptions *options = dodgeburn_options; + gdouble exposure = DODGEBURN_DEFAULT_TYPE; + DodgeBurnType type = DODGEBURN_DEFAULT_TYPE; + DodgeBurnMode mode = DODGEBURN_DEFAULT_MODE; + DodgeBurnOptions *options = dodgeburn_options; if (options) { @@ -510,18 +536,19 @@ dodgeburn_non_gui_default (GimpDrawable *drawable, mode = dodgeburn_options->mode; } - return dodgeburn_non_gui (drawable, exposure, type, mode, num_strokes, stroke_array); + return dodgeburn_non_gui (drawable, exposure, type, mode, + num_strokes, stroke_array); } gboolean dodgeburn_non_gui (GimpDrawable *drawable, - double exposure, + gdouble exposure, DodgeBurnType type, DodgeBurnMode mode, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -569,15 +596,15 @@ dodgeburn_non_gui (GimpDrawable *drawable, } static gfloat -dodgeburn_highlights_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_highlights_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat factor = 1.0 + exposure * (.333333); - + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat factor = 1.0 + exposure * (.333333); + if ((nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) return value; @@ -586,14 +613,14 @@ dodgeburn_highlights_lut_func (void *user_data, } static gfloat -dodgeburn_midtones_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_midtones_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat factor; + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat factor; if ((nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) @@ -603,19 +630,20 @@ dodgeburn_midtones_lut_func (void *user_data, factor = 1.0 - exposure * (.333333); else factor = 1/(1.0 + exposure); + return pow (value, factor); } static gfloat -dodgeburn_shadows_lut_func (void *user_data, - int nchannels, - int channel, - gfloat value) +dodgeburn_shadows_lut_func (gpointer user_data, + gint nchannels, + gint channel, + gfloat value) { - gfloat * exposure_ptr = (gfloat *)user_data; - gfloat exposure = *exposure_ptr; - gfloat new_value; - gfloat factor; + gfloat *exposure_ptr = (gfloat *) user_data; + gfloat exposure = *exposure_ptr; + gfloat new_value; + gfloat factor; if ( (nchannels == 2 && channel == 1) || (nchannels == 4 && channel == 3)) diff --git a/app/tools/gimpdodgeburntool.h b/app/tools/gimpdodgeburntool.h index 341fe445ea..edd02ba64d 100644 --- a/app/tools/gimpdodgeburntool.h +++ b/app/tools/gimpdodgeburntool.h @@ -34,21 +34,18 @@ typedef enum } DodgeBurnMode; -void * dodgeburn_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean dodgeburn_non_gui (GimpDrawable *, - gdouble, - DodgeBurnType, - DodgeBurnMode, - gint, - gdouble *); -gboolean dodgeburn_non_gui_default (GimpDrawable *, - gint, - gdouble *); +gboolean dodgeburn_non_gui (GimpDrawable *drawable, + gdouble exposure, + DodgeBurnType type, + DodgeBurnMode mode, + gint num_strokes, + gdouble *stroke_array); +gboolean dodgeburn_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_dodgeburn (void); -void tools_free_dodgeburn (Tool *); +void tools_free_dodgeburn (Tool *tool); #endif /* __DODGEBURN_H__ */ diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c index ab759aa00c..dd68019c65 100644 --- a/app/tools/gimpeditselectiontool.c +++ b/app/tools/gimpeditselectiontool.c @@ -127,15 +127,12 @@ edit_selection_snap (GDisplay *gdisp, void init_edit_selection (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, GdkEventButton *bevent, EditType edit_type) { - GDisplay *gdisp; Layer *layer; - gint x, y; - - gdisp = (GDisplay *) gdisp_ptr; + gint x, y; undo_push_group_start (gdisp->gimage, LAYER_DISPLACE_UNDO); @@ -218,15 +215,12 @@ init_edit_selection (Tool *tool, void edit_selection_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { gint x; gint y; - GDisplay *gdisp; Layer *layer; - gdisp = (GDisplay *) gdisp_ptr; - /* resume the current selection and ungrab the pointer */ selection_resume (gdisp->select); @@ -312,11 +306,10 @@ edit_selection_button_release (Tool *tool, void edit_selection_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - gchar offset[STATUSBAR_SIZE]; - gdouble lastmotion_x, lastmotion_y; + gchar offset[STATUSBAR_SIZE]; + gdouble lastmotion_x, lastmotion_y; if (tool->state != ACTIVE) { @@ -324,8 +317,6 @@ edit_selection_motion (Tool *tool, return; } - gdisp = (GDisplay *) gdisp_ptr; - gdk_flush (); draw_core_pause (edit_select.core, tool); @@ -521,7 +512,7 @@ edit_selection_draw (Tool *tool) gint off_x, off_y; GdkSegment *segs_copy; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; select = gdisp->select; switch (edit_select.edit_type) @@ -637,7 +628,7 @@ edit_selection_draw (Tool *tool) void edit_selection_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -663,11 +654,8 @@ edit_selection_control (Tool *tool, void edit_selection_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - - gdisp = (GDisplay *) gdisp_ptr; gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_CURSOR, TOOL_TYPE_NONE, CURSOR_MODIFIER_MOVE, @@ -770,10 +758,9 @@ process_event_queue_keys (GdkEventKey *kevent, void edit_sel_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { gint inc_x, inc_y, mask_inc_x, mask_inc_y; - GDisplay *gdisp; Layer *layer; Layer *floating_layer; GSList *layer_list; @@ -781,8 +768,6 @@ edit_sel_arrow_keys_func (Tool *tool, layer = NULL; - gdisp = (GDisplay *) gdisp_ptr; - inc_x = process_event_queue_keys (kevent, GDK_Left, 0, -1, diff --git a/app/tools/gimpeditselectiontool.h b/app/tools/gimpeditselectiontool.h index c1e8914d71..1486849289 100644 --- a/app/tools/gimpeditselectiontool.h +++ b/app/tools/gimpeditselectiontool.h @@ -30,26 +30,26 @@ typedef enum void init_edit_selection (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, GdkEventButton *bevent, EditType edit_type); -void edit_selection_button_release (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -void edit_selection_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); -void edit_selection_control (Tool *tool, - ToolAction action, - gpointer gdisp_ptr); -void edit_selection_cursor_update (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); +void edit_selection_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void edit_selection_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +void edit_selection_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); +void edit_selection_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); void edit_selection_draw (Tool *tool); void edit_sel_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr); + GDisplay *gdisp); #endif /* __EDIT_SELECTION_H__ */ diff --git a/app/tools/gimpellipseselecttool.c b/app/tools/gimpellipseselecttool.c index b65dd27a06..a4235d237a 100644 --- a/app/tools/gimpellipseselecttool.c +++ b/app/tools/gimpellipseselecttool.c @@ -93,12 +93,10 @@ ellipse_select (GimpImage *gimage, void ellipse_select_draw (Tool *tool) { - GDisplay *gdisp; EllipseSelect *ellipse_sel; gint x1, y1; gint x2, y2; - gdisp = (GDisplay *) tool->gdisp_ptr; ellipse_sel = (EllipseSelect *) tool->private; x1 = MIN (ellipse_sel->x, ellipse_sel->x + ellipse_sel->w); @@ -106,8 +104,8 @@ ellipse_select_draw (Tool *tool) x2 = MAX (ellipse_sel->x, ellipse_sel->x + ellipse_sel->w); y2 = MAX (ellipse_sel->y, ellipse_sel->y + ellipse_sel->h); - gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); - gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); + gdisplay_transform_coords (tool->gdisp, x1, y1, &x1, &y1, 0); + gdisplay_transform_coords (tool->gdisp, x2, y2, &x2, &y2, 0); gdk_draw_arc (ellipse_sel->core->win, ellipse_sel->core->gc, 0, diff --git a/app/tools/gimperasertool.c b/app/tools/gimperasertool.c index 1ffa616c08..5467be7ede 100644 --- a/app/tools/gimperasertool.c +++ b/app/tools/gimperasertool.c @@ -42,7 +42,7 @@ #include "libgimp/gimpintl.h" -/* Defaults */ +/* Defaults */ #define ERASER_DEFAULT_HARD FALSE #define ERASER_DEFAULT_INCREMENTAL FALSE #define ERASER_DEFAULT_ANTI_ERASE FALSE @@ -50,6 +50,7 @@ /* the eraser structures */ typedef struct _EraserOptions EraserOptions; + struct _EraserOptions { PaintOptions paint_options; @@ -64,6 +65,18 @@ struct _EraserOptions }; +/* forward function declarations */ +static gpointer eraser_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void eraser_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + gboolean hard, + gboolean incremental, + gboolean anti_erase); + + /* the eraser tool options */ static EraserOptions *eraser_options = NULL; @@ -72,11 +85,6 @@ static gboolean non_gui_hard; static gboolean non_gui_incremental; static gboolean non_gui_anti_erase; -/* forward function declarations */ -static void eraser_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, - gboolean, gboolean, gboolean); - /* functions */ @@ -137,7 +145,7 @@ eraser_options_new (void) static void eraser_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -164,10 +172,10 @@ eraser_modifier_key_func (Tool *tool, } -void * +static gpointer eraser_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -196,8 +204,8 @@ eraser_paint_func (PaintCore *paint_core, Tool * tools_new_eraser (void) { - Tool * tool; - PaintCore * private; + Tool *tool; + PaintCore *private; /* The tool options */ if (! eraser_options) @@ -274,10 +282,10 @@ eraser_motion (PaintCore *paint_core, } -static void * +static gpointer eraser_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { eraser_motion (paint_core, drawable, &non_gui_pressure_options, @@ -288,8 +296,8 @@ eraser_non_gui_paint_func (PaintCore *paint_core, gboolean eraser_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gboolean hardness = ERASER_DEFAULT_HARD; gboolean method = ERASER_DEFAULT_INCREMENTAL; @@ -310,13 +318,13 @@ eraser_non_gui_default (GimpDrawable *drawable, gboolean eraser_non_gui (GimpDrawable *drawable, - int num_strokes, - double *stroke_array, - int hardness, - int method, - int anti_erase) + gint num_strokes, + gdouble *stroke_array, + gint hardness, + gint method, + gboolean anti_erase) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) @@ -351,6 +359,6 @@ eraser_non_gui (GimpDrawable *drawable, paint_core_cleanup (); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/tools/gimperasertool.h b/app/tools/gimperasertool.h index 5a94a4c044..35eb35d4e2 100644 --- a/app/tools/gimperasertool.h +++ b/app/tools/gimperasertool.h @@ -20,21 +20,18 @@ #define __ERASER_H__ -void * eraser_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean eraser_non_gui (GimpDrawable *, - gint , - gdouble *, - gint , - gint , - gint ); -gboolean eraser_non_gui_default (GimpDrawable *, - gint , - gdouble *); +gboolean eraser_non_gui (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array, + gint hardness, + gint method, + gboolean anti_erase); +gboolean eraser_non_gui_default (GimpDrawable *paint_core, + gint num_strokes, + gdouble *stroke_array); -Tool * tools_new_eraser (void ); -void tools_free_eraser (Tool *); +Tool * tools_new_eraser (void); +void tools_free_eraser (Tool *tool); #endif /* __ERASER_H__ */ diff --git a/app/tools/gimpfliptool.c b/app/tools/gimpfliptool.c index c6db3abda3..b3ff8eba49 100644 --- a/app/tools/gimpfliptool.c +++ b/app/tools/gimpfliptool.c @@ -61,6 +61,16 @@ struct _FlipOptions GtkWidget *type_w[2]; }; + +/* local function prototypes */ + +static TileManager * flip_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + + +/* private variables */ + static FlipOptions *flip_options = NULL; /* functions */ @@ -117,7 +127,7 @@ flip_options_new (void) static void flip_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -139,17 +149,15 @@ flip_modifier_key_func (Tool *tool, break; } } - -TileManager * + +static TileManager * flip_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { TransformCore *transform_core; - GDisplay *gdisp; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (state) { @@ -179,14 +187,11 @@ flip_tool_transform (Tool *tool, static void flip_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; GimpDrawable *drawable; GdkCursorType ctype = GIMP_BAD_CURSOR; - gdisp = (GDisplay *) gdisp_ptr; - if ((drawable = gimp_image_active_drawable (gdisp->gimage))) { gint x, y; @@ -231,10 +236,10 @@ tools_new_flip (void) tools_register (FLIP, (ToolOptions *) flip_options); } - tool = transform_core_new (FLIP, FALSE); + tool = transform_core_new (FLIP, FALSE); private = tool->private; - private->trans_func = flip_tool_transform; + private->trans_func = flip_tool_transform; private->trans_info[FLIP_INFO] = -1.0; tool->modifier_key_func = flip_modifier_key_func; diff --git a/app/tools/gimpfliptool.h b/app/tools/gimpfliptool.h index 0f74a6bb3b..b0d3fe71c0 100644 --- a/app/tools/gimpfliptool.h +++ b/app/tools/gimpfliptool.h @@ -20,10 +20,6 @@ #define __FLIP_TOOL_H__ -TileManager * flip_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); - TileManager * flip_tool_flip (GimpImage *gimage, GimpDrawable *drawable, TileManager *orig, diff --git a/app/tools/gimpfreeselecttool.c b/app/tools/gimpfreeselecttool.c index fb7de4eb17..911826a8b6 100644 --- a/app/tools/gimpfreeselecttool.c +++ b/app/tools/gimpfreeselecttool.c @@ -51,6 +51,7 @@ /* the free selection structures */ typedef struct _FreeSelect FreeSelect; + struct _FreeSelect { DrawCore *core; /* Core select object */ @@ -65,6 +66,18 @@ struct _FreeSelect }; +/* local function prototypes */ + +static void free_select_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void free_select_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void free_select_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); + /* the free selection tool options */ static SelectionOptions * free_options = NULL; @@ -157,15 +170,13 @@ free_select (GImage *gimage, } } -void +static void free_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; FreeSelect *free_sel; - gdisp = (GDisplay *) gdisp_ptr; free_sel = (FreeSelect *) tool->private; gdk_pointer_grab (gdisp->canvas->window, FALSE, @@ -175,15 +186,15 @@ free_select_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; switch (free_sel->op) { case SELECTION_MOVE_MASK: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; case SELECTION_MOVE: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; default: break; @@ -197,17 +208,15 @@ free_select_button_press (Tool *tool, tool); } -void +static void free_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FreeSelect *free_sel; ScanConvertPoint *pts; - GDisplay *gdisp; gint i; - gdisp = (GDisplay *) gdisp_ptr; free_sel = (FreeSelect *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -251,15 +260,13 @@ free_select_button_release (Tool *tool, } } -void +static void free_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FreeSelect *free_sel; - GDisplay *gdisp; - gdisp = (GDisplay *) gdisp_ptr; free_sel = (FreeSelect *) tool->private; /* needed for immediate cursor update on modifier event */ @@ -273,7 +280,7 @@ free_select_motion (Tool *tool, { free_sel->op = SELECTION_REPLACE; - rect_select_cursor_update (tool, mevent, gdisp_ptr); + rect_select_cursor_update (tool, mevent, gdisp); } if (add_point (free_sel->num_pts, mevent->x, mevent->y)) @@ -291,7 +298,7 @@ free_select_motion (Tool *tool, static void free_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { FreeSelect *free_sel; diff --git a/app/tools/gimpfreeselecttool.h b/app/tools/gimpfreeselecttool.h index 98fd07dfd1..11b148c231 100644 --- a/app/tools/gimpfreeselecttool.h +++ b/app/tools/gimpfreeselecttool.h @@ -20,19 +20,6 @@ #define __FREE_SELECT_H__ -/* free select action functions */ - -void free_select_button_press (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -void free_select_button_release (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -void free_select_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); - - /* free select functions */ void free_select (GimpImage *gimage, diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c index 906acff785..8180462164 100644 --- a/app/tools/gimpfuzzyselecttool.c +++ b/app/tools/gimpfuzzyselecttool.c @@ -71,6 +71,27 @@ struct _FuzzySelect }; +/* fuzzy select action functions */ +static void fuzzy_select_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void fuzzy_select_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void fuzzy_select_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void fuzzy_select_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void fuzzy_select_draw (Tool *tool); + +static GdkSegment * fuzzy_select_calculate (Tool *tool, + GDisplay *gdisp, + gint *nsegs); + + /* the fuzzy selection tool options */ static SelectionOptions *fuzzy_options = NULL; @@ -81,18 +102,6 @@ static gint num_segs = 0; Channel * fuzzy_mask = NULL; -/* fuzzy select action functions */ -static void fuzzy_select_button_press (Tool *, GdkEventButton *, gpointer); -static void fuzzy_select_button_release (Tool *, GdkEventButton *, gpointer); -static void fuzzy_select_motion (Tool *, GdkEventMotion *, gpointer); -static void fuzzy_select_control (Tool *, ToolAction, gpointer); - -static void fuzzy_select_draw (Tool *); - -/* fuzzy select action functions */ -static GdkSegment * fuzzy_select_calculate (Tool *, void *, int *); - - /*************************************/ /* Fuzzy selection apparatus */ @@ -390,12 +399,10 @@ fuzzy_select (GImage *gimage, static void fuzzy_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; FuzzySelect *fuzzy_sel; - gdisp = (GDisplay *) gdisp_ptr; fuzzy_sel = (FuzzySelect *) tool->private; fuzzy_sel->x = bevent->x; @@ -411,21 +418,21 @@ fuzzy_select_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; if (fuzzy_sel->op == SELECTION_MOVE_MASK) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; } else if (fuzzy_sel->op == SELECTION_MOVE) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; } /* calculate the region boundary */ - segs = fuzzy_select_calculate (tool, gdisp_ptr, &num_segs); + segs = fuzzy_select_calculate (tool, gdisp, &num_segs); draw_core_start (fuzzy_sel->core, gdisp->canvas->window, @@ -435,13 +442,11 @@ fuzzy_select_button_press (Tool *tool, static void fuzzy_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; - GDisplay *gdisp; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; fuzzy_sel = (FuzzySelect *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -471,13 +476,13 @@ fuzzy_select_button_release (Tool *tool, static void fuzzy_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; GdkSegment *new_segs; - gint num_new_segs; - gint diff_x, diff_y; - gdouble diff; + gint num_new_segs; + gint diff_x, diff_y; + gdouble diff; static guint last_time = 0; @@ -505,7 +510,7 @@ fuzzy_select_motion (Tool *tool, fuzzy_sel->first_threshold + diff); /* calculate the new fuzzy boundary */ - new_segs = fuzzy_select_calculate (tool, gdisp_ptr, &num_new_segs); + new_segs = fuzzy_select_calculate (tool, gdisp, &num_new_segs); /* stop the current boundary */ draw_core_pause (fuzzy_sel->core, tool); @@ -522,24 +527,22 @@ fuzzy_select_motion (Tool *tool, static GdkSegment * -fuzzy_select_calculate (Tool *tool, - void *gdisp_ptr, - gint *nsegs) +fuzzy_select_calculate (Tool *tool, + GDisplay *gdisp, + gint *nsegs) { PixelRegion maskPR; FuzzySelect *fuzzy_sel; - GDisplay *gdisp; Channel *new; GdkSegment *segs; BoundSeg *bsegs; GimpDrawable *drawable; - gint i; - gint x, y; - gboolean use_offsets; + gint i; + gint x, y; + gboolean use_offsets; fuzzy_sel = (FuzzySelect *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; - drawable = gimp_image_active_drawable (gdisp->gimage); + drawable = gimp_image_active_drawable (gdisp->gimage); gimp_add_busy_cursors (); @@ -605,7 +608,7 @@ fuzzy_select_draw (Tool *tool) static void fuzzy_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; diff --git a/app/tools/gimpfuzzyselecttool.h b/app/tools/gimpfuzzyselecttool.h index 0211a4b81f..42533a19db 100644 --- a/app/tools/gimpfuzzyselecttool.h +++ b/app/tools/gimpfuzzyselecttool.h @@ -20,14 +20,6 @@ #define __FUZZY_SELECT_H__ -extern Channel *fuzzy_mask; - - -/* fuzzy select functions */ -Tool * tools_new_fuzzy_select (void); -void tools_free_fuzzy_select (Tool *tool); - -/* functions */ Channel * find_contiguous_region (GimpImage *gimage, GimpDrawable *drawable, gboolean antialias, @@ -41,5 +33,11 @@ void fuzzy_select (GimpImage *gimage, gboolean feather, gdouble feather_radius); +Tool * tools_new_fuzzy_select (void); +void tools_free_fuzzy_select (Tool *tool); + + +extern Channel *fuzzy_mask; + #endif /* __FUZZY_SELECT_H__ */ diff --git a/app/tools/gimphistogramtool.c b/app/tools/gimphistogramtool.c index 5cb56d168f..2545e1e05a 100644 --- a/app/tools/gimphistogramtool.c +++ b/app/tools/gimphistogramtool.c @@ -51,23 +51,32 @@ struct _HistogramTool gint x, y; /* coords for last mouse click */ }; + +/* histogram_tool action functions */ +static void histogram_tool_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static HistogramToolDialog * histogram_tool_dialog_new (void); + +static void histogram_tool_close_callback (GtkWidget *widget, + gpointer data); +static void histogram_tool_channel_callback (GtkWidget *widget, + gpointer data); +static void histogram_tool_gradient_draw (GtkWidget *gdisp, + gint channel); + +static void histogram_tool_dialog_update (HistogramToolDialog *htd, + gint start, + gint end); + + /* the histogram tool options */ static ToolOptions * histogram_tool_options = NULL; /* the histogram tool dialog */ static HistogramToolDialog * histogram_tool_dialog = NULL; -/* histogram_tool action functions */ -static void histogram_tool_control (Tool *, ToolAction, gpointer); - -static HistogramToolDialog * histogram_tool_dialog_new (void); - -static void histogram_tool_close_callback (GtkWidget *, gpointer); -static void histogram_tool_channel_callback (GtkWidget *, gpointer); -static void histogram_tool_gradient_draw (GtkWidget *, gint); - -static void histogram_tool_dialog_update (HistogramToolDialog *, - gint, gint); /* histogram_tool machinery */ @@ -78,13 +87,13 @@ histogram_tool_histogram_range (HistogramWidget *widget, gpointer data) { HistogramToolDialog *htd; - gdouble pixels; - gdouble count; + gdouble pixels; + gdouble count; htd = (HistogramToolDialog *) data; if (htd == NULL || htd->hist == NULL || - gimp_histogram_nchannels(htd->hist) <= 0) + gimp_histogram_nchannels (htd->hist) <= 0) return; pixels = gimp_histogram_get_count (htd->hist, 0, 255); @@ -148,7 +157,7 @@ histogram_tool_dialog_update (HistogramToolDialog *htd, static void histogram_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -171,8 +180,8 @@ histogram_tool_control (Tool *tool, Tool * tools_new_histogram_tool (void) { - Tool * tool; - HistogramTool * private; + Tool *tool; + HistogramTool *private; /* The tool options */ if (! histogram_tool_options) @@ -181,7 +190,7 @@ tools_new_histogram_tool (void) tools_register (HISTOGRAM, histogram_tool_options); } - tool = tools_new_tool (HISTOGRAM); + tool = tools_new_tool (HISTOGRAM); private = g_new0 (HistogramTool, 1); tool->scroll_lock = TRUE; /* Disallow scrolling */ @@ -402,7 +411,7 @@ histogram_tool_close_callback (GtkWidget *widget, gimp_dialog_hide (htd->shell); - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -426,7 +435,7 @@ histogram_tool_gradient_draw (GtkWidget *gradient, { guchar buf[HISTOGRAM_WIDTH * 3]; guchar r, g, b; - gint i; + gint i; r = g = b = 0; switch (channel) @@ -458,5 +467,3 @@ histogram_tool_gradient_draw (GtkWidget *gradient, gtk_widget_queue_draw (gradient); } - - diff --git a/app/tools/gimphistogramtool.h b/app/tools/gimphistogramtool.h index 825d44e25a..ae4076b462 100644 --- a/app/tools/gimphistogramtool.h +++ b/app/tools/gimphistogramtool.h @@ -48,6 +48,7 @@ struct _HistogramToolDialog gint color; }; + /* histogram_tool functions */ Tool * tools_new_histogram_tool (void); void tools_free_histogram_tool (Tool *tool); diff --git a/app/tools/gimphuesaturationtool.c b/app/tools/gimphuesaturationtool.c index 0caf2f0a6f..fde7e3de2b 100644 --- a/app/tools/gimphuesaturationtool.c +++ b/app/tools/gimphuesaturationtool.c @@ -43,8 +43,8 @@ #define HUE_PARTITION_MASK GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK #define SLIDER_WIDTH 200 -#define DA_WIDTH 40 -#define DA_HEIGHT 20 +#define DA_WIDTH 40 +#define DA_HEIGHT 20 #define HUE_PARTITION 0x0 #define HUE_SLIDER 0x1 @@ -62,6 +62,38 @@ struct _HueSaturation gint x, y; /* coords for last mouse click */ }; + +/* hue saturation action functions */ +static void hue_saturation_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static HueSaturationDialog * hue_saturation_dialog_new (void); + +static void hue_saturation_update (HueSaturationDialog *hsd, + gint); +static void hue_saturation_preview (HueSaturationDialog *hsd); +static void hue_saturation_reset_callback (GtkWidget *, + gpointer); +static void hue_saturation_ok_callback (GtkWidget *, + gpointer); +static void hue_saturation_cancel_callback (GtkWidget *, + gpointer); +static void hue_saturation_partition_callback (GtkWidget *, + gpointer); +static void hue_saturation_preview_update (GtkWidget *, + gpointer); +static void hue_saturation_hue_adjustment_update (GtkAdjustment *, + gpointer); +static void hue_saturation_lightness_adjustment_update (GtkAdjustment *, + gpointer); +static void hue_saturation_saturation_adjustment_update (GtkAdjustment *, + gpointer); +static gint hue_saturation_hue_partition_events (GtkWidget *, + GdkEvent *, + HueSaturationDialog *hsd); + + /* the hue-saturation tool options */ static ToolOptions *hue_saturation_options = NULL; @@ -82,27 +114,6 @@ static gint default_colors[6][3] = { 255, 0, 255 } }; -/* hue saturation action functions */ -static void hue_saturation_control (Tool *, ToolAction, gpointer); - -static HueSaturationDialog * hue_saturation_dialog_new (void); - -static void hue_saturation_update (HueSaturationDialog *, - gint); -static void hue_saturation_preview (HueSaturationDialog *); -static void hue_saturation_reset_callback (GtkWidget *, gpointer); -static void hue_saturation_ok_callback (GtkWidget *, gpointer); -static void hue_saturation_cancel_callback (GtkWidget *, gpointer); -static void hue_saturation_partition_callback (GtkWidget *, gpointer); -static void hue_saturation_preview_update (GtkWidget *, gpointer); -static void hue_saturation_hue_adjustment_update (GtkAdjustment *, - gpointer); -static void hue_saturation_lightness_adjustment_update (GtkAdjustment *, - gpointer); -static void hue_saturation_saturation_adjustment_update (GtkAdjustment *, - gpointer); -static gint hue_saturation_hue_partition_events (GtkWidget *, GdkEvent *, - HueSaturationDialog *); /* hue saturation machinery */ @@ -223,7 +234,7 @@ hue_saturation (PixelRegion *srcPR, static void hue_saturation_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -691,7 +702,7 @@ hue_saturation_ok_callback (GtkWidget *widget, active_tool->preserve = TRUE; if (!hsd->preview) - image_map_apply (hsd->image_map, hue_saturation, (void *) hsd); + image_map_apply (hsd->image_map, hue_saturation, (gpointer) hsd); if (hsd->image_map) image_map_commit (hsd->image_map); @@ -700,7 +711,7 @@ hue_saturation_ok_callback (GtkWidget *widget, hsd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -724,7 +735,7 @@ hue_saturation_cancel_callback (GtkWidget *widget, hsd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/gimphuesaturationtool.h b/app/tools/gimphuesaturationtool.h index 80ee176884..5fec88fa53 100644 --- a/app/tools/gimphuesaturationtool.h +++ b/app/tools/gimphuesaturationtool.h @@ -54,6 +54,7 @@ struct _HueSaturationDialog gboolean preview; }; + Tool * tools_new_hue_saturation (void); void tools_free_hue_saturation (Tool *tool); diff --git a/app/tools/gimpinktool.c b/app/tools/gimpinktool.c index 3673948f53..cf59f94716 100644 --- a/app/tools/gimpinktool.c +++ b/app/tools/gimpinktool.c @@ -57,7 +57,13 @@ /* the Ink structures */ -typedef Blob *(*BlobFunc) (gdouble, gdouble, gdouble, gdouble, gdouble, gdouble); +typedef Blob * (* BlobFunc) (gdouble, + gdouble, + gdouble, + gdouble, + gdouble, + gdouble); + typedef struct _InkTool InkTool; @@ -88,8 +94,8 @@ typedef struct _BrushWidget BrushWidget; struct _BrushWidget { - GtkWidget *widget; - gboolean state; + GtkWidget *widget; + gboolean state; }; typedef struct _InkOptions InkOptions; @@ -130,95 +136,109 @@ struct _InkOptions }; -/* the ink tool options */ -static InkOptions * ink_options = NULL; +/* local function prototypes */ + +static void ink_button_press (Tool *tool, + GdkEventButton *mevent, + GDisplay *gdisp); +static void ink_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void ink_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void ink_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void ink_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void time_smoother_add (InkTool *ink_tool, + guint32 value); +static gdouble time_smoother_result (InkTool *ink_tool); +static void time_smoother_init (InkTool *ink_tool, + guint32 initval); +static void dist_smoother_add (InkTool *ink_tool, + gdouble value); +static gdouble dist_smoother_result (InkTool *ink_tool); +static void dist_smoother_init (InkTool *ink_tool, + gdouble initval); + +static void ink_init (InkTool *ink_tool, + GimpDrawable *drawable, + gdouble x, + gdouble y); +static void ink_finish (InkTool *ink_tool, + GimpDrawable *drawable, + gint tool_id); +static void ink_cleanup (void); + +static void ink_type_update (GtkWidget *radio_button, + BlobFunc function); +static GdkPixmap * blob_pixmap (GdkColormap *colormap, + GdkVisual *visual, + BlobFunc function); +static void paint_blob (GdkDrawable *drawable, + GdkGC *gc, + Blob *blob); + +/* Rendering functions */ +static void ink_set_paint_area (InkTool *ink_tool, + GimpDrawable *drawable, + Blob *blob); +static void ink_paste (InkTool *ink_tool, + GimpDrawable *drawable, + Blob *blob); + +static void ink_to_canvas_tiles (InkTool *ink_tool, + Blob *blob, + guchar *color); + +static void ink_set_undo_tiles (GimpDrawable *drawable, + gint x, + gint y, + gint w, + gint h); +static void ink_set_canvas_tiles (gint x, + gint y, + gint w, + gint h); + +/* Brush pseudo-widget callbacks */ +static void brush_widget_active_rect (BrushWidget *brush_widget, + GtkWidget *widget, + GdkRectangle *rect); +static void brush_widget_realize (GtkWidget *widget); +static void brush_widget_expose (GtkWidget *widget, + GdkEventExpose *event, + BrushWidget *brush_widget); +static void brush_widget_button_press (GtkWidget *widget, + GdkEventButton *event, + BrushWidget *brush_widget); +static void brush_widget_button_release (GtkWidget *widget, + GdkEventButton *event, + BrushWidget *brush_widget); +static void brush_widget_motion_notify (GtkWidget *widget, + GdkEventMotion *event, + BrushWidget *brush_widget); + /* local variables */ +/* the ink tool options */ +static InkOptions *ink_options = NULL; + /* undo blocks variables */ -static TileManager * undo_tiles = NULL; +static TileManager *undo_tiles = NULL; /* Tiles used to render the stroke at 1 byte/pp */ -static TileManager * canvas_tiles = NULL; +static TileManager *canvas_tiles = NULL; /* Flat buffer that is used to used to render the dirty region * for composition onto the destination drawable */ -static TempBuf * canvas_buf = NULL; - - -/* local function prototypes */ - -static void ink_button_press (Tool *, GdkEventButton *, gpointer); -static void ink_button_release (Tool *, GdkEventButton *, gpointer); -static void ink_motion (Tool *, GdkEventMotion *, gpointer); -static void ink_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void ink_control (Tool *, ToolAction, gpointer); - -static void time_smoother_add (InkTool* ink_tool, guint32 value); -static gdouble time_smoother_result (InkTool* ink_tool); -static void time_smoother_init (InkTool* ink_tool, guint32 initval); -static void dist_smoother_add (InkTool* ink_tool, gdouble value); -static gdouble dist_smoother_result (InkTool* ink_tool); -static void dist_smoother_init (InkTool* ink_tool, gdouble initval); - -static void ink_init (InkTool *ink_tool, - GimpDrawable *drawable, - double x, - double y); -static void ink_finish (InkTool *ink_tool, - GimpDrawable *drawable, - int tool_id); -static void ink_cleanup (void); - -static void ink_type_update (GtkWidget *radio_button, - BlobFunc function); -static GdkPixmap *blob_pixmap (GdkColormap *colormap, - GdkVisual *visual, - BlobFunc function); -static void paint_blob (GdkDrawable *drawable, - GdkGC *gc, - Blob *blob); - -/* Rendering functions */ -static void ink_set_paint_area (InkTool *ink_tool, - GimpDrawable *drawable, - Blob *blob); -static void ink_paste (InkTool *ink_tool, - GimpDrawable *drawable, - Blob *blob); - -static void ink_to_canvas_tiles (InkTool *ink_tool, - Blob *blob, - guchar *color); - -static void ink_set_undo_tiles (GimpDrawable *drawable, - int x, - int y, - int w, - int h); -static void ink_set_canvas_tiles(int x, - int y, - int w, - int h); - -/* Brush pseudo-widget callbacks */ -static void brush_widget_active_rect (BrushWidget *brush_widget, - GtkWidget *w, - GdkRectangle *rect); -static void brush_widget_realize (GtkWidget *w); -static void brush_widget_expose (GtkWidget *w, - GdkEventExpose *event, - BrushWidget *brush_widget); -static void brush_widget_button_press (GtkWidget *w, - GdkEventButton *event, - BrushWidget *brush_widget); -static void brush_widget_button_release (GtkWidget *w, - GdkEventButton *event, - BrushWidget *brush_widget); -static void brush_widget_motion_notify (GtkWidget *w, - GdkEventMotion *event, - BrushWidget *brush_widget); +static TempBuf *canvas_buf = NULL; /* functions */ @@ -798,15 +818,13 @@ ink_pen_ellipse (gdouble x_center, gdouble y_center, static void ink_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { gdouble x, y; - GDisplay *gdisp; InkTool *ink_tool; GimpDrawable *drawable; Blob *b; - gdisp = (GDisplay *) gdisp_ptr; ink_tool = (InkTool *) tool->private; /* Keep the coordinates of the target */ @@ -816,8 +834,8 @@ ink_button_press (Tool *tool, ink_init (ink_tool, drawable, x, y); - tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->state = ACTIVE; + tool->gdisp = gdisp; tool->paused_count = 0; /* pause the current selection and grab the pointer */ @@ -834,7 +852,7 @@ ink_button_press (Tool *tool, GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; b = ink_pen_ellipse (x, y, @@ -856,14 +874,12 @@ ink_button_press (Tool *tool, static void ink_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - GImage * gimage; - InkTool * ink_tool; + GImage *gimage; + InkTool *ink_tool; - gdisp = (GDisplay *) gdisp_ptr; - gimage = gdisp->gimage; + gimage = gdisp->gimage; ink_tool = (InkTool *) tool->private; /* resume the current selection and ungrab the pointer */ @@ -965,21 +981,18 @@ time_smoother_add (InkTool* ink_tool, guint32 value) static void ink_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - InkTool *ink_tool; + InkTool *ink_tool; GimpDrawable *drawable; - Blob *b, *blob_union; + Blob *b, *blob_union; - double x, y; - double pressure; - double velocity; - double dist; + gdouble x, y; + gdouble pressure; + gdouble velocity; + gdouble dist; gdouble lasttime, thistime; - - gdisp = (GDisplay *) gdisp_ptr; ink_tool = (InkTool *) tool->private; gdisplay_untransform_coords_f (gdisp, mevent->x, mevent->y, &x, &y, TRUE); @@ -1034,14 +1047,11 @@ ink_motion (Tool *tool, static void ink_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + gint x, y; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -1073,7 +1083,7 @@ ink_cursor_update (Tool *tool, static void ink_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { InkTool *ink_tool; @@ -1099,8 +1109,10 @@ ink_control (Tool *tool, } static void -ink_init (InkTool *ink_tool, GimpDrawable *drawable, - double x, double y) +ink_init (InkTool *ink_tool, + GimpDrawable *drawable, + gdouble x, + gdouble y) { /* free the block structures */ if (undo_tiles) @@ -1123,7 +1135,9 @@ ink_init (InkTool *ink_tool, GimpDrawable *drawable, } static void -ink_finish (InkTool *ink_tool, GimpDrawable *drawable, int tool_id) +ink_finish (InkTool *ink_tool, + GimpDrawable *drawable, + gint tool_id) { /* push an undo */ drawable_apply_image (drawable, ink_tool->x1, ink_tool->y1, @@ -1178,9 +1192,9 @@ ink_set_paint_area (InkTool *ink_tool, GimpDrawable *drawable, Blob *blob) { - int x, y, width, height; - int x1, y1, x2, y2; - int bytes; + gint x, y, width, height; + gint x1, y1, x2, y2; + gint bytes; blob_bounds (blob, &x, &y, &width, &height); @@ -1203,10 +1217,12 @@ enum { ROW_START, ROW_STOP }; /* The insertion sort here, for SUBSAMPLE = 8, tends to beat out * qsort() by 4x with CFLAGS=-O2, 2x with CFLAGS=-g */ -static void insert_sort (int *data, int n) +static void +insert_sort (gint *data, + gint n) { - int i, j, k; - int tmp1, tmp2; + gint i, j, k; + gint tmp1, tmp2; for (i=2; i<2*n; i+=2) { @@ -1230,7 +1246,7 @@ static void insert_sort (int *data, int n) static void fill_run (guchar *dest, guchar alpha, - int w) + gint w) { if (alpha == 255) { @@ -1247,17 +1263,20 @@ fill_run (guchar *dest, } static void -render_blob_line (Blob *blob, guchar *dest, - int x, int y, int width) +render_blob_line (Blob *blob, + guchar *dest, + gint x, + gint y, + gint width) { - int buf[4*SUBSAMPLE]; - int *data = buf; - int n = 0; - int i, j; - int current = 0; /* number of filled rows at this point - * in the scan line */ - - int last_x; + gint buf[4*SUBSAMPLE]; + gint *data = buf; + gint n = 0; + gint i, j; + gint current = 0; /* number of filled rows at this point + * in the scan line + */ + gint last_x; /* Sort start and ends for all lines */ @@ -1309,8 +1328,8 @@ render_blob_line (Blob *blob, guchar *dest, last_x = 0; for (i=0; icore = draw_core_new (ink_no_draw); + private->core = draw_core_new (ink_no_draw); private->last_blob = NULL; tool->private = private; @@ -1570,7 +1593,7 @@ tools_new_ink (void) void tools_free_ink (Tool *tool) { - InkTool * ink_tool; + InkTool *ink_tool; ink_tool = (InkTool *) tool->private; diff --git a/app/tools/gimpinktool.h b/app/tools/gimpinktool.h index 3dfb214846..9c35db1c6b 100644 --- a/app/tools/gimpinktool.h +++ b/app/tools/gimpinktool.h @@ -23,6 +23,7 @@ Tool * tools_new_ink (void); void tools_free_ink (Tool *tool); + /* Procedure definition and marshalling function */ extern ProcRecord ink_proc; diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c index cf075959c2..793f3b32f3 100644 --- a/app/tools/gimpiscissorstool.c +++ b/app/tools/gimpiscissorstool.c @@ -133,6 +133,7 @@ struct _iscissors }; typedef struct _IScissorsOptions IScissorsOptions; + struct _IScissorsOptions { SelectionOptions selection_options; @@ -187,7 +188,7 @@ struct _IScissorsOptions /* static variables */ /* where to move on a given link direction */ -static int move [8][2] = +static gint move [8][2] = { { 1, 0 }, { 0, 1 }, @@ -271,57 +272,72 @@ static IScissorsOptions *iscissors_options = NULL; /***********************************************************************/ /* Local function prototypes */ -static void iscissors_button_press (Tool *, GdkEventButton *, gpointer); -static void iscissors_button_release (Tool *, GdkEventButton *, gpointer); -static void iscissors_motion (Tool *, GdkEventMotion *, gpointer); -static void iscissors_oper_update (Tool *, GdkEventMotion *, gpointer); -static void iscissors_modifier_update (Tool *, GdkEventKey *, gpointer); -static void iscissors_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void iscissors_control (Tool *, ToolAction, gpointer); +static void iscissors_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void iscissors_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void iscissors_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void iscissors_oper_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void iscissors_modifier_update (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void iscissors_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void iscissors_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); -static void iscissors_reset (Iscissors *iscissors); -static void iscissors_draw (Tool *tool); +static void iscissors_reset (Iscissors *iscissors); +static void iscissors_draw (Tool *tool); -static TileManager * gradient_map_new (GImage *gimage); +static TileManager * gradient_map_new (GImage *gimage); -static void find_optimal_path (TileManager *gradient_map, - TempBuf *dp_buf, - gint x1, - gint y1, - gint x2, - gint y2, - gint xs, - gint ys); -static void find_max_gradient (Iscissors *iscissors, - GImage *gimage, - gint *x, - gint *y); -static void calculate_curve (Tool *tool, - ICurve *curve); -static void iscissors_draw_curve (GDisplay *gdisp, - Iscissors *iscissors, - ICurve *curve); -static void iscissors_free_icurves (GSList *list); -static void iscissors_free_buffers (Iscissors *iscissors); +static void find_optimal_path (TileManager *gradient_map, + TempBuf *dp_buf, + gint x1, + gint y1, + gint x2, + gint y2, + gint xs, + gint ys); +static void find_max_gradient (Iscissors *iscissors, + GImage *gimage, + gint *x, + gint *y); +static void calculate_curve (Tool *tool, + ICurve *curve); +static void iscissors_draw_curve (GDisplay *gdisp, + Iscissors *iscissors, + ICurve *curve); +static void iscissors_free_icurves (GSList *list); +static void iscissors_free_buffers (Iscissors *iscissors); -static gint mouse_over_vertex (Iscissors *iscissors, - gint x, - gint y); -static gboolean clicked_on_vertex (Tool *tool); -static GSList * mouse_over_curve (Iscissors *iscissors, - gint x, - gint y); -static gboolean clicked_on_curve (Tool *tool); +static gint mouse_over_vertex (Iscissors *iscissors, + gint x, + gint y); +static gboolean clicked_on_vertex (Tool *tool); +static GSList * mouse_over_curve (Iscissors *iscissors, + gint x, + gint y); +static gboolean clicked_on_curve (Tool *tool); static void precalculate_arrays (void); -static GPtrArray * plot_pixels (Iscissors *iscissors, - TempBuf *dp_buf, - gint x1, - gint y1, - gint xs, - gint ys, - gint xe, - gint ye); +static GPtrArray * plot_pixels (Iscissors *iscissors, + TempBuf *dp_buf, + gint x1, + gint y1, + gint xs, + gint ys, + gint xe, + gint ye); + static void iscissors_options_reset (void) @@ -412,23 +428,21 @@ tools_free_iscissors (Tool *tool) static void iscissors_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; GimpDrawable *drawable; Iscissors *iscissors; gboolean grab_pointer = FALSE; - gdisp = (GDisplay *) gdisp_ptr; iscissors = (Iscissors *) tool->private; - drawable = gimp_image_active_drawable (gdisp->gimage); + drawable = gimp_image_active_drawable (gdisp->gimage); gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &iscissors->x, &iscissors->y, FALSE, FALSE); /* If the tool was being used in another image...reset it */ - if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp != tool->gdisp) { /*iscissors->draw = DRAW_CURVE; XXX? */ draw_core_stop (iscissors->core, tool); @@ -436,19 +450,19 @@ iscissors_button_press (Tool *tool, } tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; switch (iscissors->state) { case NO_ACTION: #if 0 /* XXX what's this supposed to do? */ - if (!(bevent->state & GDK_SHIFT_MASK) && - !(bevent->state & GDK_CONTROL_MASK)) - if (selection_point_inside (gdisp->select, gdisp_ptr, + if (! (bevent->state & GDK_SHIFT_MASK) && + ! (bevent->state & GDK_CONTROL_MASK)) + if (selection_point_inside (gdisp->select, gdisp, bevent->x, bevent->y)) { - init_edit_selection (tool, gdisp->select, gdisp_ptr, + init_edit_selection (tool, gdisp->select, gdisp, bevent->x, bevent->y); return; } @@ -534,17 +548,16 @@ iscissors_button_press (Tool *tool, static void iscissors_convert (Iscissors *iscissors, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp = (GDisplay *) gdisp_ptr; ScanConverter *sc; ScanConvertPoint *pts; - guint npts; - GSList *list; - ICurve *icurve; - guint packed; - gint i; - gint index; + guint npts; + GSList *list; + ICurve *icurve; + guint packed; + gint i; + gint index; sc = scan_converter_new (gdisp->gimage->width, gdisp->gimage->height, 1); @@ -583,13 +596,11 @@ iscissors_convert (Iscissors *iscissors, static void iscissors_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; ICurve *curve; - gdisp = (GDisplay *) gdisp_ptr; iscissors = (Iscissors *) tool->private; TRC (("iscissors_button_release\n")); @@ -694,18 +705,16 @@ iscissors_button_release (Tool *tool, /* convert the curves into a region */ if (iscissors->connected) - iscissors_convert (iscissors, gdisp_ptr); + iscissors_convert (iscissors, gdisp); } static void iscissors_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; - gdisp = (GDisplay *) gdisp_ptr; iscissors = (Iscissors *) tool->private; if (tool->state != ACTIVE || iscissors->state == NO_ACTION) @@ -763,16 +772,16 @@ iscissors_motion (Tool *tool, static void iscissors_draw (Tool *tool) { - GDisplay *gdisp; + GDisplay *gdisp; Iscissors *iscissors; - ICurve *curve; - GSList *list; - int tx1, ty1, tx2, ty2; - int txn, tyn; + ICurve *curve; + GSList *list; + gint tx1, ty1, tx2, ty2; + gint txn, tyn; TRC (("iscissors_draw\n")); - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; iscissors = (Iscissors *) tool->private; gdisplay_transform_coords (gdisp, iscissors->ix, iscissors->iy, &tx1, &ty1, @@ -900,14 +909,12 @@ iscissors_draw_curve (GDisplay *gdisp, static void iscissors_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; gint x, y; iscissors = (Iscissors *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -954,7 +961,7 @@ iscissors_oper_update (Tool *tool, static void iscissors_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; SelectOps op; @@ -997,13 +1004,11 @@ iscissors_modifier_update (Tool *tool, static void iscissors_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; iscissors = (Iscissors *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (iscissors->op) { @@ -1073,7 +1078,7 @@ iscissors_cursor_update (Tool *tool, static void iscissors_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors * iscissors; Iscissors_draw draw; @@ -1409,11 +1414,11 @@ calculate_curve (Tool *tool, { GDisplay *gdisp; Iscissors *iscissors; - gint x, y, dir; - gint xs, ys, xe, ye; - gint x1, y1, x2, y2; - gint width, height; - gint ewidth, eheight; + gint x, y, dir; + gint xs, ys, xe, ye; + gint x1, y1, x2, y2; + gint width, height; + gint ewidth, eheight; TRC (("calculate_curve(%p, %p)\n", tool, curve)); @@ -1427,7 +1432,7 @@ calculate_curve (Tool *tool, * structure. */ - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; iscissors = (Iscissors *) tool->private; /* Get the bounding box */ diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index 7814babaaa..adcf1c9641 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -46,6 +46,7 @@ #include "libgimp/gimpintl.h" + #define LOW_INPUT 0x1 #define GAMMA 0x2 #define HIGH_INPUT 0x4 @@ -72,6 +73,7 @@ GDK_BUTTON1_MOTION_MASK | \ GDK_POINTER_MOTION_HINT_MASK + /* the levels structures */ typedef struct _Levels Levels; @@ -121,6 +123,61 @@ struct _LevelsDialog GimpLut *lut; }; + +/* levels action functions */ +static void levels_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static LevelsDialog * levels_dialog_new (void); + +static void levels_calculate_transfers (LevelsDialog *ld); +static void levels_update (LevelsDialog *ld, + gint channel); +static void levels_preview (LevelsDialog *ld); +static void levels_channel_callback (GtkWidget *widget, + gpointer data); +static void levels_reset_callback (GtkWidget *widget, + gpointer data); +static void levels_ok_callback (GtkWidget *widget, + gpointer data); +static void levels_cancel_callback (GtkWidget *widget, + gpointer data); +static void levels_auto_callback (GtkWidget *widget, + gpointer data); +static void levels_load_callback (GtkWidget *widget, + gpointer data); +static void levels_save_callback (GtkWidget *widget, + gpointer data); +static void levels_preview_update (GtkWidget *widget, + gpointer data); +static void levels_low_input_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_gamma_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_high_input_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_low_output_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_high_output_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static gint levels_input_da_events (GtkWidget *widget, + GdkEvent *event, + LevelsDialog *ld); +static gint levels_output_da_events (GtkWidget *widget, + GdkEvent *event, + LevelsDialog *ld); + +static void file_dialog_create (GtkWidget *widget); +static void file_dialog_ok_callback (GtkWidget *widget, + gpointer data); +static void file_dialog_cancel_callback (GtkWidget *widget, + gpointer data); + +static gboolean levels_read_from_file (FILE *f); +static void levels_write_to_file (FILE *f); + + /* the levels tool options */ static ToolOptions *levels_options = NULL; @@ -133,46 +190,13 @@ static gboolean load_save; static GtkWidget *color_option_items[5]; -/* levels action functions */ -static void levels_control (Tool *, ToolAction, gpointer); - -static LevelsDialog * levels_dialog_new (void); - -static void levels_calculate_transfers (LevelsDialog *); -static void levels_update (LevelsDialog *, gint); -static void levels_preview (LevelsDialog *); -static void levels_channel_callback (GtkWidget *, gpointer); -static void levels_reset_callback (GtkWidget *, gpointer); -static void levels_ok_callback (GtkWidget *, gpointer); -static void levels_cancel_callback (GtkWidget *, gpointer); -static void levels_auto_callback (GtkWidget *, gpointer); -static void levels_load_callback (GtkWidget *, gpointer); -static void levels_save_callback (GtkWidget *, gpointer); -static void levels_preview_update (GtkWidget *, gpointer); -static void levels_low_input_adjustment_update (GtkAdjustment *, gpointer); -static void levels_gamma_adjustment_update (GtkAdjustment *, gpointer); -static void levels_high_input_adjustment_update (GtkAdjustment *, gpointer); -static void levels_low_output_adjustment_update (GtkAdjustment *, gpointer); -static void levels_high_output_adjustment_update (GtkAdjustment *, gpointer); -static gint levels_input_da_events (GtkWidget *, GdkEvent *, - LevelsDialog *); -static gint levels_output_da_events (GtkWidget *, GdkEvent *, - LevelsDialog *); - -static void file_dialog_create (GtkWidget *); -static void file_dialog_ok_callback (GtkWidget *, gpointer); -static void file_dialog_cancel_callback (GtkWidget *, gpointer); - -static gboolean levels_read_from_file (FILE *f); -static void levels_write_to_file (FILE *f); - /* levels action functions */ static void levels_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -1028,7 +1052,7 @@ levels_ok_callback (GtkWidget *widget, ld->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -1052,7 +1076,7 @@ levels_cancel_callback (GtkWidget *widget, ld->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/gimpmagnifytool.c b/app/tools/gimpmagnifytool.c index 25a9e8c90c..1d60a74324 100644 --- a/app/tools/gimpmagnifytool.c +++ b/app/tools/gimpmagnifytool.c @@ -70,25 +70,37 @@ struct _MagnifyOptions }; -/* the magnify tool options */ -static MagnifyOptions *magnify_options = NULL; - - /* magnify action functions */ -static void magnify_button_press (Tool *, GdkEventButton *, gpointer); -static void magnify_button_release (Tool *, GdkEventButton *, gpointer); -static void magnify_motion (Tool *, GdkEventMotion *, gpointer); -static void magnify_modifier_update (Tool *, GdkEventKey *, gpointer); -static void magnify_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void magnify_control (Tool *, ToolAction, gpointer); +static void magnify_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void magnify_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void magnify_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void magnify_modifier_update (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void magnify_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void magnify_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); /* magnify utility functions */ -static void zoom_in (gint *src, - gint *dest, - gint scale); -static void zoom_out (gint *src, - gint *dest, - gint scale); +static void zoom_in (gint *src, + gint *dest, + gint scale); +static void zoom_out (gint *src, + gint *dest, + gint scale); + + +/* the magnify tool options */ +static MagnifyOptions *magnify_options = NULL; /* magnify tool options functions */ @@ -193,13 +205,11 @@ zoom_out (gint *src, static void magnify_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; Magnify *magnify; - gint x, y; + gint x, y; - gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, TRUE, 0); @@ -216,7 +226,7 @@ magnify_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; draw_core_start (magnify->core, gdisp->canvas->window, @@ -227,17 +237,15 @@ magnify_button_press (Tool *tool, static void magnify_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Magnify *magnify; - GDisplay *gdisp; - gint win_width, win_height; - gint width, height; - gint scalesrc, scaledest; - gint scale; - gint x1, y1, x2, y2, w, h; + gint win_width, win_height; + gint width, height; + gint scalesrc, scaledest; + gint scale; + gint x1, y1, x2, y2, w, h; - gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -297,16 +305,14 @@ magnify_button_release (Tool *tool, static void magnify_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Magnify *magnify; - GDisplay *gdisp; - gint x, y; + gint x, y; if (tool->state != ACTIVE) return; - gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; draw_core_pause (magnify->core, tool); @@ -322,7 +328,7 @@ magnify_motion (Tool *tool, static void magnify_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -344,12 +350,8 @@ magnify_modifier_update (Tool *tool, static void magnify_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - - gdisp = (GDisplay *) gdisp_ptr; - if (magnify_options->type == ZOOMIN) { gdisplay_install_tool_cursor (gdisp, GIMP_ZOOM_CURSOR, @@ -370,11 +372,9 @@ magnify_cursor_update (Tool *tool, void magnify_draw (Tool *tool) { - GDisplay *gdisp; Magnify *magnify; - gint x1, y1, x2, y2; + gint x1, y1, x2, y2; - gdisp = (GDisplay *) tool->gdisp_ptr; magnify = (Magnify *) tool->private; x1 = MIN (magnify->x, magnify->x + magnify->w); @@ -382,8 +382,8 @@ magnify_draw (Tool *tool) x2 = MAX (magnify->x, magnify->x + magnify->w); y2 = MAX (magnify->y, magnify->y + magnify->h); - gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); - gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); + gdisplay_transform_coords (tool->gdisp, x1, y1, &x1, &y1, 0); + gdisplay_transform_coords (tool->gdisp, x2, y2, &x2, &y2, 0); gdk_draw_rectangle (magnify->core->win, magnify->core->gc, 0, x1, y1, (x2 - x1), (y2 - y1)); @@ -393,7 +393,7 @@ magnify_draw (Tool *tool) static void magnify_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { Magnify *magnify; @@ -422,7 +422,7 @@ magnify_control (Tool *tool, Tool * tools_new_magnify (void) { - Tool *tool; + Tool *tool; Magnify *private; /* The tool options */ @@ -432,7 +432,7 @@ tools_new_magnify (void) tools_register (MAGNIFY, (ToolOptions *) magnify_options); } - tool = tools_new_tool (MAGNIFY); + tool = tools_new_tool (MAGNIFY); private = g_new0 (Magnify, 1); private->core = draw_core_new (magnify_draw); diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c index 4e12bec9e5..70bf89a35c 100644 --- a/app/tools/gimpmeasuretool.c +++ b/app/tools/gimpmeasuretool.c @@ -47,6 +47,9 @@ #define ARC_RADIUS_2 1100 #define STATUSBAR_SIZE 128 +/* maximum information buffer size */ +#define MAX_INFO_BUF 16 + /* possible measure functions */ typedef enum { @@ -89,8 +92,27 @@ struct _MeasureOptions }; -/* maximum information buffer size */ -#define MAX_INFO_BUF 16 +/* local function prototypes */ +static void measure_tool_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void measure_tool_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void measure_tool_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void measure_tool_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void measure_tool_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); + +static void measure_tool_info_window_close_callback (GtkWidget *widget, + gpointer data); +static void measure_tool_info_update (void); + static MeasureOptions *measure_tool_options = NULL; @@ -100,28 +122,6 @@ static gchar distance_buf[MAX_INFO_BUF]; static gchar angle_buf[MAX_INFO_BUF]; -/* local function prototypes */ -static void measure_tool_button_press (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -static void measure_tool_button_release (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -static void measure_tool_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); -static void measure_tool_cursor_update (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); -static void measure_tool_control (Tool *tool, - ToolAction action, - gpointer gdisp_ptr); - -static void measure_tool_info_window_close_callback (GtkWidget *widget, - gpointer data); -static void measure_tool_info_update (void); - - static void measure_tool_options_reset (void) { @@ -195,21 +195,19 @@ measure_get_angle (gint dx, static void measure_tool_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; gint x[3]; gint y[3]; gint i; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; /* if we are changing displays, pop the statusbar of the old one */ - if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp != tool->gdisp) { - GDisplay *old_gdisp = tool->gdisp_ptr; + GDisplay *old_gdisp = tool->gdisp; gtk_statusbar_pop (GTK_STATUSBAR (old_gdisp->statusbar), measure_tool->context_id); @@ -219,7 +217,7 @@ measure_tool_button_press (Tool *tool, measure_tool->function = CREATING; - if (tool->state == ACTIVE && gdisp_ptr == tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp == tool->gdisp) { /* if the cursor is in one of the handles, * the new function will be moving or adding a new point or guide @@ -334,7 +332,7 @@ measure_tool_button_press (Tool *tool, measure_tool->function = ADDING; /* set the gdisplay */ - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; /* start drawing the measure tool */ draw_core_start (measure_tool->core, gdisp->canvas->window, tool); @@ -378,12 +376,10 @@ measure_tool_button_press (Tool *tool, static void measure_tool_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; measure_tool->function = FINISHED; @@ -395,9 +391,8 @@ measure_tool_button_release (Tool *tool, static void measure_tool_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; gint x, y; gint ax, ay; @@ -409,7 +404,6 @@ measure_tool_motion (Tool *tool, gdouble distance; gchar status_str[STATUSBAR_SIZE]; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; /* undraw the current tool */ @@ -607,22 +601,20 @@ measure_tool_motion (Tool *tool, static void measure_tool_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - MeasureTool *measure_tool; - GDisplay *gdisp; - gint x[3]; - gint y[3]; - gint i; - gboolean in_handle = FALSE; + MeasureTool *measure_tool; + gint x[3]; + gint y[3]; + gint i; + gboolean in_handle = FALSE; GdkCursorType ctype = GIMP_CROSSHAIR_SMALL_CURSOR; CursorModifier cmodifier = CURSOR_MODIFIER_NONE; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; - if (tool->state == ACTIVE && tool->gdisp_ptr == gdisp_ptr) + if (tool->state == ACTIVE && tool->gdisp == gdisp) { for (i = 0; i < measure_tool->num_points; i++) { @@ -674,7 +666,6 @@ measure_tool_cursor_update (Tool *tool, static void measure_tool_draw (Tool *tool) { - GDisplay *gdisp; MeasureTool *measure_tool; gint x[3]; gint y[3]; @@ -682,12 +673,12 @@ measure_tool_draw (Tool *tool) gint angle1, angle2; gint draw_arc = 0; - gdisp = (GDisplay *) tool->gdisp_ptr; measure_tool = (MeasureTool *) tool->private; for (i = 0; i < measure_tool->num_points; i++) { - gdisplay_transform_coords (gdisp, measure_tool->x[i], measure_tool->y[i], + gdisplay_transform_coords (tool->gdisp, + measure_tool->x[i], measure_tool->y[i], &x[i], &y[i], FALSE); if (i == 0 && measure_tool->num_points == 3) { @@ -745,12 +736,10 @@ measure_tool_draw (Tool *tool) static void measure_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; - gdisp = (GDisplay *) tool->gdisp_ptr; measure_tool = (MeasureTool *) tool->private; switch (action) @@ -764,7 +753,8 @@ measure_tool_control (Tool *tool, break; case HALT: - gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), measure_tool->context_id); + gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), + measure_tool->context_id); draw_core_stop (measure_tool->core, tool); tool->state = INACTIVE; break; @@ -825,15 +815,13 @@ tools_new_measure_tool (void) void tools_free_measure_tool (Tool *tool) { - GDisplay *gdisp; MeasureTool *measure_tool; measure_tool = (MeasureTool *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; if (tool->state == ACTIVE) { - gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), + gtk_statusbar_pop (GTK_STATUSBAR (tool->gdisp->statusbar), measure_tool->context_id); draw_core_stop (measure_tool->core, tool); } @@ -845,5 +833,6 @@ tools_free_measure_tool (Tool *tool) info_dialog_free (measure_tool_info); measure_tool_info = NULL; } + g_free (measure_tool); } diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c index 3b8e416564..1818da444b 100644 --- a/app/tools/gimpmovetool.c +++ b/app/tools/gimpmovetool.c @@ -45,6 +45,7 @@ /* the move structures */ typedef struct _MoveTool MoveTool; + struct _MoveTool { Layer *layer; @@ -53,6 +54,26 @@ struct _MoveTool }; +/* move tool action functions */ +static void move_tool_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void move_tool_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void move_tool_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void move_tool_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void move_tool_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void move_create_gc (GDisplay *gdisp); + + /* the move tool options */ static ToolOptions *move_options = NULL; @@ -60,48 +81,37 @@ static ToolOptions *move_options = NULL; static GdkGC *move_gc = NULL; -/* move tool action functions */ -static void move_tool_button_press (Tool *, GdkEventButton *, gpointer); -static void move_tool_button_release (Tool *, GdkEventButton *, gpointer); -static void move_tool_motion (Tool *, GdkEventMotion *, gpointer); -static void move_tool_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void move_tool_control (Tool *, ToolAction, gpointer); - -static void move_create_gc (GDisplay *gdisp); - - /* move action functions */ static void move_tool_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MoveTool *move; Layer *layer; Guide *guide; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; move = (MoveTool *) tool->private; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; move->layer = NULL; move->guide = NULL; move->disp = NULL; - gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE); + gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, + FALSE, FALSE); if (bevent->state & GDK_MOD1_MASK && !gimage_mask_is_empty (gdisp->gimage)) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); tool->state = ACTIVE; } else if (bevent->state & GDK_SHIFT_MASK) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_LAYER_TRANSLATE); tool->state = ACTIVE; } else @@ -138,7 +148,7 @@ move_tool_button_press (Tool *tool, else { gimp_image_set_active_layer (gdisp->gimage, layer); - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_LAYER_TRANSLATE); } tool->state = ACTIVE; } @@ -202,15 +212,13 @@ move_draw_guide (GDisplay *gdisp, static void move_tool_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; - GDisplay *gdisp; gboolean delete_guide; gint x1, y1; gint x2, y2; - gdisp = (GDisplay *) gdisp_ptr; move = (MoveTool *) tool->private; gdk_flush (); @@ -259,7 +267,7 @@ move_tool_button_release (Tool *tool, } else { - move_tool_motion (tool, NULL, gdisp_ptr); + move_tool_motion (tool, NULL, gdisp); } selection_resume (gdisp->select); @@ -285,15 +293,13 @@ move_tool_button_release (Tool *tool, static void move_tool_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; - GDisplay *gdisp; gint x, y; move = (MoveTool *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; if (move->guide) { @@ -323,16 +329,14 @@ move_tool_motion (Tool *tool, static void move_tool_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; - GDisplay *gdisp; Guide *guide; Layer *layer; gint x, y; move = (MoveTool *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -357,7 +361,7 @@ move_tool_cursor_update (Tool *tool, if (gdisp->draw_guides && (guide = gdisplay_find_guide (gdisp, mevent->x, mevent->y))) { - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; gdisplay_install_tool_cursor (gdisp, GDK_HAND2, TOOL_TYPE_NONE, CURSOR_MODIFIER_HAND, @@ -372,10 +376,10 @@ move_tool_cursor_update (Tool *tool, gdisplay_draw_guide (gdisp, move->guide, FALSE); } - gdisp = gdisp_ptr; + gdisp = gdisp; gdisplay_draw_guide (gdisp, guide, TRUE); move->guide = guide; - move->disp = gdisp; + move->disp = gdisp; } } else if ((layer = gimp_image_pick_correlate_layer (gdisp->gimage, x, y))) @@ -412,7 +416,7 @@ move_tool_cursor_update (Tool *tool, static void move_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; @@ -425,7 +429,7 @@ move_tool_control (Tool *tool, case RESUME: if (move->guide) - gdisplay_draw_guide (gdisp_ptr, move->guide, TRUE); + gdisplay_draw_guide (gdisp, move->guide, TRUE); break; case HALT: @@ -458,7 +462,7 @@ move_tool_start_hguide (Tool *tool, selection_pause (gdisp->select); - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->scroll_lock = TRUE; private = tool->private; @@ -482,7 +486,7 @@ move_tool_start_vguide (Tool *tool, selection_pause (gdisp->select); - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->scroll_lock = TRUE; private = tool->private; @@ -539,10 +543,10 @@ tools_free_move_tool (Tool *tool) move = (MoveTool *) tool->private; - if (tool->gdisp_ptr) + if (tool->gdisp) { if (move->guide) - gdisplay_draw_guide (tool->gdisp_ptr, move->guide, FALSE); + gdisplay_draw_guide (tool->gdisp, move->guide, FALSE); } g_free (move); diff --git a/app/tools/gimppenciltool.c b/app/tools/gimppenciltool.c index 860d3da779..345a2a855b 100644 --- a/app/tools/gimppenciltool.c +++ b/app/tools/gimppenciltool.c @@ -40,6 +40,8 @@ #include "tool_options.h" +#define PENCIL_INCREMENTAL_DEFAULT FALSE + /* the pencil tool options */ typedef struct _PencilOptions PencilOptions; @@ -48,23 +50,29 @@ struct _PencilOptions PaintOptions paint_options; }; -static PencilOptions *pencil_options = NULL; /* forward function declarations */ -static void pencil_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, gboolean); +static void pencil_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + gboolean ); +static gpointer pencil_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + + +static PencilOptions *pencil_options = NULL; static gboolean non_gui_incremental = FALSE; static void pencil_options_reset (void); -#define PENCIL_INCREMENTAL_DEFAULT FALSE /* functions */ -void * +gpointer pencil_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -203,10 +211,10 @@ pencil_motion (PaintCore *paint_core, HARD, scale, paint_appl_mode); } -static void * +static gpointer pencil_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { pencil_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_incremental); diff --git a/app/tools/gimppenciltool.h b/app/tools/gimppenciltool.h index 5bdadd451c..888d3832ea 100644 --- a/app/tools/gimppenciltool.h +++ b/app/tools/gimppenciltool.h @@ -20,12 +20,9 @@ #define __PENCIL_H__ -void * pencil_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean pencil_non_gui (GimpDrawable *, - gint , - gdouble *); +gboolean pencil_non_gui (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_pencil (void); void tools_free_pencil (Tool *tool); diff --git a/app/tools/gimpperspectivetool.c b/app/tools/gimpperspectivetool.c index 166e4fb6fa..05af32400c 100644 --- a/app/tools/gimpperspectivetool.c +++ b/app/tools/gimpperspectivetool.c @@ -41,23 +41,28 @@ #include "libgimp/gimpintl.h" +/* forward function declarations */ +static TileManager * perspective_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); +static void perspective_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void perspective_tool_motion (Tool *tool, + GDisplay *gdisp); +static void perspective_info_update (Tool *tool); + + /* storage for information dialog fields */ static gchar matrix_row_buf [3][MAX_INFO_BUF]; -/* forward function declarations */ -static void perspective_tool_recalc (Tool *, void *); -static void perspective_tool_motion (Tool *, void *); -static void perspective_info_update (Tool *); -TileManager * +static TileManager * perspective_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { - GDisplay *gdisp; TransformCore *transform_core; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; switch (state) @@ -89,12 +94,12 @@ perspective_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - perspective_tool_motion (tool, gdisp_ptr); - perspective_tool_recalc (tool, gdisp_ptr); + perspective_tool_motion (tool, gdisp); + perspective_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - perspective_tool_recalc (tool, gdisp_ptr); + perspective_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -173,14 +178,12 @@ perspective_info_update (Tool *tool) } static void -perspective_tool_motion (Tool *tool, - void *gdisp_ptr) +perspective_tool_motion (Tool *tool, + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; gint diff_x, diff_y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; diff_x = transform_core->curx - transform_core->lastx; @@ -210,16 +213,14 @@ perspective_tool_motion (Tool *tool, } static void -perspective_tool_recalc (Tool *tool, - void *gdisp_ptr) +perspective_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; GimpMatrix3 m; gdouble cx, cy; gdouble scalex, scaley; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; /* determine the perspective transform that maps from diff --git a/app/tools/gimpperspectivetool.h b/app/tools/gimpperspectivetool.h index 611a85ecc1..39f31518ab 100644 --- a/app/tools/gimpperspectivetool.h +++ b/app/tools/gimpperspectivetool.h @@ -20,9 +20,6 @@ #define __PERSPECTIVE_TOOL_H__ -TileManager * perspective_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * perspective_tool_perspective (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/tools/gimpposterizetool.c b/app/tools/gimpposterizetool.c index c8c7cc728b..10b8b7722d 100644 --- a/app/tools/gimpposterizetool.c +++ b/app/tools/gimpposterizetool.c @@ -64,6 +64,27 @@ struct _PosterizeDialog GimpLut *lut; }; + +/* posterize action functions */ +static void posterize_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static PosterizeDialog * posterize_dialog_new (void); + +static void posterize_preview (PosterizeDialog *pd); +static void posterize_reset_callback (GtkWidget *widget, + gpointer data); +static void posterize_ok_callback (GtkWidget *widget, + gpointer data); +static void posterize_cancel_callback (GtkWidget *widget, + gpointer data); +static void posterize_preview_update (GtkWidget *widget, + gpointer data); +static void posterize_levels_adjustment_update (GtkAdjustment *adjustment, + gpointer data); + + /* the posterize tool options */ static ToolOptions *posterize_options = NULL; @@ -71,24 +92,12 @@ static ToolOptions *posterize_options = NULL; static PosterizeDialog *posterize_dialog = NULL; -/* posterize action functions */ -static void posterize_control (Tool *, ToolAction, gpointer); - -static PosterizeDialog * posterize_dialog_new (void); - -static void posterize_preview (PosterizeDialog *); -static void posterize_reset_callback (GtkWidget *, gpointer); -static void posterize_ok_callback (GtkWidget *, gpointer); -static void posterize_cancel_callback (GtkWidget *, gpointer); -static void posterize_preview_update (GtkWidget *, gpointer); -static void posterize_levels_adjustment_update (GtkAdjustment *, gpointer); - /* posterize select action functions */ static void posterize_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -311,7 +320,7 @@ posterize_ok_callback (GtkWidget *widget, posterize_lut_setup( pd->lut, pd->levels, gimp_drawable_bytes (pd->drawable)); image_map_apply (pd->image_map, (ImageMapApplyFunc) gimp_lut_process_2, - (void *) pd->lut); + (gpointer) pd->lut); } if (pd->image_map) @@ -321,7 +330,7 @@ posterize_ok_callback (GtkWidget *widget, pd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -345,7 +354,7 @@ posterize_cancel_callback (GtkWidget *widget, gdisplays_flush (); } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/gimprectselecttool.c b/app/tools/gimprectselecttool.c index 3dbca9e287..f7e6e21845 100644 --- a/app/tools/gimprectselecttool.c +++ b/app/tools/gimprectselecttool.c @@ -48,26 +48,29 @@ #define STATUSBAR_SIZE 128 +extern void ellipse_select (GimpImage *gimage, + gint x, + gint y, + gint w, + gint h, + SelectOps op, + gboolean antialias, + gboolean feather, + gdouble feather_radius); + +static void selection_tool_update_op_state (RectSelect *rect_sel, + gint x, + gint y, + gint state, + GDisplay *gdisp); + + /* the rectangular selection tool options */ static SelectionOptions *rect_options = NULL; /* in gimp, ellipses are rectangular, too ;) */ extern SelectionOptions *ellipse_options; -extern void ellipse_select (GimpImage *gimage, - gint x, - gint y, - gint w, - gint h, - SelectOps op, - gboolean antialias, - gboolean feather, - gdouble feather_radius); -static void selection_tool_update_op_state (RectSelect *rect_sel, - gint x, - gint y, - gint state, - GDisplay *gdisp); /*************************************/ /* Rectangular selection apparatus */ @@ -117,16 +120,14 @@ rect_select (GimpImage *gimage, void rect_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; RectSelect *rect_sel; gchar select_mode[STATUSBAR_SIZE]; gint x, y; GimpUnit unit = GIMP_UNIT_PIXEL; gdouble unit_factor; - gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, TRUE, 0); @@ -185,15 +186,15 @@ rect_select_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; switch (rect_sel->op) { case SELECTION_MOVE_MASK: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; case SELECTION_MOVE: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; default: break; @@ -228,15 +229,13 @@ rect_select_button_press (Tool *tool, void rect_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - GDisplay *gdisp; - gint x1, y1; - gint x2, y2; - gint w, h; + gint x1, y1; + gint x2, y2; + gint w, h; - gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -301,18 +300,16 @@ rect_select_button_release (Tool *tool, void rect_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - GDisplay *gdisp; - gchar size[STATUSBAR_SIZE]; - gint ox, oy; - gint x, y; - gint w, h, s; - gint tw, th; - gdouble ratio; + gchar size[STATUSBAR_SIZE]; + gint ox, oy; + gint x, y; + gint w, h, s; + gint tw, th; + gdouble ratio; - gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; /* needed for immediate cursor update on modifier event */ @@ -326,7 +323,7 @@ rect_select_motion (Tool *tool, { rect_sel->op = SELECTION_REPLACE; - rect_select_cursor_update (tool, mevent, gdisp_ptr); + rect_select_cursor_update (tool, mevent, gdisp); } draw_core_pause (rect_sel->core, tool); @@ -472,12 +469,10 @@ rect_select_motion (Tool *tool, void rect_select_draw (Tool *tool) { - GDisplay *gdisp; RectSelect *rect_sel; - gint x1, y1; - gint x2, y2; + gint x1, y1; + gint x2, y2; - gdisp = (GDisplay *) tool->gdisp_ptr; rect_sel = (RectSelect *) tool->private; x1 = MIN (rect_sel->x, rect_sel->x + rect_sel->w); @@ -485,8 +480,8 @@ rect_select_draw (Tool *tool) x2 = MAX (rect_sel->x, rect_sel->x + rect_sel->w); y2 = MAX (rect_sel->y, rect_sel->y + rect_sel->h); - gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); - gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); + gdisplay_transform_coords (tool->gdisp, x1, y1, &x1, &y1, 0); + gdisplay_transform_coords (tool->gdisp, x2, y2, &x2, &y2, 0); gdk_draw_rectangle (rect_sel->core->win, rect_sel->core->gc, 0, @@ -553,7 +548,7 @@ selection_tool_update_op_state (RectSelect *rect_sel, void rect_select_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; @@ -565,16 +560,16 @@ rect_select_oper_update (Tool *tool, selection_tool_update_op_state (rect_sel, rect_sel->current_x, rect_sel->current_y, - mevent->state, gdisp_ptr); + mevent->state, gdisp); } void rect_select_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - gint state; + gint state; state = kevent->state; @@ -606,19 +601,17 @@ rect_select_modifier_update (Tool *tool, selection_tool_update_op_state (rect_sel, rect_sel->current_x, rect_sel->current_y, - state, gdisp_ptr); + state, gdisp); } void rect_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - GDisplay *gdisp; rect_sel = (RectSelect *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (rect_sel->op) { @@ -670,7 +663,7 @@ rect_select_cursor_update (Tool *tool, void rect_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; diff --git a/app/tools/gimprectselecttool.h b/app/tools/gimprectselecttool.h index ffc764b9db..4ea51d7378 100644 --- a/app/tools/gimprectselecttool.h +++ b/app/tools/gimprectselecttool.h @@ -23,25 +23,25 @@ /* rect select action functions */ void rect_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_control (Tool *tool, ToolAction tool_action, - gpointer gdisp_ptr); + GDisplay *gdisp); /* rect select functions */ void rect_select_draw (Tool *tool); diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c index 906acff785..8180462164 100644 --- a/app/tools/gimpregionselecttool.c +++ b/app/tools/gimpregionselecttool.c @@ -71,6 +71,27 @@ struct _FuzzySelect }; +/* fuzzy select action functions */ +static void fuzzy_select_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void fuzzy_select_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void fuzzy_select_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void fuzzy_select_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void fuzzy_select_draw (Tool *tool); + +static GdkSegment * fuzzy_select_calculate (Tool *tool, + GDisplay *gdisp, + gint *nsegs); + + /* the fuzzy selection tool options */ static SelectionOptions *fuzzy_options = NULL; @@ -81,18 +102,6 @@ static gint num_segs = 0; Channel * fuzzy_mask = NULL; -/* fuzzy select action functions */ -static void fuzzy_select_button_press (Tool *, GdkEventButton *, gpointer); -static void fuzzy_select_button_release (Tool *, GdkEventButton *, gpointer); -static void fuzzy_select_motion (Tool *, GdkEventMotion *, gpointer); -static void fuzzy_select_control (Tool *, ToolAction, gpointer); - -static void fuzzy_select_draw (Tool *); - -/* fuzzy select action functions */ -static GdkSegment * fuzzy_select_calculate (Tool *, void *, int *); - - /*************************************/ /* Fuzzy selection apparatus */ @@ -390,12 +399,10 @@ fuzzy_select (GImage *gimage, static void fuzzy_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; FuzzySelect *fuzzy_sel; - gdisp = (GDisplay *) gdisp_ptr; fuzzy_sel = (FuzzySelect *) tool->private; fuzzy_sel->x = bevent->x; @@ -411,21 +418,21 @@ fuzzy_select_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; if (fuzzy_sel->op == SELECTION_MOVE_MASK) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; } else if (fuzzy_sel->op == SELECTION_MOVE) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; } /* calculate the region boundary */ - segs = fuzzy_select_calculate (tool, gdisp_ptr, &num_segs); + segs = fuzzy_select_calculate (tool, gdisp, &num_segs); draw_core_start (fuzzy_sel->core, gdisp->canvas->window, @@ -435,13 +442,11 @@ fuzzy_select_button_press (Tool *tool, static void fuzzy_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; - GDisplay *gdisp; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; fuzzy_sel = (FuzzySelect *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -471,13 +476,13 @@ fuzzy_select_button_release (Tool *tool, static void fuzzy_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; GdkSegment *new_segs; - gint num_new_segs; - gint diff_x, diff_y; - gdouble diff; + gint num_new_segs; + gint diff_x, diff_y; + gdouble diff; static guint last_time = 0; @@ -505,7 +510,7 @@ fuzzy_select_motion (Tool *tool, fuzzy_sel->first_threshold + diff); /* calculate the new fuzzy boundary */ - new_segs = fuzzy_select_calculate (tool, gdisp_ptr, &num_new_segs); + new_segs = fuzzy_select_calculate (tool, gdisp, &num_new_segs); /* stop the current boundary */ draw_core_pause (fuzzy_sel->core, tool); @@ -522,24 +527,22 @@ fuzzy_select_motion (Tool *tool, static GdkSegment * -fuzzy_select_calculate (Tool *tool, - void *gdisp_ptr, - gint *nsegs) +fuzzy_select_calculate (Tool *tool, + GDisplay *gdisp, + gint *nsegs) { PixelRegion maskPR; FuzzySelect *fuzzy_sel; - GDisplay *gdisp; Channel *new; GdkSegment *segs; BoundSeg *bsegs; GimpDrawable *drawable; - gint i; - gint x, y; - gboolean use_offsets; + gint i; + gint x, y; + gboolean use_offsets; fuzzy_sel = (FuzzySelect *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; - drawable = gimp_image_active_drawable (gdisp->gimage); + drawable = gimp_image_active_drawable (gdisp->gimage); gimp_add_busy_cursors (); @@ -605,7 +608,7 @@ fuzzy_select_draw (Tool *tool) static void fuzzy_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { FuzzySelect *fuzzy_sel; diff --git a/app/tools/gimpregionselecttool.h b/app/tools/gimpregionselecttool.h index 0211a4b81f..42533a19db 100644 --- a/app/tools/gimpregionselecttool.h +++ b/app/tools/gimpregionselecttool.h @@ -20,14 +20,6 @@ #define __FUZZY_SELECT_H__ -extern Channel *fuzzy_mask; - - -/* fuzzy select functions */ -Tool * tools_new_fuzzy_select (void); -void tools_free_fuzzy_select (Tool *tool); - -/* functions */ Channel * find_contiguous_region (GimpImage *gimage, GimpDrawable *drawable, gboolean antialias, @@ -41,5 +33,11 @@ void fuzzy_select (GimpImage *gimage, gboolean feather, gdouble feather_radius); +Tool * tools_new_fuzzy_select (void); +void tools_free_fuzzy_select (Tool *tool); + + +extern Channel *fuzzy_mask; + #endif /* __FUZZY_SELECT_H__ */ diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c index 75b33552d7..ff0c059f18 100644 --- a/app/tools/gimprotatetool.c +++ b/app/tools/gimprotatetool.c @@ -55,34 +55,42 @@ #define EPSILON 0.018 /* ~ 1 degree */ #define FIFTEEN_DEG (G_PI / 12.0) + +/* forward function declarations */ +static TileManager * rotate_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + +static void rotate_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void rotate_tool_motion (Tool *tool, + GDisplay *gdisp); +static void rotate_info_update (Tool *tool); + +static void rotate_angle_changed (GtkWidget *entry, + gpointer data); +static void rotate_center_changed (GtkWidget *entry, + gpointer data); + + /* variables local to this file */ static gdouble angle_val; static gdouble center_vals[2]; /* needed for size update */ -static GtkWidget *sizeentry; +static GtkWidget *sizeentry = NULL; -/* forward function declarations */ -static void rotate_tool_recalc (Tool *, void *); -static void rotate_tool_motion (Tool *, void *); -static void rotate_info_update (Tool *); -/* callback functions for the info dialog sizeentries */ -static void rotate_angle_changed (GtkWidget *entry, gpointer data); -static void rotate_center_changed (GtkWidget *entry, gpointer data); - -TileManager * +static TileManager * rotate_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { TransformCore *transform_core; - GDisplay *gdisp; GtkWidget *widget; GtkWidget *spinbutton2; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (state) { @@ -174,12 +182,12 @@ rotate_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - rotate_tool_motion (tool, gdisp_ptr); - rotate_tool_recalc (tool, gdisp_ptr); + rotate_tool_motion (tool, gdisp); + rotate_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - rotate_tool_recalc (tool, gdisp_ptr); + rotate_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -246,7 +254,6 @@ rotate_angle_changed (GtkWidget *widget, gpointer data) { Tool *tool; - GDisplay *gdisp; TransformCore *transform_core; gdouble value; @@ -254,7 +261,6 @@ rotate_angle_changed (GtkWidget *widget, if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; value = gimp_deg_to_rad (GTK_ADJUSTMENT (widget)->value); @@ -263,7 +269,7 @@ rotate_angle_changed (GtkWidget *widget, { draw_core_pause (transform_core->core, tool); transform_core->trans_info[ANGLE] = value; - rotate_tool_recalc (tool, gdisp); + rotate_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } @@ -274,7 +280,6 @@ rotate_center_changed (GtkWidget *widget, gpointer data) { Tool *tool; - GDisplay *gdisp; TransformCore *transform_core; gint cx; gint cy; @@ -283,7 +288,6 @@ rotate_center_changed (GtkWidget *widget, if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; cx = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); @@ -295,15 +299,15 @@ rotate_center_changed (GtkWidget *widget, draw_core_pause (transform_core->core, tool); transform_core->cx = cx; transform_core->cy = cy; - rotate_tool_recalc (tool, gdisp); + rotate_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } } static void -rotate_tool_motion (Tool *tool, - void *gdisp_ptr) +rotate_tool_motion (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; gdouble angle1, angle2, angle; @@ -361,14 +365,12 @@ rotate_tool_motion (Tool *tool, } static void -rotate_tool_recalc (Tool *tool, - void *gdisp_ptr) +rotate_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; gdouble cx, cy; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; cx = transform_core->cx; diff --git a/app/tools/gimprotatetool.h b/app/tools/gimprotatetool.h index a466d1411d..1411efe643 100644 --- a/app/tools/gimprotatetool.h +++ b/app/tools/gimprotatetool.h @@ -20,9 +20,6 @@ #define __ROTATE_TOOL_H__ -TileManager * rotate_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * rotate_tool_rotate (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index edce4cd856..14353f7e11 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -46,6 +46,23 @@ #include "libgimp/gimpintl.h" +/* forward function declarations */ +static TileManager * scale_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + +static void scale_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void scale_tool_motion (Tool *tool, + GDisplay *gdisp); +static void scale_info_update (Tool *tool); + +static void scale_size_changed (GtkWidget *widget, + gpointer data); +static void scale_unit_changed (GtkWidget *widget, + gpointer data); + + /* storage for information dialog fields */ static gchar orig_width_buf[MAX_INFO_BUF]; static gchar orig_height_buf[MAX_INFO_BUF]; @@ -54,27 +71,17 @@ static gchar x_ratio_buf[MAX_INFO_BUF]; static gchar y_ratio_buf[MAX_INFO_BUF]; /* needed for original size unit update */ -static GtkWidget *sizeentry; +static GtkWidget *sizeentry = NULL; -/* forward function declarations */ -static void scale_tool_recalc (Tool *, void *); -static void scale_tool_motion (Tool *, void *); -static void scale_info_update (Tool *); -/* callback functions for the info dialog fields */ -static void scale_size_changed (GtkWidget *widget, gpointer data); -static void scale_unit_changed (GtkWidget *widget, gpointer data); - -TileManager * +static TileManager * scale_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { - GDisplay *gdisp; TransformCore *transform_core; GtkWidget *spinbutton; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; switch (state) @@ -163,12 +170,12 @@ scale_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - scale_tool_motion (tool, gdisp_ptr); - scale_tool_recalc (tool, gdisp_ptr); + scale_tool_motion (tool, gdisp); + scale_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - scale_tool_recalc (tool, gdisp_ptr); + scale_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -218,7 +225,6 @@ tools_free_scale_tool (Tool *tool) static void scale_info_update (Tool *tool) { - GDisplay *gdisp; TransformCore *transform_core; gdouble ratio_x, ratio_y; gint x1, y1, x2, y2, x3, y3, x4, y4; @@ -228,9 +234,8 @@ scale_info_update (Tool *tool) static GimpUnit label_unit = GIMP_UNIT_PIXEL; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; - unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));; + unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));; /* Find original sizes */ x1 = transform_core->x1; @@ -249,9 +254,9 @@ scale_info_update (Tool *tool) gimp_unit_get_digits (label_unit) + 1, gimp_unit_get_symbol (label_unit)); g_snprintf (orig_width_buf, MAX_INFO_BUF, format_buf, - (x2 - x1) * unit_factor / gdisp->gimage->xresolution); + (x2 - x1) * unit_factor / tool->gdisp->gimage->xresolution); g_snprintf (orig_height_buf, MAX_INFO_BUF, format_buf, - (y2 - y1) * unit_factor / gdisp->gimage->yresolution); + (y2 - y1) * unit_factor / tool->gdisp->gimage->yresolution); } else /* unit == GIMP_UNIT_PIXEL */ { @@ -288,7 +293,6 @@ scale_size_changed (GtkWidget *widget, { Tool *tool; TransformCore *transform_core; - GDisplay *gdisp; gint width; gint height; @@ -296,7 +300,6 @@ scale_size_changed (GtkWidget *widget, if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); @@ -312,7 +315,7 @@ scale_size_changed (GtkWidget *widget, transform_core->trans_info[X0] + width; transform_core->trans_info[Y1] = transform_core->trans_info[Y0] + height; - scale_tool_recalc (tool, gdisp); + scale_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } @@ -326,10 +329,9 @@ scale_unit_changed (GtkWidget *widget, } static void -scale_tool_motion (Tool *tool, - void *gdisp_ptr) +scale_tool_motion (Tool *tool, + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; gdouble ratio; gdouble *x1; @@ -340,7 +342,6 @@ scale_tool_motion (Tool *tool, gint dir_x, dir_y; gint diff_x, diff_y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; diff_x = transform_core->curx - transform_core->lastx; @@ -435,17 +436,15 @@ scale_tool_motion (Tool *tool, } static void -scale_tool_recalc (Tool *tool, - void *gdisp_ptr) +scale_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; gint x1, y1, x2, y2; gint diffx, diffy; gint cx, cy; gdouble scalex, scaley; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; x1 = (int) transform_core->trans_info [X0]; diff --git a/app/tools/gimpscaletool.h b/app/tools/gimpscaletool.h index 93aeac2cd6..2de517460f 100644 --- a/app/tools/gimpscaletool.h +++ b/app/tools/gimpscaletool.h @@ -20,9 +20,6 @@ #define __SCALE_TOOL_H__ -TileManager * scale_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * scale_tool_scale (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/tools/gimpsheartool.c b/app/tools/gimpsheartool.c index 279332b28d..99be358f45 100644 --- a/app/tools/gimpsheartool.c +++ b/app/tools/gimpsheartool.c @@ -54,29 +54,37 @@ /* the minimum movement before direction of shear can be determined (pixels) */ #define MIN_MOVE 5 + +/* forward function declarations */ +static TileManager * shear_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + +static void shear_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void shear_tool_motion (Tool *tool, + GDisplay *gdisp); +static void shear_info_update (Tool *tool); + +static void shear_x_mag_changed (GtkWidget *widget, + gpointer data); +static void shear_y_mag_changed (GtkWidget *widget, + gpointer data); + + /* variables local to this file */ static gdouble xshear_val; static gdouble yshear_val; -/* forward function declarations */ -static void shear_tool_recalc (Tool *, void *); -static void shear_tool_motion (Tool *, void *); -static void shear_info_update (Tool *); -/* Info dialog callback funtions */ -static void shear_x_mag_changed (GtkWidget *widget, gpointer data); -static void shear_y_mag_changed (GtkWidget *widget, gpointer data); - -TileManager * +static TileManager * shear_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { TransformCore *transform_core; - GDisplay *gdisp; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (state) { @@ -108,12 +116,12 @@ shear_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - shear_tool_motion (tool, gdisp_ptr); - shear_tool_recalc (tool, gdisp_ptr); + shear_tool_motion (tool, gdisp); + shear_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - shear_tool_recalc (tool, gdisp_ptr); + shear_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -175,14 +183,12 @@ shear_x_mag_changed (GtkWidget *widget, { Tool *tool; TransformCore *transform_core; - GDisplay *gdisp; gint value; tool = (Tool *) data; if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; value = GTK_ADJUSTMENT (widget)->value; @@ -191,7 +197,7 @@ shear_x_mag_changed (GtkWidget *widget, { draw_core_pause (transform_core->core, tool); transform_core->trans_info[XSHEAR] = value; - shear_tool_recalc (tool, gdisp); + shear_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } @@ -203,14 +209,12 @@ shear_y_mag_changed (GtkWidget *widget, { Tool *tool; TransformCore *transform_core; - GDisplay *gdisp; gint value; tool = (Tool *) data; if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; value = GTK_ADJUSTMENT (widget)->value; @@ -219,15 +223,15 @@ shear_y_mag_changed (GtkWidget *widget, { draw_core_pause (transform_core->core, tool); transform_core->trans_info[YSHEAR] = value; - shear_tool_recalc (tool, gdisp); + shear_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } } static void -shear_tool_motion (Tool *tool, - void *gdisp_ptr) +shear_tool_motion (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; gint diffx, diffy; @@ -302,15 +306,13 @@ shear_tool_motion (Tool *tool, } static void -shear_tool_recalc (Tool *tool, - void *gdisp_ptr) +shear_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; gfloat width, height; gfloat cx, cy; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; cx = (transform_core->x1 + transform_core->x2) / 2.0; diff --git a/app/tools/gimpsheartool.h b/app/tools/gimpsheartool.h index 1dd07ad975..3b1a0e381c 100644 --- a/app/tools/gimpsheartool.h +++ b/app/tools/gimpsheartool.h @@ -20,9 +20,6 @@ #define __SHEAR_TOOL_H__ -TileManager * shear_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * shear_tool_shear (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/tools/gimpsmudgetool.c b/app/tools/gimpsmudgetool.c index 26bdff458e..3aae2073cb 100644 --- a/app/tools/gimpsmudgetool.c +++ b/app/tools/gimpsmudgetool.c @@ -63,30 +63,40 @@ struct _SmudgeOptions GtkObject *rate_w; }; + +/* function prototypes */ +static gpointer smudge_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void smudge_motion (PaintCore *paint_core, + PaintPressureOptions *pressure_options, + gdouble smudge_rate, + GimpDrawable *drawable); +static gboolean smudge_init (PaintCore *paint_core, + GimpDrawable *drawable); +static void smudge_finish (PaintCore *paint_core, + GimpDrawable *drawable); + +static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, + gint *x, + gint *y, + gint *w, + gint *h); +static void smudge_allocate_accum_buffer (gint w, + gint h, + gint bytes, + guchar *do_fill); + + +/* local variables */ static PixelRegion accumPR; static guchar *accum_data; /* the smudge tool options */ static SmudgeOptions * smudge_options = NULL; -/* local variables */ static gdouble non_gui_rate; -/* function prototypes */ -static void smudge_motion (PaintCore *, PaintPressureOptions *, - gdouble, GimpDrawable *); -static gboolean smudge_init (PaintCore *, GimpDrawable *); -static void smudge_finish (PaintCore *, GimpDrawable *); - -static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, - gint *x, - gint *y, - gint *w, - gint *h); -static void smudge_allocate_accum_buffer (gint w, - gint h, - gint bytes, - guchar *do_fill); static void smudge_options_reset (void) @@ -143,10 +153,10 @@ smudge_options_new (void) return options; } -void * +static gpointer smudge_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { /* initialization fails if the user starts outside the drawable */ static gboolean initialized = FALSE; @@ -157,13 +167,18 @@ smudge_paint_func (PaintCore *paint_core, if (!initialized) initialized = smudge_init (paint_core, drawable); if (initialized) - smudge_motion (paint_core, smudge_options->paint_options.pressure_options, + smudge_motion (paint_core, + smudge_options->paint_options.pressure_options, smudge_options->rate, drawable); break; + case FINISH_PAINT: smudge_finish (paint_core, drawable); initialized = FALSE; break; + + default: + break; } return NULL; @@ -198,12 +213,12 @@ static gboolean smudge_init (PaintCore *paint_core, GimpDrawable *drawable) { - GImage *gimage; - TempBuf *area; + GImage *gimage; + TempBuf *area; PixelRegion srcPR; - gint x, y, w, h; - gint was_clipped; - guchar *do_fill = NULL; + gint x, y, w, h; + gint was_clipped; + guchar *do_fill = NULL; if (! (gimage = drawable_gimage (drawable))) return FALSE; @@ -239,7 +254,7 @@ smudge_init (PaintCore *paint_core, do_fill = gimp_drawable_get_color_at (drawable, CLAMP ((gint) paint_core->curx, 0, gimp_drawable_width (drawable) - 1), CLAMP ((gint) paint_core->cury, 0, gimp_drawable_height (drawable) - 1)); - + smudge_allocate_accum_buffer (w, h, gimp_drawable_bytes (drawable), do_fill); accumPR.x = area->x - x; @@ -277,7 +292,7 @@ smudge_allocate_accum_buffer (gint w, gint h, gint bytes, guchar *do_fill) -{ +{ /* Allocate the accumulation buffer */ accumPR.bytes = bytes; accum_data = g_malloc (w * h * bytes); @@ -332,12 +347,12 @@ smudge_motion (PaintCore *paint_core, gdouble smudge_rate, GimpDrawable *drawable) { - GImage *gimage; - TempBuf * area; - PixelRegion srcPR, destPR, tempPR; - gdouble rate; - gint opacity; - gint x,y,w,h; + GImage *gimage; + TempBuf *area; + PixelRegion srcPR, destPR, tempPR; + gdouble rate; + gint opacity; + gint x, y, w, h; if (! (gimage = drawable_gimage (drawable))) return; @@ -425,10 +440,10 @@ smudge_motion (PaintCore *paint_core, 1.0, INCREMENTAL); } -static void * +static gpointer smudge_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { smudge_motion (paint_core, &non_gui_pressure_options, non_gui_rate, drawable); @@ -437,8 +452,8 @@ smudge_non_gui_paint_func (PaintCore *paint_core, gboolean smudge_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gdouble rate = SMUDGE_DEFAULT_RATE; SmudgeOptions *options = smudge_options; @@ -452,8 +467,8 @@ smudge_non_gui_default (GimpDrawable *drawable, gboolean smudge_non_gui (GimpDrawable *drawable, gdouble rate, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gint i; @@ -493,6 +508,6 @@ smudge_non_gui (GimpDrawable *drawable, smudge_finish (&non_gui_paint_core, drawable); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/tools/gimpsmudgetool.h b/app/tools/gimpsmudgetool.h index a87d0ffe60..0ea9609198 100644 --- a/app/tools/gimpsmudgetool.h +++ b/app/tools/gimpsmudgetool.h @@ -33,16 +33,14 @@ typedef enum SMUDGE_MODE_SHADOWS } SmudgeMode; -void * smudge_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean smudge_non_gui (GimpDrawable *, - gdouble , - gint , - gdouble *); -gboolean smudge_non_gui_default (GimpDrawable *, - gint , - gdouble *); + +gboolean smudge_non_gui (GimpDrawable *drawable, + gdouble rate, + gint num_strokes, + gdouble *stroke_array); +gboolean smudge_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_smudge (void); void tools_free_smudge (Tool *tool); diff --git a/app/tools/gimpsourcetool.c b/app/tools/gimpsourcetool.c index 7c16c6f684..320e2c7725 100644 --- a/app/tools/gimpsourcetool.c +++ b/app/tools/gimpsourcetool.c @@ -79,37 +79,59 @@ struct _CloneOptions }; +/* forward function declarations */ + +static gpointer clone_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void clone_draw (Tool *tool); +static void clone_motion (PaintCore *paint_core, + GimpDrawable *drawable, + GimpDrawable *src_drawable, + PaintPressureOptions *pressure_options, + CloneType type, + gint offset_x, + gint offset_y); +static void clone_line_image (GImage *dest, + GImage *src, + GimpDrawable *d_drawable, + GimpDrawable *s_drawable, + guchar *s, + guchar *d, + gint has_alpha, + gint src_bytes, + gint dest_bytes, + gint width); +static void clone_line_pattern (GImage *dest, + GimpDrawable *drawable, + GPattern *pattern, + guchar *d, + gint x, + gint y, + gint bytes, + gint width); + + /* the clone tool options */ static CloneOptions *clone_options = NULL; /* local variables */ -static int src_x = 0; /* */ -static int src_y = 0; /* position of clone src */ -static int dest_x = 0; /* */ -static int dest_y = 0; /* position of clone src */ -static int offset_x = 0; /* */ -static int offset_y = 0; /* offset for cloning */ -static int first = TRUE; -static int trans_tx, trans_ty; /* transformed target */ +static gint src_x = 0; /* */ +static gint src_y = 0; /* position of clone src */ +static gint dest_x = 0; /* */ +static gint dest_y = 0; /* position of clone src */ +static gint offset_x = 0; /* */ +static gint offset_y = 0; /* offset for cloning */ +static gint first = TRUE; +static gint trans_tx, trans_ty; /* transformed target */ static GDisplay *the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable *src_drawable_ = NULL; /* source drawable */ static GimpDrawable *non_gui_src_drawable; -static int non_gui_offset_x; -static int non_gui_offset_y; +static gint non_gui_offset_x; +static gint non_gui_offset_y; static CloneType non_gui_type; -/* forward function declarations */ - -static void clone_draw (Tool *); -static void clone_motion (PaintCore *, GimpDrawable *, GimpDrawable *, - PaintPressureOptions *, CloneType, int, int); -static void clone_line_image (GImage *, GImage *, GimpDrawable *, - GimpDrawable *, unsigned char *, - unsigned char *, int, int, int, int); -static void clone_line_pattern (GImage *, GimpDrawable *, GPattern *, - unsigned char *, int, int, int, int); - /* functions */ @@ -128,8 +150,8 @@ static CloneOptions * clone_options_new (void) { CloneOptions *options; - GtkWidget *vbox; - GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *frame; /* the new clone tool options structure */ options = g_new (CloneOptions, 1); @@ -202,23 +224,24 @@ clone_set_src_drawable (GimpDrawable *drawable) } } -void * +static gpointer clone_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - gint state) + PaintState state) { - GDisplay * gdisp; - GDisplay * src_gdisp; - int x1, y1, x2, y2; - static int orig_src_x, orig_src_y; + GDisplay *gdisp; + GDisplay *src_gdisp; + gint x1, y1, x2, y2; + static gint orig_src_x, orig_src_y; - gdisp = (GDisplay *) active_tool->gdisp_ptr; + gdisp = (GDisplay *) active_tool->gdisp; switch (state) { case PRETRACE_PAINT: draw_core_pause (paint_core->core, active_tool); break; + case MOTION_PAINT: x1 = paint_core->curx; y1 = paint_core->cury; @@ -320,14 +343,11 @@ clone_paint_func (PaintCore *paint_core, void clone_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + gint x, y; gdisplay_untransform_coords (gdisp, (double) mevent->x, (double) mevent->y, &x, &y, TRUE, FALSE); @@ -661,10 +681,10 @@ clone_line_pattern (GImage *dest, } } -static void * -clone_non_gui_paint_func (PaintCore *paint_core, +static gpointer +clone_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { clone_motion (paint_core, drawable, non_gui_src_drawable, &non_gui_pressure_options, @@ -675,16 +695,16 @@ clone_non_gui_paint_func (PaintCore *paint_core, gboolean clone_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { GimpDrawable *src_drawable = NULL; CloneType clone_type = CLONE_DEFAULT_TYPE; - double local_src_x = 0.0; - double local_src_y = 0.0; + gdouble local_src_x = 0.0; + gdouble local_src_y = 0.0; CloneOptions *options = clone_options; - - if(options) + + if (options) { clone_type = options->type; src_drawable = src_drawable_; @@ -692,23 +712,23 @@ clone_non_gui_default (GimpDrawable *drawable, local_src_y = src_y; } - return clone_non_gui(drawable, - src_drawable, - clone_type, - local_src_x,local_src_y, - num_strokes,stroke_array); + return clone_non_gui (drawable, + src_drawable, + clone_type, + local_src_x,local_src_y, + num_strokes, stroke_array); } gboolean clone_non_gui (GimpDrawable *drawable, GimpDrawable *src_drawable, CloneType clone_type, - double src_x, - double src_y, - int num_strokes, - double *stroke_array) + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array) { - int i; + gint i; if (paint_core_init (&non_gui_paint_core, drawable, stroke_array[0], stroke_array[1])) diff --git a/app/tools/gimpsourcetool.h b/app/tools/gimpsourcetool.h index 0433bc488e..fcc2f1d247 100644 --- a/app/tools/gimpsourcetool.h +++ b/app/tools/gimpsourcetool.h @@ -26,21 +26,19 @@ typedef enum PATTERN_CLONE } CloneType; -void * clone_paint_func (PaintCore *, - GimpDrawable *, - gint); -gboolean clone_non_gui (GimpDrawable *, - GimpDrawable *, - CloneType, - gdouble, - gdouble, - gint, - gdouble *); -gboolean clone_non_gui_default (GimpDrawable *, - gint, - gdouble *); + +gboolean clone_non_gui (GimpDrawable *drawable, + GimpDrawable *src_drawable, + CloneType clone_type, + gdouble src_x, + gdouble src_y, + gint num_strokes, + gdouble *stroke_array); +gboolean clone_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_clone (void); -void tools_free_clone (Tool *); +void tools_free_clone (Tool *tool); #endif /* __CLONE_H__ */ diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index 33fd430364..3b1885d073 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -81,9 +81,9 @@ typedef struct _TextTool TextTool; struct _TextTool { - gint click_x; - gint click_y; - void *gdisp_ptr; + gint click_x; + gint click_y; + GDisplay *gdisp; }; typedef struct _TextOptions TextOptions; @@ -106,6 +106,39 @@ struct _TextOptions }; +static void text_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void text_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void text_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void text_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void text_dialog_create (void); +static void text_dialog_ok_callback (GtkWidget *widget, + gpointer data); +static void text_dialog_cancel_callback (GtkWidget *widget, + gpointer data); +static gint text_dialog_delete_callback (GtkWidget *widget, + GdkEvent *event, + gpointer data); + +static void text_init_render (TextTool *text_tool); +static void text_gdk_image_to_region (GdkImage *image, + gint , + PixelRegion *); +static void text_size_multiply (gchar **fontname, + gint size); +static void text_set_resolution (gchar **fontname, + gdouble xres, + gdouble yres); + + /* the text tool options */ static TextOptions *text_options = NULL; @@ -114,25 +147,6 @@ static TextTool *the_text_tool = NULL; static GtkWidget *text_tool_shell = NULL; -static void text_button_press (Tool *, GdkEventButton *, gpointer); -static void text_button_release (Tool *, GdkEventButton *, gpointer); -static void text_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void text_control (Tool *, ToolAction, gpointer); - -static void text_dialog_create (void); -static void text_dialog_ok_callback (GtkWidget *, gpointer); -static void text_dialog_cancel_callback (GtkWidget *, gpointer); -static gint text_dialog_delete_callback (GtkWidget *, GdkEvent *, gpointer); - -static void text_init_render (TextTool *); -static void text_gdk_image_to_region (GdkImage *, gint, PixelRegion *); -static void text_size_multiply (gchar **fontname, gint); -static void text_set_resolution (gchar **fontname, gdouble, gdouble); - -/* Layer * text_render (GImage *, GimpDrawable *, */ -/* gint, gint, gchar *, gchar *, gint, gint); */ - - /* functions */ static void @@ -304,19 +318,16 @@ text_call_gdyntext (GDisplay *gdisp) static void text_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; + Layer *layer; TextTool *text_tool; - gdisp = gdisp_ptr; - - text_tool = tool->private; - text_tool->gdisp_ptr = gdisp_ptr; + text_tool = tool->private; + text_tool->gdisp = gdisp; tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &text_tool->click_x, &text_tool->click_y, @@ -328,7 +339,7 @@ text_button_press (Tool *tool, /* If there is a floating selection, and this aint it, use the move tool */ if (layer_is_floating_sel (layer)) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_LAYER_TRANSLATE); return; } @@ -348,7 +359,7 @@ text_button_press (Tool *tool, static void text_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->state = INACTIVE; } @@ -356,13 +367,10 @@ text_button_release (Tool *tool, static void text_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; Layer *layer; - gint x, y; - - gdisp = (GDisplay *) gdisp_ptr; + gint x, y; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -387,7 +395,7 @@ text_cursor_update (Tool *tool, static void text_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -467,16 +475,16 @@ static void text_init_render (TextTool *text_tool) { GDisplay *gdisp; - gchar *fontname; - gchar *text; - gboolean antialias = text_options->antialias; + gchar *fontname; + gchar *text; + gboolean antialias = text_options->antialias; fontname = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG (text_tool_shell)); if (!fontname) return; - gdisp = (GDisplay *) text_tool->gdisp_ptr; + gdisp = text_tool->gdisp; /* override the user's antialias setting if this is an indexed image */ if (gimp_image_base_type (gdisp->gimage) == INDEXED) diff --git a/app/tools/gimptexttool.h b/app/tools/gimptexttool.h index 32deef8d3c..41633d6c35 100644 --- a/app/tools/gimptexttool.h +++ b/app/tools/gimptexttool.h @@ -20,14 +20,14 @@ #define __TEXT_TOOL_H__ +#define SUPERSAMPLE 3 + typedef enum { PIXELS, POINTS } SizeType; -#define SUPERSAMPLE 3 - Tool * tools_new_text (void); void tools_free_text (Tool *tool); diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c index 90d6cea647..5fefd450c6 100644 --- a/app/tools/gimpthresholdtool.c +++ b/app/tools/gimpthresholdtool.c @@ -56,36 +56,50 @@ struct _Threshold gint x, y; /* coords for last mouse click */ }; + +/* threshold action functions */ +static void threshold_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static ThresholdDialog * threshold_dialog_new (void); + +static void threshold_update (ThresholdDialog *td, + gint update); +static void threshold_preview (ThresholdDialog *td); +static void threshold_reset_callback (GtkWidget *widget, + gpointer data); +static void threshold_ok_callback (GtkWidget *widget, + gpointer data); +static void threshold_cancel_callback (GtkWidget *widget, + gpointer data); +static void threshold_preview_update (GtkWidget *widget, + gpointer data); +static void threshold_low_threshold_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void threshold_high_threshold_adjustment_update (GtkAdjustment *adj, + gpointer data); + +static void threshold (PixelRegion *, + PixelRegion *, + gpointer ); +static void threshold_histogram_range (HistogramWidget *, + gint , + gint , + gpointer ); + + /* the threshold tool options */ static ToolOptions *threshold_options = NULL; /* the threshold tool dialog */ static ThresholdDialog *threshold_dialog = NULL; -/* threshold action functions */ -static void threshold_control (Tool *, ToolAction, gpointer); -static ThresholdDialog * threshold_dialog_new (void); - -static void threshold_update (ThresholdDialog *, - gint); -static void threshold_preview (ThresholdDialog *); -static void threshold_reset_callback (GtkWidget *, gpointer); -static void threshold_ok_callback (GtkWidget *, gpointer); -static void threshold_cancel_callback (GtkWidget *, gpointer); -static void threshold_preview_update (GtkWidget *, gpointer); -static void threshold_low_threshold_adjustment_update (GtkAdjustment *, - gpointer); -static void threshold_high_threshold_adjustment_update (GtkAdjustment *, - gpointer); - -static void threshold (PixelRegion *, PixelRegion *, void *); -static void threshold_histogram_range (HistogramWidget *, gint, gint, - gpointer); /* threshold machinery */ void -threshold_2 (void *data, +threshold_2 (gpointer data, PixelRegion *srcPR, PixelRegion *destPR) { @@ -152,7 +166,7 @@ threshold (PixelRegion *srcPR, static void threshold_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -453,7 +467,7 @@ threshold_ok_callback (GtkWidget *widget, td->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -477,7 +491,7 @@ threshold_cancel_callback (GtkWidget *widget, gdisplays_flush (); } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/histogram_tool.c b/app/tools/histogram_tool.c index 5cb56d168f..2545e1e05a 100644 --- a/app/tools/histogram_tool.c +++ b/app/tools/histogram_tool.c @@ -51,23 +51,32 @@ struct _HistogramTool gint x, y; /* coords for last mouse click */ }; + +/* histogram_tool action functions */ +static void histogram_tool_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static HistogramToolDialog * histogram_tool_dialog_new (void); + +static void histogram_tool_close_callback (GtkWidget *widget, + gpointer data); +static void histogram_tool_channel_callback (GtkWidget *widget, + gpointer data); +static void histogram_tool_gradient_draw (GtkWidget *gdisp, + gint channel); + +static void histogram_tool_dialog_update (HistogramToolDialog *htd, + gint start, + gint end); + + /* the histogram tool options */ static ToolOptions * histogram_tool_options = NULL; /* the histogram tool dialog */ static HistogramToolDialog * histogram_tool_dialog = NULL; -/* histogram_tool action functions */ -static void histogram_tool_control (Tool *, ToolAction, gpointer); - -static HistogramToolDialog * histogram_tool_dialog_new (void); - -static void histogram_tool_close_callback (GtkWidget *, gpointer); -static void histogram_tool_channel_callback (GtkWidget *, gpointer); -static void histogram_tool_gradient_draw (GtkWidget *, gint); - -static void histogram_tool_dialog_update (HistogramToolDialog *, - gint, gint); /* histogram_tool machinery */ @@ -78,13 +87,13 @@ histogram_tool_histogram_range (HistogramWidget *widget, gpointer data) { HistogramToolDialog *htd; - gdouble pixels; - gdouble count; + gdouble pixels; + gdouble count; htd = (HistogramToolDialog *) data; if (htd == NULL || htd->hist == NULL || - gimp_histogram_nchannels(htd->hist) <= 0) + gimp_histogram_nchannels (htd->hist) <= 0) return; pixels = gimp_histogram_get_count (htd->hist, 0, 255); @@ -148,7 +157,7 @@ histogram_tool_dialog_update (HistogramToolDialog *htd, static void histogram_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -171,8 +180,8 @@ histogram_tool_control (Tool *tool, Tool * tools_new_histogram_tool (void) { - Tool * tool; - HistogramTool * private; + Tool *tool; + HistogramTool *private; /* The tool options */ if (! histogram_tool_options) @@ -181,7 +190,7 @@ tools_new_histogram_tool (void) tools_register (HISTOGRAM, histogram_tool_options); } - tool = tools_new_tool (HISTOGRAM); + tool = tools_new_tool (HISTOGRAM); private = g_new0 (HistogramTool, 1); tool->scroll_lock = TRUE; /* Disallow scrolling */ @@ -402,7 +411,7 @@ histogram_tool_close_callback (GtkWidget *widget, gimp_dialog_hide (htd->shell); - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -426,7 +435,7 @@ histogram_tool_gradient_draw (GtkWidget *gradient, { guchar buf[HISTOGRAM_WIDTH * 3]; guchar r, g, b; - gint i; + gint i; r = g = b = 0; switch (channel) @@ -458,5 +467,3 @@ histogram_tool_gradient_draw (GtkWidget *gradient, gtk_widget_queue_draw (gradient); } - - diff --git a/app/tools/histogram_tool.h b/app/tools/histogram_tool.h index 825d44e25a..ae4076b462 100644 --- a/app/tools/histogram_tool.h +++ b/app/tools/histogram_tool.h @@ -48,6 +48,7 @@ struct _HistogramToolDialog gint color; }; + /* histogram_tool functions */ Tool * tools_new_histogram_tool (void); void tools_free_histogram_tool (Tool *tool); diff --git a/app/tools/hue_saturation.c b/app/tools/hue_saturation.c index 0caf2f0a6f..fde7e3de2b 100644 --- a/app/tools/hue_saturation.c +++ b/app/tools/hue_saturation.c @@ -43,8 +43,8 @@ #define HUE_PARTITION_MASK GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK #define SLIDER_WIDTH 200 -#define DA_WIDTH 40 -#define DA_HEIGHT 20 +#define DA_WIDTH 40 +#define DA_HEIGHT 20 #define HUE_PARTITION 0x0 #define HUE_SLIDER 0x1 @@ -62,6 +62,38 @@ struct _HueSaturation gint x, y; /* coords for last mouse click */ }; + +/* hue saturation action functions */ +static void hue_saturation_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static HueSaturationDialog * hue_saturation_dialog_new (void); + +static void hue_saturation_update (HueSaturationDialog *hsd, + gint); +static void hue_saturation_preview (HueSaturationDialog *hsd); +static void hue_saturation_reset_callback (GtkWidget *, + gpointer); +static void hue_saturation_ok_callback (GtkWidget *, + gpointer); +static void hue_saturation_cancel_callback (GtkWidget *, + gpointer); +static void hue_saturation_partition_callback (GtkWidget *, + gpointer); +static void hue_saturation_preview_update (GtkWidget *, + gpointer); +static void hue_saturation_hue_adjustment_update (GtkAdjustment *, + gpointer); +static void hue_saturation_lightness_adjustment_update (GtkAdjustment *, + gpointer); +static void hue_saturation_saturation_adjustment_update (GtkAdjustment *, + gpointer); +static gint hue_saturation_hue_partition_events (GtkWidget *, + GdkEvent *, + HueSaturationDialog *hsd); + + /* the hue-saturation tool options */ static ToolOptions *hue_saturation_options = NULL; @@ -82,27 +114,6 @@ static gint default_colors[6][3] = { 255, 0, 255 } }; -/* hue saturation action functions */ -static void hue_saturation_control (Tool *, ToolAction, gpointer); - -static HueSaturationDialog * hue_saturation_dialog_new (void); - -static void hue_saturation_update (HueSaturationDialog *, - gint); -static void hue_saturation_preview (HueSaturationDialog *); -static void hue_saturation_reset_callback (GtkWidget *, gpointer); -static void hue_saturation_ok_callback (GtkWidget *, gpointer); -static void hue_saturation_cancel_callback (GtkWidget *, gpointer); -static void hue_saturation_partition_callback (GtkWidget *, gpointer); -static void hue_saturation_preview_update (GtkWidget *, gpointer); -static void hue_saturation_hue_adjustment_update (GtkAdjustment *, - gpointer); -static void hue_saturation_lightness_adjustment_update (GtkAdjustment *, - gpointer); -static void hue_saturation_saturation_adjustment_update (GtkAdjustment *, - gpointer); -static gint hue_saturation_hue_partition_events (GtkWidget *, GdkEvent *, - HueSaturationDialog *); /* hue saturation machinery */ @@ -223,7 +234,7 @@ hue_saturation (PixelRegion *srcPR, static void hue_saturation_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -691,7 +702,7 @@ hue_saturation_ok_callback (GtkWidget *widget, active_tool->preserve = TRUE; if (!hsd->preview) - image_map_apply (hsd->image_map, hue_saturation, (void *) hsd); + image_map_apply (hsd->image_map, hue_saturation, (gpointer) hsd); if (hsd->image_map) image_map_commit (hsd->image_map); @@ -700,7 +711,7 @@ hue_saturation_ok_callback (GtkWidget *widget, hsd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -724,7 +735,7 @@ hue_saturation_cancel_callback (GtkWidget *widget, hsd->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/hue_saturation.h b/app/tools/hue_saturation.h index 80ee176884..5fec88fa53 100644 --- a/app/tools/hue_saturation.h +++ b/app/tools/hue_saturation.h @@ -54,6 +54,7 @@ struct _HueSaturationDialog gboolean preview; }; + Tool * tools_new_hue_saturation (void); void tools_free_hue_saturation (Tool *tool); diff --git a/app/tools/ink.c b/app/tools/ink.c index 3673948f53..cf59f94716 100644 --- a/app/tools/ink.c +++ b/app/tools/ink.c @@ -57,7 +57,13 @@ /* the Ink structures */ -typedef Blob *(*BlobFunc) (gdouble, gdouble, gdouble, gdouble, gdouble, gdouble); +typedef Blob * (* BlobFunc) (gdouble, + gdouble, + gdouble, + gdouble, + gdouble, + gdouble); + typedef struct _InkTool InkTool; @@ -88,8 +94,8 @@ typedef struct _BrushWidget BrushWidget; struct _BrushWidget { - GtkWidget *widget; - gboolean state; + GtkWidget *widget; + gboolean state; }; typedef struct _InkOptions InkOptions; @@ -130,95 +136,109 @@ struct _InkOptions }; -/* the ink tool options */ -static InkOptions * ink_options = NULL; +/* local function prototypes */ + +static void ink_button_press (Tool *tool, + GdkEventButton *mevent, + GDisplay *gdisp); +static void ink_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void ink_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void ink_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void ink_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void time_smoother_add (InkTool *ink_tool, + guint32 value); +static gdouble time_smoother_result (InkTool *ink_tool); +static void time_smoother_init (InkTool *ink_tool, + guint32 initval); +static void dist_smoother_add (InkTool *ink_tool, + gdouble value); +static gdouble dist_smoother_result (InkTool *ink_tool); +static void dist_smoother_init (InkTool *ink_tool, + gdouble initval); + +static void ink_init (InkTool *ink_tool, + GimpDrawable *drawable, + gdouble x, + gdouble y); +static void ink_finish (InkTool *ink_tool, + GimpDrawable *drawable, + gint tool_id); +static void ink_cleanup (void); + +static void ink_type_update (GtkWidget *radio_button, + BlobFunc function); +static GdkPixmap * blob_pixmap (GdkColormap *colormap, + GdkVisual *visual, + BlobFunc function); +static void paint_blob (GdkDrawable *drawable, + GdkGC *gc, + Blob *blob); + +/* Rendering functions */ +static void ink_set_paint_area (InkTool *ink_tool, + GimpDrawable *drawable, + Blob *blob); +static void ink_paste (InkTool *ink_tool, + GimpDrawable *drawable, + Blob *blob); + +static void ink_to_canvas_tiles (InkTool *ink_tool, + Blob *blob, + guchar *color); + +static void ink_set_undo_tiles (GimpDrawable *drawable, + gint x, + gint y, + gint w, + gint h); +static void ink_set_canvas_tiles (gint x, + gint y, + gint w, + gint h); + +/* Brush pseudo-widget callbacks */ +static void brush_widget_active_rect (BrushWidget *brush_widget, + GtkWidget *widget, + GdkRectangle *rect); +static void brush_widget_realize (GtkWidget *widget); +static void brush_widget_expose (GtkWidget *widget, + GdkEventExpose *event, + BrushWidget *brush_widget); +static void brush_widget_button_press (GtkWidget *widget, + GdkEventButton *event, + BrushWidget *brush_widget); +static void brush_widget_button_release (GtkWidget *widget, + GdkEventButton *event, + BrushWidget *brush_widget); +static void brush_widget_motion_notify (GtkWidget *widget, + GdkEventMotion *event, + BrushWidget *brush_widget); + /* local variables */ +/* the ink tool options */ +static InkOptions *ink_options = NULL; + /* undo blocks variables */ -static TileManager * undo_tiles = NULL; +static TileManager *undo_tiles = NULL; /* Tiles used to render the stroke at 1 byte/pp */ -static TileManager * canvas_tiles = NULL; +static TileManager *canvas_tiles = NULL; /* Flat buffer that is used to used to render the dirty region * for composition onto the destination drawable */ -static TempBuf * canvas_buf = NULL; - - -/* local function prototypes */ - -static void ink_button_press (Tool *, GdkEventButton *, gpointer); -static void ink_button_release (Tool *, GdkEventButton *, gpointer); -static void ink_motion (Tool *, GdkEventMotion *, gpointer); -static void ink_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void ink_control (Tool *, ToolAction, gpointer); - -static void time_smoother_add (InkTool* ink_tool, guint32 value); -static gdouble time_smoother_result (InkTool* ink_tool); -static void time_smoother_init (InkTool* ink_tool, guint32 initval); -static void dist_smoother_add (InkTool* ink_tool, gdouble value); -static gdouble dist_smoother_result (InkTool* ink_tool); -static void dist_smoother_init (InkTool* ink_tool, gdouble initval); - -static void ink_init (InkTool *ink_tool, - GimpDrawable *drawable, - double x, - double y); -static void ink_finish (InkTool *ink_tool, - GimpDrawable *drawable, - int tool_id); -static void ink_cleanup (void); - -static void ink_type_update (GtkWidget *radio_button, - BlobFunc function); -static GdkPixmap *blob_pixmap (GdkColormap *colormap, - GdkVisual *visual, - BlobFunc function); -static void paint_blob (GdkDrawable *drawable, - GdkGC *gc, - Blob *blob); - -/* Rendering functions */ -static void ink_set_paint_area (InkTool *ink_tool, - GimpDrawable *drawable, - Blob *blob); -static void ink_paste (InkTool *ink_tool, - GimpDrawable *drawable, - Blob *blob); - -static void ink_to_canvas_tiles (InkTool *ink_tool, - Blob *blob, - guchar *color); - -static void ink_set_undo_tiles (GimpDrawable *drawable, - int x, - int y, - int w, - int h); -static void ink_set_canvas_tiles(int x, - int y, - int w, - int h); - -/* Brush pseudo-widget callbacks */ -static void brush_widget_active_rect (BrushWidget *brush_widget, - GtkWidget *w, - GdkRectangle *rect); -static void brush_widget_realize (GtkWidget *w); -static void brush_widget_expose (GtkWidget *w, - GdkEventExpose *event, - BrushWidget *brush_widget); -static void brush_widget_button_press (GtkWidget *w, - GdkEventButton *event, - BrushWidget *brush_widget); -static void brush_widget_button_release (GtkWidget *w, - GdkEventButton *event, - BrushWidget *brush_widget); -static void brush_widget_motion_notify (GtkWidget *w, - GdkEventMotion *event, - BrushWidget *brush_widget); +static TempBuf *canvas_buf = NULL; /* functions */ @@ -798,15 +818,13 @@ ink_pen_ellipse (gdouble x_center, gdouble y_center, static void ink_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { gdouble x, y; - GDisplay *gdisp; InkTool *ink_tool; GimpDrawable *drawable; Blob *b; - gdisp = (GDisplay *) gdisp_ptr; ink_tool = (InkTool *) tool->private; /* Keep the coordinates of the target */ @@ -816,8 +834,8 @@ ink_button_press (Tool *tool, ink_init (ink_tool, drawable, x, y); - tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->state = ACTIVE; + tool->gdisp = gdisp; tool->paused_count = 0; /* pause the current selection and grab the pointer */ @@ -834,7 +852,7 @@ ink_button_press (Tool *tool, GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->state = ACTIVE; b = ink_pen_ellipse (x, y, @@ -856,14 +874,12 @@ ink_button_press (Tool *tool, static void ink_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; - GImage * gimage; - InkTool * ink_tool; + GImage *gimage; + InkTool *ink_tool; - gdisp = (GDisplay *) gdisp_ptr; - gimage = gdisp->gimage; + gimage = gdisp->gimage; ink_tool = (InkTool *) tool->private; /* resume the current selection and ungrab the pointer */ @@ -965,21 +981,18 @@ time_smoother_add (InkTool* ink_tool, guint32 value) static void ink_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - InkTool *ink_tool; + InkTool *ink_tool; GimpDrawable *drawable; - Blob *b, *blob_union; + Blob *b, *blob_union; - double x, y; - double pressure; - double velocity; - double dist; + gdouble x, y; + gdouble pressure; + gdouble velocity; + gdouble dist; gdouble lasttime, thistime; - - gdisp = (GDisplay *) gdisp_ptr; ink_tool = (InkTool *) tool->private; gdisplay_untransform_coords_f (gdisp, mevent->x, mevent->y, &x, &y, TRUE); @@ -1034,14 +1047,11 @@ ink_motion (Tool *tool, static void ink_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; - GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; - - gdisp = (GDisplay *) gdisp_ptr; + Layer *layer; + GdkCursorType ctype = GDK_TOP_LEFT_ARROW; + gint x, y; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -1073,7 +1083,7 @@ ink_cursor_update (Tool *tool, static void ink_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { InkTool *ink_tool; @@ -1099,8 +1109,10 @@ ink_control (Tool *tool, } static void -ink_init (InkTool *ink_tool, GimpDrawable *drawable, - double x, double y) +ink_init (InkTool *ink_tool, + GimpDrawable *drawable, + gdouble x, + gdouble y) { /* free the block structures */ if (undo_tiles) @@ -1123,7 +1135,9 @@ ink_init (InkTool *ink_tool, GimpDrawable *drawable, } static void -ink_finish (InkTool *ink_tool, GimpDrawable *drawable, int tool_id) +ink_finish (InkTool *ink_tool, + GimpDrawable *drawable, + gint tool_id) { /* push an undo */ drawable_apply_image (drawable, ink_tool->x1, ink_tool->y1, @@ -1178,9 +1192,9 @@ ink_set_paint_area (InkTool *ink_tool, GimpDrawable *drawable, Blob *blob) { - int x, y, width, height; - int x1, y1, x2, y2; - int bytes; + gint x, y, width, height; + gint x1, y1, x2, y2; + gint bytes; blob_bounds (blob, &x, &y, &width, &height); @@ -1203,10 +1217,12 @@ enum { ROW_START, ROW_STOP }; /* The insertion sort here, for SUBSAMPLE = 8, tends to beat out * qsort() by 4x with CFLAGS=-O2, 2x with CFLAGS=-g */ -static void insert_sort (int *data, int n) +static void +insert_sort (gint *data, + gint n) { - int i, j, k; - int tmp1, tmp2; + gint i, j, k; + gint tmp1, tmp2; for (i=2; i<2*n; i+=2) { @@ -1230,7 +1246,7 @@ static void insert_sort (int *data, int n) static void fill_run (guchar *dest, guchar alpha, - int w) + gint w) { if (alpha == 255) { @@ -1247,17 +1263,20 @@ fill_run (guchar *dest, } static void -render_blob_line (Blob *blob, guchar *dest, - int x, int y, int width) +render_blob_line (Blob *blob, + guchar *dest, + gint x, + gint y, + gint width) { - int buf[4*SUBSAMPLE]; - int *data = buf; - int n = 0; - int i, j; - int current = 0; /* number of filled rows at this point - * in the scan line */ - - int last_x; + gint buf[4*SUBSAMPLE]; + gint *data = buf; + gint n = 0; + gint i, j; + gint current = 0; /* number of filled rows at this point + * in the scan line + */ + gint last_x; /* Sort start and ends for all lines */ @@ -1309,8 +1328,8 @@ render_blob_line (Blob *blob, guchar *dest, last_x = 0; for (i=0; icore = draw_core_new (ink_no_draw); + private->core = draw_core_new (ink_no_draw); private->last_blob = NULL; tool->private = private; @@ -1570,7 +1593,7 @@ tools_new_ink (void) void tools_free_ink (Tool *tool) { - InkTool * ink_tool; + InkTool *ink_tool; ink_tool = (InkTool *) tool->private; diff --git a/app/tools/ink.h b/app/tools/ink.h index 3dfb214846..9c35db1c6b 100644 --- a/app/tools/ink.h +++ b/app/tools/ink.h @@ -23,6 +23,7 @@ Tool * tools_new_ink (void); void tools_free_ink (Tool *tool); + /* Procedure definition and marshalling function */ extern ProcRecord ink_proc; diff --git a/app/tools/iscissors.c b/app/tools/iscissors.c index cf075959c2..793f3b32f3 100644 --- a/app/tools/iscissors.c +++ b/app/tools/iscissors.c @@ -133,6 +133,7 @@ struct _iscissors }; typedef struct _IScissorsOptions IScissorsOptions; + struct _IScissorsOptions { SelectionOptions selection_options; @@ -187,7 +188,7 @@ struct _IScissorsOptions /* static variables */ /* where to move on a given link direction */ -static int move [8][2] = +static gint move [8][2] = { { 1, 0 }, { 0, 1 }, @@ -271,57 +272,72 @@ static IScissorsOptions *iscissors_options = NULL; /***********************************************************************/ /* Local function prototypes */ -static void iscissors_button_press (Tool *, GdkEventButton *, gpointer); -static void iscissors_button_release (Tool *, GdkEventButton *, gpointer); -static void iscissors_motion (Tool *, GdkEventMotion *, gpointer); -static void iscissors_oper_update (Tool *, GdkEventMotion *, gpointer); -static void iscissors_modifier_update (Tool *, GdkEventKey *, gpointer); -static void iscissors_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void iscissors_control (Tool *, ToolAction, gpointer); +static void iscissors_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void iscissors_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void iscissors_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void iscissors_oper_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void iscissors_modifier_update (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void iscissors_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void iscissors_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); -static void iscissors_reset (Iscissors *iscissors); -static void iscissors_draw (Tool *tool); +static void iscissors_reset (Iscissors *iscissors); +static void iscissors_draw (Tool *tool); -static TileManager * gradient_map_new (GImage *gimage); +static TileManager * gradient_map_new (GImage *gimage); -static void find_optimal_path (TileManager *gradient_map, - TempBuf *dp_buf, - gint x1, - gint y1, - gint x2, - gint y2, - gint xs, - gint ys); -static void find_max_gradient (Iscissors *iscissors, - GImage *gimage, - gint *x, - gint *y); -static void calculate_curve (Tool *tool, - ICurve *curve); -static void iscissors_draw_curve (GDisplay *gdisp, - Iscissors *iscissors, - ICurve *curve); -static void iscissors_free_icurves (GSList *list); -static void iscissors_free_buffers (Iscissors *iscissors); +static void find_optimal_path (TileManager *gradient_map, + TempBuf *dp_buf, + gint x1, + gint y1, + gint x2, + gint y2, + gint xs, + gint ys); +static void find_max_gradient (Iscissors *iscissors, + GImage *gimage, + gint *x, + gint *y); +static void calculate_curve (Tool *tool, + ICurve *curve); +static void iscissors_draw_curve (GDisplay *gdisp, + Iscissors *iscissors, + ICurve *curve); +static void iscissors_free_icurves (GSList *list); +static void iscissors_free_buffers (Iscissors *iscissors); -static gint mouse_over_vertex (Iscissors *iscissors, - gint x, - gint y); -static gboolean clicked_on_vertex (Tool *tool); -static GSList * mouse_over_curve (Iscissors *iscissors, - gint x, - gint y); -static gboolean clicked_on_curve (Tool *tool); +static gint mouse_over_vertex (Iscissors *iscissors, + gint x, + gint y); +static gboolean clicked_on_vertex (Tool *tool); +static GSList * mouse_over_curve (Iscissors *iscissors, + gint x, + gint y); +static gboolean clicked_on_curve (Tool *tool); static void precalculate_arrays (void); -static GPtrArray * plot_pixels (Iscissors *iscissors, - TempBuf *dp_buf, - gint x1, - gint y1, - gint xs, - gint ys, - gint xe, - gint ye); +static GPtrArray * plot_pixels (Iscissors *iscissors, + TempBuf *dp_buf, + gint x1, + gint y1, + gint xs, + gint ys, + gint xe, + gint ye); + static void iscissors_options_reset (void) @@ -412,23 +428,21 @@ tools_free_iscissors (Tool *tool) static void iscissors_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; GimpDrawable *drawable; Iscissors *iscissors; gboolean grab_pointer = FALSE; - gdisp = (GDisplay *) gdisp_ptr; iscissors = (Iscissors *) tool->private; - drawable = gimp_image_active_drawable (gdisp->gimage); + drawable = gimp_image_active_drawable (gdisp->gimage); gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &iscissors->x, &iscissors->y, FALSE, FALSE); /* If the tool was being used in another image...reset it */ - if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp != tool->gdisp) { /*iscissors->draw = DRAW_CURVE; XXX? */ draw_core_stop (iscissors->core, tool); @@ -436,19 +450,19 @@ iscissors_button_press (Tool *tool, } tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; switch (iscissors->state) { case NO_ACTION: #if 0 /* XXX what's this supposed to do? */ - if (!(bevent->state & GDK_SHIFT_MASK) && - !(bevent->state & GDK_CONTROL_MASK)) - if (selection_point_inside (gdisp->select, gdisp_ptr, + if (! (bevent->state & GDK_SHIFT_MASK) && + ! (bevent->state & GDK_CONTROL_MASK)) + if (selection_point_inside (gdisp->select, gdisp, bevent->x, bevent->y)) { - init_edit_selection (tool, gdisp->select, gdisp_ptr, + init_edit_selection (tool, gdisp->select, gdisp, bevent->x, bevent->y); return; } @@ -534,17 +548,16 @@ iscissors_button_press (Tool *tool, static void iscissors_convert (Iscissors *iscissors, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp = (GDisplay *) gdisp_ptr; ScanConverter *sc; ScanConvertPoint *pts; - guint npts; - GSList *list; - ICurve *icurve; - guint packed; - gint i; - gint index; + guint npts; + GSList *list; + ICurve *icurve; + guint packed; + gint i; + gint index; sc = scan_converter_new (gdisp->gimage->width, gdisp->gimage->height, 1); @@ -583,13 +596,11 @@ iscissors_convert (Iscissors *iscissors, static void iscissors_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; ICurve *curve; - gdisp = (GDisplay *) gdisp_ptr; iscissors = (Iscissors *) tool->private; TRC (("iscissors_button_release\n")); @@ -694,18 +705,16 @@ iscissors_button_release (Tool *tool, /* convert the curves into a region */ if (iscissors->connected) - iscissors_convert (iscissors, gdisp_ptr); + iscissors_convert (iscissors, gdisp); } static void iscissors_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; - gdisp = (GDisplay *) gdisp_ptr; iscissors = (Iscissors *) tool->private; if (tool->state != ACTIVE || iscissors->state == NO_ACTION) @@ -763,16 +772,16 @@ iscissors_motion (Tool *tool, static void iscissors_draw (Tool *tool) { - GDisplay *gdisp; + GDisplay *gdisp; Iscissors *iscissors; - ICurve *curve; - GSList *list; - int tx1, ty1, tx2, ty2; - int txn, tyn; + ICurve *curve; + GSList *list; + gint tx1, ty1, tx2, ty2; + gint txn, tyn; TRC (("iscissors_draw\n")); - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; iscissors = (Iscissors *) tool->private; gdisplay_transform_coords (gdisp, iscissors->ix, iscissors->iy, &tx1, &ty1, @@ -900,14 +909,12 @@ iscissors_draw_curve (GDisplay *gdisp, static void iscissors_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; gint x, y; iscissors = (Iscissors *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -954,7 +961,7 @@ iscissors_oper_update (Tool *tool, static void iscissors_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; SelectOps op; @@ -997,13 +1004,11 @@ iscissors_modifier_update (Tool *tool, static void iscissors_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors *iscissors; - GDisplay *gdisp; iscissors = (Iscissors *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (iscissors->op) { @@ -1073,7 +1078,7 @@ iscissors_cursor_update (Tool *tool, static void iscissors_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { Iscissors * iscissors; Iscissors_draw draw; @@ -1409,11 +1414,11 @@ calculate_curve (Tool *tool, { GDisplay *gdisp; Iscissors *iscissors; - gint x, y, dir; - gint xs, ys, xe, ye; - gint x1, y1, x2, y2; - gint width, height; - gint ewidth, eheight; + gint x, y, dir; + gint xs, ys, xe, ye; + gint x1, y1, x2, y2; + gint width, height; + gint ewidth, eheight; TRC (("calculate_curve(%p, %p)\n", tool, curve)); @@ -1427,7 +1432,7 @@ calculate_curve (Tool *tool, * structure. */ - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; iscissors = (Iscissors *) tool->private; /* Get the bounding box */ diff --git a/app/tools/levels.c b/app/tools/levels.c index 7814babaaa..adcf1c9641 100644 --- a/app/tools/levels.c +++ b/app/tools/levels.c @@ -46,6 +46,7 @@ #include "libgimp/gimpintl.h" + #define LOW_INPUT 0x1 #define GAMMA 0x2 #define HIGH_INPUT 0x4 @@ -72,6 +73,7 @@ GDK_BUTTON1_MOTION_MASK | \ GDK_POINTER_MOTION_HINT_MASK + /* the levels structures */ typedef struct _Levels Levels; @@ -121,6 +123,61 @@ struct _LevelsDialog GimpLut *lut; }; + +/* levels action functions */ +static void levels_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static LevelsDialog * levels_dialog_new (void); + +static void levels_calculate_transfers (LevelsDialog *ld); +static void levels_update (LevelsDialog *ld, + gint channel); +static void levels_preview (LevelsDialog *ld); +static void levels_channel_callback (GtkWidget *widget, + gpointer data); +static void levels_reset_callback (GtkWidget *widget, + gpointer data); +static void levels_ok_callback (GtkWidget *widget, + gpointer data); +static void levels_cancel_callback (GtkWidget *widget, + gpointer data); +static void levels_auto_callback (GtkWidget *widget, + gpointer data); +static void levels_load_callback (GtkWidget *widget, + gpointer data); +static void levels_save_callback (GtkWidget *widget, + gpointer data); +static void levels_preview_update (GtkWidget *widget, + gpointer data); +static void levels_low_input_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_gamma_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_high_input_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_low_output_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static void levels_high_output_adjustment_update (GtkAdjustment *adjustment, + gpointer data); +static gint levels_input_da_events (GtkWidget *widget, + GdkEvent *event, + LevelsDialog *ld); +static gint levels_output_da_events (GtkWidget *widget, + GdkEvent *event, + LevelsDialog *ld); + +static void file_dialog_create (GtkWidget *widget); +static void file_dialog_ok_callback (GtkWidget *widget, + gpointer data); +static void file_dialog_cancel_callback (GtkWidget *widget, + gpointer data); + +static gboolean levels_read_from_file (FILE *f); +static void levels_write_to_file (FILE *f); + + /* the levels tool options */ static ToolOptions *levels_options = NULL; @@ -133,46 +190,13 @@ static gboolean load_save; static GtkWidget *color_option_items[5]; -/* levels action functions */ -static void levels_control (Tool *, ToolAction, gpointer); - -static LevelsDialog * levels_dialog_new (void); - -static void levels_calculate_transfers (LevelsDialog *); -static void levels_update (LevelsDialog *, gint); -static void levels_preview (LevelsDialog *); -static void levels_channel_callback (GtkWidget *, gpointer); -static void levels_reset_callback (GtkWidget *, gpointer); -static void levels_ok_callback (GtkWidget *, gpointer); -static void levels_cancel_callback (GtkWidget *, gpointer); -static void levels_auto_callback (GtkWidget *, gpointer); -static void levels_load_callback (GtkWidget *, gpointer); -static void levels_save_callback (GtkWidget *, gpointer); -static void levels_preview_update (GtkWidget *, gpointer); -static void levels_low_input_adjustment_update (GtkAdjustment *, gpointer); -static void levels_gamma_adjustment_update (GtkAdjustment *, gpointer); -static void levels_high_input_adjustment_update (GtkAdjustment *, gpointer); -static void levels_low_output_adjustment_update (GtkAdjustment *, gpointer); -static void levels_high_output_adjustment_update (GtkAdjustment *, gpointer); -static gint levels_input_da_events (GtkWidget *, GdkEvent *, - LevelsDialog *); -static gint levels_output_da_events (GtkWidget *, GdkEvent *, - LevelsDialog *); - -static void file_dialog_create (GtkWidget *); -static void file_dialog_ok_callback (GtkWidget *, gpointer); -static void file_dialog_cancel_callback (GtkWidget *, gpointer); - -static gboolean levels_read_from_file (FILE *f); -static void levels_write_to_file (FILE *f); - /* levels action functions */ static void levels_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -1028,7 +1052,7 @@ levels_ok_callback (GtkWidget *widget, ld->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -1052,7 +1076,7 @@ levels_cancel_callback (GtkWidget *widget, ld->image_map = NULL; } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/magnify.c b/app/tools/magnify.c index 25a9e8c90c..1d60a74324 100644 --- a/app/tools/magnify.c +++ b/app/tools/magnify.c @@ -70,25 +70,37 @@ struct _MagnifyOptions }; -/* the magnify tool options */ -static MagnifyOptions *magnify_options = NULL; - - /* magnify action functions */ -static void magnify_button_press (Tool *, GdkEventButton *, gpointer); -static void magnify_button_release (Tool *, GdkEventButton *, gpointer); -static void magnify_motion (Tool *, GdkEventMotion *, gpointer); -static void magnify_modifier_update (Tool *, GdkEventKey *, gpointer); -static void magnify_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void magnify_control (Tool *, ToolAction, gpointer); +static void magnify_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void magnify_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void magnify_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void magnify_modifier_update (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +static void magnify_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void magnify_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); /* magnify utility functions */ -static void zoom_in (gint *src, - gint *dest, - gint scale); -static void zoom_out (gint *src, - gint *dest, - gint scale); +static void zoom_in (gint *src, + gint *dest, + gint scale); +static void zoom_out (gint *src, + gint *dest, + gint scale); + + +/* the magnify tool options */ +static MagnifyOptions *magnify_options = NULL; /* magnify tool options functions */ @@ -193,13 +205,11 @@ zoom_out (gint *src, static void magnify_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; Magnify *magnify; - gint x, y; + gint x, y; - gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, TRUE, 0); @@ -216,7 +226,7 @@ magnify_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; draw_core_start (magnify->core, gdisp->canvas->window, @@ -227,17 +237,15 @@ magnify_button_press (Tool *tool, static void magnify_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Magnify *magnify; - GDisplay *gdisp; - gint win_width, win_height; - gint width, height; - gint scalesrc, scaledest; - gint scale; - gint x1, y1, x2, y2, w, h; + gint win_width, win_height; + gint width, height; + gint scalesrc, scaledest; + gint scale; + gint x1, y1, x2, y2, w, h; - gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -297,16 +305,14 @@ magnify_button_release (Tool *tool, static void magnify_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { Magnify *magnify; - GDisplay *gdisp; - gint x, y; + gint x, y; if (tool->state != ACTIVE) return; - gdisp = (GDisplay *) gdisp_ptr; magnify = (Magnify *) tool->private; draw_core_pause (magnify->core, tool); @@ -322,7 +328,7 @@ magnify_motion (Tool *tool, static void magnify_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (kevent->keyval) { @@ -344,12 +350,8 @@ magnify_modifier_update (Tool *tool, static void magnify_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - - gdisp = (GDisplay *) gdisp_ptr; - if (magnify_options->type == ZOOMIN) { gdisplay_install_tool_cursor (gdisp, GIMP_ZOOM_CURSOR, @@ -370,11 +372,9 @@ magnify_cursor_update (Tool *tool, void magnify_draw (Tool *tool) { - GDisplay *gdisp; Magnify *magnify; - gint x1, y1, x2, y2; + gint x1, y1, x2, y2; - gdisp = (GDisplay *) tool->gdisp_ptr; magnify = (Magnify *) tool->private; x1 = MIN (magnify->x, magnify->x + magnify->w); @@ -382,8 +382,8 @@ magnify_draw (Tool *tool) x2 = MAX (magnify->x, magnify->x + magnify->w); y2 = MAX (magnify->y, magnify->y + magnify->h); - gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); - gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); + gdisplay_transform_coords (tool->gdisp, x1, y1, &x1, &y1, 0); + gdisplay_transform_coords (tool->gdisp, x2, y2, &x2, &y2, 0); gdk_draw_rectangle (magnify->core->win, magnify->core->gc, 0, x1, y1, (x2 - x1), (y2 - y1)); @@ -393,7 +393,7 @@ magnify_draw (Tool *tool) static void magnify_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { Magnify *magnify; @@ -422,7 +422,7 @@ magnify_control (Tool *tool, Tool * tools_new_magnify (void) { - Tool *tool; + Tool *tool; Magnify *private; /* The tool options */ @@ -432,7 +432,7 @@ tools_new_magnify (void) tools_register (MAGNIFY, (ToolOptions *) magnify_options); } - tool = tools_new_tool (MAGNIFY); + tool = tools_new_tool (MAGNIFY); private = g_new0 (Magnify, 1); private->core = draw_core_new (magnify_draw); diff --git a/app/tools/measure.c b/app/tools/measure.c index 4e12bec9e5..70bf89a35c 100644 --- a/app/tools/measure.c +++ b/app/tools/measure.c @@ -47,6 +47,9 @@ #define ARC_RADIUS_2 1100 #define STATUSBAR_SIZE 128 +/* maximum information buffer size */ +#define MAX_INFO_BUF 16 + /* possible measure functions */ typedef enum { @@ -89,8 +92,27 @@ struct _MeasureOptions }; -/* maximum information buffer size */ -#define MAX_INFO_BUF 16 +/* local function prototypes */ +static void measure_tool_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void measure_tool_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void measure_tool_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void measure_tool_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void measure_tool_control (Tool *tool, + ToolAction action, + GDisplay *gdisp); + +static void measure_tool_info_window_close_callback (GtkWidget *widget, + gpointer data); +static void measure_tool_info_update (void); + static MeasureOptions *measure_tool_options = NULL; @@ -100,28 +122,6 @@ static gchar distance_buf[MAX_INFO_BUF]; static gchar angle_buf[MAX_INFO_BUF]; -/* local function prototypes */ -static void measure_tool_button_press (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -static void measure_tool_button_release (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr); -static void measure_tool_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); -static void measure_tool_cursor_update (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr); -static void measure_tool_control (Tool *tool, - ToolAction action, - gpointer gdisp_ptr); - -static void measure_tool_info_window_close_callback (GtkWidget *widget, - gpointer data); -static void measure_tool_info_update (void); - - static void measure_tool_options_reset (void) { @@ -195,21 +195,19 @@ measure_get_angle (gint dx, static void measure_tool_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; gint x[3]; gint y[3]; gint i; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; /* if we are changing displays, pop the statusbar of the old one */ - if (tool->state == ACTIVE && gdisp_ptr != tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp != tool->gdisp) { - GDisplay *old_gdisp = tool->gdisp_ptr; + GDisplay *old_gdisp = tool->gdisp; gtk_statusbar_pop (GTK_STATUSBAR (old_gdisp->statusbar), measure_tool->context_id); @@ -219,7 +217,7 @@ measure_tool_button_press (Tool *tool, measure_tool->function = CREATING; - if (tool->state == ACTIVE && gdisp_ptr == tool->gdisp_ptr) + if (tool->state == ACTIVE && gdisp == tool->gdisp) { /* if the cursor is in one of the handles, * the new function will be moving or adding a new point or guide @@ -334,7 +332,7 @@ measure_tool_button_press (Tool *tool, measure_tool->function = ADDING; /* set the gdisplay */ - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; /* start drawing the measure tool */ draw_core_start (measure_tool->core, gdisp->canvas->window, tool); @@ -378,12 +376,10 @@ measure_tool_button_press (Tool *tool, static void measure_tool_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; measure_tool->function = FINISHED; @@ -395,9 +391,8 @@ measure_tool_button_release (Tool *tool, static void measure_tool_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; gint x, y; gint ax, ay; @@ -409,7 +404,6 @@ measure_tool_motion (Tool *tool, gdouble distance; gchar status_str[STATUSBAR_SIZE]; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; /* undraw the current tool */ @@ -607,22 +601,20 @@ measure_tool_motion (Tool *tool, static void measure_tool_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - MeasureTool *measure_tool; - GDisplay *gdisp; - gint x[3]; - gint y[3]; - gint i; - gboolean in_handle = FALSE; + MeasureTool *measure_tool; + gint x[3]; + gint y[3]; + gint i; + gboolean in_handle = FALSE; GdkCursorType ctype = GIMP_CROSSHAIR_SMALL_CURSOR; CursorModifier cmodifier = CURSOR_MODIFIER_NONE; - gdisp = (GDisplay *) gdisp_ptr; measure_tool = (MeasureTool *) tool->private; - if (tool->state == ACTIVE && tool->gdisp_ptr == gdisp_ptr) + if (tool->state == ACTIVE && tool->gdisp == gdisp) { for (i = 0; i < measure_tool->num_points; i++) { @@ -674,7 +666,6 @@ measure_tool_cursor_update (Tool *tool, static void measure_tool_draw (Tool *tool) { - GDisplay *gdisp; MeasureTool *measure_tool; gint x[3]; gint y[3]; @@ -682,12 +673,12 @@ measure_tool_draw (Tool *tool) gint angle1, angle2; gint draw_arc = 0; - gdisp = (GDisplay *) tool->gdisp_ptr; measure_tool = (MeasureTool *) tool->private; for (i = 0; i < measure_tool->num_points; i++) { - gdisplay_transform_coords (gdisp, measure_tool->x[i], measure_tool->y[i], + gdisplay_transform_coords (tool->gdisp, + measure_tool->x[i], measure_tool->y[i], &x[i], &y[i], FALSE); if (i == 0 && measure_tool->num_points == 3) { @@ -745,12 +736,10 @@ measure_tool_draw (Tool *tool) static void measure_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MeasureTool *measure_tool; - gdisp = (GDisplay *) tool->gdisp_ptr; measure_tool = (MeasureTool *) tool->private; switch (action) @@ -764,7 +753,8 @@ measure_tool_control (Tool *tool, break; case HALT: - gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), measure_tool->context_id); + gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), + measure_tool->context_id); draw_core_stop (measure_tool->core, tool); tool->state = INACTIVE; break; @@ -825,15 +815,13 @@ tools_new_measure_tool (void) void tools_free_measure_tool (Tool *tool) { - GDisplay *gdisp; MeasureTool *measure_tool; measure_tool = (MeasureTool *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; if (tool->state == ACTIVE) { - gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), + gtk_statusbar_pop (GTK_STATUSBAR (tool->gdisp->statusbar), measure_tool->context_id); draw_core_stop (measure_tool->core, tool); } @@ -845,5 +833,6 @@ tools_free_measure_tool (Tool *tool) info_dialog_free (measure_tool_info); measure_tool_info = NULL; } + g_free (measure_tool); } diff --git a/app/tools/move.c b/app/tools/move.c index 3b8e416564..1818da444b 100644 --- a/app/tools/move.c +++ b/app/tools/move.c @@ -45,6 +45,7 @@ /* the move structures */ typedef struct _MoveTool MoveTool; + struct _MoveTool { Layer *layer; @@ -53,6 +54,26 @@ struct _MoveTool }; +/* move tool action functions */ +static void move_tool_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void move_tool_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void move_tool_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void move_tool_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void move_tool_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void move_create_gc (GDisplay *gdisp); + + /* the move tool options */ static ToolOptions *move_options = NULL; @@ -60,48 +81,37 @@ static ToolOptions *move_options = NULL; static GdkGC *move_gc = NULL; -/* move tool action functions */ -static void move_tool_button_press (Tool *, GdkEventButton *, gpointer); -static void move_tool_button_release (Tool *, GdkEventButton *, gpointer); -static void move_tool_motion (Tool *, GdkEventMotion *, gpointer); -static void move_tool_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void move_tool_control (Tool *, ToolAction, gpointer); - -static void move_create_gc (GDisplay *gdisp); - - /* move action functions */ static void move_tool_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; MoveTool *move; Layer *layer; Guide *guide; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; move = (MoveTool *) tool->private; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; move->layer = NULL; move->guide = NULL; move->disp = NULL; - gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE); + gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, + FALSE, FALSE); if (bevent->state & GDK_MOD1_MASK && !gimage_mask_is_empty (gdisp->gimage)) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); tool->state = ACTIVE; } else if (bevent->state & GDK_SHIFT_MASK) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_LAYER_TRANSLATE); tool->state = ACTIVE; } else @@ -138,7 +148,7 @@ move_tool_button_press (Tool *tool, else { gimp_image_set_active_layer (gdisp->gimage, layer); - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_LAYER_TRANSLATE); } tool->state = ACTIVE; } @@ -202,15 +212,13 @@ move_draw_guide (GDisplay *gdisp, static void move_tool_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; - GDisplay *gdisp; gboolean delete_guide; gint x1, y1; gint x2, y2; - gdisp = (GDisplay *) gdisp_ptr; move = (MoveTool *) tool->private; gdk_flush (); @@ -259,7 +267,7 @@ move_tool_button_release (Tool *tool, } else { - move_tool_motion (tool, NULL, gdisp_ptr); + move_tool_motion (tool, NULL, gdisp); } selection_resume (gdisp->select); @@ -285,15 +293,13 @@ move_tool_button_release (Tool *tool, static void move_tool_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; - GDisplay *gdisp; gint x, y; move = (MoveTool *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; if (move->guide) { @@ -323,16 +329,14 @@ move_tool_motion (Tool *tool, static void move_tool_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; - GDisplay *gdisp; Guide *guide; Layer *layer; gint x, y; move = (MoveTool *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -357,7 +361,7 @@ move_tool_cursor_update (Tool *tool, if (gdisp->draw_guides && (guide = gdisplay_find_guide (gdisp, mevent->x, mevent->y))) { - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; gdisplay_install_tool_cursor (gdisp, GDK_HAND2, TOOL_TYPE_NONE, CURSOR_MODIFIER_HAND, @@ -372,10 +376,10 @@ move_tool_cursor_update (Tool *tool, gdisplay_draw_guide (gdisp, move->guide, FALSE); } - gdisp = gdisp_ptr; + gdisp = gdisp; gdisplay_draw_guide (gdisp, guide, TRUE); move->guide = guide; - move->disp = gdisp; + move->disp = gdisp; } } else if ((layer = gimp_image_pick_correlate_layer (gdisp->gimage, x, y))) @@ -412,7 +416,7 @@ move_tool_cursor_update (Tool *tool, static void move_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { MoveTool *move; @@ -425,7 +429,7 @@ move_tool_control (Tool *tool, case RESUME: if (move->guide) - gdisplay_draw_guide (gdisp_ptr, move->guide, TRUE); + gdisplay_draw_guide (gdisp, move->guide, TRUE); break; case HALT: @@ -458,7 +462,7 @@ move_tool_start_hguide (Tool *tool, selection_pause (gdisp->select); - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->scroll_lock = TRUE; private = tool->private; @@ -482,7 +486,7 @@ move_tool_start_vguide (Tool *tool, selection_pause (gdisp->select); - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->scroll_lock = TRUE; private = tool->private; @@ -539,10 +543,10 @@ tools_free_move_tool (Tool *tool) move = (MoveTool *) tool->private; - if (tool->gdisp_ptr) + if (tool->gdisp) { if (move->guide) - gdisplay_draw_guide (tool->gdisp_ptr, move->guide, FALSE); + gdisplay_draw_guide (tool->gdisp, move->guide, FALSE); } g_free (move); diff --git a/app/tools/paint_core.c b/app/tools/paint_core.c index b6ca82f003..bf257188ff 100644 --- a/app/tools/paint_core.c +++ b/app/tools/paint_core.c @@ -196,18 +196,16 @@ paint_core_sample_color (GimpDrawable *drawable, void -paint_core_button_press (Tool *tool, - GdkEventButton *bevent, - gpointer gdisp_ptr) +paint_core_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp) { PaintCore *paint_core; - GDisplay *gdisp; GimpBrush *current_brush; gboolean draw_line; gdouble x, y; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; paint_core = (PaintCore *) tool->private; g_return_if_fail (gdisp != NULL); @@ -230,7 +228,7 @@ paint_core_button_press (Tool *tool, #endif /* GTK_HAVE_SIX_VALUATORS */ paint_core->state = bevent->state; - if (gdisp_ptr != tool->gdisp_ptr || + if (gdisp != tool->gdisp || paint_core->context_id < 1) { /* initialize the statusbar display */ @@ -239,7 +237,7 @@ paint_core_button_press (Tool *tool, } /* if this is a new image, reinit the core vals */ - if ((gdisp_ptr != tool->gdisp_ptr) || ! (bevent->state & GDK_SHIFT_MASK)) + if ((gdisp != tool->gdisp) || ! (bevent->state & GDK_SHIFT_MASK)) { /* initialize some values */ paint_core->startx = paint_core->lastx = paint_core->curx = x; @@ -295,7 +293,7 @@ paint_core_button_press (Tool *tool, } tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; tool->paused_count = 0; /* pause the current selection and grab the pointer */ @@ -369,7 +367,7 @@ paint_core_button_press (Tool *tool, if (paint_core->flags & TOOL_TRACES_ON_WINDOW) (* paint_core->paint_func) (paint_core, drawable, PRETRACE_PAINT); - + gdisplay_flush_now (gdisp); if (paint_core->flags & TOOL_TRACES_ON_WINDOW) @@ -382,14 +380,12 @@ paint_core_button_press (Tool *tool, void paint_core_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; GImage *gimage; PaintCore *paint_core; - gdisp = (GDisplay *) gdisp_ptr; - gimage = gdisp->gimage; + gimage = gdisp->gimage; paint_core = (PaintCore *) tool->private; /* resume the current selection and ungrab the pointer */ @@ -415,14 +411,12 @@ paint_core_button_release (Tool *tool, } void -paint_core_motion (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr) +paint_core_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp) { - GDisplay *gdisp; PaintCore *paint_core; - gdisp = (GDisplay *) gdisp_ptr; paint_core = (PaintCore *) tool->private; gdisplay_untransform_coords_f (gdisp, (double) mevent->x, (double) mevent->y, @@ -470,11 +464,10 @@ paint_core_motion (Tool *tool, } void -paint_core_cursor_update (Tool *tool, - GdkEventMotion *mevent, - gpointer gdisp_ptr) +paint_core_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp) { - GDisplay *gdisp; Layer *layer; PaintCore *paint_core; gint x, y; @@ -484,14 +477,12 @@ paint_core_cursor_update (Tool *tool, CursorModifier cmodifier = CURSOR_MODIFIER_NONE; gboolean ctoggle = FALSE; - gdisp = (GDisplay *) gdisp_ptr; paint_core = (PaintCore *) tool->private; /* undraw the current tool */ draw_core_pause (paint_core->core, tool); - if (gdisp_ptr != tool->gdisp_ptr || - paint_core->context_id < 1) + if (gdisp != tool->gdisp || paint_core->context_id < 1) { /* initialize the statusbar display */ paint_core->context_id = @@ -504,16 +495,16 @@ paint_core_cursor_update (Tool *tool, if ((layer = gimp_image_get_active_layer (gdisp->gimage))) { /* If shift is down and this is not the first paint stroke, draw a line */ - if (gdisp_ptr == tool->gdisp_ptr && (mevent->state & GDK_SHIFT_MASK)) + if (gdisp == tool->gdisp && (mevent->state & GDK_SHIFT_MASK)) { gdouble dx, dy, d; - ctype = GDK_PENCIL; + ctype = GDK_PENCIL; /* Get the current coordinates */ - gdisplay_untransform_coords_f (gdisp, - (double) mevent->x, + gdisplay_untransform_coords_f (gdisp, + (double) mevent->x, (double) mevent->y, - &paint_core->curx, + &paint_core->curx, &paint_core->cury, TRUE); dx = paint_core->curx - paint_core->lastx; @@ -527,7 +518,7 @@ paint_core_cursor_update (Tool *tool, gint tangens2[6] = { 34, 106, 196, 334, 618, 1944 }; gint cosinus[7] = { 256, 247, 222, 181, 128, 66, 0 }; gint i, radius, frac; - + if (idy) { radius = sqrt (SQR (idx) + SQR (idy)); @@ -640,17 +631,15 @@ paint_core_cursor_update (Tool *tool, } void -paint_core_control (Tool *tool, - ToolAction action, - gpointer gdisp_ptr) +paint_core_control (Tool *tool, + ToolAction action, + GDisplay *gdisp) { PaintCore *paint_core; - GDisplay *gdisp; GimpDrawable *drawable; - gdisp = (GDisplay *) gdisp_ptr; paint_core = (PaintCore *) tool->private; - drawable = gimp_image_active_drawable (gdisp->gimage); + drawable = gimp_image_active_drawable (gdisp->gimage); switch (action) { @@ -684,7 +673,7 @@ paint_core_draw (Tool *tool) and we don't care about a redraw */ if (paint_core->core->gc != NULL) { - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; gdisplay_transform_coords (gdisp, paint_core->lastx, paint_core->lasty, &tx1, &ty1, 1); @@ -853,10 +842,9 @@ paint_core_interpolate (PaintCore *paint_core, { GimpBrush *current_brush; GimpVector2 delta; -#ifdef GTK_HAVE_SIX_VALUATORS - gdouble dpressure, dxtilt, dytilt, dwheel; -#else /* !GTK_HAVE_SIX_VALUATORS */ gdouble dpressure, dxtilt, dytilt; +#ifdef GTK_HAVE_SIX_VALUATORS + gdouble dwheel; #endif /* GTK_HAVE_SIX_VALUATORS */ /* double spacing; */ /* double lastscale, curscale; */ @@ -888,7 +876,7 @@ paint_core_interpolate (PaintCore *paint_core, #endif /* GTK_HAVE_SIX_VALUATORS */ return; -/* calculate the distance traveled in the coordinate space of the brush */ + /* calculate the distance traveled in the coordinate space of the brush */ mag = gimp_vector2_length (&(paint_core->brush->x_axis)); xd = gimp_vector2_inner_product (&delta, &(paint_core->brush->x_axis)) / (mag*mag); @@ -897,11 +885,11 @@ paint_core_interpolate (PaintCore *paint_core, yd = gimp_vector2_inner_product (&delta, &(paint_core->brush->y_axis)) / (mag*mag); - dist = 0.5 * sqrt (xd*xd + yd*yd); - total = dist + paint_core->distance; + dist = 0.5 * sqrt (xd*xd + yd*yd); + total = dist + paint_core->distance; initial = paint_core->distance; - pixel_dist = gimp_vector2_length (&delta); + pixel_dist = gimp_vector2_length (&delta); pixel_initial = paint_core->pixel_dist; /* FIXME: need to adapt the spacing to the size */ @@ -911,9 +899,9 @@ paint_core_interpolate (PaintCore *paint_core, while (paint_core->distance < total) { - n = (int) (paint_core->distance / paint_core->spacing + 1.0 + EPSILON); + n = (gint) (paint_core->distance / paint_core->spacing + 1.0 + EPSILON); left = n * paint_core->spacing - paint_core->distance; - + paint_core->distance += left; if (paint_core->distance <= (total+EPSILON)) @@ -943,6 +931,7 @@ paint_core_interpolate (PaintCore *paint_core, paint_core->brush = current_brush; } } + paint_core->distance = total; paint_core->pixel_dist = pixel_initial + pixel_dist; paint_core->curx = paint_core->lastx + delta.x; @@ -1190,7 +1179,8 @@ paint_core_paste_canvas (PaintCore *paint_core, MaskBuf *brush_mask; /* get the brush mask */ - brush_mask = paint_core_get_brush_mask (paint_core, brush_hardness, brush_scale); + brush_mask = paint_core_get_brush_mask (paint_core, + brush_hardness, brush_scale); /* paste the canvas buf */ paint_core_paste (paint_core, brush_mask, drawable, @@ -1255,9 +1245,9 @@ paint_core_calculate_brush_size (MaskBuf *mask, ratio = 1 / 16; else ratio = sqrt (scale); - - *width = MAX ((gint)(mask->width * ratio + 0.5), 1); - *height = MAX ((gint)(mask->height * ratio + 0.5), 1); + + *width = MAX ((gint) (mask->width * ratio + 0.5), 1); + *height = MAX ((gint) (mask->height * ratio + 0.5), 1); } } @@ -1279,12 +1269,12 @@ paint_core_subsample_mask (MaskBuf *mask, gint r, s; x += (x < 0) ? mask->width : 0; - left = x - floor(x); - index1 = (int) (left * (gdouble)(SUBSAMPLE + 1)); + left = x - floor (x); + index1 = (gint) (left * (gdouble) (SUBSAMPLE + 1)); y += (y < 0) ? mask->height : 0; - left = y - floor(y); - index2 = (int) (left * (gdouble)(SUBSAMPLE + 1)); + left = y - floor (y); + index2 = (gint) (left * (gdouble) (SUBSAMPLE + 1)); kernel = subsample[index2][index1]; @@ -1307,7 +1297,7 @@ paint_core_subsample_mask (MaskBuf *mask, last_brush_mask = mask; cache_invalid = FALSE; } - + dest = kernel_brushes[index2][index1] = mask_buf_new (mask->width + 2, mask->height + 2); @@ -1416,9 +1406,10 @@ paint_core_pressurize_mask (MaskBuf *brush_mask, } #else /* ! FANCY_PRESSURE */ - for (i=0;i<256;i++) + for (i = 0; i < 256; i++) { - int tmp = (pressure/0.5)*i; + gint tmp = (pressure / 0.5) * i; + if (tmp > 255) mapi[i] = 255; else @@ -1430,7 +1421,7 @@ paint_core_pressurize_mask (MaskBuf *brush_mask, /* Now convert the brush */ source = mask_buf_data (subsample_mask); - dest = mask_buf_data (pressure_brush); + dest = mask_buf_data (pressure_brush); i = subsample_mask->width * subsample_mask->height; while (i--) @@ -1527,13 +1518,13 @@ paint_core_scale_pixmap (MaskBuf *brush_mask, scale = CLAMP (scale, 0.0, 1.0); - if (scale == 0.0) + if (scale == 0.0) return NULL; if (scale == 1.0) return brush_mask; - paint_core_calculate_brush_size (brush_mask, scale, + paint_core_calculate_brush_size (brush_mask, scale, &dest_width, &dest_height); if (brush_mask == last_brush && !cache_invalid && @@ -1568,13 +1559,15 @@ paint_core_get_brush_mask (PaintCore *paint_core, switch (brush_hardness) { case SOFT: - mask = paint_core_subsample_mask (mask, paint_core->curx, paint_core->cury); + mask = paint_core_subsample_mask (mask, + paint_core->curx, paint_core->cury); break; case HARD: mask = paint_core_solidify_mask (mask); break; case PRESSURE: - mask = paint_core_pressurize_mask (mask, paint_core->curx, paint_core->cury, + mask = paint_core_pressurize_mask (mask, + paint_core->curx, paint_core->cury, paint_core->curpressure); break; default: @@ -1623,8 +1616,10 @@ paint_core_paste (PaintCore *paint_core, /* Otherwise: * combine the canvas buf and the brush mask to the canvas buf */ - else /* mode != CONSTANT */ - brush_to_canvas_buf (paint_core, brush_mask, brush_opacity); + else + { + brush_to_canvas_buf (paint_core, brush_mask, brush_opacity); + } /* intialize canvas buf source pixel regions */ srcPR.bytes = canvas_buf->bytes; @@ -1678,7 +1673,7 @@ paint_core_replace (PaintCore *paint_core, gint offx; gint offy; - if (!drawable_has_alpha (drawable)) + if (! drawable_has_alpha (drawable)) { paint_core_paste (paint_core, brush_mask, drawable, brush_opacity, image_opacity, NORMAL_MODE, @@ -1711,7 +1706,7 @@ paint_core_replace (PaintCore *paint_core, canvas_buf->x, canvas_buf->y, canvas_buf->width, canvas_buf->height, FALSE); } - else + else { /* The mask is just the brush mask */ maskPR.bytes = 1; @@ -1722,7 +1717,7 @@ paint_core_replace (PaintCore *paint_core, maskPR.rowstride = maskPR.bytes * brush_mask->width; maskPR.data = mask_buf_data (brush_mask); } - + /* intialize canvas buf source pixel regions */ srcPR.bytes = canvas_buf->bytes; srcPR.x = 0; diff --git a/app/tools/paint_core.h b/app/tools/paint_core.h index bc6ade3edd..9621bdef3f 100644 --- a/app/tools/paint_core.h +++ b/app/tools/paint_core.h @@ -22,13 +22,16 @@ /* the different states that the painting function can be called with */ -#define INIT_PAINT 0 /* Setup PaintFunc internals */ -#define MOTION_PAINT 1 /* PaintFunc performs motion-related rendering */ -#define PAUSE_PAINT 2 /* Unused. Reserved */ -#define RESUME_PAINT 3 /* Unused. Reserved */ -#define FINISH_PAINT 4 /* Cleanup and/or reset PaintFunc operation */ -#define PRETRACE_PAINT 5 /* PaintFunc performs window tracing activity prior to rendering */ -#define POSTTRACE_PAINT 6 /* PaintFunc performs window tracing activity following rendering */ +typedef enum /*< skip >*/ +{ + INIT_PAINT, /* Setup PaintFunc internals */ + MOTION_PAINT, /* PaintFunc performs motion-related rendering */ + PAUSE_PAINT, /* Unused. Reserved */ + RESUME_PAINT, /* Unused. Reserved */ + FINISH_PAINT, /* Cleanup and/or reset PaintFunc operation */ + PRETRACE_PAINT, /* PaintFunc performs window tracing activity prior to rendering */ + POSTTRACE_PAINT /* PaintFunc performs window tracing activity following rendering */ +} PaintState; typedef enum /*< skip >*/ { @@ -44,54 +47,56 @@ typedef enum /*< skip >*/ */ } ToolFlags; -typedef void * (* PaintFunc) (PaintCore *, GimpDrawable *, int); +typedef gpointer (* PaintFunc) (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState paint_state); struct _PaintCore { - DrawCore * core; /* Core select object */ + DrawCore * core; /* Core select object */ - double startx; /* starting x coord */ - double starty; /* starting y coord */ - double startpressure; /* starting pressure */ - double startxtilt; /* starting xtilt */ - double startytilt; /* starting ytilt */ + gdouble startx; /* starting x coord */ + gdouble starty; /* starting y coord */ + gdouble startpressure; /* starting pressure */ + gdouble startxtilt; /* starting xtilt */ + gdouble startytilt; /* starting ytilt */ #ifdef GTK_HAVE_SIX_VALUATORS - double startwheel; /* starting wheel */ + gdouble startwheel; /* starting wheel */ #endif /* GTK_HAVE_SIX_VALUATORS */ - double curx; /* current x coord */ - double cury; /* current y coord */ - double curpressure; /* current pressure */ - double curxtilt; /* current xtilt */ - double curytilt; /* current ytilt */ + gdouble curx; /* current x coord */ + gdouble cury; /* current y coord */ + gdouble curpressure; /* current pressure */ + gdouble curxtilt; /* current xtilt */ + gdouble curytilt; /* current ytilt */ #ifdef GTK_HAVE_SIX_VALUATORS - double curwheel; /* current wheel */ + gdouble curwheel; /* current wheel */ #endif /* GTK_HAVE_SIX_VALUATORS */ - double lastx; /* last x coord */ - double lasty; /* last y coord */ - double lastpressure; /* last pressure */ - double lastxtilt; /* last xtilt */ - double lastytilt; /* last ytilt */ + gdouble lastx; /* last x coord */ + gdouble lasty; /* last y coord */ + gdouble lastpressure; /* last pressure */ + gdouble lastxtilt; /* last xtilt */ + gdouble lastytilt; /* last ytilt */ #ifdef GTK_HAVE_SIX_VALUATORS - double lastwheel; /* last wheel */ + gdouble lastwheel; /* last wheel */ #endif /* GTK_HAVE_SIX_VALUATORS */ - int state; /* state of buttons and keys */ + gint state; /* state of buttons and keys */ - double distance; /* distance traveled by brush */ - double pixel_dist; /* distance in pixels */ - double spacing; /* spacing */ + gdouble distance; /* distance traveled by brush */ + gdouble pixel_dist; /* distance in pixels */ + gdouble spacing; /* spacing */ - int x1, y1; /* image space coordinate */ - int x2, y2; /* image space coords */ + gint x1, y1; /* image space coordinate */ + gint x2, y2; /* image space coords */ - GimpBrush * brush; /* current brush */ + GimpBrush * brush; /* current brush */ PaintFunc paint_func; /* painting function */ - int pick_colors; /* pick color if ctrl or alt is pressed */ - int pick_state; /* was ctrl or alt pressed when clicked? */ + gboolean pick_colors; /* pick color if ctrl or alt is pressed */ + gboolean pick_state; /* was ctrl or alt pressed when clicked? */ ToolFlags flags; /* tool flags, see ToolFlags above */ guint context_id; /* for the statusbar */ @@ -100,30 +105,38 @@ struct _PaintCore extern PaintCore non_gui_paint_core; /* Special undo type */ -typedef struct _paint_undo PaintUndo; +typedef struct _PaintUndo PaintUndo; -struct _paint_undo +struct _PaintUndo { - int tool_ID; - double lastx; - double lasty; - double lastpressure; - double lastxtilt; - double lastytilt; + gint tool_ID; + gdouble lastx; + gdouble lasty; + gdouble lastpressure; + gdouble lastxtilt; + gdouble lastytilt; #ifdef GTK_HAVE_SIX_VALUATORS - double lastwheel; + gdouble lastwheel; #endif /* GTK_HAVE_SIX_VALUATORS */ }; /* paint tool action functions */ -void paint_core_button_press (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr); -void paint_core_button_release (Tool *tool, GdkEventButton *bevent, gpointer gdisp_ptr); -void paint_core_motion (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr); -void paint_core_cursor_update (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr); +void paint_core_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void paint_core_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void paint_core_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +void paint_core_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); void paint_core_control (Tool *tool, - ToolAction action, - gpointer gdisp_ptr); + ToolAction action, + GDisplay *gdisp); /* paint tool functions */ void paint_core_no_draw (Tool *tool); @@ -180,4 +193,5 @@ void paint_core_color_area_with_pixmap (PaintCore *paint_core, gdouble scale, BrushApplicationMode mode); + #endif /* __PAINT_CORE_H__ */ diff --git a/app/tools/paintbrush.c b/app/tools/paintbrush.c index 25d9ff065e..da15b92719 100644 --- a/app/tools/paintbrush.c +++ b/app/tools/paintbrush.c @@ -62,6 +62,7 @@ /* the paintbrush structures */ typedef struct _PaintbrushOptions PaintbrushOptions; + struct _PaintbrushOptions { PaintOptions paint_options; @@ -108,13 +109,16 @@ static GimpUnit non_gui_gradient_unit; /* forward function declarations */ -static void paintbrush_motion (PaintCore *, - GimpDrawable *, - PaintPressureOptions *, - gdouble, - gdouble, - PaintApplicationMode, - GradientPaintMode); +static void paintbrush_motion (PaintCore *, + GimpDrawable *, + PaintPressureOptions *, + gdouble , + gdouble , + PaintApplicationMode , + GradientPaintMode ); +static gpointer paintbrush_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); /* functions */ @@ -125,7 +129,7 @@ paintbrush_gradient_toggle_callback (GtkWidget *widget, { PaintbrushOptions *options = paintbrush_options; - static int incremental_save = FALSE; + static gboolean incremental_save = FALSE; gimp_toggle_button_update (widget, data); @@ -147,8 +151,8 @@ static void paintbrush_options_reset (void) { PaintbrushOptions *options = paintbrush_options; - GtkWidget *spinbutton; - gint digits; + GtkWidget *spinbutton; + gint digits; paint_options_reset ((PaintOptions *) options); @@ -358,10 +362,10 @@ paintbrush_options_new (void) #define TIMED_BRUSH 0 -void * +static gpointer paintbrush_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { GDisplay *gdisp = gdisplay_active (); double fade_out; @@ -584,15 +588,15 @@ paintbrush_motion (PaintCore *paint_core, } -static void * +static gpointer paintbrush_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { - GImage *gimage; - double fade_out; - double gradient_length; - double unit_factor; + GImage *gimage; + gdouble fade_out; + gdouble gradient_length; + gdouble unit_factor; if (! (gimage = drawable_gimage (drawable))) return NULL; diff --git a/app/tools/paintbrush.h b/app/tools/paintbrush.h index ee55408ed8..4ce8b274a9 100644 --- a/app/tools/paintbrush.h +++ b/app/tools/paintbrush.h @@ -20,9 +20,6 @@ #define __PAINTBRUSH_H__ -void * paintbrush_paint_func (PaintCore *, - GimpDrawable *, - gint ); gboolean paintbrush_non_gui (GimpDrawable *, gint , gdouble *, diff --git a/app/tools/path_tool.c b/app/tools/path_tool.c index 252d4183d3..f25924ddaa 100644 --- a/app/tools/path_tool.c +++ b/app/tools/path_tool.c @@ -755,9 +755,8 @@ path_tool_cursor_position (Tool *tool, void path_tool_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; PathTool * path_tool; gint grab_pointer=0; gint x, y, halfwidth, dummy; @@ -766,9 +765,8 @@ path_tool_button_press (Tool *tool, fprintf (stderr, "path_tool_button_press\n"); #endif PATH_TOOL_DEBUG - gdisp = (GDisplay *) gdisp_ptr; path_tool = (PathTool *) tool->private; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; /* Transform window-coordinates to canvas-coordinates */ gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, TRUE, 0); @@ -1099,16 +1097,14 @@ path_tool_button_press_curve (Tool *tool, void path_tool_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; PathTool * path_tool; #ifdef PATH_TOOL_DEBUG fprintf (stderr, "path_tool_button_release\n"); #endif PATH_TOOL_DEBUG - gdisp = (GDisplay *) gdisp_ptr; path_tool = (PathTool *) tool->private; path_tool->state &= ~PATH_TOOL_DRAG; @@ -1125,14 +1121,12 @@ path_tool_button_release (Tool *tool, void path_tool_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; PathTool * path_tool; if (gtk_events_pending()) return; - gdisp = (GDisplay *) gdisp_ptr; path_tool = (PathTool *) tool->private; switch (path_tool->click_type) { @@ -1314,10 +1308,9 @@ path_tool_motion_curve (Tool *tool, void path_tool_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { PathTool *path_tool; - GDisplay *gdisp; gint x, y, halfwidth, dummy, cursor_location; #ifdef PATH_TOOL_DEBUG @@ -1325,7 +1318,6 @@ path_tool_cursor_update (Tool *tool, */ #endif PATH_TOOL_DEBUG - gdisp = (GDisplay *) gdisp_ptr; path_tool = (PathTool *) tool->private; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, TRUE, 0); @@ -1361,16 +1353,14 @@ path_tool_cursor_update (Tool *tool, void path_tool_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay * gdisp; PathTool * path_tool; #ifdef PATH_TOOL_DEBUG fprintf (stderr, "path_tool_control\n"); #endif PATH_TOOL_DEBUG - gdisp = (GDisplay *) tool->gdisp_ptr; path_tool = (PathTool *) tool->private; switch (action) @@ -1462,7 +1452,7 @@ tools_free_path_tool (Tool *tool) fprintf (stderr, "tools_free_path_tool start\n"); #endif PATH_TOOL_DEBUG path_tool = (PathTool *) tool->private; - gdisp = (GDisplay *) tool->gdisp_ptr; + gdisp = tool->gdisp; if (tool->state == ACTIVE) { @@ -1850,7 +1840,7 @@ path_tool_draw_helper (Path *path, return; } - gdisp = tool->gdisp_ptr; + gdisp = tool->gdisp; path_tool = (PathTool *) tool->private; core = path_tool->core; @@ -1894,7 +1884,7 @@ path_tool_draw (Tool *tool) fprintf (stderr, "path_tool_draw\n"); #endif PATH_TOOL_DEBUG - gdisp = tool->gdisp_ptr; + gdisp = tool->gdisp; path_tool = tool->private; cur_path = path_tool->cur_path; diff --git a/app/tools/pencil.c b/app/tools/pencil.c index 860d3da779..345a2a855b 100644 --- a/app/tools/pencil.c +++ b/app/tools/pencil.c @@ -40,6 +40,8 @@ #include "tool_options.h" +#define PENCIL_INCREMENTAL_DEFAULT FALSE + /* the pencil tool options */ typedef struct _PencilOptions PencilOptions; @@ -48,23 +50,29 @@ struct _PencilOptions PaintOptions paint_options; }; -static PencilOptions *pencil_options = NULL; /* forward function declarations */ -static void pencil_motion (PaintCore *, GimpDrawable *, - PaintPressureOptions *, gboolean); +static void pencil_motion (PaintCore *paint_core, + GimpDrawable *drawable, + PaintPressureOptions *pressure_options, + gboolean ); +static gpointer pencil_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); + + +static PencilOptions *pencil_options = NULL; static gboolean non_gui_incremental = FALSE; static void pencil_options_reset (void); -#define PENCIL_INCREMENTAL_DEFAULT FALSE /* functions */ -void * +gpointer pencil_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { switch (state) { @@ -203,10 +211,10 @@ pencil_motion (PaintCore *paint_core, HARD, scale, paint_appl_mode); } -static void * +static gpointer pencil_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { pencil_motion (paint_core, drawable, &non_gui_pressure_options, non_gui_incremental); diff --git a/app/tools/pencil.h b/app/tools/pencil.h index 5bdadd451c..888d3832ea 100644 --- a/app/tools/pencil.h +++ b/app/tools/pencil.h @@ -20,12 +20,9 @@ #define __PENCIL_H__ -void * pencil_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean pencil_non_gui (GimpDrawable *, - gint , - gdouble *); +gboolean pencil_non_gui (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_pencil (void); void tools_free_pencil (Tool *tool); diff --git a/app/tools/perspective_tool.c b/app/tools/perspective_tool.c index 166e4fb6fa..05af32400c 100644 --- a/app/tools/perspective_tool.c +++ b/app/tools/perspective_tool.c @@ -41,23 +41,28 @@ #include "libgimp/gimpintl.h" +/* forward function declarations */ +static TileManager * perspective_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); +static void perspective_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void perspective_tool_motion (Tool *tool, + GDisplay *gdisp); +static void perspective_info_update (Tool *tool); + + /* storage for information dialog fields */ static gchar matrix_row_buf [3][MAX_INFO_BUF]; -/* forward function declarations */ -static void perspective_tool_recalc (Tool *, void *); -static void perspective_tool_motion (Tool *, void *); -static void perspective_info_update (Tool *); -TileManager * +static TileManager * perspective_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { - GDisplay *gdisp; TransformCore *transform_core; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; switch (state) @@ -89,12 +94,12 @@ perspective_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - perspective_tool_motion (tool, gdisp_ptr); - perspective_tool_recalc (tool, gdisp_ptr); + perspective_tool_motion (tool, gdisp); + perspective_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - perspective_tool_recalc (tool, gdisp_ptr); + perspective_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -173,14 +178,12 @@ perspective_info_update (Tool *tool) } static void -perspective_tool_motion (Tool *tool, - void *gdisp_ptr) +perspective_tool_motion (Tool *tool, + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; gint diff_x, diff_y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; diff_x = transform_core->curx - transform_core->lastx; @@ -210,16 +213,14 @@ perspective_tool_motion (Tool *tool, } static void -perspective_tool_recalc (Tool *tool, - void *gdisp_ptr) +perspective_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; GimpMatrix3 m; gdouble cx, cy; gdouble scalex, scaley; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; /* determine the perspective transform that maps from diff --git a/app/tools/perspective_tool.h b/app/tools/perspective_tool.h index 611a85ecc1..39f31518ab 100644 --- a/app/tools/perspective_tool.h +++ b/app/tools/perspective_tool.h @@ -20,9 +20,6 @@ #define __PERSPECTIVE_TOOL_H__ -TileManager * perspective_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * perspective_tool_perspective (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/tools/posterize.c b/app/tools/posterize.c index c8c7cc728b..10b8b7722d 100644 --- a/app/tools/posterize.c +++ b/app/tools/posterize.c @@ -64,6 +64,27 @@ struct _PosterizeDialog GimpLut *lut; }; + +/* posterize action functions */ +static void posterize_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static PosterizeDialog * posterize_dialog_new (void); + +static void posterize_preview (PosterizeDialog *pd); +static void posterize_reset_callback (GtkWidget *widget, + gpointer data); +static void posterize_ok_callback (GtkWidget *widget, + gpointer data); +static void posterize_cancel_callback (GtkWidget *widget, + gpointer data); +static void posterize_preview_update (GtkWidget *widget, + gpointer data); +static void posterize_levels_adjustment_update (GtkAdjustment *adjustment, + gpointer data); + + /* the posterize tool options */ static ToolOptions *posterize_options = NULL; @@ -71,24 +92,12 @@ static ToolOptions *posterize_options = NULL; static PosterizeDialog *posterize_dialog = NULL; -/* posterize action functions */ -static void posterize_control (Tool *, ToolAction, gpointer); - -static PosterizeDialog * posterize_dialog_new (void); - -static void posterize_preview (PosterizeDialog *); -static void posterize_reset_callback (GtkWidget *, gpointer); -static void posterize_ok_callback (GtkWidget *, gpointer); -static void posterize_cancel_callback (GtkWidget *, gpointer); -static void posterize_preview_update (GtkWidget *, gpointer); -static void posterize_levels_adjustment_update (GtkAdjustment *, gpointer); - /* posterize select action functions */ static void posterize_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -311,7 +320,7 @@ posterize_ok_callback (GtkWidget *widget, posterize_lut_setup( pd->lut, pd->levels, gimp_drawable_bytes (pd->drawable)); image_map_apply (pd->image_map, (ImageMapApplyFunc) gimp_lut_process_2, - (void *) pd->lut); + (gpointer) pd->lut); } if (pd->image_map) @@ -321,7 +330,7 @@ posterize_ok_callback (GtkWidget *widget, pd->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -345,7 +354,7 @@ posterize_cancel_callback (GtkWidget *widget, gdisplays_flush (); } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/rect_select.c b/app/tools/rect_select.c index 3dbca9e287..f7e6e21845 100644 --- a/app/tools/rect_select.c +++ b/app/tools/rect_select.c @@ -48,26 +48,29 @@ #define STATUSBAR_SIZE 128 +extern void ellipse_select (GimpImage *gimage, + gint x, + gint y, + gint w, + gint h, + SelectOps op, + gboolean antialias, + gboolean feather, + gdouble feather_radius); + +static void selection_tool_update_op_state (RectSelect *rect_sel, + gint x, + gint y, + gint state, + GDisplay *gdisp); + + /* the rectangular selection tool options */ static SelectionOptions *rect_options = NULL; /* in gimp, ellipses are rectangular, too ;) */ extern SelectionOptions *ellipse_options; -extern void ellipse_select (GimpImage *gimage, - gint x, - gint y, - gint w, - gint h, - SelectOps op, - gboolean antialias, - gboolean feather, - gdouble feather_radius); -static void selection_tool_update_op_state (RectSelect *rect_sel, - gint x, - gint y, - gint state, - GDisplay *gdisp); /*************************************/ /* Rectangular selection apparatus */ @@ -117,16 +120,14 @@ rect_select (GimpImage *gimage, void rect_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; RectSelect *rect_sel; gchar select_mode[STATUSBAR_SIZE]; gint x, y; GimpUnit unit = GIMP_UNIT_PIXEL; gdouble unit_factor; - gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, TRUE, 0); @@ -185,15 +186,15 @@ rect_select_button_press (Tool *tool, NULL, NULL, bevent->time); tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; switch (rect_sel->op) { case SELECTION_MOVE_MASK: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TRANSLATE); return; case SELECTION_MOVE: - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_MASK_TO_LAYER_TRANSLATE); return; default: break; @@ -228,15 +229,13 @@ rect_select_button_press (Tool *tool, void rect_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - GDisplay *gdisp; - gint x1, y1; - gint x2, y2; - gint w, h; + gint x1, y1; + gint x2, y2; + gint w, h; - gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; gdk_pointer_ungrab (bevent->time); @@ -301,18 +300,16 @@ rect_select_button_release (Tool *tool, void rect_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - GDisplay *gdisp; - gchar size[STATUSBAR_SIZE]; - gint ox, oy; - gint x, y; - gint w, h, s; - gint tw, th; - gdouble ratio; + gchar size[STATUSBAR_SIZE]; + gint ox, oy; + gint x, y; + gint w, h, s; + gint tw, th; + gdouble ratio; - gdisp = (GDisplay *) gdisp_ptr; rect_sel = (RectSelect *) tool->private; /* needed for immediate cursor update on modifier event */ @@ -326,7 +323,7 @@ rect_select_motion (Tool *tool, { rect_sel->op = SELECTION_REPLACE; - rect_select_cursor_update (tool, mevent, gdisp_ptr); + rect_select_cursor_update (tool, mevent, gdisp); } draw_core_pause (rect_sel->core, tool); @@ -472,12 +469,10 @@ rect_select_motion (Tool *tool, void rect_select_draw (Tool *tool) { - GDisplay *gdisp; RectSelect *rect_sel; - gint x1, y1; - gint x2, y2; + gint x1, y1; + gint x2, y2; - gdisp = (GDisplay *) tool->gdisp_ptr; rect_sel = (RectSelect *) tool->private; x1 = MIN (rect_sel->x, rect_sel->x + rect_sel->w); @@ -485,8 +480,8 @@ rect_select_draw (Tool *tool) x2 = MAX (rect_sel->x, rect_sel->x + rect_sel->w); y2 = MAX (rect_sel->y, rect_sel->y + rect_sel->h); - gdisplay_transform_coords (gdisp, x1, y1, &x1, &y1, 0); - gdisplay_transform_coords (gdisp, x2, y2, &x2, &y2, 0); + gdisplay_transform_coords (tool->gdisp, x1, y1, &x1, &y1, 0); + gdisplay_transform_coords (tool->gdisp, x2, y2, &x2, &y2, 0); gdk_draw_rectangle (rect_sel->core->win, rect_sel->core->gc, 0, @@ -553,7 +548,7 @@ selection_tool_update_op_state (RectSelect *rect_sel, void rect_select_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; @@ -565,16 +560,16 @@ rect_select_oper_update (Tool *tool, selection_tool_update_op_state (rect_sel, rect_sel->current_x, rect_sel->current_y, - mevent->state, gdisp_ptr); + mevent->state, gdisp); } void rect_select_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - gint state; + gint state; state = kevent->state; @@ -606,19 +601,17 @@ rect_select_modifier_update (Tool *tool, selection_tool_update_op_state (rect_sel, rect_sel->current_x, rect_sel->current_y, - state, gdisp_ptr); + state, gdisp); } void rect_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; - GDisplay *gdisp; rect_sel = (RectSelect *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (rect_sel->op) { @@ -670,7 +663,7 @@ rect_select_cursor_update (Tool *tool, void rect_select_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { RectSelect *rect_sel; diff --git a/app/tools/rect_select.h b/app/tools/rect_select.h index ffc764b9db..4ea51d7378 100644 --- a/app/tools/rect_select.h +++ b/app/tools/rect_select.h @@ -23,25 +23,25 @@ /* rect select action functions */ void rect_select_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_modifier_update (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_oper_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr); + GDisplay *gdisp); void rect_select_control (Tool *tool, ToolAction tool_action, - gpointer gdisp_ptr); + GDisplay *gdisp); /* rect select functions */ void rect_select_draw (Tool *tool); diff --git a/app/tools/rotate_tool.c b/app/tools/rotate_tool.c index 75b33552d7..ff0c059f18 100644 --- a/app/tools/rotate_tool.c +++ b/app/tools/rotate_tool.c @@ -55,34 +55,42 @@ #define EPSILON 0.018 /* ~ 1 degree */ #define FIFTEEN_DEG (G_PI / 12.0) + +/* forward function declarations */ +static TileManager * rotate_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + +static void rotate_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void rotate_tool_motion (Tool *tool, + GDisplay *gdisp); +static void rotate_info_update (Tool *tool); + +static void rotate_angle_changed (GtkWidget *entry, + gpointer data); +static void rotate_center_changed (GtkWidget *entry, + gpointer data); + + /* variables local to this file */ static gdouble angle_val; static gdouble center_vals[2]; /* needed for size update */ -static GtkWidget *sizeentry; +static GtkWidget *sizeentry = NULL; -/* forward function declarations */ -static void rotate_tool_recalc (Tool *, void *); -static void rotate_tool_motion (Tool *, void *); -static void rotate_info_update (Tool *); -/* callback functions for the info dialog sizeentries */ -static void rotate_angle_changed (GtkWidget *entry, gpointer data); -static void rotate_center_changed (GtkWidget *entry, gpointer data); - -TileManager * +static TileManager * rotate_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { TransformCore *transform_core; - GDisplay *gdisp; GtkWidget *widget; GtkWidget *spinbutton2; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (state) { @@ -174,12 +182,12 @@ rotate_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - rotate_tool_motion (tool, gdisp_ptr); - rotate_tool_recalc (tool, gdisp_ptr); + rotate_tool_motion (tool, gdisp); + rotate_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - rotate_tool_recalc (tool, gdisp_ptr); + rotate_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -246,7 +254,6 @@ rotate_angle_changed (GtkWidget *widget, gpointer data) { Tool *tool; - GDisplay *gdisp; TransformCore *transform_core; gdouble value; @@ -254,7 +261,6 @@ rotate_angle_changed (GtkWidget *widget, if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; value = gimp_deg_to_rad (GTK_ADJUSTMENT (widget)->value); @@ -263,7 +269,7 @@ rotate_angle_changed (GtkWidget *widget, { draw_core_pause (transform_core->core, tool); transform_core->trans_info[ANGLE] = value; - rotate_tool_recalc (tool, gdisp); + rotate_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } @@ -274,7 +280,6 @@ rotate_center_changed (GtkWidget *widget, gpointer data) { Tool *tool; - GDisplay *gdisp; TransformCore *transform_core; gint cx; gint cy; @@ -283,7 +288,6 @@ rotate_center_changed (GtkWidget *widget, if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; cx = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); @@ -295,15 +299,15 @@ rotate_center_changed (GtkWidget *widget, draw_core_pause (transform_core->core, tool); transform_core->cx = cx; transform_core->cy = cy; - rotate_tool_recalc (tool, gdisp); + rotate_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } } static void -rotate_tool_motion (Tool *tool, - void *gdisp_ptr) +rotate_tool_motion (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; gdouble angle1, angle2, angle; @@ -361,14 +365,12 @@ rotate_tool_motion (Tool *tool, } static void -rotate_tool_recalc (Tool *tool, - void *gdisp_ptr) +rotate_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; gdouble cx, cy; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; cx = transform_core->cx; diff --git a/app/tools/rotate_tool.h b/app/tools/rotate_tool.h index a466d1411d..1411efe643 100644 --- a/app/tools/rotate_tool.h +++ b/app/tools/rotate_tool.h @@ -20,9 +20,6 @@ #define __ROTATE_TOOL_H__ -TileManager * rotate_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * rotate_tool_rotate (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/tools/scale_tool.c b/app/tools/scale_tool.c index edce4cd856..14353f7e11 100644 --- a/app/tools/scale_tool.c +++ b/app/tools/scale_tool.c @@ -46,6 +46,23 @@ #include "libgimp/gimpintl.h" +/* forward function declarations */ +static TileManager * scale_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + +static void scale_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void scale_tool_motion (Tool *tool, + GDisplay *gdisp); +static void scale_info_update (Tool *tool); + +static void scale_size_changed (GtkWidget *widget, + gpointer data); +static void scale_unit_changed (GtkWidget *widget, + gpointer data); + + /* storage for information dialog fields */ static gchar orig_width_buf[MAX_INFO_BUF]; static gchar orig_height_buf[MAX_INFO_BUF]; @@ -54,27 +71,17 @@ static gchar x_ratio_buf[MAX_INFO_BUF]; static gchar y_ratio_buf[MAX_INFO_BUF]; /* needed for original size unit update */ -static GtkWidget *sizeentry; +static GtkWidget *sizeentry = NULL; -/* forward function declarations */ -static void scale_tool_recalc (Tool *, void *); -static void scale_tool_motion (Tool *, void *); -static void scale_info_update (Tool *); -/* callback functions for the info dialog fields */ -static void scale_size_changed (GtkWidget *widget, gpointer data); -static void scale_unit_changed (GtkWidget *widget, gpointer data); - -TileManager * +static TileManager * scale_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { - GDisplay *gdisp; TransformCore *transform_core; GtkWidget *spinbutton; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; switch (state) @@ -163,12 +170,12 @@ scale_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - scale_tool_motion (tool, gdisp_ptr); - scale_tool_recalc (tool, gdisp_ptr); + scale_tool_motion (tool, gdisp); + scale_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - scale_tool_recalc (tool, gdisp_ptr); + scale_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -218,7 +225,6 @@ tools_free_scale_tool (Tool *tool) static void scale_info_update (Tool *tool) { - GDisplay *gdisp; TransformCore *transform_core; gdouble ratio_x, ratio_y; gint x1, y1, x2, y2, x3, y3, x4, y4; @@ -228,9 +234,8 @@ scale_info_update (Tool *tool) static GimpUnit label_unit = GIMP_UNIT_PIXEL; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; - unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));; + unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));; /* Find original sizes */ x1 = transform_core->x1; @@ -249,9 +254,9 @@ scale_info_update (Tool *tool) gimp_unit_get_digits (label_unit) + 1, gimp_unit_get_symbol (label_unit)); g_snprintf (orig_width_buf, MAX_INFO_BUF, format_buf, - (x2 - x1) * unit_factor / gdisp->gimage->xresolution); + (x2 - x1) * unit_factor / tool->gdisp->gimage->xresolution); g_snprintf (orig_height_buf, MAX_INFO_BUF, format_buf, - (y2 - y1) * unit_factor / gdisp->gimage->yresolution); + (y2 - y1) * unit_factor / tool->gdisp->gimage->yresolution); } else /* unit == GIMP_UNIT_PIXEL */ { @@ -288,7 +293,6 @@ scale_size_changed (GtkWidget *widget, { Tool *tool; TransformCore *transform_core; - GDisplay *gdisp; gint width; gint height; @@ -296,7 +300,6 @@ scale_size_changed (GtkWidget *widget, if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0)); @@ -312,7 +315,7 @@ scale_size_changed (GtkWidget *widget, transform_core->trans_info[X0] + width; transform_core->trans_info[Y1] = transform_core->trans_info[Y0] + height; - scale_tool_recalc (tool, gdisp); + scale_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } @@ -326,10 +329,9 @@ scale_unit_changed (GtkWidget *widget, } static void -scale_tool_motion (Tool *tool, - void *gdisp_ptr) +scale_tool_motion (Tool *tool, + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; gdouble ratio; gdouble *x1; @@ -340,7 +342,6 @@ scale_tool_motion (Tool *tool, gint dir_x, dir_y; gint diff_x, diff_y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; diff_x = transform_core->curx - transform_core->lastx; @@ -435,17 +436,15 @@ scale_tool_motion (Tool *tool, } static void -scale_tool_recalc (Tool *tool, - void *gdisp_ptr) +scale_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; gint x1, y1, x2, y2; gint diffx, diffy; gint cx, cy; gdouble scalex, scaley; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; x1 = (int) transform_core->trans_info [X0]; diff --git a/app/tools/scale_tool.h b/app/tools/scale_tool.h index 93aeac2cd6..2de517460f 100644 --- a/app/tools/scale_tool.h +++ b/app/tools/scale_tool.h @@ -20,9 +20,6 @@ #define __SCALE_TOOL_H__ -TileManager * scale_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * scale_tool_scale (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/tools/shear_tool.c b/app/tools/shear_tool.c index 279332b28d..99be358f45 100644 --- a/app/tools/shear_tool.c +++ b/app/tools/shear_tool.c @@ -54,29 +54,37 @@ /* the minimum movement before direction of shear can be determined (pixels) */ #define MIN_MOVE 5 + +/* forward function declarations */ +static TileManager * shear_tool_transform (Tool *tool, + GDisplay *gdisp, + TransformState state); + +static void shear_tool_recalc (Tool *tool, + GDisplay *gdisp); +static void shear_tool_motion (Tool *tool, + GDisplay *gdisp); +static void shear_info_update (Tool *tool); + +static void shear_x_mag_changed (GtkWidget *widget, + gpointer data); +static void shear_y_mag_changed (GtkWidget *widget, + gpointer data); + + /* variables local to this file */ static gdouble xshear_val; static gdouble yshear_val; -/* forward function declarations */ -static void shear_tool_recalc (Tool *, void *); -static void shear_tool_motion (Tool *, void *); -static void shear_info_update (Tool *); -/* Info dialog callback funtions */ -static void shear_x_mag_changed (GtkWidget *widget, gpointer data); -static void shear_y_mag_changed (GtkWidget *widget, gpointer data); - -TileManager * +static TileManager * shear_tool_transform (Tool *tool, - gpointer gdisp_ptr, + GDisplay *gdisp, TransformState state) { TransformCore *transform_core; - GDisplay *gdisp; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; switch (state) { @@ -108,12 +116,12 @@ shear_tool_transform (Tool *tool, break; case TRANSFORM_MOTION: - shear_tool_motion (tool, gdisp_ptr); - shear_tool_recalc (tool, gdisp_ptr); + shear_tool_motion (tool, gdisp); + shear_tool_recalc (tool, gdisp); break; case TRANSFORM_RECALC: - shear_tool_recalc (tool, gdisp_ptr); + shear_tool_recalc (tool, gdisp); break; case TRANSFORM_FINISH: @@ -175,14 +183,12 @@ shear_x_mag_changed (GtkWidget *widget, { Tool *tool; TransformCore *transform_core; - GDisplay *gdisp; gint value; tool = (Tool *) data; if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; value = GTK_ADJUSTMENT (widget)->value; @@ -191,7 +197,7 @@ shear_x_mag_changed (GtkWidget *widget, { draw_core_pause (transform_core->core, tool); transform_core->trans_info[XSHEAR] = value; - shear_tool_recalc (tool, gdisp); + shear_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } @@ -203,14 +209,12 @@ shear_y_mag_changed (GtkWidget *widget, { Tool *tool; TransformCore *transform_core; - GDisplay *gdisp; gint value; tool = (Tool *) data; if (tool) { - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; value = GTK_ADJUSTMENT (widget)->value; @@ -219,15 +223,15 @@ shear_y_mag_changed (GtkWidget *widget, { draw_core_pause (transform_core->core, tool); transform_core->trans_info[YSHEAR] = value; - shear_tool_recalc (tool, gdisp); + shear_tool_recalc (tool, tool->gdisp); draw_core_resume (transform_core->core, tool); } } } static void -shear_tool_motion (Tool *tool, - void *gdisp_ptr) +shear_tool_motion (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; gint diffx, diffy; @@ -302,15 +306,13 @@ shear_tool_motion (Tool *tool, } static void -shear_tool_recalc (Tool *tool, - void *gdisp_ptr) +shear_tool_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; gfloat width, height; gfloat cx, cy; - gdisp = (GDisplay *) tool->gdisp_ptr; transform_core = (TransformCore *) tool->private; cx = (transform_core->x1 + transform_core->x2) / 2.0; diff --git a/app/tools/shear_tool.h b/app/tools/shear_tool.h index 1dd07ad975..3b1a0e381c 100644 --- a/app/tools/shear_tool.h +++ b/app/tools/shear_tool.h @@ -20,9 +20,6 @@ #define __SHEAR_TOOL_H__ -TileManager * shear_tool_transform (Tool *tool, - gpointer gdisp_ptr, - TransformState state); TileManager * shear_tool_shear (GimpImage *gimage, GimpDrawable *drawable, GDisplay *gdisp, diff --git a/app/tools/smudge.c b/app/tools/smudge.c index 26bdff458e..3aae2073cb 100644 --- a/app/tools/smudge.c +++ b/app/tools/smudge.c @@ -63,30 +63,40 @@ struct _SmudgeOptions GtkObject *rate_w; }; + +/* function prototypes */ +static gpointer smudge_paint_func (PaintCore *paint_core, + GimpDrawable *drawable, + PaintState state); +static void smudge_motion (PaintCore *paint_core, + PaintPressureOptions *pressure_options, + gdouble smudge_rate, + GimpDrawable *drawable); +static gboolean smudge_init (PaintCore *paint_core, + GimpDrawable *drawable); +static void smudge_finish (PaintCore *paint_core, + GimpDrawable *drawable); + +static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, + gint *x, + gint *y, + gint *w, + gint *h); +static void smudge_allocate_accum_buffer (gint w, + gint h, + gint bytes, + guchar *do_fill); + + +/* local variables */ static PixelRegion accumPR; static guchar *accum_data; /* the smudge tool options */ static SmudgeOptions * smudge_options = NULL; -/* local variables */ static gdouble non_gui_rate; -/* function prototypes */ -static void smudge_motion (PaintCore *, PaintPressureOptions *, - gdouble, GimpDrawable *); -static gboolean smudge_init (PaintCore *, GimpDrawable *); -static void smudge_finish (PaintCore *, GimpDrawable *); - -static void smudge_nonclipped_painthit_coords (PaintCore *paint_core, - gint *x, - gint *y, - gint *w, - gint *h); -static void smudge_allocate_accum_buffer (gint w, - gint h, - gint bytes, - guchar *do_fill); static void smudge_options_reset (void) @@ -143,10 +153,10 @@ smudge_options_new (void) return options; } -void * +static gpointer smudge_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { /* initialization fails if the user starts outside the drawable */ static gboolean initialized = FALSE; @@ -157,13 +167,18 @@ smudge_paint_func (PaintCore *paint_core, if (!initialized) initialized = smudge_init (paint_core, drawable); if (initialized) - smudge_motion (paint_core, smudge_options->paint_options.pressure_options, + smudge_motion (paint_core, + smudge_options->paint_options.pressure_options, smudge_options->rate, drawable); break; + case FINISH_PAINT: smudge_finish (paint_core, drawable); initialized = FALSE; break; + + default: + break; } return NULL; @@ -198,12 +213,12 @@ static gboolean smudge_init (PaintCore *paint_core, GimpDrawable *drawable) { - GImage *gimage; - TempBuf *area; + GImage *gimage; + TempBuf *area; PixelRegion srcPR; - gint x, y, w, h; - gint was_clipped; - guchar *do_fill = NULL; + gint x, y, w, h; + gint was_clipped; + guchar *do_fill = NULL; if (! (gimage = drawable_gimage (drawable))) return FALSE; @@ -239,7 +254,7 @@ smudge_init (PaintCore *paint_core, do_fill = gimp_drawable_get_color_at (drawable, CLAMP ((gint) paint_core->curx, 0, gimp_drawable_width (drawable) - 1), CLAMP ((gint) paint_core->cury, 0, gimp_drawable_height (drawable) - 1)); - + smudge_allocate_accum_buffer (w, h, gimp_drawable_bytes (drawable), do_fill); accumPR.x = area->x - x; @@ -277,7 +292,7 @@ smudge_allocate_accum_buffer (gint w, gint h, gint bytes, guchar *do_fill) -{ +{ /* Allocate the accumulation buffer */ accumPR.bytes = bytes; accum_data = g_malloc (w * h * bytes); @@ -332,12 +347,12 @@ smudge_motion (PaintCore *paint_core, gdouble smudge_rate, GimpDrawable *drawable) { - GImage *gimage; - TempBuf * area; - PixelRegion srcPR, destPR, tempPR; - gdouble rate; - gint opacity; - gint x,y,w,h; + GImage *gimage; + TempBuf *area; + PixelRegion srcPR, destPR, tempPR; + gdouble rate; + gint opacity; + gint x, y, w, h; if (! (gimage = drawable_gimage (drawable))) return; @@ -425,10 +440,10 @@ smudge_motion (PaintCore *paint_core, 1.0, INCREMENTAL); } -static void * +static gpointer smudge_non_gui_paint_func (PaintCore *paint_core, GimpDrawable *drawable, - int state) + PaintState state) { smudge_motion (paint_core, &non_gui_pressure_options, non_gui_rate, drawable); @@ -437,8 +452,8 @@ smudge_non_gui_paint_func (PaintCore *paint_core, gboolean smudge_non_gui_default (GimpDrawable *drawable, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gdouble rate = SMUDGE_DEFAULT_RATE; SmudgeOptions *options = smudge_options; @@ -452,8 +467,8 @@ smudge_non_gui_default (GimpDrawable *drawable, gboolean smudge_non_gui (GimpDrawable *drawable, gdouble rate, - int num_strokes, - double *stroke_array) + gint num_strokes, + gdouble *stroke_array) { gint i; @@ -493,6 +508,6 @@ smudge_non_gui (GimpDrawable *drawable, smudge_finish (&non_gui_paint_core, drawable); return TRUE; } - else - return FALSE; + + return FALSE; } diff --git a/app/tools/smudge.h b/app/tools/smudge.h index a87d0ffe60..0ea9609198 100644 --- a/app/tools/smudge.h +++ b/app/tools/smudge.h @@ -33,16 +33,14 @@ typedef enum SMUDGE_MODE_SHADOWS } SmudgeMode; -void * smudge_paint_func (PaintCore *, - GimpDrawable *, - gint ); -gboolean smudge_non_gui (GimpDrawable *, - gdouble , - gint , - gdouble *); -gboolean smudge_non_gui_default (GimpDrawable *, - gint , - gdouble *); + +gboolean smudge_non_gui (GimpDrawable *drawable, + gdouble rate, + gint num_strokes, + gdouble *stroke_array); +gboolean smudge_non_gui_default (GimpDrawable *drawable, + gint num_strokes, + gdouble *stroke_array); Tool * tools_new_smudge (void); void tools_free_smudge (Tool *tool); diff --git a/app/tools/text_tool.c b/app/tools/text_tool.c index 33fd430364..3b1885d073 100644 --- a/app/tools/text_tool.c +++ b/app/tools/text_tool.c @@ -81,9 +81,9 @@ typedef struct _TextTool TextTool; struct _TextTool { - gint click_x; - gint click_y; - void *gdisp_ptr; + gint click_x; + gint click_y; + GDisplay *gdisp; }; typedef struct _TextOptions TextOptions; @@ -106,6 +106,39 @@ struct _TextOptions }; +static void text_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void text_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +static void text_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +static void text_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static void text_dialog_create (void); +static void text_dialog_ok_callback (GtkWidget *widget, + gpointer data); +static void text_dialog_cancel_callback (GtkWidget *widget, + gpointer data); +static gint text_dialog_delete_callback (GtkWidget *widget, + GdkEvent *event, + gpointer data); + +static void text_init_render (TextTool *text_tool); +static void text_gdk_image_to_region (GdkImage *image, + gint , + PixelRegion *); +static void text_size_multiply (gchar **fontname, + gint size); +static void text_set_resolution (gchar **fontname, + gdouble xres, + gdouble yres); + + /* the text tool options */ static TextOptions *text_options = NULL; @@ -114,25 +147,6 @@ static TextTool *the_text_tool = NULL; static GtkWidget *text_tool_shell = NULL; -static void text_button_press (Tool *, GdkEventButton *, gpointer); -static void text_button_release (Tool *, GdkEventButton *, gpointer); -static void text_cursor_update (Tool *, GdkEventMotion *, gpointer); -static void text_control (Tool *, ToolAction, gpointer); - -static void text_dialog_create (void); -static void text_dialog_ok_callback (GtkWidget *, gpointer); -static void text_dialog_cancel_callback (GtkWidget *, gpointer); -static gint text_dialog_delete_callback (GtkWidget *, GdkEvent *, gpointer); - -static void text_init_render (TextTool *); -static void text_gdk_image_to_region (GdkImage *, gint, PixelRegion *); -static void text_size_multiply (gchar **fontname, gint); -static void text_set_resolution (gchar **fontname, gdouble, gdouble); - -/* Layer * text_render (GImage *, GimpDrawable *, */ -/* gint, gint, gchar *, gchar *, gint, gint); */ - - /* functions */ static void @@ -304,19 +318,16 @@ text_call_gdyntext (GDisplay *gdisp) static void text_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - Layer *layer; + Layer *layer; TextTool *text_tool; - gdisp = gdisp_ptr; - - text_tool = tool->private; - text_tool->gdisp_ptr = gdisp_ptr; + text_tool = tool->private; + text_tool->gdisp = gdisp; tool->state = ACTIVE; - tool->gdisp_ptr = gdisp_ptr; + tool->gdisp = gdisp; gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &text_tool->click_x, &text_tool->click_y, @@ -328,7 +339,7 @@ text_button_press (Tool *tool, /* If there is a floating selection, and this aint it, use the move tool */ if (layer_is_floating_sel (layer)) { - init_edit_selection (tool, gdisp_ptr, bevent, EDIT_LAYER_TRANSLATE); + init_edit_selection (tool, gdisp, bevent, EDIT_LAYER_TRANSLATE); return; } @@ -348,7 +359,7 @@ text_button_press (Tool *tool, static void text_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { tool->state = INACTIVE; } @@ -356,13 +367,10 @@ text_button_release (Tool *tool, static void text_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; Layer *layer; - gint x, y; - - gdisp = (GDisplay *) gdisp_ptr; + gint x, y; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE); @@ -387,7 +395,7 @@ text_cursor_update (Tool *tool, static void text_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -467,16 +475,16 @@ static void text_init_render (TextTool *text_tool) { GDisplay *gdisp; - gchar *fontname; - gchar *text; - gboolean antialias = text_options->antialias; + gchar *fontname; + gchar *text; + gboolean antialias = text_options->antialias; fontname = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG (text_tool_shell)); if (!fontname) return; - gdisp = (GDisplay *) text_tool->gdisp_ptr; + gdisp = text_tool->gdisp; /* override the user's antialias setting if this is an indexed image */ if (gimp_image_base_type (gdisp->gimage) == INDEXED) diff --git a/app/tools/text_tool.h b/app/tools/text_tool.h index 32deef8d3c..41633d6c35 100644 --- a/app/tools/text_tool.h +++ b/app/tools/text_tool.h @@ -20,14 +20,14 @@ #define __TEXT_TOOL_H__ +#define SUPERSAMPLE 3 + typedef enum { PIXELS, POINTS } SizeType; -#define SUPERSAMPLE 3 - Tool * tools_new_text (void); void tools_free_text (Tool *tool); diff --git a/app/tools/threshold.c b/app/tools/threshold.c index 90d6cea647..5fefd450c6 100644 --- a/app/tools/threshold.c +++ b/app/tools/threshold.c @@ -56,36 +56,50 @@ struct _Threshold gint x, y; /* coords for last mouse click */ }; + +/* threshold action functions */ +static void threshold_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); + +static ThresholdDialog * threshold_dialog_new (void); + +static void threshold_update (ThresholdDialog *td, + gint update); +static void threshold_preview (ThresholdDialog *td); +static void threshold_reset_callback (GtkWidget *widget, + gpointer data); +static void threshold_ok_callback (GtkWidget *widget, + gpointer data); +static void threshold_cancel_callback (GtkWidget *widget, + gpointer data); +static void threshold_preview_update (GtkWidget *widget, + gpointer data); +static void threshold_low_threshold_adjustment_update (GtkAdjustment *adj, + gpointer data); +static void threshold_high_threshold_adjustment_update (GtkAdjustment *adj, + gpointer data); + +static void threshold (PixelRegion *, + PixelRegion *, + gpointer ); +static void threshold_histogram_range (HistogramWidget *, + gint , + gint , + gpointer ); + + /* the threshold tool options */ static ToolOptions *threshold_options = NULL; /* the threshold tool dialog */ static ThresholdDialog *threshold_dialog = NULL; -/* threshold action functions */ -static void threshold_control (Tool *, ToolAction, gpointer); -static ThresholdDialog * threshold_dialog_new (void); - -static void threshold_update (ThresholdDialog *, - gint); -static void threshold_preview (ThresholdDialog *); -static void threshold_reset_callback (GtkWidget *, gpointer); -static void threshold_ok_callback (GtkWidget *, gpointer); -static void threshold_cancel_callback (GtkWidget *, gpointer); -static void threshold_preview_update (GtkWidget *, gpointer); -static void threshold_low_threshold_adjustment_update (GtkAdjustment *, - gpointer); -static void threshold_high_threshold_adjustment_update (GtkAdjustment *, - gpointer); - -static void threshold (PixelRegion *, PixelRegion *, void *); -static void threshold_histogram_range (HistogramWidget *, gint, gint, - gpointer); /* threshold machinery */ void -threshold_2 (void *data, +threshold_2 (gpointer data, PixelRegion *srcPR, PixelRegion *destPR) { @@ -152,7 +166,7 @@ threshold (PixelRegion *srcPR, static void threshold_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { switch (action) { @@ -453,7 +467,7 @@ threshold_ok_callback (GtkWidget *widget, td->image_map = NULL; - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } @@ -477,7 +491,7 @@ threshold_cancel_callback (GtkWidget *widget, gdisplays_flush (); } - active_tool->gdisp_ptr = NULL; + active_tool->gdisp = NULL; active_tool->drawable = NULL; } diff --git a/app/tools/tools.c b/app/tools/tools.c index 19fce25e8b..5bd8ec119a 100644 --- a/app/tools/tools.c +++ b/app/tools/tools.c @@ -1324,17 +1324,17 @@ tools_initialize (ToolType tool_type, active_tool->drawable = gimp_image_active_drawable (gdisp->gimage); } - /* don't set gdisp_ptr here! (see commands.c) */ + /* don't set tool->gdisp here! (see commands.c) */ } void active_tool_control (ToolAction action, - void *gdisp_ptr) + GDisplay *gdisp) { if (active_tool) { - if (active_tool->gdisp_ptr == gdisp_ptr) + if (active_tool->gdisp == gdisp) { switch (action) { @@ -1344,7 +1344,7 @@ active_tool_control (ToolAction action, if (! active_tool->paused_count) { active_tool->state = PAUSED; - (* active_tool->control_func) (active_tool, action, gdisp_ptr); + (* active_tool->control_func) (active_tool, action, gdisp); } } active_tool->paused_count++; @@ -1357,14 +1357,14 @@ active_tool_control (ToolAction action, if (! active_tool->paused_count) { active_tool->state = ACTIVE; - (* active_tool->control_func) (active_tool, action, gdisp_ptr); + (* active_tool->control_func) (active_tool, action, gdisp); } } break; case HALT : active_tool->state = INACTIVE; - (* active_tool->control_func) (active_tool, action, gdisp_ptr); + (* active_tool->control_func) (active_tool, action, gdisp); break; case DESTROY : @@ -1388,52 +1388,45 @@ active_tool_control (ToolAction action, static void standard_button_press_func (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - - gdisp = gdisp_ptr; - - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->drawable = gimp_image_active_drawable (gdisp->gimage); } static void standard_button_release_func (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { } static void standard_motion_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { } static void standard_arrow_keys_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { } static void standard_modifier_key_func (Tool *tool, GdkEventKey *kevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { } static void standard_cursor_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; - - gdisp = (GDisplay *) gdisp_ptr; gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW, TOOL_TYPE_NONE, CURSOR_MODIFIER_NONE, @@ -1443,14 +1436,14 @@ standard_cursor_update_func (Tool *tool, static void standard_operator_update_func (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { } static void standard_control_func (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { } @@ -1475,7 +1468,7 @@ tools_new_tool (ToolType tool_type) tool->auto_snap_to = TRUE; /* Snap to guides */ tool->preserve = TRUE; /* Preserve tool across drawable changes */ - tool->gdisp_ptr = NULL; + tool->gdisp = NULL; tool->drawable = NULL; tool->toggled = FALSE; diff --git a/app/tools/tools.h b/app/tools/tools.h index a76ce57814..6058153c52 100644 --- a/app/tools/tools.h +++ b/app/tools/tools.h @@ -29,41 +29,58 @@ #define NON_ACTIVE_LAYER (1 << 2) /* Tool action function declarations */ -typedef void (* ButtonPressFunc) (Tool *, GdkEventButton *, gpointer); -typedef void (* ButtonReleaseFunc) (Tool *, GdkEventButton *, gpointer); -typedef void (* MotionFunc) (Tool *, GdkEventMotion *, gpointer); -typedef void (* ArrowKeysFunc) (Tool *, GdkEventKey *, gpointer); -typedef void (* ModifierKeyFunc) (Tool *, GdkEventKey *, gpointer); -typedef void (* CursorUpdateFunc) (Tool *, GdkEventMotion *, gpointer); -typedef void (* OperUpdateFunc) (Tool *, GdkEventMotion *, gpointer); -typedef void (* ToolCtlFunc) (Tool *, ToolAction, gpointer); +typedef void (* ButtonPressFunc) (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +typedef void (* ButtonReleaseFunc) (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +typedef void (* MotionFunc) (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +typedef void (* ArrowKeysFunc) (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +typedef void (* ModifierKeyFunc) (Tool *tool, + GdkEventKey *kevent, + GDisplay *gdisp); +typedef void (* CursorUpdateFunc) (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +typedef void (* OperUpdateFunc) (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +typedef void (* ToolCtlFunc) (Tool *tool, + ToolAction action, + GDisplay *gdisp); /* ToolInfo function declarations */ typedef Tool * (* ToolInfoNewFunc) (void); -typedef void (* ToolInfoFreeFunc) (Tool *); -typedef void (* ToolInfoInitFunc) (GDisplay *); +typedef void (* ToolInfoFreeFunc) (Tool *tool); +typedef void (* ToolInfoInitFunc) (GDisplay *gdisp); /* The types of tools... */ struct _Tool { /* Data */ - ToolType type; /* Tool type */ - gint ID; /* unique tool ID */ + ToolType type; /* Tool type */ + gint ID; /* unique tool ID */ - ToolState state; /* state of tool activity */ - gint paused_count; /* paused control count */ - gboolean scroll_lock; /* allow scrolling or not */ - gboolean auto_snap_to; /* snap to guides automatically */ + ToolState state; /* state of tool activity */ + gint paused_count; /* paused control count */ + gboolean scroll_lock; /* allow scrolling or not */ + gboolean auto_snap_to; /* snap to guides automatically */ - gboolean preserve; /* Preserve this tool across drawable changes */ - void *gdisp_ptr; /* pointer to currently active gdisp */ - void *drawable; /* pointer to the tool's current drawable */ + gboolean preserve; /* Preserve this tool across drawable changes */ + GDisplay *gdisp; /* pointer to currently active gdisp */ + GimpDrawable *drawable; /* pointer to the tool's current drawable */ - gboolean toggled; /* Bad hack to let the paint_core show the */ - /* right toggle cursors */ + gboolean toggled; /* Bad hack to let the paint_core show the + * right toggle cursors + */ - void *private; /* Tool-specific information */ + gpointer private; /* Tool-specific information */ /* Action functions */ ButtonPressFunc button_press_func; @@ -98,7 +115,7 @@ struct _ToolInfo ToolInfoFreeFunc free_func; ToolInfoInitFunc init_func; - GtkWidget *tool_widget; + GtkWidget *tool_widget; GimpContext *tool_context; @@ -106,34 +123,37 @@ struct _ToolInfo BitmapCursor toggle_cursor; }; -/* Global Data Structures */ -extern Tool * active_tool; -extern ToolInfo tool_info[]; -extern gint num_tools; /* Function declarations */ -Tool * tools_new_tool (ToolType tool_type); +Tool * tools_new_tool (ToolType tool_type); -void tools_select (ToolType tool_type); -void tools_initialize (ToolType tool_type, - GDisplay *gdisplay); +void tools_select (ToolType tool_type); +void tools_initialize (ToolType tool_type, + GDisplay *gdisplay); -void active_tool_control (ToolAction action, - void *gdisp_ptr); +void active_tool_control (ToolAction action, + GDisplay *gdisp); -void tools_help_func (const gchar *help_data); +void tools_help_func (const gchar *help_data); -void tools_register (ToolType tool_type, - ToolOptions *tool_options); +void tools_register (ToolType tool_type, + ToolOptions *tool_options); -void tool_options_dialog_new (void); -void tool_options_dialog_show (void); -void tool_options_dialog_free (void); +void tool_options_dialog_new (void); +void tool_options_dialog_show (void); +void tool_options_dialog_free (void); -gchar * tool_active_PDB_string (void); +gchar * tool_active_PDB_string (void); + +/* don't unref these pixmaps, they are static! */ +GdkPixmap * tool_get_pixmap (ToolType tool_type); +GdkBitmap * tool_get_mask (ToolType tool_type); + + +/* Global Data Structures */ +extern Tool *active_tool; +extern ToolInfo tool_info[]; +extern gint num_tools; -/* don't unref this pixmaps, they are static! */ -GdkPixmap * tool_get_pixmap (ToolType tool_type); -GdkBitmap * tool_get_mask (ToolType tool_type); #endif /* __TOOLS_H__ */ diff --git a/app/tools/transform_core.c b/app/tools/transform_core.c index f5a2c82b4d..0584f63c2b 100644 --- a/app/tools/transform_core.c +++ b/app/tools/transform_core.c @@ -51,37 +51,6 @@ #include "libgimp/gimpmath.h" -/* variables */ -static TranInfo old_trans_info; -InfoDialog *transform_info = NULL; -static gboolean transform_info_inited = FALSE; - -/* forward function declarations */ -static void transform_core_bounds (Tool *, void *); -static void transform_core_recalc (Tool *, void *); -static void transform_core_doit (Tool *, gpointer); -static gdouble cubic (gdouble, gint, gint, gint, gint); -static void transform_core_setup_grid (Tool *); -static void transform_core_grid_recalc (TransformCore *); - - -#define BILINEAR(jk,j1k,jk1,j1k1,dx,dy) \ - ((1-dy) * (jk + dx * (j1k - jk)) + \ - dy * (jk1 + dx * (j1k1 - jk1))) - -/* access interleaved pixels */ -#define CUBIC_ROW(dx, row, step) \ - cubic(dx, (row)[0], (row)[step], (row)[step+step], (row)[step+step+step]) -#define CUBIC_SCALED_ROW(dx, row, step, i) \ - cubic(dx, (row)[0] * (row)[i], \ - (row)[step] * (row)[step + i], \ - (row)[step+step]* (row)[step+step + i], \ - (row)[step+step+step] * (row)[step+step+step + i]) - -#define REF_TILE(i,x,y) \ - tile[i] = tile_manager_get_tile (float_tiles, x, y, TRUE, FALSE); \ - src[i] = tile_data_pointer (tile[i], (x) % TILE_WIDTH, (y) % TILE_HEIGHT); - /* This should be migrated to pixel_region or similar... */ /* PixelSurround describes a (read-only) * region around a pixel in a tile manager @@ -100,9 +69,48 @@ typedef struct _PixelSurround gint row_stride; } PixelSurround; +#define BILINEAR(jk,j1k,jk1,j1k1,dx,dy) \ + ((1-dy) * (jk + dx * (j1k - jk)) + \ + dy * (jk1 + dx * (j1k1 - jk1))) + +/* access interleaved pixels */ +#define CUBIC_ROW(dx, row, step) \ + cubic(dx, (row)[0], (row)[step], (row)[step+step], (row)[step+step+step]) +#define CUBIC_SCALED_ROW(dx, row, step, i) \ + cubic(dx, (row)[0] * (row)[i], \ + (row)[step] * (row)[step + i], \ + (row)[step+step]* (row)[step+step + i], \ + (row)[step+step+step] * (row)[step+step+step + i]) + +#define REF_TILE(i,x,y) \ + tile[i] = tile_manager_get_tile (float_tiles, x, y, TRUE, FALSE); \ + src[i] = tile_data_pointer (tile[i], (x) % TILE_WIDTH, (y) % TILE_HEIGHT); + +/* forward function declarations */ +static void transform_core_bounds (Tool *tool, + GDisplay *gdisp); +static void transform_core_recalc (Tool *tool, + GDisplay *gdisp); +static void transform_core_doit (Tool *tool, + GDisplay *gdisp); +static gdouble cubic (gdouble dx, + gint jm1, + gint j, + gint jp1, + gint jp2); +static void transform_core_setup_grid (Tool *tool); +static void transform_core_grid_recalc (TransformCore *transform_core); + + +/* variables */ +static TranInfo old_trans_info; +InfoDialog *transform_info = NULL; +static gboolean transform_info_inited = FALSE; + + static void pixel_surround_init (PixelSurround *ps, - TileManager *t, + TileManager *tm, gint w, gint h, guchar bg[MAX_CHANNELS]) @@ -113,14 +121,15 @@ pixel_surround_init (PixelSurround *ps, { ps->bg[i] = bg[i]; } - ps->tile = 0; - ps->mgr = t; - ps->bpp = tile_manager_level_bpp (t); - ps->w = w; - ps->h = h; + + ps->tile = NULL; + ps->mgr = tm; + ps->bpp = tile_manager_level_bpp (tm); + ps->w = w; + ps->h = h; /* make sure buffer is big enough */ - ps->buff_size = w * h * ps->bpp; - ps->buff = g_malloc (ps->buff_size); + ps->buff_size = w * h * ps->bpp; + ps->buff = g_malloc (ps->buff_size); ps->row_stride = 0; } @@ -170,7 +179,10 @@ pixel_surround_lock (PixelSurround *ps, if (tile) { - guchar* buff = tile_data_pointer (tile, i % TILE_WIDTH, j % TILE_HEIGHT); + guchar *buff = tile_data_pointer (tile, + i % TILE_WIDTH, + j % TILE_HEIGHT); + for (k = buff; k < buff+ps->bpp; ++k, ++ptr) { *ptr = *k; @@ -191,7 +203,7 @@ pixel_surround_lock (PixelSurround *ps, return ps->buff; } -static int +static gint pixel_surround_rowstride (PixelSurround *ps) { return ps->row_stride; @@ -226,7 +238,7 @@ transform_ok_callback (GtkWidget *widget, Tool *tool; tool = (Tool *) data; - transform_core_doit (tool, tool->gdisp_ptr); + transform_core_doit (tool, tool->gdisp); } static void @@ -248,7 +260,7 @@ transform_reset_callback (GtkWidget *widget, transform_core->trans_info [i] = old_trans_info [i]; /* recalculate the tool's transformation matrix */ - transform_core_recalc (tool, tool->gdisp_ptr); + transform_core_recalc (tool, tool->gdisp); /* resume drawing the current tool */ draw_core_resume (transform_core->core, tool); @@ -265,9 +277,8 @@ static const gchar *action_labels[] = void transform_core_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; GimpDrawable *drawable; gint dist; @@ -276,7 +287,6 @@ transform_core_button_press (Tool *tool, gint i; gint off_x, off_y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; transform_core->bpressed = TRUE; /* ALT */ @@ -294,7 +304,7 @@ transform_core_button_press (Tool *tool, * check to make sure that the display which currently owns the * tool is the one which just received the button pressed event */ - if ((gdisp == tool->gdisp_ptr) && transform_core->interactive) + if ((gdisp == tool->gdisp) && transform_core->interactive) { /* start drawing the bounding box and handles... */ draw_core_start (transform_core->core, gdisp->canvas->window, tool); @@ -377,12 +387,12 @@ transform_core_button_press (Tool *tool, * and reset */ if (tool->state == ACTIVE) - transform_core_reset (tool, gdisp_ptr); + transform_core_reset (tool, gdisp); /* Set the pointer to the active display */ - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->drawable = drawable; - tool->state = ACTIVE; + tool->state = ACTIVE; /* Grab the pointer if we're in non-interactive mode */ if (!transform_core->interactive) @@ -396,14 +406,14 @@ transform_core_button_press (Tool *tool, * perspective) that actually need the bounds for * initializing */ - transform_core_bounds (tool, gdisp_ptr); + transform_core_bounds (tool, gdisp); /* Calculate the grid line endpoints */ if (transform_tool_show_grid ()) transform_core_setup_grid (tool); /* Initialize the transform tool */ - (* transform_core->trans_func) (tool, gdisp_ptr, TRANSFORM_INIT); + (* transform_core->trans_func) (tool, gdisp, TRANSFORM_INIT); if (transform_info && !transform_info_inited) { @@ -422,24 +432,22 @@ transform_core_button_press (Tool *tool, } /* Recalculate the transform tool */ - transform_core_recalc (tool, gdisp_ptr); + transform_core_recalc (tool, gdisp); /* recall this function to find which handle we're dragging */ if (transform_core->interactive) - transform_core_button_press (tool, bevent, gdisp_ptr); + transform_core_button_press (tool, bevent, gdisp); } } void transform_core_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; gint i; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; transform_core->bpressed = FALSE; /* ALT */ @@ -459,7 +467,7 @@ transform_core_button_release (Tool *tool, /* Shift-clicking is another way to approve the transform */ if ((bevent->state & GDK_SHIFT_MASK) || (tool->type == FLIP)) { - transform_core_doit (tool, gdisp_ptr); + transform_core_doit (tool, gdisp); } else { @@ -478,7 +486,7 @@ transform_core_button_release (Tool *tool, transform_core->trans_info [i] = old_trans_info [i]; /* recalculate the tool's transformation matrix */ - transform_core_recalc (tool, gdisp_ptr); + transform_core_recalc (tool, gdisp); /* resume drawing the current tool */ draw_core_resume (transform_core->core, tool); @@ -495,9 +503,8 @@ transform_core_button_release (Tool *tool, void transform_core_doit (Tool *tool, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; TileManager *new_tiles; TransformUndo *tu; @@ -507,7 +514,6 @@ transform_core_doit (Tool *tool, gimp_add_busy_cursors (); - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; /* undraw the tool before we muck around with the transform matrix */ @@ -539,12 +545,12 @@ transform_core_doit (Tool *tool, /* Send the request for the transformation to the tool... */ - new_tiles = (* transform_core->trans_func) (tool, gdisp_ptr, + new_tiles = (* transform_core->trans_func) (tool, gdisp, TRANSFORM_FINISH); - (* transform_core->trans_func) (tool, gdisp_ptr, TRANSFORM_INIT); + (* transform_core->trans_func) (tool, gdisp, TRANSFORM_INIT); - transform_core_recalc (tool, gdisp_ptr); + transform_core_recalc (tool, gdisp); if (new_tiles) { @@ -604,7 +610,7 @@ transform_core_doit (Tool *tool, gdisplays_flush (); - transform_core_reset (tool, gdisp_ptr); + transform_core_reset (tool, gdisp); /* if this tool is non-interactive, make it inactive after use */ if (!transform_core->interactive) @@ -614,12 +620,10 @@ transform_core_doit (Tool *tool, void transform_core_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; if (transform_core->bpressed == FALSE) @@ -646,7 +650,7 @@ transform_core_motion (Tool *tool, transform_core->state = mevent->state; /* recalculate the tool's transformation matrix */ - (* transform_core->trans_func) (tool, gdisp_ptr, TRANSFORM_MOTION); + (* transform_core->trans_func) (tool, gdisp, TRANSFORM_MOTION); transform_core->lastx = transform_core->curx; transform_core->lasty = transform_core->cury; @@ -658,15 +662,13 @@ transform_core_motion (Tool *tool, void transform_core_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; GimpDrawable *drawable; GdkCursorType ctype = GDK_TOP_LEFT_ARROW; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, @@ -701,7 +703,7 @@ transform_core_cursor_update (Tool *tool, void transform_core_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { TransformCore *transform_core; @@ -714,12 +716,12 @@ transform_core_control (Tool *tool, break; case RESUME: - transform_core_recalc (tool, gdisp_ptr); + transform_core_recalc (tool, gdisp); draw_core_resume (transform_core->core, tool); break; case HALT: - transform_core_reset (tool, gdisp_ptr); + transform_core_reset (tool, gdisp); break; default: @@ -743,7 +745,7 @@ transform_core_draw (Tool *tool) gint i, k, gci; gint xa, ya, xb, yb; - gdisp = tool->gdisp_ptr; + gdisp = tool->gdisp; transform_core = (TransformCore *) tool->private; gdisplay_transform_coords (gdisp, transform_core->tx1, transform_core->ty1, @@ -962,14 +964,12 @@ transform_core_transform_bounding_box (Tool *tool) } void -transform_core_reset (Tool *tool, - void *gdisp_ptr) +transform_core_reset (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; if (transform_core->original) tile_manager_destroy (transform_core->original); @@ -980,25 +980,23 @@ transform_core_reset (Tool *tool, draw_core_stop (transform_core->core, tool); info_dialog_popdown (transform_info); - tool->state = INACTIVE; - tool->gdisp_ptr = NULL; + tool->state = INACTIVE; + tool->gdisp = NULL; tool->drawable = NULL; } static void -transform_core_bounds (Tool *tool, - void *gdisp_ptr) +transform_core_bounds (Tool *tool, + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; TileManager *tiles; GimpDrawable *drawable; gint offset_x, offset_y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; - tiles = transform_core->original; - drawable = gimp_image_active_drawable (gdisp->gimage); + tiles = transform_core->original; + drawable = gimp_image_active_drawable (gdisp->gimage); /* find the boundaries */ if (tiles) @@ -1128,16 +1126,16 @@ transform_core_setup_grid (Tool *tool) } static void -transform_core_recalc (Tool *tool, - void *gdisp_ptr) +transform_core_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; transform_core = (TransformCore *) tool->private; - transform_core_bounds (tool, gdisp_ptr); + transform_core_bounds (tool, gdisp); - (* transform_core->trans_func) (tool, gdisp_ptr, TRANSFORM_RECALC); + (* transform_core->trans_func) (tool, gdisp, TRANSFORM_RECALC); } /* Actually carry out a transformation */ diff --git a/app/tools/transform_core.h b/app/tools/transform_core.h index 22270dfe64..a0c63fbf37 100644 --- a/app/tools/transform_core.h +++ b/app/tools/transform_core.h @@ -31,7 +31,9 @@ enum BoundingBox typedef gdouble TranInfo[TRAN_INFO_SIZE]; -typedef TileManager * (* TransformFunc) (Tool *, void *, TransformState); +typedef TileManager * (* TransformFunc) (Tool *tool, + GDisplay *gdisp, + TransformState state); struct _TransformCore @@ -99,7 +101,7 @@ struct _TransformUndo gint tool_type; TranInfo trans_info; TileManager *original; - void *path_undo; + gpointer path_undo; }; @@ -107,23 +109,33 @@ struct _TransformUndo extern InfoDialog * transform_info; /* transform tool action functions */ -void transform_core_button_press (Tool *, GdkEventButton *, gpointer); -void transform_core_button_release (Tool *, GdkEventButton *, gpointer); -void transform_core_motion (Tool *, GdkEventMotion *, gpointer); -void transform_core_cursor_update (Tool *, GdkEventMotion *, gpointer); -void transform_core_control (Tool *, ToolAction, gpointer); +void transform_core_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void transform_core_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void transform_core_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +void transform_core_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +void transform_core_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); /* transform tool functions */ -Tool * transform_core_new (ToolType tool_type, - gboolean interactive); -void transform_core_free (Tool *tool); -void transform_core_draw (Tool *tool); -void transform_core_no_draw (Tool *tool); -void transform_core_transform_bounding_box (Tool *tool); -void transform_core_reset (Tool *tool, - void *gdisp_ptr); +Tool * transform_core_new (ToolType tool_type, + gboolean interactive); +void transform_core_free (Tool *tool); +void transform_core_draw (Tool *tool); +void transform_core_no_draw (Tool *tool); +void transform_core_transform_bounding_box (Tool *tool); +void transform_core_reset (Tool *tool, + GDisplay *gdisp); void transform_core_grid_density_changed (void); -void transform_core_showpath_changed (gint type); +void transform_core_showpath_changed (gint type); /* transform functions */ TileManager * transform_core_do (GImage *gimage, diff --git a/app/transform_core.c b/app/transform_core.c index f5a2c82b4d..0584f63c2b 100644 --- a/app/transform_core.c +++ b/app/transform_core.c @@ -51,37 +51,6 @@ #include "libgimp/gimpmath.h" -/* variables */ -static TranInfo old_trans_info; -InfoDialog *transform_info = NULL; -static gboolean transform_info_inited = FALSE; - -/* forward function declarations */ -static void transform_core_bounds (Tool *, void *); -static void transform_core_recalc (Tool *, void *); -static void transform_core_doit (Tool *, gpointer); -static gdouble cubic (gdouble, gint, gint, gint, gint); -static void transform_core_setup_grid (Tool *); -static void transform_core_grid_recalc (TransformCore *); - - -#define BILINEAR(jk,j1k,jk1,j1k1,dx,dy) \ - ((1-dy) * (jk + dx * (j1k - jk)) + \ - dy * (jk1 + dx * (j1k1 - jk1))) - -/* access interleaved pixels */ -#define CUBIC_ROW(dx, row, step) \ - cubic(dx, (row)[0], (row)[step], (row)[step+step], (row)[step+step+step]) -#define CUBIC_SCALED_ROW(dx, row, step, i) \ - cubic(dx, (row)[0] * (row)[i], \ - (row)[step] * (row)[step + i], \ - (row)[step+step]* (row)[step+step + i], \ - (row)[step+step+step] * (row)[step+step+step + i]) - -#define REF_TILE(i,x,y) \ - tile[i] = tile_manager_get_tile (float_tiles, x, y, TRUE, FALSE); \ - src[i] = tile_data_pointer (tile[i], (x) % TILE_WIDTH, (y) % TILE_HEIGHT); - /* This should be migrated to pixel_region or similar... */ /* PixelSurround describes a (read-only) * region around a pixel in a tile manager @@ -100,9 +69,48 @@ typedef struct _PixelSurround gint row_stride; } PixelSurround; +#define BILINEAR(jk,j1k,jk1,j1k1,dx,dy) \ + ((1-dy) * (jk + dx * (j1k - jk)) + \ + dy * (jk1 + dx * (j1k1 - jk1))) + +/* access interleaved pixels */ +#define CUBIC_ROW(dx, row, step) \ + cubic(dx, (row)[0], (row)[step], (row)[step+step], (row)[step+step+step]) +#define CUBIC_SCALED_ROW(dx, row, step, i) \ + cubic(dx, (row)[0] * (row)[i], \ + (row)[step] * (row)[step + i], \ + (row)[step+step]* (row)[step+step + i], \ + (row)[step+step+step] * (row)[step+step+step + i]) + +#define REF_TILE(i,x,y) \ + tile[i] = tile_manager_get_tile (float_tiles, x, y, TRUE, FALSE); \ + src[i] = tile_data_pointer (tile[i], (x) % TILE_WIDTH, (y) % TILE_HEIGHT); + +/* forward function declarations */ +static void transform_core_bounds (Tool *tool, + GDisplay *gdisp); +static void transform_core_recalc (Tool *tool, + GDisplay *gdisp); +static void transform_core_doit (Tool *tool, + GDisplay *gdisp); +static gdouble cubic (gdouble dx, + gint jm1, + gint j, + gint jp1, + gint jp2); +static void transform_core_setup_grid (Tool *tool); +static void transform_core_grid_recalc (TransformCore *transform_core); + + +/* variables */ +static TranInfo old_trans_info; +InfoDialog *transform_info = NULL; +static gboolean transform_info_inited = FALSE; + + static void pixel_surround_init (PixelSurround *ps, - TileManager *t, + TileManager *tm, gint w, gint h, guchar bg[MAX_CHANNELS]) @@ -113,14 +121,15 @@ pixel_surround_init (PixelSurround *ps, { ps->bg[i] = bg[i]; } - ps->tile = 0; - ps->mgr = t; - ps->bpp = tile_manager_level_bpp (t); - ps->w = w; - ps->h = h; + + ps->tile = NULL; + ps->mgr = tm; + ps->bpp = tile_manager_level_bpp (tm); + ps->w = w; + ps->h = h; /* make sure buffer is big enough */ - ps->buff_size = w * h * ps->bpp; - ps->buff = g_malloc (ps->buff_size); + ps->buff_size = w * h * ps->bpp; + ps->buff = g_malloc (ps->buff_size); ps->row_stride = 0; } @@ -170,7 +179,10 @@ pixel_surround_lock (PixelSurround *ps, if (tile) { - guchar* buff = tile_data_pointer (tile, i % TILE_WIDTH, j % TILE_HEIGHT); + guchar *buff = tile_data_pointer (tile, + i % TILE_WIDTH, + j % TILE_HEIGHT); + for (k = buff; k < buff+ps->bpp; ++k, ++ptr) { *ptr = *k; @@ -191,7 +203,7 @@ pixel_surround_lock (PixelSurround *ps, return ps->buff; } -static int +static gint pixel_surround_rowstride (PixelSurround *ps) { return ps->row_stride; @@ -226,7 +238,7 @@ transform_ok_callback (GtkWidget *widget, Tool *tool; tool = (Tool *) data; - transform_core_doit (tool, tool->gdisp_ptr); + transform_core_doit (tool, tool->gdisp); } static void @@ -248,7 +260,7 @@ transform_reset_callback (GtkWidget *widget, transform_core->trans_info [i] = old_trans_info [i]; /* recalculate the tool's transformation matrix */ - transform_core_recalc (tool, tool->gdisp_ptr); + transform_core_recalc (tool, tool->gdisp); /* resume drawing the current tool */ draw_core_resume (transform_core->core, tool); @@ -265,9 +277,8 @@ static const gchar *action_labels[] = void transform_core_button_press (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; GimpDrawable *drawable; gint dist; @@ -276,7 +287,6 @@ transform_core_button_press (Tool *tool, gint i; gint off_x, off_y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; transform_core->bpressed = TRUE; /* ALT */ @@ -294,7 +304,7 @@ transform_core_button_press (Tool *tool, * check to make sure that the display which currently owns the * tool is the one which just received the button pressed event */ - if ((gdisp == tool->gdisp_ptr) && transform_core->interactive) + if ((gdisp == tool->gdisp) && transform_core->interactive) { /* start drawing the bounding box and handles... */ draw_core_start (transform_core->core, gdisp->canvas->window, tool); @@ -377,12 +387,12 @@ transform_core_button_press (Tool *tool, * and reset */ if (tool->state == ACTIVE) - transform_core_reset (tool, gdisp_ptr); + transform_core_reset (tool, gdisp); /* Set the pointer to the active display */ - tool->gdisp_ptr = gdisp; + tool->gdisp = gdisp; tool->drawable = drawable; - tool->state = ACTIVE; + tool->state = ACTIVE; /* Grab the pointer if we're in non-interactive mode */ if (!transform_core->interactive) @@ -396,14 +406,14 @@ transform_core_button_press (Tool *tool, * perspective) that actually need the bounds for * initializing */ - transform_core_bounds (tool, gdisp_ptr); + transform_core_bounds (tool, gdisp); /* Calculate the grid line endpoints */ if (transform_tool_show_grid ()) transform_core_setup_grid (tool); /* Initialize the transform tool */ - (* transform_core->trans_func) (tool, gdisp_ptr, TRANSFORM_INIT); + (* transform_core->trans_func) (tool, gdisp, TRANSFORM_INIT); if (transform_info && !transform_info_inited) { @@ -422,24 +432,22 @@ transform_core_button_press (Tool *tool, } /* Recalculate the transform tool */ - transform_core_recalc (tool, gdisp_ptr); + transform_core_recalc (tool, gdisp); /* recall this function to find which handle we're dragging */ if (transform_core->interactive) - transform_core_button_press (tool, bevent, gdisp_ptr); + transform_core_button_press (tool, bevent, gdisp); } } void transform_core_button_release (Tool *tool, GdkEventButton *bevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; gint i; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; transform_core->bpressed = FALSE; /* ALT */ @@ -459,7 +467,7 @@ transform_core_button_release (Tool *tool, /* Shift-clicking is another way to approve the transform */ if ((bevent->state & GDK_SHIFT_MASK) || (tool->type == FLIP)) { - transform_core_doit (tool, gdisp_ptr); + transform_core_doit (tool, gdisp); } else { @@ -478,7 +486,7 @@ transform_core_button_release (Tool *tool, transform_core->trans_info [i] = old_trans_info [i]; /* recalculate the tool's transformation matrix */ - transform_core_recalc (tool, gdisp_ptr); + transform_core_recalc (tool, gdisp); /* resume drawing the current tool */ draw_core_resume (transform_core->core, tool); @@ -495,9 +503,8 @@ transform_core_button_release (Tool *tool, void transform_core_doit (Tool *tool, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; TileManager *new_tiles; TransformUndo *tu; @@ -507,7 +514,6 @@ transform_core_doit (Tool *tool, gimp_add_busy_cursors (); - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; /* undraw the tool before we muck around with the transform matrix */ @@ -539,12 +545,12 @@ transform_core_doit (Tool *tool, /* Send the request for the transformation to the tool... */ - new_tiles = (* transform_core->trans_func) (tool, gdisp_ptr, + new_tiles = (* transform_core->trans_func) (tool, gdisp, TRANSFORM_FINISH); - (* transform_core->trans_func) (tool, gdisp_ptr, TRANSFORM_INIT); + (* transform_core->trans_func) (tool, gdisp, TRANSFORM_INIT); - transform_core_recalc (tool, gdisp_ptr); + transform_core_recalc (tool, gdisp); if (new_tiles) { @@ -604,7 +610,7 @@ transform_core_doit (Tool *tool, gdisplays_flush (); - transform_core_reset (tool, gdisp_ptr); + transform_core_reset (tool, gdisp); /* if this tool is non-interactive, make it inactive after use */ if (!transform_core->interactive) @@ -614,12 +620,10 @@ transform_core_doit (Tool *tool, void transform_core_motion (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; if (transform_core->bpressed == FALSE) @@ -646,7 +650,7 @@ transform_core_motion (Tool *tool, transform_core->state = mevent->state; /* recalculate the tool's transformation matrix */ - (* transform_core->trans_func) (tool, gdisp_ptr, TRANSFORM_MOTION); + (* transform_core->trans_func) (tool, gdisp, TRANSFORM_MOTION); transform_core->lastx = transform_core->curx; transform_core->lasty = transform_core->cury; @@ -658,15 +662,13 @@ transform_core_motion (Tool *tool, void transform_core_cursor_update (Tool *tool, GdkEventMotion *mevent, - gpointer gdisp_ptr) + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; GimpDrawable *drawable; GdkCursorType ctype = GDK_TOP_LEFT_ARROW; gint x, y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, @@ -701,7 +703,7 @@ transform_core_cursor_update (Tool *tool, void transform_core_control (Tool *tool, ToolAction action, - gpointer gdisp_ptr) + GDisplay *gdisp) { TransformCore *transform_core; @@ -714,12 +716,12 @@ transform_core_control (Tool *tool, break; case RESUME: - transform_core_recalc (tool, gdisp_ptr); + transform_core_recalc (tool, gdisp); draw_core_resume (transform_core->core, tool); break; case HALT: - transform_core_reset (tool, gdisp_ptr); + transform_core_reset (tool, gdisp); break; default: @@ -743,7 +745,7 @@ transform_core_draw (Tool *tool) gint i, k, gci; gint xa, ya, xb, yb; - gdisp = tool->gdisp_ptr; + gdisp = tool->gdisp; transform_core = (TransformCore *) tool->private; gdisplay_transform_coords (gdisp, transform_core->tx1, transform_core->ty1, @@ -962,14 +964,12 @@ transform_core_transform_bounding_box (Tool *tool) } void -transform_core_reset (Tool *tool, - void *gdisp_ptr) +transform_core_reset (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; - GDisplay *gdisp; transform_core = (TransformCore *) tool->private; - gdisp = (GDisplay *) gdisp_ptr; if (transform_core->original) tile_manager_destroy (transform_core->original); @@ -980,25 +980,23 @@ transform_core_reset (Tool *tool, draw_core_stop (transform_core->core, tool); info_dialog_popdown (transform_info); - tool->state = INACTIVE; - tool->gdisp_ptr = NULL; + tool->state = INACTIVE; + tool->gdisp = NULL; tool->drawable = NULL; } static void -transform_core_bounds (Tool *tool, - void *gdisp_ptr) +transform_core_bounds (Tool *tool, + GDisplay *gdisp) { - GDisplay *gdisp; TransformCore *transform_core; TileManager *tiles; GimpDrawable *drawable; gint offset_x, offset_y; - gdisp = (GDisplay *) gdisp_ptr; transform_core = (TransformCore *) tool->private; - tiles = transform_core->original; - drawable = gimp_image_active_drawable (gdisp->gimage); + tiles = transform_core->original; + drawable = gimp_image_active_drawable (gdisp->gimage); /* find the boundaries */ if (tiles) @@ -1128,16 +1126,16 @@ transform_core_setup_grid (Tool *tool) } static void -transform_core_recalc (Tool *tool, - void *gdisp_ptr) +transform_core_recalc (Tool *tool, + GDisplay *gdisp) { TransformCore *transform_core; transform_core = (TransformCore *) tool->private; - transform_core_bounds (tool, gdisp_ptr); + transform_core_bounds (tool, gdisp); - (* transform_core->trans_func) (tool, gdisp_ptr, TRANSFORM_RECALC); + (* transform_core->trans_func) (tool, gdisp, TRANSFORM_RECALC); } /* Actually carry out a transformation */ diff --git a/app/transform_core.h b/app/transform_core.h index 22270dfe64..a0c63fbf37 100644 --- a/app/transform_core.h +++ b/app/transform_core.h @@ -31,7 +31,9 @@ enum BoundingBox typedef gdouble TranInfo[TRAN_INFO_SIZE]; -typedef TileManager * (* TransformFunc) (Tool *, void *, TransformState); +typedef TileManager * (* TransformFunc) (Tool *tool, + GDisplay *gdisp, + TransformState state); struct _TransformCore @@ -99,7 +101,7 @@ struct _TransformUndo gint tool_type; TranInfo trans_info; TileManager *original; - void *path_undo; + gpointer path_undo; }; @@ -107,23 +109,33 @@ struct _TransformUndo extern InfoDialog * transform_info; /* transform tool action functions */ -void transform_core_button_press (Tool *, GdkEventButton *, gpointer); -void transform_core_button_release (Tool *, GdkEventButton *, gpointer); -void transform_core_motion (Tool *, GdkEventMotion *, gpointer); -void transform_core_cursor_update (Tool *, GdkEventMotion *, gpointer); -void transform_core_control (Tool *, ToolAction, gpointer); +void transform_core_button_press (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void transform_core_button_release (Tool *tool, + GdkEventButton *bevent, + GDisplay *gdisp); +void transform_core_motion (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +void transform_core_cursor_update (Tool *tool, + GdkEventMotion *mevent, + GDisplay *gdisp); +void transform_core_control (Tool *tool, + ToolAction tool_action, + GDisplay *gdisp); /* transform tool functions */ -Tool * transform_core_new (ToolType tool_type, - gboolean interactive); -void transform_core_free (Tool *tool); -void transform_core_draw (Tool *tool); -void transform_core_no_draw (Tool *tool); -void transform_core_transform_bounding_box (Tool *tool); -void transform_core_reset (Tool *tool, - void *gdisp_ptr); +Tool * transform_core_new (ToolType tool_type, + gboolean interactive); +void transform_core_free (Tool *tool); +void transform_core_draw (Tool *tool); +void transform_core_no_draw (Tool *tool); +void transform_core_transform_bounding_box (Tool *tool); +void transform_core_reset (Tool *tool, + GDisplay *gdisp); void transform_core_grid_density_changed (void); -void transform_core_showpath_changed (gint type); +void transform_core_showpath_changed (gint type); /* transform functions */ TileManager * transform_core_do (GImage *gimage,