2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000-2004 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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2007-05-11 11:06:12 -04:00
|
|
|
/* Note: public Editor methods are documented in public_editor.h */
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <pbd/error.h>
|
|
|
|
#include <pbd/basename.h>
|
|
|
|
#include <pbd/pthread_utils.h>
|
2006-08-09 21:22:45 -04:00
|
|
|
#include <pbd/memento_command.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/utils.h>
|
|
|
|
#include <gtkmm2ext/choice.h>
|
2007-03-19 03:07:38 -04:00
|
|
|
#include <gtkmm2ext/window_title.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include <ardour/audioengine.h>
|
|
|
|
#include <ardour/session.h>
|
|
|
|
#include <ardour/audioplaylist.h>
|
|
|
|
#include <ardour/audioregion.h>
|
2006-06-14 21:34:54 -04:00
|
|
|
#include <ardour/audio_diskstream.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/utils.h>
|
|
|
|
#include <ardour/location.h>
|
|
|
|
#include <ardour/named_selection.h>
|
|
|
|
#include <ardour/audio_track.h>
|
|
|
|
#include <ardour/audioplaylist.h>
|
|
|
|
#include <ardour/region_factory.h>
|
2007-01-09 18:24:54 -05:00
|
|
|
#include <ardour/playlist_factory.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/reverse.h>
|
2007-08-06 01:30:18 -04:00
|
|
|
#include <ardour/quantize.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"
|
|
|
|
#include "automation_time_axis.h"
|
|
|
|
#include "streamview.h"
|
2006-08-01 13:19:38 -04:00
|
|
|
#include "audio_region_view.h"
|
2007-08-06 01:30:18 -04:00
|
|
|
#include "midi_region_view.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "rgb_macros.h"
|
|
|
|
#include "selection_templates.h"
|
|
|
|
#include "selection.h"
|
|
|
|
#include "editing.h"
|
|
|
|
#include "gtk-custom-hruler.h"
|
2006-04-06 12:51:27 -04:00
|
|
|
#include "gui_thread.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#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;
|
2007-03-19 03:07:38 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Editing;
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
Editor operations
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::undo (uint32_t n)
|
|
|
|
{
|
|
|
|
if (session) {
|
|
|
|
session->undo (n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::redo (uint32_t n)
|
|
|
|
{
|
|
|
|
if (session) {
|
|
|
|
session->redo (n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::split_region ()
|
|
|
|
{
|
2007-11-07 20:40:25 -05:00
|
|
|
split_region_at (get_preferred_edit_position());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::split_region_at (nframes_t where)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
split_regions_at (where, selection->regions);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::split_regions_at (nframes_t where, RegionSelection& regions)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
use filechooser widget in export dialog, selected files set format combos, hide progress bar until use in export dialog, speed up 'separate regions in range' operation on larger sessions, ruler scale now calculated separately to mark generation, fix for non-stacked layering regression, try not to generate 'buried' crossfades, use playlist->freeze() to speed up copying/moving regions on large playlists (not done for undo), width dependent items now reset on regionview init, get rid of jack_port_ensure_monitor check, remove audiosourse _length (only source has a length.. i think), make overlapend differ to overlapexternal where start points coincide.
git-svn-id: svn://localhost/ardour2/trunk@2576 d708f5d6-7413-0410-9779-e7cbd77b26cf
2007-10-26 09:32:24 -04:00
|
|
|
list <boost::shared_ptr<Playlist > > used_playlists;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
begin_reversible_command (_("split"));
|
|
|
|
|
2007-10-11 18:07:47 -04:00
|
|
|
// if splitting a single region, and snap-to is using
|
|
|
|
// region boundaries, don't pay attention to them
|
|
|
|
|
|
|
|
if (regions.size() == 1) {
|
|
|
|
switch (snap_type) {
|
|
|
|
case SnapToRegionStart:
|
|
|
|
case SnapToRegionSync:
|
|
|
|
case SnapToRegionEnd:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snap_to (where);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
snap_to (where);
|
|
|
|
}
|
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
for (RegionSelection::iterator a = regions.begin(); a != regions.end(); ) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
RegionSelection::iterator tmp;
|
|
|
|
|
|
|
|
/* XXX this test needs to be more complicated, to make sure we really
|
|
|
|
have something to split.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!(*a)->region()->covers (where)) {
|
|
|
|
++a;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = a;
|
|
|
|
++tmp;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> pl = (*a)->region()->playlist();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
use filechooser widget in export dialog, selected files set format combos, hide progress bar until use in export dialog, speed up 'separate regions in range' operation on larger sessions, ruler scale now calculated separately to mark generation, fix for non-stacked layering regression, try not to generate 'buried' crossfades, use playlist->freeze() to speed up copying/moving regions on large playlists (not done for undo), width dependent items now reset on regionview init, get rid of jack_port_ensure_monitor check, remove audiosourse _length (only source has a length.. i think), make overlapend differ to overlapexternal where start points coincide.
git-svn-id: svn://localhost/ardour2/trunk@2576 d708f5d6-7413-0410-9779-e7cbd77b26cf
2007-10-26 09:32:24 -04:00
|
|
|
if (! pl->frozen()) {
|
|
|
|
/* we haven't seen this playlist before */
|
|
|
|
|
|
|
|
/* remember used playlists so we can thaw them later */
|
|
|
|
used_playlists.push_back(pl);
|
|
|
|
pl->freeze();
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*a);
|
|
|
|
if (arv)
|
|
|
|
_new_regionviews_show_envelope = arv->envelope_visible();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (pl) {
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = pl->get_state();
|
2006-07-23 08:03:19 -04:00
|
|
|
pl->split_region ((*a)->region(), where);
|
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
|
|
|
}
|
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
a = tmp;
|
use filechooser widget in export dialog, selected files set format combos, hide progress bar until use in export dialog, speed up 'separate regions in range' operation on larger sessions, ruler scale now calculated separately to mark generation, fix for non-stacked layering regression, try not to generate 'buried' crossfades, use playlist->freeze() to speed up copying/moving regions on large playlists (not done for undo), width dependent items now reset on regionview init, get rid of jack_port_ensure_monitor check, remove audiosourse _length (only source has a length.. i think), make overlapend differ to overlapexternal where start points coincide.
git-svn-id: svn://localhost/ardour2/trunk@2576 d708f5d6-7413-0410-9779-e7cbd77b26cf
2007-10-26 09:32:24 -04:00
|
|
|
}
|
|
|
|
while (used_playlists.size() > 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
use filechooser widget in export dialog, selected files set format combos, hide progress bar until use in export dialog, speed up 'separate regions in range' operation on larger sessions, ruler scale now calculated separately to mark generation, fix for non-stacked layering regression, try not to generate 'buried' crossfades, use playlist->freeze() to speed up copying/moving regions on large playlists (not done for undo), width dependent items now reset on regionview init, get rid of jack_port_ensure_monitor check, remove audiosourse _length (only source has a length.. i think), make overlapend differ to overlapexternal where start points coincide.
git-svn-id: svn://localhost/ardour2/trunk@2576 d708f5d6-7413-0410-9779-e7cbd77b26cf
2007-10-26 09:32:24 -04:00
|
|
|
list <boost::shared_ptr<Playlist > >::iterator i = used_playlists.begin();
|
|
|
|
(*i)->thaw();
|
|
|
|
used_playlists.pop_front();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
commit_reversible_command ();
|
|
|
|
_new_regionviews_show_envelope = false;
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
|
|
|
|
/** Remove `clicked_regionview' */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::remove_clicked_region ()
|
|
|
|
{
|
2006-08-16 16:36:14 -04:00
|
|
|
if (clicked_routeview == 0 || clicked_regionview == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist = clicked_routeview->playlist();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
begin_reversible_command (_("remove region"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = playlist->get_state();
|
2006-08-29 17:21:48 -04:00
|
|
|
playlist->remove_region (clicked_regionview->region());
|
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
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
|
|
|
|
/** Remove the selected regions */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2007-05-10 07:53:35 -04:00
|
|
|
Editor::remove_selected_regions ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-05-10 07:53:35 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/* XXX: should be called remove regions if we're removing more than one */
|
|
|
|
begin_reversible_command (_("remove region"));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-11 18:07:47 -04:00
|
|
|
|
2007-09-09 20:06:58 -04:00
|
|
|
while (!selection->regions.empty()) {
|
|
|
|
boost::shared_ptr<Region> region = selection->regions.front()->region ();
|
2007-05-10 07:53:35 -04:00
|
|
|
boost::shared_ptr<Playlist> playlist = region->playlist ();
|
2007-10-11 18:07:47 -04:00
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
XMLNode &before = playlist->get_state();
|
|
|
|
playlist->remove_region (region);
|
|
|
|
XMLNode &after = playlist->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-10-11 18:07:47 -04:00
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
commit_reversible_command ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region>
|
2005-09-25 14:42:24 -04:00
|
|
|
Editor::select_region_for_operation (int dir, TimeAxisView **tv)
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv;
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> region;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t start = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (selection->time.start () == selection->time.end_frame ()) {
|
|
|
|
|
|
|
|
/* no current selection-> is there a selected regionview? */
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty()) {
|
2006-08-29 17:21:48 -04:00
|
|
|
return region;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
rv = *(selection->regions.begin());
|
2005-09-25 14:42:24 -04:00
|
|
|
(*tv) = &rv->get_time_axis_view();
|
2006-08-29 17:21:48 -04:00
|
|
|
region = rv->region();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
} else if (!selection->tracks.empty()) {
|
|
|
|
|
|
|
|
(*tv) = selection->tracks.front();
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
RouteTimeAxisView* rtv;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if ((rtv = dynamic_cast<RouteTimeAxisView*> (*tv)) != 0) {
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> pl;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if ((pl = rtv->playlist()) == 0) {
|
2006-08-29 17:21:48 -04:00
|
|
|
return region;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
region = pl->top_region_at (start);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return region;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::extend_selection_to_end_of_region (bool next)
|
|
|
|
{
|
|
|
|
TimeAxisView *tv;
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> region;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t start;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if ((region = select_region_for_operation (next ? 1 : 0, &tv)) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (region && selection->time.start () == selection->time.end_frame ()) {
|
|
|
|
start = region->position();
|
|
|
|
} else {
|
|
|
|
start = selection->time.start ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to leave the selection with the same route if possible */
|
|
|
|
|
|
|
|
if ((tv = selection->time.track) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("extend selection"));
|
|
|
|
selection->set (tv, start, region->position() + region->length());
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::extend_selection_to_start_of_region (bool previous)
|
|
|
|
{
|
|
|
|
TimeAxisView *tv;
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> region;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t end;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if ((region = select_region_for_operation (previous ? -1 : 0, &tv)) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (region && selection->time.start () == selection->time.end_frame ()) {
|
|
|
|
end = region->position() + region->length();
|
|
|
|
} else {
|
|
|
|
end = selection->time.end_frame ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to leave the selection with the same route if possible */
|
|
|
|
|
|
|
|
if ((tv = selection->time.track) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("extend selection"));
|
|
|
|
selection->set (tv, region->position(), end);
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::nudge_forward (bool next)
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t distance;
|
|
|
|
nframes_t next_distance;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (!session) return;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
begin_reversible_command (_("nudge forward"));
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> r ((*i)->region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
distance = get_nudge_distance (r->position(), next_distance);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (next) {
|
|
|
|
distance = next_distance;
|
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &before = r->playlist()->get_state();
|
|
|
|
r->set_position (r->position() + distance, this);
|
|
|
|
XMLNode &after = r->playlist()->get_state();
|
|
|
|
session->add_command (new MementoCommand<Playlist>(*(r->playlist()), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
distance = get_nudge_distance (playhead_cursor->current_frame, next_distance);
|
|
|
|
session->request_locate (playhead_cursor->current_frame + distance);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::nudge_backward (bool next)
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t distance;
|
|
|
|
nframes_t next_distance;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (!session) return;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
begin_reversible_command (_("nudge forward"));
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> r ((*i)->region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
distance = get_nudge_distance (r->position(), next_distance);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (next) {
|
|
|
|
distance = next_distance;
|
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &before = r->playlist()->get_state();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (r->position() > distance) {
|
|
|
|
r->set_position (r->position() - distance, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-08-29 17:21:48 -04:00
|
|
|
r->set_position (0, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &after = r->playlist()->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*(r->playlist()), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
distance = get_nudge_distance (playhead_cursor->current_frame, next_distance);
|
|
|
|
|
|
|
|
if (playhead_cursor->current_frame > distance) {
|
|
|
|
session->request_locate (playhead_cursor->current_frame - distance);
|
|
|
|
} else {
|
2006-03-11 11:01:06 -05:00
|
|
|
session->goto_start();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::nudge_forward_capture_offset ()
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t distance;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (!session) return;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
begin_reversible_command (_("nudge forward"));
|
|
|
|
|
|
|
|
distance = session->worst_output_latency();
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> r ((*i)->region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &before = r->playlist()->get_state();
|
|
|
|
r->set_position (r->position() + distance, this);
|
|
|
|
XMLNode &after = r->playlist()->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*(r->playlist()), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::nudge_backward_capture_offset ()
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t distance;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (!session) return;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
begin_reversible_command (_("nudge forward"));
|
|
|
|
|
|
|
|
distance = session->worst_output_latency();
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> r ((*i)->region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &before = r->playlist()->get_state();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (r->position() > distance) {
|
|
|
|
r->set_position (r->position() - distance, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-08-29 17:21:48 -04:00
|
|
|
r->set_position (0, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &after = r->playlist()->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*(r->playlist()), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DISPLAY MOTION */
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::move_to_start ()
|
|
|
|
{
|
2006-03-11 11:01:06 -05:00
|
|
|
session->goto_start ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::move_to_end ()
|
|
|
|
{
|
|
|
|
|
|
|
|
session->request_locate (session->current_end_frame());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::build_region_boundary_cache ()
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t pos = 0;
|
2007-04-12 19:20:37 -04:00
|
|
|
vector<RegionPoint> interesting_points;
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> r;
|
2005-09-25 14:42:24 -04:00
|
|
|
TrackViewList tracks;
|
2007-04-12 19:20:37 -04:00
|
|
|
bool at_end = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
region_boundary_cache.clear ();
|
|
|
|
|
|
|
|
if (session == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (snap_type) {
|
|
|
|
case SnapToRegionStart:
|
2007-04-12 19:20:37 -04:00
|
|
|
interesting_points.push_back (Start);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case SnapToRegionEnd:
|
2007-04-12 19:20:37 -04:00
|
|
|
interesting_points.push_back (End);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case SnapToRegionSync:
|
2007-04-12 19:20:37 -04:00
|
|
|
interesting_points.push_back (SyncPoint);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case SnapToRegionBoundary:
|
2007-04-12 19:20:37 -04:00
|
|
|
interesting_points.push_back (Start);
|
|
|
|
interesting_points.push_back (End);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
default:
|
2005-10-06 15:10:57 -04:00
|
|
|
fatal << string_compose (_("build_region_boundary_cache called with snap_type = %1"), snap_type) << endmsg;
|
2005-09-25 14:42:24 -04:00
|
|
|
/*NOTREACHED*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TimeAxisView *ontrack = 0;
|
2007-04-12 19:20:37 -04:00
|
|
|
TrackViewList tlist;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (!selection->tracks.empty()) {
|
|
|
|
tlist = selection->tracks;
|
|
|
|
} else {
|
|
|
|
tlist = track_views;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
while (pos < session->current_end_frame() && !at_end) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
nframes_t rpos;
|
|
|
|
nframes_t lpos = max_frames;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
for (vector<RegionPoint>::iterator p = interesting_points.begin(); p != interesting_points.end(); ++p) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if ((r = find_next_region (pos, *p, 1, tlist, &ontrack)) == 0) {
|
2007-10-11 18:07:47 -04:00
|
|
|
if (*p == interesting_points.back()) {
|
|
|
|
at_end = true;
|
|
|
|
}
|
2007-04-12 19:20:37 -04:00
|
|
|
/* move to next point type */
|
|
|
|
continue;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
switch (*p) {
|
|
|
|
case Start:
|
|
|
|
rpos = r->first_frame();
|
|
|
|
break;
|
|
|
|
case End:
|
|
|
|
rpos = r->last_frame();
|
|
|
|
break;
|
|
|
|
case SyncPoint:
|
|
|
|
rpos = r->adjust_to_sync (r->first_frame());
|
|
|
|
break;
|
|
|
|
default:
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
2007-04-12 19:20:37 -04:00
|
|
|
|
|
|
|
float speed = 1.0f;
|
|
|
|
RouteTimeAxisView *rtav;
|
|
|
|
|
|
|
|
if (ontrack != 0 && (rtav = dynamic_cast<RouteTimeAxisView*>(ontrack)) != 0 ) {
|
|
|
|
if (rtav->get_diskstream() != 0) {
|
|
|
|
speed = rtav->get_diskstream()->speed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rpos = track_frame_to_session_frame (rpos, speed);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (rpos < lpos) {
|
|
|
|
lpos = rpos;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
/* prevent duplicates, but we don't use set<> because we want to be able
|
|
|
|
to sort later.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
vector<nframes_t>::iterator ri;
|
|
|
|
|
|
|
|
for (ri = region_boundary_cache.begin(); ri != region_boundary_cache.end(); ++ri) {
|
|
|
|
if (*ri == rpos) {
|
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (ri == region_boundary_cache.end()) {
|
|
|
|
region_boundary_cache.push_back (rpos);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
pos = lpos + 1;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-04-12 19:20:37 -04:00
|
|
|
|
|
|
|
/* finally sort to be sure that the order is correct */
|
|
|
|
|
|
|
|
sort (region_boundary_cache.begin(), region_boundary_cache.end());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region>
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::find_next_region (nframes_t frame, RegionPoint point, int32_t dir, TrackViewList& tracks, TimeAxisView **ontrack)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
TrackViewList::iterator i;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t closest = max_frames;
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> ret;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t rpos = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
float track_speed;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t track_frame;
|
2007-04-12 19:20:37 -04:00
|
|
|
RouteTimeAxisView *rtav;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (i = tracks.begin(); i != tracks.end(); ++i) {
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t distance;
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> r;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
track_speed = 1.0f;
|
2007-04-12 19:20:37 -04:00
|
|
|
if ( (rtav = dynamic_cast<RouteTimeAxisView*>(*i)) != 0 ) {
|
|
|
|
if (rtav->get_diskstream()!=0)
|
|
|
|
track_speed = rtav->get_diskstream()->speed();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-14 10:44:23 -05:00
|
|
|
track_frame = session_frame_to_track_frame(frame, track_speed);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if ((r = (*i)->find_next_region (track_frame, point, dir)) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (point) {
|
|
|
|
case Start:
|
|
|
|
rpos = r->first_frame ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case End:
|
|
|
|
rpos = r->last_frame ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SyncPoint:
|
|
|
|
rpos = r->adjust_to_sync (r->first_frame());
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 10:44:23 -05:00
|
|
|
// rpos is a "track frame", converting it to "session frame"
|
|
|
|
rpos = track_frame_to_session_frame(rpos, track_speed);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (rpos > frame) {
|
|
|
|
distance = rpos - frame;
|
|
|
|
} else {
|
|
|
|
distance = frame - rpos;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (distance < closest) {
|
|
|
|
closest = distance;
|
|
|
|
if (ontrack != 0)
|
|
|
|
*ontrack = (*i);
|
|
|
|
ret = r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::cursor_to_region_point (Cursor* cursor, RegionPoint point, int32_t dir)
|
|
|
|
{
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> r;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t pos = cursor->current_frame;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TimeAxisView *ontrack = 0;
|
|
|
|
|
|
|
|
// so we don't find the current region again..
|
|
|
|
if (dir>0 || pos>0)
|
|
|
|
pos+=dir;
|
|
|
|
|
|
|
|
if (!selection->tracks.empty()) {
|
|
|
|
|
|
|
|
r = find_next_region (pos, point, dir, selection->tracks, &ontrack);
|
|
|
|
|
2006-08-16 16:36:14 -04:00
|
|
|
} else if (clicked_axisview) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
TrackViewList t;
|
2006-08-16 16:36:14 -04:00
|
|
|
t.push_back (clicked_axisview);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
r = find_next_region (pos, point, dir, t, &ontrack);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
r = find_next_region (pos, point, dir, track_views, &ontrack);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (point){
|
|
|
|
case Start:
|
|
|
|
pos = r->first_frame ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case End:
|
|
|
|
pos = r->last_frame ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SyncPoint:
|
|
|
|
pos = r->adjust_to_sync (r->first_frame());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
float speed = 1.0f;
|
2007-04-12 19:20:37 -04:00
|
|
|
RouteTimeAxisView *rtav;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if ( ontrack != 0 && (rtav = dynamic_cast<RouteTimeAxisView*>(ontrack)) != 0 ) {
|
|
|
|
if (rtav->get_diskstream() != 0) {
|
|
|
|
speed = rtav->get_diskstream()->speed();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-14 10:44:23 -05:00
|
|
|
pos = track_frame_to_session_frame(pos, speed);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (cursor == playhead_cursor) {
|
|
|
|
session->request_locate (pos);
|
|
|
|
} else {
|
|
|
|
cursor->set_position (pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::cursor_to_next_region_point (Cursor* cursor, RegionPoint point)
|
|
|
|
{
|
|
|
|
cursor_to_region_point (cursor, point, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::cursor_to_previous_region_point (Cursor* cursor, RegionPoint point)
|
|
|
|
{
|
|
|
|
cursor_to_region_point (cursor, point, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::cursor_to_selection_start (Cursor *cursor)
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t pos = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseObject:
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
|
|
|
pos = selection->regions.start();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
if (!selection->time.empty()) {
|
|
|
|
pos = selection->time.start ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor == playhead_cursor) {
|
|
|
|
session->request_locate (pos);
|
|
|
|
} else {
|
|
|
|
cursor->set_position (pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::cursor_to_selection_end (Cursor *cursor)
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t pos = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (mouse_mode) {
|
|
|
|
case MouseObject:
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
|
|
|
pos = selection->regions.end_frame();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
if (!selection->time.empty()) {
|
|
|
|
pos = selection->time.end_frame ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor == playhead_cursor) {
|
|
|
|
session->request_locate (pos);
|
|
|
|
} else {
|
|
|
|
cursor->set_position (pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
void
|
|
|
|
Editor::scroll_playhead (bool forward)
|
|
|
|
{
|
|
|
|
nframes_t pos = playhead_cursor->current_frame;
|
|
|
|
nframes_t delta = (nframes_t) floor (current_page_frames() / 0.8);
|
|
|
|
|
|
|
|
if (forward) {
|
|
|
|
if (pos == max_frames) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pos < max_frames - delta) {
|
|
|
|
pos += delta ;
|
|
|
|
} else {
|
|
|
|
pos = max_frames;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (pos == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pos > delta) {
|
|
|
|
pos -= delta;
|
|
|
|
} else {
|
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
session->request_locate (pos);
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::playhead_backward ()
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t pos;
|
|
|
|
nframes_t cnt;
|
2005-09-25 14:42:24 -04:00
|
|
|
float prefix;
|
|
|
|
bool was_floating;
|
|
|
|
|
|
|
|
if (get_prefix (prefix, was_floating)) {
|
|
|
|
cnt = 1;
|
|
|
|
} else {
|
|
|
|
if (was_floating) {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (prefix * session->frame_rate ());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) prefix;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = playhead_cursor->current_frame;
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
if ((nframes_t) pos < cnt) {
|
2005-09-25 14:42:24 -04:00
|
|
|
pos = 0;
|
|
|
|
} else {
|
|
|
|
pos -= cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX this is completely insane. with the current buffering
|
|
|
|
design, we'll force a complete track buffer flush and
|
|
|
|
reload, just to move 1 sample !!!
|
|
|
|
*/
|
|
|
|
|
|
|
|
session->request_locate (pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::playhead_forward ()
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t pos;
|
|
|
|
nframes_t cnt;
|
2005-09-25 14:42:24 -04:00
|
|
|
bool was_floating;
|
|
|
|
float prefix;
|
|
|
|
|
|
|
|
if (get_prefix (prefix, was_floating)) {
|
|
|
|
cnt = 1;
|
|
|
|
} else {
|
|
|
|
if (was_floating) {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (prefix * session->frame_rate ());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (prefix);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = playhead_cursor->current_frame;
|
|
|
|
|
|
|
|
/* XXX this is completely insane. with the current buffering
|
|
|
|
design, we'll force a complete track buffer flush and
|
|
|
|
reload, just to move 1 sample !!!
|
|
|
|
*/
|
|
|
|
|
|
|
|
session->request_locate (pos+cnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::cursor_align (bool playhead_to_edit)
|
|
|
|
{
|
|
|
|
if (playhead_to_edit) {
|
|
|
|
if (session) {
|
2007-11-07 20:40:25 -05:00
|
|
|
session->request_locate (get_preferred_edit_position());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
edit_cursor->set_position (playhead_cursor->current_frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::edit_cursor_backward ()
|
|
|
|
{
|
2007-11-07 20:40:25 -05:00
|
|
|
nframes64_t pos;
|
|
|
|
nframes64_t cnt;
|
2005-09-25 14:42:24 -04:00
|
|
|
float prefix;
|
|
|
|
bool was_floating;
|
|
|
|
|
|
|
|
if (get_prefix (prefix, was_floating)) {
|
|
|
|
cnt = 1;
|
|
|
|
} else {
|
|
|
|
if (was_floating) {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (prefix * session->frame_rate ());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) prefix;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
if ((pos = get_preferred_edit_position()) < 0) {
|
|
|
|
return;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
if (pos < cnt) {
|
2005-09-25 14:42:24 -04:00
|
|
|
pos = 0;
|
|
|
|
} else {
|
|
|
|
pos -= cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
edit_cursor->set_position (pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::edit_cursor_forward ()
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t pos;
|
|
|
|
nframes_t cnt;
|
2005-09-25 14:42:24 -04:00
|
|
|
bool was_floating;
|
|
|
|
float prefix;
|
|
|
|
|
|
|
|
if (get_prefix (prefix, was_floating)) {
|
|
|
|
cnt = 1;
|
|
|
|
} else {
|
|
|
|
if (was_floating) {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (prefix * session->frame_rate ());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (prefix);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = edit_cursor->current_frame;
|
|
|
|
edit_cursor->set_position (pos+cnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::goto_frame ()
|
|
|
|
{
|
|
|
|
float prefix;
|
|
|
|
bool was_floating;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t frame;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (get_prefix (prefix, was_floating)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (was_floating) {
|
2006-10-21 15:01:50 -04:00
|
|
|
frame = (nframes_t) floor (prefix * session->frame_rate());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-10-21 15:01:50 -04:00
|
|
|
frame = (nframes_t) floor (prefix);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
session->request_locate (frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::scroll_backward (float pages)
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t frame;
|
|
|
|
nframes_t one_page = (nframes_t) rint (canvas_width * frames_per_unit);
|
2005-09-25 14:42:24 -04:00
|
|
|
bool was_floating;
|
|
|
|
float prefix;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t cnt;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (get_prefix (prefix, was_floating)) {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (pages * one_page);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
if (was_floating) {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (prefix * session->frame_rate());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (prefix * one_page);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (leftmost_frame < cnt) {
|
|
|
|
frame = 0;
|
|
|
|
} else {
|
|
|
|
frame = leftmost_frame - cnt;
|
|
|
|
}
|
|
|
|
|
2007-01-11 15:36:35 -05:00
|
|
|
reset_x_origin (frame);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::scroll_forward (float pages)
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t frame;
|
|
|
|
nframes_t one_page = (nframes_t) rint (canvas_width * frames_per_unit);
|
2005-09-25 14:42:24 -04:00
|
|
|
bool was_floating;
|
|
|
|
float prefix;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t cnt;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (get_prefix (prefix, was_floating)) {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (pages * one_page);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
if (was_floating) {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (prefix * session->frame_rate());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-10-21 15:01:50 -04:00
|
|
|
cnt = (nframes_t) floor (prefix * one_page);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
if (max_frames - cnt < leftmost_frame) {
|
|
|
|
frame = max_frames - cnt;
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
frame = leftmost_frame + cnt;
|
|
|
|
}
|
|
|
|
|
2007-01-11 15:36:35 -05:00
|
|
|
reset_x_origin (frame);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::scroll_tracks_down ()
|
|
|
|
{
|
|
|
|
float prefix;
|
|
|
|
bool was_floating;
|
|
|
|
int cnt;
|
|
|
|
|
|
|
|
if (get_prefix (prefix, was_floating)) {
|
|
|
|
cnt = 1;
|
|
|
|
} else {
|
|
|
|
cnt = (int) floor (prefix);
|
|
|
|
}
|
|
|
|
|
2006-04-09 22:14:05 -04:00
|
|
|
double vert_value = vertical_adjustment.get_value() + (cnt *
|
|
|
|
vertical_adjustment.get_page_size());
|
|
|
|
if (vert_value > vertical_adjustment.get_upper() - canvas_height) {
|
|
|
|
vert_value = vertical_adjustment.get_upper() - canvas_height;
|
|
|
|
}
|
|
|
|
vertical_adjustment.set_value (vert_value);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::scroll_tracks_up ()
|
|
|
|
{
|
|
|
|
float prefix;
|
|
|
|
bool was_floating;
|
|
|
|
int cnt;
|
|
|
|
|
|
|
|
if (get_prefix (prefix, was_floating)) {
|
|
|
|
cnt = 1;
|
|
|
|
} else {
|
|
|
|
cnt = (int) floor (prefix);
|
|
|
|
}
|
|
|
|
|
2005-12-12 15:54:55 -05:00
|
|
|
vertical_adjustment.set_value (vertical_adjustment.get_value() - (cnt * vertical_adjustment.get_page_size()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::scroll_tracks_down_line ()
|
|
|
|
{
|
2006-04-09 22:14:05 -04:00
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
Gtk::Adjustment* adj = edit_vscrollbar.get_adjustment();
|
2006-04-09 22:14:05 -04:00
|
|
|
double vert_value = adj->get_value() + 20;
|
|
|
|
|
|
|
|
if (vert_value>adj->get_upper() - canvas_height) {
|
|
|
|
vert_value = adj->get_upper() - canvas_height;
|
|
|
|
}
|
|
|
|
adj->set_value (vert_value);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::scroll_tracks_up_line ()
|
|
|
|
{
|
2005-11-12 22:53:51 -05:00
|
|
|
Gtk::Adjustment* adj = edit_vscrollbar.get_adjustment();
|
2006-04-09 22:14:05 -04:00
|
|
|
adj->set_value (adj->get_value() - 20);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ZOOM */
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::temporal_zoom_step (bool coarser)
|
|
|
|
{
|
2006-04-06 12:51:27 -04:00
|
|
|
ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::temporal_zoom_step), coarser));
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
double nfpu;
|
|
|
|
|
|
|
|
nfpu = frames_per_unit;
|
|
|
|
|
|
|
|
if (coarser) {
|
2006-09-18 23:29:16 -04:00
|
|
|
nfpu *= 1.61803399;
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-09-18 23:29:16 -04:00
|
|
|
nfpu = max(1.0,(nfpu/1.61803399));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
temporal_zoom (nfpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::temporal_zoom (gdouble fpu)
|
|
|
|
{
|
|
|
|
if (!session) return;
|
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
nframes64_t current_page = current_page_frames();
|
|
|
|
nframes64_t current_leftmost = leftmost_frame;
|
|
|
|
nframes64_t current_rightmost;
|
|
|
|
nframes64_t current_center;
|
|
|
|
nframes64_t new_page;
|
|
|
|
nframes64_t leftmost_after_zoom = 0;
|
|
|
|
nframes64_t where;
|
|
|
|
bool in_track_canvas;
|
2005-09-25 14:42:24 -04:00
|
|
|
double nfpu;
|
|
|
|
|
|
|
|
nfpu = fpu;
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
new_page = (nframes_t) floor (canvas_width * nfpu);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (zoom_focus) {
|
|
|
|
case ZoomFocusLeft:
|
|
|
|
leftmost_after_zoom = current_leftmost;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ZoomFocusRight:
|
|
|
|
current_rightmost = leftmost_frame + current_page;
|
|
|
|
if (current_rightmost > new_page) {
|
|
|
|
leftmost_after_zoom = current_rightmost - new_page;
|
|
|
|
} else {
|
|
|
|
leftmost_after_zoom = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ZoomFocusCenter:
|
|
|
|
current_center = current_leftmost + (current_page/2);
|
|
|
|
if (current_center > (new_page/2)) {
|
|
|
|
leftmost_after_zoom = current_center - (new_page / 2);
|
|
|
|
} else {
|
|
|
|
leftmost_after_zoom = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ZoomFocusPlayhead:
|
|
|
|
/* try to keep the playhead in the center */
|
|
|
|
if (playhead_cursor->current_frame > new_page/2) {
|
|
|
|
leftmost_after_zoom = playhead_cursor->current_frame - (new_page/2);
|
|
|
|
} else {
|
|
|
|
leftmost_after_zoom = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
case ZoomFocusMouse:
|
|
|
|
/* try to keep the mouse over the same point in the display */
|
|
|
|
|
|
|
|
if (!mouse_frame (where, in_track_canvas)) {
|
|
|
|
/* use playhead instead */
|
|
|
|
where = playhead_cursor->current_frame;
|
|
|
|
|
|
|
|
if (where > new_page/2) {
|
|
|
|
leftmost_after_zoom = where - (new_page/2);
|
|
|
|
} else {
|
|
|
|
leftmost_after_zoom = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
double l = - ((new_page * ((where - current_leftmost)/(double)current_page)) - where);
|
|
|
|
|
|
|
|
if (l < 0) {
|
|
|
|
leftmost_after_zoom = 0;
|
|
|
|
} else if (l > max_frames) {
|
|
|
|
leftmost_after_zoom = max_frames - new_page;
|
|
|
|
} else {
|
|
|
|
leftmost_after_zoom = (nframes64_t) l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
case ZoomFocusEdit:
|
|
|
|
/* try to keep the edit cursor in the center */
|
2007-11-07 20:40:25 -05:00
|
|
|
if (get_preferred_edit_position() > new_page/2) {
|
|
|
|
leftmost_after_zoom = get_preferred_edit_position() - (new_page/2);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
leftmost_after_zoom = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// leftmost_after_zoom = min (leftmost_after_zoom, session->current_end_frame());
|
|
|
|
|
|
|
|
// begin_reversible_command (_("zoom"));
|
2005-09-25 17:19:23 -04:00
|
|
|
// session->add_undo (bind (mem_fun(*this, &Editor::reposition_and_zoom), current_leftmost, frames_per_unit));
|
|
|
|
// session->add_redo (bind (mem_fun(*this, &Editor::reposition_and_zoom), leftmost_after_zoom, nfpu));
|
2005-09-25 14:42:24 -04:00
|
|
|
// commit_reversible_command ();
|
2007-11-07 20:40:25 -05:00
|
|
|
|
|
|
|
// cerr << "repos & zoom to " << leftmost_after_zoom << " @ " << nfpu << endl;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
reposition_and_zoom (leftmost_after_zoom, nfpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::temporal_zoom_selection ()
|
|
|
|
{
|
|
|
|
if (!selection) return;
|
|
|
|
|
|
|
|
if (selection->time.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t start = selection->time[clicked_selection].start;
|
|
|
|
nframes_t end = selection->time[clicked_selection].end;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
temporal_zoom_by_frame (start, end, "zoom to selection");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::temporal_zoom_session ()
|
|
|
|
{
|
2006-04-06 12:51:27 -04:00
|
|
|
ENSURE_GUI_THREAD (mem_fun (*this, &Editor::temporal_zoom_session));
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (session) {
|
2006-03-31 11:16:16 -05:00
|
|
|
temporal_zoom_by_frame (session->current_start_frame(), session->current_end_frame(), "zoom to session");
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::temporal_zoom_by_frame (nframes_t start, nframes_t end, const string & op)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!session) return;
|
|
|
|
|
|
|
|
if ((start == 0 && end == 0) || end < start) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t range = end - start;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
double new_fpu = (double)range / (double)canvas_width;
|
|
|
|
// double p2 = 1.0;
|
|
|
|
|
|
|
|
// while (p2 < new_fpu) {
|
|
|
|
// p2 *= 2.0;
|
|
|
|
// }
|
|
|
|
// new_fpu = p2;
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t new_page = (nframes_t) floor (canvas_width * new_fpu);
|
|
|
|
nframes_t middle = (nframes_t) floor( (double)start + ((double)range / 2.0f ));
|
|
|
|
nframes_t new_leftmost = (nframes_t) floor( (double)middle - ((double)new_page/2.0f));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (new_leftmost > middle) new_leftmost = 0;
|
|
|
|
|
|
|
|
// begin_reversible_command (op);
|
2005-09-25 17:19:23 -04:00
|
|
|
// session->add_undo (bind (mem_fun(*this, &Editor::reposition_and_zoom), leftmost_frame, frames_per_unit));
|
|
|
|
// session->add_redo (bind (mem_fun(*this, &Editor::reposition_and_zoom), new_leftmost, new_fpu));
|
2005-09-25 14:42:24 -04:00
|
|
|
// commit_reversible_command ();
|
|
|
|
|
|
|
|
reposition_and_zoom (new_leftmost, new_fpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::temporal_zoom_to_frame (bool coarser, nframes_t frame)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!session) return;
|
|
|
|
|
2006-09-18 23:29:16 -04:00
|
|
|
double range_before = frame - leftmost_frame;
|
2005-09-25 14:42:24 -04:00
|
|
|
double new_fpu;
|
|
|
|
|
|
|
|
new_fpu = frames_per_unit;
|
|
|
|
|
|
|
|
if (coarser) {
|
2006-09-18 23:29:16 -04:00
|
|
|
new_fpu *= 1.61803399;
|
|
|
|
range_before *= 1.61803399;
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-09-18 23:29:16 -04:00
|
|
|
new_fpu = max(1.0,(new_fpu/1.61803399));
|
|
|
|
range_before /= 1.61803399;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (new_fpu == frames_per_unit) return;
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t new_leftmost = frame - (nframes_t)range_before;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (new_leftmost > frame) new_leftmost = 0;
|
|
|
|
|
|
|
|
// begin_reversible_command (_("zoom to frame"));
|
2005-09-25 17:19:23 -04:00
|
|
|
// session->add_undo (bind (mem_fun(*this, &Editor::reposition_and_zoom), leftmost_frame, frames_per_unit));
|
|
|
|
// session->add_redo (bind (mem_fun(*this, &Editor::reposition_and_zoom), new_leftmost, new_fpu));
|
2005-09-25 14:42:24 -04:00
|
|
|
// commit_reversible_command ();
|
|
|
|
|
|
|
|
reposition_and_zoom (new_leftmost, new_fpu);
|
|
|
|
}
|
|
|
|
|
2006-03-31 18:00:40 -05:00
|
|
|
void
|
|
|
|
Editor::add_location_from_selection ()
|
|
|
|
{
|
2007-01-09 18:24:54 -05:00
|
|
|
string rangename;
|
|
|
|
|
2006-03-31 18:00:40 -05:00
|
|
|
if (selection->time.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-08-16 16:36:14 -04:00
|
|
|
if (session == 0 || clicked_axisview == 0) {
|
2006-03-31 18:00:40 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t start = selection->time[clicked_selection].start;
|
|
|
|
nframes_t end = selection->time[clicked_selection].end;
|
2006-03-31 18:00:40 -05:00
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
session->locations()->next_available_name(rangename,"selection");
|
|
|
|
Location *location = new Location (start, end, rangename, Location::IsRangeMarker);
|
2006-03-31 18:00:40 -05:00
|
|
|
|
|
|
|
session->begin_reversible_command (_("add marker"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = session->locations()->get_state();
|
2006-03-31 18:00:40 -05:00
|
|
|
session->locations()->add (location, 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));
|
2006-03-31 18:00:40 -05:00
|
|
|
session->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::add_location_from_playhead_cursor ()
|
|
|
|
{
|
2007-01-09 18:24:54 -05:00
|
|
|
string markername;
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t where = session->audible_frame();
|
2006-03-31 18:00:40 -05:00
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
session->locations()->next_available_name(markername,"mark");
|
|
|
|
Location *location = new Location (where, where, markername, Location::IsMark);
|
2006-03-31 18:00:40 -05:00
|
|
|
session->begin_reversible_command (_("add marker"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = session->locations()->get_state();
|
2006-03-31 18:00:40 -05:00
|
|
|
session->locations()->add (location, 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));
|
2006-03-31 18:00:40 -05:00
|
|
|
session->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::add_location_from_audio_region ()
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty()) {
|
2006-03-31 18:00:40 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView* rv = *(selection->regions.begin());
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> region = rv->region();
|
2006-03-31 18:00:40 -05:00
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
Location *location = new Location (region->position(), region->last_frame(), region->name(), Location::IsRangeMarker);
|
2006-03-31 18:00:40 -05:00
|
|
|
session->begin_reversible_command (_("add marker"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = session->locations()->get_state();
|
2006-03-31 18:00:40 -05:00
|
|
|
session->locations()->add (location, 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));
|
2006-03-31 18:00:40 -05:00
|
|
|
session->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::amplitude_zoom_step (bool in)
|
|
|
|
{
|
|
|
|
gdouble zoom = 1.0;
|
|
|
|
|
|
|
|
if (in) {
|
|
|
|
zoom *= 2.0;
|
|
|
|
} else {
|
|
|
|
if (zoom > 2.0) {
|
|
|
|
zoom /= 2.0;
|
|
|
|
} else {
|
|
|
|
zoom = 1.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef FIX_FOR_CANVAS
|
|
|
|
/* XXX DO SOMETHING */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* DELETION */
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::delete_sample_forward ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::delete_sample_backward ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::delete_screen ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SEARCH */
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::search_backwards ()
|
|
|
|
{
|
|
|
|
/* what ? */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::search_forwards ()
|
|
|
|
{
|
|
|
|
/* what ? */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MARKS */
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::jump_forward_to_mark ()
|
|
|
|
{
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Location *location = session->locations()->first_location_after (playhead_cursor->current_frame);
|
|
|
|
|
|
|
|
if (location) {
|
|
|
|
session->request_locate (location->start(), session->transport_rolling());
|
|
|
|
} else {
|
|
|
|
session->request_locate (session->current_end_frame());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::jump_backward_to_mark ()
|
|
|
|
{
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Location *location = session->locations()->first_location_before (playhead_cursor->current_frame);
|
|
|
|
|
|
|
|
if (location) {
|
|
|
|
session->request_locate (location->start(), session->transport_rolling());
|
|
|
|
} else {
|
2006-03-11 11:01:06 -05:00
|
|
|
session->goto_start ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_mark ()
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t pos;
|
2005-09-25 14:42:24 -04:00
|
|
|
float prefix;
|
|
|
|
bool was_floating;
|
2007-01-09 18:24:54 -05:00
|
|
|
string markername;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (get_prefix (prefix, was_floating)) {
|
|
|
|
pos = session->audible_frame ();
|
|
|
|
} else {
|
|
|
|
if (was_floating) {
|
2006-10-21 15:01:50 -04:00
|
|
|
pos = (nframes_t) floor (prefix * session->frame_rate ());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-10-21 15:01:50 -04:00
|
|
|
pos = (nframes_t) floor (prefix);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
session->locations()->next_available_name(markername,"mark");
|
|
|
|
session->locations()->add (new Location (pos, 0, markername, Location::IsMark), true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::clear_markers ()
|
|
|
|
{
|
|
|
|
if (session) {
|
|
|
|
session->begin_reversible_command (_("clear markers"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = session->locations()->get_state();
|
2005-09-25 14:42:24 -04:00
|
|
|
session->locations()->clear_markers ();
|
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
|
|
|
session->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::clear_ranges ()
|
|
|
|
{
|
|
|
|
if (session) {
|
|
|
|
session->begin_reversible_command (_("clear ranges"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = session->locations()->get_state();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
Location * looploc = session->locations()->auto_loop_location();
|
|
|
|
Location * punchloc = session->locations()->auto_punch_location();
|
|
|
|
|
|
|
|
session->locations()->clear_ranges ();
|
|
|
|
// re-add these
|
|
|
|
if (looploc) session->locations()->add (looploc);
|
|
|
|
if (punchloc) session->locations()->add (punchloc);
|
|
|
|
|
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
|
|
|
session->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::clear_locations ()
|
|
|
|
{
|
|
|
|
session->begin_reversible_command (_("clear locations"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = session->locations()->get_state();
|
2005-09-25 14:42:24 -04:00
|
|
|
session->locations()->clear ();
|
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
|
|
|
session->commit_reversible_command ();
|
|
|
|
session->locations()->clear ();
|
|
|
|
}
|
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
void
|
|
|
|
Editor::unhide_markers ()
|
|
|
|
{
|
|
|
|
for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
|
|
|
|
Location *l = (*i).first;
|
|
|
|
if (l->is_hidden() && l->is_mark()) {
|
|
|
|
l->set_hidden(false, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::unhide_ranges ()
|
|
|
|
{
|
|
|
|
for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) {
|
|
|
|
Location *l = (*i).first;
|
|
|
|
if (l->is_hidden() && l->is_range_marker()) {
|
|
|
|
l->set_hidden(false, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* INSERT/REPLACE */
|
|
|
|
|
|
|
|
void
|
2006-08-29 17:21:48 -04:00
|
|
|
Editor::insert_region_list_drag (boost::shared_ptr<Region> region, int x, int y)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
double wx, wy;
|
|
|
|
double cx, cy;
|
|
|
|
TimeAxisView *tv;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t where;
|
2007-04-12 19:20:37 -04:00
|
|
|
RouteTimeAxisView *rtv = 0;
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-12 17:07:07 -05:00
|
|
|
track_canvas.window_to_world (x, y, wx, wy);
|
2006-01-02 15:27:51 -05:00
|
|
|
wx += horizontal_adjustment.get_value();
|
|
|
|
wy += vertical_adjustment.get_value();
|
2005-11-12 22:53:51 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
GdkEvent event;
|
|
|
|
event.type = GDK_BUTTON_RELEASE;
|
|
|
|
event.button.x = wx;
|
|
|
|
event.button.y = wy;
|
|
|
|
|
|
|
|
where = event_frame (&event, &cx, &cy);
|
|
|
|
|
|
|
|
if (where < leftmost_frame || where > leftmost_frame + current_page_frames()) {
|
|
|
|
/* clearly outside canvas area */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((tv = trackview_by_y_position (cy)) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if ((rtv = dynamic_cast<RouteTimeAxisView*>(tv)) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if ((playlist = rtv->playlist()) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
snap_to (where);
|
|
|
|
|
|
|
|
begin_reversible_command (_("insert dragged region"));
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = playlist->get_state();
|
2006-08-29 17:21:48 -04:00
|
|
|
playlist->add_region (RegionFactory::create (region), where, 1.0);
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::insert_region_list_selection (float times)
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
RouteTimeAxisView *tv = 0;
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((tv = dynamic_cast<RouteTimeAxisView*>(selection->tracks.front())) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((playlist = tv->playlist()) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
Glib::RefPtr<TreeSelection> selected = region_list_display.get_selection();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-24 09:59:36 -05:00
|
|
|
if (selected->count_selected_rows() != 1) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
TreeView::Selection::ListHandle_Path rows = selected->get_selected_rows ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
/* only one row selected, so rows.begin() is it */
|
|
|
|
|
|
|
|
TreeIter iter;
|
|
|
|
|
|
|
|
if ((iter = region_list_model->get_iter (*rows.begin()))) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
boost::shared_ptr<Region> region = (*iter)[region_list_columns.region];
|
|
|
|
|
|
|
|
begin_reversible_command (_("insert region"));
|
|
|
|
XMLNode &before = playlist->get_state();
|
2007-11-07 20:40:25 -05:00
|
|
|
playlist->add_region ((RegionFactory::create (region)), get_preferred_edit_position(), times);
|
2006-10-21 15:01:50 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* BUILT-IN EFFECTS */
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::reverse_selection ()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GAIN ENVELOPE EDITING */
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::edit_envelope ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PLAYBACK */
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
void
|
|
|
|
Editor::transition_to_rolling (bool fwd)
|
|
|
|
{
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (Config->get_slave_source()) {
|
|
|
|
case None:
|
|
|
|
case JACK:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* transport controlled by the master */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (session->is_auditioning()) {
|
|
|
|
session->cancel_audition ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session->request_transport_speed (fwd ? 1.0f : -1.0f);
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::toggle_playback (bool with_abort)
|
|
|
|
{
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
switch (Config->get_slave_source()) {
|
|
|
|
case None:
|
|
|
|
case JACK:
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* transport controlled by the master */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (session->is_auditioning()) {
|
|
|
|
session->cancel_audition ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (session->transport_rolling()) {
|
|
|
|
session->request_stop (with_abort);
|
2006-11-19 11:45:16 -05:00
|
|
|
if (session->get_play_loop()) {
|
2006-10-21 15:01:50 -04:00
|
|
|
session->request_play_loop (false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
session->request_transport_speed (1.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::play_from_start ()
|
|
|
|
{
|
2006-03-11 11:01:06 -05:00
|
|
|
session->request_locate (session->current_start_frame(), true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
void
|
|
|
|
Editor::play_from_edit_cursor ()
|
|
|
|
{
|
2007-11-07 20:40:25 -05:00
|
|
|
session->request_locate (get_preferred_edit_position(), true);
|
2006-11-19 11:45:16 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::play_selection ()
|
|
|
|
{
|
|
|
|
if (selection->time.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session->request_play_range (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::play_selected_region ()
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
|
|
|
RegionView *rv = *(selection->regions.begin());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
session->request_bounded_roll (rv->region()->position(), rv->region()->last_frame());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::loop_selected_region ()
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
|
|
|
RegionView *rv = *(selection->regions.begin());
|
2005-09-25 14:42:24 -04:00
|
|
|
Location* tll;
|
|
|
|
|
|
|
|
if ((tll = transport_loop_location()) != 0) {
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
tll->set (rv->region()->position(), rv->region()->last_frame());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
// enable looping, reposition and start rolling
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
session->request_play_loop (true);
|
2005-09-25 14:42:24 -04:00
|
|
|
session->request_locate (tll->start(), false);
|
|
|
|
session->request_transport_speed (1.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::play_location (Location& location)
|
|
|
|
{
|
|
|
|
if (location.start() <= location.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session->request_bounded_roll (location.start(), location.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::loop_location (Location& location)
|
|
|
|
{
|
|
|
|
if (location.start() <= location.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Location* tll;
|
|
|
|
|
|
|
|
if ((tll = transport_loop_location()) != 0) {
|
|
|
|
tll->set (location.start(), location.end());
|
|
|
|
|
|
|
|
// enable looping, reposition and start rolling
|
2006-10-21 15:01:50 -04:00
|
|
|
session->request_play_loop (true);
|
2005-09-25 14:42:24 -04:00
|
|
|
session->request_locate (tll->start(), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::raise_region_to_top ()
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
selection->foreach_region (&Region::raise_to_top);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::lower_region_to_bottom ()
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
selection->foreach_region (&Region::lower_to_bottom);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Show the region editor for the selected regions */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::edit_region ()
|
|
|
|
{
|
2007-05-10 07:53:35 -04:00
|
|
|
selection->foreach_regionview (&RegionView::show_region_editor);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::rename_region ()
|
|
|
|
{
|
|
|
|
Dialog dialog;
|
|
|
|
Entry entry;
|
|
|
|
Button ok_button (_("OK"));
|
|
|
|
Button cancel_button (_("Cancel"));
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-19 03:07:38 -04:00
|
|
|
WindowTitle title(Glib::get_application_name());
|
|
|
|
title += _("Rename Region");
|
|
|
|
|
|
|
|
dialog.set_title (title.get_string());
|
2005-09-25 14:42:24 -04:00
|
|
|
dialog.set_name ("RegionRenameWindow");
|
2005-09-25 16:33:00 -04:00
|
|
|
dialog.set_size_request (300, -1);
|
|
|
|
dialog.set_position (Gtk::WIN_POS_MOUSE);
|
2005-09-25 14:42:24 -04:00
|
|
|
dialog.set_modal (true);
|
|
|
|
|
|
|
|
dialog.get_vbox()->set_border_width (10);
|
|
|
|
dialog.get_vbox()->pack_start (entry);
|
|
|
|
dialog.get_action_area()->pack_start (ok_button);
|
|
|
|
dialog.get_action_area()->pack_start (cancel_button);
|
|
|
|
|
|
|
|
entry.set_name ("RegionNameDisplay");
|
|
|
|
ok_button.set_name ("EditorGTKButton");
|
|
|
|
cancel_button.set_name ("EditorGTKButton");
|
|
|
|
|
|
|
|
region_renamed = false;
|
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
entry.signal_activate().connect (bind (mem_fun(*this, &Editor::rename_region_finished), true));
|
2005-09-25 17:19:23 -04:00
|
|
|
ok_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::rename_region_finished), true));
|
|
|
|
cancel_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::rename_region_finished), false));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* recurse */
|
|
|
|
|
|
|
|
dialog.show_all ();
|
|
|
|
Main::run ();
|
|
|
|
|
|
|
|
if (region_renamed) {
|
2006-08-29 17:21:48 -04:00
|
|
|
(*selection->regions.begin())->region()->set_name (entry.get_text());
|
2005-09-25 14:42:24 -04:00
|
|
|
redisplay_regions ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::rename_region_finished (bool status)
|
|
|
|
|
|
|
|
{
|
|
|
|
region_renamed = status;
|
|
|
|
Main::quit ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-29 17:21:48 -04:00
|
|
|
Editor::audition_playlist_region_via_route (boost::shared_ptr<Region> region, Route& route)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (session->is_auditioning()) {
|
|
|
|
session->cancel_audition ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// note: some potential for creativity here, because region doesn't
|
|
|
|
// have to belong to the playlist that Route is handling
|
|
|
|
|
|
|
|
// bool was_soloed = route.soloed();
|
|
|
|
|
|
|
|
route.set_solo (true, this);
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
session->request_bounded_roll (region->position(), region->position() + region->length());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* XXX how to unset the solo state ? */
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Start an audition of the first selected region */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::audition_selected_region ()
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
|
|
|
RegionView* rv = *(selection->regions.begin());
|
2006-08-01 13:19:38 -04:00
|
|
|
session->audition_region (rv->region());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-29 17:21:48 -04:00
|
|
|
Editor::audition_playlist_region_standalone (boost::shared_ptr<Region> region)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-01 13:19:38 -04:00
|
|
|
session->audition_region (region);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::build_interthread_progress_window ()
|
|
|
|
{
|
2005-11-27 16:17:41 -05:00
|
|
|
interthread_progress_window = new ArdourDialog (X_("interthread progress"), true);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
interthread_progress_bar.set_orientation (Gtk::PROGRESS_LEFT_TO_RIGHT);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-27 16:17:41 -05:00
|
|
|
interthread_progress_window->get_vbox()->pack_start (interthread_progress_label, false, false);
|
|
|
|
interthread_progress_window->get_vbox()->pack_start (interthread_progress_bar,false, false);
|
|
|
|
|
|
|
|
// GTK2FIX: this button needs a modifiable label
|
|
|
|
|
|
|
|
Button* b = interthread_progress_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
|
|
|
b->signal_clicked().connect (mem_fun(*this, &Editor::interthread_cancel_clicked));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
interthread_cancel_button.add (interthread_cancel_label);
|
|
|
|
|
|
|
|
interthread_progress_window->set_default_size (200, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::interthread_cancel_clicked ()
|
|
|
|
{
|
|
|
|
if (current_interthread_info) {
|
|
|
|
current_interthread_info->cancel = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::region_from_selection ()
|
|
|
|
{
|
2006-08-16 16:36:14 -04:00
|
|
|
if (clicked_axisview == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selection->time.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t start = selection->time[clicked_selection].start;
|
|
|
|
nframes_t end = selection->time[clicked_selection].end;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t selection_cnt = end - start + 1;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<AudioRegion> current;
|
|
|
|
boost::shared_ptr<Region> current_r;
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> pl;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t internal_start;
|
2005-09-25 14:42:24 -04:00
|
|
|
string new_name;
|
|
|
|
|
|
|
|
if ((pl = (*i)->playlist()) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((current_r = pl->top_region_at (start)) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
current = boost::dynamic_pointer_cast<AudioRegion> (current_r);
|
2006-08-01 13:19:38 -04:00
|
|
|
assert(current); // FIXME
|
|
|
|
if (current != 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
internal_start = start - current->position();
|
|
|
|
session->region_name (new_name, current->name(), true);
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> region (RegionFactory::create (current, internal_start, selection_cnt, new_name));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-29 17:21:48 -04:00
|
|
|
Editor::create_region_from_selection (vector<boost::shared_ptr<AudioRegion> >& new_regions)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (selection->time.empty() || selection->tracks.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t start = selection->time[clicked_selection].start;
|
|
|
|
nframes_t end = selection->time[clicked_selection].end;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
sort_track_selection ();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<AudioRegion> current;
|
|
|
|
boost::shared_ptr<Region> current_r;
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t internal_start;
|
2005-09-25 14:42:24 -04:00
|
|
|
string new_name;
|
|
|
|
|
|
|
|
if ((playlist = (*i)->playlist()) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((current_r = playlist->top_region_at(start)) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if ((current = boost::dynamic_pointer_cast<AudioRegion>(current_r)) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal_start = start - current->position();
|
|
|
|
session->region_name (new_name, current->name(), true);
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
new_regions.push_back (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (current, internal_start, end - start + 1, new_name)));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::split_multichannel_region ()
|
|
|
|
{
|
2007-01-28 12:44:13 -05:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
vector<boost::shared_ptr<AudioRegion> > v;
|
|
|
|
|
|
|
|
for (list<RegionView*>::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(*x);
|
|
|
|
|
|
|
|
if (!arv || arv->audio_region()->n_channels() < 2) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
(arv)->audio_region()->separate_by_channel (*session, v);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::new_region_from_selection ()
|
|
|
|
{
|
|
|
|
region_from_selection ();
|
|
|
|
cancel_selection ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::separate_region_from_selection ()
|
|
|
|
{
|
2006-08-14 04:44:14 -04:00
|
|
|
// FIXME: TYPE
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
bool doing_undo = false;
|
|
|
|
|
|
|
|
if (selection->time.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
sort_track_selection ();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
RouteTimeAxisView* rtv;
|
|
|
|
|
|
|
|
if ((rtv = dynamic_cast<RouteTimeAxisView*> ((*i))) != 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-06-15 18:05:07 -04:00
|
|
|
boost::shared_ptr<Track> t = rtv->track();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (t != 0 && ! t->diskstream()->destructive()) {
|
|
|
|
|
|
|
|
if ((playlist = rtv->playlist()) != 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
if (!doing_undo) {
|
|
|
|
begin_reversible_command (_("separate"));
|
|
|
|
doing_undo = true;
|
|
|
|
}
|
2007-04-12 19:20:37 -04:00
|
|
|
|
|
|
|
XMLNode *before;
|
|
|
|
if (doing_undo)
|
|
|
|
before = &(playlist->get_state());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* XXX need to consider musical time selections here at some point */
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
double speed = t->diskstream()->speed();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (list<AudioRange>::iterator t = selection->time.begin(); t != selection->time.end(); ++t) {
|
2006-10-21 15:01:50 -04:00
|
|
|
playlist->partition ((nframes_t)((*t).start * speed), (nframes_t)((*t).end * speed), true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (doing_undo)
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*playlist, before, &playlist->get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-31 19:21:25 -05:00
|
|
|
if (doing_undo) commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::separate_regions_using_location (Location& loc)
|
|
|
|
{
|
2006-08-14 04:44:14 -04:00
|
|
|
// FIXME: TYPE
|
|
|
|
|
2006-03-31 19:21:25 -05:00
|
|
|
bool doing_undo = false;
|
|
|
|
|
|
|
|
if (loc.is_mark()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2006-03-31 19:21:25 -05:00
|
|
|
|
|
|
|
/* XXX i'm unsure as to whether this should operate on selected tracks only
|
|
|
|
or the entire enchillada. uncomment the below line to correct the behaviour
|
|
|
|
(currently set for all tracks)
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
//for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
RouteTimeAxisView* rtv;
|
|
|
|
|
|
|
|
if ((rtv = dynamic_cast<RouteTimeAxisView*> ((*i))) != 0) {
|
2006-03-31 19:21:25 -05:00
|
|
|
|
2007-06-15 18:05:07 -04:00
|
|
|
boost::shared_ptr<Track> t = rtv->track();
|
2006-03-31 19:21:25 -05:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (t != 0 && ! t->diskstream()->destructive()) {
|
|
|
|
|
|
|
|
if ((playlist = rtv->playlist()) != 0) {
|
2006-03-31 19:21:25 -05:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
XMLNode *before;
|
2006-03-31 19:21:25 -05:00
|
|
|
if (!doing_undo) {
|
|
|
|
begin_reversible_command (_("separate"));
|
|
|
|
doing_undo = true;
|
|
|
|
}
|
2007-04-12 19:20:37 -04:00
|
|
|
if (doing_undo)
|
|
|
|
before = &(playlist->get_state());
|
2006-08-09 21:22:45 -04:00
|
|
|
|
2006-03-31 19:21:25 -05:00
|
|
|
|
|
|
|
/* XXX need to consider musical time selections here at some point */
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
double speed = rtv->get_diskstream()->speed();
|
2006-03-31 19:21:25 -05:00
|
|
|
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
playlist->partition ((nframes_t)(loc.start() * speed), (nframes_t)(loc.end() * speed), true);
|
2006-08-09 21:22:45 -04:00
|
|
|
if (doing_undo)
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*playlist, before, &playlist->get_state()));
|
2006-03-31 19:21:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (doing_undo) commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::crop_region_to_selection ()
|
|
|
|
{
|
2007-04-12 19:20:37 -04:00
|
|
|
if (selection->time.empty() || selection->tracks.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
vector<boost::shared_ptr<Playlist> > playlists;
|
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
sort_track_selection ();
|
|
|
|
|
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
RouteTimeAxisView* rtv;
|
|
|
|
|
|
|
|
if ((rtv = dynamic_cast<RouteTimeAxisView*> ((*i))) != 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-06-15 18:05:07 -04:00
|
|
|
boost::shared_ptr<Track> t = rtv->track();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (t != 0 && ! t->diskstream()->destructive()) {
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
if ((playlist = rtv->playlist()) != 0) {
|
|
|
|
playlists.push_back (playlist);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if (playlists.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nframes_t start;
|
|
|
|
nframes_t end;
|
|
|
|
nframes_t cnt;
|
|
|
|
|
|
|
|
begin_reversible_command (_("trim to selection"));
|
|
|
|
|
|
|
|
for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
|
|
|
|
|
|
|
|
boost::shared_ptr<Region> region;
|
|
|
|
|
|
|
|
start = selection->time.start();
|
|
|
|
|
|
|
|
if ((region = (*i)->top_region_at(start)) == 0) {
|
|
|
|
continue;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-04-12 19:20:37 -04:00
|
|
|
|
|
|
|
/* now adjust lengths to that we do the right thing
|
|
|
|
if the selection extends beyond the region
|
|
|
|
*/
|
|
|
|
|
|
|
|
start = max (start, region->position());
|
|
|
|
if (max_frames - start < region->length()) {
|
|
|
|
end = start + region->length() - 1;
|
|
|
|
} else {
|
|
|
|
end = max_frames;
|
|
|
|
}
|
|
|
|
end = min (selection->time.end_frame(), end);
|
|
|
|
cnt = end - start + 1;
|
|
|
|
|
|
|
|
XMLNode &before = (*i)->get_state();
|
|
|
|
region->trim_to (start, cnt, this);
|
|
|
|
XMLNode &after = (*i)->get_state();
|
|
|
|
session->add_command (new MementoCommand<Playlist>(*(*i), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-04-12 19:20:37 -04:00
|
|
|
|
|
|
|
commit_reversible_command ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::region_fill_track ()
|
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t end;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!session || selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
end = session->current_end_frame ();
|
|
|
|
|
|
|
|
begin_reversible_command (_("region fill"));
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> region ((*i)->region());
|
2006-07-23 08:03:19 -04:00
|
|
|
|
|
|
|
// FIXME
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(region);
|
2006-08-14 04:44:14 -04:00
|
|
|
assert(ar);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> pl = region->playlist();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (end <= region->last_frame()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
double times = (double) (end - region->last_frame()) / (double) region->length();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (times == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-08-14 04:44:14 -04:00
|
|
|
XMLNode &before = pl->get_state();
|
2006-08-29 17:21:48 -04:00
|
|
|
pl->add_region (RegionFactory::create (ar), ar->last_frame(), times);
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command (new MementoCommand<Playlist>(*pl, &before, &pl->get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::region_fill_selection ()
|
|
|
|
{
|
2006-08-16 16:36:14 -04:00
|
|
|
if (clicked_routeview == 0 || !clicked_routeview->is_audio_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selection->time.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
Glib::RefPtr<TreeSelection> selected = region_list_display.get_selection();
|
2005-11-12 17:07:07 -05:00
|
|
|
|
2005-11-24 09:59:36 -05:00
|
|
|
if (selected->count_selected_rows() != 1) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-11-12 17:07:07 -05:00
|
|
|
TreeModel::iterator i = region_list_display.get_selection()->get_selected();
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> region = (*i)[region_list_columns.region];
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t start = selection->time[clicked_selection].start;
|
|
|
|
nframes_t end = selection->time[clicked_selection].end;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t selection_length = end - start;
|
2005-09-25 14:42:24 -04:00
|
|
|
float times = (float)selection_length / region->length();
|
|
|
|
|
|
|
|
begin_reversible_command (_("fill selection"));
|
|
|
|
|
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
|
|
|
|
if ((playlist = (*i)->playlist()) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = playlist->get_state();
|
2006-08-29 17:21:48 -04:00
|
|
|
playlist->add_region (RegionFactory::create (region), start, times);
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command (new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
2006-01-23 15:39:58 -05:00
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::set_a_regions_sync_position (boost::shared_ptr<Region> region, nframes_t position)
|
2006-01-23 15:39:58 -05:00
|
|
|
{
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if (!region->covers (position)) {
|
2006-01-23 15:39:58 -05:00
|
|
|
error << _("Programming error. that region doesn't cover that position") << __FILE__ << " +" << __LINE__ << endmsg;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
begin_reversible_command (_("set region sync position"));
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &before = region->playlist()->get_state();
|
|
|
|
region->set_sync_position (position);
|
|
|
|
XMLNode &after = region->playlist()->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
|
2006-01-23 15:39:58 -05:00
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Set the sync position of the selection using the position of the edit cursor */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::set_region_sync_from_edit_cursor ()
|
|
|
|
{
|
2007-05-10 07:53:35 -04:00
|
|
|
/* Check that at the edit cursor is in at least one of the selected regions */
|
|
|
|
RegionSelection::const_iterator i = selection->regions.begin();
|
2007-11-07 20:40:25 -05:00
|
|
|
|
|
|
|
while (i != selection->regions.end() && !(*i)->region()->covers (get_preferred_edit_position())) {
|
2007-05-10 07:53:35 -04:00
|
|
|
++i;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/* Give the user a hint if not */
|
|
|
|
if (i == selection->regions.end()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
error << _("Place the edit cursor at the desired sync point") << endmsg;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("set sync from edit cursor"));
|
2007-05-10 07:53:35 -04:00
|
|
|
|
|
|
|
for (RegionSelection::iterator j = selection->regions.begin(); j != selection->regions.end(); ++j) {
|
|
|
|
boost::shared_ptr<Region> r = (*j)->region();
|
|
|
|
XMLNode &before = r->playlist()->get_state();
|
2007-11-07 20:40:25 -05:00
|
|
|
r->set_sync_position (get_preferred_edit_position());
|
2007-05-10 07:53:35 -04:00
|
|
|
XMLNode &after = r->playlist()->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*(r->playlist()), &before, &after));
|
|
|
|
}
|
2007-11-07 20:40:25 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Remove the sync positions of the selection */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::remove_region_sync ()
|
|
|
|
{
|
2007-05-10 07:53:35 -04:00
|
|
|
begin_reversible_command (_("remove sync"));
|
|
|
|
|
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
|
|
|
boost::shared_ptr<Region> r = (*i)->region();
|
|
|
|
XMLNode &before = r->playlist()->get_state();
|
|
|
|
r->clear_sync_position ();
|
|
|
|
XMLNode &after = r->playlist()->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*(r->playlist()), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-05-10 07:53:35 -04:00
|
|
|
|
|
|
|
commit_reversible_command ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::naturalize ()
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
begin_reversible_command (_("naturalize"));
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &before = (*i)->region()->get_state();
|
|
|
|
(*i)->region()->move_to_natural_position (this);
|
|
|
|
XMLNode &after = (*i)->region()->get_state();
|
|
|
|
session->add_command (new MementoCommand<Region>(*((*i)->region().get()), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::align (RegionPoint what)
|
|
|
|
{
|
2007-11-07 20:40:25 -05:00
|
|
|
align_selection (what, get_preferred_edit_position());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::align_relative (RegionPoint what)
|
|
|
|
{
|
2007-11-07 20:40:25 -05:00
|
|
|
align_selection_relative (what, get_preferred_edit_position());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct RegionSortByTime {
|
2006-08-14 04:44:14 -04:00
|
|
|
bool operator() (const RegionView* a, const RegionView* b) {
|
2006-08-29 17:21:48 -04:00
|
|
|
return a->region()->position() < b->region()->position();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::align_selection_relative (RegionPoint point, nframes_t position)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t distance;
|
|
|
|
nframes_t pos = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
int dir;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
list<RegionView*> sorted;
|
|
|
|
selection->regions.by_position (sorted);
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> r ((*sorted.begin())->region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (point) {
|
|
|
|
case Start:
|
2006-08-29 17:21:48 -04:00
|
|
|
pos = r->first_frame ();
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case End:
|
2006-08-29 17:21:48 -04:00
|
|
|
pos = r->last_frame();
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SyncPoint:
|
2006-08-29 17:21:48 -04:00
|
|
|
pos = r->adjust_to_sync (r->first_frame());
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pos > position) {
|
|
|
|
distance = pos - position;
|
|
|
|
dir = -1;
|
|
|
|
} else {
|
|
|
|
distance = position - pos;
|
|
|
|
dir = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("align selection (relative)"));
|
|
|
|
|
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
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> region ((*i)->region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &before = region->playlist()->get_state();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (dir > 0) {
|
2006-08-29 17:21:48 -04:00
|
|
|
region->set_position (region->position() + distance, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-08-29 17:21:48 -04:00
|
|
|
region->set_position (region->position() - distance, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &after = region->playlist()->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::align_selection (RegionPoint point, nframes_t position)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("align selection"));
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
|
|
|
align_region_internal ((*i)->region(), point, position);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::align_region (boost::shared_ptr<Region> region, RegionPoint point, nframes_t position)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
begin_reversible_command (_("align region"));
|
|
|
|
align_region_internal (region, point, position);
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::align_region_internal (boost::shared_ptr<Region> region, RegionPoint point, nframes_t position)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &before = region->playlist()->get_state();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (point) {
|
|
|
|
case SyncPoint:
|
2006-08-29 17:21:48 -04:00
|
|
|
region->set_position (region->adjust_to_sync (position), this);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case End:
|
2006-08-29 17:21:48 -04:00
|
|
|
if (position > region->length()) {
|
|
|
|
region->set_position (position - region->length(), this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Start:
|
2006-08-29 17:21:48 -04:00
|
|
|
region->set_position (position, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &after = region->playlist()->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Trim the end of the selected regions to the position of the edit cursor */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::trim_region_to_edit_cursor ()
|
|
|
|
{
|
2007-05-10 07:53:35 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
begin_reversible_command (_("trim to edit"));
|
|
|
|
|
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
|
|
|
boost::shared_ptr<Region> region ((*i)->region());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
float speed = 1.0f;
|
|
|
|
RouteTimeAxisView *rtav;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/* XXX I don't think clicked_axisview should be used here! */
|
|
|
|
if ( clicked_axisview != 0 && (rtav = dynamic_cast<RouteTimeAxisView*>(clicked_axisview)) != 0 ) {
|
|
|
|
if (rtav->get_diskstream() != 0) {
|
|
|
|
speed = rtav->get_diskstream()->speed();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-05-10 07:53:35 -04:00
|
|
|
|
|
|
|
XMLNode &before = region->playlist()->get_state();
|
2007-11-07 20:40:25 -05:00
|
|
|
region->trim_end( session_frame_to_track_frame(get_preferred_edit_position(), speed), this);
|
2007-05-10 07:53:35 -04:00
|
|
|
XMLNode &after = region->playlist()->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-05-10 07:53:35 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Trim the start of the selected regions to the position of the edit cursor */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::trim_region_from_edit_cursor ()
|
|
|
|
{
|
2007-05-10 07:53:35 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
begin_reversible_command (_("trim to edit"));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
|
|
|
boost::shared_ptr<Region> region ((*i)->region());
|
|
|
|
|
|
|
|
float speed = 1.0f;
|
|
|
|
RouteTimeAxisView *rtav;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/* XXX: not sure about clicked_axisview here */
|
|
|
|
if ( clicked_axisview != 0 && (rtav = dynamic_cast<RouteTimeAxisView*>(clicked_axisview)) != 0 ) {
|
|
|
|
if (rtav->get_diskstream() != 0) {
|
|
|
|
speed = rtav->get_diskstream()->speed();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
XMLNode &before = region->playlist()->get_state();
|
2007-11-07 20:40:25 -05:00
|
|
|
region->trim_front ( session_frame_to_track_frame(get_preferred_edit_position(), speed), this);
|
2007-05-10 07:53:35 -04:00
|
|
|
XMLNode &after = region->playlist()->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*(region->playlist()), &before, &after));
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Unfreeze selected routes */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2007-05-10 07:53:35 -04:00
|
|
|
Editor::unfreeze_routes ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-05-10 07:53:35 -04:00
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*i);
|
|
|
|
if (atv && atv->is_audio_track()) {
|
|
|
|
atv->audio_track()->unfreeze ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
|
|
|
Editor::_freeze_thread (void* arg)
|
|
|
|
{
|
|
|
|
PBD::ThreadCreated (pthread_self(), X_("Freeze"));
|
|
|
|
return static_cast<Editor*>(arg)->freeze_thread ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
|
|
|
Editor::freeze_thread ()
|
|
|
|
{
|
2007-05-10 07:53:35 -04:00
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*i);
|
|
|
|
if (atv && atv->is_audio_track()) {
|
|
|
|
atv->audio_track()->freeze (*current_interthread_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
current_interthread_info->done = true;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
Editor::freeze_progress_timeout (void *arg)
|
|
|
|
{
|
2005-10-09 01:03:29 -04:00
|
|
|
interthread_progress_bar.set_fraction (current_interthread_info->progress/100);
|
2005-09-25 14:42:24 -04:00
|
|
|
return !(current_interthread_info->done || current_interthread_info->cancel);
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Freeze selected routes */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2007-05-10 07:53:35 -04:00
|
|
|
Editor::freeze_routes ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
InterThreadInfo itt;
|
|
|
|
|
|
|
|
if (interthread_progress_window == 0) {
|
|
|
|
build_interthread_progress_window ();
|
|
|
|
}
|
2007-03-19 03:07:38 -04:00
|
|
|
|
|
|
|
WindowTitle title(Glib::get_application_name());
|
|
|
|
title += _("Freeze");
|
|
|
|
interthread_progress_window->set_title (title.get_string());
|
2005-09-25 16:33:00 -04:00
|
|
|
interthread_progress_window->set_position (Gtk::WIN_POS_MOUSE);
|
2005-09-25 14:42:24 -04:00
|
|
|
interthread_progress_window->show_all ();
|
2005-10-26 21:10:36 -04:00
|
|
|
interthread_progress_bar.set_fraction (0.0f);
|
2005-09-25 14:42:24 -04:00
|
|
|
interthread_progress_label.set_text ("");
|
|
|
|
interthread_cancel_label.set_text (_("Cancel Freeze"));
|
|
|
|
current_interthread_info = &itt;
|
|
|
|
|
|
|
|
interthread_progress_connection =
|
2005-10-09 01:03:29 -04:00
|
|
|
Glib::signal_timeout().connect (bind (mem_fun(*this, &Editor::freeze_progress_timeout), (gpointer) 0), 100);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
itt.done = false;
|
|
|
|
itt.cancel = false;
|
|
|
|
itt.progress = 0.0f;
|
2007-01-11 14:50:49 -05:00
|
|
|
|
|
|
|
pthread_attr_t attr;
|
|
|
|
pthread_attr_init(&attr);
|
|
|
|
pthread_attr_setstacksize(&attr, 500000);
|
|
|
|
|
|
|
|
pthread_create (&itt.thread, &attr, _freeze_thread, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-11 14:50:49 -05:00
|
|
|
pthread_attr_destroy(&attr);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
while (!itt.done && !itt.cancel) {
|
|
|
|
gtk_main_iteration ();
|
|
|
|
}
|
|
|
|
|
|
|
|
interthread_progress_connection.disconnect ();
|
|
|
|
interthread_progress_window->hide_all ();
|
|
|
|
current_interthread_info = 0;
|
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::bounce_range_selection ()
|
|
|
|
{
|
|
|
|
if (selection->time.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
TrackSelection views = selection->tracks;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t start = selection->time[clicked_selection].start;
|
|
|
|
nframes_t end = selection->time[clicked_selection].end;
|
|
|
|
nframes_t cnt = end - start + 1;
|
2007-04-12 19:20:37 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
begin_reversible_command (_("bounce range"));
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
for (TrackViewList::iterator i = views.begin(); i != views.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
RouteTimeAxisView* rtv;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if ((rtv = dynamic_cast<RouteTimeAxisView*> (*i)) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if ((playlist = rtv->playlist()) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
InterThreadInfo itt;
|
|
|
|
|
|
|
|
itt.done = false;
|
|
|
|
itt.cancel = false;
|
|
|
|
itt.progress = false;
|
2007-04-12 19:20:37 -04:00
|
|
|
|
|
|
|
XMLNode &before = playlist->get_state();
|
|
|
|
rtv->track()->bounce_range (start, cnt, itt);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Cut selected regions, automation points or a time range */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::cut ()
|
|
|
|
{
|
|
|
|
cut_copy (Cut);
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Copy selected regions, automation points or a time range */
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::copy ()
|
|
|
|
{
|
|
|
|
cut_copy (Copy);
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
|
|
|
|
/** @return true if a Cut, Copy or Clear is possible */
|
|
|
|
bool
|
|
|
|
Editor::can_cut_copy () const
|
|
|
|
{
|
|
|
|
switch (current_mouse_mode()) {
|
|
|
|
|
|
|
|
case MouseObject:
|
|
|
|
if (!selection->regions.empty() || !selection->points.empty()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
if (!selection->time.empty()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Cut, copy or clear selected regions, automation points or a time range.
|
|
|
|
* @param op Operation (Cut, Copy or Clear)
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::cut_copy (CutCopyOp op)
|
|
|
|
{
|
|
|
|
/* only cancel selection if cut/copy is successful.*/
|
|
|
|
|
|
|
|
string opname;
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case Cut:
|
|
|
|
opname = _("cut");
|
|
|
|
break;
|
|
|
|
case Copy:
|
|
|
|
opname = _("copy");
|
|
|
|
break;
|
|
|
|
case Clear:
|
|
|
|
opname = _("clear");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cut_buffer->clear ();
|
|
|
|
|
|
|
|
switch (current_mouse_mode()) {
|
|
|
|
case MouseObject:
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty() || !selection->points.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
begin_reversible_command (opname + _(" objects"));
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (!selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
cut_copy_regions (op);
|
|
|
|
|
|
|
|
if (op == Cut) {
|
2006-07-23 08:03:19 -04:00
|
|
|
selection->clear_regions ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!selection->points.empty()) {
|
|
|
|
cut_copy_points (op);
|
|
|
|
|
|
|
|
if (op == Cut) {
|
|
|
|
selection->clear_points ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MouseRange:
|
|
|
|
if (!selection->time.empty()) {
|
|
|
|
|
|
|
|
begin_reversible_command (opname + _(" range"));
|
|
|
|
cut_copy_ranges (op);
|
|
|
|
commit_reversible_command ();
|
|
|
|
|
|
|
|
if (op == Cut) {
|
|
|
|
selection->clear_time ();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
/** Cut, copy or clear selected automation points.
|
|
|
|
* @param op Operation (Cut, Copy or Clear)
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::cut_copy_points (CutCopyOp op)
|
|
|
|
{
|
|
|
|
for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) {
|
|
|
|
|
|
|
|
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*>(&(*i).track);
|
|
|
|
|
|
|
|
if (atv) {
|
|
|
|
atv->cut_copy_clear_objects (selection->points, op);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-21 18:59:29 -04:00
|
|
|
struct PlaylistState {
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2006-10-21 18:59:29 -04:00
|
|
|
XMLNode* before;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lt_playlist {
|
|
|
|
bool operator () (const PlaylistState& a, const PlaylistState& b) {
|
|
|
|
return a.playlist < b.playlist;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
struct PlaylistMapping {
|
|
|
|
TimeAxisView* tv;
|
|
|
|
boost::shared_ptr<Playlist> pl;
|
|
|
|
|
|
|
|
PlaylistMapping (TimeAxisView* tvp) : tv (tvp) {}
|
|
|
|
};
|
|
|
|
|
2007-05-10 07:53:35 -04:00
|
|
|
|
|
|
|
/** Cut, copy or clear selected regions.
|
|
|
|
* @param op Operation (Cut, Copy or Clear)
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::cut_copy_regions (CutCopyOp op)
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
|
|
|
/* we can't use a std::map here because the ordering is important, and we can't trivially sort
|
|
|
|
a map when we want ordered access to both elements. i think.
|
|
|
|
*/
|
|
|
|
|
|
|
|
vector<PlaylistMapping> pmap;
|
2006-10-21 18:59:29 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
nframes_t first_position = max_frames;
|
|
|
|
|
2006-10-21 18:59:29 -04:00
|
|
|
set<PlaylistState, lt_playlist> freezelist;
|
|
|
|
pair<set<PlaylistState, lt_playlist>::iterator,bool> insert_result;
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
/* get ordering correct before we cut/copy */
|
|
|
|
|
|
|
|
selection->regions.sort_by_position_and_track ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
first_position = min ((*x)->region()->position(), first_position);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (op == Cut || op == Clear) {
|
2007-01-28 12:44:13 -05:00
|
|
|
boost::shared_ptr<Playlist> pl = (*x)->region()->playlist();
|
2007-01-09 18:24:54 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (pl) {
|
2006-10-21 18:59:29 -04:00
|
|
|
|
|
|
|
PlaylistState before;
|
|
|
|
before.playlist = pl;
|
|
|
|
before.before = &pl->get_state();
|
|
|
|
|
|
|
|
insert_result = freezelist.insert (before);
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (insert_result.second) {
|
|
|
|
pl->freeze ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
TimeAxisView* tv = &(*x)->get_trackview();
|
|
|
|
vector<PlaylistMapping>::iterator z;
|
|
|
|
|
|
|
|
for (z = pmap.begin(); z != pmap.end(); ++z) {
|
|
|
|
if ((*z).tv == tv) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (z == pmap.end()) {
|
|
|
|
pmap.push_back (PlaylistMapping (tv));
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
boost::shared_ptr<Playlist> pl = (*x)->region()->playlist();
|
|
|
|
|
|
|
|
if (!pl) {
|
|
|
|
/* impossible, but this handles it for the future */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
TimeAxisView& tv = (*x)->get_trackview();
|
|
|
|
boost::shared_ptr<Playlist> npl;
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionSelection::iterator tmp;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
tmp = x;
|
|
|
|
++tmp;
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
vector<PlaylistMapping>::iterator z;
|
|
|
|
|
|
|
|
for (z = pmap.begin(); z != pmap.end(); ++z) {
|
|
|
|
if ((*z).tv == &tv) {
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
assert (z != pmap.end());
|
|
|
|
|
|
|
|
if (!(*z).pl) {
|
|
|
|
npl = PlaylistFactory::create (pl->data_type(), *session, "cutlist", true);
|
|
|
|
npl->freeze();
|
|
|
|
(*z).pl = npl;
|
|
|
|
} else {
|
|
|
|
npl = (*z).pl;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Region> r = (*x)->region();
|
2007-04-12 19:20:37 -04:00
|
|
|
boost::shared_ptr<Region> _xx;
|
2007-05-02 09:09:03 -04:00
|
|
|
|
|
|
|
assert (r != 0);
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
switch (op) {
|
|
|
|
case Cut:
|
2007-05-02 09:09:03 -04:00
|
|
|
_xx = RegionFactory::create (r);
|
|
|
|
npl->add_region (_xx, r->position() - first_position);
|
|
|
|
pl->remove_region (r);
|
2007-01-28 12:44:13 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Copy:
|
2007-04-12 19:20:37 -04:00
|
|
|
/* copy region before adding, so we're not putting same object into two different playlists */
|
2007-05-02 11:21:51 -04:00
|
|
|
npl->add_region (RegionFactory::create (r), r->position() - first_position);
|
2007-01-28 12:44:13 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Clear:
|
|
|
|
pl->remove_region (r);
|
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
x = tmp;
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
list<boost::shared_ptr<Playlist> > foo;
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
/* the pmap is in the same order as the tracks in which selected regions occured */
|
|
|
|
|
|
|
|
for (vector<PlaylistMapping>::iterator i = pmap.begin(); i != pmap.end(); ++i) {
|
|
|
|
(*i).pl->thaw();
|
|
|
|
foo.push_back ((*i).pl);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (!foo.empty()) {
|
|
|
|
cut_buffer->set (foo);
|
|
|
|
}
|
2007-04-12 19:20:37 -04:00
|
|
|
|
2006-10-21 18:59:29 -04:00
|
|
|
for (set<PlaylistState, lt_playlist>::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) {
|
|
|
|
(*pl).playlist->thaw ();
|
|
|
|
session->add_command (new MementoCommand<Playlist>(*(*pl).playlist, (*pl).before, &(*pl).playlist->get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::cut_copy_ranges (CutCopyOp op)
|
|
|
|
{
|
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
(*i)->cut_copy_clear (*selection, op);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::paste (float times)
|
|
|
|
{
|
2007-11-07 20:40:25 -05:00
|
|
|
paste_internal (get_preferred_edit_position(), times);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::mouse_paste ()
|
|
|
|
{
|
2007-11-07 20:40:25 -05:00
|
|
|
nframes64_t where;
|
|
|
|
bool ignored;
|
2006-01-02 15:27:51 -05:00
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
if (!mouse_frame (where, ignored)) {
|
|
|
|
return;
|
|
|
|
}
|
2006-01-02 15:27:51 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
snap_to (where);
|
|
|
|
paste_internal (where, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::paste_internal (nframes_t position, float times)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
bool commit = false;
|
|
|
|
|
|
|
|
if (cut_buffer->empty() || selection->tracks.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (position == max_frames) {
|
2007-11-07 20:40:25 -05:00
|
|
|
position = get_preferred_edit_position();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("paste"));
|
|
|
|
|
|
|
|
TrackSelection::iterator i;
|
|
|
|
size_t nth;
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
/* get everything in the correct order */
|
|
|
|
|
|
|
|
sort_track_selection ();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for (nth = 0, i = selection->tracks.begin(); i != selection->tracks.end(); ++i, ++nth) {
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* undo/redo is handled by individual tracks */
|
|
|
|
|
|
|
|
if ((*i)->paste (position, times, *cut_buffer, nth)) {
|
|
|
|
commit = true;
|
|
|
|
}
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (commit) {
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::paste_named_selection (float times)
|
|
|
|
{
|
2005-11-24 09:59:36 -05:00
|
|
|
TrackSelection::iterator t;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
Glib::RefPtr<TreeSelection> selected = named_selection_display.get_selection();
|
2005-11-12 17:07:07 -05:00
|
|
|
|
2005-11-24 09:59:36 -05:00
|
|
|
if (selected->count_selected_rows() != 1 || selection->tracks.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-11-12 17:07:07 -05:00
|
|
|
TreeModel::iterator i = selected->get_selected();
|
2005-11-12 22:53:51 -05:00
|
|
|
NamedSelection* ns = (*i)[named_selection_columns.selection];
|
2005-11-12 17:07:07 -05:00
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
list<boost::shared_ptr<Playlist> >::iterator chunk;
|
|
|
|
list<boost::shared_ptr<Playlist> >::iterator tmp;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
chunk = ns->playlists.begin();
|
|
|
|
|
|
|
|
begin_reversible_command (_("paste chunk"));
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
sort_track_selection ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-24 09:59:36 -05:00
|
|
|
for (t = selection->tracks.begin(); t != selection->tracks.end(); ++t) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
RouteTimeAxisView* rtv;
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> pl;
|
|
|
|
boost::shared_ptr<AudioPlaylist> apl;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if ((rtv = dynamic_cast<RouteTimeAxisView*> (*t)) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
if ((pl = rtv->playlist()) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
continue;
|
|
|
|
}
|
2007-01-09 18:24:54 -05:00
|
|
|
|
|
|
|
if ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = chunk;
|
|
|
|
++tmp;
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
XMLNode &before = apl->get_state();
|
2007-11-07 20:40:25 -05:00
|
|
|
apl->paste (*chunk, get_preferred_edit_position(), times);
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<AudioPlaylist>(*apl, &before, &apl->get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (tmp != ns->playlists.end()) {
|
|
|
|
chunk = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
Editor::duplicate_some_regions (RegionSelection& regions, float times)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionSelection sel = regions; // clear (below) will clear the argument list
|
2006-01-08 09:50:41 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
begin_reversible_command (_("duplicate region"));
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
selection->clear_regions ();
|
2006-01-08 09:50:41 -05:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = sel.begin(); i != sel.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
boost::shared_ptr<Region> r ((*i)->region());
|
2006-01-08 01:08:15 -05:00
|
|
|
|
|
|
|
TimeAxisView& tv = (*i)->get_time_axis_view();
|
2007-04-12 19:20:37 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (&tv);
|
|
|
|
sigc::connection c = rtv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
playlist = (*i)->region()->playlist();
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = playlist->get_state();
|
2006-08-29 17:21:48 -04:00
|
|
|
playlist->duplicate (r, r->last_frame(), times);
|
2006-08-24 03:37:17 -04:00
|
|
|
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-08 01:08:15 -05:00
|
|
|
c.disconnect ();
|
2006-01-08 09:50:41 -05:00
|
|
|
|
|
|
|
if (latest_regionview) {
|
|
|
|
selection->add (latest_regionview);
|
|
|
|
}
|
2006-01-08 01:08:15 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::duplicate_selection (float times)
|
|
|
|
{
|
|
|
|
if (selection->time.empty() || selection->tracks.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2006-08-29 17:21:48 -04:00
|
|
|
vector<boost::shared_ptr<AudioRegion> > new_regions;
|
|
|
|
vector<boost::shared_ptr<AudioRegion> >::iterator ri;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
create_region_from_selection (new_regions);
|
|
|
|
|
|
|
|
if (new_regions.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("duplicate selection"));
|
|
|
|
|
|
|
|
ri = new_regions.begin();
|
|
|
|
|
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
if ((playlist = (*i)->playlist()) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = playlist->get_state();
|
2006-08-29 17:21:48 -04:00
|
|
|
playlist->duplicate (*ri, selection->time[clicked_selection].end, times);
|
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
|
|
|
|
|
|
|
++ri;
|
|
|
|
if (ri == new_regions.end()) {
|
|
|
|
--ri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2006-05-19 16:10:35 -04:00
|
|
|
void
|
|
|
|
Editor::reset_point_selection ()
|
|
|
|
{
|
|
|
|
/* reset all selected points to the relevant default value */
|
|
|
|
|
|
|
|
for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) {
|
|
|
|
|
|
|
|
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*>(&(*i).track);
|
|
|
|
|
|
|
|
if (atv) {
|
|
|
|
atv->reset_objects (selection->points);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::center_playhead ()
|
|
|
|
{
|
|
|
|
float page = canvas_width * frames_per_unit;
|
|
|
|
|
|
|
|
center_screen_internal (playhead_cursor->current_frame, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::center_edit_cursor ()
|
|
|
|
{
|
|
|
|
float page = canvas_width * frames_per_unit;
|
|
|
|
|
2007-11-07 20:40:25 -05:00
|
|
|
center_screen_internal (get_preferred_edit_position(), page);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-01-09 18:24:54 -05:00
|
|
|
Editor::clear_playlist (boost::shared_ptr<Playlist> playlist)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
begin_reversible_command (_("clear playlist"));
|
2007-01-09 18:24:54 -05:00
|
|
|
XMLNode &before = playlist->get_state();
|
|
|
|
playlist->clear ();
|
|
|
|
XMLNode &after = playlist->get_state();
|
|
|
|
session->add_command (new MementoCommand<Playlist>(*playlist.get(), &before, &after));
|
2005-09-25 14:42:24 -04:00
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-05-10 07:53:35 -04:00
|
|
|
Editor::nudge_selected_tracks (bool use_edit_cursor, bool forwards)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-01-09 18:24:54 -05:00
|
|
|
boost::shared_ptr<Playlist> playlist;
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t distance;
|
|
|
|
nframes_t next_distance;
|
|
|
|
nframes_t start;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (use_edit_cursor) {
|
2007-11-07 20:40:25 -05:00
|
|
|
start = get_preferred_edit_position();
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
start = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((distance = get_nudge_distance (start, next_distance)) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("nudge track"));
|
|
|
|
|
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
|
|
|
|
if ((playlist = (*i)->playlist()) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-08-09 21:22:45 -04:00
|
|
|
XMLNode &before = playlist->get_state();
|
2005-09-25 14:42:24 -04:00
|
|
|
playlist->nudge_after (start, distance, forwards);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::remove_last_capture ()
|
|
|
|
{
|
|
|
|
vector<string> choices;
|
|
|
|
string prompt;
|
|
|
|
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Config->get_verify_remove_last_capture()) {
|
|
|
|
prompt = _("Do you really want to destroy the last capture?"
|
|
|
|
"\n(This is destructive and cannot be undone)");
|
|
|
|
|
|
|
|
choices.push_back (_("No, do nothing."));
|
2006-04-20 07:41:45 -04:00
|
|
|
choices.push_back (_("Yes, destroy it."));
|
2005-11-24 09:59:36 -05:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
Gtkmm2ext::Choice prompter (prompt, choices);
|
2005-11-24 09:59:36 -05:00
|
|
|
|
2006-04-20 07:41:45 -04:00
|
|
|
if (prompter.run () == 1) {
|
2006-03-22 12:03:00 -05:00
|
|
|
session->remove_last_capture ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2005-11-24 09:59:36 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
session->remove_last_capture();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-05-10 07:53:35 -04:00
|
|
|
Editor::normalize_regions ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("normalize"));
|
|
|
|
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*wait_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
gdk_flush ();
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator r = selection->regions.begin(); r != selection->regions.end(); ++r) {
|
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*r);
|
|
|
|
if (!arv)
|
|
|
|
continue;
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &before = arv->region()->get_state();
|
|
|
|
arv->audio_region()->normalize_to (0.0f);
|
2006-11-19 11:45:16 -05:00
|
|
|
session->add_command (new MementoCommand<Region>(*(arv->region().get()), &before, &arv->region()->get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
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
|
2007-05-10 07:53:35 -04:00
|
|
|
Editor::denormalize_regions ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command ("denormalize");
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator r = selection->regions.begin(); r != selection->regions.end(); ++r) {
|
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*r);
|
|
|
|
if (!arv)
|
|
|
|
continue;
|
2006-08-29 17:21:48 -04:00
|
|
|
XMLNode &before = arv->region()->get_state();
|
|
|
|
arv->audio_region()->set_scale_amplitude (1.0f);
|
|
|
|
session->add_command (new MementoCommand<Region>(*(arv->region().get()), &before, &arv->region()->get_state()));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2007-05-10 07:53:35 -04:00
|
|
|
Editor::reverse_regions ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Reverse rev (*session);
|
|
|
|
apply_filter (rev, _("reverse regions"));
|
|
|
|
}
|
|
|
|
|
2007-08-06 01:30:18 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2007-08-06 01:30:18 -04:00
|
|
|
Editor::quantize_regions ()
|
|
|
|
{
|
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: varying meter?
|
|
|
|
Quantize quant (*session, snap_length_beats(0));
|
|
|
|
apply_filter (quant, _("quantize regions"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::apply_filter (Filter& filter, string command)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (command);
|
|
|
|
|
2005-12-12 15:54:55 -05:00
|
|
|
track_canvas.get_window()->set_cursor (*wait_cursor);
|
2005-09-25 14:42:24 -04:00
|
|
|
gdk_flush ();
|
|
|
|
|
2007-08-06 01:30:18 -04:00
|
|
|
/* this is ugly. */
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator r = selection->regions.begin(); r != selection->regions.end(); ) {
|
2007-08-06 01:30:18 -04:00
|
|
|
RegionSelection::iterator tmp = r;
|
|
|
|
++tmp;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-08-06 01:30:18 -04:00
|
|
|
MidiRegionView* const mrv = dynamic_cast<MidiRegionView*>(*r);
|
|
|
|
if (mrv) {
|
|
|
|
if (mrv->midi_region()->apply(filter) == 0) {
|
|
|
|
mrv->redisplay_model();
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-08-06 01:30:18 -04:00
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*r);
|
|
|
|
if (arv) {
|
|
|
|
boost::shared_ptr<Playlist> playlist = arv->region()->playlist();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-08-06 01:30:18 -04:00
|
|
|
if (arv->audio_region()->apply (filter) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-08-06 01:30:18 -04:00
|
|
|
XMLNode &before = playlist->get_state();
|
|
|
|
playlist->replace_region (arv->region(), filter.results.front(), arv->region()->position());
|
|
|
|
XMLNode &after = playlist->get_state();
|
|
|
|
session->add_command(new MementoCommand<Playlist>(*playlist, &before, &after));
|
|
|
|
} else {
|
|
|
|
goto out;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
r = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
2006-07-23 08:03:19 -04:00
|
|
|
selection->regions.clear ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
out:
|
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::region_selection_op (void (Region::*pmf)(void))
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
Region* region = (*i)->region().get();
|
|
|
|
(region->*pmf)();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::region_selection_op (void (Region::*pmf)(void*), void *arg)
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
Region* region = (*i)->region().get();
|
|
|
|
(region->*pmf)(arg);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::region_selection_op (void (Region::*pmf)(bool), bool yn)
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
Region* region = (*i)->region().get();
|
|
|
|
(region->*pmf)(yn);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::external_edit_region ()
|
|
|
|
{
|
|
|
|
/* more to come */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
Editor::brush (nframes_t pos)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionSelection sel;
|
2005-09-25 14:42:24 -04:00
|
|
|
snap_to (pos);
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (selection->regions.empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
/* XXX get selection from region list */
|
|
|
|
} else {
|
2006-07-23 08:03:19 -04:00
|
|
|
sel = selection->regions;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sel.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
mouse_brush_insert_region ((*i), pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
void
|
|
|
|
Editor::reset_region_gain_envelopes ()
|
|
|
|
{
|
|
|
|
if (!session || selection->regions.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session->begin_reversible_command (_("reset region gain"));
|
|
|
|
|
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
if (arv) {
|
2007-06-29 00:02:58 -04:00
|
|
|
boost::shared_ptr<AutomationList> alist (arv->audio_region()->envelope());
|
|
|
|
XMLNode& before (alist->get_state());
|
2006-11-19 11:45:16 -05:00
|
|
|
|
|
|
|
arv->audio_region()->set_default_envelope ();
|
2007-06-29 00:02:58 -04:00
|
|
|
session->add_command (new MementoCommand<AutomationList>(*arv->audio_region()->envelope().get(), &before, &alist->get_state()));
|
2006-11-19 11:45:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
session->commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2007-10-11 18:07:47 -04:00
|
|
|
Editor::toggle_gain_envelope_visibility ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
2006-11-19 11:45:16 -05:00
|
|
|
if (arv) {
|
2007-10-11 18:07:47 -04:00
|
|
|
bool x = region_envelope_visible_item->get_active();
|
|
|
|
if (x != arv->envelope_visible()) {
|
|
|
|
arv->set_envelope_visible (x);
|
2006-11-19 11:45:16 -05:00
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-11 18:07:47 -04:00
|
|
|
Editor::toggle_gain_envelope_active ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
2006-11-19 11:45:16 -05:00
|
|
|
if (arv) {
|
2007-10-11 18:07:47 -04:00
|
|
|
bool x = region_envelope_active_item->get_active();
|
|
|
|
if (x != arv->audio_region()->envelope_active()) {
|
|
|
|
arv->audio_region()->set_envelope_active (x);
|
2006-11-19 11:45:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-11 18:07:47 -04:00
|
|
|
/** Set the position-locked state of all selected regions to a particular value.
|
2007-05-10 07:53:35 -04:00
|
|
|
* @param yn true to make locked, false to make unlocked.
|
|
|
|
*/
|
2006-11-19 11:45:16 -05:00
|
|
|
void
|
2007-10-11 18:07:47 -04:00
|
|
|
Editor::toggle_region_position_lock ()
|
2006-11-19 11:45:16 -05:00
|
|
|
{
|
2007-10-11 18:07:47 -04:00
|
|
|
bool x = region_lock_position_item->get_active();
|
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2007-10-11 18:07:47 -04:00
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
if (arv) {
|
|
|
|
if (x != arv->audio_region()->locked()) {
|
|
|
|
arv->audio_region()->set_position_locked (x);
|
|
|
|
}
|
|
|
|
}
|
2007-05-14 12:16:54 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-11 18:07:47 -04:00
|
|
|
Editor::toggle_region_lock ()
|
2007-05-14 12:16:54 -04:00
|
|
|
{
|
2007-10-11 18:07:47 -04:00
|
|
|
bool x = region_lock_item->get_active();
|
|
|
|
|
2007-05-14 12:16:54 -04:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2007-10-11 18:07:47 -04:00
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
if (arv) {
|
|
|
|
if (x != arv->audio_region()->locked()) {
|
|
|
|
arv->audio_region()->set_locked (x);
|
|
|
|
}
|
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-11 18:07:47 -04:00
|
|
|
Editor::toggle_region_mute ()
|
2006-11-19 11:45:16 -05:00
|
|
|
{
|
2007-10-11 18:07:47 -04:00
|
|
|
bool x = region_mute_item->get_active();
|
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2007-10-11 18:07:47 -04:00
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
if (arv) {
|
|
|
|
if (x != arv->audio_region()->muted()) {
|
|
|
|
arv->audio_region()->set_muted (x);
|
|
|
|
}
|
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-11 18:07:47 -04:00
|
|
|
Editor::toggle_region_opaque ()
|
2006-11-19 11:45:16 -05:00
|
|
|
{
|
2007-10-11 18:07:47 -04:00
|
|
|
bool x = region_opaque_item->get_active();
|
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
2007-10-11 18:07:47 -04:00
|
|
|
AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
|
|
|
|
if (arv) {
|
|
|
|
if (x != arv->audio_region()->opaque()) {
|
|
|
|
arv->audio_region()->set_opaque (x);
|
|
|
|
}
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_fade_in_shape (AudioRegion::FadeShape shape)
|
|
|
|
{
|
|
|
|
begin_reversible_command (_("set fade in shape"));
|
|
|
|
|
|
|
|
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
|
|
|
|
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (*x);
|
|
|
|
|
|
|
|
if (!tmp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-29 00:02:58 -04:00
|
|
|
boost::shared_ptr<AutomationList> alist = tmp->audio_region()->fade_in();
|
|
|
|
XMLNode &before = alist->get_state();
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
tmp->audio_region()->set_fade_in_shape (shape);
|
|
|
|
|
2007-06-29 00:02:58 -04:00
|
|
|
XMLNode &after = alist->get_state();
|
|
|
|
session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &after));
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_fade_out_shape (AudioRegion::FadeShape shape)
|
|
|
|
{
|
|
|
|
begin_reversible_command (_("set fade out shape"));
|
|
|
|
|
|
|
|
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
|
|
|
|
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (*x);
|
|
|
|
|
|
|
|
if (!tmp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-29 00:02:58 -04:00
|
|
|
boost::shared_ptr<AutomationList> alist = tmp->audio_region()->fade_out();
|
|
|
|
XMLNode &before = alist->get_state();
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
tmp->audio_region()->set_fade_out_shape (shape);
|
|
|
|
|
2007-06-29 00:02:58 -04:00
|
|
|
XMLNode &after = alist->get_state();
|
|
|
|
session->add_command(new MementoCommand<AutomationList>(*alist.get(), &before, &after));
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_fade_in_active (bool yn)
|
|
|
|
{
|
|
|
|
begin_reversible_command (_("set fade in active"));
|
|
|
|
|
|
|
|
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
|
|
|
|
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (*x);
|
|
|
|
|
|
|
|
if (!tmp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boost::shared_ptr<AudioRegion> ar (tmp->audio_region());
|
|
|
|
|
|
|
|
XMLNode &before = ar->get_state();
|
|
|
|
|
|
|
|
ar->set_fade_in_active (yn);
|
|
|
|
|
|
|
|
XMLNode &after = ar->get_state();
|
|
|
|
session->add_command(new MementoCommand<AudioRegion>(*ar, &before, &after));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_fade_out_active (bool yn)
|
|
|
|
{
|
|
|
|
begin_reversible_command (_("set fade out active"));
|
|
|
|
|
|
|
|
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
|
|
|
|
AudioRegionView* tmp = dynamic_cast<AudioRegionView*> (*x);
|
|
|
|
|
|
|
|
if (!tmp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<AudioRegion> ar (tmp->audio_region());
|
|
|
|
|
|
|
|
XMLNode &before = ar->get_state();
|
|
|
|
|
|
|
|
ar->set_fade_out_active (yn);
|
|
|
|
|
|
|
|
XMLNode &after = ar->get_state();
|
|
|
|
session->add_command(new MementoCommand<AudioRegion>(*ar, &before, &after));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-22 14:01:10 -04:00
|
|
|
|
|
|
|
/** Update crossfade visibility after its configuration has been changed */
|
|
|
|
void
|
|
|
|
Editor::update_xfade_visibility ()
|
|
|
|
{
|
|
|
|
_xfade_visibility = Config->get_xfades_visible ();
|
|
|
|
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
AudioTimeAxisView* v = dynamic_cast<AudioTimeAxisView*>(*i);
|
|
|
|
if (v) {
|
|
|
|
if (_xfade_visibility) {
|
|
|
|
v->show_all_xfades ();
|
|
|
|
} else {
|
|
|
|
v->hide_all_xfades ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|