const QSizeF label_size(text_size + LabelPadding * 2);
const float top = rect.height() - label_size.height() -
TimeMarker::ArrowSize - 0.5f;
- const float x = (time_ - view_.offset()) / view_.scale();
+ const float x = get_x();
return QRectF(QPointF(x - label_size.width() / 2, top), label_size);
}
+QRectF TimeMarker::hit_box_rect(const QRectF &rect) const
+{
+ const float x = get_x();
+ const float h = QFontMetrics(QApplication::font()).height();
+ return QRectF(x - h / 2.0f, rect.top(), h, rect.height());
+}
+
void TimeMarker::paint_label(QPainter &p, const QRect &rect, bool hover)
{
if (!enabled())
*/
QRectF label_rect(const QRectF &rect) const;
+ /**
+ * Computes the outline rectangle of the viewport hit-box.
+ * @param rect the rectangle of the viewport area.
+ * @return Returns the rectangle of the hit-box.
+ */
+ QRectF hit_box_rect(const QRectF &rect) const;
+
/**
* Gets the text to show in the marker.
*/
label_size.height());
}
+QRectF Trace::hit_box_rect(const QRectF &rect) const
+{
+ const float h = QFontMetrics(QApplication::font()).height();
+ return QRectF(rect.left(), get_visual_y() - h / 2.0f,
+ rect.width(), h);
+}
+
void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)
{
p.setPen(AxisPen);
*/
void set_colour(QColor colour);
+ /**
+ * Computes the outline rectangle of the viewport hit-box.
+ * @param rect the rectangle of the viewport area.
+ * @return Returns the rectangle of the hit-box.
+ */
+ QRectF hit_box_rect(const QRectF &rect) const;
+
/**
* Paints the signal label.
* @param p the QPainter to paint into.
drag_point_ = QPoint(INT_MIN, INT_MIN);
}
+QRectF ViewItem::hit_box_rect(const QRectF &rect) const
+{
+ (void)rect;
+ return QRectF();
+}
+
QMenu* ViewItem::create_context_menu(QWidget *parent)
{
context_parent_ = parent;
*/
virtual QRectF label_rect(const QRectF &rect) const = 0;
+ /**
+ * Computes the outline rectangle of the viewport hit-box.
+ * @param rect the rectangle of the viewport area.
+ * @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;
+
/**
* Paints the signal label.
* @param p the QPainter to paint into.