mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 07:45:00 +01:00
lollis: fix drawing and positioning glitches
This commit is contained in:
parent
a6c1a3d9d0
commit
c75b9a11ef
2 changed files with 11 additions and 9 deletions
|
|
@ -4662,6 +4662,6 @@ void
|
||||||
MidiRegionView::sync_velocity_drag (double factor)
|
MidiRegionView::sync_velocity_drag (double factor)
|
||||||
{
|
{
|
||||||
for (auto & s : _selection) {
|
for (auto & s : _selection) {
|
||||||
s->set_velocity (s->visual_velocity() * factor);
|
s->set_velocity (factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ void
|
||||||
VelocityGhostRegion::add_note (NoteBase* nb)
|
VelocityGhostRegion::add_note (NoteBase* nb)
|
||||||
{
|
{
|
||||||
ArdourCanvas::Lollipop* l = new ArdourCanvas::Lollipop (_note_group);
|
ArdourCanvas::Lollipop* l = new ArdourCanvas::Lollipop (_note_group);
|
||||||
|
l->set_bounding_parent (base_rect);
|
||||||
|
|
||||||
GhostEvent* event = new GhostEvent (nb, _note_group, l);
|
GhostEvent* event = new GhostEvent (nb, _note_group, l);
|
||||||
events.insert (std::make_pair (nb->note(), event));
|
events.insert (std::make_pair (nb->note(), event));
|
||||||
|
|
@ -101,7 +102,7 @@ void
|
||||||
VelocityGhostRegion::set_size_and_position (GhostEvent& ev)
|
VelocityGhostRegion::set_size_and_position (GhostEvent& ev)
|
||||||
{
|
{
|
||||||
ArdourCanvas::Lollipop* l = dynamic_cast<ArdourCanvas::Lollipop*> (ev.item);
|
ArdourCanvas::Lollipop* l = dynamic_cast<ArdourCanvas::Lollipop*> (ev.item);
|
||||||
const double available_height = base_rect->y1() - (2.0 * lollipop_radius);
|
const double available_height = base_rect->y1();
|
||||||
const double actual_height = (ev.event->note()->velocity() / 127.0) * available_height;
|
const double actual_height = (ev.event->note()->velocity() / 127.0) * available_height;
|
||||||
l->set (ArdourCanvas::Duple (ev.event->x0() - 1.0, base_rect->y1() - actual_height), actual_height, lollipop_radius);
|
l->set (ArdourCanvas::Duple (ev.event->x0() - 1.0, base_rect->y1() - actual_height), actual_height, lollipop_radius);
|
||||||
}
|
}
|
||||||
|
|
@ -132,20 +133,21 @@ VelocityGhostRegion::set_colors ()
|
||||||
void
|
void
|
||||||
VelocityGhostRegion::drag_lolli (ArdourCanvas::Lollipop* l, GdkEventMotion* ev)
|
VelocityGhostRegion::drag_lolli (ArdourCanvas::Lollipop* l, GdkEventMotion* ev)
|
||||||
{
|
{
|
||||||
ArdourCanvas::Rect r (base_rect->item_to_window (base_rect->get()));
|
ArdourCanvas::Rect r (base_rect->item_to_canvas (base_rect->get()));
|
||||||
|
|
||||||
/* translate event y-coord so that zero matches the top of base_rect
|
/* translate event y-coord so that zero matches the top of base_rect
|
||||||
* (event coordinates use window coordinate space)
|
* (event coordinates use window coordinate space)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
ev->y -= r.y0;
|
ev->y -= r.y0;
|
||||||
|
|
||||||
/* clamp y to be within the range defined by the base_rect height minus
|
/* clamp y to be within the range defined by the base_rect height minus
|
||||||
* the lollipop radius at top and bottom
|
* the lollipop radius at top and bottom
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const double effective_y = std::max (lollipop_radius, std::min (r.height() - (2.0 * lollipop_radius), ev->y));
|
const double effective_y = std::max (0.0, std::min (r.height(), ev->y));
|
||||||
const double newlen = r.height() - effective_y - lollipop_radius;
|
const double newlen = r.height() - effective_y;
|
||||||
const double delta = newlen - l->length();
|
const double delta = newlen - l->length();
|
||||||
|
|
||||||
MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (&parent_rv);
|
MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (&parent_rv);
|
||||||
|
|
@ -155,7 +157,7 @@ VelocityGhostRegion::drag_lolli (ArdourCanvas::Lollipop* l, GdkEventMotion* ev)
|
||||||
* changing the note velocities.
|
* changing the note velocities.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const double factor = newlen / l->length();
|
const double factor = newlen / base_rect->height();
|
||||||
mrv->sync_velocity_drag (factor);
|
mrv->sync_velocity_drag (factor);
|
||||||
|
|
||||||
MidiRegionView::Selection const & sel (mrv->selection());
|
MidiRegionView::Selection const & sel (mrv->selection());
|
||||||
|
|
@ -176,12 +178,12 @@ VelocityGhostRegion::y_position_to_velocity (double y) const
|
||||||
const ArdourCanvas::Rect r (base_rect->get());
|
const ArdourCanvas::Rect r (base_rect->get());
|
||||||
int velocity;
|
int velocity;
|
||||||
|
|
||||||
if (y >= r.height() - (2.0 * lollipop_radius)) {
|
if (y >= r.height()) {
|
||||||
velocity = 0;
|
velocity = 0;
|
||||||
} else if (y <= lollipop_radius) {
|
} else if (y <= 0.) {
|
||||||
velocity = 127;
|
velocity = 127;
|
||||||
} else {
|
} else {
|
||||||
velocity = floor (127. * (((r.height() - 2.0 * lollipop_radius)- y) / r.height()));
|
velocity = floor (127. * (1.0 - (y / r.height())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return velocity;
|
return velocity;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue