2007-01-28 12:44:13 -05:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2000-2006 Paul Davis
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
#include <algorithm>
|
2008-09-10 11:03:30 -04:00
|
|
|
#include <cstdlib>
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/stacktrace.h"
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2009-10-30 11:30:22 -04:00
|
|
|
#include "ardour/session.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/playlist.h"
|
|
|
|
#include "ardour/route_group.h"
|
|
|
|
#include "ardour/profile.h"
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
#include "editor.h"
|
|
|
|
#include "actions.h"
|
|
|
|
#include "audio_time_axis.h"
|
|
|
|
#include "audio_region_view.h"
|
|
|
|
#include "audio_streamview.h"
|
|
|
|
#include "automation_line.h"
|
2007-07-06 23:19:04 -04:00
|
|
|
#include "control_point.h"
|
2009-07-03 18:42:22 -04:00
|
|
|
#include "editor_regions.h"
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Glib;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
using namespace Editing;
|
|
|
|
|
|
|
|
struct TrackViewByPositionSorter
|
|
|
|
{
|
2009-07-09 13:58:13 -04:00
|
|
|
bool operator() (const TimeAxisView* a, const TimeAxisView *b) {
|
2009-01-01 19:17:55 -05:00
|
|
|
return a->y_position() < b->y_position();
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
2009-07-09 13:58:13 -04:00
|
|
|
Editor::extend_selection_to_track (TimeAxisView& view)
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
2009-07-09 13:58:13 -04:00
|
|
|
if (selection->selected (&view)) {
|
2007-01-28 12:44:13 -05:00
|
|
|
/* already selected, do nothing */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
if (!selection->selected (&view)) {
|
|
|
|
selection->set (&view);
|
2007-01-28 12:44:13 -05:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
/* something is already selected, so figure out which range of things to add */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
TrackViewList to_be_added;
|
|
|
|
TrackViewList sorted = track_views;
|
|
|
|
TrackViewByPositionSorter cmp;
|
|
|
|
bool passed_clicked = false;
|
|
|
|
bool forwards = true;
|
|
|
|
|
|
|
|
sorted.sort (cmp);
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
if (!selection->selected (&view)) {
|
|
|
|
to_be_added.push_back (&view);
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* figure out if we should go forward or backwards */
|
|
|
|
|
|
|
|
for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) {
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
if ((*i) == &view) {
|
2007-01-28 12:44:13 -05:00
|
|
|
passed_clicked = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selection->selected (*i)) {
|
|
|
|
if (passed_clicked) {
|
|
|
|
forwards = true;
|
|
|
|
} else {
|
|
|
|
forwards = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
passed_clicked = false;
|
|
|
|
|
|
|
|
if (forwards) {
|
|
|
|
|
|
|
|
for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
if ((*i) == &view) {
|
2007-01-28 12:44:13 -05:00
|
|
|
passed_clicked = true;
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
if (passed_clicked) {
|
|
|
|
if ((*i)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (selection->selected (*i)) {
|
|
|
|
break;
|
|
|
|
} else if (!(*i)->hidden()) {
|
|
|
|
to_be_added.push_back (*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
for (TrackViewList::reverse_iterator r = sorted.rbegin(); r != sorted.rend(); ++r) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
if ((*r) == &view) {
|
2007-01-28 12:44:13 -05:00
|
|
|
passed_clicked = true;
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
if (passed_clicked) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
if ((*r)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
if (selection->selected (*r)) {
|
|
|
|
break;
|
|
|
|
} else if (!(*r)->hidden()) {
|
|
|
|
to_be_added.push_back (*r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
if (!to_be_added.empty()) {
|
|
|
|
selection->add (to_be_added);
|
|
|
|
return true;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-18 02:07:08 -04:00
|
|
|
void
|
|
|
|
Editor::select_all_tracks ()
|
|
|
|
{
|
2008-10-14 10:20:29 -04:00
|
|
|
TrackViewList visible_views;
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
if ((*i)->marked_for_display()) {
|
|
|
|
visible_views.push_back (*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
selection->set (visible_views);
|
2007-03-18 02:07:08 -04:00
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2010-08-06 19:28:44 -04:00
|
|
|
/** Select clicked_axisview, unless there are no currently selected
|
2010-01-01 17:11:15 -05:00
|
|
|
* tracks, in which case nothing will happen unless `force' is true.
|
|
|
|
*/
|
2008-01-10 16:20:59 -05:00
|
|
|
void
|
2010-09-02 13:01:36 -04:00
|
|
|
Editor::set_selected_track_as_side_effect (Selection::Operation op, bool /*force*/)
|
2008-01-10 16:20:59 -05:00
|
|
|
{
|
2010-08-06 19:28:44 -04:00
|
|
|
if (!clicked_axisview) {
|
2008-01-10 16:20:59 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-26 19:25:44 -04:00
|
|
|
#if 1
|
|
|
|
if (!clicked_routeview) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-30 13:34:12 -04:00
|
|
|
bool had_tracks = !selection->tracks.empty();
|
2010-08-26 19:25:44 -04:00
|
|
|
RouteGroup* group = clicked_routeview->route()->route_group();
|
2010-08-30 13:34:12 -04:00
|
|
|
RouteGroup& arg (_session->all_route_group());
|
2010-08-26 19:25:44 -04:00
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case Selection::Toggle:
|
|
|
|
if (selection->selected (clicked_axisview)) {
|
2010-08-30 13:34:12 -04:00
|
|
|
if (arg.is_select() && arg.is_active()) {
|
2010-08-26 19:25:44 -04:00
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
|
|
|
|
selection->remove(*i);
|
|
|
|
}
|
|
|
|
} else if (group && group->is_active()) {
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
|
|
|
|
if ((*i)->route_group() == group)
|
|
|
|
selection->remove(*i);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
selection->remove (clicked_axisview);
|
|
|
|
}
|
|
|
|
} else {
|
2010-08-30 13:34:12 -04:00
|
|
|
if (arg.is_select() && arg.is_active()) {
|
2010-08-26 19:25:44 -04:00
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
|
|
|
|
selection->add(*i);
|
|
|
|
}
|
|
|
|
} else if (group && group->is_active()) {
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
|
|
|
|
if ( (*i)->route_group() == group)
|
|
|
|
selection->add(*i);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
selection->add (clicked_axisview);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Selection::Add:
|
2010-08-30 13:34:12 -04:00
|
|
|
if (!had_tracks && arg.is_select() && arg.is_active()) {
|
|
|
|
/* nothing was selected already, and all group is active etc. so use
|
|
|
|
all tracks.
|
|
|
|
*/
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
|
|
|
|
selection->add(*i);
|
|
|
|
}
|
|
|
|
} else if (group && group->is_active()) {
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
|
|
|
|
if ((*i)->route_group() == group)
|
|
|
|
selection->add(*i);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
selection->add (clicked_axisview);
|
|
|
|
}
|
2010-08-26 19:25:44 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Selection::Set:
|
2010-08-30 13:34:12 -04:00
|
|
|
selection->clear();
|
|
|
|
if (!had_tracks && arg.is_select() && arg.is_active()) {
|
|
|
|
/* nothing was selected already, and all group is active etc. so use
|
|
|
|
all tracks.
|
|
|
|
*/
|
2010-08-26 19:25:44 -04:00
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
|
|
|
|
selection->add(*i);
|
|
|
|
}
|
|
|
|
} else if (group && group->is_active()) {
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
|
|
|
|
if ((*i)->route_group() == group)
|
|
|
|
selection->add(*i);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
selection->set (clicked_axisview);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Selection::Extend:
|
|
|
|
selection->clear();
|
|
|
|
cerr << ("Editor::set_selected_track_as_side_effect case Selection::Add not yet implemented\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else // the older version
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (!selection->tracks.empty()) {
|
2010-08-06 19:28:44 -04:00
|
|
|
if (!selection->selected (clicked_axisview)) {
|
|
|
|
selection->add (clicked_axisview);
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (force) {
|
2010-08-06 19:28:44 -04:00
|
|
|
selection->set (clicked_axisview);
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2010-08-26 19:25:44 -04:00
|
|
|
#endif
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-09 13:58:13 -04:00
|
|
|
Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no_remove)
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
|
|
|
switch (op) {
|
|
|
|
case Selection::Toggle:
|
2009-07-09 13:58:13 -04:00
|
|
|
if (selection->selected (&view)) {
|
2007-01-28 12:44:13 -05:00
|
|
|
if (!no_remove) {
|
2009-07-09 13:58:13 -04:00
|
|
|
selection->remove (&view);
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
} else {
|
2009-07-09 13:58:13 -04:00
|
|
|
selection->add (&view);
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Selection::Add:
|
2009-07-09 13:58:13 -04:00
|
|
|
if (!selection->selected (&view)) {
|
|
|
|
selection->add (&view);
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Selection::Set:
|
2009-07-09 13:58:13 -04:00
|
|
|
selection->set (&view);
|
2007-01-28 12:44:13 -05:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
case Selection::Extend:
|
2008-01-10 16:20:59 -05:00
|
|
|
extend_selection_to_track (view);
|
2007-01-28 12:44:13 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
void
|
2007-01-28 12:44:13 -05:00
|
|
|
Editor::set_selected_track_from_click (bool press, Selection::Operation op, bool no_remove)
|
|
|
|
{
|
|
|
|
if (!clicked_routeview) {
|
2008-01-10 16:20:59 -05:00
|
|
|
return;
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
if (!press) {
|
2008-01-10 16:20:59 -05:00
|
|
|
return;
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
set_selected_track (*clicked_routeview, op, no_remove);
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::set_selected_control_point_from_click (Selection::Operation op, bool /*no_remove*/)
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
|
|
|
if (!clicked_control_point) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-01-04 22:15:28 -05:00
|
|
|
|
2010-08-10 21:23:03 -04:00
|
|
|
switch (op) {
|
|
|
|
case Selection::Set:
|
|
|
|
selection->set (clicked_control_point);
|
|
|
|
break;
|
|
|
|
case Selection::Add:
|
|
|
|
selection->add (clicked_control_point);
|
|
|
|
break;
|
|
|
|
case Selection::Toggle:
|
|
|
|
selection->toggle (clicked_control_point);
|
|
|
|
break;
|
|
|
|
case Selection::Extend:
|
|
|
|
/* XXX */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
2009-04-15 14:04:23 -04:00
|
|
|
void
|
|
|
|
Editor::get_onscreen_tracks (TrackViewList& tvl)
|
|
|
|
{
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
2009-06-13 13:52:51 -04:00
|
|
|
if ((*i)->y_position() < _canvas_height) {
|
2009-04-15 14:04:23 -04:00
|
|
|
tvl.push_back (*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-25 16:58:32 -04:00
|
|
|
/** Call a slot for a given `basis' track and also for any track that is in the same
|
|
|
|
* active route group with a particular set of properties.
|
|
|
|
*
|
2007-10-06 12:24:08 -04:00
|
|
|
* @param sl Slot to call.
|
|
|
|
* @param basis Basis track.
|
2009-06-25 16:58:32 -04:00
|
|
|
* @param prop Properties that active edit groups must share to be included in the map.
|
2007-10-06 12:24:08 -04:00
|
|
|
*/
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
void
|
2010-02-18 08:59:49 -05:00
|
|
|
Editor::mapover_tracks (sigc::slot<void, RouteTimeAxisView&, uint32_t> sl, TimeAxisView* basis, PBD::PropertyID prop) const
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* route_basis = dynamic_cast<RouteTimeAxisView*> (basis);
|
2010-07-06 07:34:00 -04:00
|
|
|
|
2007-10-06 12:24:08 -04:00
|
|
|
if (route_basis == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
set<RouteTimeAxisView*> tracks;
|
2009-12-13 14:09:52 -05:00
|
|
|
tracks.insert (route_basis);
|
|
|
|
|
|
|
|
RouteGroup* group = route_basis->route()->route_group();
|
2010-07-06 07:34:00 -04:00
|
|
|
|
|
|
|
if (group && group->enabled_property(prop) && group->enabled_property (Properties::active.property_id) ) {
|
2009-12-13 14:09:52 -05:00
|
|
|
|
|
|
|
/* the basis is a member of an active route group, with the appropriate
|
|
|
|
properties; find other members */
|
|
|
|
|
|
|
|
for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
RouteTimeAxisView* v = dynamic_cast<RouteTimeAxisView*> (*i);
|
|
|
|
if (v && v->route()->route_group() == group) {
|
|
|
|
tracks.insert (v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-06 12:24:08 -04:00
|
|
|
|
|
|
|
/* call the slots */
|
|
|
|
uint32_t const sz = tracks.size ();
|
2010-07-06 07:34:00 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
for (set<RouteTimeAxisView*>::iterator i = tracks.begin(); i != tracks.end(); ++i) {
|
|
|
|
sl (**i, sz);
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t, RegionView * basis, vector<RegionView*>* all_equivs) const
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
|
|
|
boost::shared_ptr<Playlist> pl;
|
|
|
|
vector<boost::shared_ptr<Region> > results;
|
|
|
|
RegionView* marv;
|
2010-04-21 16:42:22 -04:00
|
|
|
boost::shared_ptr<Track> tr;
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
if ((tr = tv.track()) == 0) {
|
2007-01-28 12:44:13 -05:00
|
|
|
/* bus */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
if (&tv == &basis->get_time_axis_view()) {
|
2007-01-28 12:44:13 -05:00
|
|
|
/* looking in same track as the original */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
if ((pl = tr->playlist()) != 0) {
|
2007-01-28 12:44:13 -05:00
|
|
|
pl->get_equivalent_regions (basis->region(), results);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
|
2009-07-09 13:58:13 -04:00
|
|
|
if ((marv = tv.view()->find_view (*ir)) != 0) {
|
2007-01-28 12:44:13 -05:00
|
|
|
all_equivs->push_back (marv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-02-18 08:59:49 -05:00
|
|
|
Editor::get_equivalent_regions (RegionView* basis, vector<RegionView*>& equivalent_regions, PBD::PropertyID property) const
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
2010-09-06 08:34:11 -04:00
|
|
|
mapover_tracks (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions), &basis->get_time_axis_view(), property);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
/* add clicked regionview since we skipped all other regions in the same track as the one it was in */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
equivalent_regions.push_back (basis);
|
|
|
|
}
|
|
|
|
|
2009-06-25 16:58:32 -04:00
|
|
|
RegionSelection
|
2010-02-18 08:59:49 -05:00
|
|
|
Editor::get_equivalent_regions (RegionSelection & basis, PBD::PropertyID prop) const
|
2009-06-25 16:58:32 -04:00
|
|
|
{
|
|
|
|
RegionSelection equivalent;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-25 16:58:32 -04:00
|
|
|
for (RegionSelection::const_iterator i = basis.begin(); i != basis.end(); ++i) {
|
|
|
|
|
|
|
|
vector<RegionView*> eq;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-25 16:58:32 -04:00
|
|
|
mapover_tracks (
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::bind (sigc::mem_fun (*this, &Editor::mapped_get_equivalent_regions), *i, &eq),
|
2010-09-06 08:34:11 -04:00
|
|
|
&(*i)->get_time_axis_view(), prop
|
2009-06-25 16:58:32 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
for (vector<RegionView*>::iterator j = eq.begin(); j != eq.end(); ++j) {
|
|
|
|
equivalent.add (*j);
|
|
|
|
}
|
|
|
|
|
|
|
|
equivalent.add (*i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return equivalent;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-25 16:58:32 -04:00
|
|
|
|
2008-09-19 10:38:46 -04:00
|
|
|
int
|
|
|
|
Editor::get_regionview_count_from_region_list (boost::shared_ptr<Region> region)
|
|
|
|
{
|
|
|
|
int region_count = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-19 10:38:46 -04:00
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* tatv;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-19 10:38:46 -04:00
|
|
|
boost::shared_ptr<Playlist> pl;
|
|
|
|
vector<boost::shared_ptr<Region> > results;
|
|
|
|
RegionView* marv;
|
2010-04-21 16:42:22 -04:00
|
|
|
boost::shared_ptr<Track> tr;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
if ((tr = tatv->track()) == 0) {
|
2008-09-19 10:38:46 -04:00
|
|
|
/* bus */
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
if ((pl = (tr->playlist())) != 0) {
|
2008-09-19 10:38:46 -04:00
|
|
|
pl->get_region_list_equivalent_regions (region, results);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-19 10:38:46 -04:00
|
|
|
for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
|
|
|
|
if ((marv = tatv->view()->find_view (*ir)) != 0) {
|
|
|
|
region_count++;
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-19 10:38:46 -04:00
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-19 10:38:46 -04:00
|
|
|
return region_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, bool /*no_track_remove*/)
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
|
|
|
vector<RegionView*> all_equivalent_regions;
|
|
|
|
bool commit = false;
|
|
|
|
|
|
|
|
if (!clicked_regionview || !clicked_routeview) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (press) {
|
|
|
|
button_release_can_deselect = false;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
if (op == Selection::Toggle || op == Selection::Set) {
|
|
|
|
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case Selection::Toggle:
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (selection->selected (clicked_regionview)) {
|
2007-01-28 12:44:13 -05:00
|
|
|
if (press) {
|
|
|
|
|
|
|
|
/* whatever was clicked was selected already; do nothing here but allow
|
|
|
|
the button release to deselect it
|
|
|
|
*/
|
|
|
|
|
|
|
|
button_release_can_deselect = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (button_release_can_deselect) {
|
|
|
|
|
|
|
|
/* just remove this one region, but only on a permitted button release */
|
|
|
|
|
|
|
|
selection->remove (clicked_regionview);
|
|
|
|
commit = true;
|
|
|
|
|
|
|
|
/* no more deselect action on button release till a new press
|
|
|
|
finds an already selected object.
|
|
|
|
*/
|
|
|
|
|
|
|
|
button_release_can_deselect = false;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (press) {
|
|
|
|
|
|
|
|
if (selection->selected (clicked_routeview)) {
|
2010-03-01 19:00:00 -05:00
|
|
|
get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::select.property_id);
|
2007-01-28 12:44:13 -05:00
|
|
|
} else {
|
|
|
|
all_equivalent_regions.push_back (clicked_regionview);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add all the equivalent regions, but only on button press */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
if (!all_equivalent_regions.empty()) {
|
|
|
|
commit = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
selection->add (all_equivalent_regions);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
case Selection::Set:
|
2008-01-10 16:20:59 -05:00
|
|
|
if (!selection->selected (clicked_regionview)) {
|
2010-03-01 19:00:00 -05:00
|
|
|
get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::select.property_id);
|
2009-06-21 15:59:56 -04:00
|
|
|
selection->set (all_equivalent_regions);
|
2007-01-28 12:44:13 -05:00
|
|
|
commit = true;
|
|
|
|
} else {
|
|
|
|
/* no commit necessary: clicked on an already selected region */
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* silly compiler */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (op == Selection::Extend) {
|
|
|
|
|
|
|
|
list<Selectable*> results;
|
2010-09-17 12:24:22 -04:00
|
|
|
framepos_t last_frame;
|
|
|
|
framepos_t first_frame;
|
2008-01-10 16:20:59 -05:00
|
|
|
bool same_track = false;
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
/* 1. find the last selected regionview in the track that was clicked in */
|
|
|
|
|
|
|
|
last_frame = 0;
|
2010-09-17 12:24:22 -04:00
|
|
|
first_frame = max_framepos;
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
|
2009-07-09 13:58:13 -04:00
|
|
|
if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) {
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
if ((*x)->region()->last_frame() > last_frame) {
|
|
|
|
last_frame = (*x)->region()->last_frame();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*x)->region()->first_frame() < first_frame) {
|
|
|
|
first_frame = (*x)->region()->first_frame();
|
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
same_track = true;
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (same_track) {
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
/* 2. figure out the boundaries for our search for new objects */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
switch (clicked_regionview->region()->coverage (first_frame, last_frame)) {
|
|
|
|
case OverlapNone:
|
|
|
|
if (last_frame < clicked_regionview->region()->first_frame()) {
|
|
|
|
first_frame = last_frame;
|
|
|
|
last_frame = clicked_regionview->region()->last_frame();
|
|
|
|
} else {
|
|
|
|
last_frame = first_frame;
|
|
|
|
first_frame = clicked_regionview->region()->first_frame();
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
case OverlapExternal:
|
|
|
|
if (last_frame < clicked_regionview->region()->first_frame()) {
|
|
|
|
first_frame = last_frame;
|
|
|
|
last_frame = clicked_regionview->region()->last_frame();
|
|
|
|
} else {
|
|
|
|
last_frame = first_frame;
|
|
|
|
first_frame = clicked_regionview->region()->first_frame();
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
case OverlapInternal:
|
|
|
|
if (last_frame < clicked_regionview->region()->first_frame()) {
|
|
|
|
first_frame = last_frame;
|
|
|
|
last_frame = clicked_regionview->region()->last_frame();
|
|
|
|
} else {
|
|
|
|
last_frame = first_frame;
|
|
|
|
first_frame = clicked_regionview->region()->first_frame();
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
case OverlapStart:
|
|
|
|
case OverlapEnd:
|
|
|
|
/* nothing to do except add clicked region to selection, since it
|
|
|
|
overlaps with the existing selection in this track.
|
|
|
|
*/
|
|
|
|
break;
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
} else {
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
/* click in a track that has no regions selected, so extend vertically
|
|
|
|
to pick out all regions that are defined by the existing selection
|
|
|
|
plus this one.
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
|
|
|
2010-09-22 08:37:48 -04:00
|
|
|
first_frame = clicked_regionview->region()->position();
|
|
|
|
last_frame = clicked_regionview->region()->last_frame();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
|
|
|
|
if ((*i)->region()->position() < first_frame) {
|
|
|
|
first_frame = (*i)->region()->position();
|
|
|
|
}
|
|
|
|
if ((*i)->region()->last_frame() + 1 > last_frame) {
|
|
|
|
last_frame = (*i)->region()->last_frame();
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 2. find all the tracks we should select in */
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
set<RouteTimeAxisView*> relevant_tracks;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2009-12-13 14:09:52 -05:00
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
RouteTimeAxisView* r = dynamic_cast<RouteTimeAxisView*> (*i);
|
|
|
|
if (r) {
|
|
|
|
relevant_tracks.insert (r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set<RouteTimeAxisView*> already_in_selection;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
if (relevant_tracks.empty()) {
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2009-12-13 14:09:52 -05:00
|
|
|
/* no tracks selected .. thus .. if the
|
|
|
|
regionview we're in isn't selected
|
|
|
|
(i.e. we're about to extend to it), then
|
|
|
|
find all tracks between the this one and
|
|
|
|
any selected ones.
|
2007-01-28 12:44:13 -05:00
|
|
|
*/
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2010-09-22 08:37:48 -04:00
|
|
|
if (!selection->selected (clicked_regionview)) {
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2010-09-22 08:37:48 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (&clicked_regionview->get_time_axis_view());
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
if (rtv) {
|
|
|
|
|
|
|
|
/* add this track to the ones we will search */
|
|
|
|
|
|
|
|
relevant_tracks.insert (rtv);
|
|
|
|
|
|
|
|
/* find the track closest to this one that
|
|
|
|
already a selected region.
|
|
|
|
*/
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* closest = 0;
|
2008-01-10 16:20:59 -05:00
|
|
|
int distance = INT_MAX;
|
|
|
|
int key = rtv->route()->order_key ("editor");
|
|
|
|
|
|
|
|
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* artv = dynamic_cast<RouteTimeAxisView*>(&(*x)->get_time_axis_view());
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
if (artv && artv != rtv) {
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
pair<set<RouteTimeAxisView*>::iterator,bool> result;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
result = already_in_selection.insert (artv);
|
|
|
|
|
|
|
|
if (result.second) {
|
|
|
|
/* newly added to already_in_selection */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
int d = artv->route()->order_key ("editor");
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
d -= key;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (abs (d) < distance) {
|
|
|
|
distance = abs (d);
|
|
|
|
closest = artv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (closest) {
|
|
|
|
|
|
|
|
/* now add all tracks between that one and this one */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
int okey = closest->route()->order_key ("editor");
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (okey > key) {
|
|
|
|
swap (okey, key);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
for (TrackViewList::iterator x = track_views.begin(); x != track_views.end(); ++x) {
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* artv = dynamic_cast<RouteTimeAxisView*>(*x);
|
2008-01-10 16:20:59 -05:00
|
|
|
if (artv && artv != rtv) {
|
|
|
|
|
|
|
|
int k = artv->route()->order_key ("editor");
|
|
|
|
|
|
|
|
if (k >= okey && k <= key) {
|
|
|
|
|
|
|
|
/* in range but don't add it if
|
|
|
|
it already has tracks selected.
|
|
|
|
this avoids odd selection
|
|
|
|
behaviour that feels wrong.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (find (already_in_selection.begin(),
|
|
|
|
already_in_selection.end(),
|
|
|
|
artv) == already_in_selection.end()) {
|
|
|
|
|
|
|
|
relevant_tracks.insert (artv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
/* 3. find all selectable objects (regionviews in this case) between that one and the end of the
|
|
|
|
one that was clicked.
|
2007-01-28 12:44:13 -05:00
|
|
|
*/
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
for (set<RouteTimeAxisView*>::iterator t = relevant_tracks.begin(); t != relevant_tracks.end(); ++t) {
|
2007-01-28 12:44:13 -05:00
|
|
|
(*t)->get_selectables (first_frame, last_frame, -1.0, -1.0, results);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
/* 4. convert to a vector of regions */
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
vector<RegionView*> regions;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
for (list<Selectable*>::iterator x = results.begin(); x != results.end(); ++x) {
|
|
|
|
RegionView* arv;
|
|
|
|
|
|
|
|
if ((arv = dynamic_cast<RegionView*>(*x)) != 0) {
|
|
|
|
regions.push_back (arv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!regions.empty()) {
|
|
|
|
selection->add (regions);
|
|
|
|
commit = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return commit;
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
void
|
|
|
|
Editor::set_selected_regionview_from_region_list (boost::shared_ptr<Region> region, Selection::Operation op)
|
|
|
|
{
|
|
|
|
vector<RegionView*> all_equivalent_regions;
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
get_regions_corresponding_to (region, all_equivalent_regions);
|
|
|
|
|
|
|
|
if (all_equivalent_regions.empty()) {
|
|
|
|
return;
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
begin_reversible_command (_("set selected regions"));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
switch (op) {
|
|
|
|
case Selection::Toggle:
|
|
|
|
/* XXX this is not correct */
|
|
|
|
selection->toggle (all_equivalent_regions);
|
|
|
|
break;
|
|
|
|
case Selection::Set:
|
|
|
|
selection->set (all_equivalent_regions);
|
|
|
|
break;
|
|
|
|
case Selection::Extend:
|
|
|
|
selection->add (all_equivalent_regions);
|
|
|
|
break;
|
|
|
|
case Selection::Add:
|
|
|
|
selection->add (all_equivalent_regions);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_reversible_command () ;
|
|
|
|
}
|
|
|
|
|
2008-01-12 18:45:50 -05:00
|
|
|
bool
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::set_selected_regionview_from_map_event (GdkEventAny* /*ev*/, StreamView* sv, boost::weak_ptr<Region> weak_r)
|
2008-01-12 18:45:50 -05:00
|
|
|
{
|
|
|
|
RegionView* rv;
|
|
|
|
boost::shared_ptr<Region> r (weak_r.lock());
|
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((rv = sv->find_view (r)) == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
/* don't reset the selection if its something other than
|
2008-01-12 18:45:50 -05:00
|
|
|
a single other region.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (selection->regions.size() > 1) {
|
|
|
|
return true;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-12 18:45:50 -05:00
|
|
|
begin_reversible_command (_("set selected regions"));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-12 18:45:50 -05:00
|
|
|
selection->set (rv);
|
|
|
|
|
|
|
|
commit_reversible_command () ;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
void
|
|
|
|
Editor::track_selection_changed ()
|
|
|
|
{
|
2010-08-09 13:28:25 -04:00
|
|
|
switch (selection->tracks.size()) {
|
2007-01-28 12:44:13 -05:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
default:
|
2009-07-09 13:58:13 -04:00
|
|
|
set_selected_mixer_strip (*(selection->tracks.front()));
|
2007-01-28 12:44:13 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
2010-08-26 19:25:44 -04:00
|
|
|
|
|
|
|
bool yn = (find (selection->tracks.begin(), selection->tracks.end(), *i) != selection->tracks.end());
|
|
|
|
|
|
|
|
(*i)->set_selected (yn);
|
2010-08-20 17:34:18 -04:00
|
|
|
|
|
|
|
TimeAxisView::Children c = (*i)->get_child_list ();
|
|
|
|
for (TimeAxisView::Children::iterator j = c.begin(); j != c.end(); ++j) {
|
|
|
|
(*j)->set_selected (find (selection->tracks.begin(), selection->tracks.end(), j->get()) != selection->tracks.end());
|
|
|
|
}
|
2010-08-26 19:25:44 -04:00
|
|
|
|
2010-08-30 14:59:02 -04:00
|
|
|
if (yn &&
|
|
|
|
((mouse_mode == MouseRange) ||
|
|
|
|
((mouse_mode == MouseObject) && (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT)))) {
|
2010-08-26 19:25:44 -04:00
|
|
|
(*i)->reshow_selection (selection->time);
|
|
|
|
} else {
|
|
|
|
(*i)->hide_selection ();
|
|
|
|
}
|
2010-08-20 17:34:18 -04:00
|
|
|
}
|
2008-03-17 16:54:03 -04:00
|
|
|
|
|
|
|
ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, !selection->tracks.empty());
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::time_selection_changed ()
|
|
|
|
{
|
2008-03-17 16:54:03 -04:00
|
|
|
if (Profile->get_sae()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
(*i)->hide_selection ();
|
|
|
|
}
|
|
|
|
|
2009-12-13 16:27:19 -05:00
|
|
|
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
|
|
|
(*i)->show_selection (selection->time);
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (selection->time.empty()) {
|
|
|
|
ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
|
|
|
|
} else {
|
|
|
|
ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-03-17 16:54:03 -04:00
|
|
|
Editor::sensitize_the_right_region_actions (bool have_selected_regions)
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
2008-02-19 17:10:27 -05:00
|
|
|
for (vector<Glib::RefPtr<Action> >::iterator x = ActionManager::region_selection_sensitive_actions.begin();
|
|
|
|
x != ActionManager::region_selection_sensitive_actions.end(); ++x) {
|
|
|
|
|
|
|
|
string accel_path = (*x)->get_accel_path ();
|
|
|
|
AccelKey key;
|
|
|
|
|
|
|
|
/* if there is an accelerator, it should always be sensitive
|
|
|
|
to allow for keyboard ops on entered regions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool known = ActionManager::lookup_entry (accel_path, key);
|
|
|
|
|
|
|
|
if (known && ((key.get_key() != GDK_VoidSymbol) && (key.get_key() != 0))) {
|
|
|
|
(*x)->set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
(*x)->set_sensitive (have_selected_regions);
|
|
|
|
}
|
|
|
|
}
|
2008-03-17 16:54:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::region_selection_changed ()
|
|
|
|
{
|
2009-07-03 18:42:22 -04:00
|
|
|
_regions->block_change_connection (true);
|
2009-01-18 05:41:56 -05:00
|
|
|
editor_regions_selection_changed_connection.block(true);
|
2009-07-03 18:42:22 -04:00
|
|
|
|
2010-09-18 19:31:39 -04:00
|
|
|
if (!_block_region_list_update_if_empty || !selection->regions.empty()) {
|
|
|
|
_regions->unselect_all ();
|
|
|
|
}
|
2010-01-25 15:34:09 -05:00
|
|
|
|
2008-03-17 16:54:03 -04:00
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
(*i)->set_selected_regionviews (selection->regions);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-01-17 18:11:22 -05:00
|
|
|
_regions->set_selected (selection->regions);
|
|
|
|
|
2008-03-17 16:54:03 -04:00
|
|
|
sensitize_the_right_region_actions (!selection->regions.empty());
|
2008-02-19 17:10:27 -05:00
|
|
|
|
2009-07-03 18:42:22 -04:00
|
|
|
_regions->block_change_connection (false);
|
2009-01-18 05:41:56 -05:00
|
|
|
editor_regions_selection_changed_connection.block(false);
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::point_selection_changed ()
|
|
|
|
{
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
(*i)->set_selected_points (selection->points);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-01-12 18:45:50 -05:00
|
|
|
Editor::select_all_in_track (Selection::Operation op)
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
|
|
|
list<Selectable *> touched;
|
|
|
|
|
2008-01-12 18:45:50 -05:00
|
|
|
if (!clicked_routeview) {
|
|
|
|
return;
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-17 12:24:22 -04:00
|
|
|
clicked_routeview->get_selectables (0, max_framepos, 0, DBL_MAX, touched);
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case Selection::Toggle:
|
|
|
|
selection->add (touched);
|
|
|
|
break;
|
|
|
|
case Selection::Set:
|
|
|
|
selection->set (touched);
|
|
|
|
break;
|
|
|
|
case Selection::Extend:
|
|
|
|
/* meaningless, because we're selecting everything */
|
|
|
|
break;
|
|
|
|
case Selection::Add:
|
|
|
|
selection->add (touched);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::select_all (Selection::Operation op)
|
|
|
|
{
|
|
|
|
list<Selectable *> touched;
|
2008-01-10 17:22:29 -05:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
|
|
|
|
if ((*iter)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-09-17 12:24:22 -04:00
|
|
|
(*iter)->get_selectables (0, max_framepos, 0, DBL_MAX, touched);
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
begin_reversible_command (_("select all"));
|
|
|
|
switch (op) {
|
|
|
|
case Selection::Add:
|
|
|
|
selection->add (touched);
|
|
|
|
break;
|
|
|
|
case Selection::Toggle:
|
|
|
|
selection->add (touched);
|
|
|
|
break;
|
|
|
|
case Selection::Set:
|
|
|
|
selection->set (touched);
|
|
|
|
break;
|
|
|
|
case Selection::Extend:
|
|
|
|
/* meaningless, because we're selecting everything */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
void
|
2008-01-12 18:45:50 -05:00
|
|
|
Editor::invert_selection_in_track ()
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
|
|
|
list<Selectable *> touched;
|
|
|
|
|
2008-01-12 18:45:50 -05:00
|
|
|
if (!clicked_routeview) {
|
|
|
|
return;
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-12 18:45:50 -05:00
|
|
|
clicked_routeview->get_inverted_selectables (*selection, touched);
|
2007-01-28 12:44:13 -05:00
|
|
|
selection->set (touched);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::invert_selection ()
|
|
|
|
{
|
|
|
|
list<Selectable *> touched;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
|
|
|
|
if ((*iter)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
(*iter)->get_inverted_selectables (*selection, touched);
|
|
|
|
}
|
|
|
|
|
|
|
|
selection->set (touched);
|
|
|
|
}
|
|
|
|
|
2010-08-05 09:36:38 -04:00
|
|
|
/** @param start Start time in session frames.
|
|
|
|
* @param end End time in session frames.
|
2010-08-06 19:28:44 -04:00
|
|
|
* @param top Top (lower) y limit in trackview coordinates (ie 0 at the top of the track view)
|
|
|
|
* @param bottom Bottom (higher) y limit in trackview coordinates (ie 0 at the top of the track view)
|
2010-08-10 06:38:48 -04:00
|
|
|
* @param preserve_if_selected true to leave the current selection alone if we're adding to the selection and all of the selectables
|
|
|
|
* within the region are already selected.
|
2010-01-03 07:04:29 -05:00
|
|
|
*/
|
2010-01-04 22:15:28 -05:00
|
|
|
bool
|
2010-08-09 21:52:49 -04:00
|
|
|
Editor::select_all_within (
|
|
|
|
framepos_t start, framepos_t end, double top, double bot, const TrackViewList& tracklist, Selection::Operation op, bool preserve_if_selected
|
|
|
|
)
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
2010-01-04 21:22:58 -05:00
|
|
|
list<Selectable*> found;
|
2007-01-28 12:44:13 -05:00
|
|
|
|
2007-04-19 14:23:23 -04:00
|
|
|
for (TrackViewList::const_iterator iter = tracklist.begin(); iter != tracklist.end(); ++iter) {
|
2010-01-04 21:22:58 -05:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
if ((*iter)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-01-04 21:22:58 -05:00
|
|
|
(*iter)->get_selectables (start, end, top, bot, found);
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
2010-08-04 11:41:55 -04:00
|
|
|
|
2010-01-04 22:15:28 -05:00
|
|
|
if (found.empty()) {
|
2007-04-12 19:20:37 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-08-10 06:38:48 -04:00
|
|
|
if (preserve_if_selected && op != Selection::Toggle) {
|
2010-08-09 21:52:49 -04:00
|
|
|
list<Selectable*>::iterator i = found.begin();
|
|
|
|
while (i != found.end() && (*i)->get_selected()) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == found.end()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
begin_reversible_command (_("select all within"));
|
|
|
|
switch (op) {
|
|
|
|
case Selection::Add:
|
2010-01-04 22:15:28 -05:00
|
|
|
selection->add (found);
|
2007-01-28 12:44:13 -05:00
|
|
|
break;
|
|
|
|
case Selection::Toggle:
|
2010-01-04 22:15:28 -05:00
|
|
|
selection->toggle (found);
|
2007-01-28 12:44:13 -05:00
|
|
|
break;
|
|
|
|
case Selection::Set:
|
2010-01-04 22:15:28 -05:00
|
|
|
selection->set (found);
|
2007-01-28 12:44:13 -05:00
|
|
|
break;
|
|
|
|
case Selection::Extend:
|
|
|
|
/* not defined yet */
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
commit_reversible_command ();
|
2007-04-12 19:20:37 -04:00
|
|
|
|
2010-01-04 22:15:28 -05:00
|
|
|
return !found.empty();
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-01-12 18:45:50 -05:00
|
|
|
Editor::set_selection_from_region ()
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
|
|
|
if (selection->regions.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-13 16:27:19 -05:00
|
|
|
selection->set (selection->regions.start(), selection->regions.end_frame());
|
2008-03-17 16:54:03 -04:00
|
|
|
if (!Profile->get_sae()) {
|
|
|
|
set_mouse_mode (Editing::MouseRange, false);
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_selection_from_punch()
|
|
|
|
{
|
|
|
|
Location* location;
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if ((location = _session->locations()->auto_punch_location()) == 0) {
|
2007-01-28 12:44:13 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_selection_from_range (*location);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_selection_from_loop()
|
|
|
|
{
|
|
|
|
Location* location;
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
if ((location = _session->locations()->auto_loop_location()) == 0) {
|
2007-01-28 12:44:13 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
set_selection_from_range (*location);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_selection_from_range (Location& loc)
|
|
|
|
{
|
|
|
|
begin_reversible_command (_("set selection from range"));
|
2009-12-13 16:27:19 -05:00
|
|
|
selection->set (loc.start(), loc.end());
|
2007-01-28 12:44:13 -05:00
|
|
|
commit_reversible_command ();
|
|
|
|
|
2008-03-17 16:54:03 -04:00
|
|
|
if (!Profile->get_sae()) {
|
|
|
|
set_mouse_mode (Editing::MouseRange, false);
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::select_all_selectables_using_time_selection ()
|
|
|
|
{
|
|
|
|
list<Selectable *> touched;
|
|
|
|
|
|
|
|
if (selection->time.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t start = selection->time[clicked_selection].start;
|
|
|
|
framepos_t end = selection->time[clicked_selection].end;
|
2007-01-28 12:44:13 -05:00
|
|
|
|
|
|
|
if (end - start < 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-13 14:09:52 -05:00
|
|
|
TrackViewList* ts;
|
2008-01-10 17:22:29 -05:00
|
|
|
|
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
ts = &track_views;
|
|
|
|
} else {
|
|
|
|
ts = &selection->tracks;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (TrackViewList::iterator iter = ts->begin(); iter != ts->end(); ++iter) {
|
2007-01-28 12:44:13 -05:00
|
|
|
if ((*iter)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
(*iter)->get_selectables (start, end - 1, 0, DBL_MAX, touched);
|
|
|
|
}
|
|
|
|
|
|
|
|
begin_reversible_command (_("select all from range"));
|
|
|
|
selection->set (touched);
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::select_all_selectables_using_punch()
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
Location* location = _session->locations()->auto_punch_location();
|
2007-01-28 12:44:13 -05:00
|
|
|
list<Selectable *> touched;
|
|
|
|
|
|
|
|
if (location == 0 || (location->end() - location->start() <= 1)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-10 17:22:29 -05:00
|
|
|
|
2009-12-13 14:09:52 -05:00
|
|
|
TrackViewList* ts;
|
2008-01-10 17:22:29 -05:00
|
|
|
|
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
ts = &track_views;
|
|
|
|
} else {
|
|
|
|
ts = &selection->tracks;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (TrackViewList::iterator iter = ts->begin(); iter != ts->end(); ++iter) {
|
2007-01-28 12:44:13 -05:00
|
|
|
if ((*iter)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
(*iter)->get_selectables (location->start(), location->end() - 1, 0, DBL_MAX, touched);
|
|
|
|
}
|
|
|
|
begin_reversible_command (_("select all from punch"));
|
|
|
|
selection->set (touched);
|
|
|
|
commit_reversible_command ();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::select_all_selectables_using_loop()
|
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
Location* location = _session->locations()->auto_loop_location();
|
2007-01-28 12:44:13 -05:00
|
|
|
list<Selectable *> touched;
|
|
|
|
|
|
|
|
if (location == 0 || (location->end() - location->start() <= 1)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-10 17:22:29 -05:00
|
|
|
|
2009-12-13 14:09:52 -05:00
|
|
|
TrackViewList* ts;
|
2008-01-10 17:22:29 -05:00
|
|
|
|
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
ts = &track_views;
|
|
|
|
} else {
|
|
|
|
ts = &selection->tracks;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (TrackViewList::iterator iter = ts->begin(); iter != ts->end(); ++iter) {
|
2007-01-28 12:44:13 -05:00
|
|
|
if ((*iter)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
(*iter)->get_selectables (location->start(), location->end() - 1, 0, DBL_MAX, touched);
|
|
|
|
}
|
|
|
|
begin_reversible_command (_("select all from loop"));
|
|
|
|
selection->set (touched);
|
|
|
|
commit_reversible_command ();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-05-30 14:25:59 -04:00
|
|
|
Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after)
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t start;
|
|
|
|
framepos_t end;
|
2007-01-28 12:44:13 -05:00
|
|
|
list<Selectable *> touched;
|
|
|
|
|
|
|
|
if (after) {
|
|
|
|
begin_reversible_command (_("select all after cursor"));
|
|
|
|
start = cursor->current_frame ;
|
2009-12-17 13:24:23 -05:00
|
|
|
end = _session->current_end_frame();
|
2007-01-28 12:44:13 -05:00
|
|
|
} else {
|
|
|
|
if (cursor->current_frame > 0) {
|
|
|
|
begin_reversible_command (_("select all before cursor"));
|
|
|
|
start = 0;
|
|
|
|
end = cursor->current_frame - 1;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-10 17:22:29 -05:00
|
|
|
|
2009-12-13 14:09:52 -05:00
|
|
|
TrackViewList* ts;
|
2008-01-10 17:22:29 -05:00
|
|
|
|
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
ts = &track_views;
|
|
|
|
} else {
|
|
|
|
ts = &selection->tracks;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (TrackViewList::iterator iter = ts->begin(); iter != ts->end(); ++iter) {
|
2007-01-28 12:44:13 -05:00
|
|
|
if ((*iter)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
(*iter)->get_selectables (start, end, 0, DBL_MAX, touched);
|
|
|
|
}
|
|
|
|
selection->set (touched);
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-11-12 17:23:01 -05:00
|
|
|
Editor::select_all_selectables_using_edit (bool after)
|
2007-01-28 12:44:13 -05:00
|
|
|
{
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t start;
|
|
|
|
framepos_t end;
|
2007-01-28 12:44:13 -05:00
|
|
|
list<Selectable *> touched;
|
|
|
|
|
2007-11-12 17:23:01 -05:00
|
|
|
if (after) {
|
|
|
|
begin_reversible_command (_("select all after edit"));
|
|
|
|
start = get_preferred_edit_position();
|
2009-12-17 13:24:23 -05:00
|
|
|
end = _session->current_end_frame();
|
2007-11-12 17:23:01 -05:00
|
|
|
} else {
|
|
|
|
if ((end = get_preferred_edit_position()) > 1) {
|
|
|
|
begin_reversible_command (_("select all before edit"));
|
|
|
|
start = 0;
|
|
|
|
end -= 1;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
|
|
|
|
2008-01-10 17:22:29 -05:00
|
|
|
|
2009-12-13 14:09:52 -05:00
|
|
|
TrackViewList* ts;
|
2008-01-10 17:22:29 -05:00
|
|
|
|
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
ts = &track_views;
|
|
|
|
} else {
|
|
|
|
ts = &selection->tracks;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (TrackViewList::iterator iter = ts->begin(); iter != ts->end(); ++iter) {
|
2007-11-12 17:23:01 -05:00
|
|
|
if ((*iter)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
(*iter)->get_selectables (start, end, 0, DBL_MAX, touched);
|
|
|
|
}
|
|
|
|
selection->set (touched);
|
|
|
|
commit_reversible_command ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
Editor::select_all_selectables_between (bool /*within*/)
|
2007-11-12 17:23:01 -05:00
|
|
|
{
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t start;
|
|
|
|
framepos_t end;
|
2007-11-12 17:23:01 -05:00
|
|
|
list<Selectable *> touched;
|
|
|
|
|
|
|
|
if (!get_edit_op_range (start, end)) {
|
|
|
|
return;
|
2007-01-28 12:44:13 -05:00
|
|
|
}
|
2008-01-10 17:22:29 -05:00
|
|
|
|
2009-12-13 14:09:52 -05:00
|
|
|
TrackViewList* ts;
|
2008-01-10 17:22:29 -05:00
|
|
|
|
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
ts = &track_views;
|
|
|
|
} else {
|
|
|
|
ts = &selection->tracks;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (TrackViewList::iterator iter = ts->begin(); iter != ts->end(); ++iter) {
|
2007-01-28 12:44:13 -05:00
|
|
|
if ((*iter)->hidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
(*iter)->get_selectables (start, end, 0, DBL_MAX, touched);
|
|
|
|
}
|
2007-11-12 17:23:01 -05:00
|
|
|
|
2007-01-28 12:44:13 -05:00
|
|
|
selection->set (touched);
|
|
|
|
}
|
|
|
|
|
2007-11-12 17:23:01 -05:00
|
|
|
void
|
|
|
|
Editor::select_range_between ()
|
|
|
|
{
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t start;
|
|
|
|
framepos_t end;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-08-20 09:24:38 -04:00
|
|
|
if (mouse_mode == MouseRange && !selection->time.empty()) {
|
|
|
|
selection->clear_time ();
|
|
|
|
}
|
|
|
|
|
2007-11-12 17:23:01 -05:00
|
|
|
if (!get_edit_op_range (start, end)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_mouse_mode (MouseRange);
|
2009-12-13 16:27:19 -05:00
|
|
|
selection->set (start, end);
|
2007-11-12 17:23:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-09-17 14:20:37 -04:00
|
|
|
Editor::get_edit_op_range (framepos_t& start, framepos_t& end) const
|
2007-11-12 17:23:01 -05:00
|
|
|
{
|
2010-09-17 14:20:37 -04:00
|
|
|
framepos_t m;
|
2007-11-12 17:23:01 -05:00
|
|
|
bool ignored;
|
|
|
|
|
|
|
|
/* in range mode, use any existing selection */
|
|
|
|
|
|
|
|
if (mouse_mode == MouseRange && !selection->time.empty()) {
|
|
|
|
/* we know that these are ordered */
|
|
|
|
start = selection->time.start();
|
|
|
|
end = selection->time.end_frame();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mouse_frame (m, ignored)) {
|
|
|
|
/* mouse is not in a canvas, try playhead+selected marker.
|
|
|
|
this is probably most true when using menus.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (selection->markers.empty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
start = selection->markers.front()->position();
|
2009-12-17 13:24:23 -05:00
|
|
|
end = _session->audible_frame();
|
2007-11-12 17:23:01 -05:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
switch (_edit_point) {
|
|
|
|
case EditAtPlayhead:
|
|
|
|
if (selection->markers.empty()) {
|
|
|
|
/* use mouse + playhead */
|
|
|
|
start = m;
|
2009-12-17 13:24:23 -05:00
|
|
|
end = _session->audible_frame();
|
2007-11-12 17:23:01 -05:00
|
|
|
} else {
|
|
|
|
/* use playhead + selected marker */
|
2009-12-17 13:24:23 -05:00
|
|
|
start = _session->audible_frame();
|
2007-11-12 17:23:01 -05:00
|
|
|
end = selection->markers.front()->position();
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-11-12 17:23:01 -05:00
|
|
|
case EditAtMouse:
|
2008-01-10 16:20:59 -05:00
|
|
|
/* use mouse + selected marker */
|
|
|
|
if (selection->markers.empty()) {
|
|
|
|
start = m;
|
2009-12-17 13:24:23 -05:00
|
|
|
end = _session->audible_frame();
|
2008-01-10 16:20:59 -05:00
|
|
|
} else {
|
|
|
|
start = selection->markers.front()->position();
|
|
|
|
end = m;
|
|
|
|
}
|
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-11-12 17:23:01 -05:00
|
|
|
case EditAtSelectedMarker:
|
|
|
|
/* use mouse + selected marker */
|
|
|
|
if (selection->markers.empty()) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
MessageDialog win (_("No edit range defined"),
|
|
|
|
false,
|
|
|
|
MESSAGE_INFO,
|
|
|
|
BUTTONS_OK);
|
|
|
|
|
|
|
|
win.set_secondary_text (
|
|
|
|
_("the edit point is Selected Marker\nbut there is no selected marker."));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
win.set_default_response (RESPONSE_CLOSE);
|
|
|
|
win.set_position (Gtk::WIN_POS_MOUSE);
|
|
|
|
win.show_all();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
win.run ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
return false; // NO RANGE
|
2007-11-12 17:23:01 -05:00
|
|
|
}
|
|
|
|
start = selection->markers.front()->position();
|
|
|
|
end = m;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start == end) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start > end) {
|
|
|
|
swap (start, end);
|
|
|
|
}
|
|
|
|
|
2008-03-17 16:54:03 -04:00
|
|
|
/* turn range into one delimited by start...end,
|
|
|
|
not start...end-1
|
|
|
|
*/
|
|
|
|
|
|
|
|
end++;
|
|
|
|
|
2007-11-12 17:23:01 -05:00
|
|
|
return true;
|
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::deselect_all ()
|
|
|
|
{
|
|
|
|
selection->clear ();
|
|
|
|
}
|
2008-01-10 17:22:29 -05:00
|
|
|
|
2010-01-12 11:14:49 -05:00
|
|
|
long
|
2010-01-01 17:11:15 -05:00
|
|
|
Editor::select_range_around_region (RegionView* rv)
|
|
|
|
{
|
2010-01-12 18:50:57 -05:00
|
|
|
assert (rv);
|
|
|
|
|
2010-01-01 17:11:15 -05:00
|
|
|
selection->set (&rv->get_time_axis_view());
|
|
|
|
|
|
|
|
selection->time.clear ();
|
|
|
|
boost::shared_ptr<Region> r = rv->region ();
|
2010-01-12 11:14:49 -05:00
|
|
|
return selection->set (r->position(), r->position() + r->length());
|
2010-01-01 17:11:15 -05:00
|
|
|
}
|