From d5cfeb6643d206490000c71ea5c3e9a8518f0eb7 Mon Sep 17 00:00:00 2001 From: CST 1998 Larry Ewing Date: Mon, 16 Mar 1998 11:13:24 +0000 Subject: [PATCH] Reworked the guide drawing and picking code to remove all known guide Mon Mar 16 05:12:00 CST 1998 Larry Ewing * app/move.c: * app/gdisplay.c: * app/gimage.c: Reworked the guide drawing and picking code to remove all known guide artifacts. --- ChangeLog | 7 +++ app/core/gimpprojection.c | 24 ++++------ app/display/gimpdisplay.c | 24 ++++------ app/gdisplay.c | 24 ++++------ app/move.c | 99 +++++++++++++++++++++------------------ app/tools/gimpmovetool.c | 99 +++++++++++++++++++++------------------ app/tools/move.c | 99 +++++++++++++++++++++------------------ 7 files changed, 190 insertions(+), 186 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93e96a2254..0737a62cb1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Mar 16 05:12:00 CST 1998 Larry Ewing + + * app/move.c: + * app/gdisplay.c: + * app/gimage.c: Reworked the guide drawing and picking code to + remove all known guide artifacts. + Mon Mar 16 12:20:12 EET 1998 Lauri Alanko * app/menus.c: Fixed the tool options disappearing at undo. diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 79d4f1e6dc..577d2edbff 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -487,13 +487,15 @@ gdisplay_find_guide (GDisplay *gdisp, { case HORIZONTAL_GUIDE: pos = (int) (scale * guide->position - offset_y); - if ((pos > (y - EPSILON)) && + if ((guide->position != -1) && + (pos > (y - EPSILON)) && (pos < (y + EPSILON))) return guide; break; case VERTICAL_GUIDE: pos = (int) (scale * guide->position - offset_x); - if ((pos > (x - EPSILON)) && + if ((guide->position != -1) && + (pos > (x - EPSILON)) && (pos < (x + EPSILON))) return guide; break; @@ -1056,31 +1058,21 @@ void gdisplay_expose_guide (GDisplay *gdisp, Guide *guide) { - int x1, y1; - int x2, y2; int x, y; - int w, h; if (guide->position < 0) return; - gdisplay_transform_coords (gdisp, 0, 0, &x1, &y1, FALSE); - gdisplay_transform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE); - gdisplay_transform_coords (gdisp, guide->position, guide->position, &x, &y, FALSE); - gdk_window_get_size (gdisp->canvas->window, &w, &h); - - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 > w) x2 = w; - if (y2 > h) y2 = h; + gdisplay_transform_coords (gdisp, guide->position, + guide->position, &x, &y, FALSE); switch (guide->orientation) { case HORIZONTAL_GUIDE: - gdisplay_expose_area (gdisp, x1, y, x2 - x1, 1); + gdisplay_expose_area (gdisp, 0, y, gdisp->disp_width, 1); break; case VERTICAL_GUIDE: - gdisplay_expose_area (gdisp, x, y1, 1, y2 - y1); + gdisplay_expose_area (gdisp, x, 0, 1, gdisp->disp_height); break; } } diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index 79d4f1e6dc..577d2edbff 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -487,13 +487,15 @@ gdisplay_find_guide (GDisplay *gdisp, { case HORIZONTAL_GUIDE: pos = (int) (scale * guide->position - offset_y); - if ((pos > (y - EPSILON)) && + if ((guide->position != -1) && + (pos > (y - EPSILON)) && (pos < (y + EPSILON))) return guide; break; case VERTICAL_GUIDE: pos = (int) (scale * guide->position - offset_x); - if ((pos > (x - EPSILON)) && + if ((guide->position != -1) && + (pos > (x - EPSILON)) && (pos < (x + EPSILON))) return guide; break; @@ -1056,31 +1058,21 @@ void gdisplay_expose_guide (GDisplay *gdisp, Guide *guide) { - int x1, y1; - int x2, y2; int x, y; - int w, h; if (guide->position < 0) return; - gdisplay_transform_coords (gdisp, 0, 0, &x1, &y1, FALSE); - gdisplay_transform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE); - gdisplay_transform_coords (gdisp, guide->position, guide->position, &x, &y, FALSE); - gdk_window_get_size (gdisp->canvas->window, &w, &h); - - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 > w) x2 = w; - if (y2 > h) y2 = h; + gdisplay_transform_coords (gdisp, guide->position, + guide->position, &x, &y, FALSE); switch (guide->orientation) { case HORIZONTAL_GUIDE: - gdisplay_expose_area (gdisp, x1, y, x2 - x1, 1); + gdisplay_expose_area (gdisp, 0, y, gdisp->disp_width, 1); break; case VERTICAL_GUIDE: - gdisplay_expose_area (gdisp, x, y1, 1, y2 - y1); + gdisplay_expose_area (gdisp, x, 0, 1, gdisp->disp_height); break; } } diff --git a/app/gdisplay.c b/app/gdisplay.c index 79d4f1e6dc..577d2edbff 100644 --- a/app/gdisplay.c +++ b/app/gdisplay.c @@ -487,13 +487,15 @@ gdisplay_find_guide (GDisplay *gdisp, { case HORIZONTAL_GUIDE: pos = (int) (scale * guide->position - offset_y); - if ((pos > (y - EPSILON)) && + if ((guide->position != -1) && + (pos > (y - EPSILON)) && (pos < (y + EPSILON))) return guide; break; case VERTICAL_GUIDE: pos = (int) (scale * guide->position - offset_x); - if ((pos > (x - EPSILON)) && + if ((guide->position != -1) && + (pos > (x - EPSILON)) && (pos < (x + EPSILON))) return guide; break; @@ -1056,31 +1058,21 @@ void gdisplay_expose_guide (GDisplay *gdisp, Guide *guide) { - int x1, y1; - int x2, y2; int x, y; - int w, h; if (guide->position < 0) return; - gdisplay_transform_coords (gdisp, 0, 0, &x1, &y1, FALSE); - gdisplay_transform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE); - gdisplay_transform_coords (gdisp, guide->position, guide->position, &x, &y, FALSE); - gdk_window_get_size (gdisp->canvas->window, &w, &h); - - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 > w) x2 = w; - if (y2 > h) y2 = h; + gdisplay_transform_coords (gdisp, guide->position, + guide->position, &x, &y, FALSE); switch (guide->orientation) { case HORIZONTAL_GUIDE: - gdisplay_expose_area (gdisp, x1, y, x2 - x1, 1); + gdisplay_expose_area (gdisp, 0, y, gdisp->disp_width, 1); break; case VERTICAL_GUIDE: - gdisplay_expose_area (gdisp, x, y1, 1, y2 - y1); + gdisplay_expose_area (gdisp, x, 0, 1, gdisp->disp_height); break; } } diff --git a/app/move.c b/app/move.c index 8d52755d14..1f1c84d158 100644 --- a/app/move.c +++ b/app/move.c @@ -127,6 +127,43 @@ move_tool_button_press (Tool *tool, } +static void +move_draw_guide (GDisplay *gdisp, Guide *guide) +{ + int x1, y1; + int x2, y2; + int w, h; + int x, y; + + if (!move_gc) + move_create_gc (gdisp); + + if (guide->position == -1) + return; + + gdisplay_transform_coords (gdisp, gdisp->gimage->width, + gdisp->gimage->height, &x2, &y2, FALSE); + + gdk_window_get_size (gdisp->canvas->window, &w, &h); + + switch (guide->orientation) { + case HORIZONTAL_GUIDE: + gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE); + if (x1 < 0) x1 = 0; + if (x2 > w) x2 = w; + + gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); + break; + case VERTICAL_GUIDE: + gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE); + if (y1 < 0) y1 = 0; + if (y2 > h) y2 = h; + + gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); + break; + } +} + void move_tool_button_release (Tool *tool, GdkEventButton *bevent, @@ -175,6 +212,7 @@ move_tool_button_release (Tool *tool, if (remove_guide) { + move_draw_guide (gdisp, move->guide); move->guide->position = -1; move->guide = NULL; move->guide_disp = -1; @@ -208,65 +246,34 @@ void move_tool_motion (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr) + { - MoveTool *private; GDisplay *gdisp; - int x1, y1; - int x2, y2; - int w, h; + MoveTool *private; int x, y; - private = tool->private; gdisp = gdisp_ptr; + private = tool->private; if (private->guide) { - if (!move_gc) - move_create_gc (gdisp); - - gdisplay_transform_coords (gdisp, 0, 0, &x1, &y1, FALSE); - gdisplay_transform_coords (gdisp, gdisp->gimage->width, gdisp->gimage->height, &x2, &y2, FALSE); - gdk_window_get_size (gdisp->canvas->window, &w, &h); - - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 > w) x2 = w; - if (y2 > h) y2 = h; - - if (private->guide->orientation == HORIZONTAL_GUIDE) + move_draw_guide (gdisp, private->guide); + + if (mevent) { - gdisplay_transform_coords (gdisp, 0, private->guide->position, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); - - if (mevent) - { - gdisplay_untransform_coords (gdisp, 0, mevent->y, - &x, &private->guide->position, - TRUE, FALSE); - - gdisplay_transform_coords (gdisp, 0, private->guide->position, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); - } - } - else if (private->guide->orientation == VERTICAL_GUIDE) - { - gdisplay_transform_coords (gdisp, private->guide->position, 0, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); - - if (mevent) - { - gdisplay_untransform_coords (gdisp, mevent->x, 0, - &private->guide->position, &y, - TRUE, FALSE); - - gdisplay_transform_coords (gdisp, private->guide->position, 0, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); - } + gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, + &x, &y, TRUE, FALSE); + + if (private->guide->orientation == HORIZONTAL_GUIDE) + private->guide->position = y; + else + private->guide->position = x; + + move_draw_guide (gdisp, private->guide); } } } - void move_tool_cursor_update (Tool *tool, GdkEventMotion *mevent, diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c index 8d52755d14..1f1c84d158 100644 --- a/app/tools/gimpmovetool.c +++ b/app/tools/gimpmovetool.c @@ -127,6 +127,43 @@ move_tool_button_press (Tool *tool, } +static void +move_draw_guide (GDisplay *gdisp, Guide *guide) +{ + int x1, y1; + int x2, y2; + int w, h; + int x, y; + + if (!move_gc) + move_create_gc (gdisp); + + if (guide->position == -1) + return; + + gdisplay_transform_coords (gdisp, gdisp->gimage->width, + gdisp->gimage->height, &x2, &y2, FALSE); + + gdk_window_get_size (gdisp->canvas->window, &w, &h); + + switch (guide->orientation) { + case HORIZONTAL_GUIDE: + gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE); + if (x1 < 0) x1 = 0; + if (x2 > w) x2 = w; + + gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); + break; + case VERTICAL_GUIDE: + gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE); + if (y1 < 0) y1 = 0; + if (y2 > h) y2 = h; + + gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); + break; + } +} + void move_tool_button_release (Tool *tool, GdkEventButton *bevent, @@ -175,6 +212,7 @@ move_tool_button_release (Tool *tool, if (remove_guide) { + move_draw_guide (gdisp, move->guide); move->guide->position = -1; move->guide = NULL; move->guide_disp = -1; @@ -208,65 +246,34 @@ void move_tool_motion (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr) + { - MoveTool *private; GDisplay *gdisp; - int x1, y1; - int x2, y2; - int w, h; + MoveTool *private; int x, y; - private = tool->private; gdisp = gdisp_ptr; + private = tool->private; if (private->guide) { - if (!move_gc) - move_create_gc (gdisp); - - gdisplay_transform_coords (gdisp, 0, 0, &x1, &y1, FALSE); - gdisplay_transform_coords (gdisp, gdisp->gimage->width, gdisp->gimage->height, &x2, &y2, FALSE); - gdk_window_get_size (gdisp->canvas->window, &w, &h); - - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 > w) x2 = w; - if (y2 > h) y2 = h; - - if (private->guide->orientation == HORIZONTAL_GUIDE) + move_draw_guide (gdisp, private->guide); + + if (mevent) { - gdisplay_transform_coords (gdisp, 0, private->guide->position, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); - - if (mevent) - { - gdisplay_untransform_coords (gdisp, 0, mevent->y, - &x, &private->guide->position, - TRUE, FALSE); - - gdisplay_transform_coords (gdisp, 0, private->guide->position, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); - } - } - else if (private->guide->orientation == VERTICAL_GUIDE) - { - gdisplay_transform_coords (gdisp, private->guide->position, 0, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); - - if (mevent) - { - gdisplay_untransform_coords (gdisp, mevent->x, 0, - &private->guide->position, &y, - TRUE, FALSE); - - gdisplay_transform_coords (gdisp, private->guide->position, 0, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); - } + gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, + &x, &y, TRUE, FALSE); + + if (private->guide->orientation == HORIZONTAL_GUIDE) + private->guide->position = y; + else + private->guide->position = x; + + move_draw_guide (gdisp, private->guide); } } } - void move_tool_cursor_update (Tool *tool, GdkEventMotion *mevent, diff --git a/app/tools/move.c b/app/tools/move.c index 8d52755d14..1f1c84d158 100644 --- a/app/tools/move.c +++ b/app/tools/move.c @@ -127,6 +127,43 @@ move_tool_button_press (Tool *tool, } +static void +move_draw_guide (GDisplay *gdisp, Guide *guide) +{ + int x1, y1; + int x2, y2; + int w, h; + int x, y; + + if (!move_gc) + move_create_gc (gdisp); + + if (guide->position == -1) + return; + + gdisplay_transform_coords (gdisp, gdisp->gimage->width, + gdisp->gimage->height, &x2, &y2, FALSE); + + gdk_window_get_size (gdisp->canvas->window, &w, &h); + + switch (guide->orientation) { + case HORIZONTAL_GUIDE: + gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE); + if (x1 < 0) x1 = 0; + if (x2 > w) x2 = w; + + gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); + break; + case VERTICAL_GUIDE: + gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE); + if (y1 < 0) y1 = 0; + if (y2 > h) y2 = h; + + gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); + break; + } +} + void move_tool_button_release (Tool *tool, GdkEventButton *bevent, @@ -175,6 +212,7 @@ move_tool_button_release (Tool *tool, if (remove_guide) { + move_draw_guide (gdisp, move->guide); move->guide->position = -1; move->guide = NULL; move->guide_disp = -1; @@ -208,65 +246,34 @@ void move_tool_motion (Tool *tool, GdkEventMotion *mevent, gpointer gdisp_ptr) + { - MoveTool *private; GDisplay *gdisp; - int x1, y1; - int x2, y2; - int w, h; + MoveTool *private; int x, y; - private = tool->private; gdisp = gdisp_ptr; + private = tool->private; if (private->guide) { - if (!move_gc) - move_create_gc (gdisp); - - gdisplay_transform_coords (gdisp, 0, 0, &x1, &y1, FALSE); - gdisplay_transform_coords (gdisp, gdisp->gimage->width, gdisp->gimage->height, &x2, &y2, FALSE); - gdk_window_get_size (gdisp->canvas->window, &w, &h); - - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 > w) x2 = w; - if (y2 > h) y2 = h; - - if (private->guide->orientation == HORIZONTAL_GUIDE) + move_draw_guide (gdisp, private->guide); + + if (mevent) { - gdisplay_transform_coords (gdisp, 0, private->guide->position, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); - - if (mevent) - { - gdisplay_untransform_coords (gdisp, 0, mevent->y, - &x, &private->guide->position, - TRUE, FALSE); - - gdisplay_transform_coords (gdisp, 0, private->guide->position, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); - } - } - else if (private->guide->orientation == VERTICAL_GUIDE) - { - gdisplay_transform_coords (gdisp, private->guide->position, 0, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); - - if (mevent) - { - gdisplay_untransform_coords (gdisp, mevent->x, 0, - &private->guide->position, &y, - TRUE, FALSE); - - gdisplay_transform_coords (gdisp, private->guide->position, 0, &x, &y, FALSE); - gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); - } + gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, + &x, &y, TRUE, FALSE); + + if (private->guide->orientation == HORIZONTAL_GUIDE) + private->guide->position = y; + else + private->guide->position = x; + + move_draw_guide (gdisp, private->guide); } } } - void move_tool_cursor_update (Tool *tool, GdkEventMotion *mevent,