2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2000 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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
2008-02-02 12:22:04 -05:00
|
|
|
#include <algorithm>
|
2008-12-23 16:05:50 -05:00
|
|
|
#include <typeinfo>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/stacktrace.h"
|
2007-04-12 19:20:37 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/audio_diskstream.h"
|
|
|
|
#include "ardour/audioplaylist.h"
|
2009-06-08 15:28:51 -04:00
|
|
|
#include "ardour/audioregion.h"
|
|
|
|
#include "ardour/region_factory.h"
|
2009-08-08 18:36:32 -04:00
|
|
|
#include "ardour/midi_region.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "editor.h"
|
2007-03-18 02:07:08 -04:00
|
|
|
#include "keyboard.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "public_editor.h"
|
2006-08-01 13:19:38 -04:00
|
|
|
#include "audio_region_view.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "audio_streamview.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "crossfade_view.h"
|
|
|
|
#include "audio_time_axis.h"
|
|
|
|
#include "region_gain_line.h"
|
2007-06-30 14:41:50 -04:00
|
|
|
#include "automation_line.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "automation_time_axis.h"
|
2007-06-30 14:41:50 -04:00
|
|
|
#include "automation_line.h"
|
2007-07-06 23:19:04 -04:00
|
|
|
#include "control_point.h"
|
2005-11-14 11:24:21 -05:00
|
|
|
#include "canvas_impl.h"
|
|
|
|
#include "simplerect.h"
|
2008-12-23 16:05:50 -05:00
|
|
|
#include "interactive-item.h"
|
2009-05-30 14:25:59 -04:00
|
|
|
#include "editor_drag.h"
|
2009-06-08 15:28:51 -04:00
|
|
|
#include "midi_time_axis.h"
|
2009-07-03 18:42:22 -04:00
|
|
|
#include "editor_regions.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2008-02-02 12:22:04 -05:00
|
|
|
using namespace std;
|
2005-09-25 14:42:24 -04:00
|
|
|
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;
|
2008-04-03 17:47:47 -04:00
|
|
|
using namespace ArdourCanvas;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-12-23 21:17:47 -05:00
|
|
|
bool
|
|
|
|
Editor::track_canvas_scroll (GdkEventScroll* ev)
|
|
|
|
{
|
2006-01-20 19:11:03 -05:00
|
|
|
int x, y;
|
|
|
|
double wx, wy;
|
2008-09-10 11:03:30 -04:00
|
|
|
nframes64_t xdelta;
|
2008-01-10 16:20:59 -05:00
|
|
|
int direction = ev->direction;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-12-23 16:05:50 -05:00
|
|
|
Gnome::Canvas::Item* item = track_canvas->get_item_at(ev->x, ev->y);
|
|
|
|
InteractiveItem* interactive_item = dynamic_cast<InteractiveItem*>(item);
|
2008-12-23 20:24:49 -05:00
|
|
|
if (interactive_item) {
|
|
|
|
return interactive_item->on_event(reinterpret_cast<GdkEvent*>(ev));
|
2008-12-23 16:05:50 -05:00
|
|
|
}
|
2006-04-09 22:14:05 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
retry:
|
|
|
|
switch (direction) {
|
2005-12-23 21:17:47 -05:00
|
|
|
case GDK_SCROLL_UP:
|
2008-01-10 16:20:59 -05:00
|
|
|
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
|
2006-05-19 16:10:35 -04:00
|
|
|
//if (ev->state == GDK_CONTROL_MASK) {
|
2009-10-14 12:10:01 -04:00
|
|
|
/* XXX
|
2006-05-19 16:10:35 -04:00
|
|
|
the ev->x will be out of step with the canvas
|
2009-10-14 12:10:01 -04:00
|
|
|
if we're in mid zoom, so we have to get the damn mouse
|
2006-05-19 16:10:35 -04:00
|
|
|
pointer again
|
|
|
|
*/
|
2008-03-17 16:54:03 -04:00
|
|
|
track_canvas->get_pointer (x, y);
|
|
|
|
track_canvas->window_to_world (x, y, wx, wy);
|
2008-09-10 17:27:39 -04:00
|
|
|
|
2006-05-19 16:10:35 -04:00
|
|
|
GdkEvent event;
|
|
|
|
event.type = GDK_BUTTON_RELEASE;
|
|
|
|
event.button.x = wx;
|
|
|
|
event.button.y = wy;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
nframes64_t where = event_frame (&event, 0, 0);
|
2007-03-18 02:07:08 -04:00
|
|
|
temporal_zoom_to_frame (false, where);
|
2006-05-19 16:10:35 -04:00
|
|
|
return true;
|
2008-01-10 16:20:59 -05:00
|
|
|
} else if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
|
|
|
|
direction = GDK_SCROLL_LEFT;
|
|
|
|
goto retry;
|
|
|
|
} else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
|
2006-05-19 16:10:35 -04:00
|
|
|
if (!current_stepping_trackview) {
|
|
|
|
step_timeout = Glib::signal_timeout().connect (mem_fun(*this, &Editor::track_height_step_timeout), 500);
|
2009-07-09 13:58:13 -04:00
|
|
|
std::pair<TimeAxisView*, int> const p = trackview_by_y_position (ev->y + vertical_adjustment.get_value() - canvas_timebars_vsize);
|
2009-01-05 22:18:09 -05:00
|
|
|
current_stepping_trackview = p.first;
|
|
|
|
if (!current_stepping_trackview) {
|
2006-05-19 16:10:35 -04:00
|
|
|
return false;
|
|
|
|
}
|
2006-04-09 22:14:05 -04:00
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
last_track_height_step_timestamp = get_microseconds();
|
2006-05-19 16:10:35 -04:00
|
|
|
current_stepping_trackview->step_height (true);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
scroll_tracks_up_line ();
|
|
|
|
return true;
|
2006-04-09 22:14:05 -04:00
|
|
|
}
|
2006-05-19 16:10:35 -04:00
|
|
|
break;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2005-12-23 21:17:47 -05:00
|
|
|
case GDK_SCROLL_DOWN:
|
2008-01-10 16:20:59 -05:00
|
|
|
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
|
2006-05-19 16:10:35 -04:00
|
|
|
//if (ev->state == GDK_CONTROL_MASK) {
|
2008-03-17 16:54:03 -04:00
|
|
|
track_canvas->get_pointer (x, y);
|
|
|
|
track_canvas->window_to_world (x, y, wx, wy);
|
2008-09-10 17:27:39 -04:00
|
|
|
|
2006-05-19 16:10:35 -04:00
|
|
|
GdkEvent event;
|
|
|
|
event.type = GDK_BUTTON_RELEASE;
|
|
|
|
event.button.x = wx;
|
|
|
|
event.button.y = wy;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
nframes64_t where = event_frame (&event, 0, 0);
|
2007-03-18 02:07:08 -04:00
|
|
|
temporal_zoom_to_frame (true, where);
|
2006-05-19 16:10:35 -04:00
|
|
|
return true;
|
2008-01-10 16:20:59 -05:00
|
|
|
} else if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
|
|
|
|
direction = GDK_SCROLL_RIGHT;
|
|
|
|
goto retry;
|
|
|
|
} else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
|
2006-05-19 16:10:35 -04:00
|
|
|
if (!current_stepping_trackview) {
|
|
|
|
step_timeout = Glib::signal_timeout().connect (mem_fun(*this, &Editor::track_height_step_timeout), 500);
|
2009-07-09 13:58:13 -04:00
|
|
|
std::pair<TimeAxisView*, int> const p = trackview_by_y_position (ev->y + vertical_adjustment.get_value() - canvas_timebars_vsize);
|
2009-01-05 22:18:09 -05:00
|
|
|
current_stepping_trackview = p.first;
|
|
|
|
if (!current_stepping_trackview) {
|
2006-05-19 16:10:35 -04:00
|
|
|
return false;
|
|
|
|
}
|
2006-04-09 22:14:05 -04:00
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
last_track_height_step_timestamp = get_microseconds();
|
2006-05-19 16:10:35 -04:00
|
|
|
current_stepping_trackview->step_height (false);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
scroll_tracks_down_line ();
|
|
|
|
return true;
|
2006-01-20 19:11:03 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
break;
|
2006-05-19 16:10:35 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
case GDK_SCROLL_LEFT:
|
2008-01-15 12:23:57 -05:00
|
|
|
xdelta = (current_page_frames() / 8);
|
2008-01-10 16:20:59 -05:00
|
|
|
if (leftmost_frame > xdelta) {
|
|
|
|
reset_x_origin (leftmost_frame - xdelta);
|
|
|
|
} else {
|
|
|
|
reset_x_origin (0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_SCROLL_RIGHT:
|
2008-01-15 12:23:57 -05:00
|
|
|
xdelta = (current_page_frames() / 8);
|
2008-01-10 16:20:59 -05:00
|
|
|
if (max_frames - xdelta > leftmost_frame) {
|
|
|
|
reset_x_origin (leftmost_frame + xdelta);
|
|
|
|
} else {
|
|
|
|
reset_x_origin (max_frames - current_page_frames());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-12-23 21:17:47 -05:00
|
|
|
default:
|
2008-01-10 16:20:59 -05:00
|
|
|
/* what? */
|
2005-12-23 21:17:47 -05:00
|
|
|
break;
|
|
|
|
}
|
2009-06-10 21:05:01 -04:00
|
|
|
|
2005-12-23 21:17:47 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
2007-04-12 19:20:37 -04:00
|
|
|
Editor::track_canvas_scroll_event (GdkEventScroll *event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2008-03-17 16:54:03 -04:00
|
|
|
track_canvas->grab_focus();
|
2007-04-12 19:20:37 -04:00
|
|
|
track_canvas_scroll (event);
|
|
|
|
return false;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::track_canvas_button_press_event (GdkEventButton */*event*/)
|
2007-04-12 19:20:37 -04:00
|
|
|
{
|
2008-01-10 16:20:59 -05:00
|
|
|
selection->clear ();
|
2008-03-17 16:54:03 -04:00
|
|
|
track_canvas->grab_focus();
|
2007-04-12 19:20:37 -04:00
|
|
|
return false;
|
|
|
|
}
|
2005-12-23 21:17:47 -05:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
bool
|
|
|
|
Editor::track_canvas_button_release_event (GdkEventButton *event)
|
|
|
|
{
|
2009-05-30 14:25:59 -04:00
|
|
|
if (_drag) {
|
|
|
|
_drag->end_grab ((GdkEvent*) event);
|
|
|
|
delete _drag;
|
|
|
|
_drag = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-04-12 19:20:37 -04:00
|
|
|
return false;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::track_canvas_motion_notify_event (GdkEventMotion */*event*/)
|
2007-04-12 19:20:37 -04:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
/* keep those motion events coming */
|
2008-03-17 16:54:03 -04:00
|
|
|
track_canvas->get_pointer (x, y);
|
2007-04-12 19:20:37 -04:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::track_canvas_motion (GdkEvent *ev)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (verbose_cursor_visible) {
|
2008-10-03 14:24:38 -04:00
|
|
|
verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (ev->motion.x + 10);
|
|
|
|
verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (ev->motion.y + 10);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::typed_event (ArdourCanvas::Item* item, GdkEvent *event, ItemType type)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
gint ret = FALSE;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
ret = button_press_handler (item, event, type);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_handler (item, event, type);
|
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-05-30 14:25:59 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
ret = enter_handler (item, event, type);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
ret = leave_handler (item, event, type);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
2006-07-23 08:03:19 -04:00
|
|
|
Editor::canvas_region_view_event (GdkEvent *event, ArdourCanvas::Item* item, RegionView *rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-04-12 19:20:37 -04:00
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
if (!rv->sensitive ()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-12-29 19:34:21 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
clicked_regionview = rv;
|
|
|
|
clicked_control_point = 0;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_axisview = &rv->get_time_axis_view();
|
|
|
|
clicked_routeview = dynamic_cast<RouteTimeAxisView*>(clicked_axisview);
|
2005-09-25 14:42:24 -04:00
|
|
|
ret = button_press_handler (item, event, RegionItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_handler (item, event, RegionItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-05-30 14:25:59 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
2009-07-09 13:58:13 -04:00
|
|
|
set_entered_track (&rv->get_time_axis_view ());
|
2005-09-25 14:42:24 -04:00
|
|
|
set_entered_regionview (rv);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
2009-07-09 13:58:13 -04:00
|
|
|
set_entered_track (0);
|
2005-09-25 14:42:24 -04:00
|
|
|
set_entered_regionview (0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
2009-07-09 13:58:13 -04:00
|
|
|
Editor::canvas_stream_view_event (GdkEvent *event, ArdourCanvas::Item* item, RouteTimeAxisView *tv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 11:24:21 -05:00
|
|
|
bool ret = FALSE;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
clicked_regionview = 0;
|
|
|
|
clicked_control_point = 0;
|
2006-08-16 16:36:14 -04:00
|
|
|
clicked_axisview = tv;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_routeview = dynamic_cast<RouteTimeAxisView*>(tv);
|
2005-09-25 14:42:24 -04:00
|
|
|
ret = button_press_handler (item, event, StreamItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_handler (item, event, StreamItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-09-02 18:02:34 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
2008-01-10 16:20:59 -05:00
|
|
|
set_entered_track (tv);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
2009-07-09 13:58:13 -04:00
|
|
|
set_entered_track (0);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
2009-07-09 13:58:13 -04:00
|
|
|
Editor::canvas_automation_track_event (GdkEvent *event, ArdourCanvas::Item* item, AutomationTimeAxisView *atv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 11:24:21 -05:00
|
|
|
bool ret = false;
|
2007-04-12 19:20:37 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
clicked_regionview = 0;
|
|
|
|
clicked_control_point = 0;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_axisview = atv;
|
|
|
|
clicked_routeview = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
ret = button_press_handler (item, event, AutomationTrackItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_handler (item, event, AutomationTrackItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-05-30 14:25:59 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
ret = enter_handler (item, event, AutomationTrackItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
ret = leave_handler (item, event, AutomationTrackItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_fade_in_event (GdkEvent *event, ArdourCanvas::Item* item, AudioRegionView *rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
/* we handle only button 3 press/release events */
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (!rv->sensitive()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
clicked_regionview = rv;
|
|
|
|
clicked_control_point = 0;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_axisview = &rv->get_time_axis_view();
|
|
|
|
clicked_routeview = dynamic_cast<RouteTimeAxisView*>(clicked_axisview);
|
2005-09-25 14:42:24 -04:00
|
|
|
if (event->button.button == 3) {
|
|
|
|
return button_press_handler (item, event, FadeInItem);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
if (event->button.button == 3) {
|
|
|
|
return button_release_handler (item, event, FadeInItem);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* proxy for the regionview */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
return canvas_region_view_event (event, rv->get_canvas_group(), rv);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_fade_in_handle_event (GdkEvent *event, ArdourCanvas::Item* item, AudioRegionView *rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 11:24:21 -05:00
|
|
|
bool ret = false;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (!rv->sensitive()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
clicked_regionview = rv;
|
|
|
|
clicked_control_point = 0;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_axisview = &rv->get_time_axis_view();
|
|
|
|
clicked_routeview = dynamic_cast<RouteTimeAxisView*>(clicked_axisview);
|
2005-09-25 14:42:24 -04:00
|
|
|
ret = button_press_handler (item, event, FadeInHandleItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_handler (item, event, FadeInHandleItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-05-30 14:25:59 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
ret = enter_handler (item, event, FadeInHandleItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
ret = leave_handler (item, event, FadeInHandleItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_fade_out_event (GdkEvent *event, ArdourCanvas::Item* item, AudioRegionView *rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
/* we handle only button 3 press/release events */
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (!rv->sensitive()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
clicked_regionview = rv;
|
|
|
|
clicked_control_point = 0;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_axisview = &rv->get_time_axis_view();
|
|
|
|
clicked_routeview = dynamic_cast<RouteTimeAxisView*>(clicked_axisview);
|
2005-09-25 14:42:24 -04:00
|
|
|
if (event->button.button == 3) {
|
|
|
|
return button_press_handler (item, event, FadeOutItem);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
if (event->button.button == 3) {
|
|
|
|
return button_release_handler (item, event, FadeOutItem);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* proxy for the regionview */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
return canvas_region_view_event (event, rv->get_canvas_group(), rv);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_fade_out_handle_event (GdkEvent *event, ArdourCanvas::Item* item, AudioRegionView *rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 11:24:21 -05:00
|
|
|
bool ret = false;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (!rv->sensitive()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
clicked_regionview = rv;
|
|
|
|
clicked_control_point = 0;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_axisview = &rv->get_time_axis_view();
|
|
|
|
clicked_routeview = dynamic_cast<RouteTimeAxisView*>(clicked_axisview);
|
2005-09-25 14:42:24 -04:00
|
|
|
ret = button_press_handler (item, event, FadeOutHandleItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_handler (item, event, FadeOutHandleItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-05-30 14:25:59 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
ret = enter_handler (item, event, FadeOutHandleItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
ret = leave_handler (item, event, FadeOutHandleItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct DescendingRegionLayerSorter {
|
2006-08-29 17:21:48 -04:00
|
|
|
bool operator()(boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return a->layer() > b->layer();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_crossfade_view_event (GdkEvent* event, ArdourCanvas::Item* item, CrossfadeView* xfv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
/* we handle only button 3 press/release events */
|
|
|
|
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
clicked_crossfadeview = xfv;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_axisview = &clicked_crossfadeview->get_time_axis_view();
|
2005-09-25 14:42:24 -04:00
|
|
|
if (event->button.button == 3) {
|
|
|
|
return button_press_handler (item, event, CrossfadeViewItem);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
if (event->button.button == 3) {
|
2005-11-14 11:24:21 -05:00
|
|
|
bool ret = button_release_handler (item, event, CrossfadeViewItem);
|
2005-09-25 14:42:24 -04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
/* XXX do not forward double clicks */
|
|
|
|
|
|
|
|
if (event->type == GDK_2BUTTON_PRESS) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-02 19:55:09 -04:00
|
|
|
/* proxy for an underlying regionview */
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* XXX really need to check if we are in the name highlight,
|
|
|
|
and proxy to that when required.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
TimeAxisView& tv (xfv->get_time_axis_view());
|
|
|
|
AudioTimeAxisView* atv;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
if ((atv = dynamic_cast<AudioTimeAxisView*>(&tv)) != 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (atv->is_audio_track()) {
|
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<AudioPlaylist> pl;
|
|
|
|
if ((pl = boost::dynamic_pointer_cast<AudioPlaylist> (atv->get_diskstream()->playlist())) != 0) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
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
|
|
|
Playlist::RegionList* rl = pl->regions_at (event_frame (event));
|
|
|
|
if (!rl->empty()) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-02 19:55:09 -04:00
|
|
|
if (atv->layer_display() == Overlaid) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-02 19:55:09 -04:00
|
|
|
/* we're in overlaid mode; proxy to the uppermost region view */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-02 19:55:09 -04:00
|
|
|
DescendingRegionLayerSorter cmp;
|
|
|
|
rl->sort (cmp);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-02 19:55:09 -04:00
|
|
|
RegionView* rv = atv->view()->find_view (rl->front());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-02 19:55:09 -04:00
|
|
|
delete rl;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-02 19:55:09 -04:00
|
|
|
/* proxy */
|
|
|
|
return canvas_region_view_event (event, rv->get_canvas_group(), rv);
|
|
|
|
|
|
|
|
} else {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-09-02 19:55:09 -04:00
|
|
|
/* we're in stacked mode; proxy to the region view under the mouse */
|
|
|
|
|
|
|
|
/* XXX: FIXME: this is an evil hack; it assumes that any event for which
|
|
|
|
this proxy is being used has its GdkEvent laid out such that the y
|
|
|
|
member is in the same place as that for a GdkEventButton */
|
|
|
|
|
|
|
|
/* position of the event within the track */
|
|
|
|
double cx = event->button.x;
|
|
|
|
double cy = event->button.y;
|
|
|
|
atv->view()->canvas_item()->w2i (cx, cy);
|
|
|
|
|
|
|
|
/* hence layer that we're over */
|
|
|
|
double const c = atv->view()->child_height ();
|
|
|
|
layer_t const l = pl->top_layer () + 1 - (cy / c);
|
|
|
|
|
|
|
|
/* hence region */
|
|
|
|
Playlist::RegionList::iterator i = rl->begin();
|
|
|
|
while (i != rl->end() && (*i)->layer() != l) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i != rl->end()) {
|
|
|
|
RegionView* rv = atv->view()->find_view (*i);
|
|
|
|
delete rl;
|
|
|
|
|
|
|
|
/* proxy */
|
|
|
|
return canvas_region_view_event (event, rv->get_canvas_group(), rv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-12 17:23:01 -05:00
|
|
|
|
|
|
|
delete rl;
|
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
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_control_point_event (GdkEvent *event, ArdourCanvas::Item* item, ControlPoint* cp)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 11:24:21 -05:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
clicked_control_point = cp;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_axisview = &cp->line().trackview;
|
|
|
|
clicked_routeview = dynamic_cast<RouteTimeAxisView*>(clicked_axisview);
|
2005-11-14 11:24:21 -05:00
|
|
|
clicked_regionview = 0;
|
|
|
|
break;
|
|
|
|
|
2006-05-19 16:10:35 -04:00
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
break;
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-06-30 14:41:50 -04:00
|
|
|
return typed_event (item, event, ControlPointItem);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_line_event (GdkEvent *event, ArdourCanvas::Item* item, AutomationLine* al)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ItemType type;
|
|
|
|
|
|
|
|
if (dynamic_cast<AudioRegionGainLine*> (al) != 0) {
|
|
|
|
type = GainLineItem;
|
|
|
|
} else {
|
2007-06-30 14:41:50 -04:00
|
|
|
type = AutomationLineItem;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return typed_event (item, event, type);
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_selection_rect_event (GdkEvent *event, ArdourCanvas::Item* item, SelectionRect* rect)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 11:24:21 -05:00
|
|
|
bool ret = false;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
clicked_selection = rect->id;
|
|
|
|
ret = button_press_handler (item, event, SelectionItem);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_handler (item, event, SelectionItem);
|
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-05-30 14:25:59 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
/* Don't need these at the moment. */
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
ret = enter_handler (item, event, SelectionItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
ret = leave_handler (item, event, SelectionItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_selection_start_trim_event (GdkEvent *event, ArdourCanvas::Item* item, SelectionRect* rect)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 11:24:21 -05:00
|
|
|
bool ret = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
clicked_selection = rect->id;
|
|
|
|
ret = button_press_handler (item, event, StartSelectionTrimItem);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_handler (item, event, StartSelectionTrimItem);
|
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-05-30 14:25:59 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
ret = enter_handler (item, event, StartSelectionTrimItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
ret = leave_handler (item, event, StartSelectionTrimItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_selection_end_trim_event (GdkEvent *event, ArdourCanvas::Item* item, SelectionRect* rect)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 11:24:21 -05:00
|
|
|
bool ret = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
clicked_selection = rect->id;
|
|
|
|
ret = button_press_handler (item, event, EndSelectionTrimItem);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_handler (item, event, EndSelectionTrimItem);
|
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-05-30 14:25:59 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
ret = enter_handler (item, event, EndSelectionTrimItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
ret = leave_handler (item, event, EndSelectionTrimItem);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-28 12:06:08 -04:00
|
|
|
bool
|
|
|
|
Editor::canvas_frame_handle_event (GdkEvent* event, ArdourCanvas::Item* item, RegionView* rv)
|
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
/* frame handles are not active when in internal edit mode, because actual notes
|
|
|
|
might be in the area occupied by the handle - we want them to be editable as normal.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (internal_editing() || !rv->sensitive()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE: frame handles pretend to be the colored trim bar from an event handling
|
|
|
|
perspective. XXX change this ??
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
|
|
|
clicked_regionview = rv;
|
|
|
|
clicked_control_point = 0;
|
|
|
|
clicked_axisview = &clicked_regionview->get_time_axis_view();
|
|
|
|
clicked_routeview = dynamic_cast<RouteTimeAxisView*>(clicked_axisview);
|
|
|
|
ret = button_press_handler (item, event, RegionViewNameHighlight);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_handler (item, event, RegionViewNameHighlight);
|
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
ret = motion_handler (item, event);
|
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
ret = enter_handler (item, event, RegionViewNameHighlight);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
ret = leave_handler (item, event, RegionViewNameHighlight);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
2006-07-23 08:03:19 -04:00
|
|
|
Editor::canvas_region_view_name_highlight_event (GdkEvent* event, ArdourCanvas::Item* item, RegionView* rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 11:24:21 -05:00
|
|
|
bool ret = false;
|
2009-08-28 12:06:08 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (!rv->sensitive()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
2005-11-14 11:24:21 -05:00
|
|
|
clicked_regionview = rv;
|
2005-09-25 14:42:24 -04:00
|
|
|
clicked_control_point = 0;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_axisview = &clicked_regionview->get_time_axis_view();
|
|
|
|
clicked_routeview = dynamic_cast<RouteTimeAxisView*>(clicked_axisview);
|
2006-07-23 08:03:19 -04:00
|
|
|
ret = button_press_handler (item, event, RegionViewNameHighlight);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2006-07-23 08:03:19 -04:00
|
|
|
ret = button_release_handler (item, event, RegionViewNameHighlight);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-05-30 14:25:59 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
2006-07-23 08:03:19 -04:00
|
|
|
ret = enter_handler (item, event, RegionViewNameHighlight);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
2006-07-23 08:03:19 -04:00
|
|
|
ret = leave_handler (item, event, RegionViewNameHighlight);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
2006-08-01 15:18:12 -04:00
|
|
|
Editor::canvas_region_view_name_event (GdkEvent *event, ArdourCanvas::Item* item, RegionView* rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-14 11:24:21 -05:00
|
|
|
bool ret = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (!rv->sensitive()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (event->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
2005-11-14 11:24:21 -05:00
|
|
|
clicked_regionview = rv;
|
2005-09-25 14:42:24 -04:00
|
|
|
clicked_control_point = 0;
|
2009-07-09 13:58:13 -04:00
|
|
|
clicked_axisview = &clicked_regionview->get_time_axis_view();
|
|
|
|
clicked_routeview = dynamic_cast<RouteTimeAxisView*>(clicked_axisview);
|
2006-07-23 08:03:19 -04:00
|
|
|
ret = button_press_handler (item, event, RegionViewName);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2006-07-23 08:03:19 -04:00
|
|
|
ret = button_release_handler (item, event, RegionViewName);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2009-05-30 14:25:59 -04:00
|
|
|
ret = motion_handler (item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
2006-07-23 08:03:19 -04:00
|
|
|
ret = enter_handler (item, event, RegionViewName);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
2006-07-23 08:03:19 -04:00
|
|
|
ret = leave_handler (item, event, RegionViewName);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::canvas_marker_event (GdkEvent *event, ArdourCanvas::Item* item, Marker* /*marker*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return typed_event (item, event, MarkerItem);
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_marker_bar_event (GdkEvent *event, ArdourCanvas::Item* item)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return typed_event (item, event, MarkerBarItem);
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_range_marker_bar_event (GdkEvent *event, ArdourCanvas::Item* item)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return typed_event (item, event, RangeMarkerBarItem);
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_transport_marker_bar_event (GdkEvent *event, ArdourCanvas::Item* item)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return typed_event (item, event, TransportMarkerBarItem);
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_cd_marker_bar_event (GdkEvent *event, ArdourCanvas::Item* item)
|
|
|
|
{
|
|
|
|
return typed_event (item, event, CdMarkerBarItem);
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::canvas_tempo_marker_event (GdkEvent *event, ArdourCanvas::Item* item, TempoMarker* /*marker*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return typed_event (item, event, TempoMarkerItem);
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::canvas_meter_marker_event (GdkEvent *event, ArdourCanvas::Item* item, MeterMarker* /*marker*/)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return typed_event (item, event, MeterMarkerItem);
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_tempo_bar_event (GdkEvent *event, ArdourCanvas::Item* item)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return typed_event (item, event, TempoBarItem);
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_meter_bar_event (GdkEvent *event, ArdourCanvas::Item* item)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return typed_event (item, event, MeterBarItem);
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_playhead_cursor_event (GdkEvent *event, ArdourCanvas::Item* item)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return typed_event (item, event, PlayheadCursorItem);
|
|
|
|
}
|
|
|
|
|
2005-11-14 11:24:21 -05:00
|
|
|
bool
|
|
|
|
Editor::canvas_zoom_rect_event (GdkEvent *event, ArdourCanvas::Item* item)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
return typed_event (item, event, NoItem);
|
|
|
|
}
|
|
|
|
|
2009-09-08 17:45:44 -04:00
|
|
|
bool
|
|
|
|
Editor::canvas_note_event (GdkEvent *event, ArdourCanvas::Item* item)
|
|
|
|
{
|
|
|
|
if (!internal_editing()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return typed_event (item, event, NoteItem);
|
|
|
|
}
|
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const & /*c*/, int x, int y, guint /*time*/)
|
2009-06-08 15:28:51 -04:00
|
|
|
{
|
|
|
|
double wx;
|
|
|
|
double wy;
|
|
|
|
track_canvas->window_to_world (x, y, wx, wy);
|
|
|
|
|
|
|
|
GdkEvent event;
|
|
|
|
event.type = GDK_MOTION_NOTIFY;
|
|
|
|
event.button.x = wx;
|
|
|
|
event.button.y = wy;
|
|
|
|
/* assume we're dragging with button 1 */
|
|
|
|
event.motion.state = Gdk::BUTTON1_MASK;
|
|
|
|
|
|
|
|
if (_drag == 0) {
|
|
|
|
|
|
|
|
double px;
|
|
|
|
double py;
|
|
|
|
nframes64_t const pos = event_frame (&event, &px, &py);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
std::pair<TimeAxisView*, int> const tv = trackview_by_y_position (py);
|
2009-06-08 15:28:51 -04:00
|
|
|
if (tv.first == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (tv.first);
|
2009-06-08 15:28:51 -04:00
|
|
|
if (rtav == 0 || !rtav->is_track ()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
boost::shared_ptr<Region> region = _regions->get_dragged_region ();
|
2009-06-08 15:28:51 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<Region> region_copy = RegionFactory::create (region);
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
if (boost::dynamic_pointer_cast<AudioRegion> (region_copy) != 0 &&
|
2009-07-09 13:58:13 -04:00
|
|
|
dynamic_cast<AudioTimeAxisView*> (tv.first) == 0) {
|
2009-06-08 15:28:51 -04:00
|
|
|
|
|
|
|
/* audio -> non-audio */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
if (boost::dynamic_pointer_cast<MidiRegion> (region_copy) == 0 &&
|
2009-07-09 13:58:13 -04:00
|
|
|
dynamic_cast<MidiTimeAxisView*> (tv.first) != 0) {
|
2009-06-08 15:28:51 -04:00
|
|
|
|
|
|
|
/* MIDI -> non-MIDI */
|
|
|
|
return true;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-08 15:28:51 -04:00
|
|
|
_drag = new RegionInsertDrag (this, region_copy, rtav, pos);
|
|
|
|
_drag->start_grab (&event);
|
|
|
|
}
|
|
|
|
|
|
|
|
_drag->motion_handler (&event, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|