Bring the note mode menu back from the dead.
[ardour.git] / gtk2_ardour / route_time_axis.cc
index 2eceeb4974d6e438546cbf52cfbc3a7558c07505..674fb2db71ebc82a156b02de7ce52f69bf1359e7 100644 (file)
 #include <gtkmm2ext/bindable_button.h>
 #include <gtkmm2ext/utils.h>
 
-#include <ardour/playlist.h>
 #include <ardour/audioplaylist.h>
 #include <ardour/diskstream.h>
-#include <ardour/processor.h>
 #include <ardour/ladspa_plugin.h>
 #include <ardour/location.h>
 #include <ardour/panner.h>
 #include <ardour/playlist.h>
+#include <ardour/playlist.h>
+#include <ardour/processor.h>
+#include <ardour/profile.h>
+#include <ardour/route_group.h>
 #include <ardour/session.h>
 #include <ardour/session_playlist.h>
 #include <ardour/utils.h>
-#include <ardour/parameter.h>
-#include <ardour/profile.h>
+#include <evoral/Parameter.hpp>
 
 #include "ardour_ui.h"
 #include "route_time_axis.h"
@@ -106,9 +107,9 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
          size_button (_("h")), // height
          automation_button (_("a")),
          visual_button (_("v")),
-         gm (rt, sess, slider, true)
-
+         gm (sess, slider, true)
 {
+       gm.set_io (rt);
        gm.get_level_meter().set_no_show_all();
        gm.get_level_meter().setup_meters(50);
 
@@ -136,6 +137,13 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
        visual_button.set_name ("TrackVisualButton");
        hide_button.set_name ("TrackRemoveButton");
 
+       edit_group_button.unset_flags (Gtk::CAN_FOCUS);
+       playlist_button.unset_flags (Gtk::CAN_FOCUS);
+       automation_button.unset_flags (Gtk::CAN_FOCUS);
+       size_button.unset_flags (Gtk::CAN_FOCUS);
+       visual_button.unset_flags (Gtk::CAN_FOCUS);
+       hide_button.unset_flags (Gtk::CAN_FOCUS);
+
        hide_button.add (*(manage (new Image (::get_icon("hide")))));
        hide_button.show_all ();
 
@@ -147,9 +155,9 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
        hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click));
 
        solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
-       solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release));
+       solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
        mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
-       mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release));
+       mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
 
        if (is_track()) {
 
@@ -213,7 +221,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
                controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
        }
 
-       y_position = -1;
+       _y_position = -1;
 
        _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
        _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
@@ -234,7 +242,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
 
        }
 
-       editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
+       _editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
        ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
 
        gm.get_gain_slider().signal_scroll_event().connect(mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
@@ -249,20 +257,14 @@ RouteTimeAxisView::~RouteTimeAxisView ()
                delete *i;
        }
 
-       if (playlist_menu) {
-               delete playlist_menu;
-               playlist_menu = 0;
-       }
+       delete playlist_menu;
+       playlist_menu = 0;
   
-       if (playlist_action_menu) {
-               delete playlist_action_menu;
-               playlist_action_menu = 0;
-       }
+       delete playlist_action_menu;
+       playlist_action_menu = 0;
 
-       if (_view) {
-               delete _view;
-               _view = 0;
-       }
+       delete _view;
+       _view = 0;
 
        for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
                delete i->second;
@@ -279,8 +281,8 @@ RouteTimeAxisView::post_construct ()
        update_diskstream_display ();
 
        subplugin_menu.items().clear ();
-       _route->foreach_processor (this, &RouteTimeAxisView::add_processor_to_subplugin_menu);
-       _route->foreach_processor (this, &RouteTimeAxisView::add_existing_processor_automation_curves);
+       _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
+       _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
        reset_processor_automation_curves ();
 }
 
@@ -371,7 +373,7 @@ RouteTimeAxisView::label_view ()
 void
 RouteTimeAxisView::route_name_changed ()
 {
-       editor.route_name_changed (this);
+       _editor.route_name_changed (this);
        label_view ();
 }
 
@@ -388,10 +390,8 @@ void
 RouteTimeAxisView::playlist_click ()
 {
        // always build a new action menu
-       
-       if (playlist_action_menu != 0) {
-               delete playlist_action_menu;
-       } 
+  
+       delete playlist_action_menu;
 
        playlist_action_menu = new Menu;
        playlist_action_menu->set_name ("ArdourContextMenu");
@@ -427,7 +427,8 @@ RouteTimeAxisView::set_state (const XMLNode& node)
        for (iter = kids.begin(); iter != kids.end(); ++iter) {
                if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
                        if ((prop = (*iter)->property ("automation-id")) != 0) {
-                               Parameter param(prop->value());
+
+                               Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
                                bool show = ((prop = (*iter)->property ("shown")) != 0) && prop->value() == "yes";
                                create_automation_child(param, show);
                        } else {
@@ -435,6 +436,7 @@ RouteTimeAxisView::set_state (const XMLNode& node)
                        }
                }
        }
+
        return 0;
 }
 
@@ -461,13 +463,12 @@ RouteTimeAxisView::build_automation_action_menu ()
 
        automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
        
-       map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i;
+       map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
        for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
 
                automation_items.push_back (SeparatorElem());
 
-               if (i->second->menu_item)
-                       delete i->second->menu_item;
+               delete i->second->menu_item;
 
                automation_items.push_back(CheckMenuElem (_route->describe_parameter(i->second->param), 
                                bind (mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
@@ -502,11 +503,10 @@ RouteTimeAxisView::build_display_menu ()
 
        items.push_back (SeparatorElem());
 
-       build_remote_control_menu ();
-       build_automation_action_menu ();
-
        if (!Profile->get_sae()) {
+               build_remote_control_menu ();
                items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
+               build_automation_action_menu ();
                items.push_back (MenuElem (_("Automation"), *automation_action_menu));
                items.push_back (SeparatorElem());
        }
@@ -550,14 +550,17 @@ RouteTimeAxisView::build_display_menu ()
 
                if (!Profile->get_sae()) {
                        items.push_back (MenuElem (_("Alignment"), *alignment_menu));
-                       get_diskstream()->AlignmentStyleChanged.connect (mem_fun(*this, &RouteTimeAxisView::align_style_changed));
+                       get_diskstream()->AlignmentStyleChanged.connect (
+                                       mem_fun(*this, &RouteTimeAxisView::align_style_changed));
                        
                        RadioMenuItem::Group mode_group;
-                       items.push_back (RadioMenuElem (mode_group, _("Normal mode"),
-                                                       bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Normal)));
+                       items.push_back (RadioMenuElem (mode_group, _("Normal mode"), bind (
+                                       mem_fun (*this, &RouteTimeAxisView::set_track_mode),
+                                       ARDOUR::Normal)));
                        normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
-                       items.push_back (RadioMenuElem (mode_group, _("Tape mode"),
-                                                       bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Destructive)));
+                       items.push_back (RadioMenuElem (mode_group, _("Tape mode"), bind (
+                                       mem_fun (*this, &RouteTimeAxisView::set_track_mode),
+                                       ARDOUR::Destructive)));
                        destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
                        
                        switch (track()->mode()) {
@@ -568,6 +571,7 @@ RouteTimeAxisView::build_display_menu ()
                                normal_track_mode_item->set_active ();
                                break;
                        }
+               }
 
                get_diskstream()->AlignmentStyleChanged.connect (
                                mem_fun(*this, &RouteTimeAxisView::align_style_changed));
@@ -576,8 +580,11 @@ RouteTimeAxisView::build_display_menu ()
                if (mode_menu)
                        items.push_back (MenuElem (_("Mode"), *mode_menu));
                        
+               color_mode_menu = build_color_mode_menu();
+               if (color_mode_menu)
+                       items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
+                       
                items.push_back (SeparatorElem());
-               }
        }
 
        items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
@@ -586,7 +593,12 @@ RouteTimeAxisView::build_display_menu ()
 
        items.push_back (SeparatorElem());
        items.push_back (MenuElem (_("Hide"), mem_fun(*this, &RouteTimeAxisView::hide_click)));
-       items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
+       if (!Profile->get_sae()) {
+               items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
+       } else {
+               items.push_front (SeparatorElem());
+               items.push_front (MenuElem (_("Delete"), mem_fun(*this, &RouteUI::remove_this_route)));
+       }
 }
 
 static bool __reset_item (RadioMenuItem* item)
@@ -708,7 +720,7 @@ RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
 #endif
 
        if (timestretch_rect == 0) {
-               timestretch_rect = new SimpleRect (*canvas_display);
+               timestretch_rect = new SimpleRect (*canvas_display ());
                timestretch_rect->property_x1() =  0.0;
                timestretch_rect->property_y1() =  0.0;
                timestretch_rect->property_x2() =  0.0;
@@ -720,8 +732,8 @@ RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
        timestretch_rect->show ();
        timestretch_rect->raise_to_top ();
 
-       x1 = start / editor.get_current_zoom();
-       x2 = (end - 1) / editor.get_current_zoom();
+       x1 = start / _editor.get_current_zoom();
+       x2 = (end - 1) / _editor.get_current_zoom();
        y2 = current_height() - 2;
        
        timestretch_rect->property_x1() = x1;
@@ -824,6 +836,18 @@ RouteTimeAxisView::set_height (uint32_t h)
 
        } else {
 
+
+               /* don't allow name_entry to be hidden while
+                  it has focus, otherwise the GUI becomes unusable.
+               */
+
+               if (name_entry.has_focus()) {
+                       if (name_entry.get_text() != _route->name()) {
+                               name_entry_changed ();
+                       }
+                       controls_ebox.grab_focus ();
+               }
+
                hide_name_entry ();
                show_name_label ();
                
@@ -862,7 +886,7 @@ RouteTimeAxisView::select_track_color ()
 void
 RouteTimeAxisView::reset_samples_per_unit ()
 {
-       set_samples_per_unit (editor.get_current_zoom());
+       set_samples_per_unit (_editor.get_current_zoom());
 }
 
 void
@@ -953,8 +977,43 @@ RouteTimeAxisView::rename_current_playlist ()
        }
 }
 
+std::string 
+RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
+{
+       std::string ret(basename);
+
+       std::string group_string = "."+edit_group()->name()+".";
+
+       // iterate through all playlists
+       int maxnumber = 0;
+       for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
+               std::string tmp = (*i)->name();
+
+               std::string::size_type idx = tmp.find(group_string);                    
+               // find those which belong to this group
+               if (idx != string::npos) {
+                       tmp = tmp.substr(idx + group_string.length());
+
+                       // and find the largest current number
+                       int x = atoi(tmp.c_str());
+                       if (x > maxnumber) {
+                               maxnumber = x;
+                       }
+               }
+       }
+
+       maxnumber++;
+
+       char buf[32];
+       snprintf (buf, sizeof(buf), "%d", maxnumber);
+               
+       ret = this->name()+"."+edit_group()->name()+"."+buf;
+
+       return ret;
+}
+
 void
-RouteTimeAxisView::use_copy_playlist (bool prompt)
+RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
 {
        string name;
        
@@ -967,10 +1026,14 @@ RouteTimeAxisView::use_copy_playlist (bool prompt)
                return;
 
        name = pl->name();
+       
+       if (edit_group() && edit_group()->is_active()) {
+               name = resolve_new_group_playlist_name(name, playlists_before_op);
+       }
 
-       do {
+       while (_session.playlist_by_name(name)) {
                name = Playlist::bump_name (name, _session);
-       } while (_session.playlist_by_name(name));
+       }
 
        // TODO: The prompter "new" button should be de-activated if the user
        // specifies a playlist name which already exists in the session.
@@ -1002,7 +1065,7 @@ RouteTimeAxisView::use_copy_playlist (bool prompt)
 }
 
 void
-RouteTimeAxisView::use_new_playlist (bool prompt)
+RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
 {
        string name;
        
@@ -1015,10 +1078,14 @@ RouteTimeAxisView::use_new_playlist (bool prompt)
                return;
 
        name = pl->name();
+       
+       if (edit_group() && edit_group()->is_active()) {
+               name = resolve_new_group_playlist_name(name,playlists_before_op);
+       }
 
-       do {
+       while (_session.playlist_by_name(name)) {
                name = Playlist::bump_name (name, _session);
-       } while (_session.playlist_by_name(name));
+       }
 
 
        if (prompt) {
@@ -1057,7 +1124,7 @@ RouteTimeAxisView::clear_playlist ()
        if (!pl)
                return;
 
-       editor.clear_playlist (pl);
+       _editor.clear_playlist (pl);
 }
 
 void
@@ -1088,38 +1155,38 @@ RouteTimeAxisView::selection_click (GdkEventButton* ev)
        if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
 
                /* special case: select/deselect all tracks */
-               if (editor.get_selection().selected (this)) {
-                       editor.get_selection().clear_tracks ();
+               if (_editor.get_selection().selected (this)) {
+                       _editor.get_selection().clear_tracks ();
                } else {
-                       editor.select_all_tracks ();
+                       _editor.select_all_tracks ();
                }
 
                return;
        } 
 
-       PublicEditor::TrackViewList* tracks = editor.get_valid_views (this, _route->edit_group());
+       PublicEditor::TrackViewList* tracks = _editor.get_valid_views (this, _route->edit_group());
 
        switch (Keyboard::selection_type (ev->state)) {
        case Selection::Toggle:
-               editor.get_selection().toggle (*tracks);
+               _editor.get_selection().toggle (*tracks);
                break;
                
        case Selection::Set:
-               editor.get_selection().set (*tracks);
+               _editor.get_selection().set (*tracks);
                break;
 
        case Selection::Extend:
                if (tracks->size() > 1) {
                        /* add each one, do not "extend" */
-                       editor.get_selection().add (*tracks);
+                       _editor.get_selection().add (*tracks);
                } else {
                        /* extend to the single track */
-                       editor.extend_selection_to_track (*tracks->front());
+                       _editor.extend_selection_to_track (*tracks->front());
                }
                break;
 
        case Selection::Add:
-               editor.get_selection().add (*tracks);
+               _editor.get_selection().add (*tracks);
                break;
        }
 
@@ -1187,30 +1254,31 @@ RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>&
 }
 
 bool
-RouteTimeAxisView::show_automation(Parameter param)
+RouteTimeAxisView::show_automation(Evoral::Parameter param)
 {
        return (_show_automation.find(param) != _show_automation.end());
 }
 
-/** Retuns NULL if track for \a param doesn't exist.
+/** Retuns 0 if track for \a param doesn't exist.
  */
 RouteTimeAxisView::RouteAutomationNode*
-RouteTimeAxisView::automation_track(Parameter param)
+RouteTimeAxisView::automation_track (Evoral::Parameter param)
 {
-       map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find(param);
+       map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
 
-       if (i != _automation_tracks.end())
+       if (i != _automation_tracks.end()) {
                return i->second;
-       else
-               return NULL;
+       } else {
+               return 0;
+       }
 }
 
 /** Shorthand for GainAutomation, etc.
  */    
 RouteTimeAxisView::RouteAutomationNode*
-RouteTimeAxisView::automation_track(AutomationType type)
+RouteTimeAxisView::automation_track (AutomationType type)
 {
-       return automation_track(Parameter(type));
+       return automation_track (Evoral::Parameter(type));
 }
 
 RouteGroup*
@@ -1275,7 +1343,7 @@ RouteTimeAxisView::hide_click ()
        // LAME fix for hide_button refresh fix
        hide_button.set_sensitive(false);
        
-       editor.hide_track_in_display (*this);
+       _editor.hide_track_in_display (*this);
        
        hide_button.set_sensitive(true);
 }
@@ -1334,14 +1402,14 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
        switch (op) {
        case Cut:
                if ((what_we_got = playlist->cut (time)) != 0) {
-                       editor.get_cut_buffer().add (what_we_got);
+                       _editor.get_cut_buffer().add (what_we_got);
                        _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
                        ret = true;
                }
                break;
        case Copy:
                if ((what_we_got = playlist->copy (time)) != 0) {
-                       editor.get_cut_buffer().add (what_we_got);
+                       _editor.get_cut_buffer().add (what_we_got);
                }
                break;
 
@@ -1411,9 +1479,7 @@ RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
        menu->set_name ("ArdourContextMenu");
        playlist_items.clear();
 
-       if (playlist_menu) {
-               delete playlist_menu;
-       }
+       delete playlist_menu;
 
        playlist_menu = new Menu;
        playlist_menu->set_name ("ArdourContextMenu");
@@ -1445,10 +1511,19 @@ RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
        playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
        playlist_items.push_back (SeparatorElem());
 
-       playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(editor, &PublicEditor::new_playlists), this)));
-       playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(editor, &PublicEditor::copy_playlists), this)));
+       if (!edit_group() || !edit_group()->is_active()) {
+               playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
+               playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
+
+       } else {
+               // Use a label which tells the user what is happening
+               playlist_items.push_back (MenuElem (_("New Take"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
+               playlist_items.push_back (MenuElem (_("Copy Take"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
+               
+       }
+
        playlist_items.push_back (SeparatorElem());
-       playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(editor, &PublicEditor::clear_playlists), this)));
+       playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(_editor, &PublicEditor::clear_playlists), this)));
        playlist_items.push_back (SeparatorElem());
 
        playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
@@ -1468,14 +1543,58 @@ RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
        boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
        
        if (apl) {
+               if (get_diskstream()->playlist() == apl) {
+                       // radio button cotnrols mean this function is called for both the 
+                       // old and new playlist
+                       return;
+               }
                get_diskstream()->use_playlist (apl);
+
+
+               if (edit_group() && edit_group()->is_active()) {
+                       //PBD::stacktrace(cerr, 20);
+                       std::string group_string = "."+edit_group()->name()+".";
+
+                       std::string take_name = apl->name();
+                       std::string::size_type idx = take_name.find(group_string);
+
+                       if (idx == std::string::npos)
+                               return;
+
+                       take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
+                       
+                       for (list<Route*>::const_iterator i = edit_group()->route_list().begin(); i != edit_group()->route_list().end(); ++i) {
+                               if ( (*i) == this->route().get()) {
+                                       continue;
+                               }
+                               
+                               std::string playlist_name = (*i)->name()+group_string+take_name;
+
+                               Track *track = dynamic_cast<Track *>(*i);
+                               if (!track) {
+                                       std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
+                                       continue;
+                               }
+
+                               boost::shared_ptr<Playlist> ipl = session().playlist_by_name(playlist_name);
+                               if (!ipl) {
+                                       // No playlist for this track for this take yet, make it
+                                       track->diskstream()->use_new_playlist();
+                                       track->diskstream()->playlist()->set_name(playlist_name);
+                               } else {
+                                       track->diskstream()->use_playlist(ipl);
+                               }
+                               
+                               //(*i)->get_dis
+                       }
+               }
        }
 }
 
 void
 RouteTimeAxisView::show_playlist_selector ()
 {
-       editor.playlist_selector().show_for (this);
+       _editor.playlist_selector().show_for (this);
 }
 
 void
@@ -1515,7 +1634,7 @@ RouteTimeAxisView::color_handler ()
 }
 
 void
-RouteTimeAxisView::toggle_automation_track (Parameter param)
+RouteTimeAxisView::toggle_automation_track (Evoral::Parameter param)
 {
        RouteAutomationNode* node = automation_track(param);
 
@@ -1527,7 +1646,7 @@ RouteTimeAxisView::toggle_automation_track (Parameter param)
        if (showit != node->track->marked_for_display()) {
                if (showit) {
                        node->track->set_marked_for_display (true);
-                       node->track->canvas_display->show();
+                       node->track->canvas_display()->show();
                        node->track->get_state_node()->add_property ("shown", X_("yes"));
                } else {
                        node->track->set_marked_for_display (false);
@@ -1544,13 +1663,14 @@ RouteTimeAxisView::toggle_automation_track (Parameter param)
 }
 
 void
-RouteTimeAxisView::automation_track_hidden (Parameter param)
+RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
 {
        RouteAutomationNode* ran = automation_track(param);
        if (!ran) {
                return;
        }
-
+       
+       // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
        _show_automation.erase(param);
        ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
 
@@ -1569,10 +1689,10 @@ RouteTimeAxisView::show_all_automation ()
        
        /* Show our automation */
 
-       map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i;
+       map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
        for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
                i->second->track->set_marked_for_display (true);
-               i->second->track->canvas_display->show();
+               i->second->track->canvas_display()->show();
                i->second->track->get_state_node()->add_property ("shown", X_("yes"));
                i->second->menu_item->set_active(true);
        }
@@ -1604,11 +1724,11 @@ RouteTimeAxisView::show_existing_automation ()
        
        /* Show our automation */
 
-       map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i;
+       map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
        for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
                if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
                        i->second->track->set_marked_for_display (true);
-                       i->second->track->canvas_display->show();
+                       i->second->track->canvas_display()->show();
                        i->second->track->get_state_node()->add_property ("shown", X_("yes"));
                        i->second->menu_item->set_active(true);
                }
@@ -1619,7 +1739,7 @@ RouteTimeAxisView::show_existing_automation ()
 
        for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
                for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
-                       if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
+                       if ((*ii)->view != 0 && (*i)->processor->data().control((*ii)->what)->list()->size() > 0) {
                                (*ii)->menu_item->set_active (true);
                        }
                }
@@ -1637,7 +1757,7 @@ RouteTimeAxisView::hide_all_automation ()
 
        /* Hide our automation */
 
-       for (map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
+       for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
                i->second->track->set_marked_for_display (false);
                i->second->track->hide ();
                i->second->track->get_state_node()->add_property ("shown", X_("no"));
@@ -1700,7 +1820,7 @@ RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pa
 }
 
 RouteTimeAxisView::ProcessorAutomationNode*
-RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Parameter what)
+RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
 {
        for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
 
@@ -1737,7 +1857,7 @@ legalize_for_xml_node (string str)
 
 
 void
-RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Parameter what)
+RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
 {
        string name;
        ProcessorAutomationNode* pan;
@@ -1765,11 +1885,11 @@ RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor>
        snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
 
        boost::shared_ptr<AutomationControl> control
-                       = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
+                       = boost::dynamic_pointer_cast<AutomationControl>(processor->data().control(what, true));
 
        pan->view = boost::shared_ptr<AutomationTimeAxisView>(
                        new AutomationTimeAxisView (_session, _route, processor, control,
-                               editor, *this, false, parent_canvas, name, state_name));
+                               _editor, *this, false, parent_canvas, name, state_name));
 
        pan->view->Hiding.connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
 
@@ -1801,14 +1921,19 @@ RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::Process
 }
 
 void
-RouteTimeAxisView::add_existing_processor_automation_curves (boost::shared_ptr<Processor> processor)
+RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
 {
-       set<Parameter> s;
+       boost::shared_ptr<Processor> processor (p.lock ());
+       if (!processor) {
+               return;
+       }
+       
+       set<Evoral::Parameter> s;
        boost::shared_ptr<AutomationLine> al;
 
        processor->what_has_visible_data (s);
 
-       for (set<Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
+       for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
                
                if ((al = find_processor_automation_curve (processor, *i)) != 0) {
                        al->queue_reset ();
@@ -1819,7 +1944,7 @@ RouteTimeAxisView::add_existing_processor_automation_curves (boost::shared_ptr<P
 }
 
 void
-RouteTimeAxisView::add_automation_child(Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
+RouteTimeAxisView::add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
 {
        using namespace Menu_Helpers;
 
@@ -1858,14 +1983,19 @@ RouteTimeAxisView::add_automation_child(Parameter param, boost::shared_ptr<Autom
 
 
 void
-RouteTimeAxisView::add_processor_to_subplugin_menu (boost::shared_ptr<Processor> processor)
+RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
 {
+       boost::shared_ptr<Processor> processor (p.lock ());
+       if (!processor) {
+               return;
+       }
+       
        using namespace Menu_Helpers;
        ProcessorAutomationInfo *rai;
        list<ProcessorAutomationInfo*>::iterator x;
        
-       const std::set<Parameter>& automatable = processor->what_can_be_automated ();
-       std::set<Parameter> has_visible_automation;
+       const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
+       std::set<Evoral::Parameter> has_visible_automation;
 
        processor->what_has_visible_data(has_visible_automation);
 
@@ -1900,7 +2030,7 @@ RouteTimeAxisView::add_processor_to_subplugin_menu (boost::shared_ptr<Processor>
 
        items.clear ();
 
-       for (std::set<Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
+       for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
 
                ProcessorAutomationNode* pan;
                CheckMenuItem* mitem;
@@ -1957,7 +2087,8 @@ RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAuto
 
                if (showit) {
                        pan->view->set_marked_for_display (true);
-                       pan->view->canvas_display->show();
+                       pan->view->canvas_display()->show();
+                       pan->view->canvas_background()->show();
                } else {
                        rai->processor->mark_automation_visible (pan->what, true);
                        pan->view->set_marked_for_display (false);
@@ -1988,8 +2119,8 @@ RouteTimeAxisView::processors_changed ()
 
        subplugin_menu.items().clear ();
 
-       _route->foreach_processor (this, &RouteTimeAxisView::add_processor_to_subplugin_menu);
-       _route->foreach_processor (this, &RouteTimeAxisView::add_existing_processor_automation_curves);
+       _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
+       _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
 
        for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
 
@@ -2014,7 +2145,7 @@ RouteTimeAxisView::processors_changed ()
 }
 
 boost::shared_ptr<AutomationLine>
-RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Parameter what)
+RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
 {
        ProcessorAutomationNode* pan;
 
@@ -2045,12 +2176,26 @@ RouteTimeAxisView::update_rec_display ()
 void
 RouteTimeAxisView::set_layer_display (LayerDisplay d)
 {
-       _view->set_layer_display (d);
+       if (_view) {
+               _view->set_layer_display (d);
+       }
 }
+
+LayerDisplay
+RouteTimeAxisView::layer_display () const
+{
+       if (_view) {
+               return _view->layer_display ();
+       }
+
+       /* we don't know, since we don't have a _view, so just return something */
+       return Overlaid;
+}
+
        
 
 boost::shared_ptr<AutomationTimeAxisView>
-RouteTimeAxisView::automation_child(ARDOUR::Parameter param)
+RouteTimeAxisView::automation_child(Evoral::Parameter param)
 {
        AutomationTracks::iterator i = _automation_tracks.find(param);
        if (i != _automation_tracks.end())
@@ -2145,12 +2290,12 @@ RouteTimeAxisView::set_underlay_state()
                }
 
                XMLProperty* prop = child_node->property ("id");
-               if(prop) {
-                       PBD::ID id(prop->value());
+               if (prop) {
+                       PBD::ID id (prop->value());
 
-                       RouteTimeAxisView* v = editor.get_route_view_by_id(id);
+                       RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
 
-                       if(v) {
+                       if (v) {
                                add_underlay(v->view(), false);
                        }
                }