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