]> sigrok.org Git - pulseview.git/blobdiff - pv/view/cursorheader.cpp
CursorHeader: Hit test time items from front to back
[pulseview.git] / pv / view / cursorheader.cpp
index f79a5785d558f56b54a60b37605614d08f9b16c9..fbc6e2e791d53eccf26140896fae83291f607714 100644 (file)
@@ -100,7 +100,8 @@ void CursorHeader::mouseMoveEvent(QMouseEvent *e)
        for (auto &i : items)
                if (i->dragging())
                        i->set_time(view_.offset() +
-                               (i->drag_point().x() + delta) * view_.scale());
+                               (i->drag_point().x() + delta - 0.5) *
+                               view_.scale());
 }
 
 void CursorHeader::mousePressEvent(QMouseEvent *e)
@@ -113,9 +114,9 @@ void CursorHeader::mousePressEvent(QMouseEvent *e)
                clear_selection();
 
                const vector< shared_ptr<TimeItem> > items(view_.time_items());
-               for (auto &i : items)
-                       if (i && i->label_rect(rect()).contains(e->pos())) {
-                               mouse_down_item_ = i;
+               for (auto i = items.rbegin(); i != items.rend(); i++)
+                       if ((*i)->label_rect(rect()).contains(e->pos())) {
+                               mouse_down_item_ = (*i);
                                break;
                        }
 
@@ -156,5 +157,10 @@ void CursorHeader::leaveEvent(QEvent*)
        update();
 }
 
+void CursorHeader::mouseDoubleClickEvent(QMouseEvent *e)
+{
+       view_.add_flag(view_.offset() + ((double)e->x() + 0.5) * view_.scale());
+}
+
 } // namespace view
 } // namespace pv