X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-selection-handle-controller.cpp;h=fef3baa5938baca0bb61885bcec8c8a4e510ce5e;hp=8e43a8726c70da131a514f5a13d87b4c1de9eed5;hb=020b07151378db83ab8e12eb3e2d51db0ed69996;hpb=e2d9cf42df969e809a572a5224d1ce5d19aaa1ca diff --git a/dali-toolkit/internal/text/text-selection-handle-controller.cpp b/dali-toolkit/internal/text/text-selection-handle-controller.cpp index 8e43a87..fef3baa 100644 --- a/dali-toolkit/internal/text/text-selection-handle-controller.cpp +++ b/dali-toolkit/internal/text/text-selection-handle-controller.cpp @@ -24,7 +24,8 @@ // INTERNAL INCLUDES #include #include -#include +#include +#include using namespace Dali; @@ -108,10 +109,13 @@ void SelectionHandleController::Reposition(Controller::Impl& impl) const GlyphIndex glyphStart = *(charactersToGlyphBuffer + selectionStart); const Length numberOfGlyphs = *(glyphsPerCharacterBuffer + selectionEndMinusOne); const GlyphIndex glyphEnd = *(charactersToGlyphBuffer + selectionEndMinusOne) + ((numberOfGlyphs > 0) ? numberOfGlyphs - 1u : 0u); - const float characterSpacing = visualModel->GetCharacterSpacing(); + const float modelCharacterSpacing = visualModel->GetCharacterSpacing(); Vector& glyphToCharacterMap = visualModel->mGlyphsToCharacters; const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin(); + // Get the character-spacing runs. + const Vector& characterSpacingGlyphRuns = visualModel->GetCharacterSpacingGlyphRuns(); + // Get the lines where the glyphs are laid-out. const LineRun* lineRun = visualModel->mLines.Begin(); @@ -148,7 +152,9 @@ void SelectionHandleController::Reposition(Controller::Impl& impl) lineRun += firstLineIndex; - selectionBoxInfo->lineHeight = GetLineHeight(*lineRun); + // The line height is the addition of the line ascender and the line descender. + // However, the line descender has a negative value, hence the subtraction also line spacing should not be included in selection height. + selectionBoxInfo->lineHeight = lineRun->ascender - lineRun->descender; GlyphIndex lastGlyphOfLine = lineRun->glyphRun.glyphIndex + lineRun->glyphRun.numberOfGlyphs - 1u; @@ -172,9 +178,10 @@ void SelectionHandleController::Reposition(Controller::Impl& impl) // Traverse the glyphs. for(GlyphIndex index = glyphStart; index <= glyphEnd; ++index) { - const GlyphInfo& glyph = *(glyphsBuffer + index); - const Vector2& position = *(positionsBuffer + index); - calculatedAdvance = GetCalculatedAdvance(*(logicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + index))), characterSpacing, glyph.advance); + const float characterSpacing = GetGlyphCharacterSpacing(index, characterSpacingGlyphRuns, modelCharacterSpacing); + const GlyphInfo& glyph = *(glyphsBuffer + index); + const Vector2& position = *(positionsBuffer + index); + calculatedAdvance = GetCalculatedAdvance(*(logicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + index))), characterSpacing, glyph.advance); if(splitStartGlyph) { @@ -260,6 +267,8 @@ void SelectionHandleController::Reposition(Controller::Impl& impl) ++lineIndex; if(lineIndex < firstLineIndex + numberOfLines) { + float currentLineSpacing = lineRun->lineSpacing; + // Retrieve the next line. ++lineRun; @@ -277,9 +286,16 @@ void SelectionHandleController::Reposition(Controller::Impl& impl) selectionBoxInfo->maxX = MIN_FLOAT; // Update the line's vertical offset. - selectionBoxInfo->lineOffset = currentLineOffset + currentLineHeight; + selectionBoxInfo->lineOffset = currentLineOffset + currentLineHeight + currentLineSpacing; + + // The line height is the addition of the line ascender and the line descender. + // However, the line descender has a negative value, hence the subtraction also line spacing should not be included in selection height. + selectionBoxInfo->lineHeight = lineRun->ascender - lineRun->descender; - selectionBoxInfo->lineHeight = GetLineHeight(*lineRun); + if(lineRun->lineSpacing > 0) + { + selectionBoxInfo->lineHeight += lineRun->lineSpacing; + } } } }