Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equivalent region selection (new) #593

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gtk2_ardour/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList
bool set_selected_control_point_from_click (bool press, Selection::Operation op = Selection::Set);
void set_selected_track_from_click (bool press, Selection::Operation op = Selection::Set, bool no_remove=false);
void set_selected_track_as_side_effect (Selection::Operation op);
bool selection_contains_isolated_equivalent_region ();
bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set);

bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::weak_ptr<ARDOUR::Region>);
Expand Down
71 changes: 64 additions & 7 deletions gtk2_ardour/editor_selection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,32 @@ Editor::get_regionview_count_from_region_list (boost::shared_ptr<Region> region)
}


bool
Editor::selection_contains_isolated_equivalent_region ()
{
vector<RegionView*> already_seen;

for (RegionSelection::iterator r = selection->regions.begin(); r != selection->regions.end(); ++r) {
if (std::find(already_seen.begin(), already_seen.end(), (*r)) != already_seen.end()){
continue;
}

vector<RegionView*> equivalent_regions;
get_equivalent_regions ((*r), equivalent_regions, ARDOUR::Properties::group_select.property_id);

for (vector<RegionView*>::iterator er = equivalent_regions.begin() ; er != equivalent_regions.end(); ++er){
already_seen.push_back((*er));

if (!selection->selected((*er))) {
return true;
}
}
}
return false;
}



bool
Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)
{
Expand All @@ -613,10 +639,10 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)
}

if (op == Selection::Toggle || op == Selection::Set) {

switch (op) {
case Selection::Toggle:
if (selection->selected (clicked_regionview)) {

if (press) {

/* whatever was clicked was selected already; do nothing here but allow
Expand All @@ -626,11 +652,22 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)
button_release_can_deselect = true;

} else {

if (button_release_can_deselect) {

/* just remove this one region, but only on a permitted button release */
if (selection->regions.empty() || selection_contains_isolated_equivalent_region()) {
/* just remove this one region, but only on a permitted button release */
selection->remove (clicked_regionview);

} else {
/* remove all equivalents regions, but only on a permitted button release */
get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id);

for (vector<RegionView*>::iterator r = all_equivalent_regions.begin(); r != all_equivalent_regions.end(); ++r ){
selection->remove((*r));
}
}

selection->remove (clicked_regionview);
commit = true;

/* no more deselect action on button release till a new press
Expand All @@ -645,10 +682,14 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)

if (press) {

if (selection->selected (clicked_routeview)) {
get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id);
} else {
if (selection->regions.empty() || selection_contains_isolated_equivalent_region()) {

all_equivalent_regions.push_back (clicked_regionview);

} else {

get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id);

}

/* add all the equivalent regions, but only on button press */
Expand All @@ -664,14 +705,20 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)

case Selection::Set:
if (!selection->selected (clicked_regionview)) {

get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id);
selection->set (all_equivalent_regions);
commit = true;

} else {
/* clicked on an already selected region */

if (press)

goto out;

else {

if (selection->regions.size() > 1) {
/* collapse region selection down to just this one region (and its equivalents) */
get_equivalent_regions(clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id);
Expand Down Expand Up @@ -897,7 +944,17 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)
RegionView* arv;

if ((arv = dynamic_cast<RegionView*>(*x)) != 0) {
regions.push_back (arv);
if (selection_contains_isolated_equivalent_region()) {
regions.push_back (arv);
} else {
get_equivalent_regions(arv, all_equivalent_regions, ARDOUR::Properties::group_select.property_id);
for (vector<RegionView*>::iterator i=all_equivalent_regions.begin(); i != all_equivalent_regions.end(); ++i){
if ( !(std::find(regions.begin(), regions.end(), (*i)) != regions.end()) ) {
regions.push_back (*i);
}
}
}

}
}

Expand Down