| 850 | } |
| 851 | |
| 852 | int LfoEditor::findSegmentIndexAt(const juce::Point<int>& position) const |
| 853 | { |
| 854 | // Safety checks: ensure there is data and at least one segment to check. |
| 855 | if (! dataIsActive || activeLfoData.points.size() < 2) |
| 856 | return -1; |
| 857 | |
| 858 | // Convert the mouse's X position to a normalized value [0, 1] |
| 859 | const float clickXNormalized = (float) position.x / (float) getWidth(); |
| 860 | |
| 861 | // Iterate through all the points that define the start of a segment |
| 862 | for (size_t i = 0; i < activeLfoData.points.size() - 1; ++i) |
| 863 | { |
| 864 | // A segment is defined by point 'i' and point 'i + 1'. |
| 865 | const auto& p1 = activeLfoData.points[i]; |
| 866 | const auto& p2 = activeLfoData.points[i + 1]; |
| 867 | |
| 868 | // Check if the normalized click position falls horizontally between the two points. |
| 869 | if (clickXNormalized >= p1.x && clickXNormalized <= p2.x) |
| 870 | { |
| 871 | // If it does, we've found our segment. Return its starting index. |
| 872 | return static_cast<int>(i); |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | // If the loop completes, no segment was found at that X position. |
| 877 | return -1; |
| 878 | } |
| 879 | |
| 880 | void LfoEditor::setEditMode(LfoEditMode newMode) |
| 881 | { |
nothing calls this directly
no outgoing calls
no test coverage detected