Slip Contents Drag: add ContentsDrag

This commit is contained in:
Ben Loftis 2021-06-15 09:06:28 -05:00
parent cc6b58ef00
commit fea3fb9e71
3 changed files with 54 additions and 1 deletions

View File

@ -675,6 +675,44 @@ RegionDrag::setup_video_sample_offset ()
_preview_video = true;
}
RegionContentsDrag::RegionContentsDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> 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<DraggingView>::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<RegionView*> const & v, bool b)
: RegionDrag (e, i, p, v)
, _brushing (b)

View File

@ -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<RegionView*> 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

View File

@ -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);