mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Misc minor cleanups and comment fixes.
This commit is contained in:
parent
5df6bf0513
commit
b093f47a8c
27 changed files with 227 additions and 299 deletions
|
|
@ -77,8 +77,7 @@ struct JUCE_API ApplicationCommandInfo
|
|||
myinfo.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier));
|
||||
@endcode
|
||||
*/
|
||||
void addDefaultKeypress (int keyCode,
|
||||
ModifierKeys modifiers) noexcept;
|
||||
void addDefaultKeypress (int keyCode, ModifierKeys modifiers) noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** The command's unique ID number.
|
||||
|
|
@ -123,7 +122,7 @@ struct JUCE_API ApplicationCommandInfo
|
|||
|
||||
@see addDefaultKeypress
|
||||
*/
|
||||
Array <KeyPress> defaultKeypresses;
|
||||
Array<KeyPress> defaultKeypresses;
|
||||
|
||||
//==============================================================================
|
||||
/** Flags describing the ways in which this command should be used.
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ void ApplicationCommandManager::registerAllCommandsForTarget (ApplicationCommand
|
|||
{
|
||||
if (target != nullptr)
|
||||
{
|
||||
Array <CommandID> commandIDs;
|
||||
Array<CommandID> commandIDs;
|
||||
target->getAllCommands (commandIDs);
|
||||
|
||||
for (int i = 0; i < commandIDs.size(); ++i)
|
||||
|
|
@ -99,7 +99,7 @@ void ApplicationCommandManager::removeCommand (const CommandID commandID)
|
|||
commands.remove (i);
|
||||
triggerAsyncUpdate();
|
||||
|
||||
const Array <KeyPress> keys (keyMappings->getKeyPressesAssignedToCommand (commandID));
|
||||
const Array<KeyPress> keys (keyMappings->getKeyPressesAssignedToCommand (commandID));
|
||||
|
||||
for (int j = keys.size(); --j >= 0;)
|
||||
keyMappings->removeKeyPress (keys.getReference (j));
|
||||
|
|
@ -151,7 +151,7 @@ StringArray ApplicationCommandManager::getCommandCategories() const
|
|||
|
||||
Array<CommandID> ApplicationCommandManager::getCommandsInCategory (const String& categoryName) const
|
||||
{
|
||||
Array <CommandID> results;
|
||||
Array<CommandID> results;
|
||||
|
||||
for (int i = 0; i < commands.size(); ++i)
|
||||
if (commands.getUnchecked(i)->categoryName == categoryName)
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ public:
|
|||
either use setFirstCommandTarget() to specify a single target, or override this method
|
||||
if you need more complex logic to choose one.
|
||||
|
||||
It may return 0 if no targets are available.
|
||||
It may return nullptr if no targets are available.
|
||||
|
||||
@see getTargetForCommand, invoke, invokeDirectly
|
||||
*/
|
||||
|
|
@ -247,11 +247,11 @@ public:
|
|||
|
||||
/** Sets a target to be returned by getFirstCommandTarget().
|
||||
|
||||
If this is set to 0, then getFirstCommandTarget() will by default return the
|
||||
If this is set to nullptr, then getFirstCommandTarget() will by default return the
|
||||
result of findDefaultComponentTarget().
|
||||
|
||||
If you use this to set a target, make sure you call setFirstCommandTarget (0) before
|
||||
deleting the target object.
|
||||
If you use this to set a target, make sure you call setFirstCommandTarget(nullptr)
|
||||
before deleting the target object.
|
||||
*/
|
||||
void setFirstCommandTarget (ApplicationCommandTarget* newTarget) noexcept;
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ public:
|
|||
ApplicationCommandTarget::getNextCommandTarget() to find the next one to try, and
|
||||
so on until no more are available.
|
||||
|
||||
If no targets are found that can perform the command, this method will return 0.
|
||||
If no targets are found that can perform the command, this method will return nullptr.
|
||||
|
||||
If a target is found, then it will get the target to fill-in the upToDateInfo
|
||||
structure with the latest info about that command, so that the caller can see
|
||||
|
|
@ -292,17 +292,17 @@ public:
|
|||
/** Examines this component and all its parents in turn, looking for the first one
|
||||
which is a ApplicationCommandTarget.
|
||||
|
||||
Returns the first ApplicationCommandTarget that it finds, or nullptr if none of them implement
|
||||
that class.
|
||||
Returns the first ApplicationCommandTarget that it finds, or nullptr if none of them
|
||||
implement that class.
|
||||
*/
|
||||
static ApplicationCommandTarget* findTargetForComponent (Component* component);
|
||||
static ApplicationCommandTarget* findTargetForComponent (Component*);
|
||||
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
OwnedArray <ApplicationCommandInfo> commands;
|
||||
ListenerList <ApplicationCommandManagerListener> listeners;
|
||||
ScopedPointer <KeyPressMappingSet> keyMappings;
|
||||
OwnedArray<ApplicationCommandInfo> commands;
|
||||
ListenerList<ApplicationCommandManagerListener> listeners;
|
||||
ScopedPointer<KeyPressMappingSet> keyMappings;
|
||||
ApplicationCommandTarget* firstTarget;
|
||||
|
||||
void sendListenerInvokeCallback (const ApplicationCommandTarget::InvocationInfo&);
|
||||
|
|
@ -335,7 +335,7 @@ public:
|
|||
virtual ~ApplicationCommandManagerListener() {}
|
||||
|
||||
/** Called when an app command is about to be invoked. */
|
||||
virtual void applicationCommandInvoked (const ApplicationCommandTarget::InvocationInfo& info) = 0;
|
||||
virtual void applicationCommandInvoked (const ApplicationCommandTarget::InvocationInfo&) = 0;
|
||||
|
||||
/** Called when commands are registered or deregistered from the
|
||||
command manager, or when commands are made active or inactive.
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ KeyPressMappingSet::KeyPressMappingSet (ApplicationCommandManager& cm)
|
|||
}
|
||||
|
||||
KeyPressMappingSet::KeyPressMappingSet (const KeyPressMappingSet& other)
|
||||
: KeyListener(), ChangeBroadcaster(), FocusChangeListener(),
|
||||
commandManager (other.commandManager)
|
||||
: KeyListener(), ChangeBroadcaster(), FocusChangeListener(), commandManager (other.commandManager)
|
||||
{
|
||||
Desktop::getInstance().addFocusChangeListener (this);
|
||||
}
|
||||
|
|
@ -50,9 +49,7 @@ Array<KeyPress> KeyPressMappingSet::getKeyPressesAssignedToCommand (const Comman
|
|||
return Array<KeyPress>();
|
||||
}
|
||||
|
||||
void KeyPressMappingSet::addKeyPress (const CommandID commandID,
|
||||
const KeyPress& newKeyPress,
|
||||
int insertIndex)
|
||||
void KeyPressMappingSet::addKeyPress (const CommandID commandID, const KeyPress& newKeyPress, int insertIndex)
|
||||
{
|
||||
// If you specify an upper-case letter but no shift key, how is the user supposed to press it!?
|
||||
// Stick to lower-case letters when defining a keypress, to avoid ambiguity.
|
||||
|
|
@ -88,20 +85,18 @@ void KeyPressMappingSet::addKeyPress (const CommandID commandID,
|
|||
}
|
||||
}
|
||||
|
||||
static void addKeyPresses (KeyPressMappingSet& set, const ApplicationCommandInfo* const ci)
|
||||
{
|
||||
for (int j = 0; j < ci->defaultKeypresses.size(); ++j)
|
||||
set.addKeyPress (ci->commandID, ci->defaultKeypresses.getReference (j));
|
||||
}
|
||||
|
||||
void KeyPressMappingSet::resetToDefaultMappings()
|
||||
{
|
||||
mappings.clear();
|
||||
|
||||
for (int i = 0; i < commandManager.getNumCommands(); ++i)
|
||||
{
|
||||
const ApplicationCommandInfo* const ci = commandManager.getCommandForIndex (i);
|
||||
|
||||
for (int j = 0; j < ci->defaultKeypresses.size(); ++j)
|
||||
{
|
||||
addKeyPress (ci->commandID,
|
||||
ci->defaultKeypresses.getReference (j));
|
||||
}
|
||||
}
|
||||
addKeyPresses (*this, commandManager.getCommandForIndex (i));
|
||||
|
||||
sendChangeMessage();
|
||||
}
|
||||
|
|
@ -110,13 +105,8 @@ void KeyPressMappingSet::resetToDefaultMapping (const CommandID commandID)
|
|||
{
|
||||
clearAllKeyPresses (commandID);
|
||||
|
||||
const ApplicationCommandInfo* const ci = commandManager.getCommandForID (commandID);
|
||||
|
||||
for (int j = 0; j < ci->defaultKeypresses.size(); ++j)
|
||||
{
|
||||
addKeyPress (ci->commandID,
|
||||
ci->defaultKeypresses.getReference (j));
|
||||
}
|
||||
if (const ApplicationCommandInfo* const ci = commandManager.getCommandForID (commandID))
|
||||
addKeyPresses (*this, ci);
|
||||
}
|
||||
|
||||
void KeyPressMappingSet::clearAllKeyPresses()
|
||||
|
|
@ -333,10 +323,8 @@ bool KeyPressMappingSet::keyPressed (const KeyPress& key, Component* const origi
|
|||
invokeCommand (cm.commandID, key, true, 0, originatingComponent);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
commandWasDisabled = true;
|
||||
}
|
||||
|
||||
commandWasDisabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,10 +99,10 @@ public:
|
|||
|
||||
@see ApplicationCommandManager
|
||||
*/
|
||||
explicit KeyPressMappingSet (ApplicationCommandManager& commandManager);
|
||||
explicit KeyPressMappingSet (ApplicationCommandManager&);
|
||||
|
||||
/** Creates an copy of a KeyPressMappingSet. */
|
||||
KeyPressMappingSet (const KeyPressMappingSet& other);
|
||||
KeyPressMappingSet (const KeyPressMappingSet&);
|
||||
|
||||
/** Destructor. */
|
||||
~KeyPressMappingSet();
|
||||
|
|
@ -135,13 +135,11 @@ public:
|
|||
int insertIndex = -1);
|
||||
|
||||
/** Reset all mappings to the defaults, as dictated by the ApplicationCommandManager.
|
||||
|
||||
@see resetToDefaultMapping
|
||||
*/
|
||||
void resetToDefaultMappings();
|
||||
|
||||
/** Resets all key-mappings to the defaults for a particular command.
|
||||
|
||||
@see resetToDefaultMappings
|
||||
*/
|
||||
void resetToDefaultMapping (CommandID commandID);
|
||||
|
|
@ -153,14 +151,12 @@ public:
|
|||
void clearAllKeyPresses (CommandID commandID);
|
||||
|
||||
/** Removes one of the keypresses that are assigned to a command.
|
||||
|
||||
See the getKeyPressesAssignedToCommand() for the list of keypresses to
|
||||
which the keyPressIndex refers.
|
||||
*/
|
||||
void removeKeyPress (CommandID commandID, int keyPressIndex);
|
||||
|
||||
/** Removes a keypress from any command that it may be assigned to.
|
||||
*/
|
||||
/** Removes a keypress from any command that it may be assigned to. */
|
||||
void removeKeyPress (const KeyPress& keypress);
|
||||
|
||||
/** Returns true if the given command is linked to this key. */
|
||||
|
|
@ -224,11 +220,11 @@ private:
|
|||
struct CommandMapping
|
||||
{
|
||||
CommandID commandID;
|
||||
Array <KeyPress> keypresses;
|
||||
Array<KeyPress> keypresses;
|
||||
bool wantsKeyUpDownCallbacks;
|
||||
};
|
||||
|
||||
OwnedArray <CommandMapping> mappings;
|
||||
OwnedArray<CommandMapping> mappings;
|
||||
|
||||
struct KeyPressTime
|
||||
{
|
||||
|
|
@ -236,7 +232,7 @@ private:
|
|||
uint32 timeWhenPressed;
|
||||
};
|
||||
|
||||
OwnedArray <KeyPressTime> keysDown;
|
||||
OwnedArray<KeyPressTime> keysDown;
|
||||
|
||||
void invokeCommand (const CommandID, const KeyPress&, const bool isKeyDown,
|
||||
const int millisecsSinceKeyPressed, Component* originator) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue