]> sigrok.org Git - pulseview.git/commitdiff
Viewport: Use fabs instead of branch
authorJoel Holdsworth <redacted>
Sun, 28 Dec 2014 21:00:33 +0000 (21:00 +0000)
committerJoel Holdsworth <redacted>
Mon, 29 Dec 2014 12:24:23 +0000 (12:24 +0000)
pv/view/viewport.cpp

index 971eb755228f978a1355677adbfb9d6f5668615d..0e89f3ad96fc6b983d3ed1d9d8fe2cb495e59f2b 100644 (file)
@@ -92,9 +92,8 @@ bool Viewport::touch_event(QTouchEvent *event)
 
        double w = touchPoint1.pos().x() - touchPoint0.pos().x();
        if (abs(w) >= 1.0) {
-               double scale = (pinch_offset1_ - pinch_offset0_) / w;
-               if (scale < 0)
-                       scale = -scale;
+               const double scale =
+                       fabs((pinch_offset1_ - pinch_offset0_) / w);
                double offset = pinch_offset0_ - touchPoint0.pos().x() * scale;
                if (scale > 0)
                        view_.set_scale_offset(scale, offset);