Applied the second patch from Xach with a slight modification to get

centered fixed-size selections right.


--Sven
This commit is contained in:
Sven Neumann
1998-12-19 23:59:04 +00:00
parent 3231691d2f
commit dc436e826e
4 changed files with 96 additions and 117 deletions

View File

@ -1,3 +1,9 @@
Sun Dec 20 00:55:21 MET 1998 Sven Neumann <sven@gimp.org>
* app/rect_select.c: applied the second patch from Xach with
a slight modification to get centered fixed-size selections
right.
Sat Dec 19 19:19:22 MET 1998 Sven Neumann <sven@gimp.org> Sat Dec 19 19:19:22 MET 1998 Sven Neumann <sven@gimp.org>
* app/rect_select.c: applied the patch from Xach. Corrects the * app/rect_select.c: applied the patch from Xach. Corrects the

View File

@ -344,13 +344,9 @@ rect_select_button_press (Tool *tool,
default: default:
break; break;
} }
if (rect_sel->fixed_size) {
rect_sel->w = rect_sel->fixed_width; rect_sel->w = 0;
rect_sel->h = rect_sel->fixed_height; rect_sel->h = 0;
} else {
rect_sel->w = 0;
rect_sel->h = 0;
}
rect_sel->center = FALSE; rect_sel->center = FALSE;
@ -520,36 +516,31 @@ rect_select_motion (Tool *tool,
(double)rect_sel->fixed_width); (double)rect_sel->fixed_width);
tw = x - ox; tw = x - ox;
th = y - oy; th = y - oy;
/*
/* * This is probably an inefficient way to do it, but it gives
* This is probably a poorly-optimized way to do it, but it gives * nicer, more predictable results than the original agorithm
* nicer, more predictable results than the original agorithm */
* FIXME: center-originating selections (Ctrl-drag) are broken now.
* -xach if ((abs(th) < (ratio * abs(tw))) && (abs(tw) > (abs(th) / ratio)))
*/ {
w = tw;
if ((abs(th) < (ratio * abs(tw))) && (abs(tw) > (abs(th) / ratio))) h = (int)(tw * ratio);
{ /* h should have the sign of th */
w = tw; if ((th < 0 && h > 0) || (th > 0 && h < 0))
h = (int)(tw * ratio); h = -h;
/* h should have the sign of th */ }
if ((th < 0 && h > 0) || (th > 0 && h < 0)) else
h = -h; {
} h = th;
else w = (int)(th / ratio);
{ /* w should have the sign of tw */
h = th; if ((tw < 0 && w > 0) || (tw > 0 && w < 0))
w = (int)(th / ratio); w = -w;
/* w should have the sign of tw */ }
if ((tw < 0 && w > 0) || (tw > 0 && w < 0)) } else {
w = -w; w = rect_sel->fixed_width;
} h = rect_sel->fixed_height;
} else { }
w = rect_sel->fixed_width;
h = rect_sel->fixed_height;
ox = x;
oy = y;
}
} else { } else {
w = (x - ox); w = (x - ox);
h = (y - oy); h = (y - oy);
@ -576,8 +567,8 @@ rect_select_motion (Tool *tool,
{ {
if (rect_sel->fixed_size) if (rect_sel->fixed_size)
{ {
rect_sel->x = ox - w / 2; rect_sel->x = ox - (w/2);
rect_sel->y = oy - h / 2; rect_sel->y = oy - (h/2);
rect_sel->w = w; rect_sel->w = w;
rect_sel->h = h; rect_sel->h = h;
} }

View File

@ -344,13 +344,9 @@ rect_select_button_press (Tool *tool,
default: default:
break; break;
} }
if (rect_sel->fixed_size) {
rect_sel->w = rect_sel->fixed_width; rect_sel->w = 0;
rect_sel->h = rect_sel->fixed_height; rect_sel->h = 0;
} else {
rect_sel->w = 0;
rect_sel->h = 0;
}
rect_sel->center = FALSE; rect_sel->center = FALSE;
@ -520,36 +516,31 @@ rect_select_motion (Tool *tool,
(double)rect_sel->fixed_width); (double)rect_sel->fixed_width);
tw = x - ox; tw = x - ox;
th = y - oy; th = y - oy;
/*
/* * This is probably an inefficient way to do it, but it gives
* This is probably a poorly-optimized way to do it, but it gives * nicer, more predictable results than the original agorithm
* nicer, more predictable results than the original agorithm */
* FIXME: center-originating selections (Ctrl-drag) are broken now.
* -xach if ((abs(th) < (ratio * abs(tw))) && (abs(tw) > (abs(th) / ratio)))
*/ {
w = tw;
if ((abs(th) < (ratio * abs(tw))) && (abs(tw) > (abs(th) / ratio))) h = (int)(tw * ratio);
{ /* h should have the sign of th */
w = tw; if ((th < 0 && h > 0) || (th > 0 && h < 0))
h = (int)(tw * ratio); h = -h;
/* h should have the sign of th */ }
if ((th < 0 && h > 0) || (th > 0 && h < 0)) else
h = -h; {
} h = th;
else w = (int)(th / ratio);
{ /* w should have the sign of tw */
h = th; if ((tw < 0 && w > 0) || (tw > 0 && w < 0))
w = (int)(th / ratio); w = -w;
/* w should have the sign of tw */ }
if ((tw < 0 && w > 0) || (tw > 0 && w < 0)) } else {
w = -w; w = rect_sel->fixed_width;
} h = rect_sel->fixed_height;
} else { }
w = rect_sel->fixed_width;
h = rect_sel->fixed_height;
ox = x;
oy = y;
}
} else { } else {
w = (x - ox); w = (x - ox);
h = (y - oy); h = (y - oy);
@ -576,8 +567,8 @@ rect_select_motion (Tool *tool,
{ {
if (rect_sel->fixed_size) if (rect_sel->fixed_size)
{ {
rect_sel->x = ox - w / 2; rect_sel->x = ox - (w/2);
rect_sel->y = oy - h / 2; rect_sel->y = oy - (h/2);
rect_sel->w = w; rect_sel->w = w;
rect_sel->h = h; rect_sel->h = h;
} }

View File

@ -344,13 +344,9 @@ rect_select_button_press (Tool *tool,
default: default:
break; break;
} }
if (rect_sel->fixed_size) {
rect_sel->w = rect_sel->fixed_width; rect_sel->w = 0;
rect_sel->h = rect_sel->fixed_height; rect_sel->h = 0;
} else {
rect_sel->w = 0;
rect_sel->h = 0;
}
rect_sel->center = FALSE; rect_sel->center = FALSE;
@ -520,36 +516,31 @@ rect_select_motion (Tool *tool,
(double)rect_sel->fixed_width); (double)rect_sel->fixed_width);
tw = x - ox; tw = x - ox;
th = y - oy; th = y - oy;
/*
/* * This is probably an inefficient way to do it, but it gives
* This is probably a poorly-optimized way to do it, but it gives * nicer, more predictable results than the original agorithm
* nicer, more predictable results than the original agorithm */
* FIXME: center-originating selections (Ctrl-drag) are broken now.
* -xach if ((abs(th) < (ratio * abs(tw))) && (abs(tw) > (abs(th) / ratio)))
*/ {
w = tw;
if ((abs(th) < (ratio * abs(tw))) && (abs(tw) > (abs(th) / ratio))) h = (int)(tw * ratio);
{ /* h should have the sign of th */
w = tw; if ((th < 0 && h > 0) || (th > 0 && h < 0))
h = (int)(tw * ratio); h = -h;
/* h should have the sign of th */ }
if ((th < 0 && h > 0) || (th > 0 && h < 0)) else
h = -h; {
} h = th;
else w = (int)(th / ratio);
{ /* w should have the sign of tw */
h = th; if ((tw < 0 && w > 0) || (tw > 0 && w < 0))
w = (int)(th / ratio); w = -w;
/* w should have the sign of tw */ }
if ((tw < 0 && w > 0) || (tw > 0 && w < 0)) } else {
w = -w; w = rect_sel->fixed_width;
} h = rect_sel->fixed_height;
} else { }
w = rect_sel->fixed_width;
h = rect_sel->fixed_height;
ox = x;
oy = y;
}
} else { } else {
w = (x - ox); w = (x - ox);
h = (y - oy); h = (y - oy);
@ -576,8 +567,8 @@ rect_select_motion (Tool *tool,
{ {
if (rect_sel->fixed_size) if (rect_sel->fixed_size)
{ {
rect_sel->x = ox - w / 2; rect_sel->x = ox - (w/2);
rect_sel->y = oy - h / 2; rect_sel->y = oy - (h/2);
rect_sel->w = w; rect_sel->w = w;
rect_sel->h = h; rect_sel->h = h;
} }