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