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.

259 lines
12KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. The latest JUCE look-and-feel style, as introduced in 2017.
  23. @see LookAndFeel, LookAndFeel_V1, LookAndFeel_V2, LookAndFeel_V3
  24. @tags{GUI}
  25. */
  26. class JUCE_API LookAndFeel_V4 : public LookAndFeel_V3
  27. {
  28. public:
  29. /**
  30. A struct containing the set of colours to apply to the GUI
  31. */
  32. class ColourScheme
  33. {
  34. public:
  35. /** The standard set of colours to use. */
  36. enum UIColour
  37. {
  38. windowBackground = 0,
  39. widgetBackground,
  40. menuBackground,
  41. outline,
  42. defaultText,
  43. defaultFill,
  44. highlightedText,
  45. highlightedFill,
  46. menuText,
  47. numColours
  48. };
  49. template <typename... ItemColours>
  50. ColourScheme (ItemColours... coloursToUse)
  51. {
  52. static_assert (sizeof... (coloursToUse) == numColours, "Must supply one colour for each UIColour item");
  53. const Colour c[] = { Colour (coloursToUse)... };
  54. for (int i = 0; i < numColours; ++i)
  55. palette[i] = c[i];
  56. }
  57. ColourScheme (const ColourScheme&) = default;
  58. ColourScheme& operator= (const ColourScheme&) = default;
  59. /** Returns a colour from the scheme */
  60. Colour getUIColour (UIColour colourToGet) const noexcept;
  61. /** Sets a scheme colour. */
  62. void setUIColour (UIColour colourToSet, Colour newColour) noexcept;
  63. /** Returns true if two ColourPalette objects contain the same colours. */
  64. bool operator== (const ColourScheme&) const noexcept;
  65. /** Returns false if two ColourPalette objects contain the same colours. */
  66. bool operator!= (const ColourScheme&) const noexcept;
  67. private:
  68. Colour palette[numColours];
  69. };
  70. //==============================================================================
  71. /** Creates a LookAndFeel_V4 object with a default colour scheme. */
  72. LookAndFeel_V4();
  73. /** Creates a LookAndFeel_V4 object with a given colour scheme. */
  74. LookAndFeel_V4 (ColourScheme);
  75. /** Destructor. */
  76. ~LookAndFeel_V4() override;
  77. //==============================================================================
  78. void setColourScheme (ColourScheme);
  79. ColourScheme& getCurrentColourScheme() noexcept { return currentColourScheme; }
  80. static ColourScheme getDarkColourScheme();
  81. static ColourScheme getMidnightColourScheme();
  82. static ColourScheme getGreyColourScheme();
  83. static ColourScheme getLightColourScheme();
  84. //==============================================================================
  85. Button* createDocumentWindowButton (int) override;
  86. void positionDocumentWindowButtons (DocumentWindow&, int, int, int, int, Button*, Button*, Button*, bool) override;
  87. void drawDocumentWindowTitleBar (DocumentWindow&, Graphics&, int, int, int, int, const Image*, bool) override;
  88. //==============================================================================
  89. Font getTextButtonFont (TextButton&, int buttonHeight) override;
  90. void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour,
  91. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  92. void drawToggleButton (Graphics&, ToggleButton&,
  93. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  94. void drawTickBox (Graphics&, Component&,
  95. float x, float y, float w, float h,
  96. bool ticked, bool isEnabled,
  97. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  98. void changeToggleButtonWidthToFitText (ToggleButton&) override;
  99. //==============================================================================
  100. AlertWindow* createAlertWindow (const String& title, const String& message,
  101. const String& button1,
  102. const String& button2,
  103. const String& button3,
  104. AlertWindow::AlertIconType iconType,
  105. int numButtons, Component* associatedComponent) override;
  106. void drawAlertBox (Graphics&, AlertWindow&, const Rectangle<int>& textArea, TextLayout&) override;
  107. int getAlertWindowButtonHeight() override;
  108. Font getAlertWindowTitleFont() override;
  109. Font getAlertWindowMessageFont() override;
  110. Font getAlertWindowFont() override;
  111. //==============================================================================
  112. void drawProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String& textToShow) override;
  113. bool isProgressBarOpaque (ProgressBar&) override { return false; }
  114. //==============================================================================
  115. int getDefaultScrollbarWidth() override;
  116. void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height, bool isScrollbarVertical,
  117. int thumbStartPosition, int thumbSize, bool isMouseOver, bool isMouseDown) override;
  118. //==============================================================================
  119. Path getTickShape (float height) override;
  120. Path getCrossShape (float height) override;
  121. //==============================================================================
  122. void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) override;
  123. void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) override;
  124. //==============================================================================
  125. Button* createFileBrowserGoUpButton() override;
  126. void layoutFileBrowserComponent (FileBrowserComponent&,
  127. DirectoryContentsDisplayComponent*,
  128. FilePreviewComponent*,
  129. ComboBox* currentPathBox,
  130. TextEditor* filenameBox,
  131. Button* goUpButton) override;
  132. void drawFileBrowserRow (Graphics&, int width, int height,
  133. const File& file, const String& filename, Image* icon,
  134. const String& fileSizeDescription, const String& fileTimeDescription,
  135. bool isDirectory, bool isItemSelected, int itemIndex,
  136. DirectoryContentsDisplayComponent&) override;
  137. //==============================================================================
  138. void drawPopupMenuItem (Graphics&, const Rectangle<int>& area,
  139. bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu,
  140. const String& text, const String& shortcutKeyText,
  141. const Drawable* icon, const Colour* textColour) override;
  142. void getIdealPopupMenuItemSize (const String& text, bool isSeparator, int standardMenuItemHeight,
  143. int& idealWidth, int& idealHeight) override;
  144. void drawMenuBarBackground (Graphics&, int width, int height, bool isMouseOverBar, MenuBarComponent&) override;
  145. void drawMenuBarItem (Graphics&, int width, int height,
  146. int itemIndex, const String& itemText,
  147. bool isMouseOverItem, bool isMenuOpen, bool isMouseOverBar,
  148. MenuBarComponent&) override;
  149. //==============================================================================
  150. void drawComboBox (Graphics&, int width, int height, bool isButtonDown,
  151. int buttonX, int buttonY, int buttonW, int buttonH,
  152. ComboBox&) override;
  153. Font getComboBoxFont (ComboBox&) override;
  154. void positionComboBoxText (ComboBox&, Label&) override;
  155. //==============================================================================
  156. int getSliderThumbRadius (Slider&) override;
  157. void drawLinearSlider (Graphics&, int x, int y, int width, int height,
  158. float sliderPos, float minSliderPos, float maxSliderPos,
  159. const Slider::SliderStyle, Slider&) override;
  160. void drawRotarySlider (Graphics&, int x, int y, int width, int height,
  161. float sliderPosProportional, float rotaryStartAngle,
  162. float rotaryEndAngle, Slider&) override;
  163. void drawPointer (Graphics&, float x, float y, float diameter,
  164. const Colour&, int direction) noexcept;
  165. Label* createSliderTextBox (Slider&) override;
  166. //==============================================================================
  167. void drawTooltip (Graphics&, const String& text, int width, int height) override;
  168. //==============================================================================
  169. void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area,
  170. bool isMouseOver, bool isMouseDown,
  171. ConcertinaPanel&, Component& panel) override;
  172. //==============================================================================
  173. void drawLevelMeter (Graphics&, int, int, float) override;
  174. //==============================================================================
  175. void paintToolbarBackground (Graphics&, int width, int height, Toolbar&) override;
  176. void paintToolbarButtonLabel (Graphics&, int x, int y, int width, int height,
  177. const String& text, ToolbarItemComponent&) override;
  178. //==============================================================================
  179. void drawPropertyPanelSectionHeader (Graphics&, const String& name, bool isOpen, int width, int height) override;
  180. void drawPropertyComponentBackground (Graphics&, int width, int height, PropertyComponent&) override;
  181. void drawPropertyComponentLabel (Graphics&, int width, int height, PropertyComponent&) override;
  182. Rectangle<int> getPropertyComponentContentPosition (PropertyComponent&) override;
  183. //==============================================================================
  184. void drawCallOutBoxBackground (CallOutBox&, Graphics&, const Path&, Image&) override;
  185. //==============================================================================
  186. void drawStretchableLayoutResizerBar (Graphics&, int, int, bool, bool, bool) override;
  187. private:
  188. //==============================================================================
  189. void drawLinearProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String&);
  190. void drawCircularProgressBar (Graphics&, ProgressBar&, const String&);
  191. int getPropertyComponentIndent (PropertyComponent&);
  192. //==============================================================================
  193. void initialiseColours();
  194. ColourScheme currentColourScheme;
  195. //==============================================================================
  196. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V4)
  197. };
  198. } // namespace juce