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 (_("Name"), group_columns.text);
495 edit_group_display.append_column (_("Active"), group_columns.is_active);
496 edit_group_display.append_column (_("Visible"), group_columns.is_visible);
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 /* name is directly editable */
504 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
505 name_cell->property_editable() = true;
506 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
508 /* use checkbox for the active + visible columns */
510 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
511 active_cell->property_activatable() = true;
512 active_cell->property_radio() = false;
514 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
515 active_cell->property_activatable() = true;
516 active_cell->property_radio() = false;
518 edit_group_display.set_name ("EditGroupList");
520 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
522 edit_group_display.set_name ("EditGroupList");
523 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
524 edit_group_display.set_reorderable (false);
525 edit_group_display.set_rules_hint (true);
526 edit_group_display.set_size_request (75, -1);
528 edit_group_display_scroller.add (edit_group_display);
529 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
531 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
533 VBox* edit_group_display_packer = manage (new VBox());
534 HButtonBox* edit_group_display_button_box = manage (new HButtonBox());
535 edit_group_display_button_box->set_homogeneous (true);
537 Button* edit_group_add_button = manage (new Button ());
538 Button* edit_group_remove_button = manage (new Button ());
542 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
544 edit_group_add_button->add (*w);
546 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
548 edit_group_remove_button->add (*w);
550 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
551 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
553 edit_group_display_button_box->pack_start (*edit_group_add_button);
554 edit_group_display_button_box->pack_start (*edit_group_remove_button);
556 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
557 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
559 region_list_display.set_size_request (100, -1);
560 region_list_display.set_name ("RegionListDisplay");
562 region_list_model = TreeStore::create (region_list_columns);
563 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
564 region_list_model->set_sort_column (0, SORT_ASCENDING);
566 region_list_display.set_model (region_list_model);
567 region_list_display.append_column (_("Regions"), region_list_columns.name);
568 region_list_display.set_headers_visible (false);
570 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
572 TreeViewColumn* tv_col = region_list_display.get_column(0);
573 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
574 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
575 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
577 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
578 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
580 /* setup DnD handling */
582 list<TargetEntry> region_list_target_table;
584 region_list_target_table.push_back (TargetEntry ("text/plain"));
585 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
586 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
588 region_list_display.add_drop_targets (region_list_target_table);
589 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
591 region_list_scroller.add (region_list_display);
592 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
594 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
595 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
596 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
597 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
598 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
599 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
601 named_selection_scroller.add (named_selection_display);
602 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
604 named_selection_model = TreeStore::create (named_selection_columns);
605 named_selection_display.set_model (named_selection_model);
606 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
607 named_selection_display.set_headers_visible (false);
608 named_selection_display.set_size_request (100, -1);
609 named_selection_display.set_name ("RegionListDisplay");
611 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
612 named_selection_display.set_size_request (100, -1);
613 named_selection_display.signal_button_press_event().connect (mem_fun(*this, &Editor::named_selection_display_button_press), false);
614 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
618 snapshot_display_model = ListStore::create (snapshot_display_columns);
619 snapshot_display.set_model (snapshot_display_model);
620 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
621 snapshot_display.set_name ("SnapshotDisplayList");
622 snapshot_display.set_size_request (75, -1);
623 snapshot_display.set_headers_visible (false);
624 snapshot_display.set_reorderable (false);
625 snapshot_display_scroller.add (snapshot_display);
626 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
628 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
629 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
631 the_notebook.append_page (region_list_scroller, _("Regions"));
632 the_notebook.append_page (route_list_scroller, _("Tracks/Busses"));
633 the_notebook.append_page (snapshot_display_scroller, _("Snapshots"));
634 the_notebook.append_page (*edit_group_display_packer, _("Edit Groups"));
635 the_notebook.append_page (named_selection_scroller, _("Chunks"));
636 the_notebook.set_show_tabs (true);
637 the_notebook.set_scrollable (true);
638 the_notebook.popup_enable ();
640 TearOff *notebook_tearoff = manage (new TearOff (the_notebook, true));
641 notebook_tearoff->tearoff_window().set_size_request (200, 400);
643 edit_pane.pack1 (edit_frame, true, true);
644 edit_pane.pack2 (*notebook_tearoff, false, true);
646 edit_pane.signal_size_allocate().connect_notify (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
648 top_hbox.pack_start (toolbar_frame, true, true);
650 HBox *hbox = manage (new HBox);
651 hbox->pack_start (edit_pane, true, true);
653 global_vpacker.pack_start (top_hbox, false, false);
654 global_vpacker.pack_start (*hbox, true, true);
656 global_hpacker.pack_start (global_vpacker, true, true);
658 set_name ("EditorWindow");
659 add_accel_group (ActionManager::ui_manager->get_accel_group());
661 vpacker.pack_end (global_hpacker, true, true);
663 /* register actions now so that set_state() can find them and set toggles/checks etc */
667 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
670 _playlist_selector = new PlaylistSelector();
671 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
673 AudioRegionView::AudioRegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_audio_regionview));
677 nudge_forward_button.add (*(manage (new Image (get_xpm("right_arrow.xpm")))));
678 nudge_backward_button.add (*(manage (new Image (get_xpm("left_arrow.xpm")))));
680 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge region/selection forwards"));
681 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge region/selection backwards"));
683 nudge_forward_button.set_name ("TransportButton");
684 nudge_backward_button.set_name ("TransportButton");
686 fade_context_menu.set_name ("ArdourContextMenu");
688 set_title (_("ardour: editor"));
689 set_wmclass (_("ardour_editor"), "Ardour");
692 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
694 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
695 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
703 /* <CMT Additions> */
704 if(image_socket_listener)
706 if(image_socket_listener->is_connected())
708 image_socket_listener->close_connection() ;
711 delete image_socket_listener ;
712 image_socket_listener = 0 ;
714 /* </CMT Additions> */
718 Editor::add_toplevel_controls (Container& cont)
720 vpacker.pack_start (cont, false, false);
725 Editor::catch_vanishing_audio_regionview (AudioRegionView *rv)
727 /* note: the selection will take care of the vanishing
728 audioregionview by itself.
731 if (clicked_regionview == rv) {
732 clicked_regionview = 0;
735 if (entered_regionview == rv) {
736 set_entered_regionview (0);
741 Editor::set_entered_regionview (AudioRegionView* rv)
743 if (rv == entered_regionview) {
747 if (entered_regionview) {
748 entered_regionview->exited ();
751 if ((entered_regionview = rv) != 0) {
752 entered_regionview->entered ();
757 Editor::set_entered_track (TimeAxisView* tav)
760 entered_track->exited ();
763 if ((entered_track = tav) != 0) {
764 entered_track->entered ();
769 Editor::left_track_canvas (GdkEventCrossing *ev)
771 set_entered_track (0);
772 set_entered_regionview (0);
778 Editor::show_window ()
783 /* now reset all audio_time_axis heights, because widgets might need
789 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
790 tv = (static_cast<TimeAxisView*>(*i));
796 Editor::tie_vertical_scrolling ()
798 double y1 = vertical_adjustment.get_value();
799 controls_layout.get_vadjustment()->set_value (y1);
800 playhead_cursor->set_y_axis(y1);
801 edit_cursor->set_y_axis(y1);
805 Editor::set_frames_per_unit (double fpu)
807 jack_nframes_t frames;
809 if (fpu == frames_per_unit) {
817 // convert fpu to frame count
819 frames = (jack_nframes_t) floor (fpu * canvas_width);
821 /* don't allow zooms that fit more than the maximum number
822 of frames into an 800 pixel wide space.
825 if (max_frames / fpu < 800.0) {
829 frames_per_unit = fpu;
831 if (frames != zoom_range_clock.current_duration()) {
832 zoom_range_clock.set (frames);
835 /* only update these if we not about to call reposition_x_origin,
836 which will do the same updates.
839 if (session && !no_zoom_repos_update) {
840 horizontal_adjustment.set_upper (session->current_end_frame() / frames_per_unit);
843 if (!no_zoom_repos_update) {
844 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
845 update_fixed_rulers ();
846 tempo_map_changed (Change (0));
849 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
850 if (!selection->tracks.empty()) {
851 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
852 (*i)->reshow_selection (selection->time);
855 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
856 (*i)->reshow_selection (selection->time);
861 ZoomChanged (); /* EMIT_SIGNAL */
863 if (edit_cursor) edit_cursor->set_position (edit_cursor->current_frame);
864 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
871 Editor::instant_save ()
873 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
878 session->add_instant_xml(get_state(), session->path());
880 Config->add_instant_xml(get_state(), Config->get_user_ardour_path());
885 Editor::reposition_x_origin (jack_nframes_t frame)
887 if (frame != leftmost_frame) {
888 leftmost_frame = frame;
889 double pixel = frame_to_pixel (frame);
890 if (pixel >= horizontal_adjustment.get_upper()) {
891 horizontal_adjustment.set_upper (frame_to_pixel (frame + (current_page_frames())));
893 horizontal_adjustment.set_value (frame/frames_per_unit);
894 XOriginChanged (); /* EMIT_SIGNAL */
899 Editor::edit_cursor_clock_changed()
901 if (edit_cursor->current_frame != edit_cursor_clock.current_time()) {
902 edit_cursor->set_position (edit_cursor_clock.current_time());
908 Editor::zoom_adjustment_changed ()
910 if (session == 0 || no_zoom_repos_update) {
914 double fpu = zoom_range_clock.current_duration() / canvas_width;
918 zoom_range_clock.set ((jack_nframes_t) floor (fpu * canvas_width));
919 } else if (fpu > session->current_end_frame() / canvas_width) {
920 fpu = session->current_end_frame() / canvas_width;
921 zoom_range_clock.set ((jack_nframes_t) floor (fpu * canvas_width));
928 Editor::canvas_horizontally_scrolled ()
930 leftmost_frame = (jack_nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
932 update_fixed_rulers ();
934 if (!edit_hscroll_dragging) {
935 tempo_map_changed (Change (0));
937 update_tempo_based_rulers();
942 Editor::reposition_and_zoom (jack_nframes_t frame, double nfpu)
944 if (!repos_zoom_queued) {
945 Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::deferred_reposition_and_zoom), frame, nfpu));
946 repos_zoom_queued = true;
951 Editor::deferred_reposition_and_zoom (jack_nframes_t frame, double nfpu)
953 /* if we need to force an update to the hscroller stuff,
954 don't set no_zoom_repos_update.
957 no_zoom_repos_update = (frame != leftmost_frame);
959 set_frames_per_unit (nfpu);
960 if (no_zoom_repos_update) {
961 reposition_x_origin (frame);
963 no_zoom_repos_update = false;
964 repos_zoom_queued = false;
970 Editor::on_realize ()
972 Window::on_realize ();
977 Editor::queue_session_control_changed (Session::ControlType t)
979 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::session_control_changed), t));
983 Editor::session_control_changed (Session::ControlType t)
985 // right now we're only tracking the loop and punch state
988 case Session::AutoLoop:
989 update_loop_range_view (true);
991 case Session::PunchIn:
992 case Session::PunchOut:
993 update_punch_range_view (true);
1002 Editor::fake_handle_new_audio_region (AudioRegion *region)
1004 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::handle_new_audio_region), region));
1008 Editor::fake_handle_audio_region_removed (AudioRegion *region)
1010 Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &Editor::handle_audio_region_removed), region));
1014 Editor::fake_handle_new_duration ()
1016 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &Editor::handle_new_duration));
1020 Editor::start_scrolling ()
1022 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1023 (mem_fun(*this, &Editor::update_current_screen));
1025 slower_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
1026 (mem_fun(*this, &Editor::update_slower));
1030 Editor::stop_scrolling ()
1032 scroll_connection.disconnect ();
1033 slower_update_connection.disconnect ();
1037 Editor::map_position_change (jack_nframes_t frame)
1039 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1041 if (session == 0 || !_follow_playhead) {
1045 center_screen (frame);
1046 playhead_cursor->set_position (frame);
1050 Editor::center_screen (jack_nframes_t frame)
1052 double page = canvas_width * frames_per_unit;
1054 /* if we're off the page, then scroll.
1057 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1058 center_screen_internal (frame, page);
1063 Editor::center_screen_internal (jack_nframes_t frame, float page)
1068 frame -= (jack_nframes_t) page;
1073 reposition_x_origin (frame);
1077 Editor::handle_new_duration ()
1079 reset_scrolling_region ();
1082 horizontal_adjustment.set_upper (session->current_end_frame() / frames_per_unit);
1083 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1088 Editor::update_title_s (const string & snap_name)
1090 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1096 Editor::update_title ()
1098 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1101 bool dirty = session->dirty();
1103 string wintitle = _("ardour: editor: ");
1109 wintitle += session->name();
1111 if (session->snap_name() != session->name()) {
1113 wintitle += session->snap_name();
1120 set_title (wintitle);
1125 Editor::connect_to_session (Session *t)
1129 if (first_action_message) {
1130 first_action_message->hide();
1135 session->going_away.connect (mem_fun(*this, &Editor::session_going_away));
1137 /* These signals can all be emitted by a non-GUI thread. Therefore the
1138 handlers for them must not attempt to directly interact with the GUI,
1139 but use Gtkmm2ext::UI::instance()->call_slot();
1142 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1143 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1144 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route_p)));
1145 session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::fake_handle_new_audio_region)));
1146 session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::fake_handle_audio_region_removed)));
1147 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::fake_handle_new_duration)));
1148 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1149 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1150 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1151 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1152 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1153 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1154 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1155 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1157 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1158 session_connections.push_back (session->SMPTETypeChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1160 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1162 edit_groups_changed ();
1164 edit_cursor_clock.set_session (session);
1165 selection_start_clock.set_session (session);
1166 selection_end_clock.set_session (session);
1167 zoom_range_clock.set_session (session);
1168 _playlist_selector->set_session (session);
1169 nudge_clock.set_session (session);
1171 switch (session->get_edit_mode()) {
1173 edit_mode_selector.set_active_text (edit_mode_strings[splice_index]);
1177 edit_mode_selector.set_active_text (edit_mode_strings[slide_index]);
1181 Location* loc = session->locations()->auto_loop_location();
1183 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1184 if (loc->start() == loc->end()) {
1185 loc->set_end (loc->start() + 1);
1187 session->locations()->add (loc, false);
1188 session->set_auto_loop_location (loc);
1192 loc->set_name (_("Loop"));
1195 loc = session->locations()->auto_punch_location();
1197 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1198 if (loc->start() == loc->end()) {
1199 loc->set_end (loc->start() + 1);
1201 session->locations()->add (loc, false);
1202 session->set_auto_punch_location (loc);
1206 loc->set_name (_("Punch"));
1209 update_loop_range_view (true);
1210 update_punch_range_view (true);
1212 session->ControlChanged.connect (mem_fun(*this, &Editor::queue_session_control_changed));
1213 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1215 refresh_location_display ();
1216 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1217 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1218 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1219 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1220 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1222 reset_scrolling_region ();
1224 redisplay_regions ();
1225 redisplay_named_selections ();
1226 redisplay_snapshots ();
1228 initial_route_list_display ();
1230 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1231 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1234 /* ::reposition_x_origin() doesn't work right here, since the old
1235 position may be zero already, and it does nothing in such
1241 horizontal_adjustment.set_upper (session->current_end_frame() / frames_per_unit);
1242 horizontal_adjustment.set_value (0);
1244 restore_ruler_visibility ();
1245 tempo_map_changed (Change (0));
1247 edit_cursor->set_position (0);
1248 playhead_cursor->set_position (0);
1252 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1255 /* don't show master bus in a new session */
1257 if (ARDOUR_UI::instance()->session_is_new ()) {
1259 TreeModel::Children rows = route_display_model->children();
1260 TreeModel::Children::iterator i;
1262 no_route_list_redisplay = true;
1264 for (i = rows.begin(); i != rows.end(); ++i) {
1265 TimeAxisView *tv = (*i)[route_display_columns.tv];
1266 AudioTimeAxisView *atv;
1268 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1269 if (atv->route().master()) {
1270 route_list_display.get_selection()->unselect (i);
1275 no_route_list_redisplay = false;
1276 redisplay_route_list ();
1281 Editor::build_cursors ()
1283 using namespace Gdk;
1285 Gdk::Color mbg ("#000000" ); /* Black */
1286 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1289 RefPtr<Bitmap> source, mask;
1290 source = Bitmap::create (mag_bits, mag_width, mag_height);
1291 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1292 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1295 Gdk::Color fbg ("#ffffff" );
1296 Gdk::Color ffg ("#000000" );
1299 RefPtr<Bitmap> source, mask;
1301 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1302 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1303 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1307 RefPtr<Bitmap> source, mask;
1308 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1309 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1310 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1313 grabber_cursor = new Gdk::Cursor (HAND2);
1314 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1315 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1316 selector_cursor = new Gdk::Cursor (XTERM);
1317 time_fx_cursor = new Gdk::Cursor (SIZING);
1318 wait_cursor = new Gdk::Cursor (WATCH);
1319 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1323 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1325 using namespace Menu_Helpers;
1326 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1329 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1333 MenuList& items (fade_context_menu.items());
1337 switch (item_type) {
1339 case FadeInHandleItem:
1340 if (arv->region.fade_in_active()) {
1341 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), false)));
1343 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), true)));
1346 items.push_back (SeparatorElem());
1348 items.push_back (MenuElem (_("Linear"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::Linear)));
1349 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::LogB)));
1350 items.push_back (MenuElem (_("Slow"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::Fast)));
1351 items.push_back (MenuElem (_("Fast"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::LogA)));
1352 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_in_shape), AudioRegion::Slow)));
1356 case FadeOutHandleItem:
1357 if (arv->region.fade_out_active()) {
1358 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), false)));
1360 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), true)));
1363 items.push_back (SeparatorElem());
1365 items.push_back (MenuElem (_("Linear"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::Linear)));
1366 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::Fast)));
1367 items.push_back (MenuElem (_("Slow"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::LogB)));
1368 items.push_back (MenuElem (_("Fast"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::LogA)));
1369 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (arv->region, &AudioRegion::set_fade_out_shape), AudioRegion::Slow)));
1373 fatal << _("programming error: ")
1374 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1379 fade_context_menu.popup (button, time);
1383 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, jack_nframes_t frame)
1385 using namespace Menu_Helpers;
1386 Menu* (Editor::*build_menu_function)(jack_nframes_t);
1389 switch (item_type) {
1391 case AudioRegionViewName:
1392 case AudioRegionViewNameHighlight:
1393 if (with_selection) {
1394 build_menu_function = &Editor::build_track_selection_context_menu;
1396 build_menu_function = &Editor::build_track_region_context_menu;
1401 if (with_selection) {
1402 build_menu_function = &Editor::build_track_selection_context_menu;
1404 build_menu_function = &Editor::build_track_context_menu;
1408 case CrossfadeViewItem:
1409 build_menu_function = &Editor::build_track_crossfade_context_menu;
1413 if (clicked_audio_trackview->get_diskstream()) {
1414 build_menu_function = &Editor::build_track_context_menu;
1416 build_menu_function = &Editor::build_track_bus_context_menu;
1421 /* probably shouldn't happen but if it does, we don't care */
1425 menu = (this->*build_menu_function)(frame);
1426 menu->set_name ("ArdourContextMenu");
1428 /* now handle specific situations */
1430 switch (item_type) {
1432 case AudioRegionViewName:
1433 case AudioRegionViewNameHighlight:
1434 if (!with_selection) {
1435 if (region_edit_menu_split_item) {
1436 if (clicked_regionview && clicked_regionview->region.covers (edit_cursor->current_frame)) {
1437 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
1439 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
1442 if (region_edit_menu_split_multichannel_item) {
1443 if (clicked_regionview && clicked_regionview->region.n_channels() > 1) {
1444 // GTK2FIX find the action, change its sensitivity
1445 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1447 // GTK2FIX see above
1448 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1457 case CrossfadeViewItem:
1464 /* probably shouldn't happen but if it does, we don't care */
1468 if (clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
1470 /* Bounce to disk */
1472 using namespace Menu_Helpers;
1473 MenuList& edit_items = menu->items();
1475 edit_items.push_back (SeparatorElem());
1477 switch (clicked_audio_trackview->audio_track()->freeze_state()) {
1478 case AudioTrack::NoFreeze:
1479 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1482 case AudioTrack::Frozen:
1483 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1486 case AudioTrack::UnFrozen:
1487 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1493 menu->popup (button, time);
1497 Editor::build_track_context_menu (jack_nframes_t ignored)
1499 using namespace Menu_Helpers;
1501 MenuList& edit_items = track_context_menu.items();
1504 add_dstream_context_items (edit_items);
1505 return &track_context_menu;
1509 Editor::build_track_bus_context_menu (jack_nframes_t ignored)
1511 using namespace Menu_Helpers;
1513 MenuList& edit_items = track_context_menu.items();
1516 add_bus_context_items (edit_items);
1517 return &track_context_menu;
1521 Editor::build_track_region_context_menu (jack_nframes_t frame)
1523 using namespace Menu_Helpers;
1524 MenuList& edit_items = track_region_context_menu.items();
1527 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1533 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1534 Playlist::RegionList* regions = pl->regions_at ((jack_nframes_t) floor ( (double)frame * ds->speed()));
1535 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1536 add_region_context_items (atv->view, (*i), edit_items);
1542 add_dstream_context_items (edit_items);
1544 return &track_region_context_menu;
1548 Editor::build_track_crossfade_context_menu (jack_nframes_t frame)
1550 using namespace Menu_Helpers;
1551 MenuList& edit_items = track_crossfade_context_menu.items();
1552 edit_items.clear ();
1554 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1561 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = dynamic_cast<AudioPlaylist*> (pl)) != 0)) {
1563 Playlist::RegionList* regions = pl->regions_at (frame);
1564 AudioPlaylist::Crossfades xfades;
1566 apl->crossfades_at (frame, xfades);
1568 bool many = xfades.size() > 1;
1570 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1571 add_crossfade_context_items (atv->view, (*i), edit_items, many);
1574 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1575 add_region_context_items (atv->view, (*i), edit_items);
1582 add_dstream_context_items (edit_items);
1584 return &track_crossfade_context_menu;
1588 Editor::build_track_selection_context_menu (jack_nframes_t ignored)
1590 using namespace Menu_Helpers;
1591 MenuList& edit_items = track_selection_context_menu.items();
1592 edit_items.clear ();
1594 add_selection_context_items (edit_items);
1595 add_dstream_context_items (edit_items);
1597 return &track_selection_context_menu;
1601 Editor::add_crossfade_context_items (StreamView* view, Crossfade* xfade, Menu_Helpers::MenuList& edit_items, bool many)
1603 using namespace Menu_Helpers;
1604 Menu *xfade_menu = manage (new Menu);
1605 MenuList& items = xfade_menu->items();
1606 xfade_menu->set_name ("ArdourContextMenu");
1609 if (xfade->active()) {
1615 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), xfade)));
1616 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), xfade)));
1618 if (xfade->can_follow_overlap()) {
1620 if (xfade->following_overlap()) {
1621 str = _("Convert to short");
1623 str = _("Convert to full");
1626 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1630 str = xfade->out().name();
1632 str += xfade->in().name();
1634 str = _("Crossfade");
1637 edit_items.push_back (MenuElem (str, *xfade_menu));
1638 edit_items.push_back (SeparatorElem());
1642 Editor::xfade_edit_left_region ()
1644 if (clicked_crossfadeview) {
1645 clicked_crossfadeview->left_view.show_region_editor ();
1650 Editor::xfade_edit_right_region ()
1652 if (clicked_crossfadeview) {
1653 clicked_crossfadeview->right_view.show_region_editor ();
1658 Editor::add_region_context_items (StreamView* sv, Region* region, Menu_Helpers::MenuList& edit_items)
1660 using namespace Menu_Helpers;
1661 Menu *region_menu = manage (new Menu);
1662 MenuList& items = region_menu->items();
1663 region_menu->set_name ("ArdourContextMenu");
1665 AudioRegion* ar = 0;
1668 ar = dynamic_cast<AudioRegion*> (region);
1671 /* when this particular menu pops up, make the relevant region
1675 region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, region));
1677 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1678 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1679 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1680 items.push_back (SeparatorElem());
1681 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_cursor)));
1682 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1683 items.push_back (SeparatorElem());
1685 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::audition_selected_region)));
1686 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1687 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1688 items.push_back (SeparatorElem());
1690 /* XXX hopefully this nonsense will go away with SigC++ 2.X, where the compiler
1691 might be able to figure out which overloaded member function to use in
1695 void (Editor::*type_A_pmf)(void (Region::*pmf)(bool), bool) = &Editor::region_selection_op;
1697 items.push_back (MenuElem (_("Lock"), bind (mem_fun(*this, type_A_pmf), &Region::set_locked, true)));
1698 items.push_back (MenuElem (_("Unlock"), bind (mem_fun(*this, type_A_pmf), &Region::set_locked, false)));
1699 items.push_back (SeparatorElem());
1701 if (region->muted()) {
1702 items.push_back (MenuElem (_("Unmute"), bind (mem_fun(*this, type_A_pmf), &Region::set_muted, false)));
1704 items.push_back (MenuElem (_("Mute"), bind (mem_fun(*this, type_A_pmf), &Region::set_muted, true)));
1706 items.push_back (SeparatorElem());
1708 items.push_back (MenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1709 items.push_back (SeparatorElem());
1714 items.push_back (MenuElem (_("Toggle envelope visibility"), mem_fun(*this, &Editor::toggle_gain_envelope_visibility)));
1715 items.push_back (MenuElem (_("Toggle envelope active"), mem_fun(*this, &Editor::toggle_gain_envelope_active)));
1716 items.push_back (SeparatorElem());
1718 if (ar->scale_amplitude() != 1.0f) {
1719 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1721 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1724 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1725 items.push_back (SeparatorElem());
1729 Menu *nudge_menu = manage (new Menu());
1730 MenuList& nudge_items = nudge_menu->items();
1731 nudge_menu->set_name ("ArdourContextMenu");
1733 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1734 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1735 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1736 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1738 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1739 items.push_back (SeparatorElem());
1741 Menu *trim_menu = manage (new Menu);
1742 MenuList& trim_items = trim_menu->items();
1743 trim_menu->set_name ("ArdourContextMenu");
1745 trim_items.push_back (MenuElem (_("Start to edit cursor"), mem_fun(*this, &Editor::trim_region_from_edit_cursor)));
1746 trim_items.push_back (MenuElem (_("Edit cursor to end"), mem_fun(*this, &Editor::trim_region_to_edit_cursor)));
1748 items.push_back (MenuElem (_("Trim"), *trim_menu));
1749 items.push_back (SeparatorElem());
1751 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1752 region_edit_menu_split_item = &items.back();
1754 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1755 region_edit_menu_split_multichannel_item = &items.back();
1757 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1758 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1759 items.push_back (SeparatorElem());
1760 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1761 items.push_back (SeparatorElem());
1762 items.push_back (MenuElem (_("Destroy"), mem_fun(*this, &Editor::destroy_clicked_region)));
1764 /* OK, stick the region submenu at the top of the list, and then add
1768 /* we have to hack up the region name because "_" has a special
1769 meaning for menu titles.
1772 string::size_type pos = 0;
1773 string menu_item_name = region->name();
1775 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1776 menu_item_name.replace (pos, 1, "__");
1780 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1781 edit_items.push_back (SeparatorElem());
1785 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1787 using namespace Menu_Helpers;
1788 Menu *selection_menu = manage (new Menu);
1789 MenuList& items = selection_menu->items();
1790 selection_menu->set_name ("ArdourContextMenu");
1792 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1793 items.push_back (MenuElem (_("Loop range"), mem_fun(*this, &Editor::set_route_loop_selection)));
1794 items.push_back (SeparatorElem());
1795 items.push_back (MenuElem (_("Separate range to track"), mem_fun(*this, &Editor::separate_region_from_selection)));
1796 items.push_back (MenuElem (_("Separate range to region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1797 items.push_back (SeparatorElem());
1798 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1799 items.push_back (SeparatorElem());
1800 items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1801 items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1802 items.push_back (SeparatorElem());
1803 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1804 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1805 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1806 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::name_selection)));
1807 items.push_back (SeparatorElem());
1808 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1809 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1811 edit_items.push_back (MenuElem (_("Range"), *selection_menu));
1812 edit_items.push_back (SeparatorElem());
1816 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1818 using namespace Menu_Helpers;
1822 Menu *play_menu = manage (new Menu);
1823 MenuList& play_items = play_menu->items();
1824 play_menu->set_name ("ArdourContextMenu");
1826 play_items.push_back (MenuElem (_("Play from edit cursor")));
1827 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1828 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1829 play_items.push_back (SeparatorElem());
1830 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1832 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1836 Menu *select_menu = manage (new Menu);
1837 MenuList& select_items = select_menu->items();
1838 select_menu->set_name ("ArdourContextMenu");
1840 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1841 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1842 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1843 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1844 select_items.push_back (SeparatorElem());
1845 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1846 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1847 select_items.push_back (SeparatorElem());
1848 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1849 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1850 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1851 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1852 select_items.push_back (SeparatorElem());
1854 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1858 Menu *cutnpaste_menu = manage (new Menu);
1859 MenuList& cutnpaste_items = cutnpaste_menu->items();
1860 cutnpaste_menu->set_name ("ArdourContextMenu");
1862 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1863 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1864 cutnpaste_items.push_back (MenuElem (_("Paste at edit cursor"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1865 cutnpaste_items.push_back (MenuElem (_("Paste at mouse"), mem_fun(*this, &Editor::mouse_paste)));
1867 cutnpaste_items.push_back (SeparatorElem());
1869 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1870 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
1872 cutnpaste_items.push_back (SeparatorElem());
1874 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
1876 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
1878 /* Adding new material */
1880 Menu *import_menu = manage (new Menu());
1881 MenuList& import_items = import_menu->items();
1882 import_menu->set_name ("ArdourContextMenu");
1884 import_items.push_back (MenuElem (_("Insert Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
1885 import_items.push_back (MenuElem (_("Insert external sndfile"), bind (mem_fun(*this, &Editor::insert_sndfile), false)));
1887 edit_items.push_back (MenuElem (_("Import"), *import_menu));
1891 Menu *nudge_menu = manage (new Menu());
1892 MenuList& nudge_items = nudge_menu->items();
1893 nudge_menu->set_name ("ArdourContextMenu");
1895 edit_items.push_back (SeparatorElem());
1896 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1897 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1898 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1899 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1901 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1905 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
1907 using namespace Menu_Helpers;
1911 Menu *play_menu = manage (new Menu);
1912 MenuList& play_items = play_menu->items();
1913 play_menu->set_name ("ArdourContextMenu");
1915 play_items.push_back (MenuElem (_("Play from edit cursor")));
1916 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1917 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1921 Menu *select_menu = manage (new Menu);
1922 MenuList& select_items = select_menu->items();
1923 select_menu->set_name ("ArdourContextMenu");
1925 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1926 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1927 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1928 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1929 select_items.push_back (SeparatorElem());
1930 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1931 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1932 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1933 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1935 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1939 Menu *cutnpaste_menu = manage (new Menu);
1940 MenuList& cutnpaste_items = cutnpaste_menu->items();
1941 cutnpaste_menu->set_name ("ArdourContextMenu");
1943 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1944 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1945 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1947 Menu *nudge_menu = manage (new Menu());
1948 MenuList& nudge_items = nudge_menu->items();
1949 nudge_menu->set_name ("ArdourContextMenu");
1951 edit_items.push_back (SeparatorElem());
1952 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1953 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1954 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1955 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1957 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1960 /* CURSOR SETTING AND MARKS AND STUFF */
1963 Editor::set_snap_to (SnapType st)
1966 vector<string> txt = internationalize (snap_type_strings);
1967 snap_type_selector.set_active_text (txt[(int)st]);
1971 switch (snap_type) {
1972 case SnapToAThirtysecondBeat:
1973 case SnapToASixteenthBeat:
1974 case SnapToAEighthBeat:
1975 case SnapToAQuarterBeat:
1976 case SnapToAThirdBeat:
1977 update_tempo_based_rulers ();
1985 Editor::set_snap_mode (SnapMode mode)
1988 vector<string> txt = internationalize (snap_mode_strings);
1989 snap_mode_selector.set_active_text (txt[(int)mode]);
1995 Editor::add_location_from_selection ()
1997 if (selection->time.empty()) {
2001 if (session == 0 || clicked_trackview == 0) {
2005 jack_nframes_t start = selection->time[clicked_selection].start;
2006 jack_nframes_t end = selection->time[clicked_selection].end;
2008 Location *location = new Location (start, end, "selection");
2010 session->begin_reversible_command (_("add marker"));
2011 session->add_undo (session->locations()->get_memento());
2012 session->locations()->add (location, true);
2013 session->add_redo_no_execute (session->locations()->get_memento());
2014 session->commit_reversible_command ();
2018 Editor::add_location_from_playhead_cursor ()
2020 jack_nframes_t where = session->audible_frame();
2022 Location *location = new Location (where, where, "mark", Location::IsMark);
2023 session->begin_reversible_command (_("add marker"));
2024 session->add_undo (session->locations()->get_memento());
2025 session->locations()->add (location, true);
2026 session->add_redo_no_execute (session->locations()->get_memento());
2027 session->commit_reversible_command ();
2032 Editor::set_state (const XMLNode& node)
2034 const XMLProperty* prop;
2036 int x, y, xoff, yoff;
2040 if ((geometry = find_named_node (node, "geometry")) == 0) {
2042 g.base_width = default_width;
2043 g.base_height = default_height;
2051 g.base_width = atoi(geometry->property("x_size")->value());
2052 g.base_height = atoi(geometry->property("y_size")->value());
2053 x = atoi(geometry->property("x_pos")->value());
2054 y = atoi(geometry->property("y_pos")->value());
2055 xoff = atoi(geometry->property("x_off")->value());
2056 yoff = atoi(geometry->property("y_off")->value());
2059 set_geometry_hints (vpacker, g, Gdk::HINT_BASE_SIZE);
2060 set_default_size (g.base_width, g.base_height);
2063 if ((prop = node.property ("zoom-focus"))) {
2064 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2067 if ((prop = node.property ("zoom"))) {
2068 set_frames_per_unit (atof (prop->value()));
2071 if ((prop = node.property ("snap-to"))) {
2072 set_snap_to ((SnapType) atoi (prop->value()));
2075 if ((prop = node.property ("snap-mode"))) {
2076 set_snap_mode ((SnapMode) atoi (prop->value()));
2079 if ((prop = node.property ("mouse-mode"))) {
2080 MouseMode m = str2mousemode(prop->value());
2081 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2082 set_mouse_mode (m, true);
2084 mouse_mode = MouseGain; /* lie, to force the mode switch */
2085 set_mouse_mode (MouseObject, true);
2088 if ((prop = node.property ("show-waveforms"))) {
2089 bool yn = (prop->value() == "yes");
2090 _show_waveforms = !yn;
2091 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
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-waveforms-recording"))) {
2101 bool yn = (prop->value() == "yes");
2102 _show_waveforms_recording = !yn;
2103 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
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 ("show-measures"))) {
2113 bool yn = (prop->value() == "yes");
2114 _show_measures = !yn;
2115 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2117 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2118 /* do it twice to force the change */
2119 tact->set_active (!yn);
2120 tact->set_active (yn);
2124 if ((prop = node.property ("follow-playhead"))) {
2125 bool yn = (prop->value() == "yes");
2126 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleFollowPlayhead"));
2128 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2129 /* do it twice to force the change */
2130 tact->set_active (!yn);
2131 tact->set_active (yn);
2136 if ((prop = node.property ("region-list-sort-type"))) {
2137 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2138 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2141 if ((prop = node.property ("xfades-visible"))) {
2142 bool yn = (prop->value() == "yes");
2143 _xfade_visibility = !yn;
2144 set_xfade_visibility (yn);
2147 if ((prop = node.property ("show-editor-mixer"))) {
2149 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2151 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2152 bool yn = (prop->value() == X_("yes"));
2154 /* do it twice to force the change */
2156 tact->set_active (!yn);
2157 tact->set_active (yn);
2165 Editor::get_state ()
2167 XMLNode* node = new XMLNode ("Editor");
2170 if (is_realized()) {
2171 Glib::RefPtr<Gdk::Window> win = get_window();
2173 int x, y, xoff, yoff, width, height;
2174 win->get_root_origin(x, y);
2175 win->get_position(xoff, yoff);
2176 win->get_size(width, height);
2178 XMLNode* geometry = new XMLNode ("geometry");
2180 snprintf(buf, sizeof(buf), "%d", width);
2181 geometry->add_property("x_size", string(buf));
2182 snprintf(buf, sizeof(buf), "%d", height);
2183 geometry->add_property("y_size", string(buf));
2184 snprintf(buf, sizeof(buf), "%d", x);
2185 geometry->add_property("x_pos", string(buf));
2186 snprintf(buf, sizeof(buf), "%d", y);
2187 geometry->add_property("y_pos", string(buf));
2188 snprintf(buf, sizeof(buf), "%d", xoff);
2189 geometry->add_property("x_off", string(buf));
2190 snprintf(buf, sizeof(buf), "%d", yoff);
2191 geometry->add_property("y_off", string(buf));
2192 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2193 geometry->add_property("edit_pane_pos", string(buf));
2195 node->add_child_nocopy (*geometry);
2198 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2199 node->add_property ("zoom-focus", buf);
2200 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2201 node->add_property ("zoom", buf);
2202 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2203 node->add_property ("snap-to", buf);
2204 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2205 node->add_property ("snap-mode", buf);
2207 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2208 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2209 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2210 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2211 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2212 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2213 node->add_property ("mouse-mode", enum2str(mouse_mode));
2215 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2217 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2218 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2227 Editor::trackview_by_y_position (double y)
2229 TrackViewList::iterator iter;
2232 for (iter = track_views.begin(); iter != track_views.end(); ++iter) {
2240 if (tv->y_position <= y && y < ((tv->y_position + tv->height + track_spacing))) {
2249 Editor::snap_to (jack_nframes_t& start, int32_t direction, bool for_mark)
2251 Location* before = 0;
2252 Location* after = 0;
2258 const jack_nframes_t one_second = session->frame_rate();
2259 const jack_nframes_t one_minute = session->frame_rate() * 60;
2261 jack_nframes_t presnap = start;
2263 switch (snap_type) {
2269 start = (jack_nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2271 start = (jack_nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2274 case SnapToSMPTEFrame:
2276 start = (jack_nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2278 start = (jack_nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2282 case SnapToSMPTESeconds:
2283 if (session->smpte_offset_negative())
2285 start += session->smpte_offset ();
2287 start -= session->smpte_offset ();
2289 if (direction > 0) {
2290 start = (jack_nframes_t) ceil ((double) start / one_second) * one_second;
2292 start = (jack_nframes_t) floor ((double) start / one_second) * one_second;
2295 if (session->smpte_offset_negative())
2297 start -= session->smpte_offset ();
2299 start += session->smpte_offset ();
2303 case SnapToSMPTEMinutes:
2304 if (session->smpte_offset_negative())
2306 start += session->smpte_offset ();
2308 start -= session->smpte_offset ();
2311 start = (jack_nframes_t) ceil ((double) start / one_minute) * one_minute;
2313 start = (jack_nframes_t) floor ((double) start / one_minute) * one_minute;
2315 if (session->smpte_offset_negative())
2317 start -= session->smpte_offset ();
2319 start += session->smpte_offset ();
2325 start = (jack_nframes_t) ceil ((double) start / one_second) * one_second;
2327 start = (jack_nframes_t) floor ((double) start / one_second) * one_second;
2333 start = (jack_nframes_t) ceil ((double) start / one_minute) * one_minute;
2335 start = (jack_nframes_t) floor ((double) start / one_minute) * one_minute;
2340 start = session->tempo_map().round_to_bar (start, direction);
2344 start = session->tempo_map().round_to_beat (start, direction);
2347 case SnapToAThirtysecondBeat:
2348 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2351 case SnapToASixteenthBeat:
2352 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2355 case SnapToAEighthBeat:
2356 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2359 case SnapToAQuarterBeat:
2360 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2363 case SnapToAThirdBeat:
2364 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2367 case SnapToEditCursor:
2368 start = edit_cursor->current_frame;
2376 before = session->locations()->first_location_before (start);
2377 after = session->locations()->first_location_after (start);
2379 if (direction < 0) {
2381 start = before->start();
2385 } else if (direction > 0) {
2387 start = after->start();
2389 start = session->current_end_frame();
2394 /* find nearest of the two */
2395 if ((start - before->start()) < (after->start() - start)) {
2396 start = before->start();
2398 start = after->start();
2401 start = before->start();
2404 start = after->start();
2411 case SnapToRegionStart:
2412 case SnapToRegionEnd:
2413 case SnapToRegionSync:
2414 case SnapToRegionBoundary:
2415 if (!region_boundary_cache.empty()) {
2416 vector<jack_nframes_t>::iterator i;
2418 if (direction > 0) {
2419 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2421 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2424 if (i != region_boundary_cache.end()) {
2427 start = region_boundary_cache.back();
2433 switch (snap_mode) {
2439 if (presnap > start) {
2440 if (presnap > (start + unit_to_frame(snap_threshold))) {
2444 } else if (presnap < start) {
2445 if (presnap < (start - unit_to_frame(snap_threshold))) {
2457 Editor::setup_toolbar ()
2460 vector<ToggleButton *> mouse_mode_buttons;
2462 mouse_mode_buttons.push_back (&mouse_move_button);
2463 mouse_mode_buttons.push_back (&mouse_select_button);
2464 mouse_mode_buttons.push_back (&mouse_gain_button);
2465 mouse_mode_buttons.push_back (&mouse_zoom_button);
2466 mouse_mode_buttons.push_back (&mouse_timefx_button);
2467 mouse_mode_buttons.push_back (&mouse_audition_button);
2468 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2470 mouse_mode_button_table.set_homogeneous (true);
2471 mouse_mode_button_table.set_col_spacings (2);
2472 mouse_mode_button_table.set_row_spacings (2);
2473 mouse_mode_button_table.set_border_width (5);
2475 mouse_mode_button_table.attach (mouse_move_button, 0, 1, 0, 1);
2476 mouse_mode_button_table.attach (mouse_select_button, 1, 2, 0, 1);
2477 mouse_mode_button_table.attach (mouse_zoom_button, 2, 3, 0, 1);
2479 mouse_mode_button_table.attach (mouse_gain_button, 0, 1, 1, 2);
2480 mouse_mode_button_table.attach (mouse_timefx_button, 1, 2, 1, 2);
2481 mouse_mode_button_table.attach (mouse_audition_button, 2, 3, 1, 2);
2483 mouse_mode_tearoff = manage (new TearOff (mouse_mode_button_table));
2484 mouse_mode_tearoff->set_name ("MouseModeBase");
2486 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2487 &mouse_mode_tearoff->tearoff_window()));
2488 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2489 &mouse_mode_tearoff->tearoff_window(), 1));
2490 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2491 &mouse_mode_tearoff->tearoff_window()));
2492 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2493 &mouse_mode_tearoff->tearoff_window(), 1));
2495 mouse_move_button.set_name ("MouseModeButton");
2496 mouse_select_button.set_name ("MouseModeButton");
2497 mouse_gain_button.set_name ("MouseModeButton");
2498 mouse_zoom_button.set_name ("MouseModeButton");
2499 mouse_timefx_button.set_name ("MouseModeButton");
2500 mouse_audition_button.set_name ("MouseModeButton");
2502 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("select/move objects"));
2503 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("select/move ranges"));
2504 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("draw gain automation"));
2505 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("select zoom range"));
2506 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("stretch/shrink regions"));
2507 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("listen to specific regions"));
2509 mouse_move_button.unset_flags (CAN_FOCUS);
2510 mouse_select_button.unset_flags (CAN_FOCUS);
2511 mouse_gain_button.unset_flags (CAN_FOCUS);
2512 mouse_zoom_button.unset_flags (CAN_FOCUS);
2513 mouse_timefx_button.unset_flags (CAN_FOCUS);
2514 mouse_audition_button.unset_flags (CAN_FOCUS);
2516 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2517 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2519 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2520 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2521 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2522 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2523 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2525 // mouse_move_button.set_active (true);
2527 /* automation control */
2529 global_automation_button.set_name ("MouseModeButton");
2530 automation_mode_button.set_name ("MouseModeButton");
2532 automation_box.set_spacing (2);
2533 automation_box.set_border_width (2);
2534 automation_box.pack_start (global_automation_button, false, false);
2535 automation_box.pack_start (automation_mode_button, false, false);
2539 edit_mode_label.set_name ("ToolBarLabel");
2541 edit_mode_selector.set_name ("EditModeSelector");
2543 edit_mode_box.set_spacing (3);
2544 edit_mode_box.set_border_width (3);
2546 /* XXX another disgusting hack because of the way combo boxes size themselves */
2548 const guint32 FUDGE = 20; // Combo's are stupid - they steal space from the entry for the button
2549 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, "EdgtMode", 2+FUDGE, 10);
2550 set_popdown_strings (edit_mode_selector, internationalize (edit_mode_strings));
2551 edit_mode_box.pack_start (edit_mode_label, false, false);
2552 edit_mode_box.pack_start (edit_mode_selector, false, false);
2554 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2558 snap_type_label.set_name ("ToolBarLabel");
2560 snap_type_selector.set_name ("SnapTypeSelector");
2562 snap_type_box.set_spacing (3);
2563 snap_type_box.set_border_width (3);
2565 /* XXX another disgusting hack because of the way combo boxes size themselves */
2567 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, "SMPTE Seconds", 2+FUDGE, 10);
2568 set_popdown_strings (snap_type_selector, internationalize (snap_type_strings));
2570 snap_type_box.pack_start (snap_type_label, false, false);
2571 snap_type_box.pack_start (snap_type_selector, false, false);
2573 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2575 /* Snap mode, not snap type */
2577 snap_mode_label.set_name ("ToolBarLabel");
2579 snap_mode_selector.set_name ("SnapModeSelector");
2581 snap_mode_box.set_spacing (3);
2582 snap_mode_box.set_border_width (3);
2584 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, "SngpMode", 2+FUDGE, 10);
2585 set_popdown_strings (snap_mode_selector, internationalize (snap_mode_strings));
2587 snap_mode_box.pack_start (snap_mode_label, false, false);
2588 snap_mode_box.pack_start (snap_mode_selector, false, false);
2590 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2592 /* Zoom focus mode */
2594 zoom_focus_label.set_name ("ToolBarLabel");
2596 zoom_focus_selector.set_name ("ZoomFocusSelector");
2598 zoom_focus_box.set_spacing (3);
2599 zoom_focus_box.set_border_width (3);
2601 /* XXX another disgusting hack because of the way combo boxes size themselves */
2603 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Edgt Cursor", 2+FUDGE, 10);
2604 set_popdown_strings (zoom_focus_selector, internationalize (zoom_focus_strings));
2606 zoom_focus_box.pack_start (zoom_focus_label, false, false);
2607 zoom_focus_box.pack_start (zoom_focus_selector, false, false);
2609 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2611 /* selection/cursor clocks */
2613 toolbar_selection_cursor_label.set_name ("ToolBarLabel");
2614 selection_start_clock_label.set_name ("ToolBarLabel");
2615 selection_end_clock_label.set_name ("ToolBarLabel");
2616 edit_cursor_clock_label.set_name ("ToolBarLabel");
2618 selection_start_clock_label.set_text (_("Start:"));
2619 selection_end_clock_label.set_text (_("End:"));
2620 edit_cursor_clock_label.set_text (_("Edit"));
2622 /* the zoom in/out buttons are generally taller than the clocks, so
2623 put all the toolbar clocks into a size group with one of the
2624 buttons to make them all equal height.
2626 this also applies to the various toolbar combos
2629 RefPtr<SizeGroup> toolbar_clock_size_group = SizeGroup::create (SIZE_GROUP_VERTICAL);
2630 toolbar_clock_size_group->add_widget (zoom_out_button);
2631 toolbar_clock_size_group->add_widget (edit_cursor_clock);
2632 toolbar_clock_size_group->add_widget (zoom_range_clock);
2633 toolbar_clock_size_group->add_widget (nudge_clock);
2634 toolbar_clock_size_group->add_widget (edit_mode_selector);
2635 toolbar_clock_size_group->add_widget (snap_type_selector);
2636 toolbar_clock_size_group->add_widget (snap_mode_selector);
2637 toolbar_clock_size_group->add_widget (zoom_focus_selector);
2639 HBox* edit_clock_hbox = manage (new HBox());
2640 VBox* edit_clock_vbox = manage (new VBox());
2642 edit_clock_hbox->pack_start (edit_cursor_clock, false, false);
2644 edit_clock_vbox->set_spacing (3);
2645 edit_clock_vbox->set_border_width (3);
2646 edit_clock_vbox->pack_start (edit_cursor_clock_label, false, false);
2647 edit_clock_vbox->pack_start (*edit_clock_hbox, false, false);
2649 HBox* hbox = new HBox;
2651 hbox->pack_start (*edit_clock_vbox, false, false);
2652 hbox->pack_start (zoom_indicator_vbox, false, false);
2653 hbox->pack_start (zoom_focus_box, false, false);
2654 hbox->pack_start (snap_type_box, false, false);
2655 hbox->pack_start (snap_mode_box, false, false);
2656 hbox->pack_start (edit_mode_box, false, false);
2658 VBox *vbox = manage (new VBox);
2660 vbox->set_spacing (3);
2661 vbox->set_border_width (3);
2663 HBox *nbox = manage (new HBox);
2665 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2666 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2668 nbox->pack_start (nudge_backward_button, false, false);
2669 nbox->pack_start (nudge_forward_button, false, false);
2670 nbox->pack_start (nudge_clock, false, false, 5);
2672 nudge_label.set_name ("ToolBarLabel");
2674 vbox->pack_start (nudge_label, false, false);
2675 vbox->pack_start (*nbox, false, false);
2677 hbox->pack_start (*vbox, false, false);
2681 tools_tearoff = new TearOff (*hbox);
2682 tools_tearoff->set_name ("MouseModeBase");
2684 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2685 &tools_tearoff->tearoff_window()));
2686 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2687 &tools_tearoff->tearoff_window(), 0));
2688 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2689 &tools_tearoff->tearoff_window()));
2690 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2691 &tools_tearoff->tearoff_window(), 0));
2693 toolbar_hbox.set_spacing (8);
2694 toolbar_hbox.set_border_width (2);
2696 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2697 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2699 toolbar_base.set_name ("ToolBarBase");
2700 toolbar_base.add (toolbar_hbox);
2702 toolbar_frame.set_shadow_type (SHADOW_OUT);
2703 toolbar_frame.set_name ("BaseFrame");
2704 toolbar_frame.add (toolbar_base);
2708 Editor::_autoscroll_canvas (void *arg)
2710 return ((Editor *) arg)->autoscroll_canvas ();
2714 Editor::autoscroll_canvas ()
2716 jack_nframes_t new_frame;
2717 bool keep_calling = true;
2719 if (autoscroll_direction < 0) {
2720 if (leftmost_frame < autoscroll_distance) {
2723 new_frame = leftmost_frame - autoscroll_distance;
2726 if (leftmost_frame > max_frames - autoscroll_distance) {
2727 new_frame = max_frames;
2729 new_frame = leftmost_frame + autoscroll_distance;
2733 if (new_frame != leftmost_frame) {
2734 reposition_x_origin (new_frame);
2737 if (new_frame == 0 || new_frame == max_frames) {
2744 if (autoscroll_cnt == 1) {
2746 /* connect the timeout so that we get called repeatedly */
2748 autoscroll_timeout_tag = gtk_timeout_add (100, _autoscroll_canvas, this);
2749 keep_calling = false;
2751 } else if (autoscroll_cnt > 10 && autoscroll_cnt < 20) {
2753 /* after about a while, speed up a bit by changing the timeout interval */
2755 autoscroll_timeout_tag = gtk_timeout_add (50, _autoscroll_canvas, this);
2756 keep_calling = false;
2758 } else if (autoscroll_cnt >= 20 && autoscroll_cnt < 30) {
2760 /* after about another while, speed up some more */
2762 autoscroll_timeout_tag = gtk_timeout_add (25, _autoscroll_canvas, this);
2763 keep_calling = false;
2765 } else if (autoscroll_cnt >= 30) {
2767 /* we've been scrolling for a while ... crank it up */
2769 autoscroll_distance = 10 * (jack_nframes_t) floor (canvas_width * frames_per_unit);
2772 return keep_calling;
2776 Editor::start_canvas_autoscroll (int dir)
2782 stop_canvas_autoscroll ();
2784 autoscroll_direction = dir;
2785 autoscroll_distance = (jack_nframes_t) floor ((canvas_width * frames_per_unit)/10.0);
2788 /* do it right now, which will start the repeated callbacks */
2790 autoscroll_canvas ();
2794 Editor::stop_canvas_autoscroll ()
2796 if (autoscroll_timeout_tag >= 0) {
2797 gtk_timeout_remove (autoscroll_timeout_tag);
2798 autoscroll_timeout_tag = -1;
2803 Editor::convert_drop_to_paths (vector<string>& paths,
2804 const RefPtr<Gdk::DragContext>& context,
2807 const SelectionData& data,
2816 vector<ustring> uris = data.get_uris();
2820 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
2821 are actually URI lists. So do it by hand.
2824 if (data.get_target() != "text/plain") {
2828 /* Parse the "uri-list" format that Nautilus provides,
2829 where each pathname is delimited by \r\n
2832 const char* p = data.get_text().c_str();
2839 while (g_ascii_isspace (*p))
2843 while (*q && (*q != '\n') && (*q != '\r'))
2849 while (q > p && g_ascii_isspace (*q))
2854 uris.push_back (ustring (p, q - p + 1));
2858 p = strchr (p, '\n');
2868 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
2869 if ((*i).substr (0,7) == "file://") {
2872 paths.push_back (p.substr (7));
2880 Editor::new_tempo_section ()
2886 Editor::map_transport_state ()
2888 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
2890 if (session->transport_stopped()) {
2891 have_pending_keyboard_selection = false;
2897 Editor::State::State ()
2899 selection = new Selection;
2902 Editor::State::~State ()
2908 Editor::get_memento () const
2910 State *state = new State;
2912 store_state (*state);
2913 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
2917 Editor::store_state (State& state) const
2919 *state.selection = *selection;
2923 Editor::restore_state (State *state)
2925 if (*selection == *state->selection) {
2929 *selection = *state->selection;
2930 time_selection_changed ();
2931 cerr << "RS: RSC\n";
2932 region_selection_changed ();
2934 /* XXX other selection change handlers? */
2938 Editor::begin_reversible_command (string name)
2941 UndoAction ua = get_memento();
2942 session->begin_reversible_command (name, &ua);
2947 Editor::commit_reversible_command ()
2950 UndoAction ua = get_memento();
2951 session->commit_reversible_command (&ua);
2956 Editor::set_selected_track_from_click (Selection::Operation op, bool with_undo, bool no_remove)
2958 if (!clicked_trackview) {
2963 begin_reversible_command (_("set selected trackview"));
2967 case Selection::Toggle:
2968 if (selection->selected (clicked_trackview)) {
2970 selection->remove (clicked_trackview);
2973 selection->toggle (clicked_trackview);
2976 case Selection::Set:
2977 if (selection->selected (clicked_trackview) && selection->tracks.size() == 1) {
2978 /* no commit necessary */
2982 selection->set (clicked_trackview);
2985 case Selection::Extend:
2986 /* not defined yet */
2991 commit_reversible_command ();
2996 Editor::set_selected_control_point_from_click (Selection::Operation op, bool with_undo, bool no_remove)
2998 if (!clicked_control_point) {
3003 begin_reversible_command (_("set selected control point"));
3007 case Selection::Set:
3009 case Selection::Toggle:
3011 case Selection::Extend:
3015 commit_reversible_command ();
3020 Editor::mapover_audio_tracks (slot<void,AudioTimeAxisView&,uint32_t> sl)
3022 set<AudioTimeAxisView*> relevant_tracks;
3024 /* step one: get all selected tracks and all tracks in the relevant edit groups */
3026 for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) {
3028 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*ti);
3034 RouteGroup* group = atv->route().edit_group();
3036 if (group && group->is_active()) {
3038 /* active group for this track, loop over all tracks and get every member of the group */
3040 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3042 AudioTimeAxisView* tatv;
3044 if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
3046 if (tatv->route().edit_group() == group) {
3047 relevant_tracks.insert (tatv);
3054 /* no active group, or no group */
3056 relevant_tracks.insert (atv);
3061 /* step two: apply operation to each track */
3063 uint32_t sz = relevant_tracks.size();
3065 for (set<AudioTimeAxisView*>::iterator ati = relevant_tracks.begin(); ati != relevant_tracks.end(); ++ati) {
3071 Editor::mapped_set_selected_regionview_from_click (AudioTimeAxisView& atv, uint32_t ignored,
3072 AudioRegionView* basis, vector<AudioRegionView*>* all_equivs)
3075 vector<AudioRegion*> results;
3076 AudioRegionView* marv;
3079 if ((ds = atv.get_diskstream()) == 0) {
3084 if ((pl = ds->playlist()) != 0) {
3085 pl->get_equivalent_regions (basis->region, results);
3088 for (vector<AudioRegion*>::iterator ir = results.begin(); ir != results.end(); ++ir) {
3089 if ((marv = atv.view->find_view (**ir)) != 0) {
3090 all_equivs->push_back (marv);
3096 Editor::set_selected_regionview_from_click (Selection::Operation op, bool no_track_remove)
3098 cerr << "In SSRfC\n";
3100 vector<AudioRegionView*> all_equivalent_regions;
3102 if (!clicked_regionview) {
3106 mapover_audio_tracks (bind (mem_fun (*this, &Editor::mapped_set_selected_regionview_from_click),
3107 clicked_regionview, &all_equivalent_regions));
3110 cerr << "mapover done\n";
3112 begin_reversible_command (_("set selected regionview"));
3115 case Selection::Toggle:
3116 selection->toggle (clicked_regionview);
3118 if (clicked_regionview->get_selected()) {
3119 if (/* group && group->is_active() && */ selection->audio_regions.size() > 1) {
3120 /* reduce selection down to just the one clicked */
3121 selection->set (clicked_regionview);
3123 selection->remove (clicked_regionview);
3126 selection->add (all_equivalent_regions);
3129 set_selected_track_from_click (op, false, no_track_remove);
3132 case Selection::Set:
3133 // karsten wiese suggested these two lines to make
3134 // a selected region rise to the top. but this
3135 // leads to a mismatch between actual layering
3136 // and visual layering. resolution required ....
3138 // gnome_canvas_item_raise_to_top (clicked_regionview->get_canvas_group());
3139 // gnome_canvas_item_raise_to_top (clicked_regionview->get_time_axis_view().canvas_display);
3141 if (clicked_regionview->get_selected()) {
3142 /* no commit necessary: we are the one selected. */
3147 selection->set (all_equivalent_regions);
3148 set_selected_track_from_click (op, false, false);
3152 case Selection::Extend:
3153 /* not defined yet */
3156 cerr << "case done\n";
3158 commit_reversible_command () ;
3162 Editor::set_selected_regionview_from_region_list (Region& r, Selection::Operation op)
3164 vector<AudioRegionView*> all_equivalent_regions;
3165 AudioRegion* region;
3167 if ((region = dynamic_cast<AudioRegion*>(&r)) == 0) {
3171 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3173 AudioTimeAxisView* tatv;
3175 if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
3178 vector<AudioRegion*> results;
3179 AudioRegionView* marv;
3182 if ((ds = tatv->get_diskstream()) == 0) {
3187 if ((pl = ds->playlist()) != 0) {
3188 pl->get_region_list_equivalent_regions (*region, results);
3191 for (vector<AudioRegion*>::iterator ir = results.begin(); ir != results.end(); ++ir) {
3192 if ((marv = tatv->view->find_view (**ir)) != 0) {
3193 all_equivalent_regions.push_back (marv);
3200 begin_reversible_command (_("set selected regions"));
3203 case Selection::Toggle:
3204 /* XXX this is not correct */
3205 selection->add (all_equivalent_regions);
3207 case Selection::Set:
3208 selection->set (all_equivalent_regions);
3210 case Selection::Extend:
3211 /* not defined yet */
3215 commit_reversible_command () ;
3219 Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, Region* r)
3221 AudioRegionView* rv;
3224 if ((ar = dynamic_cast<AudioRegion*> (r)) == 0) {
3228 if ((rv = sv->find_view (*ar)) == 0) {
3232 /* don't reset the selection if its something other than
3233 a single other region.
3236 if (selection->audio_regions.size() > 1) {
3240 begin_reversible_command (_("set selected regions"));
3242 selection->set (rv);
3244 commit_reversible_command () ;
3250 Editor::set_edit_group_solo (Route& route, bool yn)
3252 RouteGroup *edit_group;
3254 if ((edit_group = route.edit_group()) != 0) {
3255 edit_group->apply (&Route::set_solo, yn, this);
3257 route.set_solo (yn, this);
3262 Editor::set_edit_group_mute (Route& route, bool yn)
3264 RouteGroup *edit_group = 0;
3266 if ((edit_group == route.edit_group()) != 0) {
3267 edit_group->apply (&Route::set_mute, yn, this);
3269 route.set_mute (yn, this);
3274 Editor::set_edit_menu (Menu& menu)
3277 edit_menu->signal_map_event().connect (mem_fun(*this, &Editor::edit_menu_map_handler));
3281 Editor::edit_menu_map_handler (GdkEventAny* ev)
3283 using namespace Menu_Helpers;
3284 MenuList& edit_items = edit_menu->items();
3287 /* Nuke all the old items */
3289 edit_items.clear ();
3295 if (session->undo_depth() == 0) {
3298 label = string_compose(_("Undo (%1)"), session->next_undo());
3301 edit_items.push_back (MenuElem (label, bind (mem_fun(*this, &Editor::undo), 1U)));
3303 if (session->undo_depth() == 0) {
3304 edit_items.back().set_sensitive (false);
3307 if (session->redo_depth() == 0) {
3310 label = string_compose(_("Redo (%1)"), session->next_redo());
3313 edit_items.push_back (MenuElem (label, bind (mem_fun(*this, &Editor::redo), 1U)));
3314 if (session->redo_depth() == 0) {
3315 edit_items.back().set_sensitive (false);
3318 vector<MenuItem*> mitems;
3320 edit_items.push_back (SeparatorElem());
3321 edit_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
3322 mitems.push_back (&edit_items.back());
3323 edit_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
3324 mitems.push_back (&edit_items.back());
3325 edit_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
3326 mitems.push_back (&edit_items.back());
3327 edit_items.push_back (SeparatorElem());
3328 edit_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
3329 mitems.push_back (&edit_items.back());
3330 edit_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
3331 mitems.push_back (&edit_items.back());
3332 edit_items.push_back (SeparatorElem());
3334 if (selection->empty()) {
3335 for (vector<MenuItem*>::iterator i = mitems.begin(); i != mitems.end(); ++i) {
3336 (*i)->set_sensitive (false);
3340 Menu* import_menu = manage (new Menu());
3341 import_menu->set_name ("ArdourContextMenu");
3342 MenuList& import_items = import_menu->items();
3344 import_items.push_back (MenuElem (_("... as new track"), bind (mem_fun(*this, &Editor::import_audio), true)));
3345 import_items.push_back (MenuElem (_("... as new region"), bind (mem_fun(*this, &Editor::import_audio), false)));
3347 Menu* embed_menu = manage (new Menu());
3348 embed_menu->set_name ("ArdourContextMenu");
3349 MenuList& embed_items = embed_menu->items();
3351 embed_items.push_back (MenuElem (_("... as new track"), bind (mem_fun(*this, &Editor::insert_sndfile), true)));
3352 embed_items.push_back (MenuElem (_("... as new region"), mem_fun(*this, &Editor::embed_audio)));
3354 edit_items.push_back (MenuElem (_("Import audio (copy)"), *import_menu));
3355 edit_items.push_back (MenuElem (_("Embed audio (link)"), *embed_menu));
3356 edit_items.push_back (SeparatorElem());
3358 edit_items.push_back (MenuElem (_("Remove last capture"), mem_fun(*this, &Editor::remove_last_capture)));
3359 if (!session->have_captured()) {
3360 edit_items.back().set_sensitive (false);
3367 Editor::duplicate_dialog (bool dup_region)
3370 if (clicked_regionview == 0) {
3374 if (selection->time.length() == 0) {
3379 ArdourDialog win ("duplicate dialog");
3381 Label label (_("Duplicate how many times?"));
3383 win.get_vbox()->pack_start (label);
3384 win.add_action_widget (entry, RESPONSE_ACCEPT);
3385 win.add_button (Stock::OK, RESPONSE_ACCEPT);
3386 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3388 win.set_position (WIN_POS_MOUSE);
3390 entry.set_text ("1");
3391 set_size_request_to_display_given_text (entry, X_("12345678"), 20, 15);
3392 entry.select_region (0, entry.get_text_length());
3393 entry.grab_focus ();
3396 switch (win.run ()) {
3397 case RESPONSE_ACCEPT:
3403 string text = entry.get_text();
3406 if (sscanf (text.c_str(), "%f", ×) == 1) {
3408 AudioRegionSelection regions;
3409 regions.add (clicked_regionview);
3410 duplicate_some_regions (regions, times);
3412 duplicate_selection (times);
3418 Editor::show_verbose_canvas_cursor ()
3420 verbose_canvas_cursor->raise_to_top();
3421 verbose_canvas_cursor->show();
3422 verbose_cursor_visible = true;
3426 Editor::hide_verbose_canvas_cursor ()
3428 verbose_canvas_cursor->hide();
3429 verbose_cursor_visible = false;
3433 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3435 /* XXX get origin of canvas relative to root window,
3436 add x and y and check compared to gdk_screen_{width,height}
3438 verbose_canvas_cursor->property_text() = txt.c_str();
3439 verbose_canvas_cursor->property_x() = x;
3440 verbose_canvas_cursor->property_y() = y;
3444 Editor::set_verbose_canvas_cursor_text (const string & txt)
3446 verbose_canvas_cursor->property_text() = txt.c_str();
3450 Editor::edit_mode_selection_done ()
3456 string choice = edit_mode_selector.get_active_text();
3457 EditMode mode = Slide;
3459 if (choice == _("Splice")) {
3461 } else if (choice == _("Slide")) {
3465 session->set_edit_mode (mode);
3469 Editor::snap_type_selection_done ()
3475 string choice = snap_type_selector.get_active_text();
3476 SnapType snaptype = SnapToFrame;
3478 if (choice == _("Beats/3")) {
3479 snaptype = SnapToAThirdBeat;
3480 } else if (choice == _("Beats/4")) {
3481 snaptype = SnapToAQuarterBeat;
3482 } else if (choice == _("Beats/8")) {
3483 snaptype = SnapToAEighthBeat;
3484 } else if (choice == _("Beats/16")) {
3485 snaptype = SnapToASixteenthBeat;
3486 } else if (choice == _("Beats/32")) {
3487 snaptype = SnapToAThirtysecondBeat;
3488 } else if (choice == _("Beats")) {
3489 snaptype = SnapToBeat;
3490 } else if (choice == _("Bars")) {
3491 snaptype = SnapToBar;
3492 } else if (choice == _("Marks")) {
3493 snaptype = SnapToMark;
3494 } else if (choice == _("Edit Cursor")) {
3495 snaptype = SnapToEditCursor;
3496 } else if (choice == _("Region starts")) {
3497 snaptype = SnapToRegionStart;
3498 } else if (choice == _("Region ends")) {
3499 snaptype = SnapToRegionEnd;
3500 } else if (choice == _("Region bounds")) {
3501 snaptype = SnapToRegionBoundary;
3502 } else if (choice == _("Region syncs")) {
3503 snaptype = SnapToRegionSync;
3504 } else if (choice == _("CD Frames")) {
3505 snaptype = SnapToCDFrame;
3506 } else if (choice == _("SMPTE Frames")) {
3507 snaptype = SnapToSMPTEFrame;
3508 } else if (choice == _("SMPTE Seconds")) {
3509 snaptype = SnapToSMPTESeconds;
3510 } else if (choice == _("SMPTE Minutes")) {
3511 snaptype = SnapToSMPTEMinutes;
3512 } else if (choice == _("Seconds")) {
3513 snaptype = SnapToSeconds;
3514 } else if (choice == _("Minutes")) {
3515 snaptype = SnapToMinutes;
3516 } else if (choice == _("None")) {
3517 snaptype = SnapToFrame;
3520 set_snap_to (snaptype);
3524 Editor::snap_mode_selection_done ()
3530 string choice = snap_mode_selector.get_active_text();
3531 SnapMode mode = SnapNormal;
3533 if (choice == _("Normal")) {
3535 } else if (choice == _("Magnetic")) {
3536 mode = SnapMagnetic;
3539 set_snap_mode (mode);
3543 Editor::zoom_focus_selection_done ()
3549 string choice = zoom_focus_selector.get_active_text();
3550 ZoomFocus focus_type = ZoomFocusLeft;
3552 if (choice == _("Left")) {
3553 focus_type = ZoomFocusLeft;
3554 } else if (choice == _("Right")) {
3555 focus_type = ZoomFocusRight;
3556 } else if (choice == _("Center")) {
3557 focus_type = ZoomFocusCenter;
3558 } else if (choice == _("Playhead")) {
3559 focus_type = ZoomFocusPlayhead;
3560 } else if (choice == _("Edit Cursor")) {
3561 focus_type = ZoomFocusEdit;
3564 set_zoom_focus (focus_type);
3568 Editor::edit_controls_button_release (GdkEventButton* ev)
3570 if (Keyboard::is_context_menu_event (ev)) {
3571 ARDOUR_UI::instance()->add_route ();
3577 Editor::track_selection_changed ()
3579 switch (selection->tracks.size()){
3583 set_selected_mixer_strip (*(selection->tracks.front()));
3587 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3588 (*i)->set_selected (false);
3589 if (mouse_mode == MouseRange) {
3590 (*i)->hide_selection ();
3594 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3595 (*i)->set_selected (true);
3596 if (mouse_mode == MouseRange) {
3597 (*i)->show_selection (selection->time);
3603 Editor::time_selection_changed ()
3605 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3606 (*i)->hide_selection ();
3609 if (selection->tracks.empty()) {
3610 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3611 (*i)->show_selection (selection->time);
3614 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3615 (*i)->show_selection (selection->time);
3619 if (selection->time.empty()) {
3620 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
3622 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true);
3627 Editor::region_selection_changed ()
3629 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3630 (*i)->set_selected_regionviews (selection->audio_regions);
3635 Editor::point_selection_changed ()
3637 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3638 (*i)->set_selected_points (selection->points);
3643 Editor::mouse_select_button_release (GdkEventButton* ev)
3645 /* this handles just right-clicks */
3647 if (ev->button != 3) {
3654 Editor::TrackViewList *
3655 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3658 TrackViewList::iterator i;
3660 v = new TrackViewList;
3662 if (track == 0 && group == 0) {
3666 for (i = track_views.begin(); i != track_views.end (); ++i) {
3670 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3672 /* just the view for this track
3675 v->push_back (track);
3679 /* views for all tracks in the edit group */
3681 for (i = track_views.begin(); i != track_views.end (); ++i) {
3683 if (group == 0 || (*i)->edit_group() == group) {
3693 Editor::set_zoom_focus (ZoomFocus f)
3695 if (zoom_focus != f) {
3697 vector<string> txt = internationalize (zoom_focus_strings);
3698 zoom_focus_selector.set_active_text (txt[(int)f]);
3699 ZoomFocusChanged (); /* EMIT_SIGNAL */
3706 Editor::ensure_float (Window& win)
3708 win.set_transient_for (*this);
3712 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3714 /* recover or initialize pane positions. do this here rather than earlier because
3715 we don't want the positions to change the child allocations, which they seem to do.
3721 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3723 static int32_t done;
3726 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3727 width = default_width;
3728 height = default_height;
3730 width = atoi(geometry->property("x_size")->value());
3731 height = atoi(geometry->property("y_size")->value());
3734 if (which == static_cast<Paned*> (&edit_pane)) {
3740 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3741 /* initial allocation is 90% to canvas, 10% to notebook */
3742 pos = (int) floor (alloc.get_width() * 0.90f);
3743 snprintf (buf, sizeof(buf), "%d", pos);
3745 pos = atoi (prop->value());
3748 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3749 edit_pane.set_position (pos);
3750 pre_maximal_pane_position = pos;
3756 Editor::detach_tearoff (Box* b, Window* w)
3758 if (tools_tearoff->torn_off() &&
3759 mouse_mode_tearoff->torn_off()) {
3760 top_hbox.remove (toolbar_frame);
3765 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3767 if (toolbar_frame.get_parent() == 0) {
3768 top_hbox.pack_end (toolbar_frame);
3773 Editor::set_show_measures (bool yn)
3775 if (_show_measures != yn) {
3778 if ((_show_measures = yn) == true) {
3781 DisplayControlChanged (ShowMeasures);
3787 Editor::toggle_follow_playhead ()
3789 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleFollowPlayhead"));
3791 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3792 set_follow_playhead (tact->get_active());
3797 Editor::set_follow_playhead (bool yn)
3799 if (_follow_playhead != yn) {
3800 if ((_follow_playhead = yn) == true) {
3802 update_current_screen ();
3804 DisplayControlChanged (FollowPlayhead);
3810 Editor::toggle_xfade_active (Crossfade* xfade)
3812 xfade->set_active (!xfade->active());
3816 Editor::toggle_xfade_length (Crossfade* xfade)
3818 xfade->set_follow_overlap (!xfade->following_overlap());
3822 Editor::edit_xfade (Crossfade* xfade)
3824 CrossfadeEditor cew (*session, *xfade, xfade->fade_in().get_min_y(), 1.0);
3828 switch (cew.run ()) {
3829 case RESPONSE_ACCEPT:
3836 xfade->StateChanged (Change (~0));
3840 Editor::playlist_selector () const
3842 return *_playlist_selector;
3846 Editor::get_nudge_distance (jack_nframes_t pos, jack_nframes_t& next)
3850 ret = nudge_clock.current_duration (pos);
3851 next = ret + 1; /* XXXX fix me */
3857 Editor::end_location_changed (Location* location)
3859 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3860 horizontal_adjustment.set_upper (location->end() / frames_per_unit);
3864 Editor::playlist_deletion_dialog (Playlist* pl)
3866 ArdourDialog dialog ("playlist deletion dialog");
3867 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3868 "If left alone, no audio files used by it will be cleaned.\n"
3869 "If deleted, audio files used by it alone by will cleaned."),
3872 dialog.set_position (WIN_POS_CENTER);
3873 dialog.get_vbox()->pack_start (label);
3875 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3876 dialog.add_button (_("Keep playlist"), RESPONSE_CANCEL);
3877 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3879 switch (dialog.run ()) {
3880 case RESPONSE_ACCEPT:
3881 /* delete the playlist */
3885 case RESPONSE_REJECT:
3886 /* keep the playlist */
3898 Editor::audio_region_selection_covers (jack_nframes_t where)
3900 for (AudioRegionSelection::iterator a = selection->audio_regions.begin(); a != selection->audio_regions.end(); ++a) {
3901 if ((*a)->region.covers (where)) {
3910 Editor::prepare_for_cleanup ()
3912 cut_buffer->clear_audio_regions ();
3913 cut_buffer->clear_playlists ();
3915 selection->clear_audio_regions ();
3916 selection->clear_playlists ();
3920 Editor::transport_loop_location()
3923 return session->locations()->auto_loop_location();
3930 Editor::transport_punch_location()
3933 return session->locations()->auto_punch_location();
3940 Editor::control_layout_scroll (GdkEventScroll* ev)
3942 switch (ev->direction) {
3944 scroll_tracks_up_line ();
3948 case GDK_SCROLL_DOWN:
3949 scroll_tracks_down_line ();
3953 /* no left/right handling yet */
3961 Editor::snapshot_display_selection_changed ()
3963 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
3965 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
3967 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
3969 if (snap_name.length() == 0) {
3973 if (session->snap_name() == snap_name) {
3977 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
3982 Editor::snapshot_display_button_press (GdkEventButton* ev)
3988 Editor::redisplay_snapshots ()
3994 vector<string*>* states;
3996 if ((states = session->possible_states()) == 0) {
4000 snapshot_display_model->clear ();
4002 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
4003 string statename = *(*i);
4004 TreeModel::Row row = *(snapshot_display_model->append());
4005 row[snapshot_display_columns.visible_name] = statename;
4006 row[snapshot_display_columns.real_name] = statename;
4013 Editor::session_state_saved (string snap_name)
4015 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
4016 redisplay_snapshots ();
4020 Editor::maximise_editing_space ()
4022 mouse_mode_tearoff->set_visible (false);
4023 tools_tearoff->set_visible (false);
4025 pre_maximal_pane_position = edit_pane.get_position();
4026 edit_pane.set_position (edit_pane.get_width());
4032 Editor::restore_editing_space ()
4034 mouse_mode_tearoff->set_visible (true);
4035 tools_tearoff->set_visible (true);
4036 edit_pane.set_position (pre_maximal_pane_position);
4042 Editor::new_playlists ()
4044 begin_reversible_command (_("new playlists"));
4045 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist));
4046 commit_reversible_command ();
4050 Editor::copy_playlists ()
4052 begin_reversible_command (_("copy playlists"));
4053 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist));
4054 commit_reversible_command ();
4058 Editor::clear_playlists ()
4060 begin_reversible_command (_("clear playlists"));
4061 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist));
4062 commit_reversible_command ();
4066 Editor::mapped_use_new_playlist (AudioTimeAxisView& atv, uint32_t sz)
4068 atv.use_new_playlist (sz > 1 ? false : true);
4072 Editor::mapped_use_copy_playlist (AudioTimeAxisView& atv, uint32_t sz)
4074 atv.use_copy_playlist (sz > 1 ? false : true);
4078 Editor::mapped_clear_playlist (AudioTimeAxisView& atv, uint32_t sz)
4080 atv.clear_playlist ();
4084 Editor::on_key_press_event (GdkEventKey* ev)
4086 return key_press_focus_accelerator_handler (*this, ev);