pianoroll: clarify and resolve some issues caused by confusion over what type the _view member has

This commit is contained in:
Paul Davis 2025-06-03 12:14:21 -06:00
parent e23fdd5b8c
commit 024dedc446
4 changed files with 27 additions and 25 deletions

View file

@ -44,7 +44,10 @@ using namespace Gtkmm2ext;
PianoRollHeader::PianoRollHeader (MidiViewBackground& bg)
: PianoRollHeaderBase (bg)
{
alloc_layouts (get_pango_context ());
stream_view = dynamic_cast<MidiStreamView*> (&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 */
}

View file

@ -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<Gdk::Window> cursor_window();
void instrument_info_change ();
private:
MidiStreamView* stream_view;
};

View file

@ -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) {

View file

@ -47,7 +47,7 @@ class PianoRollHeaderBase : virtual public sigc::trackable {
void render (ArdourCanvas::Rect const & self, ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
void instrument_info_change ();
virtual void instrument_info_change ();
void note_range_changed();
void set_note_highlight (uint8_t note);