Fix displaying of notes in auto-created MIDI region when it's the first region in...
[ardour.git] / gtk2_ardour / editor.h
index 226cdfb5327d0a955209c9414fc1ff81827ac38d..7e96f9c9c551823545750994e93b30451fdce588 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #ifndef __ardour_editor_h__
 #include <string>
 #include <sys/time.h>
 
+#include <glibmm/ustring.h>
+
+#include <boost/optional.hpp>
+
 #include <libgnomecanvasmm/canvas.h>
 #include <libgnomecanvasmm/group.h>
 #include <libgnomecanvasmm/line.h>
+#include <libgnomecanvasmm/pixbuf.h>
 
 #include <cmath>
 
@@ -44,7 +48,7 @@
 #include <ardour/session.h>
 #include <ardour/tempo.h>
 #include <ardour/location.h>
-#include <ardour/region.h>
+#include <ardour/audioregion.h>
 
 #include "audio_clock.h"
 #include "gtk-custom-ruler.h"
 #include "region_selection.h"
 #include "canvas.h"
 #include "draginfo.h"
+#include "tempo_lines.h"
 
 namespace Gtkmm2ext {
        class TearOff;
 }
 
-namespace LinuxAudioSystems {
-       class AudioEngine;
-}
-
 namespace ARDOUR {
        class AudioDiskstream;
        class RouteGroup;
@@ -75,8 +76,9 @@ namespace ARDOUR {
        class TempoSection;
        class NamedSelection;
        class Session;
-       class AudioFilter;
+       class Filter;
        class Crossfade;
+       class ChanCount;
 }
 
 namespace LADSPA {
@@ -84,7 +86,6 @@ namespace LADSPA {
 }
 
 class TimeAxisView;
-class RouteTimeAxisView;
 class AudioTimeAxisView;
 class AutomationTimeAxisView;
 class AudioRegionView;
@@ -104,6 +105,7 @@ class MixerStrip;
 class StreamView;
 class AudioStreamView;
 class ControlPoint;
+class SoundFileOmega;
 #ifdef FFT_ANALYSIS
 class AnalysisWindow;
 #endif
@@ -122,15 +124,15 @@ class TimeAxisViewItem ;
 class Editor : public PublicEditor
 {
   public:
-       Editor (ARDOUR::AudioEngine&);
+       Editor ();
        ~Editor ();
 
        void             connect_to_session (ARDOUR::Session *);
        ARDOUR::Session* current_session() const { return session; }
 
-       jack_nframes_t leftmost_position() const { return leftmost_frame; }
-       jack_nframes_t current_page_frames() const {
-               return (jack_nframes_t) floor (canvas_width * frames_per_unit);
+       nframes_t leftmost_position() const { return leftmost_frame; }
+       nframes_t current_page_frames() const {
+               return (nframes_t) floor (canvas_width * frames_per_unit);
        }
 
        void set_snap_to (Editing::SnapType);
@@ -145,13 +147,19 @@ class Editor : public PublicEditor
 
        void set_mouse_mode (Editing::MouseMode, bool force=true);
        void step_mouse_mode (bool next);
-       Editing::MouseMode current_mouse_mode () { return mouse_mode; }
+       Editing::MouseMode current_mouse_mode () const { return mouse_mode; }
+       
+       void set_midi_edit_cursor (Editing::MidiEditMode);
+       void set_midi_edit_mode (Editing::MidiEditMode, bool force=true);
+       Editing::MidiEditMode current_midi_edit_mode () const { return midi_edit_mode; }
 
-       void add_imageframe_time_axis(const string & track_name, void*) ;
-       void add_imageframe_marker_time_axis(const string & track_name, TimeAxisView* marked_track, void*) ;
+#ifdef WITH_CMT
+       void add_imageframe_time_axis(const std::string & track_name, void*) ;
+       void add_imageframe_marker_time_axis(const std::string & track_name, TimeAxisView* marked_track, void*) ;
        void connect_to_image_compositor() ;
        void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ;
-       TimeAxisView* get_named_time_axis(const string & name) ;
+       TimeAxisView* get_named_time_axis(const std::string & name) ;
+#endif
 
        void consider_auditioning (boost::shared_ptr<ARDOUR::Region>);
        void hide_a_region (boost::shared_ptr<ARDOUR::Region>);
@@ -171,16 +179,15 @@ class Editor : public PublicEditor
        void separate_region_from_selection ();
        void separate_regions_using_location (ARDOUR::Location&);
        void toggle_playback (bool with_abort);
+       void transition_to_rolling (bool forward);
 
        /* undo related */
 
-       void set_edit_menu (Gtk::Menu&);
-
-       jack_nframes_t unit_to_frame (double unit) {
-               return (jack_nframes_t) rint (unit * frames_per_unit);
+       nframes_t unit_to_frame (double unit) {
+               return (nframes_t) rint (unit * frames_per_unit);
        }
        
-       double frame_to_unit (jack_nframes_t frame) {
+       double frame_to_unit (nframes_t frame) {
                return rint ((double) frame / (double) frames_per_unit);
        }
 
@@ -195,7 +202,7 @@ class Editor : public PublicEditor
           xscroll_adjustment.  
        */
 
-       jack_nframes_t pixel_to_frame (double pixel) {
+       nframes_t pixel_to_frame (double pixel) {
                
                /* pixel can be less than zero when motion events
                   are processed. since we've already run the world->canvas
@@ -204,13 +211,13 @@ class Editor : public PublicEditor
                */
 
                if (pixel >= 0) {
-                       return (jack_nframes_t) rint (pixel * frames_per_unit * GNOME_CANVAS(track_canvas.gobj())->pixels_per_unit);
+                       return (nframes_t) rint (pixel * frames_per_unit * GNOME_CANVAS(track_canvas.gobj())->pixels_per_unit);
                } else {
                        return 0;
                }
        }
 
-       gulong frame_to_pixel (jack_nframes_t frame) {
+       gulong frame_to_pixel (nframes_t frame) {
                return (gulong) rint ((frame / (frames_per_unit *  GNOME_CANVAS(track_canvas.gobj())->pixels_per_unit)));
        }
 
@@ -219,10 +226,12 @@ class Editor : public PublicEditor
        Selection& get_selection() const { return *selection; }
        Selection& get_cut_buffer() const { return *cut_buffer; }
 
+       bool extend_selection_to_track (TimeAxisView&);
+
        void play_selection ();
-       void select_all_in_track (Selection::Operation op);
+       void select_all_in_selected_tracks (Selection::Operation op);
        void select_all (Selection::Operation op);
-       void invert_selection_in_track ();
+       void invert_selection_in_selected_tracks ();
        void invert_selection ();
 
        /* tempo */
@@ -244,13 +253,9 @@ class Editor : public PublicEditor
        void export_session();
        void export_selection();
 
-       /* this is what actually does it */
-       
-       void export_audiofile (ARDOUR::AudioExportSpecification&);
-
-       /* */
 
        void add_toplevel_controls (Gtk::Container&);
+       Gtk::HBox& get_status_bar_packer()  { return status_bar_hpacker; }
 
        void      set_zoom_focus (Editing::ZoomFocus);
        Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
@@ -263,17 +268,19 @@ class Editor : public PublicEditor
        PlaylistSelector& playlist_selector() const;
        void route_name_changed (TimeAxisView *);
        gdouble        frames_per_unit;
-       jack_nframes_t leftmost_frame;
-       void clear_playlist (ARDOUR::Playlist&);
+       nframes_t leftmost_frame;
+       void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>);
 
-       void new_playlists ();
-       void copy_playlists ();
-       void clear_playlists ();
+       void new_playlists (TimeAxisView* v);
+       void copy_playlists (TimeAxisView* v);
+       void clear_playlists (TimeAxisView* v);
 
        TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0);
 
        Width editor_mixer_strip_width;
+       void maybe_add_mixer_strip_width (XMLNode&);
        void show_editor_mixer (bool yn);
+       void show_editor_list (bool yn);
        void set_selected_mixer_strip (TimeAxisView&);
        void hide_track_in_display (TimeAxisView& tv);
        void show_track_in_display (TimeAxisView& tv);
@@ -293,26 +300,34 @@ class Editor : public PublicEditor
        void set_follow_playhead (bool yn);
        void toggle_follow_playhead ();
        bool follow_playhead() const { return _follow_playhead; }
+       bool dragging_playhead () const { return _dragging_playhead; }
 
        void toggle_waveform_visibility ();
        void toggle_waveforms_while_recording ();
        void toggle_measure_visibility ();
+       void toggle_logo_visibility ();
 
-       void set_meter_falloff (int);
-       void set_meter_hold (int32_t);
+       /* SMPTE timecode & video sync */
 
+       void smpte_fps_chosen (ARDOUR::SmpteFormat format);
+       void video_pullup_chosen (ARDOUR::Session::PullupFormat pullup);
+       void subframes_per_frame_chosen (uint32_t);
+
+       void update_smpte_mode();
+       void update_video_pullup();
+       void update_subframes_per_frame ();
        /* xfades */
 
        void toggle_auto_xfade ();
        void toggle_xfades_active ();
        void toggle_xfade_visibility ();
        bool xfade_visibility() const { return _xfade_visibility; }
+       void update_xfade_visibility ();
        void update_crossfade_model ();
        void set_crossfade_model (ARDOUR::CrossfadeModel);
 
        /* layers */
-
-       void set_layer_model (ARDOUR::Session::LayerModel);
+       void set_layer_model (ARDOUR::LayerModel);
        void update_layering_model ();
 
        /* redirect shared ops menu. caller must free returned menu */
@@ -331,32 +346,44 @@ class Editor : public PublicEditor
        bool new_regionviews_display_gain () { return _new_regionviews_show_envelope; }
        void prepare_for_cleanup ();
 
-       void reposition_x_origin (jack_nframes_t sample);
-
        void maximise_editing_space();
        void restore_editing_space();
 
+       void reset_x_origin (nframes_t);
+       void reset_zoom (double);
+       void reposition_and_zoom (nframes_t, double);
+
+       nframes_t edit_cursor_position(bool);
+       bool update_mouse_speed ();
+       bool decelerate_mouse_speed ();
+
   protected:
        void map_transport_state ();
-       void map_position_change (jack_nframes_t);
+       void map_position_change (nframes_t);
 
        void on_realize();
 
   private:
-       
+
+       /// The session that we are editing, or 0
+       void color_handler ();
        ARDOUR::Session     *session;
-       ARDOUR::AudioEngine& engine;
        bool                 constructed;
 
+       // to keep track of the playhead position for control_scroll
+       boost::optional<nframes_t> _control_scroll_target;
        PlaylistSelector* _playlist_selector;
 
        void          set_frames_per_unit (double);
-       void          frames_per_unit_modified ();
 
-       Editing::MouseMode mouse_mode;
-       void      mouse_insert (GdkEventButton *);
+       Editing::MouseMode    mouse_mode;
+       Editing::MidiEditMode midi_edit_mode;
 
+       int  post_maximal_editor_width;
+       int  post_maximal_pane_position;
        int  pre_maximal_pane_position;
+       int  pre_maximal_editor_width;
        void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*);
 
        Gtk::Notebook the_notebook;
@@ -393,7 +420,7 @@ class Editor : public PublicEditor
            void hide();
            void show ();
            void set_name (const string&);
-           void set_position (jack_nframes_t start, jack_nframes_t end = 0);
+           void set_position (nframes_t start, nframes_t end = 0);
            void set_color_rgba (uint32_t);
        };
 
@@ -405,25 +432,33 @@ class Editor : public PublicEditor
 
        void hide_marker (ArdourCanvas::Item*, GdkEvent*);
        void clear_marker_display ();
-       void mouse_add_new_marker (jack_nframes_t where);
-
-       TimeAxisView*      clicked_trackview;
-       AudioTimeAxisView* clicked_audio_trackview;
+       void mouse_add_new_marker (nframes_t where);
+
+       TimeAxisView*      clicked_axisview;
+       RouteTimeAxisView* clicked_routeview;
+        /** The last RegionView that was clicked on, or 0 if the last click was not
+         * on a RegionView.  This is set up by the canvas event handlers in
+         * editor_canvas_events.cc
+         */
        RegionView*        clicked_regionview;
+       
        RegionView*        latest_regionview;
        uint32_t           clicked_selection;
        CrossfadeView*     clicked_crossfadeview;
        ControlPoint*      clicked_control_point;
 
-       void get_relevant_audio_tracks (AudioTimeAxisView& base, std::set<AudioTimeAxisView*>& relevant_tracks);
-       void mapover_audio_tracks (sigc::slot<void,AudioTimeAxisView&,uint32_t> sl);
+       void sort_track_selection ();
+
+       void get_relevant_tracks (std::set<RouteTimeAxisView*>& relevant_tracks);
+       void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&) const;
+       void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*) const;
 
-       /* functions to be passed to mapover_audio_tracks(), possibly with sigc::bind()-supplied arguments */
+       /* functions to be passed to mapover_tracks(), possibly with sigc::bind()-supplied arguments */
 
-       void mapped_set_selected_regionview_from_click (RouteTimeAxisView&, uint32_t, RegionView*, vector<RegionView*>*);
-       void mapped_use_new_playlist (AudioTimeAxisView&, uint32_t);
-       void mapped_use_copy_playlist (AudioTimeAxisView&, uint32_t);
-       void mapped_clear_playlist (AudioTimeAxisView&, uint32_t);
+       void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, vector<RegionView*>*) const;
+       void mapped_use_new_playlist (RouteTimeAxisView&, uint32_t);
+       void mapped_use_copy_playlist (RouteTimeAxisView&, uint32_t);
+       void mapped_clear_playlist (RouteTimeAxisView&, uint32_t);
 
        /* end */
 
@@ -432,37 +467,28 @@ class Editor : public PublicEditor
 
        void catch_vanishing_regionview (RegionView *);
 
-       bool set_selected_control_point_from_click (bool press, Selection::Operation op = Selection::Set, bool with_undo = true, bool no_remove=false);
-       bool set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool with_undo = true, bool no_remove=false);
+       bool set_selected_track (TimeAxisView&, Selection::Operation op = Selection::Set, bool no_remove=false);
+       void select_all_tracks ();
+
+       bool set_selected_control_point_from_click (Selection::Operation op = Selection::Set, bool no_remove=false);
+       bool set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool no_remove=false);
        bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set, bool no_track_remove=false);
 
        void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
-       bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::shared_ptr<ARDOUR::Region>);
        void collect_new_region_view (RegionView *);
 
-       Gtk::Menu track_context_menu;
-       Gtk::Menu track_region_context_menu;
-       Gtk::Menu track_selection_context_menu;
-       Gtk::Menu track_crossfade_context_menu;
-
        Gtk::MenuItem* region_edit_menu_split_item;
        Gtk::MenuItem* region_edit_menu_split_multichannel_item;
-       Gtk::Menu * track_region_edit_playlist_menu;
-       Gtk::Menu * track_edit_playlist_submenu;
-       Gtk::Menu * track_selection_edit_playlist_submenu;
-       
-       void popup_track_context_menu (int, int, ItemType, bool, jack_nframes_t);
-       Gtk::Menu* build_track_context_menu (jack_nframes_t);
-       Gtk::Menu* build_track_bus_context_menu (jack_nframes_t);
-       Gtk::Menu* build_track_region_context_menu (jack_nframes_t frame);
-       Gtk::Menu* build_track_crossfade_context_menu (jack_nframes_t);
-       Gtk::Menu* build_track_selection_context_menu (jack_nframes_t);
-       void add_dstream_context_items (Gtk::Menu_Helpers::MenuList&);
-       void add_bus_context_items (Gtk::Menu_Helpers::MenuList&);
-       void add_region_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Region>, Gtk::Menu_Helpers::MenuList&);
-       void add_crossfade_context_items (AudioStreamView*, ARDOUR::Crossfade*, Gtk::Menu_Helpers::MenuList&, bool many);
+
+       void popup_track_context_menu (int, int, nframes_t);
+       Gtk::Menu* build_track_context_menu (nframes_t);
+       void add_bus_or_audio_track_context_items (Gtk::Menu_Helpers::MenuList&);
+       void add_region_context_items (Gtk::Menu_Helpers::MenuList&);
+       void add_crossfade_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Crossfade>, Gtk::Menu_Helpers::MenuList&, bool many);
        void add_selection_context_items (Gtk::Menu_Helpers::MenuList&);
 
+       void add_item_with_sensitivity (Gtk::Menu_Helpers::MenuList&, Gtk::Menu_Helpers::MenuElem, bool) const;
+
        void handle_new_route (ARDOUR::Session::RouteList&);
        void remove_route (TimeAxisView *);
        bool route_removal;
@@ -480,9 +506,7 @@ class Editor : public PublicEditor
        ArdourCanvas::Text* verbose_canvas_cursor;
        bool                 verbose_cursor_visible;
 
-       void session_control_changed (ARDOUR::Session::ControlType);
-       void queue_session_control_changed (ARDOUR::Session::ControlType);
-
+       void parameter_changed (const char *);
        
        bool track_canvas_motion (GdkEvent*);
 
@@ -493,14 +517,13 @@ class Editor : public PublicEditor
 
        bool verbose_cursor_on; // so far unused
 
-       void flush_track_canvas ();
-       void flush_time_canvas ();
-
        Gtk::EventBox      time_canvas_event_box;
        Gtk::EventBox      track_canvas_event_box;
        Gtk::EventBox      time_button_event_box;
+       Gtk::Frame         time_button_frame;
 
        ArdourCanvas::Group      *minsec_group;
+       ArdourCanvas::Pixbuf     *logo_item;
        ArdourCanvas::Group      *bbt_group;
        ArdourCanvas::Group      *smpte_group;
        ArdourCanvas::Group      *frame_group;
@@ -538,7 +561,7 @@ class Editor : public PublicEditor
        void update_just_smpte ();
        void update_fixed_rulers ();
        void update_tempo_based_rulers (); 
-       void popup_ruler_menu (jack_nframes_t where = 0, ItemType type = RegionItem);
+       void popup_ruler_menu (nframes_t where = 0, ItemType type = RegionItem);
        void update_ruler_visibility ();
        void ruler_toggled (int);
        gint ruler_label_button_release (GdkEventButton*);
@@ -555,6 +578,7 @@ class Editor : public PublicEditor
        gint metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
        gint metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
 
+       Gtk::Widget        *_ruler_separator;
        GtkWidget          *_smpte_ruler;
        GtkWidget          *_bbt_ruler;
        GtkWidget          *_frames_ruler;
@@ -575,13 +599,6 @@ class Editor : public PublicEditor
        ArdourCanvas::SimpleRect* range_marker_bar;
        ArdourCanvas::SimpleRect* transport_marker_bar;
 
-       
-       ArdourCanvas::SimpleLine* tempo_line;
-       ArdourCanvas::SimpleLine* meter_line;
-       ArdourCanvas::SimpleLine* marker_line;
-       ArdourCanvas::SimpleLine* range_marker_line;
-       ArdourCanvas::SimpleLine* transport_marker_line;
-
        Gtk::Label  minsec_label;
        Gtk::Label  bbt_label;
        Gtk::Label  smpte_label;
@@ -600,13 +617,13 @@ class Editor : public PublicEditor
            Editor&               editor;
            ArdourCanvas::Points  points;
            ArdourCanvas::Line    canvas_item;
-           jack_nframes_t        current_frame;
+           nframes_t        current_frame;
            double                length;
 
-           Cursor (Editor&, const string& color, bool (Editor::*)(GdkEvent*,ArdourCanvas::Item*));
+           Cursor (Editor&, bool (Editor::*)(GdkEvent*,ArdourCanvas::Item*));
            ~Cursor ();
 
-           void set_position (jack_nframes_t);
+           void set_position (nframes_t);
            void set_length (double units);
            void set_y_axis (double position);
        };
@@ -627,9 +644,9 @@ class Editor : public PublicEditor
        void    select_all_selectables_using_cursor (Cursor *, bool);
        void    select_all_selectables_between_cursors (Cursor *, Cursor *);
 
-       boost::shared_ptr<ARDOUR::Region> find_next_region (jack_nframes_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
+       boost::shared_ptr<ARDOUR::Region> find_next_region (nframes_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
 
-       vector<jack_nframes_t> region_boundary_cache;
+       vector<nframes_t> region_boundary_cache;
        void build_region_boundary_cache ();
 
        Gtk::VBox           trackview_vpacker;
@@ -648,6 +665,7 @@ class Editor : public PublicEditor
        void controls_layout_size_request (Gtk::Requisition*);
 
        Gtk::HScrollbar     edit_hscrollbar;
+       bool                _dragging_hscrollbar;
 
        void reset_hscrollbar_stepping ();
        
@@ -657,7 +675,8 @@ class Editor : public PublicEditor
 
        double canvas_width;
        double canvas_height;
-       jack_nframes_t last_canvas_frame;
+       double full_canvas_height;
+       nframes_t last_canvas_frame;
 
        bool track_canvas_map_handler (GdkEventAny*);
        bool time_canvas_map_handler (GdkEventAny*);
@@ -666,25 +685,43 @@ class Editor : public PublicEditor
        Gtk::Menu *edit_controls_left_menu;
        Gtk::Menu *edit_controls_right_menu;
 
-       void track_canvas_scroller_realized ();
-       void time_canvas_scroller_realized ();
-
        Gtk::VBox           track_canvas_vbox;
        Gtk::VBox           time_canvas_vbox;
        Gtk::VBox           edit_controls_vbox;
        Gtk::HBox           edit_controls_hbox;
 
        void control_scroll (float);
-       bool deferred_control_scroll (jack_nframes_t);
+       bool deferred_control_scroll (nframes_t);
        sigc::connection control_scroll_connection;
 
        void tie_vertical_scrolling ();
        void canvas_horizontally_scrolled ();
 
-       void reposition_and_zoom (jack_nframes_t sample, double fpu);
-       gint deferred_reposition_and_zoom (jack_nframes_t sample, double fpu);
+       struct VisualChange {
+           enum Type { 
+                   TimeOrigin = 0x1,
+                   ZoomLevel = 0x2
+           };
+
+           Type pending;
+           nframes_t time_origin;
+           double frames_per_unit;
+
+           int idle_handler_id;
+
+           VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), frames_per_unit (0), idle_handler_id (-1) {}
+       };
+
+
+       VisualChange pending_visual_change;
+
+       static int _idle_visual_changer (void *arg);
+       int idle_visual_changer ();
+
+       void queue_visual_change (nframes_t);
+       void queue_visual_change (double);
+
        void end_location_changed (ARDOUR::Location*);
-       bool repos_zoom_queued;
 
        struct RegionListDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
            RegionListDisplayModelColumns() {
@@ -694,14 +731,15 @@ class Editor : public PublicEditor
            }
            Gtk::TreeModelColumn<Glib::ustring> name;
            Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
-               Gtk::TreeModelColumn<Gdk::Color> color_;
+           Gtk::TreeModelColumn<Gdk::Color> color_;
        };
            
-       RegionListDisplayModelColumns    region_list_columns;
-       Gtkmm2ext::DnDTreeView           region_list_display;
-       Glib::RefPtr<Gtk::TreeStore>     region_list_model;
-       Glib::RefPtr<Gtk::ToggleAction>  toggle_full_region_list_action;
-       Glib::RefPtr<Gtk::ToggleAction>  toggle_show_auto_regions_action;
+       RegionListDisplayModelColumns          region_list_columns;
+       Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > region_list_display;
+
+       Glib::RefPtr<Gtk::TreeStore>           region_list_model;
+       Glib::RefPtr<Gtk::ToggleAction>        toggle_full_region_list_action;
+       Glib::RefPtr<Gtk::ToggleAction>        toggle_show_auto_regions_action;
 
        void region_list_selection_changed ();
        bool region_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
@@ -732,7 +770,7 @@ class Editor : public PublicEditor
 
        /* snapshots */
 
-       Gtk::ScrolledWindow      snapshot_display_scroller;
+       Gtk::ScrolledWindow snapshot_display_scroller;
        struct SnapshotDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
            SnapshotDisplayModelColumns() { 
                    add (visible_name);
@@ -745,10 +783,12 @@ class Editor : public PublicEditor
        SnapshotDisplayModelColumns snapshot_display_columns;
        Glib::RefPtr<Gtk::ListStore> snapshot_display_model;
        Gtk::TreeView snapshot_display;
+       Gtk::Menu snapshot_context_menu;
 
        bool snapshot_display_button_press (GdkEventButton*);
        void snapshot_display_selection_changed ();
        void redisplay_snapshots();
+       void popup_snapshot_context_menu (int, int32_t, Glib::ustring);
 
        /* named selections */
 
@@ -764,23 +804,24 @@ class Editor : public PublicEditor
        NamedSelectionDisplayModelColumns named_selection_columns;
        Glib::RefPtr<Gtk::TreeStore>     named_selection_model;
 
-       Gtkmm2ext::DnDTreeView named_selection_display;
+       Gtkmm2ext::DnDTreeView<ARDOUR::NamedSelection*> named_selection_display;
        Gtk::ScrolledWindow    named_selection_scroller;
 
-       void name_selection();
-       void named_selection_name_chosen ();
-       void create_named_selection (const string &);
+       void create_named_selection ();
        void paste_named_selection (float times);
+       void remove_selected_named_selections ();
+       void remove_snapshot (Glib::ustring);
+       void rename_snapshot (Glib::ustring);
 
        void handle_new_named_selection ();
        void add_named_selection_to_named_selection_display (ARDOUR::NamedSelection&);
        void redisplay_named_selections ();
 
-       gint named_selection_display_button_press (GdkEventButton *ev);
+       bool named_selection_display_button_release (GdkEventButton *ev);
+       bool named_selection_display_key_release (GdkEventKey *ev);
        void named_selection_display_selection_changed ();
 
        /* track views */
-       int track_spacing;
        TrackViewList  track_views;
        TimeAxisView     *trackview_by_y_position (double ypos);
 
@@ -792,25 +833,25 @@ class Editor : public PublicEditor
        static Gdk::Cursor* time_fx_cursor;
        static Gdk::Cursor* fader_cursor;
        static Gdk::Cursor* speaker_cursor;
+       static Gdk::Cursor* midi_pencil_cursor;
+       static Gdk::Cursor* midi_select_cursor;
+       static Gdk::Cursor* midi_erase_cursor;
        static Gdk::Cursor* wait_cursor;
        static Gdk::Cursor* timebar_cursor;
 
        static void build_cursors ();
 
        sigc::connection scroll_connection;
-       jack_nframes_t last_update_frame;
-       void center_screen (jack_nframes_t);
-       void center_screen_internal (jack_nframes_t, float);
+       nframes_t last_update_frame;
+       void center_screen (nframes_t);
+       void center_screen_internal (nframes_t, float);
        
        void update_current_screen ();
        
-       gint show_track_context_menu (GdkEventButton *);
-       void hide_track_context_menu ();
-
        void session_going_away ();
 
-       jack_nframes_t cut_buffer_start;
-       jack_nframes_t cut_buffer_length;
+       nframes_t cut_buffer_start;
+       nframes_t cut_buffer_length;
 
        bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
        bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
@@ -823,48 +864,48 @@ class Editor : public PublicEditor
 
        void register_actions ();
 
-       int ensure_cursor (jack_nframes_t* pos);
+       int ensure_cursor (nframes_t* pos);
 
-       void handle_new_audio_region (boost::shared_ptr<ARDOUR::AudioRegion>);
-       void handle_audio_region_removed (boost::shared_ptr<ARDOUR::AudioRegion>);
-       void add_audio_region_to_region_display (boost::shared_ptr<ARDOUR::AudioRegion>);
+       void handle_new_region (boost::weak_ptr<ARDOUR::Region>);
+       void handle_region_removed (boost::weak_ptr<ARDOUR::Region>);
+       void add_region_to_region_display (boost::shared_ptr<ARDOUR::Region>);
        void region_hidden (boost::shared_ptr<ARDOUR::Region>);
        void redisplay_regions ();
-       void insert_into_tmp_audio_regionlist(boost::shared_ptr<ARDOUR::AudioRegion>);
+       void insert_into_tmp_regionlist(boost::shared_ptr<ARDOUR::Region>);
 
-       list<boost::shared_ptr<ARDOUR::AudioRegion> > tmp_audio_region_list;
+       list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
 
        void cut_copy (Editing::CutCopyOp);
+       bool can_cut_copy () const;
        void cut_copy_points (Editing::CutCopyOp);
        void cut_copy_regions (Editing::CutCopyOp);
        void cut_copy_ranges (Editing::CutCopyOp);
 
        void mouse_paste ();
-       void paste_internal (jack_nframes_t position, float times);
+       void paste_internal (nframes_t position, float times);
 
        /* EDITING OPERATIONS */
        
        void reset_point_selection ();
        void toggle_region_mute ();
+       void toggle_region_lock ();
        void toggle_region_opaque ();
-       void raise_region ();
+       void toggle_region_position_lock ();
        void raise_region_to_top ();
-       void lower_region ();
        void lower_region_to_bottom ();
        void split_region ();
-       void split_region_at (jack_nframes_t);
-       void split_regions_at (jack_nframes_t, RegionSelection&);
+       void split_region_at (nframes_t);
+       void split_regions_at (nframes_t, RegionSelection&);
        void crop_region_to_selection ();
-       void set_a_regions_sync_position (boost::shared_ptr<ARDOUR::Region>, jack_nframes_t);
+       void set_a_regions_sync_position (boost::shared_ptr<ARDOUR::Region>, nframes_t);
        void set_region_sync_from_edit_cursor ();
        void remove_region_sync();
-       void align_selection (ARDOUR::RegionPoint, jack_nframes_t position);
-       void align_selection_relative (ARDOUR::RegionPoint point, jack_nframes_t position);
-       void align_region (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, jack_nframes_t position);
-       void align_region_internal (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, jack_nframes_t position);
-       void remove_some_regions ();
+       void align_selection (ARDOUR::RegionPoint, nframes_t position);
+       void align_selection_relative (ARDOUR::RegionPoint point, nframes_t position);
+       void align_region (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes_t position);
+       void align_region_internal (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes_t position);
+       void remove_selected_regions ();
        void remove_clicked_region ();
-       void destroy_clicked_region ();
        void edit_region ();
        void duplicate_some_regions (RegionSelection&, float times);
        void duplicate_selection (float times);
@@ -874,9 +915,10 @@ class Editor : public PublicEditor
        void audition_playlist_region_standalone (boost::shared_ptr<ARDOUR::Region>);
        void audition_playlist_region_via_route (boost::shared_ptr<ARDOUR::Region>, ARDOUR::Route&);
        void split_multichannel_region();
-       void reverse_region ();
-       void normalize_region ();
-       void denormalize_region ();
+       void reverse_regions ();
+       void normalize_regions ();
+       void denormalize_regions ();
+       void quantize_regions ();
 
        void audition_region_from_region_list ();
        void hide_region_from_region_list ();
@@ -886,6 +928,8 @@ class Editor : public PublicEditor
        void align_relative (ARDOUR::RegionPoint);
        void naturalize ();
 
+       void reset_focus ();
+
        void cut ();
        void copy ();
        void paste (float times);
@@ -895,7 +939,6 @@ class Editor : public PublicEditor
        void keyboard_paste ();
        void keyboard_duplicate_region ();
        void keyboard_duplicate_selection ();
-       void keyboard_nudge ();
        void keyboard_insert_region_list_selection ();
 
        void region_from_selection ();
@@ -909,7 +952,6 @@ class Editor : public PublicEditor
        void play_from_edit_cursor ();
        void play_selected_region ();
        void audition_selected_region ();
-       void toggle_loop_playback ();
        void loop_selected_region ();
        void play_location (ARDOUR::Location&);
        void loop_location (ARDOUR::Location&);
@@ -919,24 +961,41 @@ class Editor : public PublicEditor
        void temporal_zoom_selection ();
        void temporal_zoom_session ();
        void temporal_zoom (gdouble scale);
-       void temporal_zoom_by_frame (jack_nframes_t start, jack_nframes_t end, const string & op);
-       void temporal_zoom_to_frame (bool coarser, jack_nframes_t frame);
+       void temporal_zoom_by_frame (nframes_t start, nframes_t end, const string & op);
+       void temporal_zoom_to_frame (bool coarser, nframes_t frame);
 
        void amplitude_zoom (gdouble scale);
        void amplitude_zoom_step (bool in);
 
-       void insert_region_list_drag (boost::shared_ptr<ARDOUR::AudioRegion>, int x, int y);
+       void insert_region_list_drag (boost::shared_ptr<ARDOUR::Region>, int x, int y);
        void insert_region_list_selection (float times);
 
+       /* import & embed */
+       
        void add_external_audio_action (Editing::ImportMode);
+       void external_audio_dialog ();
+       bool check_multichannel_status (const std::vector<Glib::ustring>& paths);
+
+       SoundFileOmega* sfbrowser;
+       
+       void bring_in_external_audio (Editing::ImportMode mode,  nframes64_t& pos);
+       void do_import (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t&);
 
-       void bring_in_external_audio (Editing::ImportMode mode, ARDOUR::AudioTrack*, jack_nframes_t& pos, bool prompt);
-       void do_import (vector<Glib::ustring> paths, bool split, Editing::ImportMode mode, ARDOUR::AudioTrack*, jack_nframes_t&, bool);
-       void do_embed (vector<Glib::ustring> paths, bool split, Editing::ImportMode mode, ARDOUR::AudioTrack*, jack_nframes_t&, bool);
-       int  import_sndfile (Glib::ustring path, Editing::ImportMode mode, ARDOUR::AudioTrack* track, jack_nframes_t& pos);
-       int  embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode, 
-                           ARDOUR::AudioTrack* track, jack_nframes_t& pos, bool prompt);
-       int finish_bringing_in_audio (boost::shared_ptr<ARDOUR::AudioRegion> region, uint32_t, uint32_t, ARDOUR::AudioTrack* track, jack_nframes_t& pos, Editing::ImportMode mode);
+       void _do_embed (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode,  nframes64_t&);
+       void do_embed (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode,  nframes64_t&);
+       bool idle_do_embed (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode,  nframes64_t&);
+
+       int  import_sndfiles (vector<Glib::ustring> paths, Editing::ImportMode mode,  ARDOUR::SrcQuality, nframes64_t& pos,
+                             int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::AudioTrack>&);
+       int  embed_sndfiles (vector<Glib::ustring> paths, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode, 
+                            nframes64_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::AudioTrack>&);
+
+       int add_sources (vector<Glib::ustring> paths, ARDOUR::SourceList& sources, nframes64_t& pos, Editing::ImportMode,
+                        int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::AudioTrack>&, bool add_channel_suffix);
+       int finish_bringing_in_audio (boost::shared_ptr<ARDOUR::AudioRegion> region, uint32_t, uint32_t,  nframes64_t& pos, Editing::ImportMode mode,
+                                     boost::shared_ptr<ARDOUR::AudioTrack>& existing_track);
+
+       boost::shared_ptr<ARDOUR::AudioTrack> get_nth_selected_audio_track (int nth) const;
 
        /* generic interthread progress window */
        
@@ -965,7 +1024,7 @@ class Editor : public PublicEditor
        /* to support this ... */
 
        void import_audio (bool as_tracks);
-       void do_import (vector<string> paths, bool split, bool as_tracks);
+       void do_import (vector<Glib::ustring> paths, bool split, bool as_tracks);
 
        void move_to_start ();
        void move_to_end ();
@@ -976,6 +1035,7 @@ class Editor : public PublicEditor
        void edit_cursor_forward ();
        void playhead_backward ();
        void playhead_forward ();
+       void scroll_playhead (bool forward);
        void scroll_backward (float pages=0.8f);
        void scroll_forward (float pages=0.8f);
        void scroll_tracks_down ();
@@ -989,6 +1049,8 @@ class Editor : public PublicEditor
        void clear_markers ();
        void clear_ranges ();
        void clear_locations ();
+       void unhide_markers ();
+       void unhide_ranges ();
        void jump_forward_to_mark ();
        void jump_backward_to_mark ();
        void cursor_align (bool playhead_to_edit);
@@ -1004,7 +1066,11 @@ class Editor : public PublicEditor
 
        void add_location_from_audio_region ();
        void add_location_from_selection ();
-       void set_route_loop_selection ();
+       void set_loop_from_selection (bool play);
+       void set_punch_from_selection ();
+       
+       void set_loop_range (nframes_t start, nframes_t end, std::string cmd);
+       void set_punch_range (nframes_t start, nframes_t end, std::string cmd);
 
        void add_location_from_playhead_cursor ();
 
@@ -1014,10 +1080,22 @@ class Editor : public PublicEditor
        void start_scrolling ();
        void stop_scrolling ();
 
+       bool _scrubbing;
+       bool have_full_mouse_speed;
+       nframes64_t last_scrub_frame;
+       double last_scrub_time;
+       int mouse_speed_update;
+       double mouse_direction;
+       double compute_mouse_speed ();
+       void add_mouse_speed (double, double);
+       double* mouse_speed;
+       size_t mouse_speed_entries;
+       size_t mouse_speed_size;
+
        void keyboard_selection_begin ();
        void keyboard_selection_finish (bool add);
        bool have_pending_keyboard_selection;
-       jack_nframes_t pending_keyboard_selection_start;
+       nframes_t pending_keyboard_selection_start;
 
        boost::shared_ptr<ARDOUR::Region> select_region_for_operation (int dir, TimeAxisView **tv);
        void extend_selection_to_end_of_region (bool next);
@@ -1025,11 +1103,9 @@ class Editor : public PublicEditor
 
        Editing::SnapType snap_type;
        Editing::SnapMode snap_mode;
-       double snap_threshold;
 
-       void soundfile_chosen_for_insert (const string & selection, bool split_channels);
-       void soundfile_chosen_for_embed (const string & selection, bool split_channels);
-       void soundfile_chosen_for_import (const string & selection, bool split_channels);
+       /// Snap threshold in pixels
+       double snap_threshold;
 
        void handle_gui_changes (const string &, void *);
 
@@ -1051,11 +1127,20 @@ class Editor : public PublicEditor
        void fade_out_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
        void fade_in_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
        void fade_out_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
+
+       void set_fade_in_shape (ARDOUR::AudioRegion::FadeShape);
+       void set_fade_out_shape (ARDOUR::AudioRegion::FadeShape);
+
+       void set_fade_in_active (bool);
+       void set_fade_out_active (bool);
        
-       std::set<ARDOUR::Playlist*> motion_frozen_playlists;
+       std::set<boost::shared_ptr<ARDOUR::Playlist> > motion_frozen_playlists;
        void region_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
        void region_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
-       void region_copy_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
+       void create_region_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
+       void create_region_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
+
+       bool _dragging_playhead;
 
        void cursor_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
        void cursor_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
@@ -1074,6 +1159,7 @@ class Editor : public PublicEditor
        gint mouse_rename_region (ArdourCanvas::Item*, GdkEvent*);
 
        void start_region_grab (ArdourCanvas::Item*, GdkEvent*);
+       void start_create_region_grab (ArdourCanvas::Item*, GdkEvent*);
        void start_region_copy_grab (ArdourCanvas::Item*, GdkEvent*);
        void start_region_brush_grab (ArdourCanvas::Item*, GdkEvent*);
        void start_selection_grab (ArdourCanvas::Item*, GdkEvent*);
@@ -1093,11 +1179,11 @@ class Editor : public PublicEditor
        void remove_gain_control_point (ArdourCanvas::Item*, GdkEvent*);
        void remove_control_point (ArdourCanvas::Item*, GdkEvent*);
 
-       void mouse_brush_insert_region (RegionView*, jack_nframes_t pos);
-       void brush (jack_nframes_t);
+       void mouse_brush_insert_region (RegionView*, nframes_t pos);
+       void brush (nframes_t);
 
-       void show_verbose_time_cursor (jack_nframes_t frame, double offset = 0, double xpos=-1, double ypos=-1);
-       void show_verbose_duration_cursor (jack_nframes_t start, jack_nframes_t end, double offset = 0, double xpos=-1, double ypos=-1);
+       void show_verbose_time_cursor (nframes_t frame, double offset = 0, double xpos=-1, double ypos=-1);
+       void show_verbose_duration_cursor (nframes_t start, nframes_t end, double offset = 0, double xpos=-1, double ypos=-1);
 
        /* Canvas event handlers */
 
@@ -1140,14 +1226,17 @@ class Editor : public PublicEditor
 
        bool canvas_playhead_cursor_event (GdkEvent* event, ArdourCanvas::Item*);
        bool canvas_edit_cursor_event (GdkEvent* event, ArdourCanvas::Item*);
-       bool track_canvas_event (GdkEvent* event, ArdourCanvas::Item*);
        bool track_canvas_scroll (GdkEventScroll* event);
 
-       bool track_canvas_button_press_event (GdkEventButton *);
-       bool track_canvas_button_release_event (GdkEventButton *);
-       
+       bool track_canvas_scroll_event (GdkEventScroll* event);
+       bool track_canvas_button_press_event (GdkEventButton* event);
+       bool track_canvas_button_release_event (GdkEventButton* event);
+       bool track_canvas_motion_notify_event (GdkEventMotion* event);
+
+       Gtk::Allocation canvas_allocation;
+       bool canvas_idle_queued;
        void track_canvas_allocate (Gtk::Allocation alloc);
-       void time_canvas_allocate (Gtk::Allocation alloc);
+       bool track_canvas_size_allocated ();
 
        void set_edit_cursor (GdkEvent* event);
        void set_playhead_cursor (GdkEvent* event);
@@ -1173,31 +1262,33 @@ class Editor : public PublicEditor
        void handle_new_duration ();
        void initialize_canvas ();
        void reset_scrolling_region (Gtk::Allocation* alloc = 0);
-       void scroll_canvas ();
 
        /* display control */
        
        bool _show_measures;
+       /// true to show waveforms, otherwise false
        bool _show_waveforms;
+       /// true if the editor should follow the playhead, otherwise false
        bool _follow_playhead;
+       /// true if waveforms should be shown while recording audio tracks, otherwise false
        bool _show_waveforms_recording;
        
        ARDOUR::TempoMap::BBTPointList *current_bbt_points;
        
-       typedef vector<ArdourCanvas::SimpleLine*> TimeLineList;
-       TimeLineList free_measure_lines;
-       TimeLineList used_measure_lines;
-
        ArdourCanvas::Group* time_line_group;
-       ArdourCanvas::SimpleLine* get_time_line ();
+       ArdourCanvas::Group* marker_time_line_group;
+       
+       TempoLines* tempo_lines;
+       TempoLines* marker_tempo_lines;
+
        void hide_measures ();
        void draw_measures ();
-       bool lazy_hide_and_draw_measures ();
+       bool redraw_measures ();
 
        void new_tempo_section ();
 
-       void mouse_add_new_tempo_event (jack_nframes_t where);
-       void mouse_add_new_meter_event (jack_nframes_t where);
+       void mouse_add_new_tempo_event (nframes_t where);
+       void mouse_add_new_meter_event (nframes_t where);
 
        void remove_tempo_marker (ArdourCanvas::Item*);
        void remove_meter_marker (ArdourCanvas::Item*);
@@ -1215,8 +1306,10 @@ class Editor : public PublicEditor
        void marker_menu_hide ();
        void marker_menu_loop_range ();
        void marker_menu_select_all_selectables_using_range ();
+       void marker_menu_select_using_range ();
        void marker_menu_separate_regions_using_location ();
        void marker_menu_play_from ();
+       void marker_menu_play_range ();
        void marker_menu_set_playhead ();
        void marker_menu_set_from_playhead ();
        void marker_menu_set_from_selection ();
@@ -1229,14 +1322,14 @@ class Editor : public PublicEditor
        void tm_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
        void transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
        void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
-       void build_range_marker_menu ();
-       void build_marker_menu ();
+       void build_range_marker_menu (bool loop_or_punch);
+       void build_marker_menu (bool start_or_end);
        void build_tm_marker_menu ();
-       void build_transport_marker_menu ();
        void build_new_transport_marker_menu ();
 
        Gtk::Menu* tm_marker_menu;
        Gtk::Menu* marker_menu;
+       Gtk::Menu* start_end_marker_menu;
        Gtk::Menu* range_marker_menu;
        Gtk::Menu* transport_marker_menu;
        Gtk::Menu* new_transport_marker_menu;
@@ -1249,16 +1342,27 @@ class Editor : public PublicEditor
        void draw_metric_marks (const ARDOUR::Metrics& metrics);
 
        void tempo_map_changed (ARDOUR::Change);
-       void redisplay_tempo ();
+       void redisplay_tempo (bool immediate_redraw);
        
-       void snap_to (jack_nframes_t& first, int32_t direction = 0, bool for_mark = false);
+       void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
+       void snap_to (nframes_t& first, int32_t direction = 0, bool for_mark = false) {
+               /* XXX remove this function when everything moves to 64 bit frame counts */
+               nframes64_t first64 = first;
+               snap_to (first64, direction, for_mark);
+               first = (nframes_t) first64;
+       }
+       
+       double snap_length_beats (nframes_t start);
+
        uint32_t bbt_beat_subdivision;
 
        /* toolbar */
        
-       Gtk::ToggleButton        editor_mixer_button;
+       Gtk::ToggleButton editor_mixer_button;
+       Gtk::ToggleButton editor_list_button;
 
        void editor_mixer_button_toggled ();
+       void editor_list_button_toggled ();
 
        AudioClock               edit_cursor_clock;
        AudioClock               zoom_range_clock;
@@ -1280,6 +1384,7 @@ class Editor : public PublicEditor
        Gtk::ToggleButton        mouse_zoom_button;
        Gtk::ToggleButton        mouse_timefx_button;
        Gtk::ToggleButton        mouse_audition_button;
+       Gtk::ToggleButton        mouse_note_button;
        GroupedButtons          *mouse_mode_button_set;
        void                     mouse_mode_toggled (Editing::MouseMode m);
        bool                     ignore_mouse_mode_toggle;
@@ -1299,28 +1404,58 @@ class Editor : public PublicEditor
        Gtk::ComboBoxText snap_mode_selector;
        Gtk::HBox         snap_box;
 
+       std::vector<std::string> snap_type_strings;
+       std::vector<std::string> snap_mode_strings;
+
        void snap_type_selection_done ();
        void snap_mode_selection_done ();
-       
+       void snap_mode_chosen (Editing::SnapMode);
+       void snap_type_chosen (Editing::SnapType);
+
+       Glib::RefPtr<Gtk::RadioAction> snap_type_action (Editing::SnapType);
+       Glib::RefPtr<Gtk::RadioAction> snap_mode_action (Editing::SnapMode);
+
        Gtk::ComboBoxText zoom_focus_selector;
-       Gtk::VBox                zoom_focus_box;
+       Gtk::VBox         zoom_focus_box;
+
+       std::vector<std::string> zoom_focus_strings;
        
        void zoom_focus_selection_done ();
+       void zoom_focus_chosen (Editing::ZoomFocus);
+
+       Glib::RefPtr<Gtk::RadioAction> zoom_focus_action (Editing::ZoomFocus);
 
        Gtk::HBox           zoom_box;
 
-       void                update_zoom_indicator ();
        void                zoom_adjustment_changed();
 
        void                edit_cursor_clock_changed();
        
        void setup_toolbar ();
 
-       Gtkmm2ext::TearOff*       tools_tearoff;
+       Gtkmm2ext::TearOff*      tools_tearoff;
        Gtk::HBox                toolbar_hbox;
        Gtk::EventBox            toolbar_base;
        Gtk::Frame               toolbar_frame;
 
+       /* midi toolbar */
+
+       Gtk::HBox                midi_tool_button_box;
+       Gtkmm2ext::TearOff*      midi_tool_tearoff;
+       Gtk::ToggleButton        midi_tool_pencil_button;
+       Gtk::ToggleButton        midi_tool_select_button;
+       Gtk::ToggleButton        midi_tool_erase_button;
+       GroupedButtons          *midi_tool_button_set;
+       void                     midi_edit_mode_toggled (Editing::MidiEditMode m);
+       bool                     ignore_midi_edit_mode_toggle;
+
+       Gtkmm2ext::TearOff* midi_tools_tearoff;
+       Gtk::HBox           midi_toolbar_hbox;
+       Gtk::EventBox       midi_toolbar_base;
+       Gtk::Frame          midi_toolbar_frame;
+       
+       void setup_midi_toolbar ();
+
        /* selection process */
 
        Selection* selection;
@@ -1330,8 +1465,6 @@ class Editor : public PublicEditor
        void track_selection_changed ();
        void region_selection_changed ();
        void point_selection_changed ();
-       void audio_track_selection_changed ();
-       void line_selection_changed ();
 
        enum SelectionOp {
                CreateSelection,
@@ -1349,7 +1482,7 @@ class Editor : public PublicEditor
        void region_selection_op (void (ARDOUR::Region::*pmf)(void*), void*);
        void region_selection_op (void (ARDOUR::Region::*pmf)(bool), bool);
 
-       bool audio_region_selection_covers (jack_nframes_t where);
+       bool audio_region_selection_covers (nframes_t where);
 
        /* transport range select process */
        enum RangeMarkerOp {
@@ -1390,7 +1523,7 @@ class Editor : public PublicEditor
        void drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
        void end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
 
-       bool select_all_within (jack_nframes_t start, jack_nframes_t end, gdouble topy, gdouble boty, Selection::Operation op);
+       bool select_all_within (nframes_t start, nframes_t end, gdouble topy, gdouble boty, const TrackViewList&, Selection::Operation op);
        
        ArdourCanvas::SimpleRect   *rubberband_rect;
        
@@ -1401,7 +1534,7 @@ class Editor : public PublicEditor
        void end_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
 
        ArdourCanvas::SimpleRect   *zoom_rect;
-       void reposition_zoom_rect (jack_nframes_t start, jack_nframes_t end);
+       void reposition_zoom_rect (nframes_t start, nframes_t end);
        
        /* diskstream/route display management */
 
@@ -1410,32 +1543,37 @@ class Editor : public PublicEditor
                    add (text);
                    add (visible);
                    add (tv);
+                   add (route);
            }
            Gtk::TreeModelColumn<Glib::ustring>  text;
            Gtk::TreeModelColumn<bool>           visible;
            Gtk::TreeModelColumn<TimeAxisView*>  tv;
+           Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> >  route;
        };
 
        RouteDisplayModelColumns         route_display_columns;
        Glib::RefPtr<Gtk::ListStore>     route_display_model;
        Glib::RefPtr<Gtk::TreeSelection> route_display_selection;
 
-       gint route_list_compare_func (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
-       Gtkmm2ext::DnDTreeView   route_list_display; 
-       Gtk::ScrolledWindow      route_list_scroller;
-       Gtk::Menu*               route_list_menu;
+       Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Route> > route_list_display; 
+       Gtk::ScrolledWindow                   route_list_scroller;
+       Gtk::Menu*                            route_list_menu;
+
+       void sync_order_keys ();
+       bool ignore_route_order_sync;
 
        bool route_list_display_button_press (GdkEventButton*);
        bool route_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
 
        void route_list_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
        void route_list_delete (const Gtk::TreeModel::Path&);
+       void track_list_reorder (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* new_order);
+
        void initial_route_list_display ();
        void redisplay_route_list();
        void route_list_reordered (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* what);
        bool ignore_route_list_reorder;
        bool no_route_list_redisplay;
-       void queue_route_list_reordered ();
 
        void build_route_list_menu ();
        void show_route_list_menu ();
@@ -1483,9 +1621,6 @@ class Editor : public PublicEditor
        void new_edit_group ();
        void edit_group_list_button_clicked ();
        gint edit_group_list_button_press_event (GdkEventButton* ev);
-       void edit_group_selection_changed ();
-       void fake_add_edit_group (ARDOUR::RouteGroup* group);
-       void fake_remove_edit_group (ARDOUR::RouteGroup* group);
        void add_edit_group (ARDOUR::RouteGroup* group);
        void remove_selected_edit_group ();
        void edit_groups_changed ();
@@ -1495,10 +1630,11 @@ class Editor : public PublicEditor
 
        /* autoscrolling */
 
+       bool autoscroll_active;
        int autoscroll_timeout_tag;
        int autoscroll_direction;
        uint32_t autoscroll_cnt;
-       jack_nframes_t autoscroll_distance;
+       nframes_t autoscroll_distance;
      
        static gint _autoscroll_canvas (void *);
        bool autoscroll_canvas ();
@@ -1516,9 +1652,9 @@ class Editor : public PublicEditor
        void start_trim (ArdourCanvas::Item*, GdkEvent*);
        void point_trim (GdkEvent*);
        void trim_motion_callback (ArdourCanvas::Item*, GdkEvent*);
-       void single_contents_trim (RegionView&, jack_nframes_t, bool, bool, bool);
-       void single_start_trim (RegionView&, jack_nframes_t, bool, bool);
-       void single_end_trim (RegionView&, jack_nframes_t, bool, bool);
+       void single_contents_trim (RegionView&, nframes_t, bool, bool, bool);
+       void single_start_trim (RegionView&, nframes_t, bool, bool);
+       void single_end_trim (RegionView&, nframes_t, bool, bool);
 
        void trim_finished_callback (ArdourCanvas::Item*, GdkEvent*);
        void thaw_region_after_trim (RegionView& rv);
@@ -1572,7 +1708,7 @@ class Editor : public PublicEditor
        ExportDialog *export_dialog;
        ExportDialog *export_range_markers_dialog;
        
-       void export_range (jack_nframes_t start, jack_nframes_t end);
+       void export_range (nframes_t start, nframes_t end);
        void export_range_markers ();
 
        int  write_region_selection(RegionSelection&);
@@ -1583,7 +1719,7 @@ class Editor : public PublicEditor
        void external_edit_region ();
 
        int write_audio_selection (TimeSelection&);
-       bool write_audio_range (ARDOUR::AudioPlaylist&, uint32_t channels, list<ARDOUR::AudioRange>&);
+       bool write_audio_range (ARDOUR::AudioPlaylist&, const ARDOUR::ChanCount& channels, list<ARDOUR::AudioRange>&);
 
        void write_selection ();
 
@@ -1591,7 +1727,8 @@ class Editor : public PublicEditor
 
        UndoAction get_memento() const;
 
-        XMLNode *before; /* used in *_reversible_command */
+       XMLNode *before; /* used in *_reversible_command */
+
        void begin_reversible_command (string cmd_name);
        void commit_reversible_command ();
 
@@ -1600,18 +1737,16 @@ class Editor : public PublicEditor
        UndoHistory visual_history;
        UndoTransaction current_visual_command;
 
-       void begin_reversible_visual_command (const string & cmd_name);
-       void commit_reversible_visual_command ();
 
        void update_title ();   
        void update_title_s (const string & snapshot_name);
 
        struct State {
            Selection* selection;
-           double     frames_per_unit;
+           double frames_per_unit;
 
-           State();
-           ~State();
+           State (PublicEditor const * e);
+           ~State ();
        };
 
        void store_state (State&) const;
@@ -1628,8 +1763,8 @@ class Editor : public PublicEditor
        static void* _freeze_thread (void*);
        void* freeze_thread ();
 
-       void freeze_route ();
-       void unfreeze_route ();
+       void freeze_routes ();
+       void unfreeze_routes ();
 
        /* edit-group solo + mute */
 
@@ -1640,12 +1775,7 @@ class Editor : public PublicEditor
 
        void duplicate_dialog (bool for_region);
        
-       /* edit menu */
-
-       Gtk::Menu* edit_menu;
-       bool edit_menu_map_handler (GdkEventAny*);
-
-       jack_nframes_t event_frame (GdkEvent*, double* px = 0, double* py = 0);
+       nframes_t event_frame (GdkEvent*, double* px = 0, double* py = 0);
 
        void time_fx_motion (ArdourCanvas::Item*, GdkEvent*);
        void start_time_fx (ArdourCanvas::Item*, GdkEvent*);
@@ -1686,6 +1816,7 @@ class Editor : public PublicEditor
        /* editor-mixer strip */
 
        MixerStrip *current_mixer_strip;
+       bool show_editor_mixer_when_tracks_arrive;
        Gtk::VBox current_mixer_strip_vbox;
        void cms_deleted ();
        void current_mixer_strip_hidden ();
@@ -1696,13 +1827,13 @@ class Editor : public PublicEditor
 
        /* nudging tracks */
 
-       void nudge_track (bool use_edit_cursor, bool forwards);
+       void nudge_selected_tracks (bool use_edit_cursor, bool forwards);
 
        /* xfades */
 
        bool _xfade_visibility;
        
-       /* <CMT Additions> */
+#ifdef WITH_CMT
        void handle_new_imageframe_time_axis_view(const string & track_name, void* src) ;
        void handle_new_imageframe_marker_time_axis_view(const string & track_name, TimeAxisView* marked_track) ;
 
@@ -1741,12 +1872,11 @@ class Editor : public PublicEditor
        void popup_marker_time_axis_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
 
        ImageFrameSocketHandler* image_socket_listener ;
-       /* </CMT Additions> */
+#endif
 
-       void toggle_xfade_active (ARDOUR::Crossfade*);
-       void toggle_xfade_length (ARDOUR::Crossfade*);
-       void edit_xfade (ARDOUR::Crossfade*);
-       void remove_xfade ();
+       void toggle_xfade_active (boost::weak_ptr<ARDOUR::Crossfade>);
+       void toggle_xfade_length (boost::weak_ptr<ARDOUR::Crossfade>);
+       void edit_xfade (boost::weak_ptr<ARDOUR::Crossfade>);
        void xfade_edit_left_region ();
        void xfade_edit_right_region ();
 
@@ -1761,15 +1891,15 @@ class Editor : public PublicEditor
        Gtk::VBox        nudge_vbox;
        AudioClock       nudge_clock;
 
-       jack_nframes_t get_nudge_distance (jack_nframes_t pos, jack_nframes_t& next);
+       nframes_t get_nudge_distance (nframes_t pos, nframes_t& next);
        
        /* audio filters */
 
-       void apply_filter (ARDOUR::AudioFilter&, string cmd);
+       void apply_filter (ARDOUR::Filter&, string cmd);
 
        /* handling cleanup */
 
-       int playlist_deletion_dialog (ARDOUR::Playlist*);
+       int playlist_deletion_dialog (boost::shared_ptr<ARDOUR::Playlist>);
 
        vector<sigc::connection> session_connections;
 
@@ -1792,10 +1922,25 @@ class Editor : public PublicEditor
 
        void toggle_gain_envelope_visibility ();
        void toggle_gain_envelope_active ();
+       void reset_region_gain_envelopes ();
+
+       Gtk::CheckMenuItem* region_envelope_visible_item;
+       Gtk::CheckMenuItem* region_envelope_active_item;
+       Gtk::CheckMenuItem* region_mute_item;
+       Gtk::CheckMenuItem* region_lock_item;
+       Gtk::CheckMenuItem* region_lock_position_item;
+       Gtk::CheckMenuItem* region_opaque_item;
        
        bool on_key_press_event (GdkEventKey*);
 
        void session_state_saved (string);
+
+       Glib::RefPtr<Gtk::Action>              undo_action;
+       Glib::RefPtr<Gtk::Action>              redo_action;
+
+       void history_changed ();
+
+       Gtk::HBox      status_bar_hpacker;
 };
 
 #endif /* __ardour_editor_h__ */