13
0

fixes to get redraws when note range changes

This commit is contained in:
Paul Davis 2024-01-12 12:51:13 -07:00
parent 3700f191cd
commit 3bd2d39d51
5 changed files with 40 additions and 19 deletions

View File

@ -21,9 +21,11 @@
*/ */
#include "midi_cue_background.h" #include "midi_cue_background.h"
#include "midi_view.h"
CueMidiBackground::CueMidiBackground (ArdourCanvas::Item* parent) CueMidiBackground::CueMidiBackground (ArdourCanvas::Item* parent)
: MidiViewBackground (parent) : MidiViewBackground (parent)
, view (nullptr)
, _width (0.) , _width (0.)
, _height (0.) , _height (0.)
{ {
@ -71,3 +73,17 @@ void
CueMidiBackground::record_layer_check (std::shared_ptr<ARDOUR::Region>, samplepos_t) CueMidiBackground::record_layer_check (std::shared_ptr<ARDOUR::Region>, samplepos_t)
{ {
} }
void
CueMidiBackground::set_view (MidiView* mv)
{
view = mv;
}
void
CueMidiBackground::apply_note_range_to_children ()
{
if (view) {
view->apply_note_range (lowest_note(), highest_note());
}
}

View File

@ -31,6 +31,8 @@
#include "midi_view_background.h" #include "midi_view_background.h"
class MidiView;
class CueMidiBackground : public MidiViewBackground class CueMidiBackground : public MidiViewBackground
{ {
public: public:
@ -45,11 +47,14 @@ class CueMidiBackground : public MidiViewBackground
void record_layer_check (std::shared_ptr<ARDOUR::Region>, samplepos_t); void record_layer_check (std::shared_ptr<ARDOUR::Region>, samplepos_t);
void set_size (double w, double h); void set_size (double w, double h);
void set_view (MidiView*);
protected: protected:
virtual void apply_note_range_to_children () {} MidiView* view;
double _width; double _width;
double _height; double _height;
void apply_note_range_to_children();
}; };

View File

@ -202,4 +202,6 @@ MidiCueEditor::set_region (std::shared_ptr<ARDOUR::MidiTrack> t, std::shared_ptr
view = new MidiView (t, *hv_scroll_group, *this, *bg, 0xff0000ff); view = new MidiView (t, *hv_scroll_group, *this, *bg, 0xff0000ff);
view->set_region (r); view->set_region (r);
bg->set_view (view);
} }

View File

@ -1003,8 +1003,6 @@ MidiView::redisplay (bool view_only)
void void
MidiView::model_changed() MidiView::model_changed()
{ {
std::cerr << "MC!\n";
if (!display_is_enabled()) { if (!display_is_enabled()) {
return; return;
} }
@ -1461,10 +1459,6 @@ MidiView::set_height (double ht)
void void
MidiView::apply_note_range (uint8_t min, uint8_t max, bool force) MidiView::apply_note_range (uint8_t min, uint8_t max, bool force)
{ {
if (!force && _midi_context.lowest_note() == min && _midi_context.highest_note() == max) {
return;
}
view_changed (); view_changed ();
} }
@ -1613,11 +1607,6 @@ MidiView::update_sustained (Note* ev, bool update_ghost_regions)
const double y0 = 1 + floor(note_to_y(note->note())); const double y0 = 1 + floor(note_to_y(note->note()));
double y1; double y1;
std::cerr << "Note: " << *note << std::endl;
std::cerr << "SSS " << session_source_start << std::endl;
std::cerr << "nh " << note_height() << std::endl;
std::cerr << "vs. " << (int) _midi_context.lowest_note() << " .. " << (int) _midi_context.highest_note() << std::endl;
if (note->length() == Temporal::Beats()) { if (note->length() == Temporal::Beats()) {
/* special case actual zero-length notes */ /* special case actual zero-length notes */
@ -1636,8 +1625,6 @@ MidiView::update_sustained (Note* ev, bool update_ghost_regions)
const samplepos_t note_end_samples = _midi_region->position().distance ((session_source_start + note_end)).samples(); const samplepos_t note_end_samples = _midi_region->position().distance ((session_source_start + note_end)).samples();
std::cerr << "nes: " << note_end_samples << " Z " << _editing_context.get_current_zoom() << std::endl;
x1 = std::max(1., _editing_context.sample_to_pixel (note_end_samples)); x1 = std::max(1., _editing_context.sample_to_pixel (note_end_samples));
} else { } else {
@ -1649,8 +1636,6 @@ MidiView::update_sustained (Note* ev, bool update_ghost_regions)
y1 = y0 + std::max(1., floor(note_height()) - 1); y1 = y0 + std::max(1., floor(note_height()) - 1);
std::cerr << "note rect " << ArdourCanvas::Rect (x0, y0, x1, y1) << std::endl;
ev->set (ArdourCanvas::Rect (x0, y0, x1, y1)); ev->set (ArdourCanvas::Rect (x0, y0, x1, y1));
ev->set_velocity (note->velocity()/127.0); ev->set_velocity (note->velocity()/127.0);

View File

@ -214,10 +214,23 @@ MidiViewBackground::set_note_range(VisibleNoteRange r)
} }
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)
{ {
_highest_note = highest; bool changed = false;
_lowest_note = lowest;
if (_highest_note != highest) {
_highest_note = highest;
changed = true;
}
if (_lowest_note != lowest) {
changed = true;
_lowest_note = lowest;
}
if (!changed) {
return;
}
float uiscale = UIConfiguration::instance().get_ui_scale(); float uiscale = UIConfiguration::instance().get_ui_scale();
uiscale = expf (uiscale) / expf (1.f); uiscale = expf (uiscale) / expf (1.f);