mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-25 02:04:23 +00:00
New method Array::resize(). Tweaked AudioThumbnail to avoid clearing the input source when loaded. New class SingleThreadedReferenceCountedObject (and used this for Font, Typeface, Expression, Value and ValueTree classes, since none of these were safe to use with threads anyway). Minor additions to GlyphArrangement.
This commit is contained in:
parent
67e22bbb56
commit
1dac02369e
16 changed files with 324 additions and 112 deletions
|
|
@ -4908,7 +4908,7 @@ END_JUCE_NAMESPACE
|
|||
/*** Start of inlined file: juce_Expression.cpp ***/
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
class Expression::Term : public ReferenceCountedObject
|
||||
class Expression::Term : public SingleThreadedReferenceCountedObject
|
||||
{
|
||||
public:
|
||||
Term() {}
|
||||
|
|
@ -22501,7 +22501,11 @@ AudioThumbnail::~AudioThumbnail()
|
|||
void AudioThumbnail::clear()
|
||||
{
|
||||
source = nullptr;
|
||||
clearChannelData();
|
||||
}
|
||||
|
||||
void AudioThumbnail::clearChannelData()
|
||||
{
|
||||
const ScopedLock sl (lock);
|
||||
window->invalidate();
|
||||
channels.clear();
|
||||
|
|
@ -22531,7 +22535,7 @@ void AudioThumbnail::createChannels (const int length)
|
|||
|
||||
void AudioThumbnail::loadFrom (InputStream& rawInput)
|
||||
{
|
||||
clear();
|
||||
clearChannelData();
|
||||
|
||||
BufferedInputStream input (rawInput, 4096);
|
||||
|
||||
|
|
@ -86247,7 +86251,7 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE (TransformedImageFillEdgeTableRenderer);
|
||||
};
|
||||
|
||||
class ClipRegionBase : public ReferenceCountedObject
|
||||
class ClipRegionBase : public SingleThreadedReferenceCountedObject
|
||||
{
|
||||
public:
|
||||
ClipRegionBase() {}
|
||||
|
|
@ -91982,33 +91986,40 @@ END_JUCE_NAMESPACE
|
|||
/*** Start of inlined file: juce_GlyphArrangement.cpp ***/
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
PositionedGlyph::PositionedGlyph (const float x_, const float y_, const float w_, const Font& font_,
|
||||
const juce_wchar character_, const int glyph_)
|
||||
: x (x_),
|
||||
y (y_),
|
||||
w (w_),
|
||||
font (font_),
|
||||
character (character_),
|
||||
glyph (glyph_)
|
||||
PositionedGlyph::PositionedGlyph (const Font& font_, const juce_wchar character_, const int glyph_,
|
||||
const float x_, const float y_, const float w_, const bool whitespace_)
|
||||
: font (font_), character (character_), glyph (glyph_),
|
||||
x (x_), y (y_), w (w_), whitespace (whitespace_)
|
||||
{
|
||||
}
|
||||
|
||||
PositionedGlyph::PositionedGlyph (const PositionedGlyph& other)
|
||||
: x (other.x),
|
||||
y (other.y),
|
||||
w (other.w),
|
||||
font (other.font),
|
||||
character (other.character),
|
||||
glyph (other.glyph)
|
||||
: font (other.font), character (other.character), glyph (other.glyph),
|
||||
x (other.x), y (other.y), w (other.w), whitespace (other.whitespace)
|
||||
{
|
||||
}
|
||||
|
||||
PositionedGlyph::~PositionedGlyph() {}
|
||||
|
||||
PositionedGlyph& PositionedGlyph::operator= (const PositionedGlyph& other)
|
||||
{
|
||||
font = other.font;
|
||||
character = other.character;
|
||||
glyph = other.glyph;
|
||||
x = other.x;
|
||||
y = other.y;
|
||||
w = other.w;
|
||||
whitespace = other.whitespace;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void PositionedGlyph::draw (const Graphics& g) const
|
||||
{
|
||||
if (! isWhitespace())
|
||||
{
|
||||
g.getInternalContext()->setFont (font);
|
||||
g.getInternalContext()->drawGlyph (glyph, AffineTransform::translation (x, y));
|
||||
LowLevelGraphicsContext* const context = g.getInternalContext();
|
||||
context->setFont (font);
|
||||
context->drawGlyph (glyph, AffineTransform::translation (x, y));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92017,9 +92028,10 @@ void PositionedGlyph::draw (const Graphics& g,
|
|||
{
|
||||
if (! isWhitespace())
|
||||
{
|
||||
g.getInternalContext()->setFont (font);
|
||||
g.getInternalContext()->drawGlyph (glyph, AffineTransform::translation (x, y)
|
||||
.followedBy (transform));
|
||||
LowLevelGraphicsContext* const context = g.getInternalContext();
|
||||
context->setFont (font);
|
||||
context->drawGlyph (glyph, AffineTransform::translation (x, y)
|
||||
.followedBy (transform));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92112,6 +92124,11 @@ void GlyphArrangement::addGlyphArrangement (const GlyphArrangement& other)
|
|||
glyphs.addCopiesOf (other.glyphs);
|
||||
}
|
||||
|
||||
void GlyphArrangement::addGlyph (const PositionedGlyph& glyph)
|
||||
{
|
||||
glyphs.add (new PositionedGlyph (glyph));
|
||||
}
|
||||
|
||||
void GlyphArrangement::removeRangeOfGlyphs (int startIndex, const int num)
|
||||
{
|
||||
glyphs.removeRange (startIndex, num < 0 ? glyphs.size() : num);
|
||||
|
|
@ -92129,7 +92146,7 @@ void GlyphArrangement::addLineOfText (const Font& font,
|
|||
|
||||
void GlyphArrangement::addCurtailedLineOfText (const Font& font,
|
||||
const String& text,
|
||||
float xOffset,
|
||||
const float xOffset,
|
||||
const float yOffset,
|
||||
const float maxWidthPixels,
|
||||
const bool useEllipsis)
|
||||
|
|
@ -92140,6 +92157,7 @@ void GlyphArrangement::addCurtailedLineOfText (const Font& font,
|
|||
Array <float> xOffsets;
|
||||
font.getGlyphPositions (text, newGlyphs, xOffsets);
|
||||
const int textLen = newGlyphs.size();
|
||||
glyphs.ensureStorageAllocated (glyphs.size() + textLen);
|
||||
|
||||
String::CharPointerType t (text.getCharPointer());
|
||||
|
||||
|
|
@ -92158,8 +92176,12 @@ void GlyphArrangement::addCurtailedLineOfText (const Font& font,
|
|||
}
|
||||
else
|
||||
{
|
||||
glyphs.add (new PositionedGlyph (xOffset + thisX, yOffset, nextX - thisX,
|
||||
font, t.getAndAdvance(), newGlyphs.getUnchecked(i)));
|
||||
const bool isWhitespace = t.isWhitespace();
|
||||
|
||||
glyphs.add (new PositionedGlyph (font, t.getAndAdvance(),
|
||||
newGlyphs.getUnchecked(i),
|
||||
xOffset + thisX, yOffset,
|
||||
nextX - thisX, isWhitespace));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -92194,8 +92216,8 @@ int GlyphArrangement::insertEllipsis (const Font& font, const float maxXPos,
|
|||
|
||||
for (int i = 3; --i >= 0;)
|
||||
{
|
||||
glyphs.insert (endIndex++, new PositionedGlyph (xOffset, yOffset, dx,
|
||||
font, '.', dotGlyphs.getFirst()));
|
||||
glyphs.insert (endIndex++, new PositionedGlyph (font, '.', dotGlyphs.getFirst(),
|
||||
xOffset, yOffset, dx, false));
|
||||
--numDeleted;
|
||||
xOffset += dx;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue