projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c3bb03f
)
ViewItem: Use drag_point() with drag_by()
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Sun, 28 Dec 2014 18:33:51 +0000
(18:33 +0000)
committer
Joel Holdsworth
<joel@airwebreathe.org.uk>
Mon, 29 Dec 2014 11:56:00 +0000
(11:56 +0000)
pv/view/header.cpp
patch
|
blob
|
history
pv/view/rowitem.cpp
patch
|
blob
|
history
pv/view/rowitem.hpp
patch
|
blob
|
history
pv/view/ruler.cpp
patch
|
blob
|
history
pv/view/timeitem.cpp
patch
|
blob
|
history
pv/view/timeitem.hpp
patch
|
blob
|
history
pv/view/viewitem.cpp
patch
|
blob
|
history
pv/view/viewitem.hpp
patch
|
blob
|
history
diff --git
a/pv/view/header.cpp
b/pv/view/header.cpp
index c19d10883af7fed3c77e3ee60d0f497faadb2958..77ac1aa88c343498bfcaf57939b4f0995862b54a 100644
(file)
--- a/
pv/view/header.cpp
+++ b/
pv/view/header.cpp
@@
-247,11
+247,11
@@
void Header::mouseMoveEvent(QMouseEvent *event)
// Do the drag
dragging_ = true;
// Do the drag
dragging_ = true;
- const
int delta = event->pos().y() - mouse_down_point_.y()
;
+ const
QPoint delta = event->pos() - mouse_down_point_
;
for (std::shared_ptr<RowItem> r : view_)
if (r->dragging()) {
for (std::shared_ptr<RowItem> r : view_)
if (r->dragging()) {
- r->
force_to_v_offset(r->drag_point().y() +
delta);
+ r->
drag_by(
delta);
// Ensure the trace is selected
r->select();
// Ensure the trace is selected
r->select();
diff --git
a/pv/view/rowitem.cpp
b/pv/view/rowitem.cpp
index 861d4adf05d28763640c12a2dac1a27d4f308f4c..2e693dd97ade70706e18bd90e2156b34787f9766 100644
(file)
--- a/
pv/view/rowitem.cpp
+++ b/
pv/view/rowitem.cpp
@@
-115,6
+115,12
@@
int RowItem::get_visual_y() const
return visual_v_offset_ + owner_->owner_visual_v_offset();
}
return visual_v_offset_ + owner_->owner_visual_v_offset();
}
+void RowItem::drag_by(const QPoint &delta)
+{
+ force_to_v_offset(drag_point_.y() + delta.y() -
+ owner_->owner_visual_v_offset());
+}
+
QPoint RowItem::point(const QRect &rect) const
{
return QPoint(rect.right(), get_visual_y());
QPoint RowItem::point(const QRect &rect) const
{
return QPoint(rect.right(), get_visual_y());
diff --git
a/pv/view/rowitem.hpp
b/pv/view/rowitem.hpp
index 3f2afbc3821c9598b04f3d8bf5dbc04e81d72143..023e2c3807b2c2d4e61bc6dd78e96591d9607cec 100644
(file)
--- a/
pv/view/rowitem.hpp
+++ b/
pv/view/rowitem.hpp
@@
-93,6
+93,12
@@
public:
*/
int get_visual_y() const;
*/
int get_visual_y() const;
+ /**
+ * Drags the item to a delta relative to the drag point.
+ * @param delta the offset from the drag point.
+ */
+ void drag_by(const QPoint &delta);
+
/**
* Gets the arrow-tip point of the row item marker.
* @param rect the rectangle of the header area.
/**
* Gets the arrow-tip point of the row item marker.
* @param rect the rectangle of the header area.
diff --git
a/pv/view/ruler.cpp
b/pv/view/ruler.cpp
index bcf6a5281d494195b97bfc6c152dfc59227453f1..47da23a8b78e21a9e5f7725ca533f64d472897ad 100644
(file)
--- a/
pv/view/ruler.cpp
+++ b/
pv/view/ruler.cpp
@@
-171,13
+171,11
@@
void Ruler::mouseMoveEvent(QMouseEvent *e)
// Do the drag
dragging_ = true;
// Do the drag
dragging_ = true;
- const
int delta = e->pos().x() - mouse_down_point_.x()
;
+ const
QPoint delta = e->pos() - mouse_down_point_
;
const vector< shared_ptr<TimeItem> > items(view_.time_items());
for (auto &i : items)
if (i->dragging())
const vector< shared_ptr<TimeItem> > items(view_.time_items());
for (auto &i : items)
if (i->dragging())
- i->set_time(view_.offset() +
- (i->drag_point().x() + delta - 0.5) *
- view_.scale());
+ i->drag_by(delta);
}
void Ruler::mousePressEvent(QMouseEvent *e)
}
void Ruler::mousePressEvent(QMouseEvent *e)
diff --git
a/pv/view/timeitem.cpp
b/pv/view/timeitem.cpp
index dabdd5f137fc45c39e204d354e831554afcc421a..ec8dd1a49f5c0abc81d68e5e4845f873e3fa4b5a 100644
(file)
--- a/
pv/view/timeitem.cpp
+++ b/
pv/view/timeitem.cpp
@@
-19,6
+19,7
@@
*/
#include "timeitem.hpp"
*/
#include "timeitem.hpp"
+#include "view.hpp"
namespace pv {
namespace view {
namespace pv {
namespace view {
@@
-27,5
+28,11
@@
TimeItem::TimeItem(View &view) :
view_(view) {
}
view_(view) {
}
+void TimeItem::drag_by(const QPoint &delta)
+{
+ set_time(view_.offset() + (drag_point_.x() + delta.x() - 0.5) *
+ view_.scale());
+}
+
} // namespace view
} // namespace pv
} // namespace view
} // namespace pv
diff --git
a/pv/view/timeitem.hpp
b/pv/view/timeitem.hpp
index f988488409c18426aebab42b720dab2d54731987..ba4ce8b6d69799a8d1b828461c738435e5b0e988 100644
(file)
--- a/
pv/view/timeitem.hpp
+++ b/
pv/view/timeitem.hpp
@@
-48,6
+48,12
@@
public:
virtual float get_x() const = 0;
virtual float get_x() const = 0;
+ /**
+ * Drags the item to a delta relative to the drag point.
+ * @param delta the offset from the drag point.
+ */
+ void drag_by(const QPoint &delta);
+
protected:
View &view_;
};
protected:
View &view_;
};
diff --git
a/pv/view/viewitem.cpp
b/pv/view/viewitem.cpp
index 6917190a46dbd8e60554cc241219a2fc62de4743..02a9c6a2f39d8deb9dcb0e0c4d3f11e1b1f16a93 100644
(file)
--- a/
pv/view/viewitem.cpp
+++ b/
pv/view/viewitem.cpp
@@
-34,8
+34,8
@@
const int ViewItem::HighlightRadius = 3;
ViewItem::ViewItem() :
context_parent_(NULL),
ViewItem::ViewItem() :
context_parent_(NULL),
-
selected_(false
),
-
drag_point_(INT_MIN, INT_MIN
)
+
drag_point_(INT_MIN, INT_MIN
),
+
selected_(false
)
{
}
{
}
@@
-54,11
+54,6
@@
bool ViewItem::dragging() const
return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN;
}
return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN;
}
-QPoint ViewItem::drag_point() const
-{
- return drag_point_;
-}
-
void ViewItem::drag()
{
drag_point_ = point(QRect());
void ViewItem::drag()
{
drag_point_ = point(QRect());
diff --git
a/pv/view/viewitem.hpp
b/pv/view/viewitem.hpp
index 11efbc0cdd1f7bd79855b7fe4c77cc67583f8922..eb0823e47e8f1b55b897597a0c8bf14a0b960742 100644
(file)
--- a/
pv/view/viewitem.hpp
+++ b/
pv/view/viewitem.hpp
@@
-71,11
+71,6
@@
public:
*/
bool dragging() const;
*/
bool dragging() const;
- /**
- * Retunrns the current drag point.
- */
- QPoint drag_point() const;
-
/**
* Sets this item into the dragged state.
*/
/**
* Sets this item into the dragged state.
*/
@@
-86,6
+81,12
@@
public:
*/
void drag_release();
*/
void drag_release();
+ /**
+ * Drags the item to a delta relative to the drag point.
+ * @param delta the offset from the drag point.
+ */
+ virtual void drag_by(const QPoint &delta) = 0;
+
/**
* Get the drag point.
* @param rect the rectangle of the widget area.
/**
* Get the drag point.
* @param rect the rectangle of the widget area.
@@
-149,10
+150,10
@@
protected:
protected:
QWidget *context_parent_;
protected:
QWidget *context_parent_;
+ QPoint drag_point_;
private:
bool selected_;
private:
bool selected_;
- QPoint drag_point_;
};
} // namespace view
};
} // namespace view