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