openshot-audio  0.1.4
juce_Drawable.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_DRAWABLE_H_INCLUDED
26 #define JUCE_DRAWABLE_H_INCLUDED
27 
28 
29 //==============================================================================
35 class JUCE_API Drawable : public Component
36 {
37 protected:
38  //==============================================================================
43  Drawable();
44 
45 public:
47  virtual ~Drawable();
48 
49  //==============================================================================
54  virtual Drawable* createCopy() const = 0;
55 
56  //==============================================================================
65  void draw (Graphics& g, float opacity,
66  const AffineTransform& transform = AffineTransform::identity) const;
67 
81  void drawAt (Graphics& g, float x, float y, float opacity) const;
82 
99  void drawWithin (Graphics& g,
100  const Rectangle<float>& destArea,
101  RectanglePlacement placement,
102  float opacity) const;
103 
104 
105  //==============================================================================
109  void setOriginWithOriginalSize (Point<float> originWithinParent);
110 
114  void setTransformToFit (const Rectangle<float>& areaInParent, RectanglePlacement placement);
115 
117  DrawableComposite* getParent() const;
118 
119  //==============================================================================
125  static Drawable* createFromImageData (const void* data, size_t numBytes);
126 
132  static Drawable* createFromImageDataStream (InputStream& dataSource);
133 
139  static Drawable* createFromImageFile (const File& file);
140 
150  static Drawable* createFromSVG (const XmlElement& svgDocument);
151 
153  static Path parseSVGPath (const String& svgPath);
154 
155  //==============================================================================
163  static Drawable* createFromValueTree (const ValueTree& tree, ComponentBuilder::ImageProvider* imageProvider);
164 
170  virtual ValueTree createValueTree (ComponentBuilder::ImageProvider* imageProvider) const = 0;
171 
176  virtual Rectangle<float> getDrawableBounds() const = 0;
177 
181  virtual bool replaceColour (Colour originalColour, Colour replacementColour);
182 
183  //==============================================================================
186  {
187  public:
188  ValueTreeWrapperBase (const ValueTree& state);
189 
190  ValueTree& getState() noexcept { return state; }
191 
192  String getID() const;
193  void setID (const String& newID);
194 
196  };
197 
198  //==============================================================================
203  static void registerDrawableTypeHandlers (ComponentBuilder& componentBuilder);
204 
205 protected:
206  //==============================================================================
207  friend class DrawableComposite;
208  friend class DrawableShape;
209 
213  void parentHierarchyChanged() override;
215  void setBoundsToEnclose (const Rectangle<float>&);
216 
218 
219  #ifndef DOXYGEN
220 
221  template <class DrawableType>
223  {
224  public:
225  Positioner (DrawableType& c)
227  owner (c)
228  {}
229 
230  bool registerCoordinates() override { return owner.registerCoordinates (*this); }
231 
232  void applyToComponentBounds() override
233  {
234  ComponentScope scope (getComponent());
235  owner.recalculateCoordinates (&scope);
236  }
237 
238  void applyNewBounds (const Rectangle<int>&) override
239  {
240  jassertfalse; // drawables can't be resized directly!
241  }
242 
243  private:
244  DrawableType& owner;
245 
247  };
248 
249  Drawable (const Drawable&);
250  #endif
251 
252 private:
253  void nonConstDraw (Graphics&, float opacity, const AffineTransform&);
254 
255  Drawable& operator= (const Drawable&);
257 };
258 
259 
260 #endif // JUCE_DRAWABLE_H_INCLUDED
void applyNewBounds(const Rectangle< int > &) override
Definition: juce_Drawable.h:238
void parentHierarchyChanged() override
Definition: juce_Drawable.cpp:93
ValueTree & getState() noexcept
Definition: juce_Drawable.h:190
Definition: juce_DrawableShape.h:36
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_InputStream.h:41
void transformContextToCorrectOrigin(Graphics &)
Definition: juce_Drawable.cpp:88
#define jassertfalse
Definition: juce_PlatformDefs.h:141
Definition: juce_Point.h:39
Definition: juce_String.h:43
void applyToComponentBounds() override
Definition: juce_Drawable.h:232
#define JUCE_API
Definition: juce_StandardHeader.h:139
static const AffineTransform identity
Definition: juce_AffineTransform.h:78
Definition: juce_Drawable.h:222
Definition: juce_Rectangle.h:36
Definition: juce_RectanglePlacement.h:37
Definition: juce_Path.h:62
Definition: juce_XmlElement.h:142
Definition: juce_Colour.h:35
Point< int > originRelativeToComponent
Definition: juce_Drawable.h:217
Definition: juce_Component.h:33
ValueTree state
Definition: juce_Drawable.h:195
void setBoundsToEnclose(const Rectangle< float > &)
Definition: juce_Drawable.cpp:98
Definition: juce_DrawableComposite.h:35
Definition: juce_RelativeCoordinatePositioner.h:33
bool registerCoordinates() override
Definition: juce_Drawable.h:230
Definition: juce_ComponentBuilder.h:45
Definition: juce_RelativeCoordinatePositioner.h:55
Definition: juce_Drawable.h:35
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_GraphicsContext.h:42
Definition: juce_AffineTransform.h:40
Definition: juce_Drawable.h:185
Definition: juce_ValueTree.h:64
Positioner(DrawableType &c)
Definition: juce_Drawable.h:225
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition: juce_LeakedObjectDetector.h:141
Definition: juce_File.h:45
Definition: juce_ComponentBuilder.h:183