The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
7.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_APPLICATIONCOMMANDINFO_JUCEHEADER__
  19. #define __JUCE_APPLICATIONCOMMANDINFO_JUCEHEADER__
  20. #include "../keyboard/juce_KeyPress.h"
  21. #include "juce_ApplicationCommandID.h"
  22. //==============================================================================
  23. /**
  24. Holds information describing an application command.
  25. This object is used to pass information about a particular command, such as its
  26. name, description and other usage flags.
  27. When an ApplicationCommandTarget is asked to provide information about the commands
  28. it can perform, this is the structure gets filled-in to describe each one.
  29. @see ApplicationCommandTarget, ApplicationCommandTarget::getCommandInfo(),
  30. ApplicationCommandManager
  31. */
  32. struct JUCE_API ApplicationCommandInfo
  33. {
  34. //==============================================================================
  35. explicit ApplicationCommandInfo (CommandID commandID) noexcept;
  36. //==============================================================================
  37. /** Sets a number of the structures values at once.
  38. The meanings of each of the parameters is described below, in the appropriate
  39. member variable's description.
  40. */
  41. void setInfo (const String& shortName,
  42. const String& description,
  43. const String& categoryName,
  44. int flags) noexcept;
  45. /** An easy way to set or remove the isDisabled bit in the structure's flags field.
  46. If isActive is true, the flags member has the isDisabled bit cleared; if isActive
  47. is false, the bit is set.
  48. */
  49. void setActive (bool isActive) noexcept;
  50. /** An easy way to set or remove the isTicked bit in the structure's flags field.
  51. */
  52. void setTicked (bool isTicked) noexcept;
  53. /** Handy method for adding a keypress to the defaultKeypresses array.
  54. This is just so you can write things like:
  55. @code
  56. myinfo.addDefaultKeypress ('s', ModifierKeys::commandModifier);
  57. @endcode
  58. instead of
  59. @code
  60. myinfo.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier));
  61. @endcode
  62. */
  63. void addDefaultKeypress (int keyCode,
  64. const ModifierKeys& modifiers) noexcept;
  65. //==============================================================================
  66. /** The command's unique ID number.
  67. */
  68. CommandID commandID;
  69. /** A short name to describe the command.
  70. This should be suitable for use in menus, on buttons that trigger the command, etc.
  71. You can use the setInfo() method to quickly set this and some of the command's
  72. other properties.
  73. */
  74. String shortName;
  75. /** A longer description of the command.
  76. This should be suitable for use in contexts such as a KeyMappingEditorComponent or
  77. pop-up tooltip describing what the command does.
  78. You can use the setInfo() method to quickly set this and some of the command's
  79. other properties.
  80. */
  81. String description;
  82. /** A named category that the command fits into.
  83. You can give your commands any category you like, and these will be displayed in
  84. contexts such as the KeyMappingEditorComponent, where the category is used to group
  85. commands together.
  86. You can use the setInfo() method to quickly set this and some of the command's
  87. other properties.
  88. */
  89. String categoryName;
  90. /** A list of zero or more keypresses that should be used as the default keys for
  91. this command.
  92. Methods such as KeyPressMappingSet::resetToDefaultMappings() will use the keypresses in
  93. this list to initialise the default set of key-to-command mappings.
  94. @see addDefaultKeypress
  95. */
  96. Array <KeyPress> defaultKeypresses;
  97. //==============================================================================
  98. /** Flags describing the ways in which this command should be used.
  99. A bitwise-OR of these values is stored in the ApplicationCommandInfo::flags
  100. variable.
  101. */
  102. enum CommandFlags
  103. {
  104. /** Indicates that the command can't currently be performed.
  105. The ApplicationCommandTarget::getCommandInfo() method must set this flag if it's
  106. not currently permissable to perform the command. If the flag is set, then
  107. components that trigger the command, e.g. PopupMenu, may choose to grey-out the
  108. command or show themselves as not being enabled.
  109. @see ApplicationCommandInfo::setActive
  110. */
  111. isDisabled = 1 << 0,
  112. /** Indicates that the command should have a tick next to it on a menu.
  113. If your command is shown on a menu and this is set, it'll show a tick next to
  114. it. Other components such as buttons may also use this flag to indicate that it
  115. is a value that can be toggled, and is currently in the 'on' state.
  116. @see ApplicationCommandInfo::setTicked
  117. */
  118. isTicked = 1 << 1,
  119. /** If this flag is present, then when a KeyPressMappingSet invokes the command,
  120. it will call the command twice, once on key-down and again on key-up.
  121. @see ApplicationCommandTarget::InvocationInfo
  122. */
  123. wantsKeyUpDownCallbacks = 1 << 2,
  124. /** If this flag is present, then a KeyMappingEditorComponent will not display the
  125. command in its list.
  126. */
  127. hiddenFromKeyEditor = 1 << 3,
  128. /** If this flag is present, then a KeyMappingEditorComponent will display the
  129. command in its list, but won't allow the assigned keypress to be changed.
  130. */
  131. readOnlyInKeyEditor = 1 << 4,
  132. /** If this flag is present and the command is invoked from a keypress, then any
  133. buttons or menus that are also connected to the command will not flash to
  134. indicate that they've been triggered.
  135. */
  136. dontTriggerVisualFeedback = 1 << 5
  137. };
  138. /** A bitwise-OR of the values specified in the CommandFlags enum.
  139. You can use the setInfo() method to quickly set this and some of the command's
  140. other properties.
  141. */
  142. int flags;
  143. };
  144. #endif // __JUCE_APPLICATIONCOMMANDINFO_JUCEHEADER__