2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2000-2001 Paul Davis
|
2005-09-25 14:42:24 -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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
#include <cassert>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <cmath>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <algorithm>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
2009-07-28 16:51:28 -04:00
|
|
|
#include "pbd/enumwriter.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/memento_command.h"
|
|
|
|
#include "pbd/basename.h"
|
2010-03-02 13:05:26 -05:00
|
|
|
#include "pbd/stateful_diff_command.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2011-03-03 22:10:48 -05:00
|
|
|
#include "gtkmm2ext/bindings.h"
|
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
#include "gtkmm2ext/tearoff.h"
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "ardour_ui.h"
|
2009-07-28 16:51:28 -04:00
|
|
|
#include "actions.h"
|
2010-09-21 11:15:06 -04:00
|
|
|
#include "canvas-note.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "editor.h"
|
|
|
|
#include "time_axis_view.h"
|
|
|
|
#include "audio_time_axis.h"
|
2006-08-01 13:19:38 -04:00
|
|
|
#include "audio_region_view.h"
|
2007-03-18 02:07:08 -04:00
|
|
|
#include "midi_region_view.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "marker.h"
|
|
|
|
#include "streamview.h"
|
|
|
|
#include "region_gain_line.h"
|
|
|
|
#include "automation_time_axis.h"
|
2007-07-06 23:19:04 -04:00
|
|
|
#include "control_point.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "prompter.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "selection.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "editing.h"
|
|
|
|
#include "rgb_macros.h"
|
2008-12-18 12:46:28 -05:00
|
|
|
#include "control_point_dialog.h"
|
2009-05-30 14:25:59 -04:00
|
|
|
#include "editor_drag.h"
|
2010-08-04 11:41:55 -04:00
|
|
|
#include "automation_region_view.h"
|
2010-08-13 22:00:50 -04:00
|
|
|
#include "edit_note_dialog.h"
|
2010-11-16 09:53:16 -05:00
|
|
|
#include "mouse_cursors.h"
|
|
|
|
#include "editor_cursors.h"
|
2011-05-02 09:38:16 -04:00
|
|
|
#include "verbose_cursor.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/types.h"
|
|
|
|
#include "ardour/profile.h"
|
|
|
|
#include "ardour/route.h"
|
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/audio_diskstream.h"
|
|
|
|
#include "ardour/midi_diskstream.h"
|
|
|
|
#include "ardour/playlist.h"
|
|
|
|
#include "ardour/audioplaylist.h"
|
|
|
|
#include "ardour/audioregion.h"
|
|
|
|
#include "ardour/midi_region.h"
|
|
|
|
#include "ardour/dB.h"
|
|
|
|
#include "ardour/utils.h"
|
|
|
|
#include "ardour/region_factory.h"
|
|
|
|
#include "ardour/source_factory.h"
|
2009-10-30 11:30:22 -04:00
|
|
|
#include "ardour/session.h"
|
2011-01-19 12:38:56 -05:00
|
|
|
#include "ardour/operations.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include <bitset>
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one)
Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now.
Relevant (significant) changes:
- Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)
- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)
- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output.
- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.
- MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here.
- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)
Known broken: Loading of sessions containing MIDI tracks.
git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Editing;
|
2009-12-04 17:51:32 -05:00
|
|
|
using Gtkmm2ext::Keyboard;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
bool
|
2010-09-17 14:20:37 -04:00
|
|
|
Editor::mouse_frame (framepos_t& where, bool& in_track_canvas) const
|
2007-11-07 20:40:25 -05:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
double wx, wy;
|
|
|
|
Gdk::ModifierType mask;
|
2008-03-17 16:54:03 -04:00
|
|
|
Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->track_canvas->get_window();
|
2007-11-07 20:40:25 -05:00
|
|
|
Glib::RefPtr<const Gdk::Window> pointer_window;
|
2008-04-11 10:06:50 -04:00
|
|
|
|
|
|
|
if (!canvas_window) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
pointer_window = canvas_window->get_pointer (x, y, mask);
|
|
|
|
|
2008-03-17 16:54:03 -04:00
|
|
|
if (pointer_window == track_canvas->get_bin_window()) {
|
2008-09-10 17:27:39 -04:00
|
|
|
wx = x;
|
|
|
|
wy = y;
|
2007-11-07 20:40:25 -05:00
|
|
|
in_track_canvas = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
in_track_canvas = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkEvent event;
|
|
|
|
event.type = GDK_BUTTON_RELEASE;
|
|
|
|
event.button.x = wx;
|
|
|
|
event.button.y = wy;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
where = event_frame (&event, 0, 0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t
|
2009-06-08 15:28:51 -04:00
|
|
|
Editor::event_frame (GdkEvent const * event, double* pcx, double* pcy) const
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
double cx, cy;
|
|
|
|
|
|
|
|
if (pcx == 0) {
|
|
|
|
pcx = &cx;
|
|
|
|
}
|
|
|
|
if (pcy == 0) {
|
|
|
|
pcy = &cy;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcx = 0;
|
|
|
|
*pcy = 0;
|
|
|
|
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
2008-09-10 17:27:39 -04:00
|
|
|
*pcx = event->button.x;
|
|
|
|
*pcy = event->button.y;
|
|
|
|
_trackview_group->w2i(*pcx, *pcy);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2008-09-10 17:27:39 -04:00
|
|
|
*pcx = event->motion.x;
|
|
|
|
*pcy = event->motion.y;
|
|
|
|
_trackview_group->w2i(*pcx, *pcy);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
2008-03-17 16:54:03 -04:00
|
|
|
track_canvas->w2c(event->crossing.x, event->crossing.y, *pcx, *pcy);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2006-01-28 08:33:54 -05:00
|
|
|
case GDK_KEY_PRESS:
|
|
|
|
case GDK_KEY_RELEASE:
|
2008-03-17 16:54:03 -04:00
|
|
|
// track_canvas->w2c(event->key.x, event->key.y, *pcx, *pcy);
|
2006-01-28 08:33:54 -05:00
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
2005-10-06 15:10:57 -04:00
|
|
|
warning << string_compose (_("Editor::event_frame() used on unhandled event type %1"), event->type) << endmsg;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* note that pixel_to_frame() never returns less than zero, so even if the pixel
|
|
|
|
position is negative (as can be the case with motion events in particular),
|
|
|
|
the frame location is always positive.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return pixel_to_frame (*pcx);
|
|
|
|
}
|
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
Gdk::Cursor*
|
|
|
|
Editor::which_grabber_cursor ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-11-16 09:53:16 -05:00
|
|
|
Gdk::Cursor* c = _cursors->grabber;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
if (_internal_editing) {
|
|
|
|
switch (mouse_mode) {
|
2009-08-28 12:06:08 -04:00
|
|
|
case MouseRange:
|
2010-11-16 09:53:16 -05:00
|
|
|
c = _cursors->midi_pencil;
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-28 12:06:08 -04:00
|
|
|
case MouseObject:
|
2010-11-16 09:53:16 -05:00
|
|
|
c = _cursors->grabber_note;
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
case MouseTimeFX:
|
2010-11-16 09:53:16 -05:00
|
|
|
c = _cursors->midi_resize;
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
} else {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
switch (_edit_point) {
|
|
|
|
case EditAtMouse:
|
2010-11-16 09:53:16 -05:00
|
|
|
c = _cursors->grabber_edit_point;
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
|
|
|
default:
|
2010-11-25 15:37:39 -05:00
|
|
|
boost::shared_ptr<Movable> m = _movable.lock();
|
|
|
|
if (m && m->locked()) {
|
|
|
|
c = _cursors->speaker;
|
|
|
|
}
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-07-28 16:51:28 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
return c;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-09-22 11:21:06 -04:00
|
|
|
void
|
|
|
|
Editor::set_current_trimmable (boost::shared_ptr<Trimmable> t)
|
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
boost::shared_ptr<Trimmable> st = _trimmable.lock();
|
2010-09-22 11:21:06 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!st || st == t) {
|
|
|
|
_trimmable = t;
|
|
|
|
set_canvas_cursor ();
|
|
|
|
}
|
2010-09-22 11:21:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_current_movable (boost::shared_ptr<Movable> m)
|
|
|
|
{
|
2010-11-25 15:37:39 -05:00
|
|
|
boost::shared_ptr<Movable> sm = _movable.lock();
|
2010-09-22 11:21:06 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!sm || sm != m) {
|
|
|
|
_movable = m;
|
|
|
|
set_canvas_cursor ();
|
|
|
|
}
|
2010-09-22 11:21:06 -04:00
|
|
|
}
|
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
void
|
|
|
|
Editor::set_canvas_cursor ()
|
|
|
|
{
|
|
|
|
if (_internal_editing) {
|
|
|
|
|
|
|
|
switch (mouse_mode) {
|
2009-08-28 12:06:08 -04:00
|
|
|
case MouseRange:
|
2010-11-16 09:53:16 -05:00
|
|
|
current_canvas_cursor = _cursors->midi_pencil;
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-28 12:06:08 -04:00
|
|
|
case MouseObject:
|
|
|
|
current_canvas_cursor = which_grabber_cursor();
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
case MouseTimeFX:
|
2010-11-16 09:53:16 -05:00
|
|
|
current_canvas_cursor = _cursors->midi_resize;
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
2007-07-14 21:56:11 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
} else {
|
|
|
|
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseRange:
|
2010-11-16 09:53:16 -05:00
|
|
|
current_canvas_cursor = _cursors->selector;
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
case MouseObject:
|
|
|
|
current_canvas_cursor = which_grabber_cursor();
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
case MouseGain:
|
2010-11-16 09:53:16 -05:00
|
|
|
current_canvas_cursor = _cursors->cross_hair;
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
case MouseZoom:
|
2010-11-06 22:35:00 -04:00
|
|
|
if (Keyboard::the_keyboard().key_is_down (GDK_Control_L)) {
|
2010-11-16 09:53:16 -05:00
|
|
|
current_canvas_cursor = _cursors->zoom_out;
|
2010-11-06 22:35:00 -04:00
|
|
|
} else {
|
2010-11-16 09:53:16 -05:00
|
|
|
current_canvas_cursor = _cursors->zoom_in;
|
2010-11-06 22:35:00 -04:00
|
|
|
}
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
case MouseTimeFX:
|
2010-11-16 09:53:16 -05:00
|
|
|
current_canvas_cursor = _cursors->time_fx; // just use playhead
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
case MouseAudition:
|
2010-11-16 09:53:16 -05:00
|
|
|
current_canvas_cursor = _cursors->speaker;
|
2009-07-28 16:51:28 -04:00
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
switch (_join_object_range_state) {
|
|
|
|
case JOIN_OBJECT_RANGE_NONE:
|
|
|
|
break;
|
|
|
|
case JOIN_OBJECT_RANGE_OBJECT:
|
|
|
|
current_canvas_cursor = which_grabber_cursor ();
|
|
|
|
break;
|
|
|
|
case JOIN_OBJECT_RANGE_RANGE:
|
2010-11-16 09:53:16 -05:00
|
|
|
current_canvas_cursor = _cursors->selector;
|
2010-01-01 17:11:15 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-08-18 14:06:31 -04:00
|
|
|
/* up-down cursor as a cue that automation can be dragged up and down when in join object/range mode */
|
|
|
|
if (join_object_range_button.get_active() && last_item_entered) {
|
|
|
|
if (last_item_entered->property_parent() && (*last_item_entered->property_parent()).get_data (X_("timeselection"))) {
|
|
|
|
pair<TimeAxisView*, int> tvp = trackview_by_y_position (_last_motion_y + vertical_adjustment.get_value() - canvas_timebars_vsize);
|
|
|
|
if (dynamic_cast<AutomationTimeAxisView*> (tvp.first)) {
|
2010-11-16 09:53:16 -05:00
|
|
|
current_canvas_cursor = _cursors->up_down;
|
2010-08-18 14:06:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
set_canvas_cursor (current_canvas_cursor, true);
|
2008-02-16 17:43:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-28 16:51:28 -04:00
|
|
|
Editor::set_mouse_mode (MouseMode m, bool force)
|
2008-02-16 17:43:18 -05:00
|
|
|
{
|
2010-01-12 11:14:49 -05:00
|
|
|
if (_drags->active ()) {
|
2009-07-28 16:51:28 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!force && m == mouse_mode) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Glib::RefPtr<Action> act;
|
|
|
|
|
|
|
|
switch (m) {
|
2008-02-16 17:43:18 -05:00
|
|
|
case MouseRange:
|
2009-07-28 16:51:28 -04:00
|
|
|
act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-range"));
|
2008-02-16 17:43:18 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseObject:
|
2009-07-28 16:51:28 -04:00
|
|
|
act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-object"));
|
2008-02-16 17:43:18 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseGain:
|
2009-07-28 16:51:28 -04:00
|
|
|
act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-gain"));
|
2008-02-16 17:43:18 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseZoom:
|
2009-07-28 16:51:28 -04:00
|
|
|
act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-zoom"));
|
2008-02-16 17:43:18 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseTimeFX:
|
2009-07-28 16:51:28 -04:00
|
|
|
act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-timefx"));
|
2008-02-16 17:43:18 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseAudition:
|
2009-07-28 16:51:28 -04:00
|
|
|
act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-audition"));
|
2008-02-16 17:43:18 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
assert (act);
|
|
|
|
|
|
|
|
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
|
|
|
|
assert (tact);
|
2009-08-04 14:19:40 -04:00
|
|
|
|
|
|
|
/* go there and back to ensure that the toggled handler is called to set up mouse_mode */
|
|
|
|
tact->set_active (false);
|
2009-07-28 16:51:28 -04:00
|
|
|
tact->set_active (true);
|
2010-11-21 18:54:57 -05:00
|
|
|
|
|
|
|
MouseModeChanged (); /* EMIT SIGNAL */
|
2008-02-16 17:43:18 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2009-07-28 16:51:28 -04:00
|
|
|
Editor::mouse_mode_toggled (MouseMode m)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
mouse_mode = m;
|
|
|
|
|
|
|
|
instant_save ();
|
2010-05-24 21:13:45 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!internal_editing()) {
|
|
|
|
if (mouse_mode != MouseRange && _join_object_range_state == JOIN_OBJECT_RANGE_NONE) {
|
2010-05-24 21:13:45 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
/* in all modes except range and joined object/range, hide the range selection,
|
|
|
|
show the object (region) selection.
|
|
|
|
*/
|
2010-05-24 21:13:45 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
(*i)->hide_selection ();
|
|
|
|
}
|
2010-05-24 21:13:45 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
} else {
|
2010-05-24 21:13:45 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
/*
|
|
|
|
in range or object/range mode, show the range selection.
|
|
|
|
*/
|
2010-05-24 21:13:45 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
(*i)->show_selection (selection->time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
set_canvas_cursor ();
|
2010-11-21 18:54:57 -05:00
|
|
|
|
|
|
|
MouseModeChanged (); /* EMIT SIGNAL */
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::step_mouse_mode (bool next)
|
|
|
|
{
|
|
|
|
switch (current_mouse_mode()) {
|
|
|
|
case MouseObject:
|
2008-12-12 09:43:24 -05:00
|
|
|
if (next) {
|
|
|
|
if (Profile->get_sae()) {
|
|
|
|
set_mouse_mode (MouseZoom);
|
|
|
|
} else {
|
|
|
|
set_mouse_mode (MouseRange);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
set_mouse_mode (MouseTimeFX);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
if (next) set_mouse_mode (MouseZoom);
|
|
|
|
else set_mouse_mode (MouseObject);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseZoom:
|
2008-12-12 09:43:24 -05:00
|
|
|
if (next) {
|
|
|
|
if (Profile->get_sae()) {
|
|
|
|
set_mouse_mode (MouseTimeFX);
|
|
|
|
} else {
|
|
|
|
set_mouse_mode (MouseGain);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (Profile->get_sae()) {
|
|
|
|
set_mouse_mode (MouseObject);
|
|
|
|
} else {
|
|
|
|
set_mouse_mode (MouseRange);
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MouseGain:
|
|
|
|
if (next) set_mouse_mode (MouseTimeFX);
|
|
|
|
else set_mouse_mode (MouseZoom);
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MouseTimeFX:
|
2008-12-12 09:43:24 -05:00
|
|
|
if (next) {
|
|
|
|
set_mouse_mode (MouseAudition);
|
|
|
|
} else {
|
|
|
|
if (Profile->get_sae()) {
|
|
|
|
set_mouse_mode (MouseZoom);
|
|
|
|
} else {
|
|
|
|
set_mouse_mode (MouseGain);
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseAudition:
|
|
|
|
if (next) set_mouse_mode (MouseObject);
|
|
|
|
else set_mouse_mode (MouseTimeFX);
|
|
|
|
break;
|
2007-08-10 16:55:27 -04:00
|
|
|
}
|
2007-08-08 15:13:36 -04:00
|
|
|
}
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemType item_type)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2008-12-12 09:43:24 -05:00
|
|
|
/* in object/audition/timefx/gain-automation mode,
|
|
|
|
any button press sets the selection if the object
|
|
|
|
can be selected. this is a bit of hack, because
|
|
|
|
we want to avoid this if the mouse operation is a
|
|
|
|
region alignment.
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
note: not dbl-click or triple-click
|
2010-07-08 20:57:22 -04:00
|
|
|
|
|
|
|
Also note that there is no region selection in internal edit mode, otherwise
|
|
|
|
for operations operating on the selection (e.g. cut) it is not obvious whether
|
|
|
|
to cut notes or regions.
|
2006-06-13 03:27:52 -04:00
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
if (((mouse_mode != MouseObject) &&
|
2010-01-01 17:11:15 -05:00
|
|
|
(_join_object_range_state != JOIN_OBJECT_RANGE_OBJECT) &&
|
2006-06-13 03:27:52 -04:00
|
|
|
(mouse_mode != MouseAudition || item_type != RegionItem) &&
|
2007-03-18 02:07:08 -04:00
|
|
|
(mouse_mode != MouseTimeFX || item_type != RegionItem) &&
|
2008-12-12 09:43:24 -05:00
|
|
|
(mouse_mode != MouseGain) &&
|
2007-03-18 02:07:08 -04:00
|
|
|
(mouse_mode != MouseRange)) ||
|
2010-07-08 20:57:22 -04:00
|
|
|
((event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE) || event->button.button > 3) ||
|
|
|
|
internal_editing()) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
return;
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
if (event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) {
|
|
|
|
|
|
|
|
if ((event->button.state & Keyboard::RelevantModifierKeyMask) && event->button.button != 1) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
/* almost no selection action on modified button-2 or button-3 events */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
if (item_type != RegionItem && event->button.button != 2) {
|
|
|
|
return;
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2009-12-04 17:51:32 -05:00
|
|
|
Selection::Operation op = ArdourKeyboard::selection_type (event->button.state);
|
2006-06-13 03:27:52 -04:00
|
|
|
bool press = (event->type == GDK_BUTTON_PRESS);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
2010-07-08 20:57:22 -04:00
|
|
|
if (mouse_mode != MouseRange || _join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) {
|
2008-01-10 16:20:59 -05:00
|
|
|
set_selected_regionview_from_click (press, op, true);
|
2007-10-11 18:07:47 -04:00
|
|
|
} else if (event->type == GDK_BUTTON_PRESS) {
|
2010-01-01 17:11:15 -05:00
|
|
|
selection->clear_tracks ();
|
2010-08-26 19:25:44 -04:00
|
|
|
set_selected_track_as_side_effect (op, true);
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
if (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT && !selection->regions.empty()) {
|
2010-01-12 11:14:49 -05:00
|
|
|
clicked_selection = select_range_around_region (selection->regions.front());
|
2007-10-11 18:07:47 -04:00
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-10-11 18:07:47 -04:00
|
|
|
case RegionViewNameHighlight:
|
|
|
|
case RegionViewName:
|
2010-11-25 15:37:39 -05:00
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
2010-07-08 20:57:22 -04:00
|
|
|
if (mouse_mode != MouseRange || _join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) {
|
2008-01-10 16:20:59 -05:00
|
|
|
set_selected_regionview_from_click (press, op, true);
|
2007-10-11 18:07:47 -04:00
|
|
|
} else if (event->type == GDK_BUTTON_PRESS) {
|
2010-08-26 19:25:44 -04:00
|
|
|
set_selected_track_as_side_effect (op);
|
2007-10-11 18:07:47 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
case FadeInHandleItem:
|
|
|
|
case FadeInItem:
|
|
|
|
case FadeOutHandleItem:
|
|
|
|
case FadeOutItem:
|
2010-01-01 17:11:15 -05:00
|
|
|
if (mouse_mode != MouseRange || _join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) {
|
2008-01-10 16:20:59 -05:00
|
|
|
set_selected_regionview_from_click (press, op, true);
|
2007-03-18 02:07:08 -04:00
|
|
|
} else if (event->type == GDK_BUTTON_PRESS) {
|
2010-08-26 19:25:44 -04:00
|
|
|
set_selected_track_as_side_effect (op);
|
2007-03-18 02:07:08 -04:00
|
|
|
}
|
2006-06-13 03:27:52 -04:00
|
|
|
break;
|
2007-05-10 07:53:35 -04:00
|
|
|
|
2007-06-30 14:41:50 -04:00
|
|
|
case ControlPointItem:
|
2010-08-26 19:25:44 -04:00
|
|
|
set_selected_track_as_side_effect (op, true);
|
2010-01-01 17:11:15 -05:00
|
|
|
if (mouse_mode != MouseRange || _join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) {
|
2008-01-10 16:20:59 -05:00
|
|
|
set_selected_control_point_from_click (op, false);
|
2007-03-18 02:07:08 -04:00
|
|
|
}
|
2006-06-13 03:27:52 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
case StreamItem:
|
2009-12-13 16:27:19 -05:00
|
|
|
/* for context click, select track */
|
2007-03-18 02:07:08 -04:00
|
|
|
if (event->button.button == 3) {
|
2010-04-22 22:06:07 -04:00
|
|
|
selection->clear_tracks ();
|
2010-08-26 19:25:44 -04:00
|
|
|
set_selected_track_as_side_effect (op, true);
|
2007-03-18 02:07:08 -04:00
|
|
|
}
|
2006-06-13 03:27:52 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
case AutomationTrackItem:
|
2010-08-26 19:25:44 -04:00
|
|
|
set_selected_track_as_side_effect (op, true);
|
2006-06-13 03:27:52 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-06-13 03:27:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2009-08-04 14:21:09 -04:00
|
|
|
Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
2006-06-13 03:27:52 -04:00
|
|
|
{
|
2009-08-04 14:21:09 -04:00
|
|
|
/* single mouse clicks on any of these item types operate
|
|
|
|
independent of mouse mode, mostly because they are
|
|
|
|
not on the main track canvas or because we want
|
|
|
|
them to be modeless.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case PlayheadCursorItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new CursorDrag (this, item, true), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case MarkerItem:
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
|
|
|
|
hide_marker (item, event);
|
2008-09-10 11:03:30 -04:00
|
|
|
} else {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new MarkerDrag (this, item), event);
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
2006-06-13 03:27:52 -04:00
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case TempoMarkerItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (
|
|
|
|
new TempoMarkerDrag (
|
|
|
|
this,
|
|
|
|
item,
|
|
|
|
Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier)
|
|
|
|
),
|
|
|
|
event
|
2009-08-04 14:21:09 -04:00
|
|
|
);
|
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case MeterMarkerItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (
|
|
|
|
new MeterMarkerDrag (
|
|
|
|
this,
|
|
|
|
item,
|
|
|
|
Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier)
|
|
|
|
),
|
|
|
|
event
|
2009-08-04 14:21:09 -04:00
|
|
|
);
|
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case MarkerBarItem:
|
|
|
|
case TempoBarItem:
|
|
|
|
case MeterBarItem:
|
|
|
|
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new CursorDrag (this, &playhead_cursor->canvas_item, false), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
break;
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case RangeMarkerBarItem:
|
|
|
|
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new CursorDrag (this, &playhead_cursor->canvas_item, false), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
} else {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateRangeMarker), event);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case CdMarkerBarItem:
|
|
|
|
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new CursorDrag (this, &playhead_cursor->canvas_item, false), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
} else {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateCDMarker), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case TransportMarkerBarItem:
|
|
|
|
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new CursorDrag (this, &playhead_cursor->canvas_item, false), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
} else {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateTransportMarker), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-01 20:19:47 -05:00
|
|
|
if (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) {
|
|
|
|
/* special case: allow trim of range selections in joined object mode;
|
|
|
|
in theory eff should equal MouseRange in this case, but it doesn't
|
|
|
|
because entering the range selection canvas item results in entered_regionview
|
|
|
|
being set to 0, so update_join_object_range_location acts as if we aren't
|
|
|
|
over a region.
|
|
|
|
*/
|
2010-01-01 20:36:19 -05:00
|
|
|
if (item_type == StartSelectionTrimItem) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionStartTrim), event);
|
2010-01-01 20:36:19 -05:00
|
|
|
} else if (item_type == EndSelectionTrimItem) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionEndTrim), event);
|
2010-01-01 20:19:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
Editing::MouseMode eff = effective_mouse_mode ();
|
|
|
|
|
2010-01-24 21:24:44 -05:00
|
|
|
/* special case: allow drag of region fade in/out in object mode with join object/range enabled */
|
|
|
|
if (item_type == FadeInHandleItem || item_type == FadeOutHandleItem) {
|
|
|
|
eff = MouseObject;
|
|
|
|
}
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
switch (eff) {
|
2009-11-18 08:24:43 -05:00
|
|
|
case MouseRange:
|
2009-08-28 12:06:08 -04:00
|
|
|
switch (item_type) {
|
2009-11-18 08:24:43 -05:00
|
|
|
case StartSelectionTrimItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionStartTrim), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EndSelectionTrimItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionEndTrim), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionItem:
|
|
|
|
if (Keyboard::modifier_state_contains
|
2010-03-16 16:16:13 -04:00
|
|
|
(event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier))) {
|
2009-11-18 08:24:43 -05:00
|
|
|
// contains and not equals because I can't use alt as a modifier alone.
|
|
|
|
start_selection_grab (item, event);
|
2010-03-16 16:16:13 -04:00
|
|
|
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::SecondaryModifier)) {
|
2009-11-18 08:24:43 -05:00
|
|
|
/* grab selection for moving */
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionMove), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
} else {
|
2010-01-01 17:11:15 -05:00
|
|
|
double const y = event->button.y + vertical_adjustment.get_value() - canvas_timebars_vsize;
|
|
|
|
pair<TimeAxisView*, int> tvp = trackview_by_y_position (y);
|
|
|
|
if (tvp.first) {
|
|
|
|
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (tvp.first);
|
|
|
|
if (join_object_range_button.get_active() && atv) {
|
|
|
|
/* smart "join" mode: drag automation */
|
2010-11-16 09:53:16 -05:00
|
|
|
_drags->set (new AutomationRangeDrag (this, atv->base_item(), selection->time), event, _cursors->up_down);
|
2010-01-01 17:11:15 -05:00
|
|
|
} else {
|
|
|
|
/* this was debated, but decided the more common action was to
|
|
|
|
make a new selection */
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event);
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
}
|
2009-09-08 17:45:44 -04:00
|
|
|
}
|
|
|
|
break;
|
2009-11-18 08:24:43 -05:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
case NoteItem:
|
|
|
|
if (internal_editing()) {
|
|
|
|
/* trim notes if we're in internal edit mode and near the ends of the note */
|
|
|
|
ArdourCanvas::CanvasNote* cn = dynamic_cast<ArdourCanvas::CanvasNote*> (item);
|
2011-05-11 07:55:36 -04:00
|
|
|
if (cn && cn->big_enough_to_trim() && cn->mouse_near_ends()) {
|
2010-11-25 15:37:39 -05:00
|
|
|
_drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor);
|
|
|
|
} else {
|
|
|
|
_drags->set (new NoteDrag (this, item), event);
|
|
|
|
}
|
|
|
|
}
|
2010-06-17 11:06:30 -04:00
|
|
|
return true;
|
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
case StreamItem:
|
|
|
|
if (internal_editing()) {
|
2010-08-20 08:01:13 -04:00
|
|
|
if (dynamic_cast<MidiTimeAxisView*> (clicked_axisview)) {
|
|
|
|
_drags->set (new RegionCreateDrag (this, item, clicked_axisview), event);
|
|
|
|
return true;
|
|
|
|
}
|
2010-11-25 15:37:39 -05:00
|
|
|
} else {
|
2010-06-21 21:28:49 -04:00
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event);
|
|
|
|
return true;
|
|
|
|
}
|
2010-11-25 15:37:39 -05:00
|
|
|
break;
|
2010-05-29 07:28:27 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
case RegionViewNameHighlight:
|
2011-02-09 09:02:49 -05:00
|
|
|
if (!clicked_regionview->region()->locked()) {
|
|
|
|
RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
|
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
2011-02-09 09:02:49 -05:00
|
|
|
if (!internal_editing() && !clicked_regionview->region()->locked()) {
|
2010-11-25 15:37:39 -05:00
|
|
|
RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
|
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2010-05-30 16:13:29 -04:00
|
|
|
|
2009-08-28 12:06:08 -04:00
|
|
|
default:
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!internal_editing()) {
|
|
|
|
_drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event);
|
|
|
|
}
|
2009-08-28 12:06:08 -04:00
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case MouseObject:
|
|
|
|
switch (item_type) {
|
|
|
|
case NoteItem:
|
|
|
|
if (internal_editing()) {
|
2010-12-07 09:45:24 -05:00
|
|
|
ArdourCanvas::CanvasNoteEvent* cn = dynamic_cast<ArdourCanvas::CanvasNoteEvent*> (item);
|
2010-11-25 15:37:39 -05:00
|
|
|
if (cn->mouse_near_ends()) {
|
|
|
|
_drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor);
|
|
|
|
} else {
|
|
|
|
_drags->set (new NoteDrag (this, item), event);
|
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier|Keyboard::SecondaryModifier)) &&
|
|
|
|
event->type == GDK_BUTTON_PRESS) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RubberbandSelectDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
|
|
|
|
} else if (event->type == GDK_BUTTON_PRESS) {
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case FadeInHandleItem:
|
|
|
|
{
|
2010-03-01 19:00:00 -05:00
|
|
|
RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
|
2010-11-16 09:53:16 -05:00
|
|
|
_drags->set (new FadeInDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), s), event, _cursors->fade_in);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2009-08-04 14:21:09 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case FadeOutHandleItem:
|
|
|
|
{
|
2010-03-01 19:00:00 -05:00
|
|
|
RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
|
2010-11-16 09:53:16 -05:00
|
|
|
_drags->set (new FadeOutDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), s), event, _cursors->fade_out);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-07-06 07:33:27 -04:00
|
|
|
case FeatureLineItem:
|
|
|
|
{
|
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) {
|
|
|
|
remove_transient(item);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_drags->set (new FeatureLineDrag (this, item), event);
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case RegionItem:
|
2010-08-04 11:41:55 -04:00
|
|
|
if (dynamic_cast<AutomationRegionView*> (clicked_regionview)) {
|
|
|
|
/* click on an automation region view; do nothing here and let the ARV's signal handler
|
|
|
|
sort it out.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
2010-09-18 16:22:03 -04:00
|
|
|
|
|
|
|
if (internal_editing ()) {
|
|
|
|
/* no region drags in internal edit mode */
|
|
|
|
break;
|
|
|
|
}
|
2010-08-04 11:41:55 -04:00
|
|
|
|
|
|
|
/* click on a normal region view */
|
2009-11-18 08:24:43 -05:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier)) {
|
2010-01-12 11:14:49 -05:00
|
|
|
add_region_copy_drag (item, event, clicked_regionview);
|
2011-03-02 12:00:54 -05:00
|
|
|
} else if (Keyboard::the_keyboard().key_is_down (GDK_b)) {
|
2010-01-12 11:14:49 -05:00
|
|
|
add_region_brush_drag (item, event, clicked_regionview);
|
2009-11-18 08:24:43 -05:00
|
|
|
} else {
|
2010-01-12 11:14:49 -05:00
|
|
|
add_region_drag (item, event, clicked_regionview);
|
2009-11-18 08:24:43 -05:00
|
|
|
}
|
2010-08-04 11:41:55 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT && !selection->regions.empty()) {
|
|
|
|
_drags->add (new SelectionDrag (this, clicked_axisview->get_selection_rect (clicked_selection)->rect, SelectionDrag::SelectionMove));
|
|
|
|
}
|
|
|
|
|
|
|
|
_drags->start_grab (event);
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case RegionViewNameHighlight:
|
2010-06-17 08:45:51 -04:00
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
2011-02-09 09:02:49 -05:00
|
|
|
if (!clicked_regionview->region()->locked()) {
|
2010-07-21 22:12:28 -04:00
|
|
|
RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
|
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event);
|
|
|
|
return true;
|
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case RegionViewName:
|
|
|
|
{
|
|
|
|
/* rename happens on edit clicks */
|
2010-03-01 19:00:00 -05:00
|
|
|
RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new TrimDrag (this, clicked_regionview->get_name_highlight(), clicked_regionview, s.by_layer()), event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case ControlPointItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new ControlPointDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case AutomationLineItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new LineDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case StreamItem:
|
|
|
|
if (internal_editing()) {
|
2010-08-20 08:01:13 -04:00
|
|
|
if (dynamic_cast<MidiTimeAxisView*> (clicked_axisview)) {
|
|
|
|
_drags->set (new RegionCreateDrag (this, item, clicked_axisview), event);
|
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2010-01-01 17:11:15 -05:00
|
|
|
} else {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RubberbandSelectDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
break;
|
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case AutomationTrackItem:
|
2010-01-01 20:19:47 -05:00
|
|
|
/* rubberband drag to select automation points */
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RubberbandSelectDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
case SelectionItem:
|
|
|
|
{
|
|
|
|
if (join_object_range_button.get_active()) {
|
2010-01-12 11:14:49 -05:00
|
|
|
/* we're in "smart" joined mode, and we've clicked on a Selection */
|
2010-01-01 17:11:15 -05:00
|
|
|
double const y = event->button.y + vertical_adjustment.get_value() - canvas_timebars_vsize;
|
|
|
|
pair<TimeAxisView*, int> tvp = trackview_by_y_position (y);
|
|
|
|
if (tvp.first) {
|
2010-01-12 11:14:49 -05:00
|
|
|
/* if we're over an automation track, start a drag of its data */
|
2010-01-01 17:11:15 -05:00
|
|
|
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (tvp.first);
|
|
|
|
if (atv) {
|
2010-11-16 09:53:16 -05:00
|
|
|
_drags->set (new AutomationRangeDrag (this, atv->base_item(), selection->time), event, _cursors->up_down);
|
2010-01-12 11:14:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if we're over a track and a region, and in the `object' part of a region,
|
|
|
|
put a selection around the region and drag both
|
|
|
|
*/
|
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tvp.first);
|
|
|
|
if (rtv && _join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) {
|
|
|
|
boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (rtv->route ());
|
|
|
|
if (t) {
|
2010-04-21 16:42:22 -04:00
|
|
|
boost::shared_ptr<Playlist> pl = t->playlist ();
|
2010-01-12 11:14:49 -05:00
|
|
|
if (pl) {
|
2010-01-15 20:08:15 -05:00
|
|
|
|
|
|
|
boost::shared_ptr<Region> r = pl->top_region_at (event_frame (event));
|
2010-01-12 18:50:57 -05:00
|
|
|
if (r) {
|
|
|
|
RegionView* rv = rtv->view()->find_view (r);
|
|
|
|
clicked_selection = select_range_around_region (rv);
|
|
|
|
_drags->add (new SelectionDrag (this, item, SelectionDrag::SelectionMove));
|
|
|
|
list<RegionView*> rvs;
|
|
|
|
rvs.push_back (rv);
|
|
|
|
_drags->add (new RegionMoveDrag (this, item, rv, rvs, false, false));
|
|
|
|
_drags->start_grab (event);
|
|
|
|
}
|
2010-01-12 11:14:49 -05:00
|
|
|
}
|
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
#ifdef WITH_CMT
|
|
|
|
case ImageFrameHandleStartItem:
|
|
|
|
imageframe_start_handle_op(item, event) ;
|
|
|
|
return(true) ;
|
|
|
|
break ;
|
|
|
|
case ImageFrameHandleEndItem:
|
|
|
|
imageframe_end_handle_op(item, event) ;
|
|
|
|
return(true) ;
|
|
|
|
break ;
|
|
|
|
case MarkerViewHandleStartItem:
|
|
|
|
markerview_item_start_handle_op(item, event) ;
|
|
|
|
return(true) ;
|
|
|
|
break ;
|
|
|
|
case MarkerViewHandleEndItem:
|
|
|
|
markerview_item_end_handle_op(item, event) ;
|
|
|
|
return(true) ;
|
|
|
|
break ;
|
|
|
|
case MarkerViewItem:
|
|
|
|
start_markerview_grab(item, event) ;
|
|
|
|
break ;
|
|
|
|
case ImageFrameItem:
|
|
|
|
start_imageframe_grab(item, event) ;
|
|
|
|
break ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case MarkerBarItem:
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseGain:
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
|
|
|
/* start a grab so that if we finish after moving
|
|
|
|
we can tell what happened.
|
|
|
|
*/
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RegionGainDrag (this, item), event, current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case GainLineItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new LineDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
case ControlPointItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new ControlPointDrag (this, item), event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
default:
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-11-18 08:24:43 -05:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-18 08:24:43 -05:00
|
|
|
switch (item_type) {
|
|
|
|
case ControlPointItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new ControlPointDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AutomationLineItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new LineDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RegionItem:
|
|
|
|
// XXX need automation mode to identify which
|
|
|
|
// line to use
|
|
|
|
// start_line_grab_from_regionview (item, event);
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseZoom:
|
|
|
|
if (event->type == GDK_BUTTON_PRESS) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new MouseZoomDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseTimeFX:
|
|
|
|
if (internal_editing() && item_type == NoteItem) {
|
2010-04-28 19:16:07 -04:00
|
|
|
/* drag notes if we're in internal edit mode */
|
2010-09-22 11:21:06 -04:00
|
|
|
_drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
2010-05-17 15:28:34 -04:00
|
|
|
} else if ((!internal_editing() || dynamic_cast<AudioRegionView*> (clicked_regionview)) && clicked_regionview) {
|
2010-04-28 19:16:07 -04:00
|
|
|
/* do time-FX if we're not in internal edit mode, or we are but we clicked on an audio region */
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new TimeFXDrag (this, item, clicked_regionview, selection->regions.by_layer()), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseAudition:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new ScrubDrag (this, item), event);
|
2009-11-18 08:24:43 -05:00
|
|
|
scrub_reversals = 0;
|
|
|
|
scrub_reverse_distance = 0;
|
|
|
|
last_scrub_x = event->button.x;
|
|
|
|
scrubbing_direction = 0;
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->transparent);
|
2009-11-18 08:24:43 -05:00
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2009-08-04 14:21:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Editor::button_press_handler_2 (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
|
|
|
{
|
2010-01-01 17:11:15 -05:00
|
|
|
Editing::MouseMode const eff = effective_mouse_mode ();
|
|
|
|
switch (eff) {
|
2009-08-04 14:21:09 -04:00
|
|
|
case MouseObject:
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
2011-03-24 07:48:12 -04:00
|
|
|
if (internal_editing ()) {
|
|
|
|
/* no region drags in internal edit mode */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier)) {
|
2010-01-12 11:14:49 -05:00
|
|
|
add_region_copy_drag (item, event, clicked_regionview);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2010-01-12 11:14:49 -05:00
|
|
|
add_region_drag (item, event, clicked_regionview);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->start_grab (event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-08-04 14:21:09 -04:00
|
|
|
case ControlPointItem:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new ControlPointDrag (this, item), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case RegionViewNameHighlight:
|
2011-02-09 09:02:49 -05:00
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer()), event);
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
|
2010-06-17 08:45:51 -04:00
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
2010-07-21 22:12:28 -04:00
|
|
|
if (!internal_editing ()) {
|
|
|
|
_drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer()), event);
|
|
|
|
}
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case RegionViewName:
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new TrimDrag (this, clicked_regionview->get_name_highlight(), clicked_regionview, selection->regions.by_layer()), event);
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
/* relax till release */
|
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
case MouseZoom:
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
2011-02-17 13:53:31 -05:00
|
|
|
temporal_zoom_to_frame (false, event_frame (event));
|
2009-08-04 14:21:09 -04:00
|
|
|
} else {
|
|
|
|
temporal_zoom_to_frame (true, event_frame(event));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
|
|
|
{
|
|
|
|
if (event->type != GDK_BUTTON_PRESS) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->track_canvas->get_window();
|
|
|
|
|
|
|
|
if (canvas_window) {
|
|
|
|
Glib::RefPtr<const Gdk::Window> pointer_window;
|
|
|
|
int x, y;
|
|
|
|
double wx, wy;
|
|
|
|
Gdk::ModifierType mask;
|
|
|
|
|
|
|
|
pointer_window = canvas_window->get_pointer (x, y, mask);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
if (pointer_window == track_canvas->get_bin_window()) {
|
|
|
|
track_canvas->window_to_world (x, y, wx, wy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-22 11:21:06 -04:00
|
|
|
pre_press_cursor = current_canvas_cursor;
|
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
track_canvas->grab_focus();
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session && _session->actively_recording()) {
|
2009-08-04 14:21:09 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-10 12:41:51 -04:00
|
|
|
button_selection (item, event, item_type);
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (!_drags->active () &&
|
2009-08-04 14:21:09 -04:00
|
|
|
(Keyboard::is_delete_event (&event->button) ||
|
|
|
|
Keyboard::is_context_menu_event (&event->button) ||
|
|
|
|
Keyboard::is_edit_event (&event->button))) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-04 14:21:09 -04:00
|
|
|
/* handled by button release */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (event->button.button) {
|
|
|
|
case 1:
|
|
|
|
return button_press_handler_1 (item, event, item_type);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
return button_press_handler_2 (item, event, item_type);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-03-03 22:10:48 -05:00
|
|
|
return button_press_dispatch (&event->button);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
|
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2011-03-03 22:10:48 -05:00
|
|
|
bool
|
|
|
|
Editor::button_press_dispatch (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
/* this function is intended only for buttons 4 and above.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Gtkmm2ext::MouseButton b (ev->state, ev->button);
|
|
|
|
return button_bindings->activate (b, Gtkmm2ext::Bindings::Press);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Editor::button_release_dispatch (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
/* this function is intended only for buttons 4 and above.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Gtkmm2ext::MouseButton b (ev->state, ev->button);
|
|
|
|
return button_bindings->activate (b, Gtkmm2ext::Bindings::Release);
|
|
|
|
}
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
bool
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-08-25 15:28:33 -04:00
|
|
|
framepos_t where = event_frame (event, 0, 0);
|
2009-07-09 13:58:13 -04:00
|
|
|
AutomationTimeAxisView* atv = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-22 11:21:06 -04:00
|
|
|
if (pre_press_cursor) {
|
|
|
|
set_canvas_cursor (pre_press_cursor);
|
|
|
|
pre_press_cursor = 0;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* no action if we're recording */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session && _session->actively_recording()) {
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2010-08-09 21:52:49 -04:00
|
|
|
/* see if we're finishing a drag */
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-06-01 20:39:57 -04:00
|
|
|
bool were_dragging = false;
|
2010-01-12 11:14:49 -05:00
|
|
|
if (_drags->active ()) {
|
|
|
|
bool const r = _drags->end_grab (event);
|
2009-05-30 14:25:59 -04:00
|
|
|
if (r) {
|
2005-09-25 14:42:24 -04:00
|
|
|
/* grab dragged, so do nothing else */
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-06-01 20:39:57 -04:00
|
|
|
|
|
|
|
were_dragging = true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-11-03 18:19:29 -04:00
|
|
|
update_region_layering_order_editor ();
|
2010-08-25 15:28:33 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* edit events get handled here */
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (!_drags->active () && Keyboard::is_edit_event (&event->button)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
2010-11-03 18:19:29 -04:00
|
|
|
show_region_properties ();
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TempoMarkerItem:
|
|
|
|
edit_tempo_marker (item);
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterMarkerItem:
|
|
|
|
edit_meter_marker (item);
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewName:
|
2005-09-25 14:42:24 -04:00
|
|
|
if (clicked_regionview->name_active()) {
|
|
|
|
return mouse_rename_region (item, event);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-12-18 12:46:28 -05:00
|
|
|
case ControlPointItem:
|
|
|
|
edit_control_point (item);
|
|
|
|
break;
|
|
|
|
|
2010-08-13 22:00:50 -04:00
|
|
|
case NoteItem:
|
|
|
|
edit_note (item);
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* context menu events get handled here */
|
|
|
|
|
|
|
|
if (Keyboard::is_context_menu_event (&event->button)) {
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (!_drags->active ()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* no matter which button pops up the context menu, tell the menu
|
|
|
|
widget to use button 1 to drive menu selection.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case FadeInItem:
|
|
|
|
case FadeInHandleItem:
|
|
|
|
case FadeOutItem:
|
|
|
|
case FadeOutHandleItem:
|
|
|
|
popup_fade_context_menu (1, event->button.time, item, item_type);
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case StreamItem:
|
2010-11-14 11:49:59 -05:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false);
|
2007-10-11 18:07:47 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case RegionItem:
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
2010-06-17 08:45:51 -04:00
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewName:
|
2010-11-14 11:49:59 -05:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false);
|
2007-10-11 18:07:47 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case SelectionItem:
|
2010-11-14 11:49:59 -05:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, true);
|
2007-10-11 18:07:47 -04:00
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case AutomationTrackItem:
|
2010-11-14 11:49:59 -05:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
case MarkerBarItem:
|
|
|
|
case RangeMarkerBarItem:
|
2008-01-10 16:20:59 -05:00
|
|
|
case TransportMarkerBarItem:
|
|
|
|
case CdMarkerBarItem:
|
2005-09-25 14:42:24 -04:00
|
|
|
case TempoBarItem:
|
|
|
|
case MeterBarItem:
|
2009-03-21 09:08:06 -04:00
|
|
|
popup_ruler_menu (where, item_type);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MarkerItem:
|
|
|
|
marker_context_menu (&event->button, item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TempoMarkerItem:
|
2010-05-02 19:14:43 -04:00
|
|
|
tempo_or_meter_marker_context_menu (&event->button, item);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterMarkerItem:
|
2010-05-02 19:14:43 -04:00
|
|
|
tempo_or_meter_marker_context_menu (&event->button, item);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-12 18:45:50 -05:00
|
|
|
case CrossfadeViewItem:
|
2010-11-14 11:49:59 -05:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false);
|
2008-01-12 18:45:50 -05:00
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-05-10 22:54:43 -04:00
|
|
|
#ifdef WITH_CMT
|
2005-09-25 14:42:24 -04:00
|
|
|
case ImageFrameItem:
|
|
|
|
popup_imageframe_edit_menu(1, event->button.time, item, true) ;
|
|
|
|
break ;
|
|
|
|
case ImageFrameTimeAxisItem:
|
|
|
|
popup_imageframe_edit_menu(1, event->button.time, item, false) ;
|
|
|
|
break ;
|
|
|
|
case MarkerViewItem:
|
|
|
|
popup_marker_time_axis_edit_menu(1, event->button.time, item, true) ;
|
|
|
|
break ;
|
|
|
|
case MarkerTimeAxisItem:
|
|
|
|
popup_marker_time_axis_edit_menu(1, event->button.time, item, false) ;
|
|
|
|
break ;
|
2007-05-10 22:54:43 -04:00
|
|
|
#endif
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* delete events get handled here */
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
Editing::MouseMode const eff = effective_mouse_mode ();
|
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (!_drags->active () && Keyboard::is_delete_event (&event->button)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case TempoMarkerItem:
|
|
|
|
remove_tempo_marker (item);
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterMarkerItem:
|
|
|
|
remove_meter_marker (item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MarkerItem:
|
2005-11-12 22:53:51 -05:00
|
|
|
remove_marker (*item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RegionItem:
|
2010-01-01 17:11:15 -05:00
|
|
|
if (eff == MouseObject) {
|
2005-09-25 14:42:24 -04:00
|
|
|
remove_clicked_region ();
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-06-30 14:41:50 -04:00
|
|
|
case ControlPointItem:
|
2010-01-01 17:11:15 -05:00
|
|
|
if (eff == MouseGain) {
|
2005-09-25 14:42:24 -04:00
|
|
|
remove_gain_control_point (item, event);
|
2007-06-30 14:41:50 -04:00
|
|
|
} else {
|
|
|
|
remove_control_point (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-05-24 21:39:45 -04:00
|
|
|
case NoteItem:
|
|
|
|
remove_midi_note (item, event);
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (event->button.button) {
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
/* see comments in button_press_handler */
|
|
|
|
case PlayheadCursorItem:
|
|
|
|
case MarkerItem:
|
|
|
|
case GainLineItem:
|
2007-06-30 14:41:50 -04:00
|
|
|
case AutomationLineItem:
|
2005-09-25 14:42:24 -04:00
|
|
|
case StartSelectionTrimItem:
|
|
|
|
case EndSelectionTrimItem:
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case MarkerBarItem:
|
2008-12-12 09:43:24 -05:00
|
|
|
if (!_dragging_playhead) {
|
2009-08-24 16:26:34 -04:00
|
|
|
snap_to_with_modifier (where, event, 0, true);
|
2008-12-12 09:43:24 -05:00
|
|
|
mouse_add_new_marker (where);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
case CdMarkerBarItem:
|
2008-12-12 09:43:24 -05:00
|
|
|
if (!_dragging_playhead) {
|
|
|
|
// if we get here then a dragged range wasn't done
|
2009-08-24 16:26:34 -04:00
|
|
|
snap_to_with_modifier (where, event, 0, true);
|
2008-12-12 09:43:24 -05:00
|
|
|
mouse_add_new_marker (where, true);
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case TempoBarItem:
|
2008-12-12 09:43:24 -05:00
|
|
|
if (!_dragging_playhead) {
|
2009-08-24 16:26:34 -04:00
|
|
|
snap_to_with_modifier (where, event);
|
2008-12-12 09:43:24 -05:00
|
|
|
mouse_add_new_tempo_event (where);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterBarItem:
|
2008-12-12 09:43:24 -05:00
|
|
|
if (!_dragging_playhead) {
|
|
|
|
mouse_add_new_meter_event (pixel_to_frame (event->button.x));
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
switch (eff) {
|
2005-09-25 14:42:24 -04:00
|
|
|
case MouseObject:
|
|
|
|
switch (item_type) {
|
|
|
|
case AutomationTrackItem:
|
2009-07-09 13:58:13 -04:00
|
|
|
atv = dynamic_cast<AutomationTimeAxisView*>(clicked_axisview);
|
2008-02-16 17:43:18 -05:00
|
|
|
if (atv) {
|
|
|
|
atv->add_automation_event (item, event, where, event->button.y);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseGain:
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
2010-05-26 21:08:37 -04:00
|
|
|
{
|
2008-12-12 09:43:24 -05:00
|
|
|
/* check that we didn't drag before releasing, since
|
|
|
|
its really annoying to create new control
|
|
|
|
points when doing this.
|
|
|
|
*/
|
2010-05-26 21:08:37 -04:00
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (clicked_regionview);
|
|
|
|
if (were_dragging && arv) {
|
|
|
|
arv->add_gain_point_event (item, event);
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2010-05-26 21:08:37 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case AutomationTrackItem:
|
2009-07-09 13:58:13 -04:00
|
|
|
dynamic_cast<AutomationTimeAxisView*>(clicked_axisview)->
|
2005-09-25 14:42:24 -04:00
|
|
|
add_automation_event (item, event, where, event->button.y);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MouseAudition:
|
2011-02-14 16:49:43 -05:00
|
|
|
set_canvas_cursor (current_canvas_cursor);
|
2007-11-07 20:40:25 -05:00
|
|
|
if (scrubbing_direction == 0) {
|
2007-10-11 18:07:47 -04:00
|
|
|
/* no drag, just a click */
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
2008-01-10 16:20:59 -05:00
|
|
|
play_selected_region ();
|
2007-10-11 18:07:47 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* make sure we stop */
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_transport_speed (0.0);
|
2009-10-23 16:17:20 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
2011-03-08 07:45:23 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2011-03-08 07:45:23 -05:00
|
|
|
/* do any (de)selection operations that should occur on button release */
|
|
|
|
button_selection (item, event, item_type);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 2:
|
2010-01-01 17:11:15 -05:00
|
|
|
switch (eff) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
case MouseObject:
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) {
|
|
|
|
raise_region ();
|
|
|
|
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::TertiaryModifier|Keyboard::SecondaryModifier))) {
|
|
|
|
lower_region ();
|
|
|
|
} else {
|
|
|
|
// Button2 click is unused
|
|
|
|
}
|
|
|
|
return true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MouseRange:
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
// x_style_paste (where, 1.0);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case 3:
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-03-08 07:45:23 -05:00
|
|
|
|
2006-03-07 21:50:53 -05:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
bool
|
2010-01-01 17:11:15 -05:00
|
|
|
Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ControlPoint* cp;
|
|
|
|
Marker * marker;
|
|
|
|
double fraction;
|
2010-05-30 16:13:29 -04:00
|
|
|
bool ret = true;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-08-26 22:01:59 -04:00
|
|
|
last_item_entered = item;
|
2008-02-16 17:43:18 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (item_type) {
|
2007-06-30 14:41:50 -04:00
|
|
|
case ControlPointItem:
|
2007-03-18 02:07:08 -04:00
|
|
|
if (mouse_mode == MouseGain || mouse_mode == MouseObject) {
|
|
|
|
cp = static_cast<ControlPoint*>(item->get_data ("control_point"));
|
|
|
|
cp->set_visible (true);
|
|
|
|
|
|
|
|
double at_x, at_y;
|
|
|
|
at_x = cp->get_x();
|
|
|
|
at_y = cp->get_y ();
|
2010-01-02 19:08:58 -05:00
|
|
|
cp->i2w (at_x, at_y);
|
2008-10-03 14:24:38 -04:00
|
|
|
at_x += 10.0;
|
|
|
|
at_y += 10.0;
|
2007-03-18 02:07:08 -04:00
|
|
|
|
2007-07-06 23:19:04 -04:00
|
|
|
fraction = 1.0 - (cp->get_y() / cp->line().height());
|
2007-03-18 02:07:08 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (is_drawable() && !_drags->active ()) {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->fader);
|
2007-03-18 02:07:08 -04:00
|
|
|
}
|
2008-02-16 17:43:18 -05:00
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
_verbose_cursor->set (cp->line().get_verbose_cursor_string (fraction), at_x, at_y);
|
|
|
|
_verbose_cursor->show ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case GainLineItem:
|
|
|
|
if (mouse_mode == MouseGain) {
|
2005-11-27 17:35:04 -05:00
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
|
|
|
if (line)
|
2007-06-29 13:13:09 -04:00
|
|
|
line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_EnteredGainLine.get();
|
2005-09-25 14:42:24 -04:00
|
|
|
if (is_drawable()) {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->fader);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-06-30 14:41:50 -04:00
|
|
|
case AutomationLineItem:
|
2007-03-18 02:07:08 -04:00
|
|
|
if (mouse_mode == MouseGain || mouse_mode == MouseObject) {
|
|
|
|
{
|
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
|
|
|
if (line)
|
2007-06-29 13:13:09 -04:00
|
|
|
line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_EnteredAutomationLine.get();
|
2007-03-18 02:07:08 -04:00
|
|
|
}
|
|
|
|
if (is_drawable()) {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->fader);
|
2007-03-18 02:07:08 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
2011-02-09 09:02:49 -05:00
|
|
|
if (is_drawable() && mouse_mode == MouseObject && entered_regionview) {
|
2010-11-15 14:00:31 -05:00
|
|
|
set_canvas_cursor_for_region_view (event->crossing.x, entered_regionview);
|
|
|
|
_over_region_trim_target = true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-06-17 08:45:51 -04:00
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
2010-11-15 17:55:39 -05:00
|
|
|
if (is_drawable() && mouse_mode == MouseObject && !internal_editing() && entered_regionview) {
|
|
|
|
set_canvas_cursor_for_region_view (event->crossing.x, entered_regionview);
|
2010-06-17 08:45:51 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case StartSelectionTrimItem:
|
|
|
|
case EndSelectionTrimItem:
|
2007-05-10 22:54:43 -04:00
|
|
|
|
|
|
|
#ifdef WITH_CMT
|
2005-09-25 14:42:24 -04:00
|
|
|
case ImageFrameHandleStartItem:
|
|
|
|
case ImageFrameHandleEndItem:
|
|
|
|
case MarkerViewHandleStartItem:
|
|
|
|
case MarkerViewHandleEndItem:
|
2007-05-10 22:54:43 -04:00
|
|
|
#endif
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (is_drawable()) {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->trimmer);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PlayheadCursorItem:
|
|
|
|
if (is_drawable()) {
|
2008-02-16 17:43:18 -05:00
|
|
|
switch (_edit_point) {
|
|
|
|
case EditAtMouse:
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->grabber_edit_point);
|
2008-02-16 17:43:18 -05:00
|
|
|
break;
|
|
|
|
default:
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->grabber);
|
2008-02-16 17:43:18 -05:00
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewName:
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* when the name is not an active item, the entire name highlight is for trimming */
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!reinterpret_cast<RegionView *> (item->get_data ("regionview"))->name_active()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
if (mouse_mode == MouseObject && is_drawable()) {
|
2010-11-15 14:00:31 -05:00
|
|
|
set_canvas_cursor_for_region_view (event->crossing.x, entered_regionview);
|
|
|
|
_over_region_trim_target = true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case AutomationTrackItem:
|
|
|
|
if (is_drawable()) {
|
2007-08-10 16:55:27 -04:00
|
|
|
Gdk::Cursor *cursor;
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseRange:
|
2010-11-16 09:53:16 -05:00
|
|
|
cursor = _cursors->selector;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case MouseZoom:
|
2010-11-16 09:53:16 -05:00
|
|
|
cursor = _cursors->zoom_in;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
default:
|
2010-11-16 09:53:16 -05:00
|
|
|
cursor = _cursors->cross_hair;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-09-22 11:21:06 -04:00
|
|
|
set_canvas_cursor (cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
AutomationTimeAxisView* atv;
|
|
|
|
if ((atv = static_cast<AutomationTimeAxisView*>(item->get_data ("trackview"))) != 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
clear_entered_track = false;
|
|
|
|
set_entered_track (atv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MarkerBarItem:
|
|
|
|
case RangeMarkerBarItem:
|
|
|
|
case TransportMarkerBarItem:
|
2008-01-10 16:20:59 -05:00
|
|
|
case CdMarkerBarItem:
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterBarItem:
|
|
|
|
case TempoBarItem:
|
|
|
|
if (is_drawable()) {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->timebar);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MarkerItem:
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = static_cast<Marker *> (item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
2007-11-12 17:23:01 -05:00
|
|
|
entered_marker = marker;
|
2007-06-29 13:13:09 -04:00
|
|
|
marker->set_color_rgba (ARDOUR_UI::config()->canvasvar_EnteredMarker.get());
|
2005-09-25 14:42:24 -04:00
|
|
|
// fall through
|
|
|
|
case MeterMarkerItem:
|
|
|
|
case TempoMarkerItem:
|
|
|
|
if (is_drawable()) {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->timebar);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
2010-06-17 18:09:07 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case FadeInHandleItem:
|
2010-07-16 17:12:06 -04:00
|
|
|
if (mouse_mode == MouseObject && !internal_editing()) {
|
2010-06-17 18:09:07 -04:00
|
|
|
ArdourCanvas::SimpleRect *rect = dynamic_cast<ArdourCanvas::SimpleRect *> (item);
|
|
|
|
if (rect) {
|
2010-09-07 07:41:16 -04:00
|
|
|
rect->property_fill_color_rgba() = 0xBBBBBBAA;
|
2010-06-17 18:09:07 -04:00
|
|
|
}
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->fade_in);
|
2010-06-17 18:09:07 -04:00
|
|
|
}
|
2010-11-25 15:37:39 -05:00
|
|
|
break;
|
2010-06-17 18:09:07 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case FadeOutHandleItem:
|
2010-07-16 17:12:06 -04:00
|
|
|
if (mouse_mode == MouseObject && !internal_editing()) {
|
2005-11-27 17:35:04 -05:00
|
|
|
ArdourCanvas::SimpleRect *rect = dynamic_cast<ArdourCanvas::SimpleRect *> (item);
|
|
|
|
if (rect) {
|
2010-09-07 07:41:16 -04:00
|
|
|
rect->property_fill_color_rgba() = 0xBBBBBBAA;
|
2005-11-27 17:35:04 -05:00
|
|
|
}
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->fade_out);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
2010-07-06 07:33:27 -04:00
|
|
|
case FeatureLineItem:
|
|
|
|
{
|
2011-02-14 16:49:43 -05:00
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
|
|
|
line->property_fill_color_rgba() = 0xFF0000FF;
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
|
|
|
break;
|
2010-08-18 14:06:31 -04:00
|
|
|
case SelectionItem:
|
|
|
|
if (join_object_range_button.get_active()) {
|
|
|
|
set_canvas_cursor ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* second pass to handle entered track status in a comprehensible way.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case GainLineItem:
|
2007-06-30 14:41:50 -04:00
|
|
|
case AutomationLineItem:
|
|
|
|
case ControlPointItem:
|
2005-09-25 14:42:24 -04:00
|
|
|
/* these do not affect the current entered track state */
|
|
|
|
clear_entered_track = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AutomationTrackItem:
|
|
|
|
/* handled above already */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-07-09 13:58:13 -04:00
|
|
|
set_entered_track (0);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-30 16:13:29 -04:00
|
|
|
return ret;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
bool
|
2010-01-01 17:11:15 -05:00
|
|
|
Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
AutomationLine* al;
|
|
|
|
ControlPoint* cp;
|
|
|
|
Marker *marker;
|
|
|
|
Location *loc;
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv;
|
2005-09-25 14:42:24 -04:00
|
|
|
bool is_start;
|
2010-11-25 15:37:39 -05:00
|
|
|
bool ret = true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (item_type) {
|
2007-06-30 14:41:50 -04:00
|
|
|
case ControlPointItem:
|
2005-11-28 17:36:26 -05:00
|
|
|
cp = reinterpret_cast<ControlPoint*>(item->get_data ("control_point"));
|
2007-07-06 23:19:04 -04:00
|
|
|
if (cp->line().the_list()->interpolation() != AutomationList::Discrete) {
|
2010-08-10 21:23:03 -04:00
|
|
|
if (cp->line().npoints() > 1 && !cp->get_selected()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
cp->set_visible (false);
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (is_drawable()) {
|
2010-11-25 15:37:39 -05:00
|
|
|
set_canvas_cursor (current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2011-05-02 09:38:16 -04:00
|
|
|
_verbose_cursor->hide ();
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
2010-06-17 08:45:51 -04:00
|
|
|
case LeftFrameHandle:
|
|
|
|
case RightFrameHandle:
|
2005-09-25 14:42:24 -04:00
|
|
|
case StartSelectionTrimItem:
|
|
|
|
case EndSelectionTrimItem:
|
|
|
|
case PlayheadCursorItem:
|
2007-05-10 22:54:43 -04:00
|
|
|
|
|
|
|
#ifdef WITH_CMT
|
2005-09-25 14:42:24 -04:00
|
|
|
case ImageFrameHandleStartItem:
|
|
|
|
case ImageFrameHandleEndItem:
|
|
|
|
case MarkerViewHandleStartItem:
|
|
|
|
case MarkerViewHandleEndItem:
|
2007-05-10 22:54:43 -04:00
|
|
|
#endif
|
|
|
|
|
2010-11-15 14:00:31 -05:00
|
|
|
_over_region_trim_target = false;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (is_drawable()) {
|
2010-11-25 15:37:39 -05:00
|
|
|
set_canvas_cursor (current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GainLineItem:
|
2007-06-30 14:41:50 -04:00
|
|
|
case AutomationLineItem:
|
2005-11-28 17:36:26 -05:00
|
|
|
al = reinterpret_cast<AutomationLine*> (item->get_data ("line"));
|
2005-11-27 17:35:04 -05:00
|
|
|
{
|
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
|
|
|
if (line)
|
|
|
|
line->property_fill_color_rgba() = al->get_line_color();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
if (is_drawable()) {
|
2010-11-25 15:37:39 -05:00
|
|
|
set_canvas_cursor (current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewName:
|
2005-09-25 14:42:24 -04:00
|
|
|
/* see enter_handler() for notes */
|
2010-11-15 14:00:31 -05:00
|
|
|
_over_region_trim_target = false;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!reinterpret_cast<RegionView *> (item->get_data ("regionview"))->name_active()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
if (is_drawable() && mouse_mode == MouseObject) {
|
2010-11-25 15:37:39 -05:00
|
|
|
set_canvas_cursor (current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RangeMarkerBarItem:
|
|
|
|
case TransportMarkerBarItem:
|
2008-01-10 16:20:59 -05:00
|
|
|
case CdMarkerBarItem:
|
2005-09-25 14:42:24 -04:00
|
|
|
case MeterBarItem:
|
|
|
|
case TempoBarItem:
|
|
|
|
case MarkerBarItem:
|
|
|
|
if (is_drawable()) {
|
2010-11-25 15:37:39 -05:00
|
|
|
set_canvas_cursor (current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case MarkerItem:
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = static_cast<Marker *> (item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
2007-11-12 17:23:01 -05:00
|
|
|
entered_marker = 0;
|
|
|
|
if ((loc = find_location_from_marker (marker, is_start)) != 0) {
|
|
|
|
location_flags_changed (loc, this);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
// fall through
|
|
|
|
case MeterMarkerItem:
|
|
|
|
case TempoMarkerItem:
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (is_drawable()) {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->timebar);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FadeInHandleItem:
|
|
|
|
case FadeOutHandleItem:
|
2006-07-23 08:03:19 -04:00
|
|
|
rv = static_cast<RegionView*>(item->get_data ("regionview"));
|
2005-11-27 17:35:04 -05:00
|
|
|
{
|
|
|
|
ArdourCanvas::SimpleRect *rect = dynamic_cast<ArdourCanvas::SimpleRect *> (item);
|
|
|
|
if (rect) {
|
|
|
|
rect->property_fill_color_rgba() = rv->get_fill_color();
|
|
|
|
rect->property_outline_pixels() = 0;
|
|
|
|
}
|
|
|
|
}
|
2010-11-25 15:37:39 -05:00
|
|
|
set_canvas_cursor (current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AutomationTrackItem:
|
|
|
|
if (is_drawable()) {
|
2010-11-25 15:37:39 -05:00
|
|
|
set_canvas_cursor (current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
clear_entered_track = true;
|
2009-12-11 18:29:48 -05:00
|
|
|
Glib::signal_idle().connect (sigc::mem_fun(*this, &Editor::left_automation_track));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
2010-07-06 07:33:27 -04:00
|
|
|
case FeatureLineItem:
|
|
|
|
{
|
2011-02-14 16:49:43 -05:00
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
|
|
|
line->property_fill_color_rgba() = (guint) ARDOUR_UI::config()->canvasvar_ZeroLine.get();;
|
2010-07-06 07:33:27 -04:00
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-30 16:13:29 -04:00
|
|
|
return ret;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
Editor::left_automation_track ()
|
|
|
|
{
|
|
|
|
if (clear_entered_track) {
|
2009-07-09 13:58:13 -04:00
|
|
|
set_entered_track (0);
|
2005-09-25 14:42:24 -04:00
|
|
|
clear_entered_track = false;
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
void
|
2010-09-17 14:20:37 -04:00
|
|
|
Editor::scrub (framepos_t frame, double current_x)
|
2008-04-11 10:06:50 -04:00
|
|
|
{
|
|
|
|
double delta;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (scrubbing_direction == 0) {
|
|
|
|
/* first move */
|
2010-01-12 11:14:49 -05:00
|
|
|
_session->request_locate (frame, false);
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_transport_speed (0.1);
|
2008-04-11 10:06:50 -04:00
|
|
|
scrubbing_direction = 1;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
if (last_scrub_x > current_x) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
/* pointer moved to the left */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (scrubbing_direction > 0) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
/* we reversed direction to go backwards */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
scrub_reversals++;
|
2010-01-12 11:14:49 -05:00
|
|
|
scrub_reverse_distance += (int) (last_scrub_x - current_x);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
/* still moving to the left (backwards) */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
scrub_reversals = 0;
|
|
|
|
scrub_reverse_distance = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
delta = 0.01 * (last_scrub_x - current_x);
|
2011-02-06 20:12:47 -05:00
|
|
|
_session->request_transport_speed_nonzero (_session->transport_speed() - delta);
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
} else {
|
|
|
|
/* pointer moved to the right */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (scrubbing_direction < 0) {
|
|
|
|
/* we reversed direction to go forward */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
scrub_reversals++;
|
2010-01-12 11:14:49 -05:00
|
|
|
scrub_reverse_distance += (int) (current_x - last_scrub_x);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
} else {
|
|
|
|
/* still moving to the right */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
scrub_reversals = 0;
|
|
|
|
scrub_reverse_distance = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
delta = 0.01 * (current_x - last_scrub_x);
|
2011-02-06 20:12:47 -05:00
|
|
|
_session->request_transport_speed_nonzero (_session->transport_speed() + delta);
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
/* if there have been more than 2 opposite motion moves detected, or one that moves
|
|
|
|
back more than 10 pixels, reverse direction
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (scrub_reversals >= 2 || scrub_reverse_distance > 10) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
if (scrubbing_direction > 0) {
|
|
|
|
/* was forwards, go backwards */
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_transport_speed (-0.1);
|
2008-04-11 10:06:50 -04:00
|
|
|
scrubbing_direction = -1;
|
|
|
|
} else {
|
|
|
|
/* was backwards, go forwards */
|
2009-12-17 13:24:23 -05:00
|
|
|
_session->request_transport_speed (0.1);
|
2008-04-11 10:06:50 -04:00
|
|
|
scrubbing_direction = 1;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
scrub_reverse_distance = 0;
|
|
|
|
scrub_reversals = 0;
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
last_scrub_x = current_x;
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::motion_handler (ArdourCanvas::Item* /*item*/, GdkEvent* event, bool from_autoscroll)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2010-08-18 14:06:31 -04:00
|
|
|
_last_motion_y = event->motion.y;
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (event->motion.is_hint) {
|
|
|
|
gint x, y;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
/* We call this so that MOTION_NOTIFY events continue to be
|
|
|
|
delivered to the canvas. We need to do this because we set
|
|
|
|
Gdk::POINTER_MOTION_HINT_MASK on the canvas. This reduces
|
|
|
|
the density of the events, at the expense of a round-trip
|
|
|
|
to the server. Given that this will mostly occur on cases
|
|
|
|
where DISPLAY = :0.0, and given the cost of what the motion
|
2009-10-14 12:10:01 -04:00
|
|
|
event might do, its a good tradeoff.
|
2008-01-10 16:20:59 -05:00
|
|
|
*/
|
2008-09-10 17:27:39 -04:00
|
|
|
|
2008-03-17 16:54:03 -04:00
|
|
|
track_canvas->get_pointer (x, y);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (current_stepping_trackview) {
|
|
|
|
/* don't keep the persistent stepped trackview if the mouse moves */
|
2009-07-09 13:58:13 -04:00
|
|
|
current_stepping_trackview = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
step_timeout.disconnect ();
|
|
|
|
}
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if (_session && _session->actively_recording()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
/* Sorry. no dragging stuff around while we record */
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
JoinObjectRangeState const old = _join_object_range_state;
|
|
|
|
update_join_object_range_location (event->motion.x, event->motion.y);
|
|
|
|
if (_join_object_range_state != old) {
|
|
|
|
set_canvas_cursor ();
|
|
|
|
}
|
|
|
|
|
2010-11-15 14:00:31 -05:00
|
|
|
if (_over_region_trim_target) {
|
|
|
|
set_canvas_cursor_for_region_view (event->motion.x, entered_regionview);
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
bool handled = false;
|
2010-01-12 11:14:49 -05:00
|
|
|
if (_drags->active ()) {
|
|
|
|
handled = _drags->motion_handler (event, from_autoscroll);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2010-08-04 11:41:55 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (!handled) {
|
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-10-26 21:10:36 -04:00
|
|
|
track_canvas_motion (event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::remove_gain_control_point (ArdourCanvas::Item*item, GdkEvent* /*event*/)
|
2008-04-11 10:06:50 -04:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
ControlPoint* control_point;
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if ((control_point = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"))) == 0) {
|
|
|
|
fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
// We shouldn't remove the first or last gain point
|
|
|
|
if (control_point->line().is_last_point(*control_point) ||
|
2009-10-14 12:10:01 -04:00
|
|
|
control_point->line().is_first_point(*control_point)) {
|
2009-05-30 14:25:59 -04:00
|
|
|
return;
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
control_point->line().remove_point (*control_point);
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::remove_control_point (ArdourCanvas::Item* item, GdkEvent* /*event*/)
|
2008-04-11 10:06:50 -04:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
ControlPoint* control_point;
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if ((control_point = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"))) == 0) {
|
|
|
|
fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
|
2005-09-25 14:42:24 -04:00
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
control_point->line().remove_point (*control_point);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
void
|
2009-05-30 14:25:59 -04:00
|
|
|
Editor::edit_control_point (ArdourCanvas::Item* item)
|
2006-06-13 03:27:52 -04:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
ControlPoint* p = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
|
2006-06-13 03:27:52 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (p == 0) {
|
|
|
|
fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
2006-06-13 03:27:52 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
ControlPointDialog d (p);
|
|
|
|
d.set_position (Gtk::WIN_POS_MOUSE);
|
|
|
|
ensure_float (d);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (d.run () != RESPONSE_ACCEPT) {
|
|
|
|
return;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
p->line().modify_point_y (*p, d.get_y_fraction ());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2010-08-13 22:00:50 -04:00
|
|
|
void
|
|
|
|
Editor::edit_note (ArdourCanvas::Item* item)
|
|
|
|
{
|
|
|
|
ArdourCanvas::CanvasNoteEvent* e = dynamic_cast<ArdourCanvas::CanvasNoteEvent*> (item);
|
|
|
|
assert (e);
|
|
|
|
|
|
|
|
EditNoteDialog d (&e->region_view(), e);
|
|
|
|
d.set_position (Gtk::WIN_POS_MOUSE);
|
|
|
|
ensure_float (d);
|
|
|
|
|
|
|
|
d.run ();
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
void
|
2009-05-30 14:25:59 -04:00
|
|
|
Editor::visible_order_range (int* low, int* high) const
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
*low = TimeAxisView::max_order ();
|
|
|
|
*high = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (!rtv->hidden()) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (*high < rtv->order()) {
|
|
|
|
*high = rtv->order ();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (*low > rtv->order()) {
|
|
|
|
*low = rtv->order ();
|
|
|
|
}
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2009-05-30 14:25:59 -04:00
|
|
|
Editor::region_view_item_click (AudioRegionView& rv, GdkEventButton* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
/* Either add to or set the set the region selection, unless
|
|
|
|
this is an alignment click (control used)
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (Keyboard::modifier_state_contains (event->state, Keyboard::PrimaryModifier)) {
|
2009-07-09 13:58:13 -04:00
|
|
|
TimeAxisView* tv = &rv.get_time_axis_view();
|
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(tv);
|
2009-05-30 14:25:59 -04:00
|
|
|
double speed = 1.0;
|
|
|
|
if (rtv && rtv->is_track()) {
|
2010-04-21 16:42:22 -04:00
|
|
|
speed = rtv->track()->speed();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t where = get_preferred_edit_position();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (where >= 0) {
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-17 14:20:37 -04:00
|
|
|
align_region (rv.region(), SyncPoint, (framepos_t) (where * speed));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
} else if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-17 14:20:37 -04:00
|
|
|
align_region (rv.region(), End, (framepos_t) (where * speed));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-17 14:20:37 -04:00
|
|
|
align_region (rv.region(), Start, (framepos_t) (where * speed));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
|
|
|
Editor::collect_new_region_view (RegionView* rv)
|
|
|
|
{
|
|
|
|
latest_regionviews.push_back (rv);
|
|
|
|
}
|
2009-04-20 17:02:46 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
|
|
|
Editor::collect_and_select_new_region_view (RegionView* rv)
|
|
|
|
{
|
|
|
|
selection->add(rv);
|
|
|
|
latest_regionviews.push_back (rv);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
|
|
|
Editor::cancel_selection ()
|
|
|
|
{
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
(*i)->hide_selection ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
selection->clear ();
|
|
|
|
clicked_selection = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
void
|
2010-09-17 14:20:37 -04:00
|
|
|
Editor::point_trim (GdkEvent* event, framepos_t new_bound)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv = clicked_regionview;
|
2009-04-20 17:02:46 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* Choose action dependant on which button was pressed */
|
|
|
|
switch (event->button.button) {
|
|
|
|
case 1:
|
2010-09-14 20:33:33 -04:00
|
|
|
begin_reversible_command (_("start point trim"));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (selection->selected (rv)) {
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin();
|
|
|
|
i != selection->regions.by_layer().end(); ++i)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-04-20 17:02:46 -04:00
|
|
|
if ( (*i) == NULL){
|
|
|
|
cerr << "region view contains null region" << endl;
|
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (!(*i)->region()->locked()) {
|
2010-08-25 13:32:08 -04:00
|
|
|
(*i)->region()->clear_changes ();
|
2009-04-20 17:02:46 -04:00
|
|
|
(*i)->region()->trim_front (new_bound, this);
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command(new StatefulDiffCommand ((*i)->region()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2006-08-29 17:21:48 -04:00
|
|
|
if (!rv->region()->locked()) {
|
2010-08-25 13:32:08 -04:00
|
|
|
rv->region()->clear_changes ();
|
2009-04-20 17:02:46 -04:00
|
|
|
rv->region()->trim_front (new_bound, this);
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command(new StatefulDiffCommand (rv->region()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
begin_reversible_command (_("End point trim"));
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (selection->selected (rv)) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-29 17:21:48 -04:00
|
|
|
if (!(*i)->region()->locked()) {
|
2010-08-25 13:32:08 -04:00
|
|
|
(*i)->region()->clear_changes();
|
2006-08-29 17:21:48 -04:00
|
|
|
(*i)->region()->trim_end (new_bound, this);
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command(new StatefulDiffCommand ((*i)->region()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2006-06-13 03:27:52 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (!rv->region()->locked()) {
|
2010-08-25 13:32:08 -04:00
|
|
|
rv->region()->clear_changes ();
|
2009-05-30 14:25:59 -04:00
|
|
|
rv->region()->trim_end (new_bound, this);
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command (new StatefulDiffCommand (rv->region()));
|
2006-06-13 03:27:52 -04:00
|
|
|
}
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
commit_reversible_command();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::hide_marker (ArdourCanvas::Item* item, GdkEvent* /*event*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
Marker* marker;
|
|
|
|
bool is_start;
|
|
|
|
|
|
|
|
if ((marker = static_cast<Marker *> (item->get_data ("marker"))) == 0) {
|
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
Location* location = find_location_from_marker (marker, is_start);
|
2009-05-30 14:25:59 -04:00
|
|
|
location->set_hidden (true, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2010-09-17 14:20:37 -04:00
|
|
|
Editor::reposition_zoom_rect (framepos_t start, framepos_t end)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
double x1 = frame_to_pixel (start);
|
|
|
|
double x2 = frame_to_pixel (end);
|
2007-01-09 18:24:54 -05:00
|
|
|
double y2 = full_canvas_height - 1.0;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-27 17:35:04 -05:00
|
|
|
zoom_rect->property_x1() = x1;
|
|
|
|
zoom_rect->property_y1() = 1.0;
|
|
|
|
zoom_rect->property_x2() = x2;
|
|
|
|
zoom_rect->property_y2() = y2;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gint
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::mouse_rename_region (ArdourCanvas::Item* /*item*/, GdkEvent* /*event*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
ArdourPrompter prompter (false);
|
|
|
|
|
|
|
|
prompter.set_prompt (_("Name for region:"));
|
2006-08-29 17:21:48 -04:00
|
|
|
prompter.set_initial_text (clicked_regionview->region()->name());
|
2006-04-19 16:42:17 -04:00
|
|
|
prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
|
2006-04-22 11:28:59 -04:00
|
|
|
prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
prompter.show_all ();
|
2005-10-26 21:10:36 -04:00
|
|
|
switch (prompter.run ()) {
|
2006-01-13 14:48:55 -05:00
|
|
|
case Gtk::RESPONSE_ACCEPT:
|
2007-08-10 16:55:27 -04:00
|
|
|
string str;
|
2005-10-26 21:10:36 -04:00
|
|
|
prompter.get_result(str);
|
|
|
|
if (str.length()) {
|
2007-04-29 13:23:11 -04:00
|
|
|
clicked_regionview->region()->set_name (str);
|
2005-10-26 21:10:36 -04:00
|
|
|
}
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2010-09-17 14:20:37 -04:00
|
|
|
Editor::mouse_brush_insert_region (RegionView* rv, framepos_t pos)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
/* no brushing without a useful snap setting */
|
|
|
|
|
2009-10-26 19:43:04 -04:00
|
|
|
switch (_snap_mode) {
|
2005-09-25 14:42:24 -04:00
|
|
|
case SnapMagnetic:
|
|
|
|
return; /* can't work because it allows region to be placed anywhere */
|
|
|
|
default:
|
|
|
|
break; /* OK */
|
|
|
|
}
|
|
|
|
|
2009-10-26 19:43:04 -04:00
|
|
|
switch (_snap_type) {
|
2005-09-25 14:42:24 -04:00
|
|
|
case SnapToMark:
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't brush a copy over the original */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (pos == rv->region()->position()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&rv->get_time_axis_view());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
if (rtv == 0 || !rtv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
boost::shared_ptr<Playlist> playlist = rtv->playlist();
|
2010-04-21 16:42:22 -04:00
|
|
|
double speed = rtv->track()->speed();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
playlist->clear_changes ();
|
2011-02-14 16:49:43 -05:00
|
|
|
boost::shared_ptr<Region> new_region (RegionFactory::create (rv->region(), true));
|
2010-11-25 15:37:39 -05:00
|
|
|
playlist->add_region (new_region, (framepos_t) (pos * speed));
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command (new StatefulDiffCommand (playlist));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-25 15:34:09 -05:00
|
|
|
// playlist is frozen, so we have to update manually XXX this is disgusting
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-25 15:34:09 -05:00
|
|
|
playlist->RegionAdded (new_region); /* EMIT SIGNAL */
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
Editor::track_height_step_timeout ()
|
|
|
|
{
|
2008-09-10 11:03:30 -04:00
|
|
|
if (get_microseconds() - last_track_height_step_timestamp < 250000) {
|
2009-07-09 13:58:13 -04:00
|
|
|
current_stepping_trackview = 0;
|
2006-03-07 21:50:53 -05:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-10-11 18:07:47 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
void
|
2010-01-12 11:14:49 -05:00
|
|
|
Editor::add_region_drag (ArdourCanvas::Item* item, GdkEvent* event, RegionView* region_view)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
assert (region_view);
|
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!region_view->region()->playlist()) {
|
|
|
|
return;
|
|
|
|
}
|
2010-09-16 17:58:54 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
_region_motion_group->raise_to_top ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (Config->get_edit_mode() == Splice) {
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->add (new RegionSpliceDrag (this, item, region_view, selection->regions.by_layer()));
|
2009-05-30 14:25:59 -04:00
|
|
|
} else {
|
2010-03-01 19:00:00 -05:00
|
|
|
RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.property_id);
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), false, false));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
/* sync the canvas to what we think is its current state */
|
2009-06-12 15:05:16 -04:00
|
|
|
update_canvas_now();
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-01-12 11:14:49 -05:00
|
|
|
Editor::add_region_copy_drag (ArdourCanvas::Item* item, GdkEvent* event, RegionView* region_view)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
assert (region_view);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!region_view->region()->playlist()) {
|
|
|
|
return;
|
|
|
|
}
|
2010-09-16 17:58:54 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
_region_motion_group->raise_to_top ();
|
2009-06-25 16:58:32 -04:00
|
|
|
|
2010-03-01 19:00:00 -05:00
|
|
|
RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.property_id);
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), false, true));
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-01-12 11:14:49 -05:00
|
|
|
Editor::add_region_brush_drag (ArdourCanvas::Item* item, GdkEvent* event, RegionView* region_view)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
assert (region_view);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
if (!region_view->region()->playlist()) {
|
|
|
|
return;
|
|
|
|
}
|
2010-09-16 17:58:54 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (Config->get_edit_mode() == Splice) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-01 19:00:00 -05:00
|
|
|
RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.property_id);
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), true, false));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-01-19 12:38:56 -05:00
|
|
|
begin_reversible_command (Operations::drag_region_brush);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Start a grab where a time range is selected, track(s) are selected, and the
|
|
|
|
* user clicks and drags a region with a modifier in order to create a new region containing
|
|
|
|
* the section of the clicked region that lies within the time range.
|
|
|
|
*/
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::start_selection_grab (ArdourCanvas::Item* /*item*/, GdkEvent* event)
|
2009-05-30 14:25:59 -04:00
|
|
|
{
|
|
|
|
if (clicked_regionview == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* lets try to create new Region for the selection */
|
|
|
|
|
|
|
|
vector<boost::shared_ptr<Region> > new_regions;
|
|
|
|
create_region_from_selection (new_regions);
|
|
|
|
|
|
|
|
if (new_regions.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX fix me one day to use all new regions */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
boost::shared_ptr<Region> region (new_regions.front());
|
|
|
|
|
|
|
|
/* add it to the current stream/playlist.
|
|
|
|
|
|
|
|
tricky: the streamview for the track will add a new regionview. we will
|
|
|
|
catch the signal it sends when it creates the regionview to
|
|
|
|
set the regionview we want to then drag.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
latest_regionviews.clear();
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::connection c = clicked_routeview->view()->RegionViewAdded.connect (sigc::mem_fun(*this, &Editor::collect_new_region_view));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
|
|
/* A selection grab currently creates two undo/redo operations, one for
|
2009-05-30 14:25:59 -04:00
|
|
|
creating the new region and another for moving it.
|
|
|
|
*/
|
|
|
|
|
2011-01-19 12:38:56 -05:00
|
|
|
begin_reversible_command (Operations::selection_grab);
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<Playlist> playlist = clicked_axisview->playlist();
|
|
|
|
|
2010-11-25 15:37:39 -05:00
|
|
|
playlist->clear_changes ();
|
2009-05-30 14:25:59 -04:00
|
|
|
clicked_routeview->playlist()->add_region (region, selection->time[clicked_selection].start);
|
2010-03-02 13:05:26 -05:00
|
|
|
_session->add_command(new StatefulDiffCommand (playlist));
|
2009-05-30 14:25:59 -04:00
|
|
|
|
|
|
|
commit_reversible_command ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
c.disconnect ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
if (latest_regionviews.empty()) {
|
|
|
|
/* something went wrong */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we need to deselect all other regionviews, and select this one
|
2009-10-14 12:10:01 -04:00
|
|
|
i'm ignoring undo stuff, because the region creation will take care of it
|
2009-05-30 14:25:59 -04:00
|
|
|
*/
|
|
|
|
selection->set (latest_regionviews);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
_drags->set (new RegionMoveDrag (this, latest_regionviews.front()->get_canvas_group(), latest_regionviews.front(), latest_regionviews, false, false), event);
|
2009-05-30 14:25:59 -04:00
|
|
|
}
|
|
|
|
|
2010-01-07 20:28:15 -05:00
|
|
|
void
|
|
|
|
Editor::escape ()
|
|
|
|
{
|
2010-01-12 11:14:49 -05:00
|
|
|
if (_drags->active ()) {
|
2010-05-05 18:09:07 -04:00
|
|
|
_drags->abort ();
|
2010-01-07 20:28:15 -05:00
|
|
|
} else {
|
|
|
|
selection->clear ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-28 16:51:28 -04:00
|
|
|
void
|
|
|
|
Editor::set_internal_edit (bool yn)
|
|
|
|
{
|
|
|
|
_internal_editing = yn;
|
2009-08-17 11:58:47 -04:00
|
|
|
|
|
|
|
if (yn) {
|
2009-08-28 12:06:08 -04:00
|
|
|
mouse_select_button.set_image (*(manage (new Image (::get_icon("midi_tool_pencil")))));
|
2009-10-14 17:24:35 -04:00
|
|
|
mouse_select_button.get_image ()->show ();
|
2010-11-25 15:37:39 -05:00
|
|
|
ARDOUR_UI::instance()->set_tip (mouse_select_button, _("Draw/Edit MIDI Notes"));
|
2010-11-21 18:54:57 -05:00
|
|
|
mouse_mode_toggled (mouse_mode);
|
2010-05-18 15:08:39 -04:00
|
|
|
|
2011-03-07 20:55:50 -05:00
|
|
|
pre_internal_mouse_mode = mouse_mode;
|
|
|
|
|
2011-03-03 09:51:02 -05:00
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
(*i)->enter_internal_edit_mode ();
|
|
|
|
}
|
|
|
|
|
2009-08-17 11:58:47 -04:00
|
|
|
} else {
|
2009-09-03 10:50:21 -04:00
|
|
|
|
2009-10-14 17:24:35 -04:00
|
|
|
mouse_select_button.set_image (*(manage (new Image (::get_icon("tool_range")))));
|
|
|
|
mouse_select_button.get_image ()->show ();
|
2010-11-25 15:37:39 -05:00
|
|
|
ARDOUR_UI::instance()->set_tip (mouse_select_button, _("Select/Move Ranges"));
|
|
|
|
mouse_mode_toggled (mouse_mode); // sets cursor
|
2011-03-03 09:51:02 -05:00
|
|
|
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
(*i)->leave_internal_edit_mode ();
|
|
|
|
}
|
2011-03-07 20:55:50 -05:00
|
|
|
|
|
|
|
if (mouse_mode == MouseRange && pre_internal_mouse_mode != MouseRange) {
|
|
|
|
/* we were drawing .. flip back to something sensible */
|
|
|
|
set_mouse_mode (pre_internal_mouse_mode);
|
|
|
|
}
|
2010-05-24 21:13:45 -04:00
|
|
|
}
|
2009-07-28 16:51:28 -04:00
|
|
|
}
|
2010-01-01 17:11:15 -05:00
|
|
|
|
|
|
|
/** Update _join_object_range_state which indicate whether we are over the top or bottom half of a region view,
|
|
|
|
* used by the `join object/range' tool mode.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Editor::update_join_object_range_location (double x, double y)
|
|
|
|
{
|
2010-01-12 11:14:49 -05:00
|
|
|
/* XXX: actually, this decides based on whether the mouse is in the top or bottom half of a RouteTimeAxisView;
|
|
|
|
entered_{track,regionview} is not always setup (e.g. if the mouse is over a TimeSelection), and to get a Region
|
|
|
|
that we're over requires searching the playlist.
|
|
|
|
*/
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
if (join_object_range_button.get_active() == false || (mouse_mode != MouseRange && mouse_mode != MouseObject)) {
|
|
|
|
_join_object_range_state = JOIN_OBJECT_RANGE_NONE;
|
|
|
|
return;
|
|
|
|
}
|
2010-01-12 11:14:49 -05:00
|
|
|
|
|
|
|
if (mouse_mode == MouseObject) {
|
|
|
|
_join_object_range_state = JOIN_OBJECT_RANGE_OBJECT;
|
|
|
|
} else if (mouse_mode == MouseRange) {
|
|
|
|
_join_object_range_state = JOIN_OBJECT_RANGE_RANGE;
|
|
|
|
}
|
2010-01-01 20:19:47 -05:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
/* XXX: maybe we should make entered_track work in all cases, rather than resorting to this */
|
|
|
|
pair<TimeAxisView*, int> tvp = trackview_by_y_position (y + vertical_adjustment.get_value() - canvas_timebars_vsize);
|
|
|
|
|
|
|
|
if (tvp.first) {
|
2010-01-01 17:11:15 -05:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tvp.first);
|
|
|
|
if (rtv) {
|
|
|
|
|
|
|
|
double cx = 0;
|
|
|
|
double cy = y;
|
|
|
|
rtv->canvas_display()->w2i (cx, cy);
|
|
|
|
|
2010-09-21 19:26:18 -04:00
|
|
|
double const c = cy / rtv->view()->child_height();
|
|
|
|
double d;
|
|
|
|
double const f = modf (c, &d);
|
|
|
|
|
|
|
|
_join_object_range_state = f < 0.5 ? JOIN_OBJECT_RANGE_RANGE : JOIN_OBJECT_RANGE_OBJECT;
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Editing::MouseMode
|
|
|
|
Editor::effective_mouse_mode () const
|
|
|
|
{
|
|
|
|
if (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) {
|
|
|
|
return MouseObject;
|
|
|
|
} else if (_join_object_range_state == JOIN_OBJECT_RANGE_RANGE) {
|
|
|
|
return MouseRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mouse_mode;
|
|
|
|
}
|
2010-05-24 21:39:45 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::remove_midi_note (ArdourCanvas::Item* item, GdkEvent *)
|
|
|
|
{
|
|
|
|
ArdourCanvas::CanvasNoteEvent* e = dynamic_cast<ArdourCanvas::CanvasNoteEvent*> (item);
|
|
|
|
assert (e);
|
|
|
|
|
|
|
|
e->region_view().delete_note (e->note ());
|
|
|
|
}
|
2010-11-15 14:00:31 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_canvas_cursor_for_region_view (double x, RegionView* rv)
|
|
|
|
{
|
2011-04-07 19:14:04 -04:00
|
|
|
assert (rv);
|
|
|
|
|
2010-11-15 14:00:31 -05:00
|
|
|
ArdourCanvas::Group* g = rv->get_canvas_group ();
|
|
|
|
ArdourCanvas::Group* p = g->get_parent_group ();
|
|
|
|
|
|
|
|
/* Compute x in region view parent coordinates */
|
|
|
|
double dy = 0;
|
|
|
|
p->w2i (x, dy);
|
|
|
|
|
|
|
|
double x1, x2, y1, y2;
|
|
|
|
g->get_bounds (x1, y1, x2, y2);
|
|
|
|
|
2010-11-15 17:55:39 -05:00
|
|
|
/* Halfway across the region */
|
2010-11-15 14:00:31 -05:00
|
|
|
double const h = (x1 + x2) / 2;
|
|
|
|
|
2010-11-15 17:55:39 -05:00
|
|
|
Trimmable::CanTrim ct = rv->region()->can_trim ();
|
|
|
|
if (x <= h) {
|
|
|
|
if (ct & Trimmable::FrontTrimEarlier) {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->left_side_trim);
|
2010-11-15 17:55:39 -05:00
|
|
|
} else {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->left_side_trim_right_only);
|
2010-11-15 17:55:39 -05:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ct & Trimmable::EndTrimLater) {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->right_side_trim);
|
2010-11-15 17:55:39 -05:00
|
|
|
} else {
|
2010-11-16 09:53:16 -05:00
|
|
|
set_canvas_cursor (_cursors->right_side_trim_left_only);
|
2010-11-15 17:55:39 -05:00
|
|
|
}
|
2010-11-15 14:00:31 -05:00
|
|
|
}
|
|
|
|
}
|
2011-05-02 09:38:16 -04:00
|
|
|
|
|
|
|
/** Obtain the pointer position in world coordinates */
|
|
|
|
void
|
|
|
|
Editor::get_pointer_position (double& x, double& y) const
|
|
|
|
{
|
|
|
|
int px, py;
|
|
|
|
track_canvas->get_pointer (px, py);
|
|
|
|
track_canvas->window_to_world (px, py, x, y);
|
|
|
|
}
|