projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Outline effect has been fixed to be not front cropped.
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
internal
/
text
/
layouts
/
layout-engine.cpp
diff --git
a/dali-toolkit/internal/text/layouts/layout-engine.cpp
b/dali-toolkit/internal/text/layouts/layout-engine.cpp
index
148ff58
..
ccd42ae
100644
(file)
--- a/
dali-toolkit/internal/text/layouts/layout-engine.cpp
+++ b/
dali-toolkit/internal/text/layouts/layout-engine.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 201
5
Samsung Electronics Co., Ltd.
+ * Copyright (c) 201
7
Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-198,6
+198,7
@@
struct Engine::Impl
LineLayout tmpLineLayout;
const bool isMultiline = mLayout == MULTI_LINE_BOX;
LineLayout tmpLineLayout;
const bool isMultiline = mLayout == MULTI_LINE_BOX;
+ const bool isWordLaidOut = parameters.lineWrapMode == Text::LineWrap::WORD;
// The last glyph to be laid-out.
const GlyphIndex lastGlyphOfParagraphPlusOne = parameters.startGlyphIndex + parameters.numberOfGlyphs;
// The last glyph to be laid-out.
const GlyphIndex lastGlyphOfParagraphPlusOne = parameters.startGlyphIndex + parameters.numberOfGlyphs;
@@
-447,7
+448,7
@@
struct Engine::Impl
if( isMultiline &&
( TextAbstraction::WORD_BREAK == wordBreakInfo ) )
{
if( isMultiline &&
( TextAbstraction::WORD_BREAK == wordBreakInfo ) )
{
- oneWordLaidOut =
true
;
+ oneWordLaidOut =
isWordLaidOut
;
DALI_LOG_INFO( gLogFilter, Debug::Verbose, " One word laid-out\n" );
// Current glyph is the last one of the current word.
DALI_LOG_INFO( gLogFilter, Debug::Verbose, " One word laid-out\n" );
// Current glyph is the last one of the current word.
@@
-469,6
+470,7
@@
struct Engine::Impl
void SetGlyphPositions( const GlyphInfo* const glyphsBuffer,
Length numberOfGlyphs,
void SetGlyphPositions( const GlyphInfo* const glyphsBuffer,
Length numberOfGlyphs,
+ float outlineWidth,
Vector2* glyphPositionsBuffer )
{
// Traverse the glyphs and set the positions.
Vector2* glyphPositionsBuffer )
{
// Traverse the glyphs and set the positions.
@@
-478,7
+480,8
@@
struct Engine::Impl
// so the penX position needs to be moved to the right.
const GlyphInfo& glyph = *glyphsBuffer;
// so the penX position needs to be moved to the right.
const GlyphInfo& glyph = *glyphsBuffer;
- float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing : 0.f;
+ float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing + outlineWidth : outlineWidth;
+
for( GlyphIndex i = 0u; i < numberOfGlyphs; ++i )
{
for( GlyphIndex i = 0u; i < numberOfGlyphs; ++i )
{
@@
-603,6
+606,7
@@
struct Engine::Impl
SetGlyphPositions( layoutParameters.glyphsBuffer + lineRun->glyphRun.glyphIndex,
ellipsisLayout.numberOfGlyphs,
SetGlyphPositions( layoutParameters.glyphsBuffer + lineRun->glyphRun.glyphIndex,
ellipsisLayout.numberOfGlyphs,
+ layoutParameters.outlineWidth,
glyphPositionsBuffer + lineRun->glyphRun.glyphIndex - layoutParameters.startGlyphIndex );
}
glyphPositionsBuffer + lineRun->glyphRun.glyphIndex - layoutParameters.startGlyphIndex );
}
@@
-962,6
+966,7
@@
struct Engine::Impl
// Sets the positions of the glyphs.
SetGlyphPositions( layoutParameters.glyphsBuffer + index,
layout.numberOfGlyphs,
// Sets the positions of the glyphs.
SetGlyphPositions( layoutParameters.glyphsBuffer + index,
layout.numberOfGlyphs,
+ layoutParameters.outlineWidth,
glyphPositionsBuffer + index - layoutParameters.startGlyphIndex );
// Updates the vertical pen's position.
glyphPositionsBuffer + index - layoutParameters.startGlyphIndex );
// Updates the vertical pen's position.
@@
-1042,7
+1047,7
@@
struct Engine::Impl
const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *bidiLine.visualToLogicalMap;
const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) );
const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *bidiLine.visualToLogicalMap;
const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) );
- float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing
: 0.f
;
+ float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing
- layoutParameters.outlineWidth : -layoutParameters.outlineWidth
;
Vector2* glyphPositionsBuffer = glyphPositions.Begin();
Vector2* glyphPositionsBuffer = glyphPositions.Begin();
@@
-1077,11
+1082,13
@@
struct Engine::Impl
void Align( const Size& size,
CharacterIndex startIndex,
Length numberOfCharacters,
void Align( const Size& size,
CharacterIndex startIndex,
Length numberOfCharacters,
- HorizontalAlignment horizontalAlignment,
- Vector<LineRun>& lines )
+ Text::HorizontalAlignment::Type horizontalAlignment,
+ Vector<LineRun>& lines,
+ float& alignmentOffset )
{
const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
{
const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
+ alignmentOffset = MAX_FLOAT;
// Traverse all lines and align the glyphs.
for( Vector<LineRun>::Iterator it = lines.Begin(), endIt = lines.End();
it != endIt;
// Traverse all lines and align the glyphs.
for( Vector<LineRun>::Iterator it = lines.Begin(), endIt = lines.End();
it != endIt;
@@
-1106,36
+1113,39
@@
struct Engine::Impl
CalculateHorizontalAlignment( size.width,
horizontalAlignment,
line );
CalculateHorizontalAlignment( size.width,
horizontalAlignment,
line );
+
+ // Updates the alignment offset.
+ alignmentOffset = std::min( alignmentOffset, line.alignmentOffset );
}
}
void CalculateHorizontalAlignment( float boxWidth,
}
}
void CalculateHorizontalAlignment( float boxWidth,
- HorizontalAlignment horizontalAlignment,
+ HorizontalAlignment
::Type
horizontalAlignment,
LineRun& line )
{
line.alignmentOffset = 0.f;
const bool isRTL = RTL == line.direction;
float lineLength = line.width;
LineRun& line )
{
line.alignmentOffset = 0.f;
const bool isRTL = RTL == line.direction;
float lineLength = line.width;
- HorizontalAlignment alignment = horizontalAlignment;
+ HorizontalAlignment
::Type
alignment = horizontalAlignment;
if( isRTL )
{
// Swap the alignment type if the line is right to left.
switch( alignment )
{
if( isRTL )
{
// Swap the alignment type if the line is right to left.
switch( alignment )
{
- case H
ORIZONTAL_ALIGN_
BEGIN:
+ case H
orizontalAlignment::
BEGIN:
{
{
- alignment = H
ORIZONTAL_ALIGN_
END;
+ alignment = H
orizontalAlignment::
END;
break;
}
break;
}
- case H
ORIZONTAL_ALIGN_
CENTER:
+ case H
orizontalAlignment::
CENTER:
{
// Nothing to do.
break;
}
{
// Nothing to do.
break;
}
- case H
ORIZONTAL_ALIGN_
END:
+ case H
orizontalAlignment::
END:
{
{
- alignment = H
ORIZONTAL_ALIGN_
BEGIN;
+ alignment = H
orizontalAlignment::
BEGIN;
break;
}
}
break;
}
}
@@
-1144,7
+1154,7
@@
struct Engine::Impl
// Calculate the horizontal line offset.
switch( alignment )
{
// Calculate the horizontal line offset.
switch( alignment )
{
- case H
ORIZONTAL_ALIGN_
BEGIN:
+ case H
orizontalAlignment::
BEGIN:
{
line.alignmentOffset = 0.f;
{
line.alignmentOffset = 0.f;
@@
-1155,7
+1165,7
@@
struct Engine::Impl
}
break;
}
}
break;
}
- case H
ORIZONTAL_ALIGN_
CENTER:
+ case H
orizontalAlignment::
CENTER:
{
line.alignmentOffset = 0.5f * ( boxWidth - lineLength );
{
line.alignmentOffset = 0.5f * ( boxWidth - lineLength );
@@
-1167,7
+1177,7
@@
struct Engine::Impl
line.alignmentOffset = floorf( line.alignmentOffset ); // try to avoid pixel alignment.
break;
}
line.alignmentOffset = floorf( line.alignmentOffset ); // try to avoid pixel alignment.
break;
}
- case H
ORIZONTAL_ALIGN_
END:
+ case H
orizontalAlignment::
END:
{
if( isRTL )
{
{
if( isRTL )
{
@@
-1266,14
+1276,16
@@
void Engine::ReLayoutRightToLeftLines( const Parameters& layoutParameters,
void Engine::Align( const Size& size,
CharacterIndex startIndex,
Length numberOfCharacters,
void Engine::Align( const Size& size,
CharacterIndex startIndex,
Length numberOfCharacters,
- Layout::HorizontalAlignment horizontalAlignment,
- Vector<LineRun>& lines )
+ Text::HorizontalAlignment::Type horizontalAlignment,
+ Vector<LineRun>& lines,
+ float& alignmentOffset )
{
mImpl->Align( size,
startIndex,
numberOfCharacters,
horizontalAlignment,
{
mImpl->Align( size,
startIndex,
numberOfCharacters,
horizontalAlignment,
- lines );
+ lines,
+ alignmentOffset );
}
void Engine::SetDefaultLineSpacing( float lineSpacing )
}
void Engine::SetDefaultLineSpacing( float lineSpacing )