Bug 149615 - Problem when switching between mouse zoom modes using shortcuts
Summary: Problem when switching between mouse zoom modes using shortcuts
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.4.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-06 22:44 UTC by Andrew Walker
Modified: 2007-09-10 20:52 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2007-09-06 22:44:33 UTC
Version:           1.4.0 (using KDE KDE 3.5.1)
Installed from:    Compiled From Sources0
OS:                Linux

PROBLEM:
There are several inconsistencies in the cursor and lines displayed when switching between mouse zoom modes.
As they are all presumably related I'll describe them all in the the bug report.

* Select X mouse zoom from toolbar
Hit shift to switch to Y mouse zoom
Release shift
Cursor is drawn correctly but no guideline is drawn

* Select Y mouse zoom from toolbar
Hit ctrl to switch to X mouse zoom
Release ctrl
Cursor is drawn correctly but no guideline is drawn

* Select XY mouse zoom from toolbar
Start a zoom operation by clicking and dragging (but not releasing)
Hit ctrl or shift and the corresponding guideline is drawn, but shouldn't be

* Same problem as above for X or Y mouse zoom selected from toolbar

* Select X or Y mouse zoom from toolbar
Hit 'm' in plot to zoom out
Guideline is not drawn but should be
Comment 1 Andrew Walker 2007-09-10 20:52:40 UTC
SVN commit 710735 by arwalker:

BUG:149615 Clean up several problems with the zoom modes and guideline display

 M  +71 -44    kst2dplot.cpp  


--- branches/work/kst/1.5/kst/src/libkstapp/kst2dplot.cpp #710734:710735
@@ -2562,7 +2562,7 @@
         }
       }
     }
-    
+
     KstMouseModeType gzType = globalZoomType();
     if (view && GetPlotRegion().contains(_mouse.tracker)) {
       if (gzType == X_ZOOMBOX || gzType == Y_ZOOMBOX) {
@@ -2570,10 +2570,10 @@
       } else if (gzType == XY_ZOOMBOX) {
         updateXYGuideline(view, QPoint(-1, -1), view->mapFromGlobal(QCursor::pos()), GetPlotRegion(), _mouse.mode);
       } else {
-        _mouse.lastGuideline = QPoint(-1, -1);        
+        _mouse.lastGuideline = QPoint(-1, -1);
       }
     } else {
-      _mouse.lastGuideline = QPoint(-1, -1);        
+      _mouse.lastGuideline = QPoint(-1, -1);
     }
   }
 }
@@ -4263,15 +4263,30 @@
   QRect pr = GetPlotRegion();
 
   KstMouseModeType gzType = globalZoomType();
-  // Draw a helper guide in X or Y zoom modes
+
+  //
+  // draw a helper guide in X or Y zoom modes
+  //
   if (gzType == X_ZOOMBOX || gzType == Y_ZOOMBOX) {
     ButtonState s = e->stateAfter();
     if (s == 0) {
-      updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, gzType);
+      if (e->state() & Qt::LeftButton && _mouse.zooming()) {
+        updateXYGuideline(view, _mouse.lastGuideline, QPoint(-1, -1), pr, gzType);
+      } else {
+        updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, gzType);
+      }
     } else if (s & Qt::ShiftButton) {
-      updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, Y_ZOOMBOX);
+      if (e->state() & Qt::LeftButton && _mouse.zooming()) {
+        updateXYGuideline(view, _mouse.lastGuideline, QPoint(-1, -1), pr, Y_ZOOMBOX);
+      } else {
+        updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, Y_ZOOMBOX);
+      }
     } else if (s & Qt::ControlButton) {
-      updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, X_ZOOMBOX);
+      if (e->state() & Qt::LeftButton && _mouse.zooming()) {
+        updateXYGuideline(view, _mouse.lastGuideline, QPoint(-1, -1), pr, X_ZOOMBOX);
+      } else {
+        updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, pr, X_ZOOMBOX);
+      }
     } else {
       updateXYGuideline(view, _mouse.lastGuideline, QPoint(-1, -1), pr, gzType);
     }
@@ -4322,6 +4337,7 @@
   }
 
   int x, y;
+
   if (_mouse.mode == XY_ZOOMBOX) {
     if (e->x() > pr.right()) {
       x = pr.right() + 1;
@@ -4686,44 +4702,44 @@
   int x = _mouse.pressLocation.x();
   int y = _mouse.pressLocation.y();
 
-  if (newType == Y_ZOOMBOX) {
-    if (c.y() > pr.bottom()) {
-      y = pr.bottom() + 1;
-    } else if (c.y() < pr.top()) {
-      y = pr.top();
+  if (_mouse.zooming()) {
+    if (newType == Y_ZOOMBOX) {
+      if (c.y() > pr.bottom()) {
+        y = pr.bottom() + 1;
+      } else if (c.y() < pr.top()) {
+        y = pr.top();
+      } else {
+        y = c.y();
+      }
+    } else if (newType == X_ZOOMBOX) {
+      if (c.x() > pr.right()) {
+        x = pr.right() + 1;
+      } else if (c.x() < pr.left()) {
+        x = pr.left();
+      } else {
+        x = c.x();
+      }
     } else {
-      y = c.y();
-    }
-  } else if (newType == X_ZOOMBOX) {
-    if (c.x() > pr.right()) {
-      x = pr.right() + 1;
-    } else if (c.x() < pr.left()) {
-      x = pr.left();
-    } else {
-      x = c.x();
-    }
-  } else {
-    if (c.x() > pr.right()) {
-      x = pr.right() + 1;
-    } else if (c.x() < pr.left()) {
-      x = pr.left();
-    } else {
-      x = c.x();
-    }
+      if (c.x() > pr.right()) {
+        x = pr.right() + 1;
+      } else if (c.x() < pr.left()) {
+        x = pr.left();
+      } else {
+        x = c.x();
+      }
 
-    if (c.y() > pr.bottom()) {
-      y = pr.bottom() + 1;
-    } else if (c.y() < pr.top()) {
-      y = pr.top();
-    } else {
-      y = c.y();
+      if (c.y() > pr.bottom()) {
+        y = pr.bottom() + 1;
+      } else if (c.y() < pr.top()) {
+        y = pr.top();
+      } else {
+        y = c.y();
+      }
     }
-  }
 
-  if (_mouse.zooming()) {
     QPoint newp(x, y);
-    QPainter p(view); // FIXME: Broken, just prepare and then trigger a
-                      //  view->paint(GetPlotRegion());
+    QPainter p(view);
+
     p.setRasterOp(Qt::NotROP);
     if (_mouse.rectBigEnough()) {
       p.drawWinFocusRect(_mouse.mouseRect());
@@ -4742,6 +4758,13 @@
   }
 
   setCursorForMode(view, newType, c);
+
+  if (newType == X_ZOOMBOX) {
+    updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, GetPlotRegion(), X_ZOOMBOX);
+  } else if (newType == Y_ZOOMBOX) {
+    updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, GetPlotRegion(), Y_ZOOMBOX);
+  }
+
   e->accept();
 }
 
@@ -5480,13 +5503,17 @@
       }
       break;
     case Key_Shift:
-      updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, GetPlotRegion(), Y_ZOOMBOX);
-      setCursorForMode(view, Y_ZOOMBOX, _mouse.tracker);
+      if (!_mouse.zooming()) {
+        updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, GetPlotRegion(), Y_ZOOMBOX);
+        setCursorForMode(view, Y_ZOOMBOX, _mouse.tracker);
+      }
       paint = false;
       break;
     case Key_Control:
-      updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, GetPlotRegion(), X_ZOOMBOX);
-      setCursorForMode(view, X_ZOOMBOX, _mouse.tracker);
+      if (!_mouse.zooming()) {
+        updateXYGuideline(view, _mouse.lastGuideline, _mouse.tracker, GetPlotRegion(), X_ZOOMBOX);
+        setCursorForMode(view, X_ZOOMBOX, _mouse.tracker);
+      }
       paint = false;
       break;
     default: