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.h 11KB

7 years ago
7 years ago
7 years ago
7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. /** This class is used to hold a few look and feel base classes which are associated
  23. with classes that may not be present because they're from modules other than
  24. juce_gui_basics.
  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() {}
  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() {}
  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() {}
  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. */
  58. class JUCE_API LookAndFeel : public ScrollBar::LookAndFeelMethods,
  59. public Button::LookAndFeelMethods,
  60. public ImageButton::LookAndFeelMethods,
  61. public TextEditor::LookAndFeelMethods,
  62. public FileBrowserComponent::LookAndFeelMethods,
  63. public TreeView::LookAndFeelMethods,
  64. public BubbleComponent::LookAndFeelMethods,
  65. public AlertWindow::LookAndFeelMethods,
  66. public PopupMenu::LookAndFeelMethods,
  67. public ComboBox::LookAndFeelMethods,
  68. public Label::LookAndFeelMethods,
  69. public Slider::LookAndFeelMethods,
  70. public ResizableWindow::LookAndFeelMethods,
  71. public DocumentWindow::LookAndFeelMethods,
  72. public TooltipWindow::LookAndFeelMethods,
  73. public TabbedButtonBar::LookAndFeelMethods,
  74. public PropertyComponent::LookAndFeelMethods,
  75. public FilenameComponent::LookAndFeelMethods,
  76. public GroupComponent::LookAndFeelMethods,
  77. public TableHeaderComponent::LookAndFeelMethods,
  78. public CallOutBox::LookAndFeelMethods,
  79. public Toolbar::LookAndFeelMethods,
  80. public ConcertinaPanel::LookAndFeelMethods,
  81. public ProgressBar::LookAndFeelMethods,
  82. public StretchableLayoutResizerBar::LookAndFeelMethods,
  83. public ExtraLookAndFeelBaseClasses::KeyMappingEditorComponentMethods,
  84. public ExtraLookAndFeelBaseClasses::AudioDeviceSelectorComponentMethods,
  85. public ExtraLookAndFeelBaseClasses::LassoComponentMethods
  86. {
  87. public:
  88. //==============================================================================
  89. /** Creates the default JUCE look and feel. */
  90. LookAndFeel();
  91. /** Destructor. */
  92. virtual ~LookAndFeel();
  93. //==============================================================================
  94. /** Returns the current default look-and-feel for a component to use when it
  95. hasn't got one explicitly set.
  96. @see setDefaultLookAndFeel
  97. */
  98. static LookAndFeel& getDefaultLookAndFeel() noexcept;
  99. /** Changes the default look-and-feel.
  100. @param newDefaultLookAndFeel the new look-and-feel object to use - if this is
  101. set to null, it will revert to using the default one. The
  102. object passed-in must be deleted by the caller when
  103. it's no longer needed.
  104. @see getDefaultLookAndFeel
  105. */
  106. static void setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel) noexcept;
  107. //==============================================================================
  108. /** Looks for a colour that has been registered with the given colour ID number.
  109. If a colour has been set for this ID number using setColour(), then it is
  110. returned. If none has been set, it will just return Colours::black.
  111. The colour IDs for various purposes are stored as enums in the components that
  112. they are relevant to - for an example, see Slider::ColourIds,
  113. Label::ColourIds, TextEditor::ColourIds, TreeView::ColourIds, etc.
  114. If you're looking up a colour for use in drawing a component, it's usually
  115. best not to call this directly, but to use the Component::findColour() method
  116. instead. That will first check whether a suitable colour has been registered
  117. directly with the component, and will fall-back on calling the component's
  118. LookAndFeel's findColour() method if none is found.
  119. @see setColour, Component::findColour, Component::setColour
  120. */
  121. Colour findColour (int colourId) const noexcept;
  122. /** Registers a colour to be used for a particular purpose.
  123. For more details, see the comments for findColour().
  124. @see findColour, Component::findColour, Component::setColour
  125. */
  126. void setColour (int colourId, Colour colour) noexcept;
  127. /** Returns true if the specified colour ID has been explicitly set using the
  128. setColour() method.
  129. */
  130. bool isColourSpecified (int colourId) const noexcept;
  131. //==============================================================================
  132. /** Returns the typeface that should be used for a given font.
  133. The default implementation just does what you'd expect it to, but you can override
  134. this if you want to intercept fonts and use your own custom typeface object.
  135. */
  136. virtual Typeface::Ptr getTypefaceForFont (const Font&);
  137. /** Allows you to change the default sans-serif font.
  138. If you need to supply your own Typeface object for any of the default fonts, rather
  139. than just supplying the name (e.g. if you want to use an embedded font), then
  140. you should instead override getTypefaceForFont() to create and return the typeface.
  141. */
  142. void setDefaultSansSerifTypefaceName (const String& newName);
  143. //==============================================================================
  144. /** Override this to get the chance to swap a component's mouse cursor for a
  145. customised one.
  146. */
  147. virtual MouseCursor getMouseCursorFor (Component&);
  148. //==============================================================================
  149. /** Creates a new graphics context object. */
  150. virtual LowLevelGraphicsContext* createGraphicsContext (const Image& imageToRenderOn,
  151. const Point<int>& origin,
  152. const RectangleList<int>& initialClip);
  153. void setUsingNativeAlertWindows (bool shouldUseNativeAlerts);
  154. bool isUsingNativeAlertWindows();
  155. //==============================================================================
  156. /** Draws a small image that spins to indicate that something's happening.
  157. This method should use the current time to animate itself, so just keep
  158. repainting it every so often.
  159. */
  160. virtual void drawSpinningWaitAnimation (Graphics&, const Colour& colour,
  161. int x, int y, int w, int h) = 0;
  162. //==============================================================================
  163. /** Returns a tick shape for use in yes/no boxes, etc. */
  164. virtual Path getTickShape (float height) = 0;
  165. /** Returns a cross shape for use in yes/no boxes, etc. */
  166. virtual Path getCrossShape (float height) = 0;
  167. //==============================================================================
  168. virtual DropShadower* createDropShadowerForComponent (Component*) = 0;
  169. //==============================================================================
  170. /** Plays the system's default 'beep' noise, to alert the user about something very important. */
  171. virtual void playAlertSound();
  172. private:
  173. //==============================================================================
  174. struct ColourSetting
  175. {
  176. int colourID;
  177. Colour colour;
  178. bool operator< (const ColourSetting& other) const noexcept { return colourID < other.colourID; }
  179. bool operator== (const ColourSetting& other) const noexcept { return colourID == other.colourID; }
  180. };
  181. SortedSet<ColourSetting> colours;
  182. String defaultSans, defaultSerif, defaultFixed;
  183. bool useNativeAlertWindows = false;
  184. JUCE_DECLARE_WEAK_REFERENCEABLE (LookAndFeel)
  185. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel)
  186. };
  187. } // namespace juce