remove timebar canvas and just use a single canvas instead. This is just part one...
[ardour.git] / gtk2_ardour / editor.h
index 9533acbb529ffa06c1e4633be918504b2f37da90..9f71ec620fb8a8e1b328fd894cd6fd4a0516cc78 100644 (file)
@@ -51,6 +51,7 @@
 #include "gtk-custom-ruler.h"
 #include "ardour_button.h"
 #include "ardour_dialog.h"
+#include "ardour_dropdown.h"
 #include "public_editor.h"
 #include "editing.h"
 #include "enums.h"
@@ -127,7 +128,7 @@ class VerboseCursor;
 
 class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr
 {
 public:
+ public:
        Editor ();
        ~Editor ();
 
@@ -177,6 +178,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void set_internal_edit (bool yn);
        bool toggle_internal_editing_from_double_click (GdkEvent*);
 
+        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);
 
@@ -207,7 +209,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
           account any scrolling offsets.
        */
 
-       framepos_t pixel_to_sample (double pixel) const {
+       framepos_t pixel_to_sample_from_event (double pixel) const {
 
                /* pixel can be less than zero when motion events
                   are processed. since we've already run the world->canvas
@@ -222,6 +224,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
                }
        }
 
+       framepos_t pixel_to_sample (double pixel) const {
+               return pixel * samples_per_pixel;
+       }
+
         double sample_to_pixel (framepos_t sample) const {
                return sample / samples_per_pixel;
        }
@@ -313,6 +319,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void nudge_forward_capture_offset ();
        void nudge_backward_capture_offset ();
 
+       void sequence_regions ();
+
        /* playhead/screen stuff */
 
        void set_stationary_playhead (bool yn);
@@ -345,9 +353,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void show_window ();
 
-       void ensure_time_axis_view_is_visible (const TimeAxisView& tav);
        void scroll_tracks_down_line ();
        void scroll_tracks_up_line ();
+        bool scroll_up_one_track ();
+        bool scroll_down_one_track ();
 
        void prepare_for_cleanup ();
        void finish_cleanup ();
@@ -408,7 +417,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
                return _drags;
        }
 
-       void maybe_autoscroll (bool, bool, bool, bool);
+        void maybe_autoscroll (bool, bool, bool);
+        bool autoscroll_active() const;
 
        Gdk::Cursor* get_canvas_cursor () const { return current_canvas_cursor; }
        void set_canvas_cursor (Gdk::Cursor*, bool save=false);
@@ -439,9 +449,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        ArdourCanvas::Group* get_trackview_group () const { return _trackview_group; }
         ArdourCanvas::Group* get_time_bars_group () const;
         ArdourCanvas::Group* get_track_canvas_group () const;
-        ArdourCanvas::GtkCanvasViewport* get_time_bars_canvas () const;
         ArdourCanvas::GtkCanvasViewport* get_track_canvas () const;
 
+        void override_visible_track_count ();
 
   protected:
        void map_transport_state ();
@@ -684,9 +694,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        ArdourCanvas::GtkCanvas* _track_canvas;
        ArdourCanvas::GtkCanvasViewport* _track_canvas_viewport;
 
-        ArdourCanvas::GtkCanvas* _time_bars_canvas;
-        ArdourCanvas::GtkCanvasViewport* _time_bars_canvas_viewport;
-
        bool within_track_canvas;
 
        friend class VerboseCursor;
@@ -722,12 +729,31 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        ArdourCanvas::Group*      transport_marker_bar_group;
        ArdourCanvas::Group*      cd_marker_bar_group;
 
-       /* The group containing all trackviews.  Only scrolled vertically. */
+       /* The group containing all other groups that are scrolled vertically
+          and horizontally.
+       */
+        ArdourCanvas::Group* hv_scroll_group;
+
+       /* The group containing all other groups that are scrolled vertically ONLY
+       */
+        ArdourCanvas::Group* v_scroll_group;
+
+       /* The group containing all other groups that are scrolled horizontally ONLY
+       */
+        ArdourCanvas::Group* h_scroll_group;
+
+       /* The group containing all trackviews. */
        ArdourCanvas::Group* _trackview_group;
 
        /* The group used for region motion.  Sits on top of _trackview_group */
        ArdourCanvas::Group* _region_motion_group;
 
+        /* 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);
+
        enum RulerType {
                ruler_metric_timecode = 0,
                ruler_metric_bbt = 1,
@@ -895,7 +921,7 @@ 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 ();
+       void export_video (bool range = false);
        void toggle_region_video_lock ();
 
        Gtk::VBox          time_bars_vbox;
@@ -1022,12 +1048,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 ensure_visual_change_idle_handler ();
 
        /* track views */
        TrackViewList track_views;
        std::pair<TimeAxisView*, double> trackview_by_y_position (double);
-       TimeAxisView* axis_view_from_route (boost::shared_ptr<ARDOUR::Route>) const;
+       RouteTimeAxisView* axis_view_from_route (boost::shared_ptr<ARDOUR::Route>) const;
 
        TrackViewList get_tracks_for_range_action () const;
 
@@ -1051,6 +1078,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        bool button_press_handler_1 (ArdourCanvas::Item *, GdkEvent *, ItemType);
        bool button_press_handler_2 (ArdourCanvas::Item *, GdkEvent *, ItemType);
        bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
+       bool button_double_click_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
        bool button_press_dispatch (GdkEventButton*);
        bool button_release_dispatch (GdkEventButton*);
        bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false);
@@ -1071,8 +1099,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
         Gtkmm2ext::ActionMap editor_action_map;
         Gtkmm2ext::Bindings  key_bindings;
 
-       int ensure_cursor (framepos_t* pos);
-
        void cut_copy (Editing::CutCopyOp);
        bool can_cut_copy () const;
        void cut_copy_points (Editing::CutCopyOp);
@@ -1215,13 +1241,17 @@ 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::ImportMode mode,  ARDOUR::SrcQuality, framepos_t& pos,
+        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::ImportMode mode,
+       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::ImportMode,
+       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);
 
@@ -1332,7 +1362,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void escape ();
 
        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;
@@ -1380,9 +1409,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        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_in_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*, bool trim = false);
        bool canvas_fade_out_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
-       bool canvas_fade_out_handle_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_frame_handle_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
        bool canvas_region_view_name_highlight_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
@@ -1410,7 +1439,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        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);
+       void embed_audio_from_video (std::string, framepos_t n = 0, bool lock_position_to_video = true);
 
        PBD::Signal0<void> EditorFreeze;
        PBD::Signal0<void> EditorThaw;
@@ -1435,7 +1464,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        Gtk::Allocation _canvas_viewport_allocation;
        void track_canvas_viewport_allocate (Gtk::Allocation alloc);
-       bool track_canvas_viewport_size_allocated ();
+       void track_canvas_viewport_size_allocated ();
        bool track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const &, int, int, guint);
        bool track_canvas_key_press (GdkEventKey *);
        bool track_canvas_key_release (GdkEventKey *);
@@ -1458,6 +1487,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        TempoLines* tempo_lines;
 
+       ArdourCanvas::Group* global_rect_group;
        ArdourCanvas::Group* time_line_group;
 
        void hide_measures ();
@@ -1476,14 +1506,15 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        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_tempo_marker (TempoMarker&);
+       void edit_meter_marker (MeterMarker&);
        void edit_control_point (ArdourCanvas::Item*);
         void edit_notes (TimeAxisViewItem&);
 
        void marker_menu_edit ();
        void marker_menu_remove ();
        void marker_menu_rename ();
+       void rename_marker (Marker *marker);
        void toggle_marker_menu_lock ();
        void toggle_marker_menu_glue ();
        void marker_menu_hide ();
@@ -1500,8 +1531,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        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);
-       void update_punch_range_view (bool visibility=false);
+       void update_loop_range_view ();
+       void update_punch_range_view ();
        void new_transport_marker_menu_popdown ();
        void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
        void tempo_or_meter_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
@@ -1550,6 +1581,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        ArdourButton              tav_expand_button;
        ArdourButton              tav_shrink_button;
+       ArdourDropdown            visible_tracks_selector;
+
+    int32_t                   _visible_track_count;
+    void build_track_count_menu ();
+    void set_visible_track_count (int32_t);
 
        Gtk::VBox                toolbar_clock_vbox;
        Gtk::VBox                toolbar_selection_clock_vbox;
@@ -1580,35 +1616,40 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::VBox                automation_box;
        Gtk::Button              automation_mode_button;
 
-       Gtk::ComboBoxText edit_mode_selector;
+       //edit mode menu stuff
+       ArdourDropdown  edit_mode_selector;
+       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 ();
-       void edit_mode_selection_done ();
 
-       Gtk::ComboBoxText snap_type_selector;
-       Gtk::ComboBoxText snap_mode_selector;
+       ArdourDropdown snap_type_selector;
+       void build_snap_type_menu ();
+
+       ArdourDropdown snap_mode_selector;
+       void build_snap_mode_menu ();
        Gtk::HBox         snap_box;
 
        std::vector<std::string> snap_type_strings;
        std::vector<std::string> snap_mode_strings;
 
-       void snap_type_selection_done ();
-       void snap_mode_selection_done ();
+       void snap_type_selection_done (Editing::SnapType);
+       void snap_mode_selection_done (Editing::SnapMode);
        void snap_mode_chosen (Editing::SnapMode);
        void snap_type_chosen (Editing::SnapType);
 
        Glib::RefPtr<Gtk::RadioAction> snap_type_action (Editing::SnapType);
        Glib::RefPtr<Gtk::RadioAction> snap_mode_action (Editing::SnapMode);
 
-       Gtk::ComboBoxText zoom_focus_selector;
-       Gtk::VBox         zoom_focus_box;
-
+       //zoom focus meu stuff
+       ArdourDropdown  zoom_focus_selector;
+       void zoom_focus_selection_done ( Editing::ZoomFocus f );
+       void build_zoom_focus_menu ();
        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);
@@ -1639,6 +1680,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Selection* cut_buffer;
 
        void time_selection_changed ();
+        void update_time_selection_display ();
        void track_selection_changed ();
        void region_selection_changed ();
        sigc::connection editor_regions_selection_changed_connection;
@@ -1714,22 +1756,15 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        /* autoscrolling */
 
-       bool autoscroll_active;
-       int autoscroll_timeout_tag;
-       int autoscroll_x;
-       int autoscroll_y;
-       int last_autoscroll_x;
-       int last_autoscroll_y;
-       uint32_t autoscroll_cnt;
-       framecnt_t autoscroll_x_distance;
-       double autoscroll_y_distance;
-
-       bool _autoscroll_fudging;
-       int autoscroll_fudge_threshold () const;
+        sigc::connection autoscroll_connection;
+        bool autoscroll_horizontal_allowed;
+        bool autoscroll_vertical_allowed;
+        uint32_t autoscroll_cnt;
+        Gtk::Widget* autoscroll_widget;
+        ArdourCanvas::Rect autoscroll_boundary;
 
-       static gint _autoscroll_canvas (void *);
        bool autoscroll_canvas ();
-       void start_canvas_autoscroll (int x, int y);
+        void start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect& boundary);
        void stop_canvas_autoscroll ();
 
        /* trimming */
@@ -1830,12 +1865,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
         /** computes the timeline frame (sample) of an event whose coordinates
         * are in canvas units (pixels, scroll offset included).
         */
-       framepos_t canvas_event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
+       framepos_t canvas_event_sample (GdkEvent const *, double* px = 0, double* py = 0) const;
 
         /** computes the timeline frame (sample) of an event whose coordinates
         * are in window units (pixels, no scroll offset).
         */
-       framepos_t window_event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
+       framepos_t window_event_sample (GdkEvent const *, double* px = 0, double* py = 0) const;
 
        /* returns false if mouse pointer is not in track or marker canvas
         */
@@ -1936,12 +1971,13 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        Editing::EditPoint _edit_point;
 
-       Gtk::ComboBoxText edit_point_selector;
+       ArdourDropdown edit_point_selector;
+       void build_edit_point_menu();
 
        void set_edit_point_preference (Editing::EditPoint ep, bool force = false);
        void cycle_edit_point (bool with_marker);
        void set_edit_point ();
-       void edit_point_selection_done ();
+       void edit_point_selection_done (Editing::EditPoint);
        void edit_point_chosen (Editing::EditPoint);
        Glib::RefPtr<Gtk::RadioAction> edit_point_action (Editing::EditPoint);
        std::vector<std::string> edit_point_strings;
@@ -2049,15 +2085,16 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        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).
+           stepped in height using ScrollZoomVerticalModifier+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 modifier key is released.  In this (hacky) way,
+           pushing the modifier key and moving the scroll wheel will operate on the same track
+           until the key 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 ();
+       void zoom_vertical_modifier_released();
 
        friend class Drag;
        friend class RegionDrag;