fix some region-view level selection issues

This commit is contained in:
Paul Davis 2024-01-12 11:34:59 -07:00
parent 182a24751b
commit 3700f191cd
5 changed files with 53 additions and 12 deletions

View file

@ -749,3 +749,37 @@ MidiRegionView::drag_group () const
{
return get_canvas_group ();
}
void
MidiRegionView::select_self (bool add)
{
if (add) {
_editing_context.get_selection().add (this);
} else {
_editing_context.get_selection().set (this);
}
}
void
MidiRegionView::unselect_self ()
{
_editing_context.get_selection().remove (this);
}
void
MidiRegionView::begin_drag_edit (std::string const & why)
{
if (!_selected) {
/* unclear why gcc can't understand which version of
select_self() to use here, but so be it.
*/
MidiView::select_self ();
}
// start_note_diff_command (why);
}
void
MidiRegionView::select_self_uniquely ()
{
_editing_context.set_selected_midi_region_view (*this);
}

View file

@ -126,6 +126,10 @@ public:
void redisplay (bool);
ArdourCanvas::Item* drag_group() const;
void select_self (bool add);
void unselect_self ();
void select_self_uniquely ();
void begin_drag_edit (std::string const & why);
protected:
void reset_width_dependent_items (double pixel_width);

View file

@ -113,9 +113,9 @@ MidiView::MidiView (std::shared_ptr<MidiTrack> mt,
: _midi_track (mt)
, _editing_context (ec)
, _midi_context (bg)
, _active_notes(0)
, _active_notes (0)
, _note_group (new ArdourCanvas::Container (&parent))
, _note_diff_command (0)
, _note_diff_command (nullptr)
, _ghost_note(0)
, _step_edit_cursor (0)
, _step_edit_cursor_width (1, 0)
@ -123,7 +123,7 @@ MidiView::MidiView (std::shared_ptr<MidiTrack> mt,
, _mouse_state(None)
, _pressed_button(0)
, _optimization_iterator (_events.end())
, _list_editor (0)
, _list_editor (nullptr)
, _no_sound_notes (false)
, _last_display_zoom (0)
, _last_event_x (0)
@ -2066,7 +2066,7 @@ void
MidiView::clear_note_selection ()
{
clear_selection_internal ();
// XXXX _editing_context.get_selection().remove (this);
unselect_self ();
}
void
@ -2403,7 +2403,7 @@ MidiView::remove_from_selection (NoteBase* ev)
ghost_sync_selection (ev);
if (_selection.empty()) {
// XXXX _editing_context.get_selection().remove (this);
unselect_self ();
}
}
@ -2428,7 +2428,7 @@ MidiView::add_to_selection (NoteBase* ev)
* only apply to notes anyway, not regions.
*/
// XXX _editing_context.set_selected_midi_region_view (*this);
select_self_uniquely ();
}
if (_selection.insert (ev).second == true) {
@ -3173,8 +3173,6 @@ MidiView::change_note_length (NoteBase* event, Temporal::Beats t)
void
MidiView::begin_drag_edit (std::string const & why)
{
// XXXX _editing_context.get_selection().set (this, true);
start_note_diff_command (why);
}
void
@ -4079,7 +4077,7 @@ MidiView::maybe_select_by_position (GdkEventButton* ev, double /*x*/, double y)
}
if (add_mrv_selection) {
// XXXXX _editing_context.get_selection().add (this);
select_self (true);
}
}

View file

@ -173,7 +173,7 @@ class MidiView : public virtual sigc::trackable
void end_write();
void extend_active_notes();
void begin_drag_edit (std::string const & why);
virtual void begin_drag_edit (std::string const & why);
void end_drag_edit ();
void display_model(std::shared_ptr<ARDOUR::MidiModel> model);
@ -332,6 +332,11 @@ class MidiView : public virtual sigc::trackable
EditingContext& editing_context() const { return _editing_context; }
MidiViewBackground& midi_context() const { return _midi_context; }
virtual void select_self (bool add) {}
virtual void unselect_self () {}
void select_self () { select_self (false); }
virtual void select_self_uniquely () {}
protected:
void init ();
virtual void region_resized (const PBD::PropertyChange&);

View file

@ -1622,8 +1622,8 @@ Selection::midi_regions ()
{
MidiRegionSelection ms;
for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*i);
for (auto & r : regions) {
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(r);
if (mrv) {
ms.add (mrv);
}