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 "ardour_ui.h"
33 * ardour_ui.h include was moved to the top of the list
34 * due to a conflicting definition of 'Style' between
35 * Apple's MacTypes.h and BarController.
38 #include <boost/none.hpp>
40 #include <sigc++/bind.h>
42 #include "pbd/convert.h"
43 #include "pbd/error.h"
44 #include "pbd/enumwriter.h"
45 #include "pbd/memento_command.h"
46 #include "pbd/unknown_type.h"
48 #include <glibmm/miscutils.h>
49 #include <gtkmm/image.h>
50 #include <gdkmm/color.h>
51 #include <gdkmm/bitmap.h>
53 #include <gtkmm2ext/grouped_buttons.h>
54 #include <gtkmm2ext/gtk_ui.h>
55 #include <gtkmm2ext/tearoff.h>
56 #include <gtkmm2ext/utils.h>
57 #include <gtkmm2ext/window_title.h>
58 #include <gtkmm2ext/choice.h>
59 #include <gtkmm2ext/cell_renderer_pixbuf_toggle.h>
61 #include "ardour/audio_diskstream.h"
62 #include "ardour/audio_track.h"
63 #include "ardour/audioplaylist.h"
64 #include "ardour/audioregion.h"
65 #include "ardour/location.h"
66 #include "ardour/midi_region.h"
67 #include "ardour/plugin_manager.h"
68 #include "ardour/profile.h"
69 #include "ardour/route_group.h"
70 #include "ardour/session_directory.h"
71 #include "ardour/session_route.h"
72 #include "ardour/session_state_utils.h"
73 #include "ardour/tempo.h"
74 #include "ardour/utils.h"
75 #include "ardour/session_playlists.h"
76 #include "ardour/audioengine.h"
78 #include "control_protocol/control_protocol.h"
83 #include "playlist_selector.h"
84 #include "audio_region_view.h"
85 #include "rgb_macros.h"
86 #include "selection.h"
87 #include "audio_streamview.h"
88 #include "time_axis_view.h"
89 #include "audio_time_axis.h"
91 #include "crossfade_view.h"
92 #include "canvas-noevent-text.h"
94 #include "public_editor.h"
95 #include "crossfade_edit.h"
96 #include "canvas_impl.h"
99 #include "gui_thread.h"
100 #include "simpleline.h"
101 #include "rhythm_ferret.h"
103 #include "tempo_lines.h"
104 #include "analysis_window.h"
105 #include "bundle_manager.h"
106 #include "global_port_matrix.h"
107 #include "editor_drag.h"
108 #include "editor_group_tabs.h"
109 #include "automation_time_axis.h"
110 #include "editor_routes.h"
111 #include "midi_time_axis.h"
112 #include "mixer_strip.h"
113 #include "editor_route_groups.h"
114 #include "editor_regions.h"
115 #include "editor_locations.h"
116 #include "editor_snapshots.h"
117 #include "editor_summary.h"
122 #include "imageframe_socket_handler.h"
126 using namespace ARDOUR;
129 using namespace Glib;
130 using namespace Gtkmm2ext;
131 using namespace Editing;
133 using PBD::internationalize;
135 using Gtkmm2ext::Keyboard;
137 const double Editor::timebar_height = 15.0;
139 #include "editor_xpms"
141 static const gchar *_snap_type_strings[] = {
143 N_("Timecode Frames"),
144 N_("Timecode Seconds"),
145 N_("Timecode Minutes"),
173 static const gchar *_snap_mode_strings[] = {
180 static const gchar *_edit_point_strings[] = {
187 static const gchar *_zoom_focus_strings[] = {
197 #ifdef USE_RUBBERBAND
198 static const gchar *_rb_opt_strings[] = {
201 N_("Balanced multitimbral mixture"),
202 N_("Unpitched percussion with stable notes"),
203 N_("Crisp monophonic instrumental"),
204 N_("Unpitched solo percussion"),
205 N_("Resample without preserving pitch"),
210 /* Soundfile drag-n-drop */
212 Gdk::Cursor* Editor::cross_hair_cursor = 0;
213 Gdk::Cursor* Editor::selector_cursor = 0;
214 Gdk::Cursor* Editor::trimmer_cursor = 0;
215 Gdk::Cursor* Editor::left_side_trim_cursor = 0;
216 Gdk::Cursor* Editor::right_side_trim_cursor = 0;
217 Gdk::Cursor* Editor::fade_in_cursor = 0;
218 Gdk::Cursor* Editor::fade_out_cursor = 0;
219 Gdk::Cursor* Editor::grabber_cursor = 0;
220 Gdk::Cursor* Editor::grabber_note_cursor = 0;
221 Gdk::Cursor* Editor::grabber_edit_point_cursor = 0;
222 Gdk::Cursor* Editor::zoom_cursor = 0;
223 Gdk::Cursor* Editor::time_fx_cursor = 0;
224 Gdk::Cursor* Editor::fader_cursor = 0;
225 Gdk::Cursor* Editor::speaker_cursor = 0;
226 Gdk::Cursor* Editor::midi_pencil_cursor = 0;
227 Gdk::Cursor* Editor::midi_select_cursor = 0;
228 Gdk::Cursor* Editor::midi_resize_cursor = 0;
229 Gdk::Cursor* Editor::midi_erase_cursor = 0;
230 Gdk::Cursor* Editor::wait_cursor = 0;
231 Gdk::Cursor* Editor::timebar_cursor = 0;
232 Gdk::Cursor* Editor::transparent_cursor = 0;
235 show_me_the_size (Requisition* r, const char* what)
237 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
242 pane_size_watcher (Paned* pane)
244 /* if the handle of a pane vanishes into (at least) the tabs of a notebook,
245 it is no longer accessible. so stop that. this doesn't happen on X11,
246 just the quartz backend.
251 int max_width_of_lhs = GTK_WIDGET(pane->gobj())->allocation.width - 25;
253 gint pos = pane->get_position ();
255 if (pos > max_width_of_lhs) {
256 pane->set_position (max_width_of_lhs);
262 : _join_object_range_state (JOIN_OBJECT_RANGE_NONE)
264 /* time display buttons */
265 , minsec_label (_("Mins:Secs"))
266 , bbt_label (_("Bars:Beats"))
267 , timecode_label (_("Timecode"))
268 , frame_label (_("Samples"))
269 , tempo_label (_("Tempo"))
270 , meter_label (_("Meter"))
271 , mark_label (_("Location Markers"))
272 , range_mark_label (_("Range Markers"))
273 , transport_mark_label (_("Loop/Punch Ranges"))
274 , cd_mark_label (_("CD Markers"))
275 , edit_packer (4, 4, true)
277 /* the values here don't matter: layout widgets
278 reset them as needed.
281 , vertical_adjustment (0.0, 0.0, 10.0, 400.0)
283 /* tool bar related */
285 , zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, false, true)
287 , toolbar_selection_clock_table (2,3)
289 , automation_mode_button (_("mode"))
290 , global_automation_button (_("automation"))
292 , midi_panic_button (_("Panic"))
295 , image_socket_listener(0)
300 , nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, false, true)
301 , meters_running(false)
302 , _pending_locate_request (false)
303 , _pending_initial_locate (false)
308 /* we are a singleton */
310 PublicEditor::_instance = this;
314 selection = new Selection (this);
315 cut_buffer = new Selection (this);
317 clicked_regionview = 0;
318 clicked_axisview = 0;
319 clicked_routeview = 0;
320 clicked_crossfadeview = 0;
321 clicked_control_point = 0;
322 last_update_frame = 0;
323 _drags = new DragManager (this);
324 current_mixer_strip = 0;
325 current_bbt_points = 0;
328 snap_type_strings = I18N (_snap_type_strings);
329 snap_mode_strings = I18N (_snap_mode_strings);
330 zoom_focus_strings = I18N (_zoom_focus_strings);
331 edit_point_strings = I18N (_edit_point_strings);
332 #ifdef USE_RUBBERBAND
333 rb_opt_strings = I18N (_rb_opt_strings);
337 snap_threshold = 5.0;
338 bbt_beat_subdivision = 4;
341 last_autoscroll_x = 0;
342 last_autoscroll_y = 0;
343 autoscroll_active = false;
344 autoscroll_timeout_tag = -1;
349 current_interthread_info = 0;
350 _show_measures = true;
351 show_gain_after_trim = false;
352 verbose_cursor_on = true;
353 last_item_entered = 0;
354 last_item_entered_n = 0;
356 have_pending_keyboard_selection = false;
357 _follow_playhead = true;
358 _stationary_playhead = false;
359 _xfade_visibility = true;
360 editor_ruler_menu = 0;
361 no_ruler_shown_update = false;
363 session_range_marker_menu = 0;
364 range_marker_menu = 0;
365 marker_menu_item = 0;
366 tempo_or_meter_marker_menu = 0;
367 transport_marker_menu = 0;
368 new_transport_marker_menu = 0;
369 editor_mixer_strip_width = Wide;
370 show_editor_mixer_when_tracks_arrive = false;
371 region_edit_menu_split_multichannel_item = 0;
372 region_edit_menu_split_item = 0;
375 current_stepping_trackview = 0;
377 entered_regionview = 0;
379 clear_entered_track = false;
382 button_release_can_deselect = true;
383 _dragging_playhead = false;
384 _dragging_edit_point = false;
385 select_new_marker = false;
388 no_save_visual = false;
391 scrubbing_direction = 0;
395 location_marker_color = ARDOUR_UI::config()->canvasvar_LocationMarker.get();
396 location_range_color = ARDOUR_UI::config()->canvasvar_LocationRange.get();
397 location_cd_marker_color = ARDOUR_UI::config()->canvasvar_LocationCDMarker.get();
398 location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
399 location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
401 _edit_point = EditAtMouse;
402 _internal_editing = false;
403 current_canvas_cursor = 0;
405 frames_per_unit = 2048; /* too early to use reset_zoom () */
407 _scroll_callbacks = 0;
409 zoom_focus = ZoomFocusLeft;
410 set_zoom_focus (ZoomFocusLeft);
411 zoom_range_clock.ValueChanged.connect (sigc::mem_fun(*this, &Editor::zoom_adjustment_changed));
413 bbt_label.set_name ("EditorTimeButton");
414 bbt_label.set_size_request (-1, (int)timebar_height);
415 bbt_label.set_alignment (1.0, 0.5);
416 bbt_label.set_padding (5,0);
418 bbt_label.set_no_show_all();
419 minsec_label.set_name ("EditorTimeButton");
420 minsec_label.set_size_request (-1, (int)timebar_height);
421 minsec_label.set_alignment (1.0, 0.5);
422 minsec_label.set_padding (5,0);
423 minsec_label.hide ();
424 minsec_label.set_no_show_all();
425 timecode_label.set_name ("EditorTimeButton");
426 timecode_label.set_size_request (-1, (int)timebar_height);
427 timecode_label.set_alignment (1.0, 0.5);
428 timecode_label.set_padding (5,0);
429 timecode_label.hide ();
430 timecode_label.set_no_show_all();
431 frame_label.set_name ("EditorTimeButton");
432 frame_label.set_size_request (-1, (int)timebar_height);
433 frame_label.set_alignment (1.0, 0.5);
434 frame_label.set_padding (5,0);
436 frame_label.set_no_show_all();
438 tempo_label.set_name ("EditorTimeButton");
439 tempo_label.set_size_request (-1, (int)timebar_height);
440 tempo_label.set_alignment (1.0, 0.5);
441 tempo_label.set_padding (5,0);
443 tempo_label.set_no_show_all();
444 meter_label.set_name ("EditorTimeButton");
445 meter_label.set_size_request (-1, (int)timebar_height);
446 meter_label.set_alignment (1.0, 0.5);
447 meter_label.set_padding (5,0);
449 meter_label.set_no_show_all();
450 mark_label.set_name ("EditorTimeButton");
451 mark_label.set_size_request (-1, (int)timebar_height);
452 mark_label.set_alignment (1.0, 0.5);
453 mark_label.set_padding (5,0);
455 mark_label.set_no_show_all();
456 cd_mark_label.set_name ("EditorTimeButton");
457 cd_mark_label.set_size_request (-1, (int)timebar_height);
458 cd_mark_label.set_alignment (1.0, 0.5);
459 cd_mark_label.set_padding (5,0);
460 cd_mark_label.hide();
461 cd_mark_label.set_no_show_all();
462 range_mark_label.set_name ("EditorTimeButton");
463 range_mark_label.set_size_request (-1, (int)timebar_height);
464 range_mark_label.set_alignment (1.0, 0.5);
465 range_mark_label.set_padding (5,0);
466 range_mark_label.hide();
467 range_mark_label.set_no_show_all();
468 transport_mark_label.set_name ("EditorTimeButton");
469 transport_mark_label.set_size_request (-1, (int)timebar_height);
470 transport_mark_label.set_alignment (1.0, 0.5);
471 transport_mark_label.set_padding (5,0);
472 transport_mark_label.hide();
473 transport_mark_label.set_no_show_all();
475 initialize_rulers ();
476 initialize_canvas ();
477 _summary = new EditorSummary (this);
479 selection->TimeChanged.connect (sigc::mem_fun(*this, &Editor::time_selection_changed));
480 selection->TracksChanged.connect (sigc::mem_fun(*this, &Editor::track_selection_changed));
481 editor_regions_selection_changed_connection = selection->RegionsChanged.connect (sigc::mem_fun(*this, &Editor::region_selection_changed));
482 selection->PointsChanged.connect (sigc::mem_fun(*this, &Editor::point_selection_changed));
483 selection->MarkersChanged.connect (sigc::mem_fun(*this, &Editor::marker_selection_changed));
485 edit_controls_vbox.set_spacing (0);
486 vertical_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &Editor::tie_vertical_scrolling), true);
487 track_canvas->signal_map_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_map_handler));
489 HBox* h = manage (new HBox);
490 _group_tabs = new EditorGroupTabs (this);
491 h->pack_start (*_group_tabs, PACK_SHRINK);
492 h->pack_start (edit_controls_vbox);
493 controls_layout.add (*h);
495 controls_layout.set_name ("EditControlsBase");
496 controls_layout.add_events (Gdk::SCROLL_MASK);
497 controls_layout.signal_scroll_event().connect (sigc::mem_fun(*this, &Editor::control_layout_scroll), false);
499 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
500 controls_layout.signal_button_release_event().connect (sigc::mem_fun(*this, &Editor::edit_controls_button_release));
501 controls_layout_size_request_connection = controls_layout.signal_size_request().connect (sigc::mem_fun (*this, &Editor::controls_layout_size_request));
505 ArdourCanvas::Canvas* time_pad = manage(new ArdourCanvas::Canvas());
506 ArdourCanvas::SimpleLine* pad_line_1 = manage(new ArdourCanvas::SimpleLine(*time_pad->root(),
507 0.0, 1.0, 100.0, 1.0));
508 pad_line_1->property_color_rgba() = 0xFF0000FF;
512 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars) + 2);
513 time_canvas_vbox.set_size_request (-1, -1);
515 ruler_label_event_box.add (ruler_label_vbox);
516 ruler_label_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
517 ruler_label_event_box.signal_button_release_event().connect (sigc::mem_fun(*this, &Editor::ruler_label_button_release));
519 time_button_event_box.add (time_button_vbox);
520 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
521 time_button_event_box.signal_button_release_event().connect (sigc::mem_fun(*this, &Editor::ruler_label_button_release));
523 /* these enable us to have a dedicated window (for cursor setting, etc.)
524 for the canvas areas.
527 track_canvas_event_box.add (*track_canvas);
529 time_canvas_event_box.add (time_canvas_vbox);
530 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
532 edit_packer.set_col_spacings (0);
533 edit_packer.set_row_spacings (0);
534 edit_packer.set_homogeneous (false);
535 edit_packer.set_border_width (0);
536 edit_packer.set_name ("EditorWindow");
538 /* labels for the rulers */
539 edit_packer.attach (ruler_label_event_box, 1, 2, 0, 1, FILL, SHRINK, 0, 0);
540 /* labels for the marker "tracks" */
541 edit_packer.attach (time_button_event_box, 1, 2, 1, 2, FILL, SHRINK, 0, 0);
543 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
545 edit_packer.attach (controls_layout, 0, 2, 2, 3, FILL, FILL|EXPAND, 0, 0);
547 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 3, FILL|EXPAND, FILL|EXPAND, 0, 0);
549 bottom_hbox.set_border_width (2);
550 bottom_hbox.set_spacing (3);
552 _route_groups = new EditorRouteGroups (this);
553 _routes = new EditorRoutes (this);
554 _regions = new EditorRegions (this);
555 _snapshots = new EditorSnapshots (this);
556 _locations = new EditorLocations (this);
560 nlabel = manage (new Label (_("Regions")));
561 nlabel->set_angle (-90);
562 the_notebook.append_page (_regions->widget (), *nlabel);
563 nlabel = manage (new Label (_("Tracks & Busses")));
564 nlabel->set_angle (-90);
565 the_notebook.append_page (_routes->widget (), *nlabel);
566 nlabel = manage (new Label (_("Snapshots")));
567 nlabel->set_angle (-90);
568 the_notebook.append_page (_snapshots->widget (), *nlabel);
569 nlabel = manage (new Label (_("Route Groups")));
570 nlabel->set_angle (-90);
571 the_notebook.append_page (_route_groups->widget (), *nlabel);
572 nlabel = manage (new Label (_("Ranges & Marks")));
573 nlabel->set_angle (-90);
574 the_notebook.append_page (_locations->widget (), *nlabel);
576 the_notebook.set_show_tabs (true);
577 the_notebook.set_scrollable (true);
578 the_notebook.popup_disable ();
579 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
580 the_notebook.show_all ();
582 post_maximal_editor_width = 0;
583 post_maximal_horizontal_pane_position = 0;
584 post_maximal_editor_height = 0;
585 post_maximal_vertical_pane_position = 0;
587 editor_summary_pane.pack1(edit_packer);
589 Button* summary_arrows_left_left = manage (new Button);
590 summary_arrows_left_left->add (*manage (new Arrow (ARROW_LEFT, SHADOW_NONE)));
591 summary_arrows_left_left->signal_pressed().connect (sigc::hide_return (sigc::mem_fun (*this, &Editor::horizontal_scroll_left_press)));
592 summary_arrows_left_left->signal_released().connect (sigc::mem_fun (*this, &Editor::horizontal_scroll_left_release));
593 Button* summary_arrows_left_right = manage (new Button);
594 summary_arrows_left_right->add (*manage (new Arrow (ARROW_RIGHT, SHADOW_NONE)));
595 summary_arrows_left_right->signal_pressed().connect (sigc::hide_return (sigc::mem_fun (*this, &Editor::horizontal_scroll_right_press)));
596 summary_arrows_left_right->signal_released().connect (sigc::mem_fun (*this, &Editor::horizontal_scroll_right_release));
597 VBox* summary_arrows_left = manage (new VBox);
598 summary_arrows_left->pack_start (*summary_arrows_left_left);
599 summary_arrows_left->pack_start (*summary_arrows_left_right);
601 Button* summary_arrows_right_left = manage (new Button);
602 summary_arrows_right_left->add (*manage (new Arrow (ARROW_LEFT, SHADOW_NONE)));
603 summary_arrows_right_left->signal_pressed().connect (sigc::hide_return (sigc::mem_fun (*this, &Editor::horizontal_scroll_left_press)));
604 summary_arrows_right_left->signal_released().connect (sigc::mem_fun (*this, &Editor::horizontal_scroll_left_release));
605 Button* summary_arrows_right_right = manage (new Button);
606 summary_arrows_right_right->add (*manage (new Arrow (ARROW_RIGHT, SHADOW_NONE)));
607 summary_arrows_right_right->signal_pressed().connect (sigc::hide_return (sigc::mem_fun (*this, &Editor::horizontal_scroll_right_press)));
608 summary_arrows_right_right->signal_released().connect (sigc::mem_fun (*this, &Editor::horizontal_scroll_right_release));
609 VBox* summary_arrows_right = manage (new VBox);
610 summary_arrows_right->pack_start (*summary_arrows_right_left);
611 summary_arrows_right->pack_start (*summary_arrows_right_right);
613 Frame* summary_frame = manage (new Frame);
614 summary_frame->set_shadow_type (Gtk::SHADOW_ETCHED_IN);
615 summary_frame->add (*_summary);
616 summary_frame->show ();
618 _summary_hbox.pack_start (*summary_arrows_left, false, false);
619 _summary_hbox.pack_start (*summary_frame, true, true);
620 _summary_hbox.pack_start (*summary_arrows_right, false, false);
622 editor_summary_pane.pack2 (_summary_hbox);
624 edit_pane.pack1 (editor_summary_pane, true, true);
625 edit_pane.pack2 (the_notebook, false, true);
627 editor_summary_pane.signal_size_allocate().connect (sigc::bind (sigc::mem_fun (*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&editor_summary_pane)));
629 /* XXX: editor_summary_pane might need similar special OS X treatment to the edit_pane */
631 edit_pane.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
633 Glib::PropertyProxy<int> proxy = edit_pane.property_position();
634 proxy.signal_changed().connect (bind (sigc::ptr_fun (pane_size_watcher), static_cast<Paned*> (&edit_pane)));
636 top_hbox.pack_start (toolbar_frame, false, true);
638 HBox *hbox = manage (new HBox);
639 hbox->pack_start (edit_pane, true, true);
641 global_vpacker.pack_start (top_hbox, false, false);
642 global_vpacker.pack_start (*hbox, true, true);
644 global_hpacker.pack_start (global_vpacker, true, true);
646 set_name ("EditorWindow");
647 add_accel_group (ActionManager::ui_manager->get_accel_group());
649 status_bar_hpacker.show ();
651 vpacker.pack_end (status_bar_hpacker, false, false);
652 vpacker.pack_end (global_hpacker, true, true);
654 /* register actions now so that set_state() can find them and set toggles/checks etc */
659 setup_midi_toolbar ();
661 _snap_type = SnapToBeat;
662 set_snap_to (_snap_type);
663 _snap_mode = SnapOff;
664 set_snap_mode (_snap_mode);
665 set_mouse_mode (MouseObject, true);
666 set_edit_point_preference (EditAtMouse, true);
668 _playlist_selector = new PlaylistSelector();
669 _playlist_selector->signal_delete_event().connect (sigc::bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
671 RegionView::RegionViewGoingAway.connect (*this, invalidator (*this), ui_bind (&Editor::catch_vanishing_regionview, this, _1), gui_context());
675 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
676 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
678 nudge_forward_button.set_name ("TransportButton");
679 nudge_backward_button.set_name ("TransportButton");
681 fade_context_menu.set_name ("ArdourContextMenu");
683 /* icons, titles, WM stuff */
685 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
686 Glib::RefPtr<Gdk::Pixbuf> icon;
688 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
689 window_icons.push_back (icon);
691 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
692 window_icons.push_back (icon);
694 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
695 window_icons.push_back (icon);
697 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
698 window_icons.push_back (icon);
700 if (!window_icons.empty()) {
701 set_icon_list (window_icons);
702 set_default_icon_list (window_icons);
705 WindowTitle title(Glib::get_application_name());
706 title += _("Editor");
707 set_title (title.get_string());
708 set_wmclass (X_("ardour_editor"), PROGRAM_NAME);
711 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
713 signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
714 signal_delete_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
716 /* allow external control surfaces/protocols to do various things */
718 ControlProtocol::ZoomToSession.connect (*this, invalidator (*this), boost::bind (&Editor::temporal_zoom_session, this), gui_context());
719 ControlProtocol::ZoomIn.connect (*this, invalidator (*this), boost::bind (&Editor::temporal_zoom_step, this, false), gui_context());
720 ControlProtocol::ZoomOut.connect (*this, invalidator (*this), boost::bind (&Editor::temporal_zoom_step, this, true), gui_context());
721 ControlProtocol::ScrollTimeline.connect (*this, invalidator (*this), ui_bind (&Editor::control_scroll, this, _1), gui_context());
722 BasicUI::AccessAction.connect (*this, invalidator (*this), ui_bind (&Editor::access_action, this, _1, _2), gui_context());
724 /* problematic: has to return a value and thus cannot be x-thread */
726 Session::AskAboutPlaylistDeletion.connect_same_thread (*this, boost::bind (&Editor::playlist_deletion_dialog, this, _1));
728 Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&Editor::parameter_changed, this, _1), gui_context());
730 TimeAxisView::CatchDeletion.connect (*this, invalidator (*this), ui_bind (&Editor::timeaxisview_deleted, this, _1), gui_context());
732 _last_normalization_value = 0;
741 if(image_socket_listener) {
742 if(image_socket_listener->is_connected())
744 image_socket_listener->close_connection() ;
747 delete image_socket_listener ;
748 image_socket_listener = 0 ;
753 delete _route_groups;
759 Editor::add_toplevel_controls (Container& cont)
761 vpacker.pack_start (cont, false, false);
766 Editor::catch_vanishing_regionview (RegionView *rv)
768 /* note: the selection will take care of the vanishing
769 audioregionview by itself.
772 if (_drags->active() && _drags->have_item (rv->get_canvas_group()) && !_drags->ending()) {
776 if (clicked_regionview == rv) {
777 clicked_regionview = 0;
780 if (entered_regionview == rv) {
781 set_entered_regionview (0);
786 Editor::set_entered_regionview (RegionView* rv)
788 if (rv == entered_regionview) {
792 if (entered_regionview) {
793 entered_regionview->exited ();
796 if ((entered_regionview = rv) != 0) {
797 entered_regionview->entered (internal_editing ());
802 Editor::set_entered_track (TimeAxisView* tav)
805 entered_track->exited ();
808 if ((entered_track = tav) != 0) {
809 entered_track->entered ();
814 Editor::show_window ()
816 if (! is_visible ()) {
819 /* re-hide editor list if necessary */
820 editor_list_button_toggled ();
822 /* re-hide summary widget if necessary */
823 parameter_changed ("show-summary");
825 parameter_changed ("show-edit-group-tabs");
827 /* now reset all audio_time_axis heights, because widgets might need
833 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
834 tv = (static_cast<TimeAxisView*>(*i));
838 reset_zoom (frames_per_unit);
845 Editor::instant_save ()
847 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
852 _session->add_instant_xml(get_state());
854 Config->add_instant_xml(get_state());
859 Editor::zoom_adjustment_changed ()
865 double fpu = zoom_range_clock.current_duration() / _canvas_width;
869 zoom_range_clock.set ((nframes64_t) floor (fpu * _canvas_width));
870 } else if (fpu > _session->current_end_frame() / _canvas_width) {
871 fpu = _session->current_end_frame() / _canvas_width;
872 zoom_range_clock.set ((nframes64_t) floor (fpu * _canvas_width));
879 Editor::control_scroll (float fraction)
881 ENSURE_GUI_THREAD (*this, &Editor::control_scroll, fraction)
887 double step = fraction * current_page_frames();
890 _control_scroll_target is an optional<T>
892 it acts like a pointer to an nframes64_t, with
893 a operator conversion to boolean to check
894 that it has a value could possibly use
895 playhead_cursor->current_frame to store the
896 value and a boolean in the class to know
897 when it's out of date
900 if (!_control_scroll_target) {
901 _control_scroll_target = _session->transport_frame();
902 _dragging_playhead = true;
905 if ((fraction < 0.0f) && (*_control_scroll_target < (nframes64_t) fabs(step))) {
906 *_control_scroll_target = 0;
907 } else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
908 *_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
910 *_control_scroll_target += (nframes64_t) floor (step);
913 /* move visuals, we'll catch up with it later */
915 playhead_cursor->set_position (*_control_scroll_target);
916 UpdateAllTransportClocks (*_control_scroll_target);
918 if (*_control_scroll_target > (current_page_frames() / 2)) {
919 /* try to center PH in window */
920 reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
926 Now we do a timeout to actually bring the session to the right place
927 according to the playhead. This is to avoid reading disk buffers on every
928 call to control_scroll, which is driven by ScrollTimeline and therefore
929 probably by a control surface wheel which can generate lots of events.
931 /* cancel the existing timeout */
933 control_scroll_connection.disconnect ();
935 /* add the next timeout */
937 control_scroll_connection = Glib::signal_timeout().connect (sigc::bind (sigc::mem_fun (*this, &Editor::deferred_control_scroll), *_control_scroll_target), 250);
941 Editor::deferred_control_scroll (nframes64_t /*target*/)
943 _session->request_locate (*_control_scroll_target, _session->transport_rolling());
944 // reset for next stream
945 _control_scroll_target = boost::none;
946 _dragging_playhead = false;
951 Editor::access_action (std::string action_group, std::string action_item)
957 ENSURE_GUI_THREAD (*this, &Editor::access_action, action_group, action_item)
960 act = ActionManager::get_action( action_group.c_str(), action_item.c_str() );
968 Editor::on_realize ()
970 Window::on_realize ();
975 Editor::map_position_change (nframes64_t frame)
977 ENSURE_GUI_THREAD (*this, &Editor::map_position_change, frame)
983 if (_follow_playhead) {
984 center_screen (frame);
987 playhead_cursor->set_position (frame);
991 Editor::center_screen (nframes64_t frame)
993 double page = _canvas_width * frames_per_unit;
995 /* if we're off the page, then scroll.
998 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
999 center_screen_internal (frame, page);
1004 Editor::center_screen_internal (nframes64_t frame, float page)
1009 frame -= (nframes64_t) page;
1014 reset_x_origin (frame);
1019 Editor::update_title ()
1021 ENSURE_GUI_THREAD (*this, &Editor::update_title)
1024 bool dirty = _session->dirty();
1026 string session_name;
1028 if (_session->snap_name() != _session->name()) {
1029 session_name = _session->snap_name();
1031 session_name = _session->name();
1035 session_name = "*" + session_name;
1038 WindowTitle title(session_name);
1039 title += Glib::get_application_name();
1040 set_title (title.get_string());
1045 Editor::set_session (Session *t)
1047 SessionHandlePtr::set_session (t);
1053 zoom_range_clock.set_session (_session);
1054 _playlist_selector->set_session (_session);
1055 nudge_clock.set_session (_session);
1056 _summary->set_session (_session);
1057 _group_tabs->set_session (_session);
1058 _route_groups->set_session (_session);
1059 _regions->set_session (_session);
1060 _snapshots->set_session (_session);
1061 _routes->set_session (_session);
1062 _locations->set_session (_session);
1064 if (rhythm_ferret) {
1065 rhythm_ferret->set_session (_session);
1068 if (analysis_window) {
1069 analysis_window->set_session (_session);
1073 sfbrowser->set_session (_session);
1076 compute_fixed_ruler_scale ();
1078 /* there are never any selected regions at startup */
1079 sensitize_the_right_region_actions (false);
1081 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1082 set_state (*node, Stateful::loading_state_version);
1084 /* catch up with the playhead */
1086 _session->request_locate (playhead_cursor->current_frame);
1087 _pending_initial_locate = true;
1091 /* These signals can all be emitted by a non-GUI thread. Therefore the
1092 handlers for them must not attempt to directly interact with the GUI,
1093 but use Gtkmm2ext::UI::instance()->call_slot();
1096 _session->StepEditStatusChange.connect (_session_connections, invalidator (*this), ui_bind(&Editor::step_edit_status_change, this, _1), gui_context());
1097 _session->TransportStateChange.connect (_session_connections, invalidator (*this), boost::bind (&Editor::map_transport_state, this), gui_context());
1098 _session->PositionChanged.connect (_session_connections, invalidator (*this), ui_bind (&Editor::map_position_change, this, _1), gui_context());
1099 _session->RouteAdded.connect (_session_connections, invalidator (*this), ui_bind (&Editor::handle_new_route, this, _1), gui_context());
1100 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_title, this), gui_context());
1101 _session->TimecodeOffsetChanged.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_just_timecode, this), gui_context());
1102 _session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), ui_bind (&Editor::tempo_map_changed, this, _1), gui_context());
1103 _session->Located.connect (_session_connections, invalidator (*this), boost::bind (&Editor::located, this), gui_context());
1104 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), ui_bind (&Editor::parameter_changed, this, _1), gui_context());
1105 _session->StateSaved.connect (_session_connections, invalidator (*this), ui_bind (&Editor::session_state_saved, this, _1), gui_context());
1106 _session->locations()->added.connect (_session_connections, invalidator (*this), ui_bind (&Editor::add_new_location, this, _1), gui_context());
1107 _session->locations()->removed.connect (_session_connections, invalidator (*this), ui_bind (&Editor::location_gone, this, _1), gui_context());
1108 _session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::refresh_location_display, this), gui_context());
1109 _session->locations()->StateChanged.connect (_session_connections, invalidator (*this), ui_bind (&Editor::refresh_location_display_s, this, _1), gui_context());
1110 _session->history().Changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::history_changed, this), gui_context());
1112 if (Profile->get_sae()) {
1117 nframes_t pos = _session->tempo_map().bbt_duration_at (0, bbt, 1);
1118 nudge_clock.set_mode(AudioClock::BBT);
1119 nudge_clock.set (pos, true, 0, AudioClock::BBT);
1122 nudge_clock.set (_session->frame_rate() * 5, true, 0, AudioClock::Timecode); // default of 5 seconds
1125 playhead_cursor->canvas_item.show ();
1127 Location* loc = _session->locations()->auto_loop_location();
1129 loc = new Location (*_session, 0, _session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1130 if (loc->start() == loc->end()) {
1131 loc->set_end (loc->start() + 1);
1133 _session->locations()->add (loc, false);
1134 _session->set_auto_loop_location (loc);
1137 loc->set_name (_("Loop"));
1140 loc = _session->locations()->auto_punch_location();
1142 loc = new Location (*_session, 0, _session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1143 if (loc->start() == loc->end()) {
1144 loc->set_end (loc->start() + 1);
1146 _session->locations()->add (loc, false);
1147 _session->set_auto_punch_location (loc);
1150 loc->set_name (_("Punch"));
1153 boost::function<void (string)> pc (boost::bind (&Editor::parameter_changed, this, _1));
1154 Config->map_parameters (pc);
1155 _session->config.map_parameters (pc);
1157 refresh_location_display ();
1159 restore_ruler_visibility ();
1160 //tempo_map_changed (PropertyChange (0));
1161 _session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1163 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1164 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1167 super_rapid_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
1168 sigc::mem_fun (*this, &Editor::super_rapid_screen_update)
1171 switch (_snap_type) {
1172 case SnapToRegionStart:
1173 case SnapToRegionEnd:
1174 case SnapToRegionSync:
1175 case SnapToRegionBoundary:
1176 build_region_boundary_cache ();
1183 /* register for undo history */
1184 _session->register_with_memento_command_factory(_id, this);
1186 start_updating_meters ();
1190 Editor::build_cursors ()
1192 using namespace Gdk;
1194 Gdk::Color mbg ("#000000" ); /* Black */
1195 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1198 RefPtr<Bitmap> source, mask;
1199 source = Bitmap::create (mag_bits, mag_width, mag_height);
1200 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1201 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1204 Gdk::Color fbg ("#ffffff" );
1205 Gdk::Color ffg ("#000000" );
1208 RefPtr<Bitmap> source, mask;
1210 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1211 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1212 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1216 RefPtr<Bitmap> source, mask;
1217 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1218 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1219 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1223 RefPtr<Bitmap> bits;
1224 char pix[4] = { 0, 0, 0, 0 };
1225 bits = Bitmap::create (pix, 2, 2);
1227 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1231 RefPtr<Bitmap> bits;
1232 char pix[4] = { 0, 0, 0, 0 };
1233 bits = Bitmap::create (pix, 2, 2);
1235 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1239 grabber_cursor = new Gdk::Cursor (HAND2);
1242 Glib::RefPtr<Gdk::Pixbuf> grabber_note_pixbuf (::get_icon ("grabber_note"));
1243 grabber_note_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_note_pixbuf, 5, 10);
1247 Glib::RefPtr<Gdk::Pixbuf> grabber_edit_point_pixbuf (::get_icon ("grabber_edit_point"));
1248 grabber_edit_point_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_edit_point_pixbuf, 5, 17);
1251 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1252 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1255 Glib::RefPtr<Gdk::Pixbuf> apixbuf (::get_icon ("trim_left_cursor"));
1256 left_side_trim_cursor = new Gdk::Cursor (Gdk::Display::get_default(), apixbuf, 5, 11);
1260 Glib::RefPtr<Gdk::Pixbuf> apixbuf (::get_icon ("trim_right_cursor"));
1261 right_side_trim_cursor = new Gdk::Cursor (Gdk::Display::get_default(), apixbuf, 23, 11);
1265 Glib::RefPtr<Gdk::Pixbuf> apixbuf (::get_icon ("fade_in_cursor"));
1266 fade_in_cursor = new Gdk::Cursor (Gdk::Display::get_default(), apixbuf, 0, 40);
1270 Glib::RefPtr<Gdk::Pixbuf> apixbuf (::get_icon ("fade_out_cursor"));
1271 fade_out_cursor = new Gdk::Cursor (Gdk::Display::get_default(), apixbuf, 27, 40);
1274 selector_cursor = new Gdk::Cursor (XTERM);
1275 time_fx_cursor = new Gdk::Cursor (SIZING);
1276 wait_cursor = new Gdk::Cursor (WATCH);
1277 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1278 midi_pencil_cursor = new Gdk::Cursor (PENCIL);
1279 midi_select_cursor = new Gdk::Cursor (CENTER_PTR);
1280 midi_resize_cursor = new Gdk::Cursor (SIZING);
1281 midi_erase_cursor = new Gdk::Cursor (DRAPED_BOX);
1284 /** Pop up a context menu for when the user clicks on a fade in or fade out */
1286 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1288 using namespace Menu_Helpers;
1289 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1292 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1296 MenuList& items (fade_context_menu.items());
1300 switch (item_type) {
1302 case FadeInHandleItem:
1303 if (arv->audio_region()->fade_in_active()) {
1304 items.push_back (MenuElem (_("Deactivate"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_active), false)));
1306 items.push_back (MenuElem (_("Activate"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_active), true)));
1309 items.push_back (SeparatorElem());
1311 if (Profile->get_sae()) {
1312 items.push_back (MenuElem (_("Linear"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1313 items.push_back (MenuElem (_("Slowest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1315 items.push_back (MenuElem (_("Linear"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1316 items.push_back (MenuElem (_("Slowest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1317 items.push_back (MenuElem (_("Slow"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
1318 items.push_back (MenuElem (_("Fast"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
1319 items.push_back (MenuElem (_("Fastest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
1325 case FadeOutHandleItem:
1326 if (arv->audio_region()->fade_out_active()) {
1327 items.push_back (MenuElem (_("Deactivate"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_active), false)));
1329 items.push_back (MenuElem (_("Activate"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_active), true)));
1332 items.push_back (SeparatorElem());
1334 if (Profile->get_sae()) {
1335 items.push_back (MenuElem (_("Linear"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1336 items.push_back (MenuElem (_("Slowest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1338 items.push_back (MenuElem (_("Linear"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1339 items.push_back (MenuElem (_("Slowest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1340 items.push_back (MenuElem (_("Slow"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
1341 items.push_back (MenuElem (_("Fast"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
1342 items.push_back (MenuElem (_("Fastest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
1348 fatal << _("programming error: ")
1349 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1354 fade_context_menu.popup (button, time);
1358 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes64_t frame)
1360 using namespace Menu_Helpers;
1361 Menu* (Editor::*build_menu_function)(nframes64_t);
1364 switch (item_type) {
1366 case RegionViewName:
1367 case RegionViewNameHighlight:
1368 case LeftFrameHandle:
1369 case RightFrameHandle:
1370 if (with_selection) {
1371 build_menu_function = &Editor::build_track_selection_context_menu;
1373 build_menu_function = &Editor::build_track_region_context_menu;
1378 if (with_selection) {
1379 build_menu_function = &Editor::build_track_selection_context_menu;
1381 build_menu_function = &Editor::build_track_context_menu;
1385 case CrossfadeViewItem:
1386 build_menu_function = &Editor::build_track_crossfade_context_menu;
1390 if (clicked_routeview->track()) {
1391 build_menu_function = &Editor::build_track_context_menu;
1393 build_menu_function = &Editor::build_track_bus_context_menu;
1398 /* probably shouldn't happen but if it does, we don't care */
1402 menu = (this->*build_menu_function)(frame);
1403 menu->set_name ("ArdourContextMenu");
1405 /* now handle specific situations */
1407 switch (item_type) {
1409 case RegionViewName:
1410 case RegionViewNameHighlight:
1411 case LeftFrameHandle:
1412 case RightFrameHandle:
1413 if (!with_selection) {
1414 if (region_edit_menu_split_item) {
1415 if (clicked_regionview && clicked_regionview->region()->covers (get_preferred_edit_position())) {
1416 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, true);
1418 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, false);
1421 if (region_edit_menu_split_multichannel_item) {
1422 if (clicked_regionview && clicked_regionview->region()->n_channels() > 1) {
1423 region_edit_menu_split_multichannel_item->set_sensitive (true);
1425 region_edit_menu_split_multichannel_item->set_sensitive (false);
1434 case CrossfadeViewItem:
1441 /* probably shouldn't happen but if it does, we don't care */
1445 if (item_type != SelectionItem && clicked_routeview && clicked_routeview->audio_track()) {
1447 /* Bounce to disk */
1449 using namespace Menu_Helpers;
1450 MenuList& edit_items = menu->items();
1452 edit_items.push_back (SeparatorElem());
1454 switch (clicked_routeview->audio_track()->freeze_state()) {
1455 case AudioTrack::NoFreeze:
1456 edit_items.push_back (MenuElem (_("Freeze"), sigc::mem_fun(*this, &Editor::freeze_route)));
1459 case AudioTrack::Frozen:
1460 edit_items.push_back (MenuElem (_("Unfreeze"), sigc::mem_fun(*this, &Editor::unfreeze_route)));
1463 case AudioTrack::UnFrozen:
1464 edit_items.push_back (MenuElem (_("Freeze"), sigc::mem_fun(*this, &Editor::freeze_route)));
1470 if (item_type == StreamItem && clicked_routeview) {
1471 clicked_routeview->build_underlay_menu(menu);
1474 menu->popup (button, time);
1478 Editor::build_track_context_menu (nframes64_t)
1480 using namespace Menu_Helpers;
1482 MenuList& edit_items = track_context_menu.items();
1485 add_dstream_context_items (edit_items);
1486 return &track_context_menu;
1490 Editor::build_track_bus_context_menu (nframes64_t)
1492 using namespace Menu_Helpers;
1494 MenuList& edit_items = track_context_menu.items();
1497 add_bus_context_items (edit_items);
1498 return &track_context_menu;
1502 Editor::build_track_region_context_menu (nframes64_t frame)
1504 using namespace Menu_Helpers;
1505 MenuList& edit_items = track_region_context_menu.items();
1508 /* we've just cleared the track region context menu, so the menu that these
1509 two items were on will have disappeared; stop them dangling.
1511 region_edit_menu_split_item = 0;
1512 region_edit_menu_split_multichannel_item = 0;
1514 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (clicked_axisview);
1517 boost::shared_ptr<Track> tr;
1518 boost::shared_ptr<Playlist> pl;
1520 /* Don't offer a region submenu if we are in internal edit mode, as we don't select regions in this
1521 mode and so offering region context is somewhat confusing.
1523 if ((tr = rtv->track()) && ((pl = tr->playlist())) && !internal_editing()) {
1524 Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)frame * tr->speed()));
1526 if (selection->regions.size() > 1) {
1527 // there's already a multiple selection: just add a
1528 // single region context menu that will act on all
1531 list<boost::shared_ptr<Region> > regions;
1532 for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
1533 regions.push_back ((*i)->region ());
1536 add_region_context_items (rtv->view(), regions, edit_items);
1538 for (Playlist::RegionList::reverse_iterator i = regions->rbegin(); i != regions->rend(); ++i) {
1539 list<boost::shared_ptr<Region> > regions;
1540 regions.push_back (*i);
1541 add_region_context_items (rtv->view(), regions, edit_items);
1549 add_dstream_context_items (edit_items);
1551 return &track_region_context_menu;
1555 Editor::build_track_crossfade_context_menu (nframes64_t frame)
1557 using namespace Menu_Helpers;
1558 MenuList& edit_items = track_crossfade_context_menu.items();
1559 edit_items.clear ();
1561 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_axisview);
1564 boost::shared_ptr<Track> tr;
1565 boost::shared_ptr<Playlist> pl;
1566 boost::shared_ptr<AudioPlaylist> apl;
1568 if ((tr = atv->track()) && ((pl = tr->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1570 Playlist::RegionList* regions = pl->regions_at (frame);
1571 AudioPlaylist::Crossfades xfades;
1573 apl->crossfades_at (frame, xfades);
1575 bool many = xfades.size() > 1;
1577 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1578 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1581 if (selection->regions.size() > 1) {
1582 // there's already a multiple selection: just add a
1583 // single region context menu that will act on all
1586 list<boost::shared_ptr<Region> > regions;
1587 for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
1588 regions.push_back ((*i)->region ());
1591 add_region_context_items (atv->audio_view(), regions, edit_items);
1593 for (Playlist::RegionList::reverse_iterator i = regions->rbegin(); i != regions->rend(); ++i) {
1594 list<boost::shared_ptr<Region> > regions;
1595 regions.push_back (*i);
1596 add_region_context_items (atv->audio_view(), regions, edit_items);
1603 add_dstream_context_items (edit_items);
1605 return &track_crossfade_context_menu;
1609 Editor::analyze_region_selection()
1611 if (analysis_window == 0) {
1612 analysis_window = new AnalysisWindow();
1615 analysis_window->set_session(_session);
1617 analysis_window->show_all();
1620 analysis_window->set_regionmode();
1621 analysis_window->analyze();
1623 analysis_window->present();
1627 Editor::analyze_range_selection()
1629 if (analysis_window == 0) {
1630 analysis_window = new AnalysisWindow();
1633 analysis_window->set_session(_session);
1635 analysis_window->show_all();
1638 analysis_window->set_rangemode();
1639 analysis_window->analyze();
1641 analysis_window->present();
1645 Editor::build_track_selection_context_menu (nframes64_t)
1647 using namespace Menu_Helpers;
1648 MenuList& edit_items = track_selection_context_menu.items();
1649 edit_items.clear ();
1651 add_selection_context_items (edit_items);
1652 // edit_items.push_back (SeparatorElem());
1653 // add_dstream_context_items (edit_items);
1655 return &track_selection_context_menu;
1658 /** Add context menu items relevant to crossfades.
1659 * @param edit_items List to add the items to.
1662 Editor::add_crossfade_context_items (AudioStreamView* /*view*/, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1664 using namespace Menu_Helpers;
1665 Menu *xfade_menu = manage (new Menu);
1666 MenuList& items = xfade_menu->items();
1667 xfade_menu->set_name ("ArdourContextMenu");
1670 if (xfade->active()) {
1676 items.push_back (MenuElem (str, sigc::bind (sigc::mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1677 items.push_back (MenuElem (_("Edit..."), sigc::bind (sigc::mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1679 if (xfade->can_follow_overlap()) {
1681 if (xfade->following_overlap()) {
1682 str = _("Convert to Short");
1684 str = _("Convert to Full");
1687 items.push_back (MenuElem (str, sigc::bind (sigc::mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1691 str = xfade->out()->name();
1693 str += xfade->in()->name();
1695 str = _("Crossfade");
1698 edit_items.push_back (MenuElem (str, *xfade_menu));
1699 edit_items.push_back (SeparatorElem());
1703 Editor::xfade_edit_left_region ()
1705 if (clicked_crossfadeview) {
1706 clicked_crossfadeview->left_view.show_region_editor ();
1711 Editor::xfade_edit_right_region ()
1713 if (clicked_crossfadeview) {
1714 clicked_crossfadeview->right_view.show_region_editor ();
1719 Editor::add_region_context_items (StreamView* sv, list<boost::shared_ptr<Region> > regions, Menu_Helpers::MenuList& edit_items)
1721 using namespace Menu_Helpers;
1722 Gtk::MenuItem* foo_item;
1723 Menu *region_menu = manage (new Menu);
1724 MenuList& items = region_menu->items();
1725 region_menu->set_name ("ArdourContextMenu");
1727 /* Look through the regions that we are handling and make notes about what we have got */
1729 bool have_audio = false;
1730 bool have_midi = false;
1731 bool have_locked = false;
1732 bool have_unlocked = false;
1733 bool have_position_lock_style_audio = false;
1734 bool have_position_lock_style_music = false;
1735 bool have_muted = false;
1736 bool have_unmuted = false;
1737 bool have_opaque = false;
1738 bool have_non_opaque = false;
1739 bool have_not_at_natural_position = false;
1740 bool have_envelope_visible = false;
1741 bool have_envelope_invisible = false;
1742 bool have_envelope_active = false;
1743 bool have_envelope_inactive = false;
1744 bool have_non_unity_scale_amplitude = false;
1746 for (list<boost::shared_ptr<Region> >::const_iterator i = regions.begin(); i != regions.end(); ++i) {
1747 boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (*i);
1751 if (boost::dynamic_pointer_cast<MidiRegion> (*i)) {
1755 if ((*i)->locked()) {
1758 have_unlocked = true;
1761 if ((*i)->position_lock_style() == MusicTime) {
1762 have_position_lock_style_music = true;
1764 have_position_lock_style_audio = true;
1767 if ((*i)->muted()) {
1770 have_unmuted = true;
1773 if ((*i)->opaque()) {
1776 have_non_opaque = true;
1779 if (!(*i)->at_natural_position()) {
1780 have_not_at_natural_position = true;
1784 RegionView* rv = sv->find_view (ar);
1785 AudioRegionView* arv = dynamic_cast<AudioRegionView*> (rv);
1787 if (arv->envelope_visible()) {
1788 have_envelope_visible = true;
1790 have_envelope_invisible = true;
1793 if (ar->envelope_active()) {
1794 have_envelope_active = true;
1796 have_envelope_inactive = true;
1799 if (ar->scale_amplitude() != 1) {
1800 have_non_unity_scale_amplitude = true;
1805 if (regions.size() == 1) {
1807 /* when this particular menu pops up, make the relevant region
1811 region_menu->signal_map_event().connect (
1812 sigc::bind (sigc::mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region> (regions.front()))
1815 items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &Editor::rename_region)));
1818 items.push_back (MenuElem (_("List Editor..."), sigc::mem_fun(*this, &Editor::show_midi_list_editor)));
1821 items.push_back (MenuElem (_("Region Properties..."), sigc::mem_fun(*this, &Editor::edit_region)));
1824 items.push_back (MenuElem (_("Raise to Top Layer"), sigc::mem_fun(*this, &Editor::raise_region_to_top)));
1825 items.push_back (MenuElem (_("Lower to Bottom Layer"), sigc::mem_fun (*this, &Editor::lower_region_to_bottom)));
1826 items.push_back (SeparatorElem());
1827 items.push_back (MenuElem (_("Define Sync Point"), sigc::mem_fun(*this, &Editor::set_region_sync_from_edit_point)));
1828 if (_edit_point == EditAtMouse) {
1829 items.back ().set_sensitive (false);
1831 items.push_back (MenuElem (_("Remove Sync Point"), sigc::mem_fun(*this, &Editor::remove_region_sync)));
1832 items.push_back (SeparatorElem());
1834 items.push_back (MenuElem (_("Audition"), sigc::mem_fun(*this, &Editor::play_selected_region)));
1835 items.push_back (MenuElem (_("Export..."), sigc::mem_fun(*this, &Editor::export_region)));
1836 items.push_back (MenuElem (_("Bounce"), sigc::mem_fun(*this, &Editor::bounce_region_selection)));
1839 items.push_back (MenuElem (_("Spectral Analysis..."), sigc::mem_fun(*this, &Editor::analyze_region_selection)));
1842 items.push_back (SeparatorElem());
1844 items.push_back (CheckMenuElem (_("Lock")));
1845 CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1846 if (have_locked && !have_unlocked) {
1847 region_lock_item->set_active();
1848 } else if (have_locked && have_unlocked) {
1849 region_lock_item->set_inconsistent ();
1851 region_lock_item->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_region_lock));
1853 items.push_back (CheckMenuElem (_("Glue to Bars and Beats")));
1854 CheckMenuItem* bbt_glue_item = static_cast<CheckMenuItem*>(&items.back());
1856 if (have_position_lock_style_music && !have_position_lock_style_audio) {
1857 bbt_glue_item->set_active ();
1858 } else if (have_position_lock_style_music && have_position_lock_style_audio) {
1859 bbt_glue_item->set_inconsistent ();
1862 bbt_glue_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_region_lock_style));
1864 items.push_back (CheckMenuElem (_("Mute")));
1865 CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1867 if (have_muted && !have_unmuted) {
1868 region_mute_item->set_active();
1869 } else if (have_muted && have_unmuted) {
1870 region_mute_item->set_inconsistent ();
1873 region_mute_item->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_region_mute));
1875 items.push_back (MenuElem (_("Transpose..."), mem_fun(*this, &Editor::pitch_shift_regions)));
1877 if (!Profile->get_sae()) {
1878 items.push_back (CheckMenuElem (_("Opaque")));
1879 CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1880 if (have_opaque && !have_non_opaque) {
1881 region_opaque_item->set_active();
1882 } else if (have_opaque && have_non_opaque) {
1883 region_opaque_item->set_inconsistent ();
1885 region_opaque_item->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_region_opaque));
1888 items.push_back (CheckMenuElem (_("Original Position"), sigc::mem_fun(*this, &Editor::naturalize)));
1889 if (!have_not_at_natural_position) {
1890 items.back().set_sensitive (false);
1893 items.push_back (SeparatorElem());
1897 if (!Profile->get_sae()) {
1898 items.push_back (MenuElem (_("Reset Envelope"), sigc::mem_fun(*this, &Editor::reset_region_gain_envelopes)));
1900 items.push_back (CheckMenuElem (_("Envelope Visible")));
1901 CheckMenuItem* region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1902 if (have_envelope_visible && !have_envelope_invisible) {
1903 region_envelope_visible_item->set_active ();
1904 } else if (have_envelope_visible && have_envelope_invisible) {
1905 region_envelope_visible_item->set_inconsistent ();
1907 region_envelope_visible_item->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
1909 items.push_back (CheckMenuElem (_("Envelope Active")));
1910 CheckMenuItem* region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1912 if (have_envelope_active && !have_envelope_inactive) {
1913 region_envelope_active_item->set_active ();
1914 } else if (have_envelope_active && have_envelope_inactive) {
1915 region_envelope_active_item->set_inconsistent ();
1918 region_envelope_active_item->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_gain_envelope_active));
1919 items.push_back (SeparatorElem());
1922 items.push_back (MenuElem (_("Normalize..."), sigc::mem_fun(*this, &Editor::normalize_region)));
1923 if (have_non_unity_scale_amplitude) {
1924 items.push_back (MenuElem (_("Reset Gain"), sigc::mem_fun(*this, &Editor::reset_region_scale_amplitude)));
1927 } else if (have_midi) {
1928 items.push_back (MenuElem (_("Quantize"), sigc::mem_fun(*this, &Editor::quantize_region)));
1929 items.push_back (MenuElem (_("Fork"), sigc::mem_fun(*this, &Editor::fork_region)));
1930 items.push_back (SeparatorElem());
1933 items.push_back (MenuElem (_("Strip Silence..."), sigc::mem_fun (*this, &Editor::strip_region_silence)));
1934 items.push_back (MenuElem (_("Reverse"), sigc::mem_fun(*this, &Editor::reverse_region)));
1935 items.push_back (SeparatorElem());
1937 /* range related stuff */
1939 items.push_back (MenuElem (_("Add Single Range"), sigc::mem_fun (*this, &Editor::add_location_from_audio_region)));
1940 items.push_back (MenuElem (_("Add Range Markers"), sigc::mem_fun (*this, &Editor::add_locations_from_audio_region)));
1941 if (selection->regions.size() < 2) {
1942 items.back().set_sensitive (false);
1945 items.push_back (MenuElem (_("Set Range Selection"), sigc::mem_fun (*this, &Editor::set_selection_from_region)));
1946 items.push_back (SeparatorElem());
1950 Menu *nudge_menu = manage (new Menu());
1951 MenuList& nudge_items = nudge_menu->items();
1952 nudge_menu->set_name ("ArdourContextMenu");
1954 nudge_items.push_back (MenuElem (_("Nudge Forward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_forward), false, false))));
1955 nudge_items.push_back (MenuElem (_("Nudge Backward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_backward), false, false))));
1956 nudge_items.push_back (MenuElem (_("Nudge Forward by Capture Offset"), (sigc::mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1957 nudge_items.push_back (MenuElem (_("Nudge Backward by Capture Offset"), (sigc::mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1959 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1960 items.push_back (SeparatorElem());
1962 Menu *trim_menu = manage (new Menu);
1963 MenuList& trim_items = trim_menu->items();
1964 trim_menu->set_name ("ArdourContextMenu");
1966 trim_items.push_back (MenuElem (_("Start to Edit Point"), sigc::mem_fun(*this, &Editor::trim_region_from_edit_point)));
1967 foo_item = &trim_items.back();
1968 if (_edit_point == EditAtMouse) {
1969 foo_item->set_sensitive (false);
1971 trim_items.push_back (MenuElem (_("Edit Point to End"), sigc::mem_fun(*this, &Editor::trim_region_to_edit_point)));
1972 foo_item = &trim_items.back();
1973 if (_edit_point == EditAtMouse) {
1974 foo_item->set_sensitive (false);
1976 trim_items.push_back (MenuElem (_("Trim to Loop"), sigc::mem_fun(*this, &Editor::trim_region_to_loop)));
1977 trim_items.push_back (MenuElem (_("Trim to Punch"), sigc::mem_fun(*this, &Editor::trim_region_to_punch)));
1979 items.push_back (MenuElem (_("Trim"), *trim_menu));
1980 items.push_back (SeparatorElem());
1982 items.push_back (MenuElem (_("Split"), (sigc::mem_fun(*this, &Editor::split))));
1983 region_edit_menu_split_item = &items.back();
1985 if (_edit_point == EditAtMouse) {
1986 region_edit_menu_split_item->set_sensitive (false);
1990 items.push_back (MenuElem (_("Make Mono Regions"), (sigc::mem_fun(*this, &Editor::split_multichannel_region))));
1991 region_edit_menu_split_multichannel_item = &items.back();
1994 items.push_back (MenuElem (_("Duplicate"), (sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_dialog), false))));
1995 items.push_back (MenuElem (_("Multi-Duplicate..."), (sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_dialog), true))));
1996 items.push_back (MenuElem (_("Fill Track"), (sigc::mem_fun(*this, &Editor::region_fill_track))));
1997 items.push_back (SeparatorElem());
1998 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::remove_selected_regions)));
2000 /* OK, stick the region submenu at the top of the list, and then add
2004 /* we have to hack up the region name because "_" has a special
2005 meaning for menu titles.
2008 string::size_type pos = 0;
2009 string menu_item_name = (regions.size() == 1) ? regions.front()->name() : _("Selected Regions");
2011 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
2012 menu_item_name.replace (pos, 1, "__");
2016 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
2017 edit_items.push_back (SeparatorElem());
2020 /** Add context menu items relevant to selection ranges.
2021 * @param edit_items List to add the items to.
2024 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
2026 using namespace Menu_Helpers;
2028 edit_items.push_back (MenuElem (_("Play Range"), sigc::mem_fun(*this, &Editor::play_selection)));
2029 edit_items.push_back (MenuElem (_("Loop Range"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_selection), true)));
2031 edit_items.push_back (SeparatorElem());
2032 edit_items.push_back (MenuElem (_("Spectral Analysis"), sigc::mem_fun(*this, &Editor::analyze_range_selection)));
2034 if (!selection->regions.empty()) {
2035 edit_items.push_back (SeparatorElem());
2036 edit_items.push_back (MenuElem (_("Extend Range to End of Region"), sigc::bind (sigc::mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
2037 edit_items.push_back (MenuElem (_("Extend Range to Start of Region"), sigc::bind (sigc::mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
2040 edit_items.push_back (SeparatorElem());
2041 edit_items.push_back (MenuElem (_("Convert to region in-place"), mem_fun(*this, &Editor::separate_region_from_selection)));
2042 edit_items.push_back (MenuElem (_("Convert to Region in Region List"), sigc::mem_fun(*this, &Editor::new_region_from_selection)));
2044 edit_items.push_back (SeparatorElem());
2045 edit_items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
2047 edit_items.push_back (SeparatorElem());
2048 edit_items.push_back (MenuElem (_("Set Loop from Range"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_selection), false)));
2049 edit_items.push_back (MenuElem (_("Set Punch from Range"), sigc::mem_fun(*this, &Editor::set_punch_from_selection)));
2051 edit_items.push_back (SeparatorElem());
2052 edit_items.push_back (MenuElem (_("Add Range Markers"), sigc::mem_fun (*this, &Editor::add_location_from_selection)));
2054 edit_items.push_back (SeparatorElem());
2055 edit_items.push_back (MenuElem (_("Crop Region to Range"), sigc::mem_fun(*this, &Editor::crop_region_to_selection)));
2056 edit_items.push_back (MenuElem (_("Fill Range with Region"), sigc::mem_fun(*this, &Editor::region_fill_selection)));
2057 edit_items.push_back (MenuElem (_("Duplicate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_dialog), false)));
2059 edit_items.push_back (SeparatorElem());
2060 edit_items.push_back (MenuElem (_("Consolidate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), true, false)));
2061 edit_items.push_back (MenuElem (_("Consolidate Range With Processing"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), true, true)));
2062 edit_items.push_back (MenuElem (_("Bounce Range to Region List"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), false, false)));
2063 edit_items.push_back (MenuElem (_("Bounce Range to Region List With Processing"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), false, true)));
2064 edit_items.push_back (MenuElem (_("Export Range"), sigc::mem_fun(*this, &Editor::export_selection)));
2069 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
2071 using namespace Menu_Helpers;
2075 Menu *play_menu = manage (new Menu);
2076 MenuList& play_items = play_menu->items();
2077 play_menu->set_name ("ArdourContextMenu");
2079 play_items.push_back (MenuElem (_("Play From Edit Point"), sigc::mem_fun(*this, &Editor::play_from_edit_point)));
2080 play_items.push_back (MenuElem (_("Play From Start"), sigc::mem_fun(*this, &Editor::play_from_start)));
2081 play_items.push_back (MenuElem (_("Play Region"), sigc::mem_fun(*this, &Editor::play_selected_region)));
2082 play_items.push_back (SeparatorElem());
2083 play_items.push_back (MenuElem (_("Loop Region"), sigc::mem_fun(*this, &Editor::loop_selected_region)));
2085 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2089 Menu *select_menu = manage (new Menu);
2090 MenuList& select_items = select_menu->items();
2091 select_menu->set_name ("ArdourContextMenu");
2093 select_items.push_back (MenuElem (_("Select All in Track"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2094 select_items.push_back (MenuElem (_("Select All"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all), Selection::Set)));
2095 select_items.push_back (MenuElem (_("Invert Selection in Track"), sigc::mem_fun(*this, &Editor::invert_selection_in_track)));
2096 select_items.push_back (MenuElem (_("Invert Selection"), sigc::mem_fun(*this, &Editor::invert_selection)));
2097 select_items.push_back (SeparatorElem());
2098 select_items.push_back (MenuElem (_("Set Range to Loop Range"), sigc::mem_fun(*this, &Editor::set_selection_from_loop)));
2099 select_items.push_back (MenuElem (_("Set Range to Punch Range"), sigc::mem_fun(*this, &Editor::set_selection_from_punch)));
2100 select_items.push_back (SeparatorElem());
2101 select_items.push_back (MenuElem (_("Select All After Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2102 select_items.push_back (MenuElem (_("Select All Before Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2103 select_items.push_back (MenuElem (_("Select All After Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2104 select_items.push_back (MenuElem (_("Select All Before Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2105 select_items.push_back (MenuElem (_("Select All Between Playhead and Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_between), false)));
2106 select_items.push_back (MenuElem (_("Select All Within Playhead and Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_between), true)));
2107 select_items.push_back (MenuElem (_("Select Range Between Playhead and Edit Point"), sigc::mem_fun(*this, &Editor::select_range_between)));
2109 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2113 Menu *cutnpaste_menu = manage (new Menu);
2114 MenuList& cutnpaste_items = cutnpaste_menu->items();
2115 cutnpaste_menu->set_name ("ArdourContextMenu");
2117 cutnpaste_items.push_back (MenuElem (_("Cut"), sigc::mem_fun(*this, &Editor::cut)));
2118 cutnpaste_items.push_back (MenuElem (_("Copy"), sigc::mem_fun(*this, &Editor::copy)));
2119 cutnpaste_items.push_back (MenuElem (_("Paste"), sigc::bind (sigc::mem_fun(*this, &Editor::paste), 1.0f)));
2121 cutnpaste_items.push_back (SeparatorElem());
2123 cutnpaste_items.push_back (MenuElem (_("Align"), sigc::bind (sigc::mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
2124 cutnpaste_items.push_back (MenuElem (_("Align Relative"), sigc::bind (sigc::mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
2126 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
2128 /* Adding new material */
2130 edit_items.push_back (SeparatorElem());
2131 edit_items.push_back (MenuElem (_("Insert Selected Region"), sigc::bind (sigc::mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
2132 edit_items.push_back (MenuElem (_("Insert Existing Media"), sigc::bind (sigc::mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
2136 Menu *nudge_menu = manage (new Menu());
2137 MenuList& nudge_items = nudge_menu->items();
2138 nudge_menu->set_name ("ArdourContextMenu");
2140 edit_items.push_back (SeparatorElem());
2141 nudge_items.push_back (MenuElem (_("Nudge Entire Track Forward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, true))));
2142 nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Forward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, true))));
2143 nudge_items.push_back (MenuElem (_("Nudge Entire Track Backward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, false))));
2144 nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Backward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, false))));
2146 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2150 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
2152 using namespace Menu_Helpers;
2156 Menu *play_menu = manage (new Menu);
2157 MenuList& play_items = play_menu->items();
2158 play_menu->set_name ("ArdourContextMenu");
2160 play_items.push_back (MenuElem (_("Play From Edit Point"), sigc::mem_fun(*this, &Editor::play_from_edit_point)));
2161 play_items.push_back (MenuElem (_("Play From Start"), sigc::mem_fun(*this, &Editor::play_from_start)));
2162 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2166 Menu *select_menu = manage (new Menu);
2167 MenuList& select_items = select_menu->items();
2168 select_menu->set_name ("ArdourContextMenu");
2170 select_items.push_back (MenuElem (_("Select All in Track"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2171 select_items.push_back (MenuElem (_("Select All"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all), Selection::Set)));
2172 select_items.push_back (MenuElem (_("Invert Selection in Track"), sigc::mem_fun(*this, &Editor::invert_selection_in_track)));
2173 select_items.push_back (MenuElem (_("Invert Selection"), sigc::mem_fun(*this, &Editor::invert_selection)));
2174 select_items.push_back (SeparatorElem());
2175 select_items.push_back (MenuElem (_("Select All After Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2176 select_items.push_back (MenuElem (_("Select All Before Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2177 select_items.push_back (MenuElem (_("Select All After Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2178 select_items.push_back (MenuElem (_("Select All Before Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2180 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2184 Menu *cutnpaste_menu = manage (new Menu);
2185 MenuList& cutnpaste_items = cutnpaste_menu->items();
2186 cutnpaste_menu->set_name ("ArdourContextMenu");
2188 cutnpaste_items.push_back (MenuElem (_("Cut"), sigc::mem_fun(*this, &Editor::cut)));
2189 cutnpaste_items.push_back (MenuElem (_("Copy"), sigc::mem_fun(*this, &Editor::copy)));
2190 cutnpaste_items.push_back (MenuElem (_("Paste"), sigc::bind (sigc::mem_fun(*this, &Editor::paste), 1.0f)));
2192 Menu *nudge_menu = manage (new Menu());
2193 MenuList& nudge_items = nudge_menu->items();
2194 nudge_menu->set_name ("ArdourContextMenu");
2196 edit_items.push_back (SeparatorElem());
2197 nudge_items.push_back (MenuElem (_("Nudge Entire Track Forward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, true))));
2198 nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Forward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, true))));
2199 nudge_items.push_back (MenuElem (_("Nudge Entire Track Backward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), false, false))));
2200 nudge_items.push_back (MenuElem (_("Nudge Track After Edit Point Backward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_track), true, false))));
2202 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2206 Editor::snap_type() const
2212 Editor::snap_mode() const
2218 Editor::set_snap_to (SnapType st)
2220 unsigned int snap_ind = (unsigned int)st;
2224 if (snap_ind > snap_type_strings.size() - 1) {
2226 _snap_type = (SnapType)snap_ind;
2229 string str = snap_type_strings[snap_ind];
2231 if (str != snap_type_selector.get_active_text()) {
2232 snap_type_selector.set_active_text (str);
2237 switch (_snap_type) {
2238 case SnapToBeatDiv32:
2239 case SnapToBeatDiv28:
2240 case SnapToBeatDiv24:
2241 case SnapToBeatDiv20:
2242 case SnapToBeatDiv16:
2243 case SnapToBeatDiv14:
2244 case SnapToBeatDiv12:
2245 case SnapToBeatDiv10:
2246 case SnapToBeatDiv8:
2247 case SnapToBeatDiv7:
2248 case SnapToBeatDiv6:
2249 case SnapToBeatDiv5:
2250 case SnapToBeatDiv4:
2251 case SnapToBeatDiv3:
2252 case SnapToBeatDiv2:
2253 compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames());
2254 update_tempo_based_rulers ();
2257 case SnapToRegionStart:
2258 case SnapToRegionEnd:
2259 case SnapToRegionSync:
2260 case SnapToRegionBoundary:
2261 build_region_boundary_cache ();
2269 SnapChanged (); /* EMIT SIGNAL */
2273 Editor::set_snap_mode (SnapMode mode)
2276 string str = snap_mode_strings[(int)mode];
2278 if (str != snap_mode_selector.get_active_text ()) {
2279 snap_mode_selector.set_active_text (str);
2285 Editor::set_edit_point_preference (EditPoint ep, bool force)
2287 bool changed = (_edit_point != ep);
2290 string str = edit_point_strings[(int)ep];
2292 if (str != edit_point_selector.get_active_text ()) {
2293 edit_point_selector.set_active_text (str);
2296 set_canvas_cursor ();
2298 if (!force && !changed) {
2302 const char* action=NULL;
2304 switch (_edit_point) {
2305 case EditAtPlayhead:
2306 action = "edit-at-playhead";
2308 case EditAtSelectedMarker:
2309 action = "edit-at-marker";
2312 action = "edit-at-mouse";
2316 Glib::RefPtr<Action> act = ActionManager::get_action ("Editor", action);
2318 Glib::RefPtr<RadioAction>::cast_dynamic(act)->set_active (true);
2322 bool in_track_canvas;
2324 if (!mouse_frame (foo, in_track_canvas)) {
2325 in_track_canvas = false;
2328 reset_canvas_action_sensitivity (in_track_canvas);
2334 Editor::set_state (const XMLNode& node, int /*version*/)
2336 const XMLProperty* prop;
2338 int x, y, xoff, yoff;
2341 if ((prop = node.property ("id")) != 0) {
2342 _id = prop->value ();
2345 g.base_width = default_width;
2346 g.base_height = default_height;
2352 if ((geometry = find_named_node (node, "geometry")) != 0) {
2356 if ((prop = geometry->property("x_size")) == 0) {
2357 prop = geometry->property ("x-size");
2360 g.base_width = atoi(prop->value());
2362 if ((prop = geometry->property("y_size")) == 0) {
2363 prop = geometry->property ("y-size");
2366 g.base_height = atoi(prop->value());
2369 if ((prop = geometry->property ("x_pos")) == 0) {
2370 prop = geometry->property ("x-pos");
2373 x = atoi (prop->value());
2376 if ((prop = geometry->property ("y_pos")) == 0) {
2377 prop = geometry->property ("y-pos");
2380 y = atoi (prop->value());
2383 if ((prop = geometry->property ("x_off")) == 0) {
2384 prop = geometry->property ("x-off");
2387 xoff = atoi (prop->value());
2389 if ((prop = geometry->property ("y_off")) == 0) {
2390 prop = geometry->property ("y-off");
2393 yoff = atoi (prop->value());
2397 set_default_size (g.base_width, g.base_height);
2400 if (_session && (prop = node.property ("playhead"))) {
2402 sscanf (prop->value().c_str(), "%" PRIi64, &pos);
2403 playhead_cursor->set_position (pos);
2405 playhead_cursor->set_position (0);
2408 if ((prop = node.property ("mixer-width"))) {
2409 editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
2412 if ((prop = node.property ("zoom-focus"))) {
2413 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2416 if ((prop = node.property ("zoom"))) {
2417 reset_zoom (PBD::atof (prop->value()));
2420 if ((prop = node.property ("snap-to"))) {
2421 set_snap_to ((SnapType) atoi (prop->value()));
2424 if ((prop = node.property ("snap-mode"))) {
2425 set_snap_mode ((SnapMode) atoi (prop->value()));
2428 if ((prop = node.property ("mouse-mode"))) {
2429 MouseMode m = str2mousemode(prop->value());
2430 set_mouse_mode (m, true);
2432 set_mouse_mode (MouseObject, true);
2435 if ((prop = node.property ("left-frame")) != 0){
2437 if (sscanf (prop->value().c_str(), "%" PRId64, &pos) == 1) {
2438 reset_x_origin (pos);
2442 if ((prop = node.property ("y-origin")) != 0) {
2443 reset_y_origin (atof (prop->value ()));
2446 if ((prop = node.property ("internal-edit"))) {
2447 bool yn = string_is_affirmative (prop->value());
2448 RefPtr<Action> act = ActionManager::get_action (X_("MouseMode"), X_("toggle-internal-edit"));
2450 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2451 tact->set_active (!yn);
2452 tact->set_active (yn);
2456 if ((prop = node.property ("join-object-range"))) {
2457 join_object_range_button.set_active (string_is_affirmative (prop->value ()));
2460 if ((prop = node.property ("edit-point"))) {
2461 set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point), true);
2464 if ((prop = node.property ("show-measures"))) {
2465 bool yn = string_is_affirmative (prop->value());
2466 _show_measures = !yn;
2467 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2469 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2470 /* do it twice to force the change */
2471 tact->set_active (!yn);
2472 tact->set_active (yn);
2476 if ((prop = node.property ("follow-playhead"))) {
2477 bool yn = string_is_affirmative (prop->value());
2478 set_follow_playhead (yn);
2479 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2481 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2482 if (tact->get_active() != yn) {
2483 tact->set_active (yn);
2488 if ((prop = node.property ("stationary-playhead"))) {
2489 bool yn = (prop->value() == "yes");
2490 set_stationary_playhead (yn);
2491 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-stationary-playhead"));
2493 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2494 if (tact->get_active() != yn) {
2495 tact->set_active (yn);
2500 if ((prop = node.property ("region-list-sort-type"))) {
2501 RegionListSortType st;
2502 _regions->reset_sort_type ((RegionListSortType) string_2_enum (prop->value(), st), true);
2505 if ((prop = node.property ("xfades-visible"))) {
2506 bool yn = string_is_affirmative (prop->value());
2507 _xfade_visibility = !yn;
2508 // set_xfade_visibility (yn);
2511 if ((prop = node.property ("show-editor-mixer"))) {
2513 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2516 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2517 bool yn = string_is_affirmative (prop->value());
2519 /* do it twice to force the change */
2521 tact->set_active (!yn);
2522 tact->set_active (yn);
2526 if ((prop = node.property ("show-editor-list"))) {
2528 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2532 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2533 bool yn = string_is_affirmative (prop->value());
2535 /* do it twice to force the change */
2537 tact->set_active (!yn);
2538 tact->set_active (yn);
2542 if ((prop = node.property (X_("editor-list-page")))) {
2543 the_notebook.set_current_page (atoi (prop->value ()));
2546 XMLNodeList children = node.children ();
2547 for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
2548 selection->set_state (**i, Stateful::current_state_version);
2555 Editor::get_state ()
2557 XMLNode* node = new XMLNode ("Editor");
2560 _id.print (buf, sizeof (buf));
2561 node->add_property ("id", buf);
2563 if (is_realized()) {
2564 Glib::RefPtr<Gdk::Window> win = get_window();
2566 int x, y, xoff, yoff, width, height;
2567 win->get_root_origin(x, y);
2568 win->get_position(xoff, yoff);
2569 win->get_size(width, height);
2571 XMLNode* geometry = new XMLNode ("geometry");
2573 snprintf(buf, sizeof(buf), "%d", width);
2574 geometry->add_property("x-size", string(buf));
2575 snprintf(buf, sizeof(buf), "%d", height);
2576 geometry->add_property("y-size", string(buf));
2577 snprintf(buf, sizeof(buf), "%d", x);
2578 geometry->add_property("x-pos", string(buf));
2579 snprintf(buf, sizeof(buf), "%d", y);
2580 geometry->add_property("y-pos", string(buf));
2581 snprintf(buf, sizeof(buf), "%d", xoff);
2582 geometry->add_property("x-off", string(buf));
2583 snprintf(buf, sizeof(buf), "%d", yoff);
2584 geometry->add_property("y-off", string(buf));
2585 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2586 geometry->add_property("edit-horizontal-pane-pos", string(buf));
2587 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&editor_summary_pane)->gobj()));
2588 geometry->add_property("edit-vertical-pane-pos", string(buf));
2590 node->add_child_nocopy (*geometry);
2593 maybe_add_mixer_strip_width (*node);
2595 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2596 node->add_property ("zoom-focus", buf);
2597 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2598 node->add_property ("zoom", buf);
2599 snprintf (buf, sizeof(buf), "%d", (int) _snap_type);
2600 node->add_property ("snap-to", buf);
2601 snprintf (buf, sizeof(buf), "%d", (int) _snap_mode);
2602 node->add_property ("snap-mode", buf);
2604 node->add_property ("edit-point", enum_2_string (_edit_point));
2606 snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame);
2607 node->add_property ("playhead", buf);
2608 snprintf (buf, sizeof (buf), "%" PRIi64, leftmost_frame);
2609 node->add_property ("left-frame", buf);
2610 snprintf (buf, sizeof (buf), "%f", vertical_adjustment.get_value ());
2611 node->add_property ("y-origin", buf);
2613 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2614 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2615 node->add_property ("stationary-playhead", _stationary_playhead ? "yes" : "no");
2616 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2617 node->add_property ("region-list-sort-type", enum_2_string (_regions->sort_type ()));
2618 node->add_property ("mouse-mode", enum2str(mouse_mode));
2619 node->add_property ("internal-edit", _internal_editing ? "yes" : "no");
2620 node->add_property ("join-object-range", join_object_range_button.get_active () ? "yes" : "no");
2622 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2624 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2625 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2628 act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2630 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2631 node->add_property (X_("show-editor-list"), tact->get_active() ? "yes" : "no");
2634 snprintf (buf, sizeof (buf), "%d", the_notebook.get_current_page ());
2635 node->add_property (X_("editor-list-page"), buf);
2637 node->add_child_nocopy (selection->get_state ());
2644 /** @param y y offset from the top of all trackviews.
2645 * @return pair: TimeAxisView that y is over, layer index.
2646 * TimeAxisView may be 0. Layer index is the layer number if the TimeAxisView is valid and is
2647 * in stacked region display mode, otherwise 0.
2649 std::pair<TimeAxisView *, layer_t>
2650 Editor::trackview_by_y_position (double y)
2652 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2654 std::pair<TimeAxisView*, int> const r = (*iter)->covers_y_position (y);
2660 return std::make_pair ( (TimeAxisView *) 0, 0);
2663 /** Snap a position to the grid, if appropriate, taking into account current
2664 * grid settings and also the state of any snap modifier keys that may be pressed.
2665 * @param start Position to snap.
2666 * @param event Event to get current key modifier information from, or 0.
2669 Editor::snap_to_with_modifier (nframes64_t& start, GdkEvent const * event, int32_t direction, bool for_mark)
2671 if (!_session || !event) {
2675 if (Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
2676 if (_snap_mode == SnapOff) {
2677 snap_to_internal (start, direction, for_mark);
2680 if (_snap_mode != SnapOff) {
2681 snap_to_internal (start, direction, for_mark);
2687 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
2689 if (!_session || _snap_mode == SnapOff) {
2693 snap_to_internal (start, direction, for_mark);
2697 Editor::timecode_snap_to_internal (nframes64_t& start, int32_t direction, bool /*for_mark*/)
2699 const nframes64_t one_timecode_second = (nframes64_t)(rint(_session->timecode_frames_per_second()) * _session->frames_per_timecode_frame());
2700 nframes64_t one_timecode_minute = (nframes64_t)(rint(_session->timecode_frames_per_second()) * _session->frames_per_timecode_frame() * 60);
2702 switch (_snap_type) {
2703 case SnapToTimecodeFrame:
2704 if (((direction == 0) && (fmod((double)start, (double)_session->frames_per_timecode_frame()) > (_session->frames_per_timecode_frame() / 2))) || (direction > 0)) {
2705 start = (nframes64_t) (ceil ((double) start / _session->frames_per_timecode_frame()) * _session->frames_per_timecode_frame());
2707 start = (nframes64_t) (floor ((double) start / _session->frames_per_timecode_frame()) * _session->frames_per_timecode_frame());
2711 case SnapToTimecodeSeconds:
2712 if (_session->timecode_offset_negative())
2714 start += _session->timecode_offset ();
2716 start -= _session->timecode_offset ();
2718 if (((direction == 0) && (start % one_timecode_second > one_timecode_second / 2)) || direction > 0) {
2719 start = (nframes64_t) ceil ((double) start / one_timecode_second) * one_timecode_second;
2721 start = (nframes64_t) floor ((double) start / one_timecode_second) * one_timecode_second;
2724 if (_session->timecode_offset_negative())
2726 start -= _session->timecode_offset ();
2728 start += _session->timecode_offset ();
2732 case SnapToTimecodeMinutes:
2733 if (_session->timecode_offset_negative())
2735 start += _session->timecode_offset ();
2737 start -= _session->timecode_offset ();
2739 if (((direction == 0) && (start % one_timecode_minute > one_timecode_minute / 2)) || direction > 0) {
2740 start = (nframes64_t) ceil ((double) start / one_timecode_minute) * one_timecode_minute;
2742 start = (nframes64_t) floor ((double) start / one_timecode_minute) * one_timecode_minute;
2744 if (_session->timecode_offset_negative())
2746 start -= _session->timecode_offset ();
2748 start += _session->timecode_offset ();
2752 fatal << "Editor::smpte_snap_to_internal() called with non-timecode snap type!" << endmsg;
2758 Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
2760 const nframes64_t one_second = _session->frame_rate();
2761 const nframes64_t one_minute = _session->frame_rate() * 60;
2762 nframes64_t presnap = start;
2766 switch (_snap_type) {
2767 case SnapToTimecodeFrame:
2768 case SnapToTimecodeSeconds:
2769 case SnapToTimecodeMinutes:
2770 return timecode_snap_to_internal (start, direction, for_mark);
2773 if (((direction == 0) && (start % (one_second/75) > (one_second/75) / 2)) || (direction > 0)) {
2774 start = (nframes64_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2776 start = (nframes64_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2781 if (((direction == 0) && (start % one_second > one_second / 2)) || (direction > 0)) {
2782 start = (nframes64_t) ceil ((double) start / one_second) * one_second;
2784 start = (nframes64_t) floor ((double) start / one_second) * one_second;
2789 if (((direction == 0) && (start % one_minute > one_minute / 2)) || (direction > 0)) {
2790 start = (nframes64_t) ceil ((double) start / one_minute) * one_minute;
2792 start = (nframes64_t) floor ((double) start / one_minute) * one_minute;
2797 start = _session->tempo_map().round_to_bar (start, direction);
2801 start = _session->tempo_map().round_to_beat (start, direction);
2804 case SnapToBeatDiv32:
2805 start = _session->tempo_map().round_to_beat_subdivision (start, 32, direction);
2807 case SnapToBeatDiv28:
2808 start = _session->tempo_map().round_to_beat_subdivision (start, 28, direction);
2810 case SnapToBeatDiv24:
2811 start = _session->tempo_map().round_to_beat_subdivision (start, 24, direction);
2813 case SnapToBeatDiv20:
2814 start = _session->tempo_map().round_to_beat_subdivision (start, 20, direction);
2816 case SnapToBeatDiv16:
2817 start = _session->tempo_map().round_to_beat_subdivision (start, 16, direction);
2819 case SnapToBeatDiv14:
2820 start = _session->tempo_map().round_to_beat_subdivision (start, 14, direction);
2822 case SnapToBeatDiv12:
2823 start = _session->tempo_map().round_to_beat_subdivision (start, 12, direction);
2825 case SnapToBeatDiv10:
2826 start = _session->tempo_map().round_to_beat_subdivision (start, 10, direction);
2828 case SnapToBeatDiv8:
2829 start = _session->tempo_map().round_to_beat_subdivision (start, 8, direction);
2831 case SnapToBeatDiv7:
2832 start = _session->tempo_map().round_to_beat_subdivision (start, 7, direction);
2834 case SnapToBeatDiv6:
2835 start = _session->tempo_map().round_to_beat_subdivision (start, 6, direction);
2837 case SnapToBeatDiv5:
2838 start = _session->tempo_map().round_to_beat_subdivision (start, 5, direction);
2840 case SnapToBeatDiv4:
2841 start = _session->tempo_map().round_to_beat_subdivision (start, 4, direction);
2843 case SnapToBeatDiv3:
2844 start = _session->tempo_map().round_to_beat_subdivision (start, 3, direction);
2846 case SnapToBeatDiv2:
2847 start = _session->tempo_map().round_to_beat_subdivision (start, 2, direction);
2855 _session->locations()->marks_either_side (start, before, after);
2857 if (before == max_frames) {
2859 } else if (after == max_frames) {
2861 } else if (before != max_frames && after != max_frames) {
2862 /* have before and after */
2863 if ((start - before) < (after - start)) {
2872 case SnapToRegionStart:
2873 case SnapToRegionEnd:
2874 case SnapToRegionSync:
2875 case SnapToRegionBoundary:
2876 if (!region_boundary_cache.empty()) {
2878 vector<nframes64_t>::iterator prev = region_boundary_cache.end ();
2879 vector<nframes64_t>::iterator next = region_boundary_cache.end ();
2881 if (direction > 0) {
2882 next = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2884 next = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2887 if (next != region_boundary_cache.begin ()) {
2892 nframes64_t const p = (prev == region_boundary_cache.end()) ? region_boundary_cache.front () : *prev;
2893 nframes64_t const n = (next == region_boundary_cache.end()) ? region_boundary_cache.back () : *next;
2895 if (start > (p + n) / 2) {
2904 switch (_snap_mode) {
2910 if (presnap > start) {
2911 if (presnap > (start + unit_to_frame(snap_threshold))) {
2915 } else if (presnap < start) {
2916 if (presnap < (start - unit_to_frame(snap_threshold))) {
2922 /* handled at entry */
2930 Editor::setup_toolbar ()
2934 /* Mode Buttons (tool selection) */
2936 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2937 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2938 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2939 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2940 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2941 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2942 // internal_edit_button.set_relief(Gtk::RELIEF_NONE);
2943 join_object_range_button.set_relief(Gtk::RELIEF_NONE);
2945 HBox* mode_box = manage(new HBox);
2946 mode_box->set_border_width (2);
2947 mode_box->set_spacing(4);
2949 /* table containing mode buttons */
2951 HBox* mouse_mode_button_box = manage (new HBox ());
2953 if (Profile->get_sae()) {
2954 mouse_mode_button_box->pack_start (mouse_move_button);
2956 mouse_mode_button_box->pack_start (mouse_move_button);
2957 mouse_mode_button_box->pack_start (join_object_range_button);
2958 mouse_mode_button_box->pack_start (mouse_select_button);
2961 mouse_mode_button_box->pack_start (mouse_zoom_button);
2963 if (!Profile->get_sae()) {
2964 mouse_mode_button_box->pack_start (mouse_gain_button);
2967 mouse_mode_button_box->pack_start (mouse_timefx_button);
2968 mouse_mode_button_box->pack_start (mouse_audition_button);
2969 mouse_mode_button_box->pack_start (internal_edit_button);
2971 vector<string> edit_mode_strings;
2972 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2973 if (!Profile->get_sae()) {
2974 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2976 edit_mode_strings.push_back (edit_mode_to_string (Lock));
2978 edit_mode_selector.set_name ("EditModeSelector");
2979 set_popdown_strings (edit_mode_selector, edit_mode_strings, true);
2980 edit_mode_selector.signal_changed().connect (sigc::mem_fun(*this, &Editor::edit_mode_selection_done));
2982 mode_box->pack_start (edit_mode_selector);
2983 mode_box->pack_start (*mouse_mode_button_box);
2985 _mouse_mode_tearoff = manage (new TearOff (*mode_box));
2986 _mouse_mode_tearoff->set_name ("MouseModeBase");
2987 _mouse_mode_tearoff->tearoff_window().signal_key_press_event().connect (sigc::bind (sigc::ptr_fun (relay_key_press), &_mouse_mode_tearoff->tearoff_window()), false);
2989 if (Profile->get_sae()) {
2990 _mouse_mode_tearoff->set_can_be_torn_off (false);
2993 _mouse_mode_tearoff->Detach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2994 &_mouse_mode_tearoff->tearoff_window()));
2995 _mouse_mode_tearoff->Attach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2996 &_mouse_mode_tearoff->tearoff_window(), 1));
2997 _mouse_mode_tearoff->Hidden.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2998 &_mouse_mode_tearoff->tearoff_window()));
2999 _mouse_mode_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3000 &_mouse_mode_tearoff->tearoff_window(), 1));
3002 mouse_move_button.set_mode (false);
3003 mouse_select_button.set_mode (false);
3004 mouse_gain_button.set_mode (false);
3005 mouse_zoom_button.set_mode (false);
3006 mouse_timefx_button.set_mode (false);
3007 mouse_audition_button.set_mode (false);
3008 join_object_range_button.set_mode (false);
3010 mouse_move_button.set_name ("MouseModeButton");
3011 mouse_select_button.set_name ("MouseModeButton");
3012 mouse_gain_button.set_name ("MouseModeButton");
3013 mouse_zoom_button.set_name ("MouseModeButton");
3014 mouse_timefx_button.set_name ("MouseModeButton");
3015 mouse_audition_button.set_name ("MouseModeButton");
3016 internal_edit_button.set_name ("MouseModeButton");
3017 join_object_range_button.set_name ("MouseModeButton");
3019 mouse_move_button.unset_flags (CAN_FOCUS);
3020 mouse_select_button.unset_flags (CAN_FOCUS);
3021 mouse_gain_button.unset_flags (CAN_FOCUS);
3022 mouse_zoom_button.unset_flags (CAN_FOCUS);
3023 mouse_timefx_button.unset_flags (CAN_FOCUS);
3024 mouse_audition_button.unset_flags (CAN_FOCUS);
3025 internal_edit_button.unset_flags (CAN_FOCUS);
3026 join_object_range_button.unset_flags (CAN_FOCUS);
3030 _zoom_box.set_spacing (1);
3031 _zoom_box.set_border_width (0);
3033 zoom_in_button.set_name ("EditorTimeButton");
3034 zoom_in_button.set_image (*(manage (new Image (Stock::ZOOM_IN, Gtk::ICON_SIZE_MENU))));
3035 zoom_in_button.signal_clicked().connect (sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_step), false));
3037 zoom_out_button.set_name ("EditorTimeButton");
3038 zoom_out_button.set_image (*(manage (new Image (Stock::ZOOM_OUT, Gtk::ICON_SIZE_MENU))));
3039 zoom_out_button.signal_clicked().connect (sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_step), true));
3041 zoom_out_full_button.set_name ("EditorTimeButton");
3042 zoom_out_full_button.set_image (*(manage (new Image (Stock::ZOOM_100, Gtk::ICON_SIZE_MENU))));
3043 zoom_out_full_button.signal_clicked().connect (sigc::mem_fun(*this, &Editor::temporal_zoom_session));
3045 zoom_focus_selector.set_name ("ZoomFocusSelector");
3046 set_popdown_strings (zoom_focus_selector, zoom_focus_strings, true);
3047 zoom_focus_selector.signal_changed().connect (sigc::mem_fun(*this, &Editor::zoom_focus_selection_done));
3049 _zoom_box.pack_start (zoom_out_button, false, false);
3050 _zoom_box.pack_start (zoom_in_button, false, false);
3051 _zoom_box.pack_start (zoom_out_full_button, false, false);
3053 _zoom_box.pack_start (zoom_focus_selector);
3055 /* Track zoom buttons */
3056 tav_expand_button.set_name ("TrackHeightButton");
3057 tav_expand_button.set_size_request(-1,20);
3058 tav_expand_button.add (*(manage (new Image (::get_icon("tav_exp")))));
3059 tav_expand_button.signal_clicked().connect (sigc::bind (sigc::mem_fun(*this, &Editor::tav_zoom_step), true));
3061 tav_shrink_button.set_name ("TrackHeightButton");
3062 tav_shrink_button.set_size_request(-1,20);
3063 tav_shrink_button.add (*(manage (new Image (::get_icon("tav_shrink")))));
3064 tav_shrink_button.signal_clicked().connect (sigc::bind (sigc::mem_fun(*this, &Editor::tav_zoom_step), false));
3066 _zoom_box.pack_start (tav_shrink_button);
3067 _zoom_box.pack_start (tav_expand_button);
3069 _zoom_tearoff = manage (new TearOff (_zoom_box));
3071 _zoom_tearoff->Detach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3072 &_zoom_tearoff->tearoff_window()));
3073 _zoom_tearoff->Attach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3074 &_zoom_tearoff->tearoff_window(), 0));
3075 _zoom_tearoff->Hidden.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3076 &_zoom_tearoff->tearoff_window()));
3077 _zoom_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3078 &_zoom_tearoff->tearoff_window(), 0));
3080 snap_box.set_spacing (1);
3081 snap_box.set_border_width (2);
3083 snap_type_selector.set_name ("SnapTypeSelector");
3084 set_popdown_strings (snap_type_selector, snap_type_strings, true);
3085 snap_type_selector.signal_changed().connect (sigc::mem_fun(*this, &Editor::snap_type_selection_done));
3087 snap_mode_selector.set_name ("SnapModeSelector");
3088 set_popdown_strings (snap_mode_selector, snap_mode_strings, true);
3089 snap_mode_selector.signal_changed().connect (sigc::mem_fun(*this, &Editor::snap_mode_selection_done));
3091 edit_point_selector.set_name ("EditPointSelector");
3092 set_popdown_strings (edit_point_selector, edit_point_strings, true);
3093 edit_point_selector.signal_changed().connect (sigc::mem_fun(*this, &Editor::edit_point_selection_done));
3095 snap_box.pack_start (snap_mode_selector, false, false);
3096 snap_box.pack_start (snap_type_selector, false, false);
3097 snap_box.pack_start (edit_point_selector, false, false);
3101 HBox *nudge_box = manage (new HBox);
3102 nudge_box->set_spacing(1);
3103 nudge_box->set_border_width (2);
3105 nudge_forward_button.signal_button_release_event().connect (sigc::mem_fun(*this, &Editor::nudge_forward_release), false);
3106 nudge_backward_button.signal_button_release_event().connect (sigc::mem_fun(*this, &Editor::nudge_backward_release), false);
3108 nudge_box->pack_start (nudge_backward_button, false, false);
3109 nudge_box->pack_start (nudge_forward_button, false, false);
3110 nudge_box->pack_start (nudge_clock, false, false);
3113 /* Pack everything in... */
3115 HBox* hbox = manage (new HBox);
3116 hbox->set_spacing(10);
3118 _tools_tearoff = manage (new TearOff (*hbox));
3119 _tools_tearoff->set_name ("MouseModeBase");
3120 _tools_tearoff->tearoff_window().signal_key_press_event().connect (sigc::bind (sigc::ptr_fun (relay_key_press), &_tools_tearoff->tearoff_window()), false);
3122 if (Profile->get_sae()) {
3123 _tools_tearoff->set_can_be_torn_off (false);
3126 _tools_tearoff->Detach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3127 &_tools_tearoff->tearoff_window()));
3128 _tools_tearoff->Attach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3129 &_tools_tearoff->tearoff_window(), 0));
3130 _tools_tearoff->Hidden.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3131 &_tools_tearoff->tearoff_window()));
3132 _tools_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3133 &_tools_tearoff->tearoff_window(), 0));
3135 toolbar_hbox.set_spacing (10);
3136 toolbar_hbox.set_border_width (1);
3138 toolbar_hbox.pack_start (*_mouse_mode_tearoff, false, false);
3139 toolbar_hbox.pack_start (*_zoom_tearoff, false, false);
3140 toolbar_hbox.pack_start (*_tools_tearoff, false, false);
3142 hbox->pack_start (snap_box, false, false);
3143 hbox->pack_start (*nudge_box, false, false);
3144 hbox->pack_start (panic_box, false, false);
3148 toolbar_base.set_name ("ToolBarBase");
3149 toolbar_base.add (toolbar_hbox);
3151 toolbar_frame.set_shadow_type (SHADOW_OUT);
3152 toolbar_frame.set_name ("BaseFrame");
3153 toolbar_frame.add (toolbar_base);
3157 Editor::setup_tooltips ()
3159 ARDOUR_UI::instance()->set_tip (mouse_move_button, _("Select/Move Objects"));
3160 ARDOUR_UI::instance()->set_tip (mouse_gain_button, _("Draw Gain Automation"));
3161 ARDOUR_UI::instance()->set_tip (mouse_zoom_button, _("Select Zoom Range"));
3162 ARDOUR_UI::instance()->set_tip (mouse_timefx_button, _("Stretch/Shrink Regions and MIDI Notes"));
3163 ARDOUR_UI::instance()->set_tip (mouse_audition_button, _("Listen to Specific Regions"));
3164 ARDOUR_UI::instance()->set_tip (join_object_range_button, _("Select/Move Objects or Ranges"));
3165 ARDOUR_UI::instance()->set_tip (internal_edit_button, _("Edit Region Contents (e.g. notes)"));
3166 ARDOUR_UI::instance()->set_tip (*_group_tabs, _("Groups: context-click for possible operations"));
3167 ARDOUR_UI::instance()->set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
3168 ARDOUR_UI::instance()->set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
3169 ARDOUR_UI::instance()->set_tip (zoom_in_button, _("Zoom In"));
3170 ARDOUR_UI::instance()->set_tip (zoom_out_button, _("Zoom Out"));
3171 ARDOUR_UI::instance()->set_tip (zoom_out_full_button, _("Zoom to Session"));
3172 ARDOUR_UI::instance()->set_tip (zoom_focus_selector, _("Zoom focus"));
3173 ARDOUR_UI::instance()->set_tip (tav_expand_button, _("Expand Tracks"));
3174 ARDOUR_UI::instance()->set_tip (tav_shrink_button, _("Shrink Tracks"));
3175 ARDOUR_UI::instance()->set_tip (snap_type_selector, _("Snap/Grid Units"));
3176 ARDOUR_UI::instance()->set_tip (snap_mode_selector, _("Snap/Grid Mode"));
3177 ARDOUR_UI::instance()->set_tip (edit_point_selector, _("Edit point"));
3178 ARDOUR_UI::instance()->set_tip (midi_sound_notes, _("Sound Notes"));
3179 ARDOUR_UI::instance()->set_tip (midi_panic_button, _("Send note off and reset controller messages on all MIDI channels"));
3180 ARDOUR_UI::instance()->set_tip (edit_mode_selector, _("Edit Mode"));
3184 Editor::midi_panic ()
3186 cerr << "MIDI panic\n";
3189 _session->midi_panic();
3194 Editor::setup_midi_toolbar ()
3198 /* Midi sound notes */
3199 midi_sound_notes.add (*(manage (new Image (::get_icon("midi_sound_notes")))));
3200 midi_sound_notes.set_relief(Gtk::RELIEF_NONE);
3201 midi_sound_notes.unset_flags (CAN_FOCUS);
3205 act = ActionManager::get_action (X_("MIDI"), X_("panic"));
3206 midi_panic_button.set_name("MidiPanicButton");
3207 act->connect_proxy (midi_panic_button);
3209 panic_box.pack_start (midi_sound_notes , true, true);
3210 panic_box.pack_start (midi_panic_button, true, true);
3214 Editor::convert_drop_to_paths (
3215 vector<ustring>& paths,
3216 const RefPtr<Gdk::DragContext>& /*context*/,
3219 const SelectionData& data,
3223 if (_session == 0) {
3227 vector<ustring> uris = data.get_uris();
3231 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
3232 are actually URI lists. So do it by hand.
3235 if (data.get_target() != "text/plain") {
3239 /* Parse the "uri-list" format that Nautilus provides,
3240 where each pathname is delimited by \r\n.
3242 THERE MAY BE NO NULL TERMINATING CHAR!!!
3245 ustring txt = data.get_text();
3249 p = (const char *) malloc (txt.length() + 1);
3250 txt.copy ((char *) p, txt.length(), 0);
3251 ((char*)p)[txt.length()] = '\0';
3257 while (g_ascii_isspace (*p))
3261 while (*q && (*q != '\n') && (*q != '\r')) {
3268 while (q > p && g_ascii_isspace (*q))
3273 uris.push_back (ustring (p, q - p + 1));
3277 p = strchr (p, '\n');
3289 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
3291 if ((*i).substr (0,7) == "file://") {
3294 PBD::url_decode (p);
3296 // scan forward past three slashes
3298 ustring::size_type slashcnt = 0;
3299 ustring::size_type n = 0;
3300 ustring::iterator x = p.begin();
3302 while (slashcnt < 3 && x != p.end()) {
3305 } else if (slashcnt == 3) {
3312 if (slashcnt != 3 || x == p.end()) {
3313 error << _("malformed URL passed to drag-n-drop code") << endmsg;
3317 paths.push_back (p.substr (n - 1));
3325 Editor::new_tempo_section ()
3331 Editor::map_transport_state ()
3333 ENSURE_GUI_THREAD (*this, &Editor::map_transport_state)
3335 if (_session && _session->transport_stopped()) {
3336 have_pending_keyboard_selection = false;
3339 update_loop_range_view (true);
3344 Editor::State::State (PublicEditor const * e)
3346 selection = new Selection (e);
3349 Editor::State::~State ()
3355 Editor::begin_reversible_command (string name)
3358 _session->begin_reversible_command (name);
3363 Editor::commit_reversible_command ()
3366 _session->commit_reversible_command ();
3371 Editor::set_route_group_solo (Route& route, bool yn)
3373 RouteGroup *route_group;
3375 if ((route_group = route.route_group()) != 0) {
3376 route_group->apply (&Route::set_solo, yn, this);
3378 route.set_solo (yn, this);
3383 Editor::set_route_group_mute (Route& route, bool yn)
3385 RouteGroup *route_group = 0;
3387 if ((route_group = route.route_group()) != 0) {
3388 route_group->apply (&Route::set_mute, yn, this);
3390 route.set_mute (yn, this);
3395 Editor::history_changed ()
3399 if (undo_action && _session) {
3400 if (_session->undo_depth() == 0) {
3403 label = string_compose(_("Undo (%1)"), _session->next_undo());
3405 undo_action->property_label() = label;
3408 if (redo_action && _session) {
3409 if (_session->redo_depth() == 0) {
3412 label = string_compose(_("Redo (%1)"), _session->next_redo());
3414 redo_action->property_label() = label;
3419 Editor::duplicate_dialog (bool with_dialog)
3423 if (mouse_mode == MouseRange) {
3424 if (selection->time.length() == 0) {
3430 get_regions_for_action (rs);
3432 if (mouse_mode != MouseRange) {
3441 ArdourDialog win (_("Duplicate"));
3442 Label label (_("Number of duplications:"));
3443 Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
3444 SpinButton spinner (adjustment, 0.0, 1);
3447 win.get_vbox()->set_spacing (12);
3448 win.get_vbox()->pack_start (hbox);
3449 hbox.set_border_width (6);
3450 hbox.pack_start (label, PACK_EXPAND_PADDING, 12);
3452 /* dialogs have ::add_action_widget() but that puts the spinner in the wrong
3453 place, visually. so do this by hand.
3456 hbox.pack_start (spinner, PACK_EXPAND_PADDING, 12);
3457 spinner.signal_activate().connect (sigc::bind (sigc::mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
3458 spinner.grab_focus();
3464 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3465 win.add_button (_("Duplicate"), RESPONSE_ACCEPT);
3466 win.set_default_response (RESPONSE_ACCEPT);
3468 win.set_position (WIN_POS_MOUSE);
3470 spinner.grab_focus ();
3472 switch (win.run ()) {
3473 case RESPONSE_ACCEPT:
3479 times = adjustment.get_value();
3482 if (mouse_mode == MouseRange) {
3483 duplicate_selection (times);
3485 duplicate_some_regions (rs, times);
3490 Editor::show_verbose_canvas_cursor ()
3492 verbose_canvas_cursor->raise_to_top();
3493 verbose_canvas_cursor->show();
3494 verbose_cursor_visible = true;
3498 Editor::hide_verbose_canvas_cursor ()
3500 verbose_canvas_cursor->hide();
3501 verbose_cursor_visible = false;
3505 Editor::clamp_verbose_cursor_x (double x)
3510 x = min (_canvas_width - 200.0, x);
3516 Editor::clamp_verbose_cursor_y (double y)
3518 if (y < canvas_timebars_vsize) {
3519 y = canvas_timebars_vsize;
3521 y = min (_canvas_height - 50, y);
3527 Editor::show_verbose_canvas_cursor_with (const string & txt)
3529 verbose_canvas_cursor->property_text() = txt.c_str();
3534 track_canvas->get_pointer (x, y);
3535 track_canvas->window_to_world (x, y, wx, wy);
3537 /* don't get too close to the edge */
3538 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (wx);
3539 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (wy);
3541 show_verbose_canvas_cursor ();
3545 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3547 verbose_canvas_cursor->property_text() = txt.c_str();
3548 /* don't get too close to the edge */
3549 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (x);
3550 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (y);
3554 Editor::set_verbose_canvas_cursor_text (const string & txt)
3556 verbose_canvas_cursor->property_text() = txt.c_str();
3560 Editor::set_edit_mode (EditMode m)
3562 Config->set_edit_mode (m);
3566 Editor::cycle_edit_mode ()
3568 switch (Config->get_edit_mode()) {
3570 if (Profile->get_sae()) {
3571 Config->set_edit_mode (Lock);
3573 Config->set_edit_mode (Splice);
3577 Config->set_edit_mode (Lock);
3580 Config->set_edit_mode (Slide);
3586 Editor::edit_mode_selection_done ()
3588 Config->set_edit_mode (string_to_edit_mode (edit_mode_selector.get_active_text ()));
3592 Editor::snap_type_selection_done ()
3594 string choice = snap_type_selector.get_active_text();
3595 SnapType snaptype = SnapToBeat;
3597 if (choice == _("Beats/2")) {
3598 snaptype = SnapToBeatDiv2;
3599 } else if (choice == _("Beats/3")) {
3600 snaptype = SnapToBeatDiv3;
3601 } else if (choice == _("Beats/4")) {
3602 snaptype = SnapToBeatDiv4;
3603 } else if (choice == _("Beats/5")) {
3604 snaptype = SnapToBeatDiv5;
3605 } else if (choice == _("Beats/6")) {
3606 snaptype = SnapToBeatDiv6;
3607 } else if (choice == _("Beats/7")) {
3608 snaptype = SnapToBeatDiv7;
3609 } else if (choice == _("Beats/8")) {
3610 snaptype = SnapToBeatDiv8;
3611 } else if (choice == _("Beats/10")) {
3612 snaptype = SnapToBeatDiv10;
3613 } else if (choice == _("Beats/12")) {
3614 snaptype = SnapToBeatDiv12;
3615 } else if (choice == _("Beats/14")) {
3616 snaptype = SnapToBeatDiv14;
3617 } else if (choice == _("Beats/16")) {
3618 snaptype = SnapToBeatDiv16;
3619 } else if (choice == _("Beats/20")) {
3620 snaptype = SnapToBeatDiv20;
3621 } else if (choice == _("Beats/24")) {
3622 snaptype = SnapToBeatDiv24;
3623 } else if (choice == _("Beats/28")) {
3624 snaptype = SnapToBeatDiv28;
3625 } else if (choice == _("Beats/32")) {
3626 snaptype = SnapToBeatDiv32;
3627 } else if (choice == _("Beats")) {
3628 snaptype = SnapToBeat;
3629 } else if (choice == _("Bars")) {
3630 snaptype = SnapToBar;
3631 } else if (choice == _("Marks")) {
3632 snaptype = SnapToMark;
3633 } else if (choice == _("Region starts")) {
3634 snaptype = SnapToRegionStart;
3635 } else if (choice == _("Region ends")) {
3636 snaptype = SnapToRegionEnd;
3637 } else if (choice == _("Region bounds")) {
3638 snaptype = SnapToRegionBoundary;
3639 } else if (choice == _("Region syncs")) {
3640 snaptype = SnapToRegionSync;
3641 } else if (choice == _("CD Frames")) {
3642 snaptype = SnapToCDFrame;
3643 } else if (choice == _("Timecode Frames")) {
3644 snaptype = SnapToTimecodeFrame;
3645 } else if (choice == _("Timecode Seconds")) {
3646 snaptype = SnapToTimecodeSeconds;
3647 } else if (choice == _("Timecode Minutes")) {
3648 snaptype = SnapToTimecodeMinutes;
3649 } else if (choice == _("Seconds")) {
3650 snaptype = SnapToSeconds;
3651 } else if (choice == _("Minutes")) {
3652 snaptype = SnapToMinutes;
3655 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3657 ract->set_active ();
3662 Editor::snap_mode_selection_done ()
3664 string choice = snap_mode_selector.get_active_text();
3665 SnapMode mode = SnapNormal;
3667 if (choice == _("No Grid")) {
3669 } else if (choice == _("Grid")) {
3671 } else if (choice == _("Magnetic")) {
3672 mode = SnapMagnetic;
3675 RefPtr<RadioAction> ract = snap_mode_action (mode);
3678 ract->set_active (true);
3683 Editor::cycle_edit_point (bool with_marker)
3685 switch (_edit_point) {
3687 set_edit_point_preference (EditAtPlayhead);
3689 case EditAtPlayhead:
3691 set_edit_point_preference (EditAtSelectedMarker);
3693 set_edit_point_preference (EditAtMouse);
3696 case EditAtSelectedMarker:
3697 set_edit_point_preference (EditAtMouse);
3703 Editor::edit_point_selection_done ()
3705 string choice = edit_point_selector.get_active_text();
3706 EditPoint ep = EditAtSelectedMarker;
3708 if (choice == _("Marker")) {
3709 set_edit_point_preference (EditAtSelectedMarker);
3710 } else if (choice == _("Playhead")) {
3711 set_edit_point_preference (EditAtPlayhead);
3713 set_edit_point_preference (EditAtMouse);
3716 RefPtr<RadioAction> ract = edit_point_action (ep);
3719 ract->set_active (true);
3724 Editor::zoom_focus_selection_done ()
3726 string choice = zoom_focus_selector.get_active_text();
3727 ZoomFocus focus_type = ZoomFocusLeft;
3729 if (choice == _("Left")) {
3730 focus_type = ZoomFocusLeft;
3731 } else if (choice == _("Right")) {
3732 focus_type = ZoomFocusRight;
3733 } else if (choice == _("Center")) {
3734 focus_type = ZoomFocusCenter;
3735 } else if (choice == _("Playhead")) {
3736 focus_type = ZoomFocusPlayhead;
3737 } else if (choice == _("Mouse")) {
3738 focus_type = ZoomFocusMouse;
3739 } else if (choice == _("Edit point")) {
3740 focus_type = ZoomFocusEdit;
3743 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3746 ract->set_active ();
3751 Editor::edit_controls_button_release (GdkEventButton* ev)
3753 if (Keyboard::is_context_menu_event (ev)) {
3754 ARDOUR_UI::instance()->add_route (this);
3760 Editor::mouse_select_button_release (GdkEventButton* ev)
3762 /* this handles just right-clicks */
3764 if (ev->button != 3) {
3772 Editor::set_zoom_focus (ZoomFocus f)
3774 string str = zoom_focus_strings[(int)f];
3776 if (str != zoom_focus_selector.get_active_text()) {
3777 zoom_focus_selector.set_active_text (str);
3780 if (zoom_focus != f) {
3783 ZoomFocusChanged (); /* EMIT_SIGNAL */
3790 Editor::ensure_float (Window& win)
3792 win.set_transient_for (*this);
3796 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3798 /* recover or initialize pane positions. do this here rather than earlier because
3799 we don't want the positions to change the child allocations, which they seem to do.
3805 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3817 width = default_width;
3818 height = default_height;
3820 if ((geometry = find_named_node (*node, "geometry")) != 0) {
3822 prop = geometry->property ("x-size");
3824 width = atoi (prop->value());
3826 prop = geometry->property ("y-size");
3828 height = atoi (prop->value());
3832 if (which == static_cast<Paned*> (&edit_pane)) {
3834 if (done & Horizontal) {
3838 if (!geometry || (prop = geometry->property ("edit-horizontal-pane-pos")) == 0) {
3839 /* initial allocation is 90% to canvas, 10% to notebook */
3840 pos = (int) floor (alloc.get_width() * 0.90f);
3841 snprintf (buf, sizeof(buf), "%d", pos);
3843 pos = atoi (prop->value());
3846 if (GTK_WIDGET(edit_pane.gobj())->allocation.width > pos) {
3847 edit_pane.set_position (pos);
3848 pre_maximal_horizontal_pane_position = pos;
3851 done = (Pane) (done | Horizontal);
3853 } else if (which == static_cast<Paned*> (&editor_summary_pane)) {
3855 if (done & Vertical) {
3859 if (!geometry || (prop = geometry->property ("edit-vertical-pane-pos")) == 0) {
3860 /* initial allocation is 90% to canvas, 10% to summary */
3861 pos = (int) floor (alloc.get_height() * 0.90f);
3862 snprintf (buf, sizeof(buf), "%d", pos);
3864 pos = atoi (prop->value());
3867 if (GTK_WIDGET(editor_summary_pane.gobj())->allocation.height > pos) {
3868 editor_summary_pane.set_position (pos);
3869 pre_maximal_vertical_pane_position = pos;
3872 done = (Pane) (done | Vertical);
3877 Editor::detach_tearoff (Box* /*b*/, Window* /*w*/)
3879 if (_tools_tearoff->torn_off() && _mouse_mode_tearoff->torn_off()) {
3880 top_hbox.remove (toolbar_frame);
3885 Editor::reattach_tearoff (Box* /*b*/, Window* /*w*/, int32_t /*n*/)
3887 if (toolbar_frame.get_parent() == 0) {
3888 top_hbox.pack_end (toolbar_frame);
3893 Editor::set_show_measures (bool yn)
3895 if (_show_measures != yn) {
3898 if ((_show_measures = yn) == true) {
3900 tempo_lines->show();
3908 Editor::toggle_follow_playhead ()
3910 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3912 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3913 set_follow_playhead (tact->get_active());
3918 Editor::set_follow_playhead (bool yn)
3920 if (_follow_playhead != yn) {
3921 if ((_follow_playhead = yn) == true) {
3923 reset_x_origin_to_follow_playhead ();
3930 Editor::toggle_stationary_playhead ()
3932 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-stationary-playhead"));
3934 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3935 set_stationary_playhead (tact->get_active());
3940 Editor::set_stationary_playhead (bool yn)
3942 if (_stationary_playhead != yn) {
3943 if ((_stationary_playhead = yn) == true) {
3945 // FIXME need a 3.0 equivalent of this 2.X call
3946 // update_current_screen ();
3953 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
3955 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3957 xfade->set_active (!xfade->active());
3962 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
3964 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3966 xfade->set_follow_overlap (!xfade->following_overlap());
3971 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
3973 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3979 CrossfadeEditor cew (_session, xfade, xfade->fade_in().get_min_y(), 1.0);
3983 switch (cew.run ()) {
3984 case RESPONSE_ACCEPT:
3991 PropertyChange all_crossfade_properties;
3992 all_crossfade_properties.add (ARDOUR::Properties::active);
3993 all_crossfade_properties.add (ARDOUR::Properties::follow_overlap);
3994 xfade->PropertyChanged (all_crossfade_properties);
3998 Editor::playlist_selector () const
4000 return *_playlist_selector;
4004 Editor::get_grid_type_as_beats (bool& success, nframes64_t position)
4008 switch (_snap_type) {
4013 case SnapToBeatDiv32:
4016 case SnapToBeatDiv28:
4019 case SnapToBeatDiv24:
4022 case SnapToBeatDiv20:
4025 case SnapToBeatDiv16:
4028 case SnapToBeatDiv14:
4031 case SnapToBeatDiv12:
4034 case SnapToBeatDiv10:
4037 case SnapToBeatDiv8:
4040 case SnapToBeatDiv7:
4043 case SnapToBeatDiv6:
4046 case SnapToBeatDiv5:
4049 case SnapToBeatDiv4:
4052 case SnapToBeatDiv3:
4055 case SnapToBeatDiv2:
4061 return _session->tempo_map().meter_at (position).beats_per_bar();
4066 case SnapToTimecodeFrame:
4067 case SnapToTimecodeSeconds:
4068 case SnapToTimecodeMinutes:
4071 case SnapToRegionStart:
4072 case SnapToRegionEnd:
4073 case SnapToRegionSync:
4074 case SnapToRegionBoundary:
4084 Editor::get_nudge_distance (nframes64_t pos, nframes64_t& next)
4088 ret = nudge_clock.current_duration (pos);
4089 next = ret + 1; /* XXXX fix me */
4095 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
4097 ArdourDialog dialog (_("Playlist Deletion"));
4098 Label label (string_compose (_("Playlist %1 is currently unused.\n"
4099 "If left alone, no audio files used by it will be cleaned.\n"
4100 "If deleted, audio files used by it alone by will cleaned."),
4103 dialog.set_position (WIN_POS_CENTER);
4104 dialog.get_vbox()->pack_start (label);
4108 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
4109 dialog.add_button (_("Keep playlist"), RESPONSE_REJECT);
4110 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
4112 switch (dialog.run ()) {
4113 case RESPONSE_ACCEPT:
4114 /* delete the playlist */
4118 case RESPONSE_REJECT:
4119 /* keep the playlist */
4131 Editor::audio_region_selection_covers (nframes64_t where)
4133 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
4134 if ((*a)->region()->covers (where)) {
4143 Editor::prepare_for_cleanup ()
4145 cut_buffer->clear_regions ();
4146 cut_buffer->clear_playlists ();
4148 selection->clear_regions ();
4149 selection->clear_playlists ();
4151 _regions->suspend_redisplay ();
4155 Editor::finish_cleanup ()
4157 _regions->resume_redisplay ();
4161 Editor::transport_loop_location()
4164 return _session->locations()->auto_loop_location();
4171 Editor::transport_punch_location()
4174 return _session->locations()->auto_punch_location();
4181 Editor::control_layout_scroll (GdkEventScroll* ev)
4183 if (Keyboard::some_magic_widget_has_focus()) {
4187 switch (ev->direction) {
4189 scroll_tracks_up_line ();
4193 case GDK_SCROLL_DOWN:
4194 scroll_tracks_down_line ();
4198 /* no left/right handling yet */
4206 Editor::session_state_saved (string snap_name)
4208 ENSURE_GUI_THREAD (*this, &Editor::session_state_saved, snap_name);
4211 _snapshots->redisplay ();
4215 Editor::maximise_editing_space ()
4217 _mouse_mode_tearoff->set_visible (false);
4218 _tools_tearoff->set_visible (false);
4219 _zoom_tearoff->set_visible (false);
4221 pre_maximal_horizontal_pane_position = edit_pane.get_position ();
4222 pre_maximal_vertical_pane_position = editor_summary_pane.get_position ();
4223 pre_maximal_editor_width = this->get_width ();
4224 pre_maximal_editor_height = this->get_height ();
4226 if (post_maximal_horizontal_pane_position == 0) {
4227 post_maximal_horizontal_pane_position = edit_pane.get_width();
4230 if (post_maximal_vertical_pane_position == 0) {
4231 post_maximal_vertical_pane_position = editor_summary_pane.get_height();
4236 if (post_maximal_editor_width) {
4237 edit_pane.set_position (post_maximal_horizontal_pane_position -
4238 abs(post_maximal_editor_width - pre_maximal_editor_width));
4240 edit_pane.set_position (post_maximal_horizontal_pane_position);
4243 if (post_maximal_editor_height) {
4244 editor_summary_pane.set_position (post_maximal_vertical_pane_position -
4245 abs(post_maximal_editor_height - pre_maximal_editor_height));
4247 editor_summary_pane.set_position (post_maximal_vertical_pane_position);
4250 if (Config->get_keep_tearoffs()) {
4251 _mouse_mode_tearoff->set_visible (true);
4252 _tools_tearoff->set_visible (true);
4253 _zoom_tearoff->set_visible (true);
4258 Editor::restore_editing_space ()
4260 // user changed width/height of panes during fullscreen
4262 if (post_maximal_horizontal_pane_position != edit_pane.get_position()) {
4263 post_maximal_horizontal_pane_position = edit_pane.get_position();
4266 if (post_maximal_vertical_pane_position != editor_summary_pane.get_position()) {
4267 post_maximal_vertical_pane_position = editor_summary_pane.get_position();
4272 _mouse_mode_tearoff->set_visible (true);
4273 _tools_tearoff->set_visible (true);
4274 _zoom_tearoff->set_visible (true);
4275 post_maximal_editor_width = this->get_width();
4276 post_maximal_editor_height = this->get_height();
4278 edit_pane.set_position (pre_maximal_horizontal_pane_position + abs(this->get_width() - pre_maximal_editor_width));
4279 editor_summary_pane.set_position (pre_maximal_vertical_pane_position + abs(this->get_height() - pre_maximal_editor_height));
4283 * Make new playlists for a given track and also any others that belong
4284 * to the same active route group with the `edit' property.
4289 Editor::new_playlists (TimeAxisView* v)
4291 begin_reversible_command (_("new playlists"));
4292 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4293 _session->playlists->get (playlists);
4294 mapover_tracks (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v, ARDOUR::Properties::edit.property_id);
4295 commit_reversible_command ();
4299 * Use a copy of the current playlist for a given track and also any others that belong
4300 * to the same active route group with the `edit' property.
4305 Editor::copy_playlists (TimeAxisView* v)
4307 begin_reversible_command (_("copy playlists"));
4308 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4309 _session->playlists->get (playlists);
4310 mapover_tracks (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v, ARDOUR::Properties::edit.property_id);
4311 commit_reversible_command ();
4314 /** Clear the current playlist for a given track and also any others that belong
4315 * to the same active route group with the `edit' property.
4320 Editor::clear_playlists (TimeAxisView* v)
4322 begin_reversible_command (_("clear playlists"));
4323 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4324 _session->playlists->get (playlists);
4325 mapover_tracks (sigc::mem_fun (*this, &Editor::mapped_clear_playlist), v, ARDOUR::Properties::edit.property_id);
4326 commit_reversible_command ();
4330 Editor::mapped_use_new_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4332 atv.use_new_playlist (sz > 1 ? false : true, playlists);
4336 Editor::mapped_use_copy_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4338 atv.use_copy_playlist (sz > 1 ? false : true, playlists);
4342 Editor::mapped_clear_playlist (RouteTimeAxisView& atv, uint32_t /*sz*/)
4344 atv.clear_playlist ();
4348 Editor::on_key_press_event (GdkEventKey* ev)
4350 return key_press_focus_accelerator_handler (*this, ev);
4354 Editor::on_key_release_event (GdkEventKey* ev)
4356 return Gtk::Window::on_key_release_event (ev);
4357 // return key_press_focus_accelerator_handler (*this, ev);
4360 /** Queue up a change to the viewport x origin.
4361 * @param frame New x origin.
4364 Editor::reset_x_origin (nframes64_t frame)
4366 queue_visual_change (frame);
4370 Editor::reset_y_origin (double y)
4372 queue_visual_change_y (y);
4376 Editor::reset_zoom (double fpu)
4378 queue_visual_change (fpu);
4382 Editor::reposition_and_zoom (nframes64_t frame, double fpu)
4384 reset_x_origin (frame);
4387 if (!no_save_visual) {
4388 undo_visual_stack.push_back (current_visual_state(false));
4392 Editor::VisualState*
4393 Editor::current_visual_state (bool with_tracks)
4395 VisualState* vs = new VisualState;
4396 vs->y_position = vertical_adjustment.get_value();
4397 vs->frames_per_unit = frames_per_unit;
4398 vs->leftmost_frame = leftmost_frame;
4399 vs->zoom_focus = zoom_focus;
4402 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4403 vs->track_states.push_back (TAVState ((*i), &(*i)->get_state()));
4411 Editor::undo_visual_state ()
4413 if (undo_visual_stack.empty()) {
4417 redo_visual_stack.push_back (current_visual_state());
4419 VisualState* vs = undo_visual_stack.back();
4420 undo_visual_stack.pop_back();
4421 use_visual_state (*vs);
4425 Editor::redo_visual_state ()
4427 if (redo_visual_stack.empty()) {
4431 undo_visual_stack.push_back (current_visual_state());
4433 VisualState* vs = redo_visual_stack.back();
4434 redo_visual_stack.pop_back();
4435 use_visual_state (*vs);
4439 Editor::swap_visual_state ()
4441 if (undo_visual_stack.empty()) {
4442 redo_visual_state ();
4444 undo_visual_state ();
4449 Editor::use_visual_state (VisualState& vs)
4451 no_save_visual = true;
4453 _routes->suspend_redisplay ();
4455 vertical_adjustment.set_value (vs.y_position);
4457 set_zoom_focus (vs.zoom_focus);
4458 reposition_and_zoom (vs.leftmost_frame, vs.frames_per_unit);
4460 for (list<TAVState>::iterator i = vs.track_states.begin(); i != vs.track_states.end(); ++i) {
4461 TrackViewList::iterator t;
4463 /* check if the track still exists - it could have been deleted */
4465 if ((t = find (track_views.begin(), track_views.end(), i->first)) != track_views.end()) {
4466 (*t)->set_state (*(i->second), Stateful::loading_state_version);
4471 if (!vs.track_states.empty()) {
4472 _routes->update_visibility ();
4475 _routes->resume_redisplay ();
4477 no_save_visual = false;
4481 Editor::set_frames_per_unit (double fpu)
4483 /* this is the core function that controls the zoom level of the canvas. it is called
4484 whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
4487 if (fpu == frames_per_unit) {
4496 /* don't allow zooms that fit more than the maximum number
4497 of frames into an 800 pixel wide space.
4500 if (max_frames / fpu < 800.0) {
4505 tempo_lines->tempo_map_changed();
4507 frames_per_unit = fpu;
4512 Editor::post_zoom ()
4514 // convert fpu to frame count
4516 nframes64_t frames = (nframes64_t) floor (frames_per_unit * _canvas_width);
4518 if (frames_per_unit != zoom_range_clock.current_duration()) {
4519 zoom_range_clock.set (frames);
4522 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
4523 for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4524 (*i)->reshow_selection (selection->time);
4528 ZoomChanged (); /* EMIT_SIGNAL */
4530 //reset_scrolling_region ();
4532 if (playhead_cursor) {
4533 playhead_cursor->set_position (playhead_cursor->current_frame);
4536 refresh_location_display();
4537 _summary->set_overlays_dirty ();
4543 Editor::queue_visual_change (nframes64_t where)
4545 pending_visual_change.add (VisualChange::TimeOrigin);
4546 pending_visual_change.time_origin = where;
4547 ensure_visual_change_idle_handler ();
4551 Editor::queue_visual_change (double fpu)
4553 pending_visual_change.add (VisualChange::ZoomLevel);
4554 pending_visual_change.frames_per_unit = fpu;
4556 ensure_visual_change_idle_handler ();
4560 Editor::queue_visual_change_y (double y)
4562 pending_visual_change.add (VisualChange::YOrigin);
4563 pending_visual_change.y_origin = y;
4565 ensure_visual_change_idle_handler ();
4569 Editor::ensure_visual_change_idle_handler ()
4571 if (pending_visual_change.idle_handler_id < 0) {
4572 pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
4577 Editor::_idle_visual_changer (void* arg)
4579 return static_cast<Editor*>(arg)->idle_visual_changer ();
4583 Editor::idle_visual_changer ()
4585 VisualChange::Type p = pending_visual_change.pending;
4586 pending_visual_change.pending = (VisualChange::Type) 0;
4588 double last_time_origin = horizontal_position ();
4590 if (p & VisualChange::ZoomLevel) {
4591 set_frames_per_unit (pending_visual_change.frames_per_unit);
4593 compute_fixed_ruler_scale ();
4594 compute_current_bbt_points(pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4595 compute_bbt_ruler_scale (pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4596 update_tempo_based_rulers ();
4598 if (p & VisualChange::TimeOrigin) {
4599 set_horizontal_position (pending_visual_change.time_origin / frames_per_unit);
4601 if (p & VisualChange::YOrigin) {
4602 vertical_adjustment.set_value (pending_visual_change.y_origin);
4605 if (last_time_origin == horizontal_position ()) {
4606 /* changed signal not emitted */
4607 update_fixed_rulers ();
4608 redisplay_tempo (true);
4611 _summary->set_overlays_dirty ();
4613 pending_visual_change.idle_handler_id = -1;
4614 return 0; /* this is always a one-shot call */
4617 struct EditorOrderTimeAxisSorter {
4618 bool operator() (const TimeAxisView* a, const TimeAxisView* b) const {
4619 return a->order () < b->order ();
4624 Editor::sort_track_selection (TrackViewList* sel)
4626 EditorOrderTimeAxisSorter cmp;
4631 selection->tracks.sort (cmp);
4636 Editor::get_preferred_edit_position (bool ignore_playhead)
4639 nframes64_t where = 0;
4640 EditPoint ep = _edit_point;
4642 if (entered_marker) {
4643 return entered_marker->position();
4646 if (ignore_playhead && ep == EditAtPlayhead) {
4647 ep = EditAtSelectedMarker;
4651 case EditAtPlayhead:
4652 where = _session->audible_frame();
4655 case EditAtSelectedMarker:
4656 if (!selection->markers.empty()) {
4658 Location* loc = find_location_from_marker (selection->markers.front(), is_start);
4661 where = loc->start();
4672 if (!mouse_frame (where, ignored)) {
4673 /* XXX not right but what can we do ? */
4684 Editor::set_loop_range (nframes64_t start, nframes64_t end, string cmd)
4686 if (!_session) return;
4688 begin_reversible_command (cmd);
4692 if ((tll = transport_loop_location()) == 0) {
4693 Location* loc = new Location (*_session, start, end, _("Loop"), Location::IsAutoLoop);
4694 XMLNode &before = _session->locations()->get_state();
4695 _session->locations()->add (loc, true);
4696 _session->set_auto_loop_location (loc);
4697 XMLNode &after = _session->locations()->get_state();
4698 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
4700 XMLNode &before = tll->get_state();
4701 tll->set_hidden (false, this);
4702 tll->set (start, end);
4703 XMLNode &after = tll->get_state();
4704 _session->add_command (new MementoCommand<Location>(*tll, &before, &after));
4707 commit_reversible_command ();
4711 Editor::set_punch_range (nframes64_t start, nframes64_t end, string cmd)
4713 if (!_session) return;
4715 begin_reversible_command (cmd);
4719 if ((tpl = transport_punch_location()) == 0) {
4720 Location* loc = new Location (*_session, start, end, _("Loop"), Location::IsAutoPunch);
4721 XMLNode &before = _session->locations()->get_state();
4722 _session->locations()->add (loc, true);
4723 _session->set_auto_loop_location (loc);
4724 XMLNode &after = _session->locations()->get_state();
4725 _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
4728 XMLNode &before = tpl->get_state();
4729 tpl->set_hidden (false, this);
4730 tpl->set (start, end);
4731 XMLNode &after = tpl->get_state();
4732 _session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
4735 commit_reversible_command ();
4738 /** Find regions which exist at a given time, and optionally on a given list of tracks.
4739 * @param rs List to which found regions are added.
4740 * @param where Time to look at.
4741 * @param ts Tracks to look on; if this is empty, all tracks are examined.
4744 Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackViewList& ts) const
4746 const TrackViewList* tracks;
4749 tracks = &track_views;
4754 for (TrackViewList::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4755 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4757 boost::shared_ptr<Track> tr;
4758 boost::shared_ptr<Playlist> pl;
4760 if ((tr = rtv->track()) && ((pl = tr->playlist()))) {
4762 Playlist::RegionList* regions = pl->regions_at (
4763 (nframes64_t) floor ( (double)where * tr->speed()));
4765 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4766 RegionView* rv = rtv->view()->find_view (*i);
4779 Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackViewList& ts) const
4781 const TrackViewList* tracks;
4784 tracks = &track_views;
4789 for (TrackViewList::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4790 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4792 boost::shared_ptr<Track> tr;
4793 boost::shared_ptr<Playlist> pl;
4795 if ((tr = rtv->track()) && ((pl = tr->playlist()))) {
4797 Playlist::RegionList* regions = pl->regions_touched (
4798 (nframes64_t) floor ( (double)where * tr->speed()), max_frames);
4800 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4802 RegionView* rv = rtv->view()->find_view (*i);
4815 /** Find all regions which are either:
4817 * - the entered_regionview (if allow_entered == true) or
4818 * - under the preferred edit position AND on a selected track, or on a track
4819 * which is in the same active edit-enable route group as a selected region (if allow_edit_position == true)
4820 * @param rs Returned region list.
4821 * @param allow_entered true to include the entered_regionview in the list.
4824 Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered, bool allow_edit_position)
4826 /* Start with selected regions */
4827 rs = selection->regions;
4829 /* Add the entered_regionview, if requested */
4830 if (allow_entered && entered_regionview) {
4831 rs.add (entered_regionview);
4834 if (allow_edit_position) {
4836 TrackViewList tracks = selection->tracks;
4838 /* tracks is currently the set of selected tracks; add any other tracks that
4839 * have regions that are in the same edit-activated route group as one of
4841 for (RegionSelection::iterator i = rs.begin (); i != rs.end(); ++i) {
4843 RouteGroup* g = (*i)->get_time_axis_view().route_group ();
4844 if (g && g->is_active() && g->is_edit()) {
4845 tracks.add (axis_views_from_routes (g->route_list()));
4850 if (!tracks.empty()) {
4851 /* now find regions that are at the edit position on those tracks */
4852 nframes64_t const where = get_preferred_edit_position ();
4853 get_regions_at (rs, where, tracks);
4859 Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<RegionView*>& regions)
4861 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4863 RouteTimeAxisView* tatv;
4865 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
4867 boost::shared_ptr<Playlist> pl;
4868 vector<boost::shared_ptr<Region> > results;
4870 boost::shared_ptr<Track> tr;
4872 if ((tr = tatv->track()) == 0) {
4877 if ((pl = (tr->playlist())) != 0) {
4878 pl->get_region_list_equivalent_regions (region, results);
4881 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
4882 if ((marv = tatv->view()->find_view (*ir)) != 0) {
4883 regions.push_back (marv);
4892 Editor::show_rhythm_ferret ()
4894 if (rhythm_ferret == 0) {
4895 rhythm_ferret = new RhythmFerret(*this);
4898 rhythm_ferret->set_session (_session);
4899 rhythm_ferret->show ();
4900 rhythm_ferret->present ();
4904 Editor::first_idle ()
4906 MessageDialog* dialog = 0;
4908 if (track_views.size() > 1) {
4909 dialog = new MessageDialog (*this,
4910 string_compose (_("Please wait while %1 loads visual data"), PROGRAM_NAME),
4915 ARDOUR_UI::instance()->flush_pending ();
4918 for (TrackViewList::iterator t = track_views.begin(); t != track_views.end(); ++t) {
4922 // first idle adds route children (automation tracks), so we need to redisplay here
4923 _routes->redisplay ();
4931 Editor::_idle_resize (gpointer arg)
4933 return ((Editor*)arg)->idle_resize ();
4937 Editor::add_to_idle_resize (TimeAxisView* view, int32_t h)
4939 if (resize_idle_id < 0) {
4940 resize_idle_id = g_idle_add (_idle_resize, this);
4941 _pending_resize_amount = 0;
4944 /* make a note of the smallest resulting height, so that we can clamp the
4945 lower limit at TimeAxisView::hSmall */
4947 int32_t min_resulting = INT32_MAX;
4949 _pending_resize_amount += h;
4950 _pending_resize_view = view;
4952 min_resulting = min (min_resulting, int32_t (_pending_resize_view->current_height()) + _pending_resize_amount);
4954 if (selection->tracks.contains (_pending_resize_view)) {
4955 for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4956 min_resulting = min (min_resulting, int32_t ((*i)->current_height()) + _pending_resize_amount);
4960 if (min_resulting < 0) {
4965 if (uint32_t (min_resulting) < TimeAxisView::preset_height (HeightSmall)) {
4966 _pending_resize_amount += TimeAxisView::preset_height (HeightSmall) - min_resulting;
4970 /** Handle pending resizing of tracks */
4972 Editor::idle_resize ()
4974 _pending_resize_view->idle_resize (_pending_resize_view->current_height() + _pending_resize_amount);
4976 if (dynamic_cast<AutomationTimeAxisView*> (_pending_resize_view) == 0 &&
4977 selection->tracks.contains (_pending_resize_view)) {
4979 for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4980 if (*i != _pending_resize_view) {
4981 (*i)->idle_resize ((*i)->current_height() + _pending_resize_amount);
4986 _pending_resize_amount = 0;
4988 _group_tabs->set_dirty ();
4989 resize_idle_id = -1;
4997 ENSURE_GUI_THREAD (*this, &Editor::located);
4999 playhead_cursor->set_position (_session->audible_frame ());
5000 if (_follow_playhead && !_pending_initial_locate) {
5001 reset_x_origin_to_follow_playhead ();
5004 _pending_locate_request = false;
5005 _pending_initial_locate = false;
5009 Editor::region_view_added (RegionView *)
5011 _summary->set_dirty ();
5015 Editor::axis_view_from_route (boost::shared_ptr<Route> r) const
5017 TrackViewList::const_iterator j = track_views.begin ();
5018 while (j != track_views.end()) {
5019 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*j);
5020 if (rtv && rtv->route() == r) {
5031 Editor::axis_views_from_routes (boost::shared_ptr<RouteList> r) const
5035 for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
5036 TimeAxisView* tv = axis_view_from_route (*i);
5047 Editor::handle_new_route (RouteList& routes)
5049 ENSURE_GUI_THREAD (*this, &Editor::handle_new_route, routes)
5051 RouteTimeAxisView *rtv;
5052 list<RouteTimeAxisView*> new_views;
5054 for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) {
5055 boost::shared_ptr<Route> route = (*x);
5057 if (route->is_hidden() || route->is_monitor()) {
5061 DataType dt = route->input()->default_type();
5063 if (dt == ARDOUR::DataType::AUDIO) {
5064 rtv = new AudioTimeAxisView (*this, _session, route, *track_canvas);
5065 } else if (dt == ARDOUR::DataType::MIDI) {
5066 rtv = new MidiTimeAxisView (*this, _session, route, *track_canvas);
5068 throw unknown_type();
5071 new_views.push_back (rtv);
5072 track_views.push_back (rtv);
5074 rtv->effective_gain_display ();
5076 rtv->view()->RegionViewAdded.connect (sigc::mem_fun (*this, &Editor::region_view_added));
5079 _routes->routes_added (new_views);
5081 if (show_editor_mixer_when_tracks_arrive) {
5082 show_editor_mixer (true);
5085 editor_list_button.set_sensitive (true);
5087 _summary->set_dirty ();
5091 Editor::timeaxisview_deleted (TimeAxisView *tv)
5093 if (_session && _session->deletion_in_progress()) {
5094 /* the situation is under control */
5098 ENSURE_GUI_THREAD (*this, &Editor::timeaxisview_deleted, tv);
5100 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (tv);
5102 _routes->route_removed (tv);
5104 if (tv == entered_track) {
5108 TimeAxisView::Children c = tv->get_child_list ();
5109 for (TimeAxisView::Children::const_iterator i = c.begin(); i != c.end(); ++i) {
5110 if (entered_track == i->get()) {
5115 /* remove it from the list of track views */
5117 TrackViewList::iterator i;
5119 if ((i = find (track_views.begin(), track_views.end(), tv)) != track_views.end()) {
5120 i = track_views.erase (i);
5123 /* update whatever the current mixer strip is displaying, if revelant */
5125 boost::shared_ptr<Route> route;
5128 route = rtav->route ();
5131 if (current_mixer_strip && current_mixer_strip->route() == route) {
5133 TimeAxisView* next_tv;
5135 if (track_views.empty()) {
5137 } else if (i == track_views.end()) {
5138 next_tv = track_views.front();
5145 set_selected_mixer_strip (*next_tv);
5147 /* make the editor mixer strip go away setting the
5148 * button to inactive (which also unticks the menu option)
5151 ActionManager::uncheck_toggleaction ("<Actions>/Editor/show-editor-mixer");
5157 Editor::hide_track_in_display (TimeAxisView* tv, bool /*temponly*/)
5159 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
5161 if (rtv && current_mixer_strip && (rtv->route() == current_mixer_strip->route())) {
5162 // this will hide the mixer strip
5163 set_selected_mixer_strip (*tv);
5166 _routes->hide_track_in_display (*tv);
5170 Editor::sync_track_view_list_and_routes ()
5172 track_views = TrackViewList (_routes->views ());
5174 _summary->set_dirty ();
5175 _group_tabs->set_dirty ();
5177 return false; // do not call again (until needed)
5181 Editor::foreach_time_axis_view (sigc::slot<void,TimeAxisView&> theslot)
5183 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5188 /** Find a RouteTimeAxisView by the ID of its route */
5190 Editor::get_route_view_by_route_id (PBD::ID& id) const
5192 RouteTimeAxisView* v;
5194 for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) {
5195 if((v = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) {
5196 if(v->route()->id() == id) {
5206 Editor::fit_route_group (RouteGroup *g)
5208 TrackViewList ts = axis_views_from_routes (g->route_list ());
5213 Editor::consider_auditioning (boost::shared_ptr<Region> region)
5215 boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion> (region);
5218 _session->cancel_audition ();
5222 if (_session->is_auditioning()) {
5223 _session->cancel_audition ();
5224 if (r == last_audition_region) {
5229 _session->audition_region (r);
5230 last_audition_region = r;
5235 Editor::hide_a_region (boost::shared_ptr<Region> r)
5237 r->set_hidden (true);
5241 Editor::show_a_region (boost::shared_ptr<Region> r)
5243 r->set_hidden (false);
5247 Editor::audition_region_from_region_list ()
5249 _regions->selection_mapover (sigc::mem_fun (*this, &Editor::consider_auditioning));
5253 Editor::hide_region_from_region_list ()
5255 _regions->selection_mapover (sigc::mem_fun (*this, &Editor::hide_a_region));
5259 Editor::show_region_in_region_list ()
5261 _regions->selection_mapover (sigc::mem_fun (*this, &Editor::show_a_region));
5265 Editor::step_edit_status_change (bool yn)
5268 start_step_editing ();
5270 stop_step_editing ();
5275 Editor::start_step_editing ()
5277 step_edit_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &Editor::check_step_edit), 20);
5281 Editor::stop_step_editing ()
5283 step_edit_connection.disconnect ();
5287 Editor::check_step_edit ()
5289 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5290 MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*> (*i);
5292 mtv->check_step_edit ();
5296 return true; // do it again, till we stop
5300 Editor::horizontal_scroll_left_press ()
5302 ++_scroll_callbacks;
5304 if (_scroll_connection.connected() && _scroll_callbacks < 5) {
5305 /* delay the first auto-repeat */
5309 double x = leftmost_position() - current_page_frames() / 5;
5316 /* do hacky auto-repeat */
5317 if (!_scroll_connection.connected ()) {
5318 _scroll_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &Editor::horizontal_scroll_left_press), 100);
5319 _scroll_callbacks = 0;
5326 Editor::horizontal_scroll_left_release ()
5328 _scroll_connection.disconnect ();
5332 Editor::horizontal_scroll_right_press ()
5334 ++_scroll_callbacks;
5336 if (_scroll_connection.connected() && _scroll_callbacks < 5) {
5337 /* delay the first auto-repeat */
5341 reset_x_origin (leftmost_position() + current_page_frames() / 5);
5343 /* do hacky auto-repeat */
5344 if (!_scroll_connection.connected ()) {
5345 _scroll_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &Editor::horizontal_scroll_right_press), 100);
5346 _scroll_callbacks = 0;
5353 Editor::horizontal_scroll_right_release ()
5355 _scroll_connection.disconnect ();
5358 /** Queue a change for the Editor viewport x origin to follow the playhead */
5360 Editor::reset_x_origin_to_follow_playhead ()
5362 nframes64_t const frame = playhead_cursor->current_frame;
5364 if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
5366 if (_session->transport_speed() < 0) {
5368 if (frame > (current_page_frames() / 2)) {
5369 center_screen (frame-(current_page_frames()/2));
5371 center_screen (current_page_frames()/2);
5376 if (frame < leftmost_frame) {
5379 if (_session->transport_rolling()) {
5380 /* rolling; end up with the playhead at the right of the page */
5381 l = frame - current_page_frames ();
5383 /* not rolling: end up with the playhead 3/4 of the way along the page */
5384 l = frame - (3 * current_page_frames() / 4);
5391 center_screen_internal (l + (current_page_frames() / 2), current_page_frames ());
5394 if (_session->transport_rolling()) {
5395 /* rolling: end up with the playhead on the left of the page */
5396 center_screen_internal (frame + (current_page_frames() / 2), current_page_frames ());
5398 /* not rolling: end up with the playhead 1/4 of the way along the page */
5399 center_screen_internal (frame + (current_page_frames() / 4), current_page_frames ());
5407 Editor::super_rapid_screen_update ()
5409 if (!_session || !_session->engine().running()) {
5413 /* METERING / MIXER STRIPS */
5415 /* update track meters, if required */
5416 if (is_mapped() && meters_running) {
5417 RouteTimeAxisView* rtv;
5418 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5419 if ((rtv = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) {
5420 rtv->fast_update ();
5425 /* and any current mixer strip */
5426 if (current_mixer_strip) {
5427 current_mixer_strip->fast_update ();
5430 /* PLAYHEAD AND VIEWPORT */
5432 nframes64_t const frame = _session->audible_frame();
5434 /* There are a few reasons why we might not update the playhead / viewport stuff:
5436 * 1. we don't update things when there's a pending locate request, otherwise
5437 * when the editor requests a locate there is a chance that this method
5438 * will move the playhead before the locate request is processed, causing
5440 * 2. if we're not rolling, there's nothing to do here (locates are handled elsewhere).
5441 * 3. if we're still at the same frame that we were last time, there's nothing to do.
5444 if (!_pending_locate_request && _session->transport_speed() != 0 && frame != last_update_frame) {
5446 last_update_frame = frame;
5448 if (!_dragging_playhead) {
5449 playhead_cursor->set_position (frame);
5452 if (!_stationary_playhead) {
5454 if (!_dragging_playhead && _follow_playhead && _session->requested_return_frame() < 0) {
5455 reset_x_origin_to_follow_playhead ();
5460 /* don't do continuous scroll till the new position is in the rightmost quarter of the
5464 // FIXME DO SOMETHING THAT WORKS HERE - this is 2.X code
5465 double target = ((double)frame - (double)current_page_frames()/2.0) / frames_per_unit;
5466 if (target <= 0.0) {
5469 if (fabs(target - current) < current_page_frames() / frames_per_unit) {
5470 target = (target * 0.15) + (current * 0.85);
5476 set_horizontal_position (current);
5485 Editor::session_going_away ()
5487 _have_idled = false;
5489 _session_connections.drop_connections ();
5491 super_rapid_screen_update_connection.disconnect ();
5493 selection->clear ();
5494 cut_buffer->clear ();
5496 clicked_regionview = 0;
5497 clicked_axisview = 0;
5498 clicked_routeview = 0;
5499 clicked_crossfadeview = 0;
5500 entered_regionview = 0;
5502 last_update_frame = 0;
5505 playhead_cursor->canvas_item.hide ();
5507 /* rip everything out of the list displays */
5511 _route_groups->clear ();
5513 /* do this first so that deleting a track doesn't reset cms to null
5514 and thus cause a leak.
5517 if (current_mixer_strip) {
5518 if (current_mixer_strip->get_parent() != 0) {
5519 global_hpacker.remove (*current_mixer_strip);
5521 delete current_mixer_strip;
5522 current_mixer_strip = 0;
5525 /* delete all trackviews */
5527 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5530 track_views.clear ();
5532 zoom_range_clock.set_session (0);
5533 nudge_clock.set_session (0);
5535 editor_list_button.set_active(false);
5536 editor_list_button.set_sensitive(false);
5538 /* clear tempo/meter rulers */
5539 remove_metric_marks ();
5541 clear_marker_display ();
5543 delete current_bbt_points;
5544 current_bbt_points = 0;
5546 /* get rid of any existing editor mixer strip */
5548 WindowTitle title(Glib::get_application_name());
5549 title += _("Editor");
5551 set_title (title.get_string());
5553 SessionHandlePtr::session_going_away ();
5558 Editor::show_editor_list (bool yn)
5561 the_notebook.show();
5563 the_notebook.hide();