2 Copyright (C) 2000-2007 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.
26 #include <boost/none.hpp>
28 #include <sigc++/bind.h>
30 #include <pbd/convert.h>
31 #include <pbd/error.h>
32 #include <pbd/enumwriter.h>
33 #include <pbd/memento_command.h>
35 #include <glibmm/miscutils.h>
36 #include <gtkmm/image.h>
37 #include <gdkmm/color.h>
38 #include <gdkmm/bitmap.h>
40 #include <gtkmm2ext/grouped_buttons.h>
41 #include <gtkmm2ext/gtk_ui.h>
42 #include <gtkmm2ext/tearoff.h>
43 #include <gtkmm2ext/utils.h>
44 #include <gtkmm2ext/window_title.h>
45 #include <gtkmm2ext/choice.h>
47 #include <ardour/audio_track.h>
48 #include <ardour/audio_diskstream.h>
49 #include <ardour/plugin_manager.h>
50 #include <ardour/location.h>
51 #include <ardour/audioplaylist.h>
52 #include <ardour/audioregion.h>
53 #include <ardour/region.h>
54 #include <ardour/session_route.h>
55 #include <ardour/tempo.h>
56 #include <ardour/utils.h>
58 #include <control_protocol/control_protocol.h>
60 #include "ardour_ui.h"
64 #include "playlist_selector.h"
65 #include "audio_region_view.h"
66 #include "rgb_macros.h"
67 #include "selection.h"
68 #include "audio_streamview.h"
69 #include "time_axis_view.h"
70 #include "audio_time_axis.h"
72 #include "crossfade_view.h"
74 #include "public_editor.h"
75 #include "crossfade_edit.h"
76 #include "canvas_impl.h"
78 #include "gui_thread.h"
81 #include "analysis_window.h"
87 #include "imageframe_socket_handler.h"
88 /* </CMT Additions> */
92 using namespace ARDOUR;
96 using namespace Gtkmm2ext;
97 using namespace Editing;
101 const double Editor::timebar_height = 15.0;
103 #include "editor_xpms"
105 static const gchar *_snap_type_strings[] = {
129 static const gchar *_snap_mode_strings[] = {
135 static const gchar *_zoom_focus_strings[] = {
144 /* Soundfile drag-n-drop */
146 Gdk::Cursor* Editor::cross_hair_cursor = 0;
147 Gdk::Cursor* Editor::selector_cursor = 0;
148 Gdk::Cursor* Editor::trimmer_cursor = 0;
149 Gdk::Cursor* Editor::grabber_cursor = 0;
150 Gdk::Cursor* Editor::zoom_cursor = 0;
151 Gdk::Cursor* Editor::time_fx_cursor = 0;
152 Gdk::Cursor* Editor::fader_cursor = 0;
153 Gdk::Cursor* Editor::speaker_cursor = 0;
154 Gdk::Cursor* Editor::wait_cursor = 0;
155 Gdk::Cursor* Editor::timebar_cursor = 0;
158 show_me_the_size (Requisition* r, const char* what)
160 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
164 check_adjustment (Gtk::Adjustment* adj)
166 cerr << "CHANGE adj = "
167 << adj->get_lower () << ' '
168 << adj->get_upper () << ' '
169 << adj->get_value () << ' '
170 << adj->get_step_increment () << ' '
171 << adj->get_page_increment () << ' '
172 << adj->get_page_size () << ' '
179 /* time display buttons */
180 minsec_label (_("Mins:Secs")),
181 bbt_label (_("Bars:Beats")),
182 smpte_label (_("Timecode")),
183 frame_label (_("Frames")),
184 tempo_label (_("Tempo")),
185 meter_label (_("Meter")),
186 mark_label (_("Location Markers")),
187 range_mark_label (_("Range Markers")),
188 transport_mark_label (_("Loop/Punch Ranges")),
190 edit_packer (3, 3, false),
192 /* the values here don't matter: layout widgets
193 reset them as needed.
196 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
197 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
199 /* tool bar related */
201 edit_cursor_clock (X_("editcursor"), false, X_("EditCursorClock"), true),
202 zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true),
204 toolbar_selection_clock_table (2,3),
206 automation_mode_button (_("mode")),
207 global_automation_button (_("automation")),
209 /* <CMT Additions> */
210 image_socket_listener(0),
211 /* </CMT Additions> */
215 nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true)
220 /* we are a singleton */
222 PublicEditor::_instance = this;
226 selection = new Selection;
227 cut_buffer = new Selection;
229 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
230 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
231 selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
232 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
234 clicked_regionview = 0;
235 clicked_trackview = 0;
236 clicked_audio_trackview = 0;
237 clicked_crossfadeview = 0;
238 clicked_control_point = 0;
239 latest_regionview = 0;
240 last_update_frame = 0;
242 current_mixer_strip = 0;
243 current_bbt_points = 0;
245 snap_type_strings = I18N (_snap_type_strings);
246 snap_mode_strings = I18N (_snap_mode_strings);
247 zoom_focus_strings = I18N(_zoom_focus_strings);
249 snap_type = SnapToFrame;
250 set_snap_to (snap_type);
251 snap_mode = SnapNormal;
252 set_snap_mode (snap_mode);
253 snap_threshold = 5.0;
254 bbt_beat_subdivision = 4;
257 autoscroll_active = false;
258 autoscroll_timeout_tag = -1;
259 interthread_progress_window = 0;
265 current_interthread_info = 0;
266 _show_measures = true;
267 _show_waveforms = true;
268 _show_waveforms_recording = true;
269 first_action_message = 0;
271 show_gain_after_trim = false;
272 ignore_route_list_reorder = false;
273 no_route_list_redisplay = false;
274 verbose_cursor_on = true;
275 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 region_edit_menu_split_item = 0;
297 region_edit_menu_split_multichannel_item = 0;
299 ignore_mouse_mode_toggle = false;
300 current_stepping_trackview = 0;
302 entered_regionview = 0;
303 clear_entered_track = false;
304 _new_regionviews_show_envelope = false;
305 current_timestretch = 0;
306 in_edit_group_row_change = false;
307 last_canvas_frame = 0;
310 button_release_can_deselect = true;
311 canvas_idle_queued = false;
312 _dragging_playhead = false;
313 _dragging_hscrollbar = false;
315 location_marker_color = ARDOUR_UI::config()->canvasvar_LocationMarker.get();
316 location_range_color = ARDOUR_UI::config()->canvasvar_LocationRange.get();
317 location_cd_marker_color = ARDOUR_UI::config()->canvasvar_LocationCDMarker.get();
318 location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
319 location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
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 reset_zoom () */
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), false);
360 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release), false);
361 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
363 edit_hscrollbar.set_name ("EditorHScrollbar");
368 edit_cursor_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_cursor_clock_changed));
370 time_canvas_vbox.pack_start (*_ruler_separator, false, false);
371 time_canvas_vbox.pack_start (*minsec_ruler, false, false);
372 time_canvas_vbox.pack_start (*smpte_ruler, false, false);
373 time_canvas_vbox.pack_start (*frames_ruler, false, false);
374 time_canvas_vbox.pack_start (*bbt_ruler, false, false);
375 time_canvas_vbox.pack_start (time_canvas, true, true);
376 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars) + 2);
378 bbt_label.set_name ("EditorTimeButton");
379 bbt_label.set_size_request (-1, (int)timebar_height);
380 bbt_label.set_alignment (1.0, 0.5);
381 bbt_label.set_padding (5,0);
382 minsec_label.set_name ("EditorTimeButton");
383 minsec_label.set_size_request (-1, (int)timebar_height);
384 minsec_label.set_alignment (1.0, 0.5);
385 minsec_label.set_padding (5,0);
386 smpte_label.set_name ("EditorTimeButton");
387 smpte_label.set_size_request (-1, (int)timebar_height);
388 smpte_label.set_alignment (1.0, 0.5);
389 smpte_label.set_padding (5,0);
390 frame_label.set_name ("EditorTimeButton");
391 frame_label.set_size_request (-1, (int)timebar_height);
392 frame_label.set_alignment (1.0, 0.5);
393 frame_label.set_padding (5,0);
394 tempo_label.set_name ("EditorTimeButton");
395 tempo_label.set_size_request (-1, (int)timebar_height);
396 tempo_label.set_alignment (1.0, 0.5);
397 tempo_label.set_padding (5,0);
398 meter_label.set_name ("EditorTimeButton");
399 meter_label.set_size_request (-1, (int)timebar_height);
400 meter_label.set_alignment (1.0, 0.5);
401 meter_label.set_padding (5,0);
402 mark_label.set_name ("EditorTimeButton");
403 mark_label.set_size_request (-1, (int)timebar_height);
404 mark_label.set_alignment (1.0, 0.5);
405 mark_label.set_padding (5,0);
406 range_mark_label.set_name ("EditorTimeButton");
407 range_mark_label.set_size_request (-1, (int)timebar_height);
408 range_mark_label.set_alignment (1.0, 0.5);
409 range_mark_label.set_padding (5,0);
410 transport_mark_label.set_name ("EditorTimeButton");
411 transport_mark_label.set_size_request (-1, (int)timebar_height);
412 transport_mark_label.set_alignment (1.0, 0.5);
413 transport_mark_label.set_padding (5,0);
415 time_button_vbox.pack_start (minsec_label, false, false);
416 time_button_vbox.pack_start (smpte_label, false, false);
417 time_button_vbox.pack_start (frame_label, false, false);
418 time_button_vbox.pack_start (bbt_label, false, false);
419 time_button_vbox.pack_start (meter_label, false, false);
420 time_button_vbox.pack_start (tempo_label, false, false);
421 time_button_vbox.pack_start (mark_label, false, false);
423 time_button_event_box.add (time_button_vbox);
425 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
426 time_button_event_box.set_name ("TimebarLabelBase");
427 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
429 time_button_frame.add(time_button_event_box);
430 time_button_frame.property_shadow_type() = Gtk::SHADOW_OUT;
432 /* these enable us to have a dedicated window (for cursor setting, etc.)
433 for the canvas areas.
436 track_canvas_event_box.add (track_canvas);
438 time_canvas_event_box.add (time_canvas_vbox);
439 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
441 edit_packer.set_col_spacings (0);
442 edit_packer.set_row_spacings (0);
443 edit_packer.set_homogeneous (false);
444 edit_packer.set_border_width (0);
445 edit_packer.set_name ("EditorWindow");
447 edit_packer.attach (edit_vscrollbar, 0, 1, 1, 3, FILL, FILL|EXPAND, 0, 0);
449 edit_packer.attach (time_button_frame, 0, 2, 0, 1, FILL, FILL, 0, 0);
450 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
452 edit_packer.attach (controls_layout, 1, 2, 1, 2, FILL, FILL|EXPAND, 0, 0);
453 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 2, FILL|EXPAND, FILL|EXPAND, 0, 0);
455 edit_packer.attach (zoom_box, 1, 2, 2, 3, FILL, FILL, 0, 0);
456 edit_packer.attach (edit_hscrollbar, 2, 3, 2, 3, FILL|EXPAND, FILL, 0, 0);
458 bottom_hbox.set_border_width (2);
459 bottom_hbox.set_spacing (3);
461 route_display_model = ListStore::create(route_display_columns);
462 route_list_display.set_model (route_display_model);
463 route_list_display.append_column (_("Show"), route_display_columns.visible);
464 route_list_display.append_column (_("Name"), route_display_columns.text);
465 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
466 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
467 route_list_display.set_headers_visible (true);
468 route_list_display.set_name ("TrackListDisplay");
469 route_list_display.get_selection()->set_mode (SELECTION_NONE);
470 route_list_display.set_reorderable (true);
471 route_list_display.set_size_request (100,-1);
473 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
474 route_list_visible_cell->property_activatable() = true;
475 route_list_visible_cell->property_radio() = false;
477 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
478 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
480 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
482 route_list_scroller.add (route_list_display);
483 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
485 group_model = ListStore::create(group_columns);
486 edit_group_display.set_model (group_model);
487 edit_group_display.append_column (_("Name"), group_columns.text);
488 edit_group_display.append_column (_("Active"), group_columns.is_active);
489 edit_group_display.append_column (_("Show"), group_columns.is_visible);
490 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
491 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
492 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
493 edit_group_display.get_column (0)->set_expand (true);
494 edit_group_display.get_column (1)->set_expand (false);
495 edit_group_display.get_column (2)->set_expand (false);
496 edit_group_display.set_headers_visible (true);
498 /* name is directly editable */
500 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
501 name_cell->property_editable() = true;
502 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
504 /* use checkbox for the active + visible columns */
506 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
507 active_cell->property_activatable() = true;
508 active_cell->property_radio() = false;
510 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
511 active_cell->property_activatable() = true;
512 active_cell->property_radio() = false;
514 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
516 edit_group_display.set_name ("EditGroupList");
517 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
518 edit_group_display.set_headers_visible (true);
519 edit_group_display.set_reorderable (false);
520 edit_group_display.set_rules_hint (true);
521 edit_group_display.set_size_request (75, -1);
523 edit_group_display_scroller.add (edit_group_display);
524 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
526 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
528 VBox* edit_group_display_packer = manage (new VBox());
529 HBox* edit_group_display_button_box = manage (new HBox());
530 edit_group_display_button_box->set_homogeneous (true);
532 Button* edit_group_add_button = manage (new Button ());
533 Button* edit_group_remove_button = manage (new Button ());
537 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
539 edit_group_add_button->add (*w);
541 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
543 edit_group_remove_button->add (*w);
545 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
546 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
548 edit_group_display_button_box->pack_start (*edit_group_add_button);
549 edit_group_display_button_box->pack_start (*edit_group_remove_button);
551 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
552 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
554 region_list_display.set_size_request (100, -1);
555 region_list_display.set_name ("RegionListDisplay");
557 region_list_model = TreeStore::create (region_list_columns);
558 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
559 region_list_model->set_sort_column (0, SORT_ASCENDING);
561 region_list_display.set_model (region_list_model);
562 region_list_display.append_column (_("Regions"), region_list_columns.name);
563 region_list_display.set_headers_visible (false);
565 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
567 TreeViewColumn* tv_col = region_list_display.get_column(0);
568 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
569 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
570 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
572 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
573 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
575 /* setup DnD handling */
577 list<TargetEntry> region_list_target_table;
579 region_list_target_table.push_back (TargetEntry ("text/plain"));
580 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
581 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
583 region_list_display.add_drop_targets (region_list_target_table);
584 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
586 region_list_scroller.add (region_list_display);
587 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
589 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
590 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
591 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
592 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
593 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
594 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
596 named_selection_scroller.add (named_selection_display);
597 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
599 named_selection_model = TreeStore::create (named_selection_columns);
600 named_selection_display.set_model (named_selection_model);
601 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
602 named_selection_display.set_headers_visible (false);
603 named_selection_display.set_size_request (100, -1);
604 named_selection_display.set_name ("NamedSelectionDisplay");
606 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
607 named_selection_display.set_size_request (100, -1);
608 named_selection_display.signal_button_release_event().connect (mem_fun(*this, &Editor::named_selection_display_button_release), false);
609 named_selection_display.signal_key_release_event().connect (mem_fun(*this, &Editor::named_selection_display_key_release), false);
610 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
614 snapshot_display_model = ListStore::create (snapshot_display_columns);
615 snapshot_display.set_model (snapshot_display_model);
616 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
617 snapshot_display.set_name ("SnapshotDisplay");
618 snapshot_display.set_size_request (75, -1);
619 snapshot_display.set_headers_visible (false);
620 snapshot_display.set_reorderable (false);
621 snapshot_display_scroller.add (snapshot_display);
622 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
624 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
625 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
629 nlabel = manage (new Label (_("Regions")));
630 nlabel->set_angle (-90);
631 the_notebook.append_page (region_list_scroller, *nlabel);
632 nlabel = manage (new Label (_("Tracks/Busses")));
633 nlabel->set_angle (-90);
634 the_notebook.append_page (route_list_scroller, *nlabel);
635 nlabel = manage (new Label (_("Snapshots")));
636 nlabel->set_angle (-90);
637 the_notebook.append_page (snapshot_display_scroller, *nlabel);
638 nlabel = manage (new Label (_("Edit Groups")));
639 nlabel->set_angle (-90);
640 the_notebook.append_page (*edit_group_display_packer, *nlabel);
641 nlabel = manage (new Label (_("Chunks")));
642 nlabel->set_angle (-90);
643 the_notebook.append_page (named_selection_scroller, *nlabel);
645 the_notebook.set_show_tabs (true);
646 the_notebook.set_scrollable (true);
647 the_notebook.popup_enable ();
648 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
650 post_maximal_editor_width = 0;
651 post_maximal_pane_position = 0;
652 edit_pane.pack1 (edit_packer, true, true);
653 edit_pane.pack2 (the_notebook, false, true);
655 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
657 top_hbox.pack_start (toolbar_frame, true, true);
659 HBox *hbox = manage (new HBox);
660 hbox->pack_start (edit_pane, true, true);
662 global_vpacker.pack_start (top_hbox, false, false);
663 global_vpacker.pack_start (*hbox, true, true);
665 global_hpacker.pack_start (global_vpacker, true, true);
667 set_name ("EditorWindow");
668 add_accel_group (ActionManager::ui_manager->get_accel_group());
670 vpacker.pack_end (global_hpacker, true, true);
672 /* register actions now so that set_state() can find them and set toggles/checks etc */
676 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
679 _playlist_selector = new PlaylistSelector();
680 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
682 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
686 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
687 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
689 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
690 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
692 nudge_forward_button.set_name ("TransportButton");
693 nudge_backward_button.set_name ("TransportButton");
695 fade_context_menu.set_name ("ArdourContextMenu");
697 /* icons, titles, WM stuff */
699 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
700 Glib::RefPtr<Gdk::Pixbuf> icon;
702 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
703 window_icons.push_back (icon);
705 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
706 window_icons.push_back (icon);
708 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
709 window_icons.push_back (icon);
711 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
712 window_icons.push_back (icon);
714 if (!window_icons.empty()) {
715 set_icon_list (window_icons);
716 set_default_icon_list (window_icons);
719 WindowTitle title(Glib::get_application_name());
720 title += _("Editor");
721 set_title (title.get_string());
722 set_wmclass (X_("ardour_editor"), "Ardour");
725 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
727 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
728 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
730 /* allow external control surfaces/protocols to do various things */
732 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
733 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
734 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
735 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
737 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
745 /* <CMT Additions> */
746 if(image_socket_listener)
748 if(image_socket_listener->is_connected())
750 image_socket_listener->close_connection() ;
753 delete image_socket_listener ;
754 image_socket_listener = 0 ;
756 /* </CMT Additions> */
760 Editor::add_toplevel_controls (Container& cont)
762 vpacker.pack_start (cont, false, false);
767 Editor::catch_vanishing_regionview (RegionView *rv)
769 /* note: the selection will take care of the vanishing
770 audioregionview by itself.
773 if (clicked_regionview == rv) {
774 clicked_regionview = 0;
777 if (entered_regionview == rv) {
778 set_entered_regionview (0);
783 Editor::set_entered_regionview (RegionView* rv)
785 if (rv == entered_regionview) {
789 if (entered_regionview) {
790 entered_regionview->exited ();
793 if ((entered_regionview = rv) != 0) {
794 entered_regionview->entered ();
799 Editor::set_entered_track (TimeAxisView* tav)
802 entered_track->exited ();
805 if ((entered_track = tav) != 0) {
806 entered_track->entered ();
811 Editor::show_window ()
816 /* now reset all audio_time_axis heights, because widgets might need
822 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
823 tv = (static_cast<TimeAxisView*>(*i));
829 Editor::tie_vertical_scrolling ()
831 double y1 = vertical_adjustment.get_value();
832 controls_layout.get_vadjustment()->set_value (y1);
833 playhead_cursor->set_y_axis(y1);
834 edit_cursor->set_y_axis(y1);
838 Editor::instant_save ()
840 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
845 session->add_instant_xml(get_state(), session->path());
847 Config->add_instant_xml(get_state(), get_user_ardour_path());
852 Editor::edit_cursor_clock_changed()
854 if (edit_cursor->current_frame != edit_cursor_clock.current_time()) {
855 edit_cursor->set_position (edit_cursor_clock.current_time());
861 Editor::zoom_adjustment_changed ()
867 double fpu = zoom_range_clock.current_duration() / canvas_width;
871 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
872 } else if (fpu > session->current_end_frame() / canvas_width) {
873 fpu = session->current_end_frame() / canvas_width;
874 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
881 Editor::control_scroll (float fraction)
883 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
889 double step = fraction * current_page_frames();
891 _control_scroll_target is an optional<T>
893 it acts like a pointer to an nframes_t, with a operator conversion to boolean
894 to check that it has a value
895 could possibly use playhead_cursor->current_frame to store
896 the value and a boolean in the class to know when it's out of date
898 if ( !_control_scroll_target )
900 _control_scroll_target = session->transport_frame();
901 _dragging_playhead = true;
904 if ((fraction < 0.0f) && (*_control_scroll_target < (nframes_t) fabs(step))) {
905 *_control_scroll_target = 0;
906 } else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
907 *_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
909 *_control_scroll_target += (nframes_t) floor (step);
912 /* move visuals, we'll catch up with it later */
914 playhead_cursor->set_position (*_control_scroll_target);
915 UpdateAllTransportClocks (*_control_scroll_target);
917 if (*_control_scroll_target > (current_page_frames() / 2)) {
918 /* try to center PH in window */
919 reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
925 Now we do a timeout to actually bring the session to the right place
926 according to the playhead. This is to avoid reading disk buffers on every
927 call to control_scroll, which is driven by ScrollTimeline and therefore
928 probably by a control surface wheel which can generate lots of events.
930 /* cancel the existing timeout */
932 control_scroll_connection.disconnect ();
934 /* add the next timeout */
936 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), *_control_scroll_target), 250);
940 Editor::deferred_control_scroll (nframes_t target)
942 session->request_locate (*_control_scroll_target, session->transport_rolling());
943 // reset for next stream
944 _control_scroll_target = boost::none;
945 _dragging_playhead = false;
950 Editor::on_realize ()
952 Window::on_realize ();
957 Editor::start_scrolling ()
959 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
960 (mem_fun(*this, &Editor::update_current_screen));
964 Editor::stop_scrolling ()
966 scroll_connection.disconnect ();
970 Editor::map_position_change (nframes_t frame)
972 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
974 if (session == 0 || !_follow_playhead) {
978 center_screen (frame);
979 playhead_cursor->set_position (frame);
983 Editor::center_screen (nframes_t frame)
985 double page = canvas_width * frames_per_unit;
987 /* if we're off the page, then scroll.
990 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
991 center_screen_internal (frame, page);
996 Editor::center_screen_internal (nframes_t frame, float page)
1001 frame -= (nframes_t) page;
1006 reset_x_origin (frame);
1010 Editor::handle_new_duration ()
1012 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1014 nframes_t new_end = session->get_maximum_extent() + (nframes_t) floorf (current_page_frames() * 0.10f);
1016 if (new_end > last_canvas_frame) {
1017 last_canvas_frame = new_end;
1018 horizontal_adjustment.set_upper (last_canvas_frame / frames_per_unit);
1019 reset_scrolling_region ();
1022 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1026 Editor::update_title_s (const string & snap_name)
1028 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1034 Editor::update_title ()
1036 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1039 bool dirty = session->dirty();
1041 string session_name;
1043 if (session->snap_name() != session->name()) {
1044 session_name = session->snap_name();
1046 session_name = session->name();
1050 session_name = "*" + session_name;
1053 WindowTitle title(session_name);
1054 title += Glib::get_application_name();
1055 set_title (title.get_string());
1060 Editor::connect_to_session (Session *t)
1064 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1067 /* catch up with the playhead */
1069 session->request_locate (playhead_cursor->current_frame);
1071 if (first_action_message) {
1072 first_action_message->hide();
1077 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1078 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1080 /* These signals can all be emitted by a non-GUI thread. Therefore the
1081 handlers for them must not attempt to directly interact with the GUI,
1082 but use Gtkmm2ext::UI::instance()->call_slot();
1085 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1086 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1087 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1088 session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::handle_new_audio_region)));
1089 session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::handle_audio_region_removed)));
1090 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1091 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1092 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1093 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1094 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1095 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1096 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1097 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1098 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1100 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1102 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1104 edit_groups_changed ();
1106 edit_cursor_clock.set_session (session);
1107 zoom_range_clock.set_session (session);
1108 _playlist_selector->set_session (session);
1109 nudge_clock.set_session (session);
1112 if (analysis_window != 0)
1113 analysis_window->set_session (session);
1116 Location* loc = session->locations()->auto_loop_location();
1118 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1119 if (loc->start() == loc->end()) {
1120 loc->set_end (loc->start() + 1);
1122 session->locations()->add (loc, false);
1123 session->set_auto_loop_location (loc);
1126 loc->set_name (_("Loop"));
1129 loc = session->locations()->auto_punch_location();
1131 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1132 if (loc->start() == loc->end()) {
1133 loc->set_end (loc->start() + 1);
1135 session->locations()->add (loc, false);
1136 session->set_auto_punch_location (loc);
1139 loc->set_name (_("Punch"));
1142 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1144 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1146 refresh_location_display ();
1147 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1148 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1149 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1150 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1151 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1153 handle_new_duration ();
1155 redisplay_regions ();
1156 redisplay_named_selections ();
1157 redisplay_snapshots ();
1159 initial_route_list_display ();
1161 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1162 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1165 restore_ruler_visibility ();
1166 //tempo_map_changed (Change (0));
1167 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1171 /* don't show master bus in a new session */
1173 if (ARDOUR_UI::instance()->session_is_new ()) {
1175 TreeModel::Children rows = route_display_model->children();
1176 TreeModel::Children::iterator i;
1178 no_route_list_redisplay = true;
1180 for (i = rows.begin(); i != rows.end(); ++i) {
1181 TimeAxisView *tv = (*i)[route_display_columns.tv];
1182 AudioTimeAxisView *atv;
1184 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1185 if (atv->route()->master()) {
1186 route_list_display.get_selection()->unselect (i);
1191 no_route_list_redisplay = false;
1192 redisplay_route_list ();
1195 /* register for undo history */
1197 session->register_with_memento_command_factory(_id, this);
1201 Editor::build_cursors ()
1203 using namespace Gdk;
1205 Gdk::Color mbg ("#000000" ); /* Black */
1206 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1209 RefPtr<Bitmap> source, mask;
1210 source = Bitmap::create (mag_bits, mag_width, mag_height);
1211 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1212 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1215 Gdk::Color fbg ("#ffffff" );
1216 Gdk::Color ffg ("#000000" );
1219 RefPtr<Bitmap> source, mask;
1221 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1222 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1223 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1227 RefPtr<Bitmap> source, mask;
1228 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1229 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1230 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1233 grabber_cursor = new Gdk::Cursor (HAND2);
1234 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1235 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1236 selector_cursor = new Gdk::Cursor (XTERM);
1237 time_fx_cursor = new Gdk::Cursor (SIZING);
1238 wait_cursor = new Gdk::Cursor (WATCH);
1239 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1243 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1245 using namespace Menu_Helpers;
1246 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1249 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1253 MenuList& items (fade_context_menu.items());
1257 switch (item_type) {
1259 case FadeInHandleItem:
1260 if (arv->audio_region()->fade_in_active()) {
1261 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_in_active), false)));
1263 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_in_active), true)));
1266 items.push_back (SeparatorElem());
1268 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1269 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1270 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
1271 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
1272 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
1276 case FadeOutHandleItem:
1277 if (arv->audio_region()->fade_out_active()) {
1278 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_out_active), false)));
1280 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_out_active), true)));
1283 items.push_back (SeparatorElem());
1285 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1286 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1287 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
1288 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
1289 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
1294 fatal << _("programming error: ")
1295 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1300 fade_context_menu.popup (button, time);
1304 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes_t frame)
1306 using namespace Menu_Helpers;
1307 Menu* (Editor::*build_menu_function)(nframes_t);
1310 switch (item_type) {
1312 case RegionViewName:
1313 case RegionViewNameHighlight:
1314 if (with_selection) {
1315 build_menu_function = &Editor::build_track_selection_context_menu;
1317 build_menu_function = &Editor::build_track_region_context_menu;
1322 if (with_selection) {
1323 build_menu_function = &Editor::build_track_selection_context_menu;
1325 build_menu_function = &Editor::build_track_context_menu;
1329 case CrossfadeViewItem:
1330 build_menu_function = &Editor::build_track_crossfade_context_menu;
1334 if (clicked_audio_trackview->get_diskstream()) {
1335 build_menu_function = &Editor::build_track_context_menu;
1337 build_menu_function = &Editor::build_track_bus_context_menu;
1342 /* probably shouldn't happen but if it does, we don't care */
1346 menu = (this->*build_menu_function)(frame);
1347 menu->set_name ("ArdourContextMenu");
1349 /* now handle specific situations */
1351 switch (item_type) {
1353 case RegionViewName:
1354 case RegionViewNameHighlight:
1355 if (!with_selection) {
1356 if (region_edit_menu_split_item) {
1357 if (clicked_regionview && clicked_regionview->region()->covers (edit_cursor->current_frame)) {
1358 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
1360 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
1364 if (region_edit_menu_split_multichannel_item) {
1365 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1366 // GTK2FIX find the action, change its sensitivity
1367 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1369 // GTK2FIX see above
1370 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1379 case CrossfadeViewItem:
1386 /* probably shouldn't happen but if it does, we don't care */
1390 if (item_type != SelectionItem && clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
1392 /* Bounce to disk */
1394 using namespace Menu_Helpers;
1395 MenuList& edit_items = menu->items();
1397 edit_items.push_back (SeparatorElem());
1399 switch (clicked_audio_trackview->audio_track()->freeze_state()) {
1400 case AudioTrack::NoFreeze:
1401 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1404 case AudioTrack::Frozen:
1405 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1408 case AudioTrack::UnFrozen:
1409 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1415 menu->popup (button, time);
1419 Editor::build_track_context_menu (nframes_t ignored)
1421 using namespace Menu_Helpers;
1423 MenuList& edit_items = track_context_menu.items();
1426 add_dstream_context_items (edit_items);
1427 return &track_context_menu;
1431 Editor::build_track_bus_context_menu (nframes_t ignored)
1433 using namespace Menu_Helpers;
1435 MenuList& edit_items = track_context_menu.items();
1438 add_bus_context_items (edit_items);
1439 return &track_context_menu;
1443 Editor::build_track_region_context_menu (nframes_t frame)
1445 using namespace Menu_Helpers;
1446 MenuList& edit_items = track_region_context_menu.items();
1449 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1452 boost::shared_ptr<Diskstream> ds;
1453 boost::shared_ptr<Playlist> pl;
1455 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1456 Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)frame * ds->speed()));
1457 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1458 add_region_context_items (atv->audio_view(), (*i), edit_items);
1464 add_dstream_context_items (edit_items);
1466 return &track_region_context_menu;
1470 Editor::build_track_crossfade_context_menu (nframes_t frame)
1472 using namespace Menu_Helpers;
1473 MenuList& edit_items = track_crossfade_context_menu.items();
1474 edit_items.clear ();
1476 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1479 boost::shared_ptr<Diskstream> ds;
1480 boost::shared_ptr<Playlist> pl;
1481 boost::shared_ptr<AudioPlaylist> apl;
1483 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1485 Playlist::RegionList* regions = pl->regions_at (frame);
1486 AudioPlaylist::Crossfades xfades;
1488 apl->crossfades_at (frame, xfades);
1490 bool many = xfades.size() > 1;
1492 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1493 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1496 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1497 add_region_context_items (atv->audio_view(), (*i), edit_items);
1504 add_dstream_context_items (edit_items);
1506 return &track_crossfade_context_menu;
1511 Editor::analyze_region_selection()
1513 if (analysis_window == 0) {
1514 analysis_window = new AnalysisWindow();
1517 analysis_window->set_session(session);
1519 analysis_window->show_all();
1522 analysis_window->set_regionmode();
1523 analysis_window->analyze();
1525 analysis_window->present();
1529 Editor::analyze_range_selection()
1531 if (analysis_window == 0) {
1532 analysis_window = new AnalysisWindow();
1535 analysis_window->set_session(session);
1537 analysis_window->show_all();
1540 analysis_window->set_rangemode();
1541 analysis_window->analyze();
1543 analysis_window->present();
1545 #endif /* FFT_ANALYSIS */
1550 Editor::build_track_selection_context_menu (nframes_t ignored)
1552 using namespace Menu_Helpers;
1553 MenuList& edit_items = track_selection_context_menu.items();
1554 edit_items.clear ();
1556 add_selection_context_items (edit_items);
1557 // edit_items.push_back (SeparatorElem());
1558 // add_dstream_context_items (edit_items);
1560 return &track_selection_context_menu;
1564 Editor::add_crossfade_context_items (AudioStreamView* view, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1566 using namespace Menu_Helpers;
1567 Menu *xfade_menu = manage (new Menu);
1568 MenuList& items = xfade_menu->items();
1569 xfade_menu->set_name ("ArdourContextMenu");
1572 if (xfade->active()) {
1578 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1579 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1581 if (xfade->can_follow_overlap()) {
1583 if (xfade->following_overlap()) {
1584 str = _("Convert to short");
1586 str = _("Convert to full");
1589 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1593 str = xfade->out()->name();
1595 str += xfade->in()->name();
1597 str = _("Crossfade");
1600 edit_items.push_back (MenuElem (str, *xfade_menu));
1601 edit_items.push_back (SeparatorElem());
1605 Editor::xfade_edit_left_region ()
1607 if (clicked_crossfadeview) {
1608 clicked_crossfadeview->left_view.show_region_editor ();
1613 Editor::xfade_edit_right_region ()
1615 if (clicked_crossfadeview) {
1616 clicked_crossfadeview->right_view.show_region_editor ();
1621 Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1623 using namespace Menu_Helpers;
1624 Menu *region_menu = manage (new Menu);
1625 MenuList& items = region_menu->items();
1626 region_menu->set_name ("ArdourContextMenu");
1628 boost::shared_ptr<AudioRegion> ar;
1631 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1634 /* when this particular menu pops up, make the relevant region
1638 region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1640 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1641 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1642 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1643 items.push_back (SeparatorElem());
1644 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_cursor)));
1645 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1646 items.push_back (SeparatorElem());
1648 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::audition_selected_region)));
1649 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1650 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1653 items.push_back (MenuElem (_("Analyze region"), mem_fun(*this, &Editor::analyze_region_selection)));
1656 items.push_back (SeparatorElem());
1658 sigc::connection fooc;
1660 items.push_back (CheckMenuElem (_("Lock")));
1661 region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1662 fooc = region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
1663 if (region->locked()) {
1665 region_lock_item->set_active();
1668 items.push_back (CheckMenuElem (_("Mute")));
1669 region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1670 fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
1671 if (region->muted()) {
1673 region_mute_item->set_active();
1677 items.push_back (CheckMenuElem (_("Opaque")));
1678 region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1679 fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
1680 if (region->opaque()) {
1682 region_opaque_item->set_active();
1686 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1687 if (region->at_natural_position()) {
1688 items.back().set_sensitive (false);
1691 items.push_back (SeparatorElem());
1695 RegionView* rv = sv->find_view (ar);
1696 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1698 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
1700 items.push_back (CheckMenuElem (_("Envelope Visible")));
1701 region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1702 fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
1703 if (arv->envelope_visible()) {
1705 region_envelope_visible_item->set_active (true);
1709 items.push_back (CheckMenuElem (_("Envelope Active")));
1710 region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1711 fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
1713 if (ar->envelope_active()) {
1715 region_envelope_active_item->set_active (true);
1719 items.push_back (SeparatorElem());
1721 if (ar->scale_amplitude() != 1.0f) {
1722 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1724 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1727 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1728 items.push_back (SeparatorElem());
1731 /* range related stuff */
1733 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1734 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_audio_region)));
1735 items.push_back (SeparatorElem());
1739 Menu *nudge_menu = manage (new Menu());
1740 MenuList& nudge_items = nudge_menu->items();
1741 nudge_menu->set_name ("ArdourContextMenu");
1743 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1744 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1745 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1746 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1748 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1749 items.push_back (SeparatorElem());
1751 Menu *trim_menu = manage (new Menu);
1752 MenuList& trim_items = trim_menu->items();
1753 trim_menu->set_name ("ArdourContextMenu");
1755 trim_items.push_back (MenuElem (_("Start to edit cursor"), mem_fun(*this, &Editor::trim_region_from_edit_cursor)));
1756 trim_items.push_back (MenuElem (_("Edit cursor to end"), mem_fun(*this, &Editor::trim_region_to_edit_cursor)));
1758 items.push_back (MenuElem (_("Trim"), *trim_menu));
1759 items.push_back (SeparatorElem());
1761 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1762 region_edit_menu_split_item = &items.back();
1764 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1765 region_edit_menu_split_multichannel_item = &items.back();
1767 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1768 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1769 items.push_back (SeparatorElem());
1770 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1772 /* OK, stick the region submenu at the top of the list, and then add
1776 /* we have to hack up the region name because "_" has a special
1777 meaning for menu titles.
1780 string::size_type pos = 0;
1781 string menu_item_name = region->name();
1783 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1784 menu_item_name.replace (pos, 1, "__");
1788 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1789 edit_items.push_back (SeparatorElem());
1793 Editor::add_selection_context_items (Menu_Helpers::MenuList& items)
1795 using namespace Menu_Helpers;
1797 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1798 items.push_back (MenuElem (_("Loop range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
1801 items.push_back (SeparatorElem());
1802 items.push_back (MenuElem (_("Analyze range"), mem_fun(*this, &Editor::analyze_range_selection)));
1805 items.push_back (SeparatorElem());
1806 items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
1807 items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
1809 items.push_back (SeparatorElem());
1810 items.push_back (MenuElem (_("Convert to region in-place"), mem_fun(*this, &Editor::separate_region_from_selection)));
1811 items.push_back (MenuElem (_("Convert to region in region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1813 items.push_back (SeparatorElem());
1814 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1816 items.push_back (SeparatorElem());
1817 items.push_back (MenuElem (_("Set loop from selection"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
1818 items.push_back (MenuElem (_("Set punch from selection"), mem_fun(*this, &Editor::set_punch_from_selection)));
1820 items.push_back (SeparatorElem());
1821 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
1822 items.push_back (SeparatorElem());
1823 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1824 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1825 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1826 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::create_named_selection)));
1827 items.push_back (SeparatorElem());
1828 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1829 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1833 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1835 using namespace Menu_Helpers;
1839 Menu *play_menu = manage (new Menu);
1840 MenuList& play_items = play_menu->items();
1841 play_menu->set_name ("ArdourContextMenu");
1843 play_items.push_back (MenuElem (_("Play from edit cursor"), mem_fun(*this, &Editor::play_from_edit_cursor)));
1844 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1845 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1846 play_items.push_back (SeparatorElem());
1847 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1849 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1853 Menu *select_menu = manage (new Menu);
1854 MenuList& select_items = select_menu->items();
1855 select_menu->set_name ("ArdourContextMenu");
1857 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1858 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1859 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1860 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1861 select_items.push_back (SeparatorElem());
1862 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1863 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1864 select_items.push_back (SeparatorElem());
1865 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1866 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1867 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1868 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1869 select_items.push_back (MenuElem (_("Select all between cursors"), bind (mem_fun(*this, &Editor::select_all_selectables_between_cursors), playhead_cursor, edit_cursor)));
1870 select_items.push_back (SeparatorElem());
1872 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1876 Menu *cutnpaste_menu = manage (new Menu);
1877 MenuList& cutnpaste_items = cutnpaste_menu->items();
1878 cutnpaste_menu->set_name ("ArdourContextMenu");
1880 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1881 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1882 cutnpaste_items.push_back (MenuElem (_("Paste at edit cursor"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1883 cutnpaste_items.push_back (MenuElem (_("Paste at mouse"), mem_fun(*this, &Editor::mouse_paste)));
1885 cutnpaste_items.push_back (SeparatorElem());
1887 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1888 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
1890 cutnpaste_items.push_back (SeparatorElem());
1892 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
1894 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
1896 /* Adding new material */
1898 edit_items.push_back (SeparatorElem());
1899 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
1900 edit_items.push_back (MenuElem (_("Insert Existing Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
1904 Menu *nudge_menu = manage (new Menu());
1905 MenuList& nudge_items = nudge_menu->items();
1906 nudge_menu->set_name ("ArdourContextMenu");
1908 edit_items.push_back (SeparatorElem());
1909 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1910 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1911 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1912 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1914 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1918 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
1920 using namespace Menu_Helpers;
1924 Menu *play_menu = manage (new Menu);
1925 MenuList& play_items = play_menu->items();
1926 play_menu->set_name ("ArdourContextMenu");
1928 play_items.push_back (MenuElem (_("Play from edit cursor"), mem_fun(*this, &Editor::play_from_edit_cursor)));
1929 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1930 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1934 Menu *select_menu = manage (new Menu);
1935 MenuList& select_items = select_menu->items();
1936 select_menu->set_name ("ArdourContextMenu");
1938 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1939 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1940 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1941 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1942 select_items.push_back (SeparatorElem());
1943 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1944 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1945 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1946 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1948 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1952 Menu *cutnpaste_menu = manage (new Menu);
1953 MenuList& cutnpaste_items = cutnpaste_menu->items();
1954 cutnpaste_menu->set_name ("ArdourContextMenu");
1956 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1957 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1958 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1960 Menu *nudge_menu = manage (new Menu());
1961 MenuList& nudge_items = nudge_menu->items();
1962 nudge_menu->set_name ("ArdourContextMenu");
1964 edit_items.push_back (SeparatorElem());
1965 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1966 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1967 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1968 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1970 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1973 /* CURSOR SETTING AND MARKS AND STUFF */
1976 Editor::set_snap_to (SnapType st)
1979 string str = snap_type_strings[(int) st];
1981 if (str != snap_type_selector.get_active_text()) {
1982 snap_type_selector.set_active_text (str);
1987 switch (snap_type) {
1988 case SnapToAThirtysecondBeat:
1989 case SnapToASixteenthBeat:
1990 case SnapToAEighthBeat:
1991 case SnapToAQuarterBeat:
1992 case SnapToAThirdBeat:
1993 update_tempo_based_rulers ();
2001 Editor::set_snap_mode (SnapMode mode)
2004 string str = snap_mode_strings[(int)mode];
2006 if (str != snap_mode_selector.get_active_text ()) {
2007 snap_mode_selector.set_active_text (str);
2014 Editor::set_state (const XMLNode& node)
2016 const XMLProperty* prop;
2018 int x, y, xoff, yoff;
2021 if ((prop = node.property ("id")) != 0) {
2022 _id = prop->value ();
2025 if ((geometry = find_named_node (node, "geometry")) == 0) {
2027 g.base_width = default_width;
2028 g.base_height = default_height;
2036 g.base_width = atoi(geometry->property("x_size")->value());
2037 g.base_height = atoi(geometry->property("y_size")->value());
2038 x = atoi(geometry->property("x_pos")->value());
2039 y = atoi(geometry->property("y_pos")->value());
2040 xoff = atoi(geometry->property("x_off")->value());
2041 yoff = atoi(geometry->property("y_off")->value());
2044 set_default_size (g.base_width, g.base_height);
2047 if (session && (prop = node.property ("playhead"))) {
2048 nframes_t pos = atol (prop->value().c_str());
2049 playhead_cursor->set_position (pos);
2051 playhead_cursor->set_position (0);
2053 /* reset_x_origin() doesn't work right here, since the old
2054 position may be zero already, and it does nothing in such
2059 horizontal_adjustment.set_value (0);
2062 if (session && (prop = node.property ("edit-cursor"))) {
2063 nframes_t pos = atol (prop->value().c_str());
2064 edit_cursor->set_position (pos);
2066 edit_cursor->set_position (0);
2069 if ((prop = node.property ("mixer-width"))) {
2070 editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
2073 if ((prop = node.property ("zoom-focus"))) {
2074 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2077 if ((prop = node.property ("zoom"))) {
2078 reset_zoom (PBD::atof (prop->value()));
2081 if ((prop = node.property ("snap-to"))) {
2082 set_snap_to ((SnapType) atoi (prop->value()));
2085 if ((prop = node.property ("snap-mode"))) {
2086 set_snap_mode ((SnapMode) atoi (prop->value()));
2089 if ((prop = node.property ("mouse-mode"))) {
2090 MouseMode m = str2mousemode(prop->value());
2091 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2092 set_mouse_mode (m, true);
2094 mouse_mode = MouseGain; /* lie, to force the mode switch */
2095 set_mouse_mode (MouseObject, true);
2098 if ((prop = node.property ("show-waveforms"))) {
2099 bool yn = (prop->value() == "yes");
2100 _show_waveforms = !yn;
2101 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
2103 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2104 /* do it twice to force the change */
2105 tact->set_active (!yn);
2106 tact->set_active (yn);
2110 if ((prop = node.property ("show-waveforms-recording"))) {
2111 bool yn = (prop->value() == "yes");
2112 _show_waveforms_recording = !yn;
2113 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2115 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2116 /* do it twice to force the change */
2117 tact->set_active (!yn);
2118 tact->set_active (yn);
2122 if ((prop = node.property ("show-measures"))) {
2123 bool yn = (prop->value() == "yes");
2124 _show_measures = !yn;
2125 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2127 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2128 /* do it twice to force the change */
2129 tact->set_active (!yn);
2130 tact->set_active (yn);
2134 if ((prop = node.property ("follow-playhead"))) {
2135 bool yn = (prop->value() == "yes");
2136 set_follow_playhead (yn);
2137 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2139 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2140 if (tact->get_active() != yn) {
2141 tact->set_active (yn);
2146 if ((prop = node.property ("region-list-sort-type"))) {
2147 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2148 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2151 if ((prop = node.property ("xfades-visible"))) {
2152 bool yn = (prop->value() == "yes");
2153 _xfade_visibility = !yn;
2154 // set_xfade_visibility (yn);
2157 if ((prop = node.property ("show-editor-mixer"))) {
2159 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2162 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2163 bool yn = (prop->value() == X_("yes"));
2165 /* do it twice to force the change */
2167 tact->set_active (!yn);
2168 tact->set_active (yn);
2177 Editor::get_state ()
2179 XMLNode* node = new XMLNode ("Editor");
2182 _id.print (buf, sizeof (buf));
2183 node->add_property ("id", buf);
2185 if (is_realized()) {
2186 Glib::RefPtr<Gdk::Window> win = get_window();
2188 int x, y, xoff, yoff, width, height;
2189 win->get_root_origin(x, y);
2190 win->get_position(xoff, yoff);
2191 win->get_size(width, height);
2193 XMLNode* geometry = new XMLNode ("geometry");
2195 snprintf(buf, sizeof(buf), "%d", width);
2196 geometry->add_property("x_size", string(buf));
2197 snprintf(buf, sizeof(buf), "%d", height);
2198 geometry->add_property("y_size", string(buf));
2199 snprintf(buf, sizeof(buf), "%d", x);
2200 geometry->add_property("x_pos", string(buf));
2201 snprintf(buf, sizeof(buf), "%d", y);
2202 geometry->add_property("y_pos", string(buf));
2203 snprintf(buf, sizeof(buf), "%d", xoff);
2204 geometry->add_property("x_off", string(buf));
2205 snprintf(buf, sizeof(buf), "%d", yoff);
2206 geometry->add_property("y_off", string(buf));
2207 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2208 geometry->add_property("edit_pane_pos", string(buf));
2210 node->add_child_nocopy (*geometry);
2213 maybe_add_mixer_strip_width (*node);
2215 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2216 node->add_property ("zoom-focus", buf);
2217 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2218 node->add_property ("zoom", buf);
2219 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2220 node->add_property ("snap-to", buf);
2221 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2222 node->add_property ("snap-mode", buf);
2224 snprintf (buf, sizeof (buf), "%" PRIu32, playhead_cursor->current_frame);
2225 node->add_property ("playhead", buf);
2226 snprintf (buf, sizeof (buf), "%" PRIu32, edit_cursor->current_frame);
2227 node->add_property ("edit-cursor", buf);
2229 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2230 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2231 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2232 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2233 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2234 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2235 node->add_property ("mouse-mode", enum2str(mouse_mode));
2237 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2239 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2240 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2249 Editor::trackview_by_y_position (double y)
2251 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2255 if ((tv = (*iter)->covers_y_position (y)) != 0) {
2264 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
2266 Location* before = 0;
2267 Location* after = 0;
2273 const nframes64_t one_second = session->frame_rate();
2274 const nframes64_t one_minute = session->frame_rate() * 60;
2275 const nframes64_t one_smpte_second = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
2276 nframes64_t one_smpte_minute = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
2277 nframes64_t presnap = start;
2279 switch (snap_type) {
2285 start = (nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2287 start = (nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2291 case SnapToSMPTEFrame:
2292 if (fmod((double)start, (double)session->frames_per_smpte_frame()) > (session->frames_per_smpte_frame() / 2)) {
2293 start = (nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2295 start = (nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2299 case SnapToSMPTESeconds:
2300 if (session->smpte_offset_negative())
2302 start += session->smpte_offset ();
2304 start -= session->smpte_offset ();
2306 if (start % one_smpte_second > one_smpte_second / 2) {
2307 start = (nframes_t) ceil ((double) start / one_smpte_second) * one_smpte_second;
2309 start = (nframes_t) floor ((double) start / one_smpte_second) * one_smpte_second;
2312 if (session->smpte_offset_negative())
2314 start -= session->smpte_offset ();
2316 start += session->smpte_offset ();
2320 case SnapToSMPTEMinutes:
2321 if (session->smpte_offset_negative())
2323 start += session->smpte_offset ();
2325 start -= session->smpte_offset ();
2327 if (start % one_smpte_minute > one_smpte_minute / 2) {
2328 start = (nframes_t) ceil ((double) start / one_smpte_minute) * one_smpte_minute;
2330 start = (nframes_t) floor ((double) start / one_smpte_minute) * one_smpte_minute;
2332 if (session->smpte_offset_negative())
2334 start -= session->smpte_offset ();
2336 start += session->smpte_offset ();
2341 if (start % one_second > one_second / 2) {
2342 start = (nframes_t) ceil ((double) start / one_second) * one_second;
2344 start = (nframes_t) floor ((double) start / one_second) * one_second;
2349 if (start % one_minute > one_minute / 2) {
2350 start = (nframes_t) ceil ((double) start / one_minute) * one_minute;
2352 start = (nframes_t) floor ((double) start / one_minute) * one_minute;
2357 start = session->tempo_map().round_to_bar (start, direction);
2361 start = session->tempo_map().round_to_beat (start, direction);
2364 case SnapToAThirtysecondBeat:
2365 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2368 case SnapToASixteenthBeat:
2369 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2372 case SnapToAEighthBeat:
2373 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2376 case SnapToAQuarterBeat:
2377 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2380 case SnapToAThirdBeat:
2381 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2384 case SnapToEditCursor:
2385 start = edit_cursor->current_frame;
2393 before = session->locations()->first_location_before (start);
2394 after = session->locations()->first_location_after (start);
2396 if (direction < 0) {
2398 start = before->start();
2402 } else if (direction > 0) {
2404 start = after->start();
2406 start = session->current_end_frame();
2411 /* find nearest of the two */
2412 if ((start - before->start()) < (after->start() - start)) {
2413 start = before->start();
2415 start = after->start();
2418 start = before->start();
2421 start = after->start();
2428 case SnapToRegionStart:
2429 case SnapToRegionEnd:
2430 case SnapToRegionSync:
2431 case SnapToRegionBoundary:
2432 if (!region_boundary_cache.empty()) {
2433 vector<nframes_t>::iterator i;
2435 if (direction > 0) {
2436 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2438 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2441 if (i != region_boundary_cache.end()) {
2444 start = region_boundary_cache.back();
2450 switch (snap_mode) {
2456 if (presnap > start) {
2457 if (presnap > (start + unit_to_frame(snap_threshold))) {
2461 } else if (presnap < start) {
2462 if (presnap < (start - unit_to_frame(snap_threshold))) {
2474 Editor::setup_toolbar ()
2478 const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
2481 /* Mode Buttons (tool selection) */
2483 vector<ToggleButton *> mouse_mode_buttons;
2485 mouse_move_button.add (*(manage (new Image (::get_icon("tool_object")))));
2486 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2487 mouse_mode_buttons.push_back (&mouse_move_button);
2488 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2489 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2490 mouse_mode_buttons.push_back (&mouse_select_button);
2491 mouse_gain_button.add (*(manage (new Image (::get_icon("tool_gain")))));
2492 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2493 mouse_mode_buttons.push_back (&mouse_gain_button);
2494 mouse_zoom_button.add (*(manage (new Image (::get_icon("tool_zoom")))));
2495 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2496 mouse_mode_buttons.push_back (&mouse_zoom_button);
2497 mouse_timefx_button.add (*(manage (new Image (::get_icon("tool_stretch")))));
2498 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2499 mouse_mode_buttons.push_back (&mouse_timefx_button);
2500 mouse_audition_button.add (*(manage (new Image (::get_icon("tool_audition")))));
2501 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2502 mouse_mode_buttons.push_back (&mouse_audition_button);
2504 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2506 HBox* mode_box = manage(new HBox);
2507 mode_box->set_border_width (2);
2508 mode_box->set_spacing(4);
2509 mouse_mode_button_box.set_spacing(1);
2510 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2511 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2512 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2513 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2514 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2515 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2516 mouse_mode_button_box.set_homogeneous(true);
2518 vector<string> edit_mode_strings;
2519 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2520 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2522 edit_mode_selector.set_name ("EditModeSelector");
2523 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, longest (edit_mode_strings).c_str(), 2+FUDGE, 10);
2524 set_popdown_strings (edit_mode_selector, edit_mode_strings);
2525 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2527 mode_box->pack_start(edit_mode_selector);
2528 mode_box->pack_start(mouse_mode_button_box);
2530 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2531 mouse_mode_tearoff->set_name ("MouseModeBase");
2533 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2534 &mouse_mode_tearoff->tearoff_window()));
2535 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2536 &mouse_mode_tearoff->tearoff_window(), 1));
2537 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2538 &mouse_mode_tearoff->tearoff_window()));
2539 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2540 &mouse_mode_tearoff->tearoff_window(), 1));
2542 mouse_move_button.set_name ("MouseModeButton");
2543 mouse_select_button.set_name ("MouseModeButton");
2544 mouse_gain_button.set_name ("MouseModeButton");
2545 mouse_zoom_button.set_name ("MouseModeButton");
2546 mouse_timefx_button.set_name ("MouseModeButton");
2547 mouse_audition_button.set_name ("MouseModeButton");
2549 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
2550 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
2551 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
2552 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
2553 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
2554 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
2556 mouse_move_button.unset_flags (CAN_FOCUS);
2557 mouse_select_button.unset_flags (CAN_FOCUS);
2558 mouse_gain_button.unset_flags (CAN_FOCUS);
2559 mouse_zoom_button.unset_flags (CAN_FOCUS);
2560 mouse_timefx_button.unset_flags (CAN_FOCUS);
2561 mouse_audition_button.unset_flags (CAN_FOCUS);
2563 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2564 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2566 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2567 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2568 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2569 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2570 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2572 // mouse_move_button.set_active (true);
2577 zoom_box.set_spacing (1);
2578 zoom_box.set_border_width (2);
2580 zoom_in_button.set_name ("EditorTimeButton");
2581 zoom_in_button.set_size_request(-1,16);
2582 zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in")))));
2583 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2584 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2586 zoom_out_button.set_name ("EditorTimeButton");
2587 zoom_out_button.set_size_request(-1,16);
2588 zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out")))));
2589 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2590 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2592 zoom_out_full_button.set_name ("EditorTimeButton");
2593 zoom_out_full_button.set_size_request(-1,16);
2594 zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full")))));
2595 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2596 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2598 zoom_focus_selector.set_name ("ZoomFocusSelector");
2599 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Edit Cursor", FUDGE, 0);
2600 set_popdown_strings (zoom_focus_selector, zoom_focus_strings);
2601 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2602 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
2604 zoom_box.pack_start (zoom_focus_selector, true, true);
2605 zoom_box.pack_start (zoom_out_button, false, false);
2606 zoom_box.pack_start (zoom_in_button, false, false);
2607 zoom_box.pack_start (zoom_out_full_button, false, false);
2609 /* Edit Cursor / Snap */
2611 snap_box.set_spacing (1);
2612 snap_box.set_border_width (2);
2614 snap_type_selector.set_name ("SnapTypeSelector");
2615 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, "SMPTE Seconds", 2+FUDGE, 10);
2616 set_popdown_strings (snap_type_selector, snap_type_strings);
2617 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2618 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Unit to snap cursors and ranges to"));
2620 snap_mode_selector.set_name ("SnapModeSelector");
2621 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, "Magnetic Snap", 2+FUDGE, 10);
2622 set_popdown_strings (snap_mode_selector, snap_mode_strings);
2623 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2625 snap_box.pack_start (edit_cursor_clock, false, false);
2626 snap_box.pack_start (snap_mode_selector, false, false);
2627 snap_box.pack_start (snap_type_selector, false, false);
2632 HBox *nudge_box = manage (new HBox);
2633 nudge_box->set_spacing(1);
2634 nudge_box->set_border_width (2);
2636 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2637 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2639 nudge_box->pack_start (nudge_backward_button, false, false);
2640 nudge_box->pack_start (nudge_forward_button, false, false);
2641 nudge_box->pack_start (nudge_clock, false, false);
2644 /* Pack everything in... */
2646 HBox* hbox = new HBox;
2647 hbox->set_spacing(10);
2649 tools_tearoff = new TearOff (*hbox);
2650 tools_tearoff->set_name ("MouseModeBase");
2652 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2653 &tools_tearoff->tearoff_window()));
2654 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2655 &tools_tearoff->tearoff_window(), 0));
2656 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2657 &tools_tearoff->tearoff_window()));
2658 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2659 &tools_tearoff->tearoff_window(), 0));
2661 toolbar_hbox.set_spacing (10);
2662 toolbar_hbox.set_border_width (1);
2664 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2665 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2668 hbox->pack_start (snap_box, false, false);
2669 // hbox->pack_start (zoom_box, false, false);
2670 hbox->pack_start (*nudge_box, false, false);
2674 toolbar_base.set_name ("ToolBarBase");
2675 toolbar_base.add (toolbar_hbox);
2677 toolbar_frame.set_shadow_type (SHADOW_OUT);
2678 toolbar_frame.set_name ("BaseFrame");
2679 toolbar_frame.add (toolbar_base);
2683 Editor::convert_drop_to_paths (vector<ustring>& paths,
2684 const RefPtr<Gdk::DragContext>& context,
2687 const SelectionData& data,
2696 vector<ustring> uris = data.get_uris();
2698 cerr << "there were " << uris.size() << " in that drag data\n";
2702 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
2703 are actually URI lists. So do it by hand.
2706 if (data.get_target() != "text/plain") {
2710 /* Parse the "uri-list" format that Nautilus provides,
2711 where each pathname is delimited by \r\n
2714 const char* p = data.get_text().c_str();
2721 while (g_ascii_isspace (*p))
2725 while (*q && (*q != '\n') && (*q != '\r'))
2731 while (q > p && g_ascii_isspace (*q))
2736 uris.push_back (ustring (p, q - p + 1));
2740 p = strchr (p, '\n');
2750 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
2752 if ((*i).substr (0,7) == "file://") {
2756 PBD::url_decode (p);
2758 // scan forward past three slashes
2760 ustring::size_type slashcnt = 0;
2761 ustring::size_type n = 0;
2762 ustring::iterator x = p.begin();
2764 while (slashcnt < 3 && x != p.end()) {
2767 } else if (slashcnt == 3) {
2774 if (slashcnt != 3 || x == p.end()) {
2775 error << _("malformed URL passed to drag-n-drop code") << endmsg;
2779 paths.push_back (p.substr (n - 1));
2787 Editor::new_tempo_section ()
2793 Editor::map_transport_state ()
2795 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
2797 if (session->transport_stopped()) {
2798 have_pending_keyboard_selection = false;
2801 update_loop_range_view (true);
2806 Editor::State::State ()
2808 selection = new Selection;
2811 Editor::State::~State ()
2817 Editor::get_memento () const
2819 State *state = new State;
2821 store_state (*state);
2822 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
2826 Editor::store_state (State& state) const
2828 *state.selection = *selection;
2832 Editor::restore_state (State *state)
2834 if (*selection == *state->selection) {
2838 *selection = *state->selection;
2839 time_selection_changed ();
2840 region_selection_changed ();
2842 /* XXX other selection change handlers? */
2846 Editor::begin_reversible_command (string name)
2849 before = &get_state();
2850 session->begin_reversible_command (name);
2855 Editor::commit_reversible_command ()
2858 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
2863 Editor::set_edit_group_solo (Route& route, bool yn)
2865 RouteGroup *edit_group;
2867 if ((edit_group = route.edit_group()) != 0) {
2868 edit_group->apply (&Route::set_solo, yn, this);
2870 route.set_solo (yn, this);
2875 Editor::set_edit_group_mute (Route& route, bool yn)
2877 RouteGroup *edit_group = 0;
2879 if ((edit_group == route.edit_group()) != 0) {
2880 edit_group->apply (&Route::set_mute, yn, this);
2882 route.set_mute (yn, this);
2887 Editor::history_changed ()
2891 if (undo_action && session) {
2892 if (session->undo_depth() == 0) {
2895 label = string_compose(_("Undo (%1)"), session->next_undo());
2897 undo_action->property_label() = label;
2900 if (redo_action && session) {
2901 if (session->redo_depth() == 0) {
2904 label = string_compose(_("Redo (%1)"), session->next_redo());
2906 redo_action->property_label() = label;
2911 Editor::duplicate_dialog (bool dup_region)
2913 if (selection->regions.empty() && (selection->time.length() == 0)) {
2917 ArdourDialog win ("duplicate dialog");
2918 Label label (_("Duplicate how many times?"));
2919 Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
2920 SpinButton spinner (adjustment);
2922 win.get_vbox()->set_spacing (12);
2923 win.get_vbox()->pack_start (label);
2925 /* dialogs have ::add_action_widget() but that puts the spinner in the wrong
2926 place, visually. so do this by hand.
2929 win.get_vbox()->pack_start (spinner);
2930 spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
2935 win.add_button (Stock::OK, RESPONSE_ACCEPT);
2936 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
2938 win.set_position (WIN_POS_MOUSE);
2940 spinner.grab_focus ();
2942 switch (win.run ()) {
2943 case RESPONSE_ACCEPT:
2949 float times = adjustment.get_value();
2951 if (!selection->regions.empty()) {
2952 duplicate_some_regions (selection->regions, times);
2954 duplicate_selection (times);
2959 Editor::show_verbose_canvas_cursor ()
2961 verbose_canvas_cursor->raise_to_top();
2962 verbose_canvas_cursor->show();
2963 verbose_cursor_visible = true;
2967 Editor::hide_verbose_canvas_cursor ()
2969 verbose_canvas_cursor->hide();
2970 verbose_cursor_visible = false;
2974 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
2976 /* XXX get origin of canvas relative to root window,
2977 add x and y and check compared to gdk_screen_{width,height}
2979 verbose_canvas_cursor->property_text() = txt.c_str();
2980 verbose_canvas_cursor->property_x() = x;
2981 verbose_canvas_cursor->property_y() = y;
2985 Editor::set_verbose_canvas_cursor_text (const string & txt)
2987 verbose_canvas_cursor->property_text() = txt.c_str();
2991 Editor::edit_mode_selection_done ()
2997 string choice = edit_mode_selector.get_active_text();
2998 EditMode mode = Slide;
3000 if (choice == _("Splice Edit")) {
3002 } else if (choice == _("Slide Edit")) {
3006 Config->set_edit_mode (mode);
3010 Editor::snap_type_selection_done ()
3012 string choice = snap_type_selector.get_active_text();
3013 SnapType snaptype = SnapToFrame;
3015 if (choice == _("Beats/3")) {
3016 snaptype = SnapToAThirdBeat;
3017 } else if (choice == _("Beats/4")) {
3018 snaptype = SnapToAQuarterBeat;
3019 } else if (choice == _("Beats/8")) {
3020 snaptype = SnapToAEighthBeat;
3021 } else if (choice == _("Beats/16")) {
3022 snaptype = SnapToASixteenthBeat;
3023 } else if (choice == _("Beats/32")) {
3024 snaptype = SnapToAThirtysecondBeat;
3025 } else if (choice == _("Beats")) {
3026 snaptype = SnapToBeat;
3027 } else if (choice == _("Bars")) {
3028 snaptype = SnapToBar;
3029 } else if (choice == _("Marks")) {
3030 snaptype = SnapToMark;
3031 } else if (choice == _("Edit Cursor")) {
3032 snaptype = SnapToEditCursor;
3033 } else if (choice == _("Region starts")) {
3034 snaptype = SnapToRegionStart;
3035 } else if (choice == _("Region ends")) {
3036 snaptype = SnapToRegionEnd;
3037 } else if (choice == _("Region bounds")) {
3038 snaptype = SnapToRegionBoundary;
3039 } else if (choice == _("Region syncs")) {
3040 snaptype = SnapToRegionSync;
3041 } else if (choice == _("CD Frames")) {
3042 snaptype = SnapToCDFrame;
3043 } else if (choice == _("SMPTE Frames")) {
3044 snaptype = SnapToSMPTEFrame;
3045 } else if (choice == _("SMPTE Seconds")) {
3046 snaptype = SnapToSMPTESeconds;
3047 } else if (choice == _("SMPTE Minutes")) {
3048 snaptype = SnapToSMPTEMinutes;
3049 } else if (choice == _("Seconds")) {
3050 snaptype = SnapToSeconds;
3051 } else if (choice == _("Minutes")) {
3052 snaptype = SnapToMinutes;
3053 } else if (choice == _("None")) {
3054 snaptype = SnapToFrame;
3057 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3059 ract->set_active ();
3064 Editor::snap_mode_selection_done ()
3066 string choice = snap_mode_selector.get_active_text();
3067 SnapMode mode = SnapNormal;
3069 if (choice == _("Normal")) {
3071 } else if (choice == _("Magnetic")) {
3072 mode = SnapMagnetic;
3075 RefPtr<RadioAction> ract = snap_mode_action (mode);
3078 ract->set_active (true);
3083 Editor::zoom_focus_selection_done ()
3085 string choice = zoom_focus_selector.get_active_text();
3086 ZoomFocus focus_type = ZoomFocusLeft;
3088 if (choice == _("Left")) {
3089 focus_type = ZoomFocusLeft;
3090 } else if (choice == _("Right")) {
3091 focus_type = ZoomFocusRight;
3092 } else if (choice == _("Center")) {
3093 focus_type = ZoomFocusCenter;
3094 } else if (choice == _("Playhead")) {
3095 focus_type = ZoomFocusPlayhead;
3096 } else if (choice == _("Edit Cursor")) {
3097 focus_type = ZoomFocusEdit;
3100 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3103 ract->set_active ();
3108 Editor::edit_controls_button_release (GdkEventButton* ev)
3110 if (Keyboard::is_context_menu_event (ev)) {
3111 ARDOUR_UI::instance()->add_route (this);
3117 Editor::mouse_select_button_release (GdkEventButton* ev)
3119 /* this handles just right-clicks */
3121 if (ev->button != 3) {
3128 Editor::TrackViewList *
3129 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3132 TrackViewList::iterator i;
3134 v = new TrackViewList;
3136 if (track == 0 && group == 0) {
3140 for (i = track_views.begin(); i != track_views.end (); ++i) {
3144 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3146 /* just the view for this track
3149 v->push_back (track);
3153 /* views for all tracks in the edit group */
3155 for (i = track_views.begin(); i != track_views.end (); ++i) {
3157 if (group == 0 || (*i)->edit_group() == group) {
3167 Editor::set_zoom_focus (ZoomFocus f)
3169 string str = zoom_focus_strings[(int)f];
3171 if (str != zoom_focus_selector.get_active_text()) {
3172 zoom_focus_selector.set_active_text (str);
3175 if (zoom_focus != f) {
3178 ZoomFocusChanged (); /* EMIT_SIGNAL */
3185 Editor::ensure_float (Window& win)
3187 win.set_transient_for (*this);
3191 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3193 /* recover or initialize pane positions. do this here rather than earlier because
3194 we don't want the positions to change the child allocations, which they seem to do.
3200 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3202 static int32_t done;
3205 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3206 width = default_width;
3207 height = default_height;
3209 width = atoi(geometry->property("x_size")->value());
3210 height = atoi(geometry->property("y_size")->value());
3213 if (which == static_cast<Paned*> (&edit_pane)) {
3219 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3220 /* initial allocation is 90% to canvas, 10% to notebook */
3221 pos = (int) floor (alloc.get_width() * 0.90f);
3222 snprintf (buf, sizeof(buf), "%d", pos);
3224 pos = atoi (prop->value());
3227 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3228 edit_pane.set_position (pos);
3229 pre_maximal_pane_position = pos;
3235 Editor::detach_tearoff (Box* b, Window* w)
3237 if (tools_tearoff->torn_off() &&
3238 mouse_mode_tearoff->torn_off()) {
3239 top_hbox.remove (toolbar_frame);
3244 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3246 if (toolbar_frame.get_parent() == 0) {
3247 top_hbox.pack_end (toolbar_frame);
3252 Editor::set_show_measures (bool yn)
3254 if (_show_measures != yn) {
3257 if ((_show_measures = yn) == true) {
3265 Editor::toggle_follow_playhead ()
3267 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3269 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3270 set_follow_playhead (tact->get_active());
3275 Editor::set_follow_playhead (bool yn)
3277 if (_follow_playhead != yn) {
3278 if ((_follow_playhead = yn) == true) {
3280 update_current_screen ();
3287 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
3289 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3291 xfade->set_active (!xfade->active());
3296 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
3298 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3300 xfade->set_follow_overlap (!xfade->following_overlap());
3305 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
3307 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3313 CrossfadeEditor cew (*session, xfade, xfade->fade_in().get_min_y(), 1.0);
3317 switch (cew.run ()) {
3318 case RESPONSE_ACCEPT:
3325 xfade->StateChanged (Change (~0));
3329 Editor::playlist_selector () const
3331 return *_playlist_selector;
3335 Editor::get_nudge_distance (nframes_t pos, nframes_t& next)
3339 ret = nudge_clock.current_duration (pos);
3340 next = ret + 1; /* XXXX fix me */
3346 Editor::end_location_changed (Location* location)
3348 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3349 reset_scrolling_region ();
3353 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
3355 ArdourDialog dialog ("playlist deletion dialog");
3356 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3357 "If left alone, no audio files used by it will be cleaned.\n"
3358 "If deleted, audio files used by it alone by will cleaned."),
3361 dialog.set_position (WIN_POS_CENTER);
3362 dialog.get_vbox()->pack_start (label);
3366 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3367 dialog.add_button (_("Keep playlist"), RESPONSE_REJECT);
3368 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3370 switch (dialog.run ()) {
3371 case RESPONSE_ACCEPT:
3372 /* delete the playlist */
3376 case RESPONSE_REJECT:
3377 /* keep the playlist */
3389 Editor::audio_region_selection_covers (nframes_t where)
3391 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3392 if ((*a)->region()->covers (where)) {
3401 Editor::prepare_for_cleanup ()
3403 cut_buffer->clear_regions ();
3404 cut_buffer->clear_playlists ();
3406 selection->clear_regions ();
3407 selection->clear_playlists ();
3411 Editor::transport_loop_location()
3414 return session->locations()->auto_loop_location();
3421 Editor::transport_punch_location()
3424 return session->locations()->auto_punch_location();
3431 Editor::control_layout_scroll (GdkEventScroll* ev)
3433 switch (ev->direction) {
3435 scroll_tracks_up_line ();
3439 case GDK_SCROLL_DOWN:
3440 scroll_tracks_down_line ();
3444 /* no left/right handling yet */
3452 /** A new snapshot has been selected.
3455 Editor::snapshot_display_selection_changed ()
3457 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
3459 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
3461 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
3463 if (snap_name.length() == 0) {
3467 if (session->snap_name() == snap_name) {
3471 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
3476 Editor::snapshot_display_button_press (GdkEventButton* ev)
3478 if (ev->button == 3) {
3479 /* Right-click on the snapshot list. Work out which snapshot it
3481 Gtk::TreeModel::Path path;
3482 Gtk::TreeViewColumn* col;
3485 snapshot_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, col, cx, cy);
3486 Gtk::TreeModel::iterator iter = snapshot_display_model->get_iter (path);
3488 Gtk::TreeModel::Row row = *iter;
3489 popup_snapshot_context_menu (ev->button, ev->time, row[snapshot_display_columns.real_name]);
3498 /** Pop up the snapshot display context menu.
3499 * @param button Button used to open the menu.
3500 * @param time Menu open time.
3501 * @snapshot_name Name of the snapshot that the menu click was over.
3505 Editor::popup_snapshot_context_menu (int button, int32_t time, Glib::ustring snapshot_name)
3507 using namespace Menu_Helpers;
3509 MenuList& items (snapshot_context_menu.items());
3512 const bool modification_allowed = (session->snap_name() != snapshot_name && session->name() != snapshot_name);
3514 items.push_back (MenuElem (_("Remove"), bind (mem_fun (*this, &Editor::remove_snapshot), snapshot_name)));
3515 if (!modification_allowed) {
3516 items.back().set_sensitive (false);
3519 items.push_back (MenuElem (_("Rename"), bind (mem_fun (*this, &Editor::rename_snapshot), snapshot_name)));
3520 if (!modification_allowed) {
3521 items.back().set_sensitive (false);
3524 snapshot_context_menu.popup (button, time);
3528 Editor::rename_snapshot (Glib::ustring old_name)
3530 ArdourPrompter prompter(true);
3534 prompter.set_name ("Prompter");
3535 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
3536 prompter.set_prompt (_("New name of snapshot"));
3537 prompter.set_initial_text (old_name);
3539 if (prompter.run() == RESPONSE_ACCEPT) {
3540 prompter.get_result (new_name);
3541 if (new_name.length()) {
3542 session->rename_state (old_name, new_name);
3543 redisplay_snapshots ();
3550 Editor::remove_snapshot (Glib::ustring name)
3552 vector<string> choices;
3554 std::string prompt = string_compose (_("Do you really want to remove snapshot \"%1\" ?\n(cannot be undone)"), name);
3556 choices.push_back (_("No, do nothing."));
3557 choices.push_back (_("Yes, remove it."));
3559 Gtkmm2ext::Choice prompter (prompt, choices);
3561 if (prompter.run () == 1) {
3562 session->remove_state (name);
3563 redisplay_snapshots ();
3568 Editor::redisplay_snapshots ()
3574 vector<string*>* states;
3576 if ((states = session->possible_states()) == 0) {
3580 snapshot_display_model->clear ();
3582 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
3583 string statename = *(*i);
3584 TreeModel::Row row = *(snapshot_display_model->append());
3586 /* this lingers on in case we ever want to change the visible
3587 name of the snapshot.
3590 string display_name;
3591 display_name = statename;
3593 if (statename == session->snap_name()) {
3594 snapshot_display.get_selection()->select(row);
3597 row[snapshot_display_columns.visible_name] = display_name;
3598 row[snapshot_display_columns.real_name] = statename;
3605 Editor::session_state_saved (string snap_name)
3607 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
3608 redisplay_snapshots ();
3612 Editor::maximise_editing_space ()
3614 initial_ruler_update_required = true;
3616 mouse_mode_tearoff->set_visible (false);
3617 tools_tearoff->set_visible (false);
3619 pre_maximal_pane_position = edit_pane.get_position();
3620 pre_maximal_editor_width = this->get_width();
3622 if(post_maximal_pane_position == 0) {
3623 post_maximal_pane_position = edit_pane.get_width();
3628 if(post_maximal_editor_width) {
3629 edit_pane.set_position (post_maximal_pane_position -
3630 abs(post_maximal_editor_width - pre_maximal_editor_width));
3632 edit_pane.set_position (post_maximal_pane_position);
3637 Editor::restore_editing_space ()
3639 initial_ruler_update_required = true;
3641 // user changed width of pane during fullscreen
3642 if(post_maximal_pane_position != edit_pane.get_position()) {
3643 post_maximal_pane_position = edit_pane.get_position();
3648 mouse_mode_tearoff->set_visible (true);
3649 tools_tearoff->set_visible (true);
3650 post_maximal_editor_width = this->get_width();
3653 edit_pane.set_position (
3654 pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width)
3659 Editor::new_playlists ()
3661 begin_reversible_command (_("new playlists"));
3662 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist));
3663 commit_reversible_command ();
3667 Editor::copy_playlists ()
3669 begin_reversible_command (_("copy playlists"));
3670 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist));
3671 commit_reversible_command ();
3675 Editor::clear_playlists ()
3677 begin_reversible_command (_("clear playlists"));
3678 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist));
3679 commit_reversible_command ();
3683 Editor::mapped_use_new_playlist (AudioTimeAxisView& atv, uint32_t sz)
3685 atv.use_new_playlist (sz > 1 ? false : true);
3689 Editor::mapped_use_copy_playlist (AudioTimeAxisView& atv, uint32_t sz)
3691 atv.use_copy_playlist (sz > 1 ? false : true);
3695 Editor::mapped_clear_playlist (AudioTimeAxisView& atv, uint32_t sz)
3697 atv.clear_playlist ();
3701 Editor::on_key_press_event (GdkEventKey* ev)
3703 return key_press_focus_accelerator_handler (*this, ev);
3707 Editor::reset_x_origin (nframes_t frame)
3709 queue_visual_change (frame);
3713 Editor::reset_zoom (double fpu)
3715 queue_visual_change (fpu);
3719 Editor::reposition_and_zoom (nframes_t frame, double fpu)
3721 reset_x_origin (frame);
3726 Editor::set_frames_per_unit (double fpu)
3730 /* this is the core function that controls the zoom level of the canvas. it is called
3731 whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
3734 if (fpu == frames_per_unit) {
3742 // convert fpu to frame count
3744 frames = (nframes_t) floor (fpu * canvas_width);
3746 /* don't allow zooms that fit more than the maximum number
3747 of frames into an 800 pixel wide space.
3750 if (max_frames / fpu < 800.0) {
3754 if (fpu == frames_per_unit) {
3758 frames_per_unit = fpu;
3760 if (frames != zoom_range_clock.current_duration()) {
3761 zoom_range_clock.set (frames);
3764 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
3765 if (!selection->tracks.empty()) {
3766 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3767 (*i)->reshow_selection (selection->time);
3770 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3771 (*i)->reshow_selection (selection->time);
3776 ZoomChanged (); /* EMIT_SIGNAL */
3778 reset_hscrollbar_stepping ();
3779 reset_scrolling_region ();
3781 if (edit_cursor) edit_cursor->set_position (edit_cursor->current_frame);
3782 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
3788 Editor::queue_visual_change (nframes_t where)
3790 pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::TimeOrigin);
3791 pending_visual_change.time_origin = where;
3793 if (pending_visual_change.idle_handler_id < 0) {
3794 pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
3799 Editor::queue_visual_change (double fpu)
3801 pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::ZoomLevel);
3802 pending_visual_change.frames_per_unit = fpu;
3804 if (pending_visual_change.idle_handler_id < 0) {
3805 pending_visual_change.idle_handler_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE, _idle_visual_changer, this, 0);
3810 Editor::_idle_visual_changer (void* arg)
3812 return static_cast<Editor*>(arg)->idle_visual_changer ();
3816 Editor::idle_visual_changer ()
3818 VisualChange::Type p = pending_visual_change.pending;
3820 pending_visual_change.pending = (VisualChange::Type) 0;
3821 pending_visual_change.idle_handler_id = -1;
3823 if (p & VisualChange::ZoomLevel) {
3824 set_frames_per_unit (pending_visual_change.frames_per_unit);
3827 if (p & VisualChange::TimeOrigin) {
3828 if (pending_visual_change.time_origin != leftmost_frame) {
3829 horizontal_adjustment.set_value (pending_visual_change.time_origin/frames_per_unit);
3830 /* the signal handler will do the rest */
3832 update_fixed_rulers();
3833 redisplay_tempo (true);
3837 return 0; /* this is always a one-shot call */
3840 struct EditorOrderTimeAxisSorter {
3841 bool operator() (const TimeAxisView* a, const TimeAxisView* b) const {
3842 return a->order < b->order;
3847 Editor::sort_track_selection ()
3849 EditorOrderTimeAxisSorter cmp;
3850 selection->tracks.sort (cmp);
3854 Editor::edit_cursor_position(bool sync)
3856 if (sync && edit_cursor->current_frame != edit_cursor_clock.current_time()) {
3857 edit_cursor_clock.set(edit_cursor->current_frame, true);
3860 return edit_cursor->current_frame;
3864 Editor::set_loop_range (nframes_t start, nframes_t end, string cmd)
3866 if (!session) return;
3868 begin_reversible_command (cmd);
3872 if ((tll = transport_loop_location()) == 0) {
3873 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoLoop);
3874 XMLNode &before = session->locations()->get_state();
3875 session->locations()->add (loc, true);
3876 session->set_auto_loop_location (loc);
3877 XMLNode &after = session->locations()->get_state();
3878 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
3881 XMLNode &before = tll->get_state();
3882 tll->set_hidden (false, this);
3883 tll->set (start, end);
3884 XMLNode &after = tll->get_state();
3885 session->add_command (new MementoCommand<Location>(*tll, &before, &after));
3888 commit_reversible_command ();
3892 Editor::set_punch_range (nframes_t start, nframes_t end, string cmd)
3894 if (!session) return;
3896 begin_reversible_command (cmd);
3900 if ((tpl = transport_punch_location()) == 0) {
3901 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoPunch);
3902 XMLNode &before = session->locations()->get_state();
3903 session->locations()->add (loc, true);
3904 session->set_auto_loop_location (loc);
3905 XMLNode &after = session->locations()->get_state();
3906 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
3909 XMLNode &before = tpl->get_state();
3910 tpl->set_hidden (false, this);
3911 tpl->set (start, end);
3912 XMLNode &after = tpl->get_state();
3913 session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
3916 commit_reversible_command ();