X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_drag.h;h=ab81db5a63438f9c650a809092eada0e56fb4a8c;hb=cf1541c3086b376ecac1b70cafef058b4348ab96;hp=e0d3d91ee86f6a99775e0dbe2992a491905a6595;hpb=d29f14bf33bc807be7b95015e4f011f4ad741cc6;p=ardour.git diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index e0d3d91ee8..ab81db5a63 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -42,6 +42,7 @@ namespace PBD { namespace Gnome { namespace Canvas { class CanvasNoteEvent; + class CanvasPatchChange; } } @@ -99,6 +100,7 @@ private: double _current_pointer_x; ///< trackview x of the current pointer double _current_pointer_y; ///< trackview y of the current pointer ARDOUR::framepos_t _current_pointer_frame; ///< frame that the pointer is now at + bool _old_follow_playhead; ///< state of Editor::follow_playhead() before the drags started }; /** Abstract base class for dragging of things within the editor */ @@ -146,8 +148,9 @@ public: /** Called to abort a drag and return things to how * they were before it started. + * @param m true if some movement occurred, otherwise false. */ - virtual void aborted () = 0; + virtual void aborted (bool m) = 0; /** @param m Mouse mode. * @return true if this drag should happen in this mouse mode. @@ -175,6 +178,11 @@ public: return true; } + /** Set up the _pointer_frame_offset */ + virtual void setup_pointer_frame_offset () { + _pointer_frame_offset = 0; + } + protected: double grab_x () const { @@ -283,7 +291,7 @@ public: virtual void start_grab (GdkEvent *, Gdk::Cursor *); virtual void motion (GdkEvent *, bool); virtual void finished (GdkEvent *, bool) = 0; - virtual void aborted (); + virtual void aborted (bool); /** @return true if the regions being `moved' came from somewhere on the canvas; * false if they came from outside (e.g. from the region list). @@ -312,10 +320,9 @@ public: RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list const &, bool, bool); virtual ~RegionMoveDrag () {} - virtual void start_grab (GdkEvent *, Gdk::Cursor *); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool regions_came_from_canvas () const { return true; @@ -325,6 +332,8 @@ public: return std::make_pair (4, 4); } + void setup_pointer_frame_offset (); + private: typedef std::set > PlaylistSet; @@ -369,7 +378,7 @@ public: RegionInsertDrag (Editor *, boost::shared_ptr, RouteTimeAxisView*, ARDOUR::framepos_t); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool regions_came_from_canvas () const { return false; @@ -384,7 +393,7 @@ public: void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); }; /** Drags to create regions */ @@ -395,7 +404,7 @@ public: void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); private: MidiTimeAxisView* _view; @@ -412,7 +421,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); private: MidiRegionView* region; @@ -429,7 +438,7 @@ class NoteDrag : public Drag void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); private: @@ -444,6 +453,28 @@ class NoteDrag : public Drag double _note_height; }; +/** Drag to move MIDI patch changes */ +class PatchChangeDrag : public Drag +{ +public: + PatchChangeDrag (Editor *, ArdourCanvas::CanvasPatchChange *, MidiRegionView *); + + void motion (GdkEvent *, bool); + void finished (GdkEvent *, bool); + void aborted (bool); + + bool y_movement_matters () const { + return false; + } + + void setup_pointer_frame_offset (); + +private: + MidiRegionView* _region_view; + ArdourCanvas::CanvasPatchChange* _patch_change; + double _cumulative_dx; +}; + /** Drag of region gain */ class RegionGainDrag : public Drag { @@ -456,7 +487,7 @@ public: return (m == Editing::MouseGain); } - void aborted (); + void aborted (bool); }; /** Drag to trim region(s) */ @@ -474,16 +505,17 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool y_movement_matters () const { return false; } + void setup_pointer_frame_offset (); + private: Operation _operation; - bool _have_transaction; ///< true if a transaction has been started, false otherwise. Must be set true by derived class. }; /** Meter marker drag */ @@ -495,7 +527,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool allow_vertical_autoscroll () const { return false; @@ -504,6 +536,8 @@ public: bool y_movement_matters () const { return false; } + + void setup_pointer_frame_offset (); private: MeterMarker* _marker; @@ -519,7 +553,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool allow_vertical_autoscroll () const { return false; @@ -529,13 +563,15 @@ public: return false; } + void setup_pointer_frame_offset (); + private: TempoMarker* _marker; bool _copy; }; -/** Drag of a cursor */ +/** Drag of the playhead cursor */ class CursorDrag : public Drag { public: @@ -544,7 +580,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool active (Editing::MouseMode) { return true; @@ -557,11 +593,11 @@ public: bool y_movement_matters () const { return false; } - + private: - EditorCursor* _cursor; ///< cursor being dragged + void fake_locate (framepos_t); + bool _stop; ///< true to stop the transport on starting the drag, otherwise false - }; /** Region fade-in drag */ @@ -573,11 +609,13 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool y_movement_matters () const { return false; } + + void setup_pointer_frame_offset (); }; /** Region fade-out drag */ @@ -589,11 +627,13 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool y_movement_matters () const { return false; } + + void setup_pointer_frame_offset (); }; /** Marker drag */ @@ -606,7 +646,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool allow_vertical_autoscroll () const { return false; @@ -615,13 +655,14 @@ public: bool y_movement_matters () const { return false; } + + void setup_pointer_frame_offset (); private: void update_item (ARDOUR::Location *); Marker* _marker; ///< marker being dragged std::list _copied_locations; - ArdourCanvas::Line* _line; ArdourCanvas::Points _points; }; @@ -634,7 +675,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool active (Editing::MouseMode m); @@ -657,7 +698,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool active (Editing::MouseMode) { return true; @@ -682,7 +723,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool active (Editing::MouseMode) { return true; @@ -709,7 +750,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); std::pair move_threshold () const { return std::make_pair (8, 1); @@ -725,7 +766,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); }; /** Scrub drag in audition mode */ @@ -737,7 +778,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); }; /** Drag in range select mode */ @@ -756,7 +797,9 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); + + void setup_pointer_frame_offset (); private: Operation _operation; @@ -781,7 +824,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool allow_vertical_autoscroll () const { return false; @@ -808,7 +851,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); std::pair move_threshold () const { return std::make_pair (4, 4); @@ -827,7 +870,7 @@ public: void start_grab (GdkEvent *, Gdk::Cursor* c = 0); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool x_movement_matters () const { return false;