X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Flogical-model-impl.cpp;h=bdbbbfeb4d8732b4167d280b20831aa0a8280386;hp=7dbe6284166900adcba7abc36952f2d3051eb45c;hb=3907bd39efa159835ec5456031ec4820934c40cb;hpb=24ab5420ad958de9ba345b504de62881162c754b diff --git a/dali-toolkit/internal/text/logical-model-impl.cpp b/dali-toolkit/internal/text/logical-model-impl.cpp index 7dbe628..bdbbbfe 100644 --- a/dali-toolkit/internal/text/logical-model-impl.cpp +++ b/dali-toolkit/internal/text/logical-model-impl.cpp @@ -18,8 +18,9 @@ // CLASS HEADER #include -// EXTERNAL INCLUDES -#include +// INTERNAL INCLUDES +#include +#include namespace Dali { @@ -244,6 +245,48 @@ CharacterIndex LogicalModel::GetLogicalCharacterIndex( CharacterIndex visualChar return *( mVisualToLogicalMap.Begin() + visualCharacterIndex ); } +void LogicalModel::UpdateTextStyleRuns( CharacterIndex index, int numberOfCharacters ) +{ + const Length totalNumberOfCharacters = mText.Count(); + + // Process the color runs. + Vector removedColorRuns; + UpdateCharacterRuns( index, + numberOfCharacters, + totalNumberOfCharacters, + mColorRuns, + removedColorRuns ); +} + +void LogicalModel::RetrieveStyle( CharacterIndex index, InputStyle& style ) +{ + unsigned int runIndex = 0u; + unsigned int lastRunIndex = 0u; + bool overriden = false; + + // Set the text color. + for( Vector::ConstIterator it = mColorRuns.Begin(), + endIt = mColorRuns.End(); + it != endIt; + ++it, ++runIndex ) + { + const ColorRun& colorRun = *it; + + if( ( colorRun.characterRun.characterIndex <= index ) && + ( index < colorRun.characterRun.characterIndex + colorRun.characterRun.numberOfCharacters ) ) + { + lastRunIndex = runIndex; + overriden = true; + } + } + + // Set the text's color if it's overriden. + if( overriden ) + { + style.textColor = ( *( mColorRuns.Begin() + lastRunIndex ) ).color; + } +} + LogicalModel::~LogicalModel() { }