From: Joel Holdsworth Date: Mon, 13 May 2013 18:22:11 +0000 (+0100) Subject: Moved highlight pen into SelectableItem X-Git-Tag: pulseview-0.2.0~355 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d09674d4529828b6bd2cbaa027949b953d6bd96a;p=pulseview.git Moved highlight pen into SelectableItem --- diff --git a/pv/view/selectableitem.cpp b/pv/view/selectableitem.cpp index 517b6879..8dfdd8aa 100644 --- a/pv/view/selectableitem.cpp +++ b/pv/view/selectableitem.cpp @@ -20,9 +20,14 @@ #include "selectableitem.h" +#include +#include + namespace pv { namespace view { +const int SelectableItem::HighlightRadius = 6; + SelectableItem::SelectableItem() : _selected(false) { @@ -38,5 +43,12 @@ void SelectableItem::select(bool select) _selected = select; } +QPen SelectableItem::highlight_pen() +{ + return QPen(QApplication::palette().brush( + QPalette::Highlight), HighlightRadius, + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); +} + } // namespace view } // namespace pv diff --git a/pv/view/selectableitem.h b/pv/view/selectableitem.h index 69204b29..d8545ce6 100644 --- a/pv/view/selectableitem.h +++ b/pv/view/selectableitem.h @@ -23,7 +23,7 @@ #include -#include +#include class QAction; @@ -34,6 +34,9 @@ class SelectableItem : public QObject { Q_OBJECT +private: + static const int HighlightRadius; + public: SelectableItem(); @@ -48,6 +51,9 @@ public: */ void select(bool select = true); +protected: + static QPen highlight_pen(); + private: bool _selected; }; diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index dd50243a..ae180e19 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -32,7 +32,6 @@ namespace pv { namespace view { const int Signal::LabelHitPadding = 2; -const int Signal::LabelHighlightRadius = 6; const QPen Signal::SignalAxisPen(QColor(128, 128, 128, 64)); @@ -104,9 +103,7 @@ void Signal::paint_label(QPainter &p, int y, int right, bool hover) }; if (selected()) { - p.setPen(QPen(QApplication::palette().brush( - QPalette::Highlight), LabelHighlightRadius, - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + p.setPen(highlight_pen()); p.setBrush(Qt::transparent); p.drawPolygon(points, countof(points)); } diff --git a/pv/view/signal.h b/pv/view/signal.h index 4f16e3a7..ece2e5a4 100644 --- a/pv/view/signal.h +++ b/pv/view/signal.h @@ -49,7 +49,6 @@ class Signal : public SelectableItem private: static const int LabelHitPadding; - static const int LabelHighlightRadius; static const QPen SignalAxisPen;