]> sigrok.org Git - pulseview.git/commitdiff
Trace: Moved get_text_colour into SelectableItem
authorJoel Holdsworth <redacted>
Sun, 30 Nov 2014 12:57:31 +0000 (12:57 +0000)
committerUwe Hermann <redacted>
Wed, 10 Dec 2014 17:06:15 +0000 (18:06 +0100)
pv/view/selectableitem.cpp
pv/view/selectableitem.hpp
pv/view/trace.cpp
pv/view/trace.hpp

index b699005f4374a1e2bce16ecd872f033ae691c9ee..6921f19a71c27b02d2ecaaa5dc2abaf39fea3a87 100644 (file)
@@ -85,5 +85,10 @@ QPen SelectableItem::highlight_pen()
                Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
 }
 
+QColor SelectableItem::select_text_colour(QColor background)
+{
+       return (background.lightness() > 64) ? Qt::black : Qt::white;
+}
+
 } // namespace view
 } // namespace pv
index 36ff0dbcd48a95adf8626aefe751185adb1c39f7..1f5944900bafa8d5ed9adafb482c3f77b32c8395 100644 (file)
@@ -83,6 +83,15 @@ public:
         */
        virtual QPoint point() const = 0;
 
+public:
+       /**
+        * Gets the text colour.
+        * @remarks This colour is computed by comparing the lightness
+        * of the trace colour against a threshold to determine whether
+        * white or black would be more visible.
+        */
+       static QColor select_text_colour(QColor background);
+
 public:
        virtual QMenu* create_context_menu(QWidget *parent);
 
index fd440185c4e9c376e4c5cef307c4b88e79e1b923..e9235e56f2713bfd348f29ab6c3c14112968f81d 100644 (file)
@@ -115,7 +115,7 @@ void Trace::paint_label(QPainter &p, int right, bool hover)
        p.drawPolygon(points, countof(points));
 
        // Paint the text
-       p.setPen(get_text_colour());
+       p.setPen(select_text_colour(colour_));
        p.setFont(QApplication::font());
        p.drawText(QRectF(r.x(), r.y(),
                r.width() - label_arrow_length, r.height()),
@@ -162,11 +162,6 @@ QRectF Trace::label_rect(int right) const
                label_size.height());
 }
 
-QColor Trace::get_text_colour() const
-{
-       return (colour_.lightness() > 64) ? Qt::black : Qt::white;
-}
-
 void Trace::paint_axis(QPainter &p, const RowItemPaintParams &pp, int y)
 {
        p.setPen(AxisPen);
index c0b94df26c00f86fbf61b5d673131e95a472165e..a82520ccfdc68fedf589ea8afb326c4b99016fbb 100644 (file)
@@ -95,15 +95,6 @@ public:
        QRectF label_rect(int right) const;
 
 protected:
-
-       /**
-        * Gets the text colour.
-        * @remarks This colour is computed by comparing the lightness
-        * of the trace colour against a threshold to determine whether
-        * white or black would be more visible.
-        */
-       QColor get_text_colour() const;
-
        /**
         * Paints a zero axis across the viewport.
         * @param p the QPainter to paint into.