//
// FILE HEADER
-
#include "relayout-utilities.h"
// EXTERNAL INCLUDES
#include <cmath>
// INTERNAL INCLUDES
+#include <dali/dali.h>
#include <dali-toolkit/public-api/controls/text-view/text-view.h>
#include "text-view-line-processor.h"
#include "text-view-word-processor.h"
return offset;
}
-bool IsVisible( const Vector3& position, const Size& size, const Size& parentSize, VisibilityTestType type )
+bool IsVisible( const Vector3& position, const Size& size, const Size& parentSize, const VisibilityTestType type )
{
bool visible = false;
TextStyle ellipsizeStyle;
// Stores the current size.
Size ellipsizeSize;
+ //Whether current glyph is an emoticon.
+ bool isColorGlyph = false;
float bearingOffset = 0.f;
{
const TextViewProcessor::CharacterLayoutInfo& ellipsizeCharacterLayoutInfo( *ellipsizeCharacterLayoutIt );
- if( ellipsizeStyle != ellipsizeCharacterLayoutInfo.mStyledText.mStyle )
+ if( isColorGlyph ||
+ ( isColorGlyph != ellipsizeCharacterLayoutInfo.mIsColorGlyph ) ||
+ ( ellipsizeStyle != ellipsizeCharacterLayoutInfo.mStyledText.mStyle ) )
{
// The style is different, so a new text-actor is needed.
if( !ellipsizeText.IsEmpty() )
{
// It only creates a text-actor if there is any text.
- TextActor ellipsizeTextActor = CreateTextActor( ellipsizeText, ellipsizeStyle, relayoutData.mTextActorCache );
- ellipsizeTextActor.SetSize( ellipsizeSize );
- ellipsizeTextActor.SetPosition( Vector3( ellipsizePosition.x, ellipsizePosition.y - bearingOffset, ellipsizePosition.z ) );
+ RenderableActor ellipsizeGlyphActor = CreateGlyphActor( ellipsizeText, ellipsizeStyle, relayoutData.mTextActorCache );
+ ellipsizeGlyphActor.SetSize( ellipsizeSize );
+ ellipsizeGlyphActor.SetPosition( Vector3( ellipsizePosition.x, ellipsizePosition.y - bearingOffset, ellipsizePosition.z ) );
// Updates the position for the next text-actor.
ellipsizePosition.x += ellipsizeSize.width;
// Adds the text-actor to the list.
- relayoutData.mEllipsizedTextActors.push_back( ellipsizeTextActor );
+ relayoutData.mEllipsizedGlyphActors.push_back( ellipsizeGlyphActor );
}
// Resets the current ellipsize info.
ellipsizeText = ellipsizeCharacterLayoutInfo.mStyledText.mText;
ellipsizeStyle = ellipsizeCharacterLayoutInfo.mStyledText.mStyle;
ellipsizeSize = ellipsizeCharacterLayoutInfo.mSize;
+ isColorGlyph = ellipsizeCharacterLayoutInfo.mIsColorGlyph;
bearingOffset = ( ellipsizeParameters.mLineDescender - ( ellipsizeCharacterLayoutInfo.mSize.height - ellipsizeCharacterLayoutInfo.mAscender ) ) * relayoutData.mShrinkFactor;
}
if( !ellipsizeText.IsEmpty() )
{
- // Creates the last text-actor.
- TextActor ellipsizeTextActor = CreateTextActor( ellipsizeText, ellipsizeStyle, relayoutData.mTextActorCache );
- ellipsizeTextActor.SetSize( ellipsizeSize );
- ellipsizeTextActor.SetPosition( Vector3( ellipsizePosition.x, ellipsizePosition.y - bearingOffset, ellipsizePosition.z ) );
+ // Creates the last glyph-actor.
+ RenderableActor ellipsizeGlyphActor = CreateGlyphActor( ellipsizeText, ellipsizeStyle, relayoutData.mTextActorCache );
+ ellipsizeGlyphActor.SetSize( ellipsizeSize );
+ ellipsizeGlyphActor.SetPosition( Vector3( ellipsizePosition.x, ellipsizePosition.y - bearingOffset, ellipsizePosition.z ) );
- // Adds the text-actor to the list.
- relayoutData.mEllipsizedTextActors.push_back( ellipsizeTextActor );
+ // Adds the glyph-actor to the list.
+ relayoutData.mEllipsizedGlyphActors.push_back( ellipsizeGlyphActor );
}
}
{
TextViewProcessor::CharacterLayoutInfo& characterLayoutInfo( *characterLayoutIt );
- if( characterLayoutInfo.mTextActor )
+ if( characterLayoutInfo.mIsColorGlyph )
{
- // 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 );
- }
+ ImageActor imageActor = ImageActor::DownCast( characterLayoutInfo.mGlyphActor );
- 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;
+ if( characterLayoutInfo.mSetText )
+ {
+ GlyphImage image = GlyphImage::New( characterLayoutInfo.mStyledText.mText[0] );
- currentTextActorInfo.color = characterLayoutInfo.mStyledText.mStyle.GetTextColor();
- currentTextActorInfo.color.a = characterLayoutInfo.mColorAlpha;
+ if( image )
+ {
+ imageActor.SetImage( image );
+ }
+ characterLayoutInfo.mSetText = false;
+ }
- currentTextActorInfo.gradientColor = characterLayoutInfo.mGradientColor;
- currentTextActorInfo.startPoint = characterLayoutInfo.mStartPoint;
- currentTextActorInfo.endPoint = characterLayoutInfo.mEndPoint;
+ imageActor.SetPosition( Vector3( characterLayoutInfo.mPosition.x + characterLayoutInfo.mOffset.x,
+ characterLayoutInfo.mPosition.y + characterLayoutInfo.mOffset.y,
+ characterLayoutInfo.mPosition.z ) );
+ imageActor.SetSize( characterLayoutInfo.mSize );
- // Update the current text-actor.
- currentTextActorInfo.textActor = characterLayoutInfo.mTextActor;
+ // Sets the sort modifier value.
+ imageActor.SetSortModifier( visualParameters.mSortModifier );
}
else
{
- // 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 ) )
+ 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 );
+ }
+
+ 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;
+
+ currentTextActorInfo.color = characterLayoutInfo.mStyledText.mStyle.GetTextColor();
+ currentTextActorInfo.color.a = characterLayoutInfo.mColorAlpha;
+
+ currentTextActorInfo.gradientColor = characterLayoutInfo.mGradientColor;
+ currentTextActorInfo.startPoint = characterLayoutInfo.mStartPoint;
+ currentTextActorInfo.endPoint = characterLayoutInfo.mEndPoint;
+
+ // Update the current text-actor.
+ currentTextActorInfo.textActor = textActor;
+ }
+ else
{
- currentTextActorInfo.text.Append( characterLayoutInfo.mStyledText.mText );
+ // 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 );
- 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 );
+ 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 );
+ }
}
}
} // end characters
} //end groups of words
} // end lines
- for( std::vector<TextActor>::iterator it = relayoutData.mEllipsizedTextActors.begin(),
- endIt = relayoutData.mEllipsizedTextActors.end();
+ for( std::vector<RenderableActor>::iterator it = relayoutData.mEllipsizedGlyphActors.begin(),
+ endIt = relayoutData.mEllipsizedGlyphActors.end();
it != endIt;
++it )
{
- TextActor textActor = ( *it );
+ RenderableActor glyphActor = ( *it );
- textActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
- textActor.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
+ glyphActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ glyphActor.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
// Sets the sort modifier value.
- textActor.SetSortModifier( visualParameters.mSortModifier );
+ glyphActor.SetSortModifier( visualParameters.mSortModifier );
// Enables or disables the blending.
- textActor.SetBlendMode( !visualParameters.mSnapshotModeEnabled ? BlendingMode::ON : BlendingMode::OFF );
+ glyphActor.SetBlendMode( !visualParameters.mSnapshotModeEnabled ? BlendingMode::ON : BlendingMode::OFF );
}
}
} // end of lines.
}
-void RemoveTextActors( Actor textView,
- const std::vector<TextActor>& textActors )
+void RemoveGlyphActors( Actor textView,
+ const std::vector<RenderableActor>& glyphActors )
{
- // Removes previously inserted text-actors.
+ // Removes previously inserted renderable-actors.
// The SplitByNewLineChar::Relayout(), SplitByWord::Relayout() and SplitByChar::Relayout() functions add
- // text-actors to the text-view. A handle to these text-actors are stored and passed to this function
- // in order to remove 'only' text-actors added by these functions.
+ // renderable-actors to the text-view. A handle to these renderable-actors are stored and passed to this function
+ // in order to remove 'only' renderable-actors added by these functions.
// Any other actor added by a programmer or application won't be removed.
- for( std::vector<TextActor>::const_reverse_iterator it = textActors.rbegin(), endIt = textActors.rend(); it != endIt; ++it )
+ for( std::vector<RenderableActor>::const_reverse_iterator it = glyphActors.rbegin(), endIt = glyphActors.rend(); it != endIt; ++it )
{
textView.Remove( *it );
}
{
TextViewProcessor::CharacterLayoutInfo& characterLayoutInfo( *characterLayoutIt );
- if( characterLayoutInfo.mIsVisible && characterLayoutInfo.mTextActor ) // White spaces and '\n' characters doesn't have a text-actor.
+ 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.mTextActor );
+ textView.Add( characterLayoutInfo.mGlyphActor );
}
if( insertToTextActorList )
{
- relayoutData.mTextActors.push_back( characterLayoutInfo.mTextActor );
+ relayoutData.mGlyphActors.push_back( characterLayoutInfo.mGlyphActor );
}
}
} // end group of character
} // end group of words
} // end lines
- for( std::vector<TextActor>::iterator it = relayoutData.mEllipsizedTextActors.begin(),
- endIt = relayoutData.mEllipsizedTextActors.end();
+ for( std::vector<RenderableActor>::iterator it = relayoutData.mEllipsizedGlyphActors.begin(),
+ endIt = relayoutData.mEllipsizedGlyphActors.end();
it != endIt;
++it )
{
- TextActor textActor = ( *it );
+ RenderableActor glyphActor = ( *it );
//Add to the text-view.
if( insertToTextView )
{
- textView.Add( textActor );
+ textView.Add( glyphActor );
}
if( insertToTextActorList )
{
- relayoutData.mTextActors.push_back( textActor );
+ relayoutData.mGlyphActors.push_back( glyphActor );
}
}
- relayoutData.mEllipsizedTextActors.clear();
+ relayoutData.mEllipsizedGlyphActors.clear();
}
-TextActor CreateTextActor( const Text& text, const TextStyle& style, TextActorCache& cache )
+RenderableActor CreateGlyphActor( const Text& text, const TextStyle& style, TextActorCache& cache )
{
TextActor textActor = cache.RetrieveTextActor();
void SetUnderlineInfo( TextView::RelayoutData& relayoutData );
/**
- * Remove text-actor from the text-view.
+ * Remove renderable-actor from the text-view.
*
* @param[in,out] textView The text-view.
- * @param[in] textActors text-actors to be removed from the text-view.
+ * @param[in] glyphActors renderable-actors to be removed from the text-view.
*/
-void RemoveTextActors( Actor textView,
- const std::vector<TextActor>& textActors );
+void RemoveGlyphActors( Actor textView,
+ const std::vector<RenderableActor>& glyphActors );
/**
* Inserts the text-actors into the text-view and/or the text-actor's list.
TextView::RelayoutData& relayoutData );
/**
- * Retrieves a new text-actor from the cache of text-actors or creating a new one if it's empty.
+ * Retrieves a new glyph-actor from the cache of text-actors or creating a new one if it's empty.
*
* @param[in] text The text-actor's text.
* @param[in] style The text-actor's style.
* @param[in] cache The cache of text-actors.
+ *
+ * @return a RenderableActor with the text's glyph.
*/
-TextActor CreateTextActor( const Text& text, const TextStyle& style, TextActorCache& cache );
+RenderableActor CreateGlyphActor( const Text& text, const TextStyle& style, TextActorCache& cache );
} // namespace TextViewRelayout
mAscender( 0.f ),
mUnderlineThickness( 0.f ),
mUnderlinePosition( 0.f ),
- mTextActor(),
+ mGlyphActor(),
mStyledText(),
mColorAlpha( 1.f ),
mGradientColor(),
mEndPoint(),
mIsVisible( true ),
mSetText( true ),
- mSetStyle( true )
+ mSetStyle( true ),
+ mIsColorGlyph( false )
{
}
mAscender( character.mAscender ),
mUnderlineThickness( character.mUnderlineThickness ),
mUnderlinePosition( character.mUnderlinePosition ),
- mTextActor( character.mTextActor ),
+ mGlyphActor( character.mGlyphActor ),
mStyledText( character.mStyledText ),
mColorAlpha( character.mColorAlpha ),
mGradientColor( character.mGradientColor ),
mEndPoint( character.mEndPoint ),
mIsVisible( character.mIsVisible ),
mSetText( character.mSetText ),
- mSetStyle( character.mSetStyle )
+ mSetStyle( character.mSetStyle ),
+ mIsColorGlyph( character.mIsColorGlyph )
{
}
mIsVisible = character.mIsVisible;
mSetText = character.mSetText;
mSetStyle = character.mSetStyle;
+ mIsColorGlyph = character.mIsColorGlyph;
- mTextActor = character.mTextActor;
+ mGlyphActor = character.mGlyphActor;
return *this;
}
if( ( textViewSize.width > Math::MACHINE_EPSILON_1000 ) &&
( textViewSize.height > Math::MACHINE_EPSILON_1000 ) )
{
- // Check if the text-view has text-actors.
- const bool hasTextActors = !mRelayoutData.mTextActors.empty();
+ // Check if the text-view has glyph-actors.
+ const bool hasGlyphActors = !mRelayoutData.mGlyphActors.empty();
RelayoutOperationMask mask = NO_RELAYOUT;
if( relayoutSizeAndPositionNeeded )
mask = static_cast<RelayoutOperationMask>( mask | RELAYOUT_VISIBILITY );
}
- if( hasTextActors )
+ if( hasGlyphActors )
{
- // Remove text-actors from the text-view as some text-operation like CreateTextInfo()
+ // Remove glyph-actors from the text-view as some text-operation like CreateTextInfo()
// add them to the text-actor cache.
- TextViewRelayout::RemoveTextActors( GetRootActor(), mRelayoutData.mTextActors );
- mRelayoutData.mTextActors.clear();
+ TextViewRelayout::RemoveGlyphActors( GetRootActor(), mRelayoutData.mGlyphActors );
+ mRelayoutData.mGlyphActors.clear();
}
- // Relays-out but doesn't add text-actors to the text-view.
+ // Relays-out but doesn't add glyph-actors to the text-view.
DoRelayOut( textViewSize.GetVectorXY(), mask );
- if( hasTextActors )
+ if( hasGlyphActors )
{
mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
{
mVisualParameters.mSortModifier = depthOffset;
- for( std::vector<TextActor>::iterator it = mRelayoutData.mTextActors.begin(), endIt = mRelayoutData.mTextActors.end();
+ for( std::vector<RenderableActor>::iterator it = mRelayoutData.mGlyphActors.begin(), endIt = mRelayoutData.mGlyphActors.end();
it != endIt;
++it )
{
{
if( enable != mVisualParameters.mSnapshotModeEnabled )
{
- // Remove first all text-actors
- if( !mRelayoutData.mTextActors.empty() )
+ // Remove first all glyph-actors
+ if( !mRelayoutData.mGlyphActors.empty() )
{
- TextViewRelayout::RemoveTextActors( GetRootActor(), mRelayoutData.mTextActors );
+ TextViewRelayout::RemoveGlyphActors( GetRootActor(), mRelayoutData.mGlyphActors );
}
mVisualParameters.mSnapshotModeEnabled = enable;
mTextLayoutInfo(),
mCharacterLogicalToVisualMap(),
mCharacterVisualToLogicalMap(),
- mTextActors(),
+ mGlyphActors(),
mCharacterLayoutInfoTable(),
mLines(),
mTextSizeForRelayoutOption()
mTextLayoutInfo( relayoutData.mTextLayoutInfo ),
mCharacterLogicalToVisualMap( relayoutData.mCharacterLogicalToVisualMap ),
mCharacterVisualToLogicalMap( relayoutData.mCharacterVisualToLogicalMap ),
- mTextActors( relayoutData.mTextActors ),
+ mGlyphActors( relayoutData.mGlyphActors ),
mCharacterLayoutInfoTable( relayoutData.mCharacterLayoutInfoTable ),
mLines( relayoutData.mLines ),
mTextSizeForRelayoutOption( relayoutData.mTextSizeForRelayoutOption )
mTextLayoutInfo = relayoutData.mTextLayoutInfo;
mCharacterLogicalToVisualMap = relayoutData.mCharacterLogicalToVisualMap;
mCharacterVisualToLogicalMap = relayoutData.mCharacterVisualToLogicalMap;
- mTextActors = relayoutData.mTextActors;
+ mGlyphActors = relayoutData.mGlyphActors;
mCharacterLayoutInfoTable = relayoutData.mCharacterLayoutInfoTable;
mLines = relayoutData.mLines;
mTextSizeForRelayoutOption = relayoutData.mTextSizeForRelayoutOption;
{
// There are SetText, Inserts or Removes to do. It means the current layout info is not updated.
- if( !mRelayoutData.mTextActors.empty() )
+ if( !mRelayoutData.mGlyphActors.empty() )
{
- // Remove text-actors from the text-view as some text-operation like CreateTextInfo()
+ // Remove glyph-actors from the text-view as some text-operation like CreateTextInfo()
// add them to the text-actor cache.
- TextViewRelayout::RemoveTextActors( GetRootActor(), mRelayoutData.mTextActors );
- mRelayoutData.mTextActors.clear();
+ TextViewRelayout::RemoveGlyphActors( GetRootActor(), mRelayoutData.mGlyphActors );
+ mRelayoutData.mGlyphActors.clear();
mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
// Check if the given width is different than the current one.
const bool differentWidth = ( fabsf( width - mRelayoutData.mTextViewSize.width ) > Math::MACHINE_EPSILON_1000 );
- // Check if the text-view has text-actors.
- const bool hasTextActors = !mRelayoutData.mTextActors.empty();
+ // Check if the text-view has glyph-actors.
+ const bool hasGlyphActors = !mRelayoutData.mGlyphActors.empty();
// Check which layout operations need to be done.
const bool relayoutSizeAndPositionNeeded = ( mRelayoutOperations & RELAYOUT_SIZE_POSITION ) || differentWidth;
if( relayoutSizeAndPositionNeeded )
{
- if( hasTextActors )
+ if( hasGlyphActors )
{
- // Remove text-actors from the text-view as some text-operation like CreateTextInfo()
+ // Remove glyph-actors from the text-view as some text-operation like CreateTextInfo()
// add them to the text-actor cache.
- TextViewRelayout::RemoveTextActors( GetRootActor(), mRelayoutData.mTextActors );
- mRelayoutData.mTextActors.clear();
+ TextViewRelayout::RemoveGlyphActors( GetRootActor(), mRelayoutData.mGlyphActors );
+ mRelayoutData.mGlyphActors.clear();
}
// Use the given width.
const Vector2 textViewSize( width, GetControlSize().height );
- // Relays-out but doesn't add text-actors to the text-view.
+ // Relays-out but doesn't add glyph-actors to the text-view.
DoRelayOut( textViewSize, RELAYOUT_SIZE_POSITION );
}
mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_SIZE_POSITION );
}
- if( hasTextActors )
+ 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 || hasTextActors )
+ if( differentWidth || hasGlyphActors )
{
RelayoutRequest();
}
if( size != mRelayoutData.mTextViewSize )
{
- // if new size is different than the prevoius one, set positions and maybe sizes of all text-actor is needed.
+ // if new size is different than the prevoius one, set positions and maybe sizes of all glyph-actor is needed.
if( RELAYOUT_ALL != mRelayoutOperations )
{
mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations |
}
}
- // Remove text-actors from text-view
- if( !mRelayoutData.mTextActors.empty() && ( mRelayoutOperations & RELAYOUT_REMOVE_TEXT_ACTORS ) )
+ // Remove glyph-actors from text-view
+ if( !mRelayoutData.mGlyphActors.empty() && ( mRelayoutOperations & RELAYOUT_REMOVE_TEXT_ACTORS ) )
{
- TextViewRelayout::RemoveTextActors( GetRootActor(), mRelayoutData.mTextActors );
- mRelayoutData.mTextActors.clear();
+ TextViewRelayout::RemoveGlyphActors( GetRootActor(), mRelayoutData.mGlyphActors );
+ mRelayoutData.mGlyphActors.clear();
}
if( NO_RELAYOUT != mRelayoutOperations )
{
- // Relays-out and add text-actors to the text-view.
+ // Relays-out and add glyph-actors to the text-view.
DoRelayOut( size, mRelayoutOperations );
ProcessSnapshot( size );
}
void TextView::DoRelayOut( const Size& textViewSize, const RelayoutOperationMask relayoutOperationMask )
{
- // Traverse the relayout operation vector. It fills the natural size, layout and text-actor data structures.
+ // Traverse the relayout operation vector. It fills the natural size, layout and glyph-actor data structures.
if( !mTextViewProcessorOperations.empty() )
{
PerformTextViewProcessorOperations();
if( mOffscreenRootActor )
{
- // If there is a render-task it needs to be refreshed. Therefore text-actors need to be
+ // If there is a render-task it needs to be refreshed. Therefore glyph-actors need to be
// set to visible.
mOffscreenRootActor.SetVisible( true );
}
TextViewProcessor::TextLayoutInfo mTextLayoutInfo; ///< Stores metrics, layout info (size, direction, type of word) and text-actor info for the whole text.
std::vector<int> mCharacterLogicalToVisualMap; ///< Reorder map that stores each character's visual (output) index according to its logical (input) index
std::vector<int> mCharacterVisualToLogicalMap; ///< Reorder map that stores each character's logical (input) index according to its visual (output) index
- std::vector<TextActor> mTextActors; ///< Stores handles of those text-actors which are currently added to the text-view.
- std::vector<TextActor> mEllipsizedTextActors; ///< Stores handles of those text-actors which are used to ellipsize the text.
+ std::vector<RenderableActor> mGlyphActors; ///< Stores handles of those text-actors which are currently added to the text-view.
+ std::vector<RenderableActor> mEllipsizedGlyphActors; ///< Stores handles of those text-actors which are used to ellipsize the text.
Toolkit::TextView::CharacterLayoutInfoContainer mCharacterLayoutInfoTable; ///< Stores layout info per character sorted by the character's visual index.
Toolkit::TextView::LineLayoutInfoContainer mLines; ///< Stores an index to the first character of each line.
Size mTextSizeForRelayoutOption; ///< Stores the text size after relayout.
namespace TextViewProcessor
{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gTextViewProcessorLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TEXT_VIEW_PROCESSOR");
+#endif
+
void dbgPrint( const WordLayoutInfo& word )
{
for( CharacterLayoutInfoContainer::const_iterator characterIt = word.mCharactersLayoutInfo.begin(), endCharacterIt = word.mCharactersLayoutInfo.end();
std::cout << "[" << character.mSize << std::endl;
std::cout << " ascender " << character.mAscender << std::endl;
- if( character.mTextActor )
+ TextActor textActor = TextActor::DownCast( character.mGlyphActor );
+ if( textActor )
+ {
+ std::cout << "[" << textActor.GetText() << "]";
+ }
+ else
{
- std::cout << "[" << character.mTextActor.GetText() << "]";
+ std::cout << "[ImageActor]" << std::endl;
}
std::cout << "{" << character.mStyledText.mText.GetText() << "}";
}
// INTERNAL INCLUDES
#include "text-view-processor-types.h"
+#include <dali/integration-api/debug.h>
namespace Dali
{
namespace TextViewProcessor
{
+#if defined(DEBUG_ENABLED)
+extern Debug::Filter* gTextViewProcessorLogFilter;
+#endif
+
void dbgPrint( const WordLayoutInfo& word );
void dbgPrint( const WordGroupLayoutInfo& group );
void dbgPrint( const LineLayoutInfo& line );
// INTERNAL INCLUDES
#include "text-view-processor-helper-functions.h"
+#include "text-view-processor-dbg.h"
namespace Dali
{
void ChooseFontFamilyName( MarkupProcessor::StyledText& text )
{
+ DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, "-->TextViewProcessor::ChooseFontFamilyName\n" );
+ DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, " input font name: [%s]\n", text.mStyle.GetFontName().c_str() );
+
bool userDefinedFontFamilyName = false;
// First check if there is a font defined in the style and it supports the given text.
text.mStyle.SetFontName( "" );
}
}
+ DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, " output font name: [%s]\n", text.mStyle.GetFontName().c_str() );
+ DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, "<--TextViewProcessor::ChooseFontFamilyName\n" );
}
void GetIndicesFromGlobalCharacterIndex( const std::size_t index,
float mUnderlineThickness; ///< The underline's thickness.
float mUnderlinePosition; ///< The underline's position.
- TextActor mTextActor; ///< Handle to a text-actor.
- MarkupProcessor::StyledText mStyledText; ///< Stores the text and its style.
- float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
- Vector4 mGradientColor; ///< Gradient color.
- Vector2 mStartPoint; ///< Gradient start point.
- Vector2 mEndPoint; ///< Gradient end point.
-
- bool mIsVisible:1; ///< Whether the text-actor is visible.
- bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
- bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
+ RenderableActor mGlyphActor; ///< Handle to a text-actor.
+ MarkupProcessor::StyledText mStyledText; ///< Stores the text and its style.
+ float mColorAlpha; ///< Alpha component for the initial text color when text is faded.
+ Vector4 mGradientColor; ///< Gradient color.
+ Vector2 mStartPoint; ///< Gradient start point.
+ Vector2 mEndPoint; ///< Gradient end point.
+
+ bool mIsVisible:1; ///< Whether the text-actor is visible.
+ bool mSetText:1; ///< Whether a new text needs to be set in the text-actor.
+ bool mSetStyle:1; ///< Whether a new style needs to be set in the text-actor.
+ bool mIsColorGlyph:1; ///< Whether this character is an emoticon.
};
typedef std::vector<CharacterLayoutInfo> CharacterLayoutInfoContainer;
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.
+ 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 textActorCreatedForLine = false;
+ 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.
- TextActor currentTextActor; // 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.
+ 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.
// Arrived at last line.
lineLayoutEnd = true; // Avoids access out of bounds in the relayoutData.mLines vector.
}
- textActorCreatedForLine = false;
+ glyphActorCreatedForLine = false;
}
if( !characterLayout.mStyledText.mText.IsEmpty() )
{
- // Do not create a text-actor if there is no text.
+ // 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( !character.IsWhiteSpace() || // A new line character is also a white space.
+ if( characterLayout.mIsColorGlyph ||
+ !character.IsWhiteSpace() || // A new line character is also a white space.
( character.IsWhiteSpace() && characterLayout.mStyledText.mStyle.GetUnderline() ) )
{
- // Do not create a text-actor if it's a white space (without underline) or a new line character.
+ // Do not create a glyph-actor if it's a white space (without underline) or a new line character.
- // Creates one text-actor per each counsecutive group of characters, with the same style, per line.
+ // Creates one glyph-actor per each counsecutive group of characters, with the same style, per line, or if it's an emoticon.
- if( !textActorCreatedForLine ||
+ if( !glyphActorCreatedForLine ||
+ characterLayout.mIsColorGlyph ||
( characterLayout.mStyledText.mStyle != currentStyle ) ||
( characterLayout.mGradientColor != currentGradientColor ) ||
( characterLayout.mStartPoint != currentStartPoint ) ||
- ( characterLayout.mEndPoint != currentEndPoint ) )
+ ( characterLayout.mEndPoint != currentEndPoint ) ||
+ ( characterLayout.mIsColorGlyph != currentIsColorGlyph ) )
{
+ characterLayout.mSetText = false;
+ characterLayout.mSetStyle = false;
+
// There is a new style or a new line.
- textActorCreatedForLine = true;
+ glyphActorCreatedForLine = true;
- if( characterLayout.mTextActor )
+ if( characterLayout.mIsColorGlyph )
{
- // Try to reuse first the text-actor of this character.
- currentTextActor = characterLayout.mTextActor;
- currentTextActor.SetTextStyle( characterLayout.mStyledText.mStyle );
+ ImageActor imageActor = ImageActor::DownCast( characterLayout.mGlyphActor );
+ if( !imageActor )
+ {
+ characterLayout.mGlyphActor = ImageActor::New();
+ characterLayout.mSetText = true;
+ }
}
else
{
- // If there is no text-actor, try to retrieve one from the cache.
- currentTextActor = relayoutData.mTextActorCache.RetrieveTextActor();
+ TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
- // If still there is no text-actor, create one.
- if( !currentTextActor )
+ if( textActor )
{
- currentTextActor = TextActor::New( Text(), characterLayout.mStyledText.mStyle, false, true );
+ // Try to reuse first the text-actor of this character.
+ textActor.SetTextStyle( characterLayout.mStyledText.mStyle );
+ currentGlyphActor = textActor;
}
else
{
- currentTextActor.SetTextStyle( characterLayout.mStyledText.mStyle );
+ // 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 )
+ {
+ textActor = TextActor::New( Text(), characterLayout.mStyledText.mStyle, false, true );
+ }
+ else
+ {
+ textActor.SetTextStyle( characterLayout.mStyledText.mStyle );
+ }
+
+ currentGlyphActor = textActor;
}
+ characterLayout.mGlyphActor = currentGlyphActor;
}
// Update style to be checked with next characters.
currentGradientColor = characterLayout.mGradientColor;
currentStartPoint = characterLayout.mStartPoint;
currentEndPoint = characterLayout.mEndPoint;
+ currentIsColorGlyph = characterLayout.mIsColorGlyph;
- characterLayout.mSetText = false;
- characterLayout.mSetStyle = false;
-
- characterLayout.mTextActor = currentTextActor;
- characterLayout.mTextActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
- characterLayout.mTextActor.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
+ 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.
- if( characterLayout.mTextActor )
+ 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.
- characterLayout.mTextActor.SetText( "" );
- textActorsToRemove.push_back( characterLayout.mTextActor );
- characterLayout.mTextActor.Reset();
+ textActor.SetText( "" );
+ textActorsToRemove.push_back( textActor );
+ }
+
+ if( characterLayout.mGlyphActor )
+ {
+ characterLayout.mGlyphActor.Reset();
}
}
} // no white space / new line char
// limitations under the License.
//
-// INTERNAL INCLUDES
+// FILE HEADER
#include "text-view-word-processor.h"
+
+// INTERNAL INCLUDES
+#include <dali/dali.h>
#include "text-view-processor-helper-functions.h"
+#include "text-view-processor-dbg.h"
namespace Dali
{
void CreateWordTextInfo( const MarkupProcessor::StyledTextArray& word,
TextViewProcessor::WordLayoutInfo& wordLayoutInfo )
{
+ DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, "-->TextViewProcessor::CreateWordTextInfo\n" );
// Split in characters.
for( MarkupProcessor::StyledTextArray::const_iterator charIt = word.begin(), charEndIt = word.end(); charIt != charEndIt; ++charIt )
{
// Create layout character info.
CharacterLayoutInfo characterLayoutInfo;
+ characterLayoutInfo.mIsColorGlyph = GlyphImage::IsColorGlyph( character );
+ DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, " Is color glyph: %s\n", ( characterLayoutInfo.mIsColorGlyph ? "True" : "False" ) );
+
// Fill Natural size info for current character.
characterLayoutInfo.mHeight = font.GetLineHeight();
characterLayoutInfo.mAdvance = metrics.GetAdvance();
characterLayoutInfo.mBearing = metrics.GetBearing();
- if( character.IsNewLine() )
+ if( character.IsNewLine() && !characterLayoutInfo.mIsColorGlyph )
{
// A new line character doesn't have any width.
characterLayoutInfo.mSize.width = 0.f;
wordLayoutInfo.mType = GetTextSeparatorType( character );
} // end of each character in the group of characters.
} // end of characters in the word.
+ DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, "<--TextViewProcessor::CreateWordTextInfo\n" );
}
void RemoveCharactersFromWordInfo( TextView::RelayoutData& relayoutData,
{
const CharacterLayoutInfo& characterLayout( *characterIt );
- if( characterLayout.mTextActor )
+ if( !characterLayout.mIsColorGlyph )
{
- textActors.push_back( characterLayout.mTextActor );
+ TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
+ if( textActor )
+ {
+ textActors.push_back( textActor );
+ }
}
}
}
{
const CharacterLayoutInfo& characterLayout( *characterIt );
- if( characterLayout.mTextActor )
+ if( !characterLayout.mIsColorGlyph )
{
- textActors.push_back( characterLayout.mTextActor );
+ TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
+ if( textActor )
+ {
+ textActors.push_back( textActor );
+ }
}
}
}