diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 2b6b7eedee..32cddae706 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -791,7 +791,7 @@ AutomationTimeAxisView::build_display_menu () } void -AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points, bool thin) +AutomationTimeAxisView::merge_drawn_line (Evoral::ControlList::OrderedPoints& points, bool thin) { if (points.empty()) { return; @@ -820,21 +820,23 @@ AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points, bool thin) swap (earliest, latest); } - list->erase_range (earliest, latest);; - - for (auto const & dp : points) { + /* Convert each point's "value" from geometric coordinate space to + * value space for the control + */ + for (auto & dp : points) { /* compute vertical fractional position */ - double y = 1.0 - (dp.y / _line->height()); + dp.value = 1.0 - (dp.value / _line->height()); /* map using line */ - _line->view_to_model_coord_y (y); - - list->editor_add (dp.when, y, false); + _line->view_to_model_coord_y (dp.value); } + list->freeze (); + list->editor_add_ordered (points, false); if (thin) { list->thin (50.0); } + list->thaw (); if (_control->automation_state () == ARDOUR::Off) { set_automation_state (ARDOUR::Play); @@ -844,7 +846,6 @@ AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points, bool thin) RouteTimeAxisView::signal_ctrl_touched (false); } - XMLNode& after = list->get_state(); _editor.begin_reversible_command (_("draw automation")); _session->add_command (new MementoCommand (*list.get (), &before, &after)); diff --git a/gtk2_ardour/automation_time_axis.h b/gtk2_ardour/automation_time_axis.h index e78d7c9202..8fea40341d 100644 --- a/gtk2_ardour/automation_time_axis.h +++ b/gtk2_ardour/automation_time_axis.h @@ -147,14 +147,7 @@ public: void set_selected_regionviews (RegionSelection&); - struct DrawnPoint { - DrawnPoint (Temporal::timepos_t w, double v) : when (w), y (v) {} - Temporal::timepos_t when; - double y; - }; - - typedef std::vector DrawnPoints; - void merge_drawn_line (DrawnPoints const &, bool thin); + void merge_drawn_line (Evoral::ControlList::OrderedPoints&, bool thin); protected: /* Note that for MIDI controller "automation" (in regions), all of these diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index d1bf276c64..65b79d3173 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -7258,12 +7258,6 @@ AutomationDrawDrag::~AutomationDrawDrag () delete dragging_line; } -void -AutomationDrawDrag::start_grab (GdkEvent* ev, Gdk::Cursor* c) -{ - Drag::start_grab (ev, c); -} - void AutomationDrawDrag::motion (GdkEvent* ev, bool first_move) { @@ -7278,10 +7272,19 @@ AutomationDrawDrag::motion (GdkEvent* ev, bool first_move) direction = -1; } - edge_x = grab_x (); + /* Add a point correspding to the start of the drag */ + + maybe_add_point (ev, raw_grab_time()); } - timepos_t pos (_drags->current_pointer_time ()); + maybe_add_point (ev, _drags->current_pointer_time()); +} + +void +AutomationDrawDrag::maybe_add_point (GdkEvent* ev, timepos_t const & cpos) +{ + timepos_t pos (cpos); + _editor->snap_to_with_modifier (pos, ev); if (pos != _drags->current_pointer_time()) { @@ -7333,7 +7336,7 @@ AutomationDrawDrag::motion (GdkEvent* ev, bool first_move) if (add_point) { if (drawn_points.empty() || (pos != drawn_points.back().when)) { dragging_line->add_point (ArdourCanvas::Duple (x, y)); - drawn_points.push_back (AutomationTimeAxisView::DrawnPoint (pos, y)); + drawn_points.push_back (Evoral::ControlList::OrderedPoint (pos, y)); } edge_x = x; } diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 9b019078fc..216b413abd 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -35,11 +35,12 @@ #include "ardour/tempo.h" #include "ardour/types.h" +#include "evoral/ControlList.h" + #include "canvas/types.h" #include "gtkmm2ext/bindings.h" -#include "automation_time_axis.h" #include "cursor_context.h" #include "editor_items.h" #include "mouse_cursors.h" @@ -1586,7 +1587,6 @@ class AutomationDrawDrag : public Drag AutomationDrawDrag (Editor*, ArdourCanvas::Rectangle&, Temporal::TimeDomain); ~AutomationDrawDrag (); - void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent*, bool); void finished (GdkEvent*, bool); void aborted (bool); @@ -1596,8 +1596,10 @@ private: ArdourCanvas::PolyLine* dragging_line; int direction; int edge_x; - AutomationTimeAxisView::DrawnPoints drawn_points; + Evoral::ControlList::OrderedPoints drawn_points; bool did_snap; + + void maybe_add_point (GdkEvent*, Temporal::timepos_t const &); }; #endif /* __gtk2_ardour_editor_drag_h_ */