openshot-audio  0.1.2
juce_DrawableShape.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_DRAWABLESHAPE_H_INCLUDED
26 #define JUCE_DRAWABLESHAPE_H_INCLUDED
27 
28 
29 //==============================================================================
37 {
38 protected:
39  //==============================================================================
40  DrawableShape();
42 
43 public:
45  ~DrawableShape();
46 
47  //==============================================================================
51  {
52  public:
54  RelativeFillType (const FillType& fill);
56  RelativeFillType& operator= (const RelativeFillType&);
57 
58  bool operator== (const RelativeFillType&) const;
59  bool operator!= (const RelativeFillType&) const;
60 
61  bool isDynamic() const;
62  bool recalculateCoords (Expression::Scope* scope);
63 
64  void writeTo (ValueTree& v, ComponentBuilder::ImageProvider*, UndoManager*) const;
65  bool readFrom (const ValueTree& v, ComponentBuilder::ImageProvider*);
66 
67  //==============================================================================
69  RelativePoint gradientPoint1, gradientPoint2, gradientPoint3;
70  };
71 
72  //==============================================================================
80  void setFill (const FillType& newFill);
81 
89  void setFill (const RelativeFillType& newFill);
90 
94  const RelativeFillType& getFill() const noexcept { return mainFill; }
95 
99  void setStrokeFill (const FillType& newStrokeFill);
100 
104  void setStrokeFill (const RelativeFillType& newStrokeFill);
105 
109  const RelativeFillType& getStrokeFill() const noexcept { return strokeFill; }
110 
115  void setStrokeType (const PathStrokeType& newStrokeType);
116 
120  void setStrokeThickness (float newThickness);
121 
123  const PathStrokeType& getStrokeType() const noexcept { return strokeType; }
124 
125  //==============================================================================
128  {
129  public:
130  FillAndStrokeState (const ValueTree& state);
131 
132  ValueTree getFillState (const Identifier& fillOrStrokeType);
133  RelativeFillType getFill (const Identifier& fillOrStrokeType, ComponentBuilder::ImageProvider*) const;
134  void setFill (const Identifier& fillOrStrokeType, const RelativeFillType& newFill,
136 
137  PathStrokeType getStrokeType() const;
138  void setStrokeType (const PathStrokeType& newStrokeType, UndoManager*);
139 
140  static const Identifier type, colour, colours, fill, stroke, path, jointStyle, capStyle, strokeWidth,
141  gradientPoint1, gradientPoint2, gradientPoint3, radial, imageId, imageOpacity;
142  };
143 
145  Rectangle<float> getDrawableBounds() const override;
147  void paint (Graphics&) override;
149  bool hitTest (int x, int y) override;
151  bool replaceColour (Colour originalColour, Colour replacementColour) override;
152 
153 protected:
154  //==============================================================================
156  void pathChanged();
158  void strokeChanged();
160  bool isStrokeVisible() const noexcept;
162  void refreshFillTypes (const FillAndStrokeState& newState, ComponentBuilder::ImageProvider*);
164  void writeTo (FillAndStrokeState& state, ComponentBuilder::ImageProvider*, UndoManager*) const;
165 
166  //==============================================================================
167  PathStrokeType strokeType;
168  Path path, strokePath;
169 
170 private:
171  class RelativePositioner;
172  RelativeFillType mainFill, strokeFill;
173  ScopedPointer<RelativeCoordinatePositionerBase> mainFillPositioner, strokeFillPositioner;
174 
175  void setFillInternal (RelativeFillType& fill, const RelativeFillType& newFill,
177 
178  DrawableShape& operator= (const DrawableShape&);
179 };
180 
181 
182 #endif // JUCE_DRAWABLESHAPE_H_INCLUDED
Definition: juce_DrawableShape.h:50
RelativePoint gradientPoint3
Definition: juce_DrawableShape.h:69
Definition: juce_DrawableShape.h:36
#define noexcept
Definition: juce_CompilerSupport.h:141
friend class DrawableShape
Definition: juce_Drawable.h:208
Definition: juce_Expression.h:113
Definition: juce_PathStrokeType.h:39
#define JUCE_API
Definition: juce_StandardHeader.h:139
Definition: juce_RelativePoint.h:35
Definition: juce_Rectangle.h:36
const RelativeFillType & getStrokeFill() const noexcept
Definition: juce_DrawableShape.h:109
Definition: juce_DrawableShape.h:127
Definition: juce_Path.h:62
Definition: juce_Colour.h:35
Definition: juce_ScopedPointer.h:70
Definition: juce_FillType.h:38
Definition: juce_RelativeCoordinatePositioner.h:33
bool operator==(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:565
const PathStrokeType & getStrokeType() const noexcept
Definition: juce_DrawableShape.h:123
Definition: juce_ComponentBuilder.h:45
Definition: juce_Drawable.h:35
Definition: juce_GraphicsContext.h:42
FillType fill
Definition: juce_DrawableShape.h:68
Definition: juce_DrawableShape.cpp:45
Definition: juce_Drawable.h:185
const RelativeFillType & getFill() const noexcept
Definition: juce_DrawableShape.h:94
Definition: juce_ValueTree.h:64
Definition: juce_UndoManager.h:49
bool operator!=(const var &v1, const var &v2) noexcept
Definition: juce_Variant.cpp:566
static const Identifier type
Definition: juce_DrawableShape.h:140
Definition: juce_Identifier.h:43
Definition: juce_ComponentBuilder.h:183