peak-indicator threshold configuration
[ardour.git] / gtk2_ardour / editor.h
index b3dac8c49adfbbce61bf7051be9904cca777d11d..919d6e0781c249f032e37661cc8d25a0ee32d30c 100644 (file)
@@ -42,6 +42,7 @@
 #include "gtkmm2ext/click_box.h"
 #include "gtkmm2ext/dndtreeview.h"
 #include "gtkmm2ext/stateful_button.h"
+#include "gtkmm2ext/bindings.h"
 
 #include "pbd/stateful.h"
 #include "pbd/signals.h"
@@ -52,6 +53,7 @@
 #include "ardour/types.h"
 
 #include "gtk-custom-ruler.h"
+#include "ardour_button.h"
 #include "ardour_dialog.h"
 #include "public_editor.h"
 #include "editing.h"
 #include "editor_items.h"
 #include "region_selection.h"
 #include "canvas.h"
-#include "window_proxy.h"
 
-namespace Gnome { namespace Canvas {
-       class NoEventText;
-} }
+namespace Gnome {
+       namespace Canvas {
+               class NoEventText;
+               class CanvasNoteEvent;
+       }
+}
 
 namespace Gtkmm2ext {
        class TearOff;
@@ -78,10 +82,8 @@ namespace ARDOUR {
        class Region;
        class Location;
        class TempoSection;
-       class NamedSelection;
        class Session;
        class Filter;
-       class Crossfade;
        class ChanCount;
        class MidiOperator;
        class Track;
@@ -102,16 +104,27 @@ class AutomationLine;
 class AutomationSelection;
 class AutomationTimeAxisView;
 class BundleManager;
+class ButtonJoiner;
 class ControlPoint;
-class CrossfadeView;
 class DragManager;
+class EditNoteDialog;
+class EditorCursor;
+class EditorGroupTabs;
+class EditorLocations;
+class EditorRegions;
+class EditorRoutes;
+class EditorRouteGroups;
+class EditorSnapshots;
+class EditorSummary;
 class GroupedButtons;
 class GUIObjectState;
 class Marker;
 class MidiRegionView;
 class MixerStrip;
+class MouseCursors;
 class PlaylistSelector;
 class PluginSelector;
+class ProgressReporter;
 class RhythmFerret;
 class Selection;
 class SoundFileOmega;
@@ -120,29 +133,9 @@ class TempoLines;
 class TimeAxisView;
 class TimeFXDialog;
 class TimeSelection;
-class EditorGroupTabs;
-class EditorRoutes;
-class EditorRouteGroups;
-class EditorRegions;
-class EditorLocations;
-class EditorSnapshots;
-class EditorSummary;
 class RegionLayeringOrderEditor;
-class ProgressReporter;
-class EditorCursor;
-class MouseCursors;
 class VerboseCursor;
 
-/* <CMT Additions> */
-class ImageFrameView;
-class ImageFrameTimeAxisView;
-class ImageFrameTimeAxis;
-class MarkerTimeAxis ;
-class MarkerView ;
-class ImageFrameSocketHandler ;
-class TimeAxisViewItem ;
-/* </CMT Additions> */
-
 class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr
 {
   public:
@@ -166,7 +159,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        }
 
        void cycle_snap_mode ();
-       void cycle_snap_choice ();
+       void next_snap_choice ();
+       void next_snap_choice_music_only ();
+       void next_snap_choice_music_and_time ();
+       void prev_snap_choice ();
+       void prev_snap_choice_music_only ();
+       void prev_snap_choice_music_and_time ();
        void set_snap_to (Editing::SnapType);
        void set_snap_mode (Editing::SnapMode);
        void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;}
@@ -188,19 +186,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        bool internal_editing() const { return _internal_editing ; }
        void set_internal_edit (bool yn);
-
-#ifdef WITH_CMT
-       void add_imageframe_time_axis(const std::string & track_name, void*) ;
-       void add_imageframe_marker_time_axis(const std::string & track_name, TimeAxisView* marked_track, void*) ;
-       void connect_to_image_compositor() ;
-       void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ;
-       TimeAxisView* get_named_time_axis(const std::string & name) ;
-#endif /* WITH_CMT */
+       bool toggle_internal_editing_from_double_click (GdkEvent*);
 
        void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>);
        void add_to_idle_resize (TimeAxisView*, int32_t);
 
-       RouteTimeAxisView* get_route_view_by_route_id (PBD::ID& id) const;
+       RouteTimeAxisView* get_route_view_by_route_id (const PBD::ID& id) const;
 
        void consider_auditioning (boost::shared_ptr<ARDOUR::Region>);
        void hide_a_region (boost::shared_ptr<ARDOUR::Region>);
@@ -232,6 +223,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
                return rint ((double) frame / (double) frames_per_unit);
        }
 
+       double frame_to_unit_unrounded (framepos_t frame) const {
+               return frame / frames_per_unit;
+       }
+       
        double frame_to_unit (double frame) const {
                return rint (frame / frames_per_unit);
        }
@@ -268,15 +263,20 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        Selection& get_selection() const { return *selection; }
        Selection& get_cut_buffer() const { return *cut_buffer; }
+       void track_mixer_selection ();
 
        bool extend_selection_to_track (TimeAxisView&);
 
        void play_selection ();
+       framepos_t get_preroll ();
+       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 invert_selection_in_track ();
        void invert_selection ();
        void deselect_all ();
+       long select_range (framepos_t, framepos_t);
 
        void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
 
@@ -304,9 +304,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void               set_zoom_focus (Editing::ZoomFocus);
        Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
        double             get_current_zoom () const { return frames_per_unit; }
-
+        void               cycle_zoom_focus ();
        void temporal_zoom_step (bool coarser);
        void tav_zoom_step (bool coarser);
+       void tav_zoom_smooth (bool coarser, bool force_all);
 
        /* stuff that AudioTimeAxisView and related classes use */
 
@@ -358,12 +359,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void toggle_measure_visibility ();
        void toggle_logo_visibility ();
 
-       /* fades/xfades */
+       /* fades */
 
        void toggle_region_fades (int dir);
        void update_region_fade_visibility ();
-       bool xfade_visibility() const { return _xfade_visibility; }
-       void update_xfade_visibility ();
 
        /* redirect shared ops menu. caller must free returned menu */
 
@@ -385,13 +384,15 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void maximise_editing_space();
        void restore_editing_space();
 
+       void update_tearoff_visibility();
+
        void reset_x_origin (framepos_t);
        void reset_x_origin_to_follow_playhead ();
        void reset_y_origin (double);
        void reset_zoom (double);
        void reposition_and_zoom (framepos_t, double);
 
-       framepos_t get_preferred_edit_position (bool ignore_playhead = false);
+       framepos_t get_preferred_edit_position (bool ignore_playhead = false, bool use_context_click = false);
 
        bool update_mouse_speed ();
        bool decelerate_mouse_speed ();
@@ -416,7 +417,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        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 get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions);
+        void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions, bool src_comparison);
 
        void center_screen (framepos_t);
 
@@ -436,7 +437,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
                return _drags;
        }
 
-       void maybe_autoscroll (bool, bool);
+       void maybe_autoscroll (bool, bool, bool, bool);
 
        Gdk::Cursor* get_canvas_cursor () const { return current_canvas_cursor; }
        void set_canvas_cursor (Gdk::Cursor*, bool save=false);
@@ -453,6 +454,14 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void get_pointer_position (double &, double &) const;
 
+       TimeAxisView* stepping_axis_view () {
+               return _stepping_axis_view;
+       }
+       
+       void set_stepping_axis_view (TimeAxisView* v) {
+               _stepping_axis_view = v;
+       }
+
   protected:
        void map_transport_state ();
        void map_position_change (framepos_t);
@@ -473,7 +482,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        typedef std::pair<TimeAxisView*,XMLNode*> TAVState;
 
        struct VisualState {
-           VisualState();
+           VisualState (bool with_tracks);
            ~VisualState ();
            double              y_position;
            double              frames_per_unit;
@@ -492,20 +501,22 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void swap_visual_state ();
 
        std::vector<VisualState*> visual_states;
-       sigc::connection visual_state_op_connection;
        void start_visual_state_op (uint32_t n);
        void cancel_visual_state_op (uint32_t n);
-       bool end_visual_state_op (uint32_t n);
 
        framepos_t leftmost_frame;
        double      frames_per_unit;
        Editing::ZoomFocus zoom_focus;
 
        void set_frames_per_unit (double);
-       void post_zoom ();
+       bool clamp_frames_per_unit (double &) 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;
 
@@ -521,14 +532,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void update_join_object_range_location (double, double);
 
-       int  post_maximal_editor_width;
-       int  post_maximal_editor_height;
-       int  post_maximal_horizontal_pane_position;
-       int  post_maximal_vertical_pane_position;
-       int  pre_maximal_horizontal_pane_position;
-       int  pre_maximal_vertical_pane_position;
-       int  pre_maximal_editor_width;
-       int  pre_maximal_editor_height;
+       boost::optional<int>  pre_notebook_shrink_pane_width;
+
        void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*);
 
        Gtk::Notebook _the_notebook;
@@ -539,8 +544,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::HPaned   edit_pane;
        Gtk::VPaned   editor_summary_pane;
 
-       bool idle_reset_vertical_pane_position (int);
-
        Gtk::EventBox meter_base;
        Gtk::HBox     meter_box;
        Gtk::EventBox marker_base;
@@ -590,6 +593,7 @@ 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;
        bool _show_marker_lines;
 
@@ -612,6 +616,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        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);
        bool choose_new_marker_name(std::string &name);
        void update_cd_marker_display ();
        void ensure_cd_marker_updated (LocationMarkers * lam, ARDOUR::Location * location);
@@ -625,24 +630,21 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        RegionView*        clicked_regionview;
        RegionSelection    latest_regionviews;
        uint32_t           clicked_selection;
-       CrossfadeView*     clicked_crossfadeview;
        ControlPoint*      clicked_control_point;
 
-       void sort_track_selection (TrackViewList* sel = 0);
+       void sort_track_selection (TrackViewList&);
 
        void get_equivalent_regions (RegionView* rv, std::vector<RegionView*> &, PBD::PropertyID) const;
        RegionSelection get_equivalent_regions (RegionSelection &, PBD::PropertyID) const;
        void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*, PBD::PropertyID) const;
+       void mapover_tracks_with_unique_playlists (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*, PBD::PropertyID) const;
 
        /* functions to be passed to mapover_tracks(), possibly with sigc::bind()-supplied arguments */
-
        void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView *, std::vector<RegionView*>*) const;
        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);
-
-       /* end */
-
+       
        void button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type);
        bool button_release_can_deselect;
 
@@ -652,21 +654,18 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void select_all_tracks ();
        void select_all_internal_edit (Selection::Operation);
 
-       bool set_selected_control_point_from_click (Selection::Operation op = Selection::Set, bool no_remove=false);
+       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);
-       void set_selected_track_as_side_effect (Selection::Operation op, bool force = false);
-       bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set, bool no_track_remove=false);
+       void set_selected_track_as_side_effect (Selection::Operation op);
+       bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set);
 
        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 *);
 
-       long select_range_around_region (RegionView *);
-
        Gtk::Menu track_context_menu;
        Gtk::Menu track_region_context_menu;
        Gtk::Menu track_selection_context_menu;
-       Gtk::Menu track_crossfade_context_menu;
 
        Gtk::MenuItem* region_edit_menu_split_item;
        Gtk::MenuItem* region_edit_menu_split_multichannel_item;
@@ -674,23 +673,23 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::Menu * track_edit_playlist_submenu;
        Gtk::Menu * track_selection_edit_playlist_submenu;
 
+       GdkEvent context_click_event;
+
        void popup_track_context_menu (int, int, ItemType, bool);
        Gtk::Menu* build_track_context_menu ();
        Gtk::Menu* build_track_bus_context_menu ();
        Gtk::Menu* build_track_region_context_menu ();
-       Gtk::Menu* build_track_crossfade_context_menu ();
        Gtk::Menu* build_track_selection_context_menu ();
        void add_dstream_context_items (Gtk::Menu_Helpers::MenuList&);
        void add_bus_context_items (Gtk::Menu_Helpers::MenuList&);
        void add_region_context_items (Gtk::Menu_Helpers::MenuList&, boost::shared_ptr<ARDOUR::Track>);
-       void add_crossfade_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Crossfade>, Gtk::Menu_Helpers::MenuList&, bool many);
        void add_selection_context_items (Gtk::Menu_Helpers::MenuList&);
        Gtk::MenuItem* _popup_region_menu_item;
 
        void popup_control_point_context_menu (ArdourCanvas::Item *, GdkEvent *);
        Gtk::Menu _control_point_context_menu;
 
-       void handle_new_route (ARDOUR::RouteList&);
+       void add_routes (ARDOUR::RouteList&);
        void timeaxisview_deleted (TimeAxisView *);
 
        Gtk::HBox           global_hpacker;
@@ -702,6 +701,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void set_canvas_cursor ();
 
        ArdourCanvas::Canvas* track_canvas;
+       bool within_track_canvas;
 
        friend class VerboseCursor;
        VerboseCursor* _verbose_cursor;
@@ -765,6 +765,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
                ruler_time_range_marker = 7,
                ruler_time_transport_marker = 8,
                ruler_time_cd_marker = 9,
+               ruler_video_timeline = 10,
        };
 
        static GtkCustomMetric ruler_metrics[4];
@@ -791,7 +792,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        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 (ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
+                                       ARDOUR::TempoMap::BBTPointList::const_iterator& end);
        void popup_ruler_menu (framepos_t where = 0, ItemType type = RegionItem);
        void update_ruler_visibility ();
        void set_ruler_visible (RulerType, bool);
@@ -855,7 +857,9 @@ 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);
+        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);
@@ -897,6 +901,32 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::Label  transport_mark_label;
        Gtk::Label  cd_mark_label;
 
+       /* videtimline related actions */
+       ArdourCanvas::SimpleRect* videotl_bar;
+       Gtk::Label                videotl_label;
+       ArdourCanvas::Group*      videotl_bar_group;
+       ArdourCanvas::Group*      videotl_group;
+       Glib::RefPtr<Gtk::ToggleAction> ruler_video_action;
+       Glib::RefPtr<Gtk::ToggleAction> xjadeo_proc_action;
+       Glib::RefPtr<Gtk::ToggleAction> xjadeo_ontop_action;
+       Glib::RefPtr<Gtk::ToggleAction> xjadeo_timecode_action;
+       Glib::RefPtr<Gtk::ToggleAction> xjadeo_frame_action;
+       Glib::RefPtr<Gtk::ToggleAction> xjadeo_osdbg_action;
+       Glib::RefPtr<Gtk::ToggleAction> xjadeo_fullscreen_action;
+       Glib::RefPtr<Gtk::ToggleAction> xjadeo_letterbox_action;
+       Glib::RefPtr<Gtk::Action> xjadeo_zoom_100;
+       void set_xjadeo_proc ();
+       void toggle_xjadeo_proc (int state=-1);
+       void set_close_video_sensitive (bool onoff);
+       void set_xjadeo_sensitive (bool onoff);
+       void set_xjadeo_viewoption (int);
+       void toggle_xjadeo_viewoption (int what, int state=-1);
+       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 ();
+       void toggle_region_video_lock ();
+
        Gtk::VBox          time_button_vbox;
        Gtk::HBox          time_button_hbox;
 
@@ -976,8 +1006,16 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::VBox           edit_controls_vbox;
        Gtk::HBox           edit_controls_hbox;
 
+       void control_vertical_zoom_in_all ();
+       void control_vertical_zoom_out_all ();
+       void control_vertical_zoom_in_selected ();
+       void control_vertical_zoom_out_selected ();
+       void control_step_tracks_up ();
+       void control_step_tracks_down ();
+       void control_view (uint32_t);
        void control_scroll (float);
-       void control_select (uint32_t rid);
+       void control_select (uint32_t rid, Selection::Operation);
+       void control_unselect ();
        void access_action (std::string,std::string);
        bool deferred_control_scroll (framepos_t);
        sigc::connection control_scroll_connection;
@@ -1005,27 +1043,24 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
                double y_origin;
 
                int idle_handler_id;
+               /** true if we are currently in the idle handler */
+               bool being_handled;
 
-               VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), frames_per_unit (0), idle_handler_id (-1) {}
+               VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), frames_per_unit (0), idle_handler_id (-1), being_handled (false) {}
                void add (Type t) {
                        pending = Type (pending | t);
                }
        };
 
-
        VisualChange pending_visual_change;
 
        static int _idle_visual_changer (void *arg);
        int idle_visual_changer ();
-
-       void queue_visual_change (framepos_t);
-       void queue_visual_change (double);
-       void queue_visual_change_y (double);
        void ensure_visual_change_idle_handler ();
 
        /* track views */
        TrackViewList track_views;
-       std::pair<TimeAxisView*, ARDOUR::layer_t> trackview_by_y_position (double);
+       std::pair<TimeAxisView*, double> trackview_by_y_position (double);
        TimeAxisView* axis_view_from_route (boost::shared_ptr<ARDOUR::Route>) const;
 
        TrackViewList get_tracks_for_range_action () const;
@@ -1066,6 +1101,10 @@ 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;
+
        int ensure_cursor (framepos_t* pos);
 
        void cut_copy (Editing::CutCopyOp);
@@ -1088,9 +1127,18 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void toggle_solo_isolate ();
        void toggle_mute ();
        void toggle_region_lock_style ();
+
+       enum LayerOperation {
+               Raise,
+               RaiseToTop,
+               Lower,
+               LowerToBottom
+       };
+
+       void do_layer_operation (LayerOperation);
        void raise_region ();
        void raise_region_to_top ();
-       void change_region_layering_order ();
+       void change_region_layering_order (bool from_context_menu);
        void lower_region ();
        void lower_region_to_bottom ();
        void split_regions_at (framepos_t, RegionSelection&);
@@ -1126,7 +1174,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void reset_region_scale_amplitude ();
        void adjust_region_gain (bool up);
        void quantize_region ();
-       void insert_patch_change ();
+       void insert_patch_change (bool from_context);
        void fork_region ();
 
        void do_insert_time ();
@@ -1152,7 +1200,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void delete_ ();
        void cut ();
        void copy ();
-       void paste (float times);
+       void paste (float times, bool from_context_menu = false);
 
        void place_transient ();
        void remove_transient (ArdourCanvas::Item* item);
@@ -1176,8 +1224,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void temporal_zoom_region (bool both_axes);
        void zoom_to_region (bool both_axes);
        void temporal_zoom_session ();
-       void temporal_zoom (gdouble scale);
-       void temporal_zoom_by_frame (framepos_t start, framepos_t end, const std::string & op);
+       void temporal_zoom (double scale);
+       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);
@@ -1198,8 +1246,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void bring_in_external_audio (Editing::ImportMode mode,  framepos_t& pos);
 
-       bool  idle_drop_paths  (std::vector<std::string> paths, framepos_t frame, double ypos);
-       void  drop_paths_part_two  (const std::vector<std::string>& paths, framepos_t frame, double ypos);
+       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::ImportMode mode,  ARDOUR::SrcQuality, framepos_t& pos,
                              int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool);
@@ -1214,6 +1262,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        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);
+
        ARDOUR::InterThreadInfo* current_interthread_info;
 
        AnalysisWindow* analysis_window;
@@ -1318,6 +1368,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::Menu fade_context_menu;
        void popup_fade_context_menu (int, int, ArdourCanvas::Item*, ItemType);
 
+       Gtk::Menu xfade_in_context_menu;
+       Gtk::Menu xfade_out_context_menu;
+       void popup_xfade_in_context_menu (int, int, ArdourCanvas::Item*, ItemType);
+       void popup_xfade_out_context_menu (int, int, ArdourCanvas::Item*, ItemType);
+       void fill_xfade_menu (Gtk::Menu_Helpers::MenuList& items, bool start);
+
        void set_fade_in_shape (ARDOUR::FadeShape);
        void set_fade_out_shape (ARDOUR::FadeShape);
 
@@ -1355,7 +1411,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        bool canvas_selection_rect_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
        bool canvas_selection_start_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
        bool canvas_selection_end_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
-       bool canvas_crossfade_view_event (GdkEvent* event,ArdourCanvas::Item*, CrossfadeView*);
+       bool canvas_start_xfade_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
+       bool canvas_end_xfade_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
        bool canvas_fade_in_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
        bool canvas_fade_in_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
        bool canvas_fade_out_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
@@ -1380,14 +1437,14 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        bool canvas_transport_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
        bool canvas_cd_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
 
-       bool canvas_imageframe_item_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
-       bool canvas_imageframe_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameTimeAxis*);
-       bool canvas_imageframe_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
-       bool canvas_imageframe_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
-       bool canvas_marker_time_axis_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerTimeAxis*);
-       bool canvas_markerview_item_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
-       bool canvas_markerview_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
-       bool canvas_markerview_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
+       bool canvas_videotl_bar_event (GdkEvent* event, ArdourCanvas::Item*);
+       void update_video_timeline (bool flush = false);
+       void set_video_timeline_height (const int);
+       bool is_video_timeline_locked ();
+       void toggle_video_timeline_locked ();
+       void set_video_timeline_locked (const bool);
+       void queue_visual_videotimeline_update ();
+       void embed_audio_from_video (std::string, framepos_t n = 0);
 
        PBD::Signal0<void> EditorFreeze;
        PBD::Signal0<void> EditorThaw;
@@ -1397,7 +1454,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        friend class EditorRouteGroups;
        friend class EditorRegions;
 
-       ArdourCanvas::Item *last_item_entered;
        /** true if the mouse is over a place where region trim can happen */
        bool _over_region_trim_target;
 
@@ -1431,15 +1487,16 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        bool _follow_playhead;
        /// true if we scroll the tracks rather than the playhead
        bool _stationary_playhead;
-
-       ARDOUR::TempoMap::BBTPointList *current_bbt_points;
+       /// true if we are in fullscreen mode
+       bool _maximised;
 
        TempoLines* tempo_lines;
 
        ArdourCanvas::Group* time_line_group;
 
        void hide_measures ();
-       void draw_measures ();
+        void draw_measures (ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
+                           ARDOUR::TempoMap::BBTPointList::const_iterator& end);
        bool redraw_measures ();
 
        void new_tempo_section ();
@@ -1457,7 +1514,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void edit_tempo_marker (ArdourCanvas::Item*);
        void edit_meter_marker (ArdourCanvas::Item*);
        void edit_control_point (ArdourCanvas::Item*);
-       void edit_note (ArdourCanvas::Item *);
+        void edit_notes (TimeAxisViewItem&);
 
        void marker_menu_edit ();
        void marker_menu_remove ();
@@ -1473,8 +1530,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void marker_menu_play_range ();
        void marker_menu_set_playhead ();
        void marker_menu_set_from_playhead ();
-       void marker_menu_set_from_selection ();
+       void marker_menu_set_from_selection (bool force_regions);
        void marker_menu_range_to_next ();
+       void marker_menu_zoom_to_range ();
        void new_transport_marker_menu_set_loop ();
        void new_transport_marker_menu_set_punch ();
        void update_loop_range_view (bool visibility=false);
@@ -1482,9 +1540,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void new_transport_marker_menu_popdown ();
        void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
        void tempo_or_meter_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
-       void transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
        void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
-       void build_range_marker_menu (bool);
+       void build_range_marker_menu (bool, bool);
        void build_marker_menu (ARDOUR::Location *);
        void build_tempo_or_meter_marker_menu (bool);
        void build_new_transport_marker_menu ();
@@ -1504,7 +1561,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void remove_metric_marks ();
        void draw_metric_marks (const ARDOUR::Metrics& metrics);
 
-       void compute_current_bbt_points (framepos_t left, framepos_t right);
+        void compute_current_bbt_points (framepos_t left, framepos_t right, 
+                                        ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
+                                        ARDOUR::TempoMap::BBTPointList::const_iterator& end);
+
        void tempo_map_changed (const PBD::PropertyChange&);
        void redisplay_tempo (bool immediate_redraw);
 
@@ -1518,13 +1578,13 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void editor_list_button_toggled ();
 
        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;
+       ArdourButton              zoom_in_button;
+       ArdourButton              zoom_out_button;
+       ArdourButton              zoom_out_full_button;
+
+       ArdourButton              tav_expand_button;
+       ArdourButton              tav_shrink_button;
 
        Gtk::VBox                toolbar_clock_vbox;
        Gtk::VBox                toolbar_selection_clock_vbox;
@@ -1532,20 +1592,23 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::Label               toolbar_selection_cursor_label;
 
        Gtkmm2ext::TearOff*      _mouse_mode_tearoff;
-       Gtkmm2ext::StatefulToggleButton mouse_select_button;
-       Gtkmm2ext::StatefulToggleButton mouse_move_button;
-       Gtkmm2ext::StatefulToggleButton mouse_gain_button;
-       Gtkmm2ext::StatefulToggleButton mouse_zoom_button;
-       Gtkmm2ext::StatefulToggleButton mouse_timefx_button;
-       Gtkmm2ext::StatefulToggleButton mouse_audition_button;
-       Gtkmm2ext::StatefulToggleButton join_object_range_button;
+       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_audition_button;
+
+       ArdourButton smart_mode_button;
+       Glib::RefPtr<Gtk::ToggleAction> smart_mode_action;
 
        void                     mouse_mode_toggled (Editing::MouseMode m);
-       void                     mouse_mode_object_range_toggled () {}
+       void                     mouse_mode_object_range_toggled ();
        bool                     ignore_mouse_mode_toggle;
 
-       Gtkmm2ext::StatefulToggleButton internal_edit_button;
-       void                     toggle_internal_editing ();
+       ArdourButton internal_edit_button;
+       void         toggle_internal_editing ();
 
        bool                     mouse_select_button_release (GdkEventButton*);
 
@@ -1602,10 +1665,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        /* midi toolbar */
 
        Gtk::HBox                panic_box;
-       Gtk::Button              midi_panic_button;
-       Gtk::ToggleButton        midi_sound_notes;
-       void                     midi_panic ();
-       bool                     sound_notes () const { return midi_sound_notes.get_active(); }
 
        void setup_midi_toolbar ();
 
@@ -1631,6 +1690,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void marker_selection_changed ();
 
        void cancel_selection ();
+       void cancel_time_selection ();
+
+       bool get_smart_mode() const;
 
        bool audio_region_selection_covers (framepos_t where);
 
@@ -1697,6 +1759,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        framecnt_t autoscroll_x_distance;
        double autoscroll_y_distance;
 
+       bool _autoscroll_fudging;
+       int autoscroll_fudge_threshold () const;
+
        static gint _autoscroll_canvas (void *);
        bool autoscroll_canvas ();
        void start_canvas_autoscroll (int x, int y);
@@ -1780,14 +1845,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void update_title ();
        void update_title_s (const std::string & snapshot_name);
 
-       struct State {
-           Selection* selection;
-           double frames_per_unit;
-
-           State (PublicEditor const * e);
-           ~State ();
-       };
-
        void instant_save ();
 
        boost::shared_ptr<ARDOUR::AudioRegion> last_audition_region;
@@ -1803,7 +1860,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        /* duplication */
 
-       void duplicate_dialog (bool with_dialog);
+       void duplicate_range (bool with_dialog);
 
        framepos_t event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
 
@@ -1811,17 +1868,13 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
         */
        bool mouse_frame (framepos_t&, bool& in_track_canvas) const;
 
-       /* "whats mine is yours" */
-
        TimeFXDialog* current_timefx;
-
        static void* timefx_thread (void *arg);
-       void do_timefx (TimeFXDialog&);
+       void do_timefx ();
 
        int time_stretch (RegionSelection&, float fraction);
        int pitch_shift (RegionSelection&, float cents);
        void pitch_shift_region ();
-       int time_fx (RegionSelection&, float val, bool pitching);
 
        void transpose_region ();
 
@@ -1842,64 +1895,13 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void nudge_track (bool use_edit_point, bool forwards);
 
-       /* 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) ;
-
-       void start_imageframe_grab(ArdourCanvas::Item*, GdkEvent*) ;
-       void start_markerview_grab(ArdourCanvas::Item*, GdkEvent*) ;
-
-       void imageframe_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
-       void markerview_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
-       void timeaxis_item_drag_finished_callback(ArdourCanvas::Item*, GdkEvent*) ;
-
-       gint canvas_imageframe_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
-       gint canvas_imageframe_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameTimeAxis* ifta);
-       gint canvas_imageframe_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
-       gint canvas_imageframe_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
-
-       gint canvas_marker_time_axis_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerTimeAxis* mta);
-       gint canvas_markerview_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
-       gint canvas_markerview_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
-       gint canvas_markerview_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
-
-       void imageframe_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
-       void imageframe_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
-       void imageframe_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
-       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) ;
-       void markerview_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
-       void markerview_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
-       void markerview_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
-
-       void popup_imageframe_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
-       void popup_marker_time_axis_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
-
-       ImageFrameSocketHandler* image_socket_listener ;
-#endif
-
-       void toggle_xfade_active (boost::weak_ptr<ARDOUR::Crossfade>);
-       void toggle_xfade_length (boost::weak_ptr<ARDOUR::Crossfade>);
-       void edit_xfade (boost::weak_ptr<ARDOUR::Crossfade>);
-       void xfade_edit_left_region ();
-       void xfade_edit_right_region ();
-
        static const int32_t default_width = 995;
        static const int32_t default_height = 765;
 
        /* nudge */
 
-       Gtk::Button      nudge_forward_button;
-       Gtk::Button      nudge_backward_button;
+       ArdourButton      nudge_forward_button;
+       ArdourButton      nudge_backward_button;
        Gtk::HBox        nudge_hbox;
        Gtk::VBox        nudge_vbox;
        AudioClock*       nudge_clock;
@@ -1933,8 +1935,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        */
        RegionView*   entered_regionview;
 
-
-       void ensure_entered_track_selected (bool op_acts_on_objects = false);
        bool clear_entered_track;
        bool left_track_canvas (GdkEventCrossing*);
        bool entered_track_canvas (GdkEventCrossing*);
@@ -1944,7 +1944,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        gint left_automation_track ();
 
        void reset_canvas_action_sensitivity (bool);
-       void toggle_gain_envelope_visibility ();
+       void set_gain_envelope_visibility ();
+       void set_region_gain_visibility (RegionView*);
        void toggle_gain_envelope_active ();
        void reset_region_gain_envelopes ();
 
@@ -1979,7 +1980,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void get_regions_at (RegionSelection&, framepos_t where, const TrackViewList& ts) const;
        void get_regions_after (RegionSelection&, framepos_t where, const TrackViewList& ts) const;
 
-       RegionSelection get_regions_from_selection ();
        RegionSelection get_regions_from_selection_and_edit_point ();
        RegionSelection get_regions_from_selection_and_entered ();
 
@@ -2057,6 +2057,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void setup_fade_images ();
        std::map<ARDOUR::FadeShape, Gtk::Image*> _fade_in_images;
        std::map<ARDOUR::FadeShape, Gtk::Image*> _fade_out_images;
+       std::map<ARDOUR::FadeShape, Gtk::Image*> _xfade_in_images;
+       std::map<ARDOUR::FadeShape, Gtk::Image*> _xfade_out_images;
 
        Gtk::MenuItem& action_menu_item (std::string const &);
        void action_pre_activated (Glib::RefPtr<Gtk::Action> const &);
@@ -2065,7 +2067,26 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        MouseCursors* _cursors;
 
-       void resize_text_widgets ();
+       void follow_mixer_selection ();
+       bool _following_mixer_selection;
+
+       int time_fx (ARDOUR::RegionList&, float val, bool pitching);
+        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 */
+       bool _control_point_toggled_on_press;
+
+       /** This is used by TimeAxisView to keep a track of the TimeAxisView that is currently being
+           stepped in height using Shift-Scrollwheel.  When a scroll event occurs, we do the step on
+           this _stepping_axis_view if it is non-0 (and we set up this _stepping_axis_view with the
+           TimeAxisView underneath the mouse if it is 0).  Then Editor resets _stepping_axis_view when
+           the shift key is released.  In this (hacky) way, pushing shift and moving the scroll wheel
+           will operate on the same track until shift is released (rather than skipping about to whatever
+           happens to be underneath the mouse at the time).
+       */
+       TimeAxisView* _stepping_axis_view;
+       void shift_key_released ();
 
        friend class Drag;
        friend class RegionDrag;
@@ -2082,6 +2103,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        friend class ControlPointDrag;
        friend class LineDrag;
        friend class RubberbandSelectDrag;
+       friend class EditorRubberbandSelectDrag;
        friend class TimeFXDrag;
        friend class ScrubDrag;
        friend class SelectionDrag;
@@ -2090,6 +2112,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        friend class RegionCreateDrag;
        friend class RegionMotionDrag;
        friend class RegionInsertDrag;
+       friend class VideoTimeLineDrag;
 
        friend class EditorSummary;
        friend class EditorGroupTabs;