extend MidiViewBackground API
1. provide access to an EditingContext for use in piano roll headers 2. provide pre-computed note positions and heights for use in piano roll headers
This commit is contained in:
@@ -64,7 +64,7 @@ using namespace Editing;
|
||||
|
||||
MidiStreamView::MidiStreamView (MidiTimeAxisView& tv)
|
||||
: StreamView (tv)
|
||||
, MidiViewBackground (_canvas_group)
|
||||
, MidiViewBackground (_canvas_group, tv.editor())
|
||||
, _updates_suspended (false)
|
||||
{
|
||||
/* use a dedicated group for MIDI regions (on top of the grid and lines) */
|
||||
|
||||
@@ -135,7 +135,17 @@ MidiViewBackground::update_contents_height ()
|
||||
}
|
||||
|
||||
void
|
||||
MidiViewBackground::draw_note_lines()
|
||||
MidiViewBackground::get_note_positions (std::vector<int>& numbers, std::vector<int>& pos, std::vector<int>& heights) const
|
||||
{
|
||||
for (auto const & r : _note_lines->rects()) {
|
||||
numbers.push_back (r.index);
|
||||
pos.push_back (r.y0);
|
||||
heights.push_back (r.height());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MidiViewBackground::setup_note_lines()
|
||||
{
|
||||
if (updates_suspended()) {
|
||||
return;
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace ArdourCanvas {
|
||||
class RectSet;
|
||||
}
|
||||
|
||||
class EditingContext;
|
||||
|
||||
/** A class that provides various context for a MidiVieww:
|
||||
= note ranges
|
||||
* color information
|
||||
@@ -53,7 +55,7 @@ namespace ArdourCanvas {
|
||||
class MidiViewBackground : public virtual ViewBackground
|
||||
{
|
||||
public:
|
||||
MidiViewBackground (ArdourCanvas::Item* parent);
|
||||
MidiViewBackground (ArdourCanvas::Item* parent, EditingContext& ec);
|
||||
~MidiViewBackground ();
|
||||
|
||||
Gtk::Adjustment note_range_adjustment;
|
||||
@@ -125,7 +127,12 @@ class MidiViewBackground : public virtual ViewBackground
|
||||
|
||||
virtual ARDOUR::InstrumentInfo* instrument_info() const = 0;
|
||||
|
||||
void get_note_positions (std::vector<int>& numbers, std::vector<int>& pos, std::vector<int>& heights) const;
|
||||
|
||||
EditingContext& editing_context() const { return _editing_context; }
|
||||
|
||||
protected:
|
||||
EditingContext& _editing_context;
|
||||
bool _range_dirty;
|
||||
double _range_sum_cache;
|
||||
uint8_t _lowest_note; ///< currently visible
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "midi_view.h"
|
||||
|
||||
PianorollMidiBackground::PianorollMidiBackground (ArdourCanvas::Item* parent, Pianoroll& pr)
|
||||
: MidiViewBackground (parent)
|
||||
: MidiViewBackground (parent, pr)
|
||||
, view (nullptr)
|
||||
, pianoroll (pr)
|
||||
, _width (0.)
|
||||
|
||||
Reference in New Issue
Block a user