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.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
492 time_button_event_box.add (time_button_vbox);
493 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
494 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
496 /* these enable us to have a dedicated window (for cursor setting, etc.)
497 for the canvas areas.
500 track_canvas_event_box.add (*track_canvas);
502 time_canvas_event_box.add (time_canvas_vbox);
503 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
505 edit_packer.set_col_spacings (0);
506 edit_packer.set_row_spacings (0);
507 edit_packer.set_homogeneous (false);
508 edit_packer.set_border_width (0);
509 edit_packer.set_name ("EditorWindow");
511 edit_packer.attach (zoom_vbox, 0, 1, 0, 2, SHRINK, FILL, 0, 0);
512 /* labels for the rulers */
513 edit_packer.attach (ruler_label_event_box, 1, 2, 0, 1, FILL, SHRINK, 0, 0);
514 /* labels for the marker "tracks" */
515 edit_packer.attach (time_button_event_box, 1, 2, 1, 2, FILL, SHRINK, 0, 0);
517 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
519 edit_packer.attach (controls_layout, 0, 2, 2, 3, FILL, FILL|EXPAND, 0, 0);
521 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 3, FILL|EXPAND, FILL|EXPAND, 0, 0);
522 /* summary widget at bottom */
523 edit_packer.attach (*_summary, 0, 3, 3, 4, FILL|EXPAND, SHRINK, 0, 0);
525 bottom_hbox.set_border_width (2);
526 bottom_hbox.set_spacing (3);
528 route_display_model = ListStore::create(route_display_columns);
529 route_list_display.set_model (route_display_model);
530 route_list_display.append_column (_("Show"), route_display_columns.visible);
531 route_list_display.append_column (_("Name"), route_display_columns.text);
532 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
533 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
534 route_list_display.set_headers_visible (true);
535 route_list_display.set_name ("TrackListDisplay");
536 route_list_display.get_selection()->set_mode (SELECTION_SINGLE);
537 route_list_display.set_reorderable (true);
538 route_list_display.set_size_request (100,-1);
539 route_list_display.add_object_drag (route_display_columns.route.index(), "routes");
541 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
542 route_list_visible_cell->property_activatable() = true;
543 route_list_visible_cell->property_radio() = false;
545 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
546 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
547 route_display_model->signal_rows_reordered().connect (mem_fun (*this, &Editor::route_list_reordered));
549 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
551 route_list_scroller.add (route_list_display);
552 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
554 group_model = ListStore::create(group_columns);
555 edit_group_display.set_model (group_model);
556 edit_group_display.append_column (_("Name"), group_columns.text);
557 edit_group_display.append_column (_("Active"), group_columns.is_active);
558 edit_group_display.append_column (_("Show"), group_columns.is_visible);
559 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
560 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
561 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
562 edit_group_display.get_column (0)->set_expand (true);
563 edit_group_display.get_column (1)->set_expand (false);
564 edit_group_display.get_column (2)->set_expand (false);
565 edit_group_display.set_headers_visible (true);
567 /* name is directly editable */
569 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
570 name_cell->property_editable() = true;
571 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
573 /* use checkbox for the active + visible columns */
575 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
576 active_cell->property_activatable() = true;
577 active_cell->property_radio() = false;
579 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
580 active_cell->property_activatable() = true;
581 active_cell->property_radio() = false;
583 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
585 edit_group_display.set_name ("EditGroupList");
586 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
587 edit_group_display.set_headers_visible (true);
588 edit_group_display.set_reorderable (false);
589 edit_group_display.set_rules_hint (true);
590 edit_group_display.set_size_request (75, -1);
592 edit_group_display_scroller.add (edit_group_display);
593 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
595 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
597 VBox* edit_group_display_packer = manage (new VBox());
598 HBox* edit_group_display_button_box = manage (new HBox());
599 edit_group_display_button_box->set_homogeneous (true);
601 Button* edit_group_add_button = manage (new Button ());
602 Button* edit_group_remove_button = manage (new Button ());
606 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
608 edit_group_add_button->add (*w);
610 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
612 edit_group_remove_button->add (*w);
614 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
615 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
617 edit_group_display_button_box->pack_start (*edit_group_add_button);
618 edit_group_display_button_box->pack_start (*edit_group_remove_button);
620 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
621 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
623 region_list_display.set_size_request (100, -1);
624 region_list_display.set_name ("RegionListDisplay");
625 /* Try to prevent single mouse presses from initiating edits.
626 This relies on a hack in gtktreeview.c:gtk_treeview_button_press()
628 region_list_display.set_data ("mouse-edits-require-mod1", (gpointer) 0x1);
630 region_list_model = TreeStore::create (region_list_columns);
631 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
632 region_list_model->set_sort_column (0, SORT_ASCENDING);
634 region_list_display.set_model (region_list_model);
635 region_list_display.append_column (_("Regions"), region_list_columns.name);
636 region_list_display.append_column (_("Start"), region_list_columns.start);
637 region_list_display.append_column (_("End"), region_list_columns.end);
638 region_list_display.append_column (_("Length"), region_list_columns.length);
639 region_list_display.append_column (_("Sync"), region_list_columns.sync);
640 region_list_display.append_column (_("Fade In"), region_list_columns.fadein);
641 region_list_display.append_column (_("Fade Out"), region_list_columns.fadeout);
642 region_list_display.append_column (_("L"), region_list_columns.locked);
643 region_list_display.append_column (_("G"), region_list_columns.glued);
644 region_list_display.append_column (_("M"), region_list_columns.muted);
645 region_list_display.append_column (_("O"), region_list_columns.opaque);
646 region_list_display.append_column (_("Used"), region_list_columns.used);
647 region_list_display.append_column (_("Path"), region_list_columns.path);
648 region_list_display.set_headers_visible (true);
649 //region_list_display.set_grid_lines (TREE_VIEW_GRID_LINES_BOTH);
651 CellRendererText* region_name_cell = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
652 region_name_cell->property_editable() = true;
653 region_name_cell->signal_edited().connect (mem_fun (*this, &Editor::region_name_edit));
655 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
657 TreeViewColumn* tv_col = region_list_display.get_column(0);
658 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
659 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
660 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
662 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
663 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
665 /* setup DnD handling */
667 list<TargetEntry> region_list_target_table;
669 region_list_target_table.push_back (TargetEntry ("text/plain"));
670 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
671 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
673 region_list_display.add_drop_targets (region_list_target_table);
674 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
676 region_list_scroller.add (region_list_display);
677 region_list_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
679 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
680 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
681 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
682 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
683 region_list_change_connection = region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
684 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
686 //ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (mem_fun(*this, &Editor::redisplay_regions));
687 ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (mem_fun(*this, &Editor::update_all_region_rows));
688 ARDOUR::Region::RegionPropertyChanged.connect (mem_fun(*this, &Editor::update_region_row));
690 named_selection_scroller.add (named_selection_display);
691 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
693 named_selection_model = TreeStore::create (named_selection_columns);
694 named_selection_display.set_model (named_selection_model);
695 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
696 named_selection_display.set_headers_visible (false);
697 named_selection_display.set_size_request (100, -1);
698 named_selection_display.set_name ("NamedSelectionDisplay");
700 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
701 named_selection_display.set_size_request (100, -1);
702 named_selection_display.signal_button_release_event().connect (mem_fun(*this, &Editor::named_selection_display_button_release), false);
703 named_selection_display.signal_key_release_event().connect (mem_fun(*this, &Editor::named_selection_display_key_release), false);
704 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
708 snapshot_display_model = ListStore::create (snapshot_display_columns);
709 snapshot_display.set_model (snapshot_display_model);
710 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
711 snapshot_display.set_name ("SnapshotDisplay");
712 snapshot_display.set_size_request (75, -1);
713 snapshot_display.set_headers_visible (false);
714 snapshot_display.set_reorderable (false);
715 snapshot_display_scroller.add (snapshot_display);
716 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
718 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
719 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
723 nlabel = manage (new Label (_("Regions")));
724 nlabel->set_angle (-90);
725 the_notebook.append_page (region_list_scroller, *nlabel);
726 nlabel = manage (new Label (_("Tracks/Busses")));
727 nlabel->set_angle (-90);
728 the_notebook.append_page (route_list_scroller, *nlabel);
729 nlabel = manage (new Label (_("Snapshots")));
730 nlabel->set_angle (-90);
731 the_notebook.append_page (snapshot_display_scroller, *nlabel);
732 nlabel = manage (new Label (_("Edit Groups")));
733 nlabel->set_angle (-90);
734 the_notebook.append_page (*edit_group_display_packer, *nlabel);
736 if (!Profile->get_sae()) {
737 nlabel = manage (new Label (_("Chunks")));
738 nlabel->set_angle (-90);
739 the_notebook.append_page (named_selection_scroller, *nlabel);
742 the_notebook.set_show_tabs (true);
743 the_notebook.set_scrollable (true);
744 the_notebook.popup_enable ();
745 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
746 the_notebook.show_all ();
748 post_maximal_editor_width = 0;
749 post_maximal_pane_position = 0;
750 edit_pane.pack1 (edit_packer, true, true);
751 edit_pane.pack2 (the_notebook, false, true);
753 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
755 top_hbox.pack_start (toolbar_frame, false, true);
756 top_hbox.pack_start (midi_toolbar_frame, false, true);
758 HBox *hbox = manage (new HBox);
759 hbox->pack_start (edit_pane, true, true);
761 global_vpacker.pack_start (top_hbox, false, false);
762 global_vpacker.pack_start (*hbox, true, true);
764 global_hpacker.pack_start (global_vpacker, true, true);
766 set_name ("EditorWindow");
767 add_accel_group (ActionManager::ui_manager->get_accel_group());
769 status_bar_hpacker.show ();
771 vpacker.pack_end (status_bar_hpacker, false, false);
772 vpacker.pack_end (global_hpacker, true, true);
774 /* register actions now so that set_state() can find them and set toggles/checks etc */
778 snap_type = SnapToBeat;
779 set_snap_to (snap_type);
781 set_snap_mode (snap_mode);
782 set_edit_point_preference (EditAtMouse, true);
784 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
787 _playlist_selector = new PlaylistSelector();
788 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
790 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
794 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
795 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
797 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
798 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
800 nudge_forward_button.set_name ("TransportButton");
801 nudge_backward_button.set_name ("TransportButton");
803 fade_context_menu.set_name ("ArdourContextMenu");
805 /* icons, titles, WM stuff */
807 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
808 Glib::RefPtr<Gdk::Pixbuf> icon;
810 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
811 window_icons.push_back (icon);
813 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
814 window_icons.push_back (icon);
816 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
817 window_icons.push_back (icon);
819 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
820 window_icons.push_back (icon);
822 if (!window_icons.empty()) {
823 set_icon_list (window_icons);
824 set_default_icon_list (window_icons);
827 WindowTitle title(Glib::get_application_name());
828 title += _("Editor");
829 set_title (title.get_string());
830 set_wmclass (X_("ardour_editor"), "Ardour");
833 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
835 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
836 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
838 /* allow external control surfaces/protocols to do various things */
840 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
841 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
842 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
843 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
844 BasicUI::AccessAction.connect (mem_fun (*this, &Editor::access_action));
846 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
847 Route::SyncOrderKeys.connect (mem_fun (*this, &Editor::sync_order_keys));
856 if(image_socket_listener) {
857 if(image_socket_listener->is_connected())
859 image_socket_listener->close_connection() ;
862 delete image_socket_listener ;
863 image_socket_listener = 0 ;
872 Editor::add_toplevel_controls (Container& cont)
874 vpacker.pack_start (cont, false, false);
879 Editor::catch_vanishing_regionview (RegionView *rv)
881 /* note: the selection will take care of the vanishing
882 audioregionview by itself.
885 if (_drag && rv->get_canvas_group() == _drag->item() && !_drag->ending()) {
891 if (clicked_regionview == rv) {
892 clicked_regionview = 0;
895 if (entered_regionview == rv) {
896 set_entered_regionview (0);
901 Editor::set_entered_regionview (RegionView* rv)
903 if (rv == entered_regionview) {
907 if (entered_regionview) {
908 entered_regionview->exited ();
911 if ((entered_regionview = rv) != 0) {
912 entered_regionview->entered ();
917 Editor::set_entered_track (TimeAxisView* tav)
920 entered_track->exited ();
923 if ((entered_track = tav) != 0) {
924 entered_track->entered ();
929 Editor::show_window ()
931 if (! is_visible ()) {
934 /* re-hide editor list if necessary */
935 editor_list_button_toggled ();
937 /* re-hide summary widget if necessary */
938 parameter_changed ("show-summary");
940 /* now reset all audio_time_axis heights, because widgets might need
946 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
947 tv = (static_cast<TimeAxisView*>(*i));
956 Editor::instant_save ()
958 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
963 session->add_instant_xml(get_state());
965 Config->add_instant_xml(get_state());
970 Editor::edit_point_clock_changed()
972 if (_dragging_edit_point) {
976 if (selection->markers.empty()) {
981 Location* loc = find_location_from_marker (selection->markers.front(), ignored);
987 loc->move_to (edit_point_clock.current_time());
991 Editor::zoom_adjustment_changed ()
997 double fpu = zoom_range_clock.current_duration() / _canvas_width;
1001 zoom_range_clock.set ((nframes64_t) floor (fpu * _canvas_width));
1002 } else if (fpu > session->current_end_frame() / _canvas_width) {
1003 fpu = session->current_end_frame() / _canvas_width;
1004 zoom_range_clock.set ((nframes64_t) floor (fpu * _canvas_width));
1007 temporal_zoom (fpu);
1011 Editor::control_scroll (float fraction)
1013 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
1019 double step = fraction * current_page_frames();
1022 _control_scroll_target is an optional<T>
1024 it acts like a pointer to an nframes64_t, with
1025 a operator conversion to boolean to check
1026 that it has a value could possibly use
1027 playhead_cursor->current_frame to store the
1028 value and a boolean in the class to know
1029 when it's out of date
1032 if (!_control_scroll_target) {
1033 _control_scroll_target = session->transport_frame();
1034 _dragging_playhead = true;
1037 if ((fraction < 0.0f) && (*_control_scroll_target < (nframes64_t) fabs(step))) {
1038 *_control_scroll_target = 0;
1039 } else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
1040 *_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
1042 *_control_scroll_target += (nframes64_t) floor (step);
1045 /* move visuals, we'll catch up with it later */
1047 playhead_cursor->set_position (*_control_scroll_target);
1048 UpdateAllTransportClocks (*_control_scroll_target);
1050 if (*_control_scroll_target > (current_page_frames() / 2)) {
1051 /* try to center PH in window */
1052 reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
1058 Now we do a timeout to actually bring the session to the right place
1059 according to the playhead. This is to avoid reading disk buffers on every
1060 call to control_scroll, which is driven by ScrollTimeline and therefore
1061 probably by a control surface wheel which can generate lots of events.
1063 /* cancel the existing timeout */
1065 control_scroll_connection.disconnect ();
1067 /* add the next timeout */
1069 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), *_control_scroll_target), 250);
1073 Editor::deferred_control_scroll (nframes64_t target)
1075 session->request_locate (*_control_scroll_target, session->transport_rolling());
1076 // reset for next stream
1077 _control_scroll_target = boost::none;
1078 _dragging_playhead = false;
1083 Editor::access_action (std::string action_group, std::string action_item)
1089 ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::access_action), action_group, action_item));
1092 act = ActionManager::get_action( action_group.c_str(), action_item.c_str() );
1102 Editor::on_realize ()
1104 Window::on_realize ();
1109 Editor::start_scrolling ()
1111 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1112 (mem_fun(*this, &Editor::update_current_screen));
1117 Editor::stop_scrolling ()
1119 scroll_connection.disconnect ();
1123 Editor::map_position_change (nframes64_t frame)
1125 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1127 if (session == 0 || !_follow_playhead) {
1131 center_screen (frame);
1132 playhead_cursor->set_position (frame);
1136 Editor::center_screen (nframes64_t frame)
1138 double page = _canvas_width * frames_per_unit;
1140 /* if we're off the page, then scroll.
1143 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1144 center_screen_internal (frame, page);
1149 Editor::center_screen_internal (nframes64_t frame, float page)
1154 frame -= (nframes64_t) page;
1159 reset_x_origin (frame);
1163 Editor::handle_new_duration ()
1169 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1170 nframes64_t new_end = session->current_end_frame() + (nframes64_t) floorf (current_page_frames() * 0.10f);
1172 horizontal_adjustment.set_upper (new_end / frames_per_unit);
1173 horizontal_adjustment.set_page_size (current_page_frames()/frames_per_unit);
1175 if (horizontal_adjustment.get_value() + _canvas_width > horizontal_adjustment.get_upper()) {
1176 horizontal_adjustment.set_value (horizontal_adjustment.get_upper() - _canvas_width);
1178 //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
1182 Editor::update_title_s (const string & snap_name)
1184 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1190 Editor::update_title ()
1192 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1195 bool dirty = session->dirty();
1197 string session_name;
1199 if (session->snap_name() != session->name()) {
1200 session_name = session->snap_name();
1202 session_name = session->name();
1206 session_name = "*" + session_name;
1209 WindowTitle title(session_name);
1210 title += Glib::get_application_name();
1211 set_title (title.get_string());
1216 Editor::connect_to_session (Session *t)
1220 compute_fixed_ruler_scale ();
1222 /* there are never any selected regions at startup */
1224 sensitize_the_right_region_actions (false);
1226 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1229 /* catch up with the playhead */
1231 session->request_locate (playhead_cursor->current_frame);
1235 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1236 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1238 /* These signals can all be emitted by a non-GUI thread. Therefore the
1239 handlers for them must not attempt to directly interact with the GUI,
1240 but use Gtkmm2ext::UI::instance()->call_slot();
1243 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1244 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1245 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1246 session_connections.push_back (session->RegionsAdded.connect (mem_fun(*this, &Editor::handle_new_regions)));
1247 session_connections.push_back (session->RegionRemoved.connect (mem_fun(*this, &Editor::handle_region_removed)));
1248 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1249 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1250 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1251 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1252 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1253 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1254 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1255 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1256 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1258 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1260 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1262 session_connections.push_back (session->Located.connect (mem_fun (*this, &Editor::located)));
1263 session_connections.push_back (session->config.ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed)));
1265 edit_groups_changed ();
1267 edit_point_clock.set_mode(AudioClock::BBT);
1268 edit_point_clock.set_session (session);
1269 zoom_range_clock.set_session (session);
1270 _playlist_selector->set_session (session);
1271 nudge_clock.set_session (session);
1272 if (Profile->get_sae()) {
1277 nframes_t pos = session->tempo_map().bbt_duration_at (0, bbt, 1);
1278 nudge_clock.set_mode(AudioClock::BBT);
1279 nudge_clock.set (pos, true, 0, AudioClock::BBT);
1282 nudge_clock.set (session->frame_rate() * 5, true, 0, AudioClock::SMPTE); // default of 5 seconds
1285 playhead_cursor->canvas_item.show ();
1287 if (rhythm_ferret) {
1288 rhythm_ferret->set_session (session);
1291 if (analysis_window != 0)
1292 analysis_window->set_session (session);
1294 Location* loc = session->locations()->auto_loop_location();
1296 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1297 if (loc->start() == loc->end()) {
1298 loc->set_end (loc->start() + 1);
1300 session->locations()->add (loc, false);
1301 session->set_auto_loop_location (loc);
1304 loc->set_name (_("Loop"));
1307 loc = session->locations()->auto_punch_location();
1309 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1310 if (loc->start() == loc->end()) {
1311 loc->set_end (loc->start() + 1);
1313 session->locations()->add (loc, false);
1314 session->set_auto_punch_location (loc);
1317 loc->set_name (_("Punch"));
1320 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1321 session->config.map_parameters (mem_fun (*this, &Editor::parameter_changed));
1323 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1325 refresh_location_display ();
1326 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1327 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1328 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1329 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1330 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1333 sfbrowser->set_session (session);
1336 handle_new_duration ();
1338 redisplay_regions ();
1339 redisplay_named_selections ();
1340 redisplay_snapshots ();
1342 restore_ruler_visibility ();
1343 //tempo_map_changed (Change (0));
1344 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1346 initial_route_list_display ();
1348 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1349 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1354 /* don't show master bus in a new session */
1356 if (ARDOUR_UI::instance()->session_is_new ()) {
1358 TreeModel::Children rows = route_display_model->children();
1359 TreeModel::Children::iterator i;
1361 no_route_list_redisplay = true;
1363 for (i = rows.begin(); i != rows.end(); ++i) {
1364 TimeAxisView *tv = (*i)[route_display_columns.tv];
1365 RouteTimeAxisView *rtv;
1367 if ((rtv = dynamic_cast<RouteTimeAxisView*>(tv)) != 0) {
1368 if (rtv->route()->is_master()) {
1369 route_list_display.get_selection()->unselect (i);
1374 no_route_list_redisplay = false;
1375 redisplay_route_list ();
1378 switch (snap_type) {
1379 case SnapToRegionStart:
1380 case SnapToRegionEnd:
1381 case SnapToRegionSync:
1382 case SnapToRegionBoundary:
1383 build_region_boundary_cache ();
1390 /* register for undo history */
1391 session->register_with_memento_command_factory(_id, this);
1393 _summary->set_session (session);
1399 Editor::build_cursors ()
1401 using namespace Gdk;
1403 Gdk::Color mbg ("#000000" ); /* Black */
1404 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1407 RefPtr<Bitmap> source, mask;
1408 source = Bitmap::create (mag_bits, mag_width, mag_height);
1409 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1410 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1413 Gdk::Color fbg ("#ffffff" );
1414 Gdk::Color ffg ("#000000" );
1417 RefPtr<Bitmap> source, mask;
1419 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1420 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1421 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1425 RefPtr<Bitmap> source, mask;
1426 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1427 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1428 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1432 RefPtr<Bitmap> bits;
1433 char pix[4] = { 0, 0, 0, 0 };
1434 bits = Bitmap::create (pix, 2, 2);
1436 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1440 RefPtr<Bitmap> bits;
1441 char pix[4] = { 0, 0, 0, 0 };
1442 bits = Bitmap::create (pix, 2, 2);
1444 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1448 grabber_cursor = new Gdk::Cursor (HAND2);
1451 Glib::RefPtr<Gdk::Pixbuf> grabber_edit_point_pixbuf (::get_icon ("grabber_edit_point"));
1452 grabber_edit_point_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_edit_point_pixbuf, 5, 17);
1455 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1456 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1457 selector_cursor = new Gdk::Cursor (XTERM);
1458 time_fx_cursor = new Gdk::Cursor (SIZING);
1459 wait_cursor = new Gdk::Cursor (WATCH);
1460 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1461 midi_pencil_cursor = new Gdk::Cursor (PENCIL);
1462 midi_select_cursor = new Gdk::Cursor (CENTER_PTR);
1463 midi_resize_cursor = new Gdk::Cursor (SIZING);
1464 midi_erase_cursor = new Gdk::Cursor (DRAPED_BOX);
1467 /** Pop up a context menu for when the user clicks on a fade in or fade out */
1469 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1471 using namespace Menu_Helpers;
1472 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1475 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1479 MenuList& items (fade_context_menu.items());
1483 switch (item_type) {
1485 case FadeInHandleItem:
1486 if (arv->audio_region()->fade_in_active()) {
1487 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_in_active), false)));
1489 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_in_active), true)));
1492 items.push_back (SeparatorElem());
1494 if (Profile->get_sae()) {
1495 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1496 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1498 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1499 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1500 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
1501 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
1502 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
1508 case FadeOutHandleItem:
1509 if (arv->audio_region()->fade_out_active()) {
1510 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_out_active), false)));
1512 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_out_active), true)));
1515 items.push_back (SeparatorElem());
1517 if (Profile->get_sae()) {
1518 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1519 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1521 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1522 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1523 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
1524 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
1525 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
1531 fatal << _("programming error: ")
1532 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1537 fade_context_menu.popup (button, time);
1541 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes64_t frame)
1543 using namespace Menu_Helpers;
1544 Menu* (Editor::*build_menu_function)(nframes64_t);
1547 switch (item_type) {
1549 case RegionViewName:
1550 case RegionViewNameHighlight:
1551 if (with_selection) {
1552 build_menu_function = &Editor::build_track_selection_context_menu;
1554 build_menu_function = &Editor::build_track_region_context_menu;
1559 if (with_selection) {
1560 build_menu_function = &Editor::build_track_selection_context_menu;
1562 build_menu_function = &Editor::build_track_context_menu;
1566 case CrossfadeViewItem:
1567 build_menu_function = &Editor::build_track_crossfade_context_menu;
1571 if (clicked_routeview->get_diskstream()) {
1572 build_menu_function = &Editor::build_track_context_menu;
1574 build_menu_function = &Editor::build_track_bus_context_menu;
1579 /* probably shouldn't happen but if it does, we don't care */
1583 menu = (this->*build_menu_function)(frame);
1584 menu->set_name ("ArdourContextMenu");
1586 /* now handle specific situations */
1588 switch (item_type) {
1590 case RegionViewName:
1591 case RegionViewNameHighlight:
1592 if (!with_selection) {
1593 if (region_edit_menu_split_item) {
1594 if (clicked_regionview && clicked_regionview->region()->covers (get_preferred_edit_position())) {
1595 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, true);
1597 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, false);
1601 if (region_edit_menu_split_multichannel_item) {
1602 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1603 // GTK2FIX find the action, change its sensitivity
1604 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1606 // GTK2FIX see above
1607 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1616 case CrossfadeViewItem:
1623 /* probably shouldn't happen but if it does, we don't care */
1627 if (item_type != SelectionItem && clicked_routeview && clicked_routeview->audio_track()) {
1629 /* Bounce to disk */
1631 using namespace Menu_Helpers;
1632 MenuList& edit_items = menu->items();
1634 edit_items.push_back (SeparatorElem());
1636 switch (clicked_routeview->audio_track()->freeze_state()) {
1637 case AudioTrack::NoFreeze:
1638 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1641 case AudioTrack::Frozen:
1642 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1645 case AudioTrack::UnFrozen:
1646 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1652 if (item_type == StreamItem && clicked_routeview) {
1653 clicked_routeview->build_underlay_menu(menu);
1656 menu->popup (button, time);
1660 Editor::build_track_context_menu (nframes64_t ignored)
1662 using namespace Menu_Helpers;
1664 MenuList& edit_items = track_context_menu.items();
1667 add_dstream_context_items (edit_items);
1668 return &track_context_menu;
1672 Editor::build_track_bus_context_menu (nframes64_t ignored)
1674 using namespace Menu_Helpers;
1676 MenuList& edit_items = track_context_menu.items();
1679 add_bus_context_items (edit_items);
1680 return &track_context_menu;
1684 Editor::build_track_region_context_menu (nframes64_t frame)
1686 using namespace Menu_Helpers;
1687 MenuList& edit_items = track_region_context_menu.items();
1690 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (clicked_axisview);
1693 boost::shared_ptr<Diskstream> ds;
1694 boost::shared_ptr<Playlist> pl;
1696 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
1697 Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)frame * ds->speed()));
1699 if (selection->regions.size() > 1) {
1700 // there's already a multiple selection: just add a
1701 // single region context menu that will act on all
1703 boost::shared_ptr<Region> dummy_region; // = NULL
1704 add_region_context_items (rtv->view(), dummy_region, edit_items);
1706 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1707 add_region_context_items (rtv->view(), (*i), edit_items);
1715 add_dstream_context_items (edit_items);
1717 return &track_region_context_menu;
1721 Editor::build_track_crossfade_context_menu (nframes64_t frame)
1723 using namespace Menu_Helpers;
1724 MenuList& edit_items = track_crossfade_context_menu.items();
1725 edit_items.clear ();
1727 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_axisview);
1730 boost::shared_ptr<Diskstream> ds;
1731 boost::shared_ptr<Playlist> pl;
1732 boost::shared_ptr<AudioPlaylist> apl;
1734 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1736 Playlist::RegionList* regions = pl->regions_at (frame);
1737 AudioPlaylist::Crossfades xfades;
1739 apl->crossfades_at (frame, xfades);
1741 bool many = xfades.size() > 1;
1743 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1744 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1747 if (selection->regions.size() > 1) {
1748 // there's already a multiple selection: just add a
1749 // single region context menu that will act on all
1751 boost::shared_ptr<Region> dummy_region; // = NULL
1752 add_region_context_items (atv->audio_view(), dummy_region, edit_items);
1754 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1755 add_region_context_items (atv->audio_view(), (*i), edit_items);
1762 add_dstream_context_items (edit_items);
1764 return &track_crossfade_context_menu;
1768 Editor::analyze_region_selection()
1770 if (analysis_window == 0) {
1771 analysis_window = new AnalysisWindow();
1774 analysis_window->set_session(session);
1776 analysis_window->show_all();
1779 analysis_window->set_regionmode();
1780 analysis_window->analyze();
1782 analysis_window->present();
1786 Editor::analyze_range_selection()
1788 if (analysis_window == 0) {
1789 analysis_window = new AnalysisWindow();
1792 analysis_window->set_session(session);
1794 analysis_window->show_all();
1797 analysis_window->set_rangemode();
1798 analysis_window->analyze();
1800 analysis_window->present();
1804 Editor::build_track_selection_context_menu (nframes64_t ignored)
1806 using namespace Menu_Helpers;
1807 MenuList& edit_items = track_selection_context_menu.items();
1808 edit_items.clear ();
1810 add_selection_context_items (edit_items);
1811 // edit_items.push_back (SeparatorElem());
1812 // add_dstream_context_items (edit_items);
1814 return &track_selection_context_menu;
1817 /** Add context menu items relevant to crossfades.
1818 * @param edit_items List to add the items to.
1821 Editor::add_crossfade_context_items (AudioStreamView* view, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1823 using namespace Menu_Helpers;
1824 Menu *xfade_menu = manage (new Menu);
1825 MenuList& items = xfade_menu->items();
1826 xfade_menu->set_name ("ArdourContextMenu");
1829 if (xfade->active()) {
1835 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1836 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1838 if (xfade->can_follow_overlap()) {
1840 if (xfade->following_overlap()) {
1841 str = _("Convert to short");
1843 str = _("Convert to full");
1846 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1850 str = xfade->out()->name();
1852 str += xfade->in()->name();
1854 str = _("Crossfade");
1857 edit_items.push_back (MenuElem (str, *xfade_menu));
1858 edit_items.push_back (SeparatorElem());
1862 Editor::xfade_edit_left_region ()
1864 if (clicked_crossfadeview) {
1865 clicked_crossfadeview->left_view.show_region_editor ();
1870 Editor::xfade_edit_right_region ()
1872 if (clicked_crossfadeview) {
1873 clicked_crossfadeview->right_view.show_region_editor ();
1877 /** Add an element to a menu, settings its sensitivity.
1878 * @param m Menu to add to.
1879 * @param e Element to add.
1880 * @param s true to make sensitive, false to make insensitive
1883 Editor::add_item_with_sensitivity (Menu_Helpers::MenuList& m, Menu_Helpers::MenuElem e, bool s) const
1887 m.back().set_sensitive (false);
1892 Editor::add_region_context_items (StreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1894 using namespace Menu_Helpers;
1895 Gtk::MenuItem* foo_item;
1896 Menu *region_menu = manage (new Menu);
1897 MenuList& items = region_menu->items();
1898 region_menu->set_name ("ArdourContextMenu");
1900 boost::shared_ptr<AudioRegion> ar;
1901 boost::shared_ptr<MidiRegion> mr;
1904 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1905 mr = boost::dynamic_pointer_cast<MidiRegion> (region);
1907 /* when this particular menu pops up, make the relevant region
1911 region_menu->signal_map_event().connect (
1912 bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region>(region)));
1914 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &Editor::rename_region)));
1915 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1918 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1919 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1920 items.push_back (SeparatorElem());
1921 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_point)));
1922 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1923 items.push_back (SeparatorElem());
1925 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::play_selected_region)));
1926 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1927 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1930 items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_region_selection)));
1933 items.push_back (SeparatorElem());
1935 sigc::connection fooc;
1936 boost::shared_ptr<Region> region_to_check;
1939 region_to_check = region;
1941 region_to_check = selection->regions.front()->region();
1944 items.push_back (CheckMenuElem (_("Lock")));
1945 CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1946 if (region_to_check->locked()) {
1947 region_lock_item->set_active();
1949 region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
1951 items.push_back (CheckMenuElem (_("Glue to Bars&Beats")));
1952 CheckMenuItem* bbt_glue_item = static_cast<CheckMenuItem*>(&items.back());
1954 switch (region_to_check->positional_lock_style()) {
1955 case Region::MusicTime:
1956 bbt_glue_item->set_active (true);
1959 bbt_glue_item->set_active (false);
1963 bbt_glue_item->signal_activate().connect (bind (mem_fun (*this, &Editor::set_region_lock_style), Region::MusicTime));
1965 items.push_back (CheckMenuElem (_("Mute")));
1966 CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1967 fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
1968 if (region_to_check->muted()) {
1970 region_mute_item->set_active();
1974 if (!Profile->get_sae()) {
1975 items.push_back (CheckMenuElem (_("Opaque")));
1976 CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1977 fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
1978 if (region_to_check->opaque()) {
1980 region_opaque_item->set_active();
1985 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1986 if (region_to_check->at_natural_position()) {
1987 items.back().set_sensitive (false);
1990 items.push_back (SeparatorElem());
1994 RegionView* rv = sv->find_view (ar);
1995 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1997 if (!Profile->get_sae()) {
1998 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
2000 items.push_back (CheckMenuElem (_("Envelope Visible")));
2001 CheckMenuItem* region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
2002 fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
2003 if (arv->envelope_visible()) {
2005 region_envelope_visible_item->set_active (true);
2009 items.push_back (CheckMenuElem (_("Envelope Active")));
2010 CheckMenuItem* region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
2011 fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
2013 if (ar->envelope_active()) {
2015 region_envelope_active_item->set_active (true);
2019 items.push_back (SeparatorElem());
2022 if (ar->scale_amplitude() != 1.0f) {
2023 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
2025 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
2029 items.push_back (MenuElem (_("Quantize"), mem_fun(*this, &Editor::quantize_region)));
2030 items.push_back (SeparatorElem());
2033 items.push_back (MenuElem (_("Strip silence..."), mem_fun (*this, &Editor::strip_region_silence)));
2034 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
2035 items.push_back (SeparatorElem());
2037 /* range related stuff */
2039 items.push_back (MenuElem (_("Add Single Range"), mem_fun (*this, &Editor::add_location_from_audio_region)));
2040 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_locations_from_audio_region)));
2041 if (selection->regions.size() < 2) {
2042 items.back().set_sensitive (false);
2045 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_region)));
2046 items.push_back (SeparatorElem());
2050 Menu *nudge_menu = manage (new Menu());
2051 MenuList& nudge_items = nudge_menu->items();
2052 nudge_menu->set_name ("ArdourContextMenu");
2054 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false, false))));
2055 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false, false))));
2056 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
2057 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
2059 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2060 items.push_back (SeparatorElem());
2062 Menu *trim_menu = manage (new Menu);
2063 MenuList& trim_items = trim_menu->items();
2064 trim_menu->set_name ("ArdourContextMenu");
2066 trim_items.push_back (MenuElem (_("Start to edit point"), mem_fun(*this, &Editor::trim_region_from_edit_point)));
2067 foo_item = &trim_items.back();
2068 if (_edit_point == EditAtMouse) {
2069 foo_item->set_sensitive (false);
2071 trim_items.push_back (MenuElem (_("Edit point to end"), mem_fun(*this, &Editor::trim_region_to_edit_point)));
2072 foo_item = &trim_items.back();
2073 if (_edit_point == EditAtMouse) {
2074 foo_item->set_sensitive (false);
2076 trim_items.push_back (MenuElem (_("Trim To Loop"), mem_fun(*this, &Editor::trim_region_to_loop)));
2077 trim_items.push_back (MenuElem (_("Trim To Punch"), mem_fun(*this, &Editor::trim_region_to_punch)));
2079 items.push_back (MenuElem (_("Trim"), *trim_menu));
2080 items.push_back (SeparatorElem());
2082 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
2083 region_edit_menu_split_item = &items.back();
2085 if (_edit_point == EditAtMouse) {
2086 region_edit_menu_split_item->set_sensitive (false);
2089 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
2090 region_edit_menu_split_multichannel_item = &items.back();
2092 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), false))));
2093 items.push_back (MenuElem (_("Multi-Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
2094 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
2095 items.push_back (SeparatorElem());
2096 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_selected_regions)));
2098 /* OK, stick the region submenu at the top of the list, and then add
2102 /* we have to hack up the region name because "_" has a special
2103 meaning for menu titles.
2106 string::size_type pos = 0;
2107 string menu_item_name = (region) ? region->name() : _("Selected regions");
2109 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
2110 menu_item_name.replace (pos, 1, "__");
2114 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
2115 edit_items.push_back (SeparatorElem());
2118 /** Add context menu items relevant to selection ranges.
2119 * @param edit_items List to add the items to.
2122 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
2124 using namespace Menu_Helpers;
2126 edit_items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
2127 edit_items.push_back (MenuElem (_("Loop range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
2129 edit_items.push_back (SeparatorElem());
2130 edit_items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_range_selection)));
2132 edit_items.push_back (SeparatorElem());
2133 edit_items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
2134 edit_items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
2136 edit_items.push_back (SeparatorElem());
2137 edit_items.push_back (MenuElem (_("Convert to region in-place"), mem_fun(*this, &Editor::separate_region_from_selection)));
2138 edit_items.push_back (MenuElem (_("Convert to region in region list"), mem_fun(*this, &Editor::new_region_from_selection)));
2140 edit_items.push_back (SeparatorElem());
2141 edit_items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
2143 edit_items.push_back (SeparatorElem());
2144 edit_items.push_back (MenuElem (_("Set loop from selection"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
2145 edit_items.push_back (MenuElem (_("Set punch from selection"), mem_fun(*this, &Editor::set_punch_from_selection)));
2147 edit_items.push_back (SeparatorElem());
2148 edit_items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
2149 edit_items.push_back (SeparatorElem());
2150 edit_items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
2151 edit_items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
2152 edit_items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
2153 edit_items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::create_named_selection)));
2154 edit_items.push_back (SeparatorElem());
2155 edit_items.push_back (MenuElem (_("Consolidate range"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, false)));
2156 edit_items.push_back (MenuElem (_("Consolidate range with processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, true)));
2157 edit_items.push_back (MenuElem (_("Bounce range to region list"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, false)));
2158 edit_items.push_back (MenuElem (_("Bounce range to region list with processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, true)));
2159 edit_items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_range)));
2164 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
2166 using namespace Menu_Helpers;
2170 Menu *play_menu = manage (new Menu);
2171 MenuList& play_items = play_menu->items();
2172 play_menu->set_name ("ArdourContextMenu");
2174 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
2175 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2176 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
2177 play_items.push_back (SeparatorElem());
2178 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
2180 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2184 Menu *select_menu = manage (new Menu);
2185 MenuList& select_items = select_menu->items();
2186 select_menu->set_name ("ArdourContextMenu");
2188 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2189 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2190 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2191 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2192 select_items.push_back (SeparatorElem());
2193 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
2194 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
2195 select_items.push_back (SeparatorElem());
2196 select_items.push_back (MenuElem (_("Select All After Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2197 select_items.push_back (MenuElem (_("Select All Before Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2198 select_items.push_back (MenuElem (_("Select All After Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2199 select_items.push_back (MenuElem (_("Select All Before Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2200 select_items.push_back (MenuElem (_("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), false)));
2201 select_items.push_back (MenuElem (_("Select All Within Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), true)));
2202 select_items.push_back (MenuElem (_("Select Range Between Playhead & Edit Point"), mem_fun(*this, &Editor::select_range_between)));
2204 select_items.push_back (SeparatorElem());
2206 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2210 Menu *cutnpaste_menu = manage (new Menu);
2211 MenuList& cutnpaste_items = cutnpaste_menu->items();
2212 cutnpaste_menu->set_name ("ArdourContextMenu");
2214 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2215 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2216 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2218 cutnpaste_items.push_back (SeparatorElem());
2220 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
2221 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
2223 cutnpaste_items.push_back (SeparatorElem());
2225 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
2227 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
2229 /* Adding new material */
2231 edit_items.push_back (SeparatorElem());
2232 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
2233 edit_items.push_back (MenuElem (_("Insert Existing Media"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
2237 Menu *nudge_menu = manage (new Menu());
2238 MenuList& nudge_items = nudge_menu->items();
2239 nudge_menu->set_name ("ArdourContextMenu");
2241 edit_items.push_back (SeparatorElem());
2242 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2243 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2244 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2245 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2247 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2251 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
2253 using namespace Menu_Helpers;
2257 Menu *play_menu = manage (new Menu);
2258 MenuList& play_items = play_menu->items();
2259 play_menu->set_name ("ArdourContextMenu");
2261 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
2262 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2263 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2267 Menu *select_menu = manage (new Menu);
2268 MenuList& select_items = select_menu->items();
2269 select_menu->set_name ("ArdourContextMenu");
2271 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2272 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2273 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2274 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2275 select_items.push_back (SeparatorElem());
2276 select_items.push_back (MenuElem (_("Select all after edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2277 select_items.push_back (MenuElem (_("Select all before edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2278 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2279 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2281 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2285 Menu *cutnpaste_menu = manage (new Menu);
2286 MenuList& cutnpaste_items = cutnpaste_menu->items();
2287 cutnpaste_menu->set_name ("ArdourContextMenu");
2289 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2290 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2291 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2293 Menu *nudge_menu = manage (new Menu());
2294 MenuList& nudge_items = nudge_menu->items();
2295 nudge_menu->set_name ("ArdourContextMenu");
2297 edit_items.push_back (SeparatorElem());
2298 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2299 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2300 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2301 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2303 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2307 Editor::set_snap_to (SnapType st)
2309 unsigned int snap_ind = (unsigned int)st;
2313 if (snap_ind > snap_type_strings.size() - 1) {
2315 snap_type = (SnapType)snap_ind;
2318 string str = snap_type_strings[snap_ind];
2320 if (str != snap_type_selector.get_active_text()) {
2321 snap_type_selector.set_active_text (str);
2326 switch (snap_type) {
2327 case SnapToAThirtysecondBeat:
2328 case SnapToASixteenthBeat:
2329 case SnapToAEighthBeat:
2330 case SnapToAQuarterBeat:
2331 case SnapToAThirdBeat:
2332 compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames());
2333 update_tempo_based_rulers ();
2336 case SnapToRegionStart:
2337 case SnapToRegionEnd:
2338 case SnapToRegionSync:
2339 case SnapToRegionBoundary:
2340 build_region_boundary_cache ();
2350 Editor::set_snap_mode (SnapMode mode)
2353 string str = snap_mode_strings[(int)mode];
2355 if (str != snap_mode_selector.get_active_text ()) {
2356 snap_mode_selector.set_active_text (str);
2362 Editor::set_edit_point_preference (EditPoint ep, bool force)
2364 bool changed = (_edit_point != ep);
2367 string str = edit_point_strings[(int)ep];
2369 if (str != edit_point_selector.get_active_text ()) {
2370 edit_point_selector.set_active_text (str);
2373 set_canvas_cursor ();
2375 if (!force && !changed) {
2379 switch (zoom_focus) {
2380 case ZoomFocusMouse:
2381 case ZoomFocusPlayhead:
2383 switch (_edit_point) {
2385 set_zoom_focus (ZoomFocusMouse);
2387 case EditAtPlayhead:
2388 set_zoom_focus (ZoomFocusPlayhead);
2390 case EditAtSelectedMarker:
2391 set_zoom_focus (ZoomFocusEdit);
2399 const char* action=NULL;
2401 switch (_edit_point) {
2402 case EditAtPlayhead:
2403 action = "edit-at-playhead";
2405 case EditAtSelectedMarker:
2406 action = "edit-at-marker";
2409 action = "edit-at-mouse";
2413 Glib::RefPtr<Action> act = ActionManager::get_action ("Editor", action);
2415 Glib::RefPtr<RadioAction>::cast_dynamic(act)->set_active (true);
2419 bool in_track_canvas;
2421 if (!mouse_frame (foo, in_track_canvas)) {
2422 in_track_canvas = false;
2425 reset_canvas_action_sensitivity (in_track_canvas);
2431 Editor::set_state (const XMLNode& node)
2433 const XMLProperty* prop;
2435 int x, y, xoff, yoff;
2438 if ((prop = node.property ("id")) != 0) {
2439 _id = prop->value ();
2442 g.base_width = default_width;
2443 g.base_height = default_height;
2449 if ((geometry = find_named_node (node, "geometry")) != 0) {
2453 if ((prop = geometry->property("x_size")) == 0) {
2454 prop = geometry->property ("x-size");
2457 g.base_width = atoi(prop->value());
2459 if ((prop = geometry->property("y_size")) == 0) {
2460 prop = geometry->property ("y-size");
2463 g.base_height = atoi(prop->value());
2466 if ((prop = geometry->property ("x_pos")) == 0) {
2467 prop = geometry->property ("x-pos");
2470 x = atoi (prop->value());
2473 if ((prop = geometry->property ("y_pos")) == 0) {
2474 prop = geometry->property ("y-pos");
2477 y = atoi (prop->value());
2480 if ((prop = geometry->property ("x_off")) == 0) {
2481 prop = geometry->property ("x-off");
2484 xoff = atoi (prop->value());
2486 if ((prop = geometry->property ("y_off")) == 0) {
2487 prop = geometry->property ("y-off");
2490 yoff = atoi (prop->value());
2494 set_default_size (g.base_width, g.base_height);
2497 if (session && (prop = node.property ("playhead"))) {
2498 nframes64_t pos = atol (prop->value().c_str());
2499 playhead_cursor->set_position (pos);
2501 playhead_cursor->set_position (0);
2503 /* reset_x_origin() doesn't work right here, since the old
2504 position may be zero already, and it does nothing in such
2509 horizontal_adjustment.set_value (0);
2512 if ((prop = node.property ("mixer-width"))) {
2513 editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
2516 if ((prop = node.property ("zoom-focus"))) {
2517 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2520 if ((prop = node.property ("zoom"))) {
2521 reset_zoom (PBD::atof (prop->value()));
2524 if ((prop = node.property ("snap-to"))) {
2525 set_snap_to ((SnapType) atoi (prop->value()));
2528 if ((prop = node.property ("snap-mode"))) {
2529 set_snap_mode ((SnapMode) atoi (prop->value()));
2532 if ((prop = node.property ("edit-point"))) {
2533 set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point), true);
2536 if ((prop = node.property ("mouse-mode"))) {
2537 MouseMode m = str2mousemode(prop->value());
2538 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2539 set_mouse_mode (m, true);
2541 mouse_mode = MouseGain; /* lie, to force the mode switch */
2542 set_mouse_mode (MouseObject, true);
2545 if ((prop = node.property ("show-waveforms-recording"))) {
2546 bool yn = (prop->value() == "yes");
2547 _show_waveforms_recording = !yn;
2548 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2550 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2551 /* do it twice to force the change */
2552 tact->set_active (!yn);
2553 tact->set_active (yn);
2557 if ((prop = node.property ("show-measures"))) {
2558 bool yn = (prop->value() == "yes");
2559 _show_measures = !yn;
2560 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2562 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2563 /* do it twice to force the change */
2564 tact->set_active (!yn);
2565 tact->set_active (yn);
2569 if ((prop = node.property ("follow-playhead"))) {
2570 bool yn = (prop->value() == "yes");
2571 set_follow_playhead (yn);
2572 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2574 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2575 if (tact->get_active() != yn) {
2576 tact->set_active (yn);
2581 if ((prop = node.property ("region-list-sort-type"))) {
2582 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2583 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2586 if ((prop = node.property ("xfades-visible"))) {
2587 bool yn = (prop->value() == "yes");
2588 _xfade_visibility = !yn;
2589 // set_xfade_visibility (yn);
2592 if ((prop = node.property ("show-editor-mixer"))) {
2594 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2597 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2598 bool yn = (prop->value() == X_("yes"));
2600 /* do it twice to force the change */
2602 tact->set_active (!yn);
2603 tact->set_active (yn);
2607 if ((prop = node.property ("show-editor-list"))) {
2609 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2613 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2614 bool yn = (prop->value() == X_("yes"));
2616 /* do it twice to force the change */
2618 tact->set_active (!yn);
2619 tact->set_active (yn);
2628 Editor::get_state ()
2630 XMLNode* node = new XMLNode ("Editor");
2633 _id.print (buf, sizeof (buf));
2634 node->add_property ("id", buf);
2636 if (is_realized()) {
2637 Glib::RefPtr<Gdk::Window> win = get_window();
2639 int x, y, xoff, yoff, width, height;
2640 win->get_root_origin(x, y);
2641 win->get_position(xoff, yoff);
2642 win->get_size(width, height);
2644 XMLNode* geometry = new XMLNode ("geometry");
2646 snprintf(buf, sizeof(buf), "%d", width);
2647 geometry->add_property("x-size", string(buf));
2648 snprintf(buf, sizeof(buf), "%d", height);
2649 geometry->add_property("y-size", string(buf));
2650 snprintf(buf, sizeof(buf), "%d", x);
2651 geometry->add_property("x-pos", string(buf));
2652 snprintf(buf, sizeof(buf), "%d", y);
2653 geometry->add_property("y-pos", string(buf));
2654 snprintf(buf, sizeof(buf), "%d", xoff);
2655 geometry->add_property("x-off", string(buf));
2656 snprintf(buf, sizeof(buf), "%d", yoff);
2657 geometry->add_property("y-off", string(buf));
2658 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2659 geometry->add_property("edit_pane_pos", string(buf));
2661 node->add_child_nocopy (*geometry);
2664 maybe_add_mixer_strip_width (*node);
2666 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2667 node->add_property ("zoom-focus", buf);
2668 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2669 node->add_property ("zoom", buf);
2670 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2671 node->add_property ("snap-to", buf);
2672 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2673 node->add_property ("snap-mode", buf);
2675 node->add_property ("edit-point", enum_2_string (_edit_point));
2677 snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame);
2678 node->add_property ("playhead", buf);
2680 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2681 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2682 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2683 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2684 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2685 node->add_property ("mouse-mode", enum2str(mouse_mode));
2687 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2689 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2690 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2693 act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
2695 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2696 node->add_property (X_("show-editor-list"), tact->get_active() ? "yes" : "no");
2704 /** @param y y offset from the top of all trackviews.
2705 * @return pair: TimeAxisView that y is over, layer index.
2706 * TimeAxisView may be 0. Layer index is the layer number if the TimeAxisView is valid and is
2707 * in stacked region display mode, otherwise 0.
2709 std::pair<TimeAxisView *, layer_t>
2710 Editor::trackview_by_y_position (double y)
2712 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2714 std::pair<TimeAxisView*, int> const r = (*iter)->covers_y_position (y);
2720 return std::make_pair ( (TimeAxisView *) 0, 0);
2724 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
2726 if (!session || snap_mode == SnapOff) {
2730 snap_to_internal (start, direction, for_mark);
2734 Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
2736 Location* before = 0;
2737 Location* after = 0;
2739 const nframes64_t one_second = session->frame_rate();
2740 const nframes64_t one_minute = session->frame_rate() * 60;
2741 const nframes64_t one_smpte_second = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
2742 nframes64_t one_smpte_minute = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
2743 nframes64_t presnap = start;
2745 switch (snap_type) {
2747 if (((direction == 0) && (start % (one_second/75) > (one_second/75) / 2)) || (direction > 0)) {
2748 start = (nframes64_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2750 start = (nframes64_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2754 case SnapToSMPTEFrame:
2755 if (((direction == 0) && (fmod((double)start, (double)session->frames_per_smpte_frame()) > (session->frames_per_smpte_frame() / 2))) || (direction > 0)) {
2756 start = (nframes64_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2758 start = (nframes64_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2762 case SnapToSMPTESeconds:
2763 if (session->smpte_offset_negative())
2765 start += session->smpte_offset ();
2767 start -= session->smpte_offset ();
2769 if (((direction == 0) && (start % one_smpte_second > one_smpte_second / 2)) || direction > 0) {
2770 start = (nframes64_t) ceil ((double) start / one_smpte_second) * one_smpte_second;
2772 start = (nframes64_t) floor ((double) start / one_smpte_second) * one_smpte_second;
2775 if (session->smpte_offset_negative())
2777 start -= session->smpte_offset ();
2779 start += session->smpte_offset ();
2783 case SnapToSMPTEMinutes:
2784 if (session->smpte_offset_negative())
2786 start += session->smpte_offset ();
2788 start -= session->smpte_offset ();
2790 if (((direction == 0) && (start % one_smpte_minute > one_smpte_minute / 2)) || direction > 0) {
2791 start = (nframes64_t) ceil ((double) start / one_smpte_minute) * one_smpte_minute;
2793 start = (nframes64_t) floor ((double) start / one_smpte_minute) * one_smpte_minute;
2795 if (session->smpte_offset_negative())
2797 start -= session->smpte_offset ();
2799 start += session->smpte_offset ();
2804 if (((direction == 0) && (start % one_second > one_second / 2)) || (direction > 0)) {
2805 start = (nframes64_t) ceil ((double) start / one_second) * one_second;
2807 start = (nframes64_t) floor ((double) start / one_second) * one_second;
2812 if (((direction == 0) && (start % one_minute > one_minute / 2)) || (direction > 0)) {
2813 start = (nframes64_t) ceil ((double) start / one_minute) * one_minute;
2815 start = (nframes64_t) floor ((double) start / one_minute) * one_minute;
2820 start = session->tempo_map().round_to_bar (start, direction);
2824 start = session->tempo_map().round_to_beat (start, direction);
2827 case SnapToAThirtysecondBeat:
2828 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2831 case SnapToASixteenthBeat:
2832 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2835 case SnapToAEighthBeat:
2836 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2839 case SnapToAQuarterBeat:
2840 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2843 case SnapToAThirdBeat:
2844 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2852 before = session->locations()->first_location_before (start);
2853 after = session->locations()->first_location_after (start);
2855 if (direction < 0) {
2857 start = before->start();
2861 } else if (direction > 0) {
2863 start = after->start();
2865 start = session->current_end_frame();
2870 /* find nearest of the two */
2871 if ((start - before->start()) < (after->start() - start)) {
2872 start = before->start();
2874 start = after->start();
2877 start = before->start();
2880 start = after->start();
2887 case SnapToRegionStart:
2888 case SnapToRegionEnd:
2889 case SnapToRegionSync:
2890 case SnapToRegionBoundary:
2891 if (!region_boundary_cache.empty()) {
2892 vector<nframes64_t>::iterator i;
2894 if (direction > 0) {
2895 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2897 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2900 if (i != region_boundary_cache.end()) {
2902 /* lower bound doesn't quite to the right thing for our purposes */
2904 if (direction < 0 && i != region_boundary_cache.begin()) {
2911 start = region_boundary_cache.back();
2917 switch (snap_mode) {
2923 if (presnap > start) {
2924 if (presnap > (start + unit_to_frame(snap_threshold))) {
2928 } else if (presnap < start) {
2929 if (presnap < (start - unit_to_frame(snap_threshold))) {
2935 /* handled at entry */
2942 Editor::snap_length_beats (nframes64_t start)
2948 /* FIXME: This could/should also work with non-tempo based snap settings (ie seconds) */
2950 switch (snap_type) {
2952 return session->tempo_map().meter_at(start).beats_per_bar();
2957 case SnapToAThirtysecondBeat:
2958 return 1.0 / (double)32.0;
2961 case SnapToASixteenthBeat:
2962 return 1.0 / (double)16.0;
2965 case SnapToAEighthBeat:
2966 return 1.0 / (double)8.0;
2969 case SnapToAQuarterBeat:
2970 return 1.0 / (double)4.0;
2973 case SnapToAThirdBeat:
2974 return 1.0 / (double)3.0;
2982 Editor::setup_toolbar ()
2986 /* Mode Buttons (tool selection) */
2988 vector<ToggleButton *> mouse_mode_buttons;
2990 mouse_move_button.add (*(manage (new Image (::get_icon("tool_object")))));
2991 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2992 mouse_mode_buttons.push_back (&mouse_move_button);
2994 if (!Profile->get_sae()) {
2995 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2996 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2997 mouse_mode_buttons.push_back (&mouse_select_button);
2999 mouse_gain_button.add (*(manage (new Image (::get_icon("tool_gain")))));
3000 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
3001 mouse_mode_buttons.push_back (&mouse_gain_button);
3004 mouse_zoom_button.add (*(manage (new Image (::get_icon("tool_zoom")))));
3005 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
3006 mouse_mode_buttons.push_back (&mouse_zoom_button);
3007 mouse_timefx_button.add (*(manage (new Image (::get_icon("tool_stretch")))));
3008 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
3009 mouse_mode_buttons.push_back (&mouse_timefx_button);
3010 mouse_audition_button.add (*(manage (new Image (::get_icon("tool_audition")))));
3011 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
3012 mouse_note_button.add (*(manage (new Image (::get_icon("tool_note")))));
3013 mouse_note_button.set_relief(Gtk::RELIEF_NONE);
3014 mouse_mode_buttons.push_back (&mouse_note_button);
3015 mouse_mode_buttons.push_back (&mouse_audition_button);
3017 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
3019 HBox* mode_box = manage(new HBox);
3020 mode_box->set_border_width (2);
3021 mode_box->set_spacing(4);
3022 mouse_mode_button_box.set_spacing(1);
3023 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
3024 if (!Profile->get_sae()) {
3025 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
3027 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
3028 if (!Profile->get_sae()) {
3029 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
3031 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
3032 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
3033 mouse_mode_button_box.pack_start(mouse_note_button, true, true);
3034 mouse_mode_button_box.set_homogeneous(true);
3036 vector<string> edit_mode_strings;
3037 edit_mode_strings.push_back (edit_mode_to_string (Slide));
3038 if (!Profile->get_sae()) {
3039 edit_mode_strings.push_back (edit_mode_to_string (Splice));
3041 edit_mode_strings.push_back (edit_mode_to_string (Lock));
3043 edit_mode_selector.set_name ("EditModeSelector");
3044 set_popdown_strings (edit_mode_selector, edit_mode_strings, true);
3045 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
3047 mode_box->pack_start(edit_mode_selector);
3048 mode_box->pack_start(mouse_mode_button_box);
3050 mouse_mode_tearoff = manage (new TearOff (*mode_box));
3051 mouse_mode_tearoff->set_name ("MouseModeBase");
3053 if (Profile->get_sae()) {
3054 mouse_mode_tearoff->set_can_be_torn_off (false);
3057 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3058 &mouse_mode_tearoff->tearoff_window()));
3059 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3060 &mouse_mode_tearoff->tearoff_window(), 1));
3061 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3062 &mouse_mode_tearoff->tearoff_window()));
3063 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3064 &mouse_mode_tearoff->tearoff_window(), 1));
3066 mouse_move_button.set_name ("MouseModeButton");
3067 mouse_select_button.set_name ("MouseModeButton");
3068 mouse_gain_button.set_name ("MouseModeButton");
3069 mouse_zoom_button.set_name ("MouseModeButton");
3070 mouse_timefx_button.set_name ("MouseModeButton");
3071 mouse_audition_button.set_name ("MouseModeButton");
3072 mouse_note_button.set_name ("MouseModeButton");
3074 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
3075 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
3076 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
3077 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
3078 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
3079 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
3080 ARDOUR_UI::instance()->tooltips().set_tip (mouse_note_button, _("Edit MIDI Notes"));
3082 mouse_move_button.unset_flags (CAN_FOCUS);
3083 mouse_select_button.unset_flags (CAN_FOCUS);
3084 mouse_gain_button.unset_flags (CAN_FOCUS);
3085 mouse_zoom_button.unset_flags (CAN_FOCUS);
3086 mouse_timefx_button.unset_flags (CAN_FOCUS);
3087 mouse_audition_button.unset_flags (CAN_FOCUS);
3088 mouse_note_button.unset_flags (CAN_FOCUS);
3090 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
3091 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
3093 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
3094 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
3095 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
3096 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
3097 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
3098 mouse_note_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseNote));
3100 // mouse_move_button.set_active (true);
3105 zoom_box.set_spacing (1);
3106 zoom_box.set_border_width (0);
3108 zoom_in_button.set_name ("EditorTimeButton");
3109 zoom_in_button.set_size_request(-1,16);
3110 zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in")))));
3111 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
3112 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
3114 zoom_out_button.set_name ("EditorTimeButton");
3115 zoom_out_button.set_size_request(-1,16);
3116 zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out")))));
3117 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
3118 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
3120 zoom_out_full_button.set_name ("EditorTimeButton");
3121 zoom_out_full_button.set_size_request(-1,16);
3122 zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full")))));
3123 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
3124 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
3126 zoom_focus_selector.set_name ("ZoomFocusSelector");
3127 set_popdown_strings (zoom_focus_selector, zoom_focus_strings, true);
3128 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
3129 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
3131 zoom_box.pack_start (zoom_out_button, false, false);
3132 zoom_box.pack_start (zoom_in_button, false, false);
3133 zoom_box.pack_start (zoom_out_full_button, false, false);
3135 HBox* zbc = manage (new HBox);
3136 zbc->pack_start (zoom_focus_selector, PACK_SHRINK);
3137 zoom_vbox.pack_start (*zbc, PACK_SHRINK);
3138 zoom_vbox.pack_start (zoom_box, PACK_SHRINK);
3140 snap_box.set_spacing (1);
3141 snap_box.set_border_width (2);
3143 snap_type_selector.set_name ("SnapTypeSelector");
3144 set_popdown_strings (snap_type_selector, snap_type_strings, true);
3145 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
3146 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Snap/Grid Units"));
3148 snap_mode_selector.set_name ("SnapModeSelector");
3149 set_popdown_strings (snap_mode_selector, snap_mode_strings, true);
3150 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
3151 ARDOUR_UI::instance()->tooltips().set_tip (snap_mode_selector, _("Snap/Grid Mode"));
3153 edit_point_selector.set_name ("EditPointSelector");
3154 set_popdown_strings (edit_point_selector, edit_point_strings, true);
3155 edit_point_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_point_selection_done));
3156 ARDOUR_UI::instance()->tooltips().set_tip (edit_point_selector, _("Edit point"));
3158 snap_box.pack_start (edit_point_clock, false, false);
3159 snap_box.pack_start (snap_mode_selector, false, false);
3160 snap_box.pack_start (snap_type_selector, false, false);
3161 snap_box.pack_start (edit_point_selector, false, false);
3165 HBox *nudge_box = manage (new HBox);
3166 nudge_box->set_spacing(1);
3167 nudge_box->set_border_width (2);
3169 nudge_forward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_forward_release), false);
3170 nudge_backward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_backward_release), false);
3172 nudge_box->pack_start (nudge_backward_button, false, false);
3173 nudge_box->pack_start (nudge_forward_button, false, false);
3174 nudge_box->pack_start (nudge_clock, false, false);
3177 /* Pack everything in... */
3179 HBox* hbox = manage (new HBox);
3180 hbox->set_spacing(10);
3182 tools_tearoff = manage (new TearOff (*hbox));
3183 tools_tearoff->set_name ("MouseModeBase");
3185 if (Profile->get_sae()) {
3186 tools_tearoff->set_can_be_torn_off (false);
3189 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3190 &tools_tearoff->tearoff_window()));
3191 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3192 &tools_tearoff->tearoff_window(), 0));
3193 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
3194 &tools_tearoff->tearoff_window()));
3195 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
3196 &tools_tearoff->tearoff_window(), 0));
3198 toolbar_hbox.set_spacing (10);
3199 toolbar_hbox.set_border_width (1);
3201 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
3202 toolbar_hbox.pack_start (*tools_tearoff, false, false);
3205 hbox->pack_start (snap_box, false, false);
3206 // hbox->pack_start (zoom_box, false, false);
3207 hbox->pack_start (*nudge_box, false, false);
3211 toolbar_base.set_name ("ToolBarBase");
3212 toolbar_base.add (toolbar_hbox);
3214 toolbar_frame.set_shadow_type (SHADOW_OUT);
3215 toolbar_frame.set_name ("BaseFrame");
3216 toolbar_frame.add (toolbar_base);
3220 Editor::midi_panic_button_pressed ()
3223 session->midi_panic();
3228 Editor::setup_midi_toolbar ()
3232 /* Mode Buttons (tool selection) */
3234 vector<ToggleButton *> midi_tool_buttons;
3236 midi_tool_pencil_button.add (*(manage (new Image (::get_icon("midi_tool_pencil")))));
3237 midi_tool_pencil_button.set_relief(Gtk::RELIEF_NONE);
3238 midi_tool_buttons.push_back (&midi_tool_pencil_button);
3239 midi_tool_select_button.add (*(manage (new Image (::get_icon("midi_tool_select")))));
3240 midi_tool_select_button.set_relief(Gtk::RELIEF_NONE);
3241 midi_tool_buttons.push_back (&midi_tool_select_button);
3242 midi_tool_resize_button.add (*(manage (new Image (::get_icon("strip_width")))));
3243 midi_tool_resize_button.set_relief(Gtk::RELIEF_NONE);
3244 midi_tool_buttons.push_back (&midi_tool_resize_button);
3245 midi_tool_erase_button.add (*(manage (new Image (::get_icon("midi_tool_erase")))));
3246 midi_tool_erase_button.set_relief(Gtk::RELIEF_NONE);
3247 midi_tool_buttons.push_back (&midi_tool_erase_button);
3249 midi_tool_pencil_button.set_active(true);
3251 midi_tool_button_set = new GroupedButtons (midi_tool_buttons);
3253 midi_tool_button_box.set_border_width (2);
3254 midi_tool_button_box.set_spacing(1);
3255 midi_tool_button_box.pack_start(midi_tool_pencil_button, true, true);
3256 midi_tool_button_box.pack_start(midi_tool_select_button, true, true);
3257 midi_tool_button_box.pack_start(midi_tool_resize_button, true, true);
3258 midi_tool_button_box.pack_start(midi_tool_erase_button , true, true);
3259 midi_tool_button_box.set_homogeneous(true);
3261 midi_tool_pencil_button.set_name ("MouseModeButton");
3262 midi_tool_select_button.set_name ("MouseModeButton");
3263 midi_tool_resize_button.set_name ("MouseModeButton");
3264 midi_tool_erase_button .set_name ("MouseModeButton");
3266 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_pencil_button, _("Add/Move/Stretch Notes"));
3267 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_select_button, _("Select/Move Notes"));
3268 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_resize_button, _("Resize Notes"));
3269 ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_erase_button, _("Erase Notes"));
3271 midi_tool_pencil_button.unset_flags (CAN_FOCUS);
3272 midi_tool_select_button.unset_flags (CAN_FOCUS);
3273 midi_tool_resize_button.unset_flags (CAN_FOCUS);
3274 midi_tool_erase_button.unset_flags (CAN_FOCUS);
3276 midi_tool_pencil_button.signal_toggled().connect (bind (mem_fun(*this,
3277 &Editor::midi_edit_mode_toggled), Editing::MidiEditPencil));
3278 midi_tool_select_button.signal_toggled().connect (bind (mem_fun(*this,
3279 &Editor::midi_edit_mode_toggled), Editing::MidiEditSelect));
3280 midi_tool_resize_button.signal_toggled().connect (bind (mem_fun(*this,
3281 &Editor::midi_edit_mode_toggled), Editing::MidiEditResize));
3282 midi_tool_erase_button.signal_toggled().connect (bind (mem_fun(*this,
3283 &Editor::midi_edit_mode_toggled), Editing::MidiEditErase));
3286 /* Midi sound notes */
3287 midi_sound_notes.add (*(manage (new Image (::get_icon("midi_sound_notes")))));
3288 midi_sound_notes.set_relief(Gtk::RELIEF_NONE);
3289 ARDOUR_UI::instance()->tooltips().set_tip (midi_sound_notes, _("Sound Notes"));
3290 midi_sound_notes.unset_flags (CAN_FOCUS);
3294 HBox* panic_box = manage (new HBox);
3295 midi_panic_button.set_name("MidiPanicButton");
3296 midi_panic_button.signal_pressed().connect (
3297 mem_fun(this, &Editor::midi_panic_button_pressed));
3298 panic_box->pack_start (midi_sound_notes , true, true);
3299 panic_box->pack_start (midi_panic_button, true, true);
3301 /* Pack everything in... */
3303 midi_tools_tearoff = manage (new TearOff (midi_tool_button_box));
3304 midi_tools_tearoff->set_name ("MouseModeBase");
3307 midi_tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&midi_toolbar_hbox),
3308 &midi_tools_tearoff->tearoff_window()));
3309 midi_tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&midi_toolbar_hbox),
3310 &midi_tools_tearoff->tearoff_window(), 0));
3311 midi_tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&midi_toolbar_hbox),
3312 &midi_tools_tearoff->tearoff_window()));
3313 midi_tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&midi_toolbar_hbox),
3314 &midi_tools_tearoff->tearoff_window(), 0));
3317 midi_toolbar_hbox.set_spacing (10);
3318 midi_toolbar_hbox.set_border_width (1);
3320 midi_toolbar_hbox.pack_start (*midi_tools_tearoff, false, true);
3322 midi_toolbar_hbox.pack_start(*panic_box, false, true, 4);
3324 midi_tool_button_box.show_all ();
3325 midi_toolbar_hbox.show_all();
3326 midi_tools_tearoff->show_all();
3328 midi_toolbar_base.set_name ("ToolBarBase");
3329 midi_toolbar_base.add (midi_toolbar_hbox);
3331 midi_toolbar_frame.set_shadow_type (SHADOW_OUT);
3332 midi_toolbar_frame.set_name ("BaseFrame");
3333 midi_toolbar_frame.add (midi_toolbar_base);
3337 Editor::convert_drop_to_paths (
3338 vector<ustring>& paths,
3339 const RefPtr<Gdk::DragContext>& context,
3342 const SelectionData& data,
3350 vector<ustring> uris = data.get_uris();
3354 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
3355 are actually URI lists. So do it by hand.
3358 if (data.get_target() != "text/plain") {
3362 /* Parse the "uri-list" format that Nautilus provides,
3363 where each pathname is delimited by \r\n.
3365 THERE MAY BE NO NULL TERMINATING CHAR!!!
3368 ustring txt = data.get_text();
3372 p = (const char *) malloc (txt.length() + 1);
3373 txt.copy ((char *) p, txt.length(), 0);
3374 ((char*)p)[txt.length()] = '\0';
3380 while (g_ascii_isspace (*p))
3384 while (*q && (*q != '\n') && (*q != '\r')) {
3391 while (q > p && g_ascii_isspace (*q))
3396 uris.push_back (ustring (p, q - p + 1));
3400 p = strchr (p, '\n');
3412 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
3414 if ((*i).substr (0,7) == "file://") {
3417 PBD::url_decode (p);
3419 // scan forward past three slashes
3421 ustring::size_type slashcnt = 0;
3422 ustring::size_type n = 0;
3423 ustring::iterator x = p.begin();
3425 while (slashcnt < 3 && x != p.end()) {
3428 } else if (slashcnt == 3) {
3435 if (slashcnt != 3 || x == p.end()) {
3436 error << _("malformed URL passed to drag-n-drop code") << endmsg;
3440 paths.push_back (p.substr (n - 1));
3448 Editor::new_tempo_section ()
3454 Editor::map_transport_state ()
3456 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
3458 if (session->transport_stopped()) {
3459 have_pending_keyboard_selection = false;
3462 update_loop_range_view (true);
3467 Editor::State::State (PublicEditor const * e)
3469 selection = new Selection (e);
3472 Editor::State::~State ()
3478 Editor::store_state (State& state) const
3480 *state.selection = *selection;
3484 Editor::restore_state (State *state)
3486 if (*selection == *state->selection) {
3490 *selection = *state->selection;
3491 time_selection_changed ();
3492 region_selection_changed ();
3494 /* XXX other selection change handlers? */
3498 Editor::begin_reversible_command (string name)
3501 before = &get_state();
3502 session->begin_reversible_command (name);
3507 Editor::commit_reversible_command ()
3510 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
3515 Editor::set_edit_group_solo (Route& route, bool yn)
3517 RouteGroup *edit_group;
3519 if ((edit_group = route.edit_group()) != 0) {
3520 edit_group->apply (&Route::set_solo, yn, this);
3522 route.set_solo (yn, this);
3527 Editor::set_edit_group_mute (Route& route, bool yn)
3529 RouteGroup *edit_group = 0;
3531 if ((edit_group == route.edit_group()) != 0) {
3532 edit_group->apply (&Route::set_mute, yn, this);
3534 route.set_mute (yn, this);
3539 Editor::history_changed ()
3543 if (undo_action && session) {
3544 if (session->undo_depth() == 0) {
3547 label = string_compose(_("Undo (%1)"), session->next_undo());
3549 undo_action->property_label() = label;
3552 if (redo_action && session) {
3553 if (session->redo_depth() == 0) {
3556 label = string_compose(_("Redo (%1)"), session->next_redo());
3558 redo_action->property_label() = label;
3563 Editor::duplicate_dialog (bool with_dialog)
3567 if (mouse_mode == MouseRange) {
3568 if (selection->time.length() == 0) {
3574 get_regions_for_action (rs);
3576 if (mouse_mode != MouseRange) {
3585 ArdourDialog win ("Duplication Dialog");
3586 Label label (_("Number of Duplications:"));
3587 Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
3588 SpinButton spinner (adjustment, 0.0, 1);
3591 win.get_vbox()->set_spacing (12);
3592 win.get_vbox()->pack_start (hbox);
3593 hbox.set_border_width (6);
3594 hbox.pack_start (label, PACK_EXPAND_PADDING, 12);
3596 /* dialogs have ::add_action_widget() but that puts the spinner in the wrong
3597 place, visually. so do this by hand.
3600 hbox.pack_start (spinner, PACK_EXPAND_PADDING, 12);
3601 spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
3602 spinner.grab_focus();
3608 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3609 win.add_button (_("Duplicate"), RESPONSE_ACCEPT);
3610 win.set_default_response (RESPONSE_ACCEPT);
3612 win.set_position (WIN_POS_MOUSE);
3614 spinner.grab_focus ();
3616 switch (win.run ()) {
3617 case RESPONSE_ACCEPT:
3623 times = adjustment.get_value();
3626 if (mouse_mode == MouseRange) {
3627 duplicate_selection (times);
3629 duplicate_some_regions (rs, times);
3634 Editor::show_verbose_canvas_cursor ()
3636 verbose_canvas_cursor->raise_to_top();
3637 verbose_canvas_cursor->show();
3638 verbose_cursor_visible = true;
3642 Editor::hide_verbose_canvas_cursor ()
3644 verbose_canvas_cursor->hide();
3645 verbose_cursor_visible = false;
3649 Editor::clamp_verbose_cursor_x (double x)
3654 x = min (_canvas_width - 200.0, x);
3660 Editor::clamp_verbose_cursor_y (double y)
3662 if (y < canvas_timebars_vsize) {
3663 y = canvas_timebars_vsize;
3665 y = min (_canvas_height - 50, y);
3671 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3673 verbose_canvas_cursor->property_text() = txt.c_str();
3674 /* don't get too close to the edge */
3675 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (x);
3676 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_y (y);
3680 Editor::set_verbose_canvas_cursor_text (const string & txt)
3682 verbose_canvas_cursor->property_text() = txt.c_str();
3686 Editor::set_edit_mode (EditMode m)
3688 Config->set_edit_mode (m);
3692 Editor::cycle_edit_mode ()
3694 switch (Config->get_edit_mode()) {
3696 if (Profile->get_sae()) {
3697 Config->set_edit_mode (Lock);
3699 Config->set_edit_mode (Splice);
3703 Config->set_edit_mode (Lock);
3706 Config->set_edit_mode (Slide);
3712 Editor::edit_mode_selection_done ()
3718 string choice = edit_mode_selector.get_active_text();
3719 EditMode mode = Slide;
3721 if (choice == _("Splice Edit")) {
3723 } else if (choice == _("Slide Edit")) {
3725 } else if (choice == _("Lock Edit")) {
3729 Config->set_edit_mode (mode);
3733 Editor::snap_type_selection_done ()
3735 string choice = snap_type_selector.get_active_text();
3736 SnapType snaptype = SnapToBeat;
3738 if (choice == _("Beats/3")) {
3739 snaptype = SnapToAThirdBeat;
3740 } else if (choice == _("Beats/4")) {
3741 snaptype = SnapToAQuarterBeat;
3742 } else if (choice == _("Beats/8")) {
3743 snaptype = SnapToAEighthBeat;
3744 } else if (choice == _("Beats/16")) {
3745 snaptype = SnapToASixteenthBeat;
3746 } else if (choice == _("Beats/32")) {
3747 snaptype = SnapToAThirtysecondBeat;
3748 } else if (choice == _("Beats")) {
3749 snaptype = SnapToBeat;
3750 } else if (choice == _("Bars")) {
3751 snaptype = SnapToBar;
3752 } else if (choice == _("Marks")) {
3753 snaptype = SnapToMark;
3754 } else if (choice == _("Region starts")) {
3755 snaptype = SnapToRegionStart;
3756 } else if (choice == _("Region ends")) {
3757 snaptype = SnapToRegionEnd;
3758 } else if (choice == _("Region bounds")) {
3759 snaptype = SnapToRegionBoundary;
3760 } else if (choice == _("Region syncs")) {
3761 snaptype = SnapToRegionSync;
3762 } else if (choice == _("CD Frames")) {
3763 snaptype = SnapToCDFrame;
3764 } else if (choice == _("SMPTE Frames")) {
3765 snaptype = SnapToSMPTEFrame;
3766 } else if (choice == _("SMPTE Seconds")) {
3767 snaptype = SnapToSMPTESeconds;
3768 } else if (choice == _("SMPTE Minutes")) {
3769 snaptype = SnapToSMPTEMinutes;
3770 } else if (choice == _("Seconds")) {
3771 snaptype = SnapToSeconds;
3772 } else if (choice == _("Minutes")) {
3773 snaptype = SnapToMinutes;
3776 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3778 ract->set_active ();
3783 Editor::snap_mode_selection_done ()
3785 string choice = snap_mode_selector.get_active_text();
3786 SnapMode mode = SnapNormal;
3788 if (choice == _("No Grid")) {
3790 } else if (choice == _("Grid")) {
3792 } else if (choice == _("Magnetic")) {
3793 mode = SnapMagnetic;
3796 RefPtr<RadioAction> ract = snap_mode_action (mode);
3799 ract->set_active (true);
3804 Editor::cycle_edit_point (bool with_marker)
3806 switch (_edit_point) {
3808 set_edit_point_preference (EditAtPlayhead);
3810 case EditAtPlayhead:
3812 set_edit_point_preference (EditAtSelectedMarker);
3814 set_edit_point_preference (EditAtMouse);
3817 case EditAtSelectedMarker:
3818 set_edit_point_preference (EditAtMouse);
3824 Editor::edit_point_selection_done ()
3826 string choice = edit_point_selector.get_active_text();
3827 EditPoint ep = EditAtSelectedMarker;
3829 if (choice == _("Marker")) {
3830 set_edit_point_preference (EditAtSelectedMarker);
3831 } else if (choice == _("Playhead")) {
3832 set_edit_point_preference (EditAtPlayhead);
3834 set_edit_point_preference (EditAtMouse);
3837 RefPtr<RadioAction> ract = edit_point_action (ep);
3840 ract->set_active (true);
3845 Editor::zoom_focus_selection_done ()
3847 string choice = zoom_focus_selector.get_active_text();
3848 ZoomFocus focus_type = ZoomFocusLeft;
3850 if (choice == _("Left")) {
3851 focus_type = ZoomFocusLeft;
3852 } else if (choice == _("Right")) {
3853 focus_type = ZoomFocusRight;
3854 } else if (choice == _("Center")) {
3855 focus_type = ZoomFocusCenter;
3856 } else if (choice == _("Play")) {
3857 focus_type = ZoomFocusPlayhead;
3858 } else if (choice == _("Edit")) {
3859 focus_type = ZoomFocusEdit;
3860 } else if (choice == _("Active Mark")) {
3861 focus_type = ZoomFocusEdit;
3862 } else if (choice == _("Active Mark")) {
3863 focus_type = ZoomFocusEdit;
3865 focus_type = ZoomFocusMouse;
3868 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3871 ract->set_active ();
3876 Editor::edit_controls_button_release (GdkEventButton* ev)
3878 if (Keyboard::is_context_menu_event (ev)) {
3879 ARDOUR_UI::instance()->add_route (this);
3885 Editor::mouse_select_button_release (GdkEventButton* ev)
3887 /* this handles just right-clicks */
3889 if (ev->button != 3) {
3896 Editor::TrackViewList *
3897 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3900 TrackViewList::iterator i;
3902 v = new TrackViewList;
3904 if (track == 0 && group == 0) {
3908 for (i = track_views.begin(); i != track_views.end (); ++i) {
3912 } else if ((track != 0 && group == 0) || (track != 0 && group != 0 && !group->is_active())) {
3914 /* just the view for this track
3917 v->push_back (track);
3921 /* views for all tracks in the edit group */
3923 for (i = track_views.begin(); i != track_views.end (); ++i) {
3925 if (group == 0 || (*i)->edit_group() == group) {
3935 Editor::set_zoom_focus (ZoomFocus f)
3937 string str = zoom_focus_strings[(int)f];
3939 if (str != zoom_focus_selector.get_active_text()) {
3940 zoom_focus_selector.set_active_text (str);
3943 if (zoom_focus != f) {
3946 ZoomFocusChanged (); /* EMIT_SIGNAL */
3953 Editor::ensure_float (Window& win)
3955 win.set_transient_for (*this);
3959 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3961 /* recover or initialize pane positions. do this here rather than earlier because
3962 we don't want the positions to change the child allocations, which they seem to do.
3968 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3970 static int32_t done;
3973 width = default_width;
3974 height = default_height;
3976 if ((geometry = find_named_node (*node, "geometry")) != 0) {
3978 if ((prop = geometry->property ("x_size")) == 0) {
3979 prop = geometry->property ("x-size");
3982 width = atoi (prop->value());
3984 if ((prop = geometry->property ("y_size")) == 0) {
3985 prop = geometry->property ("y-size");
3988 height = atoi (prop->value());
3992 if (which == static_cast<Paned*> (&edit_pane)) {
3998 if (!geometry || (prop = geometry->property ("edit-pane-pos")) == 0) {
3999 /* initial allocation is 90% to canvas, 10% to notebook */
4000 pos = (int) floor (alloc.get_width() * 0.90f);
4001 snprintf (buf, sizeof(buf), "%d", pos);
4003 pos = atoi (prop->value());
4006 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
4007 edit_pane.set_position (pos);
4008 pre_maximal_pane_position = pos;
4014 Editor::detach_tearoff (Box* b, Window* w)
4016 if (tools_tearoff->torn_off() &&
4017 mouse_mode_tearoff->torn_off()) {
4018 top_hbox.remove (toolbar_frame);
4023 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
4025 if (toolbar_frame.get_parent() == 0) {
4026 top_hbox.pack_end (toolbar_frame);
4031 Editor::set_show_measures (bool yn)
4033 if (_show_measures != yn) {
4036 if ((_show_measures = yn) == true) {
4038 tempo_lines->show();
4046 Editor::toggle_follow_playhead ()
4048 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
4050 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
4051 set_follow_playhead (tact->get_active());
4056 Editor::set_follow_playhead (bool yn)
4058 if (_follow_playhead != yn) {
4059 if ((_follow_playhead = yn) == true) {
4061 update_current_screen ();
4068 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
4070 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
4072 xfade->set_active (!xfade->active());
4077 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
4079 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
4081 xfade->set_follow_overlap (!xfade->following_overlap());
4086 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
4088 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
4094 CrossfadeEditor cew (*session, xfade, xfade->fade_in().get_min_y(), 1.0);
4098 switch (cew.run ()) {
4099 case RESPONSE_ACCEPT:
4106 xfade->StateChanged (Change (~0));
4110 Editor::playlist_selector () const
4112 return *_playlist_selector;
4116 Editor::get_nudge_distance (nframes64_t pos, nframes64_t& next)
4120 ret = nudge_clock.current_duration (pos);
4121 next = ret + 1; /* XXXX fix me */
4127 Editor::end_location_changed (Location* location)
4129 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
4130 //reset_scrolling_region ();
4131 nframes64_t session_span = location->start() + (nframes64_t) floorf (current_page_frames() * 0.10f);
4132 horizontal_adjustment.set_upper (session_span / frames_per_unit);
4136 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
4138 ArdourDialog dialog ("playlist deletion dialog");
4139 Label label (string_compose (_("Playlist %1 is currently unused.\n"
4140 "If left alone, no audio files used by it will be cleaned.\n"
4141 "If deleted, audio files used by it alone by will cleaned."),
4144 dialog.set_position (WIN_POS_CENTER);
4145 dialog.get_vbox()->pack_start (label);
4149 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
4150 dialog.add_button (_("Keep playlist"), RESPONSE_REJECT);
4151 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
4153 switch (dialog.run ()) {
4154 case RESPONSE_ACCEPT:
4155 /* delete the playlist */
4159 case RESPONSE_REJECT:
4160 /* keep the playlist */
4172 Editor::audio_region_selection_covers (nframes64_t where)
4174 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
4175 if ((*a)->region()->covers (where)) {
4184 Editor::prepare_for_cleanup ()
4186 cut_buffer->clear_regions ();
4187 cut_buffer->clear_playlists ();
4189 selection->clear_regions ();
4190 selection->clear_playlists ();
4192 no_region_list_redisplay = true;
4196 Editor::finish_cleanup ()
4198 no_region_list_redisplay = false;
4199 redisplay_regions ();
4203 Editor::transport_loop_location()
4206 return session->locations()->auto_loop_location();
4213 Editor::transport_punch_location()
4216 return session->locations()->auto_punch_location();
4223 Editor::control_layout_scroll (GdkEventScroll* ev)
4225 switch (ev->direction) {
4227 scroll_tracks_up_line ();
4231 case GDK_SCROLL_DOWN:
4232 scroll_tracks_down_line ();
4236 /* no left/right handling yet */
4244 /** A new snapshot has been selected.
4247 Editor::snapshot_display_selection_changed ()
4249 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
4251 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
4253 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
4255 if (snap_name.length() == 0) {
4259 if (session->snap_name() == snap_name) {
4263 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
4268 Editor::snapshot_display_button_press (GdkEventButton* ev)
4270 if (ev->button == 3) {
4271 /* Right-click on the snapshot list. Work out which snapshot it
4273 Gtk::TreeModel::Path path;
4274 Gtk::TreeViewColumn* col;
4277 snapshot_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, col, cx, cy);
4278 Gtk::TreeModel::iterator iter = snapshot_display_model->get_iter (path);
4280 Gtk::TreeModel::Row row = *iter;
4281 popup_snapshot_context_menu (ev->button, ev->time, row[snapshot_display_columns.real_name]);
4290 /** Pop up the snapshot display context menu.
4291 * @param button Button used to open the menu.
4292 * @param time Menu open time.
4293 * @snapshot_name Name of the snapshot that the menu click was over.
4297 Editor::popup_snapshot_context_menu (int button, int32_t time, Glib::ustring snapshot_name)
4299 using namespace Menu_Helpers;
4301 MenuList& items (snapshot_context_menu.items());
4304 const bool modification_allowed = (session->snap_name() != snapshot_name && session->name() != snapshot_name);
4306 add_item_with_sensitivity (items, MenuElem (_("Remove"), bind (mem_fun (*this, &Editor::remove_snapshot), snapshot_name)), modification_allowed);
4308 add_item_with_sensitivity (items, MenuElem (_("Rename"), bind (mem_fun (*this, &Editor::rename_snapshot), snapshot_name)), modification_allowed);
4310 snapshot_context_menu.popup (button, time);
4314 Editor::rename_snapshot (Glib::ustring old_name)
4316 ArdourPrompter prompter(true);
4320 prompter.set_name ("Prompter");
4321 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
4322 prompter.set_prompt (_("New name of snapshot"));
4323 prompter.set_initial_text (old_name);
4325 if (prompter.run() == RESPONSE_ACCEPT) {
4326 prompter.get_result (new_name);
4327 if (new_name.length()) {
4328 session->rename_state (old_name, new_name);
4329 redisplay_snapshots ();
4336 Editor::remove_snapshot (Glib::ustring name)
4338 vector<string> choices;
4340 std::string prompt = string_compose (_("Do you really want to remove snapshot \"%1\" ?\n(cannot be undone)"), name);
4342 choices.push_back (_("No, do nothing."));
4343 choices.push_back (_("Yes, remove it."));
4345 Gtkmm2ext::Choice prompter (prompt, choices);
4347 if (prompter.run () == 1) {
4348 session->remove_state (name);
4349 redisplay_snapshots ();
4354 Editor::redisplay_snapshots ()
4360 vector<sys::path> state_file_paths;
4362 get_state_files_in_directory (session->session_directory().root_path(),
4365 if (state_file_paths.empty()) return;
4367 vector<string> state_file_names(get_file_names_no_extension(state_file_paths));
4369 snapshot_display_model->clear ();
4371 for (vector<string>::iterator i = state_file_names.begin();
4372 i != state_file_names.end(); ++i)
4374 string statename = (*i);
4375 TreeModel::Row row = *(snapshot_display_model->append());
4377 /* this lingers on in case we ever want to change the visible
4378 name of the snapshot.
4381 string display_name;
4382 display_name = statename;
4384 if (statename == session->snap_name()) {
4385 snapshot_display.get_selection()->select(row);
4388 row[snapshot_display_columns.visible_name] = display_name;
4389 row[snapshot_display_columns.real_name] = statename;
4394 Editor::session_state_saved (string snap_name)
4396 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4397 redisplay_snapshots ();
4401 Editor::maximise_editing_space ()
4403 mouse_mode_tearoff->set_visible (false);
4404 tools_tearoff->set_visible (false);
4406 pre_maximal_pane_position = edit_pane.get_position();
4407 pre_maximal_editor_width = this->get_width();
4409 if(post_maximal_pane_position == 0) {
4410 post_maximal_pane_position = edit_pane.get_width();
4415 if(post_maximal_editor_width) {
4416 edit_pane.set_position (post_maximal_pane_position -
4417 abs(post_maximal_editor_width - pre_maximal_editor_width));
4419 edit_pane.set_position (post_maximal_pane_position);
4424 Editor::restore_editing_space ()
4426 // user changed width of pane during fullscreen
4428 if(post_maximal_pane_position != edit_pane.get_position()) {
4429 post_maximal_pane_position = edit_pane.get_position();
4434 mouse_mode_tearoff->set_visible (true);
4435 tools_tearoff->set_visible (true);
4436 post_maximal_editor_width = this->get_width();
4438 edit_pane.set_position (pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width));
4442 * Make new playlists for a given track and also any others that belong
4443 * to the same active edit group.
4448 Editor::new_playlists (TimeAxisView* v)
4450 begin_reversible_command (_("new playlists"));
4451 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4452 session->get_playlists(playlists);
4453 mapover_tracks ( bind(mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v );
4454 commit_reversible_command ();
4458 * Use a copy of the current playlist for a given track and also any others that belong
4459 * to the same active edit group.
4464 Editor::copy_playlists (TimeAxisView* v)
4466 begin_reversible_command (_("copy playlists"));
4467 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4468 session->get_playlists(playlists);
4469 mapover_tracks ( bind(mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v );
4470 commit_reversible_command ();
4474 * Clear the current playlist for a given track and also any others that belong
4475 * to the same active edit group.
4480 Editor::clear_playlists (TimeAxisView* v)
4482 begin_reversible_command (_("clear playlists"));
4483 vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
4484 session->get_playlists(playlists);
4485 mapover_tracks ( mem_fun (*this, &Editor::mapped_clear_playlist), v );
4486 commit_reversible_command ();
4490 Editor::mapped_use_new_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4492 atv.use_new_playlist (sz > 1 ? false : true, playlists);
4496 Editor::mapped_use_copy_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
4498 atv.use_copy_playlist (sz > 1 ? false : true, playlists);
4502 Editor::mapped_clear_playlist (RouteTimeAxisView& atv, uint32_t sz)
4504 atv.clear_playlist ();
4508 Editor::on_key_press_event (GdkEventKey* ev)
4510 return key_press_focus_accelerator_handler (*this, ev);
4514 Editor::on_key_release_event (GdkEventKey* ev)
4516 return Gtk::Window::on_key_release_event (ev);
4517 // return key_press_focus_accelerator_handler (*this, ev);
4521 Editor::reset_x_origin (nframes64_t frame)
4523 //cerr << "resetting x origin" << endl;
4524 queue_visual_change (frame);
4528 Editor::reset_y_origin (double y)
4530 queue_visual_change_y (y);
4534 Editor::reset_zoom (double fpu)
4536 queue_visual_change (fpu);
4540 Editor::reposition_and_zoom (nframes64_t frame, double fpu)
4542 //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
4543 reset_x_origin (frame);
4546 if (!no_save_visual) {
4547 undo_visual_stack.push_back (current_visual_state(false));
4551 Editor::VisualState*
4552 Editor::current_visual_state (bool with_tracks)
4554 VisualState* vs = new VisualState;
4555 vs->y_position = vertical_adjustment.get_value();
4556 vs->frames_per_unit = frames_per_unit;
4557 vs->leftmost_frame = leftmost_frame;
4558 vs->zoom_focus = zoom_focus;
4559 vs->zoomed_to_region = zoomed_to_region;
4562 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4563 vs->track_states.push_back (TAVState ((*i), &(*i)->get_state()));
4571 Editor::undo_visual_state ()
4573 if (undo_visual_stack.empty()) {
4577 VisualState* vs = undo_visual_stack.back();
4578 undo_visual_stack.pop_back();
4579 use_visual_state (*vs);
4580 redo_visual_stack.push_back (vs);
4584 Editor::redo_visual_state ()
4586 if (redo_visual_stack.empty()) {
4590 VisualState* vs = redo_visual_stack.back();
4591 redo_visual_stack.pop_back();
4592 use_visual_state (*vs);
4593 undo_visual_stack.push_back (vs);
4597 Editor::swap_visual_state ()
4599 if (undo_visual_stack.empty()) {
4600 redo_visual_state ();
4602 undo_visual_state ();
4607 Editor::use_visual_state (VisualState& vs)
4609 no_save_visual = true;
4610 no_route_list_redisplay = true;
4612 vertical_adjustment.set_value (vs.y_position);
4614 set_zoom_focus (vs.zoom_focus);
4615 reposition_and_zoom (vs.leftmost_frame, vs.frames_per_unit);
4616 zoomed_to_region = vs.zoomed_to_region;
4618 for (list<TAVState>::iterator i = vs.track_states.begin(); i != vs.track_states.end(); ++i) {
4619 TrackViewList::iterator t;
4621 /* check if the track still exists - it could have been deleted */
4623 if ((t = find (track_views.begin(), track_views.end(), i->first)) != track_views.end()) {
4624 (*t)->set_state (*(i->second));
4629 if (!vs.track_states.empty()) {
4630 update_route_visibility ();
4633 no_route_list_redisplay = false;
4634 redisplay_route_list ();
4636 no_save_visual = false;
4640 Editor::set_frames_per_unit (double fpu)
4642 /* this is the core function that controls the zoom level of the canvas. it is called
4643 whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
4646 if (fpu == frames_per_unit) {
4655 /* don't allow zooms that fit more than the maximum number
4656 of frames into an 800 pixel wide space.
4659 if (max_frames / fpu < 800.0) {
4664 tempo_lines->tempo_map_changed();
4666 frames_per_unit = fpu;
4671 Editor::post_zoom ()
4673 nframes64_t cef = 0;
4675 // convert fpu to frame count
4677 nframes64_t frames = (nframes64_t) floor (frames_per_unit * _canvas_width);
4679 if (frames_per_unit != zoom_range_clock.current_duration()) {
4680 zoom_range_clock.set (frames);
4683 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
4684 if (!selection->tracks.empty()) {
4685 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4686 (*i)->reshow_selection (selection->time);
4689 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4690 (*i)->reshow_selection (selection->time);
4695 leftmost_frame = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4697 ZoomChanged (); /* EMIT_SIGNAL */
4699 reset_hscrollbar_stepping ();
4702 cef = session->current_end_frame() + (current_page_frames() / 10);// Add a little extra so we can see the end marker
4704 horizontal_adjustment.set_upper (cef / frames_per_unit);
4706 //reset_scrolling_region ();
4708 if (playhead_cursor) {
4709 playhead_cursor->set_position (playhead_cursor->current_frame);
4712 _summary->set_overlays_dirty ();
4718 Editor::queue_visual_change (nframes64_t where)
4720 pending_visual_change.add (VisualChange::TimeOrigin);
4722 /* if we're moving beyond the end, make sure the upper limit of the horizontal adjustment
4726 if (where > session->current_end_frame()) {
4727 horizontal_adjustment.set_upper ((where + current_page_frames()) / frames_per_unit);
4730 pending_visual_change.time_origin = where;
4732 ensure_visual_change_idle_handler ();
4736 Editor::queue_visual_change (double fpu)
4738 pending_visual_change.add (VisualChange::ZoomLevel);
4739 pending_visual_change.frames_per_unit = fpu;
4741 ensure_visual_change_idle_handler ();
4746 Editor::queue_visual_change_y (double y)
4748 pending_visual_change.add (VisualChange::YOrigin);
4749 pending_visual_change.y_origin = y;
4751 ensure_visual_change_idle_handler ();
4755 Editor::ensure_visual_change_idle_handler ()
4757 if (pending_visual_change.idle_handler_id < 0) {
4758 pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
4763 Editor::_idle_visual_changer (void* arg)
4765 return static_cast<Editor*>(arg)->idle_visual_changer ();
4769 Editor::idle_visual_changer ()
4771 VisualChange::Type p = pending_visual_change.pending;
4772 pending_visual_change.pending = (VisualChange::Type) 0;
4774 #ifdef FIX_THIS_FOR_V3
4775 double last_time_origin = horizontal_adjustment.get_value();
4778 if (p & VisualChange::ZoomLevel) {
4779 set_frames_per_unit (pending_visual_change.frames_per_unit);
4781 compute_fixed_ruler_scale ();
4782 compute_current_bbt_points(pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4783 compute_bbt_ruler_scale (pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames());
4784 update_tempo_based_rulers ();
4786 if (p & VisualChange::TimeOrigin) {
4787 horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
4789 if (p & VisualChange::YOrigin) {
4790 vertical_adjustment.set_value (pending_visual_change.y_origin);
4793 nframes64_t csf=0, cef=0;
4794 nframes64_t current_time_origin = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4797 csf = session->current_start_frame();
4798 cef = session->current_end_frame();
4801 /* if we seek beyond the current end of the canvas, move the end */
4803 #ifdef FIX_THIS_FOR_V3
4804 if (last_time_origin == horizontal_adjustment.get_value() ) {
4805 /* changed signal not emitted */
4806 update_fixed_rulers ();
4807 redisplay_tempo (true);
4811 if (current_time_origin != pending_visual_change.time_origin) {
4812 cef += current_page_frames() / 10; // Add a little extra so we can see the end marker
4813 horizontal_adjustment.set_upper (cef / frames_per_unit);
4814 horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
4816 update_fixed_rulers();
4817 redisplay_tempo (true);
4820 _summary->set_overlays_dirty ();
4822 //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
4823 pending_visual_change.idle_handler_id = -1;
4824 return 0; /* this is always a one-shot call */
4827 struct EditorOrderTimeAxisSorter {
4828 bool operator() (const TimeAxisView* a, const TimeAxisView* b) const {
4829 return a->order () < b->order ();
4834 Editor::sort_track_selection (TrackSelection* sel)
4836 EditorOrderTimeAxisSorter cmp;
4841 selection->tracks.sort (cmp);
4846 Editor::get_preferred_edit_position (bool ignore_playhead)
4849 nframes64_t where = 0;
4850 EditPoint ep = _edit_point;
4852 if (entered_marker) {
4853 return entered_marker->position();
4856 if (ignore_playhead && ep == EditAtPlayhead) {
4857 ep = EditAtSelectedMarker;
4861 case EditAtPlayhead:
4862 where = session->audible_frame();
4865 case EditAtSelectedMarker:
4866 if (!selection->markers.empty()) {
4868 Location* loc = find_location_from_marker (selection->markers.front(), is_start);
4871 where = loc->start();
4882 if (!mouse_frame (where, ignored)) {
4883 /* XXX not right but what can we do ? */
4894 Editor::set_loop_range (nframes64_t start, nframes64_t end, string cmd)
4896 if (!session) return;
4898 begin_reversible_command (cmd);
4902 if ((tll = transport_loop_location()) == 0) {
4903 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoLoop);
4904 XMLNode &before = session->locations()->get_state();
4905 session->locations()->add (loc, true);
4906 session->set_auto_loop_location (loc);
4907 XMLNode &after = session->locations()->get_state();
4908 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4910 XMLNode &before = tll->get_state();
4911 tll->set_hidden (false, this);
4912 tll->set (start, end);
4913 XMLNode &after = tll->get_state();
4914 session->add_command (new MementoCommand<Location>(*tll, &before, &after));
4917 commit_reversible_command ();
4921 Editor::set_punch_range (nframes64_t start, nframes64_t end, string cmd)
4923 if (!session) return;
4925 begin_reversible_command (cmd);
4929 if ((tpl = transport_punch_location()) == 0) {
4930 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoPunch);
4931 XMLNode &before = session->locations()->get_state();
4932 session->locations()->add (loc, true);
4933 session->set_auto_loop_location (loc);
4934 XMLNode &after = session->locations()->get_state();
4935 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4938 XMLNode &before = tpl->get_state();
4939 tpl->set_hidden (false, this);
4940 tpl->set (start, end);
4941 XMLNode &after = tpl->get_state();
4942 session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
4945 commit_reversible_command ();
4949 Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4951 const TrackSelection* tracks;
4954 tracks = &track_views;
4959 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4960 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4962 boost::shared_ptr<Diskstream> ds;
4963 boost::shared_ptr<Playlist> pl;
4965 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
4967 Playlist::RegionList* regions = pl->regions_at (
4968 (nframes64_t) floor ( (double)where * ds->speed()));
4970 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4971 RegionView* rv = rtv->view()->find_view (*i);
4984 Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4986 const TrackSelection* tracks;
4989 tracks = &track_views;
4994 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4995 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*t);
4997 boost::shared_ptr<Diskstream> ds;
4998 boost::shared_ptr<Playlist> pl;
5000 if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) {
5002 Playlist::RegionList* regions = pl->regions_touched (
5003 (nframes64_t) floor ( (double)where * ds->speed()), max_frames);
5005 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
5007 RegionView* rv = rtv->view()->find_view (*i);
5021 Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered)
5023 if (selection->regions.empty()) {
5025 if (selection->tracks.empty()) {
5027 /* no regions or tracks selected
5030 if (entered_regionview && mouse_mode == Editing::MouseObject) {
5032 /* entered regionview is valid and we're in object mode -
5033 just use entered regionview
5036 rs.add (entered_regionview);
5043 /* no regions selected, so get all regions at the edit point across
5044 all selected tracks.
5047 nframes64_t where = get_preferred_edit_position();
5048 get_regions_at (rs, where, selection->tracks);
5050 /* if the entered regionview wasn't selected and neither was its track
5054 if (entered_regionview != 0 &&
5055 !selection->selected (entered_regionview) &&
5056 !selection->selected (&entered_regionview->get_time_axis_view())) {
5057 rs.add (entered_regionview);
5063 /* just use the selected regions */
5065 rs = selection->regions;
5067 /* if the entered regionview wasn't selected and we allow this sort of thing,
5071 if (allow_entered && entered_regionview && !selection->selected (entered_regionview)) {
5072 rs.add (entered_regionview);
5079 Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<RegionView*>& regions)
5082 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
5084 RouteTimeAxisView* tatv;
5086 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
5088 boost::shared_ptr<Playlist> pl;
5089 vector<boost::shared_ptr<Region> > results;
5091 boost::shared_ptr<Diskstream> ds;
5093 if ((ds = tatv->get_diskstream()) == 0) {
5098 if ((pl = (ds->playlist())) != 0) {
5099 pl->get_region_list_equivalent_regions (region, results);
5102 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
5103 if ((marv = tatv->view()->find_view (*ir)) != 0) {
5104 regions.push_back (marv);
5113 Editor::show_rhythm_ferret ()
5115 if (rhythm_ferret == 0) {
5116 rhythm_ferret = new RhythmFerret(*this);
5119 rhythm_ferret->set_session (session);
5120 rhythm_ferret->show ();
5121 rhythm_ferret->present ();
5125 Editor::show_bundle_manager ()
5127 if (_bundle_manager == 0) {
5128 _bundle_manager = new BundleManager (*session);
5131 _bundle_manager->show ();
5135 Editor::show_global_port_matrix (ARDOUR::DataType t)
5137 if (_global_port_matrix[t] == 0) {
5138 _global_port_matrix[t] = new GlobalPortMatrixWindow (*session, t);
5141 _global_port_matrix[t]->show ();
5145 Editor::first_idle ()
5147 MessageDialog* dialog = 0;
5149 if (track_views.size() > 1) {
5150 dialog = new MessageDialog (*this,
5151 _("Please wait while Ardour loads visual data"),
5156 ARDOUR_UI::instance()->flush_pending ();
5159 for (TrackViewList::iterator t = track_views.begin(); t != track_views.end(); ++t) {
5163 // first idle adds route children (automation tracks), so we need to redisplay here
5164 redisplay_route_list();
5172 Editor::start_resize_line_ops ()
5175 old_resize_line_y = -1;
5177 need_resize_line = true;
5182 Editor::end_resize_line_ops ()
5185 need_resize_line = false;
5187 if (old_resize_line_y >= 0) {
5188 Gdk::Rectangle r (0, old_resize_line_y, (int) _canvas_width, 3);
5189 Glib::RefPtr<Gdk::Window> win = get_window();
5190 cerr << "Final invalidation at " << old_resize_line_y << endl;
5191 win->invalidate_rect (r, false);
5197 Editor::queue_draw_resize_line (int at)
5200 Glib::RefPtr<Gdk::Window> win = get_window();
5204 if (win && _canvas_width) {
5206 int controls_width = controls_layout.get_width();
5209 controls_layout.get_window()->get_origin (xroot, discard);
5211 if (old_resize_line_y >= 0) {
5213 /* redraw where it used to be */
5216 Gdk::Rectangle r (0, old_resize_line_y - 1, controls_width + (int) _canvas_width, 3);
5217 win->invalidate_rect (r, true);
5218 cerr << "invalidate " << xroot << "," << old_resize_line_y - 1 << ' '
5219 << controls_width + _canvas_width << " x 3\n";
5222 /* draw where it is */
5224 Gdk::Rectangle r (0, at - 1, controls_width + (int) _canvas_width, 3);
5225 win->invalidate_rect (r, true);
5231 Editor::on_expose_event (GdkEventExpose* ev)
5233 /* cerr << "+++ editor expose "
5234 << ev->area.x << ',' << ev->area.y
5236 << ev->area.width << " x " << ev->area.height
5237 << " need reize ? " << need_resize_line
5240 bool ret = Window::on_expose_event (ev);
5243 if (need_resize_line) {
5245 int xroot, yroot, discard;
5248 /* Our root coordinates for drawing the line will be the left edge
5249 of the track controls, and the upper left edge of our own window.
5252 get_window()->get_origin (discard, yroot);
5253 controls_layout.get_window()->get_origin (xroot, discard);
5254 controls_width = controls_layout.get_width();
5257 GdkRectangle intersection;
5260 lr.y = resize_line_y;
5261 lr.width = controls_width + (int) _canvas_width;
5264 if (gdk_rectangle_intersect (&lr, &ev->area, &intersection)) {
5266 Glib::RefPtr<Gtk::Style> style (get_style());
5267 Glib::RefPtr<Gdk::GC> black_gc (style->get_black_gc ());
5268 Glib::RefPtr<Gdk::GC> gc = wrap (black_gc->gobj_copy(), false);
5270 /* draw on root window */
5272 GdkWindow* win = gdk_get_default_root_window();
5274 gc->set_subwindow (Gdk::INCLUDE_INFERIORS);
5275 gc->set_line_attributes (3, Gdk::LINE_SOLID,
5279 gdk_draw_line (win, gc->gobj(),
5282 (int) _canvas_width + controls_width,
5285 cerr << "drew line @ " << xroot << ", " << yroot + resize_line_y
5286 << " to " << xroot + (int) _canvas_width + controls_width
5287 << ", " << yroot + resize_line_y
5290 old_resize_line_y = resize_line_y;
5291 cerr << "NEXT EXPOSE SHOULD BE AT " << old_resize_line_y << endl;
5293 cerr << "no intersect with "
5294 << lr.x << ',' << lr.y
5296 << lr.width << " x " << lr.height
5301 //cerr << "--- editor expose\n";
5308 _idle_resizer (gpointer arg)
5310 return ((Editor*)arg)->idle_resize ();
5314 Editor::add_to_idle_resize (TimeAxisView* view, uint32_t h)
5316 if (resize_idle_id < 0) {
5317 resize_idle_id = g_idle_add (_idle_resizer, this);
5320 resize_idle_target = h;
5322 pending_resizes.push_back (view);
5324 if (selection->selected (view) && !selection->tracks.empty()) {
5325 pending_resizes.insert (pending_resizes.end(), selection->tracks.begin(), selection->tracks.end());
5330 Editor::idle_resize ()
5332 for (vector<TimeAxisView*>::iterator i = pending_resizes.begin(); i != pending_resizes.end(); ++i) {
5333 (*i)->idle_resize (resize_idle_target);
5335 pending_resizes.clear();
5337 resize_idle_id = -1;
5344 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::located));
5346 _pending_locate_request = false;
5350 Editor::region_view_added (RegionView *)
5352 _summary->set_dirty ();
5356 Editor::streamview_height_changed ()
5358 _summary->set_dirty ();