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.

258 lines
12KB

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