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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. //==============================================================================
  21. /**
  22. A factory object which can create ToolbarItemComponent objects.
  23. A subclass of ToolbarItemFactory publishes a set of types of toolbar item
  24. that it can create.
  25. Each type of item is identified by a unique ID, and multiple instances of an
  26. item type can exist at once (even on the same toolbar, e.g. spacers or separator
  27. bars).
  28. @see Toolbar, ToolbarItemComponent, ToolbarButton
  29. */
  30. class JUCE_API ToolbarItemFactory
  31. {
  32. public:
  33. //==============================================================================
  34. ToolbarItemFactory();
  35. /** Destructor. */
  36. virtual ~ToolbarItemFactory();
  37. //==============================================================================
  38. /** A set of reserved item ID values, used for the built-in item types.
  39. */
  40. enum SpecialItemIds
  41. {
  42. separatorBarId = -1, /**< The item ID for a vertical (or horizontal) separator bar that
  43. can be placed between sets of items to break them into groups. */
  44. spacerId = -2, /**< The item ID for a fixed-width space that can be placed between
  45. items.*/
  46. flexibleSpacerId = -3 /**< The item ID for a gap that pushes outwards against the things on
  47. either side of it, filling any available space. */
  48. };
  49. //==============================================================================
  50. /** Must return a list of the IDs for all the item types that this factory can create.
  51. The ids should be added to the array that is passed-in.
  52. An item ID can be any integer you choose, except for 0, which is considered a null ID,
  53. and the predefined IDs in the SpecialItemIds enum.
  54. You should also add the built-in types (separatorBarId, spacerId and flexibleSpacerId)
  55. to this list if you want your toolbar to be able to contain those items.
  56. The list returned here is used by the ToolbarItemPalette class to obtain its list
  57. of available items, and their order on the palette will reflect the order in which
  58. they appear on this list.
  59. @see ToolbarItemPalette
  60. */
  61. virtual void getAllToolbarItemIds (Array <int>& ids) = 0;
  62. /** Must return the set of items that should be added to a toolbar as its default set.
  63. This method is used by Toolbar::addDefaultItems() to determine which items to
  64. create.
  65. The items that your method adds to the array that is passed-in will be added to the
  66. toolbar in the same order. Items can appear in the list more than once.
  67. */
  68. virtual void getDefaultItemSet (Array <int>& ids) = 0;
  69. /** Must create an instance of one of the items that the factory lists in its
  70. getAllToolbarItemIds() method.
  71. The itemId parameter can be any of the values listed by your getAllToolbarItemIds()
  72. method, except for the built-in item types from the SpecialItemIds enum, which
  73. are created internally by the toolbar code.
  74. Try not to keep a pointer to the object that is returned, as it will be deleted
  75. automatically by the toolbar, and remember that multiple instances of the same
  76. item type are likely to exist at the same time.
  77. */
  78. virtual ToolbarItemComponent* createItem (int itemId) = 0;
  79. };