From 024dedc446640e871eaa506a9809ec474f2295b3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 3 Jun 2025 12:14:21 -0600 Subject: [PATCH] pianoroll: clarify and resolve some issues caused by confusion over what type the _view member has --- gtk2_ardour/piano_roll_header.cc | 18 +++++++++++++++++- gtk2_ardour/piano_roll_header.h | 5 +++++ gtk2_ardour/prh_base.cc | 27 ++++----------------------- gtk2_ardour/prh_base.h | 2 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/gtk2_ardour/piano_roll_header.cc b/gtk2_ardour/piano_roll_header.cc index 4d9dc9c4cc..8b751e9766 100644 --- a/gtk2_ardour/piano_roll_header.cc +++ b/gtk2_ardour/piano_roll_header.cc @@ -44,7 +44,10 @@ using namespace Gtkmm2ext; PianoRollHeader::PianoRollHeader (MidiViewBackground& bg) : PianoRollHeaderBase (bg) { - alloc_layouts (get_pango_context ()); + stream_view = dynamic_cast (&bg); + assert (stream_view); + + alloc_layouts (get_pango_context ()); _adj.set_lower(0); _adj.set_upper(127); @@ -153,3 +156,16 @@ PianoRollHeader::cursor_window() { return get_window (); } + +void +PianoRollHeader::instrument_info_change () +{ + PianoRollHeaderBase::instrument_info_change (); + + /* need this to get editor to potentially sync all + track header widths if our piano roll header changes + width. + */ + + stream_view->trackview().stripable()->gui_changed ("visible_tracks", (void *) 0); /* EMIT SIGNAL */ +} diff --git a/gtk2_ardour/piano_roll_header.h b/gtk2_ardour/piano_roll_header.h index 1a405c3485..64311c3a35 100644 --- a/gtk2_ardour/piano_roll_header.h +++ b/gtk2_ardour/piano_roll_header.h @@ -47,5 +47,10 @@ class PianoRollHeader : public Gtk::DrawingArea, public PianoRollHeaderBase { void do_grab() { add_modal_grab(); } void do_ungrab() { remove_modal_grab(); } Glib::RefPtr cursor_window(); + + void instrument_info_change (); + + private: + MidiStreamView* stream_view; }; diff --git a/gtk2_ardour/prh_base.cc b/gtk2_ardour/prh_base.cc index f0865b549c..dc33f11985 100644 --- a/gtk2_ardour/prh_base.cc +++ b/gtk2_ardour/prh_base.cc @@ -92,9 +92,7 @@ void PianoRollHeaderBase::set_view (MidiView* v) { _view = v; - if (_view) { - _view->midi_context().NoteRangeChanged.connect (sigc::mem_fun (*this, &PianoRollHeaderBase::note_range_changed)); - } + _midi_context.NoteRangeChanged.connect (sigc::mem_fun (*this, &PianoRollHeaderBase::note_range_changed)); } bool @@ -485,16 +483,6 @@ PianoRollHeaderBase::instrument_info_change () } _queue_resize (); - - /* need this to get editor to potentially sync all - track header widths if our piano roll header changes - width. - */ - - if (_view) { - _view->midi_track()->gui_changed ("visible_tracks", (void *) 0); /* EMIT SIGNAL */ - } - } PianoRollHeaderBase::NoteName @@ -645,17 +633,13 @@ PianoRollHeaderBase::button_press_handler (GdkEventButton* ev) double ignore; event_transform (ignore, evy); - if (!_view) { - return false; - } - /* Convert canvas-coordinates to item coordinates */ _scroomer_button_state = _scroomer_state; if (ev->button == 1 && ev->x <= _scroomer_size){ - if (ev->type == GDK_2BUTTON_PRESS) { + if (ev->type == GDK_2BUTTON_PRESS && _view) { _view->set_visibility_note_range (MidiStreamView::ContentsRange, false); return true; } @@ -780,11 +764,8 @@ PianoRollHeaderBase::enter_handler (GdkEventCrossing* ev) bool PianoRollHeaderBase::leave_handler (GdkEventCrossing*) { - if (!_scroomer_drag){ - if (_view) { - /* XXX we used to pop the cursor stack here */ - } - } + set_cursor (nullptr); + invalidate_note_range(_highlighted_note, _highlighted_note); if (_clicked_note != NO_MIDI_NOTE) { diff --git a/gtk2_ardour/prh_base.h b/gtk2_ardour/prh_base.h index 395f99155a..a5a2fd3268 100644 --- a/gtk2_ardour/prh_base.h +++ b/gtk2_ardour/prh_base.h @@ -47,7 +47,7 @@ class PianoRollHeaderBase : virtual public sigc::trackable { void render (ArdourCanvas::Rect const & self, ArdourCanvas::Rect const & area, Cairo::RefPtr) const; - void instrument_info_change (); + virtual void instrument_info_change (); void note_range_changed(); void set_note_highlight (uint8_t note);