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;
}
if (clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
if (item_type != SelectionItem && clicked_audio_trackview && clicked_audio_trackview->audio_track()) {
/* Bounce to disk */
@ -1554,7 +1554,8 @@ Editor::build_track_selection_context_menu (nframes_t ignored)
edit_items.clear ();
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;
}
@ -1789,15 +1790,12 @@ Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr<Region>
}
void
Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
Editor::add_selection_context_items (Menu_Helpers::MenuList& items)
{
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 (_("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
items.push_back (SeparatorElem());
@ -1805,15 +1803,22 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
#endif
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Separate range to track"), mem_fun(*this, &Editor::separate_region_from_selection)));
items.push_back (MenuElem (_("Separate range to region list"), mem_fun(*this, &Editor::new_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 (_("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 (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 (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 (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)));
@ -1822,9 +1827,6 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
items.push_back (SeparatorElem());
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)));
edit_items.push_back (MenuElem (_("Range"), *selection_menu));
edit_items.push_back (SeparatorElem());
}
void
@ -3830,3 +3832,59 @@ Editor::edit_cursor_position(bool sync)
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_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 ();

View file

@ -26,11 +26,13 @@
#include "region_view.h"
#include "selection.h"
#include "i18n.h"
using namespace ARDOUR;
using namespace PBD;
void
Editor::set_route_loop_selection ()
Editor::set_loop_from_selection (bool play)
{
if (session == 0 || selection->time.empty()) {
return;
@ -39,17 +41,25 @@ Editor::set_route_loop_selection ()
nframes_t start = selection->time[clicked_selection].start;
nframes_t end = selection->time[clicked_selection].end;
Location* loc = transport_loop_location();
set_loop_range (start, end, _("set loop range from selection"));
if (loc) {
loc->set (start, end);
// enable looping, reposition and start rolling
if (play) {
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

View file

@ -488,6 +488,7 @@ Editor::build_range_marker_menu (bool loop_or_punch)
} else {
range_marker_menu = markerMenu;
}
MenuList& items = markerMenu->items();
markerMenu->set_name ("ArdourContextMenu");
@ -721,8 +722,7 @@ Editor::marker_menu_set_from_selection ()
if (l->is_mark()) {
// nothing for now
}
else {
} else {
/* if range selection use first to last */
@ -909,56 +909,13 @@ Editor::new_transport_marker_menu_popdown (GdkEventAny *ev)
void
Editor::new_transport_marker_menu_set_loop ()
{
if (!session) return;
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 ();
set_loop_range (temp_location->start(), temp_location->end(), _("set loop range"));
}
void
Editor::new_transport_marker_menu_set_punch ()
{
if (!session) return;
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 ();
set_punch_range (temp_location->start(), temp_location->end(), _("set punch range"));
}
void

View file

@ -115,7 +115,23 @@ Editor::split_regions_at (nframes_t where, RegionSelection& regions)
{
begin_reversible_command (_("split"));
// 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(); ) {
RegionSelection::iterator tmp;