e8af889ad12de63e8719a9685846baa4e21471bd
[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
29 #include <glibmm/ustring.h>
30
31 #include <boost/optional.hpp>
32
33 #include <libgnomecanvasmm/canvas.h>
34 #include <libgnomecanvasmm/group.h>
35 #include <libgnomecanvasmm/line.h>
36 #include <libgnomecanvasmm/pixbuf.h>
37
38 #include <cmath>
39
40 #include <gtkmm/layout.h>
41 #include <gtkmm/comboboxtext.h>
42
43 #include <gtkmm2ext/selector.h>
44 #include <gtkmm2ext/click_box.h>
45 #include <gtkmm2ext/dndtreeview.h>
46
47 #include <pbd/stateful.h>
48 #include <ardour/session.h>
49 #include <ardour/tempo.h>
50 #include <ardour/stretch.h>
51 #include <ardour/location.h>
52 #include <ardour/audioregion.h>
53 #include <ardour/track.h>
54
55 #include "audio_clock.h"
56 #include "gtk-custom-ruler.h"
57 #include "ardour_dialog.h"
58 #include "public_editor.h"
59 #include "editing.h"
60 #include "enums.h"
61 #include "editor_items.h"
62 #include "region_selection.h"
63 #include "canvas.h"
64 #include "time_axis_view.h"
65 #include "draginfo.h"
66 #include "tempo_lines.h"
67
68 namespace Gtkmm2ext {
69         class TearOff;
70 }
71
72 namespace ARDOUR {
73         class AudioDiskstream;
74         class RouteGroup;
75         class Playlist;
76         class AudioPlaylist;
77         class Region;
78         class Location;
79         class TempoSection;
80         class NamedSelection;
81         class Session;
82         class Filter;
83         class Crossfade;
84         class ChanCount;
85 }
86
87 namespace LADSPA {
88         class Plugin;
89 }
90
91 class TimeAxisView;
92 class AudioTimeAxisView;
93 class AutomationTimeAxisView;
94 class AudioRegionView;
95 class CrossfadeView;
96 class PluginSelector;
97 class PlaylistSelector;
98 class Marker;
99 class GroupedButtons;
100 class AutomationLine;
101 class UIExportSpecification;
102 class ExportDialog;
103 class Selection;
104 class TimeSelection;
105 class TrackSelection;
106 class AutomationSelection;
107 class MixerStrip;
108 class StreamView;
109 class AudioStreamView;
110 class ControlPoint;
111 class SoundFileOmega;
112 class RhythmFerret;
113 #ifdef FFT_ANALYSIS
114 class AnalysisWindow;
115 #endif
116
117 /* <CMT Additions> */
118 class ImageFrameView;
119 class ImageFrameTimeAxisView;
120 class ImageFrameTimeAxis;
121 class MarkerTimeAxis ;
122 class MarkerView ;
123 class ImageFrameSocketHandler ;
124 class TimeAxisViewItem ;
125 /* </CMT Additions> */
126
127
128 class Editor : public PublicEditor
129 {
130   public:
131         Editor ();
132         ~Editor ();
133
134         void             connect_to_session (ARDOUR::Session *);
135         ARDOUR::Session* current_session() const { return session; }
136         void             first_idle ();
137         virtual bool have_idled() const { return _have_idled; }
138
139         nframes64_t leftmost_position() const { return leftmost_frame; }
140         nframes64_t current_page_frames() const {
141                 return (nframes64_t) floor (canvas_width * frames_per_unit);
142         }
143
144         void cycle_snap_mode ();
145         void cycle_snap_choice ();
146         void set_snap_to (Editing::SnapType);
147         void set_snap_mode (Editing::SnapMode);
148         void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;}
149
150         void undo (uint32_t n = 1);
151         void redo (uint32_t n = 1);
152
153         XMLNode& get_state ();
154         int set_state (const XMLNode& );
155
156         void set_mouse_mode (Editing::MouseMode, bool force=true);
157         void step_mouse_mode (bool next);
158         Editing::MouseMode current_mouse_mode () const { return mouse_mode; }
159         
160         void set_midi_edit_cursor (Editing::MidiEditMode);
161         void set_midi_edit_mode (Editing::MidiEditMode, bool force=true);
162         Editing::MidiEditMode current_midi_edit_mode () const { return midi_edit_mode; }
163
164 #ifdef WITH_CMT
165         void add_imageframe_time_axis(const std::string & track_name, void*) ;
166         void add_imageframe_marker_time_axis(const std::string & track_name, TimeAxisView* marked_track, void*) ;
167         void connect_to_image_compositor() ;
168         void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ;
169 #endif
170
171         TimeAxisView* get_named_time_axis(const std::string & name) ;
172         void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>);
173         void add_to_idle_resize (TimeAxisView*, uint32_t);
174
175         RouteTimeAxisView* get_route_view_by_id (PBD::ID& id);
176
177         void consider_auditioning (boost::shared_ptr<ARDOUR::Region>);
178         void hide_a_region (boost::shared_ptr<ARDOUR::Region>);
179         void remove_a_region (boost::shared_ptr<ARDOUR::Region>);
180
181 #ifdef USE_RUBBERBAND
182         std::vector<std::string> rb_opt_strings;
183 #endif
184
185         /* option editor-access */
186
187         void set_show_waveforms (bool yn);
188         bool show_waveforms() const { return _show_waveforms; }
189
190         void set_waveform_scale (Editing::WaveformScale);
191
192         void set_show_waveforms_recording (bool yn);
193         bool show_waveforms_recording() const { return _show_waveforms_recording; }
194         
195         /* things that need to be public to be used in the main menubar */
196
197         void new_region_from_selection ();
198         void separate_regions_between (const TimeSelection&);
199         void separate_region_from_selection ();
200         void separate_region_from_punch ();
201         void separate_region_from_loop ();
202         void separate_regions_using_location (ARDOUR::Location&);
203         void toggle_playback (bool with_abort);
204         void transition_to_rolling (bool forward);
205
206         /* undo related */
207
208         nframes64_t unit_to_frame (double unit) const {
209                 return (nframes64_t) rint (unit * frames_per_unit);
210         }
211         
212         double frame_to_unit (nframes64_t frame) const {
213                 return rint ((double) frame / (double) frames_per_unit);
214         }
215
216         double frame_to_unit (double frame) const {
217                 return rint (frame / frames_per_unit);
218         }
219
220         /* NOTE: these functions assume that the "pixel" coordinate is
221            the result of using the world->canvas affine transform on a
222            world coordinate. These coordinates already take into
223            account any scrolling carried out by adjusting the
224            xscroll_adjustment.  
225         */
226
227         nframes64_t pixel_to_frame (double pixel) const {
228                 
229                 /* pixel can be less than zero when motion events
230                    are processed. since we've already run the world->canvas
231                    affine, that means that the location *really* is "off
232                    to the right" and thus really is "before the start".
233                 */
234
235                 if (pixel >= 0) {
236                         return (nframes64_t) rint (pixel * frames_per_unit * GNOME_CANVAS(track_canvas->gobj())->pixels_per_unit);
237                 } else {
238                         return 0;
239                 }
240         }
241
242         gulong frame_to_pixel (nframes64_t frame) const {
243                 return (gulong) rint ((frame / (frames_per_unit *  GNOME_CANVAS(track_canvas->gobj())->pixels_per_unit)));
244         }
245
246         void flush_canvas ();
247
248         /* selection */
249
250         Selection& get_selection() const { return *selection; }
251         Selection& get_cut_buffer() const { return *cut_buffer; }
252
253         bool extend_selection_to_track (TimeAxisView&);
254
255         void play_selection ();
256         void select_all_in_track (Selection::Operation op);
257         void select_all (Selection::Operation op);
258         void invert_selection_in_track ();
259         void invert_selection ();
260         void deselect_all ();
261
262         /* tempo */
263
264         void set_show_measures (bool yn);
265         bool show_measures () const { return _show_measures; }
266         bool initial_ruler_update_required;
267
268 #ifdef FFT_ANALYSIS
269         /* analysis window */
270         void analyze_region_selection();
271         void analyze_range_selection();
272 #endif
273
274         /* export */
275
276         /* these initiate export ... */
277         
278         void export_session();
279         void export_selection();
280
281
282         void add_toplevel_controls (Gtk::Container&);
283         Gtk::HBox& get_status_bar_packer()  { return status_bar_hpacker; }
284
285         void      set_zoom_focus (Editing::ZoomFocus);
286         Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
287         double   get_current_zoom () const { return frames_per_unit; }
288
289         void temporal_zoom_step (bool coarser);
290
291         /* stuff that AudioTimeAxisView and related classes use */
292
293         PlaylistSelector& playlist_selector() const;
294         void route_name_changed (TimeAxisView *);
295         void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>);
296
297         void new_playlists (TimeAxisView* v);
298         void copy_playlists (TimeAxisView* v);
299         void clear_playlists (TimeAxisView* v);
300
301         TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0);
302
303         Width editor_mixer_strip_width;
304         void maybe_add_mixer_strip_width (XMLNode&);
305         void show_editor_mixer (bool yn);
306         void show_editor_list (bool yn);
307         void set_selected_mixer_strip (TimeAxisView&);
308         void hide_track_in_display (TimeAxisView& tv, bool temporary = false);
309         void show_track_in_display (TimeAxisView& tv);
310
311         /* nudge is initiated by transport controls owned by ARDOUR_UI */
312
313         void nudge_forward (bool next, bool force_playhead);
314         void nudge_backward (bool next, bool force_playhead);
315
316         /* nudge initiated from context menu */
317
318         void nudge_forward_capture_offset ();
319         void nudge_backward_capture_offset ();
320
321         /* playhead/screen stuff */
322         
323         void set_follow_playhead (bool yn);
324         void toggle_follow_playhead ();
325         bool follow_playhead() const { return _follow_playhead; }
326         bool dragging_playhead () const { return _dragging_playhead; }
327
328         void toggle_waveform_visibility ();
329         void toggle_zero_line_visibility ();
330         void toggle_waveforms_while_recording ();
331         void toggle_measure_visibility ();
332         void toggle_logo_visibility ();
333
334         /* SMPTE timecode & video sync */
335
336         void smpte_fps_chosen (ARDOUR::SmpteFormat format);
337         void video_pullup_chosen (ARDOUR::Session::PullupFormat pullup);
338         void subframes_per_frame_chosen (uint32_t);
339
340         void update_smpte_mode();
341         void update_video_pullup();
342         void update_subframes_per_frame ();
343         /* xfades */
344
345         void toggle_auto_xfade ();
346         void toggle_xfades_active ();
347         void toggle_xfade_visibility ();
348         bool xfade_visibility() const { return _xfade_visibility; }
349         void update_xfade_visibility ();
350         void update_crossfade_model ();
351         void set_crossfade_model (ARDOUR::CrossfadeModel);
352
353         /* layers */
354         void set_layer_model (ARDOUR::LayerModel);
355         void update_layering_model ();
356         
357         void toggle_link_region_and_track_selection ();
358
359         /* redirect shared ops menu. caller must free returned menu */
360
361         Gtk::Menu* redirect_menu ();
362
363         /* floating windows/transient */
364
365         void ensure_float (Gtk::Window&);
366
367         void show_window ();
368
369         void scroll_tracks_down_line ();
370         void scroll_tracks_up_line ();
371
372         bool new_regionviews_display_gain () { return _new_regionviews_show_envelope; }
373         void prepare_for_cleanup ();
374         void finish_cleanup ();
375
376         void maximise_editing_space();
377         void restore_editing_space();
378
379         void reset_x_origin (nframes64_t);
380         void reset_zoom (double);
381         void reposition_and_zoom (nframes64_t, double);
382
383         nframes64_t get_preferred_edit_position (bool ignore_playhead = false);
384
385         bool update_mouse_speed ();
386         bool decelerate_mouse_speed ();
387
388         void toggle_meter_updating();
389
390         void show_rhythm_ferret();
391
392         void goto_visual_state (uint32_t);
393         void save_visual_state (uint32_t);
394
395         void queue_draw_resize_line (int at);
396         void start_resize_line_ops ();
397         void end_resize_line_ops ();
398
399   protected:
400         void map_transport_state ();
401         void map_position_change (nframes64_t);
402
403         void on_realize();
404         bool on_expose_event (GdkEventExpose*);
405
406   private:
407
408         /// The session that we are editing, or 0
409         void color_handler ();
410         ARDOUR::Session     *session;
411         bool                 constructed;
412
413         // to keep track of the playhead position for control_scroll
414         boost::optional<nframes64_t> _control_scroll_target;
415  
416         PlaylistSelector* _playlist_selector;
417
418         typedef std::pair<TimeAxisView*,XMLNode*> TAVState;
419
420         struct VisualState {
421             double              y_position;
422             double              frames_per_unit;
423             nframes64_t         leftmost_frame;
424             Editing::ZoomFocus  zoom_focus;
425             bool                zoomed_to_region;
426             std::list<TAVState> track_states;
427         };
428         
429         std::list<VisualState*> undo_visual_stack;
430         std::list<VisualState*> redo_visual_stack;
431         VisualState* current_visual_state (bool with_tracks = true);
432         void undo_visual_state ();
433         void redo_visual_state ();
434         void use_visual_state (VisualState&);
435         bool no_save_visual;
436         void swap_visual_state ();
437         
438         std::vector<VisualState*> visual_states;
439         sigc::connection visual_state_op_connection;
440         void start_visual_state_op (uint32_t n);
441         void cancel_visual_state_op (uint32_t n);
442         bool end_visual_state_op (uint32_t n);
443
444         nframes64_t leftmost_frame;
445         double      frames_per_unit;
446         Editing::ZoomFocus zoom_focus;
447
448         void set_frames_per_unit (double);
449         void post_zoom ();
450
451         Editing::MouseMode mouse_mode;
452         Editing::MidiEditMode midi_edit_mode;
453
454         int  post_maximal_editor_width;
455         int  post_maximal_pane_position;
456         int  pre_maximal_pane_position;
457         int  pre_maximal_editor_width;
458         void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*);
459
460         Gtk::Notebook the_notebook;
461         Gtk::HPaned   edit_pane;
462
463         Gtk::EventBox meter_base;
464         Gtk::HBox     meter_box;
465         Gtk::EventBox marker_base;
466         Gtk::HBox     marker_box;
467         Gtk::VBox     scrollers_rulers_markers_box;
468
469         void location_changed (ARDOUR::Location *);
470         void location_flags_changed (ARDOUR::Location *, void *);
471         void refresh_location_display ();
472         void refresh_location_display_s (ARDOUR::Change);
473         void refresh_location_display_internal (ARDOUR::Locations::LocationList&);
474         void add_new_location (ARDOUR::Location *);
475         void location_gone (ARDOUR::Location *);
476         void remove_marker (ArdourCanvas::Item&, GdkEvent*);
477         gint really_remove_marker (ARDOUR::Location* loc);
478         void goto_nth_marker (int nth);
479
480         uint32_t location_marker_color;
481         uint32_t location_range_color;
482         uint32_t location_loop_color;
483         uint32_t location_punch_color;
484         uint32_t location_cd_marker_color;
485
486         struct LocationMarkers {
487             Marker* start;
488             Marker* end;
489             bool    valid;
490
491             LocationMarkers () : start(0), end(0), valid (true) {}
492             
493             ~LocationMarkers ();
494
495             void hide();
496             void show ();
497             void set_name (const string&);
498             void set_position (nframes64_t start, nframes64_t end = 0);
499             void set_color_rgba (uint32_t);
500         };
501
502         LocationMarkers  *find_location_markers (ARDOUR::Location *) const;
503         ARDOUR::Location* find_location_from_marker (Marker *, bool& is_start) const;
504         Marker* entered_marker;
505
506         typedef std::map<ARDOUR::Location*,LocationMarkers *> LocationMarkerMap;
507         LocationMarkerMap location_markers;
508
509         void hide_marker (ArdourCanvas::Item*, GdkEvent*);
510         void clear_marker_display ();
511         void mouse_add_new_marker (nframes64_t where, bool is_cd=false, bool is_xrun=false);
512         bool choose_new_marker_name(string &name);
513         void update_cd_marker_display ();
514         void ensure_cd_marker_updated (LocationMarkers * lam, ARDOUR::Location * location);
515
516         TimeAxisView*      clicked_axisview;
517         RouteTimeAxisView* clicked_routeview;
518         /** The last RegionView that was clicked on, or 0 if the last click was not
519          * on a RegionView.  This is set up by the canvas event handlers in
520          * editor_canvas_events.cc
521          */
522         RegionView*        clicked_regionview;
523         RegionSelection    latest_regionviews;
524         uint32_t           clicked_selection;
525         CrossfadeView*     clicked_crossfadeview;
526         ControlPoint*      clicked_control_point;
527
528         void sort_track_selection (TrackSelection* sel = 0);
529
530         void get_relevant_tracks (std::set<RouteTimeAxisView*>& relevant_tracks);
531         void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&) const;
532         void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*) const;
533
534         /* functions to be passed to mapover_tracks(), possibly with sigc::bind()-supplied arguments */
535
536         void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, vector<RegionView*>*) const;
537         void mapped_use_new_playlist (RouteTimeAxisView&, uint32_t);
538         void mapped_use_copy_playlist (RouteTimeAxisView&, uint32_t);
539         void mapped_clear_playlist (RouteTimeAxisView&, uint32_t);
540
541         /* end */
542
543         void button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type);
544         bool button_release_can_deselect;
545
546         void catch_vanishing_regionview (RegionView *);
547
548         void set_selected_track (TimeAxisView&, Selection::Operation op = Selection::Set, bool no_remove=false);
549         void select_all_tracks ();
550
551         bool set_selected_control_point_from_click (Selection::Operation op = Selection::Set, bool no_remove=false);
552         void set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool no_remove=false);
553         void set_selected_track_as_side_effect (bool force = false);
554         bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set, bool no_track_remove=false);
555
556         void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
557         bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::weak_ptr<ARDOUR::Region>);
558         void collect_new_region_view (RegionView *);
559         void collect_and_select_new_region_view (RegionView *);
560         
561         Gtk::Menu track_context_menu;
562         Gtk::Menu track_region_context_menu;
563         Gtk::Menu track_selection_context_menu;
564         Gtk::Menu track_crossfade_context_menu;
565
566         Gtk::MenuItem* region_edit_menu_split_item;
567         Gtk::MenuItem* region_edit_menu_split_multichannel_item;
568         Gtk::Menu * track_region_edit_playlist_menu;
569         Gtk::Menu * track_edit_playlist_submenu;
570         Gtk::Menu * track_selection_edit_playlist_submenu;
571
572         void popup_track_context_menu (int, int, ItemType, bool, nframes64_t);
573         Gtk::Menu* build_track_context_menu (nframes64_t);
574         Gtk::Menu* build_track_bus_context_menu (nframes64_t);
575         Gtk::Menu* build_track_region_context_menu (nframes64_t frame);
576         Gtk::Menu* build_track_crossfade_context_menu (nframes64_t);
577         Gtk::Menu* build_track_selection_context_menu (nframes64_t);
578         void add_dstream_context_items (Gtk::Menu_Helpers::MenuList&);
579         void add_bus_context_items (Gtk::Menu_Helpers::MenuList&);
580         void add_region_context_items (StreamView*, boost::shared_ptr<ARDOUR::Region>, Gtk::Menu_Helpers::MenuList&);
581         void add_crossfade_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Crossfade>, Gtk::Menu_Helpers::MenuList&, bool many);
582         void add_selection_context_items (Gtk::Menu_Helpers::MenuList&);
583
584         void add_item_with_sensitivity (Gtk::Menu_Helpers::MenuList&, Gtk::Menu_Helpers::MenuElem, bool) const;
585
586         void handle_new_route (ARDOUR::Session::RouteList&);
587         void remove_route (TimeAxisView *);
588         bool route_removal;
589
590         Gtk::HBox           global_hpacker;
591         Gtk::VBox           global_vpacker;
592         Gtk::VBox           vpacker;
593
594         bool need_resize_line;
595         int  resize_line_y;
596         int  old_resize_line_y;
597
598         Gdk::Cursor*          current_canvas_cursor;
599         void set_canvas_cursor ();
600         Gdk::Cursor* which_grabber_cursor ();
601
602         ArdourCanvas::Canvas* track_canvas;
603         ArdourCanvas::Canvas* time_canvas;
604
605         ArdourCanvas::Text* first_action_message;
606         ArdourCanvas::Text* verbose_canvas_cursor;
607         bool                 verbose_cursor_visible;
608
609         void parameter_changed (const char *);
610         
611         bool track_canvas_motion (GdkEvent*);
612
613         void set_verbose_canvas_cursor (const string &, double x, double y);
614         void set_verbose_canvas_cursor_text (const string &);
615         void show_verbose_canvas_cursor();
616         void hide_verbose_canvas_cursor();
617
618         bool verbose_cursor_on; // so far unused
619
620         Gtk::EventBox      time_canvas_event_box;
621         Gtk::EventBox      track_canvas_event_box;
622         Gtk::EventBox      time_button_event_box;
623         Gtk::Frame         time_button_frame;
624
625         ArdourCanvas::Group      *minsec_group;
626         ArdourCanvas::Pixbuf     *logo_item;
627         ArdourCanvas::Group      *bbt_group;
628         ArdourCanvas::Group      *smpte_group;
629         ArdourCanvas::Group      *frame_group;
630         ArdourCanvas::Group      *tempo_group;
631         ArdourCanvas::Group      *meter_group;
632         ArdourCanvas::Group      *marker_group;
633         ArdourCanvas::Group      *range_marker_group;
634         ArdourCanvas::Group      *transport_marker_group;
635         ArdourCanvas::Group*      cd_marker_group;
636         
637         enum RulerType {
638                 ruler_metric_smpte = 0,
639                 ruler_metric_bbt = 1,
640                 ruler_metric_frames = 2,
641                 ruler_metric_minsec = 3,
642
643                 ruler_time_tempo = 4,
644                 ruler_time_meter = 5,
645                 ruler_time_marker = 6,
646                 ruler_time_range_marker = 7,
647                 ruler_time_transport_marker = 8,
648                 ruler_time_cd_marker = 9,
649         };
650
651         static GtkCustomMetric ruler_metrics[4];
652         Glib::RefPtr<Gtk::ToggleAction> ruler_timecode_action;
653         Glib::RefPtr<Gtk::ToggleAction> ruler_bbt_action;
654         Glib::RefPtr<Gtk::ToggleAction> ruler_samples_action;
655         Glib::RefPtr<Gtk::ToggleAction> ruler_minsec_action;
656         Glib::RefPtr<Gtk::ToggleAction> ruler_tempo_action;
657         Glib::RefPtr<Gtk::ToggleAction> ruler_meter_action;
658         Glib::RefPtr<Gtk::ToggleAction> ruler_marker_action;
659         Glib::RefPtr<Gtk::ToggleAction> ruler_range_action;
660         Glib::RefPtr<Gtk::ToggleAction> ruler_loop_punch_action;
661         Glib::RefPtr<Gtk::ToggleAction> ruler_cd_marker_action;
662         bool                   no_ruler_shown_update;
663         
664         gint ruler_button_press (GdkEventButton*);
665         gint ruler_button_release (GdkEventButton*);
666         gint ruler_mouse_motion (GdkEventMotion*);
667         bool ruler_scroll (GdkEventScroll* event);
668
669         gint ruler_pressed_button;
670         Gtk::Widget * ruler_grabbed_widget;
671         
672         void initialize_rulers ();
673         void update_just_smpte ();
674         void compute_fixed_ruler_scale (); //calculates the RulerScale of the fixed rulers
675         void update_fixed_rulers ();
676         void update_tempo_based_rulers (); 
677         void popup_ruler_menu (nframes64_t where = 0, ItemType type = RegionItem);
678         void update_ruler_visibility ();
679         void set_ruler_visible (RulerType, bool);
680         void toggle_ruler_visibility (RulerType rt);
681         void ruler_toggled (int);
682         gint ruler_label_button_release (GdkEventButton*);
683         void store_ruler_visibility ();
684         void restore_ruler_visibility ();
685         
686         static gint _metric_get_smpte (GtkCustomRulerMark **, gdouble, gdouble, gint);
687         static gint _metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
688         static gint _metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
689         static gint _metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
690         
691         enum MinsecRulerScale {
692                 minsec_show_seconds,
693                 minsec_show_minutes,
694                 minsec_show_hours,
695                 minsec_show_frames
696         };
697
698         MinsecRulerScale minsec_ruler_scale;
699
700         nframes_t minsec_mark_interval;
701         gint minsec_mark_modulo;
702         gint minsec_nmarks;
703         void set_minsec_ruler_scale (gdouble lower, gdouble upper);
704
705         enum SMPTERulerScale {
706                 smpte_show_bits,
707                 smpte_show_frames,
708                 smpte_show_seconds,
709                 smpte_show_minutes,
710                 smpte_show_hours
711         };
712
713         SMPTERulerScale smpte_ruler_scale;
714
715         nframes_t smpte_mark_interval;
716         gint smpte_mark_modulo;
717         gint smpte_nmarks;
718         void set_smpte_ruler_scale (gdouble lower, gdouble upper);
719
720         enum BBTRulerScale {
721                 bbt_over,
722                 bbt_show_64,
723                 bbt_show_16,
724                 bbt_show_4,
725                 bbt_show_1,
726                 bbt_show_beats,
727                 bbt_show_ticks,
728                 bbt_show_ticks_detail,
729                 bbt_show_ticks_super_detail
730         };
731
732         BBTRulerScale bbt_ruler_scale;
733
734         uint32_t bbt_bars;
735         gint bbt_nmarks;
736         uint32_t bbt_bar_helper_on;
737         uint32_t bbt_accent_modulo;
738         void compute_bbt_ruler_scale (nframes64_t lower, nframes64_t upper);
739
740         gint metric_get_smpte (GtkCustomRulerMark **, gdouble, gdouble, gint);
741         gint metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
742         gint metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
743         gint metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
744
745         Gtk::Widget        *_ruler_separator;
746         GtkWidget          *_smpte_ruler;
747         GtkWidget          *_bbt_ruler;
748         GtkWidget          *_frames_ruler;
749         GtkWidget          *_minsec_ruler;
750         Gtk::Widget        *smpte_ruler;
751         Gtk::Widget        *bbt_ruler;
752         Gtk::Widget        *frames_ruler;
753         Gtk::Widget        *minsec_ruler;
754         static Editor      *ruler_editor;
755
756         static const double timebar_height;
757         guint32 visible_timebars;
758         Gtk::Menu          *editor_ruler_menu;
759         
760         ArdourCanvas::SimpleRect* tempo_bar;
761         ArdourCanvas::SimpleRect* meter_bar;
762         ArdourCanvas::SimpleRect* marker_bar;
763         ArdourCanvas::SimpleRect* range_marker_bar;
764         ArdourCanvas::SimpleRect* transport_marker_bar;
765         ArdourCanvas::SimpleRect* cd_marker_bar;
766         
767         Gtk::Label  minsec_label;
768         Gtk::Label  bbt_label;
769         Gtk::Label  smpte_label;
770         Gtk::Label  frame_label;
771         Gtk::Label  tempo_label;
772         Gtk::Label  meter_label;
773         Gtk::Label  mark_label;
774         Gtk::Label  range_mark_label;
775         Gtk::Label  transport_mark_label;
776         Gtk::Label  cd_mark_label;
777         
778
779         Gtk::VBox          time_button_vbox;
780         Gtk::HBox          time_button_hbox;
781
782         struct Cursor {
783             Editor&               editor;
784             ArdourCanvas::Points  points;
785             ArdourCanvas::Line    canvas_item;
786             nframes64_t           current_frame;
787             double                length;
788
789             Cursor (Editor&, bool (Editor::*)(GdkEvent*,ArdourCanvas::Item*));
790             ~Cursor ();
791
792             void set_position (nframes64_t);
793             void set_length (double units);
794             void set_y_axis (double position);
795         };
796
797         friend struct Cursor; /* it needs access to several private
798                                  fields. XXX fix me.
799                               */
800
801         Cursor* playhead_cursor;
802         ArdourCanvas::Group* cursor_group;
803
804         void    cursor_to_region_boundary (Cursor*, int32_t dir);
805         void    cursor_to_next_region_boundary (Cursor*);
806         void    cursor_to_previous_region_boundary (Cursor*);
807         void    cursor_to_next_region_point (Cursor*, ARDOUR::RegionPoint);
808         void    cursor_to_previous_region_point (Cursor*, ARDOUR::RegionPoint);
809         void    cursor_to_region_point (Cursor*, ARDOUR::RegionPoint, int32_t dir);
810         void    cursor_to_selection_start (Cursor *);
811         void    cursor_to_selection_end   (Cursor *);
812
813         void    selected_marker_to_region_boundary (int32_t dir);
814         void    selected_marker_to_next_region_boundary ();
815         void    selected_marker_to_previous_region_boundary ();
816         void    selected_marker_to_next_region_point (ARDOUR::RegionPoint);
817         void    selected_marker_to_previous_region_point (ARDOUR::RegionPoint);
818         void    selected_marker_to_region_point (ARDOUR::RegionPoint, int32_t dir);
819         void    selected_marker_to_selection_start ();
820         void    selected_marker_to_selection_end   ();
821
822         void    select_all_selectables_using_cursor (Cursor *, bool);
823         void    select_all_selectables_using_edit (bool);
824         void    select_all_selectables_between (bool within);
825         void    select_range_between ();
826
827         boost::shared_ptr<ARDOUR::Region> find_next_region (nframes64_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
828         nframes64_t find_next_region_boundary (nframes64_t, int32_t dir, const TrackViewList&);
829
830         vector<nframes64_t> region_boundary_cache;
831         void build_region_boundary_cache ();
832
833         Gtk::HBox           top_hbox;
834         Gtk::HBox           bottom_hbox;
835         
836         Gtk::Table          edit_packer;
837         Gtk::VScrollbar     edit_vscrollbar;
838
839         Gtk::Adjustment     vertical_adjustment;
840         Gtk::Adjustment     horizontal_adjustment;
841
842         Gtk::Layout         controls_layout;
843         bool control_layout_scroll (GdkEventScroll* ev);
844         void controls_layout_size_request (Gtk::Requisition*);
845
846         Gtk::HScrollbar     edit_hscrollbar;
847         bool                _dragging_hscrollbar;
848
849         void reset_hscrollbar_stepping ();
850         
851         bool hscrollbar_button_press (GdkEventButton*);
852         bool hscrollbar_button_release (GdkEventButton*);
853         void hscrollbar_allocate (Gtk::Allocation &alloc);
854
855         double canvas_width;
856         double canvas_height;
857         double full_canvas_height;
858         nframes64_t last_canvas_frame;
859
860         bool track_canvas_map_handler (GdkEventAny*);
861         bool time_canvas_map_handler (GdkEventAny*);
862
863         gint edit_controls_button_release (GdkEventButton*);
864         Gtk::Menu *edit_controls_left_menu;
865         Gtk::Menu *edit_controls_right_menu;
866
867         Gtk::VBox           track_canvas_vbox;
868         Gtk::VBox           time_canvas_vbox;
869         Gtk::VBox           edit_controls_vbox;
870         Gtk::HBox           edit_controls_hbox;
871
872         void control_scroll (float);
873         void access_action (std::string,std::string);
874         bool deferred_control_scroll (nframes64_t);
875         sigc::connection control_scroll_connection;
876
877         void tie_vertical_scrolling ();
878         void canvas_horizontally_scrolled ();
879         void canvas_scroll_to (nframes64_t);
880
881         struct VisualChange {
882             enum Type { 
883                     TimeOrigin = 0x1,
884                     ZoomLevel = 0x2
885             };
886
887             Type pending;
888             nframes64_t time_origin;
889             double frames_per_unit;
890
891             int idle_handler_id;
892
893             VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), frames_per_unit (0), idle_handler_id (-1) {}
894         };
895
896
897         VisualChange pending_visual_change;
898
899         static int _idle_visual_changer (void *arg);
900         int idle_visual_changer ();
901
902         void queue_visual_change (nframes64_t);
903         void queue_visual_change (double);
904
905         void end_location_changed (ARDOUR::Location*);
906
907         struct RegionListDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
908             RegionListDisplayModelColumns() {
909                     add (name);
910                     add (region);
911                     add (color_);
912             }
913             Gtk::TreeModelColumn<Glib::ustring> name;
914             Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
915             Gtk::TreeModelColumn<Gdk::Color> color_;
916         };
917             
918         RegionListDisplayModelColumns          region_list_columns;
919         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > region_list_display;
920         
921         Glib::RefPtr<Gtk::TreeStore>           region_list_model;
922         Glib::RefPtr<Gtk::ToggleAction>        toggle_full_region_list_action;
923         Glib::RefPtr<Gtk::ToggleAction>        toggle_show_auto_regions_action;
924
925         void region_list_region_changed (ARDOUR::Change, boost::weak_ptr<ARDOUR::Region>);
926         void region_list_selection_changed ();
927         bool region_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
928         void region_name_edit (const Glib::ustring&, const Glib::ustring&);
929         void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions);
930
931         Gtk::Menu          *region_list_menu;
932         Gtk::ScrolledWindow region_list_scroller;
933         Gtk::Frame          region_list_frame;
934
935         bool region_list_display_key_press (GdkEventKey *);
936         bool region_list_display_key_release (GdkEventKey *);
937         bool region_list_display_button_press (GdkEventButton *);
938         bool region_list_display_button_release (GdkEventButton *);
939         void region_list_clear ();
940         void region_list_selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
941         void build_region_list_menu ();
942         void show_region_list_display_context_menu (int button, int time);
943
944         bool show_automatic_regions_in_region_list;
945         Editing::RegionListSortType region_list_sort_type;
946
947         void reset_region_list_sort_direction (bool);
948         void reset_region_list_sort_type (Editing::RegionListSortType);
949
950         void toggle_full_region_list ();
951         void toggle_show_auto_regions ();
952
953         int region_list_sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
954
955         /* snapshots */
956
957         Gtk::ScrolledWindow snapshot_display_scroller;
958         struct SnapshotDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
959             SnapshotDisplayModelColumns() { 
960                     add (visible_name);
961                     add (real_name);
962             }
963             Gtk::TreeModelColumn<Glib::ustring> visible_name;
964             Gtk::TreeModelColumn<Glib::ustring> real_name;
965         };
966
967         SnapshotDisplayModelColumns snapshot_display_columns;
968         Glib::RefPtr<Gtk::ListStore> snapshot_display_model;
969         Gtk::TreeView snapshot_display;
970         Gtk::Menu snapshot_context_menu;
971
972         bool snapshot_display_button_press (GdkEventButton*);
973         void snapshot_display_selection_changed ();
974         void redisplay_snapshots();
975         void popup_snapshot_context_menu (int, int32_t, Glib::ustring);
976
977         /* named selections */
978
979         struct NamedSelectionDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
980             NamedSelectionDisplayModelColumns() { 
981                     add (text);
982                     add (selection);
983             }
984             Gtk::TreeModelColumn<Glib::ustring>  text;
985             Gtk::TreeModelColumn<ARDOUR::NamedSelection*>    selection;
986         };
987
988         NamedSelectionDisplayModelColumns named_selection_columns;
989         Glib::RefPtr<Gtk::TreeStore>     named_selection_model;
990
991         Gtkmm2ext::DnDTreeView<ARDOUR::NamedSelection*> named_selection_display;
992         Gtk::ScrolledWindow    named_selection_scroller;
993
994         void create_named_selection ();
995         void paste_named_selection (float times);
996         void remove_selected_named_selections ();
997         void remove_snapshot (Glib::ustring);
998         void rename_snapshot (Glib::ustring);
999
1000         void handle_new_named_selection ();
1001         void add_named_selection_to_named_selection_display (ARDOUR::NamedSelection&);
1002         void redisplay_named_selections ();
1003
1004         bool named_selection_display_button_release (GdkEventButton *ev);
1005         bool named_selection_display_key_release (GdkEventKey *ev);
1006         void named_selection_display_selection_changed ();
1007
1008         /* track views */
1009         TrackViewList  track_views;
1010         TimeAxisView     *trackview_by_y_position (double ypos);
1011
1012         static Gdk::Cursor* cross_hair_cursor;
1013         static Gdk::Cursor* trimmer_cursor;
1014         static Gdk::Cursor* selector_cursor;
1015         static Gdk::Cursor* grabber_cursor;
1016         static Gdk::Cursor* grabber_edit_point_cursor;
1017         static Gdk::Cursor* zoom_cursor;
1018         static Gdk::Cursor* time_fx_cursor;
1019         static Gdk::Cursor* fader_cursor;
1020         static Gdk::Cursor* speaker_cursor;
1021         static Gdk::Cursor* midi_pencil_cursor;
1022         static Gdk::Cursor* midi_select_cursor;
1023         static Gdk::Cursor* midi_resize_cursor;
1024         static Gdk::Cursor* midi_erase_cursor;
1025         static Gdk::Cursor* wait_cursor;
1026         static Gdk::Cursor* timebar_cursor;
1027         static Gdk::Cursor* transparent_cursor;
1028
1029         static void build_cursors ();
1030
1031         sigc::connection scroll_connection;
1032         nframes64_t last_update_frame;
1033         void center_screen (nframes64_t);
1034         void center_screen_internal (nframes64_t, float);
1035         
1036         void update_current_screen ();
1037         
1038         void session_going_away ();
1039
1040         nframes64_t cut_buffer_start;
1041         nframes64_t cut_buffer_length;
1042
1043         bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
1044         bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1045         bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1046         bool motion_handler (ArdourCanvas::Item*, GdkEvent*, ItemType, bool from_autoscroll = false);
1047         bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1048         bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1049         
1050         /* KEYMAP HANDLING */
1051
1052         void register_actions ();
1053
1054         int ensure_cursor (nframes64_t* pos);
1055
1056         void handle_new_region (boost::weak_ptr<ARDOUR::Region>);
1057         void handle_new_regions (vector<boost::weak_ptr<ARDOUR::Region> >& );
1058         void handle_region_removed (boost::weak_ptr<ARDOUR::Region>);
1059         void add_region_to_region_display (boost::shared_ptr<ARDOUR::Region>);
1060         void add_regions_to_region_display (std::vector<boost::weak_ptr<ARDOUR::Region> > & );
1061         void region_hidden (boost::shared_ptr<ARDOUR::Region>);
1062         void redisplay_regions ();
1063         bool no_region_list_redisplay;
1064         void insert_into_tmp_regionlist(boost::shared_ptr<ARDOUR::Region>);
1065
1066         list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
1067
1068         void cut_copy (Editing::CutCopyOp);
1069         bool can_cut_copy () const;
1070         void cut_copy_points (Editing::CutCopyOp);
1071         void cut_copy_regions (Editing::CutCopyOp, RegionSelection&);
1072         void cut_copy_ranges (Editing::CutCopyOp);
1073
1074         void mouse_paste ();
1075         void paste_internal (nframes64_t position, float times);
1076
1077         /* EDITING OPERATIONS */
1078         
1079         void reset_point_selection ();
1080         void toggle_region_mute ();
1081         void toggle_region_lock ();
1082         void toggle_region_opaque ();
1083         void set_region_lock_style (ARDOUR::Region::PositionLockStyle);
1084         void raise_region ();
1085         void raise_region_to_top ();
1086         void lower_region ();
1087         void lower_region_to_bottom ();
1088         void split_region ();
1089         void split_region_at (nframes64_t);
1090         void split_regions_at (nframes64_t, RegionSelection&);
1091         void split_region_at_transients ();
1092         void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret);
1093         void crop_region_to_selection ();
1094         void crop_region_to (nframes64_t start, nframes64_t end);
1095         void set_sync_point (nframes64_t, const RegionSelection&);
1096         void set_region_sync_from_edit_point ();
1097         void remove_region_sync();
1098         void align_selection (ARDOUR::RegionPoint, nframes64_t position, const RegionSelection&);
1099         void align_selection_relative (ARDOUR::RegionPoint point, nframes64_t position, const RegionSelection&);
1100         void align_region (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes64_t position);
1101         void align_region_internal (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes64_t position);
1102         void remove_selected_regions ();
1103         void remove_clicked_region ();
1104         void edit_region ();
1105         void rename_region ();
1106         void duplicate_some_regions (RegionSelection&, float times);
1107         void duplicate_selection (float times);
1108         void region_fill_selection ();
1109
1110         void region_fill_track ();
1111         void audition_playlist_region_standalone (boost::shared_ptr<ARDOUR::Region>);
1112         void audition_playlist_region_via_route (boost::shared_ptr<ARDOUR::Region>, ARDOUR::Route&);
1113         void split_multichannel_region();
1114         void reverse_region ();
1115         void normalize_region ();
1116         void denormalize_region ();
1117         void adjust_region_scale_amplitude (bool up);
1118         void quantize_region ();
1119
1120         void do_insert_time ();
1121         void insert_time (nframes64_t pos, nframes64_t distance, Editing::InsertTimeOption opt, bool ignore_music_glue, bool markers_too);
1122
1123         void tab_to_transient (bool forward);
1124
1125         void use_region_as_bar ();
1126         void use_range_as_bar ();
1127
1128         void define_one_bar (nframes64_t start, nframes64_t end);
1129
1130         void audition_region_from_region_list ();
1131         void hide_region_from_region_list ();
1132         void remove_region_from_region_list ();
1133
1134         void align (ARDOUR::RegionPoint);
1135         void align_relative (ARDOUR::RegionPoint);
1136         void naturalize ();
1137
1138         void reset_focus ();
1139
1140         void split ();
1141
1142         void cut ();
1143         void copy ();
1144         void paste (float times);
1145
1146         int  get_prefix (float&, bool&);
1147
1148         void keyboard_paste ();
1149         void keyboard_insert_region_list_selection ();
1150
1151         void region_from_selection ();
1152         void create_region_from_selection (std::vector<boost::shared_ptr<ARDOUR::Region> >&);
1153
1154         void play_from_start ();
1155         void play_from_edit_point ();
1156         void play_from_edit_point_and_return ();
1157         void play_selected_region ();
1158         void play_edit_range ();
1159         void loop_selected_region ();
1160         void play_location (ARDOUR::Location&);
1161         void loop_location (ARDOUR::Location&);
1162
1163         void temporal_zoom_selection ();
1164         void temporal_zoom_region (bool both_axes);
1165         void toggle_zoom_region (bool both_axes);
1166         bool zoomed_to_region;
1167         void temporal_zoom_session ();
1168         void temporal_zoom (gdouble scale);
1169         void temporal_zoom_by_frame (nframes64_t start, nframes64_t end, const string & op);
1170         void temporal_zoom_to_frame (bool coarser, nframes64_t frame);
1171
1172         void amplitude_zoom (gdouble scale);
1173         void amplitude_zoom_step (bool in);
1174
1175         void insert_region_list_drag (boost::shared_ptr<ARDOUR::Region>, int x, int y);
1176         void insert_region_list_selection (float times);
1177
1178         void insert_route_list_drag (boost::shared_ptr<ARDOUR::Route>, int x, int y);
1179
1180         /* import & embed */
1181         
1182         void add_external_audio_action (Editing::ImportMode);
1183         void external_audio_dialog ();
1184
1185         int  check_whether_and_how_to_import(string, bool all_or_nothing = true);
1186         bool check_multichannel_status (const std::vector<Glib::ustring>& paths);
1187
1188         SoundFileOmega* sfbrowser;
1189         
1190         void bring_in_external_audio (Editing::ImportMode mode,  nframes64_t& pos);
1191
1192         void _do_import (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t&);
1193         void do_import (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t&);
1194         bool idle_do_import (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t&);
1195
1196         void _do_embed (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode,  nframes64_t&);
1197         void do_embed (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode,  nframes64_t&);
1198         bool idle_do_embed (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode,  nframes64_t&);
1199
1200         int  import_sndfiles (vector<Glib::ustring> paths, Editing::ImportMode mode,  ARDOUR::SrcQuality, nframes64_t& pos,
1201                               int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool);
1202         int  embed_sndfiles (vector<Glib::ustring> paths, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode, 
1203                              nframes64_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&);
1204
1205         int add_sources (vector<Glib::ustring> paths, ARDOUR::SourceList& sources, nframes64_t& pos, Editing::ImportMode,
1206                          int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool add_channel_suffix);
1207         int finish_bringing_in_material (boost::shared_ptr<ARDOUR::Region> region, uint32_t, uint32_t,  nframes64_t& pos, Editing::ImportMode mode,
1208                                       boost::shared_ptr<ARDOUR::Track>& existing_track);
1209
1210         boost::shared_ptr<ARDOUR::AudioTrack> get_nth_selected_audio_track (int nth) const;
1211         boost::shared_ptr<ARDOUR::MidiTrack> get_nth_selected_midi_track (int nth) const;
1212
1213         /* generic interthread progress window */
1214         
1215         ArdourDialog* interthread_progress_window;
1216         Gtk::Label interthread_progress_label;
1217         Gtk::VBox interthread_progress_vbox;
1218         Gtk::ProgressBar interthread_progress_bar;
1219         Gtk::Button interthread_cancel_button;
1220         Gtk::Label interthread_cancel_label;
1221         sigc::connection  interthread_progress_connection;
1222         void interthread_cancel_clicked ();
1223         void build_interthread_progress_window ();
1224         ARDOUR::InterThreadInfo* current_interthread_info;
1225
1226 #ifdef FFT_ANALYSIS
1227         AnalysisWindow* analysis_window;
1228 #endif
1229
1230         /* import specific info */
1231
1232         ARDOUR::Session::import_status import_status;
1233         gint import_progress_timeout (void *);
1234         static void *_import_thread (void *);
1235         void* import_thread ();
1236
1237         /* to support this ... */
1238
1239         void import_audio (bool as_tracks);
1240         void do_import (vector<Glib::ustring> paths, bool split, bool as_tracks);
1241
1242         void move_to_start ();
1243         void move_to_end ();
1244         void goto_frame ();
1245         void center_playhead ();
1246         void center_edit_point ();
1247         void edit_cursor_backward ();
1248         void edit_cursor_forward ();
1249         void playhead_forward_to_grid ();
1250         void playhead_backward_to_grid ();
1251         void playhead_backward ();
1252         void playhead_forward ();
1253         void scroll_playhead (bool forward);
1254         void scroll_backward (float pages=0.8f);
1255         void scroll_forward (float pages=0.8f);
1256         void scroll_tracks_down ();
1257         void scroll_tracks_up ();
1258         void delete_sample_forward ();
1259         void delete_sample_backward ();
1260         void delete_screen ();
1261         void search_backwards ();
1262         void search_forwards ();
1263         void set_mark ();
1264         void clear_markers ();
1265         void clear_ranges ();
1266         void clear_locations ();
1267         void unhide_markers ();
1268         void unhide_ranges ();
1269         void jump_forward_to_mark ();
1270         void jump_backward_to_mark ();
1271         void cursor_align (bool playhead_to_edit);
1272
1273         void remove_last_capture ();
1274         void select_all_selectables_using_time_selection ();
1275         void select_all_selectables_using_loop();
1276         void select_all_selectables_using_punch();
1277         void set_selection_from_range (ARDOUR::Location&);
1278         void set_selection_from_punch ();
1279         void set_selection_from_loop ();
1280         void set_selection_from_region ();
1281
1282         void add_location_mark (nframes64_t where);
1283         void add_location_from_audio_region ();
1284         void add_location_from_selection ();
1285         void set_loop_from_selection (bool play);
1286         void set_punch_from_selection ();
1287         void set_punch_from_region ();
1288
1289         void set_loop_from_edit_range (bool play);
1290         void set_loop_from_region (bool play);
1291         void set_punch_from_edit_range ();
1292
1293         void set_loop_range (nframes64_t start, nframes64_t end, std::string cmd);
1294         void set_punch_range (nframes64_t start, nframes64_t end, std::string cmd);
1295
1296         void add_location_from_playhead_cursor ();
1297         bool select_new_marker;
1298
1299         void reverse_selection ();
1300         void edit_envelope ();
1301
1302         void start_scrolling ();
1303         void stop_scrolling ();
1304
1305         bool _scrubbing;
1306         double last_scrub_x;
1307         int scrubbing_direction;
1308         int scrub_reversals;
1309         int scrub_reverse_distance;
1310         void scrub ();
1311
1312         void keyboard_selection_begin ();
1313         void keyboard_selection_finish (bool add);
1314         bool have_pending_keyboard_selection;
1315         nframes64_t pending_keyboard_selection_start;
1316
1317         boost::shared_ptr<ARDOUR::Region> select_region_for_operation (int dir, TimeAxisView **tv);
1318         void extend_selection_to_end_of_region (bool next);
1319         void extend_selection_to_start_of_region (bool previous);
1320
1321         Editing::SnapType snap_type;
1322         Editing::SnapMode snap_mode;
1323
1324         /// Snap threshold in pixels
1325         double snap_threshold;
1326
1327         void handle_gui_changes (const string &, void *);
1328
1329         void    hide_all_tracks (bool with_select);
1330
1331         DragInfo drag_info;
1332         LineDragInfo current_line_drag_info;
1333
1334         void start_grab (GdkEvent*, Gdk::Cursor* cursor = 0);
1335         bool end_grab (ArdourCanvas::Item*, GdkEvent*);
1336         void swap_grab (ArdourCanvas::Item*, Gdk::Cursor* cursor, uint32_t time);
1337         void break_drag ();
1338         void finalize_drag ();
1339
1340         Gtk::Menu fade_context_menu;
1341         void popup_fade_context_menu (int, int, ArdourCanvas::Item*, ItemType);
1342
1343         void start_fade_in_grab (ArdourCanvas::Item*, GdkEvent*);
1344         void start_fade_out_grab (ArdourCanvas::Item*, GdkEvent*);
1345         void fade_in_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1346         void fade_out_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1347         void fade_in_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1348         void fade_out_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1349
1350         void set_fade_in_shape (ARDOUR::AudioRegion::FadeShape);
1351         void set_fade_out_shape (ARDOUR::AudioRegion::FadeShape);
1352         
1353         void set_fade_length (bool in);
1354         void toggle_fade_active (bool in);
1355         void set_fade_in_active (bool);
1356         void set_fade_out_active (bool);
1357         
1358         std::set<boost::shared_ptr<ARDOUR::Playlist> > motion_frozen_playlists;
1359         RegionSelection pre_drag_region_selection;
1360         void region_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1361         void region_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1362         void create_region_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1363         void create_region_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1364         bool check_region_drag_possible (RouteTimeAxisView**);
1365         void possibly_copy_regions_during_grab (GdkEvent*);
1366         void region_drag_splice_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1367         void region_drag_splice_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1368
1369         bool _dragging_playhead;
1370         bool _dragging_edit_point;
1371
1372         void cursor_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1373         void cursor_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1374         void marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1375         void marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1376         void control_point_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1377         void control_point_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1378         void line_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1379         void line_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1380
1381         void tempo_marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1382         void tempo_marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1383         void meter_marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1384         void meter_marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1385
1386         gint mouse_rename_region (ArdourCanvas::Item*, GdkEvent*);
1387
1388         void start_region_grab (ArdourCanvas::Item*, GdkEvent*);
1389         void start_create_region_grab (ArdourCanvas::Item*, GdkEvent*);
1390         void start_region_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1391         void start_region_brush_grab (ArdourCanvas::Item*, GdkEvent*);
1392         void start_selection_grab (ArdourCanvas::Item*, GdkEvent*);
1393         void start_cursor_grab (ArdourCanvas::Item*, GdkEvent*);
1394         void start_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1395         void start_control_point_grab (ArdourCanvas::Item*, GdkEvent*);
1396         void start_line_grab_from_regionview (ArdourCanvas::Item*, GdkEvent*);
1397         void start_line_grab_from_line (ArdourCanvas::Item*, GdkEvent*);
1398         void start_line_grab (AutomationLine *, GdkEvent*);
1399         void start_tempo_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1400         void start_tempo_marker_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1401         void start_meter_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1402         void start_meter_marker_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1403
1404         void region_view_item_click (AudioRegionView&, GdkEventButton*);
1405
1406         void remove_gain_control_point (ArdourCanvas::Item*, GdkEvent*);
1407         void remove_control_point (ArdourCanvas::Item*, GdkEvent*);
1408
1409         void mouse_brush_insert_region (RegionView*, nframes64_t pos);
1410         void brush (nframes64_t);
1411
1412         void show_verbose_time_cursor (nframes64_t frame, double offset = 0, double xpos=-1, double ypos=-1);
1413         void show_verbose_duration_cursor (nframes64_t start, nframes64_t end, double offset = 0, double xpos=-1, double ypos=-1);
1414         double clamp_verbose_cursor_x (double);
1415         double clamp_verbose_cursor_y (double);
1416
1417         /* Canvas event handlers */
1418
1419         bool canvas_control_point_event (GdkEvent* event,ArdourCanvas::Item*, ControlPoint*);
1420         bool canvas_line_event (GdkEvent* event,ArdourCanvas::Item*, AutomationLine*);
1421         bool canvas_selection_rect_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1422         bool canvas_selection_start_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1423         bool canvas_selection_end_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1424         bool canvas_crossfade_view_event (GdkEvent* event,ArdourCanvas::Item*, CrossfadeView*);
1425         bool canvas_fade_in_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1426         bool canvas_fade_in_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1427         bool canvas_fade_out_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1428         bool canvas_fade_out_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1429         
1430
1431         // These variables are used to detect a feedback loop and break it to avoid a gui hang
1432 private:
1433         ArdourCanvas::Item *last_item_entered;
1434         int last_item_entered_n;
1435 public:
1436
1437         bool canvas_region_view_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1438         bool canvas_region_view_name_highlight_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1439         bool canvas_region_view_name_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1440         bool canvas_stream_view_event (GdkEvent* event,ArdourCanvas::Item*, RouteTimeAxisView*);
1441         bool canvas_marker_event (GdkEvent* event,ArdourCanvas::Item*, Marker*);
1442         bool canvas_zoom_rect_event (GdkEvent* event,ArdourCanvas::Item*);
1443         bool canvas_tempo_marker_event (GdkEvent* event,ArdourCanvas::Item*, TempoMarker*);
1444         bool canvas_meter_marker_event (GdkEvent* event,ArdourCanvas::Item*, MeterMarker*);
1445         bool canvas_automation_track_event(GdkEvent* event, ArdourCanvas::Item*, AutomationTimeAxisView*) ;
1446
1447         bool canvas_tempo_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1448         bool canvas_meter_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1449         bool canvas_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1450         bool canvas_range_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1451         bool canvas_transport_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1452         bool canvas_cd_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1453
1454         bool canvas_imageframe_item_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1455         bool canvas_imageframe_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameTimeAxis*);
1456         bool canvas_imageframe_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1457         bool canvas_imageframe_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1458         bool canvas_marker_time_axis_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerTimeAxis*);
1459         bool canvas_markerview_item_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1460         bool canvas_markerview_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1461         bool canvas_markerview_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1462
1463         /* non-public event handlers */
1464
1465         bool canvas_playhead_cursor_event (GdkEvent* event, ArdourCanvas::Item*);
1466         bool track_canvas_scroll (GdkEventScroll* event);
1467         bool time_canvas_scroll (GdkEventScroll* event);
1468
1469         bool track_canvas_scroll_event (GdkEventScroll* event);
1470         bool track_canvas_button_press_event (GdkEventButton* event);
1471         bool track_canvas_button_release_event (GdkEventButton* event);
1472         bool track_canvas_motion_notify_event (GdkEventMotion* event);
1473
1474         bool time_canvas_scroll_event (GdkEventScroll* event);
1475
1476         Gtk::Allocation canvas_allocation;
1477         bool canvas_idle_queued;
1478         void track_canvas_allocate (Gtk::Allocation alloc);
1479         bool track_canvas_size_allocated ();
1480
1481         void set_playhead_cursor ();
1482
1483         void kbd_driver (sigc::slot<void,GdkEvent*>, bool use_track_canvas = true, bool use_time_canvas = true, bool can_select = true);
1484         void kbd_mute_unmute_region ();
1485         void kbd_brush ();
1486
1487         void kbd_do_brush (GdkEvent*);
1488         void kbd_do_audition (GdkEvent*);
1489
1490         void handle_new_duration ();
1491         void initialize_canvas ();
1492         int canvas_hroizontally_scrolled_handler_id;
1493         void reset_horizontally_scrolling_region (Gtk::Allocation* alloc = 0);
1494         void reset_scrolling_region (Gtk::Allocation* alloc = 0);
1495
1496         /* display control */
1497         
1498         bool _show_measures;
1499         /// true to show waveforms, otherwise false
1500         bool _show_waveforms;
1501         /// true if the editor should follow the playhead, otherwise false
1502         bool _follow_playhead;
1503         /// true if waveforms should be shown while recording audio tracks, otherwise false
1504         bool _show_waveforms_recording;
1505         
1506         ARDOUR::TempoMap::BBTPointList *current_bbt_points;
1507         
1508         ArdourCanvas::Group* time_line_group;
1509         ArdourCanvas::Group* marker_time_line_group;
1510         
1511         TempoLines* tempo_lines;
1512         TempoLines* marker_tempo_lines;
1513
1514         void hide_measures ();
1515         void draw_measures ();
1516         bool redraw_measures ();
1517
1518         void new_tempo_section ();
1519
1520         void mouse_add_new_tempo_event (nframes64_t where);
1521         void mouse_add_new_meter_event (nframes64_t where);
1522
1523         void remove_tempo_marker (ArdourCanvas::Item*);
1524         void remove_meter_marker (ArdourCanvas::Item*);
1525         gint real_remove_tempo_marker (ARDOUR::TempoSection*);
1526         gint real_remove_meter_marker (ARDOUR::MeterSection*);
1527         
1528         void edit_tempo_section (ARDOUR::TempoSection*);
1529         void edit_meter_section (ARDOUR::MeterSection*);
1530         void edit_tempo_marker (ArdourCanvas::Item*);
1531         void edit_meter_marker (ArdourCanvas::Item*);
1532         
1533         void marker_menu_edit ();
1534         void marker_menu_remove ();
1535         void marker_menu_rename ();
1536         void marker_menu_lock (bool yn);
1537         void marker_menu_hide ();
1538         void marker_menu_loop_range ();
1539         void marker_menu_select_all_selectables_using_range ();
1540         void marker_menu_select_using_range ();
1541         void marker_menu_separate_regions_using_location ();
1542         void marker_menu_play_from ();
1543         void marker_menu_play_range ();
1544         void marker_menu_set_playhead ();
1545         void marker_menu_set_from_playhead ();
1546         void marker_menu_set_from_selection ();
1547         void marker_menu_range_to_next ();
1548         void marker_menu_export_range ();
1549         void new_transport_marker_menu_set_loop ();
1550         void new_transport_marker_menu_set_punch ();
1551         void update_loop_range_view (bool visibility=false);
1552         void update_punch_range_view (bool visibility=false);
1553         gint new_transport_marker_menu_popdown (GdkEventAny*);
1554         void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1555         void tm_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1556         void transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1557         void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1558         void build_range_marker_menu (bool loop_or_punch);
1559         void build_marker_menu (bool start_or_end);
1560         void build_tm_marker_menu ();
1561         void build_new_transport_marker_menu ();
1562
1563         Gtk::Menu* tm_marker_menu;
1564         Gtk::Menu* marker_menu;
1565         Gtk::Menu* start_end_marker_menu;
1566         Gtk::Menu* range_marker_menu;
1567         Gtk::Menu* transport_marker_menu;
1568         Gtk::Menu* new_transport_marker_menu;
1569         Gtk::Menu* cd_marker_menu;
1570         ArdourCanvas::Item* marker_menu_item;
1571
1572         typedef list<Marker*> Marks;
1573         Marks metric_marks;
1574
1575         void remove_metric_marks ();
1576         void draw_metric_marks (const ARDOUR::Metrics& metrics);
1577
1578         void compute_current_bbt_points (nframes_t left, nframes_t right);
1579         int tempo_map_change_idle_handler_id;
1580         void tempo_map_changed (ARDOUR::Change);
1581         void redisplay_tempo (bool immediate_redraw);
1582         
1583         void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
1584         
1585         double snap_length_beats (nframes64_t start);
1586
1587         uint32_t bbt_beat_subdivision;
1588
1589         /* toolbar */
1590         
1591         Gtk::ToggleButton editor_mixer_button;
1592         Gtk::ToggleButton editor_list_button;
1593
1594         void editor_mixer_button_toggled ();
1595         void editor_list_button_toggled ();
1596
1597         AudioClock               edit_point_clock;
1598         AudioClock               zoom_range_clock;
1599         Gtk::Button              zoom_in_button;
1600         Gtk::Button              zoom_out_button;
1601         Gtk::Button              zoom_out_full_button;
1602         Gtk::Button              zoom_onetoone_button;
1603
1604         Gtk::VBox                toolbar_clock_vbox;
1605         Gtk::VBox                toolbar_selection_clock_vbox; 
1606         Gtk::Table               toolbar_selection_clock_table;
1607         Gtk::Label               toolbar_selection_cursor_label;
1608         
1609         Gtk::HBox                mouse_mode_button_box;
1610         Gtkmm2ext::TearOff*      mouse_mode_tearoff;
1611         Gtk::ToggleButton        mouse_select_button;
1612         Gtk::ToggleButton        mouse_move_button;
1613         Gtk::ToggleButton        mouse_gain_button;
1614         Gtk::ToggleButton        mouse_zoom_button;
1615         Gtk::ToggleButton        mouse_timefx_button;
1616         Gtk::ToggleButton        mouse_audition_button;
1617         Gtk::ToggleButton        mouse_note_button;
1618         GroupedButtons          *mouse_mode_button_set;
1619         void                     mouse_mode_toggled (Editing::MouseMode m);
1620         bool                     ignore_mouse_mode_toggle;
1621
1622         gint                     mouse_select_button_release (GdkEventButton*);
1623
1624         Gtk::VBox                automation_box;
1625         Gtk::Button              automation_mode_button;
1626         Gtk::ToggleButton        global_automation_button;
1627
1628         Gtk::ComboBoxText edit_mode_selector;
1629         Gtk::VBox         edit_mode_box;
1630
1631         void set_edit_mode (ARDOUR::EditMode);
1632         void cycle_edit_mode ();
1633         void edit_mode_selection_done ();
1634
1635         Gtk::ComboBoxText snap_type_selector;
1636         Gtk::ComboBoxText snap_mode_selector;
1637         Gtk::HBox         snap_box;
1638
1639         std::vector<std::string> snap_type_strings;
1640         std::vector<std::string> snap_mode_strings;
1641
1642         void snap_type_selection_done ();
1643         void snap_mode_selection_done ();
1644         void snap_mode_chosen (Editing::SnapMode);
1645         void snap_type_chosen (Editing::SnapType);
1646
1647         Glib::RefPtr<Gtk::RadioAction> snap_type_action (Editing::SnapType);
1648         Glib::RefPtr<Gtk::RadioAction> snap_mode_action (Editing::SnapMode);
1649
1650         Gtk::ComboBoxText zoom_focus_selector;
1651         Gtk::VBox         zoom_focus_box;
1652
1653         std::vector<std::string> zoom_focus_strings;
1654         
1655         void zoom_focus_selection_done ();
1656         void zoom_focus_chosen (Editing::ZoomFocus);
1657
1658         Glib::RefPtr<Gtk::RadioAction> zoom_focus_action (Editing::ZoomFocus);
1659
1660         Gtk::HBox           zoom_box;
1661
1662         void                zoom_adjustment_changed();
1663
1664         void                edit_point_clock_changed();
1665         
1666         void setup_toolbar ();
1667
1668         Gtkmm2ext::TearOff*      tools_tearoff;
1669         Gtk::HBox                toolbar_hbox;
1670         Gtk::EventBox            toolbar_base;
1671         Gtk::Frame               toolbar_frame;
1672
1673         /* midi toolbar */
1674
1675         Gtk::HBox                midi_tool_button_box;
1676         Gtkmm2ext::TearOff*      midi_tool_tearoff;
1677         Gtk::ToggleButton        midi_tool_pencil_button;
1678         Gtk::ToggleButton        midi_tool_select_button;
1679         Gtk::ToggleButton        midi_tool_resize_button;
1680         Gtk::ToggleButton        midi_tool_erase_button;
1681         GroupedButtons          *midi_tool_button_set;
1682         void                     midi_edit_mode_toggled (Editing::MidiEditMode m);
1683         bool                     ignore_midi_edit_mode_toggle;
1684
1685         Gtkmm2ext::TearOff* midi_tools_tearoff;
1686         Gtk::HBox           midi_toolbar_hbox;
1687         Gtk::EventBox       midi_toolbar_base;
1688         Gtk::Frame          midi_toolbar_frame;
1689         
1690         void setup_midi_toolbar ();
1691
1692         /* selection process */
1693
1694         Selection* selection;
1695         Selection* cut_buffer;
1696
1697         void time_selection_changed ();
1698         void track_selection_changed ();
1699         void region_selection_changed ();
1700         void sensitize_the_right_region_actions (bool have_selected_regions);
1701         void point_selection_changed ();
1702         void marker_selection_changed ();
1703
1704         enum SelectionOp {
1705                 CreateSelection,
1706                 SelectionStartTrim,
1707                 SelectionEndTrim,
1708                 SelectionMove
1709         } selection_op;
1710
1711         void start_selection_op (ArdourCanvas::Item* item, GdkEvent* event, SelectionOp);
1712         void drag_selection (ArdourCanvas::Item* item, GdkEvent* event);
1713         void end_selection_op (ArdourCanvas::Item* item, GdkEvent* event);
1714         void cancel_selection ();
1715
1716         void region_selection_op (void (ARDOUR::Region::*pmf)(void));
1717         void region_selection_op (void (ARDOUR::Region::*pmf)(void*), void*);
1718         void region_selection_op (void (ARDOUR::Region::*pmf)(bool), bool);
1719
1720         bool audio_region_selection_covers (nframes64_t where);
1721
1722         /* transport range select process */
1723         enum RangeMarkerOp {
1724                 CreateRangeMarker,
1725                 CreateTransportMarker,
1726                 CreateCDMarker
1727         } range_marker_op;
1728
1729         void start_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event, RangeMarkerOp);
1730         void drag_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event);
1731         void end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event);
1732
1733         ArdourCanvas::SimpleRect*  cd_marker_bar_drag_rect;
1734         ArdourCanvas::SimpleRect*  range_bar_drag_rect;
1735         ArdourCanvas::SimpleRect*  transport_bar_drag_rect;
1736         ArdourCanvas::Line*        marker_drag_line;
1737         ArdourCanvas::Points       marker_drag_line_points;
1738         ArdourCanvas::SimpleRect*  range_marker_drag_rect;
1739
1740         void update_marker_drag_item (ARDOUR::Location *);
1741         
1742         ArdourCanvas::SimpleRect     *transport_bar_range_rect;
1743         ArdourCanvas::SimpleRect     *transport_bar_preroll_rect;
1744         ArdourCanvas::SimpleRect     *transport_bar_postroll_rect;
1745         ArdourCanvas::SimpleRect     *transport_loop_range_rect;
1746         ArdourCanvas::SimpleRect     *transport_punch_range_rect;
1747         ArdourCanvas::SimpleLine     *transport_punchin_line;
1748         ArdourCanvas::SimpleLine     *transport_punchout_line;
1749         ArdourCanvas::SimpleRect     *transport_preroll_rect;
1750         ArdourCanvas::SimpleRect     *transport_postroll_rect;
1751
1752         ARDOUR::Location*  transport_loop_location();
1753         ARDOUR::Location*  transport_punch_location();
1754
1755         ARDOUR::Location   *temp_location;
1756         
1757         /* object rubberband select process */
1758         
1759         void start_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1760         void drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1761         void end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1762
1763         bool select_all_within (nframes64_t start, nframes64_t end, gdouble topy, gdouble boty, const TrackViewList&, Selection::Operation op);
1764         
1765         ArdourCanvas::SimpleRect   *rubberband_rect;
1766         
1767         /* mouse zoom process */
1768
1769         void start_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1770         void drag_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1771         void end_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1772
1773         ArdourCanvas::SimpleRect   *zoom_rect;
1774         void reposition_zoom_rect (nframes64_t start, nframes64_t end);
1775         
1776         /* diskstream/route display management */
1777
1778         struct RouteDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
1779             RouteDisplayModelColumns() { 
1780                     add (text);
1781                     add (visible);
1782                     add (temporary_visible);
1783                     add (tv);
1784                     add (route);
1785             }
1786             Gtk::TreeModelColumn<Glib::ustring>  text;
1787             Gtk::TreeModelColumn<bool>           visible;
1788             Gtk::TreeModelColumn<bool>           temporary_visible;
1789             Gtk::TreeModelColumn<TimeAxisView*>  tv;
1790             Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> >  route;
1791         };
1792
1793         RouteDisplayModelColumns         route_display_columns;
1794         Glib::RefPtr<Gtk::ListStore>     route_display_model;
1795         Glib::RefPtr<Gtk::TreeSelection> route_display_selection;
1796
1797         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Route> > route_list_display; 
1798         Gtk::ScrolledWindow                   route_list_scroller;
1799         Gtk::Menu*                            route_list_menu;
1800
1801         void update_route_visibility ();
1802
1803         void sync_order_keys ();
1804         bool ignore_route_order_sync;
1805
1806         bool route_list_display_button_press (GdkEventButton*);
1807         void route_list_display_drag_data_received  (const Glib::RefPtr<Gdk::DragContext>& context,
1808                                                      gint                x,
1809                                                      gint                y,
1810                                                      const Gtk::SelectionData& data,
1811                                                      guint               info,
1812                                                      guint               time);
1813
1814         bool route_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
1815
1816         void route_list_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
1817         void route_list_delete (const Gtk::TreeModel::Path&);
1818         void track_list_reorder (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* new_order);
1819
1820         void initial_route_list_display ();
1821         void redisplay_route_list();
1822         void route_list_reordered (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* what);
1823         bool ignore_route_list_reorder;
1824         bool no_route_list_redisplay;
1825
1826         void build_route_list_menu ();
1827         void show_route_list_menu ();
1828
1829         void show_all_routes ();
1830         void hide_all_routes ();
1831         void show_all_audiotracks ();
1832         void hide_all_audiotracks ();
1833         void show_all_audiobus ();
1834         void hide_all_audiobus ();
1835
1836         void set_all_tracks_visibility (bool yn);
1837         void set_all_audio_visibility (int type, bool yn);
1838
1839         /* edit group management */
1840
1841         struct GroupListModelColumns : public Gtk::TreeModel::ColumnRecord {
1842                 GroupListModelColumns () {
1843                        add (is_active);
1844                        add (is_visible);
1845                        add (text);
1846                        add (routegroup);
1847                 }
1848                 Gtk::TreeModelColumn<bool> is_active;
1849                 Gtk::TreeModelColumn<bool> is_visible;
1850                 Gtk::TreeModelColumn<std::string> text;
1851                 Gtk::TreeModelColumn<ARDOUR::RouteGroup*>   routegroup;
1852         };
1853
1854         GroupListModelColumns group_columns;
1855         Glib::RefPtr<Gtk::ListStore> group_model;
1856         Glib::RefPtr<Gtk::TreeSelection> group_selection;
1857
1858         Gtk::TreeView          edit_group_display;
1859         Gtk::ScrolledWindow    edit_group_display_scroller;
1860         Gtk::Menu*             edit_group_list_menu;
1861
1862         void build_edit_group_list_menu ();
1863         void activate_all_edit_groups ();
1864         void disable_all_edit_groups ();
1865
1866         bool in_edit_group_row_change;
1867         void edit_group_row_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
1868         void edit_group_name_edit (const Glib::ustring&, const Glib::ustring&);
1869         void new_edit_group ();
1870         void edit_group_list_button_clicked ();
1871         gint edit_group_list_button_press_event (GdkEventButton* ev);
1872         void add_edit_group (ARDOUR::RouteGroup* group);
1873         void remove_selected_edit_group ();
1874         void edit_groups_changed ();
1875         void group_flags_changed (void*, ARDOUR::RouteGroup*);
1876
1877         Gtk::VBox           list_vpacker;
1878
1879         /* autoscrolling */
1880
1881         bool autoscroll_active;
1882         int autoscroll_timeout_tag;
1883         int autoscroll_x;
1884         int autoscroll_y;
1885         int last_autoscroll_x;
1886         int last_autoscroll_y;
1887         uint32_t autoscroll_cnt;
1888         nframes64_t autoscroll_x_distance;
1889         double autoscroll_y_distance;
1890      
1891         static gint _autoscroll_canvas (void *);
1892         bool autoscroll_canvas ();
1893         void start_canvas_autoscroll (int x, int y);
1894         void stop_canvas_autoscroll ();
1895         void maybe_autoscroll (GdkEventMotion*);
1896         bool allow_vertical_scroll;
1897
1898         /* trimming */
1899         enum TrimOp {
1900                 StartTrim,
1901                 EndTrim,
1902                 ContentsTrim,
1903         } trim_op;
1904
1905         void start_trim (ArdourCanvas::Item*, GdkEvent*);
1906         void point_trim (GdkEvent*);
1907         void trim_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1908         void single_contents_trim (RegionView&, nframes64_t, bool, bool, bool);
1909         void single_start_trim (RegionView&, nframes64_t, bool, bool);
1910         void single_end_trim (RegionView&, nframes64_t, bool, bool);
1911
1912         void trim_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1913         void thaw_region_after_trim (RegionView& rv);
1914
1915         void trim_region_front();
1916         void trim_region_back();
1917         void trim_region (bool front);
1918
1919         void trim_region_to_edit_point ();
1920         void trim_region_from_edit_point ();
1921         void trim_region_to_loop ();
1922         void trim_region_to_punch ();
1923         void trim_region_to_location (const ARDOUR::Location&, const char* cmd);
1924
1925         bool show_gain_after_trim;
1926
1927         /* Drag-n-Drop */
1928
1929         int convert_drop_to_paths (std::vector<Glib::ustring>& paths,
1930                                    const Glib::RefPtr<Gdk::DragContext>& context,
1931                                    gint                x,
1932                                    gint                y,
1933                                    const Gtk::SelectionData& data,
1934                                    guint               info,
1935                                    guint               time);
1936
1937         void  track_canvas_drag_data_received  (const Glib::RefPtr<Gdk::DragContext>& context,
1938                                                 gint                x,
1939                                                 gint                y,
1940                                                 const Gtk::SelectionData& data,
1941                                                 guint               info,
1942                                                 guint               time);
1943         
1944         void  region_list_display_drag_data_received  (const Glib::RefPtr<Gdk::DragContext>& context,
1945                                                        gint                x,
1946                                                        gint                y,
1947                                                        const Gtk::SelectionData& data,
1948                                                        guint               info,
1949                                                        guint               time);
1950
1951
1952         void  drop_paths  (const Glib::RefPtr<Gdk::DragContext>& context,
1953                            gint                x,
1954                            gint                y,
1955                            const Gtk::SelectionData& data,
1956                            guint               info,
1957                            guint               time);
1958
1959         void  drop_regions  (const Glib::RefPtr<Gdk::DragContext>& context,
1960                              gint                x,
1961                              gint                y,
1962                              const Gtk::SelectionData& data,
1963                              guint               info,
1964                              guint               time);
1965
1966         void  drop_routes (const Glib::RefPtr<Gdk::DragContext>& context,
1967                            gint                x,
1968                            gint                y,
1969                            const Gtk::SelectionData& data,
1970                            guint               info,
1971                            guint               time);
1972
1973         /* audio export */
1974
1975         ExportDialog *export_dialog;
1976         ExportDialog *export_range_markers_dialog;
1977         
1978         void export_range (nframes64_t start, nframes64_t end);
1979         void export_range_markers ();
1980
1981         int  write_region_selection(RegionSelection&);
1982         bool write_region (string path, boost::shared_ptr<ARDOUR::AudioRegion>);
1983         void export_region ();
1984         void bounce_region_selection ();
1985         void bounce_range_selection (bool replace);
1986         void external_edit_region ();
1987
1988         int write_audio_selection (TimeSelection&);
1989         bool write_audio_range (ARDOUR::AudioPlaylist&, const ARDOUR::ChanCount& channels, list<ARDOUR::AudioRange>&);
1990
1991         void write_selection ();
1992
1993         /* history */
1994
1995         UndoAction get_memento() const;
1996
1997         XMLNode *before; /* used in *_reversible_command */
1998
1999         void begin_reversible_command (string cmd_name);
2000         void commit_reversible_command ();
2001
2002         void update_title ();   
2003         void update_title_s (const string & snapshot_name);
2004
2005         struct State {
2006             Selection* selection;
2007             double frames_per_unit;
2008
2009             State (PublicEditor const * e);
2010             ~State ();
2011         };
2012
2013         void store_state (State&) const;
2014         void restore_state (State *);
2015
2016         void instant_save ();
2017
2018         boost::shared_ptr<ARDOUR::AudioRegion> last_audition_region;
2019         
2020         /* freeze operations */
2021
2022         ARDOUR::InterThreadInfo freeze_status;
2023         gint freeze_progress_timeout (void *);
2024         static void* _freeze_thread (void*);
2025         void* freeze_thread ();
2026
2027         void freeze_route ();
2028         void unfreeze_route ();
2029
2030         /* edit-group solo + mute */
2031
2032         void set_edit_group_solo (ARDOUR::Route&, bool);
2033         void set_edit_group_mute (ARDOUR::Route&, bool);
2034
2035         /* duplication */
2036
2037         void duplicate_dialog (bool with_dialog);
2038         
2039         nframes64_t event_frame (GdkEvent*, double* px = 0, double* py = 0) const;
2040
2041         /* returns false if mouse pointer is not in track or marker canvas
2042          */
2043         bool mouse_frame (nframes64_t&, bool& in_track_canvas) const;
2044
2045         void time_fx_motion (ArdourCanvas::Item*, GdkEvent*);
2046         void start_time_fx (ArdourCanvas::Item*, GdkEvent*);
2047         void end_time_fx (ArdourCanvas::Item*, GdkEvent*);
2048
2049         struct TimeFXDialog : public ArdourDialog {
2050             ARDOUR::TimeFXRequest request;
2051             Editor&               editor;
2052             bool                  pitching;
2053             Gtk::Adjustment       pitch_octave_adjustment;
2054             Gtk::Adjustment       pitch_semitone_adjustment;
2055             Gtk::Adjustment       pitch_cent_adjustment;
2056             Gtk::SpinButton       pitch_octave_spinner;
2057             Gtk::SpinButton       pitch_semitone_spinner;
2058             Gtk::SpinButton       pitch_cent_spinner;
2059             RegionSelection       regions;
2060             Gtk::ProgressBar      progress_bar;
2061
2062             /* SoundTouch */
2063             Gtk::ToggleButton     quick_button;
2064             Gtk::ToggleButton     antialias_button;
2065             Gtk::HBox             upper_button_box;
2066
2067             /* RubberBand */
2068             Gtk::ComboBoxText     stretch_opts_selector;
2069             Gtk::Label            stretch_opts_label;
2070             Gtk::ToggleButton     precise_button;
2071             Gtk::HBox             opts_box;
2072
2073             Gtk::Button*          cancel_button;
2074             Gtk::Button*          action_button;
2075             Gtk::VBox             packer;
2076             int                   status;
2077
2078             TimeFXDialog (Editor& e, bool for_pitch);
2079
2080             gint update_progress ();
2081             sigc::connection first_cancel;
2082             sigc::connection first_delete;
2083             void cancel_in_progress ();
2084             gint delete_in_progress (GdkEventAny*);
2085         };
2086
2087         /* "whats mine is yours" */
2088
2089         friend class TimeFXDialog;
2090
2091         TimeFXDialog* current_timefx;
2092
2093         static void* timefx_thread (void *arg);
2094         void do_timefx (TimeFXDialog&);
2095
2096         int time_stretch (RegionSelection&, float fraction);
2097         int pitch_shift (RegionSelection&, float cents);
2098         void pitch_shift_regions ();
2099         int time_fx (RegionSelection&, float val, bool pitching);
2100
2101         /* editor-mixer strip */
2102
2103         MixerStrip *current_mixer_strip;
2104         bool show_editor_mixer_when_tracks_arrive;
2105         Gtk::VBox current_mixer_strip_vbox;
2106         void cms_new (boost::shared_ptr<ARDOUR::Route>);
2107         void cms_deleted ();
2108         void current_mixer_strip_hidden ();
2109         void current_mixer_strip_removed ();
2110
2111         void detach_tearoff (Gtk::Box* b, Gtk::Window* w);
2112         void reattach_tearoff (Gtk::Box* b, Gtk::Window* w, int32_t n);
2113
2114         /* nudging tracks */
2115
2116         void nudge_track (bool use_edit_point, bool forwards);
2117
2118         /* xfades */
2119
2120         bool _xfade_visibility;
2121         
2122 #ifdef WITH_CMT
2123         void handle_new_imageframe_time_axis_view(const string & track_name, void* src) ;
2124         void handle_new_imageframe_marker_time_axis_view(const string & track_name, TimeAxisView* marked_track) ;
2125
2126         void start_imageframe_grab(ArdourCanvas::Item*, GdkEvent*) ;
2127         void start_markerview_grab(ArdourCanvas::Item*, GdkEvent*) ;
2128
2129         void imageframe_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
2130         void markerview_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
2131         void timeaxis_item_drag_finished_callback(ArdourCanvas::Item*, GdkEvent*) ;
2132
2133         gint canvas_imageframe_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
2134         gint canvas_imageframe_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameTimeAxis* ifta);
2135         gint canvas_imageframe_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
2136         gint canvas_imageframe_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
2137
2138         gint canvas_marker_time_axis_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerTimeAxis* mta);
2139         gint canvas_markerview_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
2140         gint canvas_markerview_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
2141         gint canvas_markerview_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
2142
2143         void imageframe_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2144         void imageframe_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2145         void imageframe_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2146         void imageframe_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2147         void imageframe_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2148         void imageframe_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2149         
2150         void markerview_item_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2151         void markerview_item_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2152         void markerview_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2153         void markerview_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2154         void markerview_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2155         void markerview_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2156
2157         void popup_imageframe_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
2158         void popup_marker_time_axis_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
2159
2160         ImageFrameSocketHandler* image_socket_listener ;
2161 #endif
2162
2163         void toggle_xfade_active (boost::weak_ptr<ARDOUR::Crossfade>);
2164         void toggle_xfade_length (boost::weak_ptr<ARDOUR::Crossfade>);
2165         void edit_xfade (boost::weak_ptr<ARDOUR::Crossfade>);
2166         void xfade_edit_left_region ();
2167         void xfade_edit_right_region ();
2168
2169         static const int32_t default_width = 995;
2170         static const int32_t default_height = 765;
2171
2172         /* nudge */
2173
2174         Gtk::Button      nudge_forward_button;
2175         Gtk::Button      nudge_backward_button;
2176         Gtk::HBox        nudge_hbox;
2177         Gtk::VBox        nudge_vbox;
2178         AudioClock       nudge_clock;
2179
2180         nframes64_t get_nudge_distance (nframes64_t pos, nframes64_t& next);
2181
2182         bool nudge_forward_release (GdkEventButton*);
2183         bool nudge_backward_release (GdkEventButton*);
2184         
2185         /* audio filters */
2186
2187         void apply_filter (ARDOUR::Filter&, string cmd);
2188
2189         /* handling cleanup */
2190
2191         int playlist_deletion_dialog (boost::shared_ptr<ARDOUR::Playlist>);
2192
2193         vector<sigc::connection> session_connections;
2194
2195         /* tracking step changes of track height */
2196
2197         TimeAxisView* current_stepping_trackview;
2198         ARDOUR::microseconds_t last_track_height_step_timestamp;
2199         gint track_height_step_timeout();
2200         sigc::connection step_timeout;
2201
2202         TimeAxisView* entered_track;
2203         RegionView*   entered_regionview;
2204
2205
2206         void ensure_entered_track_selected (bool op_acts_on_objects = false);
2207         bool clear_entered_track;
2208         bool left_track_canvas (GdkEventCrossing*);
2209         bool entered_track_canvas (GdkEventCrossing*);
2210         void set_entered_track (TimeAxisView*);
2211         void set_entered_regionview (RegionView*);
2212         gint left_automation_track ();
2213
2214         bool _new_regionviews_show_envelope;
2215
2216         void reset_canvas_action_sensitivity (bool);
2217         void toggle_gain_envelope_visibility ();
2218         void toggle_gain_envelope_active ();
2219         void reset_region_gain_envelopes ();
2220
2221         bool on_key_press_event (GdkEventKey*);
2222         bool on_key_release_event (GdkEventKey*);
2223
2224         void session_state_saved (string);
2225
2226         Glib::RefPtr<Gtk::Action>              undo_action;
2227         Glib::RefPtr<Gtk::Action>              redo_action;
2228
2229         void history_changed ();
2230
2231         Gtk::HBox      status_bar_hpacker;
2232
2233         Editing::EditPoint _edit_point;
2234
2235         Gtk::ComboBoxText edit_point_selector;
2236
2237         void set_edit_point_preference (Editing::EditPoint ep, bool force = false);
2238         void cycle_edit_point (bool with_marker);
2239         void set_edit_point ();
2240         void edit_point_selection_done ();
2241         void edit_point_chosen (Editing::EditPoint);
2242         Glib::RefPtr<Gtk::RadioAction> edit_point_action (Editing::EditPoint);
2243         std::vector<std::string> edit_point_strings;
2244
2245         void selected_marker_moved (ARDOUR::Location*);
2246         sigc::connection edit_point_clock_connection_a;
2247         sigc::connection edit_point_clock_connection_b;
2248
2249         bool get_edit_op_range (nframes64_t& start, nframes64_t& end) const;
2250
2251         void get_regions_at (RegionSelection&, nframes64_t where, const TrackSelection& ts) const;
2252         void get_regions_after (RegionSelection&, nframes64_t where, const TrackSelection& ts) const;
2253         
2254         void get_regions_for_action (RegionSelection&, bool allowed_entered_regionview = false);
2255
2256         sigc::connection fast_screen_update_connection;
2257         gint start_updating ();
2258         gint stop_updating ();
2259         void fast_update_strips ();
2260         bool meters_running;
2261
2262         void select_next_route ();
2263         void select_prev_route ();
2264
2265         void snap_to_internal (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
2266
2267         RhythmFerret* rhythm_ferret;
2268
2269         void fit_tracks ();
2270         void set_track_height (uint32_t h);
2271         void set_track_height_largest ();
2272         void set_track_height_large ();
2273         void set_track_height_larger ();
2274         void set_track_height_normal ();
2275         void set_track_height_smaller ();
2276         void set_track_height_small ();
2277
2278         void remove_tracks ();
2279         void toggle_tracks_active ();
2280         void waveform_scale_chosen (Editing::WaveformScale);
2281
2282         bool _have_idled;
2283         int resize_idle_id;
2284         int32_t resize_idle_target;
2285         bool idle_resize();
2286         friend gboolean _idle_resize (gpointer);
2287         std::vector<TimeAxisView*> pending_resizes;
2288 };
2289
2290 #endif /* __ardour_editor_h__ */