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=620eb4915bc156b7076f80f73d5b1d1c1e18aa45;hp=7847fb99f34e374ca6ab26efb819040ddcdcb233;hb=ce6786c6a3ddbc40b8d302f42e7efee630430b6f;hpb=e70f617e67183aae0301f1d6c71930cd98f9870e diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 7847fb9..620eb49 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -25,6 +25,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -48,6 +49,10 @@ const float MAX_FLOAT = std::numeric_limits::max(); const std::string EMPTY_STRING(""); +const std::string KEY_C_NAME = "c"; +const std::string KEY_V_NAME = "v"; +const std::string KEY_X_NAME = "x"; + const char * const PLACEHOLDER_TEXT = "text"; const char * const PLACEHOLDER_TEXT_FOCUSED = "textFocused"; const char * const PLACEHOLDER_COLOR = "color"; @@ -346,6 +351,7 @@ void Controller::SetMultiLineEnabled( bool enable ) ALIGN | REORDER ); + mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true; mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | layoutOperations ); mImpl->RequestRelayout(); @@ -2097,6 +2103,17 @@ void Controller::GetPlaceholderProperty( Property::Map& map ) } } +Toolkit::DevelText::TextDirection::Type Controller::GetTextDirection() +{ + const LineRun* const firstline = mImpl->mModel->mVisualModel->mLines.Begin(); + if ( firstline && firstline->direction ) + { + return Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT; + } + + return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT; +} + // public : Relayout. Controller::UpdateTextType Controller::Relayout( const Size& size ) @@ -2320,6 +2337,7 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) { int keyCode = keyEvent.keyCode; const std::string& keyString = keyEvent.keyPressed; + const std::string keyName = keyEvent.keyPressedName; const bool isNullKey = ( 0 == keyCode ) && ( keyString.empty() ); @@ -2365,14 +2383,47 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) mImpl->mEventData->mCheckScrollAmount = true; Event event( Event::CURSOR_KEY_EVENT ); event.p1.mInt = keyCode; + event.p2.mBool = keyEvent.IsShiftModifier(); mImpl->mEventData->mEventQueue.push_back( event ); // Will request for relayout. relayoutNeeded = true; } - else if( Dali::DALI_KEY_BACKSPACE == keyCode ) + else if ( Dali::DevelKey::DALI_KEY_CONTROL_LEFT == keyCode || Dali::DevelKey::DALI_KEY_CONTROL_RIGHT == keyCode ) + { + // Left or Right Control key event is received before Ctrl-C/V/X key event is received + // If not handle it here, any selected text will be deleted + + // Do nothing + return false; + } + else if ( keyEvent.IsCtrlModifier() ) { - textChanged = BackspaceKeyEvent(); + bool consumed = false; + if (keyName == KEY_C_NAME) + { + // Ctrl-C to copy the selected text + TextPopupButtonTouched( Toolkit::TextSelectionPopup::COPY ); + consumed = true; + } + else if (keyName == KEY_V_NAME) + { + // Ctrl-V to paste the copied text + TextPopupButtonTouched( Toolkit::TextSelectionPopup::PASTE ); + consumed = true; + } + else if (keyName == KEY_X_NAME) + { + // Ctrl-X to cut the selected text + TextPopupButtonTouched( Toolkit::TextSelectionPopup::CUT ); + consumed = true; + } + return consumed; + } + else if( ( Dali::DALI_KEY_BACKSPACE == keyCode ) || + ( Dali::DevelKey::DALI_KEY_DELETE == keyCode ) ) + { + textChanged = DeleteEvent( keyCode ); // Will request for relayout. relayoutNeeded = true; @@ -3540,6 +3591,10 @@ void Controller::ProcessModifyEvents() { // When the text is being modified, delay cursor blinking mImpl->mEventData->mDecorator->DelayCursorBlink(); + + // Update selection position after modifying the text + mImpl->mEventData->mLeftSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition; + mImpl->mEventData->mRightSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition; } // Discard temporary text @@ -3617,9 +3672,9 @@ void Controller::SelectEvent( float x, float y, bool selectAll ) } } -bool Controller::BackspaceKeyEvent() +bool Controller::DeleteEvent( int keyCode ) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p DALI_KEY_BACKSPACE\n", this ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p KeyCode : %d \n", this, keyCode ); bool removed = false; @@ -3635,13 +3690,20 @@ bool Controller::BackspaceKeyEvent() { removed = RemoveSelectedText(); } - else if( mImpl->mEventData->mPrimaryCursorPosition > 0 ) + else if( ( mImpl->mEventData->mPrimaryCursorPosition > 0 ) && ( keyCode == Dali::DALI_KEY_BACKSPACE) ) { // Remove the character before the current cursor position removed = RemoveText( -1, 1, UPDATE_INPUT_STYLE ); } + else if( keyCode == Dali::DevelKey::DALI_KEY_DELETE ) + { + // Remove the character after the current cursor position + removed = RemoveText( 0, + 1, + UPDATE_INPUT_STYLE ); + } if( removed ) { @@ -3774,6 +3836,7 @@ void Controller::ClearFontData() mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | VALIDATE_FONTS | SHAPE_TEXT | + BIDI_INFO | GET_GLYPH_METRICS | LAYOUT | UPDATE_LAYOUT_SIZE |