From: Soeren Apel Date: Tue, 29 Dec 2015 22:12:26 +0000 (+0100) Subject: Make traces non-draggable outside the header area X-Git-Tag: pulseview-0.3.0~17 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e081bf3d864d5662716668d6b4adcb0871d11dae;p=pulseview.git Make traces non-draggable outside the header area --- diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index f7bba9ff..f7e7ebf2 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -80,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(); diff --git a/pv/view/trace.hpp b/pv/view/trace.hpp index c9582c61..acaa341a 100644 --- a/pv/view/trace.hpp +++ b/pv/view/trace.hpp @@ -81,6 +81,11 @@ public: */ void set_coloured_bg(bool state); + /** + * Returns true if the item may be dragged/moved. + */ + bool is_draggable() const; + /** * Computes the outline rectangle of the viewport hit-box. * @param rect the rectangle of the viewport area. diff --git a/pv/view/view.cpp b/pv/view/view.cpp index c9b08bf8..124048bd 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -203,6 +203,11 @@ const Viewport* View::viewport() const return viewport_; } +const QSize View::header_size() const +{ + return header_->sizeHint(); +} + vector< shared_ptr > View::time_items() const { const vector> f(flags()); diff --git a/pv/view/view.hpp b/pv/view/view.hpp index 635273da..8aa55125 100644 --- a/pv/view/view.hpp +++ b/pv/view/view.hpp @@ -95,6 +95,8 @@ public: const Viewport* viewport() const; + const QSize header_size() const; + /** * Gets a list of time markers. */