vtl: use ArdourImage
[ardour.git] / gtk2_ardour / midi_region_view.cc
index 056665eefd04a1ef6b0b2cc3870329364e949733..3b8e688ad3e4b03c1bf446d2f56901d476cb7161 100644 (file)
@@ -82,7 +82,6 @@
 using namespace ARDOUR;
 using namespace PBD;
 using namespace Editing;
-using namespace ArdourCanvas;
 using Gtkmm2ext::Keyboard;
 
 PBD::Signal1<void, MidiRegionView *> MidiRegionView::SelectionCleared;
@@ -243,10 +242,10 @@ MidiRegionView::init (Gdk::Color const & basic_color, bool wfd)
 {
        PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
 
-       NoteBase::CanvasNoteEventDeleted.connect (note_delete_connection, MISSING_INVALIDATOR,
-                                                 boost::bind (&MidiRegionView::maybe_remove_deleted_note_from_selection, this, _1),
-                                                 gui_context());
-
+       NoteBase::NoteBaseDeleted.connect (note_delete_connection, MISSING_INVALIDATOR,
+                                          boost::bind (&MidiRegionView::maybe_remove_deleted_note_from_selection, this, _1),
+                                          gui_context());
+       
        if (wfd) {
                midi_region()->midi_source(0)->load_model();
        }
@@ -531,7 +530,7 @@ MidiRegionView::button_release (GdkEventButton* ev)
                                        group->canvas_to_item (event_x, event_y);
 
                                        bool success;
-                                       Evoral::MusicalTime beats = editor.get_grid_type_as_beats (success, editor.pixel_to_frame (event_x));
+                                       Evoral::MusicalTime beats = editor.get_grid_type_as_beats (success, editor.pixel_to_sample (event_x));
 
                                        if (!success) {
                                                beats = 1;
@@ -542,7 +541,7 @@ MidiRegionView::button_release (GdkEventButton* ev)
                                        */
                                        beats -= 1.0 / Timecode::BBT_Time::ticks_per_beat;
 
-                                       create_note_at (editor.pixel_to_frame (event_x), event_y, beats, true);
+                                       create_note_at (editor.pixel_to_sample (event_x), event_y, beats, true);
                                }
 
                                break;
@@ -550,7 +549,7 @@ MidiRegionView::button_release (GdkEventButton* ev)
                case MouseDraw:
                        {
                                bool success;
-                               Evoral::MusicalTime beats = editor.get_grid_type_as_beats (success, editor.pixel_to_frame (event_x));
+                               Evoral::MusicalTime beats = editor.get_grid_type_as_beats (success, editor.pixel_to_sample (event_x));
 
                                if (!success) {
                                        beats = 1;
@@ -561,7 +560,7 @@ MidiRegionView::button_release (GdkEventButton* ev)
                                */
                                beats -= 1.0 / Timecode::BBT_Time::ticks_per_beat;
                                
-                               create_note_at (editor.pixel_to_frame (event_x), event_y, beats, true);
+                               create_note_at (editor.pixel_to_sample (event_x), event_y, beats, true);
 
                                break;
                        }
@@ -1005,7 +1004,7 @@ MidiRegionView::note_diff_remove_note (NoteBase* ev)
 }
 
 void
-MidiRegionView::note_diff_add_change (ArdourCanvas::CanvasNoteEvent* ev,
+MidiRegionView::note_diff_add_change (NoteBase* ev,
                                       MidiModel::NoteDiffCommand::Property property,
                                       uint8_t val)
 {
@@ -1015,7 +1014,7 @@ MidiRegionView::note_diff_add_change (ArdourCanvas::CanvasNoteEvent* ev,
 }
 
 void
-MidiRegionView::note_diff_add_change (ArdourCanvas::CanvasNoteEvent* ev,
+MidiRegionView::note_diff_add_change (NoteBase* ev,
                                       MidiModel::NoteDiffCommand::Property property,
                                       Evoral::MusicalTime val)
 {
@@ -1091,7 +1090,7 @@ MidiRegionView::get_events (Events& e, Evoral::Sequence<Evoral::MusicalTime>::No
        _model->get_notes (notes, op, val, chan_mask);
 
        for (MidiModel::Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
-               CanvasNoteEvent* cne = find_canvas_note (*n);
+               NoteBase* cne = find_canvas_note (*n);
                if (cne) {
                        e.push_back (cne);
                }
@@ -1119,6 +1118,8 @@ MidiRegionView::redisplay_model()
        MidiModel::Notes& notes (_model->notes());
        _optimization_iterator = _events.begin();
 
+       bool empty_when_starting = !_events.empty();
+
        for (MidiModel::Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
 
                boost::shared_ptr<NoteType> note (*n);
@@ -1127,7 +1128,7 @@ MidiRegionView::redisplay_model()
 
                if (note_in_region_range (note, visible)) {
 
-                       if ((cne = find_canvas_note (note)) != 0) {
+                       if (empty_when_starting && (cne = find_canvas_note (note)) != 0) {
 
                                cne->validate ();
 
@@ -1153,7 +1154,7 @@ MidiRegionView::redisplay_model()
 
                } else {
 
-                       if ((cne = find_canvas_note (note)) != 0) {
+                       if (empty_when_starting && (cne = find_canvas_note (note)) != 0) {
                                cne->validate ();
                                cne->hide ();
                        }
@@ -1163,21 +1164,23 @@ MidiRegionView::redisplay_model()
 
        /* remove note items that are no longer valid */
 
-       for (Events::iterator i = _events.begin(); i != _events.end(); ) {
-               if (!(*i)->valid ()) {
-
-                       for (vector<GhostRegion*>::iterator j = ghosts.begin(); j != ghosts.end(); ++j) {
-                               MidiGhostRegion* gr = dynamic_cast<MidiGhostRegion*> (*j);
-                               if (gr) {
-                                       gr->remove_note (*i);
+       if (empty_when_starting) {
+               for (Events::iterator i = _events.begin(); i != _events.end(); ) {
+                       if (!(*i)->valid ()) {
+                               
+                               for (vector<GhostRegion*>::iterator j = ghosts.begin(); j != ghosts.end(); ++j) {
+                                       MidiGhostRegion* gr = dynamic_cast<MidiGhostRegion*> (*j);
+                                       if (gr) {
+                                               gr->remove_note (*i);
+                                       }
                                }
+                               
+                               delete *i;
+                               i = _events.erase (i);
+                               
+                       } else {
+                               ++i;
                        }
-                       
-                       delete *i;
-                       i = _events.erase (i);
-                       
-               } else {
-                       ++i;
                }
        }
 
@@ -1291,12 +1294,15 @@ MidiRegionView::display_sysexes()
                }
                string text = str.str();
 
-               const double x = trackview.editor().frame_to_pixel(source_beats_to_region_frames(time));
+               const double x = trackview.editor().sample_to_pixel(source_beats_to_region_frames(time));
 
                double height = midi_stream_view()->contents_height();
 
-               boost::shared_ptr<CanvasSysEx> sysex = boost::shared_ptr<CanvasSysEx>(
-                       new CanvasSysEx(*this, *_note_group, text, height, x, 1.0, (*i)));
+               // CAIROCANVAS: no longer passing *i (the sysex event) to the
+               // SysEx canvas object!!!
+
+               boost::shared_ptr<SysEx> sysex = boost::shared_ptr<SysEx>(
+                       new SysEx (*this, _note_group, text, height, x, 1.0));
 
                // Show unless message is beyond the region bounds
                if (time - _region->start() >= _region->length() || time < _region->start()) {
@@ -1359,7 +1365,7 @@ MidiRegionView::reset_width_dependent_items (double pixel_width)
        }
 
        for (PatchChanges::iterator x = _patch_changes.begin(); x != _patch_changes.end(); ++x) {
-               if ((*x)->width() >= _pixel_width) {
+               if ((*x)->canvas_item()->width() >= _pixel_width) {
                        (*x)->hide();
                } else {
                        (*x)->show();
@@ -1382,8 +1388,8 @@ MidiRegionView::set_height (double height)
                         midi_stream_view()->highest_note(),
                         height != old_height + FUDGE);
 
-       if (name_pixbuf) {
-               name_pixbuf->raise_to_top();
+       if (name_text) {
+               name_text->raise_to_top();
        }
 
        for (PatchChanges::iterator x = _patch_changes.begin(); x != _patch_changes.end(); ++x) {
@@ -1446,7 +1452,7 @@ MidiRegionView::add_ghost (TimeAxisView& tv)
 {
        Note* note;
 
-       double unit_position = _region->position () / frames_per_pixel;
+       double unit_position = _region->position () / samples_per_pixel;
        MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&tv);
        MidiGhostRegion* ghost;
 
@@ -1466,7 +1472,7 @@ MidiRegionView::add_ghost (TimeAxisView& tv)
        }
 
        ghost->set_height ();
-       ghost->set_duration (_region->length() / frames_per_pixel);
+       ghost->set_duration (_region->length() / samples_per_pixel);
        ghosts.push_back (ghost);
 
        GhostRegion::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RegionView::remove_ghost, this, _1), gui_context());
@@ -1519,7 +1525,7 @@ MidiRegionView::resolve_note(uint8_t note, double end_time)
                */
                const framepos_t end_time_frames = region_beats_to_region_frames(end_time);
 
-               _active_notes[note]->set_x1 (trackview.editor().frame_to_pixel(end_time_frames));
+               _active_notes[note]->set_x1 (trackview.editor().sample_to_pixel(end_time_frames));
                _active_notes[note]->set_outline_what (0xf);
                _active_notes[note] = 0;
        }
@@ -1537,7 +1543,7 @@ MidiRegionView::extend_active_notes()
 
        for (unsigned i=0; i < 128; ++i) {
                if (_active_notes[i]) {
-                       _active_notes[i]->set_x1 (trackview.editor().frame_to_pixel(_region->length()));
+                       _active_notes[i]->set_x1 (trackview.editor().sample_to_pixel(_region->length()));
                }
        }
 }
@@ -1626,7 +1632,7 @@ void
 MidiRegionView::update_note (Note* ev, bool update_ghost_regions)
 {
        boost::shared_ptr<NoteType> note = ev->note();
-       const double x = trackview.editor().frame_to_pixel (source_beats_to_region_frames (note->time()));
+       const double x = trackview.editor().sample_to_pixel (source_beats_to_region_frames (note->time()));
        const double y0 = midi_stream_view()->note_to_y(note->note());
 
        ev->set_x0 (x);
@@ -1636,9 +1642,9 @@ MidiRegionView::update_note (Note* ev, bool update_ghost_regions)
 
        if (note->length() > 0) {
                const framepos_t note_end_frames = min (source_beats_to_region_frames (note->end_time()), _region->length());
-               ev->set_x1 (trackview.editor().frame_to_pixel (note_end_frames));
+               ev->set_x1 (trackview.editor().sample_to_pixel (note_end_frames));
        } else {
-               ev->set_x1 (trackview.editor().frame_to_pixel (_region->length()));
+               ev->set_x1 (trackview.editor().sample_to_pixel (_region->length()));
        }
 
        ev->set_y1 (y0 + floor(midi_stream_view()->note_height()));
@@ -1678,7 +1684,7 @@ MidiRegionView::update_hit (Hit* ev)
        boost::shared_ptr<NoteType> note = ev->note();
 
        const framepos_t note_start_frames = source_beats_to_region_frames(note->time());
-       const double x = trackview.editor().frame_to_pixel(note_start_frames);
+       const double x = trackview.editor().sample_to_pixel(note_start_frames);
        const double diamond_size = midi_stream_view()->note_height() / 2.0;
        const double y = midi_stream_view()->note_to_y(note->note()) + ((diamond_size-2) / 4.0);
 
@@ -1720,7 +1726,7 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible)
 
                const double diamond_size = midi_stream_view()->note_height() / 2.0;
 
-               Hit* ev_diamond = new CanvasHit (*this, _note_group, diamond_size, note);
+               Hit* ev_diamond = new Hit (*this, _note_group, diamond_size, note);
 
                update_hit (ev_diamond);
 
@@ -1797,23 +1803,27 @@ MidiRegionView::step_sustain (Evoral::MusicalTime beats)
  * @param active_channel true to display the flag as on an active channel, false to grey it out for an inactive channel.
  */
 void
-MidiRegionView::add_canvas_patch_change (MidiModel::PatchChangePtr patch, const string& displaytext, bool active_channel)
+MidiRegionView::add_canvas_patch_change (MidiModel::PatchChangePtr patch, const string& displaytext, bool /*active_channel*/)
 {
        framecnt_t region_frames = source_beats_to_region_frames (patch->time());
-       const double x = trackview.editor().frame_to_pixel (region_frames);
+       const double x = trackview.editor().sample_to_pixel (region_frames);
 
        double const height = midi_stream_view()->contents_height();
 
-       boost::shared_ptr<CanvasPatchChange> patch_change = boost::shared_ptr<CanvasPatchChange>(
-               new CanvasPatchChange(*this, group,
-                                     displaytext,
-                                     height,
-                                     x, 1.0,
-                                     instrument_info(),
-                                     patch,
-                                     active_channel));
+       // CAIROCANVAS: active_channel info removed from PatcChange constructor
+       // so we need to do something more sophisticated to keep its color
+       // appearance (MidiPatchChangeFill/MidiPatchChangeInactiveChannelFill)
+       // up to date.
+
+       boost::shared_ptr<PatchChange> patch_change = boost::shared_ptr<PatchChange>(
+               new PatchChange(*this, group,
+                               displaytext,
+                               height,
+                               x, 1.0,
+                               instrument_info(),
+                               patch));
 
-       if (patch_change->width() < _pixel_width) {
+       if (patch_change->item().width() < _pixel_width) {
                // Show unless patch change is beyond the region bounds
                if (region_frames < 0 || region_frames >= _region->length()) {
                        patch_change->hide();
@@ -1981,7 +1991,7 @@ MidiRegionView::next_patch (PatchChange& patch)
 }
 
 void
-MidiRegionView::next_bank (CanvasPatchChange& patch)
+MidiRegionView::next_bank (PatchChange& patch)
 {
        if (patch.patch()->program() < 127) {
                MIDI::Name::PatchPrimaryKey key = patch_change_to_patch_key (patch.patch());
@@ -1993,7 +2003,7 @@ MidiRegionView::next_bank (CanvasPatchChange& patch)
 }
 
 void
-MidiRegionView::previous_bank (CanvasPatchChange& patch)
+MidiRegionView::previous_bank (PatchChange& patch)
 {
        if (patch.patch()->program() > 0) {
                MIDI::Name::PatchPrimaryKey key = patch_change_to_patch_key (patch.patch());
@@ -2271,14 +2281,14 @@ MidiRegionView::note_deselected(NoteBase* ev)
 }
 
 void
-MidiRegionView::update_drag_selection(double x1, double x2, double y1, double y2, bool extend)
+MidiRegionView::update_drag_selection(double x0, double x1, double y0, double y1, bool extend)
 {
        // TODO: Make this faster by storing the last updated selection rect, and only
        // adjusting things that are in the area that appears/disappeared.
        // We probably need a tree to be able to find events in O(log(n)) time.
 
        for (Events::iterator i = _events.begin(); i != _events.end(); ++i) {
-               if ((*i)->x1() < x2 && (*i)->x2() > x1 && (*i)->y1() < y2 && (*i)->y2() > y1) {
+               if ((*i)->x0() < x1 && (*i)->x1() > x0 && (*i)->y0() < y1 && (*i)->y1() > y0) {
                        // Rectangles intersect
                        if (!(*i)->selected()) {
                                add_to_selection (*i);
@@ -2462,10 +2472,10 @@ MidiRegionView::note_dropped(NoteBase *, frameoffset_t dt, int8_t dnote)
  *  @return Snapped frame relative to the region position.
  */
 framepos_t
-MidiRegionView::snap_pixel_to_frame(double x)
+MidiRegionView::snap_pixel_to_sample(double x)
 {
        PublicEditor& editor (trackview.editor());
-       return snap_frame_to_frame (editor.pixel_to_frame (x));
+       return snap_frame_to_frame (editor.pixel_to_sample (x));
 }
 
 /** @param x Pixel relative to the region position.
@@ -2474,21 +2484,21 @@ MidiRegionView::snap_pixel_to_frame(double x)
 double
 MidiRegionView::snap_to_pixel(double x)
 {
-       return (double) trackview.editor().frame_to_pixel(snap_pixel_to_frame(x));
+       return (double) trackview.editor().sample_to_pixel(snap_pixel_to_sample(x));
 }
 
 double
 MidiRegionView::get_position_pixels()
 {
        framepos_t region_frame = get_position();
-       return trackview.editor().frame_to_pixel(region_frame);
+       return trackview.editor().sample_to_pixel(region_frame);
 }
 
 double
 MidiRegionView::get_end_position_pixels()
 {
        framepos_t frame = get_position() + get_duration ();
-       return trackview.editor().frame_to_pixel(frame);
+       return trackview.editor().sample_to_pixel(frame);
 }
 
 framepos_t
@@ -2531,7 +2541,7 @@ MidiRegionView::begin_resizing (bool /*at_front*/)
        _resize_data.clear();
 
        for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
-               Note *note = dynamic_cast<Note**> (*i);
+               Note *note = dynamic_cast<Note*> (*i);
 
                // only insert CanvasNotes into the map
                if (note) {
@@ -2539,7 +2549,8 @@ MidiRegionView::begin_resizing (bool /*at_front*/)
                        resize_data->note = note;
 
                        // create a new SimpleRect from the note which will be the resize preview
-                       Rectangle *resize_rect = new SimpleRect (_note_group, note->x1(), note->y1(), note->x2(), note->y2());
+                       ArdourCanvas::Rectangle *resize_rect = new ArdourCanvas::Rectangle (_note_group, 
+                                                                                           ArdourCanvas::Rect (note->x0(), note->y0(), note->x0(), note->y1()));
 
                        // calculate the colors: get the color settings
                        uint32_t fill_color = UINT_RGBA_CHANGE_A(
@@ -2551,7 +2562,7 @@ MidiRegionView::begin_resizing (bool /*at_front*/)
 
                        // calculate color based on note velocity
                        resize_rect->set_fill_color (UINT_INTERPOLATE(
-                               CanvasNoteEvent::meter_style_fill_color(note->note()->velocity(), note->selected()),
+                               NoteBase::meter_style_fill_color(note->note()->velocity(), note->selected()),
                                fill_color,
                                0.85));
 
@@ -2579,19 +2590,19 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_
        bool cursor_set = false;
 
        for (std::vector<NoteResizeData *>::iterator i = _resize_data.begin(); i != _resize_data.end(); ++i) {
-               Rectangle* resize_rect = (*i)->resize_rect;
+               ArdourCanvas::Rectangle* resize_rect = (*i)->resize_rect;
                Note* canvas_note = (*i)->note;
                double current_x;
 
                if (at_front) {
                        if (relative) {
-                               current_x = note->x0() + delta_x;
+                               current_x = canvas_note->x0() + delta_x;
                        } else {
                                current_x = primary->x0() + delta_x;
                        }
                } else {
                        if (relative) {
-                               current_x = note->x1() + delta_x;
+                               current_x = canvas_note->x1() + delta_x;
                        } else {
                                current_x = primary->x1() + delta_x;
                        }
@@ -2608,7 +2619,7 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_
                if (!cursor_set) {
                        double beats;
 
-                       beats = snap_pixel_to_frame (current_x);
+                       beats = snap_pixel_to_sample (current_x);
                        beats = region_frames_to_region_beats (beats);
 
                        double len;
@@ -2649,7 +2660,7 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_
 
        for (std::vector<NoteResizeData *>::iterator i = _resize_data.begin(); i != _resize_data.end(); ++i) {
                Note*  canvas_note = (*i)->note;
-               Rectangle*  resize_rect = (*i)->resize_rect;
+               ArdourCanvas::Rectangle*  resize_rect = (*i)->resize_rect;
 
                /* Get the new x position for this resize, which is in pixels relative
                 * to the region position.
@@ -2659,20 +2670,20 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_
 
                if (at_front) {
                        if (relative) {
-                               current_x = note->x0() + delta_x;
+                               current_x = canvas_note->x0() + delta_x;
                        } else {
                                current_x = primary->x0() + delta_x;
                        }
                } else {
                        if (relative) {
-                               current_x = note->x1() + delta_x;
+                               current_x = canvas_note->x1() + delta_x;
                        } else {
                                current_x = primary->x1() + delta_x;
                        }
                }
 
                /* Convert that to a frame within the source */
-               current_x = snap_pixel_to_frame (current_x) + _region->start ();
+               current_x = snap_pixel_to_sample (current_x) + _region->start ();
 
                /* and then to beats */
                current_x = region_frames_to_region_beats (current_x);
@@ -2822,7 +2833,7 @@ MidiRegionView::trim_note (NoteBase* event, Evoral::MusicalTime front_delta, Evo
 }
 
 void
-MidiRegionView::change_note_channel (NoteBse* event, int8_t chn, bool relative)
+MidiRegionView::change_note_channel (NoteBase* event, int8_t chn, bool relative)
 {
        uint8_t new_channel;
 
@@ -3132,7 +3143,7 @@ MidiRegionView::patch_entered (PatchChange* p)
          << _("Program ") << ((int) p->patch()->program()) + MIDI_BP_ZERO << '\n' 
          << _("Channel ") << ((int) p->patch()->channel() + 1);
        show_verbose_cursor (s.str(), 10, 20);
-       p->grab_focus();
+       p->item().grab_focus();
 }
 
 void
@@ -3145,16 +3156,18 @@ MidiRegionView::patch_left (PatchChange *)
 }
 
 void
-MidiRegionView::sysex_entered (ArdourCanvas::CanvasSysEx* p)
+MidiRegionView::sysex_entered (SysEx* p)
 {
        ostringstream s;
-       s << p->text();
-       show_verbose_cursor (s.str(), 10, 20);
-       p->grab_focus();
+       // CAIROCANVAS
+       // need a way to extract text from p->_flag->_text
+       // s << p->text();
+       // show_verbose_cursor (s.str(), 10, 20);
+       p->item().grab_focus();
 }
 
 void
-MidiRegionView::sysex_left (ArdourCanvas::CanvasSysEx *)
+MidiRegionView::sysex_left (SysEx *)
 {
        trackview.editor().verbose_cursor()->hide ();
        /* focus will transfer back via the enter-notify event sent to this
@@ -3357,7 +3370,7 @@ MidiRegionView::paste (framepos_t pos, float times, const MidiCutBuffer& mcb)
 }
 
 struct EventNoteTimeEarlyFirstComparator {
-       bool operator() (CanvasNoteEvent* a, CanvasNoteEvent* b) {
+       bool operator() (NoteBase* a, NoteBase* b) {
                return a->note()->time() < b->note()->time();
        }
 };
@@ -3482,7 +3495,7 @@ MidiRegionView::update_ghost_note (double x, double y)
 
        PublicEditor& editor = trackview.editor ();
        
-       framepos_t const unsnapped_frame = editor.pixel_to_frame (x);
+       framepos_t const unsnapped_frame = editor.pixel_to_sample (x);
        framecnt_t grid_frames;
        framepos_t const f = snap_frame_to_grid_underneath (unsnapped_frame, grid_frames);
 
@@ -3606,7 +3619,7 @@ MidiRegionView::show_step_edit_cursor (Evoral::MusicalTime pos)
        if (_step_edit_cursor == 0) {
                ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group();
 
-               _step_edit_cursor = new ArdourCanvas::Rectangle (*group);
+               _step_edit_cursor = new ArdourCanvas::Rectangle (group);
                _step_edit_cursor->set_y0 (0);
                _step_edit_cursor->set_y1 (midi_stream_view()->contents_height());
                _step_edit_cursor->set_fill_color (RGBA_TO_UINT (45,0,0,90));
@@ -3623,7 +3636,7 @@ MidiRegionView::move_step_edit_cursor (Evoral::MusicalTime pos)
        _step_edit_cursor_position = pos;
 
        if (_step_edit_cursor) {
-               double pixel = trackview.editor().frame_to_pixel (region_beats_to_region_frames (pos));
+               double pixel = trackview.editor().sample_to_pixel (region_beats_to_region_frames (pos));
                _step_edit_cursor->set_x0 (pixel);
                set_step_edit_cursor_width (_step_edit_cursor_width);
        }
@@ -3643,7 +3656,7 @@ MidiRegionView::set_step_edit_cursor_width (Evoral::MusicalTime beats)
        _step_edit_cursor_width = beats;
 
        if (_step_edit_cursor) {
-               _step_edit_cursor->set_x1 (_step_edit_cursor->x0() + trackview.editor().frame_to_pixel (region_beats_to_region_frames (beats)));
+               _step_edit_cursor->set_x1 (_step_edit_cursor->x0() + trackview.editor().sample_to_pixel (region_beats_to_region_frames (beats)));
        }
 }
 
@@ -3760,14 +3773,16 @@ MidiRegionView::edit_patch_change (PatchChange* pc)
 }
 
 void
-MidiRegionView::delete_sysex (CanvasSysEx* sysex)
+MidiRegionView::delete_sysex (SysEx* /*sysex*/)
 {
-       MidiModel::SysExDiffCommand* c = _model->new_sysex_diff_command (_("delete sysex"));
-       c->remove (sysex->sysex());
-       _model->apply_command (*trackview.session(), c);
+       // CAIROCANVAS
+       // sysyex object doesn't have a pointer to a sysex event
+       // MidiModel::SysExDiffCommand* c = _model->new_sysex_diff_command (_("delete sysex"));
+       // c->remove (sysex->sysex());
+       // _model->apply_command (*trackview.session(), c);
 
-       _sys_exes.clear ();
-       display_sysexes();
+       //_sys_exes.clear ();
+       // display_sysexes();
 }
 
 void
@@ -3806,6 +3821,7 @@ MidiRegionView::show_verbose_cursor (string const & text, double xoffset, double
 {
        double wx, wy;
 
+       trackview.editor().verbose_cursor()->set_text (text);
        trackview.editor().get_pointer_position (wx, wy);
 
        wx += xoffset;
@@ -3813,14 +3829,17 @@ MidiRegionView::show_verbose_cursor (string const & text, double xoffset, double
 
        /* Flip the cursor above the mouse pointer if it would overlap the bottom of the canvas */
 
-       double x1, y1, x2, y2;
-       trackview.editor().verbose_cursor()->canvas_item()->get_bounds (x1, y1, x2, y2);
+       boost::optional<ArdourCanvas::Rect> bbo = trackview.editor().verbose_cursor()->item().bounding_box();
+
+       assert (bbo);
+       
+       ArdourCanvas::Rect bb = bbo.get();
 
-       if ((wy + y2 - y1) > trackview.editor().canvas_height()) {
-               wy -= (y2 - y1) + 2 * yoffset;
+       if ((wy + bb.y1 - bb.y0) > trackview.editor().visible_canvas_height()) {
+               wy -= (bb.y1 - bb.y0) + 2 * yoffset;
        }
 
-       trackview.editor().verbose_cursor()->set (text, wx, wy);
+       trackview.editor().verbose_cursor()->set_position (wx, wy);
        trackview.editor().verbose_cursor()->show ();
 }