From 678ebca03218f7a6455d21d068f75665b8d4eeb3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 14 Jan 2025 16:49:58 -0700 Subject: [PATCH] don't always adjust note range in a MidiView after a model change --- gtk2_ardour/automation_line.cc | 2 ++ gtk2_ardour/midi_view.cc | 10 +++++++--- gtk2_ardour/midi_view.h | 1 + gtk2_ardour/midi_view_background.cc | 13 +++++++++++++ gtk2_ardour/midi_view_background.h | 1 + 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 4d5ce9a4cd..041e992b7a 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -1063,6 +1063,8 @@ 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/midi_view.cc b/gtk2_ardour/midi_view.cc index 1d78829f98..3b55375398 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -1096,8 +1096,6 @@ MidiView::model_changed() NoteBase* cne; - std::cerr << "Now looking at a model with " << notes.size() << std::endl; - if (_midi_context.visibility_range_style() == MidiViewBackground::ContentsRange) { uint8_t low_note = std::numeric_limits::max(); @@ -1112,7 +1110,7 @@ MidiView::model_changed() } } - set_note_range (low_note, hi_note); + maybe_set_note_range (low_note, hi_note); } for (MidiModel::Notes::iterator n = notes.begin(); n != notes.end(); ++n) { @@ -5155,6 +5153,12 @@ MidiView::set_note_range (uint8_t low, uint8_t high) _midi_context.apply_note_range (low, high, true); } +void +MidiView::maybe_set_note_range (uint8_t low, uint8_t high) +{ + _midi_context.maybe_apply_note_range (low, high, true); +} + void MidiView::set_visibility_note_range (MidiViewBackground::VisibleNoteRange nvr, bool) { diff --git a/gtk2_ardour/midi_view.h b/gtk2_ardour/midi_view.h index 72b7bd9b14..78126cb4bb 100644 --- a/gtk2_ardour/midi_view.h +++ b/gtk2_ardour/midi_view.h @@ -323,6 +323,7 @@ class MidiView : public virtual sigc::trackable, public LineMerger void show_list_editor (); void set_note_range (uint8_t low, uint8_t high); + void maybe_set_note_range (uint8_t low, uint8_t high); virtual void set_visibility_note_range (MidiViewBackground::VisibleNoteRange, bool); typedef std::set Selection; diff --git a/gtk2_ardour/midi_view_background.cc b/gtk2_ardour/midi_view_background.cc index 99e78c6035..1ab5c6517c 100644 --- a/gtk2_ardour/midi_view_background.cc +++ b/gtk2_ardour/midi_view_background.cc @@ -232,11 +232,24 @@ MidiViewBackground::maybe_extend_note_range (uint8_t note_num) apply_note_range (_data_note_min, _data_note_max, true); } } + +void +MidiViewBackground::maybe_apply_note_range (uint8_t lowest, uint8_t highest, bool to_children) +{ + if (_lowest_note <= lowest && _highest_note >= highest) { + /* already large enough */ + return; + } + + apply_note_range (lowest, highest, to_children); +} + void MidiViewBackground::apply_note_range (uint8_t lowest, uint8_t highest, bool to_children) { bool changed = false; + if (_highest_note != highest) { _highest_note = highest; changed = true; diff --git a/gtk2_ardour/midi_view_background.h b/gtk2_ardour/midi_view_background.h index 77a7088574..5811c8fcca 100644 --- a/gtk2_ardour/midi_view_background.h +++ b/gtk2_ardour/midi_view_background.h @@ -91,6 +91,7 @@ class MidiViewBackground : public virtual ViewBackground sigc::signal NoteRangeChanged; void apply_note_range (uint8_t lowest, uint8_t highest, bool to_children); + void maybe_apply_note_range (uint8_t lowest, uint8_t highest, bool to_children); /** @return y position, or -1 if hidden */ virtual double y_position () const { return 0.; }