| 610 | } |
| 611 | |
| 612 | void LfoEditor::addPoint(juce::Point<float> newPoint) |
| 613 | { |
| 614 | if (! dataIsActive || activeLfoData.points.size() >= maxPoints) |
| 615 | return; |
| 616 | |
| 617 | // Add the point and sort the list to find its correct position. |
| 618 | activeLfoData.points.push_back(newPoint); |
| 619 | updateAndSortPoints(); |
| 620 | |
| 621 | // Find the index of the point we just added. |
| 622 | auto it = std::find_if(activeLfoData.points.begin(), activeLfoData.points.end(), [&](const auto& p) |
| 623 | { return juce::approximatelyEqual(p.x, newPoint.x) && juce::approximatelyEqual(p.y, newPoint.y); }); |
| 624 | |
| 625 | if (it != activeLfoData.points.end()) |
| 626 | { |
| 627 | int insertedAtIndex = (int) std::distance(activeLfoData.points.begin(), it); |
| 628 | |
| 629 | // A new point splits a segment, so we need one more curvature value. |
| 630 | // We insert a new 0.0f (linear) curvature for the new segment being created. |
| 631 | // All other curvatures are preserved. |
| 632 | if (insertedAtIndex > 0) |
| 633 | { |
| 634 | activeLfoData.curvatures.insert(activeLfoData.curvatures.begin() + insertedAtIndex - 1, 0.0f); |
| 635 | } |
| 636 | else |
| 637 | { |
| 638 | // This should only happen if adding a point before the second point, very rare. |
| 639 | activeLfoData.curvatures.insert(activeLfoData.curvatures.begin(), 0.0f); |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | repaint(); |
| 644 | } |
| 645 | |
| 646 | void LfoEditor::removePoint(int index) |
| 647 | { |
nothing calls this directly
no outgoing calls
no test coverage detected