From: Paul Wisbey Date: Fri, 27 May 2016 15:23:17 +0000 (-0700) Subject: Merge "Bidirectional conversion table for multiline." into devel/master X-Git-Tag: dali_1.1.37~10 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=73696fd1c7d5f263261a7114159aab66ead484ff;hp=-c Merge "Bidirectional conversion table for multiline." into devel/master --- 73696fd1c7d5f263261a7114159aab66ead484ff diff --combined dali-toolkit/internal/text/text-controller-impl.cpp index d4d8fdc,29b5718..800a721 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@@ -154,19 -154,16 +154,19 @@@ bool Controller::Impl::ProcessInputEven GetCursorPosition( mEventData->mPrimaryCursorPosition, cursorInfo ); - if( mEventData->mScrollAfterUpdatePosition ) + // Scroll first the text after delete ... + if( mEventData->mScrollAfterDelete ) { - ScrollToMakePositionVisible( cursorInfo.primaryPosition ); - mEventData->mScrollAfterUpdatePosition = false; + ScrollTextToMatchCursor( cursorInfo ); } - else if( mEventData->mScrollAfterDelete ) + + // ... then, text can be scrolled to make the cursor visible. + if( mEventData->mScrollAfterUpdatePosition ) { - ScrollTextToMatchCursor( cursorInfo ); - mEventData->mScrollAfterDelete = false; + ScrollToMakePositionVisible( cursorInfo.primaryPosition ); } + mEventData->mScrollAfterUpdatePosition = false; + mEventData->mScrollAfterDelete = false; UpdateCursorPosition( cursorInfo ); @@@ -1305,7 -1302,6 +1305,7 @@@ void Controller::Impl::OnSelectEvent( c mEventData->mUpdateLeftSelectionPosition = true; mEventData->mUpdateRightSelectionPosition = true; + mEventData->mUpdateCursorPosition = false; mEventData->mScrollAfterUpdatePosition = ( mEventData->mLeftSelectionPosition != mEventData->mRightSelectionPosition ); } @@@ -1374,7 -1370,12 +1374,7 @@@ void Controller::Impl::RetrieveSelectio // Scroll after delete. mEventData->mPrimaryCursorPosition = handlesCrossed ? mEventData->mRightSelectionPosition : mEventData->mLeftSelectionPosition; - mEventData->mScrollAfterDelete = true; } - // Udpade the cursor position and the decorator. - // Scroll after the position is updated if is not scrolling after delete. - mEventData->mUpdateCursorPosition = true; - mEventData->mScrollAfterUpdatePosition = !mEventData->mScrollAfterDelete; mEventData->mDecoratorUpdated = true; } } @@@ -1929,7 -1930,7 +1929,7 @@@ CharacterIndex Controller::Impl::GetClo return logicalIndex; } - // Find which line is closest + // Find which line is closest. const LineIndex lineIndex = GetClosestLine( visualY ); const LineRun& line = mVisualModel->mLines[lineIndex]; @@@ -1950,6 -1951,9 +1950,9 @@@ const CharacterIndex endCharacter = line.characterRun.characterIndex + line.characterRun.numberOfCharacters; DALI_ASSERT_DEBUG( endCharacter <= mLogicalModel->mText.Count() && "Invalid line info" ); + // Whether this line is a bidirectional line. + const bool bidiLineFetched = mLogicalModel->FetchBidirectionalLineInfo( startCharacter ); + // Whether there is a hit on a glyph. bool matched = false; @@@ -1959,7 -1963,7 +1962,7 @@@ for( ; !matched && ( visualIndex < endCharacter ); ++visualIndex ) { // The character in logical order. - const CharacterIndex characterLogicalOrderIndex = mLogicalModel->GetLogicalCharacterIndex( visualIndex ); + const CharacterIndex characterLogicalOrderIndex = ( bidiLineFetched ? mLogicalModel->GetLogicalCharacterIndex( visualIndex ) : visualIndex ); // Get the script of the character. const Script script = mLogicalModel->GetScript( characterLogicalOrderIndex ); @@@ -1973,7 -1977,7 +1976,7 @@@ { // Get the first character/glyph of the group of glyphs. const CharacterIndex firstVisualCharacterIndex = 1u + visualIndex - numberOfCharacters; - const CharacterIndex firstLogicalCharacterIndex = mLogicalModel->GetLogicalCharacterIndex( firstVisualCharacterIndex ); + const CharacterIndex firstLogicalCharacterIndex = ( bidiLineFetched ? mLogicalModel->GetLogicalCharacterIndex( firstVisualCharacterIndex ) : firstVisualCharacterIndex ); const GlyphIndex firstLogicalGlyphIndex = *( charactersToGlyphBuffer + firstLogicalCharacterIndex ); // Get the metrics for the group of glyphs. @@@ -2023,7 -2027,7 +2026,7 @@@ visualIndex = endCharacter; } - logicalIndex = mLogicalModel->GetLogicalCursorIndex( visualIndex ); + logicalIndex = ( bidiLineFetched ? mLogicalModel->GetLogicalCursorIndex( visualIndex ) : 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" ); @@@ -2453,10 -2457,8 +2456,10 @@@ void Controller::Impl::ClampVerticalScr void Controller::Impl::ScrollToMakePositionVisible( const Vector2& position ) { + const float cursorWidth = mEventData->mDecorator ? mEventData->mDecorator->GetCursorWidth() : 0.f; + // position is in actor's coords. - const float positionEnd = position.x + ( mEventData->mDecorator ? mEventData->mDecorator->GetCursorWidth() : 0.f ); + const float positionEnd = position.x + cursorWidth; // Transform the position to decorator coords. const float alignment = IsShowingRealText() ? mAlignmentOffset.x : 0.f; @@@ -2483,9 -2485,6 +2486,9 @@@ void Controller::Impl::ScrollTextToMatc mEventData->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x - mAlignmentOffset.x; ClampHorizontalScroll( mVisualModel->GetLayoutSize() ); + + // Makes the new cursor position visible if needed. + ScrollToMakePositionVisible( cursorInfo.primaryPosition ); } void Controller::Impl::RequestRelayout()