diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 041e992b7a..4d5ce9a4cd 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -1063,8 +1063,6 @@ AutomationLine::get_inverted_selectables (Selection&, list& /*resul void AutomationLine::set_selected_points (PointSelection const & points) { - std::cerr << this << " AL::ssp\n"; - for (auto & cp : control_points) { cp->set_selected (false); } diff --git a/gtk2_ardour/cue_editor.cc b/gtk2_ardour/cue_editor.cc index 9926c90682..42021d9d0d 100644 --- a/gtk2_ardour/cue_editor.cc +++ b/gtk2_ardour/cue_editor.cc @@ -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 const &, ARDOUR::SelectionOperation, bool) -{ -} - void CueEditor::get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const { diff --git a/gtk2_ardour/cue_editor.h b/gtk2_ardour/cue_editor.h index 5375d905b3..51e980cafb 100644 --- a/gtk2_ardour/cue_editor.h +++ b/gtk2_ardour/cue_editor.h @@ -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 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) const; diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index 8161fdea47..81e5ea763d 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -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); } + diff --git a/gtk2_ardour/pianoroll.cc b/gtk2_ardour/pianoroll.cc index 4a0882cf56..4bb8ee7825 100644 --- a/gtk2_ardour/pianoroll.cc +++ b/gtk2_ardour/pianoroll.cc @@ -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 const & ignored, ARDOUR::SelectionOperation op, bool preserve_if_selected) +{ + std::list 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 (); +} diff --git a/gtk2_ardour/pianoroll.h b/gtk2_ardour/pianoroll.h index 3e93203225..24f7b8bec7 100644 --- a/gtk2_ardour/pianoroll.h +++ b/gtk2_ardour/pianoroll.h @@ -108,6 +108,7 @@ class Pianoroll : public CueEditor void midi_action (void (MidiView::*method)()); std::list selectable_owners(); + void select_all_within (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list const &, ARDOUR::SelectionOperation, bool); Gdk::Cursor* which_track_cursor () const; Gdk::Cursor* which_mode_cursor () const; diff --git a/gtk2_ardour/pianoroll_midi_view.cc b/gtk2_ardour/pianoroll_midi_view.cc index 6a7611e4d2..8eabcb2697 100644 --- a/gtk2_ardour/pianoroll_midi_view.cc +++ b/gtk2_ardour/pianoroll_midi_view.cc @@ -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); } } + diff --git a/gtk2_ardour/pianoroll_midi_view.h b/gtk2_ardour/pianoroll_midi_view.h index f1d00063d2..935c8eb613 100644 --- a/gtk2_ardour/pianoroll_midi_view.h +++ b/gtk2_ardour/pianoroll_midi_view.h @@ -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 selectable_owners();