Remove most using declarations from header files.
[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 <bitset>
29
30 #include <glibmm/ustring.h>
31
32 #include <boost/optional.hpp>
33
34 #include <libgnomecanvasmm/canvas.h>
35 #include <libgnomecanvasmm/group.h>
36 #include <libgnomecanvasmm/line.h>
37 #include <libgnomecanvasmm/pixbuf.h>
38
39 #include <cmath>
40
41 #include <gtkmm/layout.h>
42 #include <gtkmm/comboboxtext.h>
43
44 #include <gtkmm2ext/selector.h>
45 #include <gtkmm2ext/click_box.h>
46 #include <gtkmm2ext/dndtreeview.h>
47
48 #include "pbd/stateful.h"
49 #include "ardour/session.h"
50 #include "ardour/tempo.h"
51 #include "ardour/stretch.h"
52 #include "ardour/location.h"
53 #include "ardour/audioregion.h"
54 #include "ardour/track.h"
55 #include "ardour/types.h"
56
57 #include "audio_clock.h"
58 #include "gtk-custom-ruler.h"
59 #include "ardour_dialog.h"
60 #include "public_editor.h"
61 #include "editing.h"
62 #include "enums.h"
63 #include "editor_items.h"
64 #include "region_selection.h"
65 #include "canvas.h"
66 #include "draginfo.h"
67
68 namespace Gtkmm2ext {
69         class TearOff;
70 }
71
72 namespace ARDOUR {
73         class AudioDiskstream;
74         class RouteGroup;
75         class Playlist;
76         class AudioPlaylist;
77         class Region;
78         class Location;
79         class TempoSection;
80         class NamedSelection;
81         class Session;
82         class Filter;
83         class Crossfade;
84         class ChanCount;
85 }
86
87 namespace LADSPA {
88         class Plugin;
89 }
90
91 class AnalysisWindow;
92 class AudioRegionView;
93 class AudioStreamView;
94 class AudioTimeAxisView;
95 class AutomationLine;
96 class AutomationSelection;
97 class AutomationTimeAxisView;
98 class BundleManager;
99 class ControlPoint;
100 class CrossfadeView;
101 class GlobalPortMatrixWindow;
102 class GroupedButtons;
103 class Marker;
104 class MixerStrip;
105 class PlaylistSelector;
106 class PluginSelector;
107 class RhythmFerret;
108 class Selection;
109 class SoundFileOmega;
110 class StreamView;
111 class TempoLines;
112 class TimeAxisView;
113 class TimeFXDialog;
114 class TimeSelection;
115 class TrackSelection;
116
117 /* <CMT Additions> */
118 class ImageFrameView;
119 class ImageFrameTimeAxisView;
120 class ImageFrameTimeAxis;
121 class MarkerTimeAxis ;
122 class MarkerView ;
123 class ImageFrameSocketHandler ;
124 class TimeAxisViewItem ;
125 /* </CMT Additions> */
126
127
128 class Editor : public PublicEditor
129 {
130   public:
131         Editor ();
132         ~Editor ();
133         
134         void             connect_to_session (ARDOUR::Session *);
135         ARDOUR::Session* current_session() const { return session; }
136         void             first_idle ();
137         virtual bool     have_idled () const { return _have_idled; }
138
139         nframes64_t leftmost_position() const { return leftmost_frame; }
140         nframes64_t current_page_frames() const {
141                 return (nframes64_t) floor (canvas_width * frames_per_unit);
142         }
143
144         void cycle_snap_mode ();
145         void cycle_snap_choice ();
146         void set_snap_to (Editing::SnapType);
147         void set_snap_mode (Editing::SnapMode);
148         void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;}
149
150         void undo (uint32_t n = 1);
151         void redo (uint32_t n = 1);
152
153         XMLNode& get_state ();
154         int set_state (const XMLNode& );
155
156         void set_mouse_mode (Editing::MouseMode, bool force=true);
157         void step_mouse_mode (bool next);
158         Editing::MouseMode current_mouse_mode () const { return mouse_mode; }
159         
160         void set_midi_edit_cursor (Editing::MidiEditMode);
161         void set_midi_edit_mode (Editing::MidiEditMode, bool force=true);
162         Editing::MidiEditMode current_midi_edit_mode () const { return midi_edit_mode; }
163
164 #ifdef WITH_CMT
165         void add_imageframe_time_axis(const std::string & track_name, void*) ;
166         void add_imageframe_marker_time_axis(const std::string & track_name, TimeAxisView* marked_track, void*) ;
167         void connect_to_image_compositor() ;
168         void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ;
169 #endif
170
171         TimeAxisView* get_named_time_axis(const std::string & name) ;
172         void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>);
173         void add_to_idle_resize (TimeAxisView*, uint32_t);
174
175         RouteTimeAxisView* get_route_view_by_id (PBD::ID& id);
176
177         void consider_auditioning (boost::shared_ptr<ARDOUR::Region>);
178         void hide_a_region (boost::shared_ptr<ARDOUR::Region>);
179         void remove_a_region (boost::shared_ptr<ARDOUR::Region>);
180
181 #ifdef USE_RUBBERBAND
182         std::vector<std::string> rb_opt_strings;
183 #endif
184
185         /* option editor-access */
186
187         void set_show_waveforms (bool yn);
188         bool show_waveforms() const { return _show_waveforms; }
189
190         void set_waveform_scale (Editing::WaveformScale);
191
192         void set_show_waveforms_recording (bool yn);
193         bool show_waveforms_recording() const { return _show_waveforms_recording; }
194         
195         /* things that need to be public to be used in the main menubar */
196
197         void new_region_from_selection ();
198         void separate_regions_between (const TimeSelection&);
199         void separate_region_from_selection ();
200         void separate_region_from_punch ();
201         void separate_region_from_loop ();
202         void separate_regions_using_location (ARDOUR::Location&);
203         void toggle_playback (bool with_abort);
204         void transition_to_rolling (bool forward);
205
206         /* undo related */
207
208         nframes64_t unit_to_frame (double unit) const {
209                 return (nframes64_t) rint (unit * frames_per_unit);
210         }
211         
212         double frame_to_unit (nframes64_t frame) const {
213                 return rint ((double) frame / (double) frames_per_unit);
214         }
215
216         double frame_to_unit (double frame) const {
217                 return rint (frame / frames_per_unit);
218         }
219
220         /* NOTE: these functions assume that the "pixel" coordinate is
221            the result of using the world->canvas affine transform on a
222            world coordinate. These coordinates already take into
223            account any scrolling carried out by adjusting the
224            xscroll_adjustment.  
225         */
226
227         nframes64_t pixel_to_frame (double pixel) const {
228                 
229                 /* pixel can be less than zero when motion events
230                    are processed. since we've already run the world->canvas
231                    affine, that means that the location *really* is "off
232                    to the right" and thus really is "before the start".
233                 */
234
235                 if (pixel >= 0) {
236                         return (nframes64_t) rint (pixel * frames_per_unit * GNOME_CANVAS(track_canvas->gobj())->pixels_per_unit);
237                 } else {
238                         return 0;
239                 }
240         }
241
242         gulong frame_to_pixel (nframes64_t frame) const {
243                 return (gulong) rint ((frame / (frames_per_unit * GNOME_CANVAS(track_canvas->gobj())->pixels_per_unit)));
244         }
245
246         void flush_canvas ();
247
248         /* selection */
249
250         Selection& get_selection() const { return *selection; }
251         Selection& get_cut_buffer() const { return *cut_buffer; }
252
253         bool extend_selection_to_track (TimeAxisView&);
254
255         void play_selection ();
256         void select_all_in_track (Selection::Operation op);
257         void select_all (Selection::Operation op);
258         void invert_selection_in_track ();
259         void invert_selection ();
260         void deselect_all ();
261
262         /* tempo */
263
264         void set_show_measures (bool yn);
265         bool show_measures () const { return _show_measures; }
266
267         /* analysis window */
268
269         void analyze_region_selection();
270         void analyze_range_selection();
271
272         /* export */
273         
274         void export_audio ();
275         void export_selection ();
276         void export_range ();
277         void export_region ();
278
279         void add_toplevel_controls (Gtk::Container&);
280         Gtk::HBox& get_status_bar_packer()  { return status_bar_hpacker; }
281
282         void               set_zoom_focus (Editing::ZoomFocus);
283         Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
284         double             get_current_zoom () const { return frames_per_unit; }
285
286         void temporal_zoom_step (bool coarser);
287
288         /* stuff that AudioTimeAxisView and related classes use */
289
290         PlaylistSelector& playlist_selector() const;
291         void route_name_changed (TimeAxisView *);
292         void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>);
293
294         void new_playlists (TimeAxisView* v);
295         void copy_playlists (TimeAxisView* v);
296         void clear_playlists (TimeAxisView* v);
297
298         TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0);
299         void get_onscreen_tracks (TrackViewList&);
300
301         Width editor_mixer_strip_width;
302         void maybe_add_mixer_strip_width (XMLNode&);
303         void show_editor_mixer (bool yn);
304         void create_editor_mixer ();
305         void show_editor_list (bool yn);
306         void set_selected_mixer_strip (TimeAxisView&);
307         void hide_track_in_display (TimeAxisView& tv, bool temporary = false);
308         void show_track_in_display (TimeAxisView& tv);
309
310         /* nudge is initiated by transport controls owned by ARDOUR_UI */
311
312         void nudge_forward (bool next, bool force_playhead);
313         void nudge_backward (bool next, bool force_playhead);
314
315         /* nudge initiated from context menu */
316
317         void nudge_forward_capture_offset ();
318         void nudge_backward_capture_offset ();
319
320         /* playhead/screen stuff */
321         
322         void set_follow_playhead (bool yn);
323         void toggle_follow_playhead ();
324         bool follow_playhead() const { return _follow_playhead; }
325         bool dragging_playhead () const { return _dragging_playhead; }
326
327         void toggle_waveform_visibility ();
328         void toggle_zero_line_visibility ();
329         void toggle_waveforms_while_recording ();
330         void toggle_measure_visibility ();
331         void toggle_logo_visibility ();
332
333         double get_physical_screen_width () const { return physical_screen_width; };
334         double physical_screen_width;
335         double physical_screen_height;
336
337         /* SMPTE timecode & video sync */
338
339         void smpte_fps_chosen (ARDOUR::SmpteFormat format);
340         void video_pullup_chosen (ARDOUR::Session::PullupFormat pullup);
341         void subframes_per_frame_chosen (uint32_t);
342
343         void update_smpte_mode ();
344         void update_video_pullup ();
345         void update_subframes_per_frame ();
346
347         /* fades/xfades */
348
349         void toggle_region_fades ();
350         void toggle_region_fades_visible ();
351         void toggle_selected_region_fades (int dir);
352         void update_region_fade_visibility ();
353         void toggle_auto_xfade ();
354         void toggle_xfades_active ();
355         void toggle_xfade_visibility ();
356         bool xfade_visibility() const { return _xfade_visibility; }
357         void update_xfade_visibility ();
358         void update_crossfade_model ();
359         void set_crossfade_model (ARDOUR::CrossfadeModel);
360
361         /* layers */
362         void set_layer_model (ARDOUR::LayerModel);
363         void update_layering_model ();
364         
365         void toggle_link_region_and_track_selection ();
366         void toggle_automation_follows_regions ();
367
368         /* redirect shared ops menu. caller must free returned menu */
369
370         Gtk::Menu* redirect_menu ();
371
372         /* floating windows/transient */
373
374         void ensure_float (Gtk::Window&);
375
376         void show_window ();
377
378         void scroll_tracks_down_line ();
379         void scroll_tracks_up_line ();
380
381         void move_selected_tracks (bool up);
382
383         bool new_regionviews_display_gain () { return _new_regionviews_show_envelope; }
384         void prepare_for_cleanup ();
385         void finish_cleanup ();
386
387         void maximise_editing_space();
388         void restore_editing_space();
389
390         void reset_x_origin (nframes64_t);
391         void reset_zoom (double);
392         void reposition_and_zoom (nframes64_t, double);
393
394         nframes64_t get_preferred_edit_position (bool ignore_playhead = false);
395
396         bool update_mouse_speed ();
397         bool decelerate_mouse_speed ();
398
399         void toggle_meter_updating();
400
401         void show_rhythm_ferret();
402         void show_bundle_manager ();
403         void show_global_port_matrix (ARDOUR::DataType);
404
405         void goto_visual_state (uint32_t);
406         void save_visual_state (uint32_t);
407
408         void queue_draw_resize_line (int at);
409         void start_resize_line_ops ();
410         void end_resize_line_ops ();
411
412   protected:
413         void map_transport_state ();
414         void map_position_change (nframes64_t);
415
416         void on_realize();
417         bool on_expose_event (GdkEventExpose*);
418
419   private:
420
421         /// The session that we are editing, or 0
422         void color_handler ();
423         ARDOUR::Session     *session;
424         bool                 constructed;
425
426         // to keep track of the playhead position for control_scroll
427         boost::optional<nframes64_t> _control_scroll_target;
428  
429         PlaylistSelector* _playlist_selector;
430
431         typedef std::pair<TimeAxisView*,XMLNode*> TAVState;
432
433         struct VisualState {
434             double              y_position;
435             double              frames_per_unit;
436             nframes64_t         leftmost_frame;
437             Editing::ZoomFocus  zoom_focus;
438             bool                zoomed_to_region;
439             std::list<TAVState> track_states;
440         };
441         
442         std::list<VisualState*> undo_visual_stack;
443         std::list<VisualState*> redo_visual_stack;
444         VisualState* current_visual_state (bool with_tracks = true);
445         void undo_visual_state ();
446         void redo_visual_state ();
447         void use_visual_state (VisualState&);
448         bool no_save_visual;
449         void swap_visual_state ();
450         
451         std::vector<VisualState*> visual_states;
452         sigc::connection visual_state_op_connection;
453         void start_visual_state_op (uint32_t n);
454         void cancel_visual_state_op (uint32_t n);
455         bool end_visual_state_op (uint32_t n);
456
457         nframes64_t leftmost_frame;
458         double      frames_per_unit;
459         Editing::ZoomFocus zoom_focus;
460
461         void set_frames_per_unit (double);
462         void post_zoom ();
463
464         Editing::MouseMode mouse_mode;
465         Editing::MidiEditMode midi_edit_mode;
466
467         int  post_maximal_editor_width;
468         int  post_maximal_pane_position;
469         int  pre_maximal_pane_position;
470         int  pre_maximal_editor_width;
471         void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*);
472
473         Gtk::Notebook the_notebook;
474         Gtk::HPaned   edit_pane;
475
476         Gtk::EventBox meter_base;
477         Gtk::HBox     meter_box;
478         Gtk::EventBox marker_base;
479         Gtk::HBox     marker_box;
480         Gtk::VBox     scrollers_rulers_markers_box;
481
482         void location_changed (ARDOUR::Location *);
483         void location_flags_changed (ARDOUR::Location *, void *);
484         void refresh_location_display ();
485         void refresh_location_display_s (ARDOUR::Change);
486         void refresh_location_display_internal (ARDOUR::Locations::LocationList&);
487         void add_new_location (ARDOUR::Location *);
488         void location_gone (ARDOUR::Location *);
489         void remove_marker (ArdourCanvas::Item&, GdkEvent*);
490         gint really_remove_marker (ARDOUR::Location* loc);
491         void goto_nth_marker (int nth);
492
493         uint32_t location_marker_color;
494         uint32_t location_range_color;
495         uint32_t location_loop_color;
496         uint32_t location_punch_color;
497         uint32_t location_cd_marker_color;
498
499         struct LocationMarkers {
500             Marker* start;
501             Marker* end;
502             bool    valid;
503
504             LocationMarkers () : start(0), end(0), valid (true) {}
505             
506             ~LocationMarkers ();
507
508             void hide();
509             void show ();
510             void set_name (const std::string&);
511             void set_position (nframes64_t start, nframes64_t end = 0);
512             void set_color_rgba (uint32_t);
513         };
514
515         LocationMarkers  *find_location_markers (ARDOUR::Location *) const;
516         ARDOUR::Location* find_location_from_marker (Marker *, bool& is_start) const;
517         Marker* entered_marker;
518
519         typedef std::map<ARDOUR::Location*,LocationMarkers *> LocationMarkerMap;
520         LocationMarkerMap location_markers;
521
522         void hide_marker (ArdourCanvas::Item*, GdkEvent*);
523         void clear_marker_display ();
524         void mouse_add_new_marker (nframes64_t where, bool is_cd=false, bool is_xrun=false);
525         bool choose_new_marker_name(std::string &name);
526         void update_cd_marker_display ();
527         void ensure_cd_marker_updated (LocationMarkers * lam, ARDOUR::Location * location);
528
529         TimeAxisView*      clicked_axisview;
530         RouteTimeAxisView* clicked_routeview;
531         /** The last RegionView that was clicked on, or 0 if the last click was not
532          * on a RegionView.  This is set up by the canvas event handlers in
533          * editor_canvas_events.cc
534          */
535         RegionView*        clicked_regionview;
536         RegionSelection    latest_regionviews;
537         uint32_t           clicked_selection;
538         CrossfadeView*     clicked_crossfadeview;
539         ControlPoint*      clicked_control_point;
540
541         void sort_track_selection (TrackSelection* sel = 0);
542
543         void get_relevant_tracks (std::set<RouteTimeAxisView*>& relevant_tracks);
544         void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&) const;
545         void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*) const;
546
547         /* functions to be passed to mapover_tracks(), possibly with sigc::bind()-supplied arguments */
548
549         void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, std::vector<RegionView*>*) const;
550         void mapped_use_new_playlist (RouteTimeAxisView&, uint32_t, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
551         void mapped_use_copy_playlist (RouteTimeAxisView&, uint32_t, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
552         void mapped_clear_playlist (RouteTimeAxisView&, uint32_t);
553
554         /* end */
555
556         void button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type);
557         bool button_release_can_deselect;
558
559         void catch_vanishing_regionview (RegionView *);
560
561         void set_selected_track (TimeAxisView&, Selection::Operation op = Selection::Set, bool no_remove=false);
562         void select_all_tracks ();
563         
564         int get_regionview_count_from_region_list (boost::shared_ptr<ARDOUR::Region> region);
565         
566         bool set_selected_control_point_from_click (Selection::Operation op = Selection::Set, bool no_remove=false);
567         void set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool no_remove=false);
568         void set_selected_track_as_side_effect (bool force = false);
569         bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set, bool no_track_remove=false);
570
571         void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
572         bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::weak_ptr<ARDOUR::Region>);
573         void collect_new_region_view (RegionView *);
574         void collect_and_select_new_region_view (RegionView *);
575         
576         Gtk::Menu track_context_menu;
577         Gtk::Menu track_region_context_menu;
578         Gtk::Menu track_selection_context_menu;
579         Gtk::Menu track_crossfade_context_menu;
580
581         Gtk::MenuItem* region_edit_menu_split_item;
582         Gtk::MenuItem* region_edit_menu_split_multichannel_item;
583         Gtk::Menu * track_region_edit_playlist_menu;
584         Gtk::Menu * track_edit_playlist_submenu;
585         Gtk::Menu * track_selection_edit_playlist_submenu;
586
587         void popup_track_context_menu (int, int, ItemType, bool, nframes64_t);
588         Gtk::Menu* build_track_context_menu (nframes64_t);
589         Gtk::Menu* build_track_bus_context_menu (nframes64_t);
590         Gtk::Menu* build_track_region_context_menu (nframes64_t frame);
591         Gtk::Menu* build_track_crossfade_context_menu (nframes64_t);
592         Gtk::Menu* build_track_selection_context_menu (nframes64_t);
593         void add_dstream_context_items (Gtk::Menu_Helpers::MenuList&);
594         void add_bus_context_items (Gtk::Menu_Helpers::MenuList&);
595         void add_region_context_items (StreamView*, boost::shared_ptr<ARDOUR::Region>, Gtk::Menu_Helpers::MenuList&);
596         void add_crossfade_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Crossfade>, Gtk::Menu_Helpers::MenuList&, bool many);
597         void add_selection_context_items (Gtk::Menu_Helpers::MenuList&);
598
599         void add_item_with_sensitivity (Gtk::Menu_Helpers::MenuList&, Gtk::Menu_Helpers::MenuElem, bool) const;
600
601         void handle_new_route (ARDOUR::RouteList&);
602         void remove_route (TimeAxisView *);
603         bool route_removal;
604
605         Gtk::HBox           global_hpacker;
606         Gtk::VBox           global_vpacker;
607         Gtk::VBox           vpacker;
608
609         bool need_resize_line;
610         int  resize_line_y;
611         int  old_resize_line_y;
612
613         Gdk::Cursor*          current_canvas_cursor;
614         void set_canvas_cursor ();
615         Gdk::Cursor* which_grabber_cursor ();
616
617         ArdourCanvas::Canvas* track_canvas;
618
619         ArdourCanvas::Text* first_action_message;
620         ArdourCanvas::Text* verbose_canvas_cursor;
621         bool                 verbose_cursor_visible;
622
623         void parameter_changed (const char *);
624         
625         bool track_canvas_motion (GdkEvent*);
626
627         void set_verbose_canvas_cursor (const std::string &, double x, double y);
628         void set_verbose_canvas_cursor_text (const std::string &);
629         void show_verbose_canvas_cursor();
630         void hide_verbose_canvas_cursor();
631
632         bool verbose_cursor_on; // so far unused
633
634         Gtk::EventBox             time_canvas_event_box;
635         Gtk::EventBox             track_canvas_event_box;
636         Gtk::EventBox             time_button_event_box;
637         Gtk::EventBox             ruler_label_event_box;
638
639         ArdourCanvas::Group      *minsec_group;
640         ArdourCanvas::Pixbuf     *logo_item;
641         ArdourCanvas::Group      *bbt_group;
642         ArdourCanvas::Group      *smpte_group;
643         ArdourCanvas::Group      *frame_group;
644         ArdourCanvas::Group      *tempo_group;
645         ArdourCanvas::Group      *meter_group;
646         ArdourCanvas::Group      *marker_group;
647         ArdourCanvas::Group      *range_marker_group;
648         ArdourCanvas::Group      *transport_marker_group;
649         ArdourCanvas::Group*      cd_marker_group;
650
651         ArdourCanvas::Group*      timebar_group;
652
653         /* These bars never need to be scrolled */
654         ArdourCanvas::Group*      meter_bar_group;
655         ArdourCanvas::Group*      tempo_bar_group;
656         ArdourCanvas::Group*      marker_bar_group;
657         ArdourCanvas::Group*      range_marker_bar_group;
658         ArdourCanvas::Group*      transport_marker_bar_group;
659         ArdourCanvas::Group*      cd_marker_bar_group;
660
661         /** The group containing all items that require horizontal scrolling. */
662         ArdourCanvas::Group* _background_group;
663         /* 
664            The _master_group is the group containing all items
665            that require horizontal scrolling..
666            It is primarily used to separate canvas items 
667            that require horizontal scrolling from those that do not. 
668         */
669         ArdourCanvas::Group* _master_group;
670
671         /* The group containing all trackviews.  Only scrolled vertically. */
672         ArdourCanvas::Group* _trackview_group;
673         
674         /* The group used for region motion.  Sits on top of _trackview_group */
675         ArdourCanvas::Group* _region_motion_group;
676         
677         enum RulerType {
678                 ruler_metric_smpte = 0,
679                 ruler_metric_bbt = 1,
680                 ruler_metric_frames = 2,
681                 ruler_metric_minsec = 3,
682
683                 ruler_time_tempo = 4,
684                 ruler_time_meter = 5,
685                 ruler_time_marker = 6,
686                 ruler_time_range_marker = 7,
687                 ruler_time_transport_marker = 8,
688                 ruler_time_cd_marker = 9,
689         };
690
691         static GtkCustomMetric ruler_metrics[4];
692         Glib::RefPtr<Gtk::ToggleAction> ruler_timecode_action;
693         Glib::RefPtr<Gtk::ToggleAction> ruler_bbt_action;
694         Glib::RefPtr<Gtk::ToggleAction> ruler_samples_action;
695         Glib::RefPtr<Gtk::ToggleAction> ruler_minsec_action;
696         Glib::RefPtr<Gtk::ToggleAction> ruler_tempo_action;
697         Glib::RefPtr<Gtk::ToggleAction> ruler_meter_action;
698         Glib::RefPtr<Gtk::ToggleAction> ruler_marker_action;
699         Glib::RefPtr<Gtk::ToggleAction> ruler_range_action;
700         Glib::RefPtr<Gtk::ToggleAction> ruler_loop_punch_action;
701         Glib::RefPtr<Gtk::ToggleAction> ruler_cd_marker_action;
702         bool                            no_ruler_shown_update;
703         
704         gint ruler_button_press (GdkEventButton*);
705         gint ruler_button_release (GdkEventButton*);
706         gint ruler_mouse_motion (GdkEventMotion*);
707         bool ruler_scroll (GdkEventScroll* event);
708
709         gint          ruler_pressed_button;
710         Gtk::Widget * ruler_grabbed_widget;
711         
712         void initialize_rulers ();
713         void update_just_smpte ();
714         void compute_fixed_ruler_scale (); //calculates the RulerScale of the fixed rulers
715         void update_fixed_rulers ();
716         void update_tempo_based_rulers (); 
717         void popup_ruler_menu (nframes64_t where = 0, ItemType type = RegionItem);
718         void update_ruler_visibility ();
719         void set_ruler_visible (RulerType, bool);
720         void toggle_ruler_visibility (RulerType rt);
721         void ruler_toggled (int);
722         gint ruler_label_button_release (GdkEventButton*);
723         void store_ruler_visibility ();
724         void restore_ruler_visibility ();
725         
726         static gint _metric_get_smpte (GtkCustomRulerMark **, gdouble, gdouble, gint);
727         static gint _metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
728         static gint _metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
729         static gint _metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
730         
731         enum MinsecRulerScale {
732                 minsec_show_seconds,
733                 minsec_show_minutes,
734                 minsec_show_hours,
735                 minsec_show_frames
736         };
737
738         MinsecRulerScale minsec_ruler_scale;
739
740         nframes_t minsec_mark_interval;
741         gint minsec_mark_modulo;
742         gint minsec_nmarks;
743         void set_minsec_ruler_scale (gdouble lower, gdouble upper);
744
745         enum SMPTERulerScale {
746                 smpte_show_bits,
747                 smpte_show_frames,
748                 smpte_show_seconds,
749                 smpte_show_minutes,
750                 smpte_show_hours
751         };
752
753         SMPTERulerScale smpte_ruler_scale;
754
755         nframes_t smpte_mark_interval;
756         gint smpte_mark_modulo;
757         gint smpte_nmarks;
758         void set_smpte_ruler_scale (gdouble lower, gdouble upper);
759
760         enum BBTRulerScale {
761                 bbt_over,
762                 bbt_show_64,
763                 bbt_show_16,
764                 bbt_show_4,
765                 bbt_show_1,
766                 bbt_show_beats,
767                 bbt_show_ticks,
768                 bbt_show_ticks_detail,
769                 bbt_show_ticks_super_detail
770         };
771
772         BBTRulerScale bbt_ruler_scale;
773
774         uint32_t bbt_bars;
775         gint bbt_nmarks;
776         uint32_t bbt_bar_helper_on;
777         uint32_t bbt_accent_modulo;
778         void compute_bbt_ruler_scale (nframes64_t lower, nframes64_t upper);
779
780         gint metric_get_smpte (GtkCustomRulerMark **, gdouble, gdouble, gint);
781         gint metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
782         gint metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
783         gint metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
784
785         Gtk::Widget        *_ruler_separator;
786         GtkWidget          *_smpte_ruler;
787         GtkWidget          *_bbt_ruler;
788         GtkWidget          *_frames_ruler;
789         GtkWidget          *_minsec_ruler;
790         Gtk::Widget        *smpte_ruler;
791         Gtk::Widget        *bbt_ruler;
792         Gtk::Widget        *frames_ruler;
793         Gtk::Widget        *minsec_ruler;
794         static Editor      *ruler_editor;
795
796         static const double timebar_height;
797         guint32 visible_timebars;
798         gdouble canvas_timebars_vsize;
799         gdouble get_canvas_timebars_vsize () const { return canvas_timebars_vsize; }
800         Gtk::Menu          *editor_ruler_menu;
801         
802         ArdourCanvas::SimpleRect* tempo_bar;
803         ArdourCanvas::SimpleRect* meter_bar;
804         ArdourCanvas::SimpleRect* marker_bar;
805         ArdourCanvas::SimpleRect* range_marker_bar;
806         ArdourCanvas::SimpleRect* transport_marker_bar;
807         ArdourCanvas::SimpleRect* cd_marker_bar;
808         
809         Gtk::Label  minsec_label;
810         Gtk::Label  bbt_label;
811         Gtk::Label  smpte_label;
812         Gtk::Label  frame_label;
813         Gtk::Label  tempo_label;
814         Gtk::Label  meter_label;
815         Gtk::Label  mark_label;
816         Gtk::Label  range_mark_label;
817         Gtk::Label  transport_mark_label;
818         Gtk::Label  cd_mark_label;
819
820         Gtk::VBox          time_button_vbox;
821         Gtk::HBox          time_button_hbox;
822
823         struct Cursor {
824             Editor&               editor;
825             ArdourCanvas::Points  points;
826             ArdourCanvas::Line    canvas_item;
827             nframes64_t           current_frame;
828             double                length;
829
830             Cursor (Editor&, bool (Editor::*)(GdkEvent*,ArdourCanvas::Item*));
831             ~Cursor ();
832
833             void set_position (nframes64_t);
834             void set_length (double units);
835             void set_y_axis (double position);
836         };
837
838         Cursor*              playhead_cursor;
839         ArdourCanvas::Group* cursor_group;
840
841         nframes64_t get_region_boundary (nframes64_t pos, int32_t dir, bool with_selection, bool only_onscreen);
842
843         void    cursor_to_region_boundary (bool with_selection, int32_t dir);
844         void    cursor_to_next_region_boundary (bool with_selection);
845         void    cursor_to_previous_region_boundary (bool with_selection);
846         void    cursor_to_next_region_point (Cursor*, ARDOUR::RegionPoint);
847         void    cursor_to_previous_region_point (Cursor*, ARDOUR::RegionPoint);
848         void    cursor_to_region_point (Cursor*, ARDOUR::RegionPoint, int32_t dir);
849         void    cursor_to_selection_start (Cursor *);
850         void    cursor_to_selection_end   (Cursor *);
851
852         void    selected_marker_to_region_boundary (bool with_selection, int32_t dir);
853         void    selected_marker_to_next_region_boundary (bool with_selection);
854         void    selected_marker_to_previous_region_boundary (bool with_selection);
855         void    selected_marker_to_next_region_point (ARDOUR::RegionPoint);
856         void    selected_marker_to_previous_region_point (ARDOUR::RegionPoint);
857         void    selected_marker_to_region_point (ARDOUR::RegionPoint, int32_t dir);
858         void    selected_marker_to_selection_start ();
859         void    selected_marker_to_selection_end   ();
860
861         void    select_all_selectables_using_cursor (Cursor *, bool);
862         void    select_all_selectables_using_edit (bool);
863         void    select_all_selectables_between (bool within);
864         void    select_range_between ();
865
866         boost::shared_ptr<ARDOUR::Region> find_next_region (nframes64_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
867         nframes64_t find_next_region_boundary (nframes64_t, int32_t dir, const TrackViewList&);
868
869         std::vector<nframes64_t> region_boundary_cache;
870         void build_region_boundary_cache ();
871
872         Gtk::HBox           top_hbox;
873         Gtk::HBox           bottom_hbox;
874         
875         Gtk::Table          edit_packer;
876         Gtk::VScrollbar     edit_vscrollbar;
877
878         Gtk::Adjustment     vertical_adjustment;
879         Gtk::Adjustment     horizontal_adjustment;
880
881         Gtk::Layout         controls_layout;
882         bool control_layout_scroll (GdkEventScroll* ev);
883         void controls_layout_size_request (Gtk::Requisition*);
884         sigc::connection controls_layout_size_request_connection;
885
886         Gtk::HScrollbar     edit_hscrollbar;
887         bool                _dragging_hscrollbar;
888
889         void reset_hscrollbar_stepping ();
890         
891         bool hscrollbar_button_press (GdkEventButton*);
892         bool hscrollbar_button_release (GdkEventButton*);
893         void hscrollbar_allocate (Gtk::Allocation &alloc);
894
895         double canvas_width;
896         double canvas_height;
897         double full_canvas_height;
898
899         bool track_canvas_map_handler (GdkEventAny*);
900
901         gint edit_controls_button_release (GdkEventButton*);
902         Gtk::Menu *edit_controls_left_menu;
903         Gtk::Menu *edit_controls_right_menu;
904
905         Gtk::VBox           ruler_label_vbox;
906         Gtk::VBox           track_canvas_vbox;
907         Gtk::VBox           time_canvas_vbox;
908         Gtk::VBox           edit_controls_vbox;
909         Gtk::HBox           edit_controls_hbox;
910
911         void control_scroll (float);
912         void access_action (std::string,std::string);
913         bool deferred_control_scroll (nframes64_t);
914         sigc::connection control_scroll_connection;
915
916         gdouble get_trackview_group_vertical_offset () const { return vertical_adjustment.get_value () - canvas_timebars_vsize;}
917         
918         ArdourCanvas::Group* get_background_group () const { return _background_group; }
919         ArdourCanvas::Group* get_trackview_group () const { return _trackview_group; }
920         double last_trackview_group_vertical_offset;
921         void tie_vertical_scrolling ();
922         void scroll_canvas_horizontally ();
923         void scroll_canvas_vertically ();
924         void canvas_horizontally_scrolled ();
925         void canvas_scroll_to (nframes64_t);
926
927         struct VisualChange {
928             enum Type { 
929                     TimeOrigin = 0x1,
930                     ZoomLevel = 0x2
931             };
932
933             Type pending;
934             nframes64_t time_origin;
935             double frames_per_unit;
936
937             int idle_handler_id;
938
939             VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), frames_per_unit (0), idle_handler_id (-1) {}
940         };
941
942
943         VisualChange pending_visual_change;
944
945         static int _idle_visual_changer (void *arg);
946         int idle_visual_changer ();
947
948         void queue_visual_change (nframes64_t);
949         void queue_visual_change (double);
950
951         void end_location_changed (ARDOUR::Location*);
952
953         struct RegionListDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
954             RegionListDisplayModelColumns() {
955                         add (name);
956                     add (region);
957                     add (color_);
958                     add (start);
959                     add (end);
960                     add (length);
961                         add (sync);
962                         add (fadein);
963                         add (fadeout);
964                         add (locked);
965                         add (glued);
966                         add (muted);
967                         add (opaque);
968                         add (used);
969                     add (path);
970             }
971             Gtk::TreeModelColumn<Glib::ustring> name;
972             Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
973             Gtk::TreeModelColumn<Gdk::Color> color_;
974             Gtk::TreeModelColumn<Glib::ustring> start;
975             Gtk::TreeModelColumn<Glib::ustring> end;
976             Gtk::TreeModelColumn<Glib::ustring> length;
977             Gtk::TreeModelColumn<Glib::ustring> sync;
978             Gtk::TreeModelColumn<Glib::ustring> fadein;
979             Gtk::TreeModelColumn<Glib::ustring> fadeout;
980             Gtk::TreeModelColumn<bool> locked;
981             Gtk::TreeModelColumn<bool> glued;
982             Gtk::TreeModelColumn<bool> muted;
983             Gtk::TreeModelColumn<bool> opaque;
984             Gtk::TreeModelColumn<Glib::ustring> used;
985             Gtk::TreeModelColumn<Glib::ustring> path;
986         };
987             
988         RegionListDisplayModelColumns          region_list_columns;
989         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > region_list_display;
990         
991         Glib::RefPtr<Gtk::TreeStore>           region_list_model;
992         Glib::RefPtr<Gtk::ToggleAction>        toggle_full_region_list_action;
993         Glib::RefPtr<Gtk::ToggleAction>        toggle_show_auto_regions_action;
994
995         void region_list_region_changed (ARDOUR::Change, boost::weak_ptr<ARDOUR::Region>);
996         void region_list_selection_changed ();
997         sigc::connection region_list_change_connection;
998         void set_selected_in_region_list(RegionSelection&);
999         bool set_selected_in_region_list_subrow(boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
1000         bool region_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
1001         void region_name_edit (const Glib::ustring&, const Glib::ustring&);
1002         void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions);
1003
1004         Gtk::Menu          *region_list_menu;
1005         Gtk::ScrolledWindow region_list_scroller;
1006         Gtk::Frame          region_list_frame;
1007
1008         bool region_list_display_key_press (GdkEventKey *);
1009         bool region_list_display_key_release (GdkEventKey *);
1010         bool region_list_display_button_press (GdkEventButton *);
1011         bool region_list_display_button_release (GdkEventButton *);
1012         void region_list_clear ();
1013         void region_list_selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
1014         void build_region_list_menu ();
1015         void show_region_list_display_context_menu (int button, int time);
1016
1017         bool show_automatic_regions_in_region_list;
1018         Editing::RegionListSortType region_list_sort_type;
1019
1020         void reset_region_list_sort_direction (bool);
1021         void reset_region_list_sort_type (Editing::RegionListSortType);
1022
1023         void toggle_full_region_list ();
1024         void toggle_show_auto_regions ();
1025
1026         int region_list_sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
1027
1028         /* snapshots */
1029
1030         Gtk::ScrolledWindow snapshot_display_scroller;
1031         struct SnapshotDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
1032             SnapshotDisplayModelColumns() { 
1033                     add (visible_name);
1034                     add (real_name);
1035             }
1036             Gtk::TreeModelColumn<Glib::ustring> visible_name;
1037             Gtk::TreeModelColumn<Glib::ustring> real_name;
1038         };
1039
1040         SnapshotDisplayModelColumns snapshot_display_columns;
1041         Glib::RefPtr<Gtk::ListStore> snapshot_display_model;
1042         Gtk::TreeView snapshot_display;
1043         Gtk::Menu snapshot_context_menu;
1044
1045         bool snapshot_display_button_press (GdkEventButton*);
1046         void snapshot_display_selection_changed ();
1047         void redisplay_snapshots();
1048         void popup_snapshot_context_menu (int, int32_t, Glib::ustring);
1049
1050         /* named selections */
1051
1052         struct NamedSelectionDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
1053             NamedSelectionDisplayModelColumns() { 
1054                     add (text);
1055                     add (selection);
1056             }
1057             Gtk::TreeModelColumn<Glib::ustring>  text;
1058             Gtk::TreeModelColumn<ARDOUR::NamedSelection*>    selection;
1059         };
1060
1061         NamedSelectionDisplayModelColumns named_selection_columns;
1062         Glib::RefPtr<Gtk::TreeStore>     named_selection_model;
1063
1064         Gtkmm2ext::DnDTreeView<ARDOUR::NamedSelection*> named_selection_display;
1065         Gtk::ScrolledWindow    named_selection_scroller;
1066
1067         void create_named_selection ();
1068         void paste_named_selection (float times);
1069         void remove_selected_named_selections ();
1070         void remove_snapshot (Glib::ustring);
1071         void rename_snapshot (Glib::ustring);
1072
1073         void handle_new_named_selection ();
1074         void add_named_selection_to_named_selection_display (ARDOUR::NamedSelection&);
1075         void redisplay_named_selections ();
1076
1077         bool named_selection_display_button_release (GdkEventButton *ev);
1078         bool named_selection_display_key_release (GdkEventKey *ev);
1079         void named_selection_display_selection_changed ();
1080
1081         /* track views */
1082         TrackViewList  track_views;
1083         std::pair<TimeAxisView*, ARDOUR::layer_t> trackview_by_y_position (double);
1084
1085         static Gdk::Cursor* cross_hair_cursor;
1086         static Gdk::Cursor* trimmer_cursor;
1087         static Gdk::Cursor* selector_cursor;
1088         static Gdk::Cursor* grabber_cursor;
1089         static Gdk::Cursor* grabber_edit_point_cursor;
1090         static Gdk::Cursor* zoom_cursor;
1091         static Gdk::Cursor* time_fx_cursor;
1092         static Gdk::Cursor* fader_cursor;
1093         static Gdk::Cursor* speaker_cursor;
1094         static Gdk::Cursor* midi_pencil_cursor;
1095         static Gdk::Cursor* midi_select_cursor;
1096         static Gdk::Cursor* midi_resize_cursor;
1097         static Gdk::Cursor* midi_erase_cursor;
1098         static Gdk::Cursor* wait_cursor;
1099         static Gdk::Cursor* timebar_cursor;
1100         static Gdk::Cursor* transparent_cursor;
1101
1102         static void build_cursors ();
1103
1104         sigc::connection scroll_connection;
1105         nframes64_t last_update_frame;
1106         void center_screen (nframes64_t);
1107         void center_screen_internal (nframes64_t, float);
1108         
1109         void update_current_screen ();
1110         
1111         void session_going_away ();
1112
1113         nframes64_t cut_buffer_start;
1114         nframes64_t cut_buffer_length;
1115
1116         bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
1117         bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1118         bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1119         bool motion_handler (ArdourCanvas::Item*, GdkEvent*, ItemType, bool from_autoscroll = false);
1120         bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1121         bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1122         
1123         /* KEYMAP HANDLING */
1124
1125         void register_actions ();
1126
1127         int ensure_cursor (nframes64_t* pos);
1128
1129         void handle_new_region (boost::weak_ptr<ARDOUR::Region>);
1130         void handle_new_regions (std::vector<boost::weak_ptr<ARDOUR::Region> >& );
1131         void handle_region_removed (boost::weak_ptr<ARDOUR::Region>);
1132         void add_region_to_region_display (boost::shared_ptr<ARDOUR::Region>);
1133         void add_regions_to_region_display (std::vector<boost::weak_ptr<ARDOUR::Region> > & );
1134         void region_hidden (boost::shared_ptr<ARDOUR::Region>);
1135         void redisplay_regions ();
1136         void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &);
1137         void update_region_row (boost::shared_ptr<ARDOUR::Region>);
1138         bool update_region_subrows (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
1139         void update_all_region_rows ();
1140         void update_all_region_subrows (Gtk::TreeModel::Row const &, int);
1141         bool no_region_list_redisplay;
1142         void insert_into_tmp_regionlist(boost::shared_ptr<ARDOUR::Region>);
1143
1144         std::list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
1145
1146         void cut_copy (Editing::CutCopyOp);
1147         bool can_cut_copy () const;
1148         void cut_copy_points (Editing::CutCopyOp);
1149         void cut_copy_regions (Editing::CutCopyOp, RegionSelection&);
1150         void cut_copy_ranges (Editing::CutCopyOp);
1151
1152         void mouse_paste ();
1153         void paste_internal (nframes64_t position, float times);
1154
1155         /* EDITING OPERATIONS */
1156         
1157         void reset_point_selection ();
1158         void toggle_region_mute ();
1159         void toggle_region_lock ();
1160         void toggle_region_opaque ();
1161         void toggle_record_enable ();
1162         void set_region_lock_style (ARDOUR::Region::PositionLockStyle);
1163         void raise_region ();
1164         void raise_region_to_top ();
1165         void lower_region ();
1166         void lower_region_to_bottom ();
1167         void split_region ();
1168         void split_region_at (nframes64_t);
1169         void split_regions_at (nframes64_t, RegionSelection&);
1170         void split_region_at_transients ();
1171         void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret);
1172         void crop_region_to_selection ();
1173         void crop_region_to (nframes64_t start, nframes64_t end);
1174         void set_sync_point (nframes64_t, const RegionSelection&);
1175         void set_region_sync_from_edit_point ();
1176         void remove_region_sync();
1177         void align_selection (ARDOUR::RegionPoint, nframes64_t position, const RegionSelection&);
1178         void align_selection_relative (ARDOUR::RegionPoint point, nframes64_t position, const RegionSelection&);
1179         void align_region (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes64_t position);
1180         void align_region_internal (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes64_t position);
1181         void remove_selected_regions ();
1182         void remove_clicked_region ();
1183         void edit_region ();
1184         void rename_region ();
1185         void duplicate_some_regions (RegionSelection&, float times);
1186         void duplicate_selection (float times);
1187         void region_fill_selection ();
1188
1189         void region_fill_track ();
1190         void audition_playlist_region_standalone (boost::shared_ptr<ARDOUR::Region>);
1191         void audition_playlist_region_via_route (boost::shared_ptr<ARDOUR::Region>, ARDOUR::Route&);
1192         void split_multichannel_region();
1193         void reverse_region ();
1194         void strip_region_silence ();
1195         void normalize_region ();
1196         void denormalize_region ();
1197         void adjust_region_scale_amplitude (bool up);
1198         void quantize_region ();
1199
1200         void do_insert_time ();
1201         void insert_time (nframes64_t pos, nframes64_t distance, Editing::InsertTimeOption opt, bool ignore_music_glue, bool markers_too);
1202
1203         void tab_to_transient (bool forward);
1204
1205         void use_region_as_bar ();
1206         void use_range_as_bar ();
1207
1208         void define_one_bar (nframes64_t start, nframes64_t end);
1209
1210         void audition_region_from_region_list ();
1211         void hide_region_from_region_list ();
1212         void remove_region_from_region_list ();
1213
1214         void align (ARDOUR::RegionPoint);
1215         void align_relative (ARDOUR::RegionPoint);
1216         void naturalize ();
1217
1218         void reset_focus ();
1219
1220         void split ();
1221
1222         void cut ();
1223         void copy ();
1224         void paste (float times);
1225
1226         int  get_prefix (float&, bool&);
1227
1228         void keyboard_paste ();
1229         void keyboard_insert_region_list_selection ();
1230
1231         void region_from_selection ();
1232         void create_region_from_selection (std::vector<boost::shared_ptr<ARDOUR::Region> >&);
1233
1234         void play_from_start ();
1235         void play_from_edit_point ();
1236         void play_from_edit_point_and_return ();
1237         void play_selected_region ();
1238         void play_edit_range ();
1239         void loop_selected_region ();
1240         void play_location (ARDOUR::Location&);
1241         void loop_location (ARDOUR::Location&);
1242
1243         void temporal_zoom_selection ();
1244         void temporal_zoom_region (bool both_axes);
1245         void toggle_zoom_region (bool both_axes);
1246         bool zoomed_to_region;
1247         void temporal_zoom_session ();
1248         void temporal_zoom (gdouble scale);
1249         void temporal_zoom_by_frame (nframes64_t start, nframes64_t end, const std::string & op);
1250         void temporal_zoom_to_frame (bool coarser, nframes64_t frame);
1251
1252         void amplitude_zoom (gdouble scale);
1253         void amplitude_zoom_step (bool in);
1254
1255         void insert_region_list_drag (boost::shared_ptr<ARDOUR::Region>, int x, int y);
1256         void insert_region_list_selection (float times);
1257
1258         void insert_route_list_drag (boost::shared_ptr<ARDOUR::Route>, int x, int y);
1259
1260         /* import & embed */
1261         
1262         void add_external_audio_action (Editing::ImportMode);
1263         void external_audio_dialog ();
1264         void session_import_dialog ();
1265
1266         int  check_whether_and_how_to_import(std::string, bool all_or_nothing = true);
1267         bool check_multichannel_status (const std::vector<Glib::ustring>& paths);
1268
1269         SoundFileOmega* sfbrowser;
1270         
1271         void bring_in_external_audio (Editing::ImportMode mode,  nframes64_t& pos);
1272
1273         bool  idle_drop_paths  (std::vector<Glib::ustring> paths, nframes64_t frame, double ypos);
1274         void  drop_paths_part_two  (const std::vector<Glib::ustring>& paths, nframes64_t frame, double ypos);
1275         
1276         void do_import (std::vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t&);
1277         void do_embed (std::vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode,  nframes64_t&);
1278
1279         int  import_sndfiles (std::vector<Glib::ustring> paths, Editing::ImportMode mode,  ARDOUR::SrcQuality, nframes64_t& pos,
1280                               int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>, bool, uint32_t total);
1281         int  embed_sndfiles (std::vector<Glib::ustring> paths, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode, 
1282                              nframes64_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&);
1283
1284         int add_sources (std::vector<Glib::ustring> paths, ARDOUR::SourceList& sources, nframes64_t& pos, Editing::ImportMode,
1285                          int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool add_channel_suffix);
1286         int finish_bringing_in_material (boost::shared_ptr<ARDOUR::Region> region, uint32_t, uint32_t,  nframes64_t& pos, Editing::ImportMode mode,
1287                                       boost::shared_ptr<ARDOUR::Track>& existing_track);
1288
1289         boost::shared_ptr<ARDOUR::AudioTrack> get_nth_selected_audio_track (int nth) const;
1290         boost::shared_ptr<ARDOUR::MidiTrack> get_nth_selected_midi_track (int nth) const;
1291
1292         /* generic interthread progress window */
1293         
1294         ArdourDialog* interthread_progress_window;
1295         Gtk::Label interthread_progress_label;
1296         Gtk::VBox interthread_progress_vbox;
1297         Gtk::ProgressBar interthread_progress_bar;
1298         Gtk::Button interthread_cancel_button;
1299         Gtk::Label interthread_cancel_label;
1300         sigc::connection  interthread_progress_connection;
1301         void interthread_cancel_clicked ();
1302         void build_interthread_progress_window ();
1303         ARDOUR::InterThreadInfo* current_interthread_info;
1304
1305         AnalysisWindow* analysis_window;
1306
1307         /* import specific info */
1308
1309         struct EditorImportStatus : public ARDOUR::Session::ImportStatus {
1310             Editing::ImportMode mode;
1311             nframes64_t pos;
1312             int target_tracks;
1313             int target_regions;
1314             boost::shared_ptr<ARDOUR::Track> track;
1315             bool replace;
1316         };
1317
1318         EditorImportStatus import_status;
1319         gint import_progress_timeout (void *);
1320         static void *_import_thread (void *);
1321         void* import_thread ();
1322         void finish_import ();
1323
1324         /* to support this ... */
1325
1326         void import_audio (bool as_tracks);
1327         void do_import (std::vector<Glib::ustring> paths, bool split, bool as_tracks);
1328
1329         void move_to_start ();
1330         void move_to_end ();
1331         void goto_frame ();
1332         void center_playhead ();
1333         void center_edit_point ();
1334         void edit_cursor_backward ();
1335         void edit_cursor_forward ();
1336         void playhead_forward_to_grid ();
1337         void playhead_backward_to_grid ();
1338         void playhead_backward ();
1339         void playhead_forward ();
1340         void scroll_playhead (bool forward);
1341         void scroll_backward (float pages=0.8f);
1342         void scroll_forward (float pages=0.8f);
1343         void scroll_tracks_down ();
1344         void scroll_tracks_up ();
1345         void delete_sample_forward ();
1346         void delete_sample_backward ();
1347         void delete_screen ();
1348         void search_backwards ();
1349         void search_forwards ();
1350         void set_mark ();
1351         void clear_markers ();
1352         void clear_ranges ();
1353         void clear_locations ();
1354         void unhide_markers ();
1355         void unhide_ranges ();
1356         void jump_forward_to_mark ();
1357         void jump_backward_to_mark ();
1358         void cursor_align (bool playhead_to_edit);
1359
1360         void remove_last_capture ();
1361         void select_all_selectables_using_time_selection ();
1362         void select_all_selectables_using_loop();
1363         void select_all_selectables_using_punch();
1364         void set_selection_from_range (ARDOUR::Location&);
1365         void set_selection_from_punch ();
1366         void set_selection_from_loop ();
1367         void set_selection_from_region ();
1368
1369         void add_location_mark (nframes64_t where);
1370         void add_location_from_audio_region ();
1371         void add_locations_from_audio_region ();
1372         void add_location_from_selection ();
1373         void set_loop_from_selection (bool play);
1374         void set_punch_from_selection ();
1375         void set_punch_from_region ();
1376
1377         void set_loop_from_edit_range (bool play);
1378         void set_loop_from_region (bool play);
1379         void set_punch_from_edit_range ();
1380
1381         void set_loop_range (nframes64_t start, nframes64_t end, std::string cmd);
1382         void set_punch_range (nframes64_t start, nframes64_t end, std::string cmd);
1383
1384         void add_location_from_playhead_cursor ();
1385         bool select_new_marker;
1386
1387         void reverse_selection ();
1388         void edit_envelope ();
1389
1390         void start_scrolling ();
1391         void stop_scrolling ();
1392
1393         bool _scrubbing;
1394         double last_scrub_x;
1395         int scrubbing_direction;
1396         int scrub_reversals;
1397         int scrub_reverse_distance;
1398         void scrub ();
1399
1400         void keyboard_selection_begin ();
1401         void keyboard_selection_finish (bool add);
1402         bool have_pending_keyboard_selection;
1403         nframes64_t pending_keyboard_selection_start;
1404
1405         boost::shared_ptr<ARDOUR::Region> select_region_for_operation (int dir, TimeAxisView **tv);
1406         void extend_selection_to_end_of_region (bool next);
1407         void extend_selection_to_start_of_region (bool previous);
1408
1409         Editing::SnapType snap_type;
1410         Editing::SnapMode snap_mode;
1411
1412         /// Snap threshold in pixels
1413         double snap_threshold;
1414
1415         void handle_gui_changes (const std::string &, void *);
1416         bool ignore_gui_changes;
1417
1418         void    hide_all_tracks (bool with_select);
1419
1420         DragInfo drag_info;
1421         LineDragInfo current_line_drag_info;
1422
1423         void start_grab (GdkEvent*, Gdk::Cursor* cursor = 0);
1424         bool end_grab (ArdourCanvas::Item*, GdkEvent*);
1425         void swap_grab (ArdourCanvas::Item*, Gdk::Cursor* cursor, uint32_t time);
1426         void break_drag ();
1427         void finalize_drag ();
1428
1429         Gtk::Menu fade_context_menu;
1430         void popup_fade_context_menu (int, int, ArdourCanvas::Item*, ItemType);
1431
1432         void region_gain_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1433
1434         void start_fade_in_grab (ArdourCanvas::Item*, GdkEvent*);
1435         void start_fade_out_grab (ArdourCanvas::Item*, GdkEvent*);
1436         void fade_in_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1437         void fade_out_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1438         void fade_in_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1439         void fade_out_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1440
1441         void set_fade_in_shape (ARDOUR::AudioRegion::FadeShape);
1442         void set_fade_out_shape (ARDOUR::AudioRegion::FadeShape);
1443         
1444         void set_fade_length (bool in);
1445         void toggle_fade_active (bool in);
1446         void set_fade_in_active (bool);
1447         void set_fade_out_active (bool);
1448         
1449         std::set<boost::shared_ptr<ARDOUR::Playlist> > motion_frozen_playlists;
1450         RegionSelection pre_drag_region_selection;
1451         void region_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1452         void region_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1453         void create_region_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1454         void create_region_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1455         bool check_region_drag_possible (RouteTimeAxisView**, ARDOUR::layer_t*);
1456         void possibly_copy_regions_during_grab (GdkEvent*);
1457         void region_drag_splice_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1458         void region_drag_splice_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1459
1460         bool _dragging_playhead;
1461         bool _dragging_edit_point;
1462
1463         void cursor_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1464         void cursor_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1465         void cursor_drag_finished_ensure_locate_callback (ArdourCanvas::Item*, GdkEvent*);
1466         void marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1467         void marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1468         void control_point_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1469         void control_point_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1470         void line_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1471         void line_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1472
1473         void tempo_marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1474         void tempo_marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1475         void meter_marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1476         void meter_marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1477
1478         gint mouse_rename_region (ArdourCanvas::Item*, GdkEvent*);
1479
1480         void start_region_grab (ArdourCanvas::Item*, GdkEvent*);
1481         void start_create_region_grab (ArdourCanvas::Item*, GdkEvent*);
1482         void start_region_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1483         void start_region_brush_grab (ArdourCanvas::Item*, GdkEvent*);
1484         void start_selection_grab (ArdourCanvas::Item*, GdkEvent*);
1485         void start_cursor_grab (ArdourCanvas::Item*, GdkEvent*);
1486         void start_cursor_grab_no_stop (ArdourCanvas::Item*, GdkEvent*);
1487         void start_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1488         void start_control_point_grab (ArdourCanvas::Item*, GdkEvent*);
1489         void start_line_grab_from_regionview (ArdourCanvas::Item*, GdkEvent*);
1490         void start_line_grab_from_line (ArdourCanvas::Item*, GdkEvent*);
1491         void start_line_grab (AutomationLine *, GdkEvent*);
1492         void start_tempo_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1493         void start_tempo_marker_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1494         void start_meter_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1495         void start_meter_marker_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1496
1497         void region_view_item_click (AudioRegionView&, GdkEventButton*);
1498
1499         void remove_gain_control_point (ArdourCanvas::Item*, GdkEvent*);
1500         void remove_control_point (ArdourCanvas::Item*, GdkEvent*);
1501
1502         void mouse_brush_insert_region (RegionView*, nframes64_t pos);
1503         void brush (nframes64_t);
1504
1505         void show_verbose_time_cursor (nframes64_t frame, double offset = 0, double xpos=-1, double ypos=-1);
1506         void show_verbose_duration_cursor (nframes64_t start, nframes64_t end, double offset = 0, double xpos=-1, double ypos=-1);
1507         double clamp_verbose_cursor_x (double);
1508         double clamp_verbose_cursor_y (double);
1509
1510         /* Canvas event handlers */
1511
1512         bool canvas_control_point_event (GdkEvent* event,ArdourCanvas::Item*, ControlPoint*);
1513         bool canvas_line_event (GdkEvent* event,ArdourCanvas::Item*, AutomationLine*);
1514         bool canvas_selection_rect_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1515         bool canvas_selection_start_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1516         bool canvas_selection_end_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1517         bool canvas_crossfade_view_event (GdkEvent* event,ArdourCanvas::Item*, CrossfadeView*);
1518         bool canvas_fade_in_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1519         bool canvas_fade_in_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1520         bool canvas_fade_out_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1521         bool canvas_fade_out_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1522         
1523
1524         // These variables are used to detect a feedback loop and break it to avoid a gui hang
1525 private:
1526         ArdourCanvas::Item *last_item_entered;
1527         int last_item_entered_n;
1528 public:
1529
1530         bool canvas_region_view_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1531         bool canvas_region_view_name_highlight_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1532         bool canvas_region_view_name_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1533         bool canvas_stream_view_event (GdkEvent* event,ArdourCanvas::Item*, RouteTimeAxisView*);
1534         bool canvas_marker_event (GdkEvent* event,ArdourCanvas::Item*, Marker*);
1535         bool canvas_zoom_rect_event (GdkEvent* event,ArdourCanvas::Item*);
1536         bool canvas_tempo_marker_event (GdkEvent* event,ArdourCanvas::Item*, TempoMarker*);
1537         bool canvas_meter_marker_event (GdkEvent* event,ArdourCanvas::Item*, MeterMarker*);
1538         bool canvas_automation_track_event(GdkEvent* event, ArdourCanvas::Item*, AutomationTimeAxisView*) ;
1539
1540         bool canvas_tempo_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1541         bool canvas_meter_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1542         bool canvas_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1543         bool canvas_range_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1544         bool canvas_transport_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1545         bool canvas_cd_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1546
1547         bool canvas_imageframe_item_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1548         bool canvas_imageframe_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameTimeAxis*);
1549         bool canvas_imageframe_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1550         bool canvas_imageframe_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1551         bool canvas_marker_time_axis_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerTimeAxis*);
1552         bool canvas_markerview_item_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1553         bool canvas_markerview_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1554         bool canvas_markerview_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1555
1556         /* non-public event handlers */
1557
1558         bool canvas_playhead_cursor_event (GdkEvent* event, ArdourCanvas::Item*);
1559         bool track_canvas_scroll (GdkEventScroll* event);
1560
1561         bool track_canvas_scroll_event (GdkEventScroll* event);
1562         bool track_canvas_button_press_event (GdkEventButton* event);
1563         bool track_canvas_button_release_event (GdkEventButton* event);
1564         bool track_canvas_motion_notify_event (GdkEventMotion* event);
1565
1566         Gtk::Allocation canvas_allocation;
1567         void track_canvas_allocate (Gtk::Allocation alloc);
1568         bool track_canvas_size_allocated ();
1569
1570         void set_playhead_cursor ();
1571
1572         void kbd_driver (sigc::slot<void,GdkEvent*>, bool use_track_canvas = true, bool use_time_canvas = true, bool can_select = true);
1573         void kbd_mute_unmute_region ();
1574         void kbd_brush ();
1575
1576         void kbd_do_brush (GdkEvent*);
1577         void kbd_do_audition (GdkEvent*);
1578
1579         void handle_new_duration ();
1580         void initialize_canvas ();
1581
1582         /* display control */
1583         
1584         bool _show_measures;
1585         /// true to show waveforms, otherwise false
1586         bool _show_waveforms;
1587         /// true if the editor should follow the playhead, otherwise false
1588         bool _follow_playhead;
1589         /// true if waveforms should be shown while recording audio tracks, otherwise false
1590         bool _show_waveforms_recording;
1591         
1592         ARDOUR::TempoMap::BBTPointList *current_bbt_points;
1593         
1594         TempoLines* tempo_lines;
1595
1596         ArdourCanvas::Group* time_line_group;
1597
1598         void hide_measures ();
1599         void draw_measures ();
1600         bool redraw_measures ();
1601
1602         void new_tempo_section ();
1603
1604         void mouse_add_new_tempo_event (nframes64_t where);
1605         void mouse_add_new_meter_event (nframes64_t where);
1606
1607         void remove_tempo_marker (ArdourCanvas::Item*);
1608         void remove_meter_marker (ArdourCanvas::Item*);
1609         gint real_remove_tempo_marker (ARDOUR::TempoSection*);
1610         gint real_remove_meter_marker (ARDOUR::MeterSection*);
1611         
1612         void edit_tempo_section (ARDOUR::TempoSection*);
1613         void edit_meter_section (ARDOUR::MeterSection*);
1614         void edit_tempo_marker (ArdourCanvas::Item*);
1615         void edit_meter_marker (ArdourCanvas::Item*);
1616         void edit_control_point (ArdourCanvas::Item*);
1617         
1618         void marker_menu_edit ();
1619         void marker_menu_remove ();
1620         void marker_menu_rename ();
1621         void marker_menu_lock (bool yn);
1622         void marker_menu_hide ();
1623         void marker_menu_loop_range ();
1624         void marker_menu_select_all_selectables_using_range ();
1625         void marker_menu_select_using_range ();
1626         void marker_menu_separate_regions_using_location ();
1627         void marker_menu_play_from ();
1628         void marker_menu_play_range ();
1629         void marker_menu_set_playhead ();
1630         void marker_menu_set_from_playhead ();
1631         void marker_menu_set_from_selection ();
1632         void marker_menu_range_to_next ();
1633         void new_transport_marker_menu_set_loop ();
1634         void new_transport_marker_menu_set_punch ();
1635         void update_loop_range_view (bool visibility=false);
1636         void update_punch_range_view (bool visibility=false);
1637         void new_transport_marker_menu_popdown ();
1638         void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1639         void tm_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1640         void transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1641         void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1642         void build_range_marker_menu (bool loop_or_punch);
1643         void build_marker_menu (bool start_or_end);
1644         void build_tm_marker_menu ();
1645         void build_new_transport_marker_menu ();
1646
1647         Gtk::Menu* tm_marker_menu;
1648         Gtk::Menu* marker_menu;
1649         Gtk::Menu* start_end_marker_menu;
1650         Gtk::Menu* range_marker_menu;
1651         Gtk::Menu* transport_marker_menu;
1652         Gtk::Menu* new_transport_marker_menu;
1653         Gtk::Menu* cd_marker_menu;
1654         ArdourCanvas::Item* marker_menu_item;
1655
1656         typedef std::list<Marker*> Marks;
1657         Marks metric_marks;
1658
1659         void remove_metric_marks ();
1660         void draw_metric_marks (const ARDOUR::Metrics& metrics);
1661
1662         void compute_current_bbt_points (nframes_t left, nframes_t right);
1663         void tempo_map_changed (ARDOUR::Change);
1664         void redisplay_tempo (bool immediate_redraw);
1665         
1666         void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
1667         
1668         double snap_length_beats (nframes64_t start);
1669
1670         uint32_t bbt_beat_subdivision;
1671
1672         /* toolbar */
1673
1674         Gtk::ToggleButton editor_mixer_button;
1675         Gtk::ToggleButton editor_list_button;
1676         void editor_mixer_button_toggled ();
1677         void editor_list_button_toggled ();
1678
1679         AudioClock               edit_point_clock;
1680         AudioClock               zoom_range_clock;
1681         Gtk::Button              zoom_in_button;
1682         Gtk::Button              zoom_out_button;
1683         Gtk::Button              zoom_out_full_button;
1684         Gtk::Button              zoom_onetoone_button;
1685
1686         Gtk::VBox                toolbar_clock_vbox;
1687         Gtk::VBox                toolbar_selection_clock_vbox; 
1688         Gtk::Table               toolbar_selection_clock_table;
1689         Gtk::Label               toolbar_selection_cursor_label;
1690         
1691         Gtk::HBox                mouse_mode_button_box;
1692         Gtkmm2ext::TearOff*      mouse_mode_tearoff;
1693         Gtk::ToggleButton        mouse_select_button;
1694         Gtk::ToggleButton        mouse_move_button;
1695         Gtk::ToggleButton        mouse_gain_button;
1696         Gtk::ToggleButton        mouse_zoom_button;
1697         Gtk::ToggleButton        mouse_timefx_button;
1698         Gtk::ToggleButton        mouse_audition_button;
1699         Gtk::ToggleButton        mouse_note_button;
1700         GroupedButtons          *mouse_mode_button_set;
1701         void                     mouse_mode_toggled (Editing::MouseMode m);
1702         bool                     ignore_mouse_mode_toggle;
1703
1704         gint                     mouse_select_button_release (GdkEventButton*);
1705
1706         Gtk::VBox                automation_box;
1707         Gtk::Button              automation_mode_button;
1708         Gtk::ToggleButton        global_automation_button;
1709
1710         Gtk::ComboBoxText edit_mode_selector;
1711         Gtk::VBox         edit_mode_box;
1712
1713         void set_edit_mode (ARDOUR::EditMode);
1714         void cycle_edit_mode ();
1715         void edit_mode_selection_done ();
1716
1717         Gtk::ComboBoxText snap_type_selector;
1718         Gtk::ComboBoxText snap_mode_selector;
1719         Gtk::HBox         snap_box;
1720
1721         std::vector<std::string> snap_type_strings;
1722         std::vector<std::string> snap_mode_strings;
1723
1724         void snap_type_selection_done ();
1725         void snap_mode_selection_done ();
1726         void snap_mode_chosen (Editing::SnapMode);
1727         void snap_type_chosen (Editing::SnapType);
1728
1729         Glib::RefPtr<Gtk::RadioAction> snap_type_action (Editing::SnapType);
1730         Glib::RefPtr<Gtk::RadioAction> snap_mode_action (Editing::SnapMode);
1731
1732         Gtk::ComboBoxText zoom_focus_selector;
1733         Gtk::VBox         zoom_focus_box;
1734
1735         std::vector<std::string> zoom_focus_strings;
1736         
1737         void zoom_focus_selection_done ();
1738         void zoom_focus_chosen (Editing::ZoomFocus);
1739
1740         Glib::RefPtr<Gtk::RadioAction> zoom_focus_action (Editing::ZoomFocus);
1741
1742         Gtk::HBox           zoom_box;
1743
1744         void                zoom_adjustment_changed();
1745
1746         void                edit_point_clock_changed();
1747         
1748         void setup_toolbar ();
1749
1750         Gtkmm2ext::TearOff*      tools_tearoff;
1751         Gtk::HBox                toolbar_hbox;
1752         Gtk::EventBox            toolbar_base;
1753         Gtk::Frame               toolbar_frame;
1754
1755         /* midi toolbar */
1756
1757         Gtk::HBox                midi_tool_button_box;
1758         Gtk::ToggleButton        midi_tool_pencil_button;
1759         Gtk::ToggleButton        midi_tool_select_button;
1760         Gtk::ToggleButton        midi_tool_resize_button;
1761         Gtk::ToggleButton        midi_tool_erase_button;
1762         Gtk::Button              midi_panic_button;
1763         Gtk::ToggleButton        midi_sound_notes;
1764         GroupedButtons          *midi_tool_button_set;
1765         void                     midi_edit_mode_toggled (Editing::MidiEditMode m);
1766         void                     midi_panic_button_pressed ();
1767         bool                     sound_notes () const { return midi_sound_notes.get_active(); }
1768         
1769         bool                     ignore_midi_edit_mode_toggle;
1770
1771         Gtkmm2ext::TearOff* midi_tools_tearoff;
1772         Gtk::HBox           midi_toolbar_hbox;
1773         Gtk::EventBox       midi_toolbar_base;
1774         Gtk::Frame          midi_toolbar_frame;
1775         
1776         void setup_midi_toolbar ();
1777
1778         /* selection process */
1779
1780         Selection* selection;
1781         Selection* cut_buffer;
1782
1783         void time_selection_changed ();
1784         void track_selection_changed ();
1785         void region_selection_changed ();
1786         sigc::connection editor_regions_selection_changed_connection;
1787         void sensitize_the_right_region_actions (bool have_selected_regions);
1788         void point_selection_changed ();
1789         void marker_selection_changed ();
1790
1791         enum SelectionOp {
1792                 CreateSelection,
1793                 SelectionStartTrim,
1794                 SelectionEndTrim,
1795                 SelectionMove
1796         } selection_op;
1797
1798         void start_selection_op (ArdourCanvas::Item* item, GdkEvent* event, SelectionOp);
1799         void drag_selection (ArdourCanvas::Item* item, GdkEvent* event);
1800         void end_selection_op (ArdourCanvas::Item* item, GdkEvent* event);
1801         void cancel_selection ();
1802
1803         void region_selection_op (void (ARDOUR::Region::*pmf)(void));
1804         void region_selection_op (void (ARDOUR::Region::*pmf)(void*), void*);
1805         void region_selection_op (void (ARDOUR::Region::*pmf)(bool), bool);
1806
1807         bool audio_region_selection_covers (nframes64_t where);
1808
1809         /* transport range select process */
1810         enum RangeMarkerOp {
1811                 CreateRangeMarker,
1812                 CreateTransportMarker,
1813                 CreateCDMarker
1814         } range_marker_op;
1815
1816         void start_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event, RangeMarkerOp);
1817         void drag_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event);
1818         void end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event);
1819
1820         ArdourCanvas::SimpleRect*  cd_marker_bar_drag_rect;
1821         ArdourCanvas::SimpleRect*  range_bar_drag_rect;
1822         ArdourCanvas::SimpleRect*  transport_bar_drag_rect;
1823         ArdourCanvas::Line*        marker_drag_line;
1824         ArdourCanvas::Points       marker_drag_line_points;
1825         ArdourCanvas::SimpleRect*  range_marker_drag_rect;
1826
1827         void update_marker_drag_item (ARDOUR::Location *);
1828 #ifdef GTKOSX
1829         ArdourCanvas::SimpleRect     *bogus_background_rect;
1830 #endif
1831         ArdourCanvas::SimpleRect     *transport_bar_range_rect;
1832         ArdourCanvas::SimpleRect     *transport_bar_preroll_rect;
1833         ArdourCanvas::SimpleRect     *transport_bar_postroll_rect;
1834         ArdourCanvas::SimpleRect     *transport_loop_range_rect;
1835         ArdourCanvas::SimpleRect     *transport_punch_range_rect;
1836         ArdourCanvas::SimpleLine     *transport_punchin_line;
1837         ArdourCanvas::SimpleLine     *transport_punchout_line;
1838         ArdourCanvas::SimpleRect     *transport_preroll_rect;
1839         ArdourCanvas::SimpleRect     *transport_postroll_rect;
1840
1841         ARDOUR::Location*  transport_loop_location();
1842         ARDOUR::Location*  transport_punch_location();
1843
1844         ARDOUR::Location   *temp_location;
1845         
1846         /* object rubberband select process */
1847         
1848         void start_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1849         void drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1850         void end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1851
1852         bool select_all_within (nframes64_t start, nframes64_t end, gdouble topy, gdouble boty, const TrackViewList&, Selection::Operation op);
1853         
1854         ArdourCanvas::SimpleRect   *rubberband_rect;
1855         
1856         /* mouse zoom process */
1857
1858         void start_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1859         void drag_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1860         void end_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1861
1862         ArdourCanvas::SimpleRect   *zoom_rect;
1863         void reposition_zoom_rect (nframes64_t start, nframes64_t end);
1864         
1865         /* diskstream/route display management */
1866
1867         struct RouteDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
1868             RouteDisplayModelColumns() { 
1869                     add (text);
1870                     add (visible);
1871                     add (temporary_visible);
1872                     add (tv);
1873                     add (route);
1874             }
1875             Gtk::TreeModelColumn<Glib::ustring>  text;
1876             Gtk::TreeModelColumn<bool>           visible;
1877             Gtk::TreeModelColumn<bool>           temporary_visible;
1878             Gtk::TreeModelColumn<TimeAxisView*>  tv;
1879             Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> >  route;
1880         };
1881
1882         RouteDisplayModelColumns         route_display_columns;
1883         Glib::RefPtr<Gtk::ListStore>     route_display_model;
1884         Glib::RefPtr<Gtk::TreeSelection> route_display_selection;
1885
1886         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Route> > route_list_display; 
1887         Gtk::ScrolledWindow                   route_list_scroller;
1888         Gtk::Menu*                            route_list_menu;
1889
1890         void update_route_visibility ();
1891
1892         void sync_order_keys (const char*);
1893         bool route_redisplay_does_not_sync_order_keys;
1894         bool route_redisplay_does_not_reset_order_keys;
1895
1896         bool route_list_display_button_press (GdkEventButton*);
1897         void route_list_display_drag_data_received  (const Glib::RefPtr<Gdk::DragContext>& context,
1898                                                      gint                x,
1899                                                      gint                y,
1900                                                      const Gtk::SelectionData& data,
1901                                                      guint               info,
1902                                                      guint               time);
1903
1904         bool route_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
1905
1906         void route_list_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
1907         void route_list_delete (const Gtk::TreeModel::Path&);
1908         void track_list_reorder (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* new_order);
1909
1910         void initial_route_list_display ();
1911         void redisplay_route_list();
1912         void route_list_reordered (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* what);
1913         bool ignore_route_list_reorder;
1914         bool no_route_list_redisplay;
1915         bool sync_track_view_list_and_route_list ();
1916
1917         void build_route_list_menu ();
1918         void show_route_list_menu ();
1919
1920         void show_all_routes ();
1921         void hide_all_routes ();
1922         void show_all_audiotracks ();
1923         void hide_all_audiotracks ();
1924         void show_all_audiobus ();
1925         void hide_all_audiobus ();
1926
1927         void set_all_tracks_visibility (bool yn);
1928         void set_all_audio_visibility (int type, bool yn);
1929
1930         /* edit group management */
1931
1932         struct GroupListModelColumns : public Gtk::TreeModel::ColumnRecord {
1933                 GroupListModelColumns () {
1934                        add (is_active);
1935                        add (is_visible);
1936                        add (text);
1937                        add (routegroup);
1938                 }
1939                 Gtk::TreeModelColumn<bool> is_active;
1940                 Gtk::TreeModelColumn<bool> is_visible;
1941                 Gtk::TreeModelColumn<std::string> text;
1942                 Gtk::TreeModelColumn<ARDOUR::RouteGroup*>   routegroup;
1943         };
1944
1945         GroupListModelColumns group_columns;
1946         Glib::RefPtr<Gtk::ListStore> group_model;
1947         Glib::RefPtr<Gtk::TreeSelection> group_selection;
1948
1949         Gtk::TreeView          edit_group_display;
1950         Gtk::ScrolledWindow    edit_group_display_scroller;
1951         Gtk::Menu*             edit_group_list_menu;
1952
1953         void build_edit_group_list_menu ();
1954         void activate_all_edit_groups ();
1955         void disable_all_edit_groups ();
1956
1957         bool in_edit_group_row_change;
1958         void edit_group_row_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
1959         void edit_group_name_edit (const Glib::ustring&, const Glib::ustring&);
1960         void new_edit_group ();
1961         void edit_group_list_button_clicked ();
1962         gint edit_group_list_button_press_event (GdkEventButton* ev);
1963         void add_edit_group (ARDOUR::RouteGroup* group);
1964         void remove_selected_edit_group ();
1965         void edit_groups_changed ();
1966         void group_flags_changed (void*, ARDOUR::RouteGroup*);
1967
1968         Gtk::VBox           list_vpacker;
1969
1970         /* autoscrolling */
1971
1972         bool autoscroll_active;
1973         int autoscroll_timeout_tag;
1974         int autoscroll_x;
1975         int autoscroll_y;
1976         int last_autoscroll_x;
1977         int last_autoscroll_y;
1978         uint32_t autoscroll_cnt;
1979         nframes64_t autoscroll_x_distance;
1980         double autoscroll_y_distance;
1981
1982         static gint _autoscroll_canvas (void *);
1983         bool autoscroll_canvas ();
1984         void start_canvas_autoscroll (int x, int y);
1985         void stop_canvas_autoscroll ();
1986         void maybe_autoscroll (GdkEventMotion*);
1987         void maybe_autoscroll_horizontally (GdkEventMotion*);
1988         bool allow_vertical_scroll;
1989
1990         /* trimming */
1991         enum TrimOp {
1992                 StartTrim,
1993                 EndTrim,
1994                 ContentsTrim,
1995         } trim_op;
1996
1997         void start_trim (ArdourCanvas::Item*, GdkEvent*);
1998         void point_trim (GdkEvent*);
1999         void trim_motion_callback (ArdourCanvas::Item*, GdkEvent*);
2000         void single_contents_trim (RegionView&, nframes64_t, bool, bool, bool);
2001         void single_start_trim (RegionView&, nframes64_t, bool, bool, bool);
2002         void single_end_trim (RegionView&, nframes64_t, bool, bool, bool);
2003
2004         void trim_finished_callback (ArdourCanvas::Item*, GdkEvent*);
2005         void thaw_region_after_trim (RegionView& rv);
2006
2007         void trim_region_front();
2008         void trim_region_back();
2009         void trim_region (bool front);
2010
2011         void trim_region_to_edit_point ();
2012         void trim_region_from_edit_point ();
2013         void trim_region_to_loop ();
2014         void trim_region_to_punch ();
2015         void trim_region_to_location (const ARDOUR::Location&, const char* cmd);
2016
2017         void trim_to_region(bool forward);
2018         void trim_region_to_previous_region_end();
2019         void trim_region_to_next_region_start();
2020
2021         bool show_gain_after_trim;
2022
2023         /* Drag-n-Drop */
2024
2025         int convert_drop_to_paths (
2026                         std::vector<Glib::ustring>&           paths,
2027                         const Glib::RefPtr<Gdk::DragContext>& context,
2028                         gint                                  x,
2029                         gint                                  y,
2030                         const Gtk::SelectionData&             data,
2031                         guint                                 info,
2032                         guint                                 time);
2033
2034         void track_canvas_drag_data_received (
2035                         const Glib::RefPtr<Gdk::DragContext>& context,
2036                         gint                                  x,
2037                         gint                                  y,
2038                         const Gtk::SelectionData&             data,
2039                         guint                                 info,
2040                         guint                                 time);
2041         
2042         void region_list_display_drag_data_received (
2043                         const Glib::RefPtr<Gdk::DragContext>& context,
2044                         gint                                  x,
2045                         gint                                  y,
2046                         const Gtk::SelectionData&             data,
2047                         guint                                 info,
2048                         guint                                 time);
2049
2050         void drop_paths (
2051                         const Glib::RefPtr<Gdk::DragContext>& context,
2052                         gint                                  x,
2053                         gint                                  y,
2054                         const Gtk::SelectionData&             data,
2055                         guint                                 info,
2056                         guint                                 time);
2057
2058         void drop_regions (
2059                         const Glib::RefPtr<Gdk::DragContext>& context,
2060                         gint                                  x,
2061                         gint                                  y,
2062                         const Gtk::SelectionData&             data,
2063                         guint                                 info,
2064                         guint                                 time);
2065
2066         void drop_routes (
2067                         const Glib::RefPtr<Gdk::DragContext>& context,
2068                         gint                x,
2069                         gint                y,
2070                         const Gtk::SelectionData& data,
2071                         guint               info,
2072                         guint               time);
2073
2074         /* audio export */
2075
2076         int  write_region_selection(RegionSelection&);
2077         bool write_region (std::string path, boost::shared_ptr<ARDOUR::AudioRegion>);
2078         void bounce_region_selection ();
2079         void bounce_range_selection (bool replace, bool enable_processing);
2080         void external_edit_region ();
2081
2082         int write_audio_selection (TimeSelection&);
2083         bool write_audio_range (ARDOUR::AudioPlaylist&, const ARDOUR::ChanCount& channels, std::list<ARDOUR::AudioRange>&);
2084
2085         void write_selection ();
2086
2087         XMLNode *before; /* used in *_reversible_command */
2088
2089         void begin_reversible_command (std::string cmd_name);
2090         void commit_reversible_command ();
2091
2092         void update_title ();   
2093         void update_title_s (const std::string & snapshot_name);
2094
2095         struct State {
2096             Selection* selection;
2097             double frames_per_unit;
2098
2099             State (PublicEditor const * e);
2100             ~State ();
2101         };
2102
2103         void store_state (State&) const;
2104         void restore_state (State *);
2105
2106         void instant_save ();
2107
2108         boost::shared_ptr<ARDOUR::AudioRegion> last_audition_region;
2109         
2110         /* freeze operations */
2111
2112         ARDOUR::InterThreadInfo freeze_status;
2113         gint freeze_progress_timeout (void *);
2114         static void* _freeze_thread (void*);
2115         void* freeze_thread ();
2116
2117         void freeze_route ();
2118         void unfreeze_route ();
2119
2120         /* edit-group solo + mute */
2121
2122         void set_edit_group_solo (ARDOUR::Route&, bool);
2123         void set_edit_group_mute (ARDOUR::Route&, bool);
2124
2125         /* duplication */
2126
2127         void duplicate_dialog (bool with_dialog);
2128         
2129         nframes64_t event_frame (GdkEvent*, double* px = 0, double* py = 0) const;
2130
2131         /* returns false if mouse pointer is not in track or marker canvas
2132          */
2133         bool mouse_frame (nframes64_t&, bool& in_track_canvas) const;
2134
2135         void time_fx_motion (ArdourCanvas::Item*, GdkEvent*);
2136         void start_time_fx (ArdourCanvas::Item*, GdkEvent*);
2137         void end_time_fx (ArdourCanvas::Item*, GdkEvent*);
2138
2139         /* "whats mine is yours" */
2140
2141         TimeFXDialog* current_timefx;
2142
2143         static void* timefx_thread (void *arg);
2144         void do_timefx (TimeFXDialog&);
2145
2146         int time_stretch (RegionSelection&, float fraction);
2147         int pitch_shift (RegionSelection&, float cents);
2148         void pitch_shift_regions ();
2149         int time_fx (RegionSelection&, float val, bool pitching);
2150
2151         /* editor-mixer strip */
2152
2153         MixerStrip *current_mixer_strip;
2154         bool show_editor_mixer_when_tracks_arrive;
2155         Gtk::VBox current_mixer_strip_vbox;
2156         void cms_new (boost::shared_ptr<ARDOUR::Route>);
2157         void cms_deleted ();
2158         void current_mixer_strip_hidden ();
2159         void current_mixer_strip_removed ();
2160
2161         void detach_tearoff (Gtk::Box* b, Gtk::Window* w);
2162         void reattach_tearoff (Gtk::Box* b, Gtk::Window* w, int32_t n);
2163 #ifdef GTKOSX
2164         void ensure_all_elements_drawn ();
2165 #endif
2166         /* nudging tracks */
2167
2168         void nudge_track (bool use_edit_point, bool forwards);
2169
2170         /* xfades */
2171
2172         bool _xfade_visibility;
2173         
2174 #ifdef WITH_CMT
2175         void handle_new_imageframe_time_axis_view(const std::string & track_name, void* src) ;
2176         void handle_new_imageframe_marker_time_axis_view(const std::string & track_name, TimeAxisView* marked_track) ;
2177
2178         void start_imageframe_grab(ArdourCanvas::Item*, GdkEvent*) ;
2179         void start_markerview_grab(ArdourCanvas::Item*, GdkEvent*) ;
2180
2181         void imageframe_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
2182         void markerview_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
2183         void timeaxis_item_drag_finished_callback(ArdourCanvas::Item*, GdkEvent*) ;
2184
2185         gint canvas_imageframe_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
2186         gint canvas_imageframe_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameTimeAxis* ifta);
2187         gint canvas_imageframe_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
2188         gint canvas_imageframe_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
2189
2190         gint canvas_marker_time_axis_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerTimeAxis* mta);
2191         gint canvas_markerview_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
2192         gint canvas_markerview_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
2193         gint canvas_markerview_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
2194
2195         void imageframe_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2196         void imageframe_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2197         void imageframe_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2198         void imageframe_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2199         void imageframe_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2200         void imageframe_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2201         
2202         void markerview_item_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2203         void markerview_item_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2204         void markerview_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2205         void markerview_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2206         void markerview_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2207         void markerview_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2208
2209         void popup_imageframe_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
2210         void popup_marker_time_axis_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
2211
2212         ImageFrameSocketHandler* image_socket_listener ;
2213 #endif
2214
2215         void toggle_xfade_active (boost::weak_ptr<ARDOUR::Crossfade>);
2216         void toggle_xfade_length (boost::weak_ptr<ARDOUR::Crossfade>);
2217         void edit_xfade (boost::weak_ptr<ARDOUR::Crossfade>);
2218         void xfade_edit_left_region ();
2219         void xfade_edit_right_region ();
2220
2221         static const int32_t default_width = 995;
2222         static const int32_t default_height = 765;
2223
2224         /* nudge */
2225
2226         Gtk::Button      nudge_forward_button;
2227         Gtk::Button      nudge_backward_button;
2228         Gtk::HBox        nudge_hbox;
2229         Gtk::VBox        nudge_vbox;
2230         AudioClock       nudge_clock;
2231
2232         nframes64_t get_nudge_distance (nframes64_t pos, nframes64_t& next);
2233
2234         bool nudge_forward_release (GdkEventButton*);
2235         bool nudge_backward_release (GdkEventButton*);
2236         
2237         /* audio filters */
2238
2239         void apply_filter (ARDOUR::Filter&, std::string cmd);
2240
2241         /* handling cleanup */
2242
2243         int playlist_deletion_dialog (boost::shared_ptr<ARDOUR::Playlist>);
2244
2245         std::vector<sigc::connection> session_connections;
2246
2247         /* tracking step changes of track height */
2248
2249         TimeAxisView* current_stepping_trackview;
2250         ARDOUR::microseconds_t last_track_height_step_timestamp;
2251         gint track_height_step_timeout();
2252         sigc::connection step_timeout;
2253
2254         TimeAxisView* entered_track;
2255         RegionView*   entered_regionview;
2256
2257
2258         void ensure_entered_track_selected (bool op_acts_on_objects = false);
2259         bool clear_entered_track;
2260         bool left_track_canvas (GdkEventCrossing*);
2261         bool entered_track_canvas (GdkEventCrossing*);
2262         void set_entered_track (TimeAxisView*);
2263         void set_entered_regionview (RegionView*);
2264         void ensure_track_visible (TimeAxisView*);
2265         gint left_automation_track ();
2266
2267         bool _new_regionviews_show_envelope;
2268
2269         void reset_canvas_action_sensitivity (bool);
2270         void toggle_gain_envelope_visibility ();
2271         void toggle_gain_envelope_active ();
2272         void reset_region_gain_envelopes ();
2273
2274         bool on_key_press_event (GdkEventKey*);
2275         bool on_key_release_event (GdkEventKey*);
2276
2277         void session_state_saved (std::string);
2278
2279         Glib::RefPtr<Gtk::Action>              undo_action;
2280         Glib::RefPtr<Gtk::Action>              redo_action;
2281
2282         void history_changed ();
2283
2284         Gtk::HBox      status_bar_hpacker;
2285
2286         Editing::EditPoint _edit_point;
2287
2288         Gtk::ComboBoxText edit_point_selector;
2289
2290         void set_edit_point_preference (Editing::EditPoint ep, bool force = false);
2291         void cycle_edit_point (bool with_marker);
2292         void set_edit_point ();
2293         void edit_point_selection_done ();
2294         void edit_point_chosen (Editing::EditPoint);
2295         Glib::RefPtr<Gtk::RadioAction> edit_point_action (Editing::EditPoint);
2296         std::vector<std::string> edit_point_strings;
2297
2298         void selected_marker_moved (ARDOUR::Location*);
2299         sigc::connection edit_point_clock_connection_a;
2300         sigc::connection edit_point_clock_connection_b;
2301
2302         bool get_edit_op_range (nframes64_t& start, nframes64_t& end) const;
2303
2304         void get_regions_at (RegionSelection&, nframes64_t where, const TrackSelection& ts) const;
2305         void get_regions_after (RegionSelection&, nframes64_t where, const TrackSelection& ts) const;
2306         
2307         void get_regions_for_action (RegionSelection&, bool allowed_entered_regionview = false);
2308
2309         sigc::connection fast_screen_update_connection;
2310         gint start_updating ();
2311         gint stop_updating ();
2312         void fast_update_strips ();
2313         bool meters_running;
2314
2315         void select_next_route ();
2316         void select_prev_route ();
2317
2318         void snap_to_internal (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
2319
2320         RhythmFerret* rhythm_ferret;
2321         BundleManager* _bundle_manager;
2322         GlobalPortMatrixWindow* _global_port_matrix[ARDOUR::DataType::num_types];
2323
2324         void fit_tracks ();
2325         void set_track_height (uint32_t h);
2326
2327         void remove_tracks ();
2328         void toggle_tracks_active ();
2329         void waveform_scale_chosen (Editing::WaveformScale);
2330
2331         bool _have_idled;
2332         int resize_idle_id;
2333         int32_t resize_idle_target;
2334         bool idle_resize();
2335         friend gboolean _idle_resize (gpointer);
2336         std::vector<TimeAxisView*> pending_resizes;
2337
2338         void visible_order_range (int*, int*) const;
2339         bool y_movement_disallowed (int, int, int, int, int, std::bitset<512> const &, std::vector<int32_t> const &) const;
2340
2341         void located ();
2342         bool _pending_locate_request;
2343 };
2344
2345 #endif /* __ardour_editor_h__ */