The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
6.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. MouseInputSource::MouseInputSource (detail::MouseInputSourceImpl* s) noexcept : pimpl (s) {}
  22. MouseInputSource::MouseInputSource (const MouseInputSource& other) noexcept : pimpl (other.pimpl) {}
  23. MouseInputSource::~MouseInputSource() noexcept {}
  24. MouseInputSource& MouseInputSource::operator= (const MouseInputSource& other) noexcept
  25. {
  26. pimpl = other.pimpl;
  27. return *this;
  28. }
  29. MouseInputSource::InputSourceType MouseInputSource::getType() const noexcept { return pimpl->inputType; }
  30. bool MouseInputSource::isMouse() const noexcept { return (getType() == MouseInputSource::InputSourceType::mouse); }
  31. bool MouseInputSource::isTouch() const noexcept { return (getType() == MouseInputSource::InputSourceType::touch); }
  32. bool MouseInputSource::isPen() const noexcept { return (getType() == MouseInputSource::InputSourceType::pen); }
  33. bool MouseInputSource::canHover() const noexcept { return ! isTouch(); }
  34. bool MouseInputSource::hasMouseWheel() const noexcept { return ! isTouch(); }
  35. int MouseInputSource::getIndex() const noexcept { return pimpl->index; }
  36. bool MouseInputSource::isDragging() const noexcept { return pimpl->isDragging(); }
  37. Point<float> MouseInputSource::getScreenPosition() const noexcept { return pimpl->getScreenPosition(); }
  38. Point<float> MouseInputSource::getRawScreenPosition() const noexcept { return pimpl->getRawScreenPosition(); }
  39. ModifierKeys MouseInputSource::getCurrentModifiers() const noexcept { return pimpl->getCurrentModifiers(); }
  40. float MouseInputSource::getCurrentPressure() const noexcept { return pimpl->lastPointerState.pressure; }
  41. bool MouseInputSource::isPressureValid() const noexcept { return pimpl->lastPointerState.isPressureValid(); }
  42. float MouseInputSource::getCurrentOrientation() const noexcept { return pimpl->lastPointerState.orientation; }
  43. bool MouseInputSource::isOrientationValid() const noexcept { return pimpl->lastPointerState.isOrientationValid(); }
  44. float MouseInputSource::getCurrentRotation() const noexcept { return pimpl->lastPointerState.rotation; }
  45. bool MouseInputSource::isRotationValid() const noexcept { return pimpl->lastPointerState.isRotationValid(); }
  46. float MouseInputSource::getCurrentTilt (bool tiltX) const noexcept { return tiltX ? pimpl->lastPointerState.tiltX : pimpl->lastPointerState.tiltY; }
  47. bool MouseInputSource::isTiltValid (bool isX) const noexcept { return pimpl->lastPointerState.isTiltValid (isX); }
  48. Component* MouseInputSource::getComponentUnderMouse() const { return pimpl->getComponentUnderMouse(); }
  49. void MouseInputSource::triggerFakeMove() const { pimpl->triggerFakeMove(); }
  50. int MouseInputSource::getNumberOfMultipleClicks() const noexcept { return pimpl->getNumberOfMultipleClicks(); }
  51. Time MouseInputSource::getLastMouseDownTime() const noexcept { return pimpl->getLastMouseDownTime(); }
  52. Point<float> MouseInputSource::getLastMouseDownPosition() const noexcept { return pimpl->getLastMouseDownPosition(); }
  53. bool MouseInputSource::isLongPressOrDrag() const noexcept { return pimpl->isLongPressOrDrag(); }
  54. bool MouseInputSource::hasMovedSignificantlySincePressed() const noexcept { return pimpl->hasMovedSignificantlySincePressed(); }
  55. bool MouseInputSource::canDoUnboundedMovement() const noexcept { return ! isTouch(); }
  56. void MouseInputSource::enableUnboundedMouseMovement (bool isEnabled, bool keepCursorVisibleUntilOffscreen) const
  57. { pimpl->enableUnboundedMouseMovement (isEnabled, keepCursorVisibleUntilOffscreen); }
  58. bool MouseInputSource::isUnboundedMouseMovementEnabled() const { return pimpl->isUnboundedMouseModeOn; }
  59. bool MouseInputSource::hasMouseCursor() const noexcept { return ! isTouch(); }
  60. void MouseInputSource::showMouseCursor (const MouseCursor& cursor) { pimpl->showMouseCursor (cursor, false); }
  61. void MouseInputSource::hideCursor() { pimpl->hideCursor(); }
  62. void MouseInputSource::revealCursor() { pimpl->revealCursor (false); }
  63. void MouseInputSource::forceMouseCursorUpdate() { pimpl->revealCursor (true); }
  64. void MouseInputSource::setScreenPosition (Point<float> p) { pimpl->setScreenPosition (p); }
  65. void MouseInputSource::handleEvent (ComponentPeer& peer, Point<float> pos, int64 time, ModifierKeys mods,
  66. float pressure, float orientation, const PenDetails& penDetails)
  67. {
  68. pimpl->handleEvent (peer, pos, Time (time), mods.withOnlyMouseButtons(), pressure, orientation, penDetails);
  69. }
  70. void MouseInputSource::handleWheel (ComponentPeer& peer, Point<float> pos, int64 time, const MouseWheelDetails& wheel)
  71. {
  72. pimpl->handleWheel (peer, pos, Time (time), wheel);
  73. }
  74. void MouseInputSource::handleMagnifyGesture (ComponentPeer& peer, Point<float> pos, int64 time, float scaleFactor)
  75. {
  76. pimpl->handleMagnifyGesture (peer, pos, Time (time), scaleFactor);
  77. }
  78. const float MouseInputSource::invalidPressure = 0.0f;
  79. const float MouseInputSource::invalidOrientation = 0.0f;
  80. const float MouseInputSource::invalidRotation = 0.0f;
  81. const float MouseInputSource::invalidTiltX = 0.0f;
  82. const float MouseInputSource::invalidTiltY = 0.0f;
  83. const Point<float> MouseInputSource::offscreenMousePos { -10.0f, -10.0f };
  84. // Deprecated method
  85. bool MouseInputSource::hasMouseMovedSignificantlySincePressed() const noexcept { return pimpl->hasMouseMovedSignificantlySincePressed(); }
  86. } // namespace juce