2 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2009-2015 David Robillard <d@drobilla.net>
4 * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com>
6 * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
7 * Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.com>
8 * Copyright (C) 2015-2018 Ben Loftis <ben@harrisonconsoles.com>
9 * Copyright (C) 2016 Tim Mayberry <mojofunk@gmail.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #ifndef __gtk2_ardour_editor_drag_h_
27 #define __gtk2_ardour_editor_drag_h_
34 #include "ardour/tempo.h"
35 #include "ardour/types.h"
37 #include "canvas/types.h"
39 #include "cursor_context.h"
40 #include "editor_items.h"
41 #include "mouse_cursors.h"
43 #include "track_selection.h"
50 namespace ArdourCanvas {
57 class StatefulDiffCommand;
64 class MidiTimeAxisView;
69 class RouteTimeAxisView;
70 class RegionSelection;
76 class AudioRegionView;
78 class AutomationTimeAxisView;
80 /** Class to manage current drags */
85 DragManager (Editor* e);
88 bool motion_handler (GdkEvent *, bool);
92 void set (Drag *, GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
93 void start_grab (GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
94 bool end_grab (GdkEvent *);
95 bool have_item (ArdourCanvas::Item *) const;
97 void mark_double_click ();
99 /** @return true if an end drag or abort is in progress */
100 bool ending () const {
104 bool active () const {
105 return !_drags.empty ();
108 /** @return current pointer x position in canvas coordinates */
109 double current_pointer_x () const {
110 return _current_pointer_x;
113 /** @return current pointer y position in canvas coordinates */
114 double current_pointer_y () const {
115 return _current_pointer_y;
118 /** @return current pointer sample */
119 ARDOUR::samplepos_t current_pointer_sample () const {
120 return _current_pointer_sample;
123 /** return drag-motion displays video-frame of drag-location */
124 bool preview_video () const;
128 std::list<Drag*> _drags;
129 bool _ending; ///< true if end_grab or abort is in progress, otherwise false
130 double _current_pointer_x; ///< canvas-coordinate space x of the current pointer
131 double _current_pointer_y; ///< canvas-coordinate space y of the current pointer
132 ARDOUR::samplepos_t _current_pointer_sample; ///< sample that the pointer is now at
133 bool _old_follow_playhead; ///< state of Editor::follow_playhead() before the drags started
136 /** Abstract base class for dragging of things within the editor */
140 Drag (Editor *, ArdourCanvas::Item *, bool trackview_only = true);
143 void set_manager (DragManager* m) {
147 /** @return the canvas item being dragged */
148 ArdourCanvas::Item* item () const {
152 void swap_grab (ArdourCanvas::Item *, Gdk::Cursor *, uint32_t);
153 bool motion_handler (GdkEvent*, bool);
156 ARDOUR::MusicSample adjusted_sample (ARDOUR::samplepos_t, GdkEvent const *, bool snap = true) const;
157 ARDOUR::samplepos_t adjusted_current_sample (GdkEvent const *, bool snap = true) const;
159 bool was_double_click() const { return _was_double_click; }
160 void set_double_click (bool yn) { _was_double_click = yn; }
162 /** Called to start a grab of an item.
163 * @param e Event that caused the grab to start.
164 * @param c Cursor to use, or 0.
166 virtual void start_grab (GdkEvent* e, Gdk::Cursor* c = 0);
168 virtual bool end_grab (GdkEvent *);
170 /** Called when a drag motion has occurred.
171 * @param e Event describing the motion.
172 * @param f true if this is the first movement, otherwise false.
174 virtual void motion (GdkEvent* e, bool f) = 0;
176 /** Called when a drag has finished.
177 * @param e Event describing the finish.
178 * @param m true if some movement occurred, otherwise false.
180 virtual void finished (GdkEvent* e, bool m) = 0;
182 /** Called to abort a drag and return things to how
183 * they were before it started.
184 * @param m true if some movement occurred, otherwise false.
186 virtual void aborted (bool m) = 0;
188 /** @param m Mouse mode.
189 * @return true if this drag should happen in this mouse mode.
191 virtual bool active (Editing::MouseMode m) {
195 bool preview_video () const {
196 return _preview_video;
199 /** @return minimum number of samples (in x) and pixels (in y) that should be considered a movement */
200 virtual std::pair<ARDOUR::samplecnt_t, int> move_threshold () const {
201 return std::make_pair (1, 1);
204 virtual bool allow_vertical_autoscroll () const {
208 /** @return true if x movement matters to this drag */
209 virtual bool x_movement_matters () const {
213 /** @return true if y movement matters to this drag */
214 virtual bool y_movement_matters () const {
218 bool initially_vertical() const {
219 return _initially_vertical;
222 /** Set up the _pointer_sample_offset */
223 virtual void setup_pointer_sample_offset () {
224 _pointer_sample_offset = 0;
227 /** Set up the _video_sample_offset - relative to _current_pointer_sample */
228 virtual void setup_video_sample_offset () {
229 _video_sample_offset = 0;
230 _preview_video = false;
235 double grab_x () const {
239 double grab_y () const {
243 ARDOUR::samplepos_t raw_grab_sample () const {
244 return _raw_grab_sample;
247 ARDOUR::samplepos_t grab_sample () const {
251 double last_pointer_x () const {
252 return _last_pointer_x;
255 double last_pointer_y () const {
256 return _last_pointer_y;
259 ARDOUR::samplepos_t last_pointer_sample () const {
260 return _last_pointer_sample;
263 ARDOUR::sampleoffset_t snap_delta (guint const) const;
264 double snap_delta_music (guint const) const;
266 double current_pointer_x () const;
267 double current_pointer_y () const;
269 /* sets snap delta from unsnapped pos */
270 void setup_snap_delta (ARDOUR::MusicSample pos);
272 boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*, bool commit);
274 void show_verbose_cursor_time (samplepos_t);
275 void show_verbose_cursor_duration (samplepos_t, samplepos_t, double xoffset = 0);
276 void show_verbose_cursor_text (std::string const &);
277 void show_view_preview (samplepos_t);
279 Editor* _editor; ///< our editor
281 ArdourCanvas::Item* _item; ///< our item
282 /** Offset from the mouse's position for the drag to the start of the thing that is being dragged */
283 ARDOUR::samplecnt_t _pointer_sample_offset;
284 ARDOUR::samplecnt_t _video_sample_offset;
286 bool _x_constrained; ///< true if x motion is constrained, otherwise false
287 bool _y_constrained; ///< true if y motion is constrained, otherwise false
288 bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
291 bool _trackview_only; ///< true if pointer y value should always be relative to the top of the trackview group
292 bool _move_threshold_passed; ///< true if the move threshold has been passed, otherwise false
293 bool _starting_point_passed; ///< true if we called move () with first_move flag, otherwise false
294 bool _initially_vertical; ///< true if after move threshold is passed we appear to be moving vertically; undefined before that
295 bool _was_double_click; ///< true if drag initiated by a double click event
296 double _grab_x; ///< trackview x of the grab start position
297 double _grab_y; ///< y of the grab start position, possibly adjusted if _trackview_only is true
298 double _last_pointer_x; ///< trackview x of the pointer last time a motion occurred
299 double _last_pointer_y; ///< trackview y of the pointer last time a motion occurred
300 ARDOUR::samplepos_t _raw_grab_sample; ///< unsnapped sample that the mouse was at when start_grab was called, or 0
301 ARDOUR::samplepos_t _grab_sample; ///< adjusted_sample that the mouse was at when start_grab was called, or 0
302 ARDOUR::samplepos_t _last_pointer_sample; ///< adjusted_sample the last time a motion occurred
304 /* difference between some key position's snapped and unsnapped
305 * samplepos. used for relative snap.
307 samplepos_t _snap_delta;
308 double _snap_delta_music;
309 CursorContext::Handle _cursor_ctx; ///< cursor change context
310 bool _constraint_pressed; ///< if the keyboard indicated constraint modifier was pressed on start_grab()
315 /** Container for details about a region being dragged */
319 DraggingView (RegionView *, RegionDrag *, TimeAxisView* original_tav);
321 RegionView* view; ///< the view
322 /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on,
323 * or -1 if it is not visible.
326 /** layer that this region is currently being displayed on. This is a double
327 rather than a layer_t as we use fractional layers during drags to allow the user
328 to indicate a new layer to put a region on.
331 double initial_y; ///< the initial y position of the view before any reparenting
332 samplepos_t initial_position; ///< initial position of the region
333 samplepos_t initial_end; ///< initial end position of the region
334 samplepos_t anchored_fade_length; ///< fade_length when anchored during drag
335 boost::shared_ptr<ARDOUR::Playlist> initial_playlist;
336 TimeAxisView* initial_time_axis_view;
339 /** Abstract base class for drags that involve region(s) */
340 class RegionDrag : public Drag, public sigc::trackable
343 RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
344 virtual ~RegionDrag () {}
348 RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
349 std::list<DraggingView> _views; ///< information about all views that are being dragged
351 /** a list of the non-hidden TimeAxisViews sorted by editor order key */
352 std::vector<TimeAxisView*> _time_axis_views;
353 int find_time_axis_view (TimeAxisView *) const;
354 int apply_track_delta (const int start, const int delta, const int skip, const bool distance_only = false) const;
360 void setup_video_sample_offset ();
362 friend class DraggingView;
366 void region_going_away (RegionView *);
367 PBD::ScopedConnection death_connection;
371 /** Drags involving region motion from somewhere */
372 class RegionMotionDrag : public RegionDrag
376 RegionMotionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool);
377 virtual ~RegionMotionDrag () {}
379 virtual void start_grab (GdkEvent *, Gdk::Cursor *);
380 virtual void motion (GdkEvent *, bool);
381 virtual void finished (GdkEvent *, bool);
382 virtual void aborted (bool);
384 /** @return true if the regions being `moved' came from somewhere on the canvas;
385 * false if they came from outside (e.g. from the region list).
387 virtual bool regions_came_from_canvas () const = 0;
391 double compute_x_delta (GdkEvent const *, ARDOUR::MusicSample *);
392 virtual bool y_movement_allowed (int, double, int skip_invisible = 0) const;
395 bool _ignore_video_lock;
396 ARDOUR::MusicSample _last_position; ///< last position of the thing being dragged
397 double _total_x_delta;
398 int _last_pointer_time_axis_view;
399 double _last_pointer_layer;
407 /** Drags to move (or copy) regions that are already shown in the GUI to
408 * somewhere different.
410 class RegionMoveDrag : public RegionMotionDrag
413 RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
414 virtual ~RegionMoveDrag () {}
416 void motion (GdkEvent *, bool);
417 void finished (GdkEvent *, bool);
420 bool regions_came_from_canvas () const {
424 std::pair<ARDOUR::samplecnt_t, int> move_threshold () const {
425 return std::make_pair (4, 4);
428 void setup_pointer_sample_offset ();
431 typedef std::set<boost::shared_ptr<ARDOUR::Playlist> > PlaylistSet;
432 void add_stateful_diff_commands_for_playlists (PlaylistSet const &);
435 void finished_no_copy (
439 int32_t const ev_state
446 int32_t const ev_state
449 RegionView* insert_region_into_playlist (
450 boost::shared_ptr<ARDOUR::Region>,
456 bool for_music = false
459 void remove_region_from_playlist (
460 boost::shared_ptr<ARDOUR::Region>,
461 boost::shared_ptr<ARDOUR::Playlist>,
462 PlaylistSet& modified_playlists
466 void collect_new_region_view (RegionView *);
467 RouteTimeAxisView* create_destination_time_axis (boost::shared_ptr<ARDOUR::Region>, TimeAxisView* original);
470 RegionView* _new_region_view;
473 /** Drag to insert a region from somewhere */
474 class RegionInsertDrag : public RegionMotionDrag
477 RegionInsertDrag (Editor *, boost::shared_ptr<ARDOUR::Region>, RouteTimeAxisView*, ARDOUR::samplepos_t);
479 void finished (GdkEvent *, bool);
482 bool regions_came_from_canvas () const {
487 /** Region drag in splice mode */
488 class RegionSpliceDrag : public RegionMoveDrag
491 RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
493 void motion (GdkEvent *, bool);
494 void finished (GdkEvent *, bool);
498 /** Region drag in ripple mode */
500 class RegionRippleDrag : public RegionMoveDrag
503 RegionRippleDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
504 ~RegionRippleDrag () { delete exclude; }
506 void motion (GdkEvent *, bool);
507 void finished (GdkEvent *, bool);
510 bool y_movement_allowed (int delta_track, double delta_layer, int skip_invisible = 0) const;
513 TimeAxisView *prev_tav; // where regions were most recently dragged from
514 TimeAxisView *orig_tav; // where drag started
515 ARDOUR::samplecnt_t prev_amount;
516 ARDOUR::samplepos_t prev_position;
517 ARDOUR::samplecnt_t selection_length;
518 bool allow_moves_across_tracks; // only if all selected regions are on one track
519 ARDOUR::RegionList *exclude;
520 void add_all_after_to_views (TimeAxisView *tav, ARDOUR::samplepos_t where, const RegionSelection &exclude, bool drag_in_progress);
521 void remove_unselected_from_views (ARDOUR::samplecnt_t amount, bool move_regions);
525 /** "Drag" to cut a region (action only on button release) */
526 class RegionCutDrag : public Drag
529 RegionCutDrag (Editor*, ArdourCanvas::Item*, samplepos_t);
532 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
533 void motion (GdkEvent*, bool);
534 void finished (GdkEvent*, bool);
540 /** Drags to create regions */
541 class RegionCreateDrag : public Drag
544 RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
546 void motion (GdkEvent *, bool);
547 void finished (GdkEvent *, bool);
551 MidiTimeAxisView* _view;
552 boost::shared_ptr<ARDOUR::Region> _region;
555 /** Drags to resize MIDI notes */
556 class NoteResizeDrag : public Drag
559 NoteResizeDrag (Editor *, ArdourCanvas::Item *);
561 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
562 void motion (GdkEvent *, bool);
563 void finished (GdkEvent *, bool);
567 MidiRegionView* region;
574 /** Drags to move MIDI notes */
575 class NoteDrag : public Drag
578 NoteDrag (Editor*, ArdourCanvas::Item*);
580 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
581 void motion (GdkEvent *, bool);
582 void finished (GdkEvent *, bool);
585 void setup_pointer_sample_offset ();
588 double total_dx (GdkEvent * event) const; // total movement in quarter notes
589 int8_t total_dy () const;
591 MidiRegionView* _region;
593 double _cumulative_dx;
594 double _cumulative_dy;
595 double _earliest; // earliest quarter note in note selection
601 class NoteCreateDrag : public Drag
604 NoteCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
607 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
608 void motion (GdkEvent *, bool);
609 void finished (GdkEvent *, bool);
612 bool active (Editing::MouseMode mode) {
613 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
616 bool y_movement_matters () const {
621 double y_to_region (double) const;
622 ARDOUR::samplecnt_t grid_samples (samplepos_t) const;
624 /** @return minimum number of samples (in x) and pixels (in y) that should be considered a movement */
625 virtual std::pair<ARDOUR::samplecnt_t, int> move_threshold () const {
626 return std::make_pair (0, 0);
629 MidiRegionView* _region_view;
630 ArdourCanvas::Rectangle* _drag_rect;
631 samplepos_t _note[2];
634 class HitCreateDrag : public Drag
637 HitCreateDrag (Editor *, ArdourCanvas::Item *, MidiRegionView *);
640 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
641 void motion (GdkEvent *, bool);
642 void finished (GdkEvent *, bool);
645 bool active (Editing::MouseMode mode) {
646 return mode == Editing::MouseDraw || mode == Editing::MouseContent;
649 bool y_movement_matters () const {
654 double y_to_region (double) const;
655 ARDOUR::samplecnt_t grid_samples (samplepos_t) const;
657 /** @return minimum number of samples (in x) and pixels (in y) that should be considered a movement */
658 virtual std::pair<ARDOUR::samplecnt_t, int> move_threshold () const {
659 return std::make_pair (0, 0);
662 MidiRegionView* _region_view;
663 samplepos_t _last_pos;
668 /** Drag to move MIDI patch changes */
669 class PatchChangeDrag : public Drag
672 PatchChangeDrag (Editor *, PatchChange *, MidiRegionView *);
674 void motion (GdkEvent *, bool);
675 void finished (GdkEvent *, bool);
678 bool y_movement_matters () const {
682 void setup_pointer_sample_offset ();
685 MidiRegionView* _region_view;
686 PatchChange* _patch_change;
687 double _cumulative_dx;
690 /** Container for details about audio regions being dragged along with video */
694 AVDraggingView (RegionView *);
696 RegionView* view; ///< the view
697 samplepos_t initial_position; ///< initial position of the region
700 /** Drag of video offset */
701 class VideoTimeLineDrag : public Drag
704 VideoTimeLineDrag (Editor *e, ArdourCanvas::Item *i);
706 void motion (GdkEvent *, bool);
707 void finished (GdkEvent *, bool);
708 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
710 bool y_movement_matters () const {
714 bool allow_vertical_autoscroll () const {
721 std::list<AVDraggingView> _views; ///< information about all audio that are being dragged along
724 ARDOUR::sampleoffset_t _startdrag_video_offset;
725 ARDOUR::sampleoffset_t _max_backwards_drag;
729 /** Drag to trim region(s) */
730 class TrimDrag : public RegionDrag
739 TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &, bool preserve_fade_anchor = false);
741 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
742 void motion (GdkEvent *, bool);
743 void finished (GdkEvent *, bool);
746 bool y_movement_matters () const {
750 void setup_pointer_sample_offset ();
754 Operation _operation;
756 bool _preserve_fade_anchor;
757 bool _jump_position_when_done;
760 /** Meter marker drag */
761 class MeterMarkerDrag : public Drag
764 MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
766 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
767 void motion (GdkEvent *, bool);
768 void finished (GdkEvent *, bool);
771 bool allow_vertical_autoscroll () const {
775 bool y_movement_matters () const {
779 void setup_pointer_sample_offset ();
782 MeterMarker* _marker;
783 ARDOUR::MeterSection* _real_section;
786 Editing::GridType _old_grid_type;
787 Editing::SnapMode _old_snap_mode;
788 XMLNode* before_state;
791 /** Tempo marker drag */
792 class TempoMarkerDrag : public Drag
795 TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
797 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
798 void motion (GdkEvent *, bool);
799 void finished (GdkEvent *, bool);
802 bool allow_vertical_autoscroll () const {
806 bool y_movement_matters () const {
810 void setup_pointer_sample_offset ();
813 TempoMarker* _marker;
814 ARDOUR::TempoSection* _real_section;
818 ARDOUR::Tempo _grab_bpm;
820 XMLNode* _before_state;
823 /** BBT Ruler drag */
824 class BBTRulerDrag : public Drag
827 BBTRulerDrag (Editor *, ArdourCanvas::Item *);
829 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
830 void motion (GdkEvent *, bool);
831 void finished (GdkEvent *, bool);
834 bool allow_vertical_autoscroll () const {
838 bool y_movement_matters () const {
842 void setup_pointer_sample_offset ();
846 ARDOUR::TempoSection* _tempo;
847 XMLNode* _before_state;
851 /** tempo curve twist drag */
852 class TempoTwistDrag : public Drag
855 TempoTwistDrag (Editor *, ArdourCanvas::Item *);
857 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
858 void motion (GdkEvent *, bool);
859 void finished (GdkEvent *, bool);
862 bool allow_vertical_autoscroll () const {
866 bool y_movement_matters () const {
870 void setup_pointer_sample_offset ();
874 ARDOUR::Tempo _grab_tempo;
875 ARDOUR::TempoSection* _tempo;
876 ARDOUR::TempoSection* _next_tempo;
878 XMLNode* _before_state;
882 /** tempo curve twist drag */
883 class TempoEndDrag : public Drag
886 TempoEndDrag (Editor *, ArdourCanvas::Item *);
888 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
889 void motion (GdkEvent *, bool);
890 void finished (GdkEvent *, bool);
893 bool allow_vertical_autoscroll () const {
897 bool y_movement_matters () const {
901 void setup_pointer_sample_offset ();
905 ARDOUR::TempoSection* _tempo;
906 XMLNode* _before_state;
910 /** Drag of the playhead cursor */
911 class CursorDrag : public Drag
914 CursorDrag (Editor *, EditorCursor&, bool);
916 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
917 void motion (GdkEvent *, bool);
918 void finished (GdkEvent *, bool);
921 bool allow_vertical_autoscroll () const {
925 bool y_movement_matters () const {
930 void fake_locate (samplepos_t);
932 EditorCursor& _cursor;
933 bool _stop; ///< true to stop the transport on starting the drag, otherwise false
934 double _grab_zoom; ///< editor samples per unit when our grab started
943 /** Region fade-in drag */
944 class FadeInDrag : public RegionDrag
947 FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
949 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
950 void motion (GdkEvent *, bool);
951 void finished (GdkEvent *, bool);
954 bool y_movement_matters () const {
958 void setup_pointer_sample_offset ();
961 /** Region fade-out drag */
962 class FadeOutDrag : public RegionDrag
965 FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
967 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
968 void motion (GdkEvent *, bool);
969 void finished (GdkEvent *, bool);
972 bool y_movement_matters () const {
976 void setup_pointer_sample_offset ();
980 class MarkerDrag : public Drag
983 MarkerDrag (Editor *, ArdourCanvas::Item *);
986 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
987 void motion (GdkEvent *, bool);
988 void finished (GdkEvent *, bool);
991 bool allow_vertical_autoscroll () const {
995 bool y_movement_matters () const {
999 void setup_pointer_sample_offset ();
1000 void setup_video_sample_offset ();
1003 void update_item (ARDOUR::Location *);
1005 ArdourMarker* _marker; ///< marker being dragged
1006 bool _selection_changed;
1007 struct CopiedLocationMarkerInfo {
1008 ARDOUR::Location* location;
1009 std::vector<ArdourMarker*> markers;
1011 CopiedLocationMarkerInfo (ARDOUR::Location* l, ArdourMarker* m);
1014 typedef std::list<CopiedLocationMarkerInfo> CopiedLocationInfo;
1015 CopiedLocationInfo _copied_locations;
1016 ArdourCanvas::Points _points;
1019 /** Control point drag */
1020 class ControlPointDrag : public Drag
1023 ControlPointDrag (Editor *, ArdourCanvas::Item *);
1025 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1026 void motion (GdkEvent *, bool);
1027 void finished (GdkEvent *, bool);
1028 void aborted (bool);
1030 bool active (Editing::MouseMode m);
1034 ControlPoint* _point;
1035 double _fixed_grab_x;
1036 double _fixed_grab_y;
1037 double _cumulative_x_drag;
1038 double _cumulative_y_drag;
1040 uint32_t _final_index;
1041 static double _zero_gain_fraction;
1044 /** Gain or automation line drag */
1045 class LineDrag : public Drag
1048 LineDrag (Editor *e, ArdourCanvas::Item *i);
1050 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1051 void motion (GdkEvent *, bool);
1052 void finished (GdkEvent *, bool);
1053 void aborted (bool);
1057 AutomationLine* _line;
1058 double _fixed_grab_x;
1059 double _fixed_grab_y;
1060 double _cumulative_y_drag;
1065 /** Transient feature line drags*/
1066 class FeatureLineDrag : public Drag
1069 FeatureLineDrag (Editor *e, ArdourCanvas::Item *i);
1071 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1072 void motion (GdkEvent *, bool);
1073 void finished (GdkEvent *, bool);
1074 void aborted (bool);
1078 ArdourCanvas::Line* _line;
1079 AudioRegionView* _arv;
1081 double _region_view_grab_x;
1082 double _cumulative_x_drag;
1088 /** Dragging of a rubberband rectangle for selecting things */
1089 class RubberbandSelectDrag : public Drag
1092 RubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
1094 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1095 void motion (GdkEvent *, bool);
1096 void finished (GdkEvent *, bool);
1097 void aborted (bool);
1099 std::pair<ARDOUR::samplecnt_t, int> move_threshold () const {
1100 return std::make_pair (8, 1);
1103 void do_select_things (GdkEvent *, bool);
1105 /** Select some things within a rectangle.
1106 * @param button_state The button state from the GdkEvent.
1107 * @param x1 The left-hand side of the rectangle in session samples.
1108 * @param x2 The right-hand side of the rectangle in session samples.
1109 * @param y1 The top of the rectangle in trackview coordinates.
1110 * @param y2 The bottom of the rectangle in trackview coordinates.
1111 * @param drag_in_progress true if the drag is currently happening.
1113 virtual void select_things (int button_state, samplepos_t x1, samplepos_t x2, double y1, double y2, bool drag_in_progress) = 0;
1115 virtual void deselect_things () = 0;
1118 bool _vertical_only;
1121 /** A general editor RubberbandSelectDrag (for regions, automation points etc.) */
1122 class EditorRubberbandSelectDrag : public RubberbandSelectDrag
1125 EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *);
1127 void select_things (int, samplepos_t, samplepos_t, double, double, bool);
1128 void deselect_things ();
1131 /** A RubberbandSelectDrag for selecting MIDI notes */
1132 class MidiRubberbandSelectDrag : public RubberbandSelectDrag
1135 MidiRubberbandSelectDrag (Editor *, MidiRegionView *);
1137 void select_things (int, samplepos_t, samplepos_t, double, double, bool);
1138 void deselect_things ();
1141 MidiRegionView* _region_view;
1144 /** A RubberbandSelectDrag for selecting MIDI notes but with no horizonal component */
1145 class MidiVerticalSelectDrag : public RubberbandSelectDrag
1148 MidiVerticalSelectDrag (Editor *, MidiRegionView *);
1150 void select_things (int, samplepos_t, samplepos_t, double, double, bool);
1151 void deselect_things ();
1154 MidiRegionView* _region_view;
1157 /** Region drag in time-FX mode */
1158 class TimeFXDrag : public RegionDrag
1161 TimeFXDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
1163 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1164 void motion (GdkEvent *, bool);
1165 void finished (GdkEvent *, bool);
1166 void aborted (bool);
1169 /** Scrub drag in audition mode */
1170 class ScrubDrag : public Drag
1173 ScrubDrag (Editor *, ArdourCanvas::Item *);
1175 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1176 void motion (GdkEvent *, bool);
1177 void finished (GdkEvent *, bool);
1178 void aborted (bool);
1181 /** Drag in range select mode */
1182 class SelectionDrag : public Drag
1193 SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
1195 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1196 void motion (GdkEvent *, bool);
1197 void finished (GdkEvent *, bool);
1198 void aborted (bool);
1200 void setup_pointer_sample_offset ();
1203 Operation _operation;
1205 TrackSelection _track_selection_at_start;
1206 bool _time_selection_at_start;
1207 samplepos_t start_at_start;
1208 samplepos_t end_at_start;
1211 /** Range marker drag */
1212 class RangeMarkerBarDrag : public Drag
1218 CreateTransportMarker,
1222 RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
1223 ~RangeMarkerBarDrag ();
1225 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1226 void motion (GdkEvent *, bool);
1227 void finished (GdkEvent *, bool);
1228 void aborted (bool);
1230 bool allow_vertical_autoscroll () const {
1234 bool y_movement_matters () const {
1239 void update_item (ARDOUR::Location *);
1241 Operation _operation;
1242 ArdourCanvas::Rectangle* _drag_rect;
1246 /** Drag of rectangle to set zoom */
1247 class MouseZoomDrag : public Drag
1250 MouseZoomDrag (Editor *, ArdourCanvas::Item *);
1252 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1253 void motion (GdkEvent *, bool);
1254 void finished (GdkEvent *, bool);
1255 void aborted (bool);
1257 std::pair<ARDOUR::samplecnt_t, int> move_threshold () const {
1258 return std::make_pair (4, 4);
1265 /** Drag of a range of automation data (either on an automation track or region gain),
1266 * changing value but not position.
1268 class AutomationRangeDrag : public Drag
1271 AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
1272 AutomationRangeDrag (Editor *, std::list<RegionView*> const &, std::list<ARDOUR::AudioRange> const &, double y_origin, double y_height);
1274 void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
1275 void motion (GdkEvent *, bool);
1276 void finished (GdkEvent *, bool);
1277 void aborted (bool);
1279 bool x_movement_matters () const {
1284 void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
1285 double y_fraction (double global_y_position) const;
1286 double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
1288 std::list<ARDOUR::AudioRange> _ranges;
1290 /** A line that is part of the drag */
1292 boost::shared_ptr<AutomationLine> line; ///< the line
1293 std::list<ControlPoint*> points; ///< points to drag on the line
1294 std::pair<ARDOUR::samplepos_t, ARDOUR::samplepos_t> range; ///< the range of all points on the line, in session samples
1295 XMLNode* state; ///< the XML state node before the drag
1298 std::list<Line> _lines;
1301 bool _nothing_to_drag;
1305 /** Drag of one edge of an xfade
1307 class CrossfadeEdgeDrag : public Drag
1310 CrossfadeEdgeDrag (Editor*, AudioRegionView*, ArdourCanvas::Item*, bool start);
1312 void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
1313 void motion (GdkEvent*, bool);
1314 void finished (GdkEvent*, bool);
1315 void aborted (bool);
1317 bool y_movement_matters () const {
1321 virtual std::pair<ARDOUR::samplecnt_t, int> move_threshold () const {
1322 return std::make_pair (4, 4);
1326 AudioRegionView* arv;
1330 #endif /* __gtk2_ardour_editor_drag_h_ */