redraw (pianoroll) MidiView when note mode changes

This also fixes the position of the percussive mode canvas items
This commit is contained in:
Paul Davis 2025-01-15 10:34:40 -07:00
parent 5cb6a43eae
commit 5cade315fb
4 changed files with 22 additions and 4 deletions

View file

@ -190,6 +190,14 @@ MidiView::init (std::shared_ptr<MidiTrack> mt)
_note_group->raise_to_top();
EditingContext::DropDownKeys.connect (sigc::mem_fun (*this, &MidiView::drop_down_keys));
_midi_context.NoteRangeChanged.connect (sigc::mem_fun (*this, &MidiView::view_changed));
_midi_context.NoteModeChanged.connect (sigc::mem_fun (*this, &MidiView::note_mode_changed));
}
void
MidiView::note_mode_changed ()
{
clear_events ();
model_changed ();
}
void
@ -1862,9 +1870,15 @@ MidiView::update_hit (Hit* ev)
}
std::shared_ptr<NoteType> note = ev->note();
const timepos_t note_time = _midi_region->source_beats_to_absolute_time (note->time());
double x;
if (_midi_region && !_show_source) {
const timepos_t note_time = _midi_region->source_beats_to_absolute_time (note->time());
x = _editing_context.time_to_pixel(note_time) - _editing_context.time_to_pixel (_midi_region->position());
} else {
x = _editing_context.sample_to_pixel (timepos_t (note->time()).samples());
}
const double x = _editing_context.time_to_pixel(note_time) - _editing_context.time_to_pixel (_midi_region->position());
const double diamond_size = std::max(1., floor(note_height()) - 2.);
const double y = 1.5 + floor(note_to_y(note->note())) + diamond_size * .5;

View file

@ -633,6 +633,7 @@ class MidiView : public virtual sigc::trackable, public LineMerger
void update_sysexes ();
void view_changed ();
void model_changed ();
void note_mode_changed ();
void sync_ghost_selection (NoteBase*);

View file

@ -249,7 +249,6 @@ MidiViewBackground::apply_note_range (uint8_t lowest, uint8_t highest, bool to_c
{
bool changed = false;
if (_highest_note != highest) {
_highest_note = highest;
changed = true;
@ -323,5 +322,8 @@ MidiViewBackground::update_data_note_range (uint8_t min, uint8_t max)
void
MidiViewBackground::set_note_mode (ARDOUR::NoteMode nm)
{
_note_mode = nm;
if (_note_mode != nm) {
_note_mode = nm;
NoteModeChanged(); /* EMIT SIGNAL */
}
}

View file

@ -61,6 +61,7 @@ class MidiViewBackground : public virtual ViewBackground
ARDOUR::NoteMode note_mode() const { return _note_mode; }
void set_note_mode (ARDOUR::NoteMode nm);
sigc::signal<void> NoteModeChanged;
ARDOUR::ColorMode color_mode() const { return _color_mode; }
void set_color_mode (ARDOUR::ColorMode);