From fea3fb9e71b7ba1d7d1933609ecfe5669ba47735 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Tue, 15 Jun 2021 09:06:28 -0500 Subject: [PATCH] Slip Contents Drag: add ContentsDrag --- gtk2_ardour/editor_drag.cc | 38 +++++++++++++++++++++++++++++++++++++ gtk2_ardour/editor_drag.h | 13 +++++++++++++ gtk2_ardour/editor_mouse.cc | 4 +++- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index cd6dbbefc5..7efc37c620 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -675,6 +675,44 @@ RegionDrag::setup_video_sample_offset () _preview_video = true; } +RegionContentsDrag::RegionContentsDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list const & v) + : RegionDrag (e, i, p, v) +{ + DEBUG_TRACE (DEBUG::Drags, "New RegionContentsDrag\n"); +} + +void +RegionContentsDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) +{ + Drag::start_grab (event, _editor->cursors()->trimmer); +} + +void +RegionContentsDrag::motion (GdkEvent* event, bool first_move) +{ + if (first_move) { + _editor->begin_reversible_command (_("Region content trim")); + } else { + for (list::iterator i = _views.begin(); i != _views.end(); ++i) { + RegionView* rv = i->view; + samplecnt_t slippage = (last_pointer_sample() - adjusted_current_sample(event, false)); + rv->move_contents (slippage); + } + show_verbose_cursor_time (_primary->region()->start ()); + } +} + +void +RegionContentsDrag::finished (GdkEvent *, bool) +{ +} + +void +RegionContentsDrag::aborted (bool) +{ +} + + RegionMotionDrag::RegionMotionDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list const & v, bool b) : RegionDrag (e, i, p, v) , _brushing (b) diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 8cd67117c3..aeb5bc3fbb 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -371,6 +371,19 @@ private: PBD::ScopedConnection death_connection; }; +/** Drag the Contents rather than the bounds of a region (i.e. Slip) */ +class RegionContentsDrag : public RegionDrag +{ +public: + + RegionContentsDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list const &); + virtual ~RegionContentsDrag () {} + + virtual void start_grab (GdkEvent *, Gdk::Cursor *); + virtual void motion (GdkEvent *, bool); + virtual void finished (GdkEvent *, bool); + virtual void aborted (bool); +}; /** Drags involving region motion from somewhere */ class RegionMotionDrag : public RegionDrag diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 117fa5b840..655a2aca0e 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -1061,7 +1061,9 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT } /* click on a normal region view */ - if (ArdourKeyboard::indicates_copy (event->button.state)) { + if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::trim_contents_modifier ())) { + _drags->add (new RegionContentsDrag (this, item, clicked_regionview, selection->regions.by_layer())); + } else if (ArdourKeyboard::indicates_copy (event->button.state)) { add_region_copy_drag (item, event, clicked_regionview); } else if (Keyboard::the_keyboard().key_is_down (GDK_b)) { add_region_brush_drag (item, event, clicked_regionview);