mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-01 03:10:06 +00:00
Tidied a few static functions away into private namespaces.
This commit is contained in:
parent
e1f3c2df6f
commit
038886510a
15 changed files with 1564 additions and 1594 deletions
|
|
@ -41,58 +41,61 @@ KeyboardFocusTraverser::~KeyboardFocusTraverser()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
// This will sort a set of components, so that they are ordered in terms of
|
||||
// left-to-right and then top-to-bottom.
|
||||
class ScreenPositionComparator
|
||||
namespace KeyboardFocusHelpers
|
||||
{
|
||||
public:
|
||||
ScreenPositionComparator() {}
|
||||
|
||||
static int compareElements (const Component* const first, const Component* const second) throw()
|
||||
// This will sort a set of components, so that they are ordered in terms of
|
||||
// left-to-right and then top-to-bottom.
|
||||
class ScreenPositionComparator
|
||||
{
|
||||
int explicitOrder1 = first->getExplicitFocusOrder();
|
||||
if (explicitOrder1 <= 0)
|
||||
explicitOrder1 = std::numeric_limits<int>::max() / 2;
|
||||
public:
|
||||
ScreenPositionComparator() {}
|
||||
|
||||
int explicitOrder2 = second->getExplicitFocusOrder();
|
||||
if (explicitOrder2 <= 0)
|
||||
explicitOrder2 = std::numeric_limits<int>::max() / 2;
|
||||
|
||||
if (explicitOrder1 != explicitOrder2)
|
||||
return explicitOrder1 - explicitOrder2;
|
||||
|
||||
const int diff = first->getY() - second->getY();
|
||||
|
||||
return (diff == 0) ? first->getX() - second->getX()
|
||||
: diff;
|
||||
}
|
||||
};
|
||||
|
||||
static void findAllFocusableComponents (Component* const parent, Array <Component*>& comps)
|
||||
{
|
||||
if (parent->getNumChildComponents() > 0)
|
||||
{
|
||||
Array <Component*> localComps;
|
||||
ScreenPositionComparator comparator;
|
||||
|
||||
int i;
|
||||
for (i = parent->getNumChildComponents(); --i >= 0;)
|
||||
static int compareElements (const Component* const first, const Component* const second) throw()
|
||||
{
|
||||
Component* const c = parent->getChildComponent (i);
|
||||
int explicitOrder1 = first->getExplicitFocusOrder();
|
||||
if (explicitOrder1 <= 0)
|
||||
explicitOrder1 = std::numeric_limits<int>::max() / 2;
|
||||
|
||||
if (c->isVisible() && c->isEnabled())
|
||||
localComps.addSorted (comparator, c);
|
||||
int explicitOrder2 = second->getExplicitFocusOrder();
|
||||
if (explicitOrder2 <= 0)
|
||||
explicitOrder2 = std::numeric_limits<int>::max() / 2;
|
||||
|
||||
if (explicitOrder1 != explicitOrder2)
|
||||
return explicitOrder1 - explicitOrder2;
|
||||
|
||||
const int diff = first->getY() - second->getY();
|
||||
|
||||
return (diff == 0) ? first->getX() - second->getX()
|
||||
: diff;
|
||||
}
|
||||
};
|
||||
|
||||
for (i = 0; i < localComps.size(); ++i)
|
||||
static void findAllFocusableComponents (Component* const parent, Array <Component*>& comps)
|
||||
{
|
||||
if (parent->getNumChildComponents() > 0)
|
||||
{
|
||||
Component* const c = localComps.getUnchecked (i);
|
||||
Array <Component*> localComps;
|
||||
ScreenPositionComparator comparator;
|
||||
|
||||
if (c->getWantsKeyboardFocus())
|
||||
comps.add (c);
|
||||
int i;
|
||||
for (i = parent->getNumChildComponents(); --i >= 0;)
|
||||
{
|
||||
Component* const c = parent->getChildComponent (i);
|
||||
|
||||
if (! c->isFocusContainer())
|
||||
findAllFocusableComponents (c, comps);
|
||||
if (c->isVisible() && c->isEnabled())
|
||||
localComps.addSorted (comparator, c);
|
||||
}
|
||||
|
||||
for (i = 0; i < localComps.size(); ++i)
|
||||
{
|
||||
Component* const c = localComps.getUnchecked (i);
|
||||
|
||||
if (c->getWantsKeyboardFocus())
|
||||
comps.add (c);
|
||||
|
||||
if (! c->isFocusContainer())
|
||||
findAllFocusableComponents (c, comps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -109,7 +112,7 @@ static Component* getIncrementedComponent (Component* const current, const int d
|
|||
if (focusContainer != 0)
|
||||
{
|
||||
Array <Component*> comps;
|
||||
findAllFocusableComponents (focusContainer, comps);
|
||||
KeyboardFocusHelpers::findAllFocusableComponents (focusContainer, comps);
|
||||
|
||||
if (comps.size() > 0)
|
||||
{
|
||||
|
|
@ -137,7 +140,7 @@ Component* KeyboardFocusTraverser::getDefaultComponent (Component* parentCompone
|
|||
Array <Component*> comps;
|
||||
|
||||
if (parentComponent != 0)
|
||||
findAllFocusableComponents (parentComponent, comps);
|
||||
KeyboardFocusHelpers::findAllFocusableComponents (parentComponent, comps);
|
||||
|
||||
return comps.getFirst();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,17 +34,6 @@ BEGIN_JUCE_NAMESPACE
|
|||
|
||||
const int juce_edgeTableDefaultEdgesPerLine = 32;
|
||||
|
||||
//==============================================================================
|
||||
static void copyEdgeTableData (int* dest, const int destLineStride, const int* src, const int srcLineStride, int numLines) throw()
|
||||
{
|
||||
while (--numLines >= 0)
|
||||
{
|
||||
memcpy (dest, src, (src[0] * 2 + 1) * sizeof (int));
|
||||
src += srcLineStride;
|
||||
dest += destLineStride;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
EdgeTable::EdgeTable (const Rectangle<int>& bounds_,
|
||||
const Path& path, const AffineTransform& transform) throw()
|
||||
|
|
@ -277,6 +266,16 @@ EdgeTable::~EdgeTable() throw()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void EdgeTable::copyEdgeTableData (int* dest, const int destLineStride, const int* src, const int srcLineStride, int numLines) throw()
|
||||
{
|
||||
while (--numLines >= 0)
|
||||
{
|
||||
memcpy (dest, src, (src[0] * 2 + 1) * sizeof (int));
|
||||
src += srcLineStride;
|
||||
dest += destLineStride;
|
||||
}
|
||||
}
|
||||
|
||||
void EdgeTable::sanitiseLevels (const bool useNonZeroWinding) throw()
|
||||
{
|
||||
// Convert the table from relative windings to absolute levels..
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ private:
|
|||
void intersectWithEdgeTableLine (const int y, const int* otherLine) throw();
|
||||
void clipEdgeTableLineToRange (int* line, int x1, int x2) throw();
|
||||
void sanitiseLevels (const bool useNonZeroWinding) throw();
|
||||
static void copyEdgeTableData (int* dest, const int destLineStride, const int* src, const int srcLineStride, int numLines) throw();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -191,283 +191,286 @@ static bool lineIntersection (const float x1, const float y1,
|
|||
return true;
|
||||
}
|
||||
|
||||
// part of stroke drawing stuff
|
||||
static void addEdgeAndJoint (Path& destPath,
|
||||
const PathStrokeType::JointStyle style,
|
||||
const float maxMiterExtensionSquared, const float width,
|
||||
const float x1, const float y1,
|
||||
const float x2, const float y2,
|
||||
const float x3, const float y3,
|
||||
const float x4, const float y4,
|
||||
const float midX, const float midY) throw()
|
||||
namespace PathFunctions
|
||||
{
|
||||
if (style == PathStrokeType::beveled
|
||||
|| (x3 == x4 && y3 == y4)
|
||||
|| (x1 == x2 && y1 == y2))
|
||||
// part of stroke drawing stuff
|
||||
static void addEdgeAndJoint (Path& destPath,
|
||||
const PathStrokeType::JointStyle style,
|
||||
const float maxMiterExtensionSquared, const float width,
|
||||
const float x1, const float y1,
|
||||
const float x2, const float y2,
|
||||
const float x3, const float y3,
|
||||
const float x4, const float y4,
|
||||
const float midX, const float midY)
|
||||
{
|
||||
destPath.lineTo (x2, y2);
|
||||
destPath.lineTo (x3, y3);
|
||||
}
|
||||
else
|
||||
{
|
||||
float jx, jy, distanceBeyondLine1EndSquared;
|
||||
|
||||
// if they intersect, use this point..
|
||||
if (lineIntersection (x1, y1, x2, y2,
|
||||
x3, y3, x4, y4,
|
||||
jx, jy, distanceBeyondLine1EndSquared))
|
||||
if (style == PathStrokeType::beveled
|
||||
|| (x3 == x4 && y3 == y4)
|
||||
|| (x1 == x2 && y1 == y2))
|
||||
{
|
||||
destPath.lineTo (jx, jy);
|
||||
destPath.lineTo (x2, y2);
|
||||
destPath.lineTo (x3, y3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (style == PathStrokeType::mitered)
|
||||
float jx, jy, distanceBeyondLine1EndSquared;
|
||||
|
||||
// if they intersect, use this point..
|
||||
if (lineIntersection (x1, y1, x2, y2,
|
||||
x3, y3, x4, y4,
|
||||
jx, jy, distanceBeyondLine1EndSquared))
|
||||
{
|
||||
if (distanceBeyondLine1EndSquared < maxMiterExtensionSquared
|
||||
&& distanceBeyondLine1EndSquared > 0.0f)
|
||||
{
|
||||
destPath.lineTo (jx, jy);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the end sticks out too far, so just use a blunt joint
|
||||
destPath.lineTo (x2, y2);
|
||||
destPath.lineTo (x3, y3);
|
||||
}
|
||||
destPath.lineTo (jx, jy);
|
||||
}
|
||||
else
|
||||
{
|
||||
// curved joints
|
||||
float angle1 = atan2f (x2 - midX, y2 - midY);
|
||||
float angle2 = atan2f (x3 - midX, y3 - midY);
|
||||
const float angleIncrement = 0.1f;
|
||||
|
||||
destPath.lineTo (x2, y2);
|
||||
|
||||
if (fabs (angle1 - angle2) > angleIncrement)
|
||||
if (style == PathStrokeType::mitered)
|
||||
{
|
||||
if (angle2 > angle1 + float_Pi
|
||||
|| (angle2 < angle1 && angle2 >= angle1 - float_Pi))
|
||||
if (distanceBeyondLine1EndSquared < maxMiterExtensionSquared
|
||||
&& distanceBeyondLine1EndSquared > 0.0f)
|
||||
{
|
||||
if (angle2 > angle1)
|
||||
angle2 -= float_Pi * 2.0f;
|
||||
|
||||
jassert (angle1 <= angle2 + float_Pi);
|
||||
|
||||
angle1 -= angleIncrement;
|
||||
while (angle1 > angle2)
|
||||
{
|
||||
destPath.lineTo (midX + width * sinf (angle1),
|
||||
midY + width * cosf (angle1));
|
||||
|
||||
angle1 -= angleIncrement;
|
||||
}
|
||||
destPath.lineTo (jx, jy);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (angle1 > angle2)
|
||||
angle1 -= float_Pi * 2.0f;
|
||||
|
||||
jassert (angle1 >= angle2 - float_Pi);
|
||||
|
||||
angle1 += angleIncrement;
|
||||
while (angle1 < angle2)
|
||||
{
|
||||
destPath.lineTo (midX + width * sinf (angle1),
|
||||
midY + width * cosf (angle1));
|
||||
|
||||
angle1 += angleIncrement;
|
||||
}
|
||||
// the end sticks out too far, so just use a blunt joint
|
||||
destPath.lineTo (x2, y2);
|
||||
destPath.lineTo (x3, y3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// curved joints
|
||||
float angle1 = atan2f (x2 - midX, y2 - midY);
|
||||
float angle2 = atan2f (x3 - midX, y3 - midY);
|
||||
const float angleIncrement = 0.1f;
|
||||
|
||||
destPath.lineTo (x3, y3);
|
||||
destPath.lineTo (x2, y2);
|
||||
|
||||
if (fabs (angle1 - angle2) > angleIncrement)
|
||||
{
|
||||
if (angle2 > angle1 + float_Pi
|
||||
|| (angle2 < angle1 && angle2 >= angle1 - float_Pi))
|
||||
{
|
||||
if (angle2 > angle1)
|
||||
angle2 -= float_Pi * 2.0f;
|
||||
|
||||
jassert (angle1 <= angle2 + float_Pi);
|
||||
|
||||
angle1 -= angleIncrement;
|
||||
while (angle1 > angle2)
|
||||
{
|
||||
destPath.lineTo (midX + width * sinf (angle1),
|
||||
midY + width * cosf (angle1));
|
||||
|
||||
angle1 -= angleIncrement;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (angle1 > angle2)
|
||||
angle1 -= float_Pi * 2.0f;
|
||||
|
||||
jassert (angle1 >= angle2 - float_Pi);
|
||||
|
||||
angle1 += angleIncrement;
|
||||
while (angle1 < angle2)
|
||||
{
|
||||
destPath.lineTo (midX + width * sinf (angle1),
|
||||
midY + width * cosf (angle1));
|
||||
|
||||
angle1 += angleIncrement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
destPath.lineTo (x3, y3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void addLineEnd (Path& destPath,
|
||||
const PathStrokeType::EndCapStyle style,
|
||||
const float x1, const float y1,
|
||||
const float x2, const float y2,
|
||||
const float width) throw()
|
||||
{
|
||||
if (style == PathStrokeType::butt)
|
||||
static void addLineEnd (Path& destPath,
|
||||
const PathStrokeType::EndCapStyle style,
|
||||
const float x1, const float y1,
|
||||
const float x2, const float y2,
|
||||
const float width)
|
||||
{
|
||||
destPath.lineTo (x2, y2);
|
||||
}
|
||||
else
|
||||
{
|
||||
float offx1, offy1, offx2, offy2;
|
||||
|
||||
float dx = x2 - x1;
|
||||
float dy = y2 - y1;
|
||||
const float len = juce_hypotf (dx, dy);
|
||||
|
||||
if (len == 0)
|
||||
if (style == PathStrokeType::butt)
|
||||
{
|
||||
offx1 = offx2 = x1;
|
||||
offy1 = offy2 = y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const float offset = width / len;
|
||||
dx *= offset;
|
||||
dy *= offset;
|
||||
|
||||
offx1 = x1 + dy;
|
||||
offy1 = y1 - dx;
|
||||
offx2 = x2 + dy;
|
||||
offy2 = y2 - dx;
|
||||
}
|
||||
|
||||
if (style == PathStrokeType::square)
|
||||
{
|
||||
// sqaure ends
|
||||
destPath.lineTo (offx1, offy1);
|
||||
destPath.lineTo (offx2, offy2);
|
||||
destPath.lineTo (x2, y2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// rounded ends
|
||||
const float midx = (offx1 + offx2) * 0.5f;
|
||||
const float midy = (offy1 + offy2) * 0.5f;
|
||||
float offx1, offy1, offx2, offy2;
|
||||
|
||||
destPath.cubicTo (x1 + (offx1 - x1) * 0.55f, y1 + (offy1 - y1) * 0.55f,
|
||||
offx1 + (midx - offx1) * 0.45f, offy1 + (midy - offy1) * 0.45f,
|
||||
midx, midy);
|
||||
float dx = x2 - x1;
|
||||
float dy = y2 - y1;
|
||||
const float len = juce_hypotf (dx, dy);
|
||||
|
||||
destPath.cubicTo (midx + (offx2 - midx) * 0.55f, midy + (offy2 - midy) * 0.55f,
|
||||
offx2 + (x2 - offx2) * 0.45f, offy2 + (y2 - offy2) * 0.45f,
|
||||
x2, y2);
|
||||
if (len == 0)
|
||||
{
|
||||
offx1 = offx2 = x1;
|
||||
offy1 = offy2 = y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const float offset = width / len;
|
||||
dx *= offset;
|
||||
dy *= offset;
|
||||
|
||||
offx1 = x1 + dy;
|
||||
offy1 = y1 - dx;
|
||||
offx2 = x2 + dy;
|
||||
offy2 = y2 - dx;
|
||||
}
|
||||
|
||||
if (style == PathStrokeType::square)
|
||||
{
|
||||
// sqaure ends
|
||||
destPath.lineTo (offx1, offy1);
|
||||
destPath.lineTo (offx2, offy2);
|
||||
destPath.lineTo (x2, y2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// rounded ends
|
||||
const float midx = (offx1 + offx2) * 0.5f;
|
||||
const float midy = (offy1 + offy2) * 0.5f;
|
||||
|
||||
destPath.cubicTo (x1 + (offx1 - x1) * 0.55f, y1 + (offy1 - y1) * 0.55f,
|
||||
offx1 + (midx - offx1) * 0.45f, offy1 + (midy - offy1) * 0.45f,
|
||||
midx, midy);
|
||||
|
||||
destPath.cubicTo (midx + (offx2 - midx) * 0.55f, midy + (offy2 - midy) * 0.55f,
|
||||
offx2 + (x2 - offx2) * 0.45f, offy2 + (y2 - offy2) * 0.45f,
|
||||
x2, y2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct LineSection
|
||||
{
|
||||
LineSection() {}
|
||||
LineSection (int) {}
|
||||
|
||||
float x1, y1, x2, y2; // original line
|
||||
float lx1, ly1, lx2, ly2; // the left-hand stroke
|
||||
float rx1, ry1, rx2, ry2; // the right-hand stroke
|
||||
};
|
||||
|
||||
static void addSubPath (Path& destPath, const Array <LineSection>& subPath,
|
||||
const bool isClosed,
|
||||
const float width, const float maxMiterExtensionSquared,
|
||||
const PathStrokeType::JointStyle jointStyle, const PathStrokeType::EndCapStyle endStyle) throw()
|
||||
{
|
||||
jassert (subPath.size() > 0);
|
||||
|
||||
const LineSection& firstLine = subPath.getReference (0);
|
||||
|
||||
float lastX1 = firstLine.lx1;
|
||||
float lastY1 = firstLine.ly1;
|
||||
float lastX2 = firstLine.lx2;
|
||||
float lastY2 = firstLine.ly2;
|
||||
|
||||
if (isClosed)
|
||||
struct LineSection
|
||||
{
|
||||
destPath.startNewSubPath (lastX1, lastY1);
|
||||
}
|
||||
else
|
||||
LineSection() {}
|
||||
LineSection (int) {}
|
||||
|
||||
float x1, y1, x2, y2; // original line
|
||||
float lx1, ly1, lx2, ly2; // the left-hand stroke
|
||||
float rx1, ry1, rx2, ry2; // the right-hand stroke
|
||||
};
|
||||
|
||||
static void addSubPath (Path& destPath, const Array <LineSection>& subPath,
|
||||
const bool isClosed,
|
||||
const float width, const float maxMiterExtensionSquared,
|
||||
const PathStrokeType::JointStyle jointStyle, const PathStrokeType::EndCapStyle endStyle)
|
||||
{
|
||||
destPath.startNewSubPath (firstLine.rx2, firstLine.ry2);
|
||||
jassert (subPath.size() > 0);
|
||||
|
||||
addLineEnd (destPath, endStyle,
|
||||
firstLine.rx2, firstLine.ry2,
|
||||
lastX1, lastY1,
|
||||
width);
|
||||
}
|
||||
const LineSection& firstLine = subPath.getReference (0);
|
||||
|
||||
int i;
|
||||
for (i = 1; i < subPath.size(); ++i)
|
||||
{
|
||||
const LineSection& l = subPath.getReference (i);
|
||||
float lastX1 = firstLine.lx1;
|
||||
float lastY1 = firstLine.ly1;
|
||||
float lastX2 = firstLine.lx2;
|
||||
float lastY2 = firstLine.ly2;
|
||||
|
||||
addEdgeAndJoint (destPath, jointStyle,
|
||||
maxMiterExtensionSquared, width,
|
||||
lastX1, lastY1, lastX2, lastY2,
|
||||
l.lx1, l.ly1, l.lx2, l.ly2,
|
||||
l.x1, l.y1);
|
||||
if (isClosed)
|
||||
{
|
||||
destPath.startNewSubPath (lastX1, lastY1);
|
||||
}
|
||||
else
|
||||
{
|
||||
destPath.startNewSubPath (firstLine.rx2, firstLine.ry2);
|
||||
|
||||
lastX1 = l.lx1;
|
||||
lastY1 = l.ly1;
|
||||
lastX2 = l.lx2;
|
||||
lastY2 = l.ly2;
|
||||
}
|
||||
addLineEnd (destPath, endStyle,
|
||||
firstLine.rx2, firstLine.ry2,
|
||||
lastX1, lastY1,
|
||||
width);
|
||||
}
|
||||
|
||||
const LineSection& lastLine = subPath.getReference (subPath.size() - 1);
|
||||
int i;
|
||||
for (i = 1; i < subPath.size(); ++i)
|
||||
{
|
||||
const LineSection& l = subPath.getReference (i);
|
||||
|
||||
if (isClosed)
|
||||
{
|
||||
const LineSection& l = subPath.getReference (0);
|
||||
addEdgeAndJoint (destPath, jointStyle,
|
||||
maxMiterExtensionSquared, width,
|
||||
lastX1, lastY1, lastX2, lastY2,
|
||||
l.lx1, l.ly1, l.lx2, l.ly2,
|
||||
l.x1, l.y1);
|
||||
|
||||
addEdgeAndJoint (destPath, jointStyle,
|
||||
maxMiterExtensionSquared, width,
|
||||
lastX1, lastY1, lastX2, lastY2,
|
||||
l.lx1, l.ly1, l.lx2, l.ly2,
|
||||
l.x1, l.y1);
|
||||
lastX1 = l.lx1;
|
||||
lastY1 = l.ly1;
|
||||
lastX2 = l.lx2;
|
||||
lastY2 = l.ly2;
|
||||
}
|
||||
|
||||
const LineSection& lastLine = subPath.getReference (subPath.size() - 1);
|
||||
|
||||
if (isClosed)
|
||||
{
|
||||
const LineSection& l = subPath.getReference (0);
|
||||
|
||||
addEdgeAndJoint (destPath, jointStyle,
|
||||
maxMiterExtensionSquared, width,
|
||||
lastX1, lastY1, lastX2, lastY2,
|
||||
l.lx1, l.ly1, l.lx2, l.ly2,
|
||||
l.x1, l.y1);
|
||||
|
||||
destPath.closeSubPath();
|
||||
destPath.startNewSubPath (lastLine.rx1, lastLine.ry1);
|
||||
}
|
||||
else
|
||||
{
|
||||
destPath.lineTo (lastX2, lastY2);
|
||||
|
||||
addLineEnd (destPath, endStyle,
|
||||
lastX2, lastY2,
|
||||
lastLine.rx1, lastLine.ry1,
|
||||
width);
|
||||
}
|
||||
|
||||
lastX1 = lastLine.rx1;
|
||||
lastY1 = lastLine.ry1;
|
||||
lastX2 = lastLine.rx2;
|
||||
lastY2 = lastLine.ry2;
|
||||
|
||||
for (i = subPath.size() - 1; --i >= 0;)
|
||||
{
|
||||
const LineSection& l = subPath.getReference (i);
|
||||
|
||||
addEdgeAndJoint (destPath, jointStyle,
|
||||
maxMiterExtensionSquared, width,
|
||||
lastX1, lastY1, lastX2, lastY2,
|
||||
l.rx1, l.ry1, l.rx2, l.ry2,
|
||||
l.x2, l.y2);
|
||||
|
||||
lastX1 = l.rx1;
|
||||
lastY1 = l.ry1;
|
||||
lastX2 = l.rx2;
|
||||
lastY2 = l.ry2;
|
||||
}
|
||||
|
||||
if (isClosed)
|
||||
{
|
||||
addEdgeAndJoint (destPath, jointStyle,
|
||||
maxMiterExtensionSquared, width,
|
||||
lastX1, lastY1, lastX2, lastY2,
|
||||
lastLine.rx1, lastLine.ry1, lastLine.rx2, lastLine.ry2,
|
||||
lastLine.x2, lastLine.y2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// do the last line
|
||||
destPath.lineTo (lastX2, lastY2);
|
||||
}
|
||||
|
||||
destPath.closeSubPath();
|
||||
destPath.startNewSubPath (lastLine.rx1, lastLine.ry1);
|
||||
}
|
||||
else
|
||||
{
|
||||
destPath.lineTo (lastX2, lastY2);
|
||||
|
||||
addLineEnd (destPath, endStyle,
|
||||
lastX2, lastY2,
|
||||
lastLine.rx1, lastLine.ry1,
|
||||
width);
|
||||
}
|
||||
|
||||
lastX1 = lastLine.rx1;
|
||||
lastY1 = lastLine.ry1;
|
||||
lastX2 = lastLine.rx2;
|
||||
lastY2 = lastLine.ry2;
|
||||
|
||||
for (i = subPath.size() - 1; --i >= 0;)
|
||||
{
|
||||
const LineSection& l = subPath.getReference (i);
|
||||
|
||||
addEdgeAndJoint (destPath, jointStyle,
|
||||
maxMiterExtensionSquared, width,
|
||||
lastX1, lastY1, lastX2, lastY2,
|
||||
l.rx1, l.ry1, l.rx2, l.ry2,
|
||||
l.x2, l.y2);
|
||||
|
||||
lastX1 = l.rx1;
|
||||
lastY1 = l.ry1;
|
||||
lastX2 = l.rx2;
|
||||
lastY2 = l.ry2;
|
||||
}
|
||||
|
||||
if (isClosed)
|
||||
{
|
||||
addEdgeAndJoint (destPath, jointStyle,
|
||||
maxMiterExtensionSquared, width,
|
||||
lastX1, lastY1, lastX2, lastY2,
|
||||
lastLine.rx1, lastLine.ry1, lastLine.rx2, lastLine.ry2,
|
||||
lastLine.x2, lastLine.y2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// do the last line
|
||||
destPath.lineTo (lastX2, lastY2);
|
||||
}
|
||||
|
||||
destPath.closeSubPath();
|
||||
}
|
||||
|
||||
void PathStrokeType::createStrokedPath (Path& destPath,
|
||||
const Path& source,
|
||||
const AffineTransform& transform,
|
||||
const float extraAccuracy) const throw()
|
||||
const float extraAccuracy) const
|
||||
{
|
||||
if (thickness <= 0)
|
||||
{
|
||||
|
|
@ -497,6 +500,7 @@ void PathStrokeType::createStrokedPath (Path& destPath,
|
|||
// left/right-hand lines along either side of it...
|
||||
PathFlatteningIterator it (*sourcePath, transform, 9.0f / extraAccuracy);
|
||||
|
||||
using namespace PathFunctions;
|
||||
Array <LineSection> subPath;
|
||||
LineSection l;
|
||||
l.x1 = 0;
|
||||
|
|
@ -576,7 +580,7 @@ void PathStrokeType::createDashedStroke (Path& destPath,
|
|||
const float* dashLengths,
|
||||
int numDashLengths,
|
||||
const AffineTransform& transform,
|
||||
const float extraAccuracy) const throw()
|
||||
const float extraAccuracy) const
|
||||
{
|
||||
if (thickness <= 0)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public:
|
|||
void createStrokedPath (Path& destPath,
|
||||
const Path& sourcePath,
|
||||
const AffineTransform& transform = AffineTransform::identity,
|
||||
const float extraAccuracy = 1.0f) const throw();
|
||||
const float extraAccuracy = 1.0f) const;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -135,7 +135,7 @@ public:
|
|||
const float* dashLengths,
|
||||
int numDashLengths,
|
||||
const AffineTransform& transform = AffineTransform::identity,
|
||||
const float extraAccuracy = 1.0f) const throw();
|
||||
const float extraAccuracy = 1.0f) const;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the stroke thickness. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue