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_LookAndFeel_V4.h 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. namespace juce
  20. {
  21. class JUCE_API LookAndFeel_V4 : public LookAndFeel_V3
  22. {
  23. public:
  24. /**
  25. A struct containing the set of colours to apply to the GUI
  26. */
  27. class ColourScheme
  28. {
  29. public:
  30. /** The standard set of colours to use. */
  31. enum UIColour
  32. {
  33. windowBackground = 0,
  34. widgetBackground,
  35. menuBackground,
  36. outline,
  37. defaultText,
  38. defaultFill,
  39. highlightedText,
  40. highlightedFill,
  41. menuText,
  42. numColours
  43. };
  44. template <typename... ItemColours>
  45. ColourScheme (ItemColours... coloursToUse)
  46. {
  47. static_assert (sizeof... (coloursToUse) == numColours, "Must supply one colour for each UIColour item");
  48. const Colour c[] = { Colour (coloursToUse)... };
  49. for (int i = 0; i < numColours; ++i)
  50. palette[i] = c[i];
  51. }
  52. ColourScheme (const ColourScheme&) = default;
  53. ColourScheme& operator= (const ColourScheme&) = default;
  54. /** Returns a colour from the scheme */
  55. Colour getUIColour (UIColour colourToGet) const noexcept;
  56. /** Sets a scheme colour. */
  57. void setUIColour (UIColour colourToSet, Colour newColour) noexcept;
  58. /** Returns true if two ColourPalette objects contain the same colours. */
  59. bool operator== (const ColourScheme&) const noexcept;
  60. /** Returns false if two ColourPalette objects contain the same colours. */
  61. bool operator!= (const ColourScheme&) const noexcept;
  62. private:
  63. Colour palette[numColours];
  64. };
  65. //==============================================================================
  66. /** Creates a LookAndFeel_V4 object with a default colour scheme. */
  67. LookAndFeel_V4();
  68. /** Creates a LookAndFeel_V4 object with a given colour scheme. */
  69. LookAndFeel_V4 (ColourScheme);
  70. /** Destructor. */
  71. ~LookAndFeel_V4();
  72. //==============================================================================
  73. void setColourScheme (ColourScheme);
  74. ColourScheme& getCurrentColourScheme() noexcept { return currentColourScheme; }
  75. static ColourScheme getDarkColourScheme();
  76. static ColourScheme getMidnightColourScheme();
  77. static ColourScheme getGreyColourScheme();
  78. static ColourScheme getLightColourScheme();
  79. //==============================================================================
  80. Button* createDocumentWindowButton (int) override;
  81. void positionDocumentWindowButtons (DocumentWindow&, int, int, int, int, Button*, Button*, Button*, bool) override;
  82. void drawDocumentWindowTitleBar (DocumentWindow&, Graphics&, int, int, int, int, const Image*, bool) override;
  83. //==============================================================================
  84. void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour,
  85. bool isMouseOverButton, bool isButtonDown) override;
  86. void drawToggleButton (Graphics&, ToggleButton&, bool isMouseOverButton, bool isButtonDown) override;
  87. void drawTickBox (Graphics&, Component&,
  88. float x, float y, float w, float h,
  89. bool ticked, bool isEnabled, bool isMouseOverButton, bool isButtonDown) override;
  90. //==============================================================================
  91. AlertWindow* createAlertWindow (const String& title, const String& message,
  92. const String& button1,
  93. const String& button2,
  94. const String& button3,
  95. AlertWindow::AlertIconType iconType,
  96. int numButtons, Component* associatedComponent) override;
  97. void drawAlertBox (Graphics&, AlertWindow&, const Rectangle<int>& textArea, TextLayout&) override;
  98. int getAlertWindowButtonHeight() override;
  99. Font getAlertWindowTitleFont() override;
  100. Font getAlertWindowMessageFont() override;
  101. Font getAlertWindowFont() override;
  102. //==============================================================================
  103. void drawProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String& textToShow) override;
  104. bool isProgressBarOpaque (ProgressBar&) override { return false; }
  105. //==============================================================================
  106. int getDefaultScrollbarWidth() override;
  107. void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height, bool isScrollbarVertical,
  108. int thumbStartPosition, int thumbSize, bool isMouseOver, bool isMouseDown) override;
  109. //==============================================================================
  110. Path getTickShape (float height) override;
  111. Path getCrossShape (float height) override;
  112. //==============================================================================
  113. void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) override;
  114. void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) override;
  115. //==============================================================================
  116. Button* createFileBrowserGoUpButton() override;
  117. void layoutFileBrowserComponent (FileBrowserComponent&,
  118. DirectoryContentsDisplayComponent*,
  119. FilePreviewComponent*,
  120. ComboBox* currentPathBox,
  121. TextEditor* filenameBox,
  122. Button* goUpButton) override;
  123. void drawFileBrowserRow (Graphics&, int width, int height,
  124. const File& file, const String& filename, Image* icon,
  125. const String& fileSizeDescription, const String& fileTimeDescription,
  126. bool isDirectory, bool isItemSelected, int itemIndex,
  127. DirectoryContentsDisplayComponent&) override;
  128. //==============================================================================
  129. void drawPopupMenuItem (Graphics&, const Rectangle<int>& area,
  130. bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu,
  131. const String& text, const String& shortcutKeyText,
  132. const Drawable* icon, const Colour* textColour) override;
  133. void getIdealPopupMenuItemSize (const String& text, bool isSeparator, int standardMenuItemHeight,
  134. int& idealWidth, int& idealHeight) override;
  135. void drawMenuBarBackground (Graphics&, int width, int height, bool isMouseOverBar, MenuBarComponent&) override;
  136. void drawMenuBarItem (Graphics&, int width, int height,
  137. int itemIndex, const String& itemText,
  138. bool isMouseOverItem, bool isMenuOpen, bool isMouseOverBar,
  139. MenuBarComponent&) override;
  140. //==============================================================================
  141. void drawComboBox (Graphics&, int width, int height, bool isButtonDown,
  142. int buttonX, int buttonY, int buttonW, int buttonH,
  143. ComboBox&) override;
  144. Font getComboBoxFont (ComboBox&) override;
  145. void positionComboBoxText (ComboBox&, Label&) override;
  146. //==============================================================================
  147. void drawLinearSlider (Graphics&, int x, int y, int width, int height,
  148. float sliderPos, float minSliderPos, float maxSliderPos,
  149. const Slider::SliderStyle, Slider&) override;
  150. void drawRotarySlider (Graphics&, int x, int y, int width, int height,
  151. float sliderPosProportional, float rotaryStartAngle,
  152. float rotaryEndAngle, Slider&) override;
  153. void drawPointer (Graphics&, float x, float y, float diameter,
  154. const Colour&, int direction) noexcept;
  155. //==============================================================================
  156. void drawTooltip (Graphics&, const String& text, int width, int height) override;
  157. //==============================================================================
  158. void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area,
  159. bool isMouseOver, bool isMouseDown,
  160. ConcertinaPanel&, Component& panel) override;
  161. //==============================================================================
  162. void drawLevelMeter (Graphics&, int, int, float) override;
  163. //==============================================================================
  164. void paintToolbarBackground (Graphics&, int width, int height, Toolbar&) override;
  165. void paintToolbarButtonLabel (Graphics&, int x, int y, int width, int height,
  166. const String& text, ToolbarItemComponent&) override;
  167. //==============================================================================
  168. void drawPropertyPanelSectionHeader (Graphics&, const String& name, bool isOpen, int width, int height) override;
  169. void drawPropertyComponentBackground (Graphics&, int width, int height, PropertyComponent&) override;
  170. void drawPropertyComponentLabel (Graphics&, int width, int height, PropertyComponent&) override;
  171. Rectangle<int> getPropertyComponentContentPosition (PropertyComponent&) override;
  172. //==============================================================================
  173. void drawCallOutBoxBackground (CallOutBox&, Graphics&, const Path&, Image&) override;
  174. //==============================================================================
  175. void drawStretchableLayoutResizerBar (Graphics&, int, int, bool, bool, bool) override;
  176. private:
  177. //==============================================================================
  178. void drawLinearProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String&);
  179. void drawCircularProgressBar (Graphics&, ProgressBar&, const String&);
  180. int getPropertyComponentIndent (PropertyComponent&);
  181. //==============================================================================
  182. void initialiseColours();
  183. ColourScheme currentColourScheme;
  184. //==============================================================================
  185. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V4)
  186. };
  187. } // namespace juce