snap in the center of the screen
svn path=/trunk/KDE/kdelibs/; revision=938474
This commit is contained in:
parent
71dfaf6ac8
commit
ddc3a4b978
@ -235,6 +235,9 @@ void ToolBox::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
int distanceToTop = newPos.y() - d->dragStartRelative.y();
|
int distanceToTop = newPos.y() - d->dragStartRelative.y();
|
||||||
int distanceToBottom = areaHeight - h - distanceToTop;
|
int distanceToBottom = areaHeight - h - distanceToTop;
|
||||||
|
|
||||||
|
int distancetoHorizontalMiddle = qAbs(newPos.x() - areaWidth/2);
|
||||||
|
int distancetoVerticalMiddle = qAbs(newPos.y() - areaHeight/2);
|
||||||
|
|
||||||
// decide which border is the nearest
|
// decide which border is the nearest
|
||||||
if (distanceToLeft < distanceToTop && distanceToLeft < distanceToRight &&
|
if (distanceToLeft < distanceToTop && distanceToLeft < distanceToRight &&
|
||||||
distanceToLeft < distanceToBottom ) {
|
distanceToLeft < distanceToBottom ) {
|
||||||
@ -257,6 +260,12 @@ void ToolBox::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
x = (newPos.x() - d->dragStartRelative.x());
|
x = (newPos.x() - d->dragStartRelative.x());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (distancetoHorizontalMiddle < 10) {
|
||||||
|
x = areaWidth/2 - d->dragStartRelative.x();
|
||||||
|
} else if (distancetoVerticalMiddle < 10) {
|
||||||
|
y = areaHeight/2 - d->dragStartRelative.y();
|
||||||
|
}
|
||||||
|
|
||||||
//kDebug() << "distances from borders" << (newPos - d->dragStartRelative) << distanceToLeft << distanceToRight << distanceToTop << distanceToBottom << "=>" << x << y;
|
//kDebug() << "distances from borders" << (newPos - d->dragStartRelative) << distanceToLeft << distanceToRight << distanceToTop << distanceToBottom << "=>" << x << y;
|
||||||
/*
|
/*
|
||||||
if (y == 0 || y + h >= areaHeight) {
|
if (y == 0 || y + h >= areaHeight) {
|
||||||
|
Loading…
Reference in New Issue
Block a user