X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fviewwidget.cpp;h=499471b91001bf3488d4b893cac0591548b7ad07;hp=e20be24febd3cab49ddc0c20bfdf67eb75014de5;hb=a47b5a3fb9912f1d6e3fcc63d59ee6cc1b5338e2;hpb=4eba9990f617cba59193c7df8e6359ea642ccb27 diff --git a/pv/views/trace/viewwidget.cpp b/pv/views/trace/viewwidget.cpp index e20be24f..499471b9 100644 --- a/pv/views/trace/viewwidget.cpp +++ b/pv/views/trace/viewwidget.cpp @@ -253,10 +253,11 @@ void ViewWidget::mousePressEvent(QMouseEvent *event) assert(event); if (event->button() & Qt::LeftButton) { - if (event->modifiers() & Qt::ShiftModifier) - view_.show_cursors(false); + if (event->modifiers() & Qt::ShiftModifier) + view_.show_cursors(false); + mouse_down_point_ = event->pos(); - mouse_down_offset_ = view_.offset() + event->pos().x() * view_.scale(); + mouse_down_offset_ = view_.offset() + event->pos().x() * view_.scale(); mouse_down_item_ = get_mouse_over_item(event->pos()); mouse_left_press_event(event); } @@ -288,38 +289,38 @@ void ViewWidget::mouseMoveEvent(QMouseEvent *event) assert(event); mouse_point_ = event->pos(); - if (!event->buttons()) { + if (!event->buttons()) item_hover(get_mouse_over_item(event->pos()), event->pos()); - } else if (event->buttons() & Qt::LeftButton) { - - if (event->modifiers() & Qt::ShiftModifier) { // Cursor drag - pv::util::Timestamp current_offset = view_.offset() + event->pos().x() * view_.scale(); + if (event->buttons() & Qt::LeftButton) { + if (event->modifiers() & Qt::ShiftModifier) { + // Cursor drag + pv::util::Timestamp current_offset = view_.offset() + event->pos().x() * view_.scale(); - // TODO: Is startDragDistance the right constant here? - if (qAbs(current_offset - mouse_down_offset_)/view_.scale() > QApplication::startDragDistance()) { - view_.show_cursors(true); - view_.set_cursors(mouse_down_offset_, current_offset); + const int drag_distance = qAbs(current_offset.convert_to() - + mouse_down_offset_.convert_to()) / view_.scale(); - } else { - view_.show_cursors(false); - } + if (drag_distance > QApplication::startDragDistance()) { + view_.show_cursors(true); + view_.set_cursors(mouse_down_offset_, current_offset); + } else + view_.show_cursors(false); - } else { - if (!item_dragging_) { - if ((event->pos() - mouse_down_point_).manhattanLength() < - QApplication::startDragDistance()) - return; + } else { + if (!item_dragging_) { + if ((event->pos() - mouse_down_point_).manhattanLength() < + QApplication::startDragDistance()) + return; - if (!accept_drag()) - return; + if (!accept_drag()) + return; - item_dragging_ = true; - } + item_dragging_ = true; + } - // Do the drag - drag_items(event->pos() - mouse_down_point_); - } + // Do the drag + drag_items(event->pos() - mouse_down_point_); + } } }