2 Copyright (C) 2000-2006 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 <sigc++/bind.h>
29 #include <pbd/error.h>
31 #include <gtkmm/image.h>
32 #include <gdkmm/color.h>
33 #include <gdkmm/bitmap.h>
35 #include <gtkmm2ext/gtk_ui.h>
36 #include <gtkmm2ext/tearoff.h>
37 #include <gtkmm2ext/utils.h>
39 #include <ardour/audio_track.h>
40 #include <ardour/diskstream.h>
41 #include <ardour/plugin_manager.h>
42 #include <ardour/location.h>
43 #include <ardour/audioplaylist.h>
44 #include <ardour/audioregion.h>
45 #include <ardour/region.h>
46 #include <ardour/session_route.h>
47 #include <ardour/tempo.h>
48 #include <ardour/utils.h>
50 #include "ardour_ui.h"
52 #include "grouped_buttons.h"
55 #include "playlist_selector.h"
56 #include "regionview.h"
57 #include "rgb_macros.h"
58 #include "selection.h"
59 #include "streamview.h"
60 #include "time_axis_view.h"
62 #include "crossfade_view.h"
64 #include "public_editor.h"
65 #include "crossfade_edit.h"
66 #include "audio_time_axis.h"
67 #include "canvas_impl.h"
69 #include "gui_thread.h"
74 #include "imageframe_socket_handler.h"
75 /* </CMT Additions> */
79 using namespace ARDOUR;
82 using namespace Gtkmm2ext;
83 using namespace Editing;
85 const double Editor::timebar_height = 15.0;
87 #include "editor_xpms"
89 static const int32_t slide_index = 0;
90 static const int32_t splice_index = 1;
92 static const gchar *edit_mode_strings[] = {
98 static const gchar *snap_type_strings[] = {
122 static const gchar *snap_mode_strings[] = {
128 static const gchar *zoom_focus_strings[] = {
137 /* Soundfile drag-n-drop */
139 Gdk::Cursor* Editor::cross_hair_cursor = 0;
140 Gdk::Cursor* Editor::selector_cursor = 0;
141 Gdk::Cursor* Editor::trimmer_cursor = 0;
142 Gdk::Cursor* Editor::grabber_cursor = 0;
143 Gdk::Cursor* Editor::zoom_cursor = 0;
144 Gdk::Cursor* Editor::time_fx_cursor = 0;
145 Gdk::Cursor* Editor::fader_cursor = 0;
146 Gdk::Cursor* Editor::speaker_cursor = 0;
147 Gdk::Cursor* Editor::wait_cursor = 0;
148 Gdk::Cursor* Editor::timebar_cursor = 0;
151 show_me_the_size (Requisition* r, const char* what)
153 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
156 Editor::Editor (AudioEngine& eng)
159 /* time display buttons */
161 minsec_label (_("Mins:Secs")),
162 bbt_label (_("Bars:Beats")),
163 smpte_label (_("SMPTE")),
164 frame_label (_("Frames")),
165 tempo_label (_("Tempo")),
166 meter_label (_("Meter")),
167 mark_label (_("Location Markers")),
168 range_mark_label (_("Range Markers")),
169 transport_mark_label (_("Loop/Punch Ranges")),
171 edit_packer (3, 3, false),
173 /* the values here don't matter: layout widgets
174 reset them as needed.
177 vertical_adjustment (0.0, 0.0, 400.0, 10),
178 horizontal_adjustment (0.0, 0.0, 1200.0, 20),
180 /* tool bar related */
182 selection_start_clock (X_("SelectionStartClock"), true),
183 selection_end_clock (X_("SelectionEndClock"), true),
184 edit_cursor_clock (X_("EditCursorClock"), true),
185 zoom_range_clock (X_("ZoomRangeClock"), true, true),
187 toolbar_selection_clock_table (2,3),
189 mouse_mode_button_table (2, 3),
191 mouse_select_button (_("range")),
192 mouse_move_button (_("object")),
193 mouse_gain_button (_("gain")),
194 mouse_zoom_button (_("zoom")),
195 mouse_timefx_button (_("timefx")),
196 mouse_audition_button (_("listen")),
198 automation_mode_button (_("mode")),
199 global_automation_button (_("automation")),
201 edit_mode_label (_("Edit Mode")),
202 snap_type_label (_("Snap To")),
203 snap_mode_label(_("Snap Mode")),
204 zoom_focus_label (_("Zoom Focus")),
206 /* <CMT Additions> */
207 image_socket_listener(0),
208 /* </CMT Additions> */
212 nudge_label (_("Nudge")),
213 nudge_clock (X_("NudgeClock"), true, true)
218 /* we are a singleton */
220 PublicEditor::_instance = this;
224 selection = new Selection;
225 cut_buffer = new Selection;
227 selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed));
228 selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed));
229 selection->RegionsChanged.connect (mem_fun(*this, &Editor::region_selection_changed));
230 selection->PointsChanged.connect (mem_fun(*this, &Editor::point_selection_changed));
232 clicked_regionview = 0;
233 clicked_trackview = 0;
234 clicked_audio_trackview = 0;
235 clicked_crossfadeview = 0;
236 clicked_control_point = 0;
237 latest_regionview = 0;
238 last_update_frame = 0;
240 last_audition_region = 0;
241 current_mixer_strip = 0;
242 current_bbt_points = 0;
244 snap_type = SnapToFrame;
245 set_snap_to (snap_type);
246 snap_mode = SnapNormal;
247 set_snap_mode (snap_mode);
248 snap_threshold = 5.0;
249 bbt_beat_subdivision = 4;
252 autoscroll_timeout_tag = -1;
253 interthread_progress_window = 0;
254 current_interthread_info = 0;
255 _show_measures = true;
256 _show_waveforms = true;
257 _show_waveforms_recording = true;
258 first_action_message = 0;
260 show_gain_after_trim = false;
261 no_zoom_repos_update = false;
262 ignore_route_list_reorder = false;
263 no_route_list_redisplay = false;
264 verbose_cursor_on = true;
265 route_removal = false;
267 show_automatic_regions_in_region_list = true;
268 region_list_sort_type = (Editing::RegionListSortType) 0;
269 have_pending_keyboard_selection = false;
270 _follow_playhead = true;
271 _xfade_visibility = true;
272 editor_ruler_menu = 0;
273 no_ruler_shown_update = false;
274 edit_hscroll_dragging = false;
275 edit_group_list_menu = 0;
277 region_list_menu = 0;
279 marker_menu_item = 0;
281 transport_marker_menu = 0;
282 new_transport_marker_menu = 0;
283 editor_mixer_strip_width = Wide;
284 repos_zoom_queued = false;
285 region_edit_menu_split_item = 0;
287 region_edit_menu_split_multichannel_item = 0;
289 ignore_mouse_mode_toggle = false;
290 current_stepping_trackview = 0;
292 entered_regionview = 0;
293 clear_entered_track = false;
294 _new_regionviews_show_envelope = false;
295 current_timestretch = 0;
296 in_edit_group_row_change = false;
301 location_marker_color = color_map[cLocationMarker];
302 location_range_color = color_map[cLocationRange];
303 location_cd_marker_color = color_map[cLocationCDMarker];
304 location_loop_color = color_map[cLocationLoop];
305 location_punch_color = color_map[cLocationPunch];
307 range_marker_drag_rect = 0;
308 marker_drag_line = 0;
310 set_mouse_mode (MouseObject, true);
312 frames_per_unit = 2048; /* too early to use set_frames_per_unit */
313 zoom_focus = ZoomFocusLeft;
314 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
316 initialize_rulers ();
317 initialize_canvas ();
319 edit_controls_vbox.set_spacing (0);
320 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled));
321 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling));
323 track_canvas.set_hadjustment (horizontal_adjustment);
324 track_canvas.set_vadjustment (vertical_adjustment);
325 time_canvas.set_hadjustment (horizontal_adjustment);
327 track_canvas.signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
328 time_canvas.signal_map_event().connect (mem_fun (*this, &Editor::time_canvas_map_handler));
330 controls_layout.add (edit_controls_vbox);
331 controls_layout.set_name ("EditControlsBase");
332 controls_layout.add_events (Gdk::SCROLL_MASK);
333 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
335 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
336 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
337 controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
339 edit_vscrollbar.set_adjustment (vertical_adjustment);
340 edit_hscrollbar.set_adjustment (horizontal_adjustment);
342 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press));
343 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release));
344 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
349 edit_cursor_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_cursor_clock_changed));
351 time_canvas_vbox.pack_start (*minsec_ruler, false, false);
352 time_canvas_vbox.pack_start (*smpte_ruler, false, false);
353 time_canvas_vbox.pack_start (*frames_ruler, false, false);
354 time_canvas_vbox.pack_start (*bbt_ruler, false, false);
355 time_canvas_vbox.pack_start (time_canvas, true, true);
356 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars));
358 bbt_label.set_name ("EditorTimeButton");
359 bbt_label.set_size_request (-1, (int)timebar_height);
360 bbt_label.set_alignment (1.0, 0.5);
361 bbt_label.set_padding (5,0);
362 minsec_label.set_name ("EditorTimeButton");
363 minsec_label.set_size_request (-1, (int)timebar_height);
364 minsec_label.set_alignment (1.0, 0.5);
365 minsec_label.set_padding (5,0);
366 smpte_label.set_name ("EditorTimeButton");
367 smpte_label.set_size_request (-1, (int)timebar_height);
368 smpte_label.set_alignment (1.0, 0.5);
369 smpte_label.set_padding (5,0);
370 frame_label.set_name ("EditorTimeButton");
371 frame_label.set_size_request (-1, (int)timebar_height);
372 frame_label.set_alignment (1.0, 0.5);
373 frame_label.set_padding (5,0);
374 tempo_label.set_name ("EditorTimeButton");
375 tempo_label.set_size_request (-1, (int)timebar_height);
376 tempo_label.set_alignment (1.0, 0.5);
377 tempo_label.set_padding (5,0);
378 meter_label.set_name ("EditorTimeButton");
379 meter_label.set_size_request (-1, (int)timebar_height);
380 meter_label.set_alignment (1.0, 0.5);
381 meter_label.set_padding (5,0);
382 mark_label.set_name ("EditorTimeButton");
383 mark_label.set_size_request (-1, (int)timebar_height);
384 mark_label.set_alignment (1.0, 0.5);
385 mark_label.set_padding (5,0);
386 range_mark_label.set_name ("EditorTimeButton");
387 range_mark_label.set_size_request (-1, (int)timebar_height);
388 range_mark_label.set_alignment (1.0, 0.5);
389 range_mark_label.set_padding (5,0);
390 transport_mark_label.set_name ("EditorTimeButton");
391 transport_mark_label.set_size_request (-1, (int)timebar_height);
392 transport_mark_label.set_alignment (1.0, 0.5);
393 transport_mark_label.set_padding (5,0);
395 time_button_vbox.pack_start (minsec_label, false, false);
396 time_button_vbox.pack_start (smpte_label, false, false);
397 time_button_vbox.pack_start (frame_label, false, false);
398 time_button_vbox.pack_start (bbt_label, false, false);
399 time_button_vbox.pack_start (meter_label, false, false);
400 time_button_vbox.pack_start (tempo_label, false, false);
401 time_button_vbox.pack_start (mark_label, false, false);
403 time_button_event_box.add (time_button_vbox);
405 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
406 time_button_event_box.set_name ("TimebarLabelBase");
407 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
409 /* these enable us to have a dedicated window (for cursor setting, etc.)
410 for the canvas areas.
413 track_canvas_event_box.add (track_canvas);
415 time_canvas_event_box.add (time_canvas_vbox);
416 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
418 edit_packer.set_col_spacings (0);
419 edit_packer.set_row_spacings (0);
420 edit_packer.set_homogeneous (false);
421 edit_packer.set_name ("EditorWindow");
423 edit_packer.attach (edit_hscrollbar, 1, 2, 0, 1, FILL|EXPAND, FILL, 0, 0);
425 edit_packer.attach (time_button_event_box, 0, 1, 1, 2, FILL, FILL, 0, 0);
426 edit_packer.attach (time_canvas_event_box, 1, 2, 1, 2, FILL|EXPAND, FILL, 0, 0);
428 edit_packer.attach (controls_layout, 0, 1, 2, 3, FILL, FILL|EXPAND, 0, 0);
429 edit_packer.attach (track_canvas_event_box, 1, 2, 2, 3, FILL|EXPAND, FILL|EXPAND, 0, 0);
430 edit_packer.attach (edit_vscrollbar, 2, 3, 2, 3, FILL, FILL|EXPAND, 0, 0);
432 edit_frame.set_name ("BaseFrame");
433 edit_frame.set_shadow_type (SHADOW_IN);
434 edit_frame.add (edit_packer);
436 zoom_in_button.set_name ("EditorTimeButton");
437 zoom_out_button.set_name ("EditorTimeButton");
438 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom in"));
439 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom out"));
441 zoom_out_full_button.set_name ("EditorTimeButton");
442 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to session"));
444 zoom_in_button.add (*(manage (new Image (Stock::ZOOM_IN, ICON_SIZE_BUTTON))));
445 zoom_out_button.add (*(manage (new Image (Stock::ZOOM_OUT, ICON_SIZE_BUTTON))));
446 zoom_out_full_button.add (*(manage (new Image (Stock::ZOOM_FIT, ICON_SIZE_BUTTON))));
448 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
449 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
450 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
452 zoom_indicator_box.pack_start (zoom_out_button, false, false);
453 zoom_indicator_box.pack_start (zoom_in_button, false, false);
454 zoom_indicator_box.pack_start (zoom_range_clock, false, false);
455 zoom_indicator_box.pack_start (zoom_out_full_button, false, false);
457 zoom_indicator_label.set_text (_("Zoom Span"));
458 zoom_indicator_label.set_name ("ToolBarLabel");
460 zoom_indicator_vbox.set_spacing (3);
461 zoom_indicator_vbox.set_border_width (3);
462 zoom_indicator_vbox.pack_start (zoom_indicator_label, false, false);
463 zoom_indicator_vbox.pack_start (zoom_indicator_box, false, false);
465 bottom_hbox.set_border_width (3);
466 bottom_hbox.set_spacing (3);
468 route_display_model = ListStore::create(route_display_columns);
469 route_list_display.set_model (route_display_model);
470 route_list_display.append_column (_("Visible"), route_display_columns.visible);
471 route_list_display.append_column (_("Name"), route_display_columns.text);
472 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
473 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
474 route_list_display.set_headers_visible (true);
475 route_list_display.set_name ("TrackListDisplay");
476 route_list_display.get_selection()->set_mode (SELECTION_NONE);
477 route_list_display.set_reorderable (true);
478 route_list_display.set_size_request (100,-1);
480 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
481 route_list_visible_cell->property_activatable() = true;
482 route_list_visible_cell->property_radio() = false;
484 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
485 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
487 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
489 route_list_scroller.add (route_list_display);
490 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
492 group_model = ListStore::create(group_columns);
493 edit_group_display.set_model (group_model);
494 edit_group_display.append_column (_("Active"), group_columns.is_active);
495 edit_group_display.append_column (_("Visible"), group_columns.is_visible);
496 edit_group_display.append_column (_("Name"), group_columns.text);
497 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
498 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
499 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
500 edit_group_display.set_headers_visible (true);
502 /* use checkbox for the active + visible columns */
504 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (0));
505 active_cell->property_activatable() = true;
506 active_cell->property_radio() = false;
508 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
509 active_cell->property_activatable() = true;
510 active_cell->property_radio() = false;
512 /* name is directly editable */
514 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (2));
515 name_cell->property_editable() = true;
517 edit_group_display.set_name ("EditGroupList");
519 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
521 edit_group_display.set_name ("EditGroupList");
522 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
523 edit_group_display.set_reorderable (false);
524 edit_group_display.set_rules_hint (true);
525 edit_group_display.set_size_request (75, -1);
527 edit_group_display_scroller.add (edit_group_display);
528 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
530 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
532 VBox* edit_group_display_packer = manage (new VBox());
533 HButtonBox* edit_group_display_button_box = manage (new HButtonBox());
534 edit_group_display_button_box->set_homogeneous (true);
535 Button* edit_group_add_button = manage (new Button (Stock::ADD));
536 Button* edit_group_remove_button = manage (new Button(Stock::REMOVE));
538 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
539 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
541 edit_group_display_button_box->pack_start (*edit_group_add_button);
542 edit_group_display_button_box->pack_start (*edit_group_remove_button);
544 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
545 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
547 region_list_display.set_size_request (100, -1);
548 region_list_display.set_name ("RegionListDisplay");
550 region_list_model = TreeStore::create (region_list_columns);
551 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
552 region_list_model->set_sort_column (0, SORT_ASCENDING);
554 region_list_display.set_model (region_list_model);
555 region_list_display.append_column (_("Regions"), region_list_columns.name);
556 region_list_display.set_headers_visible (false);
558 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
560 TreeViewColumn* tv_col = region_list_display.get_column(0);
561 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
562 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
563 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
565 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
566 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
568 /* setup DnD handling */
570 list<TargetEntry> region_list_target_table;
572 region_list_target_table.push_back (TargetEntry ("text/plain"));
573 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
574 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
576 region_list_display.add_drop_targets (region_list_target_table);
577 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
579 region_list_scroller.add (region_list_display);
580 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
582 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
583 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
584 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
585 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
586 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
587 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
589 named_selection_scroller.add (named_selection_display);
590 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
592 named_selection_model = TreeStore::create (named_selection_columns);
593 named_selection_display.set_model (named_selection_model);
594 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
595 named_selection_display.set_headers_visible (false);
596 named_selection_display.set_size_request (100, -1);
597 named_selection_display.set_name ("RegionListDisplay");
599 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
600 named_selection_display.set_size_request (100, -1);
601 named_selection_display.signal_button_press_event().connect (mem_fun(*this, &Editor::named_selection_display_button_press), false);
602 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
606 snapshot_display_model = ListStore::create (snapshot_display_columns);
607 snapshot_display.set_model (snapshot_display_model);
608 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
609 snapshot_display.set_name ("SnapshotDisplayList");
610 snapshot_display.set_size_request (75, -1);
611 snapshot_display.set_headers_visible (false);
612 snapshot_display.set_reorderable (false);
613 snapshot_display_scroller.add (snapshot_display);
614 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
616 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
617 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
619 the_notebook.append_page (region_list_scroller, _("Regions"));
620 the_notebook.append_page (route_list_scroller, _("Tracks/Busses"));
621 the_notebook.append_page (snapshot_display_scroller, _("Snapshots"));
622 the_notebook.append_page (*edit_group_display_packer, _("Edit Groups"));
623 the_notebook.append_page (named_selection_scroller, _("Chunks"));
624 the_notebook.set_show_tabs (true);
625 the_notebook.set_scrollable (true);
626 the_notebook.popup_enable ();
628 TearOff *notebook_tearoff = manage (new TearOff (the_notebook, true));
629 notebook_tearoff->tearoff_window().set_size_request (200, 400);
631 edit_pane.pack1 (edit_frame, true, true);
632 edit_pane.pack2 (*notebook_tearoff, false, true);
634 edit_pane.signal_size_allocate().connect_notify (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
636 top_hbox.pack_start (toolbar_frame, true, true);
638 HBox *hbox = manage (new HBox);
639 hbox->pack_start (edit_pane, true, true);
641 global_vpacker.pack_start (top_hbox, false, false);
642 global_vpacker.pack_start (*hbox, true, true);
644 global_hpacker.pack_start (global_vpacker, true, true);
646 set_name ("EditorWindow");
647 add_accel_group (ActionManager::ui_manager->get_accel_group());
649 vpacker.pack_end (global_hpacker, true, true);
651 /* register actions now so that set_state() can find them and set toggles/checks etc */
655 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
658 _playlist_selector = new PlaylistSelector();
659 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
661 AudioRegionView::AudioRegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_audio_regionview));
665 nudge_forward_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(right_arrow_xpm)))));
666 nudge_backward_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(left_arrow_xpm)))));
668 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge region/selection forwards"));
669 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge region/selection backwards"));
671 nudge_forward_button.set_name ("TransportButton");
672 nudge_backward_button.set_name ("TransportButton");
674 fade_context_menu.set_name ("ArdourContextMenu");
676 set_title (_("ardour: editor"));
677 set_wmclass (_("ardour_editor"), "Ardour");
680 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
682 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
683 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
691 /* <CMT Additions> */
692 if(image_socket_listener)
694 if(image_socket_listener->is_connected())
696 image_socket_listener->close_connection() ;
699 delete image_socket_listener ;
700 image_socket_listener = 0 ;
702 /* </CMT Additions> */
706 Editor::add_toplevel_controls (Container& cont)
708 vpacker.pack_start (cont, false, false);
713 Editor::catch_vanishing_audio_regionview (AudioRegionView *rv)
715 /* note: the selection will take care of the vanishing
716 audioregionview by itself.
719 if (clicked_regionview == rv) {
720 clicked_regionview = 0;
723 if (entered_regionview == rv) {
724 set_entered_regionview (0);
729 Editor::set_entered_regionview (AudioRegionView* rv)
731 if (rv == entered_regionview) {
735 if (entered_regionview) {
736 entered_regionview->exited ();
739 if ((entered_regionview = rv) != 0) {
740 entered_regionview->entered ();
745 Editor::set_entered_track (TimeAxisView* tav)
748 entered_track->exited ();
751 if ((entered_track = tav) != 0) {
752 entered_track->entered ();
757 Editor::left_track_canvas (GdkEventCrossing *ev)
759 set_entered_track (0);
760 set_entered_regionview (0);
766 Editor::show_window ()
771 /* now reset all audio_time_axis heights, because widgets might need
777 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
778 tv = (static_cast<TimeAxisView*>(*i));
784 Editor::tie_vertical_scrolling ()
786 double y1 = vertical_adjustment.get_value();
787 controls_layout.get_vadjustment()->set_value (y1);
788 playhead_cursor->set_y_axis(y1);
789 edit_cursor->set_y_axis(y1);
793 Editor::set_frames_per_unit (double fpu)
795 jack_nframes_t frames;
797 if (fpu == frames_per_unit) {
805 // convert fpu to frame count
807 frames = (jack_nframes_t) floor (fpu * canvas_width);
809 /* don't allow zooms that fit more than the maximum number
810 of frames into an 800 pixel wide space.
813 if (max_frames / fpu < 800.0) {
817 frames_per_unit = fpu;
819 if (frames != zoom_range_clock.current_duration()) {
820 zoom_range_clock.set (frames);
823 /* only update these if we not about to call reposition_x_origin,
824 which will do the same updates.
827 if (session && !no_zoom_repos_update) {
828 horizontal_adjustment.set_upper (session->current_end_frame() / frames_per_unit);
831 if (!no_zoom_repos_update) {
832 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
833 update_fixed_rulers ();
834 tempo_map_changed (Change (0));
837 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
838 if (!selection->tracks.empty()) {
839 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
840 (*i)->reshow_selection (selection->time);
843 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
844 (*i)->reshow_selection (selection->time);
849 ZoomChanged (); /* EMIT_SIGNAL */
851 if (edit_cursor) edit_cursor->set_position (edit_cursor->current_frame);
852 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
859 Editor::instant_save ()
861 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
866 session->add_instant_xml(get_state(), session->path());
868 Config->add_instant_xml(get_state(), Config->get_user_ardour_path());
873 Editor::reposition_x_origin (jack_nframes_t frame)
875 if (frame != leftmost_frame) {
876 leftmost_frame = frame;
877 double pixel = frame_to_pixel (frame);
878 if (pixel >= horizontal_adjustment.get_upper()) {
879 horizontal_adjustment.set_upper (frame_to_pixel (frame + (current_page_frames())));
881 horizontal_adjustment.set_value (frame/frames_per_unit);
882 XOriginChanged (); /* EMIT_SIGNAL */
887 Editor::edit_cursor_clock_changed()
889 if (edit_cursor->current_frame != edit_cursor_clock.current_time()) {
890 edit_cursor->set_position (edit_cursor_clock.current_time());
896 Editor::zoom_adjustment_changed ()
898 if (session == 0 || no_zoom_repos_update) {
902 double fpu = zoom_range_clock.current_duration() / canvas_width;
906 zoom_range_clock.set ((jack_nframes_t) floor (fpu * canvas_width));
907 } else if (fpu > session->current_end_frame() / canvas_width) {
908 fpu = session->current_end_frame() / canvas_width;
909 zoom_range_clock.set ((jack_nframes_t) floor (fpu * canvas_width));
916 Editor::canvas_horizontally_scrolled ()
918 leftmost_frame = (jack_nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
920 update_fixed_rulers ();
922 if (!edit_hscroll_dragging) {
923 tempo_map_changed (Change (0));
925 update_tempo_based_rulers();
930 Editor::reposition_and_zoom (jack_nframes_t frame, double nfpu)
932 if (!repos_zoom_queued) {
933 Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::deferred_reposition_and_zoom), frame, nfpu));
934 repos_zoom_queued = true;
939 Editor::deferred_reposition_and_zoom (jack_nframes_t frame, double nfpu)
941 /* if we need to force an update to the hscroller stuff,
942 don't set no_zoom_repos_update.
945 no_zoom_repos_update = (frame != leftmost_frame);
947 set_frames_per_unit (nfpu);
948 if (no_zoom_repos_update) {
949 reposition_x_origin (frame);
951 no_zoom_repos_update = false;
952 repos_zoom_queued = false;
958 Editor::on_realize ()
960 Window::on_realize ();
965 Editor::queue_session_control_changed (Session::ControlType t)
967 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::session_control_changed), t));
971 Editor::session_control_changed (Session::ControlType t)
973 // right now we're only tracking the loop and punch state
976 case Session::AutoLoop:
977 update_loop_range_view (true);
979 case Session::PunchIn:
980 case Session::PunchOut:
981 update_punch_range_view (true);
990 Editor::fake_handle_new_audio_region (AudioRegion *region)
992 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::handle_new_audio_region), region));
996 Editor::fake_handle_audio_region_removed (AudioRegion *region)
998 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::handle_audio_region_removed), region));
1002 Editor::fake_handle_new_duration ()
1004 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &Editor::handle_new_duration));
1008 Editor::start_scrolling ()
1010 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1011 (mem_fun(*this, &Editor::update_current_screen));
1013 slower_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
1014 (mem_fun(*this, &Editor::update_slower));
1018 Editor::stop_scrolling ()
1020 scroll_connection.disconnect ();
1021 slower_update_connection.disconnect ();
1025 Editor::map_position_change (jack_nframes_t frame)
1027 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1029 if (session == 0 || !_follow_playhead) {
1033 center_screen (frame);
1034 playhead_cursor->set_position (frame);
1038 Editor::center_screen (jack_nframes_t frame)
1040 double page = canvas_width * frames_per_unit;
1042 /* if we're off the page, then scroll.
1045 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1046 center_screen_internal (frame, page);
1051 Editor::center_screen_internal (jack_nframes_t frame, float page)
1056 frame -= (jack_nframes_t) page;
1061 reposition_x_origin (frame);
1065 Editor::handle_new_duration ()
1067 reset_scrolling_region ();
1070 horizontal_adjustment.set_upper (session->current_end_frame() / frames_per_unit);
1071 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1076 Editor::update_title_s (const string & snap_name)
1078 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1084 Editor::update_title ()
1086 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1089 bool dirty = session->dirty();
1091 string wintitle = _("ardour: editor: ");
1097 wintitle += session->name();
1099 if (session->snap_name() != session->name()) {
1101 wintitle += session->snap_name();
1108 set_title (wintitle);
1113 Editor::connect_to_session (Session *t)
1117 if (first_action_message) {
1118 first_action_message->hide();
1123 session->going_away.connect (mem_fun(*this, &Editor::session_going_away));
1125 /* These signals can all be emitted by a non-GUI thread. Therefore the
1126 handlers for them must not attempt to directly interact with the GUI,
1127 but use Gtkmm2ext::UI::instance()->call_slot();
1130 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1131 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1132 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route_p)));
1133 session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::fake_handle_new_audio_region)));
1134 session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::fake_handle_audio_region_removed)));
1135 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::fake_handle_new_duration)));
1136 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1137 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1138 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1139 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1140 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1141 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1142 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1143 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1145 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1146 session_connections.push_back (session->SMPTETypeChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1148 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1150 edit_groups_changed ();
1152 edit_cursor_clock.set_session (session);
1153 selection_start_clock.set_session (session);
1154 selection_end_clock.set_session (session);
1155 zoom_range_clock.set_session (session);
1156 _playlist_selector->set_session (session);
1157 nudge_clock.set_session (session);
1159 switch (session->get_edit_mode()) {
1161 edit_mode_selector.set_active_text (edit_mode_strings[splice_index]);
1165 edit_mode_selector.set_active_text (edit_mode_strings[slide_index]);
1169 Location* loc = session->locations()->auto_loop_location();
1171 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1172 if (loc->start() == loc->end()) {
1173 loc->set_end (loc->start() + 1);
1175 session->locations()->add (loc, false);
1176 session->set_auto_loop_location (loc);
1180 loc->set_name (_("Loop"));
1183 loc = session->locations()->auto_punch_location();
1185 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1186 if (loc->start() == loc->end()) {
1187 loc->set_end (loc->start() + 1);
1189 session->locations()->add (loc, false);
1190 session->set_auto_punch_location (loc);
1194 loc->set_name (_("Punch"));
1197 update_loop_range_view (true);
1198 update_punch_range_view (true);
1200 session->ControlChanged.connect (mem_fun(*this, &Editor::queue_session_control_changed));
1201 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1203 refresh_location_display ();
1204 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1205 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1206 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1207 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1208 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1210 reset_scrolling_region ();
1212 redisplay_regions ();
1213 redisplay_named_selections ();
1214 redisplay_snapshots ();
1216 initial_route_list_display ();
1218 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1219 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1222 /* ::reposition_x_origin() doesn't work right here, since the old
1223 position may be zero already, and it does nothing in such
1229 horizontal_adjustment.set_upper (session->current_end_frame() / frames_per_unit);
1230 horizontal_adjustment.set_value (0);
1232 restore_ruler_visibility ();
1233 tempo_map_changed (Change (0));
1235 edit_cursor->set_position (0);
1236 playhead_cursor->set_position (0);
1240 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1243 /* don't show master bus in a new session */
1245 if (ARDOUR_UI::instance()->session_is_new ()) {
1247 TreeModel::Children rows = route_display_model->children();
1248 TreeModel::Children::iterator i;
1250 no_route_list_redisplay = true;
1252 for (i = rows.begin(); i != rows.end(); ++i) {
1253 TimeAxisView *tv = (*i)[route_display_columns.tv];
1254 AudioTimeAxisView *atv;
1256 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1257 if (atv->route().master()) {
1258 route_list_display.get_selection()->unselect (i);
1263 no_route_list_redisplay = false;
1264 redisplay_route_list ();
1269 Editor::build_cursors ()
1271 using namespace Gdk;
1273 Gdk::Color mbg ("#000000" ); /* Black */
1274 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1277 RefPtr<Bitmap> source, mask;
1278 source = Bitmap::create (mag_bits, mag_width, mag_height);
1279 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1280 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1283 Gdk::Color fbg ("#ffffff" );
1284 Gdk::Color ffg ("#000000" );
1287 RefPtr<Bitmap> source, mask;
1289 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1290 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1291 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1295 RefPtr<Bitmap> source, mask;
1296 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1297 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1298 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1301 grabber_cursor = new Gdk::Cursor (HAND2);
1302 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1303 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1304 selector_cursor = new Gdk::Cursor (XTERM);
1305 time_fx_cursor = new Gdk::Cursor (SIZING);
1306 wait_cursor = new Gdk::Cursor (WATCH);
1307 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1311 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1313 using namespace Menu_Helpers;
1314 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1317 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1321 MenuList& items (fade_context_menu.items());
1325 switch (item_type) {
1327 case FadeInHandleItem:
1328 if (arv->region.fade_in_active()) {
1329 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), false)));
1331 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), true)));
1334 items.push_back (SeparatorElem());
1336 items.push_back (MenuElem (_("Linear"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::Linear)));
1337 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::LogB)));
1338 items.push_back (MenuElem (_("Slow"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::Fast)));
1339 items.push_back (MenuElem (_("Fast"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::LogA)));
1340 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::Slow)));
1344 case FadeOutHandleItem:
1345 if (arv->region.fade_out_active()) {
1346 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), false)));
1348 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), true)));
1351 items.push_back (SeparatorElem());
1353 items.push_back (MenuElem (_("Linear"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::Linear)));
1354 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::Fast)));
1355 items.push_back (MenuElem (_("Slow"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::LogB)));
1356 items.push_back (MenuElem (_("Fast"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::LogA)));
1357 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::Slow)));
1361 fatal << _("programming error: ")
1362 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1367 fade_context_menu.popup (button, time);
1371 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, jack_nframes_t frame)
1373 using namespace Menu_Helpers;
1374 Menu* (Editor::*build_menu_function)(jack_nframes_t);
1377 switch (item_type) {
1379 case AudioRegionViewName:
1380 case AudioRegionViewNameHighlight:
1381 if (with_selection) {
1382 build_menu_function = &Editor::build_track_selection_context_menu;
1384 build_menu_function = &Editor::build_track_region_context_menu;
1389 if (with_selection) {
1390 build_menu_function = &Editor::build_track_selection_context_menu;
1392 build_menu_function = &Editor::build_track_context_menu;
1396 case CrossfadeViewItem:
1397 build_menu_function = &Editor::build_track_crossfade_context_menu;
1401 if (clicked_audio_trackview->get_diskstream()) {
1402 build_menu_function = &Editor::build_track_context_menu;
1404 build_menu_function = &Editor::build_track_bus_context_menu;
1409 /* probably shouldn't happen but if it does, we don't care */
1413 menu = (this->*build_menu_function)(frame);
1414 menu->set_name ("ArdourContextMenu");
1416 /* now handle specific situations */
1418 switch (item_type) {
1420 case AudioRegionViewName:
1421 case AudioRegionViewNameHighlight:
1422 if (!with_selection) {
1423 if (region_edit_menu_split_item) {
1424 if (clicked_regionview && clicked_regionview->region.covers (edit_cursor->current_frame)) {
1425 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
1427 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
1430 if (region_edit_menu_split_multichannel_item) {
1431 if (clicked_regionview && clicked_regionview->region.n_channels() > 1) {
1432 // GTK2FIX find the action, change its sensitivity
1433 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1435 // GTK2FIX see above
1436 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1445 case CrossfadeViewItem:
1452 /* probably shouldn't happen but if it does, we don't care */
1456 if (clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
1458 /* Bounce to disk */
1460 using namespace Menu_Helpers;
1461 MenuList& edit_items = menu->items();
1463 edit_items.push_back (SeparatorElem());
1465 switch (clicked_audio_trackview->audio_track()->freeze_state()) {
1466 case AudioTrack::NoFreeze:
1467 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1470 case AudioTrack::Frozen:
1471 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1474 case AudioTrack::UnFrozen:
1475 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1481 menu->popup (button, time);
1485 Editor::build_track_context_menu (jack_nframes_t ignored)
1487 using namespace Menu_Helpers;
1489 MenuList& edit_items = track_context_menu.items();
1492 add_dstream_context_items (edit_items);
1493 return &track_context_menu;
1497 Editor::build_track_bus_context_menu (jack_nframes_t ignored)
1499 using namespace Menu_Helpers;
1501 MenuList& edit_items = track_context_menu.items();
1504 add_bus_context_items (edit_items);
1505 return &track_context_menu;
1509 Editor::build_track_region_context_menu (jack_nframes_t frame)
1511 using namespace Menu_Helpers;
1512 MenuList& edit_items = track_region_context_menu.items();
1515 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1521 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1522 Playlist::RegionList* regions = pl->regions_at ((jack_nframes_t) floor ( (double)frame * ds->speed()));
1523 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1524 add_region_context_items (atv->view, (*i), edit_items);
1530 add_dstream_context_items (edit_items);
1532 return &track_region_context_menu;
1536 Editor::build_track_crossfade_context_menu (jack_nframes_t frame)
1538 using namespace Menu_Helpers;
1539 MenuList& edit_items = track_crossfade_context_menu.items();
1540 edit_items.clear ();
1542 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1549 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = dynamic_cast<AudioPlaylist*> (pl)) != 0)) {
1551 Playlist::RegionList* regions = pl->regions_at (frame);
1552 AudioPlaylist::Crossfades xfades;
1554 apl->crossfades_at (frame, xfades);
1556 bool many = xfades.size() > 1;
1558 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1559 add_crossfade_context_items (atv->view, (*i), edit_items, many);
1562 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1563 add_region_context_items (atv->view, (*i), edit_items);
1570 add_dstream_context_items (edit_items);
1572 return &track_crossfade_context_menu;
1576 Editor::build_track_selection_context_menu (jack_nframes_t ignored)
1578 using namespace Menu_Helpers;
1579 MenuList& edit_items = track_selection_context_menu.items();
1580 edit_items.clear ();
1582 add_selection_context_items (edit_items);
1583 add_dstream_context_items (edit_items);
1585 return &track_selection_context_menu;
1589 Editor::add_crossfade_context_items (StreamView* view, Crossfade* xfade, Menu_Helpers::MenuList& edit_items, bool many)
1591 using namespace Menu_Helpers;
1592 Menu *xfade_menu = manage (new Menu);
1593 MenuList& items = xfade_menu->items();
1594 xfade_menu->set_name ("ArdourContextMenu");
1597 if (xfade->active()) {
1603 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), xfade)));
1604 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), xfade)));
1606 if (xfade->can_follow_overlap()) {
1608 if (xfade->following_overlap()) {
1609 str = _("Convert to short");
1611 str = _("Convert to full");
1614 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1618 str = xfade->out().name();
1620 str += xfade->in().name();
1622 str = _("Crossfade");
1625 edit_items.push_back (MenuElem (str, *xfade_menu));
1626 edit_items.push_back (SeparatorElem());
1630 Editor::xfade_edit_left_region ()
1632 if (clicked_crossfadeview) {
1633 clicked_crossfadeview->left_view.show_region_editor ();
1638 Editor::xfade_edit_right_region ()
1640 if (clicked_crossfadeview) {
1641 clicked_crossfadeview->right_view.show_region_editor ();
1646 Editor::add_region_context_items (StreamView* sv, Region* region, Menu_Helpers::MenuList& edit_items)
1648 using namespace Menu_Helpers;
1649 Menu *region_menu = manage (new Menu);
1650 MenuList& items = region_menu->items();
1651 region_menu->set_name ("ArdourContextMenu");
1653 AudioRegion* ar = 0;
1656 ar = dynamic_cast<AudioRegion*> (region);
1659 /* when this particular menu pops up, make the relevant region
1663 region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, region));
1665 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1666 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1667 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1668 items.push_back (SeparatorElem());
1669 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_cursor)));
1670 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1671 items.push_back (SeparatorElem());
1673 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::audition_selected_region)));
1674 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1675 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1676 items.push_back (SeparatorElem());
1678 /* XXX hopefully this nonsense will go away with SigC++ 2.X, where the compiler
1679 might be able to figure out which overloaded member function to use in
1683 void (Editor::*type_A_pmf)(void (Region::*pmf)(bool), bool) = &Editor::region_selection_op;
1685 items.push_back (MenuElem (_("Lock"), bind (mem_fun(*this, type_A_pmf), &Region::set_locked, true)));
1686 items.push_back (MenuElem (_("Unlock"), bind (mem_fun(*this, type_A_pmf), &Region::set_locked, false)));
1687 items.push_back (SeparatorElem());
1689 if (region->muted()) {
1690 items.push_back (MenuElem (_("Unmute"), bind (mem_fun(*this, type_A_pmf), &Region::set_muted, false)));
1692 items.push_back (MenuElem (_("Mute"), bind (mem_fun(*this, type_A_pmf), &Region::set_muted, true)));
1694 items.push_back (SeparatorElem());
1696 items.push_back (MenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1697 items.push_back (SeparatorElem());
1702 items.push_back (MenuElem (_("Toggle envelope visibility"), mem_fun(*this, &Editor::toggle_gain_envelope_visibility)));
1703 items.push_back (MenuElem (_("Toggle envelope active"), mem_fun(*this, &Editor::toggle_gain_envelope_active)));
1704 items.push_back (SeparatorElem());
1706 if (ar->scale_amplitude() != 1.0f) {
1707 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1709 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1712 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1713 items.push_back (SeparatorElem());
1717 Menu *nudge_menu = manage (new Menu());
1718 MenuList& nudge_items = nudge_menu->items();
1719 nudge_menu->set_name ("ArdourContextMenu");
1721 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1722 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1723 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1724 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1726 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1727 items.push_back (SeparatorElem());
1729 Menu *trim_menu = manage (new Menu);
1730 MenuList& trim_items = trim_menu->items();
1731 trim_menu->set_name ("ArdourContextMenu");
1733 trim_items.push_back (MenuElem (_("Start to edit cursor"), mem_fun(*this, &Editor::trim_region_from_edit_cursor)));
1734 trim_items.push_back (MenuElem (_("Edit cursor to end"), mem_fun(*this, &Editor::trim_region_to_edit_cursor)));
1736 items.push_back (MenuElem (_("Trim"), *trim_menu));
1737 items.push_back (SeparatorElem());
1739 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1740 region_edit_menu_split_item = &items.back();
1742 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1743 region_edit_menu_split_multichannel_item = &items.back();
1745 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1746 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1747 items.push_back (SeparatorElem());
1748 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1749 items.push_back (SeparatorElem());
1750 items.push_back (MenuElem (_("Destroy"), mem_fun(*this, &Editor::destroy_clicked_region)));
1752 /* OK, stick the region submenu at the top of the list, and then add
1756 /* we have to hack up the region name because "_" has a special
1757 meaning for menu titles.
1760 string::size_type pos = 0;
1761 string menu_item_name = region->name();
1763 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1764 menu_item_name.replace (pos, 1, "__");
1768 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1769 edit_items.push_back (SeparatorElem());
1773 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1775 using namespace Menu_Helpers;
1776 Menu *selection_menu = manage (new Menu);
1777 MenuList& items = selection_menu->items();
1778 selection_menu->set_name ("ArdourContextMenu");
1780 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1781 items.push_back (MenuElem (_("Loop range"), mem_fun(*this, &Editor::set_route_loop_selection)));
1782 items.push_back (SeparatorElem());
1783 items.push_back (MenuElem (_("Separate range to track"), mem_fun(*this, &Editor::separate_region_from_selection)));
1784 items.push_back (MenuElem (_("Separate range to region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1785 items.push_back (SeparatorElem());
1786 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1787 items.push_back (SeparatorElem());
1788 items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1789 items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1790 items.push_back (SeparatorElem());
1791 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1792 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1793 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1794 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::name_selection)));
1795 items.push_back (SeparatorElem());
1796 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1797 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1799 edit_items.push_back (MenuElem (_("Range"), *selection_menu));
1800 edit_items.push_back (SeparatorElem());
1804 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1806 using namespace Menu_Helpers;
1810 Menu *play_menu = manage (new Menu);
1811 MenuList& play_items = play_menu->items();
1812 play_menu->set_name ("ArdourContextMenu");
1814 play_items.push_back (MenuElem (_("Play from edit cursor")));
1815 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1816 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1817 play_items.push_back (SeparatorElem());
1818 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1820 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1824 Menu *select_menu = manage (new Menu);
1825 MenuList& select_items = select_menu->items();
1826 select_menu->set_name ("ArdourContextMenu");
1828 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1829 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1830 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1831 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1832 select_items.push_back (SeparatorElem());
1833 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1834 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1835 select_items.push_back (SeparatorElem());
1836 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1837 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1838 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1839 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1840 select_items.push_back (SeparatorElem());
1842 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1846 Menu *cutnpaste_menu = manage (new Menu);
1847 MenuList& cutnpaste_items = cutnpaste_menu->items();
1848 cutnpaste_menu->set_name ("ArdourContextMenu");
1850 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1851 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1852 cutnpaste_items.push_back (MenuElem (_("Paste at edit cursor"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1853 cutnpaste_items.push_back (MenuElem (_("Paste at mouse"), mem_fun(*this, &Editor::mouse_paste)));
1855 cutnpaste_items.push_back (SeparatorElem());
1857 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1858 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
1860 cutnpaste_items.push_back (SeparatorElem());
1862 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
1864 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
1866 /* Adding new material */
1868 Menu *import_menu = manage (new Menu());
1869 MenuList& import_items = import_menu->items();
1870 import_menu->set_name ("ArdourContextMenu");
1872 import_items.push_back (MenuElem (_("Insert Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
1873 import_items.push_back (MenuElem (_("Insert external sndfile"), bind (mem_fun(*this, &Editor::insert_sndfile), false)));
1875 edit_items.push_back (MenuElem (_("Import"), *import_menu));
1879 Menu *nudge_menu = manage (new Menu());
1880 MenuList& nudge_items = nudge_menu->items();
1881 nudge_menu->set_name ("ArdourContextMenu");
1883 edit_items.push_back (SeparatorElem());
1884 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1885 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1886 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1887 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1889 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1893 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
1895 using namespace Menu_Helpers;
1899 Menu *play_menu = manage (new Menu);
1900 MenuList& play_items = play_menu->items();
1901 play_menu->set_name ("ArdourContextMenu");
1903 play_items.push_back (MenuElem (_("Play from edit cursor")));
1904 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1905 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1909 Menu *select_menu = manage (new Menu);
1910 MenuList& select_items = select_menu->items();
1911 select_menu->set_name ("ArdourContextMenu");
1913 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1914 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1915 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1916 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1917 select_items.push_back (SeparatorElem());
1918 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1919 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1920 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1921 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1923 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1927 Menu *cutnpaste_menu = manage (new Menu);
1928 MenuList& cutnpaste_items = cutnpaste_menu->items();
1929 cutnpaste_menu->set_name ("ArdourContextMenu");
1931 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1932 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1933 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1935 Menu *nudge_menu = manage (new Menu());
1936 MenuList& nudge_items = nudge_menu->items();
1937 nudge_menu->set_name ("ArdourContextMenu");
1939 edit_items.push_back (SeparatorElem());
1940 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1941 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1942 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1943 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1945 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1948 /* CURSOR SETTING AND MARKS AND STUFF */
1951 Editor::set_snap_to (SnapType st)
1954 vector<string> txt = internationalize (snap_type_strings);
1955 snap_type_selector.set_active_text (txt[(int)st]);
1959 switch (snap_type) {
1960 case SnapToAThirtysecondBeat:
1961 case SnapToASixteenthBeat:
1962 case SnapToAEighthBeat:
1963 case SnapToAQuarterBeat:
1964 case SnapToAThirdBeat:
1965 update_tempo_based_rulers ();
1973 Editor::set_snap_mode (SnapMode mode)
1976 vector<string> txt = internationalize (snap_mode_strings);
1977 snap_mode_selector.set_active_text (txt[(int)mode]);
1983 Editor::add_location_from_selection ()
1985 if (selection->time.empty()) {
1989 if (session == 0 || clicked_trackview == 0) {
1993 jack_nframes_t start = selection->time[clicked_selection].start;
1994 jack_nframes_t end = selection->time[clicked_selection].end;
1996 Location *location = new Location (start, end, "selection");
1998 session->begin_reversible_command (_("add marker"));
1999 session->add_undo (session->locations()->get_memento());
2000 session->locations()->add (location, true);
2001 session->add_redo_no_execute (session->locations()->get_memento());
2002 session->commit_reversible_command ();
2006 Editor::add_location_from_playhead_cursor ()
2008 jack_nframes_t where = session->audible_frame();
2010 Location *location = new Location (where, where, "mark", Location::IsMark);
2011 session->begin_reversible_command (_("add marker"));
2012 session->add_undo (session->locations()->get_memento());
2013 session->locations()->add (location, true);
2014 session->add_redo_no_execute (session->locations()->get_memento());
2015 session->commit_reversible_command ();
2020 Editor::set_state (const XMLNode& node)
2022 const XMLProperty* prop;
2024 int x, y, xoff, yoff;
2028 if ((geometry = find_named_node (node, "geometry")) == 0) {
2030 g.base_width = default_width;
2031 g.base_height = default_height;
2039 g.base_width = atoi(geometry->property("x_size")->value());
2040 g.base_height = atoi(geometry->property("y_size")->value());
2041 x = atoi(geometry->property("x_pos")->value());
2042 y = atoi(geometry->property("y_pos")->value());
2043 xoff = atoi(geometry->property("x_off")->value());
2044 yoff = atoi(geometry->property("y_off")->value());
2047 set_geometry_hints (vpacker, g, Gdk::HINT_BASE_SIZE);
2048 set_default_size (g.base_width, g.base_height);
2051 if ((prop = node.property ("zoom-focus"))) {
2052 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2055 if ((prop = node.property ("zoom"))) {
2056 set_frames_per_unit (atof (prop->value()));
2059 if ((prop = node.property ("snap-to"))) {
2060 set_snap_to ((SnapType) atoi (prop->value()));
2063 if ((prop = node.property ("snap-mode"))) {
2064 set_snap_mode ((SnapMode) atoi (prop->value()));
2067 if ((prop = node.property ("mouse-mode"))) {
2068 MouseMode m = str2mousemode(prop->value());
2069 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2070 set_mouse_mode (m, true);
2072 mouse_mode = MouseGain; /* lie, to force the mode switch */
2073 set_mouse_mode (MouseObject, true);
2076 if ((prop = node.property ("show-waveforms"))) {
2077 bool yn = (prop->value() == "yes");
2078 _show_waveforms = !yn;
2079 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
2081 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2082 /* do it twice to force the change */
2083 tact->set_active (!yn);
2084 tact->set_active (yn);
2088 if ((prop = node.property ("show-waveforms-recording"))) {
2089 bool yn = (prop->value() == "yes");
2090 _show_waveforms_recording = !yn;
2091 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2093 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2094 /* do it twice to force the change */
2095 tact->set_active (!yn);
2096 tact->set_active (yn);
2100 if ((prop = node.property ("show-measures"))) {
2101 bool yn = (prop->value() == "yes");
2102 _show_measures = !yn;
2103 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2105 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2106 /* do it twice to force the change */
2107 tact->set_active (!yn);
2108 tact->set_active (yn);
2112 if ((prop = node.property ("follow-playhead"))) {
2113 bool yn = (prop->value() == "yes");
2114 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleFollowPlayhead"));
2116 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2117 /* do it twice to force the change */
2118 tact->set_active (!yn);
2119 tact->set_active (yn);
2124 if ((prop = node.property ("region-list-sort-type"))) {
2125 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2126 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2129 if ((prop = node.property ("xfades-visible"))) {
2130 bool yn = (prop->value() == "yes");
2131 _xfade_visibility = !yn;
2132 set_xfade_visibility (yn);
2135 if ((prop = node.property ("show-editor-mixer"))) {
2137 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2139 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2140 bool yn = (prop->value() == X_("yes"));
2142 /* do it twice to force the change */
2144 tact->set_active (!yn);
2145 tact->set_active (yn);
2153 Editor::get_state ()
2155 XMLNode* node = new XMLNode ("Editor");
2158 if (is_realized()) {
2159 Glib::RefPtr<Gdk::Window> win = get_window();
2161 int x, y, xoff, yoff, width, height;
2162 win->get_root_origin(x, y);
2163 win->get_position(xoff, yoff);
2164 win->get_size(width, height);
2166 XMLNode* geometry = new XMLNode ("geometry");
2168 snprintf(buf, sizeof(buf), "%d", width);
2169 geometry->add_property("x_size", string(buf));
2170 snprintf(buf, sizeof(buf), "%d", height);
2171 geometry->add_property("y_size", string(buf));
2172 snprintf(buf, sizeof(buf), "%d", x);
2173 geometry->add_property("x_pos", string(buf));
2174 snprintf(buf, sizeof(buf), "%d", y);
2175 geometry->add_property("y_pos", string(buf));
2176 snprintf(buf, sizeof(buf), "%d", xoff);
2177 geometry->add_property("x_off", string(buf));
2178 snprintf(buf, sizeof(buf), "%d", yoff);
2179 geometry->add_property("y_off", string(buf));
2180 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2181 geometry->add_property("edit_pane_pos", string(buf));
2183 node->add_child_nocopy (*geometry);
2186 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2187 node->add_property ("zoom-focus", buf);
2188 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2189 node->add_property ("zoom", buf);
2190 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2191 node->add_property ("snap-to", buf);
2192 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2193 node->add_property ("snap-mode", buf);
2195 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2196 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2197 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2198 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2199 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2200 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2201 node->add_property ("mouse-mode", enum2str(mouse_mode));
2203 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2205 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2206 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2215 Editor::trackview_by_y_position (double y)
2217 TrackViewList::iterator iter;
2220 for (iter = track_views.begin(); iter != track_views.end(); ++iter) {
2228 if (tv->y_position <= y && y < ((tv->y_position + tv->height + track_spacing))) {
2237 Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark)
2239 Location* before = 0;
2240 Location* after = 0;
2246 const jack_nframes_t one_second = session->frame_rate();
2247 const jack_nframes_t one_minute = session->frame_rate() * 60;
2249 jack_nframes_t presnap = start;
2251 switch (snap_type) {
2257 start = (jack_nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2259 start = (jack_nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2262 case SnapToSMPTEFrame:
2264 start = (jack_nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2266 start = (jack_nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2270 case SnapToSMPTESeconds:
2271 if (session->smpte_offset_negative())
2273 start += session->smpte_offset ();
2275 start -= session->smpte_offset ();
2277 if (direction > 0) {
2278 start = (jack_nframes_t) ceil ((double) start / one_second) * one_second;
2280 start = (jack_nframes_t) floor ((double) start / one_second) * one_second;
2283 if (session->smpte_offset_negative())
2285 start -= session->smpte_offset ();
2287 start += session->smpte_offset ();
2291 case SnapToSMPTEMinutes:
2292 if (session->smpte_offset_negative())
2294 start += session->smpte_offset ();
2296 start -= session->smpte_offset ();
2299 start = (jack_nframes_t) ceil ((double) start / one_minute) * one_minute;
2301 start = (jack_nframes_t) floor ((double) start / one_minute) * one_minute;
2303 if (session->smpte_offset_negative())
2305 start -= session->smpte_offset ();
2307 start += session->smpte_offset ();
2313 start = (jack_nframes_t) ceil ((double) start / one_second) * one_second;
2315 start = (jack_nframes_t) floor ((double) start / one_second) * one_second;
2321 start = (jack_nframes_t) ceil ((double) start / one_minute) * one_minute;
2323 start = (jack_nframes_t) floor ((double) start / one_minute) * one_minute;
2328 start = session->tempo_map().round_to_bar (start, direction);
2332 start = session->tempo_map().round_to_beat (start, direction);
2335 case SnapToAThirtysecondBeat:
2336 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2339 case SnapToASixteenthBeat:
2340 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2343 case SnapToAEighthBeat:
2344 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2347 case SnapToAQuarterBeat:
2348 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2351 case SnapToAThirdBeat:
2352 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2355 case SnapToEditCursor:
2356 start = edit_cursor->current_frame;
2364 before = session->locations()->first_location_before (start);
2365 after = session->locations()->first_location_after (start);
2367 if (direction < 0) {
2369 start = before->start();
2373 } else if (direction > 0) {
2375 start = after->start();
2377 start = session->current_end_frame();
2382 /* find nearest of the two */
2383 if ((start - before->start()) < (after->start() - start)) {
2384 start = before->start();
2386 start = after->start();
2389 start = before->start();
2392 start = after->start();
2399 case SnapToRegionStart:
2400 case SnapToRegionEnd:
2401 case SnapToRegionSync:
2402 case SnapToRegionBoundary:
2403 if (!region_boundary_cache.empty()) {
2404 vector<jack_nframes_t>::iterator i;
2406 if (direction > 0) {
2407 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2409 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2412 if (i != region_boundary_cache.end()) {
2415 start = region_boundary_cache.back();
2421 switch (snap_mode) {
2427 if (presnap > start) {
2428 if (presnap > (start + unit_to_frame(snap_threshold))) {
2432 } else if (presnap < start) {
2433 if (presnap < (start - unit_to_frame(snap_threshold))) {
2445 Editor::setup_toolbar ()
2448 vector<ToggleButton *> mouse_mode_buttons;
2450 mouse_mode_buttons.push_back (&mouse_move_button);
2451 mouse_mode_buttons.push_back (&mouse_select_button);
2452 mouse_mode_buttons.push_back (&mouse_gain_button);
2453 mouse_mode_buttons.push_back (&mouse_zoom_button);
2454 mouse_mode_buttons.push_back (&mouse_timefx_button);
2455 mouse_mode_buttons.push_back (&mouse_audition_button);
2456 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2458 mouse_mode_button_table.set_homogeneous (true);
2459 mouse_mode_button_table.set_col_spacings (2);
2460 mouse_mode_button_table.set_row_spacings (2);
2461 mouse_mode_button_table.set_border_width (5);
2463 mouse_mode_button_table.attach (mouse_move_button, 0, 1, 0, 1);
2464 mouse_mode_button_table.attach (mouse_select_button, 1, 2, 0, 1);
2465 mouse_mode_button_table.attach (mouse_zoom_button, 2, 3, 0, 1);
2467 mouse_mode_button_table.attach (mouse_gain_button, 0, 1, 1, 2);
2468 mouse_mode_button_table.attach (mouse_timefx_button, 1, 2, 1, 2);
2469 mouse_mode_button_table.attach (mouse_audition_button, 2, 3, 1, 2);
2471 mouse_mode_tearoff = manage (new TearOff (mouse_mode_button_table));
2472 mouse_mode_tearoff->set_name ("MouseModeBase");
2474 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2475 &mouse_mode_tearoff->tearoff_window()));
2476 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2477 &mouse_mode_tearoff->tearoff_window(), 1));
2478 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2479 &mouse_mode_tearoff->tearoff_window()));
2480 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2481 &mouse_mode_tearoff->tearoff_window(), 1));
2483 mouse_move_button.set_name ("MouseModeButton");
2484 mouse_select_button.set_name ("MouseModeButton");
2485 mouse_gain_button.set_name ("MouseModeButton");
2486 mouse_zoom_button.set_name ("MouseModeButton");
2487 mouse_timefx_button.set_name ("MouseModeButton");
2488 mouse_audition_button.set_name ("MouseModeButton");
2490 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("select/move objects"));
2491 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("select/move ranges"));
2492 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("draw gain automation"));
2493 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("select zoom range"));
2494 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("stretch/shrink regions"));
2495 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("listen to specific regions"));
2497 mouse_move_button.unset_flags (CAN_FOCUS);
2498 mouse_select_button.unset_flags (CAN_FOCUS);
2499 mouse_gain_button.unset_flags (CAN_FOCUS);
2500 mouse_zoom_button.unset_flags (CAN_FOCUS);
2501 mouse_timefx_button.unset_flags (CAN_FOCUS);
2502 mouse_audition_button.unset_flags (CAN_FOCUS);
2504 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2505 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2507 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2508 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2509 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2510 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2511 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2513 // mouse_move_button.set_active (true);
2515 /* automation control */
2517 global_automation_button.set_name ("MouseModeButton");
2518 automation_mode_button.set_name ("MouseModeButton");
2520 automation_box.set_spacing (2);
2521 automation_box.set_border_width (2);
2522 automation_box.pack_start (global_automation_button, false, false);
2523 automation_box.pack_start (automation_mode_button, false, false);
2527 edit_mode_label.set_name ("ToolBarLabel");
2529 edit_mode_selector.set_name ("EditModeSelector");
2531 edit_mode_box.set_spacing (3);
2532 edit_mode_box.set_border_width (3);
2534 /* XXX another disgusting hack because of the way combo boxes size themselves */
2536 const guint32 FUDGE = 20; // Combo's are stupid - they steal space from the entry for the button
2537 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, "EdgtMode", 2+FUDGE, 10);
2538 set_popdown_strings (edit_mode_selector, internationalize (edit_mode_strings));
2539 edit_mode_box.pack_start (edit_mode_label, false, false);
2540 edit_mode_box.pack_start (edit_mode_selector, false, false);
2542 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2546 snap_type_label.set_name ("ToolBarLabel");
2548 snap_type_selector.set_name ("SnapTypeSelector");
2550 snap_type_box.set_spacing (3);
2551 snap_type_box.set_border_width (3);
2553 /* XXX another disgusting hack because of the way combo boxes size themselves */
2555 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, "SMPTE Seconds", 2+FUDGE, 10);
2556 set_popdown_strings (snap_type_selector, internationalize (snap_type_strings));
2558 snap_type_box.pack_start (snap_type_label, false, false);
2559 snap_type_box.pack_start (snap_type_selector, false, false);
2561 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2563 /* Snap mode, not snap type */
2565 snap_mode_label.set_name ("ToolBarLabel");
2567 snap_mode_selector.set_name ("SnapModeSelector");
2569 snap_mode_box.set_spacing (3);
2570 snap_mode_box.set_border_width (3);
2572 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, "SngpMode", 2+FUDGE, 10);
2573 set_popdown_strings (snap_mode_selector, internationalize (snap_mode_strings));
2575 snap_mode_box.pack_start (snap_mode_label, false, false);
2576 snap_mode_box.pack_start (snap_mode_selector, false, false);
2578 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2580 /* Zoom focus mode */
2582 zoom_focus_label.set_name ("ToolBarLabel");
2584 zoom_focus_selector.set_name ("ZoomFocusSelector");
2586 zoom_focus_box.set_spacing (3);
2587 zoom_focus_box.set_border_width (3);
2589 /* XXX another disgusting hack because of the way combo boxes size themselves */
2591 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Edgt Cursor", 2+FUDGE, 10);
2592 set_popdown_strings (zoom_focus_selector, internationalize (zoom_focus_strings));
2594 zoom_focus_box.pack_start (zoom_focus_label, false, false);
2595 zoom_focus_box.pack_start (zoom_focus_selector, false, false);
2597 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2599 /* selection/cursor clocks */
2601 toolbar_selection_cursor_label.set_name ("ToolBarLabel");
2602 selection_start_clock_label.set_name ("ToolBarLabel");
2603 selection_end_clock_label.set_name ("ToolBarLabel");
2604 edit_cursor_clock_label.set_name ("ToolBarLabel");
2606 selection_start_clock_label.set_text (_("Start:"));
2607 selection_end_clock_label.set_text (_("End:"));
2608 edit_cursor_clock_label.set_text (_("Edit"));
2610 /* the zoom in/out buttons are generally taller than the clocks, so
2611 put all the toolbar clocks into a size group with one of the
2612 buttons to make them all equal height.
2614 this also applies to the various toolbar combos
2617 RefPtr<SizeGroup> toolbar_clock_size_group = SizeGroup::create (SIZE_GROUP_VERTICAL);
2618 toolbar_clock_size_group->add_widget (zoom_out_button);
2619 toolbar_clock_size_group->add_widget (edit_cursor_clock);
2620 toolbar_clock_size_group->add_widget (zoom_range_clock);
2621 toolbar_clock_size_group->add_widget (nudge_clock);
2622 toolbar_clock_size_group->add_widget (edit_mode_selector);
2623 toolbar_clock_size_group->add_widget (snap_type_selector);
2624 toolbar_clock_size_group->add_widget (snap_mode_selector);
2625 toolbar_clock_size_group->add_widget (zoom_focus_selector);
2627 HBox* edit_clock_hbox = manage (new HBox());
2628 VBox* edit_clock_vbox = manage (new VBox());
2630 edit_clock_hbox->pack_start (edit_cursor_clock, false, false);
2632 edit_clock_vbox->set_spacing (3);
2633 edit_clock_vbox->set_border_width (3);
2634 edit_clock_vbox->pack_start (edit_cursor_clock_label, false, false);
2635 edit_clock_vbox->pack_start (*edit_clock_hbox, false, false);
2637 HBox* hbox = new HBox;
2639 hbox->pack_start (*edit_clock_vbox, false, false);
2640 hbox->pack_start (zoom_indicator_vbox, false, false);
2641 hbox->pack_start (zoom_focus_box, false, false);
2642 hbox->pack_start (snap_type_box, false, false);
2643 hbox->pack_start (snap_mode_box, false, false);
2644 hbox->pack_start (edit_mode_box, false, false);
2646 VBox *vbox = manage (new VBox);
2648 vbox->set_spacing (3);
2649 vbox->set_border_width (3);
2651 HBox *nbox = manage (new HBox);
2653 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2654 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2656 nbox->pack_start (nudge_backward_button, false, false);
2657 nbox->pack_start (nudge_forward_button, false, false);
2658 nbox->pack_start (nudge_clock, false, false, 5);
2660 nudge_label.set_name ("ToolBarLabel");
2662 vbox->pack_start (nudge_label, false, false);
2663 vbox->pack_start (*nbox, false, false);
2665 hbox->pack_start (*vbox, false, false);
2669 tools_tearoff = new TearOff (*hbox);
2670 tools_tearoff->set_name ("MouseModeBase");
2672 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2673 &tools_tearoff->tearoff_window()));
2674 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2675 &tools_tearoff->tearoff_window(), 0));
2676 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2677 &tools_tearoff->tearoff_window()));
2678 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2679 &tools_tearoff->tearoff_window(), 0));
2681 toolbar_hbox.set_spacing (8);
2682 toolbar_hbox.set_border_width (2);
2684 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2685 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2687 toolbar_base.set_name ("ToolBarBase");
2688 toolbar_base.add (toolbar_hbox);
2690 toolbar_frame.set_shadow_type (SHADOW_OUT);
2691 toolbar_frame.set_name ("BaseFrame");
2692 toolbar_frame.add (toolbar_base);
2696 Editor::_autoscroll_canvas (void *arg)
2698 return ((Editor *) arg)->autoscroll_canvas ();
2702 Editor::autoscroll_canvas ()
2704 jack_nframes_t new_frame;
2705 bool keep_calling = true;
2707 if (autoscroll_direction < 0) {
2708 if (leftmost_frame < autoscroll_distance) {
2711 new_frame = leftmost_frame - autoscroll_distance;
2714 if (leftmost_frame > max_frames - autoscroll_distance) {
2715 new_frame = max_frames;
2717 new_frame = leftmost_frame + autoscroll_distance;
2721 if (new_frame != leftmost_frame) {
2722 reposition_x_origin (new_frame);
2725 if (new_frame == 0 || new_frame == max_frames) {
2732 if (autoscroll_cnt == 1) {
2734 /* connect the timeout so that we get called repeatedly */
2736 autoscroll_timeout_tag = gtk_timeout_add (100, _autoscroll_canvas, this);
2737 keep_calling = false;
2739 } else if (autoscroll_cnt > 10 && autoscroll_cnt < 20) {
2741 /* after about a while, speed up a bit by changing the timeout interval */
2743 autoscroll_timeout_tag = gtk_timeout_add (50, _autoscroll_canvas, this);
2744 keep_calling = false;
2746 } else if (autoscroll_cnt >= 20 && autoscroll_cnt < 30) {
2748 /* after about another while, speed up some more */
2750 autoscroll_timeout_tag = gtk_timeout_add (25, _autoscroll_canvas, this);
2751 keep_calling = false;
2753 } else if (autoscroll_cnt >= 30) {
2755 /* we've been scrolling for a while ... crank it up */
2757 autoscroll_distance = 10 * (jack_nframes_t) floor (canvas_width * frames_per_unit);
2760 return keep_calling;
2764 Editor::start_canvas_autoscroll (int dir)
2770 stop_canvas_autoscroll ();
2772 autoscroll_direction = dir;
2773 autoscroll_distance = (jack_nframes_t) floor ((canvas_width * frames_per_unit)/10.0);
2776 /* do it right now, which will start the repeated callbacks */
2778 autoscroll_canvas ();
2782 Editor::stop_canvas_autoscroll ()
2784 if (autoscroll_timeout_tag >= 0) {
2785 gtk_timeout_remove (autoscroll_timeout_tag);
2786 autoscroll_timeout_tag = -1;
2791 Editor::convert_drop_to_paths (vector<string>& paths,
2792 const RefPtr<Gdk::DragContext>& context,
2795 const SelectionData& data,
2804 vector<ustring> uris = data.get_uris();
2808 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
2809 are actually URI lists. So do it by hand.
2812 if (data.get_target() != "text/plain") {
2816 /* Parse the "uri-list" format that Nautilus provides,
2817 where each pathname is delimited by \r\n
2820 const char* p = data.get_text().c_str();
2827 while (g_ascii_isspace (*p))
2831 while (*q && (*q != '\n') && (*q != '\r'))
2837 while (q > p && g_ascii_isspace (*q))
2842 uris.push_back (ustring (p, q - p + 1));
2846 p = strchr (p, '\n');
2856 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
2857 if ((*i).substr (0,7) == "file://") {
2860 paths.push_back (p.substr (7));
2868 Editor::new_tempo_section ()
2874 Editor::map_transport_state ()
2876 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
2878 if (session->transport_stopped()) {
2879 have_pending_keyboard_selection = false;
2885 Editor::State::State ()
2887 selection = new Selection;
2890 Editor::State::~State ()
2896 Editor::get_memento () const
2898 State *state = new State;
2900 store_state (*state);
2901 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
2905 Editor::store_state (State& state) const
2907 *state.selection = *selection;
2911 Editor::restore_state (State *state)
2913 if (*selection == *state->selection) {
2917 *selection = *state->selection;
2918 time_selection_changed ();
2919 cerr << "RS: RSC\n";
2920 region_selection_changed ();
2922 /* XXX other selection change handlers? */
2926 Editor::begin_reversible_command (string name)
2929 UndoAction ua = get_memento();
2930 session->begin_reversible_command (name, &ua);
2935 Editor::commit_reversible_command ()
2938 UndoAction ua = get_memento();
2939 session->commit_reversible_command (&ua);
2944 Editor::set_selected_track_from_click (Selection::Operation op, bool with_undo, bool no_remove)
2946 if (!clicked_trackview) {
2951 begin_reversible_command (_("set selected trackview"));
2955 case Selection::Toggle:
2956 if (selection->selected (clicked_trackview)) {
2958 selection->remove (clicked_trackview);
2961 selection->toggle (clicked_trackview);
2964 case Selection::Set:
2965 if (selection->selected (clicked_trackview) && selection->tracks.size() == 1) {
2966 /* no commit necessary */
2970 selection->set (clicked_trackview);
2973 case Selection::Extend:
2974 /* not defined yet */
2979 commit_reversible_command ();
2984 Editor::set_selected_control_point_from_click (Selection::Operation op, bool with_undo, bool no_remove)
2986 if (!clicked_control_point) {
2991 begin_reversible_command (_("set selected control point"));
2995 case Selection::Set:
2997 case Selection::Toggle:
2999 case Selection::Extend:
3003 commit_reversible_command ();
3008 Editor::mapover_audio_tracks (slot<void,AudioTimeAxisView&,uint32_t> sl)
3010 set<AudioTimeAxisView*> relevant_tracks;
3012 /* step one: get all selected tracks and all tracks in the relevant edit groups */
3014 for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) {
3016 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*ti);
3022 RouteGroup* group = atv->route().edit_group();
3024 if (group && group->is_active()) {
3026 /* active group for this track, loop over all tracks and get every member of the group */
3028 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3030 AudioTimeAxisView* tatv;
3032 if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
3034 if (tatv->route().edit_group() == group) {
3035 relevant_tracks.insert (tatv);
3042 /* no active group, or no group */
3044 relevant_tracks.insert (atv);
3049 /* step two: apply operation to each track */
3051 uint32_t sz = relevant_tracks.size();
3053 for (set<AudioTimeAxisView*>::iterator ati = relevant_tracks.begin(); ati != relevant_tracks.end(); ++ati) {
3059 Editor::mapped_set_selected_regionview_from_click (AudioTimeAxisView& atv, uint32_t ignored,
3060 AudioRegionView* basis, vector<AudioRegionView*>* all_equivs)
3063 vector<AudioRegion*> results;
3064 AudioRegionView* marv;
3067 if ((ds = atv.get_diskstream()) == 0) {
3072 if ((pl = ds->playlist()) != 0) {
3073 pl->get_equivalent_regions (basis->region, results);
3076 for (vector<AudioRegion*>::iterator ir = results.begin(); ir != results.end(); ++ir) {
3077 if ((marv = atv.view->find_view (**ir)) != 0) {
3078 all_equivs->push_back (marv);
3084 Editor::set_selected_regionview_from_click (Selection::Operation op, bool no_track_remove)
3086 cerr << "In SSRfC\n";
3088 vector<AudioRegionView*> all_equivalent_regions;
3090 if (!clicked_regionview) {
3094 mapover_audio_tracks (bind (mem_fun (*this, &Editor::mapped_set_selected_regionview_from_click),
3095 clicked_regionview, &all_equivalent_regions));
3098 cerr << "mapover done\n";
3100 begin_reversible_command (_("set selected regionview"));
3103 case Selection::Toggle:
3104 selection->toggle (clicked_regionview);
3106 if (clicked_regionview->get_selected()) {
3107 if (/* group && group->is_active() && */ selection->audio_regions.size() > 1) {
3108 /* reduce selection down to just the one clicked */
3109 selection->set (clicked_regionview);
3111 selection->remove (clicked_regionview);
3114 selection->add (all_equivalent_regions);
3117 set_selected_track_from_click (op, false, no_track_remove);
3120 case Selection::Set:
3121 // karsten wiese suggested these two lines to make
3122 // a selected region rise to the top. but this
3123 // leads to a mismatch between actual layering
3124 // and visual layering. resolution required ....
3126 // gnome_canvas_item_raise_to_top (clicked_regionview->get_canvas_group());
3127 // gnome_canvas_item_raise_to_top (clicked_regionview->get_time_axis_view().canvas_display);
3129 if (clicked_regionview->get_selected()) {
3130 /* no commit necessary: we are the one selected. */
3135 selection->set (all_equivalent_regions);
3136 set_selected_track_from_click (op, false, false);
3140 case Selection::Extend:
3141 /* not defined yet */
3144 cerr << "case done\n";
3146 commit_reversible_command () ;
3150 Editor::set_selected_regionview_from_region_list (Region& r, Selection::Operation op)
3152 vector<AudioRegionView*> all_equivalent_regions;
3153 AudioRegion* region;
3155 if ((region = dynamic_cast<AudioRegion*>(&r)) == 0) {
3159 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3161 AudioTimeAxisView* tatv;
3163 if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
3166 vector<AudioRegion*> results;
3167 AudioRegionView* marv;
3170 if ((ds = tatv->get_diskstream()) == 0) {
3175 if ((pl = ds->playlist()) != 0) {
3176 pl->get_region_list_equivalent_regions (*region, results);
3179 for (vector<AudioRegion*>::iterator ir = results.begin(); ir != results.end(); ++ir) {
3180 if ((marv = tatv->view->find_view (**ir)) != 0) {
3181 all_equivalent_regions.push_back (marv);
3188 begin_reversible_command (_("set selected regions"));
3191 case Selection::Toggle:
3192 /* XXX this is not correct */
3193 selection->add (all_equivalent_regions);
3195 case Selection::Set:
3196 selection->set (all_equivalent_regions);
3198 case Selection::Extend:
3199 /* not defined yet */
3203 commit_reversible_command () ;
3207 Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, Region* r)
3209 AudioRegionView* rv;
3212 if ((ar = dynamic_cast<AudioRegion*> (r)) == 0) {
3216 if ((rv = sv->find_view (*ar)) == 0) {
3220 /* don't reset the selection if its something other than
3221 a single other region.
3224 if (selection->audio_regions.size() > 1) {
3228 begin_reversible_command (_("set selected regions"));
3230 selection->set (rv);
3232 commit_reversible_command () ;
3238 Editor::set_edit_group_solo (Route& route, bool yn)
3240 RouteGroup *edit_group;
3242 if ((edit_group = route.edit_group()) != 0) {
3243 edit_group->apply (&Route::set_solo, yn, this);
3245 route.set_solo (yn, this);
3250 Editor::set_edit_group_mute (Route& route, bool yn)
3252 RouteGroup *edit_group = 0;
3254 if ((edit_group == route.edit_group()) != 0) {
3255 edit_group->apply (&Route::set_mute, yn, this);
3257 route.set_mute (yn, this);
3262 Editor::set_edit_menu (Menu& menu)
3265 edit_menu->signal_map_event().connect (mem_fun(*this, &Editor::edit_menu_map_handler));
3269 Editor::edit_menu_map_handler (GdkEventAny* ev)
3271 using namespace Menu_Helpers;
3272 MenuList& edit_items = edit_menu->items();
3275 /* Nuke all the old items */
3277 edit_items.clear ();
3283 if (session->undo_depth() == 0) {
3286 label = string_compose(_("Undo (%1)"), session->next_undo());
3289 edit_items.push_back (MenuElem (label, bind (mem_fun(*this, &Editor::undo), 1U)));
3291 if (session->undo_depth() == 0) {
3292 edit_items.back().set_sensitive (false);
3295 if (session->redo_depth() == 0) {
3298 label = string_compose(_("Redo (%1)"), session->next_redo());
3301 edit_items.push_back (MenuElem (label, bind (mem_fun(*this, &Editor::redo), 1U)));
3302 if (session->redo_depth() == 0) {
3303 edit_items.back().set_sensitive (false);
3306 vector<MenuItem*> mitems;
3308 edit_items.push_back (SeparatorElem());
3309 edit_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
3310 mitems.push_back (&edit_items.back());
3311 edit_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
3312 mitems.push_back (&edit_items.back());
3313 edit_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
3314 mitems.push_back (&edit_items.back());
3315 edit_items.push_back (SeparatorElem());
3316 edit_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
3317 mitems.push_back (&edit_items.back());
3318 edit_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
3319 mitems.push_back (&edit_items.back());
3320 edit_items.push_back (SeparatorElem());
3322 if (selection->empty()) {
3323 for (vector<MenuItem*>::iterator i = mitems.begin(); i != mitems.end(); ++i) {
3324 (*i)->set_sensitive (false);
3328 Menu* import_menu = manage (new Menu());
3329 import_menu->set_name ("ArdourContextMenu");
3330 MenuList& import_items = import_menu->items();
3332 import_items.push_back (MenuElem (_("... as new track"), bind (mem_fun(*this, &Editor::import_audio), true)));
3333 import_items.push_back (MenuElem (_("... as new region"), bind (mem_fun(*this, &Editor::import_audio), false)));
3335 Menu* embed_menu = manage (new Menu());
3336 embed_menu->set_name ("ArdourContextMenu");
3337 MenuList& embed_items = embed_menu->items();
3339 embed_items.push_back (MenuElem (_("... as new track"), bind (mem_fun(*this, &Editor::insert_sndfile), true)));
3340 embed_items.push_back (MenuElem (_("... as new region"), mem_fun(*this, &Editor::embed_audio)));
3342 edit_items.push_back (MenuElem (_("Import audio (copy)"), *import_menu));
3343 edit_items.push_back (MenuElem (_("Embed audio (link)"), *embed_menu));
3344 edit_items.push_back (SeparatorElem());
3346 edit_items.push_back (MenuElem (_("Remove last capture"), mem_fun(*this, &Editor::remove_last_capture)));
3347 if (!session->have_captured()) {
3348 edit_items.back().set_sensitive (false);
3355 Editor::duplicate_dialog (bool dup_region)
3358 if (clicked_regionview == 0) {
3362 if (selection->time.length() == 0) {
3367 ArdourDialog win ("duplicate dialog");
3369 Label label (_("Duplicate how many times?"));
3371 win.get_vbox()->pack_start (label);
3372 win.add_action_widget (entry, RESPONSE_ACCEPT);
3373 win.add_button (Stock::OK, RESPONSE_ACCEPT);
3374 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3376 win.set_position (WIN_POS_MOUSE);
3378 entry.set_text ("1");
3379 set_size_request_to_display_given_text (entry, X_("12345678"), 20, 15);
3380 entry.select_region (0, entry.get_text_length());
3381 entry.grab_focus ();
3384 switch (win.run ()) {
3385 case RESPONSE_ACCEPT:
3391 string text = entry.get_text();
3394 if (sscanf (text.c_str(), "%f", ×) == 1) {
3396 AudioRegionSelection regions;
3397 regions.add (clicked_regionview);
3398 duplicate_some_regions (regions, times);
3400 duplicate_selection (times);
3406 Editor::show_verbose_canvas_cursor ()
3408 verbose_canvas_cursor->raise_to_top();
3409 verbose_canvas_cursor->show();
3410 verbose_cursor_visible = true;
3414 Editor::hide_verbose_canvas_cursor ()
3416 verbose_canvas_cursor->hide();
3417 verbose_cursor_visible = false;
3421 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3423 /* XXX get origin of canvas relative to root window,
3424 add x and y and check compared to gdk_screen_{width,height}
3426 verbose_canvas_cursor->property_text() = txt.c_str();
3427 verbose_canvas_cursor->property_x() = x;
3428 verbose_canvas_cursor->property_y() = y;
3432 Editor::set_verbose_canvas_cursor_text (const string & txt)
3434 verbose_canvas_cursor->property_text() = txt.c_str();
3438 Editor::edit_mode_selection_done ()
3444 string choice = edit_mode_selector.get_active_text();
3445 EditMode mode = Slide;
3447 if (choice == _("Splice")) {
3449 } else if (choice == _("Slide")) {
3453 session->set_edit_mode (mode);
3457 Editor::snap_type_selection_done ()
3463 string choice = snap_type_selector.get_active_text();
3464 SnapType snaptype = SnapToFrame;
3466 if (choice == _("Beats/3")) {
3467 snaptype = SnapToAThirdBeat;
3468 } else if (choice == _("Beats/4")) {
3469 snaptype = SnapToAQuarterBeat;
3470 } else if (choice == _("Beats/8")) {
3471 snaptype = SnapToAEighthBeat;
3472 } else if (choice == _("Beats/16")) {
3473 snaptype = SnapToASixteenthBeat;
3474 } else if (choice == _("Beats/32")) {
3475 snaptype = SnapToAThirtysecondBeat;
3476 } else if (choice == _("Beats")) {
3477 snaptype = SnapToBeat;
3478 } else if (choice == _("Bars")) {
3479 snaptype = SnapToBar;
3480 } else if (choice == _("Marks")) {
3481 snaptype = SnapToMark;
3482 } else if (choice == _("Edit Cursor")) {
3483 snaptype = SnapToEditCursor;
3484 } else if (choice == _("Region starts")) {
3485 snaptype = SnapToRegionStart;
3486 } else if (choice == _("Region ends")) {
3487 snaptype = SnapToRegionEnd;
3488 } else if (choice == _("Region bounds")) {
3489 snaptype = SnapToRegionBoundary;
3490 } else if (choice == _("Region syncs")) {
3491 snaptype = SnapToRegionSync;
3492 } else if (choice == _("CD Frames")) {
3493 snaptype = SnapToCDFrame;
3494 } else if (choice == _("SMPTE Frames")) {
3495 snaptype = SnapToSMPTEFrame;
3496 } else if (choice == _("SMPTE Seconds")) {
3497 snaptype = SnapToSMPTESeconds;
3498 } else if (choice == _("SMPTE Minutes")) {
3499 snaptype = SnapToSMPTEMinutes;
3500 } else if (choice == _("Seconds")) {
3501 snaptype = SnapToSeconds;
3502 } else if (choice == _("Minutes")) {
3503 snaptype = SnapToMinutes;
3504 } else if (choice == _("None")) {
3505 snaptype = SnapToFrame;
3508 set_snap_to (snaptype);
3512 Editor::snap_mode_selection_done ()
3518 string choice = snap_mode_selector.get_active_text();
3519 SnapMode mode = SnapNormal;
3521 if (choice == _("Normal")) {
3523 } else if (choice == _("Magnetic")) {
3524 mode = SnapMagnetic;
3527 set_snap_mode (mode);
3531 Editor::zoom_focus_selection_done ()
3537 string choice = zoom_focus_selector.get_active_text();
3538 ZoomFocus focus_type = ZoomFocusLeft;
3540 if (choice == _("Left")) {
3541 focus_type = ZoomFocusLeft;
3542 } else if (choice == _("Right")) {
3543 focus_type = ZoomFocusRight;
3544 } else if (choice == _("Center")) {
3545 focus_type = ZoomFocusCenter;
3546 } else if (choice == _("Playhead")) {
3547 focus_type = ZoomFocusPlayhead;
3548 } else if (choice == _("Edit Cursor")) {
3549 focus_type = ZoomFocusEdit;
3552 set_zoom_focus (focus_type);
3556 Editor::edit_controls_button_release (GdkEventButton* ev)
3558 if (Keyboard::is_context_menu_event (ev)) {
3559 ARDOUR_UI::instance()->add_route ();
3565 Editor::track_selection_changed ()
3567 switch (selection->tracks.size()){
3571 set_selected_mixer_strip (*(selection->tracks.front()));
3575 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3576 (*i)->set_selected (false);
3577 if (mouse_mode == MouseRange) {
3578 (*i)->hide_selection ();
3582 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3583 (*i)->set_selected (true);
3584 if (mouse_mode == MouseRange) {
3585 (*i)->show_selection (selection->time);
3591 Editor::time_selection_changed ()
3593 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3594 (*i)->hide_selection ();
3597 if (selection->tracks.empty()) {
3598 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3599 (*i)->show_selection (selection->time);
3602 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3603 (*i)->show_selection (selection->time);
3607 if (selection->time.empty()) {
3608 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
3610 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true);
3615 Editor::region_selection_changed ()
3617 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3618 (*i)->set_selected_regionviews (selection->audio_regions);
3623 Editor::point_selection_changed ()
3625 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3626 (*i)->set_selected_points (selection->points);
3631 Editor::mouse_select_button_release (GdkEventButton* ev)
3633 /* this handles just right-clicks */
3635 if (ev->button != 3) {
3642 Editor::TrackViewList *
3643 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3646 TrackViewList::iterator i;
3648 v = new TrackViewList;
3650 if (track == 0 && group == 0) {
3654 for (i = track_views.begin(); i != track_views.end (); ++i) {
3658 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3660 /* just the view for this track
3663 v->push_back (track);
3667 /* views for all tracks in the edit group */
3669 for (i = track_views.begin(); i != track_views.end (); ++i) {
3671 if (group == 0 || (*i)->edit_group() == group) {
3681 Editor::set_zoom_focus (ZoomFocus f)
3683 if (zoom_focus != f) {
3685 vector<string> txt = internationalize (zoom_focus_strings);
3686 zoom_focus_selector.set_active_text (txt[(int)f]);
3687 ZoomFocusChanged (); /* EMIT_SIGNAL */
3694 Editor::ensure_float (Window& win)
3696 win.set_transient_for (*this);
3700 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3702 /* recover or initialize pane positions. do this here rather than earlier because
3703 we don't want the positions to change the child allocations, which they seem to do.
3709 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3711 static int32_t done;
3714 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3715 width = default_width;
3716 height = default_height;
3718 width = atoi(geometry->property("x_size")->value());
3719 height = atoi(geometry->property("y_size")->value());
3722 if (which == static_cast<Paned*> (&edit_pane)) {
3728 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3729 /* initial allocation is 90% to canvas, 10% to notebook */
3730 pos = (int) floor (alloc.get_width() * 0.90f);
3731 snprintf (buf, sizeof(buf), "%d", pos);
3733 pos = atoi (prop->value());
3736 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3737 edit_pane.set_position (pos);
3738 pre_maximal_pane_position = pos;
3744 Editor::detach_tearoff (Box* b, Window* w)
3746 if (tools_tearoff->torn_off() &&
3747 mouse_mode_tearoff->torn_off()) {
3748 top_hbox.remove (toolbar_frame);
3753 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3755 if (toolbar_frame.get_parent() == 0) {
3756 top_hbox.pack_end (toolbar_frame);
3761 Editor::set_show_measures (bool yn)
3763 if (_show_measures != yn) {
3766 if ((_show_measures = yn) == true) {
3769 DisplayControlChanged (ShowMeasures);
3775 Editor::toggle_follow_playhead ()
3777 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleFollowPlayhead"));
3779 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3780 set_follow_playhead (tact->get_active());
3785 Editor::set_follow_playhead (bool yn)
3787 if (_follow_playhead != yn) {
3788 if ((_follow_playhead = yn) == true) {
3790 update_current_screen ();
3792 DisplayControlChanged (FollowPlayhead);
3798 Editor::toggle_xfade_active (Crossfade* xfade)
3800 xfade->set_active (!xfade->active());
3804 Editor::toggle_xfade_length (Crossfade* xfade)
3806 xfade->set_follow_overlap (!xfade->following_overlap());
3810 Editor::edit_xfade (Crossfade* xfade)
3812 CrossfadeEditor cew (*session, *xfade, xfade->fade_in().get_min_y(), 1.0);
3816 switch (cew.run ()) {
3817 case RESPONSE_ACCEPT:
3824 xfade->StateChanged (Change (~0));
3828 Editor::playlist_selector () const
3830 return *_playlist_selector;
3834 Editor::get_nudge_distance (jack_nframes_t pos, jack_nframes_t& next)
3838 ret = nudge_clock.current_duration (pos);
3839 next = ret + 1; /* XXXX fix me */
3845 Editor::end_location_changed (Location* location)
3847 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3848 horizontal_adjustment.set_upper (location->end() / frames_per_unit);
3852 Editor::playlist_deletion_dialog (Playlist* pl)
3854 ArdourDialog dialog ("playlist deletion dialog");
3855 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3856 "If left alone, no audio files used by it will be cleaned.\n"
3857 "If deleted, audio files used by it alone by will cleaned."),
3860 dialog.set_position (WIN_POS_CENTER);
3861 dialog.get_vbox()->pack_start (label);
3863 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3864 dialog.add_button (_("Keep playlist"), RESPONSE_CANCEL);
3865 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3867 switch (dialog.run ()) {
3868 case RESPONSE_ACCEPT:
3869 /* delete the playlist */
3873 case RESPONSE_REJECT:
3874 /* keep the playlist */
3886 Editor::audio_region_selection_covers (jack_nframes_t where)
3888 for (AudioRegionSelection::iterator a = selection->audio_regions.begin(); a != selection->audio_regions.end(); ++a) {
3889 if ((*a)->region.covers (where)) {
3898 Editor::prepare_for_cleanup ()
3900 cut_buffer->clear_audio_regions ();
3901 cut_buffer->clear_playlists ();
3903 selection->clear_audio_regions ();
3904 selection->clear_playlists ();
3908 Editor::transport_loop_location()
3911 return session->locations()->auto_loop_location();
3918 Editor::transport_punch_location()
3921 return session->locations()->auto_punch_location();
3928 Editor::control_layout_scroll (GdkEventScroll* ev)
3930 switch (ev->direction) {
3932 scroll_tracks_up_line ();
3936 case GDK_SCROLL_DOWN:
3937 scroll_tracks_down_line ();
3941 /* no left/right handling yet */
3949 Editor::snapshot_display_selection_changed ()
3951 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
3953 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
3955 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
3957 if (snap_name.length() == 0) {
3961 if (session->snap_name() == snap_name) {
3965 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
3970 Editor::snapshot_display_button_press (GdkEventButton* ev)
3976 Editor::redisplay_snapshots ()
3982 vector<string*>* states;
3984 if ((states = session->possible_states()) == 0) {
3988 snapshot_display_model->clear ();
3990 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
3991 string statename = *(*i);
3992 TreeModel::Row row = *(snapshot_display_model->append());
3993 row[snapshot_display_columns.visible_name] = statename;
3994 row[snapshot_display_columns.real_name] = statename;
4001 Editor::session_state_saved (string snap_name)
4003 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4004 redisplay_snapshots ();
4008 Editor::maximise_editing_space ()
4010 mouse_mode_tearoff->set_visible (false);
4011 tools_tearoff->set_visible (false);
4013 pre_maximal_pane_position = edit_pane.get_position();
4014 edit_pane.set_position (edit_pane.get_width());
4020 Editor::restore_editing_space ()
4022 mouse_mode_tearoff->set_visible (true);
4023 tools_tearoff->set_visible (true);
4024 edit_pane.set_position (pre_maximal_pane_position);
4030 Editor::new_playlists ()
4032 begin_reversible_command (_("new playlists"));
4033 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist));
4034 commit_reversible_command ();
4038 Editor::copy_playlists ()
4040 begin_reversible_command (_("copy playlists"));
4041 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist));
4042 commit_reversible_command ();
4046 Editor::clear_playlists ()
4048 begin_reversible_command (_("clear playlists"));
4049 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist));
4050 commit_reversible_command ();
4054 Editor::mapped_use_new_playlist (AudioTimeAxisView& atv, uint32_t sz)
4056 atv.use_new_playlist (sz > 1 ? false : true);
4060 Editor::mapped_use_copy_playlist (AudioTimeAxisView& atv, uint32_t sz)
4062 atv.use_copy_playlist (sz > 1 ? false : true);
4066 Editor::mapped_clear_playlist (AudioTimeAxisView& atv, uint32_t sz)
4068 atv.clear_playlist ();
4072 Editor::on_key_press_event (GdkEventKey* ev)
4074 return key_press_focus_accelerator_handler (*this, ev);