]> sigrok.org Git - pulseview.git/blobdiff - pv/signal.cpp
Added a label colour chooser dialog
[pulseview.git] / pv / signal.cpp
index c23a3954455b155d74b042907c361fa245f18c3a..04c579232e4c6a2966680b0ad68a39ddf796aacf 100644 (file)
@@ -21,6 +21,7 @@
 #include <extdef.h>
 
 #include "signal.h"
 #include <extdef.h>
 
 #include "signal.h"
+#include "view/view.h"
 
 namespace pv {
 
 
 namespace pv {
 
@@ -41,9 +42,19 @@ void Signal::set_name(QString name)
        _name = name;
 }
 
        _name = name;
 }
 
+QColor Signal::get_colour() const
+{
+       return _colour;
+}
+
+void Signal::set_colour(QColor colour)
+{
+       _colour = colour;
+}
+
 void Signal::paint_label(QPainter &p, const QRect &rect, bool hover)
 {
 void Signal::paint_label(QPainter &p, const QRect &rect, bool hover)
 {
-       p.setBrush(get_colour());
+       p.setBrush(_colour);
 
        const QColor colour = get_colour();
        const float nominal_offset = get_nominal_offset(rect);
 
        const QColor colour = get_colour();
        const float nominal_offset = get_nominal_offset(rect);
@@ -105,13 +116,14 @@ QRectF Signal::get_label_rect(const QRect &rect)
 {
        using pv::view::View;
 
 {
        using pv::view::View;
 
-       const float nominal_offset = get_nominal_offset(rect);
+       const float nominal_offset = get_nominal_offset(rect) + 0.5;
        const QSizeF label_size(
                _text_size.width() + View::LabelPadding.width() * 2,
                _text_size.height() + View::LabelPadding.height() * 2);
        const float label_arrow_length = label_size.height() / 2;
        return QRectF(
        const QSizeF label_size(
                _text_size.width() + View::LabelPadding.width() * 2,
                _text_size.height() + View::LabelPadding.height() * 2);
        const float label_arrow_length = label_size.height() / 2;
        return QRectF(
-               rect.right() - label_arrow_length - label_size.width(),
+               rect.right() - label_arrow_length -
+                       label_size.width() - 0.5,
                nominal_offset - label_size.height() / 2,
                label_size.width(), label_size.height());
 }
                nominal_offset - label_size.height() / 2,
                label_size.width(), label_size.height());
 }