| 262 | } |
| 263 | |
| 264 | void Multiband::setStatesWhenAdd(int insertionIndex) |
| 265 | { |
| 266 | // 1. Update the visual focus. |
| 267 | // If a band is inserted at or before the current focus, |
| 268 | // the focus index must be shifted to the right. |
| 269 | if (insertionIndex <= focusIndex) |
| 270 | { |
| 271 | focusIndex += 1; |
| 272 | } |
| 273 | |
| 274 | // 2. Determine if the user clicked on the left or right side of the band being split. |
| 275 | // We use the center point between the enable and solo buttons as the reference. |
| 276 | float bandCenterline = (bandUIs[insertionIndex].enableButton->getRight() + bandUIs[insertionIndex].soloButton->getX()) / 2.0f; |
| 277 | bool clickedOnTheLeft = getMouseXYRelative().getX() < bandCenterline; |
| 278 | |
| 279 | // 3. Make space by shifting all bands from the insertion point onwards one step to the right. |
| 280 | // We loop backwards from the end to avoid overwriting the data we need to copy. |
| 281 | // After this loop, the settings of the original band at `insertionIndex` are now temporarily stored at `insertionIndex + 1`. |
| 282 | for (int i = 2; i >= insertionIndex; --i) |
| 283 | { |
| 284 | copyBandSettings(i + 1, i); |
| 285 | } |
| 286 | // Also shift LFO targets for the same range of bands |
| 287 | processor.shiftLfoModulationTargets(insertionIndex, 2, 1); |
| 288 | |
| 289 | // 4. Place the old and new bands correctly based on the exact user-defined logic. |
| 290 | if (clickedOnTheLeft) |
| 291 | { |
| 292 | // USER ACTION: Clicked on the LEFT side of the band. |
| 293 | // EXPECTED RESULT: The NEW band appears on the LEFT, OLD band is shifted to the RIGHT. |
| 294 | |
| 295 | // The "Make Space" step has already moved the OLD band's settings to insertionIndex + 1. This is perfect. |
| 296 | // We just need to reset the band at the original insertionIndex to its default state, creating the NEW band on the LEFT. |
| 297 | resetBandToDefault(insertionIndex); |
| 298 | processor.clearLfoModulationForBand(insertionIndex); // Clear LFOs for the new default band |
| 299 | } |
| 300 | else // Clicked on the RIGHT side |
| 301 | { |
| 302 | // USER ACTION: Clicked on the RIGHT side of the band. |
| 303 | // EXPECTED RESULT: The OLD band stays on the LEFT, NEW band appears on the RIGHT. |
| 304 | |
| 305 | // The "Make Space" step moved the OLD settings to insertionIndex + 1. We need them back. |
| 306 | // So, we copy the temporarily stored settings from (insertionIndex + 1) back to the original position. |
| 307 | copyBandSettings(insertionIndex, insertionIndex + 1); |
| 308 | processor.shiftLfoModulationTargets(insertionIndex + 1, insertionIndex + 1, -1); |
| 309 | |
| 310 | // Now, we reset the band to the right to be a new, default band. |
| 311 | resetBandToDefault(insertionIndex + 1); |
| 312 | processor.clearLfoModulationForBand(insertionIndex + 1); // Clear LFOs for the new default band |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | void Multiband::setStatesWhenDelete(int deletedIndex) |
| 317 | { |
nothing calls this directly
no test coverage detected