]> sigrok.org Git - pulseview.git/commitdiff
ViewItem: Make hit_box_rect take ViewItemPaintParams
authorJoel Holdsworth <redacted>
Mon, 7 Sep 2015 02:29:31 +0000 (20:29 -0600)
committerJoel Holdsworth <redacted>
Sun, 18 Oct 2015 21:32:30 +0000 (15:32 -0600)
pv/view/timemarker.cpp
pv/view/timemarker.hpp
pv/view/trace.cpp
pv/view/trace.hpp
pv/view/viewitem.cpp
pv/view/viewitem.hpp
pv/view/viewport.cpp

index 8c136a18189285e3a965af58e49ad0642f002b87..b5662e4b6ba32e3ec6b90945f11799cf68cc59ce 100644 (file)
@@ -95,11 +95,11 @@ QRectF TimeMarker::label_rect(const QRectF &rect) const
        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)
index 371b6e4a54ce607edbdfd7dc3ead53c55e9ae447..1116eb460d3193987931d6b762cf6a8a229782c3 100644 (file)
@@ -88,7 +88,7 @@ public:
         * @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.
index 729b0b4c1588ff6ae93cc5c152dbdcd2e46994cc..2e15ca958a1da81af2ebba507328da0b9cb801b6 100644 (file)
@@ -163,11 +163,11 @@ QRectF Trace::label_rect(const QRectF &rect) const
                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)
index 8c99191790e6aa7e6c783a0c0b5d9a95f678c19d..677f366b477f7b1caaaae3bfb03a523ff3a51a0d 100644 (file)
@@ -78,7 +78,7 @@ public:
         * @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.
index 6ad6f6b64fbb515eb3426e13d3806754e8f862cc..a63d4d38ed7a3c6932f891883ab8918df70097cc 100644 (file)
@@ -70,9 +70,9 @@ QRectF ViewItem::label_rect(const QRectF &rect) const
        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();
 }
 
index 32b9f995fedb642783964b6287e68fbe36c9e131..648be84e64384a6fa382a503ee28f0892a480619 100644 (file)
@@ -109,7 +109,7 @@ public:
         * @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.
index 91b27d3ffb02ab383c3d2c801507191610a072e6..1b3d371748b844255e0f5ef8b29b311d8130a538 100644 (file)
@@ -57,10 +57,11 @@ Viewport::Viewport(View &parent) :
 
 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;
 }