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"
43 namespace ArdourCanvas {
50 class StatefulDiffCommand;
57 class MidiTimeAxisView;
62 class RouteTimeAxisView;
63 class RegionSelection;
69 class AudioRegionView;
71 class AutomationTimeAxisView;
73 /** Class to manage current drags */
78 DragManager (Editor* e);
81 bool motion_handler (GdkEvent *, bool);
85 void set (Drag *, GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
86 void start_grab (GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
87 bool end_grab (GdkEvent *);
88 bool have_item (ArdourCanvas::Item *) const;
90 void mark_double_click ();
92 /** @return true if an end drag or abort is in progress */
93 bool ending () const {
97 bool active () const {
98 return !_drags.empty ();
101 /** @return current pointer x position in canvas coordinates */
102 double current_pointer_x () const {
103 return _current_pointer_x;
106 /** @return current pointer y position in canvas coordinates */
107 double current_pointer_y () const {
108 return _current_pointer_y;
111 /** @return current pointer frame */
112 ARDOUR::framepos_t current_pointer_frame () const {
113 return _current_pointer_frame;
118 std::list<Drag*> _drags;
119 bool _ending; ///< true if end_grab or abort is in progress, otherwise false
120 double _current_pointer_x; ///< canvas-coordinate space x of the current pointer
121 double _current_pointer_y; ///< canvas-coordinate space y of the current pointer
122 ARDOUR::framepos_t _current_pointer_frame; ///< frame that the pointer is now at
123 bool _old_follow_playhead; ///< state of Editor::follow_playhead() before the drags started
126 /** Abstract base class for dragging of things within the editor */
130 Drag (Editor *, ArdourCanvas::Item *, bool trackview_only = true);
133 void set_manager (DragManager* m) {
137 /** @return the canvas item being dragged */
138 ArdourCanvas::Item* item () const {
142 void swap_grab (ArdourCanvas::Item *, Gdk::Cursor *, uint32_t);
143 bool motion_handler (GdkEvent*, bool);
146 ARDOUR::framepos_t adjusted_frame (ARDOUR::framepos_t, GdkEvent const *, bool snap = true) const;
147 ARDOUR::framepos_t adjusted_current_frame (GdkEvent const *, bool snap = true) const;
149 bool was_double_click() const { return _was_double_click; }
150 void set_double_click (bool yn) { _was_double_click = yn; }
152 /** Called to start a grab of an item.
153 * @param e Event that caused the grab to start.
154 * @param c Cursor to use, or 0.
156 virtual void start_grab (GdkEvent* e, Gdk::Cursor* c = 0);
158 virtual bool end_grab (GdkEvent *);
160 /** Called when a drag motion has occurred.
161 * @param e Event describing the motion.
162 * @param f true if this is the first movement, otherwise false.
164 virtual void motion (GdkEvent* e, bool f) = 0;
166 /** Called when a drag has finished.
167 * @param e Event describing the finish.
168 * @param m true if some movement occurred, otherwise false.
170 virtual void finished (GdkEvent* e, bool m) = 0;
172 /** Called to abort a drag and return things to how
173 * they were before it started.
174 * @param m true if some movement occurred, otherwise false.
176 virtual void aborted (bool m) = 0;
178 /** @param m Mouse mode.
179 * @return true if this drag should happen in this mouse mode.
181 virtual bool active (Editing::MouseMode m) {
185 /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
186 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
187 return std::make_pair (1, 1);
190 virtual bool allow_vertical_autoscroll () const {
194 /** @return true if x movement matters to this drag */
195 virtual bool x_movement_matters () const {
199 /** @return true if y movement matters to this drag */
200 virtual bool y_movement_matters () const {
204 bool initially_vertical() const {
205 return _initially_vertical;
208 /** Set up the _pointer_frame_offset */
209 virtual void setup_pointer_frame_offset () {
210 _pointer_frame_offset = 0;
215 double grab_x () const {
219 double grab_y () const {
223 ARDOUR::framepos_t raw_grab_frame () const {
224 return _raw_grab_frame;
227 ARDOUR::framepos_t grab_frame () const {
231 double last_pointer_x () const {
232 return _last_pointer_x;
235 double last_pointer_y () const {
236 return _last_pointer_y;
239 ARDOUR::framepos_t last_pointer_frame () const {
240 return _last_pointer_frame;
243 ARDOUR::frameoffset_t snap_delta (guint const) const;
245 double current_pointer_x () const;
246 double current_pointer_y () const;
248 /* sets snap delta from unsnapped pos */
249 void setup_snap_delta (framepos_t pos);
251 boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*, bool commit, const int32_t sub_num);
253 void show_verbose_cursor_time (framepos_t);
254 void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0);
255 void show_verbose_cursor_text (std::string const &);
257 Editor* _editor; ///< our editor
259 ArdourCanvas::Item* _item; ///< our item
260 /** Offset from the mouse's position for the drag to the start of the thing that is being dragged */
261 ARDOUR::framecnt_t _pointer_frame_offset;
262 bool _x_constrained; ///< true if x motion is constrained, otherwise false
263 bool _y_constrained; ///< true if y motion is constrained, otherwise false
264 bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
267 bool _trackview_only; ///< true if pointer y value should always be relative to the top of the trackview group
268 bool _move_threshold_passed; ///< true if the move threshold has been passed, otherwise false
269 bool _starting_point_passed; ///< true if we called move () with first_move flag, otherwise false
270 bool _initially_vertical; ///< true if after move threshold is passed we appear to be moving vertically; undefined before that
271 bool _was_double_click; ///< true if drag initiated by a double click event
272 double _grab_x; ///< trackview x of the grab start position
273 double _grab_y; ///< y of the grab start position, possibly adjusted if _trackview_only is true
274 double _last_pointer_x; ///< trackview x of the pointer last time a motion occurred
275 double _last_pointer_y; ///< trackview y of the pointer last time a motion occurred
276 ARDOUR::framepos_t _raw_grab_frame; ///< unsnapped frame that the mouse was at when start_grab was called, or 0
277 ARDOUR::framepos_t _grab_frame; ///< adjusted_frame that the mouse was at when start_grab was called, or 0
278 ARDOUR::framepos_t _last_pointer_frame; ///< adjusted_frame the last time a motion occurred
280 /* difference between some key position's snapped and unsnapped
281 * framepos. used for relative snap.
283 ARDOUR::frameoffset_t _snap_delta;
284 CursorContext::Handle _cursor_ctx; ///< cursor change context
285 bool _constraint_pressed; ///< if the keyboard indicated constraint modifier was pressed on start_grab()
290 /** Container for details about a region being dragged */
294 DraggingView (RegionView *, RegionDrag *, TimeAxisView* original_tav);
296 RegionView* view; ///< the view
297 /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on,
298 * or -1 if it is not visible.
301 /** layer that this region is currently being displayed on. This is a double
302 rather than a layer_t as we use fractional layers during drags to allow the user
303 to indicate a new layer to put a region on.
306 double initial_y; ///< the initial y position of the view before any reparenting
307 framepos_t initial_position; ///< initial position of the region
308 framepos_t initial_end; ///< initial end position of the region
309 framepos_t anchored_fade_length; ///< fade_length when anchored during drag
310 boost::shared_ptr<ARDOUR::Playlist> initial_playlist;
311 TimeAxisView* initial_time_axis_view;
314 /** Abstract base class for drags that involve region(s) */
315 class RegionDrag : public Drag, public sigc::trackable
318 RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
319 virtual ~RegionDrag () {}
323 RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
324 std::list<DraggingView> _views; ///< information about all views that are being dragged
326 /** a list of the non-hidden TimeAxisViews sorted by editor order key */
327 std::vector<TimeAxisView*> _time_axis_views;
328 int find_time_axis_view (TimeAxisView *) const;
329 int apply_track_delta (const int start, const int delta, const int skip, const bool distance_only = false) const;
330 int32_t current_music_divisor (framepos_t pos, int32_t button_state);
336 friend class DraggingView;
340 void region_going_away (RegionView *);
341 PBD::ScopedConnection death_connection;
345 /** Drags involving region motion from somewhere */
346 class RegionMotionDrag : public RegionDrag
350 RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
351 virtual ~RegionMotionDrag () {}
353 virtual void start_grab (GdkEvent *, Gdk::Cursor *);
354 virtual void motion (GdkEvent *, bool);
355 virtual void finished (GdkEvent *, bool);
356 virtual void aborted (bool);
358 /** @return true if the regions being `moved' came from somewhere on the canvas;
359 * false if they came from outside (e.g. from the region list).
361 virtual bool regions_came_from_canvas () const = 0;
365 double compute_x_delta (GdkEvent const *, ARDOUR::framepos_t *);
366 virtual bool y_movement_allowed (int, double, int skip_invisible = 0) const;
369 bool _ignore_video_lock;
370 ARDOUR::framepos_t _last_frame_position; ///< last position of the thing being dragged
371 double _total_x_delta;
372 int _last_pointer_time_axis_view;
373 double _last_pointer_layer;
381 /** Drags to move (or copy) regions that are already shown in the GUI to
382 * somewhere different.
384 class RegionMoveDrag : public RegionMotionDrag
387 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
388 virtual ~RegionMoveDrag () {}
390 void motion (GdkEvent *, bool);
391 void finished (GdkEvent *, bool);
394 bool regions_came_from_canvas () const {
398 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
399 return std::make_pair (4, 4);
402 void setup_pointer_frame_offset ();
405 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
406 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
409 void finished_no_copy (
412 ARDOUR::framecnt_t const,
413 int32_t const ev_state
419 ARDOUR::framecnt_t const,
420 int32_t const ev_state
423 RegionView* insert_region_into_playlist (
424 boost::shared_ptr<ARDOUR::Region>,
429 const int32_t sub_num
432 void remove_region_from_playlist (
433 boost::shared_ptr<ARDOUR::Region>,
434 boost::shared_ptr<ARDOUR::Playlist>,
435 PlaylistSet& modified_playlists
439 void collect_new_region_view (RegionView *);
440 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
443 RegionView* _new_region_view;
446 /** Drag to insert a region from somewhere */
447 class RegionInsertDrag : public RegionMotionDrag
450 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
452 void finished (GdkEvent *, bool);
455 bool regions_came_from_canvas () const {
460 /** Region drag in splice mode */
461 class RegionSpliceDrag : public RegionMoveDrag
464 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
466 void motion (GdkEvent *, bool);
467 void finished (GdkEvent *, bool);
471 /** Region drag in ripple mode */
473 class RegionRippleDrag : public RegionMoveDrag
476 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
477 ~RegionRippleDrag () { delete exclude; }
479 void motion (GdkEvent *, bool);
480 void finished (GdkEvent *, bool);
483 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
486 TimeAxisView *prev_tav; // where regions were most recently dragged from
487 TimeAxisView *orig_tav; // where drag started
488 ARDOUR::framecnt_t prev_amount;
489 ARDOUR::framepos_t prev_position;
490 ARDOUR::framecnt_t selection_length;
491 bool allow_moves_across_tracks; // only if all selected regions are on one track
492 ARDOUR::RegionList *exclude;
493 void add_all_after_to_views (TimeAxisView *tav, ARDOUR::framepos_t where, const RegionSelection &exclude, bool drag_in_progress);
494 void remove_unselected_from_views (ARDOUR::framecnt_t amount, bool move_regions);
498 /** "Drag" to cut a region (action only on button release) */
499 class RegionCutDrag : public Drag
502 RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
505 void motion (GdkEvent*, bool);
506 void finished (GdkEvent*, bool);
513 /** Drags to create regions */
514 class RegionCreateDrag : public Drag
517 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
519 void motion (GdkEvent *, bool);
520 void finished (GdkEvent *, bool);
524 MidiTimeAxisView* _view;
525 boost::shared_ptr<ARDOUR::Region> _region;
528 /** Drags to resize MIDI notes */
529 class NoteResizeDrag : public Drag
532 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
534 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
535 void motion (GdkEvent *, bool);
536 void finished (GdkEvent *, bool);
540 MidiRegionView* region;
547 /** Drags to move MIDI notes */
548 class NoteDrag : public Drag
551 NoteDrag (Editor*, ArdourCanvas::Item*);
553 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
554 void motion (GdkEvent *, bool);
555 void finished (GdkEvent *, bool);
560 ARDOUR::frameoffset_t total_dx (const guint) const;
561 int8_t total_dy () const;
563 MidiRegionView* _region;
565 double _cumulative_dx;
566 double _cumulative_dy;
571 class NoteCreateDrag : public Drag
574 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
577 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
578 void motion (GdkEvent *, bool);
579 void finished (GdkEvent *, bool);
582 bool active (Editing::MouseMode mode) {
583 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
586 bool y_movement_matters () const {
591 double y_to_region (double) const;
592 ARDOUR::framecnt_t grid_frames (framepos_t) const;
594 MidiRegionView* _region_view;
595 ArdourCanvas::Rectangle* _drag_rect;
599 /** Drag to move MIDI patch changes */
600 class PatchChangeDrag : public Drag
603 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
605 void motion (GdkEvent *, bool);
606 void finished (GdkEvent *, bool);
609 bool y_movement_matters () const {
613 void setup_pointer_frame_offset ();
616 MidiRegionView* _region_view;
617 PatchChange* _patch_change;
618 double _cumulative_dx;
621 /** Container for details about audio regions being dragged along with video */
625 AVDraggingView (RegionView *);
627 RegionView* view; ///< the view
628 framepos_t initial_position; ///< initial position of the region
631 /** Drag of video offset */
632 class VideoTimeLineDrag : public Drag
635 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
637 void motion (GdkEvent *, bool);
638 void finished (GdkEvent *, bool);
639 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
641 bool y_movement_matters () const {
645 bool allow_vertical_autoscroll () const {
652 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
655 ARDOUR::frameoffset_t _startdrag_video_offset;
656 ARDOUR::frameoffset_t _max_backwards_drag;
660 /** Drag to trim region(s) */
661 class TrimDrag : public RegionDrag
670 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
672 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
673 void motion (GdkEvent *, bool);
674 void finished (GdkEvent *, bool);
677 bool y_movement_matters () const {
681 void setup_pointer_frame_offset ();
685 Operation _operation;
687 bool _preserve_fade_anchor;
688 bool _jump_position_when_done;
691 /** Meter marker drag */
692 class MeterMarkerDrag : public Drag
695 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
697 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
698 void motion (GdkEvent *, bool);
699 void finished (GdkEvent *, bool);
702 bool allow_vertical_autoscroll () const {
706 bool y_movement_matters () const {
710 void setup_pointer_frame_offset ();
713 MeterMarker* _marker;
714 ARDOUR::MeterSection* _real_section;
717 Editing::SnapType _old_snap_type;
718 Editing::SnapMode _old_snap_mode;
719 XMLNode* before_state;
722 /** Tempo marker drag */
723 class TempoMarkerDrag : public Drag
726 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
728 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
729 void motion (GdkEvent *, bool);
730 void finished (GdkEvent *, bool);
733 bool allow_vertical_autoscroll () const {
737 bool y_movement_matters () const {
741 void setup_pointer_frame_offset ();
744 TempoMarker* _marker;
745 ARDOUR::TempoSection* _real_section;
750 XMLNode* before_state;
753 /** BBT Ruler drag */
754 class BBTRulerDrag : public Drag
757 BBTRulerDrag (Editor *, ArdourCanvas::Item *);
759 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
760 void motion (GdkEvent *, bool);
761 void finished (GdkEvent *, bool);
764 bool allow_vertical_autoscroll () const {
768 bool y_movement_matters () const {
772 void setup_pointer_frame_offset ();
776 ARDOUR::TempoSection* _tempo;
777 XMLNode* before_state;
780 /** Drag of the playhead cursor */
781 class CursorDrag : public Drag
784 CursorDrag (Editor *, EditorCursor&, bool);
786 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
787 void motion (GdkEvent *, bool);
788 void finished (GdkEvent *, bool);
791 bool allow_vertical_autoscroll () const {
795 bool y_movement_matters () const {
800 void fake_locate (framepos_t);
802 EditorCursor& _cursor;
803 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
804 double _grab_zoom; ///< editor frames per unit when our grab started
807 /** Region fade-in drag */
808 class FadeInDrag : public RegionDrag
811 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
813 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
814 void motion (GdkEvent *, bool);
815 void finished (GdkEvent *, bool);
818 bool y_movement_matters () const {
822 void setup_pointer_frame_offset ();
825 /** Region fade-out drag */
826 class FadeOutDrag : public RegionDrag
829 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
831 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
832 void motion (GdkEvent *, bool);
833 void finished (GdkEvent *, bool);
836 bool y_movement_matters () const {
840 void setup_pointer_frame_offset ();
844 class MarkerDrag : public Drag
847 MarkerDrag (Editor *, ArdourCanvas::Item *);
850 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
851 void motion (GdkEvent *, bool);
852 void finished (GdkEvent *, bool);
855 bool allow_vertical_autoscroll () const {
859 bool y_movement_matters () const {
863 void setup_pointer_frame_offset ();
866 void update_item (ARDOUR::Location *);
868 ArdourMarker* _marker; ///< marker being dragged
869 bool _selection_changed;
870 struct CopiedLocationMarkerInfo {
871 ARDOUR::Location* location;
872 std::vector<ArdourMarker*> markers;
874 CopiedLocationMarkerInfo (ARDOUR::Location* l, ArdourMarker* m);
877 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
878 CopiedLocationInfo _copied_locations;
879 ArdourCanvas::Points _points;
882 /** Control point drag */
883 class ControlPointDrag : public Drag
886 ControlPointDrag (Editor *, ArdourCanvas::Item *);
888 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
889 void motion (GdkEvent *, bool);
890 void finished (GdkEvent *, bool);
893 bool active (Editing::MouseMode m);
897 ControlPoint* _point;
898 double _fixed_grab_x;
899 double _fixed_grab_y;
900 double _cumulative_x_drag;
901 double _cumulative_y_drag;
903 uint32_t _final_index;
904 static double _zero_gain_fraction;
907 /** Gain or automation line drag */
908 class LineDrag : public Drag
911 LineDrag (Editor *e, ArdourCanvas::Item *i);
913 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
914 void motion (GdkEvent *, bool);
915 void finished (GdkEvent *, bool);
920 AutomationLine* _line;
921 double _fixed_grab_x;
922 double _fixed_grab_y;
923 double _cumulative_y_drag;
928 /** Transient feature line drags*/
929 class FeatureLineDrag : public Drag
932 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
934 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
935 void motion (GdkEvent *, bool);
936 void finished (GdkEvent *, bool);
941 ArdourCanvas::Line* _line;
942 AudioRegionView* _arv;
944 double _region_view_grab_x;
945 double _cumulative_x_drag;
951 /** Dragging of a rubberband rectangle for selecting things */
952 class RubberbandSelectDrag : public Drag
955 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
957 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
958 void motion (GdkEvent *, bool);
959 void finished (GdkEvent *, bool);
962 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
963 return std::make_pair (8, 1);
966 void do_select_things (GdkEvent *, bool);
968 /** Select some things within a rectangle.
969 * @param button_state The button state from the GdkEvent.
970 * @param x1 The left-hand side of the rectangle in session frames.
971 * @param x2 The right-hand side of the rectangle in session frames.
972 * @param y1 The top of the rectangle in trackview coordinates.
973 * @param y2 The bottom of the rectangle in trackview coordinates.
974 * @param drag_in_progress true if the drag is currently happening.
976 virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
978 virtual void deselect_things () = 0;
984 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
985 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
988 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
990 void select_things (int, framepos_t, framepos_t, double, double, bool);
991 void deselect_things ();
994 /** A RubberbandSelectDrag for selecting MIDI notes */
995 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
998 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
1000 void select_things (int, framepos_t, framepos_t, double, double, bool);
1001 void deselect_things ();
1004 MidiRegionView* _region_view;
1007 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
1008 class MidiVerticalSelectDrag : public RubberbandSelectDrag
1011 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
1013 void select_things (int, framepos_t, framepos_t, double, double, bool);
1014 void deselect_things ();
1017 MidiRegionView* _region_view;
1020 /** Region drag in time-FX mode */
1021 class TimeFXDrag : public RegionDrag
1024 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
1026 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1027 void motion (GdkEvent *, bool);
1028 void finished (GdkEvent *, bool);
1029 void aborted (bool);
1032 /** Scrub drag in audition mode */
1033 class ScrubDrag : public Drag
1036 ScrubDrag (Editor *, ArdourCanvas::Item *);
1038 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1039 void motion (GdkEvent *, bool);
1040 void finished (GdkEvent *, bool);
1041 void aborted (bool);
1044 /** Drag in range select mode */
1045 class SelectionDrag : public Drag
1056 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
1058 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1059 void motion (GdkEvent *, bool);
1060 void finished (GdkEvent *, bool);
1061 void aborted (bool);
1063 void setup_pointer_frame_offset ();
1066 Operation _operation;
1068 std::list<TimeAxisView*> _added_time_axes;
1069 bool _time_selection_at_start;
1070 framepos_t start_at_start;
1071 framepos_t end_at_start;
1074 /** Range marker drag */
1075 class RangeMarkerBarDrag : public Drag
1081 CreateTransportMarker,
1085 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1086 ~RangeMarkerBarDrag ();
1088 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1089 void motion (GdkEvent *, bool);
1090 void finished (GdkEvent *, bool);
1091 void aborted (bool);
1093 bool allow_vertical_autoscroll () const {
1097 bool y_movement_matters () const {
1102 void update_item (ARDOUR::Location *);
1104 Operation _operation;
1105 ArdourCanvas::Rectangle* _drag_rect;
1109 /** Drag of rectangle to set zoom */
1110 class MouseZoomDrag : public Drag
1113 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1115 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1116 void motion (GdkEvent *, bool);
1117 void finished (GdkEvent *, bool);
1118 void aborted (bool);
1120 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1121 return std::make_pair (4, 4);
1128 /** Drag of a range of automation data (either on an automation track or region gain),
1129 * changing value but not position.
1131 class AutomationRangeDrag : public Drag
1134 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1135 AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &);
1137 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1138 void motion (GdkEvent *, bool);
1139 void finished (GdkEvent *, bool);
1140 void aborted (bool);
1142 bool x_movement_matters () const {
1147 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1148 double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
1149 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1151 std::list<ARDOUR::AudioRange> _ranges;
1153 /** A line that is part of the drag */
1155 boost::shared_ptr<AutomationLine> line; ///< the line
1156 std::list<ControlPoint*> points; ///< points to drag on the line
1157 std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
1158 XMLNode* state; ///< the XML state node before the drag
1159 double original_fraction; ///< initial y-fraction before the drag
1162 std::list<Line> _lines;
1164 bool _nothing_to_drag;
1168 /** Drag of one edge of an xfade
1170 class CrossfadeEdgeDrag : public Drag
1173 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1175 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1176 void motion (GdkEvent*, bool);
1177 void finished (GdkEvent*, bool);
1178 void aborted (bool);
1180 bool y_movement_matters () const {
1184 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1185 return std::make_pair (4, 4);
1189 AudioRegionView* arv;
1193 class RulerZoomDrag : public Drag
1196 RulerZoomDrag (Editor*, ArdourCanvas::Item*);
1198 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1199 void motion (GdkEvent *, bool);
1200 void finished (GdkEvent*, bool);
1201 void aborted (bool);
1203 virtual bool allow_vertical_autoscroll () const {
1209 #endif /* __gtk2_ardour_editor_drag_h_ */