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