2 Copyright (C) 2000-2009 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.
27 #include "pbd/unknown_type.h"
28 #include "pbd/unwind.h"
30 #include "ardour/debug.h"
31 #include "ardour/midi_track.h"
32 #include "ardour/route.h"
33 #include "ardour/session.h"
34 #include "ardour/solo_isolate_control.h"
35 #include "ardour/utils.h"
37 #include "gtkmm2ext/cell_renderer_pixbuf_multi.h"
38 #include "gtkmm2ext/cell_renderer_pixbuf_toggle.h"
39 #include "gtkmm2ext/treeutils.h"
42 #include "ardour_ui.h"
43 #include "audio_time_axis.h"
45 #include "editor_group_tabs.h"
46 #include "editor_routes.h"
47 #include "gui_thread.h"
49 #include "midi_time_axis.h"
50 #include "mixer_strip.h"
51 #include "plugin_setup_dialog.h"
52 #include "route_sorter.h"
59 using namespace ARDOUR;
60 using namespace ARDOUR_UI_UTILS;
63 using namespace Gtkmm2ext;
65 using Gtkmm2ext::Keyboard;
73 EditorRoutes::EditorRoutes (Editor* e)
75 , _ignore_reorder (false)
76 , _no_redisplay (false)
77 , _adding_routes (false)
78 , _route_deletion_in_progress (false)
79 , _redisplay_on_resume (false)
80 , _redisplay_active (0)
81 , _queue_tv_update (0)
84 , selection_countdown (0)
87 static const int column_width = 22;
89 _scroller.add (_display);
90 _scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
92 _model = ListStore::create (_columns);
93 _display.set_model (_model);
95 // Record enable toggle
96 CellRendererPixbufMulti* rec_col_renderer = manage (new CellRendererPixbufMulti());
98 rec_col_renderer->set_pixbuf (0, ::get_icon("record-normal-disabled"));
99 rec_col_renderer->set_pixbuf (1, ::get_icon("record-normal-in-progress"));
100 rec_col_renderer->set_pixbuf (2, ::get_icon("record-normal-enabled"));
101 rec_col_renderer->set_pixbuf (3, ::get_icon("record-step"));
102 rec_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_enable_changed));
104 TreeViewColumn* rec_state_column = manage (new TreeViewColumn("R", *rec_col_renderer));
106 rec_state_column->add_attribute(rec_col_renderer->property_state(), _columns.rec_state);
107 rec_state_column->add_attribute(rec_col_renderer->property_visible(), _columns.is_track);
109 rec_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
110 rec_state_column->set_alignment(ALIGN_CENTER);
111 rec_state_column->set_expand(false);
112 rec_state_column->set_fixed_width(column_width);
115 // Record safe toggle
116 CellRendererPixbufMulti* rec_safe_renderer = manage (new CellRendererPixbufMulti ());
118 rec_safe_renderer->set_pixbuf (0, ::get_icon("rec-safe-disabled"));
119 rec_safe_renderer->set_pixbuf (1, ::get_icon("rec-safe-enabled"));
120 rec_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_safe_toggled));
122 TreeViewColumn* rec_safe_column = manage (new TreeViewColumn(_("RS"), *rec_safe_renderer));
123 rec_safe_column->add_attribute(rec_safe_renderer->property_state(), _columns.rec_safe);
124 rec_safe_column->add_attribute(rec_safe_renderer->property_visible(), _columns.is_track);
125 rec_safe_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
126 rec_safe_column->set_alignment(ALIGN_CENTER);
127 rec_safe_column->set_expand(false);
128 rec_safe_column->set_fixed_width(column_width);
133 CellRendererPixbufMulti* input_active_col_renderer = manage (new CellRendererPixbufMulti());
134 input_active_col_renderer->set_pixbuf (0, ::get_icon("midi-input-inactive"));
135 input_active_col_renderer->set_pixbuf (1, ::get_icon("midi-input-active"));
136 input_active_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_input_active_changed));
138 TreeViewColumn* input_active_column = manage (new TreeViewColumn ("I", *input_active_col_renderer));
140 input_active_column->add_attribute(input_active_col_renderer->property_state(), _columns.is_input_active);
141 input_active_column->add_attribute (input_active_col_renderer->property_visible(), _columns.is_midi);
143 input_active_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
144 input_active_column->set_alignment(ALIGN_CENTER);
145 input_active_column->set_expand(false);
146 input_active_column->set_fixed_width(column_width);
148 // Mute enable toggle
149 CellRendererPixbufMulti* mute_col_renderer = manage (new CellRendererPixbufMulti());
151 mute_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("mute-disabled"));
152 mute_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("muted-by-others"));
153 mute_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("mute-enabled"));
154 mute_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_mute_enable_toggled));
156 TreeViewColumn* mute_state_column = manage (new TreeViewColumn("M", *mute_col_renderer));
158 mute_state_column->add_attribute(mute_col_renderer->property_state(), _columns.mute_state);
159 mute_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
160 mute_state_column->set_alignment(ALIGN_CENTER);
161 mute_state_column->set_expand(false);
162 mute_state_column->set_fixed_width(15);
164 // Solo enable toggle
165 CellRendererPixbufMulti* solo_col_renderer = manage (new CellRendererPixbufMulti());
167 solo_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("solo-disabled"));
168 solo_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("solo-enabled"));
169 solo_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("soloed-by-others"));
170 solo_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_enable_toggled));
172 TreeViewColumn* solo_state_column = manage (new TreeViewColumn("S", *solo_col_renderer));
174 solo_state_column->add_attribute(solo_col_renderer->property_state(), _columns.solo_state);
175 solo_state_column->add_attribute(solo_col_renderer->property_visible(), _columns.solo_visible);
176 solo_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
177 solo_state_column->set_alignment(ALIGN_CENTER);
178 solo_state_column->set_expand(false);
179 solo_state_column->set_fixed_width(column_width);
181 // Solo isolate toggle
182 CellRendererPixbufMulti* solo_iso_renderer = manage (new CellRendererPixbufMulti());
184 solo_iso_renderer->set_pixbuf (0, ::get_icon("solo-isolate-disabled"));
185 solo_iso_renderer->set_pixbuf (1, ::get_icon("solo-isolate-enabled"));
186 solo_iso_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_isolate_toggled));
188 TreeViewColumn* solo_isolate_state_column = manage (new TreeViewColumn("SI", *solo_iso_renderer));
190 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_state(), _columns.solo_isolate_state);
191 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_visible(), _columns.solo_visible);
192 solo_isolate_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
193 solo_isolate_state_column->set_alignment(ALIGN_CENTER);
194 solo_isolate_state_column->set_expand(false);
195 solo_isolate_state_column->set_fixed_width(column_width);
198 CellRendererPixbufMulti* solo_safe_renderer = manage (new CellRendererPixbufMulti ());
200 solo_safe_renderer->set_pixbuf (0, ::get_icon("solo-safe-disabled"));
201 solo_safe_renderer->set_pixbuf (1, ::get_icon("solo-safe-enabled"));
202 solo_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_safe_toggled));
204 TreeViewColumn* solo_safe_state_column = manage (new TreeViewColumn(_("SS"), *solo_safe_renderer));
205 solo_safe_state_column->add_attribute(solo_safe_renderer->property_state(), _columns.solo_safe_state);
206 solo_safe_state_column->add_attribute(solo_safe_renderer->property_visible(), _columns.solo_visible);
207 solo_safe_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
208 solo_safe_state_column->set_alignment(ALIGN_CENTER);
209 solo_safe_state_column->set_expand(false);
210 solo_safe_state_column->set_fixed_width(column_width);
212 _name_column = _display.append_column ("", _columns.text) - 1;
213 _visible_column = _display.append_column ("", _columns.visible) - 1;
214 _active_column = _display.append_column ("", _columns.active) - 1;
216 _display.append_column (*input_active_column);
217 _display.append_column (*rec_state_column);
218 _display.append_column (*rec_safe_column);
219 _display.append_column (*mute_state_column);
220 _display.append_column (*solo_state_column);
221 _display.append_column (*solo_isolate_state_column);
222 _display.append_column (*solo_safe_state_column);
229 { 0, _("Name"), _("Track/Bus Name") },
230 { 1, S_("Visible|V"), _("Track/Bus visible ?") },
231 { 2, S_("Active|A"), _("Track/Bus active ?") },
232 { 3, S_("MidiInput|I"), _("MIDI input enabled") },
233 { 4, S_("Rec|R"), _("Record enabled") },
234 { 5, S_("Rec|RS"), _("Record Safe") },
235 { 6, S_("Mute|M"), _("Muted") },
236 { 7, S_("Solo|S"), _("Soloed") },
237 { 8, S_("SoloIso|SI"), _("Solo Isolated") },
238 { 9, S_("SoloLock|SS"), _("Solo Safe (Locked)") },
242 for (int i = 0; ci[i].index >= 0; ++i) {
243 col = _display.get_column (ci[i].index);
244 l = manage (new Label (ci[i].label));
245 set_tooltip (*l, ci[i].tooltip);
246 col->set_widget (*l);
250 _display.set_headers_visible (true);
251 _display.get_selection()->set_mode (SELECTION_SINGLE);
252 _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRoutes::selection_filter));
253 _display.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::selection_changed));
254 _display.set_reorderable (true);
255 _display.set_name (X_("EditGroupList"));
256 _display.set_rules_hint (true);
257 _display.set_size_request (100, -1);
258 _display.add_object_drag (_columns.route.index(), "routes");
260 CellRendererText* name_cell = dynamic_cast<CellRendererText*> (_display.get_column_cell_renderer (_name_column));
263 name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit_started));
265 TreeViewColumn* name_column = _display.get_column (_name_column);
267 assert (name_column);
269 name_column->add_attribute (name_cell->property_editable(), _columns.name_editable);
270 name_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
271 name_column->set_expand(true);
272 name_column->set_min_width(50);
274 name_cell->property_editable() = true;
275 name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit));
277 // Set the visible column cell renderer to radio toggle
278 CellRendererToggle* visible_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_visible_column));
280 visible_cell->property_activatable() = true;
281 visible_cell->property_radio() = false;
282 visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::visible_changed));
284 TreeViewColumn* visible_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_visible_column));
285 visible_col->set_expand(false);
286 visible_col->set_sizing(TREE_VIEW_COLUMN_FIXED);
287 visible_col->set_fixed_width(30);
288 visible_col->set_alignment(ALIGN_CENTER);
290 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_active_column));
292 active_cell->property_activatable() = true;
293 active_cell->property_radio() = false;
294 active_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::active_changed));
296 TreeViewColumn* active_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_active_column));
297 active_col->set_expand (false);
298 active_col->set_sizing (TREE_VIEW_COLUMN_FIXED);
299 active_col->set_fixed_width (30);
300 active_col->set_alignment (ALIGN_CENTER);
302 _model->signal_row_deleted().connect (sigc::mem_fun (*this, &EditorRoutes::row_deleted));
303 _model->signal_rows_reordered().connect (sigc::mem_fun (*this, &EditorRoutes::reordered));
305 _display.signal_button_press_event().connect (sigc::mem_fun (*this, &EditorRoutes::button_press), false);
306 _scroller.signal_key_press_event().connect (sigc::mem_fun(*this, &EditorRoutes::key_press), false);
308 _scroller.signal_focus_in_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_in), false);
309 _scroller.signal_focus_out_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_out));
311 _display.signal_enter_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::enter_notify), false);
312 _display.signal_leave_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::leave_notify), false);
314 _display.set_enable_search (false);
316 Route::SyncOrderKeys.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::sync_treeview_from_order_keys, this), gui_context());
317 Route::PluginSetup.connect_same_thread (*this, boost::bind (&EditorRoutes::plugin_setup, this, _1, _2, _3));
322 EditorRoutes::focus_in (GdkEventFocus*)
324 Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ());
327 old_focus = win->get_focus ();
334 /* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
339 EditorRoutes::focus_out (GdkEventFocus*)
342 old_focus->grab_focus ();
350 EditorRoutes::enter_notify (GdkEventCrossing*)
356 /* arm counter so that ::selection_filter() will deny selecting anything for the
357 * next two attempts to change selection status.
359 selection_countdown = 2;
360 _scroller.grab_focus ();
361 Keyboard::magic_widget_grab_focus ();
366 EditorRoutes::leave_notify (GdkEventCrossing*)
368 selection_countdown = 0;
371 old_focus->grab_focus ();
375 Keyboard::magic_widget_drop_focus ();
380 EditorRoutes::set_session (Session* s)
382 SessionHandlePtr::set_session (s);
387 _session->SoloChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::solo_changed_so_update_mute, this), gui_context());
388 _session->RecordStateChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
390 /* TODO: check if these needs to be tied in with DisplaySuspender
391 * Given that the UI is single-threaded and DisplaySuspender is only used
392 * in loops in the UI thread all should be fine.
394 _session->BatchUpdateStart.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::suspend_redisplay, this), gui_context());
395 _session->BatchUpdateEnd.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::resume_redisplay, this), gui_context());
400 EditorRoutes::on_input_active_changed (std::string const & path_string)
402 // Get the model row that has been toggled.
403 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
405 TimeAxisView* tv = row[_columns.tv];
406 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
409 boost::shared_ptr<MidiTrack> mt;
410 mt = rtv->midi_track();
412 mt->set_input_active (!mt->input_active());
418 EditorRoutes::on_tv_rec_enable_changed (std::string const & path_string)
420 // Get the model row that has been toggled.
421 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
423 TimeAxisView* tv = row[_columns.tv];
424 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
426 if (rtv && rtv->track()) {
427 // TODO check rec-safe and ...
428 _session->set_control (rtv->track()->rec_enable_control(), !rtv->track()->rec_enable_control()->get_value(), Controllable::UseGroup);
433 EditorRoutes::on_tv_rec_safe_toggled (std::string const & path_string)
435 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
436 TimeAxisView* tv = row[_columns.tv];
437 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
439 if (rtv && rtv->track() && !rtv->track()->record_enabled()) {
441 boost::shared_ptr<RouteList> rl (new RouteList);
442 rl->push_back (rtv->route());
443 _session->set_record_safe (rl, !rtv->track()->record_safe(), Session::rt_cleanup);
448 EditorRoutes::on_tv_mute_enable_toggled (std::string const & path_string)
450 // Get the model row that has been toggled.
451 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
453 TimeAxisView *tv = row[_columns.tv];
454 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
457 _session->set_control (rtv->route()->mute_control(), rtv->route()->mute_control()->get_value() ? 0.0 : 1.0, Controllable::UseGroup);
462 EditorRoutes::on_tv_solo_enable_toggled (std::string const & path_string)
464 // Get the model row that has been toggled.
465 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
467 TimeAxisView *tv = row[_columns.tv];
468 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
471 rtv->route()->solo_control()->set_value (rtv->route()->soloed() ? 0.0 : 1.0, Controllable::UseGroup);
476 EditorRoutes::on_tv_solo_isolate_toggled (std::string const & path_string)
478 // Get the model row that has been toggled.
479 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
481 TimeAxisView *tv = row[_columns.tv];
482 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
485 rtv->route()->solo_isolate_control()->set_value (rtv->route()->solo_isolate_control()->get_value() ? 0.0 : 1.0, Controllable::UseGroup);
490 EditorRoutes::on_tv_solo_safe_toggled (std::string const & path_string)
492 // Get the model row that has been toggled.
493 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
495 TimeAxisView *tv = row[_columns.tv];
496 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
499 rtv->route()->solo_safe_control()->set_value (rtv->route()->solo_safe_control()->get_value() ? 0.0 : 1.0, Controllable::UseGroup);
504 EditorRoutes::build_menu ()
506 using namespace Menu_Helpers;
511 MenuList& items = _menu->items();
512 _menu->set_name ("ArdourContextMenu");
514 items.push_back (MenuElem (_("Show All"), sigc::mem_fun (*this, &EditorRoutes::show_all_routes)));
515 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun (*this, &EditorRoutes::hide_all_routes)));
516 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiotracks)));
517 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiotracks)));
518 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiobus)));
519 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiobus)));
520 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_miditracks)));
521 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_miditracks)));
522 items.push_back (MenuElem (_("Only Show Tracks with Regions Under Playhead"), sigc::mem_fun (*this, &EditorRoutes::show_tracks_with_regions_at_playhead)));
526 EditorRoutes::show_menu ()
532 _menu->popup (1, gtk_get_current_event_time());
536 EditorRoutes::redisplay_real ()
538 TreeModel::Children rows = _model->children();
539 TreeModel::Children::iterator i;
542 /* n will be the count of tracks plus children (updated by TimeAxisView::show_at),
543 * so we will use that to know where to put things.
547 for (n = 0, position = 0, i = rows.begin(); i != rows.end(); ++i) {
548 TimeAxisView *tv = (*i)[_columns.tv];
549 boost::shared_ptr<Route> route = (*i)[_columns.route];
552 // just a "title" row
556 bool visible = tv->marked_for_display ();
558 /* show or hide the TimeAxisView */
560 position += tv->show_at (position, n, &_editor->edit_controls_vbox);
568 /* whenever we go idle, update the track view list to reflect the new order.
569 * we can't do this here, because we could mess up something that is traversing
570 * the track order and has caused a redisplay of the list.
572 Glib::signal_idle().connect (sigc::mem_fun (*_editor, &Editor::sync_track_view_list_and_routes));
574 _editor->reset_controls_layout_height (position);
575 _editor->reset_controls_layout_width ();
576 _editor->_full_canvas_height = position;
578 if ((_editor->vertical_adjustment.get_value() + _editor->_visible_canvas_height) > _editor->vertical_adjustment.get_upper()) {
580 * We're increasing the size of the canvas while the bottom is visible.
581 * We scroll down to keep in step with the controls layout.
583 _editor->vertical_adjustment.set_value (_editor->_full_canvas_height - _editor->_visible_canvas_height);
588 EditorRoutes::redisplay ()
590 if (!_session || _session->deletion_in_progress()) {
595 _redisplay_on_resume = true;
599 // model deprecated g_atomic_int_exchange_and_add(, 1)
600 g_atomic_int_inc(const_cast<gint*>(&_redisplay_active));
601 if (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 1)) {
602 /* recursive re-display can happen if redisplay shows/hides a TrackView
603 * which has children and their display status changes as result.
610 while (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 0)) {
611 g_atomic_int_set(const_cast<gint*>(&_redisplay_active), 1);
617 EditorRoutes::row_deleted (Gtk::TreeModel::Path const &)
619 if (!_session || _session->deletion_in_progress()) {
622 /* this happens as the second step of a DnD within the treeview, and
623 * when a route is actually removed. we don't differentiate between
626 * note that the sync_orders_keys() step may not actually change any
627 * RID's (e.g. the last track may be removed, so all other tracks keep
628 * the same RID), which means that no redisplay would happen. so we
629 * have to force a redisplay.
632 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview row deleted\n");
635 sync_order_keys_from_treeview ();
639 EditorRoutes::reordered (TreeModel::Path const &, TreeModel::iterator const &, int* /*what*/)
641 /* reordering implies that RID's will change, so sync_order_keys() will
645 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview reordered\n");
646 sync_order_keys_from_treeview ();
650 EditorRoutes::visible_changed (std::string const & path)
652 if (_session && _session->deletion_in_progress()) {
659 if ((iter = _model->get_iter (path))) {
660 TimeAxisView* tv = (*iter)[_columns.tv];
662 bool visible = (*iter)[_columns.visible];
664 if (tv->set_marked_for_display (!visible)) {
665 update_visibility ();
672 EditorRoutes::active_changed (std::string const & path)
674 if (_session && _session->deletion_in_progress ()) {
678 Gtk::TreeModel::Row row = *_model->get_iter (path);
679 boost::shared_ptr<Route> route = row[_columns.route];
680 bool const active = row[_columns.active];
681 route->set_active (!active, this);
685 EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
687 PBD::Unwinder<bool> at (_adding_routes, true);
688 bool from_scratch = (_model->children().size() == 0);
689 Gtk::TreeModel::Children::iterator insert_iter = _model->children().end();
691 for (Gtk::TreeModel::Children::iterator it = _model->children().begin(); it != _model->children().end(); ++it) {
692 boost::shared_ptr<Route> r = (*it)[_columns.route];
694 if (r->order_key() == (routes.front()->route()->order_key() + routes.size())) {
702 _display.set_model (Glib::RefPtr<ListStore>());
704 for (list<RouteTimeAxisView*>::iterator x = routes.begin(); x != routes.end(); ++x) {
706 boost::shared_ptr<MidiTrack> midi_trk = boost::dynamic_pointer_cast<MidiTrack> ((*x)->route());
708 TreeModel::Row row = *(_model->insert (insert_iter));
710 row[_columns.text] = (*x)->route()->name();
711 row[_columns.visible] = (*x)->marked_for_display();
712 row[_columns.active] = (*x)->route()->active ();
713 row[_columns.tv] = *x;
714 row[_columns.route] = (*x)->route ();
715 row[_columns.is_track] = (boost::dynamic_pointer_cast<Track> ((*x)->route()) != 0);
718 row[_columns.is_input_active] = midi_trk->input_active ();
719 row[_columns.is_midi] = true;
721 row[_columns.is_input_active] = false;
722 row[_columns.is_midi] = false;
725 row[_columns.mute_state] = (*x)->route()->muted() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off;
726 row[_columns.solo_state] = RouteUI::solo_active_state ((*x)->route());
727 row[_columns.solo_visible] = !(*x)->route()->is_master ();
728 row[_columns.solo_isolate_state] = (*x)->route()->solo_isolate_control()->solo_isolated();
729 row[_columns.solo_safe_state] = (*x)->route()->solo_safe_control()->solo_safe();
730 row[_columns.name_editable] = true;
732 boost::weak_ptr<Route> wr ((*x)->route());
734 (*x)->route()->gui_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::handle_gui_changes, this, _1, _2), gui_context());
735 (*x)->route()->PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, wr), gui_context());
737 if ((*x)->is_track()) {
738 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> ((*x)->route());
739 t->rec_enable_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
740 t->rec_safe_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
743 if ((*x)->is_midi_track()) {
744 boost::shared_ptr<MidiTrack> t = boost::dynamic_pointer_cast<MidiTrack> ((*x)->route());
745 t->StepEditStatusChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
746 t->InputActiveChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_input_active_display, this), gui_context());
749 (*x)->route()->mute_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_mute_display, this), gui_context());
750 (*x)->route()->solo_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_display, this), gui_context());
751 (*x)->route()->solo_isolate_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_isolate_display, this), gui_context());
752 (*x)->route()->solo_safe_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_safe_display, this), gui_context());
754 (*x)->route()->active_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_active_display, this), gui_context ());
758 update_rec_display ();
759 update_mute_display ();
760 update_solo_display ();
761 update_solo_isolate_display ();
762 update_solo_safe_display ();
763 update_input_active_display ();
764 update_active_display ();
766 _display.set_model (_model);
768 /* now update route order keys from the treeview/track display order */
770 sync_order_keys_from_treeview ();
775 EditorRoutes::handle_gui_changes (string const & what, void*)
777 if (_adding_routes) {
781 if (what == "track_height") {
782 /* Optional :make tracks change height while it happens, instead
788 if (what == "visible_tracks") {
794 EditorRoutes::route_removed (TimeAxisView *tv)
796 ENSURE_GUI_THREAD (*this, &EditorRoutes::route_removed, tv)
798 TreeModel::Children rows = _model->children();
799 TreeModel::Children::iterator ri;
801 for (ri = rows.begin(); ri != rows.end(); ++ri) {
802 if ((*ri)[_columns.tv] == tv) {
803 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
809 /* the deleted signal for the treeview/model will take
815 EditorRoutes::route_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Route> r)
817 if (!what_changed.contains (ARDOUR::Properties::name)) {
821 ENSURE_GUI_THREAD (*this, &EditorRoutes::route_name_changed, r)
823 boost::shared_ptr<Route> route = r.lock ();
829 TreeModel::Children rows = _model->children();
830 TreeModel::Children::iterator i;
832 for (i = rows.begin(); i != rows.end(); ++i) {
833 boost::shared_ptr<Route> t = (*i)[_columns.route];
835 (*i)[_columns.text] = route->name();
842 EditorRoutes::update_active_display ()
844 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
845 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
850 EditorRoutes::update_visibility ()
852 TreeModel::Children rows = _model->children();
853 TreeModel::Children::iterator i;
857 for (i = rows.begin(); i != rows.end(); ++i) {
858 TimeAxisView *tv = (*i)[_columns.tv];
859 (*i)[_columns.visible] = tv->marked_for_display ();
862 /* force route order keys catch up with visibility changes
865 sync_order_keys_from_treeview ();
869 EditorRoutes::hide_track_in_display (TimeAxisView& tv)
871 TreeModel::Children rows = _model->children();
872 TreeModel::Children::iterator i;
874 for (i = rows.begin(); i != rows.end(); ++i) {
875 if ((*i)[_columns.tv] == &tv) {
876 tv.set_marked_for_display (false);
877 (*i)[_columns.visible] = false;
885 EditorRoutes::show_track_in_display (TimeAxisView& tv)
887 TreeModel::Children rows = _model->children();
888 TreeModel::Children::iterator i;
891 for (i = rows.begin(); i != rows.end(); ++i) {
892 if ((*i)[_columns.tv] == &tv) {
893 tv.set_marked_for_display (true);
894 (*i)[_columns.visible] = true;
902 EditorRoutes::reset_remote_control_ids ()
904 if (Config->get_remote_model() == UserOrdered || !_session || _session->deletion_in_progress()) {
908 TreeModel::Children rows = _model->children();
915 DEBUG_TRACE (DEBUG::OrderKeys, "editor reset remote control ids\n");
917 TreeModel::Children::iterator ri;
918 bool rid_change = false;
920 uint32_t invisible_key = UINT32_MAX;
922 for (ri = rows.begin(); ri != rows.end(); ++ri) {
924 /* skip two special values */
926 if (rid == Route::MasterBusRemoteControlID) {
930 if (rid == Route::MonitorBusRemoteControlID) {
934 boost::shared_ptr<Route> route = (*ri)[_columns.route];
935 bool visible = (*ri)[_columns.visible];
937 if (!route->is_master() && !route->is_monitor()) {
939 uint32_t new_rid = (visible ? rid : invisible_key--);
941 if (new_rid != route->remote_control_id()) {
942 route->set_remote_control_id_explicit (new_rid);
954 /* tell the world that we changed the remote control IDs */
955 _session->notify_remote_id_change ();
961 EditorRoutes::sync_order_keys_from_treeview ()
963 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
967 TreeModel::Children rows = _model->children();
974 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync order keys from treeview\n");
976 TreeModel::Children::iterator ri;
977 bool changed = false;
978 bool rid_change = false;
981 uint32_t invisible_key = UINT32_MAX;
983 for (ri = rows.begin(); ri != rows.end(); ++ri) {
985 boost::shared_ptr<Route> route = (*ri)[_columns.route];
986 bool visible = (*ri)[_columns.visible];
988 uint32_t old_key = route->order_key ();
990 if (order != old_key) {
991 route->set_order_key (order);
996 if ((Config->get_remote_model() == MixerOrdered) && !route->is_master() && !route->is_monitor()) {
998 uint32_t new_rid = (visible ? rid : invisible_key--);
1000 if (new_rid != route->remote_control_id()) {
1001 route->set_remote_control_id_explicit (new_rid);
1015 /* tell the world that we changed the editor sort keys */
1016 _session->sync_order_keys ();
1020 /* tell the world that we changed the remote control IDs */
1021 _session->notify_remote_id_change ();
1026 EditorRoutes::sync_treeview_from_order_keys ()
1028 /* Some route order key(s) have been changed, make sure that
1029 we update out tree/list model and GUI to reflect the change.
1032 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
1036 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync model from order keys.\n");
1038 /* we could get here after either a change in the Mixer or Editor sort
1039 * order, but either way, the mixer order keys reflect the intended
1040 * order for the GUI, so reorder the treeview model to match it.
1043 vector<int> neworder;
1044 TreeModel::Children rows = _model->children();
1045 uint32_t old_order = 0;
1046 bool changed = false;
1052 OrderingKeys sorted;
1054 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
1055 boost::shared_ptr<Route> route = (*ri)[_columns.route];
1056 sorted.push_back (OrderKeys (old_order, route->order_key ()));
1059 SortByNewDisplayOrder cmp;
1061 sort (sorted.begin(), sorted.end(), cmp);
1062 neworder.assign (sorted.size(), 0);
1066 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
1068 neworder[n] = sr->old_display_order;
1070 if (sr->old_display_order != n) {
1074 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("EDITOR change order from %1 to %2\n",
1075 sr->old_display_order, n));
1079 Unwinder<bool> uw (_ignore_reorder, true);
1080 _model->reorder (neworder);
1087 EditorRoutes::hide_all_tracks (bool /*with_select*/)
1089 TreeModel::Children rows = _model->children();
1090 TreeModel::Children::iterator i;
1092 DisplaySuspender ds;
1094 for (i = rows.begin(); i != rows.end(); ++i) {
1096 TreeModel::Row row = (*i);
1097 TimeAxisView *tv = row[_columns.tv];
1103 row[_columns.visible] = false;
1108 EditorRoutes::set_all_tracks_visibility (bool yn)
1110 TreeModel::Children rows = _model->children();
1111 TreeModel::Children::iterator i;
1113 DisplaySuspender ds;
1115 for (i = rows.begin(); i != rows.end(); ++i) {
1117 TreeModel::Row row = (*i);
1118 TimeAxisView* tv = row[_columns.tv];
1124 tv->set_marked_for_display (yn);
1125 (*i)[_columns.visible] = yn;
1128 /* force route order keys catch up with visibility changes
1131 sync_order_keys_from_treeview ();
1135 EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn)
1137 TreeModel::Children rows = _model->children();
1138 TreeModel::Children::iterator i;
1140 DisplaySuspender ds;
1142 for (i = rows.begin(); i != rows.end(); ++i) {
1144 TreeModel::Row row = (*i);
1145 TimeAxisView* tv = row[_columns.tv];
1147 AudioTimeAxisView* atv;
1148 MidiTimeAxisView* mtv;
1154 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1157 atv->set_marked_for_display (yn);
1158 (*i)[_columns.visible] = yn;
1162 if (atv->is_audio_track()) {
1163 atv->set_marked_for_display (yn);
1164 (*i)[_columns.visible] = yn;
1169 if (!atv->is_audio_track()) {
1170 atv->set_marked_for_display (yn);
1171 (*i)[_columns.visible] = yn;
1176 else if ((mtv = dynamic_cast<MidiTimeAxisView*>(tv)) != 0) {
1179 mtv->set_marked_for_display (yn);
1180 (*i)[_columns.visible] = yn;
1184 if (mtv->is_midi_track()) {
1185 mtv->set_marked_for_display (yn);
1186 (*i)[_columns.visible] = yn;
1193 /* force route order keys catch up with visibility changes
1196 sync_order_keys_from_treeview ();
1200 EditorRoutes::hide_all_routes ()
1202 set_all_tracks_visibility (false);
1206 EditorRoutes::show_all_routes ()
1208 set_all_tracks_visibility (true);
1212 EditorRoutes::show_all_audiotracks()
1214 set_all_audio_midi_visibility (1, true);
1217 EditorRoutes::hide_all_audiotracks ()
1219 set_all_audio_midi_visibility (1, false);
1223 EditorRoutes::show_all_audiobus ()
1225 set_all_audio_midi_visibility (2, true);
1228 EditorRoutes::hide_all_audiobus ()
1230 set_all_audio_midi_visibility (2, false);
1234 EditorRoutes::show_all_miditracks()
1236 set_all_audio_midi_visibility (3, true);
1239 EditorRoutes::hide_all_miditracks ()
1241 set_all_audio_midi_visibility (3, false);
1245 EditorRoutes::key_press (GdkEventKey* ev)
1247 TreeViewColumn *col;
1248 boost::shared_ptr<RouteList> rl (new RouteList);
1251 switch (ev->keyval) {
1253 case GDK_ISO_Left_Tab:
1255 /* If we appear to be editing something, leave that cleanly and appropriately. */
1256 if (name_editable) {
1257 name_editable->editing_done ();
1261 col = _display.get_column (_name_column); // select&focus on name column
1263 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
1264 treeview_select_previous (_display, _model, col);
1266 treeview_select_next (_display, _model, col);
1273 if (get_relevant_routes (rl)) {
1274 _session->set_controls (route_list_to_control_list (rl, &Route::mute_control), rl->front()->muted() ? 0.0 : 1.0, Controllable::NoGroup);
1280 if (get_relevant_routes (rl)) {
1281 _session->set_controls (route_list_to_control_list (rl, &Route::solo_control), rl->front()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
1287 if (get_relevant_routes (rl)) {
1288 for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
1289 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*r);
1291 _session->set_controls (route_list_to_control_list (rl, &Track::rec_enable_control), !t->rec_enable_control()->get_value(), Controllable::NoGroup);
1306 EditorRoutes::get_relevant_routes (boost::shared_ptr<RouteList> rl)
1309 RouteTimeAxisView* rtv;
1310 RefPtr<TreeSelection> selection = _display.get_selection();
1314 if (selection->count_selected_rows() != 0) {
1318 RefPtr<TreeModel> tm = RefPtr<TreeModel>::cast_dynamic (_model);
1319 iter = selection->get_selected (tm);
1322 /* use mouse pointer */
1327 _display.get_pointer (x, y);
1328 _display.convert_widget_to_bin_window_coords (x, y, bx, by);
1330 if (_display.get_path_at_pos (bx, by, path)) {
1331 iter = _model->get_iter (path);
1336 tv = (*iter)[_columns.tv];
1338 rtv = dynamic_cast<RouteTimeAxisView*>(tv);
1340 rl->push_back (rtv->route());
1345 return !rl->empty();
1349 EditorRoutes::button_press (GdkEventButton* ev)
1351 if (Keyboard::is_context_menu_event (ev)) {
1356 TreeModel::Path path;
1357 TreeViewColumn *tvc;
1361 if (!_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, tvc, cell_x, cell_y)) {
1362 /* cancel selection */
1363 _display.get_selection()->unselect_all ();
1364 /* end any editing by grabbing focus */
1365 _display.grab_focus ();
1369 //Scroll editor canvas to selected track
1370 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1372 Gtk::TreeModel::Row row = *_model->get_iter (path);
1373 TimeAxisView *tv = row[_columns.tv];
1376 _editor->ensure_time_axis_view_is_visible (*tv, true);
1384 EditorRoutes::selection_changed ()
1386 _editor->begin_reversible_selection_op (X_("Select Track from Route List"));
1388 if (_display.get_selection()->count_selected_rows() > 0) {
1391 TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
1392 TrackViewList selected;
1394 _editor->get_selection().clear_regions ();
1396 for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
1398 if ((iter = _model->get_iter (*i))) {
1400 TimeAxisView* tv = (*iter)[_columns.tv];
1401 selected.push_back (tv);
1406 _editor->get_selection().set (selected);
1407 _editor->ensure_time_axis_view_is_visible (*(selected.front()), true);
1410 _editor->get_selection().clear_tracks ();
1413 _editor->commit_reversible_selection_op ();
1417 EditorRoutes::selection_filter (Glib::RefPtr<TreeModel> const &, TreeModel::Path const&, bool /*selected*/)
1419 if (selection_countdown) {
1420 if (--selection_countdown == 0) {
1423 /* no selection yet ... */
1430 struct EditorOrderRouteSorter
1432 bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
1433 if (a->is_master()) {
1434 /* master before everything else */
1436 } else if (b->is_master()) {
1437 /* everything else before master */
1440 return a->order_key () < b->order_key ();
1445 EditorRoutes::initial_display ()
1447 DisplaySuspender ds;
1454 RouteList r (*_session->get_routes());
1456 r.sort (EditorOrderRouteSorter ());
1457 _editor->add_routes (r);
1461 EditorRoutes::display_drag_data_received (const RefPtr<Gdk::DragContext>& context,
1463 const SelectionData& data,
1464 guint info, guint time)
1466 if (data.get_target() == "GTK_TREE_MODEL_ROW") {
1467 _display.on_drag_data_received (context, x, y, data, info, time);
1471 context->drag_finish (true, false, time);
1475 EditorRoutes::move_selected_tracks (bool up)
1477 if (_editor->selection->tracks.empty()) {
1481 typedef std::pair<TimeAxisView*,boost::shared_ptr<Route> > ViewRoute;
1482 std::list<ViewRoute> view_routes;
1483 std::vector<int> neworder;
1484 TreeModel::Children rows = _model->children();
1485 TreeModel::Children::iterator ri;
1487 for (ri = rows.begin(); ri != rows.end(); ++ri) {
1488 TimeAxisView* tv = (*ri)[_columns.tv];
1489 boost::shared_ptr<Route> route = (*ri)[_columns.route];
1491 view_routes.push_back (ViewRoute (tv, route));
1494 list<ViewRoute>::iterator trailing;
1495 list<ViewRoute>::iterator leading;
1499 trailing = view_routes.begin();
1500 leading = view_routes.begin();
1504 while (leading != view_routes.end()) {
1505 if (_editor->selection->selected (leading->first)) {
1506 view_routes.insert (trailing, ViewRoute (leading->first, leading->second));
1507 leading = view_routes.erase (leading);
1516 /* if we could use reverse_iterator in list::insert, this code
1517 would be a beautiful reflection of the code above. but we can't
1518 and so it looks like a bit of a mess.
1521 trailing = view_routes.end();
1522 leading = view_routes.end();
1524 --leading; if (leading == view_routes.begin()) { return; }
1530 if (_editor->selection->selected (leading->first)) {
1531 list<ViewRoute>::iterator tmp;
1533 /* need to insert *after* trailing, not *before* it,
1534 which is what insert (iter, val) normally does.
1540 view_routes.insert (tmp, ViewRoute (leading->first, leading->second));
1542 /* can't use iter = cont.erase (iter); form here, because
1543 we need iter to move backwards.
1551 if (leading == view_routes.begin()) {
1552 /* the one we've just inserted somewhere else
1553 was the first in the list. erase this copy,
1554 and then break, because we're done.
1559 view_routes.erase (leading);
1568 if (leading == view_routes.begin()) {
1577 for (leading = view_routes.begin(); leading != view_routes.end(); ++leading) {
1578 uint32_t order = leading->second->order_key ();
1579 neworder.push_back (order);
1583 DEBUG_TRACE (DEBUG::OrderKeys, "New order after moving tracks:\n");
1584 for (vector<int>::iterator i = neworder.begin(); i != neworder.end(); ++i) {
1585 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("\t%1\n", *i));
1587 DEBUG_TRACE (DEBUG::OrderKeys, "-------\n");
1589 for (vector<int>::iterator i = neworder.begin(); i != neworder.end(); ++i) {
1590 if (*i >= (int) neworder.size()) {
1591 cerr << "Trying to move something to " << *i << " of " << neworder.size() << endl;
1593 assert (*i < (int) neworder.size ());
1597 _model->reorder (neworder);
1601 EditorRoutes::update_input_active_display ()
1603 TreeModel::Children rows = _model->children();
1604 TreeModel::Children::iterator i;
1606 for (i = rows.begin(); i != rows.end(); ++i) {
1607 boost::shared_ptr<Route> route = (*i)[_columns.route];
1609 if (boost::dynamic_pointer_cast<Track> (route)) {
1610 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
1613 (*i)[_columns.is_input_active] = mt->input_active();
1620 EditorRoutes::update_rec_display ()
1622 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1623 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1628 EditorRoutes::idle_update_mute_rec_solo_etc()
1630 g_atomic_int_set (const_cast<gint*>(&_queue_tv_update), 0);
1631 TreeModel::Children rows = _model->children();
1632 TreeModel::Children::iterator i;
1634 for (i = rows.begin(); i != rows.end(); ++i) {
1635 boost::shared_ptr<Route> route = (*i)[_columns.route];
1636 (*i)[_columns.mute_state] = RouteUI::mute_active_state (_session, route);
1637 (*i)[_columns.solo_state] = RouteUI::solo_active_state (route);
1638 (*i)[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (route) ? 1 : 0;
1639 (*i)[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (route) ? 1 : 0;
1640 (*i)[_columns.active] = route->active ();
1642 boost::shared_ptr<Track> trk (boost::dynamic_pointer_cast<Track>(route));
1645 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
1647 if (trk->rec_enable_control()->get_value()) {
1648 if (_session->record_status() == Session::Recording) {
1649 (*i)[_columns.rec_state] = 1;
1651 (*i)[_columns.rec_state] = 2;
1653 } else if (mt && mt->step_editing()) {
1654 (*i)[_columns.rec_state] = 3;
1656 (*i)[_columns.rec_state] = 0;
1659 (*i)[_columns.rec_safe] = !trk->rec_safe_control()->get_value();
1660 (*i)[_columns.name_editable] = !trk->rec_enable_control()->get_value();
1664 return false; // do not call again (until needed)
1669 EditorRoutes::update_mute_display ()
1671 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1672 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1677 EditorRoutes::update_solo_display ()
1679 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1680 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1685 EditorRoutes::update_solo_isolate_display ()
1687 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1688 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1693 EditorRoutes::update_solo_safe_display ()
1695 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1696 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1701 EditorRoutes::views () const
1703 list<TimeAxisView*> v;
1704 for (TreeModel::Children::iterator i = _model->children().begin(); i != _model->children().end(); ++i) {
1705 v.push_back ((*i)[_columns.tv]);
1712 EditorRoutes::clear ()
1714 _display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
1716 _display.set_model (_model);
1720 EditorRoutes::name_edit_started (CellEditable* ce, const Glib::ustring&)
1724 /* give it a special name */
1726 Gtk::Entry *e = dynamic_cast<Gtk::Entry*> (ce);
1729 e->set_name (X_("RouteNameEditorEntry"));
1734 EditorRoutes::name_edit (std::string const & path, std::string const & new_text)
1738 TreeIter iter = _model->get_iter (path);
1744 boost::shared_ptr<Route> route = (*iter)[_columns.route];
1746 if (route && route->name() != new_text) {
1747 route->set_name (new_text);
1752 EditorRoutes::solo_changed_so_update_mute ()
1754 update_mute_display ();
1758 EditorRoutes::show_tracks_with_regions_at_playhead ()
1760 boost::shared_ptr<RouteList> const r = _session->get_routes_with_regions_at (_session->transport_frame ());
1762 set<TimeAxisView*> show;
1763 for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
1764 TimeAxisView* tav = _editor->axis_view_from_route (*i);
1770 DisplaySuspender ds;
1772 TreeModel::Children rows = _model->children ();
1773 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
1774 TimeAxisView* tv = (*i)[_columns.tv];
1775 bool to_show = (show.find (tv) != show.end());
1777 tv->set_marked_for_display (to_show);
1778 (*i)[_columns.visible] = to_show;
1781 /* force route order keys catch up with visibility changes
1784 sync_order_keys_from_treeview ();
1788 EditorRoutes::plugin_setup (boost::shared_ptr<Route> r, boost::shared_ptr<PluginInsert> pi, ARDOUR::Route::PluginSetupOptions flags)
1790 PluginSetupDialog psd (r, pi, flags);