don't always adjust note range in a MidiView after a model change

This commit is contained in:
Paul Davis 2025-01-14 16:49:58 -07:00
parent 4e8591da99
commit 678ebca032
5 changed files with 24 additions and 3 deletions

View file

@ -1063,6 +1063,8 @@ AutomationLine::get_inverted_selectables (Selection&, list<Selectable*>& /*resul
void void
AutomationLine::set_selected_points (PointSelection const & points) AutomationLine::set_selected_points (PointSelection const & points)
{ {
std::cerr << this << " AL::ssp\n";
for (auto & cp : control_points) { for (auto & cp : control_points) {
cp->set_selected (false); cp->set_selected (false);
} }

View file

@ -1096,8 +1096,6 @@ MidiView::model_changed()
NoteBase* cne; NoteBase* cne;
std::cerr << "Now looking at a model with " << notes.size() << std::endl;
if (_midi_context.visibility_range_style() == MidiViewBackground::ContentsRange) { if (_midi_context.visibility_range_style() == MidiViewBackground::ContentsRange) {
uint8_t low_note = std::numeric_limits<uint8_t>::max(); uint8_t low_note = std::numeric_limits<uint8_t>::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) { 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); _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 void
MidiView::set_visibility_note_range (MidiViewBackground::VisibleNoteRange nvr, bool) MidiView::set_visibility_note_range (MidiViewBackground::VisibleNoteRange nvr, bool)
{ {

View file

@ -323,6 +323,7 @@ class MidiView : public virtual sigc::trackable, public LineMerger
void show_list_editor (); void show_list_editor ();
void set_note_range (uint8_t low, uint8_t high); 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); virtual void set_visibility_note_range (MidiViewBackground::VisibleNoteRange, bool);
typedef std::set<NoteBase*> Selection; typedef std::set<NoteBase*> Selection;

View file

@ -232,11 +232,24 @@ MidiViewBackground::maybe_extend_note_range (uint8_t note_num)
apply_note_range (_data_note_min, _data_note_max, true); 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 void
MidiViewBackground::apply_note_range (uint8_t lowest, uint8_t highest, bool to_children) MidiViewBackground::apply_note_range (uint8_t lowest, uint8_t highest, bool to_children)
{ {
bool changed = false; bool changed = false;
if (_highest_note != highest) { if (_highest_note != highest) {
_highest_note = highest; _highest_note = highest;
changed = true; changed = true;

View file

@ -91,6 +91,7 @@ class MidiViewBackground : public virtual ViewBackground
sigc::signal<void> NoteRangeChanged; sigc::signal<void> NoteRangeChanged;
void apply_note_range (uint8_t lowest, uint8_t highest, bool to_children); 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 */ /** @return y position, or -1 if hidden */
virtual double y_position () const { return 0.; } virtual double y_position () const { return 0.; }