diff options
author | David Robillard <d@drobilla.net> | 2008-02-10 18:16:25 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-02-10 18:16:25 +0000 |
commit | 1b657585572298d1a69a7b43e611f59b7e185df3 (patch) | |
tree | 5b0ca4e1f222357499f97165a13308ac070c5ddc /gtk2_ardour/midi_region_view.cc | |
parent | e76b028ffdf054775cb697174d00cd0222d675c6 (diff) |
Committed underlay support (from Audun).
git-svn-id: svn://localhost/ardour2/branches/3.0@3037 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 61 |
1 files changed, 54 insertions, 7 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index a16da1448f..a8692af77a 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -380,6 +380,14 @@ MidiRegionView::clear_events() for (std::vector<CanvasMidiEvent*>::iterator i = _events.begin(); i != _events.end(); ++i) delete *i; + MidiGhostRegion* gr; + + for(vector<GhostRegion*>::iterator g = ghosts.begin(); g != ghosts.end(); ++g) { + if((gr = dynamic_cast<MidiGhostRegion*>(*g)) != 0) { + gr->clear_events(); + } + } + _events.clear(); } @@ -505,11 +513,23 @@ MidiRegionView::set_y_position_and_height (double y, double h) for (std::vector<CanvasMidiEvent*>::const_iterator i = _events.begin(); i != _events.end(); ++i) { CanvasNote* note = dynamic_cast<CanvasNote*>(*i); if (note && note->note()) { - const double y1 = midi_stream_view()->note_to_y(note->note()->note()); - const double y2 = y1 + floor(midi_stream_view()->note_height()); - - note->property_y1() = y1; - note->property_y2() = y2; + if(note->note()->note() < midi_stream_view()->lowest_note() || + note->note()->note() > midi_stream_view()->highest_note()) { + if(canvas_item_visible(note)) { + note->hide(); + } + } + else { + const double y1 = midi_stream_view()->note_to_y(note->note()->note()); + const double y2 = y1 + floor(midi_stream_view()->note_height()); + + if(!canvas_item_visible(note)) { + note->show(); + } + + note->property_y1() = y1; + note->property_y2() = y2; + } } } @@ -522,18 +542,37 @@ MidiRegionView::set_y_position_and_height (double y, double h) } GhostRegion* -MidiRegionView::add_ghost (AutomationTimeAxisView& atv) +MidiRegionView::add_ghost (TimeAxisView& tv) { RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview); + CanvasNote* note; assert(rtv); double unit_position = _region->position () / samples_per_unit; - GhostRegion* ghost = new GhostRegion (atv, unit_position); + MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&tv); + MidiGhostRegion* ghost; + + if(mtv && mtv->midi_view()) { + /* if ghost is inserted into midi track, use a dedicated midi ghost canvas group. + this is because it's nice to have midi notes on top of the note lines and + audio waveforms under it. + */ + ghost = new MidiGhostRegion (*mtv->midi_view(), trackview, unit_position); + } + else { + ghost = new MidiGhostRegion (tv, trackview, unit_position); + } ghost->set_height (); ghost->set_duration (_region->length() / samples_per_unit); ghosts.push_back (ghost); + for (std::vector<CanvasMidiEvent*>::iterator i = _events.begin(); i != _events.end(); ++i) { + if((note = dynamic_cast<CanvasNote*>(*i)) != 0) { + ghost->add_note(note); + } + } + ghost->GoingAway.connect (mem_fun(*this, &MidiRegionView::remove_ghost)); return ghost; @@ -638,6 +677,14 @@ MidiRegionView::add_note(const boost::shared_ptr<Note> note) ev_rect->show(); _events.push_back(ev_rect); + MidiGhostRegion* gr; + + for(vector<GhostRegion*>::iterator g = ghosts.begin(); g != ghosts.end(); ++g) { + if((gr = dynamic_cast<MidiGhostRegion*>(*g)) != 0) { + gr->add_note(ev_rect); + } + } + } else if (midi_view()->note_mode() == Percussive) { //cerr << "MRV::add_note percussive " << note->note() << " @ " << note->time() |