- for (auto &i : items)
- i->paint_label(p, r);
-}
-
-void Ruler::mouseMoveEvent(QMouseEvent *e)
-{
- mouse_point_ = e->pos();
-
- if (!(e->buttons() & Qt::LeftButton))
- return;
-
- if ((e->pos() - mouse_down_point_).manhattanLength() <
- QApplication::startDragDistance())
- return;
-
- // Do the drag
- dragging_ = true;
-
- const int delta = e->pos().x() - mouse_down_point_.x();
- const vector< shared_ptr<TimeItem> > items(view_.time_items());
- for (auto &i : items)
- if (i->dragging())
- i->set_time(view_.offset() +
- (i->drag_point().x() + delta - 0.5) *
- view_.scale());
-}
-
-void Ruler::mousePressEvent(QMouseEvent *e)
-{
- if (e->buttons() & Qt::LeftButton) {
- mouse_down_point_ = e->pos();
-
- mouse_down_item_.reset();
-
- clear_selection();
-
- const vector< shared_ptr<TimeItem> > items(view_.time_items());
- for (auto i = items.rbegin(); i != items.rend(); i++)
- if ((*i)->label_rect(rect()).contains(e->pos())) {
- mouse_down_item_ = (*i);
- break;
- }
-
- if (mouse_down_item_) {
- mouse_down_item_->select();
- mouse_down_item_->drag();
- }
-
- selection_changed();
- }
-}
-
-void Ruler::mouseReleaseEvent(QMouseEvent *)
-{
- using pv::widgets::Popup;
-
- if (!dragging_ && mouse_down_item_) {
- Popup *const p = mouse_down_item_->create_popup(&view_);
- if (p) {
- const QPoint arrpos(mouse_down_item_->get_x(),
- height() - BaselineOffset);
- p->set_position(mapToGlobal(arrpos), Popup::Bottom);
- p->show();
- }
+ for (auto &i : items) {
+ const bool highlight = !item_dragging_ &&
+ i->label_rect(r).contains(mouse_point_);
+ i->paint_label(p, r, highlight);