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=cf49df5b5c3dfb35713519d92b9dd1bd0aa69266;hp=5ee189bd6bcee3bea9a874c7e5793411fd7fb8f4;hb=22451f7abe0230b418d551d9eac0c685273e72f1;hpb=d52cfe949a764d4ab0584b99d1322f06c8acd92f diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 5ee189b..cf49df5 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -22,11 +22,13 @@ #include #include #include +#include #include // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -37,6 +39,7 @@ #include #include #include +#include using namespace Dali; @@ -691,7 +694,7 @@ bool Controller::Impl::SetDefaultLineSpacing(float lineSpacing) { mLayoutEngine.SetDefaultLineSpacing(lineSpacing); - RelayoutForNewLineSize(); + RelayoutAllCharacters(); return true; } return false; @@ -703,12 +706,29 @@ bool Controller::Impl::SetDefaultLineSize(float lineSize) { mLayoutEngine.SetDefaultLineSize(lineSize); - RelayoutForNewLineSize(); + RelayoutAllCharacters(); return true; } 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; @@ -1461,7 +1481,7 @@ void Controller::Impl::RequestRelayout() } } -void Controller::Impl::RelayoutForNewLineSize() +void Controller::Impl::RelayoutAllCharacters() { // relayout all characters mTextUpdateInfo.mCharacterIndex = 0; @@ -1616,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) { - GlyphRun underlineGlyphRun; - underlineGlyphRun.glyphIndex = charactersToGlyph[characterIndex + index]; - underlineGlyphRun.numberOfGlyphs = glyphsPerCharacter[characterIndex + index]; - mModel->mVisualModel->mUnderlineRuns.PushBack(underlineGlyphRun); + 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++) + { + underlineGlyphRun.glyphRun.numberOfGlyphs += glyphsPerCharacter[characterIndex + index]; + } + + mModel->mVisualModel->mUnderlineRuns.PushBack(underlineGlyphRun); } } @@ -1637,8 +1670,14 @@ 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; @@ -1834,6 +1873,7 @@ void Controller::Impl::ClearStyleData() { mModel->mLogicalModel->mColorRuns.Clear(); mModel->mLogicalModel->ClearFontDescriptionRuns(); + mModel->mLogicalModel->ClearStrikethroughRuns(); } void Controller::Impl::ResetScrollPosition()