* Character's height and advance stores the same values than size -> height and advance removed.
* Character's gradient info stores a color (Vector4) two points (Vector2) and an alpha value (float)
These parameters are only used for some text-actors when the text is faded-out.
A new GradientInfo structure has been added and the character only stores a pointer to that struct,
which is NULL if is not needed.
Change-Id: Iaa09a5a384ed43722fd703ff659459196019fff9
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
DALI_TEST_EQUALS( indices.mCharacterIndex, 0u, TEST_LOCATION );
TextViewProcessor::CharacterLayoutInfo characterLayoutInfo;
- DALI_TEST_EQUALS( characterLayoutInfo.mHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mAdvance, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( characterLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo.mBearing, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo.mOffset, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo.mUnderlineThickness, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo.mUnderlinePosition, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_CHECK( !characterLayoutInfo.mGlyphActor );
DALI_TEST_CHECK( characterLayoutInfo.mStyledText.mText.IsEmpty() );
DALI_TEST_EQUALS( characterLayoutInfo.mColorAlpha, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mGradientColor, Vector4::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mStartPoint, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mEndPoint, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_CHECK( NULL == characterLayoutInfo.mGradientInfo );
DALI_TEST_CHECK( characterLayoutInfo.mIsVisible );
DALI_TEST_CHECK( characterLayoutInfo.mSetText );
DALI_TEST_CHECK( characterLayoutInfo.mSetStyle );
tet_infoline("UtcDaliTextViewCopyConstructorOperator : ");
TextViewProcessor::CharacterLayoutInfo characterLayoutInfo;
- characterLayoutInfo.mHeight = 1.f;
- characterLayoutInfo.mAdvance = 1.f;
+ characterLayoutInfo.mSize = Vector2( 1.f, 1.f );
characterLayoutInfo.mBearing = 1.f;
characterLayoutInfo.mPosition = Vector3( 1.f, 1.f, 1.f );
characterLayoutInfo.mOffset = Vector2( 1.f, 1.f );
- characterLayoutInfo.mSize = Vector2( 1.f, 1.f );
characterLayoutInfo.mAscender = 1.f;
characterLayoutInfo.mUnderlineThickness = 1.f;
characterLayoutInfo.mUnderlinePosition = 1.f;
characterLayoutInfo.mGlyphActor = TextActor::New( "Hello" );
characterLayoutInfo.mStyledText.mText = Text( "Hello" );
+ TextViewProcessor::GradientInfo* info = new TextViewProcessor::GradientInfo();
+ info->mGradientColor = Vector4( 1.f, 1.f, 1.f, 1.f );
+ info->mStartPoint = Vector2( 1.f, 1.f );
+ info->mEndPoint = Vector2( 1.f, 1.f );
+
characterLayoutInfo.mColorAlpha = 0.f;
- characterLayoutInfo.mGradientColor = Vector4( 1.f, 1.f, 1.f, 1.f );
- characterLayoutInfo.mStartPoint = Vector2( 1.f, 1.f );
- characterLayoutInfo.mEndPoint = Vector2( 1.f, 1.f );
+ characterLayoutInfo.mGradientInfo = info;
+
characterLayoutInfo.mIsVisible = false;
characterLayoutInfo.mSetText = false;
characterLayoutInfo.mSetStyle = false;
TextViewProcessor::CharacterLayoutInfo characterLayoutInfo1;
characterLayoutInfo1 = characterLayoutInfo;
- DALI_TEST_EQUALS( characterLayoutInfo1.mHeight, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mAdvance, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo1.mBearing, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo1.mPosition, Vector3( 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo1.mOffset, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_CHECK( characterLayoutInfo1.mGlyphActor );
DALI_TEST_EQUALS( characterLayoutInfo1.mStyledText.mText.GetLength(), 5u, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo1.mColorAlpha, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_CHECK( !characterLayoutInfo1.mIsVisible );
DALI_TEST_CHECK( !characterLayoutInfo1.mSetText );
DALI_TEST_CHECK( !characterLayoutInfo1.mSetStyle );
TextViewProcessor::CharacterLayoutInfo characterLayoutInfo2( characterLayoutInfo );
- DALI_TEST_EQUALS( characterLayoutInfo2.mHeight, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mAdvance, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo2.mBearing, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo2.mPosition, Vector3( 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo2.mOffset, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_CHECK( characterLayoutInfo2.mGlyphActor );
DALI_TEST_EQUALS( characterLayoutInfo2.mStyledText.mText.GetLength(), 5u, TEST_LOCATION );
DALI_TEST_EQUALS( characterLayoutInfo2.mColorAlpha, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
DALI_TEST_CHECK( !characterLayoutInfo2.mIsVisible );
DALI_TEST_CHECK( !characterLayoutInfo2.mSetText );
DALI_TEST_CHECK( !characterLayoutInfo2.mSetStyle );
void Print( const TextViewProcessor::CharacterLayoutInfo& character )
{
- std::cout << " height : " << character.mHeight << std::endl;
- std::cout << " advance : " << character.mAdvance << std::endl;
+ std::cout << " height : " << character.mSize.height << std::endl;
+ std::cout << " advance : " << character.mSize.width << std::endl;
std::cout << " bearing : " << character.mBearing << std::endl;
- std::cout << " mPosition : " << character.mPosition << std::endl;
- std::cout << " mSize : " << character.mSize << std::endl;
- std::cout << " mAscender : " << character.mAscender << std::endl;
+ std::cout << " ascender : " << character.mAscender << std::endl;
+ std::cout << " position : " << character.mPosition << std::endl;
TextActor textActor = TextActor::DownCast( character.mGlyphActor );
if( textActor )
bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1,
const TextViewProcessor::CharacterLayoutInfo& character2 )
{
- if( !TestEqual( character1.mHeight, character2.mHeight ) )
+ if( !TestEqual( character1.mSize.height, character2.mSize.height ) )
{
return false;
}
- if( !TestEqual( character1.mAdvance, character2.mAdvance ) )
+ if( !TestEqual( character1.mSize.width, character2.mSize.width ) )
{
return false;
}
return false;
}
- if( !TestEqual( character1.mSize.x, character2.mSize.x ) )
- {
- return false;
- }
- if( !TestEqual( character1.mSize.y, character2.mSize.y ) )
- {
- return false;
- }
-
if( !TestEqual( character1.mAscender, character2.mAscender ) )
{
return false;
// bearing : 11.9492
// ascender : 11.9492
- const float WIDTH_10( 9.48351f );
const float HEIGHT_10( 9.48351f );
const float ADVANCE_10( 9.48351f );
const float BEARING_10( 8.53516f );
const float ASCENDER_10( 8.53516f );
- const float WIDTH_12( 11.3802f );
const float HEIGHT_12( 11.3802f );
const float ADVANCE_12( 11.3802f );
const float BEARING_12( 10.2422f );
// Characters
TextViewProcessor::CharacterLayoutInfo layoutInfo10; // ( [lo wo])
- layoutInfo10.mHeight = HEIGHT_10;
- layoutInfo10.mAdvance = ADVANCE_10;
+ layoutInfo10.mSize.height = HEIGHT_10;
+ layoutInfo10.mSize.width = ADVANCE_10;
layoutInfo10.mBearing = BEARING_10;
- layoutInfo10.mSize = Size( WIDTH_10, HEIGHT_10 );
layoutInfo10.mAscender = ASCENDER_10;
TextViewProcessor::CharacterLayoutInfo layoutInfo12; // ( [Hel], [rld!] and [CR])
- layoutInfo12.mHeight = HEIGHT_12;
- layoutInfo12.mAdvance = ADVANCE_12;
+ layoutInfo12.mSize.height = HEIGHT_12;
+ layoutInfo12.mSize.width = ADVANCE_12;
layoutInfo12.mBearing = BEARING_12;
- layoutInfo12.mSize = Size( WIDTH_12, HEIGHT_12 );
layoutInfo12.mAscender = ASCENDER_12;
TextStyle style10;
TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4;
// Hello
- wordLayout1.mSize = Size( 3.f * WIDTH_12 + 2.f * WIDTH_10, HEIGHT_12 );
+ wordLayout1.mSize = Size( 3.f * ADVANCE_12 + 2.f * ADVANCE_10, HEIGHT_12 );
wordLayout1.mAscender = ASCENDER_12;
wordLayout1.mType = TextViewProcessor::NoSeparator;
wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
// (white space)
- wordLayout2.mSize = Size( WIDTH_10, HEIGHT_10 );
+ wordLayout2.mSize = Size( ADVANCE_10, HEIGHT_10 );
wordLayout2.mAscender = ASCENDER_10;
wordLayout2.mType = TextViewProcessor::WordSeparator;
layoutInfo10.mStyledText.mText = Text( " " );
wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space)
// world!
- wordLayout3.mSize = Size( 2.f * WIDTH_10 + 4.f * WIDTH_12, HEIGHT_12 );
+ wordLayout3.mSize = Size( 2.f * ADVANCE_10 + 4.f * ADVANCE_12, HEIGHT_12 );
wordLayout3.mAscender = ASCENDER_12;
wordLayout3.mType = TextViewProcessor::NoSeparator;
layoutInfo10.mStyledText.mText = Text( "w" );
TextViewProcessor::ParagraphLayoutInfo paragraphLayout1, paragraphLayout2, paragraphLayout3;
- paragraphLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
+ paragraphLayout1.mSize = Size( 5.f * ADVANCE_10 + 7.f * ADVANCE_12, HEIGHT_12 );
paragraphLayout1.mAscender = ASCENDER_12;
paragraphLayout1.mNumberOfCharacters = 13;
paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout1 );
// Text (layout)
TextViewProcessor::TextLayoutInfo textLayout;
- textLayout.mWholeTextSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, 3.f * HEIGHT_12 );
- textLayout.mMaxWordWidth = 2.f * WIDTH_10 + 4.f * WIDTH_12;
+ textLayout.mWholeTextSize = Size( 5.f * ADVANCE_10 + 7.f * ADVANCE_12, 3.f * HEIGHT_12 );
+ textLayout.mMaxWordWidth = 2.f * ADVANCE_10 + 4.f * ADVANCE_12;
textLayout.mNumberOfCharacters = 14;
textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout1 );
textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout2 );
Vector3 position;
Size size;
Vector4 color;
- Vector4 gradientColor;
- Vector2 startPoint;
- Vector2 endPoint;
+ TextViewProcessor::GradientInfo* gradientInfo;
};
void SetVisualParameters( CurrentTextActorInfo& currentTextActorInfo,
const float lineHeight )
{
currentTextActorInfo.textActor.SetTextColor( currentTextActorInfo.color );
- currentTextActorInfo.textActor.SetGradientColor( currentTextActorInfo.gradientColor );
- currentTextActorInfo.textActor.SetGradientStartPoint( currentTextActorInfo.startPoint );
- currentTextActorInfo.textActor.SetGradientEndPoint( currentTextActorInfo.endPoint );
+ if( NULL != currentTextActorInfo.gradientInfo )
+ {
+ currentTextActorInfo.textActor.SetGradientColor( currentTextActorInfo.gradientInfo->mGradientColor );
+ currentTextActorInfo.textActor.SetGradientStartPoint( currentTextActorInfo.gradientInfo->mStartPoint );
+ currentTextActorInfo.textActor.SetGradientEndPoint( currentTextActorInfo.gradientInfo->mEndPoint );
+ }
// The italics offset is used in the offscreen rendering. When text is in italics, it may exceed the text-view's boundary
// due to the trick used to implement it.
characterTableInfo.mPosition.x = positionOffset.x + characterLayoutInfo.mOffset.x;
characterTableInfo.mPosition.y = positionOffset.y + characterLayoutInfo.mOffset.y;
- positionOffset.x += characterLayoutInfo.mAdvance * relayoutData.mShrinkFactor;
+ positionOffset.x += characterLayoutInfo.mSize.width * relayoutData.mShrinkFactor;
} // end characters
} // end words
} // end paragraphs
const float descender = characterLayoutInfo.mSize.height - characterLayoutInfo.mAscender;
- const Toolkit::TextView::CharacterLayoutInfo characterLayoutTableInfo( Size( characterLayoutInfo.mAdvance * relayoutData.mShrinkFactor,
- characterLayoutInfo.mHeight * relayoutData.mShrinkFactor ),
+ const Toolkit::TextView::CharacterLayoutInfo characterLayoutTableInfo( Size( characterLayoutInfo.mSize.width * relayoutData.mShrinkFactor,
+ characterLayoutInfo.mSize.height * relayoutData.mShrinkFactor ),
positionOffset,
( TextViewProcessor::ParagraphSeparator == wordLayoutInfo.mType ),
false, // VCC set the correct direction if needed.
relayoutData.mCharacterLayoutInfoTable.push_back( characterLayoutTableInfo );
- positionOffset.x += characterLayoutInfo.mAdvance * relayoutData.mShrinkFactor;
+ positionOffset.x += characterLayoutInfo.mSize.width * relayoutData.mShrinkFactor;
}
void CalculateVisibilityForFade( const Internal::TextView::LayoutParameters& layoutParameters,
Vector2 startPoint = Vector2::ZERO;
Vector2 endPoint = Vector2::ZERO;
+ if( NULL == characterLayoutInfo.mGradientInfo )
+ {
+ characterLayoutInfo.mGradientInfo = new TextViewProcessor::GradientInfo();
+ }
+
if( !( rightFadeOut && leftFadeOut ) )
{
// Current implementation can't set gradient parameters for a text-actor exceeding at the same time the left and the right boundaries.
}
}
- characterLayoutInfo.mGradientColor = gradientColor;
- characterLayoutInfo.mStartPoint = startPoint;
- characterLayoutInfo.mEndPoint = endPoint;
+ characterLayoutInfo.mGradientInfo->mGradientColor = gradientColor;
+ characterLayoutInfo.mGradientInfo->mStartPoint = startPoint;
+ characterLayoutInfo.mGradientInfo->mEndPoint = endPoint;
}
else
{
TextViewProcessor::CharacterLayoutInfo& characterLayoutInfo( *characterLayoutIt );
characterLayoutInfo.mIsVisible = true;
- characterLayoutInfo.mGradientColor = Vector4::ZERO;
- characterLayoutInfo.mStartPoint = Vector2::ZERO;
- characterLayoutInfo.mEndPoint = Vector2::ZERO;
+ delete characterLayoutInfo.mGradientInfo;
+ characterLayoutInfo.mGradientInfo = NULL;
characterLayoutInfo.mColorAlpha = characterLayoutInfo.mStyledText.mStyle.GetTextColor().a;
} // end characters
} // end words
currentTextActorInfo.color = style.GetTextColor();
currentTextActorInfo.color.a = characterLayout.mColorAlpha;
- currentTextActorInfo.gradientColor = characterLayout.mGradientColor;
- currentTextActorInfo.startPoint = characterLayout.mStartPoint;
- currentTextActorInfo.endPoint = characterLayout.mEndPoint;
+ currentTextActorInfo.gradientInfo = characterLayout.mGradientInfo;
TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
TextStyle currentStyle; // style for the current text-actor.
- Vector4 currentGradientColor; // gradient color for the current text-actor.
- Vector2 currentStartPoint; // start point for the current text-actor.
- Vector2 currentEndPoint; // end point for the current text-actor.
+ TextViewProcessor::GradientInfo* currentGradientInfo = NULL; // gradient color for the current text-actor.
+ // start point for the current text-actor.
+ // end point for the current text-actor.
bool currentIsColorGlyph = false; // Whether current glyph is an emoticon.
{
// Do not create a glyph-actor if it's a white space (without underline) or a new paragraph character.
- // Creates one glyph-actor for each counsecutive group of characters, with the same style, per line, or if it's an emoticon.
+ // Check if the character has the same gradient info than the current one.
+ bool differentGradientInfo = false;
+ if( characterLayout.mGradientInfo && currentGradientInfo )
+ {
+ differentGradientInfo = ( characterLayout.mGradientInfo->mGradientColor != currentGradientInfo->mGradientColor ) ||
+ ( characterLayout.mGradientInfo->mStartPoint != currentGradientInfo->mStartPoint ) ||
+ ( characterLayout.mGradientInfo->mEndPoint != currentGradientInfo->mEndPoint );
+ }
+ else if( ( NULL != currentGradientInfo ) || ( NULL != characterLayout.mGradientInfo ) )
+ {
+ differentGradientInfo = true;
+ }
+ // Creates one glyph-actor for each counsecutive group of characters, with the same style, per line, or if it's an emoticon.
if( !glyphActorCreatedForLine ||
characterLayout.mIsColorGlyph ||
+ differentGradientInfo ||
( characterLayout.mIsColorGlyph != currentIsColorGlyph ) ||
- ( style != currentStyle ) ||
- ( characterLayout.mGradientColor != currentGradientColor ) ||
- ( characterLayout.mStartPoint != currentStartPoint ) ||
- ( characterLayout.mEndPoint != currentEndPoint ) )
+ ( style != currentStyle ) )
{
characterLayout.mSetText = false;
characterLayout.mSetStyle = false;
// Update style to be checked with next characters.
currentStyle = style;
- currentGradientColor = characterLayout.mGradientColor;
- currentStartPoint = characterLayout.mStartPoint;
- currentEndPoint = characterLayout.mEndPoint;
+ currentGradientInfo = characterLayout.mGradientInfo;
currentIsColorGlyph = characterLayout.mIsColorGlyph;
characterLayout.mGlyphActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
createGlyphActors );
} // paragraphs
+ // Set visual parameters for ellipsis renderable actors.
for( std::vector<RenderableActor>::iterator it = relayoutData.mEllipsizedGlyphActors.begin(),
endIt = relayoutData.mEllipsizedGlyphActors.end();
it != endIt;
// Layout info.
/////////////////////
+GradientInfo::GradientInfo()
+: mGradientColor(),
+ mStartPoint(),
+ mEndPoint()
+{
+}
+
+GradientInfo::~GradientInfo()
+{
+}
+
+GradientInfo::GradientInfo( const GradientInfo& info )
+: mGradientColor( info.mGradientColor ),
+ mStartPoint( info.mStartPoint ),
+ mEndPoint( info.mEndPoint )
+{
+}
+
+GradientInfo& GradientInfo::operator=( const GradientInfo& info )
+{
+ if( this != &info )
+ {
+ mGradientColor = info.mGradientColor;
+ mStartPoint = info.mStartPoint;
+ mEndPoint = info.mEndPoint;
+ }
+
+ return *this;
+}
+
CharacterLayoutInfo::CharacterLayoutInfo()
-: mHeight( 0.f ),
- mAdvance( 0.f ),
+: mSize(),
mBearing( 0.f ),
- mPosition(),
- mOffset(),
- mSize(),
mAscender( 0.f ),
mUnderlineThickness( 0.f ),
mUnderlinePosition( 0.f ),
+ mPosition(),
+ mOffset(),
mGlyphActor(),
mStyledText(),
mColorAlpha( 1.f ),
- mGradientColor(),
- mStartPoint(),
- mEndPoint(),
+ mGradientInfo( NULL ),
mIsVisible( true ),
mSetText( true ),
mSetStyle( true ),
CharacterLayoutInfo::~CharacterLayoutInfo()
{
+ // Deletes the gradient info.
+ delete mGradientInfo;
}
CharacterLayoutInfo::CharacterLayoutInfo( const CharacterLayoutInfo& character )
-: mHeight( character.mHeight ),
- mAdvance( character.mAdvance ),
+: mSize( character.mSize ),
mBearing( character.mBearing ),
- mPosition( character.mPosition ),
- mOffset( character.mOffset ),
- mSize( character.mSize ),
mAscender( character.mAscender ),
mUnderlineThickness( character.mUnderlineThickness ),
mUnderlinePosition( character.mUnderlinePosition ),
+ mPosition( character.mPosition ),
+ mOffset( character.mOffset ),
mGlyphActor( character.mGlyphActor ),
mStyledText( character.mStyledText ),
mColorAlpha( character.mColorAlpha ),
- mGradientColor( character.mGradientColor ),
- mStartPoint( character.mStartPoint ),
- mEndPoint( character.mEndPoint ),
+ mGradientInfo( ( NULL == character.mGradientInfo ) ? NULL : new GradientInfo( *character.mGradientInfo ) ), // Copies the gradient info.
mIsVisible( character.mIsVisible ),
mSetText( character.mSetText ),
mSetStyle( character.mSetStyle ),
CharacterLayoutInfo& CharacterLayoutInfo::operator=( const CharacterLayoutInfo& character )
{
- mHeight = character.mHeight;
- mAdvance = character.mAdvance;
- mBearing = character.mBearing;
-
- mPosition = character.mPosition;
- mOffset = character.mOffset;
mSize = character.mSize;
mAscender = character.mAscender;
+ mBearing = character.mBearing;
mUnderlineThickness = character.mUnderlineThickness;
mUnderlinePosition = character.mUnderlinePosition;
+ mPosition = character.mPosition;
+ mOffset = character.mOffset;
+
+ mGlyphActor = character.mGlyphActor;
mStyledText = character.mStyledText;
+
mColorAlpha = character.mColorAlpha;
- mGradientColor = character.mGradientColor;
- mStartPoint = character.mStartPoint;
- mEndPoint = character.mEndPoint;
+
+ // Copies the gradient info.
+ if( NULL == character.mGradientInfo )
+ {
+ // The source doesn't have. Deletes the current one.
+ delete mGradientInfo;
+ mGradientInfo = NULL;
+ }
+ else
+ {
+ // The source has gradient info.
+ if( NULL != mGradientInfo )
+ {
+ // It it has, copy to it.
+ *mGradientInfo = *character.mGradientInfo;
+ }
+ else
+ {
+ // If it doesn't have, create a new one.
+ mGradientInfo = new GradientInfo( *character.mGradientInfo );
+ }
+ }
+
mIsVisible = character.mIsVisible;
mSetText = character.mSetText;
mSetStyle = character.mSetStyle;
mIsColorGlyph = character.mIsColorGlyph;
- mGlyphActor = character.mGlyphActor;
-
return *this;
}
};
/**
+ * Stores gradient info.
+ *
+ * Used to fade in/out text-actors.
+ */
+struct GradientInfo
+{
+ /**
+ * Default constructor.
+ *
+ * Initializes all members to their default values.
+ */
+ GradientInfo();
+
+ /**
+ * Default destructor.
+ */
+ ~GradientInfo();
+
+ /**
+ * Copy constructor
+ */
+ GradientInfo( const GradientInfo& info );
+
+ /**
+ * Assignment operator.
+ */
+ GradientInfo& operator=( const GradientInfo& info );
+
+ Vector4 mGradientColor; ///< Gradient color.
+ Vector2 mStartPoint; ///< Gradient start point.
+ Vector2 mEndPoint; ///< Gradient end point.
+};
+
+/**
* Layout information for a character.
* It stores the position, size and ascender of its respective text-actor.
*/
*/
CharacterLayoutInfo& operator=( const CharacterLayoutInfo& character );
- // Natural size (metrics) of the glyph.
- float mHeight; ///< Natural height of the character.
- float mAdvance; ///< Natural horizontal distance from origin of current character and the next one.
- float mBearing; ///< Natural vertical distance from the baseline to the top of the glyph's bbox.
-
- // Size of the text-actor (may be modified by a scale factor).
- Vector3 mPosition; ///< Position within the text-view
- Vector2 mOffset; ///< Alignment and justification offset.
- Size mSize; ///< Size of this character.
+ // Metrics of the glyph.
+ Size mSize; ///< Height of the font and advance (the horizontal distance from the origin of the current character and the next one).
+ float mBearing; ///< Vertical distance from the baseline to the top of the glyph's boundary box.
float mAscender; ///< Distance from the base line to the top of the line.
float mUnderlineThickness; ///< The underline's thickness.
float mUnderlinePosition; ///< The underline's position.
- RenderableActor mGlyphActor; ///< Handle to a text-actor.
- MarkupProcessor::StyledText mStyledText; ///< Stores the text and its style.
- float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
- Vector4 mGradientColor; ///< Gradient color.
- Vector2 mStartPoint; ///< Gradient start point.
- Vector2 mEndPoint; ///< Gradient end point.
+ // Position and alignment offset. It depends on the lay-out.
+ Vector3 mPosition; ///< Position within the text-view
+ Vector2 mOffset; ///< Alignment and justification offset.
+
+ RenderableActor mGlyphActor; ///< Handle to a text-actor.
+ MarkupProcessor::StyledText mStyledText; ///< Stores the text and its style.
+ float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
+ GradientInfo* mGradientInfo; ///< Stores gradient info.
- bool mIsVisible:1; ///< Whether the text-actor is visible.
- bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
- bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
- bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
+ bool mIsVisible:1; ///< Whether the text-actor is visible.
+ bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
+ bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
+ bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
};
typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
/**
* Default destructor.
*
- * Clears all words and deletes all text styles.
+ * Clears all words.
*/
~ParagraphLayoutInfo();
ChooseFontFamilyName( styledCharacter );
}
+ // Gets the metrics of the font.
const Font font = Font::New( FontParameters( styledCharacter.mStyle.GetFontName(), styledCharacter.mStyle.GetFontStyle(), styledCharacter.mStyle.GetFontPointSize() ) );
const Font::Metrics metrics = font.GetMetrics( character );
const float ascender = font.GetAscender();
- // Fill Natural size info for current character.
- characterLayoutInfo.mHeight = font.GetLineHeight();
- characterLayoutInfo.mAdvance = metrics.GetAdvance();
+ // The font line's height is used as character's height.
+ characterLayoutInfo.mSize.height = font.GetLineHeight();
+
+ // The character's advance is used as charcter's width.
+ characterLayoutInfo.mSize.width = metrics.GetAdvance();
+
+ // The ascender and bearing are used to position correctly glyphs of different font sizes.
+ characterLayoutInfo.mAscender = ascender;
characterLayoutInfo.mBearing = metrics.GetBearing();
if( character.IsNewLine() && !characterLayoutInfo.mIsColorGlyph )
// A new paragraph character doesn't have any width.
characterLayoutInfo.mSize.width = 0.f;
}
- else
- {
- // Uses advance as width.
- characterLayoutInfo.mSize.width = characterLayoutInfo.mAdvance;
- }
- characterLayoutInfo.mSize.height = characterLayoutInfo.mHeight;
- characterLayoutInfo.mAscender = ascender;
+ // Set's the underline thickness and position.
+ // Both thickness and position includes the vertical pad adjust used in effects like glow or shadow.
if( styledCharacter.mStyle.IsUnderlineEnabled() )
{
- characterLayoutInfo.mUnderlineThickness = font.GetUnderlineThickness(); // Both thickness and position includes the
- characterLayoutInfo.mUnderlinePosition = font.GetUnderlinePosition(); // vertical pad adjust used in effects like glow or shadow.
+ characterLayoutInfo.mUnderlineThickness = font.GetUnderlineThickness();
+ characterLayoutInfo.mUnderlinePosition = font.GetUnderlinePosition();
}
// stores the styled text.