| 1708 | } |
| 1709 | |
| 1710 | void ModularSynth::MouseScrolled(float xScroll, float yScroll, bool isSmoothScroll, bool isInvertedScroll, bool canZoomCanvas) |
| 1711 | { |
| 1712 | xScroll *= UserPrefs.scroll_multiplier_horizontal.Get(); |
| 1713 | yScroll *= UserPrefs.scroll_multiplier_vertical.Get(); |
| 1714 | |
| 1715 | if (IsKeyHeld(' ') || (GetModuleAtCursor() == nullptr && gHoveredUIControl == nullptr) || (dynamic_cast<Prefab*>(GetModuleAtCursor()) != nullptr && gHoveredUIControl == nullptr)) |
| 1716 | { |
| 1717 | if (canZoomCanvas) |
| 1718 | ZoomView(yScroll / 50, true); |
| 1719 | } |
| 1720 | else if (gHoveredUIControl) |
| 1721 | { |
| 1722 | #if JUCE_WINDOWS |
| 1723 | yScroll += xScroll / 4; //taking advantage of logitech horizontal scroll wheel |
| 1724 | #endif |
| 1725 | |
| 1726 | TextEntry* textEntry = dynamic_cast<TextEntry*>(gHoveredUIControl); |
| 1727 | if (textEntry) |
| 1728 | { |
| 1729 | if (isSmoothScroll) //slow this down into steps if you're using a smooth trackpad |
| 1730 | { |
| 1731 | if (fabs(yScroll) < .1f) //need more than a miniscule change |
| 1732 | return; |
| 1733 | static float sLastSmoothScrollTimeMs = -999; |
| 1734 | if (sLastSmoothScrollTimeMs + 100 > gTime) |
| 1735 | return; |
| 1736 | sLastSmoothScrollTimeMs = gTime; |
| 1737 | } |
| 1738 | float val = textEntry->GetValue(); |
| 1739 | float change = yScroll > 0 ? 1 : -1; |
| 1740 | if (GetKeyModifiers() & kModifier_Shift) |
| 1741 | change *= .01f; |
| 1742 | float min, max; |
| 1743 | textEntry->GetRange(min, max); |
| 1744 | textEntry->SetValue(std::clamp(val + change, min, max), NextBufferTime(false)); |
| 1745 | return; |
| 1746 | } |
| 1747 | |
| 1748 | float val = gHoveredUIControl->GetMidiValue(); |
| 1749 | float movementScale = 3; |
| 1750 | FloatSlider* floatSlider = dynamic_cast<FloatSlider*>(gHoveredUIControl); |
| 1751 | IntSlider* intSlider = dynamic_cast<IntSlider*>(gHoveredUIControl); |
| 1752 | ClickButton* clickButton = dynamic_cast<ClickButton*>(gHoveredUIControl); |
| 1753 | if (floatSlider || intSlider) |
| 1754 | { |
| 1755 | float w, h; |
| 1756 | gHoveredUIControl->GetDimensions(w, h); |
| 1757 | movementScale = 200.0f / w; |
| 1758 | } |
| 1759 | |
| 1760 | if (GetKeyModifiers() & kModifier_Shift) |
| 1761 | movementScale *= .01f; |
| 1762 | |
| 1763 | if (clickButton) |
| 1764 | return; |
| 1765 | |
| 1766 | float change = yScroll / 100 * movementScale; |
| 1767 |
nothing calls this directly
no test coverage detected