]> sigrok.org Git - pulseview.git/blobdiff - pv/view/selectableitem.cpp
RowItemPaintParams: Bundled scale and offset
[pulseview.git] / pv / view / selectableitem.cpp
index 3f4f6da92dbef767611c404c753210888b7247fe..b699005f4374a1e2bce16ecd872f033ae691c9ee 100644 (file)
@@ -18,7 +18,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-#include "selectableitem.h"
+#include "selectableitem.hpp"
+
+#include <climits>
 
 #include <QApplication>
 #include <QMenu>
@@ -30,24 +32,45 @@ namespace view {
 const int SelectableItem::HighlightRadius = 6;
 
 SelectableItem::SelectableItem() :
-       _context_parent(NULL),
-       _selected(false)
+       context_parent_(NULL),
+       selected_(false),
+       drag_point_(INT_MIN, INT_MIN)
 {
 }
 
 bool SelectableItem::selected() const
 {
-       return _selected;
+       return selected_;
 }
 
 void SelectableItem::select(bool select)
 {
-       _selected = select;
+       selected_ = select;
+}
+
+bool SelectableItem::dragging() const
+{
+       return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN;
+}
+
+QPoint SelectableItem::drag_point() const
+{
+       return drag_point_;
+}
+
+void SelectableItem::drag()
+{
+       drag_point_ = point();
+}
+
+void SelectableItem::drag_release()
+{
+       drag_point_ = QPoint(INT_MIN, INT_MIN);
 }
 
 QMenu* SelectableItem::create_context_menu(QWidget *parent)
 {
-       _context_parent = parent;
+       context_parent_ = parent;
        return new QMenu(parent);
 }