X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fcursor-helper-functions.cpp;h=d8954187e1ee6c4be518b873a131d6771d044db1;hp=c70d530c3577705f43dc6f7f67737db33213b349;hb=5d397f414305c86782668ecd154d8967ee8396b0;hpb=e2d9cf42df969e809a572a5224d1ce5d19aaa1ca diff --git a/dali-toolkit/internal/text/cursor-helper-functions.cpp b/dali-toolkit/internal/text/cursor-helper-functions.cpp index c70d530..d895418 100644 --- a/dali-toolkit/internal/text/cursor-helper-functions.cpp +++ b/dali-toolkit/internal/text/cursor-helper-functions.cpp @@ -22,6 +22,8 @@ #include // INTERNAL INCLUDES +#include +#include #include namespace @@ -153,9 +155,10 @@ LineIndex GetClosestLine(VisualModelPtr visualModel, it != endIt; ++it, ++lineIndex) { - const LineRun& lineRun = *it; + const LineRun& lineRun = *it; + bool isLastLine = (it + 1 == endIt); - totalHeight += GetLineHeight(lineRun); + totalHeight += GetLineHeight(lineRun, isLastLine); if(visualY < totalHeight) { @@ -182,9 +185,10 @@ float CalculateLineOffset(const Vector& lines, it != endIt; ++it) { - const LineRun& lineRun = *it; + const LineRun& lineRun = *it; + bool isLastLine = (it + 1 == lines.End()); - offset += GetLineHeight(lineRun); + offset += GetLineHeight(lineRun, isLastLine); } return offset; @@ -456,6 +460,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"); @@ -504,7 +521,9 @@ void GetCursorPosition(GetCursorPositionParameters& parameters, cursorInfo.lineOffset = CalculateLineOffset(parameters.visualModel->mLines, newLineIndex); - cursorInfo.lineHeight = GetLineHeight(newLine); + // 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 cursor height. + cursorInfo.lineHeight = newLine.ascender - newLine.descender; index = 0u; const Length totalNumberOfCharacters = parameters.logicalModel->mText.Count(); @@ -560,7 +579,9 @@ void GetCursorPosition(GetCursorPositionParameters& parameters, cursorInfo.lineOffset = CalculateLineOffset(parameters.visualModel->mLines, lineIndex); - cursorInfo.lineHeight = GetLineHeight(line); + // 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 cursor height. + cursorInfo.lineHeight = line.ascender - line.descender; // Calculate the primary cursor.