X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Ftrace.cpp;h=ee0a4f0e921630b986a090bbdca494fb3849010f;hp=f7bba9ff31506e5a5fa68abaacfe1fe3163e321e;hb=796e136093befc76f6c223afff1c1221182cf5dd;hpb=ac0708fb7e6b4010d90a569386810d3d2edc7eb9 diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index f7bba9ff..ee0a4f0e 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -80,6 +80,27 @@ 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();