select all in time range, show object selection while in range mode, trim range ends by a frame when selecting, make things semantically a bit better.

git-svn-id: svn://localhost/trunk/ardour2@329 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Nick Mainsbridge 2006-02-15 12:15:29 +00:00
parent 99281692de
commit 69c9f3d7ce
6 changed files with 94 additions and 54 deletions

View File

@ -1828,6 +1828,8 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
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 (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 (_("Create chunk from range"), mem_fun(*this, &Editor::name_selection)));
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Create Region"), mem_fun(*this, &Editor::new_region_from_selection)));
@ -1878,10 +1880,10 @@ Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
select_items.push_back (MenuElem (_("Select loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
select_items.push_back (MenuElem (_("Select punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
select_items.push_back (SeparatorElem());
select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_after_cursor), edit_cursor, true)));
select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_after_cursor), edit_cursor, false)));
select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_after_cursor), playhead_cursor, true)));
select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_after_cursor), playhead_cursor, false)));
select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
select_items.push_back (SeparatorElem());
edit_items.push_back (MenuElem (_("Select"), *select_menu));
@ -1968,10 +1970,10 @@ Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
select_items.push_back (MenuElem (_("Select loop range"), mem_fun(*this, &Editor::set_selection_from_loop)));
select_items.push_back (MenuElem (_("Select punch range"), mem_fun(*this, &Editor::set_selection_from_punch)));
select_items.push_back (SeparatorElem());
select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_after_cursor), edit_cursor, true)));
select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_after_cursor), edit_cursor, false)));
select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_after_cursor), playhead_cursor, true)));
select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_after_cursor), playhead_cursor, false)));
select_items.push_back (MenuElem (_("Select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true)));
select_items.push_back (MenuElem (_("Select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false)));
select_items.push_back (MenuElem (_("Select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
select_items.push_back (MenuElem (_("Select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
select_items.push_back (SeparatorElem());
edit_items.push_back (MenuElem (_("Select"), *select_menu));

View File

@ -635,7 +635,7 @@ class Editor : public PublicEditor
void cursor_to_region_point (Cursor*, ARDOUR::RegionPoint, int32_t dir);
void cursor_to_selection_start (Cursor *);
void cursor_to_selection_end (Cursor *);
void select_all_after_cursor (Cursor *, bool);
void select_all_selectables_using_cursor (Cursor *, bool);
ARDOUR::Region* find_next_region (jack_nframes_t, ARDOUR::RegionPoint, int32_t dir, TrackViewList&, TimeAxisView ** = 0);
@ -1004,8 +1004,9 @@ class Editor : public PublicEditor
void cursor_align (bool playhead_to_edit);
void remove_last_capture ();
void select_all_from_loop();
void select_all_from_punch();
void select_all_selectables_using_time_selection ();
void select_all_selectables_using_loop();
void select_all_selectables_using_punch();
void set_selection_from_range (ARDOUR::Location&);
void set_selection_from_punch ();
void set_selection_from_loop ();
@ -1251,7 +1252,7 @@ class Editor : public PublicEditor
void marker_menu_rename ();
void marker_menu_hide ();
void marker_menu_loop_range ();
void marker_menu_select_all_from_range ();
void marker_menu_select_all_selectables_using_range ();
void marker_menu_play_from ();
void marker_menu_set_playhead ();
void marker_menu_set_from_playhead ();

View File

@ -84,19 +84,19 @@ Editor::register_actions ()
act = ActionManager::register_action (editor_actions, "select-all", _("select all"), bind (mem_fun(*this, &Editor::select_all), false));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "select-all-after-edit-cursor", _("select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_after_cursor), edit_cursor, true));
act = ActionManager::register_action (editor_actions, "select-all-after-edit-cursor", _("select all after edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "select-all-before-edit-cursor", _("select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_after_cursor), edit_cursor, false));
act = ActionManager::register_action (editor_actions, "select-all-before-edit-cursor", _("select all before edit cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "select-all-after-playhead", _("select all after playhead"), bind (mem_fun(*this, &Editor::select_all_after_cursor), playhead_cursor, true));
act = ActionManager::register_action (editor_actions, "select-all-after-playhead", _("select all after playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "select-all-before-playhead", _("select all before playhead"), bind (mem_fun(*this, &Editor::select_all_after_cursor), playhead_cursor, false));
act = ActionManager::register_action (editor_actions, "select-all-before-playhead", _("select all before playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "select-all-in-punch-range", _("select all in punch range"), mem_fun(*this, &Editor::select_all_from_punch));
act = ActionManager::register_action (editor_actions, "select-all-in-punch-range", _("select all in punch range"), mem_fun(*this, &Editor::select_all_selectables_using_punch));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "select-all-in-loop-range", _("select all in loop range"), mem_fun(*this, &Editor::select_all_from_loop));
act = ActionManager::register_action (editor_actions, "select-all-in-loop-range", _("select all in loop range"), mem_fun(*this, &Editor::select_all_selectables_using_loop));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (editor_actions, "jump-forward-to-mark", _("jump forward to mark"), mem_fun(*this, &Editor::jump_forward_to_mark));

View File

@ -481,7 +481,7 @@ Editor::build_range_marker_menu ()
items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::marker_menu_remove)));
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Select all in Range"), mem_fun(*this, &Editor::marker_menu_select_all_from_range)));
items.push_back (MenuElem (_("Select all in Range"), mem_fun(*this, &Editor::marker_menu_select_all_selectables_using_range)));
}
@ -529,7 +529,7 @@ Editor::build_transport_marker_menu ()
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Hide"), mem_fun(*this, &Editor::marker_menu_hide)));
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Select all in Range"), mem_fun(*this, &Editor::marker_menu_select_all_from_range)));
items.push_back (MenuElem (_("Select all in Range"), mem_fun(*this, &Editor::marker_menu_select_all_selectables_using_range)));
}
void
@ -551,7 +551,7 @@ Editor::marker_menu_hide ()
}
void
Editor::marker_menu_select_all_from_range ()
Editor::marker_menu_select_all_selectables_using_range ()
{
Marker* marker;
@ -559,11 +559,11 @@ Editor::marker_menu_select_all_from_range ()
fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg;
/*NOTREACHED*/
}
Location* l;
bool is_start;
if ((l = find_location_from_marker (marker, is_start)) != 0) {
if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) {
select_all_within (l->start(), l->end(), 0, DBL_MAX, false);
}

View File

@ -191,13 +191,10 @@ Editor::set_mouse_mode (MouseMode m, bool force)
} else {
/* in range mode, hide object (region) selection, and show the
range selection.
/*
in range mode,show the range selection.
*/
for (AudioRegionSelection::iterator i = selection->audio_regions.begin(); i != selection->audio_regions.end(); ++i) {
(*i)->set_should_show_selection (false);
}
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
if ((*i)->selected()) {
(*i)->show_selection (selection->time);

View File

@ -1228,13 +1228,13 @@ Editor::select_all (bool add)
}
(*iter)->get_selectables (0, max_frames, 0, DBL_MAX, touched);
}
begin_reversible_command (_("select all"));
if (add) {
selection->add (touched);
} else {
selection->set (touched);
}
commit_reversible_command ();
}
void
@ -1310,11 +1310,58 @@ Editor::set_selection_from_loop()
}
void
Editor::select_all_from_punch()
Editor::set_selection_from_range (Location& loc)
{
Location* location;
if (clicked_trackview == 0) {
return;
}
begin_reversible_command (_("set selection from range"));
selection->set (0, loc.start(), loc.end());
commit_reversible_command ();
}
void
Editor::select_all_selectables_using_time_selection ()
{
list<Selectable *> touched;
if ((location = session->locations()->auto_punch_location()) == 0) {
if (clicked_trackview == 0) {
return;
}
if (selection->time.empty()) {
return;
}
jack_nframes_t start = selection->time[clicked_selection].start;
jack_nframes_t end = selection->time[clicked_selection].end;
if (end - start < 1) {
return;
}
for (TrackViewList::iterator iter = selection->tracks.begin(); iter != selection->tracks.end(); ++iter) {
if ((*iter)->hidden()) {
continue;
}
(*iter)->get_selectables (start, end - 1, 0, DBL_MAX, touched);
}
begin_reversible_command (_("select all from range"));
selection->set (touched);
commit_reversible_command ();
}
void
Editor::select_all_selectables_using_punch()
{
Location* location = session->locations()->auto_punch_location();
list<Selectable *> touched;
if (location == 0 || (location->end() - location->start() <= 1)) {
return;
}
@ -1322,7 +1369,7 @@ Editor::select_all_from_punch()
if ((*iter)->hidden()) {
continue;
}
(*iter)->get_selectables (location->start(), location->end(), 0, DBL_MAX, touched);
(*iter)->get_selectables (location->start(), location->end() - 1, 0, DBL_MAX, touched);
}
begin_reversible_command (_("select all from punch"));
selection->set (touched);
@ -1331,19 +1378,20 @@ Editor::select_all_from_punch()
}
void
Editor::select_all_from_loop()
Editor::select_all_selectables_using_loop()
{
Location* location;
Location* location = session->locations()->auto_punch_location();
list<Selectable *> touched;
if ((location = session->locations()->auto_loop_location()) == 0) {
if (location == 0 || (location->end() - location->start() <= 1)) {
return;
}
for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
if ((*iter)->hidden()) {
continue;
}
(*iter)->get_selectables (location->start(), location->end(), 0, DBL_MAX, touched);
(*iter)->get_selectables (location->start(), location->end() - 1, 0, DBL_MAX, touched);
}
begin_reversible_command (_("select all from loop"));
selection->set (touched);
@ -1352,19 +1400,7 @@ Editor::select_all_from_loop()
}
void
Editor::set_selection_from_range (Location& range)
{
if (clicked_trackview == 0) {
return;
}
begin_reversible_command (_("set selection from range"));
selection->set (0, range.start(), range.end());
commit_reversible_command ();
}
void
Editor::select_all_after_cursor (Cursor *cursor, bool after)
Editor::select_all_selectables_using_cursor (Cursor *cursor, bool after)
{
jack_nframes_t start;
jack_nframes_t end;
@ -1375,9 +1411,13 @@ Editor::select_all_after_cursor (Cursor *cursor, bool after)
start = cursor->current_frame ;
end = session->current_end_frame();
} else {
begin_reversible_command (_("select all before cursor"));
start = 0;
end = cursor->current_frame ;
if (cursor->current_frame > 0) {
begin_reversible_command (_("select all before cursor"));
start = 0;
end = cursor->current_frame - 1;
} else {
return;
}
}
for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
if ((*iter)->hidden()) {