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.

428 lines
23KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - 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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-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. This LookAndFeel subclass implements the juce style from around 2008-12.
  23. @see LookAndFeel, LookAndFeel_V1, LookAndFeel_V3
  24. @tags{GUI}
  25. */
  26. class JUCE_API LookAndFeel_V2 : public LookAndFeel
  27. {
  28. public:
  29. LookAndFeel_V2();
  30. ~LookAndFeel_V2() override;
  31. //==============================================================================
  32. void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour,
  33. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  34. Font getTextButtonFont (TextButton&, int buttonHeight) override;
  35. void drawButtonText (Graphics&, TextButton&,
  36. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  37. int getTextButtonWidthToFitText (TextButton&, int buttonHeight) override;
  38. void drawToggleButton (Graphics&, ToggleButton&,
  39. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  40. void changeToggleButtonWidthToFitText (ToggleButton&) override;
  41. void drawTickBox (Graphics&, Component&,
  42. float x, float y, float w, float h,
  43. bool ticked, bool isEnabled,
  44. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  45. void drawDrawableButton (Graphics&, DrawableButton&,
  46. bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  47. //==============================================================================
  48. AlertWindow* createAlertWindow (const String& title, const String& message,
  49. const String& button1,
  50. const String& button2,
  51. const String& button3,
  52. MessageBoxIconType iconType,
  53. int numButtons, Component* associatedComponent) override;
  54. void drawAlertBox (Graphics&, AlertWindow&, const Rectangle<int>& textArea, TextLayout&) override;
  55. int getAlertBoxWindowFlags() override;
  56. Array<int> getWidthsForTextButtons (AlertWindow&, const Array<TextButton*>&) override;
  57. int getAlertWindowButtonHeight() override;
  58. /** Override this function to supply a custom font for the alert window title.
  59. This default implementation will use a boldened and slightly larger version
  60. of the alert window message font.
  61. @see getAlertWindowMessageFont.
  62. */
  63. Font getAlertWindowTitleFont() override;
  64. /** Override this function to supply a custom font for the alert window message.
  65. This default implementation will use the default font with height set to 15.0f.
  66. @see getAlertWindowTitleFont
  67. */
  68. Font getAlertWindowMessageFont() override;
  69. Font getAlertWindowFont() override;
  70. //==============================================================================
  71. void drawProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String& textToShow) override;
  72. void drawSpinningWaitAnimation (Graphics&, const Colour& colour, int x, int y, int w, int h) override;
  73. bool isProgressBarOpaque (ProgressBar&) override;
  74. //==============================================================================
  75. bool areScrollbarButtonsVisible() override;
  76. void drawScrollbarButton (Graphics&, ScrollBar&, int width, int height, int buttonDirection,
  77. bool isScrollbarVertical, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
  78. void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height,
  79. bool isScrollbarVertical, int thumbStartPosition, int thumbSize,
  80. bool isMouseOver, bool isMouseDown) override;
  81. ImageEffectFilter* getScrollbarEffect() override;
  82. int getMinimumScrollbarThumbSize (ScrollBar&) override;
  83. int getDefaultScrollbarWidth() override;
  84. int getScrollbarButtonSize (ScrollBar&) override;
  85. //==============================================================================
  86. Path getTickShape (float height) override;
  87. Path getCrossShape (float height) override;
  88. //==============================================================================
  89. void drawTreeviewPlusMinusBox (Graphics&, const Rectangle<float>& area,
  90. Colour backgroundColour, bool isOpen, bool isMouseOver) override;
  91. bool areLinesDrawnForTreeView (TreeView&) override;
  92. int getTreeViewIndentSize (TreeView&) override;
  93. //==============================================================================
  94. void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) override;
  95. void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) override;
  96. CaretComponent* createCaretComponent (Component* keyFocusOwner) override;
  97. //==============================================================================
  98. const Drawable* getDefaultFolderImage() override;
  99. const Drawable* getDefaultDocumentFileImage() override;
  100. AttributedString createFileChooserHeaderText (const String& title, const String& instructions) override;
  101. void drawFileBrowserRow (Graphics&, int width, int height,
  102. const File& file, const String& filename, Image* icon,
  103. const String& fileSizeDescription, const String& fileTimeDescription,
  104. bool isDirectory, bool isItemSelected, int itemIndex,
  105. DirectoryContentsDisplayComponent&) override;
  106. Button* createFileBrowserGoUpButton() override;
  107. void layoutFileBrowserComponent (FileBrowserComponent&,
  108. DirectoryContentsDisplayComponent*,
  109. FilePreviewComponent*,
  110. ComboBox* currentPathBox,
  111. TextEditor* filenameBox,
  112. Button* goUpButton) override;
  113. //==============================================================================
  114. void drawBubble (Graphics&, BubbleComponent&, const Point<float>& tip, const Rectangle<float>& body) override;
  115. void drawLasso (Graphics&, Component&) override;
  116. //==============================================================================
  117. void drawPopupMenuBackground (Graphics&, int width, int height) override;
  118. void drawPopupMenuBackgroundWithOptions (Graphics&,
  119. int width,
  120. int height,
  121. const PopupMenu::Options&) override;
  122. void drawPopupMenuItem (Graphics&, const Rectangle<int>& area,
  123. bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu,
  124. const String& text, const String& shortcutKeyText,
  125. const Drawable* icon, const Colour* textColour) override;
  126. void drawPopupMenuItemWithOptions (Graphics&, const Rectangle<int>& area,
  127. bool isHighlighted,
  128. const PopupMenu::Item& item,
  129. const PopupMenu::Options&) override;
  130. void drawPopupMenuSectionHeader (Graphics&, const Rectangle<int>& area,
  131. const String& sectionName) override;
  132. void drawPopupMenuSectionHeaderWithOptions (Graphics&, const Rectangle<int>& area,
  133. const String& sectionName,
  134. const PopupMenu::Options&) override;
  135. Font getPopupMenuFont() override;
  136. void drawPopupMenuUpDownArrow (Graphics&, int width, int height, bool isScrollUpArrow) override;
  137. void drawPopupMenuUpDownArrowWithOptions (Graphics&,
  138. int width, int height,
  139. bool isScrollUpArrow,
  140. const PopupMenu::Options&) override;
  141. void getIdealPopupMenuItemSize (const String& text, bool isSeparator, int standardMenuItemHeight,
  142. int& idealWidth, int& idealHeight) override;
  143. void getIdealPopupMenuItemSizeWithOptions (const String& text,
  144. bool isSeparator,
  145. int standardMenuItemHeight,
  146. int& idealWidth,
  147. int& idealHeight,
  148. const PopupMenu::Options&) override;
  149. int getMenuWindowFlags() override;
  150. void preparePopupMenuWindow (Component&) override;
  151. void drawMenuBarBackground (Graphics&, int width, int height, bool isMouseOverBar, MenuBarComponent&) override;
  152. int getMenuBarItemWidth (MenuBarComponent&, int itemIndex, const String& itemText) override;
  153. Font getMenuBarFont (MenuBarComponent&, int itemIndex, const String& itemText) override;
  154. int getDefaultMenuBarHeight() override;
  155. void drawMenuBarItem (Graphics&, int width, int height,
  156. int itemIndex, const String& itemText,
  157. bool isMouseOverItem, bool isMenuOpen, bool isMouseOverBar,
  158. MenuBarComponent&) override;
  159. Component* getParentComponentForMenuOptions (const PopupMenu::Options& options) override;
  160. bool shouldPopupMenuScaleWithTargetComponent (const PopupMenu::Options& options) override;
  161. int getPopupMenuBorderSize() override;
  162. int getPopupMenuBorderSizeWithOptions (const PopupMenu::Options&) override;
  163. void drawPopupMenuColumnSeparatorWithOptions (Graphics& g,
  164. const Rectangle<int>& bounds,
  165. const PopupMenu::Options&) override;
  166. int getPopupMenuColumnSeparatorWidthWithOptions (const PopupMenu::Options&) override;
  167. //==============================================================================
  168. void drawComboBox (Graphics&, int width, int height, bool isMouseButtonDown,
  169. int buttonX, int buttonY, int buttonW, int buttonH,
  170. ComboBox&) override;
  171. Font getComboBoxFont (ComboBox&) override;
  172. Label* createComboBoxTextBox (ComboBox&) override;
  173. void positionComboBoxText (ComboBox&, Label&) override;
  174. PopupMenu::Options getOptionsForComboBoxPopupMenu (ComboBox&, Label&) override;
  175. void drawComboBoxTextWhenNothingSelected (Graphics&, ComboBox&, Label&) override;
  176. //==============================================================================
  177. void drawLabel (Graphics&, Label&) override;
  178. Font getLabelFont (Label&) override;
  179. BorderSize<int> getLabelBorderSize (Label&) override;
  180. //==============================================================================
  181. void drawLinearSlider (Graphics&, int x, int y, int width, int height,
  182. float sliderPos, float minSliderPos, float maxSliderPos,
  183. const Slider::SliderStyle, Slider&) override;
  184. void drawLinearSliderBackground (Graphics&, int x, int y, int width, int height,
  185. float sliderPos, float minSliderPos, float maxSliderPos,
  186. const Slider::SliderStyle, Slider&) override;
  187. void drawLinearSliderThumb (Graphics&, int x, int y, int width, int height,
  188. float sliderPos, float minSliderPos, float maxSliderPos,
  189. const Slider::SliderStyle, Slider&) override;
  190. void drawRotarySlider (Graphics&, int x, int y, int width, int height,
  191. float sliderPosProportional, float rotaryStartAngle, float rotaryEndAngle,
  192. Slider&) override;
  193. int getSliderThumbRadius (Slider&) override;
  194. Button* createSliderButton (Slider&, bool isIncrement) override;
  195. Label* createSliderTextBox (Slider&) override;
  196. ImageEffectFilter* getSliderEffect (Slider&) override;
  197. Font getSliderPopupFont (Slider&) override;
  198. int getSliderPopupPlacement (Slider&) override;
  199. Slider::SliderLayout getSliderLayout (Slider&) override;
  200. //==============================================================================
  201. Rectangle<int> getTooltipBounds (const String& tipText, Point<int> screenPos, Rectangle<int> parentArea) override;
  202. void drawTooltip (Graphics&, const String& text, int width, int height) override;
  203. //==============================================================================
  204. Button* createFilenameComponentBrowseButton (const String& text) override;
  205. void layoutFilenameComponent (FilenameComponent&, ComboBox* filenameBox, Button* browseButton) override;
  206. //==============================================================================
  207. void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area,
  208. bool isMouseOver, bool isMouseDown,
  209. ConcertinaPanel&, Component& panel) override;
  210. //==============================================================================
  211. void drawCornerResizer (Graphics&, int w, int h, bool isMouseOver, bool isMouseDragging) override;
  212. void drawResizableFrame (Graphics&, int w, int h, const BorderSize<int>&) override;
  213. //==============================================================================
  214. void fillResizableWindowBackground (Graphics&, int w, int h, const BorderSize<int>&, ResizableWindow&) override;
  215. void drawResizableWindowBorder (Graphics&, int w, int h, const BorderSize<int>& border, ResizableWindow&) override;
  216. //==============================================================================
  217. void drawDocumentWindowTitleBar (DocumentWindow&, Graphics&, int w, int h,
  218. int titleSpaceX, int titleSpaceW,
  219. const Image* icon, bool drawTitleTextOnLeft) override;
  220. Button* createDocumentWindowButton (int buttonType) override;
  221. void positionDocumentWindowButtons (DocumentWindow&,
  222. int titleBarX, int titleBarY, int titleBarW, int titleBarH,
  223. Button* minimiseButton,
  224. Button* maximiseButton,
  225. Button* closeButton,
  226. bool positionTitleBarButtonsOnLeft) override;
  227. //==============================================================================
  228. std::unique_ptr<DropShadower> createDropShadowerForComponent (Component&) override;
  229. std::unique_ptr<FocusOutline> createFocusOutlineForComponent (Component&) override;
  230. //==============================================================================
  231. void drawStretchableLayoutResizerBar (Graphics&, int w, int h, bool isVerticalBar,
  232. bool isMouseOver, bool isMouseDragging) override;
  233. //==============================================================================
  234. void drawGroupComponentOutline (Graphics&, int w, int h, const String& text,
  235. const Justification&, GroupComponent&) override;
  236. //==============================================================================
  237. int getTabButtonSpaceAroundImage() override;
  238. int getTabButtonOverlap (int tabDepth) override;
  239. int getTabButtonBestWidth (TabBarButton&, int tabDepth) override;
  240. Rectangle<int> getTabButtonExtraComponentBounds (const TabBarButton&, Rectangle<int>& textArea, Component& extraComp) override;
  241. void drawTabButton (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) override;
  242. Font getTabButtonFont (TabBarButton&, float height) override;
  243. void drawTabButtonText (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) override;
  244. void drawTabbedButtonBarBackground (TabbedButtonBar&, Graphics&) override;
  245. void drawTabAreaBehindFrontButton (TabbedButtonBar&, Graphics&, int w, int h) override;
  246. void createTabButtonShape (TabBarButton&, Path&, bool isMouseOver, bool isMouseDown) override;
  247. void fillTabButtonShape (TabBarButton&, Graphics&, const Path&, bool isMouseOver, bool isMouseDown) override;
  248. Button* createTabBarExtrasButton() override;
  249. //==============================================================================
  250. void drawImageButton (Graphics&, Image*,
  251. int imageX, int imageY, int imageW, int imageH,
  252. const Colour& overlayColour, float imageOpacity, ImageButton&) override;
  253. //==============================================================================
  254. void drawTableHeaderBackground (Graphics&, TableHeaderComponent&) override;
  255. void drawTableHeaderColumn (Graphics&, TableHeaderComponent&, const String& columnName,
  256. int columnId, int width, int height, bool isMouseOver,
  257. bool isMouseDown, int columnFlags) override;
  258. //==============================================================================
  259. void paintToolbarBackground (Graphics&, int width, int height, Toolbar&) override;
  260. Button* createToolbarMissingItemsButton (Toolbar&) override;
  261. void paintToolbarButtonBackground (Graphics&, int width, int height,
  262. bool isMouseOver, bool isMouseDown,
  263. ToolbarItemComponent&) override;
  264. void paintToolbarButtonLabel (Graphics&, int x, int y, int width, int height,
  265. const String& text, ToolbarItemComponent&) override;
  266. //==============================================================================
  267. void drawPropertyPanelSectionHeader (Graphics&, const String& name, bool isOpen, int width, int height) override;
  268. void drawPropertyComponentBackground (Graphics&, int width, int height, PropertyComponent&) override;
  269. void drawPropertyComponentLabel (Graphics&, int width, int height, PropertyComponent&) override;
  270. Rectangle<int> getPropertyComponentContentPosition (PropertyComponent&) override;
  271. int getPropertyPanelSectionHeaderHeight (const String& sectionTitle) override;
  272. //==============================================================================
  273. void drawCallOutBoxBackground (CallOutBox&, Graphics&, const Path& path, Image& cachedImage) override;
  274. int getCallOutBoxBorderSize (const CallOutBox&) override;
  275. float getCallOutBoxCornerSize (const CallOutBox&) override;
  276. //==============================================================================
  277. void drawLevelMeter (Graphics&, int width, int height, float level) override;
  278. void drawKeymapChangeButton (Graphics&, int width, int height, Button&, const String& keyDescription) override;
  279. //==============================================================================
  280. Font getSidePanelTitleFont (SidePanel&) override;
  281. Justification getSidePanelTitleJustification (SidePanel&) override;
  282. Path getSidePanelDismissButtonShape (SidePanel&) override;
  283. //==============================================================================
  284. /** Draws a 3D raised (or indented) bevel using two colours.
  285. The bevel is drawn inside the given rectangle, and greater bevel thicknesses
  286. extend inwards.
  287. The top-left colour is used for the top- and left-hand edges of the
  288. bevel; the bottom-right colour is used for the bottom- and right-hand
  289. edges.
  290. If useGradient is true, then the bevel fades out to make it look more curved
  291. and less angular. If sharpEdgeOnOutside is true, the outside of the bevel is
  292. sharp, and it fades towards the centre; if sharpEdgeOnOutside is false, then
  293. the centre edges are sharp and it fades towards the outside.
  294. */
  295. static void drawBevel (Graphics&,
  296. int x, int y, int width, int height,
  297. int bevelThickness,
  298. const Colour& topLeftColour = Colours::white,
  299. const Colour& bottomRightColour = Colours::black,
  300. bool useGradient = true,
  301. bool sharpEdgeOnOutside = true);
  302. /** Utility function to draw a shiny, glassy circle (for round LED-type buttons). */
  303. static void drawGlassSphere (Graphics&, float x, float y, float diameter,
  304. const Colour&, float outlineThickness) noexcept;
  305. static void drawGlassPointer (Graphics&, float x, float y, float diameter,
  306. const Colour&, float outlineThickness, int direction) noexcept;
  307. /** Utility function to draw a shiny, glassy oblong (for text buttons). */
  308. static void drawGlassLozenge (Graphics&,
  309. float x, float y, float width, float height,
  310. const Colour&, float outlineThickness, float cornerSize,
  311. bool flatOnLeft, bool flatOnRight, bool flatOnTop, bool flatOnBottom) noexcept;
  312. private:
  313. //==============================================================================
  314. std::unique_ptr<Drawable> folderImage, documentImage;
  315. void drawShinyButtonShape (Graphics&,
  316. float x, float y, float w, float h, float maxCornerSize,
  317. const Colour&, float strokeWidth,
  318. bool flatOnLeft, bool flatOnRight, bool flatOnTop, bool flatOnBottom) noexcept;
  319. class GlassWindowButton;
  320. class SliderLabelComp;
  321. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V2)
  322. };
  323. } // namespace juce