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*, bool commit);
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 bool _ignore_video_lock;
366 ARDOUR::framepos_t _last_frame_position; ///< last position of the thing being dragged
367 double _total_x_delta;
368 int _last_pointer_time_axis_view;
369 double _last_pointer_layer;
377 /** Drags to move (or copy) regions that are already shown in the GUI to
378 * somewhere different.
380 class RegionMoveDrag : public RegionMotionDrag
383 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
384 virtual ~RegionMoveDrag () {}
386 void motion (GdkEvent *, bool);
387 void finished (GdkEvent *, bool);
390 bool regions_came_from_canvas () const {
394 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
395 return std::make_pair (4, 4);
398 void setup_pointer_frame_offset ();
401 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
402 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
405 void finished_no_copy (
408 ARDOUR::framecnt_t const
414 ARDOUR::framecnt_t const
417 RegionView* insert_region_into_playlist (
418 boost::shared_ptr<ARDOUR::Region>,
425 void remove_region_from_playlist (
426 boost::shared_ptr<ARDOUR::Region>,
427 boost::shared_ptr<ARDOUR::Playlist>,
428 PlaylistSet& modified_playlists
432 void collect_new_region_view (RegionView *);
433 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
436 RegionView* _new_region_view;
439 /** Drag to insert a region from somewhere */
440 class RegionInsertDrag : public RegionMotionDrag
443 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
445 void finished (GdkEvent *, bool);
448 bool regions_came_from_canvas () const {
453 /** Region drag in splice mode */
454 class RegionSpliceDrag : public RegionMoveDrag
457 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
459 void motion (GdkEvent *, bool);
460 void finished (GdkEvent *, bool);
464 /** Region drag in ripple mode */
466 class RegionRippleDrag : public RegionMoveDrag
469 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
470 ~RegionRippleDrag () { delete exclude; }
472 void motion (GdkEvent *, bool);
473 void finished (GdkEvent *, bool);
476 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
479 TimeAxisView *prev_tav; // where regions were most recently dragged from
480 TimeAxisView *orig_tav; // where drag started
481 ARDOUR::framecnt_t prev_amount;
482 ARDOUR::framepos_t prev_position;
483 ARDOUR::framecnt_t selection_length;
484 bool allow_moves_across_tracks; // only if all selected regions are on one track
485 ARDOUR::RegionList *exclude;
486 void add_all_after_to_views (TimeAxisView *tav, ARDOUR::framepos_t where, const RegionSelection &exclude, bool drag_in_progress);
487 void remove_unselected_from_views (ARDOUR::framecnt_t amount, bool move_regions);
491 /** "Drag" to cut a region (action only on button release) */
492 class RegionCutDrag : public Drag
495 RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
498 void motion (GdkEvent*, bool);
499 void finished (GdkEvent*, bool);
506 /** Drags to create regions */
507 class RegionCreateDrag : public Drag
510 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
512 void motion (GdkEvent *, bool);
513 void finished (GdkEvent *, bool);
517 MidiTimeAxisView* _view;
518 boost::shared_ptr<ARDOUR::Region> _region;
521 /** Drags to resize MIDI notes */
522 class NoteResizeDrag : public Drag
525 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
527 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
528 void motion (GdkEvent *, bool);
529 void finished (GdkEvent *, bool);
533 MidiRegionView* region;
540 /** Drags to move MIDI notes */
541 class NoteDrag : public Drag
544 NoteDrag (Editor*, ArdourCanvas::Item*);
546 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
547 void motion (GdkEvent *, bool);
548 void finished (GdkEvent *, bool);
553 ARDOUR::frameoffset_t total_dx (const guint) const;
554 int8_t total_dy () const;
556 MidiRegionView* _region;
558 double _cumulative_dx;
559 double _cumulative_dy;
564 class NoteCreateDrag : public Drag
567 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
570 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
571 void motion (GdkEvent *, bool);
572 void finished (GdkEvent *, bool);
575 bool active (Editing::MouseMode mode) {
576 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
579 bool y_movement_matters () const {
584 double y_to_region (double) const;
585 ARDOUR::framecnt_t grid_frames (framepos_t) const;
587 MidiRegionView* _region_view;
588 ArdourCanvas::Rectangle* _drag_rect;
592 /** Drag to move MIDI patch changes */
593 class PatchChangeDrag : public Drag
596 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
598 void motion (GdkEvent *, bool);
599 void finished (GdkEvent *, bool);
602 bool y_movement_matters () const {
606 void setup_pointer_frame_offset ();
609 MidiRegionView* _region_view;
610 PatchChange* _patch_change;
611 double _cumulative_dx;
614 /** Container for details about audio regions being dragged along with video */
618 AVDraggingView (RegionView *);
620 RegionView* view; ///< the view
621 framepos_t initial_position; ///< initial position of the region
624 /** Drag of video offset */
625 class VideoTimeLineDrag : public Drag
628 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
630 void motion (GdkEvent *, bool);
631 void finished (GdkEvent *, bool);
632 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
634 bool y_movement_matters () const {
638 bool allow_vertical_autoscroll () const {
645 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
648 ARDOUR::frameoffset_t _startdrag_video_offset;
649 ARDOUR::frameoffset_t _max_backwards_drag;
653 /** Drag to trim region(s) */
654 class TrimDrag : public RegionDrag
663 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
665 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
666 void motion (GdkEvent *, bool);
667 void finished (GdkEvent *, bool);
670 bool y_movement_matters () const {
674 void setup_pointer_frame_offset ();
678 Operation _operation;
680 bool _preserve_fade_anchor;
681 bool _jump_position_when_done;
684 /** Meter marker drag */
685 class MeterMarkerDrag : public Drag
688 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
690 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
691 void motion (GdkEvent *, bool);
692 void finished (GdkEvent *, bool);
695 bool allow_vertical_autoscroll () const {
699 bool y_movement_matters () const {
703 void setup_pointer_frame_offset ();
706 MeterMarker* _marker;
708 XMLNode* before_state;
711 /** Tempo marker drag */
712 class TempoMarkerDrag : public Drag
715 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
717 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
718 void motion (GdkEvent *, bool);
719 void finished (GdkEvent *, bool);
722 bool allow_vertical_autoscroll () const {
726 bool y_movement_matters () const {
730 void setup_pointer_frame_offset ();
733 TempoMarker* _marker;
735 XMLNode* before_state;
739 /** Drag of the playhead cursor */
740 class CursorDrag : public Drag
743 CursorDrag (Editor *, EditorCursor&, bool);
745 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
746 void motion (GdkEvent *, bool);
747 void finished (GdkEvent *, bool);
750 bool allow_vertical_autoscroll () const {
754 bool y_movement_matters () const {
759 void fake_locate (framepos_t);
761 EditorCursor& _cursor;
762 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
763 double _grab_zoom; ///< editor frames per unit when our grab started
766 /** Region fade-in drag */
767 class FadeInDrag : public RegionDrag
770 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
772 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
773 void motion (GdkEvent *, bool);
774 void finished (GdkEvent *, bool);
777 bool y_movement_matters () const {
781 void setup_pointer_frame_offset ();
784 /** Region fade-out drag */
785 class FadeOutDrag : public RegionDrag
788 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
790 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
791 void motion (GdkEvent *, bool);
792 void finished (GdkEvent *, bool);
795 bool y_movement_matters () const {
799 void setup_pointer_frame_offset ();
803 class MarkerDrag : public Drag
806 MarkerDrag (Editor *, ArdourCanvas::Item *);
809 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
810 void motion (GdkEvent *, bool);
811 void finished (GdkEvent *, bool);
814 bool allow_vertical_autoscroll () const {
818 bool y_movement_matters () const {
822 void setup_pointer_frame_offset ();
825 void update_item (ARDOUR::Location *);
827 ArdourMarker* _marker; ///< marker being dragged
828 bool _selection_changed;
829 struct CopiedLocationMarkerInfo {
830 ARDOUR::Location* location;
831 std::vector<ArdourMarker*> markers;
833 CopiedLocationMarkerInfo (ARDOUR::Location* l, ArdourMarker* m);
836 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
837 CopiedLocationInfo _copied_locations;
838 ArdourCanvas::Points _points;
841 /** Control point drag */
842 class ControlPointDrag : public Drag
845 ControlPointDrag (Editor *, ArdourCanvas::Item *);
847 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
848 void motion (GdkEvent *, bool);
849 void finished (GdkEvent *, bool);
852 bool active (Editing::MouseMode m);
856 ControlPoint* _point;
857 double _fixed_grab_x;
858 double _fixed_grab_y;
859 double _cumulative_x_drag;
860 double _cumulative_y_drag;
862 uint32_t _final_index;
863 static double _zero_gain_fraction;
866 /** Gain or automation line drag */
867 class LineDrag : public Drag
870 LineDrag (Editor *e, ArdourCanvas::Item *i);
872 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
873 void motion (GdkEvent *, bool);
874 void finished (GdkEvent *, bool);
879 AutomationLine* _line;
880 double _fixed_grab_x;
881 double _fixed_grab_y;
882 double _cumulative_y_drag;
887 /** Transient feature line drags*/
888 class FeatureLineDrag : public Drag
891 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
893 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
894 void motion (GdkEvent *, bool);
895 void finished (GdkEvent *, bool);
900 ArdourCanvas::Line* _line;
901 AudioRegionView* _arv;
903 double _region_view_grab_x;
904 double _cumulative_x_drag;
910 /** Dragging of a rubberband rectangle for selecting things */
911 class RubberbandSelectDrag : public Drag
914 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
916 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
917 void motion (GdkEvent *, bool);
918 void finished (GdkEvent *, bool);
921 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
922 return std::make_pair (8, 1);
925 void do_select_things (GdkEvent *, bool);
927 /** Select some things within a rectangle.
928 * @param button_state The button state from the GdkEvent.
929 * @param x1 The left-hand side of the rectangle in session frames.
930 * @param x2 The right-hand side of the rectangle in session frames.
931 * @param y1 The top of the rectangle in trackview coordinates.
932 * @param y2 The bottom of the rectangle in trackview coordinates.
933 * @param drag_in_progress true if the drag is currently happening.
935 virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
937 virtual void deselect_things () = 0;
943 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
944 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
947 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
949 void select_things (int, framepos_t, framepos_t, double, double, bool);
950 void deselect_things ();
953 /** A RubberbandSelectDrag for selecting MIDI notes */
954 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
957 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
959 void select_things (int, framepos_t, framepos_t, double, double, bool);
960 void deselect_things ();
963 MidiRegionView* _region_view;
966 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
967 class MidiVerticalSelectDrag : public RubberbandSelectDrag
970 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
972 void select_things (int, framepos_t, framepos_t, double, double, bool);
973 void deselect_things ();
976 MidiRegionView* _region_view;
979 /** Region drag in time-FX mode */
980 class TimeFXDrag : public RegionDrag
983 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
985 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
986 void motion (GdkEvent *, bool);
987 void finished (GdkEvent *, bool);
991 /** Scrub drag in audition mode */
992 class ScrubDrag : public Drag
995 ScrubDrag (Editor *, ArdourCanvas::Item *);
997 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
998 void motion (GdkEvent *, bool);
999 void finished (GdkEvent *, bool);
1000 void aborted (bool);
1003 /** Drag in range select mode */
1004 class SelectionDrag : public Drag
1015 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
1017 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1018 void motion (GdkEvent *, bool);
1019 void finished (GdkEvent *, bool);
1020 void aborted (bool);
1022 void setup_pointer_frame_offset ();
1025 Operation _operation;
1027 std::list<TimeAxisView*> _added_time_axes;
1028 bool _time_selection_at_start;
1029 framepos_t start_at_start;
1030 framepos_t end_at_start;
1033 /** Range marker drag */
1034 class RangeMarkerBarDrag : public Drag
1040 CreateTransportMarker,
1044 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1045 ~RangeMarkerBarDrag ();
1047 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1048 void motion (GdkEvent *, bool);
1049 void finished (GdkEvent *, bool);
1050 void aborted (bool);
1052 bool allow_vertical_autoscroll () const {
1056 bool y_movement_matters () const {
1061 void update_item (ARDOUR::Location *);
1063 Operation _operation;
1064 ArdourCanvas::Rectangle* _drag_rect;
1068 /** Drag of rectangle to set zoom */
1069 class MouseZoomDrag : public Drag
1072 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1074 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1075 void motion (GdkEvent *, bool);
1076 void finished (GdkEvent *, bool);
1077 void aborted (bool);
1079 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1080 return std::make_pair (4, 4);
1087 /** Drag of a range of automation data (either on an automation track or region gain),
1088 * changing value but not position.
1090 class AutomationRangeDrag : public Drag
1093 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1094 AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &);
1096 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1097 void motion (GdkEvent *, bool);
1098 void finished (GdkEvent *, bool);
1099 void aborted (bool);
1101 bool x_movement_matters () const {
1106 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1107 double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
1108 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1110 std::list<ARDOUR::AudioRange> _ranges;
1112 /** A line that is part of the drag */
1114 boost::shared_ptr<AutomationLine> line; ///< the line
1115 std::list<ControlPoint*> points; ///< points to drag on the line
1116 std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
1117 XMLNode* state; ///< the XML state node before the drag
1118 double original_fraction; ///< initial y-fraction before the drag
1121 std::list<Line> _lines;
1123 bool _nothing_to_drag;
1127 /** Drag of one edge of an xfade
1129 class CrossfadeEdgeDrag : public Drag
1132 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1134 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1135 void motion (GdkEvent*, bool);
1136 void finished (GdkEvent*, bool);
1137 void aborted (bool);
1139 bool y_movement_matters () const {
1143 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1144 return std::make_pair (4, 4);
1148 AudioRegionView* arv;
1152 #endif /* __gtk2_ardour_editor_drag_h_ */