/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
const float MAX_FLOAT = std::numeric_limits<float>::max();
const float MIN_FLOAT = std::numeric_limits<float>::min();
const Dali::Toolkit::Text::CharacterDirection LTR = false; ///< Left To Right direction
+const uint32_t STAR = 0x2A;
} // namespace
mScrollAfterUpdatePosition( false ),
mScrollAfterDelete( false ),
mAllTextSelected( false ),
- mUpdateInputStyle( false )
+ mUpdateInputStyle( false ),
+ mPasswordInput( false )
{
mImfManager = ImfManager::Get();
}
return false;
}
- Vector<Character>& utf32Characters = mModel->mLogicalModel->mText;
+ Vector<Character> utf32CharactersStar;
+ const Length characterCount = mModel->mLogicalModel->mText.Count();
+ const bool isPasswordInput = ( mEventData != NULL && mEventData->mPasswordInput &&
+ !mEventData->mIsShowingPlaceholderText && characterCount > 0 );
+
+ if (isPasswordInput)
+ {
+ utf32CharactersStar.Resize( characterCount );
+
+ uint32_t* begin = utf32CharactersStar.Begin();
+ uint32_t* end = begin + characterCount;
+ while ( begin < end )
+ {
+ *begin++ = STAR;
+ }
+ }
+ Vector<Character>& utf32Characters = isPasswordInput ? utf32CharactersStar : mModel->mLogicalModel->mText;
const Length numberOfCharacters = utf32Characters.Count();
// Index to the first character of the first paragraph to be updated.
}
const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( characterIndex );
+ const LineIndex previousLineIndex = ( lineIndex > 0 ? lineIndex - 1u : lineIndex );
- if( lineIndex > 0u )
- {
- // Retrieve the cursor position info.
- CursorInfo cursorInfo;
- GetCursorPosition( mEventData->mPrimaryCursorPosition,
- cursorInfo );
+ // Retrieve the cursor position info.
+ CursorInfo cursorInfo;
+ GetCursorPosition( mEventData->mPrimaryCursorPosition,
+ cursorInfo );
- // Get the line above.
- const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + ( lineIndex - 1u ) );
+ // Get the line above.
+ const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + previousLineIndex );
- // Get the next hit 'y' point.
- const float hitPointY = cursorInfo.lineOffset - 0.5f * ( line.ascender - line.descender );
+ // Get the next hit 'y' point.
+ const float hitPointY = cursorInfo.lineOffset - 0.5f * ( line.ascender - line.descender );
- // Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index.
- mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
- mModel->mLogicalModel,
- mMetrics,
- mEventData->mCursorHookPositionX,
- hitPointY );
- }
+ // Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index.
+ mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+ mModel->mLogicalModel,
+ mMetrics,
+ mEventData->mCursorHookPositionX,
+ hitPointY );
}
else if( Dali::DALI_KEY_CURSOR_DOWN == keyCode )
{
// Whether to retrieve the next line.
if( index == lastGlyphOfLine )
{
- // Retrieve the next line.
- ++lineRun;
-
- // Get the last glyph of the new line.
- lastGlyphOfLine = lineRun->glyphRun.glyphIndex + lineRun->glyphRun.numberOfGlyphs - 1u;
-
++lineIndex;
if( lineIndex < firstLineIndex + numberOfLines )
{
+ // Retrieve the next line.
+ ++lineRun;
+
+ // Get the last glyph of the new line.
+ lastGlyphOfLine = lineRun->glyphRun.glyphIndex + lineRun->glyphRun.numberOfGlyphs - 1u;
+
// Keep the offset and height of the current selection box.
const float currentLineOffset = selectionBoxInfo->lineOffset;
const float currentLineHeight = selectionBoxInfo->lineHeight;
mEventData->mUpdateRightSelectionPosition = true;
mEventData->mUpdateHighlightBox = true;
+ // It may happen an IMF commit event arrives before the selection event
+ // if the IMF manager is in pre-edit state. The commit event will set the
+ // mEventData->mUpdateCursorPosition flag to true. If it's not set back
+ // to false, the highlight box won't be updated.
+ mEventData->mUpdateCursorPosition = false;
+
mEventData->mScrollAfterUpdatePosition = ( mEventData->mLeftSelectionPosition != mEventData->mRightSelectionPosition );
}
else
const Script script = mModel->mLogicalModel->GetScript( index );
if( HasLigatureMustBreak( script ) )
{
- // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ﻻ, ...
+ // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ﻻ, ...
numberOfCharacters = 1u;
}
}
void Controller::Impl::ClampHorizontalScroll( const Vector2& layoutSize )
{
- // Clamp between -space & 0.
+ // Clamp between -space & -alignment offset.
if( layoutSize.width > mModel->mVisualModel->mControlSize.width )
{
- const float space = ( layoutSize.width - mModel->mVisualModel->mControlSize.width );
+ const float space = ( layoutSize.width - mModel->mVisualModel->mControlSize.width ) + mModel->mAlignmentOffset;
mModel->mScrollPosition.x = ( mModel->mScrollPosition.x < -space ) ? -space : mModel->mScrollPosition.x;
- mModel->mScrollPosition.x = ( mModel->mScrollPosition.x > 0.f ) ? 0.f : mModel->mScrollPosition.x;
+ mModel->mScrollPosition.x = ( mModel->mScrollPosition.x > -mModel->mAlignmentOffset ) ? -mModel->mAlignmentOffset : mModel->mScrollPosition.x;
mEventData->mDecoratorUpdated = true;
}