]> sigrok.org Git - pulseview.git/blobdiff - pv/view/selectableitem.cpp
CursorHeader: Made drag position pixel perfect
[pulseview.git] / pv / view / selectableitem.cpp
index 31c45ef3b166fa9ff4f85894edc304d761b1ad72..6921f19a71c27b02d2ecaaa5dc2abaf39fea3a87 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,27 +32,52 @@ 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);
 }
 
+void SelectableItem::delete_pressed()
+{
+}
+
 QPen SelectableItem::highlight_pen()
 {
        return QPen(QApplication::palette().brush(
@@ -58,5 +85,10 @@ QPen SelectableItem::highlight_pen()
                Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
 }
 
+QColor SelectableItem::select_text_colour(QColor background)
+{
+       return (background.lightness() > 64) ? Qt::black : Qt::white;
+}
+
 } // namespace view
 } // namespace pv