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