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.

252 lines
12KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 7 technical preview.
  4. Copyright (c) 2022 - 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 the technical preview this file cannot be licensed commercially.
  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. The latest JUCE look-and-feel style, as introduced in 2017.
  18. @see LookAndFeel, LookAndFeel_V1, LookAndFeel_V2, LookAndFeel_V3
  19. @tags{GUI}
  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() override;
  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. Font getTextButtonFont (TextButton&, int buttonHeight) override;
  85. void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour,
  86. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  87. void drawToggleButton (Graphics&, ToggleButton&,
  88. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  89. void drawTickBox (Graphics&, Component&,
  90. float x, float y, float w, float h,
  91. bool ticked, bool isEnabled,
  92. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  93. void changeToggleButtonWidthToFitText (ToggleButton&) override;
  94. //==============================================================================
  95. AlertWindow* createAlertWindow (const String& title, const String& message,
  96. const String& button1,
  97. const String& button2,
  98. const String& button3,
  99. MessageBoxIconType iconType,
  100. int numButtons, Component* associatedComponent) override;
  101. void drawAlertBox (Graphics&, AlertWindow&, const Rectangle<int>& textArea, TextLayout&) override;
  102. int getAlertWindowButtonHeight() override;
  103. Font getAlertWindowTitleFont() override;
  104. Font getAlertWindowMessageFont() override;
  105. Font getAlertWindowFont() override;
  106. //==============================================================================
  107. void drawProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String& textToShow) override;
  108. bool isProgressBarOpaque (ProgressBar&) override { return false; }
  109. //==============================================================================
  110. int getDefaultScrollbarWidth() override;
  111. void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height, bool isScrollbarVertical,
  112. int thumbStartPosition, int thumbSize, bool isMouseOver, bool isMouseDown) override;
  113. //==============================================================================
  114. Path getTickShape (float height) override;
  115. Path getCrossShape (float height) override;
  116. //==============================================================================
  117. void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) override;
  118. void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) override;
  119. //==============================================================================
  120. Button* createFileBrowserGoUpButton() override;
  121. void layoutFileBrowserComponent (FileBrowserComponent&,
  122. DirectoryContentsDisplayComponent*,
  123. FilePreviewComponent*,
  124. ComboBox* currentPathBox,
  125. TextEditor* filenameBox,
  126. Button* goUpButton) override;
  127. void drawFileBrowserRow (Graphics&, int width, int height,
  128. const File& file, const String& filename, Image* icon,
  129. const String& fileSizeDescription, const String& fileTimeDescription,
  130. bool isDirectory, bool isItemSelected, int itemIndex,
  131. DirectoryContentsDisplayComponent&) override;
  132. //==============================================================================
  133. void drawPopupMenuItem (Graphics&, const Rectangle<int>& area,
  134. bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu,
  135. const String& text, const String& shortcutKeyText,
  136. const Drawable* icon, const Colour* textColour) override;
  137. void getIdealPopupMenuItemSize (const String& text, bool isSeparator, int standardMenuItemHeight,
  138. int& idealWidth, int& idealHeight) override;
  139. void drawMenuBarBackground (Graphics&, int width, int height, bool isMouseOverBar, MenuBarComponent&) override;
  140. void drawMenuBarItem (Graphics&, int width, int height,
  141. int itemIndex, const String& itemText,
  142. bool isMouseOverItem, bool isMenuOpen, bool isMouseOverBar,
  143. MenuBarComponent&) override;
  144. //==============================================================================
  145. void drawComboBox (Graphics&, int width, int height, bool isButtonDown,
  146. int buttonX, int buttonY, int buttonW, int buttonH,
  147. ComboBox&) override;
  148. Font getComboBoxFont (ComboBox&) override;
  149. void positionComboBoxText (ComboBox&, Label&) override;
  150. //==============================================================================
  151. int getSliderThumbRadius (Slider&) override;
  152. void drawLinearSlider (Graphics&, int x, int y, int width, int height,
  153. float sliderPos, float minSliderPos, float maxSliderPos,
  154. const Slider::SliderStyle, Slider&) override;
  155. void drawRotarySlider (Graphics&, int x, int y, int width, int height,
  156. float sliderPosProportional, float rotaryStartAngle,
  157. float rotaryEndAngle, Slider&) override;
  158. void drawPointer (Graphics&, float x, float y, float diameter,
  159. const Colour&, int direction) noexcept;
  160. Label* createSliderTextBox (Slider&) override;
  161. //==============================================================================
  162. void drawTooltip (Graphics&, const String& text, int width, int height) override;
  163. //==============================================================================
  164. void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area,
  165. bool isMouseOver, bool isMouseDown,
  166. ConcertinaPanel&, Component& panel) override;
  167. //==============================================================================
  168. void drawLevelMeter (Graphics&, int, int, float) override;
  169. //==============================================================================
  170. void paintToolbarBackground (Graphics&, int width, int height, Toolbar&) override;
  171. void paintToolbarButtonLabel (Graphics&, int x, int y, int width, int height,
  172. const String& text, ToolbarItemComponent&) override;
  173. //==============================================================================
  174. void drawPropertyPanelSectionHeader (Graphics&, const String& name, bool isOpen, int width, int height) override;
  175. void drawPropertyComponentBackground (Graphics&, int width, int height, PropertyComponent&) override;
  176. void drawPropertyComponentLabel (Graphics&, int width, int height, PropertyComponent&) override;
  177. Rectangle<int> getPropertyComponentContentPosition (PropertyComponent&) override;
  178. //==============================================================================
  179. void drawCallOutBoxBackground (CallOutBox&, Graphics&, const Path&, Image&) override;
  180. //==============================================================================
  181. void drawStretchableLayoutResizerBar (Graphics&, int, int, bool, bool, bool) override;
  182. private:
  183. //==============================================================================
  184. void drawLinearProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String&);
  185. void drawCircularProgressBar (Graphics&, ProgressBar&, const String&);
  186. int getPropertyComponentIndent (PropertyComponent&);
  187. //==============================================================================
  188. void initialiseColours();
  189. ColourScheme currentColourScheme;
  190. //==============================================================================
  191. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V4)
  192. };
  193. } // namespace juce