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