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>
36 using namespace ARDOUR;
40 Editor::handle_new_route_p (Route* route)
42 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::handle_new_route_p), route));
43 handle_new_route (*route);
47 Editor::handle_new_route (Route& route)
50 AudioTimeAxisView *atv;
51 TreeModel::Row row = *(route_display_model->append());
57 tv = new AudioTimeAxisView (*this, *session, route, track_canvas);
59 track_views.push_back (tv);
61 row[route_display_columns.text] = route.name();
62 row[route_display_columns.tv] = tv;
64 ignore_route_list_reorder = true;
66 if (!no_route_list_redisplay && tv->marked_for_display()) {
67 route_list_display.get_selection()->select (row);
70 if ((atv = dynamic_cast<AudioTimeAxisView*> (tv)) != 0) {
71 /* added a new fresh one at the end */
72 if (atv->route().order_key(N_("editor")) == -1) {
73 atv->route().set_order_key (N_("editor"), route_display_model->children().size()-1);
77 ignore_route_list_reorder = false;
79 route.gui_changed.connect (mem_fun(*this, &Editor::handle_gui_changes));
81 tv->GoingAway.connect (bind (mem_fun(*this, &Editor::remove_route), tv));
83 editor_mixer_button.set_sensitive(true);
87 Editor::handle_gui_changes (const string & what, void *src)
89 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::handle_gui_changes), what, src));
91 if (what == "track_height") {
92 redisplay_route_list ();
98 Editor::remove_route (TimeAxisView *tv)
100 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::remove_route), tv));
103 TrackViewList::iterator i;
104 TreeModel::Children rows = route_display_model->children();
105 TreeModel::Children::iterator ri;
107 if ((i = find (track_views.begin(), track_views.end(), tv)) != track_views.end()) {
108 track_views.erase (i);
111 for (ri = rows.begin(); ri != rows.end(); ++ri) {
112 if ((*ri)[route_display_columns.tv] == tv) {
113 route_display_model->erase (ri);
117 /* since the editor mixer goes away when you remove a route, set the
118 * button to inacttive
120 editor_mixer_button.set_active(false);
122 /* and disable if all tracks and/or routes are gone */
124 if (track_views.size() == 0) {
125 editor_mixer_button.set_sensitive(false);
130 Editor::route_name_changed (TimeAxisView *tv)
132 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::route_name_changed), tv));
134 TreeModel::Children rows = route_display_model->children();
135 TreeModel::Children::iterator i;
137 for (i = rows.begin(); i != rows.end(); ++i) {
138 if ((*i)[route_display_columns.tv] == tv) {
139 (*i)[route_display_columns.text] = tv->name();
147 Editor::route_display_selection_changed ()
150 TreeModel::Children rows = route_display_model->children();
151 TreeModel::Children::iterator i;
152 Glib::RefPtr<TreeSelection> selection = route_list_display.get_selection();
154 for (i = rows.begin(); i != rows.end(); ++i) {
155 tv = (*i)[route_display_columns.tv];
157 if (!selection->is_selected (i)) {
158 tv->set_marked_for_display (false);
160 AudioTimeAxisView *atv;
161 tv->set_marked_for_display (true);
162 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
163 if (current_mixer_strip && &(atv->route()) == &(current_mixer_strip->route())) {
164 // this will hide the mixer strip
165 set_selected_mixer_strip(*atv);
171 redisplay_route_list ();
175 Editor::unselect_strip_in_display (TimeAxisView& tv)
177 TreeModel::Children rows = route_display_model->children();
178 TreeModel::Children::iterator i;
179 Glib::RefPtr<TreeSelection> selection = route_list_display.get_selection();
181 for (i = rows.begin(); i != rows.end(); ++i) {
182 if ((*i)[route_display_columns.tv] == &tv) {
183 selection->unselect (*i);
189 Editor::select_strip_in_display (TimeAxisView* tv)
191 TreeModel::Children rows = route_display_model->children();
192 TreeModel::Children::iterator i;
193 Glib::RefPtr<TreeSelection> selection = route_list_display.get_selection();
195 for (i = rows.begin(); i != rows.end(); ++i) {
196 if ((*i)[route_display_columns.tv] == tv) {
197 selection->select (*i);
203 Editor::route_list_reordered (const TreeModel::Path& path,const TreeModel::iterator& iter,int* what)
205 redisplay_route_list ();
209 Editor::redisplay_route_list ()
211 TreeModel::Children rows = route_display_model->children();
212 TreeModel::Children::iterator i;
217 if (no_route_list_redisplay) {
221 for (n = 0, order = 0, position = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
222 TimeAxisView *tv = (*i)[route_display_columns.tv];
223 AudioTimeAxisView* at;
225 if (!ignore_route_list_reorder) {
227 /* this reorder is caused by user action, so reassign sort order keys
231 if ((at = dynamic_cast<AudioTimeAxisView*> (tv)) != 0) {
232 at->route().set_order_key (N_("editor"), order);
235 if (tv->marked_for_display()) {
236 position += tv->show_at (position, n, &edit_controls_vbox);
237 position += track_spacing;
246 controls_layout.queue_resize ();
247 reset_scrolling_region ();
251 Editor::hide_all_tracks (bool with_select)
253 TreeModel::Children rows = route_display_model->children();
254 TreeModel::Children::iterator i;
257 // track_display_list.freeze ();
259 for (i = rows.begin(); i != rows.end(); ++i) {
261 TreeModel::Row row = (*i);
262 TimeAxisView *tv = row[route_display_columns.tv];
265 route_list_display.get_selection()->unselect (i);
267 tv->set_marked_for_display (false);
272 //route_list_display.thaw ();
273 reset_scrolling_region ();
277 Editor::build_route_list_menu ()
279 using namespace Menu_Helpers;
283 route_list_menu = new Menu;
285 MenuList& items = route_list_menu->items();
286 route_list_menu->set_name ("ArdourContextMenu");
288 items.push_back (MenuElem (_("Show All"), mem_fun(*this, &Editor::select_all_routes)));
289 items.push_back (MenuElem (_("Hide All"), mem_fun(*this, &Editor::unselect_all_routes)));
290 items.push_back (MenuElem (_("Show All AbstractTracks"), mem_fun(*this, &Editor::select_all_audiotracks)));
291 items.push_back (MenuElem (_("Hide All AbstractTracks"), mem_fun(*this, &Editor::unselect_all_audiotracks)));
292 items.push_back (MenuElem (_("Show All AudioBus"), mem_fun(*this, &Editor::select_all_audiobus)));
293 items.push_back (MenuElem (_("Hide All AudioBus"), mem_fun(*this, &Editor::unselect_all_audiobus)));
298 Editor::unselect_all_routes ()
300 hide_all_tracks (true);
304 Editor::select_all_routes ()
307 TreeModel::Children rows = route_display_model->children();
308 TreeModel::Children::iterator i;
310 for (i = rows.begin(); i != rows.end(); ++i) {
311 route_list_display.get_selection()->select (i);
316 Editor::select_all_audiotracks ()
318 TreeModel::Children rows = route_display_model->children();
319 TreeModel::Children::iterator i;
321 for (i = rows.begin(); i != rows.end(); ++i) {
322 TreeModel::Row row = (*i);
323 TimeAxisView* tv = row[route_display_columns.tv];
324 AudioTimeAxisView* atv;
326 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
327 if (atv->is_audio_track()) {
328 route_list_display.get_selection()->select (i);
337 Editor::unselect_all_audiotracks ()
339 TreeModel::Children rows = route_display_model->children();
340 TreeModel::Children::iterator i;
342 for (i = rows.begin(); i != rows.end(); ++i) {
343 TreeModel::Row row = (*i);
344 TimeAxisView *tv = row[route_display_columns.tv];
345 AudioTimeAxisView* atv;
347 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
348 if (atv->is_audio_track()) {
349 route_list_display.get_selection()->unselect (i);
358 Editor::select_all_audiobus ()
360 TreeModel::Children rows = route_display_model->children();
361 TreeModel::Children::iterator i;
363 for (i = rows.begin(); i != rows.end(); ++i) {
364 TreeModel::Row row = (*i);
365 TimeAxisView* tv = row[route_display_columns.tv];
366 AudioTimeAxisView* atv;
368 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
369 if (!atv->is_audio_track()) {
370 route_list_display.get_selection()->select (i);
379 Editor::unselect_all_audiobus ()
381 TreeModel::Children rows = route_display_model->children();
382 TreeModel::Children::iterator i;
384 for (i = rows.begin(); i != rows.end(); ++i) {
385 TreeModel::Row row = (*i);
386 TimeAxisView* tv = row[route_display_columns.tv];
387 AudioTimeAxisView* atv;
389 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
390 if (!atv->is_audio_track()) {
391 route_list_display.get_selection()->unselect (i);
400 Editor::route_list_compare_func (TreeModel::iterator a, TreeModel::iterator b)
404 AudioTimeAxisView *atv1;
405 AudioTimeAxisView *atv2;
409 tv1 = (*a)[route_display_columns.tv];
410 tv2 = (*b)[route_display_columns.tv];
412 if ((atv1 = dynamic_cast<AudioTimeAxisView*>(tv1)) == 0 ||
413 (atv2 = dynamic_cast<AudioTimeAxisView*>(tv2)) == 0) {
420 /* use of ">" forces the correct sort order */
422 return ra->order_key ("editor") > rb->order_key ("editor");