diff --git a/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp b/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp index 3af1c40c65..8455355b2d 100644 --- a/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp +++ b/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp @@ -71,17 +71,17 @@ public: } } - void mouseWheelMove (const MouseEvent&, float wheelIncrementX, float wheelIncrementY) + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails& wheel) { if (thumbnail.getTotalLength() > 0) { - double newStart = startTime - wheelIncrementX * (endTime - startTime) / 10.0; + double newStart = startTime - wheel.deltaX * (endTime - startTime) / 10.0; newStart = jlimit (0.0, jmax (0.0, thumbnail.getTotalLength() - (endTime - startTime)), newStart); endTime = newStart + (endTime - startTime); startTime = newStart; - if (wheelIncrementY != 0) - zoomSlider.setValue (zoomSlider.getValue() - wheelIncrementY); + if (wheel.deltaY != 0) + zoomSlider.setValue (zoomSlider.getValue() - wheel.deltaY); repaint(); } diff --git a/extras/the jucer/src/model/jucer_JucerDocument.cpp b/extras/the jucer/src/model/jucer_JucerDocument.cpp index 4b0003e011..062fb94561 100644 --- a/extras/the jucer/src/model/jucer_JucerDocument.cpp +++ b/extras/the jucer/src/model/jucer_JucerDocument.cpp @@ -291,7 +291,7 @@ void JucerDocument::getOptionalMethods (StringArray& baseClasses, addMethod ("Component", "void", "mouseDrag (const MouseEvent& e)", "", baseClasses, returnValues, methods, initialContents); addMethod ("Component", "void", "mouseUp (const MouseEvent& e)", "", baseClasses, returnValues, methods, initialContents); addMethod ("Component", "void", "mouseDoubleClick (const MouseEvent& e)", "", baseClasses, returnValues, methods, initialContents); - addMethod ("Component", "void", "mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY)", "", baseClasses, returnValues, methods, initialContents); + addMethod ("Component", "void", "mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel)", "", baseClasses, returnValues, methods, initialContents); addMethod ("Component", "bool", "keyPressed (const KeyPress& key)", "return false; // Return true if your handler uses this key event, or false to allow it to be passed-on.", baseClasses, returnValues, methods, initialContents); addMethod ("Component", "bool", "keyStateChanged (const bool isKeyDown)", "return false; // Return true if your handler uses this key event, or false to allow it to be passed-on.", baseClasses, returnValues, methods, initialContents); diff --git a/extras/the jucer/src/ui/jucer_EditingPanelBase.cpp b/extras/the jucer/src/ui/jucer_EditingPanelBase.cpp index 1ca82884f9..fbc1f654c5 100644 --- a/extras/the jucer/src/ui/jucer_EditingPanelBase.cpp +++ b/extras/the jucer/src/ui/jucer_EditingPanelBase.cpp @@ -70,13 +70,13 @@ public: ~ZoomingViewport() {} - void mouseWheelMove (const MouseEvent& e, float ix, float iy) + void mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) { - if (e.mods.isCtrlDown() || e.mods.isAltDown()) + if (e.mouseEvent.mods.isCtrlDown() || e.mouseEvent.mods.isAltDown()) { - const double factor = (iy > 0) ? 2.0 : 0.5; + const double factor = (e.wheelDeltaY > 0) ? 2.0 : 0.5; - panel->setZoom (panel->getZoom() * factor, e.x, e.y); + panel->setZoom (panel->getZoom() * factor, e.wheelDeltaX, e.wheelDeltaY); } else { diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 4a9ebb4862..77ea7490a2 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -1719,9 +1719,7 @@ private: } } - void mouseWheelMove (const MouseEvent& e, - float incrementX, - float incrementY) + void mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) { if (pluginWindow != 0) { @@ -1736,7 +1734,7 @@ private: ev.xbutton.x_root = e.getScreenX(); ev.xbutton.y_root = e.getScreenY(); - translateJuceToXMouseWheelModifiers (e, incrementY, ev); + translateJuceToXMouseWheelModifiers (e, wheel.deltaY, ev); sendEventToChild (&ev); // TODO - put a usleep here ? diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp index bf31d4c2d8..00b642cf36 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp @@ -785,10 +785,11 @@ void MidiKeyboardComponent::mouseExit (const MouseEvent& e) updateNoteUnderMouse (e, false); } -void MidiKeyboardComponent::mouseWheelMove (const MouseEvent&, float ix, float iy) +void MidiKeyboardComponent::mouseWheelMove (const MouseEvent&, const MouseWheelDetails& wheel) { - const float amount = (orientation == horizontalKeyboard && ix != 0) - ? ix : (orientation == verticalKeyboardFacingLeft ? iy : -iy); + const float amount = (orientation == horizontalKeyboard && wheel.deltaX != 0) + ? wheel.deltaX : (orientation == verticalKeyboardFacingLeft ? wheel.deltaY + : -wheel.deltaY); setLowestVisibleKeyFloat (firstKey - amount * keyWidth); } diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h index 1578ca722c..f01b2d6787 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h @@ -265,33 +265,33 @@ public: //============================================================================== /** @internal */ - void paint (Graphics& g); + void paint (Graphics&); /** @internal */ void resized(); /** @internal */ - void mouseMove (const MouseEvent& e); + void mouseMove (const MouseEvent&); /** @internal */ - void mouseDrag (const MouseEvent& e); + void mouseDrag (const MouseEvent&); /** @internal */ - void mouseDown (const MouseEvent& e); + void mouseDown (const MouseEvent&); /** @internal */ - void mouseUp (const MouseEvent& e); + void mouseUp (const MouseEvent&); /** @internal */ - void mouseEnter (const MouseEvent& e); + void mouseEnter (const MouseEvent&); /** @internal */ - void mouseExit (const MouseEvent& e); + void mouseExit (const MouseEvent&); /** @internal */ - void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY); + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); /** @internal */ void timerCallback(); /** @internal */ bool keyStateChanged (bool isKeyDown); /** @internal */ - void focusLost (FocusChangeType cause); + void focusLost (FocusChangeType); /** @internal */ - void handleNoteOn (MidiKeyboardState* source, int midiChannel, int midiNoteNumber, float velocity); + void handleNoteOn (MidiKeyboardState*, int midiChannel, int midiNoteNumber, float velocity); /** @internal */ - void handleNoteOff (MidiKeyboardState* source, int midiChannel, int midiNoteNumber); + void handleNoteOff (MidiKeyboardState*, int midiChannel, int midiNoteNumber); /** @internal */ void colourChanged(); diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 35a5ab8b17..f416bcce4d 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -114,8 +114,8 @@ public: } } - static void sendWheelEvent (Component& comp, Component::BailOutChecker& checker, const MouseEvent& e, - const float wheelIncrementX, const float wheelIncrementY) + static void sendWheelEvent (Component& comp, Component::BailOutChecker& checker, + const MouseEvent& e, const MouseWheelDetails& wheel) { { MouseListenerList* const list = comp.mouseListeners; @@ -124,7 +124,7 @@ public: { for (int i = list->listeners.size(); --i >= 0;) { - list->listeners.getUnchecked(i)->mouseWheelMove (e, wheelIncrementX, wheelIncrementY); + list->listeners.getUnchecked(i)->mouseWheelMove (e, wheel); if (checker.shouldBailOut()) return; @@ -144,7 +144,7 @@ public: for (int i = list->numDeepMouseListeners; --i >= 0;) { - list->listeners.getUnchecked(i)->mouseWheelMove (e, wheelIncrementX, wheelIncrementY); + list->listeners.getUnchecked(i)->mouseWheelMove (e, wheel); if (checker2.shouldBailOut()) return; @@ -2176,12 +2176,11 @@ void Component::mouseDrag (const MouseEvent&) {} void Component::mouseMove (const MouseEvent&) {} void Component::mouseDoubleClick (const MouseEvent&) {} -void Component::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) +void Component::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) { // the base class just passes this event up to its parent.. if (parentComponent != nullptr) - parentComponent->mouseWheelMove (e.getEventRelativeTo (parentComponent), - wheelIncrementX, wheelIncrementY); + parentComponent->mouseWheelMove (e.getEventRelativeTo (parentComponent), wheel); } @@ -2485,33 +2484,30 @@ void Component::internalMouseMove (MouseInputSource& source, const Point& r } void Component::internalMouseWheel (MouseInputSource& source, const Point& relativePos, - const Time& time, const float amountX, const float amountY) + const Time& time, const MouseWheelDetails& wheel) { Desktop& desktop = Desktop::getInstance(); BailOutChecker checker (this); - const float wheelIncrementX = amountX / 256.0f; - const float wheelIncrementY = amountY / 256.0f; - const MouseEvent me (source, relativePos, source.getCurrentModifiers(), this, this, time, relativePos, time, 0, false); if (isCurrentlyBlockedByAnotherModalComponent()) { // allow blocked mouse-events to go to global listeners.. - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheelIncrementX, wheelIncrementY); + desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheel); } else { - mouseWheelMove (me, wheelIncrementX, wheelIncrementY); + mouseWheelMove (me, wheel); if (checker.shouldBailOut()) return; - desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheelIncrementX, wheelIncrementY); + desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheel); if (! checker.shouldBailOut()) - MouseListenerList::sendWheelEvent (*this, checker, me, wheelIncrementX, wheelIncrementY); + MouseListenerList::sendWheelEvent (*this, checker, me, wheel); } } diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 91ffb88e63..127ce09bb8 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -1464,19 +1464,20 @@ public: //============================================================================== - /** Called when the mouse moves inside this component. + /** Called when the mouse moves inside a component. If the mouse button isn't pressed and the mouse moves over a component, this will be called to let the component react to this. A component will always get a mouseEnter callback before a mouseMove. - @param e details about the position and status of the mouse event + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseEnter, mouseExit, mouseDrag, contains */ - virtual void mouseMove (const MouseEvent& e); + virtual void mouseMove (const MouseEvent& event); - /** Called when the mouse first enters this component. + /** Called when the mouse first enters a component. If the mouse button isn't pressed and the mouse moves into a component, this will be called to let the component react to this. @@ -1486,16 +1487,13 @@ public: mouseDrag messages are sent to the component that the mouse was originally clicked on, until the button is released. - If you're writing a component that needs to repaint itself when the mouse - enters and exits, it might be quicker to use the setRepaintsOnMouseActivity() - method. - - @param e details about the position and status of the mouse event + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseExit, mouseDrag, mouseMove, contains */ - virtual void mouseEnter (const MouseEvent& e); + virtual void mouseEnter (const MouseEvent& event); - /** Called when the mouse moves out of this component. + /** Called when the mouse moves out of a component. This will be called when the mouse moves off the edge of this component. @@ -1504,16 +1502,13 @@ public: edge of the component and released, then this callback will happen when the button is released, after the mouseUp callback. - If you're writing a component that needs to repaint itself when the mouse - enters and exits, it might be quicker to use the setRepaintsOnMouseActivity() - method. - - @param e details about the position and status of the mouse event + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseEnter, mouseDrag, mouseMove, contains */ - virtual void mouseExit (const MouseEvent& e); + virtual void mouseExit (const MouseEvent& event); - /** Called when a mouse button is pressed while it's over this component. + /** Called when a mouse button is pressed. The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) @@ -1522,10 +1517,11 @@ public: Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released. - @param e details about the position and status of the mouse event + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseUp, mouseDrag, mouseDoubleClick, contains */ - virtual void mouseDown (const MouseEvent& e); + virtual void mouseDown (const MouseEvent& event); /** Called when the mouse is moved while a button is held down. @@ -1533,14 +1529,11 @@ public: receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds. - If you want to be able to drag things off the edge of a component - and have the component scroll when you get to the edges, the - beginDragAutoRepeat() method might be useful. - - @param e details about the position and status of the mouse event - @see mouseDown, mouseUp, mouseMove, contains, beginDragAutoRepeat + @param event details about the position and status of the mouse event, including + the source component in which it occurred + @see mouseDown, mouseUp, mouseMove, contains, setDragRepeatInterval */ - virtual void mouseDrag (const MouseEvent& e); + virtual void mouseDrag (const MouseEvent& event); /** Called when a mouse button is released. @@ -1551,46 +1544,38 @@ public: The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released. - @param e details about the position and status of the mouse event + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseDown, mouseDrag, mouseDoubleClick, contains */ - virtual void mouseUp (const MouseEvent& e); + virtual void mouseUp (const MouseEvent& event); - /** Called when a mouse button has been double-clicked in this component. + /** Called when a mouse button has been double-clicked on a component. The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time. - For altering the time limit used to detect double-clicks, - see MouseEvent::setDoubleClickTimeout. - - @param e details about the position and status of the mouse event - @see mouseDown, mouseUp, MouseEvent::setDoubleClickTimeout, - MouseEvent::getDoubleClickTimeout + @param event details about the position and status of the mouse event, including + the source component in which it occurred + @see mouseDown, mouseUp */ - virtual void mouseDoubleClick (const MouseEvent& e); + virtual void mouseDoubleClick (const MouseEvent& event); /** Called when the mouse-wheel is moved. This callback is sent to the component that the mouse is over when the wheel is moved. - If not overridden, the component will forward this message to its parent, so + If not overridden, a component will forward this message to its parent, so that parent components can collect mouse-wheel messages that happen to child components which aren't interested in them. - @param e details about the position and status of the mouse event - @param wheelIncrementX the speed and direction of the horizontal scroll-wheel - a positive - value means the wheel has been pushed to the right, negative means it - was pushed to the left - @param wheelIncrementY the speed and direction of the vertical scroll-wheel - a positive - value means the wheel has been pushed upwards, negative means it - was pushed downwards + @param event details about the mouse event + @param wheel details about the mouse wheel movement */ - virtual void mouseWheelMove (const MouseEvent& e, - float wheelIncrementX, - float wheelIncrementY); + virtual void mouseWheelMove (const MouseEvent& event, + const MouseWheelDetails& wheel); //============================================================================== /** Ensures that a non-stop stream of mouse-drag events will be sent during the @@ -2318,7 +2303,7 @@ private: void internalMouseUp (MouseInputSource&, const Point&, const Time&, const ModifierKeys& oldModifiers); void internalMouseDrag (MouseInputSource&, const Point&, const Time&); void internalMouseMove (MouseInputSource&, const Point&, const Time&); - void internalMouseWheel (MouseInputSource&, const Point&, const Time&, float amountX, float amountY); + void internalMouseWheel (MouseInputSource&, const Point&, const Time&, const MouseWheelDetails&); void internalBroughtToFront(); void internalFocusGain (const FocusChangeType, const WeakReference&); void internalFocusGain (const FocusChangeType); diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index 8ec7909b05..47a712db9b 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -380,11 +380,9 @@ void ScrollBar::mouseUp (const MouseEvent&) repaint(); } -void ScrollBar::mouseWheelMove (const MouseEvent&, - float wheelIncrementX, - float wheelIncrementY) +void ScrollBar::mouseWheelMove (const MouseEvent&, const MouseWheelDetails& wheel) { - float increment = 10.0f * (vertical ? wheelIncrementY : wheelIncrementX); + float increment = 10.0f * (vertical ? wheel.deltaY : wheel.deltaX); if (increment < 0) increment = jmin (increment, -1.0f); diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.h b/modules/juce_gui_basics/layout/juce_ScrollBar.h index 385f485aa9..8c30ef5bdb 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.h +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.h @@ -289,21 +289,21 @@ public: //============================================================================== /** @internal */ - bool keyPressed (const KeyPress& key); + bool keyPressed (const KeyPress&); /** @internal */ - void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY); + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); /** @internal */ void lookAndFeelChanged(); /** @internal */ void handleAsyncUpdate(); /** @internal */ - void mouseDown (const MouseEvent& e); + void mouseDown (const MouseEvent&); /** @internal */ - void mouseDrag (const MouseEvent& e); + void mouseDrag (const MouseEvent&); /** @internal */ - void mouseUp (const MouseEvent& e); + void mouseUp (const MouseEvent&); /** @internal */ - void paint (Graphics& g); + void paint (Graphics&); /** @internal */ void resized(); diff --git a/modules/juce_gui_basics/layout/juce_Viewport.cpp b/modules/juce_gui_basics/layout/juce_Viewport.cpp index 98ed93f3c7..5a774920b6 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.cpp +++ b/modules/juce_gui_basics/layout/juce_Viewport.cpp @@ -348,13 +348,13 @@ void Viewport::scrollBarMoved (ScrollBar* scrollBarThatHasMoved, double newRange } } -void Viewport::mouseWheelMove (const MouseEvent& e, const float wheelIncrementX, const float wheelIncrementY) +void Viewport::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) { - if (! useMouseWheelMoveIfNeeded (e, wheelIncrementX, wheelIncrementY)) - Component::mouseWheelMove (e, wheelIncrementX, wheelIncrementY); + if (! useMouseWheelMoveIfNeeded (e, wheel)) + Component::mouseWheelMove (e, wheel); } -bool Viewport::useMouseWheelMoveIfNeeded (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) +bool Viewport::useMouseWheelMoveIfNeeded (const MouseEvent& e, const MouseWheelDetails& wheel) { if (! (e.mods.isAltDown() || e.mods.isCtrlDown())) { @@ -363,6 +363,9 @@ bool Viewport::useMouseWheelMoveIfNeeded (const MouseEvent& e, float wheelIncrem if (hasHorzBar || hasVertBar) { + float wheelIncrementX = wheel.deltaX; + float wheelIncrementY = wheel.deltaY; + if (wheelIncrementX != 0) { wheelIncrementX *= 14.0f * singleStepX; diff --git a/modules/juce_gui_basics/layout/juce_Viewport.h b/modules/juce_gui_basics/layout/juce_Viewport.h index f6a8013e18..1d9c3df025 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.h +++ b/modules/juce_gui_basics/layout/juce_Viewport.h @@ -256,13 +256,13 @@ public: /** @internal */ void scrollBarMoved (ScrollBar* scrollBarThatHasMoved, double newRangeStart); /** @internal */ - void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY); + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); /** @internal */ - bool keyPressed (const KeyPress& key); + bool keyPressed (const KeyPress&); /** @internal */ - void componentMovedOrResized (Component& component, bool wasMoved, bool wasResized); + void componentMovedOrResized (Component&, bool wasMoved, bool wasResized); /** @internal */ - bool useMouseWheelMoveIfNeeded (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY); + bool useMouseWheelMoveIfNeeded (const MouseEvent&, const MouseWheelDetails&); private: //============================================================================== diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp index 04e6104a1e..44dd9bef6d 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp @@ -1617,7 +1617,7 @@ class SliderLabelComp : public Label public: SliderLabelComp() : Label (String::empty, String::empty) {} - void mouseWheelMove (const MouseEvent&, float, float) {} + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) {} }; Label* LookAndFeel::createSliderTextBox (Slider& slider) diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 87d6a52c92..b2e4f867cb 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -371,9 +371,9 @@ public: void mouseDrag (const MouseEvent&) { timerCallback(); } void mouseUp (const MouseEvent&) { timerCallback(); } - void mouseWheelMove (const MouseEvent&, float /*amountX*/, float amountY) + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails& wheel) { - alterChildYPos (roundToInt (-10.0f * amountY * PopupMenuSettings::scrollZone)); + alterChildYPos (roundToInt (-10.0f * wheel.deltaY * PopupMenuSettings::scrollZone)); lastMousePos = Point (-1, -1); } @@ -1471,7 +1471,7 @@ int PopupMenu::showWithOptionalCallback (const Options& options, ModalComponentM #if JUCE_MODAL_LOOPS_PERMITTED return (userCallback == nullptr && canBeModal) ? window->runModalLoop() : 0; #else - jassert (userCallback != nullptr && canBeModal); + jassert (! (userCallback == nullptr && canBeModal)); return 0; #endif } @@ -1480,7 +1480,7 @@ int PopupMenu::showWithOptionalCallback (const Options& options, ModalComponentM #if JUCE_MODAL_LOOPS_PERMITTED int PopupMenu::showMenu (const Options& options) { - return showWithOptionalCallback (options, 0, true); + return showWithOptionalCallback (options, nullptr, true); } #endif diff --git a/modules/juce_gui_basics/mouse/juce_MouseEvent.h b/modules/juce_gui_basics/mouse/juce_MouseEvent.h index 3d26d0220a..4162c9f80d 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseEvent.h +++ b/modules/juce_gui_basics/mouse/juce_MouseEvent.h @@ -319,4 +319,41 @@ private: }; +//============================================================================== +/** + Contains status information about a mouse wheel event. + + @see MouseListener, MouseEvent +*/ +struct MouseWheelDetails +{ + //============================================================================== + /** The amount that the wheel has been moved in the X axis. + + If isReversed is true, then a negative deltaX means that the wheel has been + pushed physically to the left. + If isReversed is false, then a negative deltaX means that the wheel has been + pushed physically to the right. + */ + float deltaX; + + /** The amount that the wheel has been moved in the Y axis. + + If isReversed is true, then a negative deltaY means that the wheel has been + pushed physically upwards. + If isReversed is false, then a negative deltaY means that the wheel has been + pushed physically downwards. + */ + float deltaY; + + /** Indicates whether the user has reversed the direction of the wheel. + See deltaX and deltaY for an explanation of the effects of this value. + */ + bool isReversed; + + /** If true, then the wheel has continuous, un-stepped motion. */ + bool isSmooth; +}; + + #endif // __JUCE_MOUSEEVENT_JUCEHEADER__ diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp index d8a8891749..f163e0d4c8 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp @@ -120,10 +120,10 @@ public: comp->internalMouseUp (source, comp->getLocalPoint (nullptr, screenPos), time, oldMods); } - void sendMouseWheel (Component* const comp, const Point& screenPos, const Time& time, float x, float y) + void sendMouseWheel (Component* const comp, const Point& screenPos, const Time& time, const MouseWheelDetails& wheel) { //DBG ("Mouse " + String (source.getIndex()) + " wheel: " + comp->getLocalPoint (nullptr, screenPos).toString() + " - Comp: " + String::toHexString ((int) comp)); - comp->internalMouseWheel (source, comp->getLocalPoint (nullptr, screenPos), time, x, y); + comp->internalMouseWheel (source, comp->getLocalPoint (nullptr, screenPos), time, wheel); } //============================================================================== @@ -285,7 +285,8 @@ public: } } - void handleWheel (ComponentPeer* const peer, const Point& positionWithinPeer, const Time& time, float x, float y) + void handleWheel (ComponentPeer* const peer, const Point& positionWithinPeer, + const Time& time, const MouseWheelDetails& wheel) { jassert (peer != nullptr); lastTime = time; @@ -300,7 +301,7 @@ public: { Component* current = getComponentUnderMouse(); if (current != nullptr) - sendMouseWheel (current, screenPos, time, x, y); + sendMouseWheel (current, screenPos, time, wheel); } } @@ -522,12 +523,14 @@ void MouseInputSource::hideCursor() { pimpl- void MouseInputSource::revealCursor() { pimpl->revealCursor (false); } void MouseInputSource::forceMouseCursorUpdate() { pimpl->revealCursor (true); } -void MouseInputSource::handleEvent (ComponentPeer* peer, const Point& positionWithinPeer, const int64 time, const ModifierKeys& mods) +void MouseInputSource::handleEvent (ComponentPeer* peer, const Point& positionWithinPeer, + const int64 time, const ModifierKeys& mods) { pimpl->handleEvent (peer, positionWithinPeer, Time (time), mods.withOnlyMouseButtons()); } -void MouseInputSource::handleWheel (ComponentPeer* const peer, const Point& positionWithinPeer, const int64 time, const float x, const float y) +void MouseInputSource::handleWheel (ComponentPeer* const peer, const Point& positionWithinPeer, + const int64 time, const MouseWheelDetails& wheel) { - pimpl->handleWheel (peer, positionWithinPeer, Time (time), x, y); + pimpl->handleWheel (peer, positionWithinPeer, Time (time), wheel); } diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.h b/modules/juce_gui_basics/mouse/juce_MouseInputSource.h index 6d865f9026..fa46c16e5a 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.h +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.h @@ -166,9 +166,9 @@ public: //============================================================================== /** @internal */ - void handleEvent (ComponentPeer* peer, const Point& positionWithinPeer, int64 time, const ModifierKeys& mods); + void handleEvent (ComponentPeer*, const Point& positionWithinPeer, int64 time, const ModifierKeys&); /** @internal */ - void handleWheel (ComponentPeer* peer, const Point& positionWithinPeer, int64 time, float x, float y); + void handleWheel (ComponentPeer*, const Point& positionWithinPeer, int64 time, const MouseWheelDetails&); private: //============================================================================== diff --git a/modules/juce_gui_basics/mouse/juce_MouseListener.cpp b/modules/juce_gui_basics/mouse/juce_MouseListener.cpp index 1883ae3ede..d2233068f3 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseListener.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseListener.cpp @@ -30,4 +30,4 @@ void MouseListener::mouseUp (const MouseEvent&) {} void MouseListener::mouseDrag (const MouseEvent&) {} void MouseListener::mouseMove (const MouseEvent&) {} void MouseListener::mouseDoubleClick (const MouseEvent&) {} -void MouseListener::mouseWheelMove (const MouseEvent&, float, float) {} +void MouseListener::mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) {} diff --git a/modules/juce_gui_basics/mouse/juce_MouseListener.h b/modules/juce_gui_basics/mouse/juce_MouseListener.h index 4e62b9df51..b1d9d6a064 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseListener.h +++ b/modules/juce_gui_basics/mouse/juce_MouseListener.h @@ -27,6 +27,7 @@ #define __JUCE_MOUSELISTENER_JUCEHEADER__ class MouseEvent; +struct MouseWheelDetails; //============================================================================== /** @@ -48,11 +49,11 @@ public: A component will always get a mouseEnter callback before a mouseMove. - @param e details about the position and status of the mouse event, including - the source component in which it occurred + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseEnter, mouseExit, mouseDrag, contains */ - virtual void mouseMove (const MouseEvent& e); + virtual void mouseMove (const MouseEvent& event); /** Called when the mouse first enters a component. @@ -64,11 +65,11 @@ public: mouseDrag messages are sent to the component that the mouse was originally clicked on, until the button is released. - @param e details about the position and status of the mouse event, including - the source component in which it occurred + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseExit, mouseDrag, mouseMove, contains */ - virtual void mouseEnter (const MouseEvent& e); + virtual void mouseEnter (const MouseEvent& event); /** Called when the mouse moves out of a component. @@ -79,11 +80,11 @@ public: edge of the component and released, then this callback will happen when the button is released, after the mouseUp callback. - @param e details about the position and status of the mouse event, including - the source component in which it occurred + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseEnter, mouseDrag, mouseMove, contains */ - virtual void mouseExit (const MouseEvent& e); + virtual void mouseExit (const MouseEvent& event); /** Called when a mouse button is pressed. @@ -94,11 +95,11 @@ public: Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released. - @param e details about the position and status of the mouse event, including - the source component in which it occurred + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseUp, mouseDrag, mouseDoubleClick, contains */ - virtual void mouseDown (const MouseEvent& e); + virtual void mouseDown (const MouseEvent& event); /** Called when the mouse is moved while a button is held down. @@ -106,11 +107,11 @@ public: receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds. - @param e details about the position and status of the mouse event, including - the source component in which it occurred + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseDown, mouseUp, mouseMove, contains, setDragRepeatInterval */ - virtual void mouseDrag (const MouseEvent& e); + virtual void mouseDrag (const MouseEvent& event); /** Called when a mouse button is released. @@ -121,11 +122,11 @@ public: The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released. - @param e details about the position and status of the mouse event, including - the source component in which it occurred + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseDown, mouseDrag, mouseDoubleClick, contains */ - virtual void mouseUp (const MouseEvent& e); + virtual void mouseUp (const MouseEvent& event); /** Called when a mouse button has been double-clicked on a component. @@ -133,33 +134,34 @@ public: which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time. - @param e details about the position and status of the mouse event, including - the source component in which it occurred + @param event details about the position and status of the mouse event, including + the source component in which it occurred @see mouseDown, mouseUp */ - virtual void mouseDoubleClick (const MouseEvent& e); + virtual void mouseDoubleClick (const MouseEvent& event); /** Called when the mouse-wheel is moved. This callback is sent to the component that the mouse is over when the wheel is moved. - If not overridden, the component will forward this message to its parent, so + If not overridden, a component will forward this message to its parent, so that parent components can collect mouse-wheel messages that happen to child components which aren't interested in them. - @param e details about the position and status of the mouse event, including - the source component in which it occurred - @param wheelIncrementX the speed and direction of the horizontal scroll-wheel - a positive - value means the wheel has been pushed to the right, negative means it - was pushed to the left - @param wheelIncrementY the speed and direction of the vertical scroll-wheel - a positive - value means the wheel has been pushed upwards, negative means it - was pushed downwards + @param event details about the mouse event + @param wheel details about the wheel movement */ - virtual void mouseWheelMove (const MouseEvent& e, - float wheelIncrementX, - float wheelIncrementY); + virtual void mouseWheelMove (const MouseEvent& event, + const MouseWheelDetails& wheel); + + +private: + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // This is just here to cause a compile error in old code that hasn't been + // updated to use the new version of this method. + virtual int mouseWheelMove (const MouseEvent&, float, float) { return 0; } + #endif }; diff --git a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp index d9acf5dbd3..bea6b35cca 100644 --- a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp @@ -1403,8 +1403,14 @@ public: void handleWheelEvent (const XButtonPressedEvent* const buttonPressEvent, const float amount) { + MouseWheelDetails wheel; + wheel.deltaX = 0.0f; + wheel.deltaY = amount; + wheel.isReversed = false; + wheel.isSmooth = false; + handleMouseWheel (0, Point (buttonPressEvent->x, buttonPressEvent->y), - getEventTime (buttonPressEvent->time), 0, amount); + getEventTime (buttonPressEvent->time), wheel); } void handleButtonPressEvent (const XButtonPressedEvent* const buttonPressEvent, int buttonModifierFlag) @@ -1421,8 +1427,8 @@ public: switch (pointerMap [buttonPressEvent->button - Button1]) { - case Keys::WheelUp: handleWheelEvent (buttonPressEvent, 84.0f); break; - case Keys::WheelDown: handleWheelEvent (buttonPressEvent, -84.0f); break; + case Keys::WheelUp: handleWheelEvent (buttonPressEvent, 50.0f / 256.0f); break; + case Keys::WheelDown: handleWheelEvent (buttonPressEvent, -50.0f / 256.0f); break; case Keys::LeftButton: handleButtonPressEvent (buttonPressEvent, ModifierKeys::leftButtonModifier); break; case Keys::RightButton: handleButtonPressEvent (buttonPressEvent, ModifierKeys::rightButtonModifier); break; case Keys::MiddleButton: handleButtonPressEvent (buttonPressEvent, ModifierKeys::middleButtonModifier); break; @@ -2509,12 +2515,12 @@ private: void initialisePointerMap() { const int numButtons = XGetPointerMapping (display, 0, 0); + pointerMap[2] = pointerMap[3] = pointerMap[4] = Keys::NoButton; if (numButtons == 2) { pointerMap[0] = Keys::LeftButton; pointerMap[1] = Keys::RightButton; - pointerMap[2] = pointerMap[3] = pointerMap[4] = Keys::NoButton; } else if (numButtons >= 3) { diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 4143bb6c38..8e4558dc28 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -40,6 +40,7 @@ extern CheckEventBlockedByModalComps isEventBlockedByModalComps; - (CGFloat) scrollingDeltaX; - (CGFloat) scrollingDeltaX; - (BOOL) hasPreciseScrollingDeltas; + - (BOOL) isDirectionInvertedFromDevice; #endif @end @@ -1580,36 +1581,47 @@ void NSViewComponentPeer::redirectMouseWheel (NSEvent* ev) { updateModifiers (ev); - float x = 0, y = 0; + MouseWheelDetails wheel; + wheel.deltaX = 0; + wheel.deltaY = 0; + wheel.isReversed = false; + wheel.isSmooth = false; @try { #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if ([ev respondsToSelector: @selector (isDirectionInvertedFromDevice)]) + wheel.isReversed = [ev isDirectionInvertedFromDevice]; + + const float scale = 0.5f / 256.0f; + if ([ev respondsToSelector: @selector (hasPreciseScrollingDeltas)]) { if ([ev hasPreciseScrollingDeltas]) { - x = [ev scrollingDeltaX] * 0.5f; - y = [ev scrollingDeltaY] * 0.5f; + wheel.deltaX = [ev scrollingDeltaX] * scale; + wheel.deltaY = [ev scrollingDeltaY] * scale; + wheel.isSmooth = true; } } else #endif { - x = [ev deviceDeltaX] * 0.5f; - y = [ev deviceDeltaY] * 0.5f; + wheel.deltaX = [ev deviceDeltaX] * scale; + wheel.deltaY = [ev deviceDeltaY] * scale; } } @catch (...) {} - if (x == 0 && y == 0) + if (wheel.deltaX == 0 && wheel.deltaY == 0) { - x = [ev deltaX] * 10.0f; - y = [ev deltaY] * 10.0f; + const float scale = 10.0f / 256.0f; + wheel.deltaX = [ev deltaX] * scale; + wheel.deltaY = [ev deltaY] * scale; } - handleMouseWheel (0, getMousePos (ev, view), getMouseTime (ev), x, y); + handleMouseWheel (0, getMousePos (ev, view), getMouseTime (ev), wheel); } void NSViewComponentPeer::showArrowCursorIfNeeded() diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 011549b952..f696562ad4 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -1693,7 +1693,7 @@ private: void doMouseWheel (const Point& globalPos, const WPARAM wParam, const bool isVertical) { updateKeyModifiers(); - const float amount = jlimit (-1000.0f, 1000.0f, 0.75f * (short) HIWORD (wParam)); + const float amount = jlimit (-1000.0f, 1000.0f, 0.5f * (short) HIWORD (wParam)); // Because Windows stupidly sends all wheel events to the window with the keyboard // focus, we have to redirect them here according to the mouse pos.. @@ -1703,9 +1703,13 @@ private: if (peer == nullptr) peer = this; - peer->handleMouseWheel (0, peer->globalToLocal (globalPos), getMouseEventTime(), - isVertical ? 0.0f : -amount, - isVertical ? amount : 0.0f); + MouseWheelDetails wheel; + wheel.deltaX = isVertical ? 0.0f : amount / -256.0f; + wheel.deltaY = isVertical ? amount / 256.0f : 0.0f; + wheel.isReversed = false; + wheel.isSmooth = false; + + peer->handleMouseWheel (0, peer->globalToLocal (globalPos), getMouseEventTime(), wheel); } void doTouchEvent (const int numInputs, HTOUCHINPUT eventHandle) diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 84990b4a6d..6a89d385d6 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -755,24 +755,24 @@ bool ListBox::keyStateChanged (const bool isKeyDown) || KeyPress::isKeyCurrentlyDown (KeyPress::returnKey)); } -void ListBox::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) +void ListBox::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) { bool eventWasUsed = false; - if (viewport->getHorizontalScrollBar()->isVisible() && wheelIncrementX != 0) + if (viewport->getHorizontalScrollBar()->isVisible() && wheel.deltaX != 0) { eventWasUsed = true; - viewport->getHorizontalScrollBar()->mouseWheelMove (e, wheelIncrementX, 0); + viewport->getHorizontalScrollBar()->mouseWheelMove (e, wheel); } - if (viewport->getVerticalScrollBar()->isVisible() && wheelIncrementY != 0) + if (viewport->getVerticalScrollBar()->isVisible() && wheel.deltaY != 0) { eventWasUsed = true; - viewport->getVerticalScrollBar()->mouseWheelMove (e, 0, wheelIncrementY); + viewport->getVerticalScrollBar()->mouseWheelMove (e, wheel); } if (! eventWasUsed) - Component::mouseWheelMove (e, wheelIncrementX, wheelIncrementY); + Component::mouseWheelMove (e, wheel); } void ListBox::mouseMove (const MouseEvent& e) diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.h b/modules/juce_gui_basics/widgets/juce_ListBox.h index b0c6270468..234caf838b 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -547,7 +547,7 @@ public: /** @internal */ void visibilityChanged(); /** @internal */ - void mouseWheelMove (const MouseEvent&, float wheelIncrementX, float wheelIncrementY); + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); /** @internal */ void mouseMove (const MouseEvent&); /** @internal */ diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 6b3667d5d2..6cdd8def95 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -942,7 +942,7 @@ public: } } - bool mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) + bool mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) { if (scrollWheelEnabled && style != TwoValueHorizontal @@ -954,7 +954,8 @@ public: valueBox->hideEditor (false); const double value = (double) currentValue.getValue(); - const double proportionDelta = (wheelIncrementX != 0 ? -wheelIncrementX : wheelIncrementY) * 0.15f; + const double proportionDelta = (wheel.deltaX != 0 ? -wheel.deltaX : wheel.deltaY) + * (wheel.isReversed ? -0.15f : 0.15f); const double currentPos = owner.valueToProportionOfLength (value); const double newValue = owner.proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + proportionDelta)); @@ -1557,10 +1558,10 @@ void Slider::mouseDoubleClick (const MouseEvent&) pimpl->mouseDoubleClick(); } -void Slider::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) +void Slider::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) { - if (! (isEnabled() && pimpl->mouseWheelMove (e, wheelIncrementX, wheelIncrementY))) - Component::mouseWheelMove (e, wheelIncrementX, wheelIncrementY); + if (! (isEnabled() && pimpl->mouseWheelMove (e, wheel))) + Component::mouseWheelMove (e, wheel); } void SliderListener::sliderDragStarted (Slider*) {} // (can't write Slider::Listener due to idiotic VC2005 bug) diff --git a/modules/juce_gui_basics/widgets/juce_Slider.h b/modules/juce_gui_basics/widgets/juce_Slider.h index b4faf5e8d5..ff154c8253 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.h +++ b/modules/juce_gui_basics/widgets/juce_Slider.h @@ -804,7 +804,7 @@ protected: /** @internal */ void mouseDoubleClick (const MouseEvent&); /** @internal */ - void mouseWheelMove (const MouseEvent&, float wheelIncrementX, float wheelIncrementY); + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); /** @internal */ void modifierKeysChanged (const ModifierKeys&); /** @internal */ diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 36e0901c64..92acbc473c 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1875,10 +1875,10 @@ void TextEditor::mouseDoubleClick (const MouseEvent& e) moveCaretTo (tokenStart, true); } -void TextEditor::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) +void TextEditor::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) { - if (! viewport->useMouseWheelMoveIfNeeded (e, wheelIncrementX, wheelIncrementY)) - Component::mouseWheelMove (e, wheelIncrementX, wheelIncrementY); + if (! viewport->useMouseWheelMoveIfNeeded (e, wheel)) + Component::mouseWheelMove (e, wheel); } //============================================================================== diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index d0c988b35e..9de1c1a812 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -511,7 +511,7 @@ public: /** @internal */ void mouseDoubleClick (const MouseEvent& e); /** @internal */ - void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY); + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); /** @internal */ bool keyPressed (const KeyPress& key); /** @internal */ diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index e1a9246559..202edb5dc1 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -92,12 +92,12 @@ void ComponentPeer::handleMouseEvent (const int touchIndex, const Point& po mouse->handleEvent (this, positionWithinPeer, time, newMods); } -void ComponentPeer::handleMouseWheel (const int touchIndex, const Point& positionWithinPeer, const int64 time, const float x, const float y) +void ComponentPeer::handleMouseWheel (const int touchIndex, const Point& positionWithinPeer, const int64 time, const MouseWheelDetails& wheel) { MouseInputSource* const mouse = Desktop::getInstance().getMouseSource (touchIndex); jassert (mouse != nullptr); // not enough sources! - mouse->handleWheel (this, positionWithinPeer, time, x, y); + mouse->handleWheel (this, positionWithinPeer, time, wheel); } //============================================================================== diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.h b/modules/juce_gui_basics/windows/juce_ComponentPeer.h index 17e9b445e9..bb7091f6a6 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.h +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.h @@ -307,7 +307,7 @@ public: //============================================================================== void handleMouseEvent (int touchIndex, const Point& positionWithinPeer, const ModifierKeys& newMods, int64 time); - void handleMouseWheel (int touchIndex, const Point& positionWithinPeer, int64 time, float x, float y); + void handleMouseWheel (int touchIndex, const Point& positionWithinPeer, int64 time, const MouseWheelDetails&); void handleUserClosingWindow(); diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index c50d67ed68..7f40dd6e15 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -986,17 +986,26 @@ void CodeEditorComponent::mouseDoubleClick (const MouseEvent& e) moveCaretTo (tokenStart, true); } -void CodeEditorComponent::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) +void CodeEditorComponent::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) { - if ((verticalScrollBar.isVisible() && wheelIncrementY != 0) - || (horizontalScrollBar.isVisible() && wheelIncrementX != 0)) + if ((verticalScrollBar.isVisible() && wheel.deltaY != 0) + || (horizontalScrollBar.isVisible() && wheel.deltaX != 0)) { - verticalScrollBar.mouseWheelMove (e, 0, wheelIncrementY); - horizontalScrollBar.mouseWheelMove (e, wheelIncrementX, 0); + { + MouseWheelDetails w (wheel); + w.deltaX = 0; + verticalScrollBar.mouseWheelMove (e, w); + } + + { + MouseWheelDetails w (wheel); + w.deltaY = 0; + horizontalScrollBar.mouseWheelMove (e, w); + } } else { - Component::mouseWheelMove (e, wheelIncrementX, wheelIncrementY); + Component::mouseWheelMove (e, wheel); } } diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h index f7beefc58a..b4ffe397e5 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h @@ -221,27 +221,27 @@ public: /** @internal */ void resized(); /** @internal */ - void paint (Graphics& g); + void paint (Graphics&); /** @internal */ - bool keyPressed (const KeyPress& key); + bool keyPressed (const KeyPress&); /** @internal */ - void mouseDown (const MouseEvent& e); + void mouseDown (const MouseEvent&); /** @internal */ - void mouseDrag (const MouseEvent& e); + void mouseDrag (const MouseEvent&); /** @internal */ - void mouseUp (const MouseEvent& e); + void mouseUp (const MouseEvent&); /** @internal */ - void mouseDoubleClick (const MouseEvent& e); + void mouseDoubleClick (const MouseEvent&); /** @internal */ - void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY); + void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&); /** @internal */ - void focusGained (FocusChangeType cause); + void focusGained (FocusChangeType); /** @internal */ - void focusLost (FocusChangeType cause); + void focusLost (FocusChangeType); /** @internal */ void timerCallback(); /** @internal */ - void scrollBarMoved (ScrollBar* scrollBarThatHasMoved, double newRangeStart); + void scrollBarMoved (ScrollBar*, double newRangeStart); /** @internal */ void handleAsyncUpdate(); /** @internal */