Speed up AFL/PFL changes for large sessions
[ardour.git] / gtk2_ardour / editor.h
index d486e5b9f095a6b8470df133b52e081cdafe023a..57e72393fad0053ff141b9f90f808a8802e24626 100644 (file)
 #ifndef __ardour_editor_h__
 #define __ardour_editor_h__
 
+#include <sys/time.h>
+
+#include <cmath>
 #include <list>
 #include <map>
 #include <set>
 #include <string>
-#include <sys/time.h>
-#include <cmath>
+#include <vector>
 
 #include <boost/optional.hpp>
 
 #include <gtkmm/comboboxtext.h>
 #include <gtkmm/layout.h>
 
-#include "gtkmm2ext/selector.h"
+#include "gtkmm2ext/bindings.h"
 #include "gtkmm2ext/click_box.h"
 #include "gtkmm2ext/dndtreeview.h"
+#include "gtkmm2ext/pane.h"
+#include "gtkmm2ext/selector.h"
 #include "gtkmm2ext/stateful_button.h"
-#include "gtkmm2ext/bindings.h"
 
 #include "pbd/stateful.h"
 #include "pbd/signals.h"
@@ -47,8 +50,8 @@
 #include "ardour/types.h"
 
 #include "canvas/fwd.h"
+#include "canvas/ruler.h"
 
-#include "gtk-custom-ruler.h"
 #include "ardour_button.h"
 #include "ardour_dialog.h"
 #include "ardour_dropdown.h"
 #include "enums.h"
 #include "editor_items.h"
 #include "region_selection.h"
+#include "selection_memento.h"
+#include "tempo_curve.h"
 
 namespace Gtkmm2ext {
-       class TearOff;
        class Bindings;
 }
 
 namespace ARDOUR {
-       class RouteGroup;
-       class Playlist;
        class AudioPlaylist;
        class AudioRegion;
-       class Region;
-       class Location;
-       class TempoSection;
-       class Session;
-       class Filter;
+       class AudioTrack;
        class ChanCount;
+       class Filter;
+       class Location;
        class MidiOperator;
-       class Track;
+       class MidiRegion;
        class MidiTrack;
-       class AudioTrack;
+       class Playlist;
+       class Region;
+       class RouteGroup;
+       class Session;
+       class TempoSection;
+       class Track;
 }
 
 namespace LADSPA {
@@ -95,6 +100,7 @@ class AutomationTimeAxisView;
 class BundleManager;
 class ButtonJoiner;
 class ControlPoint;
+class CursorContext;
 class DragManager;
 class EditNoteDialog;
 class EditorCursor;
@@ -107,15 +113,18 @@ class EditorSnapshots;
 class EditorSummary;
 class GroupedButtons;
 class GUIObjectState;
-class Marker;
+class ArdourMarker;
 class MidiRegionView;
+class MidiExportDialog;
 class MixerStrip;
 class MouseCursors;
 class NoteBase;
 class PlaylistSelector;
 class PluginSelector;
 class ProgressReporter;
+class QuantizeDialog;
 class RhythmFerret;
+class RulerDialog;
 class Selection;
 class SoundFileOmega;
 class StreamView;
@@ -135,6 +144,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void             set_session (ARDOUR::Session *);
        ARDOUR::Session* session() const { return _session; }
 
+       Gtk::Window* use_own_window (bool and_fill_it);
+
        void             first_idle ();
        virtual bool     have_idled () const { return _have_idled; }
 
@@ -147,6 +158,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        double visible_canvas_height () const {
                return _visible_canvas_height;
        }
+       double trackviews_height () const;
 
        void cycle_snap_mode ();
        void next_snap_choice ();
@@ -161,6 +173,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        Editing::SnapMode  snap_mode () const;
        Editing::SnapType  snap_type () const;
+       bool  snap_musical () const;
 
        void undo (uint32_t n = 1);
        void redo (uint32_t n = 1);
@@ -174,11 +187,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Editing::MidiEditMode current_midi_edit_mode () const;
        void remove_midi_note (ArdourCanvas::Item *, GdkEvent *);
 
-       bool internal_editing() const { return _internal_editing ; }
-       void set_internal_edit (bool yn);
-       bool toggle_internal_editing_from_double_click (GdkEvent*);
+       bool internal_editing() const;
 
-        void _ensure_time_axis_view_is_visible (const TimeAxisView& tav, bool at_top);
        void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>);
        void add_to_idle_resize (TimeAxisView*, int32_t);
 
@@ -229,7 +239,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        }
 
         double sample_to_pixel (framepos_t sample) const {
-               return sample / samples_per_pixel;
+               return round (sample / (double) samples_per_pixel);
        }
 
        double sample_to_pixel_unrounded (framepos_t sample) const {
@@ -239,6 +249,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        /* selection */
 
        Selection& get_selection() const { return *selection; }
+       bool get_selection_extents (framepos_t &start, framepos_t &end) const;  // the time extents of the current selection, whether Range, Region(s), Control Points, or Notes
        Selection& get_cut_buffer() const { return *cut_buffer; }
        void track_mixer_selection ();
 
@@ -249,7 +260,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void maybe_locate_with_edit_preroll (framepos_t);
        void play_with_preroll ();
        void select_all_in_track (Selection::Operation op);
-       void select_all (Selection::Operation op);
+       void select_all_objects (Selection::Operation op);
        void invert_selection_in_track ();
        void invert_selection ();
        void deselect_all ();
@@ -257,6 +268,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
 
+       void remove_tracks ();
+
        /* tempo */
 
        void set_show_measures (bool yn);
@@ -264,8 +277,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        /* analysis window */
 
-       void analyze_region_selection();
-       void analyze_range_selection();
+       void loudness_analyze_region_selection();
+       void loudness_analyze_range_selection();
+
+       void spectral_analyze_region_selection();
+       void spectral_analyze_range_selection();
 
        /* export */
 
@@ -275,14 +291,17 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void export_range ();
        void export_region ();
 
-       void add_toplevel_controls (Gtk::Container&);
-       Gtk::HBox& get_status_bar_packer()  { return status_bar_hpacker; }
+       bool process_midi_export_dialog (MidiExportDialog& dialog, boost::shared_ptr<ARDOUR::MidiRegion> midi_region);
 
        void               set_zoom_focus (Editing::ZoomFocus);
        Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
        framecnt_t         get_current_zoom () const { return samples_per_pixel; }
-        void               cycle_zoom_focus ();
-       void temporal_zoom_step (bool coarser);
+       void               cycle_zoom_focus ();
+       void temporal_zoom_step (bool zoom_out);
+       void temporal_zoom_step_scale (bool zoom_out, double scale);
+       void temporal_zoom_step_mouse_focus (bool zoom_out);
+       void temporal_zoom_step_mouse_focus_scale (bool zoom_out, double scale);
+       void ensure_time_axis_view_is_visible (TimeAxisView const & tav, bool at_top);
        void tav_zoom_step (bool coarser);
        void tav_zoom_smooth (bool coarser, bool force_all);
 
@@ -309,7 +328,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        /* nudge is initiated by transport controls owned by ARDOUR_UI */
 
        framecnt_t get_nudge_distance (framepos_t pos, framecnt_t& next);
-       Evoral::MusicalTime get_grid_type_as_beats (bool& success, framepos_t position);
+       framecnt_t get_paste_offset (framepos_t pos, unsigned paste_count, framecnt_t duration);
+       unsigned get_grid_beat_divisions(framepos_t position);
+       Evoral::Beats get_grid_type_as_beats (bool& success, framepos_t position);
+
+       int32_t get_grid_music_divisions (uint32_t event_state);
 
        void nudge_forward (bool next, bool force_playhead);
        void nudge_backward (bool next, bool force_playhead);
@@ -336,7 +359,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void set_summary ();
        void set_group_tabs ();
        void toggle_measure_visibility ();
-       void toggle_logo_visibility ();
 
        /* fades */
 
@@ -351,12 +373,17 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void ensure_float (Gtk::Window&);
 
-       void show_window ();
-
        void scroll_tracks_down_line ();
        void scroll_tracks_up_line ();
-        bool scroll_up_one_track ();
-        bool scroll_down_one_track ();
+
+       bool scroll_up_one_track (bool skip_child_views = false);
+       bool scroll_down_one_track (bool skip_child_views = false);
+
+       void scroll_left_step ();
+       void scroll_right_step ();
+
+       void scroll_left_half_page ();
+       void scroll_right_half_page ();
 
        void prepare_for_cleanup ();
        void finish_cleanup ();
@@ -364,15 +391,16 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void maximise_editing_space();
        void restore_editing_space();
 
-       void update_tearoff_visibility();
-
+       double get_y_origin () const;
        void reset_x_origin (framepos_t);
        void reset_x_origin_to_follow_playhead ();
        void reset_y_origin (double);
        void reset_zoom (framecnt_t);
        void reposition_and_zoom (framepos_t, double);
 
-       framepos_t get_preferred_edit_position (bool ignore_playhead = false, bool use_context_click = false);
+       framepos_t get_preferred_edit_position (Editing::EditIgnoreOption = Editing::EDIT_IGNORE_NONE,
+                                               bool use_context_click = false,
+                                               bool from_outside_canvas = false);
 
        bool update_mouse_speed ();
        bool decelerate_mouse_speed ();
@@ -394,34 +422,64 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        int get_regionview_count_from_region_list (boost::shared_ptr<ARDOUR::Region>);
 
-       void do_import (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, framepos_t&);
-       void do_embed (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode,  framepos_t&);
+       void do_ptimport(std::string path, ARDOUR::SrcQuality quality);
+
+       void do_import (std::vector<std::string>              paths,
+                       Editing::ImportDisposition            disposition,
+                       Editing::ImportMode                   mode,
+                       ARDOUR::SrcQuality                    quality,
+                       framepos_t&                           pos,
+                       boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
+
+       void do_embed (std::vector<std::string>              paths,
+                      Editing::ImportDisposition            disposition,
+                      Editing::ImportMode                   mode,
+                      framepos_t&                           pos,
+                      boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
+
+       void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions, bool src_comparison);
 
-        void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions, bool src_comparison);
+       void get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const;
+       void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >&) const;
 
        void center_screen (framepos_t);
 
        TrackViewList axis_views_from_routes (boost::shared_ptr<ARDOUR::RouteList>) const;
-       Gtkmm2ext::TearOff* mouse_mode_tearoff () const { return _mouse_mode_tearoff; }
-       Gtkmm2ext::TearOff* tools_tearoff () const { return _tools_tearoff; }
-
-       void snap_to (framepos_t& first, int32_t direction = 0, bool for_mark = false);
-       void snap_to_with_modifier (framepos_t& first, GdkEvent const *, int32_t direction = 0, bool for_mark = false);
-       void snap_to (framepos_t& first, framepos_t& last, int32_t direction = 0, bool for_mark = false);
 
+       void snap_to (framepos_t&       first,
+                     ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
+                     bool              for_mark  = false,
+                     bool              ensure_snap = false);
+
+       void snap_to_with_modifier (framepos_t&       first,
+                                   GdkEvent const *  ev,
+                                   ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
+                                   bool              for_mark  = false);
+
+       void snap_to (framepos_t&       first,
+                     framepos_t&       last,
+                     ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
+                     bool              for_mark  = false);
+
+       void begin_selection_op_history ();
+       void begin_reversible_selection_op (std::string cmd_name);
+       void commit_reversible_selection_op ();
+       void undo_selection_op ();
+       void redo_selection_op ();
        void begin_reversible_command (std::string cmd_name);
        void begin_reversible_command (GQuark);
+       void abort_reversible_command ();
        void commit_reversible_command ();
 
        DragManager* drags () const {
                return _drags;
        }
 
-        void maybe_autoscroll (bool, bool, bool);
-        bool autoscroll_active() const;
+       void maybe_autoscroll (bool, bool, bool);
+       bool autoscroll_active() const;
+
+       Gdk::Cursor* get_canvas_cursor () const;
 
-       Gdk::Cursor* get_canvas_cursor () const { return current_canvas_cursor; }
-       void set_canvas_cursor (Gdk::Cursor*, bool save=false);
        void set_current_trimmable (boost::shared_ptr<ARDOUR::Trimmable>);
        void set_current_movable (boost::shared_ptr<ARDOUR::Movable>);
 
@@ -438,22 +496,54 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void get_pointer_position (double &, double &) const;
 
+       /** Context for mouse entry (stored in a stack). */
+       struct EnterContext {
+               ItemType                         item_type;
+               boost::shared_ptr<CursorContext> cursor_ctx;
+       };
+
+       /** Get the topmost enter context for the given item type.
+        *
+        * This is used to change the cursor associated with a given enter context,
+        * which may not be on the top of the stack.
+        */
+       EnterContext* get_enter_context(ItemType type);
+
        TimeAxisView* stepping_axis_view () {
                return _stepping_axis_view;
        }
-       
+
        void set_stepping_axis_view (TimeAxisView* v) {
                _stepping_axis_view = v;
        }
 
-       ArdourCanvas::Group* get_trackview_group () const { return _trackview_group; }
-        ArdourCanvas::Group* get_hscroll_group () const { return h_scroll_group; }
-        ArdourCanvas::Group* get_vscroll_group () const { return v_scroll_group; }
-        ArdourCanvas::Group* get_hvscroll_group () const { return hv_scroll_group; }
+       ArdourCanvas::Container* get_trackview_group () const { return _trackview_group; }
+       ArdourCanvas::Container* get_noscroll_group () const { return no_scroll_group; }
+       ArdourCanvas::ScrollGroup* get_hscroll_group () const { return h_scroll_group; }
+       ArdourCanvas::ScrollGroup* get_hvscroll_group () const { return hv_scroll_group; }
+       ArdourCanvas::ScrollGroup* get_cursor_scroll_group () const { return cursor_scroll_group; }
+
+       ArdourCanvas::GtkCanvasViewport* get_track_canvas () const;
 
-        ArdourCanvas::GtkCanvasViewport* get_track_canvas () const;
+       void override_visible_track_count ();
 
-        void override_visible_track_count ();
+       /* Ruler metrics methods */
+
+       void metric_get_timecode (std::vector<ArdourCanvas::Ruler::Mark>&, gdouble, gdouble, gint);
+       void metric_get_bbt (std::vector<ArdourCanvas::Ruler::Mark>&, gdouble, gdouble, gint);
+       void metric_get_samples (std::vector<ArdourCanvas::Ruler::Mark>&, gdouble, gdouble, gint);
+       void metric_get_minsec (std::vector<ArdourCanvas::Ruler::Mark>&, gdouble, gdouble, gint);
+
+       /* editing operations that need to be public */
+       void mouse_add_new_marker (framepos_t where, bool is_cd=false);
+       void split_regions_at (framepos_t, RegionSelection&, const int32_t sub_num, bool snap = true);
+       void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false);
+       RegionSelection get_regions_from_selection_and_mouse (framepos_t);
+
+       void mouse_add_new_tempo_event (framepos_t where);
+       void mouse_add_new_meter_event (framepos_t where);
+       void edit_tempo_section (ARDOUR::TempoSection*);
+       void edit_meter_section (ARDOUR::MeterSection*);
 
   protected:
        void map_transport_state ();
@@ -461,6 +551,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void on_realize();
 
+       void suspend_route_redisplay ();
+       void resume_route_redisplay ();
+
   private:
 
        void color_handler ();
@@ -498,19 +591,16 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void cancel_visual_state_op (uint32_t n);
 
        framepos_t         leftmost_frame;
-        framecnt_t         samples_per_pixel;
+       framecnt_t         samples_per_pixel;
        Editing::ZoomFocus zoom_focus;
 
        void set_samples_per_pixel (framecnt_t);
-        bool clamp_samples_per_pixel (framecnt_t &) const;
 
        Editing::MouseMode mouse_mode;
-       Editing::MouseMode pre_internal_mouse_mode;
        Editing::SnapType  pre_internal_snap_type;
        Editing::SnapMode  pre_internal_snap_mode;
        Editing::SnapType  internal_snap_type;
        Editing::SnapMode  internal_snap_mode;
-       bool _internal_editing;
        Editing::MouseMode effective_mouse_mode () const;
 
        enum JoinObjectRangeState {
@@ -523,19 +613,17 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        JoinObjectRangeState _join_object_range_state;
 
-       void update_join_object_range_location (double, double);
-
-       boost::optional<int>  pre_notebook_shrink_pane_width;
+       void update_join_object_range_location (double);
 
-       void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*);
+       boost::optional<float>  pre_notebook_shrink_pane_width;
 
        Gtk::Notebook _the_notebook;
        bool _notebook_shrunk;
        void add_notebook_page (std::string const &, Gtk::Widget &);
        bool notebook_tab_clicked (GdkEventButton *, Gtk::Widget *);
 
-       Gtk::HPaned   edit_pane;
-       Gtk::VPaned   editor_summary_pane;
+       Gtkmm2ext::HPane   edit_pane;
+       Gtkmm2ext::VPane   editor_summary_pane;
 
        Gtk::EventBox meter_base;
        Gtk::HBox     meter_box;
@@ -544,15 +632,16 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::VBox     scrollers_rulers_markers_box;
 
        void location_changed (ARDOUR::Location *);
-       void location_flags_changed (ARDOUR::Location *, void *);
+       void location_flags_changed (ARDOUR::Location *);
        void refresh_location_display ();
-       void refresh_location_display_internal (ARDOUR::Locations::LocationList&);
+       void refresh_location_display_internal (const ARDOUR::Locations::LocationList&);
        void add_new_location (ARDOUR::Location *);
-       ArdourCanvas::Group* add_new_location_internal (ARDOUR::Location *);
+       ArdourCanvas::Container* add_new_location_internal (ARDOUR::Location *);
        void location_gone (ARDOUR::Location *);
        void remove_marker (ArdourCanvas::Item&, GdkEvent*);
        gint really_remove_marker (ARDOUR::Location* loc);
        void goto_nth_marker (int nth);
+       void trigger_script (int nth);
        void toggle_marker_lines ();
        void set_marker_line_visibility (bool);
 
@@ -563,8 +652,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        uint32_t location_cd_marker_color;
 
        struct LocationMarkers {
-               Marker* start;
-               Marker* end;
+               ArdourMarker* start;
+               ArdourMarker* end;
                bool    valid;
 
                LocationMarkers () : start(0), end(0), valid (true) {}
@@ -585,17 +674,17 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        };
 
        LocationMarkers  *find_location_markers (ARDOUR::Location *) const;
-       ARDOUR::Location* find_location_from_marker (Marker *, bool& is_start) const;
-       Marker* find_marker_from_location_id (PBD::ID const &, bool) const;
-       Marker* entered_marker;
+       ARDOUR::Location* find_location_from_marker (ArdourMarker *, bool& is_start) const;
+       ArdourMarker* find_marker_from_location_id (PBD::ID const &, bool) const;
+       ArdourMarker* entered_marker;
        bool _show_marker_lines;
 
        typedef std::map<ARDOUR::Location*,LocationMarkers *> LocationMarkerMap;
        LocationMarkerMap location_markers;
 
        void update_marker_labels ();
-       void update_marker_labels (ArdourCanvas::Group *);
-       void check_marker_label (Marker *);
+       void update_marker_labels (ArdourCanvas::Container *);
+       void check_marker_label (ArdourMarker *);
 
        /** A set of lists of Markers that are in each of the canvas groups
         *  for the marker sections at the top of the editor.  These lists
@@ -603,13 +692,14 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
         *  a marker has moved we can decide whether we need to update the labels
         *  for all markers or for just a few.
         */
-       std::map<ArdourCanvas::Group *, std::list<Marker *> > _sorted_marker_lists;
-       void remove_sorted_marker (Marker *);
+       std::map<ArdourCanvas::Container *, std::list<ArdourMarker *> > _sorted_marker_lists;
+       void remove_sorted_marker (ArdourMarker *);
 
        void hide_marker (ArdourCanvas::Item*, GdkEvent*);
        void clear_marker_display ();
-       void mouse_add_new_marker (framepos_t where, bool is_cd=false, bool is_xrun=false);
        void mouse_add_new_range (framepos_t);
+       void mouse_add_new_loop (framepos_t);
+       void mouse_add_new_punch (framepos_t);
        bool choose_new_marker_name(std::string &name);
        void update_cd_marker_display ();
        void ensure_cd_marker_updated (LocationMarkers * lam, ARDOUR::Location * location);
@@ -637,15 +727,16 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void mapped_use_new_playlist (RouteTimeAxisView&, uint32_t, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
        void mapped_use_copy_playlist (RouteTimeAxisView&, uint32_t, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
        void mapped_clear_playlist (RouteTimeAxisView&, uint32_t);
-       
+
        void button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type);
        bool button_release_can_deselect;
+       bool _mouse_changed_selection;
 
        void catch_vanishing_regionview (RegionView *);
 
        void set_selected_track (TimeAxisView&, Selection::Operation op = Selection::Set, bool no_remove=false);
        void select_all_tracks ();
-       void select_all_internal_edit (Selection::Operation);
+       bool select_all_internal_edit (Selection::Operation);
 
        bool set_selected_control_point_from_click (bool press, Selection::Operation op = Selection::Set);
        void set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool no_remove=false);
@@ -682,16 +773,35 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void popup_control_point_context_menu (ArdourCanvas::Item *, GdkEvent *);
        Gtk::Menu _control_point_context_menu;
 
+       void popup_note_context_menu (ArdourCanvas::Item *, GdkEvent *);
+       Gtk::Menu _note_context_menu;
+
+       void add_stripables (ARDOUR::StripableList&);
        void add_routes (ARDOUR::RouteList&);
        void timeaxisview_deleted (TimeAxisView *);
+       void add_vcas (ARDOUR::VCAList&);
+
+       Gtk::HBox global_hpacker;
+       Gtk::VBox global_vpacker;
+
+       /* Cursor stuff.  Do not use directly, use via CursorContext. */
+       friend class CursorContext;
+       std::vector<Gdk::Cursor*> _cursor_stack;
+       void set_canvas_cursor (Gdk::Cursor*);
+       size_t push_canvas_cursor (Gdk::Cursor*);
+       void pop_canvas_cursor ();
+
+       Gdk::Cursor* which_grabber_cursor () const;
+       Gdk::Cursor* which_track_cursor () const;
+       Gdk::Cursor* which_mode_cursor () const;
+       Gdk::Cursor* which_trim_cursor (bool left_side) const;
+       Gdk::Cursor* which_canvas_cursor (ItemType type) const;
 
-       Gtk::HBox           global_hpacker;
-       Gtk::VBox           global_vpacker;
-       Gtk::VBox           vpacker;
+       /** Push the appropriate enter/cursor context on item entry. */
+       void choose_canvas_cursor_on_entry (ItemType);
 
-       Gdk::Cursor*          current_canvas_cursor;
-       Gdk::Cursor* which_grabber_cursor ();
-       void set_canvas_cursor ();
+       /** Update all enter cursors based on current settings. */
+       void update_all_enter_cursors ();
 
        ArdourCanvas::GtkCanvas* _track_canvas;
        ArdourCanvas::GtkCanvasViewport* _track_canvas_viewport;
@@ -702,53 +812,50 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        VerboseCursor* _verbose_cursor;
 
        void parameter_changed (std::string);
+       void ui_parameter_changed (std::string);
 
-       bool track_canvas_motion (GdkEvent*);
-
-       Gtk::EventBox             time_canvas_event_box;
        Gtk::EventBox             time_bars_event_box;
-       Gtk::EventBox             ruler_label_event_box;
-
-       ArdourCanvas::Pixbuf     *logo_item;
-#if 0    
-    /* these will be needed when we have canvas rulers */
-       ArdourCanvas::Group      *minsec_group;
-       ArdourCanvas::Group      *bbt_group;
-       ArdourCanvas::Group      *timecode_group;
-       ArdourCanvas::Group      *frame_group;
-#endif
+       Gtk::VBox                 time_bars_vbox;
 
-       ArdourCanvas::Group      *tempo_group;
-       ArdourCanvas::Group      *meter_group;
-       ArdourCanvas::Group      *marker_group;
-       ArdourCanvas::Group      *range_marker_group;
-       ArdourCanvas::Group      *transport_marker_group;
-       ArdourCanvas::Group*      cd_marker_group;
+       ArdourCanvas::Container      *tempo_group;
+       ArdourCanvas::Container      *meter_group;
+       ArdourCanvas::Container      *marker_group;
+       ArdourCanvas::Container      *range_marker_group;
+       ArdourCanvas::Container      *transport_marker_group;
+       ArdourCanvas::Container*      cd_marker_group;
 
        /* parent for groups which themselves contain time markers */
-       ArdourCanvas::Group*     _time_markers_group;
+       ArdourCanvas::Container*     _time_markers_group;
 
        /* The group containing all other groups that are scrolled vertically
           and horizontally.
        */
-        ArdourCanvas::Group* hv_scroll_group;
+       ArdourCanvas::ScrollGroup* hv_scroll_group;
 
-       /* The group containing all other groups that are scrolled vertically ONLY
+       /* The group containing all other groups that are scrolled horizontally ONLY
        */
-        ArdourCanvas::Group* v_scroll_group;
+       ArdourCanvas::ScrollGroup* h_scroll_group;
 
-       /* The group containing all other groups that are scrolled horizontally ONLY
+       /* Scroll group for cursors, scrolled horizontally, above everything else
        */
-        ArdourCanvas::Group* h_scroll_group;
+       ArdourCanvas::ScrollGroup* cursor_scroll_group;
 
        /* The group containing all trackviews. */
-       ArdourCanvas::Group* _trackview_group;
+       ArdourCanvas::Container* no_scroll_group;
+
+       /* The group containing all trackviews. */
+       ArdourCanvas::Container* _trackview_group;
+
+       /* The group holding things (mostly regions) while dragging so they
+        * are on top of everything else
+        */
+       ArdourCanvas::Container* _drag_motion_group;
 
-        /* a rect that sits at the bottom of all tracks to act as a drag-no-drop/clickable
+       /* a rect that sits at the bottom of all tracks to act as a drag-no-drop/clickable
         * target area.
         */
-        ArdourCanvas::Rectangle* _canvas_bottom_rect;
-        bool canvas_bottom_rect_event (GdkEvent* event);
+       ArdourCanvas::Rectangle* _canvas_drop_zone;
+       bool canvas_drop_zone_event (GdkEvent* event);
 
        enum RulerType {
                ruler_metric_timecode = 0,
@@ -765,7 +872,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
                ruler_video_timeline = 10,
        };
 
-       static GtkCustomMetric ruler_metrics[4];
        Glib::RefPtr<Gtk::ToggleAction> ruler_timecode_action;
        Glib::RefPtr<Gtk::ToggleAction> ruler_bbt_action;
        Glib::RefPtr<Gtk::ToggleAction> ruler_samples_action;
@@ -778,19 +884,15 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Glib::RefPtr<Gtk::ToggleAction> ruler_cd_marker_action;
        bool                            no_ruler_shown_update;
 
-       bool ruler_button_press (GdkEventButton*);
-       bool ruler_button_release (GdkEventButton*);
-       bool ruler_mouse_motion (GdkEventMotion*);
-       bool ruler_scroll (GdkEventScroll* event);
-
        Gtk::Widget * ruler_grabbed_widget;
 
+       RulerDialog* ruler_dialog;
+
        void initialize_rulers ();
        void update_just_timecode ();
        void compute_fixed_ruler_scale (); //calculates the RulerScale of the fixed rulers
        void update_fixed_rulers ();
-        void update_tempo_based_rulers (ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
-                                       ARDOUR::TempoMap::BBTPointList::const_iterator& end);
+       void update_tempo_based_rulers ();
        void popup_ruler_menu (framepos_t where = 0, ItemType type = RegionItem);
        void update_ruler_visibility ();
        void set_ruler_visible (RulerType, bool);
@@ -800,16 +902,14 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void store_ruler_visibility ();
        void restore_ruler_visibility ();
 
-       static gint _metric_get_timecode (GtkCustomRulerMark **, gdouble, gdouble, gint);
-       static gint _metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
-       static gint _metric_get_samples (GtkCustomRulerMark **, gdouble, gdouble, gint);
-       static gint _metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
 
-       enum MinsecRulerScale {
+
+               enum MinsecRulerScale {
+               minsec_show_msecs,
                minsec_show_seconds,
                minsec_show_minutes,
                minsec_show_hours,
-               minsec_show_frames
+               minsec_show_many_hours
        };
 
        MinsecRulerScale minsec_ruler_scale;
@@ -824,7 +924,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
                timecode_show_frames,
                timecode_show_seconds,
                timecode_show_minutes,
-               timecode_show_hours
+               timecode_show_hours,
+               timecode_show_many_hours
        };
 
        TimecodeRulerScale timecode_ruler_scale;
@@ -837,7 +938,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void set_samples_ruler_scale (framepos_t, framepos_t);
 
        enum BBTRulerScale {
-               bbt_over,
+               bbt_show_many,
                bbt_show_64,
                bbt_show_16,
                bbt_show_4,
@@ -854,27 +955,14 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        gint bbt_nmarks;
        uint32_t bbt_bar_helper_on;
        uint32_t bbt_accent_modulo;
-        void compute_bbt_ruler_scale (framepos_t lower, framepos_t upper,
-                                     ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_begin,
-                                     ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_end);
-
-       gint metric_get_timecode (GtkCustomRulerMark **, gdouble, gdouble, gint);
-       gint metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
-       gint metric_get_samples (GtkCustomRulerMark **, gdouble, gdouble, gint);
-       gint metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
-
-       Gtk::Widget        *_ruler_separator;
-       GtkWidget          *_timecode_ruler;
-       GtkWidget          *_bbt_ruler;
-       GtkWidget          *_samples_ruler;
-       GtkWidget          *_minsec_ruler;
-       Gtk::Widget        *timecode_ruler;
-       Gtk::Widget        *bbt_ruler;
-       Gtk::Widget        *samples_ruler;
-       Gtk::Widget        *minsec_ruler;
-       static Editor      *ruler_editor;
-
-       static const double timebar_height;
+       void compute_bbt_ruler_scale (framepos_t lower, framepos_t upper);
+
+       ArdourCanvas::Ruler* timecode_ruler;
+       ArdourCanvas::Ruler* bbt_ruler;
+       ArdourCanvas::Ruler* samples_ruler;
+       ArdourCanvas::Ruler* minsec_ruler;
+
+       static double timebar_height;
        guint32 visible_timebars;
        Gtk::Menu          *editor_ruler_menu;
 
@@ -898,7 +986,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        /* videtimline related actions */
        Gtk::Label                videotl_label;
-       ArdourCanvas::Group*      videotl_group;
+       ArdourCanvas::Container*      videotl_group;
        Glib::RefPtr<Gtk::ToggleAction> ruler_video_action;
        Glib::RefPtr<Gtk::ToggleAction> xjadeo_proc_action;
        Glib::RefPtr<Gtk::ToggleAction> xjadeo_ontop_action;
@@ -917,11 +1005,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void toggle_ruler_video (bool onoff) {ruler_video_action->set_active(onoff);}
        int videotl_bar_height; /* in units of timebar_height; default: 4 */
        int get_videotl_bar_height () const { return videotl_bar_height; }
-       void export_video (bool range = false);
        void toggle_region_video_lock ();
 
-       Gtk::VBox          time_bars_vbox;
-
        friend class EditorCursor;
 
        EditorCursor*        playhead_cursor;
@@ -947,7 +1032,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void    selected_marker_to_selection_end   ();
 
        void    select_all_selectables_using_cursor (EditorCursor *, bool);
-       void    select_all_selectables_using_edit (bool);
+       void    select_all_selectables_using_edit (bool, bool);
        void    select_all_selectables_between (bool within);
        void    select_range_between ();
 
@@ -957,6 +1042,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        std::vector<ARDOUR::framepos_t> region_boundary_cache;
        void build_region_boundary_cache ();
 
+       Gtk::HBox           toplevel_hpacker;
+
        Gtk::HBox           top_hbox;
        Gtk::HBox           bottom_hbox;
 
@@ -964,9 +1051,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        /** the adjustment that controls the overall editor vertical scroll position */
        Gtk::Adjustment     vertical_adjustment;
-        Gtk::Adjustment     horizontal_adjustment;
+       Gtk::Adjustment     horizontal_adjustment;
 
-        Gtk::Adjustment     unused_adjustment; // yes, really; Gtk::Layout constructor requires refs
+       Gtk::Adjustment     unused_adjustment; // yes, really; Gtk::Layout constructor requires refs
        Gtk::Layout         controls_layout;
        bool control_layout_scroll (GdkEventScroll* ev);
        void reset_controls_layout_width ();
@@ -994,9 +1081,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::Menu *edit_controls_left_menu;
        Gtk::Menu *edit_controls_right_menu;
 
-       Gtk::VBox           ruler_label_vbox;
        Gtk::VBox           track_canvas_vbox;
-       Gtk::VBox           time_canvas_vbox;
        Gtk::VBox           edit_controls_vbox;
        Gtk::HBox           edit_controls_hbox;
 
@@ -1008,7 +1093,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void control_step_tracks_down ();
        void control_view (uint32_t);
        void control_scroll (float);
-       void control_select (uint32_t rid, Selection::Operation);
+       void control_select (boost::shared_ptr<ARDOUR::Stripable>, Selection::Operation);
        void control_unselect ();
        void access_action (std::string,std::string);
        bool deferred_control_scroll (framepos_t);
@@ -1044,13 +1129,13 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        static int _idle_visual_changer (void *arg);
        int idle_visual_changer ();
-        void visual_changer (const VisualChange&);
+       void visual_changer (const VisualChange&);
        void ensure_visual_change_idle_handler ();
 
        /* track views */
        TrackViewList track_views;
-       std::pair<TimeAxisView*, double> trackview_by_y_position (double);
-       RouteTimeAxisView* axis_view_from_route (boost::shared_ptr<ARDOUR::Route>) const;
+       std::pair<TimeAxisView*, double> trackview_by_y_position (double, bool trackview_relative_offset = true) const;
+       TimeAxisView* axis_view_from_stripable (boost::shared_ptr<ARDOUR::Stripable>) const;
 
        TrackViewList get_tracks_for_range_action () const;
 
@@ -1065,7 +1150,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        framepos_t cut_buffer_start;
        framecnt_t cut_buffer_length;
 
-       Gdk::Cursor* pre_press_cursor;
+       boost::shared_ptr<CursorContext> _press_cursor_ctx;  ///< Button press cursor context
+
        boost::weak_ptr<ARDOUR::Trimmable> _trimmable;
        boost::weak_ptr<ARDOUR::Movable> _movable;
 
@@ -1091,19 +1177,22 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void register_actions ();
        void register_region_actions ();
 
-        void load_bindings ();
-        Gtkmm2ext::ActionMap editor_action_map;
-        Gtkmm2ext::Bindings  key_bindings;
+       void load_bindings ();
+
+       /* CUT/COPY/PASTE */
+
+       framepos_t last_paste_pos;
+       unsigned   paste_count;
 
        void cut_copy (Editing::CutCopyOp);
        bool can_cut_copy () const;
-       void cut_copy_points (Editing::CutCopyOp);
+       void cut_copy_points (Editing::CutCopyOp, Evoral::Beats earliest=Evoral::Beats(), bool midi=false);
        void cut_copy_regions (Editing::CutCopyOp, RegionSelection&);
        void cut_copy_ranges (Editing::CutCopyOp);
        void cut_copy_midi (Editing::CutCopyOp);
 
        void mouse_paste ();
-       void paste_internal (framepos_t position, float times);
+       void paste_internal (framepos_t position, float times, const int32_t sub_num);
 
        /* EDITING OPERATIONS */
 
@@ -1129,9 +1218,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void change_region_layering_order (bool from_context_menu);
        void lower_region ();
        void lower_region_to_bottom ();
-       void split_regions_at (framepos_t, RegionSelection&);
        void split_region_at_transients ();
-       void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false);
        void crop_region_to_selection ();
        void crop_region_to (framepos_t start, framepos_t end);
        void set_sync_point (framepos_t, const RegionSelection&);
@@ -1154,7 +1241,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void region_fill_track ();
        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 strip_region_silence ();
@@ -1162,12 +1248,23 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void reset_region_scale_amplitude ();
        void adjust_region_gain (bool up);
        void quantize_region ();
+       void quantize_regions (const RegionSelection& rs);
+       void legatize_region (bool shrink_only);
+       void legatize_regions (const RegionSelection& rs, bool shrink_only);
+       void transform_region ();
+       void transform_regions (const RegionSelection& rs);
+       void transpose_region ();
+       void transpose_regions (const RegionSelection& rs);
        void insert_patch_change (bool from_context);
        void fork_region ();
 
        void do_insert_time ();
        void insert_time (framepos_t, framecnt_t, Editing::InsertTimeOption, bool, bool, bool, bool, bool, bool);
 
+       void do_remove_time ();
+       void remove_time (framepos_t pos, framecnt_t distance, Editing::InsertTimeOption opt, bool ignore_music_glue, bool markers_too,
+                       bool glued_markers_too, bool locked_markers_too, bool tempo_too);
+
        void tab_to_transient (bool forward);
 
        void set_tempo_from_region ();
@@ -1181,14 +1278,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void naturalize_region ();
 
-       void reset_focus ();
-
        void split_region ();
 
        void delete_ ();
        void cut ();
        void copy ();
-       void paste (float times, bool from_context_menu = false);
+       void paste (float times, bool from_context_menu);
 
        void place_transient ();
        void remove_transient (ArdourCanvas::Item* item);
@@ -1208,18 +1303,27 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void play_location (ARDOUR::Location&);
        void loop_location (ARDOUR::Location&);
 
-       void temporal_zoom_selection ();
+       void calc_extra_zoom_edges(framepos_t &start, framepos_t &end);
+       void temporal_zoom_selection (bool both_axes = false);
        void temporal_zoom_region (bool both_axes);
-       void zoom_to_region (bool both_axes);
        void temporal_zoom_session ();
        void temporal_zoom (framecnt_t samples_per_pixel);
        void temporal_zoom_by_frame (framepos_t start, framepos_t end);
        void temporal_zoom_to_frame (bool coarser, framepos_t frame);
 
-       void insert_region_list_drag (boost::shared_ptr<ARDOUR::Region>, int x, int y);
        void insert_region_list_selection (float times);
 
-       void insert_route_list_drag (boost::shared_ptr<ARDOUR::Route>, int x, int y);
+       /* PT import */
+       void external_pt_dialog ();
+       typedef struct ptflookup {
+               uint16_t index1;
+               uint16_t index2;
+               PBD::ID  id;
+
+               bool operator ==(const struct ptflookup& other) {
+                       return (this->index1 == other.index1);
+               }
+       } ptflookup_t;
 
        /* import & embed */
 
@@ -1237,24 +1341,52 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        bool  idle_drop_paths  (std::vector<std::string> paths, framepos_t frame, double ypos, bool copy);
        void  drop_paths_part_two  (const std::vector<std::string>& paths, framepos_t frame, double ypos, bool copy);
 
-        int  import_sndfiles (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode,  
-                             ARDOUR::SrcQuality, framepos_t& pos,
-                             int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool);
-       int  embed_sndfiles (std::vector<std::string> paths, bool multiple_files, bool& check_sample_rate, 
-                            Editing::ImportDisposition disposition, Editing::ImportMode mode,
-                            framepos_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&);
-
-       int add_sources (std::vector<std::string> paths, ARDOUR::SourceList& sources, framepos_t& pos, 
-                        Editing::ImportDisposition, Editing::ImportMode,
-                        int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool add_channel_suffix);
-
-       int finish_bringing_in_material (boost::shared_ptr<ARDOUR::Region> region, uint32_t, uint32_t,  framepos_t& pos, Editing::ImportMode mode,
-                                     boost::shared_ptr<ARDOUR::Track>& existing_track);
+       int import_sndfiles (std::vector<std::string>              paths,
+                            Editing::ImportDisposition            disposition,
+                            Editing::ImportMode                   mode,
+                            ARDOUR::SrcQuality                    quality,
+                            framepos_t&                           pos,
+                            int                                   target_regions,
+                            int                                   target_tracks,
+                            boost::shared_ptr<ARDOUR::Track>&     track,
+                            bool                                  replace,
+                            boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
+
+       int embed_sndfiles (std::vector<std::string>              paths,
+                           bool                                  multiple_files,
+                           bool&                                 check_sample_rate,
+                           Editing::ImportDisposition            disposition,
+                           Editing::ImportMode                   mode,
+                           framepos_t&                           pos,
+                           int                                   target_regions,
+                           int                                   target_tracks,
+                           boost::shared_ptr<ARDOUR::Track>&     track,
+                           boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
+
+       int add_sources (std::vector<std::string>              paths,
+                        ARDOUR::SourceList&                   sources,
+                        framepos_t&                           pos,
+                        Editing::ImportDisposition            disposition,
+                        Editing::ImportMode                   mode,
+                        int                                   target_regions,
+                        int                                   target_tracks,
+                        boost::shared_ptr<ARDOUR::Track>&     track,
+                        bool                                  add_channel_suffix,
+                        boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
+
+       int finish_bringing_in_material (boost::shared_ptr<ARDOUR::Region>     region,
+                                        uint32_t                              in_chans,
+                                        uint32_t                              out_chans,
+                                        framepos_t&                           pos,
+                                        Editing::ImportMode                   mode,
+                                        boost::shared_ptr<ARDOUR::Track>&     existing_track,
+                                        const std::string&                    new_track_name,
+                                        boost::shared_ptr<ARDOUR::PluginInfo> instrument);
 
        boost::shared_ptr<ARDOUR::AudioTrack> get_nth_selected_audio_track (int nth) const;
        boost::shared_ptr<ARDOUR::MidiTrack> get_nth_selected_midi_track (int nth) const;
 
-        void toggle_midi_input_active (bool flip_others);
+       void toggle_midi_input_active (bool flip_others);
 
        ARDOUR::InterThreadInfo* current_interthread_info;
 
@@ -1301,6 +1433,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void jump_forward_to_mark ();
        void jump_backward_to_mark ();
        void cursor_align (bool playhead_to_edit);
+       void toggle_skip_playback ();
 
        void remove_last_capture ();
        void select_all_selectables_using_time_selection ();
@@ -1318,15 +1451,21 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void set_loop_from_selection (bool play);
        void set_punch_from_selection ();
        void set_punch_from_region ();
+       void set_auto_punch_range();
+
+       void set_session_start_from_playhead ();
+       void set_session_end_from_playhead ();
+       void set_session_extents_from_selection ();
 
-       void set_loop_from_edit_range (bool play);
        void set_loop_from_region (bool play);
-       void set_punch_from_edit_range ();
 
        void set_loop_range (framepos_t start, framepos_t end, std::string cmd);
        void set_punch_range (framepos_t start, framepos_t end, std::string cmd);
 
+       void toggle_location_at_playhead_cursor ();
        void add_location_from_playhead_cursor ();
+       bool do_remove_location_at_playhead_cursor ();
+       void remove_location_at_playhead_cursor ();
        bool select_new_marker;
 
        void reverse_selection ();
@@ -1338,8 +1477,13 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        int scrub_reverse_distance;
        void scrub (framepos_t, double);
 
-       void keyboard_selection_begin ();
-       void keyboard_selection_finish (bool add);
+       void set_punch_start_from_edit_point ();
+       void set_punch_end_from_edit_point ();
+       void set_loop_start_from_edit_point ();
+       void set_loop_end_from_edit_point ();
+
+       void keyboard_selection_begin ( Editing::EditIgnoreOption = Editing::EDIT_IGNORE_NONE );
+       void keyboard_selection_finish (bool add, Editing::EditIgnoreOption = Editing::EDIT_IGNORE_NONE);
        bool have_pending_keyboard_selection;
        framepos_t pending_keyboard_selection_start;
 
@@ -1356,6 +1500,14 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        DragManager* _drags;
 
        void escape ();
+       void lock ();
+       void unlock ();
+       Gtk::Dialog* lock_dialog;
+
+       struct timeval last_event_time;
+       bool generic_event_handler (GdkEvent*);
+       bool lock_timeout_callback ();
+       void start_lock_event_timing ();
 
        Gtk::Menu fade_context_menu;
 
@@ -1372,6 +1524,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void set_fade_in_active (bool);
        void set_fade_out_active (bool);
 
+       void fade_range ();
+
        std::set<boost::shared_ptr<ARDOUR::Playlist> > motion_frozen_playlists;
 
        bool _dragging_playhead;
@@ -1397,6 +1551,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        /* Canvas event handlers */
 
+       bool canvas_scroll_event (GdkEventScroll* event, bool from_canvas);
        bool canvas_control_point_event (GdkEvent* event,ArdourCanvas::Item*, ControlPoint*);
        bool canvas_line_event (GdkEvent* event,ArdourCanvas::Item*, AutomationLine*);
        bool canvas_selection_rect_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
@@ -1409,18 +1564,20 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        bool canvas_fade_out_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
        bool canvas_fade_out_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*, bool trim = false);
        bool canvas_region_view_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
+       bool canvas_wave_view_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
        bool canvas_frame_handle_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
        bool canvas_region_view_name_highlight_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
        bool canvas_region_view_name_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
        bool canvas_feature_line_event (GdkEvent* event, ArdourCanvas::Item*, RegionView*);
        bool canvas_stream_view_event (GdkEvent* event,ArdourCanvas::Item*, RouteTimeAxisView*);
-       bool canvas_marker_event (GdkEvent* event,ArdourCanvas::Item*, Marker*);
-       bool canvas_zoom_rect_event (GdkEvent* event,ArdourCanvas::Item*);
+       bool canvas_marker_event (GdkEvent* event,ArdourCanvas::Item*, ArdourMarker*);
        bool canvas_tempo_marker_event (GdkEvent* event,ArdourCanvas::Item*, TempoMarker*);
+       bool canvas_tempo_curve_event (GdkEvent* event,ArdourCanvas::Item*, TempoCurve*);
        bool canvas_meter_marker_event (GdkEvent* event,ArdourCanvas::Item*, MeterMarker*);
        bool canvas_automation_track_event(GdkEvent* event, ArdourCanvas::Item*, AutomationTimeAxisView*);
        bool canvas_note_event (GdkEvent* event, ArdourCanvas::Item *);
 
+       bool canvas_ruler_event (GdkEvent* event, ArdourCanvas::Item *, ItemType);
        bool canvas_tempo_bar_event (GdkEvent* event, ArdourCanvas::Item*);
        bool canvas_meter_bar_event (GdkEvent* event, ArdourCanvas::Item*);
        bool canvas_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
@@ -1445,15 +1602,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        friend class EditorRouteGroups;
        friend class EditorRegions;
 
-       /** true if the mouse is over a place where region trim can happen */
-       bool _over_region_trim_target;
-
        /* non-public event handlers */
 
        bool canvas_playhead_cursor_event (GdkEvent* event, ArdourCanvas::Item*);
        bool track_canvas_scroll (GdkEventScroll* event);
 
-       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);
@@ -1471,6 +1624,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void initialize_canvas ();
 
+       void set_script_action_name (int i, const std::string&);
+
        /* display control */
 
        bool _show_measures;
@@ -1483,34 +1638,31 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        TempoLines* tempo_lines;
 
-       ArdourCanvas::Group* global_rect_group;
-       ArdourCanvas::Group* time_line_group;
+       ArdourCanvas::Container* global_rect_group;
+       ArdourCanvas::Container* time_line_group;
 
        void hide_measures ();
-        void draw_measures (ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
-                           ARDOUR::TempoMap::BBTPointList::const_iterator& end);
+       void draw_measures (std::vector<ARDOUR::TempoMap::BBTPoint>&);
 
        void new_tempo_section ();
 
-       void mouse_add_new_tempo_event (framepos_t where);
-       void mouse_add_new_meter_event (framepos_t where);
 
        void remove_tempo_marker (ArdourCanvas::Item*);
        void remove_meter_marker (ArdourCanvas::Item*);
        gint real_remove_tempo_marker (ARDOUR::TempoSection*);
        gint real_remove_meter_marker (ARDOUR::MeterSection*);
 
-       void edit_tempo_section (ARDOUR::TempoSection*);
-       void edit_meter_section (ARDOUR::MeterSection*);
        void edit_tempo_marker (TempoMarker&);
        void edit_meter_marker (MeterMarker&);
        void edit_control_point (ArdourCanvas::Item*);
-        void edit_notes (TimeAxisViewItem&);
+       void edit_notes (MidiRegionView*);
 
        void marker_menu_edit ();
        void marker_menu_remove ();
        void marker_menu_rename ();
-       void rename_marker (Marker *marker);
+       void rename_marker (ArdourMarker *marker);
+       void toggle_marker_lock_style ();
+       void toggle_tempo_type ();
        void toggle_marker_menu_lock ();
        void toggle_marker_menu_glue ();
        void marker_menu_hide ();
@@ -1535,11 +1687,13 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
        void build_range_marker_menu (bool, bool);
        void build_marker_menu (ARDOUR::Location *);
-       void build_tempo_or_meter_marker_menu (bool);
+       void build_tempo_marker_menu (TempoMarker *, bool);
+       void build_meter_marker_menu (MeterMarker *, bool);
        void build_new_transport_marker_menu ();
        void dynamic_cast_marker_object (void*, MeterMarker**, TempoMarker**) const;
 
-       Gtk::Menu* tempo_or_meter_marker_menu;
+       Gtk::Menu* tempo_marker_menu;
+       Gtk::Menu* meter_marker_menu;
        Gtk::Menu* marker_menu;
        Gtk::Menu* range_marker_menu;
        Gtk::Menu* transport_marker_menu;
@@ -1547,17 +1701,19 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::Menu* cd_marker_menu;
        ArdourCanvas::Item* marker_menu_item;
 
-       typedef std::list<Marker*> Marks;
+       typedef std::list<ArdourMarker*> Marks;
        Marks metric_marks;
 
+       typedef std::list<TempoCurve*> Curves;
+       Curves tempo_curves;
+
        void remove_metric_marks ();
        void draw_metric_marks (const ARDOUR::Metrics& metrics);
 
-        void compute_current_bbt_points (framepos_t left, framepos_t right, 
-                                        ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
-                                        ARDOUR::TempoMap::BBTPointList::const_iterator& end);
+       void compute_current_bbt_points (std::vector<ARDOUR::TempoMap::BBTPoint>& grid, framepos_t left, framepos_t right);
 
        void tempo_map_changed (const PBD::PropertyChange&);
+       void marker_position_changed ();
        void redisplay_tempo (bool immediate_redraw);
 
        uint32_t bbt_beat_subdivision;
@@ -1569,8 +1725,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void editor_mixer_button_toggled ();
        void editor_list_button_toggled ();
 
-       AudioClock*               zoom_range_clock;
-
        ArdourButton              zoom_in_button;
        ArdourButton              zoom_out_button;
        ArdourButton              zoom_out_full_button;
@@ -1578,24 +1732,26 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        ArdourButton              tav_expand_button;
        ArdourButton              tav_shrink_button;
        ArdourDropdown            visible_tracks_selector;
+       ArdourDropdown            zoom_preset_selector;
 
-    int32_t                   _visible_track_count;
-    void build_track_count_menu ();
-    void set_visible_track_count (int32_t);
+       int32_t                   _visible_track_count;
+       void build_track_count_menu ();
+       void set_visible_track_count (int32_t);
+
+       void set_zoom_preset(int64_t);
 
        Gtk::VBox                toolbar_clock_vbox;
        Gtk::VBox                toolbar_selection_clock_vbox;
        Gtk::Table               toolbar_selection_clock_table;
        Gtk::Label               toolbar_selection_cursor_label;
 
-       Gtkmm2ext::TearOff*      _mouse_mode_tearoff;
        ArdourButton mouse_select_button;
        ArdourButton mouse_draw_button;
        ArdourButton mouse_move_button;
-       ArdourButton mouse_gain_button;
-       ArdourButton mouse_zoom_button;
        ArdourButton mouse_timefx_button;
+       ArdourButton mouse_content_button;
        ArdourButton mouse_audition_button;
+       ArdourButton mouse_cut_button;
 
        ArdourButton smart_mode_button;
        Glib::RefPtr<Gtk::ToggleAction> smart_mode_action;
@@ -1604,9 +1760,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void                     mouse_mode_object_range_toggled ();
        bool                     ignore_mouse_mode_toggle;
 
-       ArdourButton internal_edit_button;
-       void         toggle_internal_editing ();
-
        bool                     mouse_select_button_release (GdkEventButton*);
 
        Gtk::VBox                automation_box;
@@ -1617,7 +1770,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void edit_mode_selection_done ( ARDOUR::EditMode m );
        void build_edit_mode_menu ();
        Gtk::VBox         edit_mode_box;
-       std::vector<std::string> edit_mode_strings;
 
        void set_edit_mode (ARDOUR::EditMode);
        void cycle_edit_mode ();
@@ -1651,32 +1803,27 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Glib::RefPtr<Gtk::RadioAction> zoom_focus_action (Editing::ZoomFocus);
 
        Gtk::HBox           _zoom_box;
-       Gtkmm2ext::TearOff* _zoom_tearoff;
        void                zoom_adjustment_changed();
 
        void setup_toolbar ();
 
        void setup_tooltips ();
 
-       Gtkmm2ext::TearOff*     _tools_tearoff;
        Gtk::HBox                toolbar_hbox;
        Gtk::EventBox            toolbar_base;
        Gtk::Frame               toolbar_frame;
        Gtk::Viewport           _toolbar_viewport;
 
-       /* midi toolbar */
-
-       Gtk::HBox                panic_box;
-
        void setup_midi_toolbar ();
 
        /* selection process */
 
        Selection* selection;
        Selection* cut_buffer;
+       SelectionMemento* _selection_memento;
 
        void time_selection_changed ();
-        void update_time_selection_display ();
+       void update_time_selection_display ();
        void track_selection_changed ();
        void region_selection_changed ();
        sigc::connection editor_regions_selection_changed_connection;
@@ -1692,6 +1839,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void point_selection_changed ();
        void marker_selection_changed ();
 
+       bool _ignore_follow_edits;
+
        void cancel_selection ();
        void cancel_time_selection ();
 
@@ -1704,10 +1853,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        ArdourCanvas::Rectangle*  cd_marker_bar_drag_rect;
        ArdourCanvas::Rectangle*  range_bar_drag_rect;
        ArdourCanvas::Rectangle*  transport_bar_drag_rect;
-
-#ifdef GTKOSX
-       ArdourCanvas::Rectangle     *bogus_background_rect;
-#endif
        ArdourCanvas::Rectangle     *transport_bar_range_rect;
        ArdourCanvas::Rectangle     *transport_bar_preroll_rect;
        ArdourCanvas::Rectangle     *transport_bar_postroll_rect;
@@ -1729,11 +1874,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        ArdourCanvas::Rectangle   *rubberband_rect;
 
-       /* mouse zoom process */
-
-       ArdourCanvas::Rectangle   *zoom_rect;
-       void reposition_zoom_rect (framepos_t start, framepos_t end);
-
        EditorRouteGroups* _route_groups;
        EditorRoutes* _routes;
        EditorRegions* _regions;
@@ -1752,15 +1892,15 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        /* autoscrolling */
 
-        sigc::connection autoscroll_connection;
-        bool autoscroll_horizontal_allowed;
-        bool autoscroll_vertical_allowed;
-        uint32_t autoscroll_cnt;
-        Gtk::Widget* autoscroll_widget;
-        ArdourCanvas::Rect autoscroll_boundary;
+       sigc::connection autoscroll_connection;
+       bool autoscroll_horizontal_allowed;
+       bool autoscroll_vertical_allowed;
+       uint32_t autoscroll_cnt;
+       Gtk::Widget* autoscroll_widget;
+       ArdourCanvas::Rect autoscroll_boundary;
 
        bool autoscroll_canvas ();
-        void start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect& boundary);
+       void start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect& boundary);
        void stop_canvas_autoscroll ();
 
        /* trimming */
@@ -1783,45 +1923,45 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        /* Drag-n-Drop */
 
        int convert_drop_to_paths (
-                std::vector<std::string>&           paths,
-                const Glib::RefPtr<Gdk::DragContext>& context,
-                gint                                  x,
-                gint                                  y,
-                const Gtk::SelectionData&             data,
-                guint                                 info,
-                guint                                 time);
+               std::vector<std::string>&           paths,
+               const Glib::RefPtr<Gdk::DragContext>& context,
+               gint                                  x,
+               gint                                  y,
+               const Gtk::SelectionData&             data,
+               guint                                 info,
+               guint                                 time);
 
        void track_canvas_drag_data_received (
-                const Glib::RefPtr<Gdk::DragContext>& context,
-                gint                                  x,
-                gint                                  y,
-                const Gtk::SelectionData&             data,
-                guint                                 info,
-                guint                                 time);
+               const Glib::RefPtr<Gdk::DragContext>& context,
+               gint                                  x,
+               gint                                  y,
+               const Gtk::SelectionData&             data,
+               guint                                 info,
+               guint                                 time);
 
        void drop_paths (
-                const Glib::RefPtr<Gdk::DragContext>& context,
-                gint                                  x,
-                gint                                  y,
-                const Gtk::SelectionData&             data,
-                guint                                 info,
-                guint                                 time);
+               const Glib::RefPtr<Gdk::DragContext>& context,
+               gint                                  x,
+               gint                                  y,
+               const Gtk::SelectionData&             data,
+               guint                                 info,
+               guint                                 time);
 
        void drop_regions (
-                const Glib::RefPtr<Gdk::DragContext>& context,
-                gint                                  x,
-                gint                                  y,
-                const Gtk::SelectionData&             data,
-                guint                                 info,
-                guint                                 time);
+               const Glib::RefPtr<Gdk::DragContext>& context,
+               gint                                  x,
+               gint                                  y,
+               const Gtk::SelectionData&             data,
+               guint                                 info,
+               guint                                 time);
 
        void drop_routes (
-                const Glib::RefPtr<Gdk::DragContext>& context,
-                gint                x,
-                gint                y,
-                const Gtk::SelectionData& data,
-                guint               info,
-                guint               time);
+               const Glib::RefPtr<Gdk::DragContext>& context,
+               gint                x,
+               gint                y,
+               const Gtk::SelectionData& data,
+               guint               info,
+               guint               time);
 
        /* audio export */
 
@@ -1836,12 +1976,17 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void write_selection ();
 
-       XMLNode *before; /* used in *_reversible_command */
+       uint32_t selection_op_cmd_depth;
+       uint32_t selection_op_history_it;
+
+       std::list<XMLNode *> selection_op_history; /* used in *_reversible_selection_op */
+       std::list<XMLNode *> before; /* used in *_reversible_command */
 
        void update_title ();
        void update_title_s (const std::string & snapshot_name);
 
        void instant_save ();
+       bool no_save_instant;
 
        boost::shared_ptr<ARDOUR::AudioRegion> last_audition_region;
 
@@ -1857,13 +2002,14 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        /* duplication */
 
        void duplicate_range (bool with_dialog);
+       void duplicate_regions (float times);
 
-        /** computes the timeline frame (sample) of an event whose coordinates
+       /** computes the timeline frame (sample) of an event whose coordinates
         * are in canvas units (pixels, scroll offset included).
         */
        framepos_t canvas_event_sample (GdkEvent const *, double* px = 0, double* py = 0) const;
 
-        /** computes the timeline frame (sample) of an event whose coordinates
+       /** computes the timeline frame (sample) of an event whose coordinates
         * are in window units (pixels, no scroll offset).
         */
        framepos_t window_event_sample (GdkEvent const *, double* px = 0, double* py = 0) const;
@@ -1880,8 +2026,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        int pitch_shift (RegionSelection&, float cents);
        void pitch_shift_region ();
 
-       void transpose_region ();
-
        /* editor-mixer strip */
 
        MixerStrip *current_mixer_strip;
@@ -1890,9 +2034,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void cms_new (boost::shared_ptr<ARDOUR::Route>);
        void current_mixer_strip_hidden ();
 
-       void detach_tearoff (Gtk::Box* b, Gtk::Window* w);
-       void reattach_tearoff (Gtk::Box* b, Gtk::Window* w, int32_t n);
-#ifdef GTKOSX
+#ifdef __APPLE__
        void ensure_all_elements_drawn ();
 #endif
        /* nudging tracks */
@@ -1918,7 +2060,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void apply_filter (ARDOUR::Filter&, std::string cmd, ProgressReporter* progress = 0);
 
        Command* apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, MidiRegionView& mrv);
-       void apply_midi_note_edit_op (ARDOUR::MidiOperator& op);
+       void apply_midi_note_edit_op (ARDOUR::MidiOperator& op, const RegionSelection& rs);
 
        /* handling cleanup */
 
@@ -1939,12 +2081,13 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        */
        RegionView*   entered_regionview;
 
+       std::vector<EnterContext> _enter_stack;
+
        bool clear_entered_track;
        bool left_track_canvas (GdkEventCrossing*);
        bool entered_track_canvas (GdkEventCrossing*);
        void set_entered_track (TimeAxisView*);
        void set_entered_regionview (RegionView*);
-       void ensure_track_visible (TimeAxisView*);
        gint left_automation_track ();
 
        void reset_canvas_action_sensitivity (bool);
@@ -1953,18 +2096,17 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void toggle_gain_envelope_active ();
        void reset_region_gain_envelopes ();
 
-       bool on_key_press_event (GdkEventKey*);
-       bool on_key_release_event (GdkEventKey*);
-
        void session_state_saved (std::string);
 
        Glib::RefPtr<Gtk::Action>              undo_action;
        Glib::RefPtr<Gtk::Action>              redo_action;
+       Glib::RefPtr<Gtk::Action>              alternate_redo_action;
+       Glib::RefPtr<Gtk::Action>              alternate_alternate_redo_action;
+       Glib::RefPtr<Gtk::Action>              selection_undo_action;
+       Glib::RefPtr<Gtk::Action>              selection_redo_action;
 
        void history_changed ();
 
-       Gtk::HBox      status_bar_hpacker;
-
        Editing::EditPoint _edit_point;
 
        ArdourDropdown edit_point_selector;
@@ -1977,6 +2119,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void edit_point_chosen (Editing::EditPoint);
        Glib::RefPtr<Gtk::RadioAction> edit_point_action (Editing::EditPoint);
        std::vector<std::string> edit_point_strings;
+       std::vector<std::string> edit_mode_strings;
 
        void selected_marker_moved (ARDOUR::Location*);
 
@@ -1986,7 +2129,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void get_regions_after (RegionSelection&, framepos_t where, const TrackViewList& ts) const;
 
        RegionSelection get_regions_from_selection_and_edit_point ();
-       RegionSelection get_regions_from_selection_and_entered ();
+       RegionSelection get_regions_from_selection_and_entered () const;
 
        void start_updating_meters ();
        void stop_updating_meters ();
@@ -1995,16 +2138,23 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void select_next_route ();
        void select_prev_route ();
 
-       void snap_to_internal (framepos_t& first, int32_t direction = 0, bool for_mark = false);
-       void timecode_snap_to_internal (framepos_t& first, int32_t direction = 0, bool for_mark = false);
+       void snap_to_internal (framepos_t&       first,
+                              ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
+                              bool              for_mark  = false,
+                              bool              ensure_snap = false);
+
+       void timecode_snap_to_internal (framepos_t&       first,
+                                       ARDOUR::RoundMode direction = ARDOUR::RoundNearest,
+                                       bool              for_mark  = false);
 
        RhythmFerret* rhythm_ferret;
 
        void fit_tracks (TrackViewList &);
-       void fit_selected_tracks ();
+       void fit_selection ();
        void set_track_height (Height);
 
-       void remove_tracks ();
+       void _remove_tracks ();
+       bool idle_remove_tracks ();
        void toggle_tracks_active ();
 
        bool _have_idled;
@@ -2066,15 +2216,13 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::MenuItem& action_menu_item (std::string const &);
        void action_pre_activated (Glib::RefPtr<Gtk::Action> const &);
 
-       void set_canvas_cursor_for_region_view (double, RegionView *);
-
        MouseCursors* _cursors;
 
        void follow_mixer_selection ();
        bool _following_mixer_selection;
 
        int time_fx (ARDOUR::RegionList&, float val, bool pitching);
-        void note_edit_done (int, EditNoteDialog*);
+       void note_edit_done (int, EditNoteDialog*);
        void toggle_sound_midi_notes ();
 
        /** Flag for a bit of a hack wrt control point selection; see set_selected_control_point_from_click */
@@ -2092,11 +2240,29 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        TimeAxisView* _stepping_axis_view;
        void zoom_vertical_modifier_released();
 
+       void bring_in_callback (Gtk::Label*, uint32_t n, uint32_t total, std::string name);
+       void update_bring_in_message (Gtk::Label* label, uint32_t n, uint32_t total, std::string name);
+       void bring_all_sources_into_session ();
+
+       QuantizeDialog* quantize_dialog;
+       MainMenuDisabler* _main_menu_disabler;
+
+       /* private helper functions to help with registering axis */
+
+       Glib::RefPtr<Gtk::Action> reg_sens (Glib::RefPtr<Gtk::ActionGroup> group, char const * name, char const * label, sigc::slot<void> slot);
+       void toggle_reg_sens (Glib::RefPtr<Gtk::ActionGroup> group, char const * name, char const * label, sigc::slot<void> slot);
+       void radio_reg_sens (Glib::RefPtr<Gtk::ActionGroup> action_group, Gtk::RadioAction::Group& radio_group, char const * name, char const * label, sigc::slot<void> slot);
+
+       Gtkmm2ext::ActionMap myactions;
+
        friend class Drag;
+       friend class RegionCutDrag;
        friend class RegionDrag;
        friend class RegionMoveDrag;
        friend class RegionSpliceDrag;
+       friend class RegionRippleDrag;
        friend class TrimDrag;
+       friend class BBTRulerDrag;
        friend class MeterMarkerDrag;
        friend class TempoMarkerDrag;
        friend class CursorDrag;
@@ -2107,6 +2273,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        friend class ControlPointDrag;
        friend class LineDrag;
        friend class RubberbandSelectDrag;
+       friend class RulerZoomDrag;
        friend class EditorRubberbandSelectDrag;
        friend class TimeFXDrag;
        friend class ScrubDrag;