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.
20 /* Note: public Editor methods are documented in public_editor.h */
28 #include <boost/none.hpp>
30 #include <sigc++/bind.h>
32 #include "pbd/convert.h"
33 #include "pbd/error.h"
34 #include "pbd/enumwriter.h"
35 #include "pbd/memento_command.h"
37 #include <glibmm/miscutils.h>
38 #include <gtkmm/image.h>
39 #include <gdkmm/color.h>
40 #include <gdkmm/bitmap.h>
42 #include <gtkmm2ext/grouped_buttons.h>
43 #include <gtkmm2ext/gtk_ui.h>
44 #include <gtkmm2ext/tearoff.h>
45 #include <gtkmm2ext/utils.h>
46 #include <gtkmm2ext/window_title.h>
47 #include <gtkmm2ext/choice.h>
49 #include "ardour/audio_diskstream.h"
50 #include "ardour/audio_track.h"
51 #include "ardour/audioplaylist.h"
52 #include "ardour/audioregion.h"
53 #include "ardour/location.h"
54 #include "ardour/midi_region.h"
55 #include "ardour/plugin_manager.h"
56 #include "ardour/profile.h"
57 #include "ardour/route_group.h"
58 #include "ardour/session_directory.h"
59 #include "ardour/session_route.h"
60 #include "ardour/session_state_utils.h"
61 #include "ardour/tempo.h"
62 #include "ardour/utils.h"
64 #include "control_protocol/control_protocol.h"
66 #include "ardour_ui.h"
70 #include "playlist_selector.h"
71 #include "audio_region_view.h"
72 #include "rgb_macros.h"
73 #include "selection.h"
74 #include "audio_streamview.h"
75 #include "time_axis_view.h"
76 #include "audio_time_axis.h"
78 #include "crossfade_view.h"
80 #include "public_editor.h"
81 #include "crossfade_edit.h"
82 #include "canvas_impl.h"
85 #include "gui_thread.h"
86 #include "simpleline.h"
87 #include "rhythm_ferret.h"
89 #include "tempo_lines.h"
90 #include "analysis_window.h"
91 #include "bundle_manager.h"
92 #include "global_port_matrix.h"
93 #include "editor_drag.h"
98 #include "imageframe_socket_handler.h"
102 using namespace sigc;
103 using namespace ARDOUR;
106 using namespace Glib;
107 using namespace Gtkmm2ext;
108 using namespace Editing;
110 using PBD::internationalize;
113 const double Editor::timebar_height = 15.0;
115 #include "editor_xpms"
117 static const gchar *_snap_type_strings[] = {
139 static const gchar *_snap_mode_strings[] = {
146 static const gchar *_edit_point_strings[] = {
153 static const gchar *_zoom_focus_strings[] = {
163 #ifdef USE_RUBBERBAND
164 static const gchar *_rb_opt_strings[] = {
167 N_("Balanced multitimbral mixture"),
168 N_("Unpitched percussion with stable notes"),
169 N_("Crisp monophonic instrumental"),
170 N_("Unpitched solo percussion"),
175 /* Soundfile drag-n-drop */
177 Gdk::Cursor* Editor::cross_hair_cursor = 0;
178 Gdk::Cursor* Editor::selector_cursor = 0;
179 Gdk::Cursor* Editor::trimmer_cursor = 0;
180 Gdk::Cursor* Editor::grabber_cursor = 0;
181 Gdk::Cursor* Editor::grabber_edit_point_cursor = 0;
182 Gdk::Cursor* Editor::zoom_cursor = 0;
183 Gdk::Cursor* Editor::time_fx_cursor = 0;
184 Gdk::Cursor* Editor::fader_cursor = 0;
185 Gdk::Cursor* Editor::speaker_cursor = 0;
186 Gdk::Cursor* Editor::midi_pencil_cursor = 0;
187 Gdk::Cursor* Editor::midi_select_cursor = 0;
188 Gdk::Cursor* Editor::midi_resize_cursor = 0;
189 Gdk::Cursor* Editor::midi_erase_cursor = 0;
190 Gdk::Cursor* Editor::wait_cursor = 0;
191 Gdk::Cursor* Editor::timebar_cursor = 0;
192 Gdk::Cursor* Editor::transparent_cursor = 0;
195 show_me_the_size (Requisition* r, const char* what)
197 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
202 /* time display buttons */
204 minsec_label (_("Mins:Secs")),
205 bbt_label (_("Bars:Beats")),
206 smpte_label (_("Timecode")),
207 frame_label (_("Samples")),
208 tempo_label (_("Tempo")),
209 meter_label (_("Meter")),
210 mark_label (_("Location Markers")),
211 range_mark_label (_("Range Markers")),
212 transport_mark_label (_("Loop/Punch Ranges")),
213 cd_mark_label (_("CD Markers")),
214 edit_packer (4, 4, true),
216 /* the values here don't matter: layout widgets
217 reset them as needed.
220 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
221 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
223 /* tool bar related */
225 edit_point_clock (X_("editpoint"), false, X_("EditPointClock"), true),
226 zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true),
228 toolbar_selection_clock_table (2,3),
230 automation_mode_button (_("mode")),
231 global_automation_button (_("automation")),
233 midi_panic_button (_("Panic")),
234 midi_tools_tearoff (0),
237 image_socket_listener(0),
242 nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true),
243 meters_running(false),
244 _pending_locate_request (false)
249 /* we are a singleton */
251 PublicEditor::_instance = this;
256 selection = new Selection (this);
257 cut_buffer = new Selection (this);
259 clicked_regionview = 0;
260 clicked_axisview = 0;
261 clicked_routeview = 0;
262 clicked_crossfadeview = 0;
263 clicked_control_point = 0;
264 last_update_frame = 0;
266 current_mixer_strip = 0;
267 current_bbt_points = 0;
270 snap_type_strings = I18N (_snap_type_strings);
271 snap_mode_strings = I18N (_snap_mode_strings);
272 zoom_focus_strings = I18N (_zoom_focus_strings);
273 edit_point_strings = I18N (_edit_point_strings);
274 #ifdef USE_RUBBERBAND
275 rb_opt_strings = I18N (_rb_opt_strings);
278 snap_threshold = 5.0;
279 bbt_beat_subdivision = 4;
282 last_autoscroll_x = 0;
283 last_autoscroll_y = 0;
284 autoscroll_active = false;
285 autoscroll_timeout_tag = -1;
286 interthread_progress_window = 0;
291 current_interthread_info = 0;
292 _show_measures = true;
293 _show_waveforms_recording = true;
294 show_gain_after_trim = false;
295 route_redisplay_does_not_sync_order_keys = false;
296 route_redisplay_does_not_reset_order_keys = false;
297 no_route_list_redisplay = false;
298 verbose_cursor_on = true;
299 route_removal = false;
300 show_automatic_regions_in_region_list = true;
301 last_item_entered = 0;
302 last_item_entered_n = 0;
304 region_list_sort_type = (Editing::RegionListSortType) 0;
305 have_pending_keyboard_selection = false;
306 _follow_playhead = true;
307 _xfade_visibility = true;
308 editor_ruler_menu = 0;
309 no_ruler_shown_update = false;
310 edit_group_list_menu = 0;
312 region_list_menu = 0;
314 start_end_marker_menu = 0;
315 range_marker_menu = 0;
316 marker_menu_item = 0;
318 transport_marker_menu = 0;
319 new_transport_marker_menu = 0;
320 editor_mixer_strip_width = Wide;
321 show_editor_mixer_when_tracks_arrive = false;
322 region_edit_menu_split_multichannel_item = 0;
323 region_edit_menu_split_item = 0;
326 ignore_mouse_mode_toggle = false;
327 ignore_midi_edit_mode_toggle = false;
328 current_stepping_trackview = 0;
330 entered_regionview = 0;
332 clear_entered_track = false;
333 _new_regionviews_show_envelope = false;
335 in_edit_group_row_change = false;
337 button_release_can_deselect = true;
338 _dragging_playhead = false;
339 _dragging_edit_point = false;
340 _dragging_hscrollbar = false;
341 select_new_marker = false;
342 zoomed_to_region = false;
345 for (ARDOUR::DataType::iterator i = ARDOUR::DataType::begin(); i != ARDOUR::DataType::end(); ++i) {
346 _global_port_matrix[*i] = 0;
348 allow_vertical_scroll = false;
349 no_save_visual = false;
350 need_resize_line = false;
352 old_resize_line_y = -1;
353 no_region_list_redisplay = false;
356 scrubbing_direction = 0;
360 location_marker_color = ARDOUR_UI::config()->canvasvar_LocationMarker.get();
361 location_range_color = ARDOUR_UI::config()->canvasvar_LocationRange.get();
362 location_cd_marker_color = ARDOUR_UI::config()->canvasvar_LocationCDMarker.get();
363 location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
364 location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
366 set_midi_edit_mode (MidiEditPencil, true);
367 _edit_point = EditAtMouse;
368 set_mouse_mode (MouseObject, true);
370 frames_per_unit = 2048; /* too early to use reset_zoom () */
371 reset_hscrollbar_stepping ();
373 zoom_focus = ZoomFocusLeft;
374 set_zoom_focus (ZoomFocusLeft);
375 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
377 bbt_label.set_name ("EditorTimeButton");
378 bbt_label.set_size_request (-1, (int)timebar_height);
379 bbt_label.set_alignment (1.0, 0.5);
380 bbt_label.set_padding (5,0);
382 bbt_label.set_no_show_all();
383 minsec_label.set_name ("EditorTimeButton");
384 minsec_label.set_size_request (-1, (int)timebar_height);
385 minsec_label.set_alignment (1.0, 0.5);
386 minsec_label.set_padding (5,0);
387 minsec_label.hide ();
388 minsec_label.set_no_show_all();
389 smpte_label.set_name ("EditorTimeButton");
390 smpte_label.set_size_request (-1, (int)timebar_height);
391 smpte_label.set_alignment (1.0, 0.5);
392 smpte_label.set_padding (5,0);
394 smpte_label.set_no_show_all();
395 frame_label.set_name ("EditorTimeButton");
396 frame_label.set_size_request (-1, (int)timebar_height);
397 frame_label.set_alignment (1.0, 0.5);
398 frame_label.set_padding (5,0);
400 frame_label.set_no_show_all();
402 tempo_label.set_name ("EditorTimeButton");
403 tempo_label.set_size_request (-1, (int)timebar_height);
404 tempo_label.set_alignment (1.0, 0.5);
405 tempo_label.set_padding (5,0);
407 tempo_label.set_no_show_all();
408 meter_label.set_name ("EditorTimeButton");
409 meter_label.set_size_request (-1, (int)timebar_height);
410 meter_label.set_alignment (1.0, 0.5);
411 meter_label.set_padding (5,0);
413 meter_label.set_no_show_all();
414 mark_label.set_name ("EditorTimeButton");
415 mark_label.set_size_request (-1, (int)timebar_height);
416 mark_label.set_alignment (1.0, 0.5);
417 mark_label.set_padding (5,0);
419 mark_label.set_no_show_all();
420 cd_mark_label.set_name ("EditorTimeButton");
421 cd_mark_label.set_size_request (-1, (int)timebar_height);
422 cd_mark_label.set_alignment (1.0, 0.5);
423 cd_mark_label.set_padding (5,0);
424 cd_mark_label.hide();
425 cd_mark_label.set_no_show_all();
426 range_mark_label.set_name ("EditorTimeButton");
427 range_mark_label.set_size_request (-1, (int)timebar_height);
428 range_mark_label.set_alignment (1.0, 0.5);
429 range_mark_label.set_padding (5,0);
430 range_mark_label.hide();
431 range_mark_label.set_no_show_all();
432 transport_mark_label.set_name ("EditorTimeButton");
433 transport_mark_label.set_size_request (-1, (int)timebar_height);
434 transport_mark_label.set_alignment (1.0, 0.5);
435 transport_mark_label.set_padding (5,0);
436 transport_mark_label.hide();
437 transport_mark_label.set_no_show_all();
439 initialize_rulers ();
440 _summary = new EditorSummary (this);
441 initialize_canvas ();
443 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
444 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
445 editor_regions_selection_changed_connection = selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
446 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
447 selection->MarkersChanged.connect (mem_fun(*this, &Editor::marker_selection_changed));
449 edit_controls_vbox.set_spacing (0);
450 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::scroll_canvas_horizontally), false);
451 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling), true);
452 track_canvas->signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
454 controls_layout.add (edit_controls_vbox);
455 controls_layout.set_name ("EditControlsBase");
456 controls_layout.add_events (Gdk::SCROLL_MASK);
457 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
459 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
460 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
461 controls_layout_size_request_connection = controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
463 edit_vscrollbar.set_adjustment (vertical_adjustment);
464 edit_hscrollbar.set_adjustment (horizontal_adjustment);
466 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press), false);
467 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release), false);
468 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
470 edit_hscrollbar.set_name ("EditorHScrollbar");
474 setup_midi_toolbar ();
476 edit_point_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_point_clock_changed));
478 ArdourCanvas::Canvas* time_pad = manage(new ArdourCanvas::Canvas());
479 ArdourCanvas::SimpleLine* pad_line_1 = manage(new ArdourCanvas::SimpleLine(*time_pad->root(),
480 0.0, 1.0, 100.0, 1.0));
481 pad_line_1->property_color_rgba() = 0xFF0000FF;
485 //time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars) + 2);
486 //time_canvas_vbox.set_size_request (-1, -1);
488 ruler_label_event_box.add (ruler_label_vbox);
489 ruler_label_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
490 ruler_label_event_box.set_name ("TimebarLabelBase");
491 ruler_label_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
493 time_button_event_box.add (time_button_vbox);
494 time_button_event_box.set_name ("TimebarLabelBase");
495 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
496 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
498 /* these enable us to have a dedicated window (for cursor setting, etc.)
499 for the canvas areas.
502 track_canvas_event_box.add (*track_canvas);
504 time_canvas_event_box.add (time_canvas_vbox);
505 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
507 edit_packer.set_col_spacings (0);
508 edit_packer.set_row_spacings (0);
509 edit_packer.set_homogeneous (false);
510 edit_packer.set_border_width (0);
511 edit_packer.set_name ("EditorWindow");
514 edit_packer.attach (*_summary, 0, 2, 0, 1, FILL|EXPAND, SHRINK, 0, 0);
516 /* labels for rulers (mins:secs, timecode, samples, bars:beats) */
517 edit_packer.attach (ruler_label_event_box, 0, 1, 1, 2, FILL, SHRINK, 0, 0);
519 /* labels for time lines (meter, tempo, markers) */
520 edit_packer.attach (time_button_event_box, 0, 1, 2, 3, FILL, SHRINK, 0, 0);
523 edit_packer.attach (time_canvas_event_box, 1, 2, 1, 2, FILL|EXPAND, FILL, 0, 0);
525 /* LHS controls for tracks */
526 edit_packer.attach (controls_layout, 0, 1, 3, 4, FILL, FILL|EXPAND, 0, 0);
528 /* main canvas (which has the time line canvas items at the top of it) */
529 edit_packer.attach (track_canvas_event_box, 1, 2, 2, 4, FILL|EXPAND, FILL|EXPAND, 0, 0);
532 edit_packer.attach (zoom_box, 0, 1, 4, 5, FILL, FILL, 0, 0);
535 edit_packer.attach (edit_hscrollbar, 1, 2, 4, 5, FILL|EXPAND, FILL, 0, 0);
538 edit_packer.attach (edit_vscrollbar, 3, 4, 3, 4, FILL, FILL|EXPAND, 0, 0);
540 bottom_hbox.set_border_width (2);
541 bottom_hbox.set_spacing (3);
543 route_display_model = ListStore::create(route_display_columns);
544 route_list_display.set_model (route_display_model);
545 route_list_display.append_column (_("Show"), route_display_columns.visible);
546 route_list_display.append_column (_("Name"), route_display_columns.text);
547 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
548 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
549 route_list_display.set_headers_visible (true);
550 route_list_display.set_name ("TrackListDisplay");
551 route_list_display.get_selection()->set_mode (SELECTION_SINGLE);
552 route_list_display.set_reorderable (true);
553 route_list_display.set_size_request (100,-1);
554 route_list_display.add_object_drag (route_display_columns.route.index(), "routes");
556 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
557 route_list_visible_cell->property_activatable() = true;
558 route_list_visible_cell->property_radio() = false;
560 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
561 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
562 route_display_model->signal_rows_reordered().connect (mem_fun (*this, &Editor::route_list_reordered));
564 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
566 route_list_scroller.add (route_list_display);
567 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
569 group_model = ListStore::create(group_columns);
570 edit_group_display.set_model (group_model);
571 edit_group_display.append_column (_("Name"), group_columns.text);
572 edit_group_display.append_column (_("Active"), group_columns.is_active);
573 edit_group_display.append_column (_("Show"), group_columns.is_visible);
574 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
575 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
576 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
577 edit_group_display.get_column (0)->set_expand (true);
578 edit_group_display.get_column (1)->set_expand (false);
579 edit_group_display.get_column (2)->set_expand (false);
580 edit_group_display.set_headers_visible (true);
582 /* name is directly editable */
584 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
585 name_cell->property_editable() = true;
586 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
588 /* use checkbox for the active + visible columns */
590 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
591 active_cell->property_activatable() = true;
592 active_cell->property_radio() = false;
594 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
595 active_cell->property_activatable() = true;
596 active_cell->property_radio() = false;
598 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
600 edit_group_display.set_name ("EditGroupList");
601 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
602 edit_group_display.set_headers_visible (true);
603 edit_group_display.set_reorderable (false);
604 edit_group_display.set_rules_hint (true);
605 edit_group_display.set_size_request (75, -1);
607 edit_group_display_scroller.add (edit_group_display);
608 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
610 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
612 VBox* edit_group_display_packer = manage (new VBox());
613 HBox* edit_group_display_button_box = manage (new HBox());
614 edit_group_display_button_box->set_homogeneous (true);
616 Button* edit_group_add_button = manage (new Button ());
617 Button* edit_group_remove_button = manage (new Button ());
621 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
623 edit_group_add_button->add (*w);
625 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
627 edit_group_remove_button->add (*w);
629 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
630 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
632 edit_group_display_button_box->pack_start (*edit_group_add_button);
633 edit_group_display_button_box->pack_start (*edit_group_remove_button);
635 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
636 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
638 region_list_display.set_size_request (100, -1);
639 region_list_display.set_name ("RegionListDisplay");
640 /* Try to prevent single mouse presses from initiating edits.
641 This relies on a hack in gtktreeview.c:gtk_treeview_button_press()
643 region_list_display.set_data ("mouse-edits-require-mod1", (gpointer) 0x1);
645 region_list_model = TreeStore::create (region_list_columns);
646 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
647 region_list_model->set_sort_column (0, SORT_ASCENDING);
649 region_list_display.set_model (region_list_model);
650 region_list_display.append_column (_("Regions"), region_list_columns.name);
651 region_list_display.append_column (_("Start"), region_list_columns.start);
652 region_list_display.append_column (_("End"), region_list_columns.end);
653 region_list_display.append_column (_("Length"), region_list_columns.length);
654 region_list_display.append_column (_("Sync"), region_list_columns.sync);
655 region_list_display.append_column (_("Fade In"), region_list_columns.fadein);
656 region_list_display.append_column (_("Fade Out"), region_list_columns.fadeout);
657 region_list_display.append_column (_("L"), region_list_columns.locked);
658 region_list_display.append_column (_("G"), region_list_columns.glued);
659 region_list_display.append_column (_("M"), region_list_columns.muted);
660 region_list_display.append_column (_("O"), region_list_columns.opaque);
661 region_list_display.append_column (_("Used"), region_list_columns.used);
662 region_list_display.append_column (_("Path"), region_list_columns.path);
663 region_list_display.set_headers_visible (true);
664 //region_list_display.set_grid_lines (TREE_VIEW_GRID_LINES_BOTH);
666 CellRendererText* region_name_cell = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
667 region_name_cell->property_editable() = true;
668 region_name_cell->signal_edited().connect (mem_fun (*this, &Editor::region_name_edit));
670 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
672 TreeViewColumn* tv_col = region_list_display.get_column(0);
673 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
674 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
675 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
677 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
678 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
680 /* setup DnD handling */
682 list<TargetEntry> region_list_target_table;
684 region_list_target_table.push_back (TargetEntry ("text/plain"));
685 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
686 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
688 region_list_display.add_drop_targets (region_list_target_table);
689 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
691 region_list_scroller.add (region_list_display);
692 region_list_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
694 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
695 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
696 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
697 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
698 region_list_change_connection = region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
699 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
701 //ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (mem_fun(*this, &Editor::redisplay_regions));
702 ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (mem_fun(*this, &Editor::update_all_region_rows));
703 ARDOUR::Region::RegionPropertyChanged.connect (mem_fun(*this, &Editor::update_region_row));
705 named_selection_scroller.add (named_selection_display);
706 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
708 named_selection_model = TreeStore::create (named_selection_columns);
709 named_selection_display.set_model (named_selection_model);
710 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
711 named_selection_display.set_headers_visible (false);
712 named_selection_display.set_size_request (100, -1);
713 named_selection_display.set_name ("NamedSelectionDisplay");
715 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
716 named_selection_display.set_size_request (100, -1);
717 named_selection_display.signal_button_release_event().connect (mem_fun(*this, &Editor::named_selection_display_button_release), false);
718 named_selection_display.signal_key_release_event().connect (mem_fun(*this, &Editor::named_selection_display_key_release), false);
719 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
723 snapshot_display_model = ListStore::create (snapshot_display_columns);
724 snapshot_display.set_model (snapshot_display_model);
725 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
726 snapshot_display.set_name ("SnapshotDisplay");
727 snapshot_display.set_size_request (75, -1);
728 snapshot_display.set_headers_visible (false);
729 snapshot_display.set_reorderable (false);
730 snapshot_display_scroller.add (snapshot_display);
731 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
733 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
734 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
738 nlabel = manage (new Label (_("Regions")));
739 nlabel->set_angle (-90);
740 the_notebook.append_page (region_list_scroller, *nlabel);
741 nlabel = manage (new Label (_("Tracks/Busses")));
742 nlabel->set_angle (-90);
743 the_notebook.append_page (route_list_scroller, *nlabel);
744 nlabel = manage (new Label (_("Snapshots")));
745 nlabel->set_angle (-90);
746 the_notebook.append_page (snapshot_display_scroller, *nlabel);
747 nlabel = manage (new Label (_("Edit Groups")));
748 nlabel->set_angle (-90);
749 the_notebook.append_page (*edit_group_display_packer, *nlabel);
751 if (!Profile->get_sae()) {
752 nlabel = manage (new Label (_("Chunks")));
753 nlabel->set_angle (-90);
754 the_notebook.append_page (named_selection_scroller, *nlabel);
757 the_notebook.set_show_tabs (true);
758 the_notebook.set_scrollable (true);
759 the_notebook.popup_enable ();
760 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
761 the_notebook.show_all ();
763 post_maximal_editor_width = 0;
764 post_maximal_pane_position = 0;
765 edit_pane.pack1 (edit_packer, true, true);
766 edit_pane.pack2 (the_notebook, false, true);
768 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
770 top_hbox.pack_start (toolbar_frame, false, true);
771 top_hbox.pack_start (midi_toolbar_frame, false, true);
773 HBox *hbox = manage (new HBox);
774 hbox->pack_start (edit_pane, true, true);
776 global_vpacker.pack_start (top_hbox, false, false);
777 global_vpacker.pack_start (*hbox, true, true);
779 global_hpacker.pack_start (global_vpacker, true, true);
781 set_name ("EditorWindow");
782 add_accel_group (ActionManager::ui_manager->get_accel_group());
784 status_bar_hpacker.show ();
786 vpacker.pack_end (status_bar_hpacker, false, false);
787 vpacker.pack_end (global_hpacker, true, true);
789 /* register actions now so that set_state() can find them and set toggles/checks etc */
793 snap_type = SnapToBeat;
794 set_snap_to (snap_type);
796 set_snap_mode (snap_mode);
797 set_edit_point_preference (EditAtMouse, true);
799 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
802 _playlist_selector = new PlaylistSelector();
803 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
805 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
809 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
810 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
812 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
813 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
815 nudge_forward_button.set_name ("TransportButton");
816 nudge_backward_button.set_name ("TransportButton");
818 fade_context_menu.set_name ("ArdourContextMenu");
820 /* icons, titles, WM stuff */
822 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
823 Glib::RefPtr<Gdk::Pixbuf> icon;
825 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
826 window_icons.push_back (icon);
828 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
829 window_icons.push_back (icon);
831 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
832 window_icons.push_back (icon);
834 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
835 window_icons.push_back (icon);
837 if (!window_icons.empty()) {
838 set_icon_list (window_icons);
839 set_default_icon_list (window_icons);
842 WindowTitle title(Glib::get_application_name());
843 title += _("Editor");
844 set_title (title.get_string());
845 set_wmclass (X_("ardour_editor"), "Ardour");
848 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
850 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
851 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
853 /* allow external control surfaces/protocols to do various things */
855 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
856 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
857 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
858 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
859 BasicUI::AccessAction.connect (mem_fun (*this, &Editor::access_action));
861 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
862 Route::SyncOrderKeys.connect (mem_fun (*this, &Editor::sync_order_keys));
871 if(image_socket_listener) {
872 if(image_socket_listener->is_connected())
874 image_socket_listener->close_connection() ;
877 delete image_socket_listener ;
878 image_socket_listener = 0 ;
887 Editor::add_toplevel_controls (Container& cont)
889 vpacker.pack_start (cont, false, false);
894 Editor::catch_vanishing_regionview (RegionView *rv)
896 /* note: the selection will take care of the vanishing
897 audioregionview by itself.
900 if (_drag && rv->get_canvas_group() == _drag->item() && !_drag->ending()) {
906 if (clicked_regionview == rv) {
907 clicked_regionview = 0;
910 if (entered_regionview == rv) {
911 set_entered_regionview (0);
916 Editor::set_entered_regionview (RegionView* rv)
918 if (rv == entered_regionview) {
922 if (entered_regionview) {
923 entered_regionview->exited ();
926 if ((entered_regionview = rv) != 0) {
927 entered_regionview->entered ();
932 Editor::set_entered_track (TimeAxisView* tav)
935 entered_track->exited ();
938 if ((entered_track = tav) != 0) {
939 entered_track->entered ();
944 Editor::show_window ()
946 if (! is_visible ()) {
949 /* re-hide editor list if necessary */
950 editor_list_button_toggled ();
952 /* re-hide summary widget if necessary */
953 parameter_changed ("show-summary");
955 /* now reset all audio_time_axis heights, because widgets might need
961 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
962 tv = (static_cast<TimeAxisView*>(*i));
971 Editor::instant_save ()
973 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
978 session->add_instant_xml(get_state());
980 Config->add_instant_xml(get_state());
985 Editor::edit_point_clock_changed()
987 if (_dragging_edit_point) {
991 if (selection->markers.empty()) {
996 Location* loc = find_location_from_marker (selection->markers.front(), ignored);
1002 loc->move_to (edit_point_clock.current_time());
1006 Editor::zoom_adjustment_changed ()
1012 double fpu = zoom_range_clock.current_duration() / _canvas_width;
1016 zoom_range_clock.set ((nframes64_t) floor (fpu * _canvas_width));
1017 } else if (fpu > session->current_end_frame() / _canvas_width) {
1018 fpu = session->current_end_frame() / _canvas_width;
1019 zoom_range_clock.set ((nframes64_t) floor (fpu * _canvas_width));
1022 temporal_zoom (fpu);
1026 Editor::control_scroll (float fraction)
1028 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
1034 double step = fraction * current_page_frames();
1037 _control_scroll_target is an optional<T>
1039 it acts like a pointer to an nframes64_t, with
1040 a operator conversion to boolean to check
1041 that it has a value could possibly use
1042 playhead_cursor->current_frame to store the
1043 value and a boolean in the class to know
1044 when it's out of date
1047 if (!_control_scroll_target) {
1048 _control_scroll_target = session->transport_frame();
1049 _dragging_playhead = true;
1052 if ((fraction < 0.0f) && (*_control_scroll_target < (nframes64_t) fabs(step))) {
1053 *_control_scroll_target = 0;
1054 } else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
1055 *_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
1057 *_control_scroll_target += (nframes64_t) floor (step);
1060 /* move visuals, we'll catch up with it later */
1062 playhead_cursor->set_position (*_control_scroll_target);
1063 UpdateAllTransportClocks (*_control_scroll_target);
1065 if (*_control_scroll_target > (current_page_frames() / 2)) {
1066 /* try to center PH in window */
1067 reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
1073 Now we do a timeout to actually bring the session to the right place
1074 according to the playhead. This is to avoid reading disk buffers on every
1075 call to control_scroll, which is driven by ScrollTimeline and therefore
1076 probably by a control surface wheel which can generate lots of events.
1078 /* cancel the existing timeout */
1080 control_scroll_connection.disconnect ();
1082 /* add the next timeout */
1084 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), *_control_scroll_target), 250);
1088 Editor::deferred_control_scroll (nframes64_t target)
1090 session->request_locate (*_control_scroll_target, session->transport_rolling());
1091 // reset for next stream
1092 _control_scroll_target = boost::none;
1093 _dragging_playhead = false;
1098 Editor::access_action (std::string action_group, std::string action_item)
1104 ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::access_action), action_group, action_item));
1107 act = ActionManager::get_action( action_group.c_str(), action_item.c_str() );
1117 Editor::on_realize ()
1119 Window::on_realize ();
1124 Editor::start_scrolling ()
1126 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1127 (mem_fun(*this, &Editor::update_current_screen));
1132 Editor::stop_scrolling ()
1134 scroll_connection.disconnect ();
1138 Editor::map_position_change (nframes64_t frame)
1140 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1142 if (session == 0 || !_follow_playhead) {
1146 center_screen (frame);
1147 playhead_cursor->set_position (frame);
1151 Editor::center_screen (nframes64_t frame)
1153 double page = _canvas_width * frames_per_unit;
1155 /* if we're off the page, then scroll.
1158 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1159 center_screen_internal (frame, page);
1164 Editor::center_screen_internal (nframes64_t frame, float page)
1169 frame -= (nframes64_t) page;
1174 reset_x_origin (frame);
1178 Editor::handle_new_duration ()
1184 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1185 nframes64_t new_end = session->current_end_frame() + (nframes64_t) floorf (current_page_frames() * 0.10f);
1187 horizontal_adjustment.set_upper (new_end / frames_per_unit);
1188 horizontal_adjustment.set_page_size (current_page_frames()/frames_per_unit);
1190 if (horizontal_adjustment.get_value() + _canvas_width > horizontal_adjustment.get_upper()) {
1191 horizontal_adjustment.set_value (horizontal_adjustment.get_upper() - _canvas_width);
1193 //cerr << "Editor::handle_new_duration () called ha v:l:u:ps:lcf = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << endl;//DEBUG
1197 Editor::update_title_s (const string & snap_name)
1199 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1205 Editor::update_title ()
1207 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1210 bool dirty = session->dirty();
1212 string session_name;
1214 if (session->snap_name() != session->name()) {
1215 session_name = session->snap_name();
1217 session_name = session->name();
1221 session_name = "*" + session_name;
1224 WindowTitle title(session_name);
1225 title += Glib::get_application_name();
1226 set_title (title.get_string());
1231 Editor::connect_to_session (Session *t)
1235 compute_fixed_ruler_scale ();
1237 /* there are never any selected regions at startup */
1239 sensitize_the_right_region_actions (false);
1241 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1244 /* catch up with the playhead */
1246 session->request_locate (playhead_cursor->current_frame);
1250 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1251 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1253 /* These signals can all be emitted by a non-GUI thread. Therefore the
1254 handlers for them must not attempt to directly interact with the GUI,
1255 but use Gtkmm2ext::UI::instance()->call_slot();
1258 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1259 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1260 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1261 session_connections.push_back (session->RegionsAdded.connect (mem_fun(*this, &Editor::handle_new_regions)));
1262 session_connections.push_back (session->RegionRemoved.connect (mem_fun(*this, &Editor::handle_region_removed)));
1263 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1264 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1265 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1266 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1267 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1268 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1269 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1270 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1271 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1273 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1275 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1277 session_connections.push_back (session->Located.connect (mem_fun (*this, &Editor::located)));
1278 session_connections.push_back (session->config.ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed)));
1280 edit_groups_changed ();
1282 edit_point_clock.set_mode(AudioClock::BBT);
1283 edit_point_clock.set_session (session);
1284 zoom_range_clock.set_session (session);
1285 _playlist_selector->set_session (session);
1286 nudge_clock.set_session (session);
1287 if (Profile->get_sae()) {
1292 nframes_t pos = session->tempo_map().bbt_duration_at (0, bbt, 1);
1293 nudge_clock.set_mode(AudioClock::BBT);
1294 nudge_clock.set (pos, true, 0, AudioClock::BBT);
1297 nudge_clock.set (session->frame_rate() * 5, true, 0, AudioClock::SMPTE); // default of 5 seconds
1300 playhead_cursor->canvas_item.show ();
1302 if (rhythm_ferret) {
1303 rhythm_ferret->set_session (session);
1306 if (analysis_window != 0)
1307 analysis_window->set_session (session);
1309 Location* loc = session->locations()->auto_loop_location();
1311 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1312 if (loc->start() == loc->end()) {
1313 loc->set_end (loc->start() + 1);
1315 session->locations()->add (loc, false);
1316 session->set_auto_loop_location (loc);
1319 loc->set_name (_("Loop"));
1322 loc = session->locations()->auto_punch_location();
1324 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1325 if (loc->start() == loc->end()) {
1326 loc->set_end (loc->start() + 1);
1328 session->locations()->add (loc, false);
1329 session->set_auto_punch_location (loc);
1332 loc->set_name (_("Punch"));
1335 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1336 session->config.map_parameters (mem_fun (*this, &Editor::parameter_changed));
1338 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1340 refresh_location_display ();
1341 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1342 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1343 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1344 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1345 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1348 sfbrowser->set_session (session);
1351 handle_new_duration ();
1353 redisplay_regions ();
1354 redisplay_named_selections ();
1355 redisplay_snapshots ();
1357 restore_ruler_visibility ();
1358 //tempo_map_changed (Change (0));
1359 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1361 initial_route_list_display ();
1363 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1364 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1369 /* don't show master bus in a new session */
1371 if (ARDOUR_UI::instance()->session_is_new ()) {
1373 TreeModel::Children rows = route_display_model->children();
1374 TreeModel::Children::iterator i;
1376 no_route_list_redisplay = true;
1378 for (i = rows.begin(); i != rows.end(); ++i) {
1379 TimeAxisView *tv = (*i)[route_display_columns.tv];
1380 RouteTimeAxisView *rtv;
1382 if ((rtv = dynamic_cast<RouteTimeAxisView*>(tv)) != 0) {
1383 if (rtv->route()->is_master()) {
1384 route_list_display.get_selection()->unselect (i);
1389 no_route_list_redisplay = false;
1390 redisplay_route_list ();
1393 switch (snap_type) {
1394 case SnapToRegionStart:
1395 case SnapToRegionEnd:
1396 case SnapToRegionSync:
1397 case SnapToRegionBoundary:
1398 build_region_boundary_cache ();
1405 /* register for undo history */
1406 session->register_with_memento_command_factory(_id, this);
1408 _summary->set_session (session);
1414 Editor::build_cursors ()
1416 using namespace Gdk;
1418 Gdk::Color mbg ("#000000" ); /* Black */
1419 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1422 RefPtr<Bitmap> source, mask;
1423 source = Bitmap::create (mag_bits, mag_width, mag_height);
1424 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1425 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1428 Gdk::Color fbg ("#ffffff" );
1429 Gdk::Color ffg ("#000000" );
1432 RefPtr<Bitmap> source, mask;
1434 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1435 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1436 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1440 RefPtr<Bitmap> source, mask;
1441 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1442 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1443 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1447 RefPtr<Bitmap> bits;
1448 char pix[4] = { 0, 0, 0, 0 };
1449 bits = Bitmap::create (pix, 2, 2);
1451 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1455 RefPtr<Bitmap> bits;
1456 char pix[4] = { 0, 0, 0, 0 };
1457 bits = Bitmap::create (pix, 2, 2);
1459 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1463 grabber_cursor = new Gdk::Cursor (HAND2);
1466 Glib::RefPtr<Gdk::Pixbuf> grabber_edit_point_pixbuf (::get_icon ("grabber_edit_point"));
1467 grabber_edit_point_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_edit_point_pixbuf, 5, 17);
1470 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1471 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1472 selector_cursor = new Gdk::Cursor (XTERM);
1473 time_fx_cursor = new Gdk::Cursor (SIZING);
1474 wait_cursor = new Gdk::Cursor (WATCH);
1475 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1476 midi_pencil_cursor = new Gdk::Cursor (PENCIL);
1477 midi_select_cursor = new Gdk::Cursor (CENTER_PTR);
1478 midi_resize_cursor = new Gdk::Cursor (SIZING);
1479 midi_erase_cursor = new Gdk::Cursor (DRAPED_BOX);
1482 /** Pop up a context menu for when the user clicks on a fade in or fade out */
1484 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1486 using namespace Menu_Helpers;
1487 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1490 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1494 MenuList& items (fade_context_menu.items());
1498 switch (item_type) {
1500 case FadeInHandleItem:
1501 if (arv->audio_region()->fade_in_active()) {
1502 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_in_active), false)));
1504 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_in_active), true)));
1507 items.push_back (SeparatorElem());
1509 if (Profile->get_sae()) {
1510 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1511 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1513 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1514 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1515 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
1516 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
1517 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
1523 case FadeOutHandleItem:
1524 if (arv->audio_region()->fade_out_active()) {
1525 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_out_active), false)));
1527 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_out_active), true)));
1530 items.push_back (SeparatorElem());
1532 if (Profile->get_sae()) {
1533 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1534 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1536 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1537 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1538 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
1539 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
1540 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
1546 fatal << _("programming error: ")
1547 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1552 fade_context_menu.popup (button, time);
1556 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes64_t frame)
1558 using namespace Menu_Helpers;
1559 Menu* (Editor::*build_menu_function)(nframes64_t);
1562 switch (item_type) {
1564 case RegionViewName:
1565 case RegionViewNameHighlight:
1566 if (with_selection) {
1567 build_menu_function = &Editor::build_track_selection_context_menu;
1569 build_menu_function = &Editor::build_track_region_context_menu;
1574 if (with_selection) {
1575 build_menu_function = &Editor::build_track_selection_context_menu;
1577 build_menu_function = &Editor::build_track_context_menu;
1581 case CrossfadeViewItem:
1582 build_menu_function = &Editor::build_track_crossfade_context_menu;
1586 if (clicked_routeview->get_diskstream()) {
1587 build_menu_function = &Editor::build_track_context_menu;
1589 build_menu_function = &Editor::build_track_bus_context_menu;
1594 /* probably shouldn't happen but if it does, we don't care */
1598 menu = (this->*build_menu_function)(frame);
1599 menu->set_name ("ArdourContextMenu");
1601 /* now handle specific situations */
1603 switch (item_type) {
1605 case RegionViewName:
1606 case RegionViewNameHighlight:
1607 if (!with_selection) {
1608 if (region_edit_menu_split_item) {
1609 if (clicked_regionview && clicked_regionview->region()->covers (get_preferred_edit_position())) {
1610 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, true);
1612 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, false);
1616 if (region_edit_menu_split_multichannel_item) {
1617 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1618 // GTK2FIX find the action, change its sensitivity
1619 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1621 // GTK2FIX see above
1622 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1631 case CrossfadeViewItem:
1638 /* probably shouldn't happen but if it does, we don't care */
1642 if (item_type != SelectionItem && clicked_routeview && clicked_routeview->audio_track()) {
1644 /* Bounce to disk */
1646 using namespace Menu_Helpers;
1647 MenuList& edit_items = menu->items();
1649 edit_items.push_back (SeparatorElem());
1651 switch (clicked_routeview->audio_track()->freeze_state()) {
1652 case AudioTrack::NoFreeze:
1653 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1656 case AudioTrack::Frozen:
1657 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1660 case AudioTrack::UnFrozen:
1661 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1667 if (item_type == StreamItem && clicked_routeview) {
1668 clicked_routeview->build_underlay_menu(menu);
1671 menu->popup (button, time);
1675 Editor::build_track_context_menu (nframes64_t ignored)
1677 using namespace Menu_Helpers;
1679 MenuList& edit_items = track_context_menu.items();
1682 add_dstream_context_items (edit_items);
1683 return &track_context_menu;
1687 Editor::build_track_bus_context_menu (nframes64_t ignored)
1689 using namespace Menu_Helpers;
1691 MenuList& edit_items = track_context_menu.items();
1694 add_bus_context_items (edit_items);
1695 return &track_context_menu;
1699 Editor::build_track_region_context_menu (nframes64_t frame)
1701 using namespace Menu_Helpers;
1702 MenuList& edit_items = track_region_context_menu.items();
1705 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (clicked_axisview);
1708 boost::shared_ptr<Diskstream> ds;
1709 boost::shared_ptr<Playlist> pl;
1711 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
1712 Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)frame * ds->speed()));
1714 if (selection->regions.size() > 1) {
1715 // there's already a multiple selection: just add a
1716 // single region context menu that will act on all
1718 boost::shared_ptr<Region> dummy_region; // = NULL
1719 add_region_context_items (rtv->view(), dummy_region, edit_items);
1721 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1722 add_region_context_items (rtv->view(), (*i), edit_items);
1730 add_dstream_context_items (edit_items);
1732 return &track_region_context_menu;
1736 Editor::build_track_crossfade_context_menu (nframes64_t frame)
1738 using namespace Menu_Helpers;
1739 MenuList& edit_items = track_crossfade_context_menu.items();
1740 edit_items.clear ();
1742 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_axisview);
1745 boost::shared_ptr<Diskstream> ds;
1746 boost::shared_ptr<Playlist> pl;
1747 boost::shared_ptr<AudioPlaylist> apl;
1749 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1751 Playlist::RegionList* regions = pl->regions_at (frame);
1752 AudioPlaylist::Crossfades xfades;
1754 apl->crossfades_at (frame, xfades);
1756 bool many = xfades.size() > 1;
1758 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1759 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1762 if (selection->regions.size() > 1) {
1763 // there's already a multiple selection: just add a
1764 // single region context menu that will act on all
1766 boost::shared_ptr<Region> dummy_region; // = NULL
1767 add_region_context_items (atv->audio_view(), dummy_region, edit_items);
1769 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1770 add_region_context_items (atv->audio_view(), (*i), edit_items);
1777 add_dstream_context_items (edit_items);
1779 return &track_crossfade_context_menu;
1783 Editor::analyze_region_selection()
1785 if (analysis_window == 0) {
1786 analysis_window = new AnalysisWindow();
1789 analysis_window->set_session(session);
1791 analysis_window->show_all();
1794 analysis_window->set_regionmode();
1795 analysis_window->analyze();
1797 analysis_window->present();
1801 Editor::analyze_range_selection()
1803 if (analysis_window == 0) {
1804 analysis_window = new AnalysisWindow();
1807 analysis_window->set_session(session);
1809 analysis_window->show_all();
1812 analysis_window->set_rangemode();
1813 analysis_window->analyze();
1815 analysis_window->present();
1819 Editor::build_track_selection_context_menu (nframes64_t ignored)
1821 using namespace Menu_Helpers;
1822 MenuList& edit_items = track_selection_context_menu.items();
1823 edit_items.clear ();
1825 add_selection_context_items (edit_items);
1826 // edit_items.push_back (SeparatorElem());
1827 // add_dstream_context_items (edit_items);
1829 return &track_selection_context_menu;
1832 /** Add context menu items relevant to crossfades.
1833 * @param edit_items List to add the items to.
1836 Editor::add_crossfade_context_items (AudioStreamView* view, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1838 using namespace Menu_Helpers;
1839 Menu *xfade_menu = manage (new Menu);
1840 MenuList& items = xfade_menu->items();
1841 xfade_menu->set_name ("ArdourContextMenu");
1844 if (xfade->active()) {
1850 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1851 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1853 if (xfade->can_follow_overlap()) {
1855 if (xfade->following_overlap()) {
1856 str = _("Convert to short");
1858 str = _("Convert to full");
1861 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1865 str = xfade->out()->name();
1867 str += xfade->in()->name();
1869 str = _("Crossfade");
1872 edit_items.push_back (MenuElem (str, *xfade_menu));
1873 edit_items.push_back (SeparatorElem());
1877 Editor::xfade_edit_left_region ()
1879 if (clicked_crossfadeview) {
1880 clicked_crossfadeview->left_view.show_region_editor ();
1885 Editor::xfade_edit_right_region ()
1887 if (clicked_crossfadeview) {
1888 clicked_crossfadeview->right_view.show_region_editor ();
1892 /** Add an element to a menu, settings its sensitivity.
1893 * @param m Menu to add to.
1894 * @param e Element to add.
1895 * @param s true to make sensitive, false to make insensitive
1898 Editor::add_item_with_sensitivity (Menu_Helpers::MenuList& m, Menu_Helpers::MenuElem e, bool s) const
1902 m.back().set_sensitive (false);
1907 Editor::add_region_context_items (StreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1909 using namespace Menu_Helpers;
1910 Gtk::MenuItem* foo_item;
1911 Menu *region_menu = manage (new Menu);
1912 MenuList& items = region_menu->items();
1913 region_menu->set_name ("ArdourContextMenu");
1915 boost::shared_ptr<AudioRegion> ar;
1916 boost::shared_ptr<MidiRegion> mr;
1919 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1920 mr = boost::dynamic_pointer_cast<MidiRegion> (region);
1922 /* when this particular menu pops up, make the relevant region
1926 region_menu->signal_map_event().connect (
1927 bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1929 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &Editor::rename_region)));
1930 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1933 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1934 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1935 items.push_back (SeparatorElem());
1936 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_point)));
1937 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1938 items.push_back (SeparatorElem());
1940 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::play_selected_region)));
1941 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1942 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1945 items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_region_selection)));
1948 items.push_back (SeparatorElem());
1950 sigc::connection fooc;
1951 boost::shared_ptr<Region> region_to_check;
1954 region_to_check = region;
1956 region_to_check = selection->regions.front()->region();
1959 items.push_back (CheckMenuElem (_("Lock")));
1960 CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1961 if (region_to_check->locked()) {
1962 region_lock_item->set_active();
1964 region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
1966 items.push_back (CheckMenuElem (_("Glue to Bars&Beats")));
1967 CheckMenuItem* bbt_glue_item = static_cast<CheckMenuItem*>(&items.back());
1969 switch (region_to_check->positional_lock_style()) {
1970 case Region::MusicTime:
1971 bbt_glue_item->set_active (true);
1974 bbt_glue_item->set_active (false);
1978 bbt_glue_item->signal_activate().connect (bind (mem_fun (*this, &Editor::set_region_lock_style), Region::MusicTime));
1980 items.push_back (CheckMenuElem (_("Mute")));
1981 CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1982 fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
1983 if (region_to_check->muted()) {
1985 region_mute_item->set_active();
1989 if (!Profile->get_sae()) {
1990 items.push_back (CheckMenuElem (_("Opaque")));
1991 CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1992 fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
1993 if (region_to_check->opaque()) {
1995 region_opaque_item->set_active();
2000 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
2001 if (region_to_check->at_natural_position()) {
2002 items.back().set_sensitive (false);
2005 items.push_back (SeparatorElem());
2009 RegionView* rv = sv->find_view (ar);
2010 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
2012 if (!Profile->get_sae()) {
2013 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
2015 items.push_back (CheckMenuElem (_("Envelope Visible")));
2016 CheckMenuItem* region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
2017 fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
2018 if (arv->envelope_visible()) {
2020 region_envelope_visible_item->set_active (true);
2024 items.push_back (CheckMenuElem (_("Envelope Active")));
2025 CheckMenuItem* region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
2026 fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
2028 if (ar->envelope_active()) {
2030 region_envelope_active_item->set_active (true);
2034 items.push_back (SeparatorElem());
2037 if (ar->scale_amplitude() != 1.0f) {
2038 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
2040 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
2044 items.push_back (MenuElem (_("Quantize"), mem_fun(*this, &Editor::quantize_region)));
2045 items.push_back (SeparatorElem());
2048 items.push_back (MenuElem (_("Strip silence..."), mem_fun (*this, &Editor::strip_region_silence)));
2049 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
2050 items.push_back (SeparatorElem());
2052 /* range related stuff */
2054 items.push_back (MenuElem (_("Add Single Range"), mem_fun (*this, &Editor::add_location_from_audio_region)));
2055 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_locations_from_audio_region)));
2056 if (selection->regions.size() < 2) {
2057 items.back().set_sensitive (false);
2060 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_region)));
2061 items.push_back (SeparatorElem());
2065 Menu *nudge_menu = manage (new Menu());
2066 MenuList& nudge_items = nudge_menu->items();
2067 nudge_menu->set_name ("ArdourContextMenu");
2069 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false, false))));
2070 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false, false))));
2071 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
2072 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
2074 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2075 items.push_back (SeparatorElem());
2077 Menu *trim_menu = manage (new Menu);
2078 MenuList& trim_items = trim_menu->items();
2079 trim_menu->set_name ("ArdourContextMenu");
2081 trim_items.push_back (MenuElem (_("Start to edit point"), mem_fun(*this, &Editor::trim_region_from_edit_point)));
2082 foo_item = &trim_items.back();
2083 if (_edit_point == EditAtMouse) {
2084 foo_item->set_sensitive (false);
2086 trim_items.push_back (MenuElem (_("Edit point to end"), mem_fun(*this, &Editor::trim_region_to_edit_point)));
2087 foo_item = &trim_items.back();
2088 if (_edit_point == EditAtMouse) {
2089 foo_item->set_sensitive (false);
2091 trim_items.push_back (MenuElem (_("Trim To Loop"), mem_fun(*this, &Editor::trim_region_to_loop)));
2092 trim_items.push_back (MenuElem (_("Trim To Punch"), mem_fun(*this, &Editor::trim_region_to_punch)));
2094 items.push_back (MenuElem (_("Trim"), *trim_menu));
2095 items.push_back (SeparatorElem());
2097 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
2098 region_edit_menu_split_item = &items.back();
2100 if (_edit_point == EditAtMouse) {
2101 region_edit_menu_split_item->set_sensitive (false);
2104 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
2105 region_edit_menu_split_multichannel_item = &items.back();
2107 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), false))));
2108 items.push_back (MenuElem (_("Multi-Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
2109 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
2110 items.push_back (SeparatorElem());
2111 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_selected_regions)));
2113 /* OK, stick the region submenu at the top of the list, and then add
2117 /* we have to hack up the region name because "_" has a special
2118 meaning for menu titles.
2121 string::size_type pos = 0;
2122 string menu_item_name = (region) ? region->name() : _("Selected regions");
2124 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
2125 menu_item_name.replace (pos, 1, "__");
2129 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
2130 edit_items.push_back (SeparatorElem());
2133 /** Add context menu items relevant to selection ranges.
2134 * @param edit_items List to add the items to.
2137 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
2139 using namespace Menu_Helpers;
2141 edit_items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
2142 edit_items.push_back (MenuElem (_("Loop range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
2144 edit_items.push_back (SeparatorElem());
2145 edit_items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_range_selection)));
2147 edit_items.push_back (SeparatorElem());
2148 edit_items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
2149 edit_items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
2151 edit_items.push_back (SeparatorElem());
2152 edit_items.push_back (MenuElem (_("Convert to region in-place"), mem_fun(*this, &Editor::separate_region_from_selection)));
2153 edit_items.push_back (MenuElem (_("Convert to region in region list"), mem_fun(*this, &Editor::new_region_from_selection)));
2155 edit_items.push_back (SeparatorElem());
2156 edit_items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
2158 edit_items.push_back (SeparatorElem());
2159 edit_items.push_back (MenuElem (_("Set loop from selection"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
2160 edit_items.push_back (MenuElem (_("Set punch from selection"), mem_fun(*this, &Editor::set_punch_from_selection)));
2162 edit_items.push_back (SeparatorElem());
2163 edit_items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
2164 edit_items.push_back (SeparatorElem());
2165 edit_items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
2166 edit_items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
2167 edit_items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
2168 edit_items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::create_named_selection)));
2169 edit_items.push_back (SeparatorElem());
2170 edit_items.push_back (MenuElem (_("Consolidate range"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, false)));
2171 edit_items.push_back (MenuElem (_("Consolidate range with processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, true)));
2172 edit_items.push_back (MenuElem (_("Bounce range to region list"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, false)));
2173 edit_items.push_back (MenuElem (_("Bounce range to region list with processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, true)));
2174 edit_items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_range)));
2179 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
2181 using namespace Menu_Helpers;
2185 Menu *play_menu = manage (new Menu);
2186 MenuList& play_items = play_menu->items();
2187 play_menu->set_name ("ArdourContextMenu");
2189 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
2190 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2191 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
2192 play_items.push_back (SeparatorElem());
2193 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
2195 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2199 Menu *select_menu = manage (new Menu);
2200 MenuList& select_items = select_menu->items();
2201 select_menu->set_name ("ArdourContextMenu");
2203 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2204 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2205 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2206 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2207 select_items.push_back (SeparatorElem());
2208 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
2209 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
2210 select_items.push_back (SeparatorElem());
2211 select_items.push_back (MenuElem (_("Select All After Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2212 select_items.push_back (MenuElem (_("Select All Before Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2213 select_items.push_back (MenuElem (_("Select All After Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2214 select_items.push_back (MenuElem (_("Select All Before Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2215 select_items.push_back (MenuElem (_("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), false)));
2216 select_items.push_back (MenuElem (_("Select All Within Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), true)));
2217 select_items.push_back (MenuElem (_("Select Range Between Playhead & Edit Point"), mem_fun(*this, &Editor::select_range_between)));
2219 select_items.push_back (SeparatorElem());
2221 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2225 Menu *cutnpaste_menu = manage (new Menu);
2226 MenuList& cutnpaste_items = cutnpaste_menu->items();
2227 cutnpaste_menu->set_name ("ArdourContextMenu");
2229 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2230 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2231 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2233 cutnpaste_items.push_back (SeparatorElem());
2235 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
2236 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
2238 cutnpaste_items.push_back (SeparatorElem());
2240 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
2242 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
2244 /* Adding new material */
2246 edit_items.push_back (SeparatorElem());
2247 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
2248 edit_items.push_back (MenuElem (_("Insert Existing Media"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
2252 Menu *nudge_menu = manage (new Menu());
2253 MenuList& nudge_items = nudge_menu->items();
2254 nudge_menu->set_name ("ArdourContextMenu");
2256 edit_items.push_back (SeparatorElem());
2257 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2258 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2259 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2260 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2262 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2266 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
2268 using namespace Menu_Helpers;
2272 Menu *play_menu = manage (new Menu);
2273 MenuList& play_items = play_menu->items();
2274 play_menu->set_name ("ArdourContextMenu");
2276 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
2277 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2278 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2282 Menu *select_menu = manage (new Menu);
2283 MenuList& select_items = select_menu->items();
2284 select_menu->set_name ("ArdourContextMenu");
2286 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2287 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2288 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2289 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2290 select_items.push_back (SeparatorElem());
2291 select_items.push_back (MenuElem (_("Select all after edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2292 select_items.push_back (MenuElem (_("Select all before edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2293 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2294 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2296 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2300 Menu *cutnpaste_menu = manage (new Menu);
2301 MenuList& cutnpaste_items = cutnpaste_menu->items();
2302 cutnpaste_menu->set_name ("ArdourContextMenu");
2304 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2305 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2306 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2308 Menu *nudge_menu = manage (new Menu());
2309 MenuList& nudge_items = nudge_menu->items();
2310 nudge_menu->set_name ("ArdourContextMenu");
2312 edit_items.push_back (SeparatorElem());
2313 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2314 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2315 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2316 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2318 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2322 Editor::set_snap_to (SnapType st)
2324 unsigned int snap_ind = (unsigned int)st;
2328 if (snap_ind > snap_type_strings.size() - 1) {
2330 snap_type = (SnapType)snap_ind;
2333 string str = snap_type_strings[snap_ind];
2335 if (str != snap_type_selector.get_active_text()) {
2336 snap_type_selector.set_active_text (str);
2341 switch (snap_type) {
2342 case SnapToAThirtysecondBeat:
2343 case SnapToASixteenthBeat:
2344 case SnapToAEighthBeat:
2345 case SnapToAQuarterBeat:
2346 case SnapToAThirdBeat:
2347 compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames());
2348 update_tempo_based_rulers ();
2351 case SnapToRegionStart:
2352 case SnapToRegionEnd:
2353 case SnapToRegionSync:
2354 case SnapToRegionBoundary:
2355 build_region_boundary_cache ();
2365 Editor::set_snap_mode (SnapMode mode)
2368 string str = snap_mode_strings[(int)mode];
2370 if (str != snap_mode_selector.get_active_text ()) {
2371 snap_mode_selector.set_active_text (str);
2377 Editor::set_edit_point_preference (EditPoint ep, bool force)
2379 bool changed = (_edit_point != ep);
2382 string str = edit_point_strings[(int)ep];
2384 if (str != edit_point_selector.get_active_text ()) {
2385 edit_point_selector.set_active_text (str);
2388 set_canvas_cursor ();
2390 if (!force && !changed) {
2394 switch (zoom_focus) {
2395 case ZoomFocusMouse:
2396 case ZoomFocusPlayhead:
2398 switch (_edit_point) {
2400 set_zoom_focus (ZoomFocusMouse);
2402 case EditAtPlayhead:
2403 set_zoom_focus (ZoomFocusPlayhead);
2405 case EditAtSelectedMarker:
2406 set_zoom_focus (ZoomFocusEdit);
2414 const char* action=NULL;
2416 switch (_edit_point) {
2417 case EditAtPlayhead:
2418 action = "edit-at-playhead";
2420 case EditAtSelectedMarker:
2421 action = "edit-at-marker";
2424 action = "edit-at-mouse";
2428 Glib::RefPtr<Action> act = ActionManager::get_action ("Editor", action);
2430 Glib::RefPtr<RadioAction>::cast_dynamic(act)->set_active (true);
2434 bool in_track_canvas;
2436 if (!mouse_frame (foo, in_track_canvas)) {
2437 in_track_canvas = false;
2440 reset_canvas_action_sensitivity (in_track_canvas);
2446 Editor::set_state (const XMLNode& node)
2448 const XMLProperty* prop;
2450 int x, y, xoff, yoff;
2453 if ((prop = node.property ("id")) != 0) {
2454 _id = prop->value ();
2457 g.base_width = default_width;
2458 g.base_height = default_height;
2464 if ((geometry = find_named_node (node, "geometry")) != 0) {
2468 if ((prop = geometry->property("x_size")) == 0) {
2469 prop = geometry->property ("x-size");
2472 g.base_width = atoi(prop->value());
2474 if ((prop = geometry->property("y_size")) == 0) {
2475 prop = geometry->property ("y-size");
2478 g.base_height = atoi(prop->value());
2481 if ((prop = geometry->property ("x_pos")) == 0) {
2482 prop = geometry->property ("x-pos");
2485 x = atoi (prop->value());
2488 if ((prop = geometry->property ("y_pos")) == 0) {
2489 prop = geometry->property ("y-pos");
2492 y = atoi (prop->value());
2495 if ((prop = geometry->property ("x_off")) == 0) {
2496 prop = geometry->property ("x-off");
2499 xoff = atoi (prop->value());
2501 if ((prop = geometry->property ("y_off")) == 0) {
2502 prop = geometry->property ("y-off");
2505 yoff = atoi (prop->value());
2509 set_default_size (g.base_width, g.base_height);
2512 if (session && (prop = node.property ("playhead"))) {
2513 nframes64_t pos = atol (prop->value().c_str());
2514 playhead_cursor->set_position (pos);
2516 playhead_cursor->set_position (0);
2518 /* reset_x_origin() doesn't work right here, since the old
2519 position may be zero already, and it does nothing in such
2524 horizontal_adjustment.set_value (0);
2527 if ((prop = node.property ("mixer-width"))) {
2528 editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
2531 if ((prop = node.property ("zoom-focus"))) {
2532 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2535 if ((prop = node.property ("zoom"))) {
2536 reset_zoom (PBD::atof (prop->value()));
2539 if ((prop = node.property ("snap-to"))) {
2540 set_snap_to ((SnapType) atoi (prop->value()));
2543 if ((prop = node.property ("snap-mode"))) {
2544 set_snap_mode ((SnapMode) atoi (prop->value()));
2547 if ((prop = node.property ("edit-point"))) {
2548 set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point), true);
2551 if ((prop = node.property ("mouse-mode"))) {
2552 MouseMode m = str2mousemode(prop->value());
2553 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2554 set_mouse_mode (m, true);
2556 mouse_mode = MouseGain; /* lie, to force the mode switch */
2557 set_mouse_mode (MouseObject, true);
2560 if ((prop = node.property ("show-waveforms-recording"))) {
2561 bool yn = (prop->value() == "yes");
2562 _show_waveforms_recording = !yn;
2563 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2565 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2566 /* do it twice to force the change */
2567 tact->set_active (!yn);
2568 tact->set_active (yn);
2572 if ((prop = node.property ("show-measures"))) {
2573 bool yn = (prop->value() == "yes");
2574 _show_measures = !yn;
2575 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2577 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2578 /* do it twice to force the change */
2579 tact->set_active (!yn);
2580 tact->set_active (yn);
2584 if ((prop = node.property ("follow-playhead"))) {
2585 bool yn = (prop->value() == "yes");
2586 set_follow_playhead (yn);
2587 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2589 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2590 if (tact->get_active() != yn) {
2591 tact->set_active (yn);
2596 if ((prop = node.property ("region-list-sort-type"))) {
2597 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2598 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2601 if ((prop = node.property ("xfades-visible"))) {
2602 bool yn = (prop->value() == "yes");
2603 _xfade_visibility = !yn;
2604 // set_xfade_visibility (yn);
2607 if ((prop = node.property ("show-editor-mixer"))) {
2609 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2612 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2613 bool yn = (prop->value() == X_("yes"));
2615 /* do it twice to force the change */
2617 tact->set_active (!yn);
2618 tact->set_active (yn);
2622 if ((prop = node.property ("show-editor-list"))) {
2624 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2628 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2629 bool yn = (prop->value() == X_("yes"));
2631 /* do it twice to force the change */
2633 tact->set_active (!yn);
2634 tact->set_active (yn);
2643 Editor::get_state ()
2645 XMLNode* node = new XMLNode ("Editor");
2648 _id.print (buf, sizeof (buf));
2649 node->add_property ("id", buf);
2651 if (is_realized()) {
2652 Glib::RefPtr<Gdk::Window> win = get_window();
2654 int x, y, xoff, yoff, width, height;
2655 win->get_root_origin(x, y);
2656 win->get_position(xoff, yoff);
2657 win->get_size(width, height);
2659 XMLNode* geometry = new XMLNode ("geometry");
2661 snprintf(buf, sizeof(buf), "%d", width);
2662 geometry->add_property("x-size", string(buf));
2663 snprintf(buf, sizeof(buf), "%d", height);
2664 geometry->add_property("y-size", string(buf));
2665 snprintf(buf, sizeof(buf), "%d", x);
2666 geometry->add_property("x-pos", string(buf));
2667 snprintf(buf, sizeof(buf), "%d", y);
2668 geometry->add_property("y-pos", string(buf));
2669 snprintf(buf, sizeof(buf), "%d", xoff);
2670 geometry->add_property("x-off", string(buf));
2671 snprintf(buf, sizeof(buf), "%d", yoff);
2672 geometry->add_property("y-off", string(buf));
2673 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2674 geometry->add_property("edit_pane_pos", string(buf));
2676 node->add_child_nocopy (*geometry);
2679 maybe_add_mixer_strip_width (*node);
2681 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2682 node->add_property ("zoom-focus", buf);
2683 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2684 node->add_property ("zoom", buf);
2685 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2686 node->add_property ("snap-to", buf);
2687 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2688 node->add_property ("snap-mode", buf);
2690 node->add_property ("edit-point", enum_2_string (_edit_point));
2692 snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame);
2693 node->add_property ("playhead", buf);
2695 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2696 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2697 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2698 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2699 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2700 node->add_property ("mouse-mode", enum2str(mouse_mode));
2702 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2704 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2705 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2708 act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2710 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2711 node->add_property (X_("show-editor-list"), tact->get_active() ? "yes" : "no");
2719 /** @param y y offset from the top of all trackviews.
2720 * @return pair: TimeAxisView that y is over, layer index.
2721 * TimeAxisView may be 0. Layer index is the layer number if the TimeAxisView is valid and is
2722 * in stacked region display mode, otherwise 0.
2724 std::pair<TimeAxisView *, layer_t>
2725 Editor::trackview_by_y_position (double y)
2727 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2729 std::pair<TimeAxisView*, int> const r = (*iter)->covers_y_position (y);
2735 return std::make_pair ( (TimeAxisView *) 0, 0);
2739 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
2741 if (!session || snap_mode == SnapOff) {
2745 snap_to_internal (start, direction, for_mark);
2749 Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
2751 Location* before = 0;
2752 Location* after = 0;
2754 const nframes64_t one_second = session->frame_rate();
2755 const nframes64_t one_minute = session->frame_rate() * 60;
2756 const nframes64_t one_smpte_second = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
2757 nframes64_t one_smpte_minute = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
2758 nframes64_t presnap = start;
2760 switch (snap_type) {
2762 if (((direction == 0) && (start % (one_second/75) > (one_second/75) / 2)) || (direction > 0)) {
2763 start = (nframes64_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2765 start = (nframes64_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2769 case SnapToSMPTEFrame:
2770 if (((direction == 0) && (fmod((double)start, (double)session->frames_per_smpte_frame()) > (session->frames_per_smpte_frame() / 2))) || (direction > 0)) {
2771 start = (nframes64_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2773 start = (nframes64_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2777 case SnapToSMPTESeconds:
2778 if (session->smpte_offset_negative())
2780 start += session->smpte_offset ();
2782 start -= session->smpte_offset ();
2784 if (((direction == 0) && (start % one_smpte_second > one_smpte_second / 2)) || direction > 0) {
2785 start = (nframes64_t) ceil ((double) start / one_smpte_second) * one_smpte_second;
2787 start = (nframes64_t) floor ((double) start / one_smpte_second) * one_smpte_second;
2790 if (session->smpte_offset_negative())
2792 start -= session->smpte_offset ();
2794 start += session->smpte_offset ();
2798 case SnapToSMPTEMinutes:
2799 if (session->smpte_offset_negative())
2801 start += session->smpte_offset ();
2803 start -= session->smpte_offset ();
2805 if (((direction == 0) && (start % one_smpte_minute > one_smpte_minute / 2)) || direction > 0) {
2806 start = (nframes64_t) ceil ((double) start / one_smpte_minute) * one_smpte_minute;
2808 start = (nframes64_t) floor ((double) start / one_smpte_minute) * one_smpte_minute;
2810 if (session->smpte_offset_negative())
2812 start -= session->smpte_offset ();
2814 start += session->smpte_offset ();
2819 if (((direction == 0) && (start % one_second > one_second / 2)) || (direction > 0)) {
2820 start = (nframes64_t) ceil ((double) start / one_second) * one_second;
2822 start = (nframes64_t) floor ((double) start / one_second) * one_second;
2827 if (((direction == 0) && (start % one_minute > one_minute / 2)) || (direction > 0)) {
2828 start = (nframes64_t) ceil ((double) start / one_minute) * one_minute;
2830 start = (nframes64_t) floor ((double) start / one_minute) * one_minute;
2835 start = session->tempo_map().round_to_bar (start, direction);
2839 start = session->tempo_map().round_to_beat (start, direction);
2842 case SnapToAThirtysecondBeat:
2843 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2846 case SnapToASixteenthBeat:
2847 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2850 case SnapToAEighthBeat:
2851 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2854 case SnapToAQuarterBeat:
2855 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2858 case SnapToAThirdBeat:
2859 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2867 before = session->locations()->first_location_before (start);
2868 after = session->locations()->first_location_after (start);
2870 if (direction < 0) {
2872 start = before->start();
2876 } else if (direction > 0) {
2878 start = after->start();
2880 start = session->current_end_frame();
2885 /* find nearest of the two */
2886 if ((start - before->start()) < (after->start() - start)) {
2887 start = before->start();
2889 start = after->start();
2892 start = before->start();
2895 start = after->start();
2902 case SnapToRegionStart:
2903 case SnapToRegionEnd:
2904 case SnapToRegionSync:
2905 case SnapToRegionBoundary:
2906 if (!region_boundary_cache.empty()) {
2907 vector<nframes64_t>::iterator i;
2909 if (direction > 0) {
2910 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2912 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2915 if (i != region_boundary_cache.end()) {
2917 /* lower bound doesn't quite to the right thing for our purposes */
2919 if (direction < 0 && i != region_boundary_cache.begin()) {
2926 start = region_boundary_cache.back();
2932 switch (snap_mode) {
2938 if (presnap > start) {
2939 if (presnap > (start + unit_to_frame(snap_threshold))) {
2943 } else if (presnap < start) {
2944 if (presnap < (start - unit_to_frame(snap_threshold))) {
2950 /* handled at entry */
2957 Editor::snap_length_beats (nframes64_t start)
2963 /* FIXME: This could/should also work with non-tempo based snap settings (ie seconds) */
2965 switch (snap_type) {
2967 return session->tempo_map().meter_at(start).beats_per_bar();
2972 case SnapToAThirtysecondBeat:
2973 return 1.0 / (double)32.0;
2976 case SnapToASixteenthBeat:
2977 return 1.0 / (double)16.0;
2980 case SnapToAEighthBeat:
2981 return 1.0 / (double)8.0;
2984 case SnapToAQuarterBeat:
2985 return 1.0 / (double)4.0;
2988 case SnapToAThirdBeat:
2989 return 1.0 / (double)3.0;
2997 Editor::setup_toolbar ()
3001 /* Mode Buttons (tool selection) */
3003 vector<ToggleButton *> mouse_mode_buttons;
3005 mouse_move_button.add (*(manage (new Image (::get_icon("tool_object")))));
3006 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
3007 mouse_mode_buttons.push_back (&mouse_move_button);
3009 if (!Profile->get_sae()) {
3010 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
3011 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
3012 mouse_mode_buttons.push_back (&mouse_select_button);
3014 mouse_gain_button.add (*(manage (new Image (::get_icon("tool_gain")))));
3015 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
3016 mouse_mode_buttons.push_back (&mouse_gain_button);
3019 mouse_zoom_button.add (*(manage (new Image (::get_icon("tool_zoom")))));
3020 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
3021 mouse_mode_buttons.push_back (&mouse_zoom_button);
3022 mouse_timefx_button.add (*(manage (new Image (::get_icon("tool_stretch")))));
3023 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
3024 mouse_mode_buttons.push_back (&mouse_timefx_button);
3025 mouse_audition_button.add (*(manage (new Image (::get_icon("tool_audition")))));
3026 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
3027 mouse_note_button.add (*(manage (new Image (::get_icon("tool_note")))));
3028 mouse_note_button.set_relief(Gtk::RELIEF_NONE);
3029 mouse_mode_buttons.push_back (&mouse_note_button);
3030 mouse_mode_buttons.push_back (&mouse_audition_button);
3032 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
3034 HBox* mode_box = manage(new HBox);
3035 mode_box->set_border_width (2);
3036 mode_box->set_spacing(4);
3037 mouse_mode_button_box.set_spacing(1);
3038 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
3039 if (!Profile->get_sae()) {
3040 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
3042 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
3043 if (!Profile->get_sae()) {
3044 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
3046 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
3047 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
3048 mouse_mode_button_box.pack_start(mouse_note_button, true, true);
3049 mouse_mode_button_box.set_homogeneous(true);
3051 vector<string> edit_mode_strings;
3052 edit_mode_strings.push_back (edit_mode_to_string (Slide));
3053 if (!Profile->get_sae()) {
3054 edit_mode_strings.push_back (edit_mode_to_string (Splice));
3056 edit_mode_strings.push_back (edit_mode_to_string (Lock));
3058 edit_mode_selector.set_name ("EditModeSelector");
3059 set_popdown_strings (edit_mode_selector, edit_mode_strings, true);
3060 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
3062 mode_box->pack_start(edit_mode_selector);
3063 mode_box->pack_start(mouse_mode_button_box);
3065 mouse_mode_tearoff = manage (new TearOff (*mode_box));
3066 mouse_mode_tearoff->set_name ("MouseModeBase");
3068 if (Profile->get_sae()) {
3069 mouse_mode_tearoff->set_can_be_torn_off (false);
3072 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3073 &mouse_mode_tearoff->tearoff_window()));
3074 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3075 &mouse_mode_tearoff->tearoff_window(), 1));
3076 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3077 &mouse_mode_tearoff->tearoff_window()));
3078 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3079 &mouse_mode_tearoff->tearoff_window(), 1));
3081 mouse_move_button.set_name ("MouseModeButton");
3082 mouse_select_button.set_name ("MouseModeButton");
3083 mouse_gain_button.set_name ("MouseModeButton");
3084 mouse_zoom_button.set_name ("MouseModeButton");
3085 mouse_timefx_button.set_name ("MouseModeButton");
3086 mouse_audition_button.set_name ("MouseModeButton");
3087 mouse_note_button.set_name ("MouseModeButton");
3089 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
3090 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
3091 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
3092 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
3093 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
3094 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
3095 ARDOUR_UI::instance()->tooltips().set_tip (mouse_note_button, _("Edit MIDI Notes"));
3097 mouse_move_button.unset_flags (CAN_FOCUS);
3098 mouse_select_button.unset_flags (CAN_FOCUS);
3099 mouse_gain_button.unset_flags (CAN_FOCUS);
3100 mouse_zoom_button.unset_flags (CAN_FOCUS);
3101 mouse_timefx_button.unset_flags (CAN_FOCUS);
3102 mouse_audition_button.unset_flags (CAN_FOCUS);
3103 mouse_note_button.unset_flags (CAN_FOCUS);
3105 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
3106 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
3108 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
3109 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
3110 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
3111 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
3112 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
3113 mouse_note_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseNote));
3115 // mouse_move_button.set_active (true);
3120 zoom_box.set_spacing (1);
3121 zoom_box.set_border_width (0);
3123 zoom_in_button.set_name ("EditorTimeButton");
3124 zoom_in_button.set_size_request(-1,16);
3125 zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in")))));
3126 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
3127 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
3129 zoom_out_button.set_name ("EditorTimeButton");
3130 zoom_out_button.set_size_request(-1,16);
3131 zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out")))));
3132 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
3133 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
3135 zoom_out_full_button.set_name ("EditorTimeButton");
3136 zoom_out_full_button.set_size_request(-1,16);
3137 zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full")))));
3138 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
3139 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
3141 zoom_focus_selector.set_name ("ZoomFocusSelector");
3142 set_popdown_strings (zoom_focus_selector, zoom_focus_strings, true);
3143 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
3144 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
3146 zoom_box.pack_start (zoom_focus_selector, true, true);
3147 zoom_box.pack_start (zoom_out_button, false, false);
3148 zoom_box.pack_start (zoom_in_button, false, false);
3149 zoom_box.pack_start (zoom_out_full_button, false, false);
3151 snap_box.set_spacing (1);
3152 snap_box.set_border_width (2);
3154 snap_type_selector.set_name ("SnapTypeSelector");
3155 set_popdown_strings (snap_type_selector, snap_type_strings, true);
3156 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
3157 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Snap/Grid Units"));
3159 snap_mode_selector.set_name ("SnapModeSelector");
3160 set_popdown_strings (snap_mode_selector, snap_mode_strings, true);
3161 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
3162 ARDOUR_UI::instance()->tooltips().set_tip (snap_mode_selector, _("Snap/Grid Mode"));
3164 edit_point_selector.set_name ("EditPointSelector");
3165 set_popdown_strings (edit_point_selector, edit_point_strings, true);
3166 edit_point_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_point_selection_done));
3167 ARDOUR_UI::instance()->tooltips().set_tip (edit_point_selector, _("Edit point"));
3169 snap_box.pack_start (edit_point_clock, false, false);
3170 snap_box.pack_start (snap_mode_selector, false, false);
3171 snap_box.pack_start (snap_type_selector, false, false);
3172 snap_box.pack_start (edit_point_selector, false, false);
3176 HBox *nudge_box = manage (new HBox);
3177 nudge_box->set_spacing(1);
3178 nudge_box->set_border_width (2);
3180 nudge_forward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_forward_release), false);
3181 nudge_backward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_backward_release), false);
3183 nudge_box->pack_start (nudge_backward_button, false, false);
3184 nudge_box->pack_start (nudge_forward_button, false, false);
3185 nudge_box->pack_start (nudge_clock, false, false);
3188 /* Pack everything in... */
3190 HBox* hbox = manage (new HBox);
3191 hbox->set_spacing(10);
3193 tools_tearoff = manage (new TearOff (*hbox));
3194 tools_tearoff->set_name ("MouseModeBase");
3196 if (Profile->get_sae()) {
3197 tools_tearoff->set_can_be_torn_off (false);
3200 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3201 &tools_tearoff->tearoff_window()));
3202 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3203 &tools_tearoff->tearoff_window(), 0));
3204 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3205 &tools_tearoff->tearoff_window()));
3206 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3207 &tools_tearoff->tearoff_window(), 0));
3209 toolbar_hbox.set_spacing (10);
3210 toolbar_hbox.set_border_width (1);
3212 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
3213 toolbar_hbox.pack_start (*tools_tearoff, false, false);
3216 hbox->pack_start (snap_box, false, false);
3217 // hbox->pack_start (zoom_box, false, false);
3218 hbox->pack_start (*nudge_box, false, false);
3222 toolbar_base.set_name ("ToolBarBase");
3223 toolbar_base.add (toolbar_hbox);
3225 toolbar_frame.set_shadow_type (SHADOW_OUT);
3226 toolbar_frame.set_name ("BaseFrame");
3227 toolbar_frame.add (toolbar_base);
3231 Editor::midi_panic_button_pressed ()
3234 session->midi_panic();
3239 Editor::setup_midi_toolbar ()
3243 /* Mode Buttons (tool selection) */
3245 vector<ToggleButton *> midi_tool_buttons;
3247 midi_tool_pencil_button.add (*(manage (new Image (::get_icon("midi_tool_pencil")))));
3248 midi_tool_pencil_button.set_relief(Gtk::RELIEF_NONE);
3249 midi_tool_buttons.push_back (&midi_tool_pencil_button);
3250 midi_tool_select_button.add (*(manage (new Image (::get_icon("midi_tool_select")))));
3251 midi_tool_select_button.set_relief(Gtk::RELIEF_NONE);
3252 midi_tool_buttons.push_back (&midi_tool_select_button);
3253 midi_tool_resize_button.add (*(manage (new Image (::get_icon("strip_width")))));
3254 midi_tool_resize_button.set_relief(Gtk::RELIEF_NONE);
3255 midi_tool_buttons.push_back (&midi_tool_resize_button);
3256 midi_tool_erase_button.add (*(manage (new Image (::get_icon("midi_tool_erase")))));
3257 midi_tool_erase_button.set_relief(Gtk::RELIEF_NONE);
3258 midi_tool_buttons.push_back (&midi_tool_erase_button);
3260 midi_tool_pencil_button.set_active(true);
3262 midi_tool_button_set = new GroupedButtons (midi_tool_buttons);
3264 midi_tool_button_box.set_border_width (2);
3265 midi_tool_button_box.set_spacing(1);
3266 midi_tool_button_box.pack_start(midi_tool_pencil_button, true, true);
3267 midi_tool_button_box.pack_start(midi_tool_select_button, true, true);
3268 midi_tool_button_box.pack_start(midi_tool_resize_button, true, true);
3269 midi_tool_button_box.pack_start(midi_tool_erase_button , true, true);
3270 midi_tool_button_box.set_homogeneous(true);
3272 midi_tool_pencil_button.set_name ("MouseModeButton");
3273 midi_tool_select_button.set_name ("MouseModeButton");
3274 midi_tool_resize_button.set_name ("MouseModeButton");
3275 midi_tool_erase_button .set_name ("MouseModeButton");
3277 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_pencil_button, _("Add/Move/Stretch Notes"));
3278 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_select_button, _("Select/Move Notes"));
3279 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_resize_button, _("Resize Notes"));
3280 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_erase_button, _("Erase Notes"));
3282 midi_tool_pencil_button.unset_flags (CAN_FOCUS);
3283 midi_tool_select_button.unset_flags (CAN_FOCUS);
3284 midi_tool_resize_button.unset_flags (CAN_FOCUS);
3285 midi_tool_erase_button.unset_flags (CAN_FOCUS);
3287 midi_tool_pencil_button.signal_toggled().connect (bind (mem_fun(*this,
3288 &Editor::midi_edit_mode_toggled), Editing::MidiEditPencil));
3289 midi_tool_select_button.signal_toggled().connect (bind (mem_fun(*this,
3290 &Editor::midi_edit_mode_toggled), Editing::MidiEditSelect));
3291 midi_tool_resize_button.signal_toggled().connect (bind (mem_fun(*this,
3292 &Editor::midi_edit_mode_toggled), Editing::MidiEditResize));
3293 midi_tool_erase_button.signal_toggled().connect (bind (mem_fun(*this,
3294 &Editor::midi_edit_mode_toggled), Editing::MidiEditErase));
3297 /* Midi sound notes */
3298 midi_sound_notes.add (*(manage (new Image (::get_icon("midi_sound_notes")))));
3299 midi_sound_notes.set_relief(Gtk::RELIEF_NONE);
3300 ARDOUR_UI::instance()->tooltips().set_tip (midi_sound_notes, _("Sound Notes"));
3301 midi_sound_notes.unset_flags (CAN_FOCUS);
3305 HBox* panic_box = manage (new HBox);
3306 midi_panic_button.set_name("MidiPanicButton");
3307 midi_panic_button.signal_pressed().connect (
3308 mem_fun(this, &Editor::midi_panic_button_pressed));
3309 panic_box->pack_start (midi_sound_notes , true, true);
3310 panic_box->pack_start (midi_panic_button, true, true);
3312 /* Pack everything in... */
3314 midi_tools_tearoff = manage (new TearOff (midi_tool_button_box));
3315 midi_tools_tearoff->set_name ("MouseModeBase");
3318 midi_tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&midi_toolbar_hbox),
3319 &midi_tools_tearoff->tearoff_window()));
3320 midi_tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&midi_toolbar_hbox),
3321 &midi_tools_tearoff->tearoff_window(), 0));
3322 midi_tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&midi_toolbar_hbox),
3323 &midi_tools_tearoff->tearoff_window()));
3324 midi_tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&midi_toolbar_hbox),
3325 &midi_tools_tearoff->tearoff_window(), 0));
3328 midi_toolbar_hbox.set_spacing (10);
3329 midi_toolbar_hbox.set_border_width (1);
3331 midi_toolbar_hbox.pack_start (*midi_tools_tearoff, false, true);
3333 midi_toolbar_hbox.pack_start(*panic_box, false, true, 4);
3335 midi_tool_button_box.show_all ();
3336 midi_toolbar_hbox.show_all();
3337 midi_tools_tearoff->show_all();
3339 midi_toolbar_base.set_name ("ToolBarBase");
3340 midi_toolbar_base.add (midi_toolbar_hbox);
3342 midi_toolbar_frame.set_shadow_type (SHADOW_OUT);
3343 midi_toolbar_frame.set_name ("BaseFrame");
3344 midi_toolbar_frame.add (midi_toolbar_base);
3348 Editor::convert_drop_to_paths (
3349 vector<ustring>& paths,
3350 const RefPtr<Gdk::DragContext>& context,
3353 const SelectionData& data,
3361 vector<ustring> uris = data.get_uris();
3365 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
3366 are actually URI lists. So do it by hand.
3369 if (data.get_target() != "text/plain") {
3373 /* Parse the "uri-list" format that Nautilus provides,
3374 where each pathname is delimited by \r\n.
3376 THERE MAY BE NO NULL TERMINATING CHAR!!!
3379 ustring txt = data.get_text();
3383 p = (const char *) malloc (txt.length() + 1);
3384 txt.copy ((char *) p, txt.length(), 0);
3385 ((char*)p)[txt.length()] = '\0';
3391 while (g_ascii_isspace (*p))
3395 while (*q && (*q != '\n') && (*q != '\r')) {
3402 while (q > p && g_ascii_isspace (*q))
3407 uris.push_back (ustring (p, q - p + 1));
3411 p = strchr (p, '\n');
3423 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
3425 if ((*i).substr (0,7) == "file://") {
3428 PBD::url_decode (p);
3430 // scan forward past three slashes
3432 ustring::size_type slashcnt = 0;
3433 ustring::size_type n = 0;
3434 ustring::iterator x = p.begin();
3436 while (slashcnt < 3 && x != p.end()) {
3439 } else if (slashcnt == 3) {
3446 if (slashcnt != 3 || x == p.end()) {
3447 error << _("malformed URL passed to drag-n-drop code") << endmsg;
3451 paths.push_back (p.substr (n - 1));
3459 Editor::new_tempo_section ()
3465 Editor::map_transport_state ()
3467 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
3469 if (session->transport_stopped()) {
3470 have_pending_keyboard_selection = false;
3473 update_loop_range_view (true);
3478 Editor::State::State (PublicEditor const * e)
3480 selection = new Selection (e);
3483 Editor::State::~State ()
3489 Editor::store_state (State& state) const
3491 *state.selection = *selection;
3495 Editor::restore_state (State *state)
3497 if (*selection == *state->selection) {
3501 *selection = *state->selection;
3502 time_selection_changed ();
3503 region_selection_changed ();
3505 /* XXX other selection change handlers? */
3509 Editor::begin_reversible_command (string name)
3512 before = &get_state();
3513 session->begin_reversible_command (name);
3518 Editor::commit_reversible_command ()
3521 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
3526 Editor::set_edit_group_solo (Route& route, bool yn)
3528 RouteGroup *edit_group;
3530 if ((edit_group = route.edit_group()) != 0) {
3531 edit_group->apply (&Route::set_solo, yn, this);
3533 route.set_solo (yn, this);
3538 Editor::set_edit_group_mute (Route& route, bool yn)
3540 RouteGroup *edit_group = 0;
3542 if ((edit_group == route.edit_group()) != 0) {
3543 edit_group->apply (&Route::set_mute, yn, this);
3545 route.set_mute (yn, this);
3550 Editor::history_changed ()
3554 if (undo_action && session) {
3555 if (session->undo_depth() == 0) {
3558 label = string_compose(_("Undo (%1)"), session->next_undo());
3560 undo_action->property_label() = label;
3563 if (redo_action && session) {
3564 if (session->redo_depth() == 0) {
3567 label = string_compose(_("Redo (%1)"), session->next_redo());
3569 redo_action->property_label() = label;
3574 Editor::duplicate_dialog (bool with_dialog)
3578 if (mouse_mode == MouseRange) {
3579 if (selection->time.length() == 0) {
3585 get_regions_for_action (rs);
3587 if (mouse_mode != MouseRange) {
3596 ArdourDialog win ("Duplication Dialog");
3597 Label label (_("Number of Duplications:"));
3598 Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
3599 SpinButton spinner (adjustment, 0.0, 1);
3602 win.get_vbox()->set_spacing (12);
3603 win.get_vbox()->pack_start (hbox);
3604 hbox.set_border_width (6);
3605 hbox.pack_start (label, PACK_EXPAND_PADDING, 12);
3607 /* dialogs have ::add_action_widget() but that puts the spinner in the wrong
3608 place, visually. so do this by hand.
3611 hbox.pack_start (spinner, PACK_EXPAND_PADDING, 12);
3612 spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
3613 spinner.grab_focus();
3619 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3620 win.add_button (_("Duplicate"), RESPONSE_ACCEPT);
3621 win.set_default_response (RESPONSE_ACCEPT);
3623 win.set_position (WIN_POS_MOUSE);
3625 spinner.grab_focus ();
3627 switch (win.run ()) {
3628 case RESPONSE_ACCEPT:
3634 times = adjustment.get_value();
3637 if (mouse_mode == MouseRange) {
3638 duplicate_selection (times);
3640 duplicate_some_regions (rs, times);
3645 Editor::show_verbose_canvas_cursor ()
3647 verbose_canvas_cursor->raise_to_top();
3648 verbose_canvas_cursor->show();
3649 verbose_cursor_visible = true;
3653 Editor::hide_verbose_canvas_cursor ()
3655 verbose_canvas_cursor->hide();
3656 verbose_cursor_visible = false;
3660 Editor::clamp_verbose_cursor_x (double x)
3665 x = min (_canvas_width - 200.0, x);
3671 Editor::clamp_verbose_cursor_y (double y)
3673 if (y < canvas_timebars_vsize) {
3674 y = canvas_timebars_vsize;
3676 y = min (_canvas_height - 50, y);
3682 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3684 verbose_canvas_cursor->property_text() = txt.c_str();
3685 /* don't get too close to the edge */
3686 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (x);
3687 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (y);
3691 Editor::set_verbose_canvas_cursor_text (const string & txt)
3693 verbose_canvas_cursor->property_text() = txt.c_str();
3697 Editor::set_edit_mode (EditMode m)
3699 Config->set_edit_mode (m);
3703 Editor::cycle_edit_mode ()
3705 switch (Config->get_edit_mode()) {
3707 if (Profile->get_sae()) {
3708 Config->set_edit_mode (Lock);
3710 Config->set_edit_mode (Splice);
3714 Config->set_edit_mode (Lock);
3717 Config->set_edit_mode (Slide);
3723 Editor::edit_mode_selection_done ()
3729 string choice = edit_mode_selector.get_active_text();
3730 EditMode mode = Slide;
3732 if (choice == _("Splice Edit")) {
3734 } else if (choice == _("Slide Edit")) {
3736 } else if (choice == _("Lock Edit")) {
3740 Config->set_edit_mode (mode);
3744 Editor::snap_type_selection_done ()
3746 string choice = snap_type_selector.get_active_text();
3747 SnapType snaptype = SnapToBeat;
3749 if (choice == _("Beats/3")) {
3750 snaptype = SnapToAThirdBeat;
3751 } else if (choice == _("Beats/4")) {
3752 snaptype = SnapToAQuarterBeat;
3753 } else if (choice == _("Beats/8")) {
3754 snaptype = SnapToAEighthBeat;
3755 } else if (choice == _("Beats/16")) {
3756 snaptype = SnapToASixteenthBeat;
3757 } else if (choice == _("Beats/32")) {
3758 snaptype = SnapToAThirtysecondBeat;
3759 } else if (choice == _("Beats")) {
3760 snaptype = SnapToBeat;
3761 } else if (choice == _("Bars")) {
3762 snaptype = SnapToBar;
3763 } else if (choice == _("Marks")) {
3764 snaptype = SnapToMark;
3765 } else if (choice == _("Region starts")) {
3766 snaptype = SnapToRegionStart;
3767 } else if (choice == _("Region ends")) {
3768 snaptype = SnapToRegionEnd;
3769 } else if (choice == _("Region bounds")) {
3770 snaptype = SnapToRegionBoundary;
3771 } else if (choice == _("Region syncs")) {
3772 snaptype = SnapToRegionSync;
3773 } else if (choice == _("CD Frames")) {
3774 snaptype = SnapToCDFrame;
3775 } else if (choice == _("SMPTE Frames")) {
3776 snaptype = SnapToSMPTEFrame;
3777 } else if (choice == _("SMPTE Seconds")) {
3778 snaptype = SnapToSMPTESeconds;
3779 } else if (choice == _("SMPTE Minutes")) {
3780 snaptype = SnapToSMPTEMinutes;
3781 } else if (choice == _("Seconds")) {
3782 snaptype = SnapToSeconds;
3783 } else if (choice == _("Minutes")) {
3784 snaptype = SnapToMinutes;
3787 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3789 ract->set_active ();
3794 Editor::snap_mode_selection_done ()
3796 string choice = snap_mode_selector.get_active_text();
3797 SnapMode mode = SnapNormal;
3799 if (choice == _("No Grid")) {
3801 } else if (choice == _("Grid")) {
3803 } else if (choice == _("Magnetic")) {
3804 mode = SnapMagnetic;
3807 RefPtr<RadioAction> ract = snap_mode_action (mode);
3810 ract->set_active (true);
3815 Editor::cycle_edit_point (bool with_marker)
3817 switch (_edit_point) {
3819 set_edit_point_preference (EditAtPlayhead);
3821 case EditAtPlayhead:
3823 set_edit_point_preference (EditAtSelectedMarker);
3825 set_edit_point_preference (EditAtMouse);
3828 case EditAtSelectedMarker:
3829 set_edit_point_preference (EditAtMouse);
3835 Editor::edit_point_selection_done ()
3837 string choice = edit_point_selector.get_active_text();
3838 EditPoint ep = EditAtSelectedMarker;
3840 if (choice == _("Marker")) {
3841 set_edit_point_preference (EditAtSelectedMarker);
3842 } else if (choice == _("Playhead")) {
3843 set_edit_point_preference (EditAtPlayhead);
3845 set_edit_point_preference (EditAtMouse);
3848 RefPtr<RadioAction> ract = edit_point_action (ep);
3851 ract->set_active (true);
3856 Editor::zoom_focus_selection_done ()
3858 string choice = zoom_focus_selector.get_active_text();
3859 ZoomFocus focus_type = ZoomFocusLeft;
3861 if (choice == _("Left")) {
3862 focus_type = ZoomFocusLeft;
3863 } else if (choice == _("Right")) {
3864 focus_type = ZoomFocusRight;
3865 } else if (choice == _("Center")) {
3866 focus_type = ZoomFocusCenter;
3867 } else if (choice == _("Play")) {
3868 focus_type = ZoomFocusPlayhead;
3869 } else if (choice == _("Edit")) {
3870 focus_type = ZoomFocusEdit;
3871 } else if (choice == _("Active Mark")) {
3872 focus_type = ZoomFocusEdit;
3873 } else if (choice == _("Active Mark")) {
3874 focus_type = ZoomFocusEdit;
3876 focus_type = ZoomFocusMouse;
3879 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3882 ract->set_active ();
3887 Editor::edit_controls_button_release (GdkEventButton* ev)
3889 if (Keyboard::is_context_menu_event (ev)) {
3890 ARDOUR_UI::instance()->add_route (this);
3896 Editor::mouse_select_button_release (GdkEventButton* ev)
3898 /* this handles just right-clicks */
3900 if (ev->button != 3) {
3907 Editor::TrackViewList *
3908 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3911 TrackViewList::iterator i;
3913 v = new TrackViewList;
3915 if (track == 0 && group == 0) {
3919 for (i = track_views.begin(); i != track_views.end (); ++i) {
3923 } else if ((track != 0 && group == 0) || (track != 0 && group != 0 && !group->is_active())) {
3925 /* just the view for this track
3928 v->push_back (track);
3932 /* views for all tracks in the edit group */
3934 for (i = track_views.begin(); i != track_views.end (); ++i) {
3936 if (group == 0 || (*i)->edit_group() == group) {
3946 Editor::set_zoom_focus (ZoomFocus f)
3948 string str = zoom_focus_strings[(int)f];
3950 if (str != zoom_focus_selector.get_active_text()) {
3951 zoom_focus_selector.set_active_text (str);
3954 if (zoom_focus != f) {
3957 ZoomFocusChanged (); /* EMIT_SIGNAL */
3964 Editor::ensure_float (Window& win)
3966 win.set_transient_for (*this);
3970 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3972 /* recover or initialize pane positions. do this here rather than earlier because
3973 we don't want the positions to change the child allocations, which they seem to do.
3979 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3981 static int32_t done;
3984 width = default_width;
3985 height = default_height;
3987 if ((geometry = find_named_node (*node, "geometry")) != 0) {
3989 if ((prop = geometry->property ("x_size")) == 0) {
3990 prop = geometry->property ("x-size");
3993 width = atoi (prop->value());
3995 if ((prop = geometry->property ("y_size")) == 0) {
3996 prop = geometry->property ("y-size");
3999 height = atoi (prop->value());
4003 if (which == static_cast<Paned*> (&edit_pane)) {
4009 if (!geometry || (prop = geometry->property ("edit-pane-pos")) == 0) {
4010 /* initial allocation is 90% to canvas, 10% to notebook */
4011 pos = (int) floor (alloc.get_width() * 0.90f);
4012 snprintf (buf, sizeof(buf), "%d", pos);
4014 pos = atoi (prop->value());
4017 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
4018 edit_pane.set_position (pos);
4019 pre_maximal_pane_position = pos;
4025 Editor::detach_tearoff (Box* b, Window* w)
4027 if (tools_tearoff->torn_off() &&
4028 mouse_mode_tearoff->torn_off()) {
4029 top_hbox.remove (toolbar_frame);
4034 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
4036 if (toolbar_frame.get_parent() == 0) {
4037 top_hbox.pack_end (toolbar_frame);
4042 Editor::set_show_measures (bool yn)
4044 if (_show_measures != yn) {
4047 if ((_show_measures = yn) == true) {
4049 tempo_lines->show();
4057 Editor::toggle_follow_playhead ()
4059 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
4061 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
4062 set_follow_playhead (tact->get_active());
4067 Editor::set_follow_playhead (bool yn)
4069 if (_follow_playhead != yn) {
4070 if ((_follow_playhead = yn) == true) {
4072 update_current_screen ();
4079 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
4081 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
4083 xfade->set_active (!xfade->active());
4088 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
4090 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
4092 xfade->set_follow_overlap (!xfade->following_overlap());
4097 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
4099 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
4105 CrossfadeEditor cew (*session, xfade, xfade->fade_in().get_min_y(), 1.0);
4109 switch (cew.run ()) {
4110 case RESPONSE_ACCEPT:
4117 xfade->StateChanged (Change (~0));
4121 Editor::playlist_selector () const
4123 return *_playlist_selector;
4127 Editor::get_nudge_distance (nframes64_t pos, nframes64_t& next)
4131 ret = nudge_clock.current_duration (pos);
4132 next = ret + 1; /* XXXX fix me */
4138 Editor::end_location_changed (Location* location)
4140 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
4141 //reset_scrolling_region ();
4142 nframes64_t session_span = location->start() + (nframes64_t) floorf (current_page_frames() * 0.10f);
4143 horizontal_adjustment.set_upper (session_span / frames_per_unit);
4147 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
4149 ArdourDialog dialog ("playlist deletion dialog");
4150 Label label (string_compose (_("Playlist %1 is currently unused.\n"
4151 "If left alone, no audio files used by it will be cleaned.\n"
4152 "If deleted, audio files used by it alone by will cleaned."),
4155 dialog.set_position (WIN_POS_CENTER);
4156 dialog.get_vbox()->pack_start (label);
4160 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
4161 dialog.add_button (_("Keep playlist"), RESPONSE_REJECT);
4162 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
4164 switch (dialog.run ()) {
4165 case RESPONSE_ACCEPT:
4166 /* delete the playlist */
4170 case RESPONSE_REJECT:
4171 /* keep the playlist */
4183 Editor::audio_region_selection_covers (nframes64_t where)
4185 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
4186 if ((*a)->region()->covers (where)) {
4195 Editor::prepare_for_cleanup ()
4197 cut_buffer->clear_regions ();
4198 cut_buffer->clear_playlists ();
4200 selection->clear_regions ();
4201 selection->clear_playlists ();
4203 no_region_list_redisplay = true;
4207 Editor::finish_cleanup ()
4209 no_region_list_redisplay = false;
4210 redisplay_regions ();
4214 Editor::transport_loop_location()
4217 return session->locations()->auto_loop_location();
4224 Editor::transport_punch_location()
4227 return session->locations()->auto_punch_location();
4234 Editor::control_layout_scroll (GdkEventScroll* ev)
4236 switch (ev->direction) {
4238 scroll_tracks_up_line ();
4242 case GDK_SCROLL_DOWN:
4243 scroll_tracks_down_line ();
4247 /* no left/right handling yet */
4255 /** A new snapshot has been selected.
4258 Editor::snapshot_display_selection_changed ()
4260 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
4262 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
4264 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
4266 if (snap_name.length() == 0) {
4270 if (session->snap_name() == snap_name) {
4274 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
4279 Editor::snapshot_display_button_press (GdkEventButton* ev)
4281 if (ev->button == 3) {
4282 /* Right-click on the snapshot list. Work out which snapshot it
4284 Gtk::TreeModel::Path path;
4285 Gtk::TreeViewColumn* col;
4288 snapshot_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, col, cx, cy);
4289 Gtk::TreeModel::iterator iter = snapshot_display_model->get_iter (path);
4291 Gtk::TreeModel::Row row = *iter;
4292 popup_snapshot_context_menu (ev->button, ev->time, row[snapshot_display_columns.real_name]);
4301 /** Pop up the snapshot display context menu.
4302 * @param button Button used to open the menu.
4303 * @param time Menu open time.
4304 * @snapshot_name Name of the snapshot that the menu click was over.
4308 Editor::popup_snapshot_context_menu (int button, int32_t time, Glib::ustring snapshot_name)
4310 using namespace Menu_Helpers;
4312 MenuList& items (snapshot_context_menu.items());
4315 const bool modification_allowed = (session->snap_name() != snapshot_name && session->name() != snapshot_name);
4317 add_item_with_sensitivity (items, MenuElem (_("Remove"), bind (mem_fun (*this, &Editor::remove_snapshot), snapshot_name)), modification_allowed);
4319 add_item_with_sensitivity (items, MenuElem (_("Rename"), bind (mem_fun (*this, &Editor::rename_snapshot), snapshot_name)), modification_allowed);
4321 snapshot_context_menu.popup (button, time);
4325 Editor::rename_snapshot (Glib::ustring old_name)
4327 ArdourPrompter prompter(true);
4331 prompter.set_name ("Prompter");
4332 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
4333 prompter.set_prompt (_("New name of snapshot"));
4334 prompter.set_initial_text (old_name);
4336 if (prompter.run() == RESPONSE_ACCEPT) {
4337 prompter.get_result (new_name);
4338 if (new_name.length()) {
4339 session->rename_state (old_name, new_name);
4340 redisplay_snapshots ();
4347 Editor::remove_snapshot (Glib::ustring name)
4349 vector<string> choices;
4351 std::string prompt = string_compose (_("Do you really want to remove snapshot \"%1\" ?\n(cannot be undone)"), name);
4353 choices.push_back (_("No, do nothing."));
4354 choices.push_back (_("Yes, remove it."));
4356 Gtkmm2ext::Choice prompter (prompt, choices);
4358 if (prompter.run () == 1) {
4359 session->remove_state (name);
4360 redisplay_snapshots ();
4365 Editor::redisplay_snapshots ()
4371 vector<sys::path> state_file_paths;
4373 get_state_files_in_directory (session->session_directory().root_path(),
4376 if (state_file_paths.empty()) return;
4378 vector<string> state_file_names(get_file_names_no_extension(state_file_paths));
4380 snapshot_display_model->clear ();
4382 for (vector<string>::iterator i = state_file_names.begin();
4383 i != state_file_names.end(); ++i)
4385 string statename = (*i);
4386 TreeModel::Row row = *(snapshot_display_model->append());
4388 /* this lingers on in case we ever want to change the visible
4389 name of the snapshot.
4392 string display_name;
4393 display_name = statename;
4395 if (statename == session->snap_name()) {
4396 snapshot_display.get_selection()->select(row);
4399 row[snapshot_display_columns.visible_name] = display_name;
4400 row[snapshot_display_columns.real_name] = statename;
4405 Editor::session_state_saved (string snap_name)
4407 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4408 redisplay_snapshots ();
4412 Editor::maximise_editing_space ()
4414 mouse_mode_tearoff->set_visible (false);
4415 tools_tearoff->set_visible (false);
4417 pre_maximal_pane_position = edit_pane.get_position();
4418 pre_maximal_editor_width = this->get_width();
4420 if(post_maximal_pane_position == 0) {
4421 post_maximal_pane_position = edit_pane.get_width();
4426 if(post_maximal_editor_width) {
4427 edit_pane.set_position (post_maximal_pane_position -
4428 abs(post_maximal_editor_width - pre_maximal_editor_width));
4430 edit_pane.set_position (post_maximal_pane_position);
4435 Editor::restore_editing_space ()
4437 // user changed width of pane during fullscreen
4439 if(post_maximal_pane_position != edit_pane.get_position()) {
4440 post_maximal_pane_position = edit_pane.get_position();
4445 mouse_mode_tearoff->set_visible (true);
4446 tools_tearoff->set_visible (true);
4447 post_maximal_editor_width = this->get_width();
4449 edit_pane.set_position (pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width));
4453 * Make new playlists for a given track and also any others that belong
4454 * to the same active edit group.
4459 Editor::new_playlists (TimeAxisView* v)
4461 begin_reversible_command (_("new playlists"));
4462 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4463 session->get_playlists(playlists);
4464 mapover_tracks ( bind(mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v );
4465 commit_reversible_command ();
4469 * Use a copy of the current playlist for a given track and also any others that belong
4470 * to the same active edit group.
4475 Editor::copy_playlists (TimeAxisView* v)
4477 begin_reversible_command (_("copy playlists"));
4478 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4479 session->get_playlists(playlists);
4480 mapover_tracks ( bind(mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v );
4481 commit_reversible_command ();
4485 * Clear the current playlist for a given track and also any others that belong
4486 * to the same active edit group.
4491 Editor::clear_playlists (TimeAxisView* v)
4493 begin_reversible_command (_("clear playlists"));
4494 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4495 session->get_playlists(playlists);
4496 mapover_tracks ( mem_fun (*this, &Editor::mapped_clear_playlist), v );
4497 commit_reversible_command ();
4501 Editor::mapped_use_new_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4503 atv.use_new_playlist (sz > 1 ? false : true, playlists);
4507 Editor::mapped_use_copy_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4509 atv.use_copy_playlist (sz > 1 ? false : true, playlists);
4513 Editor::mapped_clear_playlist (RouteTimeAxisView& atv, uint32_t sz)
4515 atv.clear_playlist ();
4519 Editor::on_key_press_event (GdkEventKey* ev)
4521 return key_press_focus_accelerator_handler (*this, ev);
4525 Editor::on_key_release_event (GdkEventKey* ev)
4527 return Gtk::Window::on_key_release_event (ev);
4528 // return key_press_focus_accelerator_handler (*this, ev);
4532 Editor::reset_x_origin (nframes64_t frame)
4534 //cerr << "resetting x origin" << endl;
4535 queue_visual_change (frame);
4539 Editor::reset_y_origin (double y)
4541 queue_visual_change_y (y);
4545 Editor::reset_zoom (double fpu)
4547 queue_visual_change (fpu);
4551 Editor::reposition_and_zoom (nframes64_t frame, double fpu)
4553 //cerr << "Editor::reposition_and_zoom () called ha v:l:u:ps:fpu = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << frames_per_unit << endl;//DEBUG
4554 reset_x_origin (frame);
4557 if (!no_save_visual) {
4558 undo_visual_stack.push_back (current_visual_state(false));
4562 Editor::VisualState*
4563 Editor::current_visual_state (bool with_tracks)
4565 VisualState* vs = new VisualState;
4566 vs->y_position = vertical_adjustment.get_value();
4567 vs->frames_per_unit = frames_per_unit;
4568 vs->leftmost_frame = leftmost_frame;
4569 vs->zoom_focus = zoom_focus;
4570 vs->zoomed_to_region = zoomed_to_region;
4573 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4574 vs->track_states.push_back (TAVState ((*i), &(*i)->get_state()));
4582 Editor::undo_visual_state ()
4584 if (undo_visual_stack.empty()) {
4588 VisualState* vs = undo_visual_stack.back();
4589 undo_visual_stack.pop_back();
4590 use_visual_state (*vs);
4591 redo_visual_stack.push_back (vs);
4595 Editor::redo_visual_state ()
4597 if (redo_visual_stack.empty()) {
4601 VisualState* vs = redo_visual_stack.back();
4602 redo_visual_stack.pop_back();
4603 use_visual_state (*vs);
4604 undo_visual_stack.push_back (vs);
4608 Editor::swap_visual_state ()
4610 if (undo_visual_stack.empty()) {
4611 redo_visual_state ();
4613 undo_visual_state ();
4618 Editor::use_visual_state (VisualState& vs)
4620 no_save_visual = true;
4621 no_route_list_redisplay = true;
4623 vertical_adjustment.set_value (vs.y_position);
4625 set_zoom_focus (vs.zoom_focus);
4626 reposition_and_zoom (vs.leftmost_frame, vs.frames_per_unit);
4627 zoomed_to_region = vs.zoomed_to_region;
4629 for (list<TAVState>::iterator i = vs.track_states.begin(); i != vs.track_states.end(); ++i) {
4630 TrackViewList::iterator t;
4632 /* check if the track still exists - it could have been deleted */
4634 if ((t = find (track_views.begin(), track_views.end(), i->first)) != track_views.end()) {
4635 (*t)->set_state (*(i->second));
4640 if (!vs.track_states.empty()) {
4641 update_route_visibility ();
4644 no_route_list_redisplay = false;
4645 redisplay_route_list ();
4647 no_save_visual = false;
4651 Editor::set_frames_per_unit (double fpu)
4653 /* this is the core function that controls the zoom level of the canvas. it is called
4654 whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
4657 if (fpu == frames_per_unit) {
4666 /* don't allow zooms that fit more than the maximum number
4667 of frames into an 800 pixel wide space.
4670 if (max_frames / fpu < 800.0) {
4675 tempo_lines->tempo_map_changed();
4677 frames_per_unit = fpu;
4682 Editor::post_zoom ()
4684 nframes64_t cef = 0;
4686 // convert fpu to frame count
4688 nframes64_t frames = (nframes64_t) floor (frames_per_unit * _canvas_width);
4690 if (frames_per_unit != zoom_range_clock.current_duration()) {
4691 zoom_range_clock.set (frames);
4694 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
4695 if (!selection->tracks.empty()) {
4696 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4697 (*i)->reshow_selection (selection->time);
4700 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4701 (*i)->reshow_selection (selection->time);
4706 leftmost_frame = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4708 ZoomChanged (); /* EMIT_SIGNAL */
4710 reset_hscrollbar_stepping ();
4713 cef = session->current_end_frame() + (current_page_frames() / 10);// Add a little extra so we can see the end marker
4715 horizontal_adjustment.set_upper (cef / frames_per_unit);
4717 //reset_scrolling_region ();
4719 if (playhead_cursor) {
4720 playhead_cursor->set_position (playhead_cursor->current_frame);
4723 _summary->set_overlays_dirty ();
4729 Editor::queue_visual_change (nframes64_t where)
4731 pending_visual_change.add (VisualChange::TimeOrigin);
4733 /* if we're moving beyond the end, make sure the upper limit of the horizontal adjustment
4737 if (where > session->current_end_frame()) {
4738 horizontal_adjustment.set_upper ((where + current_page_frames()) / frames_per_unit);
4741 pending_visual_change.time_origin = where;
4743 ensure_visual_change_idle_handler ();
4747 Editor::queue_visual_change (double fpu)
4749 pending_visual_change.add (VisualChange::ZoomLevel);
4750 pending_visual_change.frames_per_unit = fpu;
4752 ensure_visual_change_idle_handler ();
4757 Editor::queue_visual_change_y (double y)
4759 pending_visual_change.add (VisualChange::YOrigin);
4760 pending_visual_change.y_origin = y;
4762 ensure_visual_change_idle_handler ();
4766 Editor::ensure_visual_change_idle_handler ()
4768 if (pending_visual_change.idle_handler_id < 0) {
4769 pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
4774 Editor::_idle_visual_changer (void* arg)
4776 return static_cast<Editor*>(arg)->idle_visual_changer ();
4780 Editor::idle_visual_changer ()
4782 VisualChange::Type p = pending_visual_change.pending;
4783 pending_visual_change.pending = (VisualChange::Type) 0;
4785 #ifdef FIX_THIS_FOR_V3
4786 double last_time_origin = horizontal_adjustment.get_value();
4789 if (p & VisualChange::ZoomLevel) {
4790 set_frames_per_unit (pending_visual_change.frames_per_unit);
4792 compute_fixed_ruler_scale ();
4793 compute_current_bbt_points(pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4794 compute_bbt_ruler_scale (pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4795 update_tempo_based_rulers ();
4797 if (p & VisualChange::TimeOrigin) {
4798 horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
4800 if (p & VisualChange::YOrigin) {
4801 vertical_adjustment.set_value (pending_visual_change.y_origin);
4804 nframes64_t csf=0, cef=0;
4805 nframes64_t current_time_origin = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4808 csf = session->current_start_frame();
4809 cef = session->current_end_frame();
4812 /* if we seek beyond the current end of the canvas, move the end */
4814 #ifdef FIX_THIS_FOR_V3
4815 if (last_time_origin == horizontal_adjustment.get_value() ) {
4816 /* changed signal not emitted */
4817 update_fixed_rulers ();
4818 redisplay_tempo (true);
4822 if (current_time_origin != pending_visual_change.time_origin) {
4823 cef += current_page_frames() / 10; // Add a little extra so we can see the end marker
4824 horizontal_adjustment.set_upper (cef / frames_per_unit);
4825 horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
4827 update_fixed_rulers();
4828 redisplay_tempo (true);
4831 _summary->set_overlays_dirty ();
4833 //cerr << "Editor::idle_visual_changer () called ha v:l:u:ps:fpu = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << frames_per_unit << endl;//DEBUG
4834 pending_visual_change.idle_handler_id = -1;
4835 return 0; /* this is always a one-shot call */
4838 struct EditorOrderTimeAxisSorter {
4839 bool operator() (const TimeAxisView* a, const TimeAxisView* b) const {
4840 return a->order () < b->order ();
4845 Editor::sort_track_selection (TrackSelection* sel)
4847 EditorOrderTimeAxisSorter cmp;
4852 selection->tracks.sort (cmp);
4857 Editor::get_preferred_edit_position (bool ignore_playhead)
4860 nframes64_t where = 0;
4861 EditPoint ep = _edit_point;
4863 if (entered_marker) {
4864 return entered_marker->position();
4867 if (ignore_playhead && ep == EditAtPlayhead) {
4868 ep = EditAtSelectedMarker;
4872 case EditAtPlayhead:
4873 where = session->audible_frame();
4876 case EditAtSelectedMarker:
4877 if (!selection->markers.empty()) {
4879 Location* loc = find_location_from_marker (selection->markers.front(), is_start);
4882 where = loc->start();
4893 if (!mouse_frame (where, ignored)) {
4894 /* XXX not right but what can we do ? */
4905 Editor::set_loop_range (nframes64_t start, nframes64_t end, string cmd)
4907 if (!session) return;
4909 begin_reversible_command (cmd);
4913 if ((tll = transport_loop_location()) == 0) {
4914 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoLoop);
4915 XMLNode &before = session->locations()->get_state();
4916 session->locations()->add (loc, true);
4917 session->set_auto_loop_location (loc);
4918 XMLNode &after = session->locations()->get_state();
4919 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4921 XMLNode &before = tll->get_state();
4922 tll->set_hidden (false, this);
4923 tll->set (start, end);
4924 XMLNode &after = tll->get_state();
4925 session->add_command (new MementoCommand<Location>(*tll, &before, &after));
4928 commit_reversible_command ();
4932 Editor::set_punch_range (nframes64_t start, nframes64_t end, string cmd)
4934 if (!session) return;
4936 begin_reversible_command (cmd);
4940 if ((tpl = transport_punch_location()) == 0) {
4941 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoPunch);
4942 XMLNode &before = session->locations()->get_state();
4943 session->locations()->add (loc, true);
4944 session->set_auto_loop_location (loc);
4945 XMLNode &after = session->locations()->get_state();
4946 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4949 XMLNode &before = tpl->get_state();
4950 tpl->set_hidden (false, this);
4951 tpl->set (start, end);
4952 XMLNode &after = tpl->get_state();
4953 session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
4956 commit_reversible_command ();
4960 Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4962 const TrackSelection* tracks;
4965 tracks = &track_views;
4970 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4971 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4973 boost::shared_ptr<Diskstream> ds;
4974 boost::shared_ptr<Playlist> pl;
4976 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
4978 Playlist::RegionList* regions = pl->regions_at (
4979 (nframes64_t) floor ( (double)where * ds->speed()));
4981 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4982 RegionView* rv = rtv->view()->find_view (*i);
4995 Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4997 const TrackSelection* tracks;
5000 tracks = &track_views;
5005 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
5006 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
5008 boost::shared_ptr<Diskstream> ds;
5009 boost::shared_ptr<Playlist> pl;
5011 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
5013 Playlist::RegionList* regions = pl->regions_touched (
5014 (nframes64_t) floor ( (double)where * ds->speed()), max_frames);
5016 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
5018 RegionView* rv = rtv->view()->find_view (*i);
5032 Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered)
5034 if (selection->regions.empty()) {
5036 if (selection->tracks.empty()) {
5038 /* no regions or tracks selected
5041 if (entered_regionview && mouse_mode == Editing::MouseObject) {
5043 /* entered regionview is valid and we're in object mode -
5044 just use entered regionview
5047 rs.add (entered_regionview);
5054 /* no regions selected, so get all regions at the edit point across
5055 all selected tracks.
5058 nframes64_t where = get_preferred_edit_position();
5059 get_regions_at (rs, where, selection->tracks);
5061 /* if the entered regionview wasn't selected and neither was its track
5065 if (entered_regionview != 0 &&
5066 !selection->selected (entered_regionview) &&
5067 !selection->selected (&entered_regionview->get_time_axis_view())) {
5068 rs.add (entered_regionview);
5074 /* just use the selected regions */
5076 rs = selection->regions;
5078 /* if the entered regionview wasn't selected and we allow this sort of thing,
5082 if (allow_entered && entered_regionview && !selection->selected (entered_regionview)) {
5083 rs.add (entered_regionview);
5090 Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<RegionView*>& regions)
5093 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5095 RouteTimeAxisView* tatv;
5097 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
5099 boost::shared_ptr<Playlist> pl;
5100 vector<boost::shared_ptr<Region> > results;
5102 boost::shared_ptr<Diskstream> ds;
5104 if ((ds = tatv->get_diskstream()) == 0) {
5109 if ((pl = (ds->playlist())) != 0) {
5110 pl->get_region_list_equivalent_regions (region, results);
5113 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
5114 if ((marv = tatv->view()->find_view (*ir)) != 0) {
5115 regions.push_back (marv);
5124 Editor::show_rhythm_ferret ()
5126 if (rhythm_ferret == 0) {
5127 rhythm_ferret = new RhythmFerret(*this);
5130 rhythm_ferret->set_session (session);
5131 rhythm_ferret->show ();
5132 rhythm_ferret->present ();
5136 Editor::show_bundle_manager ()
5138 if (_bundle_manager == 0) {
5139 _bundle_manager = new BundleManager (*session);
5142 _bundle_manager->show ();
5146 Editor::show_global_port_matrix (ARDOUR::DataType t)
5148 if (_global_port_matrix[t] == 0) {
5149 _global_port_matrix[t] = new GlobalPortMatrixWindow (*session, t);
5152 _global_port_matrix[t]->show ();
5156 Editor::first_idle ()
5158 MessageDialog* dialog = 0;
5160 if (track_views.size() > 1) {
5161 dialog = new MessageDialog (*this,
5162 _("Please wait while Ardour loads visual data"),
5167 ARDOUR_UI::instance()->flush_pending ();
5170 for (TrackViewList::iterator t = track_views.begin(); t != track_views.end(); ++t) {
5174 // first idle adds route children (automation tracks), so we need to redisplay here
5175 redisplay_route_list();
5183 Editor::start_resize_line_ops ()
5186 old_resize_line_y = -1;
5188 need_resize_line = true;
5193 Editor::end_resize_line_ops ()
5196 need_resize_line = false;
5198 if (old_resize_line_y >= 0) {
5199 Gdk::Rectangle r (0, old_resize_line_y, (int) _canvas_width, 3);
5200 Glib::RefPtr<Gdk::Window> win = get_window();
5201 cerr << "Final invalidation at " << old_resize_line_y << endl;
5202 win->invalidate_rect (r, false);
5208 Editor::queue_draw_resize_line (int at)
5211 Glib::RefPtr<Gdk::Window> win = get_window();
5215 if (win && _canvas_width) {
5217 int controls_width = controls_layout.get_width();
5220 controls_layout.get_window()->get_origin (xroot, discard);
5222 if (old_resize_line_y >= 0) {
5224 /* redraw where it used to be */
5227 Gdk::Rectangle r (0, old_resize_line_y - 1, controls_width + (int) _canvas_width, 3);
5228 win->invalidate_rect (r, true);
5229 cerr << "invalidate " << xroot << "," << old_resize_line_y - 1 << ' '
5230 << controls_width + _canvas_width << " x 3\n";
5233 /* draw where it is */
5235 Gdk::Rectangle r (0, at - 1, controls_width + (int) _canvas_width, 3);
5236 win->invalidate_rect (r, true);
5242 Editor::on_expose_event (GdkEventExpose* ev)
5244 /* cerr << "+++ editor expose "
5245 << ev->area.x << ',' << ev->area.y
5247 << ev->area.width << " x " << ev->area.height
5248 << " need reize ? " << need_resize_line
5251 bool ret = Window::on_expose_event (ev);
5254 if (need_resize_line) {
5256 int xroot, yroot, discard;
5259 /* Our root coordinates for drawing the line will be the left edge
5260 of the track controls, and the upper left edge of our own window.
5263 get_window()->get_origin (discard, yroot);
5264 controls_layout.get_window()->get_origin (xroot, discard);
5265 controls_width = controls_layout.get_width();
5268 GdkRectangle intersection;
5271 lr.y = resize_line_y;
5272 lr.width = controls_width + (int) _canvas_width;
5275 if (gdk_rectangle_intersect (&lr, &ev->area, &intersection)) {
5277 Glib::RefPtr<Gtk::Style> style (get_style());
5278 Glib::RefPtr<Gdk::GC> black_gc (style->get_black_gc ());
5279 Glib::RefPtr<Gdk::GC> gc = wrap (black_gc->gobj_copy(), false);
5281 /* draw on root window */
5283 GdkWindow* win = gdk_get_default_root_window();
5285 gc->set_subwindow (Gdk::INCLUDE_INFERIORS);
5286 gc->set_line_attributes (3, Gdk::LINE_SOLID,
5290 gdk_draw_line (win, gc->gobj(),
5293 (int) _canvas_width + controls_width,
5296 cerr << "drew line @ " << xroot << ", " << yroot + resize_line_y
5297 << " to " << xroot + (int) _canvas_width + controls_width
5298 << ", " << yroot + resize_line_y
5301 old_resize_line_y = resize_line_y;
5302 cerr << "NEXT EXPOSE SHOULD BE AT " << old_resize_line_y << endl;
5304 cerr << "no intersect with "
5305 << lr.x << ',' << lr.y
5307 << lr.width << " x " << lr.height
5312 //cerr << "--- editor expose\n";
5319 _idle_resizer (gpointer arg)
5321 return ((Editor*)arg)->idle_resize ();
5325 Editor::add_to_idle_resize (TimeAxisView* view, uint32_t h)
5327 if (resize_idle_id < 0) {
5328 resize_idle_id = g_idle_add (_idle_resizer, this);
5331 resize_idle_target = h;
5333 pending_resizes.push_back (view);
5335 if (selection->selected (view) && !selection->tracks.empty()) {
5336 pending_resizes.insert (pending_resizes.end(), selection->tracks.begin(), selection->tracks.end());
5341 Editor::idle_resize ()
5343 for (vector<TimeAxisView*>::iterator i = pending_resizes.begin(); i != pending_resizes.end(); ++i) {
5344 (*i)->idle_resize (resize_idle_target);
5346 pending_resizes.clear();
5348 resize_idle_id = -1;
5355 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::located));
5357 _pending_locate_request = false;
5361 Editor::region_view_added (RegionView *)
5363 _summary->set_dirty ();
5367 Editor::streamview_height_changed ()
5369 _summary->set_dirty ();