do the box thing!

--Sven
This commit is contained in:
Sven Neumann 1999-09-21 09:11:42 +00:00
parent 9ee9939102
commit 8c404ed3e6
10 changed files with 160 additions and 147 deletions

View File

@ -1,3 +1,11 @@
Tue Sep 21 11:07:23 MEST 1999 Sven Neuman <sven@gimp.org>
* blend.c
* measure.c
* paint_core.c: Changed the behaviour of the 45-degrees constraints
again. Now it mimics the selection tools. Using the <Shift> key
with the blend tool restricts it to 15 degrees.
Mon Sep 20 23:06:36 MEST 1999 Sven Neuman <sven@gimp.org>
* app/measure.c: made the creation of guides undoable.

View File

@ -631,45 +631,46 @@ blend_motion (Tool *tool,
&blend_tool->endx, &blend_tool->endy, FALSE, 1);
/* Restrict to multiples of 45 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK) {
int dx, dy, d;
int abs_dx, abs_dy;
/* Restrict to multiples of 15 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK)
{
int tangens[6] = { 34, 106, 196, 334, 618, 1944 };
int cosinus[7] = { 256, 247, 222, 181, 128, 66, 0 };
int dx, dy, i, radius, frac;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
abs_dx = abs(dx);
abs_dy = abs(dy);
d = (abs_dx + abs_dy) >> 1;
if ((abs_dx >> 1) < abs_dy && (abs_dy >> 1) < abs_dx)
{
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
}
else
{
if (abs_dx > abs_dy)
blend_tool->endy = blend_tool->starty;
else
blend_tool->endx = blend_tool->startx;
}
}
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
if (dy)
{
radius = sqrt (SQR (dx) + SQR (dy));
frac = abs ((dx << 8) / dy);
for (i = 0; i < 6; i++)
{
if (frac < tangens[i])
break;
}
dx = dx > 0 ? (cosinus[6-i] * radius) >> 8 : - ((cosinus[6-i] * radius) >> 8);
dy = dy > 0 ? (cosinus[i] * radius) >> 8 : - ((cosinus[i] * radius) >> 8);
}
blend_tool->endx = blend_tool->startx + dx;
blend_tool->endy = blend_tool->starty + dy;
}
/* restrict to horizontal/vertical blend, if modifiers are pressed */
if (mevent->state & GDK_MOD1_MASK)
{
if (mevent->state & GDK_CONTROL_MASK)
{
int dx, dy, d;
int dx, dy;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
d = (abs(dx) + abs(dy)) >> 1;
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
blend_tool->endx = blend_tool->startx +
(dx > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
blend_tool->endy = blend_tool->starty +
(dy > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
}
else
blend_tool->endx = blend_tool->startx;

View File

@ -631,45 +631,46 @@ blend_motion (Tool *tool,
&blend_tool->endx, &blend_tool->endy, FALSE, 1);
/* Restrict to multiples of 45 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK) {
int dx, dy, d;
int abs_dx, abs_dy;
/* Restrict to multiples of 15 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK)
{
int tangens[6] = { 34, 106, 196, 334, 618, 1944 };
int cosinus[7] = { 256, 247, 222, 181, 128, 66, 0 };
int dx, dy, i, radius, frac;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
abs_dx = abs(dx);
abs_dy = abs(dy);
d = (abs_dx + abs_dy) >> 1;
if ((abs_dx >> 1) < abs_dy && (abs_dy >> 1) < abs_dx)
{
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
}
else
{
if (abs_dx > abs_dy)
blend_tool->endy = blend_tool->starty;
else
blend_tool->endx = blend_tool->startx;
}
}
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
if (dy)
{
radius = sqrt (SQR (dx) + SQR (dy));
frac = abs ((dx << 8) / dy);
for (i = 0; i < 6; i++)
{
if (frac < tangens[i])
break;
}
dx = dx > 0 ? (cosinus[6-i] * radius) >> 8 : - ((cosinus[6-i] * radius) >> 8);
dy = dy > 0 ? (cosinus[i] * radius) >> 8 : - ((cosinus[i] * radius) >> 8);
}
blend_tool->endx = blend_tool->startx + dx;
blend_tool->endy = blend_tool->starty + dy;
}
/* restrict to horizontal/vertical blend, if modifiers are pressed */
if (mevent->state & GDK_MOD1_MASK)
{
if (mevent->state & GDK_CONTROL_MASK)
{
int dx, dy, d;
int dx, dy;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
d = (abs(dx) + abs(dy)) >> 1;
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
blend_tool->endx = blend_tool->startx +
(dx > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
blend_tool->endy = blend_tool->starty +
(dy > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
}
else
blend_tool->endx = blend_tool->startx;

View File

@ -384,14 +384,13 @@ measure_tool_motion (Tool *tool,
{
if (mevent->state & GDK_CONTROL_MASK)
{
int d;
dx = measure_tool->x[i] - measure_tool->x[0];
dy = measure_tool->y[i] - measure_tool->y[0];
d = (abs(dx) + abs(dy)) >> 1;
measure_tool->x[i] = measure_tool->x[0] + ((dx < 0) ? -d : d);
measure_tool->y[i] = measure_tool->y[0] + ((dy < 0) ? -d : d);
measure_tool->x[i] = measure_tool->x[0] +
(dx > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
measure_tool->y[i] = measure_tool->y[0] +
(dy > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
}
else
measure_tool->x[i] = measure_tool->x[0];

View File

@ -244,14 +244,15 @@ paint_core_button_press (Tool *tool,
{
if (bevent->state & GDK_CONTROL_MASK)
{
double dx, dy, d;
double dx, dy;
dx = paint_core->curx - paint_core->lastx;
dy = paint_core->cury - paint_core->lasty;
d = (fabs(dx) + fabs(dy)) / 2;
paint_core->curx = paint_core->lastx + ((dx < 0) ? -d : d);
paint_core->cury = paint_core->lasty + ((dy < 0) ? -d : d);
paint_core->curx = paint_core->lastx +
(dx > 0 ? MAX (fabs (dx), fabs (dy)) : - MAX (fabs (dx), fabs (dy)));
paint_core->cury = paint_core->lasty +
(dy > 0 ? MAX (fabs (dx), fabs (dy)) : - MAX (fabs (dx), fabs (dy)));
}
else
paint_core->curx = paint_core->lastx;
@ -449,10 +450,11 @@ paint_core_cursor_update (Tool *tool,
{
dx = paint_core->curx - paint_core->lastx;
dy = paint_core->cury - paint_core->lasty;
d = (fabs(dx) + fabs(dy)) / 2;
paint_core->curx = paint_core->lastx + ((dx < 0) ? -d : d);
paint_core->cury = paint_core->lasty + ((dy < 0) ? -d : d);
paint_core->curx = paint_core->lastx +
(dx > 0 ? MAX (fabs (dx), fabs (dy)) : - MAX (fabs (dx), fabs (dy)));
paint_core->cury = paint_core->lasty +
(dy > 0 ? MAX (fabs (dx), fabs (dy)) : - MAX (fabs (dx), fabs (dy)));
}
else
paint_core->curx = paint_core->lastx;

View File

@ -631,45 +631,46 @@ blend_motion (Tool *tool,
&blend_tool->endx, &blend_tool->endy, FALSE, 1);
/* Restrict to multiples of 45 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK) {
int dx, dy, d;
int abs_dx, abs_dy;
/* Restrict to multiples of 15 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK)
{
int tangens[6] = { 34, 106, 196, 334, 618, 1944 };
int cosinus[7] = { 256, 247, 222, 181, 128, 66, 0 };
int dx, dy, i, radius, frac;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
abs_dx = abs(dx);
abs_dy = abs(dy);
d = (abs_dx + abs_dy) >> 1;
if ((abs_dx >> 1) < abs_dy && (abs_dy >> 1) < abs_dx)
{
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
}
else
{
if (abs_dx > abs_dy)
blend_tool->endy = blend_tool->starty;
else
blend_tool->endx = blend_tool->startx;
}
}
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
if (dy)
{
radius = sqrt (SQR (dx) + SQR (dy));
frac = abs ((dx << 8) / dy);
for (i = 0; i < 6; i++)
{
if (frac < tangens[i])
break;
}
dx = dx > 0 ? (cosinus[6-i] * radius) >> 8 : - ((cosinus[6-i] * radius) >> 8);
dy = dy > 0 ? (cosinus[i] * radius) >> 8 : - ((cosinus[i] * radius) >> 8);
}
blend_tool->endx = blend_tool->startx + dx;
blend_tool->endy = blend_tool->starty + dy;
}
/* restrict to horizontal/vertical blend, if modifiers are pressed */
if (mevent->state & GDK_MOD1_MASK)
{
if (mevent->state & GDK_CONTROL_MASK)
{
int dx, dy, d;
int dx, dy;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
d = (abs(dx) + abs(dy)) >> 1;
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
blend_tool->endx = blend_tool->startx +
(dx > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
blend_tool->endy = blend_tool->starty +
(dy > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
}
else
blend_tool->endx = blend_tool->startx;

View File

@ -631,45 +631,46 @@ blend_motion (Tool *tool,
&blend_tool->endx, &blend_tool->endy, FALSE, 1);
/* Restrict to multiples of 45 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK) {
int dx, dy, d;
int abs_dx, abs_dy;
/* Restrict to multiples of 15 degrees if shift is pressed */
if (mevent->state & GDK_SHIFT_MASK)
{
int tangens[6] = { 34, 106, 196, 334, 618, 1944 };
int cosinus[7] = { 256, 247, 222, 181, 128, 66, 0 };
int dx, dy, i, radius, frac;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
abs_dx = abs(dx);
abs_dy = abs(dy);
d = (abs_dx + abs_dy) >> 1;
if ((abs_dx >> 1) < abs_dy && (abs_dy >> 1) < abs_dx)
{
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
}
else
{
if (abs_dx > abs_dy)
blend_tool->endy = blend_tool->starty;
else
blend_tool->endx = blend_tool->startx;
}
}
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
if (dy)
{
radius = sqrt (SQR (dx) + SQR (dy));
frac = abs ((dx << 8) / dy);
for (i = 0; i < 6; i++)
{
if (frac < tangens[i])
break;
}
dx = dx > 0 ? (cosinus[6-i] * radius) >> 8 : - ((cosinus[6-i] * radius) >> 8);
dy = dy > 0 ? (cosinus[i] * radius) >> 8 : - ((cosinus[i] * radius) >> 8);
}
blend_tool->endx = blend_tool->startx + dx;
blend_tool->endy = blend_tool->starty + dy;
}
/* restrict to horizontal/vertical blend, if modifiers are pressed */
if (mevent->state & GDK_MOD1_MASK)
{
if (mevent->state & GDK_CONTROL_MASK)
{
int dx, dy, d;
int dx, dy;
dx = blend_tool->endx - blend_tool->startx;
dy = blend_tool->endy - blend_tool->starty;
d = (abs(dx) + abs(dy)) >> 1;
blend_tool->endx = blend_tool->startx + ((dx < 0) ? -d : d);
blend_tool->endy = blend_tool->starty + ((dy < 0) ? -d : d);
blend_tool->endx = blend_tool->startx +
(dx > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
blend_tool->endy = blend_tool->starty +
(dy > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
}
else
blend_tool->endx = blend_tool->startx;

View File

@ -384,14 +384,13 @@ measure_tool_motion (Tool *tool,
{
if (mevent->state & GDK_CONTROL_MASK)
{
int d;
dx = measure_tool->x[i] - measure_tool->x[0];
dy = measure_tool->y[i] - measure_tool->y[0];
d = (abs(dx) + abs(dy)) >> 1;
measure_tool->x[i] = measure_tool->x[0] + ((dx < 0) ? -d : d);
measure_tool->y[i] = measure_tool->y[0] + ((dy < 0) ? -d : d);
measure_tool->x[i] = measure_tool->x[0] +
(dx > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
measure_tool->y[i] = measure_tool->y[0] +
(dy > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
}
else
measure_tool->x[i] = measure_tool->x[0];

View File

@ -384,14 +384,13 @@ measure_tool_motion (Tool *tool,
{
if (mevent->state & GDK_CONTROL_MASK)
{
int d;
dx = measure_tool->x[i] - measure_tool->x[0];
dy = measure_tool->y[i] - measure_tool->y[0];
d = (abs(dx) + abs(dy)) >> 1;
measure_tool->x[i] = measure_tool->x[0] + ((dx < 0) ? -d : d);
measure_tool->y[i] = measure_tool->y[0] + ((dy < 0) ? -d : d);
measure_tool->x[i] = measure_tool->x[0] +
(dx > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
measure_tool->y[i] = measure_tool->y[0] +
(dy > 0 ? MAX (abs (dx), abs (dy)) : - MAX (abs (dx), abs (dy)));
}
else
measure_tool->x[i] = measure_tool->x[0];

View File

@ -244,14 +244,15 @@ paint_core_button_press (Tool *tool,
{
if (bevent->state & GDK_CONTROL_MASK)
{
double dx, dy, d;
double dx, dy;
dx = paint_core->curx - paint_core->lastx;
dy = paint_core->cury - paint_core->lasty;
d = (fabs(dx) + fabs(dy)) / 2;
paint_core->curx = paint_core->lastx + ((dx < 0) ? -d : d);
paint_core->cury = paint_core->lasty + ((dy < 0) ? -d : d);
paint_core->curx = paint_core->lastx +
(dx > 0 ? MAX (fabs (dx), fabs (dy)) : - MAX (fabs (dx), fabs (dy)));
paint_core->cury = paint_core->lasty +
(dy > 0 ? MAX (fabs (dx), fabs (dy)) : - MAX (fabs (dx), fabs (dy)));
}
else
paint_core->curx = paint_core->lastx;
@ -449,10 +450,11 @@ paint_core_cursor_update (Tool *tool,
{
dx = paint_core->curx - paint_core->lastx;
dy = paint_core->cury - paint_core->lasty;
d = (fabs(dx) + fabs(dy)) / 2;
paint_core->curx = paint_core->lastx + ((dx < 0) ? -d : d);
paint_core->cury = paint_core->lasty + ((dy < 0) ? -d : d);
paint_core->curx = paint_core->lastx +
(dx > 0 ? MAX (fabs (dx), fabs (dy)) : - MAX (fabs (dx), fabs (dy)));
paint_core->cury = paint_core->lasty +
(dy > 0 ? MAX (fabs (dx), fabs (dy)) : - MAX (fabs (dx), fabs (dy)));
}
else
paint_core->curx = paint_core->lastx;