2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "ardour_ui.h"
27 #include "audio_time_axis.h"
28 #include "mixer_strip.h"
29 #include "gui_thread.h"
31 #include <ardour/route.h>
32 #include <ardour/audio_track.h>
37 using namespace ARDOUR;
42 Editor::handle_new_route_p (Route* route)
44 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::handle_new_route_p), route));
45 handle_new_route (*route);
49 Editor::handle_new_route (Route& route)
52 AudioTimeAxisView *atv;
53 TreeModel::Row parent;
60 tv = new AudioTimeAxisView (*this, *session, route, track_canvas);
63 if (route_display_model->children().size() == 0) {
65 /* set up basic entries */
69 row = *(route_display_model->append()); // path = "0"
70 row[route_display_columns.text] = _("Busses");
71 row[route_display_columns.tv] = 0;
72 row = *(route_display_model->append()); // path = "1"
73 row[route_display_columns.text] = _("Tracks");
74 row[route_display_columns.tv] = 0;
78 if (dynamic_cast<AudioTrack*>(&route) != 0) {
79 TreeModel::iterator iter = route_display_model->get_iter ("1"); // audio tracks
82 TreeModel::iterator iter = route_display_model->get_iter ("0"); // busses
87 row = *(route_display_model->append (parent.children()));
89 row = *(route_display_model->append ());
92 row[route_display_columns.text] = route.name();
93 row[route_display_columns.visible] = tv->marked_for_display();
94 row[route_display_columns.tv] = tv;
96 track_views.push_back (tv);
98 ignore_route_list_reorder = true;
100 if ((atv = dynamic_cast<AudioTimeAxisView*> (tv)) != 0) {
101 /* added a new fresh one at the end */
102 if (atv->route().order_key(N_("editor")) == -1) {
103 atv->route().set_order_key (N_("editor"), route_display_model->children().size()-1);
107 ignore_route_list_reorder = false;
109 route.gui_changed.connect (mem_fun(*this, &Editor::handle_gui_changes));
111 tv->GoingAway.connect (bind (mem_fun(*this, &Editor::remove_route), tv));
113 editor_mixer_button.set_sensitive(true);
117 Editor::handle_gui_changes (const string & what, void *src)
119 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::handle_gui_changes), what, src));
121 if (what == "track_height") {
122 redisplay_route_list ();
128 Editor::remove_route (TimeAxisView *tv)
130 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::remove_route), tv));
133 TrackViewList::iterator i;
134 TreeModel::Children rows = route_display_model->children();
135 TreeModel::Children::iterator ri;
137 if ((i = find (track_views.begin(), track_views.end(), tv)) != track_views.end()) {
138 track_views.erase (i);
141 for (ri = rows.begin(); ri != rows.end(); ++ri) {
142 if ((*ri)[route_display_columns.tv] == tv) {
143 route_display_model->erase (ri);
147 /* since the editor mixer goes away when you remove a route, set the
148 * button to inacttive
150 editor_mixer_button.set_active(false);
152 /* and disable if all tracks and/or routes are gone */
154 if (track_views.size() == 0) {
155 editor_mixer_button.set_sensitive(false);
160 Editor::route_name_changed (TimeAxisView *tv)
162 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::route_name_changed), tv));
164 TreeModel::Children rows = route_display_model->children();
165 TreeModel::Children::iterator i;
167 for (i = rows.begin(); i != rows.end(); ++i) {
168 if ((*i)[route_display_columns.tv] == tv) {
169 (*i)[route_display_columns.text] = tv->name();
177 Editor::hide_track_in_display (TimeAxisView& tv)
179 TreeModel::Children rows = route_display_model->children();
180 TreeModel::Children::iterator i;
182 for (i = rows.begin(); i != rows.end(); ++i) {
183 if ((*i)[route_display_columns.tv] == &tv) {
184 (*i)[route_display_columns.visible] = false;
189 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (&tv);
191 if (atv && current_mixer_strip && &(atv->route()) == &(current_mixer_strip->route())) {
192 // this will hide the mixer strip
193 set_selected_mixer_strip (tv);
198 Editor::show_track_in_display (TimeAxisView& tv)
200 TreeModel::Children rows = route_display_model->children();
201 TreeModel::Children::iterator i;
203 for (i = rows.begin(); i != rows.end(); ++i) {
204 if ((*i)[route_display_columns.tv] == &tv) {
205 (*i)[route_display_columns.visible] = true;
206 tv.set_marked_for_display (true);
213 Editor::route_list_reordered (const TreeModel::Path& path,const TreeModel::iterator& iter,int* what)
215 redisplay_route_list ();
219 Editor::redisplay_route_list ()
221 TreeModel::Children rows = route_display_model->children();
222 TreeModel::Children::iterator i;
227 if (no_route_list_redisplay) {
231 for (n = 0, order = 0, position = 0, i = rows.begin(); i != rows.end(); ++i) {
232 TimeAxisView *tv = (*i)[route_display_columns.tv];
233 AudioTimeAxisView* at;
236 // just a "title" row
240 if (!ignore_route_list_reorder) {
242 /* this reorder is caused by user action, so reassign sort order keys
246 if ((at = dynamic_cast<AudioTimeAxisView*> (tv)) != 0) {
247 at->route().set_order_key (N_("editor"), order);
252 bool visible = (*i)[route_display_columns.visible];
255 tv->set_marked_for_display (true);
256 position += tv->show_at (position, n, &edit_controls_vbox);
257 position += track_spacing;
266 reset_scrolling_region ();
270 Editor::hide_all_tracks (bool with_select)
272 TreeModel::Children rows = route_display_model->children();
273 TreeModel::Children::iterator i;
275 no_route_list_redisplay = true;
277 for (i = rows.begin(); i != rows.end(); ++i) {
279 TreeModel::Row row = (*i);
280 TimeAxisView *tv = row[route_display_columns.tv];
286 row[route_display_columns.visible] = false;
289 no_route_list_redisplay = false;
290 redisplay_route_list ();
292 /* XXX this seems like a hack and half, but its not clear where to put this
296 reset_scrolling_region ();
300 Editor::build_route_list_menu ()
302 using namespace Menu_Helpers;
305 route_list_menu = new Menu;
307 MenuList& items = route_list_menu->items();
308 route_list_menu->set_name ("ArdourContextMenu");
310 items.push_back (MenuElem (_("Show All"), mem_fun(*this, &Editor::show_all_routes)));
311 items.push_back (MenuElem (_("Hide All"), mem_fun(*this, &Editor::hide_all_routes)));
312 items.push_back (MenuElem (_("Show All Audio Tracks"), mem_fun(*this, &Editor::show_all_audiotracks)));
313 items.push_back (MenuElem (_("Hide All Audio Tracks"), mem_fun(*this, &Editor::hide_all_audiotracks)));
314 items.push_back (MenuElem (_("Show All Audio Busses"), mem_fun(*this, &Editor::show_all_audiobus)));
315 items.push_back (MenuElem (_("Hide All Audio Busses"), mem_fun(*this, &Editor::hide_all_audiobus)));
320 Editor::set_all_tracks_visibility (bool yn)
322 TreeModel::Children rows = route_display_model->children();
323 TreeModel::Children::iterator i;
325 no_route_list_redisplay = true;
327 for (i = rows.begin(); i != rows.end(); ++i) {
329 TreeModel::Row row = (*i);
330 TimeAxisView* tv = row[route_display_columns.tv];
336 (*i)[route_display_columns.visible] = yn;
339 no_route_list_redisplay = false;
340 redisplay_route_list ();
344 Editor::set_all_audio_visibility (int tracks, bool yn)
346 TreeModel::Children rows = route_display_model->children();
347 TreeModel::Children::iterator i;
349 no_route_list_redisplay = true;
351 for (i = rows.begin(); i != rows.end(); ++i) {
352 TreeModel::Row row = (*i);
353 TimeAxisView* tv = row[route_display_columns.tv];
354 AudioTimeAxisView* atv;
360 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
363 (*i)[route_display_columns.visible] = yn;
367 if (atv->is_audio_track()) {
368 (*i)[route_display_columns.visible] = yn;
373 if (!atv->is_audio_track()) {
374 (*i)[route_display_columns.visible] = yn;
381 no_route_list_redisplay = false;
382 redisplay_route_list ();
386 Editor::hide_all_routes ()
388 set_all_tracks_visibility (false);
392 Editor::show_all_routes ()
394 set_all_tracks_visibility (true);
398 Editor::show_all_audiobus ()
400 set_all_audio_visibility (2, true);
403 Editor::hide_all_audiobus ()
405 set_all_audio_visibility (2, false);
409 Editor::show_all_audiotracks()
411 set_all_audio_visibility (1, true);
414 Editor::hide_all_audiotracks ()
416 set_all_audio_visibility (1, false);
420 Editor::route_list_display_button_press (GdkEventButton* ev)
422 if (Keyboard::is_context_menu_event (ev)) {
423 show_route_list_menu ();
428 TreeModel::Path path;
429 TreeViewColumn* column;
433 if (!route_list_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
437 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
439 if ((iter = route_display_model->get_iter (path))) {
440 TimeAxisView* tv = (*iter)[route_display_columns.tv];
442 bool visible = (*iter)[route_display_columns.visible];
443 (*iter)[route_display_columns.visible] = !visible;
449 /* allow normal processing to occur */
460 Editor::show_route_list_menu()
462 if (route_list_menu == 0) {
463 build_route_list_menu ();
466 route_list_menu->popup (1, 0);
470 Editor::route_list_selection_filter (const Glib::RefPtr<TreeModel>& model, const TreeModel::Path& path, bool yn)
475 struct EditorOrderRouteSorter {
476 bool operator() (Route* a, Route* b) {
477 /* use of ">" forces the correct sort order */
478 return a->order_key ("editor") < b->order_key ("editor");
483 Editor::initial_route_list_display ()
485 Session::RouteList routes = session->get_routes();
486 EditorOrderRouteSorter sorter;
488 routes.sort (sorter);
490 no_route_list_redisplay = true;
492 route_display_model->clear ();
494 for (Session::RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
495 handle_new_route (**i);
498 no_route_list_redisplay = false;
500 redisplay_route_list ();
504 Editor::route_list_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter)
506 redisplay_route_list ();
510 Editor::route_list_delete (const Gtk::TreeModel::Path& path)
512 redisplay_route_list ();