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