X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fcursor-helper-functions.h;h=f62165b1dd8add779d223b92f29b9212cbfdbe6a;hb=026776eb4b0303604b3c6ca5857cc1ac59b4006e;hp=08c21a3f1654ec94d77da556156b4917e975e7be;hpb=1e3e71f9aee86bdf912062370fa29c1fc062086c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/cursor-helper-functions.h b/dali-toolkit/internal/text/cursor-helper-functions.h index 08c21a3..f62165b 100644 --- a/dali-toolkit/internal/text/cursor-helper-functions.h +++ b/dali-toolkit/internal/text/cursor-helper-functions.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_TEXT_CURSOR_HELPER_FUNCTIONS_H__ -#define __DALI_TOOLKIT_TEXT_CURSOR_HELPER_FUNCTIONS_H__ +#ifndef DALI_TOOLKIT_TEXT_CURSOR_HELPER_FUNCTIONS_H +#define DALI_TOOLKIT_TEXT_CURSOR_HELPER_FUNCTIONS_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,18 @@ namespace Toolkit namespace Text { +struct CharacterHitTest +{ + /** + * @brief Enumeration of the types of hit test. + */ + enum Mode + { + TAP, ///< Retrieves the first or last character of the line if the touch point is outside of the boundaries of the text. + SCROLL ///< Retrieves the character above or below to the touch point if it's outside of the boundaries of the text. + }; +}; + struct CursorInfo { CursorInfo() @@ -63,20 +75,42 @@ struct CursorInfo * * @param[in] visualModel The visual model. * @param[in] visualY The touch point 'y' in text's coords. + * @param[out] matchedLine Whether the touch point actually hits a line. * * @return A line index. */ LineIndex GetClosestLine( VisualModelPtr visualModel, - float visualY ); + float visualY, + bool& matchedLine ); + +/** + * @brief Calculates the vertical line's offset for a given line. + * + * @pre @p lineIndex must be between 0 and the number of lines (both inclusive). + * + * @param[in] lines The laid-out lines. + * @param[in] lineIndex Index to the line. + * + * @return The vertical offset of the given line. + */ +float CalculateLineOffset( const Vector& lines, + LineIndex lineIndex ); /** * @brief Retrieves the cursor's logical position for a given touch point x,y * + * There are two types of hit test: CharacterHitTest::TAP retrieves the first or + * last character of a line if the touch point is outside the boundaries of the + * text, CharacterHitTest::SCROLL retrieves the character above or below to the + * touch point if it's outside the boundaries of the text. + * * @param[in] visualModel The visual model. * @param[in] logicalModel The logical model. * @param[in] metrics A wrapper around FontClient used to get metrics. * @param[in] visualX The touch point 'x' in text's coords. * @param[in] visualY The touch point 'y' in text's coords. + * @param[in] mode The type of hit test. + * @param[out] matchedCharacter Whether the touch point actually hits a character. * * @return The logical cursor position (in characters). 0 is just before the first character, a value equal to the number of characters is just after the last character. */ @@ -84,8 +118,9 @@ CharacterIndex GetClosestCursorIndex( VisualModelPtr visualModel, LogicalModelPtr logicalModel, MetricsPtr metrics, float visualX, - float visualY ); - + float visualY, + CharacterHitTest::Mode mode, + bool& matchedCharacter ); /** * @brief Calculates the cursor's position for a given character index in the logical order. @@ -115,14 +150,18 @@ void GetCursorPosition( VisualModelPtr visualModel, * @param[in] visualY The touch point 'y' in text's coords. * @param[out] startIndex Index to the first character of the selected word. * @param[out] endIndex Index to the last character of the selected word. + * @param[out] noTextHitIndex Index to the nearest character when there is no hit. + * + * @return @e true if the touch point hits a character. */ -void FindSelectionIndices( VisualModelPtr visualModel, +bool FindSelectionIndices( VisualModelPtr visualModel, LogicalModelPtr logicalModel, MetricsPtr metrics, float visualX, float visualY, CharacterIndex& startIndex, - CharacterIndex& endIndex ); + CharacterIndex& endIndex, + CharacterIndex& noTextHitIndex ); } // namespace Text @@ -130,4 +169,4 @@ void FindSelectionIndices( VisualModelPtr visualModel, } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_CURSOR_HELPER_FUNCTIONS_H__ +#endif // DALI_TOOLKIT_TEXT_CURSOR_HELPER_FUNCTIONS_H