From: Adeel Kazmi Date: Thu, 25 Jun 2015 08:08:39 +0000 (-0700) Subject: Merge "UTC Builder coverage" into devel/master X-Git-Tag: dali_1.0.47~21 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=a505bf603895074e638b374097e6d5c649e2292e;hp=d88577aa8c038c79806b77b33d5124d8e1144663 Merge "UTC Builder coverage" into devel/master --- diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 982b8d1..7a51b86 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -787,7 +787,7 @@ void Controller::Impl::OnSelectAllEvent() } } -void Controller::Impl::RetreiveSelection( std::string& selectedText, bool deleteAfterRetreival ) +void Controller::Impl::RetrieveSelection( std::string& selectedText, bool deleteAfterRetreival ) { if( mEventData->mLeftSelectionPosition == mEventData->mRightSelectionPosition ) { @@ -832,7 +832,7 @@ bool Controller::Impl::CopyStringToClipboard( std::string& source ) void Controller::Impl::SendSelectionToClipboard( bool deleteAfterSending ) { std::string selectedText; - RetreiveSelection( selectedText, deleteAfterSending ); + RetrieveSelection( selectedText, deleteAfterSending ); CopyStringToClipboard( selectedText ); ChangeState( EventData::EDITING ); } diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 8e84d3c..880004a 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -339,7 +339,7 @@ struct Controller::Impl void OnSelectAllEvent(); - void RetreiveSelection( std::string& selectedText, bool deleteAfterRetreival ); + void RetrieveSelection( std::string& selectedText, bool deleteAfterRetreival ); bool CopyStringToClipboard( std::string& source ); diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index f1ee352..b55a543 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1121,9 +1121,6 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) int keyCode = keyEvent.keyCode; const std::string& keyString = keyEvent.keyPressed; - // Hide the grab handle. - mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false ); - // Pre-process to separate modifying events from non-modifying input events. if( Dali::DALI_KEY_ESCAPE == keyCode ) { @@ -1141,29 +1138,7 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) } else if( Dali::DALI_KEY_BACKSPACE == keyCode ) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p DALI_KEY_BACKSPACE\n", this ); - - // IMF manager is no longer handling key-events - mImpl->ClearPreEditFlag(); - - // Remove the character before the current cursor position - bool removed = RemoveText( -1, 1 ); - - if( removed ) - { - if( 0u != mImpl->mLogicalModel->mText.Count() || - !mImpl->IsPlaceholderAvailable() ) - { - mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED ); - } - else - { - ShowPlaceholderText(); - mImpl->mEventData->mUpdateCursorPosition = true; - } - - textChanged = true; - } + textChanged = BackspaceKeyEvent(); } else { @@ -1173,7 +1148,6 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) mImpl->ClearPreEditFlag(); InsertText( keyString, COMMIT ); - textChanged = true; } @@ -1193,7 +1167,7 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) void Controller::InsertText( const std::string& text, Controller::InsertType type ) { - bool removedPreEdit( false ); + bool removedPrevious( false ); bool maxLengthReached( false ); DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected InsertText" ) @@ -1210,11 +1184,16 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ 0 != mImpl->mEventData->mPreEditLength ) { CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition; - removedPreEdit = RemoveText( -static_cast(offset), mImpl->mEventData->mPreEditLength ); + removedPrevious = RemoveText( -static_cast(offset), mImpl->mEventData->mPreEditLength ); mImpl->mEventData->mPrimaryCursorPosition = mImpl->mEventData->mPreEditStartPosition; mImpl->mEventData->mPreEditLength = 0; } + else + { + // Remove the previous Selection + removedPrevious = RemoveSelectedText(); + } if( ! text.empty() ) { @@ -1299,7 +1278,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ mImpl->mEventData->mUpdateCursorPosition = true; mImpl->ClearPreEditFlag(); } - else if( removedPreEdit || + else if( removedPrevious || 0 != utf32Characters.Count() ) { // Queue an inserted event @@ -1317,6 +1296,26 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ } } +bool Controller::RemoveSelectedText() +{ + bool textRemoved( false ); + + if ( EventData::SELECTING == mImpl->mEventData->mState || + EventData::SELECTION_CHANGED == mImpl->mEventData->mState ) + { + std::string removedString; + mImpl->RetrieveSelection( removedString, true ); + + if( !removedString.empty() ) + { + textRemoved = true; + mImpl->ChangeState( EventData::EDITING ); + } + } + + return textRemoved; +} + void Controller::TapEvent( unsigned int tapCount, float x, float y ) { DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" ); @@ -1501,7 +1500,7 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt { std::string stringToPaste(""); mImpl->GetTextFromClipboard( 0, stringToPaste ); // Paste latest item from system clipboard - InsertText( stringToPaste, Text::Controller::CLIPBOARD ); + InsertText( stringToPaste, Text::Controller::COMMIT ); mImpl->ChangeState( EventData::EDITING ); mImpl->RequestRelayout(); break; @@ -1606,6 +1605,43 @@ Controller::~Controller() delete mImpl; } +bool Controller::BackspaceKeyEvent() +{ + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p DALI_KEY_BACKSPACE\n", this ); + + // IMF manager is no longer handling key-events + mImpl->ClearPreEditFlag(); + + bool removed( false ); + + if ( EventData::SELECTING == mImpl->mEventData->mState || + EventData::SELECTION_CHANGED == mImpl->mEventData->mState ) + { + removed = RemoveSelectedText(); + } + else if( mImpl->mEventData->mPrimaryCursorPosition > 0 ) + { + // Remove the character before the current cursor position + removed = RemoveText( -1, 1 ); + } + + if( removed ) + { + if( 0u != mImpl->mLogicalModel->mText.Count() || + !mImpl->IsPlaceholderAvailable() ) + { + mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED ); + } + else + { + ShowPlaceholderText(); + mImpl->mEventData->mUpdateCursorPosition = true; + } + } + + return removed; +} + void Controller::ShowPlaceholderText() { if( mImpl->IsPlaceholderAvailable() ) diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index f1e1d28..2f83407 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -103,8 +103,7 @@ public: enum InsertType { COMMIT, - PRE_EDIT, - CLIPBOARD + PRE_EDIT }; /** @@ -504,6 +503,12 @@ public: void InsertText( const std::string& text, InsertType type ); /** + * @brief Checks if text is selected and if so removes it. + * @return true if text was removed + */ + bool RemoveSelectedText(); + + /** * @brief Called by editable UI controls when a tap gesture occurs. * @param[in] tapCount The number of taps. * @param[in] x The x position relative to the top-left of the parent control. @@ -569,6 +574,13 @@ protected: private: /** + * @brief Helper to KeyEvent() to handle the backspace case. + * + * @return True if a character was deleted. + */ + bool BackspaceKeyEvent(); + + /** * @brief Helper to clear font-specific data. */ void ShowPlaceholderText();