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