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.

103 lines
4.1KB

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