TextModel interface. 35/34835/7
authorVictor Cebollada <v.cebollada@samsung.com>
Tue, 3 Feb 2015 10:39:24 +0000 (10:39 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Wed, 18 Feb 2015 17:11:09 +0000 (17:11 +0000)
Change-Id: I630492ffd846dbb1c84254c10585045ae27da7bf
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali-toolkit/public-api/text/text-definitions.h
dali-toolkit/public-api/text/visual-model.cpp
dali-toolkit/public-api/text/visual-model.h

index 981c5eb..d991384 100644 (file)
@@ -33,22 +33,23 @@ namespace Toolkit
 namespace Text
 {
 
 namespace Text
 {
 
-typedef TextAbstraction::FontId          FontId;          ///< The unique identifier for a font face (generated by FontClient).
-typedef TextAbstraction::FontMetrics     FontMetrics;     ///< The metrics for a Font expressed in 26.6 fractional pixel format.
-typedef TextAbstraction::PointSize26Dot6 PointSize26Dot6; ///< The point size in 26.6 fractional points.
-typedef TextAbstraction::FaceIndex       FaceIndex;       ///< Used with fonts which allow several font faces.
-typedef TextAbstraction::GlyphIndex      GlyphIndex;      ///< Uniquely identifies a glyph within a particular font.
-typedef TextAbstraction::Character       Character;       ///< A UTF-32 representation of a character.
-typedef TextAbstraction::GlyphInfo       GlyphInfo;       ///< The information describing a glyph (font ID, index, metrics).
-typedef TextAbstraction::CharacterIndex  CharacterIndex;  ///< An index into an array of characters.
-typedef TextAbstraction::Length          Length;          ///< The length of an array.
-typedef TextAbstraction::BidiInfoIndex   BidiInfoIndex;   ///< Index to the bidirectional info for a paragraph.
-typedef TextAbstraction::Script          Script;          ///< The character's script.
-typedef TextAbstraction::LineBreakInfo   LineBreakInfo;   ///< Line break info (must break, allow break, no break). Possible values are: @e LINE_MUST_BREAK, @e LINE_ALLOW_BREAK and @e LINE_NO_BREAK (in the TextAbstraction namespace).
-typedef TextAbstraction::WordBreakInfo   WordBreakInfo;   ///< Word break info (break, no break). Possible values are: @e WORD_BREAK and @e WORD_NO_BREAK (in the TextAbstraction namespace).
-
-typedef uint32_t GlyphIndex;         ///< An index into an array of glyphs
-typedef bool     CharacterDirection; ///< The character's direction: @e false is left to right, @e true is right to left.
+typedef TextAbstraction::FontId          FontId;             ///< The unique identifier for a font face (generated by FontClient).
+typedef TextAbstraction::FontMetrics     FontMetrics;        ///< The metrics for a Font expressed in 26.6 fractional pixel format.
+typedef TextAbstraction::PointSize26Dot6 PointSize26Dot6;    ///< The point size in 26.6 fractional points.
+typedef TextAbstraction::FaceIndex       FaceIndex;          ///< Used with fonts which allow several font faces.
+typedef TextAbstraction::GlyphIndex      GlyphIndex;         ///< Uniquely identifies a glyph within a particular font.
+typedef TextAbstraction::Character       Character;          ///< A UTF-32 representation of a character.
+typedef TextAbstraction::GlyphInfo       GlyphInfo;          ///< The information describing a glyph (font ID, index, metrics).
+typedef TextAbstraction::CharacterIndex  CharacterIndex;     ///< An index into an array of characters.
+typedef TextAbstraction::Length          Length;             ///< The length of an array.
+typedef TextAbstraction::BidiInfoIndex   BidiInfoIndex;      ///< Index to the bidirectional info for a paragraph.
+typedef TextAbstraction::Script          Script;             ///< The character's script.
+typedef TextAbstraction::LineBreakInfo   LineBreakInfo;      ///< Line break info (must break, allow break, no break). Possible values are: @e LINE_MUST_BREAK, @e LINE_ALLOW_BREAK and @e LINE_NO_BREAK (in the TextAbstraction namespace).
+typedef TextAbstraction::WordBreakInfo   WordBreakInfo;      ///< Word break info (break, no break). Possible values are: @e WORD_BREAK and @e WORD_NO_BREAK (in the TextAbstraction namespace).
+
+typedef uint32_t                         GlyphIndex;         ///< An index into an array of glyphs.
+typedef bool                             CharacterDirection; ///< The character's direction: @e false is left to right, @e true is right to left.
+typedef uint32_t                         LineIndex;          ///< An index into an array of lines.
 
 } // namespace Text
 
 
 } // namespace Text
 
index da7bcdf..20285a6 100644 (file)
@@ -21,6 +21,7 @@
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/math/vector2.h>
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/math/vector2.h>
+#include <dali-toolkit/public-api/text/line-run.h>
 
 // EXTERNAL INCLUDES
 #include <memory.h>
 
 // EXTERNAL INCLUDES
 #include <memory.h>
@@ -35,6 +36,8 @@ namespace Toolkit
 namespace Text
 {
 
 namespace Text
 {
 
+const GlyphInfo GLYPH_INFO; // VCC to be removed.
+
 struct VisualModel::Impl
 {
   Vector<GlyphInfo>      mGlyphs;
 struct VisualModel::Impl
 {
   Vector<GlyphInfo>      mGlyphs;
@@ -79,6 +82,11 @@ void VisualModel::GetGlyphs( GlyphIndex glyphIndex,
   memcpy( glyphs, &modelGlyphs[glyphIndex], numberOfGlyphs*sizeof(GlyphInfo) );
 }
 
   memcpy( glyphs, &modelGlyphs[glyphIndex], numberOfGlyphs*sizeof(GlyphInfo) );
 }
 
+const GlyphInfo& VisualModel::GetGlyphInfo( GlyphIndex glyphIndex ) const
+{
+  return GLYPH_INFO;
+}
+
 CharacterIndex VisualModel::GetCharacterIndex( GlyphIndex glyphIndex ) const
 {
   return mImpl->mGlyphsToCharacters[glyphIndex];
 CharacterIndex VisualModel::GetCharacterIndex( GlyphIndex glyphIndex ) const
 {
   return mImpl->mGlyphsToCharacters[glyphIndex];
@@ -105,6 +113,24 @@ GlyphIndex VisualModel::GetGlyphIndex( CharacterIndex characterIndex ) const
   return index;
 }
 
   return index;
 }
 
+void VisualModel::GetCharacterToGlyphMap( GlyphIndex* characterToGlyphMap,
+                                          CharacterIndex characterIndex,
+                                          Length numberOfCharacters ) const
+{
+}
+
+void VisualModel::GetCharactersPerGlyphMap( Length* charactersPerGlyph,
+                                            GlyphIndex glyphIndex,
+                                            Length numberOfGlyphs ) const
+{
+}
+
+void VisualModel::GetGlyphToCharacterMap( CharacterIndex* glyphToCharacter,
+                                          GlyphIndex glyphIndex,
+                                          Length numberOfGlyphs ) const
+{
+}
+
 void VisualModel::SetGlyphPositions( const Vector2* glyphPositions,
                                      Length numberOfGlyphs )
 {
 void VisualModel::SetGlyphPositions( const Vector2* glyphPositions,
                                      Length numberOfGlyphs )
 {
@@ -121,6 +147,57 @@ void VisualModel::GetGlyphPositions( GlyphIndex glyphIndex,
   memcpy( glyphPositions, &modelPositions[0], numberOfGlyphs*sizeof(Vector2) );
 }
 
   memcpy( glyphPositions, &modelPositions[0], numberOfGlyphs*sizeof(Vector2) );
 }
 
+const Vector2& VisualModel::GetGlyphPosition( GlyphIndex glyphIndex ) const
+{
+  return Vector2::ZERO;
+}
+
+void VisualModel::SetLines( const LineRun* const lines,
+                            Length numberOfLines )
+{
+}
+
+Length VisualModel::GetNumberOfLines() const
+{
+  return 0u;
+}
+
+void VisualModel::GetLines( LineRun* lines,
+                            LineIndex lineIndex,
+                            Length numberOfLines ) const
+{
+}
+
+Length VisualModel::GetNumberOfLines( GlyphIndex glyphIndex,
+                                      Length numberOfGlyphs ) const
+{
+  return 0u;
+}
+
+void VisualModel::GetLinesOfGlyphRange( LineRun* lines,
+                                        GlyphIndex glyphIndex,
+                                        Length numberOfGlyphs ) const
+{
+}
+
+void VisualModel::SetNaturalSize( const Vector2& size  )
+{
+}
+
+const Vector2& VisualModel::GetNaturalSize() const
+{
+  return Vector2::ZERO;
+}
+
+void VisualModel::SetActualSize( const Vector2& size )
+{
+}
+
+const Vector2& VisualModel::GetActualSize() const
+{
+  return Vector2::ZERO;
+}
+
 VisualModel::~VisualModel()
 {
   delete mImpl;
 VisualModel::~VisualModel()
 {
   delete mImpl;
index d47293d..71b0514 100644 (file)
@@ -34,6 +34,7 @@ namespace Toolkit
 namespace Text
 {
 
 namespace Text
 {
 
+struct LineRun;
 class VisualModel;
 typedef IntrusivePtr<VisualModel> VisualModelPtr;
 
 class VisualModel;
 typedef IntrusivePtr<VisualModel> VisualModelPtr;
 
@@ -89,6 +90,15 @@ public:
                   GlyphInfo* glyphs,
                   Length numberOfGlyphs ) const;
 
                   GlyphInfo* glyphs,
                   Length numberOfGlyphs ) const;
 
+  /**
+   * Retrieves a glyph.
+   *
+   * @param[in] glyphIndex Index to a glyph.
+   *
+   * @return A glyph.
+   */
+  const GlyphInfo& GetGlyphInfo( GlyphIndex glyphIndex ) const;
+
   // Character <--> Glyph conversion
 
   /**
   // Character <--> Glyph conversion
 
   /**
@@ -119,6 +129,43 @@ public:
    */
   GlyphIndex GetGlyphIndex( CharacterIndex characterIndex ) const;
 
    */
   GlyphIndex GetGlyphIndex( CharacterIndex characterIndex ) const;
 
+  /**
+   * 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;
+
+  /**
+   * 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;
+
+  /**
+   * 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;
+
   // Position interface
 
   /**
   // Position interface
 
   /**
@@ -142,6 +189,103 @@ public:
                           Vector2* glyphPositions,
                           Length numberOfGlyphs ) const;
 
                           Vector2* glyphPositions,
                           Length numberOfGlyphs ) const;
 
+  /**
+   * 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;
+
+  // Line interface.
+
+  /**
+   * 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.
+   *
+   * @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 );
+
+  /**
+   * Retrieves the number of lines of the whole text.
+   *
+   * @return The number of lines.
+   */
+  Length GetNumberOfLines() const;
+
+  /**
+   * 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;
+
+  /**
+   * Retrieves the number of lines where the given range of glyphs is laid out.
+   *
+   * @param[in] glyphIndex Index to the first glyph.
+   * @param[in] numberOfGlyphs The number of glyph.
+   *
+   * @return The number of lines.
+   */
+  TextAbstraction::Length GetNumberOfLines( GlyphIndex glyphIndex,
+                                            Length numberOfGlyphs ) const;
+  /**
+   * Retrieves the lines where the given range of glyphs is laid out.
+   *
+   * 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] glyphIndex Index to the first glyphs of the range.
+   * @param[in] numberOfGlyphs Number of glyphs in the range.
+   */
+  void GetLinesOfGlyphRange( LineRun* lines,
+                             GlyphIndex glyphIndex,
+                             Length numberOfGlyphs ) const;
+
+  // Size interface
+
+  /**
+   * Sets the natural size.
+   *
+   * @param[in] size The text's natural size.
+   */
+  void SetNaturalSize( const Vector2& size  );
+
+  /**
+   * Retrieves the natural size.
+   *
+   * @return The text's natural size.
+   */
+  const Vector2& GetNaturalSize() const;
+
+  /**
+   * Sets the text's actual size after it has been laid out.
+   *
+   * @param[in] size The text's size.
+   */
+  void SetActualSize( const Vector2& size );
+
+  /**
+   * Retrieves the text's actual size after it has been laid out.
+   *
+   * @return The text's size.
+   */
+  const Vector2& GetActualSize() const;
+
 protected:
 
   /**
 protected:
 
   /**