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=b2fec632bce54d49a9691dfae57563f0d2a09652;hp=c16cd0b430920d0855c7c01fa471d779d2b1e54b;hb=5177de187f2bb2736603cbd10f99e3a50084ebc7;hpb=162dee76321b6d0ce335fc8cd04a0bb7389b54c9 diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index c16cd0b..b2fec63 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -24,14 +24,17 @@ #include #include #include +#include // INTERNAL INCLUDES #include #include #include #include +#include #include #include +#include namespace { @@ -44,6 +47,13 @@ const float MAX_FLOAT = std::numeric_limits::max(); const std::string EMPTY_STRING(""); +const char * const PLACEHOLDER_TEXT = "placeholderText"; +const char * const PLACEHOLDER_COLOR = "placeholderColor"; +const char * const PLACEHOLDER_FONT_FAMILY = "placeholderFontFamily"; +const char * const PLACEHOLDER_FONT_STYLE = "placeholderFontStyle"; +const char * const PLACEHOLDER_POINT_SIZE = "placeholderPointSize"; +const char * const PLACEHOLDER_PIXEL_SIZE = "placeholderPixelSize"; + float ConvertToEven( float value ) { int intValue(static_cast( value )); @@ -391,6 +401,16 @@ bool Controller::IsTextElideEnabled() const return mImpl->mModel->mElideEnabled; } +void Controller::SetSelectionEnabled( bool enabled ) +{ + mImpl->mEventData->mSelectionEnabled = enabled; +} + +bool Controller::IsSelectionEnabled() const +{ + return mImpl->mEventData->mSelectionEnabled; +} + // public : Update void Controller::SetText( const std::string& text ) @@ -511,6 +531,22 @@ void Controller::GetText( std::string& text ) const } } +void Controller::SetPlaceholderText( const std::string& text ) +{ + if( NULL != mImpl->mEventData ) + { + mImpl->mEventData->mPlaceholderText = text; + + // Update placeholder if there is no text + if( mImpl->IsShowingPlaceholderText() || + ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) ) + { + ShowPlaceholderText(); + } + } +} + +// This is overloading function for PLACEHOLDER_TEXT_FOCUSED in text-field void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text ) { if( NULL != mImpl->mEventData ) @@ -533,6 +569,15 @@ void Controller::SetPlaceholderText( PlaceholderType type, const std::string& te } } +void Controller::GetPlaceholderText( std::string& text ) const +{ + if( NULL != mImpl->mEventData ) + { + text = mImpl->mEventData->mPlaceholderText; + } +} + +// This is overloading function for PLACEHOLDER_TEXT_FOCUSED in text-field void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const { if( NULL != mImpl->mEventData ) @@ -592,6 +637,33 @@ const std::string& Controller::GetDefaultFontFamily() const return EMPTY_STRING; } +void Controller::SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily ) +{ + if( NULL != mImpl->mEventData ) + { + if( NULL == mImpl->mEventData->mPlaceholderFont ) + { + mImpl->mEventData->mPlaceholderFont = new FontDefaults(); + } + + mImpl->mEventData->mPlaceholderFont->mFontDescription.family = placeholderTextFontFamily; + DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str()); + mImpl->mEventData->mPlaceholderFont->familyDefined = !placeholderTextFontFamily.empty(); + + mImpl->RequestRelayout(); + } +} + +const std::string& Controller::GetPlaceholderFontFamily() const +{ + if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) ) + { + return mImpl->mEventData->mPlaceholderFont->mFontDescription.family; + } + + return EMPTY_STRING; +} + void Controller::SetDefaultFontWeight( FontWeight weight ) { if( NULL == mImpl->mFontDefaults ) @@ -623,6 +695,41 @@ FontWeight Controller::GetDefaultFontWeight() const return TextAbstraction::FontWeight::NORMAL; } +void Controller::SetPlaceholderTextFontWeight( FontWeight weight ) +{ + if( NULL != mImpl->mEventData ) + { + if( NULL == mImpl->mEventData->mPlaceholderFont ) + { + mImpl->mEventData->mPlaceholderFont = new FontDefaults(); + } + + mImpl->mEventData->mPlaceholderFont->mFontDescription.weight = weight; + mImpl->mEventData->mPlaceholderFont->weightDefined = true; + + mImpl->RequestRelayout(); + } +} + +bool Controller::IsPlaceholderTextFontWeightDefined() const +{ + if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) ) + { + return mImpl->mEventData->mPlaceholderFont->weightDefined; + } + return false; +} + +FontWeight Controller::GetPlaceholderTextFontWeight() const +{ + if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) ) + { + return mImpl->mEventData->mPlaceholderFont->mFontDescription.weight; + } + + return TextAbstraction::FontWeight::NORMAL; +} + void Controller::SetDefaultFontWidth( FontWidth width ) { if( NULL == mImpl->mFontDefaults ) @@ -654,6 +761,41 @@ FontWidth Controller::GetDefaultFontWidth() const return TextAbstraction::FontWidth::NORMAL; } +void Controller::SetPlaceholderTextFontWidth( FontWidth width ) +{ + if( NULL != mImpl->mEventData ) + { + if( NULL == mImpl->mEventData->mPlaceholderFont ) + { + mImpl->mEventData->mPlaceholderFont = new FontDefaults(); + } + + mImpl->mEventData->mPlaceholderFont->mFontDescription.width = width; + mImpl->mEventData->mPlaceholderFont->widthDefined = true; + + mImpl->RequestRelayout(); + } +} + +bool Controller::IsPlaceholderTextFontWidthDefined() const +{ + if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) ) + { + return mImpl->mEventData->mPlaceholderFont->widthDefined; + } + return false; +} + +FontWidth Controller::GetPlaceholderTextFontWidth() const +{ + if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) ) + { + return mImpl->mEventData->mPlaceholderFont->mFontDescription.width; + } + + return TextAbstraction::FontWidth::NORMAL; +} + void Controller::SetDefaultFontSlant( FontSlant slant ) { if( NULL == mImpl->mFontDefaults ) @@ -685,15 +827,69 @@ FontSlant Controller::GetDefaultFontSlant() const return TextAbstraction::FontSlant::NORMAL; } -void Controller::SetDefaultPointSize( float pointSize ) +void Controller::SetPlaceholderTextFontSlant( FontSlant slant ) +{ + if( NULL != mImpl->mEventData ) + { + if( NULL == mImpl->mEventData->mPlaceholderFont ) + { + mImpl->mEventData->mPlaceholderFont = new FontDefaults(); + } + + mImpl->mEventData->mPlaceholderFont->mFontDescription.slant = slant; + mImpl->mEventData->mPlaceholderFont->slantDefined = true; + + mImpl->RequestRelayout(); + } +} + +bool Controller::IsPlaceholderTextFontSlantDefined() const +{ + if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) ) + { + return mImpl->mEventData->mPlaceholderFont->slantDefined; + } + return false; +} + +FontSlant Controller::GetPlaceholderTextFontSlant() const +{ + if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) ) + { + return mImpl->mEventData->mPlaceholderFont->mFontDescription.slant; + } + + return TextAbstraction::FontSlant::NORMAL; +} + +void Controller::SetDefaultFontSize( float fontSize, FontSizeType type ) { if( NULL == mImpl->mFontDefaults ) { mImpl->mFontDefaults = new FontDefaults(); } - mImpl->mFontDefaults->mDefaultPointSize = pointSize; - mImpl->mFontDefaults->sizeDefined = true; + switch( type ) + { + case POINT_SIZE: + { + mImpl->mFontDefaults->mDefaultPointSize = fontSize; + mImpl->mFontDefaults->sizeDefined = true; + break; + } + case PIXEL_SIZE: + { + // Point size = Pixel size * 72.f / DPI + unsigned int horizontalDpi = 0u; + unsigned int verticalDpi = 0u; + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.GetDpi( horizontalDpi, verticalDpi ); + + mImpl->mFontDefaults->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi ); + mImpl->mFontDefaults->sizeDefined = true; + break; + } + } // Clear the font-specific data ClearFontData(); @@ -701,14 +897,117 @@ void Controller::SetDefaultPointSize( float pointSize ) mImpl->RequestRelayout(); } -float Controller::GetDefaultPointSize() const +float Controller::GetDefaultFontSize( FontSizeType type ) const { + float value = 0.0f; if( NULL != mImpl->mFontDefaults ) { - return mImpl->mFontDefaults->mDefaultPointSize; + switch( type ) + { + case POINT_SIZE: + { + value = mImpl->mFontDefaults->mDefaultPointSize; + break; + } + case PIXEL_SIZE: + { + // Pixel size = Point size * DPI / 72.f + unsigned int horizontalDpi = 0u; + unsigned int verticalDpi = 0u; + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.GetDpi( horizontalDpi, verticalDpi ); + + value = mImpl->mFontDefaults->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f; + break; + } + } + return value; + } + + return value; +} + +void Controller::SetPlaceholderTextFontSize( float fontSize, FontSizeType type ) +{ + if( NULL != mImpl->mEventData ) + { + if( NULL == mImpl->mEventData->mPlaceholderFont ) + { + mImpl->mEventData->mPlaceholderFont = new FontDefaults(); + } + + switch( type ) + { + case POINT_SIZE: + { + mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = fontSize; + mImpl->mEventData->mPlaceholderFont->sizeDefined = true; + mImpl->mEventData->mIsPlaceholderPixelSize = false; // Font size flag + break; + } + case PIXEL_SIZE: + { + // Point size = Pixel size * 72.f / DPI + unsigned int horizontalDpi = 0u; + unsigned int verticalDpi = 0u; + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.GetDpi( horizontalDpi, verticalDpi ); + + mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi ); + mImpl->mEventData->mPlaceholderFont->sizeDefined = true; + mImpl->mEventData->mIsPlaceholderPixelSize = true; // Font size flag + break; + } + } + + mImpl->RequestRelayout(); + } +} + +float Controller::GetPlaceholderTextFontSize( FontSizeType type ) const +{ + float value = 0.0f; + if( NULL != mImpl->mEventData ) + { + switch( type ) + { + case POINT_SIZE: + { + if( NULL != mImpl->mEventData->mPlaceholderFont ) + { + value = mImpl->mEventData->mPlaceholderFont->mDefaultPointSize; + } + else + { + // If the placeholder text font size is not set, then return the default font size. + value = GetDefaultFontSize( POINT_SIZE ); + } + break; + } + case PIXEL_SIZE: + { + if( NULL != mImpl->mEventData->mPlaceholderFont ) + { + // Pixel size = Point size * DPI / 72.f + unsigned int horizontalDpi = 0u; + unsigned int verticalDpi = 0u; + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); + fontClient.GetDpi( horizontalDpi, verticalDpi ); + + value = mImpl->mEventData->mPlaceholderFont->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f; + } + else + { + // If the placeholder text font size is not set, then return the default font size. + value = GetDefaultFontSize( PIXEL_SIZE ); + } + break; + } + } + return value; } - return 0.0f; + return value; } void Controller::SetDefaultColor( const Vector4& color ) @@ -1219,7 +1518,7 @@ float Controller::GetInputFontPointSize() const } // Return the default font's point size if there is no EventData. - return GetDefaultPointSize(); + return GetDefaultFontSize( Text::Controller::POINT_SIZE ); } void Controller::SetInputLineSpacing( float lineSpacing ) @@ -1370,6 +1669,36 @@ Controller::NoTextTap::Action Controller::GetNoTextLongPressAction() const return action; } +bool Controller::IsUnderlineSetByString() +{ + return mImpl->mUnderlineSetByString; +} + +void Controller::UnderlineSetByString( bool setByString ) +{ + mImpl->mUnderlineSetByString = setByString; +} + +bool Controller::IsShadowSetByString() +{ + return mImpl->mShadowSetByString; +} + +void Controller::ShadowSetByString( bool setByString ) +{ + mImpl->mShadowSetByString = setByString; +} + +bool Controller::IsFontStyleSetByString() +{ + return mImpl->mFontStyleSetByString; +} + +void Controller::FontStyleSetByString( bool setByString ) +{ + mImpl->mFontStyleSetByString = setByString; +} + // public : Queries & retrieves. Layout::Engine& Controller::GetLayoutEngine() @@ -1521,6 +1850,13 @@ float Controller::GetHeightForWidth( float width ) return layoutSize.height; } +int Controller::GetLineCount( float width ) +{ + GetHeightForWidth( width ); + int numberofLines = mImpl->mModel->GetNumberOfLines(); + return numberofLines; +} + const ModelInterface* const Controller::GetTextModel() const { return mImpl->mModel.Get(); @@ -1550,6 +1886,103 @@ bool Controller::GetTextScrollInfo( float& scrollPosition, float& controlHeight, return isScrolled; } +void Controller::SetHiddenInputOption(const Property::Map& options ) +{ + if( NULL == mImpl->mHiddenInput ) + { + mImpl->mHiddenInput = new HiddenText( this ); + } + mImpl->mHiddenInput->SetProperties(options); +} + +void Controller::GetHiddenInputOption(Property::Map& options ) +{ + if( NULL != mImpl->mHiddenInput ) + { + mImpl->mHiddenInput->GetProperties(options); + } +} + +void Controller::SetPlaceholderProperty( const Property::Map& map ) +{ + const Property::Map::SizeType count = map.Count(); + + for( Property::Map::SizeType position = 0; position < count; ++position ) + { + KeyValuePair keyValue = map.GetKeyValue( position ); + Property::Key& key = keyValue.first; + Property::Value& value = keyValue.second; + + if( key == PLACEHOLDER_TEXT ) + { + std::string text = ""; + value.Get( text ); + SetPlaceholderText( text ); + } + else if( key == PLACEHOLDER_COLOR ) + { + Vector4 textColor; + value.Get( textColor ); + if( GetPlaceholderTextColor() != textColor ) + { + SetPlaceholderTextColor( textColor ); + } + } + else if( key == PLACEHOLDER_FONT_FAMILY ) + { + std::string fontFamily = ""; + value.Get( fontFamily ); + SetPlaceholderFontFamily( fontFamily ); + } + else if( key == PLACEHOLDER_FONT_STYLE ) + { + SetFontStyleProperty( this, value, Text::FontStyle::PLACEHOLDER ); + } + else if( key == PLACEHOLDER_POINT_SIZE ) + { + float pointSize; + value.Get( pointSize ); + if( !Equals( GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE ), pointSize ) ) + { + SetPlaceholderTextFontSize( pointSize, Text::Controller::POINT_SIZE ); + } + } + else if( key == PLACEHOLDER_PIXEL_SIZE ) + { + float pixelSize; + value.Get( pixelSize ); + if( !Equals( GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) ) + { + SetPlaceholderTextFontSize( pixelSize, Text::Controller::PIXEL_SIZE ); + } + } + } +} + +void Controller::GetPlaceholderProperty( Property::Map& map ) +{ + if( NULL != mImpl->mEventData ) + { + map[ PLACEHOLDER_TEXT ] = mImpl->mEventData->mPlaceholderText; + map[ PLACEHOLDER_COLOR ] = mImpl->mEventData->mPlaceholderTextColor; + map[ PLACEHOLDER_FONT_FAMILY ] = GetPlaceholderFontFamily(); + + Property::Value fontStyleMapGet; + GetFontStyleProperty( this, fontStyleMapGet, Text::FontStyle::PLACEHOLDER ); + map[ PLACEHOLDER_FONT_STYLE ] = fontStyleMapGet; + + // Choose font size : POINT_SIZE or PIXEL_SIZE + if( !mImpl->mEventData->mIsPlaceholderPixelSize ) + { + map[ PLACEHOLDER_POINT_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE ); + } + else + { + map[ PLACEHOLDER_PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE ); + } + } +} + // public : Relayout. Controller::UpdateTextType Controller::Relayout( const Size& size ) @@ -1751,7 +2184,8 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) { DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyEvent" ); - bool textChanged( false ); + bool textChanged = false; + bool relayoutNeeded = false; if( ( NULL != mImpl->mEventData ) && ( keyEvent.state == KeyEvent::Down ) ) @@ -1771,6 +2205,9 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) { // Escape key is a special case which causes focus loss KeyboardFocusLostEvent(); + + // Will request for relayout. + relayoutNeeded = true; } else if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode ) || ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode ) || @@ -1803,10 +2240,16 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) Event event( Event::CURSOR_KEY_EVENT ); event.p1.mInt = keyCode; mImpl->mEventData->mEventQueue.push_back( event ); + + // Will request for relayout. + relayoutNeeded = true; } else if( Dali::DALI_KEY_BACKSPACE == keyCode ) { textChanged = BackspaceKeyEvent(); + + // Will request for relayout. + relayoutNeeded = true; } else if( IsKey( keyEvent, Dali::DALI_KEY_POWER ) || IsKey( keyEvent, Dali::DALI_KEY_MENU ) || @@ -1815,6 +2258,9 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) // Power key/Menu/Home key behaviour does not allow edit mode to resume. mImpl->ChangeState( EventData::INACTIVE ); + // Will request for relayout. + relayoutNeeded = true; + // This branch avoids calling the InsertText() method of the 'else' branch which can delete selected text. } else if( Dali::DALI_KEY_SHIFT_LEFT == keyCode ) @@ -1824,6 +2270,11 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) // Do nothing. } + else if( ( Dali::DALI_KEY_VOLUME_UP == keyCode ) || ( Dali::DALI_KEY_VOLUME_DOWN == keyCode ) ) + { + // This branch avoids calling the InsertText() method of the 'else' branch which can delete selected text. + // Do nothing. + } else { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() ); @@ -1833,20 +2284,31 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) InsertText( keyString, COMMIT ); textChanged = true; + + // Will request for relayout. + relayoutNeeded = true; } if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) && ( mImpl->mEventData->mState != EventData::INACTIVE ) && ( !isNullKey ) && - ( Dali::DALI_KEY_SHIFT_LEFT != keyCode ) ) + ( Dali::DALI_KEY_SHIFT_LEFT != keyCode ) && + ( Dali::DALI_KEY_VOLUME_UP != keyCode ) && + ( Dali::DALI_KEY_VOLUME_DOWN != keyCode ) ) { // Should not change the state if the key is the shift send by the imf manager. // Otherwise, when the state is SELECTING the text controller can't send the right // surrounding info to the imf. mImpl->ChangeState( EventData::EDITING ); + + // Will request for relayout. + relayoutNeeded = true; } - mImpl->RequestRelayout(); + if( relayoutNeeded ) + { + mImpl->RequestRelayout(); + } } if( textChanged && @@ -2054,6 +2516,13 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons retrieveCursor = true; break; } + case ImfManager::PRIVATECOMMAND: + { + // PRIVATECOMMAND event is just for getting the private command message + retrieveText = true; + retrieveCursor = true; + break; + } case ImfManager::VOID: { // do nothing @@ -2272,6 +2741,15 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt } } +void Controller::DisplayTimeExpired() +{ + mImpl->mEventData->mUpdateCursorPosition = true; + // Apply modifications to the model + mImpl->mOperationsPending = ALL_OPERATIONS; + + mImpl->RequestRelayout(); +} + // private : Update. void Controller::InsertText( const std::string& text, Controller::InsertType type ) @@ -2469,8 +2947,18 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ } // Mark the first paragraph to be updated. - mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex ); - mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd += maxSizeOfNewText; + if( Layout::Engine::SINGLE_LINE_BOX == mImpl->mLayoutEngine.GetLayout() ) + { + mImpl->mTextUpdateInfo.mCharacterIndex = 0; + mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters; + mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = numberOfCharactersInModel + maxSizeOfNewText; + mImpl->mTextUpdateInfo.mClearAll = true; + } + else + { + mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex ); + mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd += maxSizeOfNewText; + } // Update the cursor index. cursorIndex += maxSizeOfNewText; @@ -2551,12 +3039,12 @@ bool Controller::RemoveText( int cursorOffset, Vector& currentText = mImpl->mModel->mLogicalModel->mText; CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition; - CharacterIndex cursorIndex = oldCursorIndex; + CharacterIndex cursorIndex = 0; // Validate the cursor position & number of characters - if( static_cast< CharacterIndex >( std::abs( cursorOffset ) ) <= cursorIndex ) + if( ( static_cast< int >( mImpl->mEventData->mPrimaryCursorPosition ) + cursorOffset ) >= 0 ) { - cursorIndex = oldCursorIndex + cursorOffset; + cursorIndex = mImpl->mEventData->mPrimaryCursorPosition + cursorOffset; } if( ( cursorIndex + numberOfCharacters ) > currentText.Count() ) @@ -2568,8 +3056,18 @@ bool Controller::RemoveText( int cursorOffset, ( ( cursorIndex + numberOfCharacters ) <= mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) ) { // Mark the paragraphs to be updated. - mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex ); - mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove += numberOfCharacters; + if( Layout::Engine::SINGLE_LINE_BOX == mImpl->mLayoutEngine.GetLayout() ) + { + mImpl->mTextUpdateInfo.mCharacterIndex = 0; + mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters; + mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters - numberOfCharacters; + mImpl->mTextUpdateInfo.mClearAll = true; + } + else + { + mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex ); + mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove += numberOfCharacters; + } // Update the input style and remove the text's style before removing the text. @@ -3055,17 +3553,27 @@ void Controller::ShowPlaceholderText() const char* text( NULL ); size_t size( 0 ); - // TODO - Switch placeholder text styles when changing state - if( ( EventData::INACTIVE != mImpl->mEventData->mState ) && - ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) ) + if( !mImpl->mEventData->mPlaceholderTextActive.empty() || !mImpl->mEventData->mPlaceholderTextInactive.empty() ) { - text = mImpl->mEventData->mPlaceholderTextActive.c_str(); - size = mImpl->mEventData->mPlaceholderTextActive.size(); + if( ( EventData::INACTIVE != mImpl->mEventData->mState ) && + ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) ) + { + text = mImpl->mEventData->mPlaceholderTextActive.c_str(); + size = mImpl->mEventData->mPlaceholderTextActive.size(); + } + else + { + text = mImpl->mEventData->mPlaceholderTextInactive.c_str(); + size = mImpl->mEventData->mPlaceholderTextInactive.size(); + } } else { - text = mImpl->mEventData->mPlaceholderTextInactive.c_str(); - size = mImpl->mEventData->mPlaceholderTextInactive.size(); + if( 0u != mImpl->mEventData->mPlaceholderText.c_str() ) + { + text = mImpl->mEventData->mPlaceholderText.c_str(); + size = mImpl->mEventData->mPlaceholderText.size(); + } } mImpl->mTextUpdateInfo.mCharacterIndex = 0u;