X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller-impl.cpp;h=db6fde1c81297e6967136ffe041522ecd59ffd15;hb=2512aa2794f3c5ea5841542b9ed9c8c32973540b;hp=35ad9593a8a0ffc6b715b8dce3944fcb00abb19e;hpb=2d3b65beba8590908a3a36183c4067e5ac0a51f8;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 35ad959..db6fde1 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.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. @@ -19,14 +19,16 @@ #include // EXTERNAL INCLUDES -#include +#include #include #include -#include +#include +#include // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -54,10 +56,8 @@ const std::string EMPTY_STRING(""); namespace Dali::Toolkit::Text { - namespace { - void SetDefaultInputStyle(InputStyle& inputStyle, const FontDefaults* const fontDefaults, const Vector4& textColor) { // Sets the default text's color. @@ -342,7 +342,7 @@ void ChangeTextControllerState(Controller::Impl& impl, EventData::State newState decorator->StopCursorBlink(); decorator->SetHandleActive(GRAB_HANDLE, false); if(eventData->mDecorator->IsHandleActive(LEFT_SELECTION_HANDLE) || - decorator->IsHandleActive(RIGHT_SELECTION_HANDLE)) + decorator->IsHandleActive(RIGHT_SELECTION_HANDLE)) { decorator->SetHandleActive(LEFT_SELECTION_HANDLE, false); decorator->SetHandleActive(RIGHT_SELECTION_HANDLE, false); @@ -674,11 +674,11 @@ float Controller::Impl::GetDefaultFontLineHeight() if(nullptr == mFontDefaults) { TextAbstraction::FontDescription fontDescription; - defaultFontId = mFontClient.GetFontId(fontDescription, TextAbstraction::FontClient::DEFAULT_POINT_SIZE * mFontSizeScale); + defaultFontId = mFontClient.GetFontId(fontDescription, TextAbstraction::FontClient::DEFAULT_POINT_SIZE * GetFontSizeScale()); } else { - defaultFontId = mFontDefaults->GetFontId(mFontClient, mFontDefaults->mDefaultPointSize * mFontSizeScale); + defaultFontId = mFontDefaults->GetFontId(mFontClient, mFontDefaults->mDefaultPointSize * GetFontSizeScale()); } Text::FontMetrics fontMetrics; @@ -692,9 +692,8 @@ bool Controller::Impl::SetDefaultLineSpacing(float lineSpacing) if(std::fabs(lineSpacing - mLayoutEngine.GetDefaultLineSpacing()) > Math::MACHINE_EPSILON_1000) { mLayoutEngine.SetDefaultLineSpacing(lineSpacing); - mRecalculateNaturalSize = true; - RelayoutForNewLineSize(); + RelayoutAllCharacters(); return true; } return false; @@ -705,9 +704,8 @@ bool Controller::Impl::SetDefaultLineSize(float lineSize) if(std::fabs(lineSize - mLayoutEngine.GetDefaultLineSize()) > Math::MACHINE_EPSILON_1000) { mLayoutEngine.SetDefaultLineSize(lineSize); - mRecalculateNaturalSize = true; - RelayoutForNewLineSize(); + RelayoutAllCharacters(); return true; } return false; @@ -1199,7 +1197,10 @@ void Controller::Impl::GetCursorPosition(CharacterIndex logical, parameters.logical = logical; parameters.isMultiline = isMultiLine; + float defaultFontLineHeight = GetDefaultFontLineHeight(); + Text::GetCursorPosition(parameters, + defaultFontLineHeight, cursorInfo); // Adds Outline offset. @@ -1462,7 +1463,7 @@ void Controller::Impl::RequestRelayout() } } -void Controller::Impl::RelayoutForNewLineSize() +void Controller::Impl::RelayoutAllCharacters() { // relayout all characters mTextUpdateInfo.mCharacterIndex = 0; @@ -1470,8 +1471,13 @@ void Controller::Impl::RelayoutForNewLineSize() mTextUpdateInfo.mNumberOfCharactersToAdd = mModel->mLogicalModel->mText.Count(); mOperationsPending = static_cast(mOperationsPending | LAYOUT); + mTextUpdateInfo.mFullRelayoutNeeded = true; + + // Need to recalculate natural size + mRecalculateNaturalSize = true; + //remove selection - if(mEventData && mEventData->mState == EventData::SELECTING) + if((mEventData != nullptr) && (mEventData->mState == EventData::SELECTING)) { ChangeState(EventData::EDITING); } @@ -1493,7 +1499,7 @@ void Controller::Impl::ProcessInputStyleChangedSignals() // Emit the input style changed signal for each mask std::for_each(mEventData->mInputStyleChangedQueue.begin(), mEventData->mInputStyleChangedQueue.end(), - [&](const auto mask) { mEditableControlInterface->InputStyleChanged(mask); } ); + [&](const auto mask) { mEditableControlInterface->InputStyleChanged(mask); }); } mEventData->mInputStyleChangedQueue.Clear(); @@ -1622,6 +1628,34 @@ void Controller::Impl::CopyUnderlinedFromLogicalToVisualModels(bool shouldClearP } } +void Controller::Impl::CopyStrikethroughFromLogicalToVisualModels() +{ + //Strikethrough character runs from markup-processor + const Vector& strikethroughCharacterRuns = mModel->mLogicalModel->mStrikethroughCharacterRuns; + const Vector& charactersToGlyph = mModel->mVisualModel->mCharactersToGlyph; + const Vector& glyphsPerCharacter = mModel->mVisualModel->mGlyphsPerCharacter; + + mModel->mVisualModel->mStrikethroughRuns.Clear(); + + for(Vector::ConstIterator it = strikethroughCharacterRuns.Begin(), endIt = strikethroughCharacterRuns.End(); it != endIt; ++it) + { + CharacterIndex characterIndex = it->characterRun.characterIndex; + Length numberOfCharacters = it->characterRun.numberOfCharacters; + StrikethroughGlyphRun strikethroughGlyphRun; + strikethroughGlyphRun.color = it->color; + strikethroughGlyphRun.isColorSet = it->isColorSet; + strikethroughGlyphRun.glyphRun.glyphIndex = charactersToGlyph[characterIndex]; + strikethroughGlyphRun.glyphRun.numberOfGlyphs = glyphsPerCharacter[characterIndex]; + + for(Length index = 1u; index < numberOfCharacters; index++) + { + strikethroughGlyphRun.glyphRun.numberOfGlyphs += glyphsPerCharacter[characterIndex + index]; + } + + mModel->mVisualModel->mStrikethroughRuns.PushBack(strikethroughGlyphRun); + } +} + void Controller::Impl::SetAutoScrollEnabled(bool enable) { if(mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX) @@ -1724,7 +1758,7 @@ void Controller::Impl::SetVerticalAlignment(VerticalAlignment::Type alignment) { // Set the alignment. mModel->mVerticalAlignment = alignment; - mOperationsPending = static_cast(mOperationsPending | ALIGN); + mOperationsPending = static_cast(mOperationsPending | ALIGN); RequestRelayout(); } } @@ -1804,7 +1838,6 @@ void Controller::Impl::ClearStyleData() mModel->mLogicalModel->ClearFontDescriptionRuns(); } - void Controller::Impl::ResetScrollPosition() { if(mEventData)