mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-07 04:10:08 +00:00
Internal changes to drawable gradients. Fix for AudioFormat bug.
This commit is contained in:
parent
79b8ffa007
commit
d93a3a8ddf
11 changed files with 126 additions and 64 deletions
|
|
@ -85,7 +85,7 @@ bool AudioFormatReader::read (int** destSamples,
|
|||
{
|
||||
int* lastFullChannel = destSamples[0];
|
||||
|
||||
for (int i = numDestChannels; --i > 0;)
|
||||
for (int i = (int) numChannels; --i > 0;)
|
||||
{
|
||||
if (destSamples[i] != 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
#define JUCE_MAJOR_VERSION 1
|
||||
#define JUCE_MINOR_VERSION 52
|
||||
#define JUCE_BUILDNUMBER 24
|
||||
#define JUCE_BUILDNUMBER 25
|
||||
|
||||
/** Current Juce version number.
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ FillType::~FillType() throw()
|
|||
bool FillType::operator== (const FillType& other) const
|
||||
{
|
||||
return colour == other.colour && image == other.image
|
||||
&& transform == other.transform
|
||||
&& (gradient == other.gradient
|
||||
|| (gradient != 0 && other.gradient != 0 && *gradient == *other.gradient));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ const Identifier Drawable::ValueTreeWrapperBase::idProperty ("id");
|
|||
const Identifier Drawable::ValueTreeWrapperBase::type ("type");
|
||||
const Identifier Drawable::ValueTreeWrapperBase::gradientPoint1 ("point1");
|
||||
const Identifier Drawable::ValueTreeWrapperBase::gradientPoint2 ("point2");
|
||||
const Identifier Drawable::ValueTreeWrapperBase::gradientPoint3 ("point3");
|
||||
const Identifier Drawable::ValueTreeWrapperBase::colour ("colour");
|
||||
const Identifier Drawable::ValueTreeWrapperBase::radial ("radial");
|
||||
const Identifier Drawable::ValueTreeWrapperBase::colours ("colours");
|
||||
|
|
@ -196,7 +197,7 @@ void Drawable::ValueTreeWrapperBase::setID (const String& newID, UndoManager* co
|
|||
state.setProperty (idProperty, newID, undoManager);
|
||||
}
|
||||
|
||||
const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v, RelativePoint* const gp1, RelativePoint* const gp2,
|
||||
const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v, RelativePoint* const gp1, RelativePoint* const gp2, RelativePoint* const gp3,
|
||||
RelativeCoordinate::NamedCoordinateFinder* const nameFinder, ImageProvider* imageProvider)
|
||||
{
|
||||
const String newType (v[type].toString());
|
||||
|
|
@ -209,14 +210,13 @@ const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v,
|
|||
}
|
||||
else if (newType == "gradient")
|
||||
{
|
||||
RelativePoint p1 (v [gradientPoint1]), p2 (v [gradientPoint2]);
|
||||
RelativePoint p1 (v [gradientPoint1]), p2 (v [gradientPoint2]), p3 (v [gradientPoint3]);
|
||||
|
||||
ColourGradient g;
|
||||
|
||||
if (gp1 != 0)
|
||||
*gp1 = p1;
|
||||
if (gp2 != 0)
|
||||
*gp2 = p2;
|
||||
if (gp1 != 0) *gp1 = p1;
|
||||
if (gp2 != 0) *gp2 = p2;
|
||||
if (gp3 != 0) *gp3 = p3;
|
||||
|
||||
g.point1 = p1.resolve (nameFinder);
|
||||
g.point2 = p2.resolve (nameFinder);
|
||||
|
|
@ -229,7 +229,20 @@ const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v,
|
|||
g.addColour (colourSteps[i * 2].getDoubleValue(),
|
||||
Colour ((uint32) colourSteps[i * 2 + 1].getHexValue32()));
|
||||
|
||||
return FillType (g);
|
||||
FillType fillType (g);
|
||||
|
||||
if (g.isRadial)
|
||||
{
|
||||
const Point<float> point3 (p3.resolve (nameFinder));
|
||||
const Point<float> point3Source (g.point1.getX() + g.point2.getY() - g.point1.getY(),
|
||||
g.point1.getY() + g.point1.getX() - g.point2.getX());
|
||||
|
||||
fillType.transform = AffineTransform::fromTargetPoints (g.point1.getX(), g.point1.getY(), g.point1.getX(), g.point1.getY(),
|
||||
g.point2.getX(), g.point2.getY(), g.point2.getX(), g.point2.getY(),
|
||||
point3Source.getX(), point3Source.getY(), point3.getX(), point3.getY());
|
||||
}
|
||||
|
||||
return fillType;
|
||||
}
|
||||
else if (newType == "image")
|
||||
{
|
||||
|
|
@ -246,8 +259,17 @@ const FillType Drawable::ValueTreeWrapperBase::readFillType (const ValueTree& v,
|
|||
return FillType();
|
||||
}
|
||||
|
||||
static const Point<float> calcThirdGradientPoint (const FillType& fillType)
|
||||
{
|
||||
const ColourGradient& g = *fillType.gradient;
|
||||
const Point<float> point3Source (g.point1.getX() + g.point2.getY() - g.point1.getY(),
|
||||
g.point1.getY() + g.point1.getX() - g.point2.getX());
|
||||
|
||||
return point3Source.transformedBy (fillType.transform);
|
||||
}
|
||||
|
||||
void Drawable::ValueTreeWrapperBase::writeFillType (ValueTree& v, const FillType& fillType,
|
||||
const RelativePoint* const gp1, const RelativePoint* const gp2,
|
||||
const RelativePoint* const gp1, const RelativePoint* const gp2, const RelativePoint* gp3,
|
||||
ImageProvider* imageProvider, UndoManager* const undoManager)
|
||||
{
|
||||
if (fillType.isColour())
|
||||
|
|
@ -260,6 +282,8 @@ void Drawable::ValueTreeWrapperBase::writeFillType (ValueTree& v, const FillType
|
|||
v.setProperty (type, "gradient", undoManager);
|
||||
v.setProperty (gradientPoint1, gp1 != 0 ? gp1->toString() : fillType.gradient->point1.toString(), undoManager);
|
||||
v.setProperty (gradientPoint2, gp2 != 0 ? gp2->toString() : fillType.gradient->point2.toString(), undoManager);
|
||||
v.setProperty (gradientPoint3, gp3 != 0 ? gp3->toString() : calcThirdGradientPoint (fillType).toString(), undoManager);
|
||||
|
||||
v.setProperty (radial, fillType.gradient->isRadial, undoManager);
|
||||
|
||||
String s;
|
||||
|
|
|
|||
|
|
@ -248,17 +248,19 @@ public:
|
|||
void setID (const String& newID, UndoManager* undoManager);
|
||||
static const Identifier idProperty;
|
||||
|
||||
static const FillType readFillType (const ValueTree& v, RelativePoint* gradientPoint1, RelativePoint* gradientPoint2,
|
||||
static const FillType readFillType (const ValueTree& v, RelativePoint* gradientPoint1,
|
||||
RelativePoint* gradientPoint2, RelativePoint* gradientPoint3,
|
||||
RelativeCoordinate::NamedCoordinateFinder* nameFinder,
|
||||
ImageProvider* imageProvider);
|
||||
|
||||
static void writeFillType (ValueTree& v, const FillType& fillType,
|
||||
const RelativePoint* gradientPoint1, const RelativePoint* gradientPoint2,
|
||||
ImageProvider* imageProvider,
|
||||
const RelativePoint* gradientPoint3, ImageProvider* imageProvider,
|
||||
UndoManager* undoManager);
|
||||
|
||||
ValueTree state;
|
||||
static const Identifier type, gradientPoint1, gradientPoint2, colour, radial, colours, imageId, imageOpacity;
|
||||
static const Identifier type, gradientPoint1, gradientPoint2, gradientPoint3,
|
||||
colour, radial, colours, imageId, imageOpacity;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ ValueTree DrawablePath::ValueTreeWrapper::getMainFillState()
|
|||
if (v.isValid())
|
||||
return v;
|
||||
|
||||
setMainFill (Colours::black, 0, 0, 0, 0);
|
||||
setMainFill (Colours::black, 0, 0, 0, 0, 0);
|
||||
return getMainFillState();
|
||||
}
|
||||
|
||||
|
|
@ -222,34 +222,36 @@ ValueTree DrawablePath::ValueTreeWrapper::getStrokeFillState()
|
|||
if (v.isValid())
|
||||
return v;
|
||||
|
||||
setStrokeFill (Colours::black, 0, 0, 0, 0);
|
||||
setStrokeFill (Colours::black, 0, 0, 0, 0, 0);
|
||||
return getStrokeFillState();
|
||||
}
|
||||
|
||||
const FillType DrawablePath::ValueTreeWrapper::getMainFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
|
||||
ImageProvider* imageProvider) const
|
||||
{
|
||||
return readFillType (state.getChildWithName (fill), 0, 0, nameFinder, imageProvider);
|
||||
return readFillType (state.getChildWithName (fill), 0, 0, 0, nameFinder, imageProvider);
|
||||
}
|
||||
|
||||
void DrawablePath::ValueTreeWrapper::setMainFill (const FillType& newFill, const RelativePoint* gp1,
|
||||
const RelativePoint* gp2, ImageProvider* imageProvider, UndoManager* undoManager)
|
||||
const RelativePoint* gp2, const RelativePoint* gp3,
|
||||
ImageProvider* imageProvider, UndoManager* undoManager)
|
||||
{
|
||||
ValueTree v (state.getOrCreateChildWithName (fill, undoManager));
|
||||
writeFillType (v, newFill, gp1, gp2, imageProvider, undoManager);
|
||||
writeFillType (v, newFill, gp1, gp2, gp3, imageProvider, undoManager);
|
||||
}
|
||||
|
||||
const FillType DrawablePath::ValueTreeWrapper::getStrokeFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
|
||||
ImageProvider* imageProvider) const
|
||||
{
|
||||
return readFillType (state.getChildWithName (stroke), 0, 0, nameFinder, imageProvider);
|
||||
return readFillType (state.getChildWithName (stroke), 0, 0, 0, nameFinder, imageProvider);
|
||||
}
|
||||
|
||||
void DrawablePath::ValueTreeWrapper::setStrokeFill (const FillType& newFill, const RelativePoint* gp1,
|
||||
const RelativePoint* gp2, ImageProvider* imageProvider, UndoManager* undoManager)
|
||||
const RelativePoint* gp2, const RelativePoint* gp3,
|
||||
ImageProvider* imageProvider, UndoManager* undoManager)
|
||||
{
|
||||
ValueTree v (state.getOrCreateChildWithName (stroke, undoManager));
|
||||
writeFillType (v, newFill, gp1, gp2, imageProvider, undoManager);
|
||||
writeFillType (v, newFill, gp1, gp2, gp3, imageProvider, undoManager);
|
||||
}
|
||||
|
||||
const PathStrokeType DrawablePath::ValueTreeWrapper::getStrokeType() const
|
||||
|
|
@ -401,8 +403,8 @@ const ValueTree DrawablePath::createValueTree (ImageProvider* imageProvider) con
|
|||
ValueTreeWrapper v (tree);
|
||||
|
||||
v.setID (getName(), 0);
|
||||
v.setMainFill (mainFill, 0, 0, imageProvider, 0);
|
||||
v.setStrokeFill (strokeFill, 0, 0, imageProvider, 0);
|
||||
v.setMainFill (mainFill, 0, 0, 0, imageProvider, 0);
|
||||
v.setStrokeFill (strokeFill, 0, 0, 0, imageProvider, 0);
|
||||
v.setStrokeType (strokeType, 0);
|
||||
|
||||
if (relativePath != 0)
|
||||
|
|
|
|||
|
|
@ -132,13 +132,15 @@ public:
|
|||
const FillType getMainFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
|
||||
ImageProvider* imageProvider) const;
|
||||
ValueTree getMainFillState();
|
||||
void setMainFill (const FillType& newFill, const RelativePoint* gradientPoint1, const RelativePoint* gradientPoint2,
|
||||
void setMainFill (const FillType& newFill, const RelativePoint* gradientPoint1,
|
||||
const RelativePoint* gradientPoint2, const RelativePoint* gradientPoint3,
|
||||
ImageProvider* imageProvider, UndoManager* undoManager);
|
||||
|
||||
const FillType getStrokeFill (RelativeCoordinate::NamedCoordinateFinder* nameFinder,
|
||||
ImageProvider* imageProvider) const;
|
||||
ValueTree getStrokeFillState();
|
||||
void setStrokeFill (const FillType& newFill, const RelativePoint* gradientPoint1, const RelativePoint* gradientPoint2,
|
||||
void setStrokeFill (const FillType& newFill, const RelativePoint* gradientPoint1,
|
||||
const RelativePoint* gradientPoint2, const RelativePoint* gradientPoint3,
|
||||
ImageProvider* imageProvider, UndoManager* undoManager);
|
||||
|
||||
const PathStrokeType getStrokeType() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue