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>
57 #include <ardour/profile.h>
59 #include <control_protocol/control_protocol.h>
61 #include "ardour_ui.h"
65 #include "playlist_selector.h"
66 #include "audio_region_view.h"
67 #include "rgb_macros.h"
68 #include "selection.h"
69 #include "audio_streamview.h"
70 #include "time_axis_view.h"
71 #include "audio_time_axis.h"
73 #include "crossfade_view.h"
75 #include "public_editor.h"
76 #include "crossfade_edit.h"
77 #include "canvas_impl.h"
79 #include "gui_thread.h"
82 #include "analysis_window.h"
88 #include "imageframe_socket_handler.h"
89 /* </CMT Additions> */
93 using namespace ARDOUR;
97 using namespace Gtkmm2ext;
98 using namespace Editing;
102 const double Editor::timebar_height = 15.0;
104 #include "editor_xpms"
106 static const gchar *_snap_type_strings[] = {
130 static const gchar *_snap_mode_strings[] = {
136 static const gchar *_zoom_focus_strings[] = {
145 /* Soundfile drag-n-drop */
147 Gdk::Cursor* Editor::cross_hair_cursor = 0;
148 Gdk::Cursor* Editor::selector_cursor = 0;
149 Gdk::Cursor* Editor::trimmer_cursor = 0;
150 Gdk::Cursor* Editor::grabber_cursor = 0;
151 Gdk::Cursor* Editor::zoom_cursor = 0;
152 Gdk::Cursor* Editor::time_fx_cursor = 0;
153 Gdk::Cursor* Editor::fader_cursor = 0;
154 Gdk::Cursor* Editor::speaker_cursor = 0;
155 Gdk::Cursor* Editor::wait_cursor = 0;
156 Gdk::Cursor* Editor::timebar_cursor = 0;
159 show_me_the_size (Requisition* r, const char* what)
161 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
165 check_adjustment (Gtk::Adjustment* adj)
167 cerr << "CHANGE adj = "
168 << adj->get_lower () << ' '
169 << adj->get_upper () << ' '
170 << adj->get_value () << ' '
171 << adj->get_step_increment () << ' '
172 << adj->get_page_increment () << ' '
173 << adj->get_page_size () << ' '
180 /* time display buttons */
181 minsec_label (_("Mins:Secs")),
182 bbt_label (_("Bars:Beats")),
183 smpte_label (_("Timecode")),
184 frame_label (_("Frames")),
185 tempo_label (_("Tempo")),
186 meter_label (_("Meter")),
187 mark_label (_("Location Markers")),
188 range_mark_label (_("Range Markers")),
189 transport_mark_label (_("Loop/Punch Ranges")),
191 edit_packer (3, 3, false),
193 /* the values here don't matter: layout widgets
194 reset them as needed.
197 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
198 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
200 /* tool bar related */
202 edit_cursor_clock (X_("editcursor"), false, X_("EditCursorClock"), true),
203 zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true),
205 toolbar_selection_clock_table (2,3),
207 automation_mode_button (_("mode")),
208 global_automation_button (_("automation")),
210 /* <CMT Additions> */
211 image_socket_listener(0),
212 /* </CMT Additions> */
216 nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true)
221 /* we are a singleton */
223 PublicEditor::_instance = this;
227 selection = new Selection;
228 cut_buffer = new Selection;
230 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
231 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
232 selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
233 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
235 clicked_regionview = 0;
236 clicked_trackview = 0;
237 clicked_audio_trackview = 0;
238 clicked_crossfadeview = 0;
239 clicked_control_point = 0;
240 latest_regionview = 0;
241 last_update_frame = 0;
243 current_mixer_strip = 0;
244 current_bbt_points = 0;
246 snap_type_strings = I18N (_snap_type_strings);
247 snap_mode_strings = I18N (_snap_mode_strings);
248 zoom_focus_strings = I18N(_zoom_focus_strings);
250 snap_type = SnapToFrame;
251 set_snap_to (snap_type);
252 snap_mode = SnapNormal;
253 set_snap_mode (snap_mode);
254 snap_threshold = 5.0;
255 bbt_beat_subdivision = 4;
258 autoscroll_active = false;
259 autoscroll_timeout_tag = -1;
260 interthread_progress_window = 0;
266 current_interthread_info = 0;
267 _show_measures = true;
268 _show_waveforms = true;
269 _show_waveforms_recording = true;
270 first_action_message = 0;
272 show_gain_after_trim = false;
273 ignore_route_list_reorder = false;
274 no_route_list_redisplay = false;
275 verbose_cursor_on = true;
276 route_removal = false;
277 show_automatic_regions_in_region_list = true;
278 region_list_sort_type = (Editing::RegionListSortType) 0;
279 have_pending_keyboard_selection = false;
280 _follow_playhead = true;
281 _xfade_visibility = true;
282 editor_ruler_menu = 0;
283 no_ruler_shown_update = false;
284 edit_group_list_menu = 0;
286 region_list_menu = 0;
288 start_end_marker_menu = 0;
289 range_marker_menu = 0;
290 marker_menu_item = 0;
292 transport_marker_menu = 0;
293 new_transport_marker_menu = 0;
294 editor_mixer_strip_width = Wide;
295 show_editor_mixer_when_tracks_arrive = false;
296 region_edit_menu_split_item = 0;
298 region_edit_menu_split_multichannel_item = 0;
300 ignore_mouse_mode_toggle = false;
301 current_stepping_trackview = 0;
303 entered_regionview = 0;
304 clear_entered_track = false;
305 _new_regionviews_show_envelope = false;
306 current_timestretch = 0;
307 in_edit_group_row_change = false;
308 last_canvas_frame = 0;
311 button_release_can_deselect = true;
312 canvas_idle_queued = false;
313 _dragging_playhead = false;
314 _dragging_hscrollbar = false;
317 location_marker_color = ARDOUR_UI::config()->canvasvar_LocationMarker.get();
318 location_range_color = ARDOUR_UI::config()->canvasvar_LocationRange.get();
319 location_cd_marker_color = ARDOUR_UI::config()->canvasvar_LocationCDMarker.get();
320 location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
321 location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
323 range_marker_drag_rect = 0;
324 marker_drag_line = 0;
326 set_mouse_mode (MouseObject, true);
328 frames_per_unit = 2048; /* too early to use reset_zoom () */
329 reset_hscrollbar_stepping ();
331 zoom_focus = ZoomFocusLeft;
332 set_zoom_focus (ZoomFocusLeft);
333 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
335 initialize_rulers ();
336 initialize_canvas ();
338 edit_controls_vbox.set_spacing (0);
339 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled));
340 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling));
342 track_canvas.set_hadjustment (horizontal_adjustment);
343 track_canvas.set_vadjustment (vertical_adjustment);
344 time_canvas.set_hadjustment (horizontal_adjustment);
346 track_canvas.signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
347 time_canvas.signal_map_event().connect (mem_fun (*this, &Editor::time_canvas_map_handler));
349 controls_layout.add (edit_controls_vbox);
350 controls_layout.set_name ("EditControlsBase");
351 controls_layout.add_events (Gdk::SCROLL_MASK);
352 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
354 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
355 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
356 controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
358 edit_vscrollbar.set_adjustment (vertical_adjustment);
359 edit_hscrollbar.set_adjustment (horizontal_adjustment);
361 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press), false);
362 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release), false);
363 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
365 edit_hscrollbar.set_name ("EditorHScrollbar");
370 edit_cursor_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_cursor_clock_changed));
372 time_canvas_vbox.pack_start (*_ruler_separator, false, false);
373 time_canvas_vbox.pack_start (*minsec_ruler, false, false);
374 time_canvas_vbox.pack_start (*smpte_ruler, false, false);
375 time_canvas_vbox.pack_start (*frames_ruler, false, false);
376 time_canvas_vbox.pack_start (*bbt_ruler, false, false);
377 time_canvas_vbox.pack_start (time_canvas, true, true);
378 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars) + 2);
380 bbt_label.set_name ("EditorTimeButton");
381 bbt_label.set_size_request (-1, (int)timebar_height);
382 bbt_label.set_alignment (1.0, 0.5);
383 bbt_label.set_padding (5,0);
384 minsec_label.set_name ("EditorTimeButton");
385 minsec_label.set_size_request (-1, (int)timebar_height);
386 minsec_label.set_alignment (1.0, 0.5);
387 minsec_label.set_padding (5,0);
388 smpte_label.set_name ("EditorTimeButton");
389 smpte_label.set_size_request (-1, (int)timebar_height);
390 smpte_label.set_alignment (1.0, 0.5);
391 smpte_label.set_padding (5,0);
392 frame_label.set_name ("EditorTimeButton");
393 frame_label.set_size_request (-1, (int)timebar_height);
394 frame_label.set_alignment (1.0, 0.5);
395 frame_label.set_padding (5,0);
396 tempo_label.set_name ("EditorTimeButton");
397 tempo_label.set_size_request (-1, (int)timebar_height);
398 tempo_label.set_alignment (1.0, 0.5);
399 tempo_label.set_padding (5,0);
400 meter_label.set_name ("EditorTimeButton");
401 meter_label.set_size_request (-1, (int)timebar_height);
402 meter_label.set_alignment (1.0, 0.5);
403 meter_label.set_padding (5,0);
404 mark_label.set_name ("EditorTimeButton");
405 mark_label.set_size_request (-1, (int)timebar_height);
406 mark_label.set_alignment (1.0, 0.5);
407 mark_label.set_padding (5,0);
408 range_mark_label.set_name ("EditorTimeButton");
409 range_mark_label.set_size_request (-1, (int)timebar_height);
410 range_mark_label.set_alignment (1.0, 0.5);
411 range_mark_label.set_padding (5,0);
412 transport_mark_label.set_name ("EditorTimeButton");
413 transport_mark_label.set_size_request (-1, (int)timebar_height);
414 transport_mark_label.set_alignment (1.0, 0.5);
415 transport_mark_label.set_padding (5,0);
417 time_button_vbox.pack_start (minsec_label, false, false);
418 time_button_vbox.pack_start (smpte_label, false, false);
419 time_button_vbox.pack_start (frame_label, false, false);
420 time_button_vbox.pack_start (bbt_label, false, false);
421 time_button_vbox.pack_start (meter_label, false, false);
422 time_button_vbox.pack_start (tempo_label, false, false);
423 time_button_vbox.pack_start (mark_label, false, false);
425 time_button_event_box.add (time_button_vbox);
427 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
428 time_button_event_box.set_name ("TimebarLabelBase");
429 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
431 time_button_frame.add(time_button_event_box);
432 time_button_frame.property_shadow_type() = Gtk::SHADOW_OUT;
434 /* these enable us to have a dedicated window (for cursor setting, etc.)
435 for the canvas areas.
438 track_canvas_event_box.add (track_canvas);
440 time_canvas_event_box.add (time_canvas_vbox);
441 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
443 edit_packer.set_col_spacings (0);
444 edit_packer.set_row_spacings (0);
445 edit_packer.set_homogeneous (false);
446 edit_packer.set_border_width (0);
447 edit_packer.set_name ("EditorWindow");
449 edit_packer.attach (edit_vscrollbar, 0, 1, 1, 3, FILL, FILL|EXPAND, 0, 0);
451 edit_packer.attach (time_button_frame, 0, 2, 0, 1, FILL, FILL, 0, 0);
452 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
454 edit_packer.attach (controls_layout, 1, 2, 1, 2, FILL, FILL|EXPAND, 0, 0);
455 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 2, FILL|EXPAND, FILL|EXPAND, 0, 0);
457 edit_packer.attach (zoom_box, 1, 2, 2, 3, FILL, FILL, 0, 0);
458 edit_packer.attach (edit_hscrollbar, 2, 3, 2, 3, FILL|EXPAND, FILL, 0, 0);
460 bottom_hbox.set_border_width (2);
461 bottom_hbox.set_spacing (3);
463 route_display_model = ListStore::create(route_display_columns);
464 route_list_display.set_model (route_display_model);
465 route_list_display.append_column (_("Show"), route_display_columns.visible);
466 route_list_display.append_column (_("Name"), route_display_columns.text);
467 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
468 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
469 route_list_display.set_headers_visible (true);
470 route_list_display.set_name ("TrackListDisplay");
471 route_list_display.get_selection()->set_mode (SELECTION_NONE);
472 route_list_display.set_reorderable (true);
473 route_list_display.set_size_request (100,-1);
475 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
476 route_list_visible_cell->property_activatable() = true;
477 route_list_visible_cell->property_radio() = false;
479 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
480 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
482 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
484 route_list_scroller.add (route_list_display);
485 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
487 group_model = ListStore::create(group_columns);
488 edit_group_display.set_model (group_model);
489 edit_group_display.append_column (_("Name"), group_columns.text);
490 edit_group_display.append_column (_("Active"), group_columns.is_active);
491 edit_group_display.append_column (_("Show"), group_columns.is_visible);
492 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
493 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
494 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
495 edit_group_display.get_column (0)->set_expand (true);
496 edit_group_display.get_column (1)->set_expand (false);
497 edit_group_display.get_column (2)->set_expand (false);
498 edit_group_display.set_headers_visible (true);
500 /* name is directly editable */
502 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
503 name_cell->property_editable() = true;
504 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
506 /* use checkbox for the active + visible columns */
508 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
509 active_cell->property_activatable() = true;
510 active_cell->property_radio() = false;
512 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
513 active_cell->property_activatable() = true;
514 active_cell->property_radio() = false;
516 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
518 edit_group_display.set_name ("EditGroupList");
519 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
520 edit_group_display.set_headers_visible (true);
521 edit_group_display.set_reorderable (false);
522 edit_group_display.set_rules_hint (true);
523 edit_group_display.set_size_request (75, -1);
525 edit_group_display_scroller.add (edit_group_display);
526 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
528 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
530 VBox* edit_group_display_packer = manage (new VBox());
531 HBox* edit_group_display_button_box = manage (new HBox());
532 edit_group_display_button_box->set_homogeneous (true);
534 Button* edit_group_add_button = manage (new Button ());
535 Button* edit_group_remove_button = manage (new Button ());
539 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
541 edit_group_add_button->add (*w);
543 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
545 edit_group_remove_button->add (*w);
547 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
548 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
550 edit_group_display_button_box->pack_start (*edit_group_add_button);
551 edit_group_display_button_box->pack_start (*edit_group_remove_button);
553 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
554 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
556 region_list_display.set_size_request (100, -1);
557 region_list_display.set_name ("RegionListDisplay");
559 region_list_model = TreeStore::create (region_list_columns);
560 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
561 region_list_model->set_sort_column (0, SORT_ASCENDING);
563 region_list_display.set_model (region_list_model);
564 region_list_display.append_column (_("Regions"), region_list_columns.name);
565 region_list_display.set_headers_visible (false);
567 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
569 TreeViewColumn* tv_col = region_list_display.get_column(0);
570 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
571 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
572 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
574 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
575 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
577 /* setup DnD handling */
579 list<TargetEntry> region_list_target_table;
581 region_list_target_table.push_back (TargetEntry ("text/plain"));
582 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
583 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
585 region_list_display.add_drop_targets (region_list_target_table);
586 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
588 region_list_scroller.add (region_list_display);
589 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
591 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
592 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
593 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
594 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
595 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
596 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
598 named_selection_scroller.add (named_selection_display);
599 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
601 named_selection_model = TreeStore::create (named_selection_columns);
602 named_selection_display.set_model (named_selection_model);
603 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
604 named_selection_display.set_headers_visible (false);
605 named_selection_display.set_size_request (100, -1);
606 named_selection_display.set_name ("NamedSelectionDisplay");
608 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
609 named_selection_display.set_size_request (100, -1);
610 named_selection_display.signal_button_release_event().connect (mem_fun(*this, &Editor::named_selection_display_button_release), false);
611 named_selection_display.signal_key_release_event().connect (mem_fun(*this, &Editor::named_selection_display_key_release), false);
612 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
616 snapshot_display_model = ListStore::create (snapshot_display_columns);
617 snapshot_display.set_model (snapshot_display_model);
618 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
619 snapshot_display.set_name ("SnapshotDisplay");
620 snapshot_display.set_size_request (75, -1);
621 snapshot_display.set_headers_visible (false);
622 snapshot_display.set_reorderable (false);
623 snapshot_display_scroller.add (snapshot_display);
624 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
626 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
627 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
631 nlabel = manage (new Label (_("Regions")));
632 nlabel->set_angle (-90);
633 the_notebook.append_page (region_list_scroller, *nlabel);
634 nlabel = manage (new Label (_("Tracks/Busses")));
635 nlabel->set_angle (-90);
636 the_notebook.append_page (route_list_scroller, *nlabel);
637 nlabel = manage (new Label (_("Snapshots")));
638 nlabel->set_angle (-90);
639 the_notebook.append_page (snapshot_display_scroller, *nlabel);
640 nlabel = manage (new Label (_("Edit Groups")));
641 nlabel->set_angle (-90);
642 the_notebook.append_page (*edit_group_display_packer, *nlabel);
643 nlabel = manage (new Label (_("Chunks")));
644 nlabel->set_angle (-90);
645 the_notebook.append_page (named_selection_scroller, *nlabel);
647 the_notebook.set_show_tabs (true);
648 the_notebook.set_scrollable (true);
649 the_notebook.popup_enable ();
650 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
652 post_maximal_editor_width = 0;
653 post_maximal_pane_position = 0;
654 edit_pane.pack1 (edit_packer, true, true);
655 edit_pane.pack2 (the_notebook, false, true);
657 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
659 top_hbox.pack_start (toolbar_frame, true, true);
661 HBox *hbox = manage (new HBox);
662 hbox->pack_start (edit_pane, true, true);
664 global_vpacker.pack_start (top_hbox, false, false);
665 global_vpacker.pack_start (*hbox, true, true);
667 global_hpacker.pack_start (global_vpacker, true, true);
669 set_name ("EditorWindow");
670 add_accel_group (ActionManager::ui_manager->get_accel_group());
672 vpacker.pack_end (global_hpacker, true, true);
674 /* register actions now so that set_state() can find them and set toggles/checks etc */
678 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
681 _playlist_selector = new PlaylistSelector();
682 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
684 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
688 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
689 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
691 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
692 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
694 nudge_forward_button.set_name ("TransportButton");
695 nudge_backward_button.set_name ("TransportButton");
697 fade_context_menu.set_name ("ArdourContextMenu");
699 /* icons, titles, WM stuff */
701 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
702 Glib::RefPtr<Gdk::Pixbuf> icon;
704 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
705 window_icons.push_back (icon);
707 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
708 window_icons.push_back (icon);
710 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
711 window_icons.push_back (icon);
713 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
714 window_icons.push_back (icon);
716 if (!window_icons.empty()) {
717 set_icon_list (window_icons);
718 set_default_icon_list (window_icons);
721 WindowTitle title(Glib::get_application_name());
722 title += _("Editor");
723 set_title (title.get_string());
724 set_wmclass (X_("ardour_editor"), "Ardour");
727 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
729 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
730 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
732 /* allow external control surfaces/protocols to do various things */
734 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
735 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
736 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
737 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
739 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
747 /* <CMT Additions> */
748 if(image_socket_listener)
750 if(image_socket_listener->is_connected())
752 image_socket_listener->close_connection() ;
755 delete image_socket_listener ;
756 image_socket_listener = 0 ;
758 /* </CMT Additions> */
762 Editor::add_toplevel_controls (Container& cont)
764 vpacker.pack_start (cont, false, false);
769 Editor::catch_vanishing_regionview (RegionView *rv)
771 /* note: the selection will take care of the vanishing
772 audioregionview by itself.
775 if (clicked_regionview == rv) {
776 clicked_regionview = 0;
779 if (entered_regionview == rv) {
780 set_entered_regionview (0);
785 Editor::set_entered_regionview (RegionView* rv)
787 if (rv == entered_regionview) {
791 if (entered_regionview) {
792 entered_regionview->exited ();
795 if ((entered_regionview = rv) != 0) {
796 entered_regionview->entered ();
801 Editor::set_entered_track (TimeAxisView* tav)
804 entered_track->exited ();
807 if ((entered_track = tav) != 0) {
808 entered_track->entered ();
813 Editor::show_window ()
818 /* now reset all audio_time_axis heights, because widgets might need
824 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
825 tv = (static_cast<TimeAxisView*>(*i));
831 Editor::tie_vertical_scrolling ()
833 double y1 = vertical_adjustment.get_value();
834 controls_layout.get_vadjustment()->set_value (y1);
835 playhead_cursor->set_y_axis(y1);
836 edit_cursor->set_y_axis(y1);
840 Editor::instant_save ()
842 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
847 session->add_instant_xml(get_state(), session->path());
849 Config->add_instant_xml(get_state(), get_user_ardour_path());
854 Editor::edit_cursor_clock_changed()
856 if (edit_cursor->current_frame != edit_cursor_clock.current_time()) {
857 edit_cursor->set_position (edit_cursor_clock.current_time());
863 Editor::zoom_adjustment_changed ()
869 double fpu = zoom_range_clock.current_duration() / canvas_width;
873 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
874 } else if (fpu > session->current_end_frame() / canvas_width) {
875 fpu = session->current_end_frame() / canvas_width;
876 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
883 Editor::control_scroll (float fraction)
885 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
891 double step = fraction * current_page_frames();
894 _control_scroll_target is an optional<T>
896 it acts like a pointer to an nframes_t, with
897 a operator conversion to boolean to check
898 that it has a value could possibly use
899 playhead_cursor->current_frame to store the
900 value and a boolean in the class to know
901 when it's out of date
904 if (!_control_scroll_target) {
905 _control_scroll_target = session->transport_frame();
906 _dragging_playhead = true;
909 if ((fraction < 0.0f) && (*_control_scroll_target < (nframes_t) fabs(step))) {
910 *_control_scroll_target = 0;
911 } else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
912 *_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
914 *_control_scroll_target += (nframes_t) floor (step);
917 /* move visuals, we'll catch up with it later */
919 playhead_cursor->set_position (*_control_scroll_target);
920 UpdateAllTransportClocks (*_control_scroll_target);
922 if (*_control_scroll_target > (current_page_frames() / 2)) {
923 /* try to center PH in window */
924 reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
930 Now we do a timeout to actually bring the session to the right place
931 according to the playhead. This is to avoid reading disk buffers on every
932 call to control_scroll, which is driven by ScrollTimeline and therefore
933 probably by a control surface wheel which can generate lots of events.
935 /* cancel the existing timeout */
937 control_scroll_connection.disconnect ();
939 /* add the next timeout */
941 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), *_control_scroll_target), 250);
945 Editor::deferred_control_scroll (nframes_t target)
947 session->request_locate (*_control_scroll_target, session->transport_rolling());
948 // reset for next stream
949 _control_scroll_target = boost::none;
950 _dragging_playhead = false;
955 Editor::on_realize ()
957 Window::on_realize ();
962 Editor::start_scrolling ()
964 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
965 (mem_fun(*this, &Editor::update_current_screen));
969 Editor::stop_scrolling ()
971 scroll_connection.disconnect ();
975 Editor::map_position_change (nframes_t frame)
977 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
979 if (session == 0 || !_follow_playhead) {
983 center_screen (frame);
984 playhead_cursor->set_position (frame);
988 Editor::center_screen (nframes_t frame)
990 double page = canvas_width * frames_per_unit;
992 /* if we're off the page, then scroll.
995 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
996 center_screen_internal (frame, page);
1001 Editor::center_screen_internal (nframes_t frame, float page)
1006 frame -= (nframes_t) page;
1011 reset_x_origin (frame);
1015 Editor::handle_new_duration ()
1017 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1019 nframes_t new_end = session->get_maximum_extent() + (nframes_t) floorf (current_page_frames() * 0.10f);
1021 if (new_end > last_canvas_frame) {
1022 last_canvas_frame = new_end;
1023 horizontal_adjustment.set_upper (last_canvas_frame / frames_per_unit);
1024 reset_scrolling_region ();
1027 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1031 Editor::update_title_s (const string & snap_name)
1033 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1039 Editor::update_title ()
1041 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1044 bool dirty = session->dirty();
1046 string session_name;
1048 if (session->snap_name() != session->name()) {
1049 session_name = session->snap_name();
1051 session_name = session->name();
1055 session_name = "*" + session_name;
1058 WindowTitle title(session_name);
1059 title += Glib::get_application_name();
1060 set_title (title.get_string());
1065 Editor::connect_to_session (Session *t)
1069 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1072 /* catch up with the playhead */
1074 session->request_locate (playhead_cursor->current_frame);
1076 if (first_action_message) {
1077 first_action_message->hide();
1082 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1083 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1085 /* These signals can all be emitted by a non-GUI thread. Therefore the
1086 handlers for them must not attempt to directly interact with the GUI,
1087 but use Gtkmm2ext::UI::instance()->call_slot();
1090 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1091 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1092 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1093 session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::handle_new_audio_region)));
1094 session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::handle_audio_region_removed)));
1095 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1096 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1097 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1098 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1099 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1100 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1101 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1102 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1103 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1105 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1107 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1109 edit_groups_changed ();
1111 edit_cursor_clock.set_session (session);
1112 zoom_range_clock.set_session (session);
1113 _playlist_selector->set_session (session);
1114 nudge_clock.set_session (session);
1117 if (analysis_window != 0)
1118 analysis_window->set_session (session);
1121 Location* loc = session->locations()->auto_loop_location();
1123 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1124 if (loc->start() == loc->end()) {
1125 loc->set_end (loc->start() + 1);
1127 session->locations()->add (loc, false);
1128 session->set_auto_loop_location (loc);
1131 loc->set_name (_("Loop"));
1134 loc = session->locations()->auto_punch_location();
1136 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1137 if (loc->start() == loc->end()) {
1138 loc->set_end (loc->start() + 1);
1140 session->locations()->add (loc, false);
1141 session->set_auto_punch_location (loc);
1144 loc->set_name (_("Punch"));
1147 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1149 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1151 refresh_location_display ();
1152 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1153 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1154 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1155 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1156 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1158 handle_new_duration ();
1160 redisplay_regions ();
1161 redisplay_named_selections ();
1162 redisplay_snapshots ();
1164 initial_route_list_display ();
1166 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1167 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1170 restore_ruler_visibility ();
1171 //tempo_map_changed (Change (0));
1172 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1176 /* don't show master bus in a new session */
1178 if (ARDOUR_UI::instance()->session_is_new ()) {
1180 TreeModel::Children rows = route_display_model->children();
1181 TreeModel::Children::iterator i;
1183 no_route_list_redisplay = true;
1185 for (i = rows.begin(); i != rows.end(); ++i) {
1186 TimeAxisView *tv = (*i)[route_display_columns.tv];
1187 AudioTimeAxisView *atv;
1189 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1190 if (atv->route()->master()) {
1191 route_list_display.get_selection()->unselect (i);
1196 no_route_list_redisplay = false;
1197 redisplay_route_list ();
1200 /* register for undo history */
1202 session->register_with_memento_command_factory(_id, this);
1206 Editor::build_cursors ()
1208 using namespace Gdk;
1210 Gdk::Color mbg ("#000000" ); /* Black */
1211 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1214 RefPtr<Bitmap> source, mask;
1215 source = Bitmap::create (mag_bits, mag_width, mag_height);
1216 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1217 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1220 Gdk::Color fbg ("#ffffff" );
1221 Gdk::Color ffg ("#000000" );
1224 RefPtr<Bitmap> source, mask;
1226 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1227 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1228 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1232 RefPtr<Bitmap> source, mask;
1233 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1234 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1235 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1238 grabber_cursor = new Gdk::Cursor (HAND2);
1239 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1240 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1241 selector_cursor = new Gdk::Cursor (XTERM);
1242 time_fx_cursor = new Gdk::Cursor (SIZING);
1243 wait_cursor = new Gdk::Cursor (WATCH);
1244 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1248 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1250 using namespace Menu_Helpers;
1251 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1254 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1258 MenuList& items (fade_context_menu.items());
1262 switch (item_type) {
1264 case FadeInHandleItem:
1265 if (arv->audio_region()->fade_in_active()) {
1266 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_in_active), false)));
1268 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_in_active), true)));
1271 items.push_back (SeparatorElem());
1273 if (Profile->get_sae()) {
1274 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1275 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1277 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1278 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1279 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
1280 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
1281 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
1286 case FadeOutHandleItem:
1287 if (arv->audio_region()->fade_out_active()) {
1288 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_out_active), false)));
1290 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_out_active), true)));
1293 items.push_back (SeparatorElem());
1295 if (Profile->get_sae()) {
1296 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1297 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1299 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1300 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1301 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
1302 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
1303 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
1308 fatal << _("programming error: ")
1309 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1314 fade_context_menu.popup (button, time);
1318 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes_t frame)
1320 using namespace Menu_Helpers;
1321 Menu* (Editor::*build_menu_function)(nframes_t);
1324 switch (item_type) {
1326 case RegionViewName:
1327 case RegionViewNameHighlight:
1328 if (with_selection) {
1329 build_menu_function = &Editor::build_track_selection_context_menu;
1331 build_menu_function = &Editor::build_track_region_context_menu;
1336 if (with_selection) {
1337 build_menu_function = &Editor::build_track_selection_context_menu;
1339 build_menu_function = &Editor::build_track_context_menu;
1343 case CrossfadeViewItem:
1344 build_menu_function = &Editor::build_track_crossfade_context_menu;
1348 if (clicked_audio_trackview->get_diskstream()) {
1349 build_menu_function = &Editor::build_track_context_menu;
1351 build_menu_function = &Editor::build_track_bus_context_menu;
1356 /* probably shouldn't happen but if it does, we don't care */
1360 menu = (this->*build_menu_function)(frame);
1361 menu->set_name ("ArdourContextMenu");
1363 /* now handle specific situations */
1365 switch (item_type) {
1367 case RegionViewName:
1368 case RegionViewNameHighlight:
1369 if (!with_selection) {
1370 if (region_edit_menu_split_item) {
1371 if (clicked_regionview && clicked_regionview->region()->covers (edit_cursor->current_frame)) {
1372 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
1374 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
1378 if (region_edit_menu_split_multichannel_item) {
1379 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1380 // GTK2FIX find the action, change its sensitivity
1381 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1383 // GTK2FIX see above
1384 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1393 case CrossfadeViewItem:
1400 /* probably shouldn't happen but if it does, we don't care */
1404 if (item_type != SelectionItem && clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
1406 /* Bounce to disk */
1408 using namespace Menu_Helpers;
1409 MenuList& edit_items = menu->items();
1411 edit_items.push_back (SeparatorElem());
1413 switch (clicked_audio_trackview->audio_track()->freeze_state()) {
1414 case AudioTrack::NoFreeze:
1415 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1418 case AudioTrack::Frozen:
1419 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1422 case AudioTrack::UnFrozen:
1423 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1429 menu->popup (button, time);
1433 Editor::build_track_context_menu (nframes_t ignored)
1435 using namespace Menu_Helpers;
1437 MenuList& edit_items = track_context_menu.items();
1440 add_dstream_context_items (edit_items);
1441 return &track_context_menu;
1445 Editor::build_track_bus_context_menu (nframes_t ignored)
1447 using namespace Menu_Helpers;
1449 MenuList& edit_items = track_context_menu.items();
1452 add_bus_context_items (edit_items);
1453 return &track_context_menu;
1457 Editor::build_track_region_context_menu (nframes_t frame)
1459 using namespace Menu_Helpers;
1460 MenuList& edit_items = track_region_context_menu.items();
1463 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1466 boost::shared_ptr<Diskstream> ds;
1467 boost::shared_ptr<Playlist> pl;
1469 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1470 Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)frame * ds->speed()));
1471 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1472 add_region_context_items (atv->audio_view(), (*i), edit_items);
1478 add_dstream_context_items (edit_items);
1480 return &track_region_context_menu;
1484 Editor::build_track_crossfade_context_menu (nframes_t frame)
1486 using namespace Menu_Helpers;
1487 MenuList& edit_items = track_crossfade_context_menu.items();
1488 edit_items.clear ();
1490 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1493 boost::shared_ptr<Diskstream> ds;
1494 boost::shared_ptr<Playlist> pl;
1495 boost::shared_ptr<AudioPlaylist> apl;
1497 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1499 Playlist::RegionList* regions = pl->regions_at (frame);
1500 AudioPlaylist::Crossfades xfades;
1502 apl->crossfades_at (frame, xfades);
1504 bool many = xfades.size() > 1;
1506 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1507 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1510 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1511 add_region_context_items (atv->audio_view(), (*i), edit_items);
1518 add_dstream_context_items (edit_items);
1520 return &track_crossfade_context_menu;
1525 Editor::analyze_region_selection()
1527 if (analysis_window == 0) {
1528 analysis_window = new AnalysisWindow();
1531 analysis_window->set_session(session);
1533 analysis_window->show_all();
1536 analysis_window->set_regionmode();
1537 analysis_window->analyze();
1539 analysis_window->present();
1543 Editor::analyze_range_selection()
1545 if (analysis_window == 0) {
1546 analysis_window = new AnalysisWindow();
1549 analysis_window->set_session(session);
1551 analysis_window->show_all();
1554 analysis_window->set_rangemode();
1555 analysis_window->analyze();
1557 analysis_window->present();
1559 #endif /* FFT_ANALYSIS */
1564 Editor::build_track_selection_context_menu (nframes_t ignored)
1566 using namespace Menu_Helpers;
1567 MenuList& edit_items = track_selection_context_menu.items();
1568 edit_items.clear ();
1570 add_selection_context_items (edit_items);
1571 // edit_items.push_back (SeparatorElem());
1572 // add_dstream_context_items (edit_items);
1574 return &track_selection_context_menu;
1578 Editor::add_crossfade_context_items (AudioStreamView* view, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1580 using namespace Menu_Helpers;
1581 Menu *xfade_menu = manage (new Menu);
1582 MenuList& items = xfade_menu->items();
1583 xfade_menu->set_name ("ArdourContextMenu");
1586 if (xfade->active()) {
1592 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1593 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1595 if (xfade->can_follow_overlap()) {
1597 if (xfade->following_overlap()) {
1598 str = _("Convert to short");
1600 str = _("Convert to full");
1603 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1607 str = xfade->out()->name();
1609 str += xfade->in()->name();
1611 str = _("Crossfade");
1614 edit_items.push_back (MenuElem (str, *xfade_menu));
1615 edit_items.push_back (SeparatorElem());
1619 Editor::xfade_edit_left_region ()
1621 if (clicked_crossfadeview) {
1622 clicked_crossfadeview->left_view.show_region_editor ();
1627 Editor::xfade_edit_right_region ()
1629 if (clicked_crossfadeview) {
1630 clicked_crossfadeview->right_view.show_region_editor ();
1635 Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1637 using namespace Menu_Helpers;
1638 Menu *region_menu = manage (new Menu);
1639 MenuList& items = region_menu->items();
1640 region_menu->set_name ("ArdourContextMenu");
1642 boost::shared_ptr<AudioRegion> ar;
1645 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1648 /* when this particular menu pops up, make the relevant region
1652 region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1654 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1655 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1656 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1657 items.push_back (SeparatorElem());
1658 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_cursor)));
1659 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1660 items.push_back (SeparatorElem());
1662 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::audition_selected_region)));
1663 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1664 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1667 items.push_back (MenuElem (_("Analyze region"), mem_fun(*this, &Editor::analyze_region_selection)));
1670 items.push_back (SeparatorElem());
1672 sigc::connection fooc;
1674 items.push_back (CheckMenuElem (_("Lock")));
1675 region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1676 fooc = region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
1677 if (region->locked()) {
1679 region_lock_item->set_active();
1682 items.push_back (CheckMenuElem (_("Mute")));
1683 region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1684 fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
1685 if (region->muted()) {
1687 region_mute_item->set_active();
1691 if (!Profile->get_sae()) {
1692 items.push_back (CheckMenuElem (_("Opaque")));
1693 region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1694 fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
1695 if (region->opaque()) {
1697 region_opaque_item->set_active();
1702 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1703 if (region->at_natural_position()) {
1704 items.back().set_sensitive (false);
1707 items.push_back (SeparatorElem());
1711 RegionView* rv = sv->find_view (ar);
1712 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1714 if (!Profile->get_sae()) {
1715 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
1717 items.push_back (CheckMenuElem (_("Envelope Visible")));
1718 region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1719 fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
1720 if (arv->envelope_visible()) {
1722 region_envelope_visible_item->set_active (true);
1726 items.push_back (CheckMenuElem (_("Envelope Active")));
1727 region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1728 fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
1730 if (ar->envelope_active()) {
1732 region_envelope_active_item->set_active (true);
1736 items.push_back (SeparatorElem());
1739 if (ar->scale_amplitude() != 1.0f) {
1740 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1742 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1746 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1747 items.push_back (SeparatorElem());
1749 /* range related stuff */
1751 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1752 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_audio_region)));
1753 items.push_back (SeparatorElem());
1757 Menu *nudge_menu = manage (new Menu());
1758 MenuList& nudge_items = nudge_menu->items();
1759 nudge_menu->set_name ("ArdourContextMenu");
1761 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1762 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1763 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1764 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1766 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1767 items.push_back (SeparatorElem());
1769 Menu *trim_menu = manage (new Menu);
1770 MenuList& trim_items = trim_menu->items();
1771 trim_menu->set_name ("ArdourContextMenu");
1773 trim_items.push_back (MenuElem (_("Start to edit cursor"), mem_fun(*this, &Editor::trim_region_from_edit_cursor)));
1774 trim_items.push_back (MenuElem (_("Edit cursor to end"), mem_fun(*this, &Editor::trim_region_to_edit_cursor)));
1776 items.push_back (MenuElem (_("Trim"), *trim_menu));
1777 items.push_back (SeparatorElem());
1779 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1780 region_edit_menu_split_item = &items.back();
1782 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1783 region_edit_menu_split_multichannel_item = &items.back();
1785 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1786 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1787 items.push_back (SeparatorElem());
1788 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1790 /* OK, stick the region submenu at the top of the list, and then add
1794 /* we have to hack up the region name because "_" has a special
1795 meaning for menu titles.
1798 string::size_type pos = 0;
1799 string menu_item_name = region->name();
1801 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1802 menu_item_name.replace (pos, 1, "__");
1806 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1807 edit_items.push_back (SeparatorElem());
1811 Editor::add_selection_context_items (Menu_Helpers::MenuList& items)
1813 using namespace Menu_Helpers;
1815 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1816 items.push_back (MenuElem (_("Loop range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
1819 items.push_back (SeparatorElem());
1820 items.push_back (MenuElem (_("Analyze range"), mem_fun(*this, &Editor::analyze_range_selection)));
1823 items.push_back (SeparatorElem());
1824 items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
1825 items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
1827 items.push_back (SeparatorElem());
1828 items.push_back (MenuElem (_("Convert to region in-place"), mem_fun(*this, &Editor::separate_region_from_selection)));
1829 items.push_back (MenuElem (_("Convert to region in region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1831 items.push_back (SeparatorElem());
1832 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1834 items.push_back (SeparatorElem());
1835 items.push_back (MenuElem (_("Set loop from selection"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
1836 items.push_back (MenuElem (_("Set punch from selection"), mem_fun(*this, &Editor::set_punch_from_selection)));
1838 items.push_back (SeparatorElem());
1839 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
1840 items.push_back (SeparatorElem());
1841 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1842 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1843 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1844 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::create_named_selection)));
1845 items.push_back (SeparatorElem());
1846 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1847 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1851 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1853 using namespace Menu_Helpers;
1857 Menu *play_menu = manage (new Menu);
1858 MenuList& play_items = play_menu->items();
1859 play_menu->set_name ("ArdourContextMenu");
1861 play_items.push_back (MenuElem (_("Play from edit cursor"), mem_fun(*this, &Editor::play_from_edit_cursor)));
1862 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1863 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1864 play_items.push_back (SeparatorElem());
1865 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1867 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1871 Menu *select_menu = manage (new Menu);
1872 MenuList& select_items = select_menu->items();
1873 select_menu->set_name ("ArdourContextMenu");
1875 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1876 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1877 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1878 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1879 select_items.push_back (SeparatorElem());
1880 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1881 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1882 select_items.push_back (SeparatorElem());
1883 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1884 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1885 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1886 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1887 select_items.push_back (MenuElem (_("Select all between cursors"), bind (mem_fun(*this, &Editor::select_all_selectables_between_cursors), playhead_cursor, edit_cursor)));
1888 select_items.push_back (SeparatorElem());
1890 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1894 Menu *cutnpaste_menu = manage (new Menu);
1895 MenuList& cutnpaste_items = cutnpaste_menu->items();
1896 cutnpaste_menu->set_name ("ArdourContextMenu");
1898 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1899 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1900 cutnpaste_items.push_back (MenuElem (_("Paste at edit cursor"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1901 cutnpaste_items.push_back (MenuElem (_("Paste at mouse"), mem_fun(*this, &Editor::mouse_paste)));
1903 cutnpaste_items.push_back (SeparatorElem());
1905 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1906 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
1908 cutnpaste_items.push_back (SeparatorElem());
1910 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
1912 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
1914 /* Adding new material */
1916 edit_items.push_back (SeparatorElem());
1917 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
1918 edit_items.push_back (MenuElem (_("Insert Existing Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
1922 Menu *nudge_menu = manage (new Menu());
1923 MenuList& nudge_items = nudge_menu->items();
1924 nudge_menu->set_name ("ArdourContextMenu");
1926 edit_items.push_back (SeparatorElem());
1927 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1928 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1929 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1930 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1932 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1936 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
1938 using namespace Menu_Helpers;
1942 Menu *play_menu = manage (new Menu);
1943 MenuList& play_items = play_menu->items();
1944 play_menu->set_name ("ArdourContextMenu");
1946 play_items.push_back (MenuElem (_("Play from edit cursor"), mem_fun(*this, &Editor::play_from_edit_cursor)));
1947 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1948 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1952 Menu *select_menu = manage (new Menu);
1953 MenuList& select_items = select_menu->items();
1954 select_menu->set_name ("ArdourContextMenu");
1956 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1957 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1958 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1959 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1960 select_items.push_back (SeparatorElem());
1961 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1962 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1963 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1964 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1966 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1970 Menu *cutnpaste_menu = manage (new Menu);
1971 MenuList& cutnpaste_items = cutnpaste_menu->items();
1972 cutnpaste_menu->set_name ("ArdourContextMenu");
1974 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1975 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1976 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1978 Menu *nudge_menu = manage (new Menu());
1979 MenuList& nudge_items = nudge_menu->items();
1980 nudge_menu->set_name ("ArdourContextMenu");
1982 edit_items.push_back (SeparatorElem());
1983 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1984 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1985 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1986 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1988 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1991 /* CURSOR SETTING AND MARKS AND STUFF */
1994 Editor::set_snap_to (SnapType st)
1997 string str = snap_type_strings[(int) st];
1999 if (str != snap_type_selector.get_active_text()) {
2000 snap_type_selector.set_active_text (str);
2005 switch (snap_type) {
2006 case SnapToAThirtysecondBeat:
2007 case SnapToASixteenthBeat:
2008 case SnapToAEighthBeat:
2009 case SnapToAQuarterBeat:
2010 case SnapToAThirdBeat:
2011 update_tempo_based_rulers ();
2019 Editor::set_snap_mode (SnapMode mode)
2022 string str = snap_mode_strings[(int)mode];
2024 if (str != snap_mode_selector.get_active_text ()) {
2025 snap_mode_selector.set_active_text (str);
2032 Editor::set_state (const XMLNode& node)
2034 const XMLProperty* prop;
2036 int x, y, xoff, yoff;
2039 if ((prop = node.property ("id")) != 0) {
2040 _id = prop->value ();
2043 if ((geometry = find_named_node (node, "geometry")) == 0) {
2045 g.base_width = default_width;
2046 g.base_height = default_height;
2054 g.base_width = atoi(geometry->property("x_size")->value());
2055 g.base_height = atoi(geometry->property("y_size")->value());
2056 x = atoi(geometry->property("x_pos")->value());
2057 y = atoi(geometry->property("y_pos")->value());
2058 xoff = atoi(geometry->property("x_off")->value());
2059 yoff = atoi(geometry->property("y_off")->value());
2062 set_default_size (g.base_width, g.base_height);
2065 if (session && (prop = node.property ("playhead"))) {
2066 nframes_t pos = atol (prop->value().c_str());
2067 playhead_cursor->set_position (pos);
2069 playhead_cursor->set_position (0);
2071 /* reset_x_origin() doesn't work right here, since the old
2072 position may be zero already, and it does nothing in such
2077 horizontal_adjustment.set_value (0);
2080 if (session && (prop = node.property ("edit-cursor"))) {
2081 nframes_t pos = atol (prop->value().c_str());
2082 edit_cursor->set_position (pos);
2084 edit_cursor->set_position (0);
2087 if ((prop = node.property ("mixer-width"))) {
2088 editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
2091 if ((prop = node.property ("zoom-focus"))) {
2092 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2095 if ((prop = node.property ("zoom"))) {
2096 reset_zoom (PBD::atof (prop->value()));
2099 if ((prop = node.property ("snap-to"))) {
2100 set_snap_to ((SnapType) atoi (prop->value()));
2103 if ((prop = node.property ("snap-mode"))) {
2104 set_snap_mode ((SnapMode) atoi (prop->value()));
2107 if ((prop = node.property ("mouse-mode"))) {
2108 MouseMode m = str2mousemode(prop->value());
2109 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2110 set_mouse_mode (m, true);
2112 mouse_mode = MouseGain; /* lie, to force the mode switch */
2113 set_mouse_mode (MouseObject, true);
2116 if ((prop = node.property ("show-waveforms"))) {
2117 bool yn = (prop->value() == "yes");
2118 _show_waveforms = !yn;
2119 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
2121 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2122 /* do it twice to force the change */
2123 tact->set_active (!yn);
2124 tact->set_active (yn);
2128 if ((prop = node.property ("show-waveforms-recording"))) {
2129 bool yn = (prop->value() == "yes");
2130 _show_waveforms_recording = !yn;
2131 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2133 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2134 /* do it twice to force the change */
2135 tact->set_active (!yn);
2136 tact->set_active (yn);
2140 if ((prop = node.property ("show-measures"))) {
2141 bool yn = (prop->value() == "yes");
2142 _show_measures = !yn;
2143 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2145 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2146 /* do it twice to force the change */
2147 tact->set_active (!yn);
2148 tact->set_active (yn);
2152 if ((prop = node.property ("follow-playhead"))) {
2153 bool yn = (prop->value() == "yes");
2154 set_follow_playhead (yn);
2155 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2157 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2158 if (tact->get_active() != yn) {
2159 tact->set_active (yn);
2164 if ((prop = node.property ("region-list-sort-type"))) {
2165 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2166 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2169 if ((prop = node.property ("xfades-visible"))) {
2170 bool yn = (prop->value() == "yes");
2171 _xfade_visibility = !yn;
2172 // set_xfade_visibility (yn);
2175 if ((prop = node.property ("show-editor-mixer"))) {
2177 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2180 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2181 bool yn = (prop->value() == X_("yes"));
2183 /* do it twice to force the change */
2185 tact->set_active (!yn);
2186 tact->set_active (yn);
2195 Editor::get_state ()
2197 XMLNode* node = new XMLNode ("Editor");
2200 _id.print (buf, sizeof (buf));
2201 node->add_property ("id", buf);
2203 if (is_realized()) {
2204 Glib::RefPtr<Gdk::Window> win = get_window();
2206 int x, y, xoff, yoff, width, height;
2207 win->get_root_origin(x, y);
2208 win->get_position(xoff, yoff);
2209 win->get_size(width, height);
2211 XMLNode* geometry = new XMLNode ("geometry");
2213 snprintf(buf, sizeof(buf), "%d", width);
2214 geometry->add_property("x_size", string(buf));
2215 snprintf(buf, sizeof(buf), "%d", height);
2216 geometry->add_property("y_size", string(buf));
2217 snprintf(buf, sizeof(buf), "%d", x);
2218 geometry->add_property("x_pos", string(buf));
2219 snprintf(buf, sizeof(buf), "%d", y);
2220 geometry->add_property("y_pos", string(buf));
2221 snprintf(buf, sizeof(buf), "%d", xoff);
2222 geometry->add_property("x_off", string(buf));
2223 snprintf(buf, sizeof(buf), "%d", yoff);
2224 geometry->add_property("y_off", string(buf));
2225 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2226 geometry->add_property("edit_pane_pos", string(buf));
2228 node->add_child_nocopy (*geometry);
2231 maybe_add_mixer_strip_width (*node);
2233 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2234 node->add_property ("zoom-focus", buf);
2235 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2236 node->add_property ("zoom", buf);
2237 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2238 node->add_property ("snap-to", buf);
2239 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2240 node->add_property ("snap-mode", buf);
2242 snprintf (buf, sizeof (buf), "%" PRIu32, playhead_cursor->current_frame);
2243 node->add_property ("playhead", buf);
2244 snprintf (buf, sizeof (buf), "%" PRIu32, edit_cursor->current_frame);
2245 node->add_property ("edit-cursor", buf);
2247 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2248 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2249 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2250 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2251 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2252 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2253 node->add_property ("mouse-mode", enum2str(mouse_mode));
2255 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2257 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2258 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2267 Editor::trackview_by_y_position (double y)
2269 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2273 if ((tv = (*iter)->covers_y_position (y)) != 0) {
2282 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
2284 Location* before = 0;
2285 Location* after = 0;
2291 const nframes64_t one_second = session->frame_rate();
2292 const nframes64_t one_minute = session->frame_rate() * 60;
2293 const nframes64_t one_smpte_second = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
2294 nframes64_t one_smpte_minute = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
2295 nframes64_t presnap = start;
2297 switch (snap_type) {
2303 start = (nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2305 start = (nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2309 case SnapToSMPTEFrame:
2310 if (fmod((double)start, (double)session->frames_per_smpte_frame()) > (session->frames_per_smpte_frame() / 2)) {
2311 start = (nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2313 start = (nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2317 case SnapToSMPTESeconds:
2318 if (session->smpte_offset_negative())
2320 start += session->smpte_offset ();
2322 start -= session->smpte_offset ();
2324 if (start % one_smpte_second > one_smpte_second / 2) {
2325 start = (nframes_t) ceil ((double) start / one_smpte_second) * one_smpte_second;
2327 start = (nframes_t) floor ((double) start / one_smpte_second) * one_smpte_second;
2330 if (session->smpte_offset_negative())
2332 start -= session->smpte_offset ();
2334 start += session->smpte_offset ();
2338 case SnapToSMPTEMinutes:
2339 if (session->smpte_offset_negative())
2341 start += session->smpte_offset ();
2343 start -= session->smpte_offset ();
2345 if (start % one_smpte_minute > one_smpte_minute / 2) {
2346 start = (nframes_t) ceil ((double) start / one_smpte_minute) * one_smpte_minute;
2348 start = (nframes_t) floor ((double) start / one_smpte_minute) * one_smpte_minute;
2350 if (session->smpte_offset_negative())
2352 start -= session->smpte_offset ();
2354 start += session->smpte_offset ();
2359 if (start % one_second > one_second / 2) {
2360 start = (nframes_t) ceil ((double) start / one_second) * one_second;
2362 start = (nframes_t) floor ((double) start / one_second) * one_second;
2367 if (start % one_minute > one_minute / 2) {
2368 start = (nframes_t) ceil ((double) start / one_minute) * one_minute;
2370 start = (nframes_t) floor ((double) start / one_minute) * one_minute;
2375 start = session->tempo_map().round_to_bar (start, direction);
2379 start = session->tempo_map().round_to_beat (start, direction);
2382 case SnapToAThirtysecondBeat:
2383 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2386 case SnapToASixteenthBeat:
2387 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2390 case SnapToAEighthBeat:
2391 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2394 case SnapToAQuarterBeat:
2395 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2398 case SnapToAThirdBeat:
2399 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2402 case SnapToEditCursor:
2403 start = edit_cursor->current_frame;
2411 before = session->locations()->first_location_before (start);
2412 after = session->locations()->first_location_after (start);
2414 if (direction < 0) {
2416 start = before->start();
2420 } else if (direction > 0) {
2422 start = after->start();
2424 start = session->current_end_frame();
2429 /* find nearest of the two */
2430 if ((start - before->start()) < (after->start() - start)) {
2431 start = before->start();
2433 start = after->start();
2436 start = before->start();
2439 start = after->start();
2446 case SnapToRegionStart:
2447 case SnapToRegionEnd:
2448 case SnapToRegionSync:
2449 case SnapToRegionBoundary:
2450 if (!region_boundary_cache.empty()) {
2451 vector<nframes_t>::iterator i;
2453 if (direction > 0) {
2454 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2456 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2459 if (i != region_boundary_cache.end()) {
2462 start = region_boundary_cache.back();
2468 switch (snap_mode) {
2474 if (presnap > start) {
2475 if (presnap > (start + unit_to_frame(snap_threshold))) {
2479 } else if (presnap < start) {
2480 if (presnap < (start - unit_to_frame(snap_threshold))) {
2492 Editor::setup_toolbar ()
2496 const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
2499 /* Mode Buttons (tool selection) */
2501 vector<ToggleButton *> mouse_mode_buttons;
2503 mouse_move_button.add (*(manage (new Image (::get_icon("tool_object")))));
2504 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2505 mouse_mode_buttons.push_back (&mouse_move_button);
2506 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2507 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2508 mouse_mode_buttons.push_back (&mouse_select_button);
2509 mouse_gain_button.add (*(manage (new Image (::get_icon("tool_gain")))));
2510 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2511 mouse_mode_buttons.push_back (&mouse_gain_button);
2512 mouse_zoom_button.add (*(manage (new Image (::get_icon("tool_zoom")))));
2513 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2514 mouse_mode_buttons.push_back (&mouse_zoom_button);
2515 mouse_timefx_button.add (*(manage (new Image (::get_icon("tool_stretch")))));
2516 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2517 mouse_mode_buttons.push_back (&mouse_timefx_button);
2518 mouse_audition_button.add (*(manage (new Image (::get_icon("tool_audition")))));
2519 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2520 mouse_mode_buttons.push_back (&mouse_audition_button);
2522 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2524 HBox* mode_box = manage(new HBox);
2525 mode_box->set_border_width (2);
2526 mode_box->set_spacing(4);
2527 mouse_mode_button_box.set_spacing(1);
2528 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2529 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2530 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2531 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2532 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2533 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2534 mouse_mode_button_box.set_homogeneous(true);
2536 vector<string> edit_mode_strings;
2537 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2538 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2540 edit_mode_selector.set_name ("EditModeSelector");
2541 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, longest (edit_mode_strings).c_str(), 2+FUDGE, 10);
2542 set_popdown_strings (edit_mode_selector, edit_mode_strings);
2543 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2545 mode_box->pack_start(edit_mode_selector);
2546 mode_box->pack_start(mouse_mode_button_box);
2548 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2549 mouse_mode_tearoff->set_name ("MouseModeBase");
2551 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2552 &mouse_mode_tearoff->tearoff_window()));
2553 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2554 &mouse_mode_tearoff->tearoff_window(), 1));
2555 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2556 &mouse_mode_tearoff->tearoff_window()));
2557 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2558 &mouse_mode_tearoff->tearoff_window(), 1));
2560 mouse_move_button.set_name ("MouseModeButton");
2561 mouse_select_button.set_name ("MouseModeButton");
2562 mouse_gain_button.set_name ("MouseModeButton");
2563 mouse_zoom_button.set_name ("MouseModeButton");
2564 mouse_timefx_button.set_name ("MouseModeButton");
2565 mouse_audition_button.set_name ("MouseModeButton");
2567 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
2568 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
2569 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
2570 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
2571 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
2572 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
2574 mouse_move_button.unset_flags (CAN_FOCUS);
2575 mouse_select_button.unset_flags (CAN_FOCUS);
2576 mouse_gain_button.unset_flags (CAN_FOCUS);
2577 mouse_zoom_button.unset_flags (CAN_FOCUS);
2578 mouse_timefx_button.unset_flags (CAN_FOCUS);
2579 mouse_audition_button.unset_flags (CAN_FOCUS);
2581 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2582 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2584 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2585 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2586 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2587 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2588 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2590 // mouse_move_button.set_active (true);
2595 zoom_box.set_spacing (1);
2596 zoom_box.set_border_width (2);
2598 zoom_in_button.set_name ("EditorTimeButton");
2599 zoom_in_button.set_size_request(-1,16);
2600 zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in")))));
2601 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2602 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2604 zoom_out_button.set_name ("EditorTimeButton");
2605 zoom_out_button.set_size_request(-1,16);
2606 zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out")))));
2607 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2608 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2610 zoom_out_full_button.set_name ("EditorTimeButton");
2611 zoom_out_full_button.set_size_request(-1,16);
2612 zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full")))));
2613 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2614 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2616 zoom_focus_selector.set_name ("ZoomFocusSelector");
2617 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Edit Cursor", FUDGE, 0);
2618 set_popdown_strings (zoom_focus_selector, zoom_focus_strings);
2619 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2620 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
2622 zoom_box.pack_start (zoom_focus_selector, true, true);
2623 zoom_box.pack_start (zoom_out_button, false, false);
2624 zoom_box.pack_start (zoom_in_button, false, false);
2625 zoom_box.pack_start (zoom_out_full_button, false, false);
2627 /* Edit Cursor / Snap */
2629 snap_box.set_spacing (1);
2630 snap_box.set_border_width (2);
2632 snap_type_selector.set_name ("SnapTypeSelector");
2633 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, "SMPTE Seconds", 2+FUDGE, 10);
2634 set_popdown_strings (snap_type_selector, snap_type_strings);
2635 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2636 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Unit to snap cursors and ranges to"));
2638 snap_mode_selector.set_name ("SnapModeSelector");
2639 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, "Magnetic Snap", 2+FUDGE, 10);
2640 set_popdown_strings (snap_mode_selector, snap_mode_strings);
2641 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2643 snap_box.pack_start (edit_cursor_clock, false, false);
2644 snap_box.pack_start (snap_mode_selector, false, false);
2645 snap_box.pack_start (snap_type_selector, false, false);
2650 HBox *nudge_box = manage (new HBox);
2651 nudge_box->set_spacing(1);
2652 nudge_box->set_border_width (2);
2654 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2655 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2657 nudge_box->pack_start (nudge_backward_button, false, false);
2658 nudge_box->pack_start (nudge_forward_button, false, false);
2659 nudge_box->pack_start (nudge_clock, false, false);
2662 /* Pack everything in... */
2664 HBox* hbox = new HBox;
2665 hbox->set_spacing(10);
2667 tools_tearoff = new TearOff (*hbox);
2668 tools_tearoff->set_name ("MouseModeBase");
2670 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2671 &tools_tearoff->tearoff_window()));
2672 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2673 &tools_tearoff->tearoff_window(), 0));
2674 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2675 &tools_tearoff->tearoff_window()));
2676 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2677 &tools_tearoff->tearoff_window(), 0));
2679 toolbar_hbox.set_spacing (10);
2680 toolbar_hbox.set_border_width (1);
2682 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2683 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2686 hbox->pack_start (snap_box, false, false);
2687 // hbox->pack_start (zoom_box, false, false);
2688 hbox->pack_start (*nudge_box, false, false);
2692 toolbar_base.set_name ("ToolBarBase");
2693 toolbar_base.add (toolbar_hbox);
2695 toolbar_frame.set_shadow_type (SHADOW_OUT);
2696 toolbar_frame.set_name ("BaseFrame");
2697 toolbar_frame.add (toolbar_base);
2701 Editor::convert_drop_to_paths (vector<ustring>& paths,
2702 const RefPtr<Gdk::DragContext>& context,
2705 const SelectionData& data,
2714 vector<ustring> uris = data.get_uris();
2716 cerr << "there were " << uris.size() << " in that drag data\n";
2720 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
2721 are actually URI lists. So do it by hand.
2724 if (data.get_target() != "text/plain") {
2728 /* Parse the "uri-list" format that Nautilus provides,
2729 where each pathname is delimited by \r\n
2732 const char* p = data.get_text().c_str();
2739 while (g_ascii_isspace (*p))
2743 while (*q && (*q != '\n') && (*q != '\r'))
2749 while (q > p && g_ascii_isspace (*q))
2754 uris.push_back (ustring (p, q - p + 1));
2758 p = strchr (p, '\n');
2768 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
2770 if ((*i).substr (0,7) == "file://") {
2774 PBD::url_decode (p);
2776 // scan forward past three slashes
2778 ustring::size_type slashcnt = 0;
2779 ustring::size_type n = 0;
2780 ustring::iterator x = p.begin();
2782 while (slashcnt < 3 && x != p.end()) {
2785 } else if (slashcnt == 3) {
2792 if (slashcnt != 3 || x == p.end()) {
2793 error << _("malformed URL passed to drag-n-drop code") << endmsg;
2797 paths.push_back (p.substr (n - 1));
2805 Editor::new_tempo_section ()
2811 Editor::map_transport_state ()
2813 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
2815 if (session->transport_stopped()) {
2816 have_pending_keyboard_selection = false;
2819 update_loop_range_view (true);
2824 Editor::State::State ()
2826 selection = new Selection;
2829 Editor::State::~State ()
2835 Editor::get_memento () const
2837 State *state = new State;
2839 store_state (*state);
2840 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
2844 Editor::store_state (State& state) const
2846 *state.selection = *selection;
2850 Editor::restore_state (State *state)
2852 if (*selection == *state->selection) {
2856 *selection = *state->selection;
2857 time_selection_changed ();
2858 region_selection_changed ();
2860 /* XXX other selection change handlers? */
2864 Editor::begin_reversible_command (string name)
2867 // before = &get_state();
2868 session->begin_reversible_command (name);
2873 Editor::commit_reversible_command ()
2876 // session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
2877 session->commit_reversible_command ();
2882 Editor::set_edit_group_solo (Route& route, bool yn)
2884 RouteGroup *edit_group;
2886 if ((edit_group = route.edit_group()) != 0) {
2887 edit_group->apply (&Route::set_solo, yn, this);
2889 route.set_solo (yn, this);
2894 Editor::set_edit_group_mute (Route& route, bool yn)
2896 RouteGroup *edit_group = 0;
2898 if ((edit_group == route.edit_group()) != 0) {
2899 edit_group->apply (&Route::set_mute, yn, this);
2901 route.set_mute (yn, this);
2906 Editor::history_changed ()
2910 if (undo_action && session) {
2911 if (session->undo_depth() == 0) {
2914 label = string_compose(_("Undo (%1)"), session->next_undo());
2916 undo_action->property_label() = label;
2919 if (redo_action && session) {
2920 if (session->redo_depth() == 0) {
2923 label = string_compose(_("Redo (%1)"), session->next_redo());
2925 redo_action->property_label() = label;
2930 Editor::duplicate_dialog (bool dup_region)
2932 if (selection->regions.empty() && (selection->time.length() == 0)) {
2936 ArdourDialog win ("duplicate dialog");
2937 Label label (_("Duplicate how many times?"));
2938 Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
2939 SpinButton spinner (adjustment);
2941 win.get_vbox()->set_spacing (12);
2942 win.get_vbox()->pack_start (label);
2944 /* dialogs have ::add_action_widget() but that puts the spinner in the wrong
2945 place, visually. so do this by hand.
2948 win.get_vbox()->pack_start (spinner);
2949 spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
2954 win.add_button (Stock::OK, RESPONSE_ACCEPT);
2955 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
2957 win.set_position (WIN_POS_MOUSE);
2959 spinner.grab_focus ();
2961 switch (win.run ()) {
2962 case RESPONSE_ACCEPT:
2968 float times = adjustment.get_value();
2970 if (!selection->regions.empty()) {
2971 duplicate_some_regions (selection->regions, times);
2973 duplicate_selection (times);
2978 Editor::show_verbose_canvas_cursor ()
2980 verbose_canvas_cursor->raise_to_top();
2981 verbose_canvas_cursor->show();
2982 verbose_cursor_visible = true;
2986 Editor::hide_verbose_canvas_cursor ()
2988 verbose_canvas_cursor->hide();
2989 verbose_cursor_visible = false;
2993 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
2995 /* XXX get origin of canvas relative to root window,
2996 add x and y and check compared to gdk_screen_{width,height}
2998 verbose_canvas_cursor->property_text() = txt.c_str();
2999 verbose_canvas_cursor->property_x() = x;
3000 verbose_canvas_cursor->property_y() = y;
3004 Editor::set_verbose_canvas_cursor_text (const string & txt)
3006 verbose_canvas_cursor->property_text() = txt.c_str();
3010 Editor::edit_mode_selection_done ()
3016 string choice = edit_mode_selector.get_active_text();
3017 EditMode mode = Slide;
3019 if (choice == _("Splice Edit")) {
3021 } else if (choice == _("Slide Edit")) {
3025 Config->set_edit_mode (mode);
3029 Editor::snap_type_selection_done ()
3031 string choice = snap_type_selector.get_active_text();
3032 SnapType snaptype = SnapToFrame;
3034 if (choice == _("Beats/3")) {
3035 snaptype = SnapToAThirdBeat;
3036 } else if (choice == _("Beats/4")) {
3037 snaptype = SnapToAQuarterBeat;
3038 } else if (choice == _("Beats/8")) {
3039 snaptype = SnapToAEighthBeat;
3040 } else if (choice == _("Beats/16")) {
3041 snaptype = SnapToASixteenthBeat;
3042 } else if (choice == _("Beats/32")) {
3043 snaptype = SnapToAThirtysecondBeat;
3044 } else if (choice == _("Beats")) {
3045 snaptype = SnapToBeat;
3046 } else if (choice == _("Bars")) {
3047 snaptype = SnapToBar;
3048 } else if (choice == _("Marks")) {
3049 snaptype = SnapToMark;
3050 } else if (choice == _("Edit Cursor")) {
3051 snaptype = SnapToEditCursor;
3052 } else if (choice == _("Region starts")) {
3053 snaptype = SnapToRegionStart;
3054 } else if (choice == _("Region ends")) {
3055 snaptype = SnapToRegionEnd;
3056 } else if (choice == _("Region bounds")) {
3057 snaptype = SnapToRegionBoundary;
3058 } else if (choice == _("Region syncs")) {
3059 snaptype = SnapToRegionSync;
3060 } else if (choice == _("CD Frames")) {
3061 snaptype = SnapToCDFrame;
3062 } else if (choice == _("SMPTE Frames")) {
3063 snaptype = SnapToSMPTEFrame;
3064 } else if (choice == _("SMPTE Seconds")) {
3065 snaptype = SnapToSMPTESeconds;
3066 } else if (choice == _("SMPTE Minutes")) {
3067 snaptype = SnapToSMPTEMinutes;
3068 } else if (choice == _("Seconds")) {
3069 snaptype = SnapToSeconds;
3070 } else if (choice == _("Minutes")) {
3071 snaptype = SnapToMinutes;
3072 } else if (choice == _("None")) {
3073 snaptype = SnapToFrame;
3076 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3078 ract->set_active ();
3083 Editor::snap_mode_selection_done ()
3085 string choice = snap_mode_selector.get_active_text();
3086 SnapMode mode = SnapNormal;
3088 if (choice == _("Normal")) {
3090 } else if (choice == _("Magnetic")) {
3091 mode = SnapMagnetic;
3094 RefPtr<RadioAction> ract = snap_mode_action (mode);
3097 ract->set_active (true);
3102 Editor::zoom_focus_selection_done ()
3104 string choice = zoom_focus_selector.get_active_text();
3105 ZoomFocus focus_type = ZoomFocusLeft;
3107 if (choice == _("Left")) {
3108 focus_type = ZoomFocusLeft;
3109 } else if (choice == _("Right")) {
3110 focus_type = ZoomFocusRight;
3111 } else if (choice == _("Center")) {
3112 focus_type = ZoomFocusCenter;
3113 } else if (choice == _("Playhead")) {
3114 focus_type = ZoomFocusPlayhead;
3115 } else if (choice == _("Edit Cursor")) {
3116 focus_type = ZoomFocusEdit;
3119 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3122 ract->set_active ();
3127 Editor::edit_controls_button_release (GdkEventButton* ev)
3129 if (Keyboard::is_context_menu_event (ev)) {
3130 ARDOUR_UI::instance()->add_route (this);
3136 Editor::mouse_select_button_release (GdkEventButton* ev)
3138 /* this handles just right-clicks */
3140 if (ev->button != 3) {
3147 Editor::TrackViewList *
3148 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3151 TrackViewList::iterator i;
3153 v = new TrackViewList;
3155 if (track == 0 && group == 0) {
3159 for (i = track_views.begin(); i != track_views.end (); ++i) {
3163 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3165 /* just the view for this track
3168 v->push_back (track);
3172 /* views for all tracks in the edit group */
3174 for (i = track_views.begin(); i != track_views.end (); ++i) {
3176 if (group == 0 || (*i)->edit_group() == group) {
3186 Editor::set_zoom_focus (ZoomFocus f)
3188 string str = zoom_focus_strings[(int)f];
3190 if (str != zoom_focus_selector.get_active_text()) {
3191 zoom_focus_selector.set_active_text (str);
3194 if (zoom_focus != f) {
3197 ZoomFocusChanged (); /* EMIT_SIGNAL */
3204 Editor::ensure_float (Window& win)
3206 win.set_transient_for (*this);
3210 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3212 /* recover or initialize pane positions. do this here rather than earlier because
3213 we don't want the positions to change the child allocations, which they seem to do.
3219 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3221 static int32_t done;
3224 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3225 width = default_width;
3226 height = default_height;
3228 width = atoi(geometry->property("x_size")->value());
3229 height = atoi(geometry->property("y_size")->value());
3232 if (which == static_cast<Paned*> (&edit_pane)) {
3238 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3239 /* initial allocation is 90% to canvas, 10% to notebook */
3240 pos = (int) floor (alloc.get_width() * 0.90f);
3241 snprintf (buf, sizeof(buf), "%d", pos);
3243 pos = atoi (prop->value());
3246 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3247 edit_pane.set_position (pos);
3248 pre_maximal_pane_position = pos;
3254 Editor::detach_tearoff (Box* b, Window* w)
3256 if (tools_tearoff->torn_off() &&
3257 mouse_mode_tearoff->torn_off()) {
3258 top_hbox.remove (toolbar_frame);
3263 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3265 if (toolbar_frame.get_parent() == 0) {
3266 top_hbox.pack_end (toolbar_frame);
3271 Editor::set_show_measures (bool yn)
3273 if (_show_measures != yn) {
3276 if ((_show_measures = yn) == true) {
3284 Editor::toggle_follow_playhead ()
3286 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3288 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3289 set_follow_playhead (tact->get_active());
3294 Editor::set_follow_playhead (bool yn)
3296 if (_follow_playhead != yn) {
3297 if ((_follow_playhead = yn) == true) {
3299 update_current_screen ();
3306 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
3308 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3310 xfade->set_active (!xfade->active());
3315 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
3317 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3319 xfade->set_follow_overlap (!xfade->following_overlap());
3324 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
3326 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3332 CrossfadeEditor cew (*session, xfade, xfade->fade_in().get_min_y(), 1.0);
3336 switch (cew.run ()) {
3337 case RESPONSE_ACCEPT:
3344 xfade->StateChanged (Change (~0));
3348 Editor::playlist_selector () const
3350 return *_playlist_selector;
3354 Editor::get_nudge_distance (nframes_t pos, nframes_t& next)
3358 ret = nudge_clock.current_duration (pos);
3359 next = ret + 1; /* XXXX fix me */
3365 Editor::end_location_changed (Location* location)
3367 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3368 reset_scrolling_region ();
3372 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
3374 ArdourDialog dialog ("playlist deletion dialog");
3375 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3376 "If left alone, no audio files used by it will be cleaned.\n"
3377 "If deleted, audio files used by it alone by will cleaned."),
3380 dialog.set_position (WIN_POS_CENTER);
3381 dialog.get_vbox()->pack_start (label);
3385 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3386 dialog.add_button (_("Keep playlist"), RESPONSE_REJECT);
3387 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3389 switch (dialog.run ()) {
3390 case RESPONSE_ACCEPT:
3391 /* delete the playlist */
3395 case RESPONSE_REJECT:
3396 /* keep the playlist */
3408 Editor::audio_region_selection_covers (nframes_t where)
3410 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3411 if ((*a)->region()->covers (where)) {
3420 Editor::prepare_for_cleanup ()
3422 cut_buffer->clear_regions ();
3423 cut_buffer->clear_playlists ();
3425 selection->clear_regions ();
3426 selection->clear_playlists ();
3430 Editor::transport_loop_location()
3433 return session->locations()->auto_loop_location();
3440 Editor::transport_punch_location()
3443 return session->locations()->auto_punch_location();
3450 Editor::control_layout_scroll (GdkEventScroll* ev)
3452 switch (ev->direction) {
3454 scroll_tracks_up_line ();
3458 case GDK_SCROLL_DOWN:
3459 scroll_tracks_down_line ();
3463 /* no left/right handling yet */
3471 /** A new snapshot has been selected.
3474 Editor::snapshot_display_selection_changed ()
3476 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
3478 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
3480 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
3482 if (snap_name.length() == 0) {
3486 if (session->snap_name() == snap_name) {
3490 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
3495 Editor::snapshot_display_button_press (GdkEventButton* ev)
3497 if (ev->button == 3) {
3498 /* Right-click on the snapshot list. Work out which snapshot it
3500 Gtk::TreeModel::Path path;
3501 Gtk::TreeViewColumn* col;
3504 snapshot_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, col, cx, cy);
3505 Gtk::TreeModel::iterator iter = snapshot_display_model->get_iter (path);
3507 Gtk::TreeModel::Row row = *iter;
3508 popup_snapshot_context_menu (ev->button, ev->time, row[snapshot_display_columns.real_name]);
3517 /** Pop up the snapshot display context menu.
3518 * @param button Button used to open the menu.
3519 * @param time Menu open time.
3520 * @snapshot_name Name of the snapshot that the menu click was over.
3524 Editor::popup_snapshot_context_menu (int button, int32_t time, Glib::ustring snapshot_name)
3526 using namespace Menu_Helpers;
3528 MenuList& items (snapshot_context_menu.items());
3531 const bool modification_allowed = (session->snap_name() != snapshot_name && session->name() != snapshot_name);
3533 items.push_back (MenuElem (_("Remove"), bind (mem_fun (*this, &Editor::remove_snapshot), snapshot_name)));
3534 if (!modification_allowed) {
3535 items.back().set_sensitive (false);
3538 items.push_back (MenuElem (_("Rename"), bind (mem_fun (*this, &Editor::rename_snapshot), snapshot_name)));
3539 if (!modification_allowed) {
3540 items.back().set_sensitive (false);
3543 snapshot_context_menu.popup (button, time);
3547 Editor::rename_snapshot (Glib::ustring old_name)
3549 ArdourPrompter prompter(true);
3553 prompter.set_name ("Prompter");
3554 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
3555 prompter.set_prompt (_("New name of snapshot"));
3556 prompter.set_initial_text (old_name);
3558 if (prompter.run() == RESPONSE_ACCEPT) {
3559 prompter.get_result (new_name);
3560 if (new_name.length()) {
3561 session->rename_state (old_name, new_name);
3562 redisplay_snapshots ();
3569 Editor::remove_snapshot (Glib::ustring name)
3571 vector<string> choices;
3573 std::string prompt = string_compose (_("Do you really want to remove snapshot \"%1\" ?\n(cannot be undone)"), name);
3575 choices.push_back (_("No, do nothing."));
3576 choices.push_back (_("Yes, remove it."));
3578 Gtkmm2ext::Choice prompter (prompt, choices);
3580 if (prompter.run () == 1) {
3581 session->remove_state (name);
3582 redisplay_snapshots ();
3587 Editor::redisplay_snapshots ()
3593 vector<string*>* states;
3595 if ((states = session->possible_states()) == 0) {
3599 snapshot_display_model->clear ();
3601 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
3602 string statename = *(*i);
3603 TreeModel::Row row = *(snapshot_display_model->append());
3605 /* this lingers on in case we ever want to change the visible
3606 name of the snapshot.
3609 string display_name;
3610 display_name = statename;
3612 if (statename == session->snap_name()) {
3613 snapshot_display.get_selection()->select(row);
3616 row[snapshot_display_columns.visible_name] = display_name;
3617 row[snapshot_display_columns.real_name] = statename;
3624 Editor::session_state_saved (string snap_name)
3626 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
3627 redisplay_snapshots ();
3631 Editor::maximise_editing_space ()
3633 initial_ruler_update_required = true;
3635 mouse_mode_tearoff->set_visible (false);
3636 tools_tearoff->set_visible (false);
3638 pre_maximal_pane_position = edit_pane.get_position();
3639 pre_maximal_editor_width = this->get_width();
3641 if(post_maximal_pane_position == 0) {
3642 post_maximal_pane_position = edit_pane.get_width();
3647 if(post_maximal_editor_width) {
3648 edit_pane.set_position (post_maximal_pane_position -
3649 abs(post_maximal_editor_width - pre_maximal_editor_width));
3651 edit_pane.set_position (post_maximal_pane_position);
3656 Editor::restore_editing_space ()
3658 initial_ruler_update_required = true;
3660 // user changed width of pane during fullscreen
3661 if(post_maximal_pane_position != edit_pane.get_position()) {
3662 post_maximal_pane_position = edit_pane.get_position();
3667 mouse_mode_tearoff->set_visible (true);
3668 tools_tearoff->set_visible (true);
3669 post_maximal_editor_width = this->get_width();
3672 edit_pane.set_position (
3673 pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width)
3678 Editor::new_playlists ()
3680 begin_reversible_command (_("new playlists"));
3681 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist));
3682 commit_reversible_command ();
3686 Editor::copy_playlists ()
3688 begin_reversible_command (_("copy playlists"));
3689 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist));
3690 commit_reversible_command ();
3694 Editor::clear_playlists ()
3696 begin_reversible_command (_("clear playlists"));
3697 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist));
3698 commit_reversible_command ();
3702 Editor::mapped_use_new_playlist (AudioTimeAxisView& atv, uint32_t sz)
3704 atv.use_new_playlist (sz > 1 ? false : true);
3708 Editor::mapped_use_copy_playlist (AudioTimeAxisView& atv, uint32_t sz)
3710 atv.use_copy_playlist (sz > 1 ? false : true);
3714 Editor::mapped_clear_playlist (AudioTimeAxisView& atv, uint32_t sz)
3716 atv.clear_playlist ();
3720 Editor::on_key_press_event (GdkEventKey* ev)
3722 return key_press_focus_accelerator_handler (*this, ev);
3726 Editor::reset_x_origin (nframes_t frame)
3728 queue_visual_change (frame);
3732 Editor::reset_zoom (double fpu)
3734 queue_visual_change (fpu);
3738 Editor::reposition_and_zoom (nframes_t frame, double fpu)
3740 reset_x_origin (frame);
3745 Editor::set_frames_per_unit (double fpu)
3749 /* this is the core function that controls the zoom level of the canvas. it is called
3750 whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
3753 if (fpu == frames_per_unit) {
3761 // convert fpu to frame count
3763 frames = (nframes_t) floor (fpu * canvas_width);
3765 /* don't allow zooms that fit more than the maximum number
3766 of frames into an 800 pixel wide space.
3769 if (max_frames / fpu < 800.0) {
3773 if (fpu == frames_per_unit) {
3777 frames_per_unit = fpu;
3779 if (frames != zoom_range_clock.current_duration()) {
3780 zoom_range_clock.set (frames);
3783 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
3784 if (!selection->tracks.empty()) {
3785 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3786 (*i)->reshow_selection (selection->time);
3789 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3790 (*i)->reshow_selection (selection->time);
3795 ZoomChanged (); /* EMIT_SIGNAL */
3797 reset_hscrollbar_stepping ();
3798 reset_scrolling_region ();
3800 if (edit_cursor) edit_cursor->set_position (edit_cursor->current_frame);
3801 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
3807 Editor::queue_visual_change (nframes_t where)
3809 pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::TimeOrigin);
3810 pending_visual_change.time_origin = where;
3812 if (pending_visual_change.idle_handler_id < 0) {
3813 pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
3818 Editor::queue_visual_change (double fpu)
3820 pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::ZoomLevel);
3821 pending_visual_change.frames_per_unit = fpu;
3823 if (pending_visual_change.idle_handler_id < 0) {
3824 pending_visual_change.idle_handler_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE, _idle_visual_changer, this, 0);
3829 Editor::_idle_visual_changer (void* arg)
3831 return static_cast<Editor*>(arg)->idle_visual_changer ();
3835 Editor::idle_visual_changer ()
3837 VisualChange::Type p = pending_visual_change.pending;
3839 pending_visual_change.pending = (VisualChange::Type) 0;
3840 pending_visual_change.idle_handler_id = -1;
3842 if (p & VisualChange::ZoomLevel) {
3843 set_frames_per_unit (pending_visual_change.frames_per_unit);
3846 if (p & VisualChange::TimeOrigin) {
3847 if (pending_visual_change.time_origin != leftmost_frame) {
3848 horizontal_adjustment.set_value (pending_visual_change.time_origin/frames_per_unit);
3849 /* the signal handler will do the rest */
3851 update_fixed_rulers();
3852 redisplay_tempo (true);
3856 return 0; /* this is always a one-shot call */
3859 struct EditorOrderTimeAxisSorter {
3860 bool operator() (const TimeAxisView* a, const TimeAxisView* b) const {
3861 return a->order < b->order;
3866 Editor::sort_track_selection ()
3868 EditorOrderTimeAxisSorter cmp;
3869 selection->tracks.sort (cmp);
3873 Editor::edit_cursor_position(bool sync)
3875 if (sync && edit_cursor->current_frame != edit_cursor_clock.current_time()) {
3876 edit_cursor_clock.set(edit_cursor->current_frame, true);
3879 return edit_cursor->current_frame;
3883 Editor::set_loop_range (nframes_t start, nframes_t end, string cmd)
3885 if (!session) return;
3887 begin_reversible_command (cmd);
3891 if ((tll = transport_loop_location()) == 0) {
3892 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoLoop);
3893 XMLNode &before = session->locations()->get_state();
3894 session->locations()->add (loc, true);
3895 session->set_auto_loop_location (loc);
3896 XMLNode &after = session->locations()->get_state();
3897 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
3900 XMLNode &before = tll->get_state();
3901 tll->set_hidden (false, this);
3902 tll->set (start, end);
3903 XMLNode &after = tll->get_state();
3904 session->add_command (new MementoCommand<Location>(*tll, &before, &after));
3907 commit_reversible_command ();
3911 Editor::set_punch_range (nframes_t start, nframes_t end, string cmd)
3913 if (!session) return;
3915 begin_reversible_command (cmd);
3919 if ((tpl = transport_punch_location()) == 0) {
3920 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoPunch);
3921 XMLNode &before = session->locations()->get_state();
3922 session->locations()->add (loc, true);
3923 session->set_auto_loop_location (loc);
3924 XMLNode &after = session->locations()->get_state();
3925 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
3928 XMLNode &before = tpl->get_state();
3929 tpl->set_hidden (false, this);
3930 tpl->set (start, end);
3931 XMLNode &after = tpl->get_state();
3932 session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
3935 commit_reversible_command ();