Merge "Stop setting crazy Z value with controls (at the moment depth is ignored by...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / visual-model-impl.h
index aa8a75f..32ab386 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/common/intrusive-ptr.h>
+#include <dali/public-api/math/vector2.h>
 #include <dali/public-api/math/vector4.h>
 #include <dali/public-api/object/ref-object.h>
 
 namespace Dali
 {
 
-struct Vector2;
-
 namespace Toolkit
 {
 
 namespace Text
 {
 
-struct LineRun;
 class VisualModel;
 typedef IntrusivePtr<VisualModel> VisualModelPtr;
 
@@ -63,22 +61,6 @@ public:
   // Glyph interface.
 
   /**
-   * @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.
-   * @param[in] numberOfGlyphs The number of glyphs.
-   */
-  void SetGlyphs( const GlyphInfo* glyphs,
-                  const CharacterIndex* characterIndices,
-                  const Length* charactersPerGlyph,
-                  Length numberOfGlyphs );
-
-  /**
    * @brief Creates the character to glyph conversion table.
    *
    * @pre The glyphs per character table needs to be created first.
@@ -95,13 +77,6 @@ public:
   void CreateGlyphsPerCharacterTable( Length numberOfCharacters = 0u );
 
   /**
-   * @brief Retrieves the number of glyphs.
-   *
-   * @return The number of glyphs.
-   */
-  Length GetNumberOfGlyphs() const;
-
-  /**
    * @brief Retrieves glyphs in the given buffer.
    *
    * The size of the @p glyphs buffer needs to be big enough to copy the @p numberOfGlyphs.
@@ -113,101 +88,9 @@ public:
                   GlyphIndex glyphIndex,
                   Length numberOfGlyphs ) const;
 
-  /**
-   * @brief Retrieves a glyph.
-   *
-   * @param[in] glyphIndex Index to a glyph.
-   *
-   * @return A glyph.
-   */
-  const GlyphInfo& GetGlyphInfo( GlyphIndex glyphIndex ) const;
-
-  /**
-   * @brief 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
 
   /**
-   * @brief Retrieves the first character in the logical model which a glyph represents.
-   *
-   * @note After shaping several characters may be represented by the same glyph.
-   * Alternatively several glyphs may be required to display a character.
-   * @param[in] glyphIndex The glyph index.
-   * @return The character index.
-   */
-  CharacterIndex GetCharacterIndex( GlyphIndex glyphIndex ) const;
-
-  /**
-   * @brief Query the number of characters the glyph represents.
-   *
-   * @param[in] glyphIndex The glyph index.
-   * @return The number of characters represented by the glyph.
-   */
-  Length GetCharactersPerGlyph( GlyphIndex glyphIndex ) const;
-
-  /**
-   * @brief Retrieves the first glyph in the visual model which represents a given character.
-   *
-   * @note After shaping several characters may be represented by the same glyph.
-   * Alternatively several glyphs may be required to display a character.
-   * @param[in] characterIndex The character index.
-   * @return The glyph index.
-   */
-  GlyphIndex GetGlyphIndex( CharacterIndex characterIndex ) const;
-
-  /**
-   * @brief Retrieves the whole or part of the character to glyph conversion map.
-   *
-   * The size of the buffer needs to be big enough to copy the @p numberOfCharacters.
-   *
-   * @param[out] characterToGlyphMap Pointer to a buffer where the conversion map is copied.
-   * @param[in] characterIndex Index to the first character.
-   * @param[in] numberOfCharacters The number of characters.
-   */
-  void GetCharacterToGlyphMap( GlyphIndex* characterToGlyphMap,
-                               CharacterIndex characterIndex,
-                               Length numberOfCharacters ) const;
-
-  /**
-   * @brief 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;
-
-  /**
-   * @brief 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.
-   * @param[in] glyphIndex Index to the first glyph.
-   * @param[in] numberOfGlyphs The number of glyphs.
-   */
-  void GetCharactersPerGlyphMap( Length* charactersPerGlyph,
-                                 GlyphIndex glyphIndex,
-                                 Length numberOfGlyphs ) const;
-
-  /**
    * @brief Retrieves for each character the number of glyphs the character is shaped.
    *
    * @param[out] glyphsPerCharacter Pointer to a buffer where the number of glyphs for each character are copied.
@@ -221,25 +104,6 @@ public:
   // 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.
-   */
-  void SetGlyphPositions( const Vector2* glyphPositions,
-                          Length numberOfGlyphs );
-
-  /**
-   * @brief 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.
@@ -251,69 +115,9 @@ public:
                           GlyphIndex glyphIndex,
                           Length numberOfGlyphs ) const;
 
-  /**
-   * @brief Retrieve the glyph's position of the given glyph.
-   *
-   * @param[in] glyphIndex Index to the glyph.
-   *
-   * @return The glyph's position.
-   */
-  const Vector2& GetGlyphPosition( GlyphIndex glyphIndex ) const;
-
-  /**
-   * @brief 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.
 
   /**
-   * @brief Sets the lines.
-   *
-   * Replaces any lines previously set.
-   *
-   * 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.
-   */
-  void SetLines( const LineRun* const lines,
-                 Length numberOfLines );
-
-  /**
-   * @brief Retrieves the number of lines of the whole text.
-   *
-   * @return The number of lines.
-   */
-  Length GetNumberOfLines() const;
-
-  /**
-   * @brief Retrieves lines.
-   *
-   * The size of the @p lines buffer needs to be big enough to copy the @p numberOfLines.
-   *
-   * @param[out] lines Pointer to a buffer where the lines are copied.
-   * @param[in] lineIndex Index to the first line.
-   * @param[in] numberOfLines Number of lines to be copied.
-   */
-  void GetLines( LineRun* lines,
-                 LineIndex lineIndex,
-                 Length numberOfLines ) const;
-
-  /**
    * @brief Retrieves the number of lines and the index to the first line where the given range of glyphs is laid out.
    *
    * @param[in] glyphIndex Index to the first glyph.
@@ -325,6 +129,7 @@ public:
                          Length numberOfGlyphs,
                          LineIndex& firstLine,
                          Length& numberOfLines ) const;
+
   /**
    * @brief Retrieves the lines where the given range of glyphs is laid out.
    *
@@ -339,15 +144,6 @@ public:
                              Length numberOfGlyphs ) const;
 
   /**
-   * @brief Retrieves the line index where the glyph is laid-out.
-   *
-   * @param[in] glyphIndex The glyph's index.
-   *
-   * @return The line index.
-   */
-  LineIndex GetLineOfGlyph( GlyphIndex glyphIndex );
-
-  /**
    * @brief Retrieves the line index where the character is laid-out.
    *
    * @param[in] characterIndex The character's index.
@@ -356,22 +152,6 @@ public:
    */
   LineIndex GetLineOfCharacter( CharacterIndex characterIndex );
 
-  /**
-   * @brief 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
 
   /**
@@ -477,6 +257,20 @@ public:
    */
   void ClearCaches();
 
+  /**
+   * @brief Set the override used for underline height, 0 indicates height will be come from font metrics
+   *
+   * @param[in] height The height in pixels of the underline
+   */
+  void SetUnderlineHeight( float height );
+
+  /**
+   * @brief Retrieves the underline height override
+   *
+   * @return Returns the override height for an underline, 0 indicates that font metrics will determine the height
+   */
+  float GetUnderlineHeight() const;
+
 protected:
 
   /**
@@ -507,10 +301,12 @@ public:
   Vector<Vector2>        mGlyphPositions;       ///< For each glyph, the position.
   Vector<LineRun>        mLines;                ///< The laid out lines.
 
+  Vector2                mControlSize;           ///< The size of the UI control the decorator is adding it's decorations to.
   Vector4                mTextColor;            ///< The text color
   Vector4                mShadowColor;          ///< Color of drop shadow
   Vector4                mUnderlineColor;       ///< Color of underline
   Vector2                mShadowOffset;         ///< Offset for drop shadow, 0 indicates no shadow
+  float                  mUnderlineHeight;      ///< Fixed height for underline to override font metrics.
 
 private:
 
@@ -521,8 +317,10 @@ private:
   LineIndex mCachedLineIndex; ///< Used to increase performance in consecutive calls to GetLineOfGlyph() or GetLineOfCharacter() with consecutive glyphs or characters.
 
 public:
+
   bool                   mUnderlineEnabled:1;   ///< Underline enabled flag
   bool                   mUnderlineColorSet:1;  ///< Has the underline color been explicitly set?
+
 };
 
 } // namespace Text