]> sigrok.org Git - pulseview.git/commitdiff
Moved text colour calculation into Trace::get_text_colour
authorJoel Holdsworth <redacted>
Thu, 5 Sep 2013 12:06:41 +0000 (13:06 +0100)
committerJoel Holdsworth <redacted>
Sun, 29 Sep 2013 14:55:48 +0000 (23:55 +0900)
pv/view/trace.cpp
pv/view/trace.h

index ff1fbddbcb5305185ec1abba301cc5e3857b7c19..b3ebd95b4a7e1928b1c33370f39a1cf8506a3f86 100644 (file)
@@ -147,7 +147,7 @@ void Trace::paint_label(QPainter &p, int right, bool hover)
        p.drawPolygon(points, countof(points));
 
        // Paint the text
-       p.setPen((colour.lightness() > 64) ? Qt::black : Qt::white);
+       p.setPen(get_text_colour());
        p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, _name);
 }
 
@@ -168,6 +168,11 @@ int Trace::get_y() const
        return _v_offset - _view->v_offset();
 }
 
+QColor Trace::get_text_colour() const
+{
+       return (_colour.lightness() > 64) ? Qt::black : Qt::white;
+}
+
 void Trace::paint_axis(QPainter &p, int y, int left, int right)
 {
        p.setPen(AxisPen);
index 07f90f4c92734e718f085f7b9b0bc0fc1d913564..415a7dc28c70c4e273f2bcde3bd5d037306d10f2 100644 (file)
@@ -137,6 +137,14 @@ protected:
         */
        int get_y() const;
 
+       /**
+        * 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.