EventData::EventData(DecoratorPtr decorator, InputMethodContext& inputMethodContext)
: mDecorator(decorator),
mInputMethodContext(inputMethodContext),
- mPlaceholderFont(NULL),
+ mPlaceholderFont(nullptr),
mPlaceholderTextActive(),
mPlaceholderTextInactive(),
mPlaceholderTextColor(0.8f, 0.8f, 0.8f, 0.8f), // This color has been published in the Public API (placeholder-properties.h).
mModel->mVisualModel->mCharactersPerGlyph.Erase(charactersPerGlyphBuffer + mTextUpdateInfo.mStartGlyphIndex,
charactersPerGlyphBuffer + endGlyphIndexPlusOne);
- // Clear the positions buffer.
- Vector2* positionsBuffer = mModel->mVisualModel->mGlyphPositions.Begin();
- mModel->mVisualModel->mGlyphPositions.Erase(positionsBuffer + mTextUpdateInfo.mStartGlyphIndex,
- positionsBuffer + endGlyphIndexPlusOne);
+ // Should pass if mGlyphPositions has already been cleared in Controller::Relayouter::Relayout
+ if(0u != mModel->mVisualModel->mGlyphPositions.Count())
+ {
+ // Clear the positions buffer.
+ Vector2* positionsBuffer = mModel->mVisualModel->mGlyphPositions.Begin();
+ mModel->mVisualModel->mGlyphPositions.Erase(positionsBuffer + mTextUpdateInfo.mStartGlyphIndex,
+ positionsBuffer + endGlyphIndexPlusOne);
+ }
}
if(NO_OPERATION != (LAYOUT & operations))
startIndex,
requestedNumberOfCharacters,
bidirectionalInfo,
- mModel->mMatchSystemLanguageDirection,
+ (mModel->mMatchLayoutDirection != DevelText::MatchLayoutDirection::CONTENTS),
mLayoutDirection);
if(0u != bidirectionalInfo.Count())
if(mEventData->mSelectionEnabled && (pStart || pEnd))
{
- uint32_t length = static_cast<uint32_t>(mModel->mLogicalModel->mText.Count());
+ uint32_t length = static_cast<uint32_t>(mModel->mLogicalModel->mText.Count());
+ uint32_t oldStart = mEventData->mLeftSelectionPosition;
+ uint32_t oldEnd = mEventData->mRightSelectionPosition;
if(pStart)
{
mEventData->mUpdateLeftSelectionPosition = true;
mEventData->mUpdateRightSelectionPosition = true;
}
+
+ if(mSelectableControlInterface != nullptr)
+ {
+ mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition);
+ }
}
}
return mEventData->mPrimaryCursorPosition;
}
-bool Controller::Impl::SetPrimaryCursorPosition(CharacterIndex index)
+bool Controller::Impl::SetPrimaryCursorPosition(CharacterIndex index, bool focused)
{
if(nullptr == mEventData)
{
return false;
}
- if(mEventData->mPrimaryCursorPosition == index)
+ if(mEventData->mPrimaryCursorPosition == index && mEventData->mState != EventData::SELECTING)
{
// Nothing for same cursor position.
return false;
}
uint32_t length = static_cast<uint32_t>(mModel->mLogicalModel->mText.Count());
+ uint32_t oldCursorPos = mEventData->mPrimaryCursorPosition;
mEventData->mPrimaryCursorPosition = std::min(index, length);
- ChangeState(EventData::EDITING);
- mEventData->mLeftSelectionPosition = mEventData->mRightSelectionPosition = mEventData->mPrimaryCursorPosition;
- mEventData->mUpdateCursorPosition = true;
- ScrollTextToMatchCursor();
+ // If there is no focus, only the value is updated.
+ if(focused)
+ {
+ bool wasInSelectingState = mEventData->mState == EventData::SELECTING;
+ uint32_t oldStart = mEventData->mLeftSelectionPosition;
+ uint32_t oldEnd = mEventData->mRightSelectionPosition;
+ ChangeState(EventData::EDITING);
+ mEventData->mLeftSelectionPosition = mEventData->mRightSelectionPosition = mEventData->mPrimaryCursorPosition;
+ mEventData->mUpdateCursorPosition = true;
+
+ if(mSelectableControlInterface != nullptr && wasInSelectingState)
+ {
+ mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition);
+ }
+
+ ScrollTextToMatchCursor();
+ }
+
+ if(nullptr != mEditableControlInterface)
+ {
+ mEditableControlInterface->CursorPositionChanged(oldCursorPos, mEventData->mPrimaryCursorPosition);
+ }
+
return true;
}
void Controller::Impl::SetSelection(int start, int end)
{
+ uint32_t oldStart = mEventData->mLeftSelectionPosition;
+ uint32_t oldEnd = mEventData->mRightSelectionPosition;
+
mEventData->mLeftSelectionPosition = start;
mEventData->mRightSelectionPosition = end;
mEventData->mUpdateCursorPosition = true;
+
+ if(mSelectableControlInterface != nullptr)
+ {
+ mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, start, end);
+ }
}
std::pair<int, int> Controller::Impl::GetSelectionIndexes() const
cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
bool isRTL = false;
- if(mModel->mMatchSystemLanguageDirection)
+ if(mModel->mMatchLayoutDirection != DevelText::MatchLayoutDirection::CONTENTS)
{
isRTL = mLayoutDirection == LayoutDirection::RIGHT_TO_LEFT;
}