[Kst] extragear/graphics/kst/kst

Rick Chern rchern at interchange.ubc.ca
Wed Aug 10 01:25:28 CEST 2005


SVN commit 444383 by rchern:

- no flicker when moving mouse
- no repaint during resizes - use a minimalistic dotted outline (dotted line for lines, dotted ellipse for ellipses, and dotted rectangle for rectangles)

 M  +38 -30    ksttoplevelview.cpp  


--- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #444382:444383
@@ -207,7 +207,7 @@
       _hoverFocus->drawFocusRect(p);
       _hoverFocus = 0L;
     }
-    paint(P_PAINT, p);
+    //paint(P_PAINT, p);
     p.end();
   }
 }
@@ -742,9 +742,7 @@
     p.setRasterOp(Qt::XorROP);
     if (old.topLeft() != QPoint(-1, -1)) {
       p.drawWinFocusRect(old);
-    } else {     
-      p.drawWinFocusRect(_pressTarget->geometry());
-    }
+    } 
     p.drawWinFocusRect(_prevBand);
     p.end();
   }
@@ -772,24 +770,30 @@
 void KstTopLevelView::pressMoveLayoutModeEndPoint(const QPoint& pos, bool shift) {
   // for now we only know how to deal with lines 
   if (KstViewLinePtr line = kst_cast<KstViewLine>(_pressTarget)) {
+    QRect old = _prevBand;
     QPoint fromPoint, toPoint;
-    if (_prevBand.topLeft()== QPoint(-1,-1)) {
-      // use _prevBand to save original line position 
-      _prevBand.setTopLeft(line->from());
-      _prevBand.setBottomRight(line->to()); 
-    }
     if (_pressDirection & UP) {
       // UP means we are on the start endpoint
-      toPoint = _prevBand.bottomRight();
+      toPoint = line->to();
       fromPoint = pos;
     } else if (_pressDirection & DOWN) {
       // DOWN means we are on the end endpoint
-      fromPoint = _prevBand.topLeft();
+      fromPoint = line->from();
       toPoint = pos;
     }
-    line->setFrom(fromPoint);
-    line->setTo(toPoint);
-    paint(P_PAINT);
+    _prevBand.setTopLeft(fromPoint);
+    _prevBand.setBottomRight(toPoint);
+    if (old != _prevBand) {
+      QPainter p;
+      p.begin(_w);
+      p.setPen(QPen(Qt::black, 0, Qt::DotLine));
+      p.setRasterOp(Qt::NotROP);
+      if (old.topLeft() != QPoint(-1, -1)) {
+        p.drawLine(old.topLeft(), old.bottomRight());
+      } 
+      p.drawLine(_prevBand.topLeft(), _prevBand.bottomRight());
+      p.end();
+    }
   }
 }
 
@@ -804,13 +808,12 @@
     QPainter p;
         
     p.begin(_w);
-    p.setRasterOp(Qt::XorROP);
+    p.setPen(QPen(Qt::black, 0, Qt::DotLine));
+    p.setRasterOp(Qt::NotROP);
     if (old.topLeft() != QPoint(-1, -1)) {
-      p.drawWinFocusRect(old);
-    } else {     
-      p.drawWinFocusRect(_pressTarget->geometry());
-    }
-    p.drawWinFocusRect(_prevBand);
+      p.drawEllipse(old);
+    } 
+    p.drawEllipse(_prevBand);
     p.end();
   }
 }
@@ -905,7 +908,21 @@
 
 
 void KstTopLevelView::releasePressLayoutModeEndPoint(const QPoint& pos, bool shift) {
-  _prevBand = QRect(-1, -1, 0, 0);
+  if (KstViewLinePtr line = kst_cast<KstViewLine>(_pressTarget)) {
+    QPoint toPoint, fromPoint;
+    if (_pressDirection & UP) {
+      // UP means we are on the start endpoint
+      toPoint = _prevBand.bottomRight();
+      fromPoint = pos;
+    } else if (_pressDirection & DOWN) {
+      // DOWN means we are on the end endpoint
+      fromPoint = _prevBand.topLeft();
+      toPoint = pos;
+    }    
+    line->setFrom(fromPoint);
+    line->setTo(toPoint);
+    _onGrid = false;
+  }
 }
 
 
@@ -1298,15 +1315,6 @@
   if (_mode == LayoutMode) {
     clearFocus();
     //_pressTarget = 0L;
-    if (_pressTarget) {
-      // undo the endpoint moving
-      KstViewLinePtr line = kst_cast<KstViewLine>(_pressTarget);
-      if (line && _prevBand.topLeft() != QPoint(-1, -1)) {
-        line->setFrom(_prevBand.topLeft());
-        line->setTo(_prevBand.bottomRight());
-        paint(P_PAINT);
-      }  
-    }
     _prevBand = QRect(-1, -1, 0, 0);
     return;
   }


More information about the Kst mailing list