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

Adam Treat treat at kde.org
Thu Aug 30 15:44:46 CEST 2007


SVN commit 706463 by treat:

* Get ready for real resize VS real scale


 M  +1 -1      view.h  
 M  +22 -6     viewitem.cpp  
 M  +3 -1      viewitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/view.h #706462:706463
@@ -24,7 +24,7 @@
 {
   Q_OBJECT
 public:
-  enum MouseMode { Default, Move, Create, Resize, Rotate };
+  enum MouseMode { Default, Move, Create, Resize, Scale, Rotate };
   enum CreationEvent {
     MousePress = 0x0,
     MouseRelease =0x1,
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #706462:706463
@@ -89,7 +89,7 @@
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.topLeft(), sizeOfGrip());
   QPainterPath path;
-  if (_mouseMode == Resize)
+  if (_mouseMode == Resize || _mouseMode == Scale)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -104,7 +104,7 @@
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.topRight() - QPoint(sizeOfGrip().width(), 0), sizeOfGrip());
   QPainterPath path;
-  if (_mouseMode == Resize)
+  if (_mouseMode == Resize || _mouseMode == Scale)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -119,7 +119,7 @@
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.bottomRight() - QPoint(sizeOfGrip().width(), sizeOfGrip().height()), sizeOfGrip());
   QPainterPath path;
-  if (_mouseMode == Resize)
+  if (_mouseMode == Resize || _mouseMode == Scale)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -134,7 +134,7 @@
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.bottomLeft() - QPoint(0, sizeOfGrip().height()), sizeOfGrip());
   QPainterPath path;
-  if (_mouseMode == Resize)
+  if (_mouseMode == Resize || _mouseMode == Scale)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -274,6 +274,8 @@
   if (isSelected()) {
     painter->drawPath(shape());
     if (_mouseMode == Resize)
+      painter->fillPath(grips(), Qt::blue);
+    else if (_mouseMode == Scale)
       painter->fillPath(grips(), Qt::black);
     else if (_mouseMode == Rotate)
       painter->fillPath(grips(), Qt::red);
@@ -414,6 +416,9 @@
     } else if (mouseMode() == ViewItem::Resize) {
       parentView()->setMouseMode(View::Resize);
       parentView()->undoStack()->beginMacro(tr("Resize"));
+    } else if (mouseMode() == ViewItem::Scale) {
+      parentView()->setMouseMode(View::Scale);
+      parentView()->undoStack()->beginMacro(tr("Scale"));
     } else if (mouseMode() == ViewItem::Rotate) {
       parentView()->setMouseMode(View::Rotate);
       parentView()->undoStack()->beginMacro(tr("Rotate"));
@@ -431,7 +436,7 @@
 
     rotateTowards(l, p);
 
-  } else if (mouseMode() == ViewItem::Resize) {
+  } else if (mouseMode() == ViewItem::Resize || mouseMode() == ViewItem::Scale) {
 
     switch(_activeGrip) {
     case TopLeftGrip:
@@ -469,7 +474,12 @@
   to.setTopLeft(point);
   from.moveBottomRight(anchor);
   to.moveBottomRight(anchor);
-  transformToRect(from, to);
+
+  if (_mouseMode == Scale) {
+    transformToRect(from, to);
+  } else if (_mouseMode == Resize) {
+    //FIXME;
+  }
 }
 
 
@@ -716,6 +726,9 @@
       setMouseMode(Resize);
       break;
     case Resize:
+      setMouseMode(Scale);
+      break;
+    case Scale:
       setMouseMode(Rotate);
       break;
     default:
@@ -750,6 +763,7 @@
   if (parentView()->mouseMode() == View::Move) {
     _originalPosition = pos();
   } else if (parentView()->mouseMode() == View::Resize ||
+             parentView()->mouseMode() == View::Scale ||
              parentView()->mouseMode() == View::Rotate) {
     _originalTransform = transform();
   } else if (oldMode == View::Move) {
@@ -759,6 +773,8 @@
     new MoveCommand(this, _originalPosition, pos());
   } else if (oldMode == View::Resize) {
     new ResizeCommand(this, _originalTransform, transform());
+  } else if (oldMode == View::Scale) {
+    //new ScaleCommand(this, _originalTransform, transform());
   } else if (oldMode == View::Rotate) {
     new RotateCommand(this, _originalTransform, transform());
   }
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #706462:706463
@@ -29,7 +29,7 @@
 {
   Q_OBJECT
 public:
-  enum MouseMode { Default, Move, Resize, Rotate };
+  enum MouseMode { Default, Move, Resize, Scale, Rotate };
 
   enum ActiveGrip {
     NoGrip, TopLeftGrip, TopRightGrip, BottomRightGrip, BottomLeftGrip,
@@ -100,6 +100,8 @@
   void setBottom(const QPointF &point);
   void setLeft(const QPointF &point);
   void setRight(const QPointF &point);
+
+private:
   QTransform selectTransform() const;
   bool transformToRect(const QRectF &from, const QRectF &to);
   bool transformToRect(const QPolygonF &from, const QPolygonF &to);


More information about the Kst mailing list