From: Joel Holdsworth Date: Sun, 2 Nov 2014 16:13:42 +0000 (+0000) Subject: TraceGroup: Implemented paint_label X-Git-Tag: pulseview-0.3.0~452 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1dc835a4b49104f5b4c9695e91e6ffb7a48d7c23;p=pulseview.git TraceGroup: Implemented paint_label --- 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: /**