juce_ToolbarItemPalette.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_TOOLBARITEMPALETTE_H_INCLUDED
  18. #define JUCE_TOOLBARITEMPALETTE_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A component containing a list of toolbar items, which the user can drag onto
  22. a toolbar to add them.
  23. You can use this class directly, but it's a lot easier to call Toolbar::showCustomisationDialog(),
  24. which automatically shows one of these in a dialog box with lots of extra controls.
  25. @see Toolbar
  26. */
  27. class JUCE_API ToolbarItemPalette : public Component,
  28. public DragAndDropContainer
  29. {
  30. public:
  31. //==============================================================================
  32. /** Creates a palette of items for a given factory, with the aim of adding them
  33. to the specified toolbar.
  34. The ToolbarItemFactory::getAllToolbarItemIds() method is used to create the
  35. set of items that are shown in this palette.
  36. The toolbar and factory must not be deleted while this object exists.
  37. */
  38. ToolbarItemPalette (ToolbarItemFactory& factory,
  39. Toolbar& toolbar);
  40. /** Destructor. */
  41. ~ToolbarItemPalette();
  42. //==============================================================================
  43. /** @internal */
  44. void resized() override;
  45. private:
  46. ToolbarItemFactory& factory;
  47. Toolbar& toolbar;
  48. Viewport viewport;
  49. OwnedArray <ToolbarItemComponent> items;
  50. friend class Toolbar;
  51. void replaceComponent (ToolbarItemComponent&);
  52. void addComponent (int itemId, int index);
  53. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarItemPalette)
  54. };
  55. #endif // JUCE_TOOLBARITEMPALETTE_H_INCLUDED