From: v.cebollada Date: Wed, 19 Aug 2015 15:19:18 +0000 (+0900) Subject: Fix for underlined text. X-Git-Tag: dali_1.1.1~11^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=bac344e54e6afa0dced75f338ac7a784b7f13632;hp=f6cf60941d7fb0f8a746ac7c526be305fc2a5961 Fix for underlined text. * Avoids the crash the first time a forled name is edited. Change-Id: I378b04143afbed98d40284450bf31748efd07a96 Signed-off-by: v.cebollada --- diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 233e764..ffc8aff 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -34,7 +34,7 @@ namespace { #if defined(DEBUG_ENABLED) - Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS"); + Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Verbose, true, "LOG_TEXT_CONTROLS"); #endif const float MAX_FLOAT = std::numeric_limits::max(); @@ -1210,6 +1210,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ 0 != mImpl->mEventData->mPreEditLength ) { CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition; + removedPrevious = RemoveText( -static_cast(offset), mImpl->mEventData->mPreEditLength ); mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition; @@ -1221,7 +1222,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ removedPrevious = RemoveSelectedText(); } - if( ! text.empty() ) + if( !text.empty() ) { // Convert text into UTF-32 utf32Characters.Resize( text.size() ); @@ -1269,22 +1270,24 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ mImpl->mEventData->mPreEditLength = utf32Characters.Count(); mImpl->mEventData->mPreEditFlag = true; - // Add the underline for the pre-edit text. - const GlyphIndex* const charactersToGlyphBuffer = mImpl->mVisualModel->mCharactersToGlyph.Begin(); - const Length* const glyphsPerCharacterBuffer = mImpl->mVisualModel->mGlyphsPerCharacter.Begin(); - - const GlyphIndex glyphStart = *( charactersToGlyphBuffer + mImpl->mEventData->mPreEditStartPosition ); - const CharacterIndex lastPreEditCharacter = mImpl->mEventData->mPreEditStartPosition + ( ( mImpl->mEventData->mPreEditLength > 0u ) ? mImpl->mEventData->mPreEditLength - 1u : 0u ); - const Length numberOfGlyphsLastCharacter = *( glyphsPerCharacterBuffer + lastPreEditCharacter ); - const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + lastPreEditCharacter ) + ( numberOfGlyphsLastCharacter > 1u ? numberOfGlyphsLastCharacter - 1u : 0u ); + if( 0u != mImpl->mVisualModel->mCharactersToGlyph.Count() ) + { + // Add the underline for the pre-edit text. + const GlyphIndex* const charactersToGlyphBuffer = mImpl->mVisualModel->mCharactersToGlyph.Begin(); + const Length* const glyphsPerCharacterBuffer = mImpl->mVisualModel->mGlyphsPerCharacter.Begin(); - GlyphRun underlineRun; - underlineRun.glyphIndex = glyphStart; - underlineRun.numberOfGlyphs = 1u + glyphEnd - glyphStart; + const GlyphIndex glyphStart = *( charactersToGlyphBuffer + mImpl->mEventData->mPreEditStartPosition ); + const CharacterIndex lastPreEditCharacter = mImpl->mEventData->mPreEditStartPosition + ( ( mImpl->mEventData->mPreEditLength > 0u ) ? mImpl->mEventData->mPreEditLength - 1u : 0u ); + const Length numberOfGlyphsLastCharacter = *( glyphsPerCharacterBuffer + lastPreEditCharacter ); + const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + lastPreEditCharacter ) + ( numberOfGlyphsLastCharacter > 1u ? numberOfGlyphsLastCharacter - 1u : 0u ); - // TODO: At the moment the underline runs are only for pre-edit. - mImpl->mVisualModel->mUnderlineRuns.PushBack( underlineRun ); + GlyphRun underlineRun; + underlineRun.glyphIndex = glyphStart; + underlineRun.numberOfGlyphs = 1u + glyphEnd - glyphStart; + // TODO: At the moment the underline runs are only for pre-edit. + mImpl->mVisualModel->mUnderlineRuns.PushBack( underlineRun ); + } DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength ); } }