]> sigrok.org Git - pulseview.git/blobdiff - pv/view/viewport.hpp
Change namespace for the trace view and implement ViewBase
[pulseview.git] / pv / view / viewport.hpp
index 07bfcad9c5263a49b2fa5d22e9992dbf0541add5..a8062fb650c6e9f8fe11d93c29fd6f4dbb6e3bc7 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-#ifndef PULSEVIEW_PV_VIEW_VIEWPORT_H
-#define PULSEVIEW_PV_VIEW_VIEWPORT_H
+#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWPORT_HPP
+#define PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWPORT_HPP
+
+#include <boost/optional.hpp>
 
 #include <QTimer>
-#include <QWidget>
 #include <QTouchEvent>
 
+#include "pv/util.hpp"
+#include "viewwidget.hpp"
+
 class QPainter;
 class QPaintEvent;
 class Session;
 
 namespace pv {
-namespace view {
+namespace views {
+namespace TraceView {
 
 class View;
 
-class Viewport : public QWidget
+class Viewport : public ViewWidget
 {
        Q_OBJECT
 
 public:
        explicit Viewport(View &parent);
 
-protected:
-       void paintEvent(QPaintEvent *event);
-
 private:
-       bool event(QEvent *event);
-       void mousePressEvent(QMouseEvent *event);
-       void mouseReleaseEvent(QMouseEvent *event);
-       void mouseMoveEvent(QMouseEvent *event);
-       void mouseDoubleClickEvent(QMouseEvent * event);
-       void wheelEvent(QWheelEvent *event);
-       bool touchEvent(QTouchEvent *e);
+       /**
+        * Indicates when a view item is being hovered over.
+        * @param item The item that is being hovered over, or @c nullptr
+        * if no view item is being hovered over.
+        */
+       void item_hover(const std::shared_ptr<ViewItem> &item);
+
+       /**
+        * Gets the first view item which has a hit-box that contains @c pt .
+        * @param pt the point to search with.
+        * @return the view item that has been found, or and empty
+        *   @c shared_ptr if no item was found.
+        */
+       std::shared_ptr<ViewItem> get_mouse_over_item(const QPoint &pt);
+
+       /**
+        * Sets this item into the dragged state.
+        */
+       void drag();
 
-private Q_SLOTS:
-       void on_signals_moved();
+       /**
+        * Drag the background by the delta offset.
+        * @param delta the drag offset in pixels.
+        */
+       void drag_by(const QPoint &delta);
+
+       /**
+        * Sets this item into the un-dragged state.
+        */
+       void drag_release();
+
+       /**
+        * Gets the items in the view widget.
+        */
+       std::vector< std::shared_ptr<ViewItem> > items();
+
+       /**
+        * Handles touch begin update and end events.
+        * @param e the event that triggered this handler.
+        */
+       bool touch_event(QTouchEvent *event);
 
 private:
-       View &view_;
+       void paintEvent(QPaintEvent *event);
 
-       QPoint mouse_down_point_;
-       double mouse_down_offset_;
-       bool mouse_down_valid_;
+       void mouseDoubleClickEvent(QMouseEvent *event);
+       void wheelEvent(QWheelEvent *event);
+
+private:
+       boost::optional<pv::util::Timestamp> drag_offset_;
+       int drag_v_offset_;
 
        double pinch_offset0_;
        double pinch_offset1_;
        bool pinch_zoom_active_;
 };
 
-} // namespace view
+} // namespace TraceView
+} // namespace views
 } // namespace pv
 
-#endif // PULSEVIEW_PV_VIEW_VIEWPORT_H
+#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWPORT_HPP