Add GetCharacterIndexAtPosition API
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-geometry.h
index fb118f0..1d410bf 100644 (file)
  *
  */
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/math/rect.h>
+
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/text-model.h>
-
 namespace Dali
 {
 namespace Toolkit
@@ -40,6 +42,91 @@ namespace Text
    */
 void GetTextGeometry(ModelPtr textModel, CharacterIndex startIndex, CharacterIndex endIndex, Vector<Vector2>& sizesList, Vector<Vector2>& positionsList);
 
+/**
+  * @brief Get the line bounding rectangle.
+  * if the requested index is out of range or the line is not yet rendered, a rect of {0, 0, 0, 0} is returned.
+  *
+  * @param[in] textModel text model containing line info.
+  * @param[in] lineIndex line index to which we want to calculate the geometry for.
+  * @return bounding rectangle.
+  */
+Rect<float> GetLineBoundingRect(ModelPtr textModel, const uint32_t lineIndex);
+
+/**
+  * @brief Get the left point of the line (x).
+  *
+  * @param[in] lineRun the requested line.
+  * @return x point of the line.
+  */
+float GetLineLeft(const LineRun& lineRun);
+
+/**
+  * @brief Get the top point of the line (y).
+  * if the requested line id the first; the top = 0, else the top = the heights of the previouse lines.
+  *
+  * @param[in] lines   the lines in the text controller.
+  * @param[in] lineRun the requested line.
+  * @return y point of the line.
+  */
+float GetLineTop(const Vector<LineRun>& lines, const LineRun& lineRun);
+
+/**
+  * @brief Get the rendered size and position of a specific character in a rectangle.
+  * If the text is not yet rendered or the index > text.Count(); a rect of {0, 0, 0, 0} is returned.
+  * The Width  of the character = glyph.advance
+  * The Height of the character = glyph.height
+  * The Left (X) of the character = characterPosition.x - glyph.xBearing; Regardless of the language direction RTL or LTR, the x point is the left x-point of the glyph. 
+  * The Top  (Y) of the character = characterPosition.y.
+  * @param[in] textModel text model containing text info.
+  * @param[in] charIndex character index to which we want to calculate the geometry for.
+  * @return Rect {x, y, width, height}.
+  */
+Rect<> GetCharacterBoundingRect(ModelPtr textModel, const uint32_t charIndex);
+
+/**
+  * @brief Get the character index.
+  * If the text is not yet rendered or the text is empty, -1 is returned.
+  *
+  * @param[in] textModel text model containing text info.
+  * @param[in] visualX visual x position.
+  * @param[in] visualY visual y position.
+  * @return character index.
+  */
+int GetCharIndexAtPosition(ModelPtr textModel, float visualX, float visualY);
+
+/**
+  * @brief Get the left point of the character (x).
+  *
+  * @param[in] glyph the requested character glyph.
+  * @param[in] characterPosition the position of the requested character.
+  * @return x point of the character.
+  */
+float GetCharacterLeft(const GlyphInfo& glyph, const Vector2& characterPosition);
+
+/**
+  * @brief Get the top point of the character (y).
+  *
+  * @param[in] characterPosition the position of the requested character.
+  * @return y point of the character.
+  */
+float GetCharacterTop(const Vector2& characterPosition);
+
+/**
+  * @brief Get the height of the character.
+  *
+  * @param[in] glyph the requested character glyph.
+  * @return height of the character.
+  */
+float GetCharacterHeight(const GlyphInfo& glyph);
+
+/**
+  * @brief Get the left point of the character.
+  *
+  * @param[in] glyph the requested character glyph.
+  * @return width of the character.
+  */
+float GetCharacterWidth(const GlyphInfo& glyph);
+
 } // namespace Text
 
 } // namespace Toolkit