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