various changes (improvements, hopefully) to range mode menus and related matters

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2317 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-08-16 17:12:30 +00:00
parent eb8fa64dff
commit f433b4e735
5 changed files with 119 additions and 74 deletions

View file

@ -1387,7 +1387,7 @@ Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type,
return; return;
} }
if (clicked_audio_trackview && clicked_audio_trackview->audio_track()) { if (item_type != SelectionItem && clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
/* Bounce to disk */ /* Bounce to disk */
@ -1554,7 +1554,8 @@ Editor::build_track_selection_context_menu (nframes_t ignored)
edit_items.clear (); edit_items.clear ();
add_selection_context_items (edit_items); add_selection_context_items (edit_items);
add_dstream_context_items (edit_items); // edit_items.push_back (SeparatorElem());
// add_dstream_context_items (edit_items);
return &track_selection_context_menu; return &track_selection_context_menu;
} }
@ -1789,15 +1790,12 @@ Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region>
} }
void void
Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items) Editor::add_selection_context_items (Menu_Helpers::MenuList& items)
{ {
using namespace Menu_Helpers; using namespace Menu_Helpers;
Menu *selection_menu = manage (new Menu);
MenuList& items = selection_menu->items();
selection_menu->set_name ("ArdourContextMenu");
items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection))); items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
items.push_back (MenuElem (_("Loop range"), mem_fun(*this, &Editor::set_route_loop_selection))); items.push_back (MenuElem (_("Loop range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
#ifdef FFT_ANALYSIS #ifdef FFT_ANALYSIS
items.push_back (SeparatorElem()); items.push_back (SeparatorElem());
@ -1805,15 +1803,22 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
#endif #endif
items.push_back (SeparatorElem()); items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Separate range to track"), mem_fun(*this, &Editor::separate_region_from_selection))); items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
items.push_back (MenuElem (_("Separate range to region list"), mem_fun(*this, &Editor::new_region_from_selection))); items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Convert to region in-place"), mem_fun(*this, &Editor::separate_region_from_selection)));
items.push_back (MenuElem (_("Convert to region in region list"), mem_fun(*this, &Editor::new_region_from_selection)));
items.push_back (SeparatorElem()); items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection))); items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Set loop from selection"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
items.push_back (MenuElem (_("Set punch from selection"), mem_fun(*this, &Editor::set_punch_from_selection)));
items.push_back (SeparatorElem()); items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection))); items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
items.push_back (MenuElem (_("Set range to loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
items.push_back (MenuElem (_("Set range to punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
items.push_back (SeparatorElem()); items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection))); items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection))); items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
@ -1822,9 +1827,6 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
items.push_back (SeparatorElem()); items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection))); items.push_back (MenuElem (_("Bounce range"), mem_fun(*this, &Editor::bounce_range_selection)));
items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection))); items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_selection)));
edit_items.push_back (MenuElem (_("Range"), *selection_menu));
edit_items.push_back (SeparatorElem());
} }
void void
@ -3830,3 +3832,59 @@ Editor::edit_cursor_position(bool sync)
return edit_cursor->current_frame; return edit_cursor->current_frame;
} }
void
Editor::set_loop_range (nframes_t start, nframes_t end, string cmd)
{
if (!session) return;
begin_reversible_command (cmd);
Location* tll;
if ((tll = transport_loop_location()) == 0) {
Location* loc = new Location (start, end, _("Loop"), Location::IsAutoLoop);
XMLNode &before = session->locations()->get_state();
session->locations()->add (loc, true);
session->set_auto_loop_location (loc);
XMLNode &after = session->locations()->get_state();
session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
}
else {
XMLNode &before = tll->get_state();
tll->set_hidden (false, this);
tll->set (start, end);
XMLNode &after = tll->get_state();
session->add_command (new MementoCommand<Location>(*tll, &before, &after));
}
commit_reversible_command ();
}
void
Editor::set_punch_range (nframes_t start, nframes_t end, string cmd)
{
if (!session) return;
begin_reversible_command (cmd);
Location* tpl;
if ((tpl = transport_punch_location()) == 0) {
Location* loc = new Location (start, end, _("Loop"), Location::IsAutoPunch);
XMLNode &before = session->locations()->get_state();
session->locations()->add (loc, true);
session->set_auto_loop_location (loc);
XMLNode &after = session->locations()->get_state();
session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
}
else {
XMLNode &before = tpl->get_state();
tpl->set_hidden (false, this);
tpl->set (start, end);
XMLNode &after = tpl->get_state();
session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
}
commit_reversible_command ();
}

View file

@ -1039,7 +1039,11 @@ class Editor : public PublicEditor
void add_location_from_audio_region (); void add_location_from_audio_region ();
void add_location_from_selection (); void add_location_from_selection ();
void set_route_loop_selection (); void set_loop_from_selection (bool play);
void set_punch_from_selection ();
void set_loop_range (nframes_t start, nframes_t end, std::string cmd);
void set_punch_range (nframes_t start, nframes_t end, std::string cmd);
void add_location_from_playhead_cursor (); void add_location_from_playhead_cursor ();

View file

@ -26,11 +26,13 @@
#include "region_view.h" #include "region_view.h"
#include "selection.h" #include "selection.h"
#include "i18n.h"
using namespace ARDOUR; using namespace ARDOUR;
using namespace PBD; using namespace PBD;
void void
Editor::set_route_loop_selection () Editor::set_loop_from_selection (bool play)
{ {
if (session == 0 || selection->time.empty()) { if (session == 0 || selection->time.empty()) {
return; return;
@ -38,18 +40,26 @@ Editor::set_route_loop_selection ()
nframes_t start = selection->time[clicked_selection].start; nframes_t start = selection->time[clicked_selection].start;
nframes_t end = selection->time[clicked_selection].end; nframes_t end = selection->time[clicked_selection].end;
set_loop_range (start, end, _("set loop range from selection"));
Location* loc = transport_loop_location(); if (play) {
if (loc) {
loc->set (start, end);
// enable looping, reposition and start rolling
session->request_play_loop (true); session->request_play_loop (true);
session->request_locate (loc->start(), true); session->request_locate (start, true);
}
}
void
Editor::set_punch_from_selection ()
{
if (session == 0 || selection->time.empty()) {
return;
} }
nframes_t start = selection->time[clicked_selection].start;
nframes_t end = selection->time[clicked_selection].end;
set_punch_range (start, end, _("set punch range from selection"));
} }
void void

View file

@ -488,12 +488,13 @@ Editor::build_range_marker_menu (bool loop_or_punch)
} else { } else {
range_marker_menu = markerMenu; range_marker_menu = markerMenu;
} }
MenuList& items = markerMenu->items(); MenuList& items = markerMenu->items();
markerMenu->set_name ("ArdourContextMenu"); markerMenu->set_name ("ArdourContextMenu");
items.push_back (MenuElem (_("Locate to Range Mark"), mem_fun(*this, &Editor::marker_menu_set_playhead))); items.push_back (MenuElem (_("Locate to Range Mark"), mem_fun(*this, &Editor::marker_menu_set_playhead)));
items.push_back (MenuElem (_("Play from Range Mark"), mem_fun(*this, &Editor::marker_menu_play_from))); items.push_back (MenuElem (_("Play from Range Mark"), mem_fun(*this, &Editor::marker_menu_play_from)));
if (! loop_or_punch) { if (!loop_or_punch) {
items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::marker_menu_play_range))); items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::marker_menu_play_range)));
items.push_back (MenuElem (_("Loop Range"), mem_fun(*this, &Editor::marker_menu_loop_range))); items.push_back (MenuElem (_("Loop Range"), mem_fun(*this, &Editor::marker_menu_loop_range)));
} }
@ -503,7 +504,7 @@ Editor::build_range_marker_menu (bool loop_or_punch)
items.push_back (SeparatorElem()); items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Hide Range"), mem_fun(*this, &Editor::marker_menu_hide))); items.push_back (MenuElem (_("Hide Range"), mem_fun(*this, &Editor::marker_menu_hide)));
if (! loop_or_punch) { if (!loop_or_punch) {
items.push_back (MenuElem (_("Rename Range"), mem_fun(*this, &Editor::marker_menu_rename))); items.push_back (MenuElem (_("Rename Range"), mem_fun(*this, &Editor::marker_menu_rename)));
items.push_back (MenuElem (_("Remove Range"), mem_fun(*this, &Editor::marker_menu_remove))); items.push_back (MenuElem (_("Remove Range"), mem_fun(*this, &Editor::marker_menu_remove)));
} }
@ -721,8 +722,7 @@ Editor::marker_menu_set_from_selection ()
if (l->is_mark()) { if (l->is_mark()) {
// nothing for now // nothing for now
} } else {
else {
/* if range selection use first to last */ /* if range selection use first to last */
@ -909,56 +909,13 @@ Editor::new_transport_marker_menu_popdown (GdkEventAny *ev)
void void
Editor::new_transport_marker_menu_set_loop () Editor::new_transport_marker_menu_set_loop ()
{ {
if (!session) return; set_loop_range (temp_location->start(), temp_location->end(), _("set loop range"));
begin_reversible_command (_("set loop range"));
Location* tll;
if ((tll = transport_loop_location()) == 0) {
Location* loc = new Location (temp_location->start(), temp_location->end(), _("Loop"), Location::IsAutoLoop);
XMLNode &before = session->locations()->get_state();
session->locations()->add (loc, true);
session->set_auto_loop_location (loc);
XMLNode &after = session->locations()->get_state();
session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
}
else {
XMLNode &before = tll->get_state();
tll->set_hidden (false, this);
tll->set (temp_location->start(), temp_location->end());
XMLNode &after = tll->get_state();
session->add_command (new MementoCommand<Location>(*tll, &before, &after));
}
commit_reversible_command ();
} }
void void
Editor::new_transport_marker_menu_set_punch () Editor::new_transport_marker_menu_set_punch ()
{ {
if (!session) return; set_punch_range (temp_location->start(), temp_location->end(), _("set punch range"));
begin_reversible_command (_("set punch range"));
Location* tpl;
if ((tpl = transport_punch_location()) == 0) {
tpl = new Location (temp_location->start(), temp_location->end(), _("Punch"), Location::IsAutoPunch);
XMLNode &before = session->locations()->get_state();
session->locations()->add (tpl, true);
session->set_auto_punch_location (tpl);
XMLNode &after = session->locations()->get_state();
session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
} else {
XMLNode &before = tpl->get_state();
tpl->set_hidden(false, this);
tpl->set(temp_location->start(), temp_location->end());
XMLNode &after = tpl->get_state();
session->add_command (new MementoCommand<Location>(*tpl, &before, &after));
}
commit_reversible_command ();
} }
void void

View file

@ -115,7 +115,23 @@ Editor::split_regions_at (nframes_t where, RegionSelection& regions)
{ {
begin_reversible_command (_("split")); begin_reversible_command (_("split"));
snap_to (where); // if splitting a single region, and snap-to is using
// region boundaries, don't pay attention to them
if (regions.size() == 1) {
switch (snap_type) {
case SnapToRegionStart:
case SnapToRegionSync:
case SnapToRegionEnd:
break;
default:
snap_to (where);
}
} else {
snap_to (where);
}
for (RegionSelection::iterator a = regions.begin(); a != regions.end(); ) { for (RegionSelection::iterator a = regions.begin(); a != regions.end(); ) {
RegionSelection::iterator tmp; RegionSelection::iterator tmp;