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/audio_track.h"
32 #include "ardour/midi_track.h"
33 #include "ardour/route.h"
34 #include "ardour/session.h"
35 #include "ardour/solo_isolate_control.h"
36 #include "ardour/utils.h"
38 #include "gtkmm2ext/cell_renderer_pixbuf_multi.h"
39 #include "gtkmm2ext/cell_renderer_pixbuf_toggle.h"
40 #include "gtkmm2ext/treeutils.h"
43 #include "ardour_ui.h"
44 #include "audio_time_axis.h"
46 #include "editor_group_tabs.h"
47 #include "editor_routes.h"
48 #include "gui_thread.h"
50 #include "midi_time_axis.h"
51 #include "mixer_strip.h"
52 #include "plugin_setup_dialog.h"
53 #include "route_sorter.h"
60 using namespace ARDOUR;
61 using namespace ARDOUR_UI_UTILS;
64 using namespace Gtkmm2ext;
66 using Gtkmm2ext::Keyboard;
74 EditorRoutes::EditorRoutes (Editor* e)
76 , _ignore_reorder (false)
77 , _no_redisplay (false)
78 , _adding_routes (false)
79 , _route_deletion_in_progress (false)
80 , _redisplay_on_resume (false)
81 , _redisplay_active (0)
82 , _queue_tv_update (0)
85 , selection_countdown (0)
88 static const int column_width = 22;
90 _scroller.add (_display);
91 _scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
93 _model = ListStore::create (_columns);
94 _display.set_model (_model);
96 // Record enable toggle
97 CellRendererPixbufMulti* rec_col_renderer = manage (new CellRendererPixbufMulti());
99 rec_col_renderer->set_pixbuf (0, ::get_icon("record-normal-disabled"));
100 rec_col_renderer->set_pixbuf (1, ::get_icon("record-normal-in-progress"));
101 rec_col_renderer->set_pixbuf (2, ::get_icon("record-normal-enabled"));
102 rec_col_renderer->set_pixbuf (3, ::get_icon("record-step"));
103 rec_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_enable_changed));
105 TreeViewColumn* rec_state_column = manage (new TreeViewColumn("R", *rec_col_renderer));
107 rec_state_column->add_attribute(rec_col_renderer->property_state(), _columns.rec_state);
108 rec_state_column->add_attribute(rec_col_renderer->property_visible(), _columns.is_track);
110 rec_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
111 rec_state_column->set_alignment(ALIGN_CENTER);
112 rec_state_column->set_expand(false);
113 rec_state_column->set_fixed_width(column_width);
116 // Record safe toggle
117 CellRendererPixbufMulti* rec_safe_renderer = manage (new CellRendererPixbufMulti ());
119 rec_safe_renderer->set_pixbuf (0, ::get_icon("rec-safe-disabled"));
120 rec_safe_renderer->set_pixbuf (1, ::get_icon("rec-safe-enabled"));
121 rec_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_safe_toggled));
123 TreeViewColumn* rec_safe_column = manage (new TreeViewColumn(_("RS"), *rec_safe_renderer));
124 rec_safe_column->add_attribute(rec_safe_renderer->property_state(), _columns.rec_safe);
125 rec_safe_column->add_attribute(rec_safe_renderer->property_visible(), _columns.is_track);
126 rec_safe_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
127 rec_safe_column->set_alignment(ALIGN_CENTER);
128 rec_safe_column->set_expand(false);
129 rec_safe_column->set_fixed_width(column_width);
134 CellRendererPixbufMulti* input_active_col_renderer = manage (new CellRendererPixbufMulti());
135 input_active_col_renderer->set_pixbuf (0, ::get_icon("midi-input-inactive"));
136 input_active_col_renderer->set_pixbuf (1, ::get_icon("midi-input-active"));
137 input_active_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_input_active_changed));
139 TreeViewColumn* input_active_column = manage (new TreeViewColumn ("I", *input_active_col_renderer));
141 input_active_column->add_attribute(input_active_col_renderer->property_state(), _columns.is_input_active);
142 input_active_column->add_attribute (input_active_col_renderer->property_visible(), _columns.is_midi);
144 input_active_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
145 input_active_column->set_alignment(ALIGN_CENTER);
146 input_active_column->set_expand(false);
147 input_active_column->set_fixed_width(column_width);
149 // Mute enable toggle
150 CellRendererPixbufMulti* mute_col_renderer = manage (new CellRendererPixbufMulti());
152 mute_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("mute-disabled"));
153 mute_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("muted-by-others"));
154 mute_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("mute-enabled"));
155 mute_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_mute_enable_toggled));
157 TreeViewColumn* mute_state_column = manage (new TreeViewColumn("M", *mute_col_renderer));
159 mute_state_column->add_attribute(mute_col_renderer->property_state(), _columns.mute_state);
160 mute_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
161 mute_state_column->set_alignment(ALIGN_CENTER);
162 mute_state_column->set_expand(false);
163 mute_state_column->set_fixed_width(15);
165 // Solo enable toggle
166 CellRendererPixbufMulti* solo_col_renderer = manage (new CellRendererPixbufMulti());
168 solo_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("solo-disabled"));
169 solo_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("solo-enabled"));
170 solo_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("soloed-by-others"));
171 solo_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_enable_toggled));
173 TreeViewColumn* solo_state_column = manage (new TreeViewColumn("S", *solo_col_renderer));
175 solo_state_column->add_attribute(solo_col_renderer->property_state(), _columns.solo_state);
176 solo_state_column->add_attribute(solo_col_renderer->property_visible(), _columns.solo_visible);
177 solo_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
178 solo_state_column->set_alignment(ALIGN_CENTER);
179 solo_state_column->set_expand(false);
180 solo_state_column->set_fixed_width(column_width);
182 // Solo isolate toggle
183 CellRendererPixbufMulti* solo_iso_renderer = manage (new CellRendererPixbufMulti());
185 solo_iso_renderer->set_pixbuf (0, ::get_icon("solo-isolate-disabled"));
186 solo_iso_renderer->set_pixbuf (1, ::get_icon("solo-isolate-enabled"));
187 solo_iso_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_isolate_toggled));
189 TreeViewColumn* solo_isolate_state_column = manage (new TreeViewColumn("SI", *solo_iso_renderer));
191 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_state(), _columns.solo_isolate_state);
192 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_visible(), _columns.solo_visible);
193 solo_isolate_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
194 solo_isolate_state_column->set_alignment(ALIGN_CENTER);
195 solo_isolate_state_column->set_expand(false);
196 solo_isolate_state_column->set_fixed_width(column_width);
199 CellRendererPixbufMulti* solo_safe_renderer = manage (new CellRendererPixbufMulti ());
201 solo_safe_renderer->set_pixbuf (0, ::get_icon("solo-safe-disabled"));
202 solo_safe_renderer->set_pixbuf (1, ::get_icon("solo-safe-enabled"));
203 solo_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_safe_toggled));
205 TreeViewColumn* solo_safe_state_column = manage (new TreeViewColumn(_("SS"), *solo_safe_renderer));
206 solo_safe_state_column->add_attribute(solo_safe_renderer->property_state(), _columns.solo_safe_state);
207 solo_safe_state_column->add_attribute(solo_safe_renderer->property_visible(), _columns.solo_visible);
208 solo_safe_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
209 solo_safe_state_column->set_alignment(ALIGN_CENTER);
210 solo_safe_state_column->set_expand(false);
211 solo_safe_state_column->set_fixed_width(column_width);
213 _name_column = _display.append_column ("", _columns.text) - 1;
214 _visible_column = _display.append_column ("", _columns.visible) - 1;
215 _active_column = _display.append_column ("", _columns.active) - 1;
217 _display.append_column (*input_active_column);
218 _display.append_column (*rec_state_column);
219 _display.append_column (*rec_safe_column);
220 _display.append_column (*mute_state_column);
221 _display.append_column (*solo_state_column);
222 _display.append_column (*solo_isolate_state_column);
223 _display.append_column (*solo_safe_state_column);
230 { 0, _("Name"), _("Track/Bus Name") },
231 { 1, S_("Visible|V"), _("Track/Bus visible ?") },
232 { 2, S_("Active|A"), _("Track/Bus active ?") },
233 { 3, S_("MidiInput|I"), _("MIDI input enabled") },
234 { 4, S_("Rec|R"), _("Record enabled") },
235 { 5, S_("Rec|RS"), _("Record Safe") },
236 { 6, S_("Mute|M"), _("Muted") },
237 { 7, S_("Solo|S"), _("Soloed") },
238 { 8, S_("SoloIso|SI"), _("Solo Isolated") },
239 { 9, S_("SoloLock|SS"), _("Solo Safe (Locked)") },
243 for (int i = 0; ci[i].index >= 0; ++i) {
244 col = _display.get_column (ci[i].index);
245 l = manage (new Label (ci[i].label));
246 set_tooltip (*l, ci[i].tooltip);
247 col->set_widget (*l);
251 _display.set_headers_visible (true);
252 _display.get_selection()->set_mode (SELECTION_SINGLE);
253 _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRoutes::selection_filter));
254 _display.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::selection_changed));
255 _display.set_reorderable (true);
256 _display.set_name (X_("EditGroupList"));
257 _display.set_rules_hint (true);
258 _display.set_size_request (100, -1);
259 _display.add_object_drag (_columns.route.index(), "routes");
261 CellRendererText* name_cell = dynamic_cast<CellRendererText*> (_display.get_column_cell_renderer (_name_column));
264 name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit_started));
266 TreeViewColumn* name_column = _display.get_column (_name_column);
268 assert (name_column);
270 name_column->add_attribute (name_cell->property_editable(), _columns.name_editable);
271 name_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
272 name_column->set_expand(true);
273 name_column->set_min_width(50);
275 name_cell->property_editable() = true;
276 name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit));
278 // Set the visible column cell renderer to radio toggle
279 CellRendererToggle* visible_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_visible_column));
281 visible_cell->property_activatable() = true;
282 visible_cell->property_radio() = false;
283 visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::visible_changed));
285 TreeViewColumn* visible_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_visible_column));
286 visible_col->set_expand(false);
287 visible_col->set_sizing(TREE_VIEW_COLUMN_FIXED);
288 visible_col->set_fixed_width(30);
289 visible_col->set_alignment(ALIGN_CENTER);
291 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_active_column));
293 active_cell->property_activatable() = true;
294 active_cell->property_radio() = false;
295 active_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::active_changed));
297 TreeViewColumn* active_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_active_column));
298 active_col->set_expand (false);
299 active_col->set_sizing (TREE_VIEW_COLUMN_FIXED);
300 active_col->set_fixed_width (30);
301 active_col->set_alignment (ALIGN_CENTER);
303 _model->signal_row_deleted().connect (sigc::mem_fun (*this, &EditorRoutes::row_deleted));
304 _model->signal_rows_reordered().connect (sigc::mem_fun (*this, &EditorRoutes::reordered));
306 _display.signal_button_press_event().connect (sigc::mem_fun (*this, &EditorRoutes::button_press), false);
307 _scroller.signal_key_press_event().connect (sigc::mem_fun(*this, &EditorRoutes::key_press), false);
309 _scroller.signal_focus_in_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_in), false);
310 _scroller.signal_focus_out_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_out));
312 _display.signal_enter_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::enter_notify), false);
313 _display.signal_leave_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::leave_notify), false);
315 _display.set_enable_search (false);
317 Route::PluginSetup.connect_same_thread (*this, boost::bind (&EditorRoutes::plugin_setup, this, _1, _2, _3));
318 Stripable::PresentationInfoChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::sync_treeview_from_presentation_info, this), gui_context());
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_presentation_info_from_treeview() step may not
627 * actually change any presentation info (e.g. the last track may be
628 * removed, so all other tracks keep the same presentation info), which
629 * means that no redisplay would happen. so we have to force a
633 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview row deleted\n");
636 sync_presentation_info_from_treeview ();
640 EditorRoutes::reordered (TreeModel::Path const &, TreeModel::iterator const &, int* /*what*/)
642 /* reordering implies that RID's will change, so
643 sync_presentation_info_from_treeview() will cause a redisplay.
646 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview reordered\n");
647 sync_presentation_info_from_treeview ();
651 EditorRoutes::visible_changed (std::string const & path)
653 if (_session && _session->deletion_in_progress()) {
660 if ((iter = _model->get_iter (path))) {
661 TimeAxisView* tv = (*iter)[_columns.tv];
663 bool visible = (*iter)[_columns.visible];
665 if (tv->set_marked_for_display (!visible)) {
666 update_visibility ();
673 EditorRoutes::active_changed (std::string const & path)
675 if (_session && _session->deletion_in_progress ()) {
679 Gtk::TreeModel::Row row = *_model->get_iter (path);
680 boost::shared_ptr<Route> route = row[_columns.route];
681 bool const active = row[_columns.active];
682 route->set_active (!active, this);
686 EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
688 PBD::Unwinder<bool> at (_adding_routes, true);
689 bool from_scratch = (_model->children().size() == 0);
690 Gtk::TreeModel::Children::iterator insert_iter = _model->children().end();
692 for (Gtk::TreeModel::Children::iterator it = _model->children().begin(); it != _model->children().end(); ++it) {
693 boost::shared_ptr<Route> r = (*it)[_columns.route];
695 if (r->presentation_info().group_order() == (routes.front()->route()->presentation_info().group_order() + routes.size())) {
703 _display.set_model (Glib::RefPtr<ListStore>());
705 for (list<RouteTimeAxisView*>::iterator x = routes.begin(); x != routes.end(); ++x) {
707 boost::shared_ptr<MidiTrack> midi_trk = boost::dynamic_pointer_cast<MidiTrack> ((*x)->route());
709 TreeModel::Row row = *(_model->insert (insert_iter));
711 row[_columns.text] = (*x)->route()->name();
712 row[_columns.visible] = (*x)->marked_for_display();
713 row[_columns.active] = (*x)->route()->active ();
714 row[_columns.tv] = *x;
715 row[_columns.route] = (*x)->route ();
716 row[_columns.is_track] = (boost::dynamic_pointer_cast<Track> ((*x)->route()) != 0);
719 row[_columns.is_input_active] = midi_trk->input_active ();
720 row[_columns.is_midi] = true;
722 row[_columns.is_input_active] = false;
723 row[_columns.is_midi] = false;
726 row[_columns.mute_state] = (*x)->route()->muted() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off;
727 row[_columns.solo_state] = RouteUI::solo_active_state ((*x)->route());
728 row[_columns.solo_visible] = !(*x)->route()->is_master ();
729 row[_columns.solo_isolate_state] = (*x)->route()->solo_isolate_control()->solo_isolated();
730 row[_columns.solo_safe_state] = (*x)->route()->solo_safe_control()->solo_safe();
731 row[_columns.name_editable] = true;
733 boost::weak_ptr<Route> wr ((*x)->route());
735 (*x)->route()->gui_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::handle_gui_changes, this, _1, _2), gui_context());
736 (*x)->route()->PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, wr), gui_context());
738 if ((*x)->is_track()) {
739 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> ((*x)->route());
740 t->rec_enable_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
741 t->rec_safe_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
744 if ((*x)->is_midi_track()) {
745 boost::shared_ptr<MidiTrack> t = boost::dynamic_pointer_cast<MidiTrack> ((*x)->route());
746 t->StepEditStatusChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
747 t->InputActiveChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_input_active_display, this), gui_context());
750 (*x)->route()->mute_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_mute_display, this), gui_context());
751 (*x)->route()->solo_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_display, this), gui_context());
752 (*x)->route()->solo_isolate_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_isolate_display, this), gui_context());
753 (*x)->route()->solo_safe_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_safe_display, this), gui_context());
755 (*x)->route()->active_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_active_display, this), gui_context ());
759 update_rec_display ();
760 update_mute_display ();
761 update_solo_display ();
762 update_solo_isolate_display ();
763 update_solo_safe_display ();
764 update_input_active_display ();
765 update_active_display ();
767 _display.set_model (_model);
769 /* now update route order keys from the treeview/track display order */
771 sync_presentation_info_from_treeview ();
776 EditorRoutes::handle_gui_changes (string const & what, void*)
778 if (_adding_routes) {
782 if (what == "track_height") {
783 /* Optional :make tracks change height while it happens, instead
789 if (what == "visible_tracks") {
795 EditorRoutes::route_removed (TimeAxisView *tv)
797 ENSURE_GUI_THREAD (*this, &EditorRoutes::route_removed, tv)
799 TreeModel::Children rows = _model->children();
800 TreeModel::Children::iterator ri;
802 for (ri = rows.begin(); ri != rows.end(); ++ri) {
803 if ((*ri)[_columns.tv] == tv) {
804 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
810 /* the deleted signal for the treeview/model will take
816 EditorRoutes::route_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Route> r)
818 if (!what_changed.contains (ARDOUR::Properties::name)) {
822 ENSURE_GUI_THREAD (*this, &EditorRoutes::route_name_changed, r)
824 boost::shared_ptr<Route> route = r.lock ();
830 TreeModel::Children rows = _model->children();
831 TreeModel::Children::iterator i;
833 for (i = rows.begin(); i != rows.end(); ++i) {
834 boost::shared_ptr<Route> t = (*i)[_columns.route];
836 (*i)[_columns.text] = route->name();
843 EditorRoutes::update_active_display ()
845 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
846 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
851 EditorRoutes::update_visibility ()
853 TreeModel::Children rows = _model->children();
854 TreeModel::Children::iterator i;
858 for (i = rows.begin(); i != rows.end(); ++i) {
859 TimeAxisView *tv = (*i)[_columns.tv];
860 (*i)[_columns.visible] = tv->marked_for_display ();
863 /* force route order keys catch up with visibility changes
866 sync_presentation_info_from_treeview ();
870 EditorRoutes::hide_track_in_display (TimeAxisView& tv)
872 TreeModel::Children rows = _model->children();
873 TreeModel::Children::iterator i;
875 for (i = rows.begin(); i != rows.end(); ++i) {
876 if ((*i)[_columns.tv] == &tv) {
877 tv.set_marked_for_display (false);
878 (*i)[_columns.visible] = false;
886 EditorRoutes::show_track_in_display (TimeAxisView& tv)
888 TreeModel::Children rows = _model->children();
889 TreeModel::Children::iterator i;
892 for (i = rows.begin(); i != rows.end(); ++i) {
893 if ((*i)[_columns.tv] == &tv) {
894 tv.set_marked_for_display (true);
895 (*i)[_columns.visible] = true;
903 EditorRoutes::reset_remote_control_ids ()
905 if (Config->get_remote_model() == UserOrdered || !_session || _session->deletion_in_progress()) {
909 sync_presentation_info_from_treeview ();
912 EditorRoutes::sync_presentation_info_from_treeview ()
914 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
918 TreeModel::Children rows = _model->children();
924 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync order keys from treeview\n");
926 TreeModel::Children::iterator ri;
928 PresentationInfo::order_t order = 0;
930 /* hmm, problem ... editor doesn't represent all Stripables... we can't
931 reset the whole presentation order from here.
934 for (ri = rows.begin(); ri != rows.end(); ++ri) {
936 boost::shared_ptr<Route> route = (*ri)[_columns.route];
937 bool visible = (*ri)[_columns.visible];
939 if (route->presentation_info().special ()) {
944 route->presentation_info().set_flag (PresentationInfo::Hidden);
946 route->presentation_info().unset_flag (PresentationInfo::Hidden);
949 if (order != route->presentation_info().group_order()) {
950 route->set_presentation_group_order_explicit (order);
958 Stripable::PresentationInfoChange(); /* EMIT SIGNAL */
963 EditorRoutes::sync_treeview_from_presentation_info ()
965 /* Some route order key(s) have been changed, make sure that
966 we update out tree/list model and GUI to reflect the change.
969 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
973 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync model from presentation info.\n");
975 /* we could get here after either a change in the Mixer or Editor sort
976 * order, but either way, the mixer order keys reflect the intended
977 * order for the GUI, so reorder the treeview model to match it.
980 vector<int> neworder;
981 TreeModel::Children rows = _model->children();
982 uint32_t old_order = 0;
983 bool changed = false;
991 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
992 boost::shared_ptr<Route> route = (*ri)[_columns.route];
993 sorted.push_back (OrderKeys (old_order, route->presentation_info().group_order()));
994 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("build new order: route %3 old = %1 new = %1\n",
996 route->presentation_info().group_order(),
1000 SortByNewDisplayOrder cmp;
1002 sort (sorted.begin(), sorted.end(), cmp);
1003 neworder.assign (sorted.size(), 0);
1007 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
1009 neworder[n] = sr->old_display_order;
1011 if (sr->old_display_order != n) {
1015 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("EDITOR change order from %1 to %2\n",
1016 sr->old_display_order, n));
1020 Unwinder<bool> uw (_ignore_reorder, true);
1021 _model->reorder (neworder);
1028 EditorRoutes::hide_all_tracks (bool /*with_select*/)
1030 TreeModel::Children rows = _model->children();
1031 TreeModel::Children::iterator i;
1033 DisplaySuspender ds;
1035 for (i = rows.begin(); i != rows.end(); ++i) {
1037 TreeModel::Row row = (*i);
1038 TimeAxisView *tv = row[_columns.tv];
1044 row[_columns.visible] = false;
1049 EditorRoutes::set_all_tracks_visibility (bool yn)
1051 TreeModel::Children rows = _model->children();
1052 TreeModel::Children::iterator i;
1054 DisplaySuspender ds;
1056 for (i = rows.begin(); i != rows.end(); ++i) {
1058 TreeModel::Row row = (*i);
1059 TimeAxisView* tv = row[_columns.tv];
1065 tv->set_marked_for_display (yn);
1066 (*i)[_columns.visible] = yn;
1069 /* force route order keys catch up with visibility changes
1072 sync_presentation_info_from_treeview ();
1076 EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn)
1078 TreeModel::Children rows = _model->children();
1079 TreeModel::Children::iterator i;
1081 DisplaySuspender ds;
1083 for (i = rows.begin(); i != rows.end(); ++i) {
1085 TreeModel::Row row = (*i);
1086 TimeAxisView* tv = row[_columns.tv];
1088 AudioTimeAxisView* atv;
1089 MidiTimeAxisView* mtv;
1095 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1098 atv->set_marked_for_display (yn);
1099 (*i)[_columns.visible] = yn;
1103 if (atv->is_audio_track()) {
1104 atv->set_marked_for_display (yn);
1105 (*i)[_columns.visible] = yn;
1110 if (!atv->is_audio_track()) {
1111 atv->set_marked_for_display (yn);
1112 (*i)[_columns.visible] = yn;
1117 else if ((mtv = dynamic_cast<MidiTimeAxisView*>(tv)) != 0) {
1120 mtv->set_marked_for_display (yn);
1121 (*i)[_columns.visible] = yn;
1125 if (mtv->is_midi_track()) {
1126 mtv->set_marked_for_display (yn);
1127 (*i)[_columns.visible] = yn;
1134 /* force route order keys catch up with visibility changes
1137 sync_presentation_info_from_treeview ();
1141 EditorRoutes::hide_all_routes ()
1143 set_all_tracks_visibility (false);
1147 EditorRoutes::show_all_routes ()
1149 set_all_tracks_visibility (true);
1153 EditorRoutes::show_all_audiotracks()
1155 set_all_audio_midi_visibility (1, true);
1158 EditorRoutes::hide_all_audiotracks ()
1160 set_all_audio_midi_visibility (1, false);
1164 EditorRoutes::show_all_audiobus ()
1166 set_all_audio_midi_visibility (2, true);
1169 EditorRoutes::hide_all_audiobus ()
1171 set_all_audio_midi_visibility (2, false);
1175 EditorRoutes::show_all_miditracks()
1177 set_all_audio_midi_visibility (3, true);
1180 EditorRoutes::hide_all_miditracks ()
1182 set_all_audio_midi_visibility (3, false);
1186 EditorRoutes::key_press (GdkEventKey* ev)
1188 TreeViewColumn *col;
1189 boost::shared_ptr<RouteList> rl (new RouteList);
1192 switch (ev->keyval) {
1194 case GDK_ISO_Left_Tab:
1196 /* If we appear to be editing something, leave that cleanly and appropriately. */
1197 if (name_editable) {
1198 name_editable->editing_done ();
1202 col = _display.get_column (_name_column); // select&focus on name column
1204 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
1205 treeview_select_previous (_display, _model, col);
1207 treeview_select_next (_display, _model, col);
1214 if (get_relevant_routes (rl)) {
1215 _session->set_controls (route_list_to_control_list (rl, &Route::mute_control), rl->front()->muted() ? 0.0 : 1.0, Controllable::NoGroup);
1221 if (get_relevant_routes (rl)) {
1222 _session->set_controls (route_list_to_control_list (rl, &Route::solo_control), rl->front()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
1228 if (get_relevant_routes (rl)) {
1229 for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
1230 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*r);
1232 _session->set_controls (route_list_to_control_list (rl, &Track::rec_enable_control), !t->rec_enable_control()->get_value(), Controllable::NoGroup);
1247 EditorRoutes::get_relevant_routes (boost::shared_ptr<RouteList> rl)
1250 RouteTimeAxisView* rtv;
1251 RefPtr<TreeSelection> selection = _display.get_selection();
1255 if (selection->count_selected_rows() != 0) {
1259 RefPtr<TreeModel> tm = RefPtr<TreeModel>::cast_dynamic (_model);
1260 iter = selection->get_selected (tm);
1263 /* use mouse pointer */
1268 _display.get_pointer (x, y);
1269 _display.convert_widget_to_bin_window_coords (x, y, bx, by);
1271 if (_display.get_path_at_pos (bx, by, path)) {
1272 iter = _model->get_iter (path);
1277 tv = (*iter)[_columns.tv];
1279 rtv = dynamic_cast<RouteTimeAxisView*>(tv);
1281 rl->push_back (rtv->route());
1286 return !rl->empty();
1290 EditorRoutes::button_press (GdkEventButton* ev)
1292 if (Keyboard::is_context_menu_event (ev)) {
1297 TreeModel::Path path;
1298 TreeViewColumn *tvc;
1302 if (!_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, tvc, cell_x, cell_y)) {
1303 /* cancel selection */
1304 _display.get_selection()->unselect_all ();
1305 /* end any editing by grabbing focus */
1306 _display.grab_focus ();
1310 //Scroll editor canvas to selected track
1311 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1313 Gtk::TreeModel::Row row = *_model->get_iter (path);
1314 TimeAxisView *tv = row[_columns.tv];
1317 _editor->ensure_time_axis_view_is_visible (*tv, true);
1325 EditorRoutes::selection_changed ()
1327 _editor->begin_reversible_selection_op (X_("Select Track from Route List"));
1329 if (_display.get_selection()->count_selected_rows() > 0) {
1332 TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
1333 TrackViewList selected;
1335 _editor->get_selection().clear_regions ();
1337 for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
1339 if ((iter = _model->get_iter (*i))) {
1341 TimeAxisView* tv = (*iter)[_columns.tv];
1342 selected.push_back (tv);
1347 _editor->get_selection().set (selected);
1348 _editor->ensure_time_axis_view_is_visible (*(selected.front()), true);
1351 _editor->get_selection().clear_tracks ();
1354 _editor->commit_reversible_selection_op ();
1358 EditorRoutes::selection_filter (Glib::RefPtr<TreeModel> const &, TreeModel::Path const&, bool /*selected*/)
1360 if (selection_countdown) {
1361 if (--selection_countdown == 0) {
1364 /* no selection yet ... */
1371 struct PresentationInfoRouteSorter
1373 bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
1374 if (a->is_master()) {
1375 /* master before everything else */
1377 } else if (b->is_master()) {
1378 /* everything else before master */
1381 return a->presentation_info().global_order () < b->presentation_info().global_order ();
1386 EditorRoutes::initial_display ()
1388 DisplaySuspender ds;
1395 RouteList r (*_session->get_routes());
1397 r.sort (PresentationInfoRouteSorter ());
1398 _editor->add_routes (r);
1402 EditorRoutes::display_drag_data_received (const RefPtr<Gdk::DragContext>& context,
1404 const SelectionData& data,
1405 guint info, guint time)
1407 if (data.get_target() == "GTK_TREE_MODEL_ROW") {
1408 _display.on_drag_data_received (context, x, y, data, info, time);
1412 context->drag_finish (true, false, time);
1416 EditorRoutes::move_selected_tracks (bool up)
1418 if (_editor->selection->tracks.empty()) {
1422 typedef std::pair<TimeAxisView*,boost::shared_ptr<Route> > ViewRoute;
1423 std::list<ViewRoute> view_routes;
1424 std::vector<int> neworder;
1425 TreeModel::Children rows = _model->children();
1426 TreeModel::Children::iterator ri;
1428 for (ri = rows.begin(); ri != rows.end(); ++ri) {
1429 TimeAxisView* tv = (*ri)[_columns.tv];
1430 boost::shared_ptr<Route> route = (*ri)[_columns.route];
1432 view_routes.push_back (ViewRoute (tv, route));
1435 list<ViewRoute>::iterator trailing;
1436 list<ViewRoute>::iterator leading;
1440 trailing = view_routes.begin();
1441 leading = view_routes.begin();
1445 while (leading != view_routes.end()) {
1446 if (_editor->selection->selected (leading->first)) {
1447 view_routes.insert (trailing, ViewRoute (leading->first, leading->second));
1448 leading = view_routes.erase (leading);
1457 /* if we could use reverse_iterator in list::insert, this code
1458 would be a beautiful reflection of the code above. but we can't
1459 and so it looks like a bit of a mess.
1462 trailing = view_routes.end();
1463 leading = view_routes.end();
1465 --leading; if (leading == view_routes.begin()) { return; }
1471 if (_editor->selection->selected (leading->first)) {
1472 list<ViewRoute>::iterator tmp;
1474 /* need to insert *after* trailing, not *before* it,
1475 which is what insert (iter, val) normally does.
1481 view_routes.insert (tmp, ViewRoute (leading->first, leading->second));
1483 /* can't use iter = cont.erase (iter); form here, because
1484 we need iter to move backwards.
1492 if (leading == view_routes.begin()) {
1493 /* the one we've just inserted somewhere else
1494 was the first in the list. erase this copy,
1495 and then break, because we're done.
1500 view_routes.erase (leading);
1509 if (leading == view_routes.begin()) {
1518 for (leading = view_routes.begin(); leading != view_routes.end(); ++leading) {
1519 uint32_t order = (uint32_t) leading->second->presentation_info().group_order ();
1520 neworder.push_back (order);
1524 DEBUG_TRACE (DEBUG::OrderKeys, "New order after moving tracks:\n");
1525 for (vector<int>::iterator i = neworder.begin(); i != neworder.end(); ++i) {
1526 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("\t%1\n", *i));
1528 DEBUG_TRACE (DEBUG::OrderKeys, "-------\n");
1530 for (vector<int>::iterator i = neworder.begin(); i != neworder.end(); ++i) {
1531 if (*i >= (int) neworder.size()) {
1532 cerr << "Trying to move something to " << *i << " of " << neworder.size() << endl;
1534 assert (*i < (int) neworder.size ());
1538 _model->reorder (neworder);
1542 EditorRoutes::update_input_active_display ()
1544 TreeModel::Children rows = _model->children();
1545 TreeModel::Children::iterator i;
1547 for (i = rows.begin(); i != rows.end(); ++i) {
1548 boost::shared_ptr<Route> route = (*i)[_columns.route];
1550 if (boost::dynamic_pointer_cast<Track> (route)) {
1551 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
1554 (*i)[_columns.is_input_active] = mt->input_active();
1561 EditorRoutes::update_rec_display ()
1563 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1564 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1569 EditorRoutes::idle_update_mute_rec_solo_etc()
1571 g_atomic_int_set (const_cast<gint*>(&_queue_tv_update), 0);
1572 TreeModel::Children rows = _model->children();
1573 TreeModel::Children::iterator i;
1575 for (i = rows.begin(); i != rows.end(); ++i) {
1576 boost::shared_ptr<Route> route = (*i)[_columns.route];
1577 (*i)[_columns.mute_state] = RouteUI::mute_active_state (_session, route);
1578 (*i)[_columns.solo_state] = RouteUI::solo_active_state (route);
1579 (*i)[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (route) ? 1 : 0;
1580 (*i)[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (route) ? 1 : 0;
1581 (*i)[_columns.active] = route->active ();
1583 boost::shared_ptr<Track> trk (boost::dynamic_pointer_cast<Track>(route));
1586 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
1588 if (trk->rec_enable_control()->get_value()) {
1589 if (_session->record_status() == Session::Recording) {
1590 (*i)[_columns.rec_state] = 1;
1592 (*i)[_columns.rec_state] = 2;
1594 } else if (mt && mt->step_editing()) {
1595 (*i)[_columns.rec_state] = 3;
1597 (*i)[_columns.rec_state] = 0;
1600 (*i)[_columns.rec_safe] = !trk->rec_safe_control()->get_value();
1601 (*i)[_columns.name_editable] = !trk->rec_enable_control()->get_value();
1605 return false; // do not call again (until needed)
1610 EditorRoutes::update_mute_display ()
1612 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1613 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1618 EditorRoutes::update_solo_display ()
1620 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1621 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1626 EditorRoutes::update_solo_isolate_display ()
1628 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1629 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1634 EditorRoutes::update_solo_safe_display ()
1636 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1637 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1642 EditorRoutes::views () const
1644 list<TimeAxisView*> v;
1645 for (TreeModel::Children::iterator i = _model->children().begin(); i != _model->children().end(); ++i) {
1646 v.push_back ((*i)[_columns.tv]);
1653 EditorRoutes::clear ()
1655 _display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
1657 _display.set_model (_model);
1661 EditorRoutes::name_edit_started (CellEditable* ce, const Glib::ustring&)
1665 /* give it a special name */
1667 Gtk::Entry *e = dynamic_cast<Gtk::Entry*> (ce);
1670 e->set_name (X_("RouteNameEditorEntry"));
1675 EditorRoutes::name_edit (std::string const & path, std::string const & new_text)
1679 TreeIter iter = _model->get_iter (path);
1685 boost::shared_ptr<Route> route = (*iter)[_columns.route];
1687 if (route && route->name() != new_text) {
1688 route->set_name (new_text);
1693 EditorRoutes::solo_changed_so_update_mute ()
1695 update_mute_display ();
1699 EditorRoutes::show_tracks_with_regions_at_playhead ()
1701 boost::shared_ptr<RouteList> const r = _session->get_routes_with_regions_at (_session->transport_frame ());
1703 set<TimeAxisView*> show;
1704 for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
1705 TimeAxisView* tav = _editor->axis_view_from_route (*i);
1711 DisplaySuspender ds;
1713 TreeModel::Children rows = _model->children ();
1714 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
1715 TimeAxisView* tv = (*i)[_columns.tv];
1716 bool to_show = (show.find (tv) != show.end());
1718 tv->set_marked_for_display (to_show);
1719 (*i)[_columns.visible] = to_show;
1722 /* force route order keys catch up with visibility changes
1725 sync_presentation_info_from_treeview ();
1729 EditorRoutes::plugin_setup (boost::shared_ptr<Route> r, boost::shared_ptr<PluginInsert> pi, ARDOUR::Route::PluginSetupOptions flags)
1731 PluginSetupDialog psd (r, pi, flags);