Skip to content

Commit

Permalink
Fixed|GLTextComposer: Segment alignment for untabbed lines
Browse files Browse the repository at this point in the history
All segments now default to tab stop -1 if they don't use tabs.
  • Loading branch information
skyjake committed Aug 24, 2013
1 parent 8e9e184 commit 33d0145
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions doomsday/client/src/ui/widgets/gltextcomposer.cpp
Expand Up @@ -236,18 +236,34 @@ DENG2_PIMPL(GLTextComposer)
*/
inline int updateLineLayoutUntilUntabbed(Rangei const &lineRange)
{
bool includesTabbedLines = false;
int rangeEnd = lineRange.end;

// Find the highest tab in use and initialize seg widths.
int highestTab = 0;
for(int i = lineRange.start; i < lineRange.end; ++i)
{
int lineStop = wraps->lineInfo(i).highestTabStop();
if(lineStop >= 0)
{
// The range now includes at least one tabbed line.
includesTabbedLines = true;
}
if(lineStop < 0)
{
// An untabbed line will halt the process for now.
rangeEnd = de::max(i, lineRange.start + 1);
break;
// This is an untabbed line.
if(!includesTabbedLines)
{
// We can do many untabbed lines in the range as long as
// there are no tabbed ones.
rangeEnd = i + 1;
}
else
{
// An untabbed line will halt the process for now.
rangeEnd = de::max(i, lineRange.start + 1);
break;
}
}
highestTab = de::max(highestTab, lineStop);

Expand Down Expand Up @@ -473,7 +489,7 @@ void GLTextComposer::makeVertices(Vertices &triStrip,

// Line alignment.
/// @todo How to center/right-align text that uses tab stops?
if(line.segs.size() == 1 && !d->wraps->lineInfo(0).segs[0].tabStop)
if(line.segs.size() == 1 && d->wraps->lineInfo(0).segs[0].tabStop < 0)
{
if(lineAlign.testFlag(AlignRight))
{
Expand Down

0 comments on commit 33d0145

Please sign in to comment.