+
+MidiGhostRegion::Note::~Note()
+{
+ //delete rect;
+}
+
+void
+MidiGhostRegion::Note::x_changed()
+{
+ rect->property_x1() = event->x1();
+ rect->property_x2() = event->x2();
+}
+
+MidiGhostRegion::Hit::Hit(ArdourCanvas::CanvasHit* h, ArdourCanvas::Group*)
+ : Event(h)
+{
+ cerr << "Hit ghost item does not work yet" << endl;
+}
+
+MidiGhostRegion::Hit::~Hit()
+{
+}
+
+void
+MidiGhostRegion::Hit::x_changed()
+{
+}
+
+void
+MidiGhostRegion::set_samples_per_unit (double spu)
+{
+}
+
+MidiStreamView*
+MidiGhostRegion::midi_view()
+{
+ MidiTimeAxisView* mtv;
+
+ if ((mtv = dynamic_cast<MidiTimeAxisView*>(&trackview)) != 0) {
+ return mtv->midi_view();
+ }
+ else {
+ return 0;
+ }
+}
+
+void
+MidiGhostRegion::set_height()
+{
+ GhostRegion::set_height();
+ update_range();
+}
+
+void
+MidiGhostRegion::set_colors()
+{
+ MidiGhostRegion::Note* note;
+ guint fill = source_track_color(200);
+
+ GhostRegion::set_colors();
+
+ for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
+ if ((note = dynamic_cast<MidiGhostRegion::Note*>(*it)) != 0) {
+ note->rect->property_fill_color_rgba() = fill;
+ note->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackMidiOutline.get();
+ }
+ }
+}
+
+void
+MidiGhostRegion::update_range()
+{
+ MidiStreamView* mv = midi_view();
+
+ if (!mv) {
+ return;
+ }
+
+ MidiGhostRegion::Note* note;
+ uint8_t note_num;
+ double y;
+
+ for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
+ if ((note = dynamic_cast<MidiGhostRegion::Note*>(*it)) != 0) {
+ note_num = note->event->note()->note();
+
+ if (note_num < mv->lowest_note() || note_num > mv->highest_note()) {
+ note->rect->hide();
+ }
+ else {
+ note->rect->show();
+ y = mv->note_to_y(note_num);
+ note->rect->property_y1() = y;
+ note->rect->property_y2() = y + mv->note_height();
+ }
+ }
+ }
+}
+
+void
+MidiGhostRegion::add_note(ArdourCanvas::CanvasNote* n)
+{
+ Note* note = new Note(n, group);
+ events.push_back(note);
+
+ note->rect->property_fill_color_rgba() = source_track_color(200);
+ note->rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_GhostTrackMidiOutline.get();
+
+ MidiStreamView* mv = midi_view();
+
+ if (mv) {
+ const uint8_t note_num = n->note()->note();
+
+ if (note_num < mv->lowest_note() || note_num > mv->highest_note()) {
+ note->rect->hide();
+ } else {
+ const double y = mv->note_to_y(note_num);
+ note->rect->property_y1() = y;
+ note->rect->property_y2() = y + mv->note_height();
+ }
+ }
+}
+
+void
+MidiGhostRegion::add_hit(ArdourCanvas::CanvasHit* h)
+{
+ //events.push_back(new Hit(h, group));
+}
+
+void
+MidiGhostRegion::clear_events()
+{
+ for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
+ delete *it;
+ }
+
+ events.clear();
+}
+