diff options
author | Robin Gareus <robin@gareus.org> | 2014-09-08 18:44:32 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-09-08 18:44:32 +0200 |
commit | 1f313ec19c4c60de8ce4288c98f2632ee78fbcdc (patch) | |
tree | e1cde3077d92fa7d3bd1c8abc5811975ffcc2242 | |
parent | a649fa85723ac0c6aa8724d1cb8cfef19e5c201e (diff) |
Vertically align Midi Notes, Piano Roll & Canvas Line Grid
-rw-r--r-- | gtk2_ardour/ghostregion.cc | 4 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 14 | ||||
-rw-r--r-- | gtk2_ardour/piano_roll_header.cc | 10 |
3 files changed, 14 insertions, 14 deletions
diff --git a/gtk2_ardour/ghostregion.cc b/gtk2_ardour/ghostregion.cc index 759ffb94d2..2f9133803c 100644 --- a/gtk2_ardour/ghostregion.cc +++ b/gtk2_ardour/ghostregion.cc @@ -250,7 +250,7 @@ MidiGhostRegion::update_range () 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) { uint8_t const note_num = (*it)->event->note()->note(); @@ -285,7 +285,7 @@ MidiGhostRegion::add_note (NoteBase* n) } else { const double y = mv->note_to_y(note_num); 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)); } } } diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index a738b3c0c4..c782c84585 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1413,8 +1413,8 @@ MidiRegionView::apply_note_range (uint8_t min, uint8_t max, bool force) if (Note* cnote = dynamic_cast<Note*>(event)) { - const double y0 = midi_stream_view()->note_to_y(note->note()); - const double y1 = y0 + floor(midi_stream_view()->note_height()); + const double y0 = 1. + floor (midi_stream_view()->note_to_y(note->note())); + const double y1 = y0 + std::max(1., floor(midi_stream_view()->note_height()) - 1.); cnote->set_y0 (y0); cnote->set_y1 (y1); @@ -1612,7 +1612,7 @@ MidiRegionView::update_note (Note* ev, bool update_ghost_regions) { boost::shared_ptr<NoteType> note = ev->note(); 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_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_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 (_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 double x = trackview.editor().sample_to_pixel(note_start_frames); - const double diamond_size = midi_stream_view()->note_height(); - const double y = midi_stream_view()->note_to_y(note->note()) + (diamond_size/2.0); + const double diamond_size = std::max(1., floor(midi_stream_view()->note_height()) - 2.); + 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_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) { - 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); diff --git a/gtk2_ardour/piano_roll_header.cc b/gtk2_ardour/piano_roll_header.cc index e784242ff1..878cbb72d8 100644 --- a/gtk2_ardour/piano_roll_header.cc +++ b/gtk2_ardour/piano_roll_header.cc @@ -174,16 +174,16 @@ render_dga(Cairo::RefPtr<Cairo::Context> cr, int /*note*/, double x[], double y[ void 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 other_y1 = floor(_view.note_to_y(note+1)) + floor(_note_height / 2.0f) + 0.5f; - double other_y2 = floor(_view.note_to_y(note-1)) + floor(_note_height / 2.0f) - 1.0f; + 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 width = get_width(); if (note == 0) { - note_height = floor(_view.contents_height()) - y_pos; + note_height = floor(_view.contents_height()) - y_pos + 2.; } 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) { |