TextModel interface
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / visual-model.h
index ad2a137..4dee216 100644 (file)
  *
  */
 
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
 #include <dali/public-api/common/intrusive-ptr.h>
 #include <dali/public-api/object/ref-object.h>
+
+// INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/text-definitions.h>
 
 namespace Dali
@@ -61,6 +63,9 @@ public:
   /**
    * @brief Replaces any glyphs previously set.
    *
+   * @note If the number of glyphs is zero, all buffers are cleared.
+   * @note If one pointer is NULL and the number of glyphs is not zero, the buffer is not touched.
+   *
    * @param[in] glyphs An array of glyphs in the visual order.
    * @param[in] characterIndices An array containing the first character in the logical model that each glyph relates to.
    * @param[in] charactersPerGlyph An array containing the number of characters per glyph.
@@ -99,6 +104,24 @@ public:
    */
   const GlyphInfo& GetGlyphInfo( GlyphIndex glyphIndex ) const;
 
+  /**
+   * Replaces glyphs.
+   *
+   * If the @p numberOfGlyphsToRemove is zero, this operation is like an insert.
+   * If the @p numberOfGlyphsToInsert is zero, this operation is like a remove.
+   *
+   * @param[in] glyphIndex Where to replace the glyphs.
+   * @param[in] numberOfGlyphsToRemove The number of glyphs to be removed.
+   * @param[in] glyphs Pointer to a buffer with the new glyphs.
+   * @param[in] numberOfCharacters Pointer to a buffer with the number of characters per glyph.
+   * @param[in] numberOfGlyphsToInsert The number of new glyphs in the buffer.
+   */
+  void ReplaceGlyphs( GlyphIndex glyphIndex,
+                      Length numberOfGlyphsToRemove,
+                      const GlyphInfo* const glyphs,
+                      const Length* const numberOfCharacters,
+                      Length numberOfGlyphsToInsert );
+
   // Character <--> Glyph conversion
 
   /**
@@ -143,6 +166,19 @@ public:
                                Length numberOfCharacters ) const;
 
   /**
+   * Retrieves the whole or part of the glyph to character conversion map.
+   *
+   * The size of the buffer needs to be big enough to copy the @p numberOfGlyphs.
+   *
+   * @param[out] glyphToCharacter Pointer to a buffer where the conversion map is copied.
+   * @param[in] glyphIndex Index to the first glyph.
+   * @param[in] numberOfGlyphs The number of glyphs.
+   */
+  void GetGlyphToCharacterMap( CharacterIndex* glyphToCharacter,
+                               GlyphIndex glyphIndex,
+                               Length numberOfGlyphs ) const;
+
+  /**
    * Retrieves for each glyph the number of characters the glyph represents.
    *
    * @param[out] charactersPerGlyph Pointer to a buffer where the number of characters for each glyph are copied.
@@ -154,23 +190,23 @@ public:
                                  Length numberOfGlyphs ) const;
 
   /**
-   * Retrieves the whole or part of the glyph to character conversion map.
-   *
-   * The size of the buffer needs to be big enough to copy the @p numberOfGlyphs.
+   * Retrieves for each character the number of glyphs the character is shaped.
    *
-   * @param[out] glyphToCharacter Pointer to a buffer where the conversion map is copied.
-   * @param[in] glyphIndex Index to the first glyph.
-   * @param[in] numberOfGlyphs The number of glyphs.
+   * @param[out] glyphsPerCharacter Pointer to a buffer where the number of glyphs for each character are copied.
+   * @param[in] characterIndex Index to the first character.
+   * @param[in] numberOfCharacters The number of characters.
    */
-  void GetGlyphToCharacterMap( CharacterIndex* glyphToCharacter,
-                               GlyphIndex glyphIndex,
-                               Length numberOfGlyphs ) const;
+  void GetGlyphsPerCharacterMap( Length* glyphsPerCharacter,
+                                 CharacterIndex characterIndex,
+                                 Length numberOfCharacters ) const;
 
   // Position interface
 
   /**
    * @brief Replaces any glyph positions previously set.
    *
+   * @note If the number of glyphs is zero the position buffer is cleared.
+   *
    * @param[in] glyphPositions An array of visual positions for each glyph.
    * @param[in] numberOfGlyphs The number of positions.
    */
@@ -178,6 +214,14 @@ public:
                           Length numberOfGlyphs );
 
   /**
+   * Retrieves the number of glyph positions set.
+   *
+   * @note This may be less than the number of glyphs in the model.
+   * @return The number of glyphs.
+   */
+  Length GetNumberOfGlyphPositions() const;
+
+  /**
    * @brief Retrieves the glyph positions.
    *
    * @pre The size of the @p positions buffer needs to be big enough to copy the @p numberOfGlyphs positions.
@@ -198,6 +242,22 @@ public:
    */
   const Vector2& GetGlyphPosition( GlyphIndex glyphIndex ) const;
 
+  /**
+   * Replaces glyph's positions.
+   *
+   * If the @p numberOfGlyphsToRemove is zero, this operation is like an insert.
+   * If the @p numberOfGlyphsToInsert is zero, this operation is like a remove.
+   *
+   * @param[in] glyphIndex Where to replace the glyph's positions.
+   * @param[in] numberOfGlyphsToRemove The number of glyph's positions to be removed.
+   * @param[in] positions Pointer to a buffer with the new glyph's positions.
+   * @param[in] numberOfGlyphsToInsert The number of new glyph's positions in the buffer.
+   */
+  void ReplaceGlyphPositions( GlyphIndex glyphIndex,
+                              Length numberOfGlyphsToRemove,
+                              const Vector2* const positions,
+                              Length numberOfGlyphsToInsert );
+
   // Line interface.
 
   /**
@@ -207,6 +267,8 @@ public:
    *
    * Every line is an item run containing the index to the first glyph of the line and the number of glyphs.
    *
+   * @note If the number of lines is zero or the pointer is NULL, the lines buffer is cleared.
+   *
    * @param[in] lines Pointer to a buffer containing all the line runs.
    * @param[in] numberOfLines The number of lines in the buffer.
    */
@@ -241,8 +303,8 @@ public:
    *
    * @return The number of lines.
    */
-  TextAbstraction::Length GetNumberOfLines( GlyphIndex glyphIndex,
-                                            Length numberOfGlyphs ) const;
+  Length GetNumberOfLines( GlyphIndex glyphIndex,
+                           Length numberOfGlyphs ) const;
   /**
    * Retrieves the lines where the given range of glyphs is laid out.
    *
@@ -256,6 +318,22 @@ public:
                              GlyphIndex glyphIndex,
                              Length numberOfGlyphs ) const;
 
+  /**
+   * Replaces lines for the given range of glyphs.
+   *
+   * If the @p numberOfGlyphsToRemove is zero, this operation is like an insert.
+   * If the @p numberOfGlyphsToInsert is zero, this operation is like a remove.
+   *
+   * @param[in] glyphIndex Index of the first glyph where to replace the line info.
+   * @param[in] numberOfGlyphsToRemove The number of glyphs to be the line info removed.
+   * @param[in] lines Pointer to a buffer with the lines.
+   * @param[in] numberOfGlyphsToInsert The number of characters to be the line info inserted.
+   */
+  void ReplaceLines( GlyphIndex glyphIndex,
+                     Length numberOfGlyphsToRemove,
+                     const LineRun* const lines,
+                     Length numberOfGlyphsToInsert );
+
   // Size interface
 
   /**