X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_drag.h;h=ce8a1370f4e63ca1ac6ce266f0e75ea1dee97443;hb=267cfbe731debe3f3be88375bce34644ac7c6323;hp=6b4420715f26bc0abbae2ca64f4dc7596fe68f88;hpb=7decc96544f658882326d4e4f6d961e7706541f2;p=ardour.git diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 6b4420715f..ce8a1370f4 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 { @@ -239,6 +247,8 @@ struct DraggingView /** layer that this region is currently being displayed on */ ARDOUR::layer_t layer; double initial_y; ///< the initial y position of the view before any reparenting + framepos_t initial_position; ///< initial position of the region + framepos_t initial_end; ///< initial end position of the region boost::shared_ptr initial_playlist; }; @@ -281,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). @@ -310,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; @@ -323,6 +332,8 @@ public: return std::make_pair (4, 4); } + void setup_pointer_frame_offset (); + private: typedef std::set > PlaylistSet; @@ -367,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; @@ -382,7 +393,7 @@ public: void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); }; /** Drags to create regions */ @@ -393,11 +404,12 @@ public: void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); private: MidiTimeAxisView* _view; boost::shared_ptr _region; + void add_region (); }; /** Drags to resize MIDI notes */ @@ -409,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; @@ -426,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: @@ -441,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 { @@ -453,7 +487,7 @@ public: return (m == Editing::MouseGain); } - void aborted (); + void aborted (bool); }; /** Drag to trim region(s) */ @@ -471,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 */ @@ -492,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; @@ -501,6 +536,8 @@ public: bool y_movement_matters () const { return false; } + + void setup_pointer_frame_offset (); private: MeterMarker* _marker; @@ -516,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; @@ -526,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: @@ -541,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; @@ -554,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 */ @@ -570,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 */ @@ -586,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 */ @@ -603,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; @@ -612,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; }; @@ -631,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); @@ -654,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; @@ -679,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; @@ -687,13 +731,13 @@ public: private: - ArdourCanvas::SimpleLine* _line; + ArdourCanvas::Line* _line; AudioRegionView* _arv; double _region_view_grab_x; double _cumulative_x_drag; - uint32_t _before; + float _before; uint32_t _max_x; }; @@ -706,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); @@ -722,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 */ @@ -734,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 */ @@ -753,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; @@ -778,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; @@ -805,7 +851,14 @@ 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); + } + +private: + bool _zoom_out; }; /** Drag of a range of automation data, changing value but not position */ @@ -817,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; @@ -826,7 +879,17 @@ public: private: std::list _ranges; AutomationTimeAxisView* _atav; - boost::shared_ptr _line; + + /** A line that is part of the drag */ + struct Line { + boost::shared_ptr line; ///< the line + std::list points; ///< points to drag on the line + std::pair range; ///< the range of all points on the line, in session frames + XMLNode* state; ///< the XML state node before the drag + }; + + std::list _lines; + bool _nothing_to_drag; };