+
+void
+MidiRegionView::update_ghost_note (double x, double y)
+{
+ _last_ghost_x = x;
+ _last_ghost_y = y;
+
+ group->w2i (x, y);
+ nframes64_t f = trackview.editor().pixel_to_frame (x) + _region->position ();
+ trackview.editor().snap_to (f);
+ f -= _region->position ();
+
+ bool success;
+ Evoral::MusicalTime beats = trackview.editor().get_grid_type_as_beats (success, f);
+ if (!success) {
+ beats = 1;
+ }
+
+ double length = frames_to_beats (snap_frame_to_frame (f + beats_to_frames (beats)) - f);
+
+ _ghost_note->note()->set_time (frames_to_beats (f + _region->start()));
+ _ghost_note->note()->set_length (length);
+ _ghost_note->note()->set_note (midi_stream_view()->y_to_note (y));
+
+ update_note (_ghost_note);
+
+ show_verbose_canvas_cursor (_ghost_note->note ());
+}
+
+void
+MidiRegionView::create_ghost_note (double x, double y)
+{
+ delete _ghost_note;
+ _ghost_note = 0;
+
+ boost::shared_ptr<NoteType> g (new NoteType);
+ _ghost_note = new NoEventCanvasNote (*this, *group, g);
+ update_ghost_note (x, y);
+ _ghost_note->show ();
+
+ _last_ghost_x = x;
+ _last_ghost_y = y;
+
+ show_verbose_canvas_cursor (_ghost_note->note ());
+}
+
+void
+MidiRegionView::snap_changed ()
+{
+ if (!_ghost_note) {
+ return;
+ }
+
+ create_ghost_note (_last_ghost_x, _last_ghost_y);
+}
+
+void
+MidiRegionView::show_verbose_canvas_cursor (boost::shared_ptr<NoteType> n) const
+{
+ char buf[24];
+ snprintf (buf, sizeof (buf), "%s (%d)\nVel %d",
+ Evoral::midi_note_name (n->note()).c_str(),
+ (int) n->note (),
+ (int) n->velocity());
+ trackview.editor().show_verbose_canvas_cursor_with (buf);
+}
+
+void
+MidiRegionView::drop_down_keys ()
+{
+ _mouse_state = None;
+}
+
+void
+MidiRegionView::maybe_select_by_position (GdkEventButton* ev, double x, double y)
+{
+ double note = midi_stream_view()->y_to_note(y);
+ Events e;
+ MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
+
+ cerr << "Selecting by position\n";
+
+ uint16_t chn_mask = mtv->channel_selector().get_selected_channels();
+
+ if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
+ get_events (e, Evoral::Sequence<Evoral::MusicalTime>::PitchGreaterThanOrEqual, (uint8_t) floor (note), chn_mask);
+ } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
+ get_events (e, Evoral::Sequence<Evoral::MusicalTime>::PitchLessThanOrEqual, (uint8_t) floor (note), chn_mask);
+ } else {
+ return;
+ }
+
+ bool add_mrv_selection = false;
+
+ if (_selection.empty()) {
+ add_mrv_selection = true;
+ }
+
+ for (Events::iterator i = e.begin(); i != e.end(); ++i) {
+ if (_selection.insert (*i).second) {
+ (*i)->set_selected (true);
+ }
+ }
+
+ if (add_mrv_selection) {
+ PublicEditor& editor (trackview.editor());
+ editor.get_selection().add (this);
+ }
+}
+
+void
+MidiRegionView::color_handler ()
+{
+ RegionView::color_handler ();
+
+ for (Events::iterator i = _events.begin(); i != _events.end(); ++i) {
+ (*i)->set_selected ((*i)->selected()); // will change color
+ }
+
+ /* XXX probably more to do here */
+}
+
+void
+MidiRegionView::enable_display (bool yn)
+{
+ RegionView::enable_display (yn);
+ if (yn) {
+ redisplay_model ();
+ }
+}
+
+void
+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::SimpleRect (*group);
+ _step_edit_cursor->property_y1() = 0;
+ _step_edit_cursor->property_y2() = midi_stream_view()->contents_height();
+ _step_edit_cursor->property_fill_color_rgba() = RGBA_TO_UINT (45,0,0,90);
+ _step_edit_cursor->property_outline_color_rgba() = RGBA_TO_UINT (85,0,0,90);
+ }
+
+ move_step_edit_cursor (pos);
+ _step_edit_cursor->show ();
+}
+
+void
+MidiRegionView::move_step_edit_cursor (Evoral::MusicalTime pos)
+{
+ _step_edit_cursor_position = pos;
+
+ if (_step_edit_cursor) {
+ double pixel = trackview.editor().frame_to_pixel (beats_to_frames (pos));
+ _step_edit_cursor->property_x1() = pixel;
+ set_step_edit_cursor_width (_step_edit_cursor_width);
+ }
+}
+
+void
+MidiRegionView::hide_step_edit_cursor ()
+{
+ if (_step_edit_cursor) {
+ _step_edit_cursor->hide ();
+ }
+}
+
+void
+MidiRegionView::set_step_edit_cursor_width (Evoral::MusicalTime beats)
+{
+ _step_edit_cursor_width = beats;
+
+ if (_step_edit_cursor) {
+ _step_edit_cursor->property_x2() = _step_edit_cursor->property_x1() + trackview.editor().frame_to_pixel (beats_to_frames (beats));
+ }
+}
+