X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.cpp;h=e3b29bd1e36e9eb7026ce2bee72189ad7ee6c791;hp=457a6c529194905be0bc2bfaea5278f779039343;hb=ae34cf6aef4b3b807bd1e099baa48230b6b32156;hpb=19132dd0385b8e8a37d0a081048b0f43dc48caa4 diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 457a6c5..e3b29bd 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -681,6 +681,13 @@ void Controller::ProcessModifyEvents() } } + if( mImpl->mEventData && + 0 != events.size() ) + { + // When the text is being modified, delay cursor blinking + mImpl->mEventData->mDecorator->DelayCursorBlink(); + } + // Discard temporary text events.clear(); } @@ -1098,7 +1105,12 @@ void Controller::KeyboardFocusGainEvent() if( mImpl->mEventData ) { - mImpl->ChangeState( EventData::EDITING ); + if( ( EventData::INACTIVE == mImpl->mEventData->mState ) || + ( EventData::INTERRUPTED == mImpl->mEventData->mState ) ) + { + mImpl->ChangeState( EventData::EDITING ); + mImpl->mEventData->mUpdateCursorPosition = true; //If editing started without tap event, cursor update must be triggered. + } if( mImpl->IsShowingPlaceholderText() ) { @@ -1106,7 +1118,6 @@ void Controller::KeyboardFocusGainEvent() ShowPlaceholderText(); } - mImpl->mEventData->mUpdateCursorPosition = true; //If editing started without tap event, cursor update must be triggered. mImpl->RequestRelayout(); } } @@ -1192,7 +1203,8 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) textChanged = true; } - if ( mImpl->mEventData->mState != EventData::INTERRUPTED && mImpl->mEventData->mState != EventData::INACTIVE ) + if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) && + ( mImpl->mEventData->mState != EventData::INACTIVE ) ) { mImpl->ChangeState( EventData::EDITING ); } @@ -1291,24 +1303,6 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ mImpl->mEventData->mPreEditLength = utf32Characters.Count(); mImpl->mEventData->mPreEditFlag = true; - 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(); - - 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 ); - - 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 ); } } @@ -1390,33 +1384,50 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y ) if( NULL != mImpl->mEventData ) { - const bool isShowingPlaceholderText = mImpl->IsShowingPlaceholderText(); if( 1u == tapCount ) { - if( !isShowingPlaceholderText && - ( EventData::EDITING == mImpl->mEventData->mState ) ) + // This is to avoid unnecessary relayouts when tapping an empty text-field + bool relayoutNeeded( false ); + + if( mImpl->IsShowingRealText() && + EventData::EDITING == mImpl->mEventData->mState ) { + // Show grab handle on second tap mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE ); + relayoutNeeded = true; } - else if( EventData::EDITING_WITH_GRAB_HANDLE != mImpl->mEventData->mState ) + else if( EventData::EDITING != mImpl->mEventData->mState && + EventData::EDITING_WITH_GRAB_HANDLE != mImpl->mEventData->mState ) { - // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated + // Show cursor on first tap mImpl->ChangeState( EventData::EDITING ); + relayoutNeeded = true; + } + else if( mImpl->IsShowingRealText() ) + { + // Move the cursor + relayoutNeeded = true; } - Event event( Event::TAP_EVENT ); - event.p1.mUint = tapCount; - event.p2.mFloat = x; - event.p3.mFloat = y; - mImpl->mEventData->mEventQueue.push_back( event ); + // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated + if( relayoutNeeded ) + { + Event event( Event::TAP_EVENT ); + event.p1.mUint = tapCount; + event.p2.mFloat = x; + event.p3.mFloat = y; + mImpl->mEventData->mEventQueue.push_back( event ); - mImpl->RequestRelayout(); + mImpl->RequestRelayout(); + } } - else if( !isShowingPlaceholderText && - mImpl->mEventData->mSelectionEnabled && - ( 2u == tapCount ) ) + else if( 2u == tapCount ) { - SelectEvent( x, y, false ); + if( mImpl->mEventData->mSelectionEnabled && + mImpl->IsShowingRealText() ) + { + SelectEvent( x, y, false ); + } } }