EventData::EventData( DecoratorPtr decorator )
: mDecorator( decorator ),
mImfManager(),
+ mPlaceholderFont( NULL ),
mPlaceholderText(),
mPlaceholderTextActive(),
mPlaceholderTextInactive(),
mScrollAfterDelete( false ),
mAllTextSelected( false ),
mUpdateInputStyle( false ),
- mPasswordInput( false )
+ mPasswordInput( false ),
+ mIsPlaceholderPixelSize( false )
{
mImfManager = ImfManager::Get();
}
// Get the default font's description.
TextAbstraction::FontDescription defaultFontDescription;
TextAbstraction::PointSize26Dot6 defaultPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
- if( NULL != mFontDefaults )
+
+ if( IsShowingPlaceholderText() && ( NULL != mEventData->mPlaceholderFont ) )
{
+ // If the placeholder font is set specifically, only placeholder font is changed.
+ defaultFontDescription = mEventData->mPlaceholderFont->mFontDescription;
+ if( mEventData->mPlaceholderFont->sizeDefined )
+ {
+ defaultPointSize = mEventData->mPlaceholderFont->mDefaultPointSize * 64u;
+ }
+ }
+ else if( NULL != mFontDefaults )
+ {
+ // Set the normal font and the placeholder font.
defaultFontDescription = mFontDefaults->mFontDescription;
defaultPointSize = mFontDefaults->mDefaultPointSize * 64u;
}
mModel->mLogicalModel->UpdateTextStyleRuns( startOfSelectedText, -static_cast<int>( lengthOfSelectedText ) );
// Mark the paragraphs to be updated.
- mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
- mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+ if( Layout::Engine::SINGLE_LINE_BOX == mLayoutEngine.GetLayout() )
+ {
+ mTextUpdateInfo.mCharacterIndex = 0;
+ mTextUpdateInfo.mNumberOfCharactersToRemove = mTextUpdateInfo.mPreviousNumberOfCharacters;
+ mTextUpdateInfo.mNumberOfCharactersToAdd = mTextUpdateInfo.mPreviousNumberOfCharacters - lengthOfSelectedText;
+ mTextUpdateInfo.mClearAll = true;
+ }
+ else
+ {
+ mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+ mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+ }
// Delete text between handles
Vector<Character>::Iterator first = utf32Characters.Begin() + startOfSelectedText;
return;
}
- Text::GetCursorPosition( mModel->mVisualModel,
- mModel->mLogicalModel,
- mMetrics,
- logical,
+ const bool isMultiLine = ( Layout::Engine::MULTI_LINE_BOX == mLayoutEngine.GetLayout() );
+ GetCursorPositionParameters parameters;
+ parameters.visualModel = mModel->mVisualModel;
+ parameters.logicalModel = mModel->mLogicalModel;
+ parameters.metrics = mMetrics;
+ parameters.logical = logical;
+ parameters.isMultiline = isMultiLine;
+
+ Text::GetCursorPosition( parameters,
cursorInfo );
- if( Layout::Engine::MULTI_LINE_BOX == mLayoutEngine.GetLayout() )
+ if( isMultiLine )
{
// If the text is editable and multi-line, the cursor position after a white space shouldn't exceed the boundaries of the text control.
const Vector2 cursorPosition = cursorInfo.primaryPosition + mModel->mScrollPosition;
+ mEventData->mDecorator->SetGlyphOffset( PRIMARY_CURSOR, cursorInfo.glyphOffset );
+
// Sets the cursor position.
mEventData->mDecorator->SetPosition( PRIMARY_CURSOR,
cursorPosition.x,
mModel->mScrollPosition.x = mModel->mVisualModel->mControlSize.width - positionEndX;
}
- if( decoratorPositionBeginY < 0.f )
- {
- mModel->mScrollPosition.y = -position.y;
- }
- else if( decoratorPositionEndY > mModel->mVisualModel->mControlSize.height )
+ if( Layout::Engine::MULTI_LINE_BOX == mLayoutEngine.GetLayout() )
{
- mModel->mScrollPosition.y = mModel->mVisualModel->mControlSize.height - positionEndY;
+ if( decoratorPositionBeginY < 0.f )
+ {
+ mModel->mScrollPosition.y = -position.y;
+ }
+ else if( decoratorPositionEndY > mModel->mVisualModel->mControlSize.height )
+ {
+ mModel->mScrollPosition.y = mModel->mVisualModel->mControlSize.height - positionEndY;
+ }
}
}
// Get the current cursor position in decorator coords.
const Vector2& currentCursorPosition = mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
+ const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( mEventData->mPrimaryCursorPosition );
+
+
+
// Calculate the offset to match the cursor position before the character was deleted.
mModel->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x;
- mModel->mScrollPosition.y = currentCursorPosition.y - cursorInfo.lineOffset;
+
+ //If text control has more than two lines and current line index is not last, calculate scrollpositionY
+ if( mModel->mVisualModel->mLines.Count() > 1u && lineIndex != mModel->mVisualModel->mLines.Count() -1u )
+ {
+ const float currentCursorGlyphOffset = mEventData->mDecorator->GetGlyphOffset( PRIMARY_CURSOR );
+ mModel->mScrollPosition.y = currentCursorPosition.y - cursorInfo.lineOffset - currentCursorGlyphOffset;
+ }
+
ClampHorizontalScroll( mModel->mVisualModel->GetLayoutSize() );
ClampVerticalScroll( mModel->mVisualModel->GetLayoutSize() );