From d09674d4529828b6bd2cbaa027949b953d6bd96a Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Mon, 13 May 2013 19:22:11 +0100 Subject: [PATCH] Moved highlight pen into SelectableItem --- pv/view/selectableitem.cpp | 12 ++++++++++++ pv/view/selectableitem.h | 8 +++++++- pv/view/signal.cpp | 5 +---- pv/view/signal.h | 1 - 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/pv/view/selectableitem.cpp b/pv/view/selectableitem.cpp index 517b687..8dfdd8a 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 69204b2..d8545ce 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 dd50243..ae180e1 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 4f16e3a..ece2e5a 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; -- 2.30.2