projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Support the strikethrough and its attribute in span tag
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
internal
/
text
/
text-controller-text-updater.cpp
diff --git
a/dali-toolkit/internal/text/text-controller-text-updater.cpp
b/dali-toolkit/internal/text/text-controller-text-updater.cpp
index
69e05bf
..
0b24bc0
100644
(file)
--- a/
dali-toolkit/internal/text/text-controller-text-updater.cpp
+++ b/
dali-toolkit/internal/text/text-controller-text-updater.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 202
1
Samsung Electronics Co., Ltd.
+ * Copyright (c) 202
2
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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-26,6
+26,7
@@
#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/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
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
namespace
@@
-55,7
+56,7
@@
void Controller::TextUpdater::SetText(Controller& controller, const std::string&
ResetText(controller);
// Remove the style.
ResetText(controller);
// Remove the style.
-
controller
.ClearStyleData();
+
impl
.ClearStyleData();
CharacterIndex lastCursorIndex = 0u;
CharacterIndex lastCursorIndex = 0u;
@@
-69,6
+70,11
@@
void Controller::TextUpdater::SetText(Controller& controller, const std::string&
(EventData::EDITING_WITH_GRAB_HANDLE == eventData->mState) ||
(EventData::EDITING_WITH_PASTE_POPUP == eventData->mState))
{
(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);
}
}
impl.ChangeState(EventData::EDITING);
}
}
@@
-82,7
+88,11
@@
void Controller::TextUpdater::SetText(Controller& controller, const std::string&
MarkupProcessData markupProcessData(logicalModel->mColorRuns,
logicalModel->mFontDescriptionRuns,
logicalModel->mEmbeddedItems,
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;
Length textSize = 0u;
const uint8_t* utf8 = NULL;
@@
-134,14
+144,16
@@
void Controller::TextUpdater::SetText(Controller& controller, const std::string&
}
else
{
}
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.
// Resets the cursor position.
controller.ResetCursorPosition(lastCursorIndex);
// Scrolls the text to make the cursor visible.
-
controller
.ResetScrollPosition();
+
impl
.ResetScrollPosition();
impl.RequestRelayout();
impl.RequestRelayout();
@@
-154,6
+166,7
@@
void Controller::TextUpdater::SetText(Controller& controller, const std::string&
// Do this last since it provides callbacks into application code.
if(NULL != impl.mEditableControlInterface)
{
// Do this last since it provides callbacks into application code.
if(NULL != impl.mEditableControlInterface)
{
+ impl.mEditableControlInterface->CursorPositionChanged(oldCursorPos, lastCursorIndex);
impl.mEditableControlInterface->TextChanged(true);
}
}
impl.mEditableControlInterface->TextChanged(true);
}
}
@@
-170,9
+183,10
@@
void Controller::TextUpdater::InsertText(Controller& controller, const std::stri
return;
}
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);
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);
@@
-254,7
+268,8
@@
void Controller::TextUpdater::InsertText(Controller& controller, const std::stri
const Length numberOfCharactersInModel = logicalModel->mText.Count();
// Restrict new text to fit within Maximum characters setting.
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.
maxLengthReached = (characterCount > maxSizeOfNewText);
// The cursor position.
@@
-338,7
+353,7
@@
void Controller::TextUpdater::InsertText(Controller& controller, const std::stri
if(addFontSizeRun)
{
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;
}
fontDescriptionRun.sizeDefined = true;
}
@@
-393,7
+408,7
@@
void Controller::TextUpdater::InsertText(Controller& controller, const std::stri
impl.IsPlaceholderAvailable())
{
// Show place-holder if empty after removing the pre-edit text
impl.IsPlaceholderAvailable())
{
// Show place-holder if empty after removing the pre-edit text
-
controller.ShowPlaceholderText(
);
+
PlaceholderHandler::ShowPlaceholderText(impl
);
eventData->mUpdateCursorPosition = true;
impl.ClearPreEditFlag();
}
eventData->mUpdateCursorPosition = true;
impl.ClearPreEditFlag();
}
@@
-415,6
+430,11
@@
void Controller::TextUpdater::InsertText(Controller& controller, const std::stri
}
}
}
}
+ if(nullptr != impl.mEditableControlInterface)
+ {
+ impl.mEditableControlInterface->CursorPositionChanged(oldCursorPos, eventData->mPrimaryCursorPosition);
+ }
+
if(maxLengthReached)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", logicalModel->mText.Count());
if(maxLengthReached)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", logicalModel->mText.Count());
@@
-558,6
+578,11
@@
bool Controller::TextUpdater::RemoveText(
RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex);
}
RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex);
}
+ if(nullptr != impl.mEditableControlInterface)
+ {
+ impl.mEditableControlInterface->CursorPositionChanged(previousCursorIndex, cursorIndex);
+ }
+
// Cursor position retreat
previousCursorIndex = cursorIndex;
// Cursor position retreat
previousCursorIndex = cursorIndex;
@@
-585,6
+610,9
@@
bool Controller::TextUpdater::RemoveSelectedText(Controller& controller)
if(EventData::SELECTING == impl.mEventData->mState)
{
std::string removedString;
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())
impl.RetrieveSelection(removedString, true);
if(!removedString.empty())
@@
-601,6
+629,11
@@
bool Controller::TextUpdater::RemoveSelectedText(Controller& controller)
RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex);
}
RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex);
}
+
+ if(impl.mSelectableControlInterface != nullptr)
+ {
+ impl.mSelectableControlInterface->SelectionChanged(oldSelStart, oldSelEnd, impl.mEventData->mPrimaryCursorPosition, impl.mEventData->mPrimaryCursorPosition);
+ }
}
}
}
}