[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r1598: Respond to double-clicks on the map. Double left-click zooms (trunk/src/gui/network)



Author: edmanm
Date: 2007-01-19 22:19:56 -0500 (Fri, 19 Jan 2007)
New Revision: 1598

Modified:
   trunk/src/gui/network/zimageview.cpp
   trunk/src/gui/network/zimageview.h
Log:
Respond to double-clicks on the map. Double left-click zooms in towards the
mouse pointer and double right-click zooms out. Also a couple minor cleanups.


Modified: trunk/src/gui/network/zimageview.cpp
===================================================================
--- trunk/src/gui/network/zimageview.cpp	2007-01-19 02:55:01 UTC (rev 1597)
+++ trunk/src/gui/network/zimageview.cpp	2007-01-20 03:19:56 UTC (rev 1598)
@@ -318,7 +318,7 @@
 
 /** Responds to the user pressing a mouse button. */
 void
-ZImageView::mousePressEvent(QMouseEvent* e)
+ZImageView::mousePressEvent(QMouseEvent *e)
 {
   e->accept();
   setCursor(CURSOR_MOUSE_PRESS);
@@ -327,7 +327,8 @@
 }
 
 /** Responds to the user releasing a mouse button. */
-void ZImageView::mouseReleaseEvent(QMouseEvent* e)
+void 
+ZImageView::mouseReleaseEvent(QMouseEvent *e)
 {
   e->accept();
   setCursor(CURSOR_NORMAL);
@@ -335,9 +336,30 @@
   resetZoomPoint();
 }
 
+/** Responds to the user double-clicking a mouse button on the image. A left
+ * double-click zooms in on the image and a right double-click zooms out.
+ * Zooming is centered on the location of the double-click. */
+void
+ZImageView::mouseDoubleClickEvent(QMouseEvent *e)
+{
+  e->accept();
+  
+  QPoint center = rect().center(); 
+  int dx = e->x() - center.x();
+  int dy = e->y() - center.y();
+  updateViewport(dx, dy);
+  resetZoomPoint();
+
+  Qt::MouseButton btn = e->button();
+  if (btn == Qt::LeftButton)
+    zoomIn();
+  else if (btn == Qt::RightButton)
+    zoomOut();
+}
+
 /** Responds to the user moving the mouse. */
 void
-ZImageView::mouseMoveEvent(QMouseEvent* e)
+ZImageView::mouseMoveEvent(QMouseEvent *e)
 {
   e->accept();
   int dx = _mouseX - e->x();

Modified: trunk/src/gui/network/zimageview.h
===================================================================
--- trunk/src/gui/network/zimageview.h	2007-01-19 02:55:01 UTC (rev 1597)
+++ trunk/src/gui/network/zimageview.h	2007-01-20 03:19:56 UTC (rev 1598)
@@ -67,7 +67,9 @@
   virtual void mouseReleaseEvent(QMouseEvent* e);
   /** Handles the user moving the mouse. */
   virtual void mouseMoveEvent(QMouseEvent* e);
-  
+  /** Handles the user double-clicking a mouse button. */
+  virtual void mouseDoubleClickEvent(QMouseEvent *e);
+
   /** Update the viewport.  This will set _view to a region that,
    *  when copied from the image and scaled to the screen size, will
    *  show what is expected.  The _view may be larger in one or more