generalize VCA assign/unassign code.
[ardour.git] / gtk2_ardour / export_channel_selector.cc
index 77cabad5a17a55508010129279573cc04bcd2261..c411c2b22c3acc490cc8ea5ae1c9406eb6d5871a 100644 (file)
@@ -40,6 +40,12 @@ using namespace Glib;
 using namespace ARDOUR;
 using namespace PBD;
 
+struct EditorOrderRouteSorter {
+    bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
+           return a->order_key () < b->order_key ();
+    }
+};
+
 PortExportChannelSelector::PortExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager) :
   ExportChannelSelector (session, manager),
   channels_label (_("Channels:"), Gtk::ALIGN_LEFT),
@@ -98,6 +104,11 @@ PortExportChannelSelector::sync_with_manager ()
        split_checkbox.set_active (state->config->get_split());
        channels_spinbutton.set_value (state->config->get_n_chans());
 
+       /* when loading presets, config is ready set here (shared ptr)
+        * fill_route_list () -> update_channel_count () -> set_channel_count () -> update_config()
+        * will call config->clear_channels(); and clear the config
+        */
+       channel_view.set_config (ChannelConfigPtr ());
        fill_route_list ();
        channel_view.set_config (state->config);
 }
@@ -115,6 +126,8 @@ PortExportChannelSelector::fill_route_list ()
                channel_view.add_route (master);
        }
 
+       routes.sort (EditorOrderRouteSorter ());
+
        for (RouteList::iterator it = routes.begin(); it != routes.end(); ++it) {
                if ((*it)->is_master () || (*it)->is_monitor ()) {
                        continue;
@@ -209,6 +222,7 @@ PortExportChannelSelector::ChannelTreeView::set_config (ChannelConfigPtr c)
 
        if (config == c) { return; }
        config = c;
+       if (!config) { return; }
 
        uint32_t i = 1;
        ExportChannelConfiguration::ChannelList chan_list = config->get_channels();
@@ -528,7 +542,8 @@ RegionExportChannelSelector::handle_selection ()
        factory.reset (new RegionExportChannelFactory (_session, region, track, type));
        state->config->set_region_processing_type (type);
 
-       for (size_t chan = 0; chan < region_chans; ++chan) {
+       const size_t cc = type == RegionExportChannelFactory::Processed ? track_chans : region_chans;
+       for (size_t chan = 0; chan < cc; ++chan) {
                state->config->register_channel (factory->create (chan));
        }
 
@@ -539,8 +554,7 @@ RegionExportChannelSelector::handle_selection ()
 
 TrackExportChannelSelector::TrackExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager)
   : ExportChannelSelector(session, manager)
-  , region_contents_button(source_group, _("Export region contents"))
-  , track_output_button(source_group, _("Export track output"))
+  , track_output_button(_("Apply track/bus processing"))
   , select_tracks_button (_("Select all tracks"))
   , select_busses_button (_("Select all busses"))
   , select_none_button (_("Deselect all"))
@@ -548,7 +562,6 @@ TrackExportChannelSelector::TrackExportChannelSelector (ARDOUR::Session * sessio
        pack_start(main_layout);
 
        // Options
-       options_box.pack_start(region_contents_button);
        options_box.pack_start(track_output_button);
        options_box.pack_start (select_tracks_button);
        options_box.pack_start (select_busses_button);
@@ -588,6 +601,8 @@ TrackExportChannelSelector::TrackExportChannelSelector (ARDOUR::Session * sessio
        select_busses_button.signal_clicked().connect (sigc::mem_fun (*this, &TrackExportChannelSelector::select_busses));
        select_none_button.signal_clicked().connect (sigc::mem_fun (*this, &TrackExportChannelSelector::select_none));
 
+       track_output_button.signal_clicked().connect (sigc::mem_fun (*this, &TrackExportChannelSelector::track_outputs_selected));
+
        fill_list();
 
        show_all_children ();
@@ -638,6 +653,12 @@ TrackExportChannelSelector::select_none ()
        update_config();
 }
 
+void
+TrackExportChannelSelector::track_outputs_selected ()
+{
+       update_config();
+}
+
 void
 TrackExportChannelSelector::fill_list()
 {
@@ -716,6 +737,7 @@ TrackExportChannelSelector::update_config()
                }
 
                state->config->set_name (route->name());
+
        }
 
        CriticalSelectionChanged ();