Fix #684 by implementing snap-to-edge for TimeItem-based classes
[pulseview.git] / pv / views / trace / view.hpp
index 8e78b6260e2143dcbb141ad2a5aa0f1b4836c822..94082189be41bc1b47b7abfff094045ed703138c 100644 (file)
@@ -129,6 +129,8 @@ public:
        virtual void remove_decode_signal(shared_ptr<data::DecodeSignal> signal);
 #endif
 
+       shared_ptr<Signal> get_signal_under_mouse_cursor() const;
+
        /**
         * Returns the view of the owner.
         */
@@ -301,6 +303,15 @@ public:
 
        const QPoint& hover_point() const;
 
+       /**
+        * Determines the closest level change (i.e. edge) to a given point, which
+        * is useful for e.g. the "snap to edge" functionality.
+        *
+        * @param p The current position of the mouse cursor
+        * @return The sample number of the nearest level change or -1 if none
+        */
+       int64_t get_nearest_level_change(const QPoint &p) const;
+
        void restack_all_trace_tree_items();
 
        int header_width() const;
@@ -517,6 +528,7 @@ private:
        vector< shared_ptr<TriggerMarker> > trigger_markers_;
 
        QPoint hover_point_;
+       shared_ptr<Signal> signal_under_mouse_cursor_;
 
        unsigned int sticky_events_;
        QTimer lazy_event_handler_;