X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller-impl.cpp;h=e77f00d067b77a2d607f945ade851017e690f008;hb=7d540590dfce9f3c3773ca25486b3089b002c553;hp=c37c7be7319f9fce07fcb92f021319a6977fab4c;hpb=b9f461d2ec1241a63cd866524aaf422b94f057ae;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index c37c7be..e77f00d 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -300,17 +300,17 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters ) } else { - CharacterIndex lastIndex = 0u; + Length numberOfCharactersToUpdate = 0u; if( mTextUpdateInfo.mFullRelayoutNeeded ) { - lastIndex = mTextUpdateInfo.mPreviousNumberOfCharacters; + numberOfCharactersToUpdate = mTextUpdateInfo.mPreviousNumberOfCharacters; } else { - lastIndex = ( mTextUpdateInfo.mNumberOfCharactersToRemove > 0u ) ? mTextUpdateInfo.mNumberOfCharactersToRemove : 1u; + numberOfCharactersToUpdate = ( mTextUpdateInfo.mNumberOfCharactersToRemove > 0u ) ? mTextUpdateInfo.mNumberOfCharactersToRemove : 1u; } mLogicalModel->FindParagraphs( mTextUpdateInfo.mCharacterIndex, - lastIndex, + numberOfCharactersToUpdate, paragraphsToBeUpdated ); } @@ -345,36 +345,36 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters ) void Controller::Impl::ClearFullModelData( OperationsMask operations ) { - if( GET_LINE_BREAKS & operations ) + if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) ) { mLogicalModel->mLineBreakInfo.Clear(); mLogicalModel->mParagraphInfo.Clear(); } - if( GET_WORD_BREAKS & operations ) + if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) ) { mLogicalModel->mLineBreakInfo.Clear(); } - if( GET_SCRIPTS & operations ) + if( NO_OPERATION != ( GET_SCRIPTS & operations ) ) { mLogicalModel->mScriptRuns.Clear(); } - if( VALIDATE_FONTS & operations ) + if( NO_OPERATION != ( VALIDATE_FONTS & operations ) ) { mLogicalModel->mFontRuns.Clear(); } if( 0u != mLogicalModel->mBidirectionalParagraphInfo.Count() ) { - if( BIDI_INFO & operations ) + if( NO_OPERATION != ( BIDI_INFO & operations ) ) { mLogicalModel->mBidirectionalParagraphInfo.Clear(); mLogicalModel->mCharacterDirections.Clear(); } - if( REORDER & operations ) + if( NO_OPERATION != ( REORDER & operations ) ) { // Free the allocated memory used to store the conversion table in the bidirectional line info run. for( Vector::Iterator it = mLogicalModel->mBidirectionalLineInfo.Begin(), @@ -388,13 +388,10 @@ void Controller::Impl::ClearFullModelData( OperationsMask operations ) bidiLineInfo.visualToLogicalMap = NULL; } mLogicalModel->mBidirectionalLineInfo.Clear(); - - mLogicalModel->mLogicalToVisualMap.Clear(); - mLogicalModel->mVisualToLogicalMap.Clear(); } } - if( SHAPE_TEXT & operations ) + if( NO_OPERATION != ( SHAPE_TEXT & operations ) ) { mVisualModel->mGlyphs.Clear(); mVisualModel->mGlyphsToCharacters.Clear(); @@ -404,12 +401,12 @@ void Controller::Impl::ClearFullModelData( OperationsMask operations ) mVisualModel->mGlyphPositions.Clear(); } - if( LAYOUT & operations ) + if( NO_OPERATION != ( LAYOUT & operations ) ) { mVisualModel->mLines.Clear(); } - if( COLOR & operations ) + if( NO_OPERATION != ( COLOR & operations ) ) { mVisualModel->mColorIndices.Clear(); } @@ -419,7 +416,7 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara { const CharacterIndex endIndexPlusOne = endIndex + 1u; - if( GET_LINE_BREAKS & operations ) + if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) ) { // Clear the line break info. LineBreakInfo* lineBreakInfoBuffer = mLogicalModel->mLineBreakInfo.Begin(); @@ -433,7 +430,7 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara mLogicalModel->mParagraphInfo ); } - if( GET_WORD_BREAKS & operations ) + if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) ) { // Clear the word break info. WordBreakInfo* wordBreakInfoBuffer = mLogicalModel->mWordBreakInfo.Begin(); @@ -442,7 +439,7 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara wordBreakInfoBuffer + endIndexPlusOne ); } - if( GET_SCRIPTS & operations ) + if( NO_OPERATION != ( GET_SCRIPTS & operations ) ) { // Clear the scripts. ClearCharacterRuns( startIndex, @@ -450,7 +447,7 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara mLogicalModel->mScriptRuns ); } - if( VALIDATE_FONTS & operations ) + if( NO_OPERATION != ( VALIDATE_FONTS & operations ) ) { // Clear the fonts. ClearCharacterRuns( startIndex, @@ -460,7 +457,7 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara if( 0u != mLogicalModel->mBidirectionalParagraphInfo.Count() ) { - if( BIDI_INFO & operations ) + if( NO_OPERATION != ( BIDI_INFO & operations ) ) { // Clear the bidirectional paragraph info. ClearCharacterRuns( startIndex, @@ -474,7 +471,7 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara characterDirectionsBuffer + endIndexPlusOne ); } - if( REORDER & operations ) + if( NO_OPERATION != ( REORDER & operations ) ) { uint32_t startRemoveIndex = mLogicalModel->mBidirectionalLineInfo.Count(); uint32_t endRemoveIndex = startRemoveIndex; @@ -500,15 +497,6 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara mLogicalModel->mBidirectionalLineInfo.Erase( bidirectionalLineInfoBuffer + startRemoveIndex, bidirectionalLineInfoBuffer + endRemoveIndex ); - - // Clear the logical to visual and the visual to logical conversion tables. - CharacterIndex* logicalToVisualMapBuffer = mLogicalModel->mLogicalToVisualMap.Begin(); - mLogicalModel->mLogicalToVisualMap.Erase( logicalToVisualMapBuffer + startIndex, - logicalToVisualMapBuffer + endIndexPlusOne ); - - CharacterIndex* visualToLogicalMapBuffer = mLogicalModel->mVisualToLogicalMap.Begin(); - mLogicalModel->mVisualToLogicalMap.Erase( visualToLogicalMapBuffer + startIndex, - visualToLogicalMapBuffer + endIndexPlusOne ); } } } @@ -525,7 +513,7 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character const GlyphIndex endGlyphIndexPlusOne = *( charactersToGlyphBuffer + endIndex ) + *( glyphsPerCharacterBuffer + endIndex ); const Length numberOfGlyphsRemoved = endGlyphIndexPlusOne - mTextUpdateInfo.mStartGlyphIndex; - if( SHAPE_TEXT & operations ) + if( NO_OPERATION != ( SHAPE_TEXT & operations ) ) { // Update the character to glyph indices. for( Vector::Iterator it = charactersToGlyphBuffer + endIndexPlusOne, @@ -577,7 +565,7 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character positionsBuffer + endGlyphIndexPlusOne ); } - if( LAYOUT & operations ) + if( NO_OPERATION != ( LAYOUT & operations ) ) { // Clear the lines. uint32_t startRemoveIndex = mVisualModel->mLines.Count(); @@ -605,7 +593,7 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character linesBuffer + endRemoveIndex ); } - if( COLOR & operations ) + if( NO_OPERATION != ( COLOR & operations ) ) { if( 0u != mVisualModel->mColorIndices.Count() ) { @@ -667,7 +655,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) if( mTextUpdateInfo.mClearAll || ( 0u != paragraphCharacters ) ) { - ClearModelData( startIndex, startIndex + ( ( paragraphCharacters > 0u ) ? paragraphCharacters - 1u : 0u ), operationsRequired ); + ClearModelData( startIndex, startIndex + ( ( paragraphCharacters > 0u ) ? paragraphCharacters - 1u : 0u ), operations ); } mTextUpdateInfo.mClearAll = false; @@ -678,7 +666,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) Vector& lineBreakInfo = mLogicalModel->mLineBreakInfo; const Length requestedNumberOfCharacters = mTextUpdateInfo.mRequestedNumberOfCharacters; - if( GET_LINE_BREAKS & operations ) + if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) ) { // Retrieves the line break info. The line break info is used to split the text in 'paragraphs' to // calculate the bidirectional info for each 'paragraph'. @@ -698,7 +686,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) } Vector& wordBreakInfo = mLogicalModel->mWordBreakInfo; - if( GET_WORD_BREAKS & operations ) + if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) ) { // Retrieves the word break info. The word break info is used to layout the text (where to wrap the text in lines). wordBreakInfo.Resize( numberOfCharacters, TextAbstraction::WORD_NO_BREAK ); @@ -710,8 +698,8 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) updated = true; } - const bool getScripts = GET_SCRIPTS & operations; - const bool validateFonts = VALIDATE_FONTS & operations; + const bool getScripts = NO_OPERATION != ( GET_SCRIPTS & operations ); + const bool validateFonts = NO_OPERATION != ( VALIDATE_FONTS & operations ); Vector& scripts = mLogicalModel->mScriptRuns; Vector& validFonts = mLogicalModel->mFontRuns; @@ -755,7 +743,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) Vector mirroredUtf32Characters; bool textMirrored = false; const Length numberOfParagraphs = mLogicalModel->mParagraphInfo.Count(); - if( BIDI_INFO & operations ) + if( NO_OPERATION != ( BIDI_INFO & operations ) ) { Vector& bidirectionalInfo = mLogicalModel->mBidirectionalParagraphInfo; bidirectionalInfo.Reserve( numberOfParagraphs ); @@ -803,7 +791,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) newParagraphGlyphs.Reserve( numberOfParagraphs ); const Length currentNumberOfGlyphs = glyphs.Count(); - if( SHAPE_TEXT & operations ) + if( NO_OPERATION != ( SHAPE_TEXT & operations ) ) { const Vector& textToShape = textMirrored ? mirroredUtf32Characters : utf32Characters; // Shapes the text. @@ -827,7 +815,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) const Length numberOfGlyphs = glyphs.Count() - currentNumberOfGlyphs; - if( GET_GLYPH_METRICS & operations ) + if( NO_OPERATION != ( GET_GLYPH_METRICS & operations ) ) { GlyphInfo* glyphsBuffer = glyphs.Begin(); mMetrics->GetGlyphMetrics( glyphsBuffer + mTextUpdateInfo.mStartGlyphIndex, numberOfGlyphs ); @@ -845,7 +833,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) updated = true; } - if( COLOR & operationsRequired ) + if( NO_OPERATION != ( COLOR & operations ) ) { // Set the color runs in glyphs. SetColorSegmentationInfo( mLogicalModel->mColorRuns, @@ -1402,12 +1390,17 @@ void Controller::Impl::ShowClipboard() void Controller::Impl::HideClipboard() { - if( mClipboard ) + if( mClipboard && mClipboardHideEnabled ) { mClipboard.HideClipboard(); } } +void Controller::Impl::SetClipboardHideEnable(bool enable) +{ + mClipboardHideEnabled = enable; +} + bool Controller::Impl::CopyStringToClipboard( std::string& source ) { //Send string to clipboard @@ -1945,10 +1938,6 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX, const Vector& positions = mVisualModel->mGlyphPositions; const Vector2* const positionsBuffer = positions.Begin(); - // Get the visual to logical conversion tables. - const CharacterIndex* const visualToLogicalBuffer = ( 0u != mLogicalModel->mVisualToLogicalMap.Count() ) ? mLogicalModel->mVisualToLogicalMap.Begin() : NULL; - const CharacterIndex* const visualToLogicalCursorBuffer = mLogicalModel->mVisualToLogicalCursorMap.Begin(); - // Get the character to glyph conversion table. const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin(); @@ -1958,9 +1947,6 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX, // Get the glyph's info buffer. const GlyphInfo* const glyphInfoBuffer = mVisualModel->mGlyphs.Begin(); - // If the vector is void, there is no right to left characters. - const bool hasRightToLeftCharacters = NULL != visualToLogicalBuffer; - const CharacterIndex startCharacter = line.characterRun.characterIndex; const CharacterIndex endCharacter = line.characterRun.characterIndex + line.characterRun.numberOfCharacters; DALI_ASSERT_DEBUG( endCharacter <= mLogicalModel->mText.Count() && "Invalid line info" ); @@ -1974,7 +1960,7 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX, for( ; !matched && ( visualIndex < endCharacter ); ++visualIndex ) { // The character in logical order. - const CharacterIndex characterLogicalOrderIndex = hasRightToLeftCharacters ? *( visualToLogicalBuffer + visualIndex ) : visualIndex; + const CharacterIndex characterLogicalOrderIndex = mLogicalModel->GetLogicalCharacterIndex( visualIndex ); // Get the script of the character. const Script script = mLogicalModel->GetScript( characterLogicalOrderIndex ); @@ -1988,7 +1974,7 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX, { // Get the first character/glyph of the group of glyphs. const CharacterIndex firstVisualCharacterIndex = 1u + visualIndex - numberOfCharacters; - const CharacterIndex firstLogicalCharacterIndex = hasRightToLeftCharacters ? *( visualToLogicalBuffer + firstVisualCharacterIndex ) : firstVisualCharacterIndex; + const CharacterIndex firstLogicalCharacterIndex = mLogicalModel->GetLogicalCharacterIndex( firstVisualCharacterIndex ); const GlyphIndex firstLogicalGlyphIndex = *( charactersToGlyphBuffer + firstLogicalCharacterIndex ); // Get the metrics for the group of glyphs. @@ -2031,7 +2017,6 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX, } - // Return the logical position of the cursor in characters. if( !matched ) @@ -2039,7 +2024,7 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX, visualIndex = endCharacter; } - logicalIndex = hasRightToLeftCharacters ? *( visualToLogicalCursorBuffer + visualIndex ) : visualIndex; + logicalIndex = mLogicalModel->GetLogicalCursorIndex( visualIndex ); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "%p closest visualIndex %d logicalIndex %d\n", this, visualIndex, logicalIndex ); DALI_ASSERT_DEBUG( ( logicalIndex <= mLogicalModel->mText.Count() && logicalIndex >= 0 ) && "GetClosestCursorIndex - Out of bounds index" );