]> sigrok.org Git - pulseview.git/commitdiff
Make traces non-draggable outside the header area
authorSoeren Apel <redacted>
Tue, 29 Dec 2015 22:12:26 +0000 (23:12 +0100)
committerUwe Hermann <redacted>
Wed, 30 Dec 2015 22:15:52 +0000 (23:15 +0100)
pv/view/trace.cpp
pv/view/trace.hpp
pv/view/view.cpp
pv/view/view.hpp

index f7bba9ff31506e5a5fa68abaacfe1fe3163e321e..f7e7ebf25b8ec00a351bb415f7fe696de155e8b6 100644 (file)
@@ -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();
index c9582c61218409616c7119d1cc894f6ae0cecafd..acaa341adbadd55f477e32d1f3e01d9cd4c662f6 100644 (file)
@@ -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.
index c9b08bf8c0445de0783d5bbb16d4d4275f5066f1..124048bda8f9c63c1b14a5e770977ab89e09e37c 100644 (file)
@@ -203,6 +203,11 @@ const Viewport* View::viewport() const
        return viewport_;
 }
 
+const QSize View::header_size() const
+{
+       return header_->sizeHint();
+}
+
 vector< shared_ptr<TimeItem> > View::time_items() const
 {
        const vector<shared_ptr<Flag>> f(flags());
index 635273dae74ad6e1131a592da699beba6a8e76e7..8aa551250177199a297d73998b01fab1bd8a79f5 100644 (file)
@@ -95,6 +95,8 @@ public:
 
        const Viewport* viewport() const;
 
+       const QSize header_size() const;
+
        /**
         * Gets a list of time markers.
         */