2 Copyright (C) 2000-2007 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 */
28 #include <boost/none.hpp>
30 #include <sigc++/bind.h>
32 #include <pbd/convert.h>
33 #include <pbd/error.h>
34 #include <pbd/enumwriter.h>
35 #include <pbd/memento_command.h>
37 #include <glibmm/miscutils.h>
38 #include <gtkmm/image.h>
39 #include <gdkmm/color.h>
40 #include <gdkmm/bitmap.h>
42 #include <gtkmm2ext/grouped_buttons.h>
43 #include <gtkmm2ext/gtk_ui.h>
44 #include <gtkmm2ext/tearoff.h>
45 #include <gtkmm2ext/utils.h>
46 #include <gtkmm2ext/window_title.h>
47 #include <gtkmm2ext/choice.h>
49 #include <ardour/audio_track.h>
50 #include <ardour/audio_diskstream.h>
51 #include <ardour/plugin_manager.h>
52 #include <ardour/location.h>
53 #include <ardour/audioplaylist.h>
54 #include <ardour/audioregion.h>
55 #include <ardour/midi_region.h>
56 #include <ardour/session_route.h>
57 #include <ardour/session_directory.h>
58 #include <ardour/session_state_utils.h>
59 #include <ardour/tempo.h>
60 #include <ardour/utils.h>
61 #include <ardour/profile.h>
63 #include <control_protocol/control_protocol.h>
65 #include "ardour_ui.h"
69 #include "playlist_selector.h"
70 #include "audio_region_view.h"
71 #include "rgb_macros.h"
72 #include "selection.h"
73 #include "audio_streamview.h"
74 #include "time_axis_view.h"
75 #include "audio_time_axis.h"
77 #include "crossfade_view.h"
79 #include "public_editor.h"
80 #include "crossfade_edit.h"
81 #include "canvas_impl.h"
84 #include "gui_thread.h"
87 #include "analysis_window.h"
93 #include "imageframe_socket_handler.h"
98 using namespace ARDOUR;
101 using namespace Glib;
102 using namespace Gtkmm2ext;
103 using namespace Editing;
105 using PBD::internationalize;
108 const double Editor::timebar_height = 15.0;
110 #include "editor_xpms"
112 static const gchar *_snap_type_strings[] = {
134 static const gchar *_snap_mode_strings[] = {
141 static const gchar *_edit_point_strings[] = {
148 static const gchar *_zoom_focus_strings[] = {
158 #ifdef USE_RUBBERBAND
159 static const gchar *_rb_opt_strings[] = {
162 N_("Balanced multitimbral mixture"),
163 N_("Unpitched percussion with stable notes"),
164 N_("Crisp monophonic instrumental"),
165 N_("Unpitched solo percussion"),
170 /* Soundfile drag-n-drop */
172 Gdk::Cursor* Editor::cross_hair_cursor = 0;
173 Gdk::Cursor* Editor::selector_cursor = 0;
174 Gdk::Cursor* Editor::trimmer_cursor = 0;
175 Gdk::Cursor* Editor::grabber_cursor = 0;
176 Gdk::Cursor* Editor::zoom_cursor = 0;
177 Gdk::Cursor* Editor::time_fx_cursor = 0;
178 Gdk::Cursor* Editor::fader_cursor = 0;
179 Gdk::Cursor* Editor::speaker_cursor = 0;
180 Gdk::Cursor* Editor::midi_pencil_cursor = 0;
181 Gdk::Cursor* Editor::midi_select_cursor = 0;
182 Gdk::Cursor* Editor::midi_erase_cursor = 0;
183 Gdk::Cursor* Editor::wait_cursor = 0;
184 Gdk::Cursor* Editor::timebar_cursor = 0;
185 Gdk::Cursor* Editor::transparent_cursor = 0;
188 show_me_the_size (Requisition* r, const char* what)
190 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
195 /* time display buttons */
197 minsec_label (_("Mins:Secs")),
198 bbt_label (_("Bars:Beats")),
199 smpte_label (_("Timecode")),
200 frame_label (_("Samples")),
201 tempo_label (_("Tempo")),
202 meter_label (_("Meter")),
203 mark_label (_("Location Markers")),
204 range_mark_label (_("Range Markers")),
205 transport_mark_label (_("Loop/Punch Ranges")),
206 cd_mark_label (_("CD Markers")),
208 edit_packer (3, 3, true),
210 /* the values here don't matter: layout widgets
211 reset them as needed.
214 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
215 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
218 marker_tempo_lines(0),
220 /* tool bar related */
222 edit_point_clock (X_("editpoint"), false, X_("EditPointClock"), true),
223 zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true),
225 toolbar_selection_clock_table (2,3),
227 automation_mode_button (_("mode")),
228 global_automation_button (_("automation")),
231 image_socket_listener(0),
236 nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true),
237 meters_running(false)
242 /* we are a singleton */
244 PublicEditor::_instance = this;
248 selection = new Selection (this);
249 cut_buffer = new Selection (this);
251 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
252 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
253 selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
254 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
255 selection->MarkersChanged.connect (mem_fun(*this, &Editor::marker_selection_changed));
257 clicked_regionview = 0;
258 clicked_axisview = 0;
259 clicked_routeview = 0;
260 clicked_crossfadeview = 0;
261 clicked_control_point = 0;
262 last_update_frame = 0;
264 current_mixer_strip = 0;
265 current_bbt_points = 0;
267 snap_type_strings = I18N (_snap_type_strings);
268 snap_mode_strings = I18N (_snap_mode_strings);
269 zoom_focus_strings = I18N (_zoom_focus_strings);
270 edit_point_strings = I18N (_edit_point_strings);
271 #ifdef USE_RUBBERBAND
272 rb_opt_strings = I18N (_rb_opt_strings);
275 snap_threshold = 5.0;
276 bbt_beat_subdivision = 4;
279 autoscroll_active = false;
280 autoscroll_timeout_tag = -1;
281 interthread_progress_window = 0;
288 current_interthread_info = 0;
289 _show_measures = true;
290 _show_waveforms = true;
291 _show_waveforms_recording = true;
292 first_action_message = 0;
294 export_range_markers_dialog = 0;
295 show_gain_after_trim = false;
296 ignore_route_list_reorder = false;
297 no_route_list_redisplay = false;
298 verbose_cursor_on = true;
299 route_removal = false;
300 show_automatic_regions_in_region_list = true;
302 region_list_sort_type = (Editing::RegionListSortType) 0;
303 have_pending_keyboard_selection = false;
304 _follow_playhead = true;
305 _xfade_visibility = true;
306 editor_ruler_menu = 0;
307 no_ruler_shown_update = false;
308 edit_group_list_menu = 0;
310 region_list_menu = 0;
312 start_end_marker_menu = 0;
313 range_marker_menu = 0;
314 marker_menu_item = 0;
316 transport_marker_menu = 0;
317 new_transport_marker_menu = 0;
318 editor_mixer_strip_width = Wide;
319 show_editor_mixer_when_tracks_arrive = false;
320 region_edit_menu_split_multichannel_item = 0;
321 region_edit_menu_split_item = 0;
324 ignore_mouse_mode_toggle = false;
325 ignore_midi_edit_mode_toggle = false;
326 current_stepping_trackview = 0;
328 entered_regionview = 0;
330 clear_entered_track = false;
331 _new_regionviews_show_envelope = false;
333 in_edit_group_row_change = false;
334 last_canvas_frame = 0;
336 button_release_can_deselect = true;
337 canvas_idle_queued = false;
338 _dragging_playhead = false;
339 _dragging_edit_point = false;
340 _dragging_hscrollbar = false;
341 select_new_marker = false;
342 zoomed_to_region = false;
344 scrubbing_direction = 0;
347 ignore_route_order_sync = false;
349 location_marker_color = ARDOUR_UI::config()->canvasvar_LocationMarker.get();
350 location_range_color = ARDOUR_UI::config()->canvasvar_LocationRange.get();
351 location_cd_marker_color = ARDOUR_UI::config()->canvasvar_LocationCDMarker.get();
352 location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
353 location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
355 range_marker_drag_rect = 0;
356 marker_drag_line = 0;
357 tempo_map_change_idle_handler_id = -1;
358 canvas_hroizontally_scrolled_handler_id = -1;
359 set_midi_edit_mode (MidiEditPencil, true);
360 set_mouse_mode (MouseObject, true);
362 last_visual_state.frames_per_unit = 0;
364 frames_per_unit = 2048; /* too early to use reset_zoom () */
365 reset_hscrollbar_stepping ();
367 zoom_focus = ZoomFocusLeft;
368 set_zoom_focus (ZoomFocusLeft);
369 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
371 initialize_rulers ();
372 initialize_canvas ();
374 edit_controls_vbox.set_spacing (0);
375 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled), false);
376 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling), true);
378 track_canvas.set_hadjustment (horizontal_adjustment);
379 track_canvas.set_vadjustment (vertical_adjustment);
380 time_canvas.set_hadjustment (horizontal_adjustment);
382 track_canvas.signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
383 time_canvas.signal_map_event().connect (mem_fun (*this, &Editor::time_canvas_map_handler));
385 controls_layout.add (edit_controls_vbox);
386 controls_layout.set_name ("EditControlsBase");
387 controls_layout.add_events (Gdk::SCROLL_MASK);
388 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
390 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
391 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
392 controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
394 edit_vscrollbar.set_adjustment (vertical_adjustment);
395 edit_hscrollbar.set_adjustment (horizontal_adjustment);
397 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press), false);
398 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release), false);
399 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
401 edit_hscrollbar.set_name ("EditorHScrollbar");
405 setup_midi_toolbar ();
407 edit_point_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_point_clock_changed));
409 ArdourCanvas::Canvas* time_pad = manage(new ArdourCanvas::Canvas());
410 ArdourCanvas::SimpleLine* pad_line_1 = manage(new ArdourCanvas::SimpleLine(*time_pad->root(),
411 0.0, 1.0, 100.0, 1.0));
412 pad_line_1->property_color_rgba() = 0xFF0000FF;
416 time_canvas_vbox.pack_start (*_ruler_separator, false, false);
417 time_canvas_vbox.pack_start (*minsec_ruler, false, false);
418 time_canvas_vbox.pack_start (*smpte_ruler, false, false);
419 time_canvas_vbox.pack_start (*frames_ruler, false, false);
420 time_canvas_vbox.pack_start (*bbt_ruler, false, false);
421 time_canvas_vbox.pack_start (time_canvas, true, true);
422 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars) + 5);
424 bbt_label.set_name ("EditorTimeButton");
425 bbt_label.set_size_request (-1, (int)timebar_height);
426 bbt_label.set_alignment (1.0, 0.5);
427 bbt_label.set_padding (5,0);
428 minsec_label.set_name ("EditorTimeButton");
429 minsec_label.set_size_request (-1, (int)timebar_height);
430 minsec_label.set_alignment (1.0, 0.5);
431 minsec_label.set_padding (5,0);
432 smpte_label.set_name ("EditorTimeButton");
433 smpte_label.set_size_request (-1, (int)timebar_height);
434 smpte_label.set_alignment (1.0, 0.5);
435 smpte_label.set_padding (5,0);
436 frame_label.set_name ("EditorTimeButton");
437 frame_label.set_size_request (-1, (int)timebar_height);
438 frame_label.set_alignment (1.0, 0.5);
439 frame_label.set_padding (5,0);
440 tempo_label.set_name ("EditorTimeButton");
441 tempo_label.set_size_request (-1, (int)timebar_height);
442 tempo_label.set_alignment (1.0, 0.5);
443 tempo_label.set_padding (5,0);
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);
448 mark_label.set_name ("EditorTimeButton");
449 mark_label.set_size_request (-1, (int)timebar_height);
450 mark_label.set_alignment (1.0, 0.5);
451 mark_label.set_padding (5,0);
452 cd_mark_label.set_name ("EditorTimeButton");
453 cd_mark_label.set_size_request (-1, (int)timebar_height);
454 cd_mark_label.set_alignment (1.0, 0.5);
455 cd_mark_label.set_padding (5,0);
456 range_mark_label.set_name ("EditorTimeButton");
457 range_mark_label.set_size_request (-1, (int)timebar_height);
458 range_mark_label.set_alignment (1.0, 0.5);
459 range_mark_label.set_padding (5,0);
460 transport_mark_label.set_name ("EditorTimeButton");
461 transport_mark_label.set_size_request (-1, (int)timebar_height);
462 transport_mark_label.set_alignment (1.0, 0.5);
463 transport_mark_label.set_padding (5,0);
465 time_button_vbox.pack_start (minsec_label, false, false);
466 time_button_vbox.pack_start (smpte_label, false, false);
467 time_button_vbox.pack_start (frame_label, false, false);
468 time_button_vbox.pack_start (bbt_label, false, false);
469 time_button_vbox.pack_start (meter_label, false, false);
470 time_button_vbox.pack_start (tempo_label, false, false);
471 time_button_vbox.pack_start (mark_label, false, false);
473 time_button_event_box.add (time_button_vbox);
474 time_button_event_box.set_name ("TimebarLabelBase");
475 time_button_frame.set_shadow_type (Gtk::SHADOW_NONE);
477 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
478 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
480 time_button_frame.add (time_button_event_box);
481 time_button_frame.set_name ("TimebarLabelBase");
482 time_button_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
484 /* these enable us to have a dedicated window (for cursor setting, etc.)
485 for the canvas areas.
488 track_canvas_event_box.add (track_canvas);
490 time_canvas_event_box.add (time_canvas_vbox);
491 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
493 edit_packer.set_col_spacings (0);
494 edit_packer.set_row_spacings (0);
495 edit_packer.set_homogeneous (false);
496 edit_packer.set_border_width (0);
497 edit_packer.set_name ("EditorWindow");
499 edit_packer.attach (edit_vscrollbar, 3, 4, 1, 2, FILL, FILL|EXPAND, 0, 0);
501 edit_packer.attach (time_button_frame, 0, 2, 0, 1, FILL, SHRINK, 0, 0);
502 edit_packer.attach (time_canvas_event_box, 2, 4, 0, 1, FILL|EXPAND, FILL, 0, 0);
504 edit_packer.attach (controls_layout, 1, 2, 1, 2, FILL, FILL|EXPAND, 0, 0);
505 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 2, FILL|EXPAND, FILL|EXPAND, 0, 0);
507 edit_packer.attach (zoom_box, 1, 2, 2, 3, FILL, FILL, 0, 0);
508 edit_packer.attach (edit_hscrollbar, 2, 3, 2, 3, FILL|EXPAND, FILL, 0, 0);
510 bottom_hbox.set_border_width (2);
511 bottom_hbox.set_spacing (3);
513 route_display_model = ListStore::create(route_display_columns);
514 route_list_display.set_model (route_display_model);
515 route_list_display.append_column (_("Show"), route_display_columns.visible);
516 route_list_display.append_column (_("Name"), route_display_columns.text);
517 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
518 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
519 route_list_display.set_headers_visible (true);
520 route_list_display.set_name ("TrackListDisplay");
521 route_list_display.get_selection()->set_mode (SELECTION_NONE);
522 route_list_display.set_reorderable (true);
523 route_list_display.set_size_request (100,-1);
525 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
526 route_list_visible_cell->property_activatable() = true;
527 route_list_visible_cell->property_radio() = false;
529 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
530 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
532 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
534 route_list_scroller.add (route_list_display);
535 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
537 group_model = ListStore::create(group_columns);
538 edit_group_display.set_model (group_model);
539 edit_group_display.append_column (_("Name"), group_columns.text);
540 edit_group_display.append_column (_("Active"), group_columns.is_active);
541 edit_group_display.append_column (_("Show"), group_columns.is_visible);
542 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
543 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
544 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
545 edit_group_display.get_column (0)->set_expand (true);
546 edit_group_display.get_column (1)->set_expand (false);
547 edit_group_display.get_column (2)->set_expand (false);
548 edit_group_display.set_headers_visible (true);
550 /* name is directly editable */
552 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
553 name_cell->property_editable() = true;
554 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
556 /* use checkbox for the active + visible columns */
558 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
559 active_cell->property_activatable() = true;
560 active_cell->property_radio() = false;
562 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
563 active_cell->property_activatable() = true;
564 active_cell->property_radio() = false;
566 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
568 edit_group_display.set_name ("EditGroupList");
569 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
570 edit_group_display.set_headers_visible (true);
571 edit_group_display.set_reorderable (false);
572 edit_group_display.set_rules_hint (true);
573 edit_group_display.set_size_request (75, -1);
575 edit_group_display_scroller.add (edit_group_display);
576 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
578 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
580 VBox* edit_group_display_packer = manage (new VBox());
581 HBox* edit_group_display_button_box = manage (new HBox());
582 edit_group_display_button_box->set_homogeneous (true);
584 Button* edit_group_add_button = manage (new Button ());
585 Button* edit_group_remove_button = manage (new Button ());
589 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
591 edit_group_add_button->add (*w);
593 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
595 edit_group_remove_button->add (*w);
597 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
598 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
600 edit_group_display_button_box->pack_start (*edit_group_add_button);
601 edit_group_display_button_box->pack_start (*edit_group_remove_button);
603 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
604 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
606 region_list_display.set_size_request (100, -1);
607 region_list_display.set_name ("RegionListDisplay");
609 region_list_model = TreeStore::create (region_list_columns);
610 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
611 region_list_model->set_sort_column (0, SORT_ASCENDING);
613 region_list_display.set_model (region_list_model);
614 region_list_display.append_column (_("Regions"), region_list_columns.name);
615 region_list_display.set_headers_visible (false);
617 CellRendererText* region_name_cell = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
618 region_name_cell->property_editable() = true;
619 region_name_cell->signal_edited().connect (mem_fun (*this, &Editor::region_name_edit));
621 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
623 TreeViewColumn* tv_col = region_list_display.get_column(0);
624 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
625 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
626 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
628 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
629 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
631 /* setup DnD handling */
633 list<TargetEntry> region_list_target_table;
635 region_list_target_table.push_back (TargetEntry ("text/plain"));
636 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
637 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
639 region_list_display.add_drop_targets (region_list_target_table);
640 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
642 region_list_scroller.add (region_list_display);
643 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
645 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
646 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
647 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
648 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
649 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
650 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
652 named_selection_scroller.add (named_selection_display);
653 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
655 named_selection_model = TreeStore::create (named_selection_columns);
656 named_selection_display.set_model (named_selection_model);
657 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
658 named_selection_display.set_headers_visible (false);
659 named_selection_display.set_size_request (100, -1);
660 named_selection_display.set_name ("NamedSelectionDisplay");
662 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
663 named_selection_display.set_size_request (100, -1);
664 named_selection_display.signal_button_release_event().connect (mem_fun(*this, &Editor::named_selection_display_button_release), false);
665 named_selection_display.signal_key_release_event().connect (mem_fun(*this, &Editor::named_selection_display_key_release), false);
666 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
670 snapshot_display_model = ListStore::create (snapshot_display_columns);
671 snapshot_display.set_model (snapshot_display_model);
672 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
673 snapshot_display.set_name ("SnapshotDisplay");
674 snapshot_display.set_size_request (75, -1);
675 snapshot_display.set_headers_visible (false);
676 snapshot_display.set_reorderable (false);
677 snapshot_display_scroller.add (snapshot_display);
678 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
680 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
681 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
685 nlabel = manage (new Label (_("Regions")));
686 nlabel->set_angle (-90);
687 the_notebook.append_page (region_list_scroller, *nlabel);
688 nlabel = manage (new Label (_("Tracks/Busses")));
689 nlabel->set_angle (-90);
690 the_notebook.append_page (route_list_scroller, *nlabel);
691 nlabel = manage (new Label (_("Snapshots")));
692 nlabel->set_angle (-90);
693 the_notebook.append_page (snapshot_display_scroller, *nlabel);
694 nlabel = manage (new Label (_("Edit Groups")));
695 nlabel->set_angle (-90);
696 the_notebook.append_page (*edit_group_display_packer, *nlabel);
698 if (!Profile->get_sae()) {
699 nlabel = manage (new Label (_("Chunks")));
700 nlabel->set_angle (-90);
701 the_notebook.append_page (named_selection_scroller, *nlabel);
704 the_notebook.set_show_tabs (true);
705 the_notebook.set_scrollable (true);
706 the_notebook.popup_enable ();
707 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
709 post_maximal_editor_width = 0;
710 post_maximal_pane_position = 0;
711 edit_pane.pack1 (edit_packer, true, true);
712 edit_pane.pack2 (the_notebook, false, true);
714 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
716 top_hbox.pack_start (toolbar_frame, false, true);
717 top_hbox.pack_start (midi_toolbar_frame, false, true);
719 HBox *hbox = manage (new HBox);
720 hbox->pack_start (edit_pane, true, true);
722 global_vpacker.pack_start (top_hbox, false, false);
723 global_vpacker.pack_start (*hbox, true, true);
725 global_hpacker.pack_start (global_vpacker, true, true);
727 set_name ("EditorWindow");
728 add_accel_group (ActionManager::ui_manager->get_accel_group());
730 status_bar_hpacker.show ();
732 vpacker.pack_end (status_bar_hpacker, false, false);
733 vpacker.pack_end (global_hpacker, true, true);
735 /* register actions now so that set_state() can find them and set toggles/checks etc */
739 snap_type = SnapToBeat;
740 set_snap_to (snap_type);
742 set_snap_mode (snap_mode);
743 _edit_point = EditAtMouse;
744 set_edit_point_preference (_edit_point);
746 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
749 _playlist_selector = new PlaylistSelector();
750 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
752 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
756 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
757 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
759 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
760 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
762 nudge_forward_button.set_name ("TransportButton");
763 nudge_backward_button.set_name ("TransportButton");
765 fade_context_menu.set_name ("ArdourContextMenu");
767 /* icons, titles, WM stuff */
769 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
770 Glib::RefPtr<Gdk::Pixbuf> icon;
772 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
773 window_icons.push_back (icon);
775 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
776 window_icons.push_back (icon);
778 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
779 window_icons.push_back (icon);
781 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
782 window_icons.push_back (icon);
784 if (!window_icons.empty()) {
785 set_icon_list (window_icons);
786 set_default_icon_list (window_icons);
789 WindowTitle title(Glib::get_application_name());
790 title += _("Editor");
791 set_title (title.get_string());
792 set_wmclass (X_("ardour_editor"), "Ardour");
795 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
797 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
798 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
800 /* allow external control surfaces/protocols to do various things */
802 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
803 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
804 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
805 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
807 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
808 Route::SyncOrderKeys.connect (mem_fun (*this, &Editor::sync_order_keys));
817 if(image_socket_listener)
819 if(image_socket_listener->is_connected())
821 image_socket_listener->close_connection() ;
824 delete image_socket_listener ;
825 image_socket_listener = 0 ;
831 Editor::add_toplevel_controls (Container& cont)
833 vpacker.pack_start (cont, false, false);
838 Editor::catch_vanishing_regionview (RegionView *rv)
840 /* note: the selection will take care of the vanishing
841 audioregionview by itself.
844 if (clicked_regionview == rv) {
845 clicked_regionview = 0;
848 if (entered_regionview == rv) {
849 set_entered_regionview (0);
854 Editor::set_entered_regionview (RegionView* rv)
856 if (rv == entered_regionview) {
860 if (entered_regionview) {
861 entered_regionview->exited ();
864 if ((entered_regionview = rv) != 0) {
865 entered_regionview->entered ();
870 Editor::set_entered_track (TimeAxisView* tav)
873 entered_track->exited ();
876 if ((entered_track = tav) != 0) {
877 entered_track->entered ();
882 Editor::show_window ()
884 show_all_children ();
886 /* re-hide editor list if necessary */
887 editor_list_button_toggled ();
889 /* now reset all audio_time_axis heights, because widgets might need
895 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
896 tv = (static_cast<TimeAxisView*>(*i));
904 Editor::instant_save ()
906 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
911 session->add_instant_xml(get_state());
913 Config->add_instant_xml(get_state());
918 Editor::edit_point_clock_changed()
920 if (_dragging_edit_point) {
924 if (selection->markers.empty()) {
929 Location* loc = find_location_from_marker (selection->markers.front(), ignored);
935 loc->move_to (edit_point_clock.current_time());
939 Editor::zoom_adjustment_changed ()
945 double fpu = zoom_range_clock.current_duration() / canvas_width;
949 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
950 } else if (fpu > session->current_end_frame() / canvas_width) {
951 fpu = session->current_end_frame() / canvas_width;
952 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
959 Editor::control_scroll (float fraction)
961 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
967 double step = fraction * current_page_frames();
970 _control_scroll_target is an optional<T>
972 it acts like a pointer to an nframes_t, with
973 a operator conversion to boolean to check
974 that it has a value could possibly use
975 playhead_cursor->current_frame to store the
976 value and a boolean in the class to know
977 when it's out of date
980 if (!_control_scroll_target) {
981 _control_scroll_target = session->transport_frame();
982 _dragging_playhead = true;
985 if ((fraction < 0.0f) && (*_control_scroll_target < (nframes_t) fabs(step))) {
986 *_control_scroll_target = 0;
987 } else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
988 *_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
990 *_control_scroll_target += (nframes_t) floor (step);
993 /* move visuals, we'll catch up with it later */
995 playhead_cursor->set_position (*_control_scroll_target);
996 UpdateAllTransportClocks (*_control_scroll_target);
998 if (*_control_scroll_target > (current_page_frames() / 2)) {
999 /* try to center PH in window */
1000 reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
1006 Now we do a timeout to actually bring the session to the right place
1007 according to the playhead. This is to avoid reading disk buffers on every
1008 call to control_scroll, which is driven by ScrollTimeline and therefore
1009 probably by a control surface wheel which can generate lots of events.
1011 /* cancel the existing timeout */
1013 control_scroll_connection.disconnect ();
1015 /* add the next timeout */
1017 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), *_control_scroll_target), 250);
1021 Editor::deferred_control_scroll (nframes_t target)
1023 session->request_locate (*_control_scroll_target, session->transport_rolling());
1024 // reset for next stream
1025 _control_scroll_target = boost::none;
1026 _dragging_playhead = false;
1031 Editor::on_realize ()
1033 Window::on_realize ();
1038 Editor::start_scrolling ()
1040 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1041 (mem_fun(*this, &Editor::update_current_screen));
1045 Editor::stop_scrolling ()
1047 scroll_connection.disconnect ();
1051 Editor::map_position_change (nframes_t frame)
1053 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1055 if (session == 0 || !_follow_playhead) {
1059 center_screen (frame);
1060 playhead_cursor->set_position (frame);
1064 Editor::center_screen (nframes_t frame)
1066 double page = canvas_width * frames_per_unit;
1068 /* if we're off the page, then scroll.
1071 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1072 center_screen_internal (frame, page);
1077 Editor::center_screen_internal (nframes_t frame, float page)
1082 frame -= (nframes_t) page;
1087 reset_x_origin (frame);
1091 Editor::handle_new_duration ()
1093 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1095 nframes_t new_end = session->get_maximum_extent() + (nframes_t) floorf (current_page_frames() * 0.10f);
1097 if (new_end > last_canvas_frame) {
1098 last_canvas_frame = new_end;
1099 horizontal_adjustment.set_upper (last_canvas_frame / frames_per_unit);
1100 reset_scrolling_region ();
1103 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1107 Editor::update_title_s (const string & snap_name)
1109 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1115 Editor::update_title ()
1117 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1120 bool dirty = session->dirty();
1122 string session_name;
1124 if (session->snap_name() != session->name()) {
1125 session_name = session->snap_name();
1127 session_name = session->name();
1131 session_name = "*" + session_name;
1134 WindowTitle title(session_name);
1135 title += Glib::get_application_name();
1136 set_title (title.get_string());
1141 Editor::connect_to_session (Session *t)
1145 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1148 /* catch up with the playhead */
1150 session->request_locate (playhead_cursor->current_frame);
1152 if (first_action_message) {
1153 first_action_message->hide();
1158 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1159 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1161 /* These signals can all be emitted by a non-GUI thread. Therefore the
1162 handlers for them must not attempt to directly interact with the GUI,
1163 but use Gtkmm2ext::UI::instance()->call_slot();
1166 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1167 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1168 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1169 session_connections.push_back (session->RegionAdded.connect (mem_fun(*this, &Editor::handle_new_region)));
1170 session_connections.push_back (session->RegionRemoved.connect (mem_fun(*this, &Editor::handle_region_removed)));
1171 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1172 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1173 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1174 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1175 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1176 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1177 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1178 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1179 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1181 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1183 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1185 edit_groups_changed ();
1187 edit_point_clock.set_session (session);
1188 zoom_range_clock.set_session (session);
1189 _playlist_selector->set_session (session);
1190 nudge_clock.set_session (session);
1193 if (analysis_window != 0)
1194 analysis_window->set_session (session);
1197 Location* loc = session->locations()->auto_loop_location();
1199 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1200 if (loc->start() == loc->end()) {
1201 loc->set_end (loc->start() + 1);
1203 session->locations()->add (loc, false);
1204 session->set_auto_loop_location (loc);
1207 loc->set_name (_("Loop"));
1210 loc = session->locations()->auto_punch_location();
1212 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1213 if (loc->start() == loc->end()) {
1214 loc->set_end (loc->start() + 1);
1216 session->locations()->add (loc, false);
1217 session->set_auto_punch_location (loc);
1220 loc->set_name (_("Punch"));
1223 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1225 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1227 refresh_location_display ();
1228 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1229 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1230 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1231 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1232 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1235 sfbrowser->set_session (session);
1238 handle_new_duration ();
1240 redisplay_regions ();
1241 redisplay_named_selections ();
1242 redisplay_snapshots ();
1244 initial_route_list_display ();
1246 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1247 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1250 restore_ruler_visibility ();
1251 //tempo_map_changed (Change (0));
1252 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1256 /* don't show master bus in a new session */
1258 if (ARDOUR_UI::instance()->session_is_new ()) {
1260 TreeModel::Children rows = route_display_model->children();
1261 TreeModel::Children::iterator i;
1263 no_route_list_redisplay = true;
1265 for (i = rows.begin(); i != rows.end(); ++i) {
1266 TimeAxisView *tv = (*i)[route_display_columns.tv];
1267 RouteTimeAxisView *rtv;
1269 if ((rtv = dynamic_cast<RouteTimeAxisView*>(tv)) != 0) {
1270 if (rtv->route()->is_master()) {
1271 route_list_display.get_selection()->unselect (i);
1276 no_route_list_redisplay = false;
1277 redisplay_route_list ();
1280 /* register for undo history */
1282 session->register_with_memento_command_factory(_id, this);
1288 Editor::build_cursors ()
1290 using namespace Gdk;
1292 Gdk::Color mbg ("#000000" ); /* Black */
1293 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1296 RefPtr<Bitmap> source, mask;
1297 source = Bitmap::create (mag_bits, mag_width, mag_height);
1298 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1299 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1302 Gdk::Color fbg ("#ffffff" );
1303 Gdk::Color ffg ("#000000" );
1306 RefPtr<Bitmap> source, mask;
1308 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1309 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1310 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1314 RefPtr<Bitmap> source, mask;
1315 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1316 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1317 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1321 RefPtr<Bitmap> bits;
1322 char pix[4] = { 0, 0, 0, 0 };
1323 bits = Bitmap::create (pix, 2, 2);
1325 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1329 RefPtr<Bitmap> bits;
1330 char pix[4] = { 0, 0, 0, 0 };
1331 bits = Bitmap::create (pix, 2, 2);
1333 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1336 grabber_cursor = new Gdk::Cursor (HAND2);
1337 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1338 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1339 selector_cursor = new Gdk::Cursor (XTERM);
1340 time_fx_cursor = new Gdk::Cursor (SIZING);
1341 wait_cursor = new Gdk::Cursor (WATCH);
1342 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1343 midi_pencil_cursor = new Gdk::Cursor (PENCIL);
1344 midi_select_cursor = new Gdk::Cursor (CENTER_PTR);
1345 midi_erase_cursor = new Gdk::Cursor (DRAPED_BOX);
1348 /** Pop up a context menu for when the user clicks on a fade in or fade out */
1350 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1352 using namespace Menu_Helpers;
1353 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1356 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1360 MenuList& items (fade_context_menu.items());
1364 switch (item_type) {
1366 case FadeInHandleItem:
1367 if (arv->audio_region()->fade_in_active()) {
1368 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_in_active), false)));
1370 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_in_active), true)));
1373 items.push_back (SeparatorElem());
1375 if (Profile->get_sae()) {
1376 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1377 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1379 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1380 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1381 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
1382 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
1383 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
1389 case FadeOutHandleItem:
1390 if (arv->audio_region()->fade_out_active()) {
1391 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_out_active), false)));
1393 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_out_active), true)));
1396 items.push_back (SeparatorElem());
1398 if (Profile->get_sae()) {
1399 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1400 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1402 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1403 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1404 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
1405 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
1406 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
1412 fatal << _("programming error: ")
1413 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1418 fade_context_menu.popup (button, time);
1422 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes_t frame)
1424 using namespace Menu_Helpers;
1425 Menu* (Editor::*build_menu_function)(nframes_t);
1428 switch (item_type) {
1430 case RegionViewName:
1431 case RegionViewNameHighlight:
1432 if (with_selection) {
1433 build_menu_function = &Editor::build_track_selection_context_menu;
1435 build_menu_function = &Editor::build_track_region_context_menu;
1440 if (with_selection) {
1441 build_menu_function = &Editor::build_track_selection_context_menu;
1443 build_menu_function = &Editor::build_track_context_menu;
1447 case CrossfadeViewItem:
1448 build_menu_function = &Editor::build_track_crossfade_context_menu;
1452 if (clicked_routeview->get_diskstream()) {
1453 build_menu_function = &Editor::build_track_context_menu;
1455 build_menu_function = &Editor::build_track_bus_context_menu;
1460 /* probably shouldn't happen but if it does, we don't care */
1464 menu = (this->*build_menu_function)(frame);
1465 menu->set_name ("ArdourContextMenu");
1467 /* now handle specific situations */
1469 switch (item_type) {
1471 case RegionViewName:
1472 case RegionViewNameHighlight:
1473 if (!with_selection) {
1474 if (region_edit_menu_split_item) {
1475 if (clicked_regionview && clicked_regionview->region()->covers (get_preferred_edit_position())) {
1476 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, true);
1478 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, false);
1482 if (region_edit_menu_split_multichannel_item) {
1483 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1484 // GTK2FIX find the action, change its sensitivity
1485 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1487 // GTK2FIX see above
1488 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1497 case CrossfadeViewItem:
1504 /* probably shouldn't happen but if it does, we don't care */
1508 if (item_type != SelectionItem && clicked_routeview && clicked_routeview->audio_track()) {
1510 /* Bounce to disk */
1512 using namespace Menu_Helpers;
1513 MenuList& edit_items = menu->items();
1515 edit_items.push_back (SeparatorElem());
1517 switch (clicked_routeview->audio_track()->freeze_state()) {
1518 case AudioTrack::NoFreeze:
1519 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1522 case AudioTrack::Frozen:
1523 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1526 case AudioTrack::UnFrozen:
1527 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1533 menu->popup (button, time);
1537 Editor::build_track_context_menu (nframes_t ignored)
1539 using namespace Menu_Helpers;
1541 MenuList& edit_items = track_context_menu.items();
1544 add_dstream_context_items (edit_items);
1545 return &track_context_menu;
1549 Editor::build_track_bus_context_menu (nframes_t ignored)
1551 using namespace Menu_Helpers;
1553 MenuList& edit_items = track_context_menu.items();
1556 add_bus_context_items (edit_items);
1557 return &track_context_menu;
1561 Editor::build_track_region_context_menu (nframes_t frame)
1563 using namespace Menu_Helpers;
1564 MenuList& edit_items = track_region_context_menu.items();
1567 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (clicked_axisview);
1570 boost::shared_ptr<Diskstream> ds;
1571 boost::shared_ptr<Playlist> pl;
1573 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
1574 Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)frame * ds->speed()));
1575 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1576 add_region_context_items (rtv->view(), (*i), edit_items);
1582 add_dstream_context_items (edit_items);
1584 return &track_region_context_menu;
1588 Editor::build_track_crossfade_context_menu (nframes_t frame)
1590 using namespace Menu_Helpers;
1591 MenuList& edit_items = track_crossfade_context_menu.items();
1592 edit_items.clear ();
1594 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_axisview);
1597 boost::shared_ptr<Diskstream> ds;
1598 boost::shared_ptr<Playlist> pl;
1599 boost::shared_ptr<AudioPlaylist> apl;
1601 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1603 Playlist::RegionList* regions = pl->regions_at (frame);
1604 AudioPlaylist::Crossfades xfades;
1606 apl->crossfades_at (frame, xfades);
1608 bool many = xfades.size() > 1;
1610 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1611 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1614 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1615 add_region_context_items (atv->audio_view(), (*i), edit_items);
1622 add_dstream_context_items (edit_items);
1624 return &track_crossfade_context_menu;
1629 Editor::analyze_region_selection()
1631 if (analysis_window == 0) {
1632 analysis_window = new AnalysisWindow();
1635 analysis_window->set_session(session);
1637 analysis_window->show_all();
1640 analysis_window->set_regionmode();
1641 analysis_window->analyze();
1643 analysis_window->present();
1647 Editor::analyze_range_selection()
1649 if (analysis_window == 0) {
1650 analysis_window = new AnalysisWindow();
1653 analysis_window->set_session(session);
1655 analysis_window->show_all();
1658 analysis_window->set_rangemode();
1659 analysis_window->analyze();
1661 analysis_window->present();
1663 #endif /* FFT_ANALYSIS */
1666 Editor::build_track_selection_context_menu (nframes_t ignored)
1668 using namespace Menu_Helpers;
1669 MenuList& edit_items = track_selection_context_menu.items();
1670 edit_items.clear ();
1672 add_selection_context_items (edit_items);
1673 // edit_items.push_back (SeparatorElem());
1674 // add_dstream_context_items (edit_items);
1676 return &track_selection_context_menu;
1679 /** Add context menu items relevant to crossfades.
1680 * @param edit_items List to add the items to.
1683 Editor::add_crossfade_context_items (AudioStreamView* view, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1685 using namespace Menu_Helpers;
1686 Menu *xfade_menu = manage (new Menu);
1687 MenuList& items = xfade_menu->items();
1688 xfade_menu->set_name ("ArdourContextMenu");
1691 if (xfade->active()) {
1697 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1698 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1700 if (xfade->can_follow_overlap()) {
1702 if (xfade->following_overlap()) {
1703 str = _("Convert to short");
1705 str = _("Convert to full");
1708 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1712 str = xfade->out()->name();
1714 str += xfade->in()->name();
1716 str = _("Crossfade");
1719 edit_items.push_back (MenuElem (str, *xfade_menu));
1720 edit_items.push_back (SeparatorElem());
1724 Editor::xfade_edit_left_region ()
1726 if (clicked_crossfadeview) {
1727 clicked_crossfadeview->left_view.show_region_editor ();
1732 Editor::xfade_edit_right_region ()
1734 if (clicked_crossfadeview) {
1735 clicked_crossfadeview->right_view.show_region_editor ();
1739 /** Add an element to a menu, settings its sensitivity.
1740 * @param m Menu to add to.
1741 * @param e Element to add.
1742 * @param s true to make sensitive, false to make insensitive
1745 Editor::add_item_with_sensitivity (Menu_Helpers::MenuList& m, Menu_Helpers::MenuElem e, bool s) const
1749 m.back().set_sensitive (false);
1754 Editor::add_region_context_items (StreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1756 using namespace Menu_Helpers;
1757 Menu *region_menu = manage (new Menu);
1758 MenuList& items = region_menu->items();
1759 region_menu->set_name ("ArdourContextMenu");
1761 boost::shared_ptr<AudioRegion> ar;
1762 boost::shared_ptr<MidiRegion> mr;
1765 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1766 mr = boost::dynamic_pointer_cast<MidiRegion> (region);
1769 /* when this particular menu pops up, make the relevant region
1773 region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1775 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &Editor::rename_region)));
1776 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1777 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1778 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1779 items.push_back (SeparatorElem());
1780 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_point)));
1781 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1782 items.push_back (SeparatorElem());
1784 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::play_selected_region)));
1785 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1786 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1790 items.push_back (MenuElem (_("Analyze region"), mem_fun(*this, &Editor::analyze_region_selection)));
1793 items.push_back (SeparatorElem());
1795 sigc::connection fooc;
1797 items.push_back (CheckMenuElem (_("Lock")));
1798 CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1799 fooc = region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
1800 if (region->locked()) {
1802 region_lock_item->set_active();
1805 items.push_back (CheckMenuElem (_("Mute")));
1806 CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1807 fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
1808 if (region->muted()) {
1810 region_mute_item->set_active();
1814 if (!Profile->get_sae()) {
1815 items.push_back (CheckMenuElem (_("Opaque")));
1816 CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1817 fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
1818 if (region->opaque()) {
1820 region_opaque_item->set_active();
1825 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1826 if (region->at_natural_position()) {
1827 items.back().set_sensitive (false);
1830 items.push_back (SeparatorElem());
1834 RegionView* rv = sv->find_view (ar);
1835 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1837 if (!Profile->get_sae()) {
1838 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
1840 items.push_back (CheckMenuElem (_("Envelope Visible")));
1841 CheckMenuItem* region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1842 fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
1843 if (arv->envelope_visible()) {
1845 region_envelope_visible_item->set_active (true);
1849 items.push_back (CheckMenuElem (_("Envelope Active")));
1850 CheckMenuItem* region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1851 fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
1853 if (ar->envelope_active()) {
1855 region_envelope_active_item->set_active (true);
1859 items.push_back (SeparatorElem());
1862 if (ar->scale_amplitude() != 1.0f) {
1863 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1865 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1869 items.push_back (MenuElem (_("Quantize"), mem_fun(*this, &Editor::quantize_region)));
1870 items.push_back (SeparatorElem());
1873 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1874 items.push_back (SeparatorElem());
1876 /* range related stuff */
1878 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1879 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_region)));
1880 items.push_back (SeparatorElem());
1884 Menu *nudge_menu = manage (new Menu());
1885 MenuList& nudge_items = nudge_menu->items();
1886 nudge_menu->set_name ("ArdourContextMenu");
1888 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1889 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1890 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1891 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1893 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1894 items.push_back (SeparatorElem());
1896 Menu *trim_menu = manage (new Menu);
1897 MenuList& trim_items = trim_menu->items();
1898 trim_menu->set_name ("ArdourContextMenu");
1900 trim_items.push_back (MenuElem (_("Start to edit point"), mem_fun(*this, &Editor::trim_region_from_edit_point)));
1901 trim_items.push_back (MenuElem (_("Edit point to end"), mem_fun(*this, &Editor::trim_region_to_edit_point)));
1902 trim_items.push_back (MenuElem (_("Trim To Loop"), mem_fun(*this, &Editor::trim_region_to_loop)));
1903 trim_items.push_back (MenuElem (_("Trim To Punch"), mem_fun(*this, &Editor::trim_region_to_punch)));
1905 items.push_back (MenuElem (_("Trim"), *trim_menu));
1906 items.push_back (SeparatorElem());
1908 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1909 region_edit_menu_split_item = &items.back();
1911 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1912 region_edit_menu_split_multichannel_item = &items.back();
1914 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), false))));
1915 items.push_back (MenuElem (_("Multi-Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1916 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1917 items.push_back (SeparatorElem());
1918 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1920 /* OK, stick the region submenu at the top of the list, and then add
1924 /* we have to hack up the region name because "_" has a special
1925 meaning for menu titles.
1928 string::size_type pos = 0;
1929 string menu_item_name = region->name();
1931 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1932 menu_item_name.replace (pos, 1, "__");
1936 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1937 edit_items.push_back (SeparatorElem());
1940 /** Add context menu items relevant to selection ranges.
1941 * @param edit_items List to add the items to.
1944 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1946 using namespace Menu_Helpers;
1947 Menu *selection_menu = manage (new Menu);
1948 MenuList& items = selection_menu->items();
1949 selection_menu->set_name ("ArdourContextMenu");
1951 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1952 items.push_back (MenuElem (_("Loop range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
1955 items.push_back (SeparatorElem());
1956 items.push_back (MenuElem (_("Analyze range"), mem_fun(*this, &Editor::analyze_range_selection)));
1959 items.push_back (SeparatorElem());
1960 items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
1961 items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
1963 items.push_back (SeparatorElem());
1964 items.push_back (MenuElem (_("Convert to region in-place"), mem_fun(*this, &Editor::separate_region_from_selection)));
1965 items.push_back (MenuElem (_("Convert to region in region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1967 items.push_back (SeparatorElem());
1968 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1970 items.push_back (SeparatorElem());
1971 items.push_back (MenuElem (_("Set loop from selection"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
1972 items.push_back (MenuElem (_("Set punch from selection"), mem_fun(*this, &Editor::set_punch_from_selection)));
1974 items.push_back (SeparatorElem());
1975 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
1976 items.push_back (SeparatorElem());
1977 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1978 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1979 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1980 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::create_named_selection)));
1981 items.push_back (SeparatorElem());
1982 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1983 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1988 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1990 using namespace Menu_Helpers;
1994 Menu *play_menu = manage (new Menu);
1995 MenuList& play_items = play_menu->items();
1996 play_menu->set_name ("ArdourContextMenu");
1998 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
1999 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2000 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
2001 play_items.push_back (SeparatorElem());
2002 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
2004 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2008 Menu *select_menu = manage (new Menu);
2009 MenuList& select_items = select_menu->items();
2010 select_menu->set_name ("ArdourContextMenu");
2012 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2013 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2014 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2015 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2016 select_items.push_back (SeparatorElem());
2017 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
2018 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
2019 select_items.push_back (SeparatorElem());
2020 select_items.push_back (MenuElem (_("Select All After Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2021 select_items.push_back (MenuElem (_("Select All Before Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2022 select_items.push_back (MenuElem (_("Select All After Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2023 select_items.push_back (MenuElem (_("Select All Before Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2024 select_items.push_back (MenuElem (_("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), false)));
2025 select_items.push_back (MenuElem (_("Select All Within Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), true)));
2026 select_items.push_back (MenuElem (_("Select Range Between Playhead & Edit Point"), mem_fun(*this, &Editor::select_range_between)));
2028 select_items.push_back (SeparatorElem());
2030 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2034 Menu *cutnpaste_menu = manage (new Menu);
2035 MenuList& cutnpaste_items = cutnpaste_menu->items();
2036 cutnpaste_menu->set_name ("ArdourContextMenu");
2038 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2039 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2040 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2042 cutnpaste_items.push_back (SeparatorElem());
2044 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
2045 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
2047 cutnpaste_items.push_back (SeparatorElem());
2049 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
2051 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
2053 /* Adding new material */
2055 edit_items.push_back (SeparatorElem());
2056 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
2057 edit_items.push_back (MenuElem (_("Insert Existing Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
2061 Menu *nudge_menu = manage (new Menu());
2062 MenuList& nudge_items = nudge_menu->items();
2063 nudge_menu->set_name ("ArdourContextMenu");
2065 edit_items.push_back (SeparatorElem());
2066 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2067 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2068 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2069 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2071 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2075 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
2077 using namespace Menu_Helpers;
2081 Menu *play_menu = manage (new Menu);
2082 MenuList& play_items = play_menu->items();
2083 play_menu->set_name ("ArdourContextMenu");
2085 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
2086 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2087 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2091 Menu *select_menu = manage (new Menu);
2092 MenuList& select_items = select_menu->items();
2093 select_menu->set_name ("ArdourContextMenu");
2095 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2096 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2097 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2098 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2099 select_items.push_back (SeparatorElem());
2100 select_items.push_back (MenuElem (_("Select all after edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2101 select_items.push_back (MenuElem (_("Select all before edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2102 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2103 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2105 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2109 Menu *cutnpaste_menu = manage (new Menu);
2110 MenuList& cutnpaste_items = cutnpaste_menu->items();
2111 cutnpaste_menu->set_name ("ArdourContextMenu");
2113 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2114 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2115 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2117 Menu *nudge_menu = manage (new Menu());
2118 MenuList& nudge_items = nudge_menu->items();
2119 nudge_menu->set_name ("ArdourContextMenu");
2121 edit_items.push_back (SeparatorElem());
2122 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2123 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2124 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2125 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2127 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2130 /* CURSOR SETTING AND MARKS AND STUFF */
2133 Editor::set_snap_to (SnapType st)
2135 unsigned int snap_ind = (unsigned int)st;
2138 if ( snap_ind > snap_type_strings.size() - 1 ) {
2140 snap_type = (SnapType)snap_ind;
2143 string str = snap_type_strings[snap_ind];
2145 if (str != snap_type_selector.get_active_text()) {
2146 snap_type_selector.set_active_text (str);
2151 switch (snap_type) {
2152 case SnapToAThirtysecondBeat:
2153 case SnapToASixteenthBeat:
2154 case SnapToAEighthBeat:
2155 case SnapToAQuarterBeat:
2156 case SnapToAThirdBeat:
2157 compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + (nframes_t)(canvas_width * frames_per_unit));
2158 update_tempo_based_rulers ();
2167 Editor::set_snap_mode (SnapMode mode)
2170 string str = snap_mode_strings[(int)mode];
2172 if (str != snap_mode_selector.get_active_text ()) {
2173 snap_mode_selector.set_active_text (str);
2179 Editor::set_edit_point_preference (EditPoint ep)
2181 bool changed = _edit_point != ep;
2184 string str = edit_point_strings[(int)ep];
2186 if (str != edit_point_selector.get_active_text ()) {
2187 edit_point_selector.set_active_text (str);
2194 if (Profile->get_sae()) {
2196 switch (zoom_focus) {
2197 case ZoomFocusMouse:
2198 case ZoomFocusPlayhead:
2200 switch (_edit_point) {
2202 set_zoom_focus (ZoomFocusMouse);
2204 case EditAtPlayhead:
2205 set_zoom_focus (ZoomFocusPlayhead);
2207 case EditAtSelectedMarker:
2208 set_zoom_focus (ZoomFocusEdit);
2221 Editor::set_state (const XMLNode& node)
2223 const XMLProperty* prop;
2225 int x, y, xoff, yoff;
2228 if ((prop = node.property ("id")) != 0) {
2229 _id = prop->value ();
2232 if ((geometry = find_named_node (node, "geometry")) == 0) {
2234 g.base_width = default_width;
2235 g.base_height = default_height;
2243 g.base_width = atoi(geometry->property("x_size")->value());
2244 g.base_height = atoi(geometry->property("y_size")->value());
2245 x = atoi(geometry->property("x_pos")->value());
2246 y = atoi(geometry->property("y_pos")->value());
2247 xoff = atoi(geometry->property("x_off")->value());
2248 yoff = atoi(geometry->property("y_off")->value());
2251 set_default_size (g.base_width, g.base_height);
2254 if (session && (prop = node.property ("playhead"))) {
2255 nframes_t pos = atol (prop->value().c_str());
2256 playhead_cursor->set_position (pos);
2258 playhead_cursor->set_position (0);
2260 /* reset_x_origin() doesn't work right here, since the old
2261 position may be zero already, and it does nothing in such
2266 horizontal_adjustment.set_value (0);
2269 if ((prop = node.property ("mixer-width"))) {
2270 editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
2273 if ((prop = node.property ("zoom-focus"))) {
2274 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2277 if ((prop = node.property ("zoom"))) {
2278 reset_zoom (PBD::atof (prop->value()));
2281 if ((prop = node.property ("snap-to"))) {
2282 set_snap_to ((SnapType) atoi (prop->value()));
2285 if ((prop = node.property ("snap-mode"))) {
2286 set_snap_mode ((SnapMode) atoi (prop->value()));
2289 if ((prop = node.property ("edit-point"))) {
2290 set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point));
2293 if ((prop = node.property ("mouse-mode"))) {
2294 MouseMode m = str2mousemode(prop->value());
2295 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2296 set_mouse_mode (m, true);
2298 mouse_mode = MouseGain; /* lie, to force the mode switch */
2299 set_mouse_mode (MouseObject, true);
2302 if ((prop = node.property ("show-waveforms"))) {
2303 bool yn = (prop->value() == "yes");
2304 _show_waveforms = !yn;
2305 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
2307 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2308 /* do it twice to force the change */
2309 tact->set_active (!yn);
2310 tact->set_active (yn);
2314 if ((prop = node.property ("show-waveforms-recording"))) {
2315 bool yn = (prop->value() == "yes");
2316 _show_waveforms_recording = !yn;
2317 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2319 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2320 /* do it twice to force the change */
2321 tact->set_active (!yn);
2322 tact->set_active (yn);
2326 if ((prop = node.property ("show-measures"))) {
2327 bool yn = (prop->value() == "yes");
2328 _show_measures = !yn;
2329 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2331 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2332 /* do it twice to force the change */
2333 tact->set_active (!yn);
2334 tact->set_active (yn);
2338 if ((prop = node.property ("follow-playhead"))) {
2339 bool yn = (prop->value() == "yes");
2340 set_follow_playhead (yn);
2341 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2343 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2344 if (tact->get_active() != yn) {
2345 tact->set_active (yn);
2350 if ((prop = node.property ("region-list-sort-type"))) {
2351 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2352 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2355 if ((prop = node.property ("xfades-visible"))) {
2356 bool yn = (prop->value() == "yes");
2357 _xfade_visibility = !yn;
2358 // set_xfade_visibility (yn);
2361 if ((prop = node.property ("show-editor-mixer"))) {
2363 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2366 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2367 bool yn = (prop->value() == X_("yes"));
2369 /* do it twice to force the change */
2371 tact->set_active (!yn);
2372 tact->set_active (yn);
2376 if ((prop = node.property ("show-editor-list"))) {
2378 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2382 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2383 bool yn = (prop->value() == X_("yes"));
2385 /* do it twice to force the change */
2387 tact->set_active (!yn);
2388 tact->set_active (yn);
2397 Editor::get_state ()
2399 XMLNode* node = new XMLNode ("Editor");
2402 _id.print (buf, sizeof (buf));
2403 node->add_property ("id", buf);
2405 if (is_realized()) {
2406 Glib::RefPtr<Gdk::Window> win = get_window();
2408 int x, y, xoff, yoff, width, height;
2409 win->get_root_origin(x, y);
2410 win->get_position(xoff, yoff);
2411 win->get_size(width, height);
2413 XMLNode* geometry = new XMLNode ("geometry");
2415 snprintf(buf, sizeof(buf), "%d", width);
2416 geometry->add_property("x_size", string(buf));
2417 snprintf(buf, sizeof(buf), "%d", height);
2418 geometry->add_property("y_size", string(buf));
2419 snprintf(buf, sizeof(buf), "%d", x);
2420 geometry->add_property("x_pos", string(buf));
2421 snprintf(buf, sizeof(buf), "%d", y);
2422 geometry->add_property("y_pos", string(buf));
2423 snprintf(buf, sizeof(buf), "%d", xoff);
2424 geometry->add_property("x_off", string(buf));
2425 snprintf(buf, sizeof(buf), "%d", yoff);
2426 geometry->add_property("y_off", string(buf));
2427 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2428 geometry->add_property("edit_pane_pos", string(buf));
2430 node->add_child_nocopy (*geometry);
2433 maybe_add_mixer_strip_width (*node);
2435 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2436 node->add_property ("zoom-focus", buf);
2437 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2438 node->add_property ("zoom", buf);
2439 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2440 node->add_property ("snap-to", buf);
2441 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2442 node->add_property ("snap-mode", buf);
2444 node->add_property ("edit-point", enum_2_string (_edit_point));
2446 snprintf (buf, sizeof (buf), "%" PRIu32, playhead_cursor->current_frame);
2447 node->add_property ("playhead", buf);
2449 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2450 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2451 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2452 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2453 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2454 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2455 node->add_property ("mouse-mode", enum2str(mouse_mode));
2457 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2459 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2460 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2463 act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2465 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2466 node->add_property (X_("show-editor-list"), tact->get_active() ? "yes" : "no");
2475 Editor::trackview_by_y_position (double y)
2477 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2481 if ((tv = (*iter)->covers_y_position (y)) != 0) {
2490 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
2492 Location* before = 0;
2493 Location* after = 0;
2495 if (!session || snap_mode == SnapOff) {
2499 const nframes64_t one_second = session->frame_rate();
2500 const nframes64_t one_minute = session->frame_rate() * 60;
2501 const nframes64_t one_smpte_second = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
2502 nframes64_t one_smpte_minute = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
2503 nframes64_t presnap = start;
2505 switch (snap_type) {
2508 start = (nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2510 start = (nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2514 case SnapToSMPTEFrame:
2515 if (fmod((double)start, (double)session->frames_per_smpte_frame()) > (session->frames_per_smpte_frame() / 2)) {
2516 start = (nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2518 start = (nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2522 case SnapToSMPTESeconds:
2523 if (session->smpte_offset_negative())
2525 start += session->smpte_offset ();
2527 start -= session->smpte_offset ();
2529 if (start % one_smpte_second > one_smpte_second / 2) {
2530 start = (nframes_t) ceil ((double) start / one_smpte_second) * one_smpte_second;
2532 start = (nframes_t) floor ((double) start / one_smpte_second) * one_smpte_second;
2535 if (session->smpte_offset_negative())
2537 start -= session->smpte_offset ();
2539 start += session->smpte_offset ();
2543 case SnapToSMPTEMinutes:
2544 if (session->smpte_offset_negative())
2546 start += session->smpte_offset ();
2548 start -= session->smpte_offset ();
2550 if (start % one_smpte_minute > one_smpte_minute / 2) {
2551 start = (nframes_t) ceil ((double) start / one_smpte_minute) * one_smpte_minute;
2553 start = (nframes_t) floor ((double) start / one_smpte_minute) * one_smpte_minute;
2555 if (session->smpte_offset_negative())
2557 start -= session->smpte_offset ();
2559 start += session->smpte_offset ();
2564 if (start % one_second > one_second / 2) {
2565 start = (nframes_t) ceil ((double) start / one_second) * one_second;
2567 start = (nframes_t) floor ((double) start / one_second) * one_second;
2572 if (start % one_minute > one_minute / 2) {
2573 start = (nframes_t) ceil ((double) start / one_minute) * one_minute;
2575 start = (nframes_t) floor ((double) start / one_minute) * one_minute;
2580 start = session->tempo_map().round_to_bar (start, direction);
2584 start = session->tempo_map().round_to_beat (start, direction);
2587 case SnapToAThirtysecondBeat:
2588 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2591 case SnapToASixteenthBeat:
2592 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2595 case SnapToAEighthBeat:
2596 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2599 case SnapToAQuarterBeat:
2600 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2603 case SnapToAThirdBeat:
2604 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2612 before = session->locations()->first_location_before (start);
2613 after = session->locations()->first_location_after (start);
2615 if (direction < 0) {
2617 start = before->start();
2621 } else if (direction > 0) {
2623 start = after->start();
2625 start = session->current_end_frame();
2630 /* find nearest of the two */
2631 if ((start - before->start()) < (after->start() - start)) {
2632 start = before->start();
2634 start = after->start();
2637 start = before->start();
2640 start = after->start();
2647 case SnapToRegionStart:
2648 case SnapToRegionEnd:
2649 case SnapToRegionSync:
2650 case SnapToRegionBoundary:
2651 if (!region_boundary_cache.empty()) {
2652 vector<nframes_t>::iterator i;
2654 if (direction > 0) {
2655 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2657 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2660 if (i != region_boundary_cache.end()) {
2663 start = region_boundary_cache.back();
2669 switch (snap_mode) {
2675 if (presnap > start) {
2676 if (presnap > (start + unit_to_frame(snap_threshold))) {
2680 } else if (presnap < start) {
2681 if (presnap < (start - unit_to_frame(snap_threshold))) {
2687 /* handled at entry */
2694 Editor::snap_length_beats (nframes_t start)
2700 /* FIXME: This could/should also work with non-tempo based snap settings (ie seconds) */
2702 switch (snap_type) {
2704 return session->tempo_map().meter_at(start).beats_per_bar();
2709 case SnapToAThirtysecondBeat:
2710 return 1.0 / (double)32.0;
2713 case SnapToASixteenthBeat:
2714 return 1.0 / (double)16.0;
2717 case SnapToAEighthBeat:
2718 return 1.0 / (double)8.0;
2721 case SnapToAQuarterBeat:
2722 return 1.0 / (double)4.0;
2725 case SnapToAThirdBeat:
2726 return 1.0 / (double)3.0;
2734 Editor::setup_toolbar ()
2739 const guint32 FUDGE = 38; // Combo's are stupid - they steal space from the entry for the button
2741 const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
2744 /* Mode Buttons (tool selection) */
2746 vector<ToggleButton *> mouse_mode_buttons;
2748 mouse_move_button.add (*(manage (new Image (::get_icon("tool_object")))));
2749 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2750 mouse_mode_buttons.push_back (&mouse_move_button);
2752 if (!Profile->get_sae()) {
2753 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2754 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2755 mouse_mode_buttons.push_back (&mouse_select_button);
2757 mouse_gain_button.add (*(manage (new Image (::get_icon("tool_gain")))));
2758 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2759 mouse_mode_buttons.push_back (&mouse_gain_button);
2762 mouse_zoom_button.add (*(manage (new Image (::get_icon("tool_zoom")))));
2763 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2764 mouse_mode_buttons.push_back (&mouse_zoom_button);
2765 mouse_timefx_button.add (*(manage (new Image (::get_icon("tool_stretch")))));
2766 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2767 mouse_mode_buttons.push_back (&mouse_timefx_button);
2768 mouse_audition_button.add (*(manage (new Image (::get_icon("tool_audition")))));
2769 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2770 mouse_note_button.add (*(manage (new Image (::get_icon("tool_note")))));
2771 mouse_note_button.set_relief(Gtk::RELIEF_NONE);
2772 mouse_mode_buttons.push_back (&mouse_note_button);
2773 mouse_mode_buttons.push_back (&mouse_audition_button);
2775 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2777 HBox* mode_box = manage(new HBox);
2778 mode_box->set_border_width (2);
2779 mode_box->set_spacing(4);
2780 mouse_mode_button_box.set_spacing(1);
2781 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2782 if (!Profile->get_sae()) {
2783 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2785 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2786 if (!Profile->get_sae()) {
2787 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2789 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2790 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2791 mouse_mode_button_box.pack_start(mouse_note_button, true, true);
2792 mouse_mode_button_box.set_homogeneous(true);
2794 vector<string> edit_mode_strings;
2795 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2796 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2798 edit_mode_selector.set_name ("EditModeSelector");
2799 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, longest (edit_mode_strings).c_str(), 2+FUDGE, 10);
2800 set_popdown_strings (edit_mode_selector, edit_mode_strings);
2801 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2803 mode_box->pack_start(edit_mode_selector);
2804 mode_box->pack_start(mouse_mode_button_box);
2806 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2807 mouse_mode_tearoff->set_name ("MouseModeBase");
2809 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2810 &mouse_mode_tearoff->tearoff_window()));
2811 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2812 &mouse_mode_tearoff->tearoff_window(), 1));
2813 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2814 &mouse_mode_tearoff->tearoff_window()));
2815 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2816 &mouse_mode_tearoff->tearoff_window(), 1));
2818 mouse_move_button.set_name ("MouseModeButton");
2819 mouse_select_button.set_name ("MouseModeButton");
2820 mouse_gain_button.set_name ("MouseModeButton");
2821 mouse_zoom_button.set_name ("MouseModeButton");
2822 mouse_timefx_button.set_name ("MouseModeButton");
2823 mouse_audition_button.set_name ("MouseModeButton");
2824 mouse_note_button.set_name ("MouseModeButton");
2826 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
2827 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
2828 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
2829 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
2830 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
2831 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
2832 ARDOUR_UI::instance()->tooltips().set_tip (mouse_note_button, _("Edit MIDI Notes"));
2834 mouse_move_button.unset_flags (CAN_FOCUS);
2835 mouse_select_button.unset_flags (CAN_FOCUS);
2836 mouse_gain_button.unset_flags (CAN_FOCUS);
2837 mouse_zoom_button.unset_flags (CAN_FOCUS);
2838 mouse_timefx_button.unset_flags (CAN_FOCUS);
2839 mouse_audition_button.unset_flags (CAN_FOCUS);
2840 mouse_note_button.unset_flags (CAN_FOCUS);
2842 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2843 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2845 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2846 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2847 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2848 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2849 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2850 mouse_note_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseNote));
2852 // mouse_move_button.set_active (true);
2857 zoom_box.set_spacing (1);
2858 zoom_box.set_border_width (0);
2860 zoom_in_button.set_name ("EditorTimeButton");
2861 zoom_in_button.set_size_request(-1,16);
2862 zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in")))));
2863 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2864 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2866 zoom_out_button.set_name ("EditorTimeButton");
2867 zoom_out_button.set_size_request(-1,16);
2868 zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out")))));
2869 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2870 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2872 zoom_out_full_button.set_name ("EditorTimeButton");
2873 zoom_out_full_button.set_size_request(-1,16);
2874 zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full")))));
2875 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2876 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2878 zoom_focus_selector.set_name ("ZoomFocusSelector");
2879 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, _("Playhead"), FUDGE, 0);
2880 set_popdown_strings (zoom_focus_selector, zoom_focus_strings);
2881 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2882 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
2884 zoom_box.pack_start (zoom_focus_selector, true, true);
2885 zoom_box.pack_start (zoom_out_button, false, false);
2886 zoom_box.pack_start (zoom_in_button, false, false);
2887 zoom_box.pack_start (zoom_out_full_button, false, false);
2889 snap_box.set_spacing (1);
2890 snap_box.set_border_width (2);
2892 snap_type_selector.set_name ("SnapTypeSelector");
2893 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, _("SMPTE Seconds"), 2+FUDGE, 10);
2894 set_popdown_strings (snap_type_selector, snap_type_strings);
2895 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2896 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Snap/Grid Units"));
2898 snap_mode_selector.set_name ("SnapModeSelector");
2899 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, _("Magnetic Snap"), 2+FUDGE, 10);
2900 set_popdown_strings (snap_mode_selector, snap_mode_strings);
2901 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2902 ARDOUR_UI::instance()->tooltips().set_tip (snap_mode_selector, _("Snap/Grid Mode"));
2904 edit_point_selector.set_name ("SnapModeSelector");
2905 Gtkmm2ext::set_size_request_to_display_given_text (edit_point_selector, _("Playhead"), 2+FUDGE, 10);
2906 set_popdown_strings (edit_point_selector, edit_point_strings);
2907 edit_point_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_point_selection_done));
2908 ARDOUR_UI::instance()->tooltips().set_tip (edit_point_selector, _("Edit point"));
2910 snap_box.pack_start (edit_point_clock, false, false);
2911 snap_box.pack_start (snap_mode_selector, false, false);
2912 snap_box.pack_start (snap_type_selector, false, false);
2913 snap_box.pack_start (edit_point_selector, false, false);
2917 HBox *nudge_box = manage (new HBox);
2918 nudge_box->set_spacing(1);
2919 nudge_box->set_border_width (2);
2921 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2922 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2924 nudge_box->pack_start (nudge_backward_button, false, false);
2925 nudge_box->pack_start (nudge_forward_button, false, false);
2926 nudge_box->pack_start (nudge_clock, false, false);
2929 /* Pack everything in... */
2931 HBox* hbox = manage (new HBox);
2932 hbox->set_spacing(10);
2934 tools_tearoff = manage (new TearOff (*hbox));
2935 tools_tearoff->set_name ("MouseModeBase");
2937 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2938 &tools_tearoff->tearoff_window()));
2939 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2940 &tools_tearoff->tearoff_window(), 0));
2941 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2942 &tools_tearoff->tearoff_window()));
2943 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2944 &tools_tearoff->tearoff_window(), 0));
2946 toolbar_hbox.set_spacing (10);
2947 toolbar_hbox.set_border_width (1);
2949 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2950 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2953 hbox->pack_start (snap_box, false, false);
2954 // hbox->pack_start (zoom_box, false, false);
2955 hbox->pack_start (*nudge_box, false, false);
2959 toolbar_base.set_name ("ToolBarBase");
2960 toolbar_base.add (toolbar_hbox);
2962 toolbar_frame.set_shadow_type (SHADOW_OUT);
2963 toolbar_frame.set_name ("BaseFrame");
2964 toolbar_frame.add (toolbar_base);
2969 Editor::setup_midi_toolbar ()
2973 /* Mode Buttons (tool selection) */
2975 vector<ToggleButton *> midi_tool_buttons;
2977 midi_tool_pencil_button.add (*(manage (new Image (::get_icon("midi_tool_pencil")))));
2978 midi_tool_pencil_button.set_relief(Gtk::RELIEF_NONE);
2979 midi_tool_buttons.push_back (&midi_tool_pencil_button);
2980 midi_tool_select_button.add (*(manage (new Image (::get_icon("midi_tool_select")))));
2981 midi_tool_select_button.set_relief(Gtk::RELIEF_NONE);
2982 midi_tool_buttons.push_back (&midi_tool_select_button);
2983 midi_tool_erase_button.add (*(manage (new Image (::get_icon("midi_tool_erase")))));
2984 midi_tool_erase_button.set_relief(Gtk::RELIEF_NONE);
2985 midi_tool_buttons.push_back (&midi_tool_erase_button);
2987 midi_tool_pencil_button.set_active(true);
2989 midi_tool_button_set = new GroupedButtons (midi_tool_buttons);
2991 midi_tool_button_box.set_border_width (2);
2992 midi_tool_button_box.set_spacing(4);
2993 midi_tool_button_box.set_spacing(1);
2994 midi_tool_button_box.pack_start(midi_tool_pencil_button, true, true);
2995 midi_tool_button_box.pack_start(midi_tool_select_button, true, true);
2996 midi_tool_button_box.pack_start(midi_tool_erase_button, true, true);
2997 midi_tool_button_box.set_homogeneous(true);
2999 midi_tool_pencil_button.set_name ("MouseModeButton");
3000 midi_tool_select_button.set_name ("MouseModeButton");
3001 midi_tool_erase_button.set_name ("MouseModeButton");
3003 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_pencil_button, _("Add/Move/Stretch Notes"));
3004 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_select_button, _("Select/Move Notes"));
3005 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_erase_button, _("Erase Notes"));
3007 midi_tool_pencil_button.unset_flags (CAN_FOCUS);
3008 midi_tool_select_button.unset_flags (CAN_FOCUS);
3009 midi_tool_erase_button.unset_flags (CAN_FOCUS);
3011 midi_tool_pencil_button.signal_toggled().connect (bind (mem_fun(*this,
3012 &Editor::midi_edit_mode_toggled), Editing::MidiEditPencil));
3013 midi_tool_select_button.signal_toggled().connect (bind (mem_fun(*this,
3014 &Editor::midi_edit_mode_toggled), Editing::MidiEditSelect));
3015 midi_tool_erase_button.signal_toggled().connect (bind (mem_fun(*this,
3016 &Editor::midi_edit_mode_toggled), Editing::MidiEditErase));
3018 /* Pack everything in... */
3020 midi_tools_tearoff = manage (new TearOff (midi_tool_button_box));
3021 midi_tools_tearoff->set_name ("MouseModeBase");
3024 midi_tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&midi_toolbar_hbox),
3025 &midi_tools_tearoff->tearoff_window()));
3026 midi_tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&midi_toolbar_hbox),
3027 &midi_tools_tearoff->tearoff_window(), 0));
3028 midi_tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&midi_toolbar_hbox),
3029 &midi_tools_tearoff->tearoff_window()));
3030 midi_tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&midi_toolbar_hbox),
3031 &midi_tools_tearoff->tearoff_window(), 0));
3034 midi_toolbar_hbox.set_spacing (10);
3035 midi_toolbar_hbox.set_border_width (1);
3037 midi_toolbar_hbox.pack_start (*midi_tools_tearoff, false, true);
3039 midi_tool_button_box.show_all ();
3040 midi_toolbar_hbox.show_all();
3041 midi_tools_tearoff->show_all();
3043 midi_toolbar_base.set_name ("ToolBarBase");
3044 midi_toolbar_base.add (midi_toolbar_hbox);
3046 midi_toolbar_frame.set_shadow_type (SHADOW_OUT);
3047 midi_toolbar_frame.set_name ("BaseFrame");
3048 midi_toolbar_frame.add (midi_toolbar_base);
3052 Editor::convert_drop_to_paths (vector<ustring>& paths,
3053 const RefPtr<Gdk::DragContext>& context,
3056 const SelectionData& data,
3065 vector<ustring> uris = data.get_uris();
3069 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
3070 are actually URI lists. So do it by hand.
3073 if (data.get_target() != "text/plain") {
3077 /* Parse the "uri-list" format that Nautilus provides,
3078 where each pathname is delimited by \r\n
3081 const char* p = data.get_text().c_str();
3088 while (g_ascii_isspace (*p))
3092 while (*q && (*q != '\n') && (*q != '\r'))
3098 while (q > p && g_ascii_isspace (*q))
3103 uris.push_back (ustring (p, q - p + 1));
3107 p = strchr (p, '\n');
3117 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
3119 if ((*i).substr (0,7) == "file://") {
3122 PBD::url_decode (p);
3124 // scan forward past three slashes
3126 ustring::size_type slashcnt = 0;
3127 ustring::size_type n = 0;
3128 ustring::iterator x = p.begin();
3130 while (slashcnt < 3 && x != p.end()) {
3133 } else if (slashcnt == 3) {
3140 if (slashcnt != 3 || x == p.end()) {
3141 error << _("malformed URL passed to drag-n-drop code") << endmsg;
3145 paths.push_back (p.substr (n - 1));
3153 Editor::new_tempo_section ()
3159 Editor::map_transport_state ()
3161 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
3163 if (session->transport_stopped()) {
3164 have_pending_keyboard_selection = false;
3167 update_loop_range_view (true);
3172 Editor::State::State (PublicEditor const * e)
3174 selection = new Selection (e);
3177 Editor::State::~State ()
3183 Editor::get_memento () const
3185 State *state = new State (this);
3187 store_state (*state);
3188 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
3192 Editor::store_state (State& state) const
3194 *state.selection = *selection;
3198 Editor::restore_state (State *state)
3200 if (*selection == *state->selection) {
3204 *selection = *state->selection;
3205 time_selection_changed ();
3206 region_selection_changed ();
3208 /* XXX other selection change handlers? */
3212 Editor::begin_reversible_command (string name)
3215 before = &get_state();
3216 session->begin_reversible_command (name);
3221 Editor::commit_reversible_command ()
3224 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
3229 Editor::set_edit_group_solo (Route& route, bool yn)
3231 RouteGroup *edit_group;
3233 if ((edit_group = route.edit_group()) != 0) {
3234 edit_group->apply (&Route::set_solo, yn, this);
3236 route.set_solo (yn, this);
3241 Editor::set_edit_group_mute (Route& route, bool yn)
3243 RouteGroup *edit_group = 0;
3245 if ((edit_group == route.edit_group()) != 0) {
3246 edit_group->apply (&Route::set_mute, yn, this);
3248 route.set_mute (yn, this);
3253 Editor::history_changed ()
3257 if (undo_action && session) {
3258 if (session->undo_depth() == 0) {
3261 label = string_compose(_("Undo (%1)"), session->next_undo());
3263 undo_action->property_label() = label;
3266 if (redo_action && session) {
3267 if (session->redo_depth() == 0) {
3270 label = string_compose(_("Redo (%1)"), session->next_redo());
3272 redo_action->property_label() = label;
3277 Editor::duplicate_dialog (bool with_dialog)
3281 if (mouse_mode == MouseRange) {
3282 if (selection->time.length() == 0) {
3288 if (mouse_mode != MouseRange) {
3290 ensure_entered_region_selected (true);
3292 if (selection->regions.empty()) {
3299 ArdourDialog win ("duplicate dialog");
3300 Label label (_("Duplicate how many times?"));
3301 Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
3302 SpinButton spinner (adjustment);
3304 win.get_vbox()->set_spacing (12);
3305 win.get_vbox()->pack_start (label);
3307 /* dialogs have ::add_action_widget() but that puts the spinner in the wrong
3308 place, visually. so do this by hand.
3311 win.get_vbox()->pack_start (spinner);
3312 spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
3317 win.add_button (Stock::OK, RESPONSE_ACCEPT);
3318 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3320 win.set_position (WIN_POS_MOUSE);
3322 spinner.grab_focus ();
3324 switch (win.run ()) {
3325 case RESPONSE_ACCEPT:
3331 times = adjustment.get_value();
3334 if (mouse_mode == MouseRange) {
3335 duplicate_selection (times);
3337 duplicate_some_regions (selection->regions, times);
3342 Editor::show_verbose_canvas_cursor ()
3344 verbose_canvas_cursor->raise_to_top();
3345 verbose_canvas_cursor->show();
3346 verbose_cursor_visible = true;
3350 Editor::hide_verbose_canvas_cursor ()
3352 verbose_canvas_cursor->hide();
3353 verbose_cursor_visible = false;
3357 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3359 /* XXX get origin of canvas relative to root window,
3360 add x and y and check compared to gdk_screen_{width,height}
3362 verbose_canvas_cursor->property_text() = txt.c_str();
3363 verbose_canvas_cursor->property_x() = x;
3364 verbose_canvas_cursor->property_y() = y;
3368 Editor::set_verbose_canvas_cursor_text (const string & txt)
3370 verbose_canvas_cursor->property_text() = txt.c_str();
3374 Editor::set_edit_mode (EditMode m)
3376 Config->set_edit_mode (m);
3380 Editor::cycle_edit_mode ()
3382 switch (Config->get_edit_mode()) {
3384 Config->set_edit_mode (Splice);
3387 Config->set_edit_mode (Slide);
3393 Editor::edit_mode_selection_done ()
3399 string choice = edit_mode_selector.get_active_text();
3400 EditMode mode = Slide;
3402 if (choice == _("Splice Edit")) {
3404 } else if (choice == _("Slide Edit")) {
3408 Config->set_edit_mode (mode);
3412 Editor::snap_type_selection_done ()
3414 string choice = snap_type_selector.get_active_text();
3415 SnapType snaptype = SnapToBeat;
3417 if (choice == _("Beats/3")) {
3418 snaptype = SnapToAThirdBeat;
3419 } else if (choice == _("Beats/4")) {
3420 snaptype = SnapToAQuarterBeat;
3421 } else if (choice == _("Beats/8")) {
3422 snaptype = SnapToAEighthBeat;
3423 } else if (choice == _("Beats/16")) {
3424 snaptype = SnapToASixteenthBeat;
3425 } else if (choice == _("Beats/32")) {
3426 snaptype = SnapToAThirtysecondBeat;
3427 } else if (choice == _("Beats")) {
3428 snaptype = SnapToBeat;
3429 } else if (choice == _("Bars")) {
3430 snaptype = SnapToBar;
3431 } else if (choice == _("Marks")) {
3432 snaptype = SnapToMark;
3433 } else if (choice == _("Region starts")) {
3434 snaptype = SnapToRegionStart;
3435 } else if (choice == _("Region ends")) {
3436 snaptype = SnapToRegionEnd;
3437 } else if (choice == _("Region bounds")) {
3438 snaptype = SnapToRegionBoundary;
3439 } else if (choice == _("Region syncs")) {
3440 snaptype = SnapToRegionSync;
3441 } else if (choice == _("CD Frames")) {
3442 snaptype = SnapToCDFrame;
3443 } else if (choice == _("SMPTE Frames")) {
3444 snaptype = SnapToSMPTEFrame;
3445 } else if (choice == _("SMPTE Seconds")) {
3446 snaptype = SnapToSMPTESeconds;
3447 } else if (choice == _("SMPTE Minutes")) {
3448 snaptype = SnapToSMPTEMinutes;
3449 } else if (choice == _("Seconds")) {
3450 snaptype = SnapToSeconds;
3451 } else if (choice == _("Minutes")) {
3452 snaptype = SnapToMinutes;
3455 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3457 ract->set_active ();
3462 Editor::snap_mode_selection_done ()
3464 string choice = snap_mode_selector.get_active_text();
3465 SnapMode mode = SnapNormal;
3467 if (choice == _("No Grid")) {
3469 } else if (choice == _("Grid")) {
3471 } else if (choice == _("Magnetic")) {
3472 mode = SnapMagnetic;
3475 RefPtr<RadioAction> ract = snap_mode_action (mode);
3478 ract->set_active (true);
3483 Editor::cycle_edit_point (bool with_marker)
3485 switch (_edit_point) {
3487 set_edit_point_preference (EditAtPlayhead);
3489 case EditAtPlayhead:
3491 set_edit_point_preference (EditAtSelectedMarker);
3493 set_edit_point_preference (EditAtMouse);
3496 case EditAtSelectedMarker:
3497 set_edit_point_preference (EditAtMouse);
3503 Editor::edit_point_selection_done ()
3505 string choice = edit_point_selector.get_active_text();
3506 EditPoint ep = EditAtSelectedMarker;
3508 if (choice == _("Marker")) {
3509 set_edit_point_preference (EditAtSelectedMarker);
3510 } else if (choice == _("Playhead")) {
3511 set_edit_point_preference (EditAtPlayhead);
3513 set_edit_point_preference (EditAtMouse);
3516 RefPtr<RadioAction> ract = edit_point_action (ep);
3519 ract->set_active (true);
3524 Editor::zoom_focus_selection_done ()
3526 string choice = zoom_focus_selector.get_active_text();
3527 ZoomFocus focus_type = ZoomFocusLeft;
3529 if (choice == _("Left")) {
3530 focus_type = ZoomFocusLeft;
3531 } else if (choice == _("Right")) {
3532 focus_type = ZoomFocusRight;
3533 } else if (choice == _("Center")) {
3534 focus_type = ZoomFocusCenter;
3535 } else if (choice == _("Play")) {
3536 focus_type = ZoomFocusPlayhead;
3537 } else if (choice == _("Edit")) {
3538 focus_type = ZoomFocusEdit;
3539 } else if (choice == _("Edit Point")) {
3540 focus_type = ZoomFocusEdit;
3542 focus_type = ZoomFocusMouse;
3545 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3548 ract->set_active ();
3553 Editor::edit_controls_button_release (GdkEventButton* ev)
3555 if (Keyboard::is_context_menu_event (ev)) {
3556 ARDOUR_UI::instance()->add_route (this);
3562 Editor::mouse_select_button_release (GdkEventButton* ev)
3564 /* this handles just right-clicks */
3566 if (ev->button != 3) {
3573 Editor::TrackViewList *
3574 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3577 TrackViewList::iterator i;
3579 v = new TrackViewList;
3581 if (track == 0 && group == 0) {
3585 for (i = track_views.begin(); i != track_views.end (); ++i) {
3589 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3591 /* just the view for this track
3594 v->push_back (track);
3598 /* views for all tracks in the edit group */
3600 for (i = track_views.begin(); i != track_views.end (); ++i) {
3602 if (group == 0 || (*i)->edit_group() == group) {
3612 Editor::set_zoom_focus (ZoomFocus f)
3614 string str = zoom_focus_strings[(int)f];
3616 if (str != zoom_focus_selector.get_active_text()) {
3617 zoom_focus_selector.set_active_text (str);
3620 if (zoom_focus != f) {
3623 ZoomFocusChanged (); /* EMIT_SIGNAL */
3630 Editor::ensure_float (Window& win)
3632 win.set_transient_for (*this);
3636 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3638 /* recover or initialize pane positions. do this here rather than earlier because
3639 we don't want the positions to change the child allocations, which they seem to do.
3645 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3647 static int32_t done;
3650 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3651 width = default_width;
3652 height = default_height;
3654 width = atoi(geometry->property("x_size")->value());
3655 height = atoi(geometry->property("y_size")->value());
3658 if (which == static_cast<Paned*> (&edit_pane)) {
3664 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3665 /* initial allocation is 90% to canvas, 10% to notebook */
3666 pos = (int) floor (alloc.get_width() * 0.90f);
3667 snprintf (buf, sizeof(buf), "%d", pos);
3669 pos = atoi (prop->value());
3672 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3673 edit_pane.set_position (pos);
3674 pre_maximal_pane_position = pos;
3680 Editor::detach_tearoff (Box* b, Window* w)
3682 if (tools_tearoff->torn_off() &&
3683 mouse_mode_tearoff->torn_off()) {
3684 top_hbox.remove (toolbar_frame);
3689 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3691 if (toolbar_frame.get_parent() == 0) {
3692 top_hbox.pack_end (toolbar_frame);
3697 Editor::set_show_measures (bool yn)
3699 if (_show_measures != yn) {
3702 if ((_show_measures = yn) == true) {
3710 Editor::toggle_follow_playhead ()
3712 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3714 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3715 set_follow_playhead (tact->get_active());
3720 Editor::set_follow_playhead (bool yn)
3722 if (_follow_playhead != yn) {
3723 if ((_follow_playhead = yn) == true) {
3725 update_current_screen ();
3732 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
3734 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3736 xfade->set_active (!xfade->active());
3741 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
3743 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3745 xfade->set_follow_overlap (!xfade->following_overlap());
3750 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
3752 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3758 CrossfadeEditor cew (*session, xfade, xfade->fade_in().get_min_y(), 1.0);
3762 switch (cew.run ()) {
3763 case RESPONSE_ACCEPT:
3770 xfade->StateChanged (Change (~0));
3774 Editor::playlist_selector () const
3776 return *_playlist_selector;
3780 Editor::get_nudge_distance (nframes_t pos, nframes_t& next)
3784 ret = nudge_clock.current_duration (pos);
3785 next = ret + 1; /* XXXX fix me */
3791 Editor::end_location_changed (Location* location)
3793 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3794 reset_scrolling_region ();
3798 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
3800 ArdourDialog dialog ("playlist deletion dialog");
3801 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3802 "If left alone, no audio files used by it will be cleaned.\n"
3803 "If deleted, audio files used by it alone by will cleaned."),
3806 dialog.set_position (WIN_POS_CENTER);
3807 dialog.get_vbox()->pack_start (label);
3811 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3812 dialog.add_button (_("Keep playlist"), RESPONSE_REJECT);
3813 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3815 switch (dialog.run ()) {
3816 case RESPONSE_ACCEPT:
3817 /* delete the playlist */
3821 case RESPONSE_REJECT:
3822 /* keep the playlist */
3834 Editor::audio_region_selection_covers (nframes_t where)
3836 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3837 if ((*a)->region()->covers (where)) {
3846 Editor::prepare_for_cleanup ()
3848 cut_buffer->clear_regions ();
3849 cut_buffer->clear_playlists ();
3851 selection->clear_regions ();
3852 selection->clear_playlists ();
3856 Editor::transport_loop_location()
3859 return session->locations()->auto_loop_location();
3866 Editor::transport_punch_location()
3869 return session->locations()->auto_punch_location();
3876 Editor::control_layout_scroll (GdkEventScroll* ev)
3878 switch (ev->direction) {
3880 scroll_tracks_up_line ();
3884 case GDK_SCROLL_DOWN:
3885 scroll_tracks_down_line ();
3889 /* no left/right handling yet */
3897 /** A new snapshot has been selected.
3900 Editor::snapshot_display_selection_changed ()
3902 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
3904 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
3906 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
3908 if (snap_name.length() == 0) {
3912 if (session->snap_name() == snap_name) {
3916 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
3921 Editor::snapshot_display_button_press (GdkEventButton* ev)
3923 if (ev->button == 3) {
3924 /* Right-click on the snapshot list. Work out which snapshot it
3926 Gtk::TreeModel::Path path;
3927 Gtk::TreeViewColumn* col;
3930 snapshot_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, col, cx, cy);
3931 Gtk::TreeModel::iterator iter = snapshot_display_model->get_iter (path);
3933 Gtk::TreeModel::Row row = *iter;
3934 popup_snapshot_context_menu (ev->button, ev->time, row[snapshot_display_columns.real_name]);
3943 /** Pop up the snapshot display context menu.
3944 * @param button Button used to open the menu.
3945 * @param time Menu open time.
3946 * @snapshot_name Name of the snapshot that the menu click was over.
3950 Editor::popup_snapshot_context_menu (int button, int32_t time, Glib::ustring snapshot_name)
3952 using namespace Menu_Helpers;
3954 MenuList& items (snapshot_context_menu.items());
3957 const bool modification_allowed = (session->snap_name() != snapshot_name && session->name() != snapshot_name);
3959 add_item_with_sensitivity (items, MenuElem (_("Remove"), bind (mem_fun (*this, &Editor::remove_snapshot), snapshot_name)), modification_allowed);
3961 add_item_with_sensitivity (items, MenuElem (_("Rename"), bind (mem_fun (*this, &Editor::rename_snapshot), snapshot_name)), modification_allowed);
3963 snapshot_context_menu.popup (button, time);
3967 Editor::rename_snapshot (Glib::ustring old_name)
3969 ArdourPrompter prompter(true);
3973 prompter.set_name ("Prompter");
3974 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
3975 prompter.set_prompt (_("New name of snapshot"));
3976 prompter.set_initial_text (old_name);
3978 if (prompter.run() == RESPONSE_ACCEPT) {
3979 prompter.get_result (new_name);
3980 if (new_name.length()) {
3981 session->rename_state (old_name, new_name);
3982 redisplay_snapshots ();
3989 Editor::remove_snapshot (Glib::ustring name)
3991 vector<string> choices;
3993 std::string prompt = string_compose (_("Do you really want to remove snapshot \"%1\" ?\n(cannot be undone)"), name);
3995 choices.push_back (_("No, do nothing."));
3996 choices.push_back (_("Yes, remove it."));
3998 Gtkmm2ext::Choice prompter (prompt, choices);
4000 if (prompter.run () == 1) {
4001 session->remove_state (name);
4002 redisplay_snapshots ();
4007 Editor::redisplay_snapshots ()
4013 vector<sys::path> state_file_paths;
4015 get_state_files_in_directory (session->session_directory().root_path(),
4018 if (state_file_paths.empty()) return;
4020 vector<string> state_file_names(get_file_names_no_extension(state_file_paths));
4022 snapshot_display_model->clear ();
4024 for (vector<string>::iterator i = state_file_names.begin();
4025 i != state_file_names.end(); ++i)
4027 string statename = (*i);
4028 TreeModel::Row row = *(snapshot_display_model->append());
4030 /* this lingers on in case we ever want to change the visible
4031 name of the snapshot.
4034 string display_name;
4035 display_name = statename;
4037 if (statename == session->snap_name()) {
4038 snapshot_display.get_selection()->select(row);
4041 row[snapshot_display_columns.visible_name] = display_name;
4042 row[snapshot_display_columns.real_name] = statename;
4047 Editor::session_state_saved (string snap_name)
4049 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4050 redisplay_snapshots ();
4054 Editor::maximise_editing_space ()
4056 initial_ruler_update_required = true;
4058 mouse_mode_tearoff->set_visible (false);
4059 tools_tearoff->set_visible (false);
4061 pre_maximal_pane_position = edit_pane.get_position();
4062 pre_maximal_editor_width = this->get_width();
4064 if(post_maximal_pane_position == 0) {
4065 post_maximal_pane_position = edit_pane.get_width();
4070 if(post_maximal_editor_width) {
4071 edit_pane.set_position (post_maximal_pane_position -
4072 abs(post_maximal_editor_width - pre_maximal_editor_width));
4074 edit_pane.set_position (post_maximal_pane_position);
4079 Editor::restore_editing_space ()
4081 initial_ruler_update_required = true;
4083 // user changed width of pane during fullscreen
4084 if(post_maximal_pane_position != edit_pane.get_position()) {
4085 post_maximal_pane_position = edit_pane.get_position();
4090 mouse_mode_tearoff->set_visible (true);
4091 tools_tearoff->set_visible (true);
4092 post_maximal_editor_width = this->get_width();
4095 edit_pane.set_position (
4096 pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width)
4101 * Make new playlists for a given track and also any others that belong
4102 * to the same active edit group.
4107 Editor::new_playlists (TimeAxisView* v)
4109 begin_reversible_command (_("new playlists"));
4110 mapover_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist), v);
4111 commit_reversible_command ();
4115 * Use a copy of the current playlist for a given track and also any others that belong
4116 * to the same active edit group.
4121 Editor::copy_playlists (TimeAxisView* v)
4123 begin_reversible_command (_("copy playlists"));
4124 mapover_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist), v);
4125 commit_reversible_command ();
4129 * Clear the current playlist for a given track and also any others that belong
4130 * to the same active edit group.
4135 Editor::clear_playlists (TimeAxisView* v)
4137 begin_reversible_command (_("clear playlists"));
4138 mapover_tracks (mem_fun (*this, &Editor::mapped_clear_playlist), v);
4139 commit_reversible_command ();
4143 Editor::mapped_use_new_playlist (RouteTimeAxisView& atv, uint32_t sz)
4145 atv.use_new_playlist (sz > 1 ? false : true);
4149 Editor::mapped_use_copy_playlist (RouteTimeAxisView& atv, uint32_t sz)
4151 atv.use_copy_playlist (sz > 1 ? false : true);
4155 Editor::mapped_clear_playlist (RouteTimeAxisView& atv, uint32_t sz)
4157 atv.clear_playlist ();
4161 Editor::on_key_press_event (GdkEventKey* ev)
4163 return key_press_focus_accelerator_handler (*this, ev);
4167 Editor::on_key_release_event (GdkEventKey* ev)
4169 return Gtk::Window::on_key_release_event (ev);
4170 // return key_press_focus_accelerator_handler (*this, ev);
4174 Editor::reset_x_origin (nframes_t frame)
4176 queue_visual_change (frame);
4180 Editor::reset_zoom (double fpu)
4182 queue_visual_change (fpu);
4186 Editor::reposition_and_zoom (nframes_t frame, double fpu)
4188 reset_x_origin (frame);
4193 Editor::swap_visual_state ()
4195 if (last_visual_state.frames_per_unit == 0) {
4200 /* note: the correct functionality here is very dependent on the ordering of
4201 setting zoom focus, horizontal position and finally zoom. this is because
4202 it is set_frames_per_unit() that overwrites last_visual_state.
4205 set_zoom_focus (last_visual_state.zoom_focus);
4206 reposition_and_zoom (last_visual_state.leftmost_frame, last_visual_state.frames_per_unit);
4207 zoomed_to_region = false;
4211 Editor::set_frames_per_unit (double fpu)
4213 /* this is the core function that controls the zoom level of the canvas. it is called
4214 whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
4217 if (fpu == frames_per_unit) {
4226 /* don't allow zooms that fit more than the maximum number
4227 of frames into an 800 pixel wide space.
4230 if (max_frames / fpu < 800.0) {
4234 if (fpu == frames_per_unit) {
4238 last_visual_state.frames_per_unit = frames_per_unit;
4239 last_visual_state.leftmost_frame = leftmost_frame;
4240 last_visual_state.zoom_focus = zoom_focus;
4242 frames_per_unit = fpu;
4247 Editor::post_zoom ()
4249 // convert fpu to frame count
4251 nframes_t frames = (nframes_t) floor (frames_per_unit * canvas_width);
4253 if (frames_per_unit != zoom_range_clock.current_duration()) {
4254 zoom_range_clock.set (frames);
4257 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
4258 if (!selection->tracks.empty()) {
4259 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4260 (*i)->reshow_selection (selection->time);
4263 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4264 (*i)->reshow_selection (selection->time);
4269 ZoomChanged (); /* EMIT_SIGNAL */
4271 reset_hscrollbar_stepping ();
4272 reset_scrolling_region ();
4274 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
4280 Editor::queue_visual_change (nframes_t where)
4282 pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::TimeOrigin);
4283 pending_visual_change.time_origin = where;
4285 if (pending_visual_change.idle_handler_id < 0) {
4286 pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
4291 Editor::queue_visual_change (double fpu)
4293 pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::ZoomLevel);
4294 pending_visual_change.frames_per_unit = fpu;
4296 if (pending_visual_change.idle_handler_id < 0) {
4297 pending_visual_change.idle_handler_id = g_idle_add ( _idle_visual_changer, this);
4303 Editor::_idle_visual_changer (void* arg)
4305 return static_cast<Editor*>(arg)->idle_visual_changer ();
4309 Editor::idle_visual_changer ()
4311 VisualChange::Type p = pending_visual_change.pending;
4313 pending_visual_change.pending = (VisualChange::Type) 0;
4315 if (p & VisualChange::ZoomLevel) {
4316 set_frames_per_unit (pending_visual_change.frames_per_unit);
4318 compute_fixed_ruler_scale ();
4319 compute_current_bbt_points(pending_visual_change.time_origin, pending_visual_change.time_origin + (nframes_t)(canvas_width * pending_visual_change.frames_per_unit));
4320 compute_bbt_ruler_scale (pending_visual_change.time_origin, pending_visual_change.time_origin + (nframes_t)(canvas_width * pending_visual_change.frames_per_unit));
4321 update_tempo_based_rulers ();
4323 if (p & VisualChange::TimeOrigin) {
4325 nframes_t time_origin = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4327 if (time_origin != pending_visual_change.time_origin) {
4328 horizontal_adjustment.set_value (pending_visual_change.time_origin/frames_per_unit);
4330 update_fixed_rulers();
4331 redisplay_tempo (true);
4334 pending_visual_change.idle_handler_id = -1;
4336 return 0; /* this is always a one-shot call */
4339 struct EditorOrderTimeAxisSorter {
4340 bool operator() (const TimeAxisView* a, const TimeAxisView* b) const {
4341 return a->order < b->order;
4346 Editor::sort_track_selection (TrackSelection* sel)
4348 EditorOrderTimeAxisSorter cmp;
4353 selection->tracks.sort (cmp);
4358 Editor::get_preferred_edit_position (bool ignore_playhead)
4361 nframes64_t where = 0;
4362 EditPoint ep = _edit_point;
4364 if (entered_marker) {
4365 return entered_marker->position();
4368 if (ignore_playhead && ep == EditAtPlayhead) {
4369 ep = EditAtSelectedMarker;
4373 case EditAtPlayhead:
4374 where = session->audible_frame();
4377 case EditAtSelectedMarker:
4378 if (!selection->markers.empty()) {
4380 Location* loc = find_location_from_marker (selection->markers.front(), is_start);
4383 where = loc->start();
4394 if (!mouse_frame (where, ignored)) {
4395 /* XXX not right but what can we do ? */
4406 Editor::set_loop_range (nframes_t start, nframes_t end, string cmd)
4408 if (!session) return;
4410 begin_reversible_command (cmd);
4414 if ((tll = transport_loop_location()) == 0) {
4415 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoLoop);
4416 XMLNode &before = session->locations()->get_state();
4417 session->locations()->add (loc, true);
4418 session->set_auto_loop_location (loc);
4419 XMLNode &after = session->locations()->get_state();
4420 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4423 XMLNode &before = tll->get_state();
4424 tll->set_hidden (false, this);
4425 tll->set (start, end);
4426 XMLNode &after = tll->get_state();
4427 session->add_command (new MementoCommand<Location>(*tll, &before, &after));
4430 commit_reversible_command ();
4434 Editor::set_punch_range (nframes_t start, nframes_t end, string cmd)
4436 if (!session) return;
4438 begin_reversible_command (cmd);
4442 if ((tpl = transport_punch_location()) == 0) {
4443 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoPunch);
4444 XMLNode &before = session->locations()->get_state();
4445 session->locations()->add (loc, true);
4446 session->set_auto_loop_location (loc);
4447 XMLNode &after = session->locations()->get_state();
4448 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4451 XMLNode &before = tpl->get_state();
4452 tpl->set_hidden (false, this);
4453 tpl->set (start, end);
4454 XMLNode &after = tpl->get_state();
4455 session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
4458 commit_reversible_command ();
4462 Editor::get_regions_at (nframes64_t where, const TrackSelection& ts) const
4465 const TrackSelection* tracks;
4468 tracks = &track_views;
4473 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4475 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*t);
4478 boost::shared_ptr<Diskstream> ds;
4479 boost::shared_ptr<Playlist> pl;
4481 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
4483 Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)where * ds->speed()));
4485 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4487 RegionView* rv = atv->audio_view()->find_view (*i);
4504 Editor::get_regions_after (nframes64_t where, const TrackSelection& ts) const
4507 const TrackSelection* tracks;
4510 tracks = &track_views;
4515 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4517 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*t);
4520 boost::shared_ptr<Diskstream> ds;
4521 boost::shared_ptr<Playlist> pl;
4523 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
4525 Playlist::RegionList* regions = pl->regions_touched ((nframes_t) floor ( (double)where * ds->speed()), max_frames);
4527 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4529 RegionView* rv = atv->audio_view()->find_view (*i);
4545 Editor::get_regions_for_action ()
4547 if (!selection->regions.empty()) {
4548 return selection->regions;
4551 nframes64_t where = get_preferred_edit_position();
4552 tmp_regions = get_regions_at (where, selection->tracks);
4557 Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<RegionView*>& regions)
4560 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4562 RouteTimeAxisView* tatv;
4564 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
4566 boost::shared_ptr<Playlist> pl;
4567 vector<boost::shared_ptr<Region> > results;
4569 boost::shared_ptr<Diskstream> ds;
4571 if ((ds = tatv->get_diskstream()) == 0) {
4576 if ((pl = (ds->playlist())) != 0) {
4577 pl->get_region_list_equivalent_regions (region, results);
4580 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
4581 if ((marv = tatv->view()->find_view (*ir)) != 0) {
4582 regions.push_back (marv);