return QRectF(QPointF(x - label_size.width() / 2, top), label_size);
}
-QRectF TimeMarker::hit_box_rect(const QRectF &rect) const
+QRectF TimeMarker::hit_box_rect(const ViewItemPaintParams &pp) const
{
const float x = get_x();
const float h = QFontMetrics(QApplication::font()).height();
- return QRectF(x - h / 2.0f, rect.top(), h, rect.height());
+ return QRectF(x - h / 2.0f, pp.top(), h, pp.height());
}
void TimeMarker::paint_label(QPainter &p, const QRect &rect, bool hover)
* @param rect the rectangle of the viewport area.
* @return Returns the rectangle of the hit-box.
*/
- QRectF hit_box_rect(const QRectF &rect) const;
+ QRectF hit_box_rect(const ViewItemPaintParams &pp) const;
/**
* Gets the text to show in the marker.
label_size.height());
}
-QRectF Trace::hit_box_rect(const QRectF &rect) const
+QRectF Trace::hit_box_rect(const ViewItemPaintParams &pp) const
{
const float h = QFontMetrics(QApplication::font()).height();
- return QRectF(rect.left(), get_visual_y() - h / 2.0f,
- rect.width(), h);
+ return QRectF(pp.left(), get_visual_y() - h / 2.0f,
+ pp.width(), h);
}
void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)
* @param rect the rectangle of the viewport area.
* @return Returns the rectangle of the hit-box.
*/
- QRectF hit_box_rect(const QRectF &rect) const;
+ QRectF hit_box_rect(const ViewItemPaintParams &pp) const;
/**
* Paints the signal label.
return QRectF();
}
-QRectF ViewItem::hit_box_rect(const QRectF &rect) const
+QRectF ViewItem::hit_box_rect(const ViewItemPaintParams &pp) const
{
- (void)rect;
+ (void)pp;
return QRectF();
}
* @return Returns the rectangle of the hit-box.
* @remarks The default implementation returns an empty hit-box.
*/
- virtual QRectF hit_box_rect(const QRectF &rect) const;
+ virtual QRectF hit_box_rect(const ViewItemPaintParams &pp) const;
/**
* Paints the signal label.
shared_ptr<ViewItem> Viewport::get_mouse_over_item(const QPoint &pt)
{
+ const ViewItemPaintParams pp(rect(), view_.scale(), view_.offset());
const vector< shared_ptr<ViewItem> > items(this->items());
for (auto i = items.rbegin(); i != items.rend(); i++)
if ((*i)->enabled() &&
- (*i)->hit_box_rect(rect()).contains(pt))
+ (*i)->hit_box_rect(pp).contains(pt))
return *i;
return nullptr;
}