KShare/cropeditor/drawing/ellipseitem.cpp

13 lines
530 B
C++
Raw Normal View History

2017-06-26 18:27:38 +02:00
#include "ellipseitem.hpp"
void EllipseItem::mouseDragEvent(QGraphicsSceneMouseEvent *, CropScene *scene) {
2017-06-26 18:27:38 +02:00
if (!ellie) {
ellie = scene->addEllipse(scene->cursorPosition().x(), scene->cursorPosition().y(), 0, 0, scene->pen(), scene->brush());
initPos = scene->cursorPosition();
2017-06-26 18:27:38 +02:00
} else {
auto p = scene->cursorPosition();
2017-06-26 18:27:38 +02:00
ellie->setRect(QRectF(qMin(initPos.x(), p.x()), qMin(initPos.y(), p.y()), qAbs(initPos.x() - p.x()),
qAbs(initPos.y() - p.y())));
}
}