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.

juce_ToolbarItemFactory.h 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_TOOLBARITEMFACTORY_H_INCLUDED
  18. #define JUCE_TOOLBARITEMFACTORY_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A factory object which can create ToolbarItemComponent objects.
  22. A subclass of ToolbarItemFactory publishes a set of types of toolbar item
  23. that it can create.
  24. Each type of item is identified by a unique ID, and multiple instances of an
  25. item type can exist at once (even on the same toolbar, e.g. spacers or separator
  26. bars).
  27. @see Toolbar, ToolbarItemComponent, ToolbarButton
  28. */
  29. class JUCE_API ToolbarItemFactory
  30. {
  31. public:
  32. //==============================================================================
  33. ToolbarItemFactory();
  34. /** Destructor. */
  35. virtual ~ToolbarItemFactory();
  36. //==============================================================================
  37. /** A set of reserved item ID values, used for the built-in item types.
  38. */
  39. enum SpecialItemIds
  40. {
  41. separatorBarId = -1, /**< The item ID for a vertical (or horizontal) separator bar that
  42. can be placed between sets of items to break them into groups. */
  43. spacerId = -2, /**< The item ID for a fixed-width space that can be placed between
  44. items.*/
  45. flexibleSpacerId = -3 /**< The item ID for a gap that pushes outwards against the things on
  46. either side of it, filling any available space. */
  47. };
  48. //==============================================================================
  49. /** Must return a list of the IDs for all the item types that this factory can create.
  50. The ids should be added to the array that is passed-in.
  51. An item ID can be any integer you choose, except for 0, which is considered a null ID,
  52. and the predefined IDs in the SpecialItemIds enum.
  53. You should also add the built-in types (separatorBarId, spacerId and flexibleSpacerId)
  54. to this list if you want your toolbar to be able to contain those items.
  55. The list returned here is used by the ToolbarItemPalette class to obtain its list
  56. of available items, and their order on the palette will reflect the order in which
  57. they appear on this list.
  58. @see ToolbarItemPalette
  59. */
  60. virtual void getAllToolbarItemIds (Array <int>& ids) = 0;
  61. /** Must return the set of items that should be added to a toolbar as its default set.
  62. This method is used by Toolbar::addDefaultItems() to determine which items to
  63. create.
  64. The items that your method adds to the array that is passed-in will be added to the
  65. toolbar in the same order. Items can appear in the list more than once.
  66. */
  67. virtual void getDefaultItemSet (Array <int>& ids) = 0;
  68. /** Must create an instance of one of the items that the factory lists in its
  69. getAllToolbarItemIds() method.
  70. The itemId parameter can be any of the values listed by your getAllToolbarItemIds()
  71. method, except for the built-in item types from the SpecialItemIds enum, which
  72. are created internally by the toolbar code.
  73. Try not to keep a pointer to the object that is returned, as it will be deleted
  74. automatically by the toolbar, and remember that multiple instances of the same
  75. item type are likely to exist at the same time.
  76. */
  77. virtual ToolbarItemComponent* createItem (int itemId) = 0;
  78. };
  79. #endif // JUCE_TOOLBARITEMFACTORY_H_INCLUDED