2 Copyright (C) 2000-2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <sigc++/bind.h>
29 #include <pbd/convert.h>
30 #include <pbd/error.h>
31 #include <pbd/memento_command.h>
33 #include <gtkmm/image.h>
34 #include <gdkmm/color.h>
35 #include <gdkmm/bitmap.h>
37 #include <gtkmm2ext/gtk_ui.h>
38 #include <gtkmm2ext/tearoff.h>
39 #include <gtkmm2ext/utils.h>
41 #include <ardour/audio_track.h>
42 #include <ardour/audio_diskstream.h>
43 #include <ardour/plugin_manager.h>
44 #include <ardour/location.h>
45 #include <ardour/audioplaylist.h>
46 #include <ardour/audioregion.h>
47 #include <ardour/region.h>
48 #include <ardour/session_route.h>
49 #include <ardour/tempo.h>
50 #include <ardour/utils.h>
52 #include <control_protocol/control_protocol.h>
54 #include "ardour_ui.h"
56 #include "grouped_buttons.h"
59 #include "playlist_selector.h"
60 #include "audio_region_view.h"
61 #include "rgb_macros.h"
62 #include "selection.h"
63 #include "audio_streamview.h"
64 #include "time_axis_view.h"
65 #include "audio_time_axis.h"
67 #include "crossfade_view.h"
69 #include "public_editor.h"
70 #include "crossfade_edit.h"
71 #include "audio_time_axis.h"
72 #include "canvas_impl.h"
74 #include "gui_thread.h"
77 #include "analysis_window.h"
83 #include "imageframe_socket_handler.h"
84 /* </CMT Additions> */
88 using namespace ARDOUR;
92 using namespace Gtkmm2ext;
93 using namespace Editing;
95 using PBD::internationalize;
98 const double Editor::timebar_height = 15.0;
100 #include "editor_xpms"
102 static const gchar *_snap_type_strings[] = {
126 static const gchar *_snap_mode_strings[] = {
132 static const gchar *_zoom_focus_strings[] = {
141 /* Soundfile drag-n-drop */
143 Gdk::Cursor* Editor::cross_hair_cursor = 0;
144 Gdk::Cursor* Editor::selector_cursor = 0;
145 Gdk::Cursor* Editor::trimmer_cursor = 0;
146 Gdk::Cursor* Editor::grabber_cursor = 0;
147 Gdk::Cursor* Editor::zoom_cursor = 0;
148 Gdk::Cursor* Editor::time_fx_cursor = 0;
149 Gdk::Cursor* Editor::fader_cursor = 0;
150 Gdk::Cursor* Editor::speaker_cursor = 0;
151 Gdk::Cursor* Editor::wait_cursor = 0;
152 Gdk::Cursor* Editor::timebar_cursor = 0;
155 show_me_the_size (Requisition* r, const char* what)
157 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
161 check_adjustment (Gtk::Adjustment* adj)
163 cerr << "CHANGE adj = "
164 << adj->get_lower () << ' '
165 << adj->get_upper () << ' '
166 << adj->get_value () << ' '
167 << adj->get_step_increment () << ' '
168 << adj->get_page_increment () << ' '
169 << adj->get_page_size () << ' '
174 Editor::Editor (AudioEngine& eng)
177 /* time display buttons */
179 minsec_label (_("Mins:Secs")),
180 bbt_label (_("Bars:Beats")),
181 smpte_label (_("Timecode")),
182 frame_label (_("Frames")),
183 tempo_label (_("Tempo")),
184 meter_label (_("Meter")),
185 mark_label (_("Location Markers")),
186 range_mark_label (_("Range Markers")),
187 transport_mark_label (_("Loop/Punch Ranges")),
189 edit_packer (3, 3, false),
191 /* the values here don't matter: layout widgets
192 reset them as needed.
195 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
196 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
198 /* tool bar related */
200 edit_cursor_clock (X_("editcursor"), false, X_("EditCursorClock"), true),
201 zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true),
203 toolbar_selection_clock_table (2,3),
205 automation_mode_button (_("mode")),
206 global_automation_button (_("automation")),
208 /* <CMT Additions> */
209 image_socket_listener(0),
210 /* </CMT Additions> */
214 nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true)
219 /* we are a singleton */
221 PublicEditor::_instance = this;
225 selection = new Selection;
226 cut_buffer = new Selection;
228 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
229 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
230 selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
231 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
233 clicked_regionview = 0;
234 clicked_axisview = 0;
235 clicked_routeview = 0;
236 clicked_crossfadeview = 0;
237 clicked_control_point = 0;
238 latest_regionview = 0;
239 last_update_frame = 0;
241 current_mixer_strip = 0;
242 current_bbt_points = 0;
244 snap_type_strings = I18N (_snap_type_strings);
245 snap_mode_strings = I18N (_snap_mode_strings);
246 zoom_focus_strings = I18N(_zoom_focus_strings);
248 snap_type = SnapToFrame;
249 set_snap_to (snap_type);
250 snap_mode = SnapNormal;
251 set_snap_mode (snap_mode);
252 snap_threshold = 5.0;
253 bbt_beat_subdivision = 4;
256 autoscroll_active = false;
257 autoscroll_timeout_tag = -1;
258 interthread_progress_window = 0;
264 current_interthread_info = 0;
265 _show_measures = true;
266 _show_waveforms = true;
267 _show_waveforms_recording = true;
268 first_action_message = 0;
270 show_gain_after_trim = false;
271 ignore_route_list_reorder = false;
272 no_route_list_redisplay = false;
273 verbose_cursor_on = true;
274 route_removal = false;
276 show_automatic_regions_in_region_list = true;
277 region_list_sort_type = (Editing::RegionListSortType) 0;
278 have_pending_keyboard_selection = false;
279 _follow_playhead = true;
280 _xfade_visibility = true;
281 editor_ruler_menu = 0;
282 no_ruler_shown_update = false;
283 edit_group_list_menu = 0;
285 region_list_menu = 0;
287 start_end_marker_menu = 0;
288 range_marker_menu = 0;
289 marker_menu_item = 0;
291 transport_marker_menu = 0;
292 new_transport_marker_menu = 0;
293 editor_mixer_strip_width = Wide;
294 show_editor_mixer_when_tracks_arrive = false;
295 repos_zoom_queued = false;
296 region_edit_menu_split_item = 0;
298 region_edit_menu_split_multichannel_item = 0;
300 ignore_mouse_mode_toggle = false;
301 current_stepping_trackview = 0;
303 entered_regionview = 0;
304 clear_entered_track = false;
305 _new_regionviews_show_envelope = false;
306 current_timestretch = 0;
307 in_edit_group_row_change = false;
308 last_canvas_frame = 0;
311 button_release_can_deselect = true;
312 canvas_idle_queued = false;
313 _dragging_playhead = false;
315 location_marker_color = color_map[cLocationMarker];
316 location_range_color = color_map[cLocationRange];
317 location_cd_marker_color = color_map[cLocationCDMarker];
318 location_loop_color = color_map[cLocationLoop];
319 location_punch_color = color_map[cLocationPunch];
321 range_marker_drag_rect = 0;
322 marker_drag_line = 0;
324 set_mouse_mode (MouseObject, true);
326 frames_per_unit = 2048; /* too early to use set_frames_per_unit */
327 reset_hscrollbar_stepping ();
329 zoom_focus = ZoomFocusLeft;
330 set_zoom_focus (ZoomFocusLeft);
331 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
333 initialize_rulers ();
334 initialize_canvas ();
336 edit_controls_vbox.set_spacing (0);
337 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled));
338 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling));
340 track_canvas.set_hadjustment (horizontal_adjustment);
341 track_canvas.set_vadjustment (vertical_adjustment);
342 time_canvas.set_hadjustment (horizontal_adjustment);
344 track_canvas.signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
345 time_canvas.signal_map_event().connect (mem_fun (*this, &Editor::time_canvas_map_handler));
347 controls_layout.add (edit_controls_vbox);
348 controls_layout.set_name ("EditControlsBase");
349 controls_layout.add_events (Gdk::SCROLL_MASK);
350 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
352 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
353 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
354 controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
356 edit_vscrollbar.set_adjustment (vertical_adjustment);
357 edit_hscrollbar.set_adjustment (horizontal_adjustment);
359 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press));
360 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release));
361 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
366 edit_cursor_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_cursor_clock_changed));
368 time_canvas_vbox.pack_start (*minsec_ruler, false, false);
369 time_canvas_vbox.pack_start (*smpte_ruler, false, false);
370 time_canvas_vbox.pack_start (*frames_ruler, false, false);
371 time_canvas_vbox.pack_start (*bbt_ruler, false, false);
372 time_canvas_vbox.pack_start (time_canvas, true, true);
373 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars));
375 bbt_label.set_name ("EditorTimeButton");
376 bbt_label.set_size_request (-1, (int)timebar_height);
377 bbt_label.set_alignment (1.0, 0.5);
378 bbt_label.set_padding (5,0);
379 minsec_label.set_name ("EditorTimeButton");
380 minsec_label.set_size_request (-1, (int)timebar_height);
381 minsec_label.set_alignment (1.0, 0.5);
382 minsec_label.set_padding (5,0);
383 smpte_label.set_name ("EditorTimeButton");
384 smpte_label.set_size_request (-1, (int)timebar_height);
385 smpte_label.set_alignment (1.0, 0.5);
386 smpte_label.set_padding (5,0);
387 frame_label.set_name ("EditorTimeButton");
388 frame_label.set_size_request (-1, (int)timebar_height);
389 frame_label.set_alignment (1.0, 0.5);
390 frame_label.set_padding (5,0);
391 tempo_label.set_name ("EditorTimeButton");
392 tempo_label.set_size_request (-1, (int)timebar_height);
393 tempo_label.set_alignment (1.0, 0.5);
394 tempo_label.set_padding (5,0);
395 meter_label.set_name ("EditorTimeButton");
396 meter_label.set_size_request (-1, (int)timebar_height);
397 meter_label.set_alignment (1.0, 0.5);
398 meter_label.set_padding (5,0);
399 mark_label.set_name ("EditorTimeButton");
400 mark_label.set_size_request (-1, (int)timebar_height);
401 mark_label.set_alignment (1.0, 0.5);
402 mark_label.set_padding (5,0);
403 range_mark_label.set_name ("EditorTimeButton");
404 range_mark_label.set_size_request (-1, (int)timebar_height);
405 range_mark_label.set_alignment (1.0, 0.5);
406 range_mark_label.set_padding (5,0);
407 transport_mark_label.set_name ("EditorTimeButton");
408 transport_mark_label.set_size_request (-1, (int)timebar_height);
409 transport_mark_label.set_alignment (1.0, 0.5);
410 transport_mark_label.set_padding (5,0);
412 time_button_vbox.pack_start (minsec_label, false, false);
413 time_button_vbox.pack_start (smpte_label, false, false);
414 time_button_vbox.pack_start (frame_label, false, false);
415 time_button_vbox.pack_start (bbt_label, false, false);
416 time_button_vbox.pack_start (meter_label, false, false);
417 time_button_vbox.pack_start (tempo_label, false, false);
418 time_button_vbox.pack_start (mark_label, false, false);
420 time_button_event_box.add (time_button_vbox);
422 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
423 time_button_event_box.set_name ("TimebarLabelBase");
424 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
426 /* these enable us to have a dedicated window (for cursor setting, etc.)
427 for the canvas areas.
430 track_canvas_event_box.add (track_canvas);
432 time_canvas_event_box.add (time_canvas_vbox);
433 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
435 edit_packer.set_col_spacings (0);
436 edit_packer.set_row_spacings (0);
437 edit_packer.set_homogeneous (false);
438 edit_packer.set_border_width (0);
439 edit_packer.set_name ("EditorWindow");
441 edit_packer.attach (edit_vscrollbar, 0, 1, 1, 3, FILL, FILL|EXPAND, 0, 0);
443 edit_packer.attach (time_button_event_box, 1, 2, 0, 1, FILL, FILL, 0, 0);
444 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
446 edit_packer.attach (controls_layout, 1, 2, 1, 2, FILL, FILL|EXPAND, 0, 0);
447 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 2, FILL|EXPAND, FILL|EXPAND, 0, 0);
449 edit_packer.attach (zoom_box, 1, 2, 2, 3, FILL, FILL, 0, 0);
450 edit_packer.attach (edit_hscrollbar, 2, 3, 2, 3, FILL|EXPAND, FILL, 0, 0);
452 bottom_hbox.set_border_width (2);
453 bottom_hbox.set_spacing (3);
455 route_display_model = ListStore::create(route_display_columns);
456 route_list_display.set_model (route_display_model);
457 route_list_display.append_column (_("Show"), route_display_columns.visible);
458 route_list_display.append_column (_("Name"), route_display_columns.text);
459 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
460 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
461 route_list_display.set_headers_visible (true);
462 route_list_display.set_name ("TrackListDisplay");
463 route_list_display.get_selection()->set_mode (SELECTION_NONE);
464 route_list_display.set_reorderable (true);
465 route_list_display.set_size_request (100,-1);
467 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
468 route_list_visible_cell->property_activatable() = true;
469 route_list_visible_cell->property_radio() = false;
471 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
472 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
474 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
476 route_list_scroller.add (route_list_display);
477 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
479 group_model = ListStore::create(group_columns);
480 edit_group_display.set_model (group_model);
481 edit_group_display.append_column (_("Name"), group_columns.text);
482 edit_group_display.append_column (_("Active"), group_columns.is_active);
483 edit_group_display.append_column (_("Show"), group_columns.is_visible);
484 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
485 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
486 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
487 edit_group_display.get_column (0)->set_expand (true);
488 edit_group_display.get_column (1)->set_expand (false);
489 edit_group_display.get_column (2)->set_expand (false);
490 edit_group_display.set_headers_visible (true);
492 /* name is directly editable */
494 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
495 name_cell->property_editable() = true;
496 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
498 /* use checkbox for the active + visible columns */
500 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
501 active_cell->property_activatable() = true;
502 active_cell->property_radio() = false;
504 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
505 active_cell->property_activatable() = true;
506 active_cell->property_radio() = false;
508 edit_group_display.set_name ("EditGroupList");
510 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
512 edit_group_display.set_name ("EditGroupList");
513 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
514 edit_group_display.set_reorderable (false);
515 edit_group_display.set_rules_hint (true);
516 edit_group_display.set_size_request (75, -1);
518 edit_group_display_scroller.add (edit_group_display);
519 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
521 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
523 VBox* edit_group_display_packer = manage (new VBox());
524 HBox* edit_group_display_button_box = manage (new HBox());
525 edit_group_display_button_box->set_homogeneous (true);
527 Button* edit_group_add_button = manage (new Button ());
528 Button* edit_group_remove_button = manage (new Button ());
532 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
534 edit_group_add_button->add (*w);
536 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
538 edit_group_remove_button->add (*w);
540 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
541 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
543 edit_group_display_button_box->pack_start (*edit_group_add_button);
544 edit_group_display_button_box->pack_start (*edit_group_remove_button);
546 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
547 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
549 region_list_display.set_size_request (100, -1);
550 region_list_display.set_name ("RegionListDisplay");
552 region_list_model = TreeStore::create (region_list_columns);
553 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
554 region_list_model->set_sort_column (0, SORT_ASCENDING);
556 region_list_display.set_model (region_list_model);
557 region_list_display.append_column (_("Regions"), region_list_columns.name);
558 region_list_display.set_headers_visible (false);
560 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
562 TreeViewColumn* tv_col = region_list_display.get_column(0);
563 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
564 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
565 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
567 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
568 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
570 /* setup DnD handling */
572 list<TargetEntry> region_list_target_table;
574 region_list_target_table.push_back (TargetEntry ("text/plain"));
575 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
576 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
578 region_list_display.add_drop_targets (region_list_target_table);
579 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
581 region_list_scroller.add (region_list_display);
582 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
584 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
585 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
586 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
587 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
588 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
589 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
591 named_selection_scroller.add (named_selection_display);
592 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
594 named_selection_model = TreeStore::create (named_selection_columns);
595 named_selection_display.set_model (named_selection_model);
596 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
597 named_selection_display.set_headers_visible (false);
598 named_selection_display.set_size_request (100, -1);
599 named_selection_display.set_name ("RegionListDisplay");
601 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
602 named_selection_display.set_size_request (100, -1);
603 named_selection_display.signal_button_release_event().connect (mem_fun(*this, &Editor::named_selection_display_button_press), false);
604 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
608 snapshot_display_model = ListStore::create (snapshot_display_columns);
609 snapshot_display.set_model (snapshot_display_model);
610 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
611 snapshot_display.set_name ("SnapshotDisplayList");
612 snapshot_display.set_size_request (75, -1);
613 snapshot_display.set_headers_visible (false);
614 snapshot_display.set_reorderable (false);
615 snapshot_display_scroller.add (snapshot_display);
616 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
618 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
619 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
623 nlabel = manage (new Label (_("Regions")));
624 nlabel->set_angle (-90);
625 the_notebook.append_page (region_list_scroller, *nlabel);
626 nlabel = manage (new Label (_("Tracks/Busses")));
627 nlabel->set_angle (-90);
628 the_notebook.append_page (route_list_scroller, *nlabel);
629 nlabel = manage (new Label (_("Snapshots")));
630 nlabel->set_angle (-90);
631 the_notebook.append_page (snapshot_display_scroller, *nlabel);
632 nlabel = manage (new Label (_("Edit Groups")));
633 nlabel->set_angle (-90);
634 the_notebook.append_page (*edit_group_display_packer, *nlabel);
635 nlabel = manage (new Label (_("Chunks")));
636 nlabel->set_angle (-90);
637 the_notebook.append_page (named_selection_scroller, *nlabel);
639 the_notebook.set_show_tabs (true);
640 the_notebook.set_scrollable (true);
641 the_notebook.popup_enable ();
642 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
644 post_maximal_editor_width = 0;
645 post_maximal_pane_position = 0;
646 edit_pane.pack1 (edit_packer, true, true);
647 edit_pane.pack2 (the_notebook, false, true);
649 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
651 top_hbox.pack_start (toolbar_frame, true, true);
653 HBox *hbox = manage (new HBox);
654 hbox->pack_start (edit_pane, true, true);
656 global_vpacker.pack_start (top_hbox, false, false);
657 global_vpacker.pack_start (*hbox, true, true);
659 global_hpacker.pack_start (global_vpacker, true, true);
661 set_name ("EditorWindow");
662 add_accel_group (ActionManager::ui_manager->get_accel_group());
664 vpacker.pack_end (global_hpacker, true, true);
666 /* register actions now so that set_state() can find them and set toggles/checks etc */
670 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
673 _playlist_selector = new PlaylistSelector();
674 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
676 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
680 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
681 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
683 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
684 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
686 nudge_forward_button.set_name ("TransportButton");
687 nudge_backward_button.set_name ("TransportButton");
689 fade_context_menu.set_name ("ArdourContextMenu");
691 /* icons, titles, WM stuff */
693 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
694 Glib::RefPtr<Gdk::Pixbuf> icon;
696 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
697 window_icons.push_back (icon);
699 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
700 window_icons.push_back (icon);
702 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
703 window_icons.push_back (icon);
705 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
706 window_icons.push_back (icon);
708 if (!window_icons.empty()) {
709 set_icon_list (window_icons);
710 set_default_icon_list (window_icons);
712 set_title (_("ardour: editor"));
713 set_wmclass (X_("ardour_editor"), "Ardour");
716 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
718 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
719 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
721 /* allow external control surfaces/protocols to do various things */
723 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
724 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
725 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
726 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
728 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
736 /* <CMT Additions> */
737 if(image_socket_listener)
739 if(image_socket_listener->is_connected())
741 image_socket_listener->close_connection() ;
744 delete image_socket_listener ;
745 image_socket_listener = 0 ;
747 /* </CMT Additions> */
751 Editor::add_toplevel_controls (Container& cont)
753 vpacker.pack_start (cont, false, false);
758 Editor::catch_vanishing_regionview (RegionView *rv)
760 /* note: the selection will take care of the vanishing
761 audioregionview by itself.
764 if (clicked_regionview == rv) {
765 clicked_regionview = 0;
768 if (entered_regionview == rv) {
769 set_entered_regionview (0);
774 Editor::set_entered_regionview (RegionView* rv)
776 if (rv == entered_regionview) {
780 if (entered_regionview) {
781 entered_regionview->exited ();
784 if ((entered_regionview = rv) != 0) {
785 entered_regionview->entered ();
790 Editor::set_entered_track (TimeAxisView* tav)
793 entered_track->exited ();
796 if ((entered_track = tav) != 0) {
797 entered_track->entered ();
802 Editor::show_window ()
807 /* now reset all audio_time_axis heights, because widgets might need
813 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
814 tv = (static_cast<TimeAxisView*>(*i));
820 Editor::tie_vertical_scrolling ()
822 double y1 = vertical_adjustment.get_value();
823 controls_layout.get_vadjustment()->set_value (y1);
824 playhead_cursor->set_y_axis(y1);
825 edit_cursor->set_y_axis(y1);
829 Editor::set_frames_per_unit (double fpu)
833 if (fpu == frames_per_unit) {
841 // convert fpu to frame count
843 frames = (nframes_t) floor (fpu * canvas_width);
845 /* don't allow zooms that fit more than the maximum number
846 of frames into an 800 pixel wide space.
849 if (max_frames / fpu < 800.0) {
853 if (fpu == frames_per_unit) {
857 frames_per_unit = fpu;
859 if (frames != zoom_range_clock.current_duration()) {
860 zoom_range_clock.set (frames);
863 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
864 if (!selection->tracks.empty()) {
865 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
866 (*i)->reshow_selection (selection->time);
869 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
870 (*i)->reshow_selection (selection->time);
875 ZoomChanged (); /* EMIT_SIGNAL */
877 reset_hscrollbar_stepping ();
878 reset_scrolling_region ();
880 if (edit_cursor) edit_cursor->set_position (edit_cursor->current_frame);
881 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
888 Editor::instant_save ()
890 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
895 session->add_instant_xml(get_state(), session->path());
897 Config->add_instant_xml(get_state(), get_user_ardour_path());
902 Editor::reposition_x_origin (nframes_t frame)
904 if (frame != leftmost_frame) {
905 leftmost_frame = frame;
907 nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
909 if (rightmost_frame > last_canvas_frame) {
910 last_canvas_frame = rightmost_frame;
911 reset_scrolling_region ();
914 horizontal_adjustment.set_value (frame/frames_per_unit);
916 update_fixed_rulers();
917 tempo_map_changed (Change (0));
922 Editor::edit_cursor_clock_changed()
924 if (edit_cursor->current_frame != edit_cursor_clock.current_time()) {
925 edit_cursor->set_position (edit_cursor_clock.current_time());
931 Editor::zoom_adjustment_changed ()
937 double fpu = zoom_range_clock.current_duration() / canvas_width;
941 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
942 } else if (fpu > session->current_end_frame() / canvas_width) {
943 fpu = session->current_end_frame() / canvas_width;
944 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
951 Editor::control_scroll (float fraction)
953 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
959 double step = fraction * current_page_frames();
962 if ((fraction < 0.0f) && (session->transport_frame() < (nframes_t) fabs(step))) {
964 } else if ((fraction > 0.0f) && (max_frames - session->transport_frame() < step)) {
965 target = (max_frames - (current_page_frames()*2)); // allow room for slop in where the PH is on the screen
967 target = (session->transport_frame() + (nframes_t) floor ((fraction * current_page_frames())));
970 /* move visuals, we'll catch up with it later */
972 playhead_cursor->set_position (target);
974 if (target > (current_page_frames() / 2)) {
975 /* try to center PH in window */
976 reposition_x_origin (target - (current_page_frames()/2));
978 reposition_x_origin (0);
981 /* cancel the existing */
983 control_scroll_connection.disconnect ();
985 /* add the next one */
987 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), target), 50);
991 Editor::deferred_control_scroll (nframes_t target)
993 session->request_locate (target);
998 Editor::canvas_horizontally_scrolled ()
1001 leftmost_frame = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
1002 update_fixed_rulers ();
1003 tempo_map_changed (Change (0));
1008 Editor::reposition_and_zoom (nframes_t frame, double nfpu)
1010 if (!repos_zoom_queued) {
1011 repos_zoom_queued = true;
1012 Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::deferred_reposition_and_zoom), frame, nfpu));
1017 Editor::deferred_reposition_and_zoom (nframes_t frame, double nfpu)
1020 set_frames_per_unit (nfpu);
1021 reposition_x_origin (frame);
1022 repos_zoom_queued = false;
1028 Editor::on_realize ()
1030 Window::on_realize ();
1035 Editor::start_scrolling ()
1037 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1038 (mem_fun(*this, &Editor::update_current_screen));
1042 Editor::stop_scrolling ()
1044 scroll_connection.disconnect ();
1048 Editor::map_position_change (nframes_t frame)
1050 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1052 if (session == 0 || !_follow_playhead) {
1056 center_screen (frame);
1057 playhead_cursor->set_position (frame);
1061 Editor::center_screen (nframes_t frame)
1063 double page = canvas_width * frames_per_unit;
1065 /* if we're off the page, then scroll.
1068 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1069 center_screen_internal (frame, page);
1074 Editor::center_screen_internal (nframes_t frame, float page)
1079 frame -= (nframes_t) page;
1084 reposition_x_origin (frame);
1088 Editor::handle_new_duration ()
1090 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1092 nframes_t new_end = session->get_maximum_extent() + (nframes_t) floorf (current_page_frames() * 0.10f);
1094 if (new_end > last_canvas_frame) {
1095 last_canvas_frame = new_end;
1096 reset_scrolling_region ();
1099 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1103 Editor::update_title_s (const string & snap_name)
1105 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1111 Editor::update_title ()
1113 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1116 bool dirty = session->dirty();
1118 string wintitle = _("ardour: editor: ");
1124 wintitle += session->name();
1126 if (session->snap_name() != session->name()) {
1128 wintitle += session->snap_name();
1135 set_title (wintitle);
1140 Editor::connect_to_session (Session *t)
1144 if (first_action_message) {
1145 first_action_message->hide();
1150 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1151 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1153 /* These signals can all be emitted by a non-GUI thread. Therefore the
1154 handlers for them must not attempt to directly interact with the GUI,
1155 but use Gtkmm2ext::UI::instance()->call_slot();
1158 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1159 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1160 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1161 session_connections.push_back (session->RegionAdded.connect (mem_fun(*this, &Editor::handle_new_region)));
1162 session_connections.push_back (session->RegionRemoved.connect (mem_fun(*this, &Editor::handle_region_removed)));
1163 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1164 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1165 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1166 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1167 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1168 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1169 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1170 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1171 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1173 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1175 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1177 edit_groups_changed ();
1179 edit_cursor_clock.set_session (session);
1180 zoom_range_clock.set_session (session);
1181 _playlist_selector->set_session (session);
1182 nudge_clock.set_session (session);
1185 if (analysis_window != 0)
1186 analysis_window->set_session (session);
1189 Location* loc = session->locations()->auto_loop_location();
1191 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1192 if (loc->start() == loc->end()) {
1193 loc->set_end (loc->start() + 1);
1195 session->locations()->add (loc, false);
1196 session->set_auto_loop_location (loc);
1200 loc->set_name (_("Loop"));
1203 loc = session->locations()->auto_punch_location();
1205 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1206 if (loc->start() == loc->end()) {
1207 loc->set_end (loc->start() + 1);
1209 session->locations()->add (loc, false);
1210 session->set_auto_punch_location (loc);
1214 loc->set_name (_("Punch"));
1217 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1219 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1221 refresh_location_display ();
1222 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1223 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1224 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1225 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1226 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1228 handle_new_duration ();
1230 redisplay_regions ();
1231 redisplay_named_selections ();
1232 redisplay_snapshots ();
1234 initial_route_list_display ();
1236 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1237 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1240 /* ::reposition_x_origin() doesn't work right here, since the old
1241 position may be zero already, and it does nothing in such
1247 horizontal_adjustment.set_value (0);
1249 restore_ruler_visibility ();
1250 //tempo_map_changed (Change (0));
1251 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1253 edit_cursor->set_position (0);
1254 playhead_cursor->set_position (0);
1258 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1261 /* don't show master bus in a new session */
1263 if (ARDOUR_UI::instance()->session_is_new ()) {
1265 TreeModel::Children rows = route_display_model->children();
1266 TreeModel::Children::iterator i;
1268 no_route_list_redisplay = true;
1270 for (i = rows.begin(); i != rows.end(); ++i) {
1271 TimeAxisView *tv = (*i)[route_display_columns.tv];
1272 RouteTimeAxisView *rtv;
1274 if ((rtv = dynamic_cast<RouteTimeAxisView*>(tv)) != 0) {
1275 if (rtv->route()->master()) {
1276 route_list_display.get_selection()->unselect (i);
1281 no_route_list_redisplay = false;
1282 redisplay_route_list ();
1285 /* register for undo history */
1287 session->register_with_memento_command_factory(_id, this);
1291 Editor::build_cursors ()
1293 using namespace Gdk;
1295 Gdk::Color mbg ("#000000" ); /* Black */
1296 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1299 RefPtr<Bitmap> source, mask;
1300 source = Bitmap::create (mag_bits, mag_width, mag_height);
1301 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1302 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1305 Gdk::Color fbg ("#ffffff" );
1306 Gdk::Color ffg ("#000000" );
1309 RefPtr<Bitmap> source, mask;
1311 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1312 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1313 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1317 RefPtr<Bitmap> source, mask;
1318 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1319 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1320 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1323 grabber_cursor = new Gdk::Cursor (HAND2);
1324 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1325 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1326 selector_cursor = new Gdk::Cursor (XTERM);
1327 time_fx_cursor = new Gdk::Cursor (SIZING);
1328 wait_cursor = new Gdk::Cursor (WATCH);
1329 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1333 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1335 using namespace Menu_Helpers;
1336 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1339 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1343 MenuList& items (fade_context_menu.items());
1347 switch (item_type) {
1349 case FadeInHandleItem:
1350 if (arv->audio_region()->fade_in_active()) {
1351 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), false)));
1353 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), true)));
1356 items.push_back (SeparatorElem());
1358 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::Linear)));
1359 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::LogB)));
1360 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::Fast)));
1361 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::LogA)));
1362 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_shape), AudioRegion::Slow)));
1366 case FadeOutHandleItem:
1367 if (arv->audio_region()->fade_out_active()) {
1368 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), false)));
1370 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), true)));
1373 items.push_back (SeparatorElem());
1375 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::Linear)));
1376 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::Fast)));
1377 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::LogB)));
1378 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::LogA)));
1379 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_shape), AudioRegion::Slow)));
1384 fatal << _("programming error: ")
1385 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1390 fade_context_menu.popup (button, time);
1394 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes_t frame)
1396 using namespace Menu_Helpers;
1397 Menu* (Editor::*build_menu_function)(nframes_t);
1400 switch (item_type) {
1402 case RegionViewName:
1403 case RegionViewNameHighlight:
1404 if (with_selection) {
1405 build_menu_function = &Editor::build_track_selection_context_menu;
1407 build_menu_function = &Editor::build_track_region_context_menu;
1412 if (with_selection) {
1413 build_menu_function = &Editor::build_track_selection_context_menu;
1415 build_menu_function = &Editor::build_track_context_menu;
1419 case CrossfadeViewItem:
1420 build_menu_function = &Editor::build_track_crossfade_context_menu;
1424 if (clicked_routeview->is_track()) {
1425 build_menu_function = &Editor::build_track_context_menu;
1427 build_menu_function = &Editor::build_track_bus_context_menu;
1432 /* probably shouldn't happen but if it does, we don't care */
1436 menu = (this->*build_menu_function)(frame);
1437 menu->set_name ("ArdourContextMenu");
1439 /* now handle specific situations */
1441 switch (item_type) {
1443 case RegionViewName:
1444 case RegionViewNameHighlight:
1445 if (!with_selection) {
1446 if (region_edit_menu_split_item) {
1447 if (clicked_regionview && clicked_regionview->region()->covers (edit_cursor->current_frame)) {
1448 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
1450 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
1454 if (region_edit_menu_split_multichannel_item) {
1455 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1456 // GTK2FIX find the action, change its sensitivity
1457 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1459 // GTK2FIX see above
1460 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1469 case CrossfadeViewItem:
1476 /* probably shouldn't happen but if it does, we don't care */
1480 if (clicked_routeview && clicked_routeview->audio_track()) {
1482 /* Bounce to disk */
1484 using namespace Menu_Helpers;
1485 MenuList& edit_items = menu->items();
1487 edit_items.push_back (SeparatorElem());
1489 switch (clicked_routeview->audio_track()->freeze_state()) {
1490 case AudioTrack::NoFreeze:
1491 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1494 case AudioTrack::Frozen:
1495 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1498 case AudioTrack::UnFrozen:
1499 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1505 menu->popup (button, time);
1509 Editor::build_track_context_menu (nframes_t ignored)
1511 using namespace Menu_Helpers;
1513 MenuList& edit_items = track_context_menu.items();
1516 add_dstream_context_items (edit_items);
1517 return &track_context_menu;
1521 Editor::build_track_bus_context_menu (nframes_t ignored)
1523 using namespace Menu_Helpers;
1525 MenuList& edit_items = track_context_menu.items();
1528 add_bus_context_items (edit_items);
1529 return &track_context_menu;
1533 Editor::build_track_region_context_menu (nframes_t frame)
1535 using namespace Menu_Helpers;
1536 MenuList& edit_items = track_region_context_menu.items();
1539 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_axisview);
1542 boost::shared_ptr<Diskstream> ds;
1543 boost::shared_ptr<Playlist> pl;
1545 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1546 Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)frame * ds->speed()));
1547 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1548 add_region_context_items (atv->audio_view(), (*i), edit_items);
1554 add_dstream_context_items (edit_items);
1556 return &track_region_context_menu;
1560 Editor::build_track_crossfade_context_menu (nframes_t frame)
1562 using namespace Menu_Helpers;
1563 MenuList& edit_items = track_crossfade_context_menu.items();
1564 edit_items.clear ();
1566 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_axisview);
1569 boost::shared_ptr<Diskstream> ds;
1570 boost::shared_ptr<Playlist> pl;
1571 boost::shared_ptr<AudioPlaylist> apl;
1573 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1575 Playlist::RegionList* regions = pl->regions_at (frame);
1576 AudioPlaylist::Crossfades xfades;
1578 apl->crossfades_at (frame, xfades);
1580 bool many = xfades.size() > 1;
1582 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1583 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1586 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1587 add_region_context_items (atv->audio_view(), (*i), edit_items);
1594 add_dstream_context_items (edit_items);
1596 return &track_crossfade_context_menu;
1601 Editor::analyze_region_selection()
1603 if (analysis_window == 0) {
1604 analysis_window = new AnalysisWindow();
1607 analysis_window->set_session(session);
1609 analysis_window->show_all();
1612 analysis_window->set_regionmode();
1613 analysis_window->analyze();
1615 analysis_window->present();
1619 Editor::analyze_range_selection()
1621 if (analysis_window == 0) {
1622 analysis_window = new AnalysisWindow();
1625 analysis_window->set_session(session);
1627 analysis_window->show_all();
1630 analysis_window->set_rangemode();
1631 analysis_window->analyze();
1633 analysis_window->present();
1635 #endif /* FFT_ANALYSIS */
1640 Editor::build_track_selection_context_menu (nframes_t ignored)
1642 using namespace Menu_Helpers;
1643 MenuList& edit_items = track_selection_context_menu.items();
1644 edit_items.clear ();
1646 add_selection_context_items (edit_items);
1647 add_dstream_context_items (edit_items);
1649 return &track_selection_context_menu;
1653 Editor::add_crossfade_context_items (AudioStreamView* view, Crossfade* xfade, Menu_Helpers::MenuList& edit_items, bool many)
1655 using namespace Menu_Helpers;
1656 Menu *xfade_menu = manage (new Menu);
1657 MenuList& items = xfade_menu->items();
1658 xfade_menu->set_name ("ArdourContextMenu");
1661 if (xfade->active()) {
1667 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), xfade)));
1668 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), xfade)));
1670 if (xfade->can_follow_overlap()) {
1672 if (xfade->following_overlap()) {
1673 str = _("Convert to short");
1675 str = _("Convert to full");
1678 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1682 str = xfade->out()->name();
1684 str += xfade->in()->name();
1686 str = _("Crossfade");
1689 edit_items.push_back (MenuElem (str, *xfade_menu));
1690 edit_items.push_back (SeparatorElem());
1694 Editor::xfade_edit_left_region ()
1696 if (clicked_crossfadeview) {
1697 clicked_crossfadeview->left_view.show_region_editor ();
1702 Editor::xfade_edit_right_region ()
1704 if (clicked_crossfadeview) {
1705 clicked_crossfadeview->right_view.show_region_editor ();
1710 Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1712 using namespace Menu_Helpers;
1713 Menu *region_menu = manage (new Menu);
1714 MenuList& items = region_menu->items();
1715 region_menu->set_name ("ArdourContextMenu");
1717 boost::shared_ptr<AudioRegion> ar;
1720 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1723 /* when this particular menu pops up, make the relevant region
1727 // region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1729 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1730 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1731 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1732 items.push_back (SeparatorElem());
1733 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_cursor)));
1734 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1735 items.push_back (SeparatorElem());
1737 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::audition_selected_region)));
1738 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1739 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1742 items.push_back (MenuElem (_("Analyze region"), mem_fun(*this, &Editor::analyze_region_selection)));
1745 items.push_back (SeparatorElem());
1747 items.push_back (CheckMenuElem (_("Lock"), mem_fun(*this, &Editor::toggle_region_lock)));
1748 region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1749 if (region->locked()) {
1750 region_lock_item->set_active();
1752 items.push_back (CheckMenuElem (_("Mute"), mem_fun(*this, &Editor::toggle_region_mute)));
1753 region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1754 if (region->muted()) {
1755 region_mute_item->set_active();
1757 items.push_back (CheckMenuElem (_("Opaque"), mem_fun(*this, &Editor::toggle_region_opaque)));
1758 region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1759 if (region->opaque()) {
1760 region_opaque_item->set_active();
1763 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1764 if (region->at_natural_position()) {
1765 items.back().set_sensitive (false);
1768 items.push_back (SeparatorElem());
1772 RegionView* rv = sv->find_view (ar);
1773 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1775 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
1777 items.push_back (CheckMenuElem (_("Envelope Visible"), mem_fun(*this, &Editor::toggle_gain_envelope_visibility)));
1778 region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1780 if (arv->envelope_visible()) {
1781 region_envelope_visible_item->set_active (true);
1784 items.push_back (CheckMenuElem (_("Envelope Active"), mem_fun(*this, &Editor::toggle_gain_envelope_active)));
1785 region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1787 if (ar->envelope_active()) {
1788 region_envelope_active_item->set_active (true);
1791 items.push_back (SeparatorElem());
1793 if (ar->scale_amplitude() != 1.0f) {
1794 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1796 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1799 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1800 items.push_back (SeparatorElem());
1803 /* range related stuff */
1805 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1806 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_audio_region)));
1807 items.push_back (SeparatorElem());
1811 Menu *nudge_menu = manage (new Menu());
1812 MenuList& nudge_items = nudge_menu->items();
1813 nudge_menu->set_name ("ArdourContextMenu");
1815 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1816 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1817 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1818 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1820 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1821 items.push_back (SeparatorElem());
1823 Menu *trim_menu = manage (new Menu);
1824 MenuList& trim_items = trim_menu->items();
1825 trim_menu->set_name ("ArdourContextMenu");
1827 trim_items.push_back (MenuElem (_("Start to edit cursor"), mem_fun(*this, &Editor::trim_region_from_edit_cursor)));
1828 trim_items.push_back (MenuElem (_("Edit cursor to end"), mem_fun(*this, &Editor::trim_region_to_edit_cursor)));
1830 items.push_back (MenuElem (_("Trim"), *trim_menu));
1831 items.push_back (SeparatorElem());
1833 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1834 region_edit_menu_split_item = &items.back();
1836 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1837 region_edit_menu_split_multichannel_item = &items.back();
1839 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1840 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1841 items.push_back (SeparatorElem());
1842 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1844 /* OK, stick the region submenu at the top of the list, and then add
1848 /* we have to hack up the region name because "_" has a special
1849 meaning for menu titles.
1852 string::size_type pos = 0;
1853 string menu_item_name = region->name();
1855 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1856 menu_item_name.replace (pos, 1, "__");
1860 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1861 edit_items.push_back (SeparatorElem());
1865 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1867 using namespace Menu_Helpers;
1868 Menu *selection_menu = manage (new Menu);
1869 MenuList& items = selection_menu->items();
1870 selection_menu->set_name ("ArdourContextMenu");
1872 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1873 items.push_back (MenuElem (_("Loop range"), mem_fun(*this, &Editor::set_route_loop_selection)));
1876 items.push_back (SeparatorElem());
1877 items.push_back (MenuElem (_("Analyze range"), mem_fun(*this, &Editor::analyze_range_selection)));
1880 items.push_back (SeparatorElem());
1881 items.push_back (MenuElem (_("Separate range to track"), mem_fun(*this, &Editor::separate_region_from_selection)));
1882 items.push_back (MenuElem (_("Separate range to region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1884 items.push_back (SeparatorElem());
1885 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1886 items.push_back (SeparatorElem());
1887 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
1888 items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1889 items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1890 items.push_back (SeparatorElem());
1891 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1892 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1893 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1894 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::name_selection)));
1895 items.push_back (SeparatorElem());
1896 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1897 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1899 edit_items.push_back (MenuElem (_("Range"), *selection_menu));
1900 edit_items.push_back (SeparatorElem());
1904 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1906 using namespace Menu_Helpers;
1910 Menu *play_menu = manage (new Menu);
1911 MenuList& play_items = play_menu->items();
1912 play_menu->set_name ("ArdourContextMenu");
1914 play_items.push_back (MenuElem (_("Play from edit cursor"), mem_fun(*this, &Editor::play_from_edit_cursor)));
1915 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1916 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1917 play_items.push_back (SeparatorElem());
1918 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1920 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1924 Menu *select_menu = manage (new Menu);
1925 MenuList& select_items = select_menu->items();
1926 select_menu->set_name ("ArdourContextMenu");
1928 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1929 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1930 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1931 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1932 select_items.push_back (SeparatorElem());
1933 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1934 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1935 select_items.push_back (SeparatorElem());
1936 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1937 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1938 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1939 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1940 select_items.push_back (MenuElem (_("Select all between cursors"), bind (mem_fun(*this, &Editor::select_all_selectables_between_cursors), playhead_cursor, edit_cursor)));
1941 select_items.push_back (SeparatorElem());
1943 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1947 Menu *cutnpaste_menu = manage (new Menu);
1948 MenuList& cutnpaste_items = cutnpaste_menu->items();
1949 cutnpaste_menu->set_name ("ArdourContextMenu");
1951 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1952 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1953 cutnpaste_items.push_back (MenuElem (_("Paste at edit cursor"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1954 cutnpaste_items.push_back (MenuElem (_("Paste at mouse"), mem_fun(*this, &Editor::mouse_paste)));
1956 cutnpaste_items.push_back (SeparatorElem());
1958 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1959 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
1961 cutnpaste_items.push_back (SeparatorElem());
1963 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
1965 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
1967 /* Adding new material */
1969 edit_items.push_back (SeparatorElem());
1970 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
1971 edit_items.push_back (MenuElem (_("Insert Existing Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
1975 Menu *nudge_menu = manage (new Menu());
1976 MenuList& nudge_items = nudge_menu->items();
1977 nudge_menu->set_name ("ArdourContextMenu");
1979 edit_items.push_back (SeparatorElem());
1980 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1981 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1982 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1983 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1985 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1989 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
1991 using namespace Menu_Helpers;
1995 Menu *play_menu = manage (new Menu);
1996 MenuList& play_items = play_menu->items();
1997 play_menu->set_name ("ArdourContextMenu");
1999 play_items.push_back (MenuElem (_("Play from edit cursor"), mem_fun(*this, &Editor::play_from_edit_cursor)));
2000 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2001 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2005 Menu *select_menu = manage (new Menu);
2006 MenuList& select_items = select_menu->items();
2007 select_menu->set_name ("ArdourContextMenu");
2009 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2010 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2011 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2012 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2013 select_items.push_back (SeparatorElem());
2014 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
2015 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
2016 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2017 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2019 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2023 Menu *cutnpaste_menu = manage (new Menu);
2024 MenuList& cutnpaste_items = cutnpaste_menu->items();
2025 cutnpaste_menu->set_name ("ArdourContextMenu");
2027 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2028 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2029 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2031 Menu *nudge_menu = manage (new Menu());
2032 MenuList& nudge_items = nudge_menu->items();
2033 nudge_menu->set_name ("ArdourContextMenu");
2035 edit_items.push_back (SeparatorElem());
2036 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2037 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2038 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2039 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2041 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2044 /* CURSOR SETTING AND MARKS AND STUFF */
2047 Editor::set_snap_to (SnapType st)
2050 string str = snap_type_strings[(int) st];
2052 if (str != snap_type_selector.get_active_text()) {
2053 snap_type_selector.set_active_text (str);
2058 switch (snap_type) {
2059 case SnapToAThirtysecondBeat:
2060 case SnapToASixteenthBeat:
2061 case SnapToAEighthBeat:
2062 case SnapToAQuarterBeat:
2063 case SnapToAThirdBeat:
2064 update_tempo_based_rulers ();
2072 Editor::set_snap_mode (SnapMode mode)
2075 string str = snap_mode_strings[(int)mode];
2077 if (str != snap_mode_selector.get_active_text ()) {
2078 snap_mode_selector.set_active_text (str);
2085 Editor::set_state (const XMLNode& node)
2087 const XMLProperty* prop;
2089 int x, y, xoff, yoff;
2092 if ((prop = node.property ("id")) != 0) {
2093 _id = prop->value ();
2096 if ((geometry = find_named_node (node, "geometry")) == 0) {
2098 g.base_width = default_width;
2099 g.base_height = default_height;
2107 g.base_width = atoi(geometry->property("x_size")->value());
2108 g.base_height = atoi(geometry->property("y_size")->value());
2109 x = atoi(geometry->property("x_pos")->value());
2110 y = atoi(geometry->property("y_pos")->value());
2111 xoff = atoi(geometry->property("x_off")->value());
2112 yoff = atoi(geometry->property("y_off")->value());
2115 set_default_size (g.base_width, g.base_height);
2118 if ((prop = node.property ("zoom-focus"))) {
2119 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2122 if ((prop = node.property ("zoom"))) {
2123 set_frames_per_unit (PBD::atof (prop->value()));
2126 if ((prop = node.property ("snap-to"))) {
2127 set_snap_to ((SnapType) atoi (prop->value()));
2130 if ((prop = node.property ("snap-mode"))) {
2131 set_snap_mode ((SnapMode) atoi (prop->value()));
2134 if ((prop = node.property ("mouse-mode"))) {
2135 MouseMode m = str2mousemode(prop->value());
2136 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2137 set_mouse_mode (m, true);
2139 mouse_mode = MouseGain; /* lie, to force the mode switch */
2140 set_mouse_mode (MouseObject, true);
2143 if ((prop = node.property ("show-waveforms"))) {
2144 bool yn = (prop->value() == "yes");
2145 _show_waveforms = !yn;
2146 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
2148 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2149 /* do it twice to force the change */
2150 tact->set_active (!yn);
2151 tact->set_active (yn);
2155 if ((prop = node.property ("show-waveforms-recording"))) {
2156 bool yn = (prop->value() == "yes");
2157 _show_waveforms_recording = !yn;
2158 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2160 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2161 /* do it twice to force the change */
2162 tact->set_active (!yn);
2163 tact->set_active (yn);
2167 if ((prop = node.property ("show-measures"))) {
2168 bool yn = (prop->value() == "yes");
2169 _show_measures = !yn;
2170 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2172 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2173 /* do it twice to force the change */
2174 tact->set_active (!yn);
2175 tact->set_active (yn);
2179 if ((prop = node.property ("follow-playhead"))) {
2180 bool yn = (prop->value() == "yes");
2181 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
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);
2191 if ((prop = node.property ("region-list-sort-type"))) {
2192 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2193 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2196 if ((prop = node.property ("xfades-visible"))) {
2197 bool yn = (prop->value() == "yes");
2198 _xfade_visibility = !yn;
2199 // set_xfade_visibility (yn);
2202 if ((prop = node.property ("show-editor-mixer"))) {
2204 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2207 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2208 bool yn = (prop->value() == X_("yes"));
2210 /* do it twice to force the change */
2212 tact->set_active (!yn);
2213 tact->set_active (yn);
2222 Editor::get_state ()
2224 XMLNode* node = new XMLNode ("Editor");
2227 _id.print (buf, sizeof (buf));
2228 node->add_property ("id", buf);
2230 if (is_realized()) {
2231 Glib::RefPtr<Gdk::Window> win = get_window();
2233 int x, y, xoff, yoff, width, height;
2234 win->get_root_origin(x, y);
2235 win->get_position(xoff, yoff);
2236 win->get_size(width, height);
2238 XMLNode* geometry = new XMLNode ("geometry");
2240 snprintf(buf, sizeof(buf), "%d", width);
2241 geometry->add_property("x_size", string(buf));
2242 snprintf(buf, sizeof(buf), "%d", height);
2243 geometry->add_property("y_size", string(buf));
2244 snprintf(buf, sizeof(buf), "%d", x);
2245 geometry->add_property("x_pos", string(buf));
2246 snprintf(buf, sizeof(buf), "%d", y);
2247 geometry->add_property("y_pos", string(buf));
2248 snprintf(buf, sizeof(buf), "%d", xoff);
2249 geometry->add_property("x_off", string(buf));
2250 snprintf(buf, sizeof(buf), "%d", yoff);
2251 geometry->add_property("y_off", string(buf));
2252 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2253 geometry->add_property("edit_pane_pos", string(buf));
2255 node->add_child_nocopy (*geometry);
2258 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2259 node->add_property ("zoom-focus", buf);
2260 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2261 node->add_property ("zoom", buf);
2262 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2263 node->add_property ("snap-to", buf);
2264 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2265 node->add_property ("snap-mode", buf);
2267 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2268 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2269 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2270 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2271 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2272 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2273 node->add_property ("mouse-mode", enum2str(mouse_mode));
2275 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2277 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2278 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2287 Editor::trackview_by_y_position (double y)
2289 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2293 if ((tv = (*iter)->covers_y_position (y)) != 0) {
2302 Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark)
2304 Location* before = 0;
2305 Location* after = 0;
2311 const nframes_t one_second = session->frame_rate();
2312 const nframes_t one_minute = session->frame_rate() * 60;
2313 const nframes_t one_smpte_second = (nframes_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
2314 nframes_t one_smpte_minute = (nframes_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
2315 nframes_t presnap = start;
2317 switch (snap_type) {
2323 start = (nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2325 start = (nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2329 case SnapToSMPTEFrame:
2330 if (fmod((double)start, (double)session->frames_per_smpte_frame()) > (session->frames_per_smpte_frame() / 2)) {
2331 start = (nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2333 start = (nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2337 case SnapToSMPTESeconds:
2338 if (session->smpte_offset_negative())
2340 start += session->smpte_offset ();
2342 start -= session->smpte_offset ();
2344 if (start % one_smpte_second > one_smpte_second / 2) {
2345 start = (nframes_t) ceil ((double) start / one_smpte_second) * one_smpte_second;
2347 start = (nframes_t) floor ((double) start / one_smpte_second) * one_smpte_second;
2350 if (session->smpte_offset_negative())
2352 start -= session->smpte_offset ();
2354 start += session->smpte_offset ();
2358 case SnapToSMPTEMinutes:
2359 if (session->smpte_offset_negative())
2361 start += session->smpte_offset ();
2363 start -= session->smpte_offset ();
2365 if (start % one_smpte_minute > one_smpte_minute / 2) {
2366 start = (nframes_t) ceil ((double) start / one_smpte_minute) * one_smpte_minute;
2368 start = (nframes_t) floor ((double) start / one_smpte_minute) * one_smpte_minute;
2370 if (session->smpte_offset_negative())
2372 start -= session->smpte_offset ();
2374 start += session->smpte_offset ();
2379 if (start % one_second > one_second / 2) {
2380 start = (nframes_t) ceil ((double) start / one_second) * one_second;
2382 start = (nframes_t) floor ((double) start / one_second) * one_second;
2387 if (start % one_minute > one_minute / 2) {
2388 start = (nframes_t) ceil ((double) start / one_minute) * one_minute;
2390 start = (nframes_t) floor ((double) start / one_minute) * one_minute;
2395 start = session->tempo_map().round_to_bar (start, direction);
2399 start = session->tempo_map().round_to_beat (start, direction);
2402 case SnapToAThirtysecondBeat:
2403 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2406 case SnapToASixteenthBeat:
2407 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2410 case SnapToAEighthBeat:
2411 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2414 case SnapToAQuarterBeat:
2415 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2418 case SnapToAThirdBeat:
2419 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2422 case SnapToEditCursor:
2423 start = edit_cursor->current_frame;
2431 before = session->locations()->first_location_before (start);
2432 after = session->locations()->first_location_after (start);
2434 if (direction < 0) {
2436 start = before->start();
2440 } else if (direction > 0) {
2442 start = after->start();
2444 start = session->current_end_frame();
2449 /* find nearest of the two */
2450 if ((start - before->start()) < (after->start() - start)) {
2451 start = before->start();
2453 start = after->start();
2456 start = before->start();
2459 start = after->start();
2466 case SnapToRegionStart:
2467 case SnapToRegionEnd:
2468 case SnapToRegionSync:
2469 case SnapToRegionBoundary:
2470 if (!region_boundary_cache.empty()) {
2471 vector<nframes_t>::iterator i;
2473 if (direction > 0) {
2474 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2476 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2479 if (i != region_boundary_cache.end()) {
2482 start = region_boundary_cache.back();
2488 switch (snap_mode) {
2494 if (presnap > start) {
2495 if (presnap > (start + unit_to_frame(snap_threshold))) {
2499 } else if (presnap < start) {
2500 if (presnap < (start - unit_to_frame(snap_threshold))) {
2512 Editor::setup_toolbar ()
2516 const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
2519 /* Mode Buttons (tool selection) */
2521 vector<ToggleButton *> mouse_mode_buttons;
2523 mouse_move_button.add (*(manage (new Image (::get_icon("tool_object")))));
2524 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2525 mouse_mode_buttons.push_back (&mouse_move_button);
2526 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2527 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2528 mouse_mode_buttons.push_back (&mouse_select_button);
2529 mouse_gain_button.add (*(manage (new Image (::get_icon("tool_gain")))));
2530 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2531 mouse_mode_buttons.push_back (&mouse_gain_button);
2532 mouse_zoom_button.add (*(manage (new Image (::get_icon("tool_zoom")))));
2533 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2534 mouse_mode_buttons.push_back (&mouse_zoom_button);
2535 mouse_timefx_button.add (*(manage (new Image (::get_icon("tool_stretch")))));
2536 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2537 mouse_mode_buttons.push_back (&mouse_timefx_button);
2538 mouse_audition_button.add (*(manage (new Image (::get_icon("tool_audition")))));
2539 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2540 mouse_mode_buttons.push_back (&mouse_audition_button);
2542 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2544 HBox* mode_box = manage(new HBox);
2545 mode_box->set_border_width (2);
2546 mode_box->set_spacing(4);
2547 mouse_mode_button_box.set_spacing(1);
2548 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2549 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2550 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2551 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2552 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2553 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2554 mouse_mode_button_box.set_homogeneous(true);
2556 vector<string> edit_mode_strings;
2557 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2558 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2560 edit_mode_selector.set_name ("EditModeSelector");
2561 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, longest (edit_mode_strings).c_str(), 2+FUDGE, 10);
2562 set_popdown_strings (edit_mode_selector, edit_mode_strings);
2563 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2565 mode_box->pack_start(edit_mode_selector);
2566 mode_box->pack_start(mouse_mode_button_box);
2568 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2569 mouse_mode_tearoff->set_name ("MouseModeBase");
2571 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2572 &mouse_mode_tearoff->tearoff_window()));
2573 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2574 &mouse_mode_tearoff->tearoff_window(), 1));
2575 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2576 &mouse_mode_tearoff->tearoff_window()));
2577 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2578 &mouse_mode_tearoff->tearoff_window(), 1));
2580 mouse_move_button.set_name ("MouseModeButton");
2581 mouse_select_button.set_name ("MouseModeButton");
2582 mouse_gain_button.set_name ("MouseModeButton");
2583 mouse_zoom_button.set_name ("MouseModeButton");
2584 mouse_timefx_button.set_name ("MouseModeButton");
2585 mouse_audition_button.set_name ("MouseModeButton");
2587 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
2588 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
2589 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
2590 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
2591 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
2592 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
2594 mouse_move_button.unset_flags (CAN_FOCUS);
2595 mouse_select_button.unset_flags (CAN_FOCUS);
2596 mouse_gain_button.unset_flags (CAN_FOCUS);
2597 mouse_zoom_button.unset_flags (CAN_FOCUS);
2598 mouse_timefx_button.unset_flags (CAN_FOCUS);
2599 mouse_audition_button.unset_flags (CAN_FOCUS);
2601 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2602 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2604 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2605 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2606 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2607 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2608 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2610 // mouse_move_button.set_active (true);
2615 zoom_box.set_spacing (1);
2616 zoom_box.set_border_width (2);
2618 zoom_in_button.set_name ("EditorTimeButton");
2619 zoom_in_button.set_size_request(-1,16);
2620 zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in")))));
2621 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2622 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2624 zoom_out_button.set_name ("EditorTimeButton");
2625 zoom_out_button.set_size_request(-1,16);
2626 zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out")))));
2627 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2628 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2630 zoom_out_full_button.set_name ("EditorTimeButton");
2631 zoom_out_full_button.set_size_request(-1,16);
2632 zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full")))));
2633 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2634 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2636 zoom_focus_selector.set_name ("ZoomFocusSelector");
2637 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Edit Cursor", FUDGE, 0);
2638 set_popdown_strings (zoom_focus_selector, zoom_focus_strings);
2639 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2640 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
2642 zoom_box.pack_start (zoom_focus_selector, true, true);
2643 zoom_box.pack_start (zoom_out_button, false, false);
2644 zoom_box.pack_start (zoom_in_button, false, false);
2645 zoom_box.pack_start (zoom_out_full_button, false, false);
2647 /* Edit Cursor / Snap */
2649 snap_box.set_spacing (1);
2650 snap_box.set_border_width (2);
2652 snap_type_selector.set_name ("SnapTypeSelector");
2653 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, "SMPTE Seconds", 2+FUDGE, 10);
2654 set_popdown_strings (snap_type_selector, snap_type_strings);
2655 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2656 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Unit to snap cursors and ranges to"));
2658 snap_mode_selector.set_name ("SnapModeSelector");
2659 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, "Magnetic Snap", 2+FUDGE, 10);
2660 set_popdown_strings (snap_mode_selector, snap_mode_strings);
2661 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2663 snap_box.pack_start (edit_cursor_clock, false, false);
2664 snap_box.pack_start (snap_mode_selector, false, false);
2665 snap_box.pack_start (snap_type_selector, false, false);
2670 HBox *nudge_box = manage (new HBox);
2671 nudge_box->set_spacing(1);
2672 nudge_box->set_border_width (2);
2674 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2675 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2677 nudge_box->pack_start (nudge_backward_button, false, false);
2678 nudge_box->pack_start (nudge_forward_button, false, false);
2679 nudge_box->pack_start (nudge_clock, false, false);
2682 /* Pack everything in... */
2684 HBox* hbox = new HBox;
2685 hbox->set_spacing(10);
2687 tools_tearoff = new TearOff (*hbox);
2688 tools_tearoff->set_name ("MouseModeBase");
2690 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2691 &tools_tearoff->tearoff_window()));
2692 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2693 &tools_tearoff->tearoff_window(), 0));
2694 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2695 &tools_tearoff->tearoff_window()));
2696 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2697 &tools_tearoff->tearoff_window(), 0));
2699 toolbar_hbox.set_spacing (10);
2700 toolbar_hbox.set_border_width (1);
2702 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2703 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2706 hbox->pack_start (snap_box, false, false);
2707 // hbox->pack_start (zoom_box, false, false);
2708 hbox->pack_start (*nudge_box, false, false);
2712 toolbar_base.set_name ("ToolBarBase");
2713 toolbar_base.add (toolbar_hbox);
2715 toolbar_frame.set_shadow_type (SHADOW_OUT);
2716 toolbar_frame.set_name ("BaseFrame");
2717 toolbar_frame.add (toolbar_base);
2721 Editor::convert_drop_to_paths (vector<ustring>& paths,
2722 const RefPtr<Gdk::DragContext>& context,
2725 const SelectionData& data,
2734 vector<ustring> uris = data.get_uris();
2738 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
2739 are actually URI lists. So do it by hand.
2742 if (data.get_target() != "text/plain") {
2746 /* Parse the "uri-list" format that Nautilus provides,
2747 where each pathname is delimited by \r\n
2750 const char* p = data.get_text().c_str();
2757 while (g_ascii_isspace (*p))
2761 while (*q && (*q != '\n') && (*q != '\r'))
2767 while (q > p && g_ascii_isspace (*q))
2772 uris.push_back (ustring (p, q - p + 1));
2776 p = strchr (p, '\n');
2786 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
2787 if ((*i).substr (0,7) == "file://") {
2789 PBD::url_decode (p);
2790 paths.push_back (p.substr (7));
2798 Editor::new_tempo_section ()
2804 Editor::map_transport_state ()
2806 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
2808 if (session->transport_stopped()) {
2809 have_pending_keyboard_selection = false;
2815 Editor::State::State ()
2817 selection = new Selection;
2820 Editor::State::~State ()
2826 Editor::get_memento () const
2828 State *state = new State;
2830 store_state (*state);
2831 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
2835 Editor::store_state (State& state) const
2837 *state.selection = *selection;
2841 Editor::restore_state (State *state)
2843 if (*selection == *state->selection) {
2847 *selection = *state->selection;
2848 time_selection_changed ();
2849 region_selection_changed ();
2851 /* XXX other selection change handlers? */
2855 Editor::begin_reversible_command (string name)
2858 before = &get_state();
2859 session->begin_reversible_command (name);
2864 Editor::commit_reversible_command ()
2867 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
2871 struct TrackViewByPositionSorter
2873 bool operator() (const TimeAxisView* a, const TimeAxisView *b) {
2874 return a->y_position < b->y_position;
2879 Editor::extend_selection_to_track (TimeAxisView& view)
2881 if (selection->selected (&view)) {
2882 /* already selected, do nothing */
2886 if (selection->tracks.empty()) {
2888 if (!selection->selected (&view)) {
2889 selection->set (&view);
2896 /* something is already selected, so figure out which range of things to add */
2898 TrackViewList to_be_added;
2899 TrackViewList sorted = track_views;
2900 TrackViewByPositionSorter cmp;
2901 bool passed_clicked = false;
2906 if (!selection->selected (&view)) {
2907 to_be_added.push_back (&view);
2910 /* figure out if we should go forward or backwards */
2912 for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) {
2914 if ((*i) == &view) {
2915 passed_clicked = true;
2918 if (selection->selected (*i)) {
2919 if (passed_clicked) {
2928 passed_clicked = false;
2932 for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) {
2934 if ((*i) == &view) {
2935 passed_clicked = true;
2939 if (passed_clicked) {
2940 if ((*i)->hidden()) {
2943 if (selection->selected (*i)) {
2945 } else if (!(*i)->hidden()) {
2946 to_be_added.push_back (*i);
2953 for (TrackViewList::reverse_iterator r = sorted.rbegin(); r != sorted.rend(); ++r) {
2955 if ((*r) == &view) {
2956 passed_clicked = true;
2960 if (passed_clicked) {
2962 if ((*r)->hidden()) {
2966 if (selection->selected (*r)) {
2968 } else if (!(*r)->hidden()) {
2969 to_be_added.push_back (*r);
2975 if (!to_be_added.empty()) {
2976 selection->add (to_be_added);
2985 Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no_remove)
2987 bool commit = false;
2990 case Selection::Toggle:
2991 if (selection->selected (&view)) {
2993 selection->remove (&view);
2997 selection->add (&view);
3002 case Selection::Add:
3003 if (!selection->selected (&view)) {
3004 selection->add (&view);
3009 case Selection::Set:
3010 if (selection->selected (&view) && selection->tracks.size() == 1) {
3011 /* no commit necessary */
3013 selection->set (&view);
3018 case Selection::Extend:
3019 commit = extend_selection_to_track (view);
3027 Editor::set_selected_track_from_click (Selection::Operation op, bool no_remove)
3029 if (!clicked_routeview) {
3033 return set_selected_track (*clicked_routeview, op, no_remove);
3037 Editor::set_selected_control_point_from_click (Selection::Operation op, bool no_remove)
3039 if (!clicked_control_point) {
3043 /* select this point and any others that it represents */
3048 x1 = pixel_to_frame (clicked_control_point->get_x() - 10);
3049 x2 = pixel_to_frame (clicked_control_point->get_x() + 10);
3050 y1 = clicked_control_point->get_x() - 10;
3051 y2 = clicked_control_point->get_y() + 10;
3053 return select_all_within (x1, x2, y1, y2, op);
3057 Editor::get_relevant_tracks (set<RouteTimeAxisView*>& relevant_tracks)
3059 /* step one: get all selected tracks and all tracks in the relevant edit groups */
3061 for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) {
3063 RouteTimeAxisView* atv = dynamic_cast<RouteTimeAxisView*>(*ti);
3069 RouteGroup* group = atv->route()->edit_group();
3071 if (group && group->is_active()) {
3073 /* active group for this track, loop over all tracks and get every member of the group */
3075 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3077 RouteTimeAxisView* tatv;
3079 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
3081 if (tatv->route()->edit_group() == group) {
3082 relevant_tracks.insert (tatv);
3087 relevant_tracks.insert (atv);
3093 Editor::mapover_tracks (slot<void,RouteTimeAxisView&,uint32_t> sl)
3095 set<RouteTimeAxisView*> relevant_tracks;
3097 get_relevant_tracks (relevant_tracks);
3099 uint32_t sz = relevant_tracks.size();
3101 for (set<RouteTimeAxisView*>::iterator ati = relevant_tracks.begin(); ati != relevant_tracks.end(); ++ati) {
3107 Editor::mapped_set_selected_regionview_from_click (RouteTimeAxisView& tv, uint32_t ignored,
3108 RegionView* basis, vector<RegionView*>* all_equivs)
3110 boost::shared_ptr<Playlist> pl;
3111 vector<boost::shared_ptr<Region> > results;
3113 boost::shared_ptr<Diskstream> ds;
3115 if ((ds = tv.get_diskstream()) == 0) {
3120 if (&tv == &basis->get_time_axis_view()) {
3121 /* looking in same track as the original */
3126 if ((pl = ds->playlist()) != 0) {
3127 pl->get_equivalent_regions (basis->region(), results);
3130 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
3131 if ((marv = tv.view()->find_view (*ir)) != 0) {
3132 all_equivs->push_back (marv);
3138 Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, bool no_track_remove)
3140 vector<RegionView*> all_equivalent_regions;
3141 bool commit = false;
3143 if (!clicked_regionview || !clicked_routeview) {
3147 if (op == Selection::Toggle || op == Selection::Set) {
3149 mapover_tracks (bind (mem_fun (*this, &Editor::mapped_set_selected_regionview_from_click),
3150 clicked_regionview, &all_equivalent_regions));
3153 /* add clicked regionview since we skipped all other regions in the same track as the one it was in */
3155 all_equivalent_regions.push_back (clicked_regionview);
3158 case Selection::Toggle:
3160 if (clicked_regionview->get_selected()) {
3163 /* whatever was clicked was selected already; do nothing here but allow
3164 the button release to deselect it
3167 button_release_can_deselect = true;
3171 if (button_release_can_deselect) {
3173 /* just remove this one region, but only on a permitted button release */
3175 selection->remove (clicked_regionview);
3178 /* no more deselect action on button release till a new press
3179 finds an already selected object.
3182 button_release_can_deselect = false;
3189 /* add all the equivalent regions, but only on button press */
3191 if (!all_equivalent_regions.empty()) {
3195 for (vector<RegionView*>::iterator i = all_equivalent_regions.begin(); i != all_equivalent_regions.end(); ++i) {
3196 selection->add (*i);
3202 case Selection::Set:
3203 if (!clicked_regionview->get_selected()) {
3204 selection->set (all_equivalent_regions);
3207 /* no commit necessary: clicked on an already selected region */
3213 /* silly compiler */
3217 } else if (op == Selection::Extend) {
3219 list<Selectable*> results;
3220 nframes_t last_frame;
3221 nframes_t first_frame;
3223 /* 1. find the last selected regionview in the track that was clicked in */
3226 first_frame = max_frames;
3228 for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
3229 if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) {
3231 if ((*x)->region()->last_frame() > last_frame) {
3232 last_frame = (*x)->region()->last_frame();
3235 if ((*x)->region()->first_frame() < first_frame) {
3236 first_frame = (*x)->region()->first_frame();
3241 /* 2. figure out the boundaries for our search for new objects */
3243 switch (clicked_regionview->region()->coverage (first_frame, last_frame)) {
3245 if (last_frame < clicked_regionview->region()->first_frame()) {
3246 first_frame = last_frame;
3247 last_frame = clicked_regionview->region()->last_frame();
3249 last_frame = first_frame;
3250 first_frame = clicked_regionview->region()->first_frame();
3254 case OverlapExternal:
3255 if (last_frame < clicked_regionview->region()->first_frame()) {
3256 first_frame = last_frame;
3257 last_frame = clicked_regionview->region()->last_frame();
3259 last_frame = first_frame;
3260 first_frame = clicked_regionview->region()->first_frame();
3264 case OverlapInternal:
3265 if (last_frame < clicked_regionview->region()->first_frame()) {
3266 first_frame = last_frame;
3267 last_frame = clicked_regionview->region()->last_frame();
3269 last_frame = first_frame;
3270 first_frame = clicked_regionview->region()->first_frame();
3276 /* nothing to do except add clicked region to selection, since it
3277 overlaps with the existing selection in this track.
3282 /* 2. find all selectable objects (regionviews in this case) between that one and the end of the
3283 one that was clicked.
3286 set<RouteTimeAxisView*> relevant_tracks;
3288 get_relevant_tracks (relevant_tracks);
3290 for (set<RouteTimeAxisView*>::iterator t = relevant_tracks.begin(); t != relevant_tracks.end(); ++t) {
3291 (*t)->get_selectables (first_frame, last_frame, -1.0, -1.0, results);
3294 /* 3. convert to a vector of audio regions */
3296 vector<RegionView*> regions;
3298 for (list<Selectable*>::iterator x = results.begin(); x != results.end(); ++x) {
3301 if ((arv = dynamic_cast<RegionView*>(*x)) != 0) {
3302 regions.push_back (arv);
3306 if (!regions.empty()) {
3307 selection->add (regions);
3317 Editor::set_selected_regionview_from_region_list (boost::shared_ptr<Region> region, Selection::Operation op)
3319 vector<RegionView*> all_equivalent_regions;
3321 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3323 RouteTimeAxisView* tatv;
3325 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
3327 boost::shared_ptr<Playlist> pl;
3328 vector<boost::shared_ptr<Region> > results;
3330 boost::shared_ptr<Diskstream> ds;
3332 if ((ds = tatv->get_diskstream()) == 0) {
3337 if ((pl = (ds->playlist())) != 0) {
3338 pl->get_region_list_equivalent_regions (region, results);
3341 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
3342 if ((marv = tatv->view()->find_view (*ir)) != 0) {
3343 all_equivalent_regions.push_back (marv);
3350 begin_reversible_command (_("set selected regions"));
3353 case Selection::Toggle:
3354 /* XXX this is not correct */
3355 selection->toggle (all_equivalent_regions);
3357 case Selection::Set:
3358 selection->set (all_equivalent_regions);
3360 case Selection::Extend:
3361 selection->add (all_equivalent_regions);
3363 case Selection::Add:
3364 selection->add (all_equivalent_regions);
3368 commit_reversible_command () ;
3372 Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::weak_ptr<Region> weak_r)
3375 boost::shared_ptr<Region> r (weak_r.lock());
3381 boost::shared_ptr<AudioRegion> ar;
3383 if ((ar = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
3387 if ((rv = sv->find_view (ar)) == 0) {
3391 /* don't reset the selection if its something other than
3392 a single other region.
3395 if (selection->regions.size() > 1) {
3399 begin_reversible_command (_("set selected regions"));
3401 selection->set (rv);
3403 commit_reversible_command () ;
3409 Editor::set_edit_group_solo (Route& route, bool yn)
3411 RouteGroup *edit_group;
3413 if ((edit_group = route.edit_group()) != 0) {
3414 edit_group->apply (&Route::set_solo, yn, this);
3416 route.set_solo (yn, this);
3421 Editor::set_edit_group_mute (Route& route, bool yn)
3423 RouteGroup *edit_group = 0;
3425 if ((edit_group == route.edit_group()) != 0) {
3426 edit_group->apply (&Route::set_mute, yn, this);
3428 route.set_mute (yn, this);
3433 Editor::history_changed ()
3437 if (undo_action && session) {
3438 if (session->undo_depth() == 0) {
3441 label = string_compose(_("Undo (%1)"), session->next_undo());
3443 undo_action->property_label() = label;
3446 if (redo_action && session) {
3447 if (session->redo_depth() == 0) {
3450 label = string_compose(_("Redo (%1)"), session->next_redo());
3452 redo_action->property_label() = label;
3457 Editor::duplicate_dialog (bool dup_region)
3460 if (clicked_regionview == 0) {
3464 if (selection->time.length() == 0) {
3469 ArdourDialog win ("duplicate dialog");
3471 Label label (_("Duplicate how many times?"));
3473 win.get_vbox()->pack_start (label);
3474 win.add_action_widget (entry, RESPONSE_ACCEPT);
3475 win.add_button (Stock::OK, RESPONSE_ACCEPT);
3476 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3478 win.set_position (WIN_POS_MOUSE);
3480 entry.set_text ("1");
3481 set_size_request_to_display_given_text (entry, X_("12345678"), 20, 15);
3482 entry.select_region (0, -1);
3483 entry.grab_focus ();
3486 switch (win.run ()) {
3487 case RESPONSE_ACCEPT:
3493 string text = entry.get_text();
3496 if (sscanf (text.c_str(), "%f", ×) == 1) {
3498 RegionSelection regions;
3499 regions.add (clicked_regionview);
3500 duplicate_some_regions (regions, times);
3502 duplicate_selection (times);
3508 Editor::show_verbose_canvas_cursor ()
3510 verbose_canvas_cursor->raise_to_top();
3511 verbose_canvas_cursor->show();
3512 verbose_cursor_visible = true;
3516 Editor::hide_verbose_canvas_cursor ()
3518 verbose_canvas_cursor->hide();
3519 verbose_cursor_visible = false;
3523 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3525 /* XXX get origin of canvas relative to root window,
3526 add x and y and check compared to gdk_screen_{width,height}
3528 verbose_canvas_cursor->property_text() = txt.c_str();
3529 verbose_canvas_cursor->property_x() = x;
3530 verbose_canvas_cursor->property_y() = y;
3534 Editor::set_verbose_canvas_cursor_text (const string & txt)
3536 verbose_canvas_cursor->property_text() = txt.c_str();
3540 Editor::edit_mode_selection_done ()
3546 string choice = edit_mode_selector.get_active_text();
3547 EditMode mode = Slide;
3549 if (choice == _("Splice Edit")) {
3551 } else if (choice == _("Slide Edit")) {
3555 Config->set_edit_mode (mode);
3559 Editor::snap_type_selection_done ()
3561 string choice = snap_type_selector.get_active_text();
3562 SnapType snaptype = SnapToFrame;
3564 if (choice == _("Beats/3")) {
3565 snaptype = SnapToAThirdBeat;
3566 } else if (choice == _("Beats/4")) {
3567 snaptype = SnapToAQuarterBeat;
3568 } else if (choice == _("Beats/8")) {
3569 snaptype = SnapToAEighthBeat;
3570 } else if (choice == _("Beats/16")) {
3571 snaptype = SnapToASixteenthBeat;
3572 } else if (choice == _("Beats/32")) {
3573 snaptype = SnapToAThirtysecondBeat;
3574 } else if (choice == _("Beats")) {
3575 snaptype = SnapToBeat;
3576 } else if (choice == _("Bars")) {
3577 snaptype = SnapToBar;
3578 } else if (choice == _("Marks")) {
3579 snaptype = SnapToMark;
3580 } else if (choice == _("Edit Cursor")) {
3581 snaptype = SnapToEditCursor;
3582 } else if (choice == _("Region starts")) {
3583 snaptype = SnapToRegionStart;
3584 } else if (choice == _("Region ends")) {
3585 snaptype = SnapToRegionEnd;
3586 } else if (choice == _("Region bounds")) {
3587 snaptype = SnapToRegionBoundary;
3588 } else if (choice == _("Region syncs")) {
3589 snaptype = SnapToRegionSync;
3590 } else if (choice == _("CD Frames")) {
3591 snaptype = SnapToCDFrame;
3592 } else if (choice == _("SMPTE Frames")) {
3593 snaptype = SnapToSMPTEFrame;
3594 } else if (choice == _("SMPTE Seconds")) {
3595 snaptype = SnapToSMPTESeconds;
3596 } else if (choice == _("SMPTE Minutes")) {
3597 snaptype = SnapToSMPTEMinutes;
3598 } else if (choice == _("Seconds")) {
3599 snaptype = SnapToSeconds;
3600 } else if (choice == _("Minutes")) {
3601 snaptype = SnapToMinutes;
3602 } else if (choice == _("None")) {
3603 snaptype = SnapToFrame;
3606 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3608 ract->set_active ();
3613 Editor::snap_mode_selection_done ()
3615 string choice = snap_mode_selector.get_active_text();
3616 SnapMode mode = SnapNormal;
3618 if (choice == _("Normal")) {
3620 } else if (choice == _("Magnetic")) {
3621 mode = SnapMagnetic;
3624 RefPtr<RadioAction> ract = snap_mode_action (mode);
3627 ract->set_active (true);
3632 Editor::zoom_focus_selection_done ()
3634 string choice = zoom_focus_selector.get_active_text();
3635 ZoomFocus focus_type = ZoomFocusLeft;
3637 if (choice == _("Left")) {
3638 focus_type = ZoomFocusLeft;
3639 } else if (choice == _("Right")) {
3640 focus_type = ZoomFocusRight;
3641 } else if (choice == _("Center")) {
3642 focus_type = ZoomFocusCenter;
3643 } else if (choice == _("Playhead")) {
3644 focus_type = ZoomFocusPlayhead;
3645 } else if (choice == _("Edit Cursor")) {
3646 focus_type = ZoomFocusEdit;
3649 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3652 ract->set_active ();
3657 Editor::edit_controls_button_release (GdkEventButton* ev)
3659 if (Keyboard::is_context_menu_event (ev)) {
3660 ARDOUR_UI::instance()->add_route ();
3666 Editor::track_selection_changed ()
3668 switch (selection->tracks.size()){
3672 set_selected_mixer_strip (*(selection->tracks.front()));
3676 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3677 (*i)->set_selected (false);
3678 if (mouse_mode == MouseRange) {
3679 (*i)->hide_selection ();
3683 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3684 (*i)->set_selected (true);
3685 if (mouse_mode == MouseRange) {
3686 (*i)->show_selection (selection->time);
3692 Editor::time_selection_changed ()
3694 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3695 (*i)->hide_selection ();
3698 if (selection->tracks.empty()) {
3699 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3700 (*i)->show_selection (selection->time);
3703 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3704 (*i)->show_selection (selection->time);
3708 if (selection->time.empty()) {
3709 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
3711 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true);
3716 Editor::region_selection_changed ()
3718 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3719 (*i)->set_selected_regionviews (selection->regions);
3724 Editor::point_selection_changed ()
3726 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3727 (*i)->set_selected_points (selection->points);
3732 Editor::mouse_select_button_release (GdkEventButton* ev)
3734 /* this handles just right-clicks */
3736 if (ev->button != 3) {
3743 Editor::TrackViewList *
3744 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3747 TrackViewList::iterator i;
3749 v = new TrackViewList;
3751 if (track == 0 && group == 0) {
3755 for (i = track_views.begin(); i != track_views.end (); ++i) {
3759 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3761 /* just the view for this track
3764 v->push_back (track);
3768 /* views for all tracks in the edit group */
3770 for (i = track_views.begin(); i != track_views.end (); ++i) {
3772 if (group == 0 || (*i)->edit_group() == group) {
3782 Editor::set_zoom_focus (ZoomFocus f)
3784 string str = zoom_focus_strings[(int)f];
3786 if (str != zoom_focus_selector.get_active_text()) {
3787 zoom_focus_selector.set_active_text (str);
3790 if (zoom_focus != f) {
3793 ZoomFocusChanged (); /* EMIT_SIGNAL */
3800 Editor::ensure_float (Window& win)
3802 win.set_transient_for (*this);
3806 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3808 /* recover or initialize pane positions. do this here rather than earlier because
3809 we don't want the positions to change the child allocations, which they seem to do.
3815 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3817 static int32_t done;
3820 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3821 width = default_width;
3822 height = default_height;
3824 width = atoi(geometry->property("x_size")->value());
3825 height = atoi(geometry->property("y_size")->value());
3828 if (which == static_cast<Paned*> (&edit_pane)) {
3834 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3835 /* initial allocation is 90% to canvas, 10% to notebook */
3836 pos = (int) floor (alloc.get_width() * 0.90f);
3837 snprintf (buf, sizeof(buf), "%d", pos);
3839 pos = atoi (prop->value());
3842 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3843 edit_pane.set_position (pos);
3844 pre_maximal_pane_position = pos;
3850 Editor::detach_tearoff (Box* b, Window* w)
3852 if (tools_tearoff->torn_off() &&
3853 mouse_mode_tearoff->torn_off()) {
3854 top_hbox.remove (toolbar_frame);
3859 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3861 if (toolbar_frame.get_parent() == 0) {
3862 top_hbox.pack_end (toolbar_frame);
3867 Editor::set_show_measures (bool yn)
3869 if (_show_measures != yn) {
3872 if ((_show_measures = yn) == true) {
3875 DisplayControlChanged (ShowMeasures);
3881 Editor::toggle_follow_playhead ()
3883 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3885 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3886 set_follow_playhead (tact->get_active());
3891 Editor::set_follow_playhead (bool yn)
3893 if (_follow_playhead != yn) {
3894 if ((_follow_playhead = yn) == true) {
3896 update_current_screen ();
3898 DisplayControlChanged (FollowPlayhead);
3904 Editor::toggle_xfade_active (Crossfade* xfade)
3906 xfade->set_active (!xfade->active());
3910 Editor::toggle_xfade_length (Crossfade* xfade)
3912 xfade->set_follow_overlap (!xfade->following_overlap());
3916 Editor::edit_xfade (Crossfade* xfade)
3918 CrossfadeEditor cew (*session, *xfade, xfade->fade_in().get_min_y(), 1.0);
3922 switch (cew.run ()) {
3923 case RESPONSE_ACCEPT:
3930 xfade->StateChanged (Change (~0));
3934 Editor::playlist_selector () const
3936 return *_playlist_selector;
3940 Editor::get_nudge_distance (nframes_t pos, nframes_t& next)
3944 ret = nudge_clock.current_duration (pos);
3945 next = ret + 1; /* XXXX fix me */
3951 Editor::end_location_changed (Location* location)
3953 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3954 reset_scrolling_region ();
3958 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
3960 ArdourDialog dialog ("playlist deletion dialog");
3961 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3962 "If left alone, no audio files used by it will be cleaned.\n"
3963 "If deleted, audio files used by it alone by will cleaned."),
3966 dialog.set_position (WIN_POS_CENTER);
3967 dialog.get_vbox()->pack_start (label);
3971 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3972 dialog.add_button (_("Keep playlist"), RESPONSE_CANCEL);
3973 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3975 switch (dialog.run ()) {
3976 case RESPONSE_ACCEPT:
3977 /* delete the playlist */
3981 case RESPONSE_REJECT:
3982 /* keep the playlist */
3994 Editor::audio_region_selection_covers (nframes_t where)
3996 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3997 if ((*a)->region()->covers (where)) {
4006 Editor::prepare_for_cleanup ()
4008 cut_buffer->clear_regions ();
4009 cut_buffer->clear_playlists ();
4011 selection->clear_regions ();
4012 selection->clear_playlists ();
4016 Editor::transport_loop_location()
4019 return session->locations()->auto_loop_location();
4026 Editor::transport_punch_location()
4029 return session->locations()->auto_punch_location();
4036 Editor::control_layout_scroll (GdkEventScroll* ev)
4038 switch (ev->direction) {
4040 scroll_tracks_up_line ();
4044 case GDK_SCROLL_DOWN:
4045 scroll_tracks_down_line ();
4049 /* no left/right handling yet */
4057 Editor::snapshot_display_selection_changed ()
4059 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
4061 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
4063 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
4065 if (snap_name.length() == 0) {
4069 if (session->snap_name() == snap_name) {
4073 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
4078 Editor::snapshot_display_button_press (GdkEventButton* ev)
4084 Editor::redisplay_snapshots ()
4090 vector<string*>* states;
4092 if ((states = session->possible_states()) == 0) {
4096 snapshot_display_model->clear ();
4098 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
4099 string statename = *(*i);
4100 TreeModel::Row row = *(snapshot_display_model->append());
4102 // we don't have a way of changing the rendering in just one TreeView
4103 // cell so just put an asterisk on each side of the name for now.
4104 string display_name;
4105 if (statename == session->snap_name()) {
4106 display_name = "*"+statename+"*";
4107 snapshot_display.get_selection()->select(row);
4109 display_name = statename;
4112 row[snapshot_display_columns.visible_name] = display_name;
4113 row[snapshot_display_columns.real_name] = statename;
4120 Editor::session_state_saved (string snap_name)
4122 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4123 redisplay_snapshots ();
4127 Editor::maximise_editing_space ()
4129 initial_ruler_update_required = true;
4131 mouse_mode_tearoff->set_visible (false);
4132 tools_tearoff->set_visible (false);
4134 pre_maximal_pane_position = edit_pane.get_position();
4135 pre_maximal_editor_width = this->get_width();
4137 if(post_maximal_pane_position == 0) {
4138 post_maximal_pane_position = edit_pane.get_width();
4143 if(post_maximal_editor_width) {
4144 edit_pane.set_position (post_maximal_pane_position -
4145 abs(post_maximal_editor_width - pre_maximal_editor_width));
4147 edit_pane.set_position (post_maximal_pane_position);
4152 Editor::restore_editing_space ()
4154 initial_ruler_update_required = true;
4156 // user changed width of pane during fullscreen
4157 if(post_maximal_pane_position != edit_pane.get_position()) {
4158 post_maximal_pane_position = edit_pane.get_position();
4163 mouse_mode_tearoff->set_visible (true);
4164 tools_tearoff->set_visible (true);
4165 post_maximal_editor_width = this->get_width();
4168 edit_pane.set_position (
4169 pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width)
4174 Editor::new_playlists ()
4176 begin_reversible_command (_("new playlists"));
4177 mapover_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist));
4178 commit_reversible_command ();
4182 Editor::copy_playlists ()
4184 begin_reversible_command (_("copy playlists"));
4185 mapover_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist));
4186 commit_reversible_command ();
4190 Editor::clear_playlists ()
4192 begin_reversible_command (_("clear playlists"));
4193 mapover_tracks (mem_fun (*this, &Editor::mapped_clear_playlist));
4194 commit_reversible_command ();
4198 Editor::mapped_use_new_playlist (RouteTimeAxisView& atv, uint32_t sz)
4200 atv.use_new_playlist (sz > 1 ? false : true);
4204 Editor::mapped_use_copy_playlist (RouteTimeAxisView& atv, uint32_t sz)
4206 atv.use_copy_playlist (sz > 1 ? false : true);
4210 Editor::mapped_clear_playlist (RouteTimeAxisView& atv, uint32_t sz)
4212 atv.clear_playlist ();
4216 Editor::on_key_press_event (GdkEventKey* ev)
4218 return key_press_focus_accelerator_handler (*this, ev);