2 Copyright (C) 2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __gtk2_ardour_editor_drag_h_
21 #define __gtk2_ardour_editor_drag_h_
28 #include "ardour/types.h"
30 #include "canvas/types.h"
32 #include "cursor_context.h"
33 #include "editor_items.h"
34 #include "mouse_cursors.h"
41 namespace ArdourCanvas {
48 class StatefulDiffCommand;
55 class MidiTimeAxisView;
60 class RouteTimeAxisView;
61 class RegionSelection;
67 class AudioRegionView;
69 class AutomationTimeAxisView;
71 /** Class to manage current drags */
76 DragManager (Editor* e);
79 bool motion_handler (GdkEvent *, bool);
83 void set (Drag *, GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
84 void start_grab (GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
85 bool end_grab (GdkEvent *);
86 bool have_item (ArdourCanvas::Item *) const;
88 void mark_double_click ();
90 /** @return true if an end drag or abort is in progress */
91 bool ending () const {
95 bool active () const {
96 return !_drags.empty ();
99 /** @return current pointer x position in canvas coordinates */
100 double current_pointer_x () const {
101 return _current_pointer_x;
104 /** @return current pointer y position in canvas coordinates */
105 double current_pointer_y () const {
106 return _current_pointer_y;
109 /** @return current pointer frame */
110 ARDOUR::framepos_t current_pointer_frame () const {
111 return _current_pointer_frame;
116 std::list<Drag*> _drags;
117 bool _ending; ///< true if end_grab or abort is in progress, otherwise false
118 double _current_pointer_x; ///< canvas-coordinate space x of the current pointer
119 double _current_pointer_y; ///< canvas-coordinate space y of the current pointer
120 ARDOUR::framepos_t _current_pointer_frame; ///< frame that the pointer is now at
121 bool _old_follow_playhead; ///< state of Editor::follow_playhead() before the drags started
124 /** Abstract base class for dragging of things within the editor */
128 Drag (Editor *, ArdourCanvas::Item *, bool trackview_only = true);
131 void set_manager (DragManager* m) {
135 /** @return the canvas item being dragged */
136 ArdourCanvas::Item* item () const {
140 void swap_grab (ArdourCanvas::Item *, Gdk::Cursor *, uint32_t);
141 bool motion_handler (GdkEvent*, bool);
144 ARDOUR::framepos_t adjusted_frame (ARDOUR::framepos_t, GdkEvent const *, bool snap = true) const;
145 ARDOUR::framepos_t adjusted_current_frame (GdkEvent const *, bool snap = true) const;
147 bool was_double_click() const { return _was_double_click; }
148 void set_double_click (bool yn) { _was_double_click = yn; }
150 /** Called to start a grab of an item.
151 * @param e Event that caused the grab to start.
152 * @param c Cursor to use, or 0.
154 virtual void start_grab (GdkEvent* e, Gdk::Cursor* c = 0);
156 virtual bool end_grab (GdkEvent *);
158 /** Called when a drag motion has occurred.
159 * @param e Event describing the motion.
160 * @param f true if this is the first movement, otherwise false.
162 virtual void motion (GdkEvent* e, bool f) = 0;
164 /** Called when a drag has finished.
165 * @param e Event describing the finish.
166 * @param m true if some movement occurred, otherwise false.
168 virtual void finished (GdkEvent* e, bool m) = 0;
170 /** Called to abort a drag and return things to how
171 * they were before it started.
172 * @param m true if some movement occurred, otherwise false.
174 virtual void aborted (bool m) = 0;
176 /** @param m Mouse mode.
177 * @return true if this drag should happen in this mouse mode.
179 virtual bool active (Editing::MouseMode m) {
183 /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
184 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
185 return std::make_pair (1, 1);
188 virtual bool allow_vertical_autoscroll () const {
192 /** @return true if x movement matters to this drag */
193 virtual bool x_movement_matters () const {
197 /** @return true if y movement matters to this drag */
198 virtual bool y_movement_matters () const {
202 bool initially_vertical() const {
203 return _initially_vertical;
206 /** Set up the _pointer_frame_offset */
207 virtual void setup_pointer_frame_offset () {
208 _pointer_frame_offset = 0;
213 double grab_x () const {
217 double grab_y () const {
221 ARDOUR::framepos_t raw_grab_frame () const {
222 return _raw_grab_frame;
225 ARDOUR::framepos_t grab_frame () const {
229 double last_pointer_x () const {
230 return _last_pointer_x;
233 double last_pointer_y () const {
234 return _last_pointer_y;
237 ARDOUR::framepos_t last_pointer_frame () const {
238 return _last_pointer_frame;
241 ARDOUR::frameoffset_t snap_delta (guint const) const;
243 double current_pointer_x () const;
244 double current_pointer_y () const;
246 /* sets snap delta from unsnapped pos */
247 void setup_snap_delta (framepos_t pos);
249 boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*);
251 void show_verbose_cursor_time (framepos_t);
252 void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0);
253 void show_verbose_cursor_text (std::string const &);
255 Editor* _editor; ///< our editor
257 ArdourCanvas::Item* _item; ///< our item
258 /** Offset from the mouse's position for the drag to the start of the thing that is being dragged */
259 ARDOUR::framecnt_t _pointer_frame_offset;
260 bool _x_constrained; ///< true if x motion is constrained, otherwise false
261 bool _y_constrained; ///< true if y motion is constrained, otherwise false
262 bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
265 bool _trackview_only; ///< true if pointer y value should always be relative to the top of the trackview group
266 bool _move_threshold_passed; ///< true if the move threshold has been passed, otherwise false
267 bool _starting_point_passed; ///< true if we called move () with first_move flag, otherwise false
268 bool _initially_vertical; ///< true if after move threshold is passed we appear to be moving vertically; undefined before that
269 bool _was_double_click; ///< true if drag initiated by a double click event
270 double _grab_x; ///< trackview x of the grab start position
271 double _grab_y; ///< y of the grab start position, possibly adjusted if _trackview_only is true
272 double _last_pointer_x; ///< trackview x of the pointer last time a motion occurred
273 double _last_pointer_y; ///< trackview y of the pointer last time a motion occurred
274 ARDOUR::framepos_t _raw_grab_frame; ///< unsnapped frame that the mouse was at when start_grab was called, or 0
275 ARDOUR::framepos_t _grab_frame; ///< adjusted_frame that the mouse was at when start_grab was called, or 0
276 ARDOUR::framepos_t _last_pointer_frame; ///< adjusted_frame the last time a motion occurred
278 /* difference between some key position's snapped and unsnapped
279 * framepos. used for relative snap.
281 ARDOUR::frameoffset_t _snap_delta;
282 CursorContext::Handle _cursor_ctx; ///< cursor change context
287 /** Container for details about a region being dragged */
291 DraggingView (RegionView *, RegionDrag *, TimeAxisView* original_tav);
293 RegionView* view; ///< the view
294 /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on,
295 * or -1 if it is not visible.
298 /** layer that this region is currently being displayed on. This is a double
299 rather than a layer_t as we use fractional layers during drags to allow the user
300 to indicate a new layer to put a region on.
303 double initial_y; ///< the initial y position of the view before any reparenting
304 framepos_t initial_position; ///< initial position of the region
305 framepos_t initial_end; ///< initial end position of the region
306 framepos_t anchored_fade_length; ///< fade_length when anchored during drag
307 boost::shared_ptr<ARDOUR::Playlist> initial_playlist;
308 TimeAxisView* initial_time_axis_view;
311 /** Abstract base class for drags that involve region(s) */
312 class RegionDrag : public Drag, public sigc::trackable
315 RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
316 virtual ~RegionDrag () {}
320 RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
321 std::list<DraggingView> _views; ///< information about all views that are being dragged
323 /** a list of the non-hidden TimeAxisViews sorted by editor order key */
324 std::vector<TimeAxisView*> _time_axis_views;
325 int find_time_axis_view (TimeAxisView *) const;
326 int apply_track_delta (const int start, const int delta, const int skip, const bool distance_only = false) const;
332 friend class DraggingView;
336 void region_going_away (RegionView *);
337 PBD::ScopedConnection death_connection;
341 /** Drags involving region motion from somewhere */
342 class RegionMotionDrag : public RegionDrag
346 RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
347 virtual ~RegionMotionDrag () {}
349 virtual void start_grab (GdkEvent *, Gdk::Cursor *);
350 virtual void motion (GdkEvent *, bool);
351 virtual void finished (GdkEvent *, bool);
352 virtual void aborted (bool);
354 /** @return true if the regions being `moved' came from somewhere on the canvas;
355 * false if they came from outside (e.g. from the region list).
357 virtual bool regions_came_from_canvas () const = 0;
361 double compute_x_delta (GdkEvent const *, ARDOUR::framepos_t *);
362 virtual bool y_movement_allowed (int, double, int skip_invisible = 0) const;
365 ARDOUR::framepos_t _last_frame_position; ///< last position of the thing being dragged
366 double _total_x_delta;
367 int _last_pointer_time_axis_view;
368 double _last_pointer_layer;
376 /** Drags to move (or copy) regions that are already shown in the GUI to
377 * somewhere different.
379 class RegionMoveDrag : public RegionMotionDrag
382 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
383 virtual ~RegionMoveDrag () {}
385 void motion (GdkEvent *, bool);
386 void finished (GdkEvent *, bool);
389 bool regions_came_from_canvas () const {
393 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
394 return std::make_pair (4, 4);
397 void setup_pointer_frame_offset ();
400 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
401 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
404 void finished_no_copy (
407 ARDOUR::framecnt_t const
413 ARDOUR::framecnt_t const
416 RegionView* insert_region_into_playlist (
417 boost::shared_ptr<ARDOUR::Region>,
424 void remove_region_from_playlist (
425 boost::shared_ptr<ARDOUR::Region>,
426 boost::shared_ptr<ARDOUR::Playlist>,
427 PlaylistSet& modified_playlists
431 void collect_new_region_view (RegionView *);
432 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
435 RegionView* _new_region_view;
438 /** Drag to insert a region from somewhere */
439 class RegionInsertDrag : public RegionMotionDrag
442 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
444 void finished (GdkEvent *, bool);
447 bool regions_came_from_canvas () const {
452 /** Region drag in splice mode */
453 class RegionSpliceDrag : public RegionMoveDrag
456 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
458 void motion (GdkEvent *, bool);
459 void finished (GdkEvent *, bool);
463 /** Region drag in ripple mode */
465 class RegionRippleDrag : public RegionMoveDrag
468 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
469 ~RegionRippleDrag () { delete exclude; }
471 void motion (GdkEvent *, bool);
472 void finished (GdkEvent *, bool);
475 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
478 TimeAxisView *prev_tav; // where regions were most recently dragged from
479 TimeAxisView *orig_tav; // where drag started
480 ARDOUR::framecnt_t prev_amount;
481 ARDOUR::framepos_t prev_position;
482 ARDOUR::framecnt_t selection_length;
483 bool allow_moves_across_tracks; // only if all selected regions are on one track
484 ARDOUR::RegionList *exclude;
485 void add_all_after_to_views (TimeAxisView *tav, ARDOUR::framepos_t where, const RegionSelection &exclude, bool drag_in_progress);
486 void remove_unselected_from_views (ARDOUR::framecnt_t amount, bool move_regions);
490 /** "Drag" to cut a region (action only on button release) */
491 class RegionCutDrag : public Drag
494 RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
497 void motion (GdkEvent*, bool);
498 void finished (GdkEvent*, bool);
505 /** Drags to create regions */
506 class RegionCreateDrag : public Drag
509 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
511 void motion (GdkEvent *, bool);
512 void finished (GdkEvent *, bool);
516 MidiTimeAxisView* _view;
517 boost::shared_ptr<ARDOUR::Region> _region;
520 /** Drags to resize MIDI notes */
521 class NoteResizeDrag : public Drag
524 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
526 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
527 void motion (GdkEvent *, bool);
528 void finished (GdkEvent *, bool);
532 MidiRegionView* region;
538 /** Drags to move MIDI notes */
539 class NoteDrag : public Drag
542 NoteDrag (Editor*, ArdourCanvas::Item*);
544 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
545 void motion (GdkEvent *, bool);
546 void finished (GdkEvent *, bool);
551 ARDOUR::frameoffset_t total_dx (const guint) const;
552 int8_t total_dy () const;
554 MidiRegionView* _region;
556 double _cumulative_dx;
557 double _cumulative_dy;
562 class NoteCreateDrag : public Drag
565 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
568 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
569 void motion (GdkEvent *, bool);
570 void finished (GdkEvent *, bool);
573 bool active (Editing::MouseMode mode) {
574 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
577 bool y_movement_matters () const {
582 double y_to_region (double) const;
583 ARDOUR::framecnt_t grid_frames (framepos_t) const;
585 MidiRegionView* _region_view;
586 ArdourCanvas::Rectangle* _drag_rect;
590 /** Drag to move MIDI patch changes */
591 class PatchChangeDrag : public Drag
594 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
596 void motion (GdkEvent *, bool);
597 void finished (GdkEvent *, bool);
600 bool y_movement_matters () const {
604 void setup_pointer_frame_offset ();
607 MidiRegionView* _region_view;
608 PatchChange* _patch_change;
609 double _cumulative_dx;
612 /** Container for details about audio regions being dragged along with video */
616 AVDraggingView (RegionView *);
618 RegionView* view; ///< the view
619 framepos_t initial_position; ///< initial position of the region
622 /** Drag of video offset */
623 class VideoTimeLineDrag : public Drag
626 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
628 void motion (GdkEvent *, bool);
629 void finished (GdkEvent *, bool);
630 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
632 bool y_movement_matters () const {
636 bool allow_vertical_autoscroll () const {
643 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
646 ARDOUR::frameoffset_t _startdrag_video_offset;
647 ARDOUR::frameoffset_t _max_backwards_drag;
650 /** Drag to trim region(s) */
651 class TrimDrag : public RegionDrag
660 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
662 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
663 void motion (GdkEvent *, bool);
664 void finished (GdkEvent *, bool);
667 bool y_movement_matters () const {
671 void setup_pointer_frame_offset ();
675 Operation _operation;
677 bool _preserve_fade_anchor;
678 bool _jump_position_when_done;
681 /** Meter marker drag */
682 class MeterMarkerDrag : public Drag
685 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
687 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
688 void motion (GdkEvent *, bool);
689 void finished (GdkEvent *, bool);
692 bool allow_vertical_autoscroll () const {
696 bool y_movement_matters () const {
700 void setup_pointer_frame_offset ();
703 MeterMarker* _marker;
705 XMLNode* before_state;
708 /** Tempo marker drag */
709 class TempoMarkerDrag : public Drag
712 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
714 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
715 void motion (GdkEvent *, bool);
716 void finished (GdkEvent *, bool);
719 bool allow_vertical_autoscroll () const {
723 bool y_movement_matters () const {
727 void setup_pointer_frame_offset ();
730 TempoMarker* _marker;
732 XMLNode* before_state;
736 /** Drag of the playhead cursor */
737 class CursorDrag : public Drag
740 CursorDrag (Editor *, EditorCursor&, bool);
742 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
743 void motion (GdkEvent *, bool);
744 void finished (GdkEvent *, bool);
747 bool allow_vertical_autoscroll () const {
751 bool y_movement_matters () const {
756 void fake_locate (framepos_t);
758 EditorCursor& _cursor;
759 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
760 double _grab_zoom; ///< editor frames per unit when our grab started
763 /** Region fade-in drag */
764 class FadeInDrag : public RegionDrag
767 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
769 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
770 void motion (GdkEvent *, bool);
771 void finished (GdkEvent *, bool);
774 bool y_movement_matters () const {
778 void setup_pointer_frame_offset ();
781 /** Region fade-out drag */
782 class FadeOutDrag : public RegionDrag
785 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
787 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
788 void motion (GdkEvent *, bool);
789 void finished (GdkEvent *, bool);
792 bool y_movement_matters () const {
796 void setup_pointer_frame_offset ();
800 class MarkerDrag : public Drag
803 MarkerDrag (Editor *, ArdourCanvas::Item *);
806 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
807 void motion (GdkEvent *, bool);
808 void finished (GdkEvent *, bool);
811 bool allow_vertical_autoscroll () const {
815 bool y_movement_matters () const {
819 void setup_pointer_frame_offset ();
822 void update_item (ARDOUR::Location *);
824 Marker* _marker; ///< marker being dragged
826 struct CopiedLocationMarkerInfo {
827 ARDOUR::Location* location;
828 std::vector<Marker*> markers;
830 CopiedLocationMarkerInfo (ARDOUR::Location* l, Marker* m);
833 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
834 CopiedLocationInfo _copied_locations;
835 ArdourCanvas::Points _points;
838 /** Control point drag */
839 class ControlPointDrag : public Drag
842 ControlPointDrag (Editor *, ArdourCanvas::Item *);
844 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
845 void motion (GdkEvent *, bool);
846 void finished (GdkEvent *, bool);
849 bool active (Editing::MouseMode m);
853 ControlPoint* _point;
854 double _fixed_grab_x;
855 double _fixed_grab_y;
856 double _cumulative_x_drag;
857 double _cumulative_y_drag;
859 uint32_t _final_index;
860 static double _zero_gain_fraction;
863 /** Gain or automation line drag */
864 class LineDrag : public Drag
867 LineDrag (Editor *e, ArdourCanvas::Item *i);
869 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
870 void motion (GdkEvent *, bool);
871 void finished (GdkEvent *, bool);
876 AutomationLine* _line;
877 double _fixed_grab_x;
878 double _fixed_grab_y;
879 double _cumulative_y_drag;
884 /** Transient feature line drags*/
885 class FeatureLineDrag : public Drag
888 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
890 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
891 void motion (GdkEvent *, bool);
892 void finished (GdkEvent *, bool);
897 ArdourCanvas::Line* _line;
898 AudioRegionView* _arv;
900 double _region_view_grab_x;
901 double _cumulative_x_drag;
907 /** Dragging of a rubberband rectangle for selecting things */
908 class RubberbandSelectDrag : public Drag
911 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
913 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
914 void motion (GdkEvent *, bool);
915 void finished (GdkEvent *, bool);
918 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
919 return std::make_pair (8, 1);
922 void do_select_things (GdkEvent *, bool);
924 /** Select some things within a rectangle.
925 * @param button_state The button state from the GdkEvent.
926 * @param x1 The left-hand side of the rectangle in session frames.
927 * @param x2 The right-hand side of the rectangle in session frames.
928 * @param y1 The top of the rectangle in trackview coordinates.
929 * @param y2 The bottom of the rectangle in trackview coordinates.
930 * @param drag_in_progress true if the drag is currently happening.
932 virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
934 virtual void deselect_things () = 0;
940 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
941 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
944 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
946 void select_things (int, framepos_t, framepos_t, double, double, bool);
947 void deselect_things ();
950 /** A RubberbandSelectDrag for selecting MIDI notes */
951 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
954 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
956 void select_things (int, framepos_t, framepos_t, double, double, bool);
957 void deselect_things ();
960 MidiRegionView* _region_view;
963 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
964 class MidiVerticalSelectDrag : public RubberbandSelectDrag
967 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
969 void select_things (int, framepos_t, framepos_t, double, double, bool);
970 void deselect_things ();
973 MidiRegionView* _region_view;
976 /** Region drag in time-FX mode */
977 class TimeFXDrag : public RegionDrag
980 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
982 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
983 void motion (GdkEvent *, bool);
984 void finished (GdkEvent *, bool);
988 /** Scrub drag in audition mode */
989 class ScrubDrag : public Drag
992 ScrubDrag (Editor *, ArdourCanvas::Item *);
994 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
995 void motion (GdkEvent *, bool);
996 void finished (GdkEvent *, bool);
1000 /** Drag in range select mode */
1001 class SelectionDrag : public Drag
1012 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
1014 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1015 void motion (GdkEvent *, bool);
1016 void finished (GdkEvent *, bool);
1017 void aborted (bool);
1019 void setup_pointer_frame_offset ();
1022 Operation _operation;
1024 std::list<TimeAxisView*> _added_time_axes;
1025 bool _time_selection_at_start;
1026 framepos_t start_at_start;
1027 framepos_t end_at_start;
1030 /** Range marker drag */
1031 class RangeMarkerBarDrag : public Drag
1037 CreateTransportMarker,
1041 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1042 ~RangeMarkerBarDrag ();
1044 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1045 void motion (GdkEvent *, bool);
1046 void finished (GdkEvent *, bool);
1047 void aborted (bool);
1049 bool allow_vertical_autoscroll () const {
1053 bool y_movement_matters () const {
1058 void update_item (ARDOUR::Location *);
1060 Operation _operation;
1061 ArdourCanvas::Rectangle* _drag_rect;
1065 /** Drag of rectangle to set zoom */
1066 class MouseZoomDrag : public Drag
1069 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1071 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1072 void motion (GdkEvent *, bool);
1073 void finished (GdkEvent *, bool);
1074 void aborted (bool);
1076 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1077 return std::make_pair (4, 4);
1084 /** Drag of a range of automation data (either on an automation track or region gain),
1085 * changing value but not position.
1087 class AutomationRangeDrag : public Drag
1090 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1091 AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &);
1093 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1094 void motion (GdkEvent *, bool);
1095 void finished (GdkEvent *, bool);
1096 void aborted (bool);
1098 bool x_movement_matters () const {
1103 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1104 double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
1105 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1107 std::list<ARDOUR::AudioRange> _ranges;
1109 /** A line that is part of the drag */
1111 boost::shared_ptr<AutomationLine> line; ///< the line
1112 std::list<ControlPoint*> points; ///< points to drag on the line
1113 std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
1114 XMLNode* state; ///< the XML state node before the drag
1115 double original_fraction; ///< initial y-fraction before the drag
1118 std::list<Line> _lines;
1120 bool _nothing_to_drag;
1124 /** Drag of one edge of an xfade
1126 class CrossfadeEdgeDrag : public Drag
1129 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1131 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1132 void motion (GdkEvent*, bool);
1133 void finished (GdkEvent*, bool);
1134 void aborted (bool);
1136 bool y_movement_matters () const {
1140 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1141 return std::make_pair (4, 4);
1145 AudioRegionView* arv;
1149 #endif /* __gtk2_ardour_editor_drag_h_ */