LMMS
Loading...
Searching...
No Matches
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) 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 TabbedButtonBar;
30
31
32//==============================================================================
44{
45public:
46 //==============================================================================
48 TabBarButton (const String& name, TabbedButtonBar& ownerBar);
49
51 ~TabBarButton() override;
52
55
56 //==============================================================================
64
72 void setExtraComponent (Component* extraTabComponent,
73 ExtraComponentPlacement extraComponentPlacement);
74
77
80
86 Rectangle<int> getActiveArea() const;
87
89 Rectangle<int> getTextArea() const;
90
92 int getIndex() const;
93
95 Colour getTabBackgroundColour() const;
96
98 bool isFrontTab() const;
99
100 //==============================================================================
107 virtual int getBestTabLength (int depth);
108
109 //==============================================================================
111 void paintButton (Graphics&, bool, bool) override;
113 void clicked (const ModifierKeys&) override;
115 bool hitTest (int x, int y) override;
117 void resized() override;
119 void childBoundsChanged (Component*) override;
120
121protected:
122 friend class TabbedButtonBar;
125
126 std::unique_ptr<Component> extraComponent;
128
129private:
130 using Button::clicked;
132
134};
135
136
137//==============================================================================
154 public ChangeBroadcaster
155{
156public:
157 //==============================================================================
168
169 //==============================================================================
173 TabbedButtonBar (Orientation orientation);
174
176 ~TabbedButtonBar() override;
177
178 //==============================================================================
185 void setOrientation (Orientation orientation);
186
191
194
197
201 void setMinimumTabScaleFactor (double newMinimumScale);
202
203 //==============================================================================
207 void clearTabs();
208
213 void addTab (const String& tabName,
214 Colour tabBackgroundColour,
215 int insertIndex);
216
218 void setTabName (int tabIndex, const String& newName);
219
221 void removeTab (int tabIndex, bool animate = false);
222
226 void moveTab (int currentIndex, int newIndex, bool animate = false);
227
229 int getNumTabs() const;
230
232 StringArray getTabNames() const;
233
241 void setCurrentTabIndex (int newTabIndex, bool sendChangeMessage = true);
242
246 String getCurrentTabName() const;
247
252
258 TabBarButton* getTabButton (int index) const;
259
261 int indexOfTabButton (const TabBarButton* button) const;
262
264 Rectangle<int> getTargetBounds (TabBarButton* button) const;
265
266 //==============================================================================
270 virtual void currentTabChanged (int newCurrentTabIndex,
271 const String& newCurrentTabName);
272
274 virtual void popupMenuClickOnTab (int tabIndex, const String& tabName);
275
279 Colour getTabBackgroundColour (int tabIndex);
280
284 void setTabBackgroundColour (int tabIndex, Colour newColour);
285
286 //==============================================================================
295 {
296 tabOutlineColourId = 0x1005812,
297 tabTextColourId = 0x1005813,
300 frontTextColourId = 0x1005815,
303 };
304
305 //==============================================================================
310 {
311 virtual ~LookAndFeelMethods() = default;
312
314 virtual int getTabButtonOverlap (int tabDepth) = 0;
315 virtual int getTabButtonBestWidth (TabBarButton&, int tabDepth) = 0;
317
318 virtual void drawTabButton (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) = 0;
320 virtual void drawTabButtonText (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) = 0;
322 virtual void drawTabAreaBehindFrontButton (TabbedButtonBar&, Graphics&, int w, int h) = 0;
323
324 virtual void createTabButtonShape (TabBarButton&, Path& path, bool isMouseOver, bool isMouseDown) = 0;
325 virtual void fillTabButtonShape (TabBarButton&, Graphics&, const Path& path, bool isMouseOver, bool isMouseDown) = 0;
326
328 };
329
330 //==============================================================================
332 void paint (Graphics&) override;
334 void resized() override;
336 void lookAndFeelChanged() override;
337
338protected:
339 //==============================================================================
345 virtual TabBarButton* createTabButton (const String& tabName, int tabIndex);
346
347private:
348 struct TabInfo
349 {
350 std::unique_ptr<TabBarButton> button;
353 };
354
356
358 double minimumScale = 0.7;
360
361 class BehindFrontTabComp;
362 std::unique_ptr<BehindFrontTabComp> behindFrontTab;
363 std::unique_ptr<Button> extraTabsButton;
364
365 std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
366 void showExtraItemsMenu();
367 void updateTabPositions (bool animate);
368
370};
371
372} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_Button.h:43
virtual void clicked()
Definition juce_Button.cpp:339
Button(const String &buttonName)
Definition juce_Button.cpp:76
ChangeBroadcaster() noexcept
Definition juce_ChangeBroadcaster.cpp:26
Definition juce_Colour.h:38
Definition juce_Component.h:36
int getHeight() const noexcept
Definition juce_Component.h:274
Component() noexcept
Definition juce_Component.cpp:517
bool isMouseOver(bool includeChildren=false) const
Definition juce_Component.cpp:3159
int getWidth() const noexcept
Definition juce_Component.h:271
Definition juce_Font.h:42
Definition juce_GraphicsContext.h:45
Definition juce_ModifierKeys.h:41
Definition juce_OwnedArray.h:51
Definition juce_Path.h:65
Definition juce_Rectangle.h:67
Definition juce_StringArray.h:35
Definition juce_String.h:53
Definition juce_TabbedButtonBar.h:44
ExtraComponentPlacement getExtraComponentPlacement() const noexcept
Definition juce_TabbedButtonBar.h:79
void calcAreas(Rectangle< int > &, Rectangle< int > &) const
Definition juce_TabbedButtonBar.cpp:83
Component * getExtraComponent() const noexcept
Definition juce_TabbedButtonBar.h:76
TabbedButtonBar & getTabbedButtonBar() const
Definition juce_TabbedButtonBar.h:54
TabBarButton(const String &name, TabbedButtonBar &ownerBar)
Definition juce_TabbedButtonBar.cpp:29
ExtraComponentPlacement extraCompPlacement
Definition juce_TabbedButtonBar.h:127
friend class TabbedButtonBar
Definition juce_TabbedButtonBar.h:122
std::unique_ptr< Component > extraComponent
Definition juce_TabbedButtonBar.h:126
ExtraComponentPlacement
Definition juce_TabbedButtonBar.h:60
@ beforeText
Definition juce_TabbedButtonBar.h:61
@ afterText
Definition juce_TabbedButtonBar.h:62
TabbedButtonBar & owner
Definition juce_TabbedButtonBar.h:123
int overlapPixels
Definition juce_TabbedButtonBar.h:124
Definition juce_TabbedButtonBar.cpp:175
Definition juce_TabbedButtonBar.h:155
std::unique_ptr< BehindFrontTabComp > behindFrontTab
Definition juce_TabbedButtonBar.h:362
double minimumScale
Definition juce_TabbedButtonBar.h:358
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Definition juce_TabbedButtonBar.cpp:578
int getCurrentTabIndex() const noexcept
Definition juce_TabbedButtonBar.h:251
TabbedButtonBar(Orientation orientation)
Definition juce_TabbedButtonBar.cpp:199
void updateTabPositions(bool animate)
Definition juce_TabbedButtonBar.cpp:402
OwnedArray< TabInfo > tabs
Definition juce_TabbedButtonBar.h:355
Orientation orientation
Definition juce_TabbedButtonBar.h:357
Orientation getOrientation() const noexcept
Definition juce_TabbedButtonBar.h:190
Orientation
Definition juce_TabbedButtonBar.h:162
@ TabsAtLeft
Definition juce_TabbedButtonBar.h:165
@ TabsAtTop
Definition juce_TabbedButtonBar.h:163
@ TabsAtBottom
Definition juce_TabbedButtonBar.h:164
@ TabsAtRight
Definition juce_TabbedButtonBar.h:166
std::unique_ptr< Button > extraTabsButton
Definition juce_TabbedButtonBar.h:363
ColourIds
Definition juce_TabbedButtonBar.h:295
@ tabOutlineColourId
Definition juce_TabbedButtonBar.h:296
@ frontTextColourId
Definition juce_TabbedButtonBar.h:300
@ tabTextColourId
Definition juce_TabbedButtonBar.h:297
@ frontOutlineColourId
Definition juce_TabbedButtonBar.h:299
virtual TabBarButton * createTabButton(const String &tabName, int tabIndex)
Definition juce_TabbedButtonBar.cpp:225
bool isVertical() const noexcept
Definition juce_TabbedButtonBar.h:193
int currentTabIndex
Definition juce_TabbedButtonBar.h:359
int getThickness() const noexcept
Definition juce_TabbedButtonBar.h:196
void showExtraItemsMenu()
Definition juce_TabbedButtonBar.cpp:554
void resized() override
Definition juce_TabbedButtonBar.cpp:396
void lookAndFeelChanged() override
Definition juce_TabbedButtonBar.cpp:385
void paint(Graphics &) override
Definition juce_TabbedButtonBar.cpp:391
UINT_D64 w
Definition inflate.c:942
int y
Definition inflate.c:1588
unsigned x[BMAX+1]
Definition inflate.c:1586
static const char * name
Definition pugl.h:1582
static int int height
Definition pugl.h:1594
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
Definition juce_TabbedButtonBar.h:310
virtual int getTabButtonOverlap(int tabDepth)=0
virtual void drawTabButton(TabBarButton &, Graphics &, bool isMouseOver, bool isMouseDown)=0
virtual void fillTabButtonShape(TabBarButton &, Graphics &, const Path &path, bool isMouseOver, bool isMouseDown)=0
virtual void createTabButtonShape(TabBarButton &, Path &path, bool isMouseOver, bool isMouseDown)=0
virtual Rectangle< int > getTabButtonExtraComponentBounds(const TabBarButton &, Rectangle< int > &textArea, Component &extraComp)=0
virtual int getTabButtonBestWidth(TabBarButton &, int tabDepth)=0
virtual Button * createTabBarExtrasButton()=0
virtual void drawTabButtonText(TabBarButton &, Graphics &, bool isMouseOver, bool isMouseDown)=0
virtual void drawTabAreaBehindFrontButton(TabbedButtonBar &, Graphics &, int w, int h)=0
virtual void drawTabbedButtonBarBackground(TabbedButtonBar &, Graphics &)=0
virtual Font getTabButtonFont(TabBarButton &, float height)=0
Definition juce_TabbedButtonBar.h:349
std::unique_ptr< TabBarButton > button
Definition juce_TabbedButtonBar.h:350
Colour colour
Definition juce_TabbedButtonBar.h:352
String name
Definition juce_TabbedButtonBar.h:351
uch h[RAND_HEAD_LEN]
Definition crypt.c:459
#define const
Definition zconf.h:137