Audio plugin host https://kx.studio/carla
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.

184 lines
6.8KB

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