]> sigrok.org Git - pulseview.git/commitdiff
ViewItem: Moved in paint_label
authorJoel Holdsworth <redacted>
Thu, 18 Dec 2014 21:16:20 +0000 (21:16 +0000)
committerJoel Holdsworth <redacted>
Sun, 28 Dec 2014 18:52:53 +0000 (18:52 +0000)
pv/view/cursorpair.cpp
pv/view/cursorpair.hpp
pv/view/rowitem.hpp
pv/view/ruler.cpp
pv/view/timeitem.hpp
pv/view/timemarker.cpp
pv/view/timemarker.hpp
pv/view/viewitem.hpp

index c5a1bc9923beafb00c805eff8f331735a764bbdf..a14f458bedd96710304cb06ad262944e5a91278d 100644 (file)
@@ -101,7 +101,7 @@ QRectF CursorPair::label_rect(const QRectF &rect) const
                right - left, height);
 }
 
                right - left, height);
 }
 
-void CursorPair::paint_label(QPainter &p, const QRect &rect)
+void CursorPair::paint_label(QPainter &p, const QRect &rect, bool hover)
 {
        assert(first_);
        assert(second_);
 {
        assert(first_);
        assert(second_);
@@ -130,7 +130,8 @@ void CursorPair::paint_label(QPainter &p, const QRect &rect)
                        p.drawRoundedRect(delta_rect, radius, radius);
                }
 
                        p.drawRoundedRect(delta_rect, radius, radius);
                }
 
-               p.setBrush(Cursor::FillColour);
+               p.setBrush(hover ? Cursor::FillColour.lighter() :
+                       Cursor::FillColour);
                p.setPen(Cursor::FillColour.darker());
                p.drawRoundedRect(delta_rect, radius, radius);
 
                p.setPen(Cursor::FillColour.darker());
                p.drawRoundedRect(delta_rect, radius, radius);
 
index af7f5556c722bc83609e72664a5b610858072d08..fc9f0d1ba6f4a4edc718e869bfe61dd381588641 100644 (file)
@@ -74,7 +74,13 @@ public:
 public:
        QRectF label_rect(const QRectF &rect) const;
 
 public:
        QRectF label_rect(const QRectF &rect) const;
 
-       void paint_label(QPainter &p, const QRect &rect);
+       /**
+        * Paints the marker's label to the ruler.
+        * @param p The painter to draw with.
+        * @param rect The rectangle of the ruler client area.
+        * @param hover true if the label is being hovered over by the mouse.
+        */
+       void paint_label(QPainter &p, const QRect &rect, bool hover);
 
        /**
         * Paints the background layer of the item with a QPainter
 
        /**
         * Paints the background layer of the item with a QPainter
index cf521ff0be88d2f030cab0c4cd4616de9728594b..d30227830e73782c4427dad7df1e19f76380297e 100644 (file)
@@ -104,14 +104,6 @@ public:
         */
        virtual std::pair<int, int> v_extents() const = 0;
 
         */
        virtual std::pair<int, int> v_extents() const = 0;
 
-       /**
-        * Paints the signal label.
-        * @param p the QPainter to paint into.
-        * @param rect the rectangle of the header area.
-        * @param hover true if the label is being hovered over by the mouse.
-        */
-       virtual void paint_label(QPainter &p, const QRect &rect, bool hover) = 0;
-
 public:
        virtual void hover_point_changed();
 
 public:
        virtual void hover_point_changed();
 
index 7018c212db52f8b72f1449400b9160594a746dde..d08cfc43f3a1352c340f2a90b25cfbee3092da4b 100644 (file)
@@ -138,8 +138,11 @@ void Ruler::paintEvent(QPaintEvent*)
 
        // Draw the items
        const vector< shared_ptr<TimeItem> > items(view_.time_items());
 
        // Draw the items
        const vector< shared_ptr<TimeItem> > items(view_.time_items());
-       for (auto &i : items)
-               i->paint_label(p, r);
+       for (auto &i : items) {
+               const bool highlight = !dragging_ &&
+                       i->label_rect(r).contains(mouse_point_);
+               i->paint_label(p, r, highlight);
+       }
 }
 
 void Ruler::mouseMoveEvent(QMouseEvent *e)
 }
 
 void Ruler::mouseMoveEvent(QMouseEvent *e)
index 8374244215807b5c34e4433c441c8f4a19582e6d..f988488409c18426aebab42b720dab2d54731987 100644 (file)
@@ -48,13 +48,6 @@ public:
 
        virtual float get_x() const = 0;
 
 
        virtual float get_x() const = 0;
 
-       /**
-        * Paints the marker's label to the ruler.
-        * @param p The painter to draw with.
-        * @param rect The rectangle of the ruler client area.
-        */
-       virtual void paint_label(QPainter &p, const QRect &rect) = 0;
-
 protected:
        View &view_;
 };
 protected:
        View &view_;
 };
index ed9df36064f74407b1a1ee81f80d11378adbc81c..399664675bd83b61c40ec484e8aa4842705625ad 100644 (file)
@@ -100,7 +100,7 @@ QRectF TimeMarker::label_rect(const QRectF &rect) const
                label_size.width(), height);
 }
 
                label_size.width(), height);
 }
 
-void TimeMarker::paint_label(QPainter &p, const QRect &rect)
+void TimeMarker::paint_label(QPainter &p, const QRect &rect, bool hover)
 {
        if (!enabled())
                return;
 {
        if (!enabled())
                return;
@@ -136,7 +136,7 @@ void TimeMarker::paint_label(QPainter &p, const QRect &rect)
        }
 
        p.setPen(Qt::transparent);
        }
 
        p.setPen(Qt::transparent);
-       p.setBrush(colour_);
+       p.setBrush(hover ? colour_.lighter() : colour_);
        p.drawPolygon(points, countof(points));
 
        p.setPen(colour_.lighter());
        p.drawPolygon(points, countof(points));
 
        p.setPen(colour_.lighter());
index 9cab1fc6d0a96e666069e635c564a0d62ac80ab5..57d6c9b04ecc1bb7cb58d3c812688ecd31cfb2d5 100644 (file)
@@ -88,8 +88,9 @@ public:
         * Paints the marker's label to the ruler.
         * @param p The painter to draw with.
         * @param rect The rectangle of the ruler client area.
         * Paints the marker's label to the ruler.
         * @param p The painter to draw with.
         * @param rect The rectangle of the ruler client area.
+        * @param hover true if the label is being hovered over by the mouse.
         */
         */
-       void paint_label(QPainter &p, const QRect &rect);
+       void paint_label(QPainter &p, const QRect &rect, bool hover);
 
        /**
         * Paints the foreground layer of the item with a QPainter
 
        /**
         * Paints the foreground layer of the item with a QPainter
index 12e1f44fc7659ac538ea6d8725ca60fcc3b4b116..3e6801fe3186dffe74c10263f27b4192e95ef871 100644 (file)
@@ -97,6 +97,14 @@ public:
         */
        virtual QRectF label_rect(const QRectF &rect) const = 0;
 
         */
        virtual QRectF label_rect(const QRectF &rect) const = 0;
 
+       /**
+        * Paints the signal label.
+        * @param p the QPainter to paint into.
+        * @param rect the rectangle of the header area.
+        * @param hover true if the label is being hovered over by the mouse.
+        */
+       virtual void paint_label(QPainter &p, const QRect &rect, bool hover) = 0;
+
        /**
         * Paints the background layer of the item with a QPainter
         * @param p the QPainter to paint into.
        /**
         * Paints the background layer of the item with a QPainter
         * @param p the QPainter to paint into.