| 435 | } |
| 436 | |
| 437 | void Multiband::mouseDown(const juce::MouseEvent& e) |
| 438 | { |
| 439 | if (! isDragging && e.mods.isLeftButtonDown() && e.y <= getHeight() / 5.0f) // create new lines |
| 440 | { |
| 441 | float xPercent = getMouseXYRelative().getX() / static_cast<float>(getWidth()); |
| 442 | if (lineNum < 3) |
| 443 | { |
| 444 | bool canCreate = true; |
| 445 | |
| 446 | int i = 0; |
| 447 | for (; i < lineNum; i++) |
| 448 | { |
| 449 | // can't create near existed lines |
| 450 | if ((freqDividerGroup[i]->getToggleState() && fabs(freqDividerGroup[i]->getVerticalLine().getXPercent() - xPercent) <= limitLeft) || xPercent < limitLeft || xPercent > limitRight) |
| 451 | { |
| 452 | canCreate = false; |
| 453 | break; |
| 454 | } |
| 455 | } |
| 456 | if (canCreate) |
| 457 | { |
| 458 | for (; i < 3; i++) |
| 459 | { |
| 460 | // create lines and close buttons and then set state |
| 461 | if (! freqDividerGroup[i]->getToggleState()) |
| 462 | { |
| 463 | freqDividerGroup[i]->getVerticalLine().setXPercent(xPercent); |
| 464 | int freq = static_cast<int>(transformFromLog(xPercent)); |
| 465 | freqDividerGroup[i]->setFreq(freq); |
| 466 | freqDividerGroup[i]->setToggleState(true, juce::sendNotificationSync); |
| 467 | int changeIndex = sortLines(); |
| 468 | if (auto* param = processor.treeState.getParameter(NUM_BANDS_ID)) |
| 469 | { |
| 470 | param->setValueNotifyingHost(param->getNormalisableRange().convertTo0to1(lineNum + 1)); |
| 471 | } |
| 472 | setStatesWhenAdd(changeIndex); |
| 473 | break; |
| 474 | } |
| 475 | } |
| 476 | setLineRelatedBoundsByX(); // TODO: dont use this, only set freq |
| 477 | setSoloRelatedBounds(); |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | else if (! isDragging && e.mods.isLeftButtonDown() && e.y > getHeight() / 5.0f) // focus on one band |
| 482 | { |
| 483 | int num = lineNum; |
| 484 | if (lineNum == 0) |
| 485 | { |
| 486 | focusIndex = 0; |
| 487 | return; |
| 488 | } |
| 489 | else |
| 490 | { |
| 491 | if (e.x >= 0 && e.x < freqDividerGroup[0]->getX()) |
| 492 | { |
| 493 | focusIndex = 0; |
| 494 | return; |
nothing calls this directly
no test coverage detected