2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000-2001 Paul Davis
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
#include <pbd/error.h>
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/utils.h>
|
2006-08-09 21:22:45 -04:00
|
|
|
#include <pbd/memento_command.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#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"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "marker.h"
|
|
|
|
#include "streamview.h"
|
|
|
|
#include "region_gain_line.h"
|
|
|
|
#include "automation_time_axis.h"
|
|
|
|
#include "prompter.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "selection.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "editing.h"
|
|
|
|
#include "rgb_macros.h"
|
|
|
|
|
|
|
|
#include <ardour/types.h>
|
|
|
|
#include <ardour/route.h>
|
|
|
|
#include <ardour/audio_track.h>
|
2006-06-14 21:34:54 -04:00
|
|
|
#include <ardour/audio_diskstream.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/playlist.h>
|
|
|
|
#include <ardour/audioplaylist.h>
|
|
|
|
#include <ardour/audioregion.h>
|
2006-07-23 08:03:19 -04:00
|
|
|
#include <ardour/midi_region.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/dB.h>
|
|
|
|
#include <ardour/utils.h>
|
|
|
|
#include <ardour/region_factory.h>
|
|
|
|
|
|
|
|
#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 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Editing;
|
|
|
|
|
|
|
|
jack_nframes_t
|
|
|
|
Editor::event_frame (GdkEvent* event, double* pcx, double* pcy)
|
|
|
|
{
|
|
|
|
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:
|
2005-11-22 00:10:12 -05:00
|
|
|
track_canvas.w2c(event->button.x, event->button.y, *pcx, *pcy);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
2005-11-22 00:10:12 -05:00
|
|
|
track_canvas.w2c(event->motion.x, event->motion.y, *pcx, *pcy);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
2005-11-22 00:10:12 -05: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:
|
|
|
|
// track_canvas.w2c(event->key.x, event->key.y, *pcx, *pcy);
|
|
|
|
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.
|
|
|
|
*/
|
2006-01-02 15:27:51 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return pixel_to_frame (*pcx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::mouse_mode_toggled (MouseMode m)
|
|
|
|
{
|
|
|
|
if (ignore_mouse_mode_toggle) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (m) {
|
|
|
|
case MouseRange:
|
|
|
|
if (mouse_select_button.get_active()) {
|
|
|
|
set_mouse_mode (m);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseObject:
|
|
|
|
if (mouse_move_button.get_active()) {
|
|
|
|
set_mouse_mode (m);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseGain:
|
|
|
|
if (mouse_gain_button.get_active()) {
|
|
|
|
set_mouse_mode (m);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseZoom:
|
|
|
|
if (mouse_zoom_button.get_active()) {
|
|
|
|
set_mouse_mode (m);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseTimeFX:
|
|
|
|
if (mouse_timefx_button.get_active()) {
|
|
|
|
set_mouse_mode (m);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseAudition:
|
|
|
|
if (mouse_audition_button.get_active()) {
|
|
|
|
set_mouse_mode (m);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_mouse_mode (MouseMode m, bool force)
|
|
|
|
{
|
|
|
|
if (drag_info.item) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-24 18:43:15 -04:00
|
|
|
if (!force && m == mouse_mode) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mouse_mode = m;
|
|
|
|
|
|
|
|
instant_save ();
|
|
|
|
|
|
|
|
if (mouse_mode != MouseRange) {
|
|
|
|
|
|
|
|
/* in all modes except range, hide the range selection,
|
|
|
|
show the object (region) selection.
|
|
|
|
*/
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
(*i)->set_should_show_selection (true);
|
|
|
|
}
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
(*i)->hide_selection ();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2006-02-15 07:15:29 -05:00
|
|
|
/*
|
|
|
|
in range mode,show the range selection.
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
2006-06-21 14:14:45 -04:00
|
|
|
if ((*i)->get_selected()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
(*i)->show_selection (selection->time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX the hack of unsetting all other buttongs should go
|
|
|
|
away once GTK2 allows us to use regular radio buttons drawn like
|
|
|
|
normal buttons, rather than my silly GroupedButton hack.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ignore_mouse_mode_toggle = true;
|
|
|
|
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseRange:
|
|
|
|
mouse_select_button.set_active (true);
|
|
|
|
current_canvas_cursor = selector_cursor;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseObject:
|
|
|
|
mouse_move_button.set_active (true);
|
|
|
|
current_canvas_cursor = grabber_cursor;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseGain:
|
|
|
|
mouse_gain_button.set_active (true);
|
|
|
|
current_canvas_cursor = cross_hair_cursor;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseZoom:
|
|
|
|
mouse_zoom_button.set_active (true);
|
|
|
|
current_canvas_cursor = zoom_cursor;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseTimeFX:
|
|
|
|
mouse_timefx_button.set_active (true);
|
|
|
|
current_canvas_cursor = time_fx_cursor; // just use playhead
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseAudition:
|
|
|
|
mouse_audition_button.set_active (true);
|
|
|
|
current_canvas_cursor = speaker_cursor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ignore_mouse_mode_toggle = false;
|
|
|
|
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor(*current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::step_mouse_mode (bool next)
|
|
|
|
{
|
|
|
|
switch (current_mouse_mode()) {
|
|
|
|
case MouseObject:
|
|
|
|
if (next) set_mouse_mode (MouseRange);
|
|
|
|
else set_mouse_mode (MouseTimeFX);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
if (next) set_mouse_mode (MouseZoom);
|
|
|
|
else set_mouse_mode (MouseObject);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseZoom:
|
|
|
|
if (next) set_mouse_mode (MouseGain);
|
|
|
|
else set_mouse_mode (MouseRange);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseGain:
|
|
|
|
if (next) set_mouse_mode (MouseTimeFX);
|
|
|
|
else set_mouse_mode (MouseZoom);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseTimeFX:
|
|
|
|
if (next) set_mouse_mode (MouseAudition);
|
|
|
|
else set_mouse_mode (MouseGain);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseAudition:
|
|
|
|
if (next) set_mouse_mode (MouseObject);
|
|
|
|
else set_mouse_mode (MouseTimeFX);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
void
|
|
|
|
Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-06-14 21:34:54 -04:00
|
|
|
bool commit = false;
|
2006-06-13 03:27:52 -04:00
|
|
|
bool c1;
|
|
|
|
bool c2;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* in object/audition/timefx 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.
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
note: not dbl-click or triple-click
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
if (((mouse_mode != MouseObject) &&
|
|
|
|
(mouse_mode != MouseAudition || item_type != RegionItem) &&
|
|
|
|
(mouse_mode != MouseTimeFX || item_type != RegionItem)) ||
|
|
|
|
(event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE || event->button.button > 3)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Selection::Operation op = Keyboard::selection_type (event->button.state);
|
|
|
|
bool press = (event->type == GDK_BUTTON_PRESS);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
begin_reversible_command (_("select on click"));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
|
|
|
c1 = set_selected_track_from_click (press, op, true, true);
|
|
|
|
c2 = set_selected_regionview_from_click (press, op, true);
|
|
|
|
commit = (c1 || c2);
|
|
|
|
break;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
|
|
|
case RegionViewName:
|
2006-06-13 03:27:52 -04:00
|
|
|
c1 = set_selected_track_from_click (press, op, true, true);
|
|
|
|
c2 = set_selected_regionview_from_click (press, op, true);
|
|
|
|
commit = (c1 || c2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GainAutomationControlPointItem:
|
|
|
|
case PanAutomationControlPointItem:
|
|
|
|
case RedirectAutomationControlPointItem:
|
|
|
|
c1 = set_selected_track_from_click (press, op, true, true);
|
|
|
|
c2 = set_selected_control_point_from_click (press, op, false);
|
|
|
|
commit = (c1 || c2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case StreamItem:
|
|
|
|
commit = set_selected_track_from_click (press, op, true, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AutomationTrackItem:
|
|
|
|
commit = set_selected_track_from_click (press, op, true, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-06-13 03:27:52 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#define SELECT_TRACK_FROM_CANVAS_IN_RANGE_MODE
|
|
|
|
#ifdef SELECT_TRACK_FROM_CANVAS_IN_RANGE_MODE
|
|
|
|
/* in range mode, button 1/2/3 press potentially selects a track */
|
|
|
|
|
|
|
|
if (mouse_mode == MouseRange &&
|
|
|
|
event->type == GDK_BUTTON_PRESS &&
|
|
|
|
event->button.button <= 3) {
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case StreamItem:
|
|
|
|
case RegionItem:
|
|
|
|
case AutomationTrackItem:
|
2006-06-13 03:27:52 -04:00
|
|
|
commit = set_selected_track_from_click (press, op, true, true);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2006-06-13 03:27:52 -04:00
|
|
|
if (commit) {
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
|
|
|
{
|
|
|
|
jack_nframes_t where = event_frame (event, 0, 0);
|
|
|
|
|
|
|
|
track_canvas.grab_focus();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
if (session && session->actively_recording()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
button_selection (item, event, item_type);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (drag_info.item == 0 &&
|
|
|
|
(Keyboard::is_delete_event (&event->button) ||
|
|
|
|
Keyboard::is_context_menu_event (&event->button) ||
|
|
|
|
Keyboard::is_edit_event (&event->button))) {
|
|
|
|
|
|
|
|
/* handled by button release */
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (event->button.button) {
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
if (event->type == GDK_BUTTON_PRESS) {
|
|
|
|
|
|
|
|
if (drag_info.item) {
|
2005-11-12 22:53:51 -05:00
|
|
|
drag_info.item->ungrab (event->button.time);
|
2005-09-25 14:42:24 -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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case EditCursorItem:
|
|
|
|
case PlayheadCursorItem:
|
|
|
|
start_cursor_grab (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case MarkerItem:
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state,
|
|
|
|
Keyboard::ModifierMask(Keyboard::Control|Keyboard::Shift))) {
|
|
|
|
hide_marker (item, event);
|
|
|
|
} else {
|
|
|
|
start_marker_grab (item, event);
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case TempoMarkerItem:
|
2006-03-05 14:39:16 -05:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::Control)) {
|
|
|
|
start_tempo_marker_copy_grab (item, event);
|
|
|
|
} else {
|
|
|
|
start_tempo_marker_grab (item, event);
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case MeterMarkerItem:
|
2006-03-05 14:39:16 -05:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::Control)) {
|
|
|
|
start_meter_marker_copy_grab (item, event);
|
|
|
|
} else {
|
|
|
|
start_meter_marker_grab (item, event);
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case TempoBarItem:
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case MeterBarItem:
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case RangeMarkerBarItem:
|
|
|
|
start_range_markerbar_op (item, event, CreateRangeMarker);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2006-06-13 03:27:52 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case TransportMarkerBarItem:
|
|
|
|
start_range_markerbar_op (item, event, CreateTransportMarker);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseRange:
|
|
|
|
switch (item_type) {
|
|
|
|
case StartSelectionTrimItem:
|
|
|
|
start_selection_op (item, event, SelectionStartTrim);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EndSelectionTrimItem:
|
|
|
|
start_selection_op (item, event, SelectionEndTrim);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionItem:
|
|
|
|
if (Keyboard::modifier_state_contains
|
|
|
|
(event->button.state, Keyboard::ModifierMask(Keyboard::Alt))) {
|
|
|
|
// contains and not equals because I can't use alt as a modifier alone.
|
|
|
|
start_selection_grab (item, event);
|
|
|
|
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) {
|
|
|
|
/* grab selection for moving */
|
|
|
|
start_selection_op (item, event, SelectionMove);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* this was debated, but decided the more common action was to
|
|
|
|
make a new selection */
|
|
|
|
start_selection_op (item, event, CreateSelection);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
start_selection_op (item, event, CreateSelection);
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseObject:
|
|
|
|
if (Keyboard::modifier_state_contains (event->button.state,
|
|
|
|
Keyboard::ModifierMask(Keyboard::Control|Keyboard::Alt))
|
|
|
|
&& event->type == GDK_BUTTON_PRESS) {
|
|
|
|
|
|
|
|
start_rubberband_select (item, event);
|
|
|
|
|
|
|
|
} else if (event->type == GDK_BUTTON_PRESS) {
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case FadeInHandleItem:
|
|
|
|
start_fade_in_grab (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case FadeOutHandleItem:
|
|
|
|
start_fade_out_grab (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case RegionItem:
|
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::Control)) {
|
|
|
|
start_region_copy_grab (item, event);
|
|
|
|
} else if (Keyboard::the_keyboard().key_is_down (GDK_b)) {
|
|
|
|
start_region_brush_grab (item, event);
|
|
|
|
} else {
|
|
|
|
start_region_grab (item, event);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
2005-09-25 14:42:24 -04:00
|
|
|
start_trim (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
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
|
|
|
/* rename happens on edit clicks */
|
|
|
|
start_trim (clicked_regionview->get_name_highlight(), event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GainAutomationControlPointItem:
|
|
|
|
case PanAutomationControlPointItem:
|
|
|
|
case RedirectAutomationControlPointItem:
|
|
|
|
start_control_point_grab (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GainAutomationLineItem:
|
|
|
|
case PanAutomationLineItem:
|
|
|
|
case RedirectAutomationLineItem:
|
|
|
|
start_line_grab_from_line (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case StreamItem:
|
|
|
|
case AutomationTrackItem:
|
|
|
|
start_rubberband_select (item, event);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* <CMT Additions> */
|
|
|
|
case ImageFrameHandleStartItem:
|
|
|
|
imageframe_start_handle_op(item, event) ;
|
2006-03-07 21:50:53 -05:00
|
|
|
return(true) ;
|
2005-09-25 14:42:24 -04:00
|
|
|
break ;
|
|
|
|
case ImageFrameHandleEndItem:
|
|
|
|
imageframe_end_handle_op(item, event) ;
|
2006-03-07 21:50:53 -05:00
|
|
|
return(true) ;
|
2005-09-25 14:42:24 -04:00
|
|
|
break ;
|
|
|
|
case MarkerViewHandleStartItem:
|
|
|
|
markerview_item_start_handle_op(item, event) ;
|
2006-03-07 21:50:53 -05:00
|
|
|
return(true) ;
|
2005-09-25 14:42:24 -04:00
|
|
|
break ;
|
|
|
|
case MarkerViewHandleEndItem:
|
|
|
|
markerview_item_end_handle_op(item, event) ;
|
2006-03-07 21:50:53 -05:00
|
|
|
return(true) ;
|
2005-09-25 14:42:24 -04:00
|
|
|
break ;
|
|
|
|
/* </CMT Additions> */
|
|
|
|
|
|
|
|
/* <CMT Additions> */
|
|
|
|
case MarkerViewItem:
|
|
|
|
start_markerview_grab(item, event) ;
|
|
|
|
break ;
|
|
|
|
case ImageFrameItem:
|
|
|
|
start_imageframe_grab(item, event) ;
|
|
|
|
break ;
|
|
|
|
/* </CMT Additions> */
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
case MarkerBarItem:
|
|
|
|
|
|
|
|
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
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseGain:
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
|
|
|
// start_line_grab_from_regionview (item, event);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GainControlPointItem:
|
|
|
|
start_control_point_grab (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case GainLineItem:
|
|
|
|
start_line_grab_from_line (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case GainAutomationControlPointItem:
|
|
|
|
case PanAutomationControlPointItem:
|
|
|
|
case RedirectAutomationControlPointItem:
|
|
|
|
start_control_point_grab (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case GainAutomationControlPointItem:
|
|
|
|
case PanAutomationControlPointItem:
|
|
|
|
case RedirectAutomationControlPointItem:
|
|
|
|
start_control_point_grab (item, event);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GainAutomationLineItem:
|
|
|
|
case PanAutomationLineItem:
|
|
|
|
case RedirectAutomationLineItem:
|
|
|
|
start_line_grab_from_line (item, event);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RegionItem:
|
|
|
|
// XXX need automation mode to identify which
|
|
|
|
// line to use
|
|
|
|
// start_line_grab_from_regionview (item, event);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseZoom:
|
|
|
|
if (event->type == GDK_BUTTON_PRESS) {
|
|
|
|
start_mouse_zoom (item, event);
|
|
|
|
}
|
|
|
|
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseTimeFX:
|
|
|
|
if (item_type == RegionItem) {
|
|
|
|
start_time_fx (item, event);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseAudition:
|
|
|
|
/* handled in release */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseObject:
|
|
|
|
if (event->type == GDK_BUTTON_PRESS) {
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::Control)) {
|
|
|
|
start_region_copy_grab (item, event);
|
|
|
|
} else {
|
|
|
|
start_region_grab (item, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case GainAutomationControlPointItem:
|
|
|
|
case PanAutomationControlPointItem:
|
|
|
|
case RedirectAutomationControlPointItem:
|
|
|
|
start_control_point_grab (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (item_type) {
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
2005-09-25 14:42:24 -04:00
|
|
|
start_trim (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
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
|
|
|
start_trim (clicked_regionview->get_name_highlight(), event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
if (event->type == GDK_BUTTON_PRESS) {
|
|
|
|
/* relax till release */
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case MouseZoom:
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) {
|
|
|
|
temporal_zoom_session();
|
|
|
|
} else {
|
|
|
|
temporal_zoom_to_frame (true, event_frame(event));
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseZoom:
|
|
|
|
//temporal_zoom_to_frame (true, where);
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) {
|
|
|
|
temporal_zoom_to_frame (true, where);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
temporal_zoom_step (true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
|
2006-03-12 11:47:49 -05:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::Alt))) {
|
2005-09-25 14:42:24 -04:00
|
|
|
scroll_backward (0.6f);
|
2006-03-12 11:19:03 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else if (Keyboard::no_modifier_keys_pressed (&event->button)) {
|
|
|
|
scroll_tracks_up_line ();
|
|
|
|
} else {
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) {
|
2006-08-16 16:36:14 -04:00
|
|
|
if (clicked_axisview) {
|
2005-09-25 14:42:24 -04:00
|
|
|
if (!current_stepping_trackview) {
|
2005-10-26 21:10:36 -04:00
|
|
|
step_timeout = Glib::signal_timeout().connect (mem_fun(*this, &Editor::track_height_step_timeout), 500);
|
2006-08-16 16:36:14 -04:00
|
|
|
current_stepping_trackview = clicked_axisview;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
gettimeofday (&last_track_height_step_timestamp, 0);
|
|
|
|
current_stepping_trackview->step_height (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) {
|
|
|
|
temporal_zoom_to_frame (true, where);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseZoom:
|
|
|
|
// temporal_zoom_to_frame (false, where);
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) {
|
|
|
|
temporal_zoom_to_frame (false, where);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
temporal_zoom_step (false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
|
2006-03-12 11:47:49 -05:00
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::Alt))) {
|
2005-09-25 14:42:24 -04:00
|
|
|
scroll_forward (0.6f);
|
2006-03-12 11:19:03 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else if (Keyboard::no_modifier_keys_pressed (&event->button)) {
|
|
|
|
scroll_tracks_down_line ();
|
|
|
|
} else {
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) {
|
2006-08-16 16:36:14 -04:00
|
|
|
if (clicked_axisview) {
|
2005-09-25 14:42:24 -04:00
|
|
|
if (!current_stepping_trackview) {
|
2005-10-26 21:10:36 -04:00
|
|
|
step_timeout = Glib::signal_timeout().connect (mem_fun(*this, &Editor::track_height_step_timeout), 500);
|
2006-08-16 16:36:14 -04:00
|
|
|
current_stepping_trackview = clicked_axisview;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
gettimeofday (&last_track_height_step_timestamp, 0);
|
|
|
|
current_stepping_trackview->step_height (false);
|
|
|
|
}
|
|
|
|
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) {
|
|
|
|
temporal_zoom_to_frame (false, where);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
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
|
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
|
|
|
{
|
|
|
|
jack_nframes_t where = event_frame (event, 0, 0);
|
|
|
|
|
|
|
|
/* no action if we're recording */
|
|
|
|
|
|
|
|
if (session && session->actively_recording()) {
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* first, see if we're finishing a drag ... */
|
|
|
|
|
|
|
|
if (drag_info.item) {
|
|
|
|
if (end_grab (item, event)) {
|
|
|
|
/* grab dragged, so do nothing else */
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
button_selection (item, event, item_type);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* edit events get handled here */
|
|
|
|
|
|
|
|
if (drag_info.item == 0 && Keyboard::is_edit_event (&event->button)) {
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
|
|
|
edit_region ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TempoMarkerItem:
|
|
|
|
edit_tempo_marker (item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MeterMarkerItem:
|
|
|
|
edit_meter_marker (item);
|
|
|
|
break;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
|
|
|
|
if (drag_info.item == 0) {
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
case StreamItem:
|
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false, where);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RegionItem:
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
|
|
|
case RegionViewName:
|
2005-09-25 14:42:24 -04:00
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false, where);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionItem:
|
|
|
|
popup_track_context_menu (1, event->button.time, item_type, true, where);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AutomationTrackItem:
|
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false, where);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MarkerBarItem:
|
|
|
|
case RangeMarkerBarItem:
|
|
|
|
case TransportMarkerBarItem:
|
|
|
|
case TempoBarItem:
|
|
|
|
case MeterBarItem:
|
|
|
|
popup_ruler_menu (pixel_to_frame(event->button.x), item_type);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MarkerItem:
|
|
|
|
marker_context_menu (&event->button, item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TempoMarkerItem:
|
|
|
|
tm_marker_context_menu (&event->button, item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MeterMarkerItem:
|
|
|
|
tm_marker_context_menu (&event->button, item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CrossfadeViewItem:
|
|
|
|
popup_track_context_menu (1, event->button.time, item_type, false, where);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* <CMT Additions> */
|
|
|
|
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 ;
|
|
|
|
/* <CMT Additions> */
|
|
|
|
|
|
|
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
if (drag_info.item == 0 && Keyboard::is_delete_event (&event->button)) {
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case TempoMarkerItem:
|
|
|
|
remove_tempo_marker (item);
|
|
|
|
break;
|
|
|
|
|
|
|
|
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:
|
|
|
|
if (mouse_mode == MouseObject) {
|
|
|
|
remove_clicked_region ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GainControlPointItem:
|
|
|
|
if (mouse_mode == MouseGain) {
|
|
|
|
remove_gain_control_point (item, event);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GainAutomationControlPointItem:
|
|
|
|
case PanAutomationControlPointItem:
|
|
|
|
case RedirectAutomationControlPointItem:
|
|
|
|
remove_control_point (item, event);
|
|
|
|
break;
|
|
|
|
|
|
|
|
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 EditCursorItem:
|
|
|
|
case PlayheadCursorItem:
|
|
|
|
case MarkerItem:
|
|
|
|
case GainLineItem:
|
|
|
|
case GainAutomationLineItem:
|
|
|
|
case PanAutomationLineItem:
|
|
|
|
case RedirectAutomationLineItem:
|
|
|
|
case StartSelectionTrimItem:
|
|
|
|
case EndSelectionTrimItem:
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case MarkerBarItem:
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (where, 0, true);
|
|
|
|
}
|
|
|
|
mouse_add_new_marker (where);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case TempoBarItem:
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (where);
|
|
|
|
}
|
|
|
|
mouse_add_new_tempo_event (where);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case MeterBarItem:
|
|
|
|
mouse_add_new_meter_event (pixel_to_frame (event->button.x));
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseObject:
|
|
|
|
switch (item_type) {
|
|
|
|
case AutomationTrackItem:
|
2006-08-16 16:36:14 -04:00
|
|
|
dynamic_cast<AutomationTimeAxisView*>(clicked_axisview)->add_automation_event
|
2005-09-25 14:42:24 -04:00
|
|
|
(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;
|
|
|
|
|
|
|
|
case MouseGain:
|
2006-08-01 13:19:38 -04:00
|
|
|
// Gain only makes sense for audio regions
|
|
|
|
if ( ! dynamic_cast<AudioRegionView*>(clicked_regionview))
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
2006-07-23 08:03:19 -04:00
|
|
|
dynamic_cast<AudioRegionView*>(clicked_regionview)->add_gain_point_event (item, event);
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AutomationTrackItem:
|
2006-08-16 16:36:14 -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;
|
|
|
|
|
|
|
|
case MouseAudition:
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
|
|
|
audition_selected_region ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
switch (mouse_mode) {
|
|
|
|
|
|
|
|
case MouseObject:
|
|
|
|
switch (item_type) {
|
|
|
|
case RegionItem:
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) {
|
|
|
|
raise_region ();
|
|
|
|
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::Shift|Keyboard::Alt))) {
|
|
|
|
lower_region ();
|
|
|
|
} else {
|
|
|
|
// Button2 click is unused
|
|
|
|
}
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
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
|
2005-11-23 12:21:12 -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;
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case GainControlPointItem:
|
|
|
|
if (mouse_mode == MouseGain) {
|
2006-03-07 21:50:53 -05:00
|
|
|
cp = static_cast<ControlPoint*>(item->get_data ("control_point"));
|
2005-09-25 14:42:24 -04:00
|
|
|
cp->set_visible (true);
|
|
|
|
|
|
|
|
double at_x, at_y;
|
|
|
|
at_x = cp->get_x();
|
|
|
|
at_y = cp->get_y ();
|
2005-11-12 22:53:51 -05:00
|
|
|
cp->item->i2w (at_x, at_y);
|
2005-09-25 14:42:24 -04:00
|
|
|
at_x += 20.0;
|
|
|
|
at_y += 20.0;
|
|
|
|
|
|
|
|
fraction = 1.0 - (cp->get_y() / cp->line.height());
|
|
|
|
|
|
|
|
set_verbose_canvas_cursor (cp->line.get_verbose_cursor_string (fraction), at_x, at_y);
|
|
|
|
show_verbose_canvas_cursor ();
|
|
|
|
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*fader_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GainAutomationControlPointItem:
|
|
|
|
case PanAutomationControlPointItem:
|
|
|
|
case RedirectAutomationControlPointItem:
|
2006-03-07 21:50:53 -05:00
|
|
|
cp = static_cast<ControlPoint*>(item->get_data ("control_point"));
|
2005-09-25 14:42:24 -04:00
|
|
|
cp->set_visible (true);
|
|
|
|
|
|
|
|
double at_x, at_y;
|
|
|
|
at_x = cp->get_x();
|
|
|
|
at_y = cp->get_y ();
|
2005-11-12 22:53:51 -05:00
|
|
|
cp->item->i2w (at_x, at_y);
|
2005-09-25 14:42:24 -04:00
|
|
|
at_x += 20.0;
|
|
|
|
at_y += 20.0;
|
|
|
|
|
|
|
|
fraction = 1.0 - (cp->get_y() / cp->line.height());
|
|
|
|
|
|
|
|
set_verbose_canvas_cursor (cp->line.get_verbose_cursor_string (fraction), at_x, at_y);
|
|
|
|
show_verbose_canvas_cursor ();
|
|
|
|
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*fader_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GainLineItem:
|
|
|
|
if (mouse_mode == MouseGain) {
|
2005-11-27 17:35:04 -05:00
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
|
|
|
if (line)
|
|
|
|
line->property_fill_color_rgba() = color_map[cEnteredGainLine];
|
2005-09-25 14:42:24 -04:00
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*fader_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GainAutomationLineItem:
|
|
|
|
case RedirectAutomationLineItem:
|
|
|
|
case PanAutomationLineItem:
|
2005-11-27 17:35:04 -05:00
|
|
|
{
|
|
|
|
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
|
|
|
|
if (line)
|
|
|
|
line->property_fill_color_rgba() = color_map[cEnteredAutomationLine];
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*fader_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
2005-09-25 14:42:24 -04:00
|
|
|
if (is_drawable() && mouse_mode == MouseObject) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*trimmer_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case StartSelectionTrimItem:
|
|
|
|
case EndSelectionTrimItem:
|
|
|
|
/* <CMT Additions> */
|
|
|
|
case ImageFrameHandleStartItem:
|
|
|
|
case ImageFrameHandleEndItem:
|
|
|
|
case MarkerViewHandleStartItem:
|
|
|
|
case MarkerViewHandleEndItem:
|
|
|
|
/* </CMT Additions> */
|
|
|
|
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*trimmer_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EditCursorItem:
|
|
|
|
case PlayheadCursorItem:
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*grabber_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
|
|
|
|
|
|
|
/* 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()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*trimmer_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case AutomationTrackItem:
|
|
|
|
if (is_drawable()) {
|
2005-10-28 18:19:45 -04:00
|
|
|
Gdk::Cursor *cursor;
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseRange:
|
|
|
|
cursor = selector_cursor;
|
|
|
|
break;
|
|
|
|
case MouseZoom:
|
|
|
|
cursor = zoom_cursor;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cursor = cross_hair_cursor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
AutomationTimeAxisView* atv;
|
2005-11-28 17:36:26 -05:00
|
|
|
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:
|
|
|
|
case MeterBarItem:
|
|
|
|
case TempoBarItem:
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
time_canvas.get_window()->set_cursor (*timebar_cursor);
|
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;
|
|
|
|
}
|
|
|
|
marker->set_color_rgba (color_map[cEnteredMarker]);
|
|
|
|
// fall through
|
|
|
|
case MeterMarkerItem:
|
|
|
|
case TempoMarkerItem:
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
time_canvas.get_window()->set_cursor (*timebar_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FadeInHandleItem:
|
|
|
|
case FadeOutHandleItem:
|
|
|
|
if (mouse_mode == MouseObject) {
|
2005-11-27 17:35:04 -05:00
|
|
|
ArdourCanvas::SimpleRect *rect = dynamic_cast<ArdourCanvas::SimpleRect *> (item);
|
|
|
|
if (rect) {
|
|
|
|
rect->property_fill_color_rgba() = 0;
|
|
|
|
rect->property_outline_pixels() = 1;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* second pass to handle entered track status in a comprehensible way.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case GainLineItem:
|
|
|
|
case GainAutomationLineItem:
|
|
|
|
case RedirectAutomationLineItem:
|
|
|
|
case PanAutomationLineItem:
|
|
|
|
case GainControlPointItem:
|
|
|
|
case GainAutomationControlPointItem:
|
|
|
|
case PanAutomationControlPointItem:
|
|
|
|
case RedirectAutomationControlPointItem:
|
|
|
|
/* these do not affect the current entered track state */
|
|
|
|
clear_entered_track = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AutomationTrackItem:
|
|
|
|
/* handled above already */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
set_entered_track (0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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
|
2005-11-23 12:21:12 -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;
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case GainControlPointItem:
|
|
|
|
case GainAutomationControlPointItem:
|
|
|
|
case PanAutomationControlPointItem:
|
|
|
|
case RedirectAutomationControlPointItem:
|
2005-11-28 17:36:26 -05:00
|
|
|
cp = reinterpret_cast<ControlPoint*>(item->get_data ("control_point"));
|
2005-09-25 14:42:24 -04:00
|
|
|
if (cp->line.npoints() > 1) {
|
|
|
|
if (!cp->selected) {
|
|
|
|
cp->set_visible (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
hide_verbose_canvas_cursor ();
|
|
|
|
break;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
2005-09-25 14:42:24 -04:00
|
|
|
case StartSelectionTrimItem:
|
|
|
|
case EndSelectionTrimItem:
|
|
|
|
case EditCursorItem:
|
|
|
|
case PlayheadCursorItem:
|
|
|
|
/* <CMT Additions> */
|
|
|
|
case ImageFrameHandleStartItem:
|
|
|
|
case ImageFrameHandleEndItem:
|
|
|
|
case MarkerViewHandleStartItem:
|
|
|
|
case MarkerViewHandleEndItem:
|
|
|
|
/* </CMT Additions> */
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GainLineItem:
|
|
|
|
case GainAutomationLineItem:
|
|
|
|
case RedirectAutomationLineItem:
|
|
|
|
case PanAutomationLineItem:
|
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()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_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 */
|
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) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RangeMarkerBarItem:
|
|
|
|
case TransportMarkerBarItem:
|
|
|
|
case MeterBarItem:
|
|
|
|
case TempoBarItem:
|
|
|
|
case MarkerBarItem:
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
time_canvas.get_window()->set_cursor (*timebar_cursor);
|
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;
|
|
|
|
}
|
|
|
|
loc = find_location_from_marker (marker, is_start);
|
|
|
|
if (loc) location_flags_changed (loc, this);
|
|
|
|
// fall through
|
|
|
|
case MeterMarkerItem:
|
|
|
|
case TempoMarkerItem:
|
|
|
|
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
time_canvas.get_window()->set_cursor (*timebar_cursor);
|
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;
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AutomationTrackItem:
|
|
|
|
if (is_drawable()) {
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*current_canvas_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
clear_entered_track = true;
|
2005-10-09 01:03:29 -04:00
|
|
|
Glib::signal_idle().connect (mem_fun(*this, &Editor::left_automation_track));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-03-07 21:50:53 -05:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
Editor::left_automation_track ()
|
|
|
|
{
|
|
|
|
if (clear_entered_track) {
|
|
|
|
set_entered_track (0);
|
|
|
|
clear_entered_track = false;
|
|
|
|
}
|
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
|
2006-05-17 22:19:27 -04:00
|
|
|
Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type, bool from_autoscroll)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
gint x, y;
|
|
|
|
|
|
|
|
/* We call this so that MOTION_NOTIFY events continue to be
|
|
|
|
delivered to the canvas. We need to do this because we set
|
2005-09-25 16:33:00 -04:00
|
|
|
Gdk::POINTER_MOTION_HINT_MASK on the canvas. This reduces
|
2005-09-25 14:42:24 -04:00
|
|
|
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
|
|
|
|
event might do, its a good tradeoff.
|
|
|
|
*/
|
|
|
|
|
2005-10-26 21:10:36 -04:00
|
|
|
track_canvas.get_pointer (x, y);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (current_stepping_trackview) {
|
|
|
|
/* don't keep the persistent stepped trackview if the mouse moves */
|
|
|
|
current_stepping_trackview = 0;
|
|
|
|
step_timeout.disconnect ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (session && session->actively_recording()) {
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2006-05-17 22:19:27 -04:00
|
|
|
drag_info.item_type = item_type;
|
2005-09-25 14:42:24 -04:00
|
|
|
drag_info.current_pointer_frame = event_frame (event, &drag_info.current_pointer_x,
|
|
|
|
&drag_info.current_pointer_y);
|
2006-01-02 15:27:51 -05:00
|
|
|
|
2006-05-17 22:19:27 -04:00
|
|
|
if (!from_autoscroll && drag_info.item) {
|
2006-05-25 16:30:32 -04:00
|
|
|
/* item != 0 is the best test i can think of for dragging.
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
2006-06-13 03:27:52 -04:00
|
|
|
if (!drag_info.move_threshold_passed) {
|
2006-05-25 16:30:32 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
drag_info.move_threshold_passed = (abs ((int) (drag_info.current_pointer_x - drag_info.grab_x)) > 4);
|
2006-03-07 21:50:53 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
// and change the initial grab loc/frame if this drag info wants us to
|
2006-05-25 16:30:32 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
if (drag_info.want_move_threshold && drag_info.move_threshold_passed) {
|
2005-09-25 14:42:24 -04:00
|
|
|
drag_info.grab_frame = drag_info.current_pointer_frame;
|
|
|
|
drag_info.grab_x = drag_info.current_pointer_x;
|
|
|
|
drag_info.grab_y = drag_info.current_pointer_y;
|
|
|
|
drag_info.last_pointer_frame = drag_info.grab_frame;
|
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (item_type) {
|
|
|
|
case PlayheadCursorItem:
|
|
|
|
case EditCursorItem:
|
|
|
|
case MarkerItem:
|
|
|
|
case GainControlPointItem:
|
|
|
|
case RedirectAutomationControlPointItem:
|
|
|
|
case GainAutomationControlPointItem:
|
|
|
|
case PanAutomationControlPointItem:
|
|
|
|
case TempoMarkerItem:
|
|
|
|
case MeterMarkerItem:
|
2006-07-23 08:03:19 -04:00
|
|
|
case RegionViewNameHighlight:
|
2005-09-25 14:42:24 -04:00
|
|
|
case StartSelectionTrimItem:
|
|
|
|
case EndSelectionTrimItem:
|
|
|
|
case SelectionItem:
|
|
|
|
case GainLineItem:
|
|
|
|
case RedirectAutomationLineItem:
|
|
|
|
case GainAutomationLineItem:
|
|
|
|
case PanAutomationLineItem:
|
|
|
|
case FadeInHandleItem:
|
|
|
|
case FadeOutHandleItem:
|
|
|
|
/* <CMT Additions> */
|
|
|
|
case ImageFrameHandleStartItem:
|
|
|
|
case ImageFrameHandleEndItem:
|
|
|
|
case MarkerViewHandleStartItem:
|
|
|
|
case MarkerViewHandleEndItem:
|
|
|
|
/* </CMT Additions> */
|
2005-11-12 22:53:51 -05:00
|
|
|
if (drag_info.item && (event->motion.state & Gdk::BUTTON1_MASK ||
|
|
|
|
(event->motion.state & Gdk::BUTTON2_MASK))) {
|
2006-05-17 22:19:27 -04:00
|
|
|
if (!from_autoscroll) {
|
|
|
|
maybe_autoscroll (event);
|
|
|
|
}
|
|
|
|
(this->*(drag_info.motion_callback)) (item, event);
|
|
|
|
goto handled;
|
|
|
|
}
|
|
|
|
goto not_handled;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseObject:
|
|
|
|
case MouseRange:
|
|
|
|
case MouseZoom:
|
|
|
|
case MouseTimeFX:
|
|
|
|
if (drag_info.item && (event->motion.state & GDK_BUTTON1_MASK ||
|
|
|
|
(event->motion.state & GDK_BUTTON2_MASK))) {
|
2006-05-17 22:19:27 -04:00
|
|
|
if (!from_autoscroll) {
|
|
|
|
maybe_autoscroll (event);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
(this->*(drag_info.motion_callback)) (item, event);
|
|
|
|
goto handled;
|
|
|
|
}
|
|
|
|
goto not_handled;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
handled:
|
2005-10-26 21:10:36 -04:00
|
|
|
track_canvas_motion (event);
|
2006-06-13 03:27:52 -04:00
|
|
|
// drag_info.last_pointer_frame = drag_info.current_pointer_frame;
|
2006-03-07 21:50:53 -05:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
not_handled:
|
2006-03-07 21:50:53 -05:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-10-28 18:19:45 -04:00
|
|
|
Editor::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (drag_info.item == 0) {
|
|
|
|
fatal << _("programming error: start_grab called without drag item") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor == 0) {
|
|
|
|
cursor = grabber_cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if dragging with button2, the motion is x constrained, with Alt-button2 it is y constrained
|
|
|
|
|
|
|
|
if (event->button.button == 2) {
|
2006-04-27 05:04:24 -04:00
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Alt)) {
|
|
|
|
drag_info.y_constrained = true;
|
|
|
|
drag_info.x_constrained = false;
|
|
|
|
} else {
|
|
|
|
drag_info.y_constrained = false;
|
|
|
|
drag_info.x_constrained = true;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
drag_info.x_constrained = false;
|
2006-04-27 05:04:24 -04:00
|
|
|
drag_info.y_constrained = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.grab_frame = event_frame(event, &drag_info.grab_x, &drag_info.grab_y);
|
|
|
|
drag_info.last_pointer_frame = drag_info.grab_frame;
|
|
|
|
drag_info.current_pointer_frame = drag_info.grab_frame;
|
|
|
|
drag_info.current_pointer_x = drag_info.grab_x;
|
|
|
|
drag_info.current_pointer_y = drag_info.grab_y;
|
|
|
|
drag_info.cumulative_x_drag = 0;
|
|
|
|
drag_info.cumulative_y_drag = 0;
|
|
|
|
drag_info.first_move = true;
|
2006-06-13 03:27:52 -04:00
|
|
|
drag_info.move_threshold_passed = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
drag_info.want_move_threshold = false;
|
|
|
|
drag_info.pointer_frame_offset = 0;
|
|
|
|
drag_info.brushing = false;
|
|
|
|
drag_info.copied_location = 0;
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
drag_info.item->grab (Gdk::POINTER_MOTION_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK,
|
|
|
|
*cursor,
|
|
|
|
event->button.time);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (session && session->transport_rolling()) {
|
|
|
|
drag_info.was_rolling = true;
|
|
|
|
} else {
|
|
|
|
drag_info.was_rolling = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (snap_type) {
|
|
|
|
case SnapToRegionStart:
|
|
|
|
case SnapToRegionEnd:
|
|
|
|
case SnapToRegionSync:
|
|
|
|
case SnapToRegionBoundary:
|
|
|
|
build_region_boundary_cache ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
void
|
|
|
|
Editor::swap_grab (ArdourCanvas::Item* new_item, Gdk::Cursor* cursor, uint32_t time)
|
|
|
|
{
|
|
|
|
drag_info.item->ungrab (0);
|
|
|
|
drag_info.item = new_item;
|
|
|
|
|
|
|
|
if (cursor == 0) {
|
|
|
|
cursor = grabber_cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.item->grab (Gdk::POINTER_MOTION_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK, *cursor, time);
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
bool
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::end_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
bool did_drag = false;
|
|
|
|
|
|
|
|
stop_canvas_autoscroll ();
|
|
|
|
|
|
|
|
if (drag_info.item == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
drag_info.item->ungrab (event->button.time);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (drag_info.finished_callback) {
|
|
|
|
(this->*(drag_info.finished_callback)) (item, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
did_drag = !drag_info.first_move;
|
|
|
|
|
|
|
|
hide_verbose_canvas_cursor();
|
|
|
|
|
|
|
|
drag_info.item = 0;
|
|
|
|
drag_info.copy = false;
|
|
|
|
drag_info.motion_callback = 0;
|
|
|
|
drag_info.finished_callback = 0;
|
|
|
|
drag_info.last_trackview = 0;
|
|
|
|
drag_info.last_frame_position = 0;
|
|
|
|
drag_info.grab_frame = 0;
|
|
|
|
drag_info.last_pointer_frame = 0;
|
|
|
|
drag_info.current_pointer_frame = 0;
|
|
|
|
drag_info.brushing = false;
|
|
|
|
|
|
|
|
if (drag_info.copied_location) {
|
|
|
|
delete drag_info.copied_location;
|
|
|
|
drag_info.copied_location = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return did_drag;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_edit_cursor (GdkEvent* event)
|
|
|
|
{
|
|
|
|
jack_nframes_t pointer_frame = event_frame (event);
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
if (snap_type != SnapToEditCursor) {
|
|
|
|
snap_to (pointer_frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
edit_cursor->set_position (pointer_frame);
|
|
|
|
edit_cursor_clock.set (pointer_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_playhead_cursor (GdkEvent* event)
|
|
|
|
{
|
|
|
|
jack_nframes_t pointer_frame = event_frame (event);
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (pointer_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (session) {
|
|
|
|
session->request_locate (pointer_frame, session->transport_rolling());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_fade_in_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.motion_callback = &Editor::fade_in_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::fade_in_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((drag_info.data = (item->get_data ("regionview"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - ((jack_nframes_t) arv->audio_region().fade_in().back()->when + arv->region().position());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::fade_in_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
|
|
|
|
jack_nframes_t pos;
|
|
|
|
jack_nframes_t fade_length;
|
|
|
|
|
|
|
|
if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
|
|
|
|
pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (pos);
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (pos < (arv->region().position() + 64)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fade_length = 64; // this should be a minimum defined somewhere
|
2006-07-23 08:03:19 -04:00
|
|
|
} else if (pos > arv->region().last_frame()) {
|
|
|
|
fade_length = arv->region().length();
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-07-23 08:03:19 -04:00
|
|
|
fade_length = pos - arv->region().position();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
arv->reset_fade_in_shape_width (fade_length);
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
show_verbose_duration_cursor (arv->region().position(), arv->region().position() + fade_length, 10);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
drag_info.first_move = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::fade_in_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (drag_info.first_move) return;
|
|
|
|
|
|
|
|
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
|
|
|
|
jack_nframes_t pos;
|
|
|
|
jack_nframes_t fade_length;
|
|
|
|
|
|
|
|
if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
|
|
|
|
pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (pos);
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (pos < (arv->region().position() + 64)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fade_length = 64; // this should be a minimum defined somewhere
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
else if (pos > arv->region().last_frame()) {
|
|
|
|
fade_length = arv->region().length();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else {
|
2006-07-23 08:03:19 -04:00
|
|
|
fade_length = pos - arv->region().position();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("change fade in length"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = arv->audio_region().get_state();
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
arv->audio_region().set_fade_in_length (fade_length);
|
2006-08-09 21:22:45 -04:00
|
|
|
|
|
|
|
XMLNode &after = arv->audio_region().get_state();
|
|
|
|
session->add_command(new MementoCommand<ARDOUR::AudioRegion>(arv->audio_region(),
|
2006-08-24 03:37:17 -04:00
|
|
|
&before,
|
|
|
|
&after));
|
2005-09-25 14:42:24 -04:00
|
|
|
commit_reversible_command ();
|
|
|
|
fade_in_drag_motion_callback (item, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_fade_out_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.motion_callback = &Editor::fade_out_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::fade_out_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((drag_info.data = (item->get_data ("regionview"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: fade out canvas item has no regionview data pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - (arv->region().length() - (jack_nframes_t) arv->audio_region().fade_out().back()->when + arv->region().position());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::fade_out_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
|
|
|
|
jack_nframes_t pos;
|
|
|
|
jack_nframes_t fade_length;
|
|
|
|
|
|
|
|
if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
|
|
|
|
pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (pos);
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (pos > (arv->region().last_frame() - 64)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fade_length = 64; // this should really be a minimum fade defined somewhere
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
else if (pos < arv->region().position()) {
|
|
|
|
fade_length = arv->region().length();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else {
|
2006-07-23 08:03:19 -04:00
|
|
|
fade_length = arv->region().last_frame() - pos;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
arv->reset_fade_out_shape_width (fade_length);
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
show_verbose_duration_cursor (arv->region().last_frame() - fade_length, arv->region().last_frame(), 10);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
drag_info.first_move = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::fade_out_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (drag_info.first_move) return;
|
|
|
|
|
|
|
|
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
|
|
|
|
jack_nframes_t pos;
|
|
|
|
jack_nframes_t fade_length;
|
|
|
|
|
|
|
|
if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
|
|
|
|
pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (pos);
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (pos > (arv->region().last_frame() - 64)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fade_length = 64; // this should really be a minimum fade defined somewhere
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
else if (pos < arv->region().position()) {
|
|
|
|
fade_length = arv->region().length();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else {
|
2006-07-23 08:03:19 -04:00
|
|
|
fade_length = arv->region().last_frame() - pos;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("change fade out length"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = arv->region().get_state();
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
arv->audio_region().set_fade_out_length (fade_length);
|
2006-08-09 21:22:45 -04:00
|
|
|
|
|
|
|
XMLNode &after = arv->region().get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<ARDOUR::Region>(arv->region(), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
commit_reversible_command ();
|
|
|
|
|
|
|
|
fade_out_drag_motion_callback (item, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_cursor_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.motion_callback = &Editor::cursor_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::cursor_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((drag_info.data = (item->get_data ("cursor"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: cursor canvas item has no cursor data pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Cursor* cursor = (Cursor *) drag_info.data;
|
|
|
|
|
|
|
|
if (session && cursor == playhead_cursor) {
|
|
|
|
if (drag_info.was_rolling) {
|
|
|
|
session->request_stop ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - cursor->current_frame;
|
|
|
|
|
|
|
|
show_verbose_time_cursor (cursor->current_frame, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::cursor_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
Cursor* cursor = (Cursor *) drag_info.data;
|
|
|
|
jack_nframes_t adjusted_frame;
|
|
|
|
|
|
|
|
if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
|
|
|
|
adjusted_frame = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
adjusted_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
if (cursor != edit_cursor || snap_type != SnapToEditCursor) {
|
|
|
|
snap_to (adjusted_frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (adjusted_frame == drag_info.last_pointer_frame) return;
|
|
|
|
|
|
|
|
cursor->set_position (adjusted_frame);
|
|
|
|
|
|
|
|
if (cursor == edit_cursor) {
|
|
|
|
edit_cursor_clock.set (cursor->current_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
show_verbose_time_cursor (cursor->current_frame, 10);
|
|
|
|
|
|
|
|
drag_info.last_pointer_frame = adjusted_frame;
|
|
|
|
drag_info.first_move = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::cursor_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (drag_info.first_move) return;
|
|
|
|
|
|
|
|
cursor_drag_motion_callback (item, event);
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
if (item == &playhead_cursor->canvas_item) {
|
2005-09-25 14:42:24 -04:00
|
|
|
if (session) {
|
|
|
|
session->request_locate (playhead_cursor->current_frame, drag_info.was_rolling);
|
|
|
|
}
|
2005-11-22 00:10:12 -05:00
|
|
|
} else if (item == &edit_cursor->canvas_item) {
|
2005-09-25 14:42:24 -04:00
|
|
|
edit_cursor->set_position (edit_cursor->current_frame);
|
|
|
|
edit_cursor_clock.set (edit_cursor->current_frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::update_marker_drag_item (Location *location)
|
|
|
|
{
|
|
|
|
double x1 = frame_to_pixel (location->start());
|
|
|
|
double x2 = frame_to_pixel (location->end());
|
|
|
|
|
|
|
|
if (location->is_mark()) {
|
2005-11-25 19:06:46 -05:00
|
|
|
marker_drag_line_points.front().set_x(x1);
|
|
|
|
marker_drag_line_points.back().set_x(x1);
|
2005-11-27 17:35:04 -05:00
|
|
|
marker_drag_line->property_points() = marker_drag_line_points;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else {
|
2005-11-27 17:35:04 -05:00
|
|
|
range_marker_drag_rect->property_x1() = x1;
|
|
|
|
range_marker_drag_rect->property_x2() = x2;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_marker_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
|
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
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_start;
|
|
|
|
|
|
|
|
Location *location = find_location_from_marker (marker, is_start);
|
|
|
|
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.data = marker;
|
|
|
|
drag_info.motion_callback = &Editor::marker_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::marker_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
|
|
|
drag_info.copied_location = new Location (*location);
|
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - (is_start ? location->start() : location->end());
|
2006-07-13 23:43:32 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
update_marker_drag_item (location);
|
|
|
|
|
|
|
|
if (location->is_mark()) {
|
2005-10-28 18:19:45 -04:00
|
|
|
marker_drag_line->show();
|
|
|
|
marker_drag_line->raise_to_top();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
else {
|
2005-10-28 18:19:45 -04:00
|
|
|
range_marker_drag_rect->show();
|
|
|
|
range_marker_drag_rect->raise_to_top();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_start) show_verbose_time_cursor (location->start(), 10);
|
|
|
|
else show_verbose_time_cursor (location->end(), 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
jack_nframes_t f_delta;
|
|
|
|
Marker* marker = (Marker *) drag_info.data;
|
|
|
|
Location *real_location;
|
|
|
|
Location *copy_location;
|
|
|
|
bool is_start;
|
|
|
|
bool move_both = false;
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
jack_nframes_t newframe;
|
|
|
|
if (drag_info.pointer_frame_offset <= (long) drag_info.current_pointer_frame) {
|
|
|
|
newframe = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newframe = 0;
|
|
|
|
}
|
2006-06-13 03:27:52 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
jack_nframes_t next = newframe;
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (newframe, 0, true);
|
|
|
|
}
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
if (drag_info.current_pointer_frame == drag_info.last_pointer_frame) {
|
|
|
|
return;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* call this to find out if its the start or end */
|
|
|
|
|
|
|
|
real_location = find_location_from_marker (marker, is_start);
|
|
|
|
|
|
|
|
/* use the copy that we're "dragging" around */
|
|
|
|
|
|
|
|
copy_location = drag_info.copied_location;
|
|
|
|
|
|
|
|
f_delta = copy_location->end() - copy_location->start();
|
|
|
|
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) {
|
|
|
|
move_both = true;
|
|
|
|
}
|
|
|
|
|
2006-07-13 23:43:32 -04:00
|
|
|
if (copy_location->is_mark()) {
|
|
|
|
/* just move it */
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-13 23:43:32 -04:00
|
|
|
copy_location->set_start (newframe);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-13 23:43:32 -04:00
|
|
|
} else {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-13 23:43:32 -04:00
|
|
|
if (is_start) { // start-of-range marker
|
|
|
|
|
|
|
|
if (move_both) {
|
|
|
|
copy_location->set_start (newframe);
|
|
|
|
copy_location->set_end (newframe + f_delta);
|
|
|
|
} else if (newframe < copy_location->end()) {
|
|
|
|
copy_location->set_start (newframe);
|
|
|
|
} else {
|
|
|
|
snap_to (next, 1, true);
|
|
|
|
copy_location->set_end (next);
|
|
|
|
copy_location->set_start (newframe);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-13 23:43:32 -04:00
|
|
|
} else { // end marker
|
|
|
|
|
|
|
|
if (move_both) {
|
|
|
|
copy_location->set_end (newframe);
|
|
|
|
copy_location->set_start (newframe - f_delta);
|
|
|
|
} else if (newframe > copy_location->start()) {
|
|
|
|
copy_location->set_end (newframe);
|
|
|
|
|
|
|
|
} else if (newframe > 0) {
|
|
|
|
snap_to (next, -1, true);
|
|
|
|
copy_location->set_start (next);
|
|
|
|
copy_location->set_end (newframe);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.last_pointer_frame = drag_info.current_pointer_frame;
|
|
|
|
drag_info.first_move = false;
|
|
|
|
|
|
|
|
update_marker_drag_item (copy_location);
|
|
|
|
|
|
|
|
LocationMarkers* lm = find_location_markers (real_location);
|
|
|
|
lm->set_position (copy_location->start(), copy_location->end());
|
|
|
|
|
|
|
|
show_verbose_time_cursor (newframe, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
marker_drag_motion_callback (item, event);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Marker* marker = (Marker *) drag_info.data;
|
|
|
|
bool is_start;
|
2006-03-21 13:40:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
begin_reversible_command ( _("move marker") );
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = session->locations()->get_state();
|
2006-03-21 13:40:17 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
Location * location = find_location_from_marker (marker, is_start);
|
2006-03-21 13:40:17 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (location) {
|
2006-07-13 23:43:32 -04:00
|
|
|
if (location->is_mark()) {
|
|
|
|
location->set_start (drag_info.copied_location->start());
|
|
|
|
} else {
|
|
|
|
location->set (drag_info.copied_location->start(), drag_info.copied_location->end());
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-21 13:40:17 -05:00
|
|
|
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = session->locations()->get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
|
2006-03-21 13:40:17 -05:00
|
|
|
commit_reversible_command ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-28 18:19:45 -04:00
|
|
|
marker_drag_line->hide();
|
|
|
|
range_marker_drag_rect->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_meter_marker_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
MeterMarker* meter_marker;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((marker = reinterpret_cast<Marker *> (item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: meter marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
meter_marker = dynamic_cast<MeterMarker*> (marker);
|
|
|
|
|
|
|
|
MetricSection& section (meter_marker->meter());
|
|
|
|
|
|
|
|
if (!section.movable()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.data = marker;
|
|
|
|
drag_info.motion_callback = &Editor::meter_marker_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::meter_marker_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - meter_marker->meter().frame();
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
void
|
|
|
|
Editor::start_meter_marker_copy_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
MeterMarker* meter_marker;
|
|
|
|
|
|
|
|
if ((marker = reinterpret_cast<Marker *> (item->get_data ("marker"))) == 0) {
|
|
|
|
fatal << _("programming error: meter marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
meter_marker = dynamic_cast<MeterMarker*> (marker);
|
|
|
|
|
|
|
|
// create a dummy marker for visual representation of moving the copy.
|
|
|
|
// The actual copying is not done before we reach the finish callback.
|
|
|
|
char name[64];
|
|
|
|
snprintf (name, sizeof(name), "%g/%g", meter_marker->meter().beats_per_bar(), meter_marker->meter().note_divisor ());
|
|
|
|
MeterMarker* new_marker = new MeterMarker(*this, *meter_group, color_map[cMeterMarker], name,
|
|
|
|
*new MeterSection(meter_marker->meter()));
|
|
|
|
|
|
|
|
drag_info.item = &new_marker->the_item();
|
|
|
|
drag_info.copy = true;
|
|
|
|
drag_info.data = new_marker;
|
|
|
|
drag_info.motion_callback = &Editor::meter_marker_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::meter_marker_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - meter_marker->meter().frame();
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::meter_marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
MeterMarker* marker = (MeterMarker *) drag_info.data;
|
|
|
|
jack_nframes_t adjusted_frame;
|
|
|
|
|
|
|
|
if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
|
|
|
|
adjusted_frame = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
adjusted_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (adjusted_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (adjusted_frame == drag_info.last_pointer_frame) return;
|
|
|
|
|
|
|
|
marker->set_position (adjusted_frame);
|
|
|
|
|
|
|
|
|
|
|
|
drag_info.last_pointer_frame = adjusted_frame;
|
|
|
|
drag_info.first_move = false;
|
|
|
|
|
|
|
|
show_verbose_time_cursor (adjusted_frame, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::meter_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (drag_info.first_move) return;
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
meter_marker_drag_motion_callback (drag_info.item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
MeterMarker* marker = (MeterMarker *) drag_info.data;
|
|
|
|
BBT_Time when;
|
|
|
|
|
|
|
|
TempoMap& map (session->tempo_map());
|
|
|
|
map.bbt_time (drag_info.last_pointer_frame, when);
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
if (drag_info.copy == true) {
|
|
|
|
begin_reversible_command (_("copy meter mark"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = map.get_state();
|
2006-03-05 14:39:16 -05:00
|
|
|
map.add_meter (marker->meter(), when);
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = map.get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
|
2006-03-05 14:39:16 -05:00
|
|
|
commit_reversible_command ();
|
|
|
|
|
|
|
|
// delete the dummy marker we used for visual representation of copying.
|
|
|
|
// a new visual marker will show up automatically.
|
|
|
|
delete marker;
|
|
|
|
} else {
|
|
|
|
begin_reversible_command (_("move meter mark"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = map.get_state();
|
2006-03-05 14:39:16 -05:00
|
|
|
map.move_meter (marker->meter(), when);
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = map.get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
|
2006-03-05 14:39:16 -05:00
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_tempo_marker_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
TempoMarker* tempo_marker;
|
|
|
|
|
2005-12-08 13:53:43 -05:00
|
|
|
if ((marker = reinterpret_cast<Marker *> (item->get_data ("marker"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: tempo marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((tempo_marker = dynamic_cast<TempoMarker *> (marker)) == 0) {
|
|
|
|
fatal << _("programming error: marker for tempo is not a tempo marker!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
MetricSection& section (tempo_marker->tempo());
|
|
|
|
|
|
|
|
if (!section.movable()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.data = marker;
|
|
|
|
drag_info.motion_callback = &Editor::tempo_marker_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::tempo_marker_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - tempo_marker->tempo().frame();
|
|
|
|
show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
void
|
|
|
|
Editor::start_tempo_marker_copy_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
TempoMarker* tempo_marker;
|
|
|
|
|
|
|
|
if ((marker = reinterpret_cast<Marker *> (item->get_data ("marker"))) == 0) {
|
|
|
|
fatal << _("programming error: tempo marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((tempo_marker = dynamic_cast<TempoMarker *> (marker)) == 0) {
|
|
|
|
fatal << _("programming error: marker for tempo is not a tempo marker!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
// create a dummy marker for visual representation of moving the copy.
|
|
|
|
// The actual copying is not done before we reach the finish callback.
|
|
|
|
char name[64];
|
|
|
|
snprintf (name, sizeof (name), "%.2f", tempo_marker->tempo().beats_per_minute());
|
|
|
|
TempoMarker* new_marker = new TempoMarker(*this, *tempo_group, color_map[cTempoMarker], name,
|
|
|
|
*new TempoSection(tempo_marker->tempo()));
|
|
|
|
|
|
|
|
drag_info.item = &new_marker->the_item();
|
|
|
|
drag_info.copy = true;
|
|
|
|
drag_info.data = new_marker;
|
|
|
|
drag_info.motion_callback = &Editor::tempo_marker_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::tempo_marker_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - tempo_marker->tempo().frame();
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::tempo_marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
TempoMarker* marker = (TempoMarker *) drag_info.data;
|
|
|
|
jack_nframes_t adjusted_frame;
|
|
|
|
|
|
|
|
if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
|
|
|
|
adjusted_frame = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
adjusted_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (adjusted_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (adjusted_frame == drag_info.last_pointer_frame) return;
|
|
|
|
|
|
|
|
/* OK, we've moved far enough to make it worth actually move the thing. */
|
|
|
|
|
|
|
|
marker->set_position (adjusted_frame);
|
|
|
|
|
|
|
|
show_verbose_time_cursor (adjusted_frame, 10);
|
|
|
|
|
|
|
|
drag_info.last_pointer_frame = adjusted_frame;
|
|
|
|
drag_info.first_move = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::tempo_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (drag_info.first_move) return;
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
tempo_marker_drag_motion_callback (drag_info.item, event);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
TempoMarker* marker = (TempoMarker *) drag_info.data;
|
|
|
|
BBT_Time when;
|
|
|
|
|
|
|
|
TempoMap& map (session->tempo_map());
|
|
|
|
map.bbt_time (drag_info.last_pointer_frame, when);
|
2006-08-09 21:22:45 -04:00
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
if (drag_info.copy == true) {
|
|
|
|
begin_reversible_command (_("copy tempo mark"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = map.get_state();
|
2006-03-05 14:39:16 -05:00
|
|
|
map.add_tempo (marker->tempo(), when);
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = map.get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command (new MementoCommand<TempoMap>(map, &before, &after));
|
2006-03-05 14:39:16 -05:00
|
|
|
commit_reversible_command ();
|
|
|
|
|
|
|
|
// delete the dummy marker we used for visual representation of copying.
|
|
|
|
// a new visual marker will show up automatically.
|
|
|
|
delete marker;
|
|
|
|
} else {
|
|
|
|
begin_reversible_command (_("move tempo mark"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = map.get_state();
|
2006-03-05 14:39:16 -05:00
|
|
|
map.move_tempo (marker->tempo(), when);
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = map.get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command (new MementoCommand<TempoMap>(map, &before, &after));
|
2006-03-05 14:39:16 -05:00
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::remove_gain_control_point (ArdourCanvas::Item*item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ControlPoint* control_point;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((control_point = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
// We shouldn't remove the first or last gain point
|
|
|
|
if (control_point->line.is_last_point(*control_point) ||
|
|
|
|
control_point->line.is_first_point(*control_point)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
control_point->line.remove_point (*control_point);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::remove_control_point (ArdourCanvas::Item*item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ControlPoint* control_point;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((control_point = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
control_point->line.remove_point (*control_point);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_control_point_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ControlPoint* control_point;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((control_point = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.data = control_point;
|
|
|
|
drag_info.motion_callback = &Editor::control_point_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::control_point_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event, fader_cursor);
|
|
|
|
|
|
|
|
control_point->line.start_drag (control_point, 0);
|
|
|
|
|
|
|
|
float fraction = 1.0 - (control_point->get_y() / control_point->line.height());
|
|
|
|
set_verbose_canvas_cursor (control_point->line.get_verbose_cursor_string (fraction),
|
|
|
|
drag_info.current_pointer_x + 20, drag_info.current_pointer_y + 20);
|
|
|
|
|
|
|
|
show_verbose_canvas_cursor ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::control_point_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ControlPoint* cp = reinterpret_cast<ControlPoint *> (drag_info.data);
|
|
|
|
|
|
|
|
double cx = drag_info.current_pointer_x;
|
|
|
|
double cy = drag_info.current_pointer_y;
|
|
|
|
|
|
|
|
drag_info.cumulative_x_drag = cx - drag_info.grab_x ;
|
|
|
|
drag_info.cumulative_y_drag = cy - drag_info.grab_y ;
|
|
|
|
|
|
|
|
if (drag_info.x_constrained) {
|
2006-04-27 05:04:24 -04:00
|
|
|
cx = drag_info.grab_x;
|
|
|
|
}
|
|
|
|
if (drag_info.y_constrained) {
|
|
|
|
cy = drag_info.grab_y;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
cp->line.parent_group().w2i (cx, cy);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
cx = max (0.0, cx);
|
|
|
|
cy = max (0.0, cy);
|
|
|
|
cy = min ((double) cp->line.height(), cy);
|
|
|
|
|
|
|
|
//translate cx to frames
|
2006-04-27 05:04:24 -04:00
|
|
|
jack_nframes_t cx_frames = unit_to_frame (cx);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-04-27 05:04:24 -04:00
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier()) && !drag_info.x_constrained) {
|
2005-09-25 14:42:24 -04:00
|
|
|
snap_to (cx_frames);
|
|
|
|
}
|
|
|
|
|
|
|
|
float fraction = 1.0 - (cy / cp->line.height());
|
|
|
|
|
|
|
|
bool push;
|
|
|
|
|
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::Control)) {
|
|
|
|
push = true;
|
|
|
|
} else {
|
|
|
|
push = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
cp->line.point_drag (*cp, cx_frames , fraction, push);
|
|
|
|
|
|
|
|
set_verbose_canvas_cursor_text (cp->line.get_verbose_cursor_string (fraction));
|
2006-05-19 16:10:35 -04:00
|
|
|
|
|
|
|
drag_info.first_move = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::control_point_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ControlPoint* cp = reinterpret_cast<ControlPoint *> (drag_info.data);
|
2006-05-19 16:10:35 -04:00
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
|
|
|
|
/* just a click */
|
|
|
|
|
|
|
|
if ((event->type == GDK_BUTTON_RELEASE) && (event->button.button == 1) && Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) {
|
|
|
|
reset_point_selection ();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
control_point_drag_motion_callback (item, event);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
cp->line.end_drag (cp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_line_grab_from_regionview (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseGain:
|
2006-07-23 08:03:19 -04:00
|
|
|
assert(dynamic_cast<AudioRegionView*>(clicked_regionview));
|
|
|
|
start_line_grab (dynamic_cast<AudioRegionView*>(clicked_regionview)->get_gain_line(), event);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_line_grab_from_line (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
AutomationLine* al;
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
if ((al = reinterpret_cast<AutomationLine*> (item->get_data ("line"))) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
fatal << _("programming error: line canvas item has no line pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
start_line_grab (al, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::start_line_grab (AutomationLine* line, GdkEvent* event)
|
|
|
|
{
|
|
|
|
double cx;
|
|
|
|
double cy;
|
|
|
|
jack_nframes_t frame_within_region;
|
|
|
|
|
|
|
|
/* need to get x coordinate in terms of parent (TimeAxisItemView)
|
|
|
|
origin.
|
|
|
|
*/
|
|
|
|
|
|
|
|
cx = event->button.x;
|
|
|
|
cy = event->button.y;
|
2005-11-22 00:10:12 -05:00
|
|
|
line->parent_group().w2i (cx, cy);
|
2005-09-25 14:42:24 -04:00
|
|
|
frame_within_region = (jack_nframes_t) floor (cx * frames_per_unit);
|
|
|
|
|
|
|
|
if (!line->control_points_adjacent (frame_within_region, current_line_drag_info.before,
|
|
|
|
current_line_drag_info.after)) {
|
|
|
|
/* no adjacent points */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
drag_info.item = &line->grab_item();
|
2005-09-25 14:42:24 -04:00
|
|
|
drag_info.data = line;
|
|
|
|
drag_info.motion_callback = &Editor::line_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::line_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event, fader_cursor);
|
|
|
|
|
|
|
|
double fraction = 1.0 - (cy / line->height());
|
|
|
|
|
|
|
|
line->start_drag (0, fraction);
|
|
|
|
|
|
|
|
set_verbose_canvas_cursor (line->get_verbose_cursor_string (fraction),
|
|
|
|
drag_info.current_pointer_x + 20, drag_info.current_pointer_y + 20);
|
|
|
|
show_verbose_canvas_cursor ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::line_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
AutomationLine* line = reinterpret_cast<AutomationLine *> (drag_info.data);
|
|
|
|
double cx = drag_info.current_pointer_x;
|
|
|
|
double cy = drag_info.current_pointer_y;
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
line->parent_group().w2i (cx, cy);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
double fraction;
|
|
|
|
fraction = 1.0 - (cy / line->height());
|
|
|
|
|
|
|
|
bool push;
|
|
|
|
|
|
|
|
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::Control)) {
|
|
|
|
push = false;
|
|
|
|
} else {
|
|
|
|
push = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
line->line_drag (current_line_drag_info.before, current_line_drag_info.after, fraction, push);
|
|
|
|
|
|
|
|
set_verbose_canvas_cursor_text (line->get_verbose_cursor_string (fraction));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::line_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
AutomationLine* line = reinterpret_cast<AutomationLine *> (drag_info.data);
|
|
|
|
line_drag_motion_callback (item, event);
|
|
|
|
line->end_drag (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_region_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty() || clicked_regionview == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.copy = false;
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.data = clicked_regionview;
|
|
|
|
drag_info.motion_callback = &Editor::region_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::region_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
|
|
|
double speed = 1.0;
|
2006-08-16 16:36:14 -04:00
|
|
|
TimeAxisView* tvp = clicked_axisview;
|
2006-07-23 08:03:19 -04:00
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (tv && tv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
speed = tv->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
drag_info.last_frame_position = (jack_nframes_t) (clicked_regionview->region().position() / speed);
|
2005-09-25 14:42:24 -04:00
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
|
|
|
|
drag_info.last_trackview = &clicked_regionview->get_time_axis_view();
|
|
|
|
// we want a move threshold
|
|
|
|
drag_info.want_move_threshold = true;
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.last_frame_position, 10);
|
|
|
|
|
|
|
|
begin_reversible_command (_("move region(s)"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_region_copy_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty() || clicked_regionview == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.copy = true;
|
2006-06-13 03:27:52 -04:00
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.data = clicked_regionview;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
start_grab(event);
|
|
|
|
|
|
|
|
TimeAxisView* tv = &clicked_regionview->get_time_axis_view();
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(tv);
|
2005-09-25 14:42:24 -04:00
|
|
|
double speed = 1.0;
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (rtv && rtv->is_track()) {
|
|
|
|
speed = rtv->get_diskstream()->speed();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.last_trackview = &clicked_regionview->get_time_axis_view();
|
2006-07-23 08:03:19 -04:00
|
|
|
drag_info.last_frame_position = (jack_nframes_t) (clicked_regionview->region().position() / speed);
|
2005-09-25 14:42:24 -04:00
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
|
|
|
|
// we want a move threshold
|
|
|
|
drag_info.want_move_threshold = true;
|
2006-06-13 03:27:52 -04:00
|
|
|
drag_info.motion_callback = &Editor::region_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::region_drag_finished_callback;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_region_brush_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty() || clicked_regionview == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.copy = false;
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.data = clicked_regionview;
|
|
|
|
drag_info.motion_callback = &Editor::region_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::region_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
|
|
|
double speed = 1.0;
|
2006-08-16 16:36:14 -04:00
|
|
|
TimeAxisView* tvp = clicked_axisview;
|
2006-07-23 08:03:19 -04:00
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (tv && tv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
speed = tv->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
drag_info.last_frame_position = (jack_nframes_t) (clicked_regionview->region().position() / speed);
|
2005-09-25 14:42:24 -04:00
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
|
|
|
|
drag_info.last_trackview = &clicked_regionview->get_time_axis_view();
|
|
|
|
// we want a move threshold
|
|
|
|
drag_info.want_move_threshold = true;
|
|
|
|
drag_info.brushing = true;
|
|
|
|
|
|
|
|
begin_reversible_command (_("Drag region brush"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
double x_delta;
|
|
|
|
double y_delta = 0;
|
2006-08-01 13:19:38 -04:00
|
|
|
RegionView* rv = reinterpret_cast<RegionView*> (drag_info.data);
|
2005-09-25 14:42:24 -04:00
|
|
|
jack_nframes_t pending_region_position = 0;
|
|
|
|
int32_t pointer_y_span = 0, canvas_pointer_y_span = 0, original_pointer_order;
|
|
|
|
int32_t visible_y_high = 0, visible_y_low = 512; //high meaning higher numbered.. not the height on the screen
|
|
|
|
bool clamp_y_axis = false;
|
|
|
|
vector<int32_t> height_list(512) ;
|
|
|
|
vector<int32_t>::iterator j;
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
show_verbose_time_cursor (drag_info.last_frame_position, 10);
|
|
|
|
|
|
|
|
if (drag_info.copy && drag_info.move_threshold_passed && drag_info.want_move_threshold) {
|
|
|
|
|
|
|
|
drag_info.want_move_threshold = false; // don't copy again
|
|
|
|
|
|
|
|
/* this is committed in the grab finished callback. */
|
|
|
|
|
|
|
|
begin_reversible_command (_("Drag region copy"));
|
|
|
|
|
|
|
|
/* duplicate the region(s) */
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
vector<RegionView*> new_regionviews;
|
2006-06-13 03:27:52 -04:00
|
|
|
|
|
|
|
set<Playlist*> affected_playlists;
|
|
|
|
pair<set<Playlist*>::iterator,bool> insert_result;
|
|
|
|
|
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) {
|
|
|
|
RegionView* rv;
|
2006-06-13 03:27:52 -04:00
|
|
|
|
|
|
|
rv = (*i);
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
Playlist* to_playlist = rv->region().playlist();
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&rv->get_time_axis_view());
|
2006-06-13 03:27:52 -04:00
|
|
|
|
|
|
|
insert_result = affected_playlists.insert (to_playlist);
|
|
|
|
if (insert_result.second) {
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command (new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));
|
2006-06-13 03:27:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
latest_regionview = 0;
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
sigc::connection c = rtv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
|
2006-06-13 03:27:52 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
/* create a new region with the same name. */
|
2006-06-13 03:27:52 -04:00
|
|
|
|
2006-08-01 13:19:38 -04:00
|
|
|
// FIXME: ew. need a (virtual) Region::duplicate() or something?
|
2006-07-23 08:03:19 -04:00
|
|
|
Region* newregion = NULL;
|
|
|
|
if (dynamic_cast<AudioRegion*>(&rv->region()))
|
|
|
|
newregion = new AudioRegion (dynamic_cast<AudioRegion&>(rv->region()));
|
|
|
|
else if (dynamic_cast<MidiRegion*>(&rv->region()))
|
|
|
|
newregion = new MidiRegion (dynamic_cast<MidiRegion&>(rv->region()));
|
|
|
|
assert(newregion);
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
/* if the original region was locked, we don't care */
|
|
|
|
|
|
|
|
newregion->set_locked (false);
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
to_playlist->add_region (*newregion, (jack_nframes_t) (rv->region().position() * rtv->get_diskstream()->speed()));
|
2006-06-13 03:27:52 -04:00
|
|
|
|
|
|
|
c.disconnect ();
|
|
|
|
|
|
|
|
if (latest_regionview) {
|
|
|
|
new_regionviews.push_back (latest_regionview);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_regionviews.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset selection to new regionviews */
|
|
|
|
|
|
|
|
selection->set (new_regionviews);
|
|
|
|
|
|
|
|
/* reset drag_info data to reflect the fact that we are dragging the copies */
|
|
|
|
|
|
|
|
drag_info.data = new_regionviews.front();
|
|
|
|
swap_grab (new_regionviews.front()->get_canvas_group (), 0, event->motion.time);
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* Which trackview is this ? */
|
|
|
|
|
|
|
|
TimeAxisView* tvp = trackview_by_y_position (drag_info.current_pointer_y);
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* The region motion is only processed if the pointer is over
|
|
|
|
an audio track.
|
|
|
|
*/
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (!tv || !tv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
/* To make sure we hide the verbose canvas cursor when the mouse is
|
2006-08-14 04:44:14 -04:00
|
|
|
not held over a track.
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
|
|
|
hide_verbose_canvas_cursor ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
original_pointer_order = drag_info.last_trackview->order;
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
Y-Delta Computation
|
|
|
|
************************************************************/
|
|
|
|
|
|
|
|
if (drag_info.brushing) {
|
|
|
|
clamp_y_axis = true;
|
|
|
|
pointer_y_span = 0;
|
|
|
|
goto y_axis_done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pointer_y_span = (drag_info.last_trackview->order - tv->order)) != 0) {
|
|
|
|
|
|
|
|
int32_t children = 0, numtracks = 0;
|
2006-01-03 00:40:21 -05:00
|
|
|
// XXX hard coding track limit, oh my, so very very bad
|
|
|
|
bitset <1024> tracks (0x00);
|
2005-09-25 14:42:24 -04:00
|
|
|
/* get a bitmask representing the visible tracks */
|
|
|
|
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
TimeAxisView *tracklist_timeview;
|
|
|
|
tracklist_timeview = (*i);
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* rtv2 = dynamic_cast<RouteTimeAxisView*>(tracklist_timeview);
|
2005-09-25 14:42:24 -04:00
|
|
|
list<TimeAxisView*> children_list;
|
|
|
|
|
|
|
|
/* zeroes are audio tracks. ones are other types. */
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (!rtv2->hidden()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (visible_y_high < rtv2->order) {
|
|
|
|
visible_y_high = rtv2->order;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-08-14 04:44:14 -04:00
|
|
|
if (visible_y_low > rtv2->order) {
|
|
|
|
visible_y_low = rtv2->order;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (!rtv2->is_track()) {
|
|
|
|
tracks = tracks |= (0x01 << rtv2->order);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
height_list[rtv2->order] = (*i)->height;
|
2005-09-25 14:42:24 -04:00
|
|
|
children = 1;
|
2006-08-14 04:44:14 -04:00
|
|
|
if ((children_list = rtv2->get_child_list()).size() > 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
for (list<TimeAxisView*>::iterator j = children_list.begin(); j != children_list.end(); ++j) {
|
2006-08-14 04:44:14 -04:00
|
|
|
tracks = tracks |= (0x01 << (rtv2->order + children));
|
|
|
|
height_list[rtv2->order + children] = (*j)->height;
|
2005-09-25 14:42:24 -04:00
|
|
|
numtracks++;
|
|
|
|
children++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
numtracks++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* find the actual span according to the canvas */
|
|
|
|
|
|
|
|
canvas_pointer_y_span = pointer_y_span;
|
|
|
|
if (drag_info.last_trackview->order >= tv->order) {
|
|
|
|
int32_t y;
|
|
|
|
for (y = tv->order; y < drag_info.last_trackview->order; y++) {
|
|
|
|
if (height_list[y] == 0 ) {
|
|
|
|
canvas_pointer_y_span--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int32_t y;
|
|
|
|
for (y = drag_info.last_trackview->order;y <= tv->order; y++) {
|
|
|
|
if ( height_list[y] == 0 ) {
|
|
|
|
canvas_pointer_y_span++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
RegionView* rv2 = (*i);
|
2005-09-25 14:42:24 -04:00
|
|
|
double ix1, ix2, iy1, iy2;
|
|
|
|
int32_t n = 0;
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
rv2->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
|
|
|
|
rv2->get_canvas_group()->i2w (ix1, iy1);
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisView* tvp2 = trackview_by_y_position (iy1);
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* rtv2 = dynamic_cast<RouteTimeAxisView*>(tvp2);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (rtv2->order != original_pointer_order) {
|
2005-09-25 14:42:24 -04:00
|
|
|
/* this isn't the pointer track */
|
|
|
|
|
|
|
|
if (canvas_pointer_y_span > 0) {
|
|
|
|
|
|
|
|
/* moving up the canvas */
|
2006-08-14 04:44:14 -04:00
|
|
|
if ((rtv2->order - canvas_pointer_y_span) >= visible_y_low) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
int32_t visible_tracks = 0;
|
|
|
|
while (visible_tracks < canvas_pointer_y_span ) {
|
|
|
|
visible_tracks++;
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
while (height_list[rtv2->order - (visible_tracks - n)] == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
/* we're passing through a hidden track */
|
|
|
|
n--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (tracks[rtv2->order - (canvas_pointer_y_span - n)] != 0x00) {
|
2005-09-25 14:42:24 -04:00
|
|
|
clamp_y_axis = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
clamp_y_axis = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (canvas_pointer_y_span < 0) {
|
|
|
|
|
|
|
|
/*moving down the canvas*/
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if ((rtv2->order - (canvas_pointer_y_span - n)) <= visible_y_high) { // we will overflow
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
int32_t visible_tracks = 0;
|
|
|
|
|
|
|
|
while (visible_tracks > canvas_pointer_y_span ) {
|
|
|
|
visible_tracks--;
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
while (height_list[rtv2->order - (visible_tracks - n)] == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
2006-08-14 04:44:14 -04:00
|
|
|
if ( tracks[rtv2->order - ( canvas_pointer_y_span - n)] != 0x00) {
|
2005-09-25 14:42:24 -04:00
|
|
|
clamp_y_axis = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
clamp_y_axis = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* this is the pointer's track */
|
2006-08-14 04:44:14 -04:00
|
|
|
if ((rtv2->order - pointer_y_span) > visible_y_high) { // we will overflow
|
2005-09-25 14:42:24 -04:00
|
|
|
clamp_y_axis = true;
|
2006-08-14 04:44:14 -04:00
|
|
|
} else if ((rtv2->order - pointer_y_span) < visible_y_low) { // we will underflow
|
2005-09-25 14:42:24 -04:00
|
|
|
clamp_y_axis = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (clamp_y_axis) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (drag_info.last_trackview == tv) {
|
|
|
|
clamp_y_axis = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
y_axis_done:
|
|
|
|
if (!clamp_y_axis) {
|
|
|
|
drag_info.last_trackview = tv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
X DELTA COMPUTATION
|
|
|
|
************************************************************/
|
|
|
|
|
|
|
|
/* compute the amount of pointer motion in frames, and where
|
|
|
|
the region would be if we moved it by that much.
|
|
|
|
*/
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
if (drag_info.move_threshold_passed) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if ((int32_t)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
|
|
|
|
|
|
|
|
jack_nframes_t sync_frame;
|
|
|
|
jack_nframes_t sync_offset;
|
|
|
|
int32_t sync_dir;
|
|
|
|
|
|
|
|
pending_region_position = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
sync_offset = rv->region().sync_offset (sync_dir);
|
|
|
|
sync_frame = rv->region().adjust_to_sync (pending_region_position);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* we snap if the snap modifier is not enabled.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (sync_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sync_frame - sync_offset <= sync_frame) {
|
|
|
|
pending_region_position = sync_frame - (sync_dir*sync_offset);
|
|
|
|
} else {
|
|
|
|
pending_region_position = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
pending_region_position = 0;
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (pending_region_position > max_frames - rv->region().length()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
pending_region_position = drag_info.last_frame_position;
|
|
|
|
}
|
|
|
|
|
|
|
|
// printf ("3: pending_region_position= %lu %lu\n", pending_region_position, drag_info.last_frame_position );
|
|
|
|
|
|
|
|
if (pending_region_position != drag_info.last_frame_position && !drag_info.x_constrained) {
|
|
|
|
|
|
|
|
/* now compute the canvas unit distance we need to move the regiondrag_info.last_trackview->order
|
|
|
|
to make it appear at the new location.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (pending_region_position > drag_info.last_frame_position) {
|
|
|
|
x_delta = ((double) (pending_region_position - drag_info.last_frame_position) / frames_per_unit);
|
|
|
|
} else {
|
|
|
|
x_delta = -((double) (drag_info.last_frame_position - pending_region_position) / frames_per_unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.last_frame_position = pending_region_position;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
x_delta = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* threshold not passed */
|
|
|
|
|
|
|
|
x_delta = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
PREPARE TO MOVE
|
|
|
|
************************************************************/
|
|
|
|
|
|
|
|
if (x_delta == 0 && (pointer_y_span == 0)) {
|
|
|
|
/* haven't reached next snap point, and we're not switching
|
|
|
|
trackviews. nothing to do.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x_delta < 0) {
|
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-07-23 08:03:19 -04:00
|
|
|
RegionView* rv2 = (*i);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
// If any regionview is at zero, we need to know so we can stop further leftward motion.
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
double ix1, ix2, iy1, iy2;
|
2005-11-12 22:53:51 -05:00
|
|
|
rv2->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
|
|
|
|
rv2->get_canvas_group()->i2w (ix1, iy1);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (ix1 <= 1) {
|
|
|
|
x_delta = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
MOTION
|
|
|
|
************************************************************/
|
|
|
|
|
|
|
|
pair<set<Playlist*>::iterator,bool> insert_result;
|
2006-07-23 08:03:19 -04:00
|
|
|
const list<RegionView*>& layered_regions = selection->regions.by_layer();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::const_iterator i = layered_regions.begin(); i != layered_regions.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv = (*i);
|
2005-09-25 14:42:24 -04:00
|
|
|
double ix1, ix2, iy1, iy2;
|
|
|
|
int32_t temp_pointer_y_span = pointer_y_span;
|
|
|
|
|
|
|
|
/* get item BBox, which will be relative to parent. so we have
|
|
|
|
to query on a child, then convert to world coordinates using
|
|
|
|
the parent.
|
|
|
|
*/
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
|
|
|
|
rv->get_canvas_group()->i2w (ix1, iy1);
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisView* tvp2 = trackview_by_y_position (iy1);
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* canvas_rtv = dynamic_cast<RouteTimeAxisView*>(tvp2);
|
|
|
|
RouteTimeAxisView* temp_rtv;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if ((pointer_y_span != 0) && !clamp_y_axis) {
|
|
|
|
y_delta = 0;
|
|
|
|
int32_t x = 0;
|
|
|
|
for (j = height_list.begin(); j!= height_list.end(); j++) {
|
2006-08-14 04:44:14 -04:00
|
|
|
if (x == canvas_rtv->order) {
|
2005-09-25 14:42:24 -04:00
|
|
|
/* we found the track the region is on */
|
|
|
|
if (x != original_pointer_order) {
|
|
|
|
/*this isn't from the same track we're dragging from */
|
|
|
|
temp_pointer_y_span = canvas_pointer_y_span;
|
|
|
|
}
|
|
|
|
while (temp_pointer_y_span > 0) {
|
|
|
|
/* we're moving up canvas-wise,
|
|
|
|
so we need to find the next track height
|
|
|
|
*/
|
|
|
|
if (j != height_list.begin()) {
|
|
|
|
j--;
|
|
|
|
}
|
|
|
|
if (x != original_pointer_order) {
|
|
|
|
/* we're not from the dragged track, so ignore hidden tracks. */
|
|
|
|
if ((*j) == 0) {
|
|
|
|
temp_pointer_y_span++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
y_delta -= (*j);
|
|
|
|
temp_pointer_y_span--;
|
|
|
|
}
|
|
|
|
while (temp_pointer_y_span < 0) {
|
|
|
|
y_delta += (*j);
|
|
|
|
if (x != original_pointer_order) {
|
|
|
|
if ((*j) == 0) {
|
|
|
|
temp_pointer_y_span--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j != height_list.end()) {
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
temp_pointer_y_span++;
|
|
|
|
}
|
|
|
|
/* find out where we'll be when we move and set height accordingly */
|
|
|
|
|
|
|
|
tvp2 = trackview_by_y_position (iy1 + y_delta);
|
2006-08-14 04:44:14 -04:00
|
|
|
temp_rtv = dynamic_cast<RouteTimeAxisView*>(tvp2);
|
|
|
|
rv->set_height (temp_rtv->height);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* if you un-comment the following, the region colours will follow the track colours whilst dragging,
|
|
|
|
personally, i think this can confuse things, but never mind.
|
|
|
|
*/
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
//const GdkColor& col (temp_rtv->view->get_region_color());
|
2005-09-25 14:42:24 -04:00
|
|
|
//rv->set_color (const_cast<GdkColor&>(col));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* prevent the regionview from being moved to before
|
|
|
|
the zero position on the canvas.
|
|
|
|
*/
|
|
|
|
/* clamp */
|
|
|
|
|
|
|
|
if (x_delta < 0) {
|
|
|
|
if (-x_delta > ix1) {
|
|
|
|
x_delta = -ix1;
|
|
|
|
}
|
2006-07-23 08:03:19 -04:00
|
|
|
} else if ((x_delta > 0) &&(rv->region().last_frame() > max_frames - x_delta)) {
|
|
|
|
x_delta = max_frames - rv->region().last_frame();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
|
|
|
|
/* hide any dependent views */
|
|
|
|
|
|
|
|
// rv->get_time_axis_view().hide_dependent_views (*rv);
|
|
|
|
|
|
|
|
/* this is subtle. raising the regionview itself won't help,
|
|
|
|
because raise_to_top() just puts the item on the top of
|
|
|
|
its parent's stack. so, we need to put the trackview canvas_display group
|
|
|
|
on the top, since its parent is the whole canvas.
|
|
|
|
*/
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
rv->get_canvas_group()->raise_to_top();
|
|
|
|
rv->get_time_axis_view().canvas_display->raise_to_top();
|
2005-10-28 18:19:45 -04:00
|
|
|
cursor_group->raise_to_top();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* freeze the playlists from notifying till
|
|
|
|
the motion is done.
|
|
|
|
*/
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (&rv->get_time_axis_view());
|
|
|
|
if (rtv && rtv->is_track()) {
|
|
|
|
Playlist* pl = dynamic_cast<Playlist*>(rtv->get_diskstream()->playlist());
|
2005-09-25 14:42:24 -04:00
|
|
|
if (pl) {
|
|
|
|
/* only freeze and capture state once */
|
|
|
|
|
|
|
|
insert_result = motion_frozen_playlists.insert (pl);
|
|
|
|
if (insert_result.second) {
|
|
|
|
pl->freeze();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*pl, &pl->get_state(), 0));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drag_info.brushing) {
|
|
|
|
mouse_brush_insert_region (rv, pending_region_position);
|
|
|
|
} else {
|
|
|
|
rv->move (x_delta, y_delta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
2005-10-28 18:19:45 -04:00
|
|
|
cursor_group->raise_to_top();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.first_move = false;
|
|
|
|
|
|
|
|
if (x_delta != 0 && !drag_info.brushing) {
|
|
|
|
show_verbose_time_cursor (drag_info.last_frame_position, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
jack_nframes_t where;
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv = reinterpret_cast<RegionView *> (drag_info.data);
|
2005-09-25 14:42:24 -04:00
|
|
|
pair<set<Playlist*>::iterator,bool> insert_result;
|
|
|
|
bool nocommit = true;
|
|
|
|
double speed;
|
2006-07-23 08:03:19 -04:00
|
|
|
RouteTimeAxisView* atv;
|
2005-09-25 14:42:24 -04:00
|
|
|
bool regionview_y_movement;
|
|
|
|
bool regionview_x_movement;
|
|
|
|
|
|
|
|
/* first_move is set to false if the regionview has been moved in the
|
|
|
|
motion handler.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
/* just a click */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
nocommit = false;
|
|
|
|
|
|
|
|
/* The regionview has been moved at some stage during the grab so we need
|
|
|
|
to account for any mouse movement between this event and the last one.
|
|
|
|
*/
|
|
|
|
|
|
|
|
region_drag_motion_callback (item, event);
|
|
|
|
|
|
|
|
if (drag_info.brushing) {
|
|
|
|
/* all changes were made during motion event handlers */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust for track speed */
|
|
|
|
speed = 1.0;
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
atv = dynamic_cast<RouteTimeAxisView*> (drag_info.last_trackview);
|
2005-09-25 14:42:24 -04:00
|
|
|
if (atv && atv->get_diskstream()) {
|
|
|
|
speed = atv->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
regionview_x_movement = (drag_info.last_frame_position != (jack_nframes_t) (rv->region().position()/speed));
|
2005-09-25 14:42:24 -04:00
|
|
|
regionview_y_movement = (drag_info.last_trackview != &rv->get_time_axis_view());
|
|
|
|
|
|
|
|
//printf ("last_frame: %s position is %lu %g\n", rv->get_time_axis_view().name().c_str(), drag_info.last_frame_position, speed);
|
|
|
|
//printf ("last_rackview: %s \n", drag_info.last_trackview->name().c_str());
|
|
|
|
|
|
|
|
if (regionview_y_movement) {
|
|
|
|
|
|
|
|
/* motion between tracks */
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
list<RegionView*> new_selection;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* moved to a different audio track. */
|
|
|
|
|
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(); ) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv2 = (*i);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* the region that used to be in the old playlist is not
|
|
|
|
moved to the new one - we make a copy of it. as a result,
|
|
|
|
any existing editor for the region should no longer be
|
|
|
|
visible.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!drag_info.copy) {
|
|
|
|
rv2->hide_region_editor();
|
|
|
|
}
|
|
|
|
new_selection.push_back (rv2);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* first, freeze the target tracks */
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::const_iterator i = new_selection.begin(); i != new_selection.end();i++ ) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
Playlist* from_playlist;
|
|
|
|
Playlist* to_playlist;
|
|
|
|
|
|
|
|
double ix1, ix2, iy1, iy2;
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
(*i)->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
|
|
|
|
(*i)->get_canvas_group()->i2w (ix1, iy1);
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisView* tvp2 = trackview_by_y_position (iy1);
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* atv2 = dynamic_cast<RouteTimeAxisView*>(tvp2);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
from_playlist = (*i)->region().playlist();
|
2005-09-25 14:42:24 -04:00
|
|
|
to_playlist = atv2->playlist();
|
|
|
|
|
|
|
|
/* the from_playlist was frozen in the "first_move" case
|
|
|
|
of the motion handler. the insert can fail,
|
|
|
|
but that doesn't matter. it just means
|
|
|
|
we already have the playlist in the list.
|
|
|
|
*/
|
|
|
|
|
|
|
|
motion_frozen_playlists.insert (from_playlist);
|
|
|
|
|
|
|
|
/* only freeze the to_playlist once */
|
|
|
|
|
|
|
|
insert_result = motion_frozen_playlists.insert(to_playlist);
|
|
|
|
if (insert_result.second) {
|
|
|
|
to_playlist->freeze();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now do it again with the actual operations */
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::const_iterator i = new_selection.begin(); i != new_selection.end();i++ ) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
Playlist* from_playlist;
|
|
|
|
Playlist* to_playlist;
|
|
|
|
|
|
|
|
double ix1, ix2, iy1, iy2;
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
(*i)->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
|
|
|
|
(*i)->get_canvas_group()->i2w (ix1, iy1);
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisView* tvp2 = trackview_by_y_position (iy1);
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* atv2 = dynamic_cast<RouteTimeAxisView*>(tvp2);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
from_playlist = (*i)->region().playlist();
|
2005-09-25 14:42:24 -04:00
|
|
|
to_playlist = atv2->playlist();
|
|
|
|
|
|
|
|
latest_regionview = 0;
|
|
|
|
|
|
|
|
where = (jack_nframes_t) (unit_to_frame (ix1) * speed);
|
2006-07-23 08:03:19 -04:00
|
|
|
Region* new_region = createRegion ((*i)->region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
from_playlist->remove_region (&((*i)->region()));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
sigc::connection c = atv2->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
|
2005-09-25 14:42:24 -04:00
|
|
|
to_playlist->add_region (*new_region, where);
|
|
|
|
c.disconnect ();
|
|
|
|
|
|
|
|
if (latest_regionview) {
|
|
|
|
selection->add (latest_regionview);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* motion within a single track */
|
2006-01-19 13:00:07 -05: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
|
|
|
|
|
|
|
rv = (*i);
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (rv->region().locked()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (regionview_x_movement) {
|
|
|
|
double ownspeed = 1.0;
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* atv = dynamic_cast<RouteTimeAxisView*> (&(rv->get_time_axis_view()));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (atv && atv->get_diskstream()) {
|
|
|
|
ownspeed = atv->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* base the new region position on the current position of the regionview.*/
|
|
|
|
|
|
|
|
double ix1, ix2, iy1, iy2;
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
|
|
|
|
rv->get_canvas_group()->i2w (ix1, iy1);
|
2005-09-25 14:42:24 -04:00
|
|
|
where = (jack_nframes_t) (unit_to_frame (ix1) * ownspeed);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
where = rv->region().position();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
rv->get_time_axis_view().reveal_dependent_views (*rv);
|
2006-01-07 21:56:49 -05:00
|
|
|
|
|
|
|
/* no need to add an undo here, we did that when we added this playlist to motion_frozen playlists */
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
rv->region().set_position (where, (void *) this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
for (set<Playlist*>::iterator p = motion_frozen_playlists.begin(); p != motion_frozen_playlists.end(); ++p) {
|
|
|
|
(*p)->thaw ();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command (new MementoCommand<Playlist>(*(*p), 0, & (*p)->get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
motion_frozen_playlists.clear ();
|
|
|
|
|
|
|
|
if (!nocommit) {
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::region_view_item_click (AudioRegionView& rv, GdkEventButton* event)
|
|
|
|
{
|
|
|
|
/* Either add to or set the set the region selection, unless
|
|
|
|
this is an alignment click (control used)
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (Keyboard::modifier_state_contains (event->state, Keyboard::Control)) {
|
|
|
|
TimeAxisView* tv = &rv.get_time_axis_view();
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* atv = dynamic_cast<RouteTimeAxisView*>(tv);
|
2005-09-25 14:42:24 -04:00
|
|
|
double speed = 1.0;
|
2006-08-14 04:44:14 -04:00
|
|
|
if (atv && atv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
speed = atv->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::Control|Keyboard::Alt))) {
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
align_region (rv.region(), SyncPoint, (jack_nframes_t) (edit_cursor->current_frame * speed));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
} else if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::Control|Keyboard::Shift))) {
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
align_region (rv.region(), End, (jack_nframes_t) (edit_cursor->current_frame * speed));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
align_region (rv.region(), Start, (jack_nframes_t) (edit_cursor->current_frame * speed));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::show_verbose_time_cursor (jack_nframes_t frame, double offset, double xpos, double ypos)
|
|
|
|
{
|
|
|
|
char buf[128];
|
2006-06-08 19:46:42 -04:00
|
|
|
SMPTE::Time smpte;
|
2005-09-25 14:42:24 -04:00
|
|
|
BBT_Time bbt;
|
|
|
|
float secs;
|
|
|
|
|
|
|
|
if (session == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ARDOUR_UI::instance()->secondary_clock.mode ()) {
|
|
|
|
case AudioClock::BBT:
|
|
|
|
session->bbt_time (frame, bbt);
|
|
|
|
snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, bbt.bars, bbt.beats, bbt.ticks);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AudioClock::SMPTE:
|
|
|
|
session->smpte_time (frame, smpte);
|
|
|
|
snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32, smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AudioClock::MinSec:
|
|
|
|
/* XXX fix this to compute min/sec properly */
|
|
|
|
session->smpte_time (frame, smpte);
|
|
|
|
secs = smpte.seconds + ((float) smpte.frames / session->smpte_frames_per_second);
|
|
|
|
snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%.4f", smpte.hours, smpte.minutes, secs);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
snprintf (buf, sizeof(buf), "%u", frame);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xpos >= 0 && ypos >=0) {
|
|
|
|
set_verbose_canvas_cursor (buf, xpos + offset, ypos + offset);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
set_verbose_canvas_cursor (buf, drag_info.current_pointer_x + offset, drag_info.current_pointer_y + offset);
|
|
|
|
}
|
|
|
|
show_verbose_canvas_cursor ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::show_verbose_duration_cursor (jack_nframes_t start, jack_nframes_t end, double offset, double xpos, double ypos)
|
|
|
|
{
|
|
|
|
char buf[128];
|
2006-06-08 19:46:42 -04:00
|
|
|
SMPTE::Time smpte;
|
2005-09-25 14:42:24 -04:00
|
|
|
BBT_Time sbbt;
|
|
|
|
BBT_Time ebbt;
|
|
|
|
float secs;
|
|
|
|
Meter meter_at_start(session->tempo_map().meter_at(start));
|
|
|
|
|
|
|
|
if (session == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ARDOUR_UI::instance()->secondary_clock.mode ()) {
|
|
|
|
case AudioClock::BBT:
|
|
|
|
session->bbt_time (start, sbbt);
|
|
|
|
session->bbt_time (end, ebbt);
|
|
|
|
|
|
|
|
/* subtract */
|
|
|
|
/* XXX this computation won't work well if the
|
|
|
|
user makes a selection that spans any meter changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ebbt.bars -= sbbt.bars;
|
|
|
|
if (ebbt.beats >= sbbt.beats) {
|
|
|
|
ebbt.beats -= sbbt.beats;
|
|
|
|
} else {
|
|
|
|
ebbt.bars--;
|
|
|
|
ebbt.beats = int(meter_at_start.beats_per_bar()) + ebbt.beats - sbbt.beats;
|
|
|
|
}
|
|
|
|
if (ebbt.ticks >= sbbt.ticks) {
|
|
|
|
ebbt.ticks -= sbbt.ticks;
|
|
|
|
} else {
|
|
|
|
ebbt.beats--;
|
|
|
|
ebbt.ticks = int(Meter::ticks_per_beat) + ebbt.ticks - sbbt.ticks;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, ebbt.bars, ebbt.beats, ebbt.ticks);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AudioClock::SMPTE:
|
|
|
|
session->smpte_duration (end - start, smpte);
|
|
|
|
snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32, smpte.hours, smpte.minutes, smpte.seconds, smpte.frames);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AudioClock::MinSec:
|
|
|
|
/* XXX fix this to compute min/sec properly */
|
|
|
|
session->smpte_duration (end - start, smpte);
|
|
|
|
secs = smpte.seconds + ((float) smpte.frames / session->smpte_frames_per_second);
|
2006-06-13 03:27:52 -04:00
|
|
|
snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%.4f", smpte.hours, smpte.minutes, secs);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
snprintf (buf, sizeof(buf), "%u", end - start);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xpos >= 0 && ypos >=0) {
|
|
|
|
set_verbose_canvas_cursor (buf, xpos + offset, ypos + offset);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
set_verbose_canvas_cursor (buf, drag_info.current_pointer_x + offset, drag_info.current_pointer_y + offset);
|
|
|
|
}
|
|
|
|
show_verbose_canvas_cursor ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
Editor::collect_new_region_view (RegionView* rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
latest_regionview = rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_selection_grab (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (clicked_regionview == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* lets try to create new Region for the selection */
|
|
|
|
|
|
|
|
vector<AudioRegion*> new_regions;
|
|
|
|
create_region_from_selection (new_regions);
|
|
|
|
|
|
|
|
if (new_regions.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX fix me one day to use all new regions */
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
latest_regionview = 0;
|
2006-08-16 16:36:14 -04:00
|
|
|
sigc::connection c = clicked_routeview->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* A selection grab currently creates two undo/redo operations, one for
|
|
|
|
creating the new region and another for moving it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
begin_reversible_command (_("selection grab"));
|
|
|
|
|
2006-08-16 16:36:14 -04:00
|
|
|
Playlist* playlist = clicked_axisview->playlist();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-24 03:37:17 -04:00
|
|
|
XMLNode *before = &(playlist->get_state());
|
2006-08-16 16:36:14 -04:00
|
|
|
clicked_axisview->playlist()->add_region (*region, selection->time[clicked_selection].start);
|
2006-08-24 03:37:17 -04:00
|
|
|
XMLNode *after = &(playlist->get_state());
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*playlist, before, after));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
|
|
|
|
c.disconnect ();
|
|
|
|
|
|
|
|
if (latest_regionview == 0) {
|
|
|
|
/* something went wrong */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we need to deselect all other regionviews, and select this one
|
|
|
|
i'm ignoring undo stuff, because the region creation will take care of it */
|
|
|
|
selection->set (latest_regionview);
|
|
|
|
|
|
|
|
drag_info.item = latest_regionview->get_canvas_group();
|
|
|
|
drag_info.data = latest_regionview;
|
|
|
|
drag_info.motion_callback = &Editor::region_drag_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::region_drag_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
2006-08-16 16:36:14 -04:00
|
|
|
drag_info.last_trackview = clicked_axisview;
|
2006-07-23 08:03:19 -04:00
|
|
|
drag_info.last_frame_position = latest_regionview->region().position();
|
2005-09-25 14:42:24 -04:00
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.last_frame_position, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::cancel_selection ()
|
|
|
|
{
|
2006-04-09 22:14:05 -04:00
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
(*i)->hide_selection ();
|
|
|
|
}
|
2006-04-09 22:14:05 -04:00
|
|
|
begin_reversible_command (_("cancel selection"));
|
2005-09-25 14:42:24 -04:00
|
|
|
selection->clear ();
|
|
|
|
clicked_selection = 0;
|
2006-04-09 22:14:05 -04:00
|
|
|
commit_reversible_command ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_selection_op (ArdourCanvas::Item* item, GdkEvent* event, SelectionOp op)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
jack_nframes_t start = 0;
|
|
|
|
jack_nframes_t end = 0;
|
|
|
|
|
|
|
|
if (session == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.motion_callback = &Editor::drag_selection;
|
|
|
|
drag_info.finished_callback = &Editor::end_selection_op;
|
|
|
|
|
|
|
|
selection_op = op;
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case CreateSelection:
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) {
|
|
|
|
drag_info.copy = true;
|
|
|
|
} else {
|
|
|
|
drag_info.copy = false;
|
|
|
|
}
|
|
|
|
start_grab (event, selector_cursor);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionStartTrim:
|
2006-08-16 16:36:14 -04:00
|
|
|
if (clicked_axisview) {
|
|
|
|
clicked_axisview->order_selection_trims (item, true);
|
2006-06-13 03:27:52 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
start_grab (event, trimmer_cursor);
|
|
|
|
start = selection->time[clicked_selection].start;
|
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - start;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionEndTrim:
|
2006-08-16 16:36:14 -04:00
|
|
|
if (clicked_axisview) {
|
|
|
|
clicked_axisview->order_selection_trims (item, false);
|
2006-06-13 03:27:52 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
start_grab (event, trimmer_cursor);
|
|
|
|
end = selection->time[clicked_selection].end;
|
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - end;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionMove:
|
|
|
|
start = selection->time[clicked_selection].start;
|
|
|
|
start_grab (event);
|
|
|
|
drag_info.pointer_frame_offset = drag_info.grab_frame - start;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selection_op == SelectionMove) {
|
|
|
|
show_verbose_time_cursor(start, 10);
|
|
|
|
} else {
|
|
|
|
show_verbose_time_cursor(drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::drag_selection (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
jack_nframes_t start = 0;
|
|
|
|
jack_nframes_t end = 0;
|
|
|
|
jack_nframes_t length;
|
|
|
|
jack_nframes_t pending_position;
|
|
|
|
|
|
|
|
if ((int32_t) drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
|
|
|
|
pending_position = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pending_position = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (pending_position);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only alter selection if the current frame is
|
|
|
|
different from the last frame position (adjusted)
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (pending_position == drag_info.last_pointer_frame) return;
|
|
|
|
|
|
|
|
switch (selection_op) {
|
|
|
|
case CreateSelection:
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
snap_to (drag_info.grab_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pending_position < drag_info.grab_frame) {
|
|
|
|
start = pending_position;
|
|
|
|
end = drag_info.grab_frame;
|
|
|
|
} else {
|
|
|
|
end = pending_position;
|
|
|
|
start = drag_info.grab_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* first drag: Either add to the selection
|
|
|
|
or create a new selection->
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
|
|
|
|
begin_reversible_command (_("range selection"));
|
|
|
|
|
|
|
|
if (drag_info.copy) {
|
|
|
|
/* adding to the selection */
|
|
|
|
clicked_selection = selection->add (start, end);
|
|
|
|
drag_info.copy = false;
|
|
|
|
} else {
|
|
|
|
/* new selection-> */
|
2006-08-16 16:36:14 -04:00
|
|
|
clicked_selection = selection->set (clicked_axisview, start, end);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionStartTrim:
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
begin_reversible_command (_("trim selection start"));
|
|
|
|
}
|
|
|
|
|
|
|
|
start = selection->time[clicked_selection].start;
|
|
|
|
end = selection->time[clicked_selection].end;
|
|
|
|
|
|
|
|
if (pending_position > end) {
|
|
|
|
start = end;
|
|
|
|
} else {
|
|
|
|
start = pending_position;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionEndTrim:
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
begin_reversible_command (_("trim selection end"));
|
|
|
|
}
|
|
|
|
|
|
|
|
start = selection->time[clicked_selection].start;
|
|
|
|
end = selection->time[clicked_selection].end;
|
|
|
|
|
|
|
|
if (pending_position < start) {
|
|
|
|
end = start;
|
|
|
|
} else {
|
|
|
|
end = pending_position;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SelectionMove:
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
begin_reversible_command (_("move selection"));
|
|
|
|
}
|
|
|
|
|
|
|
|
start = selection->time[clicked_selection].start;
|
|
|
|
end = selection->time[clicked_selection].end;
|
|
|
|
|
|
|
|
length = end - start;
|
|
|
|
|
|
|
|
start = pending_position;
|
|
|
|
snap_to (start);
|
|
|
|
|
|
|
|
end = start + length;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-12-12 15:54:55 -05:00
|
|
|
if (event->button.x >= horizontal_adjustment.get_value() + canvas_width) {
|
2005-09-25 14:42:24 -04:00
|
|
|
start_canvas_autoscroll (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start != end) {
|
|
|
|
selection->replace (clicked_selection, start, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.last_pointer_frame = pending_position;
|
|
|
|
drag_info.first_move = false;
|
|
|
|
|
|
|
|
if (selection_op == SelectionMove) {
|
|
|
|
show_verbose_time_cursor(start, 10);
|
|
|
|
} else {
|
|
|
|
show_verbose_time_cursor(pending_position, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::end_selection_op (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!drag_info.first_move) {
|
|
|
|
drag_selection (item, event);
|
|
|
|
/* XXX this is not object-oriented programming at all. ick */
|
|
|
|
if (selection->time.consolidate()) {
|
|
|
|
selection->TimeChanged ();
|
|
|
|
}
|
|
|
|
commit_reversible_command ();
|
|
|
|
} else {
|
|
|
|
/* just a click, no pointer movement.*/
|
|
|
|
|
|
|
|
if (Keyboard::no_modifier_keys_pressed (&event->button)) {
|
|
|
|
|
|
|
|
selection->clear_time();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX what happens if its a music selection? */
|
|
|
|
session->set_audio_range (selection->time);
|
|
|
|
stop_canvas_autoscroll ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_trim (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
double speed = 1.0;
|
2006-08-16 16:36:14 -04:00
|
|
|
TimeAxisView* tvp = clicked_axisview;
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (tv && tv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
speed = tv->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
jack_nframes_t region_start = (jack_nframes_t) (clicked_regionview->region().position() / speed);
|
|
|
|
jack_nframes_t region_end = (jack_nframes_t) (clicked_regionview->region().last_frame() / speed);
|
|
|
|
jack_nframes_t region_length = (jack_nframes_t) (clicked_regionview->region().length() / speed);
|
2006-01-19 13:00:07 -05:00
|
|
|
|
|
|
|
motion_frozen_playlists.clear();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
//drag_info.item = clicked_regionview->get_name_highlight();
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.motion_callback = &Editor::trim_motion_callback;
|
|
|
|
drag_info.finished_callback = &Editor::trim_finished_callback;
|
|
|
|
|
|
|
|
start_grab (event, trimmer_cursor);
|
|
|
|
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) {
|
|
|
|
trim_op = ContentsTrim;
|
|
|
|
} else {
|
|
|
|
/* These will get overridden for a point trim.*/
|
|
|
|
if (drag_info.current_pointer_frame < (region_start + region_length/2)) {
|
|
|
|
/* closer to start */
|
|
|
|
trim_op = StartTrim;
|
|
|
|
} else if (drag_info.current_pointer_frame > (region_end - region_length/2)) {
|
|
|
|
/* closer to end */
|
|
|
|
trim_op = EndTrim;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (trim_op) {
|
|
|
|
case StartTrim:
|
|
|
|
show_verbose_time_cursor(region_start, 10);
|
|
|
|
break;
|
|
|
|
case EndTrim:
|
|
|
|
show_verbose_time_cursor(region_end, 10);
|
|
|
|
break;
|
|
|
|
case ContentsTrim:
|
|
|
|
show_verbose_time_cursor(drag_info.current_pointer_frame, 10);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv = clicked_regionview;
|
2005-09-25 14:42:24 -04:00
|
|
|
jack_nframes_t frame_delta = 0;
|
|
|
|
bool left_direction;
|
|
|
|
bool obey_snap = !Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier());
|
|
|
|
|
|
|
|
/* snap modifier works differently here..
|
|
|
|
its' current state has to be passed to the
|
|
|
|
various trim functions in order to work properly
|
|
|
|
*/
|
|
|
|
|
|
|
|
double speed = 1.0;
|
2006-08-16 16:36:14 -04:00
|
|
|
TimeAxisView* tvp = clicked_axisview;
|
2006-07-23 08:03:19 -04:00
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
|
2006-01-19 13:00:07 -05:00
|
|
|
pair<set<Playlist*>::iterator,bool> insert_result;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (tv && tv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
speed = tv->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drag_info.last_pointer_frame > drag_info.current_pointer_frame) {
|
|
|
|
left_direction = true;
|
|
|
|
} else {
|
|
|
|
left_direction = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obey_snap) {
|
|
|
|
snap_to (drag_info.current_pointer_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drag_info.current_pointer_frame == drag_info.last_pointer_frame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
|
|
|
|
string trim_type;
|
|
|
|
|
|
|
|
switch (trim_op) {
|
|
|
|
case StartTrim:
|
|
|
|
trim_type = "Region start trim";
|
|
|
|
break;
|
|
|
|
case EndTrim:
|
|
|
|
trim_type = "Region end trim";
|
|
|
|
break;
|
|
|
|
case ContentsTrim:
|
|
|
|
trim_type = "Region content trim";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (trim_type);
|
|
|
|
|
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) {
|
|
|
|
(*i)->region().freeze ();
|
|
|
|
|
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
if (arv)
|
|
|
|
arv->temporarily_hide_envelope ();
|
2006-01-19 13:00:07 -05:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
Playlist * pl = (*i)->region().playlist();
|
2006-01-19 13:00:07 -05:00
|
|
|
insert_result = motion_frozen_playlists.insert (pl);
|
|
|
|
if (insert_result.second) {
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*pl, &pl->get_state(), 0));
|
2006-01-19 13:00:07 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (left_direction) {
|
|
|
|
frame_delta = (drag_info.last_pointer_frame - drag_info.current_pointer_frame);
|
|
|
|
} else {
|
|
|
|
frame_delta = (drag_info.current_pointer_frame - drag_info.last_pointer_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (trim_op) {
|
|
|
|
case StartTrim:
|
2006-07-23 08:03:19 -04:00
|
|
|
if ((left_direction == false) && (drag_info.current_pointer_frame <= rv->region().first_frame()/speed)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
} else {
|
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
|
|
|
single_start_trim (**i, frame_delta, left_direction, obey_snap);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case EndTrim:
|
2006-07-23 08:03:19 -04:00
|
|
|
if ((left_direction == true) && (drag_info.current_pointer_frame > (jack_nframes_t) (rv->region().last_frame()/speed))) {
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
} else {
|
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
|
|
|
single_end_trim (**i, frame_delta, left_direction, obey_snap);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ContentsTrim:
|
|
|
|
{
|
|
|
|
bool swap_direction = false;
|
|
|
|
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) {
|
|
|
|
swap_direction = true;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
single_contents_trim (**i, frame_delta, left_direction, swap_direction, obey_snap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (trim_op) {
|
|
|
|
case StartTrim:
|
2006-07-23 08:03:19 -04:00
|
|
|
show_verbose_time_cursor((jack_nframes_t) (rv->region().position()/speed), 10);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case EndTrim:
|
2006-07-23 08:03:19 -04:00
|
|
|
show_verbose_time_cursor((jack_nframes_t) (rv->region().last_frame()/speed), 10);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case ContentsTrim:
|
|
|
|
show_verbose_time_cursor(drag_info.current_pointer_frame, 10);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.last_pointer_frame = drag_info.current_pointer_frame;
|
|
|
|
drag_info.first_move = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
Editor::single_contents_trim (RegionView& rv, jack_nframes_t frame_delta, bool left_direction, bool swap_direction, bool obey_snap)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
Region& region (rv.region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (region.locked()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
jack_nframes_t new_bound;
|
|
|
|
|
|
|
|
double speed = 1.0;
|
2006-08-16 16:36:14 -04:00
|
|
|
TimeAxisView* tvp = clicked_axisview;
|
2006-07-23 08:03:19 -04:00
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (tv && tv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
speed = tv->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (left_direction) {
|
|
|
|
if (swap_direction) {
|
|
|
|
new_bound = (jack_nframes_t) (region.position()/speed) + frame_delta;
|
|
|
|
} else {
|
|
|
|
new_bound = (jack_nframes_t) (region.position()/speed) - frame_delta;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (swap_direction) {
|
|
|
|
new_bound = (jack_nframes_t) (region.position()/speed) - frame_delta;
|
|
|
|
} else {
|
|
|
|
new_bound = (jack_nframes_t) (region.position()/speed) + frame_delta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obey_snap) {
|
|
|
|
snap_to (new_bound);
|
|
|
|
}
|
|
|
|
region.trim_start ((jack_nframes_t) (new_bound * speed), this);
|
|
|
|
rv.region_changed (StartChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
Editor::single_start_trim (RegionView& rv, jack_nframes_t frame_delta, bool left_direction, bool obey_snap)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
Region& region (rv.region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (region.locked()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
jack_nframes_t new_bound;
|
|
|
|
|
|
|
|
double speed = 1.0;
|
2006-08-16 16:36:14 -04:00
|
|
|
TimeAxisView* tvp = clicked_axisview;
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (tv && tv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
speed = tv->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (left_direction) {
|
|
|
|
new_bound = (jack_nframes_t) (region.position()/speed) - frame_delta;
|
|
|
|
} else {
|
|
|
|
new_bound = (jack_nframes_t) (region.position()/speed) + frame_delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obey_snap) {
|
|
|
|
snap_to (new_bound, (left_direction ? 0 : 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
region.trim_front ((jack_nframes_t) (new_bound * speed), this);
|
|
|
|
|
|
|
|
rv.region_changed (Change (LengthChanged|PositionChanged|StartChanged));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
Editor::single_end_trim (RegionView& rv, jack_nframes_t frame_delta, bool left_direction, bool obey_snap)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
Region& region (rv.region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (region.locked()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
jack_nframes_t new_bound;
|
|
|
|
|
|
|
|
double speed = 1.0;
|
2006-08-16 16:36:14 -04:00
|
|
|
TimeAxisView* tvp = clicked_axisview;
|
2006-08-14 04:44:14 -04:00
|
|
|
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (tv && tv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
speed = tv->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (left_direction) {
|
|
|
|
new_bound = (jack_nframes_t) ((region.last_frame() + 1)/speed) - frame_delta;
|
|
|
|
} else {
|
|
|
|
new_bound = (jack_nframes_t) ((region.last_frame() + 1)/speed) + frame_delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obey_snap) {
|
|
|
|
snap_to (new_bound);
|
|
|
|
}
|
|
|
|
region.trim_end ((jack_nframes_t) (new_bound * speed), this);
|
|
|
|
rv.region_changed (LengthChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::trim_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!drag_info.first_move) {
|
|
|
|
trim_motion_callback (item, event);
|
|
|
|
|
|
|
|
if (!clicked_regionview->get_selected()) {
|
|
|
|
thaw_region_after_trim (*clicked_regionview);
|
|
|
|
} else {
|
|
|
|
|
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
|
|
|
{
|
|
|
|
thaw_region_after_trim (**i);
|
|
|
|
}
|
|
|
|
}
|
2006-01-19 13:00:07 -05:00
|
|
|
|
|
|
|
for (set<Playlist*>::iterator p = motion_frozen_playlists.begin(); p != motion_frozen_playlists.end(); ++p) {
|
|
|
|
//(*p)->thaw ();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command (new MementoCommand<Playlist>(*(*p), 0, &(*p)->get_state()));
|
2006-08-09 21:22:45 -04:00
|
|
|
}
|
2006-01-19 13:00:07 -05:00
|
|
|
|
|
|
|
motion_frozen_playlists.clear ();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
commit_reversible_command();
|
|
|
|
} else {
|
|
|
|
/* no mouse movement */
|
|
|
|
point_trim (event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::point_trim (GdkEvent* event)
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv = clicked_regionview;
|
2005-09-25 14:42:24 -04:00
|
|
|
jack_nframes_t new_bound = drag_info.current_pointer_frame;
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (new_bound);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Choose action dependant on which button was pressed */
|
|
|
|
switch (event->button.button) {
|
|
|
|
case 1:
|
|
|
|
trim_op = StartTrim;
|
|
|
|
begin_reversible_command (_("Start point trim"));
|
|
|
|
|
|
|
|
if (rv->get_selected()) {
|
|
|
|
|
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-07-23 08:03:19 -04:00
|
|
|
if (!(*i)->region().locked()) {
|
2006-08-09 21:22:45 -04:00
|
|
|
Playlist *pl = (*i)->region().playlist();
|
|
|
|
XMLNode &before = pl->get_state();
|
2006-07-23 08:03:19 -04:00
|
|
|
(*i)->region().trim_front (new_bound, this);
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = pl->get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*pl, &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!rv->region().locked()) {
|
2006-08-09 21:22:45 -04:00
|
|
|
Playlist *pl = rv->region().playlist();
|
|
|
|
XMLNode &before = pl->get_state();
|
2006-07-23 08:03:19 -04:00
|
|
|
rv->region().trim_front (new_bound, this);
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = pl->get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*pl, &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command();
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
trim_op = EndTrim;
|
|
|
|
begin_reversible_command (_("End point trim"));
|
|
|
|
|
|
|
|
if (rv->get_selected()) {
|
|
|
|
|
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-07-23 08:03:19 -04:00
|
|
|
if (!(*i)->region().locked()) {
|
2006-08-09 21:22:45 -04:00
|
|
|
Playlist *pl = (*i)->region().playlist();
|
|
|
|
XMLNode &before = pl->get_state();
|
2006-07-23 08:03:19 -04:00
|
|
|
(*i)->region().trim_end (new_bound, this);
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = pl->get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*pl, &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!rv->region().locked()) {
|
2006-08-09 21:22:45 -04:00
|
|
|
Playlist *pl = rv->region().playlist();
|
|
|
|
XMLNode &before = pl->get_state();
|
2006-07-23 08:03:19 -04:00
|
|
|
rv->region().trim_end (new_bound, this);
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = pl->get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command (new MementoCommand<Playlist>(*pl, &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command();
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
Editor::thaw_region_after_trim (RegionView& rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
Region& region (rv.region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (region.locked()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
region.thaw (_("trimmed region"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = region.playlist()->get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command (new MementoCommand<Playlist>(*(region.playlist()), 0, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(&rv);
|
|
|
|
if (arv)
|
|
|
|
arv->unhide_envelope ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::hide_marker (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
Marker* marker;
|
|
|
|
bool is_start;
|
|
|
|
|
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
|
|
|
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* location = find_location_from_marker (marker, is_start);
|
|
|
|
location->set_hidden (true, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event, RangeMarkerOp op)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (session == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.motion_callback = &Editor::drag_range_markerbar_op;
|
|
|
|
drag_info.finished_callback = &Editor::end_range_markerbar_op;
|
|
|
|
|
|
|
|
range_marker_op = op;
|
|
|
|
|
|
|
|
if (!temp_location) {
|
|
|
|
temp_location = new Location;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case CreateRangeMarker:
|
|
|
|
case CreateTransportMarker:
|
|
|
|
|
|
|
|
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) {
|
|
|
|
drag_info.copy = true;
|
|
|
|
} else {
|
|
|
|
drag_info.copy = false;
|
|
|
|
}
|
|
|
|
start_grab (event, selector_cursor);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
show_verbose_time_cursor(drag_info.current_pointer_frame, 10);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::drag_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
jack_nframes_t start = 0;
|
|
|
|
jack_nframes_t end = 0;
|
2005-11-27 17:35:04 -05:00
|
|
|
ArdourCanvas::SimpleRect *crect = (range_marker_op == CreateRangeMarker) ? range_bar_drag_rect: transport_bar_drag_rect;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (drag_info.current_pointer_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only alter selection if the current frame is
|
|
|
|
different from the last frame position.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (drag_info.current_pointer_frame == drag_info.last_pointer_frame) return;
|
|
|
|
|
|
|
|
switch (range_marker_op) {
|
|
|
|
case CreateRangeMarker:
|
|
|
|
case CreateTransportMarker:
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
snap_to (drag_info.grab_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drag_info.current_pointer_frame < drag_info.grab_frame) {
|
|
|
|
start = drag_info.current_pointer_frame;
|
|
|
|
end = drag_info.grab_frame;
|
|
|
|
} else {
|
|
|
|
end = drag_info.current_pointer_frame;
|
|
|
|
start = drag_info.grab_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* first drag: Either add to the selection
|
2006-06-13 03:27:52 -04:00
|
|
|
or create a new selection.
|
2005-09-25 14:42:24 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
|
|
|
|
temp_location->set (start, end);
|
|
|
|
|
2005-11-12 17:07:07 -05:00
|
|
|
crect->show ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
update_marker_drag_item (temp_location);
|
2005-10-28 18:19:45 -04:00
|
|
|
range_marker_drag_rect->show();
|
|
|
|
range_marker_drag_rect->raise_to_top();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-12-12 15:54:55 -05:00
|
|
|
if (event->button.x >= horizontal_adjustment.get_value() + canvas_width) {
|
2005-09-25 14:42:24 -04:00
|
|
|
start_canvas_autoscroll (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start != end) {
|
|
|
|
temp_location->set (start, end);
|
|
|
|
|
|
|
|
double x1 = frame_to_pixel (start);
|
|
|
|
double x2 = frame_to_pixel (end);
|
2005-11-27 17:35:04 -05:00
|
|
|
crect->property_x1() = x1;
|
|
|
|
crect->property_x2() = x2;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
update_marker_drag_item (temp_location);
|
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.last_pointer_frame = drag_info.current_pointer_frame;
|
|
|
|
drag_info.first_move = false;
|
|
|
|
|
|
|
|
show_verbose_time_cursor(drag_info.current_pointer_frame, 10);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
Location * newloc = 0;
|
|
|
|
|
|
|
|
if (!drag_info.first_move) {
|
|
|
|
drag_range_markerbar_op (item, event);
|
|
|
|
|
2005-12-08 13:53:43 -05:00
|
|
|
switch (range_marker_op) {
|
2005-09-25 14:42:24 -04:00
|
|
|
case CreateRangeMarker:
|
2006-08-09 21:22:45 -04:00
|
|
|
{
|
2005-09-25 14:42:24 -04:00
|
|
|
begin_reversible_command (_("new range marker"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = session->locations()->get_state();
|
2006-03-05 14:39:16 -05:00
|
|
|
newloc = new Location(temp_location->start(), temp_location->end(), "unnamed", Location::IsRangeMarker);
|
2005-09-25 14:42:24 -04:00
|
|
|
session->locations()->add (newloc, true);
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = session->locations()->get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
commit_reversible_command ();
|
|
|
|
|
2005-10-28 18:19:45 -04:00
|
|
|
range_bar_drag_rect->hide();
|
|
|
|
range_marker_drag_rect->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
2006-08-09 21:22:45 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
case CreateTransportMarker:
|
|
|
|
// popup menu to pick loop or punch
|
|
|
|
new_transport_marker_context_menu (&event->button, item);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2006-06-13 03:27:52 -04:00
|
|
|
/* just a click, no pointer movement. remember that context menu stuff was handled elsewhere */
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (Keyboard::no_modifier_keys_pressed (&event->button)) {
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
jack_nframes_t start;
|
|
|
|
jack_nframes_t end;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
start = session->locations()->first_mark_before (drag_info.grab_frame);
|
|
|
|
end = session->locations()->first_mark_after (drag_info.grab_frame);
|
|
|
|
|
|
|
|
if (end == max_frames) {
|
|
|
|
end = session->current_end_frame ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start == 0) {
|
|
|
|
start = session->current_start_frame ();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseObject:
|
|
|
|
/* find the two markers on either side and then make the selection from it */
|
|
|
|
cerr << "select between " << start << " .. " << end << endl;
|
|
|
|
select_all_within (start, end, 0.0f, FLT_MAX, Selection::Set);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
/* find the two markers on either side of the click and make the range out of it */
|
|
|
|
selection->set (0, start, end);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_canvas_autoscroll ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.motion_callback = &Editor::drag_mouse_zoom;
|
|
|
|
drag_info.finished_callback = &Editor::end_mouse_zoom;
|
|
|
|
|
|
|
|
start_grab (event, zoom_cursor);
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::drag_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
jack_nframes_t start;
|
|
|
|
jack_nframes_t end;
|
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (drag_info.current_pointer_frame);
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
snap_to (drag_info.grab_frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drag_info.current_pointer_frame == drag_info.last_pointer_frame) return;
|
|
|
|
|
|
|
|
/* base start and end on initial click position */
|
|
|
|
if (drag_info.current_pointer_frame < drag_info.grab_frame) {
|
|
|
|
start = drag_info.current_pointer_frame;
|
|
|
|
end = drag_info.grab_frame;
|
|
|
|
} else {
|
|
|
|
end = drag_info.current_pointer_frame;
|
|
|
|
start = drag_info.grab_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start != end) {
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
2005-10-28 18:19:45 -04:00
|
|
|
zoom_rect->show();
|
|
|
|
zoom_rect->raise_to_top();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
reposition_zoom_rect(start, end);
|
|
|
|
|
|
|
|
drag_info.last_pointer_frame = drag_info.current_pointer_frame;
|
|
|
|
drag_info.first_move = false;
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::end_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!drag_info.first_move) {
|
|
|
|
drag_mouse_zoom (item, event);
|
|
|
|
|
|
|
|
if (drag_info.grab_frame < drag_info.last_pointer_frame) {
|
|
|
|
temporal_zoom_by_frame (drag_info.grab_frame, drag_info.last_pointer_frame, "mouse zoom");
|
|
|
|
} else {
|
|
|
|
temporal_zoom_by_frame (drag_info.last_pointer_frame, drag_info.grab_frame, "mouse zoom");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
temporal_zoom_to_frame (false, drag_info.grab_frame);
|
|
|
|
/*
|
|
|
|
temporal_zoom_step (false);
|
|
|
|
center_screen (drag_info.grab_frame);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2005-10-28 18:19:45 -04:00
|
|
|
zoom_rect->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::reposition_zoom_rect (jack_nframes_t start, jack_nframes_t end)
|
|
|
|
{
|
|
|
|
double x1 = frame_to_pixel (start);
|
|
|
|
double x2 = frame_to_pixel (end);
|
|
|
|
double y2 = canvas_height - 2;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.motion_callback = &Editor::drag_rubberband_select;
|
|
|
|
drag_info.finished_callback = &Editor::end_rubberband_select;
|
|
|
|
|
|
|
|
start_grab (event, cross_hair_cursor);
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
jack_nframes_t start;
|
|
|
|
jack_nframes_t end;
|
|
|
|
double y1;
|
|
|
|
double y2;
|
|
|
|
|
|
|
|
/* use a bigger drag threshold than the default */
|
|
|
|
|
|
|
|
if (abs ((int) (drag_info.current_pointer_frame - drag_info.grab_frame)) < 8) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
// snap_to (drag_info.current_pointer_frame);
|
|
|
|
|
|
|
|
// if (drag_info.first_move) {
|
|
|
|
// snap_to (drag_info.grab_frame);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/* base start and end on initial click position */
|
|
|
|
if (drag_info.current_pointer_frame < drag_info.grab_frame) {
|
|
|
|
start = drag_info.current_pointer_frame;
|
|
|
|
end = drag_info.grab_frame;
|
|
|
|
} else {
|
|
|
|
end = drag_info.current_pointer_frame;
|
|
|
|
start = drag_info.grab_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drag_info.current_pointer_y < drag_info.grab_y) {
|
|
|
|
y1 = drag_info.current_pointer_y;
|
|
|
|
y2 = drag_info.grab_y;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
y2 = drag_info.current_pointer_y;
|
|
|
|
y1 = drag_info.grab_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (start != end || y1 != y2) {
|
|
|
|
|
|
|
|
double x1 = frame_to_pixel (start);
|
|
|
|
double x2 = frame_to_pixel (end);
|
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
rubberband_rect->property_x1() = x1;
|
|
|
|
rubberband_rect->property_y1() = y1;
|
|
|
|
rubberband_rect->property_x2() = x2;
|
|
|
|
rubberband_rect->property_y2() = y2;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-28 18:19:45 -04:00
|
|
|
rubberband_rect->show();
|
|
|
|
rubberband_rect->raise_to_top();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
drag_info.last_pointer_frame = drag_info.current_pointer_frame;
|
|
|
|
drag_info.first_move = false;
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!drag_info.first_move) {
|
|
|
|
|
|
|
|
drag_rubberband_select (item, event);
|
|
|
|
|
|
|
|
double y1,y2;
|
|
|
|
if (drag_info.current_pointer_y < drag_info.grab_y) {
|
|
|
|
y1 = drag_info.current_pointer_y;
|
|
|
|
y2 = drag_info.grab_y;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
y2 = drag_info.current_pointer_y;
|
|
|
|
y1 = drag_info.grab_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
Selection::Operation op = Keyboard::selection_type (event->button.state);
|
2005-09-25 14:42:24 -04:00
|
|
|
bool commit;
|
|
|
|
|
|
|
|
begin_reversible_command (_("select regions"));
|
|
|
|
|
|
|
|
if (drag_info.grab_frame < drag_info.last_pointer_frame) {
|
2006-03-05 14:39:16 -05:00
|
|
|
commit = select_all_within (drag_info.grab_frame, drag_info.last_pointer_frame, y1, y2, op);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-03-05 14:39:16 -05:00
|
|
|
commit = select_all_within (drag_info.last_pointer_frame, drag_info.grab_frame, y1, y2, op);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (commit) {
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2006-07-23 08:03:19 -04:00
|
|
|
selection->clear_regions();
|
2005-09-25 14:42:24 -04:00
|
|
|
selection->clear_points ();
|
|
|
|
selection->clear_lines ();
|
|
|
|
}
|
|
|
|
|
2005-10-28 18:19:45 -04:00
|
|
|
rubberband_rect->hide();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gint
|
2005-11-23 12:21:12 -05: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-07-23 08:03:19 -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:
|
2006-01-13 17:46:04 -05:00
|
|
|
string str;
|
2005-10-26 21:10:36 -04:00
|
|
|
prompter.get_result(str);
|
|
|
|
if (str.length()) {
|
2006-07-23 08:03:19 -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
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::start_time_fx (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
drag_info.item = item;
|
|
|
|
drag_info.motion_callback = &Editor::time_fx_motion;
|
|
|
|
drag_info.finished_callback = &Editor::end_time_fx;
|
|
|
|
|
|
|
|
start_grab (event);
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::time_fx_motion (ArdourCanvas::Item *item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv = clicked_regionview;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
|
|
|
|
snap_to (drag_info.current_pointer_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drag_info.current_pointer_frame == drag_info.last_pointer_frame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (drag_info.current_pointer_frame > rv->region().position()) {
|
|
|
|
rv->get_time_axis_view().show_timestretch (rv->region().position(), drag_info.current_pointer_frame);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
drag_info.last_pointer_frame = drag_info.current_pointer_frame;
|
|
|
|
drag_info.first_move = false;
|
|
|
|
|
|
|
|
show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-23 12:21:12 -05:00
|
|
|
Editor::end_time_fx (ArdourCanvas::Item* item, GdkEvent* event)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
clicked_regionview->get_time_axis_view().hide_timestretch ();
|
|
|
|
|
|
|
|
if (drag_info.first_move) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
jack_nframes_t newlen = drag_info.last_pointer_frame - clicked_regionview->region().position();
|
|
|
|
float percentage = (float) ((double) newlen - (double) clicked_regionview->region().length()) / ((double) newlen) * 100.0f;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
begin_reversible_command (_("timestretch"));
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (run_timestretch (selection->regions, percentage) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
session->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
Editor::mouse_brush_insert_region (RegionView* rv, jack_nframes_t pos)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
/* no brushing without a useful snap setting */
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
// FIXME
|
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
|
|
|
|
assert(arv);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (snap_mode) {
|
|
|
|
case SnapMagnetic:
|
|
|
|
return; /* can't work because it allows region to be placed anywhere */
|
|
|
|
default:
|
|
|
|
break; /* OK */
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (snap_type) {
|
|
|
|
case SnapToFrame:
|
|
|
|
case SnapToMark:
|
|
|
|
case SnapToEditCursor:
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't brush a copy over the original */
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (pos == rv->region().position()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
RouteTimeAxisView* atv = dynamic_cast<RouteTimeAxisView*>(&arv->get_time_axis_view());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if (atv == 0 || !atv->is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Playlist* playlist = atv->playlist();
|
|
|
|
double speed = atv->get_diskstream()->speed();
|
|
|
|
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = playlist->get_state();
|
2006-07-23 08:03:19 -04:00
|
|
|
playlist->add_region (*(new AudioRegion (arv->audio_region())), (jack_nframes_t) (pos * speed));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &after = playlist->get_state();
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
// playlist is frozen, so we have to update manually
|
|
|
|
|
|
|
|
playlist->StateChanged (Change (~0)); /* EMIT SIGNAL */
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
Editor::track_height_step_timeout ()
|
|
|
|
{
|
|
|
|
struct timeval now;
|
|
|
|
struct timeval delta;
|
|
|
|
|
|
|
|
gettimeofday (&now, 0);
|
|
|
|
timersub (&now, &last_track_height_step_timestamp, &delta);
|
|
|
|
|
|
|
|
if (delta.tv_sec * 1000000 + delta.tv_usec > 250000) { /* milliseconds */
|
|
|
|
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
|
|
|
}
|