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
289 /** Container for details about a region being dragged */
293 DraggingView (RegionView *, RegionDrag *, TimeAxisView* original_tav);
295 RegionView* view; ///< the view
296 /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on,
297 * or -1 if it is not visible.
300 /** layer that this region is currently being displayed on. This is a double
301 rather than a layer_t as we use fractional layers during drags to allow the user
302 to indicate a new layer to put a region on.
305 double initial_y; ///< the initial y position of the view before any reparenting
306 framepos_t initial_position; ///< initial position of the region
307 framepos_t initial_end; ///< initial end position of the region
308 framepos_t anchored_fade_length; ///< fade_length when anchored during drag
309 boost::shared_ptr<ARDOUR::Playlist> initial_playlist;
310 TimeAxisView* initial_time_axis_view;
313 /** Abstract base class for drags that involve region(s) */
314 class RegionDrag : public Drag, public sigc::trackable
317 RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
318 virtual ~RegionDrag () {}
322 RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
323 std::list<DraggingView> _views; ///< information about all views that are being dragged
325 /** a list of the non-hidden TimeAxisViews sorted by editor order key */
326 std::vector<TimeAxisView*> _time_axis_views;
327 int find_time_axis_view (TimeAxisView *) const;
328 int apply_track_delta (const int start, const int delta, const int skip, const bool distance_only = false) const;
334 friend class DraggingView;
338 void region_going_away (RegionView *);
339 PBD::ScopedConnection death_connection;
343 /** Drags involving region motion from somewhere */
344 class RegionMotionDrag : public RegionDrag
348 RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
349 virtual ~RegionMotionDrag () {}
351 virtual void start_grab (GdkEvent *, Gdk::Cursor *);
352 virtual void motion (GdkEvent *, bool);
353 virtual void finished (GdkEvent *, bool);
354 virtual void aborted (bool);
356 /** @return true if the regions being `moved' came from somewhere on the canvas;
357 * false if they came from outside (e.g. from the region list).
359 virtual bool regions_came_from_canvas () const = 0;
363 double compute_x_delta (GdkEvent const *, ARDOUR::framepos_t *);
364 virtual bool y_movement_allowed (int, double, int skip_invisible = 0) const;
367 bool _ignore_video_lock;
368 ARDOUR::framepos_t _last_frame_position; ///< last position of the thing being dragged
369 double _total_x_delta;
370 int _last_pointer_time_axis_view;
371 double _last_pointer_layer;
379 /** Drags to move (or copy) regions that are already shown in the GUI to
380 * somewhere different.
382 class RegionMoveDrag : public RegionMotionDrag
385 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
386 virtual ~RegionMoveDrag () {}
388 void motion (GdkEvent *, bool);
389 void finished (GdkEvent *, bool);
392 bool regions_came_from_canvas () const {
396 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
397 return std::make_pair (4, 4);
400 void setup_pointer_frame_offset ();
403 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
404 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
407 void finished_no_copy (
410 ARDOUR::framecnt_t const,
411 int32_t const ev_state
417 ARDOUR::framecnt_t const,
418 int32_t const ev_state
421 RegionView* insert_region_into_playlist (
422 boost::shared_ptr<ARDOUR::Region>,
427 const int32_t sub_num
430 void remove_region_from_playlist (
431 boost::shared_ptr<ARDOUR::Region>,
432 boost::shared_ptr<ARDOUR::Playlist>,
433 PlaylistSet& modified_playlists
437 void collect_new_region_view (RegionView *);
438 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
441 RegionView* _new_region_view;
444 /** Drag to insert a region from somewhere */
445 class RegionInsertDrag : public RegionMotionDrag
448 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::framepos_t);
450 void finished (GdkEvent *, bool);
453 bool regions_came_from_canvas () const {
458 /** Region drag in splice mode */
459 class RegionSpliceDrag : public RegionMoveDrag
462 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
464 void motion (GdkEvent *, bool);
465 void finished (GdkEvent *, bool);
469 /** Region drag in ripple mode */
471 class RegionRippleDrag : public RegionMoveDrag
474 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
475 ~RegionRippleDrag () { delete exclude; }
477 void motion (GdkEvent *, bool);
478 void finished (GdkEvent *, bool);
481 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
484 TimeAxisView *prev_tav; // where regions were most recently dragged from
485 TimeAxisView *orig_tav; // where drag started
486 ARDOUR::framecnt_t prev_amount;
487 ARDOUR::framepos_t prev_position;
488 ARDOUR::framecnt_t selection_length;
489 bool allow_moves_across_tracks; // only if all selected regions are on one track
490 ARDOUR::RegionList *exclude;
491 void add_all_after_to_views (TimeAxisView *tav, ARDOUR::framepos_t where, const RegionSelection &exclude, bool drag_in_progress);
492 void remove_unselected_from_views (ARDOUR::framecnt_t amount, bool move_regions);
496 /** "Drag" to cut a region (action only on button release) */
497 class RegionCutDrag : public Drag
500 RegionCutDrag (Editor*, ArdourCanvas::Item*, framepos_t);
503 void motion (GdkEvent*, bool);
504 void finished (GdkEvent*, bool);
511 /** Drags to create regions */
512 class RegionCreateDrag : public Drag
515 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
517 void motion (GdkEvent *, bool);
518 void finished (GdkEvent *, bool);
522 MidiTimeAxisView* _view;
523 boost::shared_ptr<ARDOUR::Region> _region;
526 /** Drags to resize MIDI notes */
527 class NoteResizeDrag : public Drag
530 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
532 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
533 void motion (GdkEvent *, bool);
534 void finished (GdkEvent *, bool);
538 MidiRegionView* region;
545 /** Drags to move MIDI notes */
546 class NoteDrag : public Drag
549 NoteDrag (Editor*, ArdourCanvas::Item*);
551 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
552 void motion (GdkEvent *, bool);
553 void finished (GdkEvent *, bool);
558 ARDOUR::frameoffset_t total_dx (const guint) const;
559 int8_t total_dy () const;
561 MidiRegionView* _region;
563 double _cumulative_dx;
564 double _cumulative_dy;
569 class NoteCreateDrag : public Drag
572 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
575 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
576 void motion (GdkEvent *, bool);
577 void finished (GdkEvent *, bool);
580 bool active (Editing::MouseMode mode) {
581 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
584 bool y_movement_matters () const {
589 double y_to_region (double) const;
590 ARDOUR::framecnt_t grid_frames (framepos_t) const;
592 MidiRegionView* _region_view;
593 ArdourCanvas::Rectangle* _drag_rect;
597 /** Drag to move MIDI patch changes */
598 class PatchChangeDrag : public Drag
601 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
603 void motion (GdkEvent *, bool);
604 void finished (GdkEvent *, bool);
607 bool y_movement_matters () const {
611 void setup_pointer_frame_offset ();
614 MidiRegionView* _region_view;
615 PatchChange* _patch_change;
616 double _cumulative_dx;
619 /** Container for details about audio regions being dragged along with video */
623 AVDraggingView (RegionView *);
625 RegionView* view; ///< the view
626 framepos_t initial_position; ///< initial position of the region
629 /** Drag of video offset */
630 class VideoTimeLineDrag : public Drag
633 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
635 void motion (GdkEvent *, bool);
636 void finished (GdkEvent *, bool);
637 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
639 bool y_movement_matters () const {
643 bool allow_vertical_autoscroll () const {
650 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
653 ARDOUR::frameoffset_t _startdrag_video_offset;
654 ARDOUR::frameoffset_t _max_backwards_drag;
658 /** Drag to trim region(s) */
659 class TrimDrag : public RegionDrag
668 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
670 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
671 void motion (GdkEvent *, bool);
672 void finished (GdkEvent *, bool);
675 bool y_movement_matters () const {
679 void setup_pointer_frame_offset ();
683 Operation _operation;
685 bool _preserve_fade_anchor;
686 bool _jump_position_when_done;
689 /** Meter marker drag */
690 class MeterMarkerDrag : public Drag
693 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
695 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
696 void motion (GdkEvent *, bool);
697 void finished (GdkEvent *, bool);
700 bool allow_vertical_autoscroll () const {
704 bool y_movement_matters () const {
708 void setup_pointer_frame_offset ();
711 MeterMarker* _marker;
712 ARDOUR::MeterSection* _real_section;
715 Editing::SnapType _old_snap_type;
716 Editing::SnapMode _old_snap_mode;
717 XMLNode* before_state;
720 /** Tempo marker drag */
721 class TempoMarkerDrag : public Drag
724 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
726 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
727 void motion (GdkEvent *, bool);
728 void finished (GdkEvent *, bool);
731 bool allow_vertical_autoscroll () const {
735 bool y_movement_matters () const {
739 void setup_pointer_frame_offset ();
742 TempoMarker* _marker;
743 ARDOUR::TempoSection* _real_section;
747 XMLNode* before_state;
750 /** BBT Ruler drag */
751 class BBTRulerDrag : public Drag
754 BBTRulerDrag (Editor *, ArdourCanvas::Item *);
756 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
757 void motion (GdkEvent *, bool);
758 void finished (GdkEvent *, bool);
761 bool allow_vertical_autoscroll () const {
765 bool y_movement_matters () const {
769 void setup_pointer_frame_offset ();
773 ARDOUR::TempoSection* _tempo;
774 XMLNode* before_state;
777 /** Drag of the playhead cursor */
778 class CursorDrag : public Drag
781 CursorDrag (Editor *, EditorCursor&, bool);
783 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
784 void motion (GdkEvent *, bool);
785 void finished (GdkEvent *, bool);
788 bool allow_vertical_autoscroll () const {
792 bool y_movement_matters () const {
797 void fake_locate (framepos_t);
799 EditorCursor& _cursor;
800 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
801 double _grab_zoom; ///< editor frames per unit when our grab started
804 /** Region fade-in drag */
805 class FadeInDrag : public RegionDrag
808 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
810 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
811 void motion (GdkEvent *, bool);
812 void finished (GdkEvent *, bool);
815 bool y_movement_matters () const {
819 void setup_pointer_frame_offset ();
822 /** Region fade-out drag */
823 class FadeOutDrag : public RegionDrag
826 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
828 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
829 void motion (GdkEvent *, bool);
830 void finished (GdkEvent *, bool);
833 bool y_movement_matters () const {
837 void setup_pointer_frame_offset ();
841 class MarkerDrag : public Drag
844 MarkerDrag (Editor *, ArdourCanvas::Item *);
847 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
848 void motion (GdkEvent *, bool);
849 void finished (GdkEvent *, bool);
852 bool allow_vertical_autoscroll () const {
856 bool y_movement_matters () const {
860 void setup_pointer_frame_offset ();
863 void update_item (ARDOUR::Location *);
865 ArdourMarker* _marker; ///< marker being dragged
866 bool _selection_changed;
867 struct CopiedLocationMarkerInfo {
868 ARDOUR::Location* location;
869 std::vector<ArdourMarker*> markers;
871 CopiedLocationMarkerInfo (ARDOUR::Location* l, ArdourMarker* m);
874 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
875 CopiedLocationInfo _copied_locations;
876 ArdourCanvas::Points _points;
879 /** Control point drag */
880 class ControlPointDrag : public Drag
883 ControlPointDrag (Editor *, ArdourCanvas::Item *);
885 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
886 void motion (GdkEvent *, bool);
887 void finished (GdkEvent *, bool);
890 bool active (Editing::MouseMode m);
894 ControlPoint* _point;
895 double _fixed_grab_x;
896 double _fixed_grab_y;
897 double _cumulative_x_drag;
898 double _cumulative_y_drag;
900 uint32_t _final_index;
901 static double _zero_gain_fraction;
904 /** Gain or automation line drag */
905 class LineDrag : public Drag
908 LineDrag (Editor *e, ArdourCanvas::Item *i);
910 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
911 void motion (GdkEvent *, bool);
912 void finished (GdkEvent *, bool);
917 AutomationLine* _line;
918 double _fixed_grab_x;
919 double _fixed_grab_y;
920 double _cumulative_y_drag;
925 /** Transient feature line drags*/
926 class FeatureLineDrag : public Drag
929 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
931 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
932 void motion (GdkEvent *, bool);
933 void finished (GdkEvent *, bool);
938 ArdourCanvas::Line* _line;
939 AudioRegionView* _arv;
941 double _region_view_grab_x;
942 double _cumulative_x_drag;
948 /** Dragging of a rubberband rectangle for selecting things */
949 class RubberbandSelectDrag : public Drag
952 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
954 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
955 void motion (GdkEvent *, bool);
956 void finished (GdkEvent *, bool);
959 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
960 return std::make_pair (8, 1);
963 void do_select_things (GdkEvent *, bool);
965 /** Select some things within a rectangle.
966 * @param button_state The button state from the GdkEvent.
967 * @param x1 The left-hand side of the rectangle in session frames.
968 * @param x2 The right-hand side of the rectangle in session frames.
969 * @param y1 The top of the rectangle in trackview coordinates.
970 * @param y2 The bottom of the rectangle in trackview coordinates.
971 * @param drag_in_progress true if the drag is currently happening.
973 virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
975 virtual void deselect_things () = 0;
981 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
982 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
985 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
987 void select_things (int, framepos_t, framepos_t, double, double, bool);
988 void deselect_things ();
991 /** A RubberbandSelectDrag for selecting MIDI notes */
992 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
995 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
997 void select_things (int, framepos_t, framepos_t, double, double, bool);
998 void deselect_things ();
1001 MidiRegionView* _region_view;
1004 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
1005 class MidiVerticalSelectDrag : public RubberbandSelectDrag
1008 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
1010 void select_things (int, framepos_t, framepos_t, double, double, bool);
1011 void deselect_things ();
1014 MidiRegionView* _region_view;
1017 /** Region drag in time-FX mode */
1018 class TimeFXDrag : public RegionDrag
1021 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
1023 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1024 void motion (GdkEvent *, bool);
1025 void finished (GdkEvent *, bool);
1026 void aborted (bool);
1029 /** Scrub drag in audition mode */
1030 class ScrubDrag : public Drag
1033 ScrubDrag (Editor *, ArdourCanvas::Item *);
1035 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1036 void motion (GdkEvent *, bool);
1037 void finished (GdkEvent *, bool);
1038 void aborted (bool);
1041 /** Drag in range select mode */
1042 class SelectionDrag : public Drag
1053 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
1055 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1056 void motion (GdkEvent *, bool);
1057 void finished (GdkEvent *, bool);
1058 void aborted (bool);
1060 void setup_pointer_frame_offset ();
1063 Operation _operation;
1065 std::list<TimeAxisView*> _added_time_axes;
1066 bool _time_selection_at_start;
1067 framepos_t start_at_start;
1068 framepos_t end_at_start;
1071 /** Range marker drag */
1072 class RangeMarkerBarDrag : public Drag
1078 CreateTransportMarker,
1082 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1083 ~RangeMarkerBarDrag ();
1085 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1086 void motion (GdkEvent *, bool);
1087 void finished (GdkEvent *, bool);
1088 void aborted (bool);
1090 bool allow_vertical_autoscroll () const {
1094 bool y_movement_matters () const {
1099 void update_item (ARDOUR::Location *);
1101 Operation _operation;
1102 ArdourCanvas::Rectangle* _drag_rect;
1106 /** Drag of rectangle to set zoom */
1107 class MouseZoomDrag : public Drag
1110 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1112 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1113 void motion (GdkEvent *, bool);
1114 void finished (GdkEvent *, bool);
1115 void aborted (bool);
1117 std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1118 return std::make_pair (4, 4);
1125 /** Drag of a range of automation data (either on an automation track or region gain),
1126 * changing value but not position.
1128 class AutomationRangeDrag : public Drag
1131 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1132 AutomationRangeDrag (Editor *, RegionView *, std::list<ARDOUR::AudioRange> const &);
1134 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1135 void motion (GdkEvent *, bool);
1136 void finished (GdkEvent *, bool);
1137 void aborted (bool);
1139 bool x_movement_matters () const {
1144 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1145 double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
1146 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1148 std::list<ARDOUR::AudioRange> _ranges;
1150 /** A line that is part of the drag */
1152 boost::shared_ptr<AutomationLine> line; ///< the line
1153 std::list<ControlPoint*> points; ///< points to drag on the line
1154 std::pair<ARDOUR::framepos_t, ARDOUR::framepos_t> range; ///< the range of all points on the line, in session frames
1155 XMLNode* state; ///< the XML state node before the drag
1156 double original_fraction; ///< initial y-fraction before the drag
1159 std::list<Line> _lines;
1161 bool _nothing_to_drag;
1165 /** Drag of one edge of an xfade
1167 class CrossfadeEdgeDrag : public Drag
1170 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1172 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1173 void motion (GdkEvent*, bool);
1174 void finished (GdkEvent*, bool);
1175 void aborted (bool);
1177 bool y_movement_matters () const {
1181 virtual std::pair<ARDOUR::framecnt_t, int> move_threshold () const {
1182 return std::make_pair (4, 4);
1186 AudioRegionView* arv;
1190 #endif /* __gtk2_ardour_editor_drag_h_ */