some API tweaks, code movement and code implementation to make rbselect for pianoroll automation work

This commit is contained in:
Paul Davis 2025-01-19 15:04:51 -07:00
parent 801b8b2f1e
commit f052c3ae15
8 changed files with 104 additions and 9 deletions

View file

@ -1063,8 +1063,6 @@ AutomationLine::get_inverted_selectables (Selection&, list<Selectable*>& /*resul
void
AutomationLine::set_selected_points (PointSelection const & points)
{
std::cerr << this << " AL::ssp\n";
for (auto & cp : control_points) {
cp->set_selected (false);
}

View file

@ -29,11 +29,6 @@ CueEditor::filter_to_unique_midi_region_views (RegionSelection const & ms) const
return mrv;
}
void
CueEditor::select_all_within (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list<SelectableOwner*> const &, ARDOUR::SelectionOperation, bool)
{
}
void
CueEditor::get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const
{

View file

@ -29,8 +29,6 @@ class CueEditor : public EditingContext, public PBD::HistoryOwner, public sigc::
CueEditor (std::string const & name);
~CueEditor ();
void select_all_within (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list<SelectableOwner*> const &, ARDOUR::SelectionOperation, bool);
void get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const;
StripableTimeAxisView* get_stripable_time_axis_by_id (const PBD::ID& id) const;
TrackViewList axis_views_from_routes (std::shared_ptr<ARDOUR::RouteList>) const;

View file

@ -5302,3 +5302,4 @@ EndBoundaryRect::compute_bounding_box() const
const double radius = 10. * scale;
_bounding_box = _bounding_box.expand (0., 0., 0., radius + _outline_width);
}

View file

@ -2199,3 +2199,85 @@ Pianoroll::cut_copy (Editing::CutCopyOp op)
_drags->abort ();
}
}
void
Pianoroll::select_all_within (Temporal::timepos_t const & start, Temporal::timepos_t const & end, double y0, double y1, std::list<SelectableOwner*> const & ignored, ARDOUR::SelectionOperation op, bool preserve_if_selected)
{
std::list<Selectable*> found;
if (!view) {
return;
}
AutomationLine* al = view->active_automation_line();
if (!al) {
return;
}
double topfrac;
double botfrac;
/* translate y0 and y1 to use the top of the automation area as the * origin */
double automation_origin = view->automation_group_position().y;
y0 -= automation_origin;
y1 -= automation_origin;
if (y0 < 0. && al->height() <= y1) {
/* _y_position is below top, mybot is above bot, so we're fully
covered vertically.
*/
topfrac = 1.0;
botfrac = 0.0;
} else {
/* top and bot are within _y_position .. mybot */
topfrac = 1.0 - (y0 / al->height());
botfrac = 1.0 - (y1 / al->height());
}
al->get_selectables (start, end, botfrac, topfrac, found);
if (found.empty()) {
view->clear_selection ();
return;
}
if (preserve_if_selected && op != SelectionToggle) {
auto i = found.begin();
while (i != found.end() && (*i)->selected()) {
++i;
}
if (i == found.end()) {
return;
}
}
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;
default:
return;
}
commit_reversible_selection_op ();
}

View file

@ -108,6 +108,7 @@ class Pianoroll : public CueEditor
void midi_action (void (MidiView::*method)());
std::list<SelectableOwner*> selectable_owners();
void select_all_within (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list<SelectableOwner*> const &, ARDOUR::SelectionOperation, bool);
Gdk::Cursor* which_track_cursor () const;
Gdk::Cursor* which_mode_cursor () const;

View file

@ -151,6 +151,22 @@ PianorollMidiView::set_height (double h)
view_changed ();
}
ArdourCanvas::Duple
PianorollMidiView::automation_group_position() const
{
return automation_group->position();
}
AutomationLine*
PianorollMidiView::active_automation_line() const
{
if (active_automation) {
return active_automation->line.get();
}
return nullptr;
}
ArdourCanvas::Item*
PianorollMidiView::drag_group () const
{
@ -642,3 +658,4 @@ PianorollMidiView::clear_selection ()
i->second.line->set_selected_points (empty);
}
}

View file

@ -66,6 +66,9 @@ class PianorollMidiView : public MidiView
bool is_active_automation (Evoral::Parameter const &) const;
bool is_visible_automation (Evoral::Parameter const &) const;
AutomationLine* active_automation_line() const;
ArdourCanvas::Duple automation_group_position() const;
ArdourCanvas::Item* drag_group() const;
std::list<SelectableOwner*> selectable_owners();