[Kst] extragear/graphics/kst

George Staikos staikos at kde.org
Thu Dec 8 04:24:35 CET 2005


SVN commit 486520 by staikos:

Remove flicker by using the same trick used in 2dplot.  It needs to be optimized
though.  Actually all the painting needs to be fixed.


 M  +0 -1      devel-docs/PlotUIFixes  
 M  +12 -3     kst/kstviewbox.cpp  
 M  +14 -4     kst/kstviewellipse.cpp  
 M  +14 -5     kst/kstviewpicture.cpp  


--- trunk/extragear/graphics/kst/devel-docs/PlotUIFixes #486519:486520
@@ -13,5 +13,4 @@
 More bugs:
 - Lines and arrows are clipped
 - Selection points are always clipped even if the object lies below.
-- Flicker!!
 
--- trunk/extragear/graphics/kst/kst/kstviewbox.cpp #486519:486520
@@ -67,7 +67,18 @@
 void KstViewBox::paint(KstPainter& p, const QRegion& bounds) {
   if (p.makingMask()) {
     p.setRasterOp(Qt::SetROP);
+    KstViewObject::paint(p, bounds);
+  } else {
+    QRegion boundary = bounds & _lastClipRegion;
+    KstViewObject::paint(p, bounds);
+    // FIXME: inefficient
+    for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+      boundary -= (*i)->clipRegion();
+    }
+    boundary -= p.uiMask();
+    p.setClipRegion(boundary);
   }
+
   QPen pen(borderColor(), borderWidth());
   pen.setJoinStyle(_cornerStyle);
   if (borderWidth() == 0) {
@@ -86,9 +97,7 @@
   r.setHeight(_geom.height() - borderWidth());
 
   p.drawRoundRect(r, _xRound, _yRound);
-  
-  // do this last so the focus rectangle isn't covered up
-  KstViewObject::paint(p, bounds); // skip over the immediate parent
+  p.setClipping(false); 
 }
 
 
--- trunk/extragear/graphics/kst/kst/kstviewellipse.cpp #486519:486520
@@ -61,7 +61,18 @@
 void KstViewEllipse::paint(KstPainter& p, const QRegion& bounds) {
   if (p.makingMask()) {
     p.setRasterOp(Qt::SetROP);
+    KstViewObject::paint(p, bounds);
+  } else {
+    QRegion boundary = bounds & _lastClipRegion;
+    KstViewObject::paint(p, bounds);
+    // FIXME: inefficient
+    for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+      boundary -= (*i)->clipRegion();
+    }
+    boundary -= p.uiMask();
+    p.setClipRegion(boundary);
   }
+
   QPen pen(_borderColor, _borderWidth);
   p.setPen(pen);
   if (_transparentFill) {
@@ -70,10 +81,9 @@
     p.setBrush(_foregroundColor);
   }
   //p.drawEllipse(geometry());
-  p.drawEllipse(geometry().x()+_borderWidth/2, geometry().y()+_borderWidth/2,
-                geometry().width()-_borderWidth, geometry().height()-_borderWidth);
-
-  KstViewObject::paint(p, bounds);
+  p.drawEllipse(geometry().x() + _borderWidth/2, geometry().y() + _borderWidth/2,
+         geometry().width() - _borderWidth, geometry().height() - _borderWidth);
+  p.setClipping(false); 
 }
 
 
--- trunk/extragear/graphics/kst/kst/kstviewpicture.cpp #486519:486520
@@ -68,10 +68,21 @@
 
 
 void KstViewPicture::paint(KstPainter& p, const QRegion& bounds) {
+  if (p.makingMask()) {
+    p.setRasterOp(Qt::SetROP);
+    KstBorderedViewObject::paint(p, bounds);
+  } else {
+    QRegion boundary = bounds & _lastClipRegion;
+    KstBorderedViewObject::paint(p, bounds);
+    // FIXME: inefficient
+    for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+      boundary -= (*i)->clipRegion();
+    }
+    boundary -= p.uiMask();
+    p.setClipRegion(boundary);
+  }
+
   if (_image.isNull()) {
-    if (p.makingMask()) {
-      p.setRasterOp(Qt::SetROP);
-    }
     QRect r(_geom);
     r.setWidth(_geom.width() - 1);
     r.setHeight(_geom.height() - 1);
@@ -95,7 +106,6 @@
     }
     if (!_iCache.isNull()) {
       if (p.makingMask()) {
-        p.setRasterOp(Qt::OrROP);
         // which indicates clipping / BW mode
         if (_iCache.hasAlphaBuffer()) {
           p.drawImage(contentsRect().topLeft(), _iCache.createAlphaMask());
@@ -108,7 +118,6 @@
       }
     }
   }
-  KstBorderedViewObject::paint(p, bounds);
 }
 
 


More information about the Kst mailing list