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 , zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true)
239 , toolbar_selection_clock_table (2,3)
241 , automation_mode_button (_("mode"))
242 , global_automation_button (_("automation"))
244 , midi_panic_button (_("Panic"))
247 , image_socket_listener(0)
252 , nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true)
253 , meters_running(false)
254 , _pending_locate_request (false)
259 /* we are a singleton */
261 PublicEditor::_instance = this;
266 selection = new Selection (this);
267 cut_buffer = new Selection (this);
269 clicked_regionview = 0;
270 clicked_axisview = 0;
271 clicked_routeview = 0;
272 clicked_crossfadeview = 0;
273 clicked_control_point = 0;
274 last_update_frame = 0;
276 current_mixer_strip = 0;
277 current_bbt_points = 0;
280 snap_type_strings = I18N (_snap_type_strings);
281 snap_mode_strings = I18N (_snap_mode_strings);
282 zoom_focus_strings = I18N (_zoom_focus_strings);
283 edit_point_strings = I18N (_edit_point_strings);
284 #ifdef USE_RUBBERBAND
285 rb_opt_strings = I18N (_rb_opt_strings);
288 snap_threshold = 5.0;
289 bbt_beat_subdivision = 4;
292 last_autoscroll_x = 0;
293 last_autoscroll_y = 0;
294 autoscroll_active = false;
295 autoscroll_timeout_tag = -1;
296 interthread_progress_window = 0;
301 current_interthread_info = 0;
302 _show_measures = true;
303 _show_waveforms_recording = true;
304 show_gain_after_trim = false;
305 verbose_cursor_on = true;
306 route_removal = false;
307 last_item_entered = 0;
308 last_item_entered_n = 0;
310 have_pending_keyboard_selection = false;
311 _follow_playhead = true;
312 _xfade_visibility = true;
313 editor_ruler_menu = 0;
314 no_ruler_shown_update = false;
316 start_end_marker_menu = 0;
317 range_marker_menu = 0;
318 marker_menu_item = 0;
320 transport_marker_menu = 0;
321 new_transport_marker_menu = 0;
322 editor_mixer_strip_width = Wide;
323 show_editor_mixer_when_tracks_arrive = false;
324 region_edit_menu_split_multichannel_item = 0;
325 region_edit_menu_split_item = 0;
328 current_stepping_trackview = 0;
330 entered_regionview = 0;
332 clear_entered_track = false;
333 _new_regionviews_show_envelope = false;
336 button_release_can_deselect = true;
337 _dragging_playhead = false;
338 _dragging_edit_point = false;
339 _dragging_hscrollbar = false;
340 select_new_marker = false;
343 for (ARDOUR::DataType::iterator i = ARDOUR::DataType::begin(); i != ARDOUR::DataType::end(); ++i) {
344 _global_port_matrix[*i] = 0;
346 allow_vertical_scroll = false;
347 no_save_visual = false;
350 scrubbing_direction = 0;
354 location_marker_color = ARDOUR_UI::config()->canvasvar_LocationMarker.get();
355 location_range_color = ARDOUR_UI::config()->canvasvar_LocationRange.get();
356 location_cd_marker_color = ARDOUR_UI::config()->canvasvar_LocationCDMarker.get();
357 location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
358 location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
360 _edit_point = EditAtMouse;
361 _internal_editing = false;
362 current_canvas_cursor = 0;
364 frames_per_unit = 2048; /* too early to use reset_zoom () */
365 reset_hscrollbar_stepping ();
367 zoom_focus = ZoomFocusLeft;
368 set_zoom_focus (ZoomFocusLeft);
369 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
371 bbt_label.set_name ("EditorTimeButton");
372 bbt_label.set_size_request (-1, (int)timebar_height);
373 bbt_label.set_alignment (1.0, 0.5);
374 bbt_label.set_padding (5,0);
376 bbt_label.set_no_show_all();
377 minsec_label.set_name ("EditorTimeButton");
378 minsec_label.set_size_request (-1, (int)timebar_height);
379 minsec_label.set_alignment (1.0, 0.5);
380 minsec_label.set_padding (5,0);
381 minsec_label.hide ();
382 minsec_label.set_no_show_all();
383 timecode_label.set_name ("EditorTimeButton");
384 timecode_label.set_size_request (-1, (int)timebar_height);
385 timecode_label.set_alignment (1.0, 0.5);
386 timecode_label.set_padding (5,0);
387 timecode_label.hide ();
388 timecode_label.set_no_show_all();
389 frame_label.set_name ("EditorTimeButton");
390 frame_label.set_size_request (-1, (int)timebar_height);
391 frame_label.set_alignment (1.0, 0.5);
392 frame_label.set_padding (5,0);
394 frame_label.set_no_show_all();
396 tempo_label.set_name ("EditorTimeButton");
397 tempo_label.set_size_request (-1, (int)timebar_height);
398 tempo_label.set_alignment (1.0, 0.5);
399 tempo_label.set_padding (5,0);
401 tempo_label.set_no_show_all();
402 meter_label.set_name ("EditorTimeButton");
403 meter_label.set_size_request (-1, (int)timebar_height);
404 meter_label.set_alignment (1.0, 0.5);
405 meter_label.set_padding (5,0);
407 meter_label.set_no_show_all();
408 mark_label.set_name ("EditorTimeButton");
409 mark_label.set_size_request (-1, (int)timebar_height);
410 mark_label.set_alignment (1.0, 0.5);
411 mark_label.set_padding (5,0);
413 mark_label.set_no_show_all();
414 cd_mark_label.set_name ("EditorTimeButton");
415 cd_mark_label.set_size_request (-1, (int)timebar_height);
416 cd_mark_label.set_alignment (1.0, 0.5);
417 cd_mark_label.set_padding (5,0);
418 cd_mark_label.hide();
419 cd_mark_label.set_no_show_all();
420 range_mark_label.set_name ("EditorTimeButton");
421 range_mark_label.set_size_request (-1, (int)timebar_height);
422 range_mark_label.set_alignment (1.0, 0.5);
423 range_mark_label.set_padding (5,0);
424 range_mark_label.hide();
425 range_mark_label.set_no_show_all();
426 transport_mark_label.set_name ("EditorTimeButton");
427 transport_mark_label.set_size_request (-1, (int)timebar_height);
428 transport_mark_label.set_alignment (1.0, 0.5);
429 transport_mark_label.set_padding (5,0);
430 transport_mark_label.hide();
431 transport_mark_label.set_no_show_all();
433 initialize_rulers ();
434 _summary = new EditorSummary (this);
435 initialize_canvas ();
437 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
438 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
439 editor_regions_selection_changed_connection = selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
440 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
441 selection->MarkersChanged.connect (mem_fun(*this, &Editor::marker_selection_changed));
443 edit_controls_vbox.set_spacing (0);
444 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::scroll_canvas_horizontally), false);
445 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling), true);
446 track_canvas->signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
448 HBox* h = manage (new HBox);
449 _group_tabs = new EditorGroupTabs (this);
450 h->pack_start (*_group_tabs, PACK_SHRINK);
451 h->pack_start (edit_controls_vbox);
452 controls_layout.add (*h);
454 controls_layout.set_name ("EditControlsBase");
455 controls_layout.add_events (Gdk::SCROLL_MASK);
456 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
458 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
459 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
460 controls_layout_size_request_connection = controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
462 edit_vscrollbar.set_adjustment (vertical_adjustment);
463 edit_hscrollbar.set_adjustment (horizontal_adjustment);
465 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press), false);
466 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release), false);
467 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
469 edit_hscrollbar.set_name ("EditorHScrollbar");
473 ArdourCanvas::Canvas* time_pad = manage(new ArdourCanvas::Canvas());
474 ArdourCanvas::SimpleLine* pad_line_1 = manage(new ArdourCanvas::SimpleLine(*time_pad->root(),
475 0.0, 1.0, 100.0, 1.0));
476 pad_line_1->property_color_rgba() = 0xFF0000FF;
480 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars) + 2);
481 time_canvas_vbox.set_size_request (-1, -1);
483 ruler_label_event_box.add (ruler_label_vbox);
484 ruler_label_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
485 ruler_label_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
487 time_button_event_box.add (time_button_vbox);
488 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
489 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
491 /* these enable us to have a dedicated window (for cursor setting, etc.)
492 for the canvas areas.
495 track_canvas_event_box.add (*track_canvas);
497 time_canvas_event_box.add (time_canvas_vbox);
498 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
500 edit_packer.set_col_spacings (0);
501 edit_packer.set_row_spacings (0);
502 edit_packer.set_homogeneous (false);
503 edit_packer.set_border_width (0);
504 edit_packer.set_name ("EditorWindow");
506 edit_packer.attach (zoom_vbox, 0, 1, 0, 2, SHRINK, FILL, 0, 0);
507 /* labels for the rulers */
508 edit_packer.attach (ruler_label_event_box, 1, 2, 0, 1, FILL, SHRINK, 0, 0);
509 /* labels for the marker "tracks" */
510 edit_packer.attach (time_button_event_box, 1, 2, 1, 2, FILL, SHRINK, 0, 0);
512 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
514 edit_packer.attach (controls_layout, 0, 2, 2, 3, FILL, FILL|EXPAND, 0, 0);
516 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 3, FILL|EXPAND, FILL|EXPAND, 0, 0);
518 bottom_hbox.set_border_width (2);
519 bottom_hbox.set_spacing (3);
521 _route_groups = new EditorRouteGroups (this);
522 _routes = new EditorRoutes (this);
523 _regions = new EditorRegions (this);
524 _snapshots = new EditorSnapshots (this);
525 _locations = new EditorLocations (this);
529 nlabel = manage (new Label (_("Regions")));
530 nlabel->set_angle (-90);
531 the_notebook.append_page (_regions->widget (), *nlabel);
532 nlabel = manage (new Label (_("Tracks/Busses")));
533 nlabel->set_angle (-90);
534 the_notebook.append_page (_routes->widget (), *nlabel);
535 nlabel = manage (new Label (_("Snapshots")));
536 nlabel->set_angle (-90);
537 the_notebook.append_page (_snapshots->widget (), *nlabel);
538 nlabel = manage (new Label (_("Route Groups")));
539 nlabel->set_angle (-90);
540 the_notebook.append_page (_route_groups->widget (), *nlabel);
541 nlabel = manage (new Label (_("Ranges & Marks")));
542 nlabel->set_angle (-90);
543 the_notebook.append_page (_locations->widget (), *nlabel);
545 the_notebook.set_show_tabs (true);
546 the_notebook.set_scrollable (true);
547 the_notebook.popup_disable ();
548 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
549 the_notebook.show_all ();
551 post_maximal_editor_width = 0;
552 post_maximal_pane_position = 0;
554 VPaned *editor_summary_pane = manage(new VPaned());
555 editor_summary_pane->pack1(edit_packer);
556 editor_summary_pane->pack2(*_summary);
558 edit_pane.pack1 (*editor_summary_pane, true, true);
559 edit_pane.pack2 (the_notebook, false, true);
561 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
563 top_hbox.pack_start (toolbar_frame, false, true);
565 HBox *hbox = manage (new HBox);
566 hbox->pack_start (edit_pane, true, true);
568 global_vpacker.pack_start (top_hbox, false, false);
569 global_vpacker.pack_start (*hbox, true, true);
571 global_hpacker.pack_start (global_vpacker, true, true);
573 set_name ("EditorWindow");
574 add_accel_group (ActionManager::ui_manager->get_accel_group());
576 status_bar_hpacker.show ();
578 vpacker.pack_end (status_bar_hpacker, false, false);
579 vpacker.pack_end (global_hpacker, true, true);
581 /* register actions now so that set_state() can find them and set toggles/checks etc */
586 setup_midi_toolbar ();
588 _snap_type = SnapToBeat;
589 set_snap_to (_snap_type);
590 _snap_mode = SnapOff;
591 set_snap_mode (_snap_mode);
592 set_mouse_mode (MouseObject, true);
593 set_edit_point_preference (EditAtMouse, true);
595 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
596 set_state (*node, Stateful::loading_state_version);
598 _playlist_selector = new PlaylistSelector();
599 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
601 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
605 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
606 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
608 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
609 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
611 nudge_forward_button.set_name ("TransportButton");
612 nudge_backward_button.set_name ("TransportButton");
614 fade_context_menu.set_name ("ArdourContextMenu");
616 /* icons, titles, WM stuff */
618 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
619 Glib::RefPtr<Gdk::Pixbuf> icon;
621 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
622 window_icons.push_back (icon);
624 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
625 window_icons.push_back (icon);
627 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
628 window_icons.push_back (icon);
630 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
631 window_icons.push_back (icon);
633 if (!window_icons.empty()) {
634 set_icon_list (window_icons);
635 set_default_icon_list (window_icons);
638 WindowTitle title(Glib::get_application_name());
639 title += _("Editor");
640 set_title (title.get_string());
641 set_wmclass (X_("ardour_editor"), "Ardour");
644 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
646 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
647 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
649 /* allow external control surfaces/protocols to do various things */
651 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
652 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
653 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
654 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
655 BasicUI::AccessAction.connect (mem_fun (*this, &Editor::access_action));
657 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
659 _last_normalization_value = 0;
668 if(image_socket_listener) {
669 if(image_socket_listener->is_connected())
671 image_socket_listener->close_connection() ;
674 delete image_socket_listener ;
675 image_socket_listener = 0 ;
680 delete _route_groups;
686 Editor::add_toplevel_controls (Container& cont)
688 vpacker.pack_start (cont, false, false);
693 Editor::catch_vanishing_regionview (RegionView *rv)
695 /* note: the selection will take care of the vanishing
696 audioregionview by itself.
699 if (_drag && rv->get_canvas_group() == _drag->item() && !_drag->ending()) {
705 if (clicked_regionview == rv) {
706 clicked_regionview = 0;
709 if (entered_regionview == rv) {
710 set_entered_regionview (0);
715 Editor::set_entered_regionview (RegionView* rv)
717 if (rv == entered_regionview) {
721 if (entered_regionview) {
722 entered_regionview->exited ();
725 if ((entered_regionview = rv) != 0) {
726 entered_regionview->entered ();
731 Editor::set_entered_track (TimeAxisView* tav)
734 entered_track->exited ();
737 if ((entered_track = tav) != 0) {
738 entered_track->entered ();
743 Editor::show_window ()
745 if (! is_visible ()) {
748 /* re-hide editor list if necessary */
749 editor_list_button_toggled ();
751 /* re-hide summary widget if necessary */
752 parameter_changed ("show-summary");
754 parameter_changed ("show-edit-group-tabs");
756 /* now reset all audio_time_axis heights, because widgets might need
762 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
763 tv = (static_cast<TimeAxisView*>(*i));
772 Editor::instant_save ()
774 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
779 session->add_instant_xml(get_state());
781 Config->add_instant_xml(get_state());
786 Editor::zoom_adjustment_changed ()
792 double fpu = zoom_range_clock.current_duration() / _canvas_width;
796 zoom_range_clock.set ((nframes64_t) floor (fpu * _canvas_width));
797 } else if (fpu > session->current_end_frame() / _canvas_width) {
798 fpu = session->current_end_frame() / _canvas_width;
799 zoom_range_clock.set ((nframes64_t) floor (fpu * _canvas_width));
806 Editor::control_scroll (float fraction)
808 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
814 double step = fraction * current_page_frames();
817 _control_scroll_target is an optional<T>
819 it acts like a pointer to an nframes64_t, with
820 a operator conversion to boolean to check
821 that it has a value could possibly use
822 playhead_cursor->current_frame to store the
823 value and a boolean in the class to know
824 when it's out of date
827 if (!_control_scroll_target) {
828 _control_scroll_target = session->transport_frame();
829 _dragging_playhead = true;
832 if ((fraction < 0.0f) && (*_control_scroll_target < (nframes64_t) fabs(step))) {
833 *_control_scroll_target = 0;
834 } else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
835 *_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
837 *_control_scroll_target += (nframes64_t) floor (step);
840 /* move visuals, we'll catch up with it later */
842 playhead_cursor->set_position (*_control_scroll_target);
843 UpdateAllTransportClocks (*_control_scroll_target);
845 if (*_control_scroll_target > (current_page_frames() / 2)) {
846 /* try to center PH in window */
847 reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
853 Now we do a timeout to actually bring the session to the right place
854 according to the playhead. This is to avoid reading disk buffers on every
855 call to control_scroll, which is driven by ScrollTimeline and therefore
856 probably by a control surface wheel which can generate lots of events.
858 /* cancel the existing timeout */
860 control_scroll_connection.disconnect ();
862 /* add the next timeout */
864 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), *_control_scroll_target), 250);
868 Editor::deferred_control_scroll (nframes64_t /*target*/)
870 session->request_locate (*_control_scroll_target, session->transport_rolling());
871 // reset for next stream
872 _control_scroll_target = boost::none;
873 _dragging_playhead = false;
878 Editor::access_action (std::string action_group, std::string action_item)
884 ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::access_action), action_group, action_item));
887 act = ActionManager::get_action( action_group.c_str(), action_item.c_str() );
897 Editor::on_realize ()
899 Window::on_realize ();
904 Editor::start_scrolling ()
906 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
907 (mem_fun(*this, &Editor::update_current_screen));
912 Editor::stop_scrolling ()
914 scroll_connection.disconnect ();
918 Editor::map_position_change (nframes64_t frame)
920 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
922 if (session == 0 || !_follow_playhead) {
926 center_screen (frame);
927 playhead_cursor->set_position (frame);
931 Editor::center_screen (nframes64_t frame)
933 double page = _canvas_width * frames_per_unit;
935 /* if we're off the page, then scroll.
938 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
939 center_screen_internal (frame, page);
944 Editor::center_screen_internal (nframes64_t frame, float page)
949 frame -= (nframes64_t) page;
954 reset_x_origin (frame);
958 Editor::handle_new_duration ()
964 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
965 nframes64_t new_end = session->current_end_frame() + (nframes64_t) floorf (current_page_frames() * 0.10f);
967 horizontal_adjustment.set_upper (new_end / frames_per_unit);
968 horizontal_adjustment.set_page_size (current_page_frames()/frames_per_unit);
970 if (horizontal_adjustment.get_value() + _canvas_width > horizontal_adjustment.get_upper()) {
971 horizontal_adjustment.set_value (horizontal_adjustment.get_upper() - _canvas_width);
973 //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
977 Editor::update_title_s (const string & snap_name)
979 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
985 Editor::update_title ()
987 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
990 bool dirty = session->dirty();
994 if (session->snap_name() != session->name()) {
995 session_name = session->snap_name();
997 session_name = session->name();
1001 session_name = "*" + session_name;
1004 WindowTitle title(session_name);
1005 title += Glib::get_application_name();
1006 set_title (title.get_string());
1011 Editor::connect_to_session (Session *t)
1015 compute_fixed_ruler_scale ();
1017 /* there are never any selected regions at startup */
1019 sensitize_the_right_region_actions (false);
1021 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1022 set_state (*node, Stateful::loading_state_version);
1024 /* catch up with the playhead */
1026 session->request_locate (playhead_cursor->current_frame);
1030 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1031 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1033 /* These signals can all be emitted by a non-GUI thread. Therefore the
1034 handlers for them must not attempt to directly interact with the GUI,
1035 but use Gtkmm2ext::UI::instance()->call_slot();
1038 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1039 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1040 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1041 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1042 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1043 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1044 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1046 session_connections.push_back (session->TimecodeOffsetChanged.connect (mem_fun(*this, &Editor::update_just_timecode)));
1048 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1050 session_connections.push_back (session->Located.connect (mem_fun (*this, &Editor::located)));
1051 session_connections.push_back (session->config.ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed)));
1053 zoom_range_clock.set_session (session);
1054 _playlist_selector->set_session (session);
1055 nudge_clock.set_session (session);
1056 if (Profile->get_sae()) {
1061 nframes_t pos = session->tempo_map().bbt_duration_at (0, bbt, 1);
1062 nudge_clock.set_mode(AudioClock::BBT);
1063 nudge_clock.set (pos, true, 0, AudioClock::BBT);
1066 nudge_clock.set (session->frame_rate() * 5, true, 0, AudioClock::Timecode); // default of 5 seconds
1069 playhead_cursor->canvas_item.show ();
1071 if (rhythm_ferret) {
1072 rhythm_ferret->set_session (session);
1075 if (analysis_window != 0)
1076 analysis_window->set_session (session);
1078 Location* loc = session->locations()->auto_loop_location();
1080 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1081 if (loc->start() == loc->end()) {
1082 loc->set_end (loc->start() + 1);
1084 session->locations()->add (loc, false);
1085 session->set_auto_loop_location (loc);
1088 loc->set_name (_("Loop"));
1091 loc = session->locations()->auto_punch_location();
1093 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1094 if (loc->start() == loc->end()) {
1095 loc->set_end (loc->start() + 1);
1097 session->locations()->add (loc, false);
1098 session->set_auto_punch_location (loc);
1101 loc->set_name (_("Punch"));
1104 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1105 session->config.map_parameters (mem_fun (*this, &Editor::parameter_changed));
1107 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1109 refresh_location_display ();
1110 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1111 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1112 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1113 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1114 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1117 sfbrowser->set_session (session);
1120 handle_new_duration ();
1122 restore_ruler_visibility ();
1123 //tempo_map_changed (Change (0));
1124 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1126 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1127 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1132 switch (_snap_type) {
1133 case SnapToRegionStart:
1134 case SnapToRegionEnd:
1135 case SnapToRegionSync:
1136 case SnapToRegionBoundary:
1137 build_region_boundary_cache ();
1144 /* register for undo history */
1145 session->register_with_memento_command_factory(_id, this);
1147 _summary->connect_to_session (session);
1148 _group_tabs->connect_to_session (session);
1149 _route_groups->connect_to_session (session);
1150 _regions->connect_to_session (session);
1151 _snapshots->connect_to_session (session);
1152 _routes->connect_to_session (session);
1153 _locations->connect_to_session (session);
1159 Editor::build_cursors ()
1161 using namespace Gdk;
1163 Gdk::Color mbg ("#000000" ); /* Black */
1164 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1167 RefPtr<Bitmap> source, mask;
1168 source = Bitmap::create (mag_bits, mag_width, mag_height);
1169 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1170 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1173 Gdk::Color fbg ("#ffffff" );
1174 Gdk::Color ffg ("#000000" );
1177 RefPtr<Bitmap> source, mask;
1179 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1180 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1181 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1185 RefPtr<Bitmap> source, mask;
1186 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1187 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1188 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1192 RefPtr<Bitmap> bits;
1193 char pix[4] = { 0, 0, 0, 0 };
1194 bits = Bitmap::create (pix, 2, 2);
1196 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1200 RefPtr<Bitmap> bits;
1201 char pix[4] = { 0, 0, 0, 0 };
1202 bits = Bitmap::create (pix, 2, 2);
1204 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1208 grabber_cursor = new Gdk::Cursor (HAND2);
1211 Glib::RefPtr<Gdk::Pixbuf> grabber_edit_point_pixbuf (::get_icon ("grabber_edit_point"));
1212 grabber_edit_point_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_edit_point_pixbuf, 5, 17);
1215 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1216 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1217 selector_cursor = new Gdk::Cursor (XTERM);
1218 time_fx_cursor = new Gdk::Cursor (SIZING);
1219 wait_cursor = new Gdk::Cursor (WATCH);
1220 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1221 midi_pencil_cursor = new Gdk::Cursor (PENCIL);
1222 midi_select_cursor = new Gdk::Cursor (CENTER_PTR);
1223 midi_resize_cursor = new Gdk::Cursor (SIZING);
1224 midi_erase_cursor = new Gdk::Cursor (DRAPED_BOX);
1227 /** Pop up a context menu for when the user clicks on a fade in or fade out */
1229 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1231 using namespace Menu_Helpers;
1232 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1235 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1239 MenuList& items (fade_context_menu.items());
1243 switch (item_type) {
1245 case FadeInHandleItem:
1246 if (arv->audio_region()->fade_in_active()) {
1247 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_in_active), false)));
1249 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_in_active), true)));
1252 items.push_back (SeparatorElem());
1254 if (Profile->get_sae()) {
1255 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1256 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1258 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1259 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1260 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
1261 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
1262 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
1268 case FadeOutHandleItem:
1269 if (arv->audio_region()->fade_out_active()) {
1270 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_out_active), false)));
1272 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_out_active), true)));
1275 items.push_back (SeparatorElem());
1277 if (Profile->get_sae()) {
1278 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1279 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1281 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1282 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1283 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
1284 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
1285 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
1291 fatal << _("programming error: ")
1292 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1297 fade_context_menu.popup (button, time);
1301 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes64_t frame)
1303 using namespace Menu_Helpers;
1304 Menu* (Editor::*build_menu_function)(nframes64_t);
1307 switch (item_type) {
1309 case RegionViewName:
1310 case RegionViewNameHighlight:
1311 if (with_selection) {
1312 build_menu_function = &Editor::build_track_selection_context_menu;
1314 build_menu_function = &Editor::build_track_region_context_menu;
1319 if (with_selection) {
1320 build_menu_function = &Editor::build_track_selection_context_menu;
1322 build_menu_function = &Editor::build_track_context_menu;
1326 case CrossfadeViewItem:
1327 build_menu_function = &Editor::build_track_crossfade_context_menu;
1331 if (clicked_routeview->get_diskstream()) {
1332 build_menu_function = &Editor::build_track_context_menu;
1334 build_menu_function = &Editor::build_track_bus_context_menu;
1339 /* probably shouldn't happen but if it does, we don't care */
1343 menu = (this->*build_menu_function)(frame);
1344 menu->set_name ("ArdourContextMenu");
1346 /* now handle specific situations */
1348 switch (item_type) {
1350 case RegionViewName:
1351 case RegionViewNameHighlight:
1352 if (!with_selection) {
1353 if (region_edit_menu_split_item) {
1354 if (clicked_regionview && clicked_regionview->region()->covers (get_preferred_edit_position())) {
1355 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, true);
1357 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, false);
1361 if (region_edit_menu_split_multichannel_item) {
1362 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1363 // GTK2FIX find the action, change its sensitivity
1364 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1366 // GTK2FIX see above
1367 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1376 case CrossfadeViewItem:
1383 /* probably shouldn't happen but if it does, we don't care */
1387 if (item_type != SelectionItem && clicked_routeview && clicked_routeview->audio_track()) {
1389 /* Bounce to disk */
1391 using namespace Menu_Helpers;
1392 MenuList& edit_items = menu->items();
1394 edit_items.push_back (SeparatorElem());
1396 switch (clicked_routeview->audio_track()->freeze_state()) {
1397 case AudioTrack::NoFreeze:
1398 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1401 case AudioTrack::Frozen:
1402 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1405 case AudioTrack::UnFrozen:
1406 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1412 if (item_type == StreamItem && clicked_routeview) {
1413 clicked_routeview->build_underlay_menu(menu);
1416 menu->popup (button, time);
1420 Editor::build_track_context_menu (nframes64_t)
1422 using namespace Menu_Helpers;
1424 MenuList& edit_items = track_context_menu.items();
1427 add_dstream_context_items (edit_items);
1428 return &track_context_menu;
1432 Editor::build_track_bus_context_menu (nframes64_t)
1434 using namespace Menu_Helpers;
1436 MenuList& edit_items = track_context_menu.items();
1439 add_bus_context_items (edit_items);
1440 return &track_context_menu;
1444 Editor::build_track_region_context_menu (nframes64_t frame)
1446 using namespace Menu_Helpers;
1447 MenuList& edit_items = track_region_context_menu.items();
1450 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (clicked_axisview);
1453 boost::shared_ptr<Diskstream> ds;
1454 boost::shared_ptr<Playlist> pl;
1456 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
1457 Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)frame * ds->speed()));
1459 if (selection->regions.size() > 1) {
1460 // there's already a multiple selection: just add a
1461 // single region context menu that will act on all
1463 boost::shared_ptr<Region> dummy_region; // = NULL
1464 add_region_context_items (rtv->view(), dummy_region, edit_items);
1466 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1467 add_region_context_items (rtv->view(), (*i), edit_items);
1475 add_dstream_context_items (edit_items);
1477 return &track_region_context_menu;
1481 Editor::build_track_crossfade_context_menu (nframes64_t frame)
1483 using namespace Menu_Helpers;
1484 MenuList& edit_items = track_crossfade_context_menu.items();
1485 edit_items.clear ();
1487 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_axisview);
1490 boost::shared_ptr<Diskstream> ds;
1491 boost::shared_ptr<Playlist> pl;
1492 boost::shared_ptr<AudioPlaylist> apl;
1494 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1496 Playlist::RegionList* regions = pl->regions_at (frame);
1497 AudioPlaylist::Crossfades xfades;
1499 apl->crossfades_at (frame, xfades);
1501 bool many = xfades.size() > 1;
1503 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1504 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1507 if (selection->regions.size() > 1) {
1508 // there's already a multiple selection: just add a
1509 // single region context menu that will act on all
1511 boost::shared_ptr<Region> dummy_region; // = NULL
1512 add_region_context_items (atv->audio_view(), dummy_region, edit_items);
1514 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1515 add_region_context_items (atv->audio_view(), (*i), edit_items);
1522 add_dstream_context_items (edit_items);
1524 return &track_crossfade_context_menu;
1528 Editor::analyze_region_selection()
1530 if (analysis_window == 0) {
1531 analysis_window = new AnalysisWindow();
1534 analysis_window->set_session(session);
1536 analysis_window->show_all();
1539 analysis_window->set_regionmode();
1540 analysis_window->analyze();
1542 analysis_window->present();
1546 Editor::analyze_range_selection()
1548 if (analysis_window == 0) {
1549 analysis_window = new AnalysisWindow();
1552 analysis_window->set_session(session);
1554 analysis_window->show_all();
1557 analysis_window->set_rangemode();
1558 analysis_window->analyze();
1560 analysis_window->present();
1564 Editor::build_track_selection_context_menu (nframes64_t)
1566 using namespace Menu_Helpers;
1567 MenuList& edit_items = track_selection_context_menu.items();
1568 edit_items.clear ();
1570 add_selection_context_items (edit_items);
1571 // edit_items.push_back (SeparatorElem());
1572 // add_dstream_context_items (edit_items);
1574 return &track_selection_context_menu;
1577 /** Add context menu items relevant to crossfades.
1578 * @param edit_items List to add the items to.
1581 Editor::add_crossfade_context_items (AudioStreamView* /*view*/, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1583 using namespace Menu_Helpers;
1584 Menu *xfade_menu = manage (new Menu);
1585 MenuList& items = xfade_menu->items();
1586 xfade_menu->set_name ("ArdourContextMenu");
1589 if (xfade->active()) {
1595 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1596 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1598 if (xfade->can_follow_overlap()) {
1600 if (xfade->following_overlap()) {
1601 str = _("Convert to short");
1603 str = _("Convert to full");
1606 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1610 str = xfade->out()->name();
1612 str += xfade->in()->name();
1614 str = _("Crossfade");
1617 edit_items.push_back (MenuElem (str, *xfade_menu));
1618 edit_items.push_back (SeparatorElem());
1622 Editor::xfade_edit_left_region ()
1624 if (clicked_crossfadeview) {
1625 clicked_crossfadeview->left_view.show_region_editor ();
1630 Editor::xfade_edit_right_region ()
1632 if (clicked_crossfadeview) {
1633 clicked_crossfadeview->right_view.show_region_editor ();
1638 Editor::add_region_context_items (StreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1640 using namespace Menu_Helpers;
1641 Gtk::MenuItem* foo_item;
1642 Menu *region_menu = manage (new Menu);
1643 MenuList& items = region_menu->items();
1644 region_menu->set_name ("ArdourContextMenu");
1646 boost::shared_ptr<AudioRegion> ar;
1647 boost::shared_ptr<MidiRegion> mr;
1650 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1651 mr = boost::dynamic_pointer_cast<MidiRegion> (region);
1653 /* when this particular menu pops up, make the relevant region
1657 region_menu->signal_map_event().connect (
1658 bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1660 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &Editor::rename_region)));
1661 if (mr && internal_editing()) {
1662 items.push_back (MenuElem (_("List editor..."), mem_fun(*this, &Editor::show_midi_list_editor)));
1664 items.push_back (MenuElem (_("Region editor"), mem_fun(*this, &Editor::edit_region)));
1668 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1669 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1670 items.push_back (SeparatorElem());
1671 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_point)));
1672 if (_edit_point == EditAtMouse) {
1673 items.back ().set_sensitive (false);
1675 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1676 items.push_back (SeparatorElem());
1678 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::play_selected_region)));
1679 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1680 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1683 items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_region_selection)));
1686 items.push_back (SeparatorElem());
1688 sigc::connection fooc;
1689 boost::shared_ptr<Region> region_to_check;
1692 region_to_check = region;
1694 region_to_check = selection->regions.front()->region();
1697 items.push_back (CheckMenuElem (_("Lock")));
1698 CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1699 if (region_to_check->locked()) {
1700 region_lock_item->set_active();
1702 region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
1704 items.push_back (CheckMenuElem (_("Glue to Bars&Beats")));
1705 CheckMenuItem* bbt_glue_item = static_cast<CheckMenuItem*>(&items.back());
1707 switch (region_to_check->positional_lock_style()) {
1708 case Region::MusicTime:
1709 bbt_glue_item->set_active (true);
1712 bbt_glue_item->set_active (false);
1716 bbt_glue_item->signal_activate().connect (bind (mem_fun (*this, &Editor::set_region_lock_style), Region::MusicTime));
1718 items.push_back (CheckMenuElem (_("Mute")));
1719 CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1720 fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
1721 if (region_to_check->muted()) {
1723 region_mute_item->set_active();
1727 if (!Profile->get_sae()) {
1728 items.push_back (CheckMenuElem (_("Opaque")));
1729 CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1730 fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
1731 if (region_to_check->opaque()) {
1733 region_opaque_item->set_active();
1738 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1739 if (region_to_check->at_natural_position()) {
1740 items.back().set_sensitive (false);
1743 items.push_back (SeparatorElem());
1747 RegionView* rv = sv->find_view (ar);
1748 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1750 if (!Profile->get_sae()) {
1751 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
1753 items.push_back (CheckMenuElem (_("Envelope Visible")));
1754 CheckMenuItem* region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1755 fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
1756 if (arv->envelope_visible()) {
1758 region_envelope_visible_item->set_active (true);
1762 items.push_back (CheckMenuElem (_("Envelope Active")));
1763 CheckMenuItem* region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1764 fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
1766 if (ar->envelope_active()) {
1768 region_envelope_active_item->set_active (true);
1772 items.push_back (SeparatorElem());
1775 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1776 if (ar->scale_amplitude() != 1) {
1777 items.push_back (MenuElem (_("Reset Gain"), mem_fun(*this, &Editor::reset_region_scale_amplitude)));
1781 items.push_back (MenuElem (_("Quantize"), mem_fun(*this, &Editor::quantize_region)));
1782 items.push_back (SeparatorElem());
1785 items.push_back (MenuElem (_("Strip Silence..."), mem_fun (*this, &Editor::strip_region_silence)));
1786 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1787 items.push_back (SeparatorElem());
1789 /* range related stuff */
1791 items.push_back (MenuElem (_("Add Single Range"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1792 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_locations_from_audio_region)));
1793 if (selection->regions.size() < 2) {
1794 items.back().set_sensitive (false);
1797 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_region)));
1798 items.push_back (SeparatorElem());
1802 Menu *nudge_menu = manage (new Menu());
1803 MenuList& nudge_items = nudge_menu->items();
1804 nudge_menu->set_name ("ArdourContextMenu");
1806 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false, false))));
1807 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false, false))));
1808 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1809 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1811 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1812 items.push_back (SeparatorElem());
1814 Menu *trim_menu = manage (new Menu);
1815 MenuList& trim_items = trim_menu->items();
1816 trim_menu->set_name ("ArdourContextMenu");
1818 trim_items.push_back (MenuElem (_("Start to edit point"), mem_fun(*this, &Editor::trim_region_from_edit_point)));
1819 foo_item = &trim_items.back();
1820 if (_edit_point == EditAtMouse) {
1821 foo_item->set_sensitive (false);
1823 trim_items.push_back (MenuElem (_("Edit point to end"), mem_fun(*this, &Editor::trim_region_to_edit_point)));
1824 foo_item = &trim_items.back();
1825 if (_edit_point == EditAtMouse) {
1826 foo_item->set_sensitive (false);
1828 trim_items.push_back (MenuElem (_("Trim To Loop"), mem_fun(*this, &Editor::trim_region_to_loop)));
1829 trim_items.push_back (MenuElem (_("Trim To Punch"), mem_fun(*this, &Editor::trim_region_to_punch)));
1831 items.push_back (MenuElem (_("Trim"), *trim_menu));
1832 items.push_back (SeparatorElem());
1834 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split))));
1835 region_edit_menu_split_item = &items.back();
1837 if (_edit_point == EditAtMouse) {
1838 region_edit_menu_split_item->set_sensitive (false);
1841 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1842 region_edit_menu_split_multichannel_item = &items.back();
1844 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), false))));
1845 items.push_back (MenuElem (_("Multi-Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1846 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1847 items.push_back (SeparatorElem());
1848 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_selected_regions)));
1850 /* OK, stick the region submenu at the top of the list, and then add
1854 /* we have to hack up the region name because "_" has a special
1855 meaning for menu titles.
1858 string::size_type pos = 0;
1859 string menu_item_name = (region) ? region->name() : _("Selected regions");
1861 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1862 menu_item_name.replace (pos, 1, "__");
1866 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1867 edit_items.push_back (SeparatorElem());
1870 /** Add context menu items relevant to selection ranges.
1871 * @param edit_items List to add the items to.
1874 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1876 using namespace Menu_Helpers;
1878 edit_items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::play_selection)));
1879 edit_items.push_back (MenuElem (_("Loop Range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
1881 edit_items.push_back (SeparatorElem());
1882 edit_items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_range_selection)));
1884 if (!selection->regions.empty()) {
1885 edit_items.push_back (SeparatorElem());
1886 edit_items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
1887 edit_items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
1890 edit_items.push_back (SeparatorElem());
1891 edit_items.push_back (MenuElem (_("Silence Range"), mem_fun(*this, &Editor::separate_region_from_selection)));
1892 edit_items.push_back (MenuElem (_("Convert to Region in Region List"), mem_fun(*this, &Editor::new_region_from_selection)));
1894 edit_items.push_back (SeparatorElem());
1895 edit_items.push_back (MenuElem (_("Select All in Range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1897 edit_items.push_back (SeparatorElem());
1898 edit_items.push_back (MenuElem (_("Set Loop from Range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
1899 edit_items.push_back (MenuElem (_("Set Punch from Range"), mem_fun(*this, &Editor::set_punch_from_selection)));
1901 edit_items.push_back (SeparatorElem());
1902 edit_items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
1904 edit_items.push_back (SeparatorElem());
1905 edit_items.push_back (MenuElem (_("Crop Region to Range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1906 edit_items.push_back (MenuElem (_("Fill Range with Region"), mem_fun(*this, &Editor::region_fill_selection)));
1907 edit_items.push_back (MenuElem (_("Duplicate Range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1909 edit_items.push_back (SeparatorElem());
1910 edit_items.push_back (MenuElem (_("Consolidate Range"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, false)));
1911 edit_items.push_back (MenuElem (_("Consolidate Range With Processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, true)));
1912 edit_items.push_back (MenuElem (_("Bounce Range to Region List"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, false)));
1913 edit_items.push_back (MenuElem (_("Bounce Range to Region List With Processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, true)));
1914 edit_items.push_back (MenuElem (_("Export Range"), mem_fun(*this, &Editor::export_range)));
1919 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1921 using namespace Menu_Helpers;
1925 Menu *play_menu = manage (new Menu);
1926 MenuList& play_items = play_menu->items();
1927 play_menu->set_name ("ArdourContextMenu");
1929 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
1930 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1931 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1932 play_items.push_back (SeparatorElem());
1933 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1935 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1939 Menu *select_menu = manage (new Menu);
1940 MenuList& select_items = select_menu->items();
1941 select_menu->set_name ("ArdourContextMenu");
1943 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1944 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1945 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1946 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1947 select_items.push_back (SeparatorElem());
1948 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1949 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1950 select_items.push_back (SeparatorElem());
1951 select_items.push_back (MenuElem (_("Select All After Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
1952 select_items.push_back (MenuElem (_("Select All Before Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
1953 select_items.push_back (MenuElem (_("Select All After Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1954 select_items.push_back (MenuElem (_("Select All Before Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1955 select_items.push_back (MenuElem (_("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), false)));
1956 select_items.push_back (MenuElem (_("Select All Within Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), true)));
1957 select_items.push_back (MenuElem (_("Select Range Between Playhead & Edit Point"), mem_fun(*this, &Editor::select_range_between)));
1959 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1963 Menu *cutnpaste_menu = manage (new Menu);
1964 MenuList& cutnpaste_items = cutnpaste_menu->items();
1965 cutnpaste_menu->set_name ("ArdourContextMenu");
1967 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1968 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1969 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1971 cutnpaste_items.push_back (SeparatorElem());
1973 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1974 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
1976 cutnpaste_items.push_back (SeparatorElem());
1978 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
1980 /* Adding new material */
1982 edit_items.push_back (SeparatorElem());
1983 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
1984 edit_items.push_back (MenuElem (_("Insert Existing Media"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
1988 Menu *nudge_menu = manage (new Menu());
1989 MenuList& nudge_items = nudge_menu->items();
1990 nudge_menu->set_name ("ArdourContextMenu");
1992 edit_items.push_back (SeparatorElem());
1993 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1994 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1995 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1996 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1998 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2002 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
2004 using namespace Menu_Helpers;
2008 Menu *play_menu = manage (new Menu);
2009 MenuList& play_items = play_menu->items();
2010 play_menu->set_name ("ArdourContextMenu");
2012 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
2013 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2014 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2018 Menu *select_menu = manage (new Menu);
2019 MenuList& select_items = select_menu->items();
2020 select_menu->set_name ("ArdourContextMenu");
2022 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2023 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2024 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2025 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2026 select_items.push_back (SeparatorElem());
2027 select_items.push_back (MenuElem (_("Select all after edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2028 select_items.push_back (MenuElem (_("Select all before edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2029 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2030 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2032 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2036 Menu *cutnpaste_menu = manage (new Menu);
2037 MenuList& cutnpaste_items = cutnpaste_menu->items();
2038 cutnpaste_menu->set_name ("ArdourContextMenu");
2040 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2041 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2042 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2044 Menu *nudge_menu = manage (new Menu());
2045 MenuList& nudge_items = nudge_menu->items();
2046 nudge_menu->set_name ("ArdourContextMenu");
2048 edit_items.push_back (SeparatorElem());
2049 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2050 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2051 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2052 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2054 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2058 Editor::snap_type() const
2064 Editor::snap_mode() const
2070 Editor::set_snap_to (SnapType st)
2072 unsigned int snap_ind = (unsigned int)st;
2076 if (snap_ind > snap_type_strings.size() - 1) {
2078 _snap_type = (SnapType)snap_ind;
2081 string str = snap_type_strings[snap_ind];
2083 if (str != snap_type_selector.get_active_text()) {
2084 snap_type_selector.set_active_text (str);
2089 switch (_snap_type) {
2090 case SnapToAThirtysecondBeat:
2091 case SnapToASixteenthBeat:
2092 case SnapToAEighthBeat:
2093 case SnapToAQuarterBeat:
2094 case SnapToAThirdBeat:
2095 compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames());
2096 update_tempo_based_rulers ();
2099 case SnapToRegionStart:
2100 case SnapToRegionEnd:
2101 case SnapToRegionSync:
2102 case SnapToRegionBoundary:
2103 build_region_boundary_cache ();
2113 Editor::set_snap_mode (SnapMode mode)
2116 string str = snap_mode_strings[(int)mode];
2118 if (str != snap_mode_selector.get_active_text ()) {
2119 snap_mode_selector.set_active_text (str);
2125 Editor::set_edit_point_preference (EditPoint ep, bool force)
2127 bool changed = (_edit_point != ep);
2130 string str = edit_point_strings[(int)ep];
2132 if (str != edit_point_selector.get_active_text ()) {
2133 edit_point_selector.set_active_text (str);
2136 set_canvas_cursor ();
2138 if (!force && !changed) {
2142 switch (zoom_focus) {
2143 case ZoomFocusMouse:
2144 case ZoomFocusPlayhead:
2146 switch (_edit_point) {
2148 set_zoom_focus (ZoomFocusMouse);
2150 case EditAtPlayhead:
2151 set_zoom_focus (ZoomFocusPlayhead);
2153 case EditAtSelectedMarker:
2154 set_zoom_focus (ZoomFocusEdit);
2162 const char* action=NULL;
2164 switch (_edit_point) {
2165 case EditAtPlayhead:
2166 action = "edit-at-playhead";
2168 case EditAtSelectedMarker:
2169 action = "edit-at-marker";
2172 action = "edit-at-mouse";
2176 Glib::RefPtr<Action> act = ActionManager::get_action ("Editor", action);
2178 Glib::RefPtr<RadioAction>::cast_dynamic(act)->set_active (true);
2182 bool in_track_canvas;
2184 if (!mouse_frame (foo, in_track_canvas)) {
2185 in_track_canvas = false;
2188 reset_canvas_action_sensitivity (in_track_canvas);
2194 Editor::set_state (const XMLNode& node, int /*version*/)
2196 const XMLProperty* prop;
2198 int x, y, xoff, yoff;
2201 if ((prop = node.property ("id")) != 0) {
2202 _id = prop->value ();
2205 g.base_width = default_width;
2206 g.base_height = default_height;
2212 if ((geometry = find_named_node (node, "geometry")) != 0) {
2216 if ((prop = geometry->property("x_size")) == 0) {
2217 prop = geometry->property ("x-size");
2220 g.base_width = atoi(prop->value());
2222 if ((prop = geometry->property("y_size")) == 0) {
2223 prop = geometry->property ("y-size");
2226 g.base_height = atoi(prop->value());
2229 if ((prop = geometry->property ("x_pos")) == 0) {
2230 prop = geometry->property ("x-pos");
2233 x = atoi (prop->value());
2236 if ((prop = geometry->property ("y_pos")) == 0) {
2237 prop = geometry->property ("y-pos");
2240 y = atoi (prop->value());
2243 if ((prop = geometry->property ("x_off")) == 0) {
2244 prop = geometry->property ("x-off");
2247 xoff = atoi (prop->value());
2249 if ((prop = geometry->property ("y_off")) == 0) {
2250 prop = geometry->property ("y-off");
2253 yoff = atoi (prop->value());
2257 set_default_size (g.base_width, g.base_height);
2260 if (session && (prop = node.property ("playhead"))) {
2261 nframes64_t pos = atol (prop->value().c_str());
2262 playhead_cursor->set_position (pos);
2264 playhead_cursor->set_position (0);
2266 /* reset_x_origin() doesn't work right here, since the old
2267 position may be zero already, and it does nothing in such
2272 horizontal_adjustment.set_value (0);
2275 if ((prop = node.property ("mixer-width"))) {
2276 editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
2279 if ((prop = node.property ("zoom-focus"))) {
2280 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2283 if ((prop = node.property ("zoom"))) {
2284 reset_zoom (PBD::atof (prop->value()));
2287 if ((prop = node.property ("snap-to"))) {
2288 set_snap_to ((SnapType) atoi (prop->value()));
2291 if ((prop = node.property ("snap-mode"))) {
2292 set_snap_mode ((SnapMode) atoi (prop->value()));
2295 if ((prop = node.property ("mouse-mode"))) {
2296 MouseMode m = str2mousemode(prop->value());
2297 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2298 set_mouse_mode (m, true);
2300 mouse_mode = MouseGain; /* lie, to force the mode switch */
2301 set_mouse_mode (MouseObject, true);
2304 if ((prop = node.property ("internal-edit"))) {
2305 bool yn = string_is_affirmative (prop->value());
2306 RefPtr<Action> act = ActionManager::get_action (X_("MouseMode"), X_("toggle-internal-edit"));
2308 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2309 tact->set_active (!yn);
2310 tact->set_active (yn);
2314 if ((prop = node.property ("edit-point"))) {
2315 set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point), true);
2318 if ((prop = node.property ("show-waveforms-recording"))) {
2319 bool yn = string_is_affirmative (prop->value());
2320 _show_waveforms_recording = !yn;
2321 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2323 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2324 /* do it twice to force the change */
2325 tact->set_active (!yn);
2326 tact->set_active (yn);
2330 if ((prop = node.property ("show-measures"))) {
2331 bool yn = string_is_affirmative (prop->value());
2332 _show_measures = !yn;
2333 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2335 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2336 /* do it twice to force the change */
2337 tact->set_active (!yn);
2338 tact->set_active (yn);
2342 if ((prop = node.property ("follow-playhead"))) {
2343 bool yn = string_is_affirmative (prop->value());
2344 set_follow_playhead (yn);
2345 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2347 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2348 if (tact->get_active() != yn) {
2349 tact->set_active (yn);
2354 if ((prop = node.property ("region-list-sort-type"))) {
2355 _regions->reset_sort_type (str2regionlistsorttype(prop->value()), true);
2358 if ((prop = node.property ("xfades-visible"))) {
2359 bool yn = string_is_affirmative (prop->value());
2360 _xfade_visibility = !yn;
2361 // set_xfade_visibility (yn);
2364 if ((prop = node.property ("show-editor-mixer"))) {
2366 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2369 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2370 bool yn = string_is_affirmative (prop->value());
2372 /* do it twice to force the change */
2374 tact->set_active (!yn);
2375 tact->set_active (yn);
2379 if ((prop = node.property ("show-editor-list"))) {
2381 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2385 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2386 bool yn = string_is_affirmative (prop->value());
2388 /* do it twice to force the change */
2390 tact->set_active (!yn);
2391 tact->set_active (yn);
2400 Editor::get_state ()
2402 XMLNode* node = new XMLNode ("Editor");
2405 _id.print (buf, sizeof (buf));
2406 node->add_property ("id", buf);
2408 if (is_realized()) {
2409 Glib::RefPtr<Gdk::Window> win = get_window();
2411 int x, y, xoff, yoff, width, height;
2412 win->get_root_origin(x, y);
2413 win->get_position(xoff, yoff);
2414 win->get_size(width, height);
2416 XMLNode* geometry = new XMLNode ("geometry");
2418 snprintf(buf, sizeof(buf), "%d", width);
2419 geometry->add_property("x-size", string(buf));
2420 snprintf(buf, sizeof(buf), "%d", height);
2421 geometry->add_property("y-size", string(buf));
2422 snprintf(buf, sizeof(buf), "%d", x);
2423 geometry->add_property("x-pos", string(buf));
2424 snprintf(buf, sizeof(buf), "%d", y);
2425 geometry->add_property("y-pos", string(buf));
2426 snprintf(buf, sizeof(buf), "%d", xoff);
2427 geometry->add_property("x-off", string(buf));
2428 snprintf(buf, sizeof(buf), "%d", yoff);
2429 geometry->add_property("y-off", string(buf));
2430 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2431 geometry->add_property("edit_pane_pos", string(buf));
2433 node->add_child_nocopy (*geometry);
2436 maybe_add_mixer_strip_width (*node);
2438 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2439 node->add_property ("zoom-focus", buf);
2440 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2441 node->add_property ("zoom", buf);
2442 snprintf (buf, sizeof(buf), "%d", (int) _snap_type);
2443 node->add_property ("snap-to", buf);
2444 snprintf (buf, sizeof(buf), "%d", (int) _snap_mode);
2445 node->add_property ("snap-mode", buf);
2447 node->add_property ("edit-point", enum_2_string (_edit_point));
2449 snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame);
2450 node->add_property ("playhead", buf);
2452 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2453 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2454 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2455 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2456 node->add_property ("region-list-sort-type", enum2str (_regions->sort_type ()));
2457 node->add_property ("mouse-mode", enum2str(mouse_mode));
2458 node->add_property ("internal-edit", _internal_editing ? "yes" : "no");
2460 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2462 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2463 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2466 act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2468 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2469 node->add_property (X_("show-editor-list"), tact->get_active() ? "yes" : "no");
2477 /** @param y y offset from the top of all trackviews.
2478 * @return pair: TimeAxisView that y is over, layer index.
2479 * TimeAxisView may be 0. Layer index is the layer number if the TimeAxisView is valid and is
2480 * in stacked region display mode, otherwise 0.
2482 std::pair<TimeAxisView *, layer_t>
2483 Editor::trackview_by_y_position (double y)
2485 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2487 std::pair<TimeAxisView*, int> const r = (*iter)->covers_y_position (y);
2493 return std::make_pair ( (TimeAxisView *) 0, 0);
2496 /** Snap a position to the grid, if appropriate, taking into account current
2497 * grid settings and also the state of any snap modifier keys that may be pressed.
2498 * @param start Position to snap.
2499 * @param event Event to get current key modifier information from.
2502 Editor::snap_to_with_modifier (nframes64_t& start, GdkEvent const * event, int32_t direction, bool for_mark)
2508 if (Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
2509 if (_snap_mode == SnapOff) {
2510 snap_to_internal (start, direction, for_mark);
2513 if (_snap_mode != SnapOff) {
2514 snap_to_internal (start, direction, for_mark);
2520 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
2522 if (!session || _snap_mode == SnapOff) {
2526 snap_to_internal (start, direction, for_mark);
2530 Editor::timecode_snap_to_internal (nframes64_t& start, int32_t direction, bool /*for_mark*/)
2532 const nframes64_t one_timecode_second = (nframes64_t)(rint(session->timecode_frames_per_second()) * session->frames_per_timecode_frame());
2533 nframes64_t one_timecode_minute = (nframes64_t)(rint(session->timecode_frames_per_second()) * session->frames_per_timecode_frame() * 60);
2535 switch (_snap_type) {
2536 case SnapToTimecodeFrame:
2537 if (((direction == 0) && (fmod((double)start, (double)session->frames_per_timecode_frame()) > (session->frames_per_timecode_frame() / 2))) || (direction > 0)) {
2538 start = (nframes64_t) (ceil ((double) start / session->frames_per_timecode_frame()) * session->frames_per_timecode_frame());
2540 start = (nframes64_t) (floor ((double) start / session->frames_per_timecode_frame()) * session->frames_per_timecode_frame());
2544 case SnapToTimecodeSeconds:
2545 if (session->timecode_offset_negative())
2547 start += session->timecode_offset ();
2549 start -= session->timecode_offset ();
2551 if (((direction == 0) && (start % one_timecode_second > one_timecode_second / 2)) || direction > 0) {
2552 start = (nframes64_t) ceil ((double) start / one_timecode_second) * one_timecode_second;
2554 start = (nframes64_t) floor ((double) start / one_timecode_second) * one_timecode_second;
2557 if (session->timecode_offset_negative())
2559 start -= session->timecode_offset ();
2561 start += session->timecode_offset ();
2565 case SnapToTimecodeMinutes:
2566 if (session->timecode_offset_negative())
2568 start += session->timecode_offset ();
2570 start -= session->timecode_offset ();
2572 if (((direction == 0) && (start % one_timecode_minute > one_timecode_minute / 2)) || direction > 0) {
2573 start = (nframes64_t) ceil ((double) start / one_timecode_minute) * one_timecode_minute;
2575 start = (nframes64_t) floor ((double) start / one_timecode_minute) * one_timecode_minute;
2577 if (session->timecode_offset_negative())
2579 start -= session->timecode_offset ();
2581 start += session->timecode_offset ();
2585 fatal << "Editor::smpte_snap_to_internal() called with non-timecode snap type!" << endmsg;
2591 Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
2593 const nframes64_t one_second = session->frame_rate();
2594 const nframes64_t one_minute = session->frame_rate() * 60;
2595 nframes64_t presnap = start;
2599 switch (_snap_type) {
2600 case SnapToTimecodeFrame:
2601 case SnapToTimecodeSeconds:
2602 case SnapToTimecodeMinutes:
2603 return timecode_snap_to_internal (start, direction, for_mark);
2606 if (((direction == 0) && (start % (one_second/75) > (one_second/75) / 2)) || (direction > 0)) {
2607 start = (nframes64_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2609 start = (nframes64_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2614 if (((direction == 0) && (start % one_second > one_second / 2)) || (direction > 0)) {
2615 start = (nframes64_t) ceil ((double) start / one_second) * one_second;
2617 start = (nframes64_t) floor ((double) start / one_second) * one_second;
2622 if (((direction == 0) && (start % one_minute > one_minute / 2)) || (direction > 0)) {
2623 start = (nframes64_t) ceil ((double) start / one_minute) * one_minute;
2625 start = (nframes64_t) floor ((double) start / one_minute) * one_minute;
2630 start = session->tempo_map().round_to_bar (start, direction);
2634 start = session->tempo_map().round_to_beat (start, direction);
2637 case SnapToAThirtysecondBeat:
2638 start = session->tempo_map().round_to_beat_subdivision (start, 32, direction);
2641 case SnapToASixteenthBeat:
2642 start = session->tempo_map().round_to_beat_subdivision (start, 16, direction);
2645 case SnapToAEighthBeat:
2646 start = session->tempo_map().round_to_beat_subdivision (start, 8, direction);
2649 case SnapToAQuarterBeat:
2650 start = session->tempo_map().round_to_beat_subdivision (start, 4, direction);
2653 case SnapToAThirdBeat:
2654 start = session->tempo_map().round_to_beat_subdivision (start, 3, direction);
2662 session->locations()->marks_either_side (start, before, after);
2664 if (before == max_frames) {
2666 } else if (after == max_frames) {
2668 } else if (before != max_frames && after != max_frames) {
2669 /* have before and after */
2670 if ((start - before) < (after - start)) {
2679 case SnapToRegionStart:
2680 case SnapToRegionEnd:
2681 case SnapToRegionSync:
2682 case SnapToRegionBoundary:
2683 if (!region_boundary_cache.empty()) {
2685 vector<nframes64_t>::iterator prev = region_boundary_cache.end ();
2686 vector<nframes64_t>::iterator next = region_boundary_cache.end ();
2688 if (direction > 0) {
2689 next = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2691 next = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2694 if (next != region_boundary_cache.begin ()) {
2699 nframes64_t const p = (prev == region_boundary_cache.end()) ? region_boundary_cache.front () : *prev;
2700 nframes64_t const n = (next == region_boundary_cache.end()) ? region_boundary_cache.back () : *next;
2702 if (start > (p + n) / 2) {
2711 switch (_snap_mode) {
2717 if (presnap > start) {
2718 if (presnap > (start + unit_to_frame(snap_threshold))) {
2722 } else if (presnap < start) {
2723 if (presnap < (start - unit_to_frame(snap_threshold))) {
2729 /* handled at entry */
2737 Editor::setup_toolbar ()
2741 /* Mode Buttons (tool selection) */
2743 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2744 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2745 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2746 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2747 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2748 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2749 // internal_edit_button.set_relief(Gtk::RELIEF_NONE);
2751 HBox* mode_box = manage(new HBox);
2752 mode_box->set_border_width (2);
2753 mode_box->set_spacing(4);
2754 mouse_mode_button_box.set_spacing(1);
2755 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2756 if (!Profile->get_sae()) {
2757 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2759 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2760 if (!Profile->get_sae()) {
2761 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2763 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2764 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2765 mouse_mode_button_box.pack_start(internal_edit_button, true, true);
2766 mouse_mode_button_box.set_homogeneous(true);
2768 vector<string> edit_mode_strings;
2769 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2770 if (!Profile->get_sae()) {
2771 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2773 edit_mode_strings.push_back (edit_mode_to_string (Lock));
2775 edit_mode_selector.set_name ("EditModeSelector");
2776 set_popdown_strings (edit_mode_selector, edit_mode_strings, true);
2777 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2779 mode_box->pack_start(edit_mode_selector);
2780 mode_box->pack_start(mouse_mode_button_box);
2782 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2783 mouse_mode_tearoff->set_name ("MouseModeBase");
2784 mouse_mode_tearoff->tearoff_window().signal_key_press_event().connect (bind (sigc::ptr_fun (relay_key_press), &mouse_mode_tearoff->tearoff_window()), false);
2786 if (Profile->get_sae()) {
2787 mouse_mode_tearoff->set_can_be_torn_off (false);
2790 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2791 &mouse_mode_tearoff->tearoff_window()));
2792 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2793 &mouse_mode_tearoff->tearoff_window(), 1));
2794 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2795 &mouse_mode_tearoff->tearoff_window()));
2796 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2797 &mouse_mode_tearoff->tearoff_window(), 1));
2799 mouse_move_button.set_mode (false);
2800 mouse_select_button.set_mode (false);
2801 mouse_gain_button.set_mode (false);
2802 mouse_zoom_button.set_mode (false);
2803 mouse_timefx_button.set_mode (false);
2804 mouse_audition_button.set_mode (false);
2806 mouse_move_button.set_name ("MouseModeButton");
2807 mouse_select_button.set_name ("MouseModeButton");
2808 mouse_gain_button.set_name ("MouseModeButton");
2809 mouse_zoom_button.set_name ("MouseModeButton");
2810 mouse_timefx_button.set_name ("MouseModeButton");
2811 mouse_audition_button.set_name ("MouseModeButton");
2813 internal_edit_button.set_name ("MouseModeButton");
2815 mouse_move_button.unset_flags (CAN_FOCUS);
2816 mouse_select_button.unset_flags (CAN_FOCUS);
2817 mouse_gain_button.unset_flags (CAN_FOCUS);
2818 mouse_zoom_button.unset_flags (CAN_FOCUS);
2819 mouse_timefx_button.unset_flags (CAN_FOCUS);
2820 mouse_audition_button.unset_flags (CAN_FOCUS);
2821 internal_edit_button.unset_flags (CAN_FOCUS);
2825 zoom_box.set_spacing (1);
2826 zoom_box.set_border_width (0);
2828 zoom_in_button.set_name ("EditorTimeButton");
2829 zoom_in_button.set_image (*(manage (new Image (Stock::ZOOM_IN, Gtk::ICON_SIZE_BUTTON))));
2830 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2831 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2833 zoom_out_button.set_name ("EditorTimeButton");
2834 zoom_out_button.set_image (*(manage (new Image (Stock::ZOOM_OUT, Gtk::ICON_SIZE_BUTTON))));
2835 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2836 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2838 zoom_out_full_button.set_name ("EditorTimeButton");
2839 zoom_out_full_button.set_image (*(manage (new Image (Stock::ZOOM_100, Gtk::ICON_SIZE_BUTTON))));
2840 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2841 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2843 zoom_focus_selector.set_name ("ZoomFocusSelector");
2844 set_popdown_strings (zoom_focus_selector, zoom_focus_strings, true);
2845 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2846 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
2848 zoom_box.pack_start (zoom_out_button, false, false);
2849 zoom_box.pack_start (zoom_in_button, false, false);
2850 zoom_box.pack_start (zoom_out_full_button, false, false);
2852 /* Track zoom buttons */
2853 tav_expand_button.set_name ("TrackHeightButton");
2854 tav_expand_button.set_size_request(-1,20);
2855 tav_expand_button.add (*(manage (new Image (::get_icon("tav_exp")))));
2856 tav_expand_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::tav_zoom_step), true));
2857 ARDOUR_UI::instance()->tooltips().set_tip (tav_expand_button, _("Expand Tracks"));
2859 tav_shrink_button.set_name ("TrackHeightButton");
2860 tav_shrink_button.set_size_request(-1,20);
2861 tav_shrink_button.add (*(manage (new Image (::get_icon("tav_shrink")))));
2862 tav_shrink_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::tav_zoom_step), false));
2863 ARDOUR_UI::instance()->tooltips().set_tip (tav_shrink_button, _("Shrink Tracks"));
2865 track_zoom_box.set_spacing (1);
2866 track_zoom_box.set_border_width (0);
2868 track_zoom_box.pack_start (tav_shrink_button, false, false);
2869 track_zoom_box.pack_start (tav_expand_button, false, false);
2871 HBox* zbc = manage (new HBox);
2872 zbc->pack_start (zoom_focus_selector, PACK_SHRINK);
2873 zoom_vbox.pack_start (*zbc, PACK_SHRINK);
2874 zoom_vbox.pack_start (zoom_box, PACK_SHRINK);
2875 zoom_vbox.pack_start (track_zoom_box, PACK_SHRINK);
2877 snap_box.set_spacing (1);
2878 snap_box.set_border_width (2);
2880 snap_type_selector.set_name ("SnapTypeSelector");
2881 set_popdown_strings (snap_type_selector, snap_type_strings, true);
2882 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2883 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Snap/Grid Units"));
2885 snap_mode_selector.set_name ("SnapModeSelector");
2886 set_popdown_strings (snap_mode_selector, snap_mode_strings, true);
2887 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2888 ARDOUR_UI::instance()->tooltips().set_tip (snap_mode_selector, _("Snap/Grid Mode"));
2890 edit_point_selector.set_name ("EditPointSelector");
2891 set_popdown_strings (edit_point_selector, edit_point_strings, true);
2892 edit_point_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_point_selection_done));
2893 ARDOUR_UI::instance()->tooltips().set_tip (edit_point_selector, _("Edit point"));
2895 snap_box.pack_start (snap_mode_selector, false, false);
2896 snap_box.pack_start (snap_type_selector, false, false);
2897 snap_box.pack_start (edit_point_selector, false, false);
2901 HBox *nudge_box = manage (new HBox);
2902 nudge_box->set_spacing(1);
2903 nudge_box->set_border_width (2);
2905 nudge_forward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_forward_release), false);
2906 nudge_backward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_backward_release), false);
2908 nudge_box->pack_start (nudge_backward_button, false, false);
2909 nudge_box->pack_start (nudge_forward_button, false, false);
2910 nudge_box->pack_start (nudge_clock, false, false);
2913 /* Pack everything in... */
2915 HBox* hbox = manage (new HBox);
2916 hbox->set_spacing(10);
2918 tools_tearoff = manage (new TearOff (*hbox));
2919 tools_tearoff->set_name ("MouseModeBase");
2920 tools_tearoff->tearoff_window().signal_key_press_event().connect (bind (sigc::ptr_fun (relay_key_press), &tools_tearoff->tearoff_window()), false);
2922 if (Profile->get_sae()) {
2923 tools_tearoff->set_can_be_torn_off (false);
2926 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2927 &tools_tearoff->tearoff_window()));
2928 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2929 &tools_tearoff->tearoff_window(), 0));
2930 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2931 &tools_tearoff->tearoff_window()));
2932 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2933 &tools_tearoff->tearoff_window(), 0));
2935 toolbar_hbox.set_spacing (10);
2936 toolbar_hbox.set_border_width (1);
2938 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2939 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2941 hbox->pack_start (snap_box, false, false);
2942 hbox->pack_start (*nudge_box, false, false);
2943 hbox->pack_start (panic_box, false, false);
2947 toolbar_base.set_name ("ToolBarBase");
2948 toolbar_base.add (toolbar_hbox);
2950 toolbar_frame.set_shadow_type (SHADOW_OUT);
2951 toolbar_frame.set_name ("BaseFrame");
2952 toolbar_frame.add (toolbar_base);
2956 Editor::midi_panic ()
2958 cerr << "MIDI panic\n";
2961 session->midi_panic();
2966 Editor::setup_midi_toolbar ()
2970 /* Midi sound notes */
2971 midi_sound_notes.add (*(manage (new Image (::get_icon("midi_sound_notes")))));
2972 midi_sound_notes.set_relief(Gtk::RELIEF_NONE);
2973 ARDOUR_UI::instance()->tooltips().set_tip (midi_sound_notes, _("Sound Notes"));
2974 midi_sound_notes.unset_flags (CAN_FOCUS);
2978 act = ActionManager::get_action (X_("MIDI"), X_("panic"));
2979 midi_panic_button.set_name("MidiPanicButton");
2980 ARDOUR_UI::instance()->tooltips().set_tip (midi_panic_button, _("Send note off and reset controller messages on all MIDI channels"));
2981 act->connect_proxy (midi_panic_button);
2983 panic_box.pack_start (midi_sound_notes , true, true);
2984 panic_box.pack_start (midi_panic_button, true, true);
2988 Editor::convert_drop_to_paths (
2989 vector<ustring>& paths,
2990 const RefPtr<Gdk::DragContext>& /*context*/,
2993 const SelectionData& data,
3001 vector<ustring> uris = data.get_uris();
3005 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
3006 are actually URI lists. So do it by hand.
3009 if (data.get_target() != "text/plain") {
3013 /* Parse the "uri-list" format that Nautilus provides,
3014 where each pathname is delimited by \r\n.
3016 THERE MAY BE NO NULL TERMINATING CHAR!!!
3019 ustring txt = data.get_text();
3023 p = (const char *) malloc (txt.length() + 1);
3024 txt.copy ((char *) p, txt.length(), 0);
3025 ((char*)p)[txt.length()] = '\0';
3031 while (g_ascii_isspace (*p))
3035 while (*q && (*q != '\n') && (*q != '\r')) {
3042 while (q > p && g_ascii_isspace (*q))
3047 uris.push_back (ustring (p, q - p + 1));
3051 p = strchr (p, '\n');
3063 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
3065 if ((*i).substr (0,7) == "file://") {
3068 PBD::url_decode (p);
3070 // scan forward past three slashes
3072 ustring::size_type slashcnt = 0;
3073 ustring::size_type n = 0;
3074 ustring::iterator x = p.begin();
3076 while (slashcnt < 3 && x != p.end()) {
3079 } else if (slashcnt == 3) {
3086 if (slashcnt != 3 || x == p.end()) {
3087 error << _("malformed URL passed to drag-n-drop code") << endmsg;
3091 paths.push_back (p.substr (n - 1));
3099 Editor::new_tempo_section ()
3105 Editor::map_transport_state ()
3107 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
3109 if (session->transport_stopped()) {
3110 have_pending_keyboard_selection = false;
3113 update_loop_range_view (true);
3118 Editor::State::State (PublicEditor const * e)
3120 selection = new Selection (e);
3123 Editor::State::~State ()
3129 Editor::store_state (State& state) const
3131 *state.selection = *selection;
3135 Editor::restore_state (State *state)
3137 if (*selection == *state->selection) {
3141 *selection = *state->selection;
3142 time_selection_changed ();
3143 region_selection_changed ();
3145 /* XXX other selection change handlers? */
3149 Editor::begin_reversible_command (string name)
3152 before = &get_state();
3153 session->begin_reversible_command (name);
3158 Editor::commit_reversible_command ()
3161 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
3166 Editor::set_route_group_solo (Route& route, bool yn)
3168 RouteGroup *route_group;
3170 if ((route_group = route.route_group()) != 0) {
3171 route_group->apply (&Route::set_solo, yn, this);
3173 route.set_solo (yn, this);
3178 Editor::set_route_group_mute (Route& route, bool yn)
3180 RouteGroup *route_group = 0;
3182 if ((route_group == route.route_group()) != 0) {
3183 route_group->apply (&Route::set_mute, yn, this);
3185 route.set_mute (yn, this);
3190 Editor::history_changed ()
3194 if (undo_action && session) {
3195 if (session->undo_depth() == 0) {
3198 label = string_compose(_("Undo (%1)"), session->next_undo());
3200 undo_action->property_label() = label;
3203 if (redo_action && session) {
3204 if (session->redo_depth() == 0) {
3207 label = string_compose(_("Redo (%1)"), session->next_redo());
3209 redo_action->property_label() = label;
3214 Editor::duplicate_dialog (bool with_dialog)
3218 if (mouse_mode == MouseRange) {
3219 if (selection->time.length() == 0) {
3225 get_regions_for_action (rs);
3227 if (mouse_mode != MouseRange) {
3236 ArdourDialog win ("Duplicate");
3237 Label label (_("Number of Duplications:"));
3238 Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
3239 SpinButton spinner (adjustment, 0.0, 1);
3242 win.get_vbox()->set_spacing (12);
3243 win.get_vbox()->pack_start (hbox);
3244 hbox.set_border_width (6);
3245 hbox.pack_start (label, PACK_EXPAND_PADDING, 12);
3247 /* dialogs have ::add_action_widget() but that puts the spinner in the wrong
3248 place, visually. so do this by hand.
3251 hbox.pack_start (spinner, PACK_EXPAND_PADDING, 12);
3252 spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
3253 spinner.grab_focus();
3259 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3260 win.add_button (_("Duplicate"), RESPONSE_ACCEPT);
3261 win.set_default_response (RESPONSE_ACCEPT);
3263 win.set_position (WIN_POS_MOUSE);
3265 spinner.grab_focus ();
3267 switch (win.run ()) {
3268 case RESPONSE_ACCEPT:
3274 times = adjustment.get_value();
3277 if (mouse_mode == MouseRange) {
3278 duplicate_selection (times);
3280 duplicate_some_regions (rs, times);
3285 Editor::show_verbose_canvas_cursor ()
3287 verbose_canvas_cursor->raise_to_top();
3288 verbose_canvas_cursor->show();
3289 verbose_cursor_visible = true;
3293 Editor::hide_verbose_canvas_cursor ()
3295 verbose_canvas_cursor->hide();
3296 verbose_cursor_visible = false;
3300 Editor::clamp_verbose_cursor_x (double x)
3305 x = min (_canvas_width - 200.0, x);
3311 Editor::clamp_verbose_cursor_y (double y)
3313 if (y < canvas_timebars_vsize) {
3314 y = canvas_timebars_vsize;
3316 y = min (_canvas_height - 50, y);
3322 Editor::show_verbose_canvas_cursor_with (const string & txt)
3324 verbose_canvas_cursor->property_text() = txt.c_str();
3329 track_canvas->get_pointer (x, y);
3330 track_canvas->window_to_world (x, y, wx, wy);
3332 /* move it away from the mouse pointer to avoid an
3333 infinite loop of enter/leave events.
3339 /* don't get too close to the edge */
3340 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (wx);
3341 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (wy);
3343 show_verbose_canvas_cursor ();
3347 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3349 verbose_canvas_cursor->property_text() = txt.c_str();
3350 /* don't get too close to the edge */
3351 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (x);
3352 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (y);
3356 Editor::set_verbose_canvas_cursor_text (const string & txt)
3358 verbose_canvas_cursor->property_text() = txt.c_str();
3362 Editor::set_edit_mode (EditMode m)
3364 Config->set_edit_mode (m);
3368 Editor::cycle_edit_mode ()
3370 switch (Config->get_edit_mode()) {
3372 if (Profile->get_sae()) {
3373 Config->set_edit_mode (Lock);
3375 Config->set_edit_mode (Splice);
3379 Config->set_edit_mode (Lock);
3382 Config->set_edit_mode (Slide);
3388 Editor::edit_mode_selection_done ()
3394 string choice = edit_mode_selector.get_active_text();
3395 EditMode mode = Slide;
3397 if (choice == _("Splice Edit")) {
3399 } else if (choice == _("Slide Edit")) {
3401 } else if (choice == _("Lock Edit")) {
3405 Config->set_edit_mode (mode);
3409 Editor::snap_type_selection_done ()
3411 string choice = snap_type_selector.get_active_text();
3412 SnapType snaptype = SnapToBeat;
3414 if (choice == _("Beats/3")) {
3415 snaptype = SnapToAThirdBeat;
3416 } else if (choice == _("Beats/4")) {
3417 snaptype = SnapToAQuarterBeat;
3418 } else if (choice == _("Beats/8")) {
3419 snaptype = SnapToAEighthBeat;
3420 } else if (choice == _("Beats/16")) {
3421 snaptype = SnapToASixteenthBeat;
3422 } else if (choice == _("Beats/32")) {
3423 snaptype = SnapToAThirtysecondBeat;
3424 } else if (choice == _("Beats")) {
3425 snaptype = SnapToBeat;
3426 } else if (choice == _("Bars")) {
3427 snaptype = SnapToBar;
3428 } else if (choice == _("Marks")) {
3429 snaptype = SnapToMark;
3430 } else if (choice == _("Region starts")) {
3431 snaptype = SnapToRegionStart;
3432 } else if (choice == _("Region ends")) {
3433 snaptype = SnapToRegionEnd;
3434 } else if (choice == _("Region bounds")) {
3435 snaptype = SnapToRegionBoundary;
3436 } else if (choice == _("Region syncs")) {
3437 snaptype = SnapToRegionSync;
3438 } else if (choice == _("CD Frames")) {
3439 snaptype = SnapToCDFrame;
3440 } else if (choice == _("Timecode Frames")) {
3441 snaptype = SnapToTimecodeFrame;
3442 } else if (choice == _("Timecode Seconds")) {
3443 snaptype = SnapToTimecodeSeconds;
3444 } else if (choice == _("Timecode Minutes")) {
3445 snaptype = SnapToTimecodeMinutes;
3446 } else if (choice == _("Seconds")) {
3447 snaptype = SnapToSeconds;
3448 } else if (choice == _("Minutes")) {
3449 snaptype = SnapToMinutes;
3452 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3454 ract->set_active ();
3459 Editor::snap_mode_selection_done ()
3461 string choice = snap_mode_selector.get_active_text();
3462 SnapMode mode = SnapNormal;
3464 if (choice == _("No Grid")) {
3466 } else if (choice == _("Grid")) {
3468 } else if (choice == _("Magnetic")) {
3469 mode = SnapMagnetic;
3472 RefPtr<RadioAction> ract = snap_mode_action (mode);
3475 ract->set_active (true);
3480 Editor::cycle_edit_point (bool with_marker)
3482 switch (_edit_point) {
3484 set_edit_point_preference (EditAtPlayhead);
3486 case EditAtPlayhead:
3488 set_edit_point_preference (EditAtSelectedMarker);
3490 set_edit_point_preference (EditAtMouse);
3493 case EditAtSelectedMarker:
3494 set_edit_point_preference (EditAtMouse);
3500 Editor::edit_point_selection_done ()
3502 string choice = edit_point_selector.get_active_text();
3503 EditPoint ep = EditAtSelectedMarker;
3505 if (choice == _("Marker")) {
3506 set_edit_point_preference (EditAtSelectedMarker);
3507 } else if (choice == _("Playhead")) {
3508 set_edit_point_preference (EditAtPlayhead);
3510 set_edit_point_preference (EditAtMouse);
3513 RefPtr<RadioAction> ract = edit_point_action (ep);
3516 ract->set_active (true);
3521 Editor::zoom_focus_selection_done ()
3523 string choice = zoom_focus_selector.get_active_text();
3524 ZoomFocus focus_type = ZoomFocusLeft;
3526 if (choice == _("Left")) {
3527 focus_type = ZoomFocusLeft;
3528 } else if (choice == _("Right")) {
3529 focus_type = ZoomFocusRight;
3530 } else if (choice == _("Center")) {
3531 focus_type = ZoomFocusCenter;
3532 } else if (choice == _("Play")) {
3533 focus_type = ZoomFocusPlayhead;
3534 } else if (choice == _("Edit")) {
3535 focus_type = ZoomFocusEdit;
3536 } else if (choice == _("Active Mark")) {
3537 focus_type = ZoomFocusEdit;
3538 } else if (choice == _("Active Mark")) {
3539 focus_type = ZoomFocusEdit;
3541 focus_type = ZoomFocusMouse;
3544 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3547 ract->set_active ();
3552 Editor::edit_controls_button_release (GdkEventButton* ev)
3554 if (Keyboard::is_context_menu_event (ev)) {
3555 ARDOUR_UI::instance()->add_route (this);
3561 Editor::mouse_select_button_release (GdkEventButton* ev)
3563 /* this handles just right-clicks */
3565 if (ev->button != 3) {
3572 Editor::TrackViewList *
3573 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3575 TrackViewList::iterator i;
3577 TrackViewList* v = new TrackViewList;
3579 if (track == 0 && group == 0) {
3583 for (i = track_views.begin(); i != track_views.end (); ++i) {
3587 } else if ((track != 0 && group == 0) || (track != 0 && group != 0 && !group->active_property (RouteGroup::Select))) {
3589 /* just the view for this track
3592 v->push_back (track);
3596 /* views for all tracks in the route group */
3598 for (i = track_views.begin(); i != track_views.end (); ++i) {
3600 if (group == 0 || ((*i)->route_group() == group && group->active_property (RouteGroup::Select))) {
3610 Editor::set_zoom_focus (ZoomFocus f)
3612 string str = zoom_focus_strings[(int)f];
3614 if (str != zoom_focus_selector.get_active_text()) {
3615 zoom_focus_selector.set_active_text (str);
3618 if (zoom_focus != f) {
3621 ZoomFocusChanged (); /* EMIT_SIGNAL */
3628 Editor::ensure_float (Window& win)
3630 win.set_transient_for (*this);
3634 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3636 /* recover or initialize pane positions. do this here rather than earlier because
3637 we don't want the positions to change the child allocations, which they seem to do.
3643 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3645 static int32_t done;
3648 width = default_width;
3649 height = default_height;
3651 if ((geometry = find_named_node (*node, "geometry")) != 0) {
3653 if ((prop = geometry->property ("x_size")) == 0) {
3654 prop = geometry->property ("x-size");
3657 width = atoi (prop->value());
3659 if ((prop = geometry->property ("y_size")) == 0) {
3660 prop = geometry->property ("y-size");
3663 height = atoi (prop->value());
3667 if (which == static_cast<Paned*> (&edit_pane)) {
3673 if (!geometry || (prop = geometry->property ("edit-pane-pos")) == 0) {
3674 /* initial allocation is 90% to canvas, 10% to notebook */
3675 pos = (int) floor (alloc.get_width() * 0.90f);
3676 snprintf (buf, sizeof(buf), "%d", pos);
3678 pos = atoi (prop->value());
3681 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3682 edit_pane.set_position (pos);
3683 pre_maximal_pane_position = pos;
3689 Editor::detach_tearoff (Box* /*b*/, Window* /*w*/)
3691 cerr << "remove tearoff\n";
3693 if (tools_tearoff->torn_off() &&
3694 mouse_mode_tearoff->torn_off()) {
3695 top_hbox.remove (toolbar_frame);
3700 Editor::reattach_tearoff (Box* /*b*/, Window* /*w*/, int32_t /*n*/)
3702 cerr << "reattach tearoff\n";
3703 if (toolbar_frame.get_parent() == 0) {
3704 top_hbox.pack_end (toolbar_frame);
3709 Editor::set_show_measures (bool yn)
3711 if (_show_measures != yn) {
3714 if ((_show_measures = yn) == true) {
3716 tempo_lines->show();
3724 Editor::toggle_follow_playhead ()
3726 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3728 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3729 set_follow_playhead (tact->get_active());
3734 Editor::set_follow_playhead (bool yn)
3736 if (_follow_playhead != yn) {
3737 if ((_follow_playhead = yn) == true) {
3739 update_current_screen ();
3746 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
3748 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3750 xfade->set_active (!xfade->active());
3755 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
3757 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3759 xfade->set_follow_overlap (!xfade->following_overlap());
3764 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
3766 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3772 CrossfadeEditor cew (*session, xfade, xfade->fade_in().get_min_y(), 1.0);
3776 switch (cew.run ()) {
3777 case RESPONSE_ACCEPT:
3784 xfade->StateChanged (Change (~0));
3788 Editor::playlist_selector () const
3790 return *_playlist_selector;
3794 Editor::get_grid_type_as_beats (bool& success, nframes64_t position)
3798 switch (_snap_type) {
3803 case SnapToAThirtysecondBeat:
3807 case SnapToASixteenthBeat:
3811 case SnapToAEighthBeat:
3815 case SnapToAQuarterBeat:
3819 case SnapToAThirdBeat:
3825 return session->tempo_map().meter_at (position).beats_per_bar();
3830 case SnapToTimecodeFrame:
3831 case SnapToTimecodeSeconds:
3832 case SnapToTimecodeMinutes:
3835 case SnapToRegionStart:
3836 case SnapToRegionEnd:
3837 case SnapToRegionSync:
3838 case SnapToRegionBoundary:
3848 Editor::get_nudge_distance (nframes64_t pos, nframes64_t& next)
3852 ret = nudge_clock.current_duration (pos);
3853 next = ret + 1; /* XXXX fix me */
3859 Editor::end_location_changed (Location* location)
3861 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3862 //reset_scrolling_region ();
3863 nframes64_t session_span = location->start() + (nframes64_t) floorf (current_page_frames() * 0.10f);
3864 horizontal_adjustment.set_upper (session_span / frames_per_unit);
3868 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
3870 ArdourDialog dialog ("playlist deletion dialog");
3871 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3872 "If left alone, no audio files used by it will be cleaned.\n"
3873 "If deleted, audio files used by it alone by will cleaned."),
3876 dialog.set_position (WIN_POS_CENTER);
3877 dialog.get_vbox()->pack_start (label);
3881 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3882 dialog.add_button (_("Keep playlist"), RESPONSE_REJECT);
3883 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3885 switch (dialog.run ()) {
3886 case RESPONSE_ACCEPT:
3887 /* delete the playlist */
3891 case RESPONSE_REJECT:
3892 /* keep the playlist */
3904 Editor::audio_region_selection_covers (nframes64_t where)
3906 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3907 if ((*a)->region()->covers (where)) {
3916 Editor::prepare_for_cleanup ()
3918 cut_buffer->clear_regions ();
3919 cut_buffer->clear_playlists ();
3921 selection->clear_regions ();
3922 selection->clear_playlists ();
3924 _regions->suspend_redisplay ();
3928 Editor::finish_cleanup ()
3930 _regions->resume_redisplay ();
3934 Editor::transport_loop_location()
3937 return session->locations()->auto_loop_location();
3944 Editor::transport_punch_location()
3947 return session->locations()->auto_punch_location();
3954 Editor::control_layout_scroll (GdkEventScroll* ev)
3956 switch (ev->direction) {
3958 scroll_tracks_up_line ();
3962 case GDK_SCROLL_DOWN:
3963 scroll_tracks_down_line ();
3967 /* no left/right handling yet */
3975 Editor::session_state_saved (string snap_name)
3977 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
3979 _snapshots->redisplay ();
3983 Editor::maximise_editing_space ()
3985 mouse_mode_tearoff->set_visible (false);
3986 tools_tearoff->set_visible (false);
3988 pre_maximal_pane_position = edit_pane.get_position();
3989 pre_maximal_editor_width = this->get_width();
3991 if(post_maximal_pane_position == 0) {
3992 post_maximal_pane_position = edit_pane.get_width();
3997 if(post_maximal_editor_width) {
3998 edit_pane.set_position (post_maximal_pane_position -
3999 abs(post_maximal_editor_width - pre_maximal_editor_width));
4001 edit_pane.set_position (post_maximal_pane_position);
4006 Editor::restore_editing_space ()
4008 // user changed width of pane during fullscreen
4010 if(post_maximal_pane_position != edit_pane.get_position()) {
4011 post_maximal_pane_position = edit_pane.get_position();
4016 mouse_mode_tearoff->set_visible (true);
4017 tools_tearoff->set_visible (true);
4018 post_maximal_editor_width = this->get_width();
4020 edit_pane.set_position (pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width));
4024 * Make new playlists for a given track and also any others that belong
4025 * to the same active route group with the `edit' property.
4030 Editor::new_playlists (TimeAxisView* v)
4032 begin_reversible_command (_("new playlists"));
4033 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4034 session->get_playlists(playlists);
4035 mapover_tracks (bind (mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v, RouteGroup::Edit);
4036 commit_reversible_command ();
4040 * Use a copy of the current playlist for a given track and also any others that belong
4041 * to the same active route group with the `edit' property.
4046 Editor::copy_playlists (TimeAxisView* v)
4048 begin_reversible_command (_("copy playlists"));
4049 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4050 session->get_playlists(playlists);
4051 mapover_tracks (bind (mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v, RouteGroup::Edit);
4052 commit_reversible_command ();
4055 /** Clear the current playlist for a given track and also any others that belong
4056 * to the same active route group with the `edit' property.
4061 Editor::clear_playlists (TimeAxisView* v)
4063 begin_reversible_command (_("clear playlists"));
4064 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4065 session->get_playlists(playlists);
4066 mapover_tracks (mem_fun (*this, &Editor::mapped_clear_playlist), v, RouteGroup::Edit);
4067 commit_reversible_command ();
4071 Editor::mapped_use_new_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4073 atv.use_new_playlist (sz > 1 ? false : true, playlists);
4077 Editor::mapped_use_copy_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4079 atv.use_copy_playlist (sz > 1 ? false : true, playlists);
4083 Editor::mapped_clear_playlist (RouteTimeAxisView& atv, uint32_t /*sz*/)
4085 atv.clear_playlist ();
4089 Editor::on_key_press_event (GdkEventKey* ev)
4091 return key_press_focus_accelerator_handler (*this, ev);
4095 Editor::on_key_release_event (GdkEventKey* ev)
4097 return Gtk::Window::on_key_release_event (ev);
4098 // return key_press_focus_accelerator_handler (*this, ev);
4102 Editor::reset_x_origin (nframes64_t frame)
4104 //cerr << "resetting x origin" << endl;
4105 queue_visual_change (frame);
4109 Editor::reset_y_origin (double y)
4111 queue_visual_change_y (y);
4115 Editor::reset_zoom (double fpu)
4117 queue_visual_change (fpu);
4121 Editor::reposition_and_zoom (nframes64_t frame, double fpu)
4123 //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
4124 reset_x_origin (frame);
4127 if (!no_save_visual) {
4128 undo_visual_stack.push_back (current_visual_state(false));
4132 Editor::VisualState*
4133 Editor::current_visual_state (bool with_tracks)
4135 VisualState* vs = new VisualState;
4136 vs->y_position = vertical_adjustment.get_value();
4137 vs->frames_per_unit = frames_per_unit;
4138 vs->leftmost_frame = leftmost_frame;
4139 vs->zoom_focus = zoom_focus;
4142 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4143 vs->track_states.push_back (TAVState ((*i), &(*i)->get_state()));
4151 Editor::undo_visual_state ()
4153 if (undo_visual_stack.empty()) {
4157 VisualState* vs = undo_visual_stack.back();
4158 undo_visual_stack.pop_back();
4159 use_visual_state (*vs);
4160 redo_visual_stack.push_back (vs);
4164 Editor::redo_visual_state ()
4166 if (redo_visual_stack.empty()) {
4170 VisualState* vs = redo_visual_stack.back();
4171 redo_visual_stack.pop_back();
4172 use_visual_state (*vs);
4173 undo_visual_stack.push_back (vs);
4177 Editor::swap_visual_state ()
4179 if (undo_visual_stack.empty()) {
4180 redo_visual_state ();
4182 undo_visual_state ();
4187 Editor::use_visual_state (VisualState& vs)
4189 no_save_visual = true;
4191 _routes->suspend_redisplay ();
4193 vertical_adjustment.set_value (vs.y_position);
4195 set_zoom_focus (vs.zoom_focus);
4196 reposition_and_zoom (vs.leftmost_frame, vs.frames_per_unit);
4198 for (list<TAVState>::iterator i = vs.track_states.begin(); i != vs.track_states.end(); ++i) {
4199 TrackViewList::iterator t;
4201 /* check if the track still exists - it could have been deleted */
4203 if ((t = find (track_views.begin(), track_views.end(), i->first)) != track_views.end()) {
4204 (*t)->set_state (*(i->second), Stateful::loading_state_version);
4209 if (!vs.track_states.empty()) {
4210 _routes->update_visibility ();
4213 _routes->resume_redisplay ();
4215 no_save_visual = false;
4219 Editor::set_frames_per_unit (double fpu)
4221 /* this is the core function that controls the zoom level of the canvas. it is called
4222 whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
4225 if (fpu == frames_per_unit) {
4234 /* don't allow zooms that fit more than the maximum number
4235 of frames into an 800 pixel wide space.
4238 if (max_frames / fpu < 800.0) {
4243 tempo_lines->tempo_map_changed();
4245 frames_per_unit = fpu;
4250 Editor::post_zoom ()
4252 nframes64_t cef = 0;
4254 // convert fpu to frame count
4256 nframes64_t frames = (nframes64_t) floor (frames_per_unit * _canvas_width);
4258 if (frames_per_unit != zoom_range_clock.current_duration()) {
4259 zoom_range_clock.set (frames);
4262 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
4263 if (!selection->tracks.empty()) {
4264 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4265 (*i)->reshow_selection (selection->time);
4268 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4269 (*i)->reshow_selection (selection->time);
4274 leftmost_frame = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4276 ZoomChanged (); /* EMIT_SIGNAL */
4278 reset_hscrollbar_stepping ();
4281 cef = session->current_end_frame() + (current_page_frames() / 10);// Add a little extra so we can see the end marker
4283 horizontal_adjustment.set_upper (cef / frames_per_unit);
4285 //reset_scrolling_region ();
4287 if (playhead_cursor) {
4288 playhead_cursor->set_position (playhead_cursor->current_frame);
4291 refresh_location_display();
4292 _summary->set_overlays_dirty ();
4298 Editor::queue_visual_change (nframes64_t where)
4300 pending_visual_change.add (VisualChange::TimeOrigin);
4302 /* if we're moving beyond the end, make sure the upper limit of the horizontal adjustment
4306 if (where > session->current_end_frame()) {
4307 horizontal_adjustment.set_upper ((where + current_page_frames()) / frames_per_unit);
4310 pending_visual_change.time_origin = where;
4312 ensure_visual_change_idle_handler ();
4316 Editor::queue_visual_change (double fpu)
4318 pending_visual_change.add (VisualChange::ZoomLevel);
4319 pending_visual_change.frames_per_unit = fpu;
4321 ensure_visual_change_idle_handler ();
4326 Editor::queue_visual_change_y (double y)
4328 pending_visual_change.add (VisualChange::YOrigin);
4329 pending_visual_change.y_origin = y;
4331 ensure_visual_change_idle_handler ();
4335 Editor::ensure_visual_change_idle_handler ()
4337 if (pending_visual_change.idle_handler_id < 0) {
4338 pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
4343 Editor::_idle_visual_changer (void* arg)
4345 return static_cast<Editor*>(arg)->idle_visual_changer ();
4349 Editor::idle_visual_changer ()
4351 VisualChange::Type p = pending_visual_change.pending;
4352 pending_visual_change.pending = (VisualChange::Type) 0;
4354 #ifdef FIX_THIS_FOR_V3
4355 double last_time_origin = horizontal_adjustment.get_value();
4358 if (p & VisualChange::ZoomLevel) {
4359 set_frames_per_unit (pending_visual_change.frames_per_unit);
4361 compute_fixed_ruler_scale ();
4362 compute_current_bbt_points(pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4363 compute_bbt_ruler_scale (pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4364 update_tempo_based_rulers ();
4366 if (p & VisualChange::TimeOrigin) {
4367 horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
4369 if (p & VisualChange::YOrigin) {
4370 vertical_adjustment.set_value (pending_visual_change.y_origin);
4373 nframes64_t csf=0, cef=0;
4374 nframes64_t current_time_origin = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4377 csf = session->current_start_frame();
4378 cef = session->current_end_frame();
4381 /* if we seek beyond the current end of the canvas, move the end */
4383 #ifdef FIX_THIS_FOR_V3
4384 if (last_time_origin == horizontal_adjustment.get_value() ) {
4385 /* changed signal not emitted */
4386 update_fixed_rulers ();
4387 redisplay_tempo (true);
4391 if (current_time_origin != pending_visual_change.time_origin) {
4392 cef += current_page_frames() / 10; // Add a little extra so we can see the end marker
4393 horizontal_adjustment.set_upper (cef / frames_per_unit);
4394 horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
4396 update_fixed_rulers();
4397 redisplay_tempo (true);
4400 _summary->set_overlays_dirty ();
4402 //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
4403 pending_visual_change.idle_handler_id = -1;
4404 return 0; /* this is always a one-shot call */
4407 struct EditorOrderTimeAxisSorter {
4408 bool operator() (const TimeAxisView* a, const TimeAxisView* b) const {
4409 return a->order () < b->order ();
4414 Editor::sort_track_selection (TrackSelection* sel)
4416 EditorOrderTimeAxisSorter cmp;
4421 selection->tracks.sort (cmp);
4426 Editor::get_preferred_edit_position (bool ignore_playhead)
4429 nframes64_t where = 0;
4430 EditPoint ep = _edit_point;
4432 if (entered_marker) {
4433 return entered_marker->position();
4436 if (ignore_playhead && ep == EditAtPlayhead) {
4437 ep = EditAtSelectedMarker;
4441 case EditAtPlayhead:
4442 where = session->audible_frame();
4445 case EditAtSelectedMarker:
4446 if (!selection->markers.empty()) {
4448 Location* loc = find_location_from_marker (selection->markers.front(), is_start);
4451 where = loc->start();
4462 if (!mouse_frame (where, ignored)) {
4463 /* XXX not right but what can we do ? */
4474 Editor::set_loop_range (nframes64_t start, nframes64_t end, string cmd)
4476 if (!session) return;
4478 begin_reversible_command (cmd);
4482 if ((tll = transport_loop_location()) == 0) {
4483 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoLoop);
4484 XMLNode &before = session->locations()->get_state();
4485 session->locations()->add (loc, true);
4486 session->set_auto_loop_location (loc);
4487 XMLNode &after = session->locations()->get_state();
4488 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4490 XMLNode &before = tll->get_state();
4491 tll->set_hidden (false, this);
4492 tll->set (start, end);
4493 XMLNode &after = tll->get_state();
4494 session->add_command (new MementoCommand<Location>(*tll, &before, &after));
4497 commit_reversible_command ();
4501 Editor::set_punch_range (nframes64_t start, nframes64_t end, string cmd)
4503 if (!session) return;
4505 begin_reversible_command (cmd);
4509 if ((tpl = transport_punch_location()) == 0) {
4510 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoPunch);
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));
4518 XMLNode &before = tpl->get_state();
4519 tpl->set_hidden (false, this);
4520 tpl->set (start, end);
4521 XMLNode &after = tpl->get_state();
4522 session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
4525 commit_reversible_command ();
4528 /** Find regions which exist at a given time, and optionally on a given list of tracks.
4529 * @param rs List to which found regions are added.
4530 * @param where Time to look at.
4531 * @param ts Tracks to look on; if this is empty, all tracks are examined.
4534 Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4536 const TrackSelection* tracks;
4539 tracks = &track_views;
4544 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4545 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4547 boost::shared_ptr<Diskstream> ds;
4548 boost::shared_ptr<Playlist> pl;
4550 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
4552 Playlist::RegionList* regions = pl->regions_at (
4553 (nframes64_t) floor ( (double)where * ds->speed()));
4555 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4556 RegionView* rv = rtv->view()->find_view (*i);
4569 Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4571 const TrackSelection* tracks;
4574 tracks = &track_views;
4579 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4580 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4582 boost::shared_ptr<Diskstream> ds;
4583 boost::shared_ptr<Playlist> pl;
4585 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
4587 Playlist::RegionList* regions = pl->regions_touched (
4588 (nframes64_t) floor ( (double)where * ds->speed()), max_frames);
4590 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4592 RegionView* rv = rtv->view()->find_view (*i);
4605 /** Find all regions which are either:
4607 * - the entered_regionview (if allow_entered == true) or
4608 * - under the preferred edit position AND on a selected track, or on a track
4609 * which is in the same active edit-enable route group as a selected region (if allow_edit_position == true)
4610 * @param rs Returned region list.
4611 * @param allow_entered true to include the entered_regionview in the list.
4614 Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered, bool allow_edit_position)
4616 /* Start with selected regions */
4617 rs = selection->regions;
4619 /* Add the entered_regionview, if requested */
4620 if (allow_entered && entered_regionview) {
4621 rs.add (entered_regionview);
4624 if (allow_edit_position) {
4626 TrackSelection tracks = selection->tracks;
4628 /* tracks is currently the set of selected tracks; add any other tracks that
4629 * have regions that are in the same edit-activated route group as one of
4631 for (RegionSelection::iterator i = rs.begin (); i != rs.end(); ++i) {
4633 RouteGroup* g = (*i)->get_time_axis_view().route_group ();
4634 if (g && g->active_property (RouteGroup::Edit)) {
4635 tracks.add (axis_views_from_routes (g->route_list()));
4639 /* now find regions that are at the edit position on those tracks */
4640 nframes64_t const where = get_preferred_edit_position ();
4641 get_regions_at (rs, where, tracks);
4646 Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<RegionView*>& regions)
4648 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4650 RouteTimeAxisView* tatv;
4652 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
4654 boost::shared_ptr<Playlist> pl;
4655 vector<boost::shared_ptr<Region> > results;
4657 boost::shared_ptr<Diskstream> ds;
4659 if ((ds = tatv->get_diskstream()) == 0) {
4664 if ((pl = (ds->playlist())) != 0) {
4665 pl->get_region_list_equivalent_regions (region, results);
4668 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
4669 if ((marv = tatv->view()->find_view (*ir)) != 0) {
4670 regions.push_back (marv);
4679 Editor::show_rhythm_ferret ()
4681 if (rhythm_ferret == 0) {
4682 rhythm_ferret = new RhythmFerret(*this);
4685 rhythm_ferret->set_session (session);
4686 rhythm_ferret->show ();
4687 rhythm_ferret->present ();
4691 Editor::show_bundle_manager ()
4693 if (_bundle_manager == 0) {
4694 _bundle_manager = new BundleManager (*session);
4697 _bundle_manager->show ();
4701 Editor::show_global_port_matrix (ARDOUR::DataType t)
4703 if (_global_port_matrix[t] == 0) {
4704 _global_port_matrix[t] = new GlobalPortMatrixWindow (*session, t);
4707 _global_port_matrix[t]->show ();
4711 Editor::first_idle ()
4713 MessageDialog* dialog = 0;
4715 if (track_views.size() > 1) {
4716 dialog = new MessageDialog (*this,
4717 _("Please wait while Ardour loads visual data"),
4722 ARDOUR_UI::instance()->flush_pending ();
4725 for (TrackViewList::iterator t = track_views.begin(); t != track_views.end(); ++t) {
4729 // first idle adds route children (automation tracks), so we need to redisplay here
4730 _routes->redisplay ();
4738 _idle_resizer (gpointer arg)
4740 return ((Editor*)arg)->idle_resize ();
4744 Editor::add_to_idle_resize (TimeAxisView* view, int32_t h)
4746 if (resize_idle_id < 0) {
4747 resize_idle_id = g_idle_add (_idle_resizer, this);
4748 _pending_resize_amount = 0;
4751 /* make a note of the smallest resulting height, so that we can clamp the
4752 lower limit at TimeAxisView::hSmall */
4754 int32_t min_resulting = INT32_MAX;
4756 _pending_resize_amount += h;
4757 _pending_resize_view = view;
4759 min_resulting = min (min_resulting, int32_t (_pending_resize_view->current_height()) + _pending_resize_amount);
4761 if (selection->tracks.contains (_pending_resize_view)) {
4762 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4763 min_resulting = min (min_resulting, int32_t ((*i)->current_height()) + _pending_resize_amount);
4767 if (min_resulting < 0) {
4772 if (uint32_t (min_resulting) < TimeAxisView::hSmall) {
4773 _pending_resize_amount += TimeAxisView::hSmall - min_resulting;
4777 /** Handle pending resizing of tracks */
4779 Editor::idle_resize ()
4781 _pending_resize_view->idle_resize (_pending_resize_view->current_height() + _pending_resize_amount);
4783 if (dynamic_cast<AutomationTimeAxisView*> (_pending_resize_view) == 0 &&
4784 selection->tracks.contains (_pending_resize_view)) {
4786 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4787 if (*i != _pending_resize_view) {
4788 (*i)->idle_resize ((*i)->current_height() + _pending_resize_amount);
4794 _group_tabs->set_dirty ();
4795 resize_idle_id = -1;
4803 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::located));
4805 _pending_locate_request = false;
4809 Editor::region_view_added (RegionView *)
4811 _summary->set_dirty ();
4815 Editor::streamview_height_changed ()
4817 _summary->set_dirty ();
4821 Editor::axis_view_from_route (Route* r) const
4823 TrackViewList::const_iterator j = track_views.begin ();
4824 while (j != track_views.end()) {
4825 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*j);
4826 if (rtv && rtv->route().get() == r) {
4837 Editor::axis_views_from_routes (list<Route*> r) const
4841 for (list<Route*>::const_iterator i = r.begin(); i != r.end(); ++i) {
4842 TimeAxisView* tv = axis_view_from_route (*i);
4853 Editor::handle_new_route (RouteList& routes)
4855 ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_route), routes));
4857 RouteTimeAxisView *rtv;
4858 list<RouteTimeAxisView*> new_views;
4860 for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) {
4861 boost::shared_ptr<Route> route = (*x);
4863 if (route->is_hidden()) {
4867 DataType dt = route->input()->default_type();
4869 if (dt == ARDOUR::DataType::AUDIO) {
4870 rtv = new AudioTimeAxisView (*this, *session, route, *track_canvas);
4871 } else if (dt == ARDOUR::DataType::MIDI) {
4872 rtv = new MidiTimeAxisView (*this, *session, route, *track_canvas);
4874 throw unknown_type();
4877 new_views.push_back (rtv);
4878 track_views.push_back (rtv);
4880 rtv->effective_gain_display ();
4882 rtv->view()->RegionViewAdded.connect (mem_fun (*this, &Editor::region_view_added));
4883 rtv->view()->HeightChanged.connect (mem_fun (*this, &Editor::streamview_height_changed));
4885 rtv->GoingAway.connect (bind (mem_fun(*this, &Editor::remove_route), rtv));
4888 _routes->routes_added (new_views);
4890 if (show_editor_mixer_when_tracks_arrive) {
4891 show_editor_mixer (true);
4894 editor_list_button.set_sensitive (true);
4896 _summary->set_dirty ();
4900 Editor::remove_route (TimeAxisView *tv)
4902 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::remove_route), tv));
4904 TrackViewList::iterator i;
4906 boost::shared_ptr<Route> route;
4907 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (tv);
4909 route = rtav->route ();
4912 TimeAxisView* next_tv = 0;
4914 if (tv == entered_track) {
4918 if ((i = find (track_views.begin(), track_views.end(), tv)) != track_views.end()) {
4920 i = track_views.erase (i);
4922 if (track_views.empty()) {
4924 } else if (i == track_views.end()) {
4925 next_tv = track_views.front();
4931 if (current_mixer_strip && current_mixer_strip->route() == route) {
4934 set_selected_mixer_strip (*next_tv);
4936 /* make the editor mixer strip go away setting the
4937 * button to inactive (which also unticks the menu option)
4940 ActionManager::uncheck_toggleaction ("<Actions>/Editor/show-editor-mixer");
4946 Editor::hide_track_in_display (TimeAxisView& tv, bool /*temponly*/)
4948 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (&tv);
4950 if (rtv && current_mixer_strip && (rtv->route() == current_mixer_strip->route())) {
4951 // this will hide the mixer strip
4952 set_selected_mixer_strip (tv);
4955 _routes->hide_track_in_display (tv);
4959 Editor::sync_track_view_list_and_routes ()
4961 track_views = TrackSelection (_routes->views ());
4963 _summary->set_dirty ();
4964 _group_tabs->set_dirty ();
4966 return false; // do not call again (until needed)
4970 Editor::foreach_time_axis_view (sigc::slot<void,TimeAxisView&> theslot)
4972 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4978 Editor::get_route_view_by_id (PBD::ID& id)
4980 RouteTimeAxisView* v;
4982 for(TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4983 if((v = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) {
4984 if(v->route()->id() == id) {
4994 Editor::fit_route_group (RouteGroup *g)
4996 TrackSelection ts = axis_views_from_routes (g->route_list ());
5001 Editor::consider_auditioning (boost::shared_ptr<Region> region)
5003 boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion> (region);
5006 session->cancel_audition ();
5010 if (session->is_auditioning()) {
5011 session->cancel_audition ();
5012 if (r == last_audition_region) {
5017 session->audition_region (r);
5018 last_audition_region = r;
5023 Editor::hide_a_region (boost::shared_ptr<Region> r)
5025 r->set_hidden (true);
5029 Editor::remove_a_region (boost::shared_ptr<Region> r)
5031 session->remove_region_from_region_list (r);
5035 Editor::audition_region_from_region_list ()
5037 _regions->selection_mapover (mem_fun (*this, &Editor::consider_auditioning));
5041 Editor::hide_region_from_region_list ()
5043 _regions->selection_mapover (mem_fun (*this, &Editor::hide_a_region));
5047 Editor::start_step_editing ()
5049 step_edit_connection = Glib::signal_timeout().connect (mem_fun (*this, &Editor::check_step_edit), 20);
5053 Editor::stop_step_editing ()
5055 step_edit_connection.disconnect ();
5059 Editor::check_step_edit ()
5061 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5062 MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*> (*i);
5064 mtv->check_step_edit ();
5068 return true; // do it again, till we stop