Fix some bugs in autoscroll when dragging regions.

git-svn-id: svn://localhost/ardour2/branches/3.0@6460 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-01-06 01:14:56 +00:00
parent b66dfe0eea
commit e2981526ea
3 changed files with 30 additions and 6 deletions

View File

@ -551,7 +551,7 @@ void
Editor::maybe_autoscroll (GdkEventMotion* event, bool allow_vert)
{
nframes64_t rightmost_frame = leftmost_frame + current_page_frames();
nframes64_t frame = _drag->adjusted_current_frame (0);
pair<nframes64_t, nframes64_t> frames = _drag->extent ();
bool startit = false;
autoscroll_y = 0;
@ -564,14 +564,14 @@ Editor::maybe_autoscroll (GdkEventMotion* event, bool allow_vert)
startit = true;
}
if (frame > rightmost_frame) {
if (frames.second > rightmost_frame) {
if (rightmost_frame < max_frames) {
autoscroll_x = 1;
startit = true;
}
} else if (frame < leftmost_frame) {
} else if (frames.first < leftmost_frame) {
if (leftmost_frame > 0) {
autoscroll_x = -1;
startit = true;
@ -613,10 +613,13 @@ Editor::autoscroll_canvas ()
assert (_drag);
if (autoscroll_x_distance != 0) {
pair<nframes64_t, nframes64_t> const e = _drag->extent ();
if (autoscroll_x > 0) {
autoscroll_x_distance = (unit_to_frame (_drag->current_pointer_x()) - (leftmost_frame + current_page_frames())) / 3;
autoscroll_x_distance = (e.second - (leftmost_frame + current_page_frames())) / 3;
} else if (autoscroll_x < 0) {
autoscroll_x_distance = (leftmost_frame - unit_to_frame (_drag->current_pointer_x())) / 3;
autoscroll_x_distance = (leftmost_frame - e.first) / 3;
}
}
@ -702,7 +705,7 @@ Editor::autoscroll_canvas ()
Gdk::ModifierType mask;
canvas_window->get_pointer (x, y, mask);
ev.type = GDK_MOTION_NOTIFY;
ev.state &= Gdk::BUTTON1_MASK;
ev.state = Gdk::BUTTON1_MASK;
ev.x = x;
ev.y = y;

View File

@ -242,6 +242,12 @@ Drag::break_drag ()
}
}
pair<nframes64_t, nframes64_t>
Drag::extent () const
{
nframes64_t const f = adjusted_current_frame (0);
return make_pair (f, f);
}
RegionDrag::RegionDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v)
: Drag (e, i),
@ -257,6 +263,14 @@ RegionDrag::region_going_away (RegionView* v)
_views.remove (v);
}
pair<nframes64_t, nframes64_t>
RegionDrag::extent () const
{
nframes64_t const f = adjusted_current_frame (0);
return make_pair (f, f + _primary->region()->length ());
}
RegionMotionDrag::RegionMotionDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v, bool b)
: RegionDrag (e, i, p, v),
_dest_trackview (0),

View File

@ -120,6 +120,11 @@ public:
return true;
}
/** @return current x extent of the thing being dragged; ie
* a pair of (leftmost_position, rightmost_position)
*/
virtual std::pair<nframes64_t, nframes64_t> extent () const;
protected:
double grab_x () const {
@ -180,6 +185,8 @@ public:
RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
virtual ~RegionDrag () {}
std::pair<nframes64_t, nframes64_t> extent () const;
protected:
RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag