VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_gui_basics / lookandfeel / juce_LookAndFeel_V4.h
blobf2072f19827367d6b941cc3be28218c3fd3db6c7
1 /*
2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
23 ==============================================================================
26 namespace juce
29 //==============================================================================
30 /**
31 The latest JUCE look-and-feel style, as introduced in 2017.
32 @see LookAndFeel, LookAndFeel_V1, LookAndFeel_V2, LookAndFeel_V3
34 @tags{GUI}
36 class JUCE_API LookAndFeel_V4 : public LookAndFeel_V3
38 public:
39 /**
40 A struct containing the set of colours to apply to the GUI
42 class ColourScheme
44 public:
45 /** The standard set of colours to use. */
46 enum UIColour
48 windowBackground = 0,
49 widgetBackground,
50 menuBackground,
51 outline,
52 defaultText,
53 defaultFill,
54 highlightedText,
55 highlightedFill,
56 menuText,
58 numColours
61 template <typename... ItemColours>
62 ColourScheme (ItemColours... coloursToUse)
64 static_assert (sizeof... (coloursToUse) == numColours, "Must supply one colour for each UIColour item");
65 const Colour c[] = { Colour (coloursToUse)... };
67 for (int i = 0; i < numColours; ++i)
68 palette[i] = c[i];
71 ColourScheme (const ColourScheme&) = default;
72 ColourScheme& operator= (const ColourScheme&) = default;
74 /** Returns a colour from the scheme */
75 Colour getUIColour (UIColour colourToGet) const noexcept;
77 /** Sets a scheme colour. */
78 void setUIColour (UIColour colourToSet, Colour newColour) noexcept;
80 /** Returns true if two ColourPalette objects contain the same colours. */
81 bool operator== (const ColourScheme&) const noexcept;
82 /** Returns false if two ColourPalette objects contain the same colours. */
83 bool operator!= (const ColourScheme&) const noexcept;
85 private:
86 Colour palette[numColours];
89 //==============================================================================
90 /** Creates a LookAndFeel_V4 object with a default colour scheme. */
91 LookAndFeel_V4();
93 /** Creates a LookAndFeel_V4 object with a given colour scheme. */
94 LookAndFeel_V4 (ColourScheme);
96 /** Destructor. */
97 ~LookAndFeel_V4() override;
99 //==============================================================================
100 void setColourScheme (ColourScheme);
101 ColourScheme& getCurrentColourScheme() noexcept { return currentColourScheme; }
103 static ColourScheme getDarkColourScheme();
104 static ColourScheme getMidnightColourScheme();
105 static ColourScheme getGreyColourScheme();
106 static ColourScheme getLightColourScheme();
108 //==============================================================================
109 Button* createDocumentWindowButton (int) override;
110 void positionDocumentWindowButtons (DocumentWindow&, int, int, int, int, Button*, Button*, Button*, bool) override;
111 void drawDocumentWindowTitleBar (DocumentWindow&, Graphics&, int, int, int, int, const Image*, bool) override;
113 //==============================================================================
114 Font getTextButtonFont (TextButton&, int buttonHeight) override;
116 void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour,
117 bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
119 void drawToggleButton (Graphics&, ToggleButton&,
120 bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
121 void drawTickBox (Graphics&, Component&,
122 float x, float y, float w, float h,
123 bool ticked, bool isEnabled,
124 bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
126 void changeToggleButtonWidthToFitText (ToggleButton&) override;
128 //==============================================================================
129 AlertWindow* createAlertWindow (const String& title, const String& message,
130 const String& button1,
131 const String& button2,
132 const String& button3,
133 MessageBoxIconType iconType,
134 int numButtons, Component* associatedComponent) override;
135 void drawAlertBox (Graphics&, AlertWindow&, const Rectangle<int>& textArea, TextLayout&) override;
137 int getAlertWindowButtonHeight() override;
138 Font getAlertWindowTitleFont() override;
139 Font getAlertWindowMessageFont() override;
140 Font getAlertWindowFont() override;
142 //==============================================================================
143 void drawProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String& textToShow) override;
144 bool isProgressBarOpaque (ProgressBar&) override { return false; }
146 //==============================================================================
147 int getDefaultScrollbarWidth() override;
148 void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height, bool isScrollbarVertical,
149 int thumbStartPosition, int thumbSize, bool isMouseOver, bool isMouseDown) override;
151 //==============================================================================
152 Path getTickShape (float height) override;
153 Path getCrossShape (float height) override;
155 //==============================================================================
156 void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) override;
157 void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) override;
159 //==============================================================================
160 Button* createFileBrowserGoUpButton() override;
162 void layoutFileBrowserComponent (FileBrowserComponent&,
163 DirectoryContentsDisplayComponent*,
164 FilePreviewComponent*,
165 ComboBox* currentPathBox,
166 TextEditor* filenameBox,
167 Button* goUpButton) override;
169 void drawFileBrowserRow (Graphics&, int width, int height,
170 const File& file, const String& filename, Image* icon,
171 const String& fileSizeDescription, const String& fileTimeDescription,
172 bool isDirectory, bool isItemSelected, int itemIndex,
173 DirectoryContentsDisplayComponent&) override;
175 //==============================================================================
176 void drawPopupMenuItem (Graphics&, const Rectangle<int>& area,
177 bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu,
178 const String& text, const String& shortcutKeyText,
179 const Drawable* icon, const Colour* textColour) override;
181 void getIdealPopupMenuItemSize (const String& text, bool isSeparator, int standardMenuItemHeight,
182 int& idealWidth, int& idealHeight) override;
184 void drawMenuBarBackground (Graphics&, int width, int height, bool isMouseOverBar, MenuBarComponent&) override;
186 void drawMenuBarItem (Graphics&, int width, int height,
187 int itemIndex, const String& itemText,
188 bool isMouseOverItem, bool isMenuOpen, bool isMouseOverBar,
189 MenuBarComponent&) override;
191 //==============================================================================
192 void drawComboBox (Graphics&, int width, int height, bool isButtonDown,
193 int buttonX, int buttonY, int buttonW, int buttonH,
194 ComboBox&) override;
195 Font getComboBoxFont (ComboBox&) override;
196 void positionComboBoxText (ComboBox&, Label&) override;
198 //==============================================================================
199 int getSliderThumbRadius (Slider&) override;
201 void drawLinearSlider (Graphics&, int x, int y, int width, int height,
202 float sliderPos, float minSliderPos, float maxSliderPos,
203 const Slider::SliderStyle, Slider&) override;
205 void drawRotarySlider (Graphics&, int x, int y, int width, int height,
206 float sliderPosProportional, float rotaryStartAngle,
207 float rotaryEndAngle, Slider&) override;
209 void drawPointer (Graphics&, float x, float y, float diameter,
210 const Colour&, int direction) noexcept;
212 Label* createSliderTextBox (Slider&) override;
214 //==============================================================================
215 void drawTooltip (Graphics&, const String& text, int width, int height) override;
217 //==============================================================================
218 void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area,
219 bool isMouseOver, bool isMouseDown,
220 ConcertinaPanel&, Component& panel) override;
222 //==============================================================================
223 void drawLevelMeter (Graphics&, int, int, float) override;
225 //==============================================================================
226 void paintToolbarBackground (Graphics&, int width, int height, Toolbar&) override;
228 void paintToolbarButtonLabel (Graphics&, int x, int y, int width, int height,
229 const String& text, ToolbarItemComponent&) override;
231 //==============================================================================
232 void drawPropertyPanelSectionHeader (Graphics&, const String& name, bool isOpen, int width, int height) override;
233 void drawPropertyComponentBackground (Graphics&, int width, int height, PropertyComponent&) override;
234 void drawPropertyComponentLabel (Graphics&, int width, int height, PropertyComponent&) override;
235 Rectangle<int> getPropertyComponentContentPosition (PropertyComponent&) override;
237 //==============================================================================
238 void drawCallOutBoxBackground (CallOutBox&, Graphics&, const Path&, Image&) override;
240 //==============================================================================
241 void drawStretchableLayoutResizerBar (Graphics&, int, int, bool, bool, bool) override;
243 private:
244 //==============================================================================
245 void drawLinearProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String&);
246 void drawCircularProgressBar (Graphics&, ProgressBar&, const String&);
248 int getPropertyComponentIndent (PropertyComponent&);
250 //==============================================================================
251 void initialiseColours();
252 ColourScheme currentColourScheme;
254 //==============================================================================
255 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V4)
258 } // namespace juce