diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-02-13 16:13:12 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-02-13 16:22:08 -0500 |
commit | 6f98f91f18869a6536ec38218862151e16c00ff9 (patch) | |
tree | 8c586c3e086b4d580e22b7e510a992920ab7f97e /gtk2_ardour/editor_drag.cc | |
parent | 456374c99564f7e1eefcf8572e6180ee01ef9b27 (diff) |
prevent fade in/fade out on audio regions from overlapping each other
Diffstat (limited to 'gtk2_ardour/editor_drag.cc')
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 497baf5896..bdd93efe7d 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3061,12 +3061,12 @@ FadeInDrag::motion (GdkEvent* event, bool) framepos_t const pos = adjusted_current_frame (event); - boost::shared_ptr<Region> region = _primary->region (); + boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (_primary->region ()); if (pos < (region->position() + 64)) { fade_length = 64; // this should be a minimum defined somewhere - } else if (pos > region->last_frame()) { - fade_length = region->length(); + } else if (pos > region->length() - region->fade_out()->back()->when) { + fade_length = region->length() - region->fade_out()->back()->when - 1; } else { fade_length = pos - region->position(); } @@ -3096,12 +3096,12 @@ FadeInDrag::finished (GdkEvent* event, bool movement_occurred) framepos_t const pos = adjusted_current_frame (event); - boost::shared_ptr<Region> region = _primary->region (); + boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (_primary->region ()); if (pos < (region->position() + 64)) { fade_length = 64; // this should be a minimum defined somewhere - } else if (pos > region->last_frame()) { - fade_length = region->length(); + } else if (pos >= region->length() - region->fade_out()->back()->when) { + fade_length = region->length() - region->fade_out()->back()->when - 1; } else { fade_length = pos - region->position(); } @@ -3175,16 +3175,14 @@ FadeOutDrag::motion (GdkEvent* event, bool) framepos_t const pos = adjusted_current_frame (event); - boost::shared_ptr<Region> region = _primary->region (); + boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (_primary->region ()); if (pos > (region->last_frame() - 64)) { fade_length = 64; // this should really be a minimum fade defined somewhere - } - else if (pos < region->position()) { - fade_length = region->length(); - } - else { - fade_length = region->last_frame() - pos; + } else if (pos <= region->fade_in()->back()->when) { + fade_length = region->length() - region->fade_in()->back()->when - 1; + } else { + fade_length = region->length() - pos; } for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) { @@ -3212,16 +3210,14 @@ FadeOutDrag::finished (GdkEvent* event, bool movement_occurred) framepos_t const pos = adjusted_current_frame (event); - boost::shared_ptr<Region> region = _primary->region (); + boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (_primary->region ()); if (pos > (region->last_frame() - 64)) { fade_length = 64; // this should really be a minimum fade defined somewhere - } - else if (pos < region->position()) { - fade_length = region->length(); - } - else { - fade_length = region->last_frame() - pos; + } else if (pos <= region->fade_in()->back()->when) { + fade_length = region->length() - region->fade_in()->back()->when - 1; + } else { + fade_length = region->length() - pos; } _editor->begin_reversible_command (_("change fade out length")); |