2 Copyright (C) 2000-2006 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.
27 #include <sigc++/bind.h>
29 #include <pbd/convert.h>
30 #include <pbd/error.h>
31 #include <pbd/memento_command.h>
33 #include <gtkmm/image.h>
34 #include <gdkmm/color.h>
35 #include <gdkmm/bitmap.h>
37 #include <gtkmm2ext/gtk_ui.h>
38 #include <gtkmm2ext/tearoff.h>
39 #include <gtkmm2ext/utils.h>
41 #include <ardour/audio_track.h>
42 #include <ardour/audio_diskstream.h>
43 #include <ardour/plugin_manager.h>
44 #include <ardour/location.h>
45 #include <ardour/audioplaylist.h>
46 #include <ardour/audioregion.h>
47 #include <ardour/region.h>
48 #include <ardour/session_route.h>
49 #include <ardour/tempo.h>
50 #include <ardour/utils.h>
52 #include <control_protocol/control_protocol.h>
54 #include "ardour_ui.h"
56 #include "grouped_buttons.h"
59 #include "playlist_selector.h"
60 #include "audio_region_view.h"
61 #include "rgb_macros.h"
62 #include "selection.h"
63 #include "audio_streamview.h"
64 #include "time_axis_view.h"
65 #include "audio_time_axis.h"
67 #include "crossfade_view.h"
69 #include "public_editor.h"
70 #include "crossfade_edit.h"
71 #include "audio_time_axis.h"
72 #include "canvas_impl.h"
74 #include "gui_thread.h"
77 #include "analysis_window.h"
83 #include "imageframe_socket_handler.h"
84 /* </CMT Additions> */
88 using namespace ARDOUR;
92 using namespace Gtkmm2ext;
93 using namespace Editing;
97 const double Editor::timebar_height = 15.0;
99 #include "editor_xpms"
101 static const gchar *_snap_type_strings[] = {
125 static const gchar *_snap_mode_strings[] = {
131 static const gchar *_zoom_focus_strings[] = {
140 /* Soundfile drag-n-drop */
142 Gdk::Cursor* Editor::cross_hair_cursor = 0;
143 Gdk::Cursor* Editor::selector_cursor = 0;
144 Gdk::Cursor* Editor::trimmer_cursor = 0;
145 Gdk::Cursor* Editor::grabber_cursor = 0;
146 Gdk::Cursor* Editor::zoom_cursor = 0;
147 Gdk::Cursor* Editor::time_fx_cursor = 0;
148 Gdk::Cursor* Editor::fader_cursor = 0;
149 Gdk::Cursor* Editor::speaker_cursor = 0;
150 Gdk::Cursor* Editor::wait_cursor = 0;
151 Gdk::Cursor* Editor::timebar_cursor = 0;
154 show_me_the_size (Requisition* r, const char* what)
156 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
160 check_adjustment (Gtk::Adjustment* adj)
162 cerr << "CHANGE adj = "
163 << adj->get_lower () << ' '
164 << adj->get_upper () << ' '
165 << adj->get_value () << ' '
166 << adj->get_step_increment () << ' '
167 << adj->get_page_increment () << ' '
168 << adj->get_page_size () << ' '
173 Editor::Editor (AudioEngine& eng)
176 /* time display buttons */
178 minsec_label (_("Mins:Secs")),
179 bbt_label (_("Bars:Beats")),
180 smpte_label (_("Timecode")),
181 frame_label (_("Frames")),
182 tempo_label (_("Tempo")),
183 meter_label (_("Meter")),
184 mark_label (_("Location Markers")),
185 range_mark_label (_("Range Markers")),
186 transport_mark_label (_("Loop/Punch Ranges")),
188 edit_packer (3, 3, false),
190 /* the values here don't matter: layout widgets
191 reset them as needed.
194 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
195 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
197 /* tool bar related */
199 edit_cursor_clock (X_("editcursor"), false, X_("EditCursorClock"), true),
200 zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true),
202 toolbar_selection_clock_table (2,3),
204 automation_mode_button (_("mode")),
205 global_automation_button (_("automation")),
207 /* <CMT Additions> */
208 image_socket_listener(0),
209 /* </CMT Additions> */
213 nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true)
218 /* we are a singleton */
220 PublicEditor::_instance = this;
224 selection = new Selection;
225 cut_buffer = new Selection;
227 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
228 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
229 selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
230 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
232 clicked_regionview = 0;
233 clicked_trackview = 0;
234 clicked_audio_trackview = 0;
235 clicked_crossfadeview = 0;
236 clicked_control_point = 0;
237 latest_regionview = 0;
238 last_update_frame = 0;
240 current_mixer_strip = 0;
241 current_bbt_points = 0;
243 snap_type_strings = I18N (_snap_type_strings);
244 snap_mode_strings = I18N (_snap_mode_strings);
245 zoom_focus_strings = I18N(_zoom_focus_strings);
247 snap_type = SnapToFrame;
248 set_snap_to (snap_type);
249 snap_mode = SnapNormal;
250 set_snap_mode (snap_mode);
251 snap_threshold = 5.0;
252 bbt_beat_subdivision = 4;
255 autoscroll_active = false;
256 autoscroll_timeout_tag = -1;
257 interthread_progress_window = 0;
263 current_interthread_info = 0;
264 _show_measures = true;
265 _show_waveforms = true;
266 _show_waveforms_recording = true;
267 first_action_message = 0;
269 show_gain_after_trim = false;
270 ignore_route_list_reorder = false;
271 no_route_list_redisplay = false;
272 verbose_cursor_on = true;
273 route_removal = false;
275 show_automatic_regions_in_region_list = true;
276 region_list_sort_type = (Editing::RegionListSortType) 0;
277 have_pending_keyboard_selection = false;
278 _follow_playhead = true;
279 _xfade_visibility = true;
280 editor_ruler_menu = 0;
281 no_ruler_shown_update = false;
282 edit_group_list_menu = 0;
284 region_list_menu = 0;
286 start_end_marker_menu = 0;
287 range_marker_menu = 0;
288 marker_menu_item = 0;
290 transport_marker_menu = 0;
291 new_transport_marker_menu = 0;
292 editor_mixer_strip_width = Wide;
293 show_editor_mixer_when_tracks_arrive = false;
294 repos_zoom_queued = false;
295 region_edit_menu_split_item = 0;
297 region_edit_menu_split_multichannel_item = 0;
299 ignore_mouse_mode_toggle = false;
300 current_stepping_trackview = 0;
302 entered_regionview = 0;
303 clear_entered_track = false;
304 _new_regionviews_show_envelope = false;
305 current_timestretch = 0;
306 in_edit_group_row_change = false;
307 last_canvas_frame = 0;
310 button_release_can_deselect = true;
311 canvas_idle_queued = false;
312 _dragging_playhead = false;
314 location_marker_color = color_map[cLocationMarker];
315 location_range_color = color_map[cLocationRange];
316 location_cd_marker_color = color_map[cLocationCDMarker];
317 location_loop_color = color_map[cLocationLoop];
318 location_punch_color = color_map[cLocationPunch];
320 range_marker_drag_rect = 0;
321 marker_drag_line = 0;
323 set_mouse_mode (MouseObject, true);
325 frames_per_unit = 2048; /* too early to use set_frames_per_unit */
326 reset_hscrollbar_stepping ();
328 zoom_focus = ZoomFocusLeft;
329 set_zoom_focus (ZoomFocusLeft);
330 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
332 initialize_rulers ();
333 initialize_canvas ();
335 edit_controls_vbox.set_spacing (0);
336 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled));
337 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling));
339 track_canvas.set_hadjustment (horizontal_adjustment);
340 track_canvas.set_vadjustment (vertical_adjustment);
341 time_canvas.set_hadjustment (horizontal_adjustment);
343 track_canvas.signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
344 time_canvas.signal_map_event().connect (mem_fun (*this, &Editor::time_canvas_map_handler));
346 controls_layout.add (edit_controls_vbox);
347 controls_layout.set_name ("EditControlsBase");
348 controls_layout.add_events (Gdk::SCROLL_MASK);
349 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
351 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
352 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
353 controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
355 edit_vscrollbar.set_adjustment (vertical_adjustment);
356 edit_hscrollbar.set_adjustment (horizontal_adjustment);
358 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press));
359 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release));
360 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
365 edit_cursor_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_cursor_clock_changed));
367 time_canvas_vbox.pack_start (*minsec_ruler, false, false);
368 time_canvas_vbox.pack_start (*smpte_ruler, false, false);
369 time_canvas_vbox.pack_start (*frames_ruler, false, false);
370 time_canvas_vbox.pack_start (*bbt_ruler, false, false);
371 time_canvas_vbox.pack_start (time_canvas, true, true);
372 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars));
374 bbt_label.set_name ("EditorTimeButton");
375 bbt_label.set_size_request (-1, (int)timebar_height);
376 bbt_label.set_alignment (1.0, 0.5);
377 bbt_label.set_padding (5,0);
378 minsec_label.set_name ("EditorTimeButton");
379 minsec_label.set_size_request (-1, (int)timebar_height);
380 minsec_label.set_alignment (1.0, 0.5);
381 minsec_label.set_padding (5,0);
382 smpte_label.set_name ("EditorTimeButton");
383 smpte_label.set_size_request (-1, (int)timebar_height);
384 smpte_label.set_alignment (1.0, 0.5);
385 smpte_label.set_padding (5,0);
386 frame_label.set_name ("EditorTimeButton");
387 frame_label.set_size_request (-1, (int)timebar_height);
388 frame_label.set_alignment (1.0, 0.5);
389 frame_label.set_padding (5,0);
390 tempo_label.set_name ("EditorTimeButton");
391 tempo_label.set_size_request (-1, (int)timebar_height);
392 tempo_label.set_alignment (1.0, 0.5);
393 tempo_label.set_padding (5,0);
394 meter_label.set_name ("EditorTimeButton");
395 meter_label.set_size_request (-1, (int)timebar_height);
396 meter_label.set_alignment (1.0, 0.5);
397 meter_label.set_padding (5,0);
398 mark_label.set_name ("EditorTimeButton");
399 mark_label.set_size_request (-1, (int)timebar_height);
400 mark_label.set_alignment (1.0, 0.5);
401 mark_label.set_padding (5,0);
402 range_mark_label.set_name ("EditorTimeButton");
403 range_mark_label.set_size_request (-1, (int)timebar_height);
404 range_mark_label.set_alignment (1.0, 0.5);
405 range_mark_label.set_padding (5,0);
406 transport_mark_label.set_name ("EditorTimeButton");
407 transport_mark_label.set_size_request (-1, (int)timebar_height);
408 transport_mark_label.set_alignment (1.0, 0.5);
409 transport_mark_label.set_padding (5,0);
411 time_button_vbox.pack_start (minsec_label, false, false);
412 time_button_vbox.pack_start (smpte_label, false, false);
413 time_button_vbox.pack_start (frame_label, false, false);
414 time_button_vbox.pack_start (bbt_label, false, false);
415 time_button_vbox.pack_start (meter_label, false, false);
416 time_button_vbox.pack_start (tempo_label, false, false);
417 time_button_vbox.pack_start (mark_label, false, false);
419 time_button_event_box.add (time_button_vbox);
421 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
422 time_button_event_box.set_name ("TimebarLabelBase");
423 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
425 /* these enable us to have a dedicated window (for cursor setting, etc.)
426 for the canvas areas.
429 track_canvas_event_box.add (track_canvas);
431 time_canvas_event_box.add (time_canvas_vbox);
432 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
434 edit_packer.set_col_spacings (0);
435 edit_packer.set_row_spacings (0);
436 edit_packer.set_homogeneous (false);
437 edit_packer.set_border_width (0);
438 edit_packer.set_name ("EditorWindow");
440 edit_packer.attach (edit_vscrollbar, 0, 1, 1, 3, FILL, FILL|EXPAND, 0, 0);
442 edit_packer.attach (time_button_event_box, 1, 2, 0, 1, FILL, FILL, 0, 0);
443 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
445 edit_packer.attach (controls_layout, 1, 2, 1, 2, FILL, FILL|EXPAND, 0, 0);
446 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 2, FILL|EXPAND, FILL|EXPAND, 0, 0);
448 edit_packer.attach (zoom_box, 1, 2, 2, 3, FILL, FILL, 0, 0);
449 edit_packer.attach (edit_hscrollbar, 2, 3, 2, 3, FILL|EXPAND, FILL, 0, 0);
451 bottom_hbox.set_border_width (2);
452 bottom_hbox.set_spacing (3);
454 route_display_model = ListStore::create(route_display_columns);
455 route_list_display.set_model (route_display_model);
456 route_list_display.append_column (_("Show"), route_display_columns.visible);
457 route_list_display.append_column (_("Name"), route_display_columns.text);
458 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
459 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
460 route_list_display.set_headers_visible (true);
461 route_list_display.set_name ("TrackListDisplay");
462 route_list_display.get_selection()->set_mode (SELECTION_NONE);
463 route_list_display.set_reorderable (true);
464 route_list_display.set_size_request (100,-1);
466 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
467 route_list_visible_cell->property_activatable() = true;
468 route_list_visible_cell->property_radio() = false;
470 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
471 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
473 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
475 route_list_scroller.add (route_list_display);
476 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
478 group_model = ListStore::create(group_columns);
479 edit_group_display.set_model (group_model);
480 edit_group_display.append_column (_("Name"), group_columns.text);
481 edit_group_display.append_column (_("Active"), group_columns.is_active);
482 edit_group_display.append_column (_("Show"), group_columns.is_visible);
483 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
484 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
485 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
486 edit_group_display.get_column (0)->set_expand (true);
487 edit_group_display.get_column (1)->set_expand (false);
488 edit_group_display.get_column (2)->set_expand (false);
489 edit_group_display.set_headers_visible (true);
491 /* name is directly editable */
493 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
494 name_cell->property_editable() = true;
495 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
497 /* use checkbox for the active + visible columns */
499 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
500 active_cell->property_activatable() = true;
501 active_cell->property_radio() = false;
503 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
504 active_cell->property_activatable() = true;
505 active_cell->property_radio() = false;
507 edit_group_display.set_name ("EditGroupList");
509 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
511 edit_group_display.set_name ("EditGroupList");
512 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
513 edit_group_display.set_reorderable (false);
514 edit_group_display.set_rules_hint (true);
515 edit_group_display.set_size_request (75, -1);
517 edit_group_display_scroller.add (edit_group_display);
518 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
520 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
522 VBox* edit_group_display_packer = manage (new VBox());
523 HBox* edit_group_display_button_box = manage (new HBox());
524 edit_group_display_button_box->set_homogeneous (true);
526 Button* edit_group_add_button = manage (new Button ());
527 Button* edit_group_remove_button = manage (new Button ());
531 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
533 edit_group_add_button->add (*w);
535 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
537 edit_group_remove_button->add (*w);
539 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
540 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
542 edit_group_display_button_box->pack_start (*edit_group_add_button);
543 edit_group_display_button_box->pack_start (*edit_group_remove_button);
545 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
546 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
548 region_list_display.set_size_request (100, -1);
549 region_list_display.set_name ("RegionListDisplay");
551 region_list_model = TreeStore::create (region_list_columns);
552 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
553 region_list_model->set_sort_column (0, SORT_ASCENDING);
555 region_list_display.set_model (region_list_model);
556 region_list_display.append_column (_("Regions"), region_list_columns.name);
557 region_list_display.set_headers_visible (false);
559 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
561 TreeViewColumn* tv_col = region_list_display.get_column(0);
562 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
563 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
564 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
566 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
567 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
569 /* setup DnD handling */
571 list<TargetEntry> region_list_target_table;
573 region_list_target_table.push_back (TargetEntry ("text/plain"));
574 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
575 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
577 region_list_display.add_drop_targets (region_list_target_table);
578 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
580 region_list_scroller.add (region_list_display);
581 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
583 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
584 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
585 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
586 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
587 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
588 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
590 named_selection_scroller.add (named_selection_display);
591 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
593 named_selection_model = TreeStore::create (named_selection_columns);
594 named_selection_display.set_model (named_selection_model);
595 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
596 named_selection_display.set_headers_visible (false);
597 named_selection_display.set_size_request (100, -1);
598 named_selection_display.set_name ("RegionListDisplay");
600 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
601 named_selection_display.set_size_request (100, -1);
602 named_selection_display.signal_button_release_event().connect (mem_fun(*this, &Editor::named_selection_display_button_press), false);
603 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
607 snapshot_display_model = ListStore::create (snapshot_display_columns);
608 snapshot_display.set_model (snapshot_display_model);
609 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
610 snapshot_display.set_name ("SnapshotDisplayList");
611 snapshot_display.set_size_request (75, -1);
612 snapshot_display.set_headers_visible (false);
613 snapshot_display.set_reorderable (false);
614 snapshot_display_scroller.add (snapshot_display);
615 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
617 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
618 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
622 nlabel = manage (new Label (_("Regions")));
623 nlabel->set_angle (-90);
624 the_notebook.append_page (region_list_scroller, *nlabel);
625 nlabel = manage (new Label (_("Tracks/Busses")));
626 nlabel->set_angle (-90);
627 the_notebook.append_page (route_list_scroller, *nlabel);
628 nlabel = manage (new Label (_("Snapshots")));
629 nlabel->set_angle (-90);
630 the_notebook.append_page (snapshot_display_scroller, *nlabel);
631 nlabel = manage (new Label (_("Edit Groups")));
632 nlabel->set_angle (-90);
633 the_notebook.append_page (*edit_group_display_packer, *nlabel);
634 nlabel = manage (new Label (_("Chunks")));
635 nlabel->set_angle (-90);
636 the_notebook.append_page (named_selection_scroller, *nlabel);
638 the_notebook.set_show_tabs (true);
639 the_notebook.set_scrollable (true);
640 the_notebook.popup_enable ();
641 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
643 post_maximal_editor_width = 0;
644 post_maximal_pane_position = 0;
645 edit_pane.pack1 (edit_packer, true, true);
646 edit_pane.pack2 (the_notebook, false, true);
648 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
650 top_hbox.pack_start (toolbar_frame, true, true);
652 HBox *hbox = manage (new HBox);
653 hbox->pack_start (edit_pane, true, true);
655 global_vpacker.pack_start (top_hbox, false, false);
656 global_vpacker.pack_start (*hbox, true, true);
658 global_hpacker.pack_start (global_vpacker, true, true);
660 set_name ("EditorWindow");
661 add_accel_group (ActionManager::ui_manager->get_accel_group());
663 vpacker.pack_end (global_hpacker, true, true);
665 /* register actions now so that set_state() can find them and set toggles/checks etc */
669 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
672 _playlist_selector = new PlaylistSelector();
673 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
675 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
679 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
680 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
682 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
683 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
685 nudge_forward_button.set_name ("TransportButton");
686 nudge_backward_button.set_name ("TransportButton");
688 fade_context_menu.set_name ("ArdourContextMenu");
690 /* icons, titles, WM stuff */
692 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
693 Glib::RefPtr<Gdk::Pixbuf> icon;
695 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
696 window_icons.push_back (icon);
698 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
699 window_icons.push_back (icon);
701 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
702 window_icons.push_back (icon);
704 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
705 window_icons.push_back (icon);
707 if (!window_icons.empty()) {
708 set_icon_list (window_icons);
709 set_default_icon_list (window_icons);
711 set_title (_("ardour: editor"));
712 set_wmclass (X_("ardour_editor"), "Ardour");
715 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
717 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
718 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
720 /* allow external control surfaces/protocols to do various things */
722 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
723 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
724 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
725 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
727 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
735 /* <CMT Additions> */
736 if(image_socket_listener)
738 if(image_socket_listener->is_connected())
740 image_socket_listener->close_connection() ;
743 delete image_socket_listener ;
744 image_socket_listener = 0 ;
746 /* </CMT Additions> */
750 Editor::add_toplevel_controls (Container& cont)
752 vpacker.pack_start (cont, false, false);
757 Editor::catch_vanishing_regionview (RegionView *rv)
759 /* note: the selection will take care of the vanishing
760 audioregionview by itself.
763 if (clicked_regionview == rv) {
764 clicked_regionview = 0;
767 if (entered_regionview == rv) {
768 set_entered_regionview (0);
773 Editor::set_entered_regionview (RegionView* rv)
775 if (rv == entered_regionview) {
779 if (entered_regionview) {
780 entered_regionview->exited ();
783 if ((entered_regionview = rv) != 0) {
784 entered_regionview->entered ();
789 Editor::set_entered_track (TimeAxisView* tav)
792 entered_track->exited ();
795 if ((entered_track = tav) != 0) {
796 entered_track->entered ();
801 Editor::show_window ()
806 /* now reset all audio_time_axis heights, because widgets might need
812 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
813 tv = (static_cast<TimeAxisView*>(*i));
819 Editor::tie_vertical_scrolling ()
821 double y1 = vertical_adjustment.get_value();
822 controls_layout.get_vadjustment()->set_value (y1);
823 playhead_cursor->set_y_axis(y1);
824 edit_cursor->set_y_axis(y1);
828 Editor::set_frames_per_unit (double fpu)
832 if (fpu == frames_per_unit) {
840 // convert fpu to frame count
842 frames = (nframes_t) floor (fpu * canvas_width);
844 /* don't allow zooms that fit more than the maximum number
845 of frames into an 800 pixel wide space.
848 if (max_frames / fpu < 800.0) {
852 if (fpu == frames_per_unit) {
856 frames_per_unit = fpu;
858 if (frames != zoom_range_clock.current_duration()) {
859 zoom_range_clock.set (frames);
862 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
863 if (!selection->tracks.empty()) {
864 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
865 (*i)->reshow_selection (selection->time);
868 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
869 (*i)->reshow_selection (selection->time);
874 ZoomChanged (); /* EMIT_SIGNAL */
876 reset_hscrollbar_stepping ();
877 reset_scrolling_region ();
879 if (edit_cursor) edit_cursor->set_position (edit_cursor->current_frame);
880 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
887 Editor::instant_save ()
889 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
894 session->add_instant_xml(get_state(), session->path());
896 Config->add_instant_xml(get_state(), get_user_ardour_path());
901 Editor::reposition_x_origin (nframes_t frame)
903 if (frame != leftmost_frame) {
904 leftmost_frame = frame;
906 nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
908 if (rightmost_frame > last_canvas_frame) {
909 last_canvas_frame = rightmost_frame;
910 reset_scrolling_region ();
913 horizontal_adjustment.set_value (frame/frames_per_unit);
915 update_fixed_rulers();
916 tempo_map_changed (Change (0));
921 Editor::edit_cursor_clock_changed()
923 if (edit_cursor->current_frame != edit_cursor_clock.current_time()) {
924 edit_cursor->set_position (edit_cursor_clock.current_time());
930 Editor::zoom_adjustment_changed ()
936 double fpu = zoom_range_clock.current_duration() / canvas_width;
940 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
941 } else if (fpu > session->current_end_frame() / canvas_width) {
942 fpu = session->current_end_frame() / canvas_width;
943 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
950 Editor::control_scroll (float fraction)
952 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
958 double step = fraction * current_page_frames();
961 if ((fraction < 0.0f) && (session->transport_frame() < (nframes_t) fabs(step))) {
963 } else if ((fraction > 0.0f) && (max_frames - session->transport_frame() < step)) {
964 target = (max_frames - (current_page_frames()*2)); // allow room for slop in where the PH is on the screen
966 target = (session->transport_frame() + (nframes_t) floor ((fraction * current_page_frames())));
969 /* move visuals, we'll catch up with it later */
971 playhead_cursor->set_position (target);
973 if (target > (current_page_frames() / 2)) {
974 /* try to center PH in window */
975 reposition_x_origin (target - (current_page_frames()/2));
977 reposition_x_origin (0);
980 /* cancel the existing */
982 control_scroll_connection.disconnect ();
984 /* add the next one */
986 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), target), 50);
990 Editor::deferred_control_scroll (nframes_t target)
992 session->request_locate (target);
997 Editor::canvas_horizontally_scrolled ()
1000 leftmost_frame = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
1001 update_fixed_rulers ();
1002 tempo_map_changed (Change (0));
1007 Editor::reposition_and_zoom (nframes_t frame, double nfpu)
1009 if (!repos_zoom_queued) {
1010 repos_zoom_queued = true;
1011 Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::deferred_reposition_and_zoom), frame, nfpu));
1016 Editor::deferred_reposition_and_zoom (nframes_t frame, double nfpu)
1019 set_frames_per_unit (nfpu);
1020 reposition_x_origin (frame);
1021 repos_zoom_queued = false;
1027 Editor::on_realize ()
1029 Window::on_realize ();
1034 Editor::start_scrolling ()
1036 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1037 (mem_fun(*this, &Editor::update_current_screen));
1041 Editor::stop_scrolling ()
1043 scroll_connection.disconnect ();
1047 Editor::map_position_change (nframes_t frame)
1049 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1051 if (session == 0 || !_follow_playhead) {
1055 center_screen (frame);
1056 playhead_cursor->set_position (frame);
1060 Editor::center_screen (nframes_t frame)
1062 double page = canvas_width * frames_per_unit;
1064 /* if we're off the page, then scroll.
1067 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1068 center_screen_internal (frame, page);
1073 Editor::center_screen_internal (nframes_t frame, float page)
1078 frame -= (nframes_t) page;
1083 reposition_x_origin (frame);
1087 Editor::handle_new_duration ()
1089 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1091 nframes_t new_end = session->get_maximum_extent() + (nframes_t) floorf (current_page_frames() * 0.10f);
1093 if (new_end > last_canvas_frame) {
1094 last_canvas_frame = new_end;
1095 reset_scrolling_region ();
1098 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1102 Editor::update_title_s (const string & snap_name)
1104 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1110 Editor::update_title ()
1112 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1115 bool dirty = session->dirty();
1117 string wintitle = _("ardour: editor: ");
1123 wintitle += session->name();
1125 if (session->snap_name() != session->name()) {
1127 wintitle += session->snap_name();
1134 set_title (wintitle);
1139 Editor::connect_to_session (Session *t)
1143 if (first_action_message) {
1144 first_action_message->hide();
1149 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1150 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1152 /* These signals can all be emitted by a non-GUI thread. Therefore the
1153 handlers for them must not attempt to directly interact with the GUI,
1154 but use Gtkmm2ext::UI::instance()->call_slot();
1157 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1158 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1159 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1160 session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::handle_new_audio_region)));
1161 session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::handle_audio_region_removed)));
1162 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1163 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1164 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1165 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1166 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1167 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1168 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1169 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1170 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1172 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1174 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1176 edit_groups_changed ();
1178 edit_cursor_clock.set_session (session);
1179 zoom_range_clock.set_session (session);
1180 _playlist_selector->set_session (session);
1181 nudge_clock.set_session (session);
1184 if (analysis_window != 0)
1185 analysis_window->set_session (session);
1188 Location* loc = session->locations()->auto_loop_location();
1190 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1191 if (loc->start() == loc->end()) {
1192 loc->set_end (loc->start() + 1);
1194 session->locations()->add (loc, false);
1195 session->set_auto_loop_location (loc);
1199 loc->set_name (_("Loop"));
1202 loc = session->locations()->auto_punch_location();
1204 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1205 if (loc->start() == loc->end()) {
1206 loc->set_end (loc->start() + 1);
1208 session->locations()->add (loc, false);
1209 session->set_auto_punch_location (loc);
1213 loc->set_name (_("Punch"));
1216 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1218 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1220 refresh_location_display ();
1221 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1222 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1223 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1224 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1225 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1227 handle_new_duration ();
1229 redisplay_regions ();
1230 redisplay_named_selections ();
1231 redisplay_snapshots ();
1233 initial_route_list_display ();
1235 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1236 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1239 /* ::reposition_x_origin() doesn't work right here, since the old
1240 position may be zero already, and it does nothing in such
1246 horizontal_adjustment.set_value (0);
1248 restore_ruler_visibility ();
1249 //tempo_map_changed (Change (0));
1250 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1252 edit_cursor->set_position (0);
1253 playhead_cursor->set_position (0);
1257 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1260 /* don't show master bus in a new session */
1262 if (ARDOUR_UI::instance()->session_is_new ()) {
1264 TreeModel::Children rows = route_display_model->children();
1265 TreeModel::Children::iterator i;
1267 no_route_list_redisplay = true;
1269 for (i = rows.begin(); i != rows.end(); ++i) {
1270 TimeAxisView *tv = (*i)[route_display_columns.tv];
1271 AudioTimeAxisView *atv;
1273 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1274 if (atv->route()->master()) {
1275 route_list_display.get_selection()->unselect (i);
1280 no_route_list_redisplay = false;
1281 redisplay_route_list ();
1284 /* register for undo history */
1286 session->register_with_memento_command_factory(_id, this);
1290 Editor::build_cursors ()
1292 using namespace Gdk;
1294 Gdk::Color mbg ("#000000" ); /* Black */
1295 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1298 RefPtr<Bitmap> source, mask;
1299 source = Bitmap::create (mag_bits, mag_width, mag_height);
1300 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1301 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1304 Gdk::Color fbg ("#ffffff" );
1305 Gdk::Color ffg ("#000000" );
1308 RefPtr<Bitmap> source, mask;
1310 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1311 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1312 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1316 RefPtr<Bitmap> source, mask;
1317 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1318 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1319 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1322 grabber_cursor = new Gdk::Cursor (HAND2);
1323 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1324 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1325 selector_cursor = new Gdk::Cursor (XTERM);
1326 time_fx_cursor = new Gdk::Cursor (SIZING);
1327 wait_cursor = new Gdk::Cursor (WATCH);
1328 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1332 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1334 using namespace Menu_Helpers;
1335 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1338 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1342 MenuList& items (fade_context_menu.items());
1346 switch (item_type) {
1348 case FadeInHandleItem:
1349 if (arv->audio_region()->fade_in_active()) {
1350 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), false)));
1352 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), true)));
1355 items.push_back (SeparatorElem());
1357 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::Linear)));
1358 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::LogB)));
1359 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::Fast)));
1360 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::LogA)));
1361 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::Slow)));
1365 case FadeOutHandleItem:
1366 if (arv->audio_region()->fade_out_active()) {
1367 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), false)));
1369 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), true)));
1372 items.push_back (SeparatorElem());
1374 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::Linear)));
1375 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::Fast)));
1376 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::LogB)));
1377 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::LogA)));
1378 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::Slow)));
1383 fatal << _("programming error: ")
1384 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1389 fade_context_menu.popup (button, time);
1393 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes_t frame)
1395 using namespace Menu_Helpers;
1396 Menu* (Editor::*build_menu_function)(nframes_t);
1399 switch (item_type) {
1401 case RegionViewName:
1402 case RegionViewNameHighlight:
1403 if (with_selection) {
1404 build_menu_function = &Editor::build_track_selection_context_menu;
1406 build_menu_function = &Editor::build_track_region_context_menu;
1411 if (with_selection) {
1412 build_menu_function = &Editor::build_track_selection_context_menu;
1414 build_menu_function = &Editor::build_track_context_menu;
1418 case CrossfadeViewItem:
1419 build_menu_function = &Editor::build_track_crossfade_context_menu;
1423 if (clicked_audio_trackview->get_diskstream()) {
1424 build_menu_function = &Editor::build_track_context_menu;
1426 build_menu_function = &Editor::build_track_bus_context_menu;
1431 /* probably shouldn't happen but if it does, we don't care */
1435 menu = (this->*build_menu_function)(frame);
1436 menu->set_name ("ArdourContextMenu");
1438 /* now handle specific situations */
1440 switch (item_type) {
1442 case RegionViewName:
1443 case RegionViewNameHighlight:
1444 if (!with_selection) {
1445 if (region_edit_menu_split_item) {
1446 if (clicked_regionview && clicked_regionview->region()->covers (edit_cursor->current_frame)) {
1447 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
1449 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
1453 if (region_edit_menu_split_multichannel_item) {
1454 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1455 // GTK2FIX find the action, change its sensitivity
1456 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1458 // GTK2FIX see above
1459 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1468 case CrossfadeViewItem:
1475 /* probably shouldn't happen but if it does, we don't care */
1479 if (clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
1481 /* Bounce to disk */
1483 using namespace Menu_Helpers;
1484 MenuList& edit_items = menu->items();
1486 edit_items.push_back (SeparatorElem());
1488 switch (clicked_audio_trackview->audio_track()->freeze_state()) {
1489 case AudioTrack::NoFreeze:
1490 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1493 case AudioTrack::Frozen:
1494 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1497 case AudioTrack::UnFrozen:
1498 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1504 menu->popup (button, time);
1508 Editor::build_track_context_menu (nframes_t ignored)
1510 using namespace Menu_Helpers;
1512 MenuList& edit_items = track_context_menu.items();
1515 add_dstream_context_items (edit_items);
1516 return &track_context_menu;
1520 Editor::build_track_bus_context_menu (nframes_t ignored)
1522 using namespace Menu_Helpers;
1524 MenuList& edit_items = track_context_menu.items();
1527 add_bus_context_items (edit_items);
1528 return &track_context_menu;
1532 Editor::build_track_region_context_menu (nframes_t frame)
1534 using namespace Menu_Helpers;
1535 MenuList& edit_items = track_region_context_menu.items();
1538 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1541 boost::shared_ptr<Diskstream> ds;
1542 boost::shared_ptr<Playlist> pl;
1544 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1545 Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)frame * ds->speed()));
1546 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1547 add_region_context_items (atv->audio_view(), (*i), edit_items);
1553 add_dstream_context_items (edit_items);
1555 return &track_region_context_menu;
1559 Editor::build_track_crossfade_context_menu (nframes_t frame)
1561 using namespace Menu_Helpers;
1562 MenuList& edit_items = track_crossfade_context_menu.items();
1563 edit_items.clear ();
1565 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1568 boost::shared_ptr<Diskstream> ds;
1569 boost::shared_ptr<Playlist> pl;
1570 boost::shared_ptr<AudioPlaylist> apl;
1572 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1574 Playlist::RegionList* regions = pl->regions_at (frame);
1575 AudioPlaylist::Crossfades xfades;
1577 apl->crossfades_at (frame, xfades);
1579 bool many = xfades.size() > 1;
1581 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1582 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1585 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1586 add_region_context_items (atv->audio_view(), (*i), edit_items);
1593 add_dstream_context_items (edit_items);
1595 return &track_crossfade_context_menu;
1600 Editor::analyze_region_selection()
1602 if (analysis_window == 0) {
1603 analysis_window = new AnalysisWindow();
1606 analysis_window->set_session(session);
1608 analysis_window->show_all();
1611 analysis_window->set_regionmode();
1612 analysis_window->analyze();
1614 analysis_window->present();
1618 Editor::analyze_range_selection()
1620 if (analysis_window == 0) {
1621 analysis_window = new AnalysisWindow();
1624 analysis_window->set_session(session);
1626 analysis_window->show_all();
1629 analysis_window->set_rangemode();
1630 analysis_window->analyze();
1632 analysis_window->present();
1634 #endif /* FFT_ANALYSIS */
1639 Editor::build_track_selection_context_menu (nframes_t ignored)
1641 using namespace Menu_Helpers;
1642 MenuList& edit_items = track_selection_context_menu.items();
1643 edit_items.clear ();
1645 add_selection_context_items (edit_items);
1646 add_dstream_context_items (edit_items);
1648 return &track_selection_context_menu;
1652 Editor::add_crossfade_context_items (AudioStreamView* view, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1654 using namespace Menu_Helpers;
1655 Menu *xfade_menu = manage (new Menu);
1656 MenuList& items = xfade_menu->items();
1657 xfade_menu->set_name ("ArdourContextMenu");
1660 if (xfade->active()) {
1666 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1667 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1669 if (xfade->can_follow_overlap()) {
1671 if (xfade->following_overlap()) {
1672 str = _("Convert to short");
1674 str = _("Convert to full");
1677 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1681 str = xfade->out()->name();
1683 str += xfade->in()->name();
1685 str = _("Crossfade");
1688 edit_items.push_back (MenuElem (str, *xfade_menu));
1689 edit_items.push_back (SeparatorElem());
1693 Editor::xfade_edit_left_region ()
1695 if (clicked_crossfadeview) {
1696 clicked_crossfadeview->left_view.show_region_editor ();
1701 Editor::xfade_edit_right_region ()
1703 if (clicked_crossfadeview) {
1704 clicked_crossfadeview->right_view.show_region_editor ();
1709 Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1711 using namespace Menu_Helpers;
1712 Menu *region_menu = manage (new Menu);
1713 MenuList& items = region_menu->items();
1714 region_menu->set_name ("ArdourContextMenu");
1716 boost::shared_ptr<AudioRegion> ar;
1719 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1722 /* when this particular menu pops up, make the relevant region
1726 // region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1728 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1729 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1730 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1731 items.push_back (SeparatorElem());
1732 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_cursor)));
1733 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1734 items.push_back (SeparatorElem());
1736 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::audition_selected_region)));
1737 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1738 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1741 items.push_back (MenuElem (_("Analyze region"), mem_fun(*this, &Editor::analyze_region_selection)));
1744 items.push_back (SeparatorElem());
1746 items.push_back (CheckMenuElem (_("Lock"), mem_fun(*this, &Editor::toggle_region_lock)));
1747 region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1748 if (region->locked()) {
1749 region_lock_item->set_active();
1751 items.push_back (CheckMenuElem (_("Mute"), mem_fun(*this, &Editor::toggle_region_mute)));
1752 region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1753 if (region->muted()) {
1754 region_mute_item->set_active();
1756 items.push_back (CheckMenuElem (_("Opaque"), mem_fun(*this, &Editor::toggle_region_opaque)));
1757 region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1758 if (region->opaque()) {
1759 region_opaque_item->set_active();
1762 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1763 if (region->at_natural_position()) {
1764 items.back().set_sensitive (false);
1767 items.push_back (SeparatorElem());
1771 RegionView* rv = sv->find_view (ar);
1772 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1774 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
1776 items.push_back (CheckMenuElem (_("Envelope Visible"), mem_fun(*this, &Editor::toggle_gain_envelope_visibility)));
1777 region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1779 if (arv->envelope_visible()) {
1780 region_envelope_visible_item->set_active (true);
1783 items.push_back (CheckMenuElem (_("Envelope Active"), mem_fun(*this, &Editor::toggle_gain_envelope_active)));
1784 region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1786 if (ar->envelope_active()) {
1787 region_envelope_active_item->set_active (true);
1790 items.push_back (SeparatorElem());
1792 if (ar->scale_amplitude() != 1.0f) {
1793 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1795 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1798 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1799 items.push_back (SeparatorElem());
1802 /* range related stuff */
1804 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1805 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_audio_region)));
1806 items.push_back (SeparatorElem());
1810 Menu *nudge_menu = manage (new Menu());
1811 MenuList& nudge_items = nudge_menu->items();
1812 nudge_menu->set_name ("ArdourContextMenu");
1814 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1815 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1816 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1817 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1819 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1820 items.push_back (SeparatorElem());
1822 Menu *trim_menu = manage (new Menu);
1823 MenuList& trim_items = trim_menu->items();
1824 trim_menu->set_name ("ArdourContextMenu");
1826 trim_items.push_back (MenuElem (_("Start to edit cursor"), mem_fun(*this, &Editor::trim_region_from_edit_cursor)));
1827 trim_items.push_back (MenuElem (_("Edit cursor to end"), mem_fun(*this, &Editor::trim_region_to_edit_cursor)));
1829 items.push_back (MenuElem (_("Trim"), *trim_menu));
1830 items.push_back (SeparatorElem());
1832 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1833 region_edit_menu_split_item = &items.back();
1835 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1836 region_edit_menu_split_multichannel_item = &items.back();
1838 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1839 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1840 items.push_back (SeparatorElem());
1841 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1843 /* OK, stick the region submenu at the top of the list, and then add
1847 /* we have to hack up the region name because "_" has a special
1848 meaning for menu titles.
1851 string::size_type pos = 0;
1852 string menu_item_name = region->name();
1854 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1855 menu_item_name.replace (pos, 1, "__");
1859 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1860 edit_items.push_back (SeparatorElem());
1864 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1866 using namespace Menu_Helpers;
1867 Menu *selection_menu = manage (new Menu);
1868 MenuList& items = selection_menu->items();
1869 selection_menu->set_name ("ArdourContextMenu");
1871 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1872 items.push_back (MenuElem (_("Loop range"), mem_fun(*this, &Editor::set_route_loop_selection)));
1875 items.push_back (SeparatorElem());
1876 items.push_back (MenuElem (_("Analyze range"), mem_fun(*this, &Editor::analyze_range_selection)));
1879 items.push_back (SeparatorElem());
1880 items.push_back (MenuElem (_("Separate range to track"), mem_fun(*this, &Editor::separate_region_from_selection)));
1881 items.push_back (MenuElem (_("Separate range to region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1883 items.push_back (SeparatorElem());
1884 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1885 items.push_back (SeparatorElem());
1886 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
1887 items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1888 items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1889 items.push_back (SeparatorElem());
1890 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1891 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1892 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1893 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::name_selection)));
1894 items.push_back (SeparatorElem());
1895 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1896 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1898 edit_items.push_back (MenuElem (_("Range"), *selection_menu));
1899 edit_items.push_back (SeparatorElem());
1903 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1905 using namespace Menu_Helpers;
1909 Menu *play_menu = manage (new Menu);
1910 MenuList& play_items = play_menu->items();
1911 play_menu->set_name ("ArdourContextMenu");
1913 play_items.push_back (MenuElem (_("Play from edit cursor"), mem_fun(*this, &Editor::play_from_edit_cursor)));
1914 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1915 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1916 play_items.push_back (SeparatorElem());
1917 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1919 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1923 Menu *select_menu = manage (new Menu);
1924 MenuList& select_items = select_menu->items();
1925 select_menu->set_name ("ArdourContextMenu");
1927 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1928 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1929 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1930 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1931 select_items.push_back (SeparatorElem());
1932 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1933 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1934 select_items.push_back (SeparatorElem());
1935 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1936 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1937 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1938 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1939 select_items.push_back (MenuElem (_("Select all between cursors"), bind (mem_fun(*this, &Editor::select_all_selectables_between_cursors), playhead_cursor, edit_cursor)));
1940 select_items.push_back (SeparatorElem());
1942 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1946 Menu *cutnpaste_menu = manage (new Menu);
1947 MenuList& cutnpaste_items = cutnpaste_menu->items();
1948 cutnpaste_menu->set_name ("ArdourContextMenu");
1950 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1951 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1952 cutnpaste_items.push_back (MenuElem (_("Paste at edit cursor"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1953 cutnpaste_items.push_back (MenuElem (_("Paste at mouse"), mem_fun(*this, &Editor::mouse_paste)));
1955 cutnpaste_items.push_back (SeparatorElem());
1957 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1958 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
1960 cutnpaste_items.push_back (SeparatorElem());
1962 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
1964 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
1966 /* Adding new material */
1968 edit_items.push_back (SeparatorElem());
1969 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
1970 edit_items.push_back (MenuElem (_("Insert Existing Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
1974 Menu *nudge_menu = manage (new Menu());
1975 MenuList& nudge_items = nudge_menu->items();
1976 nudge_menu->set_name ("ArdourContextMenu");
1978 edit_items.push_back (SeparatorElem());
1979 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1980 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1981 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1982 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1984 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1988 Editor::add_bus_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 cursor"), mem_fun(*this, &Editor::play_from_edit_cursor)));
1999 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2000 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2004 Menu *select_menu = manage (new Menu);
2005 MenuList& select_items = select_menu->items();
2006 select_menu->set_name ("ArdourContextMenu");
2008 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2009 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2010 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2011 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2012 select_items.push_back (SeparatorElem());
2013 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
2014 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
2015 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2016 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2018 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2022 Menu *cutnpaste_menu = manage (new Menu);
2023 MenuList& cutnpaste_items = cutnpaste_menu->items();
2024 cutnpaste_menu->set_name ("ArdourContextMenu");
2026 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2027 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2028 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2030 Menu *nudge_menu = manage (new Menu());
2031 MenuList& nudge_items = nudge_menu->items();
2032 nudge_menu->set_name ("ArdourContextMenu");
2034 edit_items.push_back (SeparatorElem());
2035 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2036 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2037 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2038 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2040 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2043 /* CURSOR SETTING AND MARKS AND STUFF */
2046 Editor::set_snap_to (SnapType st)
2049 string str = snap_type_strings[(int) st];
2051 if (str != snap_type_selector.get_active_text()) {
2052 snap_type_selector.set_active_text (str);
2057 switch (snap_type) {
2058 case SnapToAThirtysecondBeat:
2059 case SnapToASixteenthBeat:
2060 case SnapToAEighthBeat:
2061 case SnapToAQuarterBeat:
2062 case SnapToAThirdBeat:
2063 update_tempo_based_rulers ();
2071 Editor::set_snap_mode (SnapMode mode)
2074 string str = snap_mode_strings[(int)mode];
2076 if (str != snap_mode_selector.get_active_text ()) {
2077 snap_mode_selector.set_active_text (str);
2084 Editor::set_state (const XMLNode& node)
2086 const XMLProperty* prop;
2088 int x, y, xoff, yoff;
2091 if ((prop = node.property ("id")) != 0) {
2092 _id = prop->value ();
2095 if ((geometry = find_named_node (node, "geometry")) == 0) {
2097 g.base_width = default_width;
2098 g.base_height = default_height;
2106 g.base_width = atoi(geometry->property("x_size")->value());
2107 g.base_height = atoi(geometry->property("y_size")->value());
2108 x = atoi(geometry->property("x_pos")->value());
2109 y = atoi(geometry->property("y_pos")->value());
2110 xoff = atoi(geometry->property("x_off")->value());
2111 yoff = atoi(geometry->property("y_off")->value());
2114 set_default_size (g.base_width, g.base_height);
2117 if ((prop = node.property ("zoom-focus"))) {
2118 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2121 if ((prop = node.property ("zoom"))) {
2122 set_frames_per_unit (PBD::atof (prop->value()));
2125 if ((prop = node.property ("snap-to"))) {
2126 set_snap_to ((SnapType) atoi (prop->value()));
2129 if ((prop = node.property ("snap-mode"))) {
2130 set_snap_mode ((SnapMode) atoi (prop->value()));
2133 if ((prop = node.property ("mouse-mode"))) {
2134 MouseMode m = str2mousemode(prop->value());
2135 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2136 set_mouse_mode (m, true);
2138 mouse_mode = MouseGain; /* lie, to force the mode switch */
2139 set_mouse_mode (MouseObject, true);
2142 if ((prop = node.property ("show-waveforms"))) {
2143 bool yn = (prop->value() == "yes");
2144 _show_waveforms = !yn;
2145 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
2147 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2148 /* do it twice to force the change */
2149 tact->set_active (!yn);
2150 tact->set_active (yn);
2154 if ((prop = node.property ("show-waveforms-recording"))) {
2155 bool yn = (prop->value() == "yes");
2156 _show_waveforms_recording = !yn;
2157 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2159 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2160 /* do it twice to force the change */
2161 tact->set_active (!yn);
2162 tact->set_active (yn);
2166 if ((prop = node.property ("show-measures"))) {
2167 bool yn = (prop->value() == "yes");
2168 _show_measures = !yn;
2169 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2171 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2172 /* do it twice to force the change */
2173 tact->set_active (!yn);
2174 tact->set_active (yn);
2178 if ((prop = node.property ("follow-playhead"))) {
2179 bool yn = (prop->value() == "yes");
2180 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2182 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2183 /* do it twice to force the change */
2184 tact->set_active (!yn);
2185 tact->set_active (yn);
2190 if ((prop = node.property ("region-list-sort-type"))) {
2191 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2192 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2195 if ((prop = node.property ("xfades-visible"))) {
2196 bool yn = (prop->value() == "yes");
2197 _xfade_visibility = !yn;
2198 // set_xfade_visibility (yn);
2201 if ((prop = node.property ("show-editor-mixer"))) {
2203 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2206 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2207 bool yn = (prop->value() == X_("yes"));
2209 /* do it twice to force the change */
2211 tact->set_active (!yn);
2212 tact->set_active (yn);
2221 Editor::get_state ()
2223 XMLNode* node = new XMLNode ("Editor");
2226 _id.print (buf, sizeof (buf));
2227 node->add_property ("id", buf);
2229 if (is_realized()) {
2230 Glib::RefPtr<Gdk::Window> win = get_window();
2232 int x, y, xoff, yoff, width, height;
2233 win->get_root_origin(x, y);
2234 win->get_position(xoff, yoff);
2235 win->get_size(width, height);
2237 XMLNode* geometry = new XMLNode ("geometry");
2239 snprintf(buf, sizeof(buf), "%d", width);
2240 geometry->add_property("x_size", string(buf));
2241 snprintf(buf, sizeof(buf), "%d", height);
2242 geometry->add_property("y_size", string(buf));
2243 snprintf(buf, sizeof(buf), "%d", x);
2244 geometry->add_property("x_pos", string(buf));
2245 snprintf(buf, sizeof(buf), "%d", y);
2246 geometry->add_property("y_pos", string(buf));
2247 snprintf(buf, sizeof(buf), "%d", xoff);
2248 geometry->add_property("x_off", string(buf));
2249 snprintf(buf, sizeof(buf), "%d", yoff);
2250 geometry->add_property("y_off", string(buf));
2251 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2252 geometry->add_property("edit_pane_pos", string(buf));
2254 node->add_child_nocopy (*geometry);
2257 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2258 node->add_property ("zoom-focus", buf);
2259 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2260 node->add_property ("zoom", buf);
2261 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2262 node->add_property ("snap-to", buf);
2263 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2264 node->add_property ("snap-mode", buf);
2266 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2267 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2268 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2269 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2270 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2271 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2272 node->add_property ("mouse-mode", enum2str(mouse_mode));
2274 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2276 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2277 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2286 Editor::trackview_by_y_position (double y)
2288 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2292 if ((tv = (*iter)->covers_y_position (y)) != 0) {
2301 Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark)
2303 Location* before = 0;
2304 Location* after = 0;
2310 const nframes_t one_second = session->frame_rate();
2311 const nframes_t one_minute = session->frame_rate() * 60;
2312 const nframes_t one_smpte_second = (nframes_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
2313 nframes_t one_smpte_minute = (nframes_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
2314 nframes_t presnap = start;
2316 switch (snap_type) {
2322 start = (nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2324 start = (nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2328 case SnapToSMPTEFrame:
2329 if (fmod((double)start, (double)session->frames_per_smpte_frame()) > (session->frames_per_smpte_frame() / 2)) {
2330 start = (nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2332 start = (nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2336 case SnapToSMPTESeconds:
2337 if (session->smpte_offset_negative())
2339 start += session->smpte_offset ();
2341 start -= session->smpte_offset ();
2343 if (start % one_smpte_second > one_smpte_second / 2) {
2344 start = (nframes_t) ceil ((double) start / one_smpte_second) * one_smpte_second;
2346 start = (nframes_t) floor ((double) start / one_smpte_second) * one_smpte_second;
2349 if (session->smpte_offset_negative())
2351 start -= session->smpte_offset ();
2353 start += session->smpte_offset ();
2357 case SnapToSMPTEMinutes:
2358 if (session->smpte_offset_negative())
2360 start += session->smpte_offset ();
2362 start -= session->smpte_offset ();
2364 if (start % one_smpte_minute > one_smpte_minute / 2) {
2365 start = (nframes_t) ceil ((double) start / one_smpte_minute) * one_smpte_minute;
2367 start = (nframes_t) floor ((double) start / one_smpte_minute) * one_smpte_minute;
2369 if (session->smpte_offset_negative())
2371 start -= session->smpte_offset ();
2373 start += session->smpte_offset ();
2378 if (start % one_second > one_second / 2) {
2379 start = (nframes_t) ceil ((double) start / one_second) * one_second;
2381 start = (nframes_t) floor ((double) start / one_second) * one_second;
2386 if (start % one_minute > one_minute / 2) {
2387 start = (nframes_t) ceil ((double) start / one_minute) * one_minute;
2389 start = (nframes_t) floor ((double) start / one_minute) * one_minute;
2394 start = session->tempo_map().round_to_bar (start, direction);
2398 start = session->tempo_map().round_to_beat (start, direction);
2401 case SnapToAThirtysecondBeat:
2402 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2405 case SnapToASixteenthBeat:
2406 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2409 case SnapToAEighthBeat:
2410 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2413 case SnapToAQuarterBeat:
2414 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2417 case SnapToAThirdBeat:
2418 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2421 case SnapToEditCursor:
2422 start = edit_cursor->current_frame;
2430 before = session->locations()->first_location_before (start);
2431 after = session->locations()->first_location_after (start);
2433 if (direction < 0) {
2435 start = before->start();
2439 } else if (direction > 0) {
2441 start = after->start();
2443 start = session->current_end_frame();
2448 /* find nearest of the two */
2449 if ((start - before->start()) < (after->start() - start)) {
2450 start = before->start();
2452 start = after->start();
2455 start = before->start();
2458 start = after->start();
2465 case SnapToRegionStart:
2466 case SnapToRegionEnd:
2467 case SnapToRegionSync:
2468 case SnapToRegionBoundary:
2469 if (!region_boundary_cache.empty()) {
2470 vector<nframes_t>::iterator i;
2472 if (direction > 0) {
2473 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2475 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2478 if (i != region_boundary_cache.end()) {
2481 start = region_boundary_cache.back();
2487 switch (snap_mode) {
2493 if (presnap > start) {
2494 if (presnap > (start + unit_to_frame(snap_threshold))) {
2498 } else if (presnap < start) {
2499 if (presnap < (start - unit_to_frame(snap_threshold))) {
2511 Editor::setup_toolbar ()
2515 const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
2518 /* Mode Buttons (tool selection) */
2520 vector<ToggleButton *> mouse_mode_buttons;
2522 mouse_move_button.add (*(manage (new Image (::get_icon("tool_object")))));
2523 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2524 mouse_mode_buttons.push_back (&mouse_move_button);
2525 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2526 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2527 mouse_mode_buttons.push_back (&mouse_select_button);
2528 mouse_gain_button.add (*(manage (new Image (::get_icon("tool_gain")))));
2529 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2530 mouse_mode_buttons.push_back (&mouse_gain_button);
2531 mouse_zoom_button.add (*(manage (new Image (::get_icon("tool_zoom")))));
2532 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2533 mouse_mode_buttons.push_back (&mouse_zoom_button);
2534 mouse_timefx_button.add (*(manage (new Image (::get_icon("tool_stretch")))));
2535 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2536 mouse_mode_buttons.push_back (&mouse_timefx_button);
2537 mouse_audition_button.add (*(manage (new Image (::get_icon("tool_audition")))));
2538 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2539 mouse_mode_buttons.push_back (&mouse_audition_button);
2541 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2543 HBox* mode_box = manage(new HBox);
2544 mode_box->set_border_width (2);
2545 mode_box->set_spacing(4);
2546 mouse_mode_button_box.set_spacing(1);
2547 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2548 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2549 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2550 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2551 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2552 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2553 mouse_mode_button_box.set_homogeneous(true);
2555 vector<string> edit_mode_strings;
2556 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2557 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2559 edit_mode_selector.set_name ("EditModeSelector");
2560 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, longest (edit_mode_strings).c_str(), 2+FUDGE, 10);
2561 set_popdown_strings (edit_mode_selector, edit_mode_strings);
2562 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2564 mode_box->pack_start(edit_mode_selector);
2565 mode_box->pack_start(mouse_mode_button_box);
2567 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2568 mouse_mode_tearoff->set_name ("MouseModeBase");
2570 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2571 &mouse_mode_tearoff->tearoff_window()));
2572 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2573 &mouse_mode_tearoff->tearoff_window(), 1));
2574 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2575 &mouse_mode_tearoff->tearoff_window()));
2576 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2577 &mouse_mode_tearoff->tearoff_window(), 1));
2579 mouse_move_button.set_name ("MouseModeButton");
2580 mouse_select_button.set_name ("MouseModeButton");
2581 mouse_gain_button.set_name ("MouseModeButton");
2582 mouse_zoom_button.set_name ("MouseModeButton");
2583 mouse_timefx_button.set_name ("MouseModeButton");
2584 mouse_audition_button.set_name ("MouseModeButton");
2586 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
2587 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
2588 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
2589 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
2590 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
2591 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
2593 mouse_move_button.unset_flags (CAN_FOCUS);
2594 mouse_select_button.unset_flags (CAN_FOCUS);
2595 mouse_gain_button.unset_flags (CAN_FOCUS);
2596 mouse_zoom_button.unset_flags (CAN_FOCUS);
2597 mouse_timefx_button.unset_flags (CAN_FOCUS);
2598 mouse_audition_button.unset_flags (CAN_FOCUS);
2600 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2601 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2603 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2604 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2605 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2606 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2607 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2609 // mouse_move_button.set_active (true);
2614 zoom_box.set_spacing (1);
2615 zoom_box.set_border_width (2);
2617 zoom_in_button.set_name ("EditorTimeButton");
2618 zoom_in_button.set_size_request(-1,16);
2619 zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in")))));
2620 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2621 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2623 zoom_out_button.set_name ("EditorTimeButton");
2624 zoom_out_button.set_size_request(-1,16);
2625 zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out")))));
2626 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2627 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2629 zoom_out_full_button.set_name ("EditorTimeButton");
2630 zoom_out_full_button.set_size_request(-1,16);
2631 zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full")))));
2632 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2633 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2635 zoom_focus_selector.set_name ("ZoomFocusSelector");
2636 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Edit Cursor", FUDGE, 0);
2637 set_popdown_strings (zoom_focus_selector, zoom_focus_strings);
2638 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2639 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
2641 zoom_box.pack_start (zoom_focus_selector, true, true);
2642 zoom_box.pack_start (zoom_out_button, false, false);
2643 zoom_box.pack_start (zoom_in_button, false, false);
2644 zoom_box.pack_start (zoom_out_full_button, false, false);
2646 /* Edit Cursor / Snap */
2648 snap_box.set_spacing (1);
2649 snap_box.set_border_width (2);
2651 snap_type_selector.set_name ("SnapTypeSelector");
2652 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, "SMPTE Seconds", 2+FUDGE, 10);
2653 set_popdown_strings (snap_type_selector, snap_type_strings);
2654 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2655 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Unit to snap cursors and ranges to"));
2657 snap_mode_selector.set_name ("SnapModeSelector");
2658 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, "Magnetic Snap", 2+FUDGE, 10);
2659 set_popdown_strings (snap_mode_selector, snap_mode_strings);
2660 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2662 snap_box.pack_start (edit_cursor_clock, false, false);
2663 snap_box.pack_start (snap_mode_selector, false, false);
2664 snap_box.pack_start (snap_type_selector, false, false);
2669 HBox *nudge_box = manage (new HBox);
2670 nudge_box->set_spacing(1);
2671 nudge_box->set_border_width (2);
2673 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2674 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2676 nudge_box->pack_start (nudge_backward_button, false, false);
2677 nudge_box->pack_start (nudge_forward_button, false, false);
2678 nudge_box->pack_start (nudge_clock, false, false);
2681 /* Pack everything in... */
2683 HBox* hbox = new HBox;
2684 hbox->set_spacing(10);
2686 tools_tearoff = new TearOff (*hbox);
2687 tools_tearoff->set_name ("MouseModeBase");
2689 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2690 &tools_tearoff->tearoff_window()));
2691 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2692 &tools_tearoff->tearoff_window(), 0));
2693 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2694 &tools_tearoff->tearoff_window()));
2695 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2696 &tools_tearoff->tearoff_window(), 0));
2698 toolbar_hbox.set_spacing (10);
2699 toolbar_hbox.set_border_width (1);
2701 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2702 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2705 hbox->pack_start (snap_box, false, false);
2706 // hbox->pack_start (zoom_box, false, false);
2707 hbox->pack_start (*nudge_box, false, false);
2711 toolbar_base.set_name ("ToolBarBase");
2712 toolbar_base.add (toolbar_hbox);
2714 toolbar_frame.set_shadow_type (SHADOW_OUT);
2715 toolbar_frame.set_name ("BaseFrame");
2716 toolbar_frame.add (toolbar_base);
2720 Editor::convert_drop_to_paths (vector<ustring>& paths,
2721 const RefPtr<Gdk::DragContext>& context,
2724 const SelectionData& data,
2733 vector<ustring> uris = data.get_uris();
2737 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
2738 are actually URI lists. So do it by hand.
2741 if (data.get_target() != "text/plain") {
2745 /* Parse the "uri-list" format that Nautilus provides,
2746 where each pathname is delimited by \r\n
2749 const char* p = data.get_text().c_str();
2756 while (g_ascii_isspace (*p))
2760 while (*q && (*q != '\n') && (*q != '\r'))
2766 while (q > p && g_ascii_isspace (*q))
2771 uris.push_back (ustring (p, q - p + 1));
2775 p = strchr (p, '\n');
2785 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
2786 if ((*i).substr (0,7) == "file://") {
2788 PBD::url_decode (p);
2789 paths.push_back (p.substr (7));
2797 Editor::new_tempo_section ()
2803 Editor::map_transport_state ()
2805 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
2807 if (session->transport_stopped()) {
2808 have_pending_keyboard_selection = false;
2814 Editor::State::State ()
2816 selection = new Selection;
2819 Editor::State::~State ()
2825 Editor::get_memento () const
2827 State *state = new State;
2829 store_state (*state);
2830 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
2834 Editor::store_state (State& state) const
2836 *state.selection = *selection;
2840 Editor::restore_state (State *state)
2842 if (*selection == *state->selection) {
2846 *selection = *state->selection;
2847 time_selection_changed ();
2848 region_selection_changed ();
2850 /* XXX other selection change handlers? */
2854 Editor::begin_reversible_command (string name)
2857 before = &get_state();
2858 session->begin_reversible_command (name);
2863 Editor::commit_reversible_command ()
2866 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
2870 struct TrackViewByPositionSorter
2872 bool operator() (const TimeAxisView* a, const TimeAxisView *b) {
2873 return a->y_position < b->y_position;
2878 Editor::extend_selection_to_track (TimeAxisView& view)
2880 if (selection->selected (&view)) {
2881 /* already selected, do nothing */
2885 if (selection->tracks.empty()) {
2887 if (!selection->selected (&view)) {
2888 selection->set (&view);
2895 /* something is already selected, so figure out which range of things to add */
2897 TrackViewList to_be_added;
2898 TrackViewList sorted = track_views;
2899 TrackViewByPositionSorter cmp;
2900 bool passed_clicked = false;
2905 if (!selection->selected (&view)) {
2906 to_be_added.push_back (&view);
2909 /* figure out if we should go forward or backwards */
2911 for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) {
2913 if ((*i) == &view) {
2914 passed_clicked = true;
2917 if (selection->selected (*i)) {
2918 if (passed_clicked) {
2927 passed_clicked = false;
2931 for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) {
2933 if ((*i) == &view) {
2934 passed_clicked = true;
2938 if (passed_clicked) {
2939 if ((*i)->hidden()) {
2942 if (selection->selected (*i)) {
2944 } else if (!(*i)->hidden()) {
2945 to_be_added.push_back (*i);
2952 for (TrackViewList::reverse_iterator r = sorted.rbegin(); r != sorted.rend(); ++r) {
2954 if ((*r) == &view) {
2955 passed_clicked = true;
2959 if (passed_clicked) {
2961 if ((*r)->hidden()) {
2965 if (selection->selected (*r)) {
2967 } else if (!(*r)->hidden()) {
2968 to_be_added.push_back (*r);
2974 if (!to_be_added.empty()) {
2975 selection->add (to_be_added);
2984 Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no_remove)
2986 bool commit = false;
2989 case Selection::Toggle:
2990 if (selection->selected (&view)) {
2992 selection->remove (&view);
2996 selection->add (&view);
3001 case Selection::Add:
3002 if (!selection->selected (&view)) {
3003 selection->add (&view);
3008 case Selection::Set:
3009 if (selection->selected (&view) && selection->tracks.size() == 1) {
3010 /* no commit necessary */
3012 selection->set (&view);
3017 case Selection::Extend:
3018 commit = extend_selection_to_track (view);
3026 Editor::set_selected_track_from_click (Selection::Operation op, bool no_remove)
3028 if (!clicked_trackview) {
3032 return set_selected_track (*clicked_trackview, op, no_remove);
3036 Editor::set_selected_control_point_from_click (Selection::Operation op, bool no_remove)
3038 if (!clicked_control_point) {
3042 /* select this point and any others that it represents */
3047 x1 = pixel_to_frame (clicked_control_point->get_x() - 10);
3048 x2 = pixel_to_frame (clicked_control_point->get_x() + 10);
3049 y1 = clicked_control_point->get_x() - 10;
3050 y2 = clicked_control_point->get_y() + 10;
3052 return select_all_within (x1, x2, y1, y2, op);
3056 Editor::get_relevant_audio_tracks (set<AudioTimeAxisView*>& relevant_tracks)
3058 /* step one: get all selected tracks and all tracks in the relevant edit groups */
3060 for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) {
3062 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*ti);
3068 RouteGroup* group = atv->route()->edit_group();
3070 if (group && group->is_active()) {
3072 /* active group for this track, loop over all tracks and get every member of the group */
3074 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3076 AudioTimeAxisView* tatv;
3078 if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
3080 if (tatv->route()->edit_group() == group) {
3081 relevant_tracks.insert (tatv);
3086 relevant_tracks.insert (atv);
3092 Editor::mapover_audio_tracks (slot<void,AudioTimeAxisView&,uint32_t> sl)
3094 set<AudioTimeAxisView*> relevant_tracks;
3096 get_relevant_audio_tracks (relevant_tracks);
3098 uint32_t sz = relevant_tracks.size();
3100 for (set<AudioTimeAxisView*>::iterator ati = relevant_tracks.begin(); ati != relevant_tracks.end(); ++ati) {
3106 Editor::mapped_set_selected_regionview_from_click (RouteTimeAxisView& tv, uint32_t ignored,
3107 RegionView* basis, vector<RegionView*>* all_equivs)
3109 boost::shared_ptr<Playlist> pl;
3110 vector<boost::shared_ptr<Region> > results;
3112 boost::shared_ptr<Diskstream> ds;
3114 if ((ds = tv.get_diskstream()) == 0) {
3119 if (&tv == &basis->get_time_axis_view()) {
3120 /* looking in same track as the original */
3125 if ((pl = ds->playlist()) != 0) {
3126 pl->get_equivalent_regions (basis->region(), results);
3129 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
3130 if ((marv = tv.view()->find_view (*ir)) != 0) {
3131 all_equivs->push_back (marv);
3137 Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, bool no_track_remove)
3139 vector<RegionView*> all_equivalent_regions;
3140 bool commit = false;
3142 if (!clicked_regionview || !clicked_audio_trackview) {
3146 if (op == Selection::Toggle || op == Selection::Set) {
3148 mapover_audio_tracks (bind (mem_fun (*this, &Editor::mapped_set_selected_regionview_from_click),
3149 clicked_regionview, &all_equivalent_regions));
3152 /* add clicked regionview since we skipped all other regions in the same track as the one it was in */
3154 all_equivalent_regions.push_back (clicked_regionview);
3157 case Selection::Toggle:
3159 if (clicked_regionview->get_selected()) {
3162 /* whatever was clicked was selected already; do nothing here but allow
3163 the button release to deselect it
3166 button_release_can_deselect = true;
3170 if (button_release_can_deselect) {
3172 /* just remove this one region, but only on a permitted button release */
3174 selection->remove (clicked_regionview);
3177 /* no more deselect action on button release till a new press
3178 finds an already selected object.
3181 button_release_can_deselect = false;
3188 /* add all the equivalent regions, but only on button press */
3190 if (!all_equivalent_regions.empty()) {
3194 for (vector<RegionView*>::iterator i = all_equivalent_regions.begin(); i != all_equivalent_regions.end(); ++i) {
3195 selection->add (*i);
3201 case Selection::Set:
3202 if (!clicked_regionview->get_selected()) {
3203 selection->set (all_equivalent_regions);
3206 /* no commit necessary: clicked on an already selected region */
3212 /* silly compiler */
3216 } else if (op == Selection::Extend) {
3218 list<Selectable*> results;
3219 nframes_t last_frame;
3220 nframes_t first_frame;
3222 /* 1. find the last selected regionview in the track that was clicked in */
3225 first_frame = max_frames;
3227 for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
3228 if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) {
3230 if ((*x)->region()->last_frame() > last_frame) {
3231 last_frame = (*x)->region()->last_frame();
3234 if ((*x)->region()->first_frame() < first_frame) {
3235 first_frame = (*x)->region()->first_frame();
3240 /* 2. figure out the boundaries for our search for new objects */
3242 switch (clicked_regionview->region()->coverage (first_frame, last_frame)) {
3244 if (last_frame < clicked_regionview->region()->first_frame()) {
3245 first_frame = last_frame;
3246 last_frame = clicked_regionview->region()->last_frame();
3248 last_frame = first_frame;
3249 first_frame = clicked_regionview->region()->first_frame();
3253 case OverlapExternal:
3254 if (last_frame < clicked_regionview->region()->first_frame()) {
3255 first_frame = last_frame;
3256 last_frame = clicked_regionview->region()->last_frame();
3258 last_frame = first_frame;
3259 first_frame = clicked_regionview->region()->first_frame();
3263 case OverlapInternal:
3264 if (last_frame < clicked_regionview->region()->first_frame()) {
3265 first_frame = last_frame;
3266 last_frame = clicked_regionview->region()->last_frame();
3268 last_frame = first_frame;
3269 first_frame = clicked_regionview->region()->first_frame();
3275 /* nothing to do except add clicked region to selection, since it
3276 overlaps with the existing selection in this track.
3281 /* 2. find all selectable objects (regionviews in this case) between that one and the end of the
3282 one that was clicked.
3285 set<AudioTimeAxisView*> relevant_tracks;
3287 get_relevant_audio_tracks (relevant_tracks);
3289 for (set<AudioTimeAxisView*>::iterator t = relevant_tracks.begin(); t != relevant_tracks.end(); ++t) {
3290 (*t)->get_selectables (first_frame, last_frame, -1.0, -1.0, results);
3293 /* 3. convert to a vector of audio regions */
3295 vector<RegionView*> regions;
3297 for (list<Selectable*>::iterator x = results.begin(); x != results.end(); ++x) {
3300 if ((arv = dynamic_cast<RegionView*>(*x)) != 0) {
3301 regions.push_back (arv);
3305 if (!regions.empty()) {
3306 selection->add (regions);
3316 Editor::set_selected_regionview_from_region_list (boost::shared_ptr<Region> region, Selection::Operation op)
3318 vector<RegionView*> all_equivalent_regions;
3320 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3322 RouteTimeAxisView* tatv;
3324 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
3326 boost::shared_ptr<Playlist> pl;
3327 vector<boost::shared_ptr<Region> > results;
3329 boost::shared_ptr<Diskstream> ds;
3331 if ((ds = tatv->get_diskstream()) == 0) {
3336 if ((pl = (ds->playlist())) != 0) {
3337 pl->get_region_list_equivalent_regions (region, results);
3340 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
3341 if ((marv = tatv->view()->find_view (*ir)) != 0) {
3342 all_equivalent_regions.push_back (marv);
3349 begin_reversible_command (_("set selected regions"));
3352 case Selection::Toggle:
3353 /* XXX this is not correct */
3354 selection->toggle (all_equivalent_regions);
3356 case Selection::Set:
3357 selection->set (all_equivalent_regions);
3359 case Selection::Extend:
3360 selection->add (all_equivalent_regions);
3362 case Selection::Add:
3363 selection->add (all_equivalent_regions);
3367 commit_reversible_command () ;
3371 Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::weak_ptr<Region> weak_r)
3374 boost::shared_ptr<Region> r (weak_r.lock());
3380 boost::shared_ptr<AudioRegion> ar;
3382 if ((ar = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
3386 if ((rv = sv->find_view (ar)) == 0) {
3390 /* don't reset the selection if its something other than
3391 a single other region.
3394 if (selection->regions.size() > 1) {
3398 begin_reversible_command (_("set selected regions"));
3400 selection->set (rv);
3402 commit_reversible_command () ;
3408 Editor::set_edit_group_solo (Route& route, bool yn)
3410 RouteGroup *edit_group;
3412 if ((edit_group = route.edit_group()) != 0) {
3413 edit_group->apply (&Route::set_solo, yn, this);
3415 route.set_solo (yn, this);
3420 Editor::set_edit_group_mute (Route& route, bool yn)
3422 RouteGroup *edit_group = 0;
3424 if ((edit_group == route.edit_group()) != 0) {
3425 edit_group->apply (&Route::set_mute, yn, this);
3427 route.set_mute (yn, this);
3432 Editor::history_changed ()
3436 if (undo_action && session) {
3437 if (session->undo_depth() == 0) {
3440 label = string_compose(_("Undo (%1)"), session->next_undo());
3442 undo_action->property_label() = label;
3445 if (redo_action && session) {
3446 if (session->redo_depth() == 0) {
3449 label = string_compose(_("Redo (%1)"), session->next_redo());
3451 redo_action->property_label() = label;
3456 Editor::duplicate_dialog (bool dup_region)
3459 if (clicked_regionview == 0) {
3463 if (selection->time.length() == 0) {
3468 ArdourDialog win ("duplicate dialog");
3470 Label label (_("Duplicate how many times?"));
3472 win.get_vbox()->pack_start (label);
3473 win.add_action_widget (entry, RESPONSE_ACCEPT);
3474 win.add_button (Stock::OK, RESPONSE_ACCEPT);
3475 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3477 win.set_position (WIN_POS_MOUSE);
3479 entry.set_text ("1");
3480 set_size_request_to_display_given_text (entry, X_("12345678"), 20, 15);
3481 entry.select_region (0, -1);
3482 entry.grab_focus ();
3485 switch (win.run ()) {
3486 case RESPONSE_ACCEPT:
3492 string text = entry.get_text();
3495 if (sscanf (text.c_str(), "%f", ×) == 1) {
3497 RegionSelection regions;
3498 regions.add (clicked_regionview);
3499 duplicate_some_regions (regions, times);
3501 duplicate_selection (times);
3507 Editor::show_verbose_canvas_cursor ()
3509 verbose_canvas_cursor->raise_to_top();
3510 verbose_canvas_cursor->show();
3511 verbose_cursor_visible = true;
3515 Editor::hide_verbose_canvas_cursor ()
3517 verbose_canvas_cursor->hide();
3518 verbose_cursor_visible = false;
3522 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3524 /* XXX get origin of canvas relative to root window,
3525 add x and y and check compared to gdk_screen_{width,height}
3527 verbose_canvas_cursor->property_text() = txt.c_str();
3528 verbose_canvas_cursor->property_x() = x;
3529 verbose_canvas_cursor->property_y() = y;
3533 Editor::set_verbose_canvas_cursor_text (const string & txt)
3535 verbose_canvas_cursor->property_text() = txt.c_str();
3539 Editor::edit_mode_selection_done ()
3545 string choice = edit_mode_selector.get_active_text();
3546 EditMode mode = Slide;
3548 if (choice == _("Splice Edit")) {
3550 } else if (choice == _("Slide Edit")) {
3554 Config->set_edit_mode (mode);
3558 Editor::snap_type_selection_done ()
3560 string choice = snap_type_selector.get_active_text();
3561 SnapType snaptype = SnapToFrame;
3563 if (choice == _("Beats/3")) {
3564 snaptype = SnapToAThirdBeat;
3565 } else if (choice == _("Beats/4")) {
3566 snaptype = SnapToAQuarterBeat;
3567 } else if (choice == _("Beats/8")) {
3568 snaptype = SnapToAEighthBeat;
3569 } else if (choice == _("Beats/16")) {
3570 snaptype = SnapToASixteenthBeat;
3571 } else if (choice == _("Beats/32")) {
3572 snaptype = SnapToAThirtysecondBeat;
3573 } else if (choice == _("Beats")) {
3574 snaptype = SnapToBeat;
3575 } else if (choice == _("Bars")) {
3576 snaptype = SnapToBar;
3577 } else if (choice == _("Marks")) {
3578 snaptype = SnapToMark;
3579 } else if (choice == _("Edit Cursor")) {
3580 snaptype = SnapToEditCursor;
3581 } else if (choice == _("Region starts")) {
3582 snaptype = SnapToRegionStart;
3583 } else if (choice == _("Region ends")) {
3584 snaptype = SnapToRegionEnd;
3585 } else if (choice == _("Region bounds")) {
3586 snaptype = SnapToRegionBoundary;
3587 } else if (choice == _("Region syncs")) {
3588 snaptype = SnapToRegionSync;
3589 } else if (choice == _("CD Frames")) {
3590 snaptype = SnapToCDFrame;
3591 } else if (choice == _("SMPTE Frames")) {
3592 snaptype = SnapToSMPTEFrame;
3593 } else if (choice == _("SMPTE Seconds")) {
3594 snaptype = SnapToSMPTESeconds;
3595 } else if (choice == _("SMPTE Minutes")) {
3596 snaptype = SnapToSMPTEMinutes;
3597 } else if (choice == _("Seconds")) {
3598 snaptype = SnapToSeconds;
3599 } else if (choice == _("Minutes")) {
3600 snaptype = SnapToMinutes;
3601 } else if (choice == _("None")) {
3602 snaptype = SnapToFrame;
3605 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3607 ract->set_active ();
3612 Editor::snap_mode_selection_done ()
3614 string choice = snap_mode_selector.get_active_text();
3615 SnapMode mode = SnapNormal;
3617 if (choice == _("Normal")) {
3619 } else if (choice == _("Magnetic")) {
3620 mode = SnapMagnetic;
3623 RefPtr<RadioAction> ract = snap_mode_action (mode);
3626 ract->set_active (true);
3631 Editor::zoom_focus_selection_done ()
3633 string choice = zoom_focus_selector.get_active_text();
3634 ZoomFocus focus_type = ZoomFocusLeft;
3636 if (choice == _("Left")) {
3637 focus_type = ZoomFocusLeft;
3638 } else if (choice == _("Right")) {
3639 focus_type = ZoomFocusRight;
3640 } else if (choice == _("Center")) {
3641 focus_type = ZoomFocusCenter;
3642 } else if (choice == _("Playhead")) {
3643 focus_type = ZoomFocusPlayhead;
3644 } else if (choice == _("Edit Cursor")) {
3645 focus_type = ZoomFocusEdit;
3648 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3651 ract->set_active ();
3656 Editor::edit_controls_button_release (GdkEventButton* ev)
3658 if (Keyboard::is_context_menu_event (ev)) {
3659 ARDOUR_UI::instance()->add_route ();
3665 Editor::track_selection_changed ()
3667 switch (selection->tracks.size()){
3671 set_selected_mixer_strip (*(selection->tracks.front()));
3675 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3676 (*i)->set_selected (false);
3677 if (mouse_mode == MouseRange) {
3678 (*i)->hide_selection ();
3682 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3683 (*i)->set_selected (true);
3684 if (mouse_mode == MouseRange) {
3685 (*i)->show_selection (selection->time);
3691 Editor::time_selection_changed ()
3693 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3694 (*i)->hide_selection ();
3697 if (selection->tracks.empty()) {
3698 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3699 (*i)->show_selection (selection->time);
3702 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3703 (*i)->show_selection (selection->time);
3707 if (selection->time.empty()) {
3708 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
3710 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true);
3715 Editor::region_selection_changed ()
3717 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3718 (*i)->set_selected_regionviews (selection->regions);
3723 Editor::point_selection_changed ()
3725 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3726 (*i)->set_selected_points (selection->points);
3731 Editor::mouse_select_button_release (GdkEventButton* ev)
3733 /* this handles just right-clicks */
3735 if (ev->button != 3) {
3742 Editor::TrackViewList *
3743 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3746 TrackViewList::iterator i;
3748 v = new TrackViewList;
3750 if (track == 0 && group == 0) {
3754 for (i = track_views.begin(); i != track_views.end (); ++i) {
3758 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3760 /* just the view for this track
3763 v->push_back (track);
3767 /* views for all tracks in the edit group */
3769 for (i = track_views.begin(); i != track_views.end (); ++i) {
3771 if (group == 0 || (*i)->edit_group() == group) {
3781 Editor::set_zoom_focus (ZoomFocus f)
3783 string str = zoom_focus_strings[(int)f];
3785 if (str != zoom_focus_selector.get_active_text()) {
3786 zoom_focus_selector.set_active_text (str);
3789 if (zoom_focus != f) {
3792 ZoomFocusChanged (); /* EMIT_SIGNAL */
3799 Editor::ensure_float (Window& win)
3801 win.set_transient_for (*this);
3805 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3807 /* recover or initialize pane positions. do this here rather than earlier because
3808 we don't want the positions to change the child allocations, which they seem to do.
3814 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3816 static int32_t done;
3819 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3820 width = default_width;
3821 height = default_height;
3823 width = atoi(geometry->property("x_size")->value());
3824 height = atoi(geometry->property("y_size")->value());
3827 if (which == static_cast<Paned*> (&edit_pane)) {
3833 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3834 /* initial allocation is 90% to canvas, 10% to notebook */
3835 pos = (int) floor (alloc.get_width() * 0.90f);
3836 snprintf (buf, sizeof(buf), "%d", pos);
3838 pos = atoi (prop->value());
3841 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3842 edit_pane.set_position (pos);
3843 pre_maximal_pane_position = pos;
3849 Editor::detach_tearoff (Box* b, Window* w)
3851 if (tools_tearoff->torn_off() &&
3852 mouse_mode_tearoff->torn_off()) {
3853 top_hbox.remove (toolbar_frame);
3858 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3860 if (toolbar_frame.get_parent() == 0) {
3861 top_hbox.pack_end (toolbar_frame);
3866 Editor::set_show_measures (bool yn)
3868 if (_show_measures != yn) {
3871 if ((_show_measures = yn) == true) {
3874 DisplayControlChanged (ShowMeasures);
3880 Editor::toggle_follow_playhead ()
3882 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3884 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3885 set_follow_playhead (tact->get_active());
3890 Editor::set_follow_playhead (bool yn)
3892 if (_follow_playhead != yn) {
3893 if ((_follow_playhead = yn) == true) {
3895 update_current_screen ();
3897 DisplayControlChanged (FollowPlayhead);
3903 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
3905 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3907 xfade->set_active (!xfade->active());
3912 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
3914 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3916 xfade->set_follow_overlap (!xfade->following_overlap());
3921 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
3923 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3929 CrossfadeEditor cew (*session, xfade, xfade->fade_in().get_min_y(), 1.0);
3933 switch (cew.run ()) {
3934 case RESPONSE_ACCEPT:
3941 xfade->StateChanged (Change (~0));
3945 Editor::playlist_selector () const
3947 return *_playlist_selector;
3951 Editor::get_nudge_distance (nframes_t pos, nframes_t& next)
3955 ret = nudge_clock.current_duration (pos);
3956 next = ret + 1; /* XXXX fix me */
3962 Editor::end_location_changed (Location* location)
3964 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3965 reset_scrolling_region ();
3969 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
3971 ArdourDialog dialog ("playlist deletion dialog");
3972 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3973 "If left alone, no audio files used by it will be cleaned.\n"
3974 "If deleted, audio files used by it alone by will cleaned."),
3977 dialog.set_position (WIN_POS_CENTER);
3978 dialog.get_vbox()->pack_start (label);
3982 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3983 dialog.add_button (_("Keep playlist"), RESPONSE_CANCEL);
3984 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3986 switch (dialog.run ()) {
3987 case RESPONSE_ACCEPT:
3988 /* delete the playlist */
3992 case RESPONSE_REJECT:
3993 /* keep the playlist */
4005 Editor::audio_region_selection_covers (nframes_t where)
4007 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
4008 if ((*a)->region()->covers (where)) {
4017 Editor::prepare_for_cleanup ()
4019 cut_buffer->clear_regions ();
4020 cut_buffer->clear_playlists ();
4022 selection->clear_regions ();
4023 selection->clear_playlists ();
4027 Editor::transport_loop_location()
4030 return session->locations()->auto_loop_location();
4037 Editor::transport_punch_location()
4040 return session->locations()->auto_punch_location();
4047 Editor::control_layout_scroll (GdkEventScroll* ev)
4049 switch (ev->direction) {
4051 scroll_tracks_up_line ();
4055 case GDK_SCROLL_DOWN:
4056 scroll_tracks_down_line ();
4060 /* no left/right handling yet */
4068 Editor::snapshot_display_selection_changed ()
4070 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
4072 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
4074 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
4076 if (snap_name.length() == 0) {
4080 if (session->snap_name() == snap_name) {
4084 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
4089 Editor::snapshot_display_button_press (GdkEventButton* ev)
4095 Editor::redisplay_snapshots ()
4101 vector<string*>* states;
4103 if ((states = session->possible_states()) == 0) {
4107 snapshot_display_model->clear ();
4109 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
4110 string statename = *(*i);
4111 TreeModel::Row row = *(snapshot_display_model->append());
4113 // we don't have a way of changing the rendering in just one TreeView
4114 // cell so just put an asterisk on each side of the name for now.
4115 string display_name;
4116 if (statename == session->snap_name()) {
4117 display_name = "*"+statename+"*";
4118 snapshot_display.get_selection()->select(row);
4120 display_name = statename;
4123 row[snapshot_display_columns.visible_name] = display_name;
4124 row[snapshot_display_columns.real_name] = statename;
4131 Editor::session_state_saved (string snap_name)
4133 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4134 redisplay_snapshots ();
4138 Editor::maximise_editing_space ()
4140 initial_ruler_update_required = true;
4142 mouse_mode_tearoff->set_visible (false);
4143 tools_tearoff->set_visible (false);
4145 pre_maximal_pane_position = edit_pane.get_position();
4146 pre_maximal_editor_width = this->get_width();
4148 if(post_maximal_pane_position == 0) {
4149 post_maximal_pane_position = edit_pane.get_width();
4154 if(post_maximal_editor_width) {
4155 edit_pane.set_position (post_maximal_pane_position -
4156 abs(post_maximal_editor_width - pre_maximal_editor_width));
4158 edit_pane.set_position (post_maximal_pane_position);
4163 Editor::restore_editing_space ()
4165 initial_ruler_update_required = true;
4167 // user changed width of pane during fullscreen
4168 if(post_maximal_pane_position != edit_pane.get_position()) {
4169 post_maximal_pane_position = edit_pane.get_position();
4174 mouse_mode_tearoff->set_visible (true);
4175 tools_tearoff->set_visible (true);
4176 post_maximal_editor_width = this->get_width();
4179 edit_pane.set_position (
4180 pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width)
4185 Editor::new_playlists ()
4187 begin_reversible_command (_("new playlists"));
4188 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist));
4189 commit_reversible_command ();
4193 Editor::copy_playlists ()
4195 begin_reversible_command (_("copy playlists"));
4196 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist));
4197 commit_reversible_command ();
4201 Editor::clear_playlists ()
4203 begin_reversible_command (_("clear playlists"));
4204 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist));
4205 commit_reversible_command ();
4209 Editor::mapped_use_new_playlist (AudioTimeAxisView& atv, uint32_t sz)
4211 atv.use_new_playlist (sz > 1 ? false : true);
4215 Editor::mapped_use_copy_playlist (AudioTimeAxisView& atv, uint32_t sz)
4217 atv.use_copy_playlist (sz > 1 ? false : true);
4221 Editor::mapped_clear_playlist (AudioTimeAxisView& atv, uint32_t sz)
4223 atv.clear_playlist ();
4227 Editor::on_key_press_event (GdkEventKey* ev)
4229 return key_press_focus_accelerator_handler (*this, ev);