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_PointerState.h
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::detail
27{
28
30{
31 auto tie() const noexcept
32 {
33 return std::tie (position, pressure, orientation, rotation, tiltX, tiltY);
34 }
35
36public:
37 PointerState() = default;
38
39 bool operator== (const PointerState& other) const noexcept { return tie() == other.tie(); }
40 bool operator!= (const PointerState& other) const noexcept { return tie() != other.tie(); }
41
42 [[nodiscard]] PointerState withPositionOffset (Point<float> x) const noexcept { return with (&PointerState::position, position + x); }
43 [[nodiscard]] PointerState withPosition (Point<float> x) const noexcept { return with (&PointerState::position, x); }
44 [[nodiscard]] PointerState withPressure (float x) const noexcept { return with (&PointerState::pressure, x); }
45 [[nodiscard]] PointerState withOrientation (float x) const noexcept { return with (&PointerState::orientation, x); }
46 [[nodiscard]] PointerState withRotation (float x) const noexcept { return with (&PointerState::rotation, x); }
47 [[nodiscard]] PointerState withTiltX (float x) const noexcept { return with (&PointerState::tiltX, x); }
48 [[nodiscard]] PointerState withTiltY (float x) const noexcept { return with (&PointerState::tiltY, x); }
49
50 Point<float> position;
51 float pressure = MouseInputSource::defaultPressure;
52 float orientation = MouseInputSource::defaultOrientation;
53 float rotation = MouseInputSource::defaultRotation;
55 float tiltY = MouseInputSource::defaultTiltY;
56
57 bool isPressureValid() const noexcept { return 0.0f <= pressure && pressure <= 1.0f; }
58 bool isOrientationValid() const noexcept { return 0.0f <= orientation && orientation <= MathConstants<float>::twoPi; }
59 bool isRotationValid() const noexcept { return 0.0f <= rotation && rotation <= MathConstants<float>::twoPi; }
60 bool isTiltValid (bool isX) const noexcept
61 {
62 return isX ? (-1.0f <= tiltX && tiltX <= 1.0f)
63 : (-1.0f <= tiltY && tiltY <= 1.0f);
64 }
65
66private:
67 template <typename Value>
68 PointerState with (Value PointerState::* member, Value item) const
69 {
70 auto copy = *this;
71 copy.*member = std::move (item);
72 return copy;
73 }
74};
75
76inline auto makeMouseEvent (MouseInputSource source,
77 const PointerState& ps,
79 Component* eventComponent,
80 Component* originator,
81 Time eventTime,
82 Point<float> mouseDownPos,
83 Time mouseDownTime,
84 int numberOfClicks,
85 bool mouseWasDragged)
86{
87 return MouseEvent (source,
88 ps.position,
90 ps.pressure,
91 ps.orientation,
92 ps.rotation,
93 ps.tiltX,
94 ps.tiltY,
95 eventComponent,
96 originator,
97 eventTime,
98 mouseDownPos,
99 mouseDownTime,
100 numberOfClicks,
102}
103
104} // namespace juce::detail
The base class for all JUCE user-interface objects.
Represents the state of the mouse buttons and modifier keys.
Contains position and status information about a mouse event.
Represents a linear source of mouse events from a mouse device or individual finger in a multi-touch ...
static constexpr float defaultRotation
A default value for rotation, which is used when a device doesn't support it.
static constexpr float defaultTiltX
Default values for tilt, which are used when a device doesn't support it.
static constexpr float defaultOrientation
A default value for orientation, which is used when a device doesn't support it.
static constexpr float defaultPressure
A default value for pressure, which is used when a device doesn't support it, or for mouse-moves,...
A pair of (x, y) coordinates.
Definition juce_Point.h:42
Holds an absolute date and time.
Definition juce_Time.h:37
Represents a shared variant value.
Definition juce_Value.h:51
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
T tie(T... args)