]> sigrok.org Git - pulseview.git/commitdiff
TraceGroup: Implemented paint_label
authorJoel Holdsworth <redacted>
Sun, 2 Nov 2014 16:13:42 +0000 (16:13 +0000)
committerJoel Holdsworth <redacted>
Wed, 19 Nov 2014 10:23:03 +0000 (10:23 +0000)
pv/view/tracegroup.cpp
pv/view/tracegroup.h

index af756d49be6bea0a4877433223773d0b3bbc84c2..f5263e3facc92ddc5805eaa92ac7f757e145f633 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <extdef.h>
 #include <assert.h>
 
 #include <algorithm>
 
 #include <QMenu>
+#include <QPainter>
 
 #include "tracegroup.h"
 
@@ -35,6 +37,8 @@ namespace view {
 
 const int TraceGroup::Padding = 8;
 const int TraceGroup::Width = 12;
+const int TraceGroup::LineThickness = 5;
+const QColor TraceGroup::LineColour(QColor(0x55, 0x57, 0x53));
 
 TraceGroup::~TraceGroup()
 {
@@ -79,9 +83,33 @@ pair<int, int> TraceGroup::v_extents() const
 
 void TraceGroup::paint_label(QPainter &p, int right, bool hover)
 {
-       (void)p;
-       (void)right;
-       (void)hover;
+       const QRectF r = label_rect(right).adjusted(
+               LineThickness / 2, LineThickness / 2,
+               -LineThickness / 2, -LineThickness / 2);
+
+       // Paint the label
+       const QPointF points[] = {
+               r.topRight(),
+               r.topLeft(),
+               r.bottomLeft(),
+               r.bottomRight()
+       };
+
+       if (selected()) {
+               const QPen pen(highlight_pen());
+               p.setPen(QPen(pen.brush(), pen.width() + LineThickness,
+                       Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin));
+               p.setBrush(Qt::transparent);
+               p.drawPolyline(points, countof(points));
+       }
+
+       p.setPen(QPen(QBrush(LineColour.darker()), LineThickness,
+               Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin));
+       p.drawPolyline(points, countof(points));
+       p.setPen(QPen(QBrush(hover ? LineColour.lighter() : LineColour),
+               LineThickness - 2, Qt::SolidLine, Qt::SquareCap,
+               Qt::RoundJoin));
+       p.drawPolyline(points, countof(points));
 }
 
 QRectF TraceGroup::label_rect(int right) const
index 341a2a8835fac28ea57f7c04c47acd867c199e4c..5171b7fc880c23f5e2d390ba2bc1d06c553e3399 100644 (file)
@@ -34,6 +34,8 @@ class TraceGroup : public RowItem, public RowItemOwner
 private:
        static const int Padding;
        static const int Width;
+       static const int LineThickness;
+       static const QColor LineColour;
 
 public:
        /**