[Kst] extragear/graphics/kst/kst

Rick Chern rchern at interchange.ubc.ca
Tue Aug 9 23:53:37 CEST 2005


SVN commit 444367 by rchern:

- crosshair cursor for line endpoints
- make hotpoint areas actually match the displayed hotpoint

 M  +28 -107   ksttoplevelview.cpp  
 M  +0 -3      ksttoplevelview.h  
 M  +24 -0     kstviewellipse.cpp  
 M  +3 -0      kstviewellipse.h  
 M  +9 -4      kstviewobject.cpp  


--- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #444366:444367
@@ -226,7 +226,7 @@
   
   //TODO: make this work better with click-select mode
   
-  KstViewObjectPtr p = findChildOfModeType(pos, true);
+  KstViewObjectPtr p = findChild(pos, false);
   if (p) {
     setCursorFor(pos, p);
     if (p->focused()) {
@@ -295,28 +295,32 @@
   // cursor directions are the same for centred resize
   direction = direction & ~CENTREDRESIZE;
   
-  switch (direction) {
-    case UP:
-    case DOWN:
-      _cursor.setShape(Qt::SizeVerCursor);
-      break;
-    case LEFT:
-    case RIGHT:
-      _cursor.setShape(Qt::SizeHorCursor);
-      break;
-    case UP|LEFT:
-    case DOWN|RIGHT:
-      _cursor.setShape(Qt::SizeFDiagCursor);
-      break;
-    case UP|RIGHT:
-    case DOWN|LEFT:
-      _cursor.setShape(Qt::SizeBDiagCursor);
-      break;
-    default:
-      _cursor.setShape(Qt::SizeAllCursor);
-      break;
+  if (direction & ENDPOINT) {
+    _cursor.setShape(Qt::CrossCursor);  
+  } else {
+    switch (direction) {
+      case UP:
+      case DOWN:
+        _cursor.setShape(Qt::SizeVerCursor);
+        break;
+      case LEFT:
+      case RIGHT:
+        _cursor.setShape(Qt::SizeHorCursor);
+        break;
+      case UP|LEFT:
+      case DOWN|RIGHT:
+        _cursor.setShape(Qt::SizeFDiagCursor);
+        break;
+      case UP|RIGHT:
+      case DOWN|LEFT:
+        _cursor.setShape(Qt::SizeBDiagCursor);
+        break;
+      default:
+        _cursor.setShape(Qt::SizeAllCursor);
+        break;
+    }
   }
-
+  
   if (_cursor.shape() != _w->cursor().shape()) {
     _w->setCursor(_cursor);
   }
@@ -344,7 +348,7 @@
   _pressDirection = -1;
 
   // find target first - if it's found, pretend we're in layout mode
-  _pressTarget = findChildOfModeType(pos, true);
+  _pressTarget = findChild(pos, false);
   
   if (_mode != LayoutMode && !_pressTarget) {
     _pressTarget = 0L;
@@ -811,90 +815,7 @@
   }
 }
 
-KstViewObjectPtr KstTopLevelView::findChildOfModeType(const QPoint& pos, bool borderForTransparent) {
-  // just like KstViewObject::findChild except this only finds children of the current 
-  // viewmode type
-  KstViewObjectPtr obj;
-  
-  if (!_geom.contains(pos) || _children.isEmpty()) {
-    return obj;  
-  }
-  
-  KstViewObjectList::Iterator i = _children.end();
-  for (--i; ; --i) {
-    // if the mouse is on top of this child
-    if ((*i)->geometry().contains(pos)) {
-      // see if we care about this child
-      bool care = false;
-      switch (_mode) {
-        case LayoutMode:
-          care = true;
-          break;
-        case GfxLineMode:
-          if (kst_cast<KstViewLine>(*i)) {
-            care = true;  
-          }
-          break;
-        case GfxRectangleMode:
-          if (kst_cast<KstViewBox>(*i)) {
-            care = true;  
-          }
-          break;
-        case GfxTextMode:
-          if (kst_cast<KstViewLabel>(*i)) {
-            care = true;  
-          }
-          break;
-        case GfxArrowMode:
-          if (kst_cast<KstViewArrow>(*i)) {
-            care = true;  
-          }
-          break;
-        case GfxEllipseMode:
-          if (kst_cast<KstViewEllipse>(*i)) {
-            care = true;  
-          }
-          break;
-        case GfxPictureMode:
-          if (kst_cast<KstViewPicture>(*i)) {
-            care = true;  
-          }
-          break;
-        default:
-          break;
-      }
-      if (care) {
-        if ((*i)->maximized()) {
-          obj = *i;
-          break;
-        }
-        if (!obj) {
-          if ((*i)->transparent()) {
-            if ((*i)->clipRegion().contains(pos)) {
-              obj = *i;
-            } else if (borderForTransparent && (*i)->geometry().contains(pos)) {
-              QRect g = (*i)->geometry();
-              if ((pos.x() >= g.left() && pos.x() <= g.left() + KST_RESIZE_BORDER_W) ||
-                   (pos.x() <= g.right() && pos.x() >= g.right() - KST_RESIZE_BORDER_W) ||
-                   (pos.y() >= g.top() && pos.y() <= g.top() + KST_RESIZE_BORDER_W) ||
-                   (pos.y() <= g.bottom() && pos.y() >= g.bottom() - KST_RESIZE_BORDER_W)) {
-                obj = *i;
-                   }
-            }
-          } else {
-            obj = *i;
-          }
-        }
-      }  
-    }
-    if (i == _children.begin()) {
-      break;
-    }
-  }
-  return obj;
-}
 
-
 void KstTopLevelView::releasePressLayoutMode(const QPoint& pos, bool shift) {
 
   if (_pressTarget) {
@@ -1044,7 +965,7 @@
 bool KstTopLevelView::popupMenu(KPopupMenu *menu, const QPoint& pos) {
   bool rc = false;
   // Want to clear focus without repaint
-  _pressTarget = findChild(pos, true);
+  _pressTarget = findChild(pos, false);
 
   if (_focusOn) {
     _pressDirection = -1;
--- trunk/extragear/graphics/kst/kst/ksttoplevelview.h #444366:444367
@@ -131,9 +131,6 @@
     void releasePressLayoutModeSelect(const QPoint& pos, bool shift = false);
     void releasePressLayoutModeEndPoint(const QPoint& pos, bool shift = false);
     void releasePressLayoutModeCentredResize(const QPoint& pos, bool shift = false);
-    
-    // a special find child that only finds children of the current mode type
-    KstViewObjectPtr findChildOfModeType(const QPoint& pos, bool borderForTransparent = true);
 
     void setCursorFor(const QPoint& pos, KstViewObjectPtr p);
     bool popupMenu(KPopupMenu *menu, const QPoint& pos);
--- trunk/extragear/graphics/kst/kst/kstviewellipse.cpp #444366:444367
@@ -15,6 +15,7 @@
  *                                                                         *
  ***************************************************************************/
 
+#include "kstaccessibility.h" 
 #include "kstviewellipse.h"
 #include <qpainter.h>
 
@@ -111,5 +112,28 @@
 }
 
 
+QRegion KstViewEllipse::clipRegion() {
+  QRegion objRegion = KstViewObject::clipRegion();
+  if (isSelected()) {
+    // include the hotpoints on each corner
+    int dx = KST_RESIZE_BORDER_W/2;
+    int width = 2*dx + 1;
+    objRegion += QRegion(geometry().topLeft().x() - dx, 
+                         geometry().topLeft().y() - dx, 
+                         width, width);
+    objRegion += QRegion(geometry().topRight().x() - dx, 
+                         geometry().topRight().y() - dx, 
+                         width, width);
+    objRegion += QRegion(geometry().bottomRight().x() - dx, 
+                         geometry().bottomRight().y() - dx, 
+                         width, width);
+    objRegion += QRegion(geometry().bottomLeft().x() - dx, 
+                         geometry().bottomLeft().y() - dx, 
+                         width, width);
+  }  
+  return objRegion;
+}
+
+
 #include "kstviewellipse.moc"
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/kstviewellipse.h #444366:444367
@@ -41,6 +41,9 @@
     // can't have Q_PROPERTY in KstViewObject?
     virtual void setForegroundColor(const QColor& color);
     virtual QColor foregroundColor() const;
+    
+    // need to include hotpoints outside of ellipse
+    virtual QRegion clipRegion();
 
   public slots:
     virtual void paint(KstPaintType type, QPainter& p);
--- trunk/extragear/graphics/kst/kst/kstviewobject.cpp #444366:444367
@@ -743,6 +743,10 @@
         }
       }
     }
+    // one last check - hotpoints
+    if (!obj && (*i)->isSelected() && (*i)->directionFor(pos) > 0) {
+      obj = *i;  
+    }
     if (i == _children.begin()) {
       break;
     }
@@ -1512,10 +1516,11 @@
 
 
 bool KstViewObject::pointsCloseEnough(const QPoint& point1, const QPoint& point2) {
-  return (point1.x() <= point2.x() + KST_RESIZE_BORDER_W &&
-      point1.x() >= point2.x() - KST_RESIZE_BORDER_W &&
-      point1.y() <= point2.y() + KST_RESIZE_BORDER_W &&
-      point1.y() >= point2.y() - KST_RESIZE_BORDER_W);
+  int dx = KST_RESIZE_BORDER_W/2;
+  return (point1.x() <= point2.x() + dx &&
+      point1.x() >= point2.x() - dx &&
+      point1.y() <= point2.y() + dx &&
+      point1.y() >= point2.y() - dx);
 }
 
 


More information about the Kst mailing list