2014-06-03 16:37:53 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2009 Paul Davis
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
#ifdef WAF_BUILD
|
|
|
|
#include "gtk2ardour-config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-01-15 17:47:56 -05:00
|
|
|
#include <stdint.h>
|
2013-03-27 13:45:08 -04:00
|
|
|
#include <algorithm>
|
2010-09-26 09:33:39 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
#include "pbd/memento_command.h"
|
|
|
|
#include "pbd/basename.h"
|
2010-02-09 09:44:01 -05:00
|
|
|
#include "pbd/stateful_diff_command.h"
|
2010-09-26 09:33:39 -04:00
|
|
|
|
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
2012-07-10 00:05:48 -04:00
|
|
|
#include "ardour/audioengine.h"
|
2011-10-19 17:53:09 -04:00
|
|
|
#include "ardour/audioregion.h"
|
2014-05-17 15:51:08 -04:00
|
|
|
#include "ardour/audio_track.h"
|
2009-05-30 14:25:59 -04:00
|
|
|
#include "ardour/dB.h"
|
2011-10-19 17:53:09 -04:00
|
|
|
#include "ardour/midi_region.h"
|
2014-05-17 15:51:08 -04:00
|
|
|
#include "ardour/midi_track.h"
|
2011-01-19 12:38:56 -05:00
|
|
|
#include "ardour/operations.h"
|
2011-10-19 17:53:09 -04:00
|
|
|
#include "ardour/region_factory.h"
|
|
|
|
#include "ardour/session.h"
|
2011-01-19 12:38:56 -05:00
|
|
|
|
2014-07-08 21:37:49 -04:00
|
|
|
#include "canvas/canvas.h"
|
2014-06-03 15:57:56 -04:00
|
|
|
#include "canvas/scroll_group.h"
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
#include "editor.h"
|
|
|
|
#include "i18n.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "audio_region_view.h"
|
2015-01-13 23:30:37 -05:00
|
|
|
#include "automation_region_view.h"
|
2009-05-30 14:25:59 -04:00
|
|
|
#include "midi_region_view.h"
|
|
|
|
#include "ardour_ui.h"
|
2009-12-21 13:23:07 -05:00
|
|
|
#include "gui_thread.h"
|
2009-05-30 14:25:59 -04:00
|
|
|
#include "control_point.h"
|
|
|
|
#include "region_gain_line.h"
|
|
|
|
#include "editor_drag.h"
|
2009-06-08 15:28:51 -04:00
|
|
|
#include "audio_time_axis.h"
|
|
|
|
#include "midi_time_axis.h"
|
2009-09-08 22:09:04 -04:00
|
|
|
#include "selection.h"
|
|
|
|
#include "midi_selection.h"
|
2010-01-01 17:11:15 -05:00
|
|
|
#include "automation_time_axis.h"
|
2010-09-09 17:34:45 -04:00
|
|
|
#include "debug.h"
|
2010-11-16 09:53:16 -05:00
|
|
|
#include "editor_cursors.h"
|
|
|
|
#include "mouse_cursors.h"
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "note_base.h"
|
|
|
|
#include "patch_change.h"
|
2011-05-02 09:38:16 -04:00
|
|
|
#include "verbose_cursor.h"
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Gtk;
|
2010-09-26 09:33:39 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2009-05-30 14:25:59 -04:00
|
|
|
using namespace Editing;
|
2009-10-06 18:07:10 -04:00
|
|
|
using namespace ArdourCanvas;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2009-12-04 17:51:32 -05:00
|
|
|
using Gtkmm2ext::Keyboard;
|
|
|
|
|
2011-06-19 19:02:55 -04:00
|
|
|
double ControlPointDrag::_zero_gain_fraction = -1.0;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
DragManager::DragManager (Editor* e)
|
|
|
|
: _editor (e)
|
|
|
|
, _ending (false)
|
|
|
|
, _current_pointer_frame (0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DragManager::~DragManager ()
|
|
|
|
{
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
|
2010-05-05 18:09:07 -04:00
|
|
|
/** Call abort for each active drag */
|
2010-01-12 11:14:49 -05:00
|
|
|
void
|
|
|
|
DragManager::abort ()
|
|
|
|
{
|
|
|
|
_ending = true;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-07-07 08:26:37 -04:00
|
|
|
cerr << "Aborting drag\n";
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
for (list<Drag*>::const_iterator i = _drags.begin(); i != _drags.end(); ++i) {
|
2010-05-05 18:09:07 -04:00
|
|
|
(*i)->abort ();
|
2010-01-12 11:14:49 -05:00
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
|
2011-05-17 11:28:12 -04:00
|
|
|
if (!_drags.empty ()) {
|
|
|
|
_editor->set_follow_playhead (_old_follow_playhead, false);
|
|
|
|
}
|
2010-01-12 11:14:49 -05:00
|
|
|
|
2011-05-17 11:28:12 -04:00
|
|
|
_drags.clear ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
_ending = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DragManager::add (Drag* d)
|
|
|
|
{
|
|
|
|
d->set_manager (this);
|
|
|
|
_drags.push_back (d);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DragManager::set (Drag* d, GdkEvent* e, Gdk::Cursor* c)
|
|
|
|
{
|
|
|
|
d->set_manager (this);
|
|
|
|
_drags.push_back (d);
|
2010-08-18 14:06:31 -04:00
|
|
|
start_grab (e, c);
|
2010-01-12 11:14:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-08-18 14:06:31 -04:00
|
|
|
DragManager::start_grab (GdkEvent* e, Gdk::Cursor* c)
|
2010-01-12 11:14:49 -05:00
|
|
|
{
|
2011-01-04 21:28:28 -05:00
|
|
|
/* Prevent follow playhead during the drag to be nice to the user */
|
|
|
|
_old_follow_playhead = _editor->follow_playhead ();
|
|
|
|
_editor->set_follow_playhead (false);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-02-26 08:43:53 -05:00
|
|
|
_current_pointer_frame = _editor->canvas_event_sample (e, &_current_pointer_x, &_current_pointer_y);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
for (list<Drag*>::const_iterator i = _drags.begin(); i != _drags.end(); ++i) {
|
2010-08-18 14:06:31 -04:00
|
|
|
(*i)->start_grab (e, c);
|
2010-01-12 11:14:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-05 18:09:07 -04:00
|
|
|
/** Call end_grab for each active drag.
|
|
|
|
* @return true if any drag reported movement having occurred.
|
|
|
|
*/
|
2010-01-12 11:14:49 -05:00
|
|
|
bool
|
|
|
|
DragManager::end_grab (GdkEvent* e)
|
|
|
|
{
|
|
|
|
_ending = true;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
bool r = false;
|
|
|
|
for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) {
|
|
|
|
bool const t = (*i)->end_grab (e);
|
|
|
|
if (t) {
|
|
|
|
r = true;
|
|
|
|
}
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
|
|
|
|
_drags.clear ();
|
|
|
|
|
|
|
|
_ending = false;
|
2011-01-04 21:28:28 -05:00
|
|
|
|
|
|
|
_editor->set_follow_playhead (_old_follow_playhead, false);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-06-21 15:18:54 -04:00
|
|
|
void
|
|
|
|
DragManager::mark_double_click ()
|
|
|
|
{
|
|
|
|
for (list<Drag*>::const_iterator i = _drags.begin(); i != _drags.end(); ++i) {
|
|
|
|
(*i)->set_double_click (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
bool
|
|
|
|
DragManager::motion_handler (GdkEvent* e, bool from_autoscroll)
|
|
|
|
{
|
|
|
|
bool r = false;
|
|
|
|
|
2014-06-17 08:08:07 -04:00
|
|
|
/* calling this implies that we expect the event to have canvas
|
|
|
|
* coordinates
|
|
|
|
*
|
|
|
|
* Can we guarantee that this is true?
|
|
|
|
*/
|
|
|
|
|
2014-02-26 08:43:53 -05:00
|
|
|
_current_pointer_frame = _editor->canvas_event_sample (e, &_current_pointer_x, &_current_pointer_y);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) {
|
|
|
|
bool const t = (*i)->motion_handler (e, from_autoscroll);
|
2014-06-06 08:32:35 -04:00
|
|
|
/* run all handlers; return true if at least one of them
|
|
|
|
returns true (indicating that the event has been handled).
|
|
|
|
*/
|
2010-01-12 11:14:49 -05:00
|
|
|
if (t) {
|
|
|
|
r = true;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DragManager::have_item (ArdourCanvas::Item* i) const
|
|
|
|
{
|
|
|
|
list<Drag*>::const_iterator j = _drags.begin ();
|
|
|
|
while (j != _drags.end() && (*j)->item () != i) {
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
|
|
|
|
return j != _drags.end ();
|
|
|
|
}
|
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
Drag::Drag (Editor* e, ArdourCanvas::Item* i, bool trackview_only)
|
2009-11-08 11:28:21 -05:00
|
|
|
: _editor (e)
|
|
|
|
, _item (i)
|
|
|
|
, _pointer_frame_offset (0)
|
2014-06-08 11:26:25 -04:00
|
|
|
, _trackview_only (trackview_only)
|
2009-11-08 11:28:21 -05:00
|
|
|
, _move_threshold_passed (false)
|
2013-06-21 15:18:54 -04:00
|
|
|
, _was_double_click (false)
|
2010-09-08 21:38:12 -04:00
|
|
|
, _raw_grab_frame (0)
|
2009-12-21 20:12:41 -05:00
|
|
|
, _grab_frame (0)
|
|
|
|
, _last_pointer_frame (0)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-04 18:45:27 -04:00
|
|
|
Drag::swap_grab (ArdourCanvas::Item* new_item, Gdk::Cursor* cursor, uint32_t /*time*/)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2013-04-04 00:32:52 -04:00
|
|
|
_item->ungrab ();
|
2009-05-30 14:25:59 -04:00
|
|
|
_item = new_item;
|
|
|
|
|
|
|
|
if (cursor == 0) {
|
2013-04-04 00:32:52 -04:00
|
|
|
_item->grab ();
|
2012-01-19 17:23:28 -05:00
|
|
|
} else {
|
2013-04-04 00:32:52 -04:00
|
|
|
_item->grab ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
|
|
|
|
{
|
|
|
|
// if dragging with button2, the motion is x constrained, with Alt-button2 it is y constrained
|
|
|
|
|
|
|
|
if (Keyboard::is_button2_event (&event->button)) {
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::SecondaryModifier)) {
|
|
|
|
_y_constrained = true;
|
|
|
|
_x_constrained = false;
|
|
|
|
} else {
|
|
|
|
_y_constrained = false;
|
|
|
|
_x_constrained = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_x_constrained = false;
|
|
|
|
_y_constrained = false;
|
|
|
|
}
|
|
|
|
|
2014-02-26 08:43:53 -05:00
|
|
|
_raw_grab_frame = _editor->canvas_event_sample (event, &_grab_x, &_grab_y);
|
2010-12-19 22:42:59 -05:00
|
|
|
setup_pointer_frame_offset ();
|
2010-09-08 21:38:12 -04:00
|
|
|
_grab_frame = adjusted_frame (_raw_grab_frame, event);
|
2009-05-30 14:25:59 -04:00
|
|
|
_last_pointer_frame = _grab_frame;
|
2010-01-12 11:14:49 -05:00
|
|
|
_last_pointer_x = _grab_x;
|
2014-06-08 11:26:25 -04:00
|
|
|
|
|
|
|
if (_trackview_only) {
|
|
|
|
_grab_y = _grab_y - _editor->get_trackview_group()->canvas_origin().y;
|
|
|
|
}
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
_last_pointer_y = _grab_y;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2012-01-19 17:23:28 -05:00
|
|
|
if (cursor == 0) {
|
2013-04-04 00:32:52 -04:00
|
|
|
_item->grab ();
|
2012-01-19 17:23:28 -05:00
|
|
|
} else {
|
2013-04-04 00:32:52 -04:00
|
|
|
/* CAIROCANVAS need a variant here that passes *cursor */
|
|
|
|
_item->grab ();
|
2014-12-20 01:11:28 -05:00
|
|
|
_cursor_ctx = CursorContext::create(*_editor, cursor);
|
2012-01-19 17:23:28 -05:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_editor->session() && _editor->session()->transport_rolling()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
_was_rolling = true;
|
|
|
|
} else {
|
|
|
|
_was_rolling = false;
|
|
|
|
}
|
|
|
|
|
2009-10-26 19:43:04 -04:00
|
|
|
switch (_editor->snap_type()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
case SnapToRegionStart:
|
|
|
|
case SnapToRegionEnd:
|
|
|
|
case SnapToRegionSync:
|
|
|
|
case SnapToRegionBoundary:
|
|
|
|
_editor->build_region_boundary_cache ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-05 18:09:07 -04:00
|
|
|
/** Call to end a drag `successfully'. Ungrabs item and calls
|
|
|
|
* subclass' finished() method.
|
|
|
|
*
|
|
|
|
* @param event GDK event, or 0.
|
2009-06-01 20:39:57 -04:00
|
|
|
* @return true if some movement occurred, otherwise false.
|
|
|
|
*/
|
2009-05-30 14:25:59 -04:00
|
|
|
bool
|
|
|
|
Drag::end_grab (GdkEvent* event)
|
|
|
|
{
|
|
|
|
_editor->stop_canvas_autoscroll ();
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_item->ungrab ();
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-01-04 20:10:53 -05:00
|
|
|
finished (event, _move_threshold_passed);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
_editor->verbose_cursor()->hide ();
|
2014-12-20 01:11:28 -05:00
|
|
|
_cursor_ctx.reset();
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-01-04 20:10:53 -05:00
|
|
|
return _move_threshold_passed;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t
|
|
|
|
Drag::adjusted_frame (framepos_t f, GdkEvent const * event, bool snap) const
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t pos = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-04 20:10:53 -05:00
|
|
|
if (f > _pointer_frame_offset) {
|
|
|
|
pos = f - _pointer_frame_offset;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
if (snap) {
|
|
|
|
_editor->snap_to_with_modifier (pos, event);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-10 17:31:00 -04:00
|
|
|
return pos;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t
|
2010-01-04 20:10:53 -05:00
|
|
|
Drag::adjusted_current_frame (GdkEvent const * event, bool snap) const
|
|
|
|
{
|
2010-01-12 11:14:49 -05:00
|
|
|
return adjusted_frame (_drags->current_pointer_frame (), event, snap);
|
2010-01-04 20:10:53 -05:00
|
|
|
}
|
|
|
|
|
2014-11-24 14:58:56 -05:00
|
|
|
double
|
|
|
|
Drag::current_pointer_x() const
|
|
|
|
{
|
|
|
|
return _drags->current_pointer_x ();
|
|
|
|
}
|
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
double
|
|
|
|
Drag::current_pointer_y () const
|
|
|
|
{
|
|
|
|
if (!_trackview_only) {
|
|
|
|
return _drags->current_pointer_y ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return _drags->current_pointer_y () - _editor->get_trackview_group()->canvas_origin().y;
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
bool
|
|
|
|
Drag::motion_handler (GdkEvent* event, bool from_autoscroll)
|
|
|
|
{
|
2010-01-05 10:51:13 -05:00
|
|
|
/* check to see if we have moved in any way that matters since the last motion event */
|
2010-12-21 20:06:18 -05:00
|
|
|
if (_move_threshold_passed &&
|
2014-11-24 14:58:56 -05:00
|
|
|
(!x_movement_matters() || _last_pointer_x == current_pointer_x ()) &&
|
2014-06-08 11:26:25 -04:00
|
|
|
(!y_movement_matters() || _last_pointer_y == current_pointer_y ()) ) {
|
2010-01-05 10:51:13 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
pair<framecnt_t, int> const threshold = move_threshold ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-04 20:10:53 -05:00
|
|
|
bool const old_move_threshold_passed = _move_threshold_passed;
|
2010-01-05 10:51:13 -05:00
|
|
|
|
2010-01-04 20:10:53 -05:00
|
|
|
if (!from_autoscroll && !_move_threshold_passed) {
|
2009-06-01 20:39:57 -04:00
|
|
|
|
2011-03-14 15:25:18 -04:00
|
|
|
bool const xp = (::llabs (_drags->current_pointer_frame () - _raw_grab_frame) >= threshold.first);
|
2014-06-08 11:26:25 -04:00
|
|
|
bool const yp = (::fabs ((current_pointer_y () - _grab_y)) >= threshold.second);
|
2009-06-01 20:39:57 -04:00
|
|
|
|
2010-01-04 20:10:53 -05:00
|
|
|
_move_threshold_passed = ((xp && x_movement_matters()) || (yp && y_movement_matters()));
|
2009-06-01 20:39:57 -04:00
|
|
|
}
|
|
|
|
|
2010-01-04 20:10:53 -05:00
|
|
|
if (active (_editor->mouse_mode) && _move_threshold_passed) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
if (event->motion.state & Gdk::BUTTON1_MASK || event->motion.state & Gdk::BUTTON2_MASK) {
|
|
|
|
if (!from_autoscroll) {
|
2014-03-20 13:29:29 -04:00
|
|
|
_editor->maybe_autoscroll (true, allow_vertical_autoscroll (), false);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2014-03-20 13:29:29 -04:00
|
|
|
if (!_editor->autoscroll_active() || from_autoscroll) {
|
|
|
|
motion (event, _move_threshold_passed != old_move_threshold_passed);
|
|
|
|
|
|
|
|
_last_pointer_x = _drags->current_pointer_x ();
|
2014-06-08 11:26:25 -04:00
|
|
|
_last_pointer_y = current_pointer_y ();
|
2014-03-20 13:29:29 -04:00
|
|
|
_last_pointer_frame = adjusted_current_frame (event);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2014-06-17 08:08:07 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-05-05 18:09:07 -04:00
|
|
|
/** Call to abort a drag. Ungrabs item and calls subclass's aborted () */
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2010-05-05 18:09:07 -04:00
|
|
|
Drag::abort ()
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
if (_item) {
|
2013-04-04 00:32:52 -04:00
|
|
|
_item->ungrab ();
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-12-28 14:17:37 -05:00
|
|
|
aborted (_move_threshold_passed);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
_editor->stop_canvas_autoscroll ();
|
2011-05-02 09:38:16 -04:00
|
|
|
_editor->verbose_cursor()->hide ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
void
|
|
|
|
Drag::show_verbose_cursor_time (framepos_t frame)
|
|
|
|
{
|
2014-06-26 15:07:29 -04:00
|
|
|
_editor->verbose_cursor()->set_time (frame);
|
2011-05-02 09:38:16 -04:00
|
|
|
_editor->verbose_cursor()->show ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-06-26 15:07:29 -04:00
|
|
|
Drag::show_verbose_cursor_duration (framepos_t start, framepos_t end, double /*xoffset*/)
|
2011-05-02 09:38:16 -04:00
|
|
|
{
|
2014-06-26 15:07:29 -04:00
|
|
|
_editor->verbose_cursor()->set_duration (start, end);
|
|
|
|
_editor->verbose_cursor()->show ();
|
2011-05-02 09:38:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Drag::show_verbose_cursor_text (string const & text)
|
|
|
|
{
|
2014-06-26 15:07:29 -04:00
|
|
|
_editor->verbose_cursor()->set (text);
|
2011-05-04 10:56:24 -04:00
|
|
|
_editor->verbose_cursor()->show ();
|
2011-05-02 09:38:16 -04:00
|
|
|
}
|
|
|
|
|
2012-01-25 14:39:20 -05:00
|
|
|
boost::shared_ptr<Region>
|
|
|
|
Drag::add_midi_region (MidiTimeAxisView* view)
|
|
|
|
{
|
|
|
|
if (_editor->session()) {
|
|
|
|
const TempoMap& map (_editor->session()->tempo_map());
|
|
|
|
framecnt_t pos = grab_frame();
|
|
|
|
const Meter& m = map.meter_at (pos);
|
|
|
|
/* not that the frame rate used here can be affected by pull up/down which
|
|
|
|
might be wrong.
|
|
|
|
*/
|
|
|
|
framecnt_t len = m.frames_per_bar (map.tempo_at (pos), _editor->session()->frame_rate());
|
|
|
|
return view->add_region (grab_frame(), len, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return boost::shared_ptr<Region>();
|
|
|
|
}
|
2011-05-02 09:38:16 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
struct EditorOrderTimeAxisViewSorter {
|
|
|
|
bool operator() (TimeAxisView* a, TimeAxisView* b) {
|
|
|
|
RouteTimeAxisView* ra = dynamic_cast<RouteTimeAxisView*> (a);
|
|
|
|
RouteTimeAxisView* rb = dynamic_cast<RouteTimeAxisView*> (b);
|
|
|
|
assert (ra && rb);
|
2013-10-20 09:19:43 -04:00
|
|
|
return ra->route()->order_key () < rb->route()->order_key ();
|
2010-09-06 08:34:11 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
RegionDrag::RegionDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v)
|
|
|
|
: Drag (e, i),
|
2010-04-06 20:17:54 -04:00
|
|
|
_primary (p)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-06 08:34:11 -04:00
|
|
|
_editor->visible_order_range (&_visible_y_low, &_visible_y_high);
|
|
|
|
|
2011-10-22 14:11:40 -04:00
|
|
|
/* Make a list of tracks to refer to during the drag; we include hidden tracks,
|
|
|
|
as some of the regions we are dragging may be on such tracks.
|
|
|
|
*/
|
2010-09-06 08:34:11 -04:00
|
|
|
|
|
|
|
TrackViewList track_views = _editor->track_views;
|
|
|
|
track_views.sort (EditorOrderTimeAxisViewSorter ());
|
|
|
|
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
2011-10-22 14:11:40 -04:00
|
|
|
_time_axis_views.push_back (*i);
|
|
|
|
|
|
|
|
TimeAxisView::Children children_list = (*i)->get_child_list ();
|
|
|
|
for (TimeAxisView::Children::iterator j = children_list.begin(); j != children_list.end(); ++j) {
|
|
|
|
_time_axis_views.push_back (j->get());
|
2010-09-06 08:34:11 -04:00
|
|
|
}
|
|
|
|
}
|
2010-09-18 16:22:03 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
/* the list of views can be empty at this point if this is a region list-insert drag
|
|
|
|
*/
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<RegionView*>::const_iterator i = v.begin(); i != v.end(); ++i) {
|
2014-06-19 11:16:27 -04:00
|
|
|
_views.push_back (DraggingView (*i, this, &(*i)->get_time_axis_view()));
|
2010-04-06 20:17:54 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2012-04-25 08:58:19 -04:00
|
|
|
RegionView::RegionViewGoingAway.connect (death_connection, invalidator (*this), boost::bind (&RegionDrag::region_going_away, this, _1), gui_context());
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionDrag::region_going_away (RegionView* v)
|
|
|
|
{
|
2010-04-06 20:17:54 -04:00
|
|
|
list<DraggingView>::iterator i = _views.begin ();
|
|
|
|
while (i != _views.end() && i->view != v) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i != _views.end()) {
|
|
|
|
_views.erase (i);
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2011-10-22 14:11:40 -04:00
|
|
|
/** Given a TimeAxisView, return the index of it into the _time_axis_views vector,
|
|
|
|
* or -1 if it is not found.
|
|
|
|
*/
|
2010-09-06 08:34:11 -04:00
|
|
|
int
|
|
|
|
RegionDrag::find_time_axis_view (TimeAxisView* t) const
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
int const N = _time_axis_views.size ();
|
|
|
|
while (i < N && _time_axis_views[i] != t) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == N) {
|
|
|
|
return -1;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
RegionMotionDrag::RegionMotionDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v, bool b)
|
2013-06-26 11:49:16 -04:00
|
|
|
: RegionDrag (e, i, p, v)
|
|
|
|
, _brushing (b)
|
|
|
|
, _total_x_delta (0)
|
|
|
|
, _last_pointer_time_axis_view (0)
|
|
|
|
, _last_pointer_layer (0)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2013-04-11 20:19:22 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New RegionMotionDrag\n");
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-09-06 08:34:11 -04:00
|
|
|
RegionMotionDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-06 08:34:11 -04:00
|
|
|
Drag::start_grab (event, cursor);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (_last_frame_position);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
pair<TimeAxisView*, double> const tv = _editor->trackview_by_y_position (current_pointer_y ());
|
2013-06-26 11:49:16 -04:00
|
|
|
if (tv.first) {
|
|
|
|
_last_pointer_time_axis_view = find_time_axis_view (tv.first);
|
|
|
|
_last_pointer_layer = tv.first->layer_display() == Overlaid ? 0 : tv.second;
|
|
|
|
}
|
2009-06-08 15:28:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
double
|
2010-09-08 21:38:21 -04:00
|
|
|
RegionMotionDrag::compute_x_delta (GdkEvent const * event, framepos_t* pending_region_position)
|
2009-06-08 15:28:51 -04:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
/* compute the amount of pointer motion in frames, and where
|
|
|
|
the region would be if we moved it by that much.
|
|
|
|
*/
|
2009-12-21 20:12:41 -05:00
|
|
|
*pending_region_position = adjusted_current_frame (event);
|
2010-08-13 12:50:01 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t sync_frame;
|
|
|
|
framecnt_t sync_offset;
|
2009-12-21 20:12:41 -05:00
|
|
|
int32_t sync_dir;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
sync_offset = _primary->region()->sync_offset (sync_dir);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
/* we don't handle a sync point that lies before zero.
|
|
|
|
*/
|
|
|
|
if (sync_dir >= 0 || (sync_dir < 0 && *pending_region_position >= sync_offset)) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
sync_frame = *pending_region_position + (sync_dir*sync_offset);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
_editor->snap_to_with_modifier (sync_frame, event);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
*pending_region_position = _primary->region()->adjust_to_sync (sync_frame);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
} else {
|
|
|
|
*pending_region_position = _last_frame_position;
|
2009-06-01 20:39:57 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-17 12:24:22 -04:00
|
|
|
if (*pending_region_position > max_framepos - _primary->region()->length()) {
|
2009-06-08 15:28:51 -04:00
|
|
|
*pending_region_position = _last_frame_position;
|
2009-06-01 20:39:57 -04:00
|
|
|
}
|
2009-06-08 15:28:51 -04:00
|
|
|
|
2010-08-13 12:50:01 -04:00
|
|
|
double dx = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
/* in locked edit mode, reverse the usual meaning of _x_constrained */
|
|
|
|
bool const x_move_allowed = Config->get_edit_mode() == Lock ? _x_constrained : !_x_constrained;
|
|
|
|
|
|
|
|
if ((*pending_region_position != _last_frame_position) && x_move_allowed) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-04-06 19:12:45 -04:00
|
|
|
/* x movement since last time (in pixels) */
|
2013-04-12 11:31:50 -04:00
|
|
|
dx = (static_cast<double> (*pending_region_position) - _last_frame_position) / _editor->samples_per_pixel;
|
2010-08-19 19:56:30 -04:00
|
|
|
|
2010-08-13 12:50:01 -04:00
|
|
|
/* total x movement */
|
2010-08-19 19:56:30 -04:00
|
|
|
framecnt_t total_dx = *pending_region_position;
|
|
|
|
if (regions_came_from_canvas()) {
|
2011-04-06 19:12:45 -04:00
|
|
|
total_dx = total_dx - grab_frame ();
|
2010-08-19 19:56:30 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-08-13 12:50:01 -04:00
|
|
|
/* check that no regions have gone off the start of the session */
|
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
if ((i->view->region()->position() + total_dx) < 0) {
|
|
|
|
dx = 0;
|
|
|
|
*pending_region_position = _last_frame_position;
|
|
|
|
break;
|
2009-06-01 20:39:57 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-06-01 20:39:57 -04:00
|
|
|
|
2010-08-13 12:50:01 -04:00
|
|
|
return dx;
|
2009-06-08 15:28:51 -04:00
|
|
|
}
|
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
bool
|
2011-12-26 20:42:49 -05:00
|
|
|
RegionMotionDrag::y_movement_allowed (int delta_track, double delta_layer) const
|
2009-06-08 15:28:51 -04:00
|
|
|
{
|
2010-09-06 08:34:11 -04:00
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
int const n = i->time_axis_view + delta_track;
|
|
|
|
if (n < 0 || n >= int (_time_axis_views.size())) {
|
|
|
|
/* off the top or bottom track */
|
|
|
|
return false;
|
|
|
|
}
|
2009-06-08 15:28:51 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
RouteTimeAxisView const * to = dynamic_cast<RouteTimeAxisView const *> (_time_axis_views[n]);
|
|
|
|
if (to == 0 || !to->is_track() || to->track()->data_type() != i->view->region()->data_type()) {
|
|
|
|
/* not a track, or the wrong type */
|
|
|
|
return false;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-12-26 20:42:49 -05:00
|
|
|
double const l = i->layer + delta_layer;
|
|
|
|
|
|
|
|
/* Note that we allow layer to be up to 0.5 below zero, as this is used by `Expanded'
|
|
|
|
mode to allow the user to place a region below another on layer 0.
|
|
|
|
*/
|
|
|
|
if (delta_track == 0 && (l < -0.5 || l >= int (to->view()->layers()))) {
|
2010-09-06 08:34:11 -04:00
|
|
|
/* Off the top or bottom layer; note that we only refuse if the track hasn't changed.
|
|
|
|
If it has, the layers will be munged later anyway, so it's ok.
|
|
|
|
*/
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2009-06-08 15:28:51 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
/* all regions being dragged are ok with this change */
|
|
|
|
return true;
|
|
|
|
}
|
2009-06-08 15:28:51 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
void
|
|
|
|
RegionMotionDrag::motion (GdkEvent* event, bool first_move)
|
|
|
|
{
|
2014-05-17 12:17:16 -04:00
|
|
|
double delta_layer = 0;
|
|
|
|
int delta_time_axis_view = 0;
|
2010-09-20 23:09:02 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
assert (!_views.empty ());
|
2009-06-08 15:28:51 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
/* Note: time axis views in this method are often expressed as an index into the _time_axis_views vector */
|
2013-06-26 11:49:16 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
/* Find the TimeAxisView that the pointer is now over */
|
2014-06-08 11:26:25 -04:00
|
|
|
pair<TimeAxisView*, double> const r = _editor->trackview_by_y_position (current_pointer_y ());
|
2014-05-17 12:17:16 -04:00
|
|
|
TimeAxisView* tv = r.first;
|
2009-06-08 15:28:51 -04:00
|
|
|
|
2014-06-03 15:57:56 -04:00
|
|
|
if (tv && tv->view()) {
|
2014-05-17 12:17:16 -04:00
|
|
|
double layer = r.second;
|
2014-06-09 10:55:37 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
if (first_move && tv->view()->layer_display() == Stacked) {
|
|
|
|
tv->view()->set_layer_display (Expanded);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
/* Here's the current pointer position in terms of time axis view and layer */
|
|
|
|
int const current_pointer_time_axis_view = find_time_axis_view (tv);
|
|
|
|
double const current_pointer_layer = tv->layer_display() == Overlaid ? 0 : layer;
|
|
|
|
|
|
|
|
/* Work out the change in y */
|
2009-06-08 15:28:51 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
delta_time_axis_view = current_pointer_time_axis_view - _last_pointer_time_axis_view;
|
|
|
|
delta_layer = current_pointer_layer - _last_pointer_layer;
|
2014-06-17 08:08:07 -04:00
|
|
|
}
|
2014-05-17 12:17:16 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
/* Work out the change in x */
|
|
|
|
framepos_t pending_region_position;
|
2009-06-08 15:28:51 -04:00
|
|
|
double const x_delta = compute_x_delta (event, &pending_region_position);
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
_last_frame_position = pending_region_position;
|
2009-06-08 15:28:51 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
/* Verify change in y */
|
2010-09-06 08:34:11 -04:00
|
|
|
if (!y_movement_allowed (delta_time_axis_view, delta_layer)) {
|
|
|
|
/* this y movement is not allowed, so do no y movement this time */
|
|
|
|
delta_time_axis_view = 0;
|
|
|
|
delta_layer = 0;
|
|
|
|
}
|
|
|
|
|
2014-06-19 11:16:27 -04:00
|
|
|
if (x_delta == 0 && (tv && tv->view() && delta_time_axis_view == 0) && delta_layer == 0 && !first_move) {
|
2009-05-30 14:25:59 -04:00
|
|
|
/* haven't reached next snap point, and we're not switching
|
|
|
|
trackviews nor layers. nothing to do.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
pair<set<boost::shared_ptr<Playlist> >::iterator,bool> insert_result;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
RegionView* rv = i->view;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-11 13:49:29 -04:00
|
|
|
if (rv->region()->locked() || rv->region()->video_locked()) {
|
2009-06-01 20:39:57 -04:00
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
if (first_move) {
|
2012-05-07 18:02:17 -04:00
|
|
|
rv->drag_start ();
|
2014-06-05 15:16:55 -04:00
|
|
|
|
|
|
|
/* reparent the regionview into a group above all
|
|
|
|
* others
|
|
|
|
*/
|
2014-06-21 11:44:22 -04:00
|
|
|
|
|
|
|
ArdourCanvas::Item* rvg = rv->get_canvas_group();
|
2014-06-08 11:26:25 -04:00
|
|
|
Duple rv_canvas_offset = rvg->parent()->canvas_origin ();
|
|
|
|
Duple dmg_canvas_offset = _editor->_drag_motion_group->canvas_origin ();
|
2014-06-05 15:16:55 -04:00
|
|
|
rv->get_canvas_group()->reparent (_editor->_drag_motion_group);
|
2014-06-05 15:22:26 -04:00
|
|
|
/* move the item so that it continues to appear at the
|
|
|
|
same location now that its parent has changed.
|
|
|
|
*/
|
2014-06-05 15:16:55 -04:00
|
|
|
rvg->move (rv_canvas_offset - dmg_canvas_offset);
|
2009-06-01 20:39:57 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
/* If we have moved tracks, we'll fudge the layer delta so that the
|
|
|
|
region gets moved back onto layer 0 on its new track; this avoids
|
|
|
|
confusion when dragging regions from non-zero layers onto different
|
|
|
|
tracks.
|
|
|
|
*/
|
2011-12-26 20:42:49 -05:00
|
|
|
double this_delta_layer = delta_layer;
|
2010-09-06 08:34:11 -04:00
|
|
|
if (delta_time_axis_view != 0) {
|
|
|
|
this_delta_layer = - i->layer;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
if (tv) {
|
2011-12-26 20:42:49 -05:00
|
|
|
|
2014-06-09 10:55:37 -04:00
|
|
|
int track_index;
|
|
|
|
|
|
|
|
if (i->time_axis_view >= 0) {
|
|
|
|
track_index = i->time_axis_view + delta_time_axis_view;
|
|
|
|
} else {
|
|
|
|
track_index = _time_axis_views.size() - 1 + delta_time_axis_view;
|
|
|
|
}
|
2014-06-03 15:57:56 -04:00
|
|
|
|
|
|
|
if (track_index < 0 || track_index >= (int) _time_axis_views.size()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The TimeAxisView that this region is now over */
|
2014-06-09 10:55:37 -04:00
|
|
|
TimeAxisView* current_tv = _time_axis_views[track_index];
|
2014-05-17 12:17:16 -04:00
|
|
|
|
|
|
|
/* Ensure it is moved from stacked -> expanded if appropriate */
|
|
|
|
if (current_tv->view()->layer_display() == Stacked) {
|
|
|
|
current_tv->view()->set_layer_display (Expanded);
|
|
|
|
}
|
2012-05-07 18:02:17 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
/* We're only allowed to go -ve in layer on Expanded views */
|
|
|
|
if (current_tv->view()->layer_display() != Expanded && (i->layer + this_delta_layer) < 0) {
|
|
|
|
this_delta_layer = - i->layer;
|
|
|
|
}
|
2012-05-07 18:02:17 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
/* Set height */
|
|
|
|
rv->set_height (current_tv->view()->child_height ());
|
2012-05-07 18:02:17 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
/* Update show/hidden status as the region view may have come from a hidden track,
|
|
|
|
or have moved to one.
|
|
|
|
*/
|
|
|
|
if (current_tv->hidden ()) {
|
|
|
|
rv->get_canvas_group()->hide ();
|
|
|
|
} else {
|
|
|
|
rv->get_canvas_group()->show ();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
/* Update the DraggingView */
|
2014-06-09 10:55:37 -04:00
|
|
|
i->time_axis_view = track_index;
|
2014-05-17 12:17:16 -04:00
|
|
|
i->layer += this_delta_layer;
|
|
|
|
|
|
|
|
if (_brushing) {
|
|
|
|
_editor->mouse_brush_insert_region (rv, pending_region_position);
|
|
|
|
} else {
|
2014-09-04 10:14:01 -04:00
|
|
|
Duple track_origin;
|
2014-05-17 12:17:16 -04:00
|
|
|
|
2014-06-03 15:57:56 -04:00
|
|
|
/* Get the y coordinate of the top of the track that this region is now over */
|
|
|
|
track_origin = current_tv->canvas_display()->item_to_canvas (track_origin);
|
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
/* And adjust for the layer that it should be on */
|
|
|
|
StreamView* cv = current_tv->view ();
|
|
|
|
switch (cv->layer_display ()) {
|
|
|
|
case Overlaid:
|
|
|
|
break;
|
|
|
|
case Stacked:
|
2014-06-03 15:57:56 -04:00
|
|
|
track_origin.y += (cv->layers() - i->layer - 1) * cv->child_height ();
|
2014-05-17 12:17:16 -04:00
|
|
|
break;
|
|
|
|
case Expanded:
|
2014-06-03 15:57:56 -04:00
|
|
|
track_origin.y += (cv->layers() - i->layer - 0.5) * 2 * cv->child_height ();
|
2014-05-17 12:17:16 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-06-03 15:57:56 -04:00
|
|
|
/* need to get the parent of the regionview
|
|
|
|
* canvas group and get its position in
|
|
|
|
* equivalent coordinate space as the trackview
|
|
|
|
* we are now dragging over.
|
|
|
|
*/
|
|
|
|
|
2014-05-17 12:17:16 -04:00
|
|
|
/* Now move the region view */
|
2014-06-08 11:26:25 -04:00
|
|
|
rv->move (x_delta, track_origin.y - rv->get_canvas_group()->canvas_origin().y);
|
2014-05-17 12:17:16 -04:00
|
|
|
}
|
2009-06-01 20:39:57 -04:00
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-06-03 15:57:56 -04:00
|
|
|
/* Only move the region into the empty dropzone at the bottom if the pointer
|
|
|
|
* is down there.
|
|
|
|
*/
|
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
if (current_pointer_y() >= 0) {
|
2014-06-03 15:57:56 -04:00
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
Coord last_track_bottom_edge;
|
|
|
|
if (!_time_axis_views.empty()) {
|
|
|
|
TimeAxisView* last = _time_axis_views.back();
|
|
|
|
last_track_bottom_edge = last->canvas_display()->canvas_origin ().y + last->effective_height();
|
|
|
|
} else {
|
|
|
|
last_track_bottom_edge = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv->move (x_delta, last_track_bottom_edge - rv->get_canvas_group()->canvas_origin().y);
|
2014-06-03 15:57:56 -04:00
|
|
|
i->time_axis_view = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
} /* foreach region */
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
_total_x_delta += x_delta;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (x_delta != 0 && !_brushing) {
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (_last_frame_position);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2010-09-06 08:34:11 -04:00
|
|
|
|
|
|
|
_last_pointer_time_axis_view += delta_time_axis_view;
|
|
|
|
_last_pointer_layer += delta_layer;
|
2009-06-08 15:28:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionMoveDrag::motion (GdkEvent* event, bool first_move)
|
|
|
|
{
|
|
|
|
if (_copy && first_move) {
|
2010-09-06 08:34:11 -04:00
|
|
|
|
2014-12-14 08:13:38 -05:00
|
|
|
if (_x_constrained) {
|
|
|
|
_editor->begin_reversible_command (Operations::fixed_time_region_copy);
|
|
|
|
} else {
|
|
|
|
_editor->begin_reversible_command (Operations::region_copy);
|
|
|
|
}
|
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
/* duplicate the regionview(s) and region(s) */
|
|
|
|
|
|
|
|
list<DraggingView> new_regionviews;
|
|
|
|
|
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
RegionView* rv = i->view;
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
|
|
|
|
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(rv);
|
|
|
|
|
|
|
|
const boost::shared_ptr<const Region> original = rv->region();
|
2010-09-20 23:02:30 -04:00
|
|
|
boost::shared_ptr<Region> region_copy = RegionFactory::create (original, true);
|
2011-05-30 09:54:44 -04:00
|
|
|
region_copy->set_position (original->position());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
RegionView* nrv;
|
|
|
|
if (arv) {
|
|
|
|
boost::shared_ptr<AudioRegion> audioregion_copy
|
|
|
|
= boost::dynamic_pointer_cast<AudioRegion>(region_copy);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
nrv = new AudioRegionView (*arv, audioregion_copy);
|
|
|
|
} else if (mrv) {
|
|
|
|
boost::shared_ptr<MidiRegion> midiregion_copy
|
|
|
|
= boost::dynamic_pointer_cast<MidiRegion>(region_copy);
|
|
|
|
nrv = new MidiRegionView (*mrv, midiregion_copy);
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
nrv->get_canvas_group()->show ();
|
2014-06-19 11:16:27 -04:00
|
|
|
new_regionviews.push_back (DraggingView (nrv, this, i->initial_time_axis_view));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
/* swap _primary to the copy */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
if (rv == _primary) {
|
|
|
|
_primary = nrv;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
/* ..and deselect the one we copied */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
rv->set_selected (false);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
if (!new_regionviews.empty()) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
/* reflect the fact that we are dragging the copies */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
_views = new_regionviews;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
swap_grab (new_regionviews.front().view->get_canvas_group (), 0, event ? event->motion.time : 0);
|
|
|
|
}
|
2014-12-14 08:13:38 -05:00
|
|
|
|
|
|
|
} else if (!_copy && first_move) {
|
|
|
|
|
|
|
|
if (_x_constrained) {
|
|
|
|
_editor->begin_reversible_command (_("fixed time region drag"));
|
|
|
|
} else {
|
|
|
|
_editor->begin_reversible_command (Operations::region_drag);
|
|
|
|
}
|
2009-06-08 15:28:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
RegionMotionDrag::motion (event, first_move);
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
void
|
2011-12-26 20:42:49 -05:00
|
|
|
RegionMotionDrag::finished (GdkEvent *, bool)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2011-12-26 20:42:49 -05:00
|
|
|
for (vector<TimeAxisView*>::iterator i = _time_axis_views.begin(); i != _time_axis_views.end(); ++i) {
|
2011-12-29 09:48:42 -05:00
|
|
|
if (!(*i)->view()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-12-26 20:42:49 -05:00
|
|
|
if ((*i)->view()->layer_display() == Expanded) {
|
|
|
|
(*i)->view()->set_layer_display (Stacked);
|
|
|
|
}
|
|
|
|
}
|
2011-12-29 17:14:15 -05:00
|
|
|
}
|
2011-12-26 20:42:49 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
RegionMoveDrag::finished (GdkEvent* ev, bool movement_occurred)
|
|
|
|
{
|
|
|
|
RegionMotionDrag::finished (ev, movement_occurred);
|
2011-12-29 17:14:15 -05:00
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
if (!movement_occurred) {
|
2014-01-27 10:09:58 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
/* just a click */
|
2014-01-27 10:09:58 -05:00
|
|
|
|
|
|
|
if (was_double_click() && !_views.empty()) {
|
|
|
|
DraggingView dv = _views.front();
|
|
|
|
dv.view->show_region_editor ();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-08-23 22:10:46 -04:00
|
|
|
return;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* reverse this here so that we have the correct logic to finalize
|
|
|
|
the drag.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-10-20 16:43:23 -04:00
|
|
|
if (Config->get_edit_mode() == Lock) {
|
2009-05-30 14:25:59 -04:00
|
|
|
_x_constrained = !_x_constrained;
|
|
|
|
}
|
|
|
|
|
2010-09-18 16:22:03 -04:00
|
|
|
assert (!_views.empty ());
|
|
|
|
|
2011-11-13 14:51:30 -05:00
|
|
|
/* We might have hidden region views so that they weren't visible during the drag
|
|
|
|
(when they have been reparented). Now everything can be shown again, as region
|
|
|
|
views are back in their track parent groups.
|
|
|
|
*/
|
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
i->view->get_canvas_group()->show ();
|
|
|
|
}
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
bool const changed_position = (_last_frame_position != _primary->region()->position());
|
2010-09-06 08:34:11 -04:00
|
|
|
bool const changed_tracks = (_time_axis_views[_views.front().time_axis_view] != &_views.front().view->get_time_axis_view());
|
2010-08-23 21:02:40 -04:00
|
|
|
framecnt_t const drag_delta = _primary->region()->position() - _last_frame_position;
|
2011-11-13 14:51:30 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (_copy) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
finished_copy (
|
|
|
|
changed_position,
|
|
|
|
changed_tracks,
|
|
|
|
drag_delta
|
|
|
|
);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
} else {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
finished_no_copy (
|
|
|
|
changed_position,
|
|
|
|
changed_tracks,
|
|
|
|
drag_delta
|
|
|
|
);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
}
|
2012-01-30 17:53:22 -05:00
|
|
|
|
2012-11-26 18:07:21 -05:00
|
|
|
_editor->maybe_locate_with_edit_preroll (_editor->get_selection().regions.start());
|
2010-08-23 21:02:40 -04:00
|
|
|
}
|
|
|
|
|
2014-05-17 17:24:42 -04:00
|
|
|
RouteTimeAxisView*
|
2014-06-19 11:16:27 -04:00
|
|
|
RegionMoveDrag::create_destination_time_axis (boost::shared_ptr<Region> region, TimeAxisView* original)
|
2014-05-17 17:24:42 -04:00
|
|
|
{
|
2014-05-17 17:31:11 -04:00
|
|
|
/* Add a new track of the correct type, and return the RouteTimeAxisView that is created to display the
|
|
|
|
new track.
|
2014-05-17 17:24:42 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (boost::dynamic_pointer_cast<AudioRegion> (region)) {
|
|
|
|
list<boost::shared_ptr<AudioTrack> > audio_tracks;
|
|
|
|
audio_tracks = _editor->session()->new_audio_track (region->n_channels(), region->n_channels(), ARDOUR::Normal, 0, 1, region->name());
|
2014-06-19 11:16:27 -04:00
|
|
|
RouteTimeAxisView* rtav = _editor->axis_view_from_route (audio_tracks.front());
|
|
|
|
if (rtav) {
|
|
|
|
rtav->set_height (original->current_height());
|
|
|
|
}
|
|
|
|
return rtav;
|
2014-05-17 17:24:42 -04:00
|
|
|
} else {
|
|
|
|
ChanCount one_midi_port (DataType::MIDI, 1);
|
|
|
|
list<boost::shared_ptr<MidiTrack> > midi_tracks;
|
|
|
|
midi_tracks = _editor->session()->new_midi_track (one_midi_port, one_midi_port, boost::shared_ptr<ARDOUR::PluginInfo>(), ARDOUR::Normal, 0, 1, region->name());
|
2014-06-19 11:16:27 -04:00
|
|
|
RouteTimeAxisView* rtav = _editor->axis_view_from_route (midi_tracks.front());
|
|
|
|
if (rtav) {
|
|
|
|
rtav->set_height (original->current_height());
|
|
|
|
}
|
|
|
|
return rtav;
|
2014-05-17 17:24:42 -04:00
|
|
|
}
|
|
|
|
} catch (...) {
|
|
|
|
error << _("Could not create new track after region placed in the drop zone") << endmsg;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
void
|
2010-11-13 00:14:48 -05:00
|
|
|
RegionMoveDrag::finished_copy (bool const changed_position, bool const /*changed_tracks*/, framecnt_t const drag_delta)
|
2010-08-23 21:02:40 -04:00
|
|
|
{
|
|
|
|
RegionSelection new_views;
|
|
|
|
PlaylistSet modified_playlists;
|
2014-05-17 17:24:42 -04:00
|
|
|
RouteTimeAxisView* new_time_axis_view = 0;
|
2010-08-23 21:02:40 -04:00
|
|
|
|
|
|
|
if (_brushing) {
|
|
|
|
/* all changes were made during motion event handlers */
|
|
|
|
|
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
delete i->view;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2010-08-23 21:02:40 -04:00
|
|
|
|
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* insert the regions into their new playlists */
|
2014-05-17 17:24:42 -04:00
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end();) {
|
|
|
|
|
|
|
|
RouteTimeAxisView* dest_rtv = 0;
|
2010-08-23 21:02:40 -04:00
|
|
|
|
2013-04-11 13:49:29 -04:00
|
|
|
if (i->view->region()->locked() || i->view->region()->video_locked()) {
|
2010-08-23 21:02:40 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t where;
|
2010-09-06 08:34:11 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
if (changed_position && !_x_constrained) {
|
|
|
|
where = i->view->region()->position() - drag_delta;
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2010-08-23 21:02:40 -04:00
|
|
|
where = i->view->region()->position();
|
|
|
|
}
|
2014-05-17 17:24:42 -04:00
|
|
|
|
|
|
|
if (i->time_axis_view < 0) {
|
|
|
|
if (!new_time_axis_view) {
|
2014-06-19 11:16:27 -04:00
|
|
|
new_time_axis_view = create_destination_time_axis (i->view->region(), i->initial_time_axis_view);
|
2014-05-17 17:24:42 -04:00
|
|
|
}
|
|
|
|
dest_rtv = new_time_axis_view;
|
|
|
|
} else {
|
|
|
|
dest_rtv = dynamic_cast<RouteTimeAxisView*> (_time_axis_views[i->time_axis_view]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dest_rtv != 0) {
|
|
|
|
RegionView* new_view = insert_region_into_playlist (i->view->region(), dest_rtv, i->layer, where, modified_playlists);
|
|
|
|
if (new_view != 0) {
|
|
|
|
new_views.push_back (new_view);
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2014-05-17 17:24:42 -04:00
|
|
|
|
|
|
|
/* Delete the copy of the view that was used for dragging. Need to play safe with the iterator
|
|
|
|
since deletion will automagically remove it from _views, thus invalidating i as an iterator.
|
|
|
|
*/
|
|
|
|
|
|
|
|
list<DraggingView>::const_iterator next = i;
|
|
|
|
++next;
|
|
|
|
delete i->view;
|
|
|
|
i = next;
|
2010-08-23 21:02:40 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
/* If we've created new regions either by copying or moving
|
|
|
|
to a new track, we want to replace the old selection with the new ones
|
2010-08-23 21:02:40 -04:00
|
|
|
*/
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
if (new_views.size() > 0) {
|
|
|
|
_editor->selection->set (new_views);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write commands for the accumulated diffs for all our modified playlists */
|
|
|
|
add_stateful_diff_commands_for_playlists (modified_playlists);
|
|
|
|
|
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
void
|
|
|
|
RegionMoveDrag::finished_no_copy (
|
|
|
|
bool const changed_position,
|
|
|
|
bool const changed_tracks,
|
|
|
|
framecnt_t const drag_delta
|
|
|
|
)
|
|
|
|
{
|
|
|
|
RegionSelection new_views;
|
|
|
|
PlaylistSet modified_playlists;
|
|
|
|
PlaylistSet frozen_playlists;
|
2011-12-27 16:10:20 -05:00
|
|
|
set<RouteTimeAxisView*> views_to_update;
|
2014-05-17 15:51:08 -04:00
|
|
|
RouteTimeAxisView* new_time_axis_view = 0;
|
2010-08-23 21:02:40 -04:00
|
|
|
|
|
|
|
if (_brushing) {
|
|
|
|
/* all changes were made during motion event handlers */
|
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
RegionView* rv = i->view;
|
2014-05-17 15:51:08 -04:00
|
|
|
RouteTimeAxisView* dest_rtv = 0;
|
2010-03-01 19:00:00 -05:00
|
|
|
|
2013-04-11 13:49:29 -04:00
|
|
|
if (rv->region()->locked() || rv->region()->video_locked()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
2014-05-17 15:51:08 -04:00
|
|
|
|
|
|
|
if (i->time_axis_view < 0) {
|
|
|
|
if (!new_time_axis_view) {
|
2014-06-19 11:16:27 -04:00
|
|
|
new_time_axis_view = create_destination_time_axis (rv->region(), i->initial_time_axis_view);
|
2014-05-17 15:51:08 -04:00
|
|
|
}
|
|
|
|
dest_rtv = new_time_axis_view;
|
|
|
|
} else {
|
|
|
|
dest_rtv = dynamic_cast<RouteTimeAxisView*> (_time_axis_views[i->time_axis_view]);
|
|
|
|
}
|
2014-05-17 17:24:42 -04:00
|
|
|
|
2014-05-17 15:51:08 -04:00
|
|
|
assert (dest_rtv);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2014-05-17 15:51:08 -04:00
|
|
|
double const dest_layer = i->layer;
|
|
|
|
|
2011-12-27 16:10:20 -05:00
|
|
|
views_to_update.insert (dest_rtv);
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t where;
|
2010-08-23 21:02:40 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (changed_position && !_x_constrained) {
|
|
|
|
where = rv->region()->position() - drag_delta;
|
|
|
|
} else {
|
|
|
|
where = rv->region()->position();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
if (changed_tracks) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
/* insert into new playlist */
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
RegionView* new_view = insert_region_into_playlist (
|
2010-09-20 23:02:30 -04:00
|
|
|
RegionFactory::create (rv->region (), true), dest_rtv, dest_layer, where, modified_playlists
|
2010-08-23 21:02:40 -04:00
|
|
|
);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
if (new_view == 0) {
|
2009-05-30 14:25:59 -04:00
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
new_views.push_back (new_view);
|
2010-03-01 19:00:00 -05:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
/* remove from old playlist */
|
2010-03-01 19:00:00 -05:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
/* the region that used to be in the old playlist is not
|
|
|
|
moved to the new one - we use a copy of it. as a result,
|
|
|
|
any existing editor for the region should no longer be
|
|
|
|
visible.
|
|
|
|
*/
|
|
|
|
rv->hide_region_editor();
|
2014-06-13 10:56:46 -04:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
remove_region_from_playlist (rv->region(), i->initial_playlist, modified_playlists);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
} else {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-04-14 08:34:18 -04:00
|
|
|
boost::shared_ptr<Playlist> playlist = dest_rtv->playlist();
|
|
|
|
|
|
|
|
/* this movement may result in a crossfade being modified, or a layering change,
|
|
|
|
so we need to get undo data from the playlist as well as the region.
|
|
|
|
*/
|
|
|
|
|
|
|
|
pair<PlaylistSet::iterator, bool> r = modified_playlists.insert (playlist);
|
|
|
|
if (r.second) {
|
|
|
|
playlist->clear_changes ();
|
|
|
|
}
|
|
|
|
|
2010-08-25 13:32:08 -04:00
|
|
|
rv->region()->clear_changes ();
|
2010-02-08 14:41:43 -05:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
/*
|
|
|
|
motion on the same track. plonk the previously reparented region
|
2009-05-30 14:25:59 -04:00
|
|
|
back to its original canvas group (its streamview).
|
|
|
|
No need to do anything for copies as they are fake regions which will be deleted.
|
|
|
|
*/
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
rv->get_canvas_group()->reparent (dest_rtv->view()->canvas_item());
|
|
|
|
rv->get_canvas_group()->set_y_position (i->initial_y);
|
2012-05-07 18:02:17 -04:00
|
|
|
rv->drag_end ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
/* just change the model */
|
2011-12-29 17:14:15 -05:00
|
|
|
if (dest_rtv->view()->layer_display() == Stacked || dest_rtv->view()->layer_display() == Expanded) {
|
2011-12-30 15:05:48 -05:00
|
|
|
playlist->set_layer (rv->region(), dest_layer);
|
2009-08-25 20:06:21 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-25 15:34:09 -05:00
|
|
|
/* freeze playlist to avoid lots of relayering in the case of a multi-region drag */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-04-14 08:34:18 -04:00
|
|
|
r = frozen_playlists.insert (playlist);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
if (r.second) {
|
|
|
|
playlist->freeze ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2011-05-30 09:54:44 -04:00
|
|
|
rv->region()->set_position (where);
|
2010-01-25 15:34:09 -05:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
_editor->session()->add_command (new StatefulDiffCommand (rv->region()));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
if (changed_tracks) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
/* OK, this is where it gets tricky. If the playlist was being used by >1 tracks, and the region
|
|
|
|
was selected in all of them, then removing it from a playlist will have removed all
|
2010-08-23 21:02:40 -04:00
|
|
|
trace of it from _views (i.e. there were N regions selected, we removed 1,
|
2009-05-30 14:25:59 -04:00
|
|
|
but since its the same playlist for N tracks, all N tracks updated themselves, removed the
|
2010-08-23 21:02:40 -04:00
|
|
|
corresponding regionview, and _views is now empty).
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
This could have invalidated any and all iterators into _views.
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
The heuristic we use here is: if the region selection is empty, break out of the loop
|
2009-05-30 14:25:59 -04:00
|
|
|
here. if the region selection is not empty, then restart the loop because we know that
|
|
|
|
we must have removed at least the region(view) we've just been working on as well as any
|
|
|
|
that we processed on previous iterations.
|
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
EXCEPT .... if we are doing a copy drag, then _views hasn't been modified and
|
2009-05-30 14:25:59 -04:00
|
|
|
we can just iterate.
|
|
|
|
*/
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (_views.empty()) {
|
2010-11-25 15:37:39 -05:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
} else {
|
2009-05-30 14:25:59 -04:00
|
|
|
i = _views.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
2010-03-01 19:00:00 -05:00
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
/* If we've created new regions either by copying or moving
|
|
|
|
to a new track, we want to replace the old selection with the new ones
|
2009-12-10 12:23:56 -05:00
|
|
|
*/
|
2010-03-01 19:00:00 -05:00
|
|
|
|
2009-12-10 12:23:56 -05:00
|
|
|
if (new_views.size() > 0) {
|
|
|
|
_editor->selection->set (new_views);
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2011-12-29 17:14:15 -05:00
|
|
|
for (set<boost::shared_ptr<Playlist> >::iterator p = frozen_playlists.begin(); p != frozen_playlists.end(); ++p) {
|
2009-05-30 14:25:59 -04:00
|
|
|
(*p)->thaw();
|
2011-12-26 20:42:49 -05:00
|
|
|
}
|
2011-12-27 13:33:49 -05:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
/* write commands for the accumulated diffs for all our modified playlists */
|
|
|
|
add_stateful_diff_commands_for_playlists (modified_playlists);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-23 22:10:46 -04:00
|
|
|
_editor->commit_reversible_command ();
|
2011-12-27 16:10:20 -05:00
|
|
|
|
|
|
|
/* We have futzed with the layering of canvas items on our streamviews.
|
|
|
|
If any region changed layer, this will have resulted in the stream
|
2011-12-29 17:14:15 -05:00
|
|
|
views being asked to set up their region views, and all will be well.
|
|
|
|
If not, we might now have badly-ordered region views. Ask the StreamViews
|
|
|
|
involved to sort themselves out, just in case.
|
2011-12-27 16:10:20 -05:00
|
|
|
*/
|
2011-12-29 17:14:15 -05:00
|
|
|
|
2011-12-27 16:10:20 -05:00
|
|
|
for (set<RouteTimeAxisView*>::iterator i = views_to_update.begin(); i != views_to_update.end(); ++i) {
|
|
|
|
(*i)->view()->playlist_layered ((*i)->track ());
|
|
|
|
}
|
2010-08-23 21:02:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Remove a region from a playlist, clearing the diff history of the playlist first if necessary.
|
|
|
|
* @param region Region to remove.
|
|
|
|
* @param playlist playlist To remove from.
|
|
|
|
* @param modified_playlists The playlist will be added to this if it is not there already; used to ensure
|
2010-08-25 13:32:08 -04:00
|
|
|
* that clear_changes () is only called once per playlist.
|
2010-08-23 21:02:40 -04:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
RegionMoveDrag::remove_region_from_playlist (
|
|
|
|
boost::shared_ptr<Region> region,
|
|
|
|
boost::shared_ptr<Playlist> playlist,
|
|
|
|
PlaylistSet& modified_playlists
|
|
|
|
)
|
|
|
|
{
|
|
|
|
pair<set<boost::shared_ptr<Playlist> >::iterator, bool> r = modified_playlists.insert (playlist);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
if (r.second) {
|
2010-08-25 13:32:08 -04:00
|
|
|
playlist->clear_changes ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2010-08-23 21:02:40 -04:00
|
|
|
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
playlist->remove_region (region); // should be no need to ripple; we better already have rippled the playlist in RegionRippleDrag
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-08-23 21:02:40 -04:00
|
|
|
|
|
|
|
/** Insert a region into a playlist, handling the recovery of the resulting new RegionView, and
|
|
|
|
* clearing the playlist's diff history first if necessary.
|
|
|
|
* @param region Region to insert.
|
|
|
|
* @param dest_rtv Destination RouteTimeAxisView.
|
|
|
|
* @param dest_layer Destination layer.
|
|
|
|
* @param where Destination position.
|
|
|
|
* @param modified_playlists The playlist will be added to this if it is not there already; used to ensure
|
2011-06-01 13:00:29 -04:00
|
|
|
* that clear_changes () is only called once per playlist.
|
2010-08-23 21:02:40 -04:00
|
|
|
* @return New RegionView, or 0 if no insert was performed.
|
|
|
|
*/
|
|
|
|
RegionView *
|
|
|
|
RegionMoveDrag::insert_region_into_playlist (
|
|
|
|
boost::shared_ptr<Region> region,
|
|
|
|
RouteTimeAxisView* dest_rtv,
|
|
|
|
layer_t dest_layer,
|
|
|
|
framecnt_t where,
|
|
|
|
PlaylistSet& modified_playlists
|
|
|
|
)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<Playlist> dest_playlist = dest_rtv->playlist ();
|
|
|
|
if (!dest_playlist) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* arrange to collect the new region view that will be created as a result of our playlist insertion */
|
|
|
|
_new_region_view = 0;
|
|
|
|
sigc::connection c = dest_rtv->view()->RegionViewAdded.connect (sigc::mem_fun (*this, &RegionMoveDrag::collect_new_region_view));
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
/* clear history for the playlist we are about to insert to, provided we haven't already done so */
|
2010-08-23 21:02:40 -04:00
|
|
|
pair<PlaylistSet::iterator, bool> r = modified_playlists.insert (dest_playlist);
|
|
|
|
if (r.second) {
|
2010-08-25 13:32:08 -04:00
|
|
|
dest_playlist->clear_changes ();
|
2010-08-23 21:02:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
dest_playlist->add_region (region, where);
|
|
|
|
|
2011-12-26 20:42:49 -05:00
|
|
|
if (dest_rtv->view()->layer_display() == Stacked || dest_rtv->view()->layer_display() == Expanded) {
|
2011-12-30 15:05:48 -05:00
|
|
|
dest_playlist->set_layer (region, dest_layer);
|
2010-08-23 21:02:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
c.disconnect ();
|
|
|
|
|
|
|
|
assert (_new_region_view);
|
|
|
|
|
|
|
|
return _new_region_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionMoveDrag::collect_new_region_view (RegionView* rv)
|
|
|
|
{
|
|
|
|
_new_region_view = rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionMoveDrag::add_stateful_diff_commands_for_playlists (PlaylistSet const & playlists)
|
|
|
|
{
|
|
|
|
for (PlaylistSet::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
|
2010-08-25 21:44:11 -04:00
|
|
|
StatefulDiffCommand* c = new StatefulDiffCommand (*i);
|
|
|
|
if (!c->empty()) {
|
2011-01-16 14:34:00 -05:00
|
|
|
_editor->session()->add_command (c);
|
2010-08-25 21:44:11 -04:00
|
|
|
} else {
|
|
|
|
delete c;
|
|
|
|
}
|
2010-08-23 21:02:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
RegionMoveDrag::aborted (bool movement_occurred)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
|
|
|
if (_copy) {
|
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
delete i->view;
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_views.clear ();
|
|
|
|
|
|
|
|
} else {
|
2010-12-28 14:17:37 -05:00
|
|
|
RegionMotionDrag::aborted (movement_occurred);
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
RegionMotionDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2011-12-26 20:42:49 -05:00
|
|
|
for (vector<TimeAxisView*>::iterator i = _time_axis_views.begin(); i != _time_axis_views.end(); ++i) {
|
2013-07-09 09:45:54 -04:00
|
|
|
|
|
|
|
StreamView* sview = (*i)->view();
|
|
|
|
|
|
|
|
if (sview) {
|
|
|
|
if (sview->layer_display() == Expanded) {
|
|
|
|
sview->set_layer_display (Stacked);
|
|
|
|
}
|
2011-12-26 20:42:49 -05:00
|
|
|
}
|
|
|
|
}
|
2011-12-29 17:14:15 -05:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
RegionView* rv = i->view;
|
|
|
|
TimeAxisView* tv = &(rv->get_time_axis_view ());
|
2010-01-07 20:28:15 -05:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
|
|
|
|
assert (rtv);
|
2013-04-04 00:32:52 -04:00
|
|
|
rv->get_canvas_group()->reparent (rtv->view()->canvas_item());
|
|
|
|
rv->get_canvas_group()->set_y_position (0);
|
2012-05-07 18:02:17 -04:00
|
|
|
rv->drag_end ();
|
2010-04-06 20:17:54 -04:00
|
|
|
rv->move (-_total_x_delta, 0);
|
|
|
|
rv->set_height (rtv->view()->child_height ());
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
}
|
2011-03-02 12:00:35 -05:00
|
|
|
|
|
|
|
/** @param b true to brush, otherwise false.
|
|
|
|
* @param c true to make copies of the regions being moved, otherwise false.
|
|
|
|
*/
|
2009-06-08 15:28:51 -04:00
|
|
|
RegionMoveDrag::RegionMoveDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v, bool b, bool c)
|
|
|
|
: RegionMotionDrag (e, i, p, v, b),
|
|
|
|
_copy (c)
|
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New RegionMoveDrag\n");
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
double speed = 1;
|
2010-09-06 08:34:11 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (&_primary->get_time_axis_view ());
|
2009-06-08 15:28:51 -04:00
|
|
|
if (rtv && rtv->is_track()) {
|
2010-04-21 16:42:22 -04:00
|
|
|
speed = rtv->track()->speed ();
|
2009-06-08 15:28:51 -04:00
|
|
|
}
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
_last_frame_position = static_cast<framepos_t> (_primary->region()->position() / speed);
|
2009-06-08 15:28:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-19 22:42:59 -05:00
|
|
|
RegionMoveDrag::setup_pointer_frame_offset ()
|
2009-06-08 15:28:51 -04:00
|
|
|
{
|
2010-09-08 21:38:12 -04:00
|
|
|
_pointer_frame_offset = raw_grab_frame() - _last_frame_position;
|
2009-06-08 15:28:51 -04:00
|
|
|
}
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
RegionInsertDrag::RegionInsertDrag (Editor* e, boost::shared_ptr<Region> r, RouteTimeAxisView* v, framepos_t pos)
|
2009-06-08 15:28:51 -04:00
|
|
|
: RegionMotionDrag (e, 0, 0, list<RegionView*> (), false)
|
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New RegionInsertDrag\n");
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
assert ((boost::dynamic_pointer_cast<AudioRegion> (r) && dynamic_cast<AudioTimeAxisView*> (v)) ||
|
|
|
|
(boost::dynamic_pointer_cast<MidiRegion> (r) && dynamic_cast<MidiTimeAxisView*> (v)));
|
2009-06-08 15:28:51 -04:00
|
|
|
|
|
|
|
_primary = v->view()->create_region_view (r, false, false);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
_primary->get_canvas_group()->show ();
|
|
|
|
_primary->set_position (pos, 0);
|
2014-06-19 11:16:27 -04:00
|
|
|
_views.push_back (DraggingView (_primary, this, v));
|
2009-06-08 15:28:51 -04:00
|
|
|
|
|
|
|
_last_frame_position = pos;
|
|
|
|
|
|
|
|
_item = _primary->get_canvas_group ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-09-06 08:34:11 -04:00
|
|
|
RegionInsertDrag::finished (GdkEvent *, bool)
|
2009-06-08 15:28:51 -04:00
|
|
|
{
|
2010-09-06 08:34:11 -04:00
|
|
|
RouteTimeAxisView* dest_rtv = dynamic_cast<RouteTimeAxisView*> (_time_axis_views[_views.front().time_axis_view]);
|
2009-06-08 15:28:51 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_primary->get_canvas_group()->reparent (dest_rtv->view()->canvas_item());
|
|
|
|
_primary->get_canvas_group()->set_y_position (0);
|
2009-06-08 15:28:51 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<Playlist> playlist = dest_rtv->playlist();
|
|
|
|
|
2011-01-19 12:38:56 -05:00
|
|
|
_editor->begin_reversible_command (Operations::insert_region);
|
2010-11-25 15:37:39 -05:00
|
|
|
playlist->clear_changes ();
|
2009-06-08 15:28:51 -04:00
|
|
|
playlist->add_region (_primary->region (), _last_frame_position);
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
|
|
|
|
// Mixbus doesn't seem to ripple when inserting regions from the list: should we? yes, probably
|
|
|
|
if (Config->get_edit_mode() == Ripple) {
|
|
|
|
playlist->ripple (_last_frame_position, _primary->region()->length(), _primary->region());
|
|
|
|
}
|
|
|
|
|
2010-03-02 13:05:26 -05:00
|
|
|
_editor->session()->add_command (new StatefulDiffCommand (playlist));
|
2009-06-08 15:28:51 -04:00
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
|
|
|
|
delete _primary;
|
|
|
|
_primary = 0;
|
|
|
|
_views.clear ();
|
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
RegionInsertDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2010-05-05 18:09:07 -04:00
|
|
|
delete _primary;
|
|
|
|
_primary = 0;
|
|
|
|
_views.clear ();
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
RegionSpliceDrag::RegionSpliceDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v)
|
|
|
|
: RegionMoveDrag (e, i, p, v, false, false)
|
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New RegionSpliceDrag\n");
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct RegionSelectionByPosition {
|
|
|
|
bool operator() (RegionView*a, RegionView* b) {
|
|
|
|
return a->region()->position () < b->region()->position();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2009-12-21 20:12:41 -05:00
|
|
|
RegionSpliceDrag::motion (GdkEvent* event, bool)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-06 08:34:11 -04:00
|
|
|
/* Which trackview is this ? */
|
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
pair<TimeAxisView*, double> const tvp = _editor->trackview_by_y_position (current_pointer_y ());
|
2010-09-06 08:34:11 -04:00
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*> (tvp.first);
|
|
|
|
|
|
|
|
/* The region motion is only processed if the pointer is over
|
|
|
|
an audio track.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-06 08:34:11 -04:00
|
|
|
if (!tv || !tv->is_track()) {
|
|
|
|
/* To make sure we hide the verbose canvas cursor when the mouse is
|
2014-03-08 12:11:37 -05:00
|
|
|
not held over an audio track.
|
2010-09-06 08:34:11 -04:00
|
|
|
*/
|
2011-05-02 09:38:16 -04:00
|
|
|
_editor->verbose_cursor()->hide ();
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
2014-06-26 15:07:29 -04:00
|
|
|
} else {
|
|
|
|
_editor->verbose_cursor()->show ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int dir;
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if ((_drags->current_pointer_x() - last_pointer_x()) > 0) {
|
2009-05-30 14:25:59 -04:00
|
|
|
dir = 1;
|
|
|
|
} else {
|
|
|
|
dir = -1;
|
|
|
|
}
|
|
|
|
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
RegionSelection copy;
|
|
|
|
_editor->selection->regions.by_position(copy);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const pf = adjusted_current_frame (event);
|
2009-12-21 20:12:41 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
for (RegionSelection::iterator i = copy.begin(); i != copy.end(); ++i) {
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* atv = dynamic_cast<RouteTimeAxisView*> (&(*i)->get_time_axis_view());
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
if (!atv) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Playlist> playlist;
|
|
|
|
|
|
|
|
if ((playlist = atv->playlist()) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!playlist->region_is_shuffle_constrained ((*i)->region())) {
|
|
|
|
continue;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
if (dir > 0) {
|
2009-12-21 20:12:41 -05:00
|
|
|
if (pf < (*i)->region()->last_frame() + 1) {
|
2009-05-30 14:25:59 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
2009-12-21 20:12:41 -05:00
|
|
|
if (pf > (*i)->region()->first_frame()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
playlist->shuffle ((*i)->region(), dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-09-06 08:34:11 -04:00
|
|
|
RegionSpliceDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-06 08:34:11 -04:00
|
|
|
RegionMoveDrag::finished (event, movement_occurred);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
RegionSpliceDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
/***
|
|
|
|
* ripple mode...
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionRippleDrag::add_all_after_to_views(TimeAxisView *tav, framepos_t where, const RegionSelection &exclude, bool drag_in_progress)
|
|
|
|
{
|
2014-07-01 15:40:40 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<RegionList> rl = tav->playlist()->regions_with_start_within (Evoral::Range<framepos_t>(where, max_framepos));
|
|
|
|
|
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(tav);
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
RegionSelection to_ripple;
|
2014-07-01 15:40:40 -04:00
|
|
|
for (RegionList::iterator i = rl->begin(); i != rl->end(); ++i) {
|
|
|
|
if ((*i)->position() >= where) {
|
|
|
|
to_ripple.push_back (rtv->view()->find_view(*i));
|
|
|
|
}
|
|
|
|
}
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
|
|
|
|
for (RegionSelection::iterator i = to_ripple.begin(); i != to_ripple.end(); ++i) {
|
|
|
|
if (!exclude.contains (*i)) {
|
|
|
|
// the selection has already been added to _views
|
|
|
|
|
|
|
|
if (drag_in_progress) {
|
2014-07-01 14:33:21 -04:00
|
|
|
// do the same things that RegionMotionDrag::motion does when
|
|
|
|
// first_move is true, for the region views that we're adding
|
|
|
|
// to _views this time
|
2014-07-01 13:46:13 -04:00
|
|
|
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
(*i)->drag_start();
|
2014-07-01 13:46:13 -04:00
|
|
|
ArdourCanvas::Item* rvg = (*i)->get_canvas_group();
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
Duple rv_canvas_offset = rvg->item_to_canvas (Duple (0,0));
|
2014-07-01 14:10:47 -04:00
|
|
|
Duple dmg_canvas_offset = _editor->_drag_motion_group->canvas_origin ();
|
|
|
|
rvg->reparent (_editor->_drag_motion_group);
|
|
|
|
|
2014-07-01 14:33:21 -04:00
|
|
|
// we only need to move in the y direction
|
2014-07-01 14:10:47 -04:00
|
|
|
Duple fudge = rv_canvas_offset - dmg_canvas_offset;
|
|
|
|
fudge.x = 0;
|
|
|
|
rvg->move (fudge);
|
|
|
|
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
}
|
2014-07-01 14:10:47 -04:00
|
|
|
_views.push_back (DraggingView (*i, this, tav));
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-07-01 13:46:13 -04:00
|
|
|
RegionRippleDrag::remove_unselected_from_views(framecnt_t amount, bool move_regions)
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
for (std::list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ) {
|
|
|
|
// we added all the regions after the selection
|
|
|
|
|
|
|
|
std::list<DraggingView>::iterator to_erase = i++;
|
|
|
|
if (!_editor->selection->regions.contains (to_erase->view)) {
|
|
|
|
// restore the non-selected regions to their original playlist & positions,
|
|
|
|
// and then ripple them back by the length of the regions that were dragged away
|
|
|
|
// do the same things as RegionMotionDrag::aborted
|
|
|
|
|
|
|
|
RegionView *rv = to_erase->view;
|
2014-07-01 13:46:13 -04:00
|
|
|
TimeAxisView* tv = &(rv->get_time_axis_view ());
|
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
|
|
|
|
assert (rtv);
|
|
|
|
|
|
|
|
// plonk them back onto their own track
|
|
|
|
rv->get_canvas_group()->reparent(rtv->view()->canvas_item());
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
rv->get_canvas_group()->set_y_position (0);
|
|
|
|
rv->drag_end ();
|
|
|
|
|
2014-07-01 13:46:13 -04:00
|
|
|
if (move_regions) {
|
|
|
|
// move the underlying region to match the view
|
|
|
|
rv->region()->set_position (rv->region()->position() + amount);
|
|
|
|
} else {
|
|
|
|
// restore the view to match the underlying region's original position
|
|
|
|
rv->move(-amount, 0); // second parameter is y delta - seems 0 is OK
|
|
|
|
}
|
|
|
|
|
|
|
|
rv->set_height (rtv->view()->child_height ());
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
_views.erase (to_erase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-01 08:23:43 -04:00
|
|
|
bool
|
|
|
|
RegionRippleDrag::y_movement_allowed (int delta_track, double delta_layer) const
|
|
|
|
{
|
|
|
|
if (RegionMotionDrag::y_movement_allowed (delta_track, delta_layer)) {
|
|
|
|
if (delta_track) {
|
|
|
|
return allow_moves_across_tracks;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
RegionRippleDrag::RegionRippleDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v)
|
|
|
|
: RegionMoveDrag (e, i, p, v, false, false)
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New RegionRippleDrag\n");
|
|
|
|
// compute length of selection
|
|
|
|
RegionSelection selected_regions = _editor->selection->regions;
|
|
|
|
selection_length = selected_regions.end_frame() - selected_regions.start();
|
|
|
|
|
|
|
|
// we'll only allow dragging to another track in ripple mode if all the regions
|
|
|
|
// being dragged start off on the same track
|
|
|
|
allow_moves_across_tracks = (selected_regions.playlists().size() == 1);
|
|
|
|
prev_tav = NULL;
|
|
|
|
prev_amount = 0;
|
|
|
|
exclude = new RegionList;
|
|
|
|
for (RegionSelection::iterator i =selected_regions.begin(); i != selected_regions.end(); ++i) {
|
|
|
|
exclude->push_back((*i)->region());
|
|
|
|
}
|
|
|
|
|
|
|
|
// also add regions before start of selection to exclude, to be consistent with how Mixbus does ripple
|
|
|
|
RegionSelection copy;
|
|
|
|
selected_regions.by_position(copy); // get selected regions sorted by position into copy
|
|
|
|
|
|
|
|
std::set<boost::shared_ptr<ARDOUR::Playlist> > playlists = copy.playlists();
|
|
|
|
std::set<boost::shared_ptr<ARDOUR::Playlist> >::const_iterator pi;
|
|
|
|
|
|
|
|
for (pi = playlists.begin(); pi != playlists.end(); ++pi) {
|
|
|
|
// find ripple start point on each applicable playlist
|
|
|
|
RegionView *first_selected_on_this_track = NULL;
|
|
|
|
for (RegionSelection::iterator i = copy.begin(); i != copy.end(); ++i) {
|
|
|
|
if ((*i)->region()->playlist() == (*pi)) {
|
|
|
|
// region is on this playlist - it's the first, because they're sorted
|
|
|
|
first_selected_on_this_track = *i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert (first_selected_on_this_track); // we should always find the region in one of the playlists...
|
|
|
|
add_all_after_to_views (
|
|
|
|
&first_selected_on_this_track->get_time_axis_view(),
|
2014-07-01 15:40:40 -04:00
|
|
|
first_selected_on_this_track->region()->position(),
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
selected_regions, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (allow_moves_across_tracks) {
|
|
|
|
orig_tav = &(*selected_regions.begin())->get_time_axis_view();
|
|
|
|
} else {
|
|
|
|
orig_tav = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionRippleDrag::motion (GdkEvent* event, bool first_move)
|
|
|
|
{
|
|
|
|
/* Which trackview is this ? */
|
|
|
|
|
2014-07-01 14:10:47 -04:00
|
|
|
pair<TimeAxisView*, double> const tvp = _editor->trackview_by_y_position (current_pointer_y ());
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*> (tvp.first);
|
|
|
|
|
|
|
|
/* The region motion is only processed if the pointer is over
|
|
|
|
an audio track.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!tv || !tv->is_track()) {
|
|
|
|
/* To make sure we hide the verbose canvas cursor when the mouse is
|
|
|
|
not held over an audiotrack.
|
|
|
|
*/
|
|
|
|
_editor->verbose_cursor()->hide ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
framepos_t where = adjusted_current_frame (event);
|
|
|
|
assert (where >= 0);
|
|
|
|
framepos_t after;
|
|
|
|
double delta = compute_x_delta (event, &after);
|
|
|
|
|
|
|
|
framecnt_t amount = _editor->pixel_to_sample (delta);
|
|
|
|
|
|
|
|
if (allow_moves_across_tracks) {
|
|
|
|
// all the originally selected regions were on the same track
|
|
|
|
|
|
|
|
framecnt_t adjust = 0;
|
|
|
|
if (prev_tav && tv != prev_tav) {
|
|
|
|
// dragged onto a different track
|
|
|
|
// remove the unselected regions from _views, restore them to their original positions
|
|
|
|
// and add the regions after the drop point on the new playlist to _views instead.
|
|
|
|
// undo the effect of rippling the previous playlist, and include the effect of removing
|
|
|
|
// the dragged region(s) from this track
|
|
|
|
|
2014-07-01 13:46:13 -04:00
|
|
|
remove_unselected_from_views (prev_amount, false);
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
// ripple previous playlist according to the regions that have been removed onto the new playlist
|
|
|
|
prev_tav->playlist()->ripple(prev_position, -selection_length, exclude);
|
|
|
|
prev_amount = 0;
|
|
|
|
|
|
|
|
// move just the selected regions
|
|
|
|
RegionMoveDrag::motion(event, first_move);
|
|
|
|
|
|
|
|
// ensure that the ripple operation on the new playlist inserts selection_length time
|
|
|
|
adjust = selection_length;
|
|
|
|
// ripple the new current playlist
|
|
|
|
tv->playlist()->ripple (where, amount+adjust, exclude);
|
|
|
|
|
|
|
|
// add regions after point where drag entered this track to subsequent ripples
|
|
|
|
add_all_after_to_views (tv, where, _editor->selection->regions, true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// motion on same track
|
|
|
|
RegionMoveDrag::motion(event, first_move);
|
|
|
|
}
|
|
|
|
prev_tav = tv;
|
|
|
|
|
|
|
|
// remember what we've done to this playlist so we can undo it if the selection is dragged to another track
|
|
|
|
prev_position = where;
|
|
|
|
} else {
|
|
|
|
// selection encompasses multiple tracks - just drag
|
|
|
|
// cross-track drags are forbidden
|
|
|
|
RegionMoveDrag::motion(event, first_move);
|
|
|
|
}
|
|
|
|
|
2014-07-01 13:46:13 -04:00
|
|
|
if (!_x_constrained) {
|
|
|
|
prev_amount += amount;
|
|
|
|
}
|
|
|
|
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
_last_frame_position = after;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionRippleDrag::finished (GdkEvent* event, bool movement_occurred)
|
|
|
|
{
|
|
|
|
if (!movement_occurred) {
|
2014-09-15 12:43:12 -04:00
|
|
|
|
|
|
|
/* just a click */
|
|
|
|
|
|
|
|
if (was_double_click() && !_views.empty()) {
|
|
|
|
DraggingView dv = _views.front();
|
|
|
|
dv.view->show_region_editor ();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_editor->begin_reversible_command(_("Ripple drag"));
|
|
|
|
|
2014-07-01 13:46:13 -04:00
|
|
|
// remove the regions being rippled from the dragging view, updating them to
|
|
|
|
// their new positions
|
|
|
|
remove_unselected_from_views (prev_amount, true);
|
|
|
|
|
|
|
|
if (allow_moves_across_tracks) {
|
|
|
|
if (orig_tav) {
|
|
|
|
// if regions were dragged across tracks, we've rippled any later
|
|
|
|
// regions on the track the regions were dragged off, so we need
|
|
|
|
// to add the original track to the undo record
|
|
|
|
orig_tav->playlist()->clear_changes();
|
|
|
|
vector<Command*> cmds;
|
|
|
|
orig_tav->playlist()->rdiff (cmds);
|
|
|
|
_editor->session()->add_commands (cmds);
|
|
|
|
}
|
|
|
|
if (prev_tav && prev_tav != orig_tav) {
|
|
|
|
prev_tav->playlist()->clear_changes();
|
|
|
|
vector<Command*> cmds;
|
|
|
|
prev_tav->playlist()->rdiff (cmds);
|
|
|
|
_editor->session()->add_commands (cmds);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// selection spanned multiple tracks - all will need adding to undo record
|
|
|
|
|
|
|
|
std::set<boost::shared_ptr<ARDOUR::Playlist> > playlists = _editor->selection->regions.playlists();
|
|
|
|
std::set<boost::shared_ptr<ARDOUR::Playlist> >::const_iterator pi;
|
|
|
|
|
|
|
|
for (pi = playlists.begin(); pi != playlists.end(); ++pi) {
|
|
|
|
(*pi)->clear_changes();
|
|
|
|
vector<Command*> cmds;
|
|
|
|
(*pi)->rdiff (cmds);
|
|
|
|
_editor->session()->add_commands (cmds);
|
|
|
|
}
|
Ripple mode: basic implementation
Add a value for Ripple to EditMode enum.
Add Ripple edit mode to edit mode dropdown, by adding it to the
Editor::build_edit_mode_menu() helper function, and remove the old code that
added items to the (now unused) Editor::edit_mode_strings.
Add the regions that should be affected by the drag to RegionDrag::_views so
that the drag carries them along automatically.
Use a copy of the RegionList in Playlist::core_ripple(), since bad things
happen when iterating over regions and they get moved around in the list.
Handle rippling in removal of regions from playlist.
When dragging in ripple mode, exclude all regions that lie before the
original start position of the selected regions being dragged from
rippling: this is what Mixbus does.
Make editor dragging respect snap-to settings, by using the existing
compute_x_delta() function, which did almost the right thing. Move setting
of _last_frame_position out of that function so all ripple-dragged regions
can move.
Ripple when dragging from region list: even though Mixbus doesn't do this, it
seems like a good idea.
Prevent multi-track selection being dragged across tracks, by making
RegionMotionDrag::y_movement_allowed() virtual, and overriding it in
RegionRippleDrag to forbid dragging of selections containing regions on more
than one track to dofferent tracks in ripple mode.
Remember which TimeAxisView a ripple-mode drag that's allowed cross-track
drags started from, so that the effect of rippling regions after any region
that's dragged off that track can be undone.
2013-10-23 16:50:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// other modified playlists are added to undo by RegionMoveDrag::finished()
|
|
|
|
RegionMoveDrag::finished (event, movement_occurred);
|
|
|
|
_editor->commit_reversible_command();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionRippleDrag::aborted (bool movement_occurred)
|
|
|
|
{
|
|
|
|
RegionMoveDrag::aborted (movement_occurred);
|
|
|
|
_views.clear ();
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RegionCreateDrag::RegionCreateDrag (Editor* e, ArdourCanvas::Item* i, TimeAxisView* v)
|
2009-05-30 14:25:59 -04:00
|
|
|
: Drag (e, i),
|
2010-08-20 08:01:13 -04:00
|
|
|
_view (dynamic_cast<MidiTimeAxisView*> (v))
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New RegionCreateDrag\n");
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-08-20 08:01:13 -04:00
|
|
|
assert (_view);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-08-25 08:23:52 -04:00
|
|
|
RegionCreateDrag::motion (GdkEvent* event, bool first_move)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2009-06-01 20:39:57 -04:00
|
|
|
if (first_move) {
|
2012-01-25 14:39:20 -05:00
|
|
|
_region = add_midi_region (_view);
|
2011-03-01 11:23:31 -05:00
|
|
|
_view->playlist()->freeze ();
|
2010-08-20 08:01:13 -04:00
|
|
|
} else {
|
2010-11-25 15:37:39 -05:00
|
|
|
if (_region) {
|
|
|
|
framepos_t const f = adjusted_current_frame (event);
|
|
|
|
if (f < grab_frame()) {
|
2011-05-30 09:54:44 -04:00
|
|
|
_region->set_position (f);
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-04-20 19:50:31 -04:00
|
|
|
/* Don't use a zero-length region, and subtract 1 frame from the snapped length
|
|
|
|
so that if this region is duplicated, its duplicate starts on
|
|
|
|
a snap point rather than 1 frame after a snap point. Otherwise things get
|
|
|
|
a bit confusing as if a region starts 1 frame after a snap point, one cannot
|
|
|
|
place snapped notes at the start of the region.
|
|
|
|
*/
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-10-03 04:06:56 -04:00
|
|
|
framecnt_t const len = (framecnt_t) fabs ((double)(f - grab_frame () - 1));
|
2011-05-30 09:54:44 -04:00
|
|
|
_region->set_length (len < 1 ? 1 : len);
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
void
|
2010-11-13 00:14:48 -05:00
|
|
|
RegionCreateDrag::finished (GdkEvent*, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-13 15:46:28 -04:00
|
|
|
if (!movement_occurred) {
|
2012-01-25 14:39:20 -05:00
|
|
|
add_midi_region (_view);
|
2011-03-01 11:23:31 -05:00
|
|
|
} else {
|
|
|
|
_view->playlist()->thaw ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2010-09-13 15:46:28 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
RegionCreateDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2011-03-01 11:23:31 -05:00
|
|
|
if (_region) {
|
|
|
|
_view->playlist()->thaw ();
|
|
|
|
}
|
|
|
|
|
2010-08-20 08:01:13 -04:00
|
|
|
/* XXX */
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2009-09-08 17:45:44 -04:00
|
|
|
NoteResizeDrag::NoteResizeDrag (Editor* e, ArdourCanvas::Item* i)
|
|
|
|
: Drag (e, i)
|
|
|
|
, region (0)
|
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New NoteResizeDrag\n");
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-17 18:09:07 -04:00
|
|
|
NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*ignored*/)
|
2009-09-08 17:45:44 -04:00
|
|
|
{
|
2010-06-17 11:06:30 -04:00
|
|
|
Gdk::Cursor* cursor;
|
2013-04-04 00:32:52 -04:00
|
|
|
NoteBase* cnote = reinterpret_cast<NoteBase*> (_item->get_data ("notebase"));
|
|
|
|
assert (cnote);
|
2010-11-25 15:37:39 -05:00
|
|
|
float x_fraction = cnote->mouse_x_fraction ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (x_fraction > 0.0 && x_fraction < 0.25) {
|
|
|
|
cursor = _editor->cursors()->left_side_trim;
|
2014-11-18 02:20:38 -05:00
|
|
|
at_front = true;
|
2010-11-25 15:37:39 -05:00
|
|
|
} else {
|
|
|
|
cursor = _editor->cursors()->right_side_trim;
|
2014-11-18 02:20:38 -05:00
|
|
|
at_front = false;
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2010-09-22 11:21:06 -04:00
|
|
|
|
|
|
|
Drag::start_grab (event, cursor);
|
2009-09-08 17:45:44 -04:00
|
|
|
|
|
|
|
region = &cnote->region_view();
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_item->grab ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-08 17:45:44 -04:00
|
|
|
if (event->motion.state & Keyboard::PrimaryModifier) {
|
|
|
|
relative = false;
|
|
|
|
} else {
|
|
|
|
relative = true;
|
|
|
|
}
|
2009-09-08 22:09:04 -04:00
|
|
|
|
|
|
|
MidiRegionSelection& ms (_editor->get_selection().midi_regions);
|
|
|
|
|
|
|
|
if (ms.size() > 1) {
|
|
|
|
/* has to be relative, may make no sense otherwise */
|
|
|
|
relative = true;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-05-26 19:17:10 -04:00
|
|
|
/* select this note; if it is already selected, preserve the existing selection,
|
|
|
|
otherwise make this note the only one selected.
|
|
|
|
*/
|
|
|
|
region->note_selected (cnote, cnote->selected ());
|
2009-09-08 22:09:04 -04:00
|
|
|
|
2015-01-16 12:55:05 -05:00
|
|
|
_editor->begin_reversible_command (_("resize notes"));
|
|
|
|
|
2009-09-08 22:09:04 -04:00
|
|
|
for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ) {
|
|
|
|
MidiRegionSelection::iterator next;
|
|
|
|
next = r;
|
|
|
|
++next;
|
2014-11-13 21:32:08 -05:00
|
|
|
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*r);
|
|
|
|
if (mrv) {
|
|
|
|
mrv->begin_resizing (at_front);
|
|
|
|
}
|
2009-09-08 22:09:04 -04:00
|
|
|
r = next;
|
|
|
|
}
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-09-15 11:23:59 -04:00
|
|
|
NoteResizeDrag::motion (GdkEvent* /*event*/, bool /*first_move*/)
|
2009-09-08 17:45:44 -04:00
|
|
|
{
|
2009-09-08 22:09:04 -04:00
|
|
|
MidiRegionSelection& ms (_editor->get_selection().midi_regions);
|
2009-09-10 16:41:08 -04:00
|
|
|
for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ++r) {
|
2013-04-04 00:32:52 -04:00
|
|
|
NoteBase* nb = reinterpret_cast<NoteBase*> (_item->get_data ("notebase"));
|
|
|
|
assert (nb);
|
2014-11-13 21:32:08 -05:00
|
|
|
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*r);
|
|
|
|
if (mrv) {
|
|
|
|
mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative);
|
|
|
|
}
|
2009-09-08 22:09:04 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-09-08 17:45:44 -04:00
|
|
|
|
|
|
|
void
|
2009-09-15 11:23:59 -04:00
|
|
|
NoteResizeDrag::finished (GdkEvent*, bool /*movement_occurred*/)
|
2009-09-08 17:45:44 -04:00
|
|
|
{
|
2009-09-08 22:09:04 -04:00
|
|
|
MidiRegionSelection& ms (_editor->get_selection().midi_regions);
|
2009-09-10 16:41:08 -04:00
|
|
|
for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ++r) {
|
2013-04-04 00:32:52 -04:00
|
|
|
NoteBase* nb = reinterpret_cast<NoteBase*> (_item->get_data ("notebase"));
|
|
|
|
assert (nb);
|
2014-11-13 21:32:08 -05:00
|
|
|
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*r);
|
|
|
|
if (mrv) {
|
|
|
|
mrv->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative);
|
|
|
|
}
|
2009-09-08 22:09:04 -04:00
|
|
|
}
|
2015-01-16 12:55:05 -05:00
|
|
|
|
|
|
|
_editor->commit_reversible_command ();
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
NoteResizeDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2011-12-02 22:05:59 -05:00
|
|
|
MidiRegionSelection& ms (_editor->get_selection().midi_regions);
|
|
|
|
for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ++r) {
|
2014-11-13 21:32:08 -05:00
|
|
|
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*r);
|
|
|
|
if (mrv) {
|
|
|
|
mrv->abort_resizing ();
|
|
|
|
}
|
2011-12-02 22:05:59 -05:00
|
|
|
}
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2013-03-12 17:00:09 -04:00
|
|
|
AVDraggingView::AVDraggingView (RegionView* v)
|
|
|
|
: view (v)
|
|
|
|
{
|
|
|
|
initial_position = v->region()->position ();
|
|
|
|
}
|
|
|
|
|
|
|
|
VideoTimeLineDrag::VideoTimeLineDrag (Editor* e, ArdourCanvas::Item* i)
|
|
|
|
: Drag (e, i)
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New VideoTimeLineDrag\n");
|
|
|
|
|
|
|
|
RegionSelection rs;
|
|
|
|
TrackViewList empty;
|
|
|
|
empty.clear();
|
|
|
|
_editor->get_regions_after(rs, (framepos_t) 0, empty);
|
|
|
|
std::list<RegionView*> views = rs.by_layer();
|
2013-04-11 13:49:29 -04:00
|
|
|
|
2013-03-12 17:00:09 -04:00
|
|
|
for (list<RegionView*>::iterator i = views.begin(); i != views.end(); ++i) {
|
|
|
|
RegionView* rv = (*i);
|
|
|
|
if (!rv->region()->video_locked()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
_views.push_back (AVDraggingView (rv));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VideoTimeLineDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event);
|
|
|
|
if (_editor->session() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_startdrag_video_offset=ARDOUR_UI::instance()->video_timeline->get_offset();
|
|
|
|
_max_backwards_drag = (
|
|
|
|
ARDOUR_UI::instance()->video_timeline->get_duration()
|
|
|
|
+ ARDOUR_UI::instance()->video_timeline->get_offset()
|
|
|
|
- ceil(ARDOUR_UI::instance()->video_timeline->get_apv())
|
|
|
|
);
|
|
|
|
|
|
|
|
for (list<AVDraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
if (i->initial_position < _max_backwards_drag || _max_backwards_drag < 0) {
|
|
|
|
_max_backwards_drag = ARDOUR_UI::instance()->video_timeline->quantify_frames_to_apv (i->initial_position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DEBUG_TRACE (DEBUG::Drags, string_compose("VideoTimeLineDrag: max backwards-drag: %1\n", _max_backwards_drag));
|
|
|
|
|
|
|
|
char buf[128];
|
|
|
|
Timecode::Time timecode;
|
|
|
|
_editor->session()->sample_to_timecode(abs(_startdrag_video_offset), timecode, true /* use_offset */, false /* use_subframes */ );
|
|
|
|
snprintf (buf, sizeof (buf), "Video Start:\n%c%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32, (_startdrag_video_offset<0?'-':' '), timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
|
2014-06-26 15:07:29 -04:00
|
|
|
show_verbose_cursor_text (buf);
|
2013-03-12 17:00:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VideoTimeLineDrag::motion (GdkEvent* event, bool first_move)
|
|
|
|
{
|
|
|
|
if (_editor->session() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ARDOUR_UI::instance()->video_timeline->is_offset_locked()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
framecnt_t dt = adjusted_current_frame (event) - raw_grab_frame() + _pointer_frame_offset;
|
2013-08-04 12:49:28 -04:00
|
|
|
dt = ARDOUR_UI::instance()->video_timeline->quantify_frames_to_apv(_startdrag_video_offset+dt) - _startdrag_video_offset;
|
2013-03-12 17:00:09 -04:00
|
|
|
|
|
|
|
if (_max_backwards_drag >= 0 && dt <= - _max_backwards_drag) {
|
|
|
|
dt = - _max_backwards_drag;
|
|
|
|
}
|
|
|
|
|
|
|
|
ARDOUR_UI::instance()->video_timeline->set_offset(_startdrag_video_offset+dt);
|
|
|
|
ARDOUR_UI::instance()->flush_videotimeline_cache(true);
|
|
|
|
|
|
|
|
for (list<AVDraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
RegionView* rv = i->view;
|
|
|
|
DEBUG_TRACE (DEBUG::Drags, string_compose("SHIFT REGION at %1 by %2\n", i->initial_position, dt));
|
|
|
|
if (first_move) {
|
|
|
|
rv->drag_start ();
|
|
|
|
rv->region()->clear_changes ();
|
|
|
|
rv->region()->suspend_property_changes();
|
|
|
|
}
|
|
|
|
rv->region()->set_position(i->initial_position + dt);
|
|
|
|
rv->region_changed(ARDOUR::Properties::position);
|
|
|
|
}
|
|
|
|
|
|
|
|
const framepos_t offset = ARDOUR_UI::instance()->video_timeline->get_offset();
|
|
|
|
Timecode::Time timecode;
|
|
|
|
Timecode::Time timediff;
|
|
|
|
char buf[128];
|
|
|
|
_editor->session()->sample_to_timecode(abs(offset), timecode, true /* use_offset */, false /* use_subframes */ );
|
|
|
|
_editor->session()->sample_to_timecode(abs(dt), timediff, false /* use_offset */, false /* use_subframes */ );
|
|
|
|
snprintf (buf, sizeof (buf),
|
|
|
|
"%s\n%c%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32
|
|
|
|
"\n%s\n%c%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32
|
|
|
|
, _("Video Start:"),
|
|
|
|
(offset<0?'-':' '), timecode.hours, timecode.minutes, timecode.seconds, timecode.frames
|
|
|
|
, _("Diff:"),
|
|
|
|
(dt<0?'-':' '), timediff.hours, timediff.minutes, timediff.seconds, timediff.frames
|
|
|
|
);
|
2014-06-26 15:07:29 -04:00
|
|
|
show_verbose_cursor_text (buf);
|
2013-03-12 17:00:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-03-13 20:36:36 -04:00
|
|
|
VideoTimeLineDrag::finished (GdkEvent * /*event*/, bool movement_occurred)
|
2013-03-12 17:00:09 -04:00
|
|
|
{
|
|
|
|
if (ARDOUR_UI::instance()->video_timeline->is_offset_locked()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!movement_occurred || ! _editor->session()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ARDOUR_UI::instance()->flush_videotimeline_cache(true);
|
|
|
|
|
|
|
|
_editor->begin_reversible_command (_("Move Video"));
|
|
|
|
|
|
|
|
XMLNode &before = ARDOUR_UI::instance()->video_timeline->get_state();
|
|
|
|
ARDOUR_UI::instance()->video_timeline->save_undo();
|
|
|
|
XMLNode &after = ARDOUR_UI::instance()->video_timeline->get_state();
|
|
|
|
_editor->session()->add_command(new MementoCommand<VideoTimeLine>(*(ARDOUR_UI::instance()->video_timeline), &before, &after));
|
|
|
|
|
|
|
|
for (list<AVDraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
i->view->drag_end();
|
|
|
|
i->view->region()->resume_property_changes ();
|
|
|
|
|
|
|
|
_editor->session()->add_command (new StatefulDiffCommand (i->view->region()));
|
|
|
|
}
|
|
|
|
|
2013-03-27 13:21:09 -04:00
|
|
|
_editor->session()->maybe_update_session_range(
|
2013-03-27 13:45:08 -04:00
|
|
|
std::max(ARDOUR_UI::instance()->video_timeline->get_offset(), (ARDOUR::frameoffset_t) 0),
|
|
|
|
std::max(ARDOUR_UI::instance()->video_timeline->get_offset() + ARDOUR_UI::instance()->video_timeline->get_duration(), (ARDOUR::frameoffset_t) 0)
|
2013-03-27 13:21:09 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2013-03-12 17:00:09 -04:00
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VideoTimeLineDrag::aborted (bool)
|
|
|
|
{
|
|
|
|
if (ARDOUR_UI::instance()->video_timeline->is_offset_locked()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ARDOUR_UI::instance()->video_timeline->set_offset(_startdrag_video_offset);
|
|
|
|
ARDOUR_UI::instance()->flush_videotimeline_cache(true);
|
|
|
|
|
|
|
|
for (list<AVDraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
i->view->region()->resume_property_changes ();
|
|
|
|
i->view->region()->set_position(i->initial_position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-13 11:42:05 -05:00
|
|
|
TrimDrag::TrimDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v, bool preserve_fade_anchor)
|
2009-05-30 14:25:59 -04:00
|
|
|
: RegionDrag (e, i, p, v)
|
2014-05-07 12:13:34 -04:00
|
|
|
, _preserve_fade_anchor (preserve_fade_anchor)
|
|
|
|
, _jump_position_when_done (false)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New TrimDrag\n");
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-13 00:14:48 -05:00
|
|
|
TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
double speed = 1.0;
|
2009-07-09 13:58:13 -04:00
|
|
|
TimeAxisView* tvp = &_primary->get_time_axis_view ();
|
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
if (tv && tv->is_track()) {
|
2010-04-21 16:42:22 -04:00
|
|
|
speed = tv->track()->speed();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const region_start = (framepos_t) (_primary->region()->position() / speed);
|
|
|
|
framepos_t const region_end = (framepos_t) (_primary->region()->last_frame() / speed);
|
|
|
|
framecnt_t const region_length = (framecnt_t) (_primary->region()->length() / speed);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const pf = adjusted_current_frame (event);
|
2009-12-21 20:12:41 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2010-12-09 16:34:46 -05:00
|
|
|
/* Move the contents of the region around without changing the region bounds */
|
2009-05-30 14:25:59 -04:00
|
|
|
_operation = ContentsTrim;
|
2010-11-25 15:37:39 -05:00
|
|
|
Drag::start_grab (event, _editor->cursors()->trimmer);
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
|
|
|
/* These will get overridden for a point trim.*/
|
2009-12-21 20:12:41 -05:00
|
|
|
if (pf < (region_start + region_length/2)) {
|
2010-12-07 12:16:59 -05:00
|
|
|
/* closer to front */
|
2009-05-30 14:25:59 -04:00
|
|
|
_operation = StartTrim;
|
2014-06-13 17:15:23 -04:00
|
|
|
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) {
|
|
|
|
Drag::start_grab (event, _editor->cursors()->anchored_left_side_trim);
|
|
|
|
} else {
|
|
|
|
Drag::start_grab (event, _editor->cursors()->left_side_trim);
|
|
|
|
}
|
2010-06-17 08:45:51 -04:00
|
|
|
} else {
|
2009-05-30 14:25:59 -04:00
|
|
|
/* closer to end */
|
|
|
|
_operation = EndTrim;
|
2014-06-13 17:15:23 -04:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) {
|
|
|
|
Drag::start_grab (event, _editor->cursors()->anchored_right_side_trim);
|
|
|
|
} else {
|
|
|
|
Drag::start_grab (event, _editor->cursors()->right_side_trim);
|
|
|
|
}
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2014-05-07 12:13:34 -04:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) {
|
|
|
|
_jump_position_when_done = true;
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
switch (_operation) {
|
|
|
|
case StartTrim:
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (region_start);
|
2010-11-23 20:04:53 -05:00
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
2010-12-07 12:16:59 -05:00
|
|
|
i->view->trim_front_starting ();
|
2010-11-23 20:04:53 -05:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
case EndTrim:
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (region_end);
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
case ContentsTrim:
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (pf);
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
}
|
2010-09-21 19:23:07 -04:00
|
|
|
|
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
i->view->region()->suspend_property_changes ();
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
TrimDrag::motion (GdkEvent* event, bool first_move)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
RegionView* rv = _primary;
|
|
|
|
|
|
|
|
double speed = 1.0;
|
2009-07-09 13:58:13 -04:00
|
|
|
TimeAxisView* tvp = &_primary->get_time_axis_view ();
|
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
|
2009-05-30 14:25:59 -04:00
|
|
|
pair<set<boost::shared_ptr<Playlist> >::iterator,bool> insert_result;
|
2013-04-24 15:42:14 -04:00
|
|
|
frameoffset_t frame_delta = 0;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
if (tv && tv->is_track()) {
|
2010-04-21 16:42:22 -04:00
|
|
|
speed = tv->track()->speed();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-05-30 21:53:59 -04:00
|
|
|
framecnt_t dt = adjusted_current_frame (event) - raw_grab_frame () + _pointer_frame_offset;
|
2009-12-21 20:12:41 -05:00
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
if (first_move) {
|
2009-06-21 14:34:08 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
string trim_type;
|
|
|
|
|
|
|
|
switch (_operation) {
|
|
|
|
case StartTrim:
|
|
|
|
trim_type = "Region start trim";
|
|
|
|
break;
|
|
|
|
case EndTrim:
|
|
|
|
trim_type = "Region end trim";
|
|
|
|
break;
|
|
|
|
case ContentsTrim:
|
|
|
|
trim_type = "Region content trim";
|
|
|
|
break;
|
2014-05-30 21:53:59 -04:00
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
break;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_editor->begin_reversible_command (trim_type);
|
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
RegionView* rv = i->view;
|
2010-06-28 14:43:40 -04:00
|
|
|
rv->enable_display (false);
|
2010-12-28 14:17:37 -05:00
|
|
|
rv->region()->playlist()->clear_owned_changes ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*> (rv);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-11-08 20:58:42 -05:00
|
|
|
if (arv) {
|
2009-05-30 14:25:59 -04:00
|
|
|
arv->temporarily_hide_envelope ();
|
2012-05-07 18:02:17 -04:00
|
|
|
arv->drag_start ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
boost::shared_ptr<Playlist> pl = rv->region()->playlist();
|
2009-05-30 14:25:59 -04:00
|
|
|
insert_result = _editor->motion_frozen_playlists.insert (pl);
|
|
|
|
|
|
|
|
if (insert_result.second) {
|
|
|
|
pl->freeze();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool non_overlap_trim = false;
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
if (event && Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) {
|
2009-05-30 14:25:59 -04:00
|
|
|
non_overlap_trim = true;
|
|
|
|
}
|
|
|
|
|
2014-05-30 21:53:59 -04:00
|
|
|
/* contstrain trim to fade length */
|
|
|
|
if (_preserve_fade_anchor) {
|
|
|
|
switch (_operation) {
|
|
|
|
case StartTrim:
|
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (i->view);
|
|
|
|
if (!arv) continue;
|
|
|
|
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
|
|
|
if (ar->locked()) continue;
|
|
|
|
framecnt_t len = ar->fade_in()->back()->when;
|
|
|
|
if (len < dt) dt = min(dt, len);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EndTrim:
|
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (i->view);
|
|
|
|
if (!arv) continue;
|
|
|
|
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
|
|
|
if (ar->locked()) continue;
|
|
|
|
framecnt_t len = ar->fade_out()->back()->when;
|
|
|
|
if (len < -dt) dt = max(dt, -len);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ContentsTrim:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
switch (_operation) {
|
2009-05-30 14:25:59 -04:00
|
|
|
case StartTrim:
|
2014-05-30 21:53:59 -04:00
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
2012-12-13 11:42:05 -05:00
|
|
|
bool changed = i->view->trim_front (i->initial_position + dt, non_overlap_trim);
|
|
|
|
if (changed && _preserve_fade_anchor) {
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (i->view);
|
|
|
|
if (arv) {
|
|
|
|
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
2014-05-30 21:53:59 -04:00
|
|
|
framecnt_t len = ar->fade_in()->back()->when;
|
|
|
|
framecnt_t diff = ar->first_frame() - i->initial_position;
|
2014-05-31 18:40:07 -04:00
|
|
|
framepos_t new_length = len - diff;
|
|
|
|
i->anchored_fade_length = min (ar->length(), new_length);
|
|
|
|
//i->anchored_fade_length = ar->verify_xfade_bounds (new_length, true /*START*/ );
|
2014-05-30 21:53:59 -04:00
|
|
|
arv->reset_fade_in_shape_width (ar, i->anchored_fade_length, true);
|
2012-12-13 11:42:05 -05:00
|
|
|
}
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2010-05-04 21:54:16 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
case EndTrim:
|
2014-05-30 21:53:59 -04:00
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
2012-12-13 11:42:05 -05:00
|
|
|
bool changed = i->view->trim_end (i->initial_end + dt, non_overlap_trim);
|
|
|
|
if (changed && _preserve_fade_anchor) {
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (i->view);
|
|
|
|
if (arv) {
|
|
|
|
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
2014-05-30 21:53:59 -04:00
|
|
|
framecnt_t len = ar->fade_out()->back()->when;
|
|
|
|
framecnt_t diff = 1 + ar->last_frame() - i->initial_end;
|
2014-05-31 18:40:07 -04:00
|
|
|
framepos_t new_length = len + diff;
|
|
|
|
i->anchored_fade_length = min (ar->length(), new_length);
|
|
|
|
//i->anchored_fade_length = ar->verify_xfade_bounds (new_length, false /*END*/ );
|
2014-05-30 21:53:59 -04:00
|
|
|
arv->reset_fade_out_shape_width (ar, i->anchored_fade_length, true);
|
2012-12-13 11:42:05 -05:00
|
|
|
}
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2010-05-04 21:54:16 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
case ContentsTrim:
|
|
|
|
{
|
2014-04-15 17:13:06 -04:00
|
|
|
frame_delta = (last_pointer_frame() - adjusted_current_frame(event));
|
2010-05-04 21:54:16 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
2013-04-24 15:42:14 -04:00
|
|
|
i->view->move_contents (frame_delta);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (_operation) {
|
|
|
|
case StartTrim:
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time ((framepos_t) (rv->region()->position() / speed));
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
case EndTrim:
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time ((framepos_t) (rv->region()->last_frame() / speed));
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
case ContentsTrim:
|
2013-04-24 15:42:14 -04:00
|
|
|
// show_verbose_cursor_time (frame_delta);
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
TrimDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2009-06-01 20:39:57 -04:00
|
|
|
if (movement_occurred) {
|
|
|
|
motion (event, false);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-12-09 16:34:46 -05:00
|
|
|
if (_operation == StartTrim) {
|
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
2012-12-13 11:42:05 -05:00
|
|
|
{
|
|
|
|
/* This must happen before the region's StatefulDiffCommand is created, as it may
|
|
|
|
`correct' (ahem) the region's _start from being negative to being zero. It
|
|
|
|
needs to be zero in the undo record.
|
|
|
|
*/
|
|
|
|
i->view->trim_front_ending ();
|
|
|
|
}
|
|
|
|
if (_preserve_fade_anchor) {
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (i->view);
|
|
|
|
if (arv) {
|
|
|
|
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
2014-05-30 21:53:59 -04:00
|
|
|
arv->reset_fade_in_shape_width (ar, i->anchored_fade_length);
|
|
|
|
ar->set_fade_in_length(i->anchored_fade_length);
|
|
|
|
ar->set_fade_in_active(true);
|
2012-12-13 11:42:05 -05:00
|
|
|
}
|
|
|
|
}
|
2014-05-07 12:13:34 -04:00
|
|
|
if (_jump_position_when_done) {
|
|
|
|
i->view->region()->set_position (i->initial_position);
|
|
|
|
}
|
2012-12-13 11:42:05 -05:00
|
|
|
}
|
|
|
|
} else if (_operation == EndTrim) {
|
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
if (_preserve_fade_anchor) {
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (i->view);
|
|
|
|
if (arv) {
|
|
|
|
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
2014-05-30 21:53:59 -04:00
|
|
|
arv->reset_fade_out_shape_width (ar, i->anchored_fade_length);
|
|
|
|
ar->set_fade_out_length(i->anchored_fade_length);
|
|
|
|
ar->set_fade_out_active(true);
|
2012-12-13 11:42:05 -05:00
|
|
|
}
|
|
|
|
}
|
2014-05-07 12:13:34 -04:00
|
|
|
if (_jump_position_when_done) {
|
|
|
|
i->view->region()->set_position (i->initial_end - i->view->region()->length());
|
|
|
|
}
|
2010-12-09 16:34:46 -05:00
|
|
|
}
|
|
|
|
}
|
2013-01-20 01:57:52 -05:00
|
|
|
|
|
|
|
if (!_views.empty()) {
|
|
|
|
if (_operation == StartTrim) {
|
|
|
|
_editor->maybe_locate_with_edit_preroll(
|
|
|
|
_views.begin()->view->region()->position());
|
|
|
|
}
|
|
|
|
if (_operation == EndTrim) {
|
|
|
|
_editor->maybe_locate_with_edit_preroll(
|
|
|
|
_views.begin()->view->region()->position() +
|
|
|
|
_views.begin()->view->region()->length());
|
|
|
|
}
|
2012-11-20 14:43:43 -05:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (!_editor->selection->selected (_primary)) {
|
2010-11-08 20:58:12 -05:00
|
|
|
_primary->thaw_after_trim ();
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-12-28 14:17:37 -05:00
|
|
|
set<boost::shared_ptr<Playlist> > diffed_playlists;
|
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
2010-12-28 15:37:11 -05:00
|
|
|
i->view->thaw_after_trim ();
|
2010-06-28 14:43:40 -04:00
|
|
|
i->view->enable_display (true);
|
2010-12-28 14:17:37 -05:00
|
|
|
|
|
|
|
/* Trimming one region may affect others on the playlist, so we need
|
|
|
|
to get undo Commands from the whole playlist rather than just the
|
|
|
|
region. Use diffed_playlists to make sure we don't diff a given
|
|
|
|
playlist more than once.
|
|
|
|
*/
|
|
|
|
boost::shared_ptr<Playlist> p = i->view->region()->playlist ();
|
|
|
|
if (diffed_playlists.find (p) == diffed_playlists.end()) {
|
|
|
|
vector<Command*> cmds;
|
|
|
|
p->rdiff (cmds);
|
|
|
|
_editor->session()->add_commands (cmds);
|
|
|
|
diffed_playlists.insert (p);
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
2012-12-13 10:54:50 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
for (set<boost::shared_ptr<Playlist> >::iterator p = _editor->motion_frozen_playlists.begin(); p != _editor->motion_frozen_playlists.end(); ++p) {
|
|
|
|
(*p)->thaw ();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->motion_frozen_playlists.clear ();
|
2010-12-28 14:17:37 -05:00
|
|
|
_editor->commit_reversible_command();
|
2009-11-08 11:28:21 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
|
|
|
/* no mouse movement */
|
2010-01-12 11:14:49 -05:00
|
|
|
_editor->point_trim (event, adjusted_current_frame (event));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2010-09-21 19:23:07 -04:00
|
|
|
|
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
2010-11-23 20:04:53 -05:00
|
|
|
if (_operation == StartTrim) {
|
2010-12-07 12:16:59 -05:00
|
|
|
i->view->trim_front_ending ();
|
2010-11-23 20:04:53 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-21 19:23:07 -04:00
|
|
|
i->view->region()->resume_property_changes ();
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
TrimDrag::aborted (bool movement_occurred)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
|
|
|
/* Our motion method is changing model state, so use the Undo system
|
|
|
|
to cancel. Perhaps not ideal, as this will leave an Undo point
|
|
|
|
behind which may be slightly odd from the user's point of view.
|
|
|
|
*/
|
|
|
|
|
|
|
|
finished (0, true);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-28 14:17:37 -05:00
|
|
|
if (movement_occurred) {
|
2010-01-07 20:28:15 -05:00
|
|
|
_editor->undo ();
|
|
|
|
}
|
2010-09-21 19:23:07 -04:00
|
|
|
|
|
|
|
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
i->view->region()->resume_property_changes ();
|
|
|
|
}
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2010-12-21 20:06:18 -05:00
|
|
|
void
|
|
|
|
TrimDrag::setup_pointer_frame_offset ()
|
|
|
|
{
|
|
|
|
list<DraggingView>::iterator i = _views.begin ();
|
|
|
|
while (i != _views.end() && i->view != _primary) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == _views.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (_operation) {
|
|
|
|
case StartTrim:
|
|
|
|
_pointer_frame_offset = raw_grab_frame() - i->initial_position;
|
|
|
|
break;
|
|
|
|
case EndTrim:
|
|
|
|
_pointer_frame_offset = raw_grab_frame() - i->initial_end;
|
|
|
|
break;
|
2010-12-22 18:45:04 -05:00
|
|
|
case ContentsTrim:
|
|
|
|
break;
|
2010-12-21 20:06:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
MeterMarkerDrag::MeterMarkerDrag (Editor* e, ArdourCanvas::Item* i, bool c)
|
2009-06-08 15:28:51 -04:00
|
|
|
: Drag (e, i),
|
|
|
|
_copy (c)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New MeterMarkerDrag\n");
|
2009-05-30 14:25:59 -04:00
|
|
|
_marker = reinterpret_cast<MeterMarker*> (_item->get_data ("marker"));
|
|
|
|
assert (_marker);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MeterMarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event, cursor);
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (adjusted_current_frame(event));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-12-19 22:42:59 -05:00
|
|
|
void
|
|
|
|
MeterMarkerDrag::setup_pointer_frame_offset ()
|
|
|
|
{
|
|
|
|
_pointer_frame_offset = raw_grab_frame() - _marker->meter().frame();
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2011-12-13 14:43:41 -05:00
|
|
|
MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2014-01-27 10:09:58 -05:00
|
|
|
if (!_marker->meter().movable()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-13 14:43:41 -05:00
|
|
|
if (first_move) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-12-13 14:43:41 -05:00
|
|
|
// create a dummy marker for visual representation of moving the
|
|
|
|
// section, because whether its a copy or not, we're going to
|
|
|
|
// leave or lose the original marker (leave if its a copy; lose if its
|
|
|
|
// not, because we'll remove it from the map).
|
|
|
|
|
|
|
|
MeterSection section (_marker->meter());
|
2012-01-05 17:36:58 -05:00
|
|
|
|
2011-12-13 14:43:41 -05:00
|
|
|
if (!section.movable()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
char name[64];
|
|
|
|
snprintf (name, sizeof(name), "%g/%g", _marker->meter().divisions_per_bar(), _marker->meter().note_divisor ());
|
|
|
|
|
|
|
|
_marker = new MeterMarker (
|
|
|
|
*_editor,
|
|
|
|
*_editor->meter_group,
|
2014-12-14 16:15:38 -05:00
|
|
|
ARDOUR_UI::config()->color ("meter marker"),
|
2011-12-13 14:43:41 -05:00
|
|
|
name,
|
|
|
|
*new MeterSection (_marker->meter())
|
|
|
|
);
|
|
|
|
|
|
|
|
/* use the new marker for the grab */
|
|
|
|
swap_grab (&_marker->the_item(), 0, GDK_CURRENT_TIME);
|
|
|
|
|
|
|
|
if (!_copy) {
|
|
|
|
TempoMap& map (_editor->session()->tempo_map());
|
2012-01-04 15:40:06 -05:00
|
|
|
/* get current state */
|
|
|
|
before_state = &map.get_state();
|
2011-12-13 14:43:41 -05:00
|
|
|
/* remove the section while we drag it */
|
2011-12-28 16:02:31 -05:00
|
|
|
map.remove_meter (section, true);
|
2011-12-13 14:43:41 -05:00
|
|
|
}
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-12-13 14:43:41 -05:00
|
|
|
framepos_t const pf = adjusted_current_frame (event);
|
2014-11-24 14:58:56 -05:00
|
|
|
|
2011-12-13 14:43:41 -05:00
|
|
|
_marker->set_position (pf);
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (pf);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
MeterMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2009-06-01 20:39:57 -04:00
|
|
|
if (!movement_occurred) {
|
2014-01-27 10:09:58 -05:00
|
|
|
if (was_double_click()) {
|
|
|
|
_editor->edit_meter_marker (*_marker);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_marker->meter().movable()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
motion (event, false);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-12-14 13:13:37 -05:00
|
|
|
Timecode::BBT_Time when;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
TempoMap& map (_editor->session()->tempo_map());
|
2009-12-21 20:12:41 -05:00
|
|
|
map.bbt_time (last_pointer_frame(), when);
|
2011-12-12 21:46:36 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (_copy == true) {
|
|
|
|
_editor->begin_reversible_command (_("copy meter mark"));
|
|
|
|
XMLNode &before = map.get_state();
|
|
|
|
map.add_meter (_marker->meter(), when);
|
|
|
|
XMLNode &after = map.get_state();
|
2009-12-17 13:24:23 -05:00
|
|
|
_editor->session()->add_command(new MementoCommand<TempoMap>(map, &before, &after));
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
_editor->begin_reversible_command (_("move meter mark"));
|
2011-12-12 21:46:36 -05:00
|
|
|
|
|
|
|
/* we removed it before, so add it back now */
|
|
|
|
|
|
|
|
map.add_meter (_marker->meter(), when);
|
2009-05-30 14:25:59 -04:00
|
|
|
XMLNode &after = map.get_state();
|
2012-01-04 15:40:06 -05:00
|
|
|
_editor->session()->add_command(new MementoCommand<TempoMap>(map, before_state, &after));
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
}
|
2011-12-12 21:46:36 -05:00
|
|
|
|
|
|
|
// delete the dummy marker we used for visual representation while moving.
|
|
|
|
// a new visual marker will show up automatically.
|
|
|
|
delete _marker;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2011-12-21 09:21:05 -05:00
|
|
|
MeterMarkerDrag::aborted (bool moved)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
|
|
|
_marker->set_position (_marker->meter().frame ());
|
2011-12-20 21:53:33 -05:00
|
|
|
|
2011-12-21 09:21:05 -05:00
|
|
|
if (moved) {
|
|
|
|
TempoMap& map (_editor->session()->tempo_map());
|
|
|
|
/* we removed it before, so add it back now */
|
|
|
|
map.add_meter (_marker->meter(), _marker->meter().frame());
|
|
|
|
// delete the dummy marker we used for visual representation while moving.
|
|
|
|
// a new visual marker will show up automatically.
|
|
|
|
delete _marker;
|
|
|
|
}
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
TempoMarkerDrag::TempoMarkerDrag (Editor* e, ArdourCanvas::Item* i, bool c)
|
2009-06-08 15:28:51 -04:00
|
|
|
: Drag (e, i),
|
|
|
|
_copy (c)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New TempoMarkerDrag\n");
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-06-09 04:41:43 -04:00
|
|
|
_marker = reinterpret_cast<TempoMarker*> (_item->get_data ("marker"));
|
2009-05-30 14:25:59 -04:00
|
|
|
assert (_marker);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TempoMarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
|
|
|
{
|
2011-12-20 21:53:33 -05:00
|
|
|
Drag::start_grab (event, cursor);
|
|
|
|
show_verbose_cursor_time (adjusted_current_frame (event));
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-12-20 21:53:33 -05:00
|
|
|
void
|
|
|
|
TempoMarkerDrag::setup_pointer_frame_offset ()
|
|
|
|
{
|
|
|
|
_pointer_frame_offset = raw_grab_frame() - _marker->tempo().frame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
|
|
|
|
{
|
2014-01-27 10:09:58 -05:00
|
|
|
if (!_marker->tempo().movable()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-20 21:53:33 -05:00
|
|
|
if (first_move) {
|
|
|
|
|
|
|
|
// create a dummy marker for visual representation of moving the
|
|
|
|
// section, because whether its a copy or not, we're going to
|
|
|
|
// leave or lose the original marker (leave if its a copy; lose if its
|
|
|
|
// not, because we'll remove it from the map).
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
// create a dummy marker for visual representation of moving the copy.
|
|
|
|
// The actual copying is not done before we reach the finish callback.
|
2011-12-20 21:53:33 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
char name[64];
|
|
|
|
snprintf (name, sizeof (name), "%.2f", _marker->tempo().beats_per_minute());
|
2010-11-11 08:36:38 -05:00
|
|
|
|
2011-12-20 21:53:33 -05:00
|
|
|
TempoSection section (_marker->tempo());
|
|
|
|
|
|
|
|
_marker = new TempoMarker (
|
2010-11-11 08:36:38 -05:00
|
|
|
*_editor,
|
|
|
|
*_editor->tempo_group,
|
2014-12-14 16:15:38 -05:00
|
|
|
ARDOUR_UI::config()->color ("tempo marker"),
|
2010-11-11 08:36:38 -05:00
|
|
|
name,
|
|
|
|
*new TempoSection (_marker->tempo())
|
|
|
|
);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2011-12-20 21:53:33 -05:00
|
|
|
/* use the new marker for the grab */
|
|
|
|
swap_grab (&_marker->the_item(), 0, GDK_CURRENT_TIME);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2011-12-20 21:53:33 -05:00
|
|
|
if (!_copy) {
|
|
|
|
TempoMap& map (_editor->session()->tempo_map());
|
2012-01-04 15:40:06 -05:00
|
|
|
/* get current state */
|
|
|
|
before_state = &map.get_state();
|
2011-12-20 21:53:33 -05:00
|
|
|
/* remove the section while we drag it */
|
2011-12-28 16:02:31 -05:00
|
|
|
map.remove_tempo (section, true);
|
2011-12-20 21:53:33 -05:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const pf = adjusted_current_frame (event);
|
2009-12-21 20:12:41 -05:00
|
|
|
_marker->set_position (pf);
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (pf);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
TempoMarkerDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2009-06-01 20:39:57 -04:00
|
|
|
if (!movement_occurred) {
|
2014-01-27 10:09:58 -05:00
|
|
|
if (was_double_click()) {
|
|
|
|
_editor->edit_tempo_marker (*_marker);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_marker->tempo().movable()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
motion (event, false);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-01-07 10:10:31 -05:00
|
|
|
TempoMap& map (_editor->session()->tempo_map());
|
2014-11-16 01:05:21 -05:00
|
|
|
framepos_t beat_time = map.round_to_beat (last_pointer_frame(), RoundNearest);
|
2010-12-14 13:13:37 -05:00
|
|
|
Timecode::BBT_Time when;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-01-07 10:10:31 -05:00
|
|
|
map.bbt_time (beat_time, when);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
if (_copy == true) {
|
|
|
|
_editor->begin_reversible_command (_("copy tempo mark"));
|
|
|
|
XMLNode &before = map.get_state();
|
|
|
|
map.add_tempo (_marker->tempo(), when);
|
|
|
|
XMLNode &after = map.get_state();
|
2009-12-17 13:24:23 -05:00
|
|
|
_editor->session()->add_command (new MementoCommand<TempoMap>(map, &before, &after));
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->commit_reversible_command ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
|
|
|
_editor->begin_reversible_command (_("move tempo mark"));
|
2011-12-20 21:53:33 -05:00
|
|
|
/* we removed it before, so add it back now */
|
|
|
|
map.add_tempo (_marker->tempo(), when);
|
2009-05-30 14:25:59 -04:00
|
|
|
XMLNode &after = map.get_state();
|
2012-01-04 15:40:06 -05:00
|
|
|
_editor->session()->add_command (new MementoCommand<TempoMap>(map, before_state, &after));
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
}
|
2011-12-20 21:53:33 -05:00
|
|
|
|
|
|
|
// delete the dummy marker we used for visual representation while moving.
|
|
|
|
// a new visual marker will show up automatically.
|
|
|
|
delete _marker;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2011-12-21 09:21:05 -05:00
|
|
|
TempoMarkerDrag::aborted (bool moved)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
|
|
|
_marker->set_position (_marker->tempo().frame());
|
2011-12-21 09:21:05 -05:00
|
|
|
if (moved) {
|
|
|
|
TempoMap& map (_editor->session()->tempo_map());
|
|
|
|
/* we removed it before, so add it back now */
|
2011-12-28 16:02:31 -05:00
|
|
|
map.add_tempo (_marker->tempo(), _marker->tempo().start());
|
2011-12-21 09:21:05 -05:00
|
|
|
// delete the dummy marker we used for visual representation while moving.
|
|
|
|
// a new visual marker will show up automatically.
|
|
|
|
delete _marker;
|
|
|
|
}
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2013-04-17 15:22:09 -04:00
|
|
|
CursorDrag::CursorDrag (Editor* e, EditorCursor& c, bool s)
|
2014-06-08 11:26:25 -04:00
|
|
|
: Drag (e, &c.track_canvas_item(), false)
|
2013-04-17 15:22:09 -04:00
|
|
|
, _cursor (c)
|
|
|
|
, _stop (s)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New CursorDrag\n");
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-12-22 18:43:04 -05:00
|
|
|
/** Do all the things we do when dragging the playhead to make it look as though
|
|
|
|
* we have located, without actually doing the locate (because that would cause
|
|
|
|
* the diskstream buffers to be refilled, which is too slow).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CursorDrag::fake_locate (framepos_t t)
|
|
|
|
{
|
|
|
|
_editor->playhead_cursor->set_position (t);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-22 18:43:04 -05:00
|
|
|
Session* s = _editor->session ();
|
|
|
|
if (s->timecode_transmission_suspended ()) {
|
2013-04-04 00:32:52 -04:00
|
|
|
framepos_t const f = _editor->playhead_cursor->current_frame ();
|
2013-08-08 19:31:10 -04:00
|
|
|
/* This is asynchronous so it will be sent "now"
|
|
|
|
*/
|
2010-12-22 18:43:04 -05:00
|
|
|
s->send_mmc_locate (f);
|
2013-08-08 19:31:10 -04:00
|
|
|
/* These are synchronous and will be sent during the next
|
|
|
|
process cycle
|
|
|
|
*/
|
|
|
|
s->queue_full_time_code ();
|
|
|
|
s->queue_song_position_pointer ();
|
2010-12-22 18:43:04 -05:00
|
|
|
}
|
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (t);
|
2010-12-22 18:43:04 -05:00
|
|
|
_editor->UpdateAllTransportClocks (t);
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
|
|
|
CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event, c);
|
|
|
|
|
2013-04-12 11:31:50 -04:00
|
|
|
_grab_zoom = _editor->samples_per_pixel;
|
2011-05-25 12:38:49 -04:00
|
|
|
|
2014-02-26 08:43:53 -05:00
|
|
|
framepos_t where = _editor->canvas_event_sample (event);
|
2013-04-18 15:14:48 -04:00
|
|
|
|
2010-12-22 18:43:04 -05:00
|
|
|
_editor->snap_to_with_modifier (where, event);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-12-22 18:16:39 -05:00
|
|
|
_editor->_dragging_playhead = true;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-22 18:16:39 -05:00
|
|
|
Session* s = _editor->session ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-04-17 15:22:09 -04:00
|
|
|
/* grab the track canvas item as well */
|
|
|
|
|
|
|
|
_cursor.track_canvas_item().grab();
|
|
|
|
|
2010-12-22 18:16:39 -05:00
|
|
|
if (s) {
|
|
|
|
if (_was_rolling && _stop) {
|
|
|
|
s->request_stop ();
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-22 18:16:39 -05:00
|
|
|
if (s->is_auditioning()) {
|
|
|
|
s->cancel_audition ();
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2012-07-10 00:18:06 -04:00
|
|
|
|
2012-07-10 00:05:48 -04:00
|
|
|
if (AudioEngine::instance()->connected()) {
|
2012-07-10 00:18:06 -04:00
|
|
|
|
|
|
|
/* do this only if we're the engine is connected
|
|
|
|
* because otherwise this request will never be
|
|
|
|
* serviced and we'll busy wait forever. likewise,
|
|
|
|
* notice if we are disconnected while waiting for the
|
|
|
|
* request to be serviced.
|
|
|
|
*/
|
|
|
|
|
2012-07-10 00:05:48 -04:00
|
|
|
s->request_suspend_timecode_transmission ();
|
|
|
|
while (AudioEngine::instance()->connected() && !s->timecode_transmission_suspended ()) {
|
|
|
|
/* twiddle our thumbs */
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-22 18:43:04 -05:00
|
|
|
fake_locate (where);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
CursorDrag::motion (GdkEvent* event, bool)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2011-05-25 12:38:49 -04:00
|
|
|
framepos_t const adjusted_frame = adjusted_current_frame (event);
|
|
|
|
if (adjusted_frame != last_pointer_frame()) {
|
|
|
|
fake_locate (adjusted_frame);
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
CursorDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
_editor->_dragging_playhead = false;
|
|
|
|
|
2013-04-17 15:22:09 -04:00
|
|
|
_cursor.track_canvas_item().ungrab();
|
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
if (!movement_occurred && _stop) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
motion (event, false);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-12-22 18:16:39 -05:00
|
|
|
Session* s = _editor->session ();
|
|
|
|
if (s) {
|
2013-04-04 00:32:52 -04:00
|
|
|
s->request_locate (_editor->playhead_cursor->current_frame (), _was_rolling);
|
2010-12-22 18:16:39 -05:00
|
|
|
_editor->_pending_locate_request = true;
|
|
|
|
s->request_resume_timecode_transmission ();
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
CursorDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2013-04-17 15:22:09 -04:00
|
|
|
_cursor.track_canvas_item().ungrab();
|
|
|
|
|
2010-08-01 21:59:34 -04:00
|
|
|
if (_editor->_dragging_playhead) {
|
|
|
|
_editor->session()->request_resume_timecode_transmission ();
|
|
|
|
_editor->_dragging_playhead = false;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-22 18:16:39 -05:00
|
|
|
_editor->playhead_cursor->set_position (adjusted_frame (grab_frame (), 0, false));
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
FadeInDrag::FadeInDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v)
|
|
|
|
: RegionDrag (e, i, p, v)
|
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New FadeInDrag\n");
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FadeInDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event, cursor);
|
|
|
|
|
2010-09-07 07:41:16 -04:00
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (_primary);
|
|
|
|
boost::shared_ptr<AudioRegion> const r = arv->audio_region ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-05-04 10:56:24 -04:00
|
|
|
show_verbose_cursor_duration (r->position(), r->position() + r->fade_in()->back()->when, 32);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-12-19 22:42:59 -05:00
|
|
|
void
|
|
|
|
FadeInDrag::setup_pointer_frame_offset ()
|
|
|
|
{
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (_primary);
|
|
|
|
boost::shared_ptr<AudioRegion> const r = arv->audio_region ();
|
|
|
|
_pointer_frame_offset = raw_grab_frame() - ((framecnt_t) r->fade_in()->back()->when + r->position());
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
FadeInDrag::motion (GdkEvent* event, bool)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-08 21:38:21 -04:00
|
|
|
framecnt_t fade_length;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const pos = adjusted_current_frame (event);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
boost::shared_ptr<Region> region = _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 {
|
|
|
|
fade_length = pos - region->position();
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (i->view);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (!tmp) {
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-12-14 12:21:44 -05:00
|
|
|
tmp->reset_fade_in_shape_width (tmp->audio_region(), fade_length);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2011-05-04 10:56:24 -04:00
|
|
|
show_verbose_cursor_duration (region->position(), region->position() + fade_length, 32);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
FadeInDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2009-06-01 20:39:57 -04:00
|
|
|
if (!movement_occurred) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framecnt_t fade_length;
|
2009-06-01 20:39:57 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const pos = adjusted_current_frame (event);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
boost::shared_ptr<Region> region = _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 {
|
|
|
|
fade_length = pos - region->position();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->begin_reversible_command (_("change fade in length"));
|
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (i->view);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (!tmp) {
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
boost::shared_ptr<AutomationList> alist = tmp->audio_region()->fade_in();
|
|
|
|
XMLNode &before = alist->get_state();
|
|
|
|
|
|
|
|
tmp->audio_region()->set_fade_in_length (fade_length);
|
|
|
|
tmp->audio_region()->set_fade_in_active (true);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
XMLNode &after = alist->get_state();
|
2009-12-17 13:24:23 -05:00
|
|
|
_editor->session()->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &after));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
FadeInDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (i->view);
|
2010-01-07 20:28:15 -05:00
|
|
|
|
|
|
|
if (!tmp) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-12-14 12:21:44 -05:00
|
|
|
tmp->reset_fade_in_shape_width (tmp->audio_region(), tmp->audio_region()->fade_in()->back()->when);
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
FadeOutDrag::FadeOutDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v)
|
|
|
|
: RegionDrag (e, i, p, v)
|
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New FadeOutDrag\n");
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FadeOutDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event, cursor);
|
|
|
|
|
2010-09-07 07:41:16 -04:00
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (_primary);
|
|
|
|
boost::shared_ptr<AudioRegion> r = arv->audio_region ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_duration (r->last_frame() - r->fade_out()->back()->when, r->last_frame());
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-12-19 22:42:59 -05:00
|
|
|
void
|
|
|
|
FadeOutDrag::setup_pointer_frame_offset ()
|
|
|
|
{
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (_primary);
|
|
|
|
boost::shared_ptr<AudioRegion> r = arv->audio_region ();
|
|
|
|
_pointer_frame_offset = raw_grab_frame() - (r->length() - (framecnt_t) r->fade_out()->back()->when + r->position());
|
2011-06-01 13:00:29 -04:00
|
|
|
}
|
2010-12-19 22:42:59 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
FadeOutDrag::motion (GdkEvent* event, bool)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-08 21:38:21 -04:00
|
|
|
framecnt_t fade_length;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const pos = adjusted_current_frame (event);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<Region> region = _primary->region ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
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;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (i->view);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (!tmp) {
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-12-14 12:21:44 -05:00
|
|
|
tmp->reset_fade_out_shape_width (tmp->audio_region(), fade_length);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_duration (region->last_frame() - fade_length, region->last_frame());
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
FadeOutDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2009-06-01 20:39:57 -04:00
|
|
|
if (!movement_occurred) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framecnt_t fade_length;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const pos = adjusted_current_frame (event);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<Region> region = _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;
|
|
|
|
}
|
|
|
|
|
|
|
|
_editor->begin_reversible_command (_("change fade out length"));
|
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-04-06 20:17:54 -04:00
|
|
|
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (i->view);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (!tmp) {
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
boost::shared_ptr<AutomationList> alist = tmp->audio_region()->fade_out();
|
|
|
|
XMLNode &before = alist->get_state();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
tmp->audio_region()->set_fade_out_length (fade_length);
|
|
|
|
tmp->audio_region()->set_fade_out_active (true);
|
|
|
|
|
|
|
|
XMLNode &after = alist->get_state();
|
2009-12-17 13:24:23 -05:00
|
|
|
_editor->session()->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &after));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
FadeOutDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2010-04-06 20:17:54 -04:00
|
|
|
for (list<DraggingView>::iterator i = _views.begin(); i != _views.end(); ++i) {
|
|
|
|
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (i->view);
|
2010-01-07 20:28:15 -05:00
|
|
|
|
|
|
|
if (!tmp) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-12-14 12:21:44 -05:00
|
|
|
tmp->reset_fade_out_shape_width (tmp->audio_region(), tmp->audio_region()->fade_out()->back()->when);
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
MarkerDrag::MarkerDrag (Editor* e, ArdourCanvas::Item* i)
|
|
|
|
: Drag (e, i)
|
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New MarkerDrag\n");
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
_marker = reinterpret_cast<Marker*> (_item->get_data ("marker"));
|
|
|
|
assert (_marker);
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_points.push_back (ArdourCanvas::Duple (0, 0));
|
|
|
|
_points.push_back (ArdourCanvas::Duple (0, physical_screen_height (_editor->get_window())));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MarkerDrag::~MarkerDrag ()
|
|
|
|
{
|
2013-01-02 18:54:06 -05:00
|
|
|
for (CopiedLocationInfo::iterator i = _copied_locations.begin(); i != _copied_locations.end(); ++i) {
|
|
|
|
delete i->location;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
MarkerDrag::CopiedLocationMarkerInfo::CopiedLocationMarkerInfo (Location* l, Marker* m)
|
|
|
|
{
|
|
|
|
location = new Location (*l);
|
|
|
|
markers.push_back (m);
|
|
|
|
move_both = false;
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
|
|
|
MarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event, cursor);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
bool is_start;
|
|
|
|
|
|
|
|
Location *location = _editor->find_location_from_marker (_marker, is_start);
|
|
|
|
_editor->_dragging_edit_point = true;
|
|
|
|
|
|
|
|
update_item (location);
|
|
|
|
|
|
|
|
// _drag_line->show();
|
|
|
|
// _line->raise_to_top();
|
|
|
|
|
|
|
|
if (is_start) {
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (location->start());
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (location->end());
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2009-12-04 17:51:32 -05:00
|
|
|
Selection::Operation op = ArdourKeyboard::selection_type (event->button.state);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case Selection::Toggle:
|
2013-01-02 18:54:06 -05:00
|
|
|
/* we toggle on the button release */
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
case Selection::Set:
|
|
|
|
if (!_editor->selection->selected (_marker)) {
|
|
|
|
_editor->selection->set (_marker);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Selection::Extend:
|
|
|
|
{
|
|
|
|
Locations::LocationList ll;
|
|
|
|
list<Marker*> to_add;
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t s, e;
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->selection->markers.range (s, e);
|
|
|
|
s = min (_marker->position(), s);
|
|
|
|
e = max (_marker->position(), e);
|
|
|
|
s = min (s, e);
|
|
|
|
e = max (s, e);
|
2010-09-17 12:24:22 -04:00
|
|
|
if (e < max_framepos) {
|
2009-05-30 14:25:59 -04:00
|
|
|
++e;
|
|
|
|
}
|
2009-12-17 13:24:23 -05:00
|
|
|
_editor->session()->locations()->find_all_between (s, e, ll, Location::Flags (0));
|
2009-05-30 14:25:59 -04:00
|
|
|
for (Locations::LocationList::iterator i = ll.begin(); i != ll.end(); ++i) {
|
|
|
|
Editor::LocationMarkers* lm = _editor->find_location_markers (*i);
|
|
|
|
if (lm) {
|
|
|
|
if (lm->start) {
|
|
|
|
to_add.push_back (lm->start);
|
|
|
|
}
|
|
|
|
if (lm->end) {
|
|
|
|
to_add.push_back (lm->end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!to_add.empty()) {
|
|
|
|
_editor->selection->add (to_add);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Selection::Add:
|
|
|
|
_editor->selection->add (_marker);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
/* Set up copies for us to manipulate during the drag
|
|
|
|
*/
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
for (MarkerSelection::iterator i = _editor->selection->markers.begin(); i != _editor->selection->markers.end(); ++i) {
|
2013-01-02 18:54:06 -05:00
|
|
|
|
2010-04-18 17:29:48 -04:00
|
|
|
Location* l = _editor->find_location_from_marker (*i, is_start);
|
2013-01-02 18:54:06 -05:00
|
|
|
|
|
|
|
if (!l) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l->is_mark()) {
|
|
|
|
_copied_locations.push_back (CopiedLocationMarkerInfo (l, *i));
|
|
|
|
} else {
|
|
|
|
/* range: check that the other end of the range isn't
|
|
|
|
already there.
|
|
|
|
*/
|
|
|
|
CopiedLocationInfo::iterator x;
|
|
|
|
for (x = _copied_locations.begin(); x != _copied_locations.end(); ++x) {
|
|
|
|
if (*(*x).location == *l) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (x == _copied_locations.end()) {
|
|
|
|
_copied_locations.push_back (CopiedLocationMarkerInfo (l, *i));
|
|
|
|
} else {
|
|
|
|
(*x).markers.push_back (*i);
|
|
|
|
(*x).move_both = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-19 22:42:59 -05:00
|
|
|
void
|
|
|
|
MarkerDrag::setup_pointer_frame_offset ()
|
|
|
|
{
|
|
|
|
bool is_start;
|
|
|
|
Location *location = _editor->find_location_from_marker (_marker, is_start);
|
|
|
|
_pointer_frame_offset = raw_grab_frame() - (is_start ? location->start() : location->end());
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
MarkerDrag::motion (GdkEvent* event, bool)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-08 21:38:21 -04:00
|
|
|
framecnt_t f_delta = 0;
|
2009-05-30 14:25:59 -04:00
|
|
|
bool is_start;
|
|
|
|
bool move_both = false;
|
2010-04-18 17:29:48 -04:00
|
|
|
Location *real_location;
|
2009-05-30 14:25:59 -04:00
|
|
|
Location *copy_location = 0;
|
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const newframe = adjusted_current_frame (event);
|
|
|
|
framepos_t next = newframe;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
|
|
|
move_both = true;
|
|
|
|
}
|
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
CopiedLocationInfo::iterator x;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
/* find the marker we're dragging, and compute the delta */
|
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
for (x = _copied_locations.begin(); x != _copied_locations.end(); ++x) {
|
|
|
|
|
|
|
|
copy_location = (*x).location;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
if (find (x->markers.begin(), x->markers.end(), _marker) != x->markers.end()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
/* this marker is represented by this
|
|
|
|
* CopiedLocationMarkerInfo
|
|
|
|
*/
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
if ((real_location = _editor->find_location_from_marker (_marker, is_start)) == 0) {
|
2009-05-30 14:25:59 -04:00
|
|
|
/* que pasa ?? */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (real_location->is_mark()) {
|
|
|
|
f_delta = newframe - copy_location->start();
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
switch (_marker->type()) {
|
2010-11-12 18:16:59 -05:00
|
|
|
case Marker::SessionStart:
|
|
|
|
case Marker::RangeStart:
|
2009-05-30 14:25:59 -04:00
|
|
|
case Marker::LoopStart:
|
|
|
|
case Marker::PunchIn:
|
|
|
|
f_delta = newframe - copy_location->start();
|
|
|
|
break;
|
|
|
|
|
2010-11-12 18:16:59 -05:00
|
|
|
case Marker::SessionEnd:
|
|
|
|
case Marker::RangeEnd:
|
2009-05-30 14:25:59 -04:00
|
|
|
case Marker::LoopEnd:
|
|
|
|
case Marker::PunchOut:
|
|
|
|
f_delta = newframe - copy_location->end();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* what kind of marker is this ? */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-01-02 18:54:06 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
if (x == _copied_locations.end()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
/* hmm, impossible - we didn't find the dragged marker */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now move them all */
|
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
for (x = _copied_locations.begin(); x != _copied_locations.end(); ++x) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
copy_location = x->location;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
/* call this to find out if its the start or end */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
if ((real_location = _editor->find_location_from_marker (x->markers.front(), is_start)) == 0) {
|
2009-05-30 14:25:59 -04:00
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (real_location->locked()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_location->is_mark()) {
|
|
|
|
|
2010-04-18 17:29:48 -04:00
|
|
|
/* now move it */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
copy_location->set_start (copy_location->start() + f_delta);
|
|
|
|
|
|
|
|
} else {
|
2013-01-02 18:54:06 -05:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t new_start = copy_location->start() + f_delta;
|
|
|
|
framepos_t new_end = copy_location->end() + f_delta;
|
2013-01-02 18:54:06 -05:00
|
|
|
|
|
|
|
if (is_start) { // start-of-range marker
|
|
|
|
|
|
|
|
if (move_both || (*x).move_both) {
|
2009-05-30 14:25:59 -04:00
|
|
|
copy_location->set_start (new_start);
|
|
|
|
copy_location->set_end (new_end);
|
|
|
|
} else if (new_start < copy_location->end()) {
|
|
|
|
copy_location->set_start (new_start);
|
2010-12-28 15:37:11 -05:00
|
|
|
} else if (newframe > 0) {
|
2014-11-16 01:05:21 -05:00
|
|
|
_editor->snap_to (next, RoundUpAlways, true);
|
2009-05-30 14:25:59 -04:00
|
|
|
copy_location->set_end (next);
|
|
|
|
copy_location->set_start (newframe);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
} else { // end marker
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-01-02 18:54:06 -05:00
|
|
|
if (move_both || (*x).move_both) {
|
2009-05-30 14:25:59 -04:00
|
|
|
copy_location->set_end (new_end);
|
|
|
|
copy_location->set_start (new_start);
|
|
|
|
} else if (new_end > copy_location->start()) {
|
|
|
|
copy_location->set_end (new_end);
|
|
|
|
} else if (newframe > 0) {
|
2014-11-16 01:05:21 -05:00
|
|
|
_editor->snap_to (next, RoundDownAlways, true);
|
2009-05-30 14:25:59 -04:00
|
|
|
copy_location->set_start (next);
|
|
|
|
copy_location->set_end (newframe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
update_item (copy_location);
|
2013-01-02 18:54:06 -05:00
|
|
|
|
|
|
|
/* now lookup the actual GUI items used to display this
|
|
|
|
* location and move them to wherever the copy of the location
|
|
|
|
* is now. This means that the logic in ARDOUR::Location is
|
|
|
|
* still enforced, even though we are not (yet) modifying
|
|
|
|
* the real Location itself.
|
|
|
|
*/
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
Editor::LocationMarkers* lm = _editor->find_location_markers (real_location);
|
|
|
|
|
|
|
|
if (lm) {
|
|
|
|
lm->set_position (copy_location->start(), copy_location->end());
|
|
|
|
}
|
2013-01-02 18:54:06 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
assert (!_copied_locations.empty());
|
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (newframe);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
MarkerDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2009-06-01 20:39:57 -04:00
|
|
|
if (!movement_occurred) {
|
2013-06-21 15:18:54 -04:00
|
|
|
|
|
|
|
if (was_double_click()) {
|
2014-01-27 10:09:58 -05:00
|
|
|
_editor->rename_marker (_marker);
|
|
|
|
return;
|
2013-06-21 15:18:54 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
/* just a click, do nothing but finish
|
|
|
|
off the selection process
|
|
|
|
*/
|
|
|
|
|
2009-12-04 17:51:32 -05:00
|
|
|
Selection::Operation op = ArdourKeyboard::selection_type (event->button.state);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case Selection::Set:
|
|
|
|
if (_editor->selection->selected (_marker) && _editor->selection->markers.size() > 1) {
|
|
|
|
_editor->selection->set (_marker);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Selection::Toggle:
|
2013-01-02 18:54:06 -05:00
|
|
|
/* we toggle on the button release, click only */
|
|
|
|
_editor->selection->toggle (_marker);
|
|
|
|
break;
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
case Selection::Extend:
|
|
|
|
case Selection::Add:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_editor->_dragging_edit_point = false;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->begin_reversible_command ( _("move marker") );
|
2009-12-17 13:24:23 -05:00
|
|
|
XMLNode &before = _editor->session()->locations()->get_state();
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
MarkerSelection::iterator i;
|
2013-01-02 18:54:06 -05:00
|
|
|
CopiedLocationInfo::iterator x;
|
2009-05-30 14:25:59 -04:00
|
|
|
bool is_start;
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
for (i = _editor->selection->markers.begin(), x = _copied_locations.begin();
|
|
|
|
x != _copied_locations.end() && i != _editor->selection->markers.end();
|
2009-05-30 14:25:59 -04:00
|
|
|
++i, ++x) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
Location * location = _editor->find_location_from_marker (*i, is_start);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (location) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (location->locked()) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (location->is_mark()) {
|
2013-01-02 18:54:06 -05:00
|
|
|
location->set_start (((*x).location)->start());
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2013-01-02 18:54:06 -05:00
|
|
|
location->set (((*x).location)->start(), ((*x).location)->end());
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
XMLNode &after = _editor->session()->locations()->get_state();
|
|
|
|
_editor->session()->add_command(new MementoCommand<Locations>(*(_editor->session()->locations()), &before, &after));
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
MarkerDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2011-09-30 13:55:14 -04:00
|
|
|
MarkerDrag::update_item (Location*)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-12-28 15:37:11 -05:00
|
|
|
/* noop */
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ControlPointDrag::ControlPointDrag (Editor* e, ArdourCanvas::Item* i)
|
|
|
|
: Drag (e, i),
|
|
|
|
_cumulative_x_drag (0),
|
|
|
|
_cumulative_y_drag (0)
|
|
|
|
{
|
2011-06-19 19:02:55 -04:00
|
|
|
if (_zero_gain_fraction < 0.0) {
|
|
|
|
_zero_gain_fraction = gain_to_slider_position_with_max (dB_to_coefficient (0.0), Config->get_max_gain());
|
|
|
|
}
|
|
|
|
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New ControlPointDrag\n");
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-06-09 11:46:33 -04:00
|
|
|
_point = reinterpret_cast<ControlPoint*> (_item->get_data ("control_point"));
|
2009-05-30 14:25:59 -04:00
|
|
|
assert (_point);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
ControlPointDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-11-16 09:53:16 -05:00
|
|
|
Drag::start_grab (event, _editor->cursors()->fader);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
// start the grab at the center of the control point so
|
|
|
|
// the point doesn't 'jump' to the mouse after the first drag
|
2010-08-20 18:43:10 -04:00
|
|
|
_fixed_grab_x = _point->get_x();
|
|
|
|
_fixed_grab_y = _point->get_y();
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
float const fraction = 1 - (_point->get_y() / _point->line().height());
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-08-20 18:43:10 -04:00
|
|
|
_point->line().start_drag_single (_point, _fixed_grab_x, fraction);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2014-06-26 15:07:29 -04:00
|
|
|
show_verbose_cursor_text (_point->line().get_verbose_cursor_string (fraction));
|
2012-05-27 17:02:36 -04:00
|
|
|
|
2012-12-19 10:55:06 -05:00
|
|
|
_pushing = Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier);
|
|
|
|
|
2012-05-27 17:02:36 -04:00
|
|
|
if (!_point->can_slide ()) {
|
|
|
|
_x_constrained = true;
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
ControlPointDrag::motion (GdkEvent* event, bool)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-01-12 11:14:49 -05:00
|
|
|
double dx = _drags->current_pointer_x() - last_pointer_x();
|
2014-06-08 11:26:25 -04:00
|
|
|
double dy = current_pointer_y() - last_pointer_y();
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
if (event->button.state & Keyboard::SecondaryModifier) {
|
|
|
|
dx *= 0.1;
|
|
|
|
dy *= 0.1;
|
|
|
|
}
|
|
|
|
|
2010-08-20 18:43:10 -04:00
|
|
|
/* coordinate in pixels relative to the start of the region (for region-based automation)
|
|
|
|
or track (for track-based automation) */
|
|
|
|
double cx = _fixed_grab_x + _cumulative_x_drag + dx;
|
|
|
|
double cy = _fixed_grab_y + _cumulative_y_drag + dy;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
// calculate zero crossing point. back off by .01 to stay on the
|
|
|
|
// positive side of zero
|
2010-01-01 17:11:15 -05:00
|
|
|
double const zero_gain_y = (1.0 - _zero_gain_fraction) * _point->line().height() - .01;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
// make sure we hit zero when passing through
|
2010-01-01 17:11:15 -05:00
|
|
|
if ((cy < zero_gain_y && (cy - dy) > zero_gain_y) || (cy > zero_gain_y && (cy - dy) < zero_gain_y)) {
|
2009-05-30 14:25:59 -04:00
|
|
|
cy = zero_gain_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_x_constrained) {
|
2010-08-20 18:43:10 -04:00
|
|
|
cx = _fixed_grab_x;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
if (_y_constrained) {
|
2010-08-20 18:43:10 -04:00
|
|
|
cy = _fixed_grab_y;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-08-20 18:43:10 -04:00
|
|
|
_cumulative_x_drag = cx - _fixed_grab_x;
|
|
|
|
_cumulative_y_drag = cy - _fixed_grab_y;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
cx = max (0.0, cx);
|
|
|
|
cy = max (0.0, cy);
|
|
|
|
cy = min ((double) _point->line().height(), cy);
|
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
framepos_t cx_frames = _editor->pixel_to_sample (cx);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-08-24 16:26:34 -04:00
|
|
|
if (!_x_constrained) {
|
|
|
|
_editor->snap_to_with_modifier (cx_frames, event);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-08-20 18:43:10 -04:00
|
|
|
cx_frames = min (cx_frames, _point->line().maximum_time());
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
float const fraction = 1.0 - (cy / _point->line().height());
|
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
_point->line().drag_motion (_editor->sample_to_pixel_unrounded (cx_frames), fraction, false, _pushing, _final_index);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-06-26 15:07:29 -04:00
|
|
|
show_verbose_cursor_text (_point->line().get_verbose_cursor_string (fraction));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
ControlPointDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2009-06-01 20:39:57 -04:00
|
|
|
if (!movement_occurred) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
/* just a click */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-08-06 19:28:44 -04:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) {
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->reset_point_selection ();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2009-06-01 20:39:57 -04:00
|
|
|
motion (event, false);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2012-12-19 10:55:06 -05:00
|
|
|
_point->line().end_drag (_pushing, _final_index);
|
2014-12-14 08:13:38 -05:00
|
|
|
_editor->commit_reversible_command ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
ControlPointDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2010-01-07 20:53:50 -05:00
|
|
|
_point->line().reset ();
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2009-06-26 08:20:11 -04:00
|
|
|
bool
|
|
|
|
ControlPointDrag::active (Editing::MouseMode m)
|
|
|
|
{
|
2014-12-07 19:53:46 -05:00
|
|
|
if (m == Editing::MouseDraw) {
|
|
|
|
/* always active in mouse draw */
|
2009-06-26 08:20:11 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* otherwise active if the point is on an automation line (ie not if its on a region gain line) */
|
|
|
|
return dynamic_cast<AutomationLine*> (&(_point->line())) != 0;
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
LineDrag::LineDrag (Editor* e, ArdourCanvas::Item* i)
|
|
|
|
: Drag (e, i),
|
|
|
|
_line (0),
|
|
|
|
_cumulative_y_drag (0)
|
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New LineDrag\n");
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2010-09-09 17:34:45 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
LineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
_line = reinterpret_cast<AutomationLine*> (_item->get_data ("line"));
|
|
|
|
assert (_line);
|
|
|
|
|
|
|
|
_item = &_line->grab_item ();
|
|
|
|
|
|
|
|
/* need to get x coordinate in terms of parent (TimeAxisItemView)
|
|
|
|
origin, and ditto for y.
|
|
|
|
*/
|
|
|
|
|
|
|
|
double cx = event->button.x;
|
|
|
|
double cy = event->button.y;
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_line->parent_group().canvas_to_item (cx, cy);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2013-04-12 11:31:50 -04:00
|
|
|
framecnt_t const frame_within_region = (framecnt_t) floor (cx * _editor->samples_per_pixel);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
uint32_t before;
|
|
|
|
uint32_t after;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
if (!_line->control_points_adjacent (frame_within_region, before, after)) {
|
2009-05-30 14:25:59 -04:00
|
|
|
/* no adjacent points */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-16 09:53:16 -05:00
|
|
|
Drag::start_grab (event, _editor->cursors()->fader);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
/* store grab start in parent frame */
|
|
|
|
|
2010-08-20 18:43:10 -04:00
|
|
|
_fixed_grab_x = cx;
|
|
|
|
_fixed_grab_y = cy;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
double fraction = 1.0 - (cy / _line->height());
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
_line->start_drag_line (before, after, fraction);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-06-26 15:07:29 -04:00
|
|
|
show_verbose_cursor_text (_line->get_verbose_cursor_string (fraction));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
LineDrag::motion (GdkEvent* event, bool)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2014-06-08 11:26:25 -04:00
|
|
|
double dy = current_pointer_y() - last_pointer_y();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (event->button.state & Keyboard::SecondaryModifier) {
|
|
|
|
dy *= 0.1;
|
|
|
|
}
|
|
|
|
|
2010-08-20 18:43:10 -04:00
|
|
|
double cy = _fixed_grab_y + _cumulative_y_drag + dy;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-08-20 18:43:10 -04:00
|
|
|
_cumulative_y_drag = cy - _fixed_grab_y;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
cy = max (0.0, cy);
|
|
|
|
cy = min ((double) _line->height(), cy);
|
|
|
|
|
|
|
|
double const fraction = 1.0 - (cy / _line->height());
|
2012-12-19 10:55:06 -05:00
|
|
|
uint32_t ignored;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-01-11 14:36:29 -05:00
|
|
|
/* we are ignoring x position for this drag, so we can just pass in anything */
|
2012-12-19 10:55:06 -05:00
|
|
|
_line->drag_motion (0, fraction, true, false, ignored);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-06-26 15:07:29 -04:00
|
|
|
show_verbose_cursor_text (_line->get_verbose_cursor_string (fraction));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-19 13:22:41 -05:00
|
|
|
LineDrag::finished (GdkEvent* event, bool movement_occured)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2014-02-19 13:22:41 -05:00
|
|
|
if (movement_occured) {
|
|
|
|
motion (event, false);
|
|
|
|
_line->end_drag (false, 0);
|
|
|
|
} else {
|
|
|
|
/* add a new control point on the line */
|
|
|
|
|
|
|
|
AutomationTimeAxisView* atv;
|
|
|
|
|
|
|
|
_line->end_drag (false, 0);
|
|
|
|
|
|
|
|
if ((atv = dynamic_cast<AutomationTimeAxisView*>(_editor->clicked_axisview)) != 0) {
|
2014-02-26 08:43:53 -05:00
|
|
|
framepos_t where = _editor->window_event_sample (event, 0, 0);
|
2014-02-19 13:22:41 -05:00
|
|
|
atv->add_automation_event (event, where, event->button.y, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-14 08:13:38 -05:00
|
|
|
_editor->commit_reversible_command ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
LineDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2010-01-07 20:53:50 -05:00
|
|
|
_line->reset ();
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
FeatureLineDrag::FeatureLineDrag (Editor* e, ArdourCanvas::Item* i)
|
|
|
|
: Drag (e, i),
|
|
|
|
_line (0),
|
|
|
|
_cumulative_x_drag (0)
|
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New FeatureLineDrag\n");
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
2010-09-09 17:34:45 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
void
|
|
|
|
FeatureLineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
_line = reinterpret_cast<Line*> (_item);
|
2010-07-06 07:33:27 -04:00
|
|
|
assert (_line);
|
|
|
|
|
|
|
|
/* need to get x coordinate in terms of parent (AudioRegionView) origin. */
|
|
|
|
|
|
|
|
double cx = event->button.x;
|
|
|
|
double cy = event->button.y;
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_item->parent()->canvas_to_item (cx, cy);
|
2010-07-06 07:33:27 -04:00
|
|
|
|
|
|
|
/* store grab start in parent frame */
|
|
|
|
_region_view_grab_x = cx;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
_before = *(float*) _item->get_data ("position");
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
_arv = reinterpret_cast<AudioRegionView*> (_item->get_data ("regionview"));
|
2011-02-14 16:49:43 -05:00
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
_max_x = _editor->sample_to_pixel(_arv->get_duration());
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-13 00:14:48 -05:00
|
|
|
FeatureLineDrag::motion (GdkEvent*, bool)
|
2010-07-06 07:33:27 -04:00
|
|
|
{
|
|
|
|
double dx = _drags->current_pointer_x() - last_pointer_x();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
double cx = _region_view_grab_x + _cumulative_x_drag + dx;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
_cumulative_x_drag += dx;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
/* Clamp the min and max extent of the drag to keep it within the region view bounds */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
if (cx > _max_x){
|
|
|
|
cx = _max_x;
|
|
|
|
}
|
|
|
|
else if(cx < 0){
|
|
|
|
cx = 0;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-04-12 21:46:44 -04:00
|
|
|
boost::optional<ArdourCanvas::Rect> bbox = _line->bounding_box ();
|
2013-04-04 00:32:52 -04:00
|
|
|
assert (bbox);
|
|
|
|
_line->set (ArdourCanvas::Duple (cx, 2.0), ArdourCanvas::Duple (cx, bbox.get().height ()));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
float *pos = new float;
|
|
|
|
*pos = cx;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-02-14 16:49:43 -05:00
|
|
|
_line->set_data ("position", pos);
|
|
|
|
|
|
|
|
_before = cx;
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-13 00:14:48 -05:00
|
|
|
FeatureLineDrag::finished (GdkEvent*, bool)
|
2010-07-06 07:33:27 -04:00
|
|
|
{
|
|
|
|
_arv = reinterpret_cast<AudioRegionView*> (_item->get_data ("regionview"));
|
2011-02-14 16:49:43 -05:00
|
|
|
_arv->update_transient(_before, _before);
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
FeatureLineDrag::aborted (bool)
|
2010-07-06 07:33:27 -04:00
|
|
|
{
|
|
|
|
//_line->reset ();
|
|
|
|
}
|
|
|
|
|
2010-09-09 17:34:45 -04:00
|
|
|
RubberbandSelectDrag::RubberbandSelectDrag (Editor* e, ArdourCanvas::Item* i)
|
|
|
|
: Drag (e, i)
|
2012-01-19 21:54:23 -05:00
|
|
|
, _vertical_only (false)
|
2010-09-09 17:34:45 -04:00
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New RubberbandSelectDrag\n");
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
|
|
|
RubberbandSelectDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event);
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (adjusted_current_frame (event));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-25 16:06:52 -05:00
|
|
|
RubberbandSelectDrag::motion (GdkEvent* event, bool)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t start;
|
|
|
|
framepos_t end;
|
2009-05-30 14:25:59 -04:00
|
|
|
double y1;
|
|
|
|
double y2;
|
|
|
|
|
2014-12-22 13:39:41 -05:00
|
|
|
framepos_t const pf = adjusted_current_frame (event, ARDOUR_UI::config()->get_rubberbanding_snaps_to_grid ());
|
2009-12-21 20:12:41 -05:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t grab = grab_frame ();
|
2014-12-22 13:39:41 -05:00
|
|
|
if (ARDOUR_UI::config()->get_rubberbanding_snaps_to_grid ()) {
|
2009-12-21 20:12:41 -05:00
|
|
|
_editor->snap_to_with_modifier (grab, event);
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
/* base start and end on initial click position */
|
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
if (pf < grab) {
|
|
|
|
start = pf;
|
|
|
|
end = grab;
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2009-12-21 20:12:41 -05:00
|
|
|
end = pf;
|
|
|
|
start = grab;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
if (current_pointer_y() < grab_y()) {
|
|
|
|
y1 = current_pointer_y();
|
2009-12-21 20:12:41 -05:00
|
|
|
y2 = grab_y();
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2014-06-08 11:26:25 -04:00
|
|
|
y2 = current_pointer_y();
|
2009-12-21 20:12:41 -05:00
|
|
|
y1 = grab_y();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (start != end || y1 != y2) {
|
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
double x1 = _editor->sample_to_pixel (start);
|
|
|
|
double x2 = _editor->sample_to_pixel (end);
|
2014-01-02 09:53:53 -05:00
|
|
|
const double min_dimension = 2.0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-01-19 21:54:23 -05:00
|
|
|
if (_vertical_only) {
|
|
|
|
/* fixed 10 pixel width */
|
2014-06-06 08:32:35 -04:00
|
|
|
x2 = x1 + 10;
|
2012-01-19 21:54:23 -05:00
|
|
|
} else {
|
2014-01-02 09:44:15 -05:00
|
|
|
if (x2 < x1) {
|
2014-01-02 09:53:53 -05:00
|
|
|
x2 = min (x1 - min_dimension, x2);
|
2014-01-02 09:44:15 -05:00
|
|
|
} else {
|
2014-01-02 09:53:53 -05:00
|
|
|
x2 = max (x1 + min_dimension, x2);
|
2014-01-02 09:44:15 -05:00
|
|
|
}
|
2012-01-19 21:54:23 -05:00
|
|
|
}
|
|
|
|
|
2014-01-02 09:44:15 -05:00
|
|
|
if (y2 < y1) {
|
2014-01-02 09:53:53 -05:00
|
|
|
y2 = min (y1 - min_dimension, y2);
|
2014-01-02 09:44:15 -05:00
|
|
|
} else {
|
2014-01-02 09:53:53 -05:00
|
|
|
y2 = max (y1 + min_dimension, y2);
|
2014-01-02 09:44:15 -05:00
|
|
|
}
|
|
|
|
|
2014-06-06 08:32:35 -04:00
|
|
|
/* translate rect into item space and set */
|
|
|
|
|
2014-06-10 11:00:15 -04:00
|
|
|
ArdourCanvas::Rect r (x1, y1, x2, y2);
|
2014-06-06 08:32:35 -04:00
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
/* this drag is a _trackview_only == true drag, so the y1 and
|
|
|
|
* y2 (computed using current_pointer_y() and grab_y()) will be
|
|
|
|
* relative to the top of the trackview group). The
|
|
|
|
* rubberband rect has the same parent/scroll offset as the
|
|
|
|
* the trackview group, so we can use the "r" rect directly
|
|
|
|
* to set the shape of the rubberband.
|
|
|
|
*/
|
|
|
|
|
|
|
|
_editor->rubberband_rect->set (r);
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->rubberband_rect->show();
|
|
|
|
_editor->rubberband_rect->raise_to_top();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (pf);
|
2011-11-16 15:11:33 -05:00
|
|
|
|
|
|
|
do_select_things (event, true);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-16 15:11:33 -05:00
|
|
|
RubberbandSelectDrag::do_select_things (GdkEvent* event, bool drag_in_progress)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2011-11-16 15:11:33 -05:00
|
|
|
framepos_t x1;
|
|
|
|
framepos_t x2;
|
|
|
|
|
|
|
|
if (grab_frame() < last_pointer_frame()) {
|
|
|
|
x1 = grab_frame ();
|
|
|
|
x2 = last_pointer_frame ();
|
|
|
|
} else {
|
|
|
|
x2 = grab_frame ();
|
|
|
|
x1 = last_pointer_frame ();
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2011-11-16 15:11:33 -05:00
|
|
|
double y1;
|
|
|
|
double y2;
|
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
if (current_pointer_y() < grab_y()) {
|
|
|
|
y1 = current_pointer_y();
|
2011-11-16 15:11:33 -05:00
|
|
|
y2 = grab_y();
|
|
|
|
} else {
|
2014-06-08 11:26:25 -04:00
|
|
|
y2 = current_pointer_y();
|
2011-11-16 15:11:33 -05:00
|
|
|
y1 = grab_y();
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2011-11-16 15:11:33 -05:00
|
|
|
select_things (event->button.state, x1, x2, y1, y2, drag_in_progress);
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2011-11-16 15:11:33 -05:00
|
|
|
void
|
|
|
|
RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred)
|
|
|
|
{
|
|
|
|
if (movement_occurred) {
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2011-11-16 15:11:33 -05:00
|
|
|
motion (event, false);
|
|
|
|
do_select_things (event, false);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2011-11-16 15:11:33 -05:00
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-01-25 14:39:20 -05:00
|
|
|
/* just a click */
|
|
|
|
|
|
|
|
bool do_deselect = true;
|
|
|
|
MidiTimeAxisView* mtv;
|
|
|
|
|
|
|
|
if ((mtv = dynamic_cast<MidiTimeAxisView*>(_editor->clicked_axisview)) != 0) {
|
|
|
|
/* MIDI track */
|
2014-11-15 02:03:40 -05:00
|
|
|
if (_editor->selection->empty() && _editor->mouse_mode == MouseDraw) {
|
2012-01-25 14:39:20 -05:00
|
|
|
/* nothing selected */
|
|
|
|
add_midi_region (mtv);
|
|
|
|
do_deselect = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-05 15:29:54 -05:00
|
|
|
/* do not deselect if Primary or Tertiary (toggle-select or
|
|
|
|
* extend-select are pressed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier) &&
|
|
|
|
!Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier) &&
|
|
|
|
do_deselect) {
|
2012-01-25 14:39:20 -05:00
|
|
|
deselect_things ();
|
|
|
|
}
|
2011-02-14 16:49:43 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_editor->rubberband_rect->hide();
|
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
RubberbandSelectDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2010-01-07 20:53:50 -05:00
|
|
|
_editor->rubberband_rect->hide ();
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2010-09-09 17:34:45 -04:00
|
|
|
TimeFXDrag::TimeFXDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, std::list<RegionView*> const & v)
|
|
|
|
: RegionDrag (e, i, p, v)
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New TimeFXDrag\n");
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2010-09-06 08:34:11 -04:00
|
|
|
TimeFXDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-06 08:34:11 -04:00
|
|
|
Drag::start_grab (event, cursor);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (adjusted_current_frame (event));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
TimeFXDrag::motion (GdkEvent* event, bool)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
RegionView* rv = _primary;
|
2012-05-27 16:07:13 -04:00
|
|
|
StreamView* cv = rv->get_time_axis_view().view ();
|
|
|
|
|
|
|
|
pair<TimeAxisView*, double> const tv = _editor->trackview_by_y_position (grab_y());
|
|
|
|
int layer = tv.first->layer_display() == Overlaid ? 0 : tv.second;
|
|
|
|
int layers = tv.first->layer_display() == Overlaid ? 1 : cv->layers();
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const pf = adjusted_current_frame (event);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
if (pf > rv->region()->position()) {
|
2012-05-27 16:07:13 -04:00
|
|
|
rv->get_time_axis_view().show_timestretch (rv->region()->position(), pf, layers, layer);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (pf);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
TimeFXDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2009-07-09 13:58:13 -04:00
|
|
|
_primary->get_time_axis_view().hide_timestretch ();
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2009-10-22 14:55:39 -04:00
|
|
|
if (!movement_occurred) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
if (last_pointer_frame() < _primary->region()->position()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
/* backwards drag of the left edge - not usable */
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framecnt_t newlen = last_pointer_frame() - _primary->region()->position();
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
float percentage = (double) newlen / (double) _primary->region()->length();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
#ifndef USE_RUBBERBAND
|
2009-10-14 12:10:01 -04:00
|
|
|
// Soundtouch uses percentage / 100 instead of normal (/ 1)
|
2009-05-30 14:25:59 -04:00
|
|
|
if (_primary->region()->data_type() == DataType::AUDIO) {
|
|
|
|
percentage = (float) ((double) newlen - (double) _primary->region()->length()) / ((double) newlen) * 100.0f;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
#endif
|
|
|
|
|
2012-01-27 11:29:01 -05:00
|
|
|
if (!_editor->get_selection().regions.empty()) {
|
|
|
|
/* primary will already be included in the selection, and edit
|
|
|
|
group shared editing will propagate selection across
|
|
|
|
equivalent regions, so just use the current region
|
|
|
|
selection.
|
|
|
|
*/
|
2012-01-24 12:04:15 -05:00
|
|
|
|
2012-01-27 11:29:01 -05:00
|
|
|
if (_editor->time_stretch (_editor->get_selection().regions, percentage) == -1) {
|
|
|
|
error << _("An error occurred while executing time stretch operation") << endmsg;
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
TimeFXDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2010-01-07 20:53:50 -05:00
|
|
|
_primary->get_time_axis_view().hide_timestretch ();
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
|
|
|
|
2010-09-09 17:34:45 -04:00
|
|
|
ScrubDrag::ScrubDrag (Editor* e, ArdourCanvas::Item* i)
|
|
|
|
: Drag (e, i)
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New ScrubDrag\n");
|
|
|
|
}
|
2010-01-07 20:28:15 -05:00
|
|
|
|
2009-06-10 09:58:22 -04:00
|
|
|
void
|
|
|
|
ScrubDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
ScrubDrag::motion (GdkEvent* /*event*/, bool)
|
2009-06-10 09:58:22 -04:00
|
|
|
{
|
2010-01-12 11:14:49 -05:00
|
|
|
_editor->scrub (adjusted_current_frame (0, false), _drags->current_pointer_x ());
|
2009-06-10 09:58:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
ScrubDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
|
2009-06-10 09:58:22 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (movement_occurred && _editor->session()) {
|
2009-06-10 09:58:22 -04:00
|
|
|
/* make sure we stop */
|
2009-12-17 13:24:23 -05:00
|
|
|
_editor->session()->request_transport_speed (0.0);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-06-10 09:58:22 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
ScrubDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
SelectionDrag::SelectionDrag (Editor* e, ArdourCanvas::Item* i, Operation o)
|
2009-11-08 11:28:21 -05:00
|
|
|
: Drag (e, i)
|
|
|
|
, _operation (o)
|
2012-12-13 14:39:36 -05:00
|
|
|
, _add (false)
|
2010-01-01 17:11:15 -05:00
|
|
|
, _original_pointer_time_axis (-1)
|
2012-01-30 17:53:22 -05:00
|
|
|
, _time_selection_at_start (!_editor->get_selection().time.empty())
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New SelectionDrag\n");
|
2012-12-13 14:39:36 -05:00
|
|
|
|
|
|
|
if (_time_selection_at_start) {
|
|
|
|
start_at_start = _editor->get_selection().time.start();
|
|
|
|
end_at_start = _editor->get_selection().time.end_frame();
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SelectionDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_editor->session() == 0) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Gdk::Cursor* cursor = 0;
|
|
|
|
|
|
|
|
switch (_operation) {
|
|
|
|
case CreateSelection:
|
2012-12-13 14:39:36 -05:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::CopyModifier)) {
|
|
|
|
_add = true;
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2012-12-13 14:39:36 -05:00
|
|
|
_add = false;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2010-11-16 09:53:16 -05:00
|
|
|
cursor = _editor->cursors()->selector;
|
2009-05-30 14:25:59 -04:00
|
|
|
Drag::start_grab (event, cursor);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionStartTrim:
|
|
|
|
if (_editor->clicked_axisview) {
|
|
|
|
_editor->clicked_axisview->order_selection_trims (_item, true);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2010-11-16 09:53:16 -05:00
|
|
|
Drag::start_grab (event, _editor->cursors()->left_side_trim);
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
case SelectionEndTrim:
|
|
|
|
if (_editor->clicked_axisview) {
|
|
|
|
_editor->clicked_axisview->order_selection_trims (_item, false);
|
|
|
|
}
|
2010-11-16 09:53:16 -05:00
|
|
|
Drag::start_grab (event, _editor->cursors()->right_side_trim);
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionMove:
|
|
|
|
Drag::start_grab (event, cursor);
|
|
|
|
break;
|
2012-12-13 14:39:36 -05:00
|
|
|
|
|
|
|
case SelectionExtend:
|
|
|
|
Drag::start_grab (event, cursor);
|
|
|
|
break;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_operation == SelectionMove) {
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (_editor->selection->time[_editor->clicked_selection].start);
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (adjusted_current_frame (event));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
_original_pointer_time_axis = _editor->trackview_by_y_position (current_pointer_y ()).first->order ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-12-19 22:42:59 -05:00
|
|
|
void
|
|
|
|
SelectionDrag::setup_pointer_frame_offset ()
|
|
|
|
{
|
|
|
|
switch (_operation) {
|
|
|
|
case CreateSelection:
|
|
|
|
_pointer_frame_offset = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionStartTrim:
|
|
|
|
case SelectionMove:
|
|
|
|
_pointer_frame_offset = raw_grab_frame() - _editor->selection->time[_editor->clicked_selection].start;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionEndTrim:
|
|
|
|
_pointer_frame_offset = raw_grab_frame() - _editor->selection->time[_editor->clicked_selection].end;
|
|
|
|
break;
|
2012-12-13 14:39:36 -05:00
|
|
|
|
|
|
|
case SelectionExtend:
|
|
|
|
break;
|
2010-12-19 22:42:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
SelectionDrag::motion (GdkEvent* event, bool first_move)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t start = 0;
|
|
|
|
framepos_t end = 0;
|
2012-12-13 14:39:36 -05:00
|
|
|
framecnt_t length = 0;
|
|
|
|
framecnt_t distance = 0;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const pending_position = adjusted_current_frame (event);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-02-26 08:24:41 -05:00
|
|
|
if (_operation != CreateSelection && pending_position == last_pointer_frame()) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
switch (_operation) {
|
|
|
|
case CreateSelection:
|
2009-12-21 20:12:41 -05:00
|
|
|
{
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t grab = grab_frame ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
if (first_move) {
|
2012-11-18 10:35:05 -05:00
|
|
|
grab = adjusted_current_frame (event, false);
|
|
|
|
if (grab < pending_position) {
|
2014-11-16 02:01:02 -05:00
|
|
|
_editor->snap_to (grab, RoundDownMaybe);
|
2012-11-18 10:35:05 -05:00
|
|
|
} else {
|
2014-11-16 02:01:02 -05:00
|
|
|
_editor->snap_to (grab, RoundUpMaybe);
|
2012-11-18 10:35:05 -05:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-11-18 10:35:05 -05:00
|
|
|
if (pending_position < grab) {
|
2009-05-30 14:25:59 -04:00
|
|
|
start = pending_position;
|
2009-12-21 20:12:41 -05:00
|
|
|
end = grab;
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
|
|
|
end = pending_position;
|
2009-12-21 20:12:41 -05:00
|
|
|
start = grab;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
/* first drag: Either add to the selection
|
2009-12-13 16:27:19 -05:00
|
|
|
or create a new selection
|
2009-05-30 14:25:59 -04:00
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
if (first_move) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2012-12-13 14:39:36 -05:00
|
|
|
if (_add) {
|
2014-02-25 21:55:25 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
/* adding to the selection */
|
2010-11-25 15:37:39 -05:00
|
|
|
_editor->set_selected_track_as_side_effect (Selection::Add);
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->clicked_selection = _editor->selection->add (start, end);
|
2012-12-13 14:39:36 -05:00
|
|
|
_add = false;
|
2014-02-25 21:55:25 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2014-02-25 21:55:25 -05:00
|
|
|
|
2009-12-13 16:27:19 -05:00
|
|
|
/* new selection */
|
|
|
|
|
2010-05-20 18:38:12 -04:00
|
|
|
if (_editor->clicked_axisview && !_editor->selection->selected (_editor->clicked_axisview)) {
|
2010-11-25 15:37:39 -05:00
|
|
|
_editor->set_selected_track_as_side_effect (Selection::Set);
|
2009-12-13 16:27:19 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-13 16:27:19 -05:00
|
|
|
_editor->clicked_selection = _editor->selection->set (start, end);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2014-02-25 21:55:25 -05:00
|
|
|
|
2014-08-05 16:42:06 -04:00
|
|
|
//if user is selecting a range on an automation track, bail out here before we get to the grouped stuff,
|
|
|
|
// because the grouped stuff will start working on tracks (routeTAVs), and end up removing this
|
|
|
|
AutomationTimeAxisView *atest = dynamic_cast<AutomationTimeAxisView *>(_editor->clicked_axisview);
|
|
|
|
if (atest) {
|
|
|
|
_editor->selection->add (atest);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:55:25 -05:00
|
|
|
/* select all tracks within the rectangle that we've marked out so far */
|
2014-07-09 15:45:20 -04:00
|
|
|
TrackViewList new_selection;
|
2014-02-25 21:55:25 -05:00
|
|
|
TrackViewList& all_tracks (_editor->track_views);
|
2010-01-01 17:11:15 -05:00
|
|
|
|
2014-06-08 11:26:25 -04:00
|
|
|
ArdourCanvas::Coord const top = grab_y();
|
|
|
|
ArdourCanvas::Coord const bottom = current_pointer_y();
|
2014-06-05 17:06:36 -04:00
|
|
|
|
|
|
|
if (top >= 0 && bottom >= 0) {
|
|
|
|
|
2014-07-09 15:45:20 -04:00
|
|
|
//first, find the tracks that are covered in the y range selection
|
2014-06-05 17:06:36 -04:00
|
|
|
for (TrackViewList::const_iterator i = all_tracks.begin(); i != all_tracks.end(); ++i) {
|
|
|
|
if ((*i)->covered_by_y_range (top, bottom)) {
|
2014-07-09 15:45:20 -04:00
|
|
|
new_selection.push_back (*i);
|
2014-02-25 21:55:25 -05:00
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
|
2014-07-09 15:45:20 -04:00
|
|
|
//now find any tracks that are GROUPED with the tracks we selected
|
|
|
|
TrackViewList grouped_add = new_selection;
|
|
|
|
for (TrackViewList::const_iterator i = new_selection.begin(); i != new_selection.end(); ++i) {
|
|
|
|
RouteTimeAxisView *n = dynamic_cast<RouteTimeAxisView *>(*i);
|
2014-07-09 17:33:48 -04:00
|
|
|
if ( n && n->route()->route_group() && n->route()->route_group()->is_active() && n->route()->route_group()->enabled_property (ARDOUR::Properties::select.property_id) ) {
|
2014-07-09 15:34:00 -04:00
|
|
|
for (TrackViewList::const_iterator j = all_tracks.begin(); j != all_tracks.end(); ++j) {
|
2014-07-09 15:45:20 -04:00
|
|
|
RouteTimeAxisView *check = dynamic_cast<RouteTimeAxisView *>(*j);
|
|
|
|
if ( check && (n != check) && (check->route()->route_group() == n->route()->route_group()) )
|
2014-07-09 15:34:00 -04:00
|
|
|
grouped_add.push_back (*j);
|
|
|
|
}
|
|
|
|
}
|
2014-06-05 17:06:36 -04:00
|
|
|
}
|
2014-07-09 15:34:00 -04:00
|
|
|
|
2014-07-09 15:45:20 -04:00
|
|
|
//now compare our list with the current selection, and add or remove as necessary
|
|
|
|
//( NOTE: most mouse moves don't change the selection so we can't just SET it for every mouse move; it gets clunky )
|
2014-07-09 15:34:00 -04:00
|
|
|
TrackViewList tracks_to_add;
|
|
|
|
TrackViewList tracks_to_remove;
|
|
|
|
for (TrackViewList::const_iterator i = grouped_add.begin(); i != grouped_add.end(); ++i)
|
|
|
|
if ( !_editor->selection->tracks.contains ( *i ) )
|
|
|
|
tracks_to_add.push_back ( *i );
|
|
|
|
for (TrackViewList::const_iterator i = _editor->selection->tracks.begin(); i != _editor->selection->tracks.end(); ++i)
|
|
|
|
if ( !grouped_add.contains ( *i ) )
|
|
|
|
tracks_to_remove.push_back ( *i );
|
|
|
|
_editor->selection->add(tracks_to_add);
|
|
|
|
_editor->selection->remove(tracks_to_remove);
|
|
|
|
|
2014-02-25 21:55:25 -05:00
|
|
|
}
|
2009-12-21 20:12:41 -05:00
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
case SelectionStartTrim:
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
start = _editor->selection->time[_editor->clicked_selection].start;
|
|
|
|
end = _editor->selection->time[_editor->clicked_selection].end;
|
|
|
|
|
|
|
|
if (pending_position > end) {
|
|
|
|
start = end;
|
|
|
|
} else {
|
|
|
|
start = pending_position;
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
case SelectionEndTrim:
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
start = _editor->selection->time[_editor->clicked_selection].start;
|
|
|
|
end = _editor->selection->time[_editor->clicked_selection].end;
|
|
|
|
|
|
|
|
if (pending_position < start) {
|
|
|
|
end = start;
|
|
|
|
} else {
|
|
|
|
end = pending_position;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
2012-12-13 14:39:36 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
case SelectionMove:
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
start = _editor->selection->time[_editor->clicked_selection].start;
|
|
|
|
end = _editor->selection->time[_editor->clicked_selection].end;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
length = end - start;
|
2012-12-13 14:39:36 -05:00
|
|
|
distance = pending_position - start;
|
2009-05-30 14:25:59 -04:00
|
|
|
start = pending_position;
|
|
|
|
_editor->snap_to (start);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
end = start + length;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
2012-12-13 14:39:36 -05:00
|
|
|
|
|
|
|
case SelectionExtend:
|
|
|
|
break;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (start != end) {
|
2012-12-13 14:39:36 -05:00
|
|
|
switch (_operation) {
|
|
|
|
case SelectionMove:
|
|
|
|
if (_time_selection_at_start) {
|
|
|
|
_editor->selection->move_time (distance);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_editor->selection->replace (_editor->clicked_selection, start, end);
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_operation == SelectionMove) {
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time(start);
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time(pending_position);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
SelectionDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
Session* s = _editor->session();
|
2009-11-08 11:28:21 -05:00
|
|
|
|
2014-12-22 08:30:23 -05:00
|
|
|
_editor->begin_reversible_selection_op (_("Change Time Selection"));
|
2009-06-01 20:39:57 -04:00
|
|
|
if (movement_occurred) {
|
|
|
|
motion (event, false);
|
2009-05-30 14:25:59 -04:00
|
|
|
/* XXX this is not object-oriented programming at all. ick */
|
|
|
|
if (_editor->selection->time.consolidate()) {
|
|
|
|
_editor->selection->TimeChanged ();
|
|
|
|
}
|
2009-11-08 11:28:21 -05:00
|
|
|
|
|
|
|
/* XXX what if its a music time selection? */
|
2012-01-30 17:53:22 -05:00
|
|
|
if (s) {
|
2012-11-28 12:03:39 -05:00
|
|
|
if ( s->get_play_range() && s->transport_rolling() ) {
|
2012-01-30 17:53:22 -05:00
|
|
|
s->request_play_range (&_editor->selection->time, true);
|
|
|
|
} else {
|
2014-12-22 13:39:41 -05:00
|
|
|
if (ARDOUR_UI::config()->get_follow_edits() && !s->transport_rolling()) {
|
2014-07-03 13:49:59 -04:00
|
|
|
if (_operation == SelectionEndTrim)
|
|
|
|
_editor->maybe_locate_with_edit_preroll( _editor->get_selection().time.end_frame());
|
|
|
|
else
|
|
|
|
s->request_locate (_editor->get_selection().time.start());
|
2012-01-30 17:53:22 -05:00
|
|
|
}
|
|
|
|
}
|
2009-11-08 11:28:21 -05:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2012-01-30 17:53:22 -05:00
|
|
|
/* just a click, no pointer movement.
|
|
|
|
*/
|
2012-12-13 14:39:36 -05:00
|
|
|
|
|
|
|
if (_operation == SelectionExtend) {
|
|
|
|
if (_time_selection_at_start) {
|
|
|
|
framepos_t pos = adjusted_current_frame (event, false);
|
|
|
|
framepos_t start = min (pos, start_at_start);
|
|
|
|
framepos_t end = max (pos, end_at_start);
|
|
|
|
_editor->selection->set (start, end);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::CopyModifier)) {
|
|
|
|
if (_editor->clicked_selection) {
|
|
|
|
_editor->selection->remove (_editor->clicked_selection);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!_editor->clicked_selection) {
|
|
|
|
_editor->selection->clear_time();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-05-20 18:38:12 -04:00
|
|
|
if (_editor->clicked_axisview && !_editor->selection->selected (_editor->clicked_axisview)) {
|
2009-12-13 16:27:19 -05:00
|
|
|
_editor->selection->set (_editor->clicked_axisview);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2012-12-13 14:39:36 -05:00
|
|
|
|
2009-11-08 11:28:21 -05:00
|
|
|
if (s && s->get_play_range () && s->transport_rolling()) {
|
|
|
|
s->request_stop (false, false);
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_editor->stop_canvas_autoscroll ();
|
2012-12-14 11:46:01 -05:00
|
|
|
_editor->clicked_selection = 0;
|
2014-12-22 08:30:23 -05:00
|
|
|
_editor->commit_reversible_selection_op ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
SelectionDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
RangeMarkerBarDrag::RangeMarkerBarDrag (Editor* e, ArdourCanvas::Item* i, Operation o)
|
2014-06-08 11:26:25 -04:00
|
|
|
: Drag (e, i, false),
|
2009-06-08 15:28:51 -04:00
|
|
|
_operation (o),
|
|
|
|
_copy (false)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New RangeMarkerBarDrag\n");
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2013-04-04 18:45:27 -04:00
|
|
|
_drag_rect = new ArdourCanvas::Rectangle (_editor->time_line_group,
|
|
|
|
ArdourCanvas::Rect (0.0, 0.0, 0.0,
|
|
|
|
physical_screen_height (_editor->get_window())));
|
2009-05-30 14:25:59 -04:00
|
|
|
_drag_rect->hide ();
|
|
|
|
|
2014-12-14 16:15:38 -05:00
|
|
|
_drag_rect->set_fill_color (ARDOUR_UI::config()->color ("range drag rect"));
|
|
|
|
_drag_rect->set_outline_color (ARDOUR_UI::config()->color ("range drag rect"));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RangeMarkerBarDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_editor->session() == 0) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Gdk::Cursor* cursor = 0;
|
|
|
|
|
|
|
|
if (!_editor->temp_location) {
|
2010-08-09 12:40:31 -04:00
|
|
|
_editor->temp_location = new Location (*_editor->session());
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
switch (_operation) {
|
2014-09-17 09:39:29 -04:00
|
|
|
case CreateSkipMarker:
|
2009-05-30 14:25:59 -04:00
|
|
|
case CreateRangeMarker:
|
|
|
|
case CreateTransportMarker:
|
|
|
|
case CreateCDMarker:
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) {
|
|
|
|
_copy = true;
|
|
|
|
} else {
|
|
|
|
_copy = false;
|
|
|
|
}
|
2010-11-16 09:53:16 -05:00
|
|
|
cursor = _editor->cursors()->selector;
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Drag::start_grab (event, cursor);
|
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (adjusted_current_frame (event));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
RangeMarkerBarDrag::motion (GdkEvent* event, bool first_move)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t start = 0;
|
|
|
|
framepos_t end = 0;
|
2013-04-04 00:32:52 -04:00
|
|
|
ArdourCanvas::Rectangle *crect;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
switch (_operation) {
|
2014-09-17 09:39:29 -04:00
|
|
|
case CreateSkipMarker:
|
|
|
|
crect = _editor->range_bar_drag_rect;
|
|
|
|
break;
|
2009-05-30 14:25:59 -04:00
|
|
|
case CreateRangeMarker:
|
|
|
|
crect = _editor->range_bar_drag_rect;
|
|
|
|
break;
|
|
|
|
case CreateTransportMarker:
|
|
|
|
crect = _editor->transport_bar_drag_rect;
|
|
|
|
break;
|
|
|
|
case CreateCDMarker:
|
|
|
|
crect = _editor->cd_marker_bar_drag_rect;
|
|
|
|
break;
|
|
|
|
default:
|
2012-11-13 10:11:07 -05:00
|
|
|
error << string_compose (_("programming_error: %1"), "Error: unknown range marker op passed to Editor::drag_range_markerbar_op ()") << endmsg;
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t const pf = adjusted_current_frame (event);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2014-09-17 09:39:29 -04:00
|
|
|
if (_operation == CreateSkipMarker || _operation == CreateRangeMarker || _operation == CreateTransportMarker || _operation == CreateCDMarker) {
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t grab = grab_frame ();
|
2009-12-21 20:12:41 -05:00
|
|
|
_editor->snap_to (grab);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
if (pf < grab_frame()) {
|
|
|
|
start = pf;
|
|
|
|
end = grab;
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2009-12-21 20:12:41 -05:00
|
|
|
end = pf;
|
|
|
|
start = grab;
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
/* first drag: Either add to the selection
|
|
|
|
or create a new selection.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
if (first_move) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->temp_location->set (start, end);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
crect->show ();
|
|
|
|
|
|
|
|
update_item (_editor->temp_location);
|
|
|
|
_drag_rect->show();
|
|
|
|
//_drag_rect->raise_to_top();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (start != end) {
|
|
|
|
_editor->temp_location->set (start, end);
|
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
double x1 = _editor->sample_to_pixel (start);
|
|
|
|
double x2 = _editor->sample_to_pixel (end);
|
2013-04-04 00:32:52 -04:00
|
|
|
crect->set_x0 (x1);
|
|
|
|
crect->set_x1 (x2);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
update_item (_editor->temp_location);
|
|
|
|
}
|
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_time (pf);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-01 20:39:57 -04:00
|
|
|
RangeMarkerBarDrag::finished (GdkEvent* event, bool movement_occurred)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
Location * newloc = 0;
|
|
|
|
string rangename;
|
|
|
|
int flags;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
if (movement_occurred) {
|
|
|
|
motion (event, false);
|
2009-08-04 14:18:57 -04:00
|
|
|
_drag_rect->hide();
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
switch (_operation) {
|
2014-09-17 09:39:29 -04:00
|
|
|
case CreateSkipMarker:
|
2009-05-30 14:25:59 -04:00
|
|
|
case CreateRangeMarker:
|
|
|
|
case CreateCDMarker:
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
XMLNode &before = _editor->session()->locations()->get_state();
|
2014-09-17 09:39:29 -04:00
|
|
|
if (_operation == CreateSkipMarker) {
|
|
|
|
_editor->begin_reversible_command (_("new skip marker"));
|
|
|
|
_editor->session()->locations()->next_available_name(rangename,_("skip"));
|
|
|
|
flags = Location::IsRangeMarker | Location::IsSkip;
|
|
|
|
_editor->range_bar_drag_rect->hide();
|
|
|
|
} else if (_operation == CreateCDMarker) {
|
|
|
|
_editor->session()->locations()->next_available_name(rangename, _("CD"));
|
|
|
|
_editor->begin_reversible_command (_("new CD marker"));
|
2009-05-30 14:25:59 -04:00
|
|
|
flags = Location::IsRangeMarker | Location::IsCDMarker;
|
|
|
|
_editor->cd_marker_bar_drag_rect->hide();
|
2014-09-17 09:39:29 -04:00
|
|
|
} else {
|
|
|
|
_editor->begin_reversible_command (_("new skip marker"));
|
|
|
|
_editor->session()->locations()->next_available_name(rangename, _("unnamed"));
|
2009-05-30 14:25:59 -04:00
|
|
|
flags = Location::IsRangeMarker;
|
|
|
|
_editor->range_bar_drag_rect->hide();
|
|
|
|
}
|
2010-08-09 12:40:31 -04:00
|
|
|
newloc = new Location (
|
|
|
|
*_editor->session(), _editor->temp_location->start(), _editor->temp_location->end(), rangename, (Location::Flags) flags
|
|
|
|
);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
_editor->session()->locations()->add (newloc, true);
|
|
|
|
XMLNode &after = _editor->session()->locations()->get_state();
|
|
|
|
_editor->session()->add_command(new MementoCommand<Locations>(*(_editor->session()->locations()), &before, &after));
|
2009-05-30 14:25:59 -04:00
|
|
|
_editor->commit_reversible_command ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CreateTransportMarker:
|
|
|
|
// popup menu to pick loop or punch
|
|
|
|
_editor->new_transport_marker_context_menu (&event->button, _item);
|
|
|
|
break;
|
|
|
|
}
|
2014-01-27 10:09:58 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2014-01-27 10:09:58 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
/* just a click, no pointer movement. remember that context menu stuff was handled elsewhere */
|
|
|
|
|
2014-01-27 10:09:58 -05:00
|
|
|
if (_operation == CreateTransportMarker) {
|
|
|
|
|
|
|
|
/* didn't drag, so just locate */
|
|
|
|
|
|
|
|
_editor->session()->request_locate (grab_frame(), _editor->session()->transport_rolling());
|
|
|
|
|
|
|
|
} else if (_operation == CreateCDMarker) {
|
|
|
|
|
|
|
|
/* didn't drag, but mark is already created so do
|
|
|
|
* nothing */
|
|
|
|
|
2014-09-17 09:39:29 -04:00
|
|
|
} else { /* operation == CreateRangeMarker || CreateSkipMarker */
|
2014-01-27 10:09:58 -05:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2010-09-08 21:38:21 -04:00
|
|
|
framepos_t start;
|
|
|
|
framepos_t end;
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2009-12-21 20:12:41 -05:00
|
|
|
_editor->session()->locations()->marks_either_side (grab_frame(), start, end);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-17 12:24:22 -04:00
|
|
|
if (end == max_framepos) {
|
2009-12-17 13:24:23 -05:00
|
|
|
end = _editor->session()->current_end_frame ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-09-17 12:24:22 -04:00
|
|
|
if (start == max_framepos) {
|
2009-12-17 13:24:23 -05:00
|
|
|
start = _editor->session()->current_start_frame ();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (_editor->mouse_mode) {
|
|
|
|
case MouseObject:
|
|
|
|
/* find the two markers on either side and then make the selection from it */
|
2010-08-09 21:52:49 -04:00
|
|
|
_editor->select_all_within (start, end, 0.0f, FLT_MAX, _editor->track_views, Selection::Set, false);
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
/* find the two markers on either side of the click and make the range out of it */
|
2009-12-13 16:27:19 -05:00
|
|
|
_editor->selection->set (start, end);
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_editor->stop_canvas_autoscroll ();
|
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
RangeMarkerBarDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
RangeMarkerBarDrag::update_item (Location* location)
|
|
|
|
{
|
2013-04-12 11:15:45 -04:00
|
|
|
double const x1 = _editor->sample_to_pixel (location->start());
|
|
|
|
double const x2 = _editor->sample_to_pixel (location->end());
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_drag_rect->set_x0 (x1);
|
|
|
|
_drag_rect->set_x1 (x2);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2009-09-08 17:45:44 -04:00
|
|
|
NoteDrag::NoteDrag (Editor* e, ArdourCanvas::Item* i)
|
|
|
|
: Drag (e, i)
|
2010-08-19 18:01:10 -04:00
|
|
|
, _cumulative_dx (0)
|
|
|
|
, _cumulative_dy (0)
|
2009-09-08 17:45:44 -04:00
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New NoteDrag\n");
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_primary = reinterpret_cast<NoteBase*> (_item->get_data ("notebase"));
|
|
|
|
assert (_primary);
|
2010-08-19 18:01:10 -04:00
|
|
|
_region = &_primary->region_view ();
|
|
|
|
_note_height = _region->midi_stream_view()->note_height ();
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NoteDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event);
|
|
|
|
|
2010-08-19 18:01:10 -04:00
|
|
|
if (!(_was_selected = _primary->selected())) {
|
2009-09-12 12:46:19 -04:00
|
|
|
|
2009-09-10 16:41:08 -04:00
|
|
|
/* tertiary-click means extend selection - we'll do that on button release,
|
|
|
|
so don't add it here, because otherwise we make it hard to figure
|
|
|
|
out the "extend-to" range.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool extend = Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier);
|
|
|
|
|
|
|
|
if (!extend) {
|
2009-09-12 12:46:19 -04:00
|
|
|
bool add = Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier);
|
|
|
|
|
|
|
|
if (add) {
|
2010-08-19 18:01:10 -04:00
|
|
|
_region->note_selected (_primary, true);
|
2009-09-12 12:46:19 -04:00
|
|
|
} else {
|
2010-08-19 18:01:10 -04:00
|
|
|
_region->unique_select (_primary);
|
2009-09-12 12:46:19 -04:00
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
|
|
|
|
_editor->begin_reversible_selection_op(_("Select Note Press"));
|
|
|
|
_editor->commit_reversible_selection_op();
|
2009-09-10 16:41:08 -04:00
|
|
|
}
|
|
|
|
}
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
|
|
|
|
2010-08-19 18:01:10 -04:00
|
|
|
/** @return Current total drag x change in frames */
|
|
|
|
frameoffset_t
|
|
|
|
NoteDrag::total_dx () const
|
2009-09-08 17:45:44 -04:00
|
|
|
{
|
2010-08-19 18:01:10 -04:00
|
|
|
/* dx in frames */
|
2013-04-12 11:15:45 -04:00
|
|
|
frameoffset_t const dx = _editor->pixel_to_sample (_drags->current_pointer_x() - grab_x());
|
2009-09-08 17:45:44 -04:00
|
|
|
|
2010-08-19 18:01:10 -04:00
|
|
|
/* primary note time */
|
2011-08-16 10:24:41 -04:00
|
|
|
frameoffset_t const n = _region->source_beats_to_absolute_frames (_primary->note()->time ());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-10-22 19:17:08 -04:00
|
|
|
/* new time of the primary note in session frames */
|
2011-05-02 20:45:54 -04:00
|
|
|
frameoffset_t st = n + dx;
|
|
|
|
|
2011-10-22 19:18:54 -04:00
|
|
|
framepos_t const rp = _region->region()->position ();
|
|
|
|
|
2011-05-02 20:45:54 -04:00
|
|
|
/* prevent the note being dragged earlier than the region's position */
|
2011-10-22 19:18:54 -04:00
|
|
|
st = max (st, rp);
|
2009-09-08 17:45:44 -04:00
|
|
|
|
2010-08-19 18:01:10 -04:00
|
|
|
/* snap and return corresponding delta */
|
2011-10-22 19:18:54 -04:00
|
|
|
return _region->snap_frame_to_frame (st - rp) + rp - n;
|
2010-08-19 18:01:10 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-07-17 12:02:26 -04:00
|
|
|
/** @return Current total drag y change in note number */
|
2010-08-19 18:01:10 -04:00
|
|
|
int8_t
|
|
|
|
NoteDrag::total_dy () const
|
|
|
|
{
|
2012-06-13 14:01:29 -04:00
|
|
|
MidiStreamView* msv = _region->midi_stream_view ();
|
|
|
|
double const y = _region->midi_view()->y_position ();
|
|
|
|
/* new current note */
|
2014-06-08 11:26:25 -04:00
|
|
|
uint8_t n = msv->y_to_note (current_pointer_y () - y);
|
2012-06-13 14:01:29 -04:00
|
|
|
/* clamp */
|
|
|
|
n = max (msv->lowest_note(), n);
|
|
|
|
n = min (msv->highest_note(), n);
|
|
|
|
/* and work out delta */
|
|
|
|
return n - msv->y_to_note (grab_y() - y);
|
2011-06-01 13:00:29 -04:00
|
|
|
}
|
2010-08-19 18:01:10 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
NoteDrag::motion (GdkEvent *, bool)
|
|
|
|
{
|
|
|
|
/* Total change in x and y since the start of the drag */
|
|
|
|
frameoffset_t const dx = total_dx ();
|
2011-07-17 12:02:26 -04:00
|
|
|
int8_t const dy = total_dy ();
|
2010-08-19 18:01:10 -04:00
|
|
|
|
|
|
|
/* Now work out what we have to do to the note canvas items to set this new drag delta */
|
2013-04-12 11:15:45 -04:00
|
|
|
double const tdx = _editor->sample_to_pixel (dx) - _cumulative_dx;
|
2011-07-17 12:02:26 -04:00
|
|
|
double const tdy = -dy * _note_height - _cumulative_dy;
|
2010-08-19 18:01:10 -04:00
|
|
|
|
|
|
|
if (tdx || tdy) {
|
|
|
|
_cumulative_dx += tdx;
|
|
|
|
_cumulative_dy += tdy;
|
2010-05-20 18:38:12 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
int8_t note_delta = total_dy();
|
2010-09-17 16:32:18 -04:00
|
|
|
|
|
|
|
_region->move_selection (tdx, tdy, note_delta);
|
2010-09-15 12:54:17 -04:00
|
|
|
|
2011-08-12 10:41:11 -04:00
|
|
|
/* the new note value may be the same as the old one, but we
|
|
|
|
* don't know what that means because the selection may have
|
|
|
|
* involved more than one note and we might be doing something
|
|
|
|
* odd with them. so show the note value anyway, always.
|
|
|
|
*/
|
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
char buf[12];
|
2011-08-12 10:41:11 -04:00
|
|
|
uint8_t new_note = min (max (_primary->note()->note() + note_delta, 0), 127);
|
|
|
|
|
|
|
|
snprintf (buf, sizeof (buf), "%s (%d)", Evoral::midi_note_name (new_note).c_str(),
|
2013-10-03 04:06:56 -04:00
|
|
|
(int) floor ((double)new_note));
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
show_verbose_cursor_text (buf);
|
2010-11-25 15:37:39 -05:00
|
|
|
}
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-08 17:45:44 -04:00
|
|
|
void
|
|
|
|
NoteDrag::finished (GdkEvent* ev, bool moved)
|
|
|
|
{
|
|
|
|
if (!moved) {
|
2012-02-08 07:50:32 -05:00
|
|
|
/* no motion - select note */
|
2015-01-10 12:07:31 -05:00
|
|
|
|
2012-02-08 07:50:32 -05:00
|
|
|
if (_editor->current_mouse_mode() == Editing::MouseObject ||
|
|
|
|
_editor->current_mouse_mode() == Editing::MouseDraw) {
|
2015-01-10 12:07:31 -05:00
|
|
|
|
|
|
|
bool changed = false;
|
|
|
|
|
2010-08-19 18:01:10 -04:00
|
|
|
if (_was_selected) {
|
2009-09-10 16:41:08 -04:00
|
|
|
bool add = Keyboard::modifier_state_equals (ev->button.state, Keyboard::PrimaryModifier);
|
|
|
|
if (add) {
|
2010-08-19 18:01:10 -04:00
|
|
|
_region->note_deselected (_primary);
|
2015-01-10 12:07:31 -05:00
|
|
|
changed = true;
|
2009-09-10 16:41:08 -04:00
|
|
|
}
|
2009-09-08 17:45:44 -04:00
|
|
|
} else {
|
|
|
|
bool extend = Keyboard::modifier_state_equals (ev->button.state, Keyboard::TertiaryModifier);
|
|
|
|
bool add = Keyboard::modifier_state_equals (ev->button.state, Keyboard::PrimaryModifier);
|
2009-09-10 16:41:08 -04:00
|
|
|
|
2010-08-19 18:01:10 -04:00
|
|
|
if (!extend && !add && _region->selection_size() > 1) {
|
|
|
|
_region->unique_select (_primary);
|
2015-01-10 12:07:31 -05:00
|
|
|
changed = true;
|
2009-09-10 16:41:08 -04:00
|
|
|
} else if (extend) {
|
2010-08-19 18:01:10 -04:00
|
|
|
_region->note_selected (_primary, true, true);
|
2015-01-10 12:07:31 -05:00
|
|
|
changed = true;
|
2009-09-08 17:45:44 -04:00
|
|
|
} else {
|
2009-09-10 16:41:08 -04:00
|
|
|
/* it was added during button press */
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
|
|
|
}
|
2015-01-10 12:07:31 -05:00
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
_editor->begin_reversible_selection_op(_("Select Note Release"));
|
|
|
|
_editor->commit_reversible_selection_op();
|
|
|
|
}
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
|
|
|
} else {
|
2010-09-21 11:15:06 -04:00
|
|
|
_region->note_dropped (_primary, total_dx(), total_dy());
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
NoteDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
|
|
|
}
|
|
|
|
|
2012-03-22 12:41:23 -04:00
|
|
|
/** Make an AutomationRangeDrag for lines in an AutomationTimeAxisView */
|
|
|
|
AutomationRangeDrag::AutomationRangeDrag (Editor* editor, AutomationTimeAxisView* atv, list<AudioRange> const & r)
|
|
|
|
: Drag (editor, atv->base_item ())
|
2010-01-01 17:11:15 -05:00
|
|
|
, _ranges (r)
|
2015-01-13 23:30:37 -05:00
|
|
|
, _y_origin (atv->y_position())
|
2010-01-01 17:11:15 -05:00
|
|
|
, _nothing_to_drag (false)
|
|
|
|
{
|
2010-09-09 17:34:45 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New AutomationRangeDrag\n");
|
2012-03-22 12:41:23 -04:00
|
|
|
setup (atv->lines ());
|
|
|
|
}
|
|
|
|
|
2015-01-13 23:30:37 -05:00
|
|
|
/** Make an AutomationRangeDrag for region gain lines or MIDI controller regions */
|
|
|
|
AutomationRangeDrag::AutomationRangeDrag (Editor* editor, RegionView* rv, list<AudioRange> const & r)
|
2012-03-22 12:41:23 -04:00
|
|
|
: Drag (editor, rv->get_canvas_group ())
|
|
|
|
, _ranges (r)
|
2015-01-13 23:30:37 -05:00
|
|
|
, _y_origin (rv->get_time_axis_view().y_position())
|
2012-03-22 12:41:23 -04:00
|
|
|
, _nothing_to_drag (false)
|
2015-01-13 23:30:37 -05:00
|
|
|
, _integral (false)
|
2012-03-22 12:41:23 -04:00
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::Drags, "New AutomationRangeDrag\n");
|
2010-01-01 17:11:15 -05:00
|
|
|
|
2012-03-22 12:41:23 -04:00
|
|
|
list<boost::shared_ptr<AutomationLine> > lines;
|
2015-01-13 23:30:37 -05:00
|
|
|
|
|
|
|
AudioRegionView* audio_view;
|
|
|
|
AutomationRegionView* automation_view;
|
|
|
|
if ((audio_view = dynamic_cast<AudioRegionView*>(rv))) {
|
|
|
|
lines.push_back (audio_view->get_gain_line ());
|
|
|
|
} else if ((automation_view = dynamic_cast<AutomationRegionView*>(rv))) {
|
|
|
|
lines.push_back (automation_view->line ());
|
|
|
|
_integral = true;
|
|
|
|
} else {
|
|
|
|
error << _("Automation range drag created for invalid region type") << endmsg;
|
|
|
|
}
|
|
|
|
|
2012-03-22 12:41:23 -04:00
|
|
|
setup (lines);
|
|
|
|
}
|
2010-09-09 17:35:28 -04:00
|
|
|
|
2012-03-22 12:41:23 -04:00
|
|
|
/** @param lines AutomationLines to drag.
|
|
|
|
* @param offset Offset from the session start to the points in the AutomationLines.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
AutomationRangeDrag::setup (list<boost::shared_ptr<AutomationLine> > const & lines)
|
|
|
|
{
|
|
|
|
/* find the lines that overlap the ranges being dragged */
|
|
|
|
list<boost::shared_ptr<AutomationLine> >::const_iterator i = lines.begin ();
|
2010-09-09 17:35:28 -04:00
|
|
|
while (i != lines.end ()) {
|
2012-03-22 12:41:23 -04:00
|
|
|
list<boost::shared_ptr<AutomationLine> >::const_iterator j = i;
|
2010-09-09 17:35:28 -04:00
|
|
|
++j;
|
|
|
|
|
2012-03-22 12:41:23 -04:00
|
|
|
pair<framepos_t, framepos_t> r = (*i)->get_point_x_range ();
|
2010-09-09 17:35:28 -04:00
|
|
|
|
|
|
|
/* check this range against all the AudioRanges that we are using */
|
|
|
|
list<AudioRange>::const_iterator k = _ranges.begin ();
|
|
|
|
while (k != _ranges.end()) {
|
2012-04-16 12:32:22 -04:00
|
|
|
if (k->coverage (r.first, r.second) != Evoral::OverlapNone) {
|
2010-09-09 17:35:28 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add it to our list if it overlaps at all */
|
|
|
|
if (k != _ranges.end()) {
|
|
|
|
Line n;
|
|
|
|
n.line = *i;
|
|
|
|
n.state = 0;
|
|
|
|
n.range = r;
|
|
|
|
_lines.push_back (n);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now ::lines contains the AutomationLines that somehow overlap our drag */
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
|
2012-07-10 11:58:09 -04:00
|
|
|
double
|
|
|
|
AutomationRangeDrag::y_fraction (boost::shared_ptr<AutomationLine> line, double global_y) const
|
|
|
|
{
|
2015-01-13 23:30:37 -05:00
|
|
|
return 1.0 - ((global_y - _y_origin) / line->height());
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
AutomationRangeDrag::value (boost::shared_ptr<AutomationList> list, double x) const
|
|
|
|
{
|
|
|
|
const double v = list->eval(x);
|
|
|
|
return _integral ? rint(v) : v;
|
2012-07-10 11:58:09 -04:00
|
|
|
}
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
void
|
|
|
|
AutomationRangeDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event, cursor);
|
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
/* Get line states before we start changing things */
|
|
|
|
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
|
|
|
|
i->state = &i->line->get_state ();
|
2014-06-08 11:26:25 -04:00
|
|
|
i->original_fraction = y_fraction (i->line, current_pointer_y());
|
2010-09-09 17:35:28 -04:00
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
|
|
|
|
if (_ranges.empty()) {
|
2010-09-09 17:35:28 -04:00
|
|
|
|
|
|
|
/* No selected time ranges: drag all points */
|
|
|
|
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
|
|
|
|
uint32_t const N = i->line->npoints ();
|
|
|
|
for (uint32_t j = 0; j < N; ++j) {
|
|
|
|
i->points.push_back (i->line->nth (j));
|
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
} else {
|
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
for (list<AudioRange>::const_iterator i = _ranges.begin(); i != _ranges.end(); ++i) {
|
2010-01-01 20:19:47 -05:00
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
framecnt_t const half = (i->start + i->end) / 2;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
/* find the line that this audio range starts in */
|
|
|
|
list<Line>::iterator j = _lines.begin();
|
|
|
|
while (j != _lines.end() && (j->range.first > i->start || j->range.second < i->start)) {
|
|
|
|
++j;
|
2010-01-01 20:19:47 -05:00
|
|
|
}
|
2010-09-09 17:35:28 -04:00
|
|
|
|
|
|
|
if (j != _lines.end()) {
|
|
|
|
boost::shared_ptr<AutomationList> the_list = j->line->the_list ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
/* j is the line that this audio range starts in; fade into it;
|
|
|
|
64 samples length plucked out of thin air.
|
|
|
|
*/
|
|
|
|
|
|
|
|
framepos_t a = i->start + 64;
|
|
|
|
if (a > half) {
|
|
|
|
a = half;
|
|
|
|
}
|
|
|
|
|
|
|
|
double const p = j->line->time_converter().from (i->start - j->line->time_converter().origin_b ());
|
|
|
|
double const q = j->line->time_converter().from (a - j->line->time_converter().origin_b ());
|
|
|
|
|
2015-01-13 23:30:37 -05:00
|
|
|
the_list->editor_add (p, value (the_list, p));
|
|
|
|
the_list->editor_add (q, value (the_list, q));
|
2010-01-01 20:19:47 -05:00
|
|
|
}
|
2010-09-09 17:35:28 -04:00
|
|
|
|
|
|
|
/* same thing for the end */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
j = _lines.begin();
|
|
|
|
while (j != _lines.end() && (j->range.first > i->end || j->range.second < i->end)) {
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j != _lines.end()) {
|
|
|
|
boost::shared_ptr<AutomationList> the_list = j->line->the_list ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
/* j is the line that this audio range starts in; fade out of it;
|
|
|
|
64 samples length plucked out of thin air.
|
|
|
|
*/
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
framepos_t b = i->end - 64;
|
|
|
|
if (b < half) {
|
|
|
|
b = half;
|
|
|
|
}
|
|
|
|
|
|
|
|
double const p = j->line->time_converter().from (b - j->line->time_converter().origin_b ());
|
|
|
|
double const q = j->line->time_converter().from (i->end - j->line->time_converter().origin_b ());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-01-13 23:30:37 -05:00
|
|
|
the_list->editor_add (p, value (the_list, p));
|
|
|
|
the_list->editor_add (q, value (the_list, q));
|
2010-09-09 17:35:28 -04:00
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
_nothing_to_drag = true;
|
2010-01-01 17:11:15 -05:00
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
/* Find all the points that should be dragged and put them in the relevant
|
|
|
|
points lists in the Line structs.
|
|
|
|
*/
|
2010-01-01 17:11:15 -05:00
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
|
2010-01-01 17:11:15 -05:00
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
uint32_t const N = i->line->npoints ();
|
|
|
|
for (uint32_t j = 0; j < N; ++j) {
|
|
|
|
|
|
|
|
/* here's a control point on this line */
|
|
|
|
ControlPoint* p = i->line->nth (j);
|
|
|
|
double const w = i->line->time_converter().to ((*p->model())->when) + i->line->time_converter().origin_b ();
|
|
|
|
|
|
|
|
/* see if it's inside a range */
|
|
|
|
list<AudioRange>::const_iterator k = _ranges.begin ();
|
|
|
|
while (k != _ranges.end() && (k->start >= w || k->end <= w)) {
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k != _ranges.end()) {
|
|
|
|
/* dragging this point */
|
|
|
|
_nothing_to_drag = false;
|
|
|
|
i->points.push_back (p);
|
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
if (_nothing_to_drag) {
|
2010-01-01 17:11:15 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-09 17:35:28 -04:00
|
|
|
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
|
2014-06-08 11:26:25 -04:00
|
|
|
i->line->start_drag_multiple (i->points, y_fraction (i->line, current_pointer_y()), i->state);
|
2010-09-09 17:35:28 -04:00
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-13 00:14:48 -05:00
|
|
|
AutomationRangeDrag::motion (GdkEvent*, bool /*first_move*/)
|
2010-01-01 17:11:15 -05:00
|
|
|
{
|
|
|
|
if (_nothing_to_drag) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-10 11:44:56 -04:00
|
|
|
for (list<Line>::iterator l = _lines.begin(); l != _lines.end(); ++l) {
|
2014-06-08 11:26:25 -04:00
|
|
|
float const f = y_fraction (l->line, current_pointer_y());
|
2010-09-09 17:35:28 -04:00
|
|
|
/* we are ignoring x position for this drag, so we can just pass in anything */
|
2012-12-19 10:55:06 -05:00
|
|
|
uint32_t ignored;
|
|
|
|
l->line->drag_motion (0, f, true, false, ignored);
|
2012-07-10 11:44:56 -04:00
|
|
|
show_verbose_cursor_text (l->line->get_verbose_cursor_relative_string (l->original_fraction, f));
|
2010-09-09 17:35:28 -04:00
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AutomationRangeDrag::finished (GdkEvent* event, bool)
|
|
|
|
{
|
|
|
|
if (_nothing_to_drag) {
|
|
|
|
return;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
motion (event, false);
|
2010-09-09 17:35:28 -04:00
|
|
|
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
|
2012-12-19 10:55:06 -05:00
|
|
|
i->line->end_drag (false, 0);
|
2010-09-09 17:35:28 -04:00
|
|
|
}
|
|
|
|
|
2014-12-14 08:13:38 -05:00
|
|
|
_editor->commit_reversible_command ();
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
2010-01-07 20:28:15 -05:00
|
|
|
|
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
AutomationRangeDrag::aborted (bool)
|
2010-01-07 20:28:15 -05:00
|
|
|
{
|
2010-09-09 17:35:28 -04:00
|
|
|
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
|
|
|
|
i->line->reset ();
|
|
|
|
}
|
2010-01-07 20:28:15 -05:00
|
|
|
}
|
2010-04-06 20:17:54 -04:00
|
|
|
|
2014-06-19 11:16:27 -04:00
|
|
|
DraggingView::DraggingView (RegionView* v, RegionDrag* parent, TimeAxisView* itav)
|
2010-04-06 20:17:54 -04:00
|
|
|
: view (v)
|
2014-06-19 11:16:27 -04:00
|
|
|
, initial_time_axis_view (itav)
|
2010-04-06 20:17:54 -04:00
|
|
|
{
|
2014-06-19 11:16:27 -04:00
|
|
|
/* note that time_axis_view may be null if the regionview was created
|
|
|
|
* as part of a copy operation.
|
|
|
|
*/
|
2010-09-06 08:34:11 -04:00
|
|
|
time_axis_view = parent->find_time_axis_view (&v->get_time_axis_view ());
|
|
|
|
layer = v->region()->layer ();
|
2013-04-04 00:32:52 -04:00
|
|
|
initial_y = v->get_canvas_group()->position().y;
|
2010-08-23 21:02:40 -04:00
|
|
|
initial_playlist = v->region()->playlist ();
|
2010-11-08 20:58:42 -05:00
|
|
|
initial_position = v->region()->position ();
|
|
|
|
initial_end = v->region()->position () + v->region()->length ();
|
2010-04-06 20:17:54 -04:00
|
|
|
}
|
2010-12-19 22:42:59 -05:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
PatchChangeDrag::PatchChangeDrag (Editor* e, PatchChange* i, MidiRegionView* r)
|
|
|
|
: Drag (e, i->canvas_item ())
|
2010-12-19 22:42:59 -05:00
|
|
|
, _region_view (r)
|
2010-12-28 13:19:40 -05:00
|
|
|
, _patch_change (i)
|
2010-12-19 22:42:59 -05:00
|
|
|
, _cumulative_dx (0)
|
|
|
|
{
|
2012-06-12 22:00:51 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Drags, string_compose ("New PatchChangeDrag, patch @ %1, grab @ %2\n",
|
|
|
|
_region_view->source_beats_to_absolute_frames (_patch_change->patch()->time()),
|
|
|
|
grab_frame()));
|
2010-12-19 22:42:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-28 13:19:40 -05:00
|
|
|
PatchChangeDrag::motion (GdkEvent* ev, bool)
|
2010-12-19 22:42:59 -05:00
|
|
|
{
|
|
|
|
framepos_t f = adjusted_current_frame (ev);
|
|
|
|
boost::shared_ptr<Region> r = _region_view->region ();
|
|
|
|
f = max (f, r->position ());
|
|
|
|
f = min (f, r->last_frame ());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2012-06-12 22:00:51 -04:00
|
|
|
framecnt_t const dxf = f - grab_frame(); // permitted dx in frames
|
2013-04-12 11:15:45 -04:00
|
|
|
double const dxu = _editor->sample_to_pixel (dxf); // permitted fx in units
|
2013-04-04 00:32:52 -04:00
|
|
|
_patch_change->move (ArdourCanvas::Duple (dxu - _cumulative_dx, 0));
|
2010-12-19 22:42:59 -05:00
|
|
|
_cumulative_dx = dxu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-28 13:19:40 -05:00
|
|
|
PatchChangeDrag::finished (GdkEvent* ev, bool movement_occurred)
|
2010-12-19 22:42:59 -05:00
|
|
|
{
|
|
|
|
if (!movement_occurred) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Region> r (_region_view->region ());
|
|
|
|
framepos_t f = adjusted_current_frame (ev);
|
|
|
|
f = max (f, r->position ());
|
|
|
|
f = min (f, r->last_frame ());
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-12-28 13:19:40 -05:00
|
|
|
_region_view->move_patch_change (
|
|
|
|
*_patch_change,
|
2012-06-12 22:00:51 -04:00
|
|
|
_region_view->region_frames_to_region_beats (f - (r->position() - r->start()))
|
2010-12-19 22:42:59 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-28 14:17:37 -05:00
|
|
|
PatchChangeDrag::aborted (bool)
|
2010-12-19 22:42:59 -05:00
|
|
|
{
|
2013-04-04 00:32:52 -04:00
|
|
|
_patch_change->move (ArdourCanvas::Duple (-_cumulative_dx, 0));
|
2010-12-19 22:42:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-12-28 13:19:40 -05:00
|
|
|
PatchChangeDrag::setup_pointer_frame_offset ()
|
2010-12-19 22:42:59 -05:00
|
|
|
{
|
|
|
|
boost::shared_ptr<Region> region = _region_view->region ();
|
2011-08-16 10:24:41 -04:00
|
|
|
_pointer_frame_offset = raw_grab_frame() - _region_view->source_beats_to_absolute_frames (_patch_change->patch()->time());
|
2010-12-19 22:42:59 -05:00
|
|
|
}
|
|
|
|
|
2011-11-16 15:11:33 -05:00
|
|
|
MidiRubberbandSelectDrag::MidiRubberbandSelectDrag (Editor* e, MidiRegionView* rv)
|
2013-04-25 16:05:21 -04:00
|
|
|
: RubberbandSelectDrag (e, rv->get_canvas_group ())
|
2011-11-16 15:11:33 -05:00
|
|
|
, _region_view (rv)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-02 16:29:46 -04:00
|
|
|
MidiRubberbandSelectDrag::select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool /*drag_in_progress*/)
|
2011-11-16 15:11:33 -05:00
|
|
|
{
|
|
|
|
_region_view->update_drag_selection (
|
2014-11-16 22:35:37 -05:00
|
|
|
x1, x2, y1, y2,
|
|
|
|
Keyboard::modifier_state_contains (button_state, Keyboard::TertiaryModifier));
|
2011-11-16 15:11:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiRubberbandSelectDrag::deselect_things ()
|
|
|
|
{
|
|
|
|
/* XXX */
|
|
|
|
}
|
|
|
|
|
2012-01-19 21:54:23 -05:00
|
|
|
MidiVerticalSelectDrag::MidiVerticalSelectDrag (Editor* e, MidiRegionView* rv)
|
2013-04-25 16:05:21 -04:00
|
|
|
: RubberbandSelectDrag (e, rv->get_canvas_group ())
|
2012-01-19 21:54:23 -05:00
|
|
|
, _region_view (rv)
|
|
|
|
{
|
|
|
|
_vertical_only = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-02 16:29:46 -04:00
|
|
|
MidiVerticalSelectDrag::select_things (int button_state, framepos_t /*x1*/, framepos_t /*x2*/, double y1, double y2, bool /*drag_in_progress*/)
|
2012-01-19 21:54:23 -05:00
|
|
|
{
|
|
|
|
double const y = _region_view->midi_view()->y_position ();
|
|
|
|
|
|
|
|
y1 = max (0.0, y1 - y);
|
|
|
|
y2 = max (0.0, y2 - y);
|
|
|
|
|
|
|
|
_region_view->update_vertical_drag_selection (
|
|
|
|
y1,
|
|
|
|
y2,
|
|
|
|
Keyboard::modifier_state_contains (button_state, Keyboard::TertiaryModifier)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiVerticalSelectDrag::deselect_things ()
|
|
|
|
{
|
|
|
|
/* XXX */
|
|
|
|
}
|
|
|
|
|
2011-11-16 15:11:33 -05:00
|
|
|
EditorRubberbandSelectDrag::EditorRubberbandSelectDrag (Editor* e, ArdourCanvas::Item* i)
|
|
|
|
: RubberbandSelectDrag (e, i)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorRubberbandSelectDrag::select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress)
|
|
|
|
{
|
|
|
|
if (drag_in_progress) {
|
|
|
|
/* We just want to select things at the end of the drag, not during it */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Selection::Operation op = ArdourKeyboard::selection_type (button_state);
|
2014-12-14 08:13:38 -05:00
|
|
|
|
2014-12-22 08:30:23 -05:00
|
|
|
_editor->begin_reversible_selection_op (_("rubberband selection"));
|
2014-12-14 08:13:38 -05:00
|
|
|
|
2011-11-16 15:11:33 -05:00
|
|
|
_editor->select_all_within (x1, x2 - 1, y1, y2, _editor->track_views, op, false);
|
2014-12-14 08:13:38 -05:00
|
|
|
|
2014-12-22 08:30:23 -05:00
|
|
|
_editor->commit_reversible_selection_op ();
|
2011-11-16 15:11:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorRubberbandSelectDrag::deselect_things ()
|
|
|
|
{
|
2015-01-10 12:07:31 -05:00
|
|
|
_editor->begin_reversible_selection_op (_("Clear Selection (rubberband)"));
|
|
|
|
|
|
|
|
_editor->selection->clear_tracks();
|
2011-11-16 15:11:33 -05:00
|
|
|
_editor->selection->clear_regions();
|
|
|
|
_editor->selection->clear_points ();
|
|
|
|
_editor->selection->clear_lines ();
|
2015-01-10 12:07:31 -05:00
|
|
|
_editor->selection->clear_midi_notes ();
|
|
|
|
|
|
|
|
_editor->commit_reversible_selection_op();
|
2011-11-16 15:11:33 -05:00
|
|
|
}
|
2011-12-11 07:54:54 -05:00
|
|
|
|
|
|
|
NoteCreateDrag::NoteCreateDrag (Editor* e, ArdourCanvas::Item* i, MidiRegionView* rv)
|
|
|
|
: Drag (e, i)
|
|
|
|
, _region_view (rv)
|
|
|
|
, _drag_rect (0)
|
|
|
|
{
|
2014-12-07 20:36:32 -05:00
|
|
|
_note[0] = _note[1] = 0;
|
2011-12-11 07:54:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
NoteCreateDrag::~NoteCreateDrag ()
|
|
|
|
{
|
|
|
|
delete _drag_rect;
|
|
|
|
}
|
|
|
|
|
2011-12-11 08:42:18 -05:00
|
|
|
framecnt_t
|
|
|
|
NoteCreateDrag::grid_frames (framepos_t t) const
|
2011-12-11 07:54:54 -05:00
|
|
|
{
|
|
|
|
bool success;
|
2015-01-07 00:12:07 -05:00
|
|
|
Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, t);
|
2011-12-11 07:54:54 -05:00
|
|
|
if (!success) {
|
2015-01-07 00:12:07 -05:00
|
|
|
grid_beats = Evoral::Beats(1);
|
2011-12-11 07:54:54 -05:00
|
|
|
}
|
|
|
|
|
2011-12-11 08:42:18 -05:00
|
|
|
return _region_view->region_beats_to_region_frames (grid_beats);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NoteCreateDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
|
|
|
{
|
2011-12-11 09:07:24 -05:00
|
|
|
Drag::start_grab (event, cursor);
|
|
|
|
|
2013-04-04 18:45:27 -04:00
|
|
|
_drag_rect = new ArdourCanvas::Rectangle (_region_view->get_canvas_group ());
|
2011-12-11 08:42:18 -05:00
|
|
|
|
|
|
|
framepos_t pf = _drags->current_pointer_frame ();
|
|
|
|
framecnt_t const g = grid_frames (pf);
|
2011-12-11 07:54:54 -05:00
|
|
|
|
|
|
|
/* Hack so that we always snap to the note that we are over, instead of snapping
|
|
|
|
to the next one if we're more than halfway through the one we're over.
|
|
|
|
*/
|
2011-12-11 08:42:18 -05:00
|
|
|
if (_editor->snap_mode() == SnapNormal && pf > g / 2) {
|
|
|
|
pf -= g / 2;
|
2011-12-11 07:54:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_note[0] = adjusted_frame (pf, event) - _region_view->region()->position ();
|
2014-12-07 20:36:32 -05:00
|
|
|
_note[1] = _note[0];
|
2011-12-11 07:54:54 -05:00
|
|
|
|
|
|
|
MidiStreamView* sv = _region_view->midi_stream_view ();
|
2013-04-12 11:15:45 -04:00
|
|
|
double const x = _editor->sample_to_pixel (_note[0]);
|
2011-12-11 07:54:54 -05:00
|
|
|
double const y = sv->note_to_y (sv->y_to_note (y_to_region (event->button.y)));
|
|
|
|
|
2013-04-04 18:45:27 -04:00
|
|
|
_drag_rect->set (ArdourCanvas::Rect (x, y, x, y + floor (_region_view->midi_stream_view()->note_height ())));
|
2014-03-11 07:39:25 -04:00
|
|
|
_drag_rect->set_outline_all ();
|
2013-04-04 18:45:27 -04:00
|
|
|
_drag_rect->set_outline_color (0xffffff99);
|
|
|
|
_drag_rect->set_fill_color (0xffffff66);
|
2011-12-11 07:54:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NoteCreateDrag::motion (GdkEvent* event, bool)
|
|
|
|
{
|
2012-01-30 20:59:39 -05:00
|
|
|
_note[1] = max ((framepos_t)0, adjusted_current_frame (event) - _region_view->region()->position ());
|
2014-11-14 00:33:05 -05:00
|
|
|
double const x0 = _editor->sample_to_pixel (_note[0]);
|
|
|
|
double const x1 = _editor->sample_to_pixel (_note[1]);
|
|
|
|
_drag_rect->set_x0 (std::min(x0, x1));
|
|
|
|
_drag_rect->set_x1 (std::max(x0, x1));
|
2011-12-11 07:54:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-02 16:29:46 -04:00
|
|
|
NoteCreateDrag::finished (GdkEvent*, bool had_movement)
|
2011-12-11 07:54:54 -05:00
|
|
|
{
|
2011-12-11 08:42:18 -05:00
|
|
|
if (!had_movement) {
|
2011-12-11 09:07:24 -05:00
|
|
|
return;
|
2011-12-11 07:54:54 -05:00
|
|
|
}
|
2011-12-11 08:42:18 -05:00
|
|
|
|
2011-12-11 07:54:54 -05:00
|
|
|
framepos_t const start = min (_note[0], _note[1]);
|
2013-10-03 04:06:56 -04:00
|
|
|
framecnt_t length = (framecnt_t) fabs ((double)(_note[0] - _note[1]));
|
2011-12-11 08:42:18 -05:00
|
|
|
|
|
|
|
framecnt_t const g = grid_frames (start);
|
2015-01-07 00:12:07 -05:00
|
|
|
Evoral::Beats const one_tick = Evoral::Beats::ticks(1);
|
2011-12-30 08:41:16 -05:00
|
|
|
|
2011-12-11 08:42:18 -05:00
|
|
|
if (_editor->snap_mode() == SnapNormal && length < g) {
|
2014-11-22 21:49:42 -05:00
|
|
|
length = g;
|
2011-12-11 08:42:18 -05:00
|
|
|
}
|
2011-12-11 09:07:24 -05:00
|
|
|
|
2015-01-07 00:12:07 -05:00
|
|
|
Evoral::Beats length_beats = max (
|
2014-11-22 21:49:42 -05:00
|
|
|
one_tick, _region_view->region_frames_to_region_beats (length) - one_tick);
|
2011-12-30 08:41:16 -05:00
|
|
|
|
2013-04-04 18:45:27 -04:00
|
|
|
_region_view->create_note_at (start, _drag_rect->y0(), length_beats, false);
|
2011-12-11 07:54:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
NoteCreateDrag::y_to_region (double y) const
|
|
|
|
{
|
|
|
|
double x = 0;
|
2013-04-04 18:45:27 -04:00
|
|
|
_region_view->get_canvas_group()->canvas_to_item (x, y);
|
2011-12-11 07:54:54 -05:00
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NoteCreateDrag::aborted (bool)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2012-05-09 19:04:18 -04:00
|
|
|
|
|
|
|
CrossfadeEdgeDrag::CrossfadeEdgeDrag (Editor* e, AudioRegionView* rv, ArdourCanvas::Item* i, bool start_yn)
|
|
|
|
: Drag (e, i)
|
|
|
|
, arv (rv)
|
|
|
|
, start (start_yn)
|
|
|
|
{
|
2012-12-13 11:42:05 -05:00
|
|
|
std::cout << ("CrossfadeEdgeDrag is DEPRECATED. See TrimDrag::preserve_fade_anchor") << endl;
|
2012-05-09 19:04:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEdgeDrag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
|
|
|
|
{
|
|
|
|
Drag::start_grab (event, cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEdgeDrag::motion (GdkEvent*, bool)
|
|
|
|
{
|
2012-05-09 22:50:59 -04:00
|
|
|
double distance;
|
2012-05-09 20:46:22 -04:00
|
|
|
double new_length;
|
|
|
|
framecnt_t len;
|
|
|
|
|
|
|
|
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
|
|
|
|
|
|
|
if (start) {
|
2012-05-09 22:50:59 -04:00
|
|
|
distance = _drags->current_pointer_x() - grab_x();
|
2012-05-09 20:46:22 -04:00
|
|
|
len = ar->fade_in()->back()->when;
|
|
|
|
} else {
|
2012-05-09 22:50:59 -04:00
|
|
|
distance = grab_x() - _drags->current_pointer_x();
|
2012-05-09 20:46:22 -04:00
|
|
|
len = ar->fade_out()->back()->when;
|
|
|
|
}
|
|
|
|
|
2012-05-10 08:14:26 -04:00
|
|
|
/* how long should it be ? */
|
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
new_length = len + _editor->pixel_to_sample (distance);
|
2012-05-10 08:14:26 -04:00
|
|
|
|
|
|
|
/* now check with the region that this is legal */
|
|
|
|
|
|
|
|
new_length = ar->verify_xfade_bounds (new_length, start);
|
|
|
|
|
2012-05-09 20:46:22 -04:00
|
|
|
if (start) {
|
2013-04-18 09:55:53 -04:00
|
|
|
arv->reset_fade_in_shape_width (ar, new_length);
|
2012-05-09 20:46:22 -04:00
|
|
|
} else {
|
2013-04-18 09:55:53 -04:00
|
|
|
arv->reset_fade_out_shape_width (ar, new_length);
|
2012-05-09 20:46:22 -04:00
|
|
|
}
|
2012-05-09 19:04:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEdgeDrag::finished (GdkEvent*, bool)
|
|
|
|
{
|
2012-05-09 22:50:59 -04:00
|
|
|
double distance;
|
2012-05-09 20:46:22 -04:00
|
|
|
double new_length;
|
|
|
|
framecnt_t len;
|
|
|
|
|
|
|
|
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
|
|
|
|
|
|
|
if (start) {
|
2012-05-09 22:50:59 -04:00
|
|
|
distance = _drags->current_pointer_x() - grab_x();
|
2012-05-09 20:46:22 -04:00
|
|
|
len = ar->fade_in()->back()->when;
|
|
|
|
} else {
|
2012-05-09 22:50:59 -04:00
|
|
|
distance = grab_x() - _drags->current_pointer_x();
|
2012-05-09 20:46:22 -04:00
|
|
|
len = ar->fade_out()->back()->when;
|
|
|
|
}
|
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
new_length = ar->verify_xfade_bounds (len + _editor->pixel_to_sample (distance), start);
|
2012-05-09 20:46:22 -04:00
|
|
|
|
2012-05-10 14:36:05 -04:00
|
|
|
_editor->begin_reversible_command ("xfade trim");
|
|
|
|
ar->playlist()->clear_owned_changes ();
|
|
|
|
|
2012-05-09 20:46:22 -04:00
|
|
|
if (start) {
|
|
|
|
ar->set_fade_in_length (new_length);
|
|
|
|
} else {
|
|
|
|
ar->set_fade_out_length (new_length);
|
|
|
|
}
|
2012-05-10 14:36:05 -04:00
|
|
|
|
|
|
|
/* Adjusting the xfade may affect other regions in the playlist, so we need
|
|
|
|
to get undo Commands from the whole playlist rather than just the
|
|
|
|
region.
|
|
|
|
*/
|
|
|
|
|
|
|
|
vector<Command*> cmds;
|
|
|
|
ar->playlist()->rdiff (cmds);
|
|
|
|
_editor->session()->add_commands (cmds);
|
2012-06-09 09:25:13 -04:00
|
|
|
_editor->commit_reversible_command ();
|
2012-05-10 14:36:05 -04:00
|
|
|
|
2012-05-09 19:04:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CrossfadeEdgeDrag::aborted (bool)
|
|
|
|
{
|
2012-05-09 20:46:22 -04:00
|
|
|
if (start) {
|
|
|
|
arv->redraw_start_xfade ();
|
|
|
|
} else {
|
|
|
|
arv->redraw_end_xfade ();
|
|
|
|
}
|
2012-05-09 19:04:18 -04:00
|
|
|
}
|
|
|
|
|
2014-07-07 10:13:19 -04:00
|
|
|
RegionCutDrag::RegionCutDrag (Editor* e, ArdourCanvas::Item* item, framepos_t pos)
|
2014-07-07 07:05:27 -04:00
|
|
|
: Drag (e, item, true)
|
2014-07-07 08:26:37 -04:00
|
|
|
, line (new EditorCursor (*e))
|
2014-07-07 07:05:27 -04:00
|
|
|
{
|
2014-07-07 10:13:19 -04:00
|
|
|
line->set_position (pos);
|
|
|
|
line->show ();
|
2014-07-07 08:26:37 -04:00
|
|
|
}
|
2014-07-07 07:05:27 -04:00
|
|
|
|
2014-07-07 08:26:37 -04:00
|
|
|
RegionCutDrag::~RegionCutDrag ()
|
|
|
|
{
|
|
|
|
delete line;
|
2014-07-07 07:05:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionCutDrag::motion (GdkEvent*, bool)
|
|
|
|
{
|
2014-07-08 16:08:31 -04:00
|
|
|
framepos_t where = _drags->current_pointer_frame();
|
|
|
|
_editor->snap_to (where);
|
|
|
|
|
|
|
|
line->set_position (where);
|
2014-07-07 07:05:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionCutDrag::finished (GdkEvent*, bool)
|
|
|
|
{
|
2014-07-08 21:37:49 -04:00
|
|
|
_editor->get_track_canvas()->canvas()->re_enter();
|
2014-07-07 10:21:47 -04:00
|
|
|
|
2014-07-08 21:37:49 -04:00
|
|
|
framepos_t pos = _drags->current_pointer_frame();
|
|
|
|
|
2014-07-07 08:26:37 -04:00
|
|
|
line->hide ();
|
2014-07-07 10:13:19 -04:00
|
|
|
|
2014-07-07 10:21:47 -04:00
|
|
|
RegionSelection rs = _editor->get_regions_from_selection_and_mouse (pos);
|
2014-07-07 10:13:19 -04:00
|
|
|
|
|
|
|
if (rs.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-07 10:21:47 -04:00
|
|
|
_editor->split_regions_at (pos, rs);
|
2014-07-07 07:05:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RegionCutDrag::aborted (bool)
|
|
|
|
{
|
|
|
|
}
|