[Kst] extragear/graphics/kst/src/libkstapp
Duncan Hanson
duncan.hanson at gmail.com
Wed Aug 2 23:28:20 CEST 2006
SVN commit 569079 by dhanson:
BUG:131740 correct for cases of even height/width.
M +15 -14 kstgfxmousehandlerutils.cpp
--- trunk/extragear/graphics/kst/src/libkstapp/kstgfxmousehandlerutils.cpp #569078:569079
@@ -109,32 +109,33 @@
QRect newSize(originalSize);
if (movePoint.y() == anchorPoint.y()) {
- int newWidth = pos.x() - anchorPoint.x() + 1; // +1 for the way widths are defined in QRect.
+ int newWidth = pos.x() - anchorPoint.x(); //defined differently than in QRect.
if (maintainAspect) {
- double newHalfHeight = originalSize.height() * abs(newWidth) / originalSize.width() / 2.0;
+ double newHalfHeight = originalSize.height() * (abs(newWidth) + 1) / originalSize.width() / 2.0; //defined with the QRect convention (height = bot - top + 1)
- newHalfHeight = kMin(double(movePoint.y() - bounds.top() + 1), newHalfHeight); // ensure we are still within the bounds.
- newHalfHeight = kMin(double(bounds.bottom() - movePoint.y() + 1), newHalfHeight);
+ newHalfHeight = kMin(double(movePoint.y() - bounds.top()) + 1, newHalfHeight); // ensure we are still within the bounds.
+ newHalfHeight = kMin(double(bounds.bottom() - movePoint.y()) + 1, newHalfHeight);
if (newWidth == 0) { // anything better to be done?
newWidth = 1;
}
- newWidth = int(originalSize.width() * newHalfHeight * 2.0 / originalSize.height() * newWidth / abs(newWidth)); // consistency of width w/ the newly calculated height.
- newSize.setTop(anchorPoint.y() + int(newHalfHeight));
- newSize.setBottom(anchorPoint.y() - int(newHalfHeight));
+ newWidth = (int(originalSize.width() * (newHalfHeight * 2.0) / originalSize.height()) - 1)*newWidth/abs(newWidth); // consistency of width w/ the newly calculated height.
+
+ newSize.setTop(anchorPoint.y() + int(newHalfHeight - 0.5));
+ newSize.setBottom(anchorPoint.y() - int(newHalfHeight - 0.5));
}
newSize.setLeft(anchorPoint.x());
- newSize.setWidth(newWidth);
+ newSize.setRight(anchorPoint.x() + newWidth); // +1 for the way widths are defined in QRect.
} else if (movePoint.x() == anchorPoint.x()) {
// mimic the case for (movePoint.y() == anchorPoint.y()). comments are there.
- int newHeight = pos.y() - anchorPoint.y() + 1;
+ int newHeight = pos.y() - anchorPoint.y();
if (maintainAspect) {
- double newHalfWidth = originalSize.width() * abs(newHeight) / originalSize.height() / 2.0;
+ double newHalfWidth = originalSize.width() * (abs(newHeight) + 1) / originalSize.height() / 2.0;
newHalfWidth = kMin(double(movePoint.x() - bounds.left() + 1), newHalfWidth);
newHalfWidth = kMin(double(bounds.right() - movePoint.x() + 1), newHalfWidth);
@@ -143,13 +144,13 @@
newHeight = 1;
}
- newHeight = int(originalSize.height() * newHalfWidth * 2.0 / originalSize.width() * newHeight / abs(newHeight));
- newSize.setLeft(anchorPoint.x() + int(newHalfWidth));
- newSize.setRight(anchorPoint.x() - int(newHalfWidth));
+ newHeight = (int(originalSize.height() * newHalfWidth * 2.0 / originalSize.width()) - 1)*newHeight/abs(newHeight);
+ newSize.setLeft(anchorPoint.x() + int(newHalfWidth - .5));
+ newSize.setRight(anchorPoint.x() - int(newHalfWidth - .5));
}
newSize.setTop(anchorPoint.y());
- newSize.setHeight(newHeight);
+ newSize.setBottom(anchorPoint.y() + newHeight);
}
newSize = newSize.normalize();
More information about the Kst
mailing list