openshot-audio  0.1.4
juce_TabbedButtonBar.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_TABBEDBUTTONBAR_H_INCLUDED
26 #define JUCE_TABBEDBUTTONBAR_H_INCLUDED
27 
28 class TabbedButtonBar;
29 
30 
31 //==============================================================================
41 {
42 public:
43  //==============================================================================
45  TabBarButton (const String& name, TabbedButtonBar& ownerBar);
46 
48  ~TabBarButton();
49 
51  TabbedButtonBar& getTabbedButtonBar() const { return owner; }
52 
53  //==============================================================================
57  {
59  afterText
60  };
61 
69  void setExtraComponent (Component* extraTabComponent,
70  ExtraComponentPlacement extraComponentPlacement);
71 
73  Component* getExtraComponent() const noexcept { return extraComponent; }
74 
76  ExtraComponentPlacement getExtraComponentPlacement() const noexcept { return extraCompPlacement; }
77 
83  Rectangle<int> getActiveArea() const;
84 
86  Rectangle<int> getTextArea() const;
87 
89  int getIndex() const;
90 
92  Colour getTabBackgroundColour() const;
93 
95  bool isFrontTab() const;
96 
97  //==============================================================================
104  virtual int getBestTabLength (int depth);
105 
106  //==============================================================================
108  void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown) override;
110  void clicked (const ModifierKeys&) override;
112  bool hitTest (int x, int y) override;
114  void resized() override;
116  void childBoundsChanged (Component*) override;
117 
118 protected:
119  friend class TabbedButtonBar;
122 
125 
126 private:
127  void calcAreas (Rectangle<int>&, Rectangle<int>&) const;
128 
130 };
131 
132 
133 //==============================================================================
148  public ChangeBroadcaster
149 {
150 public:
151  //==============================================================================
156  {
160  TabsAtRight
161  };
162 
163  //==============================================================================
167  TabbedButtonBar (Orientation orientation);
168 
170  ~TabbedButtonBar();
171 
172  //==============================================================================
179  void setOrientation (Orientation orientation);
180 
184  Orientation getOrientation() const noexcept { return orientation; }
185 
187  bool isVertical() const noexcept { return orientation == TabsAtLeft || orientation == TabsAtRight; }
188 
190  int getThickness() const noexcept { return isVertical() ? getWidth() : getHeight(); }
191 
195  void setMinimumTabScaleFactor (double newMinimumScale);
196 
197  //==============================================================================
201  void clearTabs();
202 
207  void addTab (const String& tabName,
208  Colour tabBackgroundColour,
209  int insertIndex);
210 
212  void setTabName (int tabIndex, const String& newName);
213 
215  void removeTab (int tabIndex, bool animate = false);
216 
220  void moveTab (int currentIndex, int newIndex, bool animate = false);
221 
223  int getNumTabs() const;
224 
226  StringArray getTabNames() const;
227 
235  void setCurrentTabIndex (int newTabIndex, bool sendChangeMessage = true);
236 
240  String getCurrentTabName() const;
241 
245  int getCurrentTabIndex() const noexcept { return currentTabIndex; }
246 
252  TabBarButton* getTabButton (int index) const;
253 
255  int indexOfTabButton (const TabBarButton* button) const;
256 
258  Rectangle<int> getTargetBounds (TabBarButton* button) const;
259 
260  //==============================================================================
264  virtual void currentTabChanged (int newCurrentTabIndex,
265  const String& newCurrentTabName);
266 
268  virtual void popupMenuClickOnTab (int tabIndex, const String& tabName);
269 
273  Colour getTabBackgroundColour (int tabIndex);
274 
278  void setTabBackgroundColour (int tabIndex, Colour newColour);
279 
280  //==============================================================================
289  {
290  tabOutlineColourId = 0x1005812,
291  tabTextColourId = 0x1005813,
293  frontOutlineColourId = 0x1005814,
294  frontTextColourId = 0x1005815,
297  };
298 
299  //==============================================================================
304  {
305  virtual ~LookAndFeelMethods() {}
306 
307  virtual int getTabButtonSpaceAroundImage() = 0;
308  virtual int getTabButtonOverlap (int tabDepth) = 0;
309  virtual int getTabButtonBestWidth (TabBarButton&, int tabDepth) = 0;
310  virtual Rectangle<int> getTabButtonExtraComponentBounds (const TabBarButton&, Rectangle<int>& textArea, Component& extraComp) = 0;
311 
312  virtual void drawTabButton (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) = 0;
313  virtual void drawTabButtonText (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) = 0;
314  virtual void drawTabbedButtonBarBackground (TabbedButtonBar&, Graphics&) = 0;
315  virtual void drawTabAreaBehindFrontButton (TabbedButtonBar&, Graphics&, int w, int h) = 0;
316 
317  virtual void createTabButtonShape (TabBarButton&, Path& path, bool isMouseOver, bool isMouseDown) = 0;
318  virtual void fillTabButtonShape (TabBarButton&, Graphics&, const Path& path, bool isMouseOver, bool isMouseDown) = 0;
319 
320  virtual Button* createTabBarExtrasButton() = 0;
321  };
322 
323  //==============================================================================
325  void paint (Graphics&) override;
327  void resized() override;
329  void lookAndFeelChanged() override;
330 
331 protected:
332  //==============================================================================
338  virtual TabBarButton* createTabButton (const String& tabName, int tabIndex);
339 
340 private:
341  Orientation orientation;
342 
343  struct TabInfo
344  {
346  String name;
347  Colour colour;
348  };
349 
351 
352  double minimumScale;
353  int currentTabIndex;
354 
356  friend class BehindFrontTabComp;
358  ScopedPointer<BehindFrontTabComp> behindFrontTab;
359  ScopedPointer<Button> extraTabsButton;
360 
361  void showExtraItemsMenu();
362  static void extraItemsMenuCallback (int, TabbedButtonBar*);
363  void updateTabPositions (bool animate);
364 
366 };
367 
368 
369 #endif // JUCE_TABBEDBUTTONBAR_H_INCLUDED
virtual void clicked()
Definition: juce_Button.cpp:325
bool isVertical() const noexcept
Definition: juce_TabbedButtonBar.h:187
virtual ~LookAndFeelMethods()
Definition: juce_TabbedButtonBar.h:305
#define noexcept
Definition: juce_CompilerSupport.h:141
ColourIds
Definition: juce_TabbedButtonBar.h:288
Definition: juce_TabbedButtonBar.cpp:169
ScopedPointer< Component > extraComponent
Definition: juce_TabbedButtonBar.h:123
int getWidth() const noexcept
Definition: juce_Component.h:268
Definition: juce_Button.h:39
Definition: juce_ModifierKeys.h:38
Definition: juce_TabbedButtonBar.h:40
int getThickness() const noexcept
Definition: juce_TabbedButtonBar.h:190
Definition: juce_String.h:43
Definition: juce_ChangeBroadcaster.h:35
int getHeight() const noexcept
Definition: juce_Component.h:271
#define JUCE_API
Definition: juce_StandardHeader.h:139
Orientation
Definition: juce_TabbedButtonBar.h:155
ExtraComponentPlacement
Definition: juce_TabbedButtonBar.h:56
Definition: juce_TabbedButtonBar.h:158
Definition: juce_TabbedButtonBar.h:58
Definition: juce_Rectangle.h:36
virtual void resized()
Definition: juce_Component.cpp:2272
Definition: juce_TabbedButtonBar.h:147
Definition: juce_Path.h:62
Orientation getOrientation() const noexcept
Definition: juce_TabbedButtonBar.h:184
Definition: juce_Colour.h:35
TabbedButtonBar & owner
Definition: juce_TabbedButtonBar.h:120
ExtraComponentPlacement extraCompPlacement
Definition: juce_TabbedButtonBar.h:124
int getCurrentTabIndex() const noexcept
Definition: juce_TabbedButtonBar.h:245
TabbedButtonBar & getTabbedButtonBar() const
Definition: juce_TabbedButtonBar.h:51
Definition: juce_Component.h:33
Definition: juce_StringArray.h:39
Definition: juce_TabbedButtonBar.h:303
Definition: juce_ContainerDeletePolicy.h:44
Definition: juce_TabbedButtonBar.h:159
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_GraphicsContext.h:42
virtual void childBoundsChanged(Component *child)
Definition: juce_Component.cpp:2274
int overlapPixels
Definition: juce_TabbedButtonBar.h:121
Component * getExtraComponent() const noexcept
Definition: juce_TabbedButtonBar.h:73
Definition: juce_TabbedButtonBar.h:157
virtual void paintButton(Graphics &g, bool isMouseOverButton, bool isButtonDown)=0
virtual bool hitTest(int x, int y)
Definition: juce_Component.cpp:1365
ExtraComponentPlacement getExtraComponentPlacement() const noexcept
Definition: juce_TabbedButtonBar.h:76