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