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-impl.cpp;h=318c19609a93b11b13283e02db8041c71ce78b22;hp=db6fde1c81297e6967136ffe041522ecd59ffd15;hb=1d6351bc6c29b125b71b266f4a8d0f25413e099d;hpb=895806b4ad86de88dcc731aeb8e3dbe453ce4202 diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index db6fde1..318c196 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -39,6 +39,7 @@ #include #include #include +#include using namespace Dali; @@ -711,6 +712,23 @@ bool Controller::Impl::SetDefaultLineSize(float lineSize) return false; } +bool Controller::Impl::SetRelativeLineSize(float relativeLineSize) +{ + if(std::fabs(relativeLineSize - GetRelativeLineSize()) > Math::MACHINE_EPSILON_1000) + { + mLayoutEngine.SetRelativeLineSize(relativeLineSize); + + RelayoutAllCharacters(); + return true; + } + return false; +} + +float Controller::Impl::GetRelativeLineSize() +{ + return mLayoutEngine.GetRelativeLineSize(); +} + string Controller::Impl::GetSelectedText() { string text; @@ -1618,13 +1636,26 @@ void Controller::Impl::CopyUnderlinedFromLogicalToVisualModels(bool shouldClearP { CharacterIndex characterIndex = it->characterRun.characterIndex; Length numberOfCharacters = it->characterRun.numberOfCharacters; - for(Length index = 0u; index < numberOfCharacters; index++) + + if(numberOfCharacters == 0) + { + continue; + } + + // Create one run for all glyphs of all run's characters that has same properties + // This enhance performance and reduce the needed memory to store glyphs-runs + UnderlinedGlyphRun underlineGlyphRun; + underlineGlyphRun.glyphRun.glyphIndex = charactersToGlyph[characterIndex]; + underlineGlyphRun.glyphRun.numberOfGlyphs = glyphsPerCharacter[characterIndex]; + //Copy properties (attributes) + underlineGlyphRun.properties = it->properties; + + for(Length index = 1u; index < numberOfCharacters; index++) { - GlyphRun underlineGlyphRun; - underlineGlyphRun.glyphIndex = charactersToGlyph[characterIndex + index]; - underlineGlyphRun.numberOfGlyphs = glyphsPerCharacter[characterIndex + index]; - mModel->mVisualModel->mUnderlineRuns.PushBack(underlineGlyphRun); + underlineGlyphRun.glyphRun.numberOfGlyphs += glyphsPerCharacter[characterIndex + index]; } + + mModel->mVisualModel->mUnderlineRuns.PushBack(underlineGlyphRun); } } @@ -1639,11 +1670,16 @@ void Controller::Impl::CopyStrikethroughFromLogicalToVisualModels() for(Vector::ConstIterator it = strikethroughCharacterRuns.Begin(), endIt = strikethroughCharacterRuns.End(); it != endIt; ++it) { - CharacterIndex characterIndex = it->characterRun.characterIndex; - Length numberOfCharacters = it->characterRun.numberOfCharacters; + CharacterIndex characterIndex = it->characterRun.characterIndex; + Length numberOfCharacters = it->characterRun.numberOfCharacters; + + if(numberOfCharacters == 0) + { + continue; + } + StrikethroughGlyphRun strikethroughGlyphRun; - strikethroughGlyphRun.color = it->color; - strikethroughGlyphRun.isColorSet = it->isColorSet; + strikethroughGlyphRun.properties = it->properties; strikethroughGlyphRun.glyphRun.glyphIndex = charactersToGlyph[characterIndex]; strikethroughGlyphRun.glyphRun.numberOfGlyphs = glyphsPerCharacter[characterIndex]; @@ -1656,6 +1692,39 @@ void Controller::Impl::CopyStrikethroughFromLogicalToVisualModels() } } +void Controller::Impl::CopyCharacterSpacingFromLogicalToVisualModels() +{ + //CharacterSpacing character runs from markup-processor + const Vector& characterSpacingCharacterRuns = mModel->mLogicalModel->mCharacterSpacingCharacterRuns; + const Vector& charactersToGlyph = mModel->mVisualModel->mCharactersToGlyph; + const Vector& glyphsPerCharacter = mModel->mVisualModel->mGlyphsPerCharacter; + + mModel->mVisualModel->mCharacterSpacingRuns.Clear(); + + for(Vector::ConstIterator it = characterSpacingCharacterRuns.Begin(), endIt = characterSpacingCharacterRuns.End(); it != endIt; ++it) + { + const CharacterIndex& characterIndex = it->characterRun.characterIndex; + const Length& numberOfCharacters = it->characterRun.numberOfCharacters; + + if(numberOfCharacters == 0) + { + continue; + } + + CharacterSpacingGlyphRun characterSpacingGlyphRun; + characterSpacingGlyphRun.value = it->value; + characterSpacingGlyphRun.glyphRun.glyphIndex = charactersToGlyph[characterIndex]; + characterSpacingGlyphRun.glyphRun.numberOfGlyphs = glyphsPerCharacter[characterIndex]; + + for(Length index = 1u; index < numberOfCharacters; index++) + { + characterSpacingGlyphRun.glyphRun.numberOfGlyphs += glyphsPerCharacter[characterIndex + index]; + } + + mModel->mVisualModel->mCharacterSpacingRuns.PushBack(characterSpacingGlyphRun); + } +} + void Controller::Impl::SetAutoScrollEnabled(bool enable) { if(mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX) @@ -1836,6 +1905,7 @@ void Controller::Impl::ClearStyleData() { mModel->mLogicalModel->mColorRuns.Clear(); mModel->mLogicalModel->ClearFontDescriptionRuns(); + mModel->mLogicalModel->ClearStrikethroughRuns(); } void Controller::Impl::ResetScrollPosition()