]> sigrok.org Git - pulseview.git/blobdiff - pv/view/signal.cpp
Added signal (multi) selection
[pulseview.git] / pv / view / signal.cpp
index 3e951b339bc261c319e3807249c2a4d91ae35462..8fed4273e86d40beeac77329f60e60f0c6f9ecf7 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <extdef.h>
 
+#include <QApplication>
+
 #include "signal.h"
 #include "view.h"
 
@@ -27,9 +29,12 @@ namespace pv {
 namespace view {
 
 const int Signal::LabelHitPadding = 2;
+const int Signal::LabelHighlightRadius = 6;
 
 Signal::Signal(QString name) :
-       _name(name)
+       _name(name),
+       _v_offset(0),
+       _selected(false)
 {
 }
 
@@ -53,6 +58,26 @@ void Signal::set_colour(QColor colour)
        _colour = colour;
 }
 
+int Signal::get_v_offset() const
+{
+       return _v_offset;
+}
+
+void Signal::set_v_offset(int v_offset)
+{
+       _v_offset = v_offset;
+}
+
+bool Signal::selected() const
+{
+       return _selected;
+}
+
+void Signal::select(bool select)
+{
+       _selected = select;
+}
+
 void Signal::paint_label(QPainter &p, const QRect &rect, bool hover)
 {
        p.setBrush(_colour);
@@ -80,6 +105,14 @@ void Signal::paint_label(QPainter &p, const QRect &rect, bool hover)
                QPointF(label_rect.left() + 1, label_rect.bottom() - 1)
        };
 
+       if(_selected) {
+               p.setPen(QPen(QApplication::palette().brush(
+                       QPalette::Highlight), LabelHighlightRadius,
+                       Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
+               p.setBrush(Qt::transparent);
+               p.drawPolygon(points, countof(points));
+       }
+
        p.setPen(Qt::transparent);
        p.setBrush(hover ? colour.lighter() : colour);
        p.drawPolygon(points, countof(points));