X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fviewwidget.hpp;h=e2c04f297a0c9b81a084ec1886a9d86cd35dd66d;hp=fc7247627a8783f1a55bf81dc31526da151c8032;hb=086f4df565d8e70328f3c4bbc92949e0817dc6d4;hpb=e9e4e5e7ea46132262fbd53f708dafc039b3b24f diff --git a/pv/view/viewwidget.hpp b/pv/view/viewwidget.hpp index fc724762..e2c04f29 100644 --- a/pv/view/viewwidget.hpp +++ b/pv/view/viewwidget.hpp @@ -18,13 +18,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEWWIDGET_H -#define PULSEVIEW_PV_VIEWWIDGET_H +#ifndef PULSEVIEW_PV_VIEWWIDGET_HPP +#define PULSEVIEW_PV_VIEWWIDGET_HPP #include #include +class QTouchEvent; + namespace pv { namespace view { @@ -38,6 +40,15 @@ class ViewWidget : public QWidget protected: ViewWidget(View &parent); + /** + * 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. + * @remarks the default implementation does nothing. + */ + virtual void item_hover( + const std::shared_ptr &item); + /** * Indicates the event an a view item has been clicked. * @param item the view item that has been clicked. @@ -52,12 +63,34 @@ protected: */ bool accept_drag() const; + /** + * Returns true if the mouse button is down. + */ + bool mouse_down() const; + /** * Drag the dragging items by the delta offset. * @param delta the drag offset in pixels. */ void drag_items(const QPoint &delta); + /** + * Sets this item into the dragged state. + */ + virtual void drag(); + + /** + * Drag the background by the delta offset. + * @param delta the drag offset in pixels. + * @remarks The default implementation does nothing. + */ + virtual void drag_by(const QPoint &delta); + + /** + * Sets this item into the un-dragged state. + */ + virtual void drag_release(); + /** * Gets the items in the view widget. */ @@ -84,7 +117,15 @@ protected: */ void mouse_left_release_event(QMouseEvent *event); + /** + * Handles touch begin update and end events. + * @param e the event that triggered this handler. + */ + virtual bool touch_event(QTouchEvent *e); + protected: + bool event(QEvent *event); + void mousePressEvent(QMouseEvent * event); void mouseReleaseEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); @@ -102,10 +143,10 @@ protected: QPoint mouse_point_; QPoint mouse_down_point_; std::shared_ptr mouse_down_item_; - bool dragging_; + bool item_dragging_; }; } // namespace view } // namespace pv -#endif // PULSEVIEW_PV_VIEWWIDGET_H +#endif // PULSEVIEW_PV_VIEWWIDGET_HPP