Reworked the guide drawing and picking code to remove all known guide

Mon Mar 16 05:12:00 CST 1998  Larry Ewing  <lewing@gimp.org>

	* app/move.c:
	* app/gdisplay.c:
	* app/gimage.c: Reworked the guide drawing and picking code to
	remove all known guide artifacts.
This commit is contained in:
CST 1998 Larry Ewing 1998-03-16 11:13:24 +00:00 committed by Larry Ewing
parent 798a99b03d
commit d5cfeb6643
7 changed files with 190 additions and 186 deletions

View File

@ -1,3 +1,10 @@
Mon Mar 16 05:12:00 CST 1998 Larry Ewing <lewing@gimp.org>
* 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 <la@iki.fi> Mon Mar 16 12:20:12 EET 1998 Lauri Alanko <la@iki.fi>
* app/menus.c: Fixed the tool options disappearing at undo. * app/menus.c: Fixed the tool options disappearing at undo.

View File

@ -487,13 +487,15 @@ gdisplay_find_guide (GDisplay *gdisp,
{ {
case HORIZONTAL_GUIDE: case HORIZONTAL_GUIDE:
pos = (int) (scale * guide->position - offset_y); pos = (int) (scale * guide->position - offset_y);
if ((pos > (y - EPSILON)) && if ((guide->position != -1) &&
(pos > (y - EPSILON)) &&
(pos < (y + EPSILON))) (pos < (y + EPSILON)))
return guide; return guide;
break; break;
case VERTICAL_GUIDE: case VERTICAL_GUIDE:
pos = (int) (scale * guide->position - offset_x); pos = (int) (scale * guide->position - offset_x);
if ((pos > (x - EPSILON)) && if ((guide->position != -1) &&
(pos > (x - EPSILON)) &&
(pos < (x + EPSILON))) (pos < (x + EPSILON)))
return guide; return guide;
break; break;
@ -1056,31 +1058,21 @@ void
gdisplay_expose_guide (GDisplay *gdisp, gdisplay_expose_guide (GDisplay *gdisp,
Guide *guide) Guide *guide)
{ {
int x1, y1;
int x2, y2;
int x, y; int x, y;
int w, h;
if (guide->position < 0) if (guide->position < 0)
return; return;
gdisplay_transform_coords (gdisp, 0, 0, &x1, &y1, FALSE); gdisplay_transform_coords (gdisp, guide->position,
gdisplay_transform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE); guide->position, &x, &y, 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;
switch (guide->orientation) switch (guide->orientation)
{ {
case HORIZONTAL_GUIDE: case HORIZONTAL_GUIDE:
gdisplay_expose_area (gdisp, x1, y, x2 - x1, 1); gdisplay_expose_area (gdisp, 0, y, gdisp->disp_width, 1);
break; break;
case VERTICAL_GUIDE: case VERTICAL_GUIDE:
gdisplay_expose_area (gdisp, x, y1, 1, y2 - y1); gdisplay_expose_area (gdisp, x, 0, 1, gdisp->disp_height);
break; break;
} }
} }

View File

@ -487,13 +487,15 @@ gdisplay_find_guide (GDisplay *gdisp,
{ {
case HORIZONTAL_GUIDE: case HORIZONTAL_GUIDE:
pos = (int) (scale * guide->position - offset_y); pos = (int) (scale * guide->position - offset_y);
if ((pos > (y - EPSILON)) && if ((guide->position != -1) &&
(pos > (y - EPSILON)) &&
(pos < (y + EPSILON))) (pos < (y + EPSILON)))
return guide; return guide;
break; break;
case VERTICAL_GUIDE: case VERTICAL_GUIDE:
pos = (int) (scale * guide->position - offset_x); pos = (int) (scale * guide->position - offset_x);
if ((pos > (x - EPSILON)) && if ((guide->position != -1) &&
(pos > (x - EPSILON)) &&
(pos < (x + EPSILON))) (pos < (x + EPSILON)))
return guide; return guide;
break; break;
@ -1056,31 +1058,21 @@ void
gdisplay_expose_guide (GDisplay *gdisp, gdisplay_expose_guide (GDisplay *gdisp,
Guide *guide) Guide *guide)
{ {
int x1, y1;
int x2, y2;
int x, y; int x, y;
int w, h;
if (guide->position < 0) if (guide->position < 0)
return; return;
gdisplay_transform_coords (gdisp, 0, 0, &x1, &y1, FALSE); gdisplay_transform_coords (gdisp, guide->position,
gdisplay_transform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE); guide->position, &x, &y, 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;
switch (guide->orientation) switch (guide->orientation)
{ {
case HORIZONTAL_GUIDE: case HORIZONTAL_GUIDE:
gdisplay_expose_area (gdisp, x1, y, x2 - x1, 1); gdisplay_expose_area (gdisp, 0, y, gdisp->disp_width, 1);
break; break;
case VERTICAL_GUIDE: case VERTICAL_GUIDE:
gdisplay_expose_area (gdisp, x, y1, 1, y2 - y1); gdisplay_expose_area (gdisp, x, 0, 1, gdisp->disp_height);
break; break;
} }
} }

View File

@ -487,13 +487,15 @@ gdisplay_find_guide (GDisplay *gdisp,
{ {
case HORIZONTAL_GUIDE: case HORIZONTAL_GUIDE:
pos = (int) (scale * guide->position - offset_y); pos = (int) (scale * guide->position - offset_y);
if ((pos > (y - EPSILON)) && if ((guide->position != -1) &&
(pos > (y - EPSILON)) &&
(pos < (y + EPSILON))) (pos < (y + EPSILON)))
return guide; return guide;
break; break;
case VERTICAL_GUIDE: case VERTICAL_GUIDE:
pos = (int) (scale * guide->position - offset_x); pos = (int) (scale * guide->position - offset_x);
if ((pos > (x - EPSILON)) && if ((guide->position != -1) &&
(pos > (x - EPSILON)) &&
(pos < (x + EPSILON))) (pos < (x + EPSILON)))
return guide; return guide;
break; break;
@ -1056,31 +1058,21 @@ void
gdisplay_expose_guide (GDisplay *gdisp, gdisplay_expose_guide (GDisplay *gdisp,
Guide *guide) Guide *guide)
{ {
int x1, y1;
int x2, y2;
int x, y; int x, y;
int w, h;
if (guide->position < 0) if (guide->position < 0)
return; return;
gdisplay_transform_coords (gdisp, 0, 0, &x1, &y1, FALSE); gdisplay_transform_coords (gdisp, guide->position,
gdisplay_transform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE); guide->position, &x, &y, 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;
switch (guide->orientation) switch (guide->orientation)
{ {
case HORIZONTAL_GUIDE: case HORIZONTAL_GUIDE:
gdisplay_expose_area (gdisp, x1, y, x2 - x1, 1); gdisplay_expose_area (gdisp, 0, y, gdisp->disp_width, 1);
break; break;
case VERTICAL_GUIDE: case VERTICAL_GUIDE:
gdisplay_expose_area (gdisp, x, y1, 1, y2 - y1); gdisplay_expose_area (gdisp, x, 0, 1, gdisp->disp_height);
break; break;
} }
} }

View File

@ -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 void
move_tool_button_release (Tool *tool, move_tool_button_release (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
@ -175,6 +212,7 @@ move_tool_button_release (Tool *tool,
if (remove_guide) if (remove_guide)
{ {
move_draw_guide (gdisp, move->guide);
move->guide->position = -1; move->guide->position = -1;
move->guide = NULL; move->guide = NULL;
move->guide_disp = -1; move->guide_disp = -1;
@ -208,65 +246,34 @@ void
move_tool_motion (Tool *tool, move_tool_motion (Tool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
MoveTool *private;
GDisplay *gdisp; GDisplay *gdisp;
int x1, y1; MoveTool *private;
int x2, y2;
int w, h;
int x, y; int x, y;
private = tool->private;
gdisp = gdisp_ptr; gdisp = gdisp_ptr;
private = tool->private;
if (private->guide) if (private->guide)
{ {
if (!move_gc) move_draw_guide (gdisp, private->guide);
move_create_gc (gdisp);
if (mevent)
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)
{ {
gdisplay_transform_coords (gdisp, 0, private->guide->position, &x, &y, FALSE); gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); &x, &y, TRUE, FALSE);
if (mevent) if (private->guide->orientation == HORIZONTAL_GUIDE)
{ private->guide->position = y;
gdisplay_untransform_coords (gdisp, 0, mevent->y, else
&x, &private->guide->position, private->guide->position = x;
TRUE, FALSE);
move_draw_guide (gdisp, private->guide);
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);
}
} }
} }
} }
void void
move_tool_cursor_update (Tool *tool, move_tool_cursor_update (Tool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,

View File

@ -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 void
move_tool_button_release (Tool *tool, move_tool_button_release (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
@ -175,6 +212,7 @@ move_tool_button_release (Tool *tool,
if (remove_guide) if (remove_guide)
{ {
move_draw_guide (gdisp, move->guide);
move->guide->position = -1; move->guide->position = -1;
move->guide = NULL; move->guide = NULL;
move->guide_disp = -1; move->guide_disp = -1;
@ -208,65 +246,34 @@ void
move_tool_motion (Tool *tool, move_tool_motion (Tool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
MoveTool *private;
GDisplay *gdisp; GDisplay *gdisp;
int x1, y1; MoveTool *private;
int x2, y2;
int w, h;
int x, y; int x, y;
private = tool->private;
gdisp = gdisp_ptr; gdisp = gdisp_ptr;
private = tool->private;
if (private->guide) if (private->guide)
{ {
if (!move_gc) move_draw_guide (gdisp, private->guide);
move_create_gc (gdisp);
if (mevent)
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)
{ {
gdisplay_transform_coords (gdisp, 0, private->guide->position, &x, &y, FALSE); gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); &x, &y, TRUE, FALSE);
if (mevent) if (private->guide->orientation == HORIZONTAL_GUIDE)
{ private->guide->position = y;
gdisplay_untransform_coords (gdisp, 0, mevent->y, else
&x, &private->guide->position, private->guide->position = x;
TRUE, FALSE);
move_draw_guide (gdisp, private->guide);
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);
}
} }
} }
} }
void void
move_tool_cursor_update (Tool *tool, move_tool_cursor_update (Tool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,

View File

@ -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 void
move_tool_button_release (Tool *tool, move_tool_button_release (Tool *tool,
GdkEventButton *bevent, GdkEventButton *bevent,
@ -175,6 +212,7 @@ move_tool_button_release (Tool *tool,
if (remove_guide) if (remove_guide)
{ {
move_draw_guide (gdisp, move->guide);
move->guide->position = -1; move->guide->position = -1;
move->guide = NULL; move->guide = NULL;
move->guide_disp = -1; move->guide_disp = -1;
@ -208,65 +246,34 @@ void
move_tool_motion (Tool *tool, move_tool_motion (Tool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
MoveTool *private;
GDisplay *gdisp; GDisplay *gdisp;
int x1, y1; MoveTool *private;
int x2, y2;
int w, h;
int x, y; int x, y;
private = tool->private;
gdisp = gdisp_ptr; gdisp = gdisp_ptr;
private = tool->private;
if (private->guide) if (private->guide)
{ {
if (!move_gc) move_draw_guide (gdisp, private->guide);
move_create_gc (gdisp);
if (mevent)
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)
{ {
gdisplay_transform_coords (gdisp, 0, private->guide->position, &x, &y, FALSE); gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); &x, &y, TRUE, FALSE);
if (mevent) if (private->guide->orientation == HORIZONTAL_GUIDE)
{ private->guide->position = y;
gdisplay_untransform_coords (gdisp, 0, mevent->y, else
&x, &private->guide->position, private->guide->position = x;
TRUE, FALSE);
move_draw_guide (gdisp, private->guide);
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);
}
} }
} }
} }
void void
move_tool_cursor_update (Tool *tool, move_tool_cursor_update (Tool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,