43 :
TRANS (
"Click to change this key-mapping"));
62 if (button !=
nullptr)
63 button.getComponent()->assignNewKey();
71 if (button !=
nullptr)
72 button->owner.getMappings().removeKeyPress (button->commandID,
86 void fitToContent (
const int h)
noexcept
100 TRANS (
"Please press a key combination now..."),
109 child->setWantsKeyboardFocus (
false);
124 <<
TRANS (
"Currently assigned to \"CMDN\"")
163 TRANS (
"Change key-mapping"),
164 TRANS (
"This key is already assigned to the command \"CMDN\"")
167 +
TRANS (
"Do you want to re-assign it to this new command instead?"),
180 static void keyChosen (
int result, ChangeKeyButton* button)
182 if (button !=
nullptr && button->currentKeyEntryWindow !=
nullptr)
186 button->currentKeyEntryWindow->setVisible (
false);
187 button->setNewKey (button->currentKeyEntryWindow->lastPress,
false);
190 button->currentKeyEntryWindow.reset();
196 currentKeyEntryWindow.reset (
new KeyEntryWindow (owner));
201 KeyMappingEditorComponent& owner;
205 ScopedMessageBox messageBox;
215 : owner (
kec), commandID (command)
223 for (
int i = 0; i <
jmin ((
int) maxNumAssignments, keyPresses.size()); ++i)
226 addKeyPressButton (
"Change Key Mapping", -1, isReadOnly);
229 void addKeyPressButton (
const String& desc,
const int index,
const bool isReadOnly)
232 keyChangeButtons.add (b);
234 b->setEnabled (! isReadOnly);
235 b->setVisible (keyChangeButtons.size() <= (
int) maxNumAssignments);
253 for (
int i = keyChangeButtons.size(); --i >= 0;)
255 auto* b = keyChangeButtons.getUnchecked (i);
258 b->setTopRightPosition (x, 1);
273 enum { maxNumAssignments = 3 };
283 : owner (
kec), commandID (command)
305 : owner (
kec), categoryName (name)
388 resetButton (
TRANS (
"reset to defaults"))
399 TRANS (
"Reset to defaults"),
400 TRANS (
"Are you sure you want to reset all the key-mappings to their default state?"),
437 treeItem->changeListenerCallback (
nullptr);
446 const int buttonHeight = 20;
447 h -= buttonHeight + 8;
A window that displays a message and has buttons for the user to react to it.
void addButton(const String &name, int returnValue, const KeyPress &shortcutKey1=KeyPress(), const KeyPress &shortcutKey2=KeyPress())
Adds a button to the window.
void setMessage(const String &message)
Changes the dialog box's message.
static ScopedMessageBox showScopedAsync(const MessageBoxOptions &options, std::function< void(int)> callback)
Shows an alert window using the specified options.
Array< CommandID > getCommandsInCategory(const String &categoryName) const
Returns a list of all the command UIDs in a particular category.
String getNameOfCommand(CommandID commandID) const noexcept
Returns the name field for a command.
StringArray getCommandCategories() const
Returns the list of categories.
const ApplicationCommandInfo * getCommandForID(CommandID commandID) const noexcept
Returns the details about a given command ID.
Holds a list of ChangeListeners, and sends messages to them when instructed.
void addChangeListener(ChangeListener *listener)
Registers a listener to receive change callbacks from this broadcaster.
void removeChangeListener(ChangeListener *listener)
Unregisters a listener from the list.
Receives change event callbacks that are sent out by a ChangeBroadcaster.
Represents a colour, also including a transparency value.
Holds a pointer to some type of Component, which automatically becomes null if the component is delet...
The base class for all JUCE user-interface objects.
void setInterceptsMouseClicks(bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
Changes the default return value for the hitTest() method.
bool isVisible() const noexcept
Tests whether the component is visible or not.
void setTitle(const String &newTitle)
Sets the title for this component.
int getHeight() const noexcept
Returns the component's height in pixels.
void grabKeyboardFocus()
Tries to give keyboard focus to this component.
int getX() const noexcept
Returns the x coordinate of the component's left edge.
void setTopRightPosition(int x, int y)
Moves the component to a new position.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
Component * getChildComponent(int index) const noexcept
Returns one of this component's child components, by it index.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
void setColour(int colourID, Colour newColour)
Registers a colour to be used for a particular purpose.
void setWantsKeyboardFocus(bool wantsFocus) noexcept
Sets a flag to indicate whether this component wants keyboard focus or not.
Colour findColour(int colourID, bool inheritFromParent=false) const
Looks for a colour that has been registered with the given colour ID number.
int getWidth() const noexcept
Returns the component's width in pixels.
LookAndFeel & getLookAndFeel() const noexcept
Finds the appropriate look-and-feel to use for this component.
void addChildComponent(Component *child, int zOrder=-1)
Adds a child component to this one.
const Array< Component * > & getChildren() const noexcept
Provides access to the underlying array of child components.
String getName() const noexcept
Returns the name of this component.
Represents a particular font, including its size, style, etc.
A graphics context, used for drawing a component or image.
void drawText(const String &text, int x, int y, int width, int height, Justification justificationType, bool useEllipsesIfTooBig=true) const
Draws a line of text within a specified rectangle.
void drawFittedText(const String &text, int x, int y, int width, int height, Justification justificationFlags, int maximumNumberOfLines, float minimumHorizontalScale=0.0f) const
Tries to draw a text string inside a given space.
void setFont(const Font &newFont)
Changes the font to use for subsequent text-drawing functions.
void setColour(Colour newColour)
Changes the current drawing colour.
@ centredLeft
Indicates that the item should be centred vertically but placed on the left hand side.
void itemOpennessChanged(bool isNowOpen) override
Called when an item is opened or closed.
String getAccessibilityName() override
Use this to set the name for this item that will be read out by accessibility clients.
int getItemHeight() const override
Must return the height required by this item.
bool mightContainSubItems() override
Tells the tree whether this item can potentially be opened.
void paintItem(Graphics &g, int width, int height) override
Draws the item's contents.
String getUniqueName() const override
Returns a string to uniquely identify this item.
bool keyStateChanged(bool) override
Called when a key is pressed or released.
bool keyPressed(const KeyPress &key) override
Called when a key is pressed.
void resized() override
Called when this component's size has been changed.
void paint(Graphics &g) override
Components can override this method to draw their content.
String getUniqueName() const override
Returns a string to uniquely identify this item.
std::unique_ptr< Component > createItemComponent() override
Creates a component that will be used to represent this item.
String getAccessibilityName() override
Use this to set the name for this item that will be read out by accessibility clients.
bool mightContainSubItems() override
Tells the tree whether this item can potentially be opened.
int getItemHeight() const override
Must return the height required by this item.
String getUniqueName() const override
Returns a string to uniquely identify this item.
void changeListenerCallback(ChangeBroadcaster *) override
Your subclass should implement this method to receive the callback.
bool mightContainSubItems() override
Tells the tree whether this item can potentially be opened.
A component to allow editing of the keymaps stored by a KeyPressMappingSet object.
@ backgroundColourId
The background colour to fill the editor background.
@ textColourId
The colour for the text.
~KeyMappingEditorComponent() override
Destructor.
void setColours(Colour mainBackground, Colour textColour)
Sets up the colours to use for parts of the component.
virtual bool isCommandReadOnly(CommandID commandID)
Can be overridden to indicate that some commands are shown as read-only.
virtual bool shouldCommandBeIncluded(CommandID commandID)
Can be overridden if some commands need to be excluded from the list.
void parentHierarchyChanged() override
Called to indicate that the component's parents have changed.
ApplicationCommandManager & getCommandManager() const noexcept
Returns the ApplicationCommandManager that this component is connected to.
void resized() override
Called when this component's size has been changed.
virtual String getDescriptionForKeyPress(const KeyPress &key)
This can be overridden to let you change the format of the string used to describe a keypress.
KeyPressMappingSet & getMappings() const noexcept
Returns the KeyPressMappingSet that this component is acting upon.
KeyMappingEditorComponent(KeyPressMappingSet &mappingSet, bool showResetToDefaultButton)
Creates a KeyMappingEditorComponent.
Manages and edits a list of keypresses, which it uses to invoke the appropriate command in an Applica...
void addKeyPress(CommandID commandID, const KeyPress &newKeyPress, int insertIndex=-1)
Assigns a keypress to a command.
Array< KeyPress > getKeyPressesAssignedToCommand(CommandID commandID) const
Returns a list of keypresses that are assigned to a particular command.
void removeKeyPress(CommandID commandID, int keyPressIndex)
Removes one of the keypresses that are assigned to a command.
CommandID findCommandForKeyPress(const KeyPress &keyPress) const noexcept
Looks for a command that corresponds to a keypress.
Represents a key press, including any modifier keys that are needed.
String getTextDescription() const
Creates a textual description of the key combination.
static MessageBoxOptions makeOptionsOkCancel(MessageBoxIconType iconType, const String &title, const String &message, const String &button1Text=String(), const String &button2Text=String(), Component *associatedComponent=nullptr)
Creates options suitable for a message box with two buttons.
static ModalComponentManager::Callback * forComponent(void(*functionToCall)(int, ComponentType *), ComponentType *component)
This is a utility function to create a ModalComponentManager::Callback that will call a static functi...
An array designed for holding objects.
String replace(StringRef stringToReplace, StringRef stringToInsertInstead, bool ignoreCase=false) const
Replaces all occurrences of a substring with another string.
void changeWidthToFitText()
Changes this button's width to fit neatly around its current text, without changing its height.
This handy class takes a copy of a TreeViewItem's openness when you create it, and restores that open...
void clearSubItems()
Removes any sub-items.
int getNumSubItems() const noexcept
Returns the number of sub-items that have been added to this item.
void setLinesDrawnForSubItems(bool shouldDrawLines) noexcept
Changes whether lines are drawn to connect any sub-items to this item.
void addSubItem(TreeViewItem *newItem, int insertPosition=-1)
Adds a sub-item.
@ backgroundColourId
A background colour to fill the component with.
void setDefaultOpenness(bool isOpenByDefault)
Sets whether items are open or closed by default.
void setIndentSize(int newIndentSize)
Changes the distance by which each nested level of the tree is indented.
void setRootItem(TreeViewItem *newRootItem)
Sets the item that is displayed in the TreeView.
void setRootItemVisible(bool shouldBeVisible)
Changes whether the tree's root item is shown or not.
#define TRANS(stringLiteral)
Uses the LocalisedStrings class to translate the given string literal.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
@ WarningIcon
An exclamation mark to indicate that the dialog is a warning about something and shouldn't be ignored...
@ QuestionIcon
A question-mark icon, for dialog boxes that need the user to answer a question.
@ NoIcon
No icon will be shown on the dialog box.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
int CommandID
A type used to hold the unique ID for an application command.
@ readOnlyInKeyEditor
If this flag is present, then a KeyMappingEditorComponent will display the command in its list,...
@ hiddenFromKeyEditor
If this flag is present, then a KeyMappingEditorComponent will not display the command in its list.