X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller-text-updater.cpp;h=f49e9539996e99ceacd9053cf54d5ff560edf71d;hp=75ea73c99274218ab1f8cac44629060646a83edf;hb=5d397f414305c86782668ecd154d8967ee8396b0;hpb=5196315c0dcb4ffe51650ebd5415d680be611f7e diff --git a/dali-toolkit/internal/text/text-controller-text-updater.cpp b/dali-toolkit/internal/text/text-controller-text-updater.cpp index 75ea73c..f49e953 100644 --- 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) 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. @@ -24,8 +24,11 @@ // INTERNAL INCLUDES #include +#include +#include #include #include +#include #include namespace @@ -55,7 +58,7 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string& ResetText(controller); // Remove the style. - controller.ClearStyleData(); + impl.ClearStyleData(); CharacterIndex lastCursorIndex = 0u; @@ -89,7 +92,9 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string& logicalModel->mEmbeddedItems, logicalModel->mAnchors, logicalModel->mUnderlinedCharacterRuns, - logicalModel->mBackgroundColorRuns); + logicalModel->mBackgroundColorRuns, + logicalModel->mStrikethroughCharacterRuns, + logicalModel->mBoundedParagraphRuns); Length textSize = 0u; const uint8_t* utf8 = NULL; @@ -141,7 +146,7 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string& } else { - controller.ShowPlaceholderText(); + PlaceholderHandler::ShowPlaceholderText(impl); } unsigned int oldCursorPos = (nullptr != eventData ? eventData->mPrimaryCursorPosition : 0); @@ -150,7 +155,7 @@ void Controller::TextUpdater::SetText(Controller& controller, const std::string& controller.ResetCursorPosition(lastCursorIndex); // Scrolls the text to make the cursor visible. - controller.ResetScrollPosition(); + impl.ResetScrollPosition(); impl.RequestRelayout(); @@ -350,7 +355,7 @@ void Controller::TextUpdater::InsertText(Controller& controller, const std::stri if(addFontSizeRun) { - fontDescriptionRun.size = static_cast(inputStyle.size * impl.mFontSizeScale * 64.f); + fontDescriptionRun.size = static_cast(inputStyle.size * impl.GetFontSizeScale() * 64.f); fontDescriptionRun.sizeDefined = true; } @@ -405,7 +410,7 @@ void Controller::TextUpdater::InsertText(Controller& controller, const std::stri impl.IsPlaceholderAvailable()) { // Show place-holder if empty after removing the pre-edit text - controller.ShowPlaceholderText(); + PlaceholderHandler::ShowPlaceholderText(impl); eventData->mUpdateCursorPosition = true; impl.ClearPreEditFlag(); } @@ -478,6 +483,7 @@ bool Controller::TextUpdater::RemoveText( ModelPtr& model = impl.mModel; LogicalModelPtr& logicalModel = model->mLogicalModel; + VisualModelPtr& visualModel = model->mVisualModel; DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n", &controller, logicalModel->mText.Count(), eventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters); @@ -495,6 +501,25 @@ bool Controller::TextUpdater::RemoveText( cursorIndex = eventData->mPrimaryCursorPosition + cursorOffset; } + //Handle Emoji clustering for cursor handling + // Deletion case: this is handling the deletion cases when the cursor is before or after Emoji + // - Before: when use delete key and cursor is before Emoji (cursorOffset = -1) + // - After: when use backspace key and cursor is after Emoji (cursorOffset = 0) + + const Script script = logicalModel->GetScript(cursorIndex); + if((numberOfCharacters == 1u) && + (IsOneOfEmojiScripts(script))) + { + //TODO: Use this clustering for Emoji cases only. This needs more testing to generalize to all scripts. + CharacterRun emojiClusteredCharacters = RetrieveClusteredCharactersOfCharacterIndex(visualModel, logicalModel, cursorIndex); + Length actualNumberOfCharacters = emojiClusteredCharacters.numberOfCharacters; + + //Set cursorIndex at the first characterIndex of clustred Emoji + cursorIndex = emojiClusteredCharacters.characterIndex; + + numberOfCharacters = actualNumberOfCharacters; + } + if((cursorIndex + numberOfCharacters) > currentText.Count()) { numberOfCharacters = currentText.Count() - cursorIndex;