const char* const PROPERTY_WIDTH_EXCEED_POLICY = "width-exceed-policy";
const char* const PROPERTY_HEIGHT_EXCEED_POLICY = "height-exceed-policy";
const char* const PROPERTY_LINE_JUSTIFICATION = "line-justification";
-const char* const PROPERTY_FADE_BOUNDARY_LEFT = "fade-boundary-left";
-const char* const PROPERTY_FADE_BOUNDARY_RIGHT = "fade-boundary-right";
-const char* const PROPERTY_FADE_BOUNDARY_TOP = "fade-boundary-top";
-const char* const PROPERTY_FADE_BOUNDARY_BOTTOM = "fade-boundary-bottom";
+const char* const PROPERTY_FADE_BOUNDARY = "fade-boundary";
const char* const PROPERTY_LINE_HEIGHT_OFFSET = "line-height-offset";
const char* const PROPERTY_HORIZONTAL_ALIGNMENT = "horizontal-alignment";
const char* const PROPERTY_VERTICAL_ALIGNMENT = "vertical-alignment";
DALI_TEST_CHECK( Toolkit::TextView::Justified == view.GetLineJustification() );
//Test fade boundary property
- unsigned int testValue = 23;
- PixelSize leftFadeBoundary(testValue);
- view.SetProperty(view.GetPropertyIndex(PROPERTY_FADE_BOUNDARY_LEFT), testValue);
- DALI_TEST_CHECK( leftFadeBoundary == view.GetFadeBoundary().mLeft );
-
- testValue = 26;
- PixelSize rightFadeBoundary(testValue);
- view.SetProperty(view.GetPropertyIndex(PROPERTY_FADE_BOUNDARY_RIGHT), testValue);
- DALI_TEST_CHECK( rightFadeBoundary == view.GetFadeBoundary().mRight );
-
- testValue = 2;
- PixelSize topFadeBoundary(testValue);
- view.SetProperty(view.GetPropertyIndex(PROPERTY_FADE_BOUNDARY_TOP), testValue);
- DALI_TEST_CHECK( topFadeBoundary == view.GetFadeBoundary().mTop );
-
- testValue = 11;
- PixelSize bottomFadeBoundary(testValue);
- view.SetProperty(view.GetPropertyIndex(PROPERTY_FADE_BOUNDARY_BOTTOM), testValue);
- DALI_TEST_CHECK( bottomFadeBoundary == view.GetFadeBoundary().mBottom );
+ const Vector4 testValue( 23.f, 26.f, 2.f, 11.f );
+
+ view.SetProperty(view.GetPropertyIndex(PROPERTY_FADE_BOUNDARY), testValue);
+ DALI_TEST_CHECK( testValue.x == view.GetFadeBoundary().mLeft );
+ DALI_TEST_CHECK( testValue.y == view.GetFadeBoundary().mRight );
+ DALI_TEST_CHECK( testValue.z == view.GetFadeBoundary().mTop );
+ DALI_TEST_CHECK( testValue.w == view.GetFadeBoundary().mBottom );
//Test Line height offset property
float testOffsetValue = 14.04f;
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.mLineIndex = 0u;
for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
float justificationOffset = 0.f;
- relayoutParameters.mIndices.mWordIndex = 0;
+ relayoutParameters.mIndices.mWordIndex = 0u;
for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
{
TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordLayoutIt );
- relayoutParameters.mIndices.mCharacterIndex = 0;
+ relayoutParameters.mIndices.mCharacterIndex = 0u;
for( TextViewProcessor::CharacterLayoutInfoContainer::iterator characterLayoutIt = wordLayoutInfo.mCharactersLayoutInfo.begin(),
endCharacterLayoutIt = wordLayoutInfo.mCharactersLayoutInfo.end();
// 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;
ellipsizeText.Append( ellipsizeCharacterLayoutInfo.mStyledText.mText );
TextViewProcessor::UpdateSize( ellipsizeSize, ellipsizeCharacterLayoutInfo.mSize );
}
-
}
if( !ellipsizeText.IsEmpty() )
// 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.mLineIndex = 0u;
for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
{
TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *lineLayoutIt );
- relayoutParameters.mIndices.mWordIndex = 0;
+ relayoutParameters.mIndices.mWordIndex = 0u;
for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
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();
// 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] line Layout info for the line.
+ * @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::LineLayoutInfo& line,
+ 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,
+ line.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.gradientColor = characterLayout.mGradientColor;
+ currentTextActorInfo.startPoint = characterLayout.mStartPoint;
+ currentTextActorInfo.endPoint = characterLayout.mEndPoint;
+
+ 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 line 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] line Layout info for the line.
+ * @param[in,out] characterGlobalIndex Index to the character within the whole text.
+ * @param[in,out] lineLayoutInfoIndex Index to the table of laid out lines.
+ * @param[in,out] createGlyphActors Whether to initialize renderable-actor handles.
+ */
+void UpdateTextActorInfoForLine( const TextView::VisualParameters& visualParameters,
+ TextView::RelayoutData& relayoutData,
+ TextViewProcessor::LineLayoutInfo& line,
+ 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 laid out lines.
+ bool lineLayoutEnd = false; // Whether lineLayoutInfoIndex points at the last laid out line.
+ bool glyphActorCreatedForLine = false; // Whether a renderable actor has been created for this line.
+
+ 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.
+
+ 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 characterLineIndex = 0u; // Index to the character (within the line).
+ for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = line.mWordsLayoutInfo.begin(), wordEndIt = line.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;
+
+ bool appendCharacter = false;
- if( characterLayoutInfo.mIsColorGlyph )
+ if( characterLayout.mIsColorGlyph ||
+ !character.IsWhiteSpace() || // A new line 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 line character.
+
+ // 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 ||
+ ( characterLayout.mIsColorGlyph != currentIsColorGlyph ) ||
+ ( style != currentStyle ) ||
+ ( characterLayout.mGradientColor != currentGradientColor ) ||
+ ( characterLayout.mStartPoint != currentStartPoint ) ||
+ ( characterLayout.mEndPoint != currentEndPoint ) )
{
- ImageActor imageActor = ImageActor::DownCast( characterLayoutInfo.mGlyphActor );
+ characterLayout.mSetText = false;
+ characterLayout.mSetStyle = false;
- if( characterLayoutInfo.mSetText )
- {
- GlyphImage image = GlyphImage::New( characterLayoutInfo.mStyledText.mText[0] );
+ // There is a new style or a new line.
+ glyphActorCreatedForLine = true;
- if( image )
- {
- imageActor.SetImage( image );
- }
- characterLayoutInfo.mSetText = false;
+ if( characterLayout.mIsColorGlyph )
+ {
+ CreateEmoticon( visualParameters,
+ characterLayout,
+ character );
+ }
+ else
+ {
+ CreateTextActor( visualParameters,
+ relayoutData,
+ line,
+ 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;
+ currentGradientColor = characterLayout.mGradientColor;
+ currentStartPoint = characterLayout.mStartPoint;
+ currentEndPoint = characterLayout.mEndPoint;
+ 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 line 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::LineSeparator != 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;
+ ++characterLineIndex;
+ } // 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,
+ line.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.mLinesLayoutInfo.empty() )
+ {
+ // nothing to do if there is no lines.
+ return;
+ }
+
+ std::size_t characterGlobalIndex = 0u; // Index to the global character (within the whole text).
+ std::size_t lineLayoutInfoIndex = 0u; // Index to the laid out line info.
+
+ for( TextViewProcessor::LineLayoutInfoContainer::iterator lineIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
+ lineIt != lineEndIt;
+ ++lineIt )
+ {
+ TextViewProcessor::LineLayoutInfo& line( *lineIt );
+
+ UpdateTextActorInfoForLine( visualParameters,
+ relayoutData,
+ line,
+ characterGlobalIndex,
+ lineLayoutInfoIndex,
+ createGlyphActors );
+ } // lines
for( std::vector<RenderableActor>::iterator it = relayoutData.mEllipsizedGlyphActors.begin(),
endIt = relayoutData.mEllipsizedGlyphActors.end();
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 );
// 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;
}
}
-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(),
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
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();
}
TextView::RelayoutData& relayoutData );
/**
- * Traverse all text updating text-actor handles with new size, position, ...
+ * Traverse all text initializing all non initialized text-actor handles
+ * and updating text-actor handles with new size, 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] createGlyphActors Whether to create RenderableActor for text-actors or emojis.
*/
void UpdateTextActorInfo( const TextView::VisualParameters& visualParameters,
- TextView::RelayoutData& relayoutData );
+ TextView::RelayoutData& relayoutData,
+ bool createGlyphActors );
/**
* Traverses the whole text and for each piece of underlined text,
const std::vector<RenderableActor>& glyphActors );
/**
- * Inserts the text-actors into the text-view and/or the text-actor's list.
+ * Inserts the text-actors into the text-view and the text-actor's list.
*
- * @param[in] relayoutOperationMask Whether the text-actors should be added into the text-view, the list of text-actors or in both.
* @param[in,out] textView The text-view.
* @param[in,out] relayoutData The text-view's data structures.
*/
-void InsertToTextView( TextView::RelayoutOperationMask relayoutOperationMask,
- Actor textView,
+void InsertToTextView( Actor textView,
TextView::RelayoutData& relayoutData );
/**
relayoutParameters.mPositionOffset = Vector3::ZERO;
relayoutParameters.mIsFirstCharacter = true;
- relayoutParameters.mIndices.mLineIndex = 0;
- relayoutParameters.mCharacterGlobalIndex = 0;
+ relayoutParameters.mIndices.mLineIndex = 0u;
+ relayoutParameters.mCharacterGlobalIndex = 0u;
for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
relayoutParameters.mIsNewLine = true;
relayoutParameters.mLineSize = lineLayoutInfo.mSize;
- relayoutParameters.mIndices.mWordIndex = 0;
+ relayoutParameters.mIndices.mWordIndex = 0u;
for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
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();
// Check if the last character is a new line character. In that case the height should be added.
if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1 ) );
+ const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
if( lineLayoutInfo.mWordsLayoutInfo.empty() ) // if it's empty, it means the last character is a new line character.
{
relayoutData );
}
- if( relayoutOperationMask & TextView::RELAYOUT_INITIALIZE_TEXT_ACTORS )
- {
- TextViewProcessor::InitializeTextActorInfo( relayoutData );
- }
-
- if( relayoutOperationMask & TextView::RELAYOUT_TEXT_ACTOR_UPDATE )
+ const bool initializeTextActors = relayoutOperationMask & TextView::RELAYOUT_INITIALIZE_TEXT_ACTORS;
+ const bool updateTextActors = relayoutOperationMask & TextView::RELAYOUT_TEXT_ACTOR_UPDATE;
+ if( initializeTextActors || updateTextActors )
{
TextViewRelayout::UpdateTextActorInfo( visualParameters,
- relayoutData );
+ relayoutData,
+ initializeTextActors );
}
- if( ( relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_VIEW ) ||
- ( relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST ) )
+ if( relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_VIEW )
{
- TextViewRelayout::InsertToTextView( relayoutOperationMask,
- textView,
+ TextViewRelayout::InsertToTextView( textView,
relayoutData );
}
}
}
relayoutParameters.mIsFirstCharacter = true;
- relayoutParameters.mIndices.mLineIndex = 0;
+ relayoutParameters.mIndices.mLineIndex = 0u;
relayoutParameters.mPositionOffset = Vector3::ZERO;
- relayoutParameters.mCharacterGlobalIndex = 0;
+ relayoutParameters.mCharacterGlobalIndex = 0u;
for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
relayoutParameters.mLineSize = lineLayoutInfo.mSize * relayoutData.mShrinkFactor;
relayoutParameters.mIsNewLine = true;
- relayoutParameters.mIndices.mWordIndex = 0;
+ relayoutParameters.mIndices.mWordIndex = 0u;
for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
relayoutParameters.mIsFirstCharacterOfWord = true;
relayoutParameters.mWordSize = wordLayoutInfo.mSize;
- relayoutParameters.mIndices.mCharacterIndex = 0;
+ relayoutParameters.mIndices.mCharacterIndex = 0u;
if( relayoutParameters.mIsNewLine )
{
// Check if the last character is a new line character. In that case the height should be added.
if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1 ) );
+ const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
if( lineLayoutInfo.mWordsLayoutInfo.empty() ) // if it's empty, it means the last character is a new line character.
{
relayoutData );
}
- if( relayoutOperationMask & TextView::RELAYOUT_INITIALIZE_TEXT_ACTORS )
- {
- TextViewProcessor::InitializeTextActorInfo( relayoutData );
- }
-
- if( relayoutOperationMask & TextView::RELAYOUT_TEXT_ACTOR_UPDATE )
+ const bool initializeTextActors = relayoutOperationMask & TextView::RELAYOUT_INITIALIZE_TEXT_ACTORS;
+ const bool updateTextActors = relayoutOperationMask & TextView::RELAYOUT_TEXT_ACTOR_UPDATE;
+ if( initializeTextActors || updateTextActors )
{
TextViewRelayout::UpdateTextActorInfo( visualParameters,
- relayoutData );
+ relayoutData,
+ initializeTextActors );
}
- if( ( relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_VIEW ) ||
- ( relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST ) )
+ if( relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_VIEW )
{
- TextViewRelayout::InsertToTextView( relayoutOperationMask,
- textView,
+ TextViewRelayout::InsertToTextView( textView,
relayoutData );
}
}
float lastCharHeight = 0.f;
relayoutData.mLines.clear();
- std::size_t characterGlobalIndex = 0;
+ std::size_t characterGlobalIndex = 0u;
for( TextViewProcessor::LineLayoutInfoContainer::iterator lineIt = textLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = textLayoutInfo.mLinesLayoutInfo.end();
lineIt != lineEndIt;
// The next character is in a new line.
bool isNewLine = true;
-
// Reset the index of words.
- indices.mWordIndex = 0;
+ indices.mWordIndex = 0u;
for( TextViewProcessor::WordLayoutInfoContainer::iterator wordIt = lineLayoutInfo.mWordsLayoutInfo.begin(), wordEndIt = lineLayoutInfo.mWordsLayoutInfo.end();
wordIt != wordEndIt;
TextViewProcessor::WordLayoutInfo& wordLayoutInfo( *wordIt );
// Reset the index of the character.
- indices.mCharacterIndex = 0;
+ indices.mCharacterIndex = 0u;
// Whether current character is the first of the word.
bool isFirstCharOfWord = true;
lineInfo.mAscender = subLineInfo.mMaxAscender; // Ascender of this piece of line.
relayoutData.mLines.push_back( lineInfo );
-
// Stores some info to calculate the line justification in a post-process.
TextView::LineJustificationInfo justificationInfo;
}
// Get last line info and calculate the bearing.
- 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 ) ) * shrinkFactor;
previousSize = characterLayoutInfo.mSize * shrinkFactor;
const float MIN_RATIO( 0.90f ); // The algorithm finishes if the ratio
const float MAX_RATIO( 1.00f ); // new_text_height / text_view_height is between this two values
- const unsigned int MAX_ITERATIONS( 8 ); // or max_iteration is reached.
+ const unsigned int MAX_ITERATIONS( 8u ); // or max_iteration is reached.
float ratio = newTextHeight / textViewSize.height;
float maxScaleFactor = shrinkFactor; // bigger scale factors than maxScaleFactor will produce a too big text.
float minScaleFactor = shrinkFactor * ( textViewSize.height / newTextHeight ); // smaller scale factors than minScaleFactor will produce a too small text.
- for( unsigned int iterations = 0; ( ( MIN_RATIO > ratio ) || ( ratio > MAX_RATIO ) ) && ( iterations < MAX_ITERATIONS ); ++iterations )
+ for( unsigned int iterations = 0u; ( ( MIN_RATIO > ratio ) || ( ratio > MAX_RATIO ) ) && ( iterations < MAX_ITERATIONS ); ++iterations )
{
// Calculates the new scale factor.
// The new scale factor is always between the min and max scale factors.
relayoutData.mShrinkFactor = 1.f; // Shrink factor used when the exceed policy contains ShrinkToFit
- if( TextView::Shrink== layoutParameters.mExceedPolicy )
+ if( TextView::Shrink == layoutParameters.mExceedPolicy )
{
// Relays-out the text for the shrink to fit policy.
relayoutData.mShrinkFactor = RelayoutForShrinkToFit( relayoutData, layoutParameters );
relayoutParameters.mPositionOffset = Vector3::ZERO;
relayoutParameters.mIsFirstCharacter = true;
- relayoutParameters.mIndices.mLineIndex = 0;
- relayoutParameters.mCharacterGlobalIndex = 0;
+ relayoutParameters.mIndices.mLineIndex = 0u;
+ relayoutParameters.mCharacterGlobalIndex = 0u;
for( TextViewProcessor::LineLayoutInfoContainer::iterator lineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin(),
endLineLayoutIt = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end();
relayoutParameters.mIsNewLine = true;
relayoutParameters.mLineSize = lineLayoutInfo.mSize;
- relayoutParameters.mIndices.mWordIndex = 0;
+ relayoutParameters.mIndices.mWordIndex = 0u;
for( TextViewProcessor::WordLayoutInfoContainer::iterator wordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
endWordLayoutIt = lineLayoutInfo.mWordsLayoutInfo.end();
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();
// Check if the last character is a new line character. In that case the height should be added.
if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
{
- const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1 ) );
+ const TextViewProcessor::LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
if( lineLayoutInfo.mWordsLayoutInfo.empty() ) // if it's empty, it means the last character is a new line character.
{
visualParameters,
relayoutData );
}
-
- if( relayoutOperationMask & TextView::RELAYOUT_INITIALIZE_TEXT_ACTORS )
- {
- TextViewProcessor::InitializeTextActorInfo( relayoutData );
- }
-
- if( relayoutOperationMask & TextView::RELAYOUT_TEXT_ACTOR_UPDATE )
+ const bool initializeTextActors = relayoutOperationMask & TextView::RELAYOUT_INITIALIZE_TEXT_ACTORS;
+ const bool updateTextActors = relayoutOperationMask & TextView::RELAYOUT_TEXT_ACTOR_UPDATE;
+ if( initializeTextActors || updateTextActors )
{
TextViewRelayout::UpdateTextActorInfo( visualParameters,
- relayoutData );
+ relayoutData,
+ initializeTextActors );
}
- if( ( relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_VIEW ) ||
- ( relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST ) )
+ if( relayoutOperationMask & TextView::RELAYOUT_INSERT_TO_TEXT_VIEW )
{
- TextViewRelayout::InsertToTextView( relayoutOperationMask,
- textView,
+ TextViewRelayout::InsertToTextView( textView,
relayoutData );
}
}
{
const MarkupProcessor::StyledText& styledText( *it );
- for( size_t i = 0, length = styledText.mText.GetLength(); i < length; ++i )
+ for( size_t i = 0u, length = styledText.mText.GetLength(); i < length; ++i )
{
const Dali::Character character = styledText.mText[i];
for( MarkupProcessor::StyledTextArray::const_iterator it = line.begin(), endIt = line.end(); it != endIt; ++it )
{
const MarkupProcessor::StyledText& styledText( *it );
- const Dali::Character character = styledText.mText[0];
+ const Dali::Character character = styledText.mText[0u];
if( character.IsWhiteSpace() )
{
{
const Text& text( (*it).mText );
- for( size_t i = 0, length = text.GetLength(); i < length; ++i )
+ for( size_t i = 0u, length = text.GetLength(); i < length; ++i )
{
Character::CharacterDirection direction = text[i].GetCharacterDirection();
if( direction != Character::Neutral )
bool BeginsRightToLeftCharacter( const Text& text )
{
- for( size_t i = 0, length = text.GetLength(); i < length; ++i )
+ for( size_t i = 0u, length = text.GetLength(); i < length; ++i )
{
Character::CharacterDirection direction = text[i].GetCharacterDirection();
if( direction != Character::Neutral )
{
const Text& text( (*it).mText );
- for( size_t i = 0, length = text.GetLength(); i < length; ++i )
+ for( size_t i = 0u, length = text.GetLength(); i < length; ++i )
{
Character::CharacterDirection direction = text[i].GetCharacterDirection();
if( ( Character::RightToLeft == direction ) || ( Character::RightToLeftWeak == direction ) )
bool ContainsRightToLeftCharacter( const Dali::Text& text )
{
- for( size_t i = 0, length = text.GetLength(); i < length; ++i )
+ for( size_t i = 0u, length = text.GetLength(); i < length; ++i )
{
Character::CharacterDirection direction = ( text[i] ).GetCharacterDirection();
if( ( Character::RightToLeft == direction ) || ( Character::RightToLeftWeak == direction ) )
// pad these buffers with 0's, as it's unclear what fribidi_log2vis does w.r.t.
// the length of it's output content (appears the same as input content, and does
// not seem to generate bidi marks i.e. FRIBIDI_CHAR_LRM/FRIBIDI_CHAR_RLM)
- logicalStrBuffer.resize( stringSize+1, 0 );
- visualStrBuffer.resize( stringSize+1, 0 );
- FriBidiChar *logicalStr( &logicalStrBuffer[0] );
- FriBidiChar *visualStr( &visualStrBuffer[0] );
+ logicalStrBuffer.resize( stringSize+1u, 0u );
+ visualStrBuffer.resize( stringSize+1u, 0u );
+ FriBidiChar *logicalStr( &logicalStrBuffer[0u] );
+ FriBidiChar *visualStr( &visualStrBuffer[0u] );
// Convert UTF-8 string to unicode string
const std::size_t length = fribidi_charset_to_unicode( FRIBIDI_CHAR_SET_UTF8, textToBeConverted.c_str(), stringSize, logicalStr );
- if( 0 == length )
+ if( 0u == length )
{
DALI_ASSERT_DEBUG( !"TextProcessor::ConvertBidirectionalText. Error when calling at fribidi_charset_to_unicode" );
// Convert and reorder the string as specified by the Unicode Bidirectional Algorithm
FriBidiCharType baseDirection = FRIBIDI_TYPE_ON;
- fribidi_boolean log2vis = fribidi_log2vis( logicalStr, length, &baseDirection, visualStr, &logicalToVisualMap[0], &visualToLogicalMap[0], NULL );
+ fribidi_boolean log2vis = fribidi_log2vis( logicalStr, length, &baseDirection, visualStr, &logicalToVisualMap[0u], &visualToLogicalMap[0u], NULL );
if(log2vis)
{
// Convert the unicode string back to the UTF-8 string
std::vector<char> bidiTextConverted;
- bidiTextConverted.resize( length * 4 + 1 ); // Maximum bytes to represent one UTF-8 character is 6.
+ bidiTextConverted.resize( length * 4u + 1u ); // Maximum bytes to represent one UTF-8 character is 6.
// Currently Dali doesn't support this UTF-8 extension. Dali only supports 'regular' UTF-8 which has a maximum of 4 bytes per character.
- fribidi_unicode_to_charset( FRIBIDI_CHAR_SET_UTF8, visualStr, length, &bidiTextConverted[0] );
+ fribidi_unicode_to_charset( FRIBIDI_CHAR_SET_UTF8, visualStr, length, &bidiTextConverted[0u] );
- textToBeConverted = &bidiTextConverted[0];
+ textToBeConverted = &bidiTextConverted[0u];
// After reorder the text, rebuild the text with the original styles is needed.
// To assign the original style is needed to use the characterLogicalToVisualMap table.
- Text text( &bidiTextConverted[0] );
+ Text text( &bidiTextConverted[0u] );
// Split the line in words.
// Add the correct styles for the characters after they are reordered.
- for( size_t i = 0; i < length; ++i )
+ for( size_t i = 0u; i < length; ++i )
{
const Character character( text[i] );
DALI_ASSERT_DEBUG( offset < text.size() );
// assume 1 Character per StyledText
- return text[offset].mText[0].IsWhiteSpace();
+ return text[offset].mText[0u].IsWhiteSpace();
}
void FindNearestWord( const MarkupProcessor::StyledTextArray& text, size_t offset, size_t& start, size_t& end)
{
const size_t size(text.size());
- offset = std::min(offset, size-1);
+ offset = std::min(offset, size-1u);
size_t i(offset);
size_t j(offset);
if(IsWhiteSpace(text, offset))
{
// scan left until non-white space / beginning of string.
- while(i > 0 && IsWhiteSpace(text, i))
+ while(i > 0u && IsWhiteSpace(text, i))
{
i--;
}
}
// expand left and right markers to encompase entire word
- while(i > 0 && !IsWhiteSpace(text, i-1))
+ while(i > 0u && !IsWhiteSpace(text, i-1u))
{
i--;
}
TextView::TextViewProcessorMetadata::TextViewProcessorMetadata()
: mType( TextView::TextSet ),
- mPosition( 0 ),
- mNumberOfCharacters( 0 ),
+ mPosition( 0u ),
+ mNumberOfCharacters( 0u ),
mText()
{
}
RELAYOUT_ALIGNMENT |
RELAYOUT_VISIBILITY |
RELAYOUT_TEXT_ACTOR_UPDATE |
- RELAYOUT_INSERT_TO_TEXT_VIEW |
- RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+ RELAYOUT_INSERT_TO_TEXT_VIEW );
}
}
}
RELAYOUT_ALIGNMENT |
RELAYOUT_VISIBILITY |
RELAYOUT_TEXT_ACTOR_UPDATE |
- RELAYOUT_INSERT_TO_TEXT_VIEW |
- RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+ RELAYOUT_INSERT_TO_TEXT_VIEW );
}
}
}
RELAYOUT_ALIGNMENT |
RELAYOUT_VISIBILITY |
RELAYOUT_TEXT_ACTOR_UPDATE |
- RELAYOUT_INSERT_TO_TEXT_VIEW |
- RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+ RELAYOUT_INSERT_TO_TEXT_VIEW );
}
}
}
RELAYOUT_REMOVE_TEXT_ACTORS |
RELAYOUT_VISIBILITY |
RELAYOUT_TEXT_ACTOR_UPDATE |
- RELAYOUT_INSERT_TO_TEXT_VIEW |
- RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+ RELAYOUT_INSERT_TO_TEXT_VIEW );
}
}
}
if( hasGlyphActors )
{
mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
- mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
}
}
mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations |
RELAYOUT_REMOVE_TEXT_ACTORS |
RELAYOUT_TEXT_ACTOR_UPDATE |
- RELAYOUT_INSERT_TO_TEXT_VIEW |
- RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+ RELAYOUT_INSERT_TO_TEXT_VIEW );
}
RelayoutRequest();
}
mRelayoutData.mGlyphActors.clear();
mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
- mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
}
PerformTextViewProcessorOperations();
if( hasGlyphActors )
{
mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
- mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
}
if( differentWidth || hasGlyphActors )
RELAYOUT_ALIGNMENT |
RELAYOUT_VISIBILITY |
RELAYOUT_TEXT_ACTOR_UPDATE |
- RELAYOUT_INSERT_TO_TEXT_VIEW |
- RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+ RELAYOUT_INSERT_TO_TEXT_VIEW );
}
}
{
bool optimizationDone = false;
- if( it + 1 != endIt )
+ if( it + 1u != endIt )
{
- const TextViewProcessorMetadata& nextRelayoutMetadata( *( it + 1 ) );
+ const TextViewProcessorMetadata& nextRelayoutMetadata( *( it + 1u ) );
if( TextView::TextInserted == nextRelayoutMetadata.mType )
{
if( relayoutMetadata.mPosition == nextRelayoutMetadata.mPosition )
void TextView::OnFadeBoundaryPropertySet( Property::Value propertyValue )
{
Vector4 value( propertyValue.Get<Vector4>() );
- DALI_ASSERT_ALWAYS( value.x >= 0 && value.y >= 0 && value.z >= 0 && value.w >= 0
+ DALI_ASSERT_ALWAYS( ( value.x >= 0.f ) && ( value.y >= 0.f ) && ( value.z >= 0.f ) && ( value.w >= 0.f )
&& "TextView::OnFadeBoundaryPropertySet(). Negative value is invalid. " );
Toolkit::TextView::FadeBoundary fadeBoundary( PixelSize( static_cast<unsigned int>( value.x ) ),
RELAYOUT_INITIALIZE_TEXT_ACTORS = 0x10, ///< Initialize text-actors (create handles).
RELAYOUT_TEXT_ACTOR_UPDATE = 0x20, ///< Updates text-actors (set size, position, style, ...)
RELAYOUT_INSERT_TO_TEXT_VIEW = 0x40, ///< Adds the text-actors to the text-view.
- RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST = 0x80, ///< Inserts the text-actors to the text-actor list.
RELAYOUT_ALL = 0xFF ///< Does all operations.
};
mAscender( 0.f ),
mLineHeightOffset( 0.f ),
mWordsLayoutInfo(),
- mNumberOfCharacters( 0 )
+ mNumberOfCharacters( 0u )
{
}
return *this;
}
-void UpdateLineLayoutInfo( LineLayoutInfo& lineLayoutInfo, const float lineHeightOffset )
-{
- // Update layout info.
- lineLayoutInfo.mSize = Size::ZERO;
- lineLayoutInfo.mAscender = 0.f;
- lineLayoutInfo.mNumberOfCharacters = 0u;
- for( WordLayoutInfoContainer::iterator it = lineLayoutInfo.mWordsLayoutInfo.begin(), endIt = lineLayoutInfo.mWordsLayoutInfo.end();
- it != endIt;
- ++it )
- {
- WordLayoutInfo& word( *it );
-
- UpdateSize( lineLayoutInfo.mSize, word.mSize );
- lineLayoutInfo.mAscender = std::max( lineLayoutInfo.mAscender, word.mAscender );
- lineLayoutInfo.mNumberOfCharacters += word.mCharactersLayoutInfo.size();
- }
-
- lineLayoutInfo.mSize.height += lineHeightOffset;
- lineLayoutInfo.mLineHeightOffset = lineHeightOffset;
-}
-
void CreateLineInfo( const MarkupProcessor::StyledTextArray& line,
TextView::RelayoutData& relayoutData,
LineLayoutInfo& lineLayoutInfo )
convertedLine = line;
// Create trivial bidirectional map tables.
- std::size_t index = 0;
+ std::size_t index = 0u;
for( MarkupProcessor::StyledTextArray::const_iterator it = convertedLine.begin(), endIt = convertedLine.end(); it != endIt; ++it )
{
const MarkupProcessor::StyledText& styledText( *it );
- for( std::size_t i = 0, length = styledText.mText.GetLength(); i < length; ++i )
+ for( std::size_t i = 0u, length = styledText.mText.GetLength(); i < length; ++i )
{
relayoutData.mCharacterLogicalToVisualMap.push_back( relayoutData.mTextLayoutInfo.mNumberOfCharacters + index );
relayoutData.mCharacterVisualToLogicalMap.push_back( relayoutData.mTextLayoutInfo.mNumberOfCharacters + index );
// kepps the font of the last character.
if( !wordLayoutInfo.mCharactersLayoutInfo.empty() )
{
- lastCharacterFont = ( *( wordLayoutInfo.mCharactersLayoutInfo.end() - 1 ) ).mStyledText.mStyle.GetFontName();
+ lastCharacterFont = ( *( wordLayoutInfo.mCharactersLayoutInfo.end() - 1u ) ).mStyledText.mStyle.GetFontName();
}
}
} // end of words
}
+void UpdateLayoutInfo( LineLayoutInfo& lineLayoutInfo, const float lineHeightOffset )
+{
+ // Update layout info.
+ lineLayoutInfo.mSize = Size::ZERO;
+ lineLayoutInfo.mAscender = 0.f;
+ lineLayoutInfo.mNumberOfCharacters = 0u;
+ for( WordLayoutInfoContainer::iterator it = lineLayoutInfo.mWordsLayoutInfo.begin(), endIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ it != endIt;
+ ++it )
+ {
+ WordLayoutInfo& word( *it );
+
+ UpdateSize( lineLayoutInfo.mSize, word.mSize );
+ lineLayoutInfo.mAscender = std::max( lineLayoutInfo.mAscender, word.mAscender );
+ lineLayoutInfo.mNumberOfCharacters += word.mCharactersLayoutInfo.size();
+ }
+
+ lineLayoutInfo.mSize.height += lineHeightOffset;
+ lineLayoutInfo.mLineHeightOffset = lineHeightOffset;
+}
+
void RemoveWordsFromLine( std::size_t wordIndex,
std::size_t numberOfWords,
float lineHeightOffset,
lineLayout.mWordsLayoutInfo.erase( lineLayout.mWordsLayoutInfo.begin() + wordIndex,
lineLayout.mWordsLayoutInfo.begin() + ( wordIndex + numberOfWords ) );
- UpdateLineLayoutInfo( lineLayout, lineHeightOffset );
+ UpdateLayoutInfo( lineLayout, lineHeightOffset );
}
void RemoveCharactersFromLineInfo( TextView::RelayoutData& relayoutData,
// * Remove words added to the last part of the line from the first line.
// early returns!!
- if( ( 0 == indices.mWordIndex ) && ( 0 == indices.mCharacterIndex ) )
+ if( ( 0u == indices.mWordIndex ) && ( 0u == indices.mCharacterIndex ) )
{
// the whole line goes to the last part.
lastLineLayoutInfo = firstLineLayoutInfo;
firstLineLayoutInfo.mWordsLayoutInfo.erase( firstLineLayoutInfo.mWordsLayoutInfo.begin() + index, firstLineLayoutInfo.mWordsLayoutInfo.end() );
// 6) update layout info of the first line.
- UpdateLineLayoutInfo( firstLineLayoutInfo, lineHeightOffset );
+ UpdateLayoutInfo( firstLineLayoutInfo, lineHeightOffset );
}
void MergeLine( LineLayoutInfo& firstLineLineLayoutInfo,
{
/**
- * Updates the line layout size info.
- *
- * @param[in,out] lineLayoutInfo The line layout info.
- * @param[in] lineHeightOffset The line height offset.
- */
-void UpdateLineLayoutInfo( LineLayoutInfo& lineLayoutInfo, float lineHeightOffset );
-
-/**
* Creates a data structure with info to layout the line, and data structures with useful info to modify the layout data structure if characters are added or removed.
*
* @param[in] line The styled line.
LineLayoutInfo& lineLayoutInfo );
/**
+ * Updates the line layout size info.
+ *
+ * @param[in,out] lineLayoutInfo The line layout info.
+ * @param[in] lineHeightOffset The line height offset.
+ */
+void UpdateLayoutInfo( LineLayoutInfo& lineLayoutInfo, float lineHeightOffset );
+
+/**
* Removes a given number of words from the given line.
*
* @pre \e wordIndex and \e wordIndex + \e numberOfWords can't exceed the bounds of the line.
return;
}
- std::size_t currentIndex = 0; // stores how many characters have been traversed (within the whole text).
+ std::size_t currentIndex = 0u; // stores how many characters have been traversed (within the whole text).
// Traverse all lines and words until global index is found.
bool found = false;
*
* @param[in,out] textLayoutInfo
*/
-void UpdateTextLayoutInfo( TextLayoutInfo& textLayoutInfo )
+void UpdateLayoutInfo( TextLayoutInfo& textLayoutInfo )
{
// Initialize members to be updated.
- textLayoutInfo.mWholeTextSize = Size();
+ textLayoutInfo.mWholeTextSize = Size::ZERO;
textLayoutInfo.mMaxWordWidth = 0.f;
- textLayoutInfo.mNumberOfCharacters = 0;
+ textLayoutInfo.mNumberOfCharacters = 0u;
// Traverse all text updating values.
for( LineLayoutInfoContainer::const_iterator lineIt = textLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = textLayoutInfo.mLinesLayoutInfo.end();
// Constructors and assignment operators
TextInfoIndices::TextInfoIndices()
-: mLineIndex( 0 ),
- mWordIndex( 0 ),
- mCharacterIndex( 0 )
+: mLineIndex( 0u ),
+ mWordIndex( 0u ),
+ mCharacterIndex( 0u )
{
}
: mWholeTextSize(),
mMaxWordWidth( 0.f ),
mLinesLayoutInfo(),
- mNumberOfCharacters( 0 ),
+ mNumberOfCharacters( 0u ),
mMaxItalicsOffset( 0.f ),
mEllipsizeLayoutInfo()
{
// Collect previously created text-actors.
std::vector<TextActor> textActors;
- CollectTextActorsFromLines( textActors, relayoutData.mTextLayoutInfo, 0, relayoutData.mTextLayoutInfo.mLinesLayoutInfo.size() );
+ CollectTextActorsFromLines( textActors, relayoutData.mTextLayoutInfo, 0u, relayoutData.mTextLayoutInfo.mLinesLayoutInfo.size() );
if( !textActors.empty() )
{
relayoutData,
lineLayoutInfo );
- if( 0 < lineLayoutInfo.mNumberOfCharacters )
+ if( 0u < lineLayoutInfo.mNumberOfCharacters )
{
// do not add the line offset if the line has no characters.
lineLayoutInfo.mSize.height += layoutParameters.mLineHeightOffset;
// Get the last character of the last line.
if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
{
- const LineLayoutInfo& lineInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1 ) );
+ const LineLayoutInfo& lineInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
const CharacterLayoutInfo characterInfo = GetLastCharacterLayoutInfo( lineInfo );
return;
}
- if( 0 == relayoutData.mTextLayoutInfo.mNumberOfCharacters )
+ if( 0u == relayoutData.mTextLayoutInfo.mNumberOfCharacters )
{
// Current text is empty. There is no need to update current data structure,
// just create a new one with the new input text.
// Update logical-to-visual and visual-to-logical tables.
// TODO: check that for mixed RTL/LTR text.
- std::size_t index = 0;
- for( std::size_t i = 0; i < relayoutDataForNewText.mTextLayoutInfo.mNumberOfCharacters; ++i )
+ std::size_t index = 0u;
+ for( std::size_t i = 0u; i < relayoutDataForNewText.mTextLayoutInfo.mNumberOfCharacters; ++i )
{
relayoutData.mCharacterLogicalToVisualMap.push_back( relayoutData.mTextLayoutInfo.mNumberOfCharacters + index );
relayoutData.mCharacterVisualToLogicalMap.push_back( relayoutData.mTextLayoutInfo.mNumberOfCharacters + index );
// Calculates indices for that position.
if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
{
- textInfoIndices.mLineIndex = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.size() - 1;
- const LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1 ) );
+ textInfoIndices.mLineIndex = relayoutData.mTextLayoutInfo.mLinesLayoutInfo.size() - 1u;
+ const LineLayoutInfo& lineLayoutInfo( *( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
if( !lineLayoutInfo.mWordsLayoutInfo.empty() )
{
- textInfoIndices.mWordIndex = lineLayoutInfo.mWordsLayoutInfo.size() - 1;
+ textInfoIndices.mWordIndex = lineLayoutInfo.mWordsLayoutInfo.size() - 1u;
- const WordLayoutInfo& wordLayoutInfo( *( lineLayoutInfo.mWordsLayoutInfo.end() - 1 ) );
+ const WordLayoutInfo& wordLayoutInfo( *( lineLayoutInfo.mWordsLayoutInfo.end() - 1u ) );
textInfoIndices.mCharacterIndex = wordLayoutInfo.mCharactersLayoutInfo.size();
}
}
// 2) If the new text has more than 1 line, merge the last line of the input text with the last part of the split line.
//TODO check this cases ( num lines ==1, >1, >2 ) if it could be simplified.
- if( relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.size() > 1 )
+ if( relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.size() > 1u )
{
- LineLayoutInfo& lastInputLineLayoutInfo( *( relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.end() - 1 ) );
+ LineLayoutInfo& lastInputLineLayoutInfo( *( relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u ) );
MergeLine( lastInputLineLayoutInfo,
lastLineLayoutInfo );
- if( relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.size() > 2 )
+ if( relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.size() > 2u )
{
// Insert all lines except first and last in the text.
- relayoutData.mTextLayoutInfo.mLinesLayoutInfo.insert( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndices.mLineIndex + 1,
- relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.begin() + 1,
- relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.end() - 1 );
+ relayoutData.mTextLayoutInfo.mLinesLayoutInfo.insert( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndices.mLineIndex + 1u,
+ relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.begin() + 1u,
+ relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.end() - 1u );
}
// Insert the last line to the text
- relayoutData.mTextLayoutInfo.mLinesLayoutInfo.insert( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndices.mLineIndex + relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.size() - 1,
+ relayoutData.mTextLayoutInfo.mLinesLayoutInfo.insert( relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndices.mLineIndex + relayoutDataForNewText.mTextLayoutInfo.mLinesLayoutInfo.size() - 1u,
lastInputLineLayoutInfo );
}
else
// 4) Update text info.
// Updates the whole text size, maximum word size, etc.
- UpdateTextLayoutInfo( relayoutData.mTextLayoutInfo );
+ UpdateLayoutInfo( relayoutData.mTextLayoutInfo );
}
void UpdateTextInfo( const std::size_t position,
const std::size_t removedNumberOfCharacters = ( wordNumberCharacters - wordLayout.mCharactersLayoutInfo.size() );
lineLayout.mNumberOfCharacters -= removedNumberOfCharacters;
}
- UpdateLineLayoutInfo( lineLayout, layoutParameters.mLineHeightOffset );
+ UpdateLayoutInfo( lineLayout, layoutParameters.mLineHeightOffset );
// Insert the text-actors in order.
removedTextActorsFromBegin.insert( removedTextActorsFromBegin.end(), removedTextActorsFromFirstWord.begin(), removedTextActorsFromFirstWord.end() );
const std::size_t removedNumberOfCharacters = ( wordNumberCharacters - wordLayout.mCharactersLayoutInfo.size() );
lineLayout.mNumberOfCharacters -= removedNumberOfCharacters;
}
- UpdateLineLayoutInfo( lineLayout, layoutParameters.mLineHeightOffset );
+ UpdateLayoutInfo( lineLayout, layoutParameters.mLineHeightOffset );
// Insert the text-actors in order.
removedTextActorsFromEnd.insert( removedTextActorsFromEnd.end(), removedTextActorsFromFirstWord.begin(), removedTextActorsFromFirstWord.end() );
lineLayout.mWordsLayoutInfo.erase( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex, lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesEnd.mWordIndex );
// Update line info.
- UpdateLineLayoutInfo( lineLayout, layoutParameters.mLineHeightOffset );
+ UpdateLayoutInfo( lineLayout, layoutParameters.mLineHeightOffset );
}// end delete text from same line.
if( mergeLines )
relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin() + textInfoIndicesEnd.mLineIndex );
// Update text info.
- UpdateTextLayoutInfo( relayoutData.mTextLayoutInfo );
+ UpdateLayoutInfo( relayoutData.mTextLayoutInfo );
// If the last character of the last line is a new line character, an empty line need to be added.
if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
} // end lines
}
-void InitializeTextActorInfo( TextView::RelayoutData& relayoutData )
-{
- TextLayoutInfo& textLayoutInfo = relayoutData.mTextLayoutInfo;
- if( textLayoutInfo.mLinesLayoutInfo.empty() )
- {
- // nothing to do if there is no lines.
- return;
- }
-
- std::size_t characterGlobalIndex = 0; // Index to the global character (within the whole text).
- std::size_t lineLayoutInfoIndex = 0; // Index to the laid out line info.
- const std::size_t lineLayoutInfoSize = relayoutData.mLines.size(); // Number or laid out lines.
- bool lineLayoutEnd = false; // Whether lineLayoutInfoIndex points at the last laid out line.
- bool glyphActorCreatedForLine = false; // Whether a renderable actor has been created for this line.
-
- RenderableActor currentGlyphActor; // text-actor used when the edit mode is disabled.
- 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.
- 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.
-
- for( LineLayoutInfoContainer::iterator lineIt = textLayoutInfo.mLinesLayoutInfo.begin(), lineEndIt = textLayoutInfo.mLinesLayoutInfo.end();
- lineIt != lineEndIt;
- ++lineIt )
- {
- LineLayoutInfo& line( *lineIt );
-
- for( WordLayoutInfoContainer::iterator wordIt = line.mWordsLayoutInfo.begin(), wordEndIt = line.mWordsLayoutInfo.end();
- wordIt != wordEndIt;
- ++wordIt )
- {
- WordLayoutInfo& word( *wordIt );
-
- for( CharacterLayoutInfoContainer::iterator characterIt = word.mCharactersLayoutInfo.begin(), characterEndIt = word.mCharactersLayoutInfo.end();
- characterIt != characterEndIt;
- ++characterIt )
- {
- CharacterLayoutInfo& characterLayout( *characterIt );
-
- // Check if there is a new line.
- const bool newLine = !lineLayoutEnd && ( characterGlobalIndex == relayoutData.mLines[lineLayoutInfoIndex].mCharacterGlobalIndex );
-
- if( newLine )
- {
- // 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;
- }
-
- if( !characterLayout.mStyledText.mText.IsEmpty() )
- {
- // Do not create a glyph-actor if there is no text.
- const Character character = characterLayout.mStyledText.mText[0]; // there are only one character per character layout.
-
- if( characterLayout.mIsColorGlyph ||
- !character.IsWhiteSpace() || // A new line character is also a white space.
- ( character.IsWhiteSpace() && characterLayout.mStyledText.mStyle.IsUnderlineEnabled() ) )
- {
- // Do not create a glyph-actor if it's a white space (without underline) or a new line character.
-
- // Creates one glyph-actor per each counsecutive group of characters, with the same style, per line, or if it's an emoticon.
-
- if( !glyphActorCreatedForLine ||
- characterLayout.mIsColorGlyph ||
- ( characterLayout.mStyledText.mStyle != currentStyle ) ||
- ( characterLayout.mGradientColor != currentGradientColor ) ||
- ( characterLayout.mStartPoint != currentStartPoint ) ||
- ( characterLayout.mEndPoint != currentEndPoint ) ||
- ( characterLayout.mIsColorGlyph != currentIsColorGlyph ) )
- {
- characterLayout.mSetText = false;
- characterLayout.mSetStyle = false;
-
- // There is a new style or a new line.
- glyphActorCreatedForLine = true;
-
- if( characterLayout.mIsColorGlyph )
- {
- ImageActor imageActor = ImageActor::DownCast( characterLayout.mGlyphActor );
- if( !imageActor )
- {
- characterLayout.mGlyphActor = ImageActor::New();
- characterLayout.mSetText = true;
- }
- }
- else
- {
- TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
-
- if( textActor )
- {
- // Try to reuse first the text-actor of this character.
- textActor.SetTextStyle( characterLayout.mStyledText.mStyle );
- currentGlyphActor = textActor;
- }
- 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( characterLayout.mStyledText.mStyle, TextActorParameters::FONT_DETECTION_OFF );
- textActor = TextActor::New( NULL, parameters );
- }
- else
- {
- textActor.SetTextStyle( characterLayout.mStyledText.mStyle );
- }
-
- currentGlyphActor = textActor;
- }
- characterLayout.mGlyphActor = currentGlyphActor;
- }
-
- // Update style to be checked with next characters.
- currentStyle = characterLayout.mStyledText.mStyle;
- currentGradientColor = characterLayout.mGradientColor;
- currentStartPoint = characterLayout.mStartPoint;
- currentEndPoint = characterLayout.mEndPoint;
- currentIsColorGlyph = characterLayout.mIsColorGlyph;
-
- characterLayout.mGlyphActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
- characterLayout.mGlyphActor.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
- }
- else
- {
- DALI_ASSERT_DEBUG( !characterLayout.mIsColorGlyph && "TextViewProcessor::InitializeTextActorInfo. An image-actor doesn't store more than one emoticon." );
-
- // Same style than previous one.
- TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
- if( textActor )
- {
- // 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 );
- }
-
- if( characterLayout.mGlyphActor )
- {
- characterLayout.mGlyphActor.Reset();
- }
- }
- } // no white space / new line char
- } // text not empty
-
- ++characterGlobalIndex;
- } // characters
- } // words
- } // lines
-
- // Insert the spare text-actors into the cache.
- relayoutData.mTextActorCache.InsertTextActors( textActorsToRemove );
-}
-
} // namespace TextViewProcessor
} // namespace Internal
TextStyle::Mask mask,
TextView::RelayoutData& relayoutData );
-/**
- * Traverse all text initializing all non initialized text-actor handles.
- *
- * @param[in,out] relayoutData Natural size (metrics), layout, text-actor info.
- */
-void InitializeTextActorInfo( TextView::RelayoutData& relayoutData );
-
} // namespace TextViewProcessor
} // namespace Internal
void UpdateLayoutInfo( WordLayoutInfo& wordLayout )
{
// Initialize layout info for the whole word.
- wordLayout.mSize = Size();
+ wordLayout.mSize = Size::ZERO;
wordLayout.mAscender = 0.f;
// Traverse the character layout info to update the word layout.
const std::size_t length = styledText.mText.GetLength();
// It could be a group of characters.
- for( std::size_t index = 0; index < length; ++index )
+ for( std::size_t index = 0u; index < length; ++index )
{
MarkupProcessor::StyledText styledCharacter;
styledCharacter.mStyle = styledText.mStyle;
if( LineSeparator == wordLayout.mType )
{
// If the word is a line separator and there is more lines, then current line and the line after need to be merged.
- if( textInfoIndicesBegin.mLineIndex + 1 < textLayoutInfo.mLinesLayoutInfo.size() )
+ if( textInfoIndicesBegin.mLineIndex + 1u < textLayoutInfo.mLinesLayoutInfo.size() )
{
// current line is not the last one.
// Update indices to merge lines.
textInfoMergeIndicesBegin.mLineIndex = textInfoIndicesBegin.mLineIndex;
- textInfoMergeIndicesEnd.mLineIndex = textInfoIndicesBegin.mLineIndex + 1;
+ textInfoMergeIndicesEnd.mLineIndex = textInfoIndicesBegin.mLineIndex + 1u;
mergeLines = true;
- ++textInfoIndicesBegin.mLineIndex; // increase both indices,
- textInfoIndicesEnd.mLineIndex +=2; // will delete last line.
+ ++textInfoIndicesBegin.mLineIndex; // increase both indices,
+ textInfoIndicesEnd.mLineIndex += 2u; // will delete last line.
}
++textInfoIndicesEnd.mWordIndex; //will delete the line separator;
{
// If the word is a word separator. Check if the word before and the word after can be merged.
- if( ( 0 < textInfoIndicesBegin.mWordIndex ) && ( lineLayout.mWordsLayoutInfo.size() > textInfoIndicesBegin.mWordIndex + 1 ) )
+ if( ( 0u < textInfoIndicesBegin.mWordIndex ) && ( lineLayout.mWordsLayoutInfo.size() > textInfoIndicesBegin.mWordIndex + 1u ) )
{
- const WordLayoutInfo& wordLayoutBefore( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex - 1 ) );
- const WordLayoutInfo& wordLayoutAfter( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex + 1 ) );
+ const WordLayoutInfo& wordLayoutBefore( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex - 1u ) );
+ const WordLayoutInfo& wordLayoutAfter( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex + 1u ) );
if( ( NoSeparator == wordLayoutBefore.mType ) && ( NoSeparator == wordLayoutAfter.mType ) )
{
mergeWords = true;
// Set indices to merge the words.
- textInfoMergeIndicesBegin.mWordIndex = textInfoIndicesBegin.mWordIndex - 1; // word before word separator.
- textInfoMergeIndicesEnd.mWordIndex = textInfoIndicesBegin.mWordIndex + 1; // word after word separator.
+ textInfoMergeIndicesBegin.mWordIndex = textInfoIndicesBegin.mWordIndex - 1u; // word before word separator.
+ textInfoMergeIndicesEnd.mWordIndex = textInfoIndicesBegin.mWordIndex + 1u; // word after word separator.
- textInfoIndicesEnd.mWordIndex += 2; // will delete the word separator and the merged word.
+ textInfoIndicesEnd.mWordIndex += 2u; // will delete the word separator and the merged word.
}
else
{
// Removes a given number of characters from the given word starting from the 'position' index.
// Early return.
- if( 0 == numberOfCharacters )
+ if( 0u == numberOfCharacters )
{
// nothing to do if the number of characters is zero.
// It moves characters from the first part of the word to the last one.
// early returns
- if( 0 == position )
+ if( 0u == position )
{
// the whole word goes to the last part of the word.
lastWordLayoutInfo = firstWordLayoutInfo;
if( !wordLayoutInfo.mCharactersLayoutInfo.empty() )
{
- layoutInfo = *( wordLayoutInfo.mCharactersLayoutInfo.end() - 1 );
+ layoutInfo = *( wordLayoutInfo.mCharactersLayoutInfo.end() - 1u );
}
return layoutInfo;