RelayoutParameters::RelayoutParameters()
: mPositionOffset(),
- mLineSize(),
+ mParagraphSize(),
mWordSize(),
mCharacterSize(),
mIndices(),
mIsFirstCharacter( false ),
mIsFirstCharacterOfWord( false ),
mIsNewLine( false ),
- mIsNewLineCharacter( false ),
+ mIsNewParagraphCharacter( false ),
mIsWhiteSpace( false ),
mIsVisible( false )
{
{
}
-SubLineLayoutInfo::SubLineLayoutInfo()
+LineLayoutInfo::LineLayoutInfo()
: mLineLength( 0.f ),
mMaxCharHeight( 0.f ),
mMaxAscender( 0.f )
{
}
-SubLineLayoutInfo::~SubLineLayoutInfo()
+LineLayoutInfo::~LineLayoutInfo()
{
}
* @param[out] lineLength The length of the portion of line which doesn't exceed the parant's width
* @param[out] endWhiteSpaceLength The length of white spaces which are at the end of the line.
*/
-void CalculateLineLength( const bool isWhiteSpace, const float width, const float parentWidth, bool& found, float& lineLength, float& endWhiteSpaceLength )
+void CalculateLineLength( bool isWhiteSpace, float width, float parentWidth, bool& found, float& lineLength, float& endWhiteSpaceLength )
{
if( lineLength + width > parentWidth )
{
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.
currentTextActorInfo.textActor.SetBlendMode( !visualParameters.mSnapshotModeEnabled ? BlendingMode::ON : BlendingMode::OFF );
}
-void CalculateSubLineLayout( const float parentWidth,
- const TextViewProcessor::TextInfoIndices& indices,
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo,
- const HorizontalWrapType splitPolicy,
- const float shrinkFactor,
- SubLineLayoutInfo& subLineInfo )
+void CalculateLineLayout( float parentWidth,
+ const TextViewProcessor::TextInfoIndices& indices,
+ const TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo,
+ HorizontalWrapType splitPolicy,
+ float shrinkFactor,
+ LineLayoutInfo& subLineInfo )
{
subLineInfo.mLineLength = 0.f;
subLineInfo.mMaxCharHeight = 0.f;
float lineOffset = 0.f;
bool found = false;
bool isFirstCharacter = true;
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator wordIt = lineLayoutInfo.mWordsLayoutInfo.begin() + indices.mWordIndex,
- wordEndIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::const_iterator wordIt = paragraphLayoutInfo.mWordsLayoutInfo.begin() + indices.mWordIndex,
+ wordEndIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
( wordIt != wordEndIt ) && !found;
++wordIt )
{
break;
}
case WrapByWord:
- case WrapByLine: // Fall through
+ case WrapByParagraphCharacter: // Fall through
{
splitByCharacter = false;
break;
splitByCharacter = ( shrunkWordWidth > parentWidth );
break;
}
- case WrapByLineAndSplit:
+ case WrapByParagraphCharacterAndSplit:
{
if( ( 0u != characterIndex ) ||
( ( 0u == characterIndex ) && ( lineOffset + shrunkWordWidth > parentWidth ) ) )
subLineInfo.mMaxAscender *= shrinkFactor;
}
-float CalculateXoffset( const Toolkit::Alignment::Type horizontalTextAlignment, const float parentWidth, const float wholeTextWidth )
+float CalculateXoffset( Toolkit::Alignment::Type horizontalTextAlignment, float parentWidth, float wholeTextWidth )
{
float xOffset( 0.f );
switch( horizontalTextAlignment )
return xOffset;
}
-float CalculateYoffset( const Toolkit::Alignment::Type verticalTextAlignment, const float parentHeight, const float wholeTextHeight )
+float CalculateYoffset( Toolkit::Alignment::Type verticalTextAlignment, float parentHeight, float wholeTextHeight )
{
float yOffset( 0.f );
switch( verticalTextAlignment )
return yOffset;
}
-float CalculateJustificationOffset( const Toolkit::TextView::LineJustification justification, const float wholeTextWidth, const float lineLength )
+float CalculateJustificationOffset( Toolkit::TextView::LineJustification justification, float wholeTextWidth, float lineLength )
{
float offset = 0.f;
switch( justification )
return offset;
}
-bool IsVisible( const Vector3& position, const Size& size, const Size& parentSize, const VisibilityTestType type )
+bool IsVisible( const Vector3& position, const Size& size, const Size& parentSize, VisibilityTestType type )
{
bool visible = false;
const float textHorizontalOffset = CalculateXoffset( layoutParameters.mHorizontalAlignment, relayoutData.mTextViewSize.width, relayoutData.mTextSizeForRelayoutOption.width );
const float textVerticalOffset = CalculateYoffset( layoutParameters.mVerticalAlignment, relayoutData.mTextViewSize.height, relayoutData.mTextSizeForRelayoutOption.height );
- std::size_t lineJustificationIndex = 0; // Index to the first position of the vector which stores all line justification info.
- std::size_t infoTableCharacterIndex = 0;
+ std::size_t lineJustificationIndex = 0u; // Index to the first position of the vector which stores all line justification info.
+ std::size_t infoTableCharacterIndex = 0u;
- relayoutParameters.mIndices.mLineIndex = 0;
+ relayoutParameters.mIndices.mParagraphIndex = 0u;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt, ++relayoutParameters.mIndices.mLineIndex )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt, ++relayoutParameters.mIndices.mParagraphIndex )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
float justificationOffset = 0.f;
- relayoutParameters.mIndices.mWordIndex = 0;
+ relayoutParameters.mIndices.mWordIndex = 0u;
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt, ++relayoutParameters.mIndices.mWordIndex )
{
TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordLayoutIt );
- relayoutParameters.mIndices.mCharacterIndex = 0;
+ relayoutParameters.mIndices.mCharacterIndex = 0u;
for( TextViewProcessor::CharacterLayoutInfoContainer::iterator characterLayoutIt = wordLayoutInfo.mCharactersLayoutInfo.begin(),
endCharacterLayoutIt = wordLayoutInfo.mCharactersLayoutInfo.end();
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 lines
+ } // end paragraphs
}
void CalculateBearing( TextViewProcessor::CharacterLayoutInfo& characterLayoutInfo,
// gggggggggg
// gggggggggg
- const Toolkit::TextView::LineLayoutInfo& lineInfo( *( relayoutData.mLines.end() - 1 ) );
+ const Toolkit::TextView::LineLayoutInfo& lineInfo( *( relayoutData.mLines.end() - 1u ) );
const float bearingOffset = ( lineInfo.mSize.height - lineInfo.mAscender ) - ( characterLayoutInfo.mSize.height - characterLayoutInfo.mAscender );
characterLayoutInfo.mPosition.y -= bearingOffset * relayoutData.mShrinkFactor;
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::LineSeparator == wordLayoutInfo.mType ),
+ ( TextViewProcessor::ParagraphSeparator == wordLayoutInfo.mType ),
false, // VCC set the correct direction if needed.
true,
descender );
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
{
ellipsizeText.Append( ellipsizeCharacterLayoutInfo.mStyledText.mText );
TextViewProcessor::UpdateSize( ellipsizeSize, ellipsizeCharacterLayoutInfo.mSize );
}
-
}
if( !ellipsizeText.IsEmpty() )
EllipsizeParameters& ellipsizeParameters,
TextView::RelayoutData& relayoutData )
{
- // Traverses the text layout info from the first character of the laid out line
+ // Traverses the text layout info from the first character of the line
// to the last one setting to each character its visibility. If needed, it adds the ellipsize text (...).
- // Indices to the first character of the laid out line.
+ // Indices to the first character of the line.
TextViewProcessor::TextInfoIndices firstIndices;
TextViewProcessor::GetIndicesFromGlobalCharacterIndex( ellipsizeParameters.mFirstIndex,
relayoutData.mTextLayoutInfo,
firstIndices );
- // Indices to the last character of the laid out line.
+ // Indices to the last character of the line.
TextViewProcessor::TextInfoIndices lastIndices;
TextViewProcessor::GetIndicesFromGlobalCharacterIndex( ellipsizeParameters.mLastIndex,
relayoutData.mTextLayoutInfo,
ellipsizeParameters.mEllipsizeBoundary = relayoutData.mTextViewSize;
ellipsizeParameters.mEllipsizeBoundary.width -= relayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo.mSize.width;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + firstIndices.mLineIndex,
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + lastIndices.mLineIndex + 1u;
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + firstIndices.mParagraphIndex,
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin() + lastIndices.mParagraphIndex + 1u;
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
ellipsizeParameters.mLineFits = ellipsizeParameters.mIsLineWidthFullyVisible && ellipsizeParameters.mIsLineHeightFullyVisible && ellipsizeParameters.mIsNextLineFullyVisibleHeight;
std::size_t wordCount = 0u;
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin() + firstIndices.mWordIndex,
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin() + lastIndices.mWordIndex + 1u;
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin() + firstIndices.mWordIndex,
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin() + lastIndices.mWordIndex + 1u;
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt, ++wordCount )
{
} // end characters
firstWord = false;
} // end words
- } // end lines
+ } // end paragraphs
}
void SetTextVisible( TextView::RelayoutData& relayoutData )
{
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt )
{
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
- } // end lines
+ } // end paragraphs
// Updates the visibility for text-input..
for( std::vector<Toolkit::TextView::CharacterLayoutInfo>::iterator it = relayoutData.mCharacterLayoutInfoTable.begin(),
// Calculates the fade thresholds (from where the text starts to fade out). If any of the fade boundaries is zero, it sets a very small value just to avoid a zero division.
fadeParameters.mRightFadeBoundary = static_cast<float>( visualParameters.mFadeBoundary.mRight );
- fadeParameters.mRightFadeBoundaryOffset = ( visualParameters.mFadeBoundary.mRight > 0 ? fadeParameters.mRightFadeBoundary : MINIMUM_FADE_BOUNDARY );
+ fadeParameters.mRightFadeBoundaryOffset = ( visualParameters.mFadeBoundary.mRight > 0u ? fadeParameters.mRightFadeBoundary : MINIMUM_FADE_BOUNDARY );
fadeParameters.mRightFadeThreshold = relayoutData.mTextViewSize.width - fadeParameters.mRightFadeBoundary;
fadeParameters.mRightFadeThresholdOffset = relayoutData.mTextViewSize.width - fadeParameters.mRightFadeBoundaryOffset;
fadeParameters.mLeftFadeBoundary = static_cast<float>( visualParameters.mFadeBoundary.mLeft );
- fadeParameters.mLeftFadeBoundaryOffset = ( visualParameters.mFadeBoundary.mLeft > 0 ? fadeParameters.mLeftFadeBoundary : MINIMUM_FADE_BOUNDARY );
+ fadeParameters.mLeftFadeBoundaryOffset = ( visualParameters.mFadeBoundary.mLeft > 0u ? fadeParameters.mLeftFadeBoundary : MINIMUM_FADE_BOUNDARY );
fadeParameters.mLeftFadeThreshold = fadeParameters.mLeftFadeBoundary;
fadeParameters.mLeftFadeThresholdOffset = fadeParameters.mLeftFadeBoundaryOffset;
fadeParameters.mTopFadeBoundary = static_cast<float>( visualParameters.mFadeBoundary.mTop );
- fadeParameters.mTopFadeBoundaryOffset = ( visualParameters.mFadeBoundary.mTop > 0 ? fadeParameters.mTopFadeBoundary : MINIMUM_FADE_BOUNDARY );
+ fadeParameters.mTopFadeBoundaryOffset = ( visualParameters.mFadeBoundary.mTop > 0u ? fadeParameters.mTopFadeBoundary : MINIMUM_FADE_BOUNDARY );
fadeParameters.mTopFadeThreshold = fadeParameters.mTopFadeBoundary;
fadeParameters.mTopFadeThresholdOffset = fadeParameters.mTopFadeBoundaryOffset;
fadeParameters.mBottomFadeBoundary = static_cast<float>( visualParameters.mFadeBoundary.mBottom );
- fadeParameters.mBottomFadeBoundaryOffset = ( visualParameters.mFadeBoundary.mBottom > 0 ? fadeParameters.mBottomFadeBoundary : MINIMUM_FADE_BOUNDARY );
+ fadeParameters.mBottomFadeBoundaryOffset = ( visualParameters.mFadeBoundary.mBottom > 0u ? fadeParameters.mBottomFadeBoundary : MINIMUM_FADE_BOUNDARY );
fadeParameters.mBottomFadeThreshold = relayoutData.mTextViewSize.height - fadeParameters.mBottomFadeBoundary;
fadeParameters.mBottomFadeThresholdOffset = relayoutData.mTextViewSize.height - fadeParameters.mBottomFadeBoundaryOffset;
// Traverses all characters and calculates the visibility.
- std::size_t infoTableCharacterIndex = 0;
+ std::size_t infoTableCharacterIndex = 0u;
- relayoutParameters.mIndices.mLineIndex = 0;
+ relayoutParameters.mIndices.mParagraphIndex = 0u;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt, ++relayoutParameters.mIndices.mLineIndex )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt, ++relayoutParameters.mIndices.mParagraphIndex )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
- relayoutParameters.mIndices.mWordIndex = 0;
+ relayoutParameters.mIndices.mWordIndex = 0u;
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt, ++relayoutParameters.mIndices.mWordIndex )
{
relayoutParameters.mIsFirstCharacterOfWord = true;
relayoutParameters.mWordSize = wordLayoutInfo.mSize;
- relayoutParameters.mIndices.mCharacterIndex = 0;
+ relayoutParameters.mIndices.mCharacterIndex = 0u;
for( TextViewProcessor::CharacterLayoutInfoContainer::iterator characterLayoutIt = wordLayoutInfo.mCharactersLayoutInfo.begin(),
endCharacterLayoutIt = wordLayoutInfo.mCharactersLayoutInfo.end();
relayoutParameters.mIsFirstCharacterOfWord = false;
} // end character
} // end words
- } // end lines
+ } // end paragraphs
}
void UpdateVisibilityForEllipsize( const TextView::LayoutParameters& layoutParameters,
const TextView::VisualParameters& visualParameters,
TextView::RelayoutData& relayoutData )
{
- // Traverses the laid-out lines and checks which ones doesn't fit in the text-view's boundary.
+ // Traverses the lines and checks which ones doesn't fit in the text-view's boundary.
for( Toolkit::TextView::LineLayoutInfoContainer::const_iterator lineInfoIt = relayoutData.mLines.begin(), endLineInfoIt = relayoutData.mLines.end();
lineInfoIt != endLineInfoIt;
++lineInfoIt )
{
const Toolkit::TextView::LineLayoutInfo& lineInfo( *lineInfoIt );
- // To check if a laid-out line fits in the text-view's boundary,
+ // To check if a line fits in the text-view's boundary,
// get the position of the first character is needed and do the test
- // with the laid-out line size.
+ // with the line size.
// An bearing offset may have been applied to the first character so it's needed to
// get the start position of the line.
// Retrieves the first index and the last index of the line.
ellipsizeParameters.mFirstIndex = lineInfo.mCharacterGlobalIndex;
- ellipsizeParameters.mLastIndex = 0;
- if( ( lineInfoIt + 1 ) != endLineInfoIt )
+ ellipsizeParameters.mLastIndex = 0u;
+ if( ( lineInfoIt + 1u ) != endLineInfoIt )
{
- const Toolkit::TextView::LineLayoutInfo& nextLineInfo( *( lineInfoIt + 1 ) );
- ellipsizeParameters.mLastIndex = nextLineInfo.mCharacterGlobalIndex - 1;
+ const Toolkit::TextView::LineLayoutInfo& nextLineInfo( *( lineInfoIt + 1u ) );
+ ellipsizeParameters.mLastIndex = nextLineInfo.mCharacterGlobalIndex - 1u;
}
else
{
- ellipsizeParameters.mLastIndex = relayoutData.mCharacterLayoutInfoTable.size() - 1;
+ ellipsizeParameters.mLastIndex = relayoutData.mCharacterLayoutInfoTable.size() - 1u;
}
// Retrieves the first character of the line and build the position of the line with the bearing.
{
// Current line is not ellipsized.
// Need to check if there is a next line and if it's not visible. If there is, current line needs to be ellipsized.
- Toolkit::TextView::LineLayoutInfoContainer::const_iterator nextLineInfoIt = lineInfoIt + 1;
+ Toolkit::TextView::LineLayoutInfoContainer::const_iterator nextLineInfoIt = lineInfoIt + 1u;
if( nextLineInfoIt != endLineInfoIt )
{
// Retrives the position of the first character of the line and remove
}
}
-void UpdateTextActorInfo( const TextView::VisualParameters& visualParameters,
- TextView::RelayoutData& relayoutData )
+/**
+ * Creates an image actor for the emoticon.
+ *
+ * @param[in] visualParameters Some visual parameters (fade, sort modifier and blending).
+ * @param[in,out] characterLayout Layout info for the character.
+ * @param[in] character The character.
+ */
+void CreateEmoticon( const TextView::VisualParameters& visualParameters,
+ TextViewProcessor::CharacterLayoutInfo& characterLayout,
+ const Character& character )
+{
+ // The character is an emoticon.
+ ImageActor imageActor = ImageActor::DownCast( characterLayout.mGlyphActor );
+ if( !imageActor )
+ {
+ imageActor = ImageActor::New();
+
+ GlyphImage image = GlyphImage::New( character );
+
+ if( image )
+ {
+ imageActor.SetImage( image );
+ }
+ }
+
+ imageActor.SetPosition( Vector3( characterLayout.mPosition.x + characterLayout.mOffset.x,
+ characterLayout.mPosition.y + characterLayout.mOffset.y,
+ characterLayout.mPosition.z ) );
+ imageActor.SetSize( characterLayout.mSize );
+
+ // Sets the sort modifier value.
+ imageActor.SetSortModifier( visualParameters.mSortModifier );
+
+ characterLayout.mGlyphActor = imageActor;
+}
+
+/**
+ * Creates text-actors for the given text.
+ *
+ * @param[in] visualParameters Some visual parameters (fade, sort modifier and blending).
+ * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
+ * @param[in,out] paragraph Layout info for the paragraph.
+ * @param[in,out] characterLayout Layout info for the character.
+ * @param[in] character The character.
+ * @param[in] style The character's style.
+ * @param[in,out] currentTextActorInfo Temporary stores the text-actor's info to be set.
+ * @param[in,out] createGlyphActors Whether to initialize renderable-actor handles.
+ */
+void CreateTextActor( const TextView::VisualParameters& visualParameters,
+ TextView::RelayoutData& relayoutData,
+ const TextViewProcessor::ParagraphLayoutInfo& paragraph,
+ TextViewProcessor::CharacterLayoutInfo& characterLayout,
+ const Character& character,
+ const TextStyle& style,
+ CurrentTextActorInfo& currentTextActorInfo,
+ bool createGlyphActors )
+{
+ // Set the text-actor for the current traversed text.
+ if( currentTextActorInfo.textActor )
+ {
+ currentTextActorInfo.textActor.SetText( currentTextActorInfo.text );
+ currentTextActorInfo.textActor.SetPosition( currentTextActorInfo.position );
+ currentTextActorInfo.textActor.SetSize( currentTextActorInfo.size );
+
+ SetVisualParameters( currentTextActorInfo,
+ visualParameters,
+ relayoutData,
+ paragraph.mSize.height );
+ }
+
+ currentTextActorInfo.text = Text( character );
+ currentTextActorInfo.position = Vector3( characterLayout.mPosition.x + characterLayout.mOffset.x,
+ characterLayout.mPosition.y + characterLayout.mOffset.y,
+ characterLayout.mPosition.z );
+ currentTextActorInfo.size = characterLayout.mSize * relayoutData.mShrinkFactor;
+
+ currentTextActorInfo.color = style.GetTextColor();
+ currentTextActorInfo.color.a = characterLayout.mColorAlpha;
+
+ currentTextActorInfo.gradientInfo = characterLayout.mGradientInfo;
+
+ TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
+
+ if( createGlyphActors )
+ {
+ if( textActor )
+ {
+ // Try to reuse first the text-actor of this character.
+ textActor.SetTextStyle( style );
+ }
+ else
+ {
+ // If there is no text-actor, try to retrieve one from the cache.
+ textActor = relayoutData.mTextActorCache.RetrieveTextActor();
+
+ // If still there is no text-actor, create one.
+ if( !textActor )
+ {
+ TextActorParameters parameters( style, TextActorParameters::FONT_DETECTION_OFF );
+ textActor = TextActor::New( Text(), parameters );
+ }
+ else
+ {
+ textActor.SetTextStyle( style );
+ }
+ }
+ characterLayout.mGlyphActor = textActor;
+ }
+
+ // Update the current text-actor.
+ currentTextActorInfo.textActor = textActor;
+}
+
+/**
+ * Traverses the whole paragraph initializating renderable-actor handles and updating them with the new size and position.
+ *
+ * @param[in] visualParameters Some visual parameters (fade, sort modifier and blending).
+ * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
+ * @param[in,out] paragraph Layout info for the paragraph.
+ * @param[in,out] characterGlobalIndex Index to the character within the whole text.
+ * @param[in,out] lineLayoutInfoIndex Index to the table of lines.
+ * @param[in,out] createGlyphActors Whether to initialize renderable-actor handles.
+ */
+void UpdateTextActorInfoForParagraph( const TextView::VisualParameters& visualParameters,
+ TextView::RelayoutData& relayoutData,
+ TextViewProcessor::ParagraphLayoutInfo& paragraph,
+ std::size_t& characterGlobalIndex,
+ std::size_t& lineLayoutInfoIndex,
+ bool createGlyphActors )
{
CurrentTextActorInfo currentTextActorInfo;
- // Traverses the text-actor and layout info data structures.
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt )
+ const std::size_t lineLayoutInfoSize = relayoutData.mLines.size(); // Number of lines.
+ bool lineLayoutEnd = false; // Whether lineLayoutInfoIndex points at the last line.
+ bool glyphActorCreatedForLine = false; // Whether a renderable actor has been created for this line.
+
+ TextStyle currentStyle; // style 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.
+
+ std::vector<TextActor> textActorsToRemove; // Keep a vector of text-actors to be included into the cache.
+
+ std::size_t characterParagraphIndex = 0u; // Index to the character (within the paragraph).
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = paragraph.mWordsLayoutInfo.begin(), wordEndIt = paragraph.mWordsLayoutInfo.end();
+ wordIt != wordEndIt;
+ ++wordIt )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::WordLayoutInfo& word( *wordIt );
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
- wordLayoutIt != endWordLayoutIt;
- ++wordLayoutIt )
+ for( TextViewProcessor::CharacterLayoutInfoContainer::iterator characterIt = word.mCharactersLayoutInfo.begin(), characterEndIt = word.mCharactersLayoutInfo.end();
+ characterIt != characterEndIt;
+ ++characterIt )
{
- TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordLayoutIt );
+ TextViewProcessor::CharacterLayoutInfo& characterLayout( *characterIt );
- for( TextViewProcessor::CharacterLayoutInfoContainer::iterator characterLayoutIt = wordLayoutInfo.mCharactersLayoutInfo.begin(),
- endCharacterLayoutIt = wordLayoutInfo.mCharactersLayoutInfo.end();
- characterLayoutIt != endCharacterLayoutIt;
- ++characterLayoutIt )
+ // Check if there is a new line.
+ const bool newLine = !lineLayoutEnd && ( characterGlobalIndex == relayoutData.mLines[lineLayoutInfoIndex].mCharacterGlobalIndex );
+
+ if( newLine )
{
- TextViewProcessor::CharacterLayoutInfo& characterLayoutInfo( *characterLayoutIt );
+ // Point to the next line.
+ ++lineLayoutInfoIndex;
+ if( lineLayoutInfoIndex >= lineLayoutInfoSize )
+ {
+ // Arrived at last line.
+ lineLayoutEnd = true; // Avoids access out of bounds in the relayoutData.mLines vector.
+ }
+ glyphActorCreatedForLine = false;
+ }
+
+ // Do not create a glyph-actor if there is no text.
+ const Character character = characterLayout.mStyledText.mText[0u]; // there are only one character per character layout.
+ const TextStyle& style = characterLayout.mStyledText.mStyle;
- if( characterLayoutInfo.mIsColorGlyph )
+ bool appendCharacter = false;
+
+ if( characterLayout.mIsColorGlyph ||
+ !character.IsWhiteSpace() || // A new paragraph character is also a white space.
+ ( character.IsWhiteSpace() && style.IsUnderlineEnabled() ) )
+ {
+ // Do not create a glyph-actor if it's a white space (without underline) or a new paragraph character.
+
+ // 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 ) )
{
- ImageActor imageActor = ImageActor::DownCast( characterLayoutInfo.mGlyphActor );
+ differentGradientInfo = true;
+ }
- if( characterLayoutInfo.mSetText )
- {
- GlyphImage image = GlyphImage::New( characterLayoutInfo.mStyledText.mText[0] );
+ // 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.mSetText = false;
+ characterLayout.mSetStyle = false;
- if( image )
- {
- imageActor.SetImage( image );
- }
- characterLayoutInfo.mSetText = false;
+ // There is a new style or a new line.
+ glyphActorCreatedForLine = true;
+
+ if( characterLayout.mIsColorGlyph )
+ {
+ CreateEmoticon( visualParameters,
+ characterLayout,
+ character );
+ }
+ else
+ {
+ CreateTextActor( visualParameters,
+ relayoutData,
+ paragraph,
+ characterLayout,
+ character,
+ style,
+ currentTextActorInfo,
+ createGlyphActors );
}
- imageActor.SetPosition( Vector3( characterLayoutInfo.mPosition.x + characterLayoutInfo.mOffset.x,
- characterLayoutInfo.mPosition.y + characterLayoutInfo.mOffset.y,
- characterLayoutInfo.mPosition.z ) );
- imageActor.SetSize( characterLayoutInfo.mSize );
+ // Update style to be checked with next characters.
+ currentStyle = style;
+ currentGradientInfo = characterLayout.mGradientInfo;
+ currentIsColorGlyph = characterLayout.mIsColorGlyph;
- // Sets the sort modifier value.
- imageActor.SetSortModifier( visualParameters.mSortModifier );
+ characterLayout.mGlyphActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ characterLayout.mGlyphActor.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
}
else
{
- TextActor textActor = TextActor::DownCast( characterLayoutInfo.mGlyphActor );
- if( textActor )
- {
- // There is a new text-actor. Set text and everything to the previous one.
- if( currentTextActorInfo.textActor )
- {
- currentTextActorInfo.textActor.SetText( currentTextActorInfo.text );
- currentTextActorInfo.textActor.SetPosition( currentTextActorInfo.position );
- currentTextActorInfo.textActor.SetSize( currentTextActorInfo.size );
-
- SetVisualParameters( currentTextActorInfo,
- visualParameters,
- relayoutData,
- lineLayoutInfo.mSize.height );
- }
+ DALI_ASSERT_DEBUG( !characterLayout.mIsColorGlyph && "TextViewProcessor::InitializeTextActorInfo. An image-actor doesn't store more than one emoticon." );
- currentTextActorInfo.text = characterLayoutInfo.mStyledText.mText;
- currentTextActorInfo.position = Vector3( characterLayoutInfo.mPosition.x + characterLayoutInfo.mOffset.x,
- characterLayoutInfo.mPosition.y + characterLayoutInfo.mOffset.y,
- characterLayoutInfo.mPosition.z );
- currentTextActorInfo.size = characterLayoutInfo.mSize * relayoutData.mShrinkFactor;
+ // Same style than previous one.
- currentTextActorInfo.color = characterLayoutInfo.mStyledText.mStyle.GetTextColor();
- currentTextActorInfo.color.a = characterLayoutInfo.mColorAlpha;
+ // Add the character to the current text-actor and update the size.
+ appendCharacter = true;
- currentTextActorInfo.gradientColor = characterLayoutInfo.mGradientColor;
- currentTextActorInfo.startPoint = characterLayoutInfo.mStartPoint;
- currentTextActorInfo.endPoint = characterLayoutInfo.mEndPoint;
-
- // Update the current text-actor.
- currentTextActorInfo.textActor = textActor;
- }
- else
+ TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
+ if( textActor )
{
- // If this character layout has no text-actor is because this character has the same style than previous one.
- // Add the character to the current text-actor and update the size.
- if( characterLayoutInfo.mIsVisible && ( TextViewProcessor::LineSeparator != wordLayoutInfo.mType ) )
- {
- currentTextActorInfo.text.Append( characterLayoutInfo.mStyledText.mText );
+ // There is a previously created text-actor for this character.
+ // If this character has another one put it into the cache.
+ textActor.SetText( "" );
+ textActorsToRemove.push_back( textActor );
+ }
- currentTextActorInfo.position.y = std::min( currentTextActorInfo.position.y, ( characterLayoutInfo.mPosition.y + characterLayoutInfo.mOffset.y ) );
- currentTextActorInfo.size.width += characterLayoutInfo.mSize.width * relayoutData.mShrinkFactor;
- currentTextActorInfo.size.height = std::max( currentTextActorInfo.size.height, characterLayoutInfo.mSize.height * relayoutData.mShrinkFactor );
- }
+ if( characterLayout.mGlyphActor )
+ {
+ characterLayout.mGlyphActor.Reset();
}
}
- } // end characters
- } // end words
+ } // no white space / new paragraph char
+ else
+ {
+ appendCharacter = true;
+ }
- if( !currentTextActorInfo.text.IsEmpty() )
- {
- if( currentTextActorInfo.textActor )
+ if( appendCharacter )
{
- currentTextActorInfo.textActor.SetText( currentTextActorInfo.text );
- currentTextActorInfo.textActor.SetPosition( currentTextActorInfo.position );
- currentTextActorInfo.textActor.SetSize( currentTextActorInfo.size );
+ // Add the character to the current text-actor and update the size.
+ if( characterLayout.mIsVisible && ( TextViewProcessor::ParagraphSeparator != word.mType ) )
+ {
+ currentTextActorInfo.text.Append( character );
- SetVisualParameters( currentTextActorInfo,
- visualParameters,
- relayoutData,
- lineLayoutInfo.mSize.height );
+ currentTextActorInfo.position.y = std::min( currentTextActorInfo.position.y, ( characterLayout.mPosition.y + characterLayout.mOffset.y ) );
+ currentTextActorInfo.size.width += characterLayout.mSize.width * relayoutData.mShrinkFactor;
+ currentTextActorInfo.size.height = std::max( currentTextActorInfo.size.height, characterLayout.mSize.height * relayoutData.mShrinkFactor );
+ }
}
+
+ ++characterGlobalIndex;
+ ++characterParagraphIndex;
+ } // characters
+ } // words
+
+ if( !currentTextActorInfo.text.IsEmpty() )
+ {
+ if( currentTextActorInfo.textActor )
+ {
+ currentTextActorInfo.textActor.SetText( currentTextActorInfo.text );
+ currentTextActorInfo.textActor.SetPosition( currentTextActorInfo.position );
+ currentTextActorInfo.textActor.SetSize( currentTextActorInfo.size );
+
+ SetVisualParameters( currentTextActorInfo,
+ visualParameters,
+ relayoutData,
+ paragraph.mSize.height );
}
- } // end lines
+ }
+
+ // Insert the spare text-actors into the cache.
+ relayoutData.mTextActorCache.InsertTextActors( textActorsToRemove );
+}
+void UpdateTextActorInfo( const TextView::VisualParameters& visualParameters,
+ TextView::RelayoutData& relayoutData,
+ bool createGlyphActors )
+{
+ if( relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
+ {
+ // nothing to do if there is no paragraphs.
+ return;
+ }
+
+ std::size_t characterGlobalIndex = 0u; // Index to the global character (within the whole text).
+ std::size_t lineLayoutInfoIndex = 0u; // Index to the line info.
+
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(), paragraphEndIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt )
+ {
+ TextViewProcessor::ParagraphLayoutInfo& paragraph( *paragraphIt );
+
+ UpdateTextActorInfoForParagraph( visualParameters,
+ relayoutData,
+ paragraph,
+ characterGlobalIndex,
+ lineLayoutInfoIndex,
+ createGlyphActors );
+ } // paragraphs
+
+ // Set visual parameters for ellipsis renderable actors.
for( std::vector<RenderableActor>::iterator it = relayoutData.mEllipsizedGlyphActors.begin(),
endIt = relayoutData.mEllipsizedGlyphActors.end();
it != endIt;
void CalculateUnderlineInfo( TextView::RelayoutData& relayoutData, TextViewRelayout::TextUnderlineStatus& textUnderlineStatus )
{
- // Traverse the whole text to find all groups of consecutive underlined characters in the same laid-out line.
+ // Traverse the whole text to find all groups of consecutive underlined characters in the same line.
//
- // Note that relayoutData.mTextLayoutInfo contains layout info per line but these lines are the result of split the whole text every time a '\n' is found.
- // According with the layout option, one of this lines could be laid-out in more than one.
+ // Note that relayoutData.mTextLayoutInfo contains layout info per paragraph but these paragraphs are the result of split the whole text every time a '\n' is found.
+ // According with the layout option, one of this paragraphs could be laid-out in more than one line.
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineIt != lineEndIt;
- ++lineIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(), paragraphEndIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt )
{
- TextViewProcessor::LineLayoutInfo& line( *lineIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraph( *paragraphIt );
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = line.mWordsLayoutInfo.begin(), wordEndIt = line.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = paragraph.mWordsLayoutInfo.begin(), wordEndIt = paragraph.mWordsLayoutInfo.end();
wordIt != wordEndIt;
++wordIt )
{
{
TextViewProcessor::CharacterLayoutInfo& character( *characterIt );
- // Check if current character is the first of a new laid-out line
+ // Check if current character is the first of a new line
const bool isNewLine = ( textUnderlineStatus.mLineGlobalIndex < relayoutData.mLines.size() ) &&
( textUnderlineStatus.mCharacterGlobalIndex == ( *( relayoutData.mLines.begin() + textUnderlineStatus.mLineGlobalIndex ) ).mCharacterGlobalIndex );
if( isNewLine )
if( character.mStyledText.mStyle.IsUnderlineEnabled() )
{
if( !textUnderlineStatus.mCurrentUnderlineStatus || // Current character is underlined but previous one it wasn't.
- isNewLine ) // Current character is underlined and is the first of current laid-out line.
+ isNewLine ) // Current character is underlined and is the first of current line.
{
// Create a new underline info for the current underlined characters.
UnderlineInfo underlineInfo;
else
{
// Retrieve last underline info and update it if current underline thickness is bigger.
- UnderlineInfo& underlineInfo( *( textUnderlineStatus.mUnderlineInfo.end() - 1 ) );
+ UnderlineInfo& underlineInfo( *( textUnderlineStatus.mUnderlineInfo.end() - 1u ) );
underlineInfo.mMaxHeight = std::max( underlineInfo.mMaxHeight, character.mSize.height );
++textUnderlineStatus.mCharacterGlobalIndex;
} // end characters.
} // end words.
- } // end lines.
+ } // end paragraphs.
}
void SetUnderlineInfo( TextView::RelayoutData& relayoutData )
{
- // Stores for each group of consecutive underlined characters in each laid-out line its maximum thicknes, its position of that thickness and the maximum character's height.
+ // Stores for each group of consecutive underlined characters in each line its maximum thicknes, its position of that thickness and the maximum character's height.
TextViewRelayout::TextUnderlineStatus textUnderlineStatus;
- // Traverse the whole text to find all groups of consecutive underlined characters in the same laid-out line.
+ // Traverse the whole text to find all groups of consecutive underlined characters in the same line.
CalculateUnderlineInfo( relayoutData, textUnderlineStatus );
if( textUnderlineStatus.mUnderlineInfo.empty() )
// Whether current text is underlined.
textUnderlineStatus.mCurrentUnderlineStatus = false;
- textUnderlineStatus.mCharacterGlobalIndex = 0;
- textUnderlineStatus.mLineGlobalIndex = 0;
+ textUnderlineStatus.mCharacterGlobalIndex = 0u;
+ textUnderlineStatus.mLineGlobalIndex = 0u;
float currentLineHeight = 0.f;
float currentLineAscender = 0.f;
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineIt != lineEndIt;
- ++lineIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(), paragraphEndIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphIt != paragraphEndIt;
+ ++paragraphIt )
{
- TextViewProcessor::LineLayoutInfo& line( *lineIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraph( *paragraphIt );
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = line.mWordsLayoutInfo.begin(), wordEndIt = line.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = paragraph.mWordsLayoutInfo.begin(), wordEndIt = paragraph.mWordsLayoutInfo.end();
wordIt != wordEndIt;
++wordIt )
{
{
TextViewProcessor::CharacterLayoutInfo& character( *characterIt );
- // Check if current character is the first of a new laid-out line
+ // Check if current character is the first of a new line
bool isNewLine = false;
++textUnderlineStatus.mCharacterGlobalIndex;
} // end of characters.
} // end of word.
- } // end of lines.
+ } // end of paragraphs.
}
void RemoveGlyphActors( Actor textView,
}
}
-void InsertToTextView( const TextView::RelayoutOperationMask relayoutOperationMask,
- Actor textView,
+void InsertToTextView( Actor textView,
TextView::RelayoutData& relayoutData )
{
- const bool insertToTextView = relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_VIEW;
- const bool insertToTextActorList = relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST;
-
// Add text-actors to the text-view.
- for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
- endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
- lineLayoutIt != endLineLayoutIt;
- ++lineLayoutIt )
+ for( TextViewProcessor::ParagraphLayoutInfoContainer::iterator paragraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin(),
+ endParagraphLayoutIt = relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.end();
+ paragraphLayoutIt != endParagraphLayoutIt;
+ ++paragraphLayoutIt )
{
- TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
+ TextViewProcessor::ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphLayoutIt );
- for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ endWordLayoutIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
wordLayoutIt != endWordLayoutIt;
++wordLayoutIt )
{
if( characterLayoutInfo.mIsVisible && characterLayoutInfo.mGlyphActor ) // White spaces and '\n' characters doesn't have a text-actor.
{
//Add to the text-view.
- if( insertToTextView )
- {
- textView.Add( characterLayoutInfo.mGlyphActor );
- }
- if( insertToTextActorList )
- {
- relayoutData.mGlyphActors.push_back( characterLayoutInfo.mGlyphActor );
- }
+ textView.Add( characterLayoutInfo.mGlyphActor );
+ relayoutData.mGlyphActors.push_back( characterLayoutInfo.mGlyphActor );
}
} // end character
} // end words
- } // end lines
+ } // end paragraphs
for( std::vector<RenderableActor>::iterator it = relayoutData.mEllipsizedGlyphActors.begin(),
endIt = relayoutData.mEllipsizedGlyphActors.end();
RenderableActor glyphActor = ( *it );
//Add to the text-view.
- if( insertToTextView )
- {
- textView.Add( glyphActor );
- }
- if( insertToTextActorList )
- {
- relayoutData.mGlyphActors.push_back( glyphActor );
- }
+ textView.Add( glyphActor );
+ relayoutData.mGlyphActors.push_back( glyphActor );
}
relayoutData.mEllipsizedGlyphActors.clear();
}