openshot-audio  0.1.7
juce_KeyPressMappingSet.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_KEYPRESSMAPPINGSET_H_INCLUDED
26 #define JUCE_KEYPRESSMAPPINGSET_H_INCLUDED
27 
28 
29 //==============================================================================
85  public ChangeBroadcaster,
86  private FocusChangeListener
87 {
88 public:
89  //==============================================================================
103 
106 
109 
110  //==============================================================================
111  ApplicationCommandManager& getCommandManager() const noexcept { return commandManager; }
112 
113  //==============================================================================
118  Array<KeyPress> getKeyPressesAssignedToCommand (CommandID commandID) const;
119 
133  void addKeyPress (CommandID commandID,
134  const KeyPress& newKeyPress,
135  int insertIndex = -1);
136 
140  void resetToDefaultMappings();
141 
145  void resetToDefaultMapping (CommandID commandID);
146 
148  void clearAllKeyPresses();
149 
151  void clearAllKeyPresses (CommandID commandID);
152 
157  void removeKeyPress (CommandID commandID, int keyPressIndex);
158 
160  void removeKeyPress (const KeyPress& keypress);
161 
163  bool containsMapping (CommandID commandID, const KeyPress& keyPress) const noexcept;
164 
165  //==============================================================================
169  CommandID findCommandForKeyPress (const KeyPress& keyPress) const noexcept;
170 
171  //==============================================================================
187  bool restoreFromXml (const XmlElement& xmlVersion);
188 
206  XmlElement* createXml (bool saveDifferencesFromDefaultSet) const;
207 
208  //==============================================================================
210  bool keyPressed (const KeyPress&, Component*) override;
212  bool keyStateChanged (bool isKeyDown, Component*) override;
214  void globalFocusChanged (Component*) override;
215 
216 private:
217  //==============================================================================
218  ApplicationCommandManager& commandManager;
219 
220  struct CommandMapping
221  {
222  CommandID commandID;
223  Array<KeyPress> keypresses;
224  bool wantsKeyUpDownCallbacks;
225  };
226 
228 
229  struct KeyPressTime
230  {
231  KeyPress key;
232  uint32 timeWhenPressed;
233  };
234 
235  OwnedArray<KeyPressTime> keysDown;
236 
237  void invokeCommand (const CommandID, const KeyPress&, const bool isKeyDown,
238  const int millisecsSinceKeyPressed, Component* originator) const;
239 
240  KeyPressMappingSet& operator= (const KeyPressMappingSet&);
242 };
243 
244 
245 #endif // JUCE_KEYPRESSMAPPINGSET_H_INCLUDED
Definition: juce_ApplicationCommandManager.h:84
ApplicationCommandManager & getCommandManager() const noexcept
Definition: juce_KeyPressMappingSet.h:111
Definition: juce_KeyPress.h:37
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_Desktop.h:36
Definition: juce_ChangeBroadcaster.h:35
#define JUCE_API
Definition: juce_StandardHeader.h:139
virtual bool keyStateChanged(bool isKeyDown, Component *originatingComponent)
Definition: juce_KeyListener.cpp:25
Definition: juce_XmlElement.h:142
virtual bool keyPressed(const KeyPress &key, Component *originatingComponent)=0
unsigned int uint32
Definition: juce_MathsFunctions.h:51
Definition: juce_Component.h:33
Definition: juce_KeyPressMappingSet.h:84
Definition: juce_KeyListener.h:38
int CommandID
Definition: juce_ApplicationCommandID.h:37
Definition: juce_OwnedArray.h:55
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition: juce_LeakedObjectDetector.h:141
virtual void globalFocusChanged(Component *focusedComponent)=0