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"
37 #include "track_selection.h"
44 namespace ArdourCanvas {
51 class StatefulDiffCommand;
58 class MidiTimeAxisView;
63 class RouteTimeAxisView;
64 class RegionSelection;
70 class AudioRegionView;
72 class AutomationTimeAxisView;
74 /** Class to manage current drags */
79 DragManager (Editor* e);
82 bool motion_handler (GdkEvent *, bool);
86 void set (Drag *, GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
87 void start_grab (GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
88 bool end_grab (GdkEvent *);
89 bool have_item (ArdourCanvas::Item *) const;
91 void mark_double_click ();
93 /** @return true if an end drag or abort is in progress */
94 bool ending () const {
98 bool active () const {
99 return !_drags.empty ();
102 /** @return current pointer x position in canvas coordinates */
103 double current_pointer_x () const {
104 return _current_pointer_x;
107 /** @return current pointer y position in canvas coordinates */
108 double current_pointer_y () const {
109 return _current_pointer_y;
112 /** @return current pointer frame */
113 ARDOUR::framepos_t current_pointer_frame () const {
114 return _current_pointer_frame;
119 std::list<Drag*> _drags;
120 bool _ending; ///< true if end_grab or abort is in progress, otherwise false
121 double _current_pointer_x; ///< canvas-coordinate space x of the current pointer
122 double _current_pointer_y; ///< canvas-coordinate space y of the current pointer
123 ARDOUR::framepos_t _current_pointer_frame; ///< frame that the pointer is now at
124 bool _old_follow_playhead; ///< state of Editor::follow_playhead() before the drags started
127 /** Abstract base class for dragging of things within the editor */
131 Drag (Editor *, ArdourCanvas::Item *, bool trackview_only = true);
134 void set_manager (DragManager* m) {
138 /** @return the canvas item being dragged */
139 ArdourCanvas::Item* item () const {
143 void swap_grab (ArdourCanvas::Item *, Gdk::Cursor *, uint32_t);
144 bool motion_handler (GdkEvent*, bool);
147 ARDOUR::framepos_t adjusted_frame (ARDOUR::framepos_t, GdkEvent const *, bool snap = true) const;
148 ARDOUR::framepos_t adjusted_current_frame (GdkEvent const *, bool snap = true) const;
150 bool was_double_click() const { return _was_double_click; }
151 void set_double_click (bool yn) { _was_double_click = yn; }
153 /** Called to start a grab of an item.
154 * @param e Event that caused the grab to start.
155 * @param c Cursor to use, or 0.
157 virtual void start_grab (GdkEvent* e, Gdk::Cursor* c = 0);
159 virtual bool end_grab (GdkEvent *);
161 /** Called when a drag motion has occurred.
162 * @param e Event describing the motion.
163 * @param f true if this is the first movement, otherwise false.
165 virtual void motion (GdkEvent* e, bool f) = 0;
167 /** Called when a drag has finished.
168 * @param e Event describing the finish.
169 * @param m true if some movement occurred, otherwise false.
171 virtual void finished (GdkEvent* e, bool m) = 0;
173 /** Called to abort a drag and return things to how
174 * they were before it started.
175 * @param m true if some movement occurred, otherwise false.
177 virtual void aborted (bool m) = 0;
179 /** @param m Mouse mode.
180 * @return true if this drag should happen in this mouse mode.
182 virtual bool active (Editing::MouseMode m) {
186 /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
187 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
188 return std::make_pair (1, 1);
191 virtual bool allow_vertical_autoscroll () const {
195 /** @return true if x movement matters to this drag */
196 virtual bool x_movement_matters () const {
200 /** @return true if y movement matters to this drag */
201 virtual bool y_movement_matters () const {
205 bool initially_vertical() const {
206 return _initially_vertical;
209 /** Set up the _pointer_frame_offset */
210 virtual void setup_pointer_frame_offset () {
211 _pointer_frame_offset = 0;
216 double grab_x () const {
220 double grab_y () const {
224 ARDOUR::framepos_t raw_grab_frame () const {
225 return _raw_grab_frame;
228 ARDOUR::framepos_t grab_frame () const {
232 double last_pointer_x () const {
233 return _last_pointer_x;
236 double last_pointer_y () const {
237 return _last_pointer_y;
240 ARDOUR::framepos_t last_pointer_frame () const {
241 return _last_pointer_frame;
244 ARDOUR::frameoffset_t snap_delta (guint const) const;
246 double current_pointer_x () const;
247 double current_pointer_y () const;
249 /* sets snap delta from unsnapped pos */
250 void setup_snap_delta (framepos_t pos);
252 boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*, bool commit, const int32_t sub_num);
254 void show_verbose_cursor_time (framepos_t);
255 void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0);
256 void show_verbose_cursor_text (std::string const &);
258 Editor* _editor; ///< our editor
260 ArdourCanvas::Item* _item; ///< our item
261 /** Offset from the mouse's position for the drag to the start of the thing that is being dragged */
262 ARDOUR::framecnt_t _pointer_frame_offset;
263 bool _x_constrained; ///< true if x motion is constrained, otherwise false
264 bool _y_constrained; ///< true if y motion is constrained, otherwise false
265 bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
268 bool _trackview_only; ///< true if pointer y value should always be relative to the top of the trackview group
269 bool _move_threshold_passed; ///< true if the move threshold has been passed, otherwise false
270 bool _starting_point_passed; ///< true if we called move () with first_move flag, otherwise false
271 bool _initially_vertical; ///< true if after move threshold is passed we appear to be moving vertically; undefined before that
272 bool _was_double_click; ///< true if drag initiated by a double click event
273 double _grab_x; ///< trackview x of the grab start position
274 double _grab_y; ///< y of the grab start position, possibly adjusted if _trackview_only is true
275 double _last_pointer_x; ///< trackview x of the pointer last time a motion occurred
276 double _last_pointer_y; ///< trackview y of the pointer last time a motion occurred
277 ARDOUR::framepos_t _raw_grab_frame; ///< unsnapped frame that the mouse was at when start_grab was called, or 0
278 ARDOUR::framepos_t _grab_frame; ///< adjusted_frame that the mouse was at when start_grab was called, or 0
279 ARDOUR::framepos_t _last_pointer_frame; ///< adjusted_frame the last time a motion occurred
281 /* difference between some key position's snapped and unsnapped
282 * framepos. used for relative snap.
284 ARDOUR::frameoffset_t _snap_delta;
285 CursorContext::Handle _cursor_ctx; ///< cursor change context
286 bool _constraint_pressed; ///< if the keyboard indicated constraint modifier was pressed on start_grab()
291 /** Container for details about a region being dragged */
295 DraggingView (RegionView *, RegionDrag *, TimeAxisView* original_tav);
297 RegionView* view; ///< the view
298 /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on,
299 * or -1 if it is not visible.
302 /** layer that this region is currently being displayed on. This is a double
303 rather than a layer_t as we use fractional layers during drags to allow the user
304 to indicate a new layer to put a region on.
307 double initial_y; ///< the initial y position of the view before any reparenting
308 framepos_t initial_position; ///< initial position of the region
309 framepos_t initial_end; ///< initial end position of the region
310 framepos_t anchored_fade_length; ///< fade_length when anchored during drag
311 boost::shared_ptr<ARDOUR::Playlist> initial_playlist;
312 TimeAxisView* initial_time_axis_view;
315 /** Abstract base class for drags that involve region(s) */
316 class RegionDrag : public Drag, public sigc::trackable
319 RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
320 virtual ~RegionDrag () {}
324 RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
325 std::list<DraggingView> _views; ///< information about all views that are being dragged
327 /** a list of the non-hidden TimeAxisViews sorted by editor order key */
328 std::vector<TimeAxisView*> _time_axis_views;
329 int find_time_axis_view (TimeAxisView *) const;
330 int apply_track_delta (const int start, const int delta, const int skip, const bool distance_only = false) const;
331 int32_t current_music_divisor (framepos_t pos, int32_t button_state);
337 friend class DraggingView;
341 void region_going_away (RegionView *);
342 PBD::ScopedConnection death_connection;
346 /** Drags involving region motion from somewhere */
347 class RegionMotionDrag : public RegionDrag
351 RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
352 virtual ~RegionMotionDrag () {}
354 virtual void start_grab (GdkEvent *, Gdk::Cursor *);
355 virtual void motion (GdkEvent *, bool);
356 virtual void finished (GdkEvent *, bool);
357 virtual void aborted (bool);
359 /** @return true if the regions being `moved' came from somewhere on the canvas;
360 * false if they came from outside (e.g. from the region list).
362 virtual bool regions_came_from_canvas () const = 0;
366 double compute_x_delta (GdkEvent const *, ARDOUR::framepos_t *);
367 virtual bool y_movement_allowed (int, double, int skip_invisible = 0) const;
370 bool _ignore_video_lock;
371 ARDOUR::framepos_t _last_frame_position; ///< last position of the thing being dragged
372 double _total_x_delta;
373 int _last_pointer_time_axis_view;
374 double _last_pointer_layer;
382 /** Drags to move (or copy) regions that are already shown in the GUI to
383 * somewhere different.
385 class RegionMoveDrag : public RegionMotionDrag
388 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
389 virtual ~RegionMoveDrag () {}
391 void motion (GdkEvent *, bool);
392 void finished (GdkEvent *, bool);
395 bool regions_came_from_canvas () const {
399 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
400 return std::make_pair (4, 4);
403 void setup_pointer_frame_offset ();
406 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
407 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
410 void finished_no_copy (
413 ARDOUR::framecnt_t const,
414 int32_t const ev_state
420 ARDOUR::framecnt_t const,
421 int32_t const ev_state
424 RegionView* insert_region_into_playlist (
425 boost::shared_ptr<ARDOUR::Region>,
430 const int32_t sub_num
433 void remove_region_from_playlist (
434 boost::shared_ptr<ARDOUR::Region>,
435 boost::shared_ptr<ARDOUR::Playlist>,
436 PlaylistSet& modified_playlists
440 void collect_new_region_view (RegionView *);
441 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
444 RegionView* _new_region_view;
447 /** Drag to insert a region from somewhere */
448 class RegionInsertDrag : public RegionMotionDrag
451 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
453 void finished (GdkEvent *, bool);
456 bool regions_came_from_canvas () const {
461 /** Region drag in splice mode */
462 class RegionSpliceDrag : public RegionMoveDrag
465 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
467 void motion (GdkEvent *, bool);
468 void finished (GdkEvent *, bool);
472 /** Region drag in ripple mode */
474 class RegionRippleDrag : public RegionMoveDrag
477 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
478 ~RegionRippleDrag () { delete exclude; }
480 void motion (GdkEvent *, bool);
481 void finished (GdkEvent *, bool);
484 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
487 TimeAxisView *prev_tav; // where regions were most recently dragged from
488 TimeAxisView *orig_tav; // where drag started
489 ARDOUR::framecnt_t prev_amount;
490 ARDOUR::framepos_t prev_position;
491 ARDOUR::framecnt_t selection_length;
492 bool allow_moves_across_tracks; // only if all selected regions are on one track
493 ARDOUR::RegionList *exclude;
494 void add_all_after_to_views (TimeAxisView *tav, ARDOUR::framepos_t where, const RegionSelection &exclude, bool drag_in_progress);
495 void remove_unselected_from_views (ARDOUR::framecnt_t amount, bool move_regions);
499 /** "Drag" to cut a region (action only on button release) */
500 class RegionCutDrag : public Drag
503 RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
506 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
507 void motion (GdkEvent*, bool);
508 void finished (GdkEvent*, bool);
515 /** Drags to create regions */
516 class RegionCreateDrag : public Drag
519 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
521 void motion (GdkEvent *, bool);
522 void finished (GdkEvent *, bool);
526 MidiTimeAxisView* _view;
527 boost::shared_ptr<ARDOUR::Region> _region;
530 /** Drags to resize MIDI notes */
531 class NoteResizeDrag : public Drag
534 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
536 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
537 void motion (GdkEvent *, bool);
538 void finished (GdkEvent *, bool);
542 MidiRegionView* region;
549 /** Drags to move MIDI notes */
550 class NoteDrag : public Drag
553 NoteDrag (Editor*, ArdourCanvas::Item*);
555 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
556 void motion (GdkEvent *, bool);
557 void finished (GdkEvent *, bool);
562 ARDOUR::frameoffset_t total_dx (const guint) const;
563 int8_t total_dy () const;
565 MidiRegionView* _region;
567 double _cumulative_dx;
568 double _cumulative_dy;
574 class NoteCreateDrag : public Drag
577 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
580 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
581 void motion (GdkEvent *, bool);
582 void finished (GdkEvent *, bool);
585 bool active (Editing::MouseMode mode) {
586 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
589 bool y_movement_matters () const {
594 double y_to_region (double) const;
595 ARDOUR::framecnt_t grid_frames (framepos_t) const;
597 /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
598 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
599 return std::make_pair (0, 0);
602 MidiRegionView* _region_view;
603 ArdourCanvas::Rectangle* _drag_rect;
607 class HitCreateDrag : public Drag
610 HitCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
613 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
614 void motion (GdkEvent *, bool);
615 void finished (GdkEvent *, bool);
618 bool active (Editing::MouseMode mode) {
619 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
622 bool y_movement_matters () const {
627 double y_to_region (double) const;
628 ARDOUR::framecnt_t grid_frames (framepos_t) const;
630 /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
631 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
632 return std::make_pair (0, 0);
635 MidiRegionView* _region_view;
636 framepos_t _last_pos;
641 /** Drag to move MIDI patch changes */
642 class PatchChangeDrag : public Drag
645 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
647 void motion (GdkEvent *, bool);
648 void finished (GdkEvent *, bool);
651 bool y_movement_matters () const {
655 void setup_pointer_frame_offset ();
658 MidiRegionView* _region_view;
659 PatchChange* _patch_change;
660 double _cumulative_dx;
663 /** Container for details about audio regions being dragged along with video */
667 AVDraggingView (RegionView *);
669 RegionView* view; ///< the view
670 framepos_t initial_position; ///< initial position of the region
673 /** Drag of video offset */
674 class VideoTimeLineDrag : public Drag
677 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
679 void motion (GdkEvent *, bool);
680 void finished (GdkEvent *, bool);
681 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
683 bool y_movement_matters () const {
687 bool allow_vertical_autoscroll () const {
694 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
697 ARDOUR::frameoffset_t _startdrag_video_offset;
698 ARDOUR::frameoffset_t _max_backwards_drag;
702 /** Drag to trim region(s) */
703 class TrimDrag : public RegionDrag
712 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
714 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
715 void motion (GdkEvent *, bool);
716 void finished (GdkEvent *, bool);
719 bool y_movement_matters () const {
723 void setup_pointer_frame_offset ();
727 Operation _operation;
729 bool _preserve_fade_anchor;
730 bool _jump_position_when_done;
733 /** Meter marker drag */
734 class MeterMarkerDrag : public Drag
737 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
739 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
740 void motion (GdkEvent *, bool);
741 void finished (GdkEvent *, bool);
744 bool allow_vertical_autoscroll () const {
748 bool y_movement_matters () const {
752 void setup_pointer_frame_offset ();
755 MeterMarker* _marker;
756 ARDOUR::MeterSection* _real_section;
759 Editing::SnapType _old_snap_type;
760 Editing::SnapMode _old_snap_mode;
761 XMLNode* before_state;
764 /** Tempo marker drag */
765 class TempoMarkerDrag : public Drag
768 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
770 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
771 void motion (GdkEvent *, bool);
772 void finished (GdkEvent *, bool);
775 bool allow_vertical_autoscroll () const {
779 bool y_movement_matters () const {
783 void setup_pointer_frame_offset ();
786 TempoMarker* _marker;
787 ARDOUR::TempoSection* _real_section;
792 XMLNode* before_state;
795 /** BBT Ruler drag */
796 class BBTRulerDrag : public Drag
799 BBTRulerDrag (Editor *, ArdourCanvas::Item *);
801 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
802 void motion (GdkEvent *, bool);
803 void finished (GdkEvent *, bool);
806 bool allow_vertical_autoscroll () const {
810 bool y_movement_matters () const {
814 void setup_pointer_frame_offset ();
818 ARDOUR::TempoSection* _tempo;
819 XMLNode* before_state;
822 /** Drag of the playhead cursor */
823 class CursorDrag : public Drag
826 CursorDrag (Editor *, EditorCursor&, bool);
828 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
829 void motion (GdkEvent *, bool);
830 void finished (GdkEvent *, bool);
833 bool allow_vertical_autoscroll () const {
837 bool y_movement_matters () const {
842 void fake_locate (framepos_t);
844 EditorCursor& _cursor;
845 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
846 double _grab_zoom; ///< editor frames per unit when our grab started
849 /** Region fade-in drag */
850 class FadeInDrag : public RegionDrag
853 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
855 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
856 void motion (GdkEvent *, bool);
857 void finished (GdkEvent *, bool);
860 bool y_movement_matters () const {
864 void setup_pointer_frame_offset ();
867 /** Region fade-out drag */
868 class FadeOutDrag : public RegionDrag
871 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
873 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
874 void motion (GdkEvent *, bool);
875 void finished (GdkEvent *, bool);
878 bool y_movement_matters () const {
882 void setup_pointer_frame_offset ();
886 class MarkerDrag : public Drag
889 MarkerDrag (Editor *, ArdourCanvas::Item *);
892 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
893 void motion (GdkEvent *, bool);
894 void finished (GdkEvent *, bool);
897 bool allow_vertical_autoscroll () const {
901 bool y_movement_matters () const {
905 void setup_pointer_frame_offset ();
908 void update_item (ARDOUR::Location *);
910 ArdourMarker* _marker; ///< marker being dragged
911 bool _selection_changed;
912 struct CopiedLocationMarkerInfo {
913 ARDOUR::Location* location;
914 std::vector<ArdourMarker*> markers;
916 CopiedLocationMarkerInfo (ARDOUR::Location* l, ArdourMarker* m);
919 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
920 CopiedLocationInfo _copied_locations;
921 ArdourCanvas::Points _points;
924 /** Control point drag */
925 class ControlPointDrag : public Drag
928 ControlPointDrag (Editor *, ArdourCanvas::Item *);
930 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
931 void motion (GdkEvent *, bool);
932 void finished (GdkEvent *, bool);
935 bool active (Editing::MouseMode m);
939 ControlPoint* _point;
940 double _fixed_grab_x;
941 double _fixed_grab_y;
942 double _cumulative_x_drag;
943 double _cumulative_y_drag;
945 uint32_t _final_index;
946 static double _zero_gain_fraction;
949 /** Gain or automation line drag */
950 class LineDrag : public Drag
953 LineDrag (Editor *e, ArdourCanvas::Item *i);
955 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
956 void motion (GdkEvent *, bool);
957 void finished (GdkEvent *, bool);
962 AutomationLine* _line;
963 double _fixed_grab_x;
964 double _fixed_grab_y;
965 double _cumulative_y_drag;
970 /** Transient feature line drags*/
971 class FeatureLineDrag : public Drag
974 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
976 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
977 void motion (GdkEvent *, bool);
978 void finished (GdkEvent *, bool);
983 ArdourCanvas::Line* _line;
984 AudioRegionView* _arv;
986 double _region_view_grab_x;
987 double _cumulative_x_drag;
993 /** Dragging of a rubberband rectangle for selecting things */
994 class RubberbandSelectDrag : public Drag
997 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
999 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1000 void motion (GdkEvent *, bool);
1001 void finished (GdkEvent *, bool);
1002 void aborted (bool);
1004 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1005 return std::make_pair (8, 1);
1008 void do_select_things (GdkEvent *, bool);
1010 /** Select some things within a rectangle.
1011 * @param button_state The button state from the GdkEvent.
1012 * @param x1 The left-hand side of the rectangle in session frames.
1013 * @param x2 The right-hand side of the rectangle in session frames.
1014 * @param y1 The top of the rectangle in trackview coordinates.
1015 * @param y2 The bottom of the rectangle in trackview coordinates.
1016 * @param drag_in_progress true if the drag is currently happening.
1018 virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
1020 virtual void deselect_things () = 0;
1023 bool _vertical_only;
1026 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
1027 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
1030 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
1032 void select_things (int, framepos_t, framepos_t, double, double, bool);
1033 void deselect_things ();
1036 /** A RubberbandSelectDrag for selecting MIDI notes */
1037 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
1040 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
1042 void select_things (int, framepos_t, framepos_t, double, double, bool);
1043 void deselect_things ();
1046 MidiRegionView* _region_view;
1049 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
1050 class MidiVerticalSelectDrag : public RubberbandSelectDrag
1053 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
1055 void select_things (int, framepos_t, framepos_t, double, double, bool);
1056 void deselect_things ();
1059 MidiRegionView* _region_view;
1062 /** Region drag in time-FX mode */
1063 class TimeFXDrag : public RegionDrag
1066 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
1068 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1069 void motion (GdkEvent *, bool);
1070 void finished (GdkEvent *, bool);
1071 void aborted (bool);
1074 /** Scrub drag in audition mode */
1075 class ScrubDrag : public Drag
1078 ScrubDrag (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);
1086 /** Drag in range select mode */
1087 class SelectionDrag : public Drag
1098 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
1100 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1101 void motion (GdkEvent *, bool);
1102 void finished (GdkEvent *, bool);
1103 void aborted (bool);
1105 void setup_pointer_frame_offset ();
1108 Operation _operation;
1110 TrackSelection _track_selection_at_start;
1111 bool _time_selection_at_start;
1112 framepos_t start_at_start;
1113 framepos_t end_at_start;
1116 /** Range marker drag */
1117 class RangeMarkerBarDrag : public Drag
1123 CreateTransportMarker,
1127 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1128 ~RangeMarkerBarDrag ();
1130 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1131 void motion (GdkEvent *, bool);
1132 void finished (GdkEvent *, bool);
1133 void aborted (bool);
1135 bool allow_vertical_autoscroll () const {
1139 bool y_movement_matters () const {
1144 void update_item (ARDOUR::Location *);
1146 Operation _operation;
1147 ArdourCanvas::Rectangle* _drag_rect;
1151 /** Drag of rectangle to set zoom */
1152 class MouseZoomDrag : public Drag
1155 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1157 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1158 void motion (GdkEvent *, bool);
1159 void finished (GdkEvent *, bool);
1160 void aborted (bool);
1162 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1163 return std::make_pair (4, 4);
1170 /** Drag of a range of automation data (either on an automation track or region gain),
1171 * changing value but not position.
1173 class AutomationRangeDrag : public Drag
1176 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1177 AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &);
1179 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1180 void motion (GdkEvent *, bool);
1181 void finished (GdkEvent *, bool);
1182 void aborted (bool);
1184 bool x_movement_matters () const {
1189 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1190 double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
1191 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1193 std::list<ARDOUR::AudioRange> _ranges;
1195 /** A line that is part of the drag */
1197 boost::shared_ptr<AutomationLine> line; ///< the line
1198 std::list<ControlPoint*> points; ///< points to drag on the line
1199 std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
1200 XMLNode* state; ///< the XML state node before the drag
1201 double original_fraction; ///< initial y-fraction before the drag
1204 std::list<Line> _lines;
1206 bool _nothing_to_drag;
1210 /** Drag of one edge of an xfade
1212 class CrossfadeEdgeDrag : public Drag
1215 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1217 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1218 void motion (GdkEvent*, bool);
1219 void finished (GdkEvent*, bool);
1220 void aborted (bool);
1222 bool y_movement_matters () const {
1226 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1227 return std::make_pair (4, 4);
1231 AudioRegionView* arv;
1235 class RulerZoomDrag : public Drag
1238 RulerZoomDrag (Editor*, ArdourCanvas::Item*);
1240 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1241 void motion (GdkEvent *, bool);
1242 void finished (GdkEvent*, bool);
1243 void aborted (bool);
1245 virtual bool allow_vertical_autoscroll () const {
1251 #endif /* __gtk2_ardour_editor_drag_h_ */