crossfade hack and slash. removed overlap checks, overlap mode, default length,...
[ardour.git] / gtk2_ardour / editor_drag.h
index d4cd5a6a9dbe343de802f93d40c8b6ed340f78a5..f18a40a9e257f894ef07d92e279684c0fbee28b5 100644 (file)
@@ -212,6 +212,8 @@ protected:
                return _last_pointer_frame;
        }
 
+       boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*);
+
        void show_verbose_cursor_time (framepos_t);
        void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0);
        void show_verbose_cursor_text (std::string const &);
@@ -240,15 +242,21 @@ private:
 class RegionDrag;
 
 /** Container for details about a region being dragged */
-struct DraggingView
+class DraggingView
 {
+public:
        DraggingView (RegionView *, RegionDrag *);
 
        RegionView* view; ///< the view
-       /** index into RegionDrag::_time_axis_views of the view that this region is currently beind displayed on */
+       /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on,
+        *  or -1 if it is not visible.
+        */
        int time_axis_view;
-       /** layer that this region is currently being displayed on */
-       ARDOUR::layer_t layer;
+       /** layer that this region is currently being displayed on.  This is a double
+           rather than a layer_t as we use fractional layers during drags to allow the user
+           to indicate a new layer to put a region on.
+       */
+       double layer;
        double initial_y; ///< the initial y position of the view before any reparenting
        framepos_t initial_position; ///< initial position of the region
        framepos_t initial_end; ///< initial end position of the region
@@ -293,7 +301,7 @@ public:
 
        virtual void start_grab (GdkEvent *, Gdk::Cursor *);
        virtual void motion (GdkEvent *, bool);
-       virtual void finished (GdkEvent *, bool) = 0;
+       virtual void finished (GdkEvent *, bool);
        virtual void aborted (bool);
 
        /** @return true if the regions being `moved' came from somewhere on the canvas;
@@ -303,14 +311,14 @@ public:
 
 protected:
 
-       double compute_x_delta (GdkEvent const *, ARDOUR::framecnt_t *);
-       bool y_movement_allowed (int, ARDOUR::layer_t) const;
+       double compute_x_delta (GdkEvent const *, ARDOUR::framepos_t *);
+       bool y_movement_allowed (int, double) const;
 
        bool _brushing;
        ARDOUR::framepos_t _last_frame_position; ///< last position of the thing being dragged
        double _total_x_delta;
        int _last_pointer_time_axis_view;
-       ARDOUR::layer_t _last_pointer_layer;
+       double _last_pointer_layer;
 };
 
 
@@ -412,7 +420,6 @@ public:
 private:
        MidiTimeAxisView* _view;
        boost::shared_ptr<ARDOUR::Region> _region;
-        void add_region ();
 };
 
 /** Drags to resize MIDI notes */
@@ -456,6 +463,26 @@ class NoteDrag : public Drag
        double _note_height;
 };
 
+class NoteCreateDrag : public Drag
+{
+public:
+       NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
+       ~NoteCreateDrag ();
+
+       void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
+       void motion (GdkEvent *, bool);
+       void finished (GdkEvent *, bool);
+       void aborted (bool);
+
+private:
+       double y_to_region (double) const;
+       framecnt_t grid_frames (framepos_t) const;
+       
+       MidiRegionView* _region_view;
+       ArdourCanvas::SimpleRect* _drag_rect;
+       framepos_t _note[2];
+};
+
 /** Drag to move MIDI patch changes */
 class PatchChangeDrag : public Drag
 {
@@ -478,21 +505,6 @@ private:
        double _cumulative_dx;
 };
 
-/** Drag of region gain */
-class RegionGainDrag : public Drag
-{
-public:
-       RegionGainDrag (Editor *, ArdourCanvas::Item *);
-
-       void motion (GdkEvent *, bool);
-       void finished (GdkEvent *, bool);
-       bool active (Editing::MouseMode m) {
-               return (m == Editing::MouseGain);
-       }
-
-       void aborted (bool);
-};
-
 /** Drag to trim region(s) */
 class TrimDrag : public RegionDrag
 {
@@ -503,7 +515,7 @@ public:
                ContentsTrim,
        };
 
-       TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &);
+       TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
 
        void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
        void motion (GdkEvent *, bool);
@@ -519,6 +531,8 @@ public:
 private:
 
        Operation _operation;
+       
+       bool _preserve_fade_anchor;
 };
 
 /** Meter marker drag */
@@ -545,6 +559,7 @@ public:
 private:
        MeterMarker* _marker;
        bool _copy;
+       XMLNode* before_state;
 };
 
 /** Tempo marker drag */
@@ -571,6 +586,7 @@ public:
 private:
        TempoMarker* _marker;
        bool _copy;
+       XMLNode* before_state;
 };
 
 
@@ -759,6 +775,59 @@ public:
        std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
                return std::make_pair (8, 1);
        }
+
+       void do_select_things (GdkEvent *, bool);
+
+       /** Select some things within a rectangle.
+        *  @param button_state The button state from the GdkEvent.
+        *  @param x1 The left-hand side of the rectangle in session frames.
+        *  @param x2 The right-hand side of the rectangle in session frames.
+        *  @param y1 The top of the rectangle in trackview coordinates.
+        *  @param y2 The bottom of the rectangle in trackview coordinates.
+        *  @param drag_in_progress true if the drag is currently happening.
+        */
+       virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
+       
+       virtual void deselect_things () = 0;
+
+  protected:
+       bool _vertical_only;
+};
+
+/** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
+class EditorRubberbandSelectDrag : public RubberbandSelectDrag
+{
+public:
+       EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
+
+       void select_things (int, framepos_t, framepos_t, double, double, bool);
+       void deselect_things ();
+};
+
+/** A RubberbandSelectDrag for selecting MIDI notes */
+class MidiRubberbandSelectDrag : public RubberbandSelectDrag
+{
+public:
+       MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
+
+       void select_things (int, framepos_t, framepos_t, double, double, bool);
+       void deselect_things ();
+
+private:
+       MidiRegionView* _region_view;
+};
+
+/** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
+class MidiVerticalSelectDrag : public RubberbandSelectDrag
+{
+public:
+       MidiVerticalSelectDrag (Editor *, MidiRegionView *);
+
+       void select_things (int, framepos_t, framepos_t, double, double, bool);
+       void deselect_things ();
+
+private:
+       MidiRegionView* _region_view;
 };
 
 /** Region drag in time-FX mode */
@@ -811,6 +880,7 @@ private:
        int _original_pointer_time_axis;
        int _last_pointer_time_axis;
        std::list<TimeAxisView*> _added_time_axes;
+       bool _time_selection_at_start;
 };
 
 /** Range marker drag */
@@ -865,11 +935,14 @@ private:
        bool _zoom_out;
 };
 
-/** Drag of a range of automation data, changing value but not position */
+/** Drag of a range of automation data (either on an automation track or region gain),
+ *  changing value but not position.
+ */
 class AutomationRangeDrag : public Drag
 {
 public:
-       AutomationRangeDrag (Editor *, ArdourCanvas::Item *, std::list<ARDOUR::AudioRange> const &);
+       AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
+       AutomationRangeDrag (Editor *, AudioRegionView *, std::list<ARDOUR::AudioRange> const &);
 
        void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
        void motion (GdkEvent *, bool);
@@ -880,9 +953,15 @@ public:
                return false;
        }
 
+       bool active (Editing::MouseMode) {
+               return true;
+       }
+
 private:
+       void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
+        double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
+
        std::list<ARDOUR::AudioRange> _ranges;
-       AutomationTimeAxisView* _atav;
 
        /** A line that is part of the drag */
        struct Line {
@@ -890,12 +969,38 @@ private:
                std::list<ControlPoint*> points; ///< points to drag on the line
                std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
                XMLNode* state; ///< the XML state node before the drag
+               double original_fraction; ///< initial y-fraction before the drag
        };
 
        std::list<Line> _lines;
-
+        double y_origin;
        bool _nothing_to_drag;
 };
 
+/** Drag of one edge of an xfade
+ */
+class CrossfadeEdgeDrag : public Drag
+{
+  public:
+       CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
+
+       void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
+       void motion (GdkEvent*, bool);
+       void finished (GdkEvent*, bool);
+       void aborted (bool);
+       
+       bool y_movement_matters () const {
+               return false;
+       }
+
+       virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
+               return std::make_pair (4, 4);
+       }
+
+  private:
+       AudioRegionView* arv;
+       bool start;
+};
+
 #endif /* __gtk2_ardour_editor_drag_h_ */