13
0

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);
RouteGroup* group = NULL;
if (clicked_routeview) {
group = clicked_routeview->route()->route_group();
}
switch (op) {
case SelectionToggle:
if (selection->selected (clicked_axisview)) {
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->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);
}
}
selection->remove (clicked_axisview);
} else {
selection->add (clicked_axisview);
}
break;
case SelectionAdd:
selection->add (clicked_axisview);
break;
case SelectionSet:
selection->clear();
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->set (clicked_axisview);
}
selection->set (clicked_axisview);
break;
case SelectionExtend:
selection->clear();
break;
default:
break;
}
}
void
Editor::set_selected_track (TimeAxisView& view, SelectionOperation op, bool no_remove)
{
begin_reversible_selection_op (X_("Set Selected Track"));
switch (op) {
case SelectionToggle:
begin_reversible_selection_op (X_("Toggle track selection"));
if (selection->selected (&view)) {
if (!no_remove) {
selection->remove (&view);
@ -292,16 +258,21 @@ Editor::set_selected_track (TimeAxisView& view, SelectionOperation op, bool no_r
break;
case SelectionAdd:
begin_reversible_selection_op (X_("Add track selection"));
selection->add (&view);
break;
case SelectionSet:
begin_reversible_selection_op (X_("Set track selection"));
selection->set (&view);
break;
case SelectionExtend:
begin_reversible_selection_op (X_("Extend track selection"));
extend_selection_to_track (view);
break;
default:
return;
}
commit_reversible_selection_op ();
@ -383,6 +354,8 @@ Editor::set_selected_control_point_from_click (bool press, SelectionOperation op
case SelectionExtend:
/* XXX */
break;
default:
break;
}
return ret;
@ -1025,20 +998,25 @@ Editor::set_selection (std::list<Selectable*> s, SelectionOperation op)
if (s.empty()) {
return;
}
begin_reversible_selection_op (X_("set selection"));
switch (op) {
case SelectionToggle:
selection->toggle (s);
break;
case SelectionSet:
selection->set (s);
break;
case SelectionExtend:
selection->add (s);
break;
case SelectionAdd:
selection->add (s);
break;
case SelectionToggle:
begin_reversible_selection_op (X_("toggle selection"));
selection->toggle (s);
break;
case SelectionSet:
begin_reversible_selection_op (X_("set selection"));
selection->set (s);
break;
case SelectionExtend:
begin_reversible_selection_op (X_("extend selection"));
selection->add (s);
break;
case SelectionAdd:
begin_reversible_selection_op (X_("add to selection"));
selection->add (s);
break;
default:
return;
}
commit_reversible_selection_op () ;
@ -1055,22 +1033,27 @@ Editor::set_selected_regionview_from_region_list (std::shared_ptr<Region> region
return;
}
begin_reversible_selection_op (X_("set selected regions"));
switch (op) {
case SelectionToggle:
/* XXX this is not correct */
begin_reversible_selection_op (X_("toggle selected regions"));
selection->toggle (regionviews);
break;
case SelectionSet:
begin_reversible_selection_op (X_("toggle selected regions"));
selection->set (regionviews);
break;
case SelectionExtend:
begin_reversible_selection_op (X_("extend selected regions"));
selection->add (regionviews);
break;
case SelectionAdd:
begin_reversible_selection_op (X_("add selected regions"));
selection->add (regionviews);
break;
default:
return;
}
commit_reversible_selection_op () ;
@ -1762,23 +1745,23 @@ Editor::select_all_in_track (SelectionOperation op)
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);
switch (op) {
case SelectionToggle:
begin_reversible_selection_op (X_("Toggle Select All in Track"));
selection->add (touched);
break;
case SelectionSet:
begin_reversible_selection_op (X_("Select All in Track"));
selection->set (touched);
break;
case SelectionExtend:
/* meaningless, because we're selecting everything */
break;
case SelectionAdd:
begin_reversible_selection_op (X_("Add Select All in Track"));
selection->add (touched);
break;
default:
return;
}
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);
}
begin_reversible_selection_op (X_("select all"));
switch (op) {
case SelectionAdd:
begin_reversible_selection_op (X_("add select all"));
selection->add (touched);
break;
case SelectionToggle:
begin_reversible_selection_op (X_("toggle select all"));
selection->toggle (touched);
break;
case SelectionSet:
begin_reversible_selection_op (X_("select all"));
selection->set (touched);
break;
case SelectionExtend:
/* meaningless, because we're selecting everything */
break;
default:
return;
}
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) {
case SelectionAdd:
begin_reversible_selection_op (X_("add select all within"));
selection->add (found);
break;
case SelectionToggle:
begin_reversible_selection_op (X_("toggle select all within"));
selection->toggle (found);
break;
case SelectionSet:
begin_reversible_selection_op (X_("select all within"));
selection->set (found);
break;
case SelectionExtend:
/* not defined yet */
break;
default:
return;
}
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
RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
{
@ -128,20 +108,12 @@ RouteProcessorSelection::add (AxisView* r, bool with_groups)
return;
}
std::list<AxisView*> avl;
if (with_groups) {
avl= add_grouped_tracks (r);
}
avl.push_back (r);
PresentationInfo::ChangeSuspender cs;
for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
if (axes.insert (*i).second) {
shp.session()->selection().add ((*i)->stripable(), std::shared_ptr<AutomationControl>());
MixerStrip* ms = dynamic_cast<MixerStrip*> (*i);
if (ms) {
ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1, false), gui_context());
}
if (axes.insert (r).second) {
shp.session()->selection().select_stripable_and_maybe_group (r->stripable(), SelectionAdd, with_groups);
MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
if (ms) {
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);
std::list<AxisView*> avl;
if (with_groups) {
avl= add_grouped_tracks (r);
}
avl.push_back (r);
PresentationInfo::ChangeSuspender cs;
for (std::list<AxisView*>::const_iterator i = avl.begin (); i != avl.end (); ++i) {
shp.session()->selection().remove ((*i)->stripable(), std::shared_ptr<AutomationControl>());
}
shp.session()->selection().select_stripable_and_maybe_group (r->stripable(), SelectionRemove, with_groups);
}
void
@ -173,9 +137,7 @@ RouteProcessorSelection::set (AxisView* r)
return;
}
StripableList sl;
sl.push_back (r->stripable());
shp.session()->selection().set (sl);
shp.session()->selection().select_stripable_and_maybe_group (r->stripable(), SelectionSet);
}
bool

View File

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

View File

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

View File

@ -1406,15 +1406,13 @@ Selection::remove_regions (TimeAxisView* t)
void
Selection::toggle (const TrackViewList& track_list)
{
TrackViewList t = add_grouped_tracks (track_list);
CoreSelection& selection (editor->session()->selection());
PresentationInfo::ChangeSuspender cs;
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
std::shared_ptr<Stripable> s = (*i)->stripable ();
std::shared_ptr<AutomationControl> c = (*i)->control ();
selection.toggle (s, c);
for (auto const t : track_list) {
std::shared_ptr<Stripable> s = t->stripable ();
std::shared_ptr<AutomationControl> c = t->control ();
selection.select_stripable_with_control (s, c, SelectionToggle);
}
}
@ -1429,15 +1427,13 @@ Selection::toggle (TimeAxisView* track)
void
Selection::add (TrackViewList const & track_list)
{
TrackViewList t = add_grouped_tracks (track_list);
CoreSelection& selection (editor->session()->selection());
PresentationInfo::ChangeSuspender cs;
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
std::shared_ptr<Stripable> s = (*i)->stripable ();
std::shared_ptr<AutomationControl> c = (*i)->control ();
selection.add (s, c);
for (auto const & t : track_list) {
std::shared_ptr<Stripable> s = t->stripable ();
std::shared_ptr<AutomationControl> c = t->control ();
selection.select_stripable_with_control (s, c, SelectionAdd);
}
}
@ -1469,7 +1465,7 @@ Selection::remove (const TrackViewList& t)
s = (*i)->stripable ();
}
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
Selection::set (const TrackViewList& track_list)
{
TrackViewList t = add_grouped_tracks (track_list);
CoreSelection& selection (editor->session()->selection());
#if 1 // crazy optimization hack
@ -1503,9 +1497,9 @@ Selection::set (const TrackViewList& track_list)
bool changed = false;
CoreSelection::StripableAutomationControls sac;
selection.get_stripables (sac);
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
std::shared_ptr<Stripable> s = (*i)->stripable ();
std::shared_ptr<AutomationControl> c = (*i)->control ();
for (auto const & t : track_list) {
std::shared_ptr<Stripable> s = t->stripable ();
std::shared_ptr<AutomationControl> c = t->control ();
bool found = false;
for (CoreSelection::StripableAutomationControls::iterator j = sac.begin (); j != sac.end (); ++j) {
if (j->stripable == s && j->controllable == c) {
@ -1528,10 +1522,13 @@ Selection::set (const TrackViewList& track_list)
selection.clear_stripables ();
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
std::shared_ptr<Stripable> s = (*i)->stripable ();
std::shared_ptr<AutomationControl> c = (*i)->control ();
selection.add (s, c);
bool first = true;
for (auto const & t : track_list) {
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);
}
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
static void dump_tracks (Selection const & s)
{

View File

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

View File

@ -466,7 +466,7 @@ TrackRecordAxis::playlist_click (GdkEventButton* ev)
}
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);
return true;
@ -481,7 +481,7 @@ TrackRecordAxis::route_ops_click (GdkEventButton* ev)
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);
return true;