X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Ftrace.cpp;h=df6bd63d041ec74a4228919ea4383afb2c982ae4;hb=65c34596346fbf7d25fe2065728b86c207018586;hp=ebd3dc3681e68022bb51dbcc83051aa37b1714af;hpb=8dbbc7f0b9ea59d0f0d62225772f8a56eee125f5;p=pulseview.git diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index ebd3dc36..df6bd63d 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -28,12 +28,12 @@ #include #include -#include "trace.h" -#include "tracepalette.h" -#include "view.h" +#include "trace.hpp" +#include "tracepalette.hpp" +#include "view.hpp" -#include -#include +#include +#include namespace pv { namespace view { @@ -68,7 +68,7 @@ void Trace::set_colour(QColor colour) colour_ = colour; } -void Trace::paint_label(QPainter &p, int right, bool hover) +void Trace::paint_label(QPainter &p, const QRect &rect, bool hover) { const int y = get_visual_y(); @@ -77,7 +77,7 @@ void Trace::paint_label(QPainter &p, int right, bool hover) if (!enabled()) return; - const QRectF r = label_rect(right); + const QRectF r = label_rect(rect); // Paint the label const float label_arrow_length = r.height() / 2; @@ -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()), @@ -143,7 +143,7 @@ pv::widgets::Popup* Trace::create_popup(QWidget *parent) return popup_; } -QRectF Trace::label_rect(int right) const +QRectF Trace::label_rect(const QRectF &rect) const { using pv::view::View; @@ -156,21 +156,16 @@ QRectF Trace::label_rect(int right) const ceilf((text_size.height() + View::LabelPadding.height() * 2) / 2) * 2); const float half_height = label_size.height() / 2; return QRectF( - right - half_height - label_size.width() - 0.5, + rect.right() - half_height - label_size.width() - 0.5, get_visual_y() + 0.5f - half_height, label_size.width() + half_height, label_size.height()); } -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) +void Trace::paint_axis(QPainter &p, const RowItemPaintParams &pp, int y) { p.setPen(AxisPen); - p.drawLine(QPointF(left, y + 0.5f), QPointF(right, y + 0.5f)); + p.drawLine(QPointF(pp.left(), y + 0.5f), QPointF(pp.right(), y + 0.5f)); } void Trace::add_colour_option(QWidget *parent, QFormLayout *form)