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/convert.h>
30 #include <pbd/error.h>
31 #include <pbd/memento_command.h>
33 #include <gtkmm/image.h>
34 #include <gdkmm/color.h>
35 #include <gdkmm/bitmap.h>
37 #include <gtkmm2ext/gtk_ui.h>
38 #include <gtkmm2ext/tearoff.h>
39 #include <gtkmm2ext/utils.h>
41 #include <ardour/audio_track.h>
42 #include <ardour/audio_diskstream.h>
43 #include <ardour/plugin_manager.h>
44 #include <ardour/location.h>
45 #include <ardour/audioplaylist.h>
46 #include <ardour/audioregion.h>
47 #include <ardour/region.h>
48 #include <ardour/session_route.h>
49 #include <ardour/tempo.h>
50 #include <ardour/utils.h>
52 #include <control_protocol/control_protocol.h>
54 #include "ardour_ui.h"
56 #include "grouped_buttons.h"
59 #include "playlist_selector.h"
60 #include "audio_region_view.h"
61 #include "rgb_macros.h"
62 #include "selection.h"
63 #include "audio_streamview.h"
64 #include "time_axis_view.h"
66 #include "crossfade_view.h"
68 #include "public_editor.h"
69 #include "crossfade_edit.h"
70 #include "audio_time_axis.h"
71 #include "canvas_impl.h"
73 #include "gui_thread.h"
76 #include "analysis_window.h"
82 #include "imageframe_socket_handler.h"
83 /* </CMT Additions> */
87 using namespace ARDOUR;
91 using namespace Gtkmm2ext;
92 using namespace Editing;
94 using PBD::internationalize;
97 const double Editor::timebar_height = 15.0;
99 #include "editor_xpms"
101 static const gchar *snap_type_strings[] = {
125 static const gchar *snap_mode_strings[] = {
131 static const gchar *zoom_focus_strings[] = {
140 /* Soundfile drag-n-drop */
142 Gdk::Cursor* Editor::cross_hair_cursor = 0;
143 Gdk::Cursor* Editor::selector_cursor = 0;
144 Gdk::Cursor* Editor::trimmer_cursor = 0;
145 Gdk::Cursor* Editor::grabber_cursor = 0;
146 Gdk::Cursor* Editor::zoom_cursor = 0;
147 Gdk::Cursor* Editor::time_fx_cursor = 0;
148 Gdk::Cursor* Editor::fader_cursor = 0;
149 Gdk::Cursor* Editor::speaker_cursor = 0;
150 Gdk::Cursor* Editor::wait_cursor = 0;
151 Gdk::Cursor* Editor::timebar_cursor = 0;
154 show_me_the_size (Requisition* r, const char* what)
156 cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
160 check_adjustment (Gtk::Adjustment* adj)
162 cerr << "CHANGE adj = "
163 << adj->get_lower () << ' '
164 << adj->get_upper () << ' '
165 << adj->get_value () << ' '
166 << adj->get_step_increment () << ' '
167 << adj->get_page_increment () << ' '
168 << adj->get_page_size () << ' '
173 Editor::Editor (AudioEngine& eng)
176 /* time display buttons */
178 minsec_label (_("Mins:Secs")),
179 bbt_label (_("Bars:Beats")),
180 smpte_label (_("SMPTE")),
181 frame_label (_("Frames")),
182 tempo_label (_("Tempo")),
183 meter_label (_("Meter")),
184 mark_label (_("Location Markers")),
185 range_mark_label (_("Range Markers")),
186 transport_mark_label (_("Loop/Punch Ranges")),
188 edit_packer (3, 3, false),
190 /* the values here don't matter: layout widgets
191 reset them as needed.
194 vertical_adjustment (0.0, 0.0, 10.0, 400.0),
195 horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
197 /* tool bar related */
199 edit_cursor_clock (X_("EditCursorClock"), true),
200 zoom_range_clock (X_("ZoomRangeClock"), true, true),
202 toolbar_selection_clock_table (2,3),
204 automation_mode_button (_("mode")),
205 global_automation_button (_("automation")),
207 /* <CMT Additions> */
208 image_socket_listener(0),
209 /* </CMT Additions> */
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 current_mixer_strip = 0;
241 current_bbt_points = 0;
243 snap_type = SnapToFrame;
244 set_snap_to (snap_type);
245 snap_mode = SnapNormal;
246 set_snap_mode (snap_mode);
247 snap_threshold = 5.0;
248 bbt_beat_subdivision = 4;
251 autoscroll_timeout_tag = -1;
252 interthread_progress_window = 0;
258 current_interthread_info = 0;
259 _show_measures = true;
260 _show_waveforms = true;
261 _show_waveforms_recording = true;
262 first_action_message = 0;
264 show_gain_after_trim = false;
265 ignore_route_list_reorder = false;
266 no_route_list_redisplay = false;
267 verbose_cursor_on = true;
268 route_removal = false;
270 show_automatic_regions_in_region_list = true;
271 region_list_sort_type = (Editing::RegionListSortType) 0;
272 have_pending_keyboard_selection = false;
273 _follow_playhead = true;
274 _xfade_visibility = true;
275 editor_ruler_menu = 0;
276 no_ruler_shown_update = false;
277 edit_group_list_menu = 0;
279 region_list_menu = 0;
281 range_marker_menu = 0;
282 marker_menu_item = 0;
284 transport_marker_menu = 0;
285 new_transport_marker_menu = 0;
286 editor_mixer_strip_width = Wide;
287 repos_zoom_queued = false;
288 region_edit_menu_split_item = 0;
290 region_edit_menu_split_multichannel_item = 0;
292 ignore_mouse_mode_toggle = false;
293 current_stepping_trackview = 0;
295 entered_regionview = 0;
296 clear_entered_track = false;
297 _new_regionviews_show_envelope = false;
298 current_timestretch = 0;
299 in_edit_group_row_change = false;
300 last_canvas_frame = 0;
303 button_release_can_deselect = true;
305 location_marker_color = color_map[cLocationMarker];
306 location_range_color = color_map[cLocationRange];
307 location_cd_marker_color = color_map[cLocationCDMarker];
308 location_loop_color = color_map[cLocationLoop];
309 location_punch_color = color_map[cLocationPunch];
311 range_marker_drag_rect = 0;
312 marker_drag_line = 0;
314 set_mouse_mode (MouseObject, true);
316 frames_per_unit = 2048; /* too early to use set_frames_per_unit */
317 reset_hscrollbar_stepping ();
319 zoom_focus = ZoomFocusLeft;
320 set_zoom_focus (ZoomFocusLeft);
321 zoom_range_clock.ValueChanged.connect (mem_fun(*this, &Editor::zoom_adjustment_changed));
323 initialize_rulers ();
324 initialize_canvas ();
326 edit_controls_vbox.set_spacing (0);
327 horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled));
328 vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling));
330 track_canvas.set_hadjustment (horizontal_adjustment);
331 track_canvas.set_vadjustment (vertical_adjustment);
332 time_canvas.set_hadjustment (horizontal_adjustment);
334 track_canvas.signal_map_event().connect (mem_fun (*this, &Editor::track_canvas_map_handler));
335 time_canvas.signal_map_event().connect (mem_fun (*this, &Editor::time_canvas_map_handler));
337 controls_layout.add (edit_controls_vbox);
338 controls_layout.set_name ("EditControlsBase");
339 controls_layout.add_events (Gdk::SCROLL_MASK);
340 controls_layout.signal_scroll_event().connect (mem_fun(*this, &Editor::control_layout_scroll), false);
342 controls_layout.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
343 controls_layout.signal_button_release_event().connect (mem_fun(*this, &Editor::edit_controls_button_release));
344 controls_layout.signal_size_request().connect (mem_fun (*this, &Editor::controls_layout_size_request));
346 edit_vscrollbar.set_adjustment (vertical_adjustment);
347 edit_hscrollbar.set_adjustment (horizontal_adjustment);
349 edit_hscrollbar.signal_button_press_event().connect (mem_fun(*this, &Editor::hscrollbar_button_press));
350 edit_hscrollbar.signal_button_release_event().connect (mem_fun(*this, &Editor::hscrollbar_button_release));
351 edit_hscrollbar.signal_size_allocate().connect (mem_fun(*this, &Editor::hscrollbar_allocate));
356 edit_cursor_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_cursor_clock_changed));
358 time_canvas_vbox.pack_start (*minsec_ruler, false, false);
359 time_canvas_vbox.pack_start (*smpte_ruler, false, false);
360 time_canvas_vbox.pack_start (*frames_ruler, false, false);
361 time_canvas_vbox.pack_start (*bbt_ruler, false, false);
362 time_canvas_vbox.pack_start (time_canvas, true, true);
363 time_canvas_vbox.set_size_request (-1, (int)(timebar_height * visible_timebars));
365 bbt_label.set_name ("EditorTimeButton");
366 bbt_label.set_size_request (-1, (int)timebar_height);
367 bbt_label.set_alignment (1.0, 0.5);
368 bbt_label.set_padding (5,0);
369 minsec_label.set_name ("EditorTimeButton");
370 minsec_label.set_size_request (-1, (int)timebar_height);
371 minsec_label.set_alignment (1.0, 0.5);
372 minsec_label.set_padding (5,0);
373 smpte_label.set_name ("EditorTimeButton");
374 smpte_label.set_size_request (-1, (int)timebar_height);
375 smpte_label.set_alignment (1.0, 0.5);
376 smpte_label.set_padding (5,0);
377 frame_label.set_name ("EditorTimeButton");
378 frame_label.set_size_request (-1, (int)timebar_height);
379 frame_label.set_alignment (1.0, 0.5);
380 frame_label.set_padding (5,0);
381 tempo_label.set_name ("EditorTimeButton");
382 tempo_label.set_size_request (-1, (int)timebar_height);
383 tempo_label.set_alignment (1.0, 0.5);
384 tempo_label.set_padding (5,0);
385 meter_label.set_name ("EditorTimeButton");
386 meter_label.set_size_request (-1, (int)timebar_height);
387 meter_label.set_alignment (1.0, 0.5);
388 meter_label.set_padding (5,0);
389 mark_label.set_name ("EditorTimeButton");
390 mark_label.set_size_request (-1, (int)timebar_height);
391 mark_label.set_alignment (1.0, 0.5);
392 mark_label.set_padding (5,0);
393 range_mark_label.set_name ("EditorTimeButton");
394 range_mark_label.set_size_request (-1, (int)timebar_height);
395 range_mark_label.set_alignment (1.0, 0.5);
396 range_mark_label.set_padding (5,0);
397 transport_mark_label.set_name ("EditorTimeButton");
398 transport_mark_label.set_size_request (-1, (int)timebar_height);
399 transport_mark_label.set_alignment (1.0, 0.5);
400 transport_mark_label.set_padding (5,0);
402 time_button_vbox.pack_start (minsec_label, false, false);
403 time_button_vbox.pack_start (smpte_label, false, false);
404 time_button_vbox.pack_start (frame_label, false, false);
405 time_button_vbox.pack_start (bbt_label, false, false);
406 time_button_vbox.pack_start (meter_label, false, false);
407 time_button_vbox.pack_start (tempo_label, false, false);
408 time_button_vbox.pack_start (mark_label, false, false);
410 time_button_event_box.add (time_button_vbox);
412 time_button_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
413 time_button_event_box.set_name ("TimebarLabelBase");
414 time_button_event_box.signal_button_release_event().connect (mem_fun(*this, &Editor::ruler_label_button_release));
416 /* these enable us to have a dedicated window (for cursor setting, etc.)
417 for the canvas areas.
420 track_canvas_event_box.add (track_canvas);
422 time_canvas_event_box.add (time_canvas_vbox);
423 time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
425 edit_packer.set_col_spacings (0);
426 edit_packer.set_row_spacings (0);
427 edit_packer.set_homogeneous (false);
428 edit_packer.set_border_width (0);
429 edit_packer.set_name ("EditorWindow");
431 edit_packer.attach (edit_vscrollbar, 0, 1, 1, 3, FILL, FILL|EXPAND, 0, 0);
433 edit_packer.attach (time_button_event_box, 1, 2, 0, 1, FILL, FILL, 0, 0);
434 edit_packer.attach (time_canvas_event_box, 2, 3, 0, 1, FILL|EXPAND, FILL, 0, 0);
436 edit_packer.attach (controls_layout, 1, 2, 1, 2, FILL, FILL|EXPAND, 0, 0);
437 edit_packer.attach (track_canvas_event_box, 2, 3, 1, 2, FILL|EXPAND, FILL|EXPAND, 0, 0);
439 edit_packer.attach (edit_hscrollbar, 2, 3, 2, 3, FILL|EXPAND, FILL, 0, 0);
441 bottom_hbox.set_border_width (2);
442 bottom_hbox.set_spacing (3);
444 route_display_model = ListStore::create(route_display_columns);
445 route_list_display.set_model (route_display_model);
446 route_list_display.append_column (_("Visible"), route_display_columns.visible);
447 route_list_display.append_column (_("Name"), route_display_columns.text);
448 route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
449 route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
450 route_list_display.set_headers_visible (true);
451 route_list_display.set_name ("TrackListDisplay");
452 route_list_display.get_selection()->set_mode (SELECTION_NONE);
453 route_list_display.set_reorderable (true);
454 route_list_display.set_size_request (100,-1);
456 CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (0));
457 route_list_visible_cell->property_activatable() = true;
458 route_list_visible_cell->property_radio() = false;
460 route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
461 route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
463 route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
465 route_list_scroller.add (route_list_display);
466 route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
468 group_model = ListStore::create(group_columns);
469 edit_group_display.set_model (group_model);
470 edit_group_display.append_column (_("Name"), group_columns.text);
471 edit_group_display.append_column (_("Active"), group_columns.is_active);
472 edit_group_display.append_column (_("Visible"), group_columns.is_visible);
473 edit_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
474 edit_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
475 edit_group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
476 edit_group_display.get_column (0)->set_expand (true);
477 edit_group_display.get_column (1)->set_expand (false);
478 edit_group_display.get_column (2)->set_expand (false);
479 edit_group_display.set_headers_visible (true);
481 /* name is directly editable */
483 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(edit_group_display.get_column_cell_renderer (0));
484 name_cell->property_editable() = true;
485 name_cell->signal_edited().connect (mem_fun (*this, &Editor::edit_group_name_edit));
487 /* use checkbox for the active + visible columns */
489 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
490 active_cell->property_activatable() = true;
491 active_cell->property_radio() = false;
493 active_cell = dynamic_cast<CellRendererToggle*>(edit_group_display.get_column_cell_renderer (1));
494 active_cell->property_activatable() = true;
495 active_cell->property_radio() = false;
497 edit_group_display.set_name ("EditGroupList");
499 group_model->signal_row_changed().connect (mem_fun (*this, &Editor::edit_group_row_change));
501 edit_group_display.set_name ("EditGroupList");
502 edit_group_display.get_selection()->set_mode (SELECTION_SINGLE);
503 edit_group_display.set_reorderable (false);
504 edit_group_display.set_rules_hint (true);
505 edit_group_display.set_size_request (75, -1);
507 edit_group_display_scroller.add (edit_group_display);
508 edit_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
510 edit_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::edit_group_list_button_press_event), false);
512 VBox* edit_group_display_packer = manage (new VBox());
513 HButtonBox* edit_group_display_button_box = manage (new HButtonBox());
514 edit_group_display_button_box->set_homogeneous (true);
516 Button* edit_group_add_button = manage (new Button ());
517 Button* edit_group_remove_button = manage (new Button ());
521 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
523 edit_group_add_button->add (*w);
525 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
527 edit_group_remove_button->add (*w);
529 edit_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_edit_group));
530 edit_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_edit_group));
532 edit_group_display_button_box->pack_start (*edit_group_add_button);
533 edit_group_display_button_box->pack_start (*edit_group_remove_button);
535 edit_group_display_packer->pack_start (edit_group_display_scroller, true, true);
536 edit_group_display_packer->pack_start (*edit_group_display_button_box, false, false);
538 region_list_display.set_size_request (100, -1);
539 region_list_display.set_name ("RegionListDisplay");
541 region_list_model = TreeStore::create (region_list_columns);
542 region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
543 region_list_model->set_sort_column (0, SORT_ASCENDING);
545 region_list_display.set_model (region_list_model);
546 region_list_display.append_column (_("Regions"), region_list_columns.name);
547 region_list_display.set_headers_visible (false);
548 region_list_display.set_hover_expand (true);
550 region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
552 TreeViewColumn* tv_col = region_list_display.get_column(0);
553 CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
554 tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
555 tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
557 region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
558 region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
560 /* setup DnD handling */
562 list<TargetEntry> region_list_target_table;
564 region_list_target_table.push_back (TargetEntry ("text/plain"));
565 region_list_target_table.push_back (TargetEntry ("text/uri-list"));
566 region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
568 region_list_display.add_drop_targets (region_list_target_table);
569 region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
571 region_list_scroller.add (region_list_display);
572 region_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
574 region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
575 region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
576 region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
577 region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
578 region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
579 // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
581 named_selection_scroller.add (named_selection_display);
582 named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
584 named_selection_model = TreeStore::create (named_selection_columns);
585 named_selection_display.set_model (named_selection_model);
586 named_selection_display.append_column (_("Chunks"), named_selection_columns.text);
587 named_selection_display.set_headers_visible (false);
588 named_selection_display.set_size_request (100, -1);
589 named_selection_display.set_name ("RegionListDisplay");
591 named_selection_display.get_selection()->set_mode (SELECTION_SINGLE);
592 named_selection_display.set_size_request (100, -1);
593 named_selection_display.signal_button_press_event().connect (mem_fun(*this, &Editor::named_selection_display_button_press), false);
594 named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
598 snapshot_display_model = ListStore::create (snapshot_display_columns);
599 snapshot_display.set_model (snapshot_display_model);
600 snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
601 snapshot_display.set_name ("SnapshotDisplayList");
602 snapshot_display.set_size_request (75, -1);
603 snapshot_display.set_headers_visible (false);
604 snapshot_display.set_reorderable (false);
605 snapshot_display_scroller.add (snapshot_display);
606 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
608 snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
609 snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
613 nlabel = manage (new Label (_("Regions")));
614 nlabel->set_angle (-90);
615 the_notebook.append_page (region_list_scroller, *nlabel);
616 nlabel = manage (new Label (_("Tracks/Busses")));
617 nlabel->set_angle (-90);
618 the_notebook.append_page (route_list_scroller, *nlabel);
619 nlabel = manage (new Label (_("Snapshots")));
620 nlabel->set_angle (-90);
621 the_notebook.append_page (snapshot_display_scroller, *nlabel);
622 nlabel = manage (new Label (_("Edit Groups")));
623 nlabel->set_angle (-90);
624 the_notebook.append_page (*edit_group_display_packer, *nlabel);
625 nlabel = manage (new Label (_("Chunks")));
626 nlabel->set_angle (-90);
627 the_notebook.append_page (named_selection_scroller, *nlabel);
629 the_notebook.set_show_tabs (true);
630 the_notebook.set_scrollable (true);
631 the_notebook.popup_enable ();
632 the_notebook.set_tab_pos (Gtk::POS_RIGHT);
634 edit_pane.pack1 (edit_packer, true, true);
635 edit_pane.pack2 (the_notebook, false, true);
637 edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
639 top_hbox.pack_start (toolbar_frame, true, true);
641 HBox *hbox = manage (new HBox);
642 hbox->pack_start (edit_pane, true, true);
644 global_vpacker.pack_start (top_hbox, false, false);
645 global_vpacker.pack_start (*hbox, true, true);
647 global_hpacker.pack_start (global_vpacker, true, true);
649 set_name ("EditorWindow");
650 add_accel_group (ActionManager::ui_manager->get_accel_group());
652 vpacker.pack_end (global_hpacker, true, true);
654 /* register actions now so that set_state() can find them and set toggles/checks etc */
658 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
661 _playlist_selector = new PlaylistSelector();
662 _playlist_selector->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Window *> (_playlist_selector)));
664 RegionView::RegionViewGoingAway.connect (mem_fun(*this, &Editor::catch_vanishing_regionview));
668 nudge_forward_button.add (*(manage (new Image (get_xpm("right_arrow.xpm")))));
669 nudge_backward_button.add (*(manage (new Image (get_xpm("left_arrow.xpm")))));
671 ARDOUR_UI::instance()->tooltips().set_tip (nudge_forward_button, _("Nudge Region/Selection Forwards"));
672 ARDOUR_UI::instance()->tooltips().set_tip (nudge_backward_button, _("Nudge Region/Selection Backwards"));
674 nudge_forward_button.set_name ("TransportButton");
675 nudge_backward_button.set_name ("TransportButton");
677 fade_context_menu.set_name ("ArdourContextMenu");
679 set_title (_("ardour: editor"));
680 set_wmclass (_("ardour_editor"), "Ardour");
683 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
685 signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
686 signal_delete_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::exit_on_main_window_close));
688 /* allow external control surfaces/protocols to do various things */
690 ControlProtocol::ZoomToSession.connect (mem_fun (*this, &Editor::temporal_zoom_session));
691 ControlProtocol::ZoomIn.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), false));
692 ControlProtocol::ZoomOut.connect (bind (mem_fun (*this, &Editor::temporal_zoom_step), true));
693 ControlProtocol::ScrollTimeline.connect (mem_fun (*this, &Editor::control_scroll));
695 Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
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_regionview (RegionView *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 (RegionView* 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::show_window ()
774 /* now reset all audio_time_axis heights, because widgets might need
780 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
781 tv = (static_cast<TimeAxisView*>(*i));
787 Editor::tie_vertical_scrolling ()
789 double y1 = vertical_adjustment.get_value();
790 controls_layout.get_vadjustment()->set_value (y1);
791 playhead_cursor->set_y_axis(y1);
792 edit_cursor->set_y_axis(y1);
796 Editor::set_frames_per_unit (double fpu)
800 if (fpu == frames_per_unit) {
808 // convert fpu to frame count
810 frames = (nframes_t) floor (fpu * canvas_width);
812 /* don't allow zooms that fit more than the maximum number
813 of frames into an 800 pixel wide space.
816 if (max_frames / fpu < 800.0) {
820 frames_per_unit = fpu;
822 if (frames != zoom_range_clock.current_duration()) {
823 zoom_range_clock.set (frames);
826 if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) {
827 if (!selection->tracks.empty()) {
828 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
829 (*i)->reshow_selection (selection->time);
832 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
833 (*i)->reshow_selection (selection->time);
838 ZoomChanged (); /* EMIT_SIGNAL */
840 reset_hscrollbar_stepping ();
841 reset_scrolling_region ();
843 if (edit_cursor) edit_cursor->set_position (edit_cursor->current_frame);
844 if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
851 Editor::instant_save ()
853 if (!constructed || !ARDOUR_UI::instance()->session_loaded) {
858 session->add_instant_xml(get_state(), session->path());
860 Config->add_instant_xml(get_state(), get_user_ardour_path());
865 Editor::reposition_x_origin (nframes_t frame)
867 if (frame != leftmost_frame) {
868 leftmost_frame = frame;
870 nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
872 if (rightmost_frame > last_canvas_frame) {
873 last_canvas_frame = rightmost_frame;
874 reset_scrolling_region ();
877 horizontal_adjustment.set_value (frame/frames_per_unit);
879 update_fixed_rulers();
880 tempo_map_changed (Change (0));
885 Editor::edit_cursor_clock_changed()
887 if (edit_cursor->current_frame != edit_cursor_clock.current_time()) {
888 edit_cursor->set_position (edit_cursor_clock.current_time());
894 Editor::zoom_adjustment_changed ()
900 double fpu = zoom_range_clock.current_duration() / canvas_width;
904 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
905 } else if (fpu > session->current_end_frame() / canvas_width) {
906 fpu = session->current_end_frame() / canvas_width;
907 zoom_range_clock.set ((nframes_t) floor (fpu * canvas_width));
914 Editor::control_scroll (float fraction)
916 ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::control_scroll), fraction));
922 double step = fraction * current_page_frames();
925 if ((fraction < 0.0f) && (session->transport_frame() < (nframes_t) fabs(step))) {
927 } else if ((fraction > 0.0f) && (max_frames - session->transport_frame() < step)) {
928 target = (max_frames - (current_page_frames()*2)); // allow room for slop in where the PH is on the screen
930 target = (session->transport_frame() + (nframes_t) floor ((fraction * current_page_frames())));
933 /* move visuals, we'll catch up with it later */
935 playhead_cursor->set_position (target);
937 if (target > (current_page_frames() / 2)) {
938 /* try to center PH in window */
939 reposition_x_origin (target - (current_page_frames()/2));
941 reposition_x_origin (0);
944 /* cancel the existing */
946 control_scroll_connection.disconnect ();
948 /* add the next one */
950 control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), target), 50);
954 Editor::deferred_control_scroll (nframes_t target)
956 session->request_locate (target);
961 Editor::canvas_horizontally_scrolled ()
964 leftmost_frame = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
965 update_fixed_rulers ();
966 tempo_map_changed (Change (0));
971 Editor::reposition_and_zoom (nframes_t frame, double nfpu)
973 if (!repos_zoom_queued) {
974 repos_zoom_queued = true;
975 Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::deferred_reposition_and_zoom), frame, nfpu));
980 Editor::deferred_reposition_and_zoom (nframes_t frame, double nfpu)
983 set_frames_per_unit (nfpu);
984 reposition_x_origin (frame);
985 repos_zoom_queued = false;
991 Editor::on_realize ()
993 Window::on_realize ();
998 Editor::start_scrolling ()
1000 scroll_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect
1001 (mem_fun(*this, &Editor::update_current_screen));
1005 Editor::stop_scrolling ()
1007 scroll_connection.disconnect ();
1011 Editor::map_position_change (nframes_t frame)
1013 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::map_position_change), frame));
1015 if (session == 0 || !_follow_playhead) {
1019 center_screen (frame);
1020 playhead_cursor->set_position (frame);
1024 Editor::center_screen (nframes_t frame)
1026 double page = canvas_width * frames_per_unit;
1028 /* if we're off the page, then scroll.
1031 if (frame < leftmost_frame || frame >= leftmost_frame + page) {
1032 center_screen_internal (frame, page);
1037 Editor::center_screen_internal (nframes_t frame, float page)
1042 frame -= (nframes_t) page;
1047 reposition_x_origin (frame);
1051 Editor::handle_new_duration ()
1053 ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
1055 nframes_t new_end = session->get_maximum_extent() + (nframes_t) floorf (current_page_frames() * 0.10f);
1057 if (new_end > last_canvas_frame) {
1058 last_canvas_frame = new_end;
1059 reset_scrolling_region ();
1062 horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
1066 Editor::update_title_s (const string & snap_name)
1068 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::update_title_s), snap_name));
1074 Editor::update_title ()
1076 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_title));
1079 bool dirty = session->dirty();
1081 string wintitle = _("ardour: editor: ");
1087 wintitle += session->name();
1089 if (session->snap_name() != session->name()) {
1091 wintitle += session->snap_name();
1098 set_title (wintitle);
1103 Editor::connect_to_session (Session *t)
1107 if (first_action_message) {
1108 first_action_message->hide();
1113 session->GoingAway.connect (mem_fun(*this, &Editor::session_going_away));
1115 /* These signals can all be emitted by a non-GUI thread. Therefore the
1116 handlers for them must not attempt to directly interact with the GUI,
1117 but use Gtkmm2ext::UI::instance()->call_slot();
1120 session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
1121 session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
1122 session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
1123 session_connections.push_back (session->AudioRegionAdded.connect (mem_fun(*this, &Editor::handle_new_audio_region)));
1124 session_connections.push_back (session->AudioRegionRemoved.connect (mem_fun(*this, &Editor::handle_audio_region_removed)));
1125 session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
1126 session_connections.push_back (session->edit_group_added.connect (mem_fun(*this, &Editor::add_edit_group)));
1127 session_connections.push_back (session->edit_group_removed.connect (mem_fun(*this, &Editor::edit_groups_changed)));
1128 session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1129 session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
1130 session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
1131 session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
1132 session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
1133 session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
1135 session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
1137 session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
1139 edit_groups_changed ();
1141 edit_cursor_clock.set_session (session);
1142 zoom_range_clock.set_session (session);
1143 _playlist_selector->set_session (session);
1144 nudge_clock.set_session (session);
1147 if (analysis_window != 0)
1148 analysis_window->set_session (session);
1151 Location* loc = session->locations()->auto_loop_location();
1153 loc = new Location (0, session->current_end_frame(), _("Loop"),(Location::Flags) (Location::IsAutoLoop | Location::IsHidden));
1154 if (loc->start() == loc->end()) {
1155 loc->set_end (loc->start() + 1);
1157 session->locations()->add (loc, false);
1158 session->set_auto_loop_location (loc);
1162 loc->set_name (_("Loop"));
1165 loc = session->locations()->auto_punch_location();
1167 loc = new Location (0, session->current_end_frame(), _("Punch"), (Location::Flags) (Location::IsAutoPunch | Location::IsHidden));
1168 if (loc->start() == loc->end()) {
1169 loc->set_end (loc->start() + 1);
1171 session->locations()->add (loc, false);
1172 session->set_auto_punch_location (loc);
1176 loc->set_name (_("Punch"));
1179 Config->map_parameters (mem_fun (*this, &Editor::parameter_changed));
1181 session->StateSaved.connect (mem_fun(*this, &Editor::session_state_saved));
1183 refresh_location_display ();
1184 session->locations()->added.connect (mem_fun(*this, &Editor::add_new_location));
1185 session->locations()->removed.connect (mem_fun(*this, &Editor::location_gone));
1186 session->locations()->changed.connect (mem_fun(*this, &Editor::refresh_location_display));
1187 session->locations()->StateChanged.connect (mem_fun(*this, &Editor::refresh_location_display_s));
1188 session->locations()->end_location()->changed.connect (mem_fun(*this, &Editor::end_location_changed));
1190 handle_new_duration ();
1192 redisplay_regions ();
1193 redisplay_named_selections ();
1194 redisplay_snapshots ();
1196 initial_route_list_display ();
1198 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
1199 (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
1202 /* ::reposition_x_origin() doesn't work right here, since the old
1203 position may be zero already, and it does nothing in such
1209 horizontal_adjustment.set_value (0);
1211 restore_ruler_visibility ();
1212 //tempo_map_changed (Change (0));
1213 session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
1215 edit_cursor->set_position (0);
1216 playhead_cursor->set_position (0);
1220 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
1223 /* don't show master bus in a new session */
1225 if (ARDOUR_UI::instance()->session_is_new ()) {
1227 TreeModel::Children rows = route_display_model->children();
1228 TreeModel::Children::iterator i;
1230 no_route_list_redisplay = true;
1232 for (i = rows.begin(); i != rows.end(); ++i) {
1233 TimeAxisView *tv = (*i)[route_display_columns.tv];
1234 AudioTimeAxisView *atv;
1236 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1237 if (atv->route()->master()) {
1238 route_list_display.get_selection()->unselect (i);
1243 no_route_list_redisplay = false;
1244 redisplay_route_list ();
1247 /* register for undo history */
1249 session->register_with_memento_command_factory(_id, this);
1253 Editor::build_cursors ()
1255 using namespace Gdk;
1257 Gdk::Color mbg ("#000000" ); /* Black */
1258 Gdk::Color mfg ("#0000ff" ); /* Blue. */
1261 RefPtr<Bitmap> source, mask;
1262 source = Bitmap::create (mag_bits, mag_width, mag_height);
1263 mask = Bitmap::create (magmask_bits, mag_width, mag_height);
1264 zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
1267 Gdk::Color fbg ("#ffffff" );
1268 Gdk::Color ffg ("#000000" );
1271 RefPtr<Bitmap> source, mask;
1273 source = Bitmap::create (fader_cursor_bits, fader_cursor_width, fader_cursor_height);
1274 mask = Bitmap::create (fader_cursor_mask_bits, fader_cursor_width, fader_cursor_height);
1275 fader_cursor = new Gdk::Cursor (source, mask, ffg, fbg, fader_cursor_x_hot, fader_cursor_y_hot);
1279 RefPtr<Bitmap> source, mask;
1280 source = Bitmap::create (speaker_cursor_bits, speaker_cursor_width, speaker_cursor_height);
1281 mask = Bitmap::create (speaker_cursor_mask_bits, speaker_cursor_width, speaker_cursor_height);
1282 speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
1285 grabber_cursor = new Gdk::Cursor (HAND2);
1286 cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
1287 trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);
1288 selector_cursor = new Gdk::Cursor (XTERM);
1289 time_fx_cursor = new Gdk::Cursor (SIZING);
1290 wait_cursor = new Gdk::Cursor (WATCH);
1291 timebar_cursor = new Gdk::Cursor(LEFT_PTR);
1295 Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* item, ItemType item_type)
1297 using namespace Menu_Helpers;
1298 AudioRegionView* arv = static_cast<AudioRegionView*> (item->get_data ("regionview"));
1301 fatal << _("programming error: fade in canvas item has no regionview data pointer!") << endmsg;
1305 MenuList& items (fade_context_menu.items());
1306 AudioRegion& ar (*arv->audio_region().get()); // FIXME
1310 switch (item_type) {
1312 case FadeInHandleItem:
1313 if (arv->audio_region()->fade_in_active()) {
1314 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), false)));
1316 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_in_active), true)));
1319 items.push_back (SeparatorElem());
1321 items.push_back (MenuElem (_("Linear"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Linear)));
1322 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::LogB)));
1323 items.push_back (MenuElem (_("Slow"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Fast)));
1324 items.push_back (MenuElem (_("Fast"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::LogA)));
1325 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (ar, &AudioRegion::set_fade_in_shape), AudioRegion::Slow)));
1329 case FadeOutHandleItem:
1330 if (arv->audio_region()->fade_out_active()) {
1331 items.push_back (MenuElem (_("Deactivate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), false)));
1333 items.push_back (MenuElem (_("Activate"), bind (mem_fun (*arv, &AudioRegionView::set_fade_out_active), true)));
1336 items.push_back (SeparatorElem());
1338 items.push_back (MenuElem (_("Linear"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Linear)));
1339 items.push_back (MenuElem (_("Slowest"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Fast)));
1340 items.push_back (MenuElem (_("Slow"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::LogB)));
1341 items.push_back (MenuElem (_("Fast"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::LogA)));
1342 items.push_back (MenuElem (_("Fastest"), bind (mem_fun (ar, &AudioRegion::set_fade_out_shape), AudioRegion::Slow)));
1346 fatal << _("programming error: ")
1347 << X_("non-fade canvas item passed to popup_fade_context_menu()")
1352 fade_context_menu.popup (button, time);
1356 Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, bool with_selection, nframes_t frame)
1358 using namespace Menu_Helpers;
1359 Menu* (Editor::*build_menu_function)(nframes_t);
1362 switch (item_type) {
1364 case RegionViewName:
1365 case RegionViewNameHighlight:
1366 if (with_selection) {
1367 build_menu_function = &Editor::build_track_selection_context_menu;
1369 build_menu_function = &Editor::build_track_region_context_menu;
1374 if (with_selection) {
1375 build_menu_function = &Editor::build_track_selection_context_menu;
1377 build_menu_function = &Editor::build_track_context_menu;
1381 case CrossfadeViewItem:
1382 build_menu_function = &Editor::build_track_crossfade_context_menu;
1386 if (clicked_audio_trackview->get_diskstream()) {
1387 build_menu_function = &Editor::build_track_context_menu;
1389 build_menu_function = &Editor::build_track_bus_context_menu;
1394 /* probably shouldn't happen but if it does, we don't care */
1398 menu = (this->*build_menu_function)(frame);
1399 menu->set_name ("ArdourContextMenu");
1401 /* now handle specific situations */
1403 switch (item_type) {
1405 case RegionViewName:
1406 case RegionViewNameHighlight:
1407 if (!with_selection) {
1408 if (region_edit_menu_split_item) {
1409 if (clicked_regionview && clicked_regionview->region()->covers (edit_cursor->current_frame)) {
1410 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, true);
1412 ActionManager::set_sensitive (ActionManager::edit_cursor_in_region_sensitive_actions, false);
1416 if (region_edit_menu_split_multichannel_item) {
1417 if (clicked_regionview && clicked_regionview->region().n_channels() > 1) {
1418 // GTK2FIX find the action, change its sensitivity
1419 // region_edit_menu_split_multichannel_item->set_sensitive (true);
1421 // GTK2FIX see above
1422 // region_edit_menu_split_multichannel_item->set_sensitive (false);
1431 case CrossfadeViewItem:
1438 /* probably shouldn't happen but if it does, we don't care */
1442 if (clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
1444 /* Bounce to disk */
1446 using namespace Menu_Helpers;
1447 MenuList& edit_items = menu->items();
1449 edit_items.push_back (SeparatorElem());
1451 switch (clicked_audio_trackview->audio_track()->freeze_state()) {
1452 case AudioTrack::NoFreeze:
1453 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1456 case AudioTrack::Frozen:
1457 edit_items.push_back (MenuElem (_("Unfreeze"), mem_fun(*this, &Editor::unfreeze_route)));
1460 case AudioTrack::UnFrozen:
1461 edit_items.push_back (MenuElem (_("Freeze"), mem_fun(*this, &Editor::freeze_route)));
1467 menu->popup (button, time);
1471 Editor::build_track_context_menu (nframes_t ignored)
1473 using namespace Menu_Helpers;
1475 MenuList& edit_items = track_context_menu.items();
1478 add_dstream_context_items (edit_items);
1479 return &track_context_menu;
1483 Editor::build_track_bus_context_menu (nframes_t ignored)
1485 using namespace Menu_Helpers;
1487 MenuList& edit_items = track_context_menu.items();
1490 add_bus_context_items (edit_items);
1491 return &track_context_menu;
1495 Editor::build_track_region_context_menu (nframes_t frame)
1497 using namespace Menu_Helpers;
1498 MenuList& edit_items = track_region_context_menu.items();
1501 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1504 boost::shared_ptr<Diskstream> ds;
1507 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()))) {
1508 Playlist::RegionList* regions = pl->regions_at ((nframes_t) floor ( (double)frame * ds->speed()));
1509 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1510 add_region_context_items (atv->audio_view(), (*i), edit_items);
1516 add_dstream_context_items (edit_items);
1518 return &track_region_context_menu;
1522 Editor::build_track_crossfade_context_menu (nframes_t frame)
1524 using namespace Menu_Helpers;
1525 MenuList& edit_items = track_crossfade_context_menu.items();
1526 edit_items.clear ();
1528 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (clicked_trackview);
1531 boost::shared_ptr<Diskstream> ds;
1535 if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = dynamic_cast<AudioPlaylist*> (pl)) != 0)) {
1537 Playlist::RegionList* regions = pl->regions_at (frame);
1538 AudioPlaylist::Crossfades xfades;
1540 apl->crossfades_at (frame, xfades);
1542 bool many = xfades.size() > 1;
1544 for (AudioPlaylist::Crossfades::iterator i = xfades.begin(); i != xfades.end(); ++i) {
1545 add_crossfade_context_items (atv->audio_view(), (*i), edit_items, many);
1548 for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) {
1549 add_region_context_items (atv->audio_view(), (*i), edit_items);
1556 add_dstream_context_items (edit_items);
1558 return &track_crossfade_context_menu;
1563 Editor::analyze_region_selection()
1565 if (analysis_window == 0) {
1566 analysis_window = new AnalysisWindow();
1569 analysis_window->set_session(session);
1571 analysis_window->show_all();
1574 analysis_window->set_regionmode();
1575 analysis_window->analyze();
1577 analysis_window->present();
1581 Editor::analyze_range_selection()
1583 if (analysis_window == 0) {
1584 analysis_window = new AnalysisWindow();
1587 analysis_window->set_session(session);
1589 analysis_window->show_all();
1592 analysis_window->set_rangemode();
1593 analysis_window->analyze();
1595 analysis_window->present();
1597 #endif /* FFT_ANALYSIS */
1602 Editor::build_track_selection_context_menu (nframes_t ignored)
1604 using namespace Menu_Helpers;
1605 MenuList& edit_items = track_selection_context_menu.items();
1606 edit_items.clear ();
1608 add_selection_context_items (edit_items);
1609 add_dstream_context_items (edit_items);
1611 return &track_selection_context_menu;
1615 Editor::add_crossfade_context_items (AudioStreamView* view, Crossfade* xfade, Menu_Helpers::MenuList& edit_items, bool many)
1617 using namespace Menu_Helpers;
1618 Menu *xfade_menu = manage (new Menu);
1619 MenuList& items = xfade_menu->items();
1620 xfade_menu->set_name ("ArdourContextMenu");
1623 if (xfade->active()) {
1629 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_active), xfade)));
1630 items.push_back (MenuElem (_("Edit"), bind (mem_fun(*this, &Editor::edit_xfade), xfade)));
1632 if (xfade->can_follow_overlap()) {
1634 if (xfade->following_overlap()) {
1635 str = _("Convert to short");
1637 str = _("Convert to full");
1640 items.push_back (MenuElem (str, bind (mem_fun(*this, &Editor::toggle_xfade_length), xfade)));
1644 str = xfade->out()->name();
1646 str += xfade->in()->name();
1648 str = _("Crossfade");
1651 edit_items.push_back (MenuElem (str, *xfade_menu));
1652 edit_items.push_back (SeparatorElem());
1656 Editor::xfade_edit_left_region ()
1658 if (clicked_crossfadeview) {
1659 clicked_crossfadeview->left_view.show_region_editor ();
1664 Editor::xfade_edit_right_region ()
1666 if (clicked_crossfadeview) {
1667 clicked_crossfadeview->right_view.show_region_editor ();
1672 Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
1674 using namespace Menu_Helpers;
1675 Menu *region_menu = manage (new Menu);
1676 MenuList& items = region_menu->items();
1677 region_menu->set_name ("ArdourContextMenu");
1679 boost::shared_ptr<AudioRegion> ar;
1682 ar = boost::dynamic_pointer_cast<AudioRegion> (region);
1685 /* when this particular menu pops up, make the relevant region
1689 region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, region));
1691 items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
1692 items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
1693 items.push_back (MenuElem (_("Lower to bottom layer"), mem_fun (*this, &Editor::lower_region_to_bottom)));
1694 items.push_back (SeparatorElem());
1695 items.push_back (MenuElem (_("Define sync point"), mem_fun(*this, &Editor::set_region_sync_from_edit_cursor)));
1696 items.push_back (MenuElem (_("Remove sync point"), mem_fun(*this, &Editor::remove_region_sync)));
1697 items.push_back (SeparatorElem());
1699 items.push_back (MenuElem (_("Audition"), mem_fun(*this, &Editor::audition_selected_region)));
1700 items.push_back (MenuElem (_("Export"), mem_fun(*this, &Editor::export_region)));
1701 items.push_back (MenuElem (_("Bounce"), mem_fun(*this, &Editor::bounce_region_selection)));
1704 items.push_back (MenuElem (_("Analyze region"), mem_fun(*this, &Editor::analyze_region_selection)));
1707 items.push_back (SeparatorElem());
1709 /* XXX hopefully this nonsense will go away with SigC++ 2.X, where the compiler
1710 might be able to figure out which overloaded member function to use in
1714 void (Editor::*type_A_pmf)(void (Region::*pmf)(bool), bool) = &Editor::region_selection_op;
1716 items.push_back (MenuElem (_("Lock"), bind (mem_fun(*this, type_A_pmf), &Region::set_locked, true)));
1717 items.push_back (MenuElem (_("Unlock"), bind (mem_fun(*this, type_A_pmf), &Region::set_locked, false)));
1718 items.push_back (SeparatorElem());
1720 if (region->muted()) {
1721 items.push_back (MenuElem (_("Unmute"), bind (mem_fun(*this, type_A_pmf), &Region::set_muted, false)));
1723 items.push_back (MenuElem (_("Mute"), bind (mem_fun(*this, type_A_pmf), &Region::set_muted, true)));
1725 items.push_back (SeparatorElem());
1727 items.push_back (MenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize)));
1728 items.push_back (SeparatorElem());
1733 items.push_back (MenuElem (_("Toggle envelope visibility"), mem_fun(*this, &Editor::toggle_gain_envelope_visibility)));
1734 items.push_back (MenuElem (_("Toggle envelope active"), mem_fun(*this, &Editor::toggle_gain_envelope_active)));
1735 items.push_back (SeparatorElem());
1737 if (ar->scale_amplitude() != 1.0f) {
1738 items.push_back (MenuElem (_("DeNormalize"), mem_fun(*this, &Editor::denormalize_region)));
1740 items.push_back (MenuElem (_("Normalize"), mem_fun(*this, &Editor::normalize_region)));
1743 items.push_back (MenuElem (_("Reverse"), mem_fun(*this, &Editor::reverse_region)));
1744 items.push_back (SeparatorElem());
1747 /* range related stuff */
1749 items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_audio_region)));
1750 items.push_back (MenuElem (_("Set Range"), mem_fun (*this, &Editor::set_selection_from_audio_region)));
1751 items.push_back (SeparatorElem());
1755 Menu *nudge_menu = manage (new Menu());
1756 MenuList& nudge_items = nudge_menu->items();
1757 nudge_menu->set_name ("ArdourContextMenu");
1759 nudge_items.push_back (MenuElem (_("Nudge fwd"), (bind (mem_fun(*this, &Editor::nudge_forward), false))));
1760 nudge_items.push_back (MenuElem (_("Nudge bwd"), (bind (mem_fun(*this, &Editor::nudge_backward), false))));
1761 nudge_items.push_back (MenuElem (_("Nudge fwd by capture offset"), (mem_fun(*this, &Editor::nudge_forward_capture_offset))));
1762 nudge_items.push_back (MenuElem (_("Nudge bwd by capture offset"), (mem_fun(*this, &Editor::nudge_backward_capture_offset))));
1764 items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1765 items.push_back (SeparatorElem());
1767 Menu *trim_menu = manage (new Menu);
1768 MenuList& trim_items = trim_menu->items();
1769 trim_menu->set_name ("ArdourContextMenu");
1771 trim_items.push_back (MenuElem (_("Start to edit cursor"), mem_fun(*this, &Editor::trim_region_from_edit_cursor)));
1772 trim_items.push_back (MenuElem (_("Edit cursor to end"), mem_fun(*this, &Editor::trim_region_to_edit_cursor)));
1774 items.push_back (MenuElem (_("Trim"), *trim_menu));
1775 items.push_back (SeparatorElem());
1777 items.push_back (MenuElem (_("Split"), (mem_fun(*this, &Editor::split_region))));
1778 region_edit_menu_split_item = &items.back();
1780 items.push_back (MenuElem (_("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region))));
1781 region_edit_menu_split_multichannel_item = &items.back();
1783 items.push_back (MenuElem (_("Duplicate"), (bind (mem_fun(*this, &Editor::duplicate_dialog), true))));
1784 items.push_back (MenuElem (_("Fill Track"), (mem_fun(*this, &Editor::region_fill_track))));
1785 items.push_back (SeparatorElem());
1786 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::remove_clicked_region)));
1787 items.push_back (SeparatorElem());
1788 items.push_back (MenuElem (_("Destroy"), mem_fun(*this, &Editor::destroy_clicked_region)));
1790 /* OK, stick the region submenu at the top of the list, and then add
1794 /* we have to hack up the region name because "_" has a special
1795 meaning for menu titles.
1798 string::size_type pos = 0;
1799 string menu_item_name = region->name();
1801 while ((pos = menu_item_name.find ("_", pos)) != string::npos) {
1802 menu_item_name.replace (pos, 1, "__");
1806 edit_items.push_back (MenuElem (menu_item_name, *region_menu));
1807 edit_items.push_back (SeparatorElem());
1811 Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
1813 using namespace Menu_Helpers;
1814 Menu *selection_menu = manage (new Menu);
1815 MenuList& items = selection_menu->items();
1816 selection_menu->set_name ("ArdourContextMenu");
1818 items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
1819 items.push_back (MenuElem (_("Loop range"), mem_fun(*this, &Editor::set_route_loop_selection)));
1822 items.push_back (SeparatorElem());
1823 items.push_back (MenuElem (_("Analyze range"), mem_fun(*this, &Editor::analyze_range_selection)));
1826 items.push_back (SeparatorElem());
1827 items.push_back (MenuElem (_("Separate range to track"), mem_fun(*this, &Editor::separate_region_from_selection)));
1828 items.push_back (MenuElem (_("Separate range to region list"), mem_fun(*this, &Editor::new_region_from_selection)));
1830 items.push_back (SeparatorElem());
1831 items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
1832 items.push_back (SeparatorElem());
1833 items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1834 items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1835 items.push_back (SeparatorElem());
1836 items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
1837 items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
1838 items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
1839 items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::name_selection)));
1840 items.push_back (SeparatorElem());
1841 items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
1842 items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
1844 edit_items.push_back (MenuElem (_("Range"), *selection_menu));
1845 edit_items.push_back (SeparatorElem());
1849 Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
1851 using namespace Menu_Helpers;
1855 Menu *play_menu = manage (new Menu);
1856 MenuList& play_items = play_menu->items();
1857 play_menu->set_name ("ArdourContextMenu");
1859 play_items.push_back (MenuElem (_("Play from edit cursor")));
1860 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1861 play_items.push_back (MenuElem (_("Play region"), mem_fun(*this, &Editor::play_selected_region)));
1862 play_items.push_back (SeparatorElem());
1863 play_items.push_back (MenuElem (_("Loop Region"), mem_fun(*this, &Editor::loop_selected_region)));
1865 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1869 Menu *select_menu = manage (new Menu);
1870 MenuList& select_items = select_menu->items();
1871 select_menu->set_name ("ArdourContextMenu");
1873 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1874 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1875 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1876 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1877 select_items.push_back (SeparatorElem());
1878 select_items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
1879 select_items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
1880 select_items.push_back (SeparatorElem());
1881 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1882 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1883 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1884 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1885 select_items.push_back (MenuElem (_("Select all between cursors"), bind (mem_fun(*this, &Editor::select_all_selectables_between_cursors), playhead_cursor, edit_cursor)));
1886 select_items.push_back (SeparatorElem());
1888 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1892 Menu *cutnpaste_menu = manage (new Menu);
1893 MenuList& cutnpaste_items = cutnpaste_menu->items();
1894 cutnpaste_menu->set_name ("ArdourContextMenu");
1896 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1897 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1898 cutnpaste_items.push_back (MenuElem (_("Paste at edit cursor"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1899 cutnpaste_items.push_back (MenuElem (_("Paste at mouse"), mem_fun(*this, &Editor::mouse_paste)));
1901 cutnpaste_items.push_back (SeparatorElem());
1903 cutnpaste_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
1904 cutnpaste_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
1906 cutnpaste_items.push_back (SeparatorElem());
1908 cutnpaste_items.push_back (MenuElem (_("Insert chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f)));
1910 edit_items.push_back (MenuElem (_("Edit"), *cutnpaste_menu));
1912 /* Adding new material */
1914 edit_items.push_back (SeparatorElem());
1915 edit_items.push_back (MenuElem (_("Insert Selected Region"), bind (mem_fun(*this, &Editor::insert_region_list_selection), 1.0f)));
1916 edit_items.push_back (MenuElem (_("Insert Existing Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)));
1920 Menu *nudge_menu = manage (new Menu());
1921 MenuList& nudge_items = nudge_menu->items();
1922 nudge_menu->set_name ("ArdourContextMenu");
1924 edit_items.push_back (SeparatorElem());
1925 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1926 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1927 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1928 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1930 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1934 Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
1936 using namespace Menu_Helpers;
1940 Menu *play_menu = manage (new Menu);
1941 MenuList& play_items = play_menu->items();
1942 play_menu->set_name ("ArdourContextMenu");
1944 play_items.push_back (MenuElem (_("Play from edit cursor")));
1945 play_items.push_back (MenuElem (_("Play from start"), mem_fun(*this, &Editor::play_from_start)));
1946 edit_items.push_back (MenuElem (_("Play"), *play_menu));
1950 Menu *select_menu = manage (new Menu);
1951 MenuList& select_items = select_menu->items();
1952 select_menu->set_name ("ArdourContextMenu");
1954 select_items.push_back (MenuElem (_("Select All in track"), bind (mem_fun(*this, &Editor::select_all_in_track), Selection::Set)));
1955 select_items.push_back (MenuElem (_("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set)));
1956 select_items.push_back (MenuElem (_("Invert selection in track"), mem_fun(*this, &Editor::invert_selection_in_track)));
1957 select_items.push_back (MenuElem (_("Invert selection"), mem_fun(*this, &Editor::invert_selection)));
1958 select_items.push_back (SeparatorElem());
1959 select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
1960 select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
1961 select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
1962 select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
1964 edit_items.push_back (MenuElem (_("Select"), *select_menu));
1968 Menu *cutnpaste_menu = manage (new Menu);
1969 MenuList& cutnpaste_items = cutnpaste_menu->items();
1970 cutnpaste_menu->set_name ("ArdourContextMenu");
1972 cutnpaste_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
1973 cutnpaste_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
1974 cutnpaste_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
1976 Menu *nudge_menu = manage (new Menu());
1977 MenuList& nudge_items = nudge_menu->items();
1978 nudge_menu->set_name ("ArdourContextMenu");
1980 edit_items.push_back (SeparatorElem());
1981 nudge_items.push_back (MenuElem (_("Nudge entire track fwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, true))));
1982 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor fwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, true))));
1983 nudge_items.push_back (MenuElem (_("Nudge entire track bwd"), (bind (mem_fun(*this, &Editor::nudge_track), false, false))));
1984 nudge_items.push_back (MenuElem (_("Nudge track after edit cursor bwd"), (bind (mem_fun(*this, &Editor::nudge_track), true, false))));
1986 edit_items.push_back (MenuElem (_("Nudge"), *nudge_menu));
1989 /* CURSOR SETTING AND MARKS AND STUFF */
1992 Editor::set_snap_to (SnapType st)
1995 vector<string> txt = internationalize (snap_type_strings);
1996 snap_type_selector.set_active_text (txt[(int)st]);
2000 switch (snap_type) {
2001 case SnapToAThirtysecondBeat:
2002 case SnapToASixteenthBeat:
2003 case SnapToAEighthBeat:
2004 case SnapToAQuarterBeat:
2005 case SnapToAThirdBeat:
2006 update_tempo_based_rulers ();
2014 Editor::set_snap_mode (SnapMode mode)
2017 vector<string> txt = internationalize (snap_mode_strings);
2018 snap_mode_selector.set_active_text (txt[(int)mode]);
2024 Editor::set_state (const XMLNode& node)
2026 const XMLProperty* prop;
2028 int x, y, xoff, yoff;
2031 if ((prop = node.property ("id")) != 0) {
2032 _id = prop->value ();
2035 if ((geometry = find_named_node (node, "geometry")) == 0) {
2037 g.base_width = default_width;
2038 g.base_height = default_height;
2046 g.base_width = atoi(geometry->property("x_size")->value());
2047 g.base_height = atoi(geometry->property("y_size")->value());
2048 x = atoi(geometry->property("x_pos")->value());
2049 y = atoi(geometry->property("y_pos")->value());
2050 xoff = atoi(geometry->property("x_off")->value());
2051 yoff = atoi(geometry->property("y_off")->value());
2054 set_default_size (g.base_width, g.base_height);
2057 if ((prop = node.property ("zoom-focus"))) {
2058 set_zoom_focus ((ZoomFocus) atoi (prop->value()));
2061 if ((prop = node.property ("zoom"))) {
2062 set_frames_per_unit (PBD::atof (prop->value()));
2065 if ((prop = node.property ("snap-to"))) {
2066 set_snap_to ((SnapType) atoi (prop->value()));
2069 if ((prop = node.property ("snap-mode"))) {
2070 set_snap_mode ((SnapMode) atoi (prop->value()));
2073 if ((prop = node.property ("mouse-mode"))) {
2074 MouseMode m = str2mousemode(prop->value());
2075 mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
2076 set_mouse_mode (m, true);
2078 mouse_mode = MouseGain; /* lie, to force the mode switch */
2079 set_mouse_mode (MouseObject, true);
2082 if ((prop = node.property ("show-waveforms"))) {
2083 bool yn = (prop->value() == "yes");
2084 _show_waveforms = !yn;
2085 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
2087 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2088 /* do it twice to force the change */
2089 tact->set_active (!yn);
2090 tact->set_active (yn);
2094 if ((prop = node.property ("show-waveforms-recording"))) {
2095 bool yn = (prop->value() == "yes");
2096 _show_waveforms_recording = !yn;
2097 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
2099 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2100 /* do it twice to force the change */
2101 tact->set_active (!yn);
2102 tact->set_active (yn);
2106 if ((prop = node.property ("show-measures"))) {
2107 bool yn = (prop->value() == "yes");
2108 _show_measures = !yn;
2109 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
2111 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2112 /* do it twice to force the change */
2113 tact->set_active (!yn);
2114 tact->set_active (yn);
2118 if ((prop = node.property ("follow-playhead"))) {
2119 bool yn = (prop->value() == "yes");
2120 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
2122 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
2123 /* do it twice to force the change */
2124 tact->set_active (!yn);
2125 tact->set_active (yn);
2130 if ((prop = node.property ("region-list-sort-type"))) {
2131 region_list_sort_type = (Editing::RegionListSortType) -1; // force change
2132 reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
2135 if ((prop = node.property ("xfades-visible"))) {
2136 bool yn = (prop->value() == "yes");
2137 _xfade_visibility = !yn;
2138 // set_xfade_visibility (yn);
2141 if ((prop = node.property ("show-editor-mixer"))) {
2143 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2145 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2146 bool yn = (prop->value() == X_("yes"));
2148 /* do it twice to force the change */
2150 tact->set_active (!yn);
2151 tact->set_active (yn);
2160 Editor::get_state ()
2162 XMLNode* node = new XMLNode ("Editor");
2165 _id.print (buf, sizeof (buf));
2166 node->add_property ("id", buf);
2168 if (is_realized()) {
2169 Glib::RefPtr<Gdk::Window> win = get_window();
2171 int x, y, xoff, yoff, width, height;
2172 win->get_root_origin(x, y);
2173 win->get_position(xoff, yoff);
2174 win->get_size(width, height);
2176 XMLNode* geometry = new XMLNode ("geometry");
2178 snprintf(buf, sizeof(buf), "%d", width);
2179 geometry->add_property("x_size", string(buf));
2180 snprintf(buf, sizeof(buf), "%d", height);
2181 geometry->add_property("y_size", string(buf));
2182 snprintf(buf, sizeof(buf), "%d", x);
2183 geometry->add_property("x_pos", string(buf));
2184 snprintf(buf, sizeof(buf), "%d", y);
2185 geometry->add_property("y_pos", string(buf));
2186 snprintf(buf, sizeof(buf), "%d", xoff);
2187 geometry->add_property("x_off", string(buf));
2188 snprintf(buf, sizeof(buf), "%d", yoff);
2189 geometry->add_property("y_off", string(buf));
2190 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj()));
2191 geometry->add_property("edit_pane_pos", string(buf));
2193 node->add_child_nocopy (*geometry);
2196 snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
2197 node->add_property ("zoom-focus", buf);
2198 snprintf (buf, sizeof(buf), "%f", frames_per_unit);
2199 node->add_property ("zoom", buf);
2200 snprintf (buf, sizeof(buf), "%d", (int) snap_type);
2201 node->add_property ("snap-to", buf);
2202 snprintf (buf, sizeof(buf), "%d", (int) snap_mode);
2203 node->add_property ("snap-mode", buf);
2205 node->add_property ("show-waveforms", _show_waveforms ? "yes" : "no");
2206 node->add_property ("show-waveforms-recording", _show_waveforms_recording ? "yes" : "no");
2207 node->add_property ("show-measures", _show_measures ? "yes" : "no");
2208 node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
2209 node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
2210 node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
2211 node->add_property ("mouse-mode", enum2str(mouse_mode));
2213 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
2215 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2216 node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
2225 Editor::trackview_by_y_position (double y)
2227 TrackViewList::iterator iter;
2230 for (iter = track_views.begin(); iter != track_views.end(); ++iter) {
2238 if (tv->y_position <= y && y < ((tv->y_position + tv->height + track_spacing))) {
2247 Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark)
2249 Location* before = 0;
2250 Location* after = 0;
2256 const nframes_t one_second = session->frame_rate();
2257 const nframes_t one_minute = session->frame_rate() * 60;
2259 nframes_t presnap = start;
2261 switch (snap_type) {
2267 start = (nframes_t) ceil ((double) start / (one_second / 75)) * (one_second / 75);
2269 start = (nframes_t) floor ((double) start / (one_second / 75)) * (one_second / 75);
2272 case SnapToSMPTEFrame:
2274 start = (nframes_t) (ceil ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2276 start = (nframes_t) (floor ((double) start / session->frames_per_smpte_frame()) * session->frames_per_smpte_frame());
2280 case SnapToSMPTESeconds:
2281 if (session->smpte_offset_negative())
2283 start += session->smpte_offset ();
2285 start -= session->smpte_offset ();
2287 if (direction > 0) {
2288 start = (nframes_t) ceil ((double) start / one_second) * one_second;
2290 start = (nframes_t) floor ((double) start / one_second) * one_second;
2293 if (session->smpte_offset_negative())
2295 start -= session->smpte_offset ();
2297 start += session->smpte_offset ();
2301 case SnapToSMPTEMinutes:
2302 if (session->smpte_offset_negative())
2304 start += session->smpte_offset ();
2306 start -= session->smpte_offset ();
2309 start = (nframes_t) ceil ((double) start / one_minute) * one_minute;
2311 start = (nframes_t) floor ((double) start / one_minute) * one_minute;
2313 if (session->smpte_offset_negative())
2315 start -= session->smpte_offset ();
2317 start += session->smpte_offset ();
2323 start = (nframes_t) ceil ((double) start / one_second) * one_second;
2325 start = (nframes_t) floor ((double) start / one_second) * one_second;
2331 start = (nframes_t) ceil ((double) start / one_minute) * one_minute;
2333 start = (nframes_t) floor ((double) start / one_minute) * one_minute;
2338 start = session->tempo_map().round_to_bar (start, direction);
2342 start = session->tempo_map().round_to_beat (start, direction);
2345 case SnapToAThirtysecondBeat:
2346 start = session->tempo_map().round_to_beat_subdivision (start, 32);
2349 case SnapToASixteenthBeat:
2350 start = session->tempo_map().round_to_beat_subdivision (start, 16);
2353 case SnapToAEighthBeat:
2354 start = session->tempo_map().round_to_beat_subdivision (start, 8);
2357 case SnapToAQuarterBeat:
2358 start = session->tempo_map().round_to_beat_subdivision (start, 4);
2361 case SnapToAThirdBeat:
2362 start = session->tempo_map().round_to_beat_subdivision (start, 3);
2365 case SnapToEditCursor:
2366 start = edit_cursor->current_frame;
2374 before = session->locations()->first_location_before (start);
2375 after = session->locations()->first_location_after (start);
2377 if (direction < 0) {
2379 start = before->start();
2383 } else if (direction > 0) {
2385 start = after->start();
2387 start = session->current_end_frame();
2392 /* find nearest of the two */
2393 if ((start - before->start()) < (after->start() - start)) {
2394 start = before->start();
2396 start = after->start();
2399 start = before->start();
2402 start = after->start();
2409 case SnapToRegionStart:
2410 case SnapToRegionEnd:
2411 case SnapToRegionSync:
2412 case SnapToRegionBoundary:
2413 if (!region_boundary_cache.empty()) {
2414 vector<nframes_t>::iterator i;
2416 if (direction > 0) {
2417 i = std::upper_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2419 i = std::lower_bound (region_boundary_cache.begin(), region_boundary_cache.end(), start);
2422 if (i != region_boundary_cache.end()) {
2425 start = region_boundary_cache.back();
2431 switch (snap_mode) {
2437 if (presnap > start) {
2438 if (presnap > (start + unit_to_frame(snap_threshold))) {
2442 } else if (presnap < start) {
2443 if (presnap < (start - unit_to_frame(snap_threshold))) {
2455 Editor::setup_toolbar ()
2459 const guint32 FUDGE = 18; // Combo's are stupid - they steal space from the entry for the button
2462 /* Mode Buttons (tool selection) */
2464 vector<ToggleButton *> mouse_mode_buttons;
2466 mouse_move_button.add (*(manage (new Image (get_xpm("tool_object.xpm")))));
2467 mouse_move_button.set_relief(Gtk::RELIEF_NONE);
2468 mouse_mode_buttons.push_back (&mouse_move_button);
2469 mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
2470 mouse_select_button.set_relief(Gtk::RELIEF_NONE);
2471 mouse_mode_buttons.push_back (&mouse_select_button);
2472 mouse_gain_button.add (*(manage (new Image (get_xpm("tool_gain.xpm")))));
2473 mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
2474 mouse_mode_buttons.push_back (&mouse_gain_button);
2475 mouse_zoom_button.add (*(manage (new Image (get_xpm("tool_zoom.xpm")))));
2476 mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
2477 mouse_mode_buttons.push_back (&mouse_zoom_button);
2478 mouse_timefx_button.add (*(manage (new Image (get_xpm("tool_stretch.xpm")))));
2479 mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
2480 mouse_mode_buttons.push_back (&mouse_timefx_button);
2481 mouse_audition_button.add (*(manage (new Image (get_xpm("tool_audition.xpm")))));
2482 mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
2483 mouse_mode_buttons.push_back (&mouse_audition_button);
2485 mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
2487 HBox* mode_box = manage(new HBox);
2488 mode_box->set_border_width (2);
2489 mode_box->set_spacing(4);
2490 mouse_mode_button_box.set_spacing(1);
2491 mouse_mode_button_box.pack_start(mouse_move_button, true, true);
2492 mouse_mode_button_box.pack_start(mouse_select_button, true, true);
2493 mouse_mode_button_box.pack_start(mouse_zoom_button, true, true);
2494 mouse_mode_button_box.pack_start(mouse_gain_button, true, true);
2495 mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
2496 mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
2497 mouse_mode_button_box.set_homogeneous(true);
2499 vector<string> edit_mode_strings;
2500 edit_mode_strings.push_back (edit_mode_to_string (Splice));
2501 edit_mode_strings.push_back (edit_mode_to_string (Slide));
2503 edit_mode_selector.set_name ("EditModeSelector");
2504 Gtkmm2ext::set_size_request_to_display_given_text (edit_mode_selector, longest (edit_mode_strings).c_str(), 2+FUDGE, 10);
2505 set_popdown_strings (edit_mode_selector, edit_mode_strings);
2506 edit_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_mode_selection_done));
2508 mode_box->pack_start(edit_mode_selector);
2509 mode_box->pack_start(mouse_mode_button_box);
2511 mouse_mode_tearoff = manage (new TearOff (*mode_box));
2512 mouse_mode_tearoff->set_name ("MouseModeBase");
2514 mouse_mode_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2515 &mouse_mode_tearoff->tearoff_window()));
2516 mouse_mode_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2517 &mouse_mode_tearoff->tearoff_window(), 1));
2518 mouse_mode_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2519 &mouse_mode_tearoff->tearoff_window()));
2520 mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2521 &mouse_mode_tearoff->tearoff_window(), 1));
2523 mouse_move_button.set_name ("MouseModeButton");
2524 mouse_select_button.set_name ("MouseModeButton");
2525 mouse_gain_button.set_name ("MouseModeButton");
2526 mouse_zoom_button.set_name ("MouseModeButton");
2527 mouse_timefx_button.set_name ("MouseModeButton");
2528 mouse_audition_button.set_name ("MouseModeButton");
2530 ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
2531 ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
2532 ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
2533 ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
2534 ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
2535 ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
2537 mouse_move_button.unset_flags (CAN_FOCUS);
2538 mouse_select_button.unset_flags (CAN_FOCUS);
2539 mouse_gain_button.unset_flags (CAN_FOCUS);
2540 mouse_zoom_button.unset_flags (CAN_FOCUS);
2541 mouse_timefx_button.unset_flags (CAN_FOCUS);
2542 mouse_audition_button.unset_flags (CAN_FOCUS);
2544 mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
2545 mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
2547 mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
2548 mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
2549 mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
2550 mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
2551 mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
2553 // mouse_move_button.set_active (true);
2558 zoom_box.set_spacing (1);
2559 zoom_box.set_border_width (2);
2561 zoom_in_button.set_name ("EditorTimeButton");
2562 zoom_in_button.add (*(manage (new Image (get_xpm("zoom_in.xpm")))));
2563 zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
2564 ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
2566 zoom_out_button.set_name ("EditorTimeButton");
2567 zoom_out_button.add (*(manage (new Image (get_xpm("zoom_out.xpm")))));
2568 zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
2569 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
2571 zoom_out_full_button.set_name ("EditorTimeButton");
2572 zoom_out_full_button.add (*(manage (new Image (get_xpm("zoom_full.xpm")))));
2573 zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
2574 ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
2576 zoom_box.pack_start (zoom_out_button, false, false);
2577 zoom_box.pack_start (zoom_in_button, false, false);
2578 zoom_box.pack_start (zoom_range_clock, false, false);
2579 zoom_box.pack_start (zoom_out_full_button, false, false);
2581 ARDOUR_UI::instance()->tooltips().set_tip (zoom_range_clock, _("Current Zoom Range\n(Width of visible area)"));
2583 zoom_focus_selector.set_name ("ZoomFocusSelector");
2584 Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Focus Center", 2+FUDGE, 0);
2585 set_popdown_strings (zoom_focus_selector, internationalize (zoom_focus_strings));
2586 zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
2588 zoom_box.pack_start (zoom_focus_selector, false, false);
2591 /* Edit Cursor / Snap */
2593 snap_box.set_spacing (1);
2594 snap_box.set_border_width (2);
2596 snap_type_selector.set_name ("SnapTypeSelector");
2597 Gtkmm2ext::set_size_request_to_display_given_text (snap_type_selector, "SMPTE Seconds", 2+FUDGE, 10);
2598 set_popdown_strings (snap_type_selector, internationalize (snap_type_strings));
2599 snap_type_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_type_selection_done));
2600 ARDOUR_UI::instance()->tooltips().set_tip (snap_type_selector, _("Unit to snap cursors and ranges to"));
2602 snap_mode_selector.set_name ("SnapModeSelector");
2603 Gtkmm2ext::set_size_request_to_display_given_text (snap_mode_selector, "Magnetic Snap", 2+FUDGE, 10);
2604 set_popdown_strings (snap_mode_selector, internationalize (snap_mode_strings));
2605 snap_mode_selector.signal_changed().connect (mem_fun(*this, &Editor::snap_mode_selection_done));
2607 snap_box.pack_start (edit_cursor_clock, false, false);
2608 snap_box.pack_start (snap_mode_selector, false, false);
2609 snap_box.pack_start (snap_type_selector, false, false);
2614 HBox *nudge_box = manage (new HBox);
2615 nudge_box->set_spacing(1);
2616 nudge_box->set_border_width (2);
2618 nudge_forward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_forward), false));
2619 nudge_backward_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::nudge_backward), false));
2621 nudge_box->pack_start (nudge_backward_button, false, false);
2622 nudge_box->pack_start (nudge_forward_button, false, false);
2623 nudge_box->pack_start (nudge_clock, false, false);
2626 /* Pack everything in... */
2628 HBox* hbox = new HBox;
2629 hbox->set_spacing(10);
2631 tools_tearoff = new TearOff (*hbox);
2632 tools_tearoff->set_name ("MouseModeBase");
2634 tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2635 &tools_tearoff->tearoff_window()));
2636 tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2637 &tools_tearoff->tearoff_window(), 0));
2638 tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
2639 &tools_tearoff->tearoff_window()));
2640 tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
2641 &tools_tearoff->tearoff_window(), 0));
2643 toolbar_hbox.set_spacing (10);
2644 toolbar_hbox.set_border_width (1);
2646 toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
2647 toolbar_hbox.pack_start (*tools_tearoff, false, false);
2650 hbox->pack_start (snap_box, false, false);
2651 hbox->pack_start (zoom_box, false, false);
2652 hbox->pack_start (*nudge_box, false, false);
2656 toolbar_base.set_name ("ToolBarBase");
2657 toolbar_base.add (toolbar_hbox);
2659 toolbar_frame.set_shadow_type (SHADOW_OUT);
2660 toolbar_frame.set_name ("BaseFrame");
2661 toolbar_frame.add (toolbar_base);
2665 Editor::convert_drop_to_paths (vector<ustring>& paths,
2666 const RefPtr<Gdk::DragContext>& context,
2669 const SelectionData& data,
2678 vector<ustring> uris = data.get_uris();
2682 /* This is seriously fucked up. Nautilus doesn't say that its URI lists
2683 are actually URI lists. So do it by hand.
2686 if (data.get_target() != "text/plain") {
2690 /* Parse the "uri-list" format that Nautilus provides,
2691 where each pathname is delimited by \r\n
2694 const char* p = data.get_text().c_str();
2701 while (g_ascii_isspace (*p))
2705 while (*q && (*q != '\n') && (*q != '\r'))
2711 while (q > p && g_ascii_isspace (*q))
2716 uris.push_back (ustring (p, q - p + 1));
2720 p = strchr (p, '\n');
2730 for (vector<ustring>::iterator i = uris.begin(); i != uris.end(); ++i) {
2731 if ((*i).substr (0,7) == "file://") {
2733 PBD::url_decode (p);
2734 paths.push_back (p.substr (7));
2742 Editor::new_tempo_section ()
2748 Editor::map_transport_state ()
2750 ENSURE_GUI_THREAD (mem_fun(*this, &Editor::map_transport_state));
2752 if (session->transport_stopped()) {
2753 have_pending_keyboard_selection = false;
2759 Editor::State::State ()
2761 selection = new Selection;
2764 Editor::State::~State ()
2770 Editor::get_memento () const
2772 State *state = new State;
2774 store_state (*state);
2775 return bind (mem_fun (*(const_cast<Editor*>(this)), &Editor::restore_state), state);
2779 Editor::store_state (State& state) const
2781 *state.selection = *selection;
2785 Editor::restore_state (State *state)
2787 if (*selection == *state->selection) {
2791 *selection = *state->selection;
2792 time_selection_changed ();
2793 region_selection_changed ();
2795 /* XXX other selection change handlers? */
2799 Editor::begin_reversible_command (string name)
2802 before = &get_state();
2803 session->begin_reversible_command (name);
2808 Editor::commit_reversible_command ()
2811 session->commit_reversible_command (new MementoCommand<Editor>(*this, before, &get_state()));
2816 Editor::set_selected_track_from_click (bool press, Selection::Operation op, bool with_undo, bool no_remove)
2818 bool commit = false;
2820 if (!clicked_trackview) {
2825 case Selection::Toggle:
2826 if (selection->selected (clicked_trackview)) {
2828 selection->remove (clicked_trackview);
2832 selection->add (clicked_trackview);
2837 case Selection::Set:
2838 if (selection->selected (clicked_trackview) && selection->tracks.size() == 1) {
2839 /* no commit necessary */
2842 selection->set (clicked_trackview);
2845 case Selection::Extend:
2846 /* not defined yet */
2854 Editor::set_selected_control_point_from_click (bool press, Selection::Operation op, bool with_undo, bool no_remove)
2856 if (!clicked_control_point) {
2860 /* select this point and any others that it represents */
2865 x1 = pixel_to_frame (clicked_control_point->get_x() - 10);
2866 x2 = pixel_to_frame (clicked_control_point->get_x() + 10);
2867 y1 = clicked_control_point->get_x() - 10;
2868 y2 = clicked_control_point->get_y() + 10;
2870 return select_all_within (x1, x2, y1, y2, op);
2874 Editor::get_relevant_audio_tracks (AudioTimeAxisView& base, set<AudioTimeAxisView*>& relevant_tracks)
2876 /* step one: get all selected tracks and all tracks in the relevant edit groups */
2878 for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) {
2880 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*ti);
2886 RouteGroup* group = atv->route()->edit_group();
2888 if (group && group->is_active()) {
2890 /* active group for this track, loop over all tracks and get every member of the group */
2892 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
2894 AudioTimeAxisView* tatv;
2896 if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) {
2898 if (tatv->route()->edit_group() == group) {
2899 relevant_tracks.insert (tatv);
2906 /* no active group, or no group */
2908 relevant_tracks.insert (&base);
2915 Editor::mapover_audio_tracks (slot<void,AudioTimeAxisView&,uint32_t> sl)
2917 set<AudioTimeAxisView*> relevant_tracks;
2919 if (!clicked_audio_trackview) {
2923 get_relevant_audio_tracks (*clicked_audio_trackview, relevant_tracks);
2925 uint32_t sz = relevant_tracks.size();
2927 for (set<AudioTimeAxisView*>::iterator ati = relevant_tracks.begin(); ati != relevant_tracks.end(); ++ati) {
2933 Editor::mapped_set_selected_regionview_from_click (RouteTimeAxisView& tv, uint32_t ignored,
2934 RegionView* basis, vector<RegionView*>* all_equivs)
2937 vector<boost::shared_ptr<Region> > results;
2939 boost::shared_ptr<Diskstream> ds;
2941 if ((ds = tv.get_diskstream()) == 0) {
2946 if (&tv == &basis->get_time_axis_view()) {
2947 /* looking in same track as the original */
2952 if ((pl = dynamic_cast<Playlist*>(ds->playlist())) != 0) {
2953 pl->get_equivalent_regions (basis->region(), results);
2956 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
2957 if ((marv = tv.view()->find_view (*ir)) != 0) {
2958 all_equivs->push_back (marv);
2964 Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, bool no_track_remove)
2966 vector<RegionView*> all_equivalent_regions;
2967 bool commit = false;
2969 if (!clicked_regionview || !clicked_audio_trackview) {
2973 if (op == Selection::Toggle || op == Selection::Set) {
2975 mapover_audio_tracks (bind (mem_fun (*this, &Editor::mapped_set_selected_regionview_from_click),
2976 clicked_regionview, &all_equivalent_regions));
2979 /* add clicked regionview since we skipped all other regions in the same track as the one it was in */
2981 all_equivalent_regions.push_back (clicked_regionview);
2984 case Selection::Toggle:
2986 if (clicked_regionview->get_selected()) {
2989 /* whatever was clicked was selected already; do nothing here but allow
2990 the button release to deselect it
2993 button_release_can_deselect = true;
2997 if (button_release_can_deselect) {
2999 /* just remove this one region, but only on a permitted button release */
3001 selection->remove (clicked_regionview);
3004 /* no more deselect action on button release till a new press
3005 finds an already selected object.
3008 button_release_can_deselect = false;
3015 /* add all the equivalent regions, but only on button press */
3017 if (!all_equivalent_regions.empty()) {
3021 for (vector<RegionView*>::iterator i = all_equivalent_regions.begin(); i != all_equivalent_regions.end(); ++i) {
3022 selection->add (*i);
3028 case Selection::Set:
3029 if (!clicked_regionview->get_selected()) {
3030 selection->set (all_equivalent_regions);
3033 /* no commit necessary: clicked on an already selected region */
3039 /* silly compiler */
3043 } else if (op == Selection::Extend) {
3045 list<Selectable*> results;
3046 nframes_t last_frame;
3047 nframes_t first_frame;
3049 /* 1. find the last selected regionview in the track that was clicked in */
3052 first_frame = max_frames;
3054 for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
3055 if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) {
3057 if ((*x)->region()->last_frame() > last_frame) {
3058 last_frame = (*x)->region()->last_frame();
3061 if ((*x)->region()->first_frame() < first_frame) {
3062 first_frame = (*x)->region()->first_frame();
3067 /* 2. figure out the boundaries for our search for new objects */
3069 switch (clicked_regionview->region()->coverage (first_frame, last_frame)) {
3071 cerr << "no overlap, first = " << first_frame << " last = " << last_frame << " region = "
3072 << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
3074 if (last_frame < clicked_regionview->region()->first_frame()) {
3075 first_frame = last_frame;
3076 last_frame = clicked_regionview->region()->last_frame();
3078 last_frame = first_frame;
3079 first_frame = clicked_regionview->region()->first_frame();
3083 case OverlapExternal:
3084 cerr << "external overlap, first = " << first_frame << " last = " << last_frame << " region = "
3085 << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
3087 if (last_frame < clicked_regionview->region()->first_frame()) {
3088 first_frame = last_frame;
3089 last_frame = clicked_regionview->region()->last_frame();
3091 last_frame = first_frame;
3092 first_frame = clicked_regionview->region()->first_frame();
3096 case OverlapInternal:
3097 cerr << "internal overlap, first = " << first_frame << " last = " << last_frame << " region = "
3098 << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
3100 if (last_frame < clicked_regionview->region()->first_frame()) {
3101 first_frame = last_frame;
3102 last_frame = clicked_regionview->region()->last_frame();
3104 last_frame = first_frame;
3105 first_frame = clicked_regionview->region()->first_frame();
3111 /* nothing to do except add clicked region to selection, since it
3112 overlaps with the existing selection in this track.
3117 /* 2. find all selectable objects (regionviews in this case) between that one and the end of the
3118 one that was clicked.
3121 set<AudioTimeAxisView*> relevant_tracks;
3123 get_relevant_audio_tracks (*clicked_audio_trackview, relevant_tracks);
3125 for (set<AudioTimeAxisView*>::iterator t = relevant_tracks.begin(); t != relevant_tracks.end(); ++t) {
3126 (*t)->get_selectables (first_frame, last_frame, -1.0, -1.0, results);
3129 /* 3. convert to a vector of audio regions */
3131 vector<RegionView*> regions;
3133 for (list<Selectable*>::iterator x = results.begin(); x != results.end(); ++x) {
3136 if ((arv = dynamic_cast<RegionView*>(*x)) != 0) {
3137 regions.push_back (arv);
3141 if (!regions.empty()) {
3142 selection->add (regions);
3152 Editor::set_selected_regionview_from_region_list (boost::shared_ptr<Region> region, Selection::Operation op)
3154 vector<RegionView*> all_equivalent_regions;
3156 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3158 RouteTimeAxisView* tatv;
3160 if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
3163 vector<boost::shared_ptr<Region> > results;
3165 boost::shared_ptr<Diskstream> ds;
3167 if ((ds = tatv->get_diskstream()) == 0) {
3172 if ((pl = dynamic_cast<Playlist*>(ds->playlist())) != 0) {
3173 pl->get_region_list_equivalent_regions (region, results);
3176 for (vector<boost::shared_ptr<Region> >::iterator ir = results.begin(); ir != results.end(); ++ir) {
3177 if ((marv = tatv->view()->find_view (*ir)) != 0) {
3178 all_equivalent_regions.push_back (marv);
3185 begin_reversible_command (_("set selected regions"));
3188 case Selection::Toggle:
3189 /* XXX this is not correct */
3190 selection->toggle (all_equivalent_regions);
3192 case Selection::Set:
3193 selection->set (all_equivalent_regions);
3195 case Selection::Extend:
3196 selection->add (all_equivalent_regions);
3200 commit_reversible_command () ;
3204 Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::shared_ptr<Region> r)
3207 boost::shared_ptr<AudioRegion> ar;
3209 if ((ar = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
3213 if ((rv = sv->find_view (ar)) == 0) {
3217 /* don't reset the selection if its something other than
3218 a single other region.
3221 if (selection->regions.size() > 1) {
3225 begin_reversible_command (_("set selected regions"));
3227 selection->set (rv);
3229 commit_reversible_command () ;
3235 Editor::set_edit_group_solo (Route& route, bool yn)
3237 RouteGroup *edit_group;
3239 if ((edit_group = route.edit_group()) != 0) {
3240 edit_group->apply (&Route::set_solo, yn, this);
3242 route.set_solo (yn, this);
3247 Editor::set_edit_group_mute (Route& route, bool yn)
3249 RouteGroup *edit_group = 0;
3251 if ((edit_group == route.edit_group()) != 0) {
3252 edit_group->apply (&Route::set_mute, yn, this);
3254 route.set_mute (yn, this);
3259 Editor::set_edit_menu (Menu& menu)
3262 edit_menu->signal_map_event().connect (mem_fun(*this, &Editor::edit_menu_map_handler));
3266 Editor::edit_menu_map_handler (GdkEventAny* ev)
3268 using namespace Menu_Helpers;
3269 MenuList& edit_items = edit_menu->items();
3272 /* Nuke all the old items */
3274 edit_items.clear ();
3280 if (session->undo_depth() == 0) {
3283 label = string_compose(_("Undo (%1)"), session->next_undo());
3286 edit_items.push_back (MenuElem (label, bind (mem_fun(*this, &Editor::undo), 1U)));
3288 if (session->undo_depth() == 0) {
3289 edit_items.back().set_sensitive (false);
3292 if (session->redo_depth() == 0) {
3295 label = string_compose(_("Redo (%1)"), session->next_redo());
3298 edit_items.push_back (MenuElem (label, bind (mem_fun(*this, &Editor::redo), 1U)));
3299 if (session->redo_depth() == 0) {
3300 edit_items.back().set_sensitive (false);
3303 vector<MenuItem*> mitems;
3305 edit_items.push_back (SeparatorElem());
3306 edit_items.push_back (MenuElem (_("Cut"), mem_fun(*this, &Editor::cut)));
3307 mitems.push_back (&edit_items.back());
3308 edit_items.push_back (MenuElem (_("Copy"), mem_fun(*this, &Editor::copy)));
3309 mitems.push_back (&edit_items.back());
3310 edit_items.push_back (MenuElem (_("Paste"), bind (mem_fun(*this, &Editor::paste), 1.0f)));
3311 mitems.push_back (&edit_items.back());
3312 edit_items.push_back (SeparatorElem());
3313 edit_items.push_back (MenuElem (_("Align"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint)));
3314 mitems.push_back (&edit_items.back());
3315 edit_items.push_back (MenuElem (_("Align Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint)));
3316 mitems.push_back (&edit_items.back());
3317 edit_items.push_back (SeparatorElem());
3319 if (selection->empty()) {
3320 for (vector<MenuItem*>::iterator i = mitems.begin(); i != mitems.end(); ++i) {
3321 (*i)->set_sensitive (false);
3325 Menu* import_menu = manage (new Menu());
3326 import_menu->set_name ("ArdourContextMenu");
3327 MenuList& import_items = import_menu->items();
3329 import_items.push_back (MenuElem (_("... as new track"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsTrack)));
3330 import_items.push_back (MenuElem (_("... as new region"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion)));
3332 edit_items.push_back (MenuElem (_("Import audio (copy)"), *import_menu));
3333 edit_items.push_back (SeparatorElem());
3335 edit_items.push_back (MenuElem (_("Remove last capture"), mem_fun(*this, &Editor::remove_last_capture)));
3337 if (!session->have_captured()) {
3338 edit_items.back().set_sensitive (false);
3345 Editor::duplicate_dialog (bool dup_region)
3348 if (clicked_regionview == 0) {
3352 if (selection->time.length() == 0) {
3357 ArdourDialog win ("duplicate dialog");
3359 Label label (_("Duplicate how many times?"));
3361 win.get_vbox()->pack_start (label);
3362 win.add_action_widget (entry, RESPONSE_ACCEPT);
3363 win.add_button (Stock::OK, RESPONSE_ACCEPT);
3364 win.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3366 win.set_position (WIN_POS_MOUSE);
3368 entry.set_text ("1");
3369 set_size_request_to_display_given_text (entry, X_("12345678"), 20, 15);
3370 entry.select_region (0, entry.get_text_length());
3371 entry.grab_focus ();
3374 switch (win.run ()) {
3375 case RESPONSE_ACCEPT:
3381 string text = entry.get_text();
3384 if (sscanf (text.c_str(), "%f", ×) == 1) {
3386 RegionSelection regions;
3387 regions.add (clicked_regionview);
3388 duplicate_some_regions (regions, times);
3390 duplicate_selection (times);
3396 Editor::show_verbose_canvas_cursor ()
3398 verbose_canvas_cursor->raise_to_top();
3399 verbose_canvas_cursor->show();
3400 verbose_cursor_visible = true;
3404 Editor::hide_verbose_canvas_cursor ()
3406 verbose_canvas_cursor->hide();
3407 verbose_cursor_visible = false;
3411 Editor::set_verbose_canvas_cursor (const string & txt, double x, double y)
3413 /* XXX get origin of canvas relative to root window,
3414 add x and y and check compared to gdk_screen_{width,height}
3416 verbose_canvas_cursor->property_text() = txt.c_str();
3417 verbose_canvas_cursor->property_x() = x;
3418 verbose_canvas_cursor->property_y() = y;
3422 Editor::set_verbose_canvas_cursor_text (const string & txt)
3424 verbose_canvas_cursor->property_text() = txt.c_str();
3428 Editor::edit_mode_selection_done ()
3434 string choice = edit_mode_selector.get_active_text();
3435 EditMode mode = Slide;
3437 if (choice == _("Splice Edit")) {
3439 } else if (choice == _("Slide Edit")) {
3443 Config->set_edit_mode (mode);
3447 Editor::snap_type_selection_done ()
3453 string choice = snap_type_selector.get_active_text();
3454 SnapType snaptype = SnapToFrame;
3456 if (choice == _("Beats/3")) {
3457 snaptype = SnapToAThirdBeat;
3458 } else if (choice == _("Beats/4")) {
3459 snaptype = SnapToAQuarterBeat;
3460 } else if (choice == _("Beats/8")) {
3461 snaptype = SnapToAEighthBeat;
3462 } else if (choice == _("Beats/16")) {
3463 snaptype = SnapToASixteenthBeat;
3464 } else if (choice == _("Beats/32")) {
3465 snaptype = SnapToAThirtysecondBeat;
3466 } else if (choice == _("Beats")) {
3467 snaptype = SnapToBeat;
3468 } else if (choice == _("Bars")) {
3469 snaptype = SnapToBar;
3470 } else if (choice == _("Marks")) {
3471 snaptype = SnapToMark;
3472 } else if (choice == _("Edit Cursor")) {
3473 snaptype = SnapToEditCursor;
3474 } else if (choice == _("Region starts")) {
3475 snaptype = SnapToRegionStart;
3476 } else if (choice == _("Region ends")) {
3477 snaptype = SnapToRegionEnd;
3478 } else if (choice == _("Region bounds")) {
3479 snaptype = SnapToRegionBoundary;
3480 } else if (choice == _("Region syncs")) {
3481 snaptype = SnapToRegionSync;
3482 } else if (choice == _("CD Frames")) {
3483 snaptype = SnapToCDFrame;
3484 } else if (choice == _("SMPTE Frames")) {
3485 snaptype = SnapToSMPTEFrame;
3486 } else if (choice == _("SMPTE Seconds")) {
3487 snaptype = SnapToSMPTESeconds;
3488 } else if (choice == _("SMPTE Minutes")) {
3489 snaptype = SnapToSMPTEMinutes;
3490 } else if (choice == _("Seconds")) {
3491 snaptype = SnapToSeconds;
3492 } else if (choice == _("Minutes")) {
3493 snaptype = SnapToMinutes;
3494 } else if (choice == _("None")) {
3495 snaptype = SnapToFrame;
3498 set_snap_to (snaptype);
3502 Editor::snap_mode_selection_done ()
3508 string choice = snap_mode_selector.get_active_text();
3509 SnapMode mode = SnapNormal;
3511 if (choice == _("Normal Snap")) {
3513 } else if (choice == _("Magnetic Snap")) {
3514 mode = SnapMagnetic;
3517 set_snap_mode (mode);
3521 Editor::zoom_focus_selection_done ()
3527 string choice = zoom_focus_selector.get_active_text();
3528 ZoomFocus focus_type = ZoomFocusLeft;
3530 if (choice == _("Focus Left")) {
3531 focus_type = ZoomFocusLeft;
3532 } else if (choice == _("Focus Right")) {
3533 focus_type = ZoomFocusRight;
3534 } else if (choice == _("Focus Center")) {
3535 focus_type = ZoomFocusCenter;
3536 } else if (choice == _("Focus Playhead")) {
3537 focus_type = ZoomFocusPlayhead;
3538 } else if (choice == _("Focus Edit Cursor")) {
3539 focus_type = ZoomFocusEdit;
3542 set_zoom_focus (focus_type);
3546 Editor::edit_controls_button_release (GdkEventButton* ev)
3548 if (Keyboard::is_context_menu_event (ev)) {
3549 ARDOUR_UI::instance()->add_route ();
3555 Editor::track_selection_changed ()
3557 switch (selection->tracks.size()){
3561 set_selected_mixer_strip (*(selection->tracks.front()));
3565 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3566 (*i)->set_selected (false);
3567 if (mouse_mode == MouseRange) {
3568 (*i)->hide_selection ();
3572 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3573 (*i)->set_selected (true);
3574 if (mouse_mode == MouseRange) {
3575 (*i)->show_selection (selection->time);
3581 Editor::time_selection_changed ()
3583 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3584 (*i)->hide_selection ();
3587 if (selection->tracks.empty()) {
3588 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3589 (*i)->show_selection (selection->time);
3592 for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
3593 (*i)->show_selection (selection->time);
3597 if (selection->time.empty()) {
3598 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
3600 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true);
3605 Editor::region_selection_changed ()
3607 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3608 (*i)->set_selected_regionviews (selection->regions);
3613 Editor::point_selection_changed ()
3615 for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
3616 (*i)->set_selected_points (selection->points);
3621 Editor::mouse_select_button_release (GdkEventButton* ev)
3623 /* this handles just right-clicks */
3625 if (ev->button != 3) {
3632 Editor::TrackViewList *
3633 Editor::get_valid_views (TimeAxisView* track, RouteGroup* group)
3636 TrackViewList::iterator i;
3638 v = new TrackViewList;
3640 if (track == 0 && group == 0) {
3644 for (i = track_views.begin(); i != track_views.end (); ++i) {
3648 } else if (track != 0 && group == 0 || (track != 0 && group != 0 && !group->is_active())) {
3650 /* just the view for this track
3653 v->push_back (track);
3657 /* views for all tracks in the edit group */
3659 for (i = track_views.begin(); i != track_views.end (); ++i) {
3661 if (group == 0 || (*i)->edit_group() == group) {
3671 Editor::set_zoom_focus (ZoomFocus f)
3673 vector<string> txt = internationalize (zoom_focus_strings);
3674 zoom_focus_selector.set_active_text (txt[(int)f]);
3676 if (zoom_focus != f) {
3679 ZoomFocusChanged (); /* EMIT_SIGNAL */
3686 Editor::ensure_float (Window& win)
3688 win.set_transient_for (*this);
3692 Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
3694 /* recover or initialize pane positions. do this here rather than earlier because
3695 we don't want the positions to change the child allocations, which they seem to do.
3701 XMLNode* node = ARDOUR_UI::instance()->editor_settings();
3703 static int32_t done;
3706 if ((geometry = find_named_node (*node, "geometry")) == 0) {
3707 width = default_width;
3708 height = default_height;
3710 width = atoi(geometry->property("x_size")->value());
3711 height = atoi(geometry->property("y_size")->value());
3714 if (which == static_cast<Paned*> (&edit_pane)) {
3720 if (!geometry || (prop = geometry->property ("edit_pane_pos")) == 0) {
3721 /* initial allocation is 90% to canvas, 10% to notebook */
3722 pos = (int) floor (alloc.get_width() * 0.90f);
3723 snprintf (buf, sizeof(buf), "%d", pos);
3725 pos = atoi (prop->value());
3728 if ((done = GTK_WIDGET(edit_pane.gobj())->allocation.width > pos)) {
3729 edit_pane.set_position (pos);
3730 pre_maximal_pane_position = pos;
3736 Editor::detach_tearoff (Box* b, Window* w)
3738 if (tools_tearoff->torn_off() &&
3739 mouse_mode_tearoff->torn_off()) {
3740 top_hbox.remove (toolbar_frame);
3745 Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
3747 if (toolbar_frame.get_parent() == 0) {
3748 top_hbox.pack_end (toolbar_frame);
3753 Editor::set_show_measures (bool yn)
3755 if (_show_measures != yn) {
3758 if ((_show_measures = yn) == true) {
3761 DisplayControlChanged (ShowMeasures);
3767 Editor::toggle_follow_playhead ()
3769 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
3771 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
3772 set_follow_playhead (tact->get_active());
3777 Editor::set_follow_playhead (bool yn)
3779 if (_follow_playhead != yn) {
3780 if ((_follow_playhead = yn) == true) {
3782 update_current_screen ();
3784 DisplayControlChanged (FollowPlayhead);
3790 Editor::toggle_xfade_active (Crossfade* xfade)
3792 xfade->set_active (!xfade->active());
3796 Editor::toggle_xfade_length (Crossfade* xfade)
3798 xfade->set_follow_overlap (!xfade->following_overlap());
3802 Editor::edit_xfade (Crossfade* xfade)
3804 CrossfadeEditor cew (*session, *xfade, xfade->fade_in().get_min_y(), 1.0);
3808 switch (cew.run ()) {
3809 case RESPONSE_ACCEPT:
3816 xfade->StateChanged (Change (~0));
3820 Editor::playlist_selector () const
3822 return *_playlist_selector;
3826 Editor::get_nudge_distance (nframes_t pos, nframes_t& next)
3830 ret = nudge_clock.current_duration (pos);
3831 next = ret + 1; /* XXXX fix me */
3837 Editor::end_location_changed (Location* location)
3839 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
3840 reset_scrolling_region ();
3844 Editor::playlist_deletion_dialog (Playlist* pl)
3846 ArdourDialog dialog ("playlist deletion dialog");
3847 Label label (string_compose (_("Playlist %1 is currently unused.\n"
3848 "If left alone, no audio files used by it will be cleaned.\n"
3849 "If deleted, audio files used by it alone by will cleaned."),
3852 dialog.set_position (WIN_POS_CENTER);
3853 dialog.get_vbox()->pack_start (label);
3855 dialog.add_button (_("Delete playlist"), RESPONSE_ACCEPT);
3856 dialog.add_button (_("Keep playlist"), RESPONSE_CANCEL);
3857 dialog.add_button (_("Cancel"), RESPONSE_CANCEL);
3859 switch (dialog.run ()) {
3860 case RESPONSE_ACCEPT:
3861 /* delete the playlist */
3865 case RESPONSE_REJECT:
3866 /* keep the playlist */
3878 Editor::audio_region_selection_covers (nframes_t where)
3880 for (RegionSelection::iterator a = selection->regions.begin(); a != selection->regions.end(); ++a) {
3881 if ((*a)->region()->covers (where)) {
3890 Editor::prepare_for_cleanup ()
3892 cut_buffer->clear_regions ();
3893 cut_buffer->clear_playlists ();
3895 selection->clear_regions ();
3896 selection->clear_playlists ();
3900 Editor::transport_loop_location()
3903 return session->locations()->auto_loop_location();
3910 Editor::transport_punch_location()
3913 return session->locations()->auto_punch_location();
3920 Editor::control_layout_scroll (GdkEventScroll* ev)
3922 switch (ev->direction) {
3924 scroll_tracks_up_line ();
3928 case GDK_SCROLL_DOWN:
3929 scroll_tracks_down_line ();
3933 /* no left/right handling yet */
3941 Editor::snapshot_display_selection_changed ()
3943 if (snapshot_display.get_selection()->count_selected_rows() > 0) {
3945 TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
3947 Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
3949 if (snap_name.length() == 0) {
3953 if (session->snap_name() == snap_name) {
3957 ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
3962 Editor::snapshot_display_button_press (GdkEventButton* ev)
3968 Editor::redisplay_snapshots ()
3974 vector<string*>* states;
3976 if ((states = session->possible_states()) == 0) {
3980 snapshot_display_model->clear ();
3982 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
3983 string statename = *(*i);
3984 TreeModel::Row row = *(snapshot_display_model->append());
3985 row[snapshot_display_columns.visible_name] = statename;
3986 row[snapshot_display_columns.real_name] = statename;
3993 Editor::session_state_saved (string snap_name)
3995 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
3996 redisplay_snapshots ();
4000 Editor::maximise_editing_space ()
4002 mouse_mode_tearoff->set_visible (false);
4003 tools_tearoff->set_visible (false);
4005 pre_maximal_pane_position = edit_pane.get_position();
4006 edit_pane.set_position (edit_pane.get_width());
4012 Editor::restore_editing_space ()
4014 mouse_mode_tearoff->set_visible (true);
4015 tools_tearoff->set_visible (true);
4017 edit_pane.set_position (pre_maximal_pane_position);
4023 Editor::new_playlists ()
4025 begin_reversible_command (_("new playlists"));
4026 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_new_playlist));
4027 commit_reversible_command ();
4031 Editor::copy_playlists ()
4033 begin_reversible_command (_("copy playlists"));
4034 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_use_copy_playlist));
4035 commit_reversible_command ();
4039 Editor::clear_playlists ()
4041 begin_reversible_command (_("clear playlists"));
4042 mapover_audio_tracks (mem_fun (*this, &Editor::mapped_clear_playlist));
4043 commit_reversible_command ();
4047 Editor::mapped_use_new_playlist (AudioTimeAxisView& atv, uint32_t sz)
4049 atv.use_new_playlist (sz > 1 ? false : true);
4053 Editor::mapped_use_copy_playlist (AudioTimeAxisView& atv, uint32_t sz)
4055 atv.use_copy_playlist (sz > 1 ? false : true);
4059 Editor::mapped_clear_playlist (AudioTimeAxisView& atv, uint32_t sz)
4061 atv.clear_playlist ();
4065 Editor::on_key_press_event (GdkEventKey* ev)
4067 return key_press_focus_accelerator_handler (*this, ev);