Skip to content

Commit

Permalink
Refactor|Client: GLTextComposer is an Asset
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jun 5, 2013
1 parent 3a23bfd commit 75f4d8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doomsday/client/include/ui/widgets/gltextcomposer.h
Expand Up @@ -34,7 +34,7 @@
* Relies on a pre-existing FontLineWrapping where the text content has been
* wrapped onto multiple lines and laid out appropriately.
*/
class GLTextComposer
class GLTextComposer : public de::Asset
{
public:
typedef de::Vertex2TexRgba Vertex;
Expand All @@ -53,7 +53,8 @@ class GLTextComposer

/**
* Makes sure all the lines are allocated on the atlas. After this all the
* allocated lines match the ones in the wrapping.
* allocated lines match the ones in the wrapping. This must be called
* before makeVertices().
*
* @return @c true, if any allocations were changed and makeVertices()
* should be called again.
Expand Down
8 changes: 8 additions & 0 deletions doomsday/client/src/ui/widgets/gltextcomposer.cpp
Expand Up @@ -130,6 +130,7 @@ GLTextComposer::GLTextComposer() : d(new Instance(this))
void GLTextComposer::release()
{
d->releaseLines();
setState(false);
}

void GLTextComposer::setAtlas(Atlas &atlas)
Expand All @@ -152,13 +153,15 @@ void GLTextComposer::setStyledText(const String &styledText)
d->format.clear();
d->text = d->format.initFromStyledText(styledText);
d->needRaster = true;
setState(false);
}

void GLTextComposer::setText(String const &text, Font::RichFormat const &format)
{
d->text = text;
d->format = format;
d->needRaster = true; // Force a redo of everything.
setState(false);
}

bool GLTextComposer::update()
Expand All @@ -175,6 +178,9 @@ bool GLTextComposer::update()
d->releaseLines();
d->needRaster = false;
}

setState(true);

return d->allocLines();
}

Expand All @@ -192,6 +198,8 @@ void GLTextComposer::makeVertices(Vertices &triStrip,
Alignment const &lineAlign,
Vector4f const &color)
{
if(!isReady()) return;

DENG2_ASSERT(d->wraps != 0);
DENG2_ASSERT(d->font != 0);

Expand Down

0 comments on commit 75f4d8c

Please sign in to comment.