@@ -26,7 +26,7 @@ | |||||
ApplicationCommandManager::ApplicationCommandManager() | ApplicationCommandManager::ApplicationCommandManager() | ||||
: firstTarget (nullptr) | : firstTarget (nullptr) | ||||
{ | { | ||||
keyMappings = new KeyPressMappingSet (this); | |||||
keyMappings = new KeyPressMappingSet (*this); | |||||
Desktop::getInstance().addFocusChangeListener (this); | Desktop::getInstance().addFocusChangeListener (this); | ||||
} | } | ||||
@@ -256,14 +256,13 @@ ApplicationCommandTarget* ApplicationCommandManager::findDefaultComponentTarget( | |||||
if (c != nullptr) | if (c != nullptr) | ||||
{ | { | ||||
ResizableWindow* const resizableWindow = dynamic_cast <ResizableWindow*> (c); | |||||
// if we're focused on a ResizableWindow, chances are that it's the content | // if we're focused on a ResizableWindow, chances are that it's the content | ||||
// component that really should get the event. And if not, the event will | // component that really should get the event. And if not, the event will | ||||
// still be passed up to the top level window anyway, so let's send it to the | // still be passed up to the top level window anyway, so let's send it to the | ||||
// content comp. | // content comp. | ||||
if (resizableWindow != nullptr && resizableWindow->getContentComponent() != nullptr) | |||||
c = resizableWindow->getContentComponent(); | |||||
if (ResizableWindow* const resizableWindow = dynamic_cast <ResizableWindow*> (c)) | |||||
if (resizableWindow->getContentComponent() != nullptr) | |||||
c = resizableWindow->getContentComponent(); | |||||
if (ApplicationCommandTarget* const target = findTargetForComponent (c)) | if (ApplicationCommandTarget* const target = findTargetForComponent (c)) | ||||
return target; | return target; | ||||
@@ -23,13 +23,9 @@ | |||||
============================================================================== | ============================================================================== | ||||
*/ | */ | ||||
KeyPressMappingSet::KeyPressMappingSet (ApplicationCommandManager* const commandManager_) | |||||
: commandManager (commandManager_) | |||||
KeyPressMappingSet::KeyPressMappingSet (ApplicationCommandManager& cm) | |||||
: commandManager (cm) | |||||
{ | { | ||||
// A manager is needed to get the descriptions of commands, and will be called when | |||||
// a command is invoked. So you can't leave this null.. | |||||
jassert (commandManager_ != nullptr); | |||||
Desktop::getInstance().addFocusChangeListener (this); | Desktop::getInstance().addFocusChangeListener (this); | ||||
} | } | ||||
@@ -78,9 +74,7 @@ void KeyPressMappingSet::addKeyPress (const CommandID commandID, | |||||
} | } | ||||
} | } | ||||
const ApplicationCommandInfo* const ci = commandManager->getCommandForID (commandID); | |||||
if (ci != nullptr) | |||||
if (const ApplicationCommandInfo* const ci = commandManager.getCommandForID (commandID)) | |||||
{ | { | ||||
CommandMapping* const cm = new CommandMapping(); | CommandMapping* const cm = new CommandMapping(); | ||||
cm->commandID = commandID; | cm->commandID = commandID; | ||||
@@ -98,9 +92,9 @@ void KeyPressMappingSet::resetToDefaultMappings() | |||||
{ | { | ||||
mappings.clear(); | mappings.clear(); | ||||
for (int i = 0; i < commandManager->getNumCommands(); ++i) | |||||
for (int i = 0; i < commandManager.getNumCommands(); ++i) | |||||
{ | { | ||||
const ApplicationCommandInfo* const ci = commandManager->getCommandForIndex (i); | |||||
const ApplicationCommandInfo* const ci = commandManager.getCommandForIndex (i); | |||||
for (int j = 0; j < ci->defaultKeypresses.size(); ++j) | for (int j = 0; j < ci->defaultKeypresses.size(); ++j) | ||||
{ | { | ||||
@@ -116,7 +110,7 @@ void KeyPressMappingSet::resetToDefaultMapping (const CommandID commandID) | |||||
{ | { | ||||
clearAllKeyPresses (commandID); | clearAllKeyPresses (commandID); | ||||
const ApplicationCommandInfo* const ci = commandManager->getCommandForID (commandID); | |||||
const ApplicationCommandInfo* const ci = commandManager.getCommandForID (commandID); | |||||
for (int j = 0; j < ci->defaultKeypresses.size(); ++j) | for (int j = 0; j < ci->defaultKeypresses.size(); ++j) | ||||
{ | { | ||||
@@ -152,13 +146,13 @@ void KeyPressMappingSet::removeKeyPress (const KeyPress& keypress) | |||||
{ | { | ||||
for (int i = mappings.size(); --i >= 0;) | for (int i = mappings.size(); --i >= 0;) | ||||
{ | { | ||||
CommandMapping* const cm = mappings.getUnchecked(i); | |||||
CommandMapping& cm = *mappings.getUnchecked(i); | |||||
for (int j = cm->keypresses.size(); --j >= 0;) | |||||
for (int j = cm.keypresses.size(); --j >= 0;) | |||||
{ | { | ||||
if (keypress == cm->keypresses [j]) | |||||
if (keypress == cm.keypresses [j]) | |||||
{ | { | ||||
cm->keypresses.remove (j); | |||||
cm.keypresses.remove (j); | |||||
sendChangeMessage(); | sendChangeMessage(); | ||||
} | } | ||||
} | } | ||||
@@ -212,7 +206,7 @@ void KeyPressMappingSet::invokeCommand (const CommandID commandID, | |||||
info.millisecsSinceKeyPressed = millisecsSinceKeyPressed; | info.millisecsSinceKeyPressed = millisecsSinceKeyPressed; | ||||
info.originatingComponent = originatingComponent; | info.originatingComponent = originatingComponent; | ||||
commandManager->invoke (info, false); | |||||
commandManager.invoke (info, false); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -275,18 +269,18 @@ XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefault | |||||
for (int i = 0; i < mappings.size(); ++i) | for (int i = 0; i < mappings.size(); ++i) | ||||
{ | { | ||||
const CommandMapping* const cm = mappings.getUnchecked(i); | |||||
const CommandMapping& cm = *mappings.getUnchecked(i); | |||||
for (int j = 0; j < cm->keypresses.size(); ++j) | |||||
for (int j = 0; j < cm.keypresses.size(); ++j) | |||||
{ | { | ||||
if (defaultSet == nullptr | if (defaultSet == nullptr | ||||
|| ! defaultSet->containsMapping (cm->commandID, cm->keypresses.getReference (j))) | |||||
|| ! defaultSet->containsMapping (cm.commandID, cm.keypresses.getReference (j))) | |||||
{ | { | ||||
XmlElement* const map = doc->createNewChildElement ("MAPPING"); | XmlElement* const map = doc->createNewChildElement ("MAPPING"); | ||||
map->setAttribute ("commandId", String::toHexString ((int) cm->commandID)); | |||||
map->setAttribute ("description", commandManager->getDescriptionOfCommand (cm->commandID)); | |||||
map->setAttribute ("key", cm->keypresses.getReference (j).getTextDescription()); | |||||
map->setAttribute ("commandId", String::toHexString ((int) cm.commandID)); | |||||
map->setAttribute ("description", commandManager.getDescriptionOfCommand (cm.commandID)); | |||||
map->setAttribute ("key", cm.keypresses.getReference (j).getTextDescription()); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -295,17 +289,17 @@ XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefault | |||||
{ | { | ||||
for (int i = 0; i < defaultSet->mappings.size(); ++i) | for (int i = 0; i < defaultSet->mappings.size(); ++i) | ||||
{ | { | ||||
const CommandMapping* const cm = defaultSet->mappings.getUnchecked(i); | |||||
const CommandMapping& cm = *defaultSet->mappings.getUnchecked(i); | |||||
for (int j = 0; j < cm->keypresses.size(); ++j) | |||||
for (int j = 0; j < cm.keypresses.size(); ++j) | |||||
{ | { | ||||
if (! containsMapping (cm->commandID, cm->keypresses.getReference (j))) | |||||
if (! containsMapping (cm.commandID, cm.keypresses.getReference (j))) | |||||
{ | { | ||||
XmlElement* const map = doc->createNewChildElement ("UNMAPPING"); | XmlElement* const map = doc->createNewChildElement ("UNMAPPING"); | ||||
map->setAttribute ("commandId", String::toHexString ((int) cm->commandID)); | |||||
map->setAttribute ("description", commandManager->getDescriptionOfCommand (cm->commandID)); | |||||
map->setAttribute ("key", cm->keypresses.getReference (j).getTextDescription()); | |||||
map->setAttribute ("commandId", String::toHexString ((int) cm.commandID)); | |||||
map->setAttribute ("description", commandManager.getDescriptionOfCommand (cm.commandID)); | |||||
map->setAttribute ("key", cm.keypresses.getReference (j).getTextDescription()); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -315,34 +309,33 @@ XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefault | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
bool KeyPressMappingSet::keyPressed (const KeyPress& key, | |||||
Component* originatingComponent) | |||||
bool KeyPressMappingSet::keyPressed (const KeyPress& key, Component* const originatingComponent) | |||||
{ | { | ||||
bool commandWasDisabled = false; | bool commandWasDisabled = false; | ||||
for (int i = 0; i < mappings.size(); ++i) | for (int i = 0; i < mappings.size(); ++i) | ||||
{ | { | ||||
CommandMapping* const cm = mappings.getUnchecked(i); | |||||
CommandMapping& cm = *mappings.getUnchecked(i); | |||||
if (cm->keypresses.contains (key)) | |||||
if (cm.keypresses.contains (key)) | |||||
{ | { | ||||
const ApplicationCommandInfo* const ci = commandManager->getCommandForID (cm->commandID); | |||||
if (ci != nullptr | |||||
&& (ci->flags & ApplicationCommandInfo::wantsKeyUpDownCallbacks) == 0) | |||||
if (const ApplicationCommandInfo* const ci = commandManager.getCommandForID (cm.commandID)) | |||||
{ | { | ||||
ApplicationCommandInfo info (0); | |||||
if (commandManager->getTargetForCommand (cm->commandID, info) != 0) | |||||
if ((ci->flags & ApplicationCommandInfo::wantsKeyUpDownCallbacks) == 0) | |||||
{ | { | ||||
if ((info.flags & ApplicationCommandInfo::isDisabled) == 0) | |||||
{ | |||||
invokeCommand (cm->commandID, key, true, 0, originatingComponent); | |||||
return true; | |||||
} | |||||
else | |||||
ApplicationCommandInfo info (0); | |||||
if (commandManager.getTargetForCommand (cm.commandID, info) != nullptr) | |||||
{ | { | ||||
commandWasDisabled = true; | |||||
if ((info.flags & ApplicationCommandInfo::isDisabled) == 0) | |||||
{ | |||||
invokeCommand (cm.commandID, key, true, 0, originatingComponent); | |||||
return true; | |||||
} | |||||
else | |||||
{ | |||||
commandWasDisabled = true; | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -362,13 +355,13 @@ bool KeyPressMappingSet::keyStateChanged (const bool /*isKeyDown*/, Component* o | |||||
for (int i = mappings.size(); --i >= 0;) | for (int i = mappings.size(); --i >= 0;) | ||||
{ | { | ||||
CommandMapping* const cm = mappings.getUnchecked(i); | |||||
CommandMapping& cm = *mappings.getUnchecked(i); | |||||
if (cm->wantsKeyUpDownCallbacks) | |||||
if (cm.wantsKeyUpDownCallbacks) | |||||
{ | { | ||||
for (int j = cm->keypresses.size(); --j >= 0;) | |||||
for (int j = cm.keypresses.size(); --j >= 0;) | |||||
{ | { | ||||
const KeyPress key (cm->keypresses.getReference (j)); | |||||
const KeyPress key (cm.keypresses.getReference (j)); | |||||
const bool isDown = key.isCurrentlyDown(); | const bool isDown = key.isCurrentlyDown(); | ||||
int keyPressEntryIndex = 0; | int keyPressEntryIndex = 0; | ||||
@@ -407,7 +400,7 @@ bool KeyPressMappingSet::keyStateChanged (const bool /*isKeyDown*/, Component* o | |||||
keysDown.remove (keyPressEntryIndex); | keysDown.remove (keyPressEntryIndex); | ||||
} | } | ||||
invokeCommand (cm->commandID, key, isDown, millisecs, originatingComponent); | |||||
invokeCommand (cm.commandID, key, isDown, millisecs, originatingComponent); | |||||
used = true; | used = true; | ||||
} | } | ||||
} | } | ||||
@@ -103,7 +103,7 @@ public: | |||||
@see ApplicationCommandManager | @see ApplicationCommandManager | ||||
*/ | */ | ||||
explicit KeyPressMappingSet (ApplicationCommandManager* commandManager); | |||||
explicit KeyPressMappingSet (ApplicationCommandManager& commandManager); | |||||
/** Creates an copy of a KeyPressMappingSet. */ | /** Creates an copy of a KeyPressMappingSet. */ | ||||
KeyPressMappingSet (const KeyPressMappingSet& other); | KeyPressMappingSet (const KeyPressMappingSet& other); | ||||
@@ -112,7 +112,7 @@ public: | |||||
~KeyPressMappingSet(); | ~KeyPressMappingSet(); | ||||
//============================================================================== | //============================================================================== | ||||
ApplicationCommandManager* getCommandManager() const noexcept { return commandManager; } | |||||
ApplicationCommandManager& getCommandManager() const noexcept { return commandManager; } | |||||
//============================================================================== | //============================================================================== | ||||
/** Returns a list of keypresses that are assigned to a particular command. | /** Returns a list of keypresses that are assigned to a particular command. | ||||
@@ -172,7 +172,6 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
/** Looks for a command that corresponds to a keypress. | /** Looks for a command that corresponds to a keypress. | ||||
@returns the UID of the command or 0 if none was found | @returns the UID of the command or 0 if none was found | ||||
*/ | */ | ||||
CommandID findCommandForKeyPress (const KeyPress& keyPress) const noexcept; | CommandID findCommandForKeyPress (const KeyPress& keyPress) const noexcept; | ||||
@@ -216,15 +215,15 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
/** @internal */ | /** @internal */ | ||||
bool keyPressed (const KeyPress& key, Component* originatingComponent); | |||||
bool keyPressed (const KeyPress&, Component* originatingComponent); | |||||
/** @internal */ | /** @internal */ | ||||
bool keyStateChanged (bool isKeyDown, Component* originatingComponent); | bool keyStateChanged (bool isKeyDown, Component* originatingComponent); | ||||
/** @internal */ | /** @internal */ | ||||
void globalFocusChanged (Component* focusedComponent); | |||||
void globalFocusChanged (Component*); | |||||
private: | private: | ||||
//============================================================================== | //============================================================================== | ||||
ApplicationCommandManager* commandManager; | |||||
ApplicationCommandManager& commandManager; | |||||
struct CommandMapping | struct CommandMapping | ||||
{ | { | ||||
@@ -243,13 +242,9 @@ private: | |||||
OwnedArray <KeyPressTime> keysDown; | OwnedArray <KeyPressTime> keysDown; | ||||
void handleMessage (const Message& message); | |||||
void invokeCommand (const CommandID commandID, | |||||
const KeyPress& keyPress, | |||||
const bool isKeyDown, | |||||
const int millisecsSinceKeyPressed, | |||||
Component* const originatingComponent) const; | |||||
void handleMessage (const Message&); | |||||
void invokeCommand (const CommandID, const KeyPress&, const bool isKeyDown, | |||||
const int millisecsSinceKeyPressed, Component* originator) const; | |||||
KeyPressMappingSet& operator= (const KeyPressMappingSet&); | KeyPressMappingSet& operator= (const KeyPressMappingSet&); | ||||
JUCE_LEAK_DETECTOR (KeyPressMappingSet); | JUCE_LEAK_DETECTOR (KeyPressMappingSet); | ||||
@@ -26,20 +26,18 @@ | |||||
class KeyMappingEditorComponent::ChangeKeyButton : public Button | class KeyMappingEditorComponent::ChangeKeyButton : public Button | ||||
{ | { | ||||
public: | public: | ||||
ChangeKeyButton (KeyMappingEditorComponent& owner_, | |||||
const CommandID commandID_, | |||||
const String& keyName, | |||||
const int keyNum_) | |||||
ChangeKeyButton (KeyMappingEditorComponent& kec, const CommandID command, | |||||
const String& keyName, const int keyIndex) | |||||
: Button (keyName), | : Button (keyName), | ||||
owner (owner_), | |||||
commandID (commandID_), | |||||
keyNum (keyNum_) | |||||
owner (kec), | |||||
commandID (command), | |||||
keyNum (keyIndex) | |||||
{ | { | ||||
setWantsKeyboardFocus (false); | setWantsKeyboardFocus (false); | ||||
setTriggeredOnMouseDown (keyNum >= 0); | setTriggeredOnMouseDown (keyNum >= 0); | ||||
setTooltip (keyNum_ < 0 ? TRANS("adds a new key-mapping") | |||||
: TRANS("click to change this key-mapping")); | |||||
setTooltip (keyIndex < 0 ? TRANS("adds a new key-mapping") | |||||
: TRANS("click to change this key-mapping")); | |||||
} | } | ||||
void paintButton (Graphics& g, bool /*isOver*/, bool /*isDown*/) | void paintButton (Graphics& g, bool /*isOver*/, bool /*isDown*/) | ||||
@@ -83,25 +81,20 @@ public: | |||||
void fitToContent (const int h) noexcept | void fitToContent (const int h) noexcept | ||||
{ | { | ||||
if (keyNum < 0) | if (keyNum < 0) | ||||
{ | |||||
setSize (h, h); | setSize (h, h); | ||||
} | |||||
else | else | ||||
{ | |||||
Font f (h * 0.6f); | |||||
setSize (jlimit (h * 4, h * 8, 6 + f.getStringWidth (getName())), h); | |||||
} | |||||
setSize (jlimit (h * 4, h * 8, 6 + Font (h * 0.6f).getStringWidth (getName())), h); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
class KeyEntryWindow : public AlertWindow | class KeyEntryWindow : public AlertWindow | ||||
{ | { | ||||
public: | public: | ||||
KeyEntryWindow (KeyMappingEditorComponent& owner_) | |||||
KeyEntryWindow (KeyMappingEditorComponent& kec) | |||||
: AlertWindow (TRANS("New key-mapping"), | : AlertWindow (TRANS("New key-mapping"), | ||||
TRANS("Please press a key combination now..."), | TRANS("Please press a key combination now..."), | ||||
AlertWindow::NoIcon), | AlertWindow::NoIcon), | ||||
owner (owner_) | |||||
owner (kec) | |||||
{ | { | ||||
addButton (TRANS("Ok"), 1); | addButton (TRANS("Ok"), 1); | ||||
addButton (TRANS("Cancel"), 0); | addButton (TRANS("Cancel"), 0); | ||||
@@ -123,7 +116,7 @@ public: | |||||
if (previousCommand != 0) | if (previousCommand != 0) | ||||
message << "\n\n" << TRANS("(Currently assigned to \"") | message << "\n\n" << TRANS("(Currently assigned to \"") | ||||
<< owner.getMappings().getCommandManager()->getNameOfCommand (previousCommand) << "\")"; | |||||
<< owner.getCommandManager().getNameOfCommand (previousCommand) << "\")"; | |||||
setMessage (message); | setMessage (message); | ||||
return true; | return true; | ||||
@@ -168,7 +161,7 @@ public: | |||||
AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, | AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, | ||||
TRANS("Change key-mapping"), | TRANS("Change key-mapping"), | ||||
TRANS("This key is already assigned to the command \"") | TRANS("This key is already assigned to the command \"") | ||||
+ owner.getMappings().getCommandManager()->getNameOfCommand (previousCommand) | |||||
+ owner.getCommandManager().getNameOfCommand (previousCommand) | |||||
+ TRANS("\"\n\nDo you want to re-assign it to this new command instead?"), | + TRANS("\"\n\nDo you want to re-assign it to this new command instead?"), | ||||
TRANS("Re-assign"), | TRANS("Re-assign"), | ||||
TRANS("Cancel"), | TRANS("Cancel"), | ||||
@@ -209,8 +202,8 @@ private: | |||||
class KeyMappingEditorComponent::ItemComponent : public Component | class KeyMappingEditorComponent::ItemComponent : public Component | ||||
{ | { | ||||
public: | public: | ||||
ItemComponent (KeyMappingEditorComponent& owner_, const CommandID commandID_) | |||||
: owner (owner_), commandID (commandID_) | |||||
ItemComponent (KeyMappingEditorComponent& kec, const CommandID command) | |||||
: owner (kec), commandID (command) | |||||
{ | { | ||||
setInterceptsMouseClicks (false, true); | setInterceptsMouseClicks (false, true); | ||||
@@ -239,7 +232,7 @@ public: | |||||
g.setFont (getHeight() * 0.7f); | g.setFont (getHeight() * 0.7f); | ||||
g.setColour (findColour (KeyMappingEditorComponent::textColourId)); | g.setColour (findColour (KeyMappingEditorComponent::textColourId)); | ||||
g.drawFittedText (owner.getMappings().getCommandManager()->getNameOfCommand (commandID), | |||||
g.drawFittedText (owner.getCommandManager().getNameOfCommand (commandID), | |||||
4, 0, jmax (40, getChildComponent (0)->getX() - 5), getHeight(), | 4, 0, jmax (40, getChildComponent (0)->getX() - 5), getHeight(), | ||||
Justification::centredLeft, true); | Justification::centredLeft, true); | ||||
} | } | ||||
@@ -272,19 +265,14 @@ private: | |||||
class KeyMappingEditorComponent::MappingItem : public TreeViewItem | class KeyMappingEditorComponent::MappingItem : public TreeViewItem | ||||
{ | { | ||||
public: | public: | ||||
MappingItem (KeyMappingEditorComponent& owner_, const CommandID commandID_) | |||||
: owner (owner_), commandID (commandID_) | |||||
{ | |||||
} | |||||
MappingItem (KeyMappingEditorComponent& kec, const CommandID command) | |||||
: owner (kec), commandID (command) | |||||
{} | |||||
String getUniqueName() const { return String ((int) commandID) + "_id"; } | |||||
bool mightContainSubItems() { return false; } | |||||
int getItemHeight() const { return 20; } | |||||
Component* createItemComponent() | |||||
{ | |||||
return new ItemComponent (owner, commandID); | |||||
} | |||||
String getUniqueName() const { return String ((int) commandID) + "_id"; } | |||||
bool mightContainSubItems() { return false; } | |||||
int getItemHeight() const { return 20; } | |||||
Component* createItemComponent() { return new ItemComponent (owner, commandID); } | |||||
private: | private: | ||||
KeyMappingEditorComponent& owner; | KeyMappingEditorComponent& owner; | ||||
@@ -298,10 +286,9 @@ private: | |||||
class KeyMappingEditorComponent::CategoryItem : public TreeViewItem | class KeyMappingEditorComponent::CategoryItem : public TreeViewItem | ||||
{ | { | ||||
public: | public: | ||||
CategoryItem (KeyMappingEditorComponent& owner_, const String& name) | |||||
: owner (owner_), categoryName (name) | |||||
{ | |||||
} | |||||
CategoryItem (KeyMappingEditorComponent& kec, const String& name) | |||||
: owner (kec), categoryName (name) | |||||
{} | |||||
String getUniqueName() const { return categoryName + "_cat"; } | String getUniqueName() const { return categoryName + "_cat"; } | ||||
bool mightContainSubItems() { return true; } | bool mightContainSubItems() { return true; } | ||||
@@ -323,13 +310,11 @@ public: | |||||
{ | { | ||||
if (getNumSubItems() == 0) | if (getNumSubItems() == 0) | ||||
{ | { | ||||
Array <CommandID> commands (owner.getMappings().getCommandManager()->getCommandsInCategory (categoryName)); | |||||
const Array <CommandID> commands (owner.getCommandManager().getCommandsInCategory (categoryName)); | |||||
for (int i = 0; i < commands.size(); ++i) | for (int i = 0; i < commands.size(); ++i) | ||||
{ | |||||
if (owner.shouldCommandBeIncluded (commands[i])) | if (owner.shouldCommandBeIncluded (commands[i])) | ||||
addSubItem (new MappingItem (owner, commands[i])); | addSubItem (new MappingItem (owner, commands[i])); | ||||
} | |||||
} | } | ||||
} | } | ||||
else | else | ||||
@@ -351,8 +336,8 @@ class KeyMappingEditorComponent::TopLevelItem : public TreeViewItem, | |||||
private ChangeListener | private ChangeListener | ||||
{ | { | ||||
public: | public: | ||||
TopLevelItem (KeyMappingEditorComponent& owner_) | |||||
: owner (owner_) | |||||
TopLevelItem (KeyMappingEditorComponent& kec) | |||||
: owner (kec) | |||||
{ | { | ||||
setLinesDrawnForSubItems (false); | setLinesDrawnForSubItems (false); | ||||
owner.getMappings().addChangeListener (this); | owner.getMappings().addChangeListener (this); | ||||
@@ -371,11 +356,11 @@ public: | |||||
const OpennessRestorer opennessRestorer (*this); | const OpennessRestorer opennessRestorer (*this); | ||||
clearSubItems(); | clearSubItems(); | ||||
const StringArray categories (owner.getMappings().getCommandManager()->getCommandCategories()); | |||||
const StringArray categories (owner.getCommandManager().getCommandCategories()); | |||||
for (int i = 0; i < categories.size(); ++i) | for (int i = 0; i < categories.size(); ++i) | ||||
{ | { | ||||
const Array <CommandID> commands (owner.getMappings().getCommandManager()->getCommandsInCategory (categories[i])); | |||||
const Array <CommandID> commands (owner.getCommandManager().getCommandsInCategory (categories[i])); | |||||
int count = 0; | int count = 0; | ||||
for (int j = 0; j < commands.size(); ++j) | for (int j = 0; j < commands.size(); ++j) | ||||
@@ -469,14 +454,14 @@ void KeyMappingEditorComponent::resized() | |||||
//============================================================================== | //============================================================================== | ||||
bool KeyMappingEditorComponent::shouldCommandBeIncluded (const CommandID commandID) | bool KeyMappingEditorComponent::shouldCommandBeIncluded (const CommandID commandID) | ||||
{ | { | ||||
const ApplicationCommandInfo* const ci = mappings.getCommandManager()->getCommandForID (commandID); | |||||
const ApplicationCommandInfo* const ci = mappings.getCommandManager().getCommandForID (commandID); | |||||
return ci != nullptr && (ci->flags & ApplicationCommandInfo::hiddenFromKeyEditor) == 0; | return ci != nullptr && (ci->flags & ApplicationCommandInfo::hiddenFromKeyEditor) == 0; | ||||
} | } | ||||
bool KeyMappingEditorComponent::isCommandReadOnly (const CommandID commandID) | bool KeyMappingEditorComponent::isCommandReadOnly (const CommandID commandID) | ||||
{ | { | ||||
const ApplicationCommandInfo* const ci = mappings.getCommandManager()->getCommandForID (commandID); | |||||
const ApplicationCommandInfo* const ci = mappings.getCommandManager().getCommandForID (commandID); | |||||
return ci != nullptr && (ci->flags & ApplicationCommandInfo::readOnlyInKeyEditor) != 0; | return ci != nullptr && (ci->flags & ApplicationCommandInfo::readOnlyInKeyEditor) != 0; | ||||
} | } | ||||
@@ -63,6 +63,9 @@ public: | |||||
/** Returns the KeyPressMappingSet that this component is acting upon. */ | /** Returns the KeyPressMappingSet that this component is acting upon. */ | ||||
KeyPressMappingSet& getMappings() const noexcept { return mappings; } | KeyPressMappingSet& getMappings() const noexcept { return mappings; } | ||||
/** Returns the ApplicationCommandManager that this component is connected to. */ | |||||
ApplicationCommandManager& getCommandManager() const noexcept { return mappings.getCommandManager(); } | |||||
//============================================================================== | //============================================================================== | ||||
/** Can be overridden if some commands need to be excluded from the list. | /** Can be overridden if some commands need to be excluded from the list. | ||||