31 : titleLabel (
"titleLabel", title),
44 desktop.addGlobalMouseListener (
this);
45 desktop.getAnimator().addChangeListener (
this);
59 desktop.removeGlobalMouseListener (
this);
60 desktop.getAnimator().removeChangeListener (
this);
62 if (parent !=
nullptr)
102 if (parent !=
nullptr)
107 1.0f, 250,
true, 1.0, 0.0);
123 calculateAndRemoveShadowBounds (bounds);
125 auto titleBounds = bounds.removeFromTop (titleBarHeight);
127 if (titleBarComponent !=
nullptr)
129 if (shouldShowDismissButton)
131 :
titleBounds.removeFromLeft (30).withTrimmedLeft (10));
138 :
titleBounds.removeFromLeft (30).withTrimmedLeft (10));
144 if (contentComponent !=
nullptr)
145 contentComponent->setBounds (bounds);
152 auto bgColour =
lf.findColour (SidePanel::backgroundColour);
158 : shadowArea.
getTopLeft()).toFloat(),
false));
162 .withX (isOnLeft ? 0 : shadowArea.
getWidth()));
172 if (parent !=
nullptr)
225 shouldResize =
false;
230void SidePanel::lookAndFeelChanged()
234 dismissButton.
setShape (
lf.getSidePanelDismissButtonShape (*
this),
false,
true,
false);
236 dismissButton.
setColours (
lf.findColour (SidePanel::dismissButtonNormalColour),
237 lf.findColour (SidePanel::dismissButtonOverColour),
238 lf.findColour (SidePanel::dismissButtonDownColour));
240 titleLabel.
setFont (
lf.getSidePanelTitleFont (*
this));
248 setBounds (calculateBoundsInParent (component));
251void SidePanel::changeListenerCallback (ChangeBroadcaster*)
262Rectangle<int> SidePanel::calculateBoundsInParent (Component&
parentComp)
const
268 return isShowing ?
parentBounds.removeFromLeft (panelWidth)
272 return isShowing ?
parentBounds.removeFromRight (panelWidth)
276void SidePanel::calculateAndRemoveShadowBounds (Rectangle<int>& bounds)
278 shadowArea = isOnLeft ? bounds.removeFromRight (shadowWidth)
279 : bounds.removeFromLeft (shadowWidth);
282bool SidePanel::isMouseEventInThisOrChildren (Component* eventComponent)
284 if (eventComponent ==
this)
288 if (eventComponent == child)
297 return std::make_unique<AccessibilityHandler> (*
this, AccessibilityRole::group);
Describes the layout and colours that should be used to paint a colour gradient.
void animateComponent(Component *component, const Rectangle< int > &finalBounds, float finalAlpha, int animationDurationMilliseconds, bool useProxyComponent, double startSpeed, double endSpeed)
Starts a component moving from its current position to a specified position.
The base class for all JUCE user-interface objects.
bool contains(Point< int > localPoint)
Returns true if a given point lies within this component or one of its children.
void removeComponentListener(ComponentListener *listenerToRemove)
Removes a component listener.
bool isVisible() const noexcept
Tests whether the component is visible or not.
Component * getParentComponent() const noexcept
Returns the component which this component is inside.
Point< int > getLocalPoint(const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
Converts a point to be relative to this component's coordinate space.
void addComponentListener(ComponentListener *newListener)
Adds a listener to be told about changes to the component hierarchy or position.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void setAlwaysOnTop(bool shouldStayOnTop)
Sets whether the component should always be kept at the front of its siblings.
void setOpaque(bool shouldBeOpaque)
Indicates whether any parts of the component might be transparent.
Rectangle< int > getBounds() const noexcept
Returns this component's bounding box.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
void setColour(int colourID, Colour newColour)
Registers a colour to be used for a particular purpose.
Colour findColour(int colourID, bool inheritFromParent=false) const
Looks for a colour that has been registered with the given colour ID number.
Point< int > localPointToGlobal(Point< int > localPoint) const
Converts a point relative to this component's top-left into a screen coordinate.
LookAndFeel & getLookAndFeel() const noexcept
Finds the appropriate look-and-feel to use for this component.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
const Array< Component * > & getChildren() const noexcept
Provides access to the underlying array of child components.
virtual void setVisible(bool shouldBeVisible)
Makes the component visible or invisible.
ComponentAnimator & getAnimator() noexcept
The Desktop object has a ComponentAnimator instance which can be used for performing your animations.
static Desktop &JUCE_CALLTYPE getInstance()
There's only one desktop object, and this method will return it.
A graphics context, used for drawing a component or image.
void setGradientFill(const ColourGradient &gradient)
Sets the context to use a gradient for its fill pattern.
void fillRect(Rectangle< int > rectangle) const
Fills a rectangle with the current colour or brush.
bool reduceClipRegion(int x, int y, int width, int height)
Intersects the current clipping region with another region.
void fillAll() const
Fills the context's entire clip region with the current colour or brush.
@ textColourId
The colour for the text.
void setFont(const Font &newFont)
Changes the font to use to draw the text.
void setJustificationType(Justification justification)
Sets the style of justification to be used for positioning the text.
Contains position and status information about a mouse event.
Point< int > getPosition() const noexcept
The position of the mouse when the event occurred.
Point< int > getMouseDownPosition() const noexcept
Returns the coordinates of the last place that a mouse was pressed.
Component *const eventComponent
The component that this event applies to.
A pair of (x, y) coordinates.
ValueType x
The point's X coordinate.
ValueType getRight() const noexcept
Returns the x coordinate of the rectangle's right-hand-side.
ValueType getX() const noexcept
Returns the x coordinate of the rectangle's left-hand-side.
Point< ValueType > getTopLeft() const noexcept
Returns the rectangle's top-left position as a Point.
ValueType getWidth() const noexcept
Returns the width of the rectangle.
Point< ValueType > getTopRight() const noexcept
Returns the rectangle's top-right position as a Point.
Rectangle withTrimmedRight(ValueType amountToRemove) const noexcept
Returns a version of this rectangle with the given amount removed from its right-hand edge.
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.
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 setContent(Component *newContentComponent, bool deleteComponentWhenNoLongerNeeded=true)
Sets the component that this SidePanel will contain.
void resized() override
Called when this component's size has been changed.
void paint(Graphics &g) override
Components can override this method to draw their content.
void parentHierarchyChanged() override
Called to indicate that the component's parents have changed.
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.
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.
SidePanel(StringRef title, int width, bool positionOnLeft, Component *contentComponent=nullptr, bool deleteComponentWhenNoLongerNeeded=true)
Creates a SidePanel component.
A simple class for holding temporary references to a string literal or String.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...