X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fcursor-helper-functions.cpp;h=5dfebde9e65cce8c33dd94c7630dce6e4cceb057;hb=702cdc29b907688eef62afbc63f0edb9e2dfb7d2;hp=3bfc059e111dd627cdd8036de46dbba5bef761e1;hpb=f0379552a8e3342b6606f5b64558cd24a7198b6c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/cursor-helper-functions.cpp b/dali-toolkit/internal/text/cursor-helper-functions.cpp index 3bfc059..5dfebde 100644 --- a/dali-toolkit/internal/text/cursor-helper-functions.cpp +++ b/dali-toolkit/internal/text/cursor-helper-functions.cpp @@ -22,7 +22,10 @@ #include // INTERNAL INCLUDES +#include +#include #include +#include namespace { @@ -214,7 +217,10 @@ CharacterIndex GetClosestCursorIndex(VisualModelPtr visualModel, { return logicalIndex; } - const float characterSpacing = visualModel->GetCharacterSpacing(); + + // Get the character-spacing runs. + const Vector& characterSpacingGlyphRuns = visualModel->GetCharacterSpacingGlyphRuns(); + const float modelCharacterSpacing = visualModel->GetCharacterSpacing(); // Whether there is a hit on a line. bool matchedLine = false; @@ -289,7 +295,8 @@ CharacterIndex GetClosestCursorIndex(VisualModelPtr visualModel, // Get the metrics for the group of glyphs. GlyphMetrics glyphMetrics; - calculatedAdvance = GetCalculatedAdvance(*(logicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + firstLogicalGlyphIndex))), characterSpacing, (*(visualModel->mGlyphs.Begin() + firstLogicalGlyphIndex)).advance); + const float characterSpacing = GetGlyphCharacterSpacing(firstLogicalGlyphIndex, characterSpacingGlyphRuns, modelCharacterSpacing); + calculatedAdvance = GetCalculatedAdvance(*(logicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + firstLogicalGlyphIndex))), characterSpacing, (*(visualModel->mGlyphs.Begin() + firstLogicalGlyphIndex)).advance); GetGlyphsMetrics(firstLogicalGlyphIndex, numberOfGlyphs, glyphMetrics, @@ -458,6 +465,19 @@ CharacterIndex GetClosestCursorIndex(VisualModelPtr visualModel, logicalIndex = (bidiLineFetched ? logicalModel->GetLogicalCursorIndex(visualIndex) : visualIndex); + // Handle Emoji clustering for cursor handling: + // Fixing this case: + // - When there is Emoji contains multi unicodes and it is layoutted at the end of line (LineWrap case , is not new line case) + // - Try to click at the center or at the end of Emoji then the cursor appears inside Emoji + // - Example:"FamilyManWomanGirlBoy 👨‍👩‍👧‍👦" + const Script script = logicalModel->GetScript(logicalIndex); + if(IsOneOfEmojiScripts(script)) + { + //TODO: Use this clustering for Emoji cases only. This needs more testing to generalize to all scripts. + CharacterRun emojiClusteredCharacters = RetrieveClusteredCharactersOfCharacterIndex(visualModel, logicalModel, logicalIndex); + logicalIndex = emojiClusteredCharacters.characterIndex; + } + DALI_LOG_INFO(gLogFilter, Debug::Verbose, "closest visualIndex %d logicalIndex %d\n", visualIndex, logicalIndex); DALI_ASSERT_DEBUG((logicalIndex <= logicalModel->mText.Count() && logicalIndex >= 0) && "GetClosestCursorIndex - Out of bounds index"); @@ -606,7 +626,9 @@ void GetCursorPosition(GetCursorPositionParameters& parameters, const Length* const charactersPerGlyphBuffer = parameters.visualModel->mCharactersPerGlyph.Begin(); const CharacterIndex* const glyphsToCharactersBuffer = parameters.visualModel->mGlyphsToCharacters.Begin(); const Vector2* const glyphPositionsBuffer = parameters.visualModel->mGlyphPositions.Begin(); - const float characterSpacing = parameters.visualModel->GetCharacterSpacing(); + const float modelCharacterSpacing = parameters.visualModel->GetCharacterSpacing(); + + const Vector& characterSpacingGlyphRuns = parameters.visualModel->GetCharacterSpacingGlyphRuns(); // Get the metrics for the group of glyphs. GetGlyphMetricsFromCharacterIndex(index, parameters.visualModel, parameters.logicalModel, metrics, glyphMetrics, glyphIndex, numberOfGlyphs); @@ -723,6 +745,7 @@ void GetCursorPosition(GetCursorPositionParameters& parameters, const bool addGlyphAdvance = ((!isFirstPositionOfLine && !isCurrentRightToLeft) || (isFirstPositionOfLine && !isRightToLeftParagraph)); + const float characterSpacing = GetGlyphCharacterSpacing(secondaryGlyphIndex, characterSpacingGlyphRuns, modelCharacterSpacing); cursorInfo.secondaryPosition.x = -glyphMetrics.xBearing + secondaryPosition.x + (addGlyphAdvance ? (glyphMetrics.advance + characterSpacing) : 0.f); cursorInfo.secondaryPosition.y = cursorInfo.lineOffset + cursorInfo.lineHeight - cursorInfo.secondaryCursorHeight;