|
|
|
|
@ -25,16 +25,30 @@ void RectangleHandler::drawShape(Point& c, bool shiftDown) |
|
|
|
|
{ |
|
|
|
|
stroke->addPoint(c); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
else if (shiftDown) |
|
|
|
|
{ |
|
|
|
|
// Draw square if shift is pressed
|
|
|
|
|
Point p = stroke->getPoint(0); |
|
|
|
|
if (count > 3) |
|
|
|
|
|
|
|
|
|
stroke->deletePointsFrom(1); |
|
|
|
|
|
|
|
|
|
int size = MAX(ABS(c.x - p.x), ABS(c.y - p.y)); |
|
|
|
|
|
|
|
|
|
if (c.x - p.x < 0 || c.y - p.y < 0) |
|
|
|
|
{ |
|
|
|
|
stroke->deletePoint(4); |
|
|
|
|
stroke->deletePoint(3); |
|
|
|
|
stroke->deletePoint(2); |
|
|
|
|
stroke->deletePoint(1); |
|
|
|
|
size = -size; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
stroke->addPoint(Point(p.x, p.y + size)); |
|
|
|
|
stroke->addPoint(Point(p.x + size, p.y + size)); |
|
|
|
|
stroke->addPoint(Point(p.x + size, p.y)); |
|
|
|
|
stroke->addPoint(p); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Point p = stroke->getPoint(0); |
|
|
|
|
stroke->deletePointsFrom(1); |
|
|
|
|
|
|
|
|
|
stroke->addPoint(Point(c.x, p.y)); |
|
|
|
|
stroke->addPoint(c); |
|
|
|
|
stroke->addPoint(Point(p.x, c.y)); |
|
|
|
|
|