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