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