openshot-audio  0.1.5
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
virtual ~LookAndFeelMethods()
Definition: juce_Toolbar.h:274
Definition: juce_DragAndDropTarget.h:53
Definition: juce_ToolbarItemFactory.h:42
Definition: juce_Toolbar.cpp:149
Definition: juce_Toolbar.h:167
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_Button.h:39
Definition: juce_Toolbar.cpp:28
bool isVertical() const noexcept
Definition: juce_Toolbar.h:82
Definition: juce_Toolbar.cpp:646
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
ColourIds
Definition: juce_Toolbar.h:233
static const char *const toolbarDragDescriptor
Definition: juce_Toolbar.h:308
Definition: juce_Toolbar.h:272
Definition: juce_Toolbar.h:49
Definition: juce_Component.h:33
Definition: juce_ToolbarItemComponent.h:47
Definition: juce_Button.h:162
CustomisationFlags
Definition: juce_Toolbar.h:184
ToolbarItemStyle getStyle() const noexcept
Definition: juce_Toolbar.h:175
Definition: juce_DragAndDropContainer.h:48
Definition: juce_Toolbar.h:168
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_GraphicsContext.h:42
ToolbarItemStyle
Definition: juce_Toolbar.h:165
Definition: juce_MouseEvent.h:36
Definition: juce_DragAndDropTarget.h:43