[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kivio
From:       Peter Simonsson <psn () linux ! se>
Date:       2006-01-01 13:56:41
Message-ID: 1136123801.526151.30703.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 493096 by psn:

Add more automatic guidelines and make guidelines snap to the middle of a stencil


 M  +30 -2     kiviopart/kivio_canvas.cpp  
 M  +23 -8     plugins/kivioselecttool/tool_select.cpp  


--- trunk/koffice/kivio/kiviopart/kivio_canvas.cpp #493095:493096
@@ -619,6 +619,17 @@
     m_pDragStencil->setY(qp.y() - m_pDragStencil->h());
   }
 
+  qp.setCoords(orig.x() + (m_pDragStencil->w() / 2.0), orig.y() + (m_pDragStencil->h() / 2.0));
+  qp = snapToGuides(qp, snappedX, snappedY);
+
+  if(snappedX) {
+    m_pDragStencil->setX(qp.x() - (m_pDragStencil->w() / 2.0));
+  }
+
+  if(snappedY) {
+    m_pDragStencil->setY(qp.y() - (m_pDragStencil->h() / 2.0));
+  }
+
   qp.setCoords(orig.x(), orig.y());
   qp = snapToGuides(qp, snappedX, snappedY);
 
@@ -1156,6 +1167,17 @@
     newY = p.y() - selectedRect.height();
   }
 
+  p.setCoords(selectedRect.x() + dx + (selectedRect.width() / 2.0), selectedRect.y() + dy + (selectedRect.height() / 2.0));
+  p = snapToGuides(p, snappedX, snappedY);
+
+  if(snappedX) {
+    newX = p.x() - (selectedRect.width() / 2.0);
+  }
+
+  if(snappedY) {
+    newY = p.y() - (selectedRect.height() / 2.0);
+  }
+
   p.setCoords(selectedRect.x() + dx, selectedRect.y() + dy);
   p = snapToGuides(p, snappedX, snappedY);
 
@@ -1242,13 +1264,19 @@
         ++stencilIt;
 
         if(!stencil->isSelected()) {
-          hGuideLines << stencil->y() << (stencil->y() + stencil->h());
-          vGuideLines << stencil->x() << (stencil->x() + stencil->w());
+          hGuideLines << stencil->y() << (stencil->y() + (stencil->h() / 2.0)) << (stencil->y() + stencil->h());
+          vGuideLines << stencil->x() << (stencil->x() + (stencil->w() / 2.0)) << (stencil->x() + stencil->w());
         }
       }
     }
   }
 
+  KoPageLayout pl = activePage()->paperLayout();
+
+  // Add the middle of the page and the margins
+  hGuideLines << (pl.ptHeight / 2.0) << pl.ptTop << pl.ptBottom;
+  vGuideLines << (pl.ptWidth / 2.0) << pl.ptLeft << pl.ptRight;
+
   guideLines().setAutoGuideLines(hGuideLines, vGuideLines);
 }
 
--- trunk/koffice/kivio/plugins/kivioselecttool/tool_select.cpp #493095:493096
@@ -523,31 +523,46 @@
   if(!ignoreGridGuides) {
     // First attempt a snap-to-grid
     p.setCoords(newX, newY);
-    
+
     p = canvas->snapToGrid(p);
-  
+
     newX = p.x();
     newY = p.y();
-  
+
     // Now the guides override the grid so we attempt to snap to them
+    // The bottom
     p.setCoords(m_selectedRect.x() + dx + m_selectedRect.width(), m_selectedRect.y() + dy + m_selectedRect.height());
     p = canvas->snapToGuides(p, snappedX, snappedY);
-  
+
     if(snappedX) {
       newX = p.x() - m_selectedRect.width();
     }
-  
+
     if(snappedY) {
       newY = p.y() - m_selectedRect.height();
     }
-  
+
+    // The middle
+    p.setCoords(m_selectedRect.x() + dx + (m_selectedRect.width() / 2.0),
+                m_selectedRect.y() + dy + (m_selectedRect.height() / 2.0));
+    p = canvas->snapToGuides(p, snappedX, snappedY);
+
+    if(snappedX) {
+      newX = p.x() - (m_selectedRect.width() / 2.0);
+    }
+
+    if(snappedY) {
+      newY = p.y() - (m_selectedRect.height() / 2.0);
+    }
+
+    // The top
     p.setCoords(m_selectedRect.x() + dx, m_selectedRect.y() + dy);
     p = canvas->snapToGuides(p, snappedX, snappedY);
-  
+
     if(snappedX) {
       newX = p.x();
     }
-  
+
     if(snappedY) {
       newY = p.y();
     }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic