JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_MouseInputSource.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
30MouseInputSource::MouseInputSource (detail::MouseInputSourceImpl* s) noexcept : pimpl (s) {}
31MouseInputSource::MouseInputSource (const MouseInputSource& other) noexcept : pimpl (other.pimpl) {}
32MouseInputSource::~MouseInputSource() noexcept {}
33
34MouseInputSource& MouseInputSource::operator= (const MouseInputSource& other) noexcept
35{
36 pimpl = other.pimpl;
37 return *this;
38}
39
41bool MouseInputSource::isMouse() const noexcept { return (getType() == MouseInputSource::InputSourceType::mouse); }
42bool MouseInputSource::isTouch() const noexcept { return (getType() == MouseInputSource::InputSourceType::touch); }
43bool MouseInputSource::isPen() const noexcept { return (getType() == MouseInputSource::InputSourceType::pen); }
44bool MouseInputSource::canHover() const noexcept { return ! isTouch(); }
45bool MouseInputSource::hasMouseWheel() const noexcept { return ! isTouch(); }
46int MouseInputSource::getIndex() const noexcept { return pimpl->index; }
47bool MouseInputSource::isDragging() const noexcept { return pimpl->isDragging(); }
48Point<float> MouseInputSource::getScreenPosition() const noexcept { return pimpl->getScreenPosition(); }
49Point<float> MouseInputSource::getRawScreenPosition() const noexcept { return pimpl->getRawScreenPosition(); }
50ModifierKeys MouseInputSource::getCurrentModifiers() const noexcept { return pimpl->getCurrentModifiers(); }
51float MouseInputSource::getCurrentPressure() const noexcept { return pimpl->lastPointerState.pressure; }
52bool MouseInputSource::isPressureValid() const noexcept { return pimpl->lastPointerState.isPressureValid(); }
53float MouseInputSource::getCurrentOrientation() const noexcept { return pimpl->lastPointerState.orientation; }
54bool MouseInputSource::isOrientationValid() const noexcept { return pimpl->lastPointerState.isOrientationValid(); }
55float MouseInputSource::getCurrentRotation() const noexcept { return pimpl->lastPointerState.rotation; }
56bool MouseInputSource::isRotationValid() const noexcept { return pimpl->lastPointerState.isRotationValid(); }
57float MouseInputSource::getCurrentTilt (bool tiltX) const noexcept { return tiltX ? pimpl->lastPointerState.tiltX : pimpl->lastPointerState.tiltY; }
58bool MouseInputSource::isTiltValid (bool isX) const noexcept { return pimpl->lastPointerState.isTiltValid (isX); }
59Component* MouseInputSource::getComponentUnderMouse() const { return pimpl->getComponentUnderMouse(); }
60void MouseInputSource::triggerFakeMove() const { pimpl->triggerFakeMove(); }
61int MouseInputSource::getNumberOfMultipleClicks() const noexcept { return pimpl->getNumberOfMultipleClicks(); }
62Time MouseInputSource::getLastMouseDownTime() const noexcept { return pimpl->getLastMouseDownTime(); }
63Point<float> MouseInputSource::getLastMouseDownPosition() const noexcept { return pimpl->getLastMouseDownPosition(); }
64bool MouseInputSource::isLongPressOrDrag() const noexcept { return pimpl->isLongPressOrDrag(); }
65bool MouseInputSource::hasMovedSignificantlySincePressed() const noexcept { return pimpl->hasMovedSignificantlySincePressed(); }
68 { pimpl->enableUnboundedMouseMovement (isEnabled, keepCursorVisibleUntilOffscreen); }
69bool MouseInputSource::isUnboundedMouseMovementEnabled() const { return pimpl->isUnboundedMouseModeOn; }
70bool MouseInputSource::hasMouseCursor() const noexcept { return ! isTouch(); }
71void MouseInputSource::showMouseCursor (const MouseCursor& cursor) { pimpl->showMouseCursor (cursor, false); }
72void MouseInputSource::hideCursor() { pimpl->hideCursor(); }
73void MouseInputSource::revealCursor() { pimpl->revealCursor (false); }
74void MouseInputSource::forceMouseCursorUpdate() { pimpl->revealCursor (true); }
75void MouseInputSource::setScreenPosition (Point<float> p) { pimpl->setScreenPosition (p); }
76
77void MouseInputSource::handleEvent (ComponentPeer& peer, Point<float> pos, int64 time, ModifierKeys mods,
78 float pressure, float orientation, const PenDetails& penDetails)
79{
80 pimpl->handleEvent (peer, pos, Time (time), mods.withOnlyMouseButtons(), pressure, orientation, penDetails);
81}
82
83void MouseInputSource::handleWheel (ComponentPeer& peer, Point<float> pos, int64 time, const MouseWheelDetails& wheel)
84{
85 pimpl->handleWheel (peer, pos, Time (time), wheel);
86}
87
88void MouseInputSource::handleMagnifyGesture (ComponentPeer& peer, Point<float> pos, int64 time, float scaleFactor)
89{
90 pimpl->handleMagnifyGesture (peer, pos, Time (time), scaleFactor);
91}
92
93const float MouseInputSource::invalidPressure = 0.0f;
95const float MouseInputSource::invalidRotation = 0.0f;
96
97const float MouseInputSource::invalidTiltX = 0.0f;
98const float MouseInputSource::invalidTiltY = 0.0f;
99
100const Point<float> MouseInputSource::offscreenMousePos { -10.0f, -10.0f };
101
102// Deprecated method
103bool MouseInputSource::hasMouseMovedSignificantlySincePressed() const noexcept { return pimpl->hasMouseMovedSignificantlySincePressed(); }
104
105} // namespace juce
The Component class uses a ComponentPeer internally to create and manage a real operating-system wind...
The base class for all JUCE user-interface objects.
Represents the state of the mouse buttons and modifier keys.
ModifierKeys withOnlyMouseButtons() const noexcept
Returns a copy of only the mouse-button flags.
Represents a mouse cursor image.
bool isPressureValid() const noexcept
Returns true if the current pressure value is meaningful.
void triggerFakeMove() const
Tells the device to dispatch a mouse-move or mouse-drag event.
MouseInputSource::InputSourceType getType() const noexcept
Returns the type of input source that this object represents.
Point< float > getScreenPosition() const noexcept
Returns the last-known screen position of this source.
static const float invalidRotation
A default value for rotation, which is used when a device doesn't support it.
bool isTiltValid(bool tiltX) const noexcept
Returns true if the current tilt value (either x- or y-axis) is meaningful.
void enableUnboundedMouseMovement(bool isEnabled, bool keepCursorVisibleUntilOffscreen=false) const
Allows the mouse to move beyond the edges of the screen.
bool hasMouseWheel() const noexcept
Returns true if this source may have a scroll wheel.
Point< float > getRawScreenPosition() const noexcept
Returns the last-known screen position of this source without any scaling applied.
bool isRotationValid() const noexcept
Returns true if the current rotation value is meaningful.
void revealCursor()
Un-hides the mouse cursor if it was hidden by hideCursor().
float getCurrentTilt(bool tiltX) const noexcept
Returns the angle of tilt of the pointer in a range of -1.0 to 1.0 either in the x- or y-axis.
int getIndex() const noexcept
Returns this source's index in the global list of possible sources.
void setScreenPosition(Point< float > newPosition)
Attempts to set this mouse pointer's screen position.
static const float invalidTiltX
Default values for tilt, which are used when a device doesn't support it.
bool isTouch() const noexcept
Returns true if this object represents a source of touch events.
bool hasMouseCursor() const noexcept
Returns true if this input source uses a visible mouse cursor.
int getNumberOfMultipleClicks() const noexcept
Returns the number of clicks that should be counted as belonging to the current mouse event.
bool isPen() const noexcept
Returns true if this object represents a pen device.
ModifierKeys getCurrentModifiers() const noexcept
Returns a set of modifiers that indicate which buttons are currently held down on this device.
void forceMouseCursorUpdate()
Forces an update of the mouse cursor for whatever component it's currently over.
Time getLastMouseDownTime() const noexcept
Returns the time at which the last mouse-down occurred.
void hideCursor()
Hides the mouse cursor (if there is one).
InputSourceType
Possible mouse input sources.
bool isDragging() const noexcept
Returns true if this device is currently being pressed.
bool isMouse() const noexcept
Returns true if this object represents a normal desk-based mouse device.
Component * getComponentUnderMouse() const
Returns the component that was last known to be under this pointer.
float getCurrentRotation() const noexcept
Returns the device's current rotation.
bool canDoUnboundedMovement() const noexcept
Returns true if this mouse can be moved indefinitely in any direction without running out of space.
void showMouseCursor(const MouseCursor &cursor)
Changes the mouse cursor, (if there is one).
static const float invalidPressure
A default value for pressure, which is used when a device doesn't support it.
bool hasMovedSignificantlySincePressed() const noexcept
Returns true if this input source has been dragged more than a couple of pixels from the place it was...
bool isLongPressOrDrag() const noexcept
Returns true if this input source represents a long-press or drag interaction i.e.
Point< float > getLastMouseDownPosition() const noexcept
Returns the screen position at which the last mouse-down occurred.
static const float invalidOrientation
A default value for orientation, which is used when a device doesn't support it.
float getCurrentOrientation() const noexcept
Returns the device's current orientation in radians.
bool canHover() const noexcept
Returns true if this source has an on-screen pointer that can hover over items without clicking them.
bool isUnboundedMouseMovementEnabled() const
Returns true if this source is currently in "unbounded" mode.
float getCurrentPressure() const noexcept
Returns the device's current touch or pen pressure.
static const Point< float > offscreenMousePos
An offscreen mouse position used when triggering mouse exits where we don't want to move the cursor o...
bool isOrientationValid() const noexcept
Returns true if the current orientation value is meaningful.
A pair of (x, y) coordinates.
Definition juce_Point.h:42
Holds an absolute date and time.
Definition juce_Time.h:37
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
long long int64
A platform-independent 64-bit integer type.
Contains status information about a pen event.