2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000 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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
#include <list>
|
|
|
|
#include <vector>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <algorithm>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
2006-07-23 08:03:19 -04:00
|
|
|
#include <cassert>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "editor.h"
|
2007-03-18 02:07:08 -04:00
|
|
|
#include "keyboard.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "audio_time_axis.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "midi_time_axis.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "mixer_strip.h"
|
|
|
|
#include "gui_thread.h"
|
2007-03-18 02:07:08 -04:00
|
|
|
#include "actions.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-24 03:37:17 -04:00
|
|
|
#include <pbd/unknown_type.h>
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/route.h>
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace ARDOUR;
|
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one)
Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now.
Relevant (significant) changes:
- Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)
- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)
- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output.
- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.
- MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here.
- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)
Known broken: Loading of sessions containing MIDI tracks.
git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
2008-01-10 16:20:59 -05:00
|
|
|
using namespace Glib;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
const char* _order_key = N_("editor");
|
2006-07-27 21:08:57 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2006-08-24 03:37:17 -04:00
|
|
|
Editor::handle_new_route (Session::RouteList& routes)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-24 03:37:17 -04:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::handle_new_route), routes));
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
TimeAxisView *tv;
|
2006-08-24 03:37:17 -04:00
|
|
|
RouteTimeAxisView *rtv;
|
2006-01-09 23:25:47 -05:00
|
|
|
TreeModel::Row parent;
|
|
|
|
TreeModel::Row row;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
route_redisplay_does_not_sync_order_keys = true;
|
2007-10-11 18:07:47 -04:00
|
|
|
no_route_list_redisplay = true;
|
|
|
|
|
2006-08-24 03:37:17 -04:00
|
|
|
for (Session::RouteList::iterator x = routes.begin(); x != routes.end(); ++x) {
|
|
|
|
boost::shared_ptr<Route> route = (*x);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-06-29 00:02:58 -04:00
|
|
|
if (route->is_hidden()) {
|
2007-03-18 02:07:08 -04:00
|
|
|
continue;
|
2006-08-24 03:37:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (route->default_type() == ARDOUR::DataType::AUDIO)
|
2008-03-17 16:54:03 -04:00
|
|
|
tv = new AudioTimeAxisView (*this, *session, route, *track_canvas);
|
2006-08-24 03:37:17 -04:00
|
|
|
else if (route->default_type() == ARDOUR::DataType::MIDI)
|
2008-03-17 16:54:03 -04:00
|
|
|
tv = new MidiTimeAxisView (*this, *session, route, *track_canvas);
|
2006-08-24 03:37:17 -04:00
|
|
|
else
|
|
|
|
throw unknown_type();
|
2008-03-17 16:54:03 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
//cerr << "Editor::handle_new_route() called on " << route->name() << endl;//DEBUG
|
2006-01-09 23:25:47 -05:00
|
|
|
#if 0
|
2006-08-24 03:37:17 -04:00
|
|
|
if (route_display_model->children().size() == 0) {
|
|
|
|
|
|
|
|
/* set up basic entries */
|
|
|
|
|
|
|
|
TreeModel::Row row;
|
|
|
|
|
|
|
|
row = *(route_display_model->append()); // path = "0"
|
|
|
|
row[route_display_columns.text] = _("Busses");
|
|
|
|
row[route_display_columns.tv] = 0;
|
|
|
|
row = *(route_display_model->append()); // path = "1"
|
|
|
|
row[route_display_columns.text] = _("Tracks");
|
|
|
|
row[route_display_columns.tv] = 0;
|
|
|
|
|
|
|
|
}
|
2006-01-09 23:25:47 -05:00
|
|
|
|
2006-08-24 03:37:17 -04:00
|
|
|
if (dynamic_cast<AudioTrack*>(route.get()) != 0) {
|
|
|
|
TreeModel::iterator iter = route_display_model->get_iter ("1"); // audio tracks
|
|
|
|
parent = *iter;
|
|
|
|
} else {
|
|
|
|
TreeModel::iterator iter = route_display_model->get_iter ("0"); // busses
|
|
|
|
parent = *iter;
|
|
|
|
}
|
2006-01-09 23:25:47 -05:00
|
|
|
|
2006-08-24 03:37:17 -04:00
|
|
|
|
|
|
|
row = *(route_display_model->append (parent.children()));
|
2006-01-09 23:25:47 -05:00
|
|
|
#else
|
2006-08-24 03:37:17 -04:00
|
|
|
row = *(route_display_model->append ());
|
2006-01-09 23:25:47 -05:00
|
|
|
#endif
|
2008-09-12 05:01:52 -04:00
|
|
|
|
2008-09-30 10:18:15 -04:00
|
|
|
// cerr << route->name() << " marked for display ? " << tv->marked_for_display() << endl;
|
2006-08-24 03:37:17 -04:00
|
|
|
|
|
|
|
row[route_display_columns.text] = route->name();
|
|
|
|
row[route_display_columns.visible] = tv->marked_for_display();
|
|
|
|
row[route_display_columns.tv] = tv;
|
2007-10-11 18:07:47 -04:00
|
|
|
row[route_display_columns.route] = route;
|
2008-09-12 05:01:52 -04:00
|
|
|
|
2006-08-24 03:37:17 -04:00
|
|
|
track_views.push_back (tv);
|
|
|
|
|
|
|
|
ignore_route_list_reorder = true;
|
|
|
|
|
|
|
|
if ((rtv = dynamic_cast<RouteTimeAxisView*> (tv)) != 0) {
|
|
|
|
/* added a new fresh one at the end */
|
2008-12-08 13:16:12 -05:00
|
|
|
if (rtv->route()->order_key(_order_key) == -1) {
|
|
|
|
rtv->route()->set_order_key (_order_key, route_display_model->children().size()-1);
|
2006-08-24 03:37:17 -04:00
|
|
|
}
|
2008-02-16 17:43:18 -05:00
|
|
|
rtv->effective_gain_display ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-08-24 03:37:17 -04:00
|
|
|
|
|
|
|
ignore_route_list_reorder = false;
|
2007-11-06 07:53:04 -05:00
|
|
|
|
2006-08-24 03:37:17 -04:00
|
|
|
route->gui_changed.connect (mem_fun(*this, &Editor::handle_gui_changes));
|
|
|
|
|
|
|
|
tv->GoingAway.connect (bind (mem_fun(*this, &Editor::remove_route), tv));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-10-11 18:07:47 -04:00
|
|
|
no_route_list_redisplay = false;
|
|
|
|
|
|
|
|
redisplay_route_list ();
|
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
if (show_editor_mixer_when_tracks_arrive) {
|
|
|
|
show_editor_mixer (true);
|
|
|
|
}
|
2008-12-08 13:16:12 -05:00
|
|
|
|
2007-06-15 03:39:20 -04:00
|
|
|
editor_list_button.set_sensitive(true);
|
2008-12-08 13:16:12 -05:00
|
|
|
route_redisplay_does_not_sync_order_keys = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-12-22 07:23:54 -05:00
|
|
|
Editor::handle_gui_changes (const string & what, void *src)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::handle_gui_changes), what, src));
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (what == "track_height") {
|
2008-09-17 15:04:16 -04:00
|
|
|
/* Optional :make tracks change height while it happens, instead
|
2008-09-10 11:03:30 -04:00
|
|
|
of on first-idle
|
|
|
|
*/
|
2008-09-17 15:04:16 -04:00
|
|
|
//track_canvas->update_now ();
|
2006-01-04 22:18:44 -05:00
|
|
|
redisplay_route_list ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
if (what == "visible_tracks") {
|
|
|
|
redisplay_route_list ();
|
|
|
|
}
|
|
|
|
}
|
2005-10-26 14:12:00 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::remove_route (TimeAxisView *tv)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::remove_route), tv));
|
2005-10-26 14:12:00 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
TrackViewList::iterator i;
|
2005-10-26 14:12:00 -04:00
|
|
|
TreeModel::Children rows = route_display_model->children();
|
|
|
|
TreeModel::Children::iterator ri;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
if (tv == entered_track) {
|
|
|
|
entered_track = 0;
|
|
|
|
}
|
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
/* the core model has changed, there is no need to sync
|
|
|
|
view orders.
|
|
|
|
*/
|
|
|
|
|
|
|
|
route_redisplay_does_not_sync_order_keys = true;
|
2007-11-06 07:53:04 -05:00
|
|
|
|
2005-10-26 14:12:00 -04:00
|
|
|
for (ri = rows.begin(); ri != rows.end(); ++ri) {
|
|
|
|
if ((*ri)[route_display_columns.tv] == tv) {
|
|
|
|
route_display_model->erase (ri);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
route_redisplay_does_not_sync_order_keys = false;
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if ((i = find (track_views.begin(), track_views.end(), tv)) != track_views.end()) {
|
|
|
|
track_views.erase (i);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* since the editor mixer goes away when you remove a route, set the
|
|
|
|
* button to inactive and untick the menu option
|
|
|
|
*/
|
|
|
|
|
|
|
|
ActionManager::uncheck_toggleaction ("<Actions>/Editor/show-editor-mixer");
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::route_name_changed (TimeAxisView *tv)
|
|
|
|
{
|
2005-10-26 14:12:00 -04:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::route_name_changed), tv));
|
|
|
|
|
|
|
|
TreeModel::Children rows = route_display_model->children();
|
|
|
|
TreeModel::Children::iterator i;
|
|
|
|
|
|
|
|
for (i = rows.begin(); i != rows.end(); ++i) {
|
|
|
|
if ((*i)[route_display_columns.tv] == tv) {
|
|
|
|
(*i)[route_display_columns.text] = tv->name();
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
2005-10-26 14:12:00 -04:00
|
|
|
}
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::update_route_visibility ()
|
|
|
|
{
|
|
|
|
TreeModel::Children rows = route_display_model->children();
|
|
|
|
TreeModel::Children::iterator i;
|
|
|
|
|
|
|
|
no_route_list_redisplay = true;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
for (i = rows.begin(); i != rows.end(); ++i) {
|
|
|
|
TimeAxisView *tv = (*i)[route_display_columns.tv];
|
|
|
|
(*i)[route_display_columns.visible] = tv->marked_for_display ();
|
2008-09-12 05:01:52 -04:00
|
|
|
cerr << "marked " << tv->name() << " for display = " << tv->marked_for_display() << endl;
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
no_route_list_redisplay = false;
|
|
|
|
redisplay_route_list ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-10 11:03:30 -04:00
|
|
|
Editor::hide_track_in_display (TimeAxisView& tv, bool temponly)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-26 14:12:00 -04:00
|
|
|
TreeModel::Children rows = route_display_model->children();
|
|
|
|
TreeModel::Children::iterator i;
|
|
|
|
|
|
|
|
for (i = rows.begin(); i != rows.end(); ++i) {
|
2006-01-09 23:25:47 -05:00
|
|
|
if ((*i)[route_display_columns.tv] == &tv) {
|
|
|
|
(*i)[route_display_columns.visible] = false;
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-24 03:37:17 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (&tv);
|
2006-01-09 23:25:47 -05:00
|
|
|
|
2006-08-24 03:37:17 -04:00
|
|
|
if (rtv && current_mixer_strip && (rtv->route() == current_mixer_strip->route())) {
|
2006-01-09 23:25:47 -05:00
|
|
|
// this will hide the mixer strip
|
|
|
|
set_selected_mixer_strip (tv);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-01-09 23:25:47 -05:00
|
|
|
Editor::show_track_in_display (TimeAxisView& tv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-26 14:12:00 -04:00
|
|
|
TreeModel::Children rows = route_display_model->children();
|
|
|
|
TreeModel::Children::iterator i;
|
|
|
|
|
|
|
|
for (i = rows.begin(); i != rows.end(); ++i) {
|
2006-01-09 23:25:47 -05:00
|
|
|
if ((*i)[route_display_columns.tv] == &tv) {
|
|
|
|
(*i)[route_display_columns.visible] = true;
|
|
|
|
break;
|
2005-10-26 14:12:00 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-01-04 22:18:44 -05:00
|
|
|
Editor::route_list_reordered (const TreeModel::Path& path,const TreeModel::iterator& iter,int* what)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-01-04 22:18:44 -05:00
|
|
|
redisplay_route_list ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-10-11 18:07:47 -04:00
|
|
|
|
|
|
|
void
|
2008-12-08 13:16:12 -05:00
|
|
|
Editor::sync_order_keys (const char *src)
|
2007-10-11 18:07:47 -04:00
|
|
|
{
|
|
|
|
vector<int> neworder;
|
|
|
|
TreeModel::Children rows = route_display_model->children();
|
|
|
|
TreeModel::Children::iterator ri;
|
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
if ((strcmp (src, _order_key) == 0) || !session || (session->state_of_the_state() & Session::Loading) || rows.empty()) {
|
2007-10-11 18:07:47 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (ri = rows.begin(); ri != rows.end(); ++ri) {
|
|
|
|
neworder.push_back (0);
|
|
|
|
}
|
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
bool changed = false;
|
|
|
|
int order;
|
|
|
|
|
|
|
|
for (order = 0, ri = rows.begin(); ri != rows.end(); ++ri, ++order) {
|
2007-10-11 18:07:47 -04:00
|
|
|
boost::shared_ptr<Route> route = (*ri)[route_display_columns.route];
|
2008-12-08 13:16:12 -05:00
|
|
|
|
|
|
|
int old_key = order;
|
|
|
|
int new_key = route->order_key (_order_key);
|
|
|
|
|
|
|
|
neworder[new_key] = old_key;
|
|
|
|
|
|
|
|
if (new_key != old_key) {
|
|
|
|
changed = true;
|
|
|
|
}
|
2007-10-11 18:07:47 -04:00
|
|
|
}
|
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
if (changed) {
|
|
|
|
route_redisplay_does_not_reset_order_keys = true;
|
|
|
|
route_display_model->reorder (neworder);
|
|
|
|
route_redisplay_does_not_reset_order_keys = false;
|
|
|
|
}
|
2007-10-11 18:07:47 -04:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
Editor::redisplay_route_list ()
|
|
|
|
{
|
2005-10-26 14:12:00 -04:00
|
|
|
TreeModel::Children rows = route_display_model->children();
|
|
|
|
TreeModel::Children::iterator i;
|
2005-12-23 10:34:02 -05:00
|
|
|
uint32_t position;
|
|
|
|
uint32_t order;
|
2005-12-12 15:54:55 -05:00
|
|
|
int n;
|
2008-09-12 05:01:52 -04:00
|
|
|
|
2006-01-04 22:18:44 -05:00
|
|
|
if (no_route_list_redisplay) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
for (n = 0, order = 0, position = 0, i = rows.begin(); i != rows.end(); ++i) {
|
2005-12-17 08:39:27 -05:00
|
|
|
TimeAxisView *tv = (*i)[route_display_columns.tv];
|
2008-12-08 13:16:12 -05:00
|
|
|
boost::shared_ptr<Route> route = (*i)[route_display_columns.route];
|
2006-01-04 22:18:44 -05:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
if (tv == 0) {
|
|
|
|
// just a "title" row
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
if (!route_redisplay_does_not_reset_order_keys) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-04 22:18:44 -05:00
|
|
|
/* this reorder is caused by user action, so reassign sort order keys
|
|
|
|
to tracks.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
route->set_order_key (_order_key, order);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-01-09 23:25:47 -05:00
|
|
|
|
|
|
|
bool visible = (*i)[route_display_columns.visible];
|
|
|
|
|
2009-01-01 19:17:55 -05:00
|
|
|
/* show or hide the TimeAxisView */
|
2006-01-09 23:25:47 -05:00
|
|
|
if (visible) {
|
2006-01-17 11:40:57 -05:00
|
|
|
tv->set_marked_for_display (true);
|
2005-12-23 10:34:02 -05:00
|
|
|
position += tv->show_at (position, n, &edit_controls_vbox);
|
2008-10-04 06:38:20 -04:00
|
|
|
tv->clip_to_viewport ();
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2008-10-07 14:05:35 -04:00
|
|
|
tv->set_marked_for_display (false);
|
2005-09-25 14:42:24 -04:00
|
|
|
tv->hide ();
|
|
|
|
}
|
2008-10-07 14:05:35 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
n++;
|
2005-10-26 14:12:00 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2005-12-12 15:54:55 -05:00
|
|
|
|
2008-10-10 20:04:33 -04:00
|
|
|
full_canvas_height = position + canvas_timebars_vsize;
|
|
|
|
vertical_adjustment.set_upper (full_canvas_height);
|
2008-09-17 15:04:16 -04:00
|
|
|
if ((vertical_adjustment.get_value() + canvas_height) > vertical_adjustment.get_upper()) {
|
|
|
|
/*
|
|
|
|
We're increasing the size of the canvas while the bottom is visible.
|
|
|
|
We scroll down to keep in step with the controls layout.
|
|
|
|
*/
|
2008-10-10 20:04:33 -04:00
|
|
|
vertical_adjustment.set_value (full_canvas_height - canvas_height);
|
2008-09-17 15:04:16 -04:00
|
|
|
}
|
2007-10-11 18:07:47 -04:00
|
|
|
|
2008-12-08 13:16:12 -05:00
|
|
|
if (!route_redisplay_does_not_reset_order_keys && !route_redisplay_does_not_sync_order_keys) {
|
|
|
|
session->sync_order_keys (_order_key);
|
2007-10-11 18:07:47 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::hide_all_tracks (bool with_select)
|
|
|
|
{
|
2005-10-26 14:12:00 -04:00
|
|
|
TreeModel::Children rows = route_display_model->children();
|
|
|
|
TreeModel::Children::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
no_route_list_redisplay = true;
|
|
|
|
|
2005-10-26 14:12:00 -04:00
|
|
|
for (i = rows.begin(); i != rows.end(); ++i) {
|
|
|
|
|
|
|
|
TreeModel::Row row = (*i);
|
|
|
|
TimeAxisView *tv = row[route_display_columns.tv];
|
2006-01-09 23:25:47 -05:00
|
|
|
|
|
|
|
if (tv == 0) {
|
|
|
|
continue;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-01-09 23:25:47 -05:00
|
|
|
|
|
|
|
row[route_display_columns.visible] = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-01-09 23:25:47 -05:00
|
|
|
|
|
|
|
no_route_list_redisplay = false;
|
|
|
|
redisplay_route_list ();
|
|
|
|
|
|
|
|
/* XXX this seems like a hack and half, but its not clear where to put this
|
|
|
|
otherwise.
|
|
|
|
*/
|
|
|
|
|
2008-09-10 17:27:39 -04:00
|
|
|
//reset_scrolling_region ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::build_route_list_menu ()
|
|
|
|
{
|
2008-09-19 02:30:49 -04:00
|
|
|
using namespace Menu_Helpers;
|
2005-10-26 14:12:00 -04:00
|
|
|
using namespace Gtk;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
route_list_menu = new Menu;
|
|
|
|
|
|
|
|
MenuList& items = route_list_menu->items();
|
|
|
|
route_list_menu->set_name ("ArdourContextMenu");
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
items.push_back (MenuElem (_("Show All"), mem_fun(*this, &Editor::show_all_routes)));
|
|
|
|
items.push_back (MenuElem (_("Hide All"), mem_fun(*this, &Editor::hide_all_routes)));
|
|
|
|
items.push_back (MenuElem (_("Show All Audio Tracks"), mem_fun(*this, &Editor::show_all_audiotracks)));
|
|
|
|
items.push_back (MenuElem (_("Hide All Audio Tracks"), mem_fun(*this, &Editor::hide_all_audiotracks)));
|
|
|
|
items.push_back (MenuElem (_("Show All Audio Busses"), mem_fun(*this, &Editor::show_all_audiobus)));
|
|
|
|
items.push_back (MenuElem (_("Hide All Audio Busses"), mem_fun(*this, &Editor::hide_all_audiobus)));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-01-09 23:25:47 -05:00
|
|
|
Editor::set_all_tracks_visibility (bool yn)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2008-09-19 02:30:49 -04:00
|
|
|
TreeModel::Children rows = route_display_model->children();
|
2005-10-26 14:12:00 -04:00
|
|
|
TreeModel::Children::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
no_route_list_redisplay = true;
|
|
|
|
|
2005-10-26 14:12:00 -04:00
|
|
|
for (i = rows.begin(); i != rows.end(); ++i) {
|
2006-01-09 23:25:47 -05:00
|
|
|
|
|
|
|
TreeModel::Row row = (*i);
|
|
|
|
TimeAxisView* tv = row[route_display_columns.tv];
|
|
|
|
|
|
|
|
if (tv == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*i)[route_display_columns.visible] = yn;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-01-09 23:25:47 -05:00
|
|
|
|
|
|
|
no_route_list_redisplay = false;
|
|
|
|
redisplay_route_list ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-01-09 23:25:47 -05:00
|
|
|
Editor::set_all_audio_visibility (int tracks, bool yn)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2008-09-19 02:30:49 -04:00
|
|
|
TreeModel::Children rows = route_display_model->children();
|
2005-10-26 14:12:00 -04:00
|
|
|
TreeModel::Children::iterator i;
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
no_route_list_redisplay = true;
|
|
|
|
|
2005-10-26 14:12:00 -04:00
|
|
|
for (i = rows.begin(); i != rows.end(); ++i) {
|
2006-01-09 23:25:47 -05:00
|
|
|
TreeModel::Row row = (*i);
|
|
|
|
TimeAxisView* tv = row[route_display_columns.tv];
|
2005-09-25 14:42:24 -04:00
|
|
|
AudioTimeAxisView* atv;
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
if (tv == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2005-10-26 14:12:00 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
|
|
|
|
switch (tracks) {
|
|
|
|
case 0:
|
|
|
|
(*i)[route_display_columns.visible] = yn;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
if (atv->is_audio_track()) {
|
|
|
|
(*i)[route_display_columns.visible] = yn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
if (!atv->is_audio_track()) {
|
|
|
|
(*i)[route_display_columns.visible] = yn;
|
|
|
|
}
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
no_route_list_redisplay = false;
|
|
|
|
redisplay_route_list ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-10-26 14:12:00 -04:00
|
|
|
void
|
2006-01-09 23:25:47 -05:00
|
|
|
Editor::hide_all_routes ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-01-09 23:25:47 -05:00
|
|
|
set_all_tracks_visibility (false);
|
|
|
|
}
|
2005-10-26 14:12:00 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
void
|
|
|
|
Editor::show_all_routes ()
|
|
|
|
{
|
|
|
|
set_all_tracks_visibility (true);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
void
|
|
|
|
Editor::show_all_audiobus ()
|
|
|
|
{
|
|
|
|
set_all_audio_visibility (2, true);
|
|
|
|
}
|
|
|
|
void
|
|
|
|
Editor::hide_all_audiobus ()
|
|
|
|
{
|
|
|
|
set_all_audio_visibility (2, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-01-09 23:25:47 -05:00
|
|
|
Editor::show_all_audiotracks()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-01-09 23:25:47 -05:00
|
|
|
set_all_audio_visibility (1, true);
|
|
|
|
}
|
|
|
|
void
|
|
|
|
Editor::hide_all_audiotracks ()
|
|
|
|
{
|
|
|
|
set_all_audio_visibility (1, false);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
bool
|
|
|
|
Editor::route_list_display_button_press (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
if (Keyboard::is_context_menu_event (ev)) {
|
|
|
|
show_route_list_menu ();
|
|
|
|
return true;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
TreeIter iter;
|
|
|
|
TreeModel::Path path;
|
|
|
|
TreeViewColumn* column;
|
|
|
|
int cellx;
|
|
|
|
int celly;
|
|
|
|
|
|
|
|
if (!route_list_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
|
|
|
|
return false;
|
|
|
|
}
|
2005-10-26 14:12:00 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
|
|
|
|
case 0:
|
|
|
|
if ((iter = route_display_model->get_iter (path))) {
|
|
|
|
TimeAxisView* tv = (*iter)[route_display_columns.tv];
|
|
|
|
if (tv) {
|
|
|
|
bool visible = (*iter)[route_display_columns.visible];
|
|
|
|
(*iter)[route_display_columns.visible] = !visible;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2006-01-09 23:25:47 -05:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
/* allow normal processing to occur */
|
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-01-09 23:25:47 -05:00
|
|
|
Editor::show_route_list_menu()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-01-09 23:25:47 -05:00
|
|
|
if (route_list_menu == 0) {
|
|
|
|
build_route_list_menu ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-01-09 18:24:54 -05:00
|
|
|
route_list_menu->popup (1, gtk_get_current_event_time());
|
2006-01-09 23:25:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Editor::route_list_selection_filter (const Glib::RefPtr<TreeModel>& model, const TreeModel::Path& path, bool yn)
|
|
|
|
{
|
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
struct EditorOrderRouteSorter {
|
2006-07-27 21:08:57 -04:00
|
|
|
bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
|
2006-01-09 23:25:47 -05:00
|
|
|
/* use of ">" forces the correct sort order */
|
2008-12-08 13:16:12 -05:00
|
|
|
return a->order_key (_order_key) < b->order_key (_order_key);
|
2006-01-09 23:25:47 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::initial_route_list_display ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Session::RouteList> routes = session->get_routes();
|
|
|
|
Session::RouteList r (*routes);
|
2006-01-09 23:25:47 -05:00
|
|
|
EditorOrderRouteSorter sorter;
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
r.sort (sorter);
|
2006-01-09 23:25:47 -05:00
|
|
|
|
|
|
|
no_route_list_redisplay = true;
|
|
|
|
|
|
|
|
route_display_model->clear ();
|
|
|
|
|
2006-08-24 03:37:17 -04:00
|
|
|
handle_new_route (r);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
no_route_list_redisplay = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
redisplay_route_list ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-11 18:07:47 -04:00
|
|
|
void
|
|
|
|
Editor::track_list_reorder (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter, int* new_order)
|
|
|
|
{
|
2008-12-08 13:16:12 -05:00
|
|
|
route_redisplay_does_not_sync_order_keys = true;
|
2007-10-11 18:07:47 -04:00
|
|
|
session->set_remote_control_ids();
|
|
|
|
redisplay_route_list ();
|
2008-12-08 13:16:12 -05:00
|
|
|
route_redisplay_does_not_sync_order_keys = false;
|
2007-10-11 18:07:47 -04:00
|
|
|
}
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
void
|
|
|
|
Editor::route_list_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter)
|
|
|
|
{
|
2008-12-08 13:16:12 -05:00
|
|
|
/* never reset order keys because of a property change */
|
|
|
|
route_redisplay_does_not_reset_order_keys = true;
|
2007-03-18 02:07:08 -04:00
|
|
|
session->set_remote_control_ids();
|
2006-01-09 23:25:47 -05:00
|
|
|
redisplay_route_list ();
|
2008-12-08 13:16:12 -05:00
|
|
|
route_redisplay_does_not_reset_order_keys = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-01-09 23:25:47 -05:00
|
|
|
void
|
|
|
|
Editor::route_list_delete (const Gtk::TreeModel::Path& path)
|
|
|
|
{
|
2008-12-08 13:16:12 -05:00
|
|
|
/* this could require an order reset & sync */
|
2007-03-18 02:07:08 -04:00
|
|
|
session->set_remote_control_ids();
|
2008-09-10 17:27:39 -04:00
|
|
|
ignore_route_list_reorder = true;
|
2006-01-09 23:25:47 -05:00
|
|
|
redisplay_route_list ();
|
2008-09-10 17:27:39 -04:00
|
|
|
ignore_route_list_reorder = false;
|
2006-01-09 23:25:47 -05:00
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::route_list_display_drag_data_received (const RefPtr<Gdk::DragContext>& context,
|
|
|
|
int x, int y,
|
|
|
|
const SelectionData& data,
|
|
|
|
guint info, guint time)
|
|
|
|
{
|
|
|
|
if (data.get_target() == "GTK_TREE_MODEL_ROW") {
|
|
|
|
route_list_display.on_drag_data_received (context, x, y, data, info, time);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
context->drag_finish (true, false, time);
|
|
|
|
}
|
2008-02-10 13:16:25 -05:00
|
|
|
|
|
|
|
RouteTimeAxisView*
|
|
|
|
Editor::get_route_view_by_id (PBD::ID& id)
|
|
|
|
{
|
|
|
|
RouteTimeAxisView* v;
|
|
|
|
|
|
|
|
for(TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
if((v = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) {
|
|
|
|
if(v->route()->id() == id) {
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-03-17 16:54:03 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::foreach_time_axis_view (sigc::slot<void,TimeAxisView&> theslot)
|
|
|
|
{
|
|
|
|
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
|
|
|
theslot (**i);
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 13:16:12 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
Editor::move_selected_tracks (bool up)
|
|
|
|
{
|
|
|
|
if (selection->tracks.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef std::pair<TimeAxisView*,boost::shared_ptr<Route> > ViewRoute;
|
|
|
|
std::list<ViewRoute> view_routes;
|
|
|
|
std::vector<int> neworder;
|
|
|
|
TreeModel::Children rows = route_display_model->children();
|
|
|
|
TreeModel::Children::iterator ri;
|
|
|
|
|
|
|
|
for (ri = rows.begin(); ri != rows.end(); ++ri) {
|
|
|
|
TimeAxisView* tv = (*ri)[route_display_columns.tv];
|
|
|
|
boost::shared_ptr<Route> route = (*ri)[route_display_columns.route];
|
|
|
|
|
|
|
|
view_routes.push_back (ViewRoute (tv, route));
|
|
|
|
}
|
|
|
|
|
|
|
|
list<ViewRoute>::iterator trailing;
|
|
|
|
list<ViewRoute>::iterator leading;
|
|
|
|
|
|
|
|
if (up) {
|
|
|
|
|
|
|
|
trailing = view_routes.begin();
|
|
|
|
leading = view_routes.begin();
|
|
|
|
|
|
|
|
++leading;
|
|
|
|
|
|
|
|
while (leading != view_routes.end()) {
|
|
|
|
if (selection->selected (leading->first)) {
|
|
|
|
view_routes.insert (trailing, ViewRoute (leading->first, leading->second));
|
|
|
|
leading = view_routes.erase (leading);
|
|
|
|
} else {
|
|
|
|
++leading;
|
|
|
|
++trailing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* if we could use reverse_iterator in list::insert, this code
|
|
|
|
would be a beautiful reflection of the code above. but we can't
|
|
|
|
and so it looks like a bit of a mess.
|
|
|
|
*/
|
|
|
|
|
|
|
|
trailing = view_routes.end();
|
|
|
|
leading = view_routes.end();
|
|
|
|
|
|
|
|
--leading; if (leading == view_routes.begin()) { return; }
|
|
|
|
--leading;
|
|
|
|
--trailing;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
|
|
|
if (selection->selected (leading->first)) {
|
|
|
|
list<ViewRoute>::iterator tmp;
|
|
|
|
|
|
|
|
/* need to insert *after* trailing, not *before* it,
|
|
|
|
which is what insert (iter, val) normally does.
|
|
|
|
*/
|
|
|
|
|
|
|
|
tmp = trailing;
|
|
|
|
tmp++;
|
|
|
|
|
|
|
|
view_routes.insert (tmp, ViewRoute (leading->first, leading->second));
|
|
|
|
|
|
|
|
/* can't use iter = cont.erase (iter); form here, because
|
|
|
|
we need iter to move backwards.
|
|
|
|
*/
|
|
|
|
|
|
|
|
tmp = leading;
|
|
|
|
--tmp;
|
|
|
|
|
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
if (leading == view_routes.begin()) {
|
|
|
|
/* the one we've just inserted somewhere else
|
|
|
|
was the first in the list. erase this copy,
|
|
|
|
and then break, because we're done.
|
|
|
|
*/
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
view_routes.erase (leading);
|
|
|
|
|
|
|
|
if (done) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
leading = tmp;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (leading == view_routes.begin()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
--leading;
|
|
|
|
--trailing;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
for (leading = view_routes.begin(); leading != view_routes.end(); ++leading) {
|
|
|
|
neworder.push_back (leading->second->order_key (_order_key));
|
|
|
|
}
|
|
|
|
|
|
|
|
route_display_model->reorder (neworder);
|
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
session->sync_order_keys (_order_key);
|
|
|
|
}
|