2 Copyright (C) 2000-2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <sigc++/bind.h>
29 #include <pbd/convert.h>
30 #include <pbd/error.h>
31 #include <pbd/memento_command.h>
33 #include <gtkmm/image.h>
34 #include <gdkmm/color.h>
35 #include <gdkmm/bitmap.h>
37 #include <gtkmm2ext/gtk_ui.h>
38 #include <gtkmm2ext/tearoff.h>
39 #include <gtkmm2ext/utils.h>
41 #include <ardour/audio_track.h>
42 #include <ardour/audio_diskstream.h>
43 #include <ardour/plugin_manager.h>
44 #include <ardour/location.h>
45 #include <ardour/audioplaylist.h>
46 #include <ardour/audioregion.h>
47 #include <ardour/region.h>
48 #include <ardour/session_route.h>
49 #include <ardour/tempo.h>
50 #include <ardour/utils.h>
52 #include <control_protocol/control_protocol.h>
54 #include "ardour_ui.h"
56 #include "grouped_buttons.h"
59 #include "playlist_selector.h"
60 #include "audio_region_view.h"
61 #include "rgb_macros.h"
62 #include "selection.h"
63 #include "audio_streamview.h"
64 #include "time_axis_view.h"
65 #include "audio_time_axis.h"
67 #include "crossfade_view.h"
69 #include "public_editor.h"
70 #include "crossfade_edit.h"
71 #include "audio_time_axis.h"
72 #include "canvas_impl.h"
74 #include "gui_thread.h"
77 #include "analysis_window.h"
83 #include "imageframe_socket_handler.h"
84 /* </CMT Additions> */
88 using namespace ARDOUR;
92 using namespace Gtkmm2ext;
93 using namespace Editing;
97 const double Editor::timebar_height = 15.0;
99 #include "editor_xpms"
101 static const gchar *_snap_type_strings[] = {
125 static const gchar *_snap_mode_strings[] = {
131 static const gchar *_zoom_focus_strings[] = {
140 /* Soundfile drag-n-drop */
142 Gdk::Cursor* Editor::cross_hair_cursor = 0;
143 Gdk::Cursor* Editor::selector_cursor = 0;
144 Gdk::Cursor* Editor::trimmer_cursor = 0;
145 Gdk::Cursor* Editor::grabber_cursor = 0;
146 Gdk::Cursor* Editor::zoom_cursor = 0;
147 Gdk::Cursor* Editor::time_fx_cursor = 0;
148 Gdk::Cursor* Editor::fader_cursor = 0;
149 Gdk::Cursor* Editor::speaker_cursor = 0;
150 Gdk::Cursor* Editor::wait_cursor = 0;
151 Gdk::Cursor* Editor::timebar_cursor = 0;
154 show_me_the_size (Requisition* r, const char* what)
156 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
160 check_adjustment (Gtk::Adjustment* adj)
162 cerr << "CHANGE adj = "
163 << adj->get_lower () << ' '
164 << adj->get_upper () << ' '
165 << adj->get_value () << ' '
166 << adj->get_step_increment () << ' '
167 << adj->get_page_increment () << ' '
168 << adj->get_page_size () << ' '
173 Editor::Editor (AudioEngine& eng)
176 /* time display buttons */
178 minsec_label (_("Mins:Secs")),
179 bbt_label (_("Bars:Beats")),
180 smpte_label (_("Timecode")),
181 frame_label (_("Frames")),
182 tempo_label (_("Tempo")),
183 meter_label (_("Meter")),
184 mark_label (_("Location Markers")),
185 range_mark_label (_("Range Markers")),
186 transport_mark_label (_("Loop/Punch Ranges")),
188 edit_packer (3, 3, false),
190 /* the values here don't matter: layout widgets
191 reset them as needed.
194 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
195 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
197 /* tool bar related */
199 edit_cursor_clock (X_("EditCursorClock"), true),
200 zoom_range_clock (X_("ZoomRangeClock"), true, true),
202 toolbar_selection_clock_table (2,3),
204 automation_mode_button (_("mode")),
205 global_automation_button (_("automation")),
207 /* <CMT Additions> */
208 image_socket_listener(0),
209 /* </CMT Additions> */
213 nudge_clock (X_("NudgeClock"), true, true)
218 /* we are a singleton */
220 PublicEditor::_instance = this;
224 selection = new Selection;
225 cut_buffer = new Selection;
227 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
228 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
229 selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
230 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
232 clicked_regionview = 0;
233 clicked_trackview = 0;
234 clicked_audio_trackview = 0;
235 clicked_crossfadeview = 0;
236 clicked_control_point = 0;
237 latest_regionview = 0;
238 last_update_frame = 0;
240 current_mixer_strip = 0;
241 current_bbt_points = 0;
243 snap_type_strings = I18N (_snap_type_strings);
244 snap_mode_strings = I18N (_snap_mode_strings);
245 zoom_focus_strings = I18N(_zoom_focus_strings);
247 snap_type = SnapToFrame;
248 set_snap_to (snap_type);
249 snap_mode = SnapNormal;
250 set_snap_mode (snap_mode);
251 snap_threshold = 5.0;
252 bbt_beat_subdivision = 4;
255 autoscroll_active = false;
256 autoscroll_timeout_tag = -1;
257 interthread_progress_window = 0;
263 current_interthread_info = 0;
264 _show_measures = true;
265 _show_waveforms = true;
266 _show_waveforms_recording = true;
267 first_action_message = 0;
269 show_gain_after_trim = false;
270 ignore_route_list_reorder = false;
271 no_route_list_redisplay = false;
272 verbose_cursor_on = true;
273 route_removal = false;
275 show_automatic_regions_in_region_list = true;
276 region_list_sort_type = (Editing::RegionListSortType) 0;
277 have_pending_keyboard_selection = false;
278 _follow_playhead = true;
279 _xfade_visibility = true;
280 editor_ruler_menu = 0;
281 no_ruler_shown_update = false;
282 edit_group_list_menu = 0;
284 region_list_menu = 0;
286 range_marker_menu = 0;
287 marker_menu_item = 0;
289 transport_marker_menu = 0;
290 new_transport_marker_menu = 0;
291 editor_mixer_strip_width = Wide;
292 show_editor_mixer_when_tracks_arrive = false;
293 repos_zoom_queued = false;
294 region_edit_menu_split_item = 0;
296 region_edit_menu_split_multichannel_item = 0;
298 ignore_mouse_mode_toggle = false;
299 current_stepping_trackview = 0;
301 entered_regionview = 0;
302 clear_entered_track = false;
303 _new_regionviews_show_envelope = false;
304 current_timestretch = 0;
305 in_edit_group_row_change = false;
306 last_canvas_frame = 0;
309 button_release_can_deselect = true;
310 canvas_idle_queued = false;
312 location_marker_color = color_map[cLocationMarker];
313 location_range_color = color_map[cLocationRange];
314 location_cd_marker_color = color_map[cLocationCDMarker];
315 location_loop_color = color_map[cLocationLoop];
316 location_punch_color = color_map[cLocationPunch];
318 range_marker_drag_rect = 0;
319 marker_drag_line = 0;
321 set_mouse_mode (MouseObject, true);
323 frames_per_unit = 2048; /* too early to use set_frames_per_unit */
324 reset_hscrollbar_stepping ();
326 zoom_focus = ZoomFocusLeft;
327 set_zoom_focus (ZoomFocusLeft);
328 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
330 initialize_rulers ();
331 initialize_canvas ();
333 edit_controls_vbox.set_spacing (0);
334 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled));
335 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling));
337 track_canvas.set_hadjustment (horizontal_adjustment);
338 track_canvas.set_vadjustment (vertical_adjustment);
339 time_canvas.set_hadjustment (horizontal_adjustment);
341 track_canvas.signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
342 time_canvas.signal_map_event().connect (mem_fun (*this, &Editor::time_canvas_map_handler));
344 controls_layout.add (edit_controls_vbox);
345 controls_layout.set_name ("EditControlsBase");
346 controls_layout.add_events (Gdk::SCROLL_MASK);
347 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
349 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
350 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
351 controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
353 edit_vscrollbar.set_adjustment (vertical_adjustment);
354 edit_hscrollbar.set_adjustment (horizontal_adjustment);
356 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press));
357 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release));
358 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
363 edit_cursor_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_cursor_clock_changed));
365 time_canvas_vbox.pack_start (*minsec_ruler, false, false);
366 time_canvas_vbox.pack_start (*smpte_ruler, false, false);
367 time_canvas_vbox.pack_start (*frames_ruler, false, false);
368 time_canvas_vbox.pack_start (*bbt_ruler, false, false);
369 time_canvas_vbox.pack_start (time_canvas, true, true);
370 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars));
372 bbt_label.set_name ("EditorTimeButton");
373 bbt_label.set_size_request (-1, (int)timebar_height);
374 bbt_label.set_alignment (1.0, 0.5);
375 bbt_label.set_padding (5,0);
376 minsec_label.set_name ("EditorTimeButton");
377 minsec_label.set_size_request (-1, (int)timebar_height);
378 minsec_label.set_alignment (1.0, 0.5);
379 minsec_label.set_padding (5,0);
380 smpte_label.set_name ("EditorTimeButton");
381 smpte_label.set_size_request (-1, (int)timebar_height);
382 smpte_label.set_alignment (1.0, 0.5);
383 smpte_label.set_padding (5,0);
384 frame_label.set_name ("EditorTimeButton");
385 frame_label.set_size_request (-1, (int)timebar_height);
386 frame_label.set_alignment (1.0, 0.5);
387 frame_label.set_padding (5,0);
388 tempo_label.set_name ("EditorTimeButton");
389 tempo_label.set_size_request (-1, (int)timebar_height);
390 tempo_label.set_alignment (1.0, 0.5);
391 tempo_label.set_padding (5,0);
392 meter_label.set_name ("EditorTimeButton");
393 meter_label.set_size_request (-1, (int)timebar_height);
394 meter_label.set_alignment (1.0, 0.5);
395 meter_label.set_padding (5,0);
396 mark_label.set_name ("EditorTimeButton");
397 mark_label.set_size_request (-1, (int)timebar_height);
398 mark_label.set_alignment (1.0, 0.5);
399 mark_label.set_padding (5,0);
400 range_mark_label.set_name ("EditorTimeButton");
401 range_mark_label.set_size_request (-1, (int)timebar_height);
402 range_mark_label.set_alignment (1.0, 0.5);
403 range_mark_label.set_padding (5,0);
404 transport_mark_label.set_name ("EditorTimeButton");
405 transport_mark_label.set_size_request (-1, (int)timebar_height);
406 transport_mark_label.set_alignment (1.0, 0.5);
407 transport_mark_label.set_padding (5,0);
409 time_button_vbox.pack_start (minsec_label, false, false);
410 time_button_vbox.pack_start (smpte_label, false, false);
411 time_button_vbox.pack_start (frame_label, false, false);
412 time_button_vbox.pack_start (bbt_label, false, false);
413 time_button_vbox.pack_start (meter_label, false, false);
414 time_button_vbox.pack_start (tempo_label, false, false);
415 time_button_vbox.pack_start (mark_label, false, false);
417 time_button_event_box.add (time_button_vbox);
419 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
420 time_button_event_box.set_name ("TimebarLabelBase");
421 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
423 /* these enable us to have a dedicated window (for cursor setting, etc.)
424 for the canvas areas.
427 track_canvas_event_box.add (track_canvas);
429 time_canvas_event_box.add (time_canvas_vbox);
430 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
432 edit_packer.set_col_spacings (0);
433 edit_packer.set_row_spacings (0);
434 edit_packer.set_homogeneous (false);
435 edit_packer.set_border_width (0);
436 edit_packer.set_name ("EditorWindow");
438 edit_packer.attach (edit_vscrollbar, 0, 1, 1, 3, FILL, FILL|EXPAND, 0, 0);
440 edit_packer.attach (time_button_event_box, 1, 2, 0, 1, FILL, FILL, 0, 0);
441 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
443 edit_packer.attach (controls_layout, 1, 2, 1, 2, FILL, FILL|EXPAND, 0, 0);
444 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 2, FILL|EXPAND, FILL|EXPAND, 0, 0);
446 edit_packer.attach (edit_hscrollbar, 2, 3, 2, 3, FILL|EXPAND, FILL, 0, 0);
448 bottom_hbox.set_border_width (2);
449 bottom_hbox.set_spacing (3);
451 route_display_model = ListStore::create(route_display_columns);
452 route_list_display.set_model (route_display_model);
453 route_list_display.append_column (_("Visible"), route_display_columns.visible);
454 route_list_display.append_column (_("Name"), route_display_columns.text);
455 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
456 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
457 route_list_display.set_headers_visible (true);
458 route_list_display.set_name ("TrackListDisplay");
459 route_list_display.get_selection()->set_mode (SELECTION_NONE);
460 route_list_display.set_reorderable (true);
461 route_list_display.set_size_request (100,-1);
463 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
464 route_list_visible_cell->property_activatable() = true;
465 route_list_visible_cell->property_radio() = false;
467 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
468 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
470 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
472 route_list_scroller.add (route_list_display);
473 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
475 group_model = ListStore::create(group_columns);
476 edit_group_display.set_model (group_model);
477 edit_group_display.append_column (_("Name"), group_columns.text);
478 edit_group_display.append_column (_("Active"), group_columns.is_active);
479 edit_group_display.append_column (_("Visible"), group_columns.is_visible);
480 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
481 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
482 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
483 edit_group_display.get_column (0)->set_expand (true);
484 edit_group_display.get_column (1)->set_expand (false);
485 edit_group_display.get_column (2)->set_expand (false);
486 edit_group_display.set_headers_visible (true);
488 /* name is directly editable */
490 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
491 name_cell->property_editable() = true;
492 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
494 /* use checkbox for the active + visible columns */
496 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
497 active_cell->property_activatable() = true;
498 active_cell->property_radio() = false;
500 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
501 active_cell->property_activatable() = true;
502 active_cell->property_radio() = false;
504 edit_group_display.set_name ("EditGroupList");
506 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
508 edit_group_display.set_name ("EditGroupList");
509 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
510 edit_group_display.set_reorderable (false);
511 edit_group_display.set_rules_hint (true);
512 edit_group_display.set_size_request (75, -1);
514 edit_group_display_scroller.add (edit_group_display);
515 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
517 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
519 VBox* edit_group_display_packer = manage (new VBox());
520 HBox* edit_group_display_button_box = manage (new HBox());
521 edit_group_display_button_box->set_homogeneous (true);
523 Button* edit_group_add_button = manage (new Button ());
524 Button* edit_group_remove_button = manage (new Button ());
528 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
530 edit_group_add_button->add (*w);
532 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
534 edit_group_remove_button->add (*w);
536 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
537 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
539 edit_group_display_button_box->pack_start (*edit_group_add_button);
540 edit_group_display_button_box->pack_start (*edit_group_remove_button);
542 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
543 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
545 region_list_display.set_size_request (100, -1);
546 region_list_display.set_name ("RegionListDisplay");
548 region_list_model = TreeStore::create (region_list_columns);
549 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
550 region_list_model->set_sort_column (0, SORT_ASCENDING);
552 region_list_display.set_model (region_list_model);
553 region_list_display.append_column (_("Regions"), region_list_columns.name);
554 region_list_display.set_headers_visible (false);
556 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
558 TreeViewColumn* tv_col = region_list_display.get_column(0);
559 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
560 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
561 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
563 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
564 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
566 /* setup DnD handling */
568 list<TargetEntry> region_list_target_table;
570 region_list_target_table.push_back (TargetEntry ("text/plain"));
571 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
572 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
574 region_list_display.add_drop_targets (region_list_target_table);
575 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
577 region_list_scroller.add (region_list_display);
578 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
580 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
581 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
582 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
583 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
584 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
585 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
587 named_selection_scroller.add (named_selection_display);
588 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
590 named_selection_model = TreeStore::create (named_selection_columns);
591 named_selection_display.set_model (named_selection_model);
592 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
593 named_selection_display.set_headers_visible (false);
594 named_selection_display.set_size_request (100, -1);
595 named_selection_display.set_name ("RegionListDisplay");
597 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
598 named_selection_display.set_size_request (100, -1);
599 named_selection_display.signal_button_press_event().connect (mem_fun(*this, &Editor::named_selection_display_button_press), false);
600 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
604 snapshot_display_model = ListStore::create (snapshot_display_columns);
605 snapshot_display.set_model (snapshot_display_model);
606 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
607 snapshot_display.set_name ("SnapshotDisplayList");
608 snapshot_display.set_size_request (75, -1);
609 snapshot_display.set_headers_visible (false);
610 snapshot_display.set_reorderable (false);
611 snapshot_display_scroller.add (snapshot_display);
612 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
614 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
615 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
619 nlabel = manage (new Label (_("Regions")));
620 nlabel->set_angle (-90);
621 the_notebook.append_page (region_list_scroller, *nlabel);
622 nlabel = manage (new Label (_("Tracks/Busses")));
623 nlabel->set_angle (-90);
624 the_notebook.append_page (route_list_scroller, *nlabel);
625 nlabel = manage (new Label (_("Snapshots")));
626 nlabel->set_angle (-90);
627 the_notebook.append_page (snapshot_display_scroller, *nlabel);
628 nlabel = manage (new Label (_("Edit Groups")));
629 nlabel->set_angle (-90);
630 the_notebook.append_page (*edit_group_display_packer, *nlabel);
631 nlabel = manage (new Label (_("Chunks")));
632 nlabel->set_angle (-90);
633 the_notebook.append_page (named_selection_scroller, *nlabel);
635 the_notebook.set_show_tabs (true);
636 the_notebook.set_scrollable (true);
637 the_notebook.popup_enable ();
638 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
640 edit_pane.pack1 (edit_packer, true, true);
641 edit_pane.pack2 (the_notebook, false, true);
643 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
645 top_hbox.pack_start (toolbar_frame, true, true);
647 HBox *hbox = manage (new HBox);
648 hbox->pack_start (edit_pane, true, true);
650 global_vpacker.pack_start (top_hbox, false, false);
651 global_vpacker.pack_start (*hbox, true, true);
653 global_hpacker.pack_start (global_vpacker, true, true);
655 set_name ("EditorWindow");
656 add_accel_group (ActionManager::ui_manager->get_accel_group());
658 vpacker.pack_end (global_hpacker, true, true);
660 /* register actions now so that set_state() can find them and set toggles/checks etc */
664 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
667 _playlist_selector = new PlaylistSelector();
668 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
670 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
674 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
675 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
677 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
678 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
680 nudge_forward_button.set_name ("TransportButton");
681 nudge_backward_button.set_name ("TransportButton");
683 fade_context_menu.set_name ("ArdourContextMenu");
685 set_title (_("ardour: editor"));
686 set_wmclass (_("ardour_editor"), "Ardour");
689 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
691 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
692 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
694 /* allow external control surfaces/protocols to do various things */
696 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
697 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
698 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
699 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
701 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
709 /* <CMT Additions> */
710 if(image_socket_listener)
712 if(image_socket_listener->is_connected())
714 image_socket_listener->close_connection() ;
717 delete image_socket_listener ;
718 image_socket_listener = 0 ;
720 /* </CMT Additions> */
724 Editor::add_toplevel_controls (Container& cont)
726 vpacker.pack_start (cont, false, false);
731 Editor::catch_vanishing_regionview (RegionView *rv)
733 /* note: the selection will take care of the vanishing
734 audioregionview by itself.
737 if (clicked_regionview == rv) {
738 clicked_regionview = 0;
741 if (entered_regionview == rv) {
742 set_entered_regionview (0);
747 Editor::set_entered_regionview (RegionView* rv)
749 if (rv == entered_regionview) {
753 if (entered_regionview) {
754 entered_regionview->exited ();
757 if ((entered_regionview = rv) != 0) {
758 entered_regionview->entered ();
763 Editor::set_entered_track (TimeAxisView* tav)
766 entered_track->exited ();
769 if ((entered_track = tav) != 0) {
770 entered_track->entered ();
775 Editor::show_window ()
780 /* now reset all audio_time_axis heights, because widgets might need
786 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
787 tv = (static_cast<TimeAxisView*>(*i));
793 Editor::tie_vertical_scrolling ()
795 double y1 = vertical_adjustment.get_value();
796 controls_layout.get_vadjustment()->set_value (y1);
797 playhead_cursor->set_y_axis(y1);
798 edit_cursor->set_y_axis(y1);
802 Editor::set_frames_per_unit (double fpu)
806 if (fpu == frames_per_unit) {
814 // convert fpu to frame count
816 frames = (nframes_t) floor (fpu * canvas_width);
818 /* don't allow zooms that fit more than the maximum number
819 of frames into an 800 pixel wide space.
822 if (max_frames / fpu < 800.0) {
826 if (fpu == frames_per_unit) {
830 frames_per_unit = fpu;
832 if (frames != zoom_range_clock.current_duration()) {
833 zoom_range_clock.set (frames);
836 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
837 if (!selection->tracks.empty()) {
838 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
839 (*i)->reshow_selection (selection->time);
842 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
843 (*i)->reshow_selection (selection->time);
848 ZoomChanged (); /* EMIT_SIGNAL */
850 reset_hscrollbar_stepping ();
851 reset_scrolling_region ();
853 if (edit_cursor) edit_cursor->set_position (edit_cursor->current_frame);
854 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
861 Editor::instant_save ()
863 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
868 session->add_instant_xml(get_state(), session->path());
870 Config->add_instant_xml(get_state(), get_user_ardour_path());
875 Editor::reposition_x_origin (nframes_t frame)
877 if (frame != leftmost_frame) {
878 leftmost_frame = frame;
880 nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
882 if (rightmost_frame > last_canvas_frame) {
883 last_canvas_frame = rightmost_frame;
884 reset_scrolling_region ();
887 horizontal_adjustment.set_value (frame/frames_per_unit);
889 update_fixed_rulers();
890 tempo_map_changed (Change (0));
895 Editor::edit_cursor_clock_changed()
897 if (edit_cursor->current_frame != edit_cursor_clock.current_time()) {
898 edit_cursor->set_position (edit_cursor_clock.current_time());
904 Editor::zoom_adjustment_changed ()
910 double fpu = zoom_range_clock.current_duration() / canvas_width;
914 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
915 } else if (fpu > session->current_end_frame() / canvas_width) {
916 fpu = session->current_end_frame() / canvas_width;
917 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
924 Editor::control_scroll (float fraction)
926 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
932 double step = fraction * current_page_frames();
935 if ((fraction < 0.0f) && (session->transport_frame() < (nframes_t) fabs(step))) {
937 } else if ((fraction > 0.0f) && (max_frames - session->transport_frame() < step)) {
938 target = (max_frames - (current_page_frames()*2)); // allow room for slop in where the PH is on the screen
940 target = (session->transport_frame() + (nframes_t) floor ((fraction * current_page_frames())));
943 /* move visuals, we'll catch up with it later */
945 playhead_cursor->set_position (target);
947 if (target > (current_page_frames() / 2)) {
948 /* try to center PH in window */
949 reposition_x_origin (target - (current_page_frames()/2));
951 reposition_x_origin (0);
954 /* cancel the existing */
956 control_scroll_connection.disconnect ();
958 /* add the next one */
960 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), target), 50);
964 Editor::deferred_control_scroll (nframes_t target)
966 session->request_locate (target);
971 Editor::canvas_horizontally_scrolled ()
974 leftmost_frame = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
975 update_fixed_rulers ();
976 tempo_map_changed (Change (0));
981 Editor::reposition_and_zoom (nframes_t frame, double nfpu)
983 if (!repos_zoom_queued) {
984 repos_zoom_queued = true;
985 Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::deferred_reposition_and_zoom), frame, nfpu));
990 Editor::deferred_reposition_and_zoom (nframes_t frame, double nfpu)
993 set_frames_per_unit (nfpu);
994 reposition_x_origin (frame);
995 repos_zoom_queued = false;
1001 Editor::on_realize ()
1003 Window::on_realize ();
1008 Editor::start_scrolling ()
1010 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1011 (mem_fun(*this, &Editor::update_current_screen));
1015 Editor::stop_scrolling ()
1017 scroll_connection.disconnect ();
1021 Editor::map_position_change (nframes_t frame)
1023 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1025 if (session == 0 || !_follow_playhead) {
1029 center_screen (frame);
1030 playhead_cursor->set_position (frame);
1034 Editor::center_screen (nframes_t frame)
1036 double page = canvas_width * frames_per_unit;
1038 /* if we're off the page, then scroll.
1041 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1042 center_screen_internal (frame, page);
1047 Editor::center_screen_internal (nframes_t frame, float page)
1052 frame -= (nframes_t) page;
1057 reposition_x_origin (frame);
1061 Editor::handle_new_duration ()
1063 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1065 nframes_t new_end = session->get_maximum_extent() + (nframes_t) floorf (current_page_frames() * 0.10f);
1067 if (new_end > last_canvas_frame) {
1068 last_canvas_frame = new_end;
1069 reset_scrolling_region ();
1072 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1076 Editor::update_title_s (const string & snap_name)
1078 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1084 Editor::update_title ()
1086 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1089 bool dirty = session->dirty();
1091 string wintitle = _("ardour: editor: ");
1097 wintitle += session->name();
1099 if (session->snap_name() != session->name()) {
1101 wintitle += session->snap_name();
1108 set_title (wintitle);
1113 Editor::connect_to_session (Session *t)
1117 if (first_action_message) {
1118 first_action_message->hide();
1123 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1124 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1126 /* These signals can all be emitted by a non-GUI thread. Therefore the
1127 handlers for them must not attempt to directly interact with the GUI,
1128 but use Gtkmm2ext::UI::instance()->call_slot();
1131 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1132 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1133 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1134 session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::handle_new_audio_region)));
1135 session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::handle_audio_region_removed)));
1136 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1137 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1138 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1139 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1140 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1141 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1142 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1143 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1144 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1146 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1148 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1150 edit_groups_changed ();
1152 edit_cursor_clock.set_session (session);
1153 zoom_range_clock.set_session (session);
1154 _playlist_selector->set_session (session);
1155 nudge_clock.set_session (session);
1158 if (analysis_window != 0)
1159 analysis_window->set_session (session);
1162 Location* loc = session->locations()->auto_loop_location();
1164 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1165 if (loc->start() == loc->end()) {
1166 loc->set_end (loc->start() + 1);
1168 session->locations()->add (loc, false);
1169 session->set_auto_loop_location (loc);
1173 loc->set_name (_("Loop"));
1176 loc = session->locations()->auto_punch_location();
1178 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1179 if (loc->start() == loc->end()) {
1180 loc->set_end (loc->start() + 1);
1182 session->locations()->add (loc, false);
1183 session->set_auto_punch_location (loc);
1187 loc->set_name (_("Punch"));
1190 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1192 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1194 refresh_location_display ();
1195 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1196 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1197 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1198 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1199 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1201 handle_new_duration ();
1203 redisplay_regions ();
1204 redisplay_named_selections ();
1205 redisplay_snapshots ();
1207 initial_route_list_display ();
1209 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1210 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1213 /* ::reposition_x_origin() doesn't work right here, since the old
1214 position may be zero already, and it does nothing in such
1220 horizontal_adjustment.set_value (0);
1222 restore_ruler_visibility ();
1223 //tempo_map_changed (Change (0));
1224 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1226 edit_cursor->set_position (0);
1227 playhead_cursor->set_position (0);
1231 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1234 /* don't show master bus in a new session */
1236 if (ARDOUR_UI::instance()->session_is_new ()) {
1238 TreeModel::Children rows = route_display_model->children();
1239 TreeModel::Children::iterator i;
1241 no_route_list_redisplay = true;
1243 for (i = rows.begin(); i != rows.end(); ++i) {
1244 TimeAxisView *tv = (*i)[route_display_columns.tv];
1245 AudioTimeAxisView *atv;
1247 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1248 if (atv->route()->master()) {
1249 route_list_display.get_selection()->unselect (i);
1254 no_route_list_redisplay = false;
1255 redisplay_route_list ();
1258 /* register for undo history */
1260 session->register_with_memento_command_factory(_id, this);
1264 Editor::build_cursors ()
1266 using namespace Gdk;
1268 Gdk::Color mbg ("#000000" ); /* Black */
1269 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1272 RefPtr<Bitmap> source, mask;
1273 source = Bitmap::create (mag_bits, mag_width, mag_height);
1274 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1275 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1278 Gdk::Color fbg ("#ffffff" );
1279 Gdk::Color ffg ("#000000" );
1282 RefPtr<Bitmap> source, mask;
1284 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1285 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1286 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1290 RefPtr<Bitmap> source, mask;
1291 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1292 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1293 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1296 grabber_cursor = new Gdk::Cursor (HAND2);
1297 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1298 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1299 selector_cursor = new Gdk::Cursor (XTERM);
1300 time_fx_cursor = new Gdk::Cursor (SIZING);
1301 wait_cursor = new Gdk::Cursor (WATCH);
1302 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1306 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1308 using namespace Menu_Helpers;
1309 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1312 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1316 MenuList& items (fade_context_menu.items());
1320 switch (item_type) {
1322 case FadeInHandleItem:
1323 if (arv->audio_region()->fade_in_active()) {
1324 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), false)));
1326 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), true)));
1329 items.push_back (SeparatorElem());
1331 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::Linear)));
1332 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::LogB)));
1333 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::Fast)));
1334 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::LogA)));
1335 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::Slow)));
1339 case FadeOutHandleItem:
1340 if (arv->audio_region()->fade_out_active()) {
1341 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), false)));
1343 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), true)));
1346 items.push_back (SeparatorElem());
1348 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::Linear)));
1349 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::Fast)));
1350 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::LogB)));
1351 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::LogA)));
1352 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::Slow)));
1357 fatal << _("programming error: ")
1358 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1363 fade_context_menu.popup (button, time);
1367 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes_t frame)
1369 using namespace Menu_Helpers;
1370 Menu* (Editor::*build_menu_function)(nframes_t);
1373 switch (item_type) {
1375 case RegionViewName:
1376 case RegionViewNameHighlight:
1377 if (with_selection) {
1378 build_menu_function = &Editor::build_track_selection_context_menu;
1380 build_menu_function = &Editor::build_track_region_context_menu;
1385 if (with_selection) {
1386 build_menu_function = &Editor::build_track_selection_context_menu;
1388 build_menu_function = &Editor::build_track_context_menu;
1392 case CrossfadeViewItem:
1393 build_menu_function = &Editor::build_track_crossfade_context_menu;
1397 if (clicked_audio_trackview->get_diskstream()) {
1398 build_menu_function = &Editor::build_track_context_menu;
1400 build_menu_function = &Editor::build_track_bus_context_menu;
1405 /* probably shouldn't happen but if it does, we don't care */
1409 menu = (this->*build_menu_function)(frame);
1410 menu->set_name ("ArdourContextMenu");
1412 /* now handle specific situations */
1414 switch (item_type) {
1416 case RegionViewName:
1417 case RegionViewNameHighlight:
1418 if (!with_selection) {
1419 if (region_edit_menu_split_item) {
1420 if (clicked_regionview && clicked_regionview->region()->covers (edit_cursor->current_frame)) {
1421 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
1423 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
1427 if (region_edit_menu_split_multichannel_item) {
1428 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1429 // GTK2FIX find the action, change its sensitivity
1430 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1432 // GTK2FIX see above
1433 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1442 case CrossfadeViewItem:
1449 /* probably shouldn't happen but if it does, we don't care */
1453 if (clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
1455 /* Bounce to disk */
1457 using namespace Menu_Helpers;
1458 MenuList& edit_items = menu->items();
1460 edit_items.push_back (SeparatorElem());
1462 switch (clicked_audio_trackview->audio_track()->freeze_state()) {
1463 case AudioTrack::NoFreeze:
1464 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1467 case AudioTrack::Frozen:
1468 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1471 case AudioTrack::UnFrozen:
1472 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1478 menu->popup (button, time);
1482 Editor::build_track_context_menu (nframes_t ignored)
1484 using namespace Menu_Helpers;
1486 MenuList& edit_items = track_context_menu.items();
1489 add_dstream_context_items (edit_items);
1490 return &track_context_menu;
1494 Editor::build_track_bus_context_menu (nframes_t ignored)
1496 using namespace Menu_Helpers;
1498 MenuList& edit_items = track_context_menu.items();
1501 add_bus_context_items (edit_items);
1502 return &track_context_menu;
1506 Editor::build_track_region_context_menu (nframes_t frame)
1508 using namespace Menu_Helpers;
1509 MenuList& edit_items = track_region_context_menu.items();
1512 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1515 boost::shared_ptr<Diskstream> ds;
1518 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1519 Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)frame * ds->speed()));
1520 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1521 add_region_context_items (atv->audio_view(), (*i), edit_items);
1527 add_dstream_context_items (edit_items);
1529 return &track_region_context_menu;
1533 Editor::build_track_crossfade_context_menu (nframes_t frame)
1535 using namespace Menu_Helpers;
1536 MenuList& edit_items = track_crossfade_context_menu.items();
1537 edit_items.clear ();
1539 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1542 boost::shared_ptr<Diskstream> ds;
1546 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = dynamic_cast<AudioPlaylist*> (pl)) != 0)) {
1548 Playlist::RegionList* regions = pl->regions_at (frame);
1549 AudioPlaylist::Crossfades xfades;
1551 apl->crossfades_at (frame, xfades);
1553 bool many = xfades.size() > 1;
1555 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1556 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1559 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1560 add_region_context_items (atv->audio_view(), (*i), edit_items);
1567 add_dstream_context_items (edit_items);
1569 return &track_crossfade_context_menu;
1574 Editor::analyze_region_selection()
1576 if (analysis_window == 0) {
1577 analysis_window = new AnalysisWindow();
1580 analysis_window->set_session(session);
1582 analysis_window->show_all();
1585 analysis_window->set_regionmode();
1586 analysis_window->analyze();
1588 analysis_window->present();
1592 Editor::analyze_range_selection()
1594 if (analysis_window == 0) {
1595 analysis_window = new AnalysisWindow();
1598 analysis_window->set_session(session);
1600 analysis_window->show_all();
1603 analysis_window->set_rangemode();
1604 analysis_window->analyze();
1606 analysis_window->present();
1608 #endif /* FFT_ANALYSIS */
1613 Editor::build_track_selection_context_menu (nframes_t ignored)
1615 using namespace Menu_Helpers;
1616 MenuList& edit_items = track_selection_context_menu.items();
1617 edit_items.clear ();
1619 add_selection_context_items (edit_items);
1620 add_dstream_context_items (edit_items);
1622 return &track_selection_context_menu;
1626 Editor::add_crossfade_context_items (AudioStreamView* view, Crossfade* xfade, Menu_Helpers::MenuList& edit_items, bool many)
1628 using namespace Menu_Helpers;
1629 Menu *xfade_menu = manage (new Menu);
1630 MenuList& items = xfade_menu->items();
1631 xfade_menu->set_name ("ArdourContextMenu");
1634 if (xfade->active()) {
1640 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), xfade)));
1641 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), xfade)));
1643 if (xfade->can_follow_overlap()) {
1645 if (xfade->following_overlap()) {
1646 str = _("Convert to short");
1648 str = _("Convert to full");
1651 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1655 str = xfade->out()->name();
1657 str += xfade->in()->name();
1659 str = _("Crossfade");
1662 edit_items.push_back (MenuElem (str, *xfade_menu));
1663 edit_items.push_back (SeparatorElem());
1667 Editor::xfade_edit_left_region ()
1669 if (clicked_crossfadeview) {
1670 clicked_crossfadeview->left_view.show_region_editor ();
1675 Editor::xfade_edit_right_region ()
1677 if (clicked_crossfadeview) {
1678 clicked_crossfadeview->right_view.show_region_editor ();
1683 Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1685 using namespace Menu_Helpers;
1686 Menu *region_menu = manage (new Menu);
1687 MenuList& items = region_menu->items();
1688 region_menu->set_name ("ArdourContextMenu");
1690 boost::shared_ptr<AudioRegion> ar;
1693 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1696 /* when this particular menu pops up, make the relevant region
1700 // region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1702 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1703 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1704 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1705 items.push_back (SeparatorElem());
1706 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_cursor)));
1707 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1708 items.push_back (SeparatorElem());
1710 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::audition_selected_region)));
1711 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1712 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1715 items.push_back (MenuElem (_("Analyze region"), mem_fun(*this, &Editor::analyze_region_selection)));
1718 items.push_back (SeparatorElem());
1720 items.push_back (CheckMenuElem (_("Lock"), mem_fun(*this, &Editor::toggle_region_lock)));
1721 region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1722 if (region->locked()) {
1723 region_lock_item->set_active();
1725 items.push_back (CheckMenuElem (_("Mute"), mem_fun(*this, &Editor::toggle_region_mute)));
1726 region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1727 if (region->muted()) {
1728 region_mute_item->set_active();
1730 items.push_back (CheckMenuElem (_("Opaque"), mem_fun(*this, &Editor::toggle_region_opaque)));
1731 region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1732 if (region->opaque()) {
1733 region_opaque_item->set_active();
1736 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1737 if (region->at_natural_position()) {
1738 items.back().set_sensitive (false);
1741 items.push_back (SeparatorElem());
1745 RegionView* rv = sv->find_view (ar);
1746 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1748 items.push_back (CheckMenuElem (_("Envelope visible"), mem_fun(*this, &Editor::toggle_gain_envelope_visibility)));
1749 region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1751 if (arv->envelope_visible()) {
1752 region_envelope_visible_item->set_active (true);
1755 items.push_back (CheckMenuElem (_("Envelope active"), mem_fun(*this, &Editor::toggle_gain_envelope_active)));
1756 region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1758 if (ar->envelope_active()) {
1759 region_envelope_active_item->set_active (true);
1762 items.push_back (SeparatorElem());
1764 if (ar->scale_amplitude() != 1.0f) {
1765 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1767 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1770 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1771 items.push_back (SeparatorElem());
1774 /* range related stuff */
1776 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1777 items.push_back (MenuElem (_("Set Range"), mem_fun (*this, &Editor::set_selection_from_audio_region)));
1778 items.push_back (SeparatorElem());
1782 Menu *nudge_menu = manage (new Menu());
1783 MenuList& nudge_items = nudge_menu->items();
1784 nudge_menu->set_name ("ArdourContextMenu");
1786 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1787 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1788 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1789 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1791 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1792 items.push_back (SeparatorElem());
1794 Menu *trim_menu = manage (new Menu);
1795 MenuList& trim_items = trim_menu->items();
1796 trim_menu->set_name ("ArdourContextMenu");
1798 trim_items.push_back (MenuElem (_("Start to edit cursor"), mem_fun(*this, &Editor::trim_region_from_edit_cursor)));
1799 trim_items.push_back (MenuElem (_("Edit cursor to end"), mem_fun(*this, &Editor::trim_region_to_edit_cursor)));
1801 items.push_back (MenuElem (_("Trim"), *trim_menu));
1802 items.push_back (SeparatorElem());
1804 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1805 region_edit_menu_split_item = &items.back();
1807 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1808 region_edit_menu_split_multichannel_item = &items.back();
1810 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1811 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1812 items.push_back (SeparatorElem());
1813 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1815 /* OK, stick the region submenu at the top of the list, and then add
1819 /* we have to hack up the region name because "_" has a special
1820 meaning for menu titles.
1823 string::size_type pos = 0;
1824 string menu_item_name = region->name();
1826 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1827 menu_item_name.replace (pos, 1, "__");
1831 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1832 edit_items.push_back (SeparatorElem());
1836 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1838 using namespace Menu_Helpers;
1839 Menu *selection_menu = manage (new Menu);
1840 MenuList& items = selection_menu->items();
1841 selection_menu->set_name ("ArdourContextMenu");
1843 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1844 items.push_back (MenuElem (_("Loop range"), mem_fun(*this, &Editor::set_route_loop_selection)));
1847 items.push_back (SeparatorElem());
1848 items.push_back (MenuElem (_("Analyze range"), mem_fun(*this, &Editor::analyze_range_selection)));
1851 items.push_back (SeparatorElem());
1852 items.push_back (MenuElem (_("Separate range to track"), mem_fun(*this, &Editor::separate_region_from_selection)));
1853 items.push_back (MenuElem (_("Separate range to region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1855 items.push_back (SeparatorElem());
1856 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1857 items.push_back (SeparatorElem());
1858 items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1859 items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1860 items.push_back (SeparatorElem());
1861 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1862 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1863 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1864 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::name_selection)));
1865 items.push_back (SeparatorElem());
1866 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1867 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1869 edit_items.push_back (MenuElem (_("Range"), *selection_menu));
1870 edit_items.push_back (SeparatorElem());
1874 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1876 using namespace Menu_Helpers;
1880 Menu *play_menu = manage (new Menu);
1881 MenuList& play_items = play_menu->items();
1882 play_menu->set_name ("ArdourContextMenu");
1884 play_items.push_back (MenuElem (_("Play from edit cursor"), mem_fun(*this, &Editor::play_from_edit_cursor)));
1885 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1886 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1887 play_items.push_back (SeparatorElem());
1888 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1890 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1894 Menu *select_menu = manage (new Menu);
1895 MenuList& select_items = select_menu->items();
1896 select_menu->set_name ("ArdourContextMenu");
1898 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1899 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1900 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1901 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1902 select_items.push_back (SeparatorElem());
1903 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1904 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1905 select_items.push_back (SeparatorElem());
1906 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1907 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1908 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1909 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1910 select_items.push_back (MenuElem (_("Select all between cursors"), bind (mem_fun(*this, &Editor::select_all_selectables_between_cursors), playhead_cursor, edit_cursor)));
1911 select_items.push_back (SeparatorElem());
1913 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1917 Menu *cutnpaste_menu = manage (new Menu);
1918 MenuList& cutnpaste_items = cutnpaste_menu->items();
1919 cutnpaste_menu->set_name ("ArdourContextMenu");
1921 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1922 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1923 cutnpaste_items.push_back (MenuElem (_("Paste at edit cursor"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1924 cutnpaste_items.push_back (MenuElem (_("Paste at mouse"), mem_fun(*this, &Editor::mouse_paste)));
1926 cutnpaste_items.push_back (SeparatorElem());
1928 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1929 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
1931 cutnpaste_items.push_back (SeparatorElem());
1933 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
1935 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
1937 /* Adding new material */
1939 edit_items.push_back (SeparatorElem());
1940 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
1941 edit_items.push_back (MenuElem (_("Insert Existing Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
1945 Menu *nudge_menu = manage (new Menu());
1946 MenuList& nudge_items = nudge_menu->items();
1947 nudge_menu->set_name ("ArdourContextMenu");
1949 edit_items.push_back (SeparatorElem());
1950 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1951 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1952 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1953 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1955 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1959 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
1961 using namespace Menu_Helpers;
1965 Menu *play_menu = manage (new Menu);
1966 MenuList& play_items = play_menu->items();
1967 play_menu->set_name ("ArdourContextMenu");
1969 play_items.push_back (MenuElem (_("Play from edit cursor"), mem_fun(*this, &Editor::play_from_edit_cursor)));
1970 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1971 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1975 Menu *select_menu = manage (new Menu);
1976 MenuList& select_items = select_menu->items();
1977 select_menu->set_name ("ArdourContextMenu");
1979 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1980 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1981 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1982 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1983 select_items.push_back (SeparatorElem());
1984 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1985 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1986 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1987 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1989 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1993 Menu *cutnpaste_menu = manage (new Menu);
1994 MenuList& cutnpaste_items = cutnpaste_menu->items();
1995 cutnpaste_menu->set_name ("ArdourContextMenu");
1997 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1998 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1999 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2001 Menu *nudge_menu = manage (new Menu());
2002 MenuList& nudge_items = nudge_menu->items();
2003 nudge_menu->set_name ("ArdourContextMenu");
2005 edit_items.push_back (SeparatorElem());
2006 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2007 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2008 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2009 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2011 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2014 /* CURSOR SETTING AND MARKS AND STUFF */
2017 Editor::set_snap_to (SnapType st)
2020 string str = snap_type_strings[(int) st];
2022 if (str != snap_type_selector.get_active_text()) {
2023 snap_type_selector.set_active_text (str);
2028 switch (snap_type) {
2029 case SnapToAThirtysecondBeat:
2030 case SnapToASixteenthBeat:
2031 case SnapToAEighthBeat:
2032 case SnapToAQuarterBeat:
2033 case SnapToAThirdBeat:
2034 update_tempo_based_rulers ();
2042 Editor::set_snap_mode (SnapMode mode)
2045 string str = snap_mode_strings[(int)mode];
2047 if (str != snap_mode_selector.get_active_text ()) {
2048 snap_mode_selector.set_active_text (str);
2055 Editor::set_state (const XMLNode& node)
2057 const XMLProperty* prop;
2059 int x, y, xoff, yoff;
2062 if ((prop = node.property ("id")) != 0) {
2063 _id = prop->value ();
2066 if ((geometry = find_named_node (node, "geometry")) == 0) {
2068 g.base_width = default_width;
2069 g.base_height = default_height;
2077 g.base_width = atoi(geometry->property("x_size")->value());
2078 g.base_height = atoi(geometry->property("y_size")->value());
2079 x = atoi(geometry->property("x_pos")->value());
2080 y = atoi(geometry->property("y_pos")->value());
2081 xoff = atoi(geometry->property("x_off")->value());
2082 yoff = atoi(geometry->property("y_off")->value());
2085 set_default_size (g.base_width, g.base_height);
2088 if ((prop = node.property ("zoom-focus"))) {
2089 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2092 if ((prop = node.property ("zoom"))) {
2093 set_frames_per_unit (PBD::atof (prop->value()));
2096 if ((prop = node.property ("snap-to"))) {
2097 set_snap_to ((SnapType) atoi (prop->value()));
2100 if ((prop = node.property ("snap-mode"))) {
2101 set_snap_mode ((SnapMode) atoi (prop->value()));
2104 if ((prop = node.property ("mouse-mode"))) {
2105 MouseMode m = str2mousemode(prop->value());
2106 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2107 set_mouse_mode (m, true);
2109 mouse_mode = MouseGain; /* lie, to force the mode switch */
2110 set_mouse_mode (MouseObject, true);
2113 if ((prop = node.property ("show-waveforms"))) {
2114 bool yn = (prop->value() == "yes");
2115 _show_waveforms = !yn;
2116 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
2118 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2119 /* do it twice to force the change */
2120 tact->set_active (!yn);
2121 tact->set_active (yn);
2125 if ((prop = node.property ("show-waveforms-recording"))) {
2126 bool yn = (prop->value() == "yes");
2127 _show_waveforms_recording = !yn;
2128 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2130 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2131 /* do it twice to force the change */
2132 tact->set_active (!yn);
2133 tact->set_active (yn);
2137 if ((prop = node.property ("show-measures"))) {
2138 bool yn = (prop->value() == "yes");
2139 _show_measures = !yn;
2140 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2142 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2143 /* do it twice to force the change */
2144 tact->set_active (!yn);
2145 tact->set_active (yn);
2149 if ((prop = node.property ("follow-playhead"))) {
2150 bool yn = (prop->value() == "yes");
2151 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2153 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2154 /* do it twice to force the change */
2155 tact->set_active (!yn);
2156 tact->set_active (yn);
2161 if ((prop = node.property ("region-list-sort-type"))) {
2162 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2163 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2166 if ((prop = node.property ("xfades-visible"))) {
2167 bool yn = (prop->value() == "yes");
2168 _xfade_visibility = !yn;
2169 // set_xfade_visibility (yn);
2172 if ((prop = node.property ("show-editor-mixer"))) {
2174 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2177 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2178 bool yn = (prop->value() == X_("yes"));
2180 /* do it twice to force the change */
2182 tact->set_active (!yn);
2183 tact->set_active (yn);
2192 Editor::get_state ()
2194 XMLNode* node = new XMLNode ("Editor");
2197 _id.print (buf, sizeof (buf));
2198 node->add_property ("id", buf);
2200 if (is_realized()) {
2201 Glib::RefPtr<Gdk::Window> win = get_window();
2203 int x, y, xoff, yoff, width, height;
2204 win->get_root_origin(x, y);
2205 win->get_position(xoff, yoff);
2206 win->get_size(width, height);
2208 XMLNode* geometry = new XMLNode ("geometry");
2210 snprintf(buf, sizeof(buf), "%d", width);
2211 geometry->add_property("x_size", string(buf));
2212 snprintf(buf, sizeof(buf), "%d", height);
2213 geometry->add_property("y_size", string(buf));
2214 snprintf(buf, sizeof(buf), "%d", x);
2215 geometry->add_property("x_pos", string(buf));
2216 snprintf(buf, sizeof(buf), "%d", y);
2217 geometry->add_property("y_pos", string(buf));
2218 snprintf(buf, sizeof(buf), "%d", xoff);
2219 geometry->add_property("x_off", string(buf));
2220 snprintf(buf, sizeof(buf), "%d", yoff);
2221 geometry->add_property("y_off", string(buf));
2222 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2223 geometry->add_property("edit_pane_pos", string(buf));
2225 node->add_child_nocopy (*geometry);
2228 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2229 node->add_property ("zoom-focus", buf);
2230 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2231 node->add_property ("zoom", buf);
2232 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2233 node->add_property ("snap-to", buf);
2234 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2235 node->add_property ("snap-mode", buf);
2237 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2238 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2239 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2240 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2241 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2242 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2243 node->add_property ("mouse-mode", enum2str(mouse_mode));
2245 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2247 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2248 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2257 Editor::trackview_by_y_position (double y)
2259 TrackViewList::iterator iter;
2262 for (iter = track_views.begin(); iter != track_views.end(); ++iter) {
2270 if (tv->y_position <= y && y < ((tv->y_position + tv->height + track_spacing))) {
2279 Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark)
2281 Location* before = 0;
2282 Location* after = 0;
2288 const nframes_t one_second = session->frame_rate();
2289 const nframes_t one_minute = session->frame_rate() * 60;
2291 nframes_t presnap = start;
2293 switch (snap_type) {
2299 start = (nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2301 start = (nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2304 case SnapToSMPTEFrame:
2306 start = (nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2308 start = (nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2312 case SnapToSMPTESeconds:
2313 if (session->smpte_offset_negative())
2315 start += session->smpte_offset ();
2317 start -= session->smpte_offset ();
2319 if (direction > 0) {
2320 start = (nframes_t) ceil ((double) start / one_second) * one_second;
2322 start = (nframes_t) floor ((double) start / one_second) * one_second;
2325 if (session->smpte_offset_negative())
2327 start -= session->smpte_offset ();
2329 start += session->smpte_offset ();
2333 case SnapToSMPTEMinutes:
2334 if (session->smpte_offset_negative())
2336 start += session->smpte_offset ();
2338 start -= session->smpte_offset ();
2341 start = (nframes_t) ceil ((double) start / one_minute) * one_minute;
2343 start = (nframes_t) floor ((double) start / one_minute) * one_minute;
2345 if (session->smpte_offset_negative())
2347 start -= session->smpte_offset ();
2349 start += session->smpte_offset ();
2355 start = (nframes_t) ceil ((double) start / one_second) * one_second;
2357 start = (nframes_t) floor ((double) start / one_second) * one_second;
2363 start = (nframes_t) ceil ((double) start / one_minute) * one_minute;
2365 start = (nframes_t) floor ((double) start / one_minute) * one_minute;
2370 start = session->tempo_map().round_to_bar (start, direction);
2374 start = session->tempo_map().round_to_beat (start, direction);
2377 case SnapToAThirtysecondBeat:
2378 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2381 case SnapToASixteenthBeat:
2382 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2385 case SnapToAEighthBeat:
2386 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2389 case SnapToAQuarterBeat:
2390 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2393 case SnapToAThirdBeat:
2394 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2397 case SnapToEditCursor:
2398 start = edit_cursor->current_frame;
2406 before = session->locations()->first_location_before (start);
2407 after = session->locations()->first_location_after (start);
2409 if (direction < 0) {
2411 start = before->start();
2415 } else if (direction > 0) {
2417 start = after->start();
2419 start = session->current_end_frame();
2424 /* find nearest of the two */
2425 if ((start - before->start()) < (after->start() - start)) {
2426 start = before->start();
2428 start = after->start();
2431 start = before->start();
2434 start = after->start();
2441 case SnapToRegionStart:
2442 case SnapToRegionEnd:
2443 case SnapToRegionSync:
2444 case SnapToRegionBoundary:
2445 if (!region_boundary_cache.empty()) {
2446 vector<nframes_t>::iterator i;
2448 if (direction > 0) {
2449 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2451 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2454 if (i != region_boundary_cache.end()) {
2457 start = region_boundary_cache.back();
2463 switch (snap_mode) {
2469 if (presnap > start) {
2470 if (presnap > (start + unit_to_frame(snap_threshold))) {
2474 } else if (presnap < start) {
2475 if (presnap < (start - unit_to_frame(snap_threshold))) {
2487 Editor::setup_toolbar ()
2491 const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
2494 /* Mode Buttons (tool selection) */
2496 vector<ToggleButton *> mouse_mode_buttons;
2498 mouse_move_button.add (*(manage (new Image (::get_icon("tool_object")))));
2499 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2500 mouse_mode_buttons.push_back (&mouse_move_button);
2501 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2502 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2503 mouse_mode_buttons.push_back (&mouse_select_button);
2504 mouse_gain_button.add (*(manage (new Image (::get_icon("tool_gain")))));
2505 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2506 mouse_mode_buttons.push_back (&mouse_gain_button);
2507 mouse_zoom_button.add (*(manage (new Image (::get_icon("tool_zoom")))));
2508 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2509 mouse_mode_buttons.push_back (&mouse_zoom_button);
2510 mouse_timefx_button.add (*(manage (new Image (::get_icon("tool_stretch")))));
2511 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2512 mouse_mode_buttons.push_back (&mouse_timefx_button);
2513 mouse_audition_button.add (*(manage (new Image (::get_icon("tool_audition")))));
2514 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2515 mouse_mode_buttons.push_back (&mouse_audition_button);
2517 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2519 HBox* mode_box = manage(new HBox);
2520 mode_box->set_border_width (2);
2521 mode_box->set_spacing(4);
2522 mouse_mode_button_box.set_spacing(1);
2523 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2524 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2525 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2526 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2527 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2528 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2529 mouse_mode_button_box.set_homogeneous(true);
2531 vector<string> edit_mode_strings;
2532 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2533 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2535 edit_mode_selector.set_name ("EditModeSelector");
2536 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, longest (edit_mode_strings).c_str(), 2+FUDGE, 10);
2537 set_popdown_strings (edit_mode_selector, edit_mode_strings);
2538 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2540 mode_box->pack_start(edit_mode_selector);
2541 mode_box->pack_start(mouse_mode_button_box);
2543 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2544 mouse_mode_tearoff->set_name ("MouseModeBase");
2546 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2547 &mouse_mode_tearoff->tearoff_window()));
2548 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2549 &mouse_mode_tearoff->tearoff_window(), 1));
2550 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2551 &mouse_mode_tearoff->tearoff_window()));
2552 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2553 &mouse_mode_tearoff->tearoff_window(), 1));
2555 mouse_move_button.set_name ("MouseModeButton");
2556 mouse_select_button.set_name ("MouseModeButton");
2557 mouse_gain_button.set_name ("MouseModeButton");
2558 mouse_zoom_button.set_name ("MouseModeButton");
2559 mouse_timefx_button.set_name ("MouseModeButton");
2560 mouse_audition_button.set_name ("MouseModeButton");
2562 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
2563 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
2564 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
2565 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
2566 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
2567 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
2569 mouse_move_button.unset_flags (CAN_FOCUS);
2570 mouse_select_button.unset_flags (CAN_FOCUS);
2571 mouse_gain_button.unset_flags (CAN_FOCUS);
2572 mouse_zoom_button.unset_flags (CAN_FOCUS);
2573 mouse_timefx_button.unset_flags (CAN_FOCUS);
2574 mouse_audition_button.unset_flags (CAN_FOCUS);
2576 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2577 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2579 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2580 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2581 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2582 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2583 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2585 // mouse_move_button.set_active (true);
2590 zoom_box.set_spacing (1);
2591 zoom_box.set_border_width (2);
2593 zoom_in_button.set_name ("EditorTimeButton");
2594 zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in")))));
2595 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2596 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2598 zoom_out_button.set_name ("EditorTimeButton");
2599 zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out")))));
2600 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2601 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2603 zoom_out_full_button.set_name ("EditorTimeButton");
2604 zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full")))));
2605 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2606 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2608 zoom_box.pack_start (zoom_out_button, false, false);
2609 zoom_box.pack_start (zoom_in_button, false, false);
2610 zoom_box.pack_start (zoom_range_clock, false, false);
2611 zoom_box.pack_start (zoom_out_full_button, false, false);
2613 ARDOUR_UI::instance()->tooltips().set_tip (zoom_range_clock, _("Current Zoom Range\n(Width of visible area)"));
2615 zoom_focus_selector.set_name ("ZoomFocusSelector");
2616 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Focus Center", 2+FUDGE, 0);
2617 set_popdown_strings (zoom_focus_selector, zoom_focus_strings);
2618 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2619 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
2621 zoom_box.pack_start (zoom_focus_selector, false, false);
2624 /* Edit Cursor / Snap */
2626 snap_box.set_spacing (1);
2627 snap_box.set_border_width (2);
2629 snap_type_selector.set_name ("SnapTypeSelector");
2630 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, "SMPTE Seconds", 2+FUDGE, 10);
2631 set_popdown_strings (snap_type_selector, snap_type_strings);
2632 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2633 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Unit to snap cursors and ranges to"));
2635 snap_mode_selector.set_name ("SnapModeSelector");
2636 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, "Magnetic Snap", 2+FUDGE, 10);
2637 set_popdown_strings (snap_mode_selector, snap_mode_strings);
2638 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2640 snap_box.pack_start (edit_cursor_clock, false, false);
2641 snap_box.pack_start (snap_mode_selector, false, false);
2642 snap_box.pack_start (snap_type_selector, false, false);
2647 HBox *nudge_box = manage (new HBox);
2648 nudge_box->set_spacing(1);
2649 nudge_box->set_border_width (2);
2651 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2652 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2654 nudge_box->pack_start (nudge_backward_button, false, false);
2655 nudge_box->pack_start (nudge_forward_button, false, false);
2656 nudge_box->pack_start (nudge_clock, false, false);
2659 /* Pack everything in... */
2661 HBox* hbox = new HBox;
2662 hbox->set_spacing(10);
2664 tools_tearoff = new TearOff (*hbox);
2665 tools_tearoff->set_name ("MouseModeBase");
2667 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2668 &tools_tearoff->tearoff_window()));
2669 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2670 &tools_tearoff->tearoff_window(), 0));
2671 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2672 &tools_tearoff->tearoff_window()));
2673 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2674 &tools_tearoff->tearoff_window(), 0));
2676 toolbar_hbox.set_spacing (10);
2677 toolbar_hbox.set_border_width (1);
2679 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2680 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2683 hbox->pack_start (snap_box, false, false);
2684 hbox->pack_start (zoom_box, false, false);
2685 hbox->pack_start (*nudge_box, false, false);
2689 toolbar_base.set_name ("ToolBarBase");
2690 toolbar_base.add (toolbar_hbox);
2692 toolbar_frame.set_shadow_type (SHADOW_OUT);
2693 toolbar_frame.set_name ("BaseFrame");
2694 toolbar_frame.add (toolbar_base);
2698 Editor::convert_drop_to_paths (vector<ustring>& paths,
2699 const RefPtr<Gdk::DragContext>& context,
2702 const SelectionData& data,
2711 vector<ustring> uris = data.get_uris();
2715 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
2716 are actually URI lists. So do it by hand.
2719 if (data.get_target() != "text/plain") {
2723 /* Parse the "uri-list" format that Nautilus provides,
2724 where each pathname is delimited by \r\n
2727 const char* p = data.get_text().c_str();
2734 while (g_ascii_isspace (*p))
2738 while (*q && (*q != '\n') && (*q != '\r'))
2744 while (q > p && g_ascii_isspace (*q))
2749 uris.push_back (ustring (p, q - p + 1));
2753 p = strchr (p, '\n');
2763 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
2764 if ((*i).substr (0,7) == "file://") {
2766 PBD::url_decode (p);
2767 paths.push_back (p.substr (7));
2775 Editor::new_tempo_section ()
2781 Editor::map_transport_state ()
2783 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
2785 if (session->transport_stopped()) {
2786 have_pending_keyboard_selection = false;
2792 Editor::State::State ()
2794 selection = new Selection;
2797 Editor::State::~State ()
2803 Editor::get_memento () const
2805 State *state = new State;
2807 store_state (*state);
2808 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
2812 Editor::store_state (State& state) const
2814 *state.selection = *selection;
2818 Editor::restore_state (State *state)
2820 if (*selection == *state->selection) {
2824 *selection = *state->selection;
2825 time_selection_changed ();
2826 region_selection_changed ();
2828 /* XXX other selection change handlers? */
2832 Editor::begin_reversible_command (string name)
2835 before = &get_state();
2836 session->begin_reversible_command (name);
2841 Editor::commit_reversible_command ()
2844 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
2849 Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no_remove)
2851 bool commit = false;
2854 case Selection::Toggle:
2855 if (selection->selected (&view)) {
2857 selection->remove (&view);
2861 selection->add (&view);
2866 case Selection::Add:
2867 if (!selection->selected (&view)) {
2868 selection->add (&view);
2873 case Selection::Set:
2874 if (selection->selected (&view) && selection->tracks.size() == 1) {
2875 /* no commit necessary */
2878 selection->set (&view);
2881 case Selection::Extend:
2882 /* not defined yet */
2890 Editor::set_selected_track_from_click (Selection::Operation op, bool no_remove)
2892 if (!clicked_trackview) {
2896 return set_selected_track (*clicked_trackview, op, no_remove);
2900 Editor::set_selected_control_point_from_click (Selection::Operation op, bool no_remove)
2902 if (!clicked_control_point) {
2906 /* select this point and any others that it represents */
2911 x1 = pixel_to_frame (clicked_control_point->get_x() - 10);
2912 x2 = pixel_to_frame (clicked_control_point->get_x() + 10);
2913 y1 = clicked_control_point->get_x() - 10;
2914 y2 = clicked_control_point->get_y() + 10;
2916 return select_all_within (x1, x2, y1, y2, op);
2920 Editor::get_relevant_audio_tracks (set<AudioTimeAxisView*>& relevant_tracks)
2922 /* step one: get all selected tracks and all tracks in the relevant edit groups */
2924 for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) {
2926 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*ti);
2932 RouteGroup* group = atv->route()->edit_group();
2934 if (group && group->is_active()) {
2936 /* active group for this track, loop over all tracks and get every member of the group */
2938 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
2940 AudioTimeAxisView* tatv;
2942 if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
2944 if (tatv->route()->edit_group() == group) {
2945 relevant_tracks.insert (tatv);
2950 relevant_tracks.insert (atv);
2956 Editor::mapover_audio_tracks (slot<void,AudioTimeAxisView&,uint32_t> sl)
2958 set<AudioTimeAxisView*> relevant_tracks;
2960 get_relevant_audio_tracks (relevant_tracks);
2962 uint32_t sz = relevant_tracks.size();
2964 for (set<AudioTimeAxisView*>::iterator ati = relevant_tracks.begin(); ati != relevant_tracks.end(); ++ati) {
2970 Editor::mapped_set_selected_regionview_from_click (RouteTimeAxisView& tv, uint32_t ignored,
2971 RegionView* basis, vector<RegionView*>* all_equivs)
2974 vector<boost::shared_ptr<Region> > results;
2976 boost::shared_ptr<Diskstream> ds;
2978 if ((ds = tv.get_diskstream()) == 0) {
2983 if (&tv == &basis->get_time_axis_view()) {
2984 /* looking in same track as the original */
2989 if ((pl = dynamic_cast<Playlist*>(ds->playlist())) != 0) {
2990 pl->get_equivalent_regions (basis->region(), results);
2993 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
2994 if ((marv = tv.view()->find_view (*ir)) != 0) {
2995 all_equivs->push_back (marv);
3001 Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, bool no_track_remove)
3003 vector<RegionView*> all_equivalent_regions;
3004 bool commit = false;
3006 if (!clicked_regionview || !clicked_audio_trackview) {
3010 if (op == Selection::Toggle || op == Selection::Set) {
3012 mapover_audio_tracks (bind (mem_fun (*this, &Editor::mapped_set_selected_regionview_from_click),
3013 clicked_regionview, &all_equivalent_regions));
3016 /* add clicked regionview since we skipped all other regions in the same track as the one it was in */
3018 all_equivalent_regions.push_back (clicked_regionview);
3021 case Selection::Toggle:
3023 if (clicked_regionview->get_selected()) {
3026 /* whatever was clicked was selected already; do nothing here but allow
3027 the button release to deselect it
3030 button_release_can_deselect = true;
3034 if (button_release_can_deselect) {
3036 /* just remove this one region, but only on a permitted button release */
3038 selection->remove (clicked_regionview);
3041 /* no more deselect action on button release till a new press
3042 finds an already selected object.
3045 button_release_can_deselect = false;
3052 /* add all the equivalent regions, but only on button press */
3054 if (!all_equivalent_regions.empty()) {
3058 for (vector<RegionView*>::iterator i = all_equivalent_regions.begin(); i != all_equivalent_regions.end(); ++i) {
3059 selection->add (*i);
3065 case Selection::Set:
3066 if (!clicked_regionview->get_selected()) {
3067 selection->set (all_equivalent_regions);
3070 /* no commit necessary: clicked on an already selected region */
3076 /* silly compiler */
3080 } else if (op == Selection::Extend) {
3082 list<Selectable*> results;
3083 nframes_t last_frame;
3084 nframes_t first_frame;
3086 /* 1. find the last selected regionview in the track that was clicked in */
3089 first_frame = max_frames;
3091 for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
3092 if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) {
3094 if ((*x)->region()->last_frame() > last_frame) {
3095 last_frame = (*x)->region()->last_frame();
3098 if ((*x)->region()->first_frame() < first_frame) {
3099 first_frame = (*x)->region()->first_frame();
3104 /* 2. figure out the boundaries for our search for new objects */
3106 switch (clicked_regionview->region()->coverage (first_frame, last_frame)) {
3108 if (last_frame < clicked_regionview->region()->first_frame()) {
3109 first_frame = last_frame;
3110 last_frame = clicked_regionview->region()->last_frame();
3112 last_frame = first_frame;
3113 first_frame = clicked_regionview->region()->first_frame();
3117 case OverlapExternal:
3118 if (last_frame < clicked_regionview->region()->first_frame()) {
3119 first_frame = last_frame;
3120 last_frame = clicked_regionview->region()->last_frame();
3122 last_frame = first_frame;
3123 first_frame = clicked_regionview->region()->first_frame();
3127 case OverlapInternal:
3128 if (last_frame < clicked_regionview->region()->first_frame()) {
3129 first_frame = last_frame;
3130 last_frame = clicked_regionview->region()->last_frame();
3132 last_frame = first_frame;
3133 first_frame = clicked_regionview->region()->first_frame();
3139 /* nothing to do except add clicked region to selection, since it
3140 overlaps with the existing selection in this track.
3145 /* 2. find all selectable objects (regionviews in this case) between that one and the end of the
3146 one that was clicked.
3149 set<AudioTimeAxisView*> relevant_tracks;
3151 get_relevant_audio_tracks (relevant_tracks);
3153 for (set<AudioTimeAxisView*>::iterator t = relevant_tracks.begin(); t != relevant_tracks.end(); ++t) {
3154 (*t)->get_selectables (first_frame, last_frame, -1.0, -1.0, results);
3157 /* 3. convert to a vector of audio regions */
3159 vector<RegionView*> regions;
3161 for (list<Selectable*>::iterator x = results.begin(); x != results.end(); ++x) {
3164 if ((arv = dynamic_cast<RegionView*>(*x)) != 0) {
3165 regions.push_back (arv);
3169 if (!regions.empty()) {
3170 selection->add (regions);
3180 Editor::set_selected_regionview_from_region_list (boost::shared_ptr<Region> region, Selection::Operation op)
3182 vector<RegionView*> all_equivalent_regions;
3184 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3186 RouteTimeAxisView* tatv;
3188 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
3191 vector<boost::shared_ptr<Region> > results;
3193 boost::shared_ptr<Diskstream> ds;
3195 if ((ds = tatv->get_diskstream()) == 0) {
3200 if ((pl = dynamic_cast<Playlist*>(ds->playlist())) != 0) {
3201 pl->get_region_list_equivalent_regions (region, results);
3204 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
3205 if ((marv = tatv->view()->find_view (*ir)) != 0) {
3206 all_equivalent_regions.push_back (marv);
3213 begin_reversible_command (_("set selected regions"));
3216 case Selection::Toggle:
3217 /* XXX this is not correct */
3218 selection->toggle (all_equivalent_regions);
3220 case Selection::Set:
3221 selection->set (all_equivalent_regions);
3223 case Selection::Extend:
3224 selection->add (all_equivalent_regions);
3226 case Selection::Add:
3227 selection->add (all_equivalent_regions);
3231 commit_reversible_command () ;
3235 Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::weak_ptr<Region> weak_r)
3238 boost::shared_ptr<Region> r (weak_r.lock());
3244 boost::shared_ptr<AudioRegion> ar;
3246 if ((ar = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
3250 if ((rv = sv->find_view (ar)) == 0) {
3254 /* don't reset the selection if its something other than
3255 a single other region.
3258 if (selection->regions.size() > 1) {
3262 begin_reversible_command (_("set selected regions"));
3264 selection->set (rv);
3266 commit_reversible_command () ;
3272 Editor::set_edit_group_solo (Route& route, bool yn)
3274 RouteGroup *edit_group;
3276 if ((edit_group = route.edit_group()) != 0) {
3277 edit_group->apply (&Route::set_solo, yn, this);
3279 route.set_solo (yn, this);
3284 Editor::set_edit_group_mute (Route& route, bool yn)
3286 RouteGroup *edit_group = 0;
3288 if ((edit_group == route.edit_group()) != 0) {
3289 edit_group->apply (&Route::set_mute, yn, this);
3291 route.set_mute (yn, this);
3296 Editor::history_changed ()
3300 if (undo_action && session) {
3301 if (session->undo_depth() == 0) {
3304 label = string_compose(_("Undo (%1)"), session->next_undo());
3306 undo_action->property_label() = label;
3309 if (redo_action && session) {
3310 if (session->redo_depth() == 0) {
3313 label = string_compose(_("Redo (%1)"), session->next_redo());
3315 redo_action->property_label() = label;
3320 Editor::duplicate_dialog (bool dup_region)
3323 if (clicked_regionview == 0) {
3327 if (selection->time.length() == 0) {
3332 ArdourDialog win ("duplicate dialog");
3334 Label label (_("Duplicate how many times?"));
3336 win.get_vbox()->pack_start (label);
3337 win.add_action_widget (entry, RESPONSE_ACCEPT);
3338 win.add_button (Stock::OK, RESPONSE_ACCEPT);
3339 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3341 win.set_position (WIN_POS_MOUSE);
3343 entry.set_text ("1");
3344 set_size_request_to_display_given_text (entry, X_("12345678"), 20, 15);
3345 entry.select_region (0, entry.get_text_length());
3346 entry.grab_focus ();
3349 switch (win.run ()) {
3350 case RESPONSE_ACCEPT:
3356 string text = entry.get_text();
3359 if (sscanf (text.c_str(), "%f", ×) == 1) {
3361 RegionSelection regions;
3362 regions.add (clicked_regionview);
3363 duplicate_some_regions (regions, times);
3365 duplicate_selection (times);
3371 Editor::show_verbose_canvas_cursor ()
3373 verbose_canvas_cursor->raise_to_top();
3374 verbose_canvas_cursor->show();
3375 verbose_cursor_visible = true;
3379 Editor::hide_verbose_canvas_cursor ()
3381 verbose_canvas_cursor->hide();
3382 verbose_cursor_visible = false;
3386 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3388 /* XXX get origin of canvas relative to root window,
3389 add x and y and check compared to gdk_screen_{width,height}
3391 verbose_canvas_cursor->property_text() = txt.c_str();
3392 verbose_canvas_cursor->property_x() = x;
3393 verbose_canvas_cursor->property_y() = y;
3397 Editor::set_verbose_canvas_cursor_text (const string & txt)
3399 verbose_canvas_cursor->property_text() = txt.c_str();
3403 Editor::edit_mode_selection_done ()
3409 string choice = edit_mode_selector.get_active_text();
3410 EditMode mode = Slide;
3412 if (choice == _("Splice Edit")) {
3414 } else if (choice == _("Slide Edit")) {
3418 Config->set_edit_mode (mode);
3422 Editor::snap_type_selection_done ()
3424 string choice = snap_type_selector.get_active_text();
3425 SnapType snaptype = SnapToFrame;
3427 if (choice == _("Beats/3")) {
3428 snaptype = SnapToAThirdBeat;
3429 } else if (choice == _("Beats/4")) {
3430 snaptype = SnapToAQuarterBeat;
3431 } else if (choice == _("Beats/8")) {
3432 snaptype = SnapToAEighthBeat;
3433 } else if (choice == _("Beats/16")) {
3434 snaptype = SnapToASixteenthBeat;
3435 } else if (choice == _("Beats/32")) {
3436 snaptype = SnapToAThirtysecondBeat;
3437 } else if (choice == _("Beats")) {
3438 snaptype = SnapToBeat;
3439 } else if (choice == _("Bars")) {
3440 snaptype = SnapToBar;
3441 } else if (choice == _("Marks")) {
3442 snaptype = SnapToMark;
3443 } else if (choice == _("Edit Cursor")) {
3444 snaptype = SnapToEditCursor;
3445 } else if (choice == _("Region starts")) {
3446 snaptype = SnapToRegionStart;
3447 } else if (choice == _("Region ends")) {
3448 snaptype = SnapToRegionEnd;
3449 } else if (choice == _("Region bounds")) {
3450 snaptype = SnapToRegionBoundary;
3451 } else if (choice == _("Region syncs")) {
3452 snaptype = SnapToRegionSync;
3453 } else if (choice == _("CD Frames")) {
3454 snaptype = SnapToCDFrame;
3455 } else if (choice == _("SMPTE Frames")) {
3456 snaptype = SnapToSMPTEFrame;
3457 } else if (choice == _("SMPTE Seconds")) {
3458 snaptype = SnapToSMPTESeconds;
3459 } else if (choice == _("SMPTE Minutes")) {
3460 snaptype = SnapToSMPTEMinutes;
3461 } else if (choice == _("Seconds")) {
3462 snaptype = SnapToSeconds;
3463 } else if (choice == _("Minutes")) {
3464 snaptype = SnapToMinutes;
3465 } else if (choice == _("None")) {
3466 snaptype = SnapToFrame;
3469 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3471 ract->set_active ();
3476 Editor::snap_mode_selection_done ()
3478 string choice = snap_mode_selector.get_active_text();
3479 SnapMode mode = SnapNormal;
3481 if (choice == _("Normal")) {
3483 } else if (choice == _("Magnetic")) {
3484 mode = SnapMagnetic;
3487 RefPtr<RadioAction> ract = snap_mode_action (mode);
3490 ract->set_active (true);
3495 Editor::zoom_focus_selection_done ()
3497 string choice = zoom_focus_selector.get_active_text();
3498 ZoomFocus focus_type = ZoomFocusLeft;
3500 if (choice == _("Left")) {
3501 focus_type = ZoomFocusLeft;
3502 } else if (choice == _("Right")) {
3503 focus_type = ZoomFocusRight;
3504 } else if (choice == _("Center")) {
3505 focus_type = ZoomFocusCenter;
3506 } else if (choice == _("Playhead")) {
3507 focus_type = ZoomFocusPlayhead;
3508 } else if (choice == _("Edit Cursor")) {
3509 focus_type = ZoomFocusEdit;
3512 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3515 ract->set_active ();
3520 Editor::edit_controls_button_release (GdkEventButton* ev)
3522 if (Keyboard::is_context_menu_event (ev)) {
3523 ARDOUR_UI::instance()->add_route ();
3529 Editor::track_selection_changed ()
3531 switch (selection->tracks.size()){
3535 set_selected_mixer_strip (*(selection->tracks.front()));
3539 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3540 (*i)->set_selected (false);
3541 if (mouse_mode == MouseRange) {
3542 (*i)->hide_selection ();
3546 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3547 (*i)->set_selected (true);
3548 if (mouse_mode == MouseRange) {
3549 (*i)->show_selection (selection->time);
3555 Editor::time_selection_changed ()
3557 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3558 (*i)->hide_selection ();
3561 if (selection->tracks.empty()) {
3562 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3563 (*i)->show_selection (selection->time);
3566 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3567 (*i)->show_selection (selection->time);
3571 if (selection->time.empty()) {
3572 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
3574 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true);
3579 Editor::region_selection_changed ()
3581 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3582 (*i)->set_selected_regionviews (selection->regions);
3587 Editor::point_selection_changed ()
3589 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3590 (*i)->set_selected_points (selection->points);
3595 Editor::mouse_select_button_release (GdkEventButton* ev)
3597 /* this handles just right-clicks */
3599 if (ev->button != 3) {
3606 Editor::TrackViewList *
3607 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3610 TrackViewList::iterator i;
3612 v = new TrackViewList;
3614 if (track == 0 && group == 0) {
3618 for (i = track_views.begin(); i != track_views.end (); ++i) {
3622 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3624 /* just the view for this track
3627 v->push_back (track);
3631 /* views for all tracks in the edit group */
3633 for (i = track_views.begin(); i != track_views.end (); ++i) {
3635 if (group == 0 || (*i)->edit_group() == group) {
3645 Editor::set_zoom_focus (ZoomFocus f)
3647 string str = zoom_focus_strings[(int)f];
3649 if (str != zoom_focus_selector.get_active_text()) {
3650 zoom_focus_selector.set_active_text (str);
3653 if (zoom_focus != f) {
3656 ZoomFocusChanged (); /* EMIT_SIGNAL */
3663 Editor::ensure_float (Window& win)
3665 win.set_transient_for (*this);
3669 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3671 /* recover or initialize pane positions. do this here rather than earlier because
3672 we don't want the positions to change the child allocations, which they seem to do.
3678 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3680 static int32_t done;
3683 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3684 width = default_width;
3685 height = default_height;
3687 width = atoi(geometry->property("x_size")->value());
3688 height = atoi(geometry->property("y_size")->value());
3691 if (which == static_cast<Paned*> (&edit_pane)) {
3697 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3698 /* initial allocation is 90% to canvas, 10% to notebook */
3699 pos = (int) floor (alloc.get_width() * 0.90f);
3700 snprintf (buf, sizeof(buf), "%d", pos);
3702 pos = atoi (prop->value());
3705 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3706 edit_pane.set_position (pos);
3707 pre_maximal_pane_position = pos;
3713 Editor::detach_tearoff (Box* b, Window* w)
3715 if (tools_tearoff->torn_off() &&
3716 mouse_mode_tearoff->torn_off()) {
3717 top_hbox.remove (toolbar_frame);
3722 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3724 if (toolbar_frame.get_parent() == 0) {
3725 top_hbox.pack_end (toolbar_frame);
3730 Editor::set_show_measures (bool yn)
3732 if (_show_measures != yn) {
3735 if ((_show_measures = yn) == true) {
3738 DisplayControlChanged (ShowMeasures);
3744 Editor::toggle_follow_playhead ()
3746 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3748 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3749 set_follow_playhead (tact->get_active());
3754 Editor::set_follow_playhead (bool yn)
3756 if (_follow_playhead != yn) {
3757 if ((_follow_playhead = yn) == true) {
3759 update_current_screen ();
3761 DisplayControlChanged (FollowPlayhead);
3767 Editor::toggle_xfade_active (Crossfade* xfade)
3769 xfade->set_active (!xfade->active());
3773 Editor::toggle_xfade_length (Crossfade* xfade)
3775 xfade->set_follow_overlap (!xfade->following_overlap());
3779 Editor::edit_xfade (Crossfade* xfade)
3781 CrossfadeEditor cew (*session, *xfade, xfade->fade_in().get_min_y(), 1.0);
3785 switch (cew.run ()) {
3786 case RESPONSE_ACCEPT:
3793 xfade->StateChanged (Change (~0));
3797 Editor::playlist_selector () const
3799 return *_playlist_selector;
3803 Editor::get_nudge_distance (nframes_t pos, nframes_t& next)
3807 ret = nudge_clock.current_duration (pos);
3808 next = ret + 1; /* XXXX fix me */
3814 Editor::end_location_changed (Location* location)
3816 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3817 reset_scrolling_region ();
3821 Editor::playlist_deletion_dialog (Playlist* pl)
3823 ArdourDialog dialog ("playlist deletion dialog");
3824 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3825 "If left alone, no audio files used by it will be cleaned.\n"
3826 "If deleted, audio files used by it alone by will cleaned."),
3829 dialog.set_position (WIN_POS_CENTER);
3830 dialog.get_vbox()->pack_start (label);
3832 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3833 dialog.add_button (_("Keep playlist"), RESPONSE_CANCEL);
3834 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3836 switch (dialog.run ()) {
3837 case RESPONSE_ACCEPT:
3838 /* delete the playlist */
3842 case RESPONSE_REJECT:
3843 /* keep the playlist */
3855 Editor::audio_region_selection_covers (nframes_t where)
3857 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3858 if ((*a)->region()->covers (where)) {
3867 Editor::prepare_for_cleanup ()
3869 cut_buffer->clear_regions ();
3870 cut_buffer->clear_playlists ();
3872 selection->clear_regions ();
3873 selection->clear_playlists ();
3877 Editor::transport_loop_location()
3880 return session->locations()->auto_loop_location();
3887 Editor::transport_punch_location()
3890 return session->locations()->auto_punch_location();
3897 Editor::control_layout_scroll (GdkEventScroll* ev)
3899 switch (ev->direction) {
3901 scroll_tracks_up_line ();
3905 case GDK_SCROLL_DOWN:
3906 scroll_tracks_down_line ();
3910 /* no left/right handling yet */
3918 Editor::snapshot_display_selection_changed ()
3920 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
3922 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
3924 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
3926 if (snap_name.length() == 0) {
3930 if (session->snap_name() == snap_name) {
3934 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
3939 Editor::snapshot_display_button_press (GdkEventButton* ev)
3945 Editor::redisplay_snapshots ()
3951 vector<string*>* states;
3953 if ((states = session->possible_states()) == 0) {
3957 snapshot_display_model->clear ();
3959 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
3960 string statename = *(*i);
3961 TreeModel::Row row = *(snapshot_display_model->append());
3963 // we don't have a way of changing the rendering in just one TreeView
3964 // cell so just put an asterisk on each side of the name for now.
3965 string display_name;
3966 if (statename == session->snap_name()) {
3967 display_name = "*"+statename+"*";
3968 snapshot_display.get_selection()->select(row);
3970 display_name = statename;
3973 row[snapshot_display_columns.visible_name] = display_name;
3974 row[snapshot_display_columns.real_name] = statename;
3981 Editor::session_state_saved (string snap_name)
3983 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
3984 redisplay_snapshots ();
3988 Editor::maximise_editing_space ()
3990 initial_ruler_update_required = true;
3992 mouse_mode_tearoff->set_visible (false);
3993 tools_tearoff->set_visible (false);
3995 pre_maximal_pane_position = edit_pane.get_position();
3996 pre_maximal_editor_width = this->get_width();
3998 edit_pane.set_position (edit_pane.get_width());
4005 Editor::restore_editing_space ()
4007 initial_ruler_update_required = true;
4011 mouse_mode_tearoff->set_visible (true);
4012 tools_tearoff->set_visible (true);
4015 edit_pane.set_position (
4016 pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width)
4021 Editor::new_playlists ()
4023 begin_reversible_command (_("new playlists"));
4024 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist));
4025 commit_reversible_command ();
4029 Editor::copy_playlists ()
4031 begin_reversible_command (_("copy playlists"));
4032 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist));
4033 commit_reversible_command ();
4037 Editor::clear_playlists ()
4039 begin_reversible_command (_("clear playlists"));
4040 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist));
4041 commit_reversible_command ();
4045 Editor::mapped_use_new_playlist (AudioTimeAxisView& atv, uint32_t sz)
4047 atv.use_new_playlist (sz > 1 ? false : true);
4051 Editor::mapped_use_copy_playlist (AudioTimeAxisView& atv, uint32_t sz)
4053 atv.use_copy_playlist (sz > 1 ? false : true);
4057 Editor::mapped_clear_playlist (AudioTimeAxisView& atv, uint32_t sz)
4059 atv.clear_playlist ();
4063 Editor::on_key_press_event (GdkEventKey* ev)
4065 return key_press_focus_accelerator_handler (*this, ev);