Applied the second patch from Xach with a slight modification to get
centered fixed-size selections right. --Sven
This commit is contained in:
@ -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
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user