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.
27 #include <boost/none.hpp>
29 #include <sigc++/bind.h>
31 #include <pbd/convert.h>
32 #include <pbd/error.h>
33 #include <pbd/enumwriter.h>
34 #include <pbd/memento_command.h>
36 #include <glibmm/miscutils.h>
37 #include <gtkmm/image.h>
38 #include <gdkmm/color.h>
39 #include <gdkmm/bitmap.h>
41 #include <gtkmm2ext/grouped_buttons.h>
42 #include <gtkmm2ext/gtk_ui.h>
43 #include <gtkmm2ext/tearoff.h>
44 #include <gtkmm2ext/utils.h>
45 #include <gtkmm2ext/window_title.h>
46 #include <gtkmm2ext/choice.h>
48 #include <ardour/audio_track.h>
49 #include <ardour/audio_diskstream.h>
50 #include <ardour/plugin_manager.h>
51 #include <ardour/location.h>
52 #include <ardour/audioplaylist.h>
53 #include <ardour/audioregion.h>
54 #include <ardour/region.h>
55 #include <ardour/session_route.h>
56 #include <ardour/tempo.h>
57 #include <ardour/utils.h>
58 #include <ardour/profile.h>
60 #include <control_protocol/control_protocol.h>
62 #include "ardour_ui.h"
66 #include "playlist_selector.h"
67 #include "audio_region_view.h"
68 #include "rgb_macros.h"
69 #include "selection.h"
70 #include "audio_streamview.h"
71 #include "time_axis_view.h"
72 #include "audio_time_axis.h"
74 #include "crossfade_view.h"
76 #include "public_editor.h"
77 #include "crossfade_edit.h"
78 #include "canvas_impl.h"
80 #include "gui_thread.h"
82 #include "rhythm_ferret.h"
86 #include "analysis_window.h"
92 #include "imageframe_socket_handler.h"
93 /* </CMT Additions> */
97 using namespace ARDOUR;
100 using namespace Glib;
101 using namespace Gtkmm2ext;
102 using namespace Editing;
106 const double Editor::timebar_height = 15.0;
108 #include "editor_xpms"
110 static const gchar *_snap_type_strings[] = {
132 static const gchar *_snap_mode_strings[] = {
139 static const gchar *_edit_point_strings[] = {
146 static const gchar *_zoom_focus_strings[] = {
156 #ifdef USE_RUBBERBAND
157 static const gchar *_rb_opt_strings[] = {
160 N_("Balanced multitimbral mixture"),
161 N_("Unpitched percussion with stable notes"),
162 N_("Crisp monophonic instrumental"),
163 N_("Unpitched solo percussion"),
168 /* Soundfile drag-n-drop */
170 Gdk::Cursor* Editor::cross_hair_cursor = 0;
171 Gdk::Cursor* Editor::selector_cursor = 0;
172 Gdk::Cursor* Editor::trimmer_cursor = 0;
173 Gdk::Cursor* Editor::grabber_cursor = 0;
174 Gdk::Cursor* Editor::grabber_edit_point_cursor = 0;
175 Gdk::Cursor* Editor::zoom_cursor = 0;
176 Gdk::Cursor* Editor::time_fx_cursor = 0;
177 Gdk::Cursor* Editor::fader_cursor = 0;
178 Gdk::Cursor* Editor::speaker_cursor = 0;
179 Gdk::Cursor* Editor::wait_cursor = 0;
180 Gdk::Cursor* Editor::timebar_cursor = 0;
181 Gdk::Cursor* Editor::transparent_cursor = 0;
184 show_me_the_size (Requisition* r, const char* what)
186 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
191 /* time display buttons */
192 minsec_label (_("Mins:Secs")),
193 bbt_label (_("Bars:Beats")),
194 smpte_label (_("Timecode")),
195 frame_label (_("Samples")),
196 tempo_label (_("Tempo")),
197 meter_label (_("Meter")),
198 mark_label (_("Location Markers")),
199 range_mark_label (_("Range Markers")),
200 transport_mark_label (_("Loop/Punch Ranges")),
201 cd_mark_label (_("CD Markers")),
203 edit_packer (3, 3, true),
205 /* the values here don't matter: layout widgets
206 reset them as needed.
209 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
210 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
212 /* tool bar related */
214 edit_point_clock (X_("editpoint"), false, X_("EditPointClock"), true),
215 zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true),
217 toolbar_selection_clock_table (2,3),
219 automation_mode_button (_("mode")),
220 global_automation_button (_("automation")),
222 /* <CMT Additions> */
223 image_socket_listener(0),
224 /* </CMT Additions> */
228 nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true),
229 meters_running(false)
234 /* we are a singleton */
236 PublicEditor::_instance = this;
241 selection = new Selection;
242 cut_buffer = new Selection;
244 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
245 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
246 selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
247 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
248 selection->MarkersChanged.connect (mem_fun(*this, &Editor::marker_selection_changed));
250 clicked_regionview = 0;
251 clicked_trackview = 0;
252 clicked_audio_trackview = 0;
253 clicked_crossfadeview = 0;
254 clicked_control_point = 0;
255 last_update_frame = 0;
257 drag_info.copied_location = 0;
258 current_mixer_strip = 0;
259 current_bbt_points = 0;
261 snap_type_strings = I18N (_snap_type_strings);
262 snap_mode_strings = I18N (_snap_mode_strings);
263 zoom_focus_strings = I18N (_zoom_focus_strings);
264 edit_point_strings = I18N (_edit_point_strings);
265 #ifdef USE_RUBBERBAND
266 rb_opt_strings = I18N (_rb_opt_strings);
269 snap_threshold = 5.0;
270 bbt_beat_subdivision = 4;
273 last_autoscroll_x = 0;
274 last_autoscroll_y = 0;
275 autoscroll_active = false;
276 autoscroll_timeout_tag = -1;
277 interthread_progress_window = 0;
284 current_interthread_info = 0;
285 _show_measures = true;
286 _show_waveforms = true;
287 _show_waveforms_recording = true;
288 first_action_message = 0;
290 export_range_markers_dialog = 0;
291 show_gain_after_trim = false;
292 ignore_route_list_reorder = false;
293 no_route_list_redisplay = false;
294 verbose_cursor_on = true;
295 route_removal = false;
296 show_automatic_regions_in_region_list = true;
297 last_item_entered = 0;
298 last_item_entered_n = 0;
300 region_list_sort_type = (Editing::RegionListSortType) 0;
301 have_pending_keyboard_selection = false;
302 _follow_playhead = true;
303 _xfade_visibility = true;
304 editor_ruler_menu = 0;
305 no_ruler_shown_update = false;
306 edit_group_list_menu = 0;
308 region_list_menu = 0;
310 start_end_marker_menu = 0;
311 range_marker_menu = 0;
312 marker_menu_item = 0;
314 transport_marker_menu = 0;
315 new_transport_marker_menu = 0;
316 editor_mixer_strip_width = Wide;
317 show_editor_mixer_when_tracks_arrive = false;
318 region_edit_menu_split_item = 0;
320 region_edit_menu_split_multichannel_item = 0;
322 ignore_mouse_mode_toggle = false;
323 current_stepping_trackview = 0;
325 entered_regionview = 0;
327 clear_entered_track = false;
328 _new_regionviews_show_envelope = false;
330 in_edit_group_row_change = false;
331 last_canvas_frame = 0;
333 button_release_can_deselect = true;
334 canvas_idle_queued = false;
335 _dragging_playhead = false;
336 _dragging_edit_point = false;
337 _dragging_hscrollbar = false;
338 select_new_marker = false;
339 zoomed_to_region = false;
341 allow_vertical_scroll = false;
342 no_save_visual = false;
343 need_resize_line = false;
345 old_resize_line_y = -1;
346 no_region_list_redisplay = false;
350 scrubbing_direction = 0;
353 ignore_route_order_sync = false;
355 location_marker_color = ARDOUR_UI::config()->canvasvar_LocationMarker.get();
356 location_range_color = ARDOUR_UI::config()->canvasvar_LocationRange.get();
357 location_cd_marker_color = ARDOUR_UI::config()->canvasvar_LocationCDMarker.get();
358 location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
359 location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
361 range_marker_drag_rect = 0;
362 marker_drag_line = 0;
364 set_mouse_mode (MouseObject, true);
366 frames_per_unit = 2048; /* too early to use reset_zoom () */
367 reset_hscrollbar_stepping ();
369 zoom_focus = ZoomFocusLeft;
370 set_zoom_focus (ZoomFocusLeft);
371 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
373 initialize_rulers ();
374 initialize_canvas ();
376 edit_controls_vbox.set_spacing (0);
377 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled), false);
378 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling), true);
380 track_canvas->set_hadjustment (horizontal_adjustment);
381 track_canvas->set_vadjustment (vertical_adjustment);
382 time_canvas->set_hadjustment (horizontal_adjustment);
384 track_canvas->signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
385 time_canvas->signal_map_event().connect (mem_fun (*this, &Editor::time_canvas_map_handler));
387 controls_layout.add (edit_controls_vbox);
388 controls_layout.set_name ("EditControlsBase");
389 controls_layout.add_events (Gdk::SCROLL_MASK);
390 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
392 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
393 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
394 controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
396 edit_vscrollbar.set_adjustment (vertical_adjustment);
397 edit_hscrollbar.set_adjustment (horizontal_adjustment);
399 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press), false);
400 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release), false);
401 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
403 edit_hscrollbar.set_name ("EditorHScrollbar");
408 edit_point_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_point_clock_changed));
410 time_canvas_vbox.pack_start (*_ruler_separator, false, false);
411 time_canvas_vbox.pack_start (*minsec_ruler, false, false);
412 time_canvas_vbox.pack_start (*smpte_ruler, false, false);
413 time_canvas_vbox.pack_start (*frames_ruler, false, false);
414 time_canvas_vbox.pack_start (*bbt_ruler, false, false);
415 time_canvas_vbox.pack_start (*time_canvas, true, true);
416 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars) + 2);
418 bbt_label.set_name ("EditorTimeButton");
419 bbt_label.set_size_request (-1, (int)timebar_height);
420 bbt_label.set_alignment (1.0, 0.5);
421 bbt_label.set_padding (5,0);
422 minsec_label.set_name ("EditorTimeButton");
423 minsec_label.set_size_request (-1, (int)timebar_height);
424 minsec_label.set_alignment (1.0, 0.5);
425 minsec_label.set_padding (5,0);
426 smpte_label.set_name ("EditorTimeButton");
427 smpte_label.set_size_request (-1, (int)timebar_height);
428 smpte_label.set_alignment (1.0, 0.5);
429 smpte_label.set_padding (5,0);
430 frame_label.set_name ("EditorTimeButton");
431 frame_label.set_size_request (-1, (int)timebar_height);
432 frame_label.set_alignment (1.0, 0.5);
433 frame_label.set_padding (5,0);
434 tempo_label.set_name ("EditorTimeButton");
435 tempo_label.set_size_request (-1, (int)timebar_height);
436 tempo_label.set_alignment (1.0, 0.5);
437 tempo_label.set_padding (5,0);
438 meter_label.set_name ("EditorTimeButton");
439 meter_label.set_size_request (-1, (int)timebar_height);
440 meter_label.set_alignment (1.0, 0.5);
441 meter_label.set_padding (5,0);
442 mark_label.set_name ("EditorTimeButton");
443 mark_label.set_size_request (-1, (int)timebar_height);
444 mark_label.set_alignment (1.0, 0.5);
445 mark_label.set_padding (5,0);
446 cd_mark_label.set_name ("EditorTimeButton");
447 cd_mark_label.set_size_request (-1, (int)timebar_height);
448 cd_mark_label.set_alignment (1.0, 0.5);
449 cd_mark_label.set_padding (5,0);
450 range_mark_label.set_name ("EditorTimeButton");
451 range_mark_label.set_size_request (-1, (int)timebar_height);
452 range_mark_label.set_alignment (1.0, 0.5);
453 range_mark_label.set_padding (5,0);
454 transport_mark_label.set_name ("EditorTimeButton");
455 transport_mark_label.set_size_request (-1, (int)timebar_height);
456 transport_mark_label.set_alignment (1.0, 0.5);
457 transport_mark_label.set_padding (5,0);
459 time_button_vbox.pack_start (minsec_label, false, false);
460 time_button_vbox.pack_start (smpte_label, false, false);
461 time_button_vbox.pack_start (frame_label, false, false);
462 time_button_vbox.pack_start (bbt_label, false, false);
463 time_button_vbox.pack_start (meter_label, false, false);
464 time_button_vbox.pack_start (tempo_label, false, false);
465 time_button_vbox.pack_start (mark_label, false, false);
467 time_button_event_box.add (time_button_vbox);
469 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
470 time_button_event_box.set_name ("TimebarLabelBase");
471 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
473 time_button_frame.add(time_button_event_box);
474 time_button_frame.property_shadow_type() = Gtk::SHADOW_OUT;
476 /* these enable us to have a dedicated window (for cursor setting, etc.)
477 for the canvas areas.
480 track_canvas_event_box.add (*track_canvas);
482 time_canvas_event_box.add (time_canvas_vbox);
483 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
485 edit_packer.set_col_spacings (0);
486 edit_packer.set_row_spacings (0);
487 edit_packer.set_homogeneous (false);
488 edit_packer.set_border_width (0);
489 edit_packer.set_name ("EditorWindow");
491 edit_packer.attach (edit_vscrollbar, 0, 1, 1, 3, FILL, FILL|EXPAND, 0, 0);
493 edit_packer.attach (time_button_frame, 0, 2, 0, 1, FILL, FILL, 0, 0);
494 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
496 edit_packer.attach (controls_layout, 1, 2, 1, 2, FILL, FILL|EXPAND, 0, 0);
497 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 2, FILL|EXPAND, FILL|EXPAND, 0, 0);
499 edit_packer.attach (zoom_box, 1, 2, 2, 3, FILL, FILL, 0, 0);
500 edit_packer.attach (edit_hscrollbar, 2, 3, 2, 3, FILL|EXPAND, FILL, 0, 0);
502 bottom_hbox.set_border_width (2);
503 bottom_hbox.set_spacing (3);
505 route_display_model = ListStore::create(route_display_columns);
506 route_list_display.set_model (route_display_model);
507 route_list_display.append_column (_("Show"), route_display_columns.visible);
508 route_list_display.append_column (_("Name"), route_display_columns.text);
509 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
510 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
511 route_list_display.set_headers_visible (true);
512 route_list_display.set_name ("TrackListDisplay");
513 route_list_display.get_selection()->set_mode (SELECTION_NONE);
514 route_list_display.set_reorderable (true);
515 route_list_display.set_size_request (100,-1);
517 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
518 route_list_visible_cell->property_activatable() = true;
519 route_list_visible_cell->property_radio() = false;
521 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
522 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
523 route_display_model->signal_rows_reordered().connect (mem_fun (*this, &Editor::track_list_reorder));
525 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
527 route_list_scroller.add (route_list_display);
528 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
530 group_model = ListStore::create(group_columns);
531 edit_group_display.set_model (group_model);
532 edit_group_display.append_column (_("Name"), group_columns.text);
533 edit_group_display.append_column (_("Active"), group_columns.is_active);
534 edit_group_display.append_column (_("Show"), group_columns.is_visible);
535 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
536 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
537 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
538 edit_group_display.get_column (0)->set_expand (true);
539 edit_group_display.get_column (1)->set_expand (false);
540 edit_group_display.get_column (2)->set_expand (false);
541 edit_group_display.set_headers_visible (true);
543 /* name is directly editable */
545 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
546 name_cell->property_editable() = true;
547 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
549 /* use checkbox for the active + visible columns */
551 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
552 active_cell->property_activatable() = true;
553 active_cell->property_radio() = false;
555 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
556 active_cell->property_activatable() = true;
557 active_cell->property_radio() = false;
559 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
561 edit_group_display.set_name ("EditGroupList");
562 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
563 edit_group_display.set_headers_visible (true);
564 edit_group_display.set_reorderable (false);
565 edit_group_display.set_rules_hint (true);
566 edit_group_display.set_size_request (75, -1);
568 edit_group_display_scroller.add (edit_group_display);
569 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
571 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
573 VBox* edit_group_display_packer = manage (new VBox());
574 HBox* edit_group_display_button_box = manage (new HBox());
575 edit_group_display_button_box->set_homogeneous (true);
577 Button* edit_group_add_button = manage (new Button ());
578 Button* edit_group_remove_button = manage (new Button ());
582 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
584 edit_group_add_button->add (*w);
586 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
588 edit_group_remove_button->add (*w);
590 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
591 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
593 edit_group_display_button_box->pack_start (*edit_group_add_button);
594 edit_group_display_button_box->pack_start (*edit_group_remove_button);
596 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
597 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
599 region_list_display.set_size_request (100, -1);
600 region_list_display.set_name ("RegionListDisplay");
601 /* Try to prevent single mouse presses from initiating edits.
602 This relies on a hack in gtktreeview.c:gtk_treeview_button_press()
604 region_list_display.set_data ("mouse-edits-require-mod1", (gpointer) 0x1);
606 region_list_model = TreeStore::create (region_list_columns);
607 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
608 region_list_model->set_sort_column (0, SORT_ASCENDING);
610 region_list_display.set_model (region_list_model);
611 region_list_display.append_column (_("Regions"), region_list_columns.name);
612 region_list_display.set_headers_visible (false);
614 CellRendererText* region_name_cell = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
615 region_name_cell->property_editable() = true;
616 region_name_cell->signal_edited().connect (mem_fun (*this, &Editor::region_name_edit));
618 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
620 TreeViewColumn* tv_col = region_list_display.get_column(0);
621 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
622 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
623 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
625 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
626 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
628 /* setup DnD handling */
630 list<TargetEntry> region_list_target_table;
632 region_list_target_table.push_back (TargetEntry ("text/plain"));
633 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
634 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
636 region_list_display.add_drop_targets (region_list_target_table);
637 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
639 region_list_scroller.add (region_list_display);
640 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
642 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
643 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
644 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
645 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
646 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
647 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
649 named_selection_scroller.add (named_selection_display);
650 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
652 named_selection_model = TreeStore::create (named_selection_columns);
653 named_selection_display.set_model (named_selection_model);
654 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
655 named_selection_display.set_headers_visible (false);
656 named_selection_display.set_size_request (100, -1);
657 named_selection_display.set_name ("NamedSelectionDisplay");
659 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
660 named_selection_display.set_size_request (100, -1);
661 named_selection_display.signal_button_release_event().connect (mem_fun(*this, &Editor::named_selection_display_button_release), false);
662 named_selection_display.signal_key_release_event().connect (mem_fun(*this, &Editor::named_selection_display_key_release), false);
663 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
667 snapshot_display_model = ListStore::create (snapshot_display_columns);
668 snapshot_display.set_model (snapshot_display_model);
669 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
670 snapshot_display.set_name ("SnapshotDisplay");
671 snapshot_display.set_size_request (75, -1);
672 snapshot_display.set_headers_visible (false);
673 snapshot_display.set_reorderable (false);
674 snapshot_display_scroller.add (snapshot_display);
675 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
677 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
678 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
682 nlabel = manage (new Label (_("Regions")));
683 nlabel->set_angle (-90);
684 the_notebook.append_page (region_list_scroller, *nlabel);
685 nlabel = manage (new Label (_("Tracks/Busses")));
686 nlabel->set_angle (-90);
687 the_notebook.append_page (route_list_scroller, *nlabel);
688 nlabel = manage (new Label (_("Snapshots")));
689 nlabel->set_angle (-90);
690 the_notebook.append_page (snapshot_display_scroller, *nlabel);
691 nlabel = manage (new Label (_("Edit Groups")));
692 nlabel->set_angle (-90);
693 the_notebook.append_page (*edit_group_display_packer, *nlabel);
695 if (!Profile->get_sae()) {
696 nlabel = manage (new Label (_("Chunks")));
697 nlabel->set_angle (-90);
698 the_notebook.append_page (named_selection_scroller, *nlabel);
701 the_notebook.set_show_tabs (true);
702 the_notebook.set_scrollable (true);
703 the_notebook.popup_enable ();
704 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
706 post_maximal_editor_width = 0;
707 post_maximal_pane_position = 0;
708 edit_pane.pack1 (edit_packer, true, true);
709 edit_pane.pack2 (the_notebook, false, true);
711 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
713 top_hbox.pack_start (toolbar_frame, true, true);
715 HBox *hbox = manage (new HBox);
716 hbox->pack_start (edit_pane, true, true);
718 global_vpacker.pack_start (top_hbox, false, false);
719 global_vpacker.pack_start (*hbox, true, true);
721 global_hpacker.pack_start (global_vpacker, true, true);
723 set_name ("EditorWindow");
724 add_accel_group (ActionManager::ui_manager->get_accel_group());
726 status_bar_hpacker.show ();
728 vpacker.pack_end (status_bar_hpacker, false, false);
729 vpacker.pack_end (global_hpacker, true, true);
731 /* register actions now so that set_state() can find them and set toggles/checks etc */
735 snap_type = SnapToBeat;
736 set_snap_to (snap_type);
738 set_snap_mode (snap_mode);
739 set_edit_point_preference (EditAtMouse, true);
741 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
744 _playlist_selector = new PlaylistSelector();
745 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
747 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
751 nudge_forward_button.add (*(manage (new Image (::get_icon("nudge_right")))));
752 nudge_backward_button.add (*(manage (new Image (::get_icon("nudge_left")))));
754 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
755 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
757 nudge_forward_button.set_name ("TransportButton");
758 nudge_backward_button.set_name ("TransportButton");
760 fade_context_menu.set_name ("ArdourContextMenu");
762 /* icons, titles, WM stuff */
764 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
765 Glib::RefPtr<Gdk::Pixbuf> icon;
767 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
768 window_icons.push_back (icon);
770 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
771 window_icons.push_back (icon);
773 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
774 window_icons.push_back (icon);
776 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
777 window_icons.push_back (icon);
779 if (!window_icons.empty()) {
780 set_icon_list (window_icons);
781 set_default_icon_list (window_icons);
784 WindowTitle title(Glib::get_application_name());
785 title += _("Editor");
786 set_title (title.get_string());
787 set_wmclass (X_("ardour_editor"), "Ardour");
790 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
792 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
793 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
795 /* allow external control surfaces/protocols to do various things */
797 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
798 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
799 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
800 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
801 BasicUI::AccessAction.connect (mem_fun (*this, &Editor::access_action));
803 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
804 Route::SyncOrderKeys.connect (mem_fun (*this, &Editor::sync_order_keys));
812 /* <CMT Additions> */
813 if(image_socket_listener)
815 if(image_socket_listener->is_connected())
817 image_socket_listener->close_connection() ;
820 delete image_socket_listener ;
821 image_socket_listener = 0 ;
823 /* </CMT Additions> */
837 Editor::add_toplevel_controls (Container& cont)
839 vpacker.pack_start (cont, false, false);
844 Editor::catch_vanishing_regionview (RegionView *rv)
846 /* note: the selection will take care of the vanishing
847 audioregionview by itself.
850 if (clicked_regionview == rv) {
851 clicked_regionview = 0;
854 if (entered_regionview == rv) {
855 set_entered_regionview (0);
860 Editor::set_entered_regionview (RegionView* rv)
862 if (rv == entered_regionview) {
866 if (entered_regionview) {
867 entered_regionview->exited ();
870 if ((entered_regionview = rv) != 0) {
871 entered_regionview->entered ();
876 Editor::set_entered_track (TimeAxisView* tav)
879 entered_track->exited ();
882 if ((entered_track = tav) != 0) {
883 entered_track->entered ();
888 Editor::show_window ()
893 /* now reset all audio_time_axis heights, because widgets might need
899 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
900 tv = (static_cast<TimeAxisView*>(*i));
906 Editor::instant_save ()
908 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
913 session->add_instant_xml(get_state(), session->path());
915 Config->add_instant_xml(get_state(), get_user_ardour_path());
920 Editor::edit_point_clock_changed()
922 if (_dragging_edit_point) {
926 if (selection->markers.empty()) {
931 Location* loc = find_location_from_marker (selection->markers.front(), ignored);
937 loc->move_to (edit_point_clock.current_time());
941 Editor::zoom_adjustment_changed ()
947 double fpu = zoom_range_clock.current_duration() / canvas_width;
951 zoom_range_clock.set ((nframes64_t) floor (fpu * canvas_width));
952 } else if (fpu > session->current_end_frame() / canvas_width) {
953 fpu = session->current_end_frame() / canvas_width;
954 zoom_range_clock.set ((nframes64_t) floor (fpu * canvas_width));
961 Editor::control_scroll (float fraction)
963 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
969 double step = fraction * current_page_frames();
972 _control_scroll_target is an optional<T>
974 it acts like a pointer to an nframes64_t, with
975 a operator conversion to boolean to check
976 that it has a value could possibly use
977 playhead_cursor->current_frame to store the
978 value and a boolean in the class to know
979 when it's out of date
982 if (!_control_scroll_target) {
983 _control_scroll_target = session->transport_frame();
984 _dragging_playhead = true;
987 if ((fraction < 0.0f) && (*_control_scroll_target < (nframes64_t) fabs(step))) {
988 *_control_scroll_target = 0;
989 } else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
990 *_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
992 *_control_scroll_target += (nframes64_t) floor (step);
995 /* move visuals, we'll catch up with it later */
997 playhead_cursor->set_position (*_control_scroll_target);
998 UpdateAllTransportClocks (*_control_scroll_target);
1000 if (*_control_scroll_target > (current_page_frames() / 2)) {
1001 /* try to center PH in window */
1002 reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
1008 Now we do a timeout to actually bring the session to the right place
1009 according to the playhead. This is to avoid reading disk buffers on every
1010 call to control_scroll, which is driven by ScrollTimeline and therefore
1011 probably by a control surface wheel which can generate lots of events.
1013 /* cancel the existing timeout */
1015 control_scroll_connection.disconnect ();
1017 /* add the next timeout */
1019 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), *_control_scroll_target), 250);
1023 Editor::deferred_control_scroll (nframes64_t target)
1025 session->request_locate (*_control_scroll_target, session->transport_rolling());
1026 // reset for next stream
1027 _control_scroll_target = boost::none;
1028 _dragging_playhead = false;
1033 Editor::access_action (std::string action_group, std::string action_item)
1039 ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::access_action), action_group, action_item));
1041 cout<< "OSC: Recieved: "<< action_item << endl;
1044 act = ActionManager::get_action( action_group.c_str(), action_item.c_str() );
1054 Editor::on_realize ()
1056 Window::on_realize ();
1061 Editor::start_scrolling ()
1063 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1064 (mem_fun(*this, &Editor::update_current_screen));
1068 Editor::stop_scrolling ()
1070 scroll_connection.disconnect ();
1074 Editor::map_position_change (nframes64_t frame)
1076 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1078 if (session == 0 || !_follow_playhead) {
1082 center_screen (frame);
1083 playhead_cursor->set_position (frame);
1087 Editor::center_screen (nframes64_t frame)
1089 double page = canvas_width * frames_per_unit;
1091 /* if we're off the page, then scroll.
1094 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1095 center_screen_internal (frame, page);
1100 Editor::center_screen_internal (nframes64_t frame, float page)
1105 frame -= (nframes64_t) page;
1110 reset_x_origin (frame);
1114 Editor::handle_new_duration ()
1116 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1118 nframes64_t new_end = session->get_maximum_extent() + (nframes64_t) floorf (current_page_frames() * 0.10f);
1120 if (new_end > last_canvas_frame) {
1121 last_canvas_frame = new_end;
1122 horizontal_adjustment.set_upper (last_canvas_frame / frames_per_unit);
1123 reset_scrolling_region ();
1126 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1127 //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() << ":" << last_canvas_frame << endl;//DEBUG
1131 Editor::update_title_s (const string & snap_name)
1133 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1139 Editor::update_title ()
1141 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1144 bool dirty = session->dirty();
1146 string session_name;
1148 if (session->snap_name() != session->name()) {
1149 session_name = session->snap_name();
1151 session_name = session->name();
1155 session_name = "*" + session_name;
1158 WindowTitle title(session_name);
1159 title += Glib::get_application_name();
1160 set_title (title.get_string());
1165 Editor::connect_to_session (Session *t)
1169 /* there are never any selected regions at startup */
1171 sensitize_the_right_region_actions (false);
1173 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1176 /* catch up with the playhead */
1178 session->request_locate (playhead_cursor->current_frame);
1180 if (first_action_message) {
1181 first_action_message->hide();
1186 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1187 session->history().Changed.connect (mem_fun (*this, &Editor::history_changed));
1189 /* These signals can all be emitted by a non-GUI thread. Therefore the
1190 handlers for them must not attempt to directly interact with the GUI,
1191 but use Gtkmm2ext::UI::instance()->call_slot();
1194 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1195 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1196 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1197 session_connections.push_back (session->AudioRegionsAdded.connect (mem_fun(*this, &Editor::handle_new_audio_regions)));
1198 session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::handle_audio_region_removed)));
1199 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1200 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1201 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1202 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1203 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1204 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1205 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1206 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1207 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1209 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1211 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1213 edit_groups_changed ();
1215 edit_point_clock.set_session (session);
1216 zoom_range_clock.set_session (session);
1217 _playlist_selector->set_session (session);
1218 nudge_clock.set_session (session);
1219 nudge_clock.set (session->frame_rate() * 5); // default of 5 seconds
1221 if (rhythm_ferret) {
1222 rhythm_ferret->set_session (session);
1226 if (analysis_window != 0)
1227 analysis_window->set_session (session);
1230 Location* loc = session->locations()->auto_loop_location();
1232 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1233 if (loc->start() == loc->end()) {
1234 loc->set_end (loc->start() + 1);
1236 session->locations()->add (loc, false);
1237 session->set_auto_loop_location (loc);
1240 loc->set_name (_("Loop"));
1243 loc = session->locations()->auto_punch_location();
1245 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1246 if (loc->start() == loc->end()) {
1247 loc->set_end (loc->start() + 1);
1249 session->locations()->add (loc, false);
1250 session->set_auto_punch_location (loc);
1253 loc->set_name (_("Punch"));
1256 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1258 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1260 refresh_location_display ();
1261 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1262 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1263 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1264 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1265 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1268 sfbrowser->set_session (session);
1271 handle_new_duration ();
1273 redisplay_regions ();
1274 redisplay_named_selections ();
1275 redisplay_snapshots ();
1277 initial_route_list_display ();
1279 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1280 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1283 restore_ruler_visibility ();
1284 //tempo_map_changed (Change (0));
1285 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1289 /* don't show master bus in a new session */
1291 if (ARDOUR_UI::instance()->session_is_new ()) {
1293 TreeModel::Children rows = route_display_model->children();
1294 TreeModel::Children::iterator i;
1296 no_route_list_redisplay = true;
1298 for (i = rows.begin(); i != rows.end(); ++i) {
1299 TimeAxisView *tv = (*i)[route_display_columns.tv];
1300 AudioTimeAxisView *atv;
1302 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1303 if (atv->route()->master()) {
1304 route_list_display.get_selection()->unselect (i);
1309 no_route_list_redisplay = false;
1310 redisplay_route_list ();
1313 switch (snap_type) {
1314 case SnapToRegionStart:
1315 case SnapToRegionEnd:
1316 case SnapToRegionSync:
1317 case SnapToRegionBoundary:
1318 build_region_boundary_cache ();
1325 /* register for undo history */
1327 session->register_with_memento_command_factory(_id, this);
1333 Editor::build_cursors ()
1335 using namespace Gdk;
1337 Gdk::Color mbg ("#000000" ); /* Black */
1338 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1341 RefPtr<Bitmap> source, mask;
1342 source = Bitmap::create (mag_bits, mag_width, mag_height);
1343 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1344 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1347 Gdk::Color fbg ("#ffffff" );
1348 Gdk::Color ffg ("#000000" );
1351 RefPtr<Bitmap> source, mask;
1353 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1354 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1355 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1359 RefPtr<Bitmap> source, mask;
1360 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1361 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1362 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1366 RefPtr<Bitmap> bits;
1367 char pix[4] = { 0, 0, 0, 0 };
1368 bits = Bitmap::create (pix, 2, 2);
1370 transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
1374 grabber_cursor = new Gdk::Cursor (HAND2);
1377 Glib::RefPtr<Gdk::Pixbuf> grabber_edit_point_pixbuf (::get_icon ("grabber_edit_point"));
1378 grabber_edit_point_cursor = new Gdk::Cursor (Gdk::Display::get_default(), grabber_edit_point_pixbuf, 5, 17);
1381 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1382 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1383 selector_cursor = new Gdk::Cursor (XTERM);
1384 time_fx_cursor = new Gdk::Cursor (SIZING);
1385 wait_cursor = new Gdk::Cursor (WATCH);
1386 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1390 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1392 using namespace Menu_Helpers;
1393 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1396 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1400 MenuList& items (fade_context_menu.items());
1404 switch (item_type) {
1406 case FadeInHandleItem:
1407 if (arv->audio_region()->fade_in_active()) {
1408 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_in_active), false)));
1410 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_in_active), true)));
1413 items.push_back (SeparatorElem());
1415 if (Profile->get_sae()) {
1416 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1417 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1419 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
1420 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
1421 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
1422 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
1423 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
1428 case FadeOutHandleItem:
1429 if (arv->audio_region()->fade_out_active()) {
1430 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*this, &Editor::set_fade_out_active), false)));
1432 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*this, &Editor::set_fade_out_active), true)));
1435 items.push_back (SeparatorElem());
1437 if (Profile->get_sae()) {
1438 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1439 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1441 items.push_back (MenuElem (_("Linear"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
1442 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
1443 items.push_back (MenuElem (_("Slow"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
1444 items.push_back (MenuElem (_("Fast"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
1445 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
1450 fatal << _("programming error: ")
1451 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1456 fade_context_menu.popup (button, time);
1460 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes64_t frame)
1462 using namespace Menu_Helpers;
1463 Menu* (Editor::*build_menu_function)(nframes64_t);
1466 switch (item_type) {
1468 case RegionViewName:
1469 case RegionViewNameHighlight:
1470 if (with_selection) {
1471 build_menu_function = &Editor::build_track_selection_context_menu;
1473 build_menu_function = &Editor::build_track_region_context_menu;
1478 if (with_selection) {
1479 build_menu_function = &Editor::build_track_selection_context_menu;
1481 build_menu_function = &Editor::build_track_context_menu;
1485 case CrossfadeViewItem:
1486 build_menu_function = &Editor::build_track_crossfade_context_menu;
1490 if (clicked_audio_trackview->get_diskstream()) {
1491 build_menu_function = &Editor::build_track_context_menu;
1493 build_menu_function = &Editor::build_track_bus_context_menu;
1498 /* probably shouldn't happen but if it does, we don't care */
1502 menu = (this->*build_menu_function)(frame);
1503 menu->set_name ("ArdourContextMenu");
1505 /* now handle specific situations */
1507 switch (item_type) {
1509 case RegionViewName:
1510 case RegionViewNameHighlight:
1511 if (!with_selection) {
1512 if (region_edit_menu_split_item) {
1513 if (clicked_regionview && clicked_regionview->region()->covers (get_preferred_edit_position())) {
1514 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, true);
1516 ActionManager::set_sensitive (ActionManager::edit_point_in_region_sensitive_actions, false);
1520 if (region_edit_menu_split_multichannel_item) {
1521 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1522 // GTK2FIX find the action, change its sensitivity
1523 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1525 // GTK2FIX see above
1526 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1535 case CrossfadeViewItem:
1542 /* probably shouldn't happen but if it does, we don't care */
1546 if (item_type != SelectionItem && clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
1548 /* Bounce to disk */
1550 using namespace Menu_Helpers;
1551 MenuList& edit_items = menu->items();
1553 edit_items.push_back (SeparatorElem());
1555 switch (clicked_audio_trackview->audio_track()->freeze_state()) {
1556 case AudioTrack::NoFreeze:
1557 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1560 case AudioTrack::Frozen:
1561 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1564 case AudioTrack::UnFrozen:
1565 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1571 menu->popup (button, time);
1575 Editor::build_track_context_menu (nframes64_t ignored)
1577 using namespace Menu_Helpers;
1579 MenuList& edit_items = track_context_menu.items();
1582 add_dstream_context_items (edit_items);
1583 return &track_context_menu;
1587 Editor::build_track_bus_context_menu (nframes64_t ignored)
1589 using namespace Menu_Helpers;
1591 MenuList& edit_items = track_context_menu.items();
1594 add_bus_context_items (edit_items);
1595 return &track_context_menu;
1599 Editor::build_track_region_context_menu (nframes64_t frame)
1601 using namespace Menu_Helpers;
1602 MenuList& edit_items = track_region_context_menu.items();
1605 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1608 boost::shared_ptr<Diskstream> ds;
1609 boost::shared_ptr<Playlist> pl;
1611 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1612 Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)frame * ds->speed()));
1614 if (selection->regions.size() > 1) {
1615 // there's already a multiple selection: just add a
1616 // single region context menu that will act on all
1618 boost::shared_ptr<Region> dummy_region; // = NULL
1619 add_region_context_items (atv->audio_view(), dummy_region, edit_items);
1621 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1622 add_region_context_items (atv->audio_view(), (*i), edit_items);
1630 add_dstream_context_items (edit_items);
1632 return &track_region_context_menu;
1636 Editor::build_track_crossfade_context_menu (nframes64_t frame)
1638 using namespace Menu_Helpers;
1639 MenuList& edit_items = track_crossfade_context_menu.items();
1640 edit_items.clear ();
1642 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1645 boost::shared_ptr<Diskstream> ds;
1646 boost::shared_ptr<Playlist> pl;
1647 boost::shared_ptr<AudioPlaylist> apl;
1649 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl)) != 0)) {
1651 Playlist::RegionList* regions = pl->regions_at (frame);
1652 AudioPlaylist::Crossfades xfades;
1654 apl->crossfades_at (frame, xfades);
1656 bool many = xfades.size() > 1;
1658 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1659 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1662 if (selection->regions.size() > 1) {
1663 // there's already a multiple selection: just add a
1664 // single region context menu that will act on all
1666 boost::shared_ptr<Region> dummy_region; // = NULL
1667 add_region_context_items (atv->audio_view(), dummy_region, edit_items);
1669 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1670 add_region_context_items (atv->audio_view(), (*i), edit_items);
1677 add_dstream_context_items (edit_items);
1679 return &track_crossfade_context_menu;
1684 Editor::analyze_region_selection()
1686 if (analysis_window == 0) {
1687 analysis_window = new AnalysisWindow();
1690 analysis_window->set_session(session);
1692 analysis_window->show_all();
1695 analysis_window->set_regionmode();
1696 analysis_window->analyze();
1698 analysis_window->present();
1702 Editor::analyze_range_selection()
1704 if (analysis_window == 0) {
1705 analysis_window = new AnalysisWindow();
1708 analysis_window->set_session(session);
1710 analysis_window->show_all();
1713 analysis_window->set_rangemode();
1714 analysis_window->analyze();
1716 analysis_window->present();
1718 #endif /* FFT_ANALYSIS */
1723 Editor::build_track_selection_context_menu (nframes64_t ignored)
1725 using namespace Menu_Helpers;
1726 MenuList& edit_items = track_selection_context_menu.items();
1727 edit_items.clear ();
1729 add_selection_context_items (edit_items);
1730 // edit_items.push_back (SeparatorElem());
1731 // add_dstream_context_items (edit_items);
1733 return &track_selection_context_menu;
1737 Editor::add_crossfade_context_items (AudioStreamView* view, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
1739 using namespace Menu_Helpers;
1740 Menu *xfade_menu = manage (new Menu);
1741 MenuList& items = xfade_menu->items();
1742 xfade_menu->set_name ("ArdourContextMenu");
1745 if (xfade->active()) {
1751 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), boost::weak_ptr<Crossfade> (xfade))));
1752 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), boost::weak_ptr<Crossfade> (xfade))));
1754 if (xfade->can_follow_overlap()) {
1756 if (xfade->following_overlap()) {
1757 str = _("Convert to short");
1759 str = _("Convert to full");
1762 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1766 str = xfade->out()->name();
1768 str += xfade->in()->name();
1770 str = _("Crossfade");
1773 edit_items.push_back (MenuElem (str, *xfade_menu));
1774 edit_items.push_back (SeparatorElem());
1778 Editor::xfade_edit_left_region ()
1780 if (clicked_crossfadeview) {
1781 clicked_crossfadeview->left_view.show_region_editor ();
1786 Editor::xfade_edit_right_region ()
1788 if (clicked_crossfadeview) {
1789 clicked_crossfadeview->right_view.show_region_editor ();
1794 Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1796 using namespace Menu_Helpers;
1797 Menu *region_menu = manage (new Menu);
1798 MenuList& items = region_menu->items();
1799 region_menu->set_name ("ArdourContextMenu");
1801 boost::shared_ptr<AudioRegion> ar;
1804 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1806 /* when this particular menu pops up, make the relevant region
1810 region_menu->signal_map_event().connect (
1812 mem_fun(*this, &Editor::set_selected_regionview_from_map_event),
1814 boost::weak_ptr<Region>(region)
1818 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &Editor::rename_region)));
1819 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1822 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1823 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1824 items.push_back (SeparatorElem());
1825 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_point)));
1826 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1827 items.push_back (SeparatorElem());
1829 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::play_selected_region)));
1830 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1831 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1834 items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_region_selection)));
1837 items.push_back (SeparatorElem());
1839 sigc::connection fooc;
1842 items.push_back (CheckMenuElem (_("Lock")));
1843 CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
1844 if (region->locked()) {
1845 region_lock_item->set_active();
1847 region_lock_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_lock));
1849 items.push_back (CheckMenuElem (_("Glue to Bars&Beats")));
1850 CheckMenuItem* bbt_glue_item = static_cast<CheckMenuItem*>(&items.back());
1852 switch (region->positional_lock_style()) {
1853 case Region::MusicTime:
1854 bbt_glue_item->set_active (true);
1857 bbt_glue_item->set_active (false);
1861 bbt_glue_item->signal_activate().connect (bind (mem_fun (*this, &Editor::set_region_lock_style), Region::MusicTime));
1863 items.push_back (CheckMenuElem (_("Mute")));
1864 CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
1865 fooc = region_mute_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_mute));
1866 if (region->muted()) {
1868 region_mute_item->set_active();
1872 if (!Profile->get_sae()) {
1873 items.push_back (CheckMenuElem (_("Opaque")));
1874 CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
1875 fooc = region_opaque_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_region_opaque));
1876 if (region->opaque()) {
1878 region_opaque_item->set_active();
1883 // multiple regions selected
1884 // how should these act?
1885 // here they toggle the property of all selected regions
1887 items.push_back (MenuElem (_("Lock"), mem_fun(*this, &Editor::toggle_region_lock)));
1888 items.push_back (MenuElem (_("Mute"), mem_fun(*this, &Editor::toggle_region_mute)));
1889 if (!Profile->get_sae()) {
1890 items.push_back (MenuElem (_("Opaque"), mem_fun(*this, &Editor::toggle_region_opaque)));
1894 items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1895 if (region && region->at_natural_position()) {
1896 items.back().set_sensitive (false);
1899 items.push_back (SeparatorElem());
1903 RegionView* rv = sv->find_view (ar);
1904 AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
1906 if (!Profile->get_sae()) {
1907 items.push_back (MenuElem (_("Reset Envelope"), mem_fun(*this, &Editor::reset_region_gain_envelopes)));
1909 items.push_back (CheckMenuElem (_("Envelope Visible")));
1910 CheckMenuItem* region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
1911 fooc = region_envelope_visible_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
1912 if (arv->envelope_visible()) {
1914 region_envelope_visible_item->set_active (true);
1918 items.push_back (CheckMenuElem (_("Envelope Active")));
1919 CheckMenuItem* region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
1920 fooc = region_envelope_active_item->signal_activate().connect (mem_fun(*this, &Editor::toggle_gain_envelope_active));
1922 if (ar->envelope_active()) {
1924 region_envelope_active_item->set_active (true);
1928 items.push_back (SeparatorElem());
1931 if (ar->scale_amplitude() != 1.0f) {
1932 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1934 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1938 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1939 items.push_back (SeparatorElem());
1941 /* range related stuff */
1943 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1944 items.push_back (MenuElem (_("Set Range Selection"), mem_fun (*this, &Editor::set_selection_from_audio_region)));
1945 items.push_back (SeparatorElem());
1949 Menu *nudge_menu = manage (new Menu());
1950 MenuList& nudge_items = nudge_menu->items();
1951 nudge_menu->set_name ("ArdourContextMenu");
1953 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false, false))));
1954 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false, false))));
1955 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1956 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1958 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1959 items.push_back (SeparatorElem());
1961 Menu *trim_menu = manage (new Menu);
1962 MenuList& trim_items = trim_menu->items();
1963 trim_menu->set_name ("ArdourContextMenu");
1965 trim_items.push_back (MenuElem (_("Start to edit point"), mem_fun(*this, &Editor::trim_region_from_edit_point)));
1966 trim_items.push_back (MenuElem (_("Edit point to end"), mem_fun(*this, &Editor::trim_region_to_edit_point)));
1967 trim_items.push_back (MenuElem (_("Trim To Loop"), mem_fun(*this, &Editor::trim_region_to_loop)));
1968 trim_items.push_back (MenuElem (_("Trim To Punch"), mem_fun(*this, &Editor::trim_region_to_punch)));
1970 items.push_back (MenuElem (_("Trim"), *trim_menu));
1971 items.push_back (SeparatorElem());
1973 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1974 region_edit_menu_split_item = &items.back();
1976 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1977 region_edit_menu_split_multichannel_item = &items.back();
1979 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), false))));
1980 items.push_back (MenuElem (_("Multi-Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1981 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1982 items.push_back (SeparatorElem());
1983 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_region)));
1985 /* OK, stick the region submenu at the top of the list, and then add
1989 /* we have to hack up the region name because "_" has a special
1990 meaning for menu titles.
1993 string::size_type pos = 0;
1994 string menu_item_name = (region) ? region->name() : _("Selected regions");
1996 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1997 menu_item_name.replace (pos, 1, "__");
2001 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
2002 edit_items.push_back (SeparatorElem());
2006 Editor::add_selection_context_items (Menu_Helpers::MenuList& items)
2008 using namespace Menu_Helpers;
2010 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
2011 items.push_back (MenuElem (_("Loop range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
2014 items.push_back (SeparatorElem());
2015 items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_range_selection)));
2018 items.push_back (SeparatorElem());
2019 items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
2020 items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
2022 items.push_back (SeparatorElem());
2023 items.push_back (MenuElem (_("Convert to region in-place"), mem_fun(*this, &Editor::separate_region_from_selection)));
2024 items.push_back (MenuElem (_("Convert to region in region list"), mem_fun(*this, &Editor::new_region_from_selection)));
2026 items.push_back (SeparatorElem());
2027 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
2029 items.push_back (SeparatorElem());
2030 items.push_back (MenuElem (_("Set loop from selection"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
2031 items.push_back (MenuElem (_("Set punch from selection"), mem_fun(*this, &Editor::set_punch_from_selection)));
2033 items.push_back (SeparatorElem());
2034 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
2035 items.push_back (SeparatorElem());
2036 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
2037 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
2038 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
2039 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::create_named_selection)));
2040 items.push_back (SeparatorElem());
2041 items.push_back (MenuElem (_("Consolidate range"), bind (mem_fun(*this, &Editor::bounce_range_selection), true)));
2042 items.push_back (MenuElem (_("Bounce range to region list"), bind (mem_fun(*this, &Editor::bounce_range_selection), false)));
2043 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
2047 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
2049 using namespace Menu_Helpers;
2053 Menu *play_menu = manage (new Menu);
2054 MenuList& play_items = play_menu->items();
2055 play_menu->set_name ("ArdourContextMenu");
2057 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
2058 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2059 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
2060 play_items.push_back (SeparatorElem());
2061 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
2063 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2067 Menu *select_menu = manage (new Menu);
2068 MenuList& select_items = select_menu->items();
2069 select_menu->set_name ("ArdourContextMenu");
2071 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2072 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2073 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2074 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2075 select_items.push_back (SeparatorElem());
2076 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
2077 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
2078 select_items.push_back (SeparatorElem());
2079 select_items.push_back (MenuElem (_("Select All After Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2080 select_items.push_back (MenuElem (_("Select All Before Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2081 select_items.push_back (MenuElem (_("Select All After Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2082 select_items.push_back (MenuElem (_("Select All Before Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2083 select_items.push_back (MenuElem (_("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), false)));
2084 select_items.push_back (MenuElem (_("Select All Within Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), true)));
2085 select_items.push_back (MenuElem (_("Select Range Between Playhead & Edit Point"), mem_fun(*this, &Editor::select_range_between)));
2087 select_items.push_back (SeparatorElem());
2089 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2093 Menu *cutnpaste_menu = manage (new Menu);
2094 MenuList& cutnpaste_items = cutnpaste_menu->items();
2095 cutnpaste_menu->set_name ("ArdourContextMenu");
2097 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2098 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2099 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2101 cutnpaste_items.push_back (SeparatorElem());
2103 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
2104 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
2106 cutnpaste_items.push_back (SeparatorElem());
2108 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
2110 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
2112 /* Adding new material */
2114 edit_items.push_back (SeparatorElem());
2115 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
2116 edit_items.push_back (MenuElem (_("Insert Existing Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
2120 Menu *nudge_menu = manage (new Menu());
2121 MenuList& nudge_items = nudge_menu->items();
2122 nudge_menu->set_name ("ArdourContextMenu");
2124 edit_items.push_back (SeparatorElem());
2125 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2126 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2127 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2128 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2130 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2134 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
2136 using namespace Menu_Helpers;
2140 Menu *play_menu = manage (new Menu);
2141 MenuList& play_items = play_menu->items();
2142 play_menu->set_name ("ArdourContextMenu");
2144 play_items.push_back (MenuElem (_("Play from edit point"), mem_fun(*this, &Editor::play_from_edit_point)));
2145 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
2146 edit_items.push_back (MenuElem (_("Play"), *play_menu));
2150 Menu *select_menu = manage (new Menu);
2151 MenuList& select_items = select_menu->items();
2152 select_menu->set_name ("ArdourContextMenu");
2154 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
2155 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
2156 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
2157 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
2158 select_items.push_back (SeparatorElem());
2159 select_items.push_back (MenuElem (_("Select all after edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), true)));
2160 select_items.push_back (MenuElem (_("Select all before edit point"), bind (mem_fun(*this, &Editor::select_all_selectables_using_edit), false)));
2161 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
2162 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
2164 edit_items.push_back (MenuElem (_("Select"), *select_menu));
2168 Menu *cutnpaste_menu = manage (new Menu);
2169 MenuList& cutnpaste_items = cutnpaste_menu->items();
2170 cutnpaste_menu->set_name ("ArdourContextMenu");
2172 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
2173 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
2174 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
2176 Menu *nudge_menu = manage (new Menu());
2177 MenuList& nudge_items = nudge_menu->items();
2178 nudge_menu->set_name ("ArdourContextMenu");
2180 edit_items.push_back (SeparatorElem());
2181 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
2182 nudge_items.push_back (MenuElem (_("Nudge track after edit point fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
2183 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
2184 nudge_items.push_back (MenuElem (_("Nudge track after edit point bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
2186 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
2190 Editor::set_snap_to (SnapType st)
2192 unsigned int snap_ind = (unsigned int)st;
2195 if (snap_ind > snap_type_strings.size() - 1) {
2197 snap_type = (SnapType)snap_ind;
2200 string str = snap_type_strings[snap_ind];
2202 if (str != snap_type_selector.get_active_text()) {
2203 snap_type_selector.set_active_text (str);
2208 switch (snap_type) {
2209 case SnapToAThirtysecondBeat:
2210 case SnapToASixteenthBeat:
2211 case SnapToAEighthBeat:
2212 case SnapToAQuarterBeat:
2213 case SnapToAThirdBeat:
2214 update_tempo_based_rulers ();
2217 case SnapToRegionStart:
2218 case SnapToRegionEnd:
2219 case SnapToRegionSync:
2220 case SnapToRegionBoundary:
2221 build_region_boundary_cache ();
2231 Editor::set_snap_mode (SnapMode mode)
2234 string str = snap_mode_strings[(int)mode];
2236 if (str != snap_mode_selector.get_active_text ()) {
2237 snap_mode_selector.set_active_text (str);
2243 Editor::set_edit_point_preference (EditPoint ep, bool force)
2245 bool changed = (_edit_point != ep);
2248 string str = edit_point_strings[(int)ep];
2250 if (str != edit_point_selector.get_active_text ()) {
2251 edit_point_selector.set_active_text (str);
2254 set_canvas_cursor ();
2256 if (!force && !changed) {
2260 switch (zoom_focus) {
2261 case ZoomFocusMouse:
2262 case ZoomFocusPlayhead:
2264 switch (_edit_point) {
2266 set_zoom_focus (ZoomFocusMouse);
2268 case EditAtPlayhead:
2269 set_zoom_focus (ZoomFocusPlayhead);
2271 case EditAtSelectedMarker:
2272 set_zoom_focus (ZoomFocusEdit);
2282 switch (_edit_point) {
2283 case EditAtPlayhead:
2284 action = "edit-at-playhead";
2286 case EditAtSelectedMarker:
2287 action = "edit-at-marker";
2290 action = "edit-at-mouse";
2294 Glib::RefPtr<Action> act = ActionManager::get_action ("Editor", action);
2296 Glib::RefPtr<RadioAction>::cast_dynamic(act)->set_active (true);
2300 bool in_track_canvas;
2302 if (!mouse_frame (foo, in_track_canvas)) {
2303 in_track_canvas = false;
2306 reset_canvas_action_sensitivity (in_track_canvas);
2312 Editor::set_state (const XMLNode& node)
2314 const XMLProperty* prop;
2316 int x, y, xoff, yoff;
2319 if ((prop = node.property ("id")) != 0) {
2320 _id = prop->value ();
2323 if ((geometry = find_named_node (node, "geometry")) == 0) {
2325 g.base_width = default_width;
2326 g.base_height = default_height;
2334 g.base_width = atoi(geometry->property("x_size")->value());
2335 g.base_height = atoi(geometry->property("y_size")->value());
2336 x = atoi(geometry->property("x_pos")->value());
2337 y = atoi(geometry->property("y_pos")->value());
2338 xoff = atoi(geometry->property("x_off")->value());
2339 yoff = atoi(geometry->property("y_off")->value());
2342 set_default_size (g.base_width, g.base_height);
2345 if (session && (prop = node.property ("playhead"))) {
2346 nframes64_t pos = atol (prop->value().c_str());
2347 playhead_cursor->set_position (pos);
2349 playhead_cursor->set_position (0);
2351 /* reset_x_origin() doesn't work right here, since the old
2352 position may be zero already, and it does nothing in such
2357 horizontal_adjustment.set_value (0);
2360 if ((prop = node.property ("mixer-width"))) {
2361 editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width));
2364 if ((prop = node.property ("zoom-focus"))) {
2365 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2368 if ((prop = node.property ("zoom"))) {
2369 reset_zoom (PBD::atof (prop->value()));
2372 if ((prop = node.property ("snap-to"))) {
2373 set_snap_to ((SnapType) atoi (prop->value()));
2376 if ((prop = node.property ("snap-mode"))) {
2377 set_snap_mode ((SnapMode) atoi (prop->value()));
2380 if ((prop = node.property ("edit-point"))) {
2381 set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point), true);
2384 if ((prop = node.property ("mouse-mode"))) {
2385 MouseMode m = str2mousemode(prop->value());
2386 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2387 set_mouse_mode (m, true);
2389 mouse_mode = MouseGain; /* lie, to force the mode switch */
2390 set_mouse_mode (MouseObject, true);
2393 if ((prop = node.property ("show-waveforms"))) {
2394 bool yn = (prop->value() == "yes");
2395 _show_waveforms = !yn;
2396 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-waveform-visible"));
2398 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2399 /* do it twice to force the change */
2400 tact->set_active (!yn);
2401 tact->set_active (yn);
2405 if ((prop = node.property ("show-waveforms-recording"))) {
2406 bool yn = (prop->value() == "yes");
2407 _show_waveforms_recording = !yn;
2408 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2410 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2411 /* do it twice to force the change */
2412 tact->set_active (!yn);
2413 tact->set_active (yn);
2417 if ((prop = node.property ("show-measures"))) {
2418 bool yn = (prop->value() == "yes");
2419 _show_measures = !yn;
2420 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2422 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2423 /* do it twice to force the change */
2424 tact->set_active (!yn);
2425 tact->set_active (yn);
2429 if ((prop = node.property ("follow-playhead"))) {
2430 bool yn = (prop->value() == "yes");
2431 set_follow_playhead (yn);
2432 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2434 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2435 if (tact->get_active() != yn) {
2436 tact->set_active (yn);
2441 if ((prop = node.property ("region-list-sort-type"))) {
2442 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2443 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2446 if ((prop = node.property ("xfades-visible"))) {
2447 bool yn = (prop->value() == "yes");
2448 _xfade_visibility = !yn;
2449 // set_xfade_visibility (yn);
2452 if ((prop = node.property ("show-editor-mixer"))) {
2454 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2457 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2458 bool yn = (prop->value() == X_("yes"));
2460 /* do it twice to force the change */
2462 tact->set_active (!yn);
2463 tact->set_active (yn);
2472 Editor::get_state ()
2474 XMLNode* node = new XMLNode ("Editor");
2477 _id.print (buf, sizeof (buf));
2478 node->add_property ("id", buf);
2480 if (is_realized()) {
2481 Glib::RefPtr<Gdk::Window> win = get_window();
2483 int x, y, xoff, yoff, width, height;
2484 win->get_root_origin(x, y);
2485 win->get_position(xoff, yoff);
2486 win->get_size(width, height);
2488 XMLNode* geometry = new XMLNode ("geometry");
2490 snprintf(buf, sizeof(buf), "%d", width);
2491 geometry->add_property("x_size", string(buf));
2492 snprintf(buf, sizeof(buf), "%d", height);
2493 geometry->add_property("y_size", string(buf));
2494 snprintf(buf, sizeof(buf), "%d", x);
2495 geometry->add_property("x_pos", string(buf));
2496 snprintf(buf, sizeof(buf), "%d", y);
2497 geometry->add_property("y_pos", string(buf));
2498 snprintf(buf, sizeof(buf), "%d", xoff);
2499 geometry->add_property("x_off", string(buf));
2500 snprintf(buf, sizeof(buf), "%d", yoff);
2501 geometry->add_property("y_off", string(buf));
2502 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2503 geometry->add_property("edit_pane_pos", string(buf));
2505 node->add_child_nocopy (*geometry);
2508 maybe_add_mixer_strip_width (*node);
2510 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2511 node->add_property ("zoom-focus", buf);
2512 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2513 node->add_property ("zoom", buf);
2514 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2515 node->add_property ("snap-to", buf);
2516 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2517 node->add_property ("snap-mode", buf);
2519 node->add_property ("edit-point", enum_2_string (_edit_point));
2521 snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame);
2522 node->add_property ("playhead", buf);
2524 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2525 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2526 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2527 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2528 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2529 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2530 node->add_property ("mouse-mode", enum2str(mouse_mode));
2532 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2534 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2535 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2544 Editor::trackview_by_y_position (double y)
2546 for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
2550 if ((tv = (*iter)->covers_y_position (y)) != 0) {
2559 Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
2561 if (!session || snap_mode == SnapOff) {
2565 snap_to_internal (start, direction, for_mark);
2569 Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
2571 Location* before = 0;
2572 Location* after = 0;
2574 const nframes64_t one_second = session->frame_rate();
2575 const nframes64_t one_minute = session->frame_rate() * 60;
2576 const nframes64_t one_smpte_second = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
2577 nframes64_t one_smpte_minute = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
2578 nframes64_t presnap = start;
2580 switch (snap_type) {
2582 if (((direction == 0) && (start % (one_second/75) > (one_second/75) / 2)) || (direction > 0)) {
2583 start = (nframes64_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2585 start = (nframes64_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2589 case SnapToSMPTEFrame:
2590 if (((direction == 0) && (fmod((double)start, (double)session->frames_per_smpte_frame()) > (session->frames_per_smpte_frame() / 2))) || (direction > 0)) {
2591 start = (nframes64_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2593 start = (nframes64_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2597 case SnapToSMPTESeconds:
2598 if (session->smpte_offset_negative())
2600 start += session->smpte_offset ();
2602 start -= session->smpte_offset ();
2604 if (((direction == 0) && (start % one_smpte_second > one_smpte_second / 2)) || direction > 0) {
2605 start = (nframes64_t) ceil ((double) start / one_smpte_second) * one_smpte_second;
2607 start = (nframes64_t) floor ((double) start / one_smpte_second) * one_smpte_second;
2610 if (session->smpte_offset_negative())
2612 start -= session->smpte_offset ();
2614 start += session->smpte_offset ();
2618 case SnapToSMPTEMinutes:
2619 if (session->smpte_offset_negative())
2621 start += session->smpte_offset ();
2623 start -= session->smpte_offset ();
2625 if (((direction == 0) && (start % one_smpte_minute > one_smpte_minute / 2)) || direction > 0) {
2626 start = (nframes64_t) ceil ((double) start / one_smpte_minute) * one_smpte_minute;
2628 start = (nframes64_t) floor ((double) start / one_smpte_minute) * one_smpte_minute;
2630 if (session->smpte_offset_negative())
2632 start -= session->smpte_offset ();
2634 start += session->smpte_offset ();
2639 if (((direction == 0) && (start % one_second > one_second / 2)) || (direction > 0)) {
2640 start = (nframes64_t) ceil ((double) start / one_second) * one_second;
2642 start = (nframes64_t) floor ((double) start / one_second) * one_second;
2647 if (((direction == 0) && (start % one_minute > one_minute / 2)) || (direction > 0)) {
2648 start = (nframes64_t) ceil ((double) start / one_minute) * one_minute;
2650 start = (nframes64_t) floor ((double) start / one_minute) * one_minute;
2655 start = session->tempo_map().round_to_bar (start, direction);
2659 start = session->tempo_map().round_to_beat (start, direction);
2662 case SnapToAThirtysecondBeat:
2663 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2666 case SnapToASixteenthBeat:
2667 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2670 case SnapToAEighthBeat:
2671 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2674 case SnapToAQuarterBeat:
2675 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2678 case SnapToAThirdBeat:
2679 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2687 before = session->locations()->first_location_before (start);
2688 after = session->locations()->first_location_after (start);
2690 if (direction < 0) {
2692 start = before->start();
2696 } else if (direction > 0) {
2698 start = after->start();
2700 start = session->current_end_frame();
2705 /* find nearest of the two */
2706 if ((start - before->start()) < (after->start() - start)) {
2707 start = before->start();
2709 start = after->start();
2712 start = before->start();
2715 start = after->start();
2722 case SnapToRegionStart:
2723 case SnapToRegionEnd:
2724 case SnapToRegionSync:
2725 case SnapToRegionBoundary:
2726 if (!region_boundary_cache.empty()) {
2727 vector<nframes64_t>::iterator i;
2729 if (direction > 0) {
2730 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2732 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2735 if (i != region_boundary_cache.end()) {
2737 /* lower bound doesn't quite to the right thing for our purposes */
2739 if (direction < 0 && i != region_boundary_cache.begin()) {
2746 start = region_boundary_cache.back();
2752 switch (snap_mode) {
2758 if (presnap > start) {
2759 if (presnap > (start + unit_to_frame(snap_threshold))) {
2763 } else if (presnap < start) {
2764 if (presnap < (start - unit_to_frame(snap_threshold))) {
2770 /* handled at entry */
2777 Editor::setup_toolbar ()
2782 const guint32 FUDGE = 38; // Combo's are stupid - they steal space from the entry for the button
2784 const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
2787 /* Mode Buttons (tool selection) */
2789 vector<ToggleButton *> mouse_mode_buttons;
2791 mouse_move_button.add (*(manage (new Image (::get_icon("tool_object")))));
2792 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2793 mouse_mode_buttons.push_back (&mouse_move_button);
2795 if (!Profile->get_sae()) {
2796 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2797 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2798 mouse_mode_buttons.push_back (&mouse_select_button);
2800 mouse_gain_button.add (*(manage (new Image (::get_icon("tool_gain")))));
2801 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2802 mouse_mode_buttons.push_back (&mouse_gain_button);
2805 mouse_zoom_button.add (*(manage (new Image (::get_icon("tool_zoom")))));
2806 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2807 mouse_mode_buttons.push_back (&mouse_zoom_button);
2808 mouse_timefx_button.add (*(manage (new Image (::get_icon("tool_stretch")))));
2809 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2810 mouse_mode_buttons.push_back (&mouse_timefx_button);
2811 mouse_audition_button.add (*(manage (new Image (::get_icon("tool_audition")))));
2812 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2813 mouse_mode_buttons.push_back (&mouse_audition_button);
2815 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2817 HBox* mode_box = manage(new HBox);
2818 mode_box->set_border_width (2);
2819 mode_box->set_spacing(4);
2820 mouse_mode_button_box.set_spacing(1);
2821 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2822 if (!Profile->get_sae()) {
2823 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2825 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2826 if (!Profile->get_sae()) {
2827 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2829 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2830 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2831 mouse_mode_button_box.set_homogeneous(true);
2833 vector<string> edit_mode_strings;
2834 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2835 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2836 edit_mode_strings.push_back (edit_mode_to_string (Lock));
2838 edit_mode_selector.set_name ("EditModeSelector");
2839 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, longest (edit_mode_strings).c_str(), 2+FUDGE, 10);
2840 set_popdown_strings (edit_mode_selector, edit_mode_strings);
2841 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2843 mode_box->pack_start(edit_mode_selector);
2844 mode_box->pack_start(mouse_mode_button_box);
2846 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2847 mouse_mode_tearoff->set_name ("MouseModeBase");
2849 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2850 &mouse_mode_tearoff->tearoff_window()));
2851 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2852 &mouse_mode_tearoff->tearoff_window(), 1));
2853 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2854 &mouse_mode_tearoff->tearoff_window()));
2855 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2856 &mouse_mode_tearoff->tearoff_window(), 1));
2858 mouse_move_button.set_name ("MouseModeButton");
2859 mouse_select_button.set_name ("MouseModeButton");
2860 mouse_gain_button.set_name ("MouseModeButton");
2861 mouse_zoom_button.set_name ("MouseModeButton");
2862 mouse_timefx_button.set_name ("MouseModeButton");
2863 mouse_audition_button.set_name ("MouseModeButton");
2865 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
2866 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
2867 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
2868 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
2869 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
2870 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
2872 mouse_move_button.unset_flags (CAN_FOCUS);
2873 mouse_select_button.unset_flags (CAN_FOCUS);
2874 mouse_gain_button.unset_flags (CAN_FOCUS);
2875 mouse_zoom_button.unset_flags (CAN_FOCUS);
2876 mouse_timefx_button.unset_flags (CAN_FOCUS);
2877 mouse_audition_button.unset_flags (CAN_FOCUS);
2879 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2880 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2882 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2883 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2884 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2885 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2886 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2888 // mouse_move_button.set_active (true);
2893 zoom_box.set_spacing (1);
2894 zoom_box.set_border_width (2);
2896 zoom_in_button.set_name ("EditorTimeButton");
2897 zoom_in_button.set_size_request(-1,16);
2898 zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in")))));
2899 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2900 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2902 zoom_out_button.set_name ("EditorTimeButton");
2903 zoom_out_button.set_size_request(-1,16);
2904 zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out")))));
2905 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2906 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2908 zoom_out_full_button.set_name ("EditorTimeButton");
2909 zoom_out_full_button.set_size_request(-1,16);
2910 zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full")))));
2911 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2912 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2914 zoom_focus_selector.set_name ("ZoomFocusSelector");
2915 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, _("Playhead"), FUDGE, 0);
2916 set_popdown_strings (zoom_focus_selector, zoom_focus_strings);
2917 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2918 ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
2920 zoom_box.pack_start (zoom_focus_selector, true, true);
2921 zoom_box.pack_start (zoom_out_button, false, false);
2922 zoom_box.pack_start (zoom_in_button, false, false);
2923 zoom_box.pack_start (zoom_out_full_button, false, false);
2925 snap_box.set_spacing (1);
2926 snap_box.set_border_width (2);
2928 snap_type_selector.set_name ("SnapTypeSelector");
2929 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, _("SMPTE Seconds"), 2+FUDGE, 10);
2930 set_popdown_strings (snap_type_selector, snap_type_strings);
2931 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2932 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Snap/Grid Units"));
2934 snap_mode_selector.set_name ("SnapModeSelector");
2935 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, _("Magnetic Snap"), 2+FUDGE, 10);
2936 set_popdown_strings (snap_mode_selector, snap_mode_strings);
2937 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2938 ARDOUR_UI::instance()->tooltips().set_tip (snap_mode_selector, _("Snap/Grid Mode"));
2940 edit_point_selector.set_name ("SnapModeSelector");
2941 Gtkmm2ext::set_size_request_to_display_given_text (edit_point_selector, _("Playhead"), 2+FUDGE, 10);
2942 set_popdown_strings (edit_point_selector, edit_point_strings);
2943 edit_point_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_point_selection_done));
2944 ARDOUR_UI::instance()->tooltips().set_tip (edit_point_selector, _("Edit point"));
2946 snap_box.pack_start (edit_point_clock, false, false);
2947 snap_box.pack_start (snap_mode_selector, false, false);
2948 snap_box.pack_start (snap_type_selector, false, false);
2949 snap_box.pack_start (edit_point_selector, false, false);
2953 HBox *nudge_box = manage (new HBox);
2954 nudge_box->set_spacing(1);
2955 nudge_box->set_border_width (2);
2957 nudge_forward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_forward_release), false);
2958 nudge_backward_button.signal_button_release_event().connect (mem_fun(*this, &Editor::nudge_backward_release), false);
2960 nudge_box->pack_start (nudge_backward_button, false, false);
2961 nudge_box->pack_start (nudge_forward_button, false, false);
2962 nudge_box->pack_start (nudge_clock, false, false);
2965 /* Pack everything in... */
2967 HBox* hbox = new HBox;
2968 hbox->set_spacing(10);
2970 tools_tearoff = new TearOff (*hbox);
2971 tools_tearoff->set_name ("MouseModeBase");
2973 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2974 &tools_tearoff->tearoff_window()));
2975 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2976 &tools_tearoff->tearoff_window(), 0));
2977 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2978 &tools_tearoff->tearoff_window()));
2979 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2980 &tools_tearoff->tearoff_window(), 0));
2982 toolbar_hbox.set_spacing (10);
2983 toolbar_hbox.set_border_width (1);
2985 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2986 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2989 hbox->pack_start (snap_box, false, false);
2990 // hbox->pack_start (zoom_box, false, false);
2991 hbox->pack_start (*nudge_box, false, false);
2995 toolbar_base.set_name ("ToolBarBase");
2996 toolbar_base.add (toolbar_hbox);
2998 toolbar_frame.set_shadow_type (SHADOW_OUT);
2999 toolbar_frame.set_name ("BaseFrame");
3000 toolbar_frame.add (toolbar_base);
3004 Editor::convert_drop_to_paths (vector<ustring>& paths,
3005 const RefPtr<Gdk::DragContext>& context,
3008 const SelectionData& data,
3017 vector<ustring> uris = data.get_uris();
3021 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
3022 are actually URI lists. So do it by hand.
3025 if (data.get_target() != "text/plain") {
3029 /* Parse the "uri-list" format that Nautilus provides,
3030 where each pathname is delimited by \r\n
3033 const char* p = data.get_text().c_str();
3040 while (g_ascii_isspace (*p))
3044 while (*q && (*q != '\n') && (*q != '\r'))
3050 while (q > p && g_ascii_isspace (*q))
3055 uris.push_back (ustring (p, q - p + 1));
3059 p = strchr (p, '\n');
3069 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
3071 if ((*i).substr (0,7) == "file://") {
3075 PBD::url_decode (p);
3077 // scan forward past three slashes
3079 ustring::size_type slashcnt = 0;
3080 ustring::size_type n = 0;
3081 ustring::iterator x = p.begin();
3083 while (slashcnt < 3 && x != p.end()) {
3086 } else if (slashcnt == 3) {
3093 if (slashcnt != 3 || x == p.end()) {
3094 error << _("malformed URL passed to drag-n-drop code") << endmsg;
3098 paths.push_back (p.substr (n - 1));
3106 Editor::new_tempo_section ()
3112 Editor::map_transport_state ()
3114 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
3116 if (session->transport_stopped()) {
3117 have_pending_keyboard_selection = false;
3120 update_loop_range_view (true);
3125 Editor::State::State ()
3127 selection = new Selection;
3130 Editor::State::~State ()
3136 Editor::get_memento () const
3138 State *state = new State;
3140 store_state (*state);
3141 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
3145 Editor::store_state (State& state) const
3147 *state.selection = *selection;
3151 Editor::restore_state (State *state)
3153 if (*selection == *state->selection) {
3157 *selection = *state->selection;
3158 time_selection_changed ();
3159 region_selection_changed ();
3161 /* XXX other selection change handlers? */
3165 Editor::begin_reversible_command (string name)
3168 // before = &get_state();
3169 session->begin_reversible_command (name);
3174 Editor::commit_reversible_command ()
3177 // session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
3178 session->commit_reversible_command ();
3183 Editor::set_edit_group_solo (Route& route, bool yn)
3185 RouteGroup *edit_group;
3187 if ((edit_group = route.edit_group()) != 0) {
3188 edit_group->apply (&Route::set_solo, yn, this);
3190 route.set_solo (yn, this);
3195 Editor::set_edit_group_mute (Route& route, bool yn)
3197 RouteGroup *edit_group = 0;
3199 if ((edit_group == route.edit_group()) != 0) {
3200 edit_group->apply (&Route::set_mute, yn, this);
3202 route.set_mute (yn, this);
3207 Editor::history_changed ()
3211 if (undo_action && session) {
3212 if (session->undo_depth() == 0) {
3215 label = string_compose(_("Undo (%1)"), session->next_undo());
3217 undo_action->property_label() = label;
3220 if (redo_action && session) {
3221 if (session->redo_depth() == 0) {
3224 label = string_compose(_("Redo (%1)"), session->next_redo());
3226 redo_action->property_label() = label;
3231 Editor::duplicate_dialog (bool with_dialog)
3235 if (mouse_mode == MouseRange) {
3236 if (selection->time.length() == 0) {
3242 get_regions_for_action (rs);
3244 if (mouse_mode != MouseRange) {
3253 ArdourDialog win ("Duplication Dialog");
3254 Label label (_("Number of Duplications:"));
3255 Adjustment adjustment (1.0, 1.0, 1000000.0, 1.0, 5.0);
3256 SpinButton spinner (adjustment, 0.0, 1);
3259 win.get_vbox()->set_spacing (12);
3260 win.get_vbox()->pack_start (hbox);
3261 hbox.set_border_width (6);
3262 hbox.pack_start (label, PACK_EXPAND_PADDING, 12);
3264 /* dialogs have ::add_action_widget() but that puts the spinner in the wrong
3265 place, visually. so do this by hand.
3268 hbox.pack_start (spinner, PACK_EXPAND_PADDING, 12);
3269 spinner.signal_activate().connect (sigc::bind (mem_fun (win, &ArdourDialog::response), RESPONSE_ACCEPT));
3270 spinner.grab_focus();
3276 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3277 win.add_button (_("Duplicate"), RESPONSE_ACCEPT);
3278 win.set_default_response (RESPONSE_ACCEPT);
3280 win.set_position (WIN_POS_MOUSE);
3282 spinner.grab_focus ();
3284 switch (win.run ()) {
3285 case RESPONSE_ACCEPT:
3291 times = adjustment.get_value();
3294 if (mouse_mode == MouseRange) {
3295 duplicate_selection (times);
3297 duplicate_some_regions (rs, times);
3302 Editor::show_verbose_canvas_cursor ()
3304 verbose_canvas_cursor->raise_to_top();
3305 verbose_canvas_cursor->show();
3306 verbose_cursor_visible = true;
3310 Editor::hide_verbose_canvas_cursor ()
3312 verbose_canvas_cursor->hide();
3313 verbose_cursor_visible = false;
3317 Editor::clamp_verbose_cursor_x (double x)
3319 return min (horizontal_adjustment.get_value() + canvas_width - 75.0, x);
3323 Editor::clamp_verbose_cursor_y (double y)
3325 return min (vertical_adjustment.get_value() + canvas_height - 50.0, y);
3329 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3331 verbose_canvas_cursor->property_text() = txt.c_str();
3332 /* don't get too close to the edge */
3333 verbose_canvas_cursor->property_x() = clamp_verbose_cursor_x (x);
3334 verbose_canvas_cursor->property_y() = clamp_verbose_cursor_x (y);
3338 Editor::set_verbose_canvas_cursor_text (const string & txt)
3340 verbose_canvas_cursor->property_text() = txt.c_str();
3344 Editor::set_edit_mode (EditMode m)
3346 Config->set_edit_mode (m);
3350 Editor::cycle_edit_mode ()
3352 switch (Config->get_edit_mode()) {
3354 Config->set_edit_mode (Splice);
3357 Config->set_edit_mode (Lock);
3360 Config->set_edit_mode (Slide);
3366 Editor::edit_mode_selection_done ()
3372 string choice = edit_mode_selector.get_active_text();
3373 EditMode mode = Slide;
3375 if (choice == _("Splice Edit")) {
3377 } else if (choice == _("Slide Edit")) {
3379 } else if (choice == _("Lock Edit")) {
3383 Config->set_edit_mode (mode);
3387 Editor::snap_type_selection_done ()
3389 string choice = snap_type_selector.get_active_text();
3390 SnapType snaptype = SnapToBeat;
3392 if (choice == _("Beats/3")) {
3393 snaptype = SnapToAThirdBeat;
3394 } else if (choice == _("Beats/4")) {
3395 snaptype = SnapToAQuarterBeat;
3396 } else if (choice == _("Beats/8")) {
3397 snaptype = SnapToAEighthBeat;
3398 } else if (choice == _("Beats/16")) {
3399 snaptype = SnapToASixteenthBeat;
3400 } else if (choice == _("Beats/32")) {
3401 snaptype = SnapToAThirtysecondBeat;
3402 } else if (choice == _("Beats")) {
3403 snaptype = SnapToBeat;
3404 } else if (choice == _("Bars")) {
3405 snaptype = SnapToBar;
3406 } else if (choice == _("Marks")) {
3407 snaptype = SnapToMark;
3408 } else if (choice == _("Region starts")) {
3409 snaptype = SnapToRegionStart;
3410 } else if (choice == _("Region ends")) {
3411 snaptype = SnapToRegionEnd;
3412 } else if (choice == _("Region bounds")) {
3413 snaptype = SnapToRegionBoundary;
3414 } else if (choice == _("Region syncs")) {
3415 snaptype = SnapToRegionSync;
3416 } else if (choice == _("CD Frames")) {
3417 snaptype = SnapToCDFrame;
3418 } else if (choice == _("SMPTE Frames")) {
3419 snaptype = SnapToSMPTEFrame;
3420 } else if (choice == _("SMPTE Seconds")) {
3421 snaptype = SnapToSMPTESeconds;
3422 } else if (choice == _("SMPTE Minutes")) {
3423 snaptype = SnapToSMPTEMinutes;
3424 } else if (choice == _("Seconds")) {
3425 snaptype = SnapToSeconds;
3426 } else if (choice == _("Minutes")) {
3427 snaptype = SnapToMinutes;
3430 RefPtr<RadioAction> ract = snap_type_action (snaptype);
3432 ract->set_active ();
3437 Editor::snap_mode_selection_done ()
3439 string choice = snap_mode_selector.get_active_text();
3440 SnapMode mode = SnapNormal;
3442 if (choice == _("No Grid")) {
3444 } else if (choice == _("Grid")) {
3446 } else if (choice == _("Magnetic")) {
3447 mode = SnapMagnetic;
3450 RefPtr<RadioAction> ract = snap_mode_action (mode);
3453 ract->set_active (true);
3458 Editor::cycle_edit_point (bool with_marker)
3460 switch (_edit_point) {
3462 set_edit_point_preference (EditAtPlayhead);
3464 case EditAtPlayhead:
3466 set_edit_point_preference (EditAtSelectedMarker);
3468 set_edit_point_preference (EditAtMouse);
3471 case EditAtSelectedMarker:
3472 set_edit_point_preference (EditAtMouse);
3478 Editor::edit_point_selection_done ()
3480 string choice = edit_point_selector.get_active_text();
3481 EditPoint ep = EditAtSelectedMarker;
3483 if (choice == _("Marker")) {
3484 set_edit_point_preference (EditAtSelectedMarker);
3485 } else if (choice == _("Playhead")) {
3486 set_edit_point_preference (EditAtPlayhead);
3488 set_edit_point_preference (EditAtMouse);
3491 RefPtr<RadioAction> ract = edit_point_action (ep);
3494 ract->set_active (true);
3499 Editor::zoom_focus_selection_done ()
3501 string choice = zoom_focus_selector.get_active_text();
3502 ZoomFocus focus_type = ZoomFocusLeft;
3504 if (choice == _("Left")) {
3505 focus_type = ZoomFocusLeft;
3506 } else if (choice == _("Right")) {
3507 focus_type = ZoomFocusRight;
3508 } else if (choice == _("Center")) {
3509 focus_type = ZoomFocusCenter;
3510 } else if (choice == _("Playhead")) {
3511 focus_type = ZoomFocusPlayhead;
3512 } else if (choice == _("Mouse")) {
3513 focus_type = ZoomFocusMouse;
3514 } else if (choice == _("Active Mark")) {
3515 focus_type = ZoomFocusEdit;
3518 RefPtr<RadioAction> ract = zoom_focus_action (focus_type);
3521 ract->set_active ();
3526 Editor::edit_controls_button_release (GdkEventButton* ev)
3528 if (Keyboard::is_context_menu_event (ev)) {
3529 ARDOUR_UI::instance()->add_route (this);
3535 Editor::mouse_select_button_release (GdkEventButton* ev)
3537 /* this handles just right-clicks */
3539 if (ev->button != 3) {
3546 Editor::TrackViewList *
3547 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3550 TrackViewList::iterator i;
3552 v = new TrackViewList;
3554 if (track == 0 && group == 0) {
3558 for (i = track_views.begin(); i != track_views.end (); ++i) {
3562 } else if ((track != 0 && group == 0) || (track != 0 && group != 0 && !group->is_active())) {
3564 /* just the view for this track
3567 v->push_back (track);
3571 /* views for all tracks in the edit group */
3573 for (i = track_views.begin(); i != track_views.end (); ++i) {
3575 if (group == 0 || (*i)->edit_group() == group) {
3585 Editor::set_zoom_focus (ZoomFocus f)
3587 string str = zoom_focus_strings[(int)f];
3589 if (str != zoom_focus_selector.get_active_text()) {
3590 zoom_focus_selector.set_active_text (str);
3593 if (zoom_focus != f) {
3596 ZoomFocusChanged (); /* EMIT_SIGNAL */
3603 Editor::ensure_float (Window& win)
3605 win.set_transient_for (*this);
3609 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3611 /* recover or initialize pane positions. do this here rather than earlier because
3612 we don't want the positions to change the child allocations, which they seem to do.
3618 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3620 static int32_t done;
3623 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3624 width = default_width;
3625 height = default_height;
3627 width = atoi(geometry->property("x_size")->value());
3628 height = atoi(geometry->property("y_size")->value());
3631 if (which == static_cast<Paned*> (&edit_pane)) {
3637 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3638 /* initial allocation is 90% to canvas, 10% to notebook */
3639 pos = (int) floor (alloc.get_width() * 0.90f);
3640 snprintf (buf, sizeof(buf), "%d", pos);
3642 pos = atoi (prop->value());
3645 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3646 edit_pane.set_position (pos);
3647 pre_maximal_pane_position = pos;
3653 Editor::detach_tearoff (Box* b, Window* w)
3655 if (tools_tearoff->torn_off() &&
3656 mouse_mode_tearoff->torn_off()) {
3657 top_hbox.remove (toolbar_frame);
3662 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3664 if (toolbar_frame.get_parent() == 0) {
3665 top_hbox.pack_end (toolbar_frame);
3670 Editor::set_show_measures (bool yn)
3672 if (_show_measures != yn) {
3675 if ((_show_measures = yn) == true) {
3683 Editor::toggle_follow_playhead ()
3685 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3687 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3688 set_follow_playhead (tact->get_active());
3693 Editor::set_follow_playhead (bool yn)
3695 if (_follow_playhead != yn) {
3696 if ((_follow_playhead = yn) == true) {
3698 update_current_screen ();
3705 Editor::toggle_xfade_active (boost::weak_ptr<Crossfade> wxfade)
3707 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3709 xfade->set_active (!xfade->active());
3714 Editor::toggle_xfade_length (boost::weak_ptr<Crossfade> wxfade)
3716 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3718 xfade->set_follow_overlap (!xfade->following_overlap());
3723 Editor::edit_xfade (boost::weak_ptr<Crossfade> wxfade)
3725 boost::shared_ptr<Crossfade> xfade (wxfade.lock());
3731 CrossfadeEditor cew (*session, xfade, xfade->fade_in().get_min_y(), 1.0);
3735 switch (cew.run ()) {
3736 case RESPONSE_ACCEPT:
3743 xfade->StateChanged (Change (~0));
3747 Editor::playlist_selector () const
3749 return *_playlist_selector;
3753 Editor::get_nudge_distance (nframes64_t pos, nframes64_t& next)
3757 ret = nudge_clock.current_duration (pos);
3758 next = ret + 1; /* XXXX fix me */
3764 Editor::end_location_changed (Location* location)
3766 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3767 reset_scrolling_region ();
3771 Editor::playlist_deletion_dialog (boost::shared_ptr<Playlist> pl)
3773 ArdourDialog dialog ("playlist deletion dialog");
3774 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3775 "If left alone, no audio files used by it will be cleaned.\n"
3776 "If deleted, audio files used by it alone by will cleaned."),
3779 dialog.set_position (WIN_POS_CENTER);
3780 dialog.get_vbox()->pack_start (label);
3784 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3785 dialog.add_button (_("Keep playlist"), RESPONSE_REJECT);
3786 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3788 switch (dialog.run ()) {
3789 case RESPONSE_ACCEPT:
3790 /* delete the playlist */
3794 case RESPONSE_REJECT:
3795 /* keep the playlist */
3807 Editor::audio_region_selection_covers (nframes64_t where)
3809 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3810 if ((*a)->region()->covers (where)) {
3819 Editor::prepare_for_cleanup ()
3821 cut_buffer->clear_regions ();
3822 cut_buffer->clear_playlists ();
3824 selection->clear_regions ();
3825 selection->clear_playlists ();
3827 no_region_list_redisplay = true;
3831 Editor::finish_cleanup ()
3833 no_region_list_redisplay = false;
3834 redisplay_regions ();
3838 Editor::transport_loop_location()
3841 return session->locations()->auto_loop_location();
3848 Editor::transport_punch_location()
3851 return session->locations()->auto_punch_location();
3858 Editor::control_layout_scroll (GdkEventScroll* ev)
3860 switch (ev->direction) {
3862 scroll_tracks_up_line ();
3866 case GDK_SCROLL_DOWN:
3867 scroll_tracks_down_line ();
3871 /* no left/right handling yet */
3879 /** A new snapshot has been selected.
3882 Editor::snapshot_display_selection_changed ()
3884 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
3886 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
3888 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
3890 if (snap_name.length() == 0) {
3894 if (session->snap_name() == snap_name) {
3898 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
3903 Editor::snapshot_display_button_press (GdkEventButton* ev)
3905 if (ev->button == 3) {
3906 /* Right-click on the snapshot list. Work out which snapshot it
3908 Gtk::TreeModel::Path path;
3909 Gtk::TreeViewColumn* col;
3912 snapshot_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, col, cx, cy);
3913 Gtk::TreeModel::iterator iter = snapshot_display_model->get_iter (path);
3915 Gtk::TreeModel::Row row = *iter;
3916 popup_snapshot_context_menu (ev->button, ev->time, row[snapshot_display_columns.real_name]);
3925 /** Pop up the snapshot display context menu.
3926 * @param button Button used to open the menu.
3927 * @param time Menu open time.
3928 * @snapshot_name Name of the snapshot that the menu click was over.
3932 Editor::popup_snapshot_context_menu (int button, int32_t time, Glib::ustring snapshot_name)
3934 using namespace Menu_Helpers;
3936 MenuList& items (snapshot_context_menu.items());
3939 const bool modification_allowed = (session->snap_name() != snapshot_name && session->name() != snapshot_name);
3941 items.push_back (MenuElem (_("Remove"), bind (mem_fun (*this, &Editor::remove_snapshot), snapshot_name)));
3942 if (!modification_allowed) {
3943 items.back().set_sensitive (false);
3946 items.push_back (MenuElem (_("Rename"), bind (mem_fun (*this, &Editor::rename_snapshot), snapshot_name)));
3947 if (!modification_allowed) {
3948 items.back().set_sensitive (false);
3951 snapshot_context_menu.popup (button, time);
3955 Editor::rename_snapshot (Glib::ustring old_name)
3957 ArdourPrompter prompter(true);
3961 prompter.set_name ("Prompter");
3962 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
3963 prompter.set_prompt (_("New name of snapshot"));
3964 prompter.set_initial_text (old_name);
3966 if (prompter.run() == RESPONSE_ACCEPT) {
3967 prompter.get_result (new_name);
3968 if (new_name.length()) {
3969 session->rename_state (old_name, new_name);
3970 redisplay_snapshots ();
3977 Editor::remove_snapshot (Glib::ustring name)
3979 vector<string> choices;
3981 std::string prompt = string_compose (_("Do you really want to remove snapshot \"%1\" ?\n(cannot be undone)"), name);
3983 choices.push_back (_("No, do nothing."));
3984 choices.push_back (_("Yes, remove it."));
3986 Gtkmm2ext::Choice prompter (prompt, choices);
3988 if (prompter.run () == 1) {
3989 session->remove_state (name);
3990 redisplay_snapshots ();
3995 Editor::redisplay_snapshots ()
4001 vector<string*>* states;
4003 if ((states = session->possible_states()) == 0) {
4007 snapshot_display_model->clear ();
4009 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
4010 string statename = *(*i);
4011 TreeModel::Row row = *(snapshot_display_model->append());
4013 /* this lingers on in case we ever want to change the visible
4014 name of the snapshot.
4017 string display_name;
4018 display_name = statename;
4020 if (statename == session->snap_name()) {
4021 snapshot_display.get_selection()->select(row);
4024 row[snapshot_display_columns.visible_name] = display_name;
4025 row[snapshot_display_columns.real_name] = statename;
4032 Editor::session_state_saved (string snap_name)
4034 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4035 redisplay_snapshots ();
4039 Editor::maximise_editing_space ()
4041 initial_ruler_update_required = true;
4043 mouse_mode_tearoff->set_visible (false);
4044 tools_tearoff->set_visible (false);
4046 pre_maximal_pane_position = edit_pane.get_position();
4047 pre_maximal_editor_width = this->get_width();
4049 if(post_maximal_pane_position == 0) {
4050 post_maximal_pane_position = edit_pane.get_width();
4055 if(post_maximal_editor_width) {
4056 edit_pane.set_position (post_maximal_pane_position -
4057 abs(post_maximal_editor_width - pre_maximal_editor_width));
4059 edit_pane.set_position (post_maximal_pane_position);
4064 Editor::restore_editing_space ()
4066 initial_ruler_update_required = true;
4068 // user changed width of pane during fullscreen
4069 if(post_maximal_pane_position != edit_pane.get_position()) {
4070 post_maximal_pane_position = edit_pane.get_position();
4075 mouse_mode_tearoff->set_visible (true);
4076 tools_tearoff->set_visible (true);
4077 post_maximal_editor_width = this->get_width();
4080 edit_pane.set_position (
4081 pre_maximal_pane_position + abs(this->get_width() - pre_maximal_editor_width)
4086 * Make new playlists for a given track and also any others that belong
4087 * to the same active edit group.
4092 Editor::new_playlists (TimeAxisView* v)
4094 begin_reversible_command (_("new playlists"));
4095 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist), v);
4096 commit_reversible_command ();
4101 * Use a copy of the current playlist for a given track and also any others that belong
4102 * to the same active edit group.
4107 Editor::copy_playlists (TimeAxisView* v)
4109 begin_reversible_command (_("copy playlists"));
4110 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist), v);
4111 commit_reversible_command ();
4116 * Clear the current playlist for a given track and also any others that belong
4117 * to the same active edit group.
4122 Editor::clear_playlists (TimeAxisView* v)
4124 begin_reversible_command (_("clear playlists"));
4125 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist), v);
4126 commit_reversible_command ();
4130 Editor::mapped_use_new_playlist (AudioTimeAxisView& atv, uint32_t sz)
4132 atv.use_new_playlist (sz > 1 ? false : true);
4136 Editor::mapped_use_copy_playlist (AudioTimeAxisView& atv, uint32_t sz)
4138 atv.use_copy_playlist (sz > 1 ? false : true);
4142 Editor::mapped_clear_playlist (AudioTimeAxisView& atv, uint32_t sz)
4144 atv.clear_playlist ();
4148 Editor::on_key_press_event (GdkEventKey* ev)
4150 return key_press_focus_accelerator_handler (*this, ev);
4154 Editor::on_key_release_event (GdkEventKey* ev)
4156 return Gtk::Window::on_key_release_event (ev);
4157 // return key_press_focus_accelerator_handler (*this, ev);
4161 Editor::reset_x_origin (nframes64_t frame)
4163 queue_visual_change (frame);
4167 Editor::reset_zoom (double fpu)
4169 queue_visual_change (fpu);
4173 Editor::reposition_and_zoom (nframes64_t frame, double fpu)
4175 //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
4176 reset_x_origin (frame);
4179 if (!no_save_visual) {
4180 undo_visual_stack.push_back (current_visual_state(false));
4184 Editor::VisualState*
4185 Editor::current_visual_state (bool with_tracks)
4187 VisualState* vs = new VisualState;
4188 vs->y_position = vertical_adjustment.get_value();
4189 vs->frames_per_unit = frames_per_unit;
4190 vs->leftmost_frame = leftmost_frame;
4191 vs->zoom_focus = zoom_focus;
4192 vs->zoomed_to_region = zoomed_to_region;
4195 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4196 vs->track_states.push_back (TAVState ((*i), &(*i)->get_state()));
4204 Editor::undo_visual_state ()
4206 if (undo_visual_stack.empty()) {
4210 VisualState* vs = undo_visual_stack.back();
4211 undo_visual_stack.pop_back();
4212 use_visual_state (*vs);
4213 redo_visual_stack.push_back (vs);
4217 Editor::redo_visual_state ()
4219 if (redo_visual_stack.empty()) {
4223 VisualState* vs = redo_visual_stack.back();
4224 redo_visual_stack.pop_back();
4225 use_visual_state (*vs);
4226 undo_visual_stack.push_back (vs);
4230 Editor::swap_visual_state ()
4232 if (undo_visual_stack.empty()) {
4233 redo_visual_state ();
4235 undo_visual_state ();
4240 Editor::use_visual_state (VisualState& vs)
4242 no_save_visual = true;
4244 vertical_adjustment.set_value (vs.y_position);
4246 set_zoom_focus (vs.zoom_focus);
4247 reposition_and_zoom (vs.leftmost_frame, vs.frames_per_unit);
4249 for (list<TAVState>::iterator i = vs.track_states.begin(); i != vs.track_states.end(); ++i) {
4250 TrackViewList::iterator t;
4252 /* check if the track still exists - it could have been deleted */
4254 if ((t = find (track_views.begin(), track_views.end(), i->first)) != track_views.end()) {
4255 (*t)->set_state (*(i->second));
4259 if (!vs.track_states.empty()) {
4260 update_route_visibility ();
4263 no_save_visual = false;
4267 Editor::set_frames_per_unit (double fpu)
4269 /* this is the core function that controls the zoom level of the canvas. it is called
4270 whenever one or more calls are made to reset_zoom(). it executes in an idle handler.
4273 if (fpu == frames_per_unit) {
4282 /* don't allow zooms that fit more than the maximum number
4283 of frames into an 800 pixel wide space.
4286 if (max_frames / fpu < 800.0) {
4290 if (fpu == frames_per_unit) {
4294 frames_per_unit = fpu;
4299 Editor::post_zoom ()
4301 // convert fpu to frame count
4303 nframes64_t frames = (nframes64_t) floor (frames_per_unit * canvas_width);
4305 if (frames_per_unit != zoom_range_clock.current_duration()) {
4306 zoom_range_clock.set (frames);
4309 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
4310 if (!selection->tracks.empty()) {
4311 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
4312 (*i)->reshow_selection (selection->time);
4315 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4316 (*i)->reshow_selection (selection->time);
4321 ZoomChanged (); /* EMIT_SIGNAL */
4323 reset_hscrollbar_stepping ();
4324 reset_scrolling_region ();
4326 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
4332 Editor::queue_visual_change (nframes64_t where)
4334 pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::TimeOrigin);
4335 pending_visual_change.time_origin = where;
4337 if (pending_visual_change.idle_handler_id < 0) {
4338 pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
4343 Editor::queue_visual_change (double fpu)
4345 pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::ZoomLevel);
4346 pending_visual_change.frames_per_unit = fpu;
4348 if (pending_visual_change.idle_handler_id < 0) {
4349 pending_visual_change.idle_handler_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE, _idle_visual_changer, this, 0);
4354 Editor::_idle_visual_changer (void* arg)
4356 return static_cast<Editor*>(arg)->idle_visual_changer ();
4360 Editor::idle_visual_changer ()
4362 VisualChange::Type p = pending_visual_change.pending;
4363 nframes64_t csf, cef;
4366 csf = session->current_start_frame();
4367 cef = session->current_end_frame() + (current_page_frames() / 24);// Add a little extra so we can see the end marker
4370 pending_visual_change.pending = (VisualChange::Type) 0;
4371 pending_visual_change.idle_handler_id = -1;
4373 if (p & VisualChange::ZoomLevel) {
4374 set_frames_per_unit (pending_visual_change.frames_per_unit);
4377 if (p & VisualChange::TimeOrigin) {
4379 nframes64_t time_origin = (nframes64_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
4381 /* if we seek beyond the current end of the canvas, move the end */
4383 if (time_origin != pending_visual_change.time_origin) {
4385 if (horizontal_adjustment.get_upper() < pending_visual_change.time_origin) {
4386 last_canvas_frame = (cef > (pending_visual_change.time_origin + current_page_frames())) ? cef : pending_visual_change.time_origin + current_page_frames();
4387 horizontal_adjustment.set_upper ((cef - csf) / frames_per_unit);
4388 reset_scrolling_region ();
4391 horizontal_adjustment.set_value (pending_visual_change.time_origin/frames_per_unit);
4393 update_fixed_rulers();
4394 redisplay_tempo (true);
4397 //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
4398 return 0; /* this is always a one-shot call */
4401 struct EditorOrderTimeAxisSorter {
4402 bool operator() (const TimeAxisView* a, const TimeAxisView* b) const {
4403 return a->order < b->order;
4408 Editor::sort_track_selection (TrackSelection* sel)
4410 EditorOrderTimeAxisSorter cmp;
4415 selection->tracks.sort (cmp);
4420 Editor::get_preferred_edit_position (bool ignore_playhead)
4423 nframes64_t where = 0;
4424 EditPoint ep = _edit_point;
4426 if (entered_marker) {
4427 return entered_marker->position();
4430 if (ignore_playhead && ep == EditAtPlayhead) {
4431 ep = EditAtSelectedMarker;
4435 case EditAtPlayhead:
4436 where = session->audible_frame();
4439 case EditAtSelectedMarker:
4440 if (!selection->markers.empty()) {
4442 Location* loc = find_location_from_marker (selection->markers.front(), is_start);
4445 where = loc->start();
4456 if (!mouse_frame (where, ignored)) {
4457 /* XXX not right but what can we do ? */
4468 Editor::set_loop_range (nframes64_t start, nframes64_t end, string cmd)
4470 if (!session) return;
4472 begin_reversible_command (cmd);
4476 if ((tll = transport_loop_location()) == 0) {
4477 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoLoop);
4478 XMLNode &before = session->locations()->get_state();
4479 session->locations()->add (loc, true);
4480 session->set_auto_loop_location (loc);
4481 XMLNode &after = session->locations()->get_state();
4482 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4484 XMLNode &before = tll->get_state();
4485 tll->set_hidden (false, this);
4486 tll->set (start, end);
4487 XMLNode &after = tll->get_state();
4488 session->add_command (new MementoCommand<Location>(*tll, &before, &after));
4491 commit_reversible_command ();
4495 Editor::set_punch_range (nframes64_t start, nframes64_t end, string cmd)
4497 if (!session) return;
4499 begin_reversible_command (cmd);
4503 if ((tpl = transport_punch_location()) == 0) {
4504 Location* loc = new Location (start, end, _("Loop"), Location::IsAutoPunch);
4505 XMLNode &before = session->locations()->get_state();
4506 session->locations()->add (loc, true);
4507 session->set_auto_loop_location (loc);
4508 XMLNode &after = session->locations()->get_state();
4509 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
4512 XMLNode &before = tpl->get_state();
4513 tpl->set_hidden (false, this);
4514 tpl->set (start, end);
4515 XMLNode &after = tpl->get_state();
4516 session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
4519 commit_reversible_command ();
4523 Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4525 const TrackSelection* tracks;
4528 tracks = &track_views;
4533 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4535 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*t);
4538 boost::shared_ptr<Diskstream> ds;
4539 boost::shared_ptr<Playlist> pl;
4541 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
4543 Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)where * ds->speed()));
4545 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4547 RegionView* rv = atv->audio_view()->find_view (*i);
4561 Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
4563 const TrackSelection* tracks;
4566 tracks = &track_views;
4571 for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) {
4573 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*t);
4576 boost::shared_ptr<Diskstream> ds;
4577 boost::shared_ptr<Playlist> pl;
4579 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
4581 Playlist::RegionList* regions = pl->regions_touched ((nframes64_t) floor ( (double)where * ds->speed()), max_frames);
4583 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
4585 RegionView* rv = atv->audio_view()->find_view (*i);
4599 Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered)
4601 if (selection->regions.empty()) {
4603 if (selection->tracks.empty()) {
4605 /* no regions or tracks selected
4608 if (entered_regionview && mouse_mode == Editing::MouseObject) {
4610 /* entered regionview is valid and we're in object mode -
4611 just use entered regionview
4614 rs.add (entered_regionview);
4621 /* no regions selected, so get all regions at the edit point across
4622 all selected tracks.
4625 nframes64_t where = get_preferred_edit_position();
4626 get_regions_at (rs, where, selection->tracks);
4628 /* if the entered regionview wasn't selected and neither was its track
4632 if (entered_regionview != 0 &&
4633 !selection->selected (entered_regionview) &&
4634 !selection->selected (&entered_regionview->get_time_axis_view())) {
4635 rs.add (entered_regionview);
4641 /* just use the selected regions */
4643 rs = selection->regions;
4645 /* if the entered regionview wasn't selected and we allow this sort of thing,
4649 if (allow_entered && entered_regionview && !selection->selected (entered_regionview)) {
4650 rs.add (entered_regionview);
4657 Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<RegionView*>& regions)
4660 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
4662 RouteTimeAxisView* tatv;
4664 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
4666 boost::shared_ptr<Playlist> pl;
4667 vector<boost::shared_ptr<Region> > results;
4669 boost::shared_ptr<Diskstream> ds;
4671 if ((ds = tatv->get_diskstream()) == 0) {
4676 if ((pl = (ds->playlist())) != 0) {
4677 pl->get_region_list_equivalent_regions (region, results);
4680 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
4681 if ((marv = tatv->view()->find_view (*ir)) != 0) {
4682 regions.push_back (marv);
4691 Editor::show_rhythm_ferret ()
4693 if (rhythm_ferret == 0) {
4694 rhythm_ferret = new RhythmFerret(*this);
4697 rhythm_ferret->set_session (session);
4698 rhythm_ferret->show ();
4699 rhythm_ferret->present ();
4703 Editor::first_idle ()
4705 MessageDialog* dialog = 0;
4707 if (track_views.size() > 1) {
4708 dialog = new MessageDialog (*this,
4709 _("Please wait while Ardour loads visual data"),
4714 ARDOUR_UI::instance()->flush_pending ();
4717 for (TrackViewList::iterator t = track_views.begin(); t != track_views.end(); ++t) {
4729 Editor::start_resize_line_ops ()
4732 old_resize_line_y = -1;
4734 need_resize_line = true;
4739 Editor::end_resize_line_ops ()
4742 need_resize_line = false;
4744 if (old_resize_line_y >= 0) {
4745 Gdk::Rectangle r (0, old_resize_line_y, (int) canvas_width, 3);
4746 Glib::RefPtr<Gdk::Window> win = get_window();
4747 cerr << "Final invalidation at " << old_resize_line_y << endl;
4748 win->invalidate_rect (r, false);
4754 Editor::queue_draw_resize_line (int at)
4757 Glib::RefPtr<Gdk::Window> win = get_window();
4761 if (win && canvas_width) {
4763 int controls_width = controls_layout.get_width();
4766 controls_layout.get_window()->get_origin (xroot, discard);
4768 if (old_resize_line_y >= 0) {
4770 /* redraw where it used to be */
4773 Gdk::Rectangle r (xroot, old_resize_line_y - 1, controls_width + (int) canvas_width, 3);
4774 win->invalidate_rect (r, true);
4775 cerr << "invalidate " << xroot << "," << old_resize_line_y - 1 << ' '
4776 << controls_width + canvas_width << " x 3\n";
4779 /* draw where it is */
4781 Gdk::Rectangle r (xroot, at - 1, controls_width + (int) canvas_width, 3);
4782 win->invalidate_rect (r, true);
4788 Editor::on_expose_event (GdkEventExpose* ev)
4790 /* cerr << "+++ editor expose "
4791 << ev->area.x << ',' << ev->area.y
4793 << ev->area.width << " x " << ev->area.height
4794 << " need reize ? " << need_resize_line
4797 bool ret = Window::on_expose_event (ev);
4800 if (need_resize_line) {
4802 int xroot, yroot, discard;
4805 /* Our root coordinates for drawing the line will be the left edge
4806 of the track controls, and the upper left edge of our own window.
4809 get_window()->get_origin (discard, yroot);
4810 controls_layout.get_window()->get_origin (xroot, discard);
4811 controls_width = controls_layout.get_width();
4814 GdkRectangle intersection;
4817 lr.y = resize_line_y;
4818 lr.width = controls_width + (int) canvas_width;
4821 if (gdk_rectangle_intersect (&lr, &ev->area, &intersection)) {
4823 Glib::RefPtr<Gtk::Style> style (get_style());
4824 Glib::RefPtr<Gdk::GC> black_gc (style->get_black_gc ());
4825 Glib::RefPtr<Gdk::GC> gc = wrap (black_gc->gobj_copy(), false);
4827 /* draw on root window */
4829 GdkWindow* win = gdk_get_default_root_window();
4831 gc->set_subwindow (Gdk::INCLUDE_INFERIORS);
4832 gc->set_line_attributes (3, Gdk::LINE_SOLID,
4836 gdk_draw_line (win, gc->gobj(),
4838 yroot + resize_line_y,
4839 xroot + (int) canvas_width + controls_width,
4840 yroot + resize_line_y);
4841 cerr << "drew line @ " << xroot << ", " << yroot + resize_line_y
4842 << " to " << xroot + (int) canvas_width + controls_width
4843 << ", " << yroot + resize_line_y
4845 old_resize_line_y = yroot + resize_line_y;
4846 cerr << "NEXT EXPOSE SHOULD BE AT " << old_resize_line_y << endl;
4848 cerr << "no intersect with "
4849 << lr.x << ',' << lr.y
4851 << lr.width << " x " << lr.height
4856 //cerr << "--- editor expose\n";
4863 _idle_resizer (gpointer arg)
4865 return ((Editor*)arg)->idle_resize ();
4869 Editor::add_to_idle_resize (TimeAxisView* view, uint32_t h)
4871 if (resize_idle_id < 0) {
4872 resize_idle_id = g_idle_add (_idle_resizer, this);
4875 resize_idle_target = h;
4877 pending_resizes.push_back (view);
4879 if (selection->selected (view) && !selection->tracks.empty()) {
4880 pending_resizes.insert (pending_resizes.end(), selection->tracks.begin(), selection->tracks.end());
4885 Editor::idle_resize ()
4887 for (vector<TimeAxisView*>::iterator i = pending_resizes.begin(); i != pending_resizes.end(); ++i) {
4888 (*i)->idle_resize (resize_idle_target);
4890 pending_resizes.clear();
4891 resize_idle_id = -1;