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::MusicFrame 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;
245 double snap_delta_music (guint const) const;
247 double current_pointer_x () const;
248 double current_pointer_y () const;
250 /* sets snap delta from unsnapped pos */
251 void setup_snap_delta (ARDOUR::MusicFrame pos);
253 boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*, bool commit);
255 void show_verbose_cursor_time (framepos_t);
256 void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0);
257 void show_verbose_cursor_text (std::string const &);
259 Editor* _editor; ///< our editor
261 ArdourCanvas::Item* _item; ///< our item
262 /** Offset from the mouse's position for the drag to the start of the thing that is being dragged */
263 ARDOUR::framecnt_t _pointer_frame_offset;
264 bool _x_constrained; ///< true if x motion is constrained, otherwise false
265 bool _y_constrained; ///< true if y motion is constrained, otherwise false
266 bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
269 bool _trackview_only; ///< true if pointer y value should always be relative to the top of the trackview group
270 bool _move_threshold_passed; ///< true if the move threshold has been passed, otherwise false
271 bool _starting_point_passed; ///< true if we called move () with first_move flag, otherwise false
272 bool _initially_vertical; ///< true if after move threshold is passed we appear to be moving vertically; undefined before that
273 bool _was_double_click; ///< true if drag initiated by a double click event
274 double _grab_x; ///< trackview x of the grab start position
275 double _grab_y; ///< y of the grab start position, possibly adjusted if _trackview_only is true
276 double _last_pointer_x; ///< trackview x of the pointer last time a motion occurred
277 double _last_pointer_y; ///< trackview y of the pointer last time a motion occurred
278 ARDOUR::framepos_t _raw_grab_frame; ///< unsnapped frame that the mouse was at when start_grab was called, or 0
279 ARDOUR::framepos_t _grab_frame; ///< adjusted_frame that the mouse was at when start_grab was called, or 0
280 ARDOUR::framepos_t _last_pointer_frame; ///< adjusted_frame the last time a motion occurred
282 /* difference between some key position's snapped and unsnapped
283 * framepos. used for relative snap.
285 framepos_t _snap_delta;
286 double _snap_delta_music;
287 CursorContext::Handle _cursor_ctx; ///< cursor change context
288 bool _constraint_pressed; ///< if the keyboard indicated constraint modifier was pressed on start_grab()
293 /** Container for details about a region being dragged */
297 DraggingView (RegionView *, RegionDrag *, TimeAxisView* original_tav);
299 RegionView* view; ///< the view
300 /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on,
301 * or -1 if it is not visible.
304 /** layer that this region is currently being displayed on. This is a double
305 rather than a layer_t as we use fractional layers during drags to allow the user
306 to indicate a new layer to put a region on.
309 double initial_y; ///< the initial y position of the view before any reparenting
310 framepos_t initial_position; ///< initial position of the region
311 framepos_t initial_end; ///< initial end position of the region
312 framepos_t anchored_fade_length; ///< fade_length when anchored during drag
313 boost::shared_ptr<ARDOUR::Playlist> initial_playlist;
314 TimeAxisView* initial_time_axis_view;
317 /** Abstract base class for drags that involve region(s) */
318 class RegionDrag : public Drag, public sigc::trackable
321 RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
322 virtual ~RegionDrag () {}
326 RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
327 std::list<DraggingView> _views; ///< information about all views that are being dragged
329 /** a list of the non-hidden TimeAxisViews sorted by editor order key */
330 std::vector<TimeAxisView*> _time_axis_views;
331 int find_time_axis_view (TimeAxisView *) const;
332 int apply_track_delta (const int start, const int delta, const int skip, const bool distance_only = false) const;
338 friend class DraggingView;
342 void region_going_away (RegionView *);
343 PBD::ScopedConnection death_connection;
347 /** Drags involving region motion from somewhere */
348 class RegionMotionDrag : public RegionDrag
352 RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
353 virtual ~RegionMotionDrag () {}
355 virtual void start_grab (GdkEvent *, Gdk::Cursor *);
356 virtual void motion (GdkEvent *, bool);
357 virtual void finished (GdkEvent *, bool);
358 virtual void aborted (bool);
360 /** @return true if the regions being `moved' came from somewhere on the canvas;
361 * false if they came from outside (e.g. from the region list).
363 virtual bool regions_came_from_canvas () const = 0;
367 double compute_x_delta (GdkEvent const *, ARDOUR::MusicFrame *);
368 virtual bool y_movement_allowed (int, double, int skip_invisible = 0) const;
371 bool _ignore_video_lock;
372 ARDOUR::MusicFrame _last_position; ///< last position of the thing being dragged
373 double _total_x_delta;
374 int _last_pointer_time_axis_view;
375 double _last_pointer_layer;
383 /** Drags to move (or copy) regions that are already shown in the GUI to
384 * somewhere different.
386 class RegionMoveDrag : public RegionMotionDrag
389 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
390 virtual ~RegionMoveDrag () {}
392 void motion (GdkEvent *, bool);
393 void finished (GdkEvent *, bool);
396 bool regions_came_from_canvas () const {
400 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
401 return std::make_pair (4, 4);
404 void setup_pointer_frame_offset ();
407 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
408 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
411 void finished_no_copy (
415 int32_t const ev_state
422 int32_t const ev_state
425 RegionView* insert_region_into_playlist (
426 boost::shared_ptr<ARDOUR::Region>,
432 bool for_music = false
435 void remove_region_from_playlist (
436 boost::shared_ptr<ARDOUR::Region>,
437 boost::shared_ptr<ARDOUR::Playlist>,
438 PlaylistSet& modified_playlists
442 void collect_new_region_view (RegionView *);
443 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
446 RegionView* _new_region_view;
449 /** Drag to insert a region from somewhere */
450 class RegionInsertDrag : public RegionMotionDrag
453 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
455 void finished (GdkEvent *, bool);
458 bool regions_came_from_canvas () const {
463 /** Region drag in splice mode */
464 class RegionSpliceDrag : public RegionMoveDrag
467 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
469 void motion (GdkEvent *, bool);
470 void finished (GdkEvent *, bool);
474 /** Region drag in ripple mode */
476 class RegionRippleDrag : public RegionMoveDrag
479 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
480 ~RegionRippleDrag () { delete exclude; }
482 void motion (GdkEvent *, bool);
483 void finished (GdkEvent *, bool);
486 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
489 TimeAxisView *prev_tav; // where regions were most recently dragged from
490 TimeAxisView *orig_tav; // where drag started
491 ARDOUR::framecnt_t prev_amount;
492 ARDOUR::framepos_t prev_position;
493 ARDOUR::framecnt_t selection_length;
494 bool allow_moves_across_tracks; // only if all selected regions are on one track
495 ARDOUR::RegionList *exclude;
496 void add_all_after_to_views (TimeAxisView *tav, ARDOUR::framepos_t where, const RegionSelection &exclude, bool drag_in_progress);
497 void remove_unselected_from_views (ARDOUR::framecnt_t amount, bool move_regions);
501 /** "Drag" to cut a region (action only on button release) */
502 class RegionCutDrag : public Drag
505 RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
508 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
509 void motion (GdkEvent*, bool);
510 void finished (GdkEvent*, bool);
517 /** Drags to create regions */
518 class RegionCreateDrag : public Drag
521 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
523 void motion (GdkEvent *, bool);
524 void finished (GdkEvent *, bool);
528 MidiTimeAxisView* _view;
529 boost::shared_ptr<ARDOUR::Region> _region;
532 /** Drags to resize MIDI notes */
533 class NoteResizeDrag : public Drag
536 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
538 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
539 void motion (GdkEvent *, bool);
540 void finished (GdkEvent *, bool);
544 MidiRegionView* region;
551 /** Drags to move MIDI notes */
552 class NoteDrag : public Drag
555 NoteDrag (Editor*, ArdourCanvas::Item*);
557 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
558 void motion (GdkEvent *, bool);
559 void finished (GdkEvent *, bool);
562 void setup_pointer_frame_offset ();
565 double total_dx (GdkEvent * event) const; // total movement in quarter notes
566 int8_t total_dy () const;
568 MidiRegionView* _region;
570 double _cumulative_dx;
571 double _cumulative_dy;
572 double _earliest; // earliest quarter note in note selection
578 class NoteCreateDrag : public Drag
581 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
584 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
585 void motion (GdkEvent *, bool);
586 void finished (GdkEvent *, bool);
589 bool active (Editing::MouseMode mode) {
590 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
593 bool y_movement_matters () const {
598 double y_to_region (double) const;
599 ARDOUR::framecnt_t grid_frames (framepos_t) const;
601 /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
602 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
603 return std::make_pair (0, 0);
606 MidiRegionView* _region_view;
607 ArdourCanvas::Rectangle* _drag_rect;
611 class HitCreateDrag : public Drag
614 HitCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
617 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
618 void motion (GdkEvent *, bool);
619 void finished (GdkEvent *, bool);
622 bool active (Editing::MouseMode mode) {
623 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
626 bool y_movement_matters () const {
631 double y_to_region (double) const;
632 ARDOUR::framecnt_t grid_frames (framepos_t) const;
634 /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
635 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
636 return std::make_pair (0, 0);
639 MidiRegionView* _region_view;
640 framepos_t _last_pos;
645 /** Drag to move MIDI patch changes */
646 class PatchChangeDrag : public Drag
649 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
651 void motion (GdkEvent *, bool);
652 void finished (GdkEvent *, bool);
655 bool y_movement_matters () const {
659 void setup_pointer_frame_offset ();
662 MidiRegionView* _region_view;
663 PatchChange* _patch_change;
664 double _cumulative_dx;
667 /** Container for details about audio regions being dragged along with video */
671 AVDraggingView (RegionView *);
673 RegionView* view; ///< the view
674 framepos_t initial_position; ///< initial position of the region
677 /** Drag of video offset */
678 class VideoTimeLineDrag : public Drag
681 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
683 void motion (GdkEvent *, bool);
684 void finished (GdkEvent *, bool);
685 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
687 bool y_movement_matters () const {
691 bool allow_vertical_autoscroll () const {
698 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
701 ARDOUR::frameoffset_t _startdrag_video_offset;
702 ARDOUR::frameoffset_t _max_backwards_drag;
706 /** Drag to trim region(s) */
707 class TrimDrag : public RegionDrag
716 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
718 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
719 void motion (GdkEvent *, bool);
720 void finished (GdkEvent *, bool);
723 bool y_movement_matters () const {
727 void setup_pointer_frame_offset ();
731 Operation _operation;
733 bool _preserve_fade_anchor;
734 bool _jump_position_when_done;
737 /** Meter marker drag */
738 class MeterMarkerDrag : public Drag
741 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
743 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
744 void motion (GdkEvent *, bool);
745 void finished (GdkEvent *, bool);
748 bool allow_vertical_autoscroll () const {
752 bool y_movement_matters () const {
756 void setup_pointer_frame_offset ();
759 MeterMarker* _marker;
760 ARDOUR::MeterSection* _real_section;
763 Editing::SnapType _old_snap_type;
764 Editing::SnapMode _old_snap_mode;
765 XMLNode* before_state;
768 /** Tempo marker drag */
769 class TempoMarkerDrag : public Drag
772 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
774 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
775 void motion (GdkEvent *, bool);
776 void finished (GdkEvent *, bool);
779 bool allow_vertical_autoscroll () const {
783 bool y_movement_matters () const {
787 void setup_pointer_frame_offset ();
790 TempoMarker* _marker;
791 ARDOUR::TempoSection* _real_section;
795 ARDOUR::Tempo _grab_bpm;
797 XMLNode* _before_state;
800 /** BBT Ruler drag */
801 class BBTRulerDrag : public Drag
804 BBTRulerDrag (Editor *, ArdourCanvas::Item *);
806 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
807 void motion (GdkEvent *, bool);
808 void finished (GdkEvent *, bool);
811 bool allow_vertical_autoscroll () const {
815 bool y_movement_matters () const {
819 void setup_pointer_frame_offset ();
823 ARDOUR::TempoSection* _tempo;
824 XMLNode* _before_state;
827 /** tempo curve twist drag */
828 class TempoTwistDrag : public Drag
831 TempoTwistDrag (Editor *, ArdourCanvas::Item *);
833 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
834 void motion (GdkEvent *, bool);
835 void finished (GdkEvent *, bool);
838 bool allow_vertical_autoscroll () const {
842 bool y_movement_matters () const {
846 void setup_pointer_frame_offset ();
850 ARDOUR::Tempo _grab_tempo;
851 ARDOUR::TempoSection* _tempo;
852 ARDOUR::TempoSection* _next_tempo;
854 XMLNode* _before_state;
858 /** tempo curve twist drag */
859 class TempoEndDrag : public Drag
862 TempoEndDrag (Editor *, ArdourCanvas::Item *);
864 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
865 void motion (GdkEvent *, bool);
866 void finished (GdkEvent *, bool);
869 bool allow_vertical_autoscroll () const {
873 bool y_movement_matters () const {
877 void setup_pointer_frame_offset ();
881 ARDOUR::TempoSection* _tempo;
882 XMLNode* _before_state;
885 /** Drag of the playhead cursor */
886 class CursorDrag : public Drag
889 CursorDrag (Editor *, EditorCursor&, bool);
891 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
892 void motion (GdkEvent *, bool);
893 void finished (GdkEvent *, bool);
896 bool allow_vertical_autoscroll () const {
900 bool y_movement_matters () const {
905 void fake_locate (framepos_t);
907 EditorCursor& _cursor;
908 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
909 double _grab_zoom; ///< editor frames per unit when our grab started
912 /** Region fade-in drag */
913 class FadeInDrag : public RegionDrag
916 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
918 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
919 void motion (GdkEvent *, bool);
920 void finished (GdkEvent *, bool);
923 bool y_movement_matters () const {
927 void setup_pointer_frame_offset ();
930 /** Region fade-out drag */
931 class FadeOutDrag : public RegionDrag
934 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
936 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
937 void motion (GdkEvent *, bool);
938 void finished (GdkEvent *, bool);
941 bool y_movement_matters () const {
945 void setup_pointer_frame_offset ();
949 class MarkerDrag : public Drag
952 MarkerDrag (Editor *, ArdourCanvas::Item *);
955 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
956 void motion (GdkEvent *, bool);
957 void finished (GdkEvent *, bool);
960 bool allow_vertical_autoscroll () const {
964 bool y_movement_matters () const {
968 void setup_pointer_frame_offset ();
971 void update_item (ARDOUR::Location *);
973 ArdourMarker* _marker; ///< marker being dragged
974 bool _selection_changed;
975 struct CopiedLocationMarkerInfo {
976 ARDOUR::Location* location;
977 std::vector<ArdourMarker*> markers;
979 CopiedLocationMarkerInfo (ARDOUR::Location* l, ArdourMarker* m);
982 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
983 CopiedLocationInfo _copied_locations;
984 ArdourCanvas::Points _points;
987 /** Control point drag */
988 class ControlPointDrag : public Drag
991 ControlPointDrag (Editor *, ArdourCanvas::Item *);
993 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
994 void motion (GdkEvent *, bool);
995 void finished (GdkEvent *, bool);
998 bool active (Editing::MouseMode m);
1002 ControlPoint* _point;
1003 double _fixed_grab_x;
1004 double _fixed_grab_y;
1005 double _cumulative_x_drag;
1006 double _cumulative_y_drag;
1008 uint32_t _final_index;
1009 static double _zero_gain_fraction;
1012 /** Gain or automation line drag */
1013 class LineDrag : public Drag
1016 LineDrag (Editor *e, ArdourCanvas::Item *i);
1018 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1019 void motion (GdkEvent *, bool);
1020 void finished (GdkEvent *, bool);
1021 void aborted (bool);
1025 AutomationLine* _line;
1026 double _fixed_grab_x;
1027 double _fixed_grab_y;
1028 double _cumulative_y_drag;
1033 /** Transient feature line drags*/
1034 class FeatureLineDrag : public Drag
1037 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
1039 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1040 void motion (GdkEvent *, bool);
1041 void finished (GdkEvent *, bool);
1042 void aborted (bool);
1046 ArdourCanvas::Line* _line;
1047 AudioRegionView* _arv;
1049 double _region_view_grab_x;
1050 double _cumulative_x_drag;
1056 /** Dragging of a rubberband rectangle for selecting things */
1057 class RubberbandSelectDrag : public Drag
1060 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
1062 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1063 void motion (GdkEvent *, bool);
1064 void finished (GdkEvent *, bool);
1065 void aborted (bool);
1067 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1068 return std::make_pair (8, 1);
1071 void do_select_things (GdkEvent *, bool);
1073 /** Select some things within a rectangle.
1074 * @param button_state The button state from the GdkEvent.
1075 * @param x1 The left-hand side of the rectangle in session frames.
1076 * @param x2 The right-hand side of the rectangle in session frames.
1077 * @param y1 The top of the rectangle in trackview coordinates.
1078 * @param y2 The bottom of the rectangle in trackview coordinates.
1079 * @param drag_in_progress true if the drag is currently happening.
1081 virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
1083 virtual void deselect_things () = 0;
1086 bool _vertical_only;
1089 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
1090 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
1093 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
1095 void select_things (int, framepos_t, framepos_t, double, double, bool);
1096 void deselect_things ();
1099 /** A RubberbandSelectDrag for selecting MIDI notes */
1100 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
1103 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
1105 void select_things (int, framepos_t, framepos_t, double, double, bool);
1106 void deselect_things ();
1109 MidiRegionView* _region_view;
1112 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
1113 class MidiVerticalSelectDrag : public RubberbandSelectDrag
1116 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
1118 void select_things (int, framepos_t, framepos_t, double, double, bool);
1119 void deselect_things ();
1122 MidiRegionView* _region_view;
1125 /** Region drag in time-FX mode */
1126 class TimeFXDrag : public RegionDrag
1129 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
1131 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1132 void motion (GdkEvent *, bool);
1133 void finished (GdkEvent *, bool);
1134 void aborted (bool);
1137 /** Scrub drag in audition mode */
1138 class ScrubDrag : public Drag
1141 ScrubDrag (Editor *, ArdourCanvas::Item *);
1143 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1144 void motion (GdkEvent *, bool);
1145 void finished (GdkEvent *, bool);
1146 void aborted (bool);
1149 /** Drag in range select mode */
1150 class SelectionDrag : public Drag
1161 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
1163 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1164 void motion (GdkEvent *, bool);
1165 void finished (GdkEvent *, bool);
1166 void aborted (bool);
1168 void setup_pointer_frame_offset ();
1171 Operation _operation;
1173 TrackSelection _track_selection_at_start;
1174 bool _time_selection_at_start;
1175 framepos_t start_at_start;
1176 framepos_t end_at_start;
1179 /** Range marker drag */
1180 class RangeMarkerBarDrag : public Drag
1186 CreateTransportMarker,
1190 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1191 ~RangeMarkerBarDrag ();
1193 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1194 void motion (GdkEvent *, bool);
1195 void finished (GdkEvent *, bool);
1196 void aborted (bool);
1198 bool allow_vertical_autoscroll () const {
1202 bool y_movement_matters () const {
1207 void update_item (ARDOUR::Location *);
1209 Operation _operation;
1210 ArdourCanvas::Rectangle* _drag_rect;
1214 /** Drag of rectangle to set zoom */
1215 class MouseZoomDrag : public Drag
1218 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1220 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1221 void motion (GdkEvent *, bool);
1222 void finished (GdkEvent *, bool);
1223 void aborted (bool);
1225 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1226 return std::make_pair (4, 4);
1233 /** Drag of a range of automation data (either on an automation track or region gain),
1234 * changing value but not position.
1236 class AutomationRangeDrag : public Drag
1239 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1240 AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &);
1242 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1243 void motion (GdkEvent *, bool);
1244 void finished (GdkEvent *, bool);
1245 void aborted (bool);
1247 bool x_movement_matters () const {
1252 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1253 double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
1254 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1256 std::list<ARDOUR::AudioRange> _ranges;
1258 /** A line that is part of the drag */
1260 boost::shared_ptr<AutomationLine> line; ///< the line
1261 std::list<ControlPoint*> points; ///< points to drag on the line
1262 std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
1263 XMLNode* state; ///< the XML state node before the drag
1264 double original_fraction; ///< initial y-fraction before the drag
1267 std::list<Line> _lines;
1269 bool _nothing_to_drag;
1273 /** Drag of one edge of an xfade
1275 class CrossfadeEdgeDrag : public Drag
1278 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1280 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1281 void motion (GdkEvent*, bool);
1282 void finished (GdkEvent*, bool);
1283 void aborted (bool);
1285 bool y_movement_matters () const {
1289 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1290 return std::make_pair (4, 4);
1294 AudioRegionView* arv;
1298 class RulerZoomDrag : public Drag
1301 RulerZoomDrag (Editor*, ArdourCanvas::Item*);
1303 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1304 void motion (GdkEvent *, bool);
1305 void finished (GdkEvent*, bool);
1306 void aborted (bool);
1308 virtual bool allow_vertical_autoscroll () const {
1314 #endif /* __gtk2_ardour_editor_drag_h_ */