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