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 "cursor_context.h"
31 #include "editor_items.h"
32 #include "mouse_cursors.h"
39 class StatefulDiffCommand;
46 class MidiTimeAxisView;
50 /** Class to manage current drags */
55 DragManager (Editor* e);
58 bool motion_handler (GdkEvent *, bool);
62 void set (Drag *, GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
63 void start_grab (GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
64 bool end_grab (GdkEvent *);
65 bool have_item (ArdourCanvas::Item *) const;
67 void mark_double_click ();
69 /** @return true if an end drag or abort is in progress */
70 bool ending () const {
74 bool active () const {
75 return !_drags.empty ();
78 /** @return current pointer x position in canvas coordinates */
79 double current_pointer_x () const {
80 return _current_pointer_x;
83 /** @return current pointer y position in canvas coordinates */
84 double current_pointer_y () const {
85 return _current_pointer_y;
88 /** @return current pointer frame */
89 ARDOUR::framepos_t current_pointer_frame () const {
90 return _current_pointer_frame;
95 std::list<Drag*> _drags;
96 bool _ending; ///< true if end_grab or abort is in progress, otherwise false
97 double _current_pointer_x; ///< canvas-coordinate space x of the current pointer
98 double _current_pointer_y; ///< canvas-coordinate space y of the current pointer
99 ARDOUR::framepos_t _current_pointer_frame; ///< frame that the pointer is now at
100 bool _old_follow_playhead; ///< state of Editor::follow_playhead() before the drags started
103 /** Abstract base class for dragging of things within the editor */
107 Drag (Editor *, ArdourCanvas::Item *, bool trackview_only = true);
110 void set_manager (DragManager* m) {
114 /** @return the canvas item being dragged */
115 ArdourCanvas::Item* item () const {
119 void swap_grab (ArdourCanvas::Item *, Gdk::Cursor *, uint32_t);
120 bool motion_handler (GdkEvent*, bool);
123 ARDOUR::framepos_t adjusted_frame (ARDOUR::framepos_t, GdkEvent const *, bool snap = true) const;
124 ARDOUR::framepos_t adjusted_current_frame (GdkEvent const *, bool snap = true) const;
126 bool was_double_click() const { return _was_double_click; }
127 void set_double_click (bool yn) { _was_double_click = yn; }
129 /** Called to start a grab of an item.
130 * @param e Event that caused the grab to start.
131 * @param c Cursor to use, or 0.
133 virtual void start_grab (GdkEvent* e, Gdk::Cursor* c = 0);
135 virtual bool end_grab (GdkEvent *);
137 /** Called when a drag motion has occurred.
138 * @param e Event describing the motion.
139 * @param f true if this is the first movement, otherwise false.
141 virtual void motion (GdkEvent* e, bool f) = 0;
143 /** Called when a drag has finished.
144 * @param e Event describing the finish.
145 * @param m true if some movement occurred, otherwise false.
147 virtual void finished (GdkEvent* e, bool m) = 0;
149 /** Called to abort a drag and return things to how
150 * they were before it started.
151 * @param m true if some movement occurred, otherwise false.
153 virtual void aborted (bool m) = 0;
155 /** @param m Mouse mode.
156 * @return true if this drag should happen in this mouse mode.
158 virtual bool active (Editing::MouseMode m) {
162 /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
163 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
164 return std::make_pair (1, 1);
167 virtual bool allow_vertical_autoscroll () const {
171 /** @return true if x movement matters to this drag */
172 virtual bool x_movement_matters () const {
176 /** @return true if y movement matters to this drag */
177 virtual bool y_movement_matters () const {
181 bool initially_vertical() const {
182 return _initially_vertical;
185 /** Set up the _pointer_frame_offset */
186 virtual void setup_pointer_frame_offset () {
187 _pointer_frame_offset = 0;
192 double grab_x () const {
196 double grab_y () const {
200 ARDOUR::framepos_t raw_grab_frame () const {
201 return _raw_grab_frame;
204 ARDOUR::framepos_t grab_frame () const {
208 double last_pointer_x () const {
209 return _last_pointer_x;
212 double last_pointer_y () const {
213 return _last_pointer_y;
216 ARDOUR::framepos_t last_pointer_frame () const {
217 return _last_pointer_frame;
220 ARDOUR::frameoffset_t snap_delta (guint const) const;
222 double current_pointer_x () const;
223 double current_pointer_y () const;
225 /* sets snap delta from unsnapped pos */
226 void setup_snap_delta (framepos_t pos);
228 boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*);
230 void show_verbose_cursor_time (framepos_t);
231 void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0);
232 void show_verbose_cursor_text (std::string const &);
234 Editor* _editor; ///< our editor
236 ArdourCanvas::Item* _item; ///< our item
237 /** Offset from the mouse's position for the drag to the start of the thing that is being dragged */
238 ARDOUR::framecnt_t _pointer_frame_offset;
239 bool _x_constrained; ///< true if x motion is constrained, otherwise false
240 bool _y_constrained; ///< true if y motion is constrained, otherwise false
241 bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
244 bool _trackview_only; ///< true if pointer y value should always be relative to the top of the trackview group
245 bool _move_threshold_passed; ///< true if the move threshold has been passed, otherwise false
246 bool _starting_point_passed; ///< true if we called move () with first_move flag, otherwise false
247 bool _initially_vertical; ///< true if after move threshold is passed we appear to be moving vertically; undefined before that
248 bool _was_double_click; ///< true if drag initiated by a double click event
249 double _grab_x; ///< trackview x of the grab start position
250 double _grab_y; ///< y of the grab start position, possibly adjusted if _trackview_only is true
251 double _last_pointer_x; ///< trackview x of the pointer last time a motion occurred
252 double _last_pointer_y; ///< trackview y of the pointer last time a motion occurred
253 ARDOUR::framepos_t _raw_grab_frame; ///< unsnapped frame that the mouse was at when start_grab was called, or 0
254 ARDOUR::framepos_t _grab_frame; ///< adjusted_frame that the mouse was at when start_grab was called, or 0
255 ARDOUR::framepos_t _last_pointer_frame; ///< adjusted_frame the last time a motion occurred
257 /* difference between some key position's snapped and unsnapped
258 * framepos. used for relative snap.
260 ARDOUR::frameoffset_t _snap_delta;
261 CursorContext::Handle _cursor_ctx; ///< cursor change context
266 /** Container for details about a region being dragged */
270 DraggingView (RegionView *, RegionDrag *, TimeAxisView* original_tav);
272 RegionView* view; ///< the view
273 /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on,
274 * or -1 if it is not visible.
277 /** layer that this region is currently being displayed on. This is a double
278 rather than a layer_t as we use fractional layers during drags to allow the user
279 to indicate a new layer to put a region on.
282 double initial_y; ///< the initial y position of the view before any reparenting
283 framepos_t initial_position; ///< initial position of the region
284 framepos_t initial_end; ///< initial end position of the region
285 framepos_t anchored_fade_length; ///< fade_length when anchored during drag
286 boost::shared_ptr<ARDOUR::Playlist> initial_playlist;
287 TimeAxisView* initial_time_axis_view;
290 /** Abstract base class for drags that involve region(s) */
291 class RegionDrag : public Drag, public sigc::trackable
294 RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
295 virtual ~RegionDrag () {}
299 RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
300 std::list<DraggingView> _views; ///< information about all views that are being dragged
302 /** a list of the non-hidden TimeAxisViews sorted by editor order key */
303 std::vector<TimeAxisView*> _time_axis_views;
304 int find_time_axis_view (TimeAxisView *) const;
305 int apply_track_delta (const int start, const int delta, const int skip, const bool distance_only = false) const;
311 friend class DraggingView;
315 void region_going_away (RegionView *);
316 PBD::ScopedConnection death_connection;
320 /** Drags involving region motion from somewhere */
321 class RegionMotionDrag : public RegionDrag
325 RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
326 virtual ~RegionMotionDrag () {}
328 virtual void start_grab (GdkEvent *, Gdk::Cursor *);
329 virtual void motion (GdkEvent *, bool);
330 virtual void finished (GdkEvent *, bool);
331 virtual void aborted (bool);
333 /** @return true if the regions being `moved' came from somewhere on the canvas;
334 * false if they came from outside (e.g. from the region list).
336 virtual bool regions_came_from_canvas () const = 0;
340 double compute_x_delta (GdkEvent const *, ARDOUR::framepos_t *);
341 virtual bool y_movement_allowed (int, double, int skip_invisible = 0) const;
344 ARDOUR::framepos_t _last_frame_position; ///< last position of the thing being dragged
345 double _total_x_delta;
346 int _last_pointer_time_axis_view;
347 double _last_pointer_layer;
355 /** Drags to move (or copy) regions that are already shown in the GUI to
356 * somewhere different.
358 class RegionMoveDrag : public RegionMotionDrag
361 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
362 virtual ~RegionMoveDrag () {}
364 void motion (GdkEvent *, bool);
365 void finished (GdkEvent *, bool);
368 bool regions_came_from_canvas () const {
372 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
373 return std::make_pair (4, 4);
376 void setup_pointer_frame_offset ();
379 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
380 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
383 void finished_no_copy (
386 ARDOUR::framecnt_t const
392 ARDOUR::framecnt_t const
395 RegionView* insert_region_into_playlist (
396 boost::shared_ptr<ARDOUR::Region>,
403 void remove_region_from_playlist (
404 boost::shared_ptr<ARDOUR::Region>,
405 boost::shared_ptr<ARDOUR::Playlist>,
406 PlaylistSet& modified_playlists
410 void collect_new_region_view (RegionView *);
411 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
414 RegionView* _new_region_view;
417 /** Drag to insert a region from somewhere */
418 class RegionInsertDrag : public RegionMotionDrag
421 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
423 void finished (GdkEvent *, bool);
426 bool regions_came_from_canvas () const {
431 /** Region drag in splice mode */
432 class RegionSpliceDrag : public RegionMoveDrag
435 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
437 void motion (GdkEvent *, bool);
438 void finished (GdkEvent *, bool);
442 /** Region drag in ripple mode */
444 class RegionRippleDrag : public RegionMoveDrag
447 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
448 ~RegionRippleDrag () { delete exclude; }
450 void motion (GdkEvent *, bool);
451 void finished (GdkEvent *, bool);
454 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
457 TimeAxisView *prev_tav; // where regions were most recently dragged from
458 TimeAxisView *orig_tav; // where drag started
459 framecnt_t prev_amount;
460 framepos_t prev_position;
461 framecnt_t selection_length;
462 bool allow_moves_across_tracks; // only if all selected regions are on one track
463 ARDOUR::RegionList *exclude;
464 void add_all_after_to_views (TimeAxisView *tav, framepos_t where, const RegionSelection &exclude, bool drag_in_progress);
465 void remove_unselected_from_views (framecnt_t amount, bool move_regions);
469 /** "Drag" to cut a region (action only on button release) */
470 class RegionCutDrag : public Drag
473 RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
476 void motion (GdkEvent*, bool);
477 void finished (GdkEvent*, bool);
484 /** Drags to create regions */
485 class RegionCreateDrag : public Drag
488 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
490 void motion (GdkEvent *, bool);
491 void finished (GdkEvent *, bool);
495 MidiTimeAxisView* _view;
496 boost::shared_ptr<ARDOUR::Region> _region;
499 /** Drags to resize MIDI notes */
500 class NoteResizeDrag : public Drag
503 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
505 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
506 void motion (GdkEvent *, bool);
507 void finished (GdkEvent *, bool);
511 MidiRegionView* region;
517 /** Drags to move MIDI notes */
518 class NoteDrag : public Drag
521 NoteDrag (Editor*, ArdourCanvas::Item*);
523 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
524 void motion (GdkEvent *, bool);
525 void finished (GdkEvent *, bool);
530 ARDOUR::frameoffset_t total_dx (const guint) const;
531 int8_t total_dy () const;
533 MidiRegionView* _region;
535 double _cumulative_dx;
536 double _cumulative_dy;
541 class NoteCreateDrag : public Drag
544 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
547 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
548 void motion (GdkEvent *, bool);
549 void finished (GdkEvent *, bool);
552 bool active (Editing::MouseMode mode) {
553 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
556 bool y_movement_matters () const {
561 double y_to_region (double) const;
562 framecnt_t grid_frames (framepos_t) const;
564 MidiRegionView* _region_view;
565 ArdourCanvas::Rectangle* _drag_rect;
569 /** Drag to move MIDI patch changes */
570 class PatchChangeDrag : public Drag
573 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
575 void motion (GdkEvent *, bool);
576 void finished (GdkEvent *, bool);
579 bool y_movement_matters () const {
583 void setup_pointer_frame_offset ();
586 MidiRegionView* _region_view;
587 PatchChange* _patch_change;
588 double _cumulative_dx;
591 /** Container for details about audio regions being dragged along with video */
595 AVDraggingView (RegionView *);
597 RegionView* view; ///< the view
598 framepos_t initial_position; ///< initial position of the region
601 /** Drag of video offset */
602 class VideoTimeLineDrag : public Drag
605 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
607 void motion (GdkEvent *, bool);
608 void finished (GdkEvent *, bool);
609 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
611 bool y_movement_matters () const {
615 bool allow_vertical_autoscroll () const {
622 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
625 ARDOUR::frameoffset_t _startdrag_video_offset;
626 ARDOUR::frameoffset_t _max_backwards_drag;
629 /** Drag to trim region(s) */
630 class TrimDrag : public RegionDrag
639 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
641 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
642 void motion (GdkEvent *, bool);
643 void finished (GdkEvent *, bool);
646 bool y_movement_matters () const {
650 void setup_pointer_frame_offset ();
654 Operation _operation;
656 bool _preserve_fade_anchor;
657 bool _jump_position_when_done;
660 /** Meter marker drag */
661 class MeterMarkerDrag : public Drag
664 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
666 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
667 void motion (GdkEvent *, bool);
668 void finished (GdkEvent *, bool);
671 bool allow_vertical_autoscroll () const {
675 bool y_movement_matters () const {
679 void setup_pointer_frame_offset ();
682 MeterMarker* _marker;
684 XMLNode* before_state;
687 /** Tempo marker drag */
688 class TempoMarkerDrag : public Drag
691 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
693 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
694 void motion (GdkEvent *, bool);
695 void finished (GdkEvent *, bool);
698 bool allow_vertical_autoscroll () const {
702 bool y_movement_matters () const {
706 void setup_pointer_frame_offset ();
709 TempoMarker* _marker;
711 XMLNode* before_state;
715 /** Drag of the playhead cursor */
716 class CursorDrag : public Drag
719 CursorDrag (Editor *, EditorCursor&, bool);
721 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
722 void motion (GdkEvent *, bool);
723 void finished (GdkEvent *, bool);
726 bool allow_vertical_autoscroll () const {
730 bool y_movement_matters () const {
735 void fake_locate (framepos_t);
737 EditorCursor& _cursor;
738 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
739 double _grab_zoom; ///< editor frames per unit when our grab started
742 /** Region fade-in drag */
743 class FadeInDrag : public RegionDrag
746 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
748 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
749 void motion (GdkEvent *, bool);
750 void finished (GdkEvent *, bool);
753 bool y_movement_matters () const {
757 void setup_pointer_frame_offset ();
760 /** Region fade-out drag */
761 class FadeOutDrag : public RegionDrag
764 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
766 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
767 void motion (GdkEvent *, bool);
768 void finished (GdkEvent *, bool);
771 bool y_movement_matters () const {
775 void setup_pointer_frame_offset ();
779 class MarkerDrag : public Drag
782 MarkerDrag (Editor *, ArdourCanvas::Item *);
785 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
786 void motion (GdkEvent *, bool);
787 void finished (GdkEvent *, bool);
790 bool allow_vertical_autoscroll () const {
794 bool y_movement_matters () const {
798 void setup_pointer_frame_offset ();
801 void update_item (ARDOUR::Location *);
803 Marker* _marker; ///< marker being dragged
805 struct CopiedLocationMarkerInfo {
806 ARDOUR::Location* location;
807 std::vector<Marker*> markers;
809 CopiedLocationMarkerInfo (ARDOUR::Location* l, Marker* m);
812 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
813 CopiedLocationInfo _copied_locations;
814 ArdourCanvas::Points _points;
817 /** Control point drag */
818 class ControlPointDrag : public Drag
821 ControlPointDrag (Editor *, ArdourCanvas::Item *);
823 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
824 void motion (GdkEvent *, bool);
825 void finished (GdkEvent *, bool);
828 bool active (Editing::MouseMode m);
832 ControlPoint* _point;
833 double _fixed_grab_x;
834 double _fixed_grab_y;
835 double _cumulative_x_drag;
836 double _cumulative_y_drag;
838 uint32_t _final_index;
839 static double _zero_gain_fraction;
842 /** Gain or automation line drag */
843 class LineDrag : public Drag
846 LineDrag (Editor *e, ArdourCanvas::Item *i);
848 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
849 void motion (GdkEvent *, bool);
850 void finished (GdkEvent *, bool);
855 AutomationLine* _line;
856 double _fixed_grab_x;
857 double _fixed_grab_y;
858 double _cumulative_y_drag;
861 /** Transient feature line drags*/
862 class FeatureLineDrag : public Drag
865 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
867 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
868 void motion (GdkEvent *, bool);
869 void finished (GdkEvent *, bool);
874 ArdourCanvas::Line* _line;
875 AudioRegionView* _arv;
877 double _region_view_grab_x;
878 double _cumulative_x_drag;
884 /** Dragging of a rubberband rectangle for selecting things */
885 class RubberbandSelectDrag : public Drag
888 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
890 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
891 void motion (GdkEvent *, bool);
892 void finished (GdkEvent *, bool);
895 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
896 return std::make_pair (8, 1);
899 void do_select_things (GdkEvent *, bool);
901 /** Select some things within a rectangle.
902 * @param button_state The button state from the GdkEvent.
903 * @param x1 The left-hand side of the rectangle in session frames.
904 * @param x2 The right-hand side of the rectangle in session frames.
905 * @param y1 The top of the rectangle in trackview coordinates.
906 * @param y2 The bottom of the rectangle in trackview coordinates.
907 * @param drag_in_progress true if the drag is currently happening.
909 virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
911 virtual void deselect_things () = 0;
917 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
918 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
921 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
923 void select_things (int, framepos_t, framepos_t, double, double, bool);
924 void deselect_things ();
927 /** A RubberbandSelectDrag for selecting MIDI notes */
928 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
931 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
933 void select_things (int, framepos_t, framepos_t, double, double, bool);
934 void deselect_things ();
937 MidiRegionView* _region_view;
940 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
941 class MidiVerticalSelectDrag : public RubberbandSelectDrag
944 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
946 void select_things (int, framepos_t, framepos_t, double, double, bool);
947 void deselect_things ();
950 MidiRegionView* _region_view;
953 /** Region drag in time-FX mode */
954 class TimeFXDrag : public RegionDrag
957 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
959 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
960 void motion (GdkEvent *, bool);
961 void finished (GdkEvent *, bool);
965 /** Scrub drag in audition mode */
966 class ScrubDrag : public Drag
969 ScrubDrag (Editor *, ArdourCanvas::Item *);
971 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
972 void motion (GdkEvent *, bool);
973 void finished (GdkEvent *, bool);
977 /** Drag in range select mode */
978 class SelectionDrag : public Drag
989 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
991 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
992 void motion (GdkEvent *, bool);
993 void finished (GdkEvent *, bool);
996 void setup_pointer_frame_offset ();
999 Operation _operation;
1001 std::list<TimeAxisView*> _added_time_axes;
1002 bool _time_selection_at_start;
1003 framepos_t start_at_start;
1004 framepos_t end_at_start;
1007 /** Range marker drag */
1008 class RangeMarkerBarDrag : public Drag
1014 CreateTransportMarker,
1018 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1019 ~RangeMarkerBarDrag ();
1021 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1022 void motion (GdkEvent *, bool);
1023 void finished (GdkEvent *, bool);
1024 void aborted (bool);
1026 bool allow_vertical_autoscroll () const {
1030 bool y_movement_matters () const {
1035 void update_item (ARDOUR::Location *);
1037 Operation _operation;
1038 ArdourCanvas::Rectangle* _drag_rect;
1042 /** Drag of rectangle to set zoom */
1043 class MouseZoomDrag : public Drag
1046 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1048 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1049 void motion (GdkEvent *, bool);
1050 void finished (GdkEvent *, bool);
1051 void aborted (bool);
1053 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1054 return std::make_pair (4, 4);
1061 /** Drag of a range of automation data (either on an automation track or region gain),
1062 * changing value but not position.
1064 class AutomationRangeDrag : public Drag
1067 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1068 AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &);
1070 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1071 void motion (GdkEvent *, bool);
1072 void finished (GdkEvent *, bool);
1073 void aborted (bool);
1075 bool x_movement_matters () const {
1080 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1081 double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
1082 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1084 std::list<ARDOUR::AudioRange> _ranges;
1086 /** A line that is part of the drag */
1088 boost::shared_ptr<AutomationLine> line; ///< the line
1089 std::list<ControlPoint*> points; ///< points to drag on the line
1090 std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
1091 XMLNode* state; ///< the XML state node before the drag
1092 double original_fraction; ///< initial y-fraction before the drag
1095 std::list<Line> _lines;
1097 bool _nothing_to_drag;
1101 /** Drag of one edge of an xfade
1103 class CrossfadeEdgeDrag : public Drag
1106 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1108 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1109 void motion (GdkEvent*, bool);
1110 void finished (GdkEvent*, bool);
1111 void aborted (bool);
1113 bool y_movement_matters () const {
1117 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1118 return std::make_pair (4, 4);
1122 AudioRegionView* arv;
1126 #endif /* __gtk2_ardour_editor_drag_h_ */