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"
66 #include "crossfade_view.h"
68 #include "public_editor.h"
69 #include "crossfade_edit.h"
70 #include "audio_time_axis.h"
71 #include "canvas_impl.h"
73 #include "gui_thread.h"
76 #include "analysis_window.h"
82 #include "imageframe_socket_handler.h"
83 /* </CMT Additions> */
87 using namespace ARDOUR;
91 using namespace Gtkmm2ext;
92 using namespace Editing;
94 using PBD::internationalize;
97 const double Editor::timebar_height = 15.0;
99 #include "editor_xpms"
101 static const int32_t slide_index = 0;
102 static const int32_t splice_index = 1;
104 static const gchar *edit_mode_strings[] = {
110 static const gchar *snap_type_strings[] = {
134 static const gchar *snap_mode_strings[] = {
140 static const gchar *zoom_focus_strings[] = {
149 /* Soundfile drag-n-drop */
151 Gdk::Cursor* Editor::cross_hair_cursor = 0;
152 Gdk::Cursor* Editor::selector_cursor = 0;
153 Gdk::Cursor* Editor::trimmer_cursor = 0;
154 Gdk::Cursor* Editor::grabber_cursor = 0;
155 Gdk::Cursor* Editor::zoom_cursor = 0;
156 Gdk::Cursor* Editor::time_fx_cursor = 0;
157 Gdk::Cursor* Editor::fader_cursor = 0;
158 Gdk::Cursor* Editor::speaker_cursor = 0;
159 Gdk::Cursor* Editor::wait_cursor = 0;
160 Gdk::Cursor* Editor::timebar_cursor = 0;
163 show_me_the_size (Requisition* r, const char* what)
165 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
169 check_adjustment (Gtk::Adjustment* adj)
171 cerr << "CHANGE adj = "
172 << adj->get_lower () << ' '
173 << adj->get_upper () << ' '
174 << adj->get_value () << ' '
175 << adj->get_step_increment () << ' '
176 << adj->get_page_increment () << ' '
177 << adj->get_page_size () << ' '
182 Editor::Editor (AudioEngine& eng)
185 /* time display buttons */
187 minsec_label (_("Mins:Secs")),
188 bbt_label (_("Bars:Beats")),
189 smpte_label (_("SMPTE")),
190 frame_label (_("Frames")),
191 tempo_label (_("Tempo")),
192 meter_label (_("Meter")),
193 mark_label (_("Location Markers")),
194 range_mark_label (_("Range Markers")),
195 transport_mark_label (_("Loop/Punch Ranges")),
197 edit_packer (3, 3, false),
199 /* the values here don't matter: layout widgets
200 reset them as needed.
203 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
204 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
206 /* tool bar related */
208 edit_cursor_clock (X_("EditCursorClock"), true),
209 zoom_range_clock (X_("ZoomRangeClock"), true, true),
211 toolbar_selection_clock_table (2,3),
213 automation_mode_button (_("mode")),
214 global_automation_button (_("automation")),
216 /* <CMT Additions> */
217 image_socket_listener(0),
218 /* </CMT Additions> */
222 nudge_clock (X_("NudgeClock"), true, true)
227 /* we are a singleton */
229 PublicEditor::_instance = this;
233 selection = new Selection;
234 cut_buffer = new Selection;
236 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
237 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
238 selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
239 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
241 clicked_regionview = 0;
242 clicked_trackview = 0;
243 clicked_audio_trackview = 0;
244 clicked_crossfadeview = 0;
245 clicked_control_point = 0;
246 latest_regionview = 0;
247 last_update_frame = 0;
249 current_mixer_strip = 0;
250 current_bbt_points = 0;
252 snap_type = SnapToFrame;
253 set_snap_to (snap_type);
254 snap_mode = SnapNormal;
255 set_snap_mode (snap_mode);
256 snap_threshold = 5.0;
257 bbt_beat_subdivision = 4;
260 autoscroll_timeout_tag = -1;
261 interthread_progress_window = 0;
267 current_interthread_info = 0;
268 _show_measures = true;
269 _show_waveforms = true;
270 _show_waveforms_recording = true;
271 first_action_message = 0;
273 show_gain_after_trim = false;
274 ignore_route_list_reorder = false;
275 no_route_list_redisplay = false;
276 verbose_cursor_on = true;
277 route_removal = false;
279 show_automatic_regions_in_region_list = true;
280 region_list_sort_type = (Editing::RegionListSortType) 0;
281 have_pending_keyboard_selection = false;
282 _follow_playhead = true;
283 _xfade_visibility = true;
284 editor_ruler_menu = 0;
285 no_ruler_shown_update = false;
286 edit_group_list_menu = 0;
288 region_list_menu = 0;
290 range_marker_menu = 0;
291 marker_menu_item = 0;
293 transport_marker_menu = 0;
294 new_transport_marker_menu = 0;
295 editor_mixer_strip_width = Wide;
296 repos_zoom_queued = false;
297 region_edit_menu_split_item = 0;
299 region_edit_menu_split_multichannel_item = 0;
301 ignore_mouse_mode_toggle = false;
302 current_stepping_trackview = 0;
304 entered_regionview = 0;
305 clear_entered_track = false;
306 _new_regionviews_show_envelope = false;
307 current_timestretch = 0;
308 in_edit_group_row_change = false;
309 last_canvas_frame = 0;
312 button_release_can_deselect = true;
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 (edit_hscrollbar, 2, 3, 2, 3, FILL|EXPAND, FILL, 0, 0);
450 bottom_hbox.set_border_width (2);
451 bottom_hbox.set_spacing (3);
453 route_display_model = ListStore::create(route_display_columns);
454 route_list_display.set_model (route_display_model);
455 route_list_display.append_column (_("Visible"), route_display_columns.visible);
456 route_list_display.append_column (_("Name"), route_display_columns.text);
457 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
458 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
459 route_list_display.set_headers_visible (true);
460 route_list_display.set_name ("TrackListDisplay");
461 route_list_display.get_selection()->set_mode (SELECTION_NONE);
462 route_list_display.set_reorderable (true);
463 route_list_display.set_size_request (100,-1);
465 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
466 route_list_visible_cell->property_activatable() = true;
467 route_list_visible_cell->property_radio() = false;
469 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
470 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
472 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
474 route_list_scroller.add (route_list_display);
475 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
477 group_model = ListStore::create(group_columns);
478 edit_group_display.set_model (group_model);
479 edit_group_display.append_column (_("Name"), group_columns.text);
480 edit_group_display.append_column (_("Active"), group_columns.is_active);
481 edit_group_display.append_column (_("Visible"), group_columns.is_visible);
482 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
483 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
484 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
485 edit_group_display.get_column (0)->set_expand (true);
486 edit_group_display.get_column (1)->set_expand (false);
487 edit_group_display.get_column (2)->set_expand (false);
488 edit_group_display.set_headers_visible (true);
490 /* name is directly editable */
492 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
493 name_cell->property_editable() = true;
494 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
496 /* use checkbox for the active + visible columns */
498 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
499 active_cell->property_activatable() = true;
500 active_cell->property_radio() = false;
502 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
503 active_cell->property_activatable() = true;
504 active_cell->property_radio() = false;
506 edit_group_display.set_name ("EditGroupList");
508 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
510 edit_group_display.set_name ("EditGroupList");
511 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
512 edit_group_display.set_reorderable (false);
513 edit_group_display.set_rules_hint (true);
514 edit_group_display.set_size_request (75, -1);
516 edit_group_display_scroller.add (edit_group_display);
517 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
519 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
521 VBox* edit_group_display_packer = manage (new VBox());
522 HButtonBox* edit_group_display_button_box = manage (new HButtonBox());
523 edit_group_display_button_box->set_homogeneous (true);
525 Button* edit_group_add_button = manage (new Button ());
526 Button* edit_group_remove_button = manage (new Button ());
530 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
532 edit_group_add_button->add (*w);
534 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
536 edit_group_remove_button->add (*w);
538 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
539 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
541 edit_group_display_button_box->pack_start (*edit_group_add_button);
542 edit_group_display_button_box->pack_start (*edit_group_remove_button);
544 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
545 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
547 region_list_display.set_size_request (100, -1);
548 region_list_display.set_name ("RegionListDisplay");
550 region_list_model = TreeStore::create (region_list_columns);
551 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
552 region_list_model->set_sort_column (0, SORT_ASCENDING);
554 region_list_display.set_model (region_list_model);
555 region_list_display.append_column (_("Regions"), region_list_columns.name);
556 region_list_display.set_headers_visible (false);
557 region_list_display.set_hover_expand (true);
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_press_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 edit_pane.pack1 (edit_packer, true, true);
644 edit_pane.pack2 (the_notebook, false, true);
646 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
648 top_hbox.pack_start (toolbar_frame, true, true);
650 HBox *hbox = manage (new HBox);
651 hbox->pack_start (edit_pane, true, true);
653 global_vpacker.pack_start (top_hbox, false, false);
654 global_vpacker.pack_start (*hbox, true, true);
656 global_hpacker.pack_start (global_vpacker, true, true);
658 set_name ("EditorWindow");
659 add_accel_group (ActionManager::ui_manager->get_accel_group());
661 vpacker.pack_end (global_hpacker, true, true);
663 /* register actions now so that set_state() can find them and set toggles/checks etc */
667 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
670 _playlist_selector = new PlaylistSelector();
671 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
673 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
677 nudge_forward_button.add (*(manage (new Image (get_xpm("right_arrow.xpm")))));
678 nudge_backward_button.add (*(manage (new Image (get_xpm("left_arrow.xpm")))));
680 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
681 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
683 nudge_forward_button.set_name ("TransportButton");
684 nudge_backward_button.set_name ("TransportButton");
686 fade_context_menu.set_name ("ArdourContextMenu");
688 set_title (_("ardour: editor"));
689 set_wmclass (_("ardour_editor"), "Ardour");
692 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
694 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
695 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
697 /* allow external control surfaces/protocols to do various things */
699 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
700 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
701 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
702 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
710 /* <CMT Additions> */
711 if(image_socket_listener)
713 if(image_socket_listener->is_connected())
715 image_socket_listener->close_connection() ;
718 delete image_socket_listener ;
719 image_socket_listener = 0 ;
721 /* </CMT Additions> */
725 Editor::add_toplevel_controls (Container& cont)
727 vpacker.pack_start (cont, false, false);
732 Editor::catch_vanishing_regionview (RegionView *rv)
734 /* note: the selection will take care of the vanishing
735 audioregionview by itself.
738 if (clicked_regionview == rv) {
739 clicked_regionview = 0;
742 if (entered_regionview == rv) {
743 set_entered_regionview (0);
748 Editor::set_entered_regionview (RegionView* rv)
750 if (rv == entered_regionview) {
754 if (entered_regionview) {
755 entered_regionview->exited ();
758 if ((entered_regionview = rv) != 0) {
759 entered_regionview->entered ();
764 Editor::set_entered_track (TimeAxisView* tav)
767 entered_track->exited ();
770 if ((entered_track = tav) != 0) {
771 entered_track->entered ();
776 Editor::show_window ()
781 /* now reset all audio_time_axis heights, because widgets might need
787 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
788 tv = (static_cast<TimeAxisView*>(*i));
794 Editor::tie_vertical_scrolling ()
796 double y1 = vertical_adjustment.get_value();
797 controls_layout.get_vadjustment()->set_value (y1);
798 playhead_cursor->set_y_axis(y1);
799 edit_cursor->set_y_axis(y1);
803 Editor::set_frames_per_unit (double fpu)
805 jack_nframes_t frames;
807 if (fpu == frames_per_unit) {
815 // convert fpu to frame count
817 frames = (jack_nframes_t) floor (fpu * canvas_width);
819 /* don't allow zooms that fit more than the maximum number
820 of frames into an 800 pixel wide space.
823 if (max_frames / fpu < 800.0) {
827 frames_per_unit = fpu;
829 if (frames != zoom_range_clock.current_duration()) {
830 zoom_range_clock.set (frames);
833 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
834 if (!selection->tracks.empty()) {
835 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
836 (*i)->reshow_selection (selection->time);
839 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
840 (*i)->reshow_selection (selection->time);
845 ZoomChanged (); /* EMIT_SIGNAL */
847 reset_hscrollbar_stepping ();
848 reset_scrolling_region ();
850 if (edit_cursor) edit_cursor->set_position (edit_cursor->current_frame);
851 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
858 Editor::instant_save ()
860 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
865 session->add_instant_xml(get_state(), session->path());
867 Config->add_instant_xml(get_state(), get_user_ardour_path());
872 Editor::reposition_x_origin (jack_nframes_t frame)
874 if (frame != leftmost_frame) {
875 leftmost_frame = frame;
877 jack_nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
879 if (rightmost_frame > last_canvas_frame) {
880 last_canvas_frame = rightmost_frame;
881 reset_scrolling_region ();
884 horizontal_adjustment.set_value (frame/frames_per_unit);
886 update_fixed_rulers();
887 tempo_map_changed (Change (0));
892 Editor::edit_cursor_clock_changed()
894 if (edit_cursor->current_frame != edit_cursor_clock.current_time()) {
895 edit_cursor->set_position (edit_cursor_clock.current_time());
901 Editor::zoom_adjustment_changed ()
907 double fpu = zoom_range_clock.current_duration() / canvas_width;
911 zoom_range_clock.set ((jack_nframes_t) floor (fpu * canvas_width));
912 } else if (fpu > session->current_end_frame() / canvas_width) {
913 fpu = session->current_end_frame() / canvas_width;
914 zoom_range_clock.set ((jack_nframes_t) floor (fpu * canvas_width));
921 Editor::control_scroll (float fraction)
923 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
929 double step = fraction * current_page_frames();
930 jack_nframes_t target;
932 if ((fraction < 0.0f) && (session->transport_frame() < (jack_nframes_t) fabs(step))) {
934 } else if ((fraction > 0.0f) && (max_frames - session->transport_frame() < step)) {
935 target = (max_frames - (current_page_frames()*2)); // allow room for slop in where the PH is on the screen
937 target = (session->transport_frame() + (jack_nframes_t) floor ((fraction * current_page_frames())));
940 /* move visuals, we'll catch up with it later */
942 playhead_cursor->set_position (target);
944 if (target > (current_page_frames() / 2)) {
945 /* try to center PH in window */
946 reposition_x_origin (target - (current_page_frames()/2));
948 reposition_x_origin (0);
951 /* cancel the existing */
953 control_scroll_connection.disconnect ();
955 /* add the next one */
957 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), target), 50);
961 Editor::deferred_control_scroll (jack_nframes_t target)
963 session->request_locate (target);
968 Editor::canvas_horizontally_scrolled ()
971 leftmost_frame = (jack_nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
972 update_fixed_rulers ();
973 tempo_map_changed (Change (0));
978 Editor::reposition_and_zoom (jack_nframes_t frame, double nfpu)
980 if (!repos_zoom_queued) {
981 repos_zoom_queued = true;
982 Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::deferred_reposition_and_zoom), frame, nfpu));
987 Editor::deferred_reposition_and_zoom (jack_nframes_t frame, double nfpu)
990 set_frames_per_unit (nfpu);
991 reposition_x_origin (frame);
992 repos_zoom_queued = false;
998 Editor::on_realize ()
1000 Window::on_realize ();
1005 Editor::queue_session_control_changed (Session::ControlType t)
1007 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::session_control_changed), t));
1011 Editor::session_control_changed (Session::ControlType t)
1013 // right now we're only tracking some state here
1016 case Session::AutoLoop:
1017 update_loop_range_view (true);
1019 case Session::PunchIn:
1020 case Session::PunchOut:
1021 update_punch_range_view (true);
1024 case Session::LayeringModel:
1025 update_layering_model ();
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 (jack_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 (jack_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 (jack_nframes_t frame, float page)
1078 frame -= (jack_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 jack_nframes_t new_end = session->get_maximum_extent() + (jack_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));
1151 /* These signals can all be emitted by a non-GUI thread. Therefore the
1152 handlers for them must not attempt to directly interact with the GUI,
1153 but use Gtkmm2ext::UI::instance()->call_slot();
1156 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1157 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1158 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1159 session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::handle_new_audio_region)));
1160 session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::handle_audio_region_removed)));
1161 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1162 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1163 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1164 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1165 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1166 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1167 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1168 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1169 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1171 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1172 session_connections.push_back (session->SMPTETypeChanged.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 switch (session->get_edit_mode()) {
1190 edit_mode_selector.set_active_text (edit_mode_strings[splice_index]);
1194 edit_mode_selector.set_active_text (edit_mode_strings[slide_index]);
1198 Location* loc = session->locations()->auto_loop_location();
1200 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1201 if (loc->start() == loc->end()) {
1202 loc->set_end (loc->start() + 1);
1204 session->locations()->add (loc, false);
1205 session->set_auto_loop_location (loc);
1209 loc->set_name (_("Loop"));
1212 loc = session->locations()->auto_punch_location();
1214 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1215 if (loc->start() == loc->end()) {
1216 loc->set_end (loc->start() + 1);
1218 session->locations()->add (loc, false);
1219 session->set_auto_punch_location (loc);
1223 loc->set_name (_("Punch"));
1226 update_loop_range_view (true);
1227 update_punch_range_view (true);
1229 session->ControlChanged.connect (mem_fun(*this, &Editor::queue_session_control_changed));
1230 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1232 refresh_location_display ();
1233 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1234 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1235 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1236 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1237 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1242 act = ActionManager::get_action (X_("Editor"), X_("toggle-xfades-active"));
1244 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
1245 /* do it twice to force the change */
1246 yn = session->get_crossfades_active();
1247 tact->set_active (!yn);
1248 tact->set_active (yn);
1251 act = ActionManager::get_action (X_("Editor"), X_("toggle-auto-xfades"));
1253 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
1254 /* do it twice to force the change */
1255 yn = Config->get_auto_xfade ();
1256 tact->set_active (!yn);
1257 tact->set_active (yn);
1260 /* xfade visibility state set from editor::set_state() */
1262 update_crossfade_model ();
1263 update_layering_model ();
1265 handle_new_duration ();
1267 redisplay_regions ();
1268 redisplay_named_selections ();
1269 redisplay_snapshots ();
1271 initial_route_list_display ();
1273 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1274 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1277 /* ::reposition_x_origin() doesn't work right here, since the old
1278 position may be zero already, and it does nothing in such
1284 horizontal_adjustment.set_value (0);
1286 restore_ruler_visibility ();
1287 //tempo_map_changed (Change (0));
1288 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1290 edit_cursor->set_position (0);
1291 playhead_cursor->set_position (0);
1295 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1298 /* don't show master bus in a new session */
1300 if (ARDOUR_UI::instance()->session_is_new ()) {
1302 TreeModel::Children rows = route_display_model->children();
1303 TreeModel::Children::iterator i;
1305 no_route_list_redisplay = true;
1307 for (i = rows.begin(); i != rows.end(); ++i) {
1308 TimeAxisView *tv = (*i)[route_display_columns.tv];
1309 AudioTimeAxisView *atv;
1311 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1312 if (atv->route()->master()) {
1313 route_list_display.get_selection()->unselect (i);
1318 no_route_list_redisplay = false;
1319 redisplay_route_list ();
1322 /* register for undo history */
1324 session->register_with_memento_command_factory(_id, this);
1328 Editor::build_cursors ()
1330 using namespace Gdk;
1332 Gdk::Color mbg ("#000000" ); /* Black */
1333 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1336 RefPtr<Bitmap> source, mask;
1337 source = Bitmap::create (mag_bits, mag_width, mag_height);
1338 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1339 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1342 Gdk::Color fbg ("#ffffff" );
1343 Gdk::Color ffg ("#000000" );
1346 RefPtr<Bitmap> source, mask;
1348 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1349 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1350 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1354 RefPtr<Bitmap> source, mask;
1355 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1356 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1357 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1360 grabber_cursor = new Gdk::Cursor (HAND2);
1361 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1362 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1363 selector_cursor = new Gdk::Cursor (XTERM);
1364 time_fx_cursor = new Gdk::Cursor (SIZING);
1365 wait_cursor = new Gdk::Cursor (WATCH);
1366 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1370 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1372 using namespace Menu_Helpers;
1373 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1376 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1380 MenuList& items (fade_context_menu.items());
1381 AudioRegion& ar (*arv->audio_region().get()); // FIXME
1385 switch (item_type) {
1387 case FadeInHandleItem:
1388 if (arv->audio_region()->fade_in_active()) {
1389 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), false)));
1391 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), true)));
1394 items.push_back (SeparatorElem());
1396 items.push_back (MenuElem (_("Linear"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Linear)));
1397 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::LogB)));
1398 items.push_back (MenuElem (_("Slow"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Fast)));
1399 items.push_back (MenuElem (_("Fast"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::LogA)));
1400 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Slow)));
1404 case FadeOutHandleItem:
1405 if (arv->audio_region()->fade_out_active()) {
1406 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), false)));
1408 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), true)));
1411 items.push_back (SeparatorElem());
1413 items.push_back (MenuElem (_("Linear"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Linear)));
1414 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Fast)));
1415 items.push_back (MenuElem (_("Slow"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::LogB)));
1416 items.push_back (MenuElem (_("Fast"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::LogA)));
1417 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Slow)));
1421 fatal << _("programming error: ")
1422 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1427 fade_context_menu.popup (button, time);
1431 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, jack_nframes_t frame)
1433 using namespace Menu_Helpers;
1434 Menu* (Editor::*build_menu_function)(jack_nframes_t);
1437 switch (item_type) {
1439 case RegionViewName:
1440 case RegionViewNameHighlight:
1441 if (with_selection) {
1442 build_menu_function = &Editor::build_track_selection_context_menu;
1444 build_menu_function = &Editor::build_track_region_context_menu;
1449 if (with_selection) {
1450 build_menu_function = &Editor::build_track_selection_context_menu;
1452 build_menu_function = &Editor::build_track_context_menu;
1456 case CrossfadeViewItem:
1457 build_menu_function = &Editor::build_track_crossfade_context_menu;
1461 if (clicked_audio_trackview->get_diskstream()) {
1462 build_menu_function = &Editor::build_track_context_menu;
1464 build_menu_function = &Editor::build_track_bus_context_menu;
1469 /* probably shouldn't happen but if it does, we don't care */
1473 menu = (this->*build_menu_function)(frame);
1474 menu->set_name ("ArdourContextMenu");
1476 /* now handle specific situations */
1478 switch (item_type) {
1480 case RegionViewName:
1481 case RegionViewNameHighlight:
1482 if (!with_selection) {
1483 if (region_edit_menu_split_item) {
1484 if (clicked_regionview && clicked_regionview->region()->covers (edit_cursor->current_frame)) {
1485 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
1487 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
1491 if (region_edit_menu_split_multichannel_item) {
1492 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1493 // GTK2FIX find the action, change its sensitivity
1494 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1496 // GTK2FIX see above
1497 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1506 case CrossfadeViewItem:
1513 /* probably shouldn't happen but if it does, we don't care */
1517 if (clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
1519 /* Bounce to disk */
1521 using namespace Menu_Helpers;
1522 MenuList& edit_items = menu->items();
1524 edit_items.push_back (SeparatorElem());
1526 switch (clicked_audio_trackview->audio_track()->freeze_state()) {
1527 case AudioTrack::NoFreeze:
1528 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1531 case AudioTrack::Frozen:
1532 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1535 case AudioTrack::UnFrozen:
1536 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1542 menu->popup (button, time);
1546 Editor::build_track_context_menu (jack_nframes_t ignored)
1548 using namespace Menu_Helpers;
1550 MenuList& edit_items = track_context_menu.items();
1553 add_dstream_context_items (edit_items);
1554 return &track_context_menu;
1558 Editor::build_track_bus_context_menu (jack_nframes_t ignored)
1560 using namespace Menu_Helpers;
1562 MenuList& edit_items = track_context_menu.items();
1565 add_bus_context_items (edit_items);
1566 return &track_context_menu;
1570 Editor::build_track_region_context_menu (jack_nframes_t frame)
1572 using namespace Menu_Helpers;
1573 MenuList& edit_items = track_region_context_menu.items();
1576 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1579 boost::shared_ptr<Diskstream> ds;
1582 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1583 Playlist::RegionList* regions = pl->regions_at ((jack_nframes_t) floor ( (double)frame * ds->speed()));
1584 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1585 add_region_context_items (atv->audio_view(), (*i), edit_items);
1591 add_dstream_context_items (edit_items);
1593 return &track_region_context_menu;
1597 Editor::build_track_crossfade_context_menu (jack_nframes_t frame)
1599 using namespace Menu_Helpers;
1600 MenuList& edit_items = track_crossfade_context_menu.items();
1601 edit_items.clear ();
1603 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1606 boost::shared_ptr<Diskstream> ds;
1610 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = dynamic_cast<AudioPlaylist*> (pl)) != 0)) {
1612 Playlist::RegionList* regions = pl->regions_at (frame);
1613 AudioPlaylist::Crossfades xfades;
1615 apl->crossfades_at (frame, xfades);
1617 bool many = xfades.size() > 1;
1619 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1620 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1623 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1624 add_region_context_items (atv->audio_view(), (*i), edit_items);
1631 add_dstream_context_items (edit_items);
1633 return &track_crossfade_context_menu;
1638 Editor::analyze_region_selection()
1640 if (analysis_window == 0) {
1641 analysis_window = new AnalysisWindow();
1644 analysis_window->set_session(session);
1646 analysis_window->show_all();
1649 analysis_window->set_regionmode();
1650 analysis_window->analyze();
1652 analysis_window->present();
1656 Editor::analyze_range_selection()
1658 if (analysis_window == 0) {
1659 analysis_window = new AnalysisWindow();
1662 analysis_window->set_session(session);
1664 analysis_window->show_all();
1667 analysis_window->set_rangemode();
1668 analysis_window->analyze();
1670 analysis_window->present();
1672 #endif /* FFT_ANALYSIS */
1677 Editor::build_track_selection_context_menu (jack_nframes_t ignored)
1679 using namespace Menu_Helpers;
1680 MenuList& edit_items = track_selection_context_menu.items();
1681 edit_items.clear ();
1683 add_selection_context_items (edit_items);
1684 add_dstream_context_items (edit_items);
1686 return &track_selection_context_menu;
1690 Editor::add_crossfade_context_items (AudioStreamView* view, Crossfade* xfade, Menu_Helpers::MenuList& edit_items, bool many)
1692 using namespace Menu_Helpers;
1693 Menu *xfade_menu = manage (new Menu);
1694 MenuList& items = xfade_menu->items();
1695 xfade_menu->set_name ("ArdourContextMenu");
1698 if (xfade->active()) {
1704 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), xfade)));
1705 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), xfade)));
1707 if (xfade->can_follow_overlap()) {
1709 if (xfade->following_overlap()) {
1710 str = _("Convert to short");
1712 str = _("Convert to full");
1715 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1719 str = xfade->out()->name();
1721 str += xfade->in()->name();
1723 str = _("Crossfade");
1726 edit_items.push_back (MenuElem (str, *xfade_menu));
1727 edit_items.push_back (SeparatorElem());
1731 Editor::xfade_edit_left_region ()
1733 if (clicked_crossfadeview) {
1734 clicked_crossfadeview->left_view.show_region_editor ();
1739 Editor::xfade_edit_right_region ()
1741 if (clicked_crossfadeview) {
1742 clicked_crossfadeview->right_view.show_region_editor ();
1747 Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1749 using namespace Menu_Helpers;
1750 Menu *region_menu = manage (new Menu);
1751 MenuList& items = region_menu->items();
1752 region_menu->set_name ("ArdourContextMenu");
1754 boost::shared_ptr<AudioRegion> ar;
1757 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1760 /* when this particular menu pops up, make the relevant region
1764 region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, region));
1766 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1767 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1768 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1769 items.push_back (SeparatorElem());
1770 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_cursor)));
1771 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1772 items.push_back (SeparatorElem());
1774 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::audition_selected_region)));
1775 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1776 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1779 items.push_back (MenuElem (_("Analyze region"), mem_fun(*this, &Editor::analyze_region_selection)));
1782 items.push_back (SeparatorElem());
1784 /* XXX hopefully this nonsense will go away with SigC++ 2.X, where the compiler
1785 might be able to figure out which overloaded member function to use in
1789 void (Editor::*type_A_pmf)(void (Region::*pmf)(bool), bool) = &Editor::region_selection_op;
1791 items.push_back (MenuElem (_("Lock"), bind (mem_fun(*this, type_A_pmf), &Region::set_locked, true)));
1792 items.push_back (MenuElem (_("Unlock"), bind (mem_fun(*this, type_A_pmf), &Region::set_locked, false)));
1793 items.push_back (SeparatorElem());
1795 if (region->muted()) {
1796 items.push_back (MenuElem (_("Unmute"), bind (mem_fun(*this, type_A_pmf), &Region::set_muted, false)));
1798 items.push_back (MenuElem (_("Mute"), bind (mem_fun(*this, type_A_pmf), &Region::set_muted, true)));
1800 items.push_back (SeparatorElem());
1802 items.push_back (MenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1803 items.push_back (SeparatorElem());
1808 items.push_back (MenuElem (_("Toggle envelope visibility"), mem_fun(*this, &Editor::toggle_gain_envelope_visibility)));
1809 items.push_back (MenuElem (_("Toggle envelope active"), mem_fun(*this, &Editor::toggle_gain_envelope_active)));
1810 items.push_back (SeparatorElem());
1812 if (ar->scale_amplitude() != 1.0f) {
1813 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1815 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1818 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1819 items.push_back (SeparatorElem());
1822 /* range related stuff */
1824 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1825 items.push_back (MenuElem (_("Set Range"), mem_fun (*this, &Editor::set_selection_from_audio_region)));
1826 items.push_back (SeparatorElem());
1830 Menu *nudge_menu = manage (new Menu());
1831 MenuList& nudge_items = nudge_menu->items();
1832 nudge_menu->set_name ("ArdourContextMenu");
1834 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1835 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1836 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1837 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1839 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1840 items.push_back (SeparatorElem());
1842 Menu *trim_menu = manage (new Menu);
1843 MenuList& trim_items = trim_menu->items();
1844 trim_menu->set_name ("ArdourContextMenu");
1846 trim_items.push_back (MenuElem (_("Start to edit cursor"), mem_fun(*this, &Editor::trim_region_from_edit_cursor)));
1847 trim_items.push_back (MenuElem (_("Edit cursor to end"), mem_fun(*this, &Editor::trim_region_to_edit_cursor)));
1849 items.push_back (MenuElem (_("Trim"), *trim_menu));
1850 items.push_back (SeparatorElem());
1852 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1853 region_edit_menu_split_item = &items.back();
1855 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1856 region_edit_menu_split_multichannel_item = &items.back();
1858 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1859 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1860 items.push_back (SeparatorElem());
1861 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1862 items.push_back (SeparatorElem());
1863 items.push_back (MenuElem (_("Destroy"), mem_fun(*this, &Editor::destroy_clicked_region)));
1865 /* OK, stick the region submenu at the top of the list, and then add
1869 /* we have to hack up the region name because "_" has a special
1870 meaning for menu titles.
1873 string::size_type pos = 0;
1874 string menu_item_name = region->name();
1876 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1877 menu_item_name.replace (pos, 1, "__");
1881 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1882 edit_items.push_back (SeparatorElem());
1886 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1888 using namespace Menu_Helpers;
1889 Menu *selection_menu = manage (new Menu);
1890 MenuList& items = selection_menu->items();
1891 selection_menu->set_name ("ArdourContextMenu");
1893 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1894 items.push_back (MenuElem (_("Loop range"), mem_fun(*this, &Editor::set_route_loop_selection)));
1897 items.push_back (SeparatorElem());
1898 items.push_back (MenuElem (_("Analyze range"), mem_fun(*this, &Editor::analyze_range_selection)));
1901 items.push_back (SeparatorElem());
1902 items.push_back (MenuElem (_("Separate range to track"), mem_fun(*this, &Editor::separate_region_from_selection)));
1903 items.push_back (MenuElem (_("Separate range to region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1905 items.push_back (SeparatorElem());
1906 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1907 items.push_back (SeparatorElem());
1908 items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1909 items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1910 items.push_back (SeparatorElem());
1911 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1912 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1913 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1914 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::name_selection)));
1915 items.push_back (SeparatorElem());
1916 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1917 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1919 edit_items.push_back (MenuElem (_("Range"), *selection_menu));
1920 edit_items.push_back (SeparatorElem());
1924 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1926 using namespace Menu_Helpers;
1930 Menu *play_menu = manage (new Menu);
1931 MenuList& play_items = play_menu->items();
1932 play_menu->set_name ("ArdourContextMenu");
1934 play_items.push_back (MenuElem (_("Play from edit cursor")));
1935 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1936 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1937 play_items.push_back (SeparatorElem());
1938 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1940 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1944 Menu *select_menu = manage (new Menu);
1945 MenuList& select_items = select_menu->items();
1946 select_menu->set_name ("ArdourContextMenu");
1948 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1949 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1950 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1951 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1952 select_items.push_back (SeparatorElem());
1953 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1954 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1955 select_items.push_back (SeparatorElem());
1956 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1957 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1958 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1959 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1960 select_items.push_back (MenuElem (_("Select all between cursors"), bind (mem_fun(*this, &Editor::select_all_selectables_between_cursors), playhead_cursor, edit_cursor)));
1961 select_items.push_back (SeparatorElem());
1963 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1967 Menu *cutnpaste_menu = manage (new Menu);
1968 MenuList& cutnpaste_items = cutnpaste_menu->items();
1969 cutnpaste_menu->set_name ("ArdourContextMenu");
1971 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1972 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1973 cutnpaste_items.push_back (MenuElem (_("Paste at edit cursor"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1974 cutnpaste_items.push_back (MenuElem (_("Paste at mouse"), mem_fun(*this, &Editor::mouse_paste)));
1976 cutnpaste_items.push_back (SeparatorElem());
1978 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1979 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
1981 cutnpaste_items.push_back (SeparatorElem());
1983 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
1985 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
1987 /* Adding new material */
1989 edit_items.push_back (SeparatorElem());
1990 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
1991 edit_items.push_back (MenuElem (_("Insert Existing Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
1995 Menu *nudge_menu = manage (new Menu());
1996 MenuList& nudge_items = nudge_menu->items();
1997 nudge_menu->set_name ("ArdourContextMenu");
1999 edit_items.push_back (SeparatorElem());
2000 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2001 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2002 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2003 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2005 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2009 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
2011 using namespace Menu_Helpers;
2015 Menu *play_menu = manage (new Menu);
2016 MenuList& play_items = play_menu->items();
2017 play_menu->set_name ("ArdourContextMenu");
2019 play_items.push_back (MenuElem (_("Play from edit cursor")));
2020 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2021 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2025 Menu *select_menu = manage (new Menu);
2026 MenuList& select_items = select_menu->items();
2027 select_menu->set_name ("ArdourContextMenu");
2029 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2030 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2031 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2032 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2033 select_items.push_back (SeparatorElem());
2034 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
2035 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
2036 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2037 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2039 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2043 Menu *cutnpaste_menu = manage (new Menu);
2044 MenuList& cutnpaste_items = cutnpaste_menu->items();
2045 cutnpaste_menu->set_name ("ArdourContextMenu");
2047 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2048 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2049 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2051 Menu *nudge_menu = manage (new Menu());
2052 MenuList& nudge_items = nudge_menu->items();
2053 nudge_menu->set_name ("ArdourContextMenu");
2055 edit_items.push_back (SeparatorElem());
2056 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2057 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2058 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2059 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2061 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2064 /* CURSOR SETTING AND MARKS AND STUFF */
2067 Editor::set_snap_to (SnapType st)
2070 vector<string> txt = internationalize (snap_type_strings);
2071 snap_type_selector.set_active_text (txt[(int)st]);
2075 switch (snap_type) {
2076 case SnapToAThirtysecondBeat:
2077 case SnapToASixteenthBeat:
2078 case SnapToAEighthBeat:
2079 case SnapToAQuarterBeat:
2080 case SnapToAThirdBeat:
2081 update_tempo_based_rulers ();
2089 Editor::set_snap_mode (SnapMode mode)
2092 vector<string> txt = internationalize (snap_mode_strings);
2093 snap_mode_selector.set_active_text (txt[(int)mode]);
2099 Editor::set_state (const XMLNode& node)
2101 const XMLProperty* prop;
2103 int x, y, xoff, yoff;
2106 if ((prop = node.property ("id")) != 0) {
2107 _id = prop->value ();
2110 if ((geometry = find_named_node (node, "geometry")) == 0) {
2112 g.base_width = default_width;
2113 g.base_height = default_height;
2121 g.base_width = atoi(geometry->property("x_size")->value());
2122 g.base_height = atoi(geometry->property("y_size")->value());
2123 x = atoi(geometry->property("x_pos")->value());
2124 y = atoi(geometry->property("y_pos")->value());
2125 xoff = atoi(geometry->property("x_off")->value());
2126 yoff = atoi(geometry->property("y_off")->value());
2129 set_default_size (g.base_width, g.base_height);
2132 if ((prop = node.property ("zoom-focus"))) {
2133 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2136 if ((prop = node.property ("zoom"))) {
2137 set_frames_per_unit (PBD::atof (prop->value()));
2140 if ((prop = node.property ("snap-to"))) {
2141 set_snap_to ((SnapType) atoi (prop->value()));
2144 if ((prop = node.property ("snap-mode"))) {
2145 set_snap_mode ((SnapMode) atoi (prop->value()));
2148 if ((prop = node.property ("mouse-mode"))) {
2149 MouseMode m = str2mousemode(prop->value());
2150 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2151 set_mouse_mode (m, true);
2153 mouse_mode = MouseGain; /* lie, to force the mode switch */
2154 set_mouse_mode (MouseObject, true);
2157 if ((prop = node.property ("show-waveforms"))) {
2158 bool yn = (prop->value() == "yes");
2159 _show_waveforms = !yn;
2160 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
2162 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2163 /* do it twice to force the change */
2164 tact->set_active (!yn);
2165 tact->set_active (yn);
2169 if ((prop = node.property ("show-waveforms-recording"))) {
2170 bool yn = (prop->value() == "yes");
2171 _show_waveforms_recording = !yn;
2172 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2174 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2175 /* do it twice to force the change */
2176 tact->set_active (!yn);
2177 tact->set_active (yn);
2181 if ((prop = node.property ("show-measures"))) {
2182 bool yn = (prop->value() == "yes");
2183 _show_measures = !yn;
2184 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2186 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2187 /* do it twice to force the change */
2188 tact->set_active (!yn);
2189 tact->set_active (yn);
2193 if ((prop = node.property ("follow-playhead"))) {
2194 bool yn = (prop->value() == "yes");
2195 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2197 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2198 /* do it twice to force the change */
2199 tact->set_active (!yn);
2200 tact->set_active (yn);
2205 if ((prop = node.property ("region-list-sort-type"))) {
2206 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2207 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2210 if ((prop = node.property ("xfades-visible"))) {
2211 bool yn = (prop->value() == "yes");
2212 _xfade_visibility = !yn;
2213 // set_xfade_visibility (yn);
2216 if ((prop = node.property ("show-editor-mixer"))) {
2218 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2220 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2221 bool yn = (prop->value() == X_("yes"));
2223 /* do it twice to force the change */
2225 tact->set_active (!yn);
2226 tact->set_active (yn);
2235 Editor::get_state ()
2237 XMLNode* node = new XMLNode ("Editor");
2241 node->add_property ("id", buf);
2243 if (is_realized()) {
2244 Glib::RefPtr<Gdk::Window> win = get_window();
2246 int x, y, xoff, yoff, width, height;
2247 win->get_root_origin(x, y);
2248 win->get_position(xoff, yoff);
2249 win->get_size(width, height);
2251 XMLNode* geometry = new XMLNode ("geometry");
2253 snprintf(buf, sizeof(buf), "%d", width);
2254 geometry->add_property("x_size", string(buf));
2255 snprintf(buf, sizeof(buf), "%d", height);
2256 geometry->add_property("y_size", string(buf));
2257 snprintf(buf, sizeof(buf), "%d", x);
2258 geometry->add_property("x_pos", string(buf));
2259 snprintf(buf, sizeof(buf), "%d", y);
2260 geometry->add_property("y_pos", string(buf));
2261 snprintf(buf, sizeof(buf), "%d", xoff);
2262 geometry->add_property("x_off", string(buf));
2263 snprintf(buf, sizeof(buf), "%d", yoff);
2264 geometry->add_property("y_off", string(buf));
2265 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2266 geometry->add_property("edit_pane_pos", string(buf));
2268 node->add_child_nocopy (*geometry);
2271 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2272 node->add_property ("zoom-focus", buf);
2273 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2274 node->add_property ("zoom", buf);
2275 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2276 node->add_property ("snap-to", buf);
2277 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2278 node->add_property ("snap-mode", buf);
2280 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2281 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2282 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2283 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2284 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2285 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2286 node->add_property ("mouse-mode", enum2str(mouse_mode));
2288 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2290 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2291 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2300 Editor::trackview_by_y_position (double y)
2302 TrackViewList::iterator iter;
2305 for (iter = track_views.begin(); iter != track_views.end(); ++iter) {
2313 if (tv->y_position <= y && y < ((tv->y_position + tv->height + track_spacing))) {
2322 Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark)
2324 Location* before = 0;
2325 Location* after = 0;
2331 const jack_nframes_t one_second = session->frame_rate();
2332 const jack_nframes_t one_minute = session->frame_rate() * 60;
2334 jack_nframes_t presnap = start;
2336 switch (snap_type) {
2342 start = (jack_nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2344 start = (jack_nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2347 case SnapToSMPTEFrame:
2349 start = (jack_nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2351 start = (jack_nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2355 case SnapToSMPTESeconds:
2356 if (session->smpte_offset_negative())
2358 start += session->smpte_offset ();
2360 start -= session->smpte_offset ();
2362 if (direction > 0) {
2363 start = (jack_nframes_t) ceil ((double) start / one_second) * one_second;
2365 start = (jack_nframes_t) floor ((double) start / one_second) * one_second;
2368 if (session->smpte_offset_negative())
2370 start -= session->smpte_offset ();
2372 start += session->smpte_offset ();
2376 case SnapToSMPTEMinutes:
2377 if (session->smpte_offset_negative())
2379 start += session->smpte_offset ();
2381 start -= session->smpte_offset ();
2384 start = (jack_nframes_t) ceil ((double) start / one_minute) * one_minute;
2386 start = (jack_nframes_t) floor ((double) start / one_minute) * one_minute;
2388 if (session->smpte_offset_negative())
2390 start -= session->smpte_offset ();
2392 start += session->smpte_offset ();
2398 start = (jack_nframes_t) ceil ((double) start / one_second) * one_second;
2400 start = (jack_nframes_t) floor ((double) start / one_second) * one_second;
2406 start = (jack_nframes_t) ceil ((double) start / one_minute) * one_minute;
2408 start = (jack_nframes_t) floor ((double) start / one_minute) * one_minute;
2413 start = session->tempo_map().round_to_bar (start, direction);
2417 start = session->tempo_map().round_to_beat (start, direction);
2420 case SnapToAThirtysecondBeat:
2421 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2424 case SnapToASixteenthBeat:
2425 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2428 case SnapToAEighthBeat:
2429 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2432 case SnapToAQuarterBeat:
2433 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2436 case SnapToAThirdBeat:
2437 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2440 case SnapToEditCursor:
2441 start = edit_cursor->current_frame;
2449 before = session->locations()->first_location_before (start);
2450 after = session->locations()->first_location_after (start);
2452 if (direction < 0) {
2454 start = before->start();
2458 } else if (direction > 0) {
2460 start = after->start();
2462 start = session->current_end_frame();
2467 /* find nearest of the two */
2468 if ((start - before->start()) < (after->start() - start)) {
2469 start = before->start();
2471 start = after->start();
2474 start = before->start();
2477 start = after->start();
2484 case SnapToRegionStart:
2485 case SnapToRegionEnd:
2486 case SnapToRegionSync:
2487 case SnapToRegionBoundary:
2488 if (!region_boundary_cache.empty()) {
2489 vector<jack_nframes_t>::iterator i;
2491 if (direction > 0) {
2492 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2494 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2497 if (i != region_boundary_cache.end()) {
2500 start = region_boundary_cache.back();
2506 switch (snap_mode) {
2512 if (presnap > start) {
2513 if (presnap > (start + unit_to_frame(snap_threshold))) {
2517 } else if (presnap < start) {
2518 if (presnap < (start - unit_to_frame(snap_threshold))) {
2530 Editor::setup_toolbar ()
2534 const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
2537 /* Mode Buttons (tool selection) */
2539 vector<ToggleButton *> mouse_mode_buttons;
2541 mouse_move_button.add (*(manage (new Image (get_xpm("tool_object.xpm")))));
2542 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2543 mouse_mode_buttons.push_back (&mouse_move_button);
2544 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2545 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2546 mouse_mode_buttons.push_back (&mouse_select_button);
2547 mouse_gain_button.add (*(manage (new Image (get_xpm("tool_gain.xpm")))));
2548 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2549 mouse_mode_buttons.push_back (&mouse_gain_button);
2550 mouse_zoom_button.add (*(manage (new Image (get_xpm("tool_zoom.xpm")))));
2551 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2552 mouse_mode_buttons.push_back (&mouse_zoom_button);
2553 mouse_timefx_button.add (*(manage (new Image (get_xpm("tool_stretch.xpm")))));
2554 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2555 mouse_mode_buttons.push_back (&mouse_timefx_button);
2556 mouse_audition_button.add (*(manage (new Image (get_xpm("tool_audition.xpm")))));
2557 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2558 mouse_mode_buttons.push_back (&mouse_audition_button);
2560 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2562 HBox* mode_box = manage(new HBox);
2563 mode_box->set_border_width (2);
2564 mode_box->set_spacing(4);
2565 mouse_mode_button_box.set_spacing(1);
2566 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2567 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2568 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2569 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2570 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2571 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2572 mouse_mode_button_box.set_homogeneous(true);
2574 edit_mode_selector.set_name ("EditModeSelector");
2575 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, "Splice Edit", 2+FUDGE, 10);
2576 set_popdown_strings (edit_mode_selector, internationalize (edit_mode_strings));
2577 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2579 mode_box->pack_start(edit_mode_selector);
2580 mode_box->pack_start(mouse_mode_button_box);
2582 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2583 mouse_mode_tearoff->set_name ("MouseModeBase");
2585 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2586 &mouse_mode_tearoff->tearoff_window()));
2587 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2588 &mouse_mode_tearoff->tearoff_window(), 1));
2589 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2590 &mouse_mode_tearoff->tearoff_window()));
2591 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2592 &mouse_mode_tearoff->tearoff_window(), 1));
2594 mouse_move_button.set_name ("MouseModeButton");
2595 mouse_select_button.set_name ("MouseModeButton");
2596 mouse_gain_button.set_name ("MouseModeButton");
2597 mouse_zoom_button.set_name ("MouseModeButton");
2598 mouse_timefx_button.set_name ("MouseModeButton");
2599 mouse_audition_button.set_name ("MouseModeButton");
2601 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
2602 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
2603 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
2604 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
2605 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
2606 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
2608 mouse_move_button.unset_flags (CAN_FOCUS);
2609 mouse_select_button.unset_flags (CAN_FOCUS);
2610 mouse_gain_button.unset_flags (CAN_FOCUS);
2611 mouse_zoom_button.unset_flags (CAN_FOCUS);
2612 mouse_timefx_button.unset_flags (CAN_FOCUS);
2613 mouse_audition_button.unset_flags (CAN_FOCUS);
2615 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2616 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2618 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2619 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2620 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2621 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2622 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2624 // mouse_move_button.set_active (true);
2629 zoom_box.set_spacing (1);
2630 zoom_box.set_border_width (2);
2632 zoom_in_button.set_name ("EditorTimeButton");
2633 zoom_in_button.add (*(manage (new Image (get_xpm("zoom_in.xpm")))));
2634 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2635 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2637 zoom_out_button.set_name ("EditorTimeButton");
2638 zoom_out_button.add (*(manage (new Image (get_xpm("zoom_out.xpm")))));
2639 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2640 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2642 zoom_out_full_button.set_name ("EditorTimeButton");
2643 zoom_out_full_button.add (*(manage (new Image (get_xpm("zoom_full.xpm")))));
2644 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2645 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2647 zoom_box.pack_start (zoom_out_button, false, false);
2648 zoom_box.pack_start (zoom_in_button, false, false);
2649 zoom_box.pack_start (zoom_range_clock, false, false);
2650 zoom_box.pack_start (zoom_out_full_button, false, false);
2652 ARDOUR_UI::instance()->tooltips().set_tip (zoom_range_clock, _("Current Zoom Range\n(Width of visible area)"));
2654 zoom_focus_selector.set_name ("ZoomFocusSelector");
2655 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Focus Center", 2+FUDGE, 0);
2656 set_popdown_strings (zoom_focus_selector, internationalize (zoom_focus_strings));
2657 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2659 zoom_box.pack_start (zoom_focus_selector, false, false);
2662 /* Edit Cursor / Snap */
2664 snap_box.set_spacing (1);
2665 snap_box.set_border_width (2);
2667 snap_type_selector.set_name ("SnapTypeSelector");
2668 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, "SMPTE Seconds", 2+FUDGE, 10);
2669 set_popdown_strings (snap_type_selector, internationalize (snap_type_strings));
2670 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2671 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Unit to snap cursors and ranges to"));
2673 snap_mode_selector.set_name ("SnapModeSelector");
2674 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, "Magnetic Snap", 2+FUDGE, 10);
2675 set_popdown_strings (snap_mode_selector, internationalize (snap_mode_strings));
2676 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2678 snap_box.pack_start (edit_cursor_clock, false, false);
2679 snap_box.pack_start (snap_mode_selector, false, false);
2680 snap_box.pack_start (snap_type_selector, false, false);
2685 HBox *nudge_box = manage (new HBox);
2686 nudge_box->set_spacing(1);
2687 nudge_box->set_border_width (2);
2689 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2690 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2692 nudge_box->pack_start (nudge_backward_button, false, false);
2693 nudge_box->pack_start (nudge_forward_button, false, false);
2694 nudge_box->pack_start (nudge_clock, false, false);
2697 /* Pack everything in... */
2699 HBox* hbox = new HBox;
2700 hbox->set_spacing(10);
2702 tools_tearoff = new TearOff (*hbox);
2703 tools_tearoff->set_name ("MouseModeBase");
2705 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2706 &tools_tearoff->tearoff_window()));
2707 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2708 &tools_tearoff->tearoff_window(), 0));
2709 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2710 &tools_tearoff->tearoff_window()));
2711 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2712 &tools_tearoff->tearoff_window(), 0));
2714 toolbar_hbox.set_spacing (10);
2715 toolbar_hbox.set_border_width (1);
2717 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2718 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2721 hbox->pack_start (snap_box, false, false);
2722 hbox->pack_start (zoom_box, false, false);
2723 hbox->pack_start (*nudge_box, false, false);
2727 toolbar_base.set_name ("ToolBarBase");
2728 toolbar_base.add (toolbar_hbox);
2730 toolbar_frame.set_shadow_type (SHADOW_OUT);
2731 toolbar_frame.set_name ("BaseFrame");
2732 toolbar_frame.add (toolbar_base);
2736 Editor::convert_drop_to_paths (vector<ustring>& paths,
2737 const RefPtr<Gdk::DragContext>& context,
2740 const SelectionData& data,
2749 vector<ustring> uris = data.get_uris();
2753 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
2754 are actually URI lists. So do it by hand.
2757 if (data.get_target() != "text/plain") {
2761 /* Parse the "uri-list" format that Nautilus provides,
2762 where each pathname is delimited by \r\n
2765 const char* p = data.get_text().c_str();
2772 while (g_ascii_isspace (*p))
2776 while (*q && (*q != '\n') && (*q != '\r'))
2782 while (q > p && g_ascii_isspace (*q))
2787 uris.push_back (ustring (p, q - p + 1));
2791 p = strchr (p, '\n');
2801 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
2802 if ((*i).substr (0,7) == "file://") {
2804 PBD::url_decode (p);
2805 paths.push_back (p.substr (7));
2813 Editor::new_tempo_section ()
2819 Editor::map_transport_state ()
2821 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
2823 if (session->transport_stopped()) {
2824 have_pending_keyboard_selection = false;
2830 Editor::State::State ()
2832 selection = new Selection;
2835 Editor::State::~State ()
2841 Editor::get_memento () const
2843 State *state = new State;
2845 store_state (*state);
2846 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
2850 Editor::store_state (State& state) const
2852 *state.selection = *selection;
2856 Editor::restore_state (State *state)
2858 if (*selection == *state->selection) {
2862 *selection = *state->selection;
2863 time_selection_changed ();
2864 region_selection_changed ();
2866 /* XXX other selection change handlers? */
2870 Editor::begin_reversible_command (string name)
2873 before = &get_state();
2874 session->begin_reversible_command (name);
2879 Editor::commit_reversible_command ()
2882 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
2887 Editor::set_selected_track_from_click (bool press, Selection::Operation op, bool with_undo, bool no_remove)
2889 bool commit = false;
2891 if (!clicked_trackview) {
2896 case Selection::Toggle:
2897 if (selection->selected (clicked_trackview)) {
2899 selection->remove (clicked_trackview);
2903 selection->add (clicked_trackview);
2908 case Selection::Set:
2909 if (selection->selected (clicked_trackview) && selection->tracks.size() == 1) {
2910 /* no commit necessary */
2913 selection->set (clicked_trackview);
2916 case Selection::Extend:
2917 /* not defined yet */
2925 Editor::set_selected_control_point_from_click (bool press, Selection::Operation op, bool with_undo, bool no_remove)
2927 if (!clicked_control_point) {
2931 /* select this point and any others that it represents */
2934 jack_nframes_t x1, x2;
2936 x1 = pixel_to_frame (clicked_control_point->get_x() - 10);
2937 x2 = pixel_to_frame (clicked_control_point->get_x() + 10);
2938 y1 = clicked_control_point->get_x() - 10;
2939 y2 = clicked_control_point->get_y() + 10;
2941 return select_all_within (x1, x2, y1, y2, op);
2945 Editor::get_relevant_audio_tracks (AudioTimeAxisView& base, set<AudioTimeAxisView*>& relevant_tracks)
2947 /* step one: get all selected tracks and all tracks in the relevant edit groups */
2949 for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) {
2951 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*ti);
2957 RouteGroup* group = atv->route()->edit_group();
2959 if (group && group->is_active()) {
2961 /* active group for this track, loop over all tracks and get every member of the group */
2963 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
2965 AudioTimeAxisView* tatv;
2967 if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
2969 if (tatv->route()->edit_group() == group) {
2970 relevant_tracks.insert (tatv);
2977 /* no active group, or no group */
2979 relevant_tracks.insert (&base);
2986 Editor::mapover_audio_tracks (slot<void,AudioTimeAxisView&,uint32_t> sl)
2988 set<AudioTimeAxisView*> relevant_tracks;
2990 if (!clicked_audio_trackview) {
2994 get_relevant_audio_tracks (*clicked_audio_trackview, relevant_tracks);
2996 uint32_t sz = relevant_tracks.size();
2998 for (set<AudioTimeAxisView*>::iterator ati = relevant_tracks.begin(); ati != relevant_tracks.end(); ++ati) {
3004 Editor::mapped_set_selected_regionview_from_click (RouteTimeAxisView& tv, uint32_t ignored,
3005 RegionView* basis, vector<RegionView*>* all_equivs)
3008 vector<boost::shared_ptr<Region> > results;
3010 boost::shared_ptr<Diskstream> ds;
3012 if ((ds = tv.get_diskstream()) == 0) {
3017 if (&tv == &basis->get_time_axis_view()) {
3018 /* looking in same track as the original */
3023 if ((pl = dynamic_cast<Playlist*>(ds->playlist())) != 0) {
3024 pl->get_equivalent_regions (basis->region(), results);
3027 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
3028 if ((marv = tv.view()->find_view (*ir)) != 0) {
3029 all_equivs->push_back (marv);
3035 Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, bool no_track_remove)
3037 vector<RegionView*> all_equivalent_regions;
3038 bool commit = false;
3040 if (!clicked_regionview || !clicked_audio_trackview) {
3044 if (op == Selection::Toggle || op == Selection::Set) {
3046 mapover_audio_tracks (bind (mem_fun (*this, &Editor::mapped_set_selected_regionview_from_click),
3047 clicked_regionview, &all_equivalent_regions));
3050 /* add clicked regionview since we skipped all other regions in the same track as the one it was in */
3052 all_equivalent_regions.push_back (clicked_regionview);
3055 case Selection::Toggle:
3057 if (clicked_regionview->get_selected()) {
3060 /* whatever was clicked was selected already; do nothing here but allow
3061 the button release to deselect it
3064 button_release_can_deselect = true;
3068 if (button_release_can_deselect) {
3070 /* just remove this one region, but only on a permitted button release */
3072 selection->remove (clicked_regionview);
3075 /* no more deselect action on button release till a new press
3076 finds an already selected object.
3079 button_release_can_deselect = false;
3086 /* add all the equivalent regions, but only on button press */
3088 if (!all_equivalent_regions.empty()) {
3092 for (vector<RegionView*>::iterator i = all_equivalent_regions.begin(); i != all_equivalent_regions.end(); ++i) {
3093 selection->add (*i);
3099 case Selection::Set:
3100 if (!clicked_regionview->get_selected()) {
3101 selection->set (all_equivalent_regions);
3104 /* no commit necessary: clicked on an already selected region */
3110 /* silly compiler */
3114 } else if (op == Selection::Extend) {
3116 list<Selectable*> results;
3117 jack_nframes_t last_frame;
3118 jack_nframes_t first_frame;
3120 /* 1. find the last selected regionview in the track that was clicked in */
3123 first_frame = max_frames;
3125 for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
3126 if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) {
3128 if ((*x)->region()->last_frame() > last_frame) {
3129 last_frame = (*x)->region()->last_frame();
3132 if ((*x)->region()->first_frame() < first_frame) {
3133 first_frame = (*x)->region()->first_frame();
3138 /* 2. figure out the boundaries for our search for new objects */
3140 switch (clicked_regionview->region()->coverage (first_frame, last_frame)) {
3142 cerr << "no overlap, first = " << first_frame << " last = " << last_frame << " region = "
3143 << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
3145 if (last_frame < clicked_regionview->region()->first_frame()) {
3146 first_frame = last_frame;
3147 last_frame = clicked_regionview->region()->last_frame();
3149 last_frame = first_frame;
3150 first_frame = clicked_regionview->region()->first_frame();
3154 case OverlapExternal:
3155 cerr << "external overlap, first = " << first_frame << " last = " << last_frame << " region = "
3156 << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
3158 if (last_frame < clicked_regionview->region()->first_frame()) {
3159 first_frame = last_frame;
3160 last_frame = clicked_regionview->region()->last_frame();
3162 last_frame = first_frame;
3163 first_frame = clicked_regionview->region()->first_frame();
3167 case OverlapInternal:
3168 cerr << "internal overlap, first = " << first_frame << " last = " << last_frame << " region = "
3169 << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
3171 if (last_frame < clicked_regionview->region()->first_frame()) {
3172 first_frame = last_frame;
3173 last_frame = clicked_regionview->region()->last_frame();
3175 last_frame = first_frame;
3176 first_frame = clicked_regionview->region()->first_frame();
3182 /* nothing to do except add clicked region to selection, since it
3183 overlaps with the existing selection in this track.
3188 /* 2. find all selectable objects (regionviews in this case) between that one and the end of the
3189 one that was clicked.
3192 set<AudioTimeAxisView*> relevant_tracks;
3194 get_relevant_audio_tracks (*clicked_audio_trackview, relevant_tracks);
3196 for (set<AudioTimeAxisView*>::iterator t = relevant_tracks.begin(); t != relevant_tracks.end(); ++t) {
3197 (*t)->get_selectables (first_frame, last_frame, -1.0, -1.0, results);
3200 /* 3. convert to a vector of audio regions */
3202 vector<RegionView*> regions;
3204 for (list<Selectable*>::iterator x = results.begin(); x != results.end(); ++x) {
3207 if ((arv = dynamic_cast<RegionView*>(*x)) != 0) {
3208 regions.push_back (arv);
3212 if (!regions.empty()) {
3213 selection->add (regions);
3223 Editor::set_selected_regionview_from_region_list (boost::shared_ptr<Region> region, Selection::Operation op)
3225 vector<RegionView*> all_equivalent_regions;
3227 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3229 RouteTimeAxisView* tatv;
3231 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
3234 vector<boost::shared_ptr<Region> > results;
3236 boost::shared_ptr<Diskstream> ds;
3238 if ((ds = tatv->get_diskstream()) == 0) {
3243 if ((pl = dynamic_cast<Playlist*>(ds->playlist())) != 0) {
3244 pl->get_region_list_equivalent_regions (region, results);
3247 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
3248 if ((marv = tatv->view()->find_view (*ir)) != 0) {
3249 all_equivalent_regions.push_back (marv);
3256 begin_reversible_command (_("set selected regions"));
3259 case Selection::Toggle:
3260 /* XXX this is not correct */
3261 selection->toggle (all_equivalent_regions);
3263 case Selection::Set:
3264 selection->set (all_equivalent_regions);
3266 case Selection::Extend:
3267 selection->add (all_equivalent_regions);
3271 commit_reversible_command () ;
3275 Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::shared_ptr<Region> r)
3278 boost::shared_ptr<AudioRegion> ar;
3280 if ((ar = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
3284 if ((rv = sv->find_view (ar)) == 0) {
3288 /* don't reset the selection if its something other than
3289 a single other region.
3292 if (selection->regions.size() > 1) {
3296 begin_reversible_command (_("set selected regions"));
3298 selection->set (rv);
3300 commit_reversible_command () ;
3306 Editor::set_edit_group_solo (Route& route, bool yn)
3308 RouteGroup *edit_group;
3310 if ((edit_group = route.edit_group()) != 0) {
3311 edit_group->apply (&Route::set_solo, yn, this);
3313 route.set_solo (yn, this);
3318 Editor::set_edit_group_mute (Route& route, bool yn)
3320 RouteGroup *edit_group = 0;
3322 if ((edit_group == route.edit_group()) != 0) {
3323 edit_group->apply (&Route::set_mute, yn, this);
3325 route.set_mute (yn, this);
3330 Editor::set_edit_menu (Menu& menu)
3333 edit_menu->signal_map_event().connect (mem_fun(*this, &Editor::edit_menu_map_handler));
3337 Editor::edit_menu_map_handler (GdkEventAny* ev)
3339 using namespace Menu_Helpers;
3340 MenuList& edit_items = edit_menu->items();
3343 /* Nuke all the old items */
3345 edit_items.clear ();
3351 if (session->undo_depth() == 0) {
3354 label = string_compose(_("Undo (%1)"), session->next_undo());
3357 edit_items.push_back (MenuElem (label, bind (mem_fun(*this, &Editor::undo), 1U)));
3359 if (session->undo_depth() == 0) {
3360 edit_items.back().set_sensitive (false);
3363 if (session->redo_depth() == 0) {
3366 label = string_compose(_("Redo (%1)"), session->next_redo());
3369 edit_items.push_back (MenuElem (label, bind (mem_fun(*this, &Editor::redo), 1U)));
3370 if (session->redo_depth() == 0) {
3371 edit_items.back().set_sensitive (false);
3374 vector<MenuItem*> mitems;
3376 edit_items.push_back (SeparatorElem());
3377 edit_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
3378 mitems.push_back (&edit_items.back());
3379 edit_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
3380 mitems.push_back (&edit_items.back());
3381 edit_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
3382 mitems.push_back (&edit_items.back());
3383 edit_items.push_back (SeparatorElem());
3384 edit_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
3385 mitems.push_back (&edit_items.back());
3386 edit_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
3387 mitems.push_back (&edit_items.back());
3388 edit_items.push_back (SeparatorElem());
3390 if (selection->empty()) {
3391 for (vector<MenuItem*>::iterator i = mitems.begin(); i != mitems.end(); ++i) {
3392 (*i)->set_sensitive (false);
3396 Menu* import_menu = manage (new Menu());
3397 import_menu->set_name ("ArdourContextMenu");
3398 MenuList& import_items = import_menu->items();
3400 import_items.push_back (MenuElem (_("... as new track"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsTrack)));
3401 import_items.push_back (MenuElem (_("... as new region"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion)));
3403 edit_items.push_back (MenuElem (_("Import audio (copy)"), *import_menu));
3404 edit_items.push_back (SeparatorElem());
3406 edit_items.push_back (MenuElem (_("Remove last capture"), mem_fun(*this, &Editor::remove_last_capture)));
3408 if (!session->have_captured()) {
3409 edit_items.back().set_sensitive (false);
3416 Editor::duplicate_dialog (bool dup_region)
3419 if (clicked_regionview == 0) {
3423 if (selection->time.length() == 0) {
3428 ArdourDialog win ("duplicate dialog");
3430 Label label (_("Duplicate how many times?"));
3432 win.get_vbox()->pack_start (label);
3433 win.add_action_widget (entry, RESPONSE_ACCEPT);
3434 win.add_button (Stock::OK, RESPONSE_ACCEPT);
3435 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3437 win.set_position (WIN_POS_MOUSE);
3439 entry.set_text ("1");
3440 set_size_request_to_display_given_text (entry, X_("12345678"), 20, 15);
3441 entry.select_region (0, entry.get_text_length());
3442 entry.grab_focus ();
3445 switch (win.run ()) {
3446 case RESPONSE_ACCEPT:
3452 string text = entry.get_text();
3455 if (sscanf (text.c_str(), "%f", ×) == 1) {
3457 RegionSelection regions;
3458 regions.add (clicked_regionview);
3459 duplicate_some_regions (regions, times);
3461 duplicate_selection (times);
3467 Editor::show_verbose_canvas_cursor ()
3469 verbose_canvas_cursor->raise_to_top();
3470 verbose_canvas_cursor->show();
3471 verbose_cursor_visible = true;
3475 Editor::hide_verbose_canvas_cursor ()
3477 verbose_canvas_cursor->hide();
3478 verbose_cursor_visible = false;
3482 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3484 /* XXX get origin of canvas relative to root window,
3485 add x and y and check compared to gdk_screen_{width,height}
3487 verbose_canvas_cursor->property_text() = txt.c_str();
3488 verbose_canvas_cursor->property_x() = x;
3489 verbose_canvas_cursor->property_y() = y;
3493 Editor::set_verbose_canvas_cursor_text (const string & txt)
3495 verbose_canvas_cursor->property_text() = txt.c_str();
3499 Editor::edit_mode_selection_done ()
3505 string choice = edit_mode_selector.get_active_text();
3506 EditMode mode = Slide;
3508 if (choice == _("Splice Edit")) {
3510 } else if (choice == _("Slide Edit")) {
3514 session->set_edit_mode (mode);
3518 Editor::snap_type_selection_done ()
3524 string choice = snap_type_selector.get_active_text();
3525 SnapType snaptype = SnapToFrame;
3527 if (choice == _("Beats/3")) {
3528 snaptype = SnapToAThirdBeat;
3529 } else if (choice == _("Beats/4")) {
3530 snaptype = SnapToAQuarterBeat;
3531 } else if (choice == _("Beats/8")) {
3532 snaptype = SnapToAEighthBeat;
3533 } else if (choice == _("Beats/16")) {
3534 snaptype = SnapToASixteenthBeat;
3535 } else if (choice == _("Beats/32")) {
3536 snaptype = SnapToAThirtysecondBeat;
3537 } else if (choice == _("Beats")) {
3538 snaptype = SnapToBeat;
3539 } else if (choice == _("Bars")) {
3540 snaptype = SnapToBar;
3541 } else if (choice == _("Marks")) {
3542 snaptype = SnapToMark;
3543 } else if (choice == _("Edit Cursor")) {
3544 snaptype = SnapToEditCursor;
3545 } else if (choice == _("Region starts")) {
3546 snaptype = SnapToRegionStart;
3547 } else if (choice == _("Region ends")) {
3548 snaptype = SnapToRegionEnd;
3549 } else if (choice == _("Region bounds")) {
3550 snaptype = SnapToRegionBoundary;
3551 } else if (choice == _("Region syncs")) {
3552 snaptype = SnapToRegionSync;
3553 } else if (choice == _("CD Frames")) {
3554 snaptype = SnapToCDFrame;
3555 } else if (choice == _("SMPTE Frames")) {
3556 snaptype = SnapToSMPTEFrame;
3557 } else if (choice == _("SMPTE Seconds")) {
3558 snaptype = SnapToSMPTESeconds;
3559 } else if (choice == _("SMPTE Minutes")) {
3560 snaptype = SnapToSMPTEMinutes;
3561 } else if (choice == _("Seconds")) {
3562 snaptype = SnapToSeconds;
3563 } else if (choice == _("Minutes")) {
3564 snaptype = SnapToMinutes;
3565 } else if (choice == _("None")) {
3566 snaptype = SnapToFrame;
3569 set_snap_to (snaptype);
3573 Editor::snap_mode_selection_done ()
3579 string choice = snap_mode_selector.get_active_text();
3580 SnapMode mode = SnapNormal;
3582 if (choice == _("Normal Snap")) {
3584 } else if (choice == _("Magnetic Snap")) {
3585 mode = SnapMagnetic;
3588 set_snap_mode (mode);
3592 Editor::zoom_focus_selection_done ()
3598 string choice = zoom_focus_selector.get_active_text();
3599 ZoomFocus focus_type = ZoomFocusLeft;
3601 if (choice == _("Focus Left")) {
3602 focus_type = ZoomFocusLeft;
3603 } else if (choice == _("Focus Right")) {
3604 focus_type = ZoomFocusRight;
3605 } else if (choice == _("Focus Center")) {
3606 focus_type = ZoomFocusCenter;
3607 } else if (choice == _("Focus Playhead")) {
3608 focus_type = ZoomFocusPlayhead;
3609 } else if (choice == _("Focus Edit Cursor")) {
3610 focus_type = ZoomFocusEdit;
3613 set_zoom_focus (focus_type);
3617 Editor::edit_controls_button_release (GdkEventButton* ev)
3619 if (Keyboard::is_context_menu_event (ev)) {
3620 ARDOUR_UI::instance()->add_route ();
3626 Editor::track_selection_changed ()
3628 switch (selection->tracks.size()){
3632 set_selected_mixer_strip (*(selection->tracks.front()));
3636 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3637 (*i)->set_selected (false);
3638 if (mouse_mode == MouseRange) {
3639 (*i)->hide_selection ();
3643 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3644 (*i)->set_selected (true);
3645 if (mouse_mode == MouseRange) {
3646 (*i)->show_selection (selection->time);
3652 Editor::time_selection_changed ()
3654 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3655 (*i)->hide_selection ();
3658 if (selection->tracks.empty()) {
3659 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3660 (*i)->show_selection (selection->time);
3663 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3664 (*i)->show_selection (selection->time);
3668 if (selection->time.empty()) {
3669 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
3671 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true);
3676 Editor::region_selection_changed ()
3678 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3679 (*i)->set_selected_regionviews (selection->regions);
3684 Editor::point_selection_changed ()
3686 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3687 (*i)->set_selected_points (selection->points);
3692 Editor::mouse_select_button_release (GdkEventButton* ev)
3694 /* this handles just right-clicks */
3696 if (ev->button != 3) {
3703 Editor::TrackViewList *
3704 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3707 TrackViewList::iterator i;
3709 v = new TrackViewList;
3711 if (track == 0 && group == 0) {
3715 for (i = track_views.begin(); i != track_views.end (); ++i) {
3719 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3721 /* just the view for this track
3724 v->push_back (track);
3728 /* views for all tracks in the edit group */
3730 for (i = track_views.begin(); i != track_views.end (); ++i) {
3732 if (group == 0 || (*i)->edit_group() == group) {
3742 Editor::set_zoom_focus (ZoomFocus f)
3744 vector<string> txt = internationalize (zoom_focus_strings);
3745 zoom_focus_selector.set_active_text (txt[(int)f]);
3747 if (zoom_focus != f) {
3750 ZoomFocusChanged (); /* EMIT_SIGNAL */
3757 Editor::ensure_float (Window& win)
3759 win.set_transient_for (*this);
3763 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3765 /* recover or initialize pane positions. do this here rather than earlier because
3766 we don't want the positions to change the child allocations, which they seem to do.
3772 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3774 static int32_t done;
3777 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3778 width = default_width;
3779 height = default_height;
3781 width = atoi(geometry->property("x_size")->value());
3782 height = atoi(geometry->property("y_size")->value());
3785 if (which == static_cast<Paned*> (&edit_pane)) {
3791 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3792 /* initial allocation is 90% to canvas, 10% to notebook */
3793 pos = (int) floor (alloc.get_width() * 0.90f);
3794 snprintf (buf, sizeof(buf), "%d", pos);
3796 pos = atoi (prop->value());
3799 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3800 edit_pane.set_position (pos);
3801 pre_maximal_pane_position = pos;
3807 Editor::detach_tearoff (Box* b, Window* w)
3809 if (tools_tearoff->torn_off() &&
3810 mouse_mode_tearoff->torn_off()) {
3811 top_hbox.remove (toolbar_frame);
3816 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3818 if (toolbar_frame.get_parent() == 0) {
3819 top_hbox.pack_end (toolbar_frame);
3824 Editor::set_show_measures (bool yn)
3826 if (_show_measures != yn) {
3829 if ((_show_measures = yn) == true) {
3832 DisplayControlChanged (ShowMeasures);
3838 Editor::toggle_follow_playhead ()
3840 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3842 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3843 set_follow_playhead (tact->get_active());
3848 Editor::set_follow_playhead (bool yn)
3850 if (_follow_playhead != yn) {
3851 if ((_follow_playhead = yn) == true) {
3853 update_current_screen ();
3855 DisplayControlChanged (FollowPlayhead);
3861 Editor::toggle_xfade_active (Crossfade* xfade)
3863 xfade->set_active (!xfade->active());
3867 Editor::toggle_xfade_length (Crossfade* xfade)
3869 xfade->set_follow_overlap (!xfade->following_overlap());
3873 Editor::edit_xfade (Crossfade* xfade)
3875 CrossfadeEditor cew (*session, *xfade, xfade->fade_in().get_min_y(), 1.0);
3879 switch (cew.run ()) {
3880 case RESPONSE_ACCEPT:
3887 xfade->StateChanged (Change (~0));
3891 Editor::playlist_selector () const
3893 return *_playlist_selector;
3897 Editor::get_nudge_distance (jack_nframes_t pos, jack_nframes_t& next)
3901 ret = nudge_clock.current_duration (pos);
3902 next = ret + 1; /* XXXX fix me */
3908 Editor::end_location_changed (Location* location)
3910 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3911 reset_scrolling_region ();
3915 Editor::playlist_deletion_dialog (Playlist* pl)
3917 ArdourDialog dialog ("playlist deletion dialog");
3918 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3919 "If left alone, no audio files used by it will be cleaned.\n"
3920 "If deleted, audio files used by it alone by will cleaned."),
3923 dialog.set_position (WIN_POS_CENTER);
3924 dialog.get_vbox()->pack_start (label);
3926 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3927 dialog.add_button (_("Keep playlist"), RESPONSE_CANCEL);
3928 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3930 switch (dialog.run ()) {
3931 case RESPONSE_ACCEPT:
3932 /* delete the playlist */
3936 case RESPONSE_REJECT:
3937 /* keep the playlist */
3949 Editor::audio_region_selection_covers (jack_nframes_t where)
3951 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3952 if ((*a)->region()->covers (where)) {
3961 Editor::prepare_for_cleanup ()
3963 cut_buffer->clear_regions ();
3964 cut_buffer->clear_playlists ();
3966 selection->clear_regions ();
3967 selection->clear_playlists ();
3971 Editor::transport_loop_location()
3974 return session->locations()->auto_loop_location();
3981 Editor::transport_punch_location()
3984 return session->locations()->auto_punch_location();
3991 Editor::control_layout_scroll (GdkEventScroll* ev)
3993 switch (ev->direction) {
3995 scroll_tracks_up_line ();
3999 case GDK_SCROLL_DOWN:
4000 scroll_tracks_down_line ();
4004 /* no left/right handling yet */
4012 Editor::snapshot_display_selection_changed ()
4014 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
4016 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
4018 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
4020 if (snap_name.length() == 0) {
4024 if (session->snap_name() == snap_name) {
4028 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
4033 Editor::snapshot_display_button_press (GdkEventButton* ev)
4039 Editor::redisplay_snapshots ()
4045 vector<string*>* states;
4047 if ((states = session->possible_states()) == 0) {
4051 snapshot_display_model->clear ();
4053 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
4054 string statename = *(*i);
4055 TreeModel::Row row = *(snapshot_display_model->append());
4056 row[snapshot_display_columns.visible_name] = statename;
4057 row[snapshot_display_columns.real_name] = statename;
4064 Editor::session_state_saved (string snap_name)
4066 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4067 redisplay_snapshots ();
4071 Editor::maximise_editing_space ()
4073 mouse_mode_tearoff->set_visible (false);
4074 tools_tearoff->set_visible (false);
4076 pre_maximal_pane_position = edit_pane.get_position();
4077 edit_pane.set_position (edit_pane.get_width());
4083 Editor::restore_editing_space ()
4085 mouse_mode_tearoff->set_visible (true);
4086 tools_tearoff->set_visible (true);
4087 edit_pane.set_position (pre_maximal_pane_position);
4093 Editor::new_playlists ()
4095 begin_reversible_command (_("new playlists"));
4096 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist));
4097 commit_reversible_command ();
4101 Editor::copy_playlists ()
4103 begin_reversible_command (_("copy playlists"));
4104 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist));
4105 commit_reversible_command ();
4109 Editor::clear_playlists ()
4111 begin_reversible_command (_("clear playlists"));
4112 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist));
4113 commit_reversible_command ();
4117 Editor::mapped_use_new_playlist (AudioTimeAxisView& atv, uint32_t sz)
4119 atv.use_new_playlist (sz > 1 ? false : true);
4123 Editor::mapped_use_copy_playlist (AudioTimeAxisView& atv, uint32_t sz)
4125 atv.use_copy_playlist (sz > 1 ? false : true);
4129 Editor::mapped_clear_playlist (AudioTimeAxisView& atv, uint32_t sz)
4131 atv.clear_playlist ();
4135 Editor::on_key_press_event (GdkEventKey* ev)
4137 return key_press_focus_accelerator_handler (*this, ev);
4141 Editor::update_layering_model ()
4145 switch (session->get_layer_model()) {
4146 case Session::LaterHigher:
4147 act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
4149 case Session::MoveAddHigher:
4150 act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
4152 case Session::AddHigher:
4153 act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
4158 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
4159 if (ract && !ract->get_active()) {
4160 ract->set_active (true);
4167 Editor::update_crossfade_model ()
4171 switch (session->get_xfade_model()) {
4173 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
4175 case ShortCrossfade:
4176 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
4181 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
4182 if (ract && !ract->get_active()) {
4183 ract->set_active (true);