diff --git a/src/patheditor/scalableimage.cpp b/src/patheditor/scalableimage.cpp index 63a148f..97462c4 100644 --- a/src/patheditor/scalableimage.cpp +++ b/src/patheditor/scalableimage.cpp @@ -21,9 +21,11 @@ ****************************************************************************/ #include "scalableimage.h" -#include "pathsettings.h" #include +#include #include "qmath.h" +#include "pathsettings.h" +#include "linerestrictor.h" using namespace patheditor; @@ -45,6 +47,14 @@ ScalableImage::ScalableImage(const QPixmap &pixmap, const QRect &initialRect, QG PathSettings settings = PathSettings::Default(); _scalePoint->createPointHandle(settings, this); + + connect(_scalePoint.data(), SIGNAL(pointDrag(PathPoint*)), this, SLOT(onScaleMove(PathPoint*))); + connect(_scalePoint.data(), SIGNAL(pointRelease(PathPoint*)), this, SLOT(onScaleMove(PathPoint*))); + + QPointF botLeft(_rect.bottomLeft()); + QPointF topRight(_rect.topRight()); + QSharedPointer restrictor(new LineRestrictor(botLeft, topRight)); + _scalePoint->setRestrictor(restrictor); } void ScalableImage::paint(QPainter *painter, const QStyleOptionGraphicsItem */*unused*/, QWidget */*unused*/) @@ -54,9 +64,23 @@ void ScalableImage::paint(QPainter *painter, const QStyleOptionGraphicsItem */*u QRectF ScalableImage::boundingRect() const { - return QRectF(_rect); + return QRectF(_rect) | _scalePoint.data()->handle()->boundingRect(); } ScalableImage::~ScalableImage() { } + +void ScalableImage::onScaleMove(PathPoint *point) +{ + QRect oldRect = _rect; + + QPointF relativePnt = *point - _rect.bottomLeft(); + + _rect.setHeight(-relativePnt.y()); + _rect.setWidth(relativePnt.x()); + + _rect.moveBottomLeft(oldRect.bottomLeft()); + + this->scene()->update(); +} diff --git a/src/patheditor/scalableimage.h b/src/patheditor/scalableimage.h index 99cd0eb..a0976af 100644 --- a/src/patheditor/scalableimage.h +++ b/src/patheditor/scalableimage.h @@ -47,6 +47,9 @@ namespace patheditor QPixmap _pixmap; QRect _rect; QScopedPointer _scalePoint; + + private slots: + void onScaleMove(PathPoint *point); }; } diff --git a/src/version_autogen.h b/src/version_autogen.h index 6d50d44..5713683 100644 --- a/src/version_autogen.h +++ b/src/version_autogen.h @@ -5,7 +5,7 @@ #ifndef VERSION_AUTOGEN_H #define VERSION_AUTOGEN_H -#define BUILD_NUMBER 229 -#define COMMIT_HASH "86e1d99c2a11ea74a05499951e9512cceb302dac" +#define BUILD_NUMBER 230 +#define COMMIT_HASH "645222332ebd341a19835353dffa7324d691f6cd" #endif // VERSION_AUTOGEN_H