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.

137 lines
5.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_KEYMAPPINGEDITORCOMPONENT_H_INCLUDED
  18. #define JUCE_KEYMAPPINGEDITORCOMPONENT_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A component to allow editing of the keymaps stored by a KeyPressMappingSet
  22. object.
  23. @see KeyPressMappingSet
  24. */
  25. class JUCE_API KeyMappingEditorComponent : public Component
  26. {
  27. public:
  28. //==============================================================================
  29. /** Creates a KeyMappingEditorComponent.
  30. @param mappingSet this is the set of mappings to display and edit. Make sure the
  31. mappings object is not deleted before this component!
  32. @param showResetToDefaultButton if true, then at the bottom of the list, the
  33. component will include a 'reset to defaults' button.
  34. */
  35. KeyMappingEditorComponent (KeyPressMappingSet& mappingSet,
  36. bool showResetToDefaultButton);
  37. /** Destructor. */
  38. ~KeyMappingEditorComponent();
  39. //==============================================================================
  40. /** Sets up the colours to use for parts of the component.
  41. @param mainBackground colour to use for most of the background
  42. @param textColour colour to use for the text
  43. */
  44. void setColours (Colour mainBackground,
  45. Colour textColour);
  46. /** Returns the KeyPressMappingSet that this component is acting upon. */
  47. KeyPressMappingSet& getMappings() const noexcept { return mappings; }
  48. /** Returns the ApplicationCommandManager that this component is connected to. */
  49. ApplicationCommandManager& getCommandManager() const noexcept { return mappings.getCommandManager(); }
  50. //==============================================================================
  51. /** Can be overridden if some commands need to be excluded from the list.
  52. By default this will use the KeyPressMappingSet's shouldCommandBeVisibleInEditor()
  53. method to decide what to return, but you can override it to handle special cases.
  54. */
  55. virtual bool shouldCommandBeIncluded (CommandID commandID);
  56. /** Can be overridden to indicate that some commands are shown as read-only.
  57. By default this will use the KeyPressMappingSet's shouldCommandBeReadOnlyInEditor()
  58. method to decide what to return, but you can override it to handle special cases.
  59. */
  60. virtual bool isCommandReadOnly (CommandID commandID);
  61. /** This can be overridden to let you change the format of the string used
  62. to describe a keypress.
  63. This is handy if you're using non-standard KeyPress objects, e.g. for custom
  64. keys that are triggered by something else externally. If you override the
  65. method, be sure to let the base class's method handle keys you're not
  66. interested in.
  67. */
  68. virtual String getDescriptionForKeyPress (const KeyPress& key);
  69. //==============================================================================
  70. /** A set of colour IDs to use to change the colour of various aspects of the editor.
  71. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  72. methods.
  73. To change the colours of the menu that pops up
  74. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  75. */
  76. enum ColourIds
  77. {
  78. backgroundColourId = 0x100ad00, /**< The background colour to fill the editor background. */
  79. textColourId = 0x100ad01, /**< The colour for the text. */
  80. };
  81. //==============================================================================
  82. /** @internal */
  83. void parentHierarchyChanged() override;
  84. /** @internal */
  85. void resized() override;
  86. private:
  87. //==============================================================================
  88. KeyPressMappingSet& mappings;
  89. TreeView tree;
  90. TextButton resetButton;
  91. class TopLevelItem;
  92. class ChangeKeyButton;
  93. class MappingItem;
  94. class CategoryItem;
  95. class ItemComponent;
  96. friend class TopLevelItem;
  97. friend struct ContainerDeletePolicy<ChangeKeyButton>;
  98. friend struct ContainerDeletePolicy<TopLevelItem>;
  99. ScopedPointer<TopLevelItem> treeItem;
  100. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KeyMappingEditorComponent)
  101. };
  102. #endif // JUCE_KEYMAPPINGEDITORCOMPONENT_H_INCLUDED