[Digikam-devel] [Bug 103645] zoom in with rectangle tool selection

Gilles Caulier caulier.gilles at gmail.com
Tue Mar 20 09:36:19 GMT 2007


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=103645         
caulier.gilles gmail com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From caulier.gilles gmail com  2007-03-20 10:36 -------
SVN commit 644517 by cgilles:

digikam from trunk : if an image selection is set in canvas when user process a zoom, we will use the center and size of selection to focus automaticly canvas content.
BUG: 103645

 M  +26 -3     canvas.cpp  


--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/canvas.cpp #644516:644517
 @ -839,10 +839,33  @
     if (d->autoZoom)
         return;
 
-    float cpx = (contentsX() + visibleWidth()  / 2.0) / d->zoom; 
-    float cpy = (contentsY() + visibleHeight() / 2.0) / d->zoom; 
+    float cpx, cpy;
+    int   xSel, ySel, wSel, hSel;
+    d->im->getSelectedArea(xSel, ySel, wSel, hSel);
+    
+    if (!wSel && !hSel )   
+    {   
+        // No current selection, zoom using center of canvas 
+        // and given zoom factor.
+        cpx = (contentsX() + visibleWidth()  / 2.0) / d->zoom; 
+        cpy = (contentsY() + visibleHeight() / 2.0) / d->zoom;
+        d->zoom = zoom;
+    }
+    else           
+    {
+        // If selected area, use center of selection
+        // and recompute zoom factor accordinly.
+        cpx = xSel + wSel / 2.0; 
+        cpy = ySel + hSel / 2.0;
 
-    d->zoom = zoom;
+        double srcWidth  = wSel;
+        double srcHeight = hSel;
+        double dstWidth  = contentsRect().width();
+        double dstHeight = contentsRect().height();
+    
+        d->zoom = QMIN(dstWidth/srcWidth, dstHeight/srcHeight);
+    } 
+
     d->im->zoom(d->zoom);
     updateContentsSize();



More information about the Digikam-devel mailing list