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