X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Ftrace.cpp;h=f7e7ebf25b8ec00a351bb415f7fe696de155e8b6;hb=0c2389230c90d8bf34b601c625bcf655b24e8f52;hp=3727afa2de246912c8834dc0f3977d5131ec25bc;hpb=574c568d184240cd87be1b57fc00d60a4eac7566;p=pulseview.git diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index 3727afa..f7e7ebf 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -41,6 +41,9 @@ 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() @@ -77,6 +80,17 @@ 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::paint_label(QPainter &p, const QRect &rect, bool hover) { const int y = get_visual_y(); @@ -181,19 +195,21 @@ QRectF Trace::hit_box_rect(const ViewItemPaintParams &pp) const void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp) { - if (coloured_bg_) { - p.setPen(QPen(Qt::NoPen)); + if (coloured_bg_) p.setBrush(bgcolour_); + else + p.setBrush(bgcolour_state_ ? BrightBGColour : DarkBGColour); - const std::pair extents = v_extents(); + p.setPen(QPen(Qt::NoPen)); - const int x = 0; - const int y = get_visual_y() + extents.first; - const int w = pp.right() - pp.left(); - const int h = extents.second - extents.first; + const std::pair extents = v_extents(); - p.drawRect(x, y, w, h); - } + const int x = 0; + const int y = get_visual_y() + extents.first; + const int w = pp.right() - pp.left(); + const int h = extents.second - extents.first; + + p.drawRect(x, y, w, h); } void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)