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;
335 friend class DraggingView;
339 void region_going_away (RegionView *);
340 PBD::ScopedConnection death_connection;
344 /** Drags involving region motion from somewhere */
345 class RegionMotionDrag : public RegionDrag
349 RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
350 virtual ~RegionMotionDrag () {}
352 virtual void start_grab (GdkEvent *, Gdk::Cursor *);
353 virtual void motion (GdkEvent *, bool);
354 virtual void finished (GdkEvent *, bool);
355 virtual void aborted (bool);
357 /** @return true if the regions being `moved' came from somewhere on the canvas;
358 * false if they came from outside (e.g. from the region list).
360 virtual bool regions_came_from_canvas () const = 0;
364 double compute_x_delta (GdkEvent const *, ARDOUR::framepos_t *);
365 virtual bool y_movement_allowed (int, double, int skip_invisible = 0) const;
368 bool _ignore_video_lock;
369 ARDOUR::framepos_t _last_frame_position; ///< last position of the thing being dragged
370 double _total_x_delta;
371 int _last_pointer_time_axis_view;
372 double _last_pointer_layer;
380 /** Drags to move (or copy) regions that are already shown in the GUI to
381 * somewhere different.
383 class RegionMoveDrag : public RegionMotionDrag
386 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
387 virtual ~RegionMoveDrag () {}
389 void motion (GdkEvent *, bool);
390 void finished (GdkEvent *, bool);
393 bool regions_came_from_canvas () const {
397 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
398 return std::make_pair (4, 4);
401 void setup_pointer_frame_offset ();
404 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
405 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
408 void finished_no_copy (
411 ARDOUR::framecnt_t const,
412 int32_t const ev_state
418 ARDOUR::framecnt_t const,
419 int32_t const ev_state
422 RegionView* insert_region_into_playlist (
423 boost::shared_ptr<ARDOUR::Region>,
428 const int32_t sub_num
431 void remove_region_from_playlist (
432 boost::shared_ptr<ARDOUR::Region>,
433 boost::shared_ptr<ARDOUR::Playlist>,
434 PlaylistSet& modified_playlists
438 void collect_new_region_view (RegionView *);
439 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
442 RegionView* _new_region_view;
445 /** Drag to insert a region from somewhere */
446 class RegionInsertDrag : public RegionMotionDrag
449 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
451 void finished (GdkEvent *, bool);
454 bool regions_came_from_canvas () const {
459 /** Region drag in splice mode */
460 class RegionSpliceDrag : public RegionMoveDrag
463 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
465 void motion (GdkEvent *, bool);
466 void finished (GdkEvent *, bool);
470 /** Region drag in ripple mode */
472 class RegionRippleDrag : public RegionMoveDrag
475 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
476 ~RegionRippleDrag () { delete exclude; }
478 void motion (GdkEvent *, bool);
479 void finished (GdkEvent *, bool);
482 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
485 TimeAxisView *prev_tav; // where regions were most recently dragged from
486 TimeAxisView *orig_tav; // where drag started
487 ARDOUR::framecnt_t prev_amount;
488 ARDOUR::framepos_t prev_position;
489 ARDOUR::framecnt_t selection_length;
490 bool allow_moves_across_tracks; // only if all selected regions are on one track
491 ARDOUR::RegionList *exclude;
492 void add_all_after_to_views (TimeAxisView *tav, ARDOUR::framepos_t where, const RegionSelection &exclude, bool drag_in_progress);
493 void remove_unselected_from_views (ARDOUR::framecnt_t amount, bool move_regions);
497 /** "Drag" to cut a region (action only on button release) */
498 class RegionCutDrag : public Drag
501 RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
504 void motion (GdkEvent*, bool);
505 void finished (GdkEvent*, bool);
512 /** Drags to create regions */
513 class RegionCreateDrag : public Drag
516 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
518 void motion (GdkEvent *, bool);
519 void finished (GdkEvent *, bool);
523 MidiTimeAxisView* _view;
524 boost::shared_ptr<ARDOUR::Region> _region;
527 /** Drags to resize MIDI notes */
528 class NoteResizeDrag : public Drag
531 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
533 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
534 void motion (GdkEvent *, bool);
535 void finished (GdkEvent *, bool);
539 MidiRegionView* region;
546 /** Drags to move MIDI notes */
547 class NoteDrag : public Drag
550 NoteDrag (Editor*, ArdourCanvas::Item*);
552 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
553 void motion (GdkEvent *, bool);
554 void finished (GdkEvent *, bool);
559 ARDOUR::frameoffset_t total_dx (const guint) const;
560 int8_t total_dy () const;
562 MidiRegionView* _region;
564 double _cumulative_dx;
565 double _cumulative_dy;
570 class NoteCreateDrag : public Drag
573 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
576 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
577 void motion (GdkEvent *, bool);
578 void finished (GdkEvent *, bool);
581 bool active (Editing::MouseMode mode) {
582 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
585 bool y_movement_matters () const {
590 double y_to_region (double) const;
591 ARDOUR::framecnt_t grid_frames (framepos_t) const;
593 MidiRegionView* _region_view;
594 ArdourCanvas::Rectangle* _drag_rect;
598 /** Drag to move MIDI patch changes */
599 class PatchChangeDrag : public Drag
602 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
604 void motion (GdkEvent *, bool);
605 void finished (GdkEvent *, bool);
608 bool y_movement_matters () const {
612 void setup_pointer_frame_offset ();
615 MidiRegionView* _region_view;
616 PatchChange* _patch_change;
617 double _cumulative_dx;
620 /** Container for details about audio regions being dragged along with video */
624 AVDraggingView (RegionView *);
626 RegionView* view; ///< the view
627 framepos_t initial_position; ///< initial position of the region
630 /** Drag of video offset */
631 class VideoTimeLineDrag : public Drag
634 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
636 void motion (GdkEvent *, bool);
637 void finished (GdkEvent *, bool);
638 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
640 bool y_movement_matters () const {
644 bool allow_vertical_autoscroll () const {
651 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
654 ARDOUR::frameoffset_t _startdrag_video_offset;
655 ARDOUR::frameoffset_t _max_backwards_drag;
659 /** Drag to trim region(s) */
660 class TrimDrag : public RegionDrag
669 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
671 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
672 void motion (GdkEvent *, bool);
673 void finished (GdkEvent *, bool);
676 bool y_movement_matters () const {
680 void setup_pointer_frame_offset ();
684 Operation _operation;
686 bool _preserve_fade_anchor;
687 bool _jump_position_when_done;
690 /** Meter marker drag */
691 class MeterMarkerDrag : public Drag
694 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
696 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
697 void motion (GdkEvent *, bool);
698 void finished (GdkEvent *, bool);
701 bool allow_vertical_autoscroll () const {
705 bool y_movement_matters () const {
709 void setup_pointer_frame_offset ();
712 MeterMarker* _marker;
713 ARDOUR::MeterSection* _real_section;
716 Editing::SnapType _old_snap_type;
717 Editing::SnapMode _old_snap_mode;
718 XMLNode* before_state;
721 /** Tempo marker drag */
722 class TempoMarkerDrag : public Drag
725 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
727 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
728 void motion (GdkEvent *, bool);
729 void finished (GdkEvent *, bool);
732 bool allow_vertical_autoscroll () const {
736 bool y_movement_matters () const {
740 void setup_pointer_frame_offset ();
743 TempoMarker* _marker;
744 ARDOUR::TempoSection* _real_section;
748 XMLNode* before_state;
751 /** BBT Ruler drag */
752 class BBTRulerDrag : public Drag
755 BBTRulerDrag (Editor *, ArdourCanvas::Item *);
757 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
758 void motion (GdkEvent *, bool);
759 void finished (GdkEvent *, bool);
762 bool allow_vertical_autoscroll () const {
766 bool y_movement_matters () const {
770 void setup_pointer_frame_offset ();
774 ARDOUR::TempoSection* _tempo;
775 XMLNode* before_state;
778 /** Drag of the playhead cursor */
779 class CursorDrag : public Drag
782 CursorDrag (Editor *, EditorCursor&, bool);
784 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
785 void motion (GdkEvent *, bool);
786 void finished (GdkEvent *, bool);
789 bool allow_vertical_autoscroll () const {
793 bool y_movement_matters () const {
798 void fake_locate (framepos_t);
800 EditorCursor& _cursor;
801 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
802 double _grab_zoom; ///< editor frames per unit when our grab started
805 /** Region fade-in drag */
806 class FadeInDrag : public RegionDrag
809 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
811 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
812 void motion (GdkEvent *, bool);
813 void finished (GdkEvent *, bool);
816 bool y_movement_matters () const {
820 void setup_pointer_frame_offset ();
823 /** Region fade-out drag */
824 class FadeOutDrag : public RegionDrag
827 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
829 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
830 void motion (GdkEvent *, bool);
831 void finished (GdkEvent *, bool);
834 bool y_movement_matters () const {
838 void setup_pointer_frame_offset ();
842 class MarkerDrag : public Drag
845 MarkerDrag (Editor *, ArdourCanvas::Item *);
848 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
849 void motion (GdkEvent *, bool);
850 void finished (GdkEvent *, bool);
853 bool allow_vertical_autoscroll () const {
857 bool y_movement_matters () const {
861 void setup_pointer_frame_offset ();
864 void update_item (ARDOUR::Location *);
866 ArdourMarker* _marker; ///< marker being dragged
867 bool _selection_changed;
868 struct CopiedLocationMarkerInfo {
869 ARDOUR::Location* location;
870 std::vector<ArdourMarker*> markers;
872 CopiedLocationMarkerInfo (ARDOUR::Location* l, ArdourMarker* m);
875 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
876 CopiedLocationInfo _copied_locations;
877 ArdourCanvas::Points _points;
880 /** Control point drag */
881 class ControlPointDrag : public Drag
884 ControlPointDrag (Editor *, ArdourCanvas::Item *);
886 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
887 void motion (GdkEvent *, bool);
888 void finished (GdkEvent *, bool);
891 bool active (Editing::MouseMode m);
895 ControlPoint* _point;
896 double _fixed_grab_x;
897 double _fixed_grab_y;
898 double _cumulative_x_drag;
899 double _cumulative_y_drag;
901 uint32_t _final_index;
902 static double _zero_gain_fraction;
905 /** Gain or automation line drag */
906 class LineDrag : public Drag
909 LineDrag (Editor *e, ArdourCanvas::Item *i);
911 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
912 void motion (GdkEvent *, bool);
913 void finished (GdkEvent *, bool);
918 AutomationLine* _line;
919 double _fixed_grab_x;
920 double _fixed_grab_y;
921 double _cumulative_y_drag;
926 /** Transient feature line drags*/
927 class FeatureLineDrag : public Drag
930 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
932 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
933 void motion (GdkEvent *, bool);
934 void finished (GdkEvent *, bool);
939 ArdourCanvas::Line* _line;
940 AudioRegionView* _arv;
942 double _region_view_grab_x;
943 double _cumulative_x_drag;
949 /** Dragging of a rubberband rectangle for selecting things */
950 class RubberbandSelectDrag : public Drag
953 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
955 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
956 void motion (GdkEvent *, bool);
957 void finished (GdkEvent *, bool);
960 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
961 return std::make_pair (8, 1);
964 void do_select_things (GdkEvent *, bool);
966 /** Select some things within a rectangle.
967 * @param button_state The button state from the GdkEvent.
968 * @param x1 The left-hand side of the rectangle in session frames.
969 * @param x2 The right-hand side of the rectangle in session frames.
970 * @param y1 The top of the rectangle in trackview coordinates.
971 * @param y2 The bottom of the rectangle in trackview coordinates.
972 * @param drag_in_progress true if the drag is currently happening.
974 virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
976 virtual void deselect_things () = 0;
982 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
983 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
986 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
988 void select_things (int, framepos_t, framepos_t, double, double, bool);
989 void deselect_things ();
992 /** A RubberbandSelectDrag for selecting MIDI notes */
993 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
996 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
998 void select_things (int, framepos_t, framepos_t, double, double, bool);
999 void deselect_things ();
1002 MidiRegionView* _region_view;
1005 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
1006 class MidiVerticalSelectDrag : public RubberbandSelectDrag
1009 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
1011 void select_things (int, framepos_t, framepos_t, double, double, bool);
1012 void deselect_things ();
1015 MidiRegionView* _region_view;
1018 /** Region drag in time-FX mode */
1019 class TimeFXDrag : public RegionDrag
1022 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
1024 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1025 void motion (GdkEvent *, bool);
1026 void finished (GdkEvent *, bool);
1027 void aborted (bool);
1030 /** Scrub drag in audition mode */
1031 class ScrubDrag : public Drag
1034 ScrubDrag (Editor *, ArdourCanvas::Item *);
1036 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1037 void motion (GdkEvent *, bool);
1038 void finished (GdkEvent *, bool);
1039 void aborted (bool);
1042 /** Drag in range select mode */
1043 class SelectionDrag : public Drag
1054 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
1056 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1057 void motion (GdkEvent *, bool);
1058 void finished (GdkEvent *, bool);
1059 void aborted (bool);
1061 void setup_pointer_frame_offset ();
1064 Operation _operation;
1066 std::list<TimeAxisView*> _added_time_axes;
1067 bool _time_selection_at_start;
1068 framepos_t start_at_start;
1069 framepos_t end_at_start;
1072 /** Range marker drag */
1073 class RangeMarkerBarDrag : public Drag
1079 CreateTransportMarker,
1083 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1084 ~RangeMarkerBarDrag ();
1086 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1087 void motion (GdkEvent *, bool);
1088 void finished (GdkEvent *, bool);
1089 void aborted (bool);
1091 bool allow_vertical_autoscroll () const {
1095 bool y_movement_matters () const {
1100 void update_item (ARDOUR::Location *);
1102 Operation _operation;
1103 ArdourCanvas::Rectangle* _drag_rect;
1107 /** Drag of rectangle to set zoom */
1108 class MouseZoomDrag : public Drag
1111 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1113 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1114 void motion (GdkEvent *, bool);
1115 void finished (GdkEvent *, bool);
1116 void aborted (bool);
1118 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1119 return std::make_pair (4, 4);
1126 /** Drag of a range of automation data (either on an automation track or region gain),
1127 * changing value but not position.
1129 class AutomationRangeDrag : public Drag
1132 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1133 AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &);
1135 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1136 void motion (GdkEvent *, bool);
1137 void finished (GdkEvent *, bool);
1138 void aborted (bool);
1140 bool x_movement_matters () const {
1145 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1146 double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
1147 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1149 std::list<ARDOUR::AudioRange> _ranges;
1151 /** A line that is part of the drag */
1153 boost::shared_ptr<AutomationLine> line; ///< the line
1154 std::list<ControlPoint*> points; ///< points to drag on the line
1155 std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
1156 XMLNode* state; ///< the XML state node before the drag
1157 double original_fraction; ///< initial y-fraction before the drag
1160 std::list<Line> _lines;
1162 bool _nothing_to_drag;
1166 /** Drag of one edge of an xfade
1168 class CrossfadeEdgeDrag : public Drag
1171 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1173 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1174 void motion (GdkEvent*, bool);
1175 void finished (GdkEvent*, bool);
1176 void aborted (bool);
1178 bool y_movement_matters () const {
1182 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1183 return std::make_pair (4, 4);
1187 AudioRegionView* arv;
1191 #endif /* __gtk2_ardour_editor_drag_h_ */