X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-view.cpp;h=b4644e7965b2fa007f03f73ced3b00377aa19c7f;hp=f8a2722ac988c2de712214325d5059907deafcb7;hb=895806b4ad86de88dcc731aeb8e3dbe453ce4202;hpb=0f5a244a8e8f8fa680dccafca44ccc9fedb387a8 diff --git a/dali-toolkit/internal/text/text-view.cpp b/dali-toolkit/internal/text/text-view.cpp index f8a2722..b4644e7 100644 --- a/dali-toolkit/internal/text/text-view.cpp +++ b/dali-toolkit/internal/text/text-view.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. @@ -23,6 +23,9 @@ #include #include +// INTERNAL INCLUDES +#include + namespace Dali { namespace Toolkit @@ -32,6 +35,7 @@ namespace Text struct View::Impl { VisualModelPtr mVisualModel; + LogicalModelPtr mLogicalModel; TextAbstraction::FontClient mFontClient; ///< Handle to the font client. }; @@ -53,6 +57,11 @@ void View::SetVisualModel(VisualModelPtr visualModel) mImpl->mVisualModel = visualModel; } +void View::SetLogicalModel(LogicalModelPtr logicalModel) +{ + mImpl->mLogicalModel = logicalModel; +} + const Vector2& View::GetControlSize() const { if(mImpl->mVisualModel) @@ -96,8 +105,13 @@ Length View::GetGlyphs(GlyphInfo* glyphs, GlyphIndex glyphIndex, Length numberOfGlyphs) const { - Length numberOfLaidOutGlyphs = 0u; - Length numberOfActualLaidOutGlyphs = 0u; + Length numberOfLaidOutGlyphs = 0u; + Length numberOfActualLaidOutGlyphs = 0u; + const float characterSpacing = mImpl->mVisualModel->GetCharacterSpacing(); + Vector& glyphToCharacterMap = mImpl->mVisualModel->mGlyphsToCharacters; + const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin(); + float calculatedAdvance = 0.f; + const Character* textBuffer = mImpl->mLogicalModel->mText.Begin(); if(mImpl->mVisualModel) { @@ -213,7 +227,7 @@ Length View::GetGlyphs(GlyphInfo* glyphs, if(lastGlyphIndexOfLine == index) { - penY += -line->descender; + penY += -line->descender + line->lineSpacing; // Get the next line. ++lineIndex; @@ -265,7 +279,7 @@ Length View::GetGlyphs(GlyphInfo* glyphs, const LineRun& elidedLine = *ellipsisLine; if((1u == numberOfLines) && - (elidedLine.ascender - elidedLine.descender > mImpl->mVisualModel->mControlSize.height)) + (GetLineHeight(elidedLine) > mImpl->mVisualModel->mControlSize.height)) { // Replace the first glyph with ellipsis glyph auto indexOfFirstGlyph = (ellipsisPosition == DevelText::EllipsisPosition::START) ? startIndexOfEllipsis : 0u; @@ -342,7 +356,8 @@ Length View::GetGlyphs(GlyphInfo* glyphs, firstPenSet = true; } - removedGlypsWidth += std::min(glyphToRemove.advance, (glyphToRemove.xBearing + glyphToRemove.width)); + calculatedAdvance = GetCalculatedAdvance(*(textBuffer + (*(glyphToCharacterMapBuffer + indexOfEllipsis))), characterSpacing, glyphToRemove.advance); + removedGlypsWidth += std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width)); // Calculate the width of the ellipsis glyph and check if it fits. const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing; @@ -625,6 +640,36 @@ float View::GetUnderlineHeight() const return 0.0f; } +Text::Underline::Type View::GetUnderlineType() const +{ + Text::Underline::Type type = Text::Underline::Type::SOLID; + if(mImpl->mVisualModel) + { + type = mImpl->mVisualModel->GetUnderlineType(); + } + return type; +} + +float View::GetDashedUnderlineWidth() const +{ + float width = 0.0f; + if(mImpl->mVisualModel) + { + width = mImpl->mVisualModel->GetDashedUnderlineWidth(); + } + return width; +} + +float View::GetDashedUnderlineGap() const +{ + float gap = 0.0f; + if(mImpl->mVisualModel) + { + gap = mImpl->mVisualModel->GetDashedUnderlineGap(); + } + return gap; +} + Length View::GetNumberOfUnderlineRuns() const { if(mImpl->mVisualModel) @@ -742,6 +787,58 @@ GlyphIndex View::GetSecondMiddleIndexOfElidedGlyphs() const return secondMiddleIndexOfElidedGlyphs; } +const Vector4& View::GetStrikethroughColor() const +{ + return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetStrikethroughColor() : Vector4::ZERO; +} + +bool View::IsStrikethroughEnabled() const +{ + return (mImpl->mVisualModel) ? mImpl->mVisualModel->IsStrikethroughEnabled() : false; +} + +float View::GetStrikethroughHeight() const +{ + return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetStrikethroughHeight() : 0.0f; +} + +Length View::GetNumberOfStrikethroughRuns() const +{ + if(mImpl->mVisualModel) + { + return mImpl->mVisualModel->GetNumberOfStrikethroughRuns(); + } + + return 0u; +} + +void View::GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, + StrikethroughRunIndex index, + Length numberOfRuns) const +{ + if(mImpl->mVisualModel) + { + mImpl->mVisualModel->GetStrikethroughRuns(strikethroughRuns, + index, + numberOfRuns); + } +} + +const float View::GetCharacterSpacing() const +{ + return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetCharacterSpacing() : 0.f; +} + +const Character* View::GetTextBuffer() const +{ + return (mImpl->mVisualModel) ? mImpl->mLogicalModel->mText.Begin() : nullptr; +} + +const Vector& View::GetGlyphsToCharacters() const +{ + return mImpl->mVisualModel->GetGlyphsToCharacters(); +} + } // namespace Text } // namespace Toolkit