Vertically align Midi Notes, Piano Roll & Canvas Line Grid

This commit is contained in:
Robin Gareus 2014-09-08 18:44:32 +02:00
parent a649fa8572
commit 1f313ec19c
3 changed files with 14 additions and 14 deletions

View file

@ -250,7 +250,7 @@ MidiGhostRegion::update_range ()
return; return;
} }
double const h = trackview.current_height() / double (mv->contents_note_range ()); double const h = std::max(1., floor (trackview.current_height() / double (mv->contents_note_range ())) -1);
for (EventList::iterator it = events.begin(); it != events.end(); ++it) { for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
uint8_t const note_num = (*it)->event->note()->note(); uint8_t const note_num = (*it)->event->note()->note();
@ -285,7 +285,7 @@ MidiGhostRegion::add_note (NoteBase* n)
} else { } else {
const double y = mv->note_to_y(note_num); const double y = mv->note_to_y(note_num);
event->rect->set_y0 (y); event->rect->set_y0 (y);
event->rect->set_y1 (y + mv->note_height()); event->rect->set_y1 (y + std::max(1., floor(mv->note_height()) -1));
} }
} }
} }

View file

@ -1413,8 +1413,8 @@ MidiRegionView::apply_note_range (uint8_t min, uint8_t max, bool force)
if (Note* cnote = dynamic_cast<Note*>(event)) { if (Note* cnote = dynamic_cast<Note*>(event)) {
const double y0 = midi_stream_view()->note_to_y(note->note()); const double y0 = 1. + floor (midi_stream_view()->note_to_y(note->note()));
const double y1 = y0 + floor(midi_stream_view()->note_height()); const double y1 = y0 + std::max(1., floor(midi_stream_view()->note_height()) - 1.);
cnote->set_y0 (y0); cnote->set_y0 (y0);
cnote->set_y1 (y1); cnote->set_y1 (y1);
@ -1612,7 +1612,7 @@ MidiRegionView::update_note (Note* ev, bool update_ghost_regions)
{ {
boost::shared_ptr<NoteType> note = ev->note(); boost::shared_ptr<NoteType> note = ev->note();
const double x = trackview.editor().sample_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()); const double y0 = 1 + floor(midi_stream_view()->note_to_y(note->note()));
ev->set_x0 (x); ev->set_x0 (x);
ev->set_y0 (y0); ev->set_y0 (y0);
@ -1626,7 +1626,7 @@ MidiRegionView::update_note (Note* ev, bool update_ghost_regions)
ev->set_x1 (trackview.editor().sample_to_pixel (_region->length())); ev->set_x1 (trackview.editor().sample_to_pixel (_region->length()));
} }
ev->set_y1 (y0 + floor(midi_stream_view()->note_height())); ev->set_y1 (y0 + std::max(1., floor(midi_stream_view()->note_height()) - 1));
if (note->length() == 0) { if (note->length() == 0) {
if (_active_notes && note->note() < 128) { if (_active_notes && note->note() < 128) {
@ -1667,8 +1667,8 @@ MidiRegionView::update_hit (Hit* ev)
const framepos_t note_start_frames = source_beats_to_region_frames(note->time()); const framepos_t note_start_frames = source_beats_to_region_frames(note->time());
const double x = trackview.editor().sample_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(); const double diamond_size = std::max(1., floor(midi_stream_view()->note_height()) - 2.);
const double y = midi_stream_view()->note_to_y(note->note()) + (diamond_size/2.0); const double y = 1.5 + floor(midi_stream_view()->note_to_y(note->note())) + diamond_size * .5;
ev->set_position (ArdourCanvas::Duple (x, y)); ev->set_position (ArdourCanvas::Duple (x, y));
ev->set_height (diamond_size); ev->set_height (diamond_size);
@ -1703,7 +1703,7 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible)
} else if (midi_view()->note_mode() == Percussive) { } else if (midi_view()->note_mode() == Percussive) {
const double diamond_size = midi_stream_view()->note_height() / 2.0; const double diamond_size = std::max(1., floor(midi_stream_view()->note_height()) - 2.);
Hit* ev_diamond = new Hit (*this, _note_group, diamond_size, note); Hit* ev_diamond = new Hit (*this, _note_group, diamond_size, note);

View file

@ -174,16 +174,16 @@ render_dga(Cairo::RefPtr<Cairo::Context> cr, int /*note*/, double x[], double y[
void void
PianoRollHeader::get_path(PianoRollHeader::ItemType note_type, int note, double x[], double y[]) PianoRollHeader::get_path(PianoRollHeader::ItemType note_type, int note, double x[], double y[])
{ {
double y_pos = floor(_view.note_to_y(note)) - 0.5f; double y_pos = floor(_view.note_to_y(note)) + 1.5f;
double note_height; double note_height;
double other_y1 = floor(_view.note_to_y(note+1)) + floor(_note_height / 2.0f) + 0.5f; double other_y1 = floor(_view.note_to_y(note+1)) + floor(_note_height / 2.0f) + 2.5f;
double other_y2 = floor(_view.note_to_y(note-1)) + floor(_note_height / 2.0f) - 1.0f; double other_y2 = floor(_view.note_to_y(note-1)) + floor(_note_height / 2.0f) + 1.0f;
double width = get_width(); double width = get_width();
if (note == 0) { if (note == 0) {
note_height = floor(_view.contents_height()) - y_pos; note_height = floor(_view.contents_height()) - y_pos + 2.;
} else { } else {
note_height = floor(_view.note_to_y(note - 1)) - y_pos; note_height = floor(_view.note_to_y(note - 1)) - y_pos + 2.;
} }
switch (note_type) { switch (note_type) {