diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index f08fdb3d50..7026755bb3 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -7242,28 +7242,50 @@ LollipopDrag::setup_pointer_offset () _pointer_offset = _region->parent_rv.region()->source_beats_to_absolute_time (note->note()->time ()).distance (raw_grab_time ()); } -AutomationDrawDrag::AutomationDrawDrag (Editor* editor, ArdourCanvas::Item* i, Temporal::TimeDomain time_domain) - : Drag (editor, i, time_domain) +AutomationDrawDrag::AutomationDrawDrag (Editor* editor, ArdourCanvas::Rectangle& r, Temporal::TimeDomain time_domain) + : Drag (editor, &r, time_domain) + , base_rect (r) + , dragging_line (nullptr) { + DEBUG_TRACE (DEBUG::Drags, "New AutomationDrawDrag\n"); } AutomationDrawDrag::~AutomationDrawDrag () { + delete dragging_line; } void -AutomationDrawDrag::start_grab (GdkEvent*, Gdk::Cursor* c) +AutomationDrawDrag::start_grab (GdkEvent* ev, Gdk::Cursor* c) { + Drag::start_grab (ev, c); } void -AutomationDrawDrag::motion (GdkEvent*, bool) +AutomationDrawDrag::motion (GdkEvent* ev, bool first_move) { + if (first_move) { + dragging_line = new ArdourCanvas::PolyLine (item()); + dragging_line->set_ignore_events (true); + dragging_line->set_outline_color (UIConfiguration::instance().color ("midi note selected outline")); + } + + ArdourCanvas::Rect r = base_rect.item_to_canvas (base_rect.get()); + + dragging_line->add_point (ArdourCanvas::Duple (ev->motion.x - r.x0, ev->motion.y - r.y0)); } void -AutomationDrawDrag::finished (GdkEvent*, bool) +AutomationDrawDrag::finished (GdkEvent* event, bool motion_occured) { + std::cerr << "ADD finished, mo " << motion_occured << std::endl; + + if (!motion_occured) { + /* DragManager will tell editor that no motion happened, and + Editor::button_release_handler() will do the right thing. + */ + return; + } } void @@ -7272,8 +7294,3 @@ AutomationDrawDrag::aborted (bool) } -void -AutomationDrawDrag::setup_pointer_sample_offset () -{ -} - diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 53098e27ab..969b3ba405 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -1582,7 +1582,7 @@ class LollipopDrag : public Drag class AutomationDrawDrag : public Drag { public: - AutomationDrawDrag (Editor*, ArdourCanvas::Item*, Temporal::TimeDomain); + AutomationDrawDrag (Editor*, ArdourCanvas::Rectangle&, Temporal::TimeDomain); ~AutomationDrawDrag (); void start_grab (GdkEvent *, Gdk::Cursor* c = 0); @@ -1590,7 +1590,9 @@ class AutomationDrawDrag : public Drag void finished (GdkEvent*, bool); void aborted (bool); - void setup_pointer_sample_offset (); +private: + ArdourCanvas::Rectangle& base_rect; /* we do not own this */ + ArdourCanvas::PolyLine* dragging_line; }; #endif /* __gtk2_ardour_editor_drag_h_ */ diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index e7d0ae4c80..e331f54120 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -1324,6 +1324,15 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; } + case AutomationTrackItem: + { + AutomationTimeAxisView* atv = static_cast (item->get_data ("trackview")); + if (atv) { + _drags->set (new AutomationDrawDrag (this, atv->base_item(), Temporal::AudioTime), event); + } + } + break; + case AutomationLineItem: _drags->set (new LineDrag (this, item), event); break;