LMMS
Loading...
Searching...
No Matches
juce_DrawableComposite.cpp
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
30 : bounds ({ 0.0f, 0.0f, 100.0f, 100.0f })
31{
32 setContentArea ({ 0.0f, 0.0f, 100.0f, 100.0f });
33}
34
36 : Drawable (other),
37 bounds (other.bounds),
39{
40 for (auto* c : other.getChildren())
41 if (auto* d = dynamic_cast<const Drawable*> (c))
42 addAndMakeVisible (d->createCopy().release());
43}
44
49
50std::unique_ptr<Drawable> DrawableComposite::createCopy() const
51{
52 return std::make_unique<DrawableComposite> (*this);
53}
54
55//==============================================================================
57{
59
60 for (auto* c : getChildren())
61 if (auto* d = dynamic_cast<const Drawable*> (c))
62 r = r.getUnion (d->isTransformed() ? d->getDrawableBounds().transformedBy (d->getTransform())
63 : d->getDrawableBounds());
64
65 return r;
66}
67
72
77
79{
80 if (bounds != newBounds)
81 {
82 bounds = newBounds;
83
84 auto t = AffineTransform::fromTargetPoints (contentArea.getTopLeft(), bounds.topLeft,
85 contentArea.getTopRight(), bounds.topRight,
86 contentArea.getBottomLeft(), bounds.bottomLeft);
87
88 if (t.isSingularity())
89 t = {};
90
92 }
93}
94
99
105
107{
108 if (auto* parent = getParent())
109 originRelativeToComponent = parent->originRelativeToComponent - getPosition();
110}
111
116
121
123{
125 {
126 const ScopedValueSetter<bool> setter (updateBoundsReentrant, true, false);
127
128 Rectangle<int> childArea;
129
130 for (auto* c : getChildren())
131 childArea = childArea.getUnion (c->getBoundsInParent());
132
133 auto delta = childArea.getPosition();
134 childArea += getPosition();
135
136 if (childArea != getBounds())
137 {
138 if (! delta.isOrigin())
139 {
141
142 for (auto* c : getChildren())
143 c->setBounds (c->getBounds() - delta);
144 }
145
146 setBounds (childArea);
147 }
148 }
149}
150
151//==============================================================================
153{
154 Path p;
155
156 for (auto* c : getChildren())
157 if (auto* d = dynamic_cast<Drawable*> (c))
158 p.addPath (d->getOutlineAsPath());
159
160 p.applyTransform (getTransform());
161 return p;
162}
163
164} // namespace juce
static AffineTransform fromTargetPoints(float x00, float y00, float x10, float y10, float x01, float y01) noexcept
Definition juce_AffineTransform.cpp:213
Definition juce_Component.h:36
AffineTransform getTransform() const
Definition juce_Component.cpp:1378
void deleteAllChildren()
Definition juce_Component.cpp:1637
void setTransform(const AffineTransform &transform)
Definition juce_Component.cpp:1341
Point< int > getPosition() const noexcept
Definition juce_Component.h:286
void addAndMakeVisible(Component *child, int zOrder=-1)
Definition juce_Component.cpp:1554
Rectangle< int > getBounds() const noexcept
Definition juce_Component.h:304
void setBounds(int x, int y, int width, int height)
Definition juce_Component.cpp:1147
const Array< Component * > & getChildren() const noexcept
Definition juce_Component.h:685
Rectangle< float > getDrawableBounds() const override
Definition juce_DrawableComposite.cpp:56
Parallelogram< float > bounds
Definition juce_DrawableComposite.h:107
void setContentArea(Rectangle< float > newArea)
Definition juce_DrawableComposite.cpp:68
~DrawableComposite() override
Definition juce_DrawableComposite.cpp:45
void updateBoundsToFitChildren()
Definition juce_DrawableComposite.cpp:122
Path getOutlineAsPath() const override
Definition juce_DrawableComposite.cpp:152
bool updateBoundsReentrant
Definition juce_DrawableComposite.h:109
Rectangle< float > contentArea
Definition juce_DrawableComposite.h:108
DrawableComposite()
Definition juce_DrawableComposite.cpp:29
void resetBoundingBoxToContentArea()
Definition juce_DrawableComposite.cpp:95
void childBoundsChanged(Component *) override
Definition juce_DrawableComposite.cpp:112
void childrenChanged() override
Definition juce_DrawableComposite.cpp:117
void parentHierarchyChanged() override
Definition juce_DrawableComposite.cpp:106
std::unique_ptr< Drawable > createCopy() const override
Definition juce_DrawableComposite.cpp:50
void resetContentAreaAndBoundingBoxToFitChildren()
Definition juce_DrawableComposite.cpp:100
void setBoundingBox(Parallelogram< float > newBoundingBox)
Definition juce_DrawableComposite.cpp:78
DrawableComposite * getParent() const
Definition juce_Drawable.cpp:109
Point< int > originRelativeToComponent
Definition juce_Drawable.h:203
Drawable()
Definition juce_Drawable.cpp:29
Definition juce_Parallelogram.h:38
Definition juce_Path.h:65
Definition juce_Rectangle.h:67
Point< ValueType > getPosition() const noexcept
Definition juce_Rectangle.h:161
Rectangle getUnion(Rectangle other) const noexcept
Definition juce_Rectangle.h:719
Definition juce_ScopedValueSetter.h:55
struct huft * t
Definition inflate.c:943
unsigned d
Definition inflate.c:940
static uintptr_t parent
Definition pugl.h:1644
Definition carla_juce.cpp:31
uch * p
Definition crypt.c:594
return c
Definition crypt.c:175
int r
Definition crypt.c:458
if(GLOBAL(newzip))
Definition crypt.c:475