fix keyboard event handling for host-provided plugin GUIs
[ardour2.git] / gtk2_ardour / editor.h
blob992ac591a6c184fee5043a39c06364eee578b81a
1 /*
2 Copyright (C) 2000-2003 Paul Davis
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.
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.
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.
20 #ifndef __ardour_editor_h__
21 #define __ardour_editor_h__
23 #include <list>
24 #include <map>
25 #include <set>
26 #include <string>
27 #include <sys/time.h>
28 #include <glibmm/ustring.h>
30 #include <boost/optional.hpp>
32 #include <libgnomecanvasmm/canvas.h>
33 #include <libgnomecanvasmm/group.h>
34 #include <libgnomecanvasmm/line.h>
35 #include <libgnomecanvasmm/pixbuf.h>
37 #include <cmath>
39 #include <gtkmm/layout.h>
40 #include <gtkmm/comboboxtext.h>
42 #include <gtkmm2ext/selector.h>
43 #include <gtkmm2ext/click_box.h>
44 #include <gtkmm2ext/dndtreeview.h>
46 #include <pbd/stateful.h>
47 #include <ardour/session.h>
48 #include <ardour/tempo.h>
49 #include <ardour/stretch.h>
50 #include <ardour/location.h>
51 #include <ardour/audioregion.h>
53 #include "audio_clock.h"
54 #include "gtk-custom-ruler.h"
55 #include "ardour_dialog.h"
56 #include "public_editor.h"
57 #include "editing.h"
58 #include "enums.h"
59 #include "editor_items.h"
60 #include "canvas-noevent-text.h"
61 #include "region_selection.h"
62 #include "canvas.h"
63 #include "time_axis_view.h"
64 #include "draginfo.h"
66 namespace Gtkmm2ext {
67 class TearOff;
70 namespace ARDOUR {
71 class AudioDiskstream;
72 class RouteGroup;
73 class Playlist;
74 class AudioPlaylist;
75 class Region;
76 class Location;
77 class TempoSection;
78 class NamedSelection;
79 class Session;
80 class AudioFilter;
81 class Crossfade;
84 namespace LADSPA {
85 class Plugin;
88 class TimeAxisView;
89 class RouteTimeAxisView;
90 class AudioTimeAxisView;
91 class AutomationTimeAxisView;
92 class AudioRegionView;
93 class CrossfadeView;
94 class PluginSelector;
95 class PlaylistSelector;
96 class Marker;
97 class GroupedButtons;
98 class AutomationLine;
99 class UIExportSpecification;
100 class ExportDialog;
101 class Selection;
102 class TempoLines;
103 class TimeSelection;
104 class TrackSelection;
105 class AutomationSelection;
106 class MixerStrip;
107 class StreamView;
108 class AudioStreamView;
109 class ControlPoint;
110 class SoundFileOmega;
111 class RhythmFerret;
112 class RegionLayeringOrderEditor;
113 #ifdef FFT_ANALYSIS
114 class AnalysisWindow;
115 #endif
117 /* <CMT Additions> */
118 class ImageFrameView;
119 class ImageFrameTimeAxisView;
120 class ImageFrameTimeAxis;
121 class MarkerTimeAxis ;
122 class MarkerView ;
123 class ImageFrameSocketHandler ;
124 class TimeAxisViewItem ;
125 /* </CMT Additions> */
128 class Editor : public PublicEditor
130 public:
131 Editor ();
132 ~Editor ();
134 void connect_to_session (ARDOUR::Session *);
135 ARDOUR::Session* current_session() const { return session; }
136 void first_idle ();
137 virtual bool have_idled() const { return _have_idled; }
139 nframes64_t leftmost_position() const { return leftmost_frame; }
140 nframes64_t current_page_frames() const {
141 return (nframes64_t) floor (canvas_width * frames_per_unit);
144 void cycle_snap_mode ();
145 void cycle_snap_choice ();
146 void set_snap_to (Editing::SnapType);
147 void set_snap_mode (Editing::SnapMode);
148 void set_snap_threshold (double pixel_distance) {snap_threshold = pixel_distance;}
150 void undo (uint32_t n = 1);
151 void redo (uint32_t n = 1);
153 XMLNode& get_state ();
154 int set_state (const XMLNode& );
156 void set_mouse_mode (Editing::MouseMode, bool force=true);
157 void step_mouse_mode (bool next);
158 Editing::MouseMode current_mouse_mode () { return mouse_mode; }
160 void add_imageframe_time_axis(const std::string & track_name, void*) ;
161 void add_imageframe_marker_time_axis(const std::string & track_name, TimeAxisView* marked_track, void*) ;
162 void connect_to_image_compositor() ;
163 void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ;
164 TimeAxisView* get_named_time_axis(const std::string & name) ;
165 void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>);
166 void add_to_idle_resize (TimeAxisView*, uint32_t);
168 void consider_auditioning (boost::shared_ptr<ARDOUR::Region>);
169 void hide_a_region (boost::shared_ptr<ARDOUR::Region>);
170 void remove_a_region (boost::shared_ptr<ARDOUR::Region>);
172 #ifdef USE_RUBBERBAND
173 std::vector<std::string> rb_opt_strings;
174 #endif
176 //global waveform options
178 void set_show_waveforms (bool yn);
179 bool show_waveforms() const { return _show_waveforms; }
181 void set_show_waveforms_rectified (bool yn);
182 bool show_waveforms_rectified() const { return _show_waveforms_rectified; }
184 void set_show_waveforms_recording (bool yn);
185 bool show_waveforms_recording() const { return _show_waveforms_recording; }
187 //per-track waveform options
189 void set_waveform_scale (Editing::WaveformScale);
191 /* things that need to be public to be used in the main menubar */
193 void new_region_from_selection ();
194 void separate_regions_between (const TimeSelection&);
195 void separate_region_from_selection ();
196 void separate_region_from_punch ();
197 void separate_region_from_loop ();
198 void separate_regions_using_location (ARDOUR::Location&);
199 void transition_to_rolling (bool forward);
201 /* undo related */
203 nframes64_t unit_to_frame (double unit) const {
204 return (nframes64_t) rint (unit * frames_per_unit);
207 double frame_to_unit (nframes64_t frame) const {
208 return rint ((double) frame / (double) frames_per_unit);
211 double frame_to_unit (double frame) const {
212 return rint (frame / frames_per_unit);
215 /* NOTE: these functions assume that the "pixel" coordinate is
216 the result of using the world->canvas affine transform on a
217 world coordinate. These coordinates already take into
218 account any scrolling carried out by adjusting the
219 xscroll_adjustment.
222 nframes64_t pixel_to_frame (double pixel) const {
224 /* pixel can be less than zero when motion events
225 are processed. since we've already run the world->canvas
226 affine, that means that the location *really* is "off
227 to the right" and thus really is "before the start".
230 if (pixel >= 0) {
231 return (nframes64_t) rint (pixel * frames_per_unit * GNOME_CANVAS(track_canvas->gobj())->pixels_per_unit);
232 } else {
233 return 0;
237 gulong frame_to_pixel (nframes64_t frame) const {
238 return (gulong) rint ((frame / (frames_per_unit * GNOME_CANVAS(track_canvas->gobj())->pixels_per_unit)));
241 void flush_canvas ();
243 /* selection */
245 Selection& get_selection() const { return *selection; }
246 Selection& get_cut_buffer() const { return *cut_buffer; }
248 bool extend_selection_to_track (TimeAxisView&);
250 void play_selection ();
251 void select_all_in_track (Selection::Operation op);
252 void select_all (Selection::Operation op);
253 void invert_selection_in_track ();
254 void invert_selection ();
255 void deselect_all ();
257 /* tempo */
259 void set_show_measures (bool yn);
260 bool show_measures () const { return _show_measures; }
262 #ifdef FFT_ANALYSIS
263 /* analysis window */
264 void analyze_region_selection();
265 void analyze_range_selection();
266 #endif
268 /* export */
270 /* these initiate export ... */
272 void export_session();
273 void export_selection();
275 void add_toplevel_controls (Gtk::Container&);
276 Gtk::HBox& get_status_bar_packer() { return status_bar_hpacker; }
278 void set_zoom_focus (Editing::ZoomFocus);
279 Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
280 double get_current_zoom () const { return frames_per_unit; }
282 void temporal_zoom_step (bool coarser);
284 /* stuff that AudioTimeAxisView and related classes use */
286 PlaylistSelector& playlist_selector() const;
287 void route_name_changed (TimeAxisView *);
288 void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>);
290 void new_playlists (TimeAxisView*);
291 void copy_playlists (TimeAxisView*);
292 void clear_playlists (TimeAxisView*);
294 TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0);
295 void get_onscreen_tracks (TrackViewList&);
297 Width editor_mixer_strip_width;
298 void maybe_add_mixer_strip_width (XMLNode&);
299 void show_editor_mixer (bool yn);
300 void create_editor_mixer ();
301 void set_selected_mixer_strip (TimeAxisView&);
302 void hide_track_in_display (TimeAxisView& tv, bool temporary = false);
303 void show_track_in_display (TimeAxisView& tv);
305 /* nudge is initiated by transport controls owned by ARDOUR_UI */
307 void nudge_forward (bool next, bool force_playhead);
308 void nudge_backward (bool next, bool force_playhead);
310 /* nudge initiated from context menu */
312 void nudge_forward_capture_offset ();
313 void nudge_backward_capture_offset ();
315 /* playhead/screen stuff */
317 void set_stationary_playhead (bool yn);
318 void toggle_stationary_playhead ();
319 bool stationary_playhead() const { return _stationary_playhead; }
321 void set_follow_playhead (bool yn);
322 void toggle_follow_playhead ();
323 bool follow_playhead() const { return _follow_playhead; }
324 bool dragging_playhead () const { return _dragging_playhead; }
326 void toggle_waveform_visibility ();
327 void toggle_waveform_rectified ();
328 void toggle_waveforms_while_recording ();
330 void toggle_measure_visibility ();
331 void toggle_logo_visibility ();
333 double get_physical_screen_width () const { return physical_screen_width; };
334 double physical_screen_width;
335 double physical_screen_height;
337 /* SMPTE timecode & video sync */
339 void smpte_fps_chosen (ARDOUR::SmpteFormat format);
340 void video_pullup_chosen (ARDOUR::Session::PullupFormat pullup);
341 void subframes_per_frame_chosen (uint32_t);
343 void update_smpte_mode();
344 void update_video_pullup();
345 void update_subframes_per_frame ();
347 /* fades & xfades */
349 void toggle_region_fades ();
350 void toggle_region_fades_visible ();
351 void toggle_selected_region_fades (int dir);
352 void update_region_fade_visibility ();
354 void toggle_auto_xfade ();
355 void toggle_xfades_active ();
356 void toggle_xfade_visibility ();
357 bool xfade_visibility() const { return _xfade_visibility; }
358 void update_xfade_visibility ();
359 void update_crossfade_model ();
360 void set_crossfade_model (ARDOUR::CrossfadeModel);
362 /* layers */
363 void set_layer_model (ARDOUR::LayerModel);
364 void update_layering_model ();
366 void toggle_link_region_and_track_selection ();
368 void toggle_replicate_missing_region_channels ();
370 /* redirect shared ops menu. caller must free returned menu */
372 Gtk::Menu* redirect_menu ();
374 /* floating windows/transient */
376 void ensure_float (Gtk::Window&);
378 void show_window ();
380 void scroll_tracks_down_line ();
381 void scroll_tracks_up_line ();
383 void move_selected_tracks (bool up);
385 bool new_regionviews_display_gain () { return _new_regionviews_show_envelope; }
386 void prepare_for_cleanup ();
387 void finish_cleanup ();
389 void maximise_editing_space();
390 void restore_editing_space();
392 void reset_x_origin (nframes64_t);
393 void reset_zoom (double);
394 void reposition_and_zoom (nframes64_t, double);
396 nframes64_t get_preferred_edit_position (bool ignore_playhead = false);
398 bool update_mouse_speed ();
399 bool decelerate_mouse_speed ();
401 void toggle_meter_updating();
403 void show_rhythm_ferret();
405 void goto_visual_state (uint32_t);
406 void save_visual_state (uint32_t);
408 protected:
409 void map_transport_state ();
410 void map_position_change (nframes64_t);
412 void on_realize();
413 bool on_expose_event (GdkEventExpose*);
415 private:
417 ARDOUR::Session *session;
418 bool constructed;
420 // to keep track of the playhead position for control_scroll
421 boost::optional<nframes64_t> _control_scroll_target;
423 PlaylistSelector* _playlist_selector;
425 typedef std::pair<TimeAxisView*,XMLNode*> TAVState;
427 struct VisualState {
428 double y_position;
429 double frames_per_unit;
430 nframes64_t leftmost_frame;
431 Editing::ZoomFocus zoom_focus;
432 std::list<TAVState> track_states;
435 std::list<VisualState*> undo_visual_stack;
436 std::list<VisualState*> redo_visual_stack;
437 VisualState* current_visual_state (bool with_tracks = true);
438 void undo_visual_state ();
439 void redo_visual_state ();
440 void use_visual_state (VisualState&);
441 bool no_save_visual;
442 void swap_visual_state ();
444 std::vector<VisualState*> visual_states;
445 sigc::connection visual_state_op_connection;
446 void start_visual_state_op (uint32_t n);
447 void cancel_visual_state_op (uint32_t n);
448 bool end_visual_state_op (uint32_t n);
450 nframes64_t leftmost_frame;
451 double frames_per_unit;
452 Editing::ZoomFocus zoom_focus;
454 void set_frames_per_unit (double);
455 void post_zoom ();
457 Editing::MouseMode mouse_mode;
459 int post_maximal_editor_width;
460 int post_maximal_pane_position;
461 int pre_maximal_pane_position;
462 int pre_maximal_editor_width;
463 void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*);
465 Gtk::Notebook the_notebook;
466 Gtk::HPaned edit_pane;
468 Gtk::EventBox meter_base;
469 Gtk::HBox meter_box;
470 Gtk::EventBox marker_base;
471 Gtk::HBox marker_box;
472 Gtk::VBox scrollers_rulers_markers_box;
474 void location_changed (ARDOUR::Location *);
475 void location_flags_changed (ARDOUR::Location *, void *);
476 void refresh_location_display ();
477 void refresh_location_display_s (ARDOUR::Change);
478 void refresh_location_display_internal (ARDOUR::Locations::LocationList&);
479 void add_new_location (ARDOUR::Location *);
480 void location_gone (ARDOUR::Location *);
481 void remove_marker (ArdourCanvas::Item&, GdkEvent*);
482 gint really_remove_marker (ARDOUR::Location* loc);
483 void goto_nth_marker (int nth);
485 uint32_t location_marker_color;
486 uint32_t location_range_color;
487 uint32_t location_loop_color;
488 uint32_t location_punch_color;
489 uint32_t location_cd_marker_color;
491 struct LocationMarkers {
492 Marker* start;
493 Marker* end;
494 bool valid;
496 LocationMarkers () : start(0), end(0), valid (true) {}
498 ~LocationMarkers ();
500 void hide();
501 void show ();
502 void set_name (const string&);
503 void set_position (nframes64_t start, nframes64_t end = 0);
504 void set_color_rgba (uint32_t);
507 LocationMarkers *find_location_markers (ARDOUR::Location *) const;
508 ARDOUR::Location* find_location_from_marker (Marker *, bool& is_start) const;
509 Marker* entered_marker;
511 typedef std::map<ARDOUR::Location*,LocationMarkers *> LocationMarkerMap;
512 LocationMarkerMap location_markers;
514 void hide_marker (ArdourCanvas::Item*, GdkEvent*);
515 void clear_marker_display ();
516 void mouse_add_new_marker (nframes64_t where, bool is_cd=false, bool is_xrun=false);
517 bool choose_new_marker_name(string &name);
518 void update_cd_marker_display ();
519 void ensure_cd_marker_updated (LocationMarkers * lam, ARDOUR::Location * location);
521 TimeAxisView* clicked_trackview;
522 AudioTimeAxisView* clicked_audio_trackview;
523 RegionView* clicked_regionview;
524 RegionSelection latest_regionviews;
525 uint32_t clicked_selection;
526 CrossfadeView* clicked_crossfadeview;
527 ControlPoint* clicked_control_point;
529 void sort_track_selection (TrackSelection* sel = 0);
531 void get_relevant_audio_tracks (std::set<AudioTimeAxisView*>& relevant_tracks);
532 void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&);
533 void mapover_audio_tracks (sigc::slot<void,AudioTimeAxisView&,uint32_t> sl, TimeAxisView*);
535 /* functions to be passed to mapover_audio_tracks(), possibly with sigc::bind()-supplied arguments */
537 void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, vector<RegionView*>*);
538 void mapped_use_new_playlist (AudioTimeAxisView&, uint32_t, vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
539 void mapped_use_copy_playlist (AudioTimeAxisView&, uint32_t, vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
540 void mapped_clear_playlist (AudioTimeAxisView&, uint32_t);
542 /* end */
544 void button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type);
545 bool button_release_can_deselect;
547 void catch_vanishing_regionview (RegionView *);
549 void set_selected_track (TimeAxisView&, Selection::Operation op = Selection::Set, bool no_remove=false);
550 void select_all_tracks ();
552 bool set_selected_control_point_from_click (Selection::Operation op = Selection::Set, bool no_remove=false);
553 void set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool no_remove=false);
554 void set_selected_track_as_side_effect (Selection::Operation op, bool force = false);
555 bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set, bool no_track_remove=false);
557 void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
558 bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::weak_ptr<ARDOUR::Region>);
559 void collect_new_region_view (RegionView *);
561 Gtk::Menu track_context_menu;
562 Gtk::Menu track_region_context_menu;
563 Gtk::Menu track_selection_context_menu;
564 Gtk::Menu track_crossfade_context_menu;
566 Gtk::MenuItem* region_edit_menu_split_item;
567 Gtk::MenuItem* region_edit_menu_split_multichannel_item;
568 Gtk::Menu * track_region_edit_playlist_menu;
569 Gtk::Menu * track_edit_playlist_submenu;
570 Gtk::Menu * track_selection_edit_playlist_submenu;
572 void popup_track_context_menu (int, int, ItemType, bool, nframes64_t);
573 Gtk::Menu* build_track_context_menu (nframes64_t);
574 Gtk::Menu* build_track_bus_context_menu (nframes64_t);
575 Gtk::Menu* build_track_region_context_menu (nframes64_t frame);
576 Gtk::Menu* build_track_crossfade_context_menu (nframes64_t);
577 Gtk::Menu* build_track_selection_context_menu (nframes64_t);
578 void add_dstream_context_items (Gtk::Menu_Helpers::MenuList&);
579 void add_bus_context_items (Gtk::Menu_Helpers::MenuList&);
580 void add_region_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Region>, Gtk::Menu_Helpers::MenuList&, nframes64_t position, bool multiple_regions_at_position);
581 void add_crossfade_context_items (AudioStreamView*, boost::shared_ptr<ARDOUR::Crossfade>, Gtk::Menu_Helpers::MenuList&, bool many);
582 void add_selection_context_items (Gtk::Menu_Helpers::MenuList&);
584 void handle_new_route (ARDOUR::Session::RouteList&);
585 void remove_route (TimeAxisView *);
586 bool route_removal;
588 Gtk::HBox global_hpacker;
589 Gtk::VBox global_vpacker;
590 Gtk::VBox vpacker;
592 bool need_resize_line;
593 int resize_line_y;
594 int old_resize_line_y;
596 Gdk::Cursor* current_canvas_cursor;
597 void set_canvas_cursor ();
598 Gdk::Cursor* which_grabber_cursor ();
600 ArdourCanvas::Canvas* track_canvas;
601 ArdourCanvas::NoEventText* verbose_canvas_cursor;
602 bool verbose_cursor_visible;
604 void parameter_changed (const char *);
606 bool track_canvas_motion (GdkEvent*);
608 void set_verbose_canvas_cursor (const string &, double x, double y);
609 void set_verbose_canvas_cursor_text (const string &);
610 void show_verbose_canvas_cursor();
611 void hide_verbose_canvas_cursor();
613 bool verbose_cursor_on; // so far unused
615 Gtk::EventBox time_canvas_event_box;
616 Gtk::EventBox track_canvas_event_box;
617 Gtk::EventBox time_button_event_box;
618 Gtk::EventBox ruler_label_event_box;
620 ArdourCanvas::Pixbuf* logo_item;
621 ArdourCanvas::Group* minsec_group;
622 ArdourCanvas::Group* bbt_group;
623 ArdourCanvas::Group* smpte_group;
624 ArdourCanvas::Group* frame_group;
625 ArdourCanvas::Group* tempo_group;
626 ArdourCanvas::Group* meter_group;
627 ArdourCanvas::Group* marker_group;
628 ArdourCanvas::Group* range_marker_group;
629 ArdourCanvas::Group* transport_marker_group;
630 ArdourCanvas::Group* cd_marker_group;
632 ArdourCanvas::Group* timebar_group;
634 /* These bars never need to be scrolled */
635 ArdourCanvas::Group* meter_bar_group;
636 ArdourCanvas::Group* tempo_bar_group;
637 ArdourCanvas::Group* marker_bar_group;
638 ArdourCanvas::Group* range_marker_bar_group;
639 ArdourCanvas::Group* transport_marker_bar_group;
640 ArdourCanvas::Group* cd_marker_bar_group;
642 ArdourCanvas::Group* _background_group;
644 The _master_group is the group containing all items
645 that require horizontal scrolling..
646 It is primarily used to separate canvas items
647 that require horizontal scrolling from those that do not.
649 ArdourCanvas::Group* _master_group;
651 The _trackview_group is the group containing all trackviews.
652 It is only scrolled vertically.
654 ArdourCanvas::Group* _trackview_group;
656 This canvas group is used for region motion.
657 It sits on top of the _trackview_group
659 ArdourCanvas::Group* _region_motion_group;
661 enum RulerType {
662 ruler_metric_smpte = 0,
663 ruler_metric_bbt = 1,
664 ruler_metric_frames = 2,
665 ruler_metric_minsec = 3,
667 ruler_time_tempo = 4,
668 ruler_time_meter = 5,
669 ruler_time_marker = 6,
670 ruler_time_range_marker = 7,
671 ruler_time_transport_marker = 8,
672 ruler_time_cd_marker = 9,
675 static GtkCustomMetric ruler_metrics[4];
676 Glib::RefPtr<Gtk::ToggleAction> ruler_timecode_action;
677 Glib::RefPtr<Gtk::ToggleAction> ruler_bbt_action;
678 Glib::RefPtr<Gtk::ToggleAction> ruler_samples_action;
679 Glib::RefPtr<Gtk::ToggleAction> ruler_minsec_action;
680 Glib::RefPtr<Gtk::ToggleAction> ruler_tempo_action;
681 Glib::RefPtr<Gtk::ToggleAction> ruler_meter_action;
682 Glib::RefPtr<Gtk::ToggleAction> ruler_marker_action;
683 Glib::RefPtr<Gtk::ToggleAction> ruler_range_action;
684 Glib::RefPtr<Gtk::ToggleAction> ruler_loop_punch_action;
685 Glib::RefPtr<Gtk::ToggleAction> ruler_cd_marker_action;
686 bool no_ruler_shown_update;
688 gint ruler_button_press (GdkEventButton*);
689 gint ruler_button_release (GdkEventButton*);
690 gint ruler_mouse_motion (GdkEventMotion*);
691 bool ruler_scroll (GdkEventScroll* event);
693 gint ruler_pressed_button;
694 Gtk::Widget * ruler_grabbed_widget;
696 void initialize_rulers ();
697 void update_just_smpte ();
698 void update_fixed_rulers ();
699 void update_tempo_based_rulers ();
700 void popup_ruler_menu (nframes64_t where = 0, ItemType type = RegionItem);
701 void update_ruler_visibility ();
702 void set_ruler_visible (RulerType, bool);
703 void toggle_ruler_visibility (RulerType rt);
704 void ruler_toggled (int);
705 gint ruler_label_button_release (GdkEventButton*);
706 void store_ruler_visibility ();
707 void restore_ruler_visibility ();
709 static gint _metric_get_smpte (GtkCustomRulerMark **, gdouble, gdouble, gint);
710 static gint _metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
711 static gint _metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
712 static gint _metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
714 gint metric_get_smpte (GtkCustomRulerMark **, gdouble, gdouble, gint);
715 gint metric_get_bbt (GtkCustomRulerMark **, gdouble, gdouble, gint);
716 gint metric_get_frames (GtkCustomRulerMark **, gdouble, gdouble, gint);
717 gint metric_get_minsec (GtkCustomRulerMark **, gdouble, gdouble, gint);
719 Gtk::Widget *_ruler_separator;
720 GtkWidget *_smpte_ruler;
721 GtkWidget *_bbt_ruler;
722 GtkWidget *_frames_ruler;
723 GtkWidget *_minsec_ruler;
724 Gtk::Widget *smpte_ruler;
725 Gtk::Widget *bbt_ruler;
726 Gtk::Widget *frames_ruler;
727 Gtk::Widget *minsec_ruler;
728 static Editor *ruler_editor;
730 static const double timebar_height;
731 guint32 visible_timebars;
732 gdouble canvas_timebars_vsize;
733 gdouble get_canvas_timebars_vsize () const { return canvas_timebars_vsize; }
734 Gtk::Menu *editor_ruler_menu;
736 ArdourCanvas::SimpleRect* tempo_bar;
737 ArdourCanvas::SimpleRect* meter_bar;
738 ArdourCanvas::SimpleRect* marker_bar;
739 ArdourCanvas::SimpleRect* range_marker_bar;
740 ArdourCanvas::SimpleRect* transport_marker_bar;
741 ArdourCanvas::SimpleRect* cd_marker_bar;
744 ArdourCanvas::SimpleLine* tempo_line;
745 ArdourCanvas::SimpleLine* meter_line;
746 ArdourCanvas::SimpleLine* marker_line;
747 ArdourCanvas::SimpleLine* range_marker_line;
748 ArdourCanvas::SimpleLine* transport_marker_line;
749 ArdourCanvas::SimpleLine* cd_marker_line;
751 Gtk::Label minsec_label;
752 Gtk::Label bbt_label;
753 Gtk::Label smpte_label;
754 Gtk::Label frame_label;
755 Gtk::Label tempo_label;
756 Gtk::Label meter_label;
757 Gtk::Label mark_label;
758 Gtk::Label range_mark_label;
759 Gtk::Label transport_mark_label;
760 Gtk::Label cd_mark_label;
763 Gtk::VBox time_button_vbox;
764 Gtk::HBox time_button_hbox;
766 struct Cursor {
767 Editor& editor;
768 ArdourCanvas::Points points;
769 ArdourCanvas::Line canvas_item;
770 nframes64_t current_frame;
771 double length;
773 Cursor (Editor&, bool (Editor::*)(GdkEvent*,ArdourCanvas::Item*));
774 ~Cursor ();
776 void set_position (nframes64_t);
777 void set_length (double units);
778 void set_y_axis (double position);
781 friend struct Cursor; /* it needs access to several private
782 fields. XXX fix me.
785 Cursor* playhead_cursor;
786 ArdourCanvas::Group* cursor_group;
788 nframes64_t get_region_boundary (nframes64_t pos, int32_t dir, bool with_selection, bool only_onscreen);
790 void cursor_to_region_boundary (bool with_selection, int32_t dir);
791 void cursor_to_next_region_boundary (bool with_selection);
792 void cursor_to_previous_region_boundary (bool with_selection);
793 void cursor_to_next_region_point (Cursor*, ARDOUR::RegionPoint);
794 void cursor_to_previous_region_point (Cursor*, ARDOUR::RegionPoint);
795 void cursor_to_region_point (Cursor*, ARDOUR::RegionPoint, int32_t dir);
796 void cursor_to_selection_start (Cursor *);
797 void cursor_to_selection_end (Cursor *);
799 void selected_marker_to_region_boundary (bool with_selection, int32_t dir);
800 void selected_marker_to_next_region_boundary (bool with_selection);
801 void selected_marker_to_previous_region_boundary (bool with_selection);
802 void selected_marker_to_next_region_point (ARDOUR::RegionPoint);
803 void selected_marker_to_previous_region_point (ARDOUR::RegionPoint);
804 void selected_marker_to_region_point (ARDOUR::RegionPoint, int32_t dir);
805 void selected_marker_to_selection_start ();
806 void selected_marker_to_selection_end ();
808 void select_all_selectables_using_cursor (Cursor *, bool);
809 void select_all_selectables_using_edit (bool);
810 void select_all_selectables_between (bool within);
811 void select_range_between ();
813 boost::shared_ptr<ARDOUR::Region> find_next_region (nframes64_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
814 nframes64_t find_next_region_boundary (nframes64_t, int32_t dir, const TrackViewList&);
816 vector<nframes64_t> region_boundary_cache;
817 void build_region_boundary_cache ();
819 Gtk::HBox top_hbox;
820 Gtk::HBox bottom_hbox;
822 Gtk::Table edit_packer;
823 Gtk::VScrollbar edit_vscrollbar;
825 Gtk::Adjustment vertical_adjustment;
826 Gtk::Adjustment horizontal_adjustment;
828 Gtk::Layout controls_layout;
829 bool control_layout_scroll (GdkEventScroll* ev);
830 void controls_layout_size_request (Gtk::Requisition*);
831 sigc::connection controls_layout_size_request_connection;
833 Gtk::HScrollbar edit_hscrollbar;
834 bool _dragging_hscrollbar;
836 void reset_hscrollbar_stepping ();
838 bool hscrollbar_button_press (GdkEventButton*);
839 bool hscrollbar_button_release (GdkEventButton*);
840 void hscrollbar_allocate (Gtk::Allocation &alloc);
842 double canvas_width;
843 double canvas_height;
844 double full_canvas_height;
846 bool track_canvas_map_handler (GdkEventAny*);
848 gint edit_controls_button_release (GdkEventButton*);
849 Gtk::Menu *edit_controls_left_menu;
850 Gtk::Menu *edit_controls_right_menu;
852 Gtk::VBox ruler_label_vbox;
853 Gtk::VBox track_canvas_vbox;
854 Gtk::VBox time_canvas_vbox;
855 Gtk::VBox edit_controls_vbox;
856 Gtk::HBox edit_controls_hbox;
858 void control_scroll (float);
859 void access_action (std::string,std::string);
860 bool deferred_control_scroll (nframes64_t);
861 sigc::connection control_scroll_connection;
863 gdouble get_trackview_group_vertical_offset () const { return vertical_adjustment.get_value () - canvas_timebars_vsize;}
865 ArdourCanvas::Group* get_background_group () const { return _background_group; }
866 ArdourCanvas::Group* get_trackview_group () const { return _trackview_group; }
867 double last_trackview_group_vertical_offset;
868 void tie_vertical_scrolling ();
869 void scroll_canvas_horizontally ();
870 void scroll_canvas_vertically ();
872 struct VisualChange {
873 enum Type {
874 TimeOrigin = 0x1,
875 ZoomLevel = 0x2
878 Type pending;
879 nframes64_t time_origin;
880 double frames_per_unit;
882 int idle_handler_id;
884 VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), frames_per_unit (0), idle_handler_id (-1) {}
888 VisualChange pending_visual_change;
890 static int _idle_visual_changer (void *arg);
891 int idle_visual_changer ();
893 void queue_visual_change (nframes64_t);
894 void queue_visual_change (double);
896 void end_location_changed (ARDOUR::Location*);
898 struct RegionListDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
899 RegionListDisplayModelColumns() {
900 add (name);
901 add (region);
902 add (color_);
904 Gtk::TreeModelColumn<Glib::ustring> name;
905 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
906 Gtk::TreeModelColumn<Gdk::Color> color_;
909 RegionListDisplayModelColumns region_list_columns;
910 Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > region_list_display;
912 Glib::RefPtr<Gtk::TreeStore> region_list_model;
913 Glib::RefPtr<Gtk::ToggleAction> toggle_full_region_list_action;
914 Glib::RefPtr<Gtk::ToggleAction> toggle_show_auto_regions_action;
916 void region_list_selection_changed ();
917 bool region_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
918 void region_name_edit (const Glib::ustring&, const Glib::ustring&);
919 void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions);
921 Gtk::Menu *region_list_menu;
922 Gtk::ScrolledWindow region_list_scroller;
923 Gtk::Frame region_list_frame;
925 bool region_list_display_key_press (GdkEventKey *);
926 bool region_list_display_key_release (GdkEventKey *);
927 bool region_list_display_button_press (GdkEventButton *);
928 bool region_list_display_button_release (GdkEventButton *);
929 void region_list_clear ();
930 void region_list_selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
931 void build_region_list_menu ();
932 void show_region_list_display_context_menu (int button, int time);
934 bool show_automatic_regions_in_region_list;
935 Editing::RegionListSortType region_list_sort_type;
937 void reset_region_list_sort_direction (bool);
938 void reset_region_list_sort_type (Editing::RegionListSortType);
940 void toggle_full_region_list ();
941 void toggle_show_auto_regions ();
943 int region_list_sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
945 /* snapshots */
947 Gtk::ScrolledWindow snapshot_display_scroller;
948 struct SnapshotDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
949 SnapshotDisplayModelColumns() {
950 add (visible_name);
951 add (real_name);
953 Gtk::TreeModelColumn<Glib::ustring> visible_name;
954 Gtk::TreeModelColumn<Glib::ustring> real_name;
957 SnapshotDisplayModelColumns snapshot_display_columns;
958 Glib::RefPtr<Gtk::ListStore> snapshot_display_model;
959 Gtk::TreeView snapshot_display;
960 Gtk::Menu snapshot_context_menu;
962 bool snapshot_display_button_press (GdkEventButton*);
963 void snapshot_display_selection_changed ();
964 void redisplay_snapshots();
965 void popup_snapshot_context_menu (int, int32_t, Glib::ustring);
967 /* named selections */
969 struct NamedSelectionDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
970 NamedSelectionDisplayModelColumns() {
971 add (text);
972 add (selection);
974 Gtk::TreeModelColumn<Glib::ustring> text;
975 Gtk::TreeModelColumn<ARDOUR::NamedSelection*> selection;
978 NamedSelectionDisplayModelColumns named_selection_columns;
979 Glib::RefPtr<Gtk::TreeStore> named_selection_model;
981 Gtkmm2ext::DnDTreeView<ARDOUR::NamedSelection*> named_selection_display;
982 Gtk::ScrolledWindow named_selection_scroller;
984 void create_named_selection ();
985 void paste_named_selection (float times);
986 void remove_selected_named_selections ();
987 void remove_snapshot (Glib::ustring);
988 void rename_snapshot (Glib::ustring);
990 void handle_new_named_selection ();
991 void add_named_selection_to_named_selection_display (ARDOUR::NamedSelection&);
992 void redisplay_named_selections ();
994 bool named_selection_display_button_release (GdkEventButton *ev);
995 bool named_selection_display_key_release (GdkEventKey *ev);
996 void named_selection_display_selection_changed ();
998 /* track views */
999 TrackViewList track_views;
1000 TimeAxisView *trackview_by_y_position (double ypos);
1002 static Gdk::Cursor* cross_hair_cursor;
1003 static Gdk::Cursor* trimmer_cursor;
1004 static Gdk::Cursor* selector_cursor;
1005 static Gdk::Cursor* grabber_cursor;
1006 static Gdk::Cursor* grabber_edit_point_cursor;
1007 static Gdk::Cursor* zoom_cursor;
1008 static Gdk::Cursor* time_fx_cursor;
1009 static Gdk::Cursor* fader_cursor;
1010 static Gdk::Cursor* speaker_cursor;
1011 static Gdk::Cursor* wait_cursor;
1012 static Gdk::Cursor* timebar_cursor;
1013 static Gdk::Cursor* transparent_cursor;
1015 static void build_cursors ();
1017 sigc::connection scroll_connection;
1018 nframes64_t last_update_frame;
1019 void center_screen (nframes64_t);
1020 void center_screen_internal (nframes64_t, float);
1022 void update_current_screen ();
1024 void session_going_away ();
1026 nframes64_t cut_buffer_start;
1027 nframes64_t cut_buffer_length;
1029 bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
1030 bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1031 bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1032 bool motion_handler (ArdourCanvas::Item*, GdkEvent*, ItemType, bool from_autoscroll = false);
1033 bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1034 bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
1036 /* KEYMAP HANDLING */
1038 void register_actions ();
1040 int ensure_cursor (nframes64_t* pos);
1042 void handle_new_audio_region (boost::weak_ptr<ARDOUR::AudioRegion>);
1043 void handle_new_audio_regions (vector<boost::weak_ptr<ARDOUR::AudioRegion> >& );
1044 void handle_audio_region_removed (boost::weak_ptr<ARDOUR::AudioRegion>);
1045 void add_audio_region_to_region_display (boost::shared_ptr<ARDOUR::AudioRegion>);
1046 void add_audio_regions_to_region_display (std::vector<boost::weak_ptr<ARDOUR::AudioRegion> > & );
1047 void region_hidden (boost::shared_ptr<ARDOUR::Region>);
1048 void redisplay_regions ();
1049 bool no_region_list_redisplay;
1050 void insert_into_tmp_audio_regionlist(boost::shared_ptr<ARDOUR::AudioRegion>);
1052 list<boost::shared_ptr<ARDOUR::AudioRegion> > tmp_audio_region_list;
1054 void cut_copy (Editing::CutCopyOp);
1055 void cut_copy_points (Editing::CutCopyOp);
1056 void cut_copy_regions (Editing::CutCopyOp, RegionSelection&);
1057 void cut_copy_ranges (Editing::CutCopyOp);
1059 void mouse_paste ();
1060 void paste_internal (nframes64_t position, float times);
1062 /* EDITING OPERATIONS */
1064 void reset_point_selection ();
1065 void toggle_region_mute ();
1066 void toggle_region_lock ();
1067 void toggle_region_opaque ();
1068 void toggle_record_enable ();
1069 void set_region_lock_style (ARDOUR::Region::PositionLockStyle);
1070 void raise_region ();
1071 void raise_region_to_top ();
1072 void change_region_layering_order (nframes64_t);
1073 void lower_region ();
1074 void lower_region_to_bottom ();
1075 void split_region ();
1076 void split_region_at (nframes64_t);
1077 void split_regions_at (nframes64_t, RegionSelection&);
1078 void split_region_at_transients ();
1079 void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret);
1080 void crop_region_to_selection ();
1081 void crop_region_to (nframes64_t start, nframes64_t end);
1082 void set_sync_point (nframes64_t, const RegionSelection&);
1083 void set_region_sync_from_edit_point ();
1084 void remove_region_sync();
1085 void align_selection (ARDOUR::RegionPoint, nframes64_t position, const RegionSelection&);
1086 void align_selection_relative (ARDOUR::RegionPoint point, nframes64_t position, const RegionSelection&);
1087 void align_region (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes64_t position);
1088 void align_region_internal (boost::shared_ptr<ARDOUR::Region>, ARDOUR::RegionPoint point, nframes64_t position);
1089 void remove_region ();
1090 void remove_clicked_region ();
1091 void edit_region ();
1092 void rename_region ();
1093 void duplicate_some_regions (RegionSelection&, float times);
1094 void duplicate_selection (float times);
1095 void region_fill_selection ();
1097 void region_fill_track ();
1098 void audition_playlist_region_standalone (boost::shared_ptr<ARDOUR::Region>);
1099 void audition_playlist_region_via_route (boost::shared_ptr<ARDOUR::Region>, ARDOUR::Route&);
1100 void split_multichannel_region();
1101 void reverse_region ();
1102 void normalize_region ();
1103 void denormalize_region ();
1104 void adjust_region_scale_amplitude (bool up);
1106 void do_insert_time ();
1107 void insert_time (nframes64_t pos, nframes64_t distance, Editing::InsertTimeOption opt, bool ignore_music_glue, bool markers_too, bool tempo_too);
1109 void tab_to_transient (bool forward);
1111 void use_region_as_bar ();
1112 void use_range_as_bar ();
1114 void define_one_bar (nframes64_t start, nframes64_t end);
1116 void audition_region_from_region_list ();
1117 void hide_region_from_region_list ();
1118 void remove_region_from_region_list ();
1120 void align (ARDOUR::RegionPoint);
1121 void align_relative (ARDOUR::RegionPoint);
1122 void naturalize ();
1124 void reset_focus ();
1126 void split ();
1128 void cut ();
1129 void copy ();
1130 void paste (float times);
1132 int get_prefix (float&, bool&);
1134 void keyboard_paste ();
1135 void keyboard_insert_region_list_selection ();
1137 void region_from_selection ();
1138 void create_region_from_selection (std::vector<boost::shared_ptr<ARDOUR::AudioRegion> >&);
1140 void play_from_start ();
1141 void play_from_edit_point ();
1142 void play_from_edit_point_and_return ();
1143 void play_selected_region ();
1144 void play_edit_range ();
1145 void loop_selected_region ();
1146 void play_location (ARDOUR::Location&);
1147 void loop_location (ARDOUR::Location&);
1149 void temporal_zoom_selection ();
1150 void temporal_zoom_region (bool both_axes);
1151 void toggle_zoom_region (bool both_axes);
1152 void temporal_zoom_session ();
1153 void temporal_zoom (gdouble scale);
1154 void temporal_zoom_by_frame (nframes64_t start, nframes64_t end, const string & op);
1155 void temporal_zoom_to_frame (bool coarser, nframes64_t frame);
1157 void amplitude_zoom (gdouble scale);
1158 void amplitude_zoom_step (bool in);
1160 void insert_region_list_drag (boost::shared_ptr<ARDOUR::AudioRegion>, int x, int y);
1161 void insert_region_list_selection (float times);
1163 void add_external_audio_action (Editing::ImportMode);
1164 void external_audio_dialog ();
1166 int check_whether_and_how_to_import(string, bool all_or_nothing = true);
1167 bool check_multichannel_status (const std::vector<Glib::ustring>& paths);
1169 SoundFileOmega* sfbrowser;
1171 void bring_in_external_audio (Editing::ImportMode mode, nframes64_t& pos);
1173 bool idle_drop_paths (std::vector<Glib::ustring> paths, nframes64_t frame, double ypos);
1174 void drop_paths_part_two (const std::vector<Glib::ustring>& paths, nframes64_t frame, double ypos);
1176 void do_import (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t&);
1177 void do_embed (vector<Glib::ustring> paths, Editing::ImportDisposition, Editing::ImportMode mode, nframes64_t&);
1179 int import_sndfiles (vector<Glib::ustring> paths, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t& pos,
1180 int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::AudioTrack>&, bool, uint32_t total);
1181 int embed_sndfiles (vector<Glib::ustring> paths, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode,
1182 nframes64_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::AudioTrack>&);
1184 int add_sources (vector<Glib::ustring> paths, ARDOUR::SourceList& sources, nframes64_t& pos, Editing::ImportMode,
1185 int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::AudioTrack>&, bool add_channel_suffix);
1186 int finish_bringing_in_audio (boost::shared_ptr<ARDOUR::AudioRegion> region, uint32_t, uint32_t, nframes64_t& pos, Editing::ImportMode mode,
1187 boost::shared_ptr<ARDOUR::AudioTrack>& existing_track);
1189 boost::shared_ptr<ARDOUR::AudioTrack> get_nth_selected_audio_track (int nth) const;
1191 /* generic interthread progress window */
1193 ArdourDialog* interthread_progress_window;
1194 Gtk::Label interthread_progress_label;
1195 Gtk::VBox interthread_progress_vbox;
1196 Gtk::ProgressBar interthread_progress_bar;
1197 Gtk::Button interthread_cancel_button;
1198 Gtk::Label interthread_cancel_label;
1199 sigc::connection interthread_progress_connection;
1200 void interthread_cancel_clicked ();
1201 void build_interthread_progress_window ();
1202 ARDOUR::InterThreadInfo* current_interthread_info;
1204 #ifdef FFT_ANALYSIS
1205 AnalysisWindow* analysis_window;
1206 #endif
1208 /* import specific info */
1210 struct EditorImportStatus : public ARDOUR::Session::import_status {
1211 Editing::ImportMode mode;
1212 nframes64_t pos;
1213 int target_tracks;
1214 int target_regions;
1215 boost::shared_ptr<ARDOUR::AudioTrack> track;
1216 bool replace;
1219 EditorImportStatus import_status;
1220 gint import_progress_timeout (void *);
1221 static void *_import_thread (void *);
1222 void* import_thread ();
1223 void finish_import ();
1225 /* to support this ... */
1227 void import_audio (bool as_tracks);
1228 void do_import (vector<Glib::ustring> paths, bool split, bool as_tracks);
1230 void move_to_start ();
1231 void move_to_end ();
1232 void goto_frame ();
1233 void center_playhead ();
1234 void center_edit_point ();
1235 void edit_cursor_backward ();
1236 void edit_cursor_forward ();
1237 void playhead_forward_to_grid ();
1238 void playhead_backward_to_grid ();
1239 void playhead_backward ();
1240 void playhead_forward ();
1241 void scroll_playhead (bool forward);
1242 void scroll_backward (float pages=0.8f);
1243 void scroll_forward (float pages=0.8f);
1244 void scroll_tracks_down ();
1245 void scroll_tracks_up ();
1246 void delete_sample_forward ();
1247 void delete_sample_backward ();
1248 void delete_screen ();
1249 void search_backwards ();
1250 void search_forwards ();
1251 void set_mark ();
1252 void clear_markers ();
1253 void clear_ranges ();
1254 void clear_locations ();
1255 void unhide_markers ();
1256 void unhide_ranges ();
1257 void jump_forward_to_mark ();
1258 void jump_backward_to_mark ();
1259 void cursor_align (bool playhead_to_edit);
1261 void remove_last_capture ();
1262 void select_all_selectables_using_time_selection ();
1263 void select_all_selectables_using_loop();
1264 void select_all_selectables_using_punch();
1265 void set_selection_from_range (ARDOUR::Location&);
1266 void set_selection_from_punch ();
1267 void set_selection_from_loop ();
1268 void set_selection_from_audio_region ();
1270 void add_location_mark (nframes64_t where);
1271 void add_location_from_audio_region ();
1272 void add_locations_from_audio_region ();
1273 void add_location_from_selection ();
1274 void set_loop_from_selection (bool play);
1275 void set_punch_from_selection ();
1276 void set_punch_from_region ();
1278 void set_loop_from_edit_range (bool play);
1279 void set_loop_from_region (bool play);
1280 void set_punch_from_edit_range ();
1282 void set_loop_range (nframes64_t start, nframes64_t end, std::string cmd);
1283 void set_punch_range (nframes64_t start, nframes64_t end, std::string cmd);
1285 void add_location_from_playhead_cursor ();
1286 bool select_new_marker;
1288 void reverse_selection ();
1289 void edit_envelope ();
1291 void start_scrolling ();
1292 void stop_scrolling ();
1294 bool _scrubbing;
1295 double last_scrub_x;
1296 int scrubbing_direction;
1297 int scrub_reversals;
1298 int scrub_reverse_distance;
1299 void scrub ();
1301 void keyboard_selection_begin ();
1302 void keyboard_selection_finish (bool add);
1303 bool have_pending_keyboard_selection;
1304 nframes64_t pending_keyboard_selection_start;
1306 boost::shared_ptr<ARDOUR::Region> select_region_for_operation (int dir, TimeAxisView **tv);
1307 void extend_selection_to_end_of_region (bool next);
1308 void extend_selection_to_start_of_region (bool previous);
1310 Editing::SnapType snap_type;
1311 Editing::SnapMode snap_mode;
1312 double snap_threshold;
1314 void handle_gui_changes (const string &, void *);
1315 bool ignore_gui_changes;
1317 void hide_all_tracks (bool with_select);
1319 DragInfo drag_info;
1320 LineDragInfo current_line_drag_info;
1322 void start_grab (GdkEvent*, Gdk::Cursor* cursor = 0);
1323 bool end_grab (ArdourCanvas::Item*, GdkEvent*);
1324 void swap_grab (ArdourCanvas::Item*, Gdk::Cursor* cursor, uint32_t time);
1325 void break_drag ();
1326 void finalize_drag ();
1328 Gtk::Menu fade_context_menu;
1329 void popup_fade_context_menu (int, int, ArdourCanvas::Item*, ItemType);
1331 void region_gain_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1333 void start_fade_in_grab (ArdourCanvas::Item*, GdkEvent*);
1334 void start_fade_out_grab (ArdourCanvas::Item*, GdkEvent*);
1335 void fade_in_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1336 void fade_out_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1337 void fade_in_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1338 void fade_out_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1340 void set_fade_in_shape (ARDOUR::AudioRegion::FadeShape);
1341 void set_fade_out_shape (ARDOUR::AudioRegion::FadeShape);
1343 void set_fade_length (bool in);
1344 void toggle_fade_active (bool in);
1345 void set_fade_in_active (bool);
1346 void set_fade_out_active (bool);
1348 std::set<boost::shared_ptr<ARDOUR::Playlist> > motion_frozen_playlists;
1349 RegionSelection pre_drag_region_selection;
1350 void region_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1351 void region_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1352 bool check_region_drag_possible (AudioTimeAxisView**);
1353 void possibly_copy_regions_during_grab (GdkEvent*);
1354 void region_drag_splice_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1355 void region_drag_splice_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1357 bool _dragging_playhead;
1358 bool _dragging_edit_point;
1360 void cursor_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1361 void cursor_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1362 void cursor_drag_finished_ensure_locate_callback (ArdourCanvas::Item*, GdkEvent*);
1363 void marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1364 void marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1365 void control_point_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1366 void control_point_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1367 void line_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1368 void line_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1370 void tempo_marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1371 void tempo_marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1372 void meter_marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1373 void meter_marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1375 gint mouse_rename_region (ArdourCanvas::Item*, GdkEvent*);
1377 void start_region_grab (ArdourCanvas::Item*, GdkEvent*);
1378 void start_region_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1379 void start_region_brush_grab (ArdourCanvas::Item*, GdkEvent*);
1380 void start_selection_grab (ArdourCanvas::Item*, GdkEvent*);
1381 void start_cursor_grab (ArdourCanvas::Item*, GdkEvent*);
1382 void start_cursor_grab_no_stop (ArdourCanvas::Item*, GdkEvent*);
1383 void start_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1384 void start_control_point_grab (ArdourCanvas::Item*, GdkEvent*);
1385 void start_line_grab_from_regionview (ArdourCanvas::Item*, GdkEvent*);
1386 void start_line_grab_from_line (ArdourCanvas::Item*, GdkEvent*);
1387 void start_line_grab (AutomationLine *, GdkEvent*);
1388 void start_tempo_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1389 void start_tempo_marker_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1390 void start_meter_marker_grab (ArdourCanvas::Item*, GdkEvent*);
1391 void start_meter_marker_copy_grab (ArdourCanvas::Item*, GdkEvent*);
1393 void region_view_item_click (AudioRegionView&, GdkEventButton*);
1395 void remove_gain_control_point (ArdourCanvas::Item*, GdkEvent*);
1396 void remove_control_point (ArdourCanvas::Item*, GdkEvent*);
1398 void mouse_brush_insert_region (RegionView*, nframes64_t pos);
1399 void brush (nframes64_t);
1401 void show_verbose_time_cursor (nframes64_t frame, double offset = 0, double xpos=-1, double ypos=-1);
1402 void show_verbose_duration_cursor (nframes64_t start, nframes64_t end, double offset = 0, double xpos=-1, double ypos=-1);
1403 double clamp_verbose_cursor_x (double);
1404 double clamp_verbose_cursor_y (double);
1406 /* Canvas event handlers */
1408 bool canvas_control_point_event (GdkEvent* event,ArdourCanvas::Item*, ControlPoint*);
1409 bool canvas_line_event (GdkEvent* event,ArdourCanvas::Item*, AutomationLine*);
1410 bool canvas_selection_rect_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1411 bool canvas_selection_start_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1412 bool canvas_selection_end_trim_event (GdkEvent* event,ArdourCanvas::Item*, SelectionRect*);
1413 bool canvas_crossfade_view_event (GdkEvent* event,ArdourCanvas::Item*, CrossfadeView*);
1414 bool canvas_fade_in_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1415 bool canvas_fade_in_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1416 bool canvas_fade_out_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1417 bool canvas_fade_out_handle_event (GdkEvent* event,ArdourCanvas::Item*, AudioRegionView*);
1420 // These variables are used to detect a feedback loop and break it to avoid a gui hang
1421 private:
1422 ArdourCanvas::Item *last_item_entered;
1423 int last_item_entered_n;
1424 public:
1426 bool canvas_region_view_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1427 bool canvas_region_view_name_highlight_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1428 bool canvas_region_view_name_event (GdkEvent* event,ArdourCanvas::Item*, RegionView*);
1429 bool canvas_stream_view_event (GdkEvent* event,ArdourCanvas::Item*, RouteTimeAxisView*);
1430 bool canvas_marker_event (GdkEvent* event,ArdourCanvas::Item*, Marker*);
1431 bool canvas_zoom_rect_event (GdkEvent* event,ArdourCanvas::Item*);
1432 bool canvas_tempo_marker_event (GdkEvent* event,ArdourCanvas::Item*, TempoMarker*);
1433 bool canvas_meter_marker_event (GdkEvent* event,ArdourCanvas::Item*, MeterMarker*);
1434 bool canvas_automation_track_event(GdkEvent* event, ArdourCanvas::Item*, AutomationTimeAxisView*) ;
1436 bool canvas_tempo_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1437 bool canvas_meter_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1438 bool canvas_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1439 bool canvas_range_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1440 bool canvas_transport_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1441 bool canvas_cd_marker_bar_event (GdkEvent* event, ArdourCanvas::Item*);
1443 bool canvas_imageframe_item_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1444 bool canvas_imageframe_view_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameTimeAxis*);
1445 bool canvas_imageframe_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1446 bool canvas_imageframe_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,ImageFrameView*);
1447 bool canvas_marker_time_axis_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerTimeAxis*);
1448 bool canvas_markerview_item_view_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1449 bool canvas_markerview_start_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1450 bool canvas_markerview_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*);
1452 /* non-public event handlers */
1454 bool canvas_playhead_cursor_event (GdkEvent* event, ArdourCanvas::Item*);
1455 bool track_canvas_scroll (GdkEventScroll* event);
1457 bool track_canvas_scroll_event (GdkEventScroll* event);
1458 bool track_canvas_button_press_event (GdkEventButton* event);
1459 bool track_canvas_button_release_event (GdkEventButton* event);
1460 bool track_canvas_motion_notify_event (GdkEventMotion* event);
1462 Gtk::Allocation canvas_allocation;
1463 void track_canvas_allocate (Gtk::Allocation alloc);
1464 bool track_canvas_size_allocated ();
1466 void set_playhead_cursor ();
1468 void kbd_driver (sigc::slot<void,GdkEvent*>, bool use_track_canvas = true, bool use_time_canvas = true, bool can_select = true);
1469 void kbd_mute_unmute_region ();
1470 void kbd_brush ();
1472 void kbd_do_brush (GdkEvent*);
1473 void kbd_do_audition (GdkEvent*);
1475 void handle_new_duration ();
1476 void initialize_canvas ();
1478 /* display control */
1480 bool _show_measures;
1482 bool _show_waveforms;
1483 bool _show_waveforms_rectified;
1484 bool _show_waveforms_recording;
1486 bool _stationary_playhead;
1487 bool _follow_playhead;
1489 ARDOUR::TempoMap::BBTPointList *current_bbt_points;
1491 TempoLines* tempo_lines;
1493 ArdourCanvas::Group* time_line_group;
1494 ArdourCanvas::SimpleLine* get_time_line ();
1495 void hide_measures ();
1496 void draw_measures ();
1497 bool redraw_measures ();
1499 void new_tempo_section ();
1501 void mouse_add_new_tempo_event (nframes64_t where);
1502 void mouse_add_new_meter_event (nframes64_t where);
1504 void remove_tempo_marker (ArdourCanvas::Item*);
1505 void remove_meter_marker (ArdourCanvas::Item*);
1506 gint real_remove_tempo_marker (ARDOUR::TempoSection*);
1507 gint real_remove_meter_marker (ARDOUR::MeterSection*);
1509 void edit_tempo_section (ARDOUR::TempoSection*);
1510 void edit_meter_section (ARDOUR::MeterSection*);
1511 void edit_tempo_marker (ArdourCanvas::Item*);
1512 void edit_meter_marker (ArdourCanvas::Item*);
1514 void marker_menu_edit ();
1515 void marker_menu_remove ();
1516 void marker_menu_rename ();
1517 void marker_menu_lock (bool yn);
1518 void marker_menu_hide ();
1519 void marker_menu_loop_range ();
1520 void marker_menu_select_all_selectables_using_range ();
1521 void marker_menu_select_using_range ();
1522 void marker_menu_separate_regions_using_location ();
1523 void marker_menu_play_from ();
1524 void marker_menu_play_range ();
1525 void marker_menu_set_playhead ();
1526 void marker_menu_set_from_playhead ();
1527 void marker_menu_set_from_selection ();
1528 void marker_menu_range_to_next ();
1529 void marker_menu_export_range ();
1530 void new_transport_marker_menu_set_loop ();
1531 void new_transport_marker_menu_set_punch ();
1532 void update_loop_range_view (bool visibility=false);
1533 void update_punch_range_view (bool visibility=false);
1534 void new_transport_marker_menu_popdown ();
1535 void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1536 void tm_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1537 void transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1538 void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
1539 void build_range_marker_menu (bool loop_or_punch);
1540 void build_marker_menu (bool start_or_end);
1541 void build_tm_marker_menu ();
1542 void build_new_transport_marker_menu ();
1544 Gtk::Menu* tm_marker_menu;
1545 Gtk::Menu* marker_menu;
1546 Gtk::Menu* start_end_marker_menu;
1547 Gtk::Menu* range_marker_menu;
1548 Gtk::Menu* transport_marker_menu;
1549 Gtk::Menu* new_transport_marker_menu;
1550 Gtk::Menu* cd_marker_menu;
1551 ArdourCanvas::Item* marker_menu_item;
1553 typedef list<Marker*> Marks;
1554 Marks metric_marks;
1556 void remove_metric_marks ();
1557 void draw_metric_marks (const ARDOUR::Metrics& metrics);
1559 void compute_current_bbt_points (nframes_t left, nframes_t right);
1560 void tempo_map_changed (ARDOUR::Change);
1561 void redisplay_tempo (bool immediate_redraw);
1563 void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
1565 uint32_t bbt_beat_subdivision;
1567 /* toolbar */
1569 void editor_mixer_button_toggled ();
1571 AudioClock edit_point_clock;
1572 AudioClock zoom_range_clock;
1573 Gtk::Button zoom_in_button;
1574 Gtk::Button zoom_out_button;
1575 Gtk::Button zoom_out_full_button;
1576 Gtk::Button zoom_onetoone_button;
1578 Gtk::VBox toolbar_clock_vbox;
1579 Gtk::VBox toolbar_selection_clock_vbox;
1580 Gtk::Table toolbar_selection_clock_table;
1581 Gtk::Label toolbar_selection_cursor_label;
1583 Gtk::HBox mouse_mode_button_box;
1584 Gtkmm2ext::TearOff* mouse_mode_tearoff;
1585 Gtk::ToggleButton mouse_select_button;
1586 Gtk::ToggleButton mouse_move_button;
1587 Gtk::ToggleButton mouse_gain_button;
1588 Gtk::ToggleButton mouse_zoom_button;
1589 Gtk::ToggleButton mouse_timefx_button;
1590 Gtk::ToggleButton mouse_audition_button;
1591 GroupedButtons *mouse_mode_button_set;
1592 void mouse_mode_toggled (Editing::MouseMode m);
1593 bool ignore_mouse_mode_toggle;
1595 gint mouse_select_button_release (GdkEventButton*);
1597 Gtk::VBox automation_box;
1598 Gtk::Button automation_mode_button;
1599 Gtk::ToggleButton global_automation_button;
1601 Gtk::ComboBoxText edit_mode_selector;
1602 Gtk::VBox edit_mode_box;
1604 void set_edit_mode (ARDOUR::EditMode);
1605 void cycle_edit_mode ();
1606 void edit_mode_selection_done ();
1608 Gtk::ComboBoxText snap_type_selector;
1609 Gtk::ComboBoxText snap_mode_selector;
1610 Gtk::HBox snap_box;
1612 std::vector<std::string> snap_type_strings;
1613 std::vector<std::string> snap_mode_strings;
1615 void snap_type_selection_done ();
1616 void snap_mode_selection_done ();
1617 void snap_mode_chosen (Editing::SnapMode);
1618 void snap_type_chosen (Editing::SnapType);
1620 Glib::RefPtr<Gtk::RadioAction> snap_type_action (Editing::SnapType);
1621 Glib::RefPtr<Gtk::RadioAction> snap_mode_action (Editing::SnapMode);
1623 Gtk::ComboBoxText zoom_focus_selector;
1624 Gtk::VBox zoom_focus_box;
1626 std::vector<std::string> zoom_focus_strings;
1628 void zoom_focus_selection_done ();
1629 void zoom_focus_chosen (Editing::ZoomFocus);
1631 Glib::RefPtr<Gtk::RadioAction> zoom_focus_action (Editing::ZoomFocus);
1633 Gtk::HBox zoom_box;
1635 void zoom_adjustment_changed();
1637 void edit_point_clock_changed();
1639 void setup_toolbar ();
1641 Gtkmm2ext::TearOff* tools_tearoff;
1642 Gtk::HBox toolbar_hbox;
1643 Gtk::EventBox toolbar_base;
1644 Gtk::Frame toolbar_frame;
1646 /* selection process */
1648 Selection* selection;
1649 Selection* cut_buffer;
1651 void time_selection_changed ();
1652 void track_selection_changed ();
1653 void region_selection_changed ();
1654 void sensitize_the_right_region_actions (bool have_selected_regions);
1655 void point_selection_changed ();
1656 void marker_selection_changed ();
1658 enum SelectionOp {
1659 CreateSelection,
1660 SelectionStartTrim,
1661 SelectionEndTrim,
1662 SelectionMove
1663 } selection_op;
1665 void start_selection_op (ArdourCanvas::Item* item, GdkEvent* event, SelectionOp);
1666 void drag_selection (ArdourCanvas::Item* item, GdkEvent* event);
1667 void end_selection_op (ArdourCanvas::Item* item, GdkEvent* event);
1668 void cancel_selection ();
1670 void region_selection_op (void (ARDOUR::Region::*pmf)(void));
1671 void region_selection_op (void (ARDOUR::Region::*pmf)(void*), void*);
1672 void region_selection_op (void (ARDOUR::Region::*pmf)(bool), bool);
1674 bool audio_region_selection_covers (nframes64_t where);
1676 /* transport range select process */
1677 enum RangeMarkerOp {
1678 CreateRangeMarker,
1679 CreateTransportMarker,
1680 CreateCDMarker
1681 } range_marker_op;
1683 void start_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event, RangeMarkerOp);
1684 void drag_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event);
1685 void end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event);
1687 ArdourCanvas::SimpleRect* cd_marker_bar_drag_rect;
1688 ArdourCanvas::SimpleRect* range_bar_drag_rect;
1689 ArdourCanvas::SimpleRect* transport_bar_drag_rect;
1690 ArdourCanvas::Line* marker_drag_line;
1691 ArdourCanvas::Points marker_drag_line_points;
1692 ArdourCanvas::SimpleRect* range_marker_drag_rect;
1694 void update_marker_drag_item (ARDOUR::Location *);
1695 #ifdef GTKOSX
1696 ArdourCanvas::SimpleRect *bogus_background_rect;
1697 #endif
1698 ArdourCanvas::SimpleRect *transport_bar_range_rect;
1699 ArdourCanvas::SimpleRect *transport_bar_preroll_rect;
1700 ArdourCanvas::SimpleRect *transport_bar_postroll_rect;
1701 ArdourCanvas::SimpleRect *transport_loop_range_rect;
1702 ArdourCanvas::SimpleRect *transport_punch_range_rect;
1703 ArdourCanvas::SimpleLine *transport_punchin_line;
1704 ArdourCanvas::SimpleLine *transport_punchout_line;
1705 ArdourCanvas::SimpleRect *transport_preroll_rect;
1706 ArdourCanvas::SimpleRect *transport_postroll_rect;
1708 ARDOUR::Location* transport_loop_location();
1709 ARDOUR::Location* transport_punch_location();
1711 ARDOUR::Location *temp_location;
1713 /* object rubberband select process */
1715 void start_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1716 void drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1717 void end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
1719 bool select_all_within (nframes64_t start, nframes64_t end, gdouble topy, gdouble boty, const TrackViewList&, Selection::Operation op);
1721 ArdourCanvas::SimpleRect *rubberband_rect;
1723 /* mouse zoom process */
1725 void start_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1726 void drag_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1727 void end_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
1729 ArdourCanvas::SimpleRect *zoom_rect;
1730 void reposition_zoom_rect (nframes64_t start, nframes64_t end);
1732 /* diskstream/route display management */
1734 struct RouteDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
1735 RouteDisplayModelColumns() {
1736 add (text);
1737 add (visible);
1738 add (temporary_visible);
1739 add (tv);
1740 add (route);
1742 Gtk::TreeModelColumn<Glib::ustring> text;
1743 Gtk::TreeModelColumn<bool> visible;
1744 Gtk::TreeModelColumn<bool> temporary_visible;
1745 Gtk::TreeModelColumn<TimeAxisView*> tv;
1746 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> > route;
1749 RouteDisplayModelColumns route_display_columns;
1750 Glib::RefPtr<Gtk::ListStore> route_display_model;
1751 Glib::RefPtr<Gtk::TreeSelection> route_display_selection;
1753 Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Route> > route_list_display;
1754 Gtk::ScrolledWindow route_list_scroller;
1755 Gtk::Menu* route_list_menu;
1757 void update_route_visibility ();
1759 void sync_order_keys (const char*);
1760 bool route_redisplay_does_not_sync_order_keys;
1761 bool route_redisplay_does_not_reset_order_keys;
1763 bool route_list_display_button_press (GdkEventButton*);
1764 void route_list_display_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context,
1765 gint x,
1766 gint y,
1767 const Gtk::SelectionData& data,
1768 guint info,
1769 guint time);
1771 bool route_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
1773 void route_list_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
1774 void route_list_delete (const Gtk::TreeModel::Path&);
1775 void track_list_reorder (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* new_order);
1777 void initial_route_list_display ();
1778 void redisplay_route_list();
1779 bool ignore_route_list_reorder;
1780 bool no_route_list_redisplay;
1781 bool sync_track_view_list_and_route_list ();
1783 void build_route_list_menu ();
1784 void show_route_list_menu ();
1786 void show_all_routes ();
1787 void hide_all_routes ();
1788 void show_all_audiotracks ();
1789 void hide_all_audiotracks ();
1790 void show_tracks_with_regions_at_playhead ();
1791 void show_all_audiobus ();
1792 void hide_all_audiobus ();
1794 void set_all_tracks_visibility (bool yn);
1795 void set_all_audio_visibility (int type, bool yn);
1797 /* edit group management */
1799 struct GroupListModelColumns : public Gtk::TreeModel::ColumnRecord {
1800 GroupListModelColumns () {
1801 add (is_active);
1802 add (is_visible);
1803 add (text);
1804 add (routegroup);
1806 Gtk::TreeModelColumn<bool> is_active;
1807 Gtk::TreeModelColumn<bool> is_visible;
1808 Gtk::TreeModelColumn<std::string> text;
1809 Gtk::TreeModelColumn<ARDOUR::RouteGroup*> routegroup;
1812 bool all_group_is_active;
1814 GroupListModelColumns group_columns;
1815 Glib::RefPtr<Gtk::ListStore> group_model;
1816 Glib::RefPtr<Gtk::TreeSelection> group_selection;
1818 Gtk::TreeView edit_group_display;
1819 Gtk::ScrolledWindow edit_group_display_scroller;
1820 Gtk::Menu* edit_group_list_menu;
1822 void build_edit_group_list_menu ();
1823 void activate_all_edit_groups ();
1824 void disable_all_edit_groups ();
1825 void show_all_edit_groups ();
1826 void hide_all_edit_groups ();
1828 bool in_edit_group_row_change;
1829 void edit_group_row_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
1830 void edit_group_name_edit (const Glib::ustring&, const Glib::ustring&);
1831 void new_edit_group ();
1832 void edit_group_list_button_clicked ();
1833 gint edit_group_list_button_press_event (GdkEventButton* ev);
1834 void add_edit_group (ARDOUR::RouteGroup* group);
1835 void remove_selected_edit_group ();
1836 void edit_groups_changed ();
1837 void group_flags_changed (void*, ARDOUR::RouteGroup*);
1839 Gtk::VBox list_vpacker;
1841 /* autoscrolling */
1843 bool autoscroll_active;
1844 int autoscroll_timeout_tag;
1845 int autoscroll_x;
1846 int autoscroll_y;
1847 int last_autoscroll_x;
1848 int last_autoscroll_y;
1849 uint32_t autoscroll_cnt;
1850 nframes64_t autoscroll_x_distance;
1851 double autoscroll_y_distance;
1853 static gint _autoscroll_canvas (void *);
1854 bool autoscroll_canvas ();
1855 void start_canvas_autoscroll (int x, int y);
1856 void stop_canvas_autoscroll ();
1857 void maybe_autoscroll (GdkEventMotion*);
1858 void maybe_autoscroll_horizontally (GdkEventMotion*);
1859 bool allow_vertical_scroll;
1861 /* trimming */
1862 enum TrimOp {
1863 StartTrim,
1864 EndTrim,
1865 ContentsTrim,
1866 } trim_op;
1868 void start_trim (ArdourCanvas::Item*, GdkEvent*);
1869 void point_trim (GdkEvent*);
1870 void trim_motion_callback (ArdourCanvas::Item*, GdkEvent*);
1871 void single_contents_trim (RegionView&, nframes64_t, bool, bool, bool);
1872 void single_start_trim (RegionView&, nframes64_t, bool, bool);
1873 void single_end_trim (RegionView&, nframes64_t, bool, bool);
1875 void trim_finished_callback (ArdourCanvas::Item*, GdkEvent*);
1876 void thaw_region_after_trim (RegionView& rv);
1878 void trim_region_front();
1879 void trim_region_back();
1880 void trim_region (bool front);
1882 void trim_region_to_edit_point ();
1883 void trim_region_from_edit_point ();
1884 void trim_region_to_loop ();
1885 void trim_region_to_punch ();
1886 void trim_region_to_location (const ARDOUR::Location&, const char* cmd);
1888 bool show_gain_after_trim;
1890 /* Drag-n-Drop */
1892 int convert_drop_to_paths (std::vector<Glib::ustring>& paths,
1893 const Glib::RefPtr<Gdk::DragContext>& context,
1894 gint x,
1895 gint y,
1896 const Gtk::SelectionData& data,
1897 guint info,
1898 guint time);
1900 void track_canvas_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context,
1901 gint x,
1902 gint y,
1903 const Gtk::SelectionData& data,
1904 guint info,
1905 guint time);
1907 void region_list_display_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context,
1908 gint x,
1909 gint y,
1910 const Gtk::SelectionData& data,
1911 guint info,
1912 guint time);
1914 void drop_paths (const Glib::RefPtr<Gdk::DragContext>& context,
1915 gint x,
1916 gint y,
1917 const Gtk::SelectionData& data,
1918 guint info,
1919 guint time);
1921 void drop_regions (const Glib::RefPtr<Gdk::DragContext>& context,
1922 gint x,
1923 gint y,
1924 const Gtk::SelectionData& data,
1925 guint info,
1926 guint time);
1928 /* audio export */
1930 ExportDialog *export_dialog;
1931 ExportDialog *export_range_markers_dialog;
1933 void export_range (nframes64_t start, nframes64_t end);
1934 void export_range_markers ();
1936 int write_region_selection(RegionSelection&);
1937 bool write_region (string path, boost::shared_ptr<ARDOUR::AudioRegion>);
1938 void export_region ();
1939 void bounce_region_selection ();
1940 void bounce_range_selection (bool replace, bool enable_processing = true);
1941 void external_edit_region ();
1943 int write_audio_selection (TimeSelection&);
1944 bool write_audio_range (ARDOUR::AudioPlaylist&, uint32_t channels, list<ARDOUR::AudioRange>&);
1946 void write_selection ();
1948 /* history */
1950 UndoAction get_memento() const;
1952 XMLNode *before; /* used in *_reversible_command */
1953 void begin_reversible_command (string cmd_name);
1954 void commit_reversible_command ();
1956 void update_title ();
1957 void update_title_s (const string & snapshot_name);
1959 struct State {
1960 Selection* selection;
1961 double frames_per_unit;
1963 State();
1964 ~State();
1967 void store_state (State&) const;
1968 void restore_state (State *);
1970 void instant_save ();
1972 boost::shared_ptr<ARDOUR::AudioRegion> last_audition_region;
1974 /* freeze operations */
1976 ARDOUR::InterThreadInfo freeze_status;
1977 gint freeze_progress_timeout (void *);
1978 static void* _freeze_thread (void*);
1979 void* freeze_thread ();
1981 void freeze_route ();
1982 void unfreeze_route ();
1984 /* edit-group solo + mute */
1986 void set_edit_group_solo (ARDOUR::Route&, bool);
1987 void set_edit_group_mute (ARDOUR::Route&, bool);
1989 /* duplication */
1991 void duplicate_dialog (bool with_dialog);
1993 nframes64_t event_frame (GdkEvent*, double* px = 0, double* py = 0) const;
1995 /* returns false if mouse pointer is not in track or marker canvas
1997 bool mouse_frame (nframes64_t&, bool& in_track_canvas) const;
1999 void time_fx_motion (ArdourCanvas::Item*, GdkEvent*);
2000 void start_time_fx (ArdourCanvas::Item*, GdkEvent*);
2001 void end_time_fx (ArdourCanvas::Item*, GdkEvent*);
2003 struct TimeFXDialog : public ArdourDialog {
2004 ARDOUR::TimeFXRequest request;
2005 Editor& editor;
2006 bool pitching;
2007 Gtk::Adjustment pitch_octave_adjustment;
2008 Gtk::Adjustment pitch_semitone_adjustment;
2009 Gtk::Adjustment pitch_cent_adjustment;
2010 Gtk::SpinButton pitch_octave_spinner;
2011 Gtk::SpinButton pitch_semitone_spinner;
2012 Gtk::SpinButton pitch_cent_spinner;
2013 RegionSelection regions;
2014 Gtk::ProgressBar progress_bar;
2016 /* SoundTouch */
2017 Gtk::ToggleButton quick_button;
2018 Gtk::ToggleButton antialias_button;
2019 Gtk::HBox upper_button_box;
2021 /* RubberBand */
2022 Gtk::ComboBoxText stretch_opts_selector;
2023 Gtk::Label stretch_opts_label;
2024 Gtk::ToggleButton precise_button;
2025 Gtk::ToggleButton preserve_formants_button;
2026 Gtk::HBox opts_box;
2028 Gtk::Button* cancel_button;
2029 Gtk::Button* action_button;
2030 Gtk::VBox packer;
2031 int status;
2033 TimeFXDialog (Editor& e, bool for_pitch);
2035 gint update_progress ();
2036 sigc::connection first_cancel;
2037 sigc::connection first_delete;
2038 void cancel_in_progress ();
2039 gint delete_in_progress (GdkEventAny*);
2042 /* "whats mine is yours" */
2044 friend class TimeFXDialog;
2046 TimeFXDialog* current_timefx;
2048 static void* timefx_thread (void *arg);
2049 void do_timefx (TimeFXDialog&);
2051 int time_stretch (RegionSelection&, float fraction);
2052 int pitch_shift (RegionSelection&, float cents);
2053 void pitch_shift_regions ();
2054 int time_fx (RegionSelection&, float val, bool pitching);
2056 /* editor-mixer strip */
2058 MixerStrip *current_mixer_strip;
2059 bool show_editor_mixer_when_tracks_arrive;
2060 Gtk::VBox current_mixer_strip_vbox;
2061 void cms_deleted ();
2062 void current_mixer_strip_hidden ();
2063 void current_mixer_strip_removed ();
2065 void detach_tearoff (Gtk::Box* b, Gtk::Window* w);
2066 void reattach_tearoff (Gtk::Box* b, Gtk::Window* w, int32_t n);
2067 #ifdef GTKOSX
2068 void ensure_all_elements_drawn ();
2069 #endif
2070 /* nudging tracks */
2072 void nudge_track (bool use_edit_point, bool forwards);
2074 /* xfades */
2076 bool _xfade_visibility;
2078 /* <CMT Additions> */
2079 void handle_new_imageframe_time_axis_view(const string & track_name, void* src) ;
2080 void handle_new_imageframe_marker_time_axis_view(const string & track_name, TimeAxisView* marked_track) ;
2082 void start_imageframe_grab(ArdourCanvas::Item*, GdkEvent*) ;
2083 void start_markerview_grab(ArdourCanvas::Item*, GdkEvent*) ;
2085 void imageframe_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
2086 void markerview_drag_motion_callback(ArdourCanvas::Item*, GdkEvent*) ;
2087 void timeaxis_item_drag_finished_callback(ArdourCanvas::Item*, GdkEvent*) ;
2089 gint canvas_imageframe_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
2090 gint canvas_imageframe_view_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameTimeAxis* ifta);
2091 gint canvas_imageframe_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
2092 gint canvas_imageframe_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, ImageFrameView* ifv);
2094 gint canvas_marker_time_axis_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerTimeAxis* mta);
2095 gint canvas_markerview_item_view_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
2096 gint canvas_markerview_start_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
2097 gint canvas_markerview_end_handle_event(ArdourCanvas::Item* item, GdkEvent* event, MarkerView* mv);
2099 void imageframe_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2100 void imageframe_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2101 void imageframe_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2102 void imageframe_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2103 void imageframe_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2104 void imageframe_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2106 void markerview_item_start_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2107 void markerview_item_end_handle_op(ArdourCanvas::Item* item, GdkEvent* event) ;
2108 void markerview_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2109 void markerview_start_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2110 void markerview_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* event) ;
2111 void markerview_end_handle_end_trim(ArdourCanvas::Item* item, GdkEvent* event) ;
2113 void popup_imageframe_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
2114 void popup_marker_time_axis_edit_menu(int button, int32_t time, ArdourCanvas::Item* ifv, bool with_frame) ;
2116 ImageFrameSocketHandler* image_socket_listener ;
2117 /* </CMT Additions> */
2119 void toggle_xfade_active (boost::weak_ptr<ARDOUR::Crossfade>);
2120 void toggle_xfade_length (boost::weak_ptr<ARDOUR::Crossfade>);
2121 void edit_xfade (boost::weak_ptr<ARDOUR::Crossfade>);
2122 void xfade_edit_left_region ();
2123 void xfade_edit_right_region ();
2125 static const int32_t default_width = 995;
2126 static const int32_t default_height = 765;
2128 /* nudge */
2130 Gtk::Button nudge_forward_button;
2131 Gtk::Button nudge_backward_button;
2132 Gtk::HBox nudge_hbox;
2133 Gtk::VBox nudge_vbox;
2134 AudioClock nudge_clock;
2136 nframes64_t get_nudge_distance (nframes64_t pos, nframes64_t& next);
2138 bool nudge_forward_release (GdkEventButton*);
2139 bool nudge_backward_release (GdkEventButton*);
2141 /* audio filters */
2143 void apply_filter (ARDOUR::AudioFilter&, string cmd);
2145 /* handling cleanup */
2147 int playlist_deletion_dialog (boost::shared_ptr<ARDOUR::Playlist>);
2149 vector<sigc::connection> session_connections;
2151 /* tracking step changes of track height */
2153 TimeAxisView* current_stepping_trackview;
2154 ARDOUR::microseconds_t last_track_height_step_timestamp;
2155 gint track_height_step_timeout();
2156 sigc::connection step_timeout;
2158 TimeAxisView* entered_track;
2159 RegionView* entered_regionview;
2162 void ensure_entered_track_selected (bool op_acts_on_objects = false);
2163 bool clear_entered_track;
2164 bool left_track_canvas (GdkEventCrossing*);
2165 bool entered_track_canvas (GdkEventCrossing*);
2166 void set_entered_track (TimeAxisView*);
2167 void set_entered_regionview (RegionView*);
2168 void ensure_track_visible (TimeAxisView*);
2169 gint left_automation_track ();
2171 bool _new_regionviews_show_envelope;
2173 void reset_canvas_action_sensitivity (bool);
2174 void toggle_gain_envelope_visibility ();
2175 void toggle_gain_envelope_active ();
2176 void reset_region_gain_envelopes ();
2178 bool on_key_press_event (GdkEventKey*);
2179 bool on_key_release_event (GdkEventKey*);
2181 void session_state_saved (string);
2183 Glib::RefPtr<Gtk::Action> undo_action;
2184 Glib::RefPtr<Gtk::Action> redo_action;
2186 void history_changed ();
2187 void color_handler ();
2189 Gtk::HBox status_bar_hpacker;
2191 Editing::EditPoint _edit_point;
2193 Gtk::ComboBoxText edit_point_selector;
2195 void set_edit_point_preference (Editing::EditPoint ep, bool force = false);
2196 void cycle_edit_point (bool with_marker);
2197 void set_edit_point ();
2198 void edit_point_selection_done ();
2199 void edit_point_chosen (Editing::EditPoint);
2200 Glib::RefPtr<Gtk::RadioAction> edit_point_action (Editing::EditPoint);
2201 std::vector<std::string> edit_point_strings;
2203 void selected_marker_moved (ARDOUR::Location*);
2204 sigc::connection edit_point_clock_connection_a;
2205 sigc::connection edit_point_clock_connection_b;
2207 bool get_edit_op_range (nframes64_t& start, nframes64_t& end) const;
2209 void get_regions_at (RegionSelection&, nframes64_t where, const TrackSelection& ts) const;
2210 void get_regions_after (RegionSelection&, nframes64_t where, const TrackSelection& ts) const;
2212 void get_regions_for_action (RegionSelection&, bool allowed_entered_regionview = false);
2214 sigc::connection fast_screen_update_connection;
2215 gint start_updating ();
2216 gint stop_updating ();
2217 void fast_update_strips ();
2218 bool meters_running;
2220 void select_next_route ();
2221 void select_prev_route ();
2223 void snap_to_internal (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
2225 RhythmFerret* rhythm_ferret;
2227 void fit_tracks ();
2228 void set_track_height (uint32_t h);
2229 void set_track_height_largest ();
2230 void set_track_height_large ();
2231 void set_track_height_larger ();
2232 void set_track_height_normal ();
2233 void set_track_height_smaller ();
2234 void set_track_height_small ();
2236 void remove_tracks ();
2237 void toggle_tracks_active ();
2239 bool _have_idled;
2240 int resize_idle_id;
2241 int32_t resize_idle_target;
2242 bool idle_resize();
2243 friend gboolean _idle_resize (gpointer);
2244 std::vector<TimeAxisView*> pending_resizes;
2246 RegionLayeringOrderEditor* layering_order_editor;
2248 void update_region_layering_order_editor (nframes64_t frame);
2251 #endif /* __ardour_editor_h__ */