X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Ftrace.cpp;h=ee0a4f0e921630b986a090bbdca494fb3849010f;hp=05054d4927001c260d271d713ba88bbc14433029;hb=086f4df565d8e70328f3c4bbc92949e0817dc6d4;hpb=99af6802961b0a5ec7ec7d3ff2215c8eb6925ca3 diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index 05054d49..ee0a4f0e 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -41,8 +41,12 @@ namespace view { const QPen Trace::AxisPen(QColor(128, 128, 128, 64)); 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 + Trace::Trace(QString name) : name_(name), + coloured_bg_(true), // Default setting is set in MainWindow::setup_ui() popup_(nullptr), popup_form_(nullptr) { @@ -71,6 +75,32 @@ void Trace::set_colour(QColor colour) bgcolour_.setAlpha(20); } +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(); @@ -175,8 +205,12 @@ QRectF Trace::hit_box_rect(const ViewItemPaintParams &pp) const void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp) { + if (coloured_bg_) + p.setBrush(bgcolour_); + else + p.setBrush(bgcolour_state_ ? BrightBGColour : DarkBGColour); + p.setPen(QPen(Qt::NoPen)); - p.setBrush(bgcolour_); const std::pair extents = v_extents();