openshot-audio  0.1.6
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) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_MULTITOUCHMAPPER_H_INCLUDED
26 #define JUCE_MULTITOUCHMAPPER_H_INCLUDED
27 
28 template <typename IDType>
30 {
31 public:
33 
34  int getIndexOfTouch (IDType touchID)
35  {
36  jassert (touchID != 0); // need to rethink this if IDs can be 0!
37 
38  int touchIndex = currentTouches.indexOf (touchID);
39 
40  if (touchIndex < 0)
41  {
42  for (touchIndex = 0; touchIndex < currentTouches.size(); ++touchIndex)
43  if (currentTouches.getUnchecked (touchIndex) == 0)
44  break;
45 
46  currentTouches.set (touchIndex, touchID);
47  }
48 
49  return touchIndex;
50  }
51 
52  void clear()
53  {
54  currentTouches.clear();
55  }
56 
57  void clearTouch (int index)
58  {
59  currentTouches.set (index, 0);
60  }
61 
63  {
64  for (int i = currentTouches.size(); --i >= 0;)
65  if (currentTouches.getUnchecked(i) != 0)
66  return true;
67 
68  return false;
69  }
70 
71 private:
72  Array<IDType> currentTouches;
73 
75 };
76 
77 #endif // JUCE_MULTITOUCHMAPPER_H_INCLUDED
#define noexcept
Definition: juce_CompilerSupport.h:141
int getIndexOfTouch(IDType touchID)
Definition: juce_MultiTouchMapper.h:34
Definition: juce_MultiTouchMapper.h:29
bool areAnyTouchesActive() const noexcept
Definition: juce_MultiTouchMapper.h:62
int indexOf(ParameterType elementToLookFor) const
Definition: juce_Array.h:355
MultiTouchMapper()
Definition: juce_MultiTouchMapper.h:32
void clearTouch(int index)
Definition: juce_MultiTouchMapper.h:57
void clear()
Definition: juce_MultiTouchMapper.h:52
#define jassert(a)
Definition: juce_PlatformDefs.h:146
void set(const int indexToChange, ParameterType newValue)
Definition: juce_Array.h:556
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
ElementType getUnchecked(const int index) const
Definition: juce_Array.h:258
void clear()
Definition: juce_Array.h:200
int size() const noexcept
Definition: juce_Array.h:221