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_V2.h 19KB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software 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. #ifndef JUCE_LOOKANDFEEL_V2_H_INCLUDED
  18. #define JUCE_LOOKANDFEEL_V2_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. This LookAndFeel subclass implements the juce style from around 2008-12.
  22. @see LookAndFeel, LookAndFeel_V1, LookAndFeel_V3
  23. */
  24. class JUCE_API LookAndFeel_V2 : public LookAndFeel
  25. {
  26. public:
  27. LookAndFeel_V2();
  28. ~LookAndFeel_V2();
  29. //==============================================================================
  30. void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour,
  31. bool isMouseOverButton, bool isButtonDown) override;
  32. Font getTextButtonFont (TextButton&, int buttonHeight) override;
  33. void drawButtonText (Graphics&, TextButton&, bool isMouseOverButton, bool isButtonDown) override;
  34. int getTextButtonWidthToFitText (TextButton&, int buttonHeight) override;
  35. void drawToggleButton (Graphics&, ToggleButton&, bool isMouseOverButton, bool isButtonDown) override;
  36. void changeToggleButtonWidthToFitText (ToggleButton&) override;
  37. void drawTickBox (Graphics&, Component&,
  38. float x, float y, float w, float h,
  39. bool ticked, bool isEnabled, bool isMouseOverButton, bool isButtonDown) override;
  40. void drawDrawableButton (Graphics&, DrawableButton&, bool isMouseOverButton, bool isButtonDown) override;
  41. //==============================================================================
  42. AlertWindow* createAlertWindow (const String& title, const String& message,
  43. const String& button1,
  44. const String& button2,
  45. const String& button3,
  46. AlertWindow::AlertIconType iconType,
  47. int numButtons, Component* associatedComponent) override;
  48. void drawAlertBox (Graphics&, AlertWindow&, const Rectangle<int>& textArea, TextLayout&) override;
  49. int getAlertBoxWindowFlags() override;
  50. int getAlertWindowButtonHeight() override;
  51. Font getAlertWindowMessageFont() override;
  52. Font getAlertWindowFont() override;
  53. //==============================================================================
  54. void drawProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String& textToShow) override;
  55. void drawSpinningWaitAnimation (Graphics&, const Colour& colour, int x, int y, int w, int h) override;
  56. //==============================================================================
  57. bool areScrollbarButtonsVisible() override;
  58. void drawScrollbarButton (Graphics&, ScrollBar&, int width, int height, int buttonDirection,
  59. bool isScrollbarVertical, bool isMouseOverButton, bool isButtonDown) override;
  60. void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height,
  61. bool isScrollbarVertical, int thumbStartPosition, int thumbSize,
  62. bool isMouseOver, bool isMouseDown) override;
  63. ImageEffectFilter* getScrollbarEffect() override;
  64. int getMinimumScrollbarThumbSize (ScrollBar&) override;
  65. int getDefaultScrollbarWidth() override;
  66. int getScrollbarButtonSize (ScrollBar&) override;
  67. //==============================================================================
  68. Path getTickShape (float height) override;
  69. Path getCrossShape (float height) override;
  70. //==============================================================================
  71. void drawTreeviewPlusMinusBox (Graphics&, const Rectangle<float>& area,
  72. Colour backgroundColour, bool isOpen, bool isMouseOver) override;
  73. bool areLinesDrawnForTreeView (TreeView&) override;
  74. int getTreeViewIndentSize (TreeView&) override;
  75. //==============================================================================
  76. void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) override;
  77. void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) override;
  78. CaretComponent* createCaretComponent (Component* keyFocusOwner) override;
  79. //==============================================================================
  80. const Drawable* getDefaultFolderImage() override;
  81. const Drawable* getDefaultDocumentFileImage() override;
  82. AttributedString createFileChooserHeaderText (const String& title, const String& instructions) override;
  83. void drawFileBrowserRow (Graphics&, int width, int height,
  84. const String& filename, Image* icon,
  85. const String& fileSizeDescription, const String& fileTimeDescription,
  86. bool isDirectory, bool isItemSelected, int itemIndex,
  87. DirectoryContentsDisplayComponent&) override;
  88. Button* createFileBrowserGoUpButton() override;
  89. void layoutFileBrowserComponent (FileBrowserComponent&,
  90. DirectoryContentsDisplayComponent*,
  91. FilePreviewComponent*,
  92. ComboBox* currentPathBox,
  93. TextEditor* filenameBox,
  94. Button* goUpButton) override;
  95. //==============================================================================
  96. void drawBubble (Graphics&, BubbleComponent&, const Point<float>& tip, const Rectangle<float>& body) override;
  97. void drawLasso (Graphics&, Component&) override;
  98. //==============================================================================
  99. void drawPopupMenuBackground (Graphics&, int width, int height) override;
  100. void drawPopupMenuItem (Graphics&, const Rectangle<int>& area,
  101. bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu,
  102. const String& text, const String& shortcutKeyText,
  103. const Drawable* icon, const Colour* textColour) override;
  104. void drawPopupMenuSectionHeader (Graphics&, const Rectangle<int>& area,
  105. const String& sectionName) override;
  106. Font getPopupMenuFont() override;
  107. void drawPopupMenuUpDownArrow (Graphics&, int width, int height, bool isScrollUpArrow) override;
  108. void getIdealPopupMenuItemSize (const String& text, bool isSeparator, int standardMenuItemHeight,
  109. int& idealWidth, int& idealHeight) override;
  110. int getMenuWindowFlags() override;
  111. void drawMenuBarBackground (Graphics&, int width, int height, bool isMouseOverBar, MenuBarComponent&) override;
  112. int getMenuBarItemWidth (MenuBarComponent&, int itemIndex, const String& itemText) override;
  113. Font getMenuBarFont (MenuBarComponent&, int itemIndex, const String& itemText) override;
  114. int getDefaultMenuBarHeight() override;
  115. void drawMenuBarItem (Graphics&, int width, int height,
  116. int itemIndex, const String& itemText,
  117. bool isMouseOverItem, bool isMenuOpen, bool isMouseOverBar,
  118. MenuBarComponent&) override;
  119. //==============================================================================
  120. void drawComboBox (Graphics&, int width, int height, bool isButtonDown,
  121. int buttonX, int buttonY, int buttonW, int buttonH,
  122. ComboBox&) override;
  123. Font getComboBoxFont (ComboBox&) override;
  124. Label* createComboBoxTextBox (ComboBox&) override;
  125. void positionComboBoxText (ComboBox&, Label&) override;
  126. //==============================================================================
  127. void drawLabel (Graphics&, Label&) override;
  128. Font getLabelFont (Label&) override;
  129. //==============================================================================
  130. void drawLinearSlider (Graphics&, int x, int y, int width, int height,
  131. float sliderPos, float minSliderPos, float maxSliderPos,
  132. const Slider::SliderStyle, Slider&) override;
  133. void drawLinearSliderBackground (Graphics&, int x, int y, int width, int height,
  134. float sliderPos, float minSliderPos, float maxSliderPos,
  135. const Slider::SliderStyle, Slider&) override;
  136. void drawLinearSliderThumb (Graphics&, int x, int y, int width, int height,
  137. float sliderPos, float minSliderPos, float maxSliderPos,
  138. const Slider::SliderStyle, Slider&) override;
  139. void drawRotarySlider (Graphics&, int x, int y, int width, int height,
  140. float sliderPosProportional, float rotaryStartAngle, float rotaryEndAngle,
  141. Slider&) override;
  142. int getSliderThumbRadius (Slider&) override;
  143. Button* createSliderButton (Slider&, bool isIncrement) override;
  144. Label* createSliderTextBox (Slider&) override;
  145. ImageEffectFilter* getSliderEffect (Slider&) override;
  146. Font getSliderPopupFont (Slider&) override;
  147. int getSliderPopupPlacement (Slider&) override;
  148. //==============================================================================
  149. void getTooltipSize (const String& tipText, int& width, int& height) override;
  150. void drawTooltip (Graphics&, const String& text, int width, int height) override;
  151. //==============================================================================
  152. Button* createFilenameComponentBrowseButton (const String& text) override;
  153. void layoutFilenameComponent (FilenameComponent&, ComboBox* filenameBox, Button* browseButton) override;
  154. //==============================================================================
  155. void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area,
  156. bool isMouseOver, bool isMouseDown,
  157. ConcertinaPanel&, Component& panel) override;
  158. //==============================================================================
  159. void drawCornerResizer (Graphics&, int w, int h, bool isMouseOver, bool isMouseDragging) override;
  160. void drawResizableFrame (Graphics&, int w, int h, const BorderSize<int>&) override;
  161. //==============================================================================
  162. void fillResizableWindowBackground (Graphics&, int w, int h, const BorderSize<int>&, ResizableWindow&) override;
  163. void drawResizableWindowBorder (Graphics&, int w, int h, const BorderSize<int>& border, ResizableWindow&) override;
  164. //==============================================================================
  165. void drawDocumentWindowTitleBar (DocumentWindow&, Graphics&, int w, int h,
  166. int titleSpaceX, int titleSpaceW,
  167. const Image* icon, bool drawTitleTextOnLeft) override;
  168. Button* createDocumentWindowButton (int buttonType) override;
  169. void positionDocumentWindowButtons (DocumentWindow&,
  170. int titleBarX, int titleBarY, int titleBarW, int titleBarH,
  171. Button* minimiseButton,
  172. Button* maximiseButton,
  173. Button* closeButton,
  174. bool positionTitleBarButtonsOnLeft) override;
  175. //==============================================================================
  176. DropShadower* createDropShadowerForComponent (Component*) override;
  177. //==============================================================================
  178. void drawStretchableLayoutResizerBar (Graphics&, int w, int h, bool isVerticalBar,
  179. bool isMouseOver, bool isMouseDragging) override;
  180. //==============================================================================
  181. void drawGroupComponentOutline (Graphics&, int w, int h, const String& text,
  182. const Justification&, GroupComponent&) override;
  183. //==============================================================================
  184. int getTabButtonSpaceAroundImage() override;
  185. int getTabButtonOverlap (int tabDepth) override;
  186. int getTabButtonBestWidth (TabBarButton&, int tabDepth) override;
  187. Rectangle<int> getTabButtonExtraComponentBounds (const TabBarButton&, Rectangle<int>& textArea, Component& extraComp) override;
  188. void drawTabButton (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) override;
  189. void drawTabButtonText (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) override;
  190. void drawTabbedButtonBarBackground (TabbedButtonBar&, Graphics&) override;
  191. void drawTabAreaBehindFrontButton (TabbedButtonBar&, Graphics&, int w, int h) override;
  192. void createTabButtonShape (TabBarButton&, Path&, bool isMouseOver, bool isMouseDown) override;
  193. void fillTabButtonShape (TabBarButton&, Graphics&, const Path&, bool isMouseOver, bool isMouseDown) override;
  194. Button* createTabBarExtrasButton() override;
  195. //==============================================================================
  196. void drawImageButton (Graphics&, Image*,
  197. int imageX, int imageY, int imageW, int imageH,
  198. const Colour& overlayColour, float imageOpacity, ImageButton&) override;
  199. //==============================================================================
  200. void drawTableHeaderBackground (Graphics&, TableHeaderComponent&) override;
  201. void drawTableHeaderColumn (Graphics&, const String& columnName, int columnId,
  202. int width, int height, bool isMouseOver, bool isMouseDown,
  203. int columnFlags) override;
  204. //==============================================================================
  205. void paintToolbarBackground (Graphics&, int width, int height, Toolbar&) override;
  206. Button* createToolbarMissingItemsButton (Toolbar&) override;
  207. void paintToolbarButtonBackground (Graphics&, int width, int height,
  208. bool isMouseOver, bool isMouseDown,
  209. ToolbarItemComponent&) override;
  210. void paintToolbarButtonLabel (Graphics&, int x, int y, int width, int height,
  211. const String& text, ToolbarItemComponent&) override;
  212. //==============================================================================
  213. void drawPropertyPanelSectionHeader (Graphics&, const String& name, bool isOpen, int width, int height) override;
  214. void drawPropertyComponentBackground (Graphics&, int width, int height, PropertyComponent&) override;
  215. void drawPropertyComponentLabel (Graphics&, int width, int height, PropertyComponent&) override;
  216. Rectangle<int> getPropertyComponentContentPosition (PropertyComponent&) override;
  217. //==============================================================================
  218. void drawCallOutBoxBackground (CallOutBox&, Graphics&, const Path& path, Image& cachedImage) override;
  219. int getCallOutBoxBorderSize (const CallOutBox&) override;
  220. //==============================================================================
  221. void drawLevelMeter (Graphics&, int width, int height, float level) override;
  222. void drawKeymapChangeButton (Graphics&, int width, int height, Button&, const String& keyDescription) override;
  223. //==============================================================================
  224. /** Draws a 3D raised (or indented) bevel using two colours.
  225. The bevel is drawn inside the given rectangle, and greater bevel thicknesses
  226. extend inwards.
  227. The top-left colour is used for the top- and left-hand edges of the
  228. bevel; the bottom-right colour is used for the bottom- and right-hand
  229. edges.
  230. If useGradient is true, then the bevel fades out to make it look more curved
  231. and less angular. If sharpEdgeOnOutside is true, the outside of the bevel is
  232. sharp, and it fades towards the centre; if sharpEdgeOnOutside is false, then
  233. the centre edges are sharp and it fades towards the outside.
  234. */
  235. static void drawBevel (Graphics&,
  236. int x, int y, int width, int height,
  237. int bevelThickness,
  238. const Colour& topLeftColour = Colours::white,
  239. const Colour& bottomRightColour = Colours::black,
  240. bool useGradient = true,
  241. bool sharpEdgeOnOutside = true);
  242. /** Utility function to draw a shiny, glassy circle (for round LED-type buttons). */
  243. static void drawGlassSphere (Graphics&, float x, float y, float diameter,
  244. const Colour&, float outlineThickness) noexcept;
  245. static void drawGlassPointer (Graphics&, float x, float y, float diameter,
  246. const Colour&, float outlineThickness, int direction) noexcept;
  247. /** Utility function to draw a shiny, glassy oblong (for text buttons). */
  248. static void drawGlassLozenge (Graphics&,
  249. float x, float y, float width, float height,
  250. const Colour&, float outlineThickness, float cornerSize,
  251. bool flatOnLeft, bool flatOnRight, bool flatOnTop, bool flatOnBottom) noexcept;
  252. private:
  253. //==============================================================================
  254. ScopedPointer<Drawable> folderImage, documentImage;
  255. void drawShinyButtonShape (Graphics&,
  256. float x, float y, float w, float h, float maxCornerSize,
  257. const Colour&, float strokeWidth,
  258. bool flatOnLeft, bool flatOnRight, bool flatOnTop, bool flatOnBottom) noexcept;
  259. class GlassWindowButton;
  260. class SliderLabelComp;
  261. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V2)
  262. };
  263. #endif // JUCE_LOOKANDFEEL_V2_H_INCLUDED