/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
#include <dali-toolkit/internal/text/character-set-conversion.h>
#include <dali-toolkit/internal/text/markup-processor.h>
#include <dali-toolkit/internal/text/text-controller-impl.h>
+#include <dali-toolkit/internal/text/text-controller-placeholder-handler.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
namespace
ResetText(controller);
// Remove the style.
- controller.ClearStyleData();
+ impl.ClearStyleData();
CharacterIndex lastCursorIndex = 0u;
(EventData::EDITING_WITH_GRAB_HANDLE == eventData->mState) ||
(EventData::EDITING_WITH_PASTE_POPUP == eventData->mState))
{
+ if((impl.mSelectableControlInterface != nullptr) && (EventData::SELECTING == eventData->mState))
+ {
+ impl.mSelectableControlInterface->SelectionChanged(eventData->mLeftSelectionPosition, eventData->mRightSelectionPosition, eventData->mPrimaryCursorPosition, eventData->mPrimaryCursorPosition);
+ }
+
impl.ChangeState(EventData::EDITING);
}
}
MarkupProcessData markupProcessData(logicalModel->mColorRuns,
logicalModel->mFontDescriptionRuns,
logicalModel->mEmbeddedItems,
- logicalModel->mAnchors);
+ logicalModel->mAnchors,
+ logicalModel->mUnderlinedCharacterRuns,
+ logicalModel->mBackgroundColorRuns,
+ logicalModel->mStrikethroughCharacterRuns,
+ logicalModel->mBoundedParagraphRuns);
Length textSize = 0u;
const uint8_t* utf8 = NULL;
}
else
{
- controller.ShowPlaceholderText();
+ PlaceholderHandler::ShowPlaceholderText(impl);
}
+ unsigned int oldCursorPos = (nullptr != eventData ? eventData->mPrimaryCursorPosition : 0);
+
// Resets the cursor position.
controller.ResetCursorPosition(lastCursorIndex);
// Scrolls the text to make the cursor visible.
- controller.ResetScrollPosition();
+ impl.ResetScrollPosition();
impl.RequestRelayout();
// Do this last since it provides callbacks into application code.
if(NULL != impl.mEditableControlInterface)
{
+ impl.mEditableControlInterface->CursorPositionChanged(oldCursorPos, lastCursorIndex);
impl.mEditableControlInterface->TextChanged(true);
}
}
return;
}
- bool removedPrevious = false;
- bool removedSelected = false;
- bool maxLengthReached = false;
+ bool removedPrevious = false;
+ bool removedSelected = false;
+ bool maxLengthReached = false;
+ unsigned int oldCursorPos = eventData->mPrimaryCursorPosition;
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n", &controller, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"), eventData->mPrimaryCursorPosition, eventData->mPreEditFlag, eventData->mPreEditStartPosition, eventData->mPreEditLength);
const Length numberOfCharactersInModel = logicalModel->mText.Count();
// Restrict new text to fit within Maximum characters setting.
- Length maxSizeOfNewText = std::min((impl.mMaximumNumberOfCharacters - numberOfCharactersInModel), characterCount);
+ Length temp_length = (impl.mMaximumNumberOfCharacters > numberOfCharactersInModel ? impl.mMaximumNumberOfCharacters - numberOfCharactersInModel : 0);
+ Length maxSizeOfNewText = std::min(temp_length, characterCount);
maxLengthReached = (characterCount > maxSizeOfNewText);
// The cursor position.
if(addFontSizeRun)
{
- fontDescriptionRun.size = static_cast<PointSize26Dot6>(inputStyle.size * impl.mFontSizeScale * 64.f);
+ fontDescriptionRun.size = static_cast<PointSize26Dot6>(inputStyle.size * impl.GetFontSizeScale() * 64.f);
fontDescriptionRun.sizeDefined = true;
}
impl.IsPlaceholderAvailable())
{
// Show place-holder if empty after removing the pre-edit text
- controller.ShowPlaceholderText();
+ PlaceholderHandler::ShowPlaceholderText(impl);
eventData->mUpdateCursorPosition = true;
impl.ClearPreEditFlag();
}
}
}
+ if(nullptr != impl.mEditableControlInterface)
+ {
+ impl.mEditableControlInterface->CursorPositionChanged(oldCursorPos, eventData->mPrimaryCursorPosition);
+ }
+
if(maxLengthReached)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", logicalModel->mText.Count());
RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex);
}
+ if(nullptr != impl.mEditableControlInterface)
+ {
+ impl.mEditableControlInterface->CursorPositionChanged(previousCursorIndex, cursorIndex);
+ }
+
// Cursor position retreat
previousCursorIndex = cursorIndex;
if(EventData::SELECTING == impl.mEventData->mState)
{
std::string removedString;
+ uint32_t oldSelStart = impl.mEventData->mLeftSelectionPosition;
+ uint32_t oldSelEnd = impl.mEventData->mRightSelectionPosition;
+
impl.RetrieveSelection(removedString, true);
if(!removedString.empty())
RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex);
}
+
+ if(impl.mSelectableControlInterface != nullptr)
+ {
+ impl.mSelectableControlInterface->SelectionChanged(oldSelStart, oldSelEnd, impl.mEventData->mPrimaryCursorPosition, impl.mEventData->mPrimaryCursorPosition);
+ }
}
}