2 Copyright (C) 2000-2009 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 /* Note: public Editor methods are documented in public_editor.h */
22 #define __STDC_LIMIT_MACROS 1
31 #include <boost/none.hpp>
33 #include <sigc++/bind.h>
35 #include "pbd/convert.h"
36 #include "pbd/error.h"
37 #include "pbd/enumwriter.h"
38 #include "pbd/memento_command.h"
39 #include "pbd/unknown_type.h"
41 #include <glibmm/miscutils.h>
42 #include <gtkmm/image.h>
43 #include <gdkmm/color.h>
44 #include <gdkmm/bitmap.h>
46 #include <gtkmm2ext/grouped_buttons.h>
47 #include <gtkmm2ext/gtk_ui.h>
48 #include <gtkmm2ext/tearoff.h>
49 #include <gtkmm2ext/utils.h>
50 #include <gtkmm2ext/window_title.h>
51 #include <gtkmm2ext/choice.h>
52 #include <gtkmm2ext/cell_renderer_pixbuf_toggle.h>
54 #include "ardour/audio_diskstream.h"
55 #include "ardour/audio_track.h"
56 #include "ardour/audioplaylist.h"
57 #include "ardour/audioregion.h"
58 #include "ardour/location.h"
59 #include "ardour/midi_region.h"
60 #include "ardour/plugin_manager.h"
61 #include "ardour/profile.h"
62 #include "ardour/route_group.h"
63 #include "ardour/session_directory.h"
64 #include "ardour/session_route.h"
65 #include "ardour/session_state_utils.h"
66 #include "ardour/tempo.h"
67 #include "ardour/utils.h"
68 #include "ardour/session_playlists.h"
70 #include "control_protocol/control_protocol.h"
72 #include "ardour_ui.h"
76 #include "playlist_selector.h"
77 #include "audio_region_view.h"
78 #include "rgb_macros.h"
79 #include "selection.h"
80 #include "audio_streamview.h"
81 #include "time_axis_view.h"
82 #include "audio_time_axis.h"
84 #include "crossfade_view.h"
85 #include "canvas-noevent-text.h"
87 #include "public_editor.h"
88 #include "crossfade_edit.h"
89 #include "canvas_impl.h"
92 #include "gui_thread.h"
93 #include "simpleline.h"
94 #include "rhythm_ferret.h"
96 #include "tempo_lines.h"
97 #include "analysis_window.h"
98 #include "bundle_manager.h"
99 #include "global_port_matrix.h"
100 #include "editor_drag.h"
101 #include "editor_group_tabs.h"
102 #include "automation_time_axis.h"
103 #include "editor_routes.h"
104 #include "midi_time_axis.h"
105 #include "mixer_strip.h"
106 #include "editor_route_groups.h"
107 #include "editor_regions.h"
108 #include "editor_locations.h"
109 #include "editor_snapshots.h"
114 #include "imageframe_socket_handler.h"
118 using namespace sigc;
119 using namespace ARDOUR;
122 using namespace Glib;
123 using namespace Gtkmm2ext;
124 using namespace Editing;
126 using PBD::internationalize;
129 const double Editor::timebar_height = 15.0;
131 #include "editor_xpms"
133 static const gchar *_snap_type_strings[] = {
135 N_("Timecode Frames"),
136 N_("Timecode Seconds"),
137 N_("Timecode Minutes"),
155 static const gchar *_snap_mode_strings[] = {
162 static const gchar *_edit_point_strings[] = {
169 static const gchar *_zoom_focus_strings[] = {
179 #ifdef USE_RUBBERBAND
180 static const gchar *_rb_opt_strings[] = {
183 N_("Balanced multitimbral mixture"),
184 N_("Unpitched percussion with stable notes"),
185 N_("Crisp monophonic instrumental"),
186 N_("Unpitched solo percussion"),
191 /* Soundfile drag-n-drop */
193 Gdk::Cursor* Editor::cross_hair_cursor = 0;
194 Gdk::Cursor* Editor::selector_cursor = 0;
195 Gdk::Cursor* Editor::trimmer_cursor = 0;
196 Gdk::Cursor* Editor::grabber_cursor = 0;
197 Gdk::Cursor* Editor::grabber_edit_point_cursor = 0;
198 Gdk::Cursor* Editor::zoom_cursor = 0;
199 Gdk::Cursor* Editor::time_fx_cursor = 0;
200 Gdk::Cursor* Editor::fader_cursor = 0;
201 Gdk::Cursor* Editor::speaker_cursor = 0;
202 Gdk::Cursor* Editor::midi_pencil_cursor = 0;
203 Gdk::Cursor* Editor::midi_select_cursor = 0;
204 Gdk::Cursor* Editor::midi_resize_cursor = 0;
205 Gdk::Cursor* Editor::midi_erase_cursor = 0;
206 Gdk::Cursor* Editor::wait_cursor = 0;
207 Gdk::Cursor* Editor::timebar_cursor = 0;
208 Gdk::Cursor* Editor::transparent_cursor = 0;
211 show_me_the_size (Requisition* r, const char* what)
213 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
217 /* time display buttons */
218 : minsec_label (_("Mins:Secs"))
219 , bbt_label (_("Bars:Beats"))
220 , timecode_label (_("Timecode"))
221 , frame_label (_("Samples"))
222 , tempo_label (_("Tempo"))
223 , meter_label (_("Meter"))
224 , mark_label (_("Location Markers"))
225 , range_mark_label (_("Range Markers"))
226 , transport_mark_label (_("Loop/Punch Ranges"))
227 , cd_mark_label (_("CD Markers"))
228 , edit_packer (4, 4, true)
230 /* the values here don't matter: layout widgets
231 reset them as needed.
234 , vertical_adjustment (0.0, 0.0, 10.0, 400.0)
235 , horizontal_adjustment (0.0, 0.0, 20.0, 1200.0)
237 /* tool bar related */
239 , zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, false, true)
241 , toolbar_selection_clock_table (2,3)
243 , automation_mode_button (_("mode"))
244 , global_automation_button (_("automation"))
246 , midi_panic_button (_("Panic"))
249 , image_socket_listener(0)
254 , nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, false, true)
255 , meters_running(false)
256 , _pending_locate_request (false)
261 /* we are a singleton */
263 PublicEditor::_instance = this;
268 selection = new Selection (this);
269 cut_buffer = new Selection (this);
271 clicked_regionview = 0;
272 clicked_axisview = 0;
273 clicked_routeview = 0;
274 clicked_crossfadeview = 0;
275 clicked_control_point = 0;
276 last_update_frame = 0;
278 current_mixer_strip = 0;
279 current_bbt_points = 0;
282 snap_type_strings = I18N (_snap_type_strings);
283 snap_mode_strings = I18N (_snap_mode_strings);
284 zoom_focus_strings = I18N (_zoom_focus_strings);
285 edit_point_strings = I18N (_edit_point_strings);
286 #ifdef USE_RUBBERBAND
287 rb_opt_strings = I18N (_rb_opt_strings);
290 snap_threshold = 5.0;
291 bbt_beat_subdivision = 4;
294 last_autoscroll_x = 0;
295 last_autoscroll_y = 0;
296 autoscroll_active = false;
297 autoscroll_timeout_tag = -1;
298 interthread_progress_window = 0;
303 current_interthread_info = 0;
304 _show_measures = true;
305 _show_waveforms_recording = true;
306 show_gain_after_trim = false;
307 verbose_cursor_on = true;
308 route_removal = false;
309 last_item_entered = 0;
310 last_item_entered_n = 0;
312 have_pending_keyboard_selection = false;
313 _follow_playhead = true;
314 _xfade_visibility = true;
315 editor_ruler_menu = 0;
316 no_ruler_shown_update = false;
318 start_end_marker_menu = 0;
319 range_marker_menu = 0;
320 marker_menu_item = 0;
322 transport_marker_menu = 0;
323 new_transport_marker_menu = 0;
324 editor_mixer_strip_width = Wide;
325 show_editor_mixer_when_tracks_arrive = false;
326 region_edit_menu_split_multichannel_item = 0;
327 region_edit_menu_split_item = 0;
330 current_stepping_trackview = 0;
332 entered_regionview = 0;
334 clear_entered_track = false;
335 _new_regionviews_show_envelope = false;
338 button_release_can_deselect = true;
339 _dragging_playhead = false;
340 _dragging_edit_point = false;
341 select_new_marker = false;
344 for (ARDOUR::DataType::iterator i = ARDOUR::DataType::begin(); i != ARDOUR::DataType::end(); ++i) {
345 _global_port_matrix[*i] = 0;
347 allow_vertical_scroll = false;
348 no_save_visual = false;
351 scrubbing_direction = 0;
355 location_marker_color = ARDOUR_UI::config()->canvasvar_LocationMarker.get();
356 location_range_color = ARDOUR_UI::config()->canvasvar_LocationRange.get();
357 location_cd_marker_color = ARDOUR_UI::config()->canvasvar_LocationCDMarker.get();
358 location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
359 location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
361 _edit_point = EditAtMouse;
362 _internal_editing = false;
363 current_canvas_cursor = 0;
365 frames_per_unit = 2048; /* too early to use reset_zoom () */
367 zoom_focus = ZoomFocusLeft;
368 set_zoom_focus (ZoomFocusLeft);
369 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
371 bbt_label.set_name ("EditorTimeButton");
372 bbt_label.set_size_request (-1, (int)timebar_height);
373 bbt_label.set_alignment (1.0, 0.5);
374 bbt_label.set_padding (5,0);
376 bbt_label.set_no_show_all();
377 minsec_label.set_name ("EditorTimeButton");
378 minsec_label.set_size_request (-1, (int)timebar_height);
379 minsec_label.set_alignment (1.0, 0.5);
380 minsec_label.set_padding (5,0);
381 minsec_label.hide ();
382 minsec_label.set_no_show_all();
383 timecode_label.set_name ("EditorTimeButton");
384 timecode_label.set_size_request (-1, (int)timebar_height);
385 timecode_label.set_alignment (1.0, 0.5);
386 timecode_label.set_padding (5,0);
387 timecode_label.hide ();
388 timecode_label.set_no_show_all();
389 frame_label.set_name ("EditorTimeButton");
390 frame_label.set_size_request (-1, (int)timebar_height);
391 frame_label.set_alignment (1.0, 0.5);
392 frame_label.set_padding (5,0);
394 frame_label.set_no_show_all();
396 tempo_label.set_name ("EditorTimeButton");
397 tempo_label.set_size_request (-1, (int)timebar_height);
398 tempo_label.set_alignment (1.0, 0.5);
399 tempo_label.set_padding (5,0);
401 tempo_label.set_no_show_all();
402 meter_label.set_name ("EditorTimeButton");
403 meter_label.set_size_request (-1, (int)timebar_height);
404 meter_label.set_alignment (1.0, 0.5);
405 meter_label.set_padding (5,0);
407 meter_label.set_no_show_all();
408 mark_label.set_name ("EditorTimeButton");
409 mark_label.set_size_request (-1, (int)timebar_height);
410 mark_label.set_alignment (1.0, 0.5);
411 mark_label.set_padding (5,0);
413 mark_label.set_no_show_all();
414 cd_mark_label.set_name ("EditorTimeButton");
415 cd_mark_label.set_size_request (-1, (int)timebar_height);
416 cd_mark_label.set_alignment (1.0, 0.5);
417 cd_mark_label.set_padding (5,0);
418 cd_mark_label.hide();
419 cd_mark_label.set_no_show_all();
420 range_mark_label.set_name ("EditorTimeButton");
421 range_mark_label.set_size_request (-1, (int)timebar_height);
422 range_mark_label.set_alignment (1.0, 0.5);
423 range_mark_label.set_padding (5,0);
424 range_mark_label.hide();
425 range_mark_label.set_no_show_all();
426 transport_mark_label.set_name ("EditorTimeButton");
427 transport_mark_label.set_size_request (-1, (int)timebar_height);
428 transport_mark_label.set_alignment (1.0, 0.5);
429 transport_mark_label.set_padding (5,0);
430 transport_mark_label.hide();
431 transport_mark_label.set_no_show_all();
433 initialize_rulers ();
434 _summary = new EditorSummary (this);
435 initialize_canvas ();
437 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
438 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
439 editor_regions_selection_changed_connection = selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
440 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
441 selection->MarkersChanged.connect (mem_fun(*this, &Editor::marker_selection_changed));
443 edit_controls_vbox.set_spacing (0);
444 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::scroll_canvas_horizontally), false);
445 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling), true);
446 track_canvas->signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
448 HBox* h = manage (new HBox);
449 _group_tabs = new EditorGroupTabs (this);
450 h->pack_start (*_group_tabs, PACK_SHRINK);
451 h->pack_start (edit_controls_vbox);
452 controls_layout.add (*h);
454 ARDOUR_UI::instance()->tooltips().set_tip (*_group_tabs, _("Groups: context-click for possible operations"));
456 controls_layout.set_name ("EditControlsBase");
457 controls_layout.add_events (Gdk::SCROLL_MASK);
458 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
460 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
461 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
462 controls_layout_size_request_connection = controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
466 ArdourCanvas::Canvas* time_pad = manage(new ArdourCanvas::Canvas());
467 ArdourCanvas::SimpleLine* pad_line_1 = manage(new ArdourCanvas::SimpleLine(*time_pad->root(),
468 0.0, 1.0, 100.0, 1.0));
469 pad_line_1->property_color_rgba() = 0xFF0000FF;
473 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars) + 2);
474 time_canvas_vbox.set_size_request (-1, -1);
476 ruler_label_event_box.add (ruler_label_vbox);
477 ruler_label_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
478 ruler_label_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
480 time_button_event_box.add (time_button_vbox);
481 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
482 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
484 /* these enable us to have a dedicated window (for cursor setting, etc.)
485 for the canvas areas.
488 track_canvas_event_box.add (*track_canvas);
490 time_canvas_event_box.add (time_canvas_vbox);
491 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
493 edit_packer.set_col_spacings (0);
494 edit_packer.set_row_spacings (0);
495 edit_packer.set_homogeneous (false);
496 edit_packer.set_border_width (0);
497 edit_packer.set_name ("EditorWindow");
499 edit_packer.attach (zoom_vbox, 0, 1, 0, 2, SHRINK, FILL, 0, 0);
500 /* labels for the rulers */
501 edit_packer.attach (ruler_label_event_box, 1, 2, 0, 1, FILL, SHRINK, 0, 0);
502 /* labels for the marker "tracks" */
503 edit_packer.attach (time_button_event_box, 1, 2, 1, 2, FILL, SHRINK, 0, 0);
505 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
507 edit_packer.attach (controls_layout, 0, 2, 2, 3, FILL, FILL|EXPAND, 0, 0);
509 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 3, FILL|EXPAND, FILL|EXPAND, 0, 0);
511 bottom_hbox.set_border_width (2);
512 bottom_hbox.set_spacing (3);
514 _route_groups = new EditorRouteGroups (this);
515 _routes = new EditorRoutes (this);
516 _regions = new EditorRegions (this);
517 _snapshots = new EditorSnapshots (this);
518 _locations = new EditorLocations (this);
522 nlabel = manage (new Label (_("Regions")));
523 nlabel->set_angle (-90);
524 the_notebook.append_page (_regions->widget (), *nlabel);
525 nlabel = manage (new Label (_("Tracks/Busses")));
526 nlabel->set_angle (-90);
527 the_notebook.append_page (_routes->widget (), *nlabel);
528 nlabel = manage (new Label (_("Snapshots")));
529 nlabel->set_angle (-90);
530 the_notebook.append_page (_snapshots->widget (), *nlabel);
531 nlabel = manage (new Label (_("Route Groups")));
532 nlabel->set_angle (-90);
533 the_notebook.append_page (_route_groups->widget (), *nlabel);
534 nlabel = manage (new Label (_("Ranges & Marks")));
535 nlabel->set_angle (-90);
536 the_notebook.append_page (_locations->widget (), *nlabel);
538 the_notebook.set_show_tabs (true);
539 the_notebook.set_scrollable (true);
540 the_notebook.popup_disable ();
541 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
542 the_notebook.show_all ();
544 post_maximal_editor_width = 0;
545 post_maximal_pane_position = 0;
547 VPaned *editor_summary_pane = manage(new VPaned());
548 editor_summary_pane->pack1(edit_packer);
550 Button* summary_arrows_left_left = manage (new Button);
551 summary_arrows_left_left->add (*manage (new Arrow (ARROW_LEFT, SHADOW_NONE)));
552 summary_arrows_left_left->signal_clicked().connect (mem_fun (*this, &Editor::horizontal_scroll_left));
553 Button* summary_arrows_left_right = manage (new Button);
554 summary_arrows_left_right->add (*manage (new Arrow (ARROW_RIGHT, SHADOW_NONE)));
555 summary_arrows_left_right->signal_clicked().connect (mem_fun (*this, &Editor::horizontal_scroll_right));
556 VBox* summary_arrows_left = manage (new VBox);
557 summary_arrows_left->pack_start (*summary_arrows_left_left);
558 summary_arrows_left->pack_start (*summary_arrows_left_right);
560 Button* summary_arrows_right_left = manage (new Button);
561 summary_arrows_right_left->add (*manage (new Arrow (ARROW_LEFT, SHADOW_NONE)));
562 summary_arrows_right_left->signal_clicked().connect (mem_fun (*this, &Editor::horizontal_scroll_left));
563 Button* summary_arrows_right_right = manage (new Button);
564 summary_arrows_right_right->add (*manage (new Arrow (ARROW_RIGHT, SHADOW_NONE)));
565 summary_arrows_right_right->signal_clicked().connect (mem_fun (*this, &Editor::horizontal_scroll_right));
566 VBox* summary_arrows_right = manage (new VBox);
567 summary_arrows_right->pack_start (*summary_arrows_right_left);
568 summary_arrows_right->pack_start (*summary_arrows_right_right);
570 Frame* summary_frame = manage (new Frame);
571 summary_frame->set_shadow_type (Gtk::SHADOW_ETCHED_IN);
572 summary_frame->add (*_summary);
573 summary_frame->show ();
575 HBox* summary_hbox = manage (new HBox);
576 summary_hbox->pack_start (*summary_arrows_left, false, false);
577 summary_hbox->pack_start (*summary_frame, true, true);
578 summary_hbox->pack_start (*summary_arrows_right, false, false);
580 editor_summary_pane->pack2(*summary_hbox);
582 edit_pane.pack1 (*editor_summary_pane, true, true);
583 edit_pane.pack2 (the_notebook, false, true);
585 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
587 top_hbox.pack_start (toolbar_frame, false, true);
589 HBox *hbox = manage (new HBox);
590 hbox->pack_start (edit_pane, true, true);
592 global_vpacker.pack_start (top_hbox, false, false);
593 global_vpacker.pack_start (*hbox, true, true);
595 global_hpacker.pack_start (global_vpacker, true, true);
597 set_name ("EditorWindow");
598 add_accel_group (ActionManager::ui_manager->get_accel_group());
600 status_bar_hpacker.show ();
602 vpacker.pack_end (status_bar_hpacker, false, false);
603 vpacker.pack_end (global_hpacker, true, true);
605 /* register actions now so that set_state() can find them and set toggles/checks etc */
610 setup_midi_toolbar ();
612 _snap_type = SnapToBeat;
613 set_snap_to (_snap_type);
614 _snap_mode = SnapOff;
615 set_snap_mode (_snap_mode);
616 set_mouse_mode (MouseObject, true);
617 set_edit_point_preference (EditAtMouse, true);
619 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
620 set_state (*node, Stateful::loading_state_version);
622 _playlist_selector = new PlaylistSelector();
623 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
625 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
629 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
630 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
632 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
633 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
635 nudge_forward_button.set_name ("TransportButton");
636 nudge_backward_button.set_name ("TransportButton");
638 fade_context_menu.set_name ("ArdourContextMenu");
640 /* icons, titles, WM stuff */
642 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
643 Glib::RefPtr<Gdk::Pixbuf> icon;
645 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
646 window_icons.push_back (icon);
648 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
649 window_icons.push_back (icon);
651 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
652 window_icons.push_back (icon);
654 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
655 window_icons.push_back (icon);
657 if (!window_icons.empty()) {
658 set_icon_list (window_icons);
659 set_default_icon_list (window_icons);
662 WindowTitle title(Glib::get_application_name());
663 title += _("Editor");
664 set_title (title.get_string());
665 set_wmclass (X_("ardour_editor"), "Ardour");
668 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
670 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
671 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
673 /* allow external control surfaces/protocols to do various things */
675 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
676 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
677 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
678 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
679 BasicUI::AccessAction.connect (mem_fun (*this, &Editor::access_action));
681 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
683 _last_normalization_value = 0;
692 if(image_socket_listener) {
693 if(image_socket_listener->is_connected())
695 image_socket_listener->close_connection() ;
698 delete image_socket_listener ;
699 image_socket_listener = 0 ;
704 delete _route_groups;
710 Editor::add_toplevel_controls (Container& cont)
712 vpacker.pack_start (cont, false, false);
717 Editor::catch_vanishing_regionview (RegionView *rv)
719 /* note: the selection will take care of the vanishing
720 audioregionview by itself.
723 if (_drag && rv->get_canvas_group() == _drag->item() && !_drag->ending()) {
729 if (clicked_regionview == rv) {
730 clicked_regionview = 0;
733 if (entered_regionview == rv) {
734 set_entered_regionview (0);
739 Editor::set_entered_regionview (RegionView* rv)
741 if (rv == entered_regionview) {
745 if (entered_regionview) {
746 entered_regionview->exited ();
749 if ((entered_regionview = rv) != 0) {
750 entered_regionview->entered ();
755 Editor::set_entered_track (TimeAxisView* tav)
758 entered_track->exited ();
761 if ((entered_track = tav) != 0) {
762 entered_track->entered ();
767 Editor::show_window ()
769 if (! is_visible ()) {
772 /* re-hide editor list if necessary */
773 editor_list_button_toggled ();
775 /* re-hide summary widget if necessary */
776 parameter_changed ("show-summary");
778 parameter_changed ("show-edit-group-tabs");
780 /* now reset all audio_time_axis heights, because widgets might need
786 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
787 tv = (static_cast<TimeAxisView*>(*i));
796 Editor::instant_save ()
798 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
803 session->add_instant_xml(get_state());
805 Config->add_instant_xml(get_state());
810 Editor::zoom_adjustment_changed ()
816 double fpu = zoom_range_clock.current_duration() / _canvas_width;
820 zoom_range_clock.set ((nframes64_t) floor (fpu * _canvas_width));
821 } else if (fpu > session->current_end_frame() / _canvas_width) {
822 fpu = session->current_end_frame() / _canvas_width;
823 zoom_range_clock.set ((nframes64_t) floor (fpu * _canvas_width));
830 Editor::control_scroll (float fraction)
832 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
838 double step = fraction * current_page_frames();
841 _control_scroll_target is an optional<T>
843 it acts like a pointer to an nframes64_t, with
844 a operator conversion to boolean to check
845 that it has a value could possibly use
846 playhead_cursor->current_frame to store the
847 value and a boolean in the class to know
848 when it's out of date
851 if (!_control_scroll_target) {
852 _control_scroll_target = session->transport_frame();
853 _dragging_playhead = true;
856 if ((fraction < 0.0f) && (*_control_scroll_target < (nframes64_t) fabs(step))) {
857 *_control_scroll_target = 0;
858 } else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
859 *_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
861 *_control_scroll_target += (nframes64_t) floor (step);
864 /* move visuals, we'll catch up with it later */
866 playhead_cursor->set_position (*_control_scroll_target);
867 UpdateAllTransportClocks (*_control_scroll_target);
869 if (*_control_scroll_target > (current_page_frames() / 2)) {
870 /* try to center PH in window */
871 reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
877 Now we do a timeout to actually bring the session to the right place
878 according to the playhead. This is to avoid reading disk buffers on every
879 call to control_scroll, which is driven by ScrollTimeline and therefore
880 probably by a control surface wheel which can generate lots of events.
882 /* cancel the existing timeout */
884 control_scroll_connection.disconnect ();
886 /* add the next timeout */
888 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), *_control_scroll_target), 250);
892 Editor::deferred_control_scroll (nframes64_t /*target*/)
894 session->request_locate (*_control_scroll_target, session->transport_rolling());
895 // reset for next stream
896 _control_scroll_target = boost::none;
897 _dragging_playhead = false;
902 Editor::access_action (std::string action_group, std::string action_item)
908 ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::access_action), action_group, action_item));
911 act = ActionManager::get_action( action_group.c_str(), action_item.c_str() );
921 Editor::on_realize ()
923 Window::on_realize ();
928 Editor::start_scrolling ()
930 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
931 (mem_fun(*this, &Editor::update_current_screen));
936 Editor::stop_scrolling ()
938 scroll_connection.disconnect ();
942 Editor::map_position_change (nframes64_t frame)
944 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
946 if (session == 0 || !_follow_playhead) {
950 center_screen (frame);
951 playhead_cursor->set_position (frame);
955 Editor::center_screen (nframes64_t frame)
957 double page = _canvas_width * frames_per_unit;
959 /* if we're off the page, then scroll.
962 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
963 center_screen_internal (frame, page);
968 Editor::center_screen_internal (nframes64_t frame, float page)
973 frame -= (nframes64_t) page;
978 reset_x_origin (frame);
982 Editor::handle_new_duration ()
988 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
989 nframes64_t new_end = session->current_end_frame() + (nframes64_t) floorf (current_page_frames() * 0.10f);
991 horizontal_adjustment.set_upper (new_end / frames_per_unit);
992 horizontal_adjustment.set_page_size (current_page_frames()/frames_per_unit);
994 if (horizontal_adjustment.get_value() + _canvas_width > horizontal_adjustment.get_upper()) {
995 horizontal_adjustment.set_value (horizontal_adjustment.get_upper() - _canvas_width);
997 //cerr << "Editor::handle_new_duration () called ha v:l:u:ps:lcf = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << endl;//DEBUG
1001 Editor::update_title_s (const string & snap_name)
1003 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1009 Editor::update_title ()
1011 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1014 bool dirty = session->dirty();
1016 string session_name;
1018 if (session->snap_name() != session->name()) {
1019 session_name = session->snap_name();
1021 session_name = session->name();
1025 session_name = "*" + session_name;
1028 WindowTitle title(session_name);
1029 title += Glib::get_application_name();
1030 set_title (title.get_string());
1035 Editor::connect_to_session (Session *t)
1039 compute_fixed_ruler_scale ();
1041 /* there are never any selected regions at startup */
1043 sensitize_the_right_region_actions (false);
1045 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1046 set_state (*node, Stateful::loading_state_version);
1048 /* catch up with the playhead */
1050 session->request_locate (playhead_cursor->current_frame);
1054 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1055 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1057 /* These signals can all be emitted by a non-GUI thread. Therefore the
1058 handlers for them must not attempt to directly interact with the GUI,
1059 but use Gtkmm2ext::UI::instance()->call_slot();
1062 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1063 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1064 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1065 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1066 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1067 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1068 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1070 session_connections.push_back (session->TimecodeOffsetChanged.connect (mem_fun(*this, &Editor::update_just_timecode)));
1072 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1074 session_connections.push_back (session->Located.connect (mem_fun (*this, &Editor::located)));
1075 session_connections.push_back (session->config.ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed)));
1077 zoom_range_clock.set_session (session);
1078 _playlist_selector->set_session (session);
1079 nudge_clock.set_session (session);
1080 if (Profile->get_sae()) {
1085 nframes_t pos = session->tempo_map().bbt_duration_at (0, bbt, 1);
1086 nudge_clock.set_mode(AudioClock::BBT);
1087 nudge_clock.set (pos, true, 0, AudioClock::BBT);
1090 nudge_clock.set (session->frame_rate() * 5, true, 0, AudioClock::Timecode); // default of 5 seconds
1093 playhead_cursor->canvas_item.show ();
1095 if (rhythm_ferret) {
1096 rhythm_ferret->set_session (session);
1099 if (analysis_window != 0)
1100 analysis_window->set_session (session);
1102 Location* loc = session->locations()->auto_loop_location();
1104 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1105 if (loc->start() == loc->end()) {
1106 loc->set_end (loc->start() + 1);
1108 session->locations()->add (loc, false);
1109 session->set_auto_loop_location (loc);
1112 loc->set_name (_("Loop"));
1115 loc = session->locations()->auto_punch_location();
1117 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1118 if (loc->start() == loc->end()) {
1119 loc->set_end (loc->start() + 1);
1121 session->locations()->add (loc, false);
1122 session->set_auto_punch_location (loc);
1125 loc->set_name (_("Punch"));
1128 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1129 session->config.map_parameters (mem_fun (*this, &Editor::parameter_changed));
1131 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1133 refresh_location_display ();
1134 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1135 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1136 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1137 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1138 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1141 sfbrowser->set_session (session);
1144 handle_new_duration ();
1146 restore_ruler_visibility ();
1147 //tempo_map_changed (Change (0));
1148 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1150 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1151 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1156 switch (_snap_type) {
1157 case SnapToRegionStart:
1158 case SnapToRegionEnd:
1159 case SnapToRegionSync:
1160 case SnapToRegionBoundary:
1161 build_region_boundary_cache ();
1168 /* register for undo history */
1169 session->register_with_memento_command_factory(_id, this);
1171 _summary->connect_to_session (session);
1172 _group_tabs->connect_to_session (session);
1173 _route_groups->connect_to_session (session);
1174 _regions->connect_to_session (session);
1175 _snapshots->connect_to_session (session);
1176 _routes->connect_to_session (session);
1177 _locations->connect_to_session (session);
1183 Editor::build_cursors ()
1185 using namespace Gdk;
1187 Gdk::Color mbg ("#000000" ); /* Black */
1188 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1191 RefPtr<Bitmap> source, mask;
1192 source = Bitmap::create (mag_bits, mag_width, mag_height);
1193 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1194 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1197 Gdk::Color fbg ("#ffffff" );
1198 Gdk::Color ffg ("#000000" );
1201 RefPtr<Bitmap> source, mask;
1203 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1204 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1205 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1209 RefPtr<Bitmap> source, mask;
1210 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1211 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1212 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1216 RefPtr<Bitmap> bits;
1217 char pix[4] = { 0, 0, 0, 0 };
1218 bits = Bitmap::create (pix, 2, 2);
1220 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1224 RefPtr<Bitmap> bits;
1225 char pix[4] = { 0, 0, 0, 0 };
1226 bits = Bitmap::create (pix, 2, 2);
1228 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1232 grabber_cursor = new Gdk::Cursor (HAND2);
1235 Glib::RefPtr<Gdk::Pixbuf> grabber_edit_point_pixbuf (::get_icon ("grabber_edit_point"));
1236 grabber_edit_point_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_edit_point_pixbuf, 5, 17);
1239 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1240 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1241 selector_cursor = new Gdk::Cursor (XTERM);
1242 time_fx_cursor = new Gdk::Cursor (SIZING);
1243 wait_cursor = new Gdk::Cursor (WATCH);
1244 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1245 midi_pencil_cursor = new Gdk::Cursor (PENCIL);
1246 midi_select_cursor = new Gdk::Cursor (CENTER_PTR);
1247 midi_resize_cursor = new Gdk::Cursor (SIZING);
1248 midi_erase_cursor = new Gdk::Cursor (DRAPED_BOX);
1251 /** Pop up a context menu for when the user clicks on a fade in or fade out */
1253 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1255 using namespace Menu_Helpers;
1256 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1259 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1263 MenuList& items (fade_context_menu.items());
1267 switch (item_type) {
1269 case FadeInHandleItem:
1270 if (arv->audio_region()->fade_in_active()) {
1271 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_in_active), false)));
1273 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_in_active), true)));
1276 items.push_back (SeparatorElem());
1278 if (Profile->get_sae()) {
1279 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1280 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1282 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1283 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1284 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
1285 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
1286 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
1292 case FadeOutHandleItem:
1293 if (arv->audio_region()->fade_out_active()) {
1294 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_out_active), false)));
1296 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_out_active), true)));
1299 items.push_back (SeparatorElem());
1301 if (Profile->get_sae()) {
1302 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1303 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1305 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1306 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1307 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
1308 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
1309 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
1315 fatal << _("programming error: ")
1316 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1321 fade_context_menu.popup (button, time);
1325 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes64_t frame)
1327 using namespace Menu_Helpers;
1328 Menu* (Editor::*build_menu_function)(nframes64_t);
1331 switch (item_type) {
1333 case RegionViewName:
1334 case RegionViewNameHighlight:
1335 if (with_selection) {
1336 build_menu_function = &Editor::build_track_selection_context_menu;
1338 build_menu_function = &Editor::build_track_region_context_menu;
1343 if (with_selection) {
1344 build_menu_function = &Editor::build_track_selection_context_menu;
1346 build_menu_function = &Editor::build_track_context_menu;
1350 case CrossfadeViewItem:
1351 build_menu_function = &Editor::build_track_crossfade_context_menu;
1355 if (clicked_routeview->get_diskstream()) {
1356 build_menu_function = &Editor::build_track_context_menu;
1358 build_menu_function = &Editor::build_track_bus_context_menu;
1363 /* probably shouldn't happen but if it does, we don't care */
1367 menu = (this->*build_menu_function)(frame);
1368 menu->set_name ("ArdourContextMenu");
1370 /* now handle specific situations */
1372 switch (item_type) {
1374 case RegionViewName:
1375 case RegionViewNameHighlight:
1376 if (!with_selection) {
1377 if (region_edit_menu_split_item) {
1378 if (clicked_regionview && clicked_regionview->region()->covers (get_preferred_edit_position())) {
1379 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, true);
1381 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, false);
1385 if (region_edit_menu_split_multichannel_item) {
1386 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1387 // GTK2FIX find the action, change its sensitivity
1388 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1390 // GTK2FIX see above
1391 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1400 case CrossfadeViewItem:
1407 /* probably shouldn't happen but if it does, we don't care */
1411 if (item_type != SelectionItem && clicked_routeview && clicked_routeview->audio_track()) {
1413 /* Bounce to disk */
1415 using namespace Menu_Helpers;
1416 MenuList& edit_items = menu->items();
1418 edit_items.push_back (SeparatorElem());
1420 switch (clicked_routeview->audio_track()->freeze_state()) {
1421 case AudioTrack::NoFreeze:
1422 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1425 case AudioTrack::Frozen:
1426 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1429 case AudioTrack::UnFrozen:
1430 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1436 if (item_type == StreamItem && clicked_routeview) {
1437 clicked_routeview->build_underlay_menu(menu);
1440 menu->popup (button, time);
1444 Editor::build_track_context_menu (nframes64_t)
1446 using namespace Menu_Helpers;
1448 MenuList& edit_items = track_context_menu.items();
1451 add_dstream_context_items (edit_items);
1452 return &track_context_menu;
1456 Editor::build_track_bus_context_menu (nframes64_t)
1458 using namespace Menu_Helpers;
1460 MenuList& edit_items = track_context_menu.items();
1463 add_bus_context_items (edit_items);
1464 return &track_context_menu;
1468 Editor::build_track_region_context_menu (nframes64_t frame)
1470 using namespace Menu_Helpers;
1471 MenuList& edit_items = track_region_context_menu.items();
1474 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (clicked_axisview);
1477 boost::shared_ptr<Diskstream> ds;
1478 boost::shared_ptr<Playlist> pl;
1480 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
1481 Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)frame * ds->speed()));
1483 if (selection->regions.size() > 1) {
1484 // there's already a multiple selection: just add a
1485 // single region context menu that will act on all
1487 boost::shared_ptr<Region> dummy_region; // = NULL
1488 add_region_context_items (rtv->view(), dummy_region, edit_items);
1490 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1491 add_region_context_items (rtv->view(), (*i), edit_items);
1499 add_dstream_context_items (edit_items);
1501 return &track_region_context_menu;
1505 Editor::build_track_crossfade_context_menu (nframes64_t frame)
1507 using namespace Menu_Helpers;
1508 MenuList& edit_items = track_crossfade_context_menu.items();
1509 edit_items.clear ();
1511 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_axisview);
1514 boost::shared_ptr<Diskstream> ds;
1515 boost::shared_ptr<Playlist> pl;
1516 boost::shared_ptr<AudioPlaylist> apl;
1518 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1520 Playlist::RegionList* regions = pl->regions_at (frame);
1521 AudioPlaylist::Crossfades xfades;
1523 apl->crossfades_at (frame, xfades);
1525 bool many = xfades.size() > 1;
1527 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1528 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1531 if (selection->regions.size() > 1) {
1532 // there's already a multiple selection: just add a
1533 // single region context menu that will act on all
1535 boost::shared_ptr<Region> dummy_region; // = NULL
1536 add_region_context_items (atv->audio_view(), dummy_region, edit_items);
1538 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1539 add_region_context_items (atv->audio_view(), (*i), edit_items);
1546 add_dstream_context_items (edit_items);
1548 return &track_crossfade_context_menu;
1552 Editor::analyze_region_selection()
1554 if (analysis_window == 0) {
1555 analysis_window = new AnalysisWindow();
1558 analysis_window->set_session(session);
1560 analysis_window->show_all();
1563 analysis_window->set_regionmode();
1564 analysis_window->analyze();
1566 analysis_window->present();
1570 Editor::analyze_range_selection()
1572 if (analysis_window == 0) {
1573 analysis_window = new AnalysisWindow();
1576 analysis_window->set_session(session);
1578 analysis_window->show_all();
1581 analysis_window->set_rangemode();
1582 analysis_window->analyze();
1584 analysis_window->present();
1588 Editor::build_track_selection_context_menu (nframes64_t)
1590 using namespace Menu_Helpers;
1591 MenuList& edit_items = track_selection_context_menu.items();
1592 edit_items.clear ();
1594 add_selection_context_items (edit_items);
1595 // edit_items.push_back (SeparatorElem());
1596 // add_dstream_context_items (edit_items);
1598 return &track_selection_context_menu;
1601 /** Add context menu items relevant to crossfades.
1602 * @param edit_items List to add the items to.
1605 Editor::add_crossfade_context_items (AudioStreamView* /*view*/, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1607 using namespace Menu_Helpers;
1608 Menu *xfade_menu = manage (new Menu);
1609 MenuList& items = xfade_menu->items();
1610 xfade_menu->set_name ("ArdourContextMenu");
1613 if (xfade->active()) {
1619 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1620 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1622 if (xfade->can_follow_overlap()) {
1624 if (xfade->following_overlap()) {
1625 str = _("Convert to short");
1627 str = _("Convert to full");
1630 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1634 str = xfade->out()->name();
1636 str += xfade->in()->name();
1638 str = _("Crossfade");
1641 edit_items.push_back (MenuElem (str, *xfade_menu));
1642 edit_items.push_back (SeparatorElem());
1646 Editor::xfade_edit_left_region ()
1648 if (clicked_crossfadeview) {
1649 clicked_crossfadeview->left_view.show_region_editor ();
1654 Editor::xfade_edit_right_region ()
1656 if (clicked_crossfadeview) {
1657 clicked_crossfadeview->right_view.show_region_editor ();
1662 Editor::add_region_context_items (StreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1664 using namespace Menu_Helpers;
1665 Gtk::MenuItem* foo_item;
1666 Menu *region_menu = manage (new Menu);
1667 MenuList& items = region_menu->items();
1668 region_menu->set_name ("ArdourContextMenu");
1670 boost::shared_ptr<AudioRegion> ar;
1671 boost::shared_ptr<MidiRegion> mr;
1674 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1675 mr = boost::dynamic_pointer_cast<MidiRegion> (region);
1677 /* when this particular menu pops up, make the relevant region
1681 region_menu->signal_map_event().connect (
1682 bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1684 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &Editor::rename_region)));
1685 if (mr && internal_editing()) {
1686 items.push_back (MenuElem (_("List editor..."), mem_fun(*this, &Editor::show_midi_list_editor)));
1688 items.push_back (MenuElem (_("Region editor"), mem_fun(*this, &Editor::edit_region)));
1692 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1693 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1694 items.push_back (SeparatorElem());
1695 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_point)));
1696 if (_edit_point == EditAtMouse) {
1697 items.back ().set_sensitive (false);
1699 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1700 items.push_back (SeparatorElem());
1702 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::play_selected_region)));
1703 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1704 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1707 items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_region_selection)));
1710 items.push_back (SeparatorElem());
1712 sigc::connection fooc;
1713 boost::shared_ptr<Region> region_to_check;
1716 region_to_check = region;
1718 region_to_check = selection->regions.front()->region();
1721 items.push_back (CheckMenuElem (_("Lock")));
1722 CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1723 if (region_to_check->locked()) {
1724 region_lock_item->set_active();
1726 region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
1728 items.push_back (CheckMenuElem (_("Glue to Bars&Beats")));
1729 CheckMenuItem* bbt_glue_item = static_cast<CheckMenuItem*>(&items.back());
1731 switch (region_to_check->positional_lock_style()) {
1732 case Region::MusicTime:
1733 bbt_glue_item->set_active (true);
1736 bbt_glue_item->set_active (false);
1740 bbt_glue_item->signal_activate().connect (bind (mem_fun (*this, &Editor::set_region_lock_style), Region::MusicTime));
1742 items.push_back (CheckMenuElem (_("Mute")));
1743 CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1744 fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
1745 if (region_to_check->muted()) {
1747 region_mute_item->set_active();
1751 if (!Profile->get_sae()) {
1752 items.push_back (CheckMenuElem (_("Opaque")));
1753 CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1754 fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
1755 if (region_to_check->opaque()) {
1757 region_opaque_item->set_active();
1762 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1763 if (region_to_check->at_natural_position()) {
1764 items.back().set_sensitive (false);
1767 items.push_back (SeparatorElem());
1771 RegionView* rv = sv->find_view (ar);
1772 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1774 if (!Profile->get_sae()) {
1775 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
1777 items.push_back (CheckMenuElem (_("Envelope Visible")));
1778 CheckMenuItem* region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1779 fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
1780 if (arv->envelope_visible()) {
1782 region_envelope_visible_item->set_active (true);
1786 items.push_back (CheckMenuElem (_("Envelope Active")));
1787 CheckMenuItem* region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1788 fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
1790 if (ar->envelope_active()) {
1792 region_envelope_active_item->set_active (true);
1796 items.push_back (SeparatorElem());
1799 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1800 if (ar->scale_amplitude() != 1) {
1801 items.push_back (MenuElem (_("Reset Gain"), mem_fun(*this, &Editor::reset_region_scale_amplitude)));
1805 items.push_back (MenuElem (_("Quantize"), mem_fun(*this, &Editor::quantize_region)));
1806 items.push_back (SeparatorElem());
1809 items.push_back (MenuElem (_("Strip Silence..."), mem_fun (*this, &Editor::strip_region_silence)));
1810 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1811 items.push_back (SeparatorElem());
1813 /* range related stuff */
1815 items.push_back (MenuElem (_("Add Single Range"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1816 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_locations_from_audio_region)));
1817 if (selection->regions.size() < 2) {
1818 items.back().set_sensitive (false);
1821 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_region)));
1822 items.push_back (SeparatorElem());
1826 Menu *nudge_menu = manage (new Menu());
1827 MenuList& nudge_items = nudge_menu->items();
1828 nudge_menu->set_name ("ArdourContextMenu");
1830 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false, false))));
1831 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false, false))));
1832 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1833 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1835 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1836 items.push_back (SeparatorElem());
1838 Menu *trim_menu = manage (new Menu);
1839 MenuList& trim_items = trim_menu->items();
1840 trim_menu->set_name ("ArdourContextMenu");
1842 trim_items.push_back (MenuElem (_("Start to edit point"), mem_fun(*this, &Editor::trim_region_from_edit_point)));
1843 foo_item = &trim_items.back();
1844 if (_edit_point == EditAtMouse) {
1845 foo_item->set_sensitive (false);
1847 trim_items.push_back (MenuElem (_("Edit point to end"), mem_fun(*this, &Editor::trim_region_to_edit_point)));
1848 foo_item = &trim_items.back();
1849 if (_edit_point == EditAtMouse) {
1850 foo_item->set_sensitive (false);
1852 trim_items.push_back (MenuElem (_("Trim To Loop"), mem_fun(*this, &Editor::trim_region_to_loop)));
1853 trim_items.push_back (MenuElem (_("Trim To Punch"), mem_fun(*this, &Editor::trim_region_to_punch)));
1855 items.push_back (MenuElem (_("Trim"), *trim_menu));
1856 items.push_back (SeparatorElem());
1858 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split))));
1859 region_edit_menu_split_item = &items.back();
1861 if (_edit_point == EditAtMouse) {
1862 region_edit_menu_split_item->set_sensitive (false);
1865 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1866 region_edit_menu_split_multichannel_item = &items.back();
1868 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), false))));
1869 items.push_back (MenuElem (_("Multi-Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1870 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1871 items.push_back (SeparatorElem());
1872 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_selected_regions)));
1874 /* OK, stick the region submenu at the top of the list, and then add
1878 /* we have to hack up the region name because "_" has a special
1879 meaning for menu titles.
1882 string::size_type pos = 0;
1883 string menu_item_name = (region) ? region->name() : _("Selected regions");
1885 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1886 menu_item_name.replace (pos, 1, "__");
1890 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1891 edit_items.push_back (SeparatorElem());
1894 /** Add context menu items relevant to selection ranges.
1895 * @param edit_items List to add the items to.
1898 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1900 using namespace Menu_Helpers;
1902 edit_items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::play_selection)));
1903 edit_items.push_back (MenuElem (_("Loop Range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
1905 edit_items.push_back (SeparatorElem());
1906 edit_items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_range_selection)));
1908 if (!selection->regions.empty()) {
1909 edit_items.push_back (SeparatorElem());
1910 edit_items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
1911 edit_items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
1914 edit_items.push_back (SeparatorElem());
1915 edit_items.push_back (MenuElem (_("Silence Range"), mem_fun(*this, &Editor::separate_region_from_selection)));
1916 edit_items.push_back (MenuElem (_("Convert to Region in Region List"), mem_fun(*this, &Editor::new_region_from_selection)));
1918 edit_items.push_back (SeparatorElem());
1919 edit_items.push_back (MenuElem (_("Select All in Range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1921 edit_items.push_back (SeparatorElem());
1922 edit_items.push_back (MenuElem (_("Set Loop from Range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
1923 edit_items.push_back (MenuElem (_("Set Punch from Range"), mem_fun(*this, &Editor::set_punch_from_selection)));
1925 edit_items.push_back (SeparatorElem());
1926 edit_items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
1928 edit_items.push_back (SeparatorElem());
1929 edit_items.push_back (MenuElem (_("Crop Region to Range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1930 edit_items.push_back (MenuElem (_("Fill Range with Region"), mem_fun(*this, &Editor::region_fill_selection)));
1931 edit_items.push_back (MenuElem (_("Duplicate Range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1933 edit_items.push_back (SeparatorElem());
1934 edit_items.push_back (MenuElem (_("Consolidate Range"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, false)));
1935 edit_items.push_back (MenuElem (_("Consolidate Range With Processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, true)));
1936 edit_items.push_back (MenuElem (_("Bounce Range to Region List"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, false)));
1937 edit_items.push_back (MenuElem (_("Bounce Range to Region List With Processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, true)));
1938 edit_items.push_back (MenuElem (_("Export Range"), mem_fun(*this, &Editor::export_range)));
1943 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1945 using namespace Menu_Helpers;
1949 Menu *play_menu = manage (new Menu);
1950 MenuList& play_items = play_menu->items();
1951 play_menu->set_name ("ArdourContextMenu");
1953 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
1954 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1955 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1956 play_items.push_back (SeparatorElem());
1957 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1959 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1963 Menu *select_menu = manage (new Menu);
1964 MenuList& select_items = select_menu->items();
1965 select_menu->set_name ("ArdourContextMenu");
1967 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1968 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1969 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1970 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1971 select_items.push_back (SeparatorElem());
1972 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1973 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1974 select_items.push_back (SeparatorElem());
1975 select_items.push_back (MenuElem (_("Select All After Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
1976 select_items.push_back (MenuElem (_("Select All Before Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
1977 select_items.push_back (MenuElem (_("Select All After Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1978 select_items.push_back (MenuElem (_("Select All Before Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1979 select_items.push_back (MenuElem (_("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), false)));
1980 select_items.push_back (MenuElem (_("Select All Within Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), true)));
1981 select_items.push_back (MenuElem (_("Select Range Between Playhead & Edit Point"), mem_fun(*this, &Editor::select_range_between)));
1983 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1987 Menu *cutnpaste_menu = manage (new Menu);
1988 MenuList& cutnpaste_items = cutnpaste_menu->items();
1989 cutnpaste_menu->set_name ("ArdourContextMenu");
1991 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1992 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1993 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1995 cutnpaste_items.push_back (SeparatorElem());
1997 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1998 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
2000 cutnpaste_items.push_back (SeparatorElem());
2002 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
2004 /* Adding new material */
2006 edit_items.push_back (SeparatorElem());
2007 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
2008 edit_items.push_back (MenuElem (_("Insert Existing Media"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
2012 Menu *nudge_menu = manage (new Menu());
2013 MenuList& nudge_items = nudge_menu->items();
2014 nudge_menu->set_name ("ArdourContextMenu");
2016 edit_items.push_back (SeparatorElem());
2017 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2018 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2019 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2020 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2022 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2026 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
2028 using namespace Menu_Helpers;
2032 Menu *play_menu = manage (new Menu);
2033 MenuList& play_items = play_menu->items();
2034 play_menu->set_name ("ArdourContextMenu");
2036 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
2037 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2038 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2042 Menu *select_menu = manage (new Menu);
2043 MenuList& select_items = select_menu->items();
2044 select_menu->set_name ("ArdourContextMenu");
2046 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2047 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2048 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2049 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2050 select_items.push_back (SeparatorElem());
2051 select_items.push_back (MenuElem (_("Select all after edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2052 select_items.push_back (MenuElem (_("Select all before edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2053 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2054 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2056 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2060 Menu *cutnpaste_menu = manage (new Menu);
2061 MenuList& cutnpaste_items = cutnpaste_menu->items();
2062 cutnpaste_menu->set_name ("ArdourContextMenu");
2064 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2065 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2066 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2068 Menu *nudge_menu = manage (new Menu());
2069 MenuList& nudge_items = nudge_menu->items();
2070 nudge_menu->set_name ("ArdourContextMenu");
2072 edit_items.push_back (SeparatorElem());
2073 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2074 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2075 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2076 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2078 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2082 Editor::snap_type() const
2088 Editor::snap_mode() const
2094 Editor::set_snap_to (SnapType st)
2096 unsigned int snap_ind = (unsigned int)st;
2100 if (snap_ind > snap_type_strings.size() - 1) {
2102 _snap_type = (SnapType)snap_ind;
2105 string str = snap_type_strings[snap_ind];
2107 if (str != snap_type_selector.get_active_text()) {
2108 snap_type_selector.set_active_text (str);
2113 switch (_snap_type) {
2114 case SnapToAThirtysecondBeat:
2115 case SnapToASixteenthBeat:
2116 case SnapToAEighthBeat:
2117 case SnapToAQuarterBeat:
2118 case SnapToAThirdBeat:
2119 compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames());
2120 update_tempo_based_rulers ();
2123 case SnapToRegionStart:
2124 case SnapToRegionEnd:
2125 case SnapToRegionSync:
2126 case SnapToRegionBoundary:
2127 build_region_boundary_cache ();
2137 Editor::set_snap_mode (SnapMode mode)
2140 string str = snap_mode_strings[(int)mode];
2142 if (str != snap_mode_selector.get_active_text ()) {
2143 snap_mode_selector.set_active_text (str);
2149 Editor::set_edit_point_preference (EditPoint ep, bool force)
2151 bool changed = (_edit_point != ep);
2154 string str = edit_point_strings[(int)ep];
2156 if (str != edit_point_selector.get_active_text ()) {
2157 edit_point_selector.set_active_text (str);
2160 set_canvas_cursor ();
2162 if (!force && !changed) {
2166 const char* action=NULL;
2168 switch (_edit_point) {
2169 case EditAtPlayhead:
2170 action = "edit-at-playhead";
2172 case EditAtSelectedMarker:
2173 action = "edit-at-marker";
2176 action = "edit-at-mouse";
2180 Glib::RefPtr<Action> act = ActionManager::get_action ("Editor", action);
2182 Glib::RefPtr<RadioAction>::cast_dynamic(act)->set_active (true);
2186 bool in_track_canvas;
2188 if (!mouse_frame (foo, in_track_canvas)) {
2189 in_track_canvas = false;
2192 reset_canvas_action_sensitivity (in_track_canvas);
2198 Editor::set_state (const XMLNode& node, int /*version*/)
2200 const XMLProperty* prop;
2202 int x, y, xoff, yoff;
2205 if ((prop = node.property ("id")) != 0) {
2206 _id = prop->value ();
2209 g.base_width = default_width;
2210 g.base_height = default_height;
2216 if ((geometry = find_named_node (node, "geometry")) != 0) {
2220 if ((prop = geometry->property("x_size")) == 0) {
2221 prop = geometry->property ("x-size");
2224 g.base_width = atoi(prop->value());
2226 if ((prop = geometry->property("y_size")) == 0) {
2227 prop = geometry->property ("y-size");
2230 g.base_height = atoi(prop->value());
2233 if ((prop = geometry->property ("x_pos")) == 0) {
2234 prop = geometry->property ("x-pos");
2237 x = atoi (prop->value());
2240 if ((prop = geometry->property ("y_pos")) == 0) {
2241 prop = geometry->property ("y-pos");
2244 y = atoi (prop->value());
2247 if ((prop = geometry->property ("x_off")) == 0) {
2248 prop = geometry->property ("x-off");
2251 xoff = atoi (prop->value());
2253 if ((prop = geometry->property ("y_off")) == 0) {
2254 prop = geometry->property ("y-off");
2257 yoff = atoi (prop->value());
2261 set_default_size (g.base_width, g.base_height);
2264 if (session && (prop = node.property ("playhead"))) {
2265 nframes64_t pos = atol (prop->value().c_str());
2266 playhead_cursor->set_position (pos);
2268 playhead_cursor->set_position (0);
2271 if ((prop = node.property ("mixer-width"))) {
2272 editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
2275 if ((prop = node.property ("zoom-focus"))) {
2276 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2279 if ((prop = node.property ("zoom"))) {
2280 reset_zoom (PBD::atof (prop->value()));
2283 if ((prop = node.property ("snap-to"))) {
2284 set_snap_to ((SnapType) atoi (prop->value()));
2287 if ((prop = node.property ("snap-mode"))) {
2288 set_snap_mode ((SnapMode) atoi (prop->value()));
2291 if ((prop = node.property ("mouse-mode"))) {
2292 MouseMode m = str2mousemode(prop->value());
2293 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2294 set_mouse_mode (m, true);
2296 mouse_mode = MouseGain; /* lie, to force the mode switch */
2297 set_mouse_mode (MouseObject, true);
2300 if ((prop = node.property ("left-frame")) != 0){
2302 if (sscanf (prop->value().c_str(), "%" PRId64, &pos) == 1) {
2303 reset_x_origin (pos);
2304 /* this hack prevents the initial call to update_current_screen() from doing re-centering on the playhead */
2305 last_update_frame = pos;
2309 if ((prop = node.property ("internal-edit"))) {
2310 bool yn = string_is_affirmative (prop->value());
2311 RefPtr<Action> act = ActionManager::get_action (X_("MouseMode"), X_("toggle-internal-edit"));
2313 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2314 tact->set_active (!yn);
2315 tact->set_active (yn);
2319 if ((prop = node.property ("edit-point"))) {
2320 set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point), true);
2323 if ((prop = node.property ("show-waveforms-recording"))) {
2324 bool yn = string_is_affirmative (prop->value());
2325 _show_waveforms_recording = !yn;
2326 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2328 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2329 /* do it twice to force the change */
2330 tact->set_active (!yn);
2331 tact->set_active (yn);
2335 if ((prop = node.property ("show-measures"))) {
2336 bool yn = string_is_affirmative (prop->value());
2337 _show_measures = !yn;
2338 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2340 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2341 /* do it twice to force the change */
2342 tact->set_active (!yn);
2343 tact->set_active (yn);
2347 if ((prop = node.property ("follow-playhead"))) {
2348 bool yn = string_is_affirmative (prop->value());
2349 set_follow_playhead (yn);
2350 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2352 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2353 if (tact->get_active() != yn) {
2354 tact->set_active (yn);
2359 if ((prop = node.property ("region-list-sort-type"))) {
2360 _regions->reset_sort_type (str2regionlistsorttype(prop->value()), true);
2363 if ((prop = node.property ("xfades-visible"))) {
2364 bool yn = string_is_affirmative (prop->value());
2365 _xfade_visibility = !yn;
2366 // set_xfade_visibility (yn);
2369 if ((prop = node.property ("show-editor-mixer"))) {
2371 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2374 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2375 bool yn = string_is_affirmative (prop->value());
2377 /* do it twice to force the change */
2379 tact->set_active (!yn);
2380 tact->set_active (yn);
2384 if ((prop = node.property ("show-editor-list"))) {
2386 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2390 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2391 bool yn = string_is_affirmative (prop->value());
2393 /* do it twice to force the change */
2395 tact->set_active (!yn);
2396 tact->set_active (yn);
2405 Editor::get_state ()
2407 XMLNode* node = new XMLNode ("Editor");
2410 _id.print (buf, sizeof (buf));
2411 node->add_property ("id", buf);
2413 if (is_realized()) {
2414 Glib::RefPtr<Gdk::Window> win = get_window();
2416 int x, y, xoff, yoff, width, height;
2417 win->get_root_origin(x, y);
2418 win->get_position(xoff, yoff);
2419 win->get_size(width, height);
2421 XMLNode* geometry = new XMLNode ("geometry");
2423 snprintf(buf, sizeof(buf), "%d", width);
2424 geometry->add_property("x-size", string(buf));
2425 snprintf(buf, sizeof(buf), "%d", height);
2426 geometry->add_property("y-size", string(buf));
2427 snprintf(buf, sizeof(buf), "%d", x);
2428 geometry->add_property("x-pos", string(buf));
2429 snprintf(buf, sizeof(buf), "%d", y);
2430 geometry->add_property("y-pos", string(buf));
2431 snprintf(buf, sizeof(buf), "%d", xoff);
2432 geometry->add_property("x-off", string(buf));
2433 snprintf(buf, sizeof(buf), "%d", yoff);
2434 geometry->add_property("y-off", string(buf));
2435 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2436 geometry->add_property("edit_pane_pos", string(buf));
2438 node->add_child_nocopy (*geometry);
2441 maybe_add_mixer_strip_width (*node);
2443 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2444 node->add_property ("zoom-focus", buf);
2445 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2446 node->add_property ("zoom", buf);
2447 snprintf (buf, sizeof(buf), "%d", (int) _snap_type);
2448 node->add_property ("snap-to", buf);
2449 snprintf (buf, sizeof(buf), "%d", (int) _snap_mode);
2450 node->add_property ("snap-mode", buf);
2452 node->add_property ("edit-point", enum_2_string (_edit_point));
2454 snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame);
2455 node->add_property ("playhead", buf);
2456 snprintf (buf, sizeof (buf), "%" PRIi64, leftmost_frame);
2457 node->add_property ("left-frame", buf);
2459 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2460 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2461 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2462 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2463 node->add_property ("region-list-sort-type", enum2str (_regions->sort_type ()));
2464 node->add_property ("mouse-mode", enum2str(mouse_mode));
2465 node->add_property ("internal-edit", _internal_editing ? "yes" : "no");
2467 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2469 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2470 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2473 act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2475 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2476 node->add_property (X_("show-editor-list"), tact->get_active() ? "yes" : "no");
2484 /** @param y y offset from the top of all trackviews.
2485 * @return pair: TimeAxisView that y is over, layer index.
2486 * TimeAxisView may be 0. Layer index is the layer number if the TimeAxisView is valid and is
2487 * in stacked region display mode, otherwise 0.
2489 std::pair<TimeAxisView *, layer_t>
2490 Editor::trackview_by_y_position (double y)
2492 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2494 std::pair<TimeAxisView*, int> const r = (*iter)->covers_y_position (y);
2500 return std::make_pair ( (TimeAxisView *) 0, 0);
2503 /** Snap a position to the grid, if appropriate, taking into account current
2504 * grid settings and also the state of any snap modifier keys that may be pressed.
2505 * @param start Position to snap.
2506 * @param event Event to get current key modifier information from.
2509 Editor::snap_to_with_modifier (nframes64_t& start, GdkEvent const * event, int32_t direction, bool for_mark)
2515 if (Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
2516 if (_snap_mode == SnapOff) {
2517 snap_to_internal (start, direction, for_mark);
2520 if (_snap_mode != SnapOff) {
2521 snap_to_internal (start, direction, for_mark);
2527 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
2529 if (!session || _snap_mode == SnapOff) {
2533 snap_to_internal (start, direction, for_mark);
2537 Editor::timecode_snap_to_internal (nframes64_t& start, int32_t direction, bool /*for_mark*/)
2539 const nframes64_t one_timecode_second = (nframes64_t)(rint(session->timecode_frames_per_second()) * session->frames_per_timecode_frame());
2540 nframes64_t one_timecode_minute = (nframes64_t)(rint(session->timecode_frames_per_second()) * session->frames_per_timecode_frame() * 60);
2542 switch (_snap_type) {
2543 case SnapToTimecodeFrame:
2544 if (((direction == 0) && (fmod((double)start, (double)session->frames_per_timecode_frame()) > (session->frames_per_timecode_frame() / 2))) || (direction > 0)) {
2545 start = (nframes64_t) (ceil ((double) start / session->frames_per_timecode_frame()) * session->frames_per_timecode_frame());
2547 start = (nframes64_t) (floor ((double) start / session->frames_per_timecode_frame()) * session->frames_per_timecode_frame());
2551 case SnapToTimecodeSeconds:
2552 if (session->timecode_offset_negative())
2554 start += session->timecode_offset ();
2556 start -= session->timecode_offset ();
2558 if (((direction == 0) && (start % one_timecode_second > one_timecode_second / 2)) || direction > 0) {
2559 start = (nframes64_t) ceil ((double) start / one_timecode_second) * one_timecode_second;
2561 start = (nframes64_t) floor ((double) start / one_timecode_second) * one_timecode_second;
2564 if (session->timecode_offset_negative())
2566 start -= session->timecode_offset ();
2568 start += session->timecode_offset ();
2572 case SnapToTimecodeMinutes:
2573 if (session->timecode_offset_negative())
2575 start += session->timecode_offset ();
2577 start -= session->timecode_offset ();
2579 if (((direction == 0) && (start % one_timecode_minute > one_timecode_minute / 2)) || direction > 0) {
2580 start = (nframes64_t) ceil ((double) start / one_timecode_minute) * one_timecode_minute;
2582 start = (nframes64_t) floor ((double) start / one_timecode_minute) * one_timecode_minute;
2584 if (session->timecode_offset_negative())
2586 start -= session->timecode_offset ();
2588 start += session->timecode_offset ();
2592 fatal << "Editor::smpte_snap_to_internal() called with non-timecode snap type!" << endmsg;
2598 Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
2600 const nframes64_t one_second = session->frame_rate();
2601 const nframes64_t one_minute = session->frame_rate() * 60;
2602 nframes64_t presnap = start;
2606 switch (_snap_type) {
2607 case SnapToTimecodeFrame:
2608 case SnapToTimecodeSeconds:
2609 case SnapToTimecodeMinutes:
2610 return timecode_snap_to_internal (start, direction, for_mark);
2613 if (((direction == 0) && (start % (one_second/75) > (one_second/75) / 2)) || (direction > 0)) {
2614 start = (nframes64_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2616 start = (nframes64_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2621 if (((direction == 0) && (start % one_second > one_second / 2)) || (direction > 0)) {
2622 start = (nframes64_t) ceil ((double) start / one_second) * one_second;
2624 start = (nframes64_t) floor ((double) start / one_second) * one_second;
2629 if (((direction == 0) && (start % one_minute > one_minute / 2)) || (direction > 0)) {
2630 start = (nframes64_t) ceil ((double) start / one_minute) * one_minute;
2632 start = (nframes64_t) floor ((double) start / one_minute) * one_minute;
2637 start = session->tempo_map().round_to_bar (start, direction);
2641 start = session->tempo_map().round_to_beat (start, direction);
2644 case SnapToAThirtysecondBeat:
2645 start = session->tempo_map().round_to_beat_subdivision (start, 32, direction);
2648 case SnapToASixteenthBeat:
2649 start = session->tempo_map().round_to_beat_subdivision (start, 16, direction);
2652 case SnapToAEighthBeat:
2653 start = session->tempo_map().round_to_beat_subdivision (start, 8, direction);
2656 case SnapToAQuarterBeat:
2657 start = session->tempo_map().round_to_beat_subdivision (start, 4, direction);
2660 case SnapToAThirdBeat:
2661 start = session->tempo_map().round_to_beat_subdivision (start, 3, direction);
2669 session->locations()->marks_either_side (start, before, after);
2671 if (before == max_frames) {
2673 } else if (after == max_frames) {
2675 } else if (before != max_frames && after != max_frames) {
2676 /* have before and after */
2677 if ((start - before) < (after - start)) {
2686 case SnapToRegionStart:
2687 case SnapToRegionEnd:
2688 case SnapToRegionSync:
2689 case SnapToRegionBoundary:
2690 if (!region_boundary_cache.empty()) {
2692 vector<nframes64_t>::iterator prev = region_boundary_cache.end ();
2693 vector<nframes64_t>::iterator next = region_boundary_cache.end ();
2695 if (direction > 0) {
2696 next = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2698 next = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2701 if (next != region_boundary_cache.begin ()) {
2706 nframes64_t const p = (prev == region_boundary_cache.end()) ? region_boundary_cache.front () : *prev;
2707 nframes64_t const n = (next == region_boundary_cache.end()) ? region_boundary_cache.back () : *next;
2709 if (start > (p + n) / 2) {
2718 switch (_snap_mode) {
2724 if (presnap > start) {
2725 if (presnap > (start + unit_to_frame(snap_threshold))) {
2729 } else if (presnap < start) {
2730 if (presnap < (start - unit_to_frame(snap_threshold))) {
2736 /* handled at entry */
2744 Editor::setup_toolbar ()
2748 /* Mode Buttons (tool selection) */
2750 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2751 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2752 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2753 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2754 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2755 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2756 // internal_edit_button.set_relief(Gtk::RELIEF_NONE);
2758 HBox* mode_box = manage(new HBox);
2759 mode_box->set_border_width (2);
2760 mode_box->set_spacing(4);
2761 mouse_mode_button_box.set_spacing(1);
2762 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2763 if (!Profile->get_sae()) {
2764 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2766 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2767 if (!Profile->get_sae()) {
2768 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2770 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2771 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2772 mouse_mode_button_box.pack_start(internal_edit_button, true, true);
2773 mouse_mode_button_box.set_homogeneous(true);
2775 vector<string> edit_mode_strings;
2776 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2777 if (!Profile->get_sae()) {
2778 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2780 edit_mode_strings.push_back (edit_mode_to_string (Lock));
2782 edit_mode_selector.set_name ("EditModeSelector");
2783 set_popdown_strings (edit_mode_selector, edit_mode_strings, true);
2784 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2786 mode_box->pack_start(edit_mode_selector);
2787 mode_box->pack_start(mouse_mode_button_box);
2789 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2790 mouse_mode_tearoff->set_name ("MouseModeBase");
2791 mouse_mode_tearoff->tearoff_window().signal_key_press_event().connect (bind (sigc::ptr_fun (relay_key_press), &mouse_mode_tearoff->tearoff_window()), false);
2793 if (Profile->get_sae()) {
2794 mouse_mode_tearoff->set_can_be_torn_off (false);
2797 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2798 &mouse_mode_tearoff->tearoff_window()));
2799 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2800 &mouse_mode_tearoff->tearoff_window(), 1));
2801 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2802 &mouse_mode_tearoff->tearoff_window()));
2803 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2804 &mouse_mode_tearoff->tearoff_window(), 1));
2806 mouse_move_button.set_mode (false);
2807 mouse_select_button.set_mode (false);
2808 mouse_gain_button.set_mode (false);
2809 mouse_zoom_button.set_mode (false);
2810 mouse_timefx_button.set_mode (false);
2811 mouse_audition_button.set_mode (false);
2813 mouse_move_button.set_name ("MouseModeButton");
2814 mouse_select_button.set_name ("MouseModeButton");
2815 mouse_gain_button.set_name ("MouseModeButton");
2816 mouse_zoom_button.set_name ("MouseModeButton");
2817 mouse_timefx_button.set_name ("MouseModeButton");
2818 mouse_audition_button.set_name ("MouseModeButton");
2820 internal_edit_button.set_name ("MouseModeButton");
2822 mouse_move_button.unset_flags (CAN_FOCUS);
2823 mouse_select_button.unset_flags (CAN_FOCUS);
2824 mouse_gain_button.unset_flags (CAN_FOCUS);
2825 mouse_zoom_button.unset_flags (CAN_FOCUS);
2826 mouse_timefx_button.unset_flags (CAN_FOCUS);
2827 mouse_audition_button.unset_flags (CAN_FOCUS);
2828 internal_edit_button.unset_flags (CAN_FOCUS);
2832 zoom_box.set_spacing (1);
2833 zoom_box.set_border_width (0);
2835 zoom_in_button.set_name ("EditorTimeButton");
2836 zoom_in_button.set_image (*(manage (new Image (Stock::ZOOM_IN, Gtk::ICON_SIZE_BUTTON))));
2837 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2838 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2840 zoom_out_button.set_name ("EditorTimeButton");
2841 zoom_out_button.set_image (*(manage (new Image (Stock::ZOOM_OUT, Gtk::ICON_SIZE_BUTTON))));
2842 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2843 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2845 zoom_out_full_button.set_name ("EditorTimeButton");
2846 zoom_out_full_button.set_image (*(manage (new Image (Stock::ZOOM_100, Gtk::ICON_SIZE_BUTTON))));
2847 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2848 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2850 zoom_focus_selector.set_name ("ZoomFocusSelector");
2851 set_popdown_strings (zoom_focus_selector, zoom_focus_strings, true);
2852 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2853 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
2855 zoom_box.pack_start (zoom_out_button, false, false);
2856 zoom_box.pack_start (zoom_in_button, false, false);
2857 zoom_box.pack_start (zoom_out_full_button, false, false);
2859 /* Track zoom buttons */
2860 tav_expand_button.set_name ("TrackHeightButton");
2861 tav_expand_button.set_size_request(-1,20);
2862 tav_expand_button.add (*(manage (new Image (::get_icon("tav_exp")))));
2863 tav_expand_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::tav_zoom_step), true));
2864 ARDOUR_UI::instance()->tooltips().set_tip (tav_expand_button, _("Expand Tracks"));
2866 tav_shrink_button.set_name ("TrackHeightButton");
2867 tav_shrink_button.set_size_request(-1,20);
2868 tav_shrink_button.add (*(manage (new Image (::get_icon("tav_shrink")))));
2869 tav_shrink_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::tav_zoom_step), false));
2870 ARDOUR_UI::instance()->tooltips().set_tip (tav_shrink_button, _("Shrink Tracks"));
2872 track_zoom_box.set_spacing (1);
2873 track_zoom_box.set_border_width (0);
2875 track_zoom_box.pack_start (tav_shrink_button, false, false);
2876 track_zoom_box.pack_start (tav_expand_button, false, false);
2878 HBox* zbc = manage (new HBox);
2879 zbc->pack_start (zoom_focus_selector, PACK_SHRINK);
2880 zoom_vbox.pack_start (*zbc, PACK_SHRINK);
2881 zoom_vbox.pack_start (zoom_box, PACK_SHRINK);
2882 zoom_vbox.pack_start (track_zoom_box, PACK_SHRINK);
2884 snap_box.set_spacing (1);
2885 snap_box.set_border_width (2);
2887 snap_type_selector.set_name ("SnapTypeSelector");
2888 set_popdown_strings (snap_type_selector, snap_type_strings, true);
2889 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2890 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Snap/Grid Units"));
2892 snap_mode_selector.set_name ("SnapModeSelector");
2893 set_popdown_strings (snap_mode_selector, snap_mode_strings, true);
2894 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2895 ARDOUR_UI::instance()->tooltips().set_tip (snap_mode_selector, _("Snap/Grid Mode"));
2897 edit_point_selector.set_name ("EditPointSelector");
2898 set_popdown_strings (edit_point_selector, edit_point_strings, true);
2899 edit_point_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_point_selection_done));
2900 ARDOUR_UI::instance()->tooltips().set_tip (edit_point_selector, _("Edit point"));
2902 snap_box.pack_start (snap_mode_selector, false, false);
2903 snap_box.pack_start (snap_type_selector, false, false);
2904 snap_box.pack_start (edit_point_selector, false, false);
2908 HBox *nudge_box = manage (new HBox);
2909 nudge_box->set_spacing(1);
2910 nudge_box->set_border_width (2);
2912 nudge_forward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_forward_release), false);
2913 nudge_backward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_backward_release), false);
2915 nudge_box->pack_start (nudge_backward_button, false, false);
2916 nudge_box->pack_start (nudge_forward_button, false, false);
2917 nudge_box->pack_start (nudge_clock, false, false);
2920 /* Pack everything in... */
2922 HBox* hbox = manage (new HBox);
2923 hbox->set_spacing(10);
2925 tools_tearoff = manage (new TearOff (*hbox));
2926 tools_tearoff->set_name ("MouseModeBase");
2927 tools_tearoff->tearoff_window().signal_key_press_event().connect (bind (sigc::ptr_fun (relay_key_press), &tools_tearoff->tearoff_window()), false);
2929 if (Profile->get_sae()) {
2930 tools_tearoff->set_can_be_torn_off (false);
2933 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2934 &tools_tearoff->tearoff_window()));
2935 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2936 &tools_tearoff->tearoff_window(), 0));
2937 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2938 &tools_tearoff->tearoff_window()));
2939 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2940 &tools_tearoff->tearoff_window(), 0));
2942 toolbar_hbox.set_spacing (10);
2943 toolbar_hbox.set_border_width (1);
2945 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2946 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2948 hbox->pack_start (snap_box, false, false);
2949 hbox->pack_start (*nudge_box, false, false);
2950 hbox->pack_start (panic_box, false, false);
2954 toolbar_base.set_name ("ToolBarBase");
2955 toolbar_base.add (toolbar_hbox);
2957 toolbar_frame.set_shadow_type (SHADOW_OUT);
2958 toolbar_frame.set_name ("BaseFrame");
2959 toolbar_frame.add (toolbar_base);
2963 Editor::midi_panic ()
2965 cerr << "MIDI panic\n";
2968 session->midi_panic();
2973 Editor::setup_midi_toolbar ()
2977 /* Midi sound notes */
2978 midi_sound_notes.add (*(manage (new Image (::get_icon("midi_sound_notes")))));
2979 midi_sound_notes.set_relief(Gtk::RELIEF_NONE);
2980 ARDOUR_UI::instance()->tooltips().set_tip (midi_sound_notes, _("Sound Notes"));
2981 midi_sound_notes.unset_flags (CAN_FOCUS);
2985 act = ActionManager::get_action (X_("MIDI"), X_("panic"));
2986 midi_panic_button.set_name("MidiPanicButton");
2987 ARDOUR_UI::instance()->tooltips().set_tip (midi_panic_button, _("Send note off and reset controller messages on all MIDI channels"));
2988 act->connect_proxy (midi_panic_button);
2990 panic_box.pack_start (midi_sound_notes , true, true);
2991 panic_box.pack_start (midi_panic_button, true, true);
2995 Editor::convert_drop_to_paths (
2996 vector<ustring>& paths,
2997 const RefPtr<Gdk::DragContext>& /*context*/,
3000 const SelectionData& data,
3008 vector<ustring> uris = data.get_uris();
3012 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
3013 are actually URI lists. So do it by hand.
3016 if (data.get_target() != "text/plain") {
3020 /* Parse the "uri-list" format that Nautilus provides,
3021 where each pathname is delimited by \r\n.
3023 THERE MAY BE NO NULL TERMINATING CHAR!!!
3026 ustring txt = data.get_text();
3030 p = (const char *) malloc (txt.length() + 1);
3031 txt.copy ((char *) p, txt.length(), 0);
3032 ((char*)p)[txt.length()] = '\0';
3038 while (g_ascii_isspace (*p))
3042 while (*q && (*q != '\n') && (*q != '\r')) {
3049 while (q > p && g_ascii_isspace (*q))
3054 uris.push_back (ustring (p, q - p + 1));
3058 p = strchr (p, '\n');
3070 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
3072 if ((*i).substr (0,7) == "file://") {
3075 PBD::url_decode (p);
3077 // scan forward past three slashes
3079 ustring::size_type slashcnt = 0;
3080 ustring::size_type n = 0;
3081 ustring::iterator x = p.begin();
3083 while (slashcnt < 3 && x != p.end()) {
3086 } else if (slashcnt == 3) {
3093 if (slashcnt != 3 || x == p.end()) {
3094 error << _("malformed URL passed to drag-n-drop code") << endmsg;
3098 paths.push_back (p.substr (n - 1));
3106 Editor::new_tempo_section ()
3112 Editor::map_transport_state ()
3114 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
3116 if (session->transport_stopped()) {
3117 have_pending_keyboard_selection = false;
3120 update_loop_range_view (true);
3125 Editor::State::State (PublicEditor const * e)
3127 selection = new Selection (e);
3130 Editor::State::~State ()
3136 Editor::store_state (State& state) const
3138 *state.selection = *selection;
3142 Editor::restore_state (State *state)
3144 if (*selection == *state->selection) {
3148 *selection = *state->selection;
3149 time_selection_changed ();
3150 region_selection_changed ();
3152 /* XXX other selection change handlers? */
3156 Editor::begin_reversible_command (string name)
3159 before = &get_state();
3160 session->begin_reversible_command (name);
3165 Editor::commit_reversible_command ()
3168 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
3173 Editor::set_route_group_solo (Route& route, bool yn)
3175 RouteGroup *route_group;
3177 if ((route_group = route.route_group()) != 0) {
3178 route_group->apply (&Route::set_solo, yn, this);
3180 route.set_solo (yn, this);
3185 Editor::set_route_group_mute (Route& route, bool yn)
3187 RouteGroup *route_group = 0;
3189 if ((route_group == route.route_group()) != 0) {
3190 route_group->apply (&Route::set_mute, yn, this);
3192 route.set_mute (yn, this);
3197 Editor::history_changed ()
3201 if (undo_action && session) {
3202 if (session->undo_depth() == 0) {
3205 label = string_compose(_("Undo (%1)"), session->next_undo());
3207 undo_action->property_label() = label;
3210 if (redo_action && session) {
3211 if (session->redo_depth() == 0) {
3214 label = string_compose(_("Redo (%1)"), session->next_redo());
3216 redo_action->property_label() = label;
3221 Editor::duplicate_dialog (bool with_dialog)
3225 if (mouse_mode == MouseRange) {
3226 if (selection->time.length() == 0) {
3232 get_regions_for_action (rs);
3234 if (mouse_mode != MouseRange) {
3243 ArdourDialog win ("Duplicate");
3244 Label label (_("Number of Duplications:"));
3245 Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
3246 SpinButton spinner (adjustment, 0.0, 1);
3249 win.get_vbox()->set_spacing (12);
3250 win.get_vbox()->pack_start (hbox);
3251 hbox.set_border_width (6);
3252 hbox.pack_start (label, PACK_EXPAND_PADDING, 12);
3254 /* dialogs have ::add_action_widget() but that puts the spinner in the wrong
3255 place, visually. so do this by hand.
3258 hbox.pack_start (spinner, PACK_EXPAND_PADDING, 12);
3259 spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
3260 spinner.grab_focus();
3266 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3267 win.add_button (_("Duplicate"), RESPONSE_ACCEPT);
3268 win.set_default_response (RESPONSE_ACCEPT);
3270 win.set_position (WIN_POS_MOUSE);
3272 spinner.grab_focus ();
3274 switch (win.run ()) {
3275 case RESPONSE_ACCEPT:
3281 times = adjustment.get_value();
3284 if (mouse_mode == MouseRange) {
3285 duplicate_selection (times);
3287 duplicate_some_regions (rs, times);
3292 Editor::show_verbose_canvas_cursor ()
3294 verbose_canvas_cursor->raise_to_top();
3295 verbose_canvas_cursor->show();
3296 verbose_cursor_visible = true;
3300 Editor::hide_verbose_canvas_cursor ()
3302 verbose_canvas_cursor->hide();
3303 verbose_cursor_visible = false;
3307 Editor::clamp_verbose_cursor_x (double x)
3312 x = min (_canvas_width - 200.0, x);
3318 Editor::clamp_verbose_cursor_y (double y)
3320 if (y < canvas_timebars_vsize) {
3321 y = canvas_timebars_vsize;
3323 y = min (_canvas_height - 50, y);
3329 Editor::show_verbose_canvas_cursor_with (const string & txt)
3331 verbose_canvas_cursor->property_text() = txt.c_str();
3336 track_canvas->get_pointer (x, y);
3337 track_canvas->window_to_world (x, y, wx, wy);
3339 /* don't get too close to the edge */
3340 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (wx);
3341 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (wy);
3343 show_verbose_canvas_cursor ();
3347 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3349 verbose_canvas_cursor->property_text() = txt.c_str();
3350 /* don't get too close to the edge */
3351 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (x);
3352 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (y);
3356 Editor::set_verbose_canvas_cursor_text (const string & txt)
3358 verbose_canvas_cursor->property_text() = txt.c_str();
3362 Editor::set_edit_mode (EditMode m)
3364 Config->set_edit_mode (m);
3368 Editor::cycle_edit_mode ()
3370 switch (Config->get_edit_mode()) {
3372 if (Profile->get_sae()) {
3373 Config->set_edit_mode (Lock);
3375 Config->set_edit_mode (Splice);
3379 Config->set_edit_mode (Lock);
3382 Config->set_edit_mode (Slide);
3388 Editor::edit_mode_selection_done ()
3394 string choice = edit_mode_selector.get_active_text();
3395 EditMode mode = Slide;
3397 if (choice == _("Splice Edit")) {
3399 } else if (choice == _("Slide Edit")) {
3401 } else if (choice == _("Lock Edit")) {
3405 Config->set_edit_mode (mode);
3409 Editor::snap_type_selection_done ()
3411 string choice = snap_type_selector.get_active_text();
3412 SnapType snaptype = SnapToBeat;
3414 if (choice == _("Beats/3")) {
3415 snaptype = SnapToAThirdBeat;
3416 } else if (choice == _("Beats/4")) {
3417 snaptype = SnapToAQuarterBeat;
3418 } else if (choice == _("Beats/8")) {
3419 snaptype = SnapToAEighthBeat;
3420 } else if (choice == _("Beats/16")) {
3421 snaptype = SnapToASixteenthBeat;
3422 } else if (choice == _("Beats/32")) {
3423 snaptype = SnapToAThirtysecondBeat;
3424 } else if (choice == _("Beats")) {
3425 snaptype = SnapToBeat;
3426 } else if (choice == _("Bars")) {
3427 snaptype = SnapToBar;
3428 } else if (choice == _("Marks")) {
3429 snaptype = SnapToMark;
3430 } else if (choice == _("Region starts")) {
3431 snaptype = SnapToRegionStart;
3432 } else if (choice == _("Region ends")) {
3433 snaptype = SnapToRegionEnd;
3434 } else if (choice == _("Region bounds")) {
3435 snaptype = SnapToRegionBoundary;
3436 } else if (choice == _("Region syncs")) {
3437 snaptype = SnapToRegionSync;
3438 } else if (choice == _("CD Frames")) {
3439 snaptype = SnapToCDFrame;
3440 } else if (choice == _("Timecode Frames")) {
3441 snaptype = SnapToTimecodeFrame;
3442 } else if (choice == _("Timecode Seconds")) {
3443 snaptype = SnapToTimecodeSeconds;
3444 } else if (choice == _("Timecode Minutes")) {
3445 snaptype = SnapToTimecodeMinutes;
3446 } else if (choice == _("Seconds")) {
3447 snaptype = SnapToSeconds;
3448 } else if (choice == _("Minutes")) {
3449 snaptype = SnapToMinutes;
3452 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3454 ract->set_active ();
3459 Editor::snap_mode_selection_done ()
3461 string choice = snap_mode_selector.get_active_text();
3462 SnapMode mode = SnapNormal;
3464 if (choice == _("No Grid")) {
3466 } else if (choice == _("Grid")) {
3468 } else if (choice == _("Magnetic")) {
3469 mode = SnapMagnetic;
3472 RefPtr<RadioAction> ract = snap_mode_action (mode);
3475 ract->set_active (true);
3480 Editor::cycle_edit_point (bool with_marker)
3482 switch (_edit_point) {
3484 set_edit_point_preference (EditAtPlayhead);
3486 case EditAtPlayhead:
3488 set_edit_point_preference (EditAtSelectedMarker);
3490 set_edit_point_preference (EditAtMouse);
3493 case EditAtSelectedMarker:
3494 set_edit_point_preference (EditAtMouse);
3500 Editor::edit_point_selection_done ()
3502 string choice = edit_point_selector.get_active_text();
3503 EditPoint ep = EditAtSelectedMarker;
3505 if (choice == _("Marker")) {
3506 set_edit_point_preference (EditAtSelectedMarker);
3507 } else if (choice == _("Playhead")) {
3508 set_edit_point_preference (EditAtPlayhead);
3510 set_edit_point_preference (EditAtMouse);
3513 RefPtr<RadioAction> ract = edit_point_action (ep);
3516 ract->set_active (true);
3521 Editor::zoom_focus_selection_done ()
3523 string choice = zoom_focus_selector.get_active_text();
3524 ZoomFocus focus_type = ZoomFocusLeft;
3526 if (choice == _("Left")) {
3527 focus_type = ZoomFocusLeft;
3528 } else if (choice == _("Right")) {
3529 focus_type = ZoomFocusRight;
3530 } else if (choice == _("Center")) {
3531 focus_type = ZoomFocusCenter;
3532 } else if (choice == _("Playhead")) {
3533 focus_type = ZoomFocusPlayhead;
3534 } else if (choice == _("Mouse")) {
3535 focus_type = ZoomFocusMouse;
3536 } else if (choice == _("Edit point")) {
3537 focus_type = ZoomFocusEdit;
3540 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3543 ract->set_active ();
3548 Editor::edit_controls_button_release (GdkEventButton* ev)
3550 if (Keyboard::is_context_menu_event (ev)) {
3551 ARDOUR_UI::instance()->add_route (this);
3557 Editor::mouse_select_button_release (GdkEventButton* ev)
3559 /* this handles just right-clicks */
3561 if (ev->button != 3) {
3568 Editor::TrackViewList *
3569 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3571 TrackViewList::iterator i;
3573 TrackViewList* v = new TrackViewList;
3575 if (track == 0 && group == 0) {
3579 for (i = track_views.begin(); i != track_views.end (); ++i) {
3583 } else if ((track != 0 && group == 0) || (track != 0 && group != 0 && !group->active_property (RouteGroup::Select))) {
3585 /* just the view for this track
3588 v->push_back (track);
3592 /* views for all tracks in the route group */
3594 for (i = track_views.begin(); i != track_views.end (); ++i) {
3596 if (group == 0 || ((*i)->route_group() == group && group->active_property (RouteGroup::Select))) {
3606 Editor::set_zoom_focus (ZoomFocus f)
3608 string str = zoom_focus_strings[(int)f];
3610 if (str != zoom_focus_selector.get_active_text()) {
3611 zoom_focus_selector.set_active_text (str);
3614 if (zoom_focus != f) {
3617 ZoomFocusChanged (); /* EMIT_SIGNAL */
3624 Editor::ensure_float (Window& win)
3626 win.set_transient_for (*this);
3630 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3632 /* recover or initialize pane positions. do this here rather than earlier because
3633 we don't want the positions to change the child allocations, which they seem to do.
3639 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3641 static int32_t done;
3644 width = default_width;
3645 height = default_height;
3647 if ((geometry = find_named_node (*node, "geometry")) != 0) {
3649 if ((prop = geometry->property ("x_size")) == 0) {
3650 prop = geometry->property ("x-size");
3653 width = atoi (prop->value());
3655 if ((prop = geometry->property ("y_size")) == 0) {
3656 prop = geometry->property ("y-size");
3659 height = atoi (prop->value());
3663 if (which == static_cast<Paned*> (&edit_pane)) {
3669 if (!geometry || (prop = geometry->property ("edit-pane-pos")) == 0) {
3670 /* initial allocation is 90% to canvas, 10% to notebook */
3671 pos = (int) floor (alloc.get_width() * 0.90f);
3672 snprintf (buf, sizeof(buf), "%d", pos);
3674 pos = atoi (prop->value());
3677 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3678 edit_pane.set_position (pos);
3679 pre_maximal_pane_position = pos;
3685 Editor::detach_tearoff (Box* /*b*/, Window* /*w*/)
3687 cerr << "remove tearoff\n";
3689 if (tools_tearoff->torn_off() &&
3690 mouse_mode_tearoff->torn_off()) {
3691 top_hbox.remove (toolbar_frame);
3696 Editor::reattach_tearoff (Box* /*b*/, Window* /*w*/, int32_t /*n*/)
3698 cerr << "reattach tearoff\n";
3699 if (toolbar_frame.get_parent() == 0) {
3700 top_hbox.pack_end (toolbar_frame);
3705 Editor::set_show_measures (bool yn)
3707 if (_show_measures != yn) {
3710 if ((_show_measures = yn) == true) {
3712 tempo_lines->show();
3720 Editor::toggle_follow_playhead ()
3722 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3724 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3725 set_follow_playhead (tact->get_active());
3730 Editor::set_follow_playhead (bool yn)
3732 if (_follow_playhead != yn) {
3733 if ((_follow_playhead = yn) == true) {
3735 update_current_screen ();
3742 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
3744 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3746 xfade->set_active (!xfade->active());
3751 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
3753 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3755 xfade->set_follow_overlap (!xfade->following_overlap());
3760 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
3762 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3768 CrossfadeEditor cew (*session, xfade, xfade->fade_in().get_min_y(), 1.0);
3772 switch (cew.run ()) {
3773 case RESPONSE_ACCEPT:
3780 xfade->StateChanged (Change (~0));
3784 Editor::playlist_selector () const
3786 return *_playlist_selector;
3790 Editor::get_grid_type_as_beats (bool& success, nframes64_t position)
3794 switch (_snap_type) {
3799 case SnapToAThirtysecondBeat:
3803 case SnapToASixteenthBeat:
3807 case SnapToAEighthBeat:
3811 case SnapToAQuarterBeat:
3815 case SnapToAThirdBeat:
3821 return session->tempo_map().meter_at (position).beats_per_bar();
3826 case SnapToTimecodeFrame:
3827 case SnapToTimecodeSeconds:
3828 case SnapToTimecodeMinutes:
3831 case SnapToRegionStart:
3832 case SnapToRegionEnd:
3833 case SnapToRegionSync:
3834 case SnapToRegionBoundary:
3844 Editor::get_nudge_distance (nframes64_t pos, nframes64_t& next)
3848 ret = nudge_clock.current_duration (pos);
3849 next = ret + 1; /* XXXX fix me */
3855 Editor::end_location_changed (Location* location)
3857 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3858 //reset_scrolling_region ();
3859 nframes64_t session_span = location->start() + (nframes64_t) floorf (current_page_frames() * 0.10f);
3860 horizontal_adjustment.set_upper (session_span / frames_per_unit);
3864 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
3866 ArdourDialog dialog ("playlist deletion dialog");
3867 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3868 "If left alone, no audio files used by it will be cleaned.\n"
3869 "If deleted, audio files used by it alone by will cleaned."),
3872 dialog.set_position (WIN_POS_CENTER);
3873 dialog.get_vbox()->pack_start (label);
3877 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3878 dialog.add_button (_("Keep playlist"), RESPONSE_REJECT);
3879 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3881 switch (dialog.run ()) {
3882 case RESPONSE_ACCEPT:
3883 /* delete the playlist */
3887 case RESPONSE_REJECT:
3888 /* keep the playlist */
3900 Editor::audio_region_selection_covers (nframes64_t where)
3902 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3903 if ((*a)->region()->covers (where)) {
3912 Editor::prepare_for_cleanup ()
3914 cut_buffer->clear_regions ();
3915 cut_buffer->clear_playlists ();
3917 selection->clear_regions ();
3918 selection->clear_playlists ();
3920 _regions->suspend_redisplay ();
3924 Editor::finish_cleanup ()
3926 _regions->resume_redisplay ();
3930 Editor::transport_loop_location()
3933 return session->locations()->auto_loop_location();
3940 Editor::transport_punch_location()
3943 return session->locations()->auto_punch_location();
3950 Editor::control_layout_scroll (GdkEventScroll* ev)
3952 switch (ev->direction) {
3954 scroll_tracks_up_line ();
3958 case GDK_SCROLL_DOWN:
3959 scroll_tracks_down_line ();
3963 /* no left/right handling yet */
3971 Editor::session_state_saved (string snap_name)
3973 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
3975 _snapshots->redisplay ();
3979 Editor::maximise_editing_space ()
3981 mouse_mode_tearoff->set_visible (false);
3982 tools_tearoff->set_visible (false);
3984 pre_maximal_pane_position = edit_pane.get_position();
3985 pre_maximal_editor_width = this->get_width();
3987 if(post_maximal_pane_position == 0) {
3988 post_maximal_pane_position = edit_pane.get_width();
3993 if(post_maximal_editor_width) {
3994 edit_pane.set_position (post_maximal_pane_position -
3995 abs(post_maximal_editor_width - pre_maximal_editor_width));
3997 edit_pane.set_position (post_maximal_pane_position);
4002 Editor::restore_editing_space ()
4004 // user changed width of pane during fullscreen
4006 if(post_maximal_pane_position != edit_pane.get_position()) {
4007 post_maximal_pane_position = edit_pane.get_position();
4012 mouse_mode_tearoff->set_visible (true);
4013 tools_tearoff->set_visible (true);
4014 post_maximal_editor_width = this->get_width();
4016 edit_pane.set_position (pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width));
4020 * Make new playlists for a given track and also any others that belong
4021 * to the same active route group with the `edit' property.
4026 Editor::new_playlists (TimeAxisView* v)
4028 begin_reversible_command (_("new playlists"));
4029 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4030 session->playlists->get (playlists);
4031 mapover_tracks (bind (mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v, RouteGroup::Edit);
4032 commit_reversible_command ();
4036 * Use a copy of the current playlist for a given track and also any others that belong
4037 * to the same active route group with the `edit' property.
4042 Editor::copy_playlists (TimeAxisView* v)
4044 begin_reversible_command (_("copy playlists"));
4045 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4046 session->playlists->get (playlists);
4047 mapover_tracks (bind (mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v, RouteGroup::Edit);
4048 commit_reversible_command ();
4051 /** Clear the current playlist for a given track and also any others that belong
4052 * to the same active route group with the `edit' property.
4057 Editor::clear_playlists (TimeAxisView* v)
4059 begin_reversible_command (_("clear playlists"));
4060 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4061 session->playlists->get (playlists);
4062 mapover_tracks (mem_fun (*this, &Editor::mapped_clear_playlist), v, RouteGroup::Edit);
4063 commit_reversible_command ();
4067 Editor::mapped_use_new_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4069 atv.use_new_playlist (sz > 1 ? false : true, playlists);
4073 Editor::mapped_use_copy_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4075 atv.use_copy_playlist (sz > 1 ? false : true, playlists);
4079 Editor::mapped_clear_playlist (RouteTimeAxisView& atv, uint32_t /*sz*/)
4081 atv.clear_playlist ();
4085 Editor::on_key_press_event (GdkEventKey* ev)
4087 return key_press_focus_accelerator_handler (*this, ev);
4091 Editor::on_key_release_event (GdkEventKey* ev)
4093 return Gtk::Window::on_key_release_event (ev);
4094 // return key_press_focus_accelerator_handler (*this, ev);
4098 Editor::reset_x_origin (nframes64_t frame)
4100 //cerr << "resetting x origin" << endl;
4101 queue_visual_change (frame);
4105 Editor::reset_y_origin (double y)
4107 queue_visual_change_y (y);
4111 Editor::reset_zoom (double fpu)
4113 queue_visual_change (fpu);
4117 Editor::reposition_and_zoom (nframes64_t frame, double fpu)
4119 //cerr << "Editor::reposition_and_zoom () called ha v:l:u:ps:fpu = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << frames_per_unit << endl;//DEBUG
4120 reset_x_origin (frame);
4123 if (!no_save_visual) {
4124 undo_visual_stack.push_back (current_visual_state(false));
4128 Editor::VisualState*
4129 Editor::current_visual_state (bool with_tracks)
4131 VisualState* vs = new VisualState;
4132 vs->y_position = vertical_adjustment.get_value();
4133 vs->frames_per_unit = frames_per_unit;
4134 vs->leftmost_frame = leftmost_frame;
4135 vs->zoom_focus = zoom_focus;
4138 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4139 vs->track_states.push_back (TAVState ((*i), &(*i)->get_state()));
4147 Editor::undo_visual_state ()
4149 if (undo_visual_stack.empty()) {
4153 VisualState* vs = undo_visual_stack.back();
4154 undo_visual_stack.pop_back();
4155 use_visual_state (*vs);
4156 redo_visual_stack.push_back (vs);
4160 Editor::redo_visual_state ()
4162 if (redo_visual_stack.empty()) {
4166 VisualState* vs = redo_visual_stack.back();
4167 redo_visual_stack.pop_back();
4168 use_visual_state (*vs);
4169 undo_visual_stack.push_back (vs);
4173 Editor::swap_visual_state ()
4175 if (undo_visual_stack.empty()) {
4176 redo_visual_state ();
4178 undo_visual_state ();
4183 Editor::use_visual_state (VisualState& vs)
4185 no_save_visual = true;
4187 _routes->suspend_redisplay ();
4189 vertical_adjustment.set_value (vs.y_position);
4191 set_zoom_focus (vs.zoom_focus);
4192 reposition_and_zoom (vs.leftmost_frame, vs.frames_per_unit);
4194 for (list<TAVState>::iterator i = vs.track_states.begin(); i != vs.track_states.end(); ++i) {
4195 TrackViewList::iterator t;
4197 /* check if the track still exists - it could have been deleted */
4199 if ((t = find (track_views.begin(), track_views.end(), i->first)) != track_views.end()) {
4200 (*t)->set_state (*(i->second), Stateful::loading_state_version);
4205 if (!vs.track_states.empty()) {
4206 _routes->update_visibility ();
4209 _routes->resume_redisplay ();
4211 no_save_visual = false;
4215 Editor::set_frames_per_unit (double fpu)
4217 /* this is the core function that controls the zoom level of the canvas. it is called
4218 whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
4221 if (fpu == frames_per_unit) {
4230 /* don't allow zooms that fit more than the maximum number
4231 of frames into an 800 pixel wide space.
4234 if (max_frames / fpu < 800.0) {
4239 tempo_lines->tempo_map_changed();
4241 frames_per_unit = fpu;
4246 Editor::post_zoom ()
4248 nframes64_t cef = 0;
4250 // convert fpu to frame count
4252 nframes64_t frames = (nframes64_t) floor (frames_per_unit * _canvas_width);
4254 if (frames_per_unit != zoom_range_clock.current_duration()) {
4255 zoom_range_clock.set (frames);
4258 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
4259 if (!selection->tracks.empty()) {
4260 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4261 (*i)->reshow_selection (selection->time);
4264 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4265 (*i)->reshow_selection (selection->time);
4270 leftmost_frame = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4272 ZoomChanged (); /* EMIT_SIGNAL */
4275 cef = session->current_end_frame() + (current_page_frames() / 10);// Add a little extra so we can see the end marker
4277 horizontal_adjustment.set_upper (cef / frames_per_unit);
4279 //reset_scrolling_region ();
4281 if (playhead_cursor) {
4282 playhead_cursor->set_position (playhead_cursor->current_frame);
4285 refresh_location_display();
4286 _summary->set_overlays_dirty ();
4292 Editor::queue_visual_change (nframes64_t where)
4294 pending_visual_change.add (VisualChange::TimeOrigin);
4296 /* if we're moving beyond the end, make sure the upper limit of the horizontal adjustment
4300 if (session && (where > session->current_end_frame())) {
4301 horizontal_adjustment.set_upper ((where + current_page_frames()) / frames_per_unit);
4304 pending_visual_change.time_origin = where;
4306 ensure_visual_change_idle_handler ();
4310 Editor::queue_visual_change (double fpu)
4312 pending_visual_change.add (VisualChange::ZoomLevel);
4313 pending_visual_change.frames_per_unit = fpu;
4315 ensure_visual_change_idle_handler ();
4319 Editor::queue_visual_change_y (double y)
4321 pending_visual_change.add (VisualChange::YOrigin);
4322 pending_visual_change.y_origin = y;
4324 ensure_visual_change_idle_handler ();
4328 Editor::ensure_visual_change_idle_handler ()
4330 if (pending_visual_change.idle_handler_id < 0) {
4331 pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
4336 Editor::_idle_visual_changer (void* arg)
4338 return static_cast<Editor*>(arg)->idle_visual_changer ();
4342 Editor::idle_visual_changer ()
4344 VisualChange::Type p = pending_visual_change.pending;
4345 pending_visual_change.pending = (VisualChange::Type) 0;
4347 double last_time_origin = horizontal_adjustment.get_value();
4349 if (p & VisualChange::ZoomLevel) {
4350 set_frames_per_unit (pending_visual_change.frames_per_unit);
4352 compute_fixed_ruler_scale ();
4353 compute_current_bbt_points(pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4354 compute_bbt_ruler_scale (pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4355 update_tempo_based_rulers ();
4357 if (p & VisualChange::TimeOrigin) {
4358 horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
4360 if (p & VisualChange::YOrigin) {
4361 vertical_adjustment.set_value (pending_visual_change.y_origin);
4364 nframes64_t csf=0, cef=0;
4365 nframes64_t current_time_origin = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4368 csf = session->current_start_frame();
4369 cef = session->current_end_frame();
4372 /* if we seek beyond the current end of the canvas, move the end */
4375 if (last_time_origin == horizontal_adjustment.get_value() ) {
4376 /* changed signal not emitted */
4377 update_fixed_rulers ();
4378 redisplay_tempo (true);
4381 if (current_time_origin != pending_visual_change.time_origin) {
4382 cef += current_page_frames() / 10; // Add a little extra so we can see the end marker
4383 horizontal_adjustment.set_upper (cef / frames_per_unit);
4384 horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
4386 update_fixed_rulers();
4387 redisplay_tempo (true);
4390 _summary->set_overlays_dirty ();
4392 // cerr << "Editor::idle_visual_changer () called ha v:l:u:ps:fpu = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << frames_per_unit << endl;//DEBUG
4393 pending_visual_change.idle_handler_id = -1;
4394 return 0; /* this is always a one-shot call */
4397 struct EditorOrderTimeAxisSorter {
4398 bool operator() (const TimeAxisView* a, const TimeAxisView* b) const {
4399 return a->order () < b->order ();
4404 Editor::sort_track_selection (TrackSelection* sel)
4406 EditorOrderTimeAxisSorter cmp;
4411 selection->tracks.sort (cmp);
4416 Editor::get_preferred_edit_position (bool ignore_playhead)
4419 nframes64_t where = 0;
4420 EditPoint ep = _edit_point;
4422 if (entered_marker) {
4423 return entered_marker->position();
4426 if (ignore_playhead && ep == EditAtPlayhead) {
4427 ep = EditAtSelectedMarker;
4431 case EditAtPlayhead:
4432 where = session->audible_frame();
4435 case EditAtSelectedMarker:
4436 if (!selection->markers.empty()) {
4438 Location* loc = find_location_from_marker (selection->markers.front(), is_start);
4441 where = loc->start();
4452 if (!mouse_frame (where, ignored)) {
4453 /* XXX not right but what can we do ? */
4464 Editor::set_loop_range (nframes64_t start, nframes64_t end, string cmd)
4466 if (!session) return;
4468 begin_reversible_command (cmd);
4472 if ((tll = transport_loop_location()) == 0) {
4473 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoLoop);
4474 XMLNode &before = session->locations()->get_state();
4475 session->locations()->add (loc, true);
4476 session->set_auto_loop_location (loc);
4477 XMLNode &after = session->locations()->get_state();
4478 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4480 XMLNode &before = tll->get_state();
4481 tll->set_hidden (false, this);
4482 tll->set (start, end);
4483 XMLNode &after = tll->get_state();
4484 session->add_command (new MementoCommand<Location>(*tll, &before, &after));
4487 commit_reversible_command ();
4491 Editor::set_punch_range (nframes64_t start, nframes64_t end, string cmd)
4493 if (!session) return;
4495 begin_reversible_command (cmd);
4499 if ((tpl = transport_punch_location()) == 0) {
4500 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoPunch);
4501 XMLNode &before = session->locations()->get_state();
4502 session->locations()->add (loc, true);
4503 session->set_auto_loop_location (loc);
4504 XMLNode &after = session->locations()->get_state();
4505 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4508 XMLNode &before = tpl->get_state();
4509 tpl->set_hidden (false, this);
4510 tpl->set (start, end);
4511 XMLNode &after = tpl->get_state();
4512 session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
4515 commit_reversible_command ();
4518 /** Find regions which exist at a given time, and optionally on a given list of tracks.
4519 * @param rs List to which found regions are added.
4520 * @param where Time to look at.
4521 * @param ts Tracks to look on; if this is empty, all tracks are examined.
4524 Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4526 const TrackSelection* tracks;
4529 tracks = &track_views;
4534 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4535 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4537 boost::shared_ptr<Diskstream> ds;
4538 boost::shared_ptr<Playlist> pl;
4540 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
4542 Playlist::RegionList* regions = pl->regions_at (
4543 (nframes64_t) floor ( (double)where * ds->speed()));
4545 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4546 RegionView* rv = rtv->view()->find_view (*i);
4559 Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4561 const TrackSelection* tracks;
4564 tracks = &track_views;
4569 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4570 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4572 boost::shared_ptr<Diskstream> ds;
4573 boost::shared_ptr<Playlist> pl;
4575 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
4577 Playlist::RegionList* regions = pl->regions_touched (
4578 (nframes64_t) floor ( (double)where * ds->speed()), max_frames);
4580 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4582 RegionView* rv = rtv->view()->find_view (*i);
4595 /** Find all regions which are either:
4597 * - the entered_regionview (if allow_entered == true) or
4598 * - under the preferred edit position AND on a selected track, or on a track
4599 * which is in the same active edit-enable route group as a selected region (if allow_edit_position == true)
4600 * @param rs Returned region list.
4601 * @param allow_entered true to include the entered_regionview in the list.
4604 Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered, bool allow_edit_position)
4606 /* Start with selected regions */
4607 rs = selection->regions;
4609 /* Add the entered_regionview, if requested */
4610 if (allow_entered && entered_regionview) {
4611 rs.add (entered_regionview);
4614 if (allow_edit_position) {
4616 TrackSelection tracks = selection->tracks;
4618 /* tracks is currently the set of selected tracks; add any other tracks that
4619 * have regions that are in the same edit-activated route group as one of
4621 for (RegionSelection::iterator i = rs.begin (); i != rs.end(); ++i) {
4623 RouteGroup* g = (*i)->get_time_axis_view().route_group ();
4624 if (g && g->active_property (RouteGroup::Edit)) {
4625 tracks.add (axis_views_from_routes (g->route_list()));
4629 /* now find regions that are at the edit position on those tracks */
4630 nframes64_t const where = get_preferred_edit_position ();
4631 get_regions_at (rs, where, tracks);
4636 Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<RegionView*>& regions)
4638 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4640 RouteTimeAxisView* tatv;
4642 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
4644 boost::shared_ptr<Playlist> pl;
4645 vector<boost::shared_ptr<Region> > results;
4647 boost::shared_ptr<Diskstream> ds;
4649 if ((ds = tatv->get_diskstream()) == 0) {
4654 if ((pl = (ds->playlist())) != 0) {
4655 pl->get_region_list_equivalent_regions (region, results);
4658 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
4659 if ((marv = tatv->view()->find_view (*ir)) != 0) {
4660 regions.push_back (marv);
4669 Editor::show_rhythm_ferret ()
4671 if (rhythm_ferret == 0) {
4672 rhythm_ferret = new RhythmFerret(*this);
4675 rhythm_ferret->set_session (session);
4676 rhythm_ferret->show ();
4677 rhythm_ferret->present ();
4681 Editor::show_global_port_matrix (ARDOUR::DataType t)
4683 if (_global_port_matrix[t] == 0) {
4684 _global_port_matrix[t] = new GlobalPortMatrixWindow (*session, t);
4687 _global_port_matrix[t]->show ();
4691 Editor::first_idle ()
4693 MessageDialog* dialog = 0;
4695 if (track_views.size() > 1) {
4696 dialog = new MessageDialog (*this,
4697 _("Please wait while Ardour loads visual data"),
4702 ARDOUR_UI::instance()->flush_pending ();
4705 for (TrackViewList::iterator t = track_views.begin(); t != track_views.end(); ++t) {
4709 // first idle adds route children (automation tracks), so we need to redisplay here
4710 _routes->redisplay ();
4718 _idle_resizer (gpointer arg)
4720 return ((Editor*)arg)->idle_resize ();
4724 Editor::add_to_idle_resize (TimeAxisView* view, int32_t h)
4726 if (resize_idle_id < 0) {
4727 resize_idle_id = g_idle_add (_idle_resizer, this);
4728 _pending_resize_amount = 0;
4731 /* make a note of the smallest resulting height, so that we can clamp the
4732 lower limit at TimeAxisView::hSmall */
4734 int32_t min_resulting = INT32_MAX;
4736 _pending_resize_amount += h;
4737 _pending_resize_view = view;
4739 min_resulting = min (min_resulting, int32_t (_pending_resize_view->current_height()) + _pending_resize_amount);
4741 if (selection->tracks.contains (_pending_resize_view)) {
4742 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4743 min_resulting = min (min_resulting, int32_t ((*i)->current_height()) + _pending_resize_amount);
4747 if (min_resulting < 0) {
4752 if (uint32_t (min_resulting) < TimeAxisView::hSmall) {
4753 _pending_resize_amount += TimeAxisView::hSmall - min_resulting;
4757 /** Handle pending resizing of tracks */
4759 Editor::idle_resize ()
4761 _pending_resize_view->idle_resize (_pending_resize_view->current_height() + _pending_resize_amount);
4763 if (dynamic_cast<AutomationTimeAxisView*> (_pending_resize_view) == 0 &&
4764 selection->tracks.contains (_pending_resize_view)) {
4766 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4767 if (*i != _pending_resize_view) {
4768 (*i)->idle_resize ((*i)->current_height() + _pending_resize_amount);
4774 _group_tabs->set_dirty ();
4775 resize_idle_id = -1;
4783 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::located));
4785 _pending_locate_request = false;
4789 Editor::region_view_added (RegionView *)
4791 _summary->set_dirty ();
4795 Editor::streamview_height_changed ()
4797 _summary->set_dirty ();
4801 Editor::axis_view_from_route (Route* r) const
4803 TrackViewList::const_iterator j = track_views.begin ();
4804 while (j != track_views.end()) {
4805 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*j);
4806 if (rtv && rtv->route().get() == r) {
4817 Editor::axis_views_from_routes (list<Route*> r) const
4821 for (list<Route*>::const_iterator i = r.begin(); i != r.end(); ++i) {
4822 TimeAxisView* tv = axis_view_from_route (*i);
4833 Editor::handle_new_route (RouteList& routes)
4835 ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_route), routes));
4837 RouteTimeAxisView *rtv;
4838 list<RouteTimeAxisView*> new_views;
4840 for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) {
4841 boost::shared_ptr<Route> route = (*x);
4843 if (route->is_hidden()) {
4847 DataType dt = route->input()->default_type();
4849 if (dt == ARDOUR::DataType::AUDIO) {
4850 rtv = new AudioTimeAxisView (*this, *session, route, *track_canvas);
4851 } else if (dt == ARDOUR::DataType::MIDI) {
4852 rtv = new MidiTimeAxisView (*this, *session, route, *track_canvas);
4854 throw unknown_type();
4857 new_views.push_back (rtv);
4858 track_views.push_back (rtv);
4860 rtv->effective_gain_display ();
4862 rtv->view()->RegionViewAdded.connect (mem_fun (*this, &Editor::region_view_added));
4863 rtv->view()->HeightChanged.connect (mem_fun (*this, &Editor::streamview_height_changed));
4865 rtv->GoingAway.connect (bind (mem_fun(*this, &Editor::remove_route), rtv));
4868 _routes->routes_added (new_views);
4870 if (show_editor_mixer_when_tracks_arrive) {
4871 show_editor_mixer (true);
4874 editor_list_button.set_sensitive (true);
4876 _summary->set_dirty ();
4880 Editor::remove_route (TimeAxisView *tv)
4882 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::remove_route), tv));
4884 TrackViewList::iterator i;
4886 boost::shared_ptr<Route> route;
4887 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (tv);
4889 route = rtav->route ();
4892 TimeAxisView* next_tv = 0;
4894 if (tv == entered_track) {
4898 if ((i = find (track_views.begin(), track_views.end(), tv)) != track_views.end()) {
4900 i = track_views.erase (i);
4902 if (track_views.empty()) {
4904 } else if (i == track_views.end()) {
4905 next_tv = track_views.front();
4911 if (current_mixer_strip && current_mixer_strip->route() == route) {
4914 set_selected_mixer_strip (*next_tv);
4916 /* make the editor mixer strip go away setting the
4917 * button to inactive (which also unticks the menu option)
4920 ActionManager::uncheck_toggleaction ("<Actions>/Editor/show-editor-mixer");
4926 Editor::hide_track_in_display (TimeAxisView& tv, bool /*temponly*/)
4928 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (&tv);
4930 if (rtv && current_mixer_strip && (rtv->route() == current_mixer_strip->route())) {
4931 // this will hide the mixer strip
4932 set_selected_mixer_strip (tv);
4935 _routes->hide_track_in_display (tv);
4939 Editor::sync_track_view_list_and_routes ()
4941 track_views = TrackSelection (_routes->views ());
4943 _summary->set_dirty ();
4944 _group_tabs->set_dirty ();
4946 return false; // do not call again (until needed)
4950 Editor::foreach_time_axis_view (sigc::slot<void,TimeAxisView&> theslot)
4952 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4958 Editor::get_route_view_by_id (PBD::ID& id)
4960 RouteTimeAxisView* v;
4962 for(TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4963 if((v = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) {
4964 if(v->route()->id() == id) {
4974 Editor::fit_route_group (RouteGroup *g)
4976 TrackSelection ts = axis_views_from_routes (g->route_list ());
4981 Editor::consider_auditioning (boost::shared_ptr<Region> region)
4983 boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion> (region);
4986 session->cancel_audition ();
4990 if (session->is_auditioning()) {
4991 session->cancel_audition ();
4992 if (r == last_audition_region) {
4997 session->audition_region (r);
4998 last_audition_region = r;
5003 Editor::hide_a_region (boost::shared_ptr<Region> r)
5005 r->set_hidden (true);
5009 Editor::remove_a_region (boost::shared_ptr<Region> r)
5011 session->remove_region_from_region_list (r);
5015 Editor::audition_region_from_region_list ()
5017 _regions->selection_mapover (mem_fun (*this, &Editor::consider_auditioning));
5021 Editor::hide_region_from_region_list ()
5023 _regions->selection_mapover (mem_fun (*this, &Editor::hide_a_region));
5027 Editor::start_step_editing ()
5029 step_edit_connection = Glib::signal_timeout().connect (mem_fun (*this, &Editor::check_step_edit), 20);
5033 Editor::stop_step_editing ()
5035 step_edit_connection.disconnect ();
5039 Editor::check_step_edit ()
5041 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5042 MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*> (*i);
5044 mtv->check_step_edit ();
5048 return true; // do it again, till we stop
5052 Editor::horizontal_scroll_left ()
5054 double x = leftmost_position() - current_page_frames() / 5;
5063 Editor::horizontal_scroll_right ()
5065 reset_x_origin (leftmost_position() + current_page_frames() / 5);