openshot-audio  0.1.5
juce_ModifierKeys.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_MODIFIERKEYS_H_INCLUDED
26 #define JUCE_MODIFIERKEYS_H_INCLUDED
27 
28 
29 //==============================================================================
39 {
40 public:
41  //==============================================================================
44 
51  ModifierKeys (int flags) noexcept;
52 
54  ModifierKeys (const ModifierKeys& other) noexcept;
55 
57  ModifierKeys& operator= (const ModifierKeys other) noexcept;
58 
59  //==============================================================================
66  inline bool isCommandDown() const noexcept { return testFlags (commandModifier); }
67 
76  inline bool isPopupMenu() const noexcept { return testFlags (popupMenuClickModifier); }
77 
79  inline bool isLeftButtonDown() const noexcept { return testFlags (leftButtonModifier); }
80 
86  inline bool isRightButtonDown() const noexcept { return testFlags (rightButtonModifier); }
87 
88  inline bool isMiddleButtonDown() const noexcept { return testFlags (middleButtonModifier); }
89 
91  inline bool isAnyMouseButtonDown() const noexcept { return testFlags (allMouseButtonModifiers); }
92 
94  inline bool isAnyModifierKeyDown() const noexcept { return testFlags ((shiftModifier | ctrlModifier | altModifier | commandModifier)); }
95 
97  inline bool isShiftDown() const noexcept { return testFlags (shiftModifier); }
98 
106  inline bool isCtrlDown() const noexcept { return testFlags (ctrlModifier); }
107 
109  inline bool isAltDown() const noexcept { return testFlags (altModifier); }
110 
111  //==============================================================================
113  enum Flags
114  {
116  noModifiers = 0,
117 
119  shiftModifier = 1,
120 
122  ctrlModifier = 2,
123 
125  altModifier = 4,
126 
128  leftButtonModifier = 16,
129 
131  rightButtonModifier = 32,
132 
134  middleButtonModifier = 64,
135 
136  #if JUCE_MAC
137 
138  commandModifier = 8,
139 
142  popupMenuClickModifier = rightButtonModifier | ctrlModifier,
143  #else
144 
145  commandModifier = ctrlModifier,
146 
149  popupMenuClickModifier = rightButtonModifier,
150  #endif
151 
153  allKeyboardModifiers = shiftModifier | ctrlModifier | altModifier | commandModifier,
154 
156  allMouseButtonModifiers = leftButtonModifier | rightButtonModifier | middleButtonModifier,
157 
159  ctrlAltCommandModifiers = ctrlModifier | altModifier | commandModifier
160  };
161 
162  //==============================================================================
164  ModifierKeys withOnlyMouseButtons() const noexcept { return ModifierKeys (flags & allMouseButtonModifiers); }
165 
167  ModifierKeys withoutMouseButtons() const noexcept { return ModifierKeys (flags & ~allMouseButtonModifiers); }
168 
169  bool operator== (const ModifierKeys other) const noexcept { return flags == other.flags; }
170  bool operator!= (const ModifierKeys other) const noexcept { return flags != other.flags; }
171 
172  //==============================================================================
174  inline int getRawFlags() const noexcept { return flags; }
175 
176  ModifierKeys withoutFlags (int rawFlagsToClear) const noexcept { return ModifierKeys (flags & ~rawFlagsToClear); }
177  ModifierKeys withFlags (int rawFlagsToSet) const noexcept { return ModifierKeys (flags | rawFlagsToSet); }
178 
180  bool testFlags (int flagsToTest) const noexcept { return (flags & flagsToTest) != 0; }
181 
183  int getNumMouseButtonsDown() const noexcept;
184 
185  //==============================================================================
191  static ModifierKeys getCurrentModifiers() noexcept;
192 
207  static ModifierKeys getCurrentModifiersRealtime() noexcept;
208 
209 
210 private:
211  //==============================================================================
212  int flags;
213 
214  friend class ComponentPeer;
215  friend class MouseInputSource;
217 
218  static ModifierKeys currentModifiers;
219  static void updateCurrentModifiers() noexcept;
220 };
221 
222 
223 #endif // JUCE_MODIFIERKEYS_H_INCLUDED
bool isCtrlDown() const noexcept
Definition: juce_ModifierKeys.h:106
bool isAnyModifierKeyDown() const noexcept
Definition: juce_ModifierKeys.h:94
#define noexcept
Definition: juce_CompilerSupport.h:141
bool isAnyMouseButtonDown() const noexcept
Definition: juce_ModifierKeys.h:91
bool isRightButtonDown() const noexcept
Definition: juce_ModifierKeys.h:86
int getRawFlags() const noexcept
Definition: juce_ModifierKeys.h:174
Flags
Definition: juce_ModifierKeys.h:113
Definition: juce_ModifierKeys.h:38
ModifierKeys withOnlyMouseButtons() const noexcept
Definition: juce_ModifierKeys.h:164
bool isCommandDown() const noexcept
Definition: juce_ModifierKeys.h:66
#define JUCE_API
Definition: juce_StandardHeader.h:139
bool isAltDown() const noexcept
Definition: juce_ModifierKeys.h:109
bool isPopupMenu() const noexcept
Definition: juce_ModifierKeys.h:76
bool isLeftButtonDown() const noexcept
Definition: juce_ModifierKeys.h:79
ModifierKeys withoutFlags(int rawFlagsToClear) const noexcept
Definition: juce_ModifierKeys.h:176
bool isMiddleButtonDown() const noexcept
Definition: juce_ModifierKeys.h:88
Definition: juce_MouseInputSource.h:49
bool isShiftDown() const noexcept
Definition: juce_ModifierKeys.h:97
Definition: juce_MouseInputSource.cpp:25
bool operator==(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:565
ModifierKeys withFlags(int rawFlagsToSet) const noexcept
Definition: juce_ModifierKeys.h:177
ModifierKeys withoutMouseButtons() const noexcept
Definition: juce_ModifierKeys.h:167
bool testFlags(int flagsToTest) const noexcept
Definition: juce_ModifierKeys.h:180
bool operator!=(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:566
Definition: juce_ComponentPeer.h:41