1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2015 - ROLI Ltd.
Permission is granted to use this software under the terms of either:
a) the GPL v2 (or any later version)
b) the Affero GPL v3
Details of these licenses can be found at: www.gnu.org/licenses
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.juce.com for more information.
==============================================================================
*/
#ifndef JUCE_DRAWABLECOMPOSITE_H_INCLUDED
#define JUCE_DRAWABLECOMPOSITE_H_INCLUDED
//==============================================================================
/**
A drawable object which acts as a container for a set of other Drawables.
@see Drawable
*/
class JUCE_API DrawableComposite : public Drawable
{
public:
//==============================================================================
/** Creates a composite Drawable. */
DrawableComposite();
/** Creates a copy of a DrawableComposite. */
DrawableComposite (const DrawableComposite&);
/** Destructor. */
~DrawableComposite();
//==============================================================================
/** Sets the parallelogram that defines the target position of the content rectangle when the drawable is rendered.
@see setContentArea
*/
void setBoundingBox (const RelativeParallelogram& newBoundingBox);
/** Returns the parallelogram that defines the target position of the content rectangle when the drawable is rendered.
@see setBoundingBox
*/
const RelativeParallelogram& getBoundingBox() const noexcept { return bounds; }
/** Changes the bounding box transform to match the content area, so that any sub-items will
be drawn at their untransformed positions.
*/
void resetBoundingBoxToContentArea();
/** Returns the main content rectangle.
The content area is actually defined by the markers named "left", "right", "top" and
"bottom", but this method is a shortcut that returns them all at once.
@see contentLeftMarkerName, contentRightMarkerName, contentTopMarkerName, contentBottomMarkerName
*/
RelativeRectangle getContentArea() const;
/** Changes the main content area.
The content area is actually defined by the markers named "left", "right", "top" and
"bottom", but this method is a shortcut that sets them all at once.
@see setBoundingBox, contentLeftMarkerName, contentRightMarkerName, contentTopMarkerName, contentBottomMarkerName
*/
void setContentArea (const RelativeRectangle& newArea);
/** Resets the content area and the bounding transform to fit around the area occupied
by the child components (ignoring any markers).
*/
void resetContentAreaAndBoundingBoxToFitChildren();
//==============================================================================
/** The name of the marker that defines the left edge of the content area. */
static const char* const contentLeftMarkerName;
/** The name of the marker that defines the right edge of the content area. */
static const char* const contentRightMarkerName;
/** The name of the marker that defines the top edge of the content area. */
static const char* const contentTopMarkerName;
/** The name of the marker that defines the bottom edge of the content area. */
static const char* const contentBottomMarkerName;
//==============================================================================
/** @internal */
Drawable* createCopy() const override;
/** @internal */
void refreshFromValueTree (const ValueTree&, ComponentBuilder&);
/** @internal */
ValueTree createValueTree (ComponentBuilder::ImageProvider* imageProvider) const override;
/** @internal */
static const Identifier valueTreeType;
/** @internal */
Rectangle<float> getDrawableBounds() const override;
/** @internal */
void childBoundsChanged (Component*) override;
/** @internal */
void childrenChanged() override;
/** @internal */
void parentHierarchyChanged() override;
/** @internal */
MarkerList* getMarkers (bool xAxis) override;
//==============================================================================
/** Internally-used class for wrapping a DrawableComposite's state into a ValueTree. */
class ValueTreeWrapper : public Drawable::ValueTreeWrapperBase
{
public:
ValueTreeWrapper (const ValueTree& state);
ValueTree getChildList() const;
ValueTree getChildListCreating (UndoManager* undoManager);
RelativeParallelogram getBoundingBox() const;
void setBoundingBox (const RelativeParallelogram& newBounds, UndoManager* undoManager);
void resetBoundingBoxToContentArea (UndoManager* undoManager);
RelativeRectangle getContentArea() const;
void setContentArea (const RelativeRectangle& newArea, UndoManager* undoManager);
MarkerList::ValueTreeWrapper getMarkerList (bool xAxis) const;
MarkerList::ValueTreeWrapper getMarkerListCreating (bool xAxis, UndoManager* undoManager);
static const Identifier topLeft, topRight, bottomLeft;
private:
static const Identifier childGroupTag, markerGroupTagX, markerGroupTagY;
};
private:
//==============================================================================
RelativeParallelogram bounds;
MarkerList markersX, markersY;
bool updateBoundsReentrant;
friend class Drawable::Positioner<DrawableComposite>;
bool registerCoordinates (RelativeCoordinatePositionerBase&);
void recalculateCoordinates (Expression::Scope*);
void updateBoundsToFitChildren();
DrawableComposite& operator= (const DrawableComposite&);
JUCE_LEAK_DETECTOR (DrawableComposite)
};
#endif // JUCE_DRAWABLECOMPOSITE_H_INCLUDED
|