From 5f464b9f5d66691c44b35c0bacf1c14390b80a79 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Sat, 15 May 1999 00:02:47 +0000 Subject: [PATCH] Show what line you are drawing when using on paint-tools. Needs some work for the clone-tool, since it seems to behave different then the rest... --Sven --- ChangeLog | 11 ++++ app/blend.c | 17 ++--- app/core/gimpdrawable-blend.c | 17 ++--- app/cursorutil.c | 8 +-- app/gui/menus.c | 2 +- app/menus.c | 2 +- app/menus/menus.c | 2 +- app/paint_core.c | 118 ++++++++++++++++++++++++++-------- app/paintbrush.c | 4 +- app/tools/blend.c | 17 ++--- app/tools/gimpblendtool.c | 17 ++--- app/tools/paint_core.c | 118 ++++++++++++++++++++++++++-------- app/tools/paintbrush.c | 4 +- app/widgets/gimpcursor.c | 8 +-- app/widgets/gimpitemfactory.c | 2 +- 15 files changed, 243 insertions(+), 104 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3537c09477..8c6ecaaa02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Sat May 15 01:55:12 MEST 1999 Sven Neumann + + * app/menus.c: Moved the seperator down so that it seperates the MRU + dialog from the rest. + * app/paint_core.c: Show the line you are drawing when using + on paint_tools. Still need to figure out what's different about the + clone tool... + * app/blend.c + * app/cursorutil.c + * app/paintbrush.c: a little bit of code cleanup while I was on it + Sat May 15 00:06:06 BST 1999 Andy Thomas * app/gdisplay.c diff --git a/app/blend.c b/app/blend.c index cba48ef54c..ff29269b6c 100644 --- a/app/blend.c +++ b/app/blend.c @@ -1113,13 +1113,13 @@ gradient_calc_shapeburst_dimpled_factor (double x, } static double -gradient_repeat_none(double val) +gradient_repeat_none (double val) { return BOUNDS(val, 0.0, 1.0); } static double -gradient_repeat_sawtooth(double val) +gradient_repeat_sawtooth (double val) { if (val >= 0.0) return fmod(val, 1.0); @@ -1128,7 +1128,7 @@ gradient_repeat_sawtooth(double val) } static double -gradient_repeat_triangular(double val) +gradient_repeat_triangular (double val) { int ival; @@ -1228,7 +1228,7 @@ gradient_precalc_shapeburst (GImage *gimage, static void -gradient_render_pixel(double x, double y, color_t *color, void *render_data) +gradient_render_pixel (double x, double y, color_t *color, void *render_data) { RenderBlendData *rbd; double factor; @@ -1321,7 +1321,7 @@ gradient_render_pixel(double x, double y, color_t *color, void *render_data) static void -gradient_put_pixel(int x, int y, color_t color, void *put_pixel_data) +gradient_put_pixel (int x, int y, color_t color, void *put_pixel_data) { PutPixelData *ppd; unsigned char *data; @@ -1568,7 +1568,7 @@ gradient_fill_region (GImage *gimage, } static void -calc_rgb_to_hsv(double *r, double *g, double *b) +calc_rgb_to_hsv (double *r, double *g, double *b) { double red, green, blue; double h, s, v; @@ -1640,7 +1640,7 @@ calc_rgb_to_hsv(double *r, double *g, double *b) } static void -calc_hsv_to_rgb(double *h, double *s, double *v) +calc_hsv_to_rgb (double *h, double *s, double *v) { double hue, saturation, value; double f, p, q, t; @@ -1738,7 +1738,8 @@ tools_new_blend () tool->button_press_func = blend_button_press; tool->button_release_func = blend_button_release; tool->motion_func = blend_motion; - tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func; + tool->arrow_keys_func = standard_arrow_keys_func; + tool->modifier_key_func = standard_modifier_key_func; tool->cursor_update_func = blend_cursor_update; tool->control_func = blend_control; tool->preserve = TRUE; diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c index cba48ef54c..ff29269b6c 100644 --- a/app/core/gimpdrawable-blend.c +++ b/app/core/gimpdrawable-blend.c @@ -1113,13 +1113,13 @@ gradient_calc_shapeburst_dimpled_factor (double x, } static double -gradient_repeat_none(double val) +gradient_repeat_none (double val) { return BOUNDS(val, 0.0, 1.0); } static double -gradient_repeat_sawtooth(double val) +gradient_repeat_sawtooth (double val) { if (val >= 0.0) return fmod(val, 1.0); @@ -1128,7 +1128,7 @@ gradient_repeat_sawtooth(double val) } static double -gradient_repeat_triangular(double val) +gradient_repeat_triangular (double val) { int ival; @@ -1228,7 +1228,7 @@ gradient_precalc_shapeburst (GImage *gimage, static void -gradient_render_pixel(double x, double y, color_t *color, void *render_data) +gradient_render_pixel (double x, double y, color_t *color, void *render_data) { RenderBlendData *rbd; double factor; @@ -1321,7 +1321,7 @@ gradient_render_pixel(double x, double y, color_t *color, void *render_data) static void -gradient_put_pixel(int x, int y, color_t color, void *put_pixel_data) +gradient_put_pixel (int x, int y, color_t color, void *put_pixel_data) { PutPixelData *ppd; unsigned char *data; @@ -1568,7 +1568,7 @@ gradient_fill_region (GImage *gimage, } static void -calc_rgb_to_hsv(double *r, double *g, double *b) +calc_rgb_to_hsv (double *r, double *g, double *b) { double red, green, blue; double h, s, v; @@ -1640,7 +1640,7 @@ calc_rgb_to_hsv(double *r, double *g, double *b) } static void -calc_hsv_to_rgb(double *h, double *s, double *v) +calc_hsv_to_rgb (double *h, double *s, double *v) { double hue, saturation, value; double f, p, q, t; @@ -1738,7 +1738,8 @@ tools_new_blend () tool->button_press_func = blend_button_press; tool->button_release_func = blend_button_release; tool->motion_func = blend_motion; - tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func; + tool->arrow_keys_func = standard_arrow_keys_func; + tool->modifier_key_func = standard_modifier_key_func; tool->cursor_update_func = blend_cursor_update; tool->control_func = blend_control; tool->preserve = TRUE; diff --git a/app/cursorutil.c b/app/cursorutil.c index 8a83228e38..8e2d3f0b5c 100644 --- a/app/cursorutil.c +++ b/app/cursorutil.c @@ -85,7 +85,7 @@ static gboolean pending_removebusy = FALSE; static void -create_cursor(BM_Cursor *bmcursor) +create_cursor (BM_Cursor *bmcursor) { GdkPixmap *pixmap; GdkPixmap *pixmapmsk; @@ -97,12 +97,12 @@ create_cursor(BM_Cursor *bmcursor) pixmap = gdk_bitmap_create_from_data (NULL, bmcursor->bits, bmcursor->width, bmcursor->height); - g_return_if_fail(pixmap != NULL); + g_return_if_fail (pixmap != NULL); pixmapmsk = gdk_bitmap_create_from_data (NULL, bmcursor->mask_bits, bmcursor->width, bmcursor->height); - g_return_if_fail(pixmapmsk != NULL); + g_return_if_fail (pixmapmsk != NULL); bmcursor->cursor = gdk_cursor_new_from_pixmap (pixmap, pixmapmsk, &fg, &bg, bmcursor->x_hot, @@ -111,7 +111,7 @@ create_cursor(BM_Cursor *bmcursor) } static void -gimp_change_win_cursor(GdkWindow *win, GimpCursorType curtype) +gimp_change_win_cursor (GdkWindow *win, GimpCursorType curtype) { GdkCursor *cursor; diff --git a/app/gui/menus.c b/app/gui/menus.c index 21235eaa4b..79d90e950b 100644 --- a/app/gui/menus.c +++ b/app/gui/menus.c @@ -55,7 +55,6 @@ static const GtkItemFactoryEntry toolbox_entries[] = { N_("/File/About..."), NULL, about_dialog_cmd_callback, 0 }, { N_("/File/Preferences..."), NULL, file_pref_cmd_callback, 0 }, { N_("/File/Tip of the day"), NULL, tips_dialog_cmd_callback, 0 }, - { N_("/File/---"), NULL, NULL, 0, "" }, { N_("/File/Dialogs/Brushes..."), "B", dialogs_brushes_cmd_callback, 0 }, { N_("/File/Dialogs/Patterns..."), "P", dialogs_patterns_cmd_callback, 0 }, { N_("/File/Dialogs/Palette..."), "P", dialogs_palette_cmd_callback, 0 }, @@ -67,6 +66,7 @@ static const GtkItemFactoryEntry toolbox_entries[] = { N_("/File/Dialogs/Document Index..."), NULL, raise_idea_callback, 0 }, { N_("/File/Dialogs/Error Console..."), NULL, dialogs_error_console_cmd_callback, 0 }, { N_("/File/Dialogs/Module Browser..."), NULL, dialogs_module_browser_cmd_callback, 0 }, + { N_("/File/---"), NULL, NULL, 0, "" }, { N_("/File/---"), NULL, NULL, 0, "" } }; static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]); diff --git a/app/menus.c b/app/menus.c index 21235eaa4b..79d90e950b 100644 --- a/app/menus.c +++ b/app/menus.c @@ -55,7 +55,6 @@ static const GtkItemFactoryEntry toolbox_entries[] = { N_("/File/About..."), NULL, about_dialog_cmd_callback, 0 }, { N_("/File/Preferences..."), NULL, file_pref_cmd_callback, 0 }, { N_("/File/Tip of the day"), NULL, tips_dialog_cmd_callback, 0 }, - { N_("/File/---"), NULL, NULL, 0, "" }, { N_("/File/Dialogs/Brushes..."), "B", dialogs_brushes_cmd_callback, 0 }, { N_("/File/Dialogs/Patterns..."), "P", dialogs_patterns_cmd_callback, 0 }, { N_("/File/Dialogs/Palette..."), "P", dialogs_palette_cmd_callback, 0 }, @@ -67,6 +66,7 @@ static const GtkItemFactoryEntry toolbox_entries[] = { N_("/File/Dialogs/Document Index..."), NULL, raise_idea_callback, 0 }, { N_("/File/Dialogs/Error Console..."), NULL, dialogs_error_console_cmd_callback, 0 }, { N_("/File/Dialogs/Module Browser..."), NULL, dialogs_module_browser_cmd_callback, 0 }, + { N_("/File/---"), NULL, NULL, 0, "" }, { N_("/File/---"), NULL, NULL, 0, "" } }; static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]); diff --git a/app/menus/menus.c b/app/menus/menus.c index 21235eaa4b..79d90e950b 100644 --- a/app/menus/menus.c +++ b/app/menus/menus.c @@ -55,7 +55,6 @@ static const GtkItemFactoryEntry toolbox_entries[] = { N_("/File/About..."), NULL, about_dialog_cmd_callback, 0 }, { N_("/File/Preferences..."), NULL, file_pref_cmd_callback, 0 }, { N_("/File/Tip of the day"), NULL, tips_dialog_cmd_callback, 0 }, - { N_("/File/---"), NULL, NULL, 0, "" }, { N_("/File/Dialogs/Brushes..."), "B", dialogs_brushes_cmd_callback, 0 }, { N_("/File/Dialogs/Patterns..."), "P", dialogs_patterns_cmd_callback, 0 }, { N_("/File/Dialogs/Palette..."), "P", dialogs_palette_cmd_callback, 0 }, @@ -67,6 +66,7 @@ static const GtkItemFactoryEntry toolbox_entries[] = { N_("/File/Dialogs/Document Index..."), NULL, raise_idea_callback, 0 }, { N_("/File/Dialogs/Error Console..."), NULL, dialogs_error_console_cmd_callback, 0 }, { N_("/File/Dialogs/Module Browser..."), NULL, dialogs_module_browser_cmd_callback, 0 }, + { N_("/File/---"), NULL, NULL, 0, "" }, { N_("/File/---"), NULL, NULL, 0, "" } }; static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]); diff --git a/app/paint_core.c b/app/paint_core.c index 7d84851411..fc390725d2 100644 --- a/app/paint_core.c +++ b/app/paint_core.c @@ -31,6 +31,7 @@ #include "layers_dialog.h" #include "paint_funcs.h" #include "paint_core.h" +#include "palette.h" #include "selection.h" #include "tools.h" #include "undo.h" @@ -40,6 +41,10 @@ #include "tile.h" /* ick. */ +/* target size */ +#define TARGET_HEIGHT 15 +#define TARGET_WIDTH 15 + #define SQR(x) ((x) * (x)) #define EPSILON 0.00001 @@ -178,8 +183,8 @@ paint_core_button_press (tool, bevent, gdisp_ptr) ! (bevent->state & GDK_SHIFT_MASK)) { /* initialize some values */ - paint_core->startx = paint_core->lastx = paint_core->curx; - paint_core->starty = paint_core->lasty = paint_core->cury; + paint_core->startx = paint_core->lastx = paint_core->curx = x; + paint_core->starty = paint_core->lasty = paint_core->cury = y; paint_core->startpressure = paint_core->lastpressure = paint_core->curpressure; paint_core->startytilt = paint_core->lastytilt = paint_core->curytilt; paint_core->startxtilt = paint_core->lastxtilt = paint_core->curxtilt; @@ -221,7 +226,7 @@ paint_core_button_press (tool, bevent, gdisp_ptr) if (paint_core->pick_colors && (bevent->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) { - paint_core_sample_color(drawable, x, y, bevent->state); + paint_core_sample_color (drawable, x, y, bevent->state); paint_core->pick_state = TRUE; return; } @@ -237,6 +242,7 @@ paint_core_button_press (tool, bevent, gdisp_ptr) paint_core->lastpressure = paint_core->curpressure; paint_core->lastxtilt = paint_core->curxtilt; paint_core->lastytilt = paint_core->curytilt; + ; } else (* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT); @@ -268,6 +274,7 @@ paint_core_button_release (tool, bevent, gdisp_ptr) (* paint_core->paint_func) (paint_core, gimage_active_drawable (gdisp->gimage), FINISH_PAINT); /* Set tool state to inactive -- no longer painting */ + draw_core_stop (paint_core->core, tool); tool->state = INACTIVE; paint_core->pick_state = FALSE; @@ -293,12 +300,11 @@ paint_core_motion (tool, mevent, gdisp_ptr) if (paint_core->pick_state) { - paint_core_sample_color(gimage_active_drawable (gdisp->gimage), - paint_core->curx, paint_core->cury, mevent->state); + paint_core_sample_color (gimage_active_drawable (gdisp->gimage), + paint_core->curx, paint_core->cury, mevent->state); return; } - paint_core->curpressure = mevent->pressure; paint_core->curxtilt = mevent->xtilt; paint_core->curytilt = mevent->ytilt; @@ -325,13 +331,17 @@ paint_core_cursor_update (tool, mevent, gdisp_ptr) Layer *layer; PaintCore * paint_core; GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; gdisp = (GDisplay *) gdisp_ptr; paint_core = (PaintCore *) tool->private; - gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, - FALSE, FALSE); + /* undraw the current tool */ + draw_core_pause (paint_core->core, tool); + + /* Get the current coordinates */ + gdisplay_untransform_coords_f (gdisp, (double) mevent->x, (double) mevent->y, + &paint_core->curx, &paint_core->cury, TRUE); + if ((layer = gimage_get_active_layer (gdisp->gimage))) { int off_x, off_y; @@ -342,19 +352,34 @@ paint_core_cursor_update (tool, mevent, gdisp_ptr) { ctype = GIMP_COLOR_PICKER_CURSOR; } - else if (x >= off_x && y >= off_y && - x < (off_x + drawable_width (GIMP_DRAWABLE(layer))) && - y < (off_y + drawable_height (GIMP_DRAWABLE(layer)))) - { - /* One more test--is there a selected region? - * if so, is cursor inside? - */ - if (gimage_mask_is_empty (gdisp->gimage)) - ctype = GDK_PENCIL; - else if (gimage_mask_value (gdisp->gimage, x, y)) - ctype = GDK_PENCIL; - } + else if (paint_core->curx >= off_x && paint_core->cury >= off_y && + paint_core->curx < (off_x + drawable_width (GIMP_DRAWABLE(layer))) && + paint_core->cury < (off_y + drawable_height (GIMP_DRAWABLE(layer)))) + { + /* One more test--is there a selected region? + * if so, is cursor inside? + */ + if (gimage_mask_is_empty (gdisp->gimage)) + ctype = GDK_PENCIL; + else if (gimage_mask_value (gdisp->gimage, paint_core->curx, paint_core->cury)) + ctype = GDK_PENCIL; + + } + + /* 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 (paint_core->core->gc == NULL) + draw_core_start (paint_core->core, gdisp->canvas->window, tool); + else + { + /* is this a bad hack ? */ + paint_core->core->paused_count = 0; + draw_core_resume (paint_core->core, tool); + } + } } + gdisplay_install_tool_cursor (gdisp, ctype); } @@ -382,17 +407,50 @@ paint_core_control (tool, action, gdisp_ptr) break; case HALT : (* paint_core->paint_func) (paint_core, drawable, FINISH_PAINT); + draw_core_stop (paint_core->core, tool); paint_core_cleanup (); break; } } void -paint_core_no_draw (tool) +paint_core_draw (tool) Tool * tool; { + GDisplay *gdisp; + PaintCore * paint_core; + + paint_core = (PaintCore *) tool->private; + + /* if shift was never used, we don't care about a redraw */ + if (paint_core->core->gc != NULL) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + + /* Draw start target */ + gdk_draw_line (gdisp->canvas->window, paint_core->core->gc, + paint_core->lastx - (TARGET_WIDTH >> 1), paint_core->lasty, + paint_core->lastx + (TARGET_WIDTH >> 1), paint_core->lasty); + gdk_draw_line (gdisp->canvas->window, paint_core->core->gc, + paint_core->lastx, paint_core->lasty - (TARGET_HEIGHT >> 1), + paint_core->lastx, paint_core->lasty + (TARGET_HEIGHT >> 1)); + + /* Draw end target */ + gdk_draw_line (gdisp->canvas->window, paint_core->core->gc, + paint_core->curx - (TARGET_WIDTH >> 1), paint_core->cury, + paint_core->curx + (TARGET_WIDTH >> 1), paint_core->cury); + gdk_draw_line (gdisp->canvas->window, paint_core->core->gc, + paint_core->curx, paint_core->cury - (TARGET_HEIGHT >> 1), + paint_core->curx, paint_core->cury + (TARGET_HEIGHT >> 1)); + + /* Draw the line between the start and end coords */ + gdk_draw_line (gdisp->canvas->window, paint_core->core->gc, + paint_core->lastx, paint_core->lasty, + paint_core->curx, paint_core->cury); + + } return; -} +} Tool * paint_core_new (type) @@ -404,7 +462,7 @@ paint_core_new (type) tool = (Tool *) g_malloc (sizeof (Tool)); private = (PaintCore *) g_malloc (sizeof (PaintCore)); - private->core = draw_core_new (paint_core_no_draw); + private->core = draw_core_new (paint_core_draw); private->pick_colors = FALSE; tool->type = type; @@ -418,7 +476,8 @@ paint_core_new (type) tool->button_press_func = paint_core_button_press; tool->button_release_func = paint_core_button_release; tool->motion_func = paint_core_motion; - tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func; + tool->arrow_keys_func = standard_arrow_keys_func; + tool->modifier_key_func = standard_modifier_key_func; tool->cursor_update_func = paint_core_cursor_update; tool->control_func = paint_core_control; @@ -514,7 +573,10 @@ paint_core_init (paint_core, drawable, x, y) } void -paint_core_get_color_from_gradient (PaintCore *paint_core, double gradient_length, double *r, double *g, double *b,double *a, int mode) +paint_core_get_color_from_gradient (PaintCore *paint_core, + double gradient_length, + double *r, double *g, double *b, double *a, + int mode) { double y; double distance; /* distance in current brush stroke */ @@ -527,10 +589,10 @@ paint_core_get_color_from_gradient (PaintCore *paint_core, double gradient_lengt /* if were past the first chunk... */ - if((y/gradient_length) > 1.0) + if ((y/gradient_length) > 1.0) { /* if this is an "odd" chunk..." */ - if((int)(y/gradient_length) & 1) + if ((int)(y/gradient_length) & 1) { /* draw it "normally" */ y = y - (gradient_length*(int)(y/gradient_length)); diff --git a/app/paintbrush.c b/app/paintbrush.c index 16c4e2c638..7e4638aecb 100644 --- a/app/paintbrush.c +++ b/app/paintbrush.c @@ -384,7 +384,7 @@ paintbrush_motion (PaintCore *paint_core, gimage_get_foreground (gimage, drawable, col); - /* Get a region which can be used to p\\aint to */ + /* Get a region which can be used to paint to */ if (! (area = paint_core_get_paint_area (paint_core, drawable))) return; @@ -405,7 +405,7 @@ paintbrush_motion (PaintCore *paint_core, temp_blend = local_blend; /* hard core to mode LOOP_TRIANGLE */ - /* need to maek a gui to handle this */ + /* need to make a gui to handle this */ mode = gradient_type; if(gradient_length) diff --git a/app/tools/blend.c b/app/tools/blend.c index cba48ef54c..ff29269b6c 100644 --- a/app/tools/blend.c +++ b/app/tools/blend.c @@ -1113,13 +1113,13 @@ gradient_calc_shapeburst_dimpled_factor (double x, } static double -gradient_repeat_none(double val) +gradient_repeat_none (double val) { return BOUNDS(val, 0.0, 1.0); } static double -gradient_repeat_sawtooth(double val) +gradient_repeat_sawtooth (double val) { if (val >= 0.0) return fmod(val, 1.0); @@ -1128,7 +1128,7 @@ gradient_repeat_sawtooth(double val) } static double -gradient_repeat_triangular(double val) +gradient_repeat_triangular (double val) { int ival; @@ -1228,7 +1228,7 @@ gradient_precalc_shapeburst (GImage *gimage, static void -gradient_render_pixel(double x, double y, color_t *color, void *render_data) +gradient_render_pixel (double x, double y, color_t *color, void *render_data) { RenderBlendData *rbd; double factor; @@ -1321,7 +1321,7 @@ gradient_render_pixel(double x, double y, color_t *color, void *render_data) static void -gradient_put_pixel(int x, int y, color_t color, void *put_pixel_data) +gradient_put_pixel (int x, int y, color_t color, void *put_pixel_data) { PutPixelData *ppd; unsigned char *data; @@ -1568,7 +1568,7 @@ gradient_fill_region (GImage *gimage, } static void -calc_rgb_to_hsv(double *r, double *g, double *b) +calc_rgb_to_hsv (double *r, double *g, double *b) { double red, green, blue; double h, s, v; @@ -1640,7 +1640,7 @@ calc_rgb_to_hsv(double *r, double *g, double *b) } static void -calc_hsv_to_rgb(double *h, double *s, double *v) +calc_hsv_to_rgb (double *h, double *s, double *v) { double hue, saturation, value; double f, p, q, t; @@ -1738,7 +1738,8 @@ tools_new_blend () tool->button_press_func = blend_button_press; tool->button_release_func = blend_button_release; tool->motion_func = blend_motion; - tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func; + tool->arrow_keys_func = standard_arrow_keys_func; + tool->modifier_key_func = standard_modifier_key_func; tool->cursor_update_func = blend_cursor_update; tool->control_func = blend_control; tool->preserve = TRUE; diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c index cba48ef54c..ff29269b6c 100644 --- a/app/tools/gimpblendtool.c +++ b/app/tools/gimpblendtool.c @@ -1113,13 +1113,13 @@ gradient_calc_shapeburst_dimpled_factor (double x, } static double -gradient_repeat_none(double val) +gradient_repeat_none (double val) { return BOUNDS(val, 0.0, 1.0); } static double -gradient_repeat_sawtooth(double val) +gradient_repeat_sawtooth (double val) { if (val >= 0.0) return fmod(val, 1.0); @@ -1128,7 +1128,7 @@ gradient_repeat_sawtooth(double val) } static double -gradient_repeat_triangular(double val) +gradient_repeat_triangular (double val) { int ival; @@ -1228,7 +1228,7 @@ gradient_precalc_shapeburst (GImage *gimage, static void -gradient_render_pixel(double x, double y, color_t *color, void *render_data) +gradient_render_pixel (double x, double y, color_t *color, void *render_data) { RenderBlendData *rbd; double factor; @@ -1321,7 +1321,7 @@ gradient_render_pixel(double x, double y, color_t *color, void *render_data) static void -gradient_put_pixel(int x, int y, color_t color, void *put_pixel_data) +gradient_put_pixel (int x, int y, color_t color, void *put_pixel_data) { PutPixelData *ppd; unsigned char *data; @@ -1568,7 +1568,7 @@ gradient_fill_region (GImage *gimage, } static void -calc_rgb_to_hsv(double *r, double *g, double *b) +calc_rgb_to_hsv (double *r, double *g, double *b) { double red, green, blue; double h, s, v; @@ -1640,7 +1640,7 @@ calc_rgb_to_hsv(double *r, double *g, double *b) } static void -calc_hsv_to_rgb(double *h, double *s, double *v) +calc_hsv_to_rgb (double *h, double *s, double *v) { double hue, saturation, value; double f, p, q, t; @@ -1738,7 +1738,8 @@ tools_new_blend () tool->button_press_func = blend_button_press; tool->button_release_func = blend_button_release; tool->motion_func = blend_motion; - tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func; + tool->arrow_keys_func = standard_arrow_keys_func; + tool->modifier_key_func = standard_modifier_key_func; tool->cursor_update_func = blend_cursor_update; tool->control_func = blend_control; tool->preserve = TRUE; diff --git a/app/tools/paint_core.c b/app/tools/paint_core.c index 7d84851411..fc390725d2 100644 --- a/app/tools/paint_core.c +++ b/app/tools/paint_core.c @@ -31,6 +31,7 @@ #include "layers_dialog.h" #include "paint_funcs.h" #include "paint_core.h" +#include "palette.h" #include "selection.h" #include "tools.h" #include "undo.h" @@ -40,6 +41,10 @@ #include "tile.h" /* ick. */ +/* target size */ +#define TARGET_HEIGHT 15 +#define TARGET_WIDTH 15 + #define SQR(x) ((x) * (x)) #define EPSILON 0.00001 @@ -178,8 +183,8 @@ paint_core_button_press (tool, bevent, gdisp_ptr) ! (bevent->state & GDK_SHIFT_MASK)) { /* initialize some values */ - paint_core->startx = paint_core->lastx = paint_core->curx; - paint_core->starty = paint_core->lasty = paint_core->cury; + paint_core->startx = paint_core->lastx = paint_core->curx = x; + paint_core->starty = paint_core->lasty = paint_core->cury = y; paint_core->startpressure = paint_core->lastpressure = paint_core->curpressure; paint_core->startytilt = paint_core->lastytilt = paint_core->curytilt; paint_core->startxtilt = paint_core->lastxtilt = paint_core->curxtilt; @@ -221,7 +226,7 @@ paint_core_button_press (tool, bevent, gdisp_ptr) if (paint_core->pick_colors && (bevent->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) { - paint_core_sample_color(drawable, x, y, bevent->state); + paint_core_sample_color (drawable, x, y, bevent->state); paint_core->pick_state = TRUE; return; } @@ -237,6 +242,7 @@ paint_core_button_press (tool, bevent, gdisp_ptr) paint_core->lastpressure = paint_core->curpressure; paint_core->lastxtilt = paint_core->curxtilt; paint_core->lastytilt = paint_core->curytilt; + ; } else (* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT); @@ -268,6 +274,7 @@ paint_core_button_release (tool, bevent, gdisp_ptr) (* paint_core->paint_func) (paint_core, gimage_active_drawable (gdisp->gimage), FINISH_PAINT); /* Set tool state to inactive -- no longer painting */ + draw_core_stop (paint_core->core, tool); tool->state = INACTIVE; paint_core->pick_state = FALSE; @@ -293,12 +300,11 @@ paint_core_motion (tool, mevent, gdisp_ptr) if (paint_core->pick_state) { - paint_core_sample_color(gimage_active_drawable (gdisp->gimage), - paint_core->curx, paint_core->cury, mevent->state); + paint_core_sample_color (gimage_active_drawable (gdisp->gimage), + paint_core->curx, paint_core->cury, mevent->state); return; } - paint_core->curpressure = mevent->pressure; paint_core->curxtilt = mevent->xtilt; paint_core->curytilt = mevent->ytilt; @@ -325,13 +331,17 @@ paint_core_cursor_update (tool, mevent, gdisp_ptr) Layer *layer; PaintCore * paint_core; GdkCursorType ctype = GDK_TOP_LEFT_ARROW; - int x, y; gdisp = (GDisplay *) gdisp_ptr; paint_core = (PaintCore *) tool->private; - gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, - FALSE, FALSE); + /* undraw the current tool */ + draw_core_pause (paint_core->core, tool); + + /* Get the current coordinates */ + gdisplay_untransform_coords_f (gdisp, (double) mevent->x, (double) mevent->y, + &paint_core->curx, &paint_core->cury, TRUE); + if ((layer = gimage_get_active_layer (gdisp->gimage))) { int off_x, off_y; @@ -342,19 +352,34 @@ paint_core_cursor_update (tool, mevent, gdisp_ptr) { ctype = GIMP_COLOR_PICKER_CURSOR; } - else if (x >= off_x && y >= off_y && - x < (off_x + drawable_width (GIMP_DRAWABLE(layer))) && - y < (off_y + drawable_height (GIMP_DRAWABLE(layer)))) - { - /* One more test--is there a selected region? - * if so, is cursor inside? - */ - if (gimage_mask_is_empty (gdisp->gimage)) - ctype = GDK_PENCIL; - else if (gimage_mask_value (gdisp->gimage, x, y)) - ctype = GDK_PENCIL; - } + else if (paint_core->curx >= off_x && paint_core->cury >= off_y && + paint_core->curx < (off_x + drawable_width (GIMP_DRAWABLE(layer))) && + paint_core->cury < (off_y + drawable_height (GIMP_DRAWABLE(layer)))) + { + /* One more test--is there a selected region? + * if so, is cursor inside? + */ + if (gimage_mask_is_empty (gdisp->gimage)) + ctype = GDK_PENCIL; + else if (gimage_mask_value (gdisp->gimage, paint_core->curx, paint_core->cury)) + ctype = GDK_PENCIL; + + } + + /* 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 (paint_core->core->gc == NULL) + draw_core_start (paint_core->core, gdisp->canvas->window, tool); + else + { + /* is this a bad hack ? */ + paint_core->core->paused_count = 0; + draw_core_resume (paint_core->core, tool); + } + } } + gdisplay_install_tool_cursor (gdisp, ctype); } @@ -382,17 +407,50 @@ paint_core_control (tool, action, gdisp_ptr) break; case HALT : (* paint_core->paint_func) (paint_core, drawable, FINISH_PAINT); + draw_core_stop (paint_core->core, tool); paint_core_cleanup (); break; } } void -paint_core_no_draw (tool) +paint_core_draw (tool) Tool * tool; { + GDisplay *gdisp; + PaintCore * paint_core; + + paint_core = (PaintCore *) tool->private; + + /* if shift was never used, we don't care about a redraw */ + if (paint_core->core->gc != NULL) + { + gdisp = (GDisplay *) tool->gdisp_ptr; + + /* Draw start target */ + gdk_draw_line (gdisp->canvas->window, paint_core->core->gc, + paint_core->lastx - (TARGET_WIDTH >> 1), paint_core->lasty, + paint_core->lastx + (TARGET_WIDTH >> 1), paint_core->lasty); + gdk_draw_line (gdisp->canvas->window, paint_core->core->gc, + paint_core->lastx, paint_core->lasty - (TARGET_HEIGHT >> 1), + paint_core->lastx, paint_core->lasty + (TARGET_HEIGHT >> 1)); + + /* Draw end target */ + gdk_draw_line (gdisp->canvas->window, paint_core->core->gc, + paint_core->curx - (TARGET_WIDTH >> 1), paint_core->cury, + paint_core->curx + (TARGET_WIDTH >> 1), paint_core->cury); + gdk_draw_line (gdisp->canvas->window, paint_core->core->gc, + paint_core->curx, paint_core->cury - (TARGET_HEIGHT >> 1), + paint_core->curx, paint_core->cury + (TARGET_HEIGHT >> 1)); + + /* Draw the line between the start and end coords */ + gdk_draw_line (gdisp->canvas->window, paint_core->core->gc, + paint_core->lastx, paint_core->lasty, + paint_core->curx, paint_core->cury); + + } return; -} +} Tool * paint_core_new (type) @@ -404,7 +462,7 @@ paint_core_new (type) tool = (Tool *) g_malloc (sizeof (Tool)); private = (PaintCore *) g_malloc (sizeof (PaintCore)); - private->core = draw_core_new (paint_core_no_draw); + private->core = draw_core_new (paint_core_draw); private->pick_colors = FALSE; tool->type = type; @@ -418,7 +476,8 @@ paint_core_new (type) tool->button_press_func = paint_core_button_press; tool->button_release_func = paint_core_button_release; tool->motion_func = paint_core_motion; - tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func; + tool->arrow_keys_func = standard_arrow_keys_func; + tool->modifier_key_func = standard_modifier_key_func; tool->cursor_update_func = paint_core_cursor_update; tool->control_func = paint_core_control; @@ -514,7 +573,10 @@ paint_core_init (paint_core, drawable, x, y) } void -paint_core_get_color_from_gradient (PaintCore *paint_core, double gradient_length, double *r, double *g, double *b,double *a, int mode) +paint_core_get_color_from_gradient (PaintCore *paint_core, + double gradient_length, + double *r, double *g, double *b, double *a, + int mode) { double y; double distance; /* distance in current brush stroke */ @@ -527,10 +589,10 @@ paint_core_get_color_from_gradient (PaintCore *paint_core, double gradient_lengt /* if were past the first chunk... */ - if((y/gradient_length) > 1.0) + if ((y/gradient_length) > 1.0) { /* if this is an "odd" chunk..." */ - if((int)(y/gradient_length) & 1) + if ((int)(y/gradient_length) & 1) { /* draw it "normally" */ y = y - (gradient_length*(int)(y/gradient_length)); diff --git a/app/tools/paintbrush.c b/app/tools/paintbrush.c index 16c4e2c638..7e4638aecb 100644 --- a/app/tools/paintbrush.c +++ b/app/tools/paintbrush.c @@ -384,7 +384,7 @@ paintbrush_motion (PaintCore *paint_core, gimage_get_foreground (gimage, drawable, col); - /* Get a region which can be used to p\\aint to */ + /* Get a region which can be used to paint to */ if (! (area = paint_core_get_paint_area (paint_core, drawable))) return; @@ -405,7 +405,7 @@ paintbrush_motion (PaintCore *paint_core, temp_blend = local_blend; /* hard core to mode LOOP_TRIANGLE */ - /* need to maek a gui to handle this */ + /* need to make a gui to handle this */ mode = gradient_type; if(gradient_length) diff --git a/app/widgets/gimpcursor.c b/app/widgets/gimpcursor.c index 8a83228e38..8e2d3f0b5c 100644 --- a/app/widgets/gimpcursor.c +++ b/app/widgets/gimpcursor.c @@ -85,7 +85,7 @@ static gboolean pending_removebusy = FALSE; static void -create_cursor(BM_Cursor *bmcursor) +create_cursor (BM_Cursor *bmcursor) { GdkPixmap *pixmap; GdkPixmap *pixmapmsk; @@ -97,12 +97,12 @@ create_cursor(BM_Cursor *bmcursor) pixmap = gdk_bitmap_create_from_data (NULL, bmcursor->bits, bmcursor->width, bmcursor->height); - g_return_if_fail(pixmap != NULL); + g_return_if_fail (pixmap != NULL); pixmapmsk = gdk_bitmap_create_from_data (NULL, bmcursor->mask_bits, bmcursor->width, bmcursor->height); - g_return_if_fail(pixmapmsk != NULL); + g_return_if_fail (pixmapmsk != NULL); bmcursor->cursor = gdk_cursor_new_from_pixmap (pixmap, pixmapmsk, &fg, &bg, bmcursor->x_hot, @@ -111,7 +111,7 @@ create_cursor(BM_Cursor *bmcursor) } static void -gimp_change_win_cursor(GdkWindow *win, GimpCursorType curtype) +gimp_change_win_cursor (GdkWindow *win, GimpCursorType curtype) { GdkCursor *cursor; diff --git a/app/widgets/gimpitemfactory.c b/app/widgets/gimpitemfactory.c index 21235eaa4b..79d90e950b 100644 --- a/app/widgets/gimpitemfactory.c +++ b/app/widgets/gimpitemfactory.c @@ -55,7 +55,6 @@ static const GtkItemFactoryEntry toolbox_entries[] = { N_("/File/About..."), NULL, about_dialog_cmd_callback, 0 }, { N_("/File/Preferences..."), NULL, file_pref_cmd_callback, 0 }, { N_("/File/Tip of the day"), NULL, tips_dialog_cmd_callback, 0 }, - { N_("/File/---"), NULL, NULL, 0, "" }, { N_("/File/Dialogs/Brushes..."), "B", dialogs_brushes_cmd_callback, 0 }, { N_("/File/Dialogs/Patterns..."), "P", dialogs_patterns_cmd_callback, 0 }, { N_("/File/Dialogs/Palette..."), "P", dialogs_palette_cmd_callback, 0 }, @@ -67,6 +66,7 @@ static const GtkItemFactoryEntry toolbox_entries[] = { N_("/File/Dialogs/Document Index..."), NULL, raise_idea_callback, 0 }, { N_("/File/Dialogs/Error Console..."), NULL, dialogs_error_console_cmd_callback, 0 }, { N_("/File/Dialogs/Module Browser..."), NULL, dialogs_module_browser_cmd_callback, 0 }, + { N_("/File/---"), NULL, NULL, 0, "" }, { N_("/File/---"), NULL, NULL, 0, "" } }; static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]);