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/selection.h"
35 #include "ardour/session.h"
36 #include "ardour/solo_isolate_control.h"
37 #include "ardour/utils.h"
38 #include "ardour/vca.h"
39 #include "ardour/vca_manager.h"
41 #include "gtkmm2ext/cell_renderer_pixbuf_multi.h"
42 #include "gtkmm2ext/cell_renderer_pixbuf_toggle.h"
43 #include "gtkmm2ext/treeutils.h"
46 #include "ardour_ui.h"
47 #include "audio_time_axis.h"
49 #include "editor_group_tabs.h"
50 #include "editor_routes.h"
51 #include "gui_thread.h"
53 #include "midi_time_axis.h"
54 #include "mixer_strip.h"
55 #include "plugin_setup_dialog.h"
56 #include "route_sorter.h"
58 #include "vca_time_axis.h"
64 using namespace ARDOUR;
65 using namespace ARDOUR_UI_UTILS;
68 using namespace Gtkmm2ext;
70 using Gtkmm2ext::Keyboard;
78 EditorRoutes::EditorRoutes (Editor* e)
80 , _ignore_reorder (false)
81 , _ignore_selection_change (false)
82 , _no_redisplay (false)
83 , _adding_routes (false)
84 , _route_deletion_in_progress (false)
85 , _redisplay_on_resume (false)
86 , _redisplay_active (0)
87 , _queue_tv_update (0)
92 static const int column_width = 22;
94 _scroller.add (_display);
95 _scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
97 _model = ListStore::create (_columns);
98 _display.set_model (_model);
100 // Record enable toggle
101 CellRendererPixbufMulti* rec_col_renderer = manage (new CellRendererPixbufMulti());
103 rec_col_renderer->set_pixbuf (0, ::get_icon("record-normal-disabled"));
104 rec_col_renderer->set_pixbuf (1, ::get_icon("record-normal-in-progress"));
105 rec_col_renderer->set_pixbuf (2, ::get_icon("record-normal-enabled"));
106 rec_col_renderer->set_pixbuf (3, ::get_icon("record-step"));
107 rec_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_enable_changed));
109 TreeViewColumn* rec_state_column = manage (new TreeViewColumn("R", *rec_col_renderer));
111 rec_state_column->add_attribute(rec_col_renderer->property_state(), _columns.rec_state);
112 rec_state_column->add_attribute(rec_col_renderer->property_visible(), _columns.is_track);
114 rec_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
115 rec_state_column->set_alignment(ALIGN_CENTER);
116 rec_state_column->set_expand(false);
117 rec_state_column->set_fixed_width(column_width);
120 // Record safe toggle
121 CellRendererPixbufMulti* rec_safe_renderer = manage (new CellRendererPixbufMulti ());
123 rec_safe_renderer->set_pixbuf (0, ::get_icon("rec-safe-disabled"));
124 rec_safe_renderer->set_pixbuf (1, ::get_icon("rec-safe-enabled"));
125 rec_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_safe_toggled));
127 TreeViewColumn* rec_safe_column = manage (new TreeViewColumn(_("RS"), *rec_safe_renderer));
128 rec_safe_column->add_attribute(rec_safe_renderer->property_state(), _columns.rec_safe);
129 rec_safe_column->add_attribute(rec_safe_renderer->property_visible(), _columns.is_track);
130 rec_safe_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
131 rec_safe_column->set_alignment(ALIGN_CENTER);
132 rec_safe_column->set_expand(false);
133 rec_safe_column->set_fixed_width(column_width);
138 CellRendererPixbufMulti* input_active_col_renderer = manage (new CellRendererPixbufMulti());
139 input_active_col_renderer->set_pixbuf (0, ::get_icon("midi-input-inactive"));
140 input_active_col_renderer->set_pixbuf (1, ::get_icon("midi-input-active"));
141 input_active_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_input_active_changed));
143 TreeViewColumn* input_active_column = manage (new TreeViewColumn ("I", *input_active_col_renderer));
145 input_active_column->add_attribute(input_active_col_renderer->property_state(), _columns.is_input_active);
146 input_active_column->add_attribute (input_active_col_renderer->property_visible(), _columns.is_midi);
148 input_active_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
149 input_active_column->set_alignment(ALIGN_CENTER);
150 input_active_column->set_expand(false);
151 input_active_column->set_fixed_width(column_width);
153 // Mute enable toggle
154 CellRendererPixbufMulti* mute_col_renderer = manage (new CellRendererPixbufMulti());
156 mute_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("mute-disabled"));
157 mute_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("muted-by-others"));
158 mute_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("mute-enabled"));
159 mute_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_mute_enable_toggled));
161 TreeViewColumn* mute_state_column = manage (new TreeViewColumn("M", *mute_col_renderer));
163 mute_state_column->add_attribute(mute_col_renderer->property_state(), _columns.mute_state);
164 mute_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
165 mute_state_column->set_alignment(ALIGN_CENTER);
166 mute_state_column->set_expand(false);
167 mute_state_column->set_fixed_width(15);
169 // Solo enable toggle
170 CellRendererPixbufMulti* solo_col_renderer = manage (new CellRendererPixbufMulti());
172 solo_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("solo-disabled"));
173 solo_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("solo-enabled"));
174 solo_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("soloed-by-others"));
175 solo_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_enable_toggled));
177 TreeViewColumn* solo_state_column = manage (new TreeViewColumn("S", *solo_col_renderer));
179 solo_state_column->add_attribute(solo_col_renderer->property_state(), _columns.solo_state);
180 solo_state_column->add_attribute(solo_col_renderer->property_visible(), _columns.solo_visible);
181 solo_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
182 solo_state_column->set_alignment(ALIGN_CENTER);
183 solo_state_column->set_expand(false);
184 solo_state_column->set_fixed_width(column_width);
186 // Solo isolate toggle
187 CellRendererPixbufMulti* solo_iso_renderer = manage (new CellRendererPixbufMulti());
189 solo_iso_renderer->set_pixbuf (0, ::get_icon("solo-isolate-disabled"));
190 solo_iso_renderer->set_pixbuf (1, ::get_icon("solo-isolate-enabled"));
191 solo_iso_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_isolate_toggled));
193 TreeViewColumn* solo_isolate_state_column = manage (new TreeViewColumn("SI", *solo_iso_renderer));
195 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_state(), _columns.solo_isolate_state);
196 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_visible(), _columns.solo_visible);
197 solo_isolate_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
198 solo_isolate_state_column->set_alignment(ALIGN_CENTER);
199 solo_isolate_state_column->set_expand(false);
200 solo_isolate_state_column->set_fixed_width(column_width);
203 CellRendererPixbufMulti* solo_safe_renderer = manage (new CellRendererPixbufMulti ());
205 solo_safe_renderer->set_pixbuf (0, ::get_icon("solo-safe-disabled"));
206 solo_safe_renderer->set_pixbuf (1, ::get_icon("solo-safe-enabled"));
207 solo_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_safe_toggled));
209 TreeViewColumn* solo_safe_state_column = manage (new TreeViewColumn(_("SS"), *solo_safe_renderer));
210 solo_safe_state_column->add_attribute(solo_safe_renderer->property_state(), _columns.solo_safe_state);
211 solo_safe_state_column->add_attribute(solo_safe_renderer->property_visible(), _columns.solo_visible);
212 solo_safe_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
213 solo_safe_state_column->set_alignment(ALIGN_CENTER);
214 solo_safe_state_column->set_expand(false);
215 solo_safe_state_column->set_fixed_width(column_width);
217 _name_column = _display.append_column ("", _columns.text) - 1;
218 _visible_column = _display.append_column ("", _columns.visible) - 1;
219 _active_column = _display.append_column ("", _columns.active) - 1;
221 _display.append_column (*input_active_column);
222 _display.append_column (*rec_state_column);
223 _display.append_column (*rec_safe_column);
224 _display.append_column (*mute_state_column);
225 _display.append_column (*solo_state_column);
226 _display.append_column (*solo_isolate_state_column);
227 _display.append_column (*solo_safe_state_column);
234 { 0, _("Name"), _("Track/Bus Name") },
235 { 1, S_("Visible|V"), _("Track/Bus visible ?") },
236 { 2, S_("Active|A"), _("Track/Bus active ?") },
237 { 3, S_("MidiInput|I"), _("MIDI input enabled") },
238 { 4, S_("Rec|R"), _("Record enabled") },
239 { 5, S_("Rec|RS"), _("Record Safe") },
240 { 6, S_("Mute|M"), _("Muted") },
241 { 7, S_("Solo|S"), _("Soloed") },
242 { 8, S_("SoloIso|SI"), _("Solo Isolated") },
243 { 9, S_("SoloLock|SS"), _("Solo Safe (Locked)") },
247 for (int i = 0; ci[i].index >= 0; ++i) {
248 col = _display.get_column (ci[i].index);
249 l = manage (new Label (ci[i].label));
250 set_tooltip (*l, ci[i].tooltip);
251 col->set_widget (*l);
255 _display.set_headers_visible (true);
256 _display.get_selection()->set_mode (SELECTION_MULTIPLE);
257 _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRoutes::selection_filter));
258 _display.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::selection_changed));
259 _display.set_reorderable (true);
260 _display.set_name (X_("EditGroupList"));
261 _display.set_rules_hint (true);
262 _display.set_size_request (100, -1);
264 CellRendererText* name_cell = dynamic_cast<CellRendererText*> (_display.get_column_cell_renderer (_name_column));
267 name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit_started));
269 TreeViewColumn* name_column = _display.get_column (_name_column);
271 assert (name_column);
273 name_column->add_attribute (name_cell->property_editable(), _columns.name_editable);
274 name_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
275 name_column->set_expand(true);
276 name_column->set_min_width(50);
278 name_cell->property_editable() = true;
279 name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit));
281 // Set the visible column cell renderer to radio toggle
282 CellRendererToggle* visible_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_visible_column));
284 visible_cell->property_activatable() = true;
285 visible_cell->property_radio() = false;
286 visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::visible_changed));
288 TreeViewColumn* visible_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_visible_column));
289 visible_col->set_expand(false);
290 visible_col->set_sizing(TREE_VIEW_COLUMN_FIXED);
291 visible_col->set_fixed_width(30);
292 visible_col->set_alignment(ALIGN_CENTER);
294 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_active_column));
296 active_cell->property_activatable() = true;
297 active_cell->property_radio() = false;
298 active_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::active_changed));
300 TreeViewColumn* active_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_active_column));
301 active_col->set_expand (false);
302 active_col->set_sizing (TREE_VIEW_COLUMN_FIXED);
303 active_col->set_fixed_width (30);
304 active_col->set_alignment (ALIGN_CENTER);
306 _model->signal_row_deleted().connect (sigc::mem_fun (*this, &EditorRoutes::row_deleted));
307 _model->signal_rows_reordered().connect (sigc::mem_fun (*this, &EditorRoutes::reordered));
309 _display.signal_button_press_event().connect (sigc::mem_fun (*this, &EditorRoutes::button_press), false);
310 _scroller.signal_key_press_event().connect (sigc::mem_fun(*this, &EditorRoutes::key_press), false);
312 _scroller.signal_focus_in_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_in), false);
313 _scroller.signal_focus_out_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_out));
315 _display.signal_enter_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::enter_notify), false);
316 _display.signal_leave_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::leave_notify), false);
318 _display.set_enable_search (false);
320 Route::PluginSetup.connect_same_thread (*this, boost::bind (&EditorRoutes::plugin_setup, this, _1, _2, _3));
324 EditorRoutes::focus_in (GdkEventFocus*)
326 Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ());
329 old_focus = win->get_focus ();
336 /* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
341 EditorRoutes::focus_out (GdkEventFocus*)
344 old_focus->grab_focus ();
352 EditorRoutes::enter_notify (GdkEventCrossing*)
358 /* arm counter so that ::selection_filter() will deny selecting anything for the
359 * next two attempts to change selection status.
361 _scroller.grab_focus ();
362 Keyboard::magic_widget_grab_focus ();
367 EditorRoutes::leave_notify (GdkEventCrossing*)
370 old_focus->grab_focus ();
374 Keyboard::magic_widget_drop_focus ();
379 EditorRoutes::set_session (Session* s)
381 SessionHandlePtr::set_session (s);
386 _session->SoloChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::solo_changed_so_update_mute, this), gui_context());
387 _session->RecordStateChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
389 /* TODO: check if these needs to be tied in with DisplaySuspender
390 * Given that the UI is single-threaded and DisplaySuspender is only used
391 * in loops in the UI thread all should be fine.
393 _session->BatchUpdateStart.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::suspend_redisplay, this), gui_context());
394 _session->BatchUpdateEnd.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::resume_redisplay, this), gui_context());
399 EditorRoutes::on_input_active_changed (std::string const & path_string)
401 // Get the model row that has been toggled.
402 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
404 TimeAxisView* tv = row[_columns.tv];
405 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
408 boost::shared_ptr<MidiTrack> mt;
409 mt = rtv->midi_track();
411 mt->set_input_active (!mt->input_active());
417 EditorRoutes::on_tv_rec_enable_changed (std::string const & path_string)
419 // Get the model row that has been toggled.
420 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
422 TimeAxisView* tv = row[_columns.tv];
423 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
429 boost::shared_ptr<AutomationControl> ac = rtv->route()->rec_enable_control();
432 ac->set_value (!ac->get_value(), Controllable::UseGroup);
437 EditorRoutes::on_tv_rec_safe_toggled (std::string const & path_string)
439 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
440 TimeAxisView* tv = row[_columns.tv];
441 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
447 boost::shared_ptr<AutomationControl> ac (rtv->route()->rec_safe_control());
450 ac->set_value (!ac->get_value(), Controllable::UseGroup);
455 EditorRoutes::on_tv_mute_enable_toggled (std::string const & path_string)
457 // Get the model row that has been toggled.
458 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
460 TimeAxisView *tv = row[_columns.tv];
461 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
467 boost::shared_ptr<AutomationControl> ac (rtv->route()->mute_control());
470 ac->set_value (!ac->get_value(), Controllable::UseGroup);
475 EditorRoutes::on_tv_solo_enable_toggled (std::string const & path_string)
477 // Get the model row that has been toggled.
478 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
480 TimeAxisView *tv = row[_columns.tv];
481 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
487 boost::shared_ptr<AutomationControl> ac (rtv->route()->solo_control());
490 ac->set_value (!ac->get_value(), Controllable::UseGroup);
495 EditorRoutes::on_tv_solo_isolate_toggled (std::string const & path_string)
497 // Get the model row that has been toggled.
498 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
500 TimeAxisView *tv = row[_columns.tv];
501 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
507 boost::shared_ptr<AutomationControl> ac (rtv->route()->solo_isolate_control());
510 ac->set_value (!ac->get_value(), Controllable::UseGroup);
515 EditorRoutes::on_tv_solo_safe_toggled (std::string const & path_string)
517 // Get the model row that has been toggled.
518 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
520 TimeAxisView *tv = row[_columns.tv];
521 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
527 boost::shared_ptr<AutomationControl> ac (rtv->route()->solo_safe_control());
530 ac->set_value (!ac->get_value(), Controllable::UseGroup);
535 EditorRoutes::build_menu ()
537 using namespace Menu_Helpers;
542 MenuList& items = _menu->items();
543 _menu->set_name ("ArdourContextMenu");
545 items.push_back (MenuElem (_("Show All"), sigc::mem_fun (*this, &EditorRoutes::show_all_routes)));
546 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun (*this, &EditorRoutes::hide_all_routes)));
547 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiotracks)));
548 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiotracks)));
549 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiobus)));
550 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiobus)));
551 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_miditracks)));
552 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_miditracks)));
553 items.push_back (MenuElem (_("Only Show Tracks with Regions Under Playhead"), sigc::mem_fun (*this, &EditorRoutes::show_tracks_with_regions_at_playhead)));
557 EditorRoutes::redisplay_real ()
559 TreeModel::Children rows = _model->children();
560 TreeModel::Children::iterator i;
563 /* n will be the count of tracks plus children (updated by TimeAxisView::show_at),
564 * so we will use that to know where to put things.
568 for (n = 0, position = 0, i = rows.begin(); i != rows.end(); ++i) {
569 TimeAxisView *tv = (*i)[_columns.tv];
572 // just a "title" row
576 bool visible = tv->marked_for_display ();
578 /* show or hide the TimeAxisView */
580 position += tv->show_at (position, n, &_editor->edit_controls_vbox);
588 /* whenever we go idle, update the track view list to reflect the new order.
589 * we can't do this here, because we could mess up something that is traversing
590 * the track order and has caused a redisplay of the list.
592 Glib::signal_idle().connect (sigc::mem_fun (*_editor, &Editor::sync_track_view_list_and_routes));
594 _editor->reset_controls_layout_height (position);
595 _editor->reset_controls_layout_width ();
596 _editor->_full_canvas_height = position;
598 if ((_editor->vertical_adjustment.get_value() + _editor->_visible_canvas_height) > _editor->vertical_adjustment.get_upper()) {
600 * We're increasing the size of the canvas while the bottom is visible.
601 * We scroll down to keep in step with the controls layout.
603 _editor->vertical_adjustment.set_value (_editor->_full_canvas_height - _editor->_visible_canvas_height);
608 EditorRoutes::redisplay ()
610 if (!_session || _session->deletion_in_progress()) {
615 _redisplay_on_resume = true;
619 // model deprecated g_atomic_int_exchange_and_add(, 1)
620 g_atomic_int_inc(const_cast<gint*>(&_redisplay_active));
621 if (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 1)) {
622 /* recursive re-display can happen if redisplay shows/hides a TrackView
623 * which has children and their display status changes as result.
630 while (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 0)) {
631 g_atomic_int_set(const_cast<gint*>(&_redisplay_active), 1);
637 EditorRoutes::row_deleted (Gtk::TreeModel::Path const &)
639 if (!_session || _session->deletion_in_progress()) {
642 /* this happens as the second step of a DnD within the treeview, and
643 * when a route is actually removed. we don't differentiate between
646 * note that the sync_presentation_info_from_treeview() step may not
647 * actually change any presentation info (e.g. the last track may be
648 * removed, so all other tracks keep the same presentation info), which
649 * means that no redisplay would happen. so we have to force a
653 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview row deleted\n");
656 sync_presentation_info_from_treeview ();
660 EditorRoutes::reordered (TreeModel::Path const &, TreeModel::iterator const &, int* /*what*/)
662 /* reordering implies that RID's will change, so
663 sync_presentation_info_from_treeview() will cause a redisplay.
666 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview reordered\n");
667 sync_presentation_info_from_treeview ();
671 EditorRoutes::visible_changed (std::string const & path)
673 if (_session && _session->deletion_in_progress()) {
680 if ((iter = _model->get_iter (path))) {
681 TimeAxisView* tv = (*iter)[_columns.tv];
683 bool visible = (*iter)[_columns.visible];
685 if (tv->set_marked_for_display (!visible)) {
686 update_visibility ();
693 EditorRoutes::active_changed (std::string const & path)
695 if (_session && _session->deletion_in_progress ()) {
699 Gtk::TreeModel::Row row = *_model->get_iter (path);
700 boost::shared_ptr<Stripable> stripable = row[_columns.stripable];
701 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
703 bool const active = row[_columns.active];
704 route->set_active (!active, this);
709 EditorRoutes::time_axis_views_added (list<TimeAxisView*> tavs)
711 PBD::Unwinder<bool> at (_adding_routes, true);
712 bool from_scratch = (_model->children().size() == 0);
713 Gtk::TreeModel::Children::iterator insert_iter = _model->children().end();
715 for (Gtk::TreeModel::Children::iterator it = _model->children().begin(); it != _model->children().end(); ++it) {
717 boost::shared_ptr<Stripable> r = (*it)[_columns.stripable];
719 if (r->presentation_info().order() == (tavs.front()->stripable()->presentation_info().order() + tavs.size())) {
726 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
727 _display.set_model (Glib::RefPtr<ListStore>());
730 for (list<TimeAxisView*>::iterator x = tavs.begin(); x != tavs.end(); ++x) {
732 VCATimeAxisView* vtav = dynamic_cast<VCATimeAxisView*> (*x);
733 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (*x);
735 TreeModel::Row row = *(_model->insert (insert_iter));
737 boost::shared_ptr<Stripable> stripable;
738 boost::shared_ptr<MidiTrack> midi_trk;
742 stripable = vtav->vca();
744 row[_columns.is_track] = false;
745 row[_columns.is_input_active] = false;
746 row[_columns.is_midi] = false;
750 stripable = rtav->route ();
751 midi_trk= boost::dynamic_pointer_cast<MidiTrack> (stripable);
753 row[_columns.is_track] = (boost::dynamic_pointer_cast<Track> (stripable) != 0);
756 row[_columns.is_input_active] = midi_trk->input_active ();
757 row[_columns.is_midi] = true;
759 row[_columns.is_input_active] = false;
760 row[_columns.is_midi] = false;
768 row[_columns.text] = stripable->name();
769 row[_columns.visible] = (*x)->marked_for_display();
770 row[_columns.active] = true;
771 row[_columns.tv] = *x;
772 row[_columns.stripable] = stripable;
773 row[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
774 row[_columns.solo_state] = RouteUI::solo_active_state (stripable);
775 row[_columns.solo_visible] = true;
776 row[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable);
777 row[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable);
778 row[_columns.name_editable] = true;
780 boost::weak_ptr<Stripable> ws (stripable);
782 /* for now, we need both of these. PropertyChanged covers on
783 * pre-defined, "global" things of interest to a
784 * UI. gui_changed covers arbitrary, un-enumerated, un-typed
785 * changes that may only be of interest to a particular
786 * UI (e.g. track-height is not of any relevant to OSC)
789 stripable->gui_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::handle_gui_changes, this, _1, _2), gui_context());
790 stripable->PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, ws), gui_context());
791 stripable->presentation_info().PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, ws), gui_context());
793 if (boost::dynamic_pointer_cast<Track> (stripable)) {
794 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (stripable);
795 t->rec_enable_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
796 t->rec_safe_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
800 midi_trk->StepEditStatusChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
801 midi_trk->InputActiveChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_input_active_display, this), gui_context());
804 boost::shared_ptr<AutomationControl> ac;
806 if ((ac = stripable->mute_control()) != 0) {
807 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_mute_display, this), gui_context());
809 if ((ac = stripable->solo_control()) != 0) {
810 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_display, this), gui_context());
812 if ((ac = stripable->solo_isolate_control()) != 0) {
813 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_isolate_display, this), gui_context());
815 if ((ac = stripable->solo_safe_control()) != 0) {
816 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_safe_display, this), gui_context());
820 rtav->route()->active_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_active_display, this), gui_context ());
824 update_rec_display ();
825 update_mute_display ();
826 update_solo_display ();
827 update_solo_isolate_display ();
828 update_solo_safe_display ();
829 update_input_active_display ();
830 update_active_display ();
833 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
834 _display.set_model (_model);
837 /* now update route order keys from the treeview/track display order */
840 sync_presentation_info_from_treeview ();
847 EditorRoutes::handle_gui_changes (string const & what, void*)
849 if (_adding_routes) {
853 if (what == "track_height") {
854 /* Optional :make tracks change height while it happens, instead
860 if (what == "visible_tracks") {
866 EditorRoutes::route_removed (TimeAxisView *tv)
868 ENSURE_GUI_THREAD (*this, &EditorRoutes::route_removed, tv)
870 TreeModel::Children rows = _model->children();
871 TreeModel::Children::iterator ri;
873 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
875 for (ri = rows.begin(); ri != rows.end(); ++ri) {
876 if ((*ri)[_columns.tv] == tv) {
877 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
885 EditorRoutes::route_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> s)
887 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
891 if (_adding_routes) {
895 boost::shared_ptr<Stripable> stripable = s.lock ();
901 TreeModel::Children rows = _model->children();
902 TreeModel::Children::iterator i;
904 for (i = rows.begin(); i != rows.end(); ++i) {
906 boost::shared_ptr<Stripable> ss = (*i)[_columns.stripable];
908 if (ss == stripable) {
910 if (what_changed.contains (ARDOUR::Properties::name)) {
911 (*i)[_columns.text] = stripable->name();
915 if (what_changed.contains (ARDOUR::Properties::hidden)) {
916 (*i)[_columns.visible] = !stripable->presentation_info().hidden();
927 EditorRoutes::update_active_display ()
929 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
930 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
935 EditorRoutes::update_visibility ()
937 TreeModel::Children rows = _model->children();
938 TreeModel::Children::iterator i;
942 for (i = rows.begin(); i != rows.end(); ++i) {
943 TimeAxisView *tv = (*i)[_columns.tv];
944 (*i)[_columns.visible] = tv->marked_for_display ();
947 /* force route order keys catch up with visibility changes */
949 sync_presentation_info_from_treeview ();
953 EditorRoutes::hide_track_in_display (TimeAxisView& tv)
955 TreeModel::Children rows = _model->children();
956 TreeModel::Children::iterator i;
958 for (i = rows.begin(); i != rows.end(); ++i) {
959 if ((*i)[_columns.tv] == &tv) {
960 tv.set_marked_for_display (false);
961 (*i)[_columns.visible] = false;
969 EditorRoutes::show_track_in_display (TimeAxisView& tv)
971 TreeModel::Children rows = _model->children();
972 TreeModel::Children::iterator i;
975 for (i = rows.begin(); i != rows.end(); ++i) {
976 if ((*i)[_columns.tv] == &tv) {
977 tv.set_marked_for_display (true);
978 (*i)[_columns.visible] = true;
986 EditorRoutes::sync_presentation_info_from_treeview ()
988 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
992 TreeModel::Children rows = _model->children();
998 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync presentation info from treeview\n");
1000 bool change = false;
1001 PresentationInfo::order_t order = 0;
1003 PresentationInfo::ChangeSuspender cs;
1005 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) {
1006 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1007 bool visible = (*ri)[_columns.visible];
1009 #ifndef NDEBUG // these should not exist in the treeview
1011 if (stripable->is_monitor() || stripable->is_auditioner()) {
1017 stripable->presentation_info().set_hidden (!visible);
1019 if (order != stripable->presentation_info().order()) {
1020 stripable->set_presentation_order (order);
1026 change |= _session->ensure_stripable_sort_order ();
1029 _session->set_dirty();
1034 EditorRoutes::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
1036 /* Some route order key(s) have been changed, make sure that
1037 we update out tree/list model and GUI to reflect the change.
1040 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
1044 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync model from presentation info.\n");
1046 PropertyChange hidden_or_order;
1047 hidden_or_order.add (Properties::hidden);
1048 hidden_or_order.add (Properties::order);
1050 TreeModel::Children rows = _model->children();
1052 bool changed = false;
1054 if (what_changed.contains (hidden_or_order)) {
1055 vector<int> neworder;
1056 uint32_t old_order = 0;
1062 TreeOrderKeys sorted;
1063 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
1064 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1065 /* use global order */
1066 sorted.push_back (TreeOrderKey (old_order, stripable));
1069 TreeOrderKeySorter cmp;
1071 sort (sorted.begin(), sorted.end(), cmp);
1072 neworder.assign (sorted.size(), 0);
1076 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
1078 neworder[n] = sr->old_display_order;
1080 if (sr->old_display_order != n) {
1086 Unwinder<bool> uw (_ignore_reorder, true);
1087 /* prevent traverse_cells: assertion 'row_path != NULL'
1088 * in case of DnD re-order: row-removed + row-inserted.
1090 * The rows (stripables) are not actually removed from the model,
1091 * but only from the display in the DnDTreeView.
1092 * ->reorder() will fail to find the row_path.
1093 * (re-order drag -> remove row -> sync PI from TV -> notify -> sync TV from PI -> crash)
1095 Unwinder<bool> uw2 (_ignore_selection_change, true);
1097 _display.unset_model();
1098 _model->reorder (neworder);
1099 _display.set_model (_model);
1103 if (changed || what_changed.contains (Properties::selected)) {
1104 /* by the time this is invoked, the GUI Selection model has
1105 * already updated itself.
1107 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
1109 /* set the treeview model selection state */
1110 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) {
1111 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1112 if (stripable && stripable->is_selected()) {
1113 _display.get_selection()->select (*ri);
1115 _display.get_selection()->unselect (*ri);
1124 EditorRoutes::hide_all_tracks (bool /*with_select*/)
1126 TreeModel::Children rows = _model->children();
1127 TreeModel::Children::iterator i;
1129 DisplaySuspender ds;
1131 for (i = rows.begin(); i != rows.end(); ++i) {
1133 TreeModel::Row row = (*i);
1134 TimeAxisView *tv = row[_columns.tv];
1140 row[_columns.visible] = false;
1145 EditorRoutes::set_all_tracks_visibility (bool yn)
1147 TreeModel::Children rows = _model->children();
1148 TreeModel::Children::iterator i;
1150 DisplaySuspender ds;
1152 for (i = rows.begin(); i != rows.end(); ++i) {
1154 TreeModel::Row row = (*i);
1155 TimeAxisView* tv = row[_columns.tv];
1161 tv->set_marked_for_display (yn);
1162 (*i)[_columns.visible] = yn;
1165 /* force route order keys catch up with visibility changes
1168 sync_presentation_info_from_treeview ();
1172 EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn)
1174 TreeModel::Children rows = _model->children();
1175 TreeModel::Children::iterator i;
1177 DisplaySuspender ds;
1179 for (i = rows.begin(); i != rows.end(); ++i) {
1181 TreeModel::Row row = (*i);
1182 TimeAxisView* tv = row[_columns.tv];
1184 AudioTimeAxisView* atv;
1185 MidiTimeAxisView* mtv;
1191 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1194 atv->set_marked_for_display (yn);
1195 (*i)[_columns.visible] = yn;
1199 if (atv->is_audio_track()) {
1200 atv->set_marked_for_display (yn);
1201 (*i)[_columns.visible] = yn;
1206 if (!atv->is_audio_track()) {
1207 atv->set_marked_for_display (yn);
1208 (*i)[_columns.visible] = yn;
1213 else if ((mtv = dynamic_cast<MidiTimeAxisView*>(tv)) != 0) {
1216 mtv->set_marked_for_display (yn);
1217 (*i)[_columns.visible] = yn;
1221 if (mtv->is_midi_track()) {
1222 mtv->set_marked_for_display (yn);
1223 (*i)[_columns.visible] = yn;
1230 /* force route order keys catch up with visibility changes
1233 sync_presentation_info_from_treeview ();
1237 EditorRoutes::hide_all_routes ()
1239 set_all_tracks_visibility (false);
1243 EditorRoutes::show_all_routes ()
1245 set_all_tracks_visibility (true);
1249 EditorRoutes::show_all_audiotracks()
1251 set_all_audio_midi_visibility (1, true);
1254 EditorRoutes::hide_all_audiotracks ()
1256 set_all_audio_midi_visibility (1, false);
1260 EditorRoutes::show_all_audiobus ()
1262 set_all_audio_midi_visibility (2, true);
1265 EditorRoutes::hide_all_audiobus ()
1267 set_all_audio_midi_visibility (2, false);
1271 EditorRoutes::show_all_miditracks()
1273 set_all_audio_midi_visibility (3, true);
1276 EditorRoutes::hide_all_miditracks ()
1278 set_all_audio_midi_visibility (3, false);
1282 EditorRoutes::key_press (GdkEventKey* ev)
1284 TreeViewColumn *col;
1285 boost::shared_ptr<RouteList> rl (new RouteList);
1288 switch (ev->keyval) {
1290 case GDK_ISO_Left_Tab:
1292 /* If we appear to be editing something, leave that cleanly and appropriately. */
1293 if (name_editable) {
1294 name_editable->editing_done ();
1298 col = _display.get_column (_name_column); // select&focus on name column
1300 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
1301 treeview_select_previous (_display, _model, col);
1303 treeview_select_next (_display, _model, col);
1310 if (get_relevant_routes (rl)) {
1311 _session->set_controls (route_list_to_control_list (rl, &Stripable::mute_control), rl->front()->muted() ? 0.0 : 1.0, Controllable::NoGroup);
1317 if (get_relevant_routes (rl)) {
1318 _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), rl->front()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
1324 if (get_relevant_routes (rl)) {
1325 for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
1326 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*r);
1328 _session->set_controls (route_list_to_control_list (rl, &Stripable::rec_enable_control), !t->rec_enable_control()->get_value(), Controllable::NoGroup);
1343 EditorRoutes::get_relevant_routes (boost::shared_ptr<RouteList> rl)
1346 RouteTimeAxisView* rtv;
1347 RefPtr<TreeSelection> selection = _display.get_selection();
1351 if (selection->count_selected_rows() != 0) {
1355 RefPtr<TreeModel> tm = RefPtr<TreeModel>::cast_dynamic (_model);
1356 iter = selection->get_selected (tm);
1359 /* use mouse pointer */
1364 _display.get_pointer (x, y);
1365 _display.convert_widget_to_bin_window_coords (x, y, bx, by);
1367 if (_display.get_path_at_pos (bx, by, path)) {
1368 iter = _model->get_iter (path);
1373 tv = (*iter)[_columns.tv];
1375 rtv = dynamic_cast<RouteTimeAxisView*>(tv);
1377 rl->push_back (rtv->route());
1382 return !rl->empty();
1386 EditorRoutes::button_press (GdkEventButton* ev)
1388 if (Keyboard::is_context_menu_event (ev)) {
1392 _menu->popup (ev->button, ev->time);
1396 TreeModel::Path path;
1397 TreeViewColumn *tvc;
1401 if (!_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, tvc, cell_x, cell_y)) {
1402 /* cancel selection */
1403 _display.get_selection()->unselect_all ();
1404 /* end any editing by grabbing focus */
1405 _display.grab_focus ();
1409 //Scroll editor canvas to selected track
1410 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1412 Gtk::TreeModel::Row row = *_model->get_iter (path);
1413 TimeAxisView *tv = row[_columns.tv];
1416 _editor->ensure_time_axis_view_is_visible (*tv, true);
1424 EditorRoutes::selection_changed ()
1426 if (_ignore_selection_change) {
1430 _editor->begin_reversible_selection_op (X_("Select Track from Route List"));
1432 if (_display.get_selection()->count_selected_rows() > 0) {
1435 TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
1436 TrackViewList selected;
1438 for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
1440 if ((iter = _model->get_iter (*i))) {
1442 TimeAxisView* tv = (*iter)[_columns.tv];
1443 selected.push_back (tv);
1448 _editor->get_selection().set (selected);
1449 _editor->ensure_time_axis_view_is_visible (*(selected.front()), true);
1452 _editor->get_selection().clear_tracks ();
1455 _editor->commit_reversible_selection_op ();
1459 EditorRoutes::selection_filter (Glib::RefPtr<TreeModel> const& model, TreeModel::Path const& path, bool /*selected*/)
1461 TreeModel::iterator iter = model->get_iter (path);
1463 boost::shared_ptr<Stripable> stripable = (*iter)[_columns.stripable];
1464 if (boost::dynamic_pointer_cast<VCA> (stripable)) {
1473 EditorRoutes::initial_display ()
1481 DisplaySuspender ds;
1486 RouteList r (*_session->get_routes());
1487 for (RouteList::iterator ri = r.begin(); ri != r.end(); ++ri) {
1491 VCAList v (_session->vca_manager().vcas());
1492 for (VCAList::iterator vi = v.begin(); vi != v.end(); ++vi) {
1496 _editor->add_stripables (s);
1498 sync_treeview_from_presentation_info (Properties::order);
1501 struct ViewStripable {
1503 boost::shared_ptr<Stripable> stripable;
1505 ViewStripable (TimeAxisView* t, boost::shared_ptr<Stripable> s)
1506 : tav (t), stripable (s) {}
1510 EditorRoutes::move_selected_tracks (bool up)
1512 TimeAxisView* scroll_to = 0;
1514 _session->get_stripables (sl);
1516 if (sl.size() < 2) {
1521 sl.sort (Stripable::Sorter());
1523 std::list<ViewStripable> view_stripables;
1525 /* build a list that includes time axis view information */
1527 for (StripableList::const_iterator sli = sl.begin(); sli != sl.end(); ++sli) {
1528 TimeAxisView* tv = _editor->time_axis_view_from_stripable (*sli);
1529 view_stripables.push_back (ViewStripable (tv, *sli));
1532 /* for each selected stripable, move it above or below the adjacent
1533 * stripable that has a time-axis view representation here. If there's
1534 * no such representation, then
1537 list<ViewStripable>::iterator unselected_neighbour;
1538 list<ViewStripable>::iterator vsi;
1541 PresentationInfo::ChangeSuspender cs;
1544 unselected_neighbour = view_stripables.end ();
1545 vsi = view_stripables.begin();
1547 while (vsi != view_stripables.end()) {
1549 if (vsi->stripable->is_selected()) {
1551 if (unselected_neighbour != view_stripables.end()) {
1553 PresentationInfo::order_t unselected_neighbour_order = unselected_neighbour->stripable->presentation_info().order();
1554 PresentationInfo::order_t my_order = vsi->stripable->presentation_info().order();
1556 unselected_neighbour->stripable->set_presentation_order (my_order);
1557 vsi->stripable->set_presentation_order (unselected_neighbour_order);
1560 scroll_to = vsi->tav;
1567 unselected_neighbour = vsi;
1577 unselected_neighbour = view_stripables.end();
1578 vsi = unselected_neighbour;
1584 if (vsi->stripable->is_selected()) {
1586 if (unselected_neighbour != view_stripables.end()) {
1588 PresentationInfo::order_t unselected_neighbour_order = unselected_neighbour->stripable->presentation_info().order();
1589 PresentationInfo::order_t my_order = vsi->stripable->presentation_info().order();
1591 unselected_neighbour->stripable->set_presentation_order (my_order);
1592 vsi->stripable->set_presentation_order (unselected_neighbour_order);
1595 scroll_to = vsi->tav;
1602 unselected_neighbour = vsi;
1607 } while (vsi != view_stripables.begin());
1612 _editor->ensure_time_axis_view_is_visible (*scroll_to, false);
1617 EditorRoutes::update_input_active_display ()
1619 TreeModel::Children rows = _model->children();
1620 TreeModel::Children::iterator i;
1622 for (i = rows.begin(); i != rows.end(); ++i) {
1623 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1625 if (boost::dynamic_pointer_cast<Track> (stripable)) {
1626 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (stripable);
1629 (*i)[_columns.is_input_active] = mt->input_active();
1636 EditorRoutes::update_rec_display ()
1638 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1639 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1644 EditorRoutes::idle_update_mute_rec_solo_etc()
1646 g_atomic_int_set (const_cast<gint*>(&_queue_tv_update), 0);
1647 TreeModel::Children rows = _model->children();
1648 TreeModel::Children::iterator i;
1650 for (i = rows.begin(); i != rows.end(); ++i) {
1651 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1652 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
1653 (*i)[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
1654 (*i)[_columns.solo_state] = RouteUI::solo_active_state (stripable);
1655 (*i)[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable) ? 1 : 0;
1656 (*i)[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable) ? 1 : 0;
1658 (*i)[_columns.active] = route->active ();
1660 (*i)[_columns.active] = true;
1663 boost::shared_ptr<Track> trk (boost::dynamic_pointer_cast<Track>(route));
1666 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
1668 if (trk->rec_enable_control()->get_value()) {
1669 if (_session->record_status() == Session::Recording) {
1670 (*i)[_columns.rec_state] = 1;
1672 (*i)[_columns.rec_state] = 2;
1674 } else if (mt && mt->step_editing()) {
1675 (*i)[_columns.rec_state] = 3;
1677 (*i)[_columns.rec_state] = 0;
1680 (*i)[_columns.rec_safe] = trk->rec_safe_control()->get_value();
1681 (*i)[_columns.name_editable] = !trk->rec_enable_control()->get_value();
1685 return false; // do not call again (until needed)
1690 EditorRoutes::update_mute_display ()
1692 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1693 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1698 EditorRoutes::update_solo_display ()
1700 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1701 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1706 EditorRoutes::update_solo_isolate_display ()
1708 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1709 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1714 EditorRoutes::update_solo_safe_display ()
1716 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1717 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1722 EditorRoutes::views () const
1724 list<TimeAxisView*> v;
1725 for (TreeModel::Children::iterator i = _model->children().begin(); i != _model->children().end(); ++i) {
1726 v.push_back ((*i)[_columns.tv]);
1733 EditorRoutes::clear ()
1735 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
1736 _display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
1738 _display.set_model (_model);
1742 EditorRoutes::name_edit_started (CellEditable* ce, const Glib::ustring&)
1746 /* give it a special name */
1748 Gtk::Entry *e = dynamic_cast<Gtk::Entry*> (ce);
1751 e->set_name (X_("RouteNameEditorEntry"));
1756 EditorRoutes::name_edit (std::string const & path, std::string const & new_text)
1760 TreeIter iter = _model->get_iter (path);
1766 boost::shared_ptr<Stripable> stripable = (*iter)[_columns.stripable];
1768 if (stripable && stripable->name() != new_text) {
1769 stripable->set_name (new_text);
1774 EditorRoutes::solo_changed_so_update_mute ()
1776 update_mute_display ();
1780 EditorRoutes::show_tracks_with_regions_at_playhead ()
1782 boost::shared_ptr<RouteList> const r = _session->get_routes_with_regions_at (_session->transport_frame ());
1784 set<TimeAxisView*> show;
1785 for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
1786 TimeAxisView* tav = _editor->time_axis_view_from_stripable (*i);
1792 DisplaySuspender ds;
1794 TreeModel::Children rows = _model->children ();
1795 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
1796 TimeAxisView* tv = (*i)[_columns.tv];
1797 bool to_show = (show.find (tv) != show.end());
1799 tv->set_marked_for_display (to_show);
1800 (*i)[_columns.visible] = to_show;
1803 /* force route order keys catch up with visibility changes
1806 sync_presentation_info_from_treeview ();
1810 EditorRoutes::plugin_setup (boost::shared_ptr<Route> r, boost::shared_ptr<PluginInsert> pi, ARDOUR::Route::PluginSetupOptions flags)
1812 PluginSetupDialog psd (r, pi, flags);
1813 int rv = psd.run ();
1814 return rv + (psd.fan_out() ? 4 : 0);