]> sigrok.org Git - pulseview.git/commitdiff
Use channel color as the trace background color
authorSoeren Apel <redacted>
Mon, 28 Dec 2015 14:13:42 +0000 (15:13 +0100)
committerSoeren Apel <redacted>
Mon, 28 Dec 2015 14:13:42 +0000 (15:13 +0100)
pv/view/analogsignal.cpp
pv/view/logicsignal.cpp
pv/view/logicsignal.hpp
pv/view/signal.cpp
pv/view/signal.hpp
pv/view/trace.cpp
pv/view/trace.hpp

index 683757d1a52cffc1f781bee07d73ca3b16f8b43c..2597a8f38445959051cadbdeae26ed7eb9f3ef8f 100644 (file)
@@ -63,7 +63,7 @@ AnalogSignal::AnalogSignal(
        scale_index_(0),
        scale_index_drag_offset_(0)
 {
-       colour_ = SignalColours[channel_->index() % countof(SignalColours)];
+       set_colour(SignalColours[channel_->index() % countof(SignalColours)]);
 }
 
 AnalogSignal::~AnalogSignal()
@@ -105,8 +105,10 @@ void AnalogSignal::scale_handle_drag_release()
 
 void AnalogSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp)
 {
-       if (channel_->enabled())
+       if (channel_->enabled()) {
+               Trace::paint_back(p, pp);
                paint_axis(p, pp, get_visual_y());
+       }
 }
 
 void AnalogSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
index 63d15314cdcf23470261f72a82dafedde51619e3..5d3ac102164375ae9aae4c5b30284ee89853eb8e 100644 (file)
@@ -113,7 +113,7 @@ LogicSignal::LogicSignal(
 {
        shared_ptr<Trigger> trigger;
 
-       colour_ = SignalColours[channel->index() % countof(SignalColours)];
+       set_colour(SignalColours[channel->index() % countof(SignalColours)]);
 
        /* Populate this channel's trigger setting with whatever we
         * find in the current session trigger, if anything. */
@@ -163,12 +163,6 @@ void LogicSignal::scale_handle_dragged(int offset)
        signal_height_ = ((units < 1) ? 1 : units) * font_height;
 }
 
-void LogicSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp)
-{
-       if (channel_->enabled())
-               paint_axis(p, pp, get_visual_y());
-}
-
 void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
 {
        QLineF *line;
index d7c4cb645b21eefc446a45acc1aae12228cc06ba..8c3525e6c47427bf94587fbfd82203ec1c2964e0 100644 (file)
@@ -94,13 +94,6 @@ public:
         */
        void scale_handle_dragged(int offset);
 
-       /**
-        * Paints the background layer of the signal with a QPainter
-        * @param p the QPainter to paint into.
-        * @param pp the painting parameters object to paint with..
-        */
-       void paint_back(QPainter &p, const ViewItemPaintParams &pp);
-
        /**
         * Paints the mid-layer of the signal with a QPainter
         * @param p the QPainter to paint into.
index 47e91f4b9a67f9a904d0b059e3da5cee543a35ab..09a6da8f17a3d7b9b2377cfa0dc1a251e454edde 100644 (file)
@@ -107,6 +107,12 @@ const ViewItemOwner::item_list& Signal::child_items() const
        return items_;
 }
 
+void Signal::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+{
+       if (channel_->enabled())
+               Trace::paint_back(p, pp);
+}
+
 void Signal::populate_popup_form(QWidget *parent, QFormLayout *form)
 {
        name_widget_ = new QComboBox(parent);
index db3286528a699964920cd47b3048d5daa7255428..bcd4e2eb617eef83a46a5c1e98bf308751b48d8e 100644 (file)
@@ -76,6 +76,8 @@ public:
         */
        const item_list& child_items() const;
 
+       void paint_back(QPainter &p, const ViewItemPaintParams &pp);
+
        virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
 
        QMenu* create_context_menu(QWidget *parent);
index 2e15ca958a1da81af2ebba507328da0b9cb801b6..05054d4927001c260d271d713ba88bbc14433029 100644 (file)
@@ -66,6 +66,9 @@ QColor Trace::colour() const
 void Trace::set_colour(QColor colour)
 {
        colour_ = colour;
+
+       bgcolour_ = colour;
+       bgcolour_.setAlpha(20);
 }
 
 void Trace::paint_label(QPainter &p, const QRect &rect, bool hover)
@@ -170,6 +173,21 @@ QRectF Trace::hit_box_rect(const ViewItemPaintParams &pp) const
                pp.width(), h);
 }
 
+void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+{
+       p.setPen(QPen(Qt::NoPen));
+       p.setBrush(bgcolour_);
+
+       const std::pair<int, int> extents = v_extents();
+
+       const int x = 0;
+       const int y = get_visual_y() + extents.first;
+       const int w = pp.right() - pp.left();
+       const int h = extents.second - extents.first;
+
+       p.drawRect(x, y, w, h);
+}
+
 void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)
 {
        p.setPen(AxisPen);
@@ -236,7 +254,7 @@ void Trace::on_colour_changed(const QColor &colour)
        set_colour(colour);
 
        if (owner_)
-               owner_->row_item_appearance_changed(true, false);
+               owner_->row_item_appearance_changed(true, true);
 }
 
 } // namespace view
index 677f366b477f7b1caaaae3bfb03a523ff3a51a0d..dce9fcc920c4ab856a5bb60663b1cb50146a3538 100644 (file)
@@ -100,6 +100,13 @@ public:
        QRectF label_rect(const QRectF &rect) const;
 
 protected:
+       /**
+        * Paints the background layer of the signal with a QPainter
+        * @param p the QPainter to paint into.
+        * @param pp the painting parameters object to paint with..
+        */
+       virtual void paint_back(QPainter &p, const ViewItemPaintParams &pp);
+
        /**
         * Paints a zero axis across the viewport.
         * @param p the QPainter to paint into.
@@ -123,7 +130,7 @@ private Q_SLOTS:
 
 protected:
        QString name_;
-       QColor colour_;
+       QColor colour_, bgcolour_;
 
 private:
        pv::widgets::Popup *popup_;