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_MouseEvent.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
30 Point<float> pos,
32 float force,
33 float o, float r,
34 float tX, float tY,
35 Component* const eventComp,
36 Component* const originator,
37 Time time,
40 const int numClicks,
41 const bool mouseWasDragged) noexcept
42 : position (pos),
43 x (roundToInt (pos.x)),
44 y (roundToInt (pos.y)),
45 mods (modKeys),
46 pressure (force),
47 orientation (o), rotation (r),
48 tiltX (tX), tiltY (tY),
49 mouseDownPosition (downPos),
50 eventComponent (eventComp),
51 originalComponent (originator),
52 eventTime (time),
53 mouseDownTime (downTime),
54 source (inputSource),
55 numberOfClicks ((uint8) numClicks),
56 wasMovedSinceMouseDown ((uint8) (mouseWasDragged ? 1 : 0))
57{
58}
59
60//==============================================================================
62{
63 jassert (otherComponent != nullptr);
64
65 return MouseEvent (source, otherComponent->getLocalPoint (eventComponent, position),
66 mods, pressure, orientation, rotation, tiltX, tiltY,
67 otherComponent, originalComponent, eventTime,
68 otherComponent->getLocalPoint (eventComponent, mouseDownPosition),
69 mouseDownTime, numberOfClicks, wasMovedSinceMouseDown != 0);
70}
71
73{
74 return MouseEvent (source, newPosition, mods, pressure, orientation, rotation, tiltX, tiltY,
75 eventComponent, originalComponent, eventTime, mouseDownPosition, mouseDownTime,
76 numberOfClicks, wasMovedSinceMouseDown != 0);
77}
78
80{
81 return MouseEvent (source, newPosition.toFloat(), mods, pressure, orientation, rotation,
82 tiltX, tiltY, eventComponent, originalComponent, eventTime, mouseDownPosition,
83 mouseDownTime, numberOfClicks, wasMovedSinceMouseDown != 0);
84}
85
86//==============================================================================
88{
89 return wasMovedSinceMouseDown != 0;
90}
91
96
98{
100 return jmax (0, (int) (eventTime - mouseDownTime).inMilliseconds());
101
102 return 0;
103}
104
105//==============================================================================
108
111
114
117
120
123
126
127bool MouseEvent::isPressureValid() const noexcept { return pressure > 0.0f && pressure < 1.0f; }
130bool MouseEvent::isTiltValid (bool isX) const noexcept { return isX ? (tiltX >= -1.0f && tiltX <= 1.0f) : (tiltY >= -1.0f && tiltY <= 1.0f); }
131
132//==============================================================================
133static int doubleClickTimeOutMs = 400;
134
135int MouseEvent::getDoubleClickTimeout() noexcept { return doubleClickTimeOutMs; }
136void MouseEvent::setDoubleClickTimeout (const int newTime) noexcept { doubleClickTimeOutMs = newTime; }
137
138} // namespace juce
The base class for all JUCE user-interface objects.
Point< int > localPointToGlobal(Point< int > localPoint) const
Converts a point relative to this component's top-left into a screen coordinate.
Represents the state of the mouse buttons and modifier keys.
Contains position and status information about a mouse event.
bool isOrientationValid() const noexcept
Returns true if the orientation value for this event is meaningful.
MouseEvent(MouseInputSource source, Point< float > position, ModifierKeys modifiers, float pressure, float orientation, float rotation, float tiltX, float tiltY, Component *eventComponent, Component *originator, Time eventTime, Point< float > mouseDownPos, Time mouseDownTime, int numberOfClicks, bool mouseWasDragged) noexcept
Creates a MouseEvent.
const Point< float > mouseDownPosition
The coordinates of the last place that a mouse button was pressed.
static int getDoubleClickTimeout() noexcept
Returns the application-wide setting for the double-click time limit.
Point< int > getOffsetFromDragStart() const noexcept
Returns the difference between the mouse's current position and where it was when the button was last...
int getMouseDownScreenX() const
Returns the x coordinate at which the mouse button was last pressed.
Point< int > getScreenPosition() const
Returns the mouse position of this event, in global screen coordinates.
const Time mouseDownTime
The time that the corresponding mouse-down event occurred.
int getMouseDownX() const noexcept
Returns the x coordinate of the last place that a mouse was pressed.
static void setDoubleClickTimeout(int timeOutMilliseconds) noexcept
Changes the application-wide setting for the double-click time limit.
Point< int > getPosition() const noexcept
The position of the mouse when the event occurred.
Point< int > getMouseDownPosition() const noexcept
Returns the coordinates of the last place that a mouse was pressed.
MouseEvent getEventRelativeTo(Component *newComponent) const noexcept
Creates a version of this event that is relative to a different component.
bool isRotationValid() const noexcept
Returns true if the rotation value for this event is meaningful.
const float orientation
The orientation of the touch input for this event in radians where 0 indicates a touch aligned with t...
const int x
The x-position of the mouse when the event occurred.
const float pressure
The pressure of the touch or stylus for this event.
const Point< float > position
The position of the mouse when the event occurred.
bool mouseWasDraggedSinceMouseDown() const noexcept
Returns true if the user seems to be performing a drag gesture.
bool isPressureValid() const noexcept
Returns true if the pressure value for this event is meaningful.
int getMouseDownScreenY() const
Returns the y coordinate at which the mouse button was last pressed.
const int y
The y-position of the mouse when the event occurred.
const float rotation
The rotation of the pen device for this event in radians.
const Time eventTime
The time that this mouse-event occurred.
Component *const eventComponent
The component that this event applies to.
int getLengthOfMousePress() const noexcept
Returns the time that the mouse button has been held down for.
Point< int > getMouseDownScreenPosition() const
Returns the coordinates at which the mouse button was last pressed.
MouseEvent withNewPosition(Point< float > newPosition) const noexcept
Creates a copy of this event with a different position.
int getScreenY() const
Returns the mouse y position of this event, in global screen coordinates.
int getDistanceFromDragStart() const noexcept
Returns the straight-line distance between where the mouse is now and where it was the last time the ...
int getScreenX() const
Returns the mouse x position of this event, in global screen coordinates.
bool isTiltValid(bool tiltX) const noexcept
Returns true if the current tilt value (either x- or y-axis) is meaningful.
int getDistanceFromDragStartY() const noexcept
Returns the difference between the mouse's current y position and where it was when the button was la...
int getMouseDownY() const noexcept
Returns the y coordinate of the last place that a mouse was pressed.
bool mouseWasClicked() const noexcept
Returns true if the mouse event is part of a click gesture rather than a drag.
int getDistanceFromDragStartX() const noexcept
Returns the difference between the mouse's current x position and where it was when the button was la...
Represents a linear source of mouse events from a mouse device or individual finger in a multi-touch ...
A pair of (x, y) coordinates.
Definition juce_Point.h:42
ValueType getDistanceFrom(Point other) const noexcept
Returns the straight-line distance between this point and another one.
Definition juce_Point.h:165
constexpr Point< int > roundToInt() const noexcept
Casts this point to a Point<int> object using roundToInt() to convert the values.
Definition juce_Point.h:245
ValueType y
The point's Y coordinate.
Definition juce_Point.h:252
ValueType x
The point's X coordinate.
Definition juce_Point.h:251
Holds an absolute date and time.
Definition juce_Time.h:37
int64 toMilliseconds() const noexcept
Returns the time as a number of milliseconds.
Definition juce_Time.h:98
#define jassert(expression)
Platform-independent assertion macro.
JUCE Namespace.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
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
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.