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 21KB

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