correct name of Midi-UI thread memory-pool and request-queue
[ardour.git] / gtk2_ardour / editor_routes.cc
index 30082adec4642b81a52dc510a911c15b8dd783f3..588b900f192b3b7a875b5fd93a7bdbf517712d4b 100644 (file)
@@ -47,6 +47,7 @@
 #include "midi_time_axis.h"
 #include "mixer_strip.h"
 #include "route_sorter.h"
+#include "tooltips.h"
 #include "utils.h"
 
 #include "i18n.h"
@@ -72,12 +73,13 @@ EditorRoutes::EditorRoutes (Editor* e)
        , _no_redisplay (false)
        , _adding_routes (false)
        , _route_deletion_in_progress (false)
+       , _redisplay_on_resume (false)
        , _redisplay_active (0)
        , _queue_tv_update (0)
        , _menu (0)
        , old_focus (0)
        , selection_countdown (0)
-               , name_editable (0)
+       , name_editable (0)
 {
        static const int column_width = 22;
 
@@ -203,22 +205,22 @@ EditorRoutes::EditorRoutes (Editor* e)
        Gtk::Label* l;
 
        ColumnInfo ci[] = {
-               { 0, _("Name"), _("Track/Bus Name") },
-               { 1, _("V"), _("Track/Bus visible ?") },
-               { 2, _("A"), _("Track/Bus active ?") },
-               { 3, _("I"), _("MIDI input enabled") },
-               { 4, _("R"), _("Record enabled") },
-               { 5, _("M"), _("Muted") },
-               { 6, _("S"), _("Soloed") },
-               { 7, _("SI"), _("Solo Isolated") },
-               { 8, _("SS"), _("Solo Safe (Locked)") },
+               { 0,  _("Name"),        _("Track/Bus Name") },
+               { 1, S_("Visible|V"),   _("Track/Bus visible ?") },
+               { 2, S_("Active|A"),    _("Track/Bus active ?") },
+               { 3, S_("MidiInput|I"), _("MIDI input enabled") },
+               { 4, S_("Rec|R"),       _("Record enabled") },
+               { 5, S_("Mute|M"),      _("Muted") },
+               { 6, S_("Solo|S"),      _("Soloed") },
+               { 7, S_("SoloIso|SI"),  _("Solo Isolated") },
+               { 8, S_("SoloLock|SS"), _("Solo Safe (Locked)") },
                { -1, 0, 0 }
        };
 
        for (int i = 0; ci[i].index >= 0; ++i) {
                col = _display.get_column (ci[i].index);
                l = manage (new Label (ci[i].label));
-               ARDOUR_UI::instance()->set_tip (*l, ci[i].tooltip);
+               set_tooltip (*l, ci[i].tooltip);
                col->set_widget (*l);
                l->show ();
        }
@@ -360,6 +362,13 @@ EditorRoutes::set_session (Session* s)
        if (_session) {
                _session->SoloChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::solo_changed_so_update_mute, this), gui_context());
                _session->RecordStateChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
+
+               /* TODO: check if these needs to be tied in with DisplaySuspender
+                * Given that the UI is single-threaded and DisplaySuspender is only used
+                * in loops in the UI thread all should be fine.
+                */
+               _session->BatchUpdateStart.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::suspend_redisplay, this), gui_context());
+               _session->BatchUpdateEnd.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::resume_redisplay, this), gui_context());
        }
 }
 
@@ -481,7 +490,7 @@ EditorRoutes::build_menu ()
        items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiobus)));
        items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_miditracks)));
        items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_miditracks)));
-       items.push_back (MenuElem (_("Show Tracks With Regions Under Playhead"), sigc::mem_fun (*this, &EditorRoutes::show_tracks_with_regions_at_playhead)));
+       items.push_back (MenuElem (_("Only Show Tracks with Regions Under Playhead"), sigc::mem_fun (*this, &EditorRoutes::show_tracks_with_regions_at_playhead)));
 }
 
 void
@@ -515,17 +524,8 @@ EditorRoutes::redisplay_real ()
                        continue;
                }
 
-               if (route->is_master()) {
-                       
-                       tv->hide(); // never show master bus
-                       if (_editor->master_bus_ui ()) {
-                               _editor->master_bus_ui ()->set_route (route);
-                       }
-                       continue;
-               }
-               
                bool visible = tv->marked_for_display ();
-               
+
                /* show or hide the TimeAxisView */
                if (visible) {
                        position += tv->show_at (position, n, &_editor->edit_controls_vbox);
@@ -558,7 +558,12 @@ EditorRoutes::redisplay_real ()
 void
 EditorRoutes::redisplay ()
 {
-       if (_no_redisplay || !_session || _session->deletion_in_progress()) {
+       if (!_session || _session->deletion_in_progress()) {
+               return;
+       }
+
+       if (_no_redisplay) {
+               _redisplay_on_resume = true;
                return;
        }
 
@@ -645,7 +650,6 @@ void
 EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
 {
        PBD::Unwinder<bool> at (_adding_routes, true);
-
        bool from_scratch = (_model->children().size() == 0);
        Gtk::TreeModel::Children::iterator insert_iter = _model->children().end();
 
@@ -658,10 +662,6 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
                }
        }
 
-       if(!from_scratch) {
-               _editor->selection->tracks.clear();
-       }
-
        DisplaySuspender ds;
 
        _display.set_model (Glib::RefPtr<ListStore>());
@@ -694,10 +694,6 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
                row[_columns.solo_safe_state] = (*x)->route()->solo_safe();
                row[_columns.name_editable] = true;
 
-               if (!from_scratch) {
-                       _editor->selection->add(*x);
-               }
-
                boost::weak_ptr<Route> wr ((*x)->route());
 
                (*x)->route()->gui_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::handle_gui_changes, this, _1, _2), gui_context());
@@ -734,8 +730,9 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
        _display.set_model (_model);
 
        /* now update route order keys from the treeview/track display order */
-
-       sync_order_keys_from_treeview ();
+       if (!from_scratch) {
+               sync_order_keys_from_treeview ();
+       }
 }
 
 void
@@ -888,10 +885,19 @@ EditorRoutes::reset_remote_control_ids ()
 
        for (ri = rows.begin(); ri != rows.end(); ++ri) {
 
+               /* skip two special values */
+
+               if (rid == Route::MasterBusRemoteControlID) {
+                       rid++;
+               }
+
+               if (rid == Route::MonitorBusRemoteControlID) {
+                       rid++;
+               }
+
                boost::shared_ptr<Route> route = (*ri)[_columns.route];
                bool visible = (*ri)[_columns.visible];
 
-
                if (!route->is_master() && !route->is_monitor()) {
 
                        uint32_t new_rid = (visible ? rid : invisible_key--);
@@ -1112,17 +1118,20 @@ EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn)
                if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
                        switch (tracks) {
                        case 0:
+                               atv->set_marked_for_display (yn);
                                (*i)[_columns.visible] = yn;
                                break;
 
                        case 1:
                                if (atv->is_audio_track()) {
+                                       atv->set_marked_for_display (yn);
                                        (*i)[_columns.visible] = yn;
                                }
                                break;
 
                        case 2:
                                if (!atv->is_audio_track()) {
+                                       atv->set_marked_for_display (yn);
                                        (*i)[_columns.visible] = yn;
                                }
                                break;
@@ -1131,11 +1140,13 @@ EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn)
                else if ((mtv = dynamic_cast<MidiTimeAxisView*>(tv)) != 0) {
                        switch (tracks) {
                        case 0:
+                               mtv->set_marked_for_display (yn);
                                (*i)[_columns.visible] = yn;
                                break;
 
                        case 3:
                                if (mtv->is_midi_track()) {
+                                       mtv->set_marked_for_display (yn);
                                        (*i)[_columns.visible] = yn;
                                }
                                break;
@@ -1402,29 +1413,10 @@ EditorRoutes::initial_display ()
                return;
        }
 
-       boost::shared_ptr<RouteList> routes = _session->get_routes();
-
-       if (ARDOUR_UI::instance()->session_is_new ()) {
-
-               /* new session: stamp all routes with the right editor order
-                * key
-                */
-
-               _editor->add_routes (*(routes.get()));
-
-       } else {
-
-               /* existing session: sort a copy of the route list by
-                * editor-order and add its contents to the display.
-                */
-
-               RouteList r (*routes);
-               EditorOrderRouteSorter sorter;
+       RouteList r (*_session->get_routes());
 
-               r.sort (sorter);
-               _editor->add_routes (r);
-
-       }
+       r.sort (EditorOrderRouteSorter ());
+       _editor->add_routes (r);
 }
 
 void
@@ -1610,7 +1602,7 @@ EditorRoutes::idle_update_mute_rec_solo_etc()
                (*i)[_columns.active] = route->active ();
                if (boost::dynamic_pointer_cast<Track> (route)) {
                        boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
-                       
+
                        if (route->record_enabled()) {
                                if (_session->record_status() == Session::Recording) {
                                        (*i)[_columns.rec_state] = 1;
@@ -1622,7 +1614,7 @@ EditorRoutes::idle_update_mute_rec_solo_etc()
                        } else {
                                (*i)[_columns.rec_state] = 0;
                        }
-                       
+
                        (*i)[_columns.name_editable] = !route->record_enabled ();
                }
        }
@@ -1738,6 +1730,14 @@ EditorRoutes::show_tracks_with_regions_at_playhead ()
        TreeModel::Children rows = _model->children ();
        for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
                TimeAxisView* tv = (*i)[_columns.tv];
-               (*i)[_columns.visible] = (show.find (tv) != show.end());
+               bool to_show = (show.find (tv) != show.end());
+
+               tv->set_marked_for_display (to_show);
+               (*i)[_columns.visible] = to_show;
        }
+
+       /* force route order keys catch up with visibility changes
+        */
+
+       sync_order_keys_from_treeview ();
 }