]> sigrok.org Git - pulseview.git/commitdiff
MarginWidget: Moved in dragging_, mouse_point_, and mouse_down_point_
authorJoel Holdsworth <redacted>
Tue, 9 Dec 2014 00:13:50 +0000 (00:13 +0000)
committerUwe Hermann <redacted>
Wed, 10 Dec 2014 17:06:16 +0000 (18:06 +0100)
pv/view/cursorheader.cpp
pv/view/cursorheader.hpp
pv/view/header.cpp
pv/view/header.hpp
pv/view/marginwidget.cpp
pv/view/marginwidget.hpp

index e308867cfd9f0335850a83b309ae563ce9b810a8..f79a5785d558f56b54a60b37605614d08f9b16c9 100644 (file)
@@ -47,7 +47,6 @@ int CursorHeader::calculateTextHeight()
 
 CursorHeader::CursorHeader(View &parent) :
        MarginWidget(parent),
-       dragging_(false),
        textHeight_(calculateTextHeight())
 {
        setMouseTracking(true);
@@ -84,6 +83,8 @@ void CursorHeader::paintEvent(QPaintEvent*)
 
 void CursorHeader::mouseMoveEvent(QMouseEvent *e)
 {
+       mouse_point_ = e->pos();
+
        if (!(e->buttons() & Qt::LeftButton))
                return;
 
@@ -149,5 +150,11 @@ void CursorHeader::mouseReleaseEvent(QMouseEvent *)
                i->drag_release();
 }
 
+void CursorHeader::leaveEvent(QEvent*)
+{
+       mouse_point_ = QPoint(-1, -1);
+       update();
+}
+
 } // namespace view
 } // namespace pv
index f37112ec755aa57ab2d4df3434c514f631a3d332..5ae2a253fc6afcf0d556bd64d65eb5c8c37ea4c9 100644 (file)
@@ -58,12 +58,11 @@ private:
        void mouseMoveEvent(QMouseEvent *e);
        void mousePressEvent(QMouseEvent *e);
        void mouseReleaseEvent(QMouseEvent *);
+       void leaveEvent(QEvent*);
 
        int calculateTextHeight();
 
-       QPoint mouse_down_point_;
        std::shared_ptr<TimeItem> mouse_down_item_;
-       bool dragging_;
        const int textHeight_;
 };
 
index 4da188af70d916564d43b59264e490f81a67bbcb..837d1916c72a69f10e8e460cbc2296c2cc88408d 100644 (file)
@@ -60,8 +60,7 @@ static bool item_selected(shared_ptr<RowItem> r)
 }
 
 Header::Header(View &parent) :
-       MarginWidget(parent),
-       dragging_(false)
+       MarginWidget(parent)
 {
        setFocusPolicy(Qt::ClickFocus);
        setMouseTracking(true);
index 662e19f2ed5027d773d55a1badc9ff7a81a0c48e..ae39bc847490357877ed380ec99456073f849a1f 100644 (file)
@@ -88,10 +88,7 @@ Q_SIGNALS:
        void signals_moved();
 
 private:
-       QPoint mouse_point_;
-       QPoint mouse_down_point_;
        std::shared_ptr<RowItem> mouse_down_item_;
-       bool dragging_;
 };
 
 } // namespace view
index f3abe361feedae833531f7d54529f9e902c4a3bd..e44233c80291c8a1cb1bdd2a5078ef9d505d6211 100644 (file)
@@ -27,7 +27,8 @@ namespace view {
 
 MarginWidget::MarginWidget(View &parent) :
        QWidget(&parent),
-       view_(parent)
+       view_(parent),
+       dragging_(false)
 {
        setAttribute(Qt::WA_NoSystemBackground, true);
 }
index 9ff4276b0dd6dc173400d171d811624198381c49..b4f0eb72c45e84abc4703a5b3e46f8031aca7e0a 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef PULSEVIEW_PV_MARGINWIDGET_H
 #define PULSEVIEW_PV_MARGINWIDGET_H
 
+#include <QPoint>
 #include <QWidget>
 
 namespace pv {
@@ -43,6 +44,9 @@ Q_SIGNALS:
 
 protected:
        pv::view::View &view_;
+       QPoint mouse_point_;
+       QPoint mouse_down_point_;
+       bool dragging_;
 };
 
 } // namespace view