From 1dc835a4b49104f5b4c9695e91e6ffb7a48d7c23 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sun, 2 Nov 2014 16:13:42 +0000 Subject: [PATCH] TraceGroup: Implemented paint_label --- pv/view/tracegroup.cpp | 34 +++++++++++++++++++++++++++++++--- pv/view/tracegroup.h | 2 ++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/pv/view/tracegroup.cpp b/pv/view/tracegroup.cpp index af756d49..f5263e3f 100644 --- a/pv/view/tracegroup.cpp +++ b/pv/view/tracegroup.cpp @@ -18,11 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include #include +#include #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 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 diff --git a/pv/view/tracegroup.h b/pv/view/tracegroup.h index 341a2a88..5171b7fc 100644 --- a/pv/view/tracegroup.h +++ b/pv/view/tracegroup.h @@ -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: /** -- 2.30.2