- bool have_audio = false;
- bool have_midi = false;
- bool have_locked = false;
- bool have_unlocked = false;
- bool have_position_lock_style_audio = false;
- bool have_position_lock_style_music = false;
- bool have_muted = false;
- bool have_unmuted = false;
- bool have_opaque = false;
- bool have_non_opaque = false;
- bool have_not_at_natural_position = false;
- bool have_envelope_visible = false;
- bool have_envelope_invisible = false;
- bool have_envelope_active = false;
- bool have_envelope_inactive = false;
- bool have_non_unity_scale_amplitude = false;
-
- for (list<boost::shared_ptr<Region> >::const_iterator i = regions.begin(); i != regions.end(); ++i) {
- boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (*i);
- if (ar) {
- have_audio = true;
- }
- if (boost::dynamic_pointer_cast<MidiRegion> (*i)) {
- have_midi = true;
- }
-
- if ((*i)->locked()) {
- have_locked = true;
- } else {
- have_unlocked = true;
- }
-
- if ((*i)->position_lock_style() == MusicTime) {
- have_position_lock_style_music = true;
- } else {
- have_position_lock_style_audio = true;
- }
-
- if ((*i)->muted()) {
- have_muted = true;
- } else {
- have_unmuted = true;
- }
-
- if ((*i)->opaque()) {
- have_opaque = true;
- } else {
- have_non_opaque = true;
- }
-
- if (!(*i)->at_natural_position()) {
- have_not_at_natural_position = true;
- }
-
- if (ar) {
- /* its a bit unfortunate that "envelope visible" is a view-only
- property. we have to find the regionview to able to check
- its current setting.
- */
-
- RegionView* rv = sv->find_view (ar);
- have_envelope_invisible = true;
-
- if (rv) {
- AudioRegionView* arv = dynamic_cast<AudioRegionView*> (rv);
- if (arv && arv->envelope_visible()) {
- have_envelope_visible = true;
- }
- }
-
- if (ar->envelope_active()) {
- have_envelope_active = true;
- } else {
- have_envelope_inactive = true;
- }
-
- if (ar->scale_amplitude() != 1) {
- have_non_unity_scale_amplitude = true;
- }
- }
- }
-
- if (regions.size() == 1) {
-
- /* when this particular menu pops up, make the relevant region
- become selected.
- */
-
- region_menu->signal_map_event().connect (
- sigc::bind (sigc::mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr<Region> (regions.front()))
- );
-
- items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &Editor::rename_region)));
-
- if (have_midi) {
- items.push_back (MenuElem (_("List Editor..."), sigc::mem_fun(*this, &Editor::show_midi_list_editor)));
- }
-
- items.push_back (MenuElem (_("Region Properties..."), sigc::mem_fun(*this, &Editor::edit_region)));
- }
-
- items.push_back (MenuElem (_("Raise to Top Layer"), sigc::mem_fun(*this, &Editor::raise_region_to_top)));
- items.push_back (MenuElem (_("Lower to Bottom Layer"), sigc::mem_fun (*this, &Editor::lower_region_to_bottom)));
- items.push_back (SeparatorElem());
- items.push_back (MenuElem (_("Define Sync Point"), sigc::mem_fun(*this, &Editor::set_region_sync_from_edit_point)));
- if (_edit_point == EditAtMouse) {
- items.back ().set_sensitive (false);
- }
- items.push_back (MenuElem (_("Remove Sync Point"), sigc::mem_fun(*this, &Editor::remove_region_sync)));
- items.push_back (SeparatorElem());
-
- items.push_back (MenuElem (_("Audition"), sigc::mem_fun(*this, &Editor::play_selected_region)));
- items.push_back (MenuElem (_("Export..."), sigc::mem_fun(*this, &Editor::export_region)));
- items.push_back (MenuElem (_("Bounce"), sigc::mem_fun(*this, &Editor::bounce_region_selection)));
-
- if (have_audio) {
- items.push_back (MenuElem (_("Spectral Analysis..."), sigc::mem_fun(*this, &Editor::analyze_region_selection)));
- }
-
- items.push_back (SeparatorElem());
-
- items.push_back (CheckMenuElem (_("Lock")));
- CheckMenuItem* region_lock_item = static_cast<CheckMenuItem*>(&items.back());
- if (have_locked && !have_unlocked) {
- region_lock_item->set_active();
- } else if (have_locked && have_unlocked) {
- region_lock_item->set_inconsistent ();
- }
- region_lock_item->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_region_lock));
-
- items.push_back (CheckMenuElem (_("Glue to Bars and Beats")));
- CheckMenuItem* bbt_glue_item = static_cast<CheckMenuItem*>(&items.back());
-
- if (have_position_lock_style_music && !have_position_lock_style_audio) {
- bbt_glue_item->set_active ();
- } else if (have_position_lock_style_music && have_position_lock_style_audio) {
- bbt_glue_item->set_inconsistent ();
- }
-
- bbt_glue_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_region_lock_style));
-
- items.push_back (CheckMenuElem (_("Mute")));
- CheckMenuItem* region_mute_item = static_cast<CheckMenuItem*>(&items.back());
-
- if (have_muted && !have_unmuted) {
- region_mute_item->set_active();
- } else if (have_muted && have_unmuted) {
- region_mute_item->set_inconsistent ();
- }
-
- region_mute_item->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_region_mute));
-
- items.push_back (MenuElem (_("Transpose..."), mem_fun(*this, &Editor::pitch_shift_regions)));
-
- if (!Profile->get_sae()) {
- items.push_back (CheckMenuElem (_("Opaque")));
- CheckMenuItem* region_opaque_item = static_cast<CheckMenuItem*>(&items.back());
- if (have_opaque && !have_non_opaque) {
- region_opaque_item->set_active();
- } else if (have_opaque && have_non_opaque) {
- region_opaque_item->set_inconsistent ();
- }
- region_opaque_item->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_region_opaque));
- }
-
- items.push_back (CheckMenuElem (_("Original Position"), sigc::mem_fun(*this, &Editor::naturalize)));
- if (!have_not_at_natural_position) {
- items.back().set_sensitive (false);
- }
-
- items.push_back (SeparatorElem());
-
- if (have_audio) {
-
- if (!Profile->get_sae()) {
- items.push_back (MenuElem (_("Reset Envelope"), sigc::mem_fun(*this, &Editor::reset_region_gain_envelopes)));
-
- items.push_back (CheckMenuElem (_("Envelope Visible")));
- CheckMenuItem* region_envelope_visible_item = static_cast<CheckMenuItem*> (&items.back());
- if (have_envelope_visible && !have_envelope_invisible) {
- region_envelope_visible_item->set_active ();
- } else if (have_envelope_visible && have_envelope_invisible) {
- region_envelope_visible_item->set_inconsistent ();
- }
- region_envelope_visible_item->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_gain_envelope_visibility));
-
- items.push_back (CheckMenuElem (_("Envelope Active")));
- CheckMenuItem* region_envelope_active_item = static_cast<CheckMenuItem*> (&items.back());
-
- if (have_envelope_active && !have_envelope_inactive) {
- region_envelope_active_item->set_active ();
- } else if (have_envelope_active && have_envelope_inactive) {
- region_envelope_active_item->set_inconsistent ();
- }
-
- region_envelope_active_item->signal_activate().connect (sigc::mem_fun(*this, &Editor::toggle_gain_envelope_active));
- items.push_back (SeparatorElem());
- }
-
- items.push_back (MenuElem (_("Normalize..."), sigc::mem_fun(*this, &Editor::normalize_region)));
- if (have_non_unity_scale_amplitude) {
- items.push_back (MenuElem (_("Reset Gain"), sigc::mem_fun(*this, &Editor::reset_region_scale_amplitude)));
- }
-
- } else if (have_midi) {
- items.push_back (MenuElem (_("Quantize"), sigc::mem_fun(*this, &Editor::quantize_region)));
- items.push_back (MenuElem (_("Fork"), sigc::mem_fun(*this, &Editor::fork_region)));
- items.push_back (SeparatorElem());
- }
-
- items.push_back (MenuElem (_("Strip Silence..."), sigc::mem_fun (*this, &Editor::strip_region_silence)));
- items.push_back (MenuElem (_("Reverse"), sigc::mem_fun(*this, &Editor::reverse_region)));
- items.push_back (SeparatorElem());
-
- /* range related stuff */
-
- items.push_back (MenuElem (_("Add Single Range"), sigc::mem_fun (*this, &Editor::add_location_from_audio_region)));
- items.push_back (MenuElem (_("Add Range Markers"), sigc::mem_fun (*this, &Editor::add_locations_from_audio_region)));
- if (selection->regions.size() < 2) {
- items.back().set_sensitive (false);
- }
-
- items.push_back (MenuElem (_("Set Range Selection"), sigc::mem_fun (*this, &Editor::set_selection_from_region)));
- items.push_back (SeparatorElem());
-
- /* Nudge region */
-
- Menu *nudge_menu = manage (new Menu());
- MenuList& nudge_items = nudge_menu->items();
- nudge_menu->set_name ("ArdourContextMenu");
-
- nudge_items.push_back (MenuElem (_("Nudge Forward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_forward), false, false))));
- nudge_items.push_back (MenuElem (_("Nudge Backward"), (sigc::bind (sigc::mem_fun(*this, &Editor::nudge_backward), false, false))));
- nudge_items.push_back (MenuElem (_("Nudge Forward by Capture Offset"), (sigc::mem_fun(*this, &Editor::nudge_forward_capture_offset))));
- nudge_items.push_back (MenuElem (_("Nudge Backward by Capture Offset"), (sigc::mem_fun(*this, &Editor::nudge_backward_capture_offset))));
-
- items.push_back (MenuElem (_("Nudge"), *nudge_menu));
- items.push_back (SeparatorElem());
-
- Menu *trim_menu = manage (new Menu);
- MenuList& trim_items = trim_menu->items();
- trim_menu->set_name ("ArdourContextMenu");
-
- trim_items.push_back (MenuElem (_("Start to Edit Point"), sigc::mem_fun(*this, &Editor::trim_region_from_edit_point)));
- foo_item = &trim_items.back();
- if (_edit_point == EditAtMouse) {
- foo_item->set_sensitive (false);
- }
- trim_items.push_back (MenuElem (_("Edit Point to End"), sigc::mem_fun(*this, &Editor::trim_region_to_edit_point)));
- foo_item = &trim_items.back();
- if (_edit_point == EditAtMouse) {
- foo_item->set_sensitive (false);
- }
- trim_items.push_back (MenuElem (_("Trim to Loop"), sigc::mem_fun(*this, &Editor::trim_region_to_loop)));
- trim_items.push_back (MenuElem (_("Trim to Punch"), sigc::mem_fun(*this, &Editor::trim_region_to_punch)));
-
- items.push_back (MenuElem (_("Trim"), *trim_menu));
- items.push_back (SeparatorElem());
-
- items.push_back (MenuElem (_("Split"), (sigc::mem_fun(*this, &Editor::split))));
- region_edit_menu_split_item = &items.back();
-
- if (_edit_point == EditAtMouse) {
- region_edit_menu_split_item->set_sensitive (false);
- }
-
- if (have_audio) {
- items.push_back (MenuElem (_("Make Mono Regions"), (sigc::mem_fun(*this, &Editor::split_multichannel_region))));
- region_edit_menu_split_multichannel_item = &items.back();
- }
-
- items.push_back (MenuElem (_("Duplicate"), (sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_dialog), false))));
- items.push_back (MenuElem (_("Multi-Duplicate..."), (sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_dialog), true))));
- items.push_back (MenuElem (_("Fill Track"), (sigc::mem_fun(*this, &Editor::region_fill_track))));
- items.push_back (SeparatorElem());
- items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::remove_selected_regions)));
-