fix deadlock in protocol manager startup; fix some other ::set_session() SNAFUs;...
[ardour.git] / gtk2_ardour / editor_drag.h
index 370cc566436aef6ebd888114c8acf61f3f920079..170c9a80802c84043e8641f790a1780fb2401c3a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2009 Paul Davis 
+    Copyright (C) 2009 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
@@ -41,7 +41,7 @@ class TimeAxisView;
 /** Abstract base class for dragging of things within the editor */
 class Drag
 {
-       
+
 public:
        Drag (Editor *, ArdourCanvas::Item *);
        virtual ~Drag () {}
@@ -110,12 +110,13 @@ public:
                return false;
        }
 
-       /** Called when a subclass should update the editor's selection following a drag */
-       virtual void update_selection () {}
+       virtual bool allow_vertical_autoscroll () const {
+               return true;
+       }
 
 protected:
-       nframes64_t adjusted_current_frame () const;
-       
+       nframes64_t adjusted_current_frame (GdkEvent *) const;
+
        Editor* _editor; ///< our editor
        ArdourCanvas::Item* _item; ///< our item
        nframes64_t _pointer_frame_offset; ///< offset from the mouse's position for the drag
@@ -135,9 +136,10 @@ protected:
        bool _x_constrained; ///< true if x motion is constrained, otherwise false
        bool _y_constrained; ///< true if y motion is constrained, otherwise false
        bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
+       bool _have_transaction; ///< true if a transaction has been started, false otherwise. Must be set true by derived class.
 
 private:
-       
+
        bool _ending; ///< true if end_grab is in progress, otherwise false
        bool _had_movement; ///< true if movement has occurred, otherwise false
        bool _move_threshold_passed; ///< true if the move threshold has been passed, otherwise false
@@ -151,15 +153,14 @@ public:
        RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
        virtual ~RegionDrag () {}
 
-       void update_selection ();
-
 protected:
-       
+
        RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
        std::list<RegionView*> _views; ///< all views that are being dragged
 
 private:
        void region_going_away (RegionView *);
+       boost::signals2::scoped_connection death_connection;
 };
 
 
@@ -167,7 +168,7 @@ private:
 class RegionMotionDrag : public RegionDrag
 {
 public:
-       
+
        RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
        virtual ~RegionMotionDrag () {}
 
@@ -178,16 +179,16 @@ public:
 protected:
        struct TimeAxisViewSummary {
                TimeAxisViewSummary () : height_list(512) {}
-               
+
                std::bitset<512> tracks;
                std::vector<int32_t> height_list;
                int visible_y_low;
                int visible_y_high;
        };
-       
+
        void copy_regions (GdkEvent *);
        bool y_movement_disallowed (int, int, int, TimeAxisViewSummary const &) const;
-       std::map<RegionView*, RouteTimeAxisView*> find_time_axis_views ();
+       std::map<RegionView*, std::pair<RouteTimeAxisView*, int> > find_time_axis_views_and_layers ();
        double compute_x_delta (GdkEvent const *, nframes64_t *);
        bool compute_y_delta (
                TimeAxisView const *, TimeAxisView*, int32_t, int32_t, TimeAxisViewSummary const &,
@@ -195,8 +196,8 @@ protected:
                );
 
        TimeAxisViewSummary get_time_axis_view_summary ();
-       virtual bool x_move_allowed () const = 0;
-       
+       bool x_move_allowed () const;
+
        TimeAxisView* _dest_trackview;
        ARDOUR::layer_t _dest_layer;
        bool check_possible (RouteTimeAxisView **, ARDOUR::layer_t *);
@@ -216,14 +217,12 @@ public:
        virtual void start_grab (GdkEvent *, Gdk::Cursor *);
        void motion (GdkEvent *, bool);
        void finished (GdkEvent *, bool);
-       
+
        bool apply_move_threshold () const {
                return true;
        }
 
 private:
-       bool x_move_allowed () const;
-
        bool _copy;
 };
 
@@ -234,9 +233,6 @@ public:
        RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, nframes64_t);
 
        void finished (GdkEvent *, bool);
-       
-private:
-       bool x_move_allowed () const;
 };
 
 /** Region drag in splice mode */
@@ -264,6 +260,40 @@ private:
        TimeAxisView* _dest_trackview;
 };
 
+/** Drags to resize MIDI notes */
+class NoteResizeDrag : public Drag
+{
+public:
+       NoteResizeDrag (Editor *, ArdourCanvas::Item *);
+
+       void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
+       void motion (GdkEvent *, bool);
+       void finished (GdkEvent *, bool);
+
+private:
+       MidiRegionView*     region;
+       bool                relative;
+       bool                at_front;
+};
+
+class NoteDrag : public Drag
+{
+  public:
+       NoteDrag (Editor*, ArdourCanvas::Item*);
+
+       void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
+       void motion (GdkEvent *, bool);
+       void finished (GdkEvent *, bool);
+
+  private:
+       MidiRegionView* region;
+       double last_x;
+       double last_y;
+       double drag_delta_x;
+       double drag_delta_note;
+       bool   was_selected;
+};
+
 /** Drag of region gain */
 class RegionGainDrag : public Drag
 {
@@ -339,10 +369,18 @@ public:
        void motion (GdkEvent *, bool);
        void finished (GdkEvent *, bool);
 
+       bool active (Editing::MouseMode) {
+               return true;
+       }
+
+       bool allow_vertical_autoscroll () const {
+               return false;
+       }
+
 private:
        EditorCursor* _cursor; ///< cursor being dragged
        bool _stop; ///< true to stop the transport on starting the drag, otherwise false
-       
+
 };
 
 /** Region fade-in drag */
@@ -380,7 +418,7 @@ public:
 
 private:
        void update_item (ARDOUR::Location *);
-       
+
        Marker* _marker; ///< marker being dragged
        std::list<ARDOUR::Location*> _copied_locations;
        ArdourCanvas::Line* _line;
@@ -397,8 +435,10 @@ public:
        void motion (GdkEvent *, bool);
        void finished (GdkEvent *, bool);
 
+       bool active (Editing::MouseMode m);
+
 private:
-       
+
        ControlPoint* _point;
        double _cumulative_x_drag;
        double _cumulative_y_drag;
@@ -415,6 +455,10 @@ public:
        void motion (GdkEvent *, bool);
        void finished (GdkEvent *, bool);
 
+       bool active (Editing::MouseMode) {
+               return true;
+       }
+
 private:
 
        AutomationLine* _line;
@@ -445,7 +489,18 @@ public:
        void finished (GdkEvent *, bool);
 };
 
-/** Drag in range selection mode */
+/** Scrub drag in audition mode */
+class ScrubDrag : public Drag
+{
+public:
+       ScrubDrag (Editor *e, ArdourCanvas::Item *i) : Drag (e, i) {}
+
+       void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
+       void motion (GdkEvent *, bool);
+       void finished (GdkEvent *, bool);
+};
+
+/** Drag in range select(gc_owner.get()) moAutomatable */
 class SelectionDrag : public Drag
 {
 public: