X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_drag.h;h=44b2d50767c5dba7a2d788f02af3524f6835dd89;hb=ccc5467bcaef73fdabafc5c4b01e8762798f9ac2;hp=04d7150ee4446409554619fa5593cd3f320debbc;hpb=37b680cd15ba0d7f902a19e56b6b4d324de535e9;p=ardour.git diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 04d7150ee4..44b2d50767 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -24,7 +24,6 @@ #include #include -#include #include "ardour/types.h" @@ -42,7 +41,7 @@ namespace PBD { namespace Gnome { namespace Canvas { class CanvasNoteEvent; - class CanvasProgramChange; + class CanvasPatchChange; } } @@ -100,6 +99,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 */ @@ -124,7 +124,7 @@ public: ARDOUR::framepos_t adjusted_frame (ARDOUR::framepos_t, GdkEvent const *, bool snap = true) const; ARDOUR::framepos_t adjusted_current_frame (GdkEvent const *, bool snap = true) const; - + /** Called to start a grab of an item. * @param e Event that caused the grab to start. * @param c Cursor to use, or 0. @@ -147,8 +147,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. @@ -211,6 +212,10 @@ protected: return _last_pointer_frame; } + void show_verbose_cursor_time (framepos_t); + void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0); + void show_verbose_cursor_text (std::string const &); + Editor* _editor; ///< our editor DragManager* _drags; ArdourCanvas::Item* _item; ///< our item @@ -240,7 +245,9 @@ struct DraggingView DraggingView (RegionView *, RegionDrag *); RegionView* view; ///< the view - /** index into RegionDrag::_time_axis_views of the view that this region is currently beind displayed on */ + /** index into RegionDrag::_time_axis_views of the view that this region is currently being displayed on, + * or -1 if it is not visible. + */ int time_axis_view; /** layer that this region is currently being displayed on */ ARDOUR::layer_t layer; @@ -270,9 +277,9 @@ protected: int _visible_y_high; friend class DraggingView; - + private: - + void region_going_away (RegionView *); PBD::ScopedConnection death_connection; }; @@ -289,7 +296,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). @@ -320,7 +327,7 @@ public: void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool regions_came_from_canvas () const { return true; @@ -364,7 +371,7 @@ private: void add_stateful_diff_commands_for_playlists (PlaylistSet const &); void collect_new_region_view (RegionView *); - + bool _copy; RegionView* _new_region_view; }; @@ -376,7 +383,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; @@ -391,7 +398,7 @@ public: void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); }; /** Drags to create regions */ @@ -402,7 +409,7 @@ public: void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); private: MidiTimeAxisView* _view; @@ -419,7 +426,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; @@ -436,13 +443,13 @@ 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: ARDOUR::frameoffset_t total_dx () const; int8_t total_dy () const; - + MidiRegionView* _region; Gnome::Canvas::CanvasNoteEvent* _primary; double _cumulative_dx; @@ -451,15 +458,15 @@ class NoteDrag : public Drag double _note_height; }; -/** Drag to move MIDI program changes */ -class ProgramChangeDrag : public Drag +/** Drag to move MIDI patch changes */ +class PatchChangeDrag : public Drag { public: - ProgramChangeDrag (Editor *, ArdourCanvas::CanvasProgramChange *, MidiRegionView *); + PatchChangeDrag (Editor *, ArdourCanvas::CanvasPatchChange *, MidiRegionView *); void motion (GdkEvent *, bool); void finished (GdkEvent *, bool); - void aborted (); + void aborted (bool); bool y_movement_matters () const { return false; @@ -469,7 +476,7 @@ public: private: MidiRegionView* _region_view; - ArdourCanvas::CanvasProgramChange* _program_change; + ArdourCanvas::CanvasPatchChange* _patch_change; double _cumulative_dx; }; @@ -485,7 +492,7 @@ public: return (m == Editing::MouseGain); } - void aborted (); + void aborted (bool); }; /** Drag to trim region(s) */ @@ -503,18 +510,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 */ @@ -526,7 +532,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; @@ -537,7 +543,7 @@ public: } void setup_pointer_frame_offset (); - + private: MeterMarker* _marker; bool _copy; @@ -552,7 +558,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; @@ -563,14 +569,14 @@ public: } void setup_pointer_frame_offset (); - + private: TempoMarker* _marker; bool _copy; }; -/** Drag of a cursor */ +/** Drag of the playhead cursor */ class CursorDrag : public Drag { public: @@ -579,7 +585,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; @@ -590,15 +596,14 @@ public: } bool y_movement_matters () const { - return false; + return true; } - void setup_pointer_frame_offset (); - private: - EditorCursor* _cursor; ///< cursor being dragged - bool _stop; ///< true to stop the transport on starting the drag, otherwise false + void fake_locate (framepos_t); + bool _stop; ///< true to stop the transport on starting the drag, otherwise false + double _grab_zoom; ///< editor frames per unit when our grab started }; /** Region fade-in drag */ @@ -610,7 +615,7 @@ 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; @@ -628,7 +633,7 @@ 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; @@ -647,7 +652,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; @@ -658,13 +663,12 @@ public: } 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; }; @@ -677,7 +681,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); @@ -688,7 +692,7 @@ private: double _fixed_grab_y; double _cumulative_x_drag; double _cumulative_y_drag; - static double const _zero_gain_fraction; + static double _zero_gain_fraction; }; /** Gain or automation line drag */ @@ -700,7 +704,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; @@ -725,7 +729,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; @@ -733,13 +737,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; }; @@ -752,11 +756,48 @@ 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); } + + void do_select_things (GdkEvent *, bool); + + /** Select some things within a rectangle. + * @param button_state The button state from the GdkEvent. + * @param x1 The left-hand side of the rectangle in session frames. + * @param x2 The right-hand side of the rectangle in session frames. + * @param y1 The top of the rectangle in trackview coordinates. + * @param y2 The bottom of the rectangle in trackview coordinates. + * @param drag_in_progress true if the drag is currently happening. + */ + virtual void select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool drag_in_progress) = 0; + + virtual void deselect_things () = 0; +}; + +/** A general editor RubberbandSelectDrag (for regions, automation points etc.) */ +class EditorRubberbandSelectDrag : public RubberbandSelectDrag +{ +public: + EditorRubberbandSelectDrag (Editor *, ArdourCanvas::Item *); + + void select_things (int, framepos_t, framepos_t, double, double, bool); + void deselect_things (); +}; + +/** A RubberbandSelectDrag for selecting MIDI notes */ +class MidiRubberbandSelectDrag : public RubberbandSelectDrag +{ +public: + MidiRubberbandSelectDrag (Editor *, MidiRegionView *); + + void select_things (int, framepos_t, framepos_t, double, double, bool); + void deselect_things (); + +private: + MidiRegionView* _region_view; }; /** Region drag in time-FX mode */ @@ -768,7 +809,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 */ @@ -780,7 +821,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 */ @@ -799,7 +840,7 @@ 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 (); @@ -826,7 +867,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; @@ -853,7 +894,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); @@ -872,7 +913,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; @@ -889,9 +930,9 @@ private: 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; };