more upgrades to the import dialog
[ardour.git] / gtk2_ardour / editor.h
1 /*
2     Copyright (C) 2000-2003 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_editor_h__
21 #define __ardour_editor_h__
22
23 #include <list>
24 #include <map>
25 #include <set>
26 #include <string>
27 #include <sys/time.h>
28 #include <glibmm/ustring.h>
29
30 #include <boost/optional.hpp>
31
32 #include <libgnomecanvasmm/canvas.h>
33 #include <libgnomecanvasmm/group.h>
34 #include <libgnomecanvasmm/line.h>
35
36 #include <cmath>
37
38 #include <gtkmm/layout.h>
39 #include <gtkmm/comboboxtext.h>
40
41 #include <gtkmm2ext/selector.h>
42 #include <gtkmm2ext/click_box.h>
43 #include <gtkmm2ext/dndtreeview.h>
44
45 #include <pbd/stateful.h>
46 #include <ardour/session.h>
47 #include <ardour/tempo.h>
48 #include <ardour/location.h>
49 #include <ardour/audioregion.h>
50
51 #include "audio_clock.h"
52 #include "gtk-custom-ruler.h"
53 #include "ardour_dialog.h"
54 #include "public_editor.h"
55 #include "editing.h"
56 #include "enums.h"
57 #include "editor_items.h"
58 #include "region_selection.h"
59 #include "canvas.h"
60 #include "draginfo.h"
61
62 namespace Gtkmm2ext {
63         class TearOff;
64 }
65
66 namespace ARDOUR {
67         class AudioDiskstream;
68         class RouteGroup;
69         class Playlist;
70         class AudioPlaylist;
71         class Region;
72         class Location;
73         class TempoSection;
74         class NamedSelection;
75         class Session;
76         class AudioFilter;
77         class Crossfade;
78 }
79
80 namespace LADSPA {
81         class Plugin;
82 }
83
84 class TimeAxisView;
85 class RouteTimeAxisView;
86 class AudioTimeAxisView;
87 class AutomationTimeAxisView;
88 class AudioRegionView;
89 class CrossfadeView;
90 class PluginSelector;
91 class PlaylistSelector;
92 class Marker;
93 class GroupedButtons;
94 class AutomationLine;
95 class UIExportSpecification;
96 class ExportDialog;
97 class Selection;
98 class TimeSelection;
99 class TrackSelection;
100 class AutomationSelection;
101 class MixerStrip;
102 class StreamView;
103 class AudioStreamView;
104 class ControlPoint;
105 #ifdef FFT_ANALYSIS
106 class AnalysisWindow;
107 #endif
108
109 /* <CMT Additions> */
110 class ImageFrameView;
111 class ImageFrameTimeAxisView;
112 class ImageFrameTimeAxis;
113 class MarkerTimeAxis ;
114 class MarkerView ;
115 class ImageFrameSocketHandler ;
116 class TimeAxisViewItem ;
117 /* </CMT Additions> */
118
119
120 class Editor : public PublicEditor
121 {
122   public:
123         Editor ();
124         ~Editor ();
125
126         void             connect_to_session (ARDOUR::Session *);
127         ARDOUR::Session* current_session() const { return session; }
128
129         nframes_t leftmost_position() const { return leftmost_frame; }
130         nframes_t current_page_frames() const {
131                 return (nframes_t) floor (canvas_width * frames_per_unit);
132         }
133
134         void set_snap_to (Editing::SnapType);
135         void set_snap_mode (Editing::SnapMode);
136         void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;}
137
138         void undo (uint32_t n = 1);
139         void redo (uint32_t n = 1);
140
141         XMLNode& get_state ();
142         int set_state (const XMLNode& );
143
144         void set_mouse_mode (Editing::MouseMode, bool force=true);
145         void step_mouse_mode (bool next);
146         Editing::MouseMode current_mouse_mode () { return mouse_mode; }
147
148         void add_imageframe_time_axis(const std::string & track_name, void*) ;
149         void add_imageframe_marker_time_axis(const std::string & track_name, TimeAxisView* marked_track, void*) ;
150         void connect_to_image_compositor() ;
151         void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ;
152         TimeAxisView* get_named_time_axis(const std::string & name) ;
153
154         void consider_auditioning (boost::shared_ptr<ARDOUR::Region>);
155         void hide_a_region (boost::shared_ptr<ARDOUR::Region>);
156         void remove_a_region (boost::shared_ptr<ARDOUR::Region>);
157
158         /* option editor-access */
159
160         void set_show_waveforms (bool yn);
161         bool show_waveforms() const { return _show_waveforms; }
162
163         void set_show_waveforms_recording (bool yn);
164         bool show_waveforms_recording() const { return _show_waveforms_recording; }
165         
166         /* things that need to be public to be used in the main menubar */
167
168         void new_region_from_selection ();
169         void separate_region_from_selection ();
170         void separate_regions_using_location (ARDOUR::Location&);
171         void toggle_playback (bool with_abort);
172         void transition_to_rolling (bool forward);
173
174         /* undo related */
175
176         nframes_t unit_to_frame (double unit) {
177                 return (nframes_t) rint (unit * frames_per_unit);
178         }
179         
180         double frame_to_unit (nframes_t frame) {
181                 return rint ((double) frame / (double) frames_per_unit);
182         }
183
184         double frame_to_unit (double frame) {
185                 return rint (frame / frames_per_unit);
186         }
187
188         /* NOTE: these functions assume that the "pixel" coordinate is
189            the result of using the world->canvas affine transform on a
190            world coordinate. These coordinates already take into
191            account any scrolling carried out by adjusting the
192            xscroll_adjustment.  
193         */
194
195         nframes_t pixel_to_frame (double pixel) {
196                 
197                 /* pixel can be less than zero when motion events
198                    are processed. since we've already run the world->canvas
199                    affine, that means that the location *really* is "off
200                    to the right" and thus really is "before the start".
201                 */
202
203                 if (pixel >= 0) {
204                         return (nframes_t) rint (pixel * frames_per_unit * GNOME_CANVAS(track_canvas.gobj())->pixels_per_unit);
205                 } else {
206                         return 0;
207                 }
208         }
209
210         gulong frame_to_pixel (nframes_t frame) {
211                 return (gulong) rint ((frame / (frames_per_unit *  GNOME_CANVAS(track_canvas.gobj())->pixels_per_unit)));
212         }
213
214         /* selection */
215
216         Selection& get_selection() const { return *selection; }
217         Selection& get_cut_buffer() const { return *cut_buffer; }
218
219         bool extend_selection_to_track (TimeAxisView&);
220
221         void play_selection ();
222         void select_all_in_track (Selection::Operation op);
223         void select_all (Selection::Operation op);
224         void invert_selection_in_track ();
225         void invert_selection ();
226
227         /* tempo */
228
229         void set_show_measures (bool yn);
230         bool show_measures () const { return _show_measures; }
231         bool initial_ruler_update_required;
232
233 #ifdef FFT_ANALYSIS
234         /* analysis window */
235         void analyze_region_selection();
236         void analyze_range_selection();
237 #endif
238
239         /* export */
240
241         /* these initiate export ... */
242         
243         void export_session();
244         void export_selection();
245
246
247         void add_toplevel_controls (Gtk::Container&);
248
249         void      set_zoom_focus (Editing::ZoomFocus);
250         Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
251         gdouble   get_current_zoom () { return frames_per_unit; }
252
253         void temporal_zoom_step (bool coarser);
254
255         /* stuff that AudioTimeAxisView and related classes use */
256
257         PlaylistSelector& playlist_selector() const;
258         void route_name_changed (TimeAxisView *);
259         gdouble        frames_per_unit;
260         nframes_t leftmost_frame;
261         void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>);
262
263         void new_playlists ();
264         void copy_playlists ();
265         void clear_playlists ();
266
267         TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0);
268
269         Width editor_mixer_strip_width;
270         void maybe_add_mixer_strip_width (XMLNode&);
271         void show_editor_mixer (bool yn);
272         void set_selected_mixer_strip (TimeAxisView&);
273         void hide_track_in_display (TimeAxisView& tv);
274         void show_track_in_display (TimeAxisView& tv);
275
276         /* nudge is initiated by transport controls owned by ARDOUR_UI */
277
278         void nudge_forward (bool next);
279         void nudge_backward (bool next);
280
281         /* nudge initiated from context menu */
282
283         void nudge_forward_capture_offset ();
284         void nudge_backward_capture_offset ();
285
286         /* playhead/screen stuff */
287         
288         void set_follow_playhead (bool yn);
289         void toggle_follow_playhead ();
290         bool follow_playhead() const { return _follow_playhead; }
291         bool dragging_playhead () const { return _dragging_playhead; }
292
293         void toggle_waveform_visibility ();
294         void toggle_waveforms_while_recording ();
295         void toggle_measure_visibility ();
296
297         /* SMPTE timecode & video sync */
298
299         void smpte_fps_chosen (ARDOUR::SmpteFormat format);
300         void video_pullup_chosen (ARDOUR::Session::PullupFormat pullup);
301         void subframes_per_frame_chosen (uint32_t);
302
303         void update_smpte_mode();
304         void update_video_pullup();
305         void update_subframes_per_frame ();
306         /* xfades */
307
308         void toggle_auto_xfade ();
309         void toggle_xfades_active ();
310         void toggle_xfade_visibility ();
311         bool xfade_visibility() const { return _xfade_visibility; }
312         void update_xfade_visibility ();
313         void update_crossfade_model ();
314         void set_crossfade_model (ARDOUR::CrossfadeModel);
315
316         /* layers */
317         void set_layer_model (ARDOUR::LayerModel);
318         void update_layering_model ();
319
320         /* redirect shared ops menu. caller must free returned menu */
321
322         Gtk::Menu* redirect_menu ();
323
324         /* floating windows/transient */
325
326         void ensure_float (Gtk::Window&);
327
328         void show_window ();
329
330         void scroll_tracks_down_line ();
331         void scroll_tracks_up_line ();
332
333         bool new_regionviews_display_gain () { return _new_regionviews_show_envelope; }
334         void prepare_for_cleanup ();
335
336         void maximise_editing_space();
337         void restore_editing_space();
338
339         void reset_x_origin (nframes_t);
340         void reset_zoom (double);
341         void reposition_and_zoom (nframes_t, double);
342
343         nframes_t edit_cursor_position(bool);
344
345   protected:
346         void map_transport_state ();
347         void map_position_change (nframes_t);
348
349         void on_realize();
350
351   private:
352         
353         ARDOUR::Session     *session;
354         bool                 constructed;
355   
356         // to keep track of the playhead position for control_scroll
357         boost::optional<nframes_t> _control_scroll_target;
358
359         PlaylistSelector* _playlist_selector;
360
361         void          set_frames_per_unit (double);
362
363         Editing::MouseMode mouse_mode;
364
365         int  post_maximal_editor_width;
366         int  post_maximal_pane_position;
367         int  pre_maximal_pane_position;
368         int  pre_maximal_editor_width;
369         void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*);
370
371         Gtk::Notebook the_notebook;
372         Gtk::HPaned   edit_pane;
373
374         Gtk::EventBox meter_base;
375         Gtk::HBox     meter_box;
376         Gtk::EventBox marker_base;
377         Gtk::HBox     marker_box;
378         Gtk::VBox     scrollers_rulers_markers_box;
379
380         void location_changed (ARDOUR::Location *);
381         void location_flags_changed (ARDOUR::Location *, void *);
382         void refresh_location_display ();
383         void refresh_location_display_s (ARDOUR::Change);
384         void refresh_location_display_internal (ARDOUR::Locations::LocationList&);
385         void add_new_location (ARDOUR::Location *);
386         void location_gone (ARDOUR::Location *);
387         void remove_marker (ArdourCanvas::Item&, GdkEvent*);
388         gint really_remove_marker (ARDOUR::Location* loc);
389
390         uint32_t location_marker_color;
391         uint32_t location_range_color;
392         uint32_t location_loop_color;
393         uint32_t location_punch_color;
394         uint32_t location_cd_marker_color;
395
396         struct LocationMarkers {
397             Marker* start;
398             Marker* end;
399
400             ~LocationMarkers ();
401
402             void hide();
403             void show ();
404             void set_name (const string&);
405             void set_position (nframes_t start, nframes_t end = 0);
406             void set_color_rgba (uint32_t);
407         };
408
409         LocationMarkers  *find_location_markers (ARDOUR::Location *);
410         ARDOUR::Location* find_location_from_marker (Marker *, bool& is_start);
411
412         typedef std::map<ARDOUR::Location*,LocationMarkers *> LocationMarkerMap;
413         LocationMarkerMap location_markers;
414
415         void hide_marker (ArdourCanvas::Item*, GdkEvent*);
416         void clear_marker_display ();
417         void mouse_add_new_marker (nframes_t where);
418
419         TimeAxisView*      clicked_trackview;
420         AudioTimeAxisView* clicked_audio_trackview;
421         RegionView*        clicked_regionview;
422         RegionView*        latest_regionview;
423         uint32_t           clicked_selection;
424         CrossfadeView*     clicked_crossfadeview;
425         ControlPoint*      clicked_control_point;
426
427         void sort_track_selection ();
428
429         void get_relevant_audio_tracks (std::set<AudioTimeAxisView*>& relevant_tracks);
430         void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&);
431         void mapover_audio_tracks (sigc::slot<void,AudioTimeAxisView&,uint32_t> sl);
432
433         /* functions to be passed to mapover_audio_tracks(), possibly with sigc::bind()-supplied arguments */
434
435         void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, vector<RegionView*>*);
436         void mapped_use_new_playlist (AudioTimeAxisView&, uint32_t);
437         void mapped_use_copy_playlist (AudioTimeAxisView&, uint32_t);
438         void mapped_clear_playlist (AudioTimeAxisView&, uint32_t);
439
440         /* end */
441
442         void button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type);
443         bool button_release_can_deselect;
444
445         void catch_vanishing_regionview (RegionView *);
446
447         bool set_selected_track (TimeAxisView&, Selection::Operation op = Selection::Set, bool no_remove=false);
448         void select_all_tracks ();
449
450         bool set_selected_control_point_from_click (Selection::Operation op = Selection::Set, bool no_remove=false);
451         bool set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool no_remove=false);
452         bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set, bool no_track_remove=false);
453
454         void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
455         bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::weak_ptr<ARDOUR::Region>);
456         void collect_new_region_view (RegionView *);
457
458         Gtk::Menu track_context_menu;
459         Gtk::Menu track_region_context_menu;
460         Gtk::Menu track_selection_context_menu;
461         Gtk::Menu track_crossfade_context_menu;
462
463         Gtk::MenuItem* region_edit_menu_split_item;
464         Gtk::MenuItem* region_edit_menu_split_multichannel_item;
465         Gtk::Menu * track_region_edit_playlist_menu;
466         Gtk::Menu * track_edit_playlist_submenu;
467         Gtk::Menu * track_selection_edit_playlist_submenu;
468         
469         void popup_track_context_menu (int, int, ItemType, bool, nframes_t);
470         Gtk::Menu* build_track_context_menu (nframes_t);
471         Gtk::Menu* build_track_bus_context_menu (nframes_t);
472         Gtk::Menu* build_track_region_context_menu (nframes_t frame);
473         Gtk::Menu* build_track_crossfade_context_menu (nframes_t);
474         Gtk::Menu* build_track_selection_context_menu (nframes_t);
475         void add_dstream_context_items (Gtk::Menu_Helpers::MenuList&);
476         void add_bus_context_items (Gtk::Menu_Helpers::MenuList&);
477         void add_region_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Region>, Gtk::Menu_Helpers::MenuList&);
478         void add_crossfade_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Crossfade>, Gtk::Menu_Helpers::MenuList&, bool many);
479         void add_selection_context_items (Gtk::Menu_Helpers::MenuList&);
480
481         void handle_new_route (ARDOUR::Session::RouteList&);
482         void remove_route (TimeAxisView *);
483         bool route_removal;
484
485         Gtk::HBox           global_hpacker;
486         Gtk::VBox           global_vpacker;
487         Gtk::VBox           vpacker;
488
489         Gdk::Cursor*          current_canvas_cursor;
490
491         ArdourCanvas::CanvasAA track_canvas;
492         ArdourCanvas::CanvasAA time_canvas;
493
494         ArdourCanvas::Text* first_action_message;
495         ArdourCanvas::Text* verbose_canvas_cursor;
496         bool                 verbose_cursor_visible;
497
498         void parameter_changed (const char *);
499         
500         bool track_canvas_motion (GdkEvent*);
501
502         void set_verbose_canvas_cursor (const string &, double x, double y);
503         void set_verbose_canvas_cursor_text (const string &);
504         void show_verbose_canvas_cursor();
505         void hide_verbose_canvas_cursor();
506
507         bool verbose_cursor_on; // so far unused
508
509         Gtk::EventBox      time_canvas_event_box;
510         Gtk::EventBox      track_canvas_event_box;
511         Gtk::EventBox      time_button_event_box;
512         Gtk::Frame         time_button_frame;
513
514         ArdourCanvas::Group      *minsec_group;
515         ArdourCanvas::Group      *bbt_group;
516         ArdourCanvas::Group      *smpte_group;
517         ArdourCanvas::Group      *frame_group;
518         ArdourCanvas::Group      *tempo_group;
519         ArdourCanvas::Group      *meter_group;
520         ArdourCanvas::Group      *marker_group;
521         ArdourCanvas::Group      *range_marker_group;
522         ArdourCanvas::Group      *transport_marker_group;
523         
524         enum {
525                 ruler_metric_smpte = 0,
526                 ruler_metric_bbt = 1,
527                 ruler_metric_frames = 2,
528                 ruler_metric_minsec = 3,
529
530                 ruler_time_tempo = 4,
531                 ruler_time_meter = 5,
532                 ruler_time_marker = 6,
533                 ruler_time_range_marker = 7,
534                 ruler_time_transport_marker = 8,
535         };
536
537         static GtkCustomMetric ruler_metrics[4];
538         bool                   ruler_shown[9];
539         bool                   no_ruler_shown_update;
540         
541         gint ruler_button_press (GdkEventButton*);
542         gint ruler_button_release (GdkEventButton*);
543         gint ruler_mouse_motion (GdkEventMotion*);
544
545         gint ruler_pressed_button;
546         Gtk::Widget * ruler_grabbed_widget;
547         
548         void initialize_rulers ();
549         void update_just_smpte ();
550         void update_fixed_rulers ();
551         void update_tempo_based_rulers (); 
552         void popup_ruler_menu (nframes_t where = 0, ItemType type = RegionItem);
553         void update_ruler_visibility ();
554         void ruler_toggled (int);
555         gint ruler_label_button_release (GdkEventButton*);
556         void store_ruler_visibility ();
557         void restore_ruler_visibility ();
558         
559         static gint _metric_get_smpte (GtkCustomRulerMark **, gdouble, gdouble, gint);
560         static gint _metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
561         static gint _metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
562         static gint _metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
563         
564         gint metric_get_smpte (GtkCustomRulerMark **, gdouble, gdouble, gint);
565         gint metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
566         gint metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
567         gint metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
568
569         Gtk::Widget        *_ruler_separator;
570         GtkWidget          *_smpte_ruler;
571         GtkWidget          *_bbt_ruler;
572         GtkWidget          *_frames_ruler;
573         GtkWidget          *_minsec_ruler;
574         Gtk::Widget        *smpte_ruler;
575         Gtk::Widget        *bbt_ruler;
576         Gtk::Widget        *frames_ruler;
577         Gtk::Widget        *minsec_ruler;
578         static Editor      *ruler_editor;
579
580         static const double timebar_height;
581         guint32 visible_timebars;
582         Gtk::Menu          *editor_ruler_menu;
583         
584         ArdourCanvas::SimpleRect* tempo_bar;
585         ArdourCanvas::SimpleRect* meter_bar;
586         ArdourCanvas::SimpleRect* marker_bar;
587         ArdourCanvas::SimpleRect* range_marker_bar;
588         ArdourCanvas::SimpleRect* transport_marker_bar;
589
590         
591         ArdourCanvas::SimpleLine* tempo_line;
592         ArdourCanvas::SimpleLine* meter_line;
593         ArdourCanvas::SimpleLine* marker_line;
594         ArdourCanvas::SimpleLine* range_marker_line;
595         ArdourCanvas::SimpleLine* transport_marker_line;
596
597         Gtk::Label  minsec_label;
598         Gtk::Label  bbt_label;
599         Gtk::Label  smpte_label;
600         Gtk::Label  frame_label;
601         Gtk::Label  tempo_label;
602         Gtk::Label  meter_label;
603         Gtk::Label  mark_label;
604         Gtk::Label  range_mark_label;
605         Gtk::Label  transport_mark_label;
606         
607
608         Gtk::VBox          time_button_vbox;
609         Gtk::HBox          time_button_hbox;
610
611         struct Cursor {
612             Editor&               editor;
613             ArdourCanvas::Points  points;
614             ArdourCanvas::Line    canvas_item;
615             nframes_t        current_frame;
616             double                length;
617
618             Cursor (Editor&, bool (Editor::*)(GdkEvent*,ArdourCanvas::Item*));
619             ~Cursor ();
620
621             void set_position (nframes_t);
622             void set_length (double units);
623             void set_y_axis (double position);
624         };
625
626         friend struct Cursor; /* it needs access to several private
627                                  fields. XXX fix me.
628                               */
629
630         Cursor* playhead_cursor;
631         Cursor* edit_cursor;
632         ArdourCanvas::Group* cursor_group;
633
634         void    cursor_to_next_region_point (Cursor*, ARDOUR::RegionPoint);
635         void    cursor_to_previous_region_point (Cursor*, ARDOUR::RegionPoint);
636         void    cursor_to_region_point (Cursor*, ARDOUR::RegionPoint, int32_t dir);
637         void    cursor_to_selection_start (Cursor *);
638         void    cursor_to_selection_end   (Cursor *);
639         void    select_all_selectables_using_cursor (Cursor *, bool);
640         void    select_all_selectables_between_cursors (Cursor *, Cursor *);
641
642         boost::shared_ptr<ARDOUR::Region> find_next_region (nframes_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
643
644         vector<nframes_t> region_boundary_cache;
645         void build_region_boundary_cache ();
646
647         Gtk::VBox           trackview_vpacker;
648
649         Gtk::HBox           top_hbox;
650         Gtk::HBox           bottom_hbox;
651         
652         Gtk::Table          edit_packer;
653         Gtk::VScrollbar     edit_vscrollbar;
654
655         Gtk::Adjustment     vertical_adjustment;
656         Gtk::Adjustment     horizontal_adjustment;
657
658         Gtk::Layout         controls_layout;
659         bool control_layout_scroll (GdkEventScroll* ev);
660         void controls_layout_size_request (Gtk::Requisition*);
661
662         Gtk::HScrollbar     edit_hscrollbar;
663         bool                _dragging_hscrollbar;
664
665         void reset_hscrollbar_stepping ();
666         
667         bool hscrollbar_button_press (GdkEventButton*);
668         bool hscrollbar_button_release (GdkEventButton*);
669         void hscrollbar_allocate (Gtk::Allocation &alloc);
670
671         double canvas_width;
672         double canvas_height;
673         double full_canvas_height;
674         nframes_t last_canvas_frame;
675
676         bool track_canvas_map_handler (GdkEventAny*);
677         bool time_canvas_map_handler (GdkEventAny*);
678
679         gint edit_controls_button_release (GdkEventButton*);
680         Gtk::Menu *edit_controls_left_menu;
681         Gtk::Menu *edit_controls_right_menu;
682
683         Gtk::VBox           track_canvas_vbox;
684         Gtk::VBox           time_canvas_vbox;
685         Gtk::VBox           edit_controls_vbox;
686         Gtk::HBox           edit_controls_hbox;
687
688         void control_scroll (float);
689         bool deferred_control_scroll (nframes_t);
690         sigc::connection control_scroll_connection;
691
692         void tie_vertical_scrolling ();
693         void canvas_horizontally_scrolled ();
694
695         struct VisualChange {
696             enum Type { 
697                     TimeOrigin = 0x1,
698                     ZoomLevel = 0x2
699             };
700
701             Type pending;
702             nframes_t time_origin;
703             double frames_per_unit;
704
705             int idle_handler_id;
706
707             VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), frames_per_unit (0), idle_handler_id (-1) {}
708         };
709
710
711         VisualChange pending_visual_change;
712
713         static int _idle_visual_changer (void *arg);
714         int idle_visual_changer ();
715
716         void queue_visual_change (nframes_t);
717         void queue_visual_change (double);
718
719         void end_location_changed (ARDOUR::Location*);
720
721         struct RegionListDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
722             RegionListDisplayModelColumns() {
723                     add (name);
724                     add (region);
725                     add (color_);
726             }
727             Gtk::TreeModelColumn<Glib::ustring> name;
728             Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
729             Gtk::TreeModelColumn<Gdk::Color> color_;
730         };
731             
732         RegionListDisplayModelColumns          region_list_columns;
733         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > region_list_display;
734
735         Glib::RefPtr<Gtk::TreeStore>           region_list_model;
736         Glib::RefPtr<Gtk::ToggleAction>        toggle_full_region_list_action;
737         Glib::RefPtr<Gtk::ToggleAction>        toggle_show_auto_regions_action;
738
739         void region_list_selection_changed ();
740         bool region_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
741
742         Gtk::Menu          *region_list_menu;
743         Gtk::ScrolledWindow region_list_scroller;
744         Gtk::Frame          region_list_frame;
745
746         bool region_list_display_key_press (GdkEventKey *);
747         bool region_list_display_key_release (GdkEventKey *);
748         bool region_list_display_button_press (GdkEventButton *);
749         bool region_list_display_button_release (GdkEventButton *);
750         void region_list_clear ();
751         void region_list_selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
752         void build_region_list_menu ();
753         void show_region_list_display_context_menu (int button, int time);
754
755         bool show_automatic_regions_in_region_list;
756         Editing::RegionListSortType region_list_sort_type;
757
758         void reset_region_list_sort_direction (bool);
759         void reset_region_list_sort_type (Editing::RegionListSortType);
760
761         void toggle_full_region_list ();
762         void toggle_show_auto_regions ();
763
764         int region_list_sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
765
766         /* snapshots */
767
768         Gtk::ScrolledWindow      snapshot_display_scroller;
769         struct SnapshotDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
770             SnapshotDisplayModelColumns() { 
771                     add (visible_name);
772                     add (real_name);
773             }
774             Gtk::TreeModelColumn<Glib::ustring> visible_name;
775             Gtk::TreeModelColumn<Glib::ustring> real_name;
776         };
777
778         SnapshotDisplayModelColumns snapshot_display_columns;
779         Glib::RefPtr<Gtk::ListStore> snapshot_display_model;
780         Gtk::TreeView snapshot_display;
781         Gtk::Menu snapshot_context_menu;
782
783         bool snapshot_display_button_press (GdkEventButton*);
784         void snapshot_display_selection_changed ();
785         void redisplay_snapshots();
786         void popup_snapshot_context_menu (int, int32_t, Glib::ustring);
787
788         /* named selections */
789
790         struct NamedSelectionDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
791             NamedSelectionDisplayModelColumns() { 
792                     add (text);
793                     add (selection);
794             }
795             Gtk::TreeModelColumn<Glib::ustring>  text;
796             Gtk::TreeModelColumn<ARDOUR::NamedSelection*>    selection;
797         };
798
799         NamedSelectionDisplayModelColumns named_selection_columns;
800         Glib::RefPtr<Gtk::TreeStore>     named_selection_model;
801
802         Gtkmm2ext::DnDTreeView<ARDOUR::NamedSelection*> named_selection_display;
803         Gtk::ScrolledWindow    named_selection_scroller;
804
805         void create_named_selection ();
806         void paste_named_selection (float times);
807         void remove_selected_named_selections ();
808         void remove_snapshot (Glib::ustring);
809         void rename_snapshot (Glib::ustring);
810
811         void handle_new_named_selection ();
812         void add_named_selection_to_named_selection_display (ARDOUR::NamedSelection&);
813         void redisplay_named_selections ();
814
815         bool named_selection_display_button_release (GdkEventButton *ev);
816         bool named_selection_display_key_release (GdkEventKey *ev);
817         void named_selection_display_selection_changed ();
818
819         /* track views */
820         TrackViewList  track_views;
821         TimeAxisView     *trackview_by_y_position (double ypos);
822
823         static Gdk::Cursor* cross_hair_cursor;
824         static Gdk::Cursor* trimmer_cursor;
825         static Gdk::Cursor* selector_cursor;
826         static Gdk::Cursor* grabber_cursor;
827         static Gdk::Cursor* zoom_cursor;
828         static Gdk::Cursor* time_fx_cursor;
829         static Gdk::Cursor* fader_cursor;
830         static Gdk::Cursor* speaker_cursor;
831         static Gdk::Cursor* wait_cursor;
832         static Gdk::Cursor* timebar_cursor;
833
834         static void build_cursors ();
835
836         sigc::connection scroll_connection;
837         nframes_t last_update_frame;
838         void center_screen (nframes_t);
839         void center_screen_internal (nframes_t, float);
840         
841         void update_current_screen ();
842         
843         void session_going_away ();
844
845         nframes_t cut_buffer_start;
846         nframes_t cut_buffer_length;
847
848         bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
849         bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
850         bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
851         bool motion_handler (ArdourCanvas::Item*, GdkEvent*, ItemType, bool from_autoscroll = false);
852         bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
853         bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
854         
855         /* KEYMAP HANDLING */
856
857         void register_actions ();
858
859         int ensure_cursor (nframes_t* pos);
860
861         void handle_new_audio_region (boost::weak_ptr<ARDOUR::AudioRegion>);
862         void handle_audio_region_removed (boost::weak_ptr<ARDOUR::AudioRegion>);
863         void add_audio_region_to_region_display (boost::shared_ptr<ARDOUR::AudioRegion>);
864         void region_hidden (boost::shared_ptr<ARDOUR::Region>);
865         void redisplay_regions ();
866         void insert_into_tmp_audio_regionlist(boost::shared_ptr<ARDOUR::AudioRegion>);
867
868         list<boost::shared_ptr<ARDOUR::AudioRegion> > tmp_audio_region_list;
869
870         void cut_copy (Editing::CutCopyOp);
871         void cut_copy_points (Editing::CutCopyOp);
872         void cut_copy_regions (Editing::CutCopyOp);
873         void cut_copy_ranges (Editing::CutCopyOp);
874
875         void mouse_paste ();
876         void paste_internal (nframes_t position, float times);
877
878         /* EDITING OPERATIONS */
879         
880         void reset_point_selection ();
881         void toggle_region_mute ();
882         void toggle_region_lock ();
883         void toggle_region_opaque ();
884         void raise_region ();
885         void raise_region_to_top ();
886         void lower_region ();
887         void lower_region_to_bottom ();
888         void split_region ();
889         void split_region_at (nframes_t);
890         void split_regions_at (nframes_t, RegionSelection&);
891         void crop_region_to_selection ();
892         void set_a_regions_sync_position (boost::shared_ptr<ARDOUR::Region>, nframes_t);
893         void set_region_sync_from_edit_cursor ();
894         void remove_region_sync();
895         void align_selection (ARDOUR::RegionPoint, nframes_t position);
896         void align_selection_relative (ARDOUR::RegionPoint point, nframes_t position);
897         void align_region (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes_t position);
898         void align_region_internal (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes_t position);
899         void remove_clicked_region ();
900         void destroy_clicked_region ();
901         void edit_region ();
902         void duplicate_some_regions (RegionSelection&, float times);
903         void duplicate_selection (float times);
904         void region_fill_selection ();
905
906         void region_fill_track ();
907         void audition_playlist_region_standalone (boost::shared_ptr<ARDOUR::Region>);
908         void audition_playlist_region_via_route (boost::shared_ptr<ARDOUR::Region>, ARDOUR::Route&);
909         void split_multichannel_region();
910         void reverse_region ();
911         void normalize_region ();
912         void denormalize_region ();
913
914         void audition_region_from_region_list ();
915         void hide_region_from_region_list ();
916         void remove_region_from_region_list ();
917
918         void align (ARDOUR::RegionPoint);
919         void align_relative (ARDOUR::RegionPoint);
920         void naturalize ();
921
922         void reset_focus ();
923
924         void cut ();
925         void copy ();
926         void paste (float times);
927
928         int  get_prefix (float&, bool&);
929
930         void keyboard_paste ();
931         void keyboard_duplicate_region ();
932         void keyboard_duplicate_selection ();
933         void keyboard_insert_region_list_selection ();
934
935         void region_from_selection ();
936         void create_region_from_selection (std::vector<boost::shared_ptr<ARDOUR::AudioRegion> >&);
937
938         bool region_renamed;
939         void rename_region ();
940         void rename_region_finished (bool);
941
942         void play_from_start ();
943         void play_from_edit_cursor ();
944         void play_selected_region ();
945         void audition_selected_region ();
946         void loop_selected_region ();
947         void play_location (ARDOUR::Location&);
948         void loop_location (ARDOUR::Location&);
949
950         Editing::ZoomFocus zoom_focus;
951
952         void temporal_zoom_selection ();
953         void temporal_zoom_session ();
954         void temporal_zoom (gdouble scale);
955         void temporal_zoom_by_frame (nframes_t start, nframes_t end, const string & op);
956         void temporal_zoom_to_frame (bool coarser, nframes_t frame);
957
958         void amplitude_zoom (gdouble scale);
959         void amplitude_zoom_step (bool in);
960
961         void insert_region_list_drag (boost::shared_ptr<ARDOUR::AudioRegion>, int x, int y);
962         void insert_region_list_selection (float times);
963
964         void add_external_audio_action (Editing::ImportMode);
965         void external_audio_dialog ();
966         bool check_multichannel_status (const std::vector<Glib::ustring>& paths);
967
968         void bring_in_external_audio (Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes64_t& pos);
969         void do_import (vector<Glib::ustring> paths, Editing::ImportChannel, Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes64_t&);
970
971         void _do_embed (vector<Glib::ustring> paths, Editing::ImportChannel, Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes64_t&);
972         void do_embed (vector<Glib::ustring> paths, Editing::ImportChannel, Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes64_t&);
973         bool idle_do_embed (vector<Glib::ustring> paths, Editing::ImportChannel, Editing::ImportMode mode, ARDOUR::AudioTrack*, nframes64_t&);
974
975         int  import_sndfile (vector<Glib::ustring> paths, Editing::ImportMode mode, ARDOUR::AudioTrack* track, nframes64_t& pos);
976         int  embed_sndfile (vector<Glib::ustring> paths, Editing::ImportChannel, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode, 
977                             ARDOUR::AudioTrack* track, nframes64_t& pos);
978         int finish_bringing_in_audio (boost::shared_ptr<ARDOUR::AudioRegion> region, uint32_t, uint32_t, ARDOUR::AudioTrack* track, nframes64_t& pos, Editing::ImportMode mode);
979
980         /* generic interthread progress window */
981         
982         ArdourDialog* interthread_progress_window;
983         Gtk::Label interthread_progress_label;
984         Gtk::VBox interthread_progress_vbox;
985         Gtk::ProgressBar interthread_progress_bar;
986         Gtk::Button interthread_cancel_button;
987         Gtk::Label interthread_cancel_label;
988         sigc::connection  interthread_progress_connection;
989         void interthread_cancel_clicked ();
990         void build_interthread_progress_window ();
991         ARDOUR::InterThreadInfo* current_interthread_info;
992
993 #ifdef FFT_ANALYSIS
994         AnalysisWindow* analysis_window;
995 #endif
996
997         /* import specific info */
998
999         ARDOUR::Session::import_status import_status;
1000         gint import_progress_timeout (void *);
1001         static void *_import_thread (void *);
1002         void* import_thread ();
1003
1004         /* to support this ... */
1005
1006         void import_audio (bool as_tracks);
1007         void do_import (vector<Glib::ustring> paths, bool split, bool as_tracks);
1008
1009         void move_to_start ();
1010         void move_to_end ();
1011         void goto_frame ();
1012         void center_playhead ();
1013         void center_edit_cursor ();
1014         void edit_cursor_backward ();
1015         void edit_cursor_forward ();
1016         void playhead_backward ();
1017         void playhead_forward ();
1018         void scroll_playhead (bool forward);
1019         void scroll_backward (float pages=0.8f);
1020         void scroll_forward (float pages=0.8f);
1021         void scroll_tracks_down ();
1022         void scroll_tracks_up ();
1023         void delete_sample_forward ();
1024         void delete_sample_backward ();
1025         void delete_screen ();
1026         void search_backwards ();
1027         void search_forwards ();
1028         void set_mark ();
1029         void clear_markers ();
1030         void clear_ranges ();
1031         void clear_locations ();
1032         void unhide_markers ();
1033         void unhide_ranges ();
1034         void jump_forward_to_mark ();
1035         void jump_backward_to_mark ();
1036         void cursor_align (bool playhead_to_edit);
1037
1038         void remove_last_capture ();
1039         void select_all_selectables_using_time_selection ();
1040         void select_all_selectables_using_loop();
1041         void select_all_selectables_using_punch();
1042         void set_selection_from_range (ARDOUR::Location&);
1043         void set_selection_from_punch ();
1044         void set_selection_from_loop ();
1045         void set_selection_from_audio_region ();
1046
1047         void add_location_from_audio_region ();
1048         void add_location_from_selection ();
1049         void set_loop_from_selection (bool play);
1050         void set_punch_from_selection ();
1051
1052         void set_loop_range (nframes_t start, nframes_t end, std::string cmd);
1053         void set_punch_range (nframes_t start, nframes_t end, std::string cmd);
1054
1055         void add_location_from_playhead_cursor ();
1056
1057         void reverse_selection ();
1058         void edit_envelope ();
1059
1060         void start_scrolling ();
1061         void stop_scrolling ();
1062
1063         bool _scrubbing;
1064         nframes64_t last_scrub_frame;
1065         uint32_t last_scrub_time;
1066
1067         void keyboard_selection_begin ();
1068         void keyboard_selection_finish (bool add);
1069         bool have_pending_keyboard_selection;
1070         nframes_t pending_keyboard_selection_start;
1071
1072         boost::shared_ptr<ARDOUR::Region> select_region_for_operation (int dir, TimeAxisView **tv);
1073         void extend_selection_to_end_of_region (bool next);
1074         void extend_selection_to_start_of_region (bool previous);
1075
1076         Editing::SnapType snap_type;
1077         Editing::SnapMode snap_mode;
1078         double snap_threshold;
1079
1080         void handle_gui_changes (const string &, void *);
1081
1082         void    hide_all_tracks (bool with_select);
1083
1084         DragInfo drag_info;
1085         LineDragInfo current_line_drag_info;
1086
1087         void start_grab (GdkEvent*, Gdk::Cursor* cursor = 0);
1088         bool end_grab (ArdourCanvas::Item*, GdkEvent*);
1089         void swap_grab (ArdourCanvas::Item*, Gdk::Cursor* cursor, uint32_t time);
1090
1091         Gtk::Menu fade_context_menu;
1092         void popup_fade_context_menu (int, int, ArdourCanvas::Item*, ItemType);
1093
1094         void start_fade_in_grab (ArdourCanvas::Item*, GdkEvent*);
1095         void start_fade_out_grab (ArdourCanvas::Item*, GdkEvent*);
1096         void fade_in_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1097         void fade_out_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1098         void fade_in_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1099         void fade_out_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1100
1101         void set_fade_in_shape (ARDOUR::AudioRegion::FadeShape);
1102         void set_fade_out_shape (ARDOUR::AudioRegion::FadeShape);
1103
1104         void set_fade_in_active (bool);
1105         void set_fade_out_active (bool);
1106         
1107         std::set<boost::shared_ptr<ARDOUR::Playlist> > motion_frozen_playlists;
1108         void region_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1109         void region_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1110
1111         bool _dragging_playhead;
1112
1113         void cursor_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1114         void cursor_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1115         void marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1116         void marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1117         void control_point_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1118         void control_point_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1119         void line_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1120         void line_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1121
1122         void tempo_marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1123         void tempo_marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1124         void meter_marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1125         void meter_marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1126
1127         gint mouse_rename_region (ArdourCanvas::Item*, GdkEvent*);
1128
1129         void start_region_grab (ArdourCanvas::Item*, GdkEvent*);
1130         void start_region_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1131         void start_region_brush_grab (ArdourCanvas::Item*, GdkEvent*);
1132         void start_selection_grab (ArdourCanvas::Item*, GdkEvent*);
1133         void start_cursor_grab (ArdourCanvas::Item*, GdkEvent*);
1134         void start_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1135         void start_control_point_grab (ArdourCanvas::Item*, GdkEvent*);
1136         void start_line_grab_from_regionview (ArdourCanvas::Item*, GdkEvent*);
1137         void start_line_grab_from_line (ArdourCanvas::Item*, GdkEvent*);
1138         void start_line_grab (AutomationLine *, GdkEvent*);
1139         void start_tempo_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1140         void start_tempo_marker_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1141         void start_meter_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1142         void start_meter_marker_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1143
1144         void region_view_item_click (AudioRegionView&, GdkEventButton*);
1145
1146         void remove_gain_control_point (ArdourCanvas::Item*, GdkEvent*);
1147         void remove_control_point (ArdourCanvas::Item*, GdkEvent*);
1148
1149         void mouse_brush_insert_region (RegionView*, nframes_t pos);
1150         void brush (nframes_t);
1151
1152         void show_verbose_time_cursor (nframes_t frame, double offset = 0, double xpos=-1, double ypos=-1);
1153         void show_verbose_duration_cursor (nframes_t start, nframes_t end, double offset = 0, double xpos=-1, double ypos=-1);
1154
1155         /* Canvas event handlers */
1156
1157         bool canvas_control_point_event (GdkEvent* event,ArdourCanvas::Item*, ControlPoint*);
1158         bool canvas_line_event (GdkEvent* event,ArdourCanvas::Item*, AutomationLine*);
1159         bool canvas_selection_rect_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1160         bool canvas_selection_start_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1161         bool canvas_selection_end_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1162         bool canvas_crossfade_view_event (GdkEvent* event,ArdourCanvas::Item*, CrossfadeView*);
1163         bool canvas_fade_in_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1164         bool canvas_fade_in_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1165         bool canvas_fade_out_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1166         bool canvas_fade_out_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1167         bool canvas_region_view_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1168         bool canvas_region_view_name_highlight_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1169         bool canvas_region_view_name_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1170         bool canvas_stream_view_event (GdkEvent* event,ArdourCanvas::Item*, RouteTimeAxisView*);
1171         bool canvas_marker_event (GdkEvent* event,ArdourCanvas::Item*, Marker*);
1172         bool canvas_zoom_rect_event (GdkEvent* event,ArdourCanvas::Item*);
1173         bool canvas_tempo_marker_event (GdkEvent* event,ArdourCanvas::Item*, TempoMarker*);
1174         bool canvas_meter_marker_event (GdkEvent* event,ArdourCanvas::Item*, MeterMarker*);
1175         bool canvas_automation_track_event(GdkEvent* event, ArdourCanvas::Item*, AutomationTimeAxisView*) ;
1176
1177         bool canvas_tempo_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1178         bool canvas_meter_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1179         bool canvas_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1180         bool canvas_range_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1181         bool canvas_transport_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1182
1183         bool canvas_imageframe_item_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1184         bool canvas_imageframe_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameTimeAxis*);
1185         bool canvas_imageframe_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1186         bool canvas_imageframe_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1187         bool canvas_marker_time_axis_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerTimeAxis*);
1188         bool canvas_markerview_item_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1189         bool canvas_markerview_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1190         bool canvas_markerview_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1191
1192         /* non-public event handlers */
1193
1194         bool canvas_playhead_cursor_event (GdkEvent* event, ArdourCanvas::Item*);
1195         bool canvas_edit_cursor_event (GdkEvent* event, ArdourCanvas::Item*);
1196         bool track_canvas_scroll (GdkEventScroll* event);
1197
1198         bool track_canvas_scroll_event (GdkEventScroll* event);
1199         bool track_canvas_button_press_event (GdkEventButton* event);
1200         bool track_canvas_button_release_event (GdkEventButton* event);
1201         bool track_canvas_motion_notify_event (GdkEventMotion* event);
1202
1203         Gtk::Allocation canvas_allocation;
1204         bool canvas_idle_queued;
1205         void track_canvas_allocate (Gtk::Allocation alloc);
1206         bool track_canvas_size_allocated ();
1207
1208         void set_edit_cursor (GdkEvent* event);
1209         void set_playhead_cursor (GdkEvent* event);
1210
1211         void kbd_driver (sigc::slot<void,GdkEvent*>, bool use_track_canvas = true, bool use_time_canvas = true, bool can_select = true);
1212         void kbd_set_playhead_cursor ();
1213         void kbd_set_edit_cursor ();
1214         void kbd_mute_unmute_region ();
1215         void kbd_split ();
1216         void kbd_set_sync_position ();
1217         void kbd_align (ARDOUR::RegionPoint);
1218         void kbd_align_relative (ARDOUR::RegionPoint);
1219         void kbd_brush ();
1220         void kbd_audition ();
1221
1222         void kbd_do_split (GdkEvent*);
1223         void kbd_do_set_sync_position (GdkEvent* ev);
1224         void kbd_do_align (GdkEvent*, ARDOUR::RegionPoint);
1225         void kbd_do_align_relative (GdkEvent*, ARDOUR::RegionPoint);
1226         void kbd_do_brush (GdkEvent*);
1227         void kbd_do_audition (GdkEvent*);
1228
1229         void handle_new_duration ();
1230         void initialize_canvas ();
1231         void reset_scrolling_region (Gtk::Allocation* alloc = 0);
1232
1233         /* display control */
1234         
1235         bool _show_measures;
1236         bool _show_waveforms;
1237         bool _follow_playhead;
1238         bool _show_waveforms_recording;
1239         
1240         ARDOUR::TempoMap::BBTPointList *current_bbt_points;
1241         
1242         typedef vector<ArdourCanvas::SimpleLine*> TimeLineList;
1243         TimeLineList free_measure_lines;
1244         TimeLineList used_measure_lines;
1245
1246         ArdourCanvas::Group* time_line_group;
1247         ArdourCanvas::SimpleLine* get_time_line ();
1248         void hide_measures ();
1249         void draw_measures ();
1250         bool lazy_hide_and_draw_measures ();
1251
1252         void new_tempo_section ();
1253
1254         void mouse_add_new_tempo_event (nframes_t where);
1255         void mouse_add_new_meter_event (nframes_t where);
1256
1257         void remove_tempo_marker (ArdourCanvas::Item*);
1258         void remove_meter_marker (ArdourCanvas::Item*);
1259         gint real_remove_tempo_marker (ARDOUR::TempoSection*);
1260         gint real_remove_meter_marker (ARDOUR::MeterSection*);
1261         
1262         void edit_tempo_section (ARDOUR::TempoSection*);
1263         void edit_meter_section (ARDOUR::MeterSection*);
1264         void edit_tempo_marker (ArdourCanvas::Item*);
1265         void edit_meter_marker (ArdourCanvas::Item*);
1266         
1267         void marker_menu_edit ();
1268         void marker_menu_remove ();
1269         void marker_menu_rename ();
1270         void marker_menu_hide ();
1271         void marker_menu_loop_range ();
1272         void marker_menu_select_all_selectables_using_range ();
1273         void marker_menu_select_using_range ();
1274         void marker_menu_separate_regions_using_location ();
1275         void marker_menu_play_from ();
1276         void marker_menu_play_range ();
1277         void marker_menu_set_playhead ();
1278         void marker_menu_set_from_playhead ();
1279         void marker_menu_set_from_selection ();
1280         void new_transport_marker_menu_set_loop ();
1281         void new_transport_marker_menu_set_punch ();
1282         void update_loop_range_view (bool visibility=false);
1283         void update_punch_range_view (bool visibility=false);
1284         gint new_transport_marker_menu_popdown (GdkEventAny*);
1285         void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1286         void tm_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1287         void transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1288         void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1289         void build_range_marker_menu (bool loop_or_punch);
1290         void build_marker_menu (bool start_or_end);
1291         void build_tm_marker_menu ();
1292         void build_new_transport_marker_menu ();
1293
1294         Gtk::Menu* tm_marker_menu;
1295         Gtk::Menu* marker_menu;
1296         Gtk::Menu* start_end_marker_menu;
1297         Gtk::Menu* range_marker_menu;
1298         Gtk::Menu* transport_marker_menu;
1299         Gtk::Menu* new_transport_marker_menu;
1300         ArdourCanvas::Item* marker_menu_item;
1301
1302         typedef list<Marker*> Marks;
1303         Marks metric_marks;
1304
1305         void remove_metric_marks ();
1306         void draw_metric_marks (const ARDOUR::Metrics& metrics);
1307
1308         void tempo_map_changed (ARDOUR::Change);
1309         void redisplay_tempo (bool immediate_redraw);
1310         
1311         void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
1312         void snap_to (nframes_t& first, int32_t direction = 0, bool for_mark = false) {
1313                 /* XXX remove this function when everything moves to 64 bit frame counts */
1314                 nframes64_t first64 = first;
1315                 snap_to (first64, direction, for_mark);
1316                 first = (nframes_t) first64;
1317         }
1318
1319         uint32_t bbt_beat_subdivision;
1320
1321         /* toolbar */
1322         
1323         Gtk::ToggleButton        editor_mixer_button;
1324
1325         void editor_mixer_button_toggled ();
1326
1327         AudioClock               edit_cursor_clock;
1328         AudioClock               zoom_range_clock;
1329         Gtk::Button              zoom_in_button;
1330         Gtk::Button              zoom_out_button;
1331         Gtk::Button              zoom_out_full_button;
1332         Gtk::Button              zoom_onetoone_button;
1333
1334         Gtk::VBox                toolbar_clock_vbox;
1335         Gtk::VBox                toolbar_selection_clock_vbox; 
1336         Gtk::Table               toolbar_selection_clock_table;
1337         Gtk::Label               toolbar_selection_cursor_label;
1338         
1339         Gtk::HBox                mouse_mode_button_box;
1340         Gtkmm2ext::TearOff*      mouse_mode_tearoff;
1341         Gtk::ToggleButton        mouse_select_button;
1342         Gtk::ToggleButton        mouse_move_button;
1343         Gtk::ToggleButton        mouse_gain_button;
1344         Gtk::ToggleButton        mouse_zoom_button;
1345         Gtk::ToggleButton        mouse_timefx_button;
1346         Gtk::ToggleButton        mouse_audition_button;
1347         GroupedButtons          *mouse_mode_button_set;
1348         void                     mouse_mode_toggled (Editing::MouseMode m);
1349         bool                     ignore_mouse_mode_toggle;
1350
1351         gint                     mouse_select_button_release (GdkEventButton*);
1352
1353         Gtk::VBox                automation_box;
1354         Gtk::Button              automation_mode_button;
1355         Gtk::ToggleButton        global_automation_button;
1356
1357         Gtk::ComboBoxText edit_mode_selector;
1358         Gtk::VBox         edit_mode_box;
1359
1360         void edit_mode_selection_done ();
1361
1362         Gtk::ComboBoxText snap_type_selector;
1363         Gtk::ComboBoxText snap_mode_selector;
1364         Gtk::HBox         snap_box;
1365
1366         std::vector<std::string> snap_type_strings;
1367         std::vector<std::string> snap_mode_strings;
1368
1369         void snap_type_selection_done ();
1370         void snap_mode_selection_done ();
1371         void snap_mode_chosen (Editing::SnapMode);
1372         void snap_type_chosen (Editing::SnapType);
1373
1374         Glib::RefPtr<Gtk::RadioAction> snap_type_action (Editing::SnapType);
1375         Glib::RefPtr<Gtk::RadioAction> snap_mode_action (Editing::SnapMode);
1376
1377         Gtk::ComboBoxText zoom_focus_selector;
1378         Gtk::VBox         zoom_focus_box;
1379
1380         std::vector<std::string> zoom_focus_strings;
1381         
1382         void zoom_focus_selection_done ();
1383         void zoom_focus_chosen (Editing::ZoomFocus);
1384
1385         Glib::RefPtr<Gtk::RadioAction> zoom_focus_action (Editing::ZoomFocus);
1386
1387         Gtk::HBox           zoom_box;
1388
1389         void                zoom_adjustment_changed();
1390
1391         void                edit_cursor_clock_changed();
1392         
1393         void setup_toolbar ();
1394
1395         Gtkmm2ext::TearOff*       tools_tearoff;
1396         Gtk::HBox                toolbar_hbox;
1397         Gtk::EventBox            toolbar_base;
1398         Gtk::Frame               toolbar_frame;
1399
1400         /* selection process */
1401
1402         Selection* selection;
1403         Selection* cut_buffer;
1404
1405         void time_selection_changed ();
1406         void track_selection_changed ();
1407         void region_selection_changed ();
1408         void point_selection_changed ();
1409
1410         enum SelectionOp {
1411                 CreateSelection,
1412                 SelectionStartTrim,
1413                 SelectionEndTrim,
1414                 SelectionMove
1415         } selection_op;
1416
1417         void start_selection_op (ArdourCanvas::Item* item, GdkEvent* event, SelectionOp);
1418         void drag_selection (ArdourCanvas::Item* item, GdkEvent* event);
1419         void end_selection_op (ArdourCanvas::Item* item, GdkEvent* event);
1420         void cancel_selection ();
1421
1422         void region_selection_op (void (ARDOUR::Region::*pmf)(void));
1423         void region_selection_op (void (ARDOUR::Region::*pmf)(void*), void*);
1424         void region_selection_op (void (ARDOUR::Region::*pmf)(bool), bool);
1425
1426         bool audio_region_selection_covers (nframes_t where);
1427
1428         /* transport range select process */
1429         enum RangeMarkerOp {
1430                 CreateRangeMarker,
1431                 CreateTransportMarker
1432         } range_marker_op;
1433
1434         void start_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event, RangeMarkerOp);
1435         void drag_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event);
1436         void end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event);
1437
1438         ArdourCanvas::SimpleRect*  range_bar_drag_rect;
1439         ArdourCanvas::SimpleRect*  transport_bar_drag_rect;
1440         ArdourCanvas::Line*        marker_drag_line;
1441         ArdourCanvas::Points       marker_drag_line_points;
1442         ArdourCanvas::SimpleRect*  range_marker_drag_rect;
1443
1444         void update_marker_drag_item (ARDOUR::Location *);
1445         
1446         ArdourCanvas::SimpleRect     *transport_bar_range_rect;
1447         ArdourCanvas::SimpleRect     *transport_bar_preroll_rect;
1448         ArdourCanvas::SimpleRect     *transport_bar_postroll_rect;
1449         ArdourCanvas::SimpleRect     *transport_loop_range_rect;
1450         ArdourCanvas::SimpleRect     *transport_punch_range_rect;
1451         ArdourCanvas::SimpleLine     *transport_punchin_line;
1452         ArdourCanvas::SimpleLine     *transport_punchout_line;
1453         ArdourCanvas::SimpleRect     *transport_preroll_rect;
1454         ArdourCanvas::SimpleRect     *transport_postroll_rect;
1455
1456         ARDOUR::Location*  transport_loop_location();
1457         ARDOUR::Location*  transport_punch_location();
1458
1459         ARDOUR::Location   *temp_location;
1460         
1461         /* object rubberband select process */
1462         
1463         void start_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1464         void drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1465         void end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1466
1467         bool select_all_within (nframes_t start, nframes_t end, gdouble topy, gdouble boty, const TrackViewList&, Selection::Operation op);
1468         
1469         ArdourCanvas::SimpleRect   *rubberband_rect;
1470         
1471         /* mouse zoom process */
1472
1473         void start_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1474         void drag_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1475         void end_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1476
1477         ArdourCanvas::SimpleRect   *zoom_rect;
1478         void reposition_zoom_rect (nframes_t start, nframes_t end);
1479         
1480         /* diskstream/route display management */
1481
1482         struct RouteDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
1483             RouteDisplayModelColumns() { 
1484                     add (text);
1485                     add (visible);
1486                     add (tv);
1487             }
1488             Gtk::TreeModelColumn<Glib::ustring>  text;
1489             Gtk::TreeModelColumn<bool>           visible;
1490             Gtk::TreeModelColumn<TimeAxisView*>  tv;
1491         };
1492
1493         RouteDisplayModelColumns         route_display_columns;
1494         Glib::RefPtr<Gtk::ListStore>     route_display_model;
1495         Glib::RefPtr<Gtk::TreeSelection> route_display_selection;
1496
1497         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Route> > route_list_display; 
1498         Gtk::ScrolledWindow                   route_list_scroller;
1499         Gtk::Menu*                            route_list_menu;
1500
1501         bool route_list_display_button_press (GdkEventButton*);
1502         bool route_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
1503
1504         void route_list_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
1505         void route_list_delete (const Gtk::TreeModel::Path&);
1506         void initial_route_list_display ();
1507         void redisplay_route_list();
1508         void route_list_reordered (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* what);
1509         bool ignore_route_list_reorder;
1510         bool no_route_list_redisplay;
1511
1512         void build_route_list_menu ();
1513         void show_route_list_menu ();
1514
1515         void show_all_routes ();
1516         void hide_all_routes ();
1517         void show_all_audiotracks ();
1518         void hide_all_audiotracks ();
1519         void show_all_audiobus ();
1520         void hide_all_audiobus ();
1521
1522         void set_all_tracks_visibility (bool yn);
1523         void set_all_audio_visibility (int type, bool yn);
1524
1525         /* edit group management */
1526
1527         struct GroupListModelColumns : public Gtk::TreeModel::ColumnRecord {
1528                 GroupListModelColumns () {
1529                        add (is_active);
1530                        add (is_visible);
1531                        add (text);
1532                        add (routegroup);
1533                 }
1534                 Gtk::TreeModelColumn<bool> is_active;
1535                 Gtk::TreeModelColumn<bool> is_visible;
1536                 Gtk::TreeModelColumn<std::string> text;
1537                 Gtk::TreeModelColumn<ARDOUR::RouteGroup*>   routegroup;
1538         };
1539
1540         GroupListModelColumns group_columns;
1541         Glib::RefPtr<Gtk::ListStore> group_model;
1542         Glib::RefPtr<Gtk::TreeSelection> group_selection;
1543
1544         Gtk::TreeView          edit_group_display;
1545         Gtk::ScrolledWindow    edit_group_display_scroller;
1546         Gtk::Menu*             edit_group_list_menu;
1547
1548         void build_edit_group_list_menu ();
1549         void activate_all_edit_groups ();
1550         void disable_all_edit_groups ();
1551
1552         bool in_edit_group_row_change;
1553         void edit_group_row_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
1554         void edit_group_name_edit (const Glib::ustring&, const Glib::ustring&);
1555         void new_edit_group ();
1556         void edit_group_list_button_clicked ();
1557         gint edit_group_list_button_press_event (GdkEventButton* ev);
1558         void add_edit_group (ARDOUR::RouteGroup* group);
1559         void remove_selected_edit_group ();
1560         void edit_groups_changed ();
1561         void group_flags_changed (void*, ARDOUR::RouteGroup*);
1562
1563         Gtk::VBox           list_vpacker;
1564
1565         /* autoscrolling */
1566
1567         bool autoscroll_active;
1568         int autoscroll_timeout_tag;
1569         int autoscroll_direction;
1570         uint32_t autoscroll_cnt;
1571         nframes_t autoscroll_distance;
1572      
1573         static gint _autoscroll_canvas (void *);
1574         bool autoscroll_canvas ();
1575         void start_canvas_autoscroll (int direction);
1576         void stop_canvas_autoscroll ();
1577         void maybe_autoscroll (GdkEvent*);
1578
1579         /* trimming */
1580         enum TrimOp {
1581                 StartTrim,
1582                 EndTrim,
1583                 ContentsTrim,
1584         } trim_op;
1585
1586         void start_trim (ArdourCanvas::Item*, GdkEvent*);
1587         void point_trim (GdkEvent*);
1588         void trim_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1589         void single_contents_trim (RegionView&, nframes_t, bool, bool, bool);
1590         void single_start_trim (RegionView&, nframes_t, bool, bool);
1591         void single_end_trim (RegionView&, nframes_t, bool, bool);
1592
1593         void trim_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1594         void thaw_region_after_trim (RegionView& rv);
1595         
1596         void trim_region_to_edit_cursor ();
1597         void trim_region_from_edit_cursor ();
1598
1599         bool show_gain_after_trim;
1600
1601         /* Drag-n-Drop */
1602
1603         int convert_drop_to_paths (std::vector<Glib::ustring>& paths,
1604                                    const Glib::RefPtr<Gdk::DragContext>& context,
1605                                    gint                x,
1606                                    gint                y,
1607                                    const Gtk::SelectionData& data,
1608                                    guint               info,
1609                                    guint               time);
1610
1611         void  track_canvas_drag_data_received  (const Glib::RefPtr<Gdk::DragContext>& context,
1612                                                 gint                x,
1613                                                 gint                y,
1614                                                 const Gtk::SelectionData& data,
1615                                                 guint               info,
1616                                                 guint               time);
1617         
1618         void  region_list_display_drag_data_received  (const Glib::RefPtr<Gdk::DragContext>& context,
1619                                                        gint                x,
1620                                                        gint                y,
1621                                                        const Gtk::SelectionData& data,
1622                                                        guint               info,
1623                                                        guint               time);
1624
1625
1626         void  drop_paths  (const Glib::RefPtr<Gdk::DragContext>& context,
1627                            gint                x,
1628                            gint                y,
1629                            const Gtk::SelectionData& data,
1630                            guint               info,
1631                            guint               time);
1632
1633         void  drop_regions  (const Glib::RefPtr<Gdk::DragContext>& context,
1634                              gint                x,
1635                              gint                y,
1636                              const Gtk::SelectionData& data,
1637                              guint               info,
1638                              guint               time);
1639
1640         /* audio export */
1641
1642         ExportDialog *export_dialog;
1643         ExportDialog *export_range_markers_dialog;
1644         
1645         void export_range (nframes_t start, nframes_t end);
1646         void export_range_markers ();
1647
1648         int  write_region_selection(RegionSelection&);
1649         bool write_region (string path, boost::shared_ptr<ARDOUR::AudioRegion>);
1650         void export_region ();
1651         void bounce_region_selection ();
1652         void bounce_range_selection ();
1653         void external_edit_region ();
1654
1655         int write_audio_selection (TimeSelection&);
1656         bool write_audio_range (ARDOUR::AudioPlaylist&, uint32_t channels, list<ARDOUR::AudioRange>&);
1657
1658         void write_selection ();
1659
1660         /* history */
1661
1662         UndoAction get_memento() const;
1663
1664         XMLNode *before; /* used in *_reversible_command */
1665         void begin_reversible_command (string cmd_name);
1666         void commit_reversible_command ();
1667
1668         /* visual history */
1669
1670         UndoHistory visual_history;
1671         UndoTransaction current_visual_command;
1672
1673
1674         void update_title ();   
1675         void update_title_s (const string & snapshot_name);
1676
1677         struct State {
1678             Selection* selection;
1679             double     frames_per_unit;
1680
1681             State();
1682             ~State();
1683         };
1684
1685         void store_state (State&) const;
1686         void restore_state (State *);
1687
1688         void instant_save ();
1689
1690         boost::shared_ptr<ARDOUR::AudioRegion> last_audition_region;
1691         
1692         /* freeze operations */
1693
1694         ARDOUR::InterThreadInfo freeze_status;
1695         gint freeze_progress_timeout (void *);
1696         static void* _freeze_thread (void*);
1697         void* freeze_thread ();
1698
1699         void freeze_route ();
1700         void unfreeze_route ();
1701
1702         /* edit-group solo + mute */
1703
1704         void set_edit_group_solo (ARDOUR::Route&, bool);
1705         void set_edit_group_mute (ARDOUR::Route&, bool);
1706
1707         /* duplication */
1708
1709         void duplicate_dialog (bool for_region);
1710         
1711         nframes_t event_frame (GdkEvent*, double* px = 0, double* py = 0);
1712
1713         void time_fx_motion (ArdourCanvas::Item*, GdkEvent*);
1714         void start_time_fx (ArdourCanvas::Item*, GdkEvent*);
1715         void end_time_fx (ArdourCanvas::Item*, GdkEvent*);
1716
1717         struct TimeStretchDialog : public ArdourDialog {
1718             ARDOUR::Session::TimeStretchRequest request;
1719             Editor&               editor;
1720             RegionSelection       regions;
1721             Gtk::ProgressBar      progress_bar;
1722             Gtk::ToggleButton     quick_button;
1723             Gtk::ToggleButton     antialias_button;
1724             Gtk::Button*          cancel_button;
1725             Gtk::Button*          action_button;
1726             Gtk::HBox             upper_button_box;
1727             Gtk::VBox             packer;
1728             int                   status;
1729
1730             TimeStretchDialog (Editor& e);
1731
1732             gint update_progress ();
1733             sigc::connection first_cancel;
1734             sigc::connection first_delete;
1735             void cancel_timestretch_in_progress ();
1736             gint delete_timestretch_in_progress (GdkEventAny*);
1737         };
1738
1739         /* "whats mine is yours" */
1740
1741         friend class TimeStretchDialog;
1742
1743         TimeStretchDialog* current_timestretch;
1744
1745         static void* timestretch_thread (void *arg);
1746         int run_timestretch (RegionSelection&, float fraction);
1747         void do_timestretch (TimeStretchDialog&);
1748
1749         /* editor-mixer strip */
1750
1751         MixerStrip *current_mixer_strip;
1752         bool show_editor_mixer_when_tracks_arrive;
1753         Gtk::VBox current_mixer_strip_vbox;
1754         void cms_deleted ();
1755         void current_mixer_strip_hidden ();
1756         void current_mixer_strip_removed ();
1757
1758         void detach_tearoff (Gtk::Box* b, Gtk::Window* w);
1759         void reattach_tearoff (Gtk::Box* b, Gtk::Window* w, int32_t n);
1760
1761         /* nudging tracks */
1762
1763         void nudge_track (bool use_edit_cursor, bool forwards);
1764
1765         /* xfades */
1766
1767         bool _xfade_visibility;
1768         
1769         /* <CMT Additions> */
1770         void handle_new_imageframe_time_axis_view(const string & track_name, void* src) ;
1771         void handle_new_imageframe_marker_time_axis_view(const string & track_name, TimeAxisView* marked_track) ;
1772
1773         void start_imageframe_grab(ArdourCanvas::Item*, GdkEvent*) ;
1774         void start_markerview_grab(ArdourCanvas::Item*, GdkEvent*) ;
1775
1776         void imageframe_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
1777         void markerview_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
1778         void timeaxis_item_drag_finished_callback(ArdourCanvas::Item*, GdkEvent*) ;
1779
1780         gint canvas_imageframe_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
1781         gint canvas_imageframe_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameTimeAxis* ifta);
1782         gint canvas_imageframe_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
1783         gint canvas_imageframe_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
1784
1785         gint canvas_marker_time_axis_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerTimeAxis* mta);
1786         gint canvas_markerview_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
1787         gint canvas_markerview_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
1788         gint canvas_markerview_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
1789
1790         void imageframe_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
1791         void imageframe_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
1792         void imageframe_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
1793         void imageframe_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
1794         void imageframe_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
1795         void imageframe_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
1796         
1797         void markerview_item_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
1798         void markerview_item_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
1799         void markerview_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
1800         void markerview_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
1801         void markerview_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
1802         void markerview_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
1803
1804         void popup_imageframe_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
1805         void popup_marker_time_axis_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
1806
1807         ImageFrameSocketHandler* image_socket_listener ;
1808         /* </CMT Additions> */
1809
1810         void toggle_xfade_active (boost::weak_ptr<ARDOUR::Crossfade>);
1811         void toggle_xfade_length (boost::weak_ptr<ARDOUR::Crossfade>);
1812         void edit_xfade (boost::weak_ptr<ARDOUR::Crossfade>);
1813         void xfade_edit_left_region ();
1814         void xfade_edit_right_region ();
1815
1816         static const int32_t default_width = 995;
1817         static const int32_t default_height = 765;
1818
1819         /* nudge */
1820
1821         Gtk::Button      nudge_forward_button;
1822         Gtk::Button      nudge_backward_button;
1823         Gtk::HBox        nudge_hbox;
1824         Gtk::VBox        nudge_vbox;
1825         AudioClock       nudge_clock;
1826
1827         nframes_t get_nudge_distance (nframes_t pos, nframes_t& next);
1828         
1829         /* audio filters */
1830
1831         void apply_filter (ARDOUR::AudioFilter&, string cmd);
1832
1833         /* handling cleanup */
1834
1835         int playlist_deletion_dialog (boost::shared_ptr<ARDOUR::Playlist>);
1836
1837         vector<sigc::connection> session_connections;
1838
1839         /* tracking step changes of track height */
1840
1841         TimeAxisView* current_stepping_trackview;
1842         struct timeval last_track_height_step_timestamp;
1843         gint track_height_step_timeout();
1844         sigc::connection step_timeout;
1845
1846         TimeAxisView* entered_track;
1847         RegionView*   entered_regionview;
1848         bool clear_entered_track;
1849         gint left_track_canvas (GdkEventCrossing*);
1850         void set_entered_track (TimeAxisView*);
1851         void set_entered_regionview (RegionView*);
1852         gint left_automation_track ();
1853
1854         bool _new_regionviews_show_envelope;
1855
1856         void toggle_gain_envelope_visibility ();
1857         void toggle_gain_envelope_active ();
1858         void reset_region_gain_envelopes ();
1859
1860         Gtk::CheckMenuItem* region_envelope_visible_item;
1861         Gtk::CheckMenuItem* region_envelope_active_item;
1862         Gtk::CheckMenuItem* region_mute_item;
1863         Gtk::CheckMenuItem* region_lock_item;
1864         Gtk::CheckMenuItem* region_opaque_item;
1865         
1866         bool on_key_press_event (GdkEventKey*);
1867
1868         void session_state_saved (string);
1869
1870         Glib::RefPtr<Gtk::Action>              undo_action;
1871         Glib::RefPtr<Gtk::Action>              redo_action;
1872
1873         void history_changed ();
1874         void color_handler ();
1875 };
1876
1877 #endif /* __ardour_editor_h__ */