X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Ftrace.cpp;h=87d3dc1dc095fa7ebd7b1dd2b7dba0bf5c255c8e;hb=25272feeeffbf2f67645a7be29ac8704c41c1bb0;hp=ee0a4f0e921630b986a090bbdca494fb3849010f;hpb=35365c66bf6166c5607f1180016528d996a45b66;p=pulseview.git diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index ee0a4f0e..87d3dc1d 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -38,11 +38,12 @@ namespace pv { namespace view { -const QPen Trace::AxisPen(QColor(128, 128, 128, 64)); +const QPen Trace::AxisPen(QColor(0, 0, 0, 30*256/100)); const int Trace::LabelHitPadding = 2; -const QColor Trace::DarkBGColour(235, 235, 235); // Quite light grey -const QColor Trace::BrightBGColour(245, 245, 245); // Very light grey +const int Trace::ColourBGAlpha = 8*256/100; +const QColor Trace::BrightGrayBGColour = QColor(0, 0, 0, 10*255/100); +const QColor Trace::DarkGrayBGColour = QColor(0, 0, 0, 15*255/100); Trace::Trace(QString name) : name_(name), @@ -72,7 +73,7 @@ void Trace::set_colour(QColor colour) colour_ = colour; bgcolour_ = colour; - bgcolour_.setAlpha(20); + bgcolour_.setAlpha(ColourBGAlpha); } void Trace::set_coloured_bg(bool state) @@ -80,27 +81,6 @@ void Trace::set_coloured_bg(bool state) coloured_bg_ = state; } -bool Trace::is_draggable() const -{ - const View *const view = owner_->view(); - assert(view); - - QPoint cursor_pos = view->mapFromGlobal(QCursor::pos()); - - // The signal is draggable only in the header area - return (cursor_pos.x() <= view->header_size().width()); -} - -void Trace::select(bool select) -{ - // Trace can only be selected if the mouse cursor is in the header area; - // as is_draggable() checks the same thing, we re-use it here - if (is_draggable() && select) - selected_ = true; - else - selected_ = false; -} - void Trace::paint_label(QPainter &p, const QRect &rect, bool hover) { const int y = get_visual_y(); @@ -196,19 +176,12 @@ QRectF Trace::label_rect(const QRectF &rect) const label_size.height()); } -QRectF Trace::hit_box_rect(const ViewItemPaintParams &pp) const -{ - const float h = QFontMetrics(QApplication::font()).height(); - return QRectF(pp.left(), get_visual_y() - h / 2.0f, - pp.width(), h); -} - void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp) { if (coloured_bg_) p.setBrush(bgcolour_); else - p.setBrush(bgcolour_state_ ? BrightBGColour : DarkBGColour); + p.setBrush(bgcolour_state_ ? BrightGrayBGColour : DarkGrayBGColour); p.setPen(QPen(Qt::NoPen)); @@ -224,8 +197,12 @@ void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp) void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y) { + p.setRenderHint(QPainter::Antialiasing, false); + p.setPen(AxisPen); - p.drawLine(QPointF(pp.left(), y + 0.5f), QPointF(pp.right(), y + 0.5f)); + p.drawLine(QPointF(pp.left(), y), QPointF(pp.right(), y)); + + p.setRenderHint(QPainter::Antialiasing, true); } void Trace::add_colour_option(QWidget *parent, QFormLayout *form) @@ -247,10 +224,14 @@ void Trace::create_popup_form() // Clear the layout // Transfer the layout and the child widgets to a temporary widget - // which then goes out of scope destroying the layout and all the child - // widgets. - if (popup_form_) - QWidget().setLayout(popup_form_); + // which we delete after the event was handled. This way, the layout + // and all widgets contained therein are deleted after the event was + // handled, leaving the parent popup_ time to handle the change. + if (popup_form_) { + QWidget *suicidal = new QWidget(); + suicidal->setLayout(popup_form_); + suicidal->deleteLater(); + } // Repopulate the popup popup_form_ = new QFormLayout(popup_);