]> sigrok.org Git - pulseview.git/commitdiff
Fix Ruler to respect the minimum dragging distance
authorJoel Holdsworth <redacted>
Tue, 1 Oct 2013 16:01:55 +0000 (17:01 +0100)
committerJoel Holdsworth <redacted>
Sun, 13 Oct 2013 10:05:23 +0000 (11:05 +0100)
pv/view/ruler.cpp
pv/view/ruler.h

index 74bc1f979b5ee7b8f04a4643ad8f455bb9d3c1ab..06cd1b1540ba3dca171d2cd286cdc35f66d1fd86 100644 (file)
@@ -50,7 +50,8 @@ const int Ruler::FirstSIPrefixPower = -15;
 const int Ruler::HoverArrowSize = 5;
 
 Ruler::Ruler(View &parent) :
-       MarginWidget(parent)
+       MarginWidget(parent),
+       _dragging(false)
 {
        setMouseTracking(true);
 
@@ -181,6 +182,15 @@ void Ruler::paintEvent(QPaintEvent*)
 
 void Ruler::mouseMoveEvent(QMouseEvent *e)
 {
+       if (!(e->buttons() & Qt::LeftButton))
+               return;
+       
+       if ((e->pos() - _mouse_down_point).manhattanLength() <
+               QApplication::startDragDistance())
+               return;
+
+       _dragging = true;
+
        if (shared_ptr<TimeMarker> m = _grabbed_marker.lock())
                m->set_time(_view.offset() +
                        ((double)e->x() + 0.5) * _view.scale());
@@ -188,7 +198,10 @@ void Ruler::mouseMoveEvent(QMouseEvent *e)
 
 void Ruler::mousePressEvent(QMouseEvent *e)
 {
-       if (e->buttons() & Qt::LeftButton) {
+       if (e->buttons() & Qt::LeftButton)
+       {
+               _mouse_down_point = e->pos();
+
                _grabbed_marker.reset();
 
                clear_selection();
@@ -212,6 +225,7 @@ void Ruler::mousePressEvent(QMouseEvent *e)
 
 void Ruler::mouseReleaseEvent(QMouseEvent *)
 {
+       _dragging = false;
        _grabbed_marker.reset();
 }
 
@@ -219,7 +233,7 @@ void Ruler::draw_hover_mark(QPainter &p)
 {
        const int x = _view.hover_point().x();
 
-       if (x == -1 || !_grabbed_marker.expired())
+       if (x == -1 || _dragging)
                return;
 
        p.setPen(QPen(Qt::NoPen));
index 7514aeca86672d849f82019b1c257232f6afba16..6f77cb4d9aa89e9f7463966bc92227a26f1b2f08 100644 (file)
@@ -70,6 +70,8 @@ private slots:
 
 private:
        boost::weak_ptr<TimeMarker> _grabbed_marker;
+       QPoint _mouse_down_point;
+       bool _dragging;
 };
 
 } // namespace view