The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

239 lines
12KB

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