io_selector.cc done, connection_editor in progress but skipped
[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     $Id$
19 */
20
21 #ifndef __ardour_editor_h__
22 #define __ardour_editor_h__
23
24 #include <list>
25 #include <map>
26 #include <set>
27 #include <string>
28 #include <sys/time.h>
29
30 #include <cmath>
31
32 #include <sndfile.h>
33
34 #include <gtkmm/layout.h>
35 #include <gtkmm/comboboxtext.h>
36
37 #include <libgnomecanvas/libgnomecanvas.h>
38 #include <libgnomecanvas/gnome-canvas-util.h>
39
40 #include <libgnomecanvasmm/canvas.h>
41 #include <libgnomecanvasmm/polygon.h>
42 #include <libgnomecanvasmm/text.h>
43 #include <libgnomecanvasmm/rect.h>
44 #include <libgnomecanvasmm/line.h>
45
46 #include <gtkmm2ext/selector.h>
47 #include <gtkmm2ext/click_box.h>
48
49 #include <ardour/stateful.h>
50 #include <ardour/session.h>
51 #include <ardour/tempo.h>
52 #include <ardour/location.h>
53 #include <ardour/region.h>
54
55 #include "keyboard_target.h"
56 #include "audio_clock.h"
57 #include "gtk-custom-ruler.h"
58 #include "ardour_dialog.h"
59 #include "public_editor.h"
60 #include "editing.h"
61 #include "enums.h"
62 #include "region_selection.h"
63 #include "simplerect.h"
64
65 namespace Gtkmm2ext {
66         class TearOff;
67 }
68
69 namespace LinuxAudioSystems {
70         class AudioEngine;
71 }
72
73 namespace ARDOUR {
74         class DiskStream;
75         class RouteGroup;
76         class Source;
77         class Playlist;
78         class Region;
79         class Location;
80         class TempoSection;
81         class NamedSelection;
82         class Session;
83         class AudioFilter;
84         class Crossfade;
85 }
86
87 namespace LADSPA {
88         class Plugin;
89 }
90
91 class TimeAxisView;
92 class AudioTimeAxisView;
93 class AutomationTimeAxisView;
94 class AudioRegionView;
95 class CrossfadeView;
96 class PluginSelector;
97 class PlaylistSelector;
98 class Marker;
99 class GroupedButtons;
100 class AutomationLine;
101 class UIExportSpecification;
102 class ExportDialog;
103 class Selection;
104 class TimeSelection;
105 class TrackSelection;
106 class AutomationSelection;
107 class MixerStrip;
108 class StreamView;
109 class ControlPoint;
110
111 /* <CMT Additions> */
112 class ImageFrameView;
113 class ImageFrameTimeAxisView;
114 class ImageFrameTimeAxis;
115 class MarkerTimeAxis ;
116 class MarkerView ;
117 class ImageFrameSocketHandler ;
118 class TimeAxisViewItem ;
119 /* </CMT Additions> */
120
121
122 class Editor : public PublicEditor
123 {
124   public:
125         Editor (ARDOUR::AudioEngine&);
126         ~Editor ();
127
128         void             connect_to_session (ARDOUR::Session *);
129         ARDOUR::Session* current_session() const { return session; }
130
131         jack_nframes_t leftmost_position() const { return leftmost_frame; }
132         jack_nframes_t current_page_frames() const {
133                 return (jack_nframes_t) floor (canvas_width * frames_per_unit);
134         }
135
136         void set_snap_to (Editing::SnapType);
137         void set_snap_mode (Editing::SnapMode);
138         void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;}
139
140         void undo (uint32_t n = 1);
141         void redo (uint32_t n = 1);
142
143         XMLNode& get_state ();
144         int set_state (const XMLNode& );
145
146         void set_mouse_mode (Editing::MouseMode, bool force=true);
147         void step_mouse_mode (bool next);
148         Editing::MouseMode current_mouse_mode () { return mouse_mode; }
149
150         void add_imageframe_time_axis(std::string track_name, void*) ;
151         void add_imageframe_marker_time_axis(std::string track_name, TimeAxisView* marked_track, void*) ;
152         void connect_to_image_compositor() ;
153         void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ;
154         TimeAxisView* get_named_time_axis(std::string name) ;
155         /* </CMT Additions> */
156
157         void consider_auditioning (ARDOUR::Region&);
158         void hide_a_region (ARDOUR::Region&);
159         void remove_a_region (ARDOUR::Region&);
160
161         /* option editor-access */
162
163         void set_show_waveforms (bool yn);
164         bool show_waveforms() const { return _show_waveforms; }
165
166         void set_show_waveforms_recording (bool yn);
167         bool show_waveforms_recording() const { return _show_waveforms_recording; }
168         
169         /* things that need to be public to be used in the main menubar */
170
171         void new_region_from_selection ();
172         void separate_region_from_selection ();
173         void toggle_playback (bool with_abort);
174
175         /* undo related */
176
177         void set_edit_menu (Gtk::Menu&);
178
179         jack_nframes_t unit_to_frame (double unit) {
180                 return (jack_nframes_t) rint (unit * frames_per_unit);
181         }
182         
183         double frame_to_unit (jack_nframes_t frame) {
184                 return rint ((double) frame / (double) frames_per_unit);
185         }
186
187         double frame_to_unit (double frame) {
188                 return rint (frame / frames_per_unit);
189         }
190
191         /* NOTE: these functions assume that the "pixel" coordinate is
192            the result of using the world->canvas affine transform on a
193            world coordinate. These coordinates already take into
194            account any scrolling carried out by adjusting the
195            xscroll_adjustment.  
196         */
197
198         jack_nframes_t pixel_to_frame (double pixel) {
199                 
200                 /* pixel can be less than zero when motion events
201                    are processed. since we've already run the world->canvas
202                    affine, that means that the location *really* is "off
203                    to the right" and thus really is "before the start".
204                 */
205
206                 if (pixel >= 0) {
207                         return (jack_nframes_t) rint (pixel * frames_per_unit * GNOME_CANVAS(track_canvas.gobj())->pixels_per_unit);
208                 } else {
209                         return 0;
210                 }
211         }
212
213         gulong frame_to_pixel (jack_nframes_t frame) {
214                 return (gulong) rint ((frame / (frames_per_unit *  GNOME_CANVAS(track_canvas.gobj())->pixels_per_unit)));
215         }
216
217         /* selection */
218
219         Selection& get_selection() const { return *selection; }
220         Selection& get_cut_buffer() const { return *cut_buffer; }
221
222         void play_selection ();
223         void select_all_in_track (bool add);
224         void select_all (bool add);
225         void invert_selection_in_track ();
226         void invert_selection ();
227
228         /* tempo */
229
230         void set_show_measures (bool yn);
231         bool show_measures () const { return _show_measures; }
232
233         /* export */
234
235         /* these initiate export ... */
236         
237         void export_session();
238         void export_selection();
239
240         /* this is what actually does it */
241         
242         void export_audiofile (ARDOUR::AudioExportSpecification&);
243
244         /* */
245
246         void add_toplevel_controls (Gtk::Container&);
247
248         void      set_zoom_focus (Editing::ZoomFocus);
249         Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
250         gdouble   get_current_zoom () { return frames_per_unit; }
251
252         void temporal_zoom_step (bool coarser);
253
254         /* stuff that AudioTimeAxisView and related classes use */
255
256         PlaylistSelector& playlist_selector() const;
257         void route_name_changed (TimeAxisView *);
258         gdouble        frames_per_unit;
259         jack_nframes_t leftmost_frame;
260         void clear_playlist (ARDOUR::Playlist&);
261
262         TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0);
263
264         Width editor_mixer_strip_width;
265         void show_editor_mixer (bool yn);
266         void set_selected_mixer_strip (TimeAxisView&);
267         void unselect_strip_in_display (TimeAxisView& tv);
268         void select_strip_in_display (TimeAxisView* tv);
269
270         /* nudge is initiated by transport controls owned by ARDOUR_UI */
271
272         void nudge_forward (bool next);
273         void nudge_backward (bool next);
274
275         /* nudge initiated from context menu */
276
277         void nudge_forward_capture_offset ();
278         void nudge_backward_capture_offset ();
279
280         /* playhead/screen stuff */
281         
282         void set_follow_playhead (bool yn);
283         void toggle_follow_playhead ();
284         bool follow_playhead() const { return _follow_playhead; }
285
286         /* xfades */
287
288         void toggle_xfades_active();
289         void toggle_xfade_visibility ();
290         void set_xfade_visibility (bool yn);
291         bool xfade_visibility() const { return _xfade_visibility; }
292
293         /* redirect shared ops menu. caller must free returned menu */
294
295         Gtk::Menu* redirect_menu ();
296
297         /* floating windows/transient */
298
299         void ensure_float (Gtk::Window&);
300
301         void show_window ();
302         
303         void scroll_tracks_down_line ();
304         void scroll_tracks_up_line ();
305
306         bool new_regionviews_display_gain () { return _new_regionviews_show_envelope; }
307         void prepare_for_cleanup ();
308
309         void reposition_x_origin (jack_nframes_t sample);
310
311   protected:
312         void map_transport_state ();
313         void map_position_change (jack_nframes_t);
314
315         void on_realize();
316         void on_map ();
317
318   private:
319         
320         ARDOUR::Session     *session;
321         ARDOUR::AudioEngine& engine;
322         bool                 constructed;
323
324         PlaylistSelector* _playlist_selector;
325
326         enum ItemType {
327                 RegionItem,
328                 StreamItem,
329                 PlayheadCursorItem,
330                 EditCursorItem,
331                 MarkerItem,
332                 MarkerBarItem,
333                 RangeMarkerBarItem,
334                 TransportMarkerBarItem,
335                 SelectionItem,
336                 GainControlPointItem,
337                 GainLineItem,
338                 GainAutomationControlPointItem,
339                 GainAutomationLineItem,
340                 PanAutomationControlPointItem,
341                 PanAutomationLineItem,
342                 RedirectAutomationControlPointItem,
343                 RedirectAutomationLineItem,
344                 MeterMarkerItem,
345                 TempoMarkerItem,
346                 MeterBarItem,
347                 TempoBarItem,
348                 AudioRegionViewNameHighlight,
349                 AudioRegionViewName,
350                 StartSelectionTrimItem,
351                 EndSelectionTrimItem,
352                 AutomationTrackItem,
353                 FadeInItem,
354                 FadeInHandleItem,
355                 FadeOutItem,
356                 FadeOutHandleItem,
357
358                 /* <CMT Additions> */
359                 MarkerViewItem,
360                 MarkerTimeAxisItem,
361                 MarkerViewHandleStartItem,
362                 MarkerViewHandleEndItem,
363                 ImageFrameItem,
364                 ImageFrameTimeAxisItem,
365                 ImageFrameHandleStartItem,
366                 ImageFrameHandleEndItem,
367                 /* </CMT Additions> */
368
369                 CrossfadeViewItem,
370                 
371                 /* don't remove this */
372
373                 NoItem
374         };
375
376         void          set_frames_per_unit (double);
377         void          frames_per_unit_modified ();
378
379         Editing::MouseMode mouse_mode;
380         void      mouse_insert (GdkEventButton *);
381
382         void pane_allocation_handler (GtkAllocation*, Gtk::Paned*);
383
384         Gtk::HPaned   canvas_region_list_pane;
385         Gtk::HPaned   track_list_canvas_pane;
386
387         Gtk::EventBox meter_base;
388         Gtk::HBox     meter_box;
389         Gtk::EventBox marker_base;
390         Gtk::HBox     marker_box;
391         Gtk::VBox     scrollers_rulers_markers_box;
392
393         void location_changed (ARDOUR::Location *);
394         void location_flags_changed (ARDOUR::Location *, void *);
395         void refresh_location_display ();
396         void refresh_location_display_s (ARDOUR::Change);
397         void refresh_location_display_internal (ARDOUR::Locations::LocationList&);
398         void add_new_location (ARDOUR::Location *);
399         void location_gone (ARDOUR::Location *);
400         void remove_marker (Gnome::Canvas::Polygon&, GdkEvent*);
401         gint really_remove_marker (ARDOUR::Location* loc);
402
403         uint32_t location_marker_color;
404         uint32_t location_range_color;
405         uint32_t location_loop_color;
406         uint32_t location_punch_color;
407         uint32_t location_cd_marker_color;
408
409         struct LocationMarkers {
410             Marker* start;
411             Marker* end;
412
413             ~LocationMarkers ();
414
415             void hide();
416             void show ();
417             void set_name (const string&);
418             void set_position (jack_nframes_t start, jack_nframes_t end = 0);
419             void set_color_rgba (uint32_t);
420         };
421
422         LocationMarkers  *find_location_markers (ARDOUR::Location *);
423         ARDOUR::Location* find_location_from_marker (Marker *, bool& is_start);
424
425         typedef std::map<ARDOUR::Location*,LocationMarkers *> LocationMarkerMap;
426         LocationMarkerMap location_markers;
427
428         void hide_marker (GnomeCanvasItem*, GdkEvent*);
429         void clear_marker_display ();
430         void mouse_add_new_marker (jack_nframes_t where);
431
432         TimeAxisView*      clicked_trackview;
433         AudioTimeAxisView* clicked_audio_trackview;
434         AudioRegionView*   clicked_regionview;
435         AudioRegionView*   latest_regionview;
436         uint32_t           clicked_selection;
437         CrossfadeView*     clicked_crossfadeview;
438         ControlPoint*      clicked_control_point;
439
440         void catch_vanishing_audio_regionview (AudioRegionView *);
441         void set_selected_control_point_from_click (bool add = false, bool with_undo = true, bool no_remove=false);
442         void set_selected_track_from_click (bool add = false, bool with_undo = true, bool no_remove=false);
443         void set_selected_regionview_from_click (bool add = false, bool no_track_remove=false);
444         void set_selected_regionview_from_region_list (ARDOUR::Region& region, bool add = false);
445         gint set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, ARDOUR::Region*);
446         void collect_new_region_view (AudioRegionView *);
447
448         Gtk::Menu track_context_menu;
449         Gtk::Menu track_region_context_menu;
450         Gtk::Menu track_selection_context_menu;
451         Gtk::Menu track_crossfade_context_menu;
452
453         Gtk::MenuItem* region_edit_menu_split_item;
454         Gtk::MenuItem* region_edit_menu_split_multichannel_item;
455         Gtk::Menu * track_region_edit_playlist_menu;
456         Gtk::Menu * track_edit_playlist_submenu;
457         Gtk::Menu * track_selection_edit_playlist_submenu;
458         
459         void popup_track_context_menu (int, int, ItemType, bool, jack_nframes_t);
460         Gtk::Menu* build_track_context_menu (jack_nframes_t);
461         Gtk::Menu* build_track_bus_context_menu (jack_nframes_t);
462         Gtk::Menu* build_track_region_context_menu (jack_nframes_t frame);
463         Gtk::Menu* build_track_crossfade_context_menu (jack_nframes_t);
464         Gtk::Menu* build_track_selection_context_menu (jack_nframes_t);
465         void add_dstream_context_items (Gtk::Menu_Helpers::MenuList&);
466         void add_bus_context_items (Gtk::Menu_Helpers::MenuList&);
467         void add_region_context_items (StreamView*, ARDOUR::Region*, Gtk::Menu_Helpers::MenuList&);
468         void add_crossfade_context_items (StreamView*, ARDOUR::Crossfade*, Gtk::Menu_Helpers::MenuList&, bool many);
469         void add_selection_context_items (Gtk::Menu_Helpers::MenuList&);
470
471         void handle_new_route (ARDOUR::Route&);
472         void handle_new_route_p (ARDOUR::Route*);
473         void remove_route (TimeAxisView *);
474         bool route_removal;
475
476         Gtk::HBox           global_hpacker;
477         Gtk::VBox           global_vpacker;
478         Gtk::VBox           vpacker;
479
480         Gdk::Cursor*          current_canvas_cursor;
481
482         Gnome::Canvas::CanvasAA track_canvas;
483         Gnome::Canvas::CanvasAA time_canvas;
484
485         Gnome::Canvas::Text* first_action_message;
486         Gnome::Canvas::Text* verbose_canvas_cursor;
487         bool                 verbose_cursor_visible;
488
489         void session_control_changed (ARDOUR::Session::ControlType);
490         void queue_session_control_changed (ARDOUR::Session::ControlType);
491
492         
493         gint track_canvas_motion (GdkEvent*);
494         void set_verbose_canvas_cursor (string, double x, double y);
495         void set_verbose_canvas_cursor_text (string);
496         void show_verbose_canvas_cursor();
497         void hide_verbose_canvas_cursor();
498
499         bool verbose_cursor_on; // so far unused
500
501         void flush_track_canvas ();
502         void flush_time_canvas ();
503
504         Gtk::EventBox      time_canvas_event_box;
505         Gtk::EventBox      track_canvas_event_box;
506         Gtk::EventBox      time_button_event_box;
507
508         Gnome::Canvas::Group      *minsec_group;
509         Gnome::Canvas::Group      *bbt_group;
510         Gnome::Canvas::Group      *smpte_group;
511         Gnome::Canvas::Group      *frame_group;
512         Gnome::Canvas::Group      *tempo_group;
513         Gnome::Canvas::Group      *meter_group;
514         Gnome::Canvas::Group      *marker_group;
515         Gnome::Canvas::Group      *range_marker_group;
516         Gnome::Canvas::Group      *transport_marker_group;
517         
518         enum {
519                 ruler_metric_smpte = 0,
520                 ruler_metric_bbt = 1,
521                 ruler_metric_frames = 2,
522                 ruler_metric_minsec = 3,
523
524                 ruler_time_tempo = 4,
525                 ruler_time_meter = 5,
526                 ruler_time_marker = 6,
527                 ruler_time_range_marker = 7,
528                 ruler_time_transport_marker = 8,
529         };
530
531         static GtkCustomMetric ruler_metrics[4];
532         bool                   ruler_shown[9];
533         bool                   no_ruler_shown_update;
534         
535         gint ruler_button_press (GdkEventButton*);
536         gint ruler_button_release (GdkEventButton*);
537         gint ruler_mouse_motion (GdkEventMotion*);
538
539         gint ruler_pressed_button;
540         Gtk::Widget * ruler_grabbed_widget;
541         
542         void initialize_rulers ();
543         void update_just_smpte ();
544         void update_fixed_rulers ();
545         void update_tempo_based_rulers (); 
546         void popup_ruler_menu (jack_nframes_t where = 0, ItemType type = RegionItem);
547         void update_ruler_visibility ();
548         void ruler_toggled (int);
549         gint ruler_label_button_release (GdkEventButton*);
550         void store_ruler_visibility ();
551         void restore_ruler_visibility ();
552         
553         static gint _metric_get_smpte (GtkCustomRulerMark **, gulong, gulong, gint);
554         static gint _metric_get_bbt (GtkCustomRulerMark **, gulong, gulong, gint);
555         static gint _metric_get_frames (GtkCustomRulerMark **, gulong, gulong, gint);
556         static gint _metric_get_minsec (GtkCustomRulerMark **, gulong, gulong, gint);
557         
558         gint metric_get_smpte (GtkCustomRulerMark **, gulong, gulong, gint);
559         gint metric_get_bbt (GtkCustomRulerMark **, gulong, gulong, gint);
560         gint metric_get_frames (GtkCustomRulerMark **, gulong, gulong, gint);
561         gint metric_get_minsec (GtkCustomRulerMark **, gulong, gulong, gint);
562
563         GtkWidget          *_smpte_ruler;
564         GtkWidget          *_bbt_ruler;
565         GtkWidget          *_frames_ruler;
566         GtkWidget          *_minsec_ruler;
567         Gtk::Widget        *smpte_ruler;
568         Gtk::Widget        *bbt_ruler;
569         Gtk::Widget        *frames_ruler;
570         Gtk::Widget        *minsec_ruler;
571         static Editor      *ruler_editor;
572
573         static const double timebar_height;
574         guint32 visible_timebars;
575         Gtk::Menu          *editor_ruler_menu;
576         
577         Gnome::Canvas::SimpleRect* tempo_bar;
578         Gnome::Canvas::SimpleRect* meter_bar;
579         Gnome::Canvas::SimpleRect* marker_bar;
580         Gnome::Canvas::SimpleRect* range_marker_bar;
581         Gnome::Canvas::SimpleRect* transport_marker_bar;
582
583         
584         Gnome::Canvas::Line* tempo_line;
585         Gnome::Canvas::Line* meter_line;
586         Gnome::Canvas::Line* marker_line;
587         Gnome::Canvas::Line* range_marker_line;
588         Gnome::Canvas::Line* transport_marker_line;
589
590         Gnome::Canvas::Points* tempo_line_points;
591         Gnome::Canvas::Points* meter_line_points;
592         Gnome::Canvas::Points* marker_line_points;
593         Gnome::Canvas::Points* range_marker_line_points;
594         Gnome::Canvas::Points* transport_marker_line_points;
595
596         Gtk::Label  minsec_label;
597         Gtk::Label  bbt_label;
598         Gtk::Label  smpte_label;
599         Gtk::Label  frame_label;
600         Gtk::Label  tempo_label;
601         Gtk::Label  meter_label;
602         Gtk::Label  mark_label;
603         Gtk::Label  range_mark_label;
604         Gtk::Label  transport_mark_label;
605         
606
607         Gtk::VBox          time_button_vbox;
608         Gtk::HBox          time_button_hbox;
609
610         struct Cursor {
611             Editor&             editor;
612             Gnome::Canvas::Points* points;
613             Gnome::Canvas::Item*   canvas_item;
614             jack_nframes_t      current_frame;
615             GtkSignalFunc       callback;
616                 double                          length;
617
618             Cursor (Editor&, const string& color, GtkSignalFunc callback);
619             ~Cursor ();
620
621             void set_position (jack_nframes_t);
622             void set_length (double units);
623                 void set_y_axis (double position);
624         };
625
626         friend struct Cursor; /* it needs access to several private
627                                  fields. XXX fix me.
628                               */
629
630         Cursor* playhead_cursor;
631         Cursor* edit_cursor;
632         Gnome::Canvas::Group* cursor_group;
633
634         void    cursor_to_next_region_point (Cursor*, ARDOUR::RegionPoint);
635         void    cursor_to_previous_region_point (Cursor*, ARDOUR::RegionPoint);
636         void    cursor_to_region_point (Cursor*, ARDOUR::RegionPoint, int32_t dir);
637         void    cursor_to_selection_start (Cursor *);
638         void    cursor_to_selection_end   (Cursor *);
639
640         ARDOUR::Region* find_next_region (jack_nframes_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
641
642         vector<jack_nframes_t> region_boundary_cache;
643         void build_region_boundary_cache ();
644
645         Gtk::VBox           trackview_vpacker;
646
647         Gtk::HBox           top_hbox;
648         Gtk::HBox           bottom_hbox;
649         
650         Gtk::Table          edit_packer;
651         Gtk::Frame          edit_frame;
652         Gtk::VScrollbar     edit_vscrollbar;
653
654         /* the horizontal scroller works in a rather different way
655            than a regular scrollbar, since its used for
656            zoom control/indication as well. But more importantly,
657            its different components (slider, left arrow, right arrow) 
658            have to be packed separately into the edit_packer.
659         */
660
661         Gtk::HScrollbar     edit_hscrollbar;
662         Gtk::DrawingArea    edit_hscroll_slider;
663         Gtk::Arrow          edit_hscroll_left_arrow;
664         Gtk::Arrow          edit_hscroll_right_arrow;
665         Gtk::EventBox       edit_hscroll_left_arrow_event;
666         Gtk::EventBox       edit_hscroll_right_arrow_event;
667         gint                edit_hscroll_slider_width;
668         gint                edit_hscroll_slider_height;
669         static const gint   edit_hscroll_edge_width = 3;
670         bool                edit_hscroll_dragging;
671         double              edit_hscroll_drag_last;
672         
673         void hscroll_slider_allocate (GtkAllocation *);
674         gint hscroll_slider_expose (GdkEventExpose*);
675         gint hscroll_slider_button_press (GdkEventButton*);
676         gint hscroll_slider_button_release (GdkEventButton*);
677         gint hscroll_slider_motion (GdkEventMotion*);
678
679         gint hscroll_trough_expose (GdkEventExpose*);
680         gint hscroll_trough_button_press (GdkEventButton*);
681         gint hscroll_trough_button_release (GdkEventButton*);
682
683         void update_hscroller ();
684
685         gint hscroll_left_arrow_button_press (GdkEventButton *);
686         gint hscroll_left_arrow_button_release (GdkEventButton *);
687         gint hscroll_right_arrow_button_press (GdkEventButton *);
688         gint hscroll_right_arrow_button_release (GdkEventButton *);
689         
690         guint32             canvas_width;
691         guint32             canvas_height;
692
693         Gtk::ScrolledWindow  track_canvas_scroller;
694         Gtk::ScrolledWindow  time_canvas_scroller;
695         Gtk::ScrolledWindow  edit_controls_scroller;
696
697         gint edit_controls_button_release (GdkEventButton*);
698         Gtk::Menu *edit_controls_left_menu;
699         Gtk::Menu *edit_controls_right_menu;
700
701         void track_canvas_scroller_realized ();
702         void time_canvas_scroller_realized ();
703
704         Gtk::VBox           track_canvas_vbox;
705         Gtk::VBox           time_canvas_vbox;
706         Gtk::VBox           edit_controls_vbox;
707         Gtk::HBox           edit_controls_hbox;
708
709         void tie_vertical_scrolling ();
710         void canvas_horizontally_scrolled ();
711         void reposition_and_zoom (jack_nframes_t sample, double fpu);
712         gint deferred_reposition_and_zoom (jack_nframes_t sample, double fpu);
713         void end_location_changed (ARDOUR::Location*);
714         bool repos_zoom_queued;
715         bool no_zoom_repos_update;
716         bool no_tempo_map_update;
717
718         struct RegionListDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
719             RegionListDisplayModelColumns() {
720                     add (name);
721                     add (region);
722             }
723             Gtk::TreeModelColumn<Glib::ustring> name;
724             Gtk::TreeModelColumn<ARDOUR::Region*> region;
725         };
726             
727         RegionListDisplayModelColumns    region_list_columns;
728         Gtk::TreeView                    region_list_display;
729         Glib::RefPtr<Gtk::TreeStore>     region_list_model;
730         Glib::RefPtr<Gtk::TreeModelSort> region_list_sort_model;
731         Glib::RefPtr<Gtk::Action>        toggle_full_region_list_action;
732
733         void region_list_selection_changed ();
734
735         Gtk::Menu          *region_list_menu;
736         Gtk::ScrolledWindow region_list_scroller;
737         Gtk::Frame          region_list_frame;
738
739         bool region_list_display_key_press (GdkEventKey *);
740         bool region_list_display_key_release (GdkEventKey *);
741         bool region_list_display_button_press (GdkEventButton *);
742         bool region_list_display_button_release (GdkEventButton *);
743         bool region_list_display_enter_notify (GdkEventCrossing *);
744         bool region_list_display_leave_notify (GdkEventCrossing *);
745         void region_list_clear ();
746         void region_list_selection_mapover (sigc::slot<void,ARDOUR::Region&>);
747         void build_region_list_menu ();
748
749         Gtk::CheckMenuItem* toggle_auto_regions_item;
750         Gtk::CheckMenuItem* toggle_full_region_list_item;
751
752         Gtk::MenuItem* import_audio_item;
753         Gtk::MenuItem* embed_audio_item;
754
755         bool show_automatic_regions_in_region_list;
756         Editing::RegionListSortType region_list_sort_type;
757
758         void reset_region_list_sort_direction (bool);
759         void reset_region_list_sort_type (Editing::RegionListSortType);
760
761         void toggle_full_region_list ();
762         void toggle_show_auto_regions ();
763
764         int region_list_sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
765
766         /* named selections */
767
768         struct NamedSelectionDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
769             NamedSelectionDisplayModelColumns() { 
770                     add (text);
771                     add (selection);
772             }
773             Gtk::TreeModelColumn<Glib::ustring>  text;
774             Gtk::TreeModelColumn<ARDOUR::NamedSelection*>    selection;
775         };
776
777         NamedSelectionDisplayModelColumns named_selection_columns;
778         Glib::RefPtr<Gtk::TreeStore>     named_selection_model;
779
780         Gtk::VPaned         region_selection_vpane;
781         Gtk::TreeView          named_selection_display;
782         Gtk::ScrolledWindow named_selection_scroller;
783
784         void name_selection();
785         void named_selection_name_chosen ();
786         void create_named_selection (string);
787         void paste_named_selection (float times);
788
789         void handle_new_named_selection ();
790         void add_named_selection_to_named_selection_display (ARDOUR::NamedSelection&);
791         void redisplay_named_selections ();
792
793         gint named_selection_display_button_press (GdkEventButton *ev);
794         void named_selection_display_selection_changed ();
795
796         /* track views */
797         int track_spacing;
798         TrackViewList  track_views;
799         TimeAxisView     *trackview_by_y_position (double ypos);
800
801         static Gdk::Cursor* cross_hair_cursor;
802         static Gdk::Cursor* trimmer_cursor;
803         static Gdk::Cursor* selector_cursor;
804         static Gdk::Cursor* grabber_cursor;
805         static Gdk::Cursor* zoom_cursor;
806         static Gdk::Cursor* time_fx_cursor;
807         static Gdk::Cursor* fader_cursor;
808         static Gdk::Cursor* speaker_cursor;
809         static Gdk::Cursor* null_cursor;
810         static Gdk::Cursor* wait_cursor;
811         static Gdk::Cursor* timebar_cursor;
812
813         static void build_cursors ();
814
815         sigc::connection scroll_connection;
816         jack_nframes_t last_update_frame;
817         void center_screen (jack_nframes_t);
818         void center_screen_internal (jack_nframes_t, float);
819         
820         void update_current_screen ();
821         sigc::connection slower_update_connection;
822         void update_slower ();
823         
824         gint show_track_context_menu (GdkEventButton *);
825         void hide_track_context_menu ();
826
827         void session_going_away ();
828
829         jack_nframes_t cut_buffer_start;
830         jack_nframes_t cut_buffer_length;
831
832         gint typed_event (GnomeCanvasItem*, GdkEvent*, ItemType);
833         gint button_press_handler (GnomeCanvasItem*, GdkEvent*, ItemType);
834         gint button_release_handler (GnomeCanvasItem*, GdkEvent*, ItemType);
835         gint motion_handler (GnomeCanvasItem*, GdkEvent*, ItemType);
836         gint enter_handler (GnomeCanvasItem*, GdkEvent*, ItemType);
837         gint leave_handler (GnomeCanvasItem*, GdkEvent*, ItemType);
838         
839         /* KEYMAP HANDLING */
840
841         void register_actions ();
842         void install_keybindings ();
843
844         int ensure_cursor (jack_nframes_t* pos);
845
846         void fake_handle_new_audio_region (ARDOUR::AudioRegion *);
847         void handle_new_audio_region (ARDOUR::AudioRegion *);
848         void fake_handle_audio_region_removed (ARDOUR::AudioRegion *);
849         void handle_audio_region_removed (ARDOUR::AudioRegion *);
850         void add_audio_region_to_region_display (ARDOUR::AudioRegion *);
851         void region_hidden (ARDOUR::Region*);
852         void redisplay_regions ();
853         void insert_into_tmp_audio_regionlist(ARDOUR::AudioRegion *);
854
855         list<ARDOUR::AudioRegion *> tmp_audio_region_list;
856
857         void cut_copy (Editing::CutCopyOp);
858         void cut_copy_points (Editing::CutCopyOp);
859         void cut_copy_regions (Editing::CutCopyOp);
860         void cut_copy_ranges (Editing::CutCopyOp);
861
862         void mouse_paste ();
863         void paste_internal (jack_nframes_t position, float times);
864
865         /* EDITING OPERATIONS */
866         
867         void toggle_region_mute ();
868         void toggle_region_opaque ();
869         void raise_region ();
870         void raise_region_to_top ();
871         void lower_region ();
872         void lower_region_to_bottom ();
873         void split_region ();
874         void split_region_at (jack_nframes_t);
875         void split_regions_at (jack_nframes_t, AudioRegionSelection&);
876         void crop_region_to_selection ();
877         void set_region_sync_from_edit_cursor ();
878         void remove_region_sync();
879         void align_selection (ARDOUR::RegionPoint, jack_nframes_t position);
880         void align_selection_relative (ARDOUR::RegionPoint point, jack_nframes_t position);
881         void align_region (ARDOUR::Region&, ARDOUR::RegionPoint point, jack_nframes_t position);
882         void align_region_internal (ARDOUR::Region&, ARDOUR::RegionPoint point, jack_nframes_t position);
883         void remove_some_regions ();
884         void remove_clicked_region ();
885         void destroy_clicked_region ();
886         void edit_region ();
887         void duplicate_some_regions (AudioRegionSelection&, float times);
888         void duplicate_selection (float times);
889         void region_fill_selection ();
890
891         void region_fill_track ();
892         void audition_playlist_region_standalone (ARDOUR::AudioRegion&);
893         void audition_playlist_region_via_route (ARDOUR::AudioRegion&, ARDOUR::Route&);
894         void split_multichannel_region();
895         void reverse_region ();
896         void normalize_region ();
897         void denormalize_region ();
898
899         void audition_region_from_region_list ();
900         void hide_region_from_region_list ();
901         void remove_region_from_region_list ();
902
903         void align (ARDOUR::RegionPoint);
904         void align_relative (ARDOUR::RegionPoint);
905         void naturalize ();
906
907         void cut ();
908         void copy ();
909         void paste (float times);
910
911         int  get_prefix (float&, bool&);
912
913         void keyboard_paste ();
914         void keyboard_duplicate_region ();
915         void keyboard_duplicate_selection ();
916         void keyboard_nudge ();
917         void keyboard_insert_region_list_selection ();
918
919         void region_from_selection ();
920         void create_region_from_selection (std::vector<ARDOUR::AudioRegion*>&);
921
922         bool region_renamed;
923         void rename_region ();
924         void rename_region_finished (bool);
925
926         void play_from_start ();
927         void play_from_edit_cursor ();
928         void play_selected_region ();
929         void audition_selected_region ();
930         void toggle_loop_playback ();
931         void loop_selected_region ();
932         void play_location (ARDOUR::Location&);
933         void loop_location (ARDOUR::Location&);
934
935         Editing::ZoomFocus zoom_focus;
936
937         void temporal_zoom_selection ();
938         void temporal_zoom_session ();
939         void temporal_zoom (gdouble scale);
940         void temporal_zoom_by_frame (jack_nframes_t start, jack_nframes_t end, string op);
941         void temporal_zoom_to_frame (bool coarser, jack_nframes_t frame);
942
943         void amplitude_zoom (gdouble scale);
944         void amplitude_zoom_step (bool in);
945
946         void insert_region_list_drag (ARDOUR::AudioRegion&);
947         void insert_region_list_selection (float times);
948
949         void insert_sndfile (bool as_tracks);
950         void embed_audio ();    // inserts into region list
951         int  reject_because_rate_differs (string path, SF_INFO& finfo, string action, bool multiple_pending);
952
953         void do_embed_sndfiles (vector<string> paths, bool split);
954         void embed_sndfile (string path, bool split, bool multiple_files, bool& check_sr);
955
956         void do_insert_sndfile (vector<string> path, bool multi, jack_nframes_t frame);
957         void insert_paths_as_new_tracks (std::vector<std::string> paths, bool multi); // inserts files as new tracks
958         void insert_sndfile_into (string path, bool multi, AudioTimeAxisView* tv, jack_nframes_t& frame, bool prompt=true);
959         static void* _insert_sndfile_thread (void*);
960         void*  insert_sndfile_thread (void*);
961
962         /* generic interthread progress window */
963         
964         ArdourDialog* interthread_progress_window;
965         Gtk::Label interthread_progress_label;
966         Gtk::VBox interthread_progress_vbox;
967         Gtk::ProgressBar interthread_progress_bar;
968         Gtk::Button interthread_cancel_button;
969         Gtk::Label interthread_cancel_label;
970         sigc::connection  interthread_progress_connection;
971         void interthread_cancel_clicked ();
972         void build_interthread_progress_window ();
973         ARDOUR::InterThreadInfo* current_interthread_info;
974
975         /* import specific info */
976
977         ARDOUR::Session::import_status import_status;
978         gint import_progress_timeout (void *);
979         static void *_import_thread (void *);
980         void* import_thread ();
981         void catch_new_audio_region (ARDOUR::AudioRegion*);
982         ARDOUR::AudioRegion* last_audio_region;
983
984         /* to support this ... */
985
986         void import_audio (bool as_tracks);
987         void do_import (vector<string> paths, bool split, bool as_tracks);
988
989         void move_to_start ();
990         void move_to_end ();
991         void goto_frame ();
992         void center_playhead ();
993         void center_edit_cursor ();
994         void edit_cursor_backward ();
995         void edit_cursor_forward ();
996         void playhead_backward ();
997         void playhead_forward ();
998         void scroll_backward (float pages=0.8f);
999         void scroll_forward (float pages=0.8f);
1000         void scroll_tracks_down ();
1001         void scroll_tracks_up ();
1002         void delete_sample_forward ();
1003         void delete_sample_backward ();
1004         void delete_screen ();
1005         void search_backwards ();
1006         void search_forwards ();
1007         void set_mark ();
1008         void clear_markers ();
1009         void clear_ranges ();
1010         void clear_locations ();
1011         void jump_forward_to_mark ();
1012         void jump_backward_to_mark ();
1013         void cursor_align (bool playhead_to_edit);
1014
1015         void remove_last_capture ();
1016
1017         void set_selection_from_range (ARDOUR::Location&);
1018         void set_selection_from_punch ();
1019         void set_selection_from_loop ();
1020
1021         void add_location_from_selection ();
1022         void set_route_loop_selection ();
1023
1024         void add_location_from_playhead_cursor ();
1025
1026         void reverse_selection ();
1027         void edit_envelope ();
1028
1029         void start_scrolling ();
1030         void stop_scrolling ();
1031
1032         void keyboard_selection_begin ();
1033         void keyboard_selection_finish (bool add);
1034         bool have_pending_keyboard_selection;
1035         jack_nframes_t pending_keyboard_selection_start;
1036
1037         ARDOUR::AudioRegion* select_region_for_operation (int dir, TimeAxisView **tv);
1038         void extend_selection_to_end_of_region (bool next);
1039         void extend_selection_to_start_of_region (bool previous);
1040
1041         Editing::SnapType snap_type;
1042         Editing::SnapMode snap_mode;
1043         double snap_threshold;
1044
1045         void soundfile_chosen_for_insert (string selection, bool split_channels);
1046         void soundfile_chosen_for_embed (string selection, bool split_channels);
1047         void soundfile_chosen_for_import (string selection, bool split_channels);
1048
1049         void handle_gui_changes (string, void *);
1050
1051         void    hide_all_tracks (bool with_select);
1052
1053         void route_display_selection_changed ();
1054         void redisplay_route_list();
1055         gint route_list_reordered ();
1056         bool ignore_route_list_reorder;
1057         void queue_route_list_reordered ();
1058
1059         struct DragInfo {
1060             GnomeCanvasItem* item;
1061             void* data;
1062             jack_nframes_t last_frame_position;
1063             int32_t pointer_frame_offset;
1064             jack_nframes_t grab_frame;
1065             jack_nframes_t last_pointer_frame;
1066             jack_nframes_t current_pointer_frame;
1067             double grab_x, grab_y;
1068             double cumulative_x_drag;
1069             double cumulative_y_drag;
1070             double current_pointer_x;
1071             double current_pointer_y;
1072             void (Editor::*motion_callback)(GnomeCanvasItem*, GdkEvent*);
1073             void (Editor::*finished_callback)(GnomeCanvasItem*, GdkEvent*);
1074             TimeAxisView* last_trackview;
1075             bool x_constrained;
1076             bool copy;
1077             bool was_rolling;
1078             bool first_move;
1079             bool move_threshold_passsed;
1080             bool want_move_threshold;
1081             bool brushing;
1082             ARDOUR::Location* copied_location;
1083         } drag_info;
1084
1085         struct LineDragInfo {
1086             uint32_t before;
1087             uint32_t after;
1088         };
1089
1090         LineDragInfo current_line_drag_info;
1091
1092         void start_grab (GdkEvent*, Gdk::Cursor* cursor = 0);
1093         bool end_grab (GnomeCanvasItem*, GdkEvent*);
1094
1095         Gtk::Menu fade_context_menu;
1096         void popup_fade_context_menu (int, int, GnomeCanvasItem*, ItemType);
1097
1098         void start_fade_in_grab (GnomeCanvasItem*, GdkEvent*);
1099         void start_fade_out_grab (GnomeCanvasItem*, GdkEvent*);
1100         void fade_in_drag_motion_callback (GnomeCanvasItem*, GdkEvent*);
1101         void fade_out_drag_motion_callback (GnomeCanvasItem*, GdkEvent*);
1102         void fade_in_drag_finished_callback (GnomeCanvasItem*, GdkEvent*);
1103         void fade_out_drag_finished_callback (GnomeCanvasItem*, GdkEvent*);
1104         
1105         std::set<ARDOUR::Playlist*> motion_frozen_playlists;
1106         void region_drag_motion_callback (GnomeCanvasItem*, GdkEvent*);
1107         void region_drag_finished_callback (GnomeCanvasItem*, GdkEvent*);
1108         void region_copy_drag_finished_callback (GnomeCanvasItem*, GdkEvent*);
1109
1110         void cursor_drag_motion_callback (GnomeCanvasItem*, GdkEvent*);
1111         void cursor_drag_finished_callback (GnomeCanvasItem*, GdkEvent*);
1112         void marker_drag_motion_callback (GnomeCanvasItem*, GdkEvent*);
1113         void marker_drag_finished_callback (GnomeCanvasItem*, GdkEvent*);
1114         void control_point_drag_motion_callback (GnomeCanvasItem*, GdkEvent*);
1115         void control_point_drag_finished_callback (GnomeCanvasItem*, GdkEvent*);
1116         void line_drag_motion_callback (GnomeCanvasItem*, GdkEvent*);
1117         void line_drag_finished_callback (GnomeCanvasItem*, GdkEvent*);
1118
1119         void tempo_marker_drag_motion_callback (GnomeCanvasItem*, GdkEvent*);
1120         void tempo_marker_drag_finished_callback (GnomeCanvasItem*, GdkEvent*);
1121         void meter_marker_drag_motion_callback (GnomeCanvasItem*, GdkEvent*);
1122         void meter_marker_drag_finished_callback (GnomeCanvasItem*, GdkEvent*);
1123
1124         gint mouse_rename_region (GnomeCanvasItem*, GdkEvent*);
1125
1126         void start_region_grab (GnomeCanvasItem*, GdkEvent*);
1127         void start_region_copy_grab (GnomeCanvasItem*, GdkEvent*);
1128         void start_region_brush_grab (GnomeCanvasItem*, GdkEvent*);
1129         void start_selection_grab (GnomeCanvasItem*, GdkEvent*);
1130         void start_cursor_grab (GnomeCanvasItem*, GdkEvent*);
1131         void start_marker_grab (GnomeCanvasItem*, GdkEvent*);
1132         void start_control_point_grab (GnomeCanvasItem*, GdkEvent*);
1133         void start_line_grab_from_regionview (GnomeCanvasItem*, GdkEvent*);
1134         void start_line_grab_from_line (GnomeCanvasItem*, GdkEvent*);
1135         void start_line_grab (AutomationLine *, GdkEvent*);
1136         void start_tempo_marker_grab (GnomeCanvasItem*, GdkEvent*);
1137         void start_meter_marker_grab (GnomeCanvasItem*, GdkEvent*);
1138
1139         void region_view_item_click (AudioRegionView&, GdkEventButton*);
1140
1141         void remove_gain_control_point (GnomeCanvasItem*, GdkEvent*);
1142         void remove_control_point (GnomeCanvasItem*, GdkEvent*);
1143
1144         void mouse_brush_insert_region (AudioRegionView*, jack_nframes_t pos);
1145         void brush (jack_nframes_t);
1146
1147         void show_verbose_time_cursor (jack_nframes_t frame, double offset = 0, double xpos=-1, double ypos=-1);
1148         void show_verbose_duration_cursor (jack_nframes_t start, jack_nframes_t end, double offset = 0, double xpos=-1, double ypos=-1);
1149
1150         /* Canvas event handlers */
1151
1152         gint canvas_crossfade_view_event (GdkEvent* event);
1153         gint canvas_fade_in_event (GdkEvent* event);
1154         gint canvas_fade_in_handle_event (GdkEvent* event);
1155         gint canvas_fade_out_event (GdkEvent* event);
1156         gint canvas_fade_out_handle_event (GdkEvent* event);
1157         gint canvas_region_view_event (GdkEvent* event);
1158         gint canvas_region_view_name_highlight_event (GdkEvent* event);
1159         gint canvas_region_view_name_event (GdkEvent* event);
1160         gint canvas_stream_view_event (GdkEvent* event);
1161         gint canvas_marker_event (GdkEvent* event);
1162         gint canvas_zoom_rect_event (GdkEvent* event);
1163         gint canvas_selection_rect_event (GdkEvent* event);
1164         gint canvas_selection_start_trim_event (GdkEvent* event);
1165         gint canvas_selection_end_trim_event (GdkEvent* event);
1166         gint canvas_control_point_event (GdkEvent* event);
1167         gint canvas_line_event (GdkEvent* event);
1168         gint canvas_tempo_marker_event (GdkEvent* event);
1169         gint canvas_meter_marker_event (GdkEvent* event);
1170         gint canvas_tempo_bar_event (GdkEvent* event);
1171         gint canvas_meter_bar_event (GdkEvent* event);
1172         gint canvas_marker_bar_event (GdkEvent* event);
1173         gint canvas_range_marker_bar_event (GdkEvent* event);
1174         gint canvas_transport_marker_bar_event (GdkEvent* event);
1175         gint canvas_imageframe_item_view_event(GdkEvent* event) ;
1176         gint canvas_imageframe_view_event(GdkEvent* event) ;
1177         gint canvas_imageframe_start_handle_event(GdkEvent* event) ;
1178         gint canvas_imageframe_end_handle_event(GdkEvent* event) ;
1179         gint canvas_marker_time_axis_view_event(GdkEvent* event) ;
1180         gint canvas_markerview_item_view_event(GdkEvent* event) ;
1181         gint canvas_markerview_start_handle_event(GdkEvent* event) ;
1182         gint canvas_markerview_end_handle_event(GdkEvent* event) ;
1183         gint canvas_automation_track_event(GdkEvent* event) ;
1184
1185 #if 0
1186         gint canvas_crossfade_view_event (GnomeCanvasItem* item, GdkEvent* event, CrossfadeView*);
1187         gint canvas_fade_in_event (GnomeCanvasItem* item, GdkEvent* event, AudioRegionView*);
1188         gint canvas_fade_in_handle_event (GnomeCanvasItem* item, GdkEvent* event, AudioRegionView*);
1189         gint canvas_fade_out_event (GnomeCanvasItem* item, GdkEvent* event, AudioRegionView*);
1190         gint canvas_fade_out_handle_event (GnomeCanvasItem* item, GdkEvent* event, AudioRegionView*);
1191         gint canvas_region_view_event (GnomeCanvasItem* item, GdkEvent* event, AudioRegionView*);
1192         gint canvas_stream_view_event (GnomeCanvasItem* item, GdkEvent* event, AudioTimeAxisView*);
1193         gint canvas_automation_track_event (GnomeCanvasItem* item, GdkEvent* event, AutomationTimeAxisView*);
1194         gint canvas_marker_event (GnomeCanvasItem* item, GdkEvent* event);
1195         gint canvas_zoom_rect_event (GnomeCanvasItem* item, GdkEvent* event);
1196         gint canvas_selection_rect_event (GnomeCanvasItem* item, GdkEvent* event);
1197         gint canvas_selection_start_trim_event (GnomeCanvasItem* item, GdkEvent* event);
1198         gint canvas_selection_end_trim_event (GnomeCanvasItem* item, GdkEvent* event);
1199         gint canvas_control_point_event (GnomeCanvasItem* item, GdkEvent* event);
1200         gint canvas_line_event (GnomeCanvasItem* item, GdkEvent* event);
1201         gint canvas_tempo_marker_event (GnomeCanvasItem* item, GdkEvent* event);
1202         gint canvas_meter_marker_event (GnomeCanvasItem* item, GdkEvent* event);
1203         gint canvas_tempo_bar_event (GnomeCanvasItem* item, GdkEvent* event);
1204         gint canvas_meter_bar_event (GnomeCanvasItem* item, GdkEvent* event);
1205         gint canvas_marker_bar_event (GnomeCanvasItem* item, GdkEvent* event);
1206         gint canvas_range_marker_bar_event (GnomeCanvasItem* item, GdkEvent* event);
1207         gint canvas_transport_marker_bar_event (GnomeCanvasItem* item, GdkEvent* event);
1208         gint canvas_region_view_name_highlight_event (GnomeCanvasItem* item, GdkEvent* event);
1209         gint canvas_region_view_name_event (GnomeCanvasItem* item, GdkEvent* event);
1210 #endif  
1211
1212         gint canvas_copy_region_event (GdkEvent* event);
1213         gint canvas_playhead_cursor_event (GdkEvent* event);
1214         gint canvas_edit_cursor_event (GdkEvent* event);
1215         gint track_canvas_event (GdkEvent* event);
1216
1217         gint track_canvas_button_press_event (GdkEventButton *);
1218         gint track_canvas_button_release_event (GdkEventButton *);
1219         
1220         void track_canvas_allocate (GtkAllocation* alloc);
1221         void time_canvas_allocate (GtkAllocation* alloc);
1222
1223         void set_edit_cursor (GdkEvent* event);
1224         void set_playhead_cursor (GdkEvent* event);
1225
1226         void kbd_driver (sigc::slot<void,GdkEvent*>, bool use_track_canvas = true, bool use_time_canvas = true, bool can_select = true);
1227         void kbd_set_playhead_cursor ();
1228         void kbd_set_edit_cursor ();
1229         void kbd_split ();
1230         void kbd_align (ARDOUR::RegionPoint);
1231         void kbd_align_relative (ARDOUR::RegionPoint);
1232         void kbd_brush ();
1233         void kbd_audition ();
1234
1235         void kbd_do_split (GdkEvent*);
1236         void kbd_do_align (GdkEvent*, ARDOUR::RegionPoint);
1237         void kbd_do_align_relative (GdkEvent*, ARDOUR::RegionPoint);
1238         void kbd_do_brush (GdkEvent*);
1239         void kbd_do_audition (GdkEvent*);
1240
1241         void fake_handle_new_duration ();
1242         void handle_new_duration ();
1243         void initialize_canvas ();
1244         void reset_scrolling_region (GtkAllocation* alloc = 0);
1245         void scroll_canvas ();
1246
1247         /* sub-event loop handling */
1248
1249         int32_t sub_event_loop_status;
1250         void run_sub_event_loop ();
1251         void finish_sub_event_loop (int status);
1252         gint finish_sub_event_loop_on_delete (GdkEventAny*, int32_t status);
1253         
1254         /* display control */
1255         
1256         bool _show_measures;
1257         bool _show_waveforms;
1258         bool _follow_playhead;
1259         bool _show_waveforms_recording;
1260         
1261         void add_bbt_marks (ARDOUR::TempoMap::BBTPointList&);
1262
1263         ARDOUR::TempoMap::BBTPointList *current_bbt_points;
1264         
1265         typedef vector<GnomeCanvasItem*> TimeLineList;
1266         TimeLineList free_measure_lines;
1267         TimeLineList used_measure_lines;
1268
1269         Gnome::Canvas::Group* time_line_group;
1270         GnomeCanvasItem* get_time_line ();
1271         void hide_measures ();
1272         void draw_measures ();
1273         void draw_time_bars ();
1274
1275         void new_tempo_section ();
1276
1277         void mouse_add_new_tempo_event (jack_nframes_t where);
1278         void mouse_add_new_meter_event (jack_nframes_t where);
1279
1280         void remove_tempo_marker (GnomeCanvasItem*);
1281         void remove_meter_marker (GnomeCanvasItem*);
1282         gint real_remove_tempo_marker (ARDOUR::TempoSection*);
1283         gint real_remove_meter_marker (ARDOUR::MeterSection*);
1284         
1285         void edit_tempo_section (ARDOUR::TempoSection*);
1286         void edit_meter_section (ARDOUR::MeterSection*);
1287         void edit_tempo_marker (GnomeCanvasItem*);
1288         void edit_meter_marker (GnomeCanvasItem*);
1289         
1290         void marker_menu_edit ();
1291         void marker_menu_remove ();
1292         void marker_menu_rename ();
1293         void marker_menu_hide ();
1294         void marker_menu_loop_range ();
1295         void marker_menu_play_from ();
1296         void marker_menu_set_playhead ();
1297         void marker_menu_set_from_playhead ();
1298         void marker_menu_set_from_selection ();
1299         void new_transport_marker_menu_set_loop ();
1300         void new_transport_marker_menu_set_punch ();
1301         void update_loop_range_view (bool visibility=false);
1302         void update_punch_range_view (bool visibility=false);
1303         gint new_transport_marker_menu_popdown (GdkEventAny*);
1304         void marker_context_menu (GdkEventButton*, GnomeCanvasItem*);
1305         void tm_marker_context_menu (GdkEventButton*, GnomeCanvasItem*);
1306         void transport_marker_context_menu (GdkEventButton*, GnomeCanvasItem*);
1307         void new_transport_marker_context_menu (GdkEventButton*, GnomeCanvasItem*);
1308         void build_marker_menu ();
1309         void build_tm_marker_menu ();
1310         void build_transport_marker_menu ();
1311         void build_new_transport_marker_menu ();
1312
1313         Gtk::Menu* tm_marker_menu;
1314         Gtk::Menu* marker_menu;
1315         Gtk::Menu* transport_marker_menu;
1316         Gtk::Menu* new_transport_marker_menu;
1317         GnomeCanvasItem* marker_menu_item;
1318
1319         typedef list<Marker*> Marks;
1320         Marks metric_marks;
1321
1322         void remove_metric_marks ();
1323         void draw_metric_marks (const ARDOUR::Metrics& metrics);
1324
1325         void tempo_map_changed (ARDOUR::Change);
1326         void redisplay_tempo ();
1327         
1328         void snap_to (jack_nframes_t& first, int32_t direction = 0, bool for_mark = false);
1329         uint32_t bbt_beat_subdivision;
1330
1331         /* toolbar */
1332         
1333         Gtk::ToggleButton        editor_mixer_button;
1334
1335         void editor_mixer_button_toggled ();
1336
1337         AudioClock               selection_start_clock;
1338         Gtk::Label               selection_start_clock_label;
1339         AudioClock               selection_end_clock;
1340         Gtk::Label               selection_end_clock_label;
1341         AudioClock               edit_cursor_clock;
1342         Gtk::Label               edit_cursor_clock_label;
1343         AudioClock               zoom_range_clock;
1344         Gtk::Button              zoom_in_button;
1345         Gtk::Button              zoom_out_button;
1346         Gtk::Button              zoom_out_full_button;
1347         Gtk::Button              zoom_onetoone_button;
1348
1349         Gtk::VBox                toolbar_clock_vbox;
1350         Gtk::VBox                toolbar_selection_clock_vbox; 
1351         Gtk::Table               toolbar_selection_clock_table;
1352         Gtk::Label               toolbar_selection_cursor_label;
1353         
1354         Gtk::Table               mouse_mode_button_table;
1355         Gtkmm2ext::TearOff*       mouse_mode_tearoff;
1356         Gtk::ToggleButton        mouse_select_button;
1357         Gtk::ToggleButton        mouse_move_button;
1358         Gtk::ToggleButton        mouse_gain_button;
1359         Gtk::ToggleButton        mouse_zoom_button;
1360         Gtk::ToggleButton        mouse_timefx_button;
1361         Gtk::ToggleButton        mouse_audition_button;
1362         GroupedButtons          *mouse_mode_button_set;
1363         void                     mouse_mode_toggled (Editing::MouseMode m);
1364         bool                     ignore_mouse_mode_toggle;
1365
1366         gint                     mouse_select_button_release (GdkEventButton*);
1367
1368         Gtk::VBox                automation_box;
1369         Gtk::Button              automation_mode_button;
1370         Gtk::ToggleButton        global_automation_button;
1371
1372         Gtk::ComboBoxText edit_mode_selector;
1373         Gtk::Label               edit_mode_label;
1374         Gtk::VBox                edit_mode_box;
1375
1376         gint edit_mode_selection_done (GdkEventAny*);
1377
1378         Gtk::ComboBoxText snap_type_selector;
1379         Gtk::Label               snap_type_label;
1380         Gtk::VBox                snap_type_box;
1381
1382         gint snap_type_selection_done (GdkEventAny*);
1383
1384         Gtk::ComboBoxText               snap_mode_selector;
1385         Gtk::Label               snap_mode_label;
1386         Gtk::VBox                snap_mode_box;
1387
1388         gint snap_mode_selection_done (GdkEventAny*);
1389
1390         Gtk::ComboBoxText zoom_focus_selector;
1391         Gtk::Label               zoom_focus_label;
1392         Gtk::VBox                zoom_focus_box;
1393         
1394         gint zoom_focus_selection_done (GdkEventAny*);
1395
1396         Gtk::Label          zoom_indicator_label;
1397         Gtk::HBox           zoom_indicator_box;
1398         Gtk::VBox           zoom_indicator_vbox;
1399
1400         void                update_zoom_indicator ();
1401         void                zoom_adjustment_changed();
1402
1403         void                edit_cursor_clock_changed();
1404         
1405         void setup_toolbar ();
1406
1407         Gtkmm2ext::TearOff*       tools_tearoff;
1408         Gtk::HBox                toolbar_hbox;
1409         Gtk::EventBox            toolbar_base;
1410         Gtk::Frame               toolbar_frame;
1411
1412         /* selection process */
1413
1414         Selection* selection;
1415         Selection* cut_buffer;
1416
1417         void time_selection_changed ();
1418         void track_selection_changed ();
1419         void region_selection_changed ();
1420         void point_selection_changed ();
1421         void audio_track_selection_changed ();
1422         void line_selection_changed ();
1423
1424         enum SelectionOp {
1425                 CreateSelection,
1426                 SelectionStartTrim,
1427                 SelectionEndTrim,
1428                 SelectionMove
1429         } selection_op;
1430
1431         void start_selection_op (GnomeCanvasItem* item, GdkEvent* event, SelectionOp);
1432         void drag_selection (GnomeCanvasItem* item, GdkEvent* event);
1433         void end_selection_op (GnomeCanvasItem* item, GdkEvent* event);
1434         void cancel_selection ();
1435
1436         void region_selection_op (void (ARDOUR::Region::*pmf)(void));
1437         void region_selection_op (void (ARDOUR::Region::*pmf)(void*), void*);
1438         void region_selection_op (void (ARDOUR::Region::*pmf)(bool), bool);
1439
1440         bool audio_region_selection_covers (jack_nframes_t where);
1441
1442         Gtk::VPaned  route_group_vpane;
1443         Gtk::Frame   route_list_frame;
1444         Gtk::Frame   edit_group_list_frame;
1445
1446         /* transport range select process */
1447         enum RangeMarkerOp {
1448                 CreateRangeMarker,
1449                 CreateTransportMarker
1450         } range_marker_op;
1451
1452         void start_range_markerbar_op (GnomeCanvasItem* item, GdkEvent* event, RangeMarkerOp);
1453         void drag_range_markerbar_op (GnomeCanvasItem* item, GdkEvent* event);
1454         void end_range_markerbar_op (GnomeCanvasItem* item, GdkEvent* event);
1455
1456         
1457         Gnome::Canvas::Item      *range_bar_drag_rect;
1458         Gnome::Canvas::Item      *transport_bar_drag_rect;
1459         Gnome::Canvas::Item      *marker_drag_line;
1460         Gnome::Canvas::Points    *marker_drag_line_points;
1461         Gnome::Canvas::Item      *range_marker_drag_rect;
1462
1463         void update_marker_drag_item (ARDOUR::Location *);
1464         
1465         GnomeCanvasItem      *transport_bar_range_rect;
1466         GnomeCanvasItem      *transport_bar_preroll_rect;
1467         GnomeCanvasItem      *transport_bar_postroll_rect;
1468         Gnome::Canvas::Item      *transport_loop_range_rect;
1469         Gnome::Canvas::Item      *transport_punch_range_rect;
1470         Gnome::Canvas::Item      *transport_punchin_line;
1471         Gnome::Canvas::Item      *transport_punchout_line;
1472         GnomeCanvasItem      *transport_preroll_rect;
1473         GnomeCanvasItem      *transport_postroll_rect;
1474
1475         ARDOUR::Location*  transport_loop_location();
1476         ARDOUR::Location*  transport_punch_location();
1477
1478         ARDOUR::Location   *temp_location;
1479         
1480         /* object rubberband select process */
1481         
1482         void start_rubberband_select (GnomeCanvasItem* item, GdkEvent* event);
1483         void drag_rubberband_select (GnomeCanvasItem* item, GdkEvent* event);
1484         void end_rubberband_select (GnomeCanvasItem* item, GdkEvent* event);
1485
1486         bool select_all_within (jack_nframes_t start, jack_nframes_t end, gdouble topy, gdouble boty, bool add);
1487         
1488         Gnome::Canvas::Item   *rubberband_rect;
1489         
1490         /* mouse zoom process */
1491
1492         void start_mouse_zoom (GnomeCanvasItem* item, GdkEvent* event);
1493         void drag_mouse_zoom (GnomeCanvasItem* item, GdkEvent* event);
1494         void end_mouse_zoom (GnomeCanvasItem* item, GdkEvent* event);
1495
1496         Gnome::Canvas::Item   *zoom_rect;
1497         void reposition_zoom_rect (jack_nframes_t start, jack_nframes_t end);
1498         
1499         /* diskstream/route display management */
1500
1501         struct RouteDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
1502             RouteDisplayModelColumns() { 
1503                     add (text);
1504                     add (tv);
1505             }
1506             Gtk::TreeModelColumn<Glib::ustring>  text;
1507             Gtk::TreeModelColumn<TimeAxisView*>    tv;
1508         };
1509
1510         RouteDisplayModelColumns    route_display_columns;
1511         Glib::RefPtr<Gtk::ListStore> route_display_model;
1512         Glib::RefPtr<Gtk::TreeSelection> route_display_selection;
1513
1514         gint route_list_compare_func (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
1515         Gtk::TreeView          route_list; //GTK2FIX rename to route_display
1516         Gtk::ScrolledWindow route_list_scroller;
1517         Gtk::Menu          *route_list_menu;
1518
1519         void route_list_column_click ();
1520         void build_route_list_menu ();
1521         void select_all_routes ();
1522         void unselect_all_routes ();
1523         void select_all_audiotracks ();
1524         void unselect_all_audiotracks ();
1525         void select_all_audiobus ();
1526         void unselect_all_audiobus ();
1527
1528         /* edit group management */
1529
1530         struct GroupListModelColumns : public Gtk::TreeModel::ColumnRecord {
1531                 GroupListModelColumns () {
1532                        add (is_active);
1533                        add (text);
1534                        add (routegroup);
1535                 }
1536                 Gtk::TreeModelColumn<bool> is_active;
1537                 Gtk::TreeModelColumn<std::string> text;
1538                 Gtk::TreeModelColumn<ARDOUR::RouteGroup*>   routegroup;
1539         };
1540
1541         GroupListModelColumns group_columns;
1542         Glib::RefPtr<Gtk::ListStore> group_model;
1543         Glib::RefPtr<Gtk::TreeSelection> group_selection;
1544
1545         Gtk::Button         edit_group_list_button;
1546         Gtk::Label          edit_group_list_button_label;
1547         Gtk::TreeView       edit_group_list;
1548         Gtk::ScrolledWindow edit_group_list_scroller;
1549         Gtk::Menu          *edit_group_list_menu;
1550         Gtk::VBox           edit_group_vbox;
1551
1552         void edit_group_list_column_click (gint);
1553         void build_edit_group_list_menu ();
1554         void select_all_edit_groups ();
1555         void unselect_all_edit_groups ();
1556         void new_edit_group ();
1557         void edit_group_list_button_clicked ();
1558         gint edit_group_list_button_press_event (GdkEventButton* ev);
1559         void edit_group_selection_changed ();
1560         void fake_add_edit_group (ARDOUR::RouteGroup* group);
1561         void add_edit_group (ARDOUR::RouteGroup* group);
1562         void group_flags_changed (void*, ARDOUR::RouteGroup*);
1563
1564         Gtk::VBox           list_vpacker;
1565
1566         static GdkPixmap* check_pixmap;
1567         static GdkBitmap* check_mask;
1568         static GdkPixmap* empty_pixmap;
1569         static GdkBitmap* empty_mask;
1570
1571         /* autoscrolling */
1572
1573         int autoscroll_timeout_tag;
1574         int autoscroll_direction;
1575         uint32_t autoscroll_cnt;
1576         jack_nframes_t autoscroll_distance;
1577      
1578         static gint _autoscroll_canvas (void *);
1579         gint autoscroll_canvas ();
1580         void start_canvas_autoscroll (int direction);
1581         void stop_canvas_autoscroll ();
1582         void maybe_autoscroll (GdkEvent*);
1583
1584         /* trimming */
1585         enum TrimOp {
1586                 StartTrim,
1587                 EndTrim,
1588                 ContentsTrim,
1589         } trim_op;
1590
1591         void start_trim (GnomeCanvasItem*, GdkEvent*);
1592         void point_trim (GdkEvent*);
1593         void trim_motion_callback (GnomeCanvasItem*, GdkEvent*);
1594         void single_contents_trim (AudioRegionView&, jack_nframes_t, bool, bool, bool);
1595         void single_start_trim (AudioRegionView&, jack_nframes_t, bool, bool);
1596         void single_end_trim (AudioRegionView&, jack_nframes_t, bool, bool);
1597
1598         void trim_finished_callback (GnomeCanvasItem*, GdkEvent*);
1599         void thaw_region_after_trim (AudioRegionView& rv);
1600         
1601         void trim_region_to_edit_cursor ();
1602         void trim_region_from_edit_cursor ();
1603
1604         bool show_gain_after_trim;
1605
1606         /* Drag-n-Drop */
1607
1608         int convert_drop_to_paths (std::vector<std::string>& paths,
1609                                    GdkDragContext     *context,
1610                                    gint                x,
1611                                    gint                y,
1612                                    GtkSelectionData   *data,
1613                                    guint               info,
1614                                    guint               time);
1615
1616         void  track_canvas_drag_data_received  (GdkDragContext     *context,
1617                                                 gint                x,
1618                                                 gint                y,
1619                                                 GtkSelectionData   *data,
1620                                                 guint               info,
1621                                                 guint               time);
1622
1623         void  region_list_display_drag_data_received  (GdkDragContext     *context,
1624                                                        gint                x,
1625                                                        gint                y,
1626                                                        GtkSelectionData   *data,
1627                                                        guint               info,
1628                                                        guint               time);
1629         
1630         /* audio export */
1631
1632         ExportDialog *export_dialog;
1633         void export_range (jack_nframes_t start, jack_nframes_t end);
1634
1635         int write_region_selection(AudioRegionSelection&);
1636         bool write_region (string path, ARDOUR::AudioRegion&);
1637         void export_region ();
1638         void write_a_region ();
1639         void bounce_region_selection ();
1640         void bounce_range_selection ();
1641         void external_edit_region ();
1642
1643         int write_audio_selection (TimeSelection&);
1644         bool write_audio_range (ARDOUR::Playlist&, uint32_t channels, list<ARDOUR::AudioRange>&);
1645
1646         void write_selection ();
1647
1648         /* history */
1649
1650         UndoAction get_memento() const;
1651
1652         void begin_reversible_command (string cmd_name);
1653         void commit_reversible_command ();
1654
1655         /* visual history */
1656
1657         UndoHistory visual_history;
1658         UndoCommand current_visual_command;
1659
1660         void begin_reversible_visual_command (string cmd_name);
1661         void commit_reversible_visual_command ();
1662
1663         void update_title ();   
1664         void update_title_s (string snapshot_name);
1665
1666         struct State {
1667             Selection* selection;
1668             double     frames_per_unit;
1669
1670             State();
1671             ~State();
1672         };
1673
1674         void store_state (State&) const;
1675         void restore_state (State *);
1676
1677         void instant_save ();
1678
1679         ARDOUR::AudioRegion* last_audition_region;
1680         
1681         /* freeze operations */
1682
1683         ARDOUR::InterThreadInfo freeze_status;
1684         gint freeze_progress_timeout (void *);
1685         static void* _freeze_thread (void*);
1686         void* freeze_thread ();
1687
1688         void freeze_route ();
1689         void unfreeze_route ();
1690
1691         /* edit-group solo + mute */
1692
1693         void set_edit_group_solo (ARDOUR::Route&, bool);
1694         void set_edit_group_mute (ARDOUR::Route&, bool);
1695
1696         /* duplication */
1697
1698         void duplicate_dialog (bool for_region);
1699         
1700         /* edit menu */
1701
1702         Gtk::Menu* edit_menu;
1703         void edit_menu_map_handler ();
1704
1705         jack_nframes_t event_frame (GdkEvent*, double* px = 0, double* py = 0);
1706
1707         void time_fx_motion (GnomeCanvasItem*, GdkEvent*);
1708         void start_time_fx (GnomeCanvasItem*, GdkEvent*);
1709         void end_time_fx (GnomeCanvasItem*, GdkEvent*);
1710
1711         struct TimeStretchDialog : public ArdourDialog {
1712             ARDOUR::Session::TimeStretchRequest request;
1713             Editor&               editor;
1714             AudioRegionSelection  regions;
1715             Gtk::ProgressBar      progress_bar;
1716             Gtk::ToggleButton     quick_button;
1717             Gtk::ToggleButton     antialias_button;
1718             Gtk::Button           cancel_button;
1719             Gtk::Button           action_button;
1720             Gtk::HBox             lower_button_box;
1721             Gtk::HBox             upper_button_box;
1722             Gtk::VBox             packer;
1723             int                   status;
1724
1725             TimeStretchDialog (Editor& e);
1726
1727             gint update_progress ();
1728             sigc::connection first_cancel;
1729             sigc::connection first_delete;
1730             void cancel_timestretch_in_progress ();
1731             gint delete_timestretch_in_progress (GdkEventAny*);
1732         };
1733
1734         /* "whats mine is yours" */
1735
1736         friend class TimeStretchDialog;
1737
1738         TimeStretchDialog* current_timestretch;
1739
1740         static void* timestretch_thread (void *arg);
1741         int run_timestretch (AudioRegionSelection&, float fraction);
1742         void do_timestretch (TimeStretchDialog&);
1743
1744         /* editor-mixer strip */
1745
1746         MixerStrip *current_mixer_strip;
1747         Gtk::VBox current_mixer_strip_vbox;
1748         void cms_deleted ();
1749         void current_mixer_strip_hidden ();
1750         void current_mixer_strip_removed ();
1751
1752         void detach_tearoff (Gtk::Box* b, Gtk::Widget* w);
1753         void reattach_tearoff (Gtk::Box* b, Gtk::Widget* w, int32_t n);
1754
1755         /* nudging tracks */
1756
1757         void nudge_track (bool use_edit_cursor, bool forwards);
1758
1759         /* xfades */
1760
1761         bool _xfade_visibility;
1762         
1763         /* <CMT Additions> */
1764         void handle_new_imageframe_time_axis_view(std::string track_name, void* src) ;
1765         void handle_new_imageframe_marker_time_axis_view(std::string track_name, TimeAxisView* marked_track) ;
1766
1767         void start_imageframe_grab(GnomeCanvasItem*, GdkEvent*) ;
1768         void start_markerview_grab(GnomeCanvasItem*, GdkEvent*) ;
1769
1770         void imageframe_drag_motion_callback(GnomeCanvasItem*, GdkEvent*) ;
1771         void markerview_drag_motion_callback(GnomeCanvasItem*, GdkEvent*) ;
1772         void timeaxis_item_drag_finished_callback(GnomeCanvasItem*, GdkEvent*) ;
1773
1774         gint canvas_imageframe_item_view_event(GnomeCanvasItem* item, GdkEvent* event, ImageFrameView* ifv);
1775         gint canvas_imageframe_view_event(GnomeCanvasItem* item, GdkEvent* event, ImageFrameTimeAxis* ifta);
1776         gint canvas_imageframe_start_handle_event(GnomeCanvasItem* item, GdkEvent* event, ImageFrameView* ifv);
1777         gint canvas_imageframe_end_handle_event(GnomeCanvasItem* item, GdkEvent* event, ImageFrameView* ifv);
1778
1779         gint canvas_marker_time_axis_view_event(GnomeCanvasItem* item, GdkEvent* event, MarkerTimeAxis* mta);
1780         gint canvas_markerview_item_view_event(GnomeCanvasItem* item, GdkEvent* event, MarkerView* mv);
1781         gint canvas_markerview_start_handle_event(GnomeCanvasItem* item, GdkEvent* event, MarkerView* mv);
1782         gint canvas_markerview_end_handle_event(GnomeCanvasItem* item, GdkEvent* event, MarkerView* mv);
1783
1784         void imageframe_start_handle_op(GnomeCanvasItem* item, GdkEvent* event) ;
1785         void imageframe_end_handle_op(GnomeCanvasItem* item, GdkEvent* event) ;
1786         void imageframe_start_handle_trim_motion(GnomeCanvasItem* item, GdkEvent* event) ;
1787         void imageframe_start_handle_end_trim(GnomeCanvasItem* item, GdkEvent* event) ;
1788         void imageframe_end_handle_trim_motion(GnomeCanvasItem* item, GdkEvent* event) ;
1789         void imageframe_end_handle_end_trim(GnomeCanvasItem* item, GdkEvent* event) ;
1790         
1791         void markerview_item_start_handle_op(GnomeCanvasItem* item, GdkEvent* event) ;
1792         void markerview_item_end_handle_op(GnomeCanvasItem* item, GdkEvent* event) ;
1793         void markerview_start_handle_trim_motion(GnomeCanvasItem* item, GdkEvent* event) ;
1794         void markerview_start_handle_end_trim(GnomeCanvasItem* item, GdkEvent* event) ;
1795         void markerview_end_handle_trim_motion(GnomeCanvasItem* item, GdkEvent* event) ;
1796         void markerview_end_handle_end_trim(GnomeCanvasItem* item, GdkEvent* event) ;
1797
1798         void popup_imageframe_edit_menu(int button, int32_t time, GnomeCanvasItem* ifv, bool with_frame) ;
1799         void popup_marker_time_axis_edit_menu(int button, int32_t time, GnomeCanvasItem* ifv, bool with_frame) ;
1800
1801         ImageFrameSocketHandler* image_socket_listener ;
1802         /* </CMT Additions> */
1803
1804         void toggle_xfade_active (ARDOUR::Crossfade*);
1805         void toggle_xfade_length (ARDOUR::Crossfade*);
1806         void edit_xfade (ARDOUR::Crossfade*);
1807         void remove_xfade ();
1808         void xfade_edit_left_region ();
1809         void xfade_edit_right_region ();
1810
1811         static const int32_t default_width = 995;
1812         static const int32_t default_height = 765;
1813
1814         /* nudge */
1815
1816         Gtk::Button      nudge_forward_button;
1817         Gtk::Button      nudge_backward_button;
1818         Gtk::HBox        nudge_hbox;
1819         Gtk::VBox        nudge_vbox;
1820         Gtk::Label       nudge_label;
1821         AudioClock       nudge_clock;
1822
1823         jack_nframes_t get_nudge_distance (jack_nframes_t pos, jack_nframes_t& next);
1824         
1825         /* audio filters */
1826
1827         void apply_filter (ARDOUR::AudioFilter&, string cmd);
1828
1829         /* handling cleanup */
1830
1831         int playlist_deletion_dialog (ARDOUR::Playlist*);
1832
1833         vector<sigc::connection> session_connections;
1834
1835         /* tracking step changes of track height */
1836
1837         TimeAxisView* current_stepping_trackview;
1838         struct timeval last_track_height_step_timestamp;
1839         gint track_height_step_timeout();
1840         sigc::connection step_timeout;
1841
1842         TimeAxisView* entered_track;
1843         AudioRegionView* entered_regionview;
1844         bool clear_entered_track;
1845         gint left_track_canvas (GdkEventCrossing*);
1846         void set_entered_track (TimeAxisView*);
1847         void set_entered_regionview (AudioRegionView*);
1848         gint left_automation_track ();
1849
1850         bool _new_regionviews_show_envelope;
1851
1852         void toggle_gain_envelope_visibility ();
1853         void toggle_gain_envelope_active ();
1854         
1855         typedef std::map<Editing::ColorID,std::string> ColorStyleMap;
1856         void init_colormap ();
1857
1858         /* GTK2 stuff */
1859
1860         Glib::RefPtr<Gtk::UIManager> ui_manager;
1861 };
1862
1863 #endif /* __ardour_editor_h__ */