Move toggle-waveforms-while-recording into RC options.
[ardour.git] / gtk2_ardour / editor.h
1 /*
2     Copyright (C) 2000-2003 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __ardour_editor_h__
21 #define __ardour_editor_h__
22
23 #include <list>
24 #include <map>
25 #include <set>
26 #include <string>
27 #include <sys/time.h>
28 #include <bitset>
29
30 #include <glibmm/ustring.h>
31
32 #include <boost/optional.hpp>
33
34 #include <libgnomecanvasmm/canvas.h>
35 #include <libgnomecanvasmm/group.h>
36 #include <libgnomecanvasmm/line.h>
37 #include <libgnomecanvasmm/pixbuf.h>
38
39 #include <cmath>
40
41 #include <gtkmm/comboboxtext.h>
42 #include <gtkmm/layout.h>
43
44 #include <gtkmm2ext/selector.h>
45 #include <gtkmm2ext/click_box.h>
46 #include <gtkmm2ext/dndtreeview.h>
47
48 #include "pbd/stateful.h"
49 #include "pbd/signals.h"
50
51 #include "ardour/import_status.h"
52 #include "ardour/tempo.h"
53 #include "ardour/location.h"
54 #include "ardour/audioregion.h"
55 #include "ardour/track.h"
56 #include "ardour/types.h"
57 #include "ardour/route_group.h"
58
59 #include "audio_clock.h"
60 #include "gtk-custom-ruler.h"
61 #include "ardour_dialog.h"
62 #include "public_editor.h"
63 #include "editing.h"
64 #include "enums.h"
65 #include "editor_items.h"
66 #include "region_selection.h"
67 #include "canvas.h"
68 #include "editor_summary.h"
69
70 namespace Gnome { namespace Canvas {
71         class NoEventText;
72 } }
73
74 namespace Gtkmm2ext {
75         class TearOff;
76 }
77
78 namespace ARDOUR {
79         class AudioDiskstream;
80         class RouteGroup;
81         class Playlist;
82         class AudioPlaylist;
83         class Region;
84         class Location;
85         class TempoSection;
86         class NamedSelection;
87         class Session;
88         class Filter;
89         class Crossfade;
90         class ChanCount;
91         class MidiOperator;
92         class MidiTrack;
93         class AudioTrack;
94 }
95
96 namespace LADSPA {
97         class Plugin;
98 }
99
100 class AnalysisWindow;
101 class AudioRegionView;
102 class AudioStreamView;
103 class AudioTimeAxisView;
104 class AutomationLine;
105 class AutomationSelection;
106 class AutomationTimeAxisView;
107 class BundleManager;
108 class ControlPoint;
109 class CrossfadeView;
110 class DragManager;
111 class GlobalPortMatrixWindow;
112 class GroupedButtons;
113 class Marker;
114 class MidiRegionView;
115 class MixerStrip;
116 class PlaylistSelector;
117 class PluginSelector;
118 class RhythmFerret;
119 class Selection;
120 class SoundFileOmega;
121 class StreamView;
122 class TempoLines;
123 class TimeAxisView;
124 class TimeFXDialog;
125 class TimeSelection;
126 class EditorGroupTabs;
127 class EditorRoutes;
128 class EditorRouteGroups;
129 class EditorRegions;
130 class EditorLocations;
131 class EditorSnapshots;
132
133 /* <CMT Additions> */
134 class ImageFrameView;
135 class ImageFrameTimeAxisView;
136 class ImageFrameTimeAxis;
137 class MarkerTimeAxis ;
138 class MarkerView ;
139 class ImageFrameSocketHandler ;
140 class TimeAxisViewItem ;
141 /* </CMT Additions> */
142
143 struct EditorCursor {
144         Editor&               editor;
145         ArdourCanvas::Points  points;
146         ArdourCanvas::Line    canvas_item;
147         nframes64_t           current_frame;
148         double            length;
149
150         EditorCursor (Editor&, bool (Editor::*)(GdkEvent*,ArdourCanvas::Item*));
151         ~EditorCursor ();
152
153         void set_position (nframes64_t);
154         void set_length (double units);
155         void set_y_axis (double position);
156
157         PBD::Signal1<void, nframes64_t> PositionChanged;
158 };
159
160 class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr
161 {
162   public:
163         Editor ();
164         ~Editor ();
165
166         void             set_session (ARDOUR::Session *);
167         ARDOUR::Session* session() const { return _session; }
168
169         void             first_idle ();
170         virtual bool     have_idled () const { return _have_idled; }
171
172         nframes64_t leftmost_position() const { return leftmost_frame; }
173
174         nframes64_t current_page_frames() const {
175                 return (nframes64_t) floor (_canvas_width * frames_per_unit);
176         }
177
178         double canvas_height () const {
179                 return _canvas_height;
180         }
181
182         void cycle_snap_mode ();
183         void cycle_snap_choice ();
184         void set_snap_to (Editing::SnapType);
185         void set_snap_mode (Editing::SnapMode);
186         void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;}
187
188         Editing::SnapMode  snap_mode () const;
189         Editing::SnapType  snap_type () const;
190
191         void undo (uint32_t n = 1);
192         void redo (uint32_t n = 1);
193
194         XMLNode& get_state ();
195         int set_state (const XMLNode&, int version);
196
197         void set_mouse_mode (Editing::MouseMode, bool force=true);
198         void step_mouse_mode (bool next);
199         Editing::MouseMode current_mouse_mode () const { return mouse_mode; }
200         Editing::MidiEditMode current_midi_edit_mode () const;
201
202         bool internal_editing() const { return _internal_editing ; }
203         void set_internal_edit (bool yn);
204
205 #ifdef WITH_CMT
206         void add_imageframe_time_axis(const std::string & track_name, void*) ;
207         void add_imageframe_marker_time_axis(const std::string & track_name, TimeAxisView* marked_track, void*) ;
208         void connect_to_image_compositor() ;
209         void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ;
210         TimeAxisView* get_named_time_axis(const std::string & name) ;
211 #endif /* WITH_CMT */
212
213         void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>);
214         void add_to_idle_resize (TimeAxisView*, int32_t);
215
216         RouteTimeAxisView* get_route_view_by_id (PBD::ID& id);
217
218         void consider_auditioning (boost::shared_ptr<ARDOUR::Region>);
219         void hide_a_region (boost::shared_ptr<ARDOUR::Region>);
220         void show_a_region (boost::shared_ptr<ARDOUR::Region>);
221
222 #ifdef USE_RUBBERBAND
223         std::vector<std::string> rb_opt_strings;
224 #endif
225
226         /* things that need to be public to be used in the main menubar */
227
228         void new_region_from_selection ();
229         void separate_regions_between (const TimeSelection&);
230         void separate_region_from_selection ();
231         void separate_region_from_punch ();
232         void separate_region_from_loop ();
233         void separate_regions_using_location (ARDOUR::Location&);
234         void transition_to_rolling (bool forward);
235
236         /* undo related */
237
238         nframes64_t unit_to_frame (double unit) const {
239                 return (nframes64_t) rint (unit * frames_per_unit);
240         }
241
242         double frame_to_unit (nframes64_t frame) const {
243                 return rint ((double) frame / (double) frames_per_unit);
244         }
245
246         double frame_to_unit (double frame) const {
247                 return rint (frame / frames_per_unit);
248         }
249
250         /* NOTE: these functions assume that the "pixel" coordinate is
251            the result of using the world->canvas affine transform on a
252            world coordinate. These coordinates already take into
253            account any scrolling carried out by adjusting the
254            xscroll_adjustment.
255         */
256
257         nframes64_t pixel_to_frame (double pixel) const {
258
259                 /* pixel can be less than zero when motion events
260                    are processed. since we've already run the world->canvas
261                    affine, that means that the location *really* is "off
262                    to the right" and thus really is "before the start".
263                 */
264
265                 if (pixel >= 0) {
266                         return (nframes64_t) rint (pixel * frames_per_unit * GNOME_CANVAS(track_canvas->gobj())->pixels_per_unit);
267                 } else {
268                         return 0;
269                 }
270         }
271
272         gulong frame_to_pixel (nframes64_t frame) const {
273                 return (gulong) rint ((frame / (frames_per_unit * GNOME_CANVAS(track_canvas->gobj())->pixels_per_unit)));
274         }
275
276         void flush_canvas ();
277
278         /* selection */
279
280         Selection& get_selection() const { return *selection; }
281         Selection& get_cut_buffer() const { return *cut_buffer; }
282
283         bool extend_selection_to_track (TimeAxisView&);
284
285         void play_selection ();
286         void select_all_in_track (Selection::Operation op);
287         void select_all (Selection::Operation op);
288         void invert_selection_in_track ();
289         void invert_selection ();
290         void deselect_all ();
291
292         void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
293
294         /* tempo */
295
296         void set_show_measures (bool yn);
297         bool show_measures () const { return _show_measures; }
298
299         /* analysis window */
300
301         void analyze_region_selection();
302         void analyze_range_selection();
303
304         /* export */
305
306         void export_audio ();
307         void export_selection ();
308         void export_range ();
309         void export_region ();
310
311         void add_toplevel_controls (Gtk::Container&);
312         Gtk::HBox& get_status_bar_packer()  { return status_bar_hpacker; }
313
314         void               set_zoom_focus (Editing::ZoomFocus);
315         Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
316         double             get_current_zoom () const { return frames_per_unit; }
317
318         void temporal_zoom_step (bool coarser);
319         void tav_zoom_step (bool coarser);
320
321         /* stuff that AudioTimeAxisView and related classes use */
322
323         PlaylistSelector& playlist_selector() const;
324         void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>);
325
326         void new_playlists (TimeAxisView* v);
327         void copy_playlists (TimeAxisView* v);
328         void clear_playlists (TimeAxisView* v);
329
330         void get_onscreen_tracks (TrackViewList&);
331
332         Width editor_mixer_strip_width;
333         void maybe_add_mixer_strip_width (XMLNode&);
334         void show_editor_mixer (bool yn);
335         void create_editor_mixer ();
336         void show_editor_list (bool yn);
337         void set_selected_mixer_strip (TimeAxisView&);
338         void hide_track_in_display (TimeAxisView& tv, bool temporary = false);
339
340         /* nudge is initiated by transport controls owned by ARDOUR_UI */
341
342         nframes64_t get_nudge_distance (nframes64_t pos, nframes64_t& next);
343         Evoral::MusicalTime get_grid_type_as_beats (bool& success, nframes64_t position);
344
345         void nudge_forward (bool next, bool force_playhead);
346         void nudge_backward (bool next, bool force_playhead);
347
348         /* nudge initiated from context menu */
349
350         void nudge_forward_capture_offset ();
351         void nudge_backward_capture_offset ();
352
353         /* playhead/screen stuff */
354
355         void set_stationary_playhead (bool yn);
356         void toggle_stationary_playhead ();
357         bool stationary_playhead() const { return _stationary_playhead; }
358         
359         void set_follow_playhead (bool yn);
360         void toggle_follow_playhead ();
361         bool follow_playhead() const { return _follow_playhead; }
362         bool dragging_playhead () const { return _dragging_playhead; }
363
364         void toggle_zero_line_visibility ();
365         void set_summary ();
366         void set_group_tabs ();
367         void toggle_measure_visibility ();
368         void toggle_logo_visibility ();
369
370         double get_physical_screen_width () const { return physical_screen_width; };
371         double physical_screen_width;
372         double physical_screen_height;
373
374         /* fades/xfades */
375
376         void toggle_selected_region_fades (int dir);
377         void update_region_fade_visibility ();
378         bool xfade_visibility() const { return _xfade_visibility; }
379         void update_xfade_visibility ();
380
381         /* redirect shared ops menu. caller must free returned menu */
382
383         Gtk::Menu* redirect_menu ();
384
385         /* floating windows/transient */
386
387         void ensure_float (Gtk::Window&);
388
389         void show_window ();
390
391         void scroll_tracks_down_line ();
392         void scroll_tracks_up_line ();
393
394         bool new_regionviews_display_gain () { return _new_regionviews_show_envelope; }
395         void prepare_for_cleanup ();
396         void finish_cleanup ();
397
398         void maximise_editing_space();
399         void restore_editing_space();
400
401         void reset_x_origin (nframes64_t);
402         void reset_x_origin_to_follow_playhead ();
403         void reset_y_origin (double);
404         void reset_zoom (double);
405         void reposition_and_zoom (nframes64_t, double);
406
407         nframes64_t get_preferred_edit_position (bool ignore_playhead = false);
408
409         bool update_mouse_speed ();
410         bool decelerate_mouse_speed ();
411
412         void toggle_meter_updating();
413
414         void show_rhythm_ferret();
415         void show_global_port_matrix (ARDOUR::DataType);
416
417         void goto_visual_state (uint32_t);
418         void save_visual_state (uint32_t);
419
420         void queue_draw_resize_line (int at);
421         void start_resize_line_ops ();
422         void end_resize_line_ops ();
423
424         TrackViewList const & get_track_views () {
425                 return track_views;
426         }
427
428         int get_regionview_count_from_region_list (boost::shared_ptr<ARDOUR::Region>);
429
430         void do_import (std::vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t&);
431         void do_embed (std::vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode,  nframes64_t&);
432
433         void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions);
434
435         void show_verbose_canvas_cursor_with (const std::string& txt);
436         void hide_verbose_canvas_cursor();
437
438         void center_screen (nframes64_t);
439
440         TrackViewList axis_views_from_routes (boost::shared_ptr<ARDOUR::RouteList>) const;
441         Gtkmm2ext::TearOff* mouse_mode_tearoff () const { return _mouse_mode_tearoff; }
442         Gtkmm2ext::TearOff* tools_tearoff () const { return _tools_tearoff; }
443
444         void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
445         void snap_to_with_modifier (nframes64_t& first, GdkEvent const *, int32_t direction = 0, bool for_mark = false);
446         void snap_to (nframes64_t& first, nframes64_t& last, int32_t direction = 0, bool for_mark = false);
447
448         void begin_reversible_command (std::string cmd_name);
449         void commit_reversible_command ();
450
451   protected:
452         void map_transport_state ();
453         void map_position_change (nframes64_t);
454
455         void on_realize();
456
457   private:
458
459         void color_handler ();
460
461         bool                 constructed;
462
463         // to keep track of the playhead position for control_scroll
464         boost::optional<nframes64_t> _control_scroll_target;
465
466         PlaylistSelector* _playlist_selector;
467
468         typedef std::pair<TimeAxisView*,XMLNode*> TAVState;
469
470         struct VisualState {
471             double              y_position;
472             double              frames_per_unit;
473             nframes64_t         leftmost_frame;
474             Editing::ZoomFocus  zoom_focus;
475             std::list<TAVState> track_states;
476         };
477
478         std::list<VisualState*> undo_visual_stack;
479         std::list<VisualState*> redo_visual_stack;
480         VisualState* current_visual_state (bool with_tracks = true);
481         void undo_visual_state ();
482         void redo_visual_state ();
483         void use_visual_state (VisualState&);
484         bool no_save_visual;
485         void swap_visual_state ();
486
487         std::vector<VisualState*> visual_states;
488         sigc::connection visual_state_op_connection;
489         void start_visual_state_op (uint32_t n);
490         void cancel_visual_state_op (uint32_t n);
491         bool end_visual_state_op (uint32_t n);
492
493         nframes64_t leftmost_frame;
494         double      frames_per_unit;
495         Editing::ZoomFocus zoom_focus;
496
497         void set_frames_per_unit (double);
498         void post_zoom ();
499
500         Editing::MouseMode mouse_mode;
501         bool _internal_editing;
502         Editing::MouseMode effective_mouse_mode () const;
503
504         enum JoinObjectRangeState {
505                 JOIN_OBJECT_RANGE_NONE,
506                 /** `join object/range' mode is active and the mouse is over a place where object mode should happen */
507                 JOIN_OBJECT_RANGE_OBJECT,
508                 /** `join object/range' mode is active and the mouse is over a place where range mode should happen */
509                 JOIN_OBJECT_RANGE_RANGE
510         };
511
512         JoinObjectRangeState _join_object_range_state;
513
514         void update_join_object_range_location (double, double);
515
516         int  post_maximal_editor_width;
517         int  post_maximal_pane_position;
518         int  pre_maximal_pane_position;
519         int  pre_maximal_editor_width;
520         void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*);
521
522         Gtk::Notebook the_notebook;
523         Gtk::HPaned   edit_pane;
524
525         Gtk::EventBox meter_base;
526         Gtk::HBox     meter_box;
527         Gtk::EventBox marker_base;
528         Gtk::HBox     marker_box;
529         Gtk::VBox     scrollers_rulers_markers_box;
530
531         void location_changed (ARDOUR::Location *);
532         void location_flags_changed (ARDOUR::Location *, void *);
533         void refresh_location_display ();
534         void refresh_location_display_s (const PBD::PropertyChange&);
535         void refresh_location_display_internal (ARDOUR::Locations::LocationList&);
536         void add_new_location (ARDOUR::Location *);
537         void location_gone (ARDOUR::Location *);
538         void remove_marker (ArdourCanvas::Item&, GdkEvent*);
539         gint really_remove_marker (ARDOUR::Location* loc);
540         void goto_nth_marker (int nth);
541
542         uint32_t location_marker_color;
543         uint32_t location_range_color;
544         uint32_t location_loop_color;
545         uint32_t location_punch_color;
546         uint32_t location_cd_marker_color;
547
548         struct LocationMarkers {
549             Marker* start;
550             Marker* end;
551             bool    valid;
552
553             LocationMarkers () : start(0), end(0), valid (true) {}
554
555             ~LocationMarkers ();
556
557             void hide();
558             void show ();
559             void set_name (const std::string&);
560             void set_position (nframes64_t start, nframes64_t end = 0);
561             void set_color_rgba (uint32_t);
562         };
563
564         LocationMarkers  *find_location_markers (ARDOUR::Location *) const;
565         ARDOUR::Location* find_location_from_marker (Marker *, bool& is_start) const;
566         Marker* entered_marker;
567
568         typedef std::map<ARDOUR::Location*,LocationMarkers *> LocationMarkerMap;
569         LocationMarkerMap location_markers;
570
571         void hide_marker (ArdourCanvas::Item*, GdkEvent*);
572         void clear_marker_display ();
573         void mouse_add_new_marker (nframes64_t where, bool is_cd=false, bool is_xrun=false);
574         bool choose_new_marker_name(std::string &name);
575         void update_cd_marker_display ();
576         void ensure_cd_marker_updated (LocationMarkers * lam, ARDOUR::Location * location);
577
578         TimeAxisView*      clicked_axisview;
579         RouteTimeAxisView* clicked_routeview;
580         /** The last RegionView that was clicked on, or 0 if the last click was not
581          * on a RegionView.  This is set up by the canvas event handlers in
582          * editor_canvas_events.cc
583          */
584         RegionView*        clicked_regionview;
585         RegionSelection    latest_regionviews;
586         uint32_t           clicked_selection;
587         CrossfadeView*     clicked_crossfadeview;
588         ControlPoint*      clicked_control_point;
589
590         void sort_track_selection (TrackViewList* sel = 0);
591
592         void get_equivalent_regions (RegionView* rv, std::vector<RegionView*> &, PBD::PropertyID) const;
593         RegionSelection get_equivalent_regions (RegionSelection &, PBD::PropertyID) const;
594         void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*, PBD::PropertyID) const;
595
596         /* functions to be passed to mapover_tracks(), possibly with sigc::bind()-supplied arguments */
597
598         void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView *, std::vector<RegionView*>*) const;
599         void mapped_use_new_playlist (RouteTimeAxisView&, uint32_t, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
600         void mapped_use_copy_playlist (RouteTimeAxisView&, uint32_t, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
601         void mapped_clear_playlist (RouteTimeAxisView&, uint32_t);
602
603         /* end */
604
605         void button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type);
606         bool button_release_can_deselect;
607
608         void catch_vanishing_regionview (RegionView *);
609
610         void set_selected_track (TimeAxisView&, Selection::Operation op = Selection::Set, bool no_remove=false);
611         void select_all_tracks ();
612
613         bool set_selected_control_point_from_click (Selection::Operation op = Selection::Set, bool no_remove=false);
614         void set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool no_remove=false);
615         void set_selected_track_as_side_effect (bool force = false);
616         bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set, bool no_track_remove=false);
617
618         bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::weak_ptr<ARDOUR::Region>);
619         void collect_new_region_view (RegionView *);
620         void collect_and_select_new_region_view (RegionView *);
621
622         long select_range_around_region (RegionView *);
623
624         Gtk::Menu track_context_menu;
625         Gtk::Menu track_region_context_menu;
626         Gtk::Menu track_selection_context_menu;
627         Gtk::Menu track_crossfade_context_menu;
628
629         Gtk::MenuItem* region_edit_menu_split_item;
630         Gtk::MenuItem* region_edit_menu_split_multichannel_item;
631         Gtk::Menu * track_region_edit_playlist_menu;
632         Gtk::Menu * track_edit_playlist_submenu;
633         Gtk::Menu * track_selection_edit_playlist_submenu;
634
635         void popup_track_context_menu (int, int, ItemType, bool, nframes64_t);
636         Gtk::Menu* build_track_context_menu (nframes64_t);
637         Gtk::Menu* build_track_bus_context_menu (nframes64_t);
638         Gtk::Menu* build_track_region_context_menu (nframes64_t frame);
639         Gtk::Menu* build_track_crossfade_context_menu (nframes64_t);
640         Gtk::Menu* build_track_selection_context_menu (nframes64_t);
641         void add_dstream_context_items (Gtk::Menu_Helpers::MenuList&);
642         void add_bus_context_items (Gtk::Menu_Helpers::MenuList&);
643         void add_region_context_items (StreamView*, boost::shared_ptr<ARDOUR::Region>, Gtk::Menu_Helpers::MenuList&);
644         void add_crossfade_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Crossfade>, Gtk::Menu_Helpers::MenuList&, bool many);
645         void add_selection_context_items (Gtk::Menu_Helpers::MenuList&);
646
647         void handle_new_route (ARDOUR::RouteList&);
648         void timeaxisview_deleted (TimeAxisView *);
649
650         Gtk::HBox           global_hpacker;
651         Gtk::VBox           global_vpacker;
652         Gtk::VBox           vpacker;
653
654         Gdk::Cursor*          current_canvas_cursor;
655         void set_canvas_cursor ();
656         Gdk::Cursor* which_grabber_cursor ();
657
658         ArdourCanvas::Canvas* track_canvas;
659
660         ArdourCanvas::NoEventText* verbose_canvas_cursor;
661         bool                 verbose_cursor_visible;
662
663         void parameter_changed (std::string);
664
665         bool track_canvas_motion (GdkEvent*);
666
667         void set_verbose_canvas_cursor (const std::string &, double x, double y);
668         void set_verbose_canvas_cursor_text (const std::string &);
669         void show_verbose_canvas_cursor();
670
671         bool verbose_cursor_on; // so far unused
672
673         Gtk::EventBox             time_canvas_event_box;
674         Gtk::EventBox             track_canvas_event_box;
675         Gtk::EventBox             time_button_event_box;
676         Gtk::EventBox             ruler_label_event_box;
677
678         ArdourCanvas::Group      *minsec_group;
679         ArdourCanvas::Pixbuf     *logo_item;
680         ArdourCanvas::Group      *bbt_group;
681         ArdourCanvas::Group      *timecode_group;
682         ArdourCanvas::Group      *frame_group;
683         ArdourCanvas::Group      *tempo_group;
684         ArdourCanvas::Group      *meter_group;
685         ArdourCanvas::Group      *marker_group;
686         ArdourCanvas::Group      *range_marker_group;
687         ArdourCanvas::Group      *transport_marker_group;
688         ArdourCanvas::Group*      cd_marker_group;
689
690         ArdourCanvas::Group*      timebar_group;
691
692         /* These bars never need to be scrolled */
693         ArdourCanvas::Group*      meter_bar_group;
694         ArdourCanvas::Group*      tempo_bar_group;
695         ArdourCanvas::Group*      marker_bar_group;
696         ArdourCanvas::Group*      range_marker_bar_group;
697         ArdourCanvas::Group*      transport_marker_bar_group;
698         ArdourCanvas::Group*      cd_marker_bar_group;
699
700         /** The group containing all items that require horizontal scrolling. */
701         ArdourCanvas::Group* _background_group;
702         /*
703            The _master_group is the group containing all items
704            that require horizontal scrolling..
705            It is primarily used to separate canvas items
706            that require horizontal scrolling from those that do not.
707         */
708         ArdourCanvas::Group* _master_group;
709
710         /* The group containing all trackviews.  Only scrolled vertically. */
711         ArdourCanvas::Group* _trackview_group;
712
713         /* The group used for region motion.  Sits on top of _trackview_group */
714         ArdourCanvas::Group* _region_motion_group;
715
716         enum RulerType {
717                 ruler_metric_timecode = 0,
718                 ruler_metric_bbt = 1,
719                 ruler_metric_frames = 2,
720                 ruler_metric_minsec = 3,
721
722                 ruler_time_tempo = 4,
723                 ruler_time_meter = 5,
724                 ruler_time_marker = 6,
725                 ruler_time_range_marker = 7,
726                 ruler_time_transport_marker = 8,
727                 ruler_time_cd_marker = 9,
728         };
729
730         static GtkCustomMetric ruler_metrics[4];
731         Glib::RefPtr<Gtk::ToggleAction> ruler_timecode_action;
732         Glib::RefPtr<Gtk::ToggleAction> ruler_bbt_action;
733         Glib::RefPtr<Gtk::ToggleAction> ruler_samples_action;
734         Glib::RefPtr<Gtk::ToggleAction> ruler_minsec_action;
735         Glib::RefPtr<Gtk::ToggleAction> ruler_tempo_action;
736         Glib::RefPtr<Gtk::ToggleAction> ruler_meter_action;
737         Glib::RefPtr<Gtk::ToggleAction> ruler_marker_action;
738         Glib::RefPtr<Gtk::ToggleAction> ruler_range_action;
739         Glib::RefPtr<Gtk::ToggleAction> ruler_loop_punch_action;
740         Glib::RefPtr<Gtk::ToggleAction> ruler_cd_marker_action;
741         bool                            no_ruler_shown_update;
742
743         gint ruler_button_press (GdkEventButton*);
744         gint ruler_button_release (GdkEventButton*);
745         gint ruler_mouse_motion (GdkEventMotion*);
746         bool ruler_scroll (GdkEventScroll* event);
747
748         Gtk::Widget * ruler_grabbed_widget;
749
750         void initialize_rulers ();
751         void update_just_timecode ();
752         void compute_fixed_ruler_scale (); //calculates the RulerScale of the fixed rulers
753         void update_fixed_rulers ();
754         void update_tempo_based_rulers ();
755         void popup_ruler_menu (nframes64_t where = 0, ItemType type = RegionItem);
756         void update_ruler_visibility ();
757         void set_ruler_visible (RulerType, bool);
758         void toggle_ruler_visibility (RulerType rt);
759         void ruler_toggled (int);
760         gint ruler_label_button_release (GdkEventButton*);
761         void store_ruler_visibility ();
762         void restore_ruler_visibility ();
763
764         static gint _metric_get_timecode (GtkCustomRulerMark **, gdouble, gdouble, gint);
765         static gint _metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
766         static gint _metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
767         static gint _metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
768
769         enum MinsecRulerScale {
770                 minsec_show_seconds,
771                 minsec_show_minutes,
772                 minsec_show_hours,
773                 minsec_show_frames
774         };
775
776         MinsecRulerScale minsec_ruler_scale;
777
778         nframes_t minsec_mark_interval;
779         gint minsec_mark_modulo;
780         gint minsec_nmarks;
781         void set_minsec_ruler_scale (gdouble lower, gdouble upper);
782
783         enum TimecodeRulerScale {
784                 timecode_show_bits,
785                 timecode_show_frames,
786                 timecode_show_seconds,
787                 timecode_show_minutes,
788                 timecode_show_hours
789         };
790
791         TimecodeRulerScale timecode_ruler_scale;
792
793         nframes_t timecode_mark_interval;
794         gint timecode_mark_modulo;
795         gint timecode_nmarks;
796         void set_timecode_ruler_scale (gdouble lower, gdouble upper);
797
798         enum BBTRulerScale {
799                 bbt_over,
800                 bbt_show_64,
801                 bbt_show_16,
802                 bbt_show_4,
803                 bbt_show_1,
804                 bbt_show_beats,
805                 bbt_show_ticks,
806                 bbt_show_ticks_detail,
807                 bbt_show_ticks_super_detail
808         };
809
810         BBTRulerScale bbt_ruler_scale;
811
812         uint32_t bbt_bars;
813         gint bbt_nmarks;
814         uint32_t bbt_bar_helper_on;
815         uint32_t bbt_accent_modulo;
816         void compute_bbt_ruler_scale (nframes64_t lower, nframes64_t upper);
817
818         gint metric_get_timecode (GtkCustomRulerMark **, gdouble, gdouble, gint);
819         gint metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
820         gint metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
821         gint metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
822
823         Gtk::Widget        *_ruler_separator;
824         GtkWidget          *_timecode_ruler;
825         GtkWidget          *_bbt_ruler;
826         GtkWidget          *_frames_ruler;
827         GtkWidget          *_minsec_ruler;
828         Gtk::Widget        *timecode_ruler;
829         Gtk::Widget        *bbt_ruler;
830         Gtk::Widget        *frames_ruler;
831         Gtk::Widget        *minsec_ruler;
832         static Editor      *ruler_editor;
833
834         static const double timebar_height;
835         guint32 visible_timebars;
836         gdouble canvas_timebars_vsize;
837         gdouble get_canvas_timebars_vsize () const { return canvas_timebars_vsize; }
838         Gtk::Menu          *editor_ruler_menu;
839
840         ArdourCanvas::SimpleRect* tempo_bar;
841         ArdourCanvas::SimpleRect* meter_bar;
842         ArdourCanvas::SimpleRect* marker_bar;
843         ArdourCanvas::SimpleRect* range_marker_bar;
844         ArdourCanvas::SimpleRect* transport_marker_bar;
845         ArdourCanvas::SimpleRect* cd_marker_bar;
846
847         Gtk::Label  minsec_label;
848         Gtk::Label  bbt_label;
849         Gtk::Label  timecode_label;
850         Gtk::Label  frame_label;
851         Gtk::Label  tempo_label;
852         Gtk::Label  meter_label;
853         Gtk::Label  mark_label;
854         Gtk::Label  range_mark_label;
855         Gtk::Label  transport_mark_label;
856         Gtk::Label  cd_mark_label;
857
858         Gtk::VBox          time_button_vbox;
859         Gtk::HBox          time_button_hbox;
860
861         friend class EditorCursor;
862
863         EditorCursor*        playhead_cursor;
864         ArdourCanvas::Group* cursor_group;
865
866         nframes64_t get_region_boundary (nframes64_t pos, int32_t dir, bool with_selection, bool only_onscreen);
867
868         void    cursor_to_region_boundary (bool with_selection, int32_t dir);
869         void    cursor_to_next_region_boundary (bool with_selection);
870         void    cursor_to_previous_region_boundary (bool with_selection);
871         void    cursor_to_next_region_point (EditorCursor*, ARDOUR::RegionPoint);
872         void    cursor_to_previous_region_point (EditorCursor*, ARDOUR::RegionPoint);
873         void    cursor_to_region_point (EditorCursor*, ARDOUR::RegionPoint, int32_t dir);
874         void    cursor_to_selection_start (EditorCursor *);
875         void    cursor_to_selection_end   (EditorCursor *);
876
877         void    selected_marker_to_region_boundary (bool with_selection, int32_t dir);
878         void    selected_marker_to_next_region_boundary (bool with_selection);
879         void    selected_marker_to_previous_region_boundary (bool with_selection);
880         void    selected_marker_to_next_region_point (ARDOUR::RegionPoint);
881         void    selected_marker_to_previous_region_point (ARDOUR::RegionPoint);
882         void    selected_marker_to_region_point (ARDOUR::RegionPoint, int32_t dir);
883         void    selected_marker_to_selection_start ();
884         void    selected_marker_to_selection_end   ();
885
886         void    select_all_selectables_using_cursor (EditorCursor *, bool);
887         void    select_all_selectables_using_edit (bool);
888         void    select_all_selectables_between (bool within);
889         void    select_range_between ();
890
891         boost::shared_ptr<ARDOUR::Region> find_next_region (nframes64_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
892         nframes64_t find_next_region_boundary (nframes64_t, int32_t dir, const TrackViewList&);
893
894         std::vector<nframes64_t> region_boundary_cache;
895         void build_region_boundary_cache ();
896
897         Gtk::HBox           top_hbox;
898         Gtk::HBox           bottom_hbox;
899
900         Gtk::Table          edit_packer;
901
902         Gtk::Adjustment     vertical_adjustment;
903         Gtk::Adjustment     horizontal_adjustment;
904
905         Gtk::Layout         controls_layout;
906         bool control_layout_scroll (GdkEventScroll* ev);
907         void controls_layout_size_request (Gtk::Requisition*);
908         sigc::connection controls_layout_size_request_connection;
909
910         void horizontal_scroll_left ();
911         void horizontal_scroll_right ();
912
913         double _canvas_width;
914         double _canvas_height;
915         double full_canvas_height;
916
917         bool track_canvas_map_handler (GdkEventAny*);
918
919         gint edit_controls_button_release (GdkEventButton*);
920         Gtk::Menu *edit_controls_left_menu;
921         Gtk::Menu *edit_controls_right_menu;
922
923         Gtk::VBox           ruler_label_vbox;
924         Gtk::VBox           track_canvas_vbox;
925         Gtk::VBox           time_canvas_vbox;
926         Gtk::VBox           edit_controls_vbox;
927         Gtk::HBox           edit_controls_hbox;
928
929         void control_scroll (float);
930         void access_action (std::string,std::string);
931         bool deferred_control_scroll (nframes64_t);
932         sigc::connection control_scroll_connection;
933
934         gdouble get_trackview_group_vertical_offset () const { return vertical_adjustment.get_value () - canvas_timebars_vsize;}
935
936         ArdourCanvas::Group* get_background_group () const { return _background_group; }
937         ArdourCanvas::Group* get_trackview_group () const { return _trackview_group; }
938         double last_trackview_group_vertical_offset;
939         void tie_vertical_scrolling ();
940         void scroll_canvas_horizontally ();
941         void scroll_canvas_vertically ();
942
943         struct VisualChange {
944                 enum Type {
945                         TimeOrigin = 0x1,
946                         ZoomLevel = 0x2,
947                         YOrigin = 0x4
948                 };
949
950                 Type pending;
951                 nframes64_t time_origin;
952                 double frames_per_unit;
953                 double y_origin;
954
955                 int idle_handler_id;
956
957                 VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), frames_per_unit (0), idle_handler_id (-1) {}
958                 void add (Type t) {
959                         pending = Type (pending | t);
960                 }
961         };
962
963
964         VisualChange pending_visual_change;
965
966         static int _idle_visual_changer (void *arg);
967         int idle_visual_changer ();
968
969         void queue_visual_change (nframes64_t);
970         void queue_visual_change (double);
971         void queue_visual_change_y (double);
972         void ensure_visual_change_idle_handler ();
973
974         void session_range_location_changed (ARDOUR::Location*);
975
976         /* track views */
977         TrackViewList track_views;
978         std::pair<TimeAxisView*, ARDOUR::layer_t> trackview_by_y_position (double);
979         TimeAxisView* axis_view_from_route (boost::shared_ptr<ARDOUR::Route>) const;
980
981         TrackViewList get_tracks_for_range_action () const;
982
983         static Gdk::Cursor* cross_hair_cursor;
984         static Gdk::Cursor* trimmer_cursor;
985         static Gdk::Cursor* selector_cursor;
986         static Gdk::Cursor* grabber_cursor;
987         static Gdk::Cursor* grabber_edit_point_cursor;
988         static Gdk::Cursor* zoom_cursor;
989         static Gdk::Cursor* time_fx_cursor;
990         static Gdk::Cursor* fader_cursor;
991         static Gdk::Cursor* speaker_cursor;
992         static Gdk::Cursor* midi_pencil_cursor;
993         static Gdk::Cursor* midi_select_cursor;
994         static Gdk::Cursor* midi_resize_cursor;
995         static Gdk::Cursor* midi_erase_cursor;
996         static Gdk::Cursor* wait_cursor;
997         static Gdk::Cursor* timebar_cursor;
998         static Gdk::Cursor* transparent_cursor;
999
1000         static void build_cursors ();
1001
1002         sigc::connection super_rapid_screen_update_connection;
1003         nframes64_t last_update_frame;
1004         void center_screen_internal (nframes64_t, float);
1005
1006         void super_rapid_screen_update ();
1007
1008         void session_going_away ();
1009
1010         nframes64_t cut_buffer_start;
1011         nframes64_t cut_buffer_length;
1012
1013         bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
1014         bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1015         bool button_press_handler_1 (ArdourCanvas::Item *, GdkEvent *, ItemType);
1016         bool button_press_handler_2 (ArdourCanvas::Item *, GdkEvent *, ItemType);
1017         bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1018         bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false);
1019         bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1020         bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1021
1022         /* KEYMAP HANDLING */
1023
1024         void register_actions ();
1025
1026         int ensure_cursor (nframes64_t* pos);
1027
1028         void cut_copy (Editing::CutCopyOp);
1029         bool can_cut_copy () const;
1030         void cut_copy_points (Editing::CutCopyOp);
1031         void cut_copy_regions (Editing::CutCopyOp, RegionSelection&);
1032         void cut_copy_ranges (Editing::CutCopyOp);
1033         void cut_copy_midi (Editing::CutCopyOp);
1034
1035         void mouse_paste ();
1036         void paste_internal (nframes64_t position, float times);
1037
1038         /* EDITING OPERATIONS */
1039
1040         void reset_point_selection ();
1041         void toggle_region_mute ();
1042         void toggle_region_lock ();
1043         void toggle_region_opaque ();
1044         void toggle_record_enable ();
1045         void set_region_lock_style (ARDOUR::Region::PositionLockStyle);
1046         void raise_region ();
1047         void raise_region_to_top ();
1048         void lower_region ();
1049         void lower_region_to_bottom ();
1050         void split_regions_at (nframes64_t, RegionSelection&);
1051         void split_region_at_transients ();
1052         void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret);
1053         void crop_region_to_selection ();
1054         void crop_region_to (nframes64_t start, nframes64_t end);
1055         void set_sync_point (nframes64_t, const RegionSelection&);
1056         void set_region_sync_from_edit_point ();
1057         void remove_region_sync();
1058         void align_selection (ARDOUR::RegionPoint, nframes64_t position, const RegionSelection&);
1059         void align_selection_relative (ARDOUR::RegionPoint point, nframes64_t position, const RegionSelection&);
1060         void align_region (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes64_t position);
1061         void align_region_internal (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes64_t position);
1062         void remove_selected_regions ();
1063         void remove_clicked_region ();
1064         void edit_region ();
1065         void show_midi_list_editor ();
1066         void rename_region ();
1067         void duplicate_some_regions (RegionSelection&, float times);
1068         void duplicate_selection (float times);
1069         void region_fill_selection ();
1070
1071         void region_fill_track ();
1072         void audition_playlist_region_standalone (boost::shared_ptr<ARDOUR::Region>);
1073         void audition_playlist_region_via_route (boost::shared_ptr<ARDOUR::Region>, ARDOUR::Route&);
1074         void split_multichannel_region();
1075         void reverse_region ();
1076         void strip_region_silence ();
1077         void normalize_region ();
1078         double _last_normalization_value;
1079         void reset_region_scale_amplitude ();
1080         void adjust_region_scale_amplitude (bool up);
1081         void quantize_region ();
1082
1083         void do_insert_time ();
1084         void insert_time (nframes64_t, nframes64_t, Editing::InsertTimeOption, bool, bool, bool);
1085
1086         void tab_to_transient (bool forward);
1087
1088         void use_region_as_bar ();
1089         void use_range_as_bar ();
1090
1091         void define_one_bar (nframes64_t start, nframes64_t end);
1092
1093         void audition_region_from_region_list ();
1094         void hide_region_from_region_list ();
1095         void show_region_in_region_list ();
1096
1097         void align (ARDOUR::RegionPoint);
1098         void align_relative (ARDOUR::RegionPoint);
1099         void naturalize ();
1100
1101         void reset_focus ();
1102
1103         void split ();
1104
1105         void cut ();
1106         void copy ();
1107         void paste (float times);
1108
1109         int  get_prefix (float&, bool&);
1110
1111         void keyboard_paste ();
1112         void keyboard_insert_region_list_selection ();
1113
1114         void region_from_selection ();
1115         void create_region_from_selection (std::vector<boost::shared_ptr<ARDOUR::Region> >&);
1116
1117         void play_from_start ();
1118         void play_from_edit_point ();
1119         void play_from_edit_point_and_return ();
1120         void play_selected_region ();
1121         void play_edit_range ();
1122         void loop_selected_region ();
1123         void play_location (ARDOUR::Location&);
1124         void loop_location (ARDOUR::Location&);
1125
1126         void temporal_zoom_selection ();
1127         void temporal_zoom_region (bool both_axes);
1128         void zoom_to_region (bool both_axes);
1129         void temporal_zoom_session ();
1130         void temporal_zoom (gdouble scale);
1131         void temporal_zoom_by_frame (nframes64_t start, nframes64_t end, const std::string & op);
1132         void temporal_zoom_to_frame (bool coarser, nframes64_t frame);
1133
1134         void amplitude_zoom (gdouble scale);
1135         void amplitude_zoom_step (bool in);
1136
1137         void insert_region_list_drag (boost::shared_ptr<ARDOUR::Region>, int x, int y);
1138         void insert_region_list_selection (float times);
1139
1140         void insert_route_list_drag (boost::shared_ptr<ARDOUR::Route>, int x, int y);
1141
1142         /* import & embed */
1143
1144         void add_external_audio_action (Editing::ImportMode);
1145         void external_audio_dialog ();
1146         void session_import_dialog ();
1147
1148         int  check_whether_and_how_to_import(std::string, bool all_or_nothing = true);
1149         bool check_multichannel_status (const std::vector<Glib::ustring>& paths);
1150
1151         SoundFileOmega* sfbrowser;
1152
1153         void bring_in_external_audio (Editing::ImportMode mode,  nframes64_t& pos);
1154
1155         bool  idle_drop_paths  (std::vector<Glib::ustring> paths, nframes64_t frame, double ypos);
1156         void  drop_paths_part_two  (const std::vector<Glib::ustring>& paths, nframes64_t frame, double ypos);
1157
1158         int  import_sndfiles (std::vector<Glib::ustring> paths, Editing::ImportMode mode,  ARDOUR::SrcQuality, nframes64_t& pos,
1159                               int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool);
1160         int  embed_sndfiles (std::vector<Glib::ustring> paths, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode,
1161                              nframes64_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&);
1162
1163         int add_sources (std::vector<Glib::ustring> paths, ARDOUR::SourceList& sources, nframes64_t& pos, Editing::ImportMode,
1164                          int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool add_channel_suffix);
1165         int finish_bringing_in_material (boost::shared_ptr<ARDOUR::Region> region, uint32_t, uint32_t,  nframes64_t& pos, Editing::ImportMode mode,
1166                                       boost::shared_ptr<ARDOUR::Track>& existing_track);
1167
1168         boost::shared_ptr<ARDOUR::AudioTrack> get_nth_selected_audio_track (int nth) const;
1169         boost::shared_ptr<ARDOUR::MidiTrack> get_nth_selected_midi_track (int nth) const;
1170
1171         ARDOUR::InterThreadInfo* current_interthread_info;
1172
1173         AnalysisWindow* analysis_window;
1174
1175         /* import specific info */
1176
1177         struct EditorImportStatus : public ARDOUR::ImportStatus {
1178             Editing::ImportMode mode;
1179             nframes64_t pos;
1180             int target_tracks;
1181             int target_regions;
1182             boost::shared_ptr<ARDOUR::Track> track;
1183             bool replace;
1184         };
1185
1186         EditorImportStatus import_status;
1187         static void *_import_thread (void *);
1188         void* import_thread ();
1189         void finish_import ();
1190
1191         /* to support this ... */
1192
1193         void import_audio (bool as_tracks);
1194         void do_import (std::vector<Glib::ustring> paths, bool split, bool as_tracks);
1195
1196         void move_to_start ();
1197         void move_to_end ();
1198         void goto_frame ();
1199         void center_playhead ();
1200         void center_edit_point ();
1201         void edit_cursor_backward ();
1202         void edit_cursor_forward ();
1203         void playhead_forward_to_grid ();
1204         void playhead_backward_to_grid ();
1205         void playhead_backward ();
1206         void playhead_forward ();
1207         void scroll_playhead (bool forward);
1208         void scroll_backward (float pages=0.8f);
1209         void scroll_forward (float pages=0.8f);
1210         void scroll_tracks_down ();
1211         void scroll_tracks_up ();
1212         void delete_sample_forward ();
1213         void delete_sample_backward ();
1214         void delete_screen ();
1215         void search_backwards ();
1216         void search_forwards ();
1217         void set_mark ();
1218         void clear_markers ();
1219         void clear_ranges ();
1220         void clear_locations ();
1221         void unhide_markers ();
1222         void unhide_ranges ();
1223         void jump_forward_to_mark ();
1224         void jump_backward_to_mark ();
1225         void cursor_align (bool playhead_to_edit);
1226
1227         void remove_last_capture ();
1228         void select_all_selectables_using_time_selection ();
1229         void select_all_selectables_using_loop();
1230         void select_all_selectables_using_punch();
1231         void set_selection_from_range (ARDOUR::Location&);
1232         void set_selection_from_punch ();
1233         void set_selection_from_loop ();
1234         void set_selection_from_region ();
1235
1236         void add_location_mark (nframes64_t where);
1237         void add_location_from_audio_region ();
1238         void add_locations_from_audio_region ();
1239         void add_location_from_selection ();
1240         void set_loop_from_selection (bool play);
1241         void set_punch_from_selection ();
1242         void set_punch_from_region ();
1243
1244         void set_loop_from_edit_range (bool play);
1245         void set_loop_from_region (bool play);
1246         void set_punch_from_edit_range ();
1247
1248         void set_loop_range (nframes64_t start, nframes64_t end, std::string cmd);
1249         void set_punch_range (nframes64_t start, nframes64_t end, std::string cmd);
1250
1251         void add_location_from_playhead_cursor ();
1252         bool select_new_marker;
1253
1254         void reverse_selection ();
1255         void edit_envelope ();
1256
1257         double last_scrub_x;
1258         int scrubbing_direction;
1259         int scrub_reversals;
1260         int scrub_reverse_distance;
1261         void scrub (nframes64_t, double);
1262
1263         void keyboard_selection_begin ();
1264         void keyboard_selection_finish (bool add);
1265         bool have_pending_keyboard_selection;
1266         nframes64_t pending_keyboard_selection_start;
1267
1268         boost::shared_ptr<ARDOUR::Region> select_region_for_operation (int dir, TimeAxisView **tv);
1269         void extend_selection_to_end_of_region (bool next);
1270         void extend_selection_to_start_of_region (bool previous);
1271
1272         Editing::SnapType _snap_type;
1273         Editing::SnapMode _snap_mode;
1274
1275         /// Snap threshold in pixels
1276         double snap_threshold;
1277
1278         bool ignore_gui_changes;
1279
1280         DragManager* _drags;
1281
1282         void escape ();
1283
1284         Gtk::Menu fade_context_menu;
1285         void popup_fade_context_menu (int, int, ArdourCanvas::Item*, ItemType);
1286
1287         void set_fade_in_shape (ARDOUR::AudioRegion::FadeShape);
1288         void set_fade_out_shape (ARDOUR::AudioRegion::FadeShape);
1289
1290         void set_fade_length (bool in);
1291         void toggle_fade_active (bool in);
1292         void set_fade_in_active (bool);
1293         void set_fade_out_active (bool);
1294
1295         std::set<boost::shared_ptr<ARDOUR::Playlist> > motion_frozen_playlists;
1296
1297         bool _dragging_playhead;
1298         bool _dragging_edit_point;
1299
1300         void marker_drag_motion_callback (GdkEvent*);
1301         void marker_drag_finished_callback (GdkEvent*);
1302
1303         gint mouse_rename_region (ArdourCanvas::Item*, GdkEvent*);
1304
1305         void add_region_drag (ArdourCanvas::Item*, GdkEvent*, RegionView*);
1306         void start_create_region_grab (ArdourCanvas::Item*, GdkEvent*);
1307         void add_region_copy_drag (ArdourCanvas::Item*, GdkEvent*, RegionView*);
1308         void add_region_brush_drag (ArdourCanvas::Item*, GdkEvent*, RegionView*);
1309         void start_selection_grab (ArdourCanvas::Item*, GdkEvent*);
1310
1311         void region_view_item_click (AudioRegionView&, GdkEventButton*);
1312
1313         void remove_gain_control_point (ArdourCanvas::Item*, GdkEvent*);
1314         void remove_control_point (ArdourCanvas::Item*, GdkEvent*);
1315
1316         void mouse_brush_insert_region (RegionView*, nframes64_t pos);
1317         void brush (nframes64_t);
1318
1319         void show_verbose_time_cursor (nframes64_t frame, double offset = 0, double xpos=-1, double ypos=-1);
1320         void show_verbose_duration_cursor (nframes64_t start, nframes64_t end, double offset = 0, double xpos=-1, double ypos=-1);
1321         double clamp_verbose_cursor_x (double);
1322         double clamp_verbose_cursor_y (double);
1323
1324         /* Canvas event handlers */
1325
1326         bool canvas_control_point_event (GdkEvent* event,ArdourCanvas::Item*, ControlPoint*);
1327         bool canvas_line_event (GdkEvent* event,ArdourCanvas::Item*, AutomationLine*);
1328         bool canvas_selection_rect_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1329         bool canvas_selection_start_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1330         bool canvas_selection_end_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1331         bool canvas_crossfade_view_event (GdkEvent* event,ArdourCanvas::Item*, CrossfadeView*);
1332         bool canvas_fade_in_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1333         bool canvas_fade_in_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1334         bool canvas_fade_out_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1335         bool canvas_fade_out_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1336
1337
1338         // These variables are used to detect a feedback loop and break it to avoid a gui hang
1339 private:
1340         ArdourCanvas::Item *last_item_entered;
1341         int last_item_entered_n;
1342
1343 public:
1344         bool canvas_region_view_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1345         bool canvas_frame_handle_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1346         bool canvas_region_view_name_highlight_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1347         bool canvas_region_view_name_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1348         bool canvas_stream_view_event (GdkEvent* event,ArdourCanvas::Item*, RouteTimeAxisView*);
1349         bool canvas_marker_event (GdkEvent* event,ArdourCanvas::Item*, Marker*);
1350         bool canvas_zoom_rect_event (GdkEvent* event,ArdourCanvas::Item*);
1351         bool canvas_tempo_marker_event (GdkEvent* event,ArdourCanvas::Item*, TempoMarker*);
1352         bool canvas_meter_marker_event (GdkEvent* event,ArdourCanvas::Item*, MeterMarker*);
1353         bool canvas_automation_track_event(GdkEvent* event, ArdourCanvas::Item*, AutomationTimeAxisView*) ;
1354         bool canvas_note_event (GdkEvent* event, ArdourCanvas::Item*);
1355
1356         bool canvas_tempo_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1357         bool canvas_meter_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1358         bool canvas_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1359         bool canvas_range_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1360         bool canvas_transport_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1361         bool canvas_cd_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1362
1363         bool canvas_imageframe_item_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1364         bool canvas_imageframe_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameTimeAxis*);
1365         bool canvas_imageframe_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1366         bool canvas_imageframe_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1367         bool canvas_marker_time_axis_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerTimeAxis*);
1368         bool canvas_markerview_item_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1369         bool canvas_markerview_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1370         bool canvas_markerview_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1371
1372   private:
1373         friend class DragManager;
1374         friend class EditorRouteGroups;
1375         friend class EditorRegions;
1376
1377         /* non-public event handlers */
1378
1379         bool canvas_playhead_cursor_event (GdkEvent* event, ArdourCanvas::Item*);
1380         bool track_canvas_scroll (GdkEventScroll* event);
1381
1382         bool track_canvas_scroll_event (GdkEventScroll* event);
1383         bool track_canvas_button_press_event (GdkEventButton* event);
1384         bool track_canvas_button_release_event (GdkEventButton* event);
1385         bool track_canvas_motion_notify_event (GdkEventMotion* event);
1386
1387         Gtk::Allocation canvas_allocation;
1388         void track_canvas_allocate (Gtk::Allocation alloc);
1389         bool track_canvas_size_allocated ();
1390         bool track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const &, int, int, guint);
1391
1392         void set_playhead_cursor ();
1393
1394         void kbd_driver (sigc::slot<void,GdkEvent*>, bool use_track_canvas = true, bool use_time_canvas = true, bool can_select = true);
1395         void kbd_mute_unmute_region ();
1396         void kbd_brush ();
1397
1398         void kbd_do_brush (GdkEvent*);
1399         void kbd_do_audition (GdkEvent*);
1400
1401         void handle_new_duration ();
1402         void initialize_canvas ();
1403
1404         /* display control */
1405
1406         bool _show_measures;
1407         /// true if the editor should follow the playhead, otherwise false
1408         bool _follow_playhead;
1409         /// true if we scroll the tracks rather than the playhead
1410         bool _stationary_playhead;
1411
1412         ARDOUR::TempoMap::BBTPointList *current_bbt_points;
1413
1414         TempoLines* tempo_lines;
1415
1416         ArdourCanvas::Group* time_line_group;
1417
1418         void hide_measures ();
1419         void draw_measures ();
1420         bool redraw_measures ();
1421
1422         void new_tempo_section ();
1423
1424         void mouse_add_new_tempo_event (nframes64_t where);
1425         void mouse_add_new_meter_event (nframes64_t where);
1426
1427         void remove_tempo_marker (ArdourCanvas::Item*);
1428         void remove_meter_marker (ArdourCanvas::Item*);
1429         gint real_remove_tempo_marker (ARDOUR::TempoSection*);
1430         gint real_remove_meter_marker (ARDOUR::MeterSection*);
1431
1432         void edit_tempo_section (ARDOUR::TempoSection*);
1433         void edit_meter_section (ARDOUR::MeterSection*);
1434         void edit_tempo_marker (ArdourCanvas::Item*);
1435         void edit_meter_marker (ArdourCanvas::Item*);
1436         void edit_control_point (ArdourCanvas::Item*);
1437
1438         void marker_menu_edit ();
1439         void marker_menu_remove ();
1440         void marker_menu_rename ();
1441         void marker_menu_lock (bool yn);
1442         void marker_menu_hide ();
1443         void marker_menu_loop_range ();
1444         void marker_menu_select_all_selectables_using_range ();
1445         void marker_menu_select_using_range ();
1446         void marker_menu_separate_regions_using_location ();
1447         void marker_menu_play_from ();
1448         void marker_menu_play_range ();
1449         void marker_menu_set_playhead ();
1450         void marker_menu_set_from_playhead ();
1451         void marker_menu_set_from_selection ();
1452         void marker_menu_range_to_next ();
1453         void new_transport_marker_menu_set_loop ();
1454         void new_transport_marker_menu_set_punch ();
1455         void update_loop_range_view (bool visibility=false);
1456         void update_punch_range_view (bool visibility=false);
1457         void new_transport_marker_menu_popdown ();
1458         void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1459         void tm_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1460         void transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1461         void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1462         void build_range_marker_menu (bool loop_or_punch);
1463         void build_marker_menu (bool);
1464         void build_tm_marker_menu ();
1465         void build_new_transport_marker_menu ();
1466
1467         Gtk::Menu* tm_marker_menu;
1468         Gtk::Menu* marker_menu;
1469         Gtk::Menu* session_range_marker_menu;
1470         Gtk::Menu* range_marker_menu;
1471         Gtk::Menu* transport_marker_menu;
1472         Gtk::Menu* new_transport_marker_menu;
1473         Gtk::Menu* cd_marker_menu;
1474         ArdourCanvas::Item* marker_menu_item;
1475
1476         typedef std::list<Marker*> Marks;
1477         Marks metric_marks;
1478
1479         void remove_metric_marks ();
1480         void draw_metric_marks (const ARDOUR::Metrics& metrics);
1481
1482         void compute_current_bbt_points (nframes_t left, nframes_t right);
1483         void tempo_map_changed (const PBD::PropertyChange&);
1484         void redisplay_tempo (bool immediate_redraw);
1485
1486         uint32_t bbt_beat_subdivision;
1487
1488         /* toolbar */
1489
1490         Gtk::ToggleButton editor_mixer_button;
1491         Gtk::ToggleButton editor_list_button;
1492         void editor_mixer_button_toggled ();
1493         void editor_list_button_toggled ();
1494
1495         AudioClock               zoom_range_clock;
1496         Gtk::Button              zoom_in_button;
1497         Gtk::Button              zoom_out_button;
1498         Gtk::Button              zoom_out_full_button;
1499         Gtk::Button              zoom_onetoone_button;
1500
1501         Gtk::Button              tav_expand_button;
1502         Gtk::Button              tav_shrink_button;
1503
1504         Gtk::VBox                toolbar_clock_vbox;
1505         Gtk::VBox                toolbar_selection_clock_vbox;
1506         Gtk::Table               toolbar_selection_clock_table;
1507         Gtk::Label               toolbar_selection_cursor_label;
1508
1509         Gtkmm2ext::TearOff*      _mouse_mode_tearoff;
1510         Gtk::ToggleButton         mouse_select_button;
1511         Gtk::ToggleButton         mouse_move_button;
1512         Gtk::ToggleButton         mouse_gain_button;
1513         Gtk::ToggleButton         mouse_zoom_button;
1514         Gtk::ToggleButton         mouse_timefx_button;
1515         Gtk::ToggleButton         mouse_audition_button;
1516         Gtk::ToggleButton         join_object_range_button;
1517
1518         void                     mouse_mode_toggled (Editing::MouseMode m);
1519         bool                     ignore_mouse_mode_toggle;
1520
1521         Gtk::ToggleButton        internal_edit_button;
1522         void                     toggle_internal_editing ();
1523
1524         gint                     mouse_select_button_release (GdkEventButton*);
1525
1526         Gtk::VBox                automation_box;
1527         Gtk::Button              automation_mode_button;
1528         Gtk::ToggleButton        global_automation_button;
1529
1530         Gtk::ComboBoxText edit_mode_selector;
1531         Gtk::VBox         edit_mode_box;
1532
1533         void set_edit_mode (ARDOUR::EditMode);
1534         void cycle_edit_mode ();
1535         void edit_mode_selection_done ();
1536
1537         Gtk::ComboBoxText snap_type_selector;
1538         Gtk::ComboBoxText snap_mode_selector;
1539         Gtk::HBox         snap_box;
1540
1541         std::vector<std::string> snap_type_strings;
1542         std::vector<std::string> snap_mode_strings;
1543
1544         void snap_type_selection_done ();
1545         void snap_mode_selection_done ();
1546         void snap_mode_chosen (Editing::SnapMode);
1547         void snap_type_chosen (Editing::SnapType);
1548
1549         Glib::RefPtr<Gtk::RadioAction> snap_type_action (Editing::SnapType);
1550         Glib::RefPtr<Gtk::RadioAction> snap_mode_action (Editing::SnapMode);
1551
1552         Gtk::ComboBoxText zoom_focus_selector;
1553         Gtk::VBox         zoom_focus_box;
1554
1555         std::vector<std::string> zoom_focus_strings;
1556
1557         void zoom_focus_selection_done ();
1558         void zoom_focus_chosen (Editing::ZoomFocus);
1559
1560         Glib::RefPtr<Gtk::RadioAction> zoom_focus_action (Editing::ZoomFocus);
1561
1562         Gtk::HBox           zoom_box;
1563         Gtk::HBox           track_zoom_box;
1564         Gtk::VBox           zoom_vbox;
1565
1566         void                zoom_adjustment_changed();
1567
1568         void setup_toolbar ();
1569
1570         void setup_tooltips ();
1571
1572         Gtkmm2ext::TearOff*     _tools_tearoff;
1573         Gtk::HBox                toolbar_hbox;
1574         Gtk::EventBox            toolbar_base;
1575         Gtk::Frame               toolbar_frame;
1576
1577         /* midi toolbar */
1578
1579         Gtk::HBox                panic_box;
1580         Gtk::Button              midi_panic_button;
1581         Gtk::ToggleButton        midi_sound_notes;
1582         void                     midi_panic ();
1583         bool                     sound_notes () const { return midi_sound_notes.get_active(); }
1584
1585         void setup_midi_toolbar ();
1586
1587         /* selection process */
1588
1589         Selection* selection;
1590         Selection* cut_buffer;
1591
1592         void time_selection_changed ();
1593         void track_selection_changed ();
1594         void region_selection_changed ();
1595         sigc::connection editor_regions_selection_changed_connection;
1596         void sensitize_the_right_region_actions (bool have_selected_regions);
1597         void point_selection_changed ();
1598         void marker_selection_changed ();
1599
1600         void cancel_selection ();
1601
1602         void region_selection_op (void (ARDOUR::Region::*pmf)(void));
1603         void region_selection_op (void (ARDOUR::Region::*pmf)(void*), void*);
1604         void region_selection_op (void (ARDOUR::Region::*pmf)(bool), bool);
1605
1606         bool audio_region_selection_covers (nframes64_t where);
1607
1608         /* transport range select process */
1609
1610         ArdourCanvas::SimpleRect*  cd_marker_bar_drag_rect;
1611         ArdourCanvas::SimpleRect*  range_bar_drag_rect;
1612         ArdourCanvas::SimpleRect*  transport_bar_drag_rect;
1613
1614 #ifdef GTKOSX
1615         ArdourCanvas::SimpleRect     *bogus_background_rect;
1616 #endif
1617         ArdourCanvas::SimpleRect     *transport_bar_range_rect;
1618         ArdourCanvas::SimpleRect     *transport_bar_preroll_rect;
1619         ArdourCanvas::SimpleRect     *transport_bar_postroll_rect;
1620         ArdourCanvas::SimpleRect     *transport_loop_range_rect;
1621         ArdourCanvas::SimpleRect     *transport_punch_range_rect;
1622         ArdourCanvas::SimpleLine     *transport_punchin_line;
1623         ArdourCanvas::SimpleLine     *transport_punchout_line;
1624         ArdourCanvas::SimpleRect     *transport_preroll_rect;
1625         ArdourCanvas::SimpleRect     *transport_postroll_rect;
1626
1627         ARDOUR::Location*  transport_loop_location();
1628         ARDOUR::Location*  transport_punch_location();
1629
1630         ARDOUR::Location   *temp_location;
1631
1632         /* object rubberband select process */
1633
1634         bool select_all_within (nframes64_t, nframes64_t, double, double, TrackViewList const &, Selection::Operation op);
1635
1636         ArdourCanvas::SimpleRect   *rubberband_rect;
1637
1638         /* mouse zoom process */
1639
1640         ArdourCanvas::SimpleRect   *zoom_rect;
1641         void reposition_zoom_rect (nframes64_t start, nframes64_t end);
1642
1643         EditorRouteGroups* _route_groups;
1644         EditorRoutes* _routes;
1645         EditorRegions* _regions;
1646         EditorSnapshots* _snapshots;
1647         EditorLocations* _locations;
1648
1649         /* diskstream/route display management */
1650         Glib::RefPtr<Gdk::Pixbuf> rec_enabled_icon;
1651         Glib::RefPtr<Gdk::Pixbuf> rec_disabled_icon;
1652
1653         Glib::RefPtr<Gtk::TreeSelection> route_display_selection;
1654
1655         bool sync_track_view_list_and_routes ();
1656
1657         Gtk::VBox           list_vpacker;
1658
1659         /* autoscrolling */
1660
1661         bool autoscroll_active;
1662         int autoscroll_timeout_tag;
1663         int autoscroll_x;
1664         int autoscroll_y;
1665         int last_autoscroll_x;
1666         int last_autoscroll_y;
1667         uint32_t autoscroll_cnt;
1668         nframes64_t autoscroll_x_distance;
1669         double autoscroll_y_distance;
1670
1671         static gint _autoscroll_canvas (void *);
1672         bool autoscroll_canvas ();
1673         void start_canvas_autoscroll (int x, int y);
1674         void stop_canvas_autoscroll ();
1675         void maybe_autoscroll (GdkEventMotion*, bool);
1676         bool allow_vertical_scroll;
1677
1678         /* trimming */
1679         void point_trim (GdkEvent *, nframes64_t);
1680         void single_contents_trim (RegionView&, nframes64_t, bool, bool, bool);
1681         void single_start_trim (RegionView&, nframes64_t, bool, bool, bool);
1682         void single_end_trim (RegionView&, nframes64_t, bool, bool, bool);
1683
1684         void thaw_region_after_trim (RegionView& rv);
1685
1686         void trim_region_front();
1687         void trim_region_back();
1688         void trim_region (bool front);
1689
1690         void trim_region_to_edit_point ();
1691         void trim_region_from_edit_point ();
1692         void trim_region_to_loop ();
1693         void trim_region_to_punch ();
1694         void trim_region_to_location (const ARDOUR::Location&, const char* cmd);
1695
1696         void trim_to_region(bool forward);
1697         void trim_region_to_previous_region_end();
1698         void trim_region_to_next_region_start();
1699
1700         bool show_gain_after_trim;
1701
1702         /* Drag-n-Drop */
1703
1704         int convert_drop_to_paths (
1705                         std::vector<Glib::ustring>&           paths,
1706                         const Glib::RefPtr<Gdk::DragContext>& context,
1707                         gint                                  x,
1708                         gint                                  y,
1709                         const Gtk::SelectionData&             data,
1710                         guint                                 info,
1711                         guint                                 time);
1712
1713         void track_canvas_drag_data_received (
1714                         const Glib::RefPtr<Gdk::DragContext>& context,
1715                         gint                                  x,
1716                         gint                                  y,
1717                         const Gtk::SelectionData&             data,
1718                         guint                                 info,
1719                         guint                                 time);
1720
1721         void drop_paths (
1722                         const Glib::RefPtr<Gdk::DragContext>& context,
1723                         gint                                  x,
1724                         gint                                  y,
1725                         const Gtk::SelectionData&             data,
1726                         guint                                 info,
1727                         guint                                 time);
1728
1729         void drop_regions (
1730                         const Glib::RefPtr<Gdk::DragContext>& context,
1731                         gint                                  x,
1732                         gint                                  y,
1733                         const Gtk::SelectionData&             data,
1734                         guint                                 info,
1735                         guint                                 time);
1736
1737         void drop_routes (
1738                         const Glib::RefPtr<Gdk::DragContext>& context,
1739                         gint                x,
1740                         gint                y,
1741                         const Gtk::SelectionData& data,
1742                         guint               info,
1743                         guint               time);
1744
1745         /* audio export */
1746
1747         int  write_region_selection(RegionSelection&);
1748         bool write_region (std::string path, boost::shared_ptr<ARDOUR::AudioRegion>);
1749         void bounce_region_selection ();
1750         void bounce_range_selection (bool replace, bool enable_processing);
1751         void external_edit_region ();
1752
1753         int write_audio_selection (TimeSelection&);
1754         bool write_audio_range (ARDOUR::AudioPlaylist&, const ARDOUR::ChanCount& channels, std::list<ARDOUR::AudioRange>&);
1755
1756         void write_selection ();
1757
1758         XMLNode *before; /* used in *_reversible_command */
1759
1760         void update_title ();
1761         void update_title_s (const std::string & snapshot_name);
1762
1763         struct State {
1764             Selection* selection;
1765             double frames_per_unit;
1766
1767             State (PublicEditor const * e);
1768             ~State ();
1769         };
1770
1771         void instant_save ();
1772
1773         boost::shared_ptr<ARDOUR::AudioRegion> last_audition_region;
1774
1775         /* freeze operations */
1776
1777         ARDOUR::InterThreadInfo freeze_status;
1778         static void* _freeze_thread (void*);
1779         void* freeze_thread ();
1780
1781         void freeze_route ();
1782         void unfreeze_route ();
1783
1784         /* route-group solo + mute */
1785
1786         void set_route_group_solo (ARDOUR::Route&, bool);
1787         void set_route_group_mute (ARDOUR::Route&, bool);
1788
1789         /* duplication */
1790
1791         void duplicate_dialog (bool with_dialog);
1792
1793         nframes64_t event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
1794
1795         /* returns false if mouse pointer is not in track or marker canvas
1796          */
1797         bool mouse_frame (nframes64_t&, bool& in_track_canvas) const;
1798
1799         /* "whats mine is yours" */
1800
1801         TimeFXDialog* current_timefx;
1802
1803         static void* timefx_thread (void *arg);
1804         void do_timefx (TimeFXDialog&);
1805
1806         int time_stretch (RegionSelection&, float fraction);
1807         int pitch_shift (RegionSelection&, float cents);
1808         void pitch_shift_regions ();
1809         int time_fx (RegionSelection&, float val, bool pitching);
1810
1811         /* editor-mixer strip */
1812
1813         MixerStrip *current_mixer_strip;
1814         bool show_editor_mixer_when_tracks_arrive;
1815         Gtk::VBox current_mixer_strip_vbox;
1816         void cms_new (boost::shared_ptr<ARDOUR::Route>);
1817         void current_mixer_strip_hidden ();
1818
1819         void detach_tearoff (Gtk::Box* b, Gtk::Window* w);
1820         void reattach_tearoff (Gtk::Box* b, Gtk::Window* w, int32_t n);
1821 #ifdef GTKOSX
1822         void ensure_all_elements_drawn ();
1823 #endif
1824         /* nudging tracks */
1825
1826         void nudge_track (bool use_edit_point, bool forwards);
1827
1828         /* xfades */
1829
1830         bool _xfade_visibility;
1831
1832 #ifdef WITH_CMT
1833         void handle_new_imageframe_time_axis_view(const std::string & track_name, void* src) ;
1834         void handle_new_imageframe_marker_time_axis_view(const std::string & track_name, TimeAxisView* marked_track) ;
1835
1836         void start_imageframe_grab(ArdourCanvas::Item*, GdkEvent*) ;
1837         void start_markerview_grab(ArdourCanvas::Item*, GdkEvent*) ;
1838
1839         void imageframe_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
1840         void markerview_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
1841         void timeaxis_item_drag_finished_callback(ArdourCanvas::Item*, GdkEvent*) ;
1842
1843         gint canvas_imageframe_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
1844         gint canvas_imageframe_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameTimeAxis* ifta);
1845         gint canvas_imageframe_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
1846         gint canvas_imageframe_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
1847
1848         gint canvas_marker_time_axis_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerTimeAxis* mta);
1849         gint canvas_markerview_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
1850         gint canvas_markerview_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
1851         gint canvas_markerview_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
1852
1853         void imageframe_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
1854         void imageframe_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
1855         void imageframe_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
1856         void imageframe_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
1857         void imageframe_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
1858         void imageframe_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
1859
1860         void markerview_item_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
1861         void markerview_item_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
1862         void markerview_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
1863         void markerview_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
1864         void markerview_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
1865         void markerview_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
1866
1867         void popup_imageframe_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
1868         void popup_marker_time_axis_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
1869
1870         ImageFrameSocketHandler* image_socket_listener ;
1871 #endif
1872
1873         void toggle_xfade_active (boost::weak_ptr<ARDOUR::Crossfade>);
1874         void toggle_xfade_length (boost::weak_ptr<ARDOUR::Crossfade>);
1875         void edit_xfade (boost::weak_ptr<ARDOUR::Crossfade>);
1876         void xfade_edit_left_region ();
1877         void xfade_edit_right_region ();
1878
1879         static const int32_t default_width = 995;
1880         static const int32_t default_height = 765;
1881
1882         /* nudge */
1883
1884         Gtk::Button      nudge_forward_button;
1885         Gtk::Button      nudge_backward_button;
1886         Gtk::HBox        nudge_hbox;
1887         Gtk::VBox        nudge_vbox;
1888         AudioClock       nudge_clock;
1889
1890         bool nudge_forward_release (GdkEventButton*);
1891         bool nudge_backward_release (GdkEventButton*);
1892
1893         /* audio filters */
1894
1895         void apply_filter (ARDOUR::Filter&, std::string cmd);
1896
1897         Command* apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, MidiRegionView& mrv);
1898         void apply_midi_note_edit_op (ARDOUR::MidiOperator& op);
1899
1900         /* handling cleanup */
1901
1902         int playlist_deletion_dialog (boost::shared_ptr<ARDOUR::Playlist>);
1903
1904         PBD::ScopedConnectionList session_connections;
1905
1906         /* tracking step changes of track height */
1907
1908         TimeAxisView* current_stepping_trackview;
1909         ARDOUR::microseconds_t last_track_height_step_timestamp;
1910         gint track_height_step_timeout();
1911         sigc::connection step_timeout;
1912
1913         TimeAxisView* entered_track;
1914         RegionView*   entered_regionview;
1915
1916
1917         void ensure_entered_track_selected (bool op_acts_on_objects = false);
1918         bool clear_entered_track;
1919         bool left_track_canvas (GdkEventCrossing*);
1920         bool entered_track_canvas (GdkEventCrossing*);
1921         void set_entered_track (TimeAxisView*);
1922         void set_entered_regionview (RegionView*);
1923         void ensure_track_visible (TimeAxisView*);
1924         gint left_automation_track ();
1925
1926         bool _new_regionviews_show_envelope;
1927
1928         void reset_canvas_action_sensitivity (bool);
1929         void toggle_gain_envelope_visibility ();
1930         void toggle_gain_envelope_active ();
1931         void reset_region_gain_envelopes ();
1932
1933         bool on_key_press_event (GdkEventKey*);
1934         bool on_key_release_event (GdkEventKey*);
1935
1936         void session_state_saved (std::string);
1937
1938         Glib::RefPtr<Gtk::Action>              undo_action;
1939         Glib::RefPtr<Gtk::Action>              redo_action;
1940
1941         void history_changed ();
1942
1943         Gtk::HBox      status_bar_hpacker;
1944
1945         Editing::EditPoint _edit_point;
1946
1947         Gtk::ComboBoxText edit_point_selector;
1948
1949         void set_edit_point_preference (Editing::EditPoint ep, bool force = false);
1950         void cycle_edit_point (bool with_marker);
1951         void set_edit_point ();
1952         void edit_point_selection_done ();
1953         void edit_point_chosen (Editing::EditPoint);
1954         Glib::RefPtr<Gtk::RadioAction> edit_point_action (Editing::EditPoint);
1955         std::vector<std::string> edit_point_strings;
1956
1957         void selected_marker_moved (ARDOUR::Location*);
1958
1959         bool get_edit_op_range (nframes64_t& start, nframes64_t& end) const;
1960
1961         void get_regions_at (RegionSelection&, nframes64_t where, const TrackViewList& ts) const;
1962         void get_regions_after (RegionSelection&, nframes64_t where, const TrackViewList& ts) const;
1963
1964         void get_regions_for_action (RegionSelection&, bool allow_entered = false, bool allow_edit_position = true);
1965
1966         void start_updating_meters ();
1967         void stop_updating_meters ();
1968         bool meters_running;
1969
1970         void select_next_route ();
1971         void select_prev_route ();
1972
1973         void snap_to_internal (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
1974         void timecode_snap_to_internal (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
1975
1976         RhythmFerret* rhythm_ferret;
1977         BundleManager* _bundle_manager;
1978         GlobalPortMatrixWindow* _global_port_matrix[ARDOUR::DataType::num_types];
1979
1980         void fit_tracks (TrackViewList &);
1981         void fit_selected_tracks ();
1982         void set_track_height (uint32_t h);
1983
1984         void remove_tracks ();
1985         void toggle_tracks_active ();
1986
1987         bool _have_idled;
1988         int resize_idle_id;
1989         static gboolean _idle_resize (gpointer);
1990         bool idle_resize();
1991         int32_t _pending_resize_amount;
1992         TimeAxisView* _pending_resize_view;
1993
1994         void visible_order_range (int*, int*) const;
1995
1996         void located ();
1997         
1998         /** true if we've made a locate request that hasn't yet been processed */
1999         bool _pending_locate_request;
2000         
2001         /** if true, there is a pending Session locate which is the initial one when loading a session;
2002             we need to know this so that we don't (necessarily) set the viewport to show the playhead
2003             initially.
2004         */
2005         bool _pending_initial_locate;
2006
2007         Gtk::HBox _summary_hbox;
2008         EditorSummary* _summary;
2009         void region_view_added (RegionView *);
2010
2011         void update_canvas_now ();
2012         void streamview_height_changed ();
2013
2014         EditorGroupTabs* _group_tabs;
2015         void fit_route_group (ARDOUR::RouteGroup *);
2016
2017         void start_step_editing ();
2018         void stop_step_editing ();
2019         bool check_step_edit ();
2020         sigc::connection step_edit_connection;
2021
2022         friend class Drag;
2023         friend class RegionDrag;
2024         friend class RegionMoveDrag;
2025         friend class RegionSpliceDrag;
2026         friend class TrimDrag;
2027         friend class MeterMarkerDrag;
2028         friend class TempoMarkerDrag;
2029         friend class CursorDrag;
2030         friend class FadeInDrag;
2031         friend class FadeOutDrag;
2032         friend class MarkerDrag;
2033         friend class RegionGainDrag;
2034         friend class ControlPointDrag;
2035         friend class LineDrag;
2036         friend class RubberbandSelectDrag;
2037         friend class TimeFXDrag;
2038         friend class ScrubDrag;
2039         friend class SelectionDrag;
2040         friend class RangeMarkerBarDrag;
2041         friend class MouseZoomDrag;
2042         friend class RegionCreateDrag;
2043         friend class RegionMotionDrag;
2044         friend class RegionInsertDrag;
2045
2046         friend class EditorSummary;
2047         friend class EditorGroupTabs;
2048
2049         friend class EditorRoutes;
2050 };
2051
2052 #endif /* __ardour_editor_h__ */