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_MenuBarComponent.h 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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_MENUBARCOMPONENT_H_INCLUDED
  18. #define JUCE_MENUBARCOMPONENT_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A menu bar component.
  22. @see MenuBarModel
  23. */
  24. class JUCE_API MenuBarComponent : public Component,
  25. private MenuBarModel::Listener,
  26. private Timer
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates a menu bar.
  31. @param model the model object to use to control this bar. You can
  32. pass 0 into this if you like, and set the model later
  33. using the setModel() method
  34. */
  35. MenuBarComponent (MenuBarModel* model);
  36. /** Destructor. */
  37. ~MenuBarComponent();
  38. //==============================================================================
  39. /** Changes the model object to use to control the bar.
  40. This can be a null pointer, in which case the bar will be empty. Don't delete the object
  41. that is passed-in while it's still being used by this MenuBar.
  42. */
  43. void setModel (MenuBarModel* newModel);
  44. /** Returns the current menu bar model being used.
  45. */
  46. MenuBarModel* getModel() const noexcept;
  47. //==============================================================================
  48. /** Pops up one of the menu items.
  49. This lets you manually open one of the menus - it could be triggered by a
  50. key shortcut, for example.
  51. */
  52. void showMenu (int menuIndex);
  53. //==============================================================================
  54. /** @internal */
  55. void paint (Graphics&) override;
  56. /** @internal */
  57. void resized() override;
  58. /** @internal */
  59. void mouseEnter (const MouseEvent&) override;
  60. /** @internal */
  61. void mouseExit (const MouseEvent&) override;
  62. /** @internal */
  63. void mouseDown (const MouseEvent&) override;
  64. /** @internal */
  65. void mouseDrag (const MouseEvent&) override;
  66. /** @internal */
  67. void mouseUp (const MouseEvent&) override;
  68. /** @internal */
  69. void mouseMove (const MouseEvent&) override;
  70. /** @internal */
  71. void handleCommandMessage (int commandId) override;
  72. /** @internal */
  73. bool keyPressed (const KeyPress&) override;
  74. /** @internal */
  75. void menuBarItemsChanged (MenuBarModel*) override;
  76. /** @internal */
  77. void menuCommandInvoked (MenuBarModel*, const ApplicationCommandTarget::InvocationInfo&) override;
  78. private:
  79. //==============================================================================
  80. MenuBarModel* model;
  81. StringArray menuNames;
  82. Array<int> xPositions;
  83. Point<int> lastMousePos;
  84. int itemUnderMouse, currentPopupIndex, topLevelIndexClicked;
  85. int getItemAt (Point<int>);
  86. void setItemUnderMouse (int index);
  87. void setOpenItem (int index);
  88. void updateItemUnderMouse (Point<int>);
  89. void timerCallback() override;
  90. void repaintMenuItem (int index);
  91. void menuDismissed (int topLevelIndex, int itemId);
  92. static void menuBarMenuDismissedCallback (int, MenuBarComponent*, int);
  93. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MenuBarComponent)
  94. };
  95. #endif // JUCE_MENUBARCOMPONENT_H_INCLUDED