LMMS
Loading...
Searching...
No Matches
juce_MultiTouchMapper.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
26JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wzero-as-null-pointer-constant")
27
28namespace juce
29{
30
31template <typename IDType>
33{
34public:
36
37 int getIndexOfTouch (ComponentPeer* peer, IDType touchID)
38 {
39 jassert (touchID != 0); // need to rethink this if IDs can be 0!
40 TouchInfo info {touchID, peer};
41
42 int touchIndex = currentTouches.indexOf (info);
43
44 if (touchIndex < 0)
45 {
46 auto emptyTouchIndex = currentTouches.indexOf ({});
47 touchIndex = (emptyTouchIndex >= 0 ? emptyTouchIndex : currentTouches.size());
48
49 currentTouches.set (touchIndex, info);
50 }
51
52 return touchIndex;
53 }
54
55 void clear()
56 {
57 currentTouches.clear();
58 }
59
60 void clearTouch (int index)
61 {
62 currentTouches.set (index, {});
63 }
64
66 {
67 for (auto& t : currentTouches)
68 if (t.touchId != 0)
69 return true;
70
71 return false;
72 }
73
75 {
76 for (auto& t : currentTouches)
77 if (t.owner == peer)
78 t.touchId = 0;
79 }
80
81private:
82 //==============================================================================
83 struct TouchInfo
84 {
85 TouchInfo() noexcept : touchId (0), owner (nullptr) {}
86 TouchInfo (IDType idToUse, ComponentPeer* peer) noexcept : touchId (idToUse), owner (peer) {}
87
88 TouchInfo (const TouchInfo&) = default;
89 TouchInfo& operator= (const TouchInfo&) = default;
91 TouchInfo& operator= (TouchInfo&&) noexcept = default;
92
93 IDType touchId;
95
96 bool operator== (const TouchInfo& o) const noexcept { return (touchId == o.touchId); }
97 };
98
99 //==============================================================================
101
103};
104
105} // namespace juce
106
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_Array.h:56
Definition juce_ComponentPeer.h:44
MultiTouchMapper()
Definition juce_MultiTouchMapper.h:35
void clear()
Definition juce_MultiTouchMapper.h:55
void deleteAllTouchesForPeer(ComponentPeer *peer)
Definition juce_MultiTouchMapper.h:74
Array< TouchInfo > currentTouches
Definition juce_MultiTouchMapper.h:100
int getIndexOfTouch(ComponentPeer *peer, IDType touchID)
Definition juce_MultiTouchMapper.h:37
void clearTouch(int index)
Definition juce_MultiTouchMapper.h:60
bool areAnyTouchesActive() const noexcept
Definition juce_MultiTouchMapper.h:65
struct huft * t
Definition inflate.c:943
struct backing_store_struct * info
Definition jmemsys.h:183
#define JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE(...)
Definition juce_CompilerWarnings.h:181
#define JUCE_END_IGNORE_WARNINGS_GCC_LIKE
Definition juce_CompilerWarnings.h:182
#define jassert(expression)
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition carla_juce.cpp:31
Definition juce_MultiTouchMapper.h:84
ComponentPeer * owner
Definition juce_MultiTouchMapper.h:94
TouchInfo(IDType idToUse, ComponentPeer *peer) noexcept
Definition juce_MultiTouchMapper.h:86
TouchInfo(TouchInfo &&) noexcept=default
IDType touchId
Definition juce_MultiTouchMapper.h:93
TouchInfo(const TouchInfo &)=default
TouchInfo() noexcept
Definition juce_MultiTouchMapper.h:85
#define const
Definition zconf.h:137