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/tempo.h"
29 #include "ardour/types.h"
31 #include "canvas/types.h"
33 #include "cursor_context.h"
34 #include "editor_items.h"
35 #include "mouse_cursors.h"
42 namespace ArdourCanvas {
49 class StatefulDiffCommand;
56 class MidiTimeAxisView;
61 class RouteTimeAxisView;
62 class RegionSelection;
68 class AudioRegionView;
70 class AutomationTimeAxisView;
72 /** Class to manage current drags */
77 DragManager (Editor* e);
80 bool motion_handler (GdkEvent *, bool);
84 void set (Drag *, GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
85 void start_grab (GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
86 bool end_grab (GdkEvent *);
87 bool have_item (ArdourCanvas::Item *) const;
89 void mark_double_click ();
91 /** @return true if an end drag or abort is in progress */
92 bool ending () const {
96 bool active () const {
97 return !_drags.empty ();
100 /** @return current pointer x position in canvas coordinates */
101 double current_pointer_x () const {
102 return _current_pointer_x;
105 /** @return current pointer y position in canvas coordinates */
106 double current_pointer_y () const {
107 return _current_pointer_y;
110 /** @return current pointer frame */
111 ARDOUR::framepos_t current_pointer_frame () const {
112 return _current_pointer_frame;
117 std::list<Drag*> _drags;
118 bool _ending; ///< true if end_grab or abort is in progress, otherwise false
119 double _current_pointer_x; ///< canvas-coordinate space x of the current pointer
120 double _current_pointer_y; ///< canvas-coordinate space y of the current pointer
121 ARDOUR::framepos_t _current_pointer_frame; ///< frame that the pointer is now at
122 bool _old_follow_playhead; ///< state of Editor::follow_playhead() before the drags started
125 /** Abstract base class for dragging of things within the editor */
129 Drag (Editor *, ArdourCanvas::Item *, bool trackview_only = true);
132 void set_manager (DragManager* m) {
136 /** @return the canvas item being dragged */
137 ArdourCanvas::Item* item () const {
141 void swap_grab (ArdourCanvas::Item *, Gdk::Cursor *, uint32_t);
142 bool motion_handler (GdkEvent*, bool);
145 ARDOUR::framepos_t adjusted_frame (ARDOUR::framepos_t, GdkEvent const *, bool snap = true) const;
146 ARDOUR::framepos_t adjusted_current_frame (GdkEvent const *, bool snap = true) const;
148 bool was_double_click() const { return _was_double_click; }
149 void set_double_click (bool yn) { _was_double_click = yn; }
151 /** Called to start a grab of an item.
152 * @param e Event that caused the grab to start.
153 * @param c Cursor to use, or 0.
155 virtual void start_grab (GdkEvent* e, Gdk::Cursor* c = 0);
157 virtual bool end_grab (GdkEvent *);
159 /** Called when a drag motion has occurred.
160 * @param e Event describing the motion.
161 * @param f true if this is the first movement, otherwise false.
163 virtual void motion (GdkEvent* e, bool f) = 0;
165 /** Called when a drag has finished.
166 * @param e Event describing the finish.
167 * @param m true if some movement occurred, otherwise false.
169 virtual void finished (GdkEvent* e, bool m) = 0;
171 /** Called to abort a drag and return things to how
172 * they were before it started.
173 * @param m true if some movement occurred, otherwise false.
175 virtual void aborted (bool m) = 0;
177 /** @param m Mouse mode.
178 * @return true if this drag should happen in this mouse mode.
180 virtual bool active (Editing::MouseMode m) {
184 /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
185 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
186 return std::make_pair (1, 1);
189 virtual bool allow_vertical_autoscroll () const {
193 /** @return true if x movement matters to this drag */
194 virtual bool x_movement_matters () const {
198 /** @return true if y movement matters to this drag */
199 virtual bool y_movement_matters () const {
203 bool initially_vertical() const {
204 return _initially_vertical;
207 /** Set up the _pointer_frame_offset */
208 virtual void setup_pointer_frame_offset () {
209 _pointer_frame_offset = 0;
214 double grab_x () const {
218 double grab_y () const {
222 ARDOUR::framepos_t raw_grab_frame () const {
223 return _raw_grab_frame;
226 ARDOUR::framepos_t grab_frame () const {
230 double last_pointer_x () const {
231 return _last_pointer_x;
234 double last_pointer_y () const {
235 return _last_pointer_y;
238 ARDOUR::framepos_t last_pointer_frame () const {
239 return _last_pointer_frame;
242 ARDOUR::frameoffset_t snap_delta (guint const) const;
244 double current_pointer_x () const;
245 double current_pointer_y () const;
247 /* sets snap delta from unsnapped pos */
248 void setup_snap_delta (framepos_t pos);
250 boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*, bool commit);
252 void show_verbose_cursor_time (framepos_t);
253 void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0);
254 void show_verbose_cursor_text (std::string const &);
256 Editor* _editor; ///< our editor
258 ArdourCanvas::Item* _item; ///< our item
259 /** Offset from the mouse's position for the drag to the start of the thing that is being dragged */
260 ARDOUR::framecnt_t _pointer_frame_offset;
261 bool _x_constrained; ///< true if x motion is constrained, otherwise false
262 bool _y_constrained; ///< true if y motion is constrained, otherwise false
263 bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
266 bool _trackview_only; ///< true if pointer y value should always be relative to the top of the trackview group
267 bool _move_threshold_passed; ///< true if the move threshold has been passed, otherwise false
268 bool _starting_point_passed; ///< true if we called move () with first_move flag, otherwise false
269 bool _initially_vertical; ///< true if after move threshold is passed we appear to be moving vertically; undefined before that
270 bool _was_double_click; ///< true if drag initiated by a double click event
271 double _grab_x; ///< trackview x of the grab start position
272 double _grab_y; ///< y of the grab start position, possibly adjusted if _trackview_only is true
273 double _last_pointer_x; ///< trackview x of the pointer last time a motion occurred
274 double _last_pointer_y; ///< trackview y of the pointer last time a motion occurred
275 ARDOUR::framepos_t _raw_grab_frame; ///< unsnapped frame that the mouse was at when start_grab was called, or 0
276 ARDOUR::framepos_t _grab_frame; ///< adjusted_frame that the mouse was at when start_grab was called, or 0
277 ARDOUR::framepos_t _last_pointer_frame; ///< adjusted_frame the last time a motion occurred
279 /* difference between some key position's snapped and unsnapped
280 * framepos. used for relative snap.
282 ARDOUR::frameoffset_t _snap_delta;
283 CursorContext::Handle _cursor_ctx; ///< cursor change context
288 /** Container for details about a region being dragged */
292 DraggingView (RegionView *, RegionDrag *, TimeAxisView* original_tav);
294 RegionView* view; ///< the view
295 /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on,
296 * or -1 if it is not visible.
299 /** layer that this region is currently being displayed on. This is a double
300 rather than a layer_t as we use fractional layers during drags to allow the user
301 to indicate a new layer to put a region on.
304 double initial_y; ///< the initial y position of the view before any reparenting
305 framepos_t initial_position; ///< initial position of the region
306 framepos_t initial_end; ///< initial end position of the region
307 framepos_t anchored_fade_length; ///< fade_length when anchored during drag
308 boost::shared_ptr<ARDOUR::Playlist> initial_playlist;
309 TimeAxisView* initial_time_axis_view;
312 /** Abstract base class for drags that involve region(s) */
313 class RegionDrag : public Drag, public sigc::trackable
316 RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
317 virtual ~RegionDrag () {}
321 RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
322 std::list<DraggingView> _views; ///< information about all views that are being dragged
324 /** a list of the non-hidden TimeAxisViews sorted by editor order key */
325 std::vector<TimeAxisView*> _time_axis_views;
326 int find_time_axis_view (TimeAxisView *) const;
327 int apply_track_delta (const int start, const int delta, const int skip, const bool distance_only = false) const;
333 friend class DraggingView;
337 void region_going_away (RegionView *);
338 PBD::ScopedConnection death_connection;
342 /** Drags involving region motion from somewhere */
343 class RegionMotionDrag : public RegionDrag
347 RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
348 virtual ~RegionMotionDrag () {}
350 virtual void start_grab (GdkEvent *, Gdk::Cursor *);
351 virtual void motion (GdkEvent *, bool);
352 virtual void finished (GdkEvent *, bool);
353 virtual void aborted (bool);
355 /** @return true if the regions being `moved' came from somewhere on the canvas;
356 * false if they came from outside (e.g. from the region list).
358 virtual bool regions_came_from_canvas () const = 0;
362 double compute_x_delta (GdkEvent const *, ARDOUR::framepos_t *);
363 virtual bool y_movement_allowed (int, double, int skip_invisible = 0) const;
366 bool _ignore_video_lock;
367 ARDOUR::framepos_t _last_frame_position; ///< last position of the thing being dragged
368 double _total_x_delta;
369 int _last_pointer_time_axis_view;
370 double _last_pointer_layer;
378 /** Drags to move (or copy) regions that are already shown in the GUI to
379 * somewhere different.
381 class RegionMoveDrag : public RegionMotionDrag
384 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
385 virtual ~RegionMoveDrag () {}
387 void motion (GdkEvent *, bool);
388 void finished (GdkEvent *, bool);
391 bool regions_came_from_canvas () const {
395 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
396 return std::make_pair (4, 4);
399 void setup_pointer_frame_offset ();
402 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
403 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
406 void finished_no_copy (
409 ARDOUR::framecnt_t const
415 ARDOUR::framecnt_t const
418 RegionView* insert_region_into_playlist (
419 boost::shared_ptr<ARDOUR::Region>,
426 void remove_region_from_playlist (
427 boost::shared_ptr<ARDOUR::Region>,
428 boost::shared_ptr<ARDOUR::Playlist>,
429 PlaylistSet& modified_playlists
433 void collect_new_region_view (RegionView *);
434 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
437 RegionView* _new_region_view;
440 /** Drag to insert a region from somewhere */
441 class RegionInsertDrag : public RegionMotionDrag
444 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
446 void finished (GdkEvent *, bool);
449 bool regions_came_from_canvas () const {
454 /** Region drag in splice mode */
455 class RegionSpliceDrag : public RegionMoveDrag
458 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
460 void motion (GdkEvent *, bool);
461 void finished (GdkEvent *, bool);
465 /** Region drag in ripple mode */
467 class RegionRippleDrag : public RegionMoveDrag
470 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
471 ~RegionRippleDrag () { delete exclude; }
473 void motion (GdkEvent *, bool);
474 void finished (GdkEvent *, bool);
477 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
480 TimeAxisView *prev_tav; // where regions were most recently dragged from
481 TimeAxisView *orig_tav; // where drag started
482 ARDOUR::framecnt_t prev_amount;
483 ARDOUR::framepos_t prev_position;
484 ARDOUR::framecnt_t selection_length;
485 bool allow_moves_across_tracks; // only if all selected regions are on one track
486 ARDOUR::RegionList *exclude;
487 void add_all_after_to_views (TimeAxisView *tav, ARDOUR::framepos_t where, const RegionSelection &exclude, bool drag_in_progress);
488 void remove_unselected_from_views (ARDOUR::framecnt_t amount, bool move_regions);
492 /** "Drag" to cut a region (action only on button release) */
493 class RegionCutDrag : public Drag
496 RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
499 void motion (GdkEvent*, bool);
500 void finished (GdkEvent*, bool);
507 /** Drags to create regions */
508 class RegionCreateDrag : public Drag
511 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
513 void motion (GdkEvent *, bool);
514 void finished (GdkEvent *, bool);
518 MidiTimeAxisView* _view;
519 boost::shared_ptr<ARDOUR::Region> _region;
522 /** Drags to resize MIDI notes */
523 class NoteResizeDrag : public Drag
526 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
528 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
529 void motion (GdkEvent *, bool);
530 void finished (GdkEvent *, bool);
534 MidiRegionView* region;
541 /** Drags to move MIDI notes */
542 class NoteDrag : public Drag
545 NoteDrag (Editor*, ArdourCanvas::Item*);
547 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
548 void motion (GdkEvent *, bool);
549 void finished (GdkEvent *, bool);
554 ARDOUR::frameoffset_t total_dx (const guint) const;
555 int8_t total_dy () const;
557 MidiRegionView* _region;
559 double _cumulative_dx;
560 double _cumulative_dy;
565 class NoteCreateDrag : public Drag
568 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
571 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
572 void motion (GdkEvent *, bool);
573 void finished (GdkEvent *, bool);
576 bool active (Editing::MouseMode mode) {
577 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
580 bool y_movement_matters () const {
585 double y_to_region (double) const;
586 ARDOUR::framecnt_t grid_frames (framepos_t) const;
588 MidiRegionView* _region_view;
589 ArdourCanvas::Rectangle* _drag_rect;
593 /** Drag to move MIDI patch changes */
594 class PatchChangeDrag : public Drag
597 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
599 void motion (GdkEvent *, bool);
600 void finished (GdkEvent *, bool);
603 bool y_movement_matters () const {
607 void setup_pointer_frame_offset ();
610 MidiRegionView* _region_view;
611 PatchChange* _patch_change;
612 double _cumulative_dx;
615 /** Container for details about audio regions being dragged along with video */
619 AVDraggingView (RegionView *);
621 RegionView* view; ///< the view
622 framepos_t initial_position; ///< initial position of the region
625 /** Drag of video offset */
626 class VideoTimeLineDrag : public Drag
629 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
631 void motion (GdkEvent *, bool);
632 void finished (GdkEvent *, bool);
633 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
635 bool y_movement_matters () const {
639 bool allow_vertical_autoscroll () const {
646 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
649 ARDOUR::frameoffset_t _startdrag_video_offset;
650 ARDOUR::frameoffset_t _max_backwards_drag;
654 /** Drag to trim region(s) */
655 class TrimDrag : public RegionDrag
664 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
666 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
667 void motion (GdkEvent *, bool);
668 void finished (GdkEvent *, bool);
671 bool y_movement_matters () const {
675 void setup_pointer_frame_offset ();
679 Operation _operation;
681 bool _preserve_fade_anchor;
682 bool _jump_position_when_done;
685 /** Meter marker drag */
686 class MeterMarkerDrag : public Drag
689 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
691 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
692 void motion (GdkEvent *, bool);
693 void finished (GdkEvent *, bool);
696 bool allow_vertical_autoscroll () const {
700 bool y_movement_matters () const {
704 void setup_pointer_frame_offset ();
707 MeterMarker* _marker;
708 ARDOUR::MeterSection* _real_section;
711 XMLNode* before_state;
714 /** Tempo marker drag */
715 class TempoMarkerDrag : public Drag
718 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
720 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
721 void motion (GdkEvent *, bool);
722 void finished (GdkEvent *, bool);
725 bool allow_vertical_autoscroll () const {
729 bool y_movement_matters () const {
733 void setup_pointer_frame_offset ();
736 TempoMarker* _marker;
737 ARDOUR::TempoSection* _real_section;
741 XMLNode* before_state;
745 /** Drag of the playhead cursor */
746 class CursorDrag : public Drag
749 CursorDrag (Editor *, EditorCursor&, bool);
751 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
752 void motion (GdkEvent *, bool);
753 void finished (GdkEvent *, bool);
756 bool allow_vertical_autoscroll () const {
760 bool y_movement_matters () const {
765 void fake_locate (framepos_t);
767 EditorCursor& _cursor;
768 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
769 double _grab_zoom; ///< editor frames per unit when our grab started
772 /** Region fade-in drag */
773 class FadeInDrag : public RegionDrag
776 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
778 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
779 void motion (GdkEvent *, bool);
780 void finished (GdkEvent *, bool);
783 bool y_movement_matters () const {
787 void setup_pointer_frame_offset ();
790 /** Region fade-out drag */
791 class FadeOutDrag : public RegionDrag
794 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
796 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
797 void motion (GdkEvent *, bool);
798 void finished (GdkEvent *, bool);
801 bool y_movement_matters () const {
805 void setup_pointer_frame_offset ();
809 class MarkerDrag : public Drag
812 MarkerDrag (Editor *, ArdourCanvas::Item *);
815 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
816 void motion (GdkEvent *, bool);
817 void finished (GdkEvent *, bool);
820 bool allow_vertical_autoscroll () const {
824 bool y_movement_matters () const {
828 void setup_pointer_frame_offset ();
831 void update_item (ARDOUR::Location *);
833 ArdourMarker* _marker; ///< marker being dragged
834 bool _selection_changed;
835 struct CopiedLocationMarkerInfo {
836 ARDOUR::Location* location;
837 std::vector<ArdourMarker*> markers;
839 CopiedLocationMarkerInfo (ARDOUR::Location* l, ArdourMarker* m);
842 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
843 CopiedLocationInfo _copied_locations;
844 ArdourCanvas::Points _points;
847 /** Control point drag */
848 class ControlPointDrag : public Drag
851 ControlPointDrag (Editor *, ArdourCanvas::Item *);
853 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
854 void motion (GdkEvent *, bool);
855 void finished (GdkEvent *, bool);
858 bool active (Editing::MouseMode m);
862 ControlPoint* _point;
863 double _fixed_grab_x;
864 double _fixed_grab_y;
865 double _cumulative_x_drag;
866 double _cumulative_y_drag;
868 uint32_t _final_index;
869 static double _zero_gain_fraction;
872 /** Gain or automation line drag */
873 class LineDrag : public Drag
876 LineDrag (Editor *e, ArdourCanvas::Item *i);
878 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
879 void motion (GdkEvent *, bool);
880 void finished (GdkEvent *, bool);
885 AutomationLine* _line;
886 double _fixed_grab_x;
887 double _fixed_grab_y;
888 double _cumulative_y_drag;
893 /** Transient feature line drags*/
894 class FeatureLineDrag : public Drag
897 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
899 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
900 void motion (GdkEvent *, bool);
901 void finished (GdkEvent *, bool);
906 ArdourCanvas::Line* _line;
907 AudioRegionView* _arv;
909 double _region_view_grab_x;
910 double _cumulative_x_drag;
916 /** Dragging of a rubberband rectangle for selecting things */
917 class RubberbandSelectDrag : public Drag
920 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
922 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
923 void motion (GdkEvent *, bool);
924 void finished (GdkEvent *, bool);
927 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
928 return std::make_pair (8, 1);
931 void do_select_things (GdkEvent *, bool);
933 /** Select some things within a rectangle.
934 * @param button_state The button state from the GdkEvent.
935 * @param x1 The left-hand side of the rectangle in session frames.
936 * @param x2 The right-hand side of the rectangle in session frames.
937 * @param y1 The top of the rectangle in trackview coordinates.
938 * @param y2 The bottom of the rectangle in trackview coordinates.
939 * @param drag_in_progress true if the drag is currently happening.
941 virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
943 virtual void deselect_things () = 0;
949 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
950 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
953 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
955 void select_things (int, framepos_t, framepos_t, double, double, bool);
956 void deselect_things ();
959 /** A RubberbandSelectDrag for selecting MIDI notes */
960 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
963 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
965 void select_things (int, framepos_t, framepos_t, double, double, bool);
966 void deselect_things ();
969 MidiRegionView* _region_view;
972 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
973 class MidiVerticalSelectDrag : public RubberbandSelectDrag
976 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
978 void select_things (int, framepos_t, framepos_t, double, double, bool);
979 void deselect_things ();
982 MidiRegionView* _region_view;
985 /** Region drag in time-FX mode */
986 class TimeFXDrag : public RegionDrag
989 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
991 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
992 void motion (GdkEvent *, bool);
993 void finished (GdkEvent *, bool);
997 /** Scrub drag in audition mode */
998 class ScrubDrag : public Drag
1001 ScrubDrag (Editor *, ArdourCanvas::Item *);
1003 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1004 void motion (GdkEvent *, bool);
1005 void finished (GdkEvent *, bool);
1006 void aborted (bool);
1009 /** Drag in range select mode */
1010 class SelectionDrag : public Drag
1021 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
1023 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1024 void motion (GdkEvent *, bool);
1025 void finished (GdkEvent *, bool);
1026 void aborted (bool);
1028 void setup_pointer_frame_offset ();
1031 Operation _operation;
1033 std::list<TimeAxisView*> _added_time_axes;
1034 bool _time_selection_at_start;
1035 framepos_t start_at_start;
1036 framepos_t end_at_start;
1039 /** Range marker drag */
1040 class RangeMarkerBarDrag : public Drag
1046 CreateTransportMarker,
1050 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1051 ~RangeMarkerBarDrag ();
1053 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1054 void motion (GdkEvent *, bool);
1055 void finished (GdkEvent *, bool);
1056 void aborted (bool);
1058 bool allow_vertical_autoscroll () const {
1062 bool y_movement_matters () const {
1067 void update_item (ARDOUR::Location *);
1069 Operation _operation;
1070 ArdourCanvas::Rectangle* _drag_rect;
1074 /** Drag of rectangle to set zoom */
1075 class MouseZoomDrag : public Drag
1078 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1080 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1081 void motion (GdkEvent *, bool);
1082 void finished (GdkEvent *, bool);
1083 void aborted (bool);
1085 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1086 return std::make_pair (4, 4);
1093 /** Drag of a range of automation data (either on an automation track or region gain),
1094 * changing value but not position.
1096 class AutomationRangeDrag : public Drag
1099 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1100 AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &);
1102 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1103 void motion (GdkEvent *, bool);
1104 void finished (GdkEvent *, bool);
1105 void aborted (bool);
1107 bool x_movement_matters () const {
1112 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1113 double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
1114 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1116 std::list<ARDOUR::AudioRange> _ranges;
1118 /** A line that is part of the drag */
1120 boost::shared_ptr<AutomationLine> line; ///< the line
1121 std::list<ControlPoint*> points; ///< points to drag on the line
1122 std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
1123 XMLNode* state; ///< the XML state node before the drag
1124 double original_fraction; ///< initial y-fraction before the drag
1127 std::list<Line> _lines;
1129 bool _nothing_to_drag;
1133 /** Drag of one edge of an xfade
1135 class CrossfadeEdgeDrag : public Drag
1138 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1140 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1141 void motion (GdkEvent*, bool);
1142 void finished (GdkEvent*, bool);
1143 void aborted (bool);
1145 bool y_movement_matters () const {
1149 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1150 return std::make_pair (4, 4);
1154 AudioRegionView* arv;
1158 #endif /* __gtk2_ardour_editor_drag_h_ */