rationalize destruction pathway (some more); tidy-ify some ImageFrame code
[ardour.git] / gtk2_ardour / editor.h
index 729211ed9d351948bc3cef8c52dbf330dde520c8..ca1082af787791e2ed601ff051c2c58500cb59fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000-2003 Paul Davis 
+    Copyright (C) 2000-2003 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -46,7 +46,9 @@
 #include <gtkmm2ext/dndtreeview.h>
 
 #include "pbd/stateful.h"
-#include "ardour/session.h"
+#include "pbd/signals.h"
+
+#include "ardour/import_status.h"
 #include "ardour/tempo.h"
 #include "ardour/location.h"
 #include "ardour/audioregion.h"
 #include "canvas.h"
 #include "editor_summary.h"
 
+namespace Gnome { namespace Canvas {
+       class NoEventText;
+} }
+
 namespace Gtkmm2ext {
        class TearOff;
 }
@@ -82,6 +88,9 @@ namespace ARDOUR {
        class Filter;
        class Crossfade;
        class ChanCount;
+       class MidiOperator;
+       class MidiTrack;
+       class AudioTrack;
 }
 
 namespace LADSPA {
@@ -102,6 +111,7 @@ class Drag;
 class GlobalPortMatrixWindow;
 class GroupedButtons;
 class Marker;
+class MidiRegionView;
 class MixerStrip;
 class PlaylistSelector;
 class PluginSelector;
@@ -113,11 +123,11 @@ class TempoLines;
 class TimeAxisView;
 class TimeFXDialog;
 class TimeSelection;
-class TrackSelection;
 class EditorGroupTabs;
 class EditorRoutes;
 class EditorRouteGroups;
 class EditorRegions;
+class EditorLocations;
 class EditorSnapshots;
 
 /* <CMT Additions> */
@@ -136,25 +146,26 @@ struct EditorCursor {
        ArdourCanvas::Line    canvas_item;
        nframes64_t           current_frame;
        double            length;
-       
+
        EditorCursor (Editor&, bool (Editor::*)(GdkEvent*,ArdourCanvas::Item*));
        ~EditorCursor ();
-       
+
        void set_position (nframes64_t);
        void set_length (double units);
        void set_y_axis (double position);
 
-       sigc::signal<void, nframes64_t> PositionChanged;
+        PBD::Signal1<void, nframes64_t> PositionChanged;
 };
 
-class Editor : public PublicEditor
+class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr
 {
   public:
        Editor ();
        ~Editor ();
-       
-       void             connect_to_session (ARDOUR::Session *);
-       ARDOUR::Session* current_session() const { return session; }
+
+       void             set_session (ARDOUR::Session *);
+       ARDOUR::Session* session() const { return _session; }
+
        void             first_idle ();
        virtual bool     have_idled () const { return _have_idled; }
 
@@ -163,7 +174,7 @@ class Editor : public PublicEditor
        nframes64_t current_page_frames() const {
                return (nframes64_t) floor (_canvas_width * frames_per_unit);
        }
-       
+
        double canvas_height () const {
                return _canvas_height;
        }
@@ -174,11 +185,14 @@ class Editor : public PublicEditor
        void set_snap_mode (Editing::SnapMode);
        void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;}
 
+       Editing::SnapMode  snap_mode () const;
+       Editing::SnapType  snap_type () const;
+
        void undo (uint32_t n = 1);
        void redo (uint32_t n = 1);
 
        XMLNode& get_state ();
-       int set_state (const XMLNode& );
+       int set_state (const XMLNode&, int version);
 
        void set_mouse_mode (Editing::MouseMode, bool force=true);
        void step_mouse_mode (bool next);
@@ -193,9 +207,9 @@ class Editor : public PublicEditor
        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) ;
-#endif
-
        TimeAxisView* get_named_time_axis(const std::string & name) ;
+#endif /* WITH_CMT */
+
        void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>);
        void add_to_idle_resize (TimeAxisView*, int32_t);
 
@@ -213,7 +227,7 @@ class Editor : public PublicEditor
 
        void set_show_waveforms_recording (bool yn);
        bool show_waveforms_recording() const { return _show_waveforms_recording; }
-       
+
        /* things that need to be public to be used in the main menubar */
 
        void new_region_from_selection ();
@@ -222,7 +236,6 @@ class Editor : public PublicEditor
        void separate_region_from_punch ();
        void separate_region_from_loop ();
        void separate_regions_using_location (ARDOUR::Location&);
-       void toggle_playback (bool with_abort);
        void transition_to_rolling (bool forward);
 
        /* undo related */
@@ -230,7 +243,7 @@ class Editor : public PublicEditor
        nframes64_t unit_to_frame (double unit) const {
                return (nframes64_t) rint (unit * frames_per_unit);
        }
-       
+
        double frame_to_unit (nframes64_t frame) const {
                return rint ((double) frame / (double) frames_per_unit);
        }
@@ -243,11 +256,11 @@ class Editor : public PublicEditor
           the result of using the world->canvas affine transform on a
           world coordinate. These coordinates already take into
           account any scrolling carried out by adjusting the
-          xscroll_adjustment.  
+          xscroll_adjustment.
        */
 
        nframes64_t pixel_to_frame (double pixel) const {
-               
+
                /* pixel can be less than zero when motion events
                   are processed. since we've already run the world->canvas
                   affine, that means that the location *really* is "off
@@ -280,7 +293,7 @@ class Editor : public PublicEditor
        void invert_selection_in_track ();
        void invert_selection ();
        void deselect_all ();
-       
+
        void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
 
        /* tempo */
@@ -294,7 +307,7 @@ class Editor : public PublicEditor
        void analyze_range_selection();
 
        /* export */
-       
+
        void export_audio ();
        void export_selection ();
        void export_range ();
@@ -308,6 +321,7 @@ class Editor : public PublicEditor
        double             get_current_zoom () const { return frames_per_unit; }
 
        void temporal_zoom_step (bool coarser);
+       void tav_zoom_step (bool coarser);
 
        /* stuff that AudioTimeAxisView and related classes use */
 
@@ -318,7 +332,6 @@ class Editor : public PublicEditor
        void copy_playlists (TimeAxisView* v);
        void clear_playlists (TimeAxisView* v);
 
-       TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0);
        void get_onscreen_tracks (TrackViewList&);
 
        Width editor_mixer_strip_width;
@@ -332,6 +345,7 @@ class Editor : public PublicEditor
        /* nudge is initiated by transport controls owned by ARDOUR_UI */
 
        nframes64_t get_nudge_distance (nframes64_t pos, nframes64_t& next);
+       Evoral::MusicalTime get_grid_type_as_beats (bool& success, nframes64_t position);
 
        void nudge_forward (bool next, bool force_playhead);
        void nudge_backward (bool next, bool force_playhead);
@@ -342,7 +356,7 @@ class Editor : public PublicEditor
        void nudge_backward_capture_offset ();
 
        /* playhead/screen stuff */
-       
+
        void set_follow_playhead (bool yn);
        void toggle_follow_playhead ();
        bool follow_playhead() const { return _follow_playhead; }
@@ -399,7 +413,6 @@ class Editor : public PublicEditor
        void toggle_meter_updating();
 
        void show_rhythm_ferret();
-       void show_bundle_manager ();
        void show_global_port_matrix (ARDOUR::DataType);
 
        void goto_visual_state (uint32_t);
@@ -415,7 +428,14 @@ class Editor : public PublicEditor
        void do_embed (std::vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode,  nframes64_t&);
 
        void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions);
-       
+
+       void show_verbose_canvas_cursor_with (const std::string& txt);
+       void hide_verbose_canvas_cursor();
+
+       void center_screen (nframes64_t);
+
+       TrackViewList axis_views_from_routes (boost::shared_ptr<ARDOUR::RouteList>) const;
+
   protected:
        void map_transport_state ();
        void map_position_change (nframes64_t);
@@ -425,13 +445,12 @@ class Editor : public PublicEditor
   private:
 
        void color_handler ();
-       
-       ARDOUR::Session     *session; ///< The session that we are editing, or 0
+
        bool                 constructed;
 
        // to keep track of the playhead position for control_scroll
        boost::optional<nframes64_t> _control_scroll_target;
+
        PlaylistSelector* _playlist_selector;
 
        typedef std::pair<TimeAxisView*,XMLNode*> TAVState;
@@ -441,10 +460,9 @@ class Editor : public PublicEditor
            double              frames_per_unit;
            nframes64_t         leftmost_frame;
            Editing::ZoomFocus  zoom_focus;
-           bool                zoomed_to_region;
            std::list<TAVState> track_states;
        };
-       
+
        std::list<VisualState*> undo_visual_stack;
        std::list<VisualState*> redo_visual_stack;
        VisualState* current_visual_state (bool with_tracks = true);
@@ -453,7 +471,7 @@ class Editor : public PublicEditor
        void use_visual_state (VisualState&);
        bool no_save_visual;
        void swap_visual_state ();
-       
+
        std::vector<VisualState*> visual_states;
        sigc::connection visual_state_op_connection;
        void start_visual_state_op (uint32_t n);
@@ -469,7 +487,7 @@ class Editor : public PublicEditor
 
        Editing::MouseMode mouse_mode;
        bool _internal_editing;
-       
+
        int  post_maximal_editor_width;
        int  post_maximal_pane_position;
        int  pre_maximal_pane_position;
@@ -508,7 +526,7 @@ class Editor : public PublicEditor
            bool    valid;
 
            LocationMarkers () : start(0), end(0), valid (true) {}
-           
+
            ~LocationMarkers ();
 
            void hide();
@@ -544,10 +562,8 @@ class Editor : public PublicEditor
        CrossfadeView*     clicked_crossfadeview;
        ControlPoint*      clicked_control_point;
 
-       void sort_track_selection (TrackSelection* sel = 0);
+       void sort_track_selection (TrackViewList* sel = 0);
 
-       void get_relevant_tracks (std::set<RouteTimeAxisView*>& relevant_tracks) const;
-       void get_equivalent_tracks (RouteTimeAxisView*, std::set<RouteTimeAxisView*> &, ARDOUR::RouteGroup::Property) const;
        void get_equivalent_regions (RegionView* rv, std::vector<RegionView*> &, ARDOUR::RouteGroup::Property) const;
        RegionSelection get_equivalent_regions (RegionSelection &, ARDOUR::RouteGroup::Property) const;
        void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*, ARDOUR::RouteGroup::Property) const;
@@ -568,7 +584,7 @@ class Editor : public PublicEditor
 
        void 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);
        void set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool no_remove=false);
        void set_selected_track_as_side_effect (bool force = false);
@@ -577,7 +593,7 @@ class Editor : public PublicEditor
        bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::weak_ptr<ARDOUR::Region>);
        void collect_new_region_view (RegionView *);
        void collect_and_select_new_region_view (RegionView *);
-       
+
        Gtk::Menu track_context_menu;
        Gtk::Menu track_region_context_menu;
        Gtk::Menu track_selection_context_menu;
@@ -602,8 +618,7 @@ class Editor : public PublicEditor
        void add_selection_context_items (Gtk::Menu_Helpers::MenuList&);
 
        void handle_new_route (ARDOUR::RouteList&);
-       void remove_route (TimeAxisView *);
-       bool route_removal;
+       void timeaxisview_deleted (TimeAxisView *);
 
        Gtk::HBox           global_hpacker;
        Gtk::VBox           global_vpacker;
@@ -615,17 +630,16 @@ class Editor : public PublicEditor
 
        ArdourCanvas::Canvas* track_canvas;
 
-       ArdourCanvas::Text* verbose_canvas_cursor;
+       ArdourCanvas::NoEventText* verbose_canvas_cursor;
        bool                 verbose_cursor_visible;
 
        void parameter_changed (std::string);
-       
+
        bool track_canvas_motion (GdkEvent*);
 
        void set_verbose_canvas_cursor (const std::string &, double x, double y);
        void set_verbose_canvas_cursor_text (const std::string &);
        void show_verbose_canvas_cursor();
-       void hide_verbose_canvas_cursor();
 
        bool verbose_cursor_on; // so far unused
 
@@ -637,7 +651,7 @@ class Editor : public PublicEditor
        ArdourCanvas::Group      *minsec_group;
        ArdourCanvas::Pixbuf     *logo_item;
        ArdourCanvas::Group      *bbt_group;
-       ArdourCanvas::Group      *smpte_group;
+       ArdourCanvas::Group      *timecode_group;
        ArdourCanvas::Group      *frame_group;
        ArdourCanvas::Group      *tempo_group;
        ArdourCanvas::Group      *meter_group;
@@ -658,22 +672,22 @@ class Editor : public PublicEditor
 
        /** The group containing all items that require horizontal scrolling. */
        ArdourCanvas::Group* _background_group;
-       /* 
+       /*
           The _master_group is the group containing all items
           that require horizontal scrolling..
-          It is primarily used to separate canvas items 
-          that require horizontal scrolling from those that do not. 
+          It is primarily used to separate canvas items
+          that require horizontal scrolling from those that do not.
        */
        ArdourCanvas::Group* _master_group;
 
        /* The group containing all trackviews.  Only scrolled vertically. */
        ArdourCanvas::Group* _trackview_group;
-       
+
        /* The group used for region motion.  Sits on top of _trackview_group */
        ArdourCanvas::Group* _region_motion_group;
-       
+
        enum RulerType {
-               ruler_metric_smpte = 0,
+               ruler_metric_timecode = 0,
                ruler_metric_bbt = 1,
                ruler_metric_frames = 2,
                ruler_metric_minsec = 3,
@@ -698,19 +712,19 @@ class Editor : public PublicEditor
        Glib::RefPtr<Gtk::ToggleAction> ruler_loop_punch_action;
        Glib::RefPtr<Gtk::ToggleAction> ruler_cd_marker_action;
        bool                            no_ruler_shown_update;
-       
+
        gint ruler_button_press (GdkEventButton*);
        gint ruler_button_release (GdkEventButton*);
        gint ruler_mouse_motion (GdkEventMotion*);
        bool ruler_scroll (GdkEventScroll* event);
 
        Gtk::Widget * ruler_grabbed_widget;
-       
+
        void initialize_rulers ();
-       void update_just_smpte ();
+       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 (); 
+       void update_tempo_based_rulers ();
        void popup_ruler_menu (nframes64_t where = 0, ItemType type = RegionItem);
        void update_ruler_visibility ();
        void set_ruler_visible (RulerType, bool);
@@ -719,12 +733,12 @@ class Editor : public PublicEditor
        gint ruler_label_button_release (GdkEventButton*);
        void store_ruler_visibility ();
        void restore_ruler_visibility ();
-       
-       static gint _metric_get_smpte (GtkCustomRulerMark **, gdouble, gdouble, gint);
+
+       static gint _metric_get_timecode (GtkCustomRulerMark **, gdouble, gdouble, gint);
        static gint _metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
        static gint _metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
        static gint _metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
-       
+
        enum MinsecRulerScale {
                minsec_show_seconds,
                minsec_show_minutes,
@@ -739,20 +753,20 @@ class Editor : public PublicEditor
        gint minsec_nmarks;
        void set_minsec_ruler_scale (gdouble lower, gdouble upper);
 
-       enum SMPTERulerScale {
-               smpte_show_bits,
-               smpte_show_frames,
-               smpte_show_seconds,
-               smpte_show_minutes,
-               smpte_show_hours
+       enum TimecodeRulerScale {
+               timecode_show_bits,
+               timecode_show_frames,
+               timecode_show_seconds,
+               timecode_show_minutes,
+               timecode_show_hours
        };
 
-       SMPTERulerScale smpte_ruler_scale;
+       TimecodeRulerScale timecode_ruler_scale;
 
-       nframes_t smpte_mark_interval;
-       gint smpte_mark_modulo;
-       gint smpte_nmarks;
-       void set_smpte_ruler_scale (gdouble lower, gdouble upper);
+       nframes_t timecode_mark_interval;
+       gint timecode_mark_modulo;
+       gint timecode_nmarks;
+       void set_timecode_ruler_scale (gdouble lower, gdouble upper);
 
        enum BBTRulerScale {
                bbt_over,
@@ -774,17 +788,17 @@ class Editor : public PublicEditor
        uint32_t bbt_accent_modulo;
        void compute_bbt_ruler_scale (nframes64_t lower, nframes64_t upper);
 
-       gint metric_get_smpte (GtkCustomRulerMark **, gdouble, gdouble, gint);
+       gint metric_get_timecode (GtkCustomRulerMark **, gdouble, gdouble, gint);
        gint metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
        gint metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
        gint metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
 
        Gtk::Widget        *_ruler_separator;
-       GtkWidget          *_smpte_ruler;
+       GtkWidget          *_timecode_ruler;
        GtkWidget          *_bbt_ruler;
        GtkWidget          *_frames_ruler;
        GtkWidget          *_minsec_ruler;
-       Gtk::Widget        *smpte_ruler;
+       Gtk::Widget        *timecode_ruler;
        Gtk::Widget        *bbt_ruler;
        Gtk::Widget        *frames_ruler;
        Gtk::Widget        *minsec_ruler;
@@ -795,17 +809,17 @@ class Editor : public PublicEditor
        gdouble canvas_timebars_vsize;
        gdouble get_canvas_timebars_vsize () const { return canvas_timebars_vsize; }
        Gtk::Menu          *editor_ruler_menu;
-       
+
        ArdourCanvas::SimpleRect* tempo_bar;
        ArdourCanvas::SimpleRect* meter_bar;
        ArdourCanvas::SimpleRect* marker_bar;
        ArdourCanvas::SimpleRect* range_marker_bar;
        ArdourCanvas::SimpleRect* transport_marker_bar;
        ArdourCanvas::SimpleRect* cd_marker_bar;
-       
+
        Gtk::Label  minsec_label;
        Gtk::Label  bbt_label;
-       Gtk::Label  smpte_label;
+       Gtk::Label  timecode_label;
        Gtk::Label  frame_label;
        Gtk::Label  tempo_label;
        Gtk::Label  meter_label;
@@ -818,7 +832,7 @@ class Editor : public PublicEditor
        Gtk::HBox          time_button_hbox;
 
        friend class EditorCursor;
-       
+
        EditorCursor*        playhead_cursor;
        ArdourCanvas::Group* cursor_group;
 
@@ -855,9 +869,8 @@ class Editor : public PublicEditor
 
        Gtk::HBox           top_hbox;
        Gtk::HBox           bottom_hbox;
-       
+
        Gtk::Table          edit_packer;
-       Gtk::VScrollbar     edit_vscrollbar;
 
        Gtk::Adjustment     vertical_adjustment;
        Gtk::Adjustment     horizontal_adjustment;
@@ -867,14 +880,8 @@ class Editor : public PublicEditor
        void controls_layout_size_request (Gtk::Requisition*);
        sigc::connection controls_layout_size_request_connection;
 
-       Gtk::HScrollbar     edit_hscrollbar;
-       bool                _dragging_hscrollbar;
-
-       void reset_hscrollbar_stepping ();
-       
-       bool hscrollbar_button_press (GdkEventButton*);
-       bool hscrollbar_button_release (GdkEventButton*);
-       void hscrollbar_allocate (Gtk::Allocation &alloc);
+       void horizontal_scroll_left ();
+       void horizontal_scroll_right ();
 
        double _canvas_width;
        double _canvas_height;
@@ -898,7 +905,7 @@ class Editor : public PublicEditor
        sigc::connection control_scroll_connection;
 
        gdouble get_trackview_group_vertical_offset () const { return vertical_adjustment.get_value () - canvas_timebars_vsize;}
-       
+
        ArdourCanvas::Group* get_background_group () const { return _background_group; }
        ArdourCanvas::Group* get_trackview_group () const { return _trackview_group; }
        double last_trackview_group_vertical_offset;
@@ -907,19 +914,19 @@ class Editor : public PublicEditor
        void scroll_canvas_vertically ();
 
        struct VisualChange {
-               enum Type { 
+               enum Type {
                        TimeOrigin = 0x1,
                        ZoomLevel = 0x2,
                        YOrigin = 0x4
                };
-               
+
                Type pending;
                nframes64_t time_origin;
                double frames_per_unit;
                double y_origin;
-               
+
                int idle_handler_id;
-               
+
                VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), frames_per_unit (0), idle_handler_id (-1) {}
                void add (Type t) {
                        pending = Type (pending | t);
@@ -939,42 +946,12 @@ class Editor : public PublicEditor
 
        void end_location_changed (ARDOUR::Location*);
 
-       /* named selections */
-
-       struct NamedSelectionDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
-           NamedSelectionDisplayModelColumns() { 
-                   add (text);
-                   add (selection);
-           }
-           Gtk::TreeModelColumn<Glib::ustring>  text;
-           Gtk::TreeModelColumn<ARDOUR::NamedSelection*>    selection;
-       };
-
-       NamedSelectionDisplayModelColumns named_selection_columns;
-       Glib::RefPtr<Gtk::TreeStore>     named_selection_model;
-
-       Gtkmm2ext::DnDTreeView<ARDOUR::NamedSelection*> named_selection_display;
-       Gtk::ScrolledWindow    named_selection_scroller;
-
-       void create_named_selection ();
-       void paste_named_selection (float times);
-       void remove_selected_named_selections ();
-
-       void handle_new_named_selection ();
-       void add_named_selection_to_named_selection_display (ARDOUR::NamedSelection&);
-       void redisplay_named_selections ();
-
-       bool named_selection_display_button_release (GdkEventButton *ev);
-       bool named_selection_display_key_release (GdkEventKey *ev);
-       void named_selection_display_selection_changed ();
-
        /* track views */
        TrackViewList track_views;
        std::pair<TimeAxisView*, ARDOUR::layer_t> trackview_by_y_position (double);
-       TimeAxisView* axis_view_from_route (ARDOUR::Route *) const;
-       TrackSelection axis_views_from_routes (std::list<ARDOUR::Route *>) const;
+       TimeAxisView* axis_view_from_route (boost::shared_ptr<ARDOUR::Route>) const;
 
-       TrackSelection get_tracks_for_range_action () const;
+       TrackViewList get_tracks_for_range_action () const;
 
        static Gdk::Cursor* cross_hair_cursor;
        static Gdk::Cursor* trimmer_cursor;
@@ -997,11 +974,10 @@ class Editor : public PublicEditor
 
        sigc::connection scroll_connection;
        nframes64_t last_update_frame;
-       void center_screen (nframes64_t);
        void center_screen_internal (nframes64_t, float);
-       
+
        void update_current_screen ();
-       
+
        void session_going_away ();
 
        nframes64_t cut_buffer_start;
@@ -1015,7 +991,7 @@ class Editor : public PublicEditor
        bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false);
        bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
        bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
-       
+
        /* KEYMAP HANDLING */
 
        void register_actions ();
@@ -1033,7 +1009,7 @@ class Editor : public PublicEditor
        void paste_internal (nframes64_t position, float times);
 
        /* EDITING OPERATIONS */
-       
+
        void reset_point_selection ();
        void toggle_region_mute ();
        void toggle_region_lock ();
@@ -1059,6 +1035,7 @@ class Editor : public PublicEditor
        void remove_selected_regions ();
        void remove_clicked_region ();
        void edit_region ();
+       void show_midi_list_editor ();
        void rename_region ();
        void duplicate_some_regions (RegionSelection&, float times);
        void duplicate_selection (float times);
@@ -1072,7 +1049,7 @@ class Editor : public PublicEditor
        void strip_region_silence ();
        void normalize_region ();
        double _last_normalization_value;
-       void denormalize_region ();
+       void reset_region_scale_amplitude ();
        void adjust_region_scale_amplitude (bool up);
        void quantize_region ();
 
@@ -1120,8 +1097,7 @@ class Editor : public PublicEditor
 
        void temporal_zoom_selection ();
        void temporal_zoom_region (bool both_axes);
-       void toggle_zoom_region (bool both_axes);
-       bool zoomed_to_region;
+       void zoom_to_region (bool both_axes);
        void temporal_zoom_session ();
        void temporal_zoom (gdouble scale);
        void temporal_zoom_by_frame (nframes64_t start, nframes64_t end, const std::string & op);
@@ -1136,7 +1112,7 @@ class Editor : public PublicEditor
        void insert_route_list_drag (boost::shared_ptr<ARDOUR::Route>, int x, int y);
 
        /* import & embed */
-       
+
        void add_external_audio_action (Editing::ImportMode);
        void external_audio_dialog ();
        void session_import_dialog ();
@@ -1145,15 +1121,15 @@ class Editor : public PublicEditor
        bool check_multichannel_status (const std::vector<Glib::ustring>& paths);
 
        SoundFileOmega* sfbrowser;
-       
+
        void bring_in_external_audio (Editing::ImportMode mode,  nframes64_t& pos);
 
        bool  idle_drop_paths  (std::vector<Glib::ustring> paths, nframes64_t frame, double ypos);
        void  drop_paths_part_two  (const std::vector<Glib::ustring>& paths, nframes64_t frame, double ypos);
-       
+
        int  import_sndfiles (std::vector<Glib::ustring> paths, Editing::ImportMode mode,  ARDOUR::SrcQuality, nframes64_t& pos,
                              int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>, bool, uint32_t total);
-       int  embed_sndfiles (std::vector<Glib::ustring> paths, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode, 
+       int  embed_sndfiles (std::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::Track>&);
 
        int add_sources (std::vector<Glib::ustring> paths, ARDOUR::SourceList& sources, nframes64_t& pos, Editing::ImportMode,
@@ -1165,7 +1141,7 @@ class Editor : public PublicEditor
        boost::shared_ptr<ARDOUR::MidiTrack> get_nth_selected_midi_track (int nth) const;
 
        /* generic interthread progress window */
-       
+
        ArdourDialog* interthread_progress_window;
        Gtk::Label interthread_progress_label;
        Gtk::VBox interthread_progress_vbox;
@@ -1181,7 +1157,7 @@ class Editor : public PublicEditor
 
        /* import specific info */
 
-       struct EditorImportStatus : public ARDOUR::Session::ImportStatus {
+       struct EditorImportStatus : public ARDOUR::ImportStatus {
            Editing::ImportMode mode;
            nframes64_t pos;
            int target_tracks;
@@ -1280,8 +1256,8 @@ class Editor : public PublicEditor
        void extend_selection_to_end_of_region (bool next);
        void extend_selection_to_start_of_region (bool previous);
 
-       Editing::SnapType snap_type;
-       Editing::SnapMode snap_mode;
+       Editing::SnapType _snap_type;
+       Editing::SnapMode _snap_mode;
 
        /// Snap threshold in pixels
        double snap_threshold;
@@ -1297,14 +1273,13 @@ class Editor : public PublicEditor
 
        void set_fade_in_shape (ARDOUR::AudioRegion::FadeShape);
        void set_fade_out_shape (ARDOUR::AudioRegion::FadeShape);
-       
+
        void set_fade_length (bool in);
        void toggle_fade_active (bool in);
        void set_fade_in_active (bool);
        void set_fade_out_active (bool);
-       
+
        std::set<boost::shared_ptr<ARDOUR::Playlist> > motion_frozen_playlists;
-       RegionSelection pre_drag_region_selection;
 
        bool _dragging_playhead;
        bool _dragging_edit_point;
@@ -1345,7 +1320,7 @@ class Editor : public PublicEditor
        bool canvas_fade_in_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
        bool canvas_fade_out_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
        bool canvas_fade_out_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
-       
+
 
        // These variables are used to detect a feedback loop and break it to avoid a gui hang
 private:
@@ -1354,6 +1329,7 @@ private:
 public:
 
        bool canvas_region_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_stream_view_event (GdkEvent* event,ArdourCanvas::Item*, RouteTimeAxisView*);
@@ -1362,6 +1338,7 @@ public:
        bool canvas_tempo_marker_event (GdkEvent* event,ArdourCanvas::Item*, TempoMarker*);
        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_tempo_bar_event (GdkEvent* event, ArdourCanvas::Item*);
        bool canvas_meter_bar_event (GdkEvent* event, ArdourCanvas::Item*);
@@ -1407,15 +1384,15 @@ public:
        void initialize_canvas ();
 
        /* display control */
-       
+
        bool _show_measures;
        /// 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;
-       
+
        TempoLines* tempo_lines;
 
        ArdourCanvas::Group* time_line_group;
@@ -1433,13 +1410,13 @@ public:
        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 (ArdourCanvas::Item*);
        void edit_meter_marker (ArdourCanvas::Item*);
        void edit_control_point (ArdourCanvas::Item*);
-       
+
        void marker_menu_edit ();
        void marker_menu_remove ();
        void marker_menu_rename ();
@@ -1487,13 +1464,11 @@ public:
        void compute_current_bbt_points (nframes_t left, nframes_t right);
        void tempo_map_changed (ARDOUR::Change);
        void redisplay_tempo (bool immediate_redraw);
-       
+
        void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
        void snap_to_with_modifier (nframes64_t& first, GdkEvent const *, int32_t direction = 0, bool for_mark = false);
        void snap_to (nframes64_t& first, nframes64_t& last, int32_t direction = 0, bool for_mark = false);
 
-       double snap_length_beats (nframes64_t start);
-
        uint32_t bbt_beat_subdivision;
 
        /* toolbar */
@@ -1503,18 +1478,20 @@ public:
        void editor_mixer_button_toggled ();
        void editor_list_button_toggled ();
 
-       AudioClock               edit_point_clock;
        AudioClock               zoom_range_clock;
        Gtk::Button              zoom_in_button;
        Gtk::Button              zoom_out_button;
        Gtk::Button              zoom_out_full_button;
        Gtk::Button              zoom_onetoone_button;
 
+       Gtk::Button              tav_expand_button;
+       Gtk::Button              tav_shrink_button;
+
        Gtk::VBox                toolbar_clock_vbox;
-       Gtk::VBox                toolbar_selection_clock_vbox; 
+       Gtk::VBox                toolbar_selection_clock_vbox;
        Gtk::Table               toolbar_selection_clock_table;
        Gtk::Label               toolbar_selection_cursor_label;
-       
+
        Gtk::HBox                mouse_mode_button_box;
        Gtkmm2ext::TearOff*      mouse_mode_tearoff;
        Gtk::ToggleButton         mouse_select_button;
@@ -1562,19 +1539,18 @@ public:
        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;
+       Gtk::HBox           track_zoom_box;
        Gtk::VBox           zoom_vbox;
 
        void                zoom_adjustment_changed();
 
-       void                edit_point_clock_changed();
-       
        void setup_toolbar ();
 
        Gtkmm2ext::TearOff*      tools_tearoff;
@@ -1587,9 +1563,9 @@ public:
        Gtk::HBox                panic_box;
        Gtk::Button              midi_panic_button;
        Gtk::ToggleButton        midi_sound_notes;
-       void                     midi_panic_button_pressed ();
+       void                     midi_panic ();
        bool                     sound_notes () const { return midi_sound_notes.get_active(); }
-       
+
        void setup_midi_toolbar ();
 
        /* selection process */
@@ -1636,13 +1612,13 @@ public:
        ARDOUR::Location*  transport_punch_location();
 
        ARDOUR::Location   *temp_location;
-       
+
        /* object rubberband select process */
-       
+
        bool select_all_within (nframes64_t start, nframes64_t end, gdouble topy, gdouble boty, const TrackViewList&, Selection::Operation op);
-       
+
        ArdourCanvas::SimpleRect   *rubberband_rect;
-       
+
        /* mouse zoom process */
 
        ArdourCanvas::SimpleRect   *zoom_rect;
@@ -1652,7 +1628,8 @@ public:
        EditorRoutes* _routes;
        EditorRegions* _regions;
        EditorSnapshots* _snapshots;
-       
+       EditorLocations* _locations;
+
        /* diskstream/route display management */
        Glib::RefPtr<Gdk::Pixbuf> rec_enabled_icon;
        Glib::RefPtr<Gdk::Pixbuf> rec_disabled_icon;
@@ -1767,7 +1744,7 @@ public:
        void begin_reversible_command (std::string cmd_name);
        void commit_reversible_command ();
 
-       void update_title ();   
+       void update_title ();
        void update_title_s (const std::string & snapshot_name);
 
        struct State {
@@ -1778,13 +1755,10 @@ public:
            ~State ();
        };
 
-       void store_state (State&) const;
-       void restore_state (State *);
-
        void instant_save ();
 
        boost::shared_ptr<ARDOUR::AudioRegion> last_audition_region;
-       
+
        /* freeze operations */
 
        ARDOUR::InterThreadInfo freeze_status;
@@ -1803,7 +1777,7 @@ public:
        /* duplication */
 
        void duplicate_dialog (bool with_dialog);
-       
+
        nframes64_t event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
 
        /* returns false if mouse pointer is not in track or marker canvas
@@ -1828,9 +1802,7 @@ public:
        bool show_editor_mixer_when_tracks_arrive;
        Gtk::VBox current_mixer_strip_vbox;
        void cms_new (boost::shared_ptr<ARDOUR::Route>);
-       void cms_deleted ();
        void current_mixer_strip_hidden ();
-       void current_mixer_strip_removed ();
 
        void detach_tearoff (Gtk::Box* b, Gtk::Window* w);
        void reattach_tearoff (Gtk::Box* b, Gtk::Window* w, int32_t n);
@@ -1844,7 +1816,7 @@ public:
        /* xfades */
 
        bool _xfade_visibility;
-       
+
 #ifdef WITH_CMT
        void handle_new_imageframe_time_axis_view(const std::string & track_name, void* src) ;
        void handle_new_imageframe_marker_time_axis_view(const std::string & track_name, TimeAxisView* marked_track) ;
@@ -1872,7 +1844,7 @@ public:
        void imageframe_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
        void imageframe_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
        void imageframe_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
-       
+
        void markerview_item_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
        void markerview_item_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
        void markerview_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
@@ -1905,16 +1877,19 @@ public:
 
        bool nudge_forward_release (GdkEventButton*);
        bool nudge_backward_release (GdkEventButton*);
-       
+
        /* audio filters */
 
        void apply_filter (ARDOUR::Filter&, std::string cmd);
 
+       Command* apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, MidiRegionView& mrv);
+       void apply_midi_note_edit_op (ARDOUR::MidiOperator& op);
+
        /* handling cleanup */
 
        int playlist_deletion_dialog (boost::shared_ptr<ARDOUR::Playlist>);
 
-       std::vector<sigc::connection> session_connections;
+       PBD::ScopedConnectionList session_connections;
 
        /* tracking step changes of track height */
 
@@ -1968,14 +1943,12 @@ public:
        std::vector<std::string> edit_point_strings;
 
        void selected_marker_moved (ARDOUR::Location*);
-       sigc::connection edit_point_clock_connection_a;
-       sigc::connection edit_point_clock_connection_b;
 
        bool get_edit_op_range (nframes64_t& start, nframes64_t& end) const;
 
-       void get_regions_at (RegionSelection&, nframes64_t where, const TrackSelection& ts) const;
-       void get_regions_after (RegionSelection&, nframes64_t where, const TrackSelection& ts) const;
-       
+       void get_regions_at (RegionSelection&, nframes64_t where, const TrackViewList& ts) const;
+       void get_regions_after (RegionSelection&, nframes64_t where, const TrackViewList& ts) const;
+
        void get_regions_for_action (RegionSelection&, bool allow_entered = false, bool allow_edit_position = true);
 
        sigc::connection fast_screen_update_connection;
@@ -1988,12 +1961,13 @@ public:
        void select_prev_route ();
 
        void snap_to_internal (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
+       void timecode_snap_to_internal (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
 
        RhythmFerret* rhythm_ferret;
        BundleManager* _bundle_manager;
        GlobalPortMatrixWindow* _global_port_matrix[ARDOUR::DataType::num_types];
 
-       void fit_tracks (TrackSelection &);
+       void fit_tracks (TrackViewList &);
        void fit_selected_tracks ();
        void set_track_height (uint32_t h);
 
@@ -2012,6 +1986,7 @@ public:
        void located ();
        bool _pending_locate_request;
 
+       Gtk::HBox _summary_hbox;
        EditorSummary* _summary;
        void region_view_added (RegionView *);
 
@@ -2021,6 +1996,11 @@ public:
        EditorGroupTabs* _group_tabs;
        void fit_route_group (ARDOUR::RouteGroup *);
 
+       void start_step_editing ();
+       void stop_step_editing ();
+       bool check_step_edit ();
+       sigc::connection step_edit_connection;
+
        friend class Drag;
        friend class RegionDrag;
        friend class RegionMoveDrag;