diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 26293a3ef6..420a9454b1 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -509,6 +509,7 @@ public: void make_region_markers_global (bool as_cd_markers); bool rb_click (GdkEvent*, Temporal::timepos_t const &); + void line_drag_click (GdkEvent*, Temporal::timepos_t const &, double); protected: void map_transport_state (); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index bd30be3e2e..337303960c 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -4938,8 +4938,8 @@ ControlPointDrag::active (Editing::MouseMode m) return dynamic_cast (&(_point->line ())) != 0; } -LineDrag::LineDrag (Editor& e, ArdourCanvas::Item* i) - : EditorDrag (e, i, e.time_domain (), e.get_trackview_group()) +LineDrag::LineDrag (EditingContext& e, ArdourCanvas::Item* i, std::function cf) + : Drag (e, i, e.time_domain (), e.get_trackview_group()) , _line (0) , _fixed_grab_x (0.0) , _fixed_grab_y (0.0) @@ -4947,6 +4947,7 @@ LineDrag::LineDrag (Editor& e, ArdourCanvas::Item* i) , _before (0) , _after (0) , have_command (false) + , click_functor (cf) { DEBUG_TRACE (DEBUG::Drags, "New LineDrag\n"); } @@ -5049,27 +5050,10 @@ LineDrag::finished (GdkEvent* event, bool movement_occurred) editing_context.commit_reversible_command (); have_command = false; } + } else { - /* add a new control point on the line */ - AutomationTimeAxisView* atv; - - if ((atv = dynamic_cast (_editor.clicked_axisview)) != 0) { - timepos_t where = grab_time (); - - double cx = 0; - double cy = _fixed_grab_y; - - _line->grab_item ().item_to_canvas (cx, cy); - - atv->add_automation_event (event, where, cy, false); - } else if (dynamic_cast (_editor.clicked_axisview) != 0) { - AudioRegionView* arv; - - if ((arv = dynamic_cast (_editor.clicked_regionview)) != 0) { - arv->add_gain_point_event (&arv->fx_line ()->grab_item (), event, false); - } - } + click_functor (event, grab_time(), _fixed_grab_y); } } diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 373b3c6d47..cd9a9fe879 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -1233,10 +1233,10 @@ private: }; /** Gain or automation line drag */ -class LineDrag : public EditorDrag +class LineDrag : public Drag { public: - LineDrag (Editor&e, ArdourCanvas::Item *i); + LineDrag (EditingContext &e, ArdourCanvas::Item *i, std::function); ~LineDrag (); void start_grab (GdkEvent *, Gdk::Cursor* c = 0); @@ -1257,6 +1257,7 @@ private: uint32_t _before; uint32_t _after; bool have_command; + std::function click_functor; }; /** Transient feature line drags*/ diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 14238d2bcc..ba1ab12800 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -848,7 +848,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT return true; case GainLineItem: - _drags->set (new LineDrag (*this, item), event); + _drags->set (new LineDrag (*this, item, [&](GdkEvent* ev,timepos_t const & pos, double y) { line_drag_click (ev, pos, y); }), event); return true; break; @@ -858,7 +858,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case EditorAutomationLineItem: - _drags->set (new LineDrag (*this, item), event); + _drags->set (new LineDrag (*this, item, [&](GdkEvent* ev,timepos_t const & pos, double y) { line_drag_click (ev, pos, y); }), event); return true; break; @@ -999,7 +999,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case EditorAutomationLineItem: - _drags->set (new LineDrag (*this, item), event); + _drags->set (new LineDrag (*this, item, [&](GdkEvent* ev,timepos_t const & pos, double y) { line_drag_click (ev, pos, y); }), event); return true; break; @@ -1062,7 +1062,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case MouseDraw: switch (item_type) { case GainLineItem: - _drags->set (new LineDrag (*this, item), event); + _drags->set (new LineDrag (*this, item, [&](GdkEvent* ev,timepos_t const & pos, double y) { line_drag_click (ev, pos, y); }), event); return true; case ControlPointItem: @@ -2617,3 +2617,22 @@ Editor::rb_click (GdkEvent* event, timepos_t const & where) return do_deselect; } + +void +Editor::line_drag_click (GdkEvent* event, timepos_t const & where, double y) +{ + AutomationTimeAxisView* atv; + + if ((atv = dynamic_cast (clicked_axisview)) != 0) { + + atv->add_automation_event (event, where, y, false); + + } else if (dynamic_cast (clicked_axisview) != 0) { + + AudioRegionView* arv; + + if ((arv = dynamic_cast (clicked_regionview)) != 0) { + arv->add_gain_point_event (&arv->fx_line ()->grab_item (), event, false); + } + } +} diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc index 3efa590564..7031991760 100644 --- a/gtk2_ardour/midi_cue_editor.cc +++ b/gtk2_ardour/midi_cue_editor.cc @@ -563,6 +563,13 @@ MidiCueEditor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event case EditorAutomationLineItem: { ARDOUR::SelectionOperation op = ArdourKeyboard::selection_type (event->button.state); select_automation_line (&event->button, item, op); + switch (mouse_mode) { + case Editing::MouseContent: + _drags->set (new LineDrag (*this, item, [&](GdkEvent* ev,timepos_t const & pos, double) { view->line_drag_click (ev, pos); }), event); + break; + default: + break; + } return true; } diff --git a/gtk2_ardour/midi_cue_view.cc b/gtk2_ardour/midi_cue_view.cc index 0e5b5887bc..62980b5313 100644 --- a/gtk2_ardour/midi_cue_view.cc +++ b/gtk2_ardour/midi_cue_view.cc @@ -318,3 +318,9 @@ MidiCueView::automation_rb_click (GdkEvent* event, Temporal::timepos_t const & p return false; } +void +MidiCueView::line_drag_click (GdkEvent* event, Temporal::timepos_t const & pos) +{ +} + + diff --git a/gtk2_ardour/midi_cue_view.h b/gtk2_ardour/midi_cue_view.h index a4ab5afea8..716d69dad4 100644 --- a/gtk2_ardour/midi_cue_view.h +++ b/gtk2_ardour/midi_cue_view.h @@ -60,6 +60,7 @@ class MidiCueView : public MidiView MergeableLine* make_merger (); bool automation_rb_click (GdkEvent*, Temporal::timepos_t const &); + void line_drag_click (GdkEvent*, Temporal::timepos_t const &); protected: bool scroll (GdkEventScroll* ev);