KShare/cropeditor/drawing/ellipseitem.cpp
2017-07-08 21:40:09 +02:00

13 lines
530 B
C++

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