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"
42 namespace ArdourCanvas {
49 class StatefulDiffCommand;
56 class MidiTimeAxisView;
61 class RouteTimeAxisView;
62 class RegionSelection;
68 class AudioRegionView;
70 class AutomationTimeAxisView;
72 /** Class to manage current drags */
77 DragManager (Editor* e);
80 bool motion_handler (GdkEvent *, bool);
84 void set (Drag *, GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
85 void start_grab (GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
86 bool end_grab (GdkEvent *);
87 bool have_item (ArdourCanvas::Item *) const;
89 void mark_double_click ();
91 /** @return true if an end drag or abort is in progress */
92 bool ending () const {
96 bool active () const {
97 return !_drags.empty ();
100 /** @return current pointer x position in canvas coordinates */
101 double current_pointer_x () const {
102 return _current_pointer_x;
105 /** @return current pointer y position in canvas coordinates */
106 double current_pointer_y () const {
107 return _current_pointer_y;
110 /** @return current pointer frame */
111 ARDOUR::framepos_t current_pointer_frame () const {
112 return _current_pointer_frame;
117 std::list<Drag*> _drags;
118 bool _ending; ///< true if end_grab or abort is in progress, otherwise false
119 double _current_pointer_x; ///< canvas-coordinate space x of the current pointer
120 double _current_pointer_y; ///< canvas-coordinate space y of the current pointer
121 ARDOUR::framepos_t _current_pointer_frame; ///< frame that the pointer is now at
122 bool _old_follow_playhead; ///< state of Editor::follow_playhead() before the drags started
125 /** Abstract base class for dragging of things within the editor */
129 Drag (Editor *, ArdourCanvas::Item *, bool trackview_only = true);
132 void set_manager (DragManager* m) {
136 /** @return the canvas item being dragged */
137 ArdourCanvas::Item* item () const {
141 void swap_grab (ArdourCanvas::Item *, Gdk::Cursor *, uint32_t);
142 bool motion_handler (GdkEvent*, bool);
145 ARDOUR::framepos_t adjusted_frame (ARDOUR::framepos_t, GdkEvent const *, bool snap = true) const;
146 ARDOUR::framepos_t adjusted_current_frame (GdkEvent const *, bool snap = true) const;
148 bool was_double_click() const { return _was_double_click; }
149 void set_double_click (bool yn) { _was_double_click = yn; }
151 /** Called to start a grab of an item.
152 * @param e Event that caused the grab to start.
153 * @param c Cursor to use, or 0.
155 virtual void start_grab (GdkEvent* e, Gdk::Cursor* c = 0);
157 virtual bool end_grab (GdkEvent *);
159 /** Called when a drag motion has occurred.
160 * @param e Event describing the motion.
161 * @param f true if this is the first movement, otherwise false.
163 virtual void motion (GdkEvent* e, bool f) = 0;
165 /** Called when a drag has finished.
166 * @param e Event describing the finish.
167 * @param m true if some movement occurred, otherwise false.
169 virtual void finished (GdkEvent* e, bool m) = 0;
171 /** Called to abort a drag and return things to how
172 * they were before it started.
173 * @param m true if some movement occurred, otherwise false.
175 virtual void aborted (bool m) = 0;
177 /** @param m Mouse mode.
178 * @return true if this drag should happen in this mouse mode.
180 virtual bool active (Editing::MouseMode m) {
184 /** @return minimum number of frames (in x) and pixels (in y) that should be considered a movement */
185 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
186 return std::make_pair (1, 1);
189 virtual bool allow_vertical_autoscroll () const {
193 /** @return true if x movement matters to this drag */
194 virtual bool x_movement_matters () const {
198 /** @return true if y movement matters to this drag */
199 virtual bool y_movement_matters () const {
203 bool initially_vertical() const {
204 return _initially_vertical;
207 /** Set up the _pointer_frame_offset */
208 virtual void setup_pointer_frame_offset () {
209 _pointer_frame_offset = 0;
214 double grab_x () const {
218 double grab_y () const {
222 ARDOUR::framepos_t raw_grab_frame () const {
223 return _raw_grab_frame;
226 ARDOUR::framepos_t grab_frame () const {
230 double last_pointer_x () const {
231 return _last_pointer_x;
234 double last_pointer_y () const {
235 return _last_pointer_y;
238 ARDOUR::framepos_t last_pointer_frame () const {
239 return _last_pointer_frame;
242 ARDOUR::frameoffset_t snap_delta (guint const) const;
244 double current_pointer_x () const;
245 double current_pointer_y () const;
247 /* sets snap delta from unsnapped pos */
248 void setup_snap_delta (framepos_t pos);
250 boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*, bool commit);
252 void show_verbose_cursor_time (framepos_t);
253 void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0);
254 void show_verbose_cursor_text (std::string const &);
256 Editor* _editor; ///< our editor
258 ArdourCanvas::Item* _item; ///< our item
259 /** Offset from the mouse's position for the drag to the start of the thing that is being dragged */
260 ARDOUR::framecnt_t _pointer_frame_offset;
261 bool _x_constrained; ///< true if x motion is constrained, otherwise false
262 bool _y_constrained; ///< true if y motion is constrained, otherwise false
263 bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
266 bool _trackview_only; ///< true if pointer y value should always be relative to the top of the trackview group
267 bool _move_threshold_passed; ///< true if the move threshold has been passed, otherwise false
268 bool _starting_point_passed; ///< true if we called move () with first_move flag, otherwise false
269 bool _initially_vertical; ///< true if after move threshold is passed we appear to be moving vertically; undefined before that
270 bool _was_double_click; ///< true if drag initiated by a double click event
271 double _grab_x; ///< trackview x of the grab start position
272 double _grab_y; ///< y of the grab start position, possibly adjusted if _trackview_only is true
273 double _last_pointer_x; ///< trackview x of the pointer last time a motion occurred
274 double _last_pointer_y; ///< trackview y of the pointer last time a motion occurred
275 ARDOUR::framepos_t _raw_grab_frame; ///< unsnapped frame that the mouse was at when start_grab was called, or 0
276 ARDOUR::framepos_t _grab_frame; ///< adjusted_frame that the mouse was at when start_grab was called, or 0
277 ARDOUR::framepos_t _last_pointer_frame; ///< adjusted_frame the last time a motion occurred
279 /* difference between some key position's snapped and unsnapped
280 * framepos. used for relative snap.
282 ARDOUR::frameoffset_t _snap_delta;
283 CursorContext::Handle _cursor_ctx; ///< cursor change context
288 /** Container for details about a region being dragged */
292 DraggingView (RegionView *, RegionDrag *, TimeAxisView* original_tav);
294 RegionView* view; ///< the view
295 /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on,
296 * or -1 if it is not visible.
299 /** layer that this region is currently being displayed on. This is a double
300 rather than a layer_t as we use fractional layers during drags to allow the user
301 to indicate a new layer to put a region on.
304 double initial_y; ///< the initial y position of the view before any reparenting
305 framepos_t initial_position; ///< initial position of the region
306 framepos_t initial_end; ///< initial end position of the region
307 framepos_t anchored_fade_length; ///< fade_length when anchored during drag
308 boost::shared_ptr<ARDOUR::Playlist> initial_playlist;
309 TimeAxisView* initial_time_axis_view;
312 /** Abstract base class for drags that involve region(s) */
313 class RegionDrag : public Drag, public sigc::trackable
316 RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
317 virtual ~RegionDrag () {}
321 RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
322 std::list<DraggingView> _views; ///< information about all views that are being dragged
324 /** a list of the non-hidden TimeAxisViews sorted by editor order key */
325 std::vector<TimeAxisView*> _time_axis_views;
326 int find_time_axis_view (TimeAxisView *) const;
327 int apply_track_delta (const int start, const int delta, const int skip, const bool distance_only = false) const;
333 friend class DraggingView;
337 void region_going_away (RegionView *);
338 PBD::ScopedConnection death_connection;
342 /** Drags involving region motion from somewhere */
343 class RegionMotionDrag : public RegionDrag
347 RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
348 virtual ~RegionMotionDrag () {}
350 virtual void start_grab (GdkEvent *, Gdk::Cursor *);
351 virtual void motion (GdkEvent *, bool);
352 virtual void finished (GdkEvent *, bool);
353 virtual void aborted (bool);
355 /** @return true if the regions being `moved' came from somewhere on the canvas;
356 * false if they came from outside (e.g. from the region list).
358 virtual bool regions_came_from_canvas () const = 0;
362 double compute_x_delta (GdkEvent const *, ARDOUR::framepos_t *);
363 virtual bool y_movement_allowed (int, double, int skip_invisible = 0) const;
366 bool _ignore_video_lock;
367 ARDOUR::framepos_t _last_frame_position; ///< last position of the thing being dragged
368 double _total_x_delta;
369 int _last_pointer_time_axis_view;
370 double _last_pointer_layer;
378 /** Drags to move (or copy) regions that are already shown in the GUI to
379 * somewhere different.
381 class RegionMoveDrag : public RegionMotionDrag
384 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
385 virtual ~RegionMoveDrag () {}
387 void motion (GdkEvent *, bool);
388 void finished (GdkEvent *, bool);
391 bool regions_came_from_canvas () const {
395 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
396 return std::make_pair (4, 4);
399 void setup_pointer_frame_offset ();
402 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
403 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
406 void finished_no_copy (
409 ARDOUR::framecnt_t const
415 ARDOUR::framecnt_t const
418 RegionView* insert_region_into_playlist (
419 boost::shared_ptr<ARDOUR::Region>,
426 void remove_region_from_playlist (
427 boost::shared_ptr<ARDOUR::Region>,
428 boost::shared_ptr<ARDOUR::Playlist>,
429 PlaylistSet& modified_playlists
433 void collect_new_region_view (RegionView *);
434 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
437 RegionView* _new_region_view;
440 /** Drag to insert a region from somewhere */
441 class RegionInsertDrag : public RegionMotionDrag
444 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
446 void finished (GdkEvent *, bool);
449 bool regions_came_from_canvas () const {
454 /** Region drag in splice mode */
455 class RegionSpliceDrag : public RegionMoveDrag
458 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
460 void motion (GdkEvent *, bool);
461 void finished (GdkEvent *, bool);
465 /** Region drag in ripple mode */
467 class RegionRippleDrag : public RegionMoveDrag
470 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
471 ~RegionRippleDrag () { delete exclude; }
473 void motion (GdkEvent *, bool);
474 void finished (GdkEvent *, bool);
477 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
480 TimeAxisView *prev_tav; // where regions were most recently dragged from
481 TimeAxisView *orig_tav; // where drag started
482 ARDOUR::framecnt_t prev_amount;
483 ARDOUR::framepos_t prev_position;
484 ARDOUR::framecnt_t selection_length;
485 bool allow_moves_across_tracks; // only if all selected regions are on one track
486 ARDOUR::RegionList *exclude;
487 void add_all_after_to_views (TimeAxisView *tav, ARDOUR::framepos_t where, const RegionSelection &exclude, bool drag_in_progress);
488 void remove_unselected_from_views (ARDOUR::framecnt_t amount, bool move_regions);
492 /** "Drag" to cut a region (action only on button release) */
493 class RegionCutDrag : public Drag
496 RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
499 void motion (GdkEvent*, bool);
500 void finished (GdkEvent*, bool);
507 /** Drags to create regions */
508 class RegionCreateDrag : public Drag
511 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
513 void motion (GdkEvent *, bool);
514 void finished (GdkEvent *, bool);
518 MidiTimeAxisView* _view;
519 boost::shared_ptr<ARDOUR::Region> _region;
522 /** Drags to resize MIDI notes */
523 class NoteResizeDrag : public Drag
526 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
528 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
529 void motion (GdkEvent *, bool);
530 void finished (GdkEvent *, bool);
534 MidiRegionView* region;
541 /** Drags to move MIDI notes */
542 class NoteDrag : public Drag
545 NoteDrag (Editor*, ArdourCanvas::Item*);
547 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
548 void motion (GdkEvent *, bool);
549 void finished (GdkEvent *, bool);
554 ARDOUR::frameoffset_t total_dx (const guint) const;
555 int8_t total_dy () const;
557 MidiRegionView* _region;
559 double _cumulative_dx;
560 double _cumulative_dy;
565 class NoteCreateDrag : public Drag
568 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
571 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
572 void motion (GdkEvent *, bool);
573 void finished (GdkEvent *, bool);
576 bool active (Editing::MouseMode mode) {
577 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
580 bool y_movement_matters () const {
585 double y_to_region (double) const;
586 ARDOUR::framecnt_t grid_frames (framepos_t) const;
588 MidiRegionView* _region_view;
589 ArdourCanvas::Rectangle* _drag_rect;
593 /** Drag to move MIDI patch changes */
594 class PatchChangeDrag : public Drag
597 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
599 void motion (GdkEvent *, bool);
600 void finished (GdkEvent *, bool);
603 bool y_movement_matters () const {
607 void setup_pointer_frame_offset ();
610 MidiRegionView* _region_view;
611 PatchChange* _patch_change;
612 double _cumulative_dx;
615 /** Container for details about audio regions being dragged along with video */
619 AVDraggingView (RegionView *);
621 RegionView* view; ///< the view
622 framepos_t initial_position; ///< initial position of the region
625 /** Drag of video offset */
626 class VideoTimeLineDrag : public Drag
629 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
631 void motion (GdkEvent *, bool);
632 void finished (GdkEvent *, bool);
633 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
635 bool y_movement_matters () const {
639 bool allow_vertical_autoscroll () const {
646 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
649 ARDOUR::frameoffset_t _startdrag_video_offset;
650 ARDOUR::frameoffset_t _max_backwards_drag;
654 /** Drag to trim region(s) */
655 class TrimDrag : public RegionDrag
664 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
666 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
667 void motion (GdkEvent *, bool);
668 void finished (GdkEvent *, bool);
671 bool y_movement_matters () const {
675 void setup_pointer_frame_offset ();
679 Operation _operation;
681 bool _preserve_fade_anchor;
682 bool _jump_position_when_done;
685 /** Meter marker drag */
686 class MeterMarkerDrag : public Drag
689 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
691 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
692 void motion (GdkEvent *, bool);
693 void finished (GdkEvent *, bool);
696 bool allow_vertical_autoscroll () const {
700 bool y_movement_matters () const {
704 void setup_pointer_frame_offset ();
707 MeterMarker* _marker;
708 ARDOUR::MeterSection* _real_section;
711 XMLNode* before_state;
714 /** Tempo marker drag */
715 class TempoMarkerDrag : public Drag
718 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
720 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
721 void motion (GdkEvent *, bool);
722 void finished (GdkEvent *, bool);
725 bool allow_vertical_autoscroll () const {
729 bool y_movement_matters () const {
733 void setup_pointer_frame_offset ();
736 TempoMarker* _marker;
737 ARDOUR::TempoSection* _real_section;
741 XMLNode* before_state;
744 /** BBT Ruler drag */
745 class BBTRulerDrag : public Drag
748 BBTRulerDrag (Editor *, ArdourCanvas::Item *);
750 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
751 void motion (GdkEvent *, bool);
752 void finished (GdkEvent *, bool);
755 bool allow_vertical_autoscroll () const {
759 bool y_movement_matters () const {
763 void setup_pointer_frame_offset ();
767 XMLNode* before_state;
770 /** Drag of the playhead cursor */
771 class CursorDrag : public Drag
774 CursorDrag (Editor *, EditorCursor&, bool);
776 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
777 void motion (GdkEvent *, bool);
778 void finished (GdkEvent *, bool);
781 bool allow_vertical_autoscroll () const {
785 bool y_movement_matters () const {
790 void fake_locate (framepos_t);
792 EditorCursor& _cursor;
793 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
794 double _grab_zoom; ///< editor frames per unit when our grab started
797 /** Region fade-in drag */
798 class FadeInDrag : public RegionDrag
801 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
803 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
804 void motion (GdkEvent *, bool);
805 void finished (GdkEvent *, bool);
808 bool y_movement_matters () const {
812 void setup_pointer_frame_offset ();
815 /** Region fade-out drag */
816 class FadeOutDrag : public RegionDrag
819 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
821 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
822 void motion (GdkEvent *, bool);
823 void finished (GdkEvent *, bool);
826 bool y_movement_matters () const {
830 void setup_pointer_frame_offset ();
834 class MarkerDrag : public Drag
837 MarkerDrag (Editor *, ArdourCanvas::Item *);
840 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
841 void motion (GdkEvent *, bool);
842 void finished (GdkEvent *, bool);
845 bool allow_vertical_autoscroll () const {
849 bool y_movement_matters () const {
853 void setup_pointer_frame_offset ();
856 void update_item (ARDOUR::Location *);
858 ArdourMarker* _marker; ///< marker being dragged
859 bool _selection_changed;
860 struct CopiedLocationMarkerInfo {
861 ARDOUR::Location* location;
862 std::vector<ArdourMarker*> markers;
864 CopiedLocationMarkerInfo (ARDOUR::Location* l, ArdourMarker* m);
867 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
868 CopiedLocationInfo _copied_locations;
869 ArdourCanvas::Points _points;
872 /** Control point drag */
873 class ControlPointDrag : public Drag
876 ControlPointDrag (Editor *, ArdourCanvas::Item *);
878 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
879 void motion (GdkEvent *, bool);
880 void finished (GdkEvent *, bool);
883 bool active (Editing::MouseMode m);
887 ControlPoint* _point;
888 double _fixed_grab_x;
889 double _fixed_grab_y;
890 double _cumulative_x_drag;
891 double _cumulative_y_drag;
893 uint32_t _final_index;
894 static double _zero_gain_fraction;
897 /** Gain or automation line drag */
898 class LineDrag : public Drag
901 LineDrag (Editor *e, ArdourCanvas::Item *i);
903 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
904 void motion (GdkEvent *, bool);
905 void finished (GdkEvent *, bool);
910 AutomationLine* _line;
911 double _fixed_grab_x;
912 double _fixed_grab_y;
913 double _cumulative_y_drag;
918 /** Transient feature line drags*/
919 class FeatureLineDrag : public Drag
922 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
924 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
925 void motion (GdkEvent *, bool);
926 void finished (GdkEvent *, bool);
931 ArdourCanvas::Line* _line;
932 AudioRegionView* _arv;
934 double _region_view_grab_x;
935 double _cumulative_x_drag;
941 /** Dragging of a rubberband rectangle for selecting things */
942 class RubberbandSelectDrag : public Drag
945 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
947 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
948 void motion (GdkEvent *, bool);
949 void finished (GdkEvent *, bool);
952 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
953 return std::make_pair (8, 1);
956 void do_select_things (GdkEvent *, bool);
958 /** Select some things within a rectangle.
959 * @param button_state The button state from the GdkEvent.
960 * @param x1 The left-hand side of the rectangle in session frames.
961 * @param x2 The right-hand side of the rectangle in session frames.
962 * @param y1 The top of the rectangle in trackview coordinates.
963 * @param y2 The bottom of the rectangle in trackview coordinates.
964 * @param drag_in_progress true if the drag is currently happening.
966 virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
968 virtual void deselect_things () = 0;
974 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
975 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
978 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
980 void select_things (int, framepos_t, framepos_t, double, double, bool);
981 void deselect_things ();
984 /** A RubberbandSelectDrag for selecting MIDI notes */
985 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
988 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
990 void select_things (int, framepos_t, framepos_t, double, double, bool);
991 void deselect_things ();
994 MidiRegionView* _region_view;
997 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
998 class MidiVerticalSelectDrag : public RubberbandSelectDrag
1001 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
1003 void select_things (int, framepos_t, framepos_t, double, double, bool);
1004 void deselect_things ();
1007 MidiRegionView* _region_view;
1010 /** Region drag in time-FX mode */
1011 class TimeFXDrag : public RegionDrag
1014 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
1016 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1017 void motion (GdkEvent *, bool);
1018 void finished (GdkEvent *, bool);
1019 void aborted (bool);
1022 /** Scrub drag in audition mode */
1023 class ScrubDrag : public Drag
1026 ScrubDrag (Editor *, ArdourCanvas::Item *);
1028 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1029 void motion (GdkEvent *, bool);
1030 void finished (GdkEvent *, bool);
1031 void aborted (bool);
1034 /** Drag in range select mode */
1035 class SelectionDrag : public Drag
1046 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
1048 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1049 void motion (GdkEvent *, bool);
1050 void finished (GdkEvent *, bool);
1051 void aborted (bool);
1053 void setup_pointer_frame_offset ();
1056 Operation _operation;
1058 std::list<TimeAxisView*> _added_time_axes;
1059 bool _time_selection_at_start;
1060 framepos_t start_at_start;
1061 framepos_t end_at_start;
1064 /** Range marker drag */
1065 class RangeMarkerBarDrag : public Drag
1071 CreateTransportMarker,
1075 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1076 ~RangeMarkerBarDrag ();
1078 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1079 void motion (GdkEvent *, bool);
1080 void finished (GdkEvent *, bool);
1081 void aborted (bool);
1083 bool allow_vertical_autoscroll () const {
1087 bool y_movement_matters () const {
1092 void update_item (ARDOUR::Location *);
1094 Operation _operation;
1095 ArdourCanvas::Rectangle* _drag_rect;
1099 /** Drag of rectangle to set zoom */
1100 class MouseZoomDrag : public Drag
1103 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1105 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1106 void motion (GdkEvent *, bool);
1107 void finished (GdkEvent *, bool);
1108 void aborted (bool);
1110 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1111 return std::make_pair (4, 4);
1118 /** Drag of a range of automation data (either on an automation track or region gain),
1119 * changing value but not position.
1121 class AutomationRangeDrag : public Drag
1124 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1125 AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &);
1127 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1128 void motion (GdkEvent *, bool);
1129 void finished (GdkEvent *, bool);
1130 void aborted (bool);
1132 bool x_movement_matters () const {
1137 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1138 double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
1139 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1141 std::list<ARDOUR::AudioRange> _ranges;
1143 /** A line that is part of the drag */
1145 boost::shared_ptr<AutomationLine> line; ///< the line
1146 std::list<ControlPoint*> points; ///< points to drag on the line
1147 std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
1148 XMLNode* state; ///< the XML state node before the drag
1149 double original_fraction; ///< initial y-fraction before the drag
1152 std::list<Line> _lines;
1154 bool _nothing_to_drag;
1158 /** Drag of one edge of an xfade
1160 class CrossfadeEdgeDrag : public Drag
1163 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1165 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1166 void motion (GdkEvent*, bool);
1167 void finished (GdkEvent*, bool);
1168 void aborted (bool);
1170 bool y_movement_matters () const {
1174 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1175 return std::make_pair (4, 4);
1179 AudioRegionView* arv;
1183 #endif /* __gtk2_ardour_editor_drag_h_ */