GUI code changes to follow new CoreSelection API

This removes ::add_grouped_tracks() from Editor selection and
RouteProcessorSelection, since adding grouped stripables is now
a CoreSelection function, and should not be attempted by UI-side
elements
This commit is contained in:
Paul Davis 2024-08-02 11:50:14 -06:00
parent b21dd1212e
commit a06e519296
7 changed files with 92 additions and 184 deletions

View file

@ -214,74 +214,40 @@ Editor::set_selected_track_as_side_effect (SelectionOperation op, Controllable::
PBD::Unwinder<bool> uw (_editor_track_selection_change_without_scroll, true); PBD::Unwinder<bool> uw (_editor_track_selection_change_without_scroll, true);
RouteGroup* group = NULL;
if (clicked_routeview) {
group = clicked_routeview->route()->route_group();
}
switch (op) { switch (op) {
case SelectionToggle: case SelectionToggle:
if (selection->selected (clicked_axisview)) { if (selection->selected (clicked_axisview)) {
if (group && group->is_active() && group->enabled_property(ARDOUR::Properties::group_select.property_id)) { selection->remove (clicked_axisview);
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
if ((*i)->route_group() == group && gcd != Controllable::NoGroup) {
selection->remove(*i);
}
}
} else {
selection->remove (clicked_axisview);
}
} else {
if (group && group->is_active() && group->enabled_property(ARDOUR::Properties::group_select.property_id)) {
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
if ((*i)->route_group() == group && gcd != Controllable::NoGroup) {
selection->add(*i);
}
}
} else {
selection->add (clicked_axisview);
}
}
break;
case SelectionAdd:
if (group && group->is_active() && group->enabled_property(ARDOUR::Properties::group_select.property_id)) {
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
if ((*i)->route_group() == group && gcd != Controllable::NoGroup) {
selection->add(*i);
}
}
} else { } else {
selection->add (clicked_axisview); selection->add (clicked_axisview);
} }
break; break;
case SelectionAdd:
selection->add (clicked_axisview);
break;
case SelectionSet: case SelectionSet:
selection->clear(); selection->clear();
if (group && group->is_active() && group->enabled_property(ARDOUR::Properties::group_select.property_id)) { selection->set (clicked_axisview);
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
if ((*i)->route_group() == group && gcd != Controllable::NoGroup) {
selection->add(*i);
}
}
} else {
selection->set (clicked_axisview);
}
break; break;
case SelectionExtend: case SelectionExtend:
selection->clear(); selection->clear();
break; break;
default:
break;
} }
} }
void void
Editor::set_selected_track (TimeAxisView& view, SelectionOperation op, bool no_remove) Editor::set_selected_track (TimeAxisView& view, SelectionOperation op, bool no_remove)
{ {
begin_reversible_selection_op (X_("Set Selected Track"));
switch (op) { switch (op) {
case SelectionToggle: case SelectionToggle:
begin_reversible_selection_op (X_("Toggle track selection"));
if (selection->selected (&view)) { if (selection->selected (&view)) {
if (!no_remove) { if (!no_remove) {
selection->remove (&view); selection->remove (&view);
@ -292,16 +258,21 @@ Editor::set_selected_track (TimeAxisView& view, SelectionOperation op, bool no_r
break; break;
case SelectionAdd: case SelectionAdd:
begin_reversible_selection_op (X_("Add track selection"));
selection->add (&view); selection->add (&view);
break; break;
case SelectionSet: case SelectionSet:
begin_reversible_selection_op (X_("Set track selection"));
selection->set (&view); selection->set (&view);
break; break;
case SelectionExtend: case SelectionExtend:
begin_reversible_selection_op (X_("Extend track selection"));
extend_selection_to_track (view); extend_selection_to_track (view);
break; break;
default:
return;
} }
commit_reversible_selection_op (); commit_reversible_selection_op ();
@ -383,6 +354,8 @@ Editor::set_selected_control_point_from_click (bool press, SelectionOperation op
case SelectionExtend: case SelectionExtend:
/* XXX */ /* XXX */
break; break;
default:
break;
} }
return ret; return ret;
@ -1025,20 +998,25 @@ Editor::set_selection (std::list<Selectable*> s, SelectionOperation op)
if (s.empty()) { if (s.empty()) {
return; return;
} }
begin_reversible_selection_op (X_("set selection"));
switch (op) { switch (op) {
case SelectionToggle: case SelectionToggle:
selection->toggle (s); begin_reversible_selection_op (X_("toggle selection"));
break; selection->toggle (s);
case SelectionSet: break;
selection->set (s); case SelectionSet:
break; begin_reversible_selection_op (X_("set selection"));
case SelectionExtend: selection->set (s);
selection->add (s); break;
break; case SelectionExtend:
case SelectionAdd: begin_reversible_selection_op (X_("extend selection"));
selection->add (s); selection->add (s);
break; break;
case SelectionAdd:
begin_reversible_selection_op (X_("add to selection"));
selection->add (s);
break;
default:
return;
} }
commit_reversible_selection_op () ; commit_reversible_selection_op () ;
@ -1055,22 +1033,27 @@ Editor::set_selected_regionview_from_region_list (std::shared_ptr<Region> region
return; return;
} }
begin_reversible_selection_op (X_("set selected regions"));
switch (op) { switch (op) {
case SelectionToggle: case SelectionToggle:
/* XXX this is not correct */ /* XXX this is not correct */
begin_reversible_selection_op (X_("toggle selected regions"));
selection->toggle (regionviews); selection->toggle (regionviews);
break; break;
case SelectionSet: case SelectionSet:
begin_reversible_selection_op (X_("toggle selected regions"));
selection->set (regionviews); selection->set (regionviews);
break; break;
case SelectionExtend: case SelectionExtend:
begin_reversible_selection_op (X_("extend selected regions"));
selection->add (regionviews); selection->add (regionviews);
break; break;
case SelectionAdd: case SelectionAdd:
begin_reversible_selection_op (X_("add selected regions"));
selection->add (regionviews); selection->add (regionviews);
break; break;
default:
return;
} }
commit_reversible_selection_op () ; commit_reversible_selection_op () ;
@ -1762,23 +1745,23 @@ Editor::select_all_in_track (SelectionOperation op)
return; return;
} }
begin_reversible_selection_op (X_("Select All in Track"));
clicked_routeview->get_selectables (timepos_t(), timepos_t::max (Temporal::AudioTime), 0, DBL_MAX, touched); clicked_routeview->get_selectables (timepos_t(), timepos_t::max (Temporal::AudioTime), 0, DBL_MAX, touched);
switch (op) { switch (op) {
case SelectionToggle: case SelectionToggle:
begin_reversible_selection_op (X_("Toggle Select All in Track"));
selection->add (touched); selection->add (touched);
break; break;
case SelectionSet: case SelectionSet:
begin_reversible_selection_op (X_("Select All in Track"));
selection->set (touched); selection->set (touched);
break; break;
case SelectionExtend:
/* meaningless, because we're selecting everything */
break;
case SelectionAdd: case SelectionAdd:
begin_reversible_selection_op (X_("Add Select All in Track"));
selection->add (touched); selection->add (touched);
break; break;
default:
return;
} }
commit_reversible_selection_op (); commit_reversible_selection_op ();
@ -1832,20 +1815,21 @@ Editor::select_all_objects (SelectionOperation op)
(*iter)->get_selectables (timepos_t(), timepos_t::max (Temporal::AudioTime), 0, DBL_MAX, touched); (*iter)->get_selectables (timepos_t(), timepos_t::max (Temporal::AudioTime), 0, DBL_MAX, touched);
} }
begin_reversible_selection_op (X_("select all"));
switch (op) { switch (op) {
case SelectionAdd: case SelectionAdd:
begin_reversible_selection_op (X_("add select all"));
selection->add (touched); selection->add (touched);
break; break;
case SelectionToggle: case SelectionToggle:
begin_reversible_selection_op (X_("toggle select all"));
selection->toggle (touched); selection->toggle (touched);
break; break;
case SelectionSet: case SelectionSet:
begin_reversible_selection_op (X_("select all"));
selection->set (touched); selection->set (touched);
break; break;
case SelectionExtend: default:
/* meaningless, because we're selecting everything */ return;
break;
} }
commit_reversible_selection_op (); commit_reversible_selection_op ();
} }
@ -1949,20 +1933,21 @@ Editor::select_all_within (timepos_t const & start, timepos_t const & end, doubl
} }
} }
begin_reversible_selection_op (X_("select all within"));
switch (op) { switch (op) {
case SelectionAdd: case SelectionAdd:
begin_reversible_selection_op (X_("add select all within"));
selection->add (found); selection->add (found);
break; break;
case SelectionToggle: case SelectionToggle:
begin_reversible_selection_op (X_("toggle select all within"));
selection->toggle (found); selection->toggle (found);
break; break;
case SelectionSet: case SelectionSet:
begin_reversible_selection_op (X_("select all within"));
selection->set (found); selection->set (found);
break; break;
case SelectionExtend: default:
/* not defined yet */ return;
break;
} }
commit_reversible_selection_op (); commit_reversible_selection_op ();

View file

@ -68,26 +68,6 @@ RouteProcessorSelection::clear_routes ()
} }
} }
std::list<AxisView*>
RouteProcessorSelection::add_grouped_tracks (AxisView* r) const
{
std::list<AxisView*> rv;
std::shared_ptr<Route> route = std::dynamic_pointer_cast<Route>(r->stripable());
if (route) {
ARDOUR::RouteGroup* rg = route->route_group ();
if (rg && rg->is_active() && rg->is_select ()) {
std::shared_ptr<RouteList> rl = rg->route_list ();
for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
AxisView* av = avp.axis_view_by_stripable (*i);
rv.push_back (av);
}
}
}
return rv;
}
void void
RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed) RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
{ {
@ -128,20 +108,12 @@ RouteProcessorSelection::add (AxisView* r, bool with_groups)
return; return;
} }
std::list<AxisView*> avl;
if (with_groups) {
avl= add_grouped_tracks (r);
}
avl.push_back (r);
PresentationInfo::ChangeSuspender cs; PresentationInfo::ChangeSuspender cs;
for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) { if (axes.insert (r).second) {
if (axes.insert (*i).second) { shp.session()->selection().select_stripable_and_maybe_group (r->stripable(), SelectionAdd, with_groups);
shp.session()->selection().add ((*i)->stripable(), std::shared_ptr<AutomationControl>()); MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
MixerStrip* ms = dynamic_cast<MixerStrip*> (*i); if (ms) {
if (ms) { ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1, false), gui_context());
ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1, false), gui_context());
}
} }
} }
} }
@ -154,16 +126,8 @@ RouteProcessorSelection::remove (AxisView* r, bool with_groups)
} }
ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r); ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
std::list<AxisView*> avl;
if (with_groups) {
avl= add_grouped_tracks (r);
}
avl.push_back (r);
PresentationInfo::ChangeSuspender cs; PresentationInfo::ChangeSuspender cs;
for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) { shp.session()->selection().select_stripable_and_maybe_group (r->stripable(), SelectionRemove, with_groups);
shp.session()->selection().remove ((*i)->stripable(), std::shared_ptr<AutomationControl>());
}
} }
void void
@ -173,9 +137,7 @@ RouteProcessorSelection::set (AxisView* r)
return; return;
} }
StripableList sl; shp.session()->selection().select_stripable_and_maybe_group (r->stripable(), SelectionSet);
sl.push_back (r->stripable());
shp.session()->selection().set (sl);
} }
bool bool

View file

@ -56,7 +56,6 @@ private:
ARDOUR::SessionHandlePtr& shp; ARDOUR::SessionHandlePtr& shp;
AxisViewProvider& avp; AxisViewProvider& avp;
void removed (AxisView*); void removed (AxisView*);
std::list<AxisView*> add_grouped_tracks (AxisView*) const;
RouteProcessorSelection& operator= (const RouteProcessorSelection& other); RouteProcessorSelection& operator= (const RouteProcessorSelection& other);
RouteProcessorSelection (RouteProcessorSelection const&); RouteProcessorSelection (RouteProcessorSelection const&);

View file

@ -1142,24 +1142,30 @@ RouteTimeAxisView::selection_click (GdkEventButton* ev)
return; return;
} }
_editor.begin_reversible_selection_op (X_("Selection Click"));
switch (ArdourKeyboard::selection_type (ev->state)) { switch (ArdourKeyboard::selection_type (ev->state)) {
case SelectionToggle: case SelectionToggle:
_editor.begin_reversible_selection_op (X_("Selection toggle"));
_editor.get_selection().toggle (this); _editor.get_selection().toggle (this);
break; break;
case SelectionSet: case SelectionSet:
_editor.begin_reversible_selection_op (X_("Selection set"));
_editor.get_selection().set (this); _editor.get_selection().set (this);
break; break;
case SelectionExtend: case SelectionExtend:
_editor.begin_reversible_selection_op (X_("Selection extend"));
_editor.extend_selection_to_track (*this); _editor.extend_selection_to_track (*this);
break; break;
case SelectionAdd: case SelectionAdd:
_editor.begin_reversible_selection_op (X_("Selection add"));
_editor.get_selection().add (this); _editor.get_selection().add (this);
break; break;
default:
/* remove not done here */
break;
} }
_editor.commit_reversible_selection_op (); _editor.commit_reversible_selection_op ();

View file

@ -1406,15 +1406,13 @@ Selection::remove_regions (TimeAxisView* t)
void void
Selection::toggle (const TrackViewList& track_list) Selection::toggle (const TrackViewList& track_list)
{ {
TrackViewList t = add_grouped_tracks (track_list);
CoreSelection& selection (editor->session()->selection()); CoreSelection& selection (editor->session()->selection());
PresentationInfo::ChangeSuspender cs; PresentationInfo::ChangeSuspender cs;
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) { for (auto const t : track_list) {
std::shared_ptr<Stripable> s = (*i)->stripable (); std::shared_ptr<Stripable> s = t->stripable ();
std::shared_ptr<AutomationControl> c = (*i)->control (); std::shared_ptr<AutomationControl> c = t->control ();
selection.toggle (s, c); selection.select_stripable_with_control (s, c, SelectionToggle);
} }
} }
@ -1429,15 +1427,13 @@ Selection::toggle (TimeAxisView* track)
void void
Selection::add (TrackViewList const & track_list) Selection::add (TrackViewList const & track_list)
{ {
TrackViewList t = add_grouped_tracks (track_list);
CoreSelection& selection (editor->session()->selection()); CoreSelection& selection (editor->session()->selection());
PresentationInfo::ChangeSuspender cs; PresentationInfo::ChangeSuspender cs;
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) { for (auto const & t : track_list) {
std::shared_ptr<Stripable> s = (*i)->stripable (); std::shared_ptr<Stripable> s = t->stripable ();
std::shared_ptr<AutomationControl> c = (*i)->control (); std::shared_ptr<AutomationControl> c = t->control ();
selection.add (s, c); selection.select_stripable_with_control (s, c, SelectionAdd);
} }
} }
@ -1469,7 +1465,7 @@ Selection::remove (const TrackViewList& t)
s = (*i)->stripable (); s = (*i)->stripable ();
} }
std::shared_ptr<AutomationControl> c = (*i)->control (); std::shared_ptr<AutomationControl> c = (*i)->control ();
selection.remove (s, c); selection.select_stripable_with_control (s, c, SelectionRemove);
} }
} }
@ -1484,8 +1480,6 @@ Selection::set (TimeAxisView* track)
void void
Selection::set (const TrackViewList& track_list) Selection::set (const TrackViewList& track_list)
{ {
TrackViewList t = add_grouped_tracks (track_list);
CoreSelection& selection (editor->session()->selection()); CoreSelection& selection (editor->session()->selection());
#if 1 // crazy optimization hack #if 1 // crazy optimization hack
@ -1503,9 +1497,9 @@ Selection::set (const TrackViewList& track_list)
bool changed = false; bool changed = false;
CoreSelection::StripableAutomationControls sac; CoreSelection::StripableAutomationControls sac;
selection.get_stripables (sac); selection.get_stripables (sac);
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) { for (auto const & t : track_list) {
std::shared_ptr<Stripable> s = (*i)->stripable (); std::shared_ptr<Stripable> s = t->stripable ();
std::shared_ptr<AutomationControl> c = (*i)->control (); std::shared_ptr<AutomationControl> c = t->control ();
bool found = false; bool found = false;
for (CoreSelection::StripableAutomationControls::iterator j = sac.begin (); j != sac.end (); ++j) { for (CoreSelection::StripableAutomationControls::iterator j = sac.begin (); j != sac.end (); ++j) {
if (j->stripable == s && j->controllable == c) { if (j->stripable == s && j->controllable == c) {
@ -1528,10 +1522,13 @@ Selection::set (const TrackViewList& track_list)
selection.clear_stripables (); selection.clear_stripables ();
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) { bool first = true;
std::shared_ptr<Stripable> s = (*i)->stripable ();
std::shared_ptr<AutomationControl> c = (*i)->control (); for (auto const & t : track_list) {
selection.add (s, c); std::shared_ptr<Stripable> s = t->stripable ();
std::shared_ptr<AutomationControl> c = t->control ();
selection.select_stripable_with_control (s, c, first ? SelectionSet : SelectionAdd);
first = false;
} }
} }
@ -1569,45 +1566,6 @@ Selection::selected (TimeAxisView* tv) const
return selection.selected (s); return selection.selected (s);
} }
TrackViewList
Selection::add_grouped_tracks (TrackViewList const & t)
{
TrackViewList added;
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
if (dynamic_cast<VCATimeAxisView*> (*i)) {
continue;
}
/* select anything in the same select-enabled route group */
ARDOUR::RouteGroup* rg = (*i)->route_group ();
if (rg && rg->is_active() && rg->is_select ()) {
TrackViewList tr = editor->axis_views_from_routes (rg->route_list ());
for (TrackViewList::iterator j = tr.begin(); j != tr.end(); ++j) {
/* Do not add the trackview passed in as an
* argument, because we want that to be on the
* end of the list.
*/
if (*j != *i) {
if (!added.contains (*j)) {
added.push_back (*j);
}
}
}
}
}
/* now add the the trackview's passed in as actual arguments */
added.insert (added.end(), t.begin(), t.end());
return added;
}
#if 0 #if 0
static void dump_tracks (Selection const & s) static void dump_tracks (Selection const & s)
{ {

View file

@ -248,8 +248,6 @@ private:
PublicEditor const * editor; PublicEditor const * editor;
uint32_t next_time_id; uint32_t next_time_id;
bool manage_libardour_selection; bool manage_libardour_selection;
TrackViewList add_grouped_tracks (TrackViewList const & t);
}; };
bool operator==(const Selection& a, const Selection& b); bool operator==(const Selection& a, const Selection& b);

View file

@ -466,7 +466,7 @@ TrackRecordAxis::playlist_click (GdkEventButton* ev)
} }
build_playlist_menu (); build_playlist_menu ();
_route->session ().selection().select_stripable_and_maybe_group (_route, false, true, 0); _route->session ().selection().select_stripable_and_maybe_group (_route, SelectionSet, false, true, nullptr);
Gtkmm2ext::anchored_menu_popup (playlist_action_menu, &_playlist_button, "", 1, ev->time); Gtkmm2ext::anchored_menu_popup (playlist_action_menu, &_playlist_button, "", 1, ev->time);
return true; return true;
@ -481,7 +481,7 @@ TrackRecordAxis::route_ops_click (GdkEventButton* ev)
build_route_ops_menu (); build_route_ops_menu ();
_route->session ().selection().select_stripable_and_maybe_group (_route, false, true, 0); _route->session ().selection().select_stripable_and_maybe_group (_route, SelectionSet, false, true, nullptr);
Gtkmm2ext::anchored_menu_popup (_route_ops_menu, &_number_label, "", 1, ev->time); Gtkmm2ext::anchored_menu_popup (_route_ops_menu, &_number_label, "", 1, ev->time);
return true; return true;