summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1b0a5f5)
* When editing with predictive text enabled, the imf manager removes
the current pre-edited text and inserts the new string.
The new string can be longer if text is being added,
or smaller if text is being removed.
The text needs to be scrolled to the cursor position if text is smaller.
* Similarly, the text-controller can remove a group of characters when a
ImfManager::DELETESURROUNDING event arrives. The text also needs to
be scrolled to the cursor position.
* If text is not added at the end of the string, the text must not be scrolled
unless the cursor becomes not visible.
Change-Id: I6ed4b9ea122cd0b8fac4111c732625bf636eb52d
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
GetCursorPosition( mEventData->mPrimaryCursorPosition,
cursorInfo );
GetCursorPosition( mEventData->mPrimaryCursorPosition,
cursorInfo );
- if( mEventData->mScrollAfterUpdatePosition )
+ // Scroll first the text after delete ...
+ if( mEventData->mScrollAfterDelete )
- ScrollToMakePositionVisible( cursorInfo.primaryPosition );
- mEventData->mScrollAfterUpdatePosition = false;
+ ScrollTextToMatchCursor( cursorInfo );
- else if( mEventData->mScrollAfterDelete )
+
+ // ... then, text can be scrolled to make the cursor visible.
+ if( mEventData->mScrollAfterUpdatePosition )
- ScrollTextToMatchCursor( cursorInfo );
- mEventData->mScrollAfterDelete = false;
+ ScrollToMakePositionVisible( cursorInfo.primaryPosition );
+ mEventData->mScrollAfterUpdatePosition = false;
+ mEventData->mScrollAfterDelete = false;
UpdateCursorPosition( cursorInfo );
UpdateCursorPosition( cursorInfo );
mEventData->mUpdateLeftSelectionPosition = true;
mEventData->mUpdateRightSelectionPosition = true;
mEventData->mUpdateLeftSelectionPosition = true;
mEventData->mUpdateRightSelectionPosition = true;
+ mEventData->mUpdateCursorPosition = false;
mEventData->mScrollAfterUpdatePosition = ( mEventData->mLeftSelectionPosition != mEventData->mRightSelectionPosition );
}
mEventData->mScrollAfterUpdatePosition = ( mEventData->mLeftSelectionPosition != mEventData->mRightSelectionPosition );
}
// Scroll after delete.
mEventData->mPrimaryCursorPosition = handlesCrossed ? mEventData->mRightSelectionPosition : mEventData->mLeftSelectionPosition;
// Scroll after delete.
mEventData->mPrimaryCursorPosition = handlesCrossed ? mEventData->mRightSelectionPosition : mEventData->mLeftSelectionPosition;
- mEventData->mScrollAfterDelete = true;
- // Udpade the cursor position and the decorator.
- // Scroll after the position is updated if is not scrolling after delete.
- mEventData->mUpdateCursorPosition = true;
- mEventData->mScrollAfterUpdatePosition = !mEventData->mScrollAfterDelete;
mEventData->mDecoratorUpdated = true;
}
}
mEventData->mDecoratorUpdated = true;
}
}
void Controller::Impl::ScrollToMakePositionVisible( const Vector2& position )
{
void Controller::Impl::ScrollToMakePositionVisible( const Vector2& position )
{
+ const float cursorWidth = mEventData->mDecorator ? mEventData->mDecorator->GetCursorWidth() : 0.f;
+
// position is in actor's coords.
// position is in actor's coords.
- const float positionEnd = position.x + ( mEventData->mDecorator ? mEventData->mDecorator->GetCursorWidth() : 0.f );
+ const float positionEnd = position.x + cursorWidth;
// Transform the position to decorator coords.
const float alignment = IsShowingRealText() ? mAlignmentOffset.x : 0.f;
// Transform the position to decorator coords.
const float alignment = IsShowingRealText() ? mAlignmentOffset.x : 0.f;
mEventData->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x - mAlignmentOffset.x;
ClampHorizontalScroll( mVisualModel->GetLayoutSize() );
mEventData->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x - mAlignmentOffset.x;
ClampHorizontalScroll( mVisualModel->GetLayoutSize() );
+
+ // Makes the new cursor position visible if needed.
+ ScrollToMakePositionVisible( cursorInfo.primaryPosition );
}
void Controller::Impl::RequestRelayout()
}
void Controller::Impl::RequestRelayout()
+ /**
+ * @brief Retrieves the selected text. It removes the text if the @p deleteAfterRetrieval parameter is @e true.
+ *
+ * @param[out] selectedText The selected text encoded in utf8.
+ * @param[in] deleteAfterRetrieval Whether the text should be deleted after retrieval.
+ */
void RetrieveSelection( std::string& selectedText, bool deleteAfterRetrieval );
void ShowClipboard();
void RetrieveSelection( std::string& selectedText, bool deleteAfterRetrieval );
void ShowClipboard();
// Cursor position retreat
oldCursorIndex = cursorIndex;
// Cursor position retreat
oldCursorIndex = cursorIndex;
+ mImpl->mEventData->mScrollAfterDelete = true;
+
DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters );
removed = true;
}
DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters );
removed = true;
}
// Apply modifications to the model; TODO - Optimize this
mImpl->mOperationsPending = ALL_OPERATIONS;
// Apply modifications to the model; TODO - Optimize this
mImpl->mOperationsPending = ALL_OPERATIONS;
-
- // Queue a cursor reposition event; this must wait until after DoRelayout()
- if( EventData::IsEditingState( mImpl->mEventData->mState ) )
- {
- mImpl->mEventData->mUpdateCursorPosition = true;
- mImpl->mEventData->mScrollAfterUpdatePosition = true;
- }
}
void Controller::TextDeletedEvent()
}
void Controller::TextDeletedEvent()
// Apply modifications to the model; TODO - Optimize this
mImpl->mOperationsPending = ALL_OPERATIONS;
// Apply modifications to the model; TODO - Optimize this
mImpl->mOperationsPending = ALL_OPERATIONS;
-
- // Queue a cursor reposition event; this must wait until after DoRelayout()
- mImpl->mEventData->mUpdateCursorPosition = true;
- if( 0u != mImpl->mLogicalModel->mText.Count() )
- {
- mImpl->mEventData->mScrollAfterDelete = true;
- }
}
bool Controller::DoRelayout( const Size& size,
}
bool Controller::DoRelayout( const Size& size,
// TODO: At the moment the underline runs are only for pre-edit.
mImpl->mVisualModel->mUnderlineRuns.Clear();
// TODO: At the moment the underline runs are only for pre-edit.
mImpl->mVisualModel->mUnderlineRuns.Clear();
- Vector<Character> utf32Characters;
- Length characterCount( 0u );
+ // Keep the current number of characters.
+ const Length currentNumberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mLogicalModel->mText.Count() : 0u;
- // Remove the previous IMF pre-edit (predicitive text)
- if( mImpl->mEventData->mPreEditFlag &&
- ( 0u != mImpl->mEventData->mPreEditLength ) )
+ // Remove the previous IMF pre-edit.
+ if( mImpl->mEventData->mPreEditFlag && ( 0u != mImpl->mEventData->mPreEditLength ) )
- const CharacterIndex offset = mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition;
-
- removedPrevious = RemoveText( -static_cast<int>( offset ),
+ removedPrevious = RemoveText( -static_cast<int>( mImpl->mEventData->mPrimaryCursorPosition - mImpl->mEventData->mPreEditStartPosition ),
mImpl->mEventData->mPreEditLength,
DONT_UPDATE_INPUT_STYLE );
mImpl->mEventData->mPreEditLength,
DONT_UPDATE_INPUT_STYLE );
- // Remove the previous Selection
+ // Remove the previous Selection.
removedPrevious = RemoveSelectedText();
}
removedPrevious = RemoveSelectedText();
}
+ Vector<Character> utf32Characters;
+ Length characterCount = 0u;
+
if( !text.empty() )
{
// Convert text into UTF-32
if( !text.empty() )
{
// Convert text into UTF-32
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
}
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
}
+ const Length numberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mLogicalModel->mText.Count() : 0u;
+
if( ( 0u == mImpl->mLogicalModel->mText.Count() ) &&
mImpl->IsPlaceholderAvailable() )
{
if( ( 0u == mImpl->mLogicalModel->mText.Count() ) &&
mImpl->IsPlaceholderAvailable() )
{
{
// Queue an inserted event
mImpl->QueueModifyEvent( ModifyEvent::TEXT_INSERTED );
{
// Queue an inserted event
mImpl->QueueModifyEvent( ModifyEvent::TEXT_INSERTED );
+
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ if( numberOfCharacters < currentNumberOfCharacters )
+ {
+ mImpl->mEventData->mScrollAfterDelete = true;
+ }
+ else
+ {
+ mImpl->mEventData->mScrollAfterUpdatePosition = true;
+ }
else
{
ShowPlaceholderText();
else
{
ShowPlaceholderText();
- mImpl->mEventData->mUpdateCursorPosition = true;
+
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ mImpl->mEventData->mScrollAfterDelete = true;
+
mImpl->RequestRelayout();
mImpl->mControlInterface.TextChanged();
break;
mImpl->RequestRelayout();
mImpl->mControlInterface.TextChanged();
break;
else
{
ShowPlaceholderText();
else
{
ShowPlaceholderText();
- mImpl->mEventData->mUpdateCursorPosition = true;
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ mImpl->mEventData->mScrollAfterDelete = true;
}
requestRelayout = true;
break;
}
requestRelayout = true;
break;
else
{
ShowPlaceholderText();
else
{
ShowPlaceholderText();
- mImpl->mEventData->mUpdateCursorPosition = true;
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ mImpl->mEventData->mScrollAfterDelete = true;