[Kst] branches/work/kst/portto4/kst/src/libkstapp

Adam Treat treat at kde.org
Fri Aug 31 00:48:36 CEST 2007


SVN commit 706634 by treat:

* resize experiment.  works, but not with transforms.


 M  +28 -7     viewitem.cpp  
 M  +1 -0      viewitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #706633:706634
@@ -431,15 +431,32 @@
   QPointF p = event->pos();
   QPointF l = event->lastPos();
   QPointF s = event->scenePos();
+  QPointF ls = event->lastScenePos();
 
   if (mouseMode() == ViewItem::Rotate) {
 
     rotateTowards(l, p);
 
-  } else if (mouseMode() == ViewItem::Resize || mouseMode() == ViewItem::Scale) {
+  } else if (mouseMode() == ViewItem::Resize) {
 
     switch(_activeGrip) {
     case TopLeftGrip:
+        resizeTopLeft(s - ls); break;
+    case TopRightGrip:
+    case BottomRightGrip:
+    case BottomLeftGrip:
+    case TopMidGrip:
+    case RightMidGrip:
+    case BottomMidGrip:
+    case LeftMidGrip:
+    case NoGrip:
+      break;
+    }
+
+  } else if (mouseMode() == ViewItem::Scale) {
+
+    switch(_activeGrip) {
+    case TopLeftGrip:
         setTopLeft(s); break;
     case TopRightGrip:
         setTopRight(s); break;
@@ -463,6 +480,14 @@
 }
 
 
+void ViewItem::resizeTopLeft(const QPointF &vector) {
+    //FIXME need to take into account transform...
+    QRectF r = rect();
+    r.setTopLeft(r.topLeft() + vector);
+    setViewRect(r);
+}
+
+
 void ViewItem::setTopLeft(const QPointF &point) {
 //   qDebug() << "setTopLeft" << point << endl;
 
@@ -474,12 +499,7 @@
   to.setTopLeft(point);
   from.moveBottomRight(anchor);
   to.moveBottomRight(anchor);
-
-  if (_mouseMode == Scale) {
-    transformToRect(from, to);
-  } else if (_mouseMode == Resize) {
-    //FIXME;
-  }
+  transformToRect(from, to);
 }
 
 
@@ -626,6 +646,7 @@
   return transformToRect(from_, to_);
 }
 
+
 bool ViewItem::transformToRect(const QPolygonF &from, const QPolygonF &to) {
 
   QTransform t;
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #706633:706634
@@ -92,6 +92,7 @@
   void raise();
   void lower();
   void edit();
+  void resizeTopLeft(const QPointF &vector);
   void setTopLeft(const QPointF &point);
   void setTopRight(const QPointF &point);
   void setBottomLeft(const QPointF &point);


More information about the Kst mailing list