JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_Toolbar.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
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.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29class ToolbarItemComponent;
30class ToolbarItemFactory;
31
32
33//==============================================================================
52class JUCE_API Toolbar : public Component,
55{
56public:
57 //==============================================================================
66 Toolbar();
67
72 ~Toolbar() override;
73
74 //==============================================================================
78 void setVertical (bool shouldBeVertical);
79
84 bool isVertical() const noexcept { return vertical; }
85
93 int getThickness() const noexcept;
94
102 int getLength() const noexcept;
103
104 //==============================================================================
107 void clear();
108
122 void addItem (ToolbarItemFactory& factory,
123 int itemId,
124 int insertIndex = -1);
125
127 void removeToolbarItem (int itemIndex);
128
130 ToolbarItemComponent* removeAndReturnItem (int itemIndex);
131
136 int getNumItems() const noexcept;
137
145 int getItemId (int itemIndex) const noexcept;
146
154 ToolbarItemComponent* getItemComponent (int itemIndex) const noexcept;
155
161 void addDefaultItems (ToolbarItemFactory& factoryToUse);
162
163 //==============================================================================
173
177 ToolbarItemStyle getStyle() const noexcept { return toolbarStyle; }
178
182 void setStyle (const ToolbarItemStyle& newStyle);
183
184 //==============================================================================
187 {
188 allowIconsOnlyChoice = 1,
190 allowIconsWithTextChoice = 2,
192 allowTextOnlyChoice = 4,
194 showResetToDefaultsButton = 8,
197 allCustomisationOptionsEnabled = (allowIconsOnlyChoice | allowIconsWithTextChoice | allowTextOnlyChoice | showResetToDefaultsButton)
198 };
199
214 void showCustomisationDialog (ToolbarItemFactory& factory,
215 int optionFlags = allCustomisationOptionsEnabled);
216
225 void setEditingActive (bool editingEnabled);
226
227 //==============================================================================
236 {
237 backgroundColourId = 0x1003200,
239 separatorColourId = 0x1003210,
241 buttonMouseOverBackgroundColourId = 0x1003220,
243 buttonMouseDownBackgroundColourId = 0x1003230,
246 labelTextColourId = 0x1003240,
249 editingModeOutlineColourId = 0x1003250,
252 customisationDialogBackgroundColourId = 0x1003260
253 };
254
255 //==============================================================================
262 String toString() const;
263
271 bool restoreFromString (ToolbarItemFactory& factoryToUse,
272 const String& savedVersion);
273
274 //==============================================================================
276 struct JUCE_API LookAndFeelMethods
277 {
278 virtual ~LookAndFeelMethods() = default;
279
280 virtual void paintToolbarBackground (Graphics&, int width, int height, Toolbar&) = 0;
281
282 virtual Button* createToolbarMissingItemsButton (Toolbar&) = 0;
283
284 virtual void paintToolbarButtonBackground (Graphics&, int width, int height,
285 bool isMouseOver, bool isMouseDown,
287
288 virtual void paintToolbarButtonLabel (Graphics&, int x, int y, int width, int height,
289 const String& text, ToolbarItemComponent&) = 0;
290 };
291
292 //==============================================================================
294 void paint (Graphics&) override;
296 void resized() override;
298 void mouseDown (const MouseEvent&) override;
300 bool isInterestedInDragSource (const SourceDetails&) override;
302 void itemDragMove (const SourceDetails&) override;
304 void itemDragExit (const SourceDetails&) override;
306 void itemDropped (const SourceDetails&) override;
308 void lookAndFeelChanged() override;
310 void updateAllItemPositions (bool animate);
312 static ToolbarItemComponent* createItem (ToolbarItemFactory&, int itemId);
314 static const char* const toolbarDragDescriptor;
316 std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
317
318private:
319 //==============================================================================
320 std::unique_ptr<Button> missingItemsButton;
321 bool vertical = false, isEditingActive = false;
322 ToolbarItemStyle toolbarStyle = iconsOnly;
324 friend class MissingItemsComponent;
326 class Spacer;
328
329 void initMissingItemButton();
330 void showMissingItems();
331 void addItemInternal (ToolbarItemFactory& factory, int itemId, int insertIndex);
332
333 ToolbarItemComponent* getNextActiveComponent (int index, int delta) const;
334
336};
337
338} // namespace juce
A base class for buttons.
Definition juce_Button.h:43
The base class for all JUCE user-interface objects.
Enables drag-and-drop behaviour for a component and all its sub-components.
Contains details about the source of a drag-and-drop operation.
Components derived from this class can have things dropped onto them by a DragAndDropContainer.
A graphics context, used for drawing a component or image.
Contains position and status information about a mouse event.
An array designed for holding objects.
The JUCE String class!
Definition juce_String.h:53
A component that can be used as one of the items in a Toolbar.
A factory object which can create ToolbarItemComponent objects.
A toolbar component.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the toolbar.
ToolbarItemStyle
Options for the way items should be displayed.
@ iconsWithText
Means that the toolbar should have text labels under each icon.
@ iconsOnly
Means that the toolbar should just contain icons.
ToolbarItemStyle getStyle() const noexcept
Returns the toolbar's current style.
CustomisationFlags
Flags used by the showCustomisationDialog() method.
bool isVertical() const noexcept
Returns true if the bar is set to be vertical, or false if it's horizontal.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.
This abstract base class is implemented by LookAndFeel classes.