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