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