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
950 sync_presentation_info_from_treeview ();
954 EditorRoutes::hide_track_in_display (TimeAxisView& tv)
956 TreeModel::Children rows = _model->children();
957 TreeModel::Children::iterator i;
959 for (i = rows.begin(); i != rows.end(); ++i) {
960 if ((*i)[_columns.tv] == &tv) {
961 tv.set_marked_for_display (false);
962 (*i)[_columns.visible] = false;
970 EditorRoutes::show_track_in_display (TimeAxisView& tv)
972 TreeModel::Children rows = _model->children();
973 TreeModel::Children::iterator i;
976 for (i = rows.begin(); i != rows.end(); ++i) {
977 if ((*i)[_columns.tv] == &tv) {
978 tv.set_marked_for_display (true);
979 (*i)[_columns.visible] = true;
987 EditorRoutes::sync_presentation_info_from_treeview ()
989 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
993 TreeModel::Children rows = _model->children();
999 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync presentation info from treeview\n");
1001 TreeModel::Children::iterator ri;
1002 bool change = false;
1003 PresentationInfo::order_t order = 0;
1005 PresentationInfo::ChangeSuspender cs;
1007 for (ri = rows.begin(); ri != rows.end(); ++ri) {
1008 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1009 bool visible = (*ri)[_columns.visible];
1011 #ifndef NDEBUG // these should not exist in the treeview
1012 if (stripable->is_monitor() || stripable->is_auditioner()) {
1018 stripable->presentation_info().set_hidden (!visible);
1020 if (order != stripable->presentation_info().order()) {
1021 stripable->set_presentation_order (order);
1027 change |= _session->ensure_stripable_sort_order ();
1030 _session->set_dirty();
1035 EditorRoutes::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
1037 /* Some route order key(s) have been changed, make sure that
1038 we update out tree/list model and GUI to reflect the change.
1041 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
1045 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync model from presentation info.\n");
1047 PropertyChange hidden_or_order;
1048 hidden_or_order.add (Properties::hidden);
1049 hidden_or_order.add (Properties::order);
1051 TreeModel::Children rows = _model->children();
1053 if (what_changed.contains (hidden_or_order)) {
1055 vector<int> neworder;
1056 uint32_t old_order = 0;
1057 bool changed = false;
1063 TreeOrderKeys sorted;
1064 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
1065 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1066 /* use global order */
1067 sorted.push_back (TreeOrderKey (old_order, stripable));
1070 TreeOrderKeySorter cmp;
1072 sort (sorted.begin(), sorted.end(), cmp);
1073 neworder.assign (sorted.size(), 0);
1077 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
1079 neworder[n] = sr->old_display_order;
1081 if (sr->old_display_order != n) {
1087 Unwinder<bool> uw (_ignore_reorder, true);
1088 /* prevent traverse_cells: assertion 'row_path != NULL'
1089 * in case of DnD re-order: row-removed + row-inserted.
1091 * The rows (stripables) are not actually removed from the model,
1092 * but only from the display in the DnDTreeView.
1093 * ->reorder() will fail to find the row_path.
1094 * (re-order drag -> remove row -> sync PI from TV -> notify -> sync TV from PI -> crash)
1096 Unwinder<bool> uw2 (_ignore_selection_change, true);
1098 _display.unset_model();
1099 _model->reorder (neworder);
1100 _display.set_model (_model);
1104 if (what_changed.contains (Properties::selected)) {
1106 /* by the time this is invoked, the GUI Selection model has
1107 * already updated itself.
1110 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
1111 /* set the treeview model selection state */
1113 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) {
1114 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1115 if (stripable && stripable->is_selected()) {
1116 _display.get_selection()->select (*ri);
1118 _display.get_selection()->unselect (*ri);
1127 EditorRoutes::hide_all_tracks (bool /*with_select*/)
1129 TreeModel::Children rows = _model->children();
1130 TreeModel::Children::iterator i;
1132 DisplaySuspender ds;
1134 for (i = rows.begin(); i != rows.end(); ++i) {
1136 TreeModel::Row row = (*i);
1137 TimeAxisView *tv = row[_columns.tv];
1143 row[_columns.visible] = false;
1148 EditorRoutes::set_all_tracks_visibility (bool yn)
1150 TreeModel::Children rows = _model->children();
1151 TreeModel::Children::iterator i;
1153 DisplaySuspender ds;
1155 for (i = rows.begin(); i != rows.end(); ++i) {
1157 TreeModel::Row row = (*i);
1158 TimeAxisView* tv = row[_columns.tv];
1164 tv->set_marked_for_display (yn);
1165 (*i)[_columns.visible] = yn;
1168 /* force route order keys catch up with visibility changes
1171 sync_presentation_info_from_treeview ();
1175 EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn)
1177 TreeModel::Children rows = _model->children();
1178 TreeModel::Children::iterator i;
1180 DisplaySuspender ds;
1182 for (i = rows.begin(); i != rows.end(); ++i) {
1184 TreeModel::Row row = (*i);
1185 TimeAxisView* tv = row[_columns.tv];
1187 AudioTimeAxisView* atv;
1188 MidiTimeAxisView* mtv;
1194 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1197 atv->set_marked_for_display (yn);
1198 (*i)[_columns.visible] = yn;
1202 if (atv->is_audio_track()) {
1203 atv->set_marked_for_display (yn);
1204 (*i)[_columns.visible] = yn;
1209 if (!atv->is_audio_track()) {
1210 atv->set_marked_for_display (yn);
1211 (*i)[_columns.visible] = yn;
1216 else if ((mtv = dynamic_cast<MidiTimeAxisView*>(tv)) != 0) {
1219 mtv->set_marked_for_display (yn);
1220 (*i)[_columns.visible] = yn;
1224 if (mtv->is_midi_track()) {
1225 mtv->set_marked_for_display (yn);
1226 (*i)[_columns.visible] = yn;
1233 /* force route order keys catch up with visibility changes
1236 sync_presentation_info_from_treeview ();
1240 EditorRoutes::hide_all_routes ()
1242 set_all_tracks_visibility (false);
1246 EditorRoutes::show_all_routes ()
1248 set_all_tracks_visibility (true);
1252 EditorRoutes::show_all_audiotracks()
1254 set_all_audio_midi_visibility (1, true);
1257 EditorRoutes::hide_all_audiotracks ()
1259 set_all_audio_midi_visibility (1, false);
1263 EditorRoutes::show_all_audiobus ()
1265 set_all_audio_midi_visibility (2, true);
1268 EditorRoutes::hide_all_audiobus ()
1270 set_all_audio_midi_visibility (2, false);
1274 EditorRoutes::show_all_miditracks()
1276 set_all_audio_midi_visibility (3, true);
1279 EditorRoutes::hide_all_miditracks ()
1281 set_all_audio_midi_visibility (3, false);
1285 EditorRoutes::key_press (GdkEventKey* ev)
1287 TreeViewColumn *col;
1288 boost::shared_ptr<RouteList> rl (new RouteList);
1291 switch (ev->keyval) {
1293 case GDK_ISO_Left_Tab:
1295 /* If we appear to be editing something, leave that cleanly and appropriately. */
1296 if (name_editable) {
1297 name_editable->editing_done ();
1301 col = _display.get_column (_name_column); // select&focus on name column
1303 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
1304 treeview_select_previous (_display, _model, col);
1306 treeview_select_next (_display, _model, col);
1313 if (get_relevant_routes (rl)) {
1314 _session->set_controls (route_list_to_control_list (rl, &Stripable::mute_control), rl->front()->muted() ? 0.0 : 1.0, Controllable::NoGroup);
1320 if (get_relevant_routes (rl)) {
1321 _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), rl->front()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
1327 if (get_relevant_routes (rl)) {
1328 for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
1329 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*r);
1331 _session->set_controls (route_list_to_control_list (rl, &Stripable::rec_enable_control), !t->rec_enable_control()->get_value(), Controllable::NoGroup);
1346 EditorRoutes::get_relevant_routes (boost::shared_ptr<RouteList> rl)
1349 RouteTimeAxisView* rtv;
1350 RefPtr<TreeSelection> selection = _display.get_selection();
1354 if (selection->count_selected_rows() != 0) {
1358 RefPtr<TreeModel> tm = RefPtr<TreeModel>::cast_dynamic (_model);
1359 iter = selection->get_selected (tm);
1362 /* use mouse pointer */
1367 _display.get_pointer (x, y);
1368 _display.convert_widget_to_bin_window_coords (x, y, bx, by);
1370 if (_display.get_path_at_pos (bx, by, path)) {
1371 iter = _model->get_iter (path);
1376 tv = (*iter)[_columns.tv];
1378 rtv = dynamic_cast<RouteTimeAxisView*>(tv);
1380 rl->push_back (rtv->route());
1385 return !rl->empty();
1389 EditorRoutes::button_press (GdkEventButton* ev)
1391 if (Keyboard::is_context_menu_event (ev)) {
1395 _menu->popup (ev->button, ev->time);
1399 TreeModel::Path path;
1400 TreeViewColumn *tvc;
1404 if (!_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, tvc, cell_x, cell_y)) {
1405 /* cancel selection */
1406 _display.get_selection()->unselect_all ();
1407 /* end any editing by grabbing focus */
1408 _display.grab_focus ();
1412 //Scroll editor canvas to selected track
1413 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1415 Gtk::TreeModel::Row row = *_model->get_iter (path);
1416 TimeAxisView *tv = row[_columns.tv];
1419 _editor->ensure_time_axis_view_is_visible (*tv, true);
1427 EditorRoutes::selection_changed ()
1429 if (_ignore_selection_change) {
1433 _editor->begin_reversible_selection_op (X_("Select Track from Route List"));
1435 if (_display.get_selection()->count_selected_rows() > 0) {
1438 TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
1439 TrackViewList selected;
1441 for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
1443 if ((iter = _model->get_iter (*i))) {
1445 TimeAxisView* tv = (*iter)[_columns.tv];
1446 selected.push_back (tv);
1451 _editor->get_selection().set (selected);
1452 _editor->ensure_time_axis_view_is_visible (*(selected.front()), true);
1455 _editor->get_selection().clear_tracks ();
1458 _editor->commit_reversible_selection_op ();
1462 EditorRoutes::selection_filter (Glib::RefPtr<TreeModel> const& model, TreeModel::Path const& path, bool /*selected*/)
1464 TreeModel::iterator iter = model->get_iter (path);
1466 boost::shared_ptr<Stripable> stripable = (*iter)[_columns.stripable];
1467 if (boost::dynamic_pointer_cast<VCA> (stripable)) {
1476 EditorRoutes::initial_display ()
1484 DisplaySuspender ds;
1489 RouteList r (*_session->get_routes());
1490 for (RouteList::iterator ri = r.begin(); ri != r.end(); ++ri) {
1494 VCAList v (_session->vca_manager().vcas());
1495 for (VCAList::iterator vi = v.begin(); vi != v.end(); ++vi) {
1499 _editor->add_stripables (s);
1501 sync_treeview_from_presentation_info (Properties::order);
1504 struct ViewStripable {
1506 boost::shared_ptr<Stripable> stripable;
1508 ViewStripable (TimeAxisView* t, boost::shared_ptr<Stripable> s)
1509 : tav (t), stripable (s) {}
1513 EditorRoutes::move_selected_tracks (bool up)
1515 TimeAxisView* scroll_to = 0;
1517 _session->get_stripables (sl);
1519 if (sl.size() < 2) {
1524 sl.sort (Stripable::Sorter());
1526 std::list<ViewStripable> view_stripables;
1528 /* build a list that includes time axis view information */
1530 for (StripableList::const_iterator sli = sl.begin(); sli != sl.end(); ++sli) {
1531 TimeAxisView* tv = _editor->time_axis_view_from_stripable (*sli);
1532 view_stripables.push_back (ViewStripable (tv, *sli));
1535 /* for each selected stripable, move it above or below the adjacent
1536 * stripable that has a time-axis view representation here. If there's
1537 * no such representation, then
1540 list<ViewStripable>::iterator unselected_neighbour;
1541 list<ViewStripable>::iterator vsi;
1544 PresentationInfo::ChangeSuspender cs;
1547 unselected_neighbour = view_stripables.end ();
1548 vsi = view_stripables.begin();
1550 while (vsi != view_stripables.end()) {
1552 if (vsi->stripable->is_selected()) {
1554 if (unselected_neighbour != view_stripables.end()) {
1556 PresentationInfo::order_t unselected_neighbour_order = unselected_neighbour->stripable->presentation_info().order();
1557 PresentationInfo::order_t my_order = vsi->stripable->presentation_info().order();
1559 unselected_neighbour->stripable->set_presentation_order (my_order);
1560 vsi->stripable->set_presentation_order (unselected_neighbour_order);
1563 scroll_to = vsi->tav;
1570 unselected_neighbour = vsi;
1580 unselected_neighbour = view_stripables.end();
1581 vsi = unselected_neighbour;
1587 if (vsi->stripable->is_selected()) {
1589 if (unselected_neighbour != view_stripables.end()) {
1591 PresentationInfo::order_t unselected_neighbour_order = unselected_neighbour->stripable->presentation_info().order();
1592 PresentationInfo::order_t my_order = vsi->stripable->presentation_info().order();
1594 unselected_neighbour->stripable->set_presentation_order (my_order);
1595 vsi->stripable->set_presentation_order (unselected_neighbour_order);
1598 scroll_to = vsi->tav;
1605 unselected_neighbour = vsi;
1610 } while (vsi != view_stripables.begin());
1615 _editor->ensure_time_axis_view_is_visible (*scroll_to, false);
1620 EditorRoutes::update_input_active_display ()
1622 TreeModel::Children rows = _model->children();
1623 TreeModel::Children::iterator i;
1625 for (i = rows.begin(); i != rows.end(); ++i) {
1626 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1628 if (boost::dynamic_pointer_cast<Track> (stripable)) {
1629 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (stripable);
1632 (*i)[_columns.is_input_active] = mt->input_active();
1639 EditorRoutes::update_rec_display ()
1641 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1642 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1647 EditorRoutes::idle_update_mute_rec_solo_etc()
1649 g_atomic_int_set (const_cast<gint*>(&_queue_tv_update), 0);
1650 TreeModel::Children rows = _model->children();
1651 TreeModel::Children::iterator i;
1653 for (i = rows.begin(); i != rows.end(); ++i) {
1654 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1655 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
1656 (*i)[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
1657 (*i)[_columns.solo_state] = RouteUI::solo_active_state (stripable);
1658 (*i)[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable) ? 1 : 0;
1659 (*i)[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable) ? 1 : 0;
1661 (*i)[_columns.active] = route->active ();
1663 (*i)[_columns.active] = true;
1666 boost::shared_ptr<Track> trk (boost::dynamic_pointer_cast<Track>(route));
1669 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
1671 if (trk->rec_enable_control()->get_value()) {
1672 if (_session->record_status() == Session::Recording) {
1673 (*i)[_columns.rec_state] = 1;
1675 (*i)[_columns.rec_state] = 2;
1677 } else if (mt && mt->step_editing()) {
1678 (*i)[_columns.rec_state] = 3;
1680 (*i)[_columns.rec_state] = 0;
1683 (*i)[_columns.rec_safe] = trk->rec_safe_control()->get_value();
1684 (*i)[_columns.name_editable] = !trk->rec_enable_control()->get_value();
1688 return false; // do not call again (until needed)
1693 EditorRoutes::update_mute_display ()
1695 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1696 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1701 EditorRoutes::update_solo_display ()
1703 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1704 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1709 EditorRoutes::update_solo_isolate_display ()
1711 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1712 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1717 EditorRoutes::update_solo_safe_display ()
1719 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1720 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1725 EditorRoutes::views () const
1727 list<TimeAxisView*> v;
1728 for (TreeModel::Children::iterator i = _model->children().begin(); i != _model->children().end(); ++i) {
1729 v.push_back ((*i)[_columns.tv]);
1736 EditorRoutes::clear ()
1738 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
1739 _display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
1741 _display.set_model (_model);
1745 EditorRoutes::name_edit_started (CellEditable* ce, const Glib::ustring&)
1749 /* give it a special name */
1751 Gtk::Entry *e = dynamic_cast<Gtk::Entry*> (ce);
1754 e->set_name (X_("RouteNameEditorEntry"));
1759 EditorRoutes::name_edit (std::string const & path, std::string const & new_text)
1763 TreeIter iter = _model->get_iter (path);
1769 boost::shared_ptr<Stripable> stripable = (*iter)[_columns.stripable];
1771 if (stripable && stripable->name() != new_text) {
1772 stripable->set_name (new_text);
1777 EditorRoutes::solo_changed_so_update_mute ()
1779 update_mute_display ();
1783 EditorRoutes::show_tracks_with_regions_at_playhead ()
1785 boost::shared_ptr<RouteList> const r = _session->get_routes_with_regions_at (_session->transport_frame ());
1787 set<TimeAxisView*> show;
1788 for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
1789 TimeAxisView* tav = _editor->time_axis_view_from_stripable (*i);
1795 DisplaySuspender ds;
1797 TreeModel::Children rows = _model->children ();
1798 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
1799 TimeAxisView* tv = (*i)[_columns.tv];
1800 bool to_show = (show.find (tv) != show.end());
1802 tv->set_marked_for_display (to_show);
1803 (*i)[_columns.visible] = to_show;
1806 /* force route order keys catch up with visibility changes
1809 sync_presentation_info_from_treeview ();
1813 EditorRoutes::plugin_setup (boost::shared_ptr<Route> r, boost::shared_ptr<PluginInsert> pi, ARDOUR::Route::PluginSetupOptions flags)
1815 PluginSetupDialog psd (r, pi, flags);
1816 int rv = psd.run ();
1817 return rv + (psd.fan_out() ? 4 : 0);