From: Adeel Kazmi Date: Wed, 1 Jul 2015 18:13:34 +0000 (-0700) Subject: Merge "Show CopyPaste Poup on long press" into devel/master X-Git-Tag: dali_1.0.48~20 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=079795bcb6a8aab48e5e4252a86f524e6749fcbb;hp=-c Merge "Show CopyPaste Poup on long press" into devel/master --- 079795bcb6a8aab48e5e4252a86f524e6749fcbb diff --combined dali-toolkit/internal/text/text-controller-impl.cpp index 0c6b2b7,ecb5c54..9e29628 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@@ -171,6 -171,11 +171,11 @@@ bool Controller::Impl::ProcessInputEven OnTapEvent( *iter ); break; } + case Event::LONG_PRESS_EVENT: + { + OnLongPressEvent( *iter ); + break; + } case Event::PAN_EVENT: { OnPanEvent( *iter ); @@@ -539,6 -544,15 +544,15 @@@ void Controller::Impl::OnPanEvent( cons } } + void Controller::Impl::OnLongPressEvent( const Event& event ) + { + if ( EventData::EDITING == mEventData->mState ) + { + ChangeState ( EventData::EDITING_WITH_POPUP ); + mEventData->mDecoratorUpdated = true; + } + } + void Controller::Impl::OnHandleEvent( const Event& event ) { if( NULL == mEventData ) @@@ -998,7 -1012,10 +1012,10 @@@ void Controller::Impl::SetPopupButtons( } else if ( EventData::EDITING_WITH_POPUP == mEventData->mState ) { - buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL ); + if ( mLogicalModel->mText.Count() && !IsShowingPlaceholderText()) + { + buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL ); + } if ( !IsClipboardEmpty() ) { @@@ -1228,7 -1245,6 +1245,7 @@@ CharacterIndex Controller::Impl::GetClo // Get the glyphs per character table. const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin(); + const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin(); // If the vector is void, there is no right to left characters. const bool hasRightToLeftCharacters = NULL != visualToLogicalBuffer; @@@ -1247,11 -1263,9 +1264,11 @@@ // The character in logical order. const CharacterIndex characterLogicalOrderIndex = hasRightToLeftCharacters ? *( visualToLogicalBuffer + visualIndex ) : visualIndex; + // Get the script of the character. + const Script script = mLogicalModel->GetScript( characterLogicalOrderIndex ); + // The first glyph for that character in logical order. const GlyphIndex glyphLogicalOrderIndex = *( charactersToGlyphBuffer + characterLogicalOrderIndex ); - // The number of glyphs for that character const Length numberOfGlyphs = *( glyphsPerCharacterBuffer + characterLogicalOrderIndex ); @@@ -1265,25 -1279,12 +1282,25 @@@ const Vector2& position = *( positionsBuffer + glyphLogicalOrderIndex ); - // Find the mid-point of the area containing the glyph - const float glyphCenter = -glyphMetrics.xBearing + position.x + 0.5f * glyphMetrics.advance; + // Prevents to jump the whole Latin ligatures like fi, ff, ... + const Length numberOfCharactersInLigature = ( TextAbstraction::LATIN == script ) ? *( charactersPerGlyphBuffer + glyphLogicalOrderIndex ) : 1u; + const float glyphAdvance = glyphMetrics.advance / static_cast( numberOfCharactersInLigature ); + + for( GlyphIndex index = 0u; !matched && ( index < numberOfCharactersInLigature ); ++index ) + { + // Find the mid-point of the area containing the glyph + const float glyphCenter = -glyphMetrics.xBearing + position.x + ( static_cast( index ) + 0.5f ) * glyphAdvance; + + if( visualX < glyphCenter ) + { + visualIndex += index; + matched = true; + break; + } + } - if( visualX < glyphCenter ) + if( matched ) { - matched = true; break; } } @@@ -1297,7 -1298,6 +1314,7 @@@ logicalIndex = hasRightToLeftCharacters ? *( visualToLogicalCursorBuffer + visualIndex ) : visualIndex; DALI_LOG_INFO( gLogFilter, Debug::Verbose, "%p closest visualIndex %d logicalIndex %d\n", this, visualIndex, logicalIndex ); + return logicalIndex; }