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