X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-view%2Ftext-view-impl.cpp;h=8082ce8efa716e83222b042d2b50fce5436fe2a4;hb=refs%2Fchanges%2F50%2F19450%2F1;hp=4488b2f2b19790a81b710ca2c8a92ae2ef39108c;hpb=9a450f332b63de22521e3e2a70c3378e574ad77f;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/text-view/text-view-impl.cpp b/dali-toolkit/internal/controls/text-view/text-view-impl.cpp index 4488b2f..8082ce8 100644 --- a/dali-toolkit/internal/controls/text-view/text-view-impl.cpp +++ b/dali-toolkit/internal/controls/text-view/text-view-impl.cpp @@ -136,7 +136,7 @@ void TextView::SetText( const std::string& text ) { // Creates a styled text with the markup or plain string. MarkupProcessor::StyledTextArray styledText; - MarkupProcessor::GetStyledTextArray( text, styledText ); + MarkupProcessor::GetStyledTextArray( text, styledText, IsMarkupProcessingEnabled() ); // Calls SetText() with the styled text array. SetText( styledText ); @@ -172,7 +172,7 @@ void TextView::InsertTextAt( std::size_t position, const std::string& text ) { // Creates a styled text with the markup or plain string. MarkupProcessor::StyledTextArray styledText; - MarkupProcessor::GetStyledTextArray( text, styledText ); + MarkupProcessor::GetStyledTextArray( text, styledText, IsMarkupProcessingEnabled() ); // Calls InsertTextAt() with the styled text array. InsertTextAt( position, styledText ); @@ -203,7 +203,7 @@ void TextView::ReplaceTextFromTo( const std::size_t position, const std::size_t { // Creates a styled text with the markup or plain string. MarkupProcessor::StyledTextArray styledText; - MarkupProcessor::GetStyledTextArray( text, styledText ); + MarkupProcessor::GetStyledTextArray( text, styledText, IsMarkupProcessingEnabled() ); // Calls ReplaceTextFromTo() with the styled text array. ReplaceTextFromTo( position, numberOfCharacters, styledText ); @@ -536,7 +536,7 @@ void TextView::SetEllipsizeText( const std::string& ellipsizeText ) { // Creates a styled text with the markup or plain string. MarkupProcessor::StyledTextArray styledText; - MarkupProcessor::GetStyledTextArray( ellipsizeText, styledText ); + MarkupProcessor::GetStyledTextArray( ellipsizeText, styledText, IsMarkupProcessingEnabled() ); SetEllipsizeText( styledText ); } @@ -591,8 +591,8 @@ void TextView::GetTextLayoutInfo() 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 ) @@ -608,18 +608,18 @@ void TextView::GetTextLayoutInfo() mask = static_cast( 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( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW ); mRelayoutOperations = static_cast( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST ); @@ -648,7 +648,7 @@ void TextView::SetSortModifier( float depthOffset ) { mVisualParameters.mSortModifier = depthOffset; - for( std::vector::iterator it = mRelayoutData.mTextActors.begin(), endIt = mRelayoutData.mTextActors.end(); + for( std::vector::iterator it = mRelayoutData.mGlyphActors.begin(), endIt = mRelayoutData.mGlyphActors.end(); it != endIt; ++it ) { @@ -665,10 +665,10 @@ void TextView::SetSnapshotModeEnabled( bool enable ) { 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; @@ -738,6 +738,16 @@ bool TextView::IsSnapshotModeEnabled() const return mVisualParameters.mSnapshotModeEnabled; } +void TextView::SetMarkupProcessingEnabled( bool enable ) +{ + mMarkUpEnabled = enable; +} + +bool TextView::IsMarkupProcessingEnabled() const +{ + return mMarkUpEnabled; +} + void TextView::SetScrollEnabled( const bool enable ) { if( enable != mVisualParameters.mScrollEnabled ) @@ -842,11 +852,12 @@ TextView::LayoutParameters::LayoutParameters() mVerticalAlignment( Toolkit::Alignment::VerticalCenter ), mLineJustification( Toolkit::TextView::Left ), mLineHeightOffset( 0.f ), - mEllipsizeText() + mEllipsizeText(), + mMarkUpEnabled( false ) { // Sets ellipsize text MarkupProcessor::StyledTextArray styledEllipsize; - MarkupProcessor::GetStyledTextArray( std::string( "..." ), mEllipsizeText ); + MarkupProcessor::GetStyledTextArray( std::string( "..." ), mEllipsizeText, false ); } TextView::LayoutParameters::LayoutParameters( const Toolkit::TextView::MultilinePolicy multilinePolicy, @@ -855,7 +866,8 @@ TextView::LayoutParameters::LayoutParameters( const Toolkit::TextView::Multiline const Toolkit::Alignment::Type alignmentType, const Toolkit::TextView::LineJustification lineJustification, const float lineHeightOffset, - const std::string& ellipsizeText ) + const std::string& ellipsizeText, + const bool markUpEnabled ) : mMultilinePolicy( multilinePolicy ), mWidthExceedPolicy( widthExceedPolicy ), mHeightExceedPolicy( heightExceedPolicy ), @@ -863,7 +875,8 @@ TextView::LayoutParameters::LayoutParameters( const Toolkit::TextView::Multiline mVerticalAlignment(), mLineJustification( lineJustification ), mLineHeightOffset( lineHeightOffset ), - mEllipsizeText() + mEllipsizeText(), + mMarkUpEnabled( markUpEnabled ) { // Sets alignment Toolkit::Alignment::Type horizontalAlignment( ( alignmentType & Toolkit::Alignment::HorizontalLeft ? Toolkit::Alignment::HorizontalLeft : @@ -878,7 +891,7 @@ TextView::LayoutParameters::LayoutParameters( const Toolkit::TextView::Multiline // Sets ellipsize text MarkupProcessor::StyledTextArray styledEllipsize; - MarkupProcessor::GetStyledTextArray( ellipsizeText, mEllipsizeText ); + MarkupProcessor::GetStyledTextArray( ellipsizeText, mEllipsizeText, mMarkUpEnabled ); } TextView::LayoutParameters::LayoutParameters( const TextView::LayoutParameters& layoutParameters ) @@ -889,7 +902,8 @@ TextView::LayoutParameters::LayoutParameters( const TextView::LayoutParameters& mVerticalAlignment( layoutParameters.mVerticalAlignment ), mLineJustification( layoutParameters.mLineJustification ), mLineHeightOffset( layoutParameters.mLineHeightOffset ), - mEllipsizeText( layoutParameters.mEllipsizeText ) + mEllipsizeText( layoutParameters.mEllipsizeText ), + mMarkUpEnabled( layoutParameters.mMarkUpEnabled ) { } @@ -903,6 +917,7 @@ TextView::LayoutParameters& TextView::LayoutParameters::operator=( const TextVie mLineJustification = layoutParameters.mLineJustification; mLineHeightOffset = layoutParameters.mLineHeightOffset; mEllipsizeText = layoutParameters.mEllipsizeText; + mMarkUpEnabled = layoutParameters.mMarkUpEnabled; return *this; } @@ -945,7 +960,7 @@ TextView::RelayoutData::RelayoutData() mTextLayoutInfo(), mCharacterLogicalToVisualMap(), mCharacterVisualToLogicalMap(), - mTextActors(), + mGlyphActors(), mCharacterLayoutInfoTable(), mLines(), mTextSizeForRelayoutOption() @@ -958,7 +973,7 @@ TextView::RelayoutData::RelayoutData( const TextView::RelayoutData& relayoutData mTextLayoutInfo( relayoutData.mTextLayoutInfo ), mCharacterLogicalToVisualMap( relayoutData.mCharacterLogicalToVisualMap ), mCharacterVisualToLogicalMap( relayoutData.mCharacterVisualToLogicalMap ), - mTextActors( relayoutData.mTextActors ), + mGlyphActors( relayoutData.mGlyphActors ), mCharacterLayoutInfoTable( relayoutData.mCharacterLayoutInfoTable ), mLines( relayoutData.mLines ), mTextSizeForRelayoutOption( relayoutData.mTextSizeForRelayoutOption ) @@ -972,7 +987,7 @@ TextView::RelayoutData& TextView::RelayoutData::operator=( const TextView::Relay mTextLayoutInfo = relayoutData.mTextLayoutInfo; mCharacterLogicalToVisualMap = relayoutData.mCharacterLogicalToVisualMap; mCharacterVisualToLogicalMap = relayoutData.mCharacterVisualToLogicalMap; - mTextActors = relayoutData.mTextActors; + mGlyphActors = relayoutData.mGlyphActors; mCharacterLayoutInfoTable = relayoutData.mCharacterLayoutInfoTable; mLines = relayoutData.mLines; mTextSizeForRelayoutOption = relayoutData.mTextSizeForRelayoutOption; @@ -990,7 +1005,8 @@ TextView::TextView() static_cast( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ), Toolkit::TextView::Left, PointSize( 0.f ), - std::string( "..." ) ), + std::string( "..." ), + false ), mVisualParameters(), mRelayoutData(), mRelayoutOperations( NO_RELAYOUT ), @@ -1002,7 +1018,8 @@ TextView::TextView() mRenderTask(), mPanGestureDetector(), mLockPreviousSnapshotMode( false ), - mPreviousSnapshotModeEnabled( false ) + mPreviousSnapshotModeEnabled( false ), + mMarkUpEnabled( false ) { TextViewProcessor::CreateWordTextInfo( mLayoutParameters.mEllipsizeText, mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo ); @@ -1026,12 +1043,12 @@ Vector3 TextView::GetNaturalSize() { // 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( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW ); mRelayoutOperations = static_cast( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST ); @@ -1060,26 +1077,26 @@ float TextView::GetHeightForWidth( float width ) // 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 ); } @@ -1092,13 +1109,13 @@ float TextView::GetHeightForWidth( float width ) mRelayoutOperations = static_cast( mRelayoutOperations | RELAYOUT_SIZE_POSITION ); } - if( hasTextActors ) + if( hasGlyphActors ) { mRelayoutOperations = static_cast( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW ); mRelayoutOperations = static_cast( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST ); } - if( differentWidth || hasTextActors ) + if( differentWidth || hasGlyphActors ) { RelayoutRequest(); } @@ -1216,7 +1233,7 @@ void TextView::OnRelaidOut( Vector2 size, ActorSizeContainer& container ) 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( mRelayoutOperations | @@ -1230,16 +1247,16 @@ void TextView::OnRelaidOut( Vector2 size, ActorSizeContainer& container ) } } - // 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 ); } @@ -1373,7 +1390,7 @@ void TextView::OptimizeTextViewProcessorOperations() 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(); @@ -1740,7 +1757,7 @@ void TextView::DoSetScrollPosition( const Vector2& position ) 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 ); }