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=c24a5cfbddb0e1b053d57f6222f52493f1956468;hp=5ee189bd6bcee3bea9a874c7e5793411fd7fb8f4;hb=a5167c61104580ae0ab724f904537a3a01ea3061;hpb=04194fd795542d80b5cf7c1b954ca14593e536d4 diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 5ee189b..c24a5cf 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; @@ -889,7 +909,8 @@ void Controller::Impl::SetEditable(bool editable) if(mEventData->mDecorator) { - mEventData->mDecorator->SetEditable(editable); + bool decoratorEditable = editable && mIsUserInteractionEnabled; + mEventData->mDecorator->SetEditable(decoratorEditable); } } } @@ -1461,7 +1482,7 @@ void Controller::Impl::RequestRelayout() } } -void Controller::Impl::RelayoutForNewLineSize() +void Controller::Impl::RelayoutAllCharacters() { // relayout all characters mTextUpdateInfo.mCharacterIndex = 0; @@ -1616,13 +1637,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,11 +1671,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]; @@ -1654,6 +1693,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) @@ -1803,6 +1875,17 @@ void Controller::Impl::SetDefaultColor(const Vector4& color) } } +void Controller::Impl::SetUserInteractionEnabled(bool enabled) +{ + mIsUserInteractionEnabled = enabled; + + if(mEventData && mEventData->mDecorator) + { + bool editable = mEventData->mEditingEnabled && enabled; + mEventData->mDecorator->SetEditable(editable); + } +} + void Controller::Impl::ClearFontData() { if(mFontDefaults) @@ -1834,6 +1917,7 @@ void Controller::Impl::ClearStyleData() { mModel->mLogicalModel->mColorRuns.Clear(); mModel->mLogicalModel->ClearFontDescriptionRuns(); + mModel->mLogicalModel->ClearStrikethroughRuns(); } void Controller::Impl::ResetScrollPosition()