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.

247 lines
12KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - 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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-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. /** This class is used to hold a few look and feel base classes which are associated
  22. with classes that may not be present because they're from modules other than
  23. juce_gui_basics.
  24. @tags{GUI}
  25. */
  26. struct JUCE_API ExtraLookAndFeelBaseClasses
  27. {
  28. //==============================================================================
  29. /** This abstract base class is implemented by LookAndFeel classes. */
  30. struct JUCE_API LassoComponentMethods
  31. {
  32. virtual ~LassoComponentMethods() = default;
  33. virtual void drawLasso (Graphics&, Component& lassoComp) = 0;
  34. };
  35. //==============================================================================
  36. /** This abstract base class is implemented by LookAndFeel classes. */
  37. struct JUCE_API KeyMappingEditorComponentMethods
  38. {
  39. virtual ~KeyMappingEditorComponentMethods() = default;
  40. virtual void drawKeymapChangeButton (Graphics&, int width, int height, Button&, const String& keyDescription) = 0;
  41. };
  42. //==============================================================================
  43. /** This abstract base class is implemented by LookAndFeel classes. */
  44. struct JUCE_API AudioDeviceSelectorComponentMethods
  45. {
  46. virtual ~AudioDeviceSelectorComponentMethods() = default;
  47. virtual void drawLevelMeter (Graphics&, int width, int height, float level) = 0;
  48. };
  49. };
  50. //==============================================================================
  51. /**
  52. LookAndFeel objects define the appearance of all the JUCE widgets, and subclasses
  53. can be used to apply different 'skins' to the application.
  54. This class is an abstract base-class - for actual look-and-feels that you can
  55. instantiate, see LookAndFeel_V1, LookAndFeel_V2 and LookAndFeel_V3.
  56. @see LookAndFeel_V1, LookAndFeel_V2, LookAndFeel_V3
  57. @tags{GUI}
  58. */
  59. class JUCE_API LookAndFeel : public ScrollBar::LookAndFeelMethods,
  60. public Button::LookAndFeelMethods,
  61. public ImageButton::LookAndFeelMethods,
  62. public TextEditor::LookAndFeelMethods,
  63. public FileBrowserComponent::LookAndFeelMethods,
  64. public TreeView::LookAndFeelMethods,
  65. public BubbleComponent::LookAndFeelMethods,
  66. public AlertWindow::LookAndFeelMethods,
  67. public PopupMenu::LookAndFeelMethods,
  68. public ComboBox::LookAndFeelMethods,
  69. public Label::LookAndFeelMethods,
  70. public Slider::LookAndFeelMethods,
  71. public ResizableWindow::LookAndFeelMethods,
  72. public DocumentWindow::LookAndFeelMethods,
  73. public TooltipWindow::LookAndFeelMethods,
  74. public TabbedButtonBar::LookAndFeelMethods,
  75. public PropertyComponent::LookAndFeelMethods,
  76. public FilenameComponent::LookAndFeelMethods,
  77. public GroupComponent::LookAndFeelMethods,
  78. public TableHeaderComponent::LookAndFeelMethods,
  79. public CallOutBox::LookAndFeelMethods,
  80. public Toolbar::LookAndFeelMethods,
  81. public ConcertinaPanel::LookAndFeelMethods,
  82. public ProgressBar::LookAndFeelMethods,
  83. public StretchableLayoutResizerBar::LookAndFeelMethods,
  84. public ExtraLookAndFeelBaseClasses::KeyMappingEditorComponentMethods,
  85. public ExtraLookAndFeelBaseClasses::AudioDeviceSelectorComponentMethods,
  86. public ExtraLookAndFeelBaseClasses::LassoComponentMethods,
  87. public SidePanel::LookAndFeelMethods
  88. {
  89. public:
  90. //==============================================================================
  91. /** Creates the default JUCE look and feel. */
  92. LookAndFeel();
  93. /** Destructor. */
  94. ~LookAndFeel() override;
  95. //==============================================================================
  96. /** Returns the current default look-and-feel for a component to use when it
  97. hasn't got one explicitly set.
  98. @see setDefaultLookAndFeel
  99. */
  100. static LookAndFeel& getDefaultLookAndFeel() noexcept;
  101. /** Changes the default look-and-feel.
  102. @param newDefaultLookAndFeel the new look-and-feel object to use - if this is
  103. set to null, it will revert to using the default one. The
  104. object passed-in must be deleted by the caller when
  105. it's no longer needed.
  106. @see getDefaultLookAndFeel
  107. */
  108. static void setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel) noexcept;
  109. //==============================================================================
  110. /** Looks for a colour that has been registered with the given colour ID number.
  111. If a colour has been set for this ID number using setColour(), then it is
  112. returned. If none has been set, it will just return Colours::black.
  113. The colour IDs for various purposes are stored as enums in the components that
  114. they are relevant to - for an example, see Slider::ColourIds,
  115. Label::ColourIds, TextEditor::ColourIds, TreeView::ColourIds, etc.
  116. If you're looking up a colour for use in drawing a component, it's usually
  117. best not to call this directly, but to use the Component::findColour() method
  118. instead. That will first check whether a suitable colour has been registered
  119. directly with the component, and will fall-back on calling the component's
  120. LookAndFeel's findColour() method if none is found.
  121. @see setColour, Component::findColour, Component::setColour
  122. */
  123. Colour findColour (int colourId) const noexcept;
  124. /** Registers a colour to be used for a particular purpose.
  125. For more details, see the comments for findColour().
  126. @see findColour, Component::findColour, Component::setColour
  127. */
  128. void setColour (int colourId, Colour colour) noexcept;
  129. /** Returns true if the specified colour ID has been explicitly set using the
  130. setColour() method.
  131. */
  132. bool isColourSpecified (int colourId) const noexcept;
  133. //==============================================================================
  134. /** Returns the typeface that should be used for a given font.
  135. The default implementation just does what you'd expect it to, but you can override
  136. this if you want to intercept fonts and use your own custom typeface object.
  137. @see setDefaultTypeface
  138. */
  139. virtual Typeface::Ptr getTypefaceForFont (const Font&);
  140. /** Allows you to supply a default typeface that will be returned as the default
  141. sans-serif font.
  142. Instead of a typeface object, you can specify a typeface by name using the
  143. setDefaultSansSerifTypefaceName() method.
  144. You can perform more complex typeface substitutions by overloading
  145. getTypefaceForFont() but this lets you easily set a global typeface.
  146. */
  147. void setDefaultSansSerifTypeface (Typeface::Ptr newDefaultTypeface);
  148. /** Allows you to change the default sans-serif font.
  149. If you need to supply your own Typeface object for any of the default fonts, rather
  150. than just supplying the name (e.g. if you want to use an embedded font), then
  151. you can instead call setDefaultSansSerifTypeface() with an object to use.
  152. */
  153. void setDefaultSansSerifTypefaceName (const String& newName);
  154. //==============================================================================
  155. /** Override this to get the chance to swap a component's mouse cursor for a
  156. customised one.
  157. */
  158. virtual MouseCursor getMouseCursorFor (Component&);
  159. //==============================================================================
  160. /** Creates a new graphics context object. */
  161. virtual std::unique_ptr<LowLevelGraphicsContext> createGraphicsContext (const Image& imageToRenderOn,
  162. Point<int> origin,
  163. const RectangleList<int>& initialClip);
  164. void setUsingNativeAlertWindows (bool shouldUseNativeAlerts);
  165. bool isUsingNativeAlertWindows();
  166. //==============================================================================
  167. /** Draws a small image that spins to indicate that something's happening.
  168. This method should use the current time to animate itself, so just keep
  169. repainting it every so often.
  170. */
  171. virtual void drawSpinningWaitAnimation (Graphics&, const Colour& colour,
  172. int x, int y, int w, int h) = 0;
  173. //==============================================================================
  174. /** Returns a tick shape for use in yes/no boxes, etc. */
  175. virtual Path getTickShape (float height) = 0;
  176. /** Returns a cross shape for use in yes/no boxes, etc. */
  177. virtual Path getCrossShape (float height) = 0;
  178. //==============================================================================
  179. virtual DropShadower* createDropShadowerForComponent (Component*) = 0;
  180. //==============================================================================
  181. /** Plays the system's default 'beep' noise, to alert the user about something very important. */
  182. virtual void playAlertSound();
  183. private:
  184. //==============================================================================
  185. struct ColourSetting
  186. {
  187. int colourID;
  188. Colour colour;
  189. bool operator< (const ColourSetting& other) const noexcept { return colourID < other.colourID; }
  190. bool operator== (const ColourSetting& other) const noexcept { return colourID == other.colourID; }
  191. };
  192. SortedSet<ColourSetting> colours;
  193. String defaultSans, defaultSerif, defaultFixed;
  194. Typeface::Ptr defaultTypeface;
  195. bool useNativeAlertWindows = false;
  196. JUCE_DECLARE_WEAK_REFERENCEABLE (LookAndFeel)
  197. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel)
  198. };
  199. } // namespace juce