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>
32 #include <gtkmm/image.h>
33 #include <gdkmm/color.h>
34 #include <gdkmm/bitmap.h>
36 #include <gtkmm2ext/gtk_ui.h>
37 #include <gtkmm2ext/tearoff.h>
38 #include <gtkmm2ext/utils.h>
40 #include <ardour/audio_track.h>
41 #include <ardour/audio_diskstream.h>
42 #include <ardour/plugin_manager.h>
43 #include <ardour/location.h>
44 #include <ardour/audioplaylist.h>
45 #include <ardour/audioregion.h>
46 #include <ardour/region.h>
47 #include <ardour/session_route.h>
48 #include <ardour/tempo.h>
49 #include <ardour/utils.h>
51 #include <control_protocol/control_protocol.h>
53 #include "ardour_ui.h"
55 #include "grouped_buttons.h"
58 #include "playlist_selector.h"
59 #include "regionview.h"
60 #include "rgb_macros.h"
61 #include "selection.h"
62 #include "streamview.h"
63 #include "time_axis_view.h"
65 #include "crossfade_view.h"
67 #include "public_editor.h"
68 #include "crossfade_edit.h"
69 #include "audio_time_axis.h"
70 #include "canvas_impl.h"
72 #include "gui_thread.h"
75 #include "analysis_window.h"
81 #include "imageframe_socket_handler.h"
82 /* </CMT Additions> */
86 using namespace ARDOUR;
90 using namespace Gtkmm2ext;
91 using namespace Editing;
93 using PBD::internationalize;
96 const double Editor::timebar_height = 15.0;
98 #include "editor_xpms"
100 static const int32_t slide_index = 0;
101 static const int32_t splice_index = 1;
103 static const gchar *edit_mode_strings[] = {
109 static const gchar *snap_type_strings[] = {
133 static const gchar *snap_mode_strings[] = {
139 static const gchar *zoom_focus_strings[] = {
148 /* Soundfile drag-n-drop */
150 Gdk::Cursor* Editor::cross_hair_cursor = 0;
151 Gdk::Cursor* Editor::selector_cursor = 0;
152 Gdk::Cursor* Editor::trimmer_cursor = 0;
153 Gdk::Cursor* Editor::grabber_cursor = 0;
154 Gdk::Cursor* Editor::zoom_cursor = 0;
155 Gdk::Cursor* Editor::time_fx_cursor = 0;
156 Gdk::Cursor* Editor::fader_cursor = 0;
157 Gdk::Cursor* Editor::speaker_cursor = 0;
158 Gdk::Cursor* Editor::wait_cursor = 0;
159 Gdk::Cursor* Editor::timebar_cursor = 0;
162 show_me_the_size (Requisition* r, const char* what)
164 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
168 check_adjustment (Gtk::Adjustment* adj)
170 cerr << "CHANGE adj = "
171 << adj->get_lower () << ' '
172 << adj->get_upper () << ' '
173 << adj->get_value () << ' '
174 << adj->get_step_increment () << ' '
175 << adj->get_page_increment () << ' '
176 << adj->get_page_size () << ' '
181 Editor::Editor (AudioEngine& eng)
184 /* time display buttons */
186 minsec_label (_("Mins:Secs")),
187 bbt_label (_("Bars:Beats")),
188 smpte_label (_("SMPTE")),
189 frame_label (_("Frames")),
190 tempo_label (_("Tempo")),
191 meter_label (_("Meter")),
192 mark_label (_("Location Markers")),
193 range_mark_label (_("Range Markers")),
194 transport_mark_label (_("Loop/Punch Ranges")),
196 edit_packer (3, 3, false),
198 /* the values here don't matter: layout widgets
199 reset them as needed.
202 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
203 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
205 /* tool bar related */
207 edit_cursor_clock (X_("EditCursorClock"), true),
208 zoom_range_clock (X_("ZoomRangeClock"), true, true),
210 toolbar_selection_clock_table (2,3),
212 //mouse_mode_button_table (2, 3),
214 /*mouse_select_button (_("range")),
215 mouse_move_button (_("object")),
216 mouse_gain_button (_("gain")),
217 mouse_zoom_button (_("zoom")),
218 mouse_timefx_button (_("timefx")),
219 mouse_audition_button (_("listen")),*/
221 automation_mode_button (_("mode")),
222 global_automation_button (_("automation")),
224 /* <CMT Additions> */
225 image_socket_listener(0),
226 /* </CMT Additions> */
230 nudge_clock (X_("NudgeClock"), true, true)
235 /* we are a singleton */
237 PublicEditor::_instance = this;
241 selection = new Selection;
242 cut_buffer = new Selection;
244 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
245 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
246 selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
247 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
249 clicked_regionview = 0;
250 clicked_trackview = 0;
251 clicked_audio_trackview = 0;
252 clicked_crossfadeview = 0;
253 clicked_control_point = 0;
254 latest_regionview = 0;
255 last_update_frame = 0;
257 last_audition_region = 0;
258 current_mixer_strip = 0;
259 current_bbt_points = 0;
261 snap_type = SnapToFrame;
262 set_snap_to (snap_type);
263 snap_mode = SnapNormal;
264 set_snap_mode (snap_mode);
265 snap_threshold = 5.0;
266 bbt_beat_subdivision = 4;
269 autoscroll_timeout_tag = -1;
270 interthread_progress_window = 0;
276 current_interthread_info = 0;
277 _show_measures = true;
278 _show_waveforms = true;
279 _show_waveforms_recording = true;
280 first_action_message = 0;
282 show_gain_after_trim = false;
283 no_zoom_repos_update = false;
284 ignore_route_list_reorder = false;
285 no_route_list_redisplay = false;
286 verbose_cursor_on = true;
287 route_removal = false;
289 show_automatic_regions_in_region_list = true;
290 region_list_sort_type = (Editing::RegionListSortType) 0;
291 have_pending_keyboard_selection = false;
292 _follow_playhead = true;
293 _xfade_visibility = true;
294 editor_ruler_menu = 0;
295 no_ruler_shown_update = false;
296 edit_hscroll_dragging = false;
297 edit_group_list_menu = 0;
299 region_list_menu = 0;
301 range_marker_menu = 0;
302 marker_menu_item = 0;
304 transport_marker_menu = 0;
305 new_transport_marker_menu = 0;
306 editor_mixer_strip_width = Wide;
307 repos_zoom_queued = false;
308 region_edit_menu_split_item = 0;
310 region_edit_menu_split_multichannel_item = 0;
312 ignore_mouse_mode_toggle = false;
313 current_stepping_trackview = 0;
315 entered_regionview = 0;
316 clear_entered_track = false;
317 _new_regionviews_show_envelope = false;
318 current_timestretch = 0;
319 in_edit_group_row_change = false;
320 last_canvas_frame = 0;
323 button_release_can_deselect = true;
325 location_marker_color = color_map[cLocationMarker];
326 location_range_color = color_map[cLocationRange];
327 location_cd_marker_color = color_map[cLocationCDMarker];
328 location_loop_color = color_map[cLocationLoop];
329 location_punch_color = color_map[cLocationPunch];
331 range_marker_drag_rect = 0;
332 marker_drag_line = 0;
334 set_mouse_mode (MouseObject, true);
336 frames_per_unit = 2048; /* too early to use set_frames_per_unit */
337 reset_hscrollbar_stepping ();
339 zoom_focus = ZoomFocusLeft;
340 set_zoom_focus (ZoomFocusLeft);
341 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
343 initialize_rulers ();
344 initialize_canvas ();
346 edit_controls_vbox.set_spacing (0);
347 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled));
348 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling));
350 track_canvas.set_hadjustment (horizontal_adjustment);
351 track_canvas.set_vadjustment (vertical_adjustment);
352 time_canvas.set_hadjustment (horizontal_adjustment);
354 track_canvas.signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
355 time_canvas.signal_map_event().connect (mem_fun (*this, &Editor::time_canvas_map_handler));
357 controls_layout.add (edit_controls_vbox);
358 controls_layout.set_name ("EditControlsBase");
359 controls_layout.add_events (Gdk::SCROLL_MASK);
360 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
362 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
363 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
364 controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
366 edit_vscrollbar.set_adjustment (vertical_adjustment);
367 edit_hscrollbar.set_adjustment (horizontal_adjustment);
369 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press));
370 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release));
371 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
376 edit_cursor_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_cursor_clock_changed));
378 time_canvas_vbox.pack_start (*minsec_ruler, false, false);
379 time_canvas_vbox.pack_start (*smpte_ruler, false, false);
380 time_canvas_vbox.pack_start (*frames_ruler, false, false);
381 time_canvas_vbox.pack_start (*bbt_ruler, false, false);
382 time_canvas_vbox.pack_start (time_canvas, true, true);
383 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars));
385 bbt_label.set_name ("EditorTimeButton");
386 bbt_label.set_size_request (-1, (int)timebar_height);
387 bbt_label.set_alignment (1.0, 0.5);
388 bbt_label.set_padding (5,0);
389 minsec_label.set_name ("EditorTimeButton");
390 minsec_label.set_size_request (-1, (int)timebar_height);
391 minsec_label.set_alignment (1.0, 0.5);
392 minsec_label.set_padding (5,0);
393 smpte_label.set_name ("EditorTimeButton");
394 smpte_label.set_size_request (-1, (int)timebar_height);
395 smpte_label.set_alignment (1.0, 0.5);
396 smpte_label.set_padding (5,0);
397 frame_label.set_name ("EditorTimeButton");
398 frame_label.set_size_request (-1, (int)timebar_height);
399 frame_label.set_alignment (1.0, 0.5);
400 frame_label.set_padding (5,0);
401 tempo_label.set_name ("EditorTimeButton");
402 tempo_label.set_size_request (-1, (int)timebar_height);
403 tempo_label.set_alignment (1.0, 0.5);
404 tempo_label.set_padding (5,0);
405 meter_label.set_name ("EditorTimeButton");
406 meter_label.set_size_request (-1, (int)timebar_height);
407 meter_label.set_alignment (1.0, 0.5);
408 meter_label.set_padding (5,0);
409 mark_label.set_name ("EditorTimeButton");
410 mark_label.set_size_request (-1, (int)timebar_height);
411 mark_label.set_alignment (1.0, 0.5);
412 mark_label.set_padding (5,0);
413 range_mark_label.set_name ("EditorTimeButton");
414 range_mark_label.set_size_request (-1, (int)timebar_height);
415 range_mark_label.set_alignment (1.0, 0.5);
416 range_mark_label.set_padding (5,0);
417 transport_mark_label.set_name ("EditorTimeButton");
418 transport_mark_label.set_size_request (-1, (int)timebar_height);
419 transport_mark_label.set_alignment (1.0, 0.5);
420 transport_mark_label.set_padding (5,0);
422 time_button_vbox.pack_start (minsec_label, false, false);
423 time_button_vbox.pack_start (smpte_label, false, false);
424 time_button_vbox.pack_start (frame_label, false, false);
425 time_button_vbox.pack_start (bbt_label, false, false);
426 time_button_vbox.pack_start (meter_label, false, false);
427 time_button_vbox.pack_start (tempo_label, false, false);
428 time_button_vbox.pack_start (mark_label, false, false);
430 time_button_event_box.add (time_button_vbox);
432 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
433 time_button_event_box.set_name ("TimebarLabelBase");
434 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
436 /* these enable us to have a dedicated window (for cursor setting, etc.)
437 for the canvas areas.
440 track_canvas_event_box.add (track_canvas);
442 time_canvas_event_box.add (time_canvas_vbox);
443 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
445 edit_packer.set_col_spacings (0);
446 edit_packer.set_row_spacings (0);
447 edit_packer.set_homogeneous (false);
448 edit_packer.set_border_width (0);
449 edit_packer.set_name ("EditorWindow");
451 edit_packer.attach (edit_vscrollbar, 0, 1, 1, 3, FILL, FILL|EXPAND, 0, 0);
453 edit_packer.attach (time_button_event_box, 1, 2, 0, 1, FILL, FILL, 0, 0);
454 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
456 edit_packer.attach (controls_layout, 1, 2, 1, 2, FILL, FILL|EXPAND, 0, 0);
457 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 2, FILL|EXPAND, FILL|EXPAND, 0, 0);
459 edit_packer.attach (edit_hscrollbar, 2, 3, 2, 3, FILL|EXPAND, FILL, 0, 0);
461 bottom_hbox.set_border_width (2);
462 bottom_hbox.set_spacing (3);
464 route_display_model = ListStore::create(route_display_columns);
465 route_list_display.set_model (route_display_model);
466 route_list_display.append_column (_("Visible"), route_display_columns.visible);
467 route_list_display.append_column (_("Name"), route_display_columns.text);
468 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
469 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
470 route_list_display.set_headers_visible (true);
471 route_list_display.set_name ("TrackListDisplay");
472 route_list_display.get_selection()->set_mode (SELECTION_NONE);
473 route_list_display.set_reorderable (true);
474 route_list_display.set_size_request (100,-1);
476 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
477 route_list_visible_cell->property_activatable() = true;
478 route_list_visible_cell->property_radio() = false;
480 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
481 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
483 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
485 route_list_scroller.add (route_list_display);
486 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
488 group_model = ListStore::create(group_columns);
489 edit_group_display.set_model (group_model);
490 edit_group_display.append_column (_("Name"), group_columns.text);
491 edit_group_display.append_column (_("Active"), group_columns.is_active);
492 edit_group_display.append_column (_("Visible"), group_columns.is_visible);
493 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
494 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
495 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
496 edit_group_display.get_column (0)->set_expand (true);
497 edit_group_display.get_column (1)->set_expand (false);
498 edit_group_display.get_column (2)->set_expand (false);
499 edit_group_display.set_headers_visible (true);
501 /* name is directly editable */
503 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
504 name_cell->property_editable() = true;
505 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
507 /* use checkbox for the active + visible columns */
509 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
510 active_cell->property_activatable() = true;
511 active_cell->property_radio() = false;
513 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
514 active_cell->property_activatable() = true;
515 active_cell->property_radio() = false;
517 edit_group_display.set_name ("EditGroupList");
519 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
521 edit_group_display.set_name ("EditGroupList");
522 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
523 edit_group_display.set_reorderable (false);
524 edit_group_display.set_rules_hint (true);
525 edit_group_display.set_size_request (75, -1);
527 edit_group_display_scroller.add (edit_group_display);
528 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
530 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
532 VBox* edit_group_display_packer = manage (new VBox());
533 HButtonBox* edit_group_display_button_box = manage (new HButtonBox());
534 edit_group_display_button_box->set_homogeneous (true);
536 Button* edit_group_add_button = manage (new Button ());
537 Button* edit_group_remove_button = manage (new Button ());
541 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
543 edit_group_add_button->add (*w);
545 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
547 edit_group_remove_button->add (*w);
549 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
550 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
552 edit_group_display_button_box->pack_start (*edit_group_add_button);
553 edit_group_display_button_box->pack_start (*edit_group_remove_button);
555 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
556 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
558 region_list_display.set_size_request (100, -1);
559 region_list_display.set_name ("RegionListDisplay");
561 region_list_model = TreeStore::create (region_list_columns);
562 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
563 region_list_model->set_sort_column (0, SORT_ASCENDING);
565 region_list_display.set_model (region_list_model);
566 region_list_display.append_column (_("Regions"), region_list_columns.name);
567 region_list_display.set_headers_visible (false);
568 region_list_display.set_hover_expand (true);
570 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
572 TreeViewColumn* tv_col = region_list_display.get_column(0);
573 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
574 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
575 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
577 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
578 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
580 /* setup DnD handling */
582 list<TargetEntry> region_list_target_table;
584 region_list_target_table.push_back (TargetEntry ("text/plain"));
585 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
586 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
588 region_list_display.add_drop_targets (region_list_target_table);
589 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
591 region_list_scroller.add (region_list_display);
592 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
594 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
595 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
596 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
597 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
598 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
599 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
601 named_selection_scroller.add (named_selection_display);
602 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
604 named_selection_model = TreeStore::create (named_selection_columns);
605 named_selection_display.set_model (named_selection_model);
606 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
607 named_selection_display.set_headers_visible (false);
608 named_selection_display.set_size_request (100, -1);
609 named_selection_display.set_name ("RegionListDisplay");
611 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
612 named_selection_display.set_size_request (100, -1);
613 named_selection_display.signal_button_press_event().connect (mem_fun(*this, &Editor::named_selection_display_button_press), false);
614 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
618 snapshot_display_model = ListStore::create (snapshot_display_columns);
619 snapshot_display.set_model (snapshot_display_model);
620 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
621 snapshot_display.set_name ("SnapshotDisplayList");
622 snapshot_display.set_size_request (75, -1);
623 snapshot_display.set_headers_visible (false);
624 snapshot_display.set_reorderable (false);
625 snapshot_display_scroller.add (snapshot_display);
626 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
628 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
629 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
633 nlabel = manage (new Label (_("Regions")));
634 nlabel->set_angle (-90);
635 the_notebook.append_page (region_list_scroller, *nlabel);
636 nlabel = manage (new Label (_("Tracks/Busses")));
637 nlabel->set_angle (-90);
638 the_notebook.append_page (route_list_scroller, *nlabel);
639 nlabel = manage (new Label (_("Snapshots")));
640 nlabel->set_angle (-90);
641 the_notebook.append_page (snapshot_display_scroller, *nlabel);
642 nlabel = manage (new Label (_("Edit Groups")));
643 nlabel->set_angle (-90);
644 the_notebook.append_page (*edit_group_display_packer, *nlabel);
645 nlabel = manage (new Label (_("Chunks")));
646 nlabel->set_angle (-90);
647 the_notebook.append_page (named_selection_scroller, *nlabel);
649 the_notebook.set_show_tabs (true);
650 the_notebook.set_scrollable (true);
651 the_notebook.popup_enable ();
652 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
654 edit_pane.pack1 (edit_packer, true, true);
655 edit_pane.pack2 (the_notebook, false, true);
657 edit_pane.signal_size_allocate().connect_notify (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
659 top_hbox.pack_start (toolbar_frame, true, true);
661 HBox *hbox = manage (new HBox);
662 hbox->pack_start (edit_pane, true, true);
664 global_vpacker.pack_start (top_hbox, false, false);
665 global_vpacker.pack_start (*hbox, true, true);
667 global_hpacker.pack_start (global_vpacker, true, true);
669 set_name ("EditorWindow");
670 add_accel_group (ActionManager::ui_manager->get_accel_group());
672 vpacker.pack_end (global_hpacker, true, true);
674 /* register actions now so that set_state() can find them and set toggles/checks etc */
678 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
681 _playlist_selector = new PlaylistSelector();
682 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
684 AudioRegionView::AudioRegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_audio_regionview));
688 nudge_forward_button.add (*(manage (new Image (get_xpm("right_arrow.xpm")))));
689 nudge_backward_button.add (*(manage (new Image (get_xpm("left_arrow.xpm")))));
691 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
692 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
694 nudge_forward_button.set_name ("TransportButton");
695 nudge_backward_button.set_name ("TransportButton");
697 fade_context_menu.set_name ("ArdourContextMenu");
699 set_title (_("ardour: editor"));
700 set_wmclass (_("ardour_editor"), "Ardour");
703 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
705 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
706 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
708 /* allow external control surfaces/protocols to do various things */
710 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
711 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
712 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
713 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
720 /* <CMT Additions> */
721 if(image_socket_listener)
723 if(image_socket_listener->is_connected())
725 image_socket_listener->close_connection() ;
728 delete image_socket_listener ;
729 image_socket_listener = 0 ;
731 /* </CMT Additions> */
735 Editor::add_toplevel_controls (Container& cont)
737 vpacker.pack_start (cont, false, false);
742 Editor::catch_vanishing_audio_regionview (AudioRegionView *rv)
744 /* note: the selection will take care of the vanishing
745 audioregionview by itself.
748 if (clicked_regionview == rv) {
749 clicked_regionview = 0;
752 if (entered_regionview == rv) {
753 set_entered_regionview (0);
758 Editor::set_entered_regionview (AudioRegionView* rv)
760 if (rv == entered_regionview) {
764 if (entered_regionview) {
765 entered_regionview->exited ();
768 if ((entered_regionview = rv) != 0) {
769 entered_regionview->entered ();
774 Editor::set_entered_track (TimeAxisView* tav)
777 entered_track->exited ();
780 if ((entered_track = tav) != 0) {
781 entered_track->entered ();
786 Editor::show_window ()
791 /* now reset all audio_time_axis heights, because widgets might need
797 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
798 tv = (static_cast<TimeAxisView*>(*i));
804 Editor::tie_vertical_scrolling ()
806 double y1 = vertical_adjustment.get_value();
807 controls_layout.get_vadjustment()->set_value (y1);
808 playhead_cursor->set_y_axis(y1);
809 edit_cursor->set_y_axis(y1);
813 Editor::set_frames_per_unit (double fpu)
815 jack_nframes_t frames;
817 if (fpu == frames_per_unit) {
825 // convert fpu to frame count
827 frames = (jack_nframes_t) floor (fpu * canvas_width);
829 /* don't allow zooms that fit more than the maximum number
830 of frames into an 800 pixel wide space.
833 if (max_frames / fpu < 800.0) {
837 frames_per_unit = fpu;
839 if (frames != zoom_range_clock.current_duration()) {
840 zoom_range_clock.set (frames);
843 /* only update these if we not about to call reposition_x_origin,
844 which will do the same updates.
847 if (!no_zoom_repos_update) {
848 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
849 update_fixed_rulers ();
850 tempo_map_changed (Change (0));
853 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
854 if (!selection->tracks.empty()) {
855 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
856 (*i)->reshow_selection (selection->time);
859 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
860 (*i)->reshow_selection (selection->time);
865 ZoomChanged (); /* EMIT_SIGNAL */
867 reset_hscrollbar_stepping ();
868 reset_scrolling_region ();
870 if (edit_cursor) edit_cursor->set_position (edit_cursor->current_frame);
871 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
878 Editor::instant_save ()
880 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
885 session->add_instant_xml(get_state(), session->path());
887 Config->add_instant_xml(get_state(), get_user_ardour_path());
892 Editor::reposition_x_origin (jack_nframes_t frame)
894 if (frame != leftmost_frame) {
895 leftmost_frame = frame;
897 jack_nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
899 if (rightmost_frame > last_canvas_frame) {
900 last_canvas_frame = rightmost_frame;
901 reset_scrolling_region ();
904 horizontal_adjustment.set_value (frame/frames_per_unit);
909 Editor::edit_cursor_clock_changed()
911 if (edit_cursor->current_frame != edit_cursor_clock.current_time()) {
912 edit_cursor->set_position (edit_cursor_clock.current_time());
918 Editor::zoom_adjustment_changed ()
920 if (session == 0 || no_zoom_repos_update) {
924 double fpu = zoom_range_clock.current_duration() / canvas_width;
928 zoom_range_clock.set ((jack_nframes_t) floor (fpu * canvas_width));
929 } else if (fpu > session->current_end_frame() / canvas_width) {
930 fpu = session->current_end_frame() / canvas_width;
931 zoom_range_clock.set ((jack_nframes_t) floor (fpu * canvas_width));
938 Editor::control_scroll (float fraction)
940 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
946 double step = fraction * current_page_frames();
947 jack_nframes_t target;
949 if ((fraction < 0.0f) && (session->transport_frame() < (jack_nframes_t) fabs(step))) {
951 } else if ((fraction > 0.0f) && (max_frames - session->transport_frame() < step)) {
952 target = (max_frames - (current_page_frames()*2)); // allow room for slop in where the PH is on the screen
954 target = (session->transport_frame() + (jack_nframes_t) floor ((fraction * current_page_frames())));
957 /* move visuals, we'll catch up with it later */
959 playhead_cursor->set_position (target);
961 if (target > (current_page_frames() / 2)) {
962 /* try to center PH in window */
963 reposition_x_origin (target - (current_page_frames()/2));
965 reposition_x_origin (0);
968 /* cancel the existing */
970 control_scroll_connection.disconnect ();
972 /* add the next one */
974 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), target), 50);
978 Editor::deferred_control_scroll (jack_nframes_t target)
980 session->request_locate (target);
985 Editor::canvas_horizontally_scrolled ()
987 leftmost_frame = (jack_nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
989 update_fixed_rulers ();
991 if (!edit_hscroll_dragging) {
992 tempo_map_changed (Change (0));
994 update_tempo_based_rulers();
999 Editor::reposition_and_zoom (jack_nframes_t frame, double nfpu)
1001 if (!repos_zoom_queued) {
1002 Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::deferred_reposition_and_zoom), frame, nfpu));
1003 repos_zoom_queued = true;
1008 Editor::deferred_reposition_and_zoom (jack_nframes_t frame, double nfpu)
1010 /* if we need to force an update to the hscroller stuff,
1011 don't set no_zoom_repos_update.
1014 no_zoom_repos_update = (frame != leftmost_frame);
1016 set_frames_per_unit (nfpu);
1017 if (no_zoom_repos_update) {
1018 reposition_x_origin (frame);
1020 no_zoom_repos_update = false;
1021 repos_zoom_queued = false;
1027 Editor::on_realize ()
1029 Window::on_realize ();
1034 Editor::queue_session_control_changed (Session::ControlType t)
1036 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::session_control_changed), t));
1040 Editor::session_control_changed (Session::ControlType t)
1042 // right now we're only tracking some state here
1045 case Session::AutoLoop:
1046 update_loop_range_view (true);
1048 case Session::PunchIn:
1049 case Session::PunchOut:
1050 update_punch_range_view (true);
1053 case Session::LayeringModel:
1054 update_layering_model ();
1063 Editor::start_scrolling ()
1065 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1066 (mem_fun(*this, &Editor::update_current_screen));
1070 Editor::stop_scrolling ()
1072 scroll_connection.disconnect ();
1073 slower_update_connection.disconnect ();
1077 Editor::map_position_change (jack_nframes_t frame)
1079 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1081 if (session == 0 || !_follow_playhead) {
1085 center_screen (frame);
1086 playhead_cursor->set_position (frame);
1090 Editor::center_screen (jack_nframes_t frame)
1092 double page = canvas_width * frames_per_unit;
1094 /* if we're off the page, then scroll.
1097 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1098 center_screen_internal (frame, page);
1103 Editor::center_screen_internal (jack_nframes_t frame, float page)
1108 frame -= (jack_nframes_t) page;
1113 reposition_x_origin (frame);
1117 Editor::handle_new_duration ()
1119 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1121 jack_nframes_t new_end = session->get_maximum_extent() + (jack_nframes_t) floorf (current_page_frames() * 0.10f);
1123 if (new_end > last_canvas_frame) {
1124 last_canvas_frame = new_end;
1125 reset_scrolling_region ();
1128 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1132 Editor::update_title_s (const string & snap_name)
1134 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1140 Editor::update_title ()
1142 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1145 bool dirty = session->dirty();
1147 string wintitle = _("ardour: editor: ");
1153 wintitle += session->name();
1155 if (session->snap_name() != session->name()) {
1157 wintitle += session->snap_name();
1164 set_title (wintitle);
1169 Editor::connect_to_session (Session *t)
1173 if (first_action_message) {
1174 first_action_message->hide();
1179 session->going_away.connect (mem_fun(*this, &Editor::session_going_away));
1181 /* These signals can all be emitted by a non-GUI thread. Therefore the
1182 handlers for them must not attempt to directly interact with the GUI,
1183 but use Gtkmm2ext::UI::instance()->call_slot();
1186 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1187 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1188 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route_p)));
1189 session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::handle_new_audio_region)));
1190 session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::handle_audio_region_removed)));
1191 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1192 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1193 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1194 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1195 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1196 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1197 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1198 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1199 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1201 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1202 session_connections.push_back (session->SMPTETypeChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1204 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1206 edit_groups_changed ();
1208 edit_cursor_clock.set_session (session);
1209 zoom_range_clock.set_session (session);
1210 _playlist_selector->set_session (session);
1211 nudge_clock.set_session (session);
1214 if (analysis_window != 0)
1215 analysis_window->set_session (session);
1218 switch (session->get_edit_mode()) {
1220 edit_mode_selector.set_active_text (edit_mode_strings[splice_index]);
1224 edit_mode_selector.set_active_text (edit_mode_strings[slide_index]);
1228 Location* loc = session->locations()->auto_loop_location();
1230 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1231 if (loc->start() == loc->end()) {
1232 loc->set_end (loc->start() + 1);
1234 session->locations()->add (loc, false);
1235 session->set_auto_loop_location (loc);
1239 loc->set_name (_("Loop"));
1242 loc = session->locations()->auto_punch_location();
1244 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1245 if (loc->start() == loc->end()) {
1246 loc->set_end (loc->start() + 1);
1248 session->locations()->add (loc, false);
1249 session->set_auto_punch_location (loc);
1253 loc->set_name (_("Punch"));
1256 update_loop_range_view (true);
1257 update_punch_range_view (true);
1259 session->ControlChanged.connect (mem_fun(*this, &Editor::queue_session_control_changed));
1260 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1262 refresh_location_display ();
1263 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1264 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1265 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1266 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1267 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1272 act = ActionManager::get_action (X_("Editor"), X_("toggle-xfades-active"));
1274 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
1275 /* do it twice to force the change */
1276 yn = session->get_crossfades_active();
1277 tact->set_active (!yn);
1278 tact->set_active (yn);
1281 act = ActionManager::get_action (X_("Editor"), X_("toggle-auto-xfades"));
1283 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
1284 /* do it twice to force the change */
1285 yn = Config->get_auto_xfade ();
1286 tact->set_active (!yn);
1287 tact->set_active (yn);
1290 /* xfade visibility state set from editor::set_state() */
1292 update_crossfade_model ();
1293 update_layering_model ();
1295 handle_new_duration ();
1297 redisplay_regions ();
1298 redisplay_named_selections ();
1299 redisplay_snapshots ();
1301 initial_route_list_display ();
1303 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1304 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1307 /* ::reposition_x_origin() doesn't work right here, since the old
1308 position may be zero already, and it does nothing in such
1314 horizontal_adjustment.set_value (0);
1316 restore_ruler_visibility ();
1317 tempo_map_changed (Change (0));
1319 edit_cursor->set_position (0);
1320 playhead_cursor->set_position (0);
1324 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1327 /* don't show master bus in a new session */
1329 if (ARDOUR_UI::instance()->session_is_new ()) {
1331 TreeModel::Children rows = route_display_model->children();
1332 TreeModel::Children::iterator i;
1334 no_route_list_redisplay = true;
1336 for (i = rows.begin(); i != rows.end(); ++i) {
1337 TimeAxisView *tv = (*i)[route_display_columns.tv];
1338 AudioTimeAxisView *atv;
1340 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1341 if (atv->route().master()) {
1342 route_list_display.get_selection()->unselect (i);
1347 no_route_list_redisplay = false;
1348 redisplay_route_list ();
1353 Editor::build_cursors ()
1355 using namespace Gdk;
1357 Gdk::Color mbg ("#000000" ); /* Black */
1358 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1361 RefPtr<Bitmap> source, mask;
1362 source = Bitmap::create (mag_bits, mag_width, mag_height);
1363 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1364 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1367 Gdk::Color fbg ("#ffffff" );
1368 Gdk::Color ffg ("#000000" );
1371 RefPtr<Bitmap> source, mask;
1373 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1374 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1375 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1379 RefPtr<Bitmap> source, mask;
1380 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1381 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1382 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1385 grabber_cursor = new Gdk::Cursor (HAND2);
1386 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1387 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1388 selector_cursor = new Gdk::Cursor (XTERM);
1389 time_fx_cursor = new Gdk::Cursor (SIZING);
1390 wait_cursor = new Gdk::Cursor (WATCH);
1391 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1395 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1397 using namespace Menu_Helpers;
1398 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1401 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1405 MenuList& items (fade_context_menu.items());
1409 switch (item_type) {
1411 case FadeInHandleItem:
1412 if (arv->region.fade_in_active()) {
1413 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), false)));
1415 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), true)));
1418 items.push_back (SeparatorElem());
1420 items.push_back (MenuElem (_("Linear"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::Linear)));
1421 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::LogB)));
1422 items.push_back (MenuElem (_("Slow"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::Fast)));
1423 items.push_back (MenuElem (_("Fast"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::LogA)));
1424 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::Slow)));
1428 case FadeOutHandleItem:
1429 if (arv->region.fade_out_active()) {
1430 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), false)));
1432 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), true)));
1435 items.push_back (SeparatorElem());
1437 items.push_back (MenuElem (_("Linear"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::Linear)));
1438 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::Fast)));
1439 items.push_back (MenuElem (_("Slow"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::LogB)));
1440 items.push_back (MenuElem (_("Fast"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::LogA)));
1441 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::Slow)));
1445 fatal << _("programming error: ")
1446 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1451 fade_context_menu.popup (button, time);
1455 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, jack_nframes_t frame)
1457 using namespace Menu_Helpers;
1458 Menu* (Editor::*build_menu_function)(jack_nframes_t);
1461 switch (item_type) {
1463 case AudioRegionViewName:
1464 case AudioRegionViewNameHighlight:
1465 if (with_selection) {
1466 build_menu_function = &Editor::build_track_selection_context_menu;
1468 build_menu_function = &Editor::build_track_region_context_menu;
1473 if (with_selection) {
1474 build_menu_function = &Editor::build_track_selection_context_menu;
1476 build_menu_function = &Editor::build_track_context_menu;
1480 case CrossfadeViewItem:
1481 build_menu_function = &Editor::build_track_crossfade_context_menu;
1485 if (clicked_audio_trackview->get_diskstream()) {
1486 build_menu_function = &Editor::build_track_context_menu;
1488 build_menu_function = &Editor::build_track_bus_context_menu;
1493 /* probably shouldn't happen but if it does, we don't care */
1497 menu = (this->*build_menu_function)(frame);
1498 menu->set_name ("ArdourContextMenu");
1500 /* now handle specific situations */
1502 switch (item_type) {
1504 case AudioRegionViewName:
1505 case AudioRegionViewNameHighlight:
1506 if (!with_selection) {
1507 if (region_edit_menu_split_item) {
1508 if (clicked_regionview && clicked_regionview->region.covers (edit_cursor->current_frame)) {
1509 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
1511 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
1514 if (region_edit_menu_split_multichannel_item) {
1515 if (clicked_regionview && clicked_regionview->region.n_channels() > 1) {
1516 // GTK2FIX find the action, change its sensitivity
1517 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1519 // GTK2FIX see above
1520 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1529 case CrossfadeViewItem:
1536 /* probably shouldn't happen but if it does, we don't care */
1540 if (clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
1542 /* Bounce to disk */
1544 using namespace Menu_Helpers;
1545 MenuList& edit_items = menu->items();
1547 edit_items.push_back (SeparatorElem());
1549 switch (clicked_audio_trackview->audio_track()->freeze_state()) {
1550 case AudioTrack::NoFreeze:
1551 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1554 case AudioTrack::Frozen:
1555 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1558 case AudioTrack::UnFrozen:
1559 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1565 menu->popup (button, time);
1569 Editor::build_track_context_menu (jack_nframes_t ignored)
1571 using namespace Menu_Helpers;
1573 MenuList& edit_items = track_context_menu.items();
1576 add_dstream_context_items (edit_items);
1577 return &track_context_menu;
1581 Editor::build_track_bus_context_menu (jack_nframes_t ignored)
1583 using namespace Menu_Helpers;
1585 MenuList& edit_items = track_context_menu.items();
1588 add_bus_context_items (edit_items);
1589 return &track_context_menu;
1593 Editor::build_track_region_context_menu (jack_nframes_t frame)
1595 using namespace Menu_Helpers;
1596 MenuList& edit_items = track_region_context_menu.items();
1599 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1602 AudioDiskstream* ds;
1605 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1606 Playlist::RegionList* regions = pl->regions_at ((jack_nframes_t) floor ( (double)frame * ds->speed()));
1607 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1608 add_region_context_items (atv->view, (*i), edit_items);
1614 add_dstream_context_items (edit_items);
1616 return &track_region_context_menu;
1620 Editor::build_track_crossfade_context_menu (jack_nframes_t frame)
1622 using namespace Menu_Helpers;
1623 MenuList& edit_items = track_crossfade_context_menu.items();
1624 edit_items.clear ();
1626 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1629 AudioDiskstream* ds;
1633 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = dynamic_cast<AudioPlaylist*> (pl)) != 0)) {
1635 Playlist::RegionList* regions = pl->regions_at (frame);
1636 AudioPlaylist::Crossfades xfades;
1638 apl->crossfades_at (frame, xfades);
1640 bool many = xfades.size() > 1;
1642 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1643 add_crossfade_context_items (atv->view, (*i), edit_items, many);
1646 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1647 add_region_context_items (atv->view, (*i), edit_items);
1654 add_dstream_context_items (edit_items);
1656 return &track_crossfade_context_menu;
1661 Editor::analyze_region_selection()
1663 if (analysis_window == 0) {
1664 analysis_window = new AnalysisWindow();
1667 analysis_window->set_session(session);
1669 analysis_window->show_all();
1672 analysis_window->set_regionmode();
1673 analysis_window->analyze();
1675 analysis_window->present();
1679 Editor::analyze_range_selection()
1681 if (analysis_window == 0) {
1682 analysis_window = new AnalysisWindow();
1685 analysis_window->set_session(session);
1687 analysis_window->show_all();
1690 analysis_window->set_rangemode();
1691 analysis_window->analyze();
1693 analysis_window->present();
1695 #endif /* FFT_ANALYSIS */
1700 Editor::build_track_selection_context_menu (jack_nframes_t ignored)
1702 using namespace Menu_Helpers;
1703 MenuList& edit_items = track_selection_context_menu.items();
1704 edit_items.clear ();
1706 add_selection_context_items (edit_items);
1707 add_dstream_context_items (edit_items);
1709 return &track_selection_context_menu;
1713 Editor::add_crossfade_context_items (StreamView* view, Crossfade* xfade, Menu_Helpers::MenuList& edit_items, bool many)
1715 using namespace Menu_Helpers;
1716 Menu *xfade_menu = manage (new Menu);
1717 MenuList& items = xfade_menu->items();
1718 xfade_menu->set_name ("ArdourContextMenu");
1721 if (xfade->active()) {
1727 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), xfade)));
1728 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), xfade)));
1730 if (xfade->can_follow_overlap()) {
1732 if (xfade->following_overlap()) {
1733 str = _("Convert to short");
1735 str = _("Convert to full");
1738 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1742 str = xfade->out().name();
1744 str += xfade->in().name();
1746 str = _("Crossfade");
1749 edit_items.push_back (MenuElem (str, *xfade_menu));
1750 edit_items.push_back (SeparatorElem());
1754 Editor::xfade_edit_left_region ()
1756 if (clicked_crossfadeview) {
1757 clicked_crossfadeview->left_view.show_region_editor ();
1762 Editor::xfade_edit_right_region ()
1764 if (clicked_crossfadeview) {
1765 clicked_crossfadeview->right_view.show_region_editor ();
1770 Editor::add_region_context_items (StreamView* sv, Region* region, Menu_Helpers::MenuList& edit_items)
1772 using namespace Menu_Helpers;
1773 Menu *region_menu = manage (new Menu);
1774 MenuList& items = region_menu->items();
1775 region_menu->set_name ("ArdourContextMenu");
1777 AudioRegion* ar = 0;
1780 ar = dynamic_cast<AudioRegion*> (region);
1783 /* when this particular menu pops up, make the relevant region
1787 region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, region));
1789 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1790 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1791 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1792 items.push_back (SeparatorElem());
1793 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_cursor)));
1794 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1795 items.push_back (SeparatorElem());
1797 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::audition_selected_region)));
1798 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1799 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1802 items.push_back (MenuElem (_("Analyze region"), mem_fun(*this, &Editor::analyze_region_selection)));
1805 items.push_back (SeparatorElem());
1807 /* XXX hopefully this nonsense will go away with SigC++ 2.X, where the compiler
1808 might be able to figure out which overloaded member function to use in
1812 void (Editor::*type_A_pmf)(void (Region::*pmf)(bool), bool) = &Editor::region_selection_op;
1814 items.push_back (MenuElem (_("Lock"), bind (mem_fun(*this, type_A_pmf), &Region::set_locked, true)));
1815 items.push_back (MenuElem (_("Unlock"), bind (mem_fun(*this, type_A_pmf), &Region::set_locked, false)));
1816 items.push_back (SeparatorElem());
1818 if (region->muted()) {
1819 items.push_back (MenuElem (_("Unmute"), bind (mem_fun(*this, type_A_pmf), &Region::set_muted, false)));
1821 items.push_back (MenuElem (_("Mute"), bind (mem_fun(*this, type_A_pmf), &Region::set_muted, true)));
1823 items.push_back (SeparatorElem());
1825 items.push_back (MenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1826 items.push_back (SeparatorElem());
1831 items.push_back (MenuElem (_("Toggle envelope visibility"), mem_fun(*this, &Editor::toggle_gain_envelope_visibility)));
1832 items.push_back (MenuElem (_("Toggle envelope active"), mem_fun(*this, &Editor::toggle_gain_envelope_active)));
1833 items.push_back (SeparatorElem());
1835 if (ar->scale_amplitude() != 1.0f) {
1836 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1838 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1841 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1842 items.push_back (SeparatorElem());
1845 /* range related stuff */
1847 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1848 items.push_back (MenuElem (_("Set Range"), mem_fun (*this, &Editor::set_selection_from_audio_region)));
1849 items.push_back (SeparatorElem());
1853 Menu *nudge_menu = manage (new Menu());
1854 MenuList& nudge_items = nudge_menu->items();
1855 nudge_menu->set_name ("ArdourContextMenu");
1857 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1858 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1859 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1860 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1862 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1863 items.push_back (SeparatorElem());
1865 Menu *trim_menu = manage (new Menu);
1866 MenuList& trim_items = trim_menu->items();
1867 trim_menu->set_name ("ArdourContextMenu");
1869 trim_items.push_back (MenuElem (_("Start to edit cursor"), mem_fun(*this, &Editor::trim_region_from_edit_cursor)));
1870 trim_items.push_back (MenuElem (_("Edit cursor to end"), mem_fun(*this, &Editor::trim_region_to_edit_cursor)));
1872 items.push_back (MenuElem (_("Trim"), *trim_menu));
1873 items.push_back (SeparatorElem());
1875 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1876 region_edit_menu_split_item = &items.back();
1878 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1879 region_edit_menu_split_multichannel_item = &items.back();
1881 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1882 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1883 items.push_back (SeparatorElem());
1884 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1885 items.push_back (SeparatorElem());
1886 items.push_back (MenuElem (_("Destroy"), mem_fun(*this, &Editor::destroy_clicked_region)));
1888 /* OK, stick the region submenu at the top of the list, and then add
1892 /* we have to hack up the region name because "_" has a special
1893 meaning for menu titles.
1896 string::size_type pos = 0;
1897 string menu_item_name = region->name();
1899 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1900 menu_item_name.replace (pos, 1, "__");
1904 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1905 edit_items.push_back (SeparatorElem());
1909 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1911 using namespace Menu_Helpers;
1912 Menu *selection_menu = manage (new Menu);
1913 MenuList& items = selection_menu->items();
1914 selection_menu->set_name ("ArdourContextMenu");
1916 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1917 items.push_back (MenuElem (_("Loop range"), mem_fun(*this, &Editor::set_route_loop_selection)));
1920 items.push_back (SeparatorElem());
1921 items.push_back (MenuElem (_("Analyze range"), mem_fun(*this, &Editor::analyze_range_selection)));
1924 items.push_back (SeparatorElem());
1925 items.push_back (MenuElem (_("Separate range to track"), mem_fun(*this, &Editor::separate_region_from_selection)));
1926 items.push_back (MenuElem (_("Separate range to region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1928 items.push_back (SeparatorElem());
1929 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1930 items.push_back (SeparatorElem());
1931 items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1932 items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1933 items.push_back (SeparatorElem());
1934 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1935 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1936 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1937 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::name_selection)));
1938 items.push_back (SeparatorElem());
1939 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1940 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1942 edit_items.push_back (MenuElem (_("Range"), *selection_menu));
1943 edit_items.push_back (SeparatorElem());
1947 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1949 using namespace Menu_Helpers;
1953 Menu *play_menu = manage (new Menu);
1954 MenuList& play_items = play_menu->items();
1955 play_menu->set_name ("ArdourContextMenu");
1957 play_items.push_back (MenuElem (_("Play from edit cursor")));
1958 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1959 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1960 play_items.push_back (SeparatorElem());
1961 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1963 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1967 Menu *select_menu = manage (new Menu);
1968 MenuList& select_items = select_menu->items();
1969 select_menu->set_name ("ArdourContextMenu");
1971 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1972 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1973 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1974 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1975 select_items.push_back (SeparatorElem());
1976 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1977 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1978 select_items.push_back (SeparatorElem());
1979 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1980 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1981 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1982 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1983 select_items.push_back (MenuElem (_("Select all between cursors"), bind (mem_fun(*this, &Editor::select_all_selectables_between_cursors), playhead_cursor, edit_cursor)));
1984 select_items.push_back (SeparatorElem());
1986 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1990 Menu *cutnpaste_menu = manage (new Menu);
1991 MenuList& cutnpaste_items = cutnpaste_menu->items();
1992 cutnpaste_menu->set_name ("ArdourContextMenu");
1994 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1995 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1996 cutnpaste_items.push_back (MenuElem (_("Paste at edit cursor"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1997 cutnpaste_items.push_back (MenuElem (_("Paste at mouse"), mem_fun(*this, &Editor::mouse_paste)));
1999 cutnpaste_items.push_back (SeparatorElem());
2001 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
2002 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
2004 cutnpaste_items.push_back (SeparatorElem());
2006 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
2008 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
2010 /* Adding new material */
2012 edit_items.push_back (SeparatorElem());
2013 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
2014 edit_items.push_back (MenuElem (_("Insert Existing Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
2018 Menu *nudge_menu = manage (new Menu());
2019 MenuList& nudge_items = nudge_menu->items();
2020 nudge_menu->set_name ("ArdourContextMenu");
2022 edit_items.push_back (SeparatorElem());
2023 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2024 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2025 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2026 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2028 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2032 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
2034 using namespace Menu_Helpers;
2038 Menu *play_menu = manage (new Menu);
2039 MenuList& play_items = play_menu->items();
2040 play_menu->set_name ("ArdourContextMenu");
2042 play_items.push_back (MenuElem (_("Play from edit cursor")));
2043 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2044 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2048 Menu *select_menu = manage (new Menu);
2049 MenuList& select_items = select_menu->items();
2050 select_menu->set_name ("ArdourContextMenu");
2052 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2053 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2054 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2055 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2056 select_items.push_back (SeparatorElem());
2057 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
2058 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
2059 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2060 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2062 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2066 Menu *cutnpaste_menu = manage (new Menu);
2067 MenuList& cutnpaste_items = cutnpaste_menu->items();
2068 cutnpaste_menu->set_name ("ArdourContextMenu");
2070 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2071 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2072 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2074 Menu *nudge_menu = manage (new Menu());
2075 MenuList& nudge_items = nudge_menu->items();
2076 nudge_menu->set_name ("ArdourContextMenu");
2078 edit_items.push_back (SeparatorElem());
2079 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2080 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2081 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2082 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2084 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2087 /* CURSOR SETTING AND MARKS AND STUFF */
2090 Editor::set_snap_to (SnapType st)
2093 vector<string> txt = internationalize (snap_type_strings);
2094 snap_type_selector.set_active_text (txt[(int)st]);
2098 switch (snap_type) {
2099 case SnapToAThirtysecondBeat:
2100 case SnapToASixteenthBeat:
2101 case SnapToAEighthBeat:
2102 case SnapToAQuarterBeat:
2103 case SnapToAThirdBeat:
2104 update_tempo_based_rulers ();
2112 Editor::set_snap_mode (SnapMode mode)
2115 vector<string> txt = internationalize (snap_mode_strings);
2116 snap_mode_selector.set_active_text (txt[(int)mode]);
2122 Editor::set_state (const XMLNode& node)
2124 const XMLProperty* prop;
2126 int x, y, xoff, yoff;
2130 if ((geometry = find_named_node (node, "geometry")) == 0) {
2132 g.base_width = default_width;
2133 g.base_height = default_height;
2141 g.base_width = atoi(geometry->property("x_size")->value());
2142 g.base_height = atoi(geometry->property("y_size")->value());
2143 x = atoi(geometry->property("x_pos")->value());
2144 y = atoi(geometry->property("y_pos")->value());
2145 xoff = atoi(geometry->property("x_off")->value());
2146 yoff = atoi(geometry->property("y_off")->value());
2149 set_geometry_hints (vpacker, g, Gdk::HINT_BASE_SIZE);
2150 set_default_size (g.base_width, g.base_height);
2153 if ((prop = node.property ("zoom-focus"))) {
2154 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2157 if ((prop = node.property ("zoom"))) {
2158 set_frames_per_unit (PBD::atof (prop->value()));
2161 if ((prop = node.property ("snap-to"))) {
2162 set_snap_to ((SnapType) atoi (prop->value()));
2165 if ((prop = node.property ("snap-mode"))) {
2166 set_snap_mode ((SnapMode) atoi (prop->value()));
2169 if ((prop = node.property ("mouse-mode"))) {
2170 MouseMode m = str2mousemode(prop->value());
2171 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2172 set_mouse_mode (m, true);
2174 mouse_mode = MouseGain; /* lie, to force the mode switch */
2175 set_mouse_mode (MouseObject, true);
2178 if ((prop = node.property ("show-waveforms"))) {
2179 bool yn = (prop->value() == "yes");
2180 _show_waveforms = !yn;
2181 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
2183 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2184 /* do it twice to force the change */
2185 tact->set_active (!yn);
2186 tact->set_active (yn);
2190 if ((prop = node.property ("show-waveforms-recording"))) {
2191 bool yn = (prop->value() == "yes");
2192 _show_waveforms_recording = !yn;
2193 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2195 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2196 /* do it twice to force the change */
2197 tact->set_active (!yn);
2198 tact->set_active (yn);
2202 if ((prop = node.property ("show-measures"))) {
2203 bool yn = (prop->value() == "yes");
2204 _show_measures = !yn;
2205 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2207 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2208 /* do it twice to force the change */
2209 tact->set_active (!yn);
2210 tact->set_active (yn);
2214 if ((prop = node.property ("follow-playhead"))) {
2215 bool yn = (prop->value() == "yes");
2216 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2218 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2219 /* do it twice to force the change */
2220 tact->set_active (!yn);
2221 tact->set_active (yn);
2226 if ((prop = node.property ("region-list-sort-type"))) {
2227 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2228 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2231 if ((prop = node.property ("xfades-visible"))) {
2232 bool yn = (prop->value() == "yes");
2233 _xfade_visibility = !yn;
2234 // set_xfade_visibility (yn);
2237 if ((prop = node.property ("show-editor-mixer"))) {
2239 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2241 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2242 bool yn = (prop->value() == X_("yes"));
2244 /* do it twice to force the change */
2246 tact->set_active (!yn);
2247 tact->set_active (yn);
2255 Editor::get_state ()
2257 XMLNode* node = new XMLNode ("Editor");
2260 if (is_realized()) {
2261 Glib::RefPtr<Gdk::Window> win = get_window();
2263 int x, y, xoff, yoff, width, height;
2264 win->get_root_origin(x, y);
2265 win->get_position(xoff, yoff);
2266 win->get_size(width, height);
2268 XMLNode* geometry = new XMLNode ("geometry");
2270 snprintf(buf, sizeof(buf), "%d", width);
2271 geometry->add_property("x_size", string(buf));
2272 snprintf(buf, sizeof(buf), "%d", height);
2273 geometry->add_property("y_size", string(buf));
2274 snprintf(buf, sizeof(buf), "%d", x);
2275 geometry->add_property("x_pos", string(buf));
2276 snprintf(buf, sizeof(buf), "%d", y);
2277 geometry->add_property("y_pos", string(buf));
2278 snprintf(buf, sizeof(buf), "%d", xoff);
2279 geometry->add_property("x_off", string(buf));
2280 snprintf(buf, sizeof(buf), "%d", yoff);
2281 geometry->add_property("y_off", string(buf));
2282 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2283 geometry->add_property("edit_pane_pos", string(buf));
2285 node->add_child_nocopy (*geometry);
2288 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2289 node->add_property ("zoom-focus", buf);
2290 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2291 node->add_property ("zoom", buf);
2292 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2293 node->add_property ("snap-to", buf);
2294 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2295 node->add_property ("snap-mode", buf);
2297 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2298 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2299 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2300 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2301 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2302 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2303 node->add_property ("mouse-mode", enum2str(mouse_mode));
2305 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2307 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2308 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2317 Editor::trackview_by_y_position (double y)
2319 TrackViewList::iterator iter;
2322 for (iter = track_views.begin(); iter != track_views.end(); ++iter) {
2330 if (tv->y_position <= y && y < ((tv->y_position + tv->height + track_spacing))) {
2339 Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark)
2341 Location* before = 0;
2342 Location* after = 0;
2348 const jack_nframes_t one_second = session->frame_rate();
2349 const jack_nframes_t one_minute = session->frame_rate() * 60;
2351 jack_nframes_t presnap = start;
2353 switch (snap_type) {
2359 start = (jack_nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2361 start = (jack_nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2364 case SnapToSMPTEFrame:
2366 start = (jack_nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2368 start = (jack_nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2372 case SnapToSMPTESeconds:
2373 if (session->smpte_offset_negative())
2375 start += session->smpte_offset ();
2377 start -= session->smpte_offset ();
2379 if (direction > 0) {
2380 start = (jack_nframes_t) ceil ((double) start / one_second) * one_second;
2382 start = (jack_nframes_t) floor ((double) start / one_second) * one_second;
2385 if (session->smpte_offset_negative())
2387 start -= session->smpte_offset ();
2389 start += session->smpte_offset ();
2393 case SnapToSMPTEMinutes:
2394 if (session->smpte_offset_negative())
2396 start += session->smpte_offset ();
2398 start -= session->smpte_offset ();
2401 start = (jack_nframes_t) ceil ((double) start / one_minute) * one_minute;
2403 start = (jack_nframes_t) floor ((double) start / one_minute) * one_minute;
2405 if (session->smpte_offset_negative())
2407 start -= session->smpte_offset ();
2409 start += session->smpte_offset ();
2415 start = (jack_nframes_t) ceil ((double) start / one_second) * one_second;
2417 start = (jack_nframes_t) floor ((double) start / one_second) * one_second;
2423 start = (jack_nframes_t) ceil ((double) start / one_minute) * one_minute;
2425 start = (jack_nframes_t) floor ((double) start / one_minute) * one_minute;
2430 start = session->tempo_map().round_to_bar (start, direction);
2434 start = session->tempo_map().round_to_beat (start, direction);
2437 case SnapToAThirtysecondBeat:
2438 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2441 case SnapToASixteenthBeat:
2442 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2445 case SnapToAEighthBeat:
2446 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2449 case SnapToAQuarterBeat:
2450 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2453 case SnapToAThirdBeat:
2454 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2457 case SnapToEditCursor:
2458 start = edit_cursor->current_frame;
2466 before = session->locations()->first_location_before (start);
2467 after = session->locations()->first_location_after (start);
2469 if (direction < 0) {
2471 start = before->start();
2475 } else if (direction > 0) {
2477 start = after->start();
2479 start = session->current_end_frame();
2484 /* find nearest of the two */
2485 if ((start - before->start()) < (after->start() - start)) {
2486 start = before->start();
2488 start = after->start();
2491 start = before->start();
2494 start = after->start();
2501 case SnapToRegionStart:
2502 case SnapToRegionEnd:
2503 case SnapToRegionSync:
2504 case SnapToRegionBoundary:
2505 if (!region_boundary_cache.empty()) {
2506 vector<jack_nframes_t>::iterator i;
2508 if (direction > 0) {
2509 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2511 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2514 if (i != region_boundary_cache.end()) {
2517 start = region_boundary_cache.back();
2523 switch (snap_mode) {
2529 if (presnap > start) {
2530 if (presnap > (start + unit_to_frame(snap_threshold))) {
2534 } else if (presnap < start) {
2535 if (presnap < (start - unit_to_frame(snap_threshold))) {
2547 Editor::setup_toolbar ()
2551 const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
2554 /* Mode Buttons (tool selection) */
2556 vector<ToggleButton *> mouse_mode_buttons;
2558 mouse_move_button.add (*(manage (new Image (get_xpm("tool_object.xpm")))));
2559 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2560 mouse_mode_buttons.push_back (&mouse_move_button);
2561 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2562 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2563 mouse_mode_buttons.push_back (&mouse_select_button);
2564 mouse_gain_button.add (*(manage (new Image (get_xpm("tool_gain.xpm")))));
2565 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2566 mouse_mode_buttons.push_back (&mouse_gain_button);
2567 mouse_zoom_button.add (*(manage (new Image (get_xpm("tool_zoom.xpm")))));
2568 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2569 mouse_mode_buttons.push_back (&mouse_zoom_button);
2570 mouse_timefx_button.add (*(manage (new Image (get_xpm("tool_stretch.xpm")))));
2571 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2572 mouse_mode_buttons.push_back (&mouse_timefx_button);
2573 mouse_audition_button.add (*(manage (new Image (get_xpm("tool_audition.xpm")))));
2574 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2575 mouse_mode_buttons.push_back (&mouse_audition_button);
2577 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2579 HBox* mode_box = manage(new HBox);
2580 mode_box->set_border_width (2);
2581 mode_box->set_spacing(4);
2582 mouse_mode_button_box.set_spacing(1);
2583 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2584 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2585 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2586 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2587 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2588 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2589 mouse_mode_button_box.set_homogeneous(true);
2591 // This one needs a little more "FUDGE" on my machine at least..
2592 edit_mode_selector.set_name ("EditModeSelector");
2593 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, "Splice Edit", 3+FUDGE, 10);
2594 set_popdown_strings (edit_mode_selector, internationalize (edit_mode_strings));
2595 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2597 mode_box->pack_start(edit_mode_selector);
2598 mode_box->pack_start(mouse_mode_button_box);
2600 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2601 mouse_mode_tearoff->set_name ("MouseModeBase");
2603 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2604 &mouse_mode_tearoff->tearoff_window()));
2605 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2606 &mouse_mode_tearoff->tearoff_window(), 1));
2607 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2608 &mouse_mode_tearoff->tearoff_window()));
2609 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2610 &mouse_mode_tearoff->tearoff_window(), 1));
2612 mouse_move_button.set_name ("MouseModeButton");
2613 mouse_select_button.set_name ("MouseModeButton");
2614 mouse_gain_button.set_name ("MouseModeButton");
2615 mouse_zoom_button.set_name ("MouseModeButton");
2616 mouse_timefx_button.set_name ("MouseModeButton");
2617 mouse_audition_button.set_name ("MouseModeButton");
2619 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
2620 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
2621 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
2622 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
2623 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
2624 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
2626 mouse_move_button.unset_flags (CAN_FOCUS);
2627 mouse_select_button.unset_flags (CAN_FOCUS);
2628 mouse_gain_button.unset_flags (CAN_FOCUS);
2629 mouse_zoom_button.unset_flags (CAN_FOCUS);
2630 mouse_timefx_button.unset_flags (CAN_FOCUS);
2631 mouse_audition_button.unset_flags (CAN_FOCUS);
2633 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2634 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2636 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2637 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2638 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2639 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2640 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2642 // mouse_move_button.set_active (true);
2647 zoom_box.set_spacing (1);
2648 zoom_box.set_border_width (2);
2650 zoom_in_button.set_name ("EditorTimeButton");
2651 zoom_in_button.add (*(manage (new Image (get_xpm("zoom_in.xpm")))));
2652 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2653 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2655 zoom_out_button.set_name ("EditorTimeButton");
2656 zoom_out_button.add (*(manage (new Image (get_xpm("zoom_out.xpm")))));
2657 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2658 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2660 zoom_out_full_button.set_name ("EditorTimeButton");
2661 zoom_out_full_button.add (*(manage (new Image (get_xpm("zoom_full.xpm")))));
2662 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2663 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2665 zoom_box.pack_start (zoom_out_button, false, false);
2666 zoom_box.pack_start (zoom_in_button, false, false);
2667 zoom_box.pack_start (zoom_range_clock, false, false);
2668 zoom_box.pack_start (zoom_out_full_button, false, false);
2670 ARDOUR_UI::instance()->tooltips().set_tip (zoom_range_clock, _("Current Zoom Range\n(Width of visible area)"));
2672 zoom_focus_selector.set_name ("ZoomFocusSelector");
2673 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Focus Center", 2+FUDGE, 0);
2674 set_popdown_strings (zoom_focus_selector, internationalize (zoom_focus_strings));
2675 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2677 zoom_box.pack_start (zoom_focus_selector, false, false);
2680 /* Edit Cursor / Snap */
2682 snap_box.set_spacing (1);
2683 snap_box.set_border_width (2);
2685 snap_type_selector.set_name ("SnapTypeSelector");
2686 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, "SMPTE Seconds", 2+FUDGE, 10);
2687 set_popdown_strings (snap_type_selector, internationalize (snap_type_strings));
2688 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2689 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Unit to snap cursors and ranges to"));
2691 snap_mode_selector.set_name ("SnapModeSelector");
2692 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, "Magnetic Snap", 2+FUDGE, 10);
2693 set_popdown_strings (snap_mode_selector, internationalize (snap_mode_strings));
2694 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2696 snap_box.pack_start (edit_cursor_clock, false, false);
2697 snap_box.pack_start (snap_mode_selector, false, false);
2698 snap_box.pack_start (snap_type_selector, false, false);
2703 HBox *nudge_box = manage (new HBox);
2704 nudge_box->set_spacing(1);
2705 nudge_box->set_border_width (2);
2707 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2708 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2710 nudge_box->pack_start (nudge_backward_button, false, false);
2711 nudge_box->pack_start (nudge_forward_button, false, false);
2712 nudge_box->pack_start (nudge_clock, false, false);
2715 /* Pack everything in... */
2717 HBox* hbox = new HBox;
2718 hbox->set_spacing(10);
2720 tools_tearoff = new TearOff (*hbox);
2721 tools_tearoff->set_name ("MouseModeBase");
2723 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2724 &tools_tearoff->tearoff_window()));
2725 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2726 &tools_tearoff->tearoff_window(), 0));
2727 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2728 &tools_tearoff->tearoff_window()));
2729 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2730 &tools_tearoff->tearoff_window(), 0));
2732 toolbar_hbox.set_spacing (10);
2733 toolbar_hbox.set_border_width (1);
2735 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2736 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2739 hbox->pack_start (snap_box, false, false);
2740 hbox->pack_start (zoom_box, false, false);
2741 hbox->pack_start (*nudge_box, false, false);
2745 toolbar_base.set_name ("ToolBarBase");
2746 toolbar_base.add (toolbar_hbox);
2748 toolbar_frame.set_shadow_type (SHADOW_OUT);
2749 toolbar_frame.set_name ("BaseFrame");
2750 toolbar_frame.add (toolbar_base);
2754 Editor::convert_drop_to_paths (vector<ustring>& paths,
2755 const RefPtr<Gdk::DragContext>& context,
2758 const SelectionData& data,
2767 vector<ustring> uris = data.get_uris();
2771 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
2772 are actually URI lists. So do it by hand.
2775 if (data.get_target() != "text/plain") {
2779 /* Parse the "uri-list" format that Nautilus provides,
2780 where each pathname is delimited by \r\n
2783 const char* p = data.get_text().c_str();
2790 while (g_ascii_isspace (*p))
2794 while (*q && (*q != '\n') && (*q != '\r'))
2800 while (q > p && g_ascii_isspace (*q))
2805 uris.push_back (ustring (p, q - p + 1));
2809 p = strchr (p, '\n');
2819 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
2820 if ((*i).substr (0,7) == "file://") {
2822 PBD::url_decode (p);
2823 paths.push_back (p.substr (7));
2831 Editor::new_tempo_section ()
2837 Editor::map_transport_state ()
2839 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
2841 if (session->transport_stopped()) {
2842 have_pending_keyboard_selection = false;
2848 Editor::State::State ()
2850 selection = new Selection;
2853 Editor::State::~State ()
2859 Editor::get_memento () const
2861 State *state = new State;
2863 store_state (*state);
2864 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
2868 Editor::store_state (State& state) const
2870 *state.selection = *selection;
2874 Editor::restore_state (State *state)
2876 if (*selection == *state->selection) {
2880 *selection = *state->selection;
2881 time_selection_changed ();
2882 region_selection_changed ();
2884 /* XXX other selection change handlers? */
2888 Editor::begin_reversible_command (string name)
2891 UndoAction ua = get_memento();
2892 session->begin_reversible_command (name, &ua);
2897 Editor::commit_reversible_command ()
2900 UndoAction ua = get_memento();
2901 session->commit_reversible_command (&ua);
2906 Editor::set_selected_track_from_click (bool press, Selection::Operation op, bool with_undo, bool no_remove)
2908 bool commit = false;
2910 if (!clicked_trackview) {
2915 case Selection::Toggle:
2916 if (selection->selected (clicked_trackview)) {
2918 selection->remove (clicked_trackview);
2922 selection->add (clicked_trackview);
2927 case Selection::Set:
2928 if (selection->selected (clicked_trackview) && selection->tracks.size() == 1) {
2929 /* no commit necessary */
2932 selection->set (clicked_trackview);
2935 case Selection::Extend:
2936 /* not defined yet */
2944 Editor::set_selected_control_point_from_click (bool press, Selection::Operation op, bool with_undo, bool no_remove)
2946 if (!clicked_control_point) {
2950 /* select this point and any others that it represents */
2953 jack_nframes_t x1, x2;
2955 x1 = pixel_to_frame (clicked_control_point->get_x() - 10);
2956 x2 = pixel_to_frame (clicked_control_point->get_x() + 10);
2957 y1 = clicked_control_point->get_x() - 10;
2958 y2 = clicked_control_point->get_y() + 10;
2960 return select_all_within (x1, x2, y1, y2, op);
2964 Editor::get_relevant_audio_tracks (AudioTimeAxisView& base, set<AudioTimeAxisView*>& relevant_tracks)
2966 /* step one: get all selected tracks and all tracks in the relevant edit groups */
2968 for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) {
2970 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*ti);
2976 RouteGroup* group = atv->route().edit_group();
2978 if (group && group->is_active()) {
2980 /* active group for this track, loop over all tracks and get every member of the group */
2982 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
2984 AudioTimeAxisView* tatv;
2986 if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
2988 if (tatv->route().edit_group() == group) {
2989 relevant_tracks.insert (tatv);
2996 /* no active group, or no group */
2998 relevant_tracks.insert (&base);
3005 Editor::mapover_audio_tracks (slot<void,AudioTimeAxisView&,uint32_t> sl)
3007 set<AudioTimeAxisView*> relevant_tracks;
3009 if (!clicked_audio_trackview) {
3013 get_relevant_audio_tracks (*clicked_audio_trackview, relevant_tracks);
3015 uint32_t sz = relevant_tracks.size();
3017 for (set<AudioTimeAxisView*>::iterator ati = relevant_tracks.begin(); ati != relevant_tracks.end(); ++ati) {
3023 Editor::mapped_set_selected_regionview_from_click (AudioTimeAxisView& atv, uint32_t ignored,
3024 AudioRegionView* basis, vector<AudioRegionView*>* all_equivs)
3027 vector<AudioRegion*> results;
3028 AudioRegionView* marv;
3029 AudioDiskstream* ds;
3031 if ((ds = atv.get_diskstream()) == 0) {
3036 if (&atv == &basis->get_time_axis_view()) {
3037 /* looking in same track as the original */
3042 if ((pl = dynamic_cast<AudioPlaylist*>(ds->playlist())) != 0) {
3043 pl->get_equivalent_regions (basis->region, results);
3046 for (vector<AudioRegion*>::iterator ir = results.begin(); ir != results.end(); ++ir) {
3047 if ((marv = atv.view->find_view (**ir)) != 0) {
3048 all_equivs->push_back (marv);
3054 Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, bool no_track_remove)
3056 vector<AudioRegionView*> all_equivalent_regions;
3057 bool commit = false;
3059 if (!clicked_regionview || !clicked_audio_trackview) {
3063 if (op == Selection::Toggle || op == Selection::Set) {
3065 mapover_audio_tracks (bind (mem_fun (*this, &Editor::mapped_set_selected_regionview_from_click),
3066 clicked_regionview, &all_equivalent_regions));
3069 /* add clicked regionview since we skipped all other regions in the same track as the one it was in */
3071 all_equivalent_regions.push_back (clicked_regionview);
3074 case Selection::Toggle:
3076 if (clicked_regionview->get_selected()) {
3079 /* whatever was clicked was selected already; do nothing here but allow
3080 the button release to deselect it
3083 button_release_can_deselect = true;
3087 if (button_release_can_deselect) {
3089 /* just remove this one region, but only on a permitted button release */
3091 selection->remove (clicked_regionview);
3094 /* no more deselect action on button release till a new press
3095 finds an already selected object.
3098 button_release_can_deselect = false;
3105 /* add all the equivalent regions, but only on button press */
3107 if (!all_equivalent_regions.empty()) {
3111 for (vector<AudioRegionView*>::iterator i = all_equivalent_regions.begin(); i != all_equivalent_regions.end(); ++i) {
3112 selection->add (*i);
3118 case Selection::Set:
3119 if (!clicked_regionview->get_selected()) {
3120 selection->set (all_equivalent_regions);
3123 /* no commit necessary: clicked on an already selected region */
3129 /* silly compiler */
3133 } else if (op == Selection::Extend) {
3135 list<Selectable*> results;
3136 jack_nframes_t last_frame;
3137 jack_nframes_t first_frame;
3139 /* 1. find the last selected regionview in the track that was clicked in */
3142 first_frame = max_frames;
3144 for (AudioRegionSelection::iterator x = selection->audio_regions.begin(); x != selection->audio_regions.end(); ++x) {
3145 if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) {
3147 if ((*x)->region.last_frame() > last_frame) {
3148 last_frame = (*x)->region.last_frame();
3151 if ((*x)->region.first_frame() < first_frame) {
3152 first_frame = (*x)->region.first_frame();
3157 /* 2. figure out the boundaries for our search for new objects */
3159 switch (clicked_regionview->region.coverage (first_frame, last_frame)) {
3161 cerr << "no overlap, first = " << first_frame << " last = " << last_frame << " region = "
3162 << clicked_regionview->region.first_frame() << " .. " << clicked_regionview->region.last_frame() << endl;
3164 if (last_frame < clicked_regionview->region.first_frame()) {
3165 first_frame = last_frame;
3166 last_frame = clicked_regionview->region.last_frame();
3168 last_frame = first_frame;
3169 first_frame = clicked_regionview->region.first_frame();
3173 case OverlapExternal:
3174 cerr << "external overlap, first = " << first_frame << " last = " << last_frame << " region = "
3175 << clicked_regionview->region.first_frame() << " .. " << clicked_regionview->region.last_frame() << endl;
3177 if (last_frame < clicked_regionview->region.first_frame()) {
3178 first_frame = last_frame;
3179 last_frame = clicked_regionview->region.last_frame();
3181 last_frame = first_frame;
3182 first_frame = clicked_regionview->region.first_frame();
3186 case OverlapInternal:
3187 cerr << "internal overlap, first = " << first_frame << " last = " << last_frame << " region = "
3188 << clicked_regionview->region.first_frame() << " .. " << clicked_regionview->region.last_frame() << endl;
3190 if (last_frame < clicked_regionview->region.first_frame()) {
3191 first_frame = last_frame;
3192 last_frame = clicked_regionview->region.last_frame();
3194 last_frame = first_frame;
3195 first_frame = clicked_regionview->region.first_frame();
3201 /* nothing to do except add clicked region to selection, since it
3202 overlaps with the existing selection in this track.
3207 /* 2. find all selectable objects (regionviews in this case) between that one and the end of the
3208 one that was clicked.
3211 set<AudioTimeAxisView*> relevant_tracks;
3213 get_relevant_audio_tracks (*clicked_audio_trackview, relevant_tracks);
3215 for (set<AudioTimeAxisView*>::iterator t = relevant_tracks.begin(); t != relevant_tracks.end(); ++t) {
3216 (*t)->get_selectables (first_frame, last_frame, -1.0, -1.0, results);
3219 /* 3. convert to a vector of audio regions */
3221 vector<AudioRegionView*> audio_regions;
3223 for (list<Selectable*>::iterator x = results.begin(); x != results.end(); ++x) {
3224 AudioRegionView* arv;
3226 if ((arv = dynamic_cast<AudioRegionView*>(*x)) != 0) {
3227 audio_regions.push_back (arv);
3231 if (!audio_regions.empty()) {
3232 selection->add (audio_regions);
3242 Editor::set_selected_regionview_from_region_list (Region& r, Selection::Operation op)
3244 vector<AudioRegionView*> all_equivalent_regions;
3245 AudioRegion* region;
3247 if ((region = dynamic_cast<AudioRegion*>(&r)) == 0) {
3251 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3253 AudioTimeAxisView* tatv;
3255 if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
3258 vector<AudioRegion*> results;
3259 AudioRegionView* marv;
3260 AudioDiskstream* ds;
3262 if ((ds = tatv->get_diskstream()) == 0) {
3267 if ((pl = dynamic_cast<AudioPlaylist*>(ds->playlist())) != 0) {
3268 pl->get_region_list_equivalent_regions (*region, results);
3271 for (vector<AudioRegion*>::iterator ir = results.begin(); ir != results.end(); ++ir) {
3272 if ((marv = tatv->view->find_view (**ir)) != 0) {
3273 all_equivalent_regions.push_back (marv);
3280 begin_reversible_command (_("set selected regions"));
3283 case Selection::Toggle:
3284 /* XXX this is not correct */
3285 selection->toggle (all_equivalent_regions);
3287 case Selection::Set:
3288 selection->set (all_equivalent_regions);
3290 case Selection::Extend:
3291 selection->add (all_equivalent_regions);
3295 commit_reversible_command () ;
3299 Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, Region* r)
3301 AudioRegionView* rv;
3304 if ((ar = dynamic_cast<AudioRegion*> (r)) == 0) {
3308 if ((rv = sv->find_view (*ar)) == 0) {
3312 /* don't reset the selection if its something other than
3313 a single other region.
3316 if (selection->audio_regions.size() > 1) {
3320 begin_reversible_command (_("set selected regions"));
3322 selection->set (rv);
3324 commit_reversible_command () ;
3330 Editor::set_edit_group_solo (Route& route, bool yn)
3332 RouteGroup *edit_group;
3334 if ((edit_group = route.edit_group()) != 0) {
3335 edit_group->apply (&Route::set_solo, yn, this);
3337 route.set_solo (yn, this);
3342 Editor::set_edit_group_mute (Route& route, bool yn)
3344 RouteGroup *edit_group = 0;
3346 if ((edit_group == route.edit_group()) != 0) {
3347 edit_group->apply (&Route::set_mute, yn, this);
3349 route.set_mute (yn, this);
3354 Editor::set_edit_menu (Menu& menu)
3357 edit_menu->signal_map_event().connect (mem_fun(*this, &Editor::edit_menu_map_handler));
3361 Editor::edit_menu_map_handler (GdkEventAny* ev)
3363 using namespace Menu_Helpers;
3364 MenuList& edit_items = edit_menu->items();
3367 /* Nuke all the old items */
3369 edit_items.clear ();
3375 if (session->undo_depth() == 0) {
3378 label = string_compose(_("Undo (%1)"), session->next_undo());
3381 edit_items.push_back (MenuElem (label, bind (mem_fun(*this, &Editor::undo), 1U)));
3383 if (session->undo_depth() == 0) {
3384 edit_items.back().set_sensitive (false);
3387 if (session->redo_depth() == 0) {
3390 label = string_compose(_("Redo (%1)"), session->next_redo());
3393 edit_items.push_back (MenuElem (label, bind (mem_fun(*this, &Editor::redo), 1U)));
3394 if (session->redo_depth() == 0) {
3395 edit_items.back().set_sensitive (false);
3398 vector<MenuItem*> mitems;
3400 edit_items.push_back (SeparatorElem());
3401 edit_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
3402 mitems.push_back (&edit_items.back());
3403 edit_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
3404 mitems.push_back (&edit_items.back());
3405 edit_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
3406 mitems.push_back (&edit_items.back());
3407 edit_items.push_back (SeparatorElem());
3408 edit_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
3409 mitems.push_back (&edit_items.back());
3410 edit_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
3411 mitems.push_back (&edit_items.back());
3412 edit_items.push_back (SeparatorElem());
3414 if (selection->empty()) {
3415 for (vector<MenuItem*>::iterator i = mitems.begin(); i != mitems.end(); ++i) {
3416 (*i)->set_sensitive (false);
3420 Menu* import_menu = manage (new Menu());
3421 import_menu->set_name ("ArdourContextMenu");
3422 MenuList& import_items = import_menu->items();
3424 import_items.push_back (MenuElem (_("... as new track"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsTrack)));
3425 import_items.push_back (MenuElem (_("... as new region"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion)));
3427 edit_items.push_back (MenuElem (_("Import audio (copy)"), *import_menu));
3428 edit_items.push_back (SeparatorElem());
3430 edit_items.push_back (MenuElem (_("Remove last capture"), mem_fun(*this, &Editor::remove_last_capture)));
3432 if (!session->have_captured()) {
3433 edit_items.back().set_sensitive (false);
3440 Editor::duplicate_dialog (bool dup_region)
3443 if (clicked_regionview == 0) {
3447 if (selection->time.length() == 0) {
3452 ArdourDialog win ("duplicate dialog");
3454 Label label (_("Duplicate how many times?"));
3456 win.get_vbox()->pack_start (label);
3457 win.add_action_widget (entry, RESPONSE_ACCEPT);
3458 win.add_button (Stock::OK, RESPONSE_ACCEPT);
3459 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3461 win.set_position (WIN_POS_MOUSE);
3463 entry.set_text ("1");
3464 set_size_request_to_display_given_text (entry, X_("12345678"), 20, 15);
3465 entry.select_region (0, entry.get_text_length());
3466 entry.grab_focus ();
3469 switch (win.run ()) {
3470 case RESPONSE_ACCEPT:
3476 string text = entry.get_text();
3479 if (sscanf (text.c_str(), "%f", ×) == 1) {
3481 AudioRegionSelection regions;
3482 regions.add (clicked_regionview);
3483 duplicate_some_regions (regions, times);
3485 duplicate_selection (times);
3491 Editor::show_verbose_canvas_cursor ()
3493 verbose_canvas_cursor->raise_to_top();
3494 verbose_canvas_cursor->show();
3495 verbose_cursor_visible = true;
3499 Editor::hide_verbose_canvas_cursor ()
3501 verbose_canvas_cursor->hide();
3502 verbose_cursor_visible = false;
3506 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3508 /* XXX get origin of canvas relative to root window,
3509 add x and y and check compared to gdk_screen_{width,height}
3511 verbose_canvas_cursor->property_text() = txt.c_str();
3512 verbose_canvas_cursor->property_x() = x;
3513 verbose_canvas_cursor->property_y() = y;
3517 Editor::set_verbose_canvas_cursor_text (const string & txt)
3519 verbose_canvas_cursor->property_text() = txt.c_str();
3523 Editor::edit_mode_selection_done ()
3529 string choice = edit_mode_selector.get_active_text();
3530 EditMode mode = Slide;
3532 if (choice == _("Splice Edit")) {
3534 } else if (choice == _("Slide Edit")) {
3538 session->set_edit_mode (mode);
3542 Editor::snap_type_selection_done ()
3548 string choice = snap_type_selector.get_active_text();
3549 SnapType snaptype = SnapToFrame;
3551 if (choice == _("Beats/3")) {
3552 snaptype = SnapToAThirdBeat;
3553 } else if (choice == _("Beats/4")) {
3554 snaptype = SnapToAQuarterBeat;
3555 } else if (choice == _("Beats/8")) {
3556 snaptype = SnapToAEighthBeat;
3557 } else if (choice == _("Beats/16")) {
3558 snaptype = SnapToASixteenthBeat;
3559 } else if (choice == _("Beats/32")) {
3560 snaptype = SnapToAThirtysecondBeat;
3561 } else if (choice == _("Beats")) {
3562 snaptype = SnapToBeat;
3563 } else if (choice == _("Bars")) {
3564 snaptype = SnapToBar;
3565 } else if (choice == _("Marks")) {
3566 snaptype = SnapToMark;
3567 } else if (choice == _("Edit Cursor")) {
3568 snaptype = SnapToEditCursor;
3569 } else if (choice == _("Region starts")) {
3570 snaptype = SnapToRegionStart;
3571 } else if (choice == _("Region ends")) {
3572 snaptype = SnapToRegionEnd;
3573 } else if (choice == _("Region bounds")) {
3574 snaptype = SnapToRegionBoundary;
3575 } else if (choice == _("Region syncs")) {
3576 snaptype = SnapToRegionSync;
3577 } else if (choice == _("CD Frames")) {
3578 snaptype = SnapToCDFrame;
3579 } else if (choice == _("SMPTE Frames")) {
3580 snaptype = SnapToSMPTEFrame;
3581 } else if (choice == _("SMPTE Seconds")) {
3582 snaptype = SnapToSMPTESeconds;
3583 } else if (choice == _("SMPTE Minutes")) {
3584 snaptype = SnapToSMPTEMinutes;
3585 } else if (choice == _("Seconds")) {
3586 snaptype = SnapToSeconds;
3587 } else if (choice == _("Minutes")) {
3588 snaptype = SnapToMinutes;
3589 } else if (choice == _("None")) {
3590 snaptype = SnapToFrame;
3593 set_snap_to (snaptype);
3597 Editor::snap_mode_selection_done ()
3603 string choice = snap_mode_selector.get_active_text();
3604 SnapMode mode = SnapNormal;
3606 if (choice == _("Normal Snap")) {
3608 } else if (choice == _("Magnetic Snap")) {
3609 mode = SnapMagnetic;
3612 set_snap_mode (mode);
3616 Editor::zoom_focus_selection_done ()
3622 string choice = zoom_focus_selector.get_active_text();
3623 ZoomFocus focus_type = ZoomFocusLeft;
3625 if (choice == _("Focus Left")) {
3626 focus_type = ZoomFocusLeft;
3627 } else if (choice == _("Focus Right")) {
3628 focus_type = ZoomFocusRight;
3629 } else if (choice == _("Focus Center")) {
3630 focus_type = ZoomFocusCenter;
3631 } else if (choice == _("Focus Playhead")) {
3632 focus_type = ZoomFocusPlayhead;
3633 } else if (choice == _("Focus Edit Cursor")) {
3634 focus_type = ZoomFocusEdit;
3637 set_zoom_focus (focus_type);
3641 Editor::edit_controls_button_release (GdkEventButton* ev)
3643 if (Keyboard::is_context_menu_event (ev)) {
3644 ARDOUR_UI::instance()->add_route ();
3650 Editor::track_selection_changed ()
3652 switch (selection->tracks.size()){
3656 set_selected_mixer_strip (*(selection->tracks.front()));
3660 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3661 (*i)->set_selected (false);
3662 if (mouse_mode == MouseRange) {
3663 (*i)->hide_selection ();
3667 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3668 (*i)->set_selected (true);
3669 if (mouse_mode == MouseRange) {
3670 (*i)->show_selection (selection->time);
3676 Editor::time_selection_changed ()
3678 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3679 (*i)->hide_selection ();
3682 if (selection->tracks.empty()) {
3683 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3684 (*i)->show_selection (selection->time);
3687 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3688 (*i)->show_selection (selection->time);
3692 if (selection->time.empty()) {
3693 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
3695 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true);
3700 Editor::region_selection_changed ()
3702 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3703 (*i)->set_selected_regionviews (selection->audio_regions);
3708 Editor::point_selection_changed ()
3710 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3711 (*i)->set_selected_points (selection->points);
3716 Editor::mouse_select_button_release (GdkEventButton* ev)
3718 /* this handles just right-clicks */
3720 if (ev->button != 3) {
3727 Editor::TrackViewList *
3728 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3731 TrackViewList::iterator i;
3733 v = new TrackViewList;
3735 if (track == 0 && group == 0) {
3739 for (i = track_views.begin(); i != track_views.end (); ++i) {
3743 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3745 /* just the view for this track
3748 v->push_back (track);
3752 /* views for all tracks in the edit group */
3754 for (i = track_views.begin(); i != track_views.end (); ++i) {
3756 if (group == 0 || (*i)->edit_group() == group) {
3766 Editor::set_zoom_focus (ZoomFocus f)
3768 if (zoom_focus != f) {
3770 vector<string> txt = internationalize (zoom_focus_strings);
3771 zoom_focus_selector.set_active_text (txt[(int)f]);
3772 ZoomFocusChanged (); /* EMIT_SIGNAL */
3779 Editor::ensure_float (Window& win)
3781 win.set_transient_for (*this);
3785 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3787 /* recover or initialize pane positions. do this here rather than earlier because
3788 we don't want the positions to change the child allocations, which they seem to do.
3794 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3796 static int32_t done;
3799 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3800 width = default_width;
3801 height = default_height;
3803 width = atoi(geometry->property("x_size")->value());
3804 height = atoi(geometry->property("y_size")->value());
3807 if (which == static_cast<Paned*> (&edit_pane)) {
3813 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3814 /* initial allocation is 90% to canvas, 10% to notebook */
3815 pos = (int) floor (alloc.get_width() * 0.90f);
3816 snprintf (buf, sizeof(buf), "%d", pos);
3818 pos = atoi (prop->value());
3821 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3822 edit_pane.set_position (pos);
3823 pre_maximal_pane_position = pos;
3829 Editor::detach_tearoff (Box* b, Window* w)
3831 if (tools_tearoff->torn_off() &&
3832 mouse_mode_tearoff->torn_off()) {
3833 top_hbox.remove (toolbar_frame);
3838 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3840 if (toolbar_frame.get_parent() == 0) {
3841 top_hbox.pack_end (toolbar_frame);
3846 Editor::set_show_measures (bool yn)
3848 if (_show_measures != yn) {
3851 if ((_show_measures = yn) == true) {
3854 DisplayControlChanged (ShowMeasures);
3860 Editor::toggle_follow_playhead ()
3862 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3864 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3865 set_follow_playhead (tact->get_active());
3870 Editor::set_follow_playhead (bool yn)
3872 if (_follow_playhead != yn) {
3873 if ((_follow_playhead = yn) == true) {
3875 update_current_screen ();
3877 DisplayControlChanged (FollowPlayhead);
3883 Editor::toggle_xfade_active (Crossfade* xfade)
3885 xfade->set_active (!xfade->active());
3889 Editor::toggle_xfade_length (Crossfade* xfade)
3891 xfade->set_follow_overlap (!xfade->following_overlap());
3895 Editor::edit_xfade (Crossfade* xfade)
3897 CrossfadeEditor cew (*session, *xfade, xfade->fade_in().get_min_y(), 1.0);
3901 switch (cew.run ()) {
3902 case RESPONSE_ACCEPT:
3909 xfade->StateChanged (Change (~0));
3913 Editor::playlist_selector () const
3915 return *_playlist_selector;
3919 Editor::get_nudge_distance (jack_nframes_t pos, jack_nframes_t& next)
3923 ret = nudge_clock.current_duration (pos);
3924 next = ret + 1; /* XXXX fix me */
3930 Editor::end_location_changed (Location* location)
3932 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3933 reset_scrolling_region ();
3937 Editor::playlist_deletion_dialog (Playlist* pl)
3939 ArdourDialog dialog ("playlist deletion dialog");
3940 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3941 "If left alone, no audio files used by it will be cleaned.\n"
3942 "If deleted, audio files used by it alone by will cleaned."),
3945 dialog.set_position (WIN_POS_CENTER);
3946 dialog.get_vbox()->pack_start (label);
3948 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3949 dialog.add_button (_("Keep playlist"), RESPONSE_CANCEL);
3950 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3952 switch (dialog.run ()) {
3953 case RESPONSE_ACCEPT:
3954 /* delete the playlist */
3958 case RESPONSE_REJECT:
3959 /* keep the playlist */
3971 Editor::audio_region_selection_covers (jack_nframes_t where)
3973 for (AudioRegionSelection::iterator a = selection->audio_regions.begin(); a != selection->audio_regions.end(); ++a) {
3974 if ((*a)->region.covers (where)) {
3983 Editor::prepare_for_cleanup ()
3985 cut_buffer->clear_audio_regions ();
3986 cut_buffer->clear_playlists ();
3988 selection->clear_audio_regions ();
3989 selection->clear_playlists ();
3993 Editor::transport_loop_location()
3996 return session->locations()->auto_loop_location();
4003 Editor::transport_punch_location()
4006 return session->locations()->auto_punch_location();
4013 Editor::control_layout_scroll (GdkEventScroll* ev)
4015 switch (ev->direction) {
4017 scroll_tracks_up_line ();
4021 case GDK_SCROLL_DOWN:
4022 scroll_tracks_down_line ();
4026 /* no left/right handling yet */
4034 Editor::snapshot_display_selection_changed ()
4036 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
4038 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
4040 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
4042 if (snap_name.length() == 0) {
4046 if (session->snap_name() == snap_name) {
4050 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
4055 Editor::snapshot_display_button_press (GdkEventButton* ev)
4061 Editor::redisplay_snapshots ()
4067 vector<string*>* states;
4069 if ((states = session->possible_states()) == 0) {
4073 snapshot_display_model->clear ();
4075 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
4076 string statename = *(*i);
4077 TreeModel::Row row = *(snapshot_display_model->append());
4078 row[snapshot_display_columns.visible_name] = statename;
4079 row[snapshot_display_columns.real_name] = statename;
4086 Editor::session_state_saved (string snap_name)
4088 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4089 redisplay_snapshots ();
4093 Editor::maximise_editing_space ()
4095 mouse_mode_tearoff->set_visible (false);
4096 tools_tearoff->set_visible (false);
4098 pre_maximal_pane_position = edit_pane.get_position();
4099 edit_pane.set_position (edit_pane.get_width());
4105 Editor::restore_editing_space ()
4107 mouse_mode_tearoff->set_visible (true);
4108 tools_tearoff->set_visible (true);
4109 edit_pane.set_position (pre_maximal_pane_position);
4115 Editor::new_playlists ()
4117 begin_reversible_command (_("new playlists"));
4118 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist));
4119 commit_reversible_command ();
4123 Editor::copy_playlists ()
4125 begin_reversible_command (_("copy playlists"));
4126 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist));
4127 commit_reversible_command ();
4131 Editor::clear_playlists ()
4133 begin_reversible_command (_("clear playlists"));
4134 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist));
4135 commit_reversible_command ();
4139 Editor::mapped_use_new_playlist (AudioTimeAxisView& atv, uint32_t sz)
4141 atv.use_new_playlist (sz > 1 ? false : true);
4145 Editor::mapped_use_copy_playlist (AudioTimeAxisView& atv, uint32_t sz)
4147 atv.use_copy_playlist (sz > 1 ? false : true);
4151 Editor::mapped_clear_playlist (AudioTimeAxisView& atv, uint32_t sz)
4153 atv.clear_playlist ();
4157 Editor::on_key_press_event (GdkEventKey* ev)
4159 return key_press_focus_accelerator_handler (*this, ev);
4163 Editor::update_layering_model ()
4167 switch (session->get_layer_model()) {
4168 case Session::LaterHigher:
4169 act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
4171 case Session::MoveAddHigher:
4172 act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
4174 case Session::AddHigher:
4175 act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
4180 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
4181 if (ract && !ract->get_active()) {
4182 ract->set_active (true);
4189 Editor::update_crossfade_model ()
4193 switch (session->get_xfade_model()) {
4195 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
4197 case ShortCrossfade:
4198 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
4203 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
4204 if (ract && !ract->get_active()) {
4205 ract->set_active (true);