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"
69 #include "control_protocol/control_protocol.h"
71 #include "ardour_ui.h"
75 #include "playlist_selector.h"
76 #include "audio_region_view.h"
77 #include "rgb_macros.h"
78 #include "selection.h"
79 #include "audio_streamview.h"
80 #include "time_axis_view.h"
81 #include "audio_time_axis.h"
83 #include "crossfade_view.h"
85 #include "public_editor.h"
86 #include "crossfade_edit.h"
87 #include "canvas_impl.h"
90 #include "gui_thread.h"
91 #include "simpleline.h"
92 #include "rhythm_ferret.h"
94 #include "tempo_lines.h"
95 #include "analysis_window.h"
96 #include "bundle_manager.h"
97 #include "global_port_matrix.h"
98 #include "editor_drag.h"
99 #include "editor_group_tabs.h"
100 #include "automation_time_axis.h"
101 #include "editor_routes.h"
102 #include "midi_time_axis.h"
103 #include "mixer_strip.h"
104 #include "editor_route_groups.h"
105 #include "editor_regions.h"
106 #include "editor_locations.h"
107 #include "editor_snapshots.h"
112 #include "imageframe_socket_handler.h"
116 using namespace sigc;
117 using namespace ARDOUR;
120 using namespace Glib;
121 using namespace Gtkmm2ext;
122 using namespace Editing;
124 using PBD::internationalize;
127 const double Editor::timebar_height = 15.0;
129 #include "editor_xpms"
131 static const gchar *_snap_type_strings[] = {
133 N_("Timecode Frames"),
134 N_("Timecode Seconds"),
135 N_("Timecode Minutes"),
153 static const gchar *_snap_mode_strings[] = {
160 static const gchar *_edit_point_strings[] = {
167 static const gchar *_zoom_focus_strings[] = {
177 #ifdef USE_RUBBERBAND
178 static const gchar *_rb_opt_strings[] = {
181 N_("Balanced multitimbral mixture"),
182 N_("Unpitched percussion with stable notes"),
183 N_("Crisp monophonic instrumental"),
184 N_("Unpitched solo percussion"),
189 /* Soundfile drag-n-drop */
191 Gdk::Cursor* Editor::cross_hair_cursor = 0;
192 Gdk::Cursor* Editor::selector_cursor = 0;
193 Gdk::Cursor* Editor::trimmer_cursor = 0;
194 Gdk::Cursor* Editor::grabber_cursor = 0;
195 Gdk::Cursor* Editor::grabber_edit_point_cursor = 0;
196 Gdk::Cursor* Editor::zoom_cursor = 0;
197 Gdk::Cursor* Editor::time_fx_cursor = 0;
198 Gdk::Cursor* Editor::fader_cursor = 0;
199 Gdk::Cursor* Editor::speaker_cursor = 0;
200 Gdk::Cursor* Editor::midi_pencil_cursor = 0;
201 Gdk::Cursor* Editor::midi_select_cursor = 0;
202 Gdk::Cursor* Editor::midi_resize_cursor = 0;
203 Gdk::Cursor* Editor::midi_erase_cursor = 0;
204 Gdk::Cursor* Editor::wait_cursor = 0;
205 Gdk::Cursor* Editor::timebar_cursor = 0;
206 Gdk::Cursor* Editor::transparent_cursor = 0;
209 show_me_the_size (Requisition* r, const char* what)
211 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
215 /* time display buttons */
216 : minsec_label (_("Mins:Secs"))
217 , bbt_label (_("Bars:Beats"))
218 , timecode_label (_("Timecode"))
219 , frame_label (_("Samples"))
220 , tempo_label (_("Tempo"))
221 , meter_label (_("Meter"))
222 , mark_label (_("Location Markers"))
223 , range_mark_label (_("Range Markers"))
224 , transport_mark_label (_("Loop/Punch Ranges"))
225 , cd_mark_label (_("CD Markers"))
226 , edit_packer (4, 4, true)
228 /* the values here don't matter: layout widgets
229 reset them as needed.
232 , vertical_adjustment (0.0, 0.0, 10.0, 400.0)
233 , horizontal_adjustment (0.0, 0.0, 20.0, 1200.0)
235 /* tool bar related */
237 , edit_point_clock (X_("editpoint"), false, X_("EditPointClock"), true)
238 , zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true)
240 , toolbar_selection_clock_table (2,3)
242 , automation_mode_button (_("mode"))
243 , global_automation_button (_("automation"))
245 , midi_panic_button (_("Panic"))
248 , image_socket_listener(0)
253 , nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true)
254 , meters_running(false)
255 , _pending_locate_request (false)
260 /* we are a singleton */
262 PublicEditor::_instance = this;
267 selection = new Selection (this);
268 cut_buffer = new Selection (this);
270 clicked_regionview = 0;
271 clicked_axisview = 0;
272 clicked_routeview = 0;
273 clicked_crossfadeview = 0;
274 clicked_control_point = 0;
275 last_update_frame = 0;
277 current_mixer_strip = 0;
278 current_bbt_points = 0;
281 snap_type_strings = I18N (_snap_type_strings);
282 snap_mode_strings = I18N (_snap_mode_strings);
283 zoom_focus_strings = I18N (_zoom_focus_strings);
284 edit_point_strings = I18N (_edit_point_strings);
285 #ifdef USE_RUBBERBAND
286 rb_opt_strings = I18N (_rb_opt_strings);
289 snap_threshold = 5.0;
290 bbt_beat_subdivision = 4;
293 last_autoscroll_x = 0;
294 last_autoscroll_y = 0;
295 autoscroll_active = false;
296 autoscroll_timeout_tag = -1;
297 interthread_progress_window = 0;
302 current_interthread_info = 0;
303 _show_measures = true;
304 _show_waveforms_recording = true;
305 show_gain_after_trim = false;
306 verbose_cursor_on = true;
307 route_removal = false;
308 last_item_entered = 0;
309 last_item_entered_n = 0;
311 have_pending_keyboard_selection = false;
312 _follow_playhead = true;
313 _xfade_visibility = true;
314 editor_ruler_menu = 0;
315 no_ruler_shown_update = false;
317 start_end_marker_menu = 0;
318 range_marker_menu = 0;
319 marker_menu_item = 0;
321 transport_marker_menu = 0;
322 new_transport_marker_menu = 0;
323 editor_mixer_strip_width = Wide;
324 show_editor_mixer_when_tracks_arrive = false;
325 region_edit_menu_split_multichannel_item = 0;
326 region_edit_menu_split_item = 0;
329 current_stepping_trackview = 0;
331 entered_regionview = 0;
333 clear_entered_track = false;
334 _new_regionviews_show_envelope = false;
337 button_release_can_deselect = true;
338 _dragging_playhead = false;
339 _dragging_edit_point = false;
340 _dragging_hscrollbar = 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 () */
366 reset_hscrollbar_stepping ();
368 zoom_focus = ZoomFocusLeft;
369 set_zoom_focus (ZoomFocusLeft);
370 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
372 bbt_label.set_name ("EditorTimeButton");
373 bbt_label.set_size_request (-1, (int)timebar_height);
374 bbt_label.set_alignment (1.0, 0.5);
375 bbt_label.set_padding (5,0);
377 bbt_label.set_no_show_all();
378 minsec_label.set_name ("EditorTimeButton");
379 minsec_label.set_size_request (-1, (int)timebar_height);
380 minsec_label.set_alignment (1.0, 0.5);
381 minsec_label.set_padding (5,0);
382 minsec_label.hide ();
383 minsec_label.set_no_show_all();
384 timecode_label.set_name ("EditorTimeButton");
385 timecode_label.set_size_request (-1, (int)timebar_height);
386 timecode_label.set_alignment (1.0, 0.5);
387 timecode_label.set_padding (5,0);
388 timecode_label.hide ();
389 timecode_label.set_no_show_all();
390 frame_label.set_name ("EditorTimeButton");
391 frame_label.set_size_request (-1, (int)timebar_height);
392 frame_label.set_alignment (1.0, 0.5);
393 frame_label.set_padding (5,0);
395 frame_label.set_no_show_all();
397 tempo_label.set_name ("EditorTimeButton");
398 tempo_label.set_size_request (-1, (int)timebar_height);
399 tempo_label.set_alignment (1.0, 0.5);
400 tempo_label.set_padding (5,0);
402 tempo_label.set_no_show_all();
403 meter_label.set_name ("EditorTimeButton");
404 meter_label.set_size_request (-1, (int)timebar_height);
405 meter_label.set_alignment (1.0, 0.5);
406 meter_label.set_padding (5,0);
408 meter_label.set_no_show_all();
409 mark_label.set_name ("EditorTimeButton");
410 mark_label.set_size_request (-1, (int)timebar_height);
411 mark_label.set_alignment (1.0, 0.5);
412 mark_label.set_padding (5,0);
414 mark_label.set_no_show_all();
415 cd_mark_label.set_name ("EditorTimeButton");
416 cd_mark_label.set_size_request (-1, (int)timebar_height);
417 cd_mark_label.set_alignment (1.0, 0.5);
418 cd_mark_label.set_padding (5,0);
419 cd_mark_label.hide();
420 cd_mark_label.set_no_show_all();
421 range_mark_label.set_name ("EditorTimeButton");
422 range_mark_label.set_size_request (-1, (int)timebar_height);
423 range_mark_label.set_alignment (1.0, 0.5);
424 range_mark_label.set_padding (5,0);
425 range_mark_label.hide();
426 range_mark_label.set_no_show_all();
427 transport_mark_label.set_name ("EditorTimeButton");
428 transport_mark_label.set_size_request (-1, (int)timebar_height);
429 transport_mark_label.set_alignment (1.0, 0.5);
430 transport_mark_label.set_padding (5,0);
431 transport_mark_label.hide();
432 transport_mark_label.set_no_show_all();
434 initialize_rulers ();
435 _summary = new EditorSummary (this);
436 initialize_canvas ();
438 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
439 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
440 editor_regions_selection_changed_connection = selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
441 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
442 selection->MarkersChanged.connect (mem_fun(*this, &Editor::marker_selection_changed));
444 edit_controls_vbox.set_spacing (0);
445 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::scroll_canvas_horizontally), false);
446 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling), true);
447 track_canvas->signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
449 HBox* h = manage (new HBox);
450 _group_tabs = new EditorGroupTabs (this);
451 h->pack_start (*_group_tabs, PACK_SHRINK);
452 h->pack_start (edit_controls_vbox);
453 controls_layout.add (*h);
455 controls_layout.set_name ("EditControlsBase");
456 controls_layout.add_events (Gdk::SCROLL_MASK);
457 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
459 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
460 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
461 controls_layout_size_request_connection = controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
463 edit_vscrollbar.set_adjustment (vertical_adjustment);
464 edit_hscrollbar.set_adjustment (horizontal_adjustment);
466 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press), false);
467 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release), false);
468 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
470 edit_hscrollbar.set_name ("EditorHScrollbar");
474 edit_point_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_point_clock_changed));
476 ArdourCanvas::Canvas* time_pad = manage(new ArdourCanvas::Canvas());
477 ArdourCanvas::SimpleLine* pad_line_1 = manage(new ArdourCanvas::SimpleLine(*time_pad->root(),
478 0.0, 1.0, 100.0, 1.0));
479 pad_line_1->property_color_rgba() = 0xFF0000FF;
483 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars) + 2);
484 time_canvas_vbox.set_size_request (-1, -1);
486 ruler_label_event_box.add (ruler_label_vbox);
487 ruler_label_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
488 ruler_label_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
490 time_button_event_box.add (time_button_vbox);
491 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
492 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
494 /* these enable us to have a dedicated window (for cursor setting, etc.)
495 for the canvas areas.
498 track_canvas_event_box.add (*track_canvas);
500 time_canvas_event_box.add (time_canvas_vbox);
501 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
503 edit_packer.set_col_spacings (0);
504 edit_packer.set_row_spacings (0);
505 edit_packer.set_homogeneous (false);
506 edit_packer.set_border_width (0);
507 edit_packer.set_name ("EditorWindow");
509 edit_packer.attach (zoom_vbox, 0, 1, 0, 2, SHRINK, FILL, 0, 0);
510 /* labels for the rulers */
511 edit_packer.attach (ruler_label_event_box, 1, 2, 0, 1, FILL, SHRINK, 0, 0);
512 /* labels for the marker "tracks" */
513 edit_packer.attach (time_button_event_box, 1, 2, 1, 2, FILL, SHRINK, 0, 0);
515 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
517 edit_packer.attach (controls_layout, 0, 2, 2, 3, FILL, FILL|EXPAND, 0, 0);
519 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 3, FILL|EXPAND, FILL|EXPAND, 0, 0);
521 bottom_hbox.set_border_width (2);
522 bottom_hbox.set_spacing (3);
524 _route_groups = new EditorRouteGroups (this);
525 _routes = new EditorRoutes (this);
526 _regions = new EditorRegions (this);
527 _snapshots = new EditorSnapshots (this);
528 _locations = new EditorLocations (this);
532 nlabel = manage (new Label (_("Regions")));
533 nlabel->set_angle (-90);
534 the_notebook.append_page (_regions->widget (), *nlabel);
535 nlabel = manage (new Label (_("Tracks/Busses")));
536 nlabel->set_angle (-90);
537 the_notebook.append_page (_routes->widget (), *nlabel);
538 nlabel = manage (new Label (_("Snapshots")));
539 nlabel->set_angle (-90);
540 the_notebook.append_page (_snapshots->widget (), *nlabel);
541 nlabel = manage (new Label (_("Route Groups")));
542 nlabel->set_angle (-90);
543 the_notebook.append_page (_route_groups->widget (), *nlabel);
544 nlabel = manage (new Label (_("Ranges & Marks")));
545 nlabel->set_angle (-90);
546 the_notebook.append_page (_locations->widget (), *nlabel);
548 the_notebook.set_show_tabs (true);
549 the_notebook.set_scrollable (true);
550 the_notebook.popup_enable ();
551 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
552 the_notebook.show_all ();
554 post_maximal_editor_width = 0;
555 post_maximal_pane_position = 0;
557 VPaned *editor_summary_pane = manage(new VPaned());
558 editor_summary_pane->pack1(edit_packer);
559 editor_summary_pane->pack2(*_summary);
561 edit_pane.pack1 (*editor_summary_pane, true, true);
562 edit_pane.pack2 (the_notebook, false, true);
564 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
566 top_hbox.pack_start (toolbar_frame, false, true);
568 HBox *hbox = manage (new HBox);
569 hbox->pack_start (edit_pane, true, true);
571 global_vpacker.pack_start (top_hbox, false, false);
572 global_vpacker.pack_start (*hbox, true, true);
574 global_hpacker.pack_start (global_vpacker, true, true);
576 set_name ("EditorWindow");
577 add_accel_group (ActionManager::ui_manager->get_accel_group());
579 status_bar_hpacker.show ();
581 vpacker.pack_end (status_bar_hpacker, false, false);
582 vpacker.pack_end (global_hpacker, true, true);
584 /* register actions now so that set_state() can find them and set toggles/checks etc */
589 setup_midi_toolbar ();
591 _snap_type = SnapToBeat;
592 set_snap_to (_snap_type);
593 _snap_mode = SnapOff;
594 set_snap_mode (_snap_mode);
595 set_mouse_mode (MouseObject, true);
596 set_edit_point_preference (EditAtMouse, true);
598 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
599 set_state (*node, Stateful::loading_state_version);
601 _playlist_selector = new PlaylistSelector();
602 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
604 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
608 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
609 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
611 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
612 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
614 nudge_forward_button.set_name ("TransportButton");
615 nudge_backward_button.set_name ("TransportButton");
617 fade_context_menu.set_name ("ArdourContextMenu");
619 /* icons, titles, WM stuff */
621 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
622 Glib::RefPtr<Gdk::Pixbuf> icon;
624 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
625 window_icons.push_back (icon);
627 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
628 window_icons.push_back (icon);
630 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
631 window_icons.push_back (icon);
633 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
634 window_icons.push_back (icon);
636 if (!window_icons.empty()) {
637 set_icon_list (window_icons);
638 set_default_icon_list (window_icons);
641 WindowTitle title(Glib::get_application_name());
642 title += _("Editor");
643 set_title (title.get_string());
644 set_wmclass (X_("ardour_editor"), "Ardour");
647 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
649 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
650 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
652 /* allow external control surfaces/protocols to do various things */
654 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
655 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
656 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
657 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
658 BasicUI::AccessAction.connect (mem_fun (*this, &Editor::access_action));
660 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
662 _last_normalization_value = 0;
671 if(image_socket_listener) {
672 if(image_socket_listener->is_connected())
674 image_socket_listener->close_connection() ;
677 delete image_socket_listener ;
678 image_socket_listener = 0 ;
683 delete _route_groups;
689 Editor::add_toplevel_controls (Container& cont)
691 vpacker.pack_start (cont, false, false);
696 Editor::catch_vanishing_regionview (RegionView *rv)
698 /* note: the selection will take care of the vanishing
699 audioregionview by itself.
702 if (_drag && rv->get_canvas_group() == _drag->item() && !_drag->ending()) {
708 if (clicked_regionview == rv) {
709 clicked_regionview = 0;
712 if (entered_regionview == rv) {
713 set_entered_regionview (0);
718 Editor::set_entered_regionview (RegionView* rv)
720 if (rv == entered_regionview) {
724 if (entered_regionview) {
725 entered_regionview->exited ();
728 if ((entered_regionview = rv) != 0) {
729 entered_regionview->entered ();
734 Editor::set_entered_track (TimeAxisView* tav)
737 entered_track->exited ();
740 if ((entered_track = tav) != 0) {
741 entered_track->entered ();
746 Editor::show_window ()
748 if (! is_visible ()) {
751 /* re-hide editor list if necessary */
752 editor_list_button_toggled ();
754 /* re-hide summary widget if necessary */
755 parameter_changed ("show-summary");
757 parameter_changed ("show-edit-group-tabs");
759 /* now reset all audio_time_axis heights, because widgets might need
765 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
766 tv = (static_cast<TimeAxisView*>(*i));
775 Editor::instant_save ()
777 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
782 session->add_instant_xml(get_state());
784 Config->add_instant_xml(get_state());
789 Editor::edit_point_clock_changed()
791 if (_dragging_edit_point) {
795 if (selection->markers.empty()) {
800 Location* loc = find_location_from_marker (selection->markers.front(), ignored);
806 loc->move_to (edit_point_clock.current_time());
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 edit_point_clock.set_mode(AudioClock::BBT);
1078 edit_point_clock.set_session (session);
1079 zoom_range_clock.set_session (session);
1080 _playlist_selector->set_session (session);
1081 nudge_clock.set_session (session);
1082 if (Profile->get_sae()) {
1087 nframes_t pos = session->tempo_map().bbt_duration_at (0, bbt, 1);
1088 nudge_clock.set_mode(AudioClock::BBT);
1089 nudge_clock.set (pos, true, 0, AudioClock::BBT);
1092 nudge_clock.set (session->frame_rate() * 5, true, 0, AudioClock::Timecode); // default of 5 seconds
1095 playhead_cursor->canvas_item.show ();
1097 if (rhythm_ferret) {
1098 rhythm_ferret->set_session (session);
1101 if (analysis_window != 0)
1102 analysis_window->set_session (session);
1104 Location* loc = session->locations()->auto_loop_location();
1106 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1107 if (loc->start() == loc->end()) {
1108 loc->set_end (loc->start() + 1);
1110 session->locations()->add (loc, false);
1111 session->set_auto_loop_location (loc);
1114 loc->set_name (_("Loop"));
1117 loc = session->locations()->auto_punch_location();
1119 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1120 if (loc->start() == loc->end()) {
1121 loc->set_end (loc->start() + 1);
1123 session->locations()->add (loc, false);
1124 session->set_auto_punch_location (loc);
1127 loc->set_name (_("Punch"));
1130 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1131 session->config.map_parameters (mem_fun (*this, &Editor::parameter_changed));
1133 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1135 refresh_location_display ();
1136 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1137 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1138 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1139 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1140 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1143 sfbrowser->set_session (session);
1146 handle_new_duration ();
1148 restore_ruler_visibility ();
1149 //tempo_map_changed (Change (0));
1150 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1152 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1153 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1158 switch (_snap_type) {
1159 case SnapToRegionStart:
1160 case SnapToRegionEnd:
1161 case SnapToRegionSync:
1162 case SnapToRegionBoundary:
1163 build_region_boundary_cache ();
1170 /* register for undo history */
1171 session->register_with_memento_command_factory(_id, this);
1173 _summary->connect_to_session (session);
1174 _group_tabs->connect_to_session (session);
1175 _route_groups->connect_to_session (session);
1176 _regions->connect_to_session (session);
1177 _snapshots->connect_to_session (session);
1178 _routes->connect_to_session (session);
1179 _locations->connect_to_session (session);
1185 Editor::build_cursors ()
1187 using namespace Gdk;
1189 Gdk::Color mbg ("#000000" ); /* Black */
1190 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1193 RefPtr<Bitmap> source, mask;
1194 source = Bitmap::create (mag_bits, mag_width, mag_height);
1195 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1196 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1199 Gdk::Color fbg ("#ffffff" );
1200 Gdk::Color ffg ("#000000" );
1203 RefPtr<Bitmap> source, mask;
1205 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1206 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1207 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1211 RefPtr<Bitmap> source, mask;
1212 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1213 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1214 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1218 RefPtr<Bitmap> bits;
1219 char pix[4] = { 0, 0, 0, 0 };
1220 bits = Bitmap::create (pix, 2, 2);
1222 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1226 RefPtr<Bitmap> bits;
1227 char pix[4] = { 0, 0, 0, 0 };
1228 bits = Bitmap::create (pix, 2, 2);
1230 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1234 grabber_cursor = new Gdk::Cursor (HAND2);
1237 Glib::RefPtr<Gdk::Pixbuf> grabber_edit_point_pixbuf (::get_icon ("grabber_edit_point"));
1238 grabber_edit_point_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_edit_point_pixbuf, 5, 17);
1241 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1242 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1243 selector_cursor = new Gdk::Cursor (XTERM);
1244 time_fx_cursor = new Gdk::Cursor (SIZING);
1245 wait_cursor = new Gdk::Cursor (WATCH);
1246 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1247 midi_pencil_cursor = new Gdk::Cursor (PENCIL);
1248 midi_select_cursor = new Gdk::Cursor (CENTER_PTR);
1249 midi_resize_cursor = new Gdk::Cursor (SIZING);
1250 midi_erase_cursor = new Gdk::Cursor (DRAPED_BOX);
1253 /** Pop up a context menu for when the user clicks on a fade in or fade out */
1255 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1257 using namespace Menu_Helpers;
1258 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1261 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1265 MenuList& items (fade_context_menu.items());
1269 switch (item_type) {
1271 case FadeInHandleItem:
1272 if (arv->audio_region()->fade_in_active()) {
1273 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_in_active), false)));
1275 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_in_active), true)));
1278 items.push_back (SeparatorElem());
1280 if (Profile->get_sae()) {
1281 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1282 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1284 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1285 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1286 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
1287 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
1288 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
1294 case FadeOutHandleItem:
1295 if (arv->audio_region()->fade_out_active()) {
1296 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_out_active), false)));
1298 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_out_active), true)));
1301 items.push_back (SeparatorElem());
1303 if (Profile->get_sae()) {
1304 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1305 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1307 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1308 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1309 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
1310 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
1311 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
1317 fatal << _("programming error: ")
1318 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1323 fade_context_menu.popup (button, time);
1327 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes64_t frame)
1329 using namespace Menu_Helpers;
1330 Menu* (Editor::*build_menu_function)(nframes64_t);
1333 switch (item_type) {
1335 case RegionViewName:
1336 case RegionViewNameHighlight:
1337 if (with_selection) {
1338 build_menu_function = &Editor::build_track_selection_context_menu;
1340 build_menu_function = &Editor::build_track_region_context_menu;
1345 if (with_selection) {
1346 build_menu_function = &Editor::build_track_selection_context_menu;
1348 build_menu_function = &Editor::build_track_context_menu;
1352 case CrossfadeViewItem:
1353 build_menu_function = &Editor::build_track_crossfade_context_menu;
1357 if (clicked_routeview->get_diskstream()) {
1358 build_menu_function = &Editor::build_track_context_menu;
1360 build_menu_function = &Editor::build_track_bus_context_menu;
1365 /* probably shouldn't happen but if it does, we don't care */
1369 menu = (this->*build_menu_function)(frame);
1370 menu->set_name ("ArdourContextMenu");
1372 /* now handle specific situations */
1374 switch (item_type) {
1376 case RegionViewName:
1377 case RegionViewNameHighlight:
1378 if (!with_selection) {
1379 if (region_edit_menu_split_item) {
1380 if (clicked_regionview && clicked_regionview->region()->covers (get_preferred_edit_position())) {
1381 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, true);
1383 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, false);
1387 if (region_edit_menu_split_multichannel_item) {
1388 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1389 // GTK2FIX find the action, change its sensitivity
1390 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1392 // GTK2FIX see above
1393 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1402 case CrossfadeViewItem:
1409 /* probably shouldn't happen but if it does, we don't care */
1413 if (item_type != SelectionItem && clicked_routeview && clicked_routeview->audio_track()) {
1415 /* Bounce to disk */
1417 using namespace Menu_Helpers;
1418 MenuList& edit_items = menu->items();
1420 edit_items.push_back (SeparatorElem());
1422 switch (clicked_routeview->audio_track()->freeze_state()) {
1423 case AudioTrack::NoFreeze:
1424 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1427 case AudioTrack::Frozen:
1428 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1431 case AudioTrack::UnFrozen:
1432 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1438 if (item_type == StreamItem && clicked_routeview) {
1439 clicked_routeview->build_underlay_menu(menu);
1442 menu->popup (button, time);
1446 Editor::build_track_context_menu (nframes64_t)
1448 using namespace Menu_Helpers;
1450 MenuList& edit_items = track_context_menu.items();
1453 add_dstream_context_items (edit_items);
1454 return &track_context_menu;
1458 Editor::build_track_bus_context_menu (nframes64_t)
1460 using namespace Menu_Helpers;
1462 MenuList& edit_items = track_context_menu.items();
1465 add_bus_context_items (edit_items);
1466 return &track_context_menu;
1470 Editor::build_track_region_context_menu (nframes64_t frame)
1472 using namespace Menu_Helpers;
1473 MenuList& edit_items = track_region_context_menu.items();
1476 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (clicked_axisview);
1479 boost::shared_ptr<Diskstream> ds;
1480 boost::shared_ptr<Playlist> pl;
1482 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
1483 Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)frame * ds->speed()));
1485 if (selection->regions.size() > 1) {
1486 // there's already a multiple selection: just add a
1487 // single region context menu that will act on all
1489 boost::shared_ptr<Region> dummy_region; // = NULL
1490 add_region_context_items (rtv->view(), dummy_region, edit_items);
1492 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1493 add_region_context_items (rtv->view(), (*i), edit_items);
1501 add_dstream_context_items (edit_items);
1503 return &track_region_context_menu;
1507 Editor::build_track_crossfade_context_menu (nframes64_t frame)
1509 using namespace Menu_Helpers;
1510 MenuList& edit_items = track_crossfade_context_menu.items();
1511 edit_items.clear ();
1513 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_axisview);
1516 boost::shared_ptr<Diskstream> ds;
1517 boost::shared_ptr<Playlist> pl;
1518 boost::shared_ptr<AudioPlaylist> apl;
1520 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1522 Playlist::RegionList* regions = pl->regions_at (frame);
1523 AudioPlaylist::Crossfades xfades;
1525 apl->crossfades_at (frame, xfades);
1527 bool many = xfades.size() > 1;
1529 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1530 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1533 if (selection->regions.size() > 1) {
1534 // there's already a multiple selection: just add a
1535 // single region context menu that will act on all
1537 boost::shared_ptr<Region> dummy_region; // = NULL
1538 add_region_context_items (atv->audio_view(), dummy_region, edit_items);
1540 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1541 add_region_context_items (atv->audio_view(), (*i), edit_items);
1548 add_dstream_context_items (edit_items);
1550 return &track_crossfade_context_menu;
1554 Editor::analyze_region_selection()
1556 if (analysis_window == 0) {
1557 analysis_window = new AnalysisWindow();
1560 analysis_window->set_session(session);
1562 analysis_window->show_all();
1565 analysis_window->set_regionmode();
1566 analysis_window->analyze();
1568 analysis_window->present();
1572 Editor::analyze_range_selection()
1574 if (analysis_window == 0) {
1575 analysis_window = new AnalysisWindow();
1578 analysis_window->set_session(session);
1580 analysis_window->show_all();
1583 analysis_window->set_rangemode();
1584 analysis_window->analyze();
1586 analysis_window->present();
1590 Editor::build_track_selection_context_menu (nframes64_t)
1592 using namespace Menu_Helpers;
1593 MenuList& edit_items = track_selection_context_menu.items();
1594 edit_items.clear ();
1596 add_selection_context_items (edit_items);
1597 // edit_items.push_back (SeparatorElem());
1598 // add_dstream_context_items (edit_items);
1600 return &track_selection_context_menu;
1603 /** Add context menu items relevant to crossfades.
1604 * @param edit_items List to add the items to.
1607 Editor::add_crossfade_context_items (AudioStreamView* /*view*/, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1609 using namespace Menu_Helpers;
1610 Menu *xfade_menu = manage (new Menu);
1611 MenuList& items = xfade_menu->items();
1612 xfade_menu->set_name ("ArdourContextMenu");
1615 if (xfade->active()) {
1621 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1622 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1624 if (xfade->can_follow_overlap()) {
1626 if (xfade->following_overlap()) {
1627 str = _("Convert to short");
1629 str = _("Convert to full");
1632 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1636 str = xfade->out()->name();
1638 str += xfade->in()->name();
1640 str = _("Crossfade");
1643 edit_items.push_back (MenuElem (str, *xfade_menu));
1644 edit_items.push_back (SeparatorElem());
1648 Editor::xfade_edit_left_region ()
1650 if (clicked_crossfadeview) {
1651 clicked_crossfadeview->left_view.show_region_editor ();
1656 Editor::xfade_edit_right_region ()
1658 if (clicked_crossfadeview) {
1659 clicked_crossfadeview->right_view.show_region_editor ();
1664 Editor::add_region_context_items (StreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1666 using namespace Menu_Helpers;
1667 Gtk::MenuItem* foo_item;
1668 Menu *region_menu = manage (new Menu);
1669 MenuList& items = region_menu->items();
1670 region_menu->set_name ("ArdourContextMenu");
1672 boost::shared_ptr<AudioRegion> ar;
1673 boost::shared_ptr<MidiRegion> mr;
1676 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1677 mr = boost::dynamic_pointer_cast<MidiRegion> (region);
1679 /* when this particular menu pops up, make the relevant region
1683 region_menu->signal_map_event().connect (
1684 bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1686 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &Editor::rename_region)));
1687 if (mr && internal_editing()) {
1688 items.push_back (MenuElem (_("List editor..."), mem_fun(*this, &Editor::show_midi_list_editor)));
1690 items.push_back (MenuElem (_("Region editor"), mem_fun(*this, &Editor::edit_region)));
1694 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1695 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1696 items.push_back (SeparatorElem());
1697 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_point)));
1698 if (_edit_point == EditAtMouse) {
1699 items.back ().set_sensitive (false);
1701 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1702 items.push_back (SeparatorElem());
1704 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::play_selected_region)));
1705 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1706 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1709 items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_region_selection)));
1712 items.push_back (SeparatorElem());
1714 sigc::connection fooc;
1715 boost::shared_ptr<Region> region_to_check;
1718 region_to_check = region;
1720 region_to_check = selection->regions.front()->region();
1723 items.push_back (CheckMenuElem (_("Lock")));
1724 CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1725 if (region_to_check->locked()) {
1726 region_lock_item->set_active();
1728 region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
1730 items.push_back (CheckMenuElem (_("Glue to Bars&Beats")));
1731 CheckMenuItem* bbt_glue_item = static_cast<CheckMenuItem*>(&items.back());
1733 switch (region_to_check->positional_lock_style()) {
1734 case Region::MusicTime:
1735 bbt_glue_item->set_active (true);
1738 bbt_glue_item->set_active (false);
1742 bbt_glue_item->signal_activate().connect (bind (mem_fun (*this, &Editor::set_region_lock_style), Region::MusicTime));
1744 items.push_back (CheckMenuElem (_("Mute")));
1745 CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1746 fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
1747 if (region_to_check->muted()) {
1749 region_mute_item->set_active();
1753 if (!Profile->get_sae()) {
1754 items.push_back (CheckMenuElem (_("Opaque")));
1755 CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1756 fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
1757 if (region_to_check->opaque()) {
1759 region_opaque_item->set_active();
1764 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1765 if (region_to_check->at_natural_position()) {
1766 items.back().set_sensitive (false);
1769 items.push_back (SeparatorElem());
1773 RegionView* rv = sv->find_view (ar);
1774 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1776 if (!Profile->get_sae()) {
1777 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
1779 items.push_back (CheckMenuElem (_("Envelope Visible")));
1780 CheckMenuItem* region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1781 fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
1782 if (arv->envelope_visible()) {
1784 region_envelope_visible_item->set_active (true);
1788 items.push_back (CheckMenuElem (_("Envelope Active")));
1789 CheckMenuItem* region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1790 fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
1792 if (ar->envelope_active()) {
1794 region_envelope_active_item->set_active (true);
1798 items.push_back (SeparatorElem());
1801 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1802 if (ar->scale_amplitude() != 1) {
1803 items.push_back (MenuElem (_("Reset Gain"), mem_fun(*this, &Editor::reset_region_scale_amplitude)));
1807 items.push_back (MenuElem (_("Quantize"), mem_fun(*this, &Editor::quantize_region)));
1808 items.push_back (SeparatorElem());
1811 items.push_back (MenuElem (_("Strip Silence..."), mem_fun (*this, &Editor::strip_region_silence)));
1812 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1813 items.push_back (SeparatorElem());
1815 /* range related stuff */
1817 items.push_back (MenuElem (_("Add Single Range"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1818 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_locations_from_audio_region)));
1819 if (selection->regions.size() < 2) {
1820 items.back().set_sensitive (false);
1823 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_region)));
1824 items.push_back (SeparatorElem());
1828 Menu *nudge_menu = manage (new Menu());
1829 MenuList& nudge_items = nudge_menu->items();
1830 nudge_menu->set_name ("ArdourContextMenu");
1832 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false, false))));
1833 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false, false))));
1834 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1835 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1837 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1838 items.push_back (SeparatorElem());
1840 Menu *trim_menu = manage (new Menu);
1841 MenuList& trim_items = trim_menu->items();
1842 trim_menu->set_name ("ArdourContextMenu");
1844 trim_items.push_back (MenuElem (_("Start to edit point"), mem_fun(*this, &Editor::trim_region_from_edit_point)));
1845 foo_item = &trim_items.back();
1846 if (_edit_point == EditAtMouse) {
1847 foo_item->set_sensitive (false);
1849 trim_items.push_back (MenuElem (_("Edit point to end"), mem_fun(*this, &Editor::trim_region_to_edit_point)));
1850 foo_item = &trim_items.back();
1851 if (_edit_point == EditAtMouse) {
1852 foo_item->set_sensitive (false);
1854 trim_items.push_back (MenuElem (_("Trim To Loop"), mem_fun(*this, &Editor::trim_region_to_loop)));
1855 trim_items.push_back (MenuElem (_("Trim To Punch"), mem_fun(*this, &Editor::trim_region_to_punch)));
1857 items.push_back (MenuElem (_("Trim"), *trim_menu));
1858 items.push_back (SeparatorElem());
1860 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split))));
1861 region_edit_menu_split_item = &items.back();
1863 if (_edit_point == EditAtMouse) {
1864 region_edit_menu_split_item->set_sensitive (false);
1867 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1868 region_edit_menu_split_multichannel_item = &items.back();
1870 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), false))));
1871 items.push_back (MenuElem (_("Multi-Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1872 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1873 items.push_back (SeparatorElem());
1874 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_selected_regions)));
1876 /* OK, stick the region submenu at the top of the list, and then add
1880 /* we have to hack up the region name because "_" has a special
1881 meaning for menu titles.
1884 string::size_type pos = 0;
1885 string menu_item_name = (region) ? region->name() : _("Selected regions");
1887 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1888 menu_item_name.replace (pos, 1, "__");
1892 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1893 edit_items.push_back (SeparatorElem());
1896 /** Add context menu items relevant to selection ranges.
1897 * @param edit_items List to add the items to.
1900 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1902 using namespace Menu_Helpers;
1904 edit_items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::play_selection)));
1905 edit_items.push_back (MenuElem (_("Loop Range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
1907 edit_items.push_back (SeparatorElem());
1908 edit_items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_range_selection)));
1910 if (!selection->regions.empty()) {
1911 edit_items.push_back (SeparatorElem());
1912 edit_items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
1913 edit_items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
1916 edit_items.push_back (SeparatorElem());
1917 edit_items.push_back (MenuElem (_("Silence Range"), mem_fun(*this, &Editor::separate_region_from_selection)));
1918 edit_items.push_back (MenuElem (_("Convert to Region in Region List"), mem_fun(*this, &Editor::new_region_from_selection)));
1920 edit_items.push_back (SeparatorElem());
1921 edit_items.push_back (MenuElem (_("Select All in Range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1923 edit_items.push_back (SeparatorElem());
1924 edit_items.push_back (MenuElem (_("Set Loop from Range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
1925 edit_items.push_back (MenuElem (_("Set Punch from Range"), mem_fun(*this, &Editor::set_punch_from_selection)));
1927 edit_items.push_back (SeparatorElem());
1928 edit_items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
1930 edit_items.push_back (SeparatorElem());
1931 edit_items.push_back (MenuElem (_("Crop Region to Range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1932 edit_items.push_back (MenuElem (_("Fill Range with Region"), mem_fun(*this, &Editor::region_fill_selection)));
1933 edit_items.push_back (MenuElem (_("Duplicate Range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1935 edit_items.push_back (SeparatorElem());
1936 edit_items.push_back (MenuElem (_("Consolidate Range"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, false)));
1937 edit_items.push_back (MenuElem (_("Consolidate Range With Processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, true)));
1938 edit_items.push_back (MenuElem (_("Bounce Range to Region List"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, false)));
1939 edit_items.push_back (MenuElem (_("Bounce Range to Region List With Processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, true)));
1940 edit_items.push_back (MenuElem (_("Export Range"), mem_fun(*this, &Editor::export_range)));
1945 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1947 using namespace Menu_Helpers;
1951 Menu *play_menu = manage (new Menu);
1952 MenuList& play_items = play_menu->items();
1953 play_menu->set_name ("ArdourContextMenu");
1955 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
1956 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1957 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1958 play_items.push_back (SeparatorElem());
1959 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1961 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1965 Menu *select_menu = manage (new Menu);
1966 MenuList& select_items = select_menu->items();
1967 select_menu->set_name ("ArdourContextMenu");
1969 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1970 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1971 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1972 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1973 select_items.push_back (SeparatorElem());
1974 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1975 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1976 select_items.push_back (SeparatorElem());
1977 select_items.push_back (MenuElem (_("Select All After Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
1978 select_items.push_back (MenuElem (_("Select All Before Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
1979 select_items.push_back (MenuElem (_("Select All After Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1980 select_items.push_back (MenuElem (_("Select All Before Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1981 select_items.push_back (MenuElem (_("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), false)));
1982 select_items.push_back (MenuElem (_("Select All Within Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), true)));
1983 select_items.push_back (MenuElem (_("Select Range Between Playhead & Edit Point"), mem_fun(*this, &Editor::select_range_between)));
1985 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1989 Menu *cutnpaste_menu = manage (new Menu);
1990 MenuList& cutnpaste_items = cutnpaste_menu->items();
1991 cutnpaste_menu->set_name ("ArdourContextMenu");
1993 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1994 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1995 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1997 cutnpaste_items.push_back (SeparatorElem());
1999 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
2000 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
2002 cutnpaste_items.push_back (SeparatorElem());
2004 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
2006 /* Adding new material */
2008 edit_items.push_back (SeparatorElem());
2009 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
2010 edit_items.push_back (MenuElem (_("Insert Existing Media"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
2014 Menu *nudge_menu = manage (new Menu());
2015 MenuList& nudge_items = nudge_menu->items();
2016 nudge_menu->set_name ("ArdourContextMenu");
2018 edit_items.push_back (SeparatorElem());
2019 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2020 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2021 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2022 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2024 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2028 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
2030 using namespace Menu_Helpers;
2034 Menu *play_menu = manage (new Menu);
2035 MenuList& play_items = play_menu->items();
2036 play_menu->set_name ("ArdourContextMenu");
2038 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
2039 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2040 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2044 Menu *select_menu = manage (new Menu);
2045 MenuList& select_items = select_menu->items();
2046 select_menu->set_name ("ArdourContextMenu");
2048 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2049 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2050 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2051 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2052 select_items.push_back (SeparatorElem());
2053 select_items.push_back (MenuElem (_("Select all after edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2054 select_items.push_back (MenuElem (_("Select all before edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2055 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2056 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2058 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2062 Menu *cutnpaste_menu = manage (new Menu);
2063 MenuList& cutnpaste_items = cutnpaste_menu->items();
2064 cutnpaste_menu->set_name ("ArdourContextMenu");
2066 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2067 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2068 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2070 Menu *nudge_menu = manage (new Menu());
2071 MenuList& nudge_items = nudge_menu->items();
2072 nudge_menu->set_name ("ArdourContextMenu");
2074 edit_items.push_back (SeparatorElem());
2075 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2076 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2077 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2078 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2080 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2084 Editor::snap_type() const
2090 Editor::snap_mode() const
2096 Editor::set_snap_to (SnapType st)
2098 unsigned int snap_ind = (unsigned int)st;
2102 if (snap_ind > snap_type_strings.size() - 1) {
2104 _snap_type = (SnapType)snap_ind;
2107 string str = snap_type_strings[snap_ind];
2109 if (str != snap_type_selector.get_active_text()) {
2110 snap_type_selector.set_active_text (str);
2115 switch (_snap_type) {
2116 case SnapToAThirtysecondBeat:
2117 case SnapToASixteenthBeat:
2118 case SnapToAEighthBeat:
2119 case SnapToAQuarterBeat:
2120 case SnapToAThirdBeat:
2121 compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames());
2122 update_tempo_based_rulers ();
2125 case SnapToRegionStart:
2126 case SnapToRegionEnd:
2127 case SnapToRegionSync:
2128 case SnapToRegionBoundary:
2129 build_region_boundary_cache ();
2139 Editor::set_snap_mode (SnapMode mode)
2142 string str = snap_mode_strings[(int)mode];
2144 if (str != snap_mode_selector.get_active_text ()) {
2145 snap_mode_selector.set_active_text (str);
2151 Editor::set_edit_point_preference (EditPoint ep, bool force)
2153 bool changed = (_edit_point != ep);
2156 string str = edit_point_strings[(int)ep];
2158 if (str != edit_point_selector.get_active_text ()) {
2159 edit_point_selector.set_active_text (str);
2162 set_canvas_cursor ();
2164 if (!force && !changed) {
2168 switch (zoom_focus) {
2169 case ZoomFocusMouse:
2170 case ZoomFocusPlayhead:
2172 switch (_edit_point) {
2174 set_zoom_focus (ZoomFocusMouse);
2176 case EditAtPlayhead:
2177 set_zoom_focus (ZoomFocusPlayhead);
2179 case EditAtSelectedMarker:
2180 set_zoom_focus (ZoomFocusEdit);
2188 const char* action=NULL;
2190 switch (_edit_point) {
2191 case EditAtPlayhead:
2192 action = "edit-at-playhead";
2194 case EditAtSelectedMarker:
2195 action = "edit-at-marker";
2198 action = "edit-at-mouse";
2202 Glib::RefPtr<Action> act = ActionManager::get_action ("Editor", action);
2204 Glib::RefPtr<RadioAction>::cast_dynamic(act)->set_active (true);
2208 bool in_track_canvas;
2210 if (!mouse_frame (foo, in_track_canvas)) {
2211 in_track_canvas = false;
2214 reset_canvas_action_sensitivity (in_track_canvas);
2220 Editor::set_state (const XMLNode& node, int /*version*/)
2222 const XMLProperty* prop;
2224 int x, y, xoff, yoff;
2227 if ((prop = node.property ("id")) != 0) {
2228 _id = prop->value ();
2231 g.base_width = default_width;
2232 g.base_height = default_height;
2238 if ((geometry = find_named_node (node, "geometry")) != 0) {
2242 if ((prop = geometry->property("x_size")) == 0) {
2243 prop = geometry->property ("x-size");
2246 g.base_width = atoi(prop->value());
2248 if ((prop = geometry->property("y_size")) == 0) {
2249 prop = geometry->property ("y-size");
2252 g.base_height = atoi(prop->value());
2255 if ((prop = geometry->property ("x_pos")) == 0) {
2256 prop = geometry->property ("x-pos");
2259 x = atoi (prop->value());
2262 if ((prop = geometry->property ("y_pos")) == 0) {
2263 prop = geometry->property ("y-pos");
2266 y = atoi (prop->value());
2269 if ((prop = geometry->property ("x_off")) == 0) {
2270 prop = geometry->property ("x-off");
2273 xoff = atoi (prop->value());
2275 if ((prop = geometry->property ("y_off")) == 0) {
2276 prop = geometry->property ("y-off");
2279 yoff = atoi (prop->value());
2283 set_default_size (g.base_width, g.base_height);
2286 if (session && (prop = node.property ("playhead"))) {
2287 nframes64_t pos = atol (prop->value().c_str());
2288 playhead_cursor->set_position (pos);
2290 playhead_cursor->set_position (0);
2292 /* reset_x_origin() doesn't work right here, since the old
2293 position may be zero already, and it does nothing in such
2298 horizontal_adjustment.set_value (0);
2301 if ((prop = node.property ("mixer-width"))) {
2302 editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
2305 if ((prop = node.property ("zoom-focus"))) {
2306 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2309 if ((prop = node.property ("zoom"))) {
2310 reset_zoom (PBD::atof (prop->value()));
2313 if ((prop = node.property ("snap-to"))) {
2314 set_snap_to ((SnapType) atoi (prop->value()));
2317 if ((prop = node.property ("snap-mode"))) {
2318 set_snap_mode ((SnapMode) atoi (prop->value()));
2321 if ((prop = node.property ("mouse-mode"))) {
2322 MouseMode m = str2mousemode(prop->value());
2323 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2324 set_mouse_mode (m, true);
2326 mouse_mode = MouseGain; /* lie, to force the mode switch */
2327 set_mouse_mode (MouseObject, true);
2330 if ((prop = node.property ("internal-edit"))) {
2331 bool yn = string_is_affirmative (prop->value());
2332 RefPtr<Action> act = ActionManager::get_action (X_("MouseMode"), X_("toggle-internal-edit"));
2334 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2335 tact->set_active (!yn);
2336 tact->set_active (yn);
2340 if ((prop = node.property ("edit-point"))) {
2341 set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point), true);
2344 if ((prop = node.property ("show-waveforms-recording"))) {
2345 bool yn = string_is_affirmative (prop->value());
2346 _show_waveforms_recording = !yn;
2347 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2349 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2350 /* do it twice to force the change */
2351 tact->set_active (!yn);
2352 tact->set_active (yn);
2356 if ((prop = node.property ("show-measures"))) {
2357 bool yn = string_is_affirmative (prop->value());
2358 _show_measures = !yn;
2359 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2361 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2362 /* do it twice to force the change */
2363 tact->set_active (!yn);
2364 tact->set_active (yn);
2368 if ((prop = node.property ("follow-playhead"))) {
2369 bool yn = string_is_affirmative (prop->value());
2370 set_follow_playhead (yn);
2371 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2373 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2374 if (tact->get_active() != yn) {
2375 tact->set_active (yn);
2380 if ((prop = node.property ("region-list-sort-type"))) {
2381 _regions->reset_sort_type (str2regionlistsorttype(prop->value()), true);
2384 if ((prop = node.property ("xfades-visible"))) {
2385 bool yn = string_is_affirmative (prop->value());
2386 _xfade_visibility = !yn;
2387 // set_xfade_visibility (yn);
2390 if ((prop = node.property ("show-editor-mixer"))) {
2392 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2395 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2396 bool yn = string_is_affirmative (prop->value());
2398 /* do it twice to force the change */
2400 tact->set_active (!yn);
2401 tact->set_active (yn);
2405 if ((prop = node.property ("show-editor-list"))) {
2407 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2411 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2412 bool yn = string_is_affirmative (prop->value());
2414 /* do it twice to force the change */
2416 tact->set_active (!yn);
2417 tact->set_active (yn);
2426 Editor::get_state ()
2428 XMLNode* node = new XMLNode ("Editor");
2431 _id.print (buf, sizeof (buf));
2432 node->add_property ("id", buf);
2434 if (is_realized()) {
2435 Glib::RefPtr<Gdk::Window> win = get_window();
2437 int x, y, xoff, yoff, width, height;
2438 win->get_root_origin(x, y);
2439 win->get_position(xoff, yoff);
2440 win->get_size(width, height);
2442 XMLNode* geometry = new XMLNode ("geometry");
2444 snprintf(buf, sizeof(buf), "%d", width);
2445 geometry->add_property("x-size", string(buf));
2446 snprintf(buf, sizeof(buf), "%d", height);
2447 geometry->add_property("y-size", string(buf));
2448 snprintf(buf, sizeof(buf), "%d", x);
2449 geometry->add_property("x-pos", string(buf));
2450 snprintf(buf, sizeof(buf), "%d", y);
2451 geometry->add_property("y-pos", string(buf));
2452 snprintf(buf, sizeof(buf), "%d", xoff);
2453 geometry->add_property("x-off", string(buf));
2454 snprintf(buf, sizeof(buf), "%d", yoff);
2455 geometry->add_property("y-off", string(buf));
2456 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2457 geometry->add_property("edit_pane_pos", string(buf));
2459 node->add_child_nocopy (*geometry);
2462 maybe_add_mixer_strip_width (*node);
2464 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2465 node->add_property ("zoom-focus", buf);
2466 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2467 node->add_property ("zoom", buf);
2468 snprintf (buf, sizeof(buf), "%d", (int) _snap_type);
2469 node->add_property ("snap-to", buf);
2470 snprintf (buf, sizeof(buf), "%d", (int) _snap_mode);
2471 node->add_property ("snap-mode", buf);
2473 node->add_property ("edit-point", enum_2_string (_edit_point));
2475 snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame);
2476 node->add_property ("playhead", buf);
2478 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2479 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2480 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2481 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2482 node->add_property ("region-list-sort-type", enum2str (_regions->sort_type ()));
2483 node->add_property ("mouse-mode", enum2str(mouse_mode));
2484 node->add_property ("internal-edit", _internal_editing ? "yes" : "no");
2486 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2488 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2489 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2492 act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2494 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2495 node->add_property (X_("show-editor-list"), tact->get_active() ? "yes" : "no");
2503 /** @param y y offset from the top of all trackviews.
2504 * @return pair: TimeAxisView that y is over, layer index.
2505 * TimeAxisView may be 0. Layer index is the layer number if the TimeAxisView is valid and is
2506 * in stacked region display mode, otherwise 0.
2508 std::pair<TimeAxisView *, layer_t>
2509 Editor::trackview_by_y_position (double y)
2511 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2513 std::pair<TimeAxisView*, int> const r = (*iter)->covers_y_position (y);
2519 return std::make_pair ( (TimeAxisView *) 0, 0);
2522 /** Snap a position to the grid, if appropriate, taking into account current
2523 * grid settings and also the state of any snap modifier keys that may be pressed.
2524 * @param start Position to snap.
2525 * @param event Event to get current key modifier information from.
2528 Editor::snap_to_with_modifier (nframes64_t& start, GdkEvent const * event, int32_t direction, bool for_mark)
2534 if (Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
2535 if (_snap_mode == SnapOff) {
2536 snap_to_internal (start, direction, for_mark);
2539 if (_snap_mode != SnapOff) {
2540 snap_to_internal (start, direction, for_mark);
2546 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
2548 if (!session || _snap_mode == SnapOff) {
2552 snap_to_internal (start, direction, for_mark);
2556 Editor::timecode_snap_to_internal (nframes64_t& start, int32_t direction, bool /*for_mark*/)
2558 const nframes64_t one_timecode_second = (nframes64_t)(rint(session->timecode_frames_per_second()) * session->frames_per_timecode_frame());
2559 nframes64_t one_timecode_minute = (nframes64_t)(rint(session->timecode_frames_per_second()) * session->frames_per_timecode_frame() * 60);
2561 switch (_snap_type) {
2562 case SnapToTimecodeFrame:
2563 if (((direction == 0) && (fmod((double)start, (double)session->frames_per_timecode_frame()) > (session->frames_per_timecode_frame() / 2))) || (direction > 0)) {
2564 start = (nframes64_t) (ceil ((double) start / session->frames_per_timecode_frame()) * session->frames_per_timecode_frame());
2566 start = (nframes64_t) (floor ((double) start / session->frames_per_timecode_frame()) * session->frames_per_timecode_frame());
2570 case SnapToTimecodeSeconds:
2571 if (session->timecode_offset_negative())
2573 start += session->timecode_offset ();
2575 start -= session->timecode_offset ();
2577 if (((direction == 0) && (start % one_timecode_second > one_timecode_second / 2)) || direction > 0) {
2578 start = (nframes64_t) ceil ((double) start / one_timecode_second) * one_timecode_second;
2580 start = (nframes64_t) floor ((double) start / one_timecode_second) * one_timecode_second;
2583 if (session->timecode_offset_negative())
2585 start -= session->timecode_offset ();
2587 start += session->timecode_offset ();
2591 case SnapToTimecodeMinutes:
2592 if (session->timecode_offset_negative())
2594 start += session->timecode_offset ();
2596 start -= session->timecode_offset ();
2598 if (((direction == 0) && (start % one_timecode_minute > one_timecode_minute / 2)) || direction > 0) {
2599 start = (nframes64_t) ceil ((double) start / one_timecode_minute) * one_timecode_minute;
2601 start = (nframes64_t) floor ((double) start / one_timecode_minute) * one_timecode_minute;
2603 if (session->timecode_offset_negative())
2605 start -= session->timecode_offset ();
2607 start += session->timecode_offset ();
2611 fatal << "Editor::smpte_snap_to_internal() called with non-timecode snap type!" << endmsg;
2617 Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
2619 const nframes64_t one_second = session->frame_rate();
2620 const nframes64_t one_minute = session->frame_rate() * 60;
2621 nframes64_t presnap = start;
2625 switch (_snap_type) {
2626 case SnapToTimecodeFrame:
2627 case SnapToTimecodeSeconds:
2628 case SnapToTimecodeMinutes:
2629 return timecode_snap_to_internal (start, direction, for_mark);
2632 if (((direction == 0) && (start % (one_second/75) > (one_second/75) / 2)) || (direction > 0)) {
2633 start = (nframes64_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2635 start = (nframes64_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2640 if (((direction == 0) && (start % one_second > one_second / 2)) || (direction > 0)) {
2641 start = (nframes64_t) ceil ((double) start / one_second) * one_second;
2643 start = (nframes64_t) floor ((double) start / one_second) * one_second;
2648 if (((direction == 0) && (start % one_minute > one_minute / 2)) || (direction > 0)) {
2649 start = (nframes64_t) ceil ((double) start / one_minute) * one_minute;
2651 start = (nframes64_t) floor ((double) start / one_minute) * one_minute;
2656 start = session->tempo_map().round_to_bar (start, direction);
2660 start = session->tempo_map().round_to_beat (start, direction);
2663 case SnapToAThirtysecondBeat:
2664 start = session->tempo_map().round_to_beat_subdivision (start, 32, direction);
2667 case SnapToASixteenthBeat:
2668 start = session->tempo_map().round_to_beat_subdivision (start, 16, direction);
2671 case SnapToAEighthBeat:
2672 start = session->tempo_map().round_to_beat_subdivision (start, 8, direction);
2675 case SnapToAQuarterBeat:
2676 start = session->tempo_map().round_to_beat_subdivision (start, 4, direction);
2679 case SnapToAThirdBeat:
2680 start = session->tempo_map().round_to_beat_subdivision (start, 3, direction);
2688 session->locations()->marks_either_side (start, before, after);
2690 if (before == max_frames) {
2692 } else if (after == max_frames) {
2694 } else if (before != max_frames && after != max_frames) {
2695 /* have before and after */
2696 if ((start - before) < (after - start)) {
2705 case SnapToRegionStart:
2706 case SnapToRegionEnd:
2707 case SnapToRegionSync:
2708 case SnapToRegionBoundary:
2709 if (!region_boundary_cache.empty()) {
2711 vector<nframes64_t>::iterator prev = region_boundary_cache.end ();
2712 vector<nframes64_t>::iterator next = region_boundary_cache.end ();
2714 if (direction > 0) {
2715 next = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2717 next = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2720 if (next != region_boundary_cache.begin ()) {
2725 nframes64_t const p = (prev == region_boundary_cache.end()) ? region_boundary_cache.front () : *prev;
2726 nframes64_t const n = (next == region_boundary_cache.end()) ? region_boundary_cache.back () : *next;
2728 if (start > (p + n) / 2) {
2737 switch (_snap_mode) {
2743 if (presnap > start) {
2744 if (presnap > (start + unit_to_frame(snap_threshold))) {
2748 } else if (presnap < start) {
2749 if (presnap < (start - unit_to_frame(snap_threshold))) {
2755 /* handled at entry */
2763 Editor::setup_toolbar ()
2767 /* Mode Buttons (tool selection) */
2769 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2770 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2771 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2772 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2773 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2774 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2775 // internal_edit_button.set_relief(Gtk::RELIEF_NONE);
2777 HBox* mode_box = manage(new HBox);
2778 mode_box->set_border_width (2);
2779 mode_box->set_spacing(4);
2780 mouse_mode_button_box.set_spacing(1);
2781 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2782 if (!Profile->get_sae()) {
2783 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2785 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2786 if (!Profile->get_sae()) {
2787 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2789 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2790 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2791 mouse_mode_button_box.pack_start(internal_edit_button, true, true);
2792 mouse_mode_button_box.set_homogeneous(true);
2794 vector<string> edit_mode_strings;
2795 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2796 if (!Profile->get_sae()) {
2797 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2799 edit_mode_strings.push_back (edit_mode_to_string (Lock));
2801 edit_mode_selector.set_name ("EditModeSelector");
2802 set_popdown_strings (edit_mode_selector, edit_mode_strings, true);
2803 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2805 mode_box->pack_start(edit_mode_selector);
2806 mode_box->pack_start(mouse_mode_button_box);
2808 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2809 mouse_mode_tearoff->set_name ("MouseModeBase");
2810 mouse_mode_tearoff->tearoff_window().signal_key_press_event().connect (bind (sigc::ptr_fun (relay_key_press), &mouse_mode_tearoff->tearoff_window()), false);
2812 if (Profile->get_sae()) {
2813 mouse_mode_tearoff->set_can_be_torn_off (false);
2816 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2817 &mouse_mode_tearoff->tearoff_window()));
2818 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2819 &mouse_mode_tearoff->tearoff_window(), 1));
2820 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2821 &mouse_mode_tearoff->tearoff_window()));
2822 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2823 &mouse_mode_tearoff->tearoff_window(), 1));
2825 mouse_move_button.set_mode (false);
2826 mouse_select_button.set_mode (false);
2827 mouse_gain_button.set_mode (false);
2828 mouse_zoom_button.set_mode (false);
2829 mouse_timefx_button.set_mode (false);
2830 mouse_audition_button.set_mode (false);
2832 mouse_move_button.set_name ("MouseModeButton");
2833 mouse_select_button.set_name ("MouseModeButton");
2834 mouse_gain_button.set_name ("MouseModeButton");
2835 mouse_zoom_button.set_name ("MouseModeButton");
2836 mouse_timefx_button.set_name ("MouseModeButton");
2837 mouse_audition_button.set_name ("MouseModeButton");
2839 internal_edit_button.set_name ("MouseModeButton");
2841 mouse_move_button.unset_flags (CAN_FOCUS);
2842 mouse_select_button.unset_flags (CAN_FOCUS);
2843 mouse_gain_button.unset_flags (CAN_FOCUS);
2844 mouse_zoom_button.unset_flags (CAN_FOCUS);
2845 mouse_timefx_button.unset_flags (CAN_FOCUS);
2846 mouse_audition_button.unset_flags (CAN_FOCUS);
2847 internal_edit_button.unset_flags (CAN_FOCUS);
2851 zoom_box.set_spacing (1);
2852 zoom_box.set_border_width (0);
2854 zoom_in_button.set_name ("EditorTimeButton");
2855 zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in")))));
2856 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2857 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2859 zoom_out_button.set_name ("EditorTimeButton");
2860 zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out")))));
2861 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2862 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2864 zoom_out_full_button.set_name ("EditorTimeButton");
2865 zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full")))));
2866 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2867 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2869 zoom_focus_selector.set_name ("ZoomFocusSelector");
2870 set_popdown_strings (zoom_focus_selector, zoom_focus_strings, true);
2871 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2872 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
2874 zoom_box.pack_start (zoom_out_button, false, false);
2875 zoom_box.pack_start (zoom_in_button, false, false);
2876 zoom_box.pack_start (zoom_out_full_button, false, false);
2878 /* Track zoom buttons */
2879 tav_expand_button.set_name ("TrackHeightButton");
2880 tav_expand_button.set_size_request(-1,20);
2881 tav_expand_button.add (*(manage (new Image (::get_icon("tav_exp")))));
2882 tav_expand_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::tav_zoom_step), true));
2883 ARDOUR_UI::instance()->tooltips().set_tip (tav_expand_button, _("Expand Tracks"));
2885 tav_shrink_button.set_name ("TrackHeightButton");
2886 tav_shrink_button.set_size_request(-1,20);
2887 tav_shrink_button.add (*(manage (new Image (::get_icon("tav_shrink")))));
2888 tav_shrink_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::tav_zoom_step), false));
2889 ARDOUR_UI::instance()->tooltips().set_tip (tav_shrink_button, _("Shrink Tracks"));
2891 track_zoom_box.set_spacing (1);
2892 track_zoom_box.set_border_width (0);
2894 track_zoom_box.pack_start (tav_shrink_button, false, false);
2895 track_zoom_box.pack_start (tav_expand_button, false, false);
2897 HBox* zbc = manage (new HBox);
2898 zbc->pack_start (zoom_focus_selector, PACK_SHRINK);
2899 zoom_vbox.pack_start (*zbc, PACK_SHRINK);
2900 zoom_vbox.pack_start (zoom_box, PACK_SHRINK);
2901 zoom_vbox.pack_start (track_zoom_box, PACK_SHRINK);
2903 snap_box.set_spacing (1);
2904 snap_box.set_border_width (2);
2906 snap_type_selector.set_name ("SnapTypeSelector");
2907 set_popdown_strings (snap_type_selector, snap_type_strings, true);
2908 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2909 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Snap/Grid Units"));
2911 snap_mode_selector.set_name ("SnapModeSelector");
2912 set_popdown_strings (snap_mode_selector, snap_mode_strings, true);
2913 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2914 ARDOUR_UI::instance()->tooltips().set_tip (snap_mode_selector, _("Snap/Grid Mode"));
2916 edit_point_selector.set_name ("EditPointSelector");
2917 set_popdown_strings (edit_point_selector, edit_point_strings, true);
2918 edit_point_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_point_selection_done));
2919 ARDOUR_UI::instance()->tooltips().set_tip (edit_point_selector, _("Edit point"));
2921 snap_box.pack_start (edit_point_clock, false, false);
2922 snap_box.pack_start (snap_mode_selector, false, false);
2923 snap_box.pack_start (snap_type_selector, false, false);
2924 snap_box.pack_start (edit_point_selector, false, false);
2928 HBox *nudge_box = manage (new HBox);
2929 nudge_box->set_spacing(1);
2930 nudge_box->set_border_width (2);
2932 nudge_forward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_forward_release), false);
2933 nudge_backward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_backward_release), false);
2935 nudge_box->pack_start (nudge_backward_button, false, false);
2936 nudge_box->pack_start (nudge_forward_button, false, false);
2937 nudge_box->pack_start (nudge_clock, false, false);
2940 /* Pack everything in... */
2942 HBox* hbox = manage (new HBox);
2943 hbox->set_spacing(10);
2945 tools_tearoff = manage (new TearOff (*hbox));
2946 tools_tearoff->set_name ("MouseModeBase");
2947 tools_tearoff->tearoff_window().signal_key_press_event().connect (bind (sigc::ptr_fun (relay_key_press), &tools_tearoff->tearoff_window()), false);
2949 if (Profile->get_sae()) {
2950 tools_tearoff->set_can_be_torn_off (false);
2953 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2954 &tools_tearoff->tearoff_window()));
2955 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2956 &tools_tearoff->tearoff_window(), 0));
2957 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2958 &tools_tearoff->tearoff_window()));
2959 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2960 &tools_tearoff->tearoff_window(), 0));
2962 toolbar_hbox.set_spacing (10);
2963 toolbar_hbox.set_border_width (1);
2965 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2966 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2968 hbox->pack_start (snap_box, false, false);
2969 hbox->pack_start (*nudge_box, false, false);
2970 hbox->pack_start (panic_box, false, false);
2974 toolbar_base.set_name ("ToolBarBase");
2975 toolbar_base.add (toolbar_hbox);
2977 toolbar_frame.set_shadow_type (SHADOW_OUT);
2978 toolbar_frame.set_name ("BaseFrame");
2979 toolbar_frame.add (toolbar_base);
2983 Editor::midi_panic ()
2985 cerr << "MIDI panic\n";
2988 session->midi_panic();
2993 Editor::setup_midi_toolbar ()
2997 /* Midi sound notes */
2998 midi_sound_notes.add (*(manage (new Image (::get_icon("midi_sound_notes")))));
2999 midi_sound_notes.set_relief(Gtk::RELIEF_NONE);
3000 ARDOUR_UI::instance()->tooltips().set_tip (midi_sound_notes, _("Sound Notes"));
3001 midi_sound_notes.unset_flags (CAN_FOCUS);
3005 act = ActionManager::get_action (X_("MIDI"), X_("panic"));
3006 midi_panic_button.set_name("MidiPanicButton");
3007 ARDOUR_UI::instance()->tooltips().set_tip (midi_panic_button, _("Send note off and reset controller messages on all MIDI channels"));
3008 act->connect_proxy (midi_panic_button);
3010 panic_box.pack_start (midi_sound_notes , true, true);
3011 panic_box.pack_start (midi_panic_button, true, true);
3015 Editor::convert_drop_to_paths (
3016 vector<ustring>& paths,
3017 const RefPtr<Gdk::DragContext>& /*context*/,
3020 const SelectionData& data,
3028 vector<ustring> uris = data.get_uris();
3032 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
3033 are actually URI lists. So do it by hand.
3036 if (data.get_target() != "text/plain") {
3040 /* Parse the "uri-list" format that Nautilus provides,
3041 where each pathname is delimited by \r\n.
3043 THERE MAY BE NO NULL TERMINATING CHAR!!!
3046 ustring txt = data.get_text();
3050 p = (const char *) malloc (txt.length() + 1);
3051 txt.copy ((char *) p, txt.length(), 0);
3052 ((char*)p)[txt.length()] = '\0';
3058 while (g_ascii_isspace (*p))
3062 while (*q && (*q != '\n') && (*q != '\r')) {
3069 while (q > p && g_ascii_isspace (*q))
3074 uris.push_back (ustring (p, q - p + 1));
3078 p = strchr (p, '\n');
3090 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
3092 if ((*i).substr (0,7) == "file://") {
3095 PBD::url_decode (p);
3097 // scan forward past three slashes
3099 ustring::size_type slashcnt = 0;
3100 ustring::size_type n = 0;
3101 ustring::iterator x = p.begin();
3103 while (slashcnt < 3 && x != p.end()) {
3106 } else if (slashcnt == 3) {
3113 if (slashcnt != 3 || x == p.end()) {
3114 error << _("malformed URL passed to drag-n-drop code") << endmsg;
3118 paths.push_back (p.substr (n - 1));
3126 Editor::new_tempo_section ()
3132 Editor::map_transport_state ()
3134 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
3136 if (session->transport_stopped()) {
3137 have_pending_keyboard_selection = false;
3140 update_loop_range_view (true);
3145 Editor::State::State (PublicEditor const * e)
3147 selection = new Selection (e);
3150 Editor::State::~State ()
3156 Editor::store_state (State& state) const
3158 *state.selection = *selection;
3162 Editor::restore_state (State *state)
3164 if (*selection == *state->selection) {
3168 *selection = *state->selection;
3169 time_selection_changed ();
3170 region_selection_changed ();
3172 /* XXX other selection change handlers? */
3176 Editor::begin_reversible_command (string name)
3179 before = &get_state();
3180 session->begin_reversible_command (name);
3185 Editor::commit_reversible_command ()
3188 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
3193 Editor::set_route_group_solo (Route& route, bool yn)
3195 RouteGroup *route_group;
3197 if ((route_group = route.route_group()) != 0) {
3198 route_group->apply (&Route::set_solo, yn, this);
3200 route.set_solo (yn, this);
3205 Editor::set_route_group_mute (Route& route, bool yn)
3207 RouteGroup *route_group = 0;
3209 if ((route_group == route.route_group()) != 0) {
3210 route_group->apply (&Route::set_mute, yn, this);
3212 route.set_mute (yn, this);
3217 Editor::history_changed ()
3221 if (undo_action && session) {
3222 if (session->undo_depth() == 0) {
3225 label = string_compose(_("Undo (%1)"), session->next_undo());
3227 undo_action->property_label() = label;
3230 if (redo_action && session) {
3231 if (session->redo_depth() == 0) {
3234 label = string_compose(_("Redo (%1)"), session->next_redo());
3236 redo_action->property_label() = label;
3241 Editor::duplicate_dialog (bool with_dialog)
3245 if (mouse_mode == MouseRange) {
3246 if (selection->time.length() == 0) {
3252 get_regions_for_action (rs);
3254 if (mouse_mode != MouseRange) {
3263 ArdourDialog win ("Duplicate");
3264 Label label (_("Number of Duplications:"));
3265 Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
3266 SpinButton spinner (adjustment, 0.0, 1);
3269 win.get_vbox()->set_spacing (12);
3270 win.get_vbox()->pack_start (hbox);
3271 hbox.set_border_width (6);
3272 hbox.pack_start (label, PACK_EXPAND_PADDING, 12);
3274 /* dialogs have ::add_action_widget() but that puts the spinner in the wrong
3275 place, visually. so do this by hand.
3278 hbox.pack_start (spinner, PACK_EXPAND_PADDING, 12);
3279 spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
3280 spinner.grab_focus();
3286 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3287 win.add_button (_("Duplicate"), RESPONSE_ACCEPT);
3288 win.set_default_response (RESPONSE_ACCEPT);
3290 win.set_position (WIN_POS_MOUSE);
3292 spinner.grab_focus ();
3294 switch (win.run ()) {
3295 case RESPONSE_ACCEPT:
3301 times = adjustment.get_value();
3304 if (mouse_mode == MouseRange) {
3305 duplicate_selection (times);
3307 duplicate_some_regions (rs, times);
3312 Editor::show_verbose_canvas_cursor ()
3314 verbose_canvas_cursor->raise_to_top();
3315 verbose_canvas_cursor->show();
3316 verbose_cursor_visible = true;
3320 Editor::hide_verbose_canvas_cursor ()
3322 verbose_canvas_cursor->hide();
3323 verbose_cursor_visible = false;
3327 Editor::clamp_verbose_cursor_x (double x)
3332 x = min (_canvas_width - 200.0, x);
3338 Editor::clamp_verbose_cursor_y (double y)
3340 if (y < canvas_timebars_vsize) {
3341 y = canvas_timebars_vsize;
3343 y = min (_canvas_height - 50, y);
3349 Editor::show_verbose_canvas_cursor_with (const string & txt)
3351 verbose_canvas_cursor->property_text() = txt.c_str();
3356 track_canvas->get_pointer (x, y);
3357 track_canvas->window_to_world (x, y, wx, wy);
3359 /* move it away from the mouse pointer to avoid an
3360 infinite loop of enter/leave events.
3366 /* don't get too close to the edge */
3367 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (wx);
3368 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (wy);
3370 show_verbose_canvas_cursor ();
3374 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3376 verbose_canvas_cursor->property_text() = txt.c_str();
3377 /* don't get too close to the edge */
3378 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (x);
3379 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (y);
3383 Editor::set_verbose_canvas_cursor_text (const string & txt)
3385 verbose_canvas_cursor->property_text() = txt.c_str();
3389 Editor::set_edit_mode (EditMode m)
3391 Config->set_edit_mode (m);
3395 Editor::cycle_edit_mode ()
3397 switch (Config->get_edit_mode()) {
3399 if (Profile->get_sae()) {
3400 Config->set_edit_mode (Lock);
3402 Config->set_edit_mode (Splice);
3406 Config->set_edit_mode (Lock);
3409 Config->set_edit_mode (Slide);
3415 Editor::edit_mode_selection_done ()
3421 string choice = edit_mode_selector.get_active_text();
3422 EditMode mode = Slide;
3424 if (choice == _("Splice Edit")) {
3426 } else if (choice == _("Slide Edit")) {
3428 } else if (choice == _("Lock Edit")) {
3432 Config->set_edit_mode (mode);
3436 Editor::snap_type_selection_done ()
3438 string choice = snap_type_selector.get_active_text();
3439 SnapType snaptype = SnapToBeat;
3441 if (choice == _("Beats/3")) {
3442 snaptype = SnapToAThirdBeat;
3443 } else if (choice == _("Beats/4")) {
3444 snaptype = SnapToAQuarterBeat;
3445 } else if (choice == _("Beats/8")) {
3446 snaptype = SnapToAEighthBeat;
3447 } else if (choice == _("Beats/16")) {
3448 snaptype = SnapToASixteenthBeat;
3449 } else if (choice == _("Beats/32")) {
3450 snaptype = SnapToAThirtysecondBeat;
3451 } else if (choice == _("Beats")) {
3452 snaptype = SnapToBeat;
3453 } else if (choice == _("Bars")) {
3454 snaptype = SnapToBar;
3455 } else if (choice == _("Marks")) {
3456 snaptype = SnapToMark;
3457 } else if (choice == _("Region starts")) {
3458 snaptype = SnapToRegionStart;
3459 } else if (choice == _("Region ends")) {
3460 snaptype = SnapToRegionEnd;
3461 } else if (choice == _("Region bounds")) {
3462 snaptype = SnapToRegionBoundary;
3463 } else if (choice == _("Region syncs")) {
3464 snaptype = SnapToRegionSync;
3465 } else if (choice == _("CD Frames")) {
3466 snaptype = SnapToCDFrame;
3467 } else if (choice == _("Timecode Frames")) {
3468 snaptype = SnapToTimecodeFrame;
3469 } else if (choice == _("Timecode Seconds")) {
3470 snaptype = SnapToTimecodeSeconds;
3471 } else if (choice == _("Timecode Minutes")) {
3472 snaptype = SnapToTimecodeMinutes;
3473 } else if (choice == _("Seconds")) {
3474 snaptype = SnapToSeconds;
3475 } else if (choice == _("Minutes")) {
3476 snaptype = SnapToMinutes;
3479 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3481 ract->set_active ();
3486 Editor::snap_mode_selection_done ()
3488 string choice = snap_mode_selector.get_active_text();
3489 SnapMode mode = SnapNormal;
3491 if (choice == _("No Grid")) {
3493 } else if (choice == _("Grid")) {
3495 } else if (choice == _("Magnetic")) {
3496 mode = SnapMagnetic;
3499 RefPtr<RadioAction> ract = snap_mode_action (mode);
3502 ract->set_active (true);
3507 Editor::cycle_edit_point (bool with_marker)
3509 switch (_edit_point) {
3511 set_edit_point_preference (EditAtPlayhead);
3513 case EditAtPlayhead:
3515 set_edit_point_preference (EditAtSelectedMarker);
3517 set_edit_point_preference (EditAtMouse);
3520 case EditAtSelectedMarker:
3521 set_edit_point_preference (EditAtMouse);
3527 Editor::edit_point_selection_done ()
3529 string choice = edit_point_selector.get_active_text();
3530 EditPoint ep = EditAtSelectedMarker;
3532 if (choice == _("Marker")) {
3533 set_edit_point_preference (EditAtSelectedMarker);
3534 } else if (choice == _("Playhead")) {
3535 set_edit_point_preference (EditAtPlayhead);
3537 set_edit_point_preference (EditAtMouse);
3540 RefPtr<RadioAction> ract = edit_point_action (ep);
3543 ract->set_active (true);
3548 Editor::zoom_focus_selection_done ()
3550 string choice = zoom_focus_selector.get_active_text();
3551 ZoomFocus focus_type = ZoomFocusLeft;
3553 if (choice == _("Left")) {
3554 focus_type = ZoomFocusLeft;
3555 } else if (choice == _("Right")) {
3556 focus_type = ZoomFocusRight;
3557 } else if (choice == _("Center")) {
3558 focus_type = ZoomFocusCenter;
3559 } else if (choice == _("Play")) {
3560 focus_type = ZoomFocusPlayhead;
3561 } else if (choice == _("Edit")) {
3562 focus_type = ZoomFocusEdit;
3563 } else if (choice == _("Active Mark")) {
3564 focus_type = ZoomFocusEdit;
3565 } else if (choice == _("Active Mark")) {
3566 focus_type = ZoomFocusEdit;
3568 focus_type = ZoomFocusMouse;
3571 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3574 ract->set_active ();
3579 Editor::edit_controls_button_release (GdkEventButton* ev)
3581 if (Keyboard::is_context_menu_event (ev)) {
3582 ARDOUR_UI::instance()->add_route (this);
3588 Editor::mouse_select_button_release (GdkEventButton* ev)
3590 /* this handles just right-clicks */
3592 if (ev->button != 3) {
3599 Editor::TrackViewList *
3600 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3602 TrackViewList::iterator i;
3604 TrackViewList* v = new TrackViewList;
3606 if (track == 0 && group == 0) {
3610 for (i = track_views.begin(); i != track_views.end (); ++i) {
3614 } else if ((track != 0 && group == 0) || (track != 0 && group != 0 && !group->active_property (RouteGroup::Select))) {
3616 /* just the view for this track
3619 v->push_back (track);
3623 /* views for all tracks in the route group */
3625 for (i = track_views.begin(); i != track_views.end (); ++i) {
3627 if (group == 0 || ((*i)->route_group() == group && group->active_property (RouteGroup::Select))) {
3637 Editor::set_zoom_focus (ZoomFocus f)
3639 string str = zoom_focus_strings[(int)f];
3641 if (str != zoom_focus_selector.get_active_text()) {
3642 zoom_focus_selector.set_active_text (str);
3645 if (zoom_focus != f) {
3648 ZoomFocusChanged (); /* EMIT_SIGNAL */
3655 Editor::ensure_float (Window& win)
3657 win.set_transient_for (*this);
3661 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3663 /* recover or initialize pane positions. do this here rather than earlier because
3664 we don't want the positions to change the child allocations, which they seem to do.
3670 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3672 static int32_t done;
3675 width = default_width;
3676 height = default_height;
3678 if ((geometry = find_named_node (*node, "geometry")) != 0) {
3680 if ((prop = geometry->property ("x_size")) == 0) {
3681 prop = geometry->property ("x-size");
3684 width = atoi (prop->value());
3686 if ((prop = geometry->property ("y_size")) == 0) {
3687 prop = geometry->property ("y-size");
3690 height = atoi (prop->value());
3694 if (which == static_cast<Paned*> (&edit_pane)) {
3700 if (!geometry || (prop = geometry->property ("edit-pane-pos")) == 0) {
3701 /* initial allocation is 90% to canvas, 10% to notebook */
3702 pos = (int) floor (alloc.get_width() * 0.90f);
3703 snprintf (buf, sizeof(buf), "%d", pos);
3705 pos = atoi (prop->value());
3708 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3709 edit_pane.set_position (pos);
3710 pre_maximal_pane_position = pos;
3716 Editor::detach_tearoff (Box* /*b*/, Window* /*w*/)
3718 cerr << "remove tearoff\n";
3720 if (tools_tearoff->torn_off() &&
3721 mouse_mode_tearoff->torn_off()) {
3722 top_hbox.remove (toolbar_frame);
3727 Editor::reattach_tearoff (Box* /*b*/, Window* /*w*/, int32_t /*n*/)
3729 cerr << "reattach tearoff\n";
3730 if (toolbar_frame.get_parent() == 0) {
3731 top_hbox.pack_end (toolbar_frame);
3736 Editor::set_show_measures (bool yn)
3738 if (_show_measures != yn) {
3741 if ((_show_measures = yn) == true) {
3743 tempo_lines->show();
3751 Editor::toggle_follow_playhead ()
3753 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3755 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3756 set_follow_playhead (tact->get_active());
3761 Editor::set_follow_playhead (bool yn)
3763 if (_follow_playhead != yn) {
3764 if ((_follow_playhead = yn) == true) {
3766 update_current_screen ();
3773 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
3775 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3777 xfade->set_active (!xfade->active());
3782 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
3784 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3786 xfade->set_follow_overlap (!xfade->following_overlap());
3791 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
3793 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3799 CrossfadeEditor cew (*session, xfade, xfade->fade_in().get_min_y(), 1.0);
3803 switch (cew.run ()) {
3804 case RESPONSE_ACCEPT:
3811 xfade->StateChanged (Change (~0));
3815 Editor::playlist_selector () const
3817 return *_playlist_selector;
3821 Editor::get_grid_type_as_beats (bool& success, nframes64_t position)
3825 switch (_snap_type) {
3830 case SnapToAThirtysecondBeat:
3834 case SnapToASixteenthBeat:
3838 case SnapToAEighthBeat:
3842 case SnapToAQuarterBeat:
3846 case SnapToAThirdBeat:
3852 return session->tempo_map().meter_at (position).beats_per_bar();
3857 case SnapToTimecodeFrame:
3858 case SnapToTimecodeSeconds:
3859 case SnapToTimecodeMinutes:
3862 case SnapToRegionStart:
3863 case SnapToRegionEnd:
3864 case SnapToRegionSync:
3865 case SnapToRegionBoundary:
3875 Editor::get_nudge_distance (nframes64_t pos, nframes64_t& next)
3879 ret = nudge_clock.current_duration (pos);
3880 next = ret + 1; /* XXXX fix me */
3886 Editor::end_location_changed (Location* location)
3888 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3889 //reset_scrolling_region ();
3890 nframes64_t session_span = location->start() + (nframes64_t) floorf (current_page_frames() * 0.10f);
3891 horizontal_adjustment.set_upper (session_span / frames_per_unit);
3895 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
3897 ArdourDialog dialog ("playlist deletion dialog");
3898 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3899 "If left alone, no audio files used by it will be cleaned.\n"
3900 "If deleted, audio files used by it alone by will cleaned."),
3903 dialog.set_position (WIN_POS_CENTER);
3904 dialog.get_vbox()->pack_start (label);
3908 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3909 dialog.add_button (_("Keep playlist"), RESPONSE_REJECT);
3910 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3912 switch (dialog.run ()) {
3913 case RESPONSE_ACCEPT:
3914 /* delete the playlist */
3918 case RESPONSE_REJECT:
3919 /* keep the playlist */
3931 Editor::audio_region_selection_covers (nframes64_t where)
3933 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3934 if ((*a)->region()->covers (where)) {
3943 Editor::prepare_for_cleanup ()
3945 cut_buffer->clear_regions ();
3946 cut_buffer->clear_playlists ();
3948 selection->clear_regions ();
3949 selection->clear_playlists ();
3951 _regions->suspend_redisplay ();
3955 Editor::finish_cleanup ()
3957 _regions->resume_redisplay ();
3961 Editor::transport_loop_location()
3964 return session->locations()->auto_loop_location();
3971 Editor::transport_punch_location()
3974 return session->locations()->auto_punch_location();
3981 Editor::control_layout_scroll (GdkEventScroll* ev)
3983 switch (ev->direction) {
3985 scroll_tracks_up_line ();
3989 case GDK_SCROLL_DOWN:
3990 scroll_tracks_down_line ();
3994 /* no left/right handling yet */
4002 Editor::session_state_saved (string snap_name)
4004 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4006 _snapshots->redisplay ();
4010 Editor::maximise_editing_space ()
4012 mouse_mode_tearoff->set_visible (false);
4013 tools_tearoff->set_visible (false);
4015 pre_maximal_pane_position = edit_pane.get_position();
4016 pre_maximal_editor_width = this->get_width();
4018 if(post_maximal_pane_position == 0) {
4019 post_maximal_pane_position = edit_pane.get_width();
4024 if(post_maximal_editor_width) {
4025 edit_pane.set_position (post_maximal_pane_position -
4026 abs(post_maximal_editor_width - pre_maximal_editor_width));
4028 edit_pane.set_position (post_maximal_pane_position);
4033 Editor::restore_editing_space ()
4035 // user changed width of pane during fullscreen
4037 if(post_maximal_pane_position != edit_pane.get_position()) {
4038 post_maximal_pane_position = edit_pane.get_position();
4043 mouse_mode_tearoff->set_visible (true);
4044 tools_tearoff->set_visible (true);
4045 post_maximal_editor_width = this->get_width();
4047 edit_pane.set_position (pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width));
4051 * Make new playlists for a given track and also any others that belong
4052 * to the same active route group with the `edit' property.
4057 Editor::new_playlists (TimeAxisView* v)
4059 begin_reversible_command (_("new playlists"));
4060 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4061 session->get_playlists(playlists);
4062 mapover_tracks (bind (mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v, RouteGroup::Edit);
4063 commit_reversible_command ();
4067 * Use a copy of the current playlist for a given track and also any others that belong
4068 * to the same active route group with the `edit' property.
4073 Editor::copy_playlists (TimeAxisView* v)
4075 begin_reversible_command (_("copy playlists"));
4076 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4077 session->get_playlists(playlists);
4078 mapover_tracks (bind (mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v, RouteGroup::Edit);
4079 commit_reversible_command ();
4082 /** Clear the current playlist for a given track and also any others that belong
4083 * to the same active route group with the `edit' property.
4088 Editor::clear_playlists (TimeAxisView* v)
4090 begin_reversible_command (_("clear playlists"));
4091 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4092 session->get_playlists(playlists);
4093 mapover_tracks (mem_fun (*this, &Editor::mapped_clear_playlist), v, RouteGroup::Edit);
4094 commit_reversible_command ();
4098 Editor::mapped_use_new_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4100 atv.use_new_playlist (sz > 1 ? false : true, playlists);
4104 Editor::mapped_use_copy_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4106 atv.use_copy_playlist (sz > 1 ? false : true, playlists);
4110 Editor::mapped_clear_playlist (RouteTimeAxisView& atv, uint32_t /*sz*/)
4112 atv.clear_playlist ();
4116 Editor::on_key_press_event (GdkEventKey* ev)
4118 return key_press_focus_accelerator_handler (*this, ev);
4122 Editor::on_key_release_event (GdkEventKey* ev)
4124 return Gtk::Window::on_key_release_event (ev);
4125 // return key_press_focus_accelerator_handler (*this, ev);
4129 Editor::reset_x_origin (nframes64_t frame)
4131 //cerr << "resetting x origin" << endl;
4132 queue_visual_change (frame);
4136 Editor::reset_y_origin (double y)
4138 queue_visual_change_y (y);
4142 Editor::reset_zoom (double fpu)
4144 queue_visual_change (fpu);
4148 Editor::reposition_and_zoom (nframes64_t frame, double fpu)
4150 //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
4151 reset_x_origin (frame);
4154 if (!no_save_visual) {
4155 undo_visual_stack.push_back (current_visual_state(false));
4159 Editor::VisualState*
4160 Editor::current_visual_state (bool with_tracks)
4162 VisualState* vs = new VisualState;
4163 vs->y_position = vertical_adjustment.get_value();
4164 vs->frames_per_unit = frames_per_unit;
4165 vs->leftmost_frame = leftmost_frame;
4166 vs->zoom_focus = zoom_focus;
4169 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4170 vs->track_states.push_back (TAVState ((*i), &(*i)->get_state()));
4178 Editor::undo_visual_state ()
4180 if (undo_visual_stack.empty()) {
4184 VisualState* vs = undo_visual_stack.back();
4185 undo_visual_stack.pop_back();
4186 use_visual_state (*vs);
4187 redo_visual_stack.push_back (vs);
4191 Editor::redo_visual_state ()
4193 if (redo_visual_stack.empty()) {
4197 VisualState* vs = redo_visual_stack.back();
4198 redo_visual_stack.pop_back();
4199 use_visual_state (*vs);
4200 undo_visual_stack.push_back (vs);
4204 Editor::swap_visual_state ()
4206 if (undo_visual_stack.empty()) {
4207 redo_visual_state ();
4209 undo_visual_state ();
4214 Editor::use_visual_state (VisualState& vs)
4216 no_save_visual = true;
4218 _routes->suspend_redisplay ();
4220 vertical_adjustment.set_value (vs.y_position);
4222 set_zoom_focus (vs.zoom_focus);
4223 reposition_and_zoom (vs.leftmost_frame, vs.frames_per_unit);
4225 for (list<TAVState>::iterator i = vs.track_states.begin(); i != vs.track_states.end(); ++i) {
4226 TrackViewList::iterator t;
4228 /* check if the track still exists - it could have been deleted */
4230 if ((t = find (track_views.begin(), track_views.end(), i->first)) != track_views.end()) {
4231 (*t)->set_state (*(i->second), Stateful::loading_state_version);
4236 if (!vs.track_states.empty()) {
4237 _routes->update_visibility ();
4240 _routes->resume_redisplay ();
4242 no_save_visual = false;
4246 Editor::set_frames_per_unit (double fpu)
4248 /* this is the core function that controls the zoom level of the canvas. it is called
4249 whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
4252 if (fpu == frames_per_unit) {
4261 /* don't allow zooms that fit more than the maximum number
4262 of frames into an 800 pixel wide space.
4265 if (max_frames / fpu < 800.0) {
4270 tempo_lines->tempo_map_changed();
4272 frames_per_unit = fpu;
4277 Editor::post_zoom ()
4279 nframes64_t cef = 0;
4281 // convert fpu to frame count
4283 nframes64_t frames = (nframes64_t) floor (frames_per_unit * _canvas_width);
4285 if (frames_per_unit != zoom_range_clock.current_duration()) {
4286 zoom_range_clock.set (frames);
4289 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
4290 if (!selection->tracks.empty()) {
4291 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4292 (*i)->reshow_selection (selection->time);
4295 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4296 (*i)->reshow_selection (selection->time);
4301 leftmost_frame = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4303 ZoomChanged (); /* EMIT_SIGNAL */
4305 reset_hscrollbar_stepping ();
4308 cef = session->current_end_frame() + (current_page_frames() / 10);// Add a little extra so we can see the end marker
4310 horizontal_adjustment.set_upper (cef / frames_per_unit);
4312 //reset_scrolling_region ();
4314 if (playhead_cursor) {
4315 playhead_cursor->set_position (playhead_cursor->current_frame);
4318 refresh_location_display();
4319 _summary->set_overlays_dirty ();
4325 Editor::queue_visual_change (nframes64_t where)
4327 pending_visual_change.add (VisualChange::TimeOrigin);
4329 /* if we're moving beyond the end, make sure the upper limit of the horizontal adjustment
4333 if (where > session->current_end_frame()) {
4334 horizontal_adjustment.set_upper ((where + current_page_frames()) / frames_per_unit);
4337 pending_visual_change.time_origin = where;
4339 ensure_visual_change_idle_handler ();
4343 Editor::queue_visual_change (double fpu)
4345 pending_visual_change.add (VisualChange::ZoomLevel);
4346 pending_visual_change.frames_per_unit = fpu;
4348 ensure_visual_change_idle_handler ();
4353 Editor::queue_visual_change_y (double y)
4355 pending_visual_change.add (VisualChange::YOrigin);
4356 pending_visual_change.y_origin = y;
4358 ensure_visual_change_idle_handler ();
4362 Editor::ensure_visual_change_idle_handler ()
4364 if (pending_visual_change.idle_handler_id < 0) {
4365 pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
4370 Editor::_idle_visual_changer (void* arg)
4372 return static_cast<Editor*>(arg)->idle_visual_changer ();
4376 Editor::idle_visual_changer ()
4378 VisualChange::Type p = pending_visual_change.pending;
4379 pending_visual_change.pending = (VisualChange::Type) 0;
4381 #ifdef FIX_THIS_FOR_V3
4382 double last_time_origin = horizontal_adjustment.get_value();
4385 if (p & VisualChange::ZoomLevel) {
4386 set_frames_per_unit (pending_visual_change.frames_per_unit);
4388 compute_fixed_ruler_scale ();
4389 compute_current_bbt_points(pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4390 compute_bbt_ruler_scale (pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4391 update_tempo_based_rulers ();
4393 if (p & VisualChange::TimeOrigin) {
4394 horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
4396 if (p & VisualChange::YOrigin) {
4397 vertical_adjustment.set_value (pending_visual_change.y_origin);
4400 nframes64_t csf=0, cef=0;
4401 nframes64_t current_time_origin = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4404 csf = session->current_start_frame();
4405 cef = session->current_end_frame();
4408 /* if we seek beyond the current end of the canvas, move the end */
4410 #ifdef FIX_THIS_FOR_V3
4411 if (last_time_origin == horizontal_adjustment.get_value() ) {
4412 /* changed signal not emitted */
4413 update_fixed_rulers ();
4414 redisplay_tempo (true);
4418 if (current_time_origin != pending_visual_change.time_origin) {
4419 cef += current_page_frames() / 10; // Add a little extra so we can see the end marker
4420 horizontal_adjustment.set_upper (cef / frames_per_unit);
4421 horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
4423 update_fixed_rulers();
4424 redisplay_tempo (true);
4427 _summary->set_overlays_dirty ();
4429 //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
4430 pending_visual_change.idle_handler_id = -1;
4431 return 0; /* this is always a one-shot call */
4434 struct EditorOrderTimeAxisSorter {
4435 bool operator() (const TimeAxisView* a, const TimeAxisView* b) const {
4436 return a->order () < b->order ();
4441 Editor::sort_track_selection (TrackSelection* sel)
4443 EditorOrderTimeAxisSorter cmp;
4448 selection->tracks.sort (cmp);
4453 Editor::get_preferred_edit_position (bool ignore_playhead)
4456 nframes64_t where = 0;
4457 EditPoint ep = _edit_point;
4459 if (entered_marker) {
4460 return entered_marker->position();
4463 if (ignore_playhead && ep == EditAtPlayhead) {
4464 ep = EditAtSelectedMarker;
4468 case EditAtPlayhead:
4469 where = session->audible_frame();
4472 case EditAtSelectedMarker:
4473 if (!selection->markers.empty()) {
4475 Location* loc = find_location_from_marker (selection->markers.front(), is_start);
4478 where = loc->start();
4489 if (!mouse_frame (where, ignored)) {
4490 /* XXX not right but what can we do ? */
4501 Editor::set_loop_range (nframes64_t start, nframes64_t end, string cmd)
4503 if (!session) return;
4505 begin_reversible_command (cmd);
4509 if ((tll = transport_loop_location()) == 0) {
4510 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoLoop);
4511 XMLNode &before = session->locations()->get_state();
4512 session->locations()->add (loc, true);
4513 session->set_auto_loop_location (loc);
4514 XMLNode &after = session->locations()->get_state();
4515 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4517 XMLNode &before = tll->get_state();
4518 tll->set_hidden (false, this);
4519 tll->set (start, end);
4520 XMLNode &after = tll->get_state();
4521 session->add_command (new MementoCommand<Location>(*tll, &before, &after));
4524 commit_reversible_command ();
4528 Editor::set_punch_range (nframes64_t start, nframes64_t end, string cmd)
4530 if (!session) return;
4532 begin_reversible_command (cmd);
4536 if ((tpl = transport_punch_location()) == 0) {
4537 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoPunch);
4538 XMLNode &before = session->locations()->get_state();
4539 session->locations()->add (loc, true);
4540 session->set_auto_loop_location (loc);
4541 XMLNode &after = session->locations()->get_state();
4542 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4545 XMLNode &before = tpl->get_state();
4546 tpl->set_hidden (false, this);
4547 tpl->set (start, end);
4548 XMLNode &after = tpl->get_state();
4549 session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
4552 commit_reversible_command ();
4555 /** Find regions which exist at a given time, and optionally on a given list of tracks.
4556 * @param rs List to which found regions are added.
4557 * @param where Time to look at.
4558 * @param ts Tracks to look on; if this is empty, all tracks are examined.
4561 Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4563 const TrackSelection* tracks;
4566 tracks = &track_views;
4571 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4572 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4574 boost::shared_ptr<Diskstream> ds;
4575 boost::shared_ptr<Playlist> pl;
4577 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
4579 Playlist::RegionList* regions = pl->regions_at (
4580 (nframes64_t) floor ( (double)where * ds->speed()));
4582 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4583 RegionView* rv = rtv->view()->find_view (*i);
4596 Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4598 const TrackSelection* tracks;
4601 tracks = &track_views;
4606 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4607 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4609 boost::shared_ptr<Diskstream> ds;
4610 boost::shared_ptr<Playlist> pl;
4612 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
4614 Playlist::RegionList* regions = pl->regions_touched (
4615 (nframes64_t) floor ( (double)where * ds->speed()), max_frames);
4617 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4619 RegionView* rv = rtv->view()->find_view (*i);
4632 /** Find all regions which are either:
4634 * - the entered_regionview (if allow_entered == true) or
4635 * - under the preferred edit position AND on a selected track, or on a track
4636 * which is in the same active edit-enable route group as a selected region (if allow_edit_position == true)
4637 * @param rs Returned region list.
4638 * @param allow_entered true to include the entered_regionview in the list.
4641 Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered, bool allow_edit_position)
4643 /* Start with selected regions */
4644 rs = selection->regions;
4646 /* Add the entered_regionview, if requested */
4647 if (allow_entered && entered_regionview) {
4648 rs.add (entered_regionview);
4651 if (allow_edit_position) {
4653 TrackSelection tracks = selection->tracks;
4655 /* tracks is currently the set of selected tracks; add any other tracks that
4656 * have regions that are in the same edit-activated route group as one of
4658 for (RegionSelection::iterator i = rs.begin (); i != rs.end(); ++i) {
4660 RouteGroup* g = (*i)->get_time_axis_view().route_group ();
4661 if (g && g->active_property (RouteGroup::Edit)) {
4662 tracks.add (axis_views_from_routes (g->route_list()));
4666 /* now find regions that are at the edit position on those tracks */
4667 nframes64_t const where = get_preferred_edit_position ();
4668 get_regions_at (rs, where, tracks);
4673 Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<RegionView*>& regions)
4675 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4677 RouteTimeAxisView* tatv;
4679 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
4681 boost::shared_ptr<Playlist> pl;
4682 vector<boost::shared_ptr<Region> > results;
4684 boost::shared_ptr<Diskstream> ds;
4686 if ((ds = tatv->get_diskstream()) == 0) {
4691 if ((pl = (ds->playlist())) != 0) {
4692 pl->get_region_list_equivalent_regions (region, results);
4695 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
4696 if ((marv = tatv->view()->find_view (*ir)) != 0) {
4697 regions.push_back (marv);
4706 Editor::show_rhythm_ferret ()
4708 if (rhythm_ferret == 0) {
4709 rhythm_ferret = new RhythmFerret(*this);
4712 rhythm_ferret->set_session (session);
4713 rhythm_ferret->show ();
4714 rhythm_ferret->present ();
4718 Editor::show_bundle_manager ()
4720 if (_bundle_manager == 0) {
4721 _bundle_manager = new BundleManager (*session);
4724 _bundle_manager->show ();
4728 Editor::show_global_port_matrix (ARDOUR::DataType t)
4730 if (_global_port_matrix[t] == 0) {
4731 _global_port_matrix[t] = new GlobalPortMatrixWindow (*session, t);
4734 _global_port_matrix[t]->show ();
4738 Editor::first_idle ()
4740 MessageDialog* dialog = 0;
4742 if (track_views.size() > 1) {
4743 dialog = new MessageDialog (*this,
4744 _("Please wait while Ardour loads visual data"),
4749 ARDOUR_UI::instance()->flush_pending ();
4752 for (TrackViewList::iterator t = track_views.begin(); t != track_views.end(); ++t) {
4756 // first idle adds route children (automation tracks), so we need to redisplay here
4757 _routes->redisplay ();
4765 _idle_resizer (gpointer arg)
4767 return ((Editor*)arg)->idle_resize ();
4771 Editor::add_to_idle_resize (TimeAxisView* view, int32_t h)
4773 if (resize_idle_id < 0) {
4774 resize_idle_id = g_idle_add (_idle_resizer, this);
4775 _pending_resize_amount = 0;
4778 /* make a note of the smallest resulting height, so that we can clamp the
4779 lower limit at TimeAxisView::hSmall */
4781 int32_t min_resulting = INT32_MAX;
4783 _pending_resize_amount += h;
4784 _pending_resize_view = view;
4786 min_resulting = min (min_resulting, int32_t (_pending_resize_view->current_height()) + _pending_resize_amount);
4788 if (selection->tracks.contains (_pending_resize_view)) {
4789 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4790 min_resulting = min (min_resulting, int32_t ((*i)->current_height()) + _pending_resize_amount);
4794 if (min_resulting < 0) {
4799 if (uint32_t (min_resulting) < TimeAxisView::hSmall) {
4800 _pending_resize_amount += TimeAxisView::hSmall - min_resulting;
4804 /** Handle pending resizing of tracks */
4806 Editor::idle_resize ()
4808 _pending_resize_view->idle_resize (_pending_resize_view->current_height() + _pending_resize_amount);
4810 if (dynamic_cast<AutomationTimeAxisView*> (_pending_resize_view) == 0 &&
4811 selection->tracks.contains (_pending_resize_view)) {
4813 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4814 if (*i != _pending_resize_view) {
4815 (*i)->idle_resize ((*i)->current_height() + _pending_resize_amount);
4821 _group_tabs->set_dirty ();
4822 resize_idle_id = -1;
4830 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::located));
4832 _pending_locate_request = false;
4836 Editor::region_view_added (RegionView *)
4838 _summary->set_dirty ();
4842 Editor::streamview_height_changed ()
4844 _summary->set_dirty ();
4848 Editor::axis_view_from_route (Route* r) const
4850 TrackViewList::const_iterator j = track_views.begin ();
4851 while (j != track_views.end()) {
4852 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*j);
4853 if (rtv && rtv->route().get() == r) {
4864 Editor::axis_views_from_routes (list<Route*> r) const
4868 for (list<Route*>::const_iterator i = r.begin(); i != r.end(); ++i) {
4869 TimeAxisView* tv = axis_view_from_route (*i);
4880 Editor::handle_new_route (RouteList& routes)
4882 ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_route), routes));
4884 RouteTimeAxisView *rtv;
4885 list<RouteTimeAxisView*> new_views;
4887 for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) {
4888 boost::shared_ptr<Route> route = (*x);
4890 if (route->is_hidden()) {
4894 DataType dt = route->input()->default_type();
4896 if (dt == ARDOUR::DataType::AUDIO) {
4897 rtv = new AudioTimeAxisView (*this, *session, route, *track_canvas);
4898 } else if (dt == ARDOUR::DataType::MIDI) {
4899 rtv = new MidiTimeAxisView (*this, *session, route, *track_canvas);
4901 throw unknown_type();
4904 new_views.push_back (rtv);
4905 track_views.push_back (rtv);
4907 rtv->effective_gain_display ();
4909 rtv->view()->RegionViewAdded.connect (mem_fun (*this, &Editor::region_view_added));
4910 rtv->view()->HeightChanged.connect (mem_fun (*this, &Editor::streamview_height_changed));
4912 rtv->GoingAway.connect (bind (mem_fun(*this, &Editor::remove_route), rtv));
4915 _routes->routes_added (new_views);
4917 if (show_editor_mixer_when_tracks_arrive) {
4918 show_editor_mixer (true);
4921 editor_list_button.set_sensitive (true);
4923 _summary->set_dirty ();
4927 Editor::remove_route (TimeAxisView *tv)
4929 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::remove_route), tv));
4931 TrackViewList::iterator i;
4933 boost::shared_ptr<Route> route;
4934 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (tv);
4936 route = rtav->route ();
4939 TimeAxisView* next_tv = 0;
4941 if (tv == entered_track) {
4945 if ((i = find (track_views.begin(), track_views.end(), tv)) != track_views.end()) {
4947 i = track_views.erase (i);
4949 if (track_views.empty()) {
4951 } else if (i == track_views.end()) {
4952 next_tv = track_views.front();
4958 if (current_mixer_strip && current_mixer_strip->route() == route) {
4961 set_selected_mixer_strip (*next_tv);
4963 /* make the editor mixer strip go away setting the
4964 * button to inactive (which also unticks the menu option)
4967 ActionManager::uncheck_toggleaction ("<Actions>/Editor/show-editor-mixer");
4973 Editor::hide_track_in_display (TimeAxisView& tv, bool /*temponly*/)
4975 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (&tv);
4977 if (rtv && current_mixer_strip && (rtv->route() == current_mixer_strip->route())) {
4978 // this will hide the mixer strip
4979 set_selected_mixer_strip (tv);
4982 _routes->hide_track_in_display (tv);
4986 Editor::sync_track_view_list_and_routes ()
4988 track_views = TrackSelection (_routes->views ());
4990 _summary->set_dirty ();
4991 _group_tabs->set_dirty ();
4993 return false; // do not call again (until needed)
4997 Editor::foreach_time_axis_view (sigc::slot<void,TimeAxisView&> theslot)
4999 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5005 Editor::get_route_view_by_id (PBD::ID& id)
5007 RouteTimeAxisView* v;
5009 for(TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5010 if((v = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) {
5011 if(v->route()->id() == id) {
5021 Editor::fit_route_group (RouteGroup *g)
5023 TrackSelection ts = axis_views_from_routes (g->route_list ());
5028 Editor::consider_auditioning (boost::shared_ptr<Region> region)
5030 boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion> (region);
5033 session->cancel_audition ();
5037 if (session->is_auditioning()) {
5038 session->cancel_audition ();
5039 if (r == last_audition_region) {
5044 session->audition_region (r);
5045 last_audition_region = r;
5050 Editor::hide_a_region (boost::shared_ptr<Region> r)
5052 r->set_hidden (true);
5056 Editor::remove_a_region (boost::shared_ptr<Region> r)
5058 session->remove_region_from_region_list (r);
5062 Editor::audition_region_from_region_list ()
5064 _regions->selection_mapover (mem_fun (*this, &Editor::consider_auditioning));
5068 Editor::hide_region_from_region_list ()
5070 _regions->selection_mapover (mem_fun (*this, &Editor::hide_a_region));
5074 Editor::start_step_editing ()
5076 step_edit_connection = Glib::signal_timeout().connect (mem_fun (*this, &Editor::check_step_edit), 20);
5080 Editor::stop_step_editing ()
5082 step_edit_connection.disconnect ();
5086 Editor::check_step_edit ()
5088 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5089 MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*> (*i);
5091 mtv->check_step_edit ();
5095 return true; // do it again, till we stop