openshot-audio  0.1.7
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) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_TOOLBAR_H_INCLUDED
26 #define JUCE_TOOLBAR_H_INCLUDED
27 
29 class ToolbarItemFactory;
30 
31 
32 //==============================================================================
49 class JUCE_API Toolbar : public Component,
50  public DragAndDropContainer,
51  public DragAndDropTarget,
52  private ButtonListener // (can't use Button::Listener due to idiotic VC2005 bug)
53 {
54 public:
55  //==============================================================================
64  Toolbar();
65 
70  ~Toolbar();
71 
72  //==============================================================================
76  void setVertical (bool shouldBeVertical);
77 
82  bool isVertical() const noexcept { return vertical; }
83 
91  int getThickness() const noexcept;
92 
100  int getLength() const noexcept;
101 
102  //==============================================================================
105  void clear();
106 
120  void addItem (ToolbarItemFactory& factory,
121  int itemId,
122  int insertIndex = -1);
123 
125  void removeToolbarItem (int itemIndex);
126 
128  ToolbarItemComponent* removeAndReturnItem (int itemIndex);
129 
134  int getNumItems() const noexcept;
135 
143  int getItemId (int itemIndex) const noexcept;
144 
152  ToolbarItemComponent* getItemComponent (int itemIndex) const noexcept;
153 
159  void addDefaultItems (ToolbarItemFactory& factoryToUse);
160 
161  //==============================================================================
166  {
169  textOnly
170  };
171 
175  ToolbarItemStyle getStyle() const noexcept { return toolbarStyle; }
176 
180  void setStyle (const ToolbarItemStyle& newStyle);
181 
182  //==============================================================================
185  {
186  allowIconsOnlyChoice = 1,
188  allowIconsWithTextChoice = 2,
190  allowTextOnlyChoice = 4,
192  showResetToDefaultsButton = 8,
195  allCustomisationOptionsEnabled = (allowIconsOnlyChoice | allowIconsWithTextChoice | allowTextOnlyChoice | showResetToDefaultsButton)
196  };
197 
212  void showCustomisationDialog (ToolbarItemFactory& factory,
213  int optionFlags = allCustomisationOptionsEnabled);
214 
223  void setEditingActive (bool editingEnabled);
224 
225  //==============================================================================
234  {
235  backgroundColourId = 0x1003200,
237  separatorColourId = 0x1003210,
239  buttonMouseOverBackgroundColourId = 0x1003220,
241  buttonMouseDownBackgroundColourId = 0x1003230,
244  labelTextColourId = 0x1003240,
247  editingModeOutlineColourId = 0x1003250
249  };
250 
251  //==============================================================================
258  String toString() const;
259 
267  bool restoreFromString (ToolbarItemFactory& factoryToUse,
268  const String& savedVersion);
269 
270  //==============================================================================
273  {
274  virtual ~LookAndFeelMethods() {}
275 
276  virtual void paintToolbarBackground (Graphics&, int width, int height, Toolbar&) = 0;
277 
278  virtual Button* createToolbarMissingItemsButton (Toolbar&) = 0;
279 
280  virtual void paintToolbarButtonBackground (Graphics&, int width, int height,
281  bool isMouseOver, bool isMouseDown,
282  ToolbarItemComponent&) = 0;
283 
284  virtual void paintToolbarButtonLabel (Graphics&, int x, int y, int width, int height,
285  const String& text, ToolbarItemComponent&) = 0;
286  };
287 
288  //==============================================================================
290  void paint (Graphics&) override;
292  void resized() override;
294  void mouseDown (const MouseEvent&) override;
296  bool isInterestedInDragSource (const SourceDetails&) override;
298  void itemDragMove (const SourceDetails&) override;
300  void itemDragExit (const SourceDetails&) override;
302  void itemDropped (const SourceDetails&) override;
304  void updateAllItemPositions (bool animate);
306  static ToolbarItemComponent* createItem (ToolbarItemFactory&, int itemId);
308  static const char* const toolbarDragDescriptor;
309 
310 private:
311  //==============================================================================
312  ScopedPointer<Button> missingItemsButton;
313  bool vertical, isEditingActive;
314  ToolbarItemStyle toolbarStyle;
316  friend class MissingItemsComponent;
318  class Spacer;
319  class CustomisationDialog;
320 
321  void buttonClicked (Button*) override;
322  void addItemInternal (ToolbarItemFactory& factory, int itemId, int insertIndex);
323 
324  ToolbarItemComponent* getNextActiveComponent (int index, int delta) const;
325 
327 };
328 
329 
330 #endif // JUCE_TOOLBAR_H_INCLUDED
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Toolbar::LookAndFeelMethods
Definition: juce_Toolbar.h:272
Toolbar::isVertical
bool isVertical() const noexcept
Definition: juce_Toolbar.h:82
Button
Definition: juce_Button.h:39
String
Definition: juce_String.h:43
JUCE_API
#define JUCE_API
Definition: juce_StandardHeader.h:139
ScopedPointer< Button >
DragAndDropContainer
Definition: juce_DragAndDropContainer.h:48
DragAndDropTarget
Definition: juce_DragAndDropTarget.h:43
Toolbar::iconsWithText
@ iconsWithText
Definition: juce_Toolbar.h:168
Graphics
Definition: juce_GraphicsContext.h:42
noexcept
#define noexcept
Definition: juce_CompilerSupport.h:141
Toolbar::CustomisationDialog
Definition: juce_Toolbar.cpp:646
Toolbar::iconsOnly
@ iconsOnly
Definition: juce_Toolbar.h:167
Toolbar::toolbarDragDescriptor
static const char *const toolbarDragDescriptor
Definition: juce_Toolbar.h:308
OwnedArray< ToolbarItemComponent >
Toolbar::LookAndFeelMethods::~LookAndFeelMethods
virtual ~LookAndFeelMethods()
Definition: juce_Toolbar.h:274
Toolbar::Spacer
Definition: juce_Toolbar.cpp:28
Toolbar::ToolbarItemStyle
ToolbarItemStyle
Definition: juce_Toolbar.h:165
Toolbar::MissingItemsComponent
Definition: juce_Toolbar.cpp:149
Button::Listener
Definition: juce_Button.h:162
Component
Definition: juce_Component.h:33
Toolbar::ColourIds
ColourIds
Definition: juce_Toolbar.h:233
ToolbarItemComponent
Definition: juce_ToolbarItemComponent.h:47
MouseEvent
Definition: juce_MouseEvent.h:36
Toolbar::CustomisationFlags
CustomisationFlags
Definition: juce_Toolbar.h:184
ToolbarItemFactory
Definition: juce_ToolbarItemFactory.h:42
Toolbar::getStyle
ToolbarItemStyle getStyle() const noexcept
Definition: juce_Toolbar.h:175
Toolbar
Definition: juce_Toolbar.h:49