X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fcontroller%2Ftext-controller-impl.cpp;h=10a76f1dee8e04f99e2848df367e8bddc4e90ec4;hb=HEAD;hp=eb24eb93acde7dce2de9100b83b8697aa3c74331;hpb=172fae8f3b64a9e14c725fbcccd51080117ca9aa;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/controller/text-controller-impl.cpp b/dali-toolkit/internal/text/controller/text-controller-impl.cpp index eb24eb9..10a76f1 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -51,8 +51,9 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT constexpr float MAX_FLOAT = std::numeric_limits::max(); -const char* EMPTY_STRING = ""; +const char* EMPTY_STRING = ""; const char* MIME_TYPE_TEXT_PLAIN = "text/plain;charset=utf-8"; +const char* MIME_TYPE_HTML = "application/xhtml+xml"; } // namespace @@ -482,14 +483,14 @@ void Controller::Impl::UpdateAnchorColor() if(mModel->mLogicalModel->mColorRuns.Count() > anchor.colorRunIndex) { ColorRun& colorRun = *(mModel->mLogicalModel->mColorRuns.Begin() + anchor.colorRunIndex); - colorRun.color = mAnchorColor; - updateNeeded = true; + colorRun.color = mAnchorColor; + updateNeeded = true; } if(mModel->mLogicalModel->mUnderlinedCharacterRuns.Count() > anchor.underlinedCharacterRunIndex) { UnderlinedCharacterRun& underlineRun = *(mModel->mLogicalModel->mUnderlinedCharacterRuns.Begin() + anchor.underlinedCharacterRunIndex); - underlineRun.properties.color = mAnchorColor; - updateNeeded = true; + underlineRun.properties.color = mAnchorColor; + updateNeeded = true; } } else if(!anchor.isMarkupClickedColorSet && anchor.isClicked) @@ -497,14 +498,14 @@ void Controller::Impl::UpdateAnchorColor() if(mModel->mLogicalModel->mColorRuns.Count() > anchor.colorRunIndex) { ColorRun& colorRun = *(mModel->mLogicalModel->mColorRuns.Begin() + anchor.colorRunIndex); - colorRun.color = mAnchorClickedColor; - updateNeeded = true; + colorRun.color = mAnchorClickedColor; + updateNeeded = true; } if(mModel->mLogicalModel->mUnderlinedCharacterRuns.Count() > anchor.underlinedCharacterRunIndex) { UnderlinedCharacterRun& underlineRun = *(mModel->mLogicalModel->mUnderlinedCharacterRuns.Begin() + anchor.underlinedCharacterRunIndex); - underlineRun.properties.color = mAnchorClickedColor; - updateNeeded = true; + underlineRun.properties.color = mAnchorClickedColor; + updateNeeded = true; } } } @@ -701,7 +702,7 @@ void Controller::Impl::CalculateTextUpdateIndices(Length& numberOfCharacters) mTextUpdateInfo.mRequestedNumberOfCharacters = mTextUpdateInfo.mNumberOfCharactersToAdd - mTextUpdateInfo.mNumberOfCharactersToRemove; mTextUpdateInfo.mStartGlyphIndex = mModel->mVisualModel->mGlyphs.Count(); - mTextUpdateInfo.mStartLineIndex = mModel->mVisualModel->mLines.Count() - 1u; + mTextUpdateInfo.mStartLineIndex = (mModel->mVisualModel->mLines.Count() > 0u) ? mModel->mVisualModel->mLines.Count() - 1u : 0u; // Nothing else to do; return; @@ -1011,6 +1012,8 @@ void Controller::Impl::SetEditable(bool editable) { bool decoratorEditable = editable && mIsUserInteractionEnabled; mEventData->mDecorator->SetEditable(decoratorEditable); + mEventData->mDecoratorUpdated = true; + RequestRelayout(); } } } @@ -1159,6 +1162,12 @@ bool Controller::Impl::CopyStringToClipboard(const std::string& source) return false; } +bool Controller::Impl::IsClipboardEmpty() +{ + bool result(Clipboard::IsAvailable() && EnsureClipboardCreated() && (mClipboard.HasType(MIME_TYPE_TEXT_PLAIN) || mClipboard.HasType(MIME_TYPE_HTML))); + return !result; +} + void Controller::Impl::SendSelectionToClipboard(bool deleteAfterSending) { std::string selectedText; @@ -1387,7 +1396,7 @@ CharacterIndex Controller::Impl::CalculateNewCursorIndex(CharacterIndex index) c else { Length textLength = mModel->mVisualModel->mCharactersToGlyph.Count(); - cursorIndex = cursorIndex + numberOfCharacters > textLength ? textLength : cursorIndex + numberOfCharacters; + cursorIndex = cursorIndex + numberOfCharacters > textLength ? textLength : cursorIndex + numberOfCharacters; } // Will update the cursor hook position. @@ -2013,6 +2022,8 @@ void Controller::Impl::SetUserInteractionEnabled(bool enabled) { bool editable = mEventData->mEditingEnabled && enabled; mEventData->mDecorator->SetEditable(editable); + mEventData->mDecoratorUpdated = true; + RequestRelayout(); } }