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_SidePanel.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
29//==============================================================================
41class SidePanel : public Component,
42 private ComponentListener,
43 private ChangeListener
44{
45public:
46 //==============================================================================
60 SidePanel (StringRef title, int width, bool positionOnLeft,
61 Component* contentComponent = nullptr,
63
65 ~SidePanel() override;
66
67 //==============================================================================
85
90 Component* getContent() const noexcept { return contentComponent.get(); }
91
109
114 Component* getTitleBarComponent() const noexcept { return titleBarComponent.get(); }
115
124 void showOrHide (bool show);
125
126 //==============================================================================
128 bool isPanelShowing() const noexcept { return isShowing; }
129
131 bool isPanelOnLeft() const noexcept { return isOnLeft; }
132
134 void setShadowWidth (int newWidth) noexcept { shadowWidth = newWidth; }
135
137 int getShadowWidth() const noexcept { return shadowWidth; }
138
140 void setTitleBarHeight (int newHeight) noexcept { titleBarHeight = newHeight; }
141
143 int getTitleBarHeight() const noexcept { return titleBarHeight; }
144
146 String getTitleText() const noexcept { return titleLabel.getText(); }
147
148 //==============================================================================
152 struct JUCE_API LookAndFeelMethods
153 {
154 virtual ~LookAndFeelMethods() = default;
155
156 virtual Font getSidePanelTitleFont (SidePanel&) = 0;
157 virtual Justification getSidePanelTitleJustification (SidePanel&) = 0;
158 virtual Path getSidePanelDismissButtonShape (SidePanel&) = 0;
159 };
160
169 {
170 backgroundColour = 0x100f001,
171 titleTextColour = 0x100f002,
172 shadowBaseColour = 0x100f003,
173 dismissButtonNormalColour = 0x100f004,
174 dismissButtonOverColour = 0x100f005,
175 dismissButtonDownColour = 0x100f006
176 };
177
178 //==============================================================================
181
184
185 //==============================================================================
187 void moved() override;
189 void resized() override;
191 void paint (Graphics& g) override;
193 void parentHierarchyChanged() override;
195 void mouseDrag (const MouseEvent&) override;
197 void mouseUp (const MouseEvent&) override;
200
201private:
202 //==============================================================================
203 Component* parent = nullptr;
204 OptionalScopedPointer<Component> contentComponent;
205 OptionalScopedPointer<Component> titleBarComponent;
206
207 Label titleLabel;
208 ShapeButton dismissButton { "dismissButton", Colours::lightgrey, Colours::lightgrey, Colours::white };
209
210 Rectangle<int> shadowArea;
211
212 bool isOnLeft = false;
213 bool isShowing = false;
214
215 int panelWidth = 0;
216 int shadowWidth = 15;
217 int titleBarHeight = 40;
218
219 Rectangle<int> startingBounds;
220 bool shouldResize = false;
221 int amountMoved = 0;
222
223 bool shouldShowDismissButton = true;
224
225 //==============================================================================
226 void lookAndFeelChanged() override;
227 void componentMovedOrResized (Component&, bool wasMoved, bool wasResized) override;
228 void changeListenerCallback (ChangeBroadcaster*) override;
229
230 Rectangle<int> calculateBoundsInParent (Component&) const;
231 void calculateAndRemoveShadowBounds (Rectangle<int>& bounds);
232
233 bool isMouseEventInThisOrChildren (Component*);
234
235 //==============================================================================
237};
238
239} // namespace juce
Holds a list of ChangeListeners, and sends messages to them when instructed.
Receives change event callbacks that are sent out by a ChangeBroadcaster.
Gets informed about changes to a component's hierarchy or position.
The base class for all JUCE user-interface objects.
Represents a particular font, including its size, style, etc.
Definition juce_Font.h:42
A graphics context, used for drawing a component or image.
Represents a type of justification to be used when positioning graphical items.
A component that displays a text string, and can optionally become a text editor when clicked.
Definition juce_Label.h:41
String getText(bool returnActiveEditorContents=false) const
Returns the label's current text.
Contains position and status information about a mouse event.
Holds a pointer to an object which can optionally be deleted when this pointer goes out of scope.
A path is a sequence of lines and curves that may either form a closed shape or be open-ended.
Definition juce_Path.h:65
Manages a rectangle and allows geometric operations to be performed on it.
A button that contains a filled shape.
A component that is positioned on either the left- or right-hand side of its parent,...
void setTitleBarComponent(Component *titleBarComponentToUse, bool keepDismissButton, bool deleteComponentWhenNoLongerNeeded=true)
Sets a custom component to be used for the title bar of this SidePanel, replacing the default.
bool isPanelShowing() const noexcept
Returns true if the SidePanel is currently showing.
void showOrHide(bool show)
Shows or hides the SidePanel.
std::function< void()> onPanelMove
You can assign a lambda to this callback object and it will be called when the panel is moved.
void setShadowWidth(int newWidth) noexcept
Sets the width of the shadow that will be drawn on the side of the panel.
void setContent(Component *newContentComponent, bool deleteComponentWhenNoLongerNeeded=true)
Sets the component that this SidePanel will contain.
Component * getContent() const noexcept
Returns the component that's currently being used inside the SidePanel.
void setTitleBarHeight(int newHeight) noexcept
Sets the height of the title bar at the top of the SidePanel.
void resized() override
Called when this component's size has been changed.
int getShadowWidth() const noexcept
Returns the width of the shadow that will be drawn on the side of the panel.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the SidePanel.
void paint(Graphics &g) override
Components can override this method to draw their content.
String getTitleText() const noexcept
Returns the text that is displayed in the title bar at the top of the SidePanel.
void parentHierarchyChanged() override
Called to indicate that the component's parents have changed.
Component * getTitleBarComponent() const noexcept
Returns the component that is currently being used as the title bar of the SidePanel.
void mouseUp(const MouseEvent &) override
Called when a mouse button is released.
void mouseDrag(const MouseEvent &) override
Called when the mouse is moved while a button is held down.
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Override this method to return a custom AccessibilityHandler for this component.
~SidePanel() override
Destructor.
int getTitleBarHeight() const noexcept
Returns the height of the title bar at the top of the SidePanel.
std::function< void(bool)> onPanelShowHide
You can assign a lambda to this callback object and it will be called when the panel is shown or hidd...
void moved() override
Called when this component's position has been changed.
bool isPanelOnLeft() const noexcept
Returns true if the SidePanel is positioned on the left of its parent.
A simple class for holding temporary references to a string literal or String.
The JUCE String class!
Definition juce_String.h:53
#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.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
This abstract base class is implemented by LookAndFeel classes to provide SidePanel drawing functiona...