Merge "Text Selection Popup to use bounding box and table views" into tizen
authorPaul Wisbey <p.wisbey@samsung.com>
Wed, 15 Apr 2015 17:33:29 +0000 (10:33 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 15 Apr 2015 17:33:29 +0000 (10:33 -0700)
27 files changed:
dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp
dali-toolkit/internal/atlas-manager/atlas-manager-impl.h
dali-toolkit/internal/atlas-manager/atlas-manager.cpp
dali-toolkit/internal/atlas-manager/atlas-manager.h
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.h
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
docs/content/example-code/property-example.cpp
docs/content/images/actors/Text-Actor.png [deleted file]
docs/content/images/actors/Text-Label.png [new file with mode: 0644]
docs/content/images/text-controls/HelloWorld-HeightForWidth.png [new file with mode: 0644]
docs/content/images/text-controls/HelloWorld-NaturalSize.png [new file with mode: 0644]
docs/content/images/text-controls/PlainText.png [new file with mode: 0644]
docs/content/images/text-controls/RedText.png [new file with mode: 0644]
docs/content/images/text-controls/TextWith1pxUnderline.png [new file with mode: 0644]
docs/content/images/text-controls/TextWithBiggerShadow.png [new file with mode: 0644]
docs/content/images/text-controls/TextWithColorShadow.png [new file with mode: 0644]
docs/content/images/text-controls/TextWithColorUnderline.png [new file with mode: 0644]
docs/content/images/text-controls/TextWithShadow.png [new file with mode: 0644]
docs/content/images/text-controls/TextWithUnderline.png [new file with mode: 0644]
docs/content/programming-guide/hello-world.h
docs/content/programming-guide/properties.h
docs/content/programming-guide/script-hello.h
docs/content/programming-guide/size-negotiation.h
docs/content/programming-guide/text-label.h

index 83bb423..853c0ae 100644 (file)
@@ -33,19 +33,24 @@ namespace Internal
 
 namespace
 {
-  const Vector2 DEFAULT_ATLAS_SIZE( 512.0f, 512.0f );
-  const Vector2 DEFAULT_BLOCK_SIZE( 32.0f, 32.0f );
+  const uint32_t DEFAULT_ATLAS_WIDTH( 512u );
+  const uint32_t DEFAULT_ATLAS_HEIGHT( 512u );
+  const uint32_t DEFAULT_BLOCK_WIDTH( 16u );
+  const uint32_t DEFAULT_BLOCK_HEIGHT( 16u );
   const uint32_t SINGLE_PIXEL_PADDING( 1u );
   const uint32_t DOUBLE_PIXEL_PADDING( SINGLE_PIXEL_PADDING << 1 );
   const uint32_t FILLED_PIXEL( -1 );
+  Toolkit::AtlasManager::AtlasSize EMPTY_SIZE;
 }
 
 AtlasManager::AtlasManager()
-: mNewAtlasSize( DEFAULT_ATLAS_SIZE ),
-  mNewBlockSize( DEFAULT_BLOCK_SIZE ),
-  mAddFailPolicy( Toolkit::AtlasManager::FAIL_ON_ADD_CREATES ),
+: mAddFailPolicy( Toolkit::AtlasManager::FAIL_ON_ADD_CREATES ),
   mFilledPixel( FILLED_PIXEL )
 {
+  mNewAtlasSize.mWidth = DEFAULT_ATLAS_WIDTH;
+  mNewAtlasSize.mHeight = DEFAULT_ATLAS_HEIGHT;
+  mNewAtlasSize.mBlockWidth = DEFAULT_BLOCK_WIDTH;
+  mNewAtlasSize.mBlockHeight = DEFAULT_BLOCK_HEIGHT;
 }
 
 AtlasManagerPtr AtlasManager::New()
@@ -62,12 +67,13 @@ AtlasManager::~AtlasManager()
   }
 }
 
-Toolkit::AtlasManager::AtlasId AtlasManager::CreateAtlas( SizeType width,
-                                                          SizeType height,
-                                                          SizeType blockWidth,
-                                                          SizeType blockHeight,
-                                                          Pixel::Format pixelformat )
+Toolkit::AtlasManager::AtlasId AtlasManager::CreateAtlas( const Toolkit::AtlasManager::AtlasSize& size, Pixel::Format pixelformat )
 {
+  SizeType width = size.mWidth;
+  SizeType height = size.mHeight;
+  SizeType blockWidth = size.mBlockWidth;
+  SizeType blockHeight = size.mBlockHeight;
+
   // Check to see if the atlas is large enough to hold a single block even ?
   if ( blockWidth > width || blockHeight > height )
   {
@@ -79,10 +85,7 @@ Toolkit::AtlasManager::AtlasId AtlasManager::CreateAtlas( SizeType width,
   Dali::Atlas atlas = Dali::Atlas::New( width, height, pixelformat );
   AtlasDescriptor atlasDescriptor;
   atlasDescriptor.mAtlas = atlas;
-  atlasDescriptor.mWidth = width;
-  atlasDescriptor.mHeight = height;
-  atlasDescriptor.mBlockWidth = blockWidth;
-  atlasDescriptor.mBlockHeight = blockHeight;
+  atlasDescriptor.mSize = size;
   atlasDescriptor.mPixelFormat = pixelformat;
   std::stringstream materialLabel;
   materialLabel << "Atlas Material - ";
@@ -152,7 +155,7 @@ void AtlasManager::Add( const BufferImage& image,
   {
     if ( Toolkit::AtlasManager::FAIL_ON_ADD_CREATES == mAddFailPolicy )
     {
-      SizeType newAtlas = CreateAtlas( mNewAtlasSize.x, mNewAtlasSize.y, mNewBlockSize.x, mNewBlockSize.y, pixelFormat );
+      SizeType newAtlas = CreateAtlas( mNewAtlasSize, pixelFormat );
       if ( !newAtlas-- )
       {
         return;
@@ -237,8 +240,8 @@ AtlasManager::SizeType AtlasManager::CheckAtlas( SizeType atlas,
   if ( pixelFormat == mAtlasList[ atlas ].mPixelFormat )
   {
     // Check to see if there are any unused blocks in this atlas to accomodate our image
-    SizeType blocksInX = mAtlasList[ atlas ].mWidth / mAtlasList[ atlas ].mBlockWidth;
-    SizeType blocksInY = mAtlasList[ atlas ].mHeight / mAtlasList[ atlas ].mBlockHeight;
+    SizeType blocksInX = mAtlasList[ atlas ].mSize.mWidth / mAtlasList[ atlas ].mSize.mBlockWidth;
+    SizeType blocksInY = mAtlasList[ atlas ].mSize.mHeight / mAtlasList[ atlas ].mSize.mBlockHeight;
     totalBlocks = blocksInX * blocksInY;
     SizeType blocksFree = mAtlasList[ atlas ].mNextFreeBlock ?
                           totalBlocks - mAtlasList[ atlas ].mNextFreeBlock + 1u :
@@ -246,8 +249,8 @@ AtlasManager::SizeType AtlasManager::CheckAtlas( SizeType atlas,
 
     // Check to see if the image will fit in these blocks, if not we'll need to create a new atlas
     if ( blocksFree
-         && width + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mBlockWidth
-         && height + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mBlockHeight )
+         && width + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mSize.mBlockWidth
+         && height + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mSize.mBlockHeight )
     {
       blockArea = 1u;
       return ( atlas + 1u );
@@ -273,14 +276,14 @@ void AtlasManager::CreateMesh( SizeType atlas,
   meshData.SetHasColor( true );
   meshData.SetHasTextureCoords( true );
 
-  SizeType blockWidth = mAtlasList[ atlas ].mBlockWidth;
-  SizeType blockHeight = mAtlasList[ atlas ].mBlockHeight;
+  SizeType blockWidth = mAtlasList[ atlas ].mSize.mBlockWidth;
+  SizeType blockHeight = mAtlasList[ atlas ].mSize.mBlockHeight;
 
   float vertexBlockWidth = static_cast< float >( blockWidth );
   float vertexBlockHeight = static_cast< float >( blockHeight );
 
-  SizeType width = mAtlasList[ atlas ].mWidth;
-  SizeType height = mAtlasList[ atlas ].mHeight;
+  SizeType width = mAtlasList[ atlas ].mSize.mWidth;
+  SizeType height = mAtlasList[ atlas ].mSize.mHeight;
 
   SizeType atlasWidthInBlocks = width / blockWidth;
 
@@ -581,9 +584,9 @@ void AtlasManager::UploadImage( const BufferImage& image,
     return;
   }
 
-  SizeType atlasBlockWidth = mAtlasList[ atlas ].mBlockWidth;
-  SizeType atlasBlockHeight = mAtlasList[ atlas ].mBlockHeight;
-  SizeType atlasWidthInBlocks = mAtlasList[ atlas ].mWidth / mAtlasList[ atlas ].mBlockWidth;
+  SizeType atlasBlockWidth = mAtlasList[ atlas ].mSize.mBlockWidth;
+  SizeType atlasBlockHeight = mAtlasList[ atlas ].mSize.mBlockHeight;
+  SizeType atlasWidthInBlocks = mAtlasList[ atlas ].mSize.mWidth / mAtlasList[ atlas ].mSize.mBlockWidth;
 
   SizeType block = desc.mBlocksList[ 0 ];
   SizeType blockX = block % atlasWidthInBlocks;
@@ -624,7 +627,7 @@ void AtlasManager::UploadImage( const BufferImage& image,
   }
 
   // Blit bottom strip
-  if ( blockOffsetY + height + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mHeight )
+  if ( blockOffsetY + height + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mSize.mHeight )
   {
     if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mHorizontalStrip,
                                              blockOffsetX,
@@ -635,7 +638,7 @@ void AtlasManager::UploadImage( const BufferImage& image,
   }
 
   // Blit right strip
-  if ( blockOffsetX + width + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mWidth )
+  if ( blockOffsetX + width + DOUBLE_PIXEL_PADDING <= mAtlasList[ atlas ].mSize.mWidth )
   {
     if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mVerticalStrip,
                                              blockOffsetX + width + SINGLE_PIXEL_PADDING,
@@ -656,13 +659,13 @@ void AtlasManager::GenerateMeshData( ImageId id,
   SizeType width = mImageList[ imageId ].mImageWidth;
   SizeType height = mImageList[ imageId ].mImageHeight;
 
-  SizeType widthInBlocks = width / mAtlasList[ atlas ].mBlockWidth;
-  if ( width % mAtlasList[ atlas ].mBlockWidth )
+  SizeType widthInBlocks = width / mAtlasList[ atlas ].mSize.mBlockWidth;
+  if ( width % mAtlasList[ atlas ].mSize.mBlockWidth )
   {
     widthInBlocks++;
   }
-  SizeType heightInBlocks = height / mAtlasList[ atlas ].mBlockHeight;
-  if ( height % mAtlasList[ atlas ].mBlockHeight )
+  SizeType heightInBlocks = height / mAtlasList[ atlas ].mSize.mBlockHeight;
+  if ( height % mAtlasList[ atlas ].mSize.mBlockHeight )
   {
     heightInBlocks++;
   }
@@ -704,7 +707,7 @@ bool AtlasManager::Remove( ImageId id )
     return false;
   }
 
-  if ( 1u == --mImageList[ imageId ].mCount )
+  if ( 2u > --mImageList[ imageId ].mCount )
   {
     // 'Remove the blocks' from this image and add to the atlas' freelist
     removed = true;
@@ -730,37 +733,20 @@ AtlasManager::AtlasId AtlasManager::GetAtlas( ImageId id ) const
   }
 }
 
-void AtlasManager::SetNewAtlasSize( const Vector2& size,
-                                    const Vector2& blockSize )
+void AtlasManager::SetNewAtlasSize( const Toolkit::AtlasManager::AtlasSize& size )
 {
   mNewAtlasSize = size;
-  mNewBlockSize = blockSize;
-}
-
-Vector2 AtlasManager::GetBlockSize( AtlasId atlas )
-{
-  if ( atlas && atlas <= mAtlasList.size() )
-  {
-  return Vector2( static_cast< float >( mAtlasList[ atlas - 1u ].mBlockWidth ),
-                  static_cast< float >( mAtlasList[ atlas - 1u ].mBlockHeight) );
-  }
-  else
-  {
-    return Vector2::ZERO;
-  }
+  mNewAtlasSize.mBlockWidth += DOUBLE_PIXEL_PADDING;
+  mNewAtlasSize.mBlockHeight += DOUBLE_PIXEL_PADDING;
 }
 
-Vector2 AtlasManager::GetAtlasSize( AtlasId atlas )
+const Toolkit::AtlasManager::AtlasSize& AtlasManager::GetAtlasSize( AtlasId atlas )
 {
-  if ( atlas && atlas <= mAtlasList.size() )
+  if ( atlas && atlas-- <= mAtlasList.size() )
   {
-    return Vector2( static_cast< float >( mAtlasList[ atlas - 1u ].mWidth ),
-                    static_cast< float >( mAtlasList[ atlas - 1u ].mHeight ) );
-  }
-  else
-  {
-    return Vector2::ZERO;
+    return mAtlasList[ atlas ].mSize;
   }
+  return EMPTY_SIZE;
 }
 
 AtlasManager::SizeType AtlasManager::GetFreeBlocks( AtlasId atlas ) const
@@ -768,17 +754,24 @@ AtlasManager::SizeType AtlasManager::GetFreeBlocks( AtlasId atlas ) const
   if ( atlas && atlas <= mAtlasList.size() )
   {
     uint32_t index = atlas - 1u;
-    uint32_t width = mAtlasList[ index ].mWidth;
-    uint32_t height = mAtlasList[ index ].mHeight;
-    uint32_t blockWidth = mAtlasList[ index ].mBlockWidth;
-    uint32_t blockHeight = mAtlasList[ index ].mBlockHeight;
+    uint32_t width = mAtlasList[ index ].mSize.mWidth;
+    uint32_t height = mAtlasList[ index ].mSize.mHeight;
+    uint32_t blockWidth = mAtlasList[ index ].mSize.mBlockWidth;
+    uint32_t blockHeight = mAtlasList[ index ].mSize.mBlockHeight;
 
     SizeType widthInBlocks = width / blockWidth;
     SizeType heightInBlocks = height / blockHeight;
     uint32_t blockCount = widthInBlocks * heightInBlocks;
 
     // Check free previously unallocated blocks and any free blocks
-    blockCount -= mAtlasList[ index ].mNextFreeBlock - mAtlasList[ index ].mFreeBlocksList.Size();
+    if ( mAtlasList[ index ].mNextFreeBlock )
+    {
+      blockCount -= mAtlasList[ index ].mNextFreeBlock -1u - mAtlasList[ index ].mFreeBlocksList.Size();
+    }
+    else
+    {
+      blockCount = mAtlasList[ index ].mFreeBlocksList.Size();
+    }
     return blockCount;
   }
   else
@@ -813,23 +806,15 @@ void AtlasManager::GetMetrics( Toolkit::AtlasManager::Metrics& metrics )
 
   for ( uint32_t i = 0; i < atlasCount; ++i )
   {
-    SizeType width = mAtlasList[ i ].mWidth;
-    SizeType height = mAtlasList[ i ].mHeight;
-    SizeType blockWidth = mAtlasList[ i ].mBlockWidth;
-    SizeType blockHeight = mAtlasList[ i ].mBlockHeight;
-
-    entry.mWidth = width;
-    entry.mHeight = height;
-    entry.mBlockWidth = blockWidth;
-    entry.mBlockHeight = blockHeight;
-    entry.mTotalBlocks = ( width / blockWidth ) * ( height / blockHeight );
+    entry.mSize = mAtlasList[ i ].mSize;
+    entry.mTotalBlocks = ( entry.mSize.mWidth / entry.mSize.mBlockWidth ) * ( entry.mSize.mHeight / entry.mSize.mBlockHeight );
     uint32_t reuseBlocks = mAtlasList[ i ].mFreeBlocksList.Size();
     entry.mBlocksUsed = mAtlasList[ i ].mNextFreeBlock ? mAtlasList[ i ].mNextFreeBlock - reuseBlocks - 1u: entry.mTotalBlocks - reuseBlocks;
     entry.mPixelFormat = GetPixelFormat( i + 1 );
 
       metrics.mAtlasMetrics.PushBack( entry );
 
-    uint32_t size = width * height;
+    uint32_t size = entry.mSize.mWidth * entry.mSize.mHeight;
     if ( entry.mPixelFormat == Pixel::BGRA8888 )
     {
       size <<= 2;
index 0656da7..ef078f8 100644 (file)
@@ -60,10 +60,7 @@ public:
   struct AtlasDescriptor
   {
     Dali::Atlas mAtlas;                                                 // atlas image
-    SizeType mWidth;                                                    // width of atlas
-    SizeType mHeight;                                                   // height of atlas
-    SizeType mBlockWidth;                                               // width of a block in atlas
-    SizeType mBlockHeight;                                              // height of a block in atlas
+    Toolkit::AtlasManager::AtlasSize mSize;                             // size of atlas
     Pixel::Format mPixelFormat;                                         // pixel format used by atlas
     BufferImage mHorizontalStrip;                                       // Image used to pad upload
     BufferImage mVerticalStrip;                                         // Image used to pad upload
@@ -95,11 +92,7 @@ public:
   /**
    * @copydoc: Toolkit::AtlasManager::CreateAtlas
    */
-  AtlasId CreateAtlas( SizeType width,
-                       SizeType height,
-                       SizeType blockWidth,
-                       SizeType blockHeight,
-                       Pixel::Format pixelformat );
+  AtlasId CreateAtlas( const Toolkit::AtlasManager::AtlasSize& size, Pixel::Format pixelformat );
 
   /**
    * @copydoc Toolkit::AtlasManager::SetAddPolicy
@@ -152,13 +145,12 @@ public:
   /**
    * @copydoc Toolkit::AtlasManager::SetNewAtlasSize
    */
-  void SetNewAtlasSize( const Vector2& size,
-                        const Vector2& blockSize );
+  void SetNewAtlasSize( const Toolkit::AtlasManager::AtlasSize& size );
 
   /**
    * @copydoc Toolkit::AtlasManager::GetAtlasSize
    */
-  Vector2 GetAtlasSize( AtlasId atlas );
+  const Toolkit::AtlasManager::AtlasSize& GetAtlasSize( AtlasId atlas );
 
   /**
    * @copydoc Toolkit::AtlasManager::GetBlockSize
@@ -215,8 +207,7 @@ private:
 
   void PrintMeshData( const MeshData& meshData );
 
-  Vector2 mNewAtlasSize;
-  Vector2 mNewBlockSize;
+  Toolkit::AtlasManager::AtlasSize mNewAtlasSize;
   Toolkit::AtlasManager::AddFailPolicy mAddFailPolicy;
   uint32_t mFilledPixel;
 };
index 6d21245..e46eb1d 100644 (file)
@@ -45,13 +45,9 @@ AtlasManager::AtlasManager(Internal::AtlasManager *impl)
 {
 }
 
-AtlasManager::AtlasId AtlasManager::CreateAtlas( SizeType width,
-                                                 SizeType height,
-                                                 SizeType blockWidth,
-                                                 SizeType blockHeight,
-                                                 Pixel::Format pixelformat )
+AtlasManager::AtlasId AtlasManager::CreateAtlas( const AtlasManager::AtlasSize& size, Pixel::Format pixelformat )
 {
-  return GetImplementation(*this).CreateAtlas( width, height, blockWidth, blockHeight, pixelformat );
+  return GetImplementation(*this).CreateAtlas( size, pixelformat );
 }
 
 void AtlasManager::SetAddPolicy( AddFailPolicy policy )
@@ -105,12 +101,7 @@ AtlasManager::AtlasId AtlasManager::GetAtlas( ImageId id )
   return GetImplementation(*this).GetAtlas( id );
 }
 
-Vector2 AtlasManager::GetBlockSize( AtlasId atlas )
-{
-  return GetImplementation(*this).GetBlockSize( atlas );
-}
-
-Vector2 AtlasManager::GetAtlasSize( AtlasId atlas )
+const AtlasManager::AtlasSize& AtlasManager::GetAtlasSize( AtlasId atlas )
 {
   return GetImplementation(*this).GetAtlasSize( atlas );
 }
@@ -120,10 +111,9 @@ AtlasManager::SizeType AtlasManager::GetFreeBlocks( AtlasId atlas )
   return GetImplementation(*this).GetFreeBlocks( atlas );
 }
 
-void AtlasManager::SetNewAtlasSize( const Vector2& size,
-                                    const Vector2& blockSize )
+void AtlasManager::SetNewAtlasSize( const AtlasSize& size )
 {
-  GetImplementation(*this).SetNewAtlasSize( size, blockSize );
+  GetImplementation(*this).SetNewAtlasSize( size );
 }
 
 AtlasManager::SizeType AtlasManager::GetAtlasCount() const
index 9263ea4..5fc10d0 100644 (file)
@@ -160,16 +160,21 @@ public:
   typedef SizeType ImageId;
   static const bool MESH_OPTIMIZE = true;
 
+  struct AtlasSize
+  {
+    SizeType mWidth;              // width of the atlas in pixels
+    SizeType mHeight;             // height of the atlas in pixels
+    SizeType mBlockWidth;         // width of a block in pixels
+    SizeType mBlockHeight;        // height of a block in pixels
+  };
+
   /**
    * Metrics structures to describe Atlas Manager state
    *
    */
   struct AtlasMetricsEntry
   {
-    SizeType mWidth;                 // width of the atlas in pixels
-    SizeType mHeight;;               // height of the atlas in pixels
-    SizeType mBlockWidth;            // width of a block in pixels
-    SizeType mBlockHeight;           // height of a block in pixels
+    AtlasSize mSize;                 // size of atlas and blocks
     SizeType mBlocksUsed;            // number of blocks used in the atlas
     SizeType mTotalBlocks;           // total blocks used by atlas
     Pixel::Format mPixelFormat;      // pixel format of the atlas
@@ -225,19 +230,12 @@ public:
   /**
    * @brief Create a blank atlas of specific dimensions and pixel format with a certain block size
    *
-   * @param[in] width desired atlas width in pixels
-   * @param[in] height desired atlas height in pixels
-   * @param[in] blockWidth block width to use in atlas in pixels
-   * @param[in] blockHeight block height to use in atlas in pixels
+   * @param[in] size desired atlas dimensions
    * @param[in] pixelformat format of a pixel in atlas
    *
    * @return atlas Id
    */
-  AtlasId CreateAtlas(  SizeType width,
-                        SizeType height,
-                        SizeType blockWidth,
-                        SizeType blockHeight,
-                        Pixel::Format pixelformat = Pixel::RGBA8888 );
+  AtlasId CreateAtlas( const AtlasSize& size, Pixel::Format pixelformat = Pixel::RGBA8888 );
 
   /**
    * @brief Set the policy on failure to add an image to an atlas
@@ -322,24 +320,14 @@ public:
    * @return Atlas Id
    */
   AtlasId GetAtlas( ImageId id );
-
-  /**
-   * @brief Get the size of the blocks used in an atlas
-   *
-   * @param[in] atlas AtlasId
-   *
-   * @return width and height of the blocks used
-   */
-  Vector2 GetBlockSize( AtlasId atlas );
-
   /**
    * @brief Get the current size of an atlas
    *
    * @param[in] atlas AtlasId
    *
-   * @return width and height of the atlas
+   * @return AtlasSize structure for the atlas
    */
-  Vector2 GetAtlasSize( AtlasId atlas );
+  const AtlasSize& GetAtlasSize( AtlasId atlas );
 
   /**
    * @brief Get the number of blocks available in an atlas
@@ -353,12 +341,11 @@ public:
   /**
    * @brief Sets the pixel area of any new atlas and also the individual block size
    *
-   * @param[in] size pixel area of atlas
+   * @param[in] size Atlas size structure
    *
    * @param blockSize pixel area in atlas for a block
    */
-  void SetNewAtlasSize( const Vector2& size,
-                        const Vector2& blockSize );
+  void SetNewAtlasSize( const AtlasSize& size );
 
   /**
    * @brief Get the number of atlases created
index 16fdc8a..734b82a 100644 (file)
@@ -110,13 +110,18 @@ void AtlasGlyphManager::Cached( Text::FontId fontId,
 
 Vector2 AtlasGlyphManager::GetAtlasSize( uint32_t atlasId )
 {
-  return mAtlasManager.GetAtlasSize( atlasId );
+  Toolkit::AtlasManager::AtlasSize size = mAtlasManager.GetAtlasSize( atlasId );
+  return Vector2( static_cast< float >( size.mWidth ), static_cast< float >( size.mHeight ) );
 }
 
-void AtlasGlyphManager::SetNewAtlasSize( const Vector2& size,
-                                         const Vector2& blockSize )
+void AtlasGlyphManager::SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight )
 {
-    mAtlasManager.SetNewAtlasSize( size, blockSize );
+  Toolkit::AtlasManager::AtlasSize size;
+  size.mWidth = width;
+  size.mHeight = height;
+  size.mBlockWidth = blockWidth;
+  size.mBlockHeight = blockHeight;
+  mAtlasManager.SetNewAtlasSize( size );
 }
 
 void AtlasGlyphManager::Remove( uint32_t imageId )
index 5068426..cbbe732 100644 (file)
@@ -100,8 +100,7 @@ public:
   /**
    * @copydoc Toolkit::AtlasGlyphManager::SetNewAtlasSize
    */
-  void SetNewAtlasSize( const Vector2& size,
-                        const Vector2& blockSize );
+  void SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight );
 
   /**
    * @copydoc Toolkit::AtlasGlyphManager::Remove
index d46ef18..ccb0efc 100644 (file)
@@ -98,10 +98,9 @@ void AtlasGlyphManager::Cached( Text::FontId fontId,
   GetImplementation(*this).Cached( fontId, index, slot );
 }
 
-void AtlasGlyphManager::SetNewAtlasSize( const Vector2& size,
-                                         const Vector2& blockSize )
+void AtlasGlyphManager::SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight )
 {
-  GetImplementation(*this).SetNewAtlasSize( size, blockSize );
+  GetImplementation(*this).SetNewAtlasSize( width, height, blockWidth, blockHeight );
 }
 
 Vector2 AtlasGlyphManager::GetAtlasSize( uint32_t atlasId )
index 6a10947..ad2c5ea 100644 (file)
@@ -119,14 +119,15 @@ public:
    */
   Vector2 GetAtlasSize( uint32_t atlasId );
 
-  /**
-   * @brief Set the Atlas size and block size for subsequent atlas generation
-   *
-   * @param[in] size size of the atlas in pixels
-   * @param[in] blockSize size of a block in this atlas in pixels
-   */
-  void SetNewAtlasSize( const Vector2& size,
-                        const Vector2& blockSize );
+   /**
+    * @brief Set the atlas size and block size for subsequent Atlas generation
+    *
+    * @param[in] width width of atlas in pixels
+    * @param[in] height height of atlas in pixels
+    * @param[in] blockWidth width of a block in pixels
+    * @param[in] blockHeight height of a block in pixels
+    */
+  void SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight );
 
   /**
    * @brief Unreference an image from the atlas and remove from cache if no longer needed
index b06d4e6..b82b07b 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/dali.h>
 #include <dali/integration-api/debug.h>
+#include <dali/public-api/text-abstraction/text-abstraction.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/atlas-manager/atlas-manager.h>
@@ -38,13 +39,12 @@ using namespace Dali::Toolkit::Text;
 
 namespace
 {
-  const Vector2 DEFAULT_ATLAS_SIZE( 512.0f, 512.0f );
-  const Vector2 DEFAULT_BLOCK_SIZE( 16.0f, 16.0f );
-  const Vector2 PADDING( 4.0f, 4.0f ); // Allow for variation in font glyphs
   const float ZERO( 0.0f );
   const float HALF( 0.5f );
   const float ONE( 1.0f );
   const float TWO( 2.0f );
+  const uint32_t DEFAULT_ATLAS_WIDTH = 512u;
+  const uint32_t DEFAULT_ATLAS_HEIGHT = 512u;
 }
 
 struct AtlasRenderer::Impl : public ConnectionTracker
@@ -84,14 +84,14 @@ struct AtlasRenderer::Impl : public ConnectionTracker
   struct MaxBlockSize
   {
     FontId mFontId;
-    Vector2 mNeededBlockSize;
+    uint32_t mNeededBlockWidth;
+    uint32_t mNeededBlockHeight;
   };
 
   Impl()
   {
     mGlyphManager = AtlasGlyphManager::Get();
     mFontClient = TextAbstraction::FontClient::Get();
-    mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_SIZE, DEFAULT_BLOCK_SIZE );
     mBasicShader = BasicShader::New();
     mBgraShader = BgraShader::New();
     mBasicShadowShader = BasicShadowShader::New();
@@ -116,7 +116,7 @@ struct AtlasRenderer::Impl : public ConnectionTracker
 
     float currentUnderlinePosition = ZERO;
     float currentUnderlineThickness = underlineHeight;
-
+    uint32_t currentBlockSize = 0;
     FontId lastFontId = 0;
     Style style = STYLE_NORMAL;
 
@@ -196,15 +196,39 @@ struct AtlasRenderer::Impl : public ConnectionTracker
             {
               if ( mBlockSizes[ j ].mFontId == glyph.fontId )
               {
-                mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_SIZE, mBlockSizes[ j ].mNeededBlockSize );
+                currentBlockSize = j;
+                mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
+                                               DEFAULT_ATLAS_HEIGHT,
+                                               mBlockSizes[ j ].mNeededBlockWidth,
+                                               mBlockSizes[ j ].mNeededBlockHeight );
               }
             }
-            lastFontId = glyph.fontId;
           }
 
-          // Glyph doesn't currently exist in atlas so upload
+          // Create a new image for the glyph
           BufferImage bitmap = mFontClient.CreateBitmap( glyph.fontId, glyph.index );
 
+          // Ensure that the next image will fit into the current block size
+          bool setSize = false;
+          if ( bitmap.GetWidth() > mBlockSizes[ currentBlockSize ].mNeededBlockWidth )
+          {
+            setSize = true;
+            mBlockSizes[ currentBlockSize ].mNeededBlockWidth = bitmap.GetWidth();
+          }
+          if ( bitmap.GetHeight() > mBlockSizes[ currentBlockSize ].mNeededBlockHeight )
+          {
+            setSize = true;
+            mBlockSizes[ currentBlockSize ].mNeededBlockHeight = bitmap.GetHeight();
+          }
+
+          if ( setSize )
+          {
+            mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
+                                           DEFAULT_ATLAS_HEIGHT,
+                                           mBlockSizes[ currentBlockSize ].mNeededBlockWidth,
+                                           mBlockSizes[ currentBlockSize ].mNeededBlockHeight );
+          }
+
           // Locate a new slot for our glyph
           mGlyphManager.Add( glyph, bitmap, slot );
 
@@ -224,6 +248,7 @@ struct AtlasRenderer::Impl : public ConnectionTracker
                         currentUnderlinePosition,
                         currentUnderlineThickness,
                         slot );
+       lastFontId = glyph.fontId;
       }
     }
 
@@ -240,6 +265,9 @@ struct AtlasRenderer::Impl : public ConnectionTracker
       {
         MeshActor actor = MeshActor::New( Mesh::New( mIt->mMeshData ) );
         actor.SetColor( mIt->mColor );
+
+        // Ensure that text rendering is unfiltered
+        actor.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
         if ( mIt->mIsUnderline )
         {
           actor.SetColorMode( USE_OWN_COLOR );
@@ -286,10 +314,10 @@ struct AtlasRenderer::Impl : public ConnectionTracker
       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Atlas [%i] %sPixels: %s Size: %ix%i, BlockSize: %ix%i, BlocksUsed: %i/%i\n",
                                                  i + 1, i > 8 ? "" : " ",
                                                  metrics.mAtlasMetrics.mAtlasMetrics[ i ].mPixelFormat == Pixel::L8 ? "L8  " : "BGRA",
-                                                 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mWidth,
-                                                 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mHeight,
-                                                 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mBlockWidth,
-                                                 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mBlockHeight,
+                                                 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mWidth,
+                                                 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mHeight,
+                                                 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mBlockWidth,
+                                                 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mBlockHeight,
                                                  metrics.mAtlasMetrics.mAtlasMetrics[ i ].mBlocksUsed,
                                                  metrics.mAtlasMetrics.mAtlasMetrics[ i ].mTotalBlocks );
     }
@@ -419,31 +447,21 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     MaxBlockSize maxBlockSize;
     for ( uint32_t i = 0; i < glyphs.Size(); ++i )
     {
-      // Get the fontId of this glyph and check to see if a max size exists?
       FontId fontId = glyphs[ i ].fontId;
-      float paddedWidth = glyphs[ i ].width + PADDING.x;
-      float paddedHeight = glyphs[ i ].height + PADDING.y;
       bool foundFont = false;
-
       for ( uint32_t j = 0; j < mBlockSizes.size(); ++j )
       {
         if ( mBlockSizes[ j ].mFontId == fontId )
         {
           foundFont = true;
-          if ( mBlockSizes[ j ].mNeededBlockSize.x < paddedWidth )
-          {
-            mBlockSizes[ j ].mNeededBlockSize.x = paddedWidth;
-          }
-          if ( mBlockSizes[ j ].mNeededBlockSize.y < paddedHeight )
-          {
-            mBlockSizes[ j ].mNeededBlockSize.y = paddedHeight;
-          }
         }
       }
-
       if ( !foundFont )
       {
-        maxBlockSize.mNeededBlockSize = Vector2( paddedWidth, paddedHeight );
+        FontMetrics fontMetrics;
+        mFontClient.GetFontMetrics( fontId, fontMetrics );
+        maxBlockSize.mNeededBlockWidth = static_cast< uint32_t >( fontMetrics.height );
+        maxBlockSize.mNeededBlockHeight = static_cast< uint32_t >( fontMetrics.height );
         maxBlockSize.mFontId = fontId;
         mBlockSizes.push_back( maxBlockSize );
       }
@@ -705,4 +723,4 @@ AtlasRenderer::AtlasRenderer()
 AtlasRenderer::~AtlasRenderer()
 {
   delete mImpl;
-}
\ No newline at end of file
+}
index 35e7869..e0f40e6 100644 (file)
@@ -101,7 +101,7 @@ class PropertyButtonsController: public ConnectionTracker
     }
 
     // Create the last selected button text view.
-    mTagText = Toolkit::TextView::New( "None selected" );
+    mTagText = Toolkit::TextLabel::New( "None selected" );
     mTagText.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
     mTagText.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
     mTagText.SetPosition( Vector3( 0.0f, -30.0f, 0.0f ) );
@@ -121,14 +121,14 @@ class PropertyButtonsController: public ConnectionTracker
     // Property::Index index = button.GetPropertyIndex( TAG_PROPERTY_NAME );
     valueText << "Selected: " << button.GetProperty< float >( mTagPropertyIndex );
 
-    mTagText.SetText( valueText.str() );
+    mTagText.SetProperty( TextLabel::Property::TEXT, valueText.str() );
 
     return true;
   }
 
   private:
 
-  Toolkit::TextView mTagText;        ///< A text label used to show the last button pressed.
+  Toolkit::TextLabel mTagText;        ///< A text label used to show the last button pressed.
   Property::Index mTagPropertyIndex; ///< A cached property index of our custom tag property.
 };
 
diff --git a/docs/content/images/actors/Text-Actor.png b/docs/content/images/actors/Text-Actor.png
deleted file mode 100644 (file)
index 6bba38e..0000000
Binary files a/docs/content/images/actors/Text-Actor.png and /dev/null differ
diff --git a/docs/content/images/actors/Text-Label.png b/docs/content/images/actors/Text-Label.png
new file mode 100644 (file)
index 0000000..cc2dc30
Binary files /dev/null and b/docs/content/images/actors/Text-Label.png differ
diff --git a/docs/content/images/text-controls/HelloWorld-HeightForWidth.png b/docs/content/images/text-controls/HelloWorld-HeightForWidth.png
new file mode 100644 (file)
index 0000000..915862c
Binary files /dev/null and b/docs/content/images/text-controls/HelloWorld-HeightForWidth.png differ
diff --git a/docs/content/images/text-controls/HelloWorld-NaturalSize.png b/docs/content/images/text-controls/HelloWorld-NaturalSize.png
new file mode 100644 (file)
index 0000000..28d24d1
Binary files /dev/null and b/docs/content/images/text-controls/HelloWorld-NaturalSize.png differ
diff --git a/docs/content/images/text-controls/PlainText.png b/docs/content/images/text-controls/PlainText.png
new file mode 100644 (file)
index 0000000..5ef9ff1
Binary files /dev/null and b/docs/content/images/text-controls/PlainText.png differ
diff --git a/docs/content/images/text-controls/RedText.png b/docs/content/images/text-controls/RedText.png
new file mode 100644 (file)
index 0000000..f2fe9fe
Binary files /dev/null and b/docs/content/images/text-controls/RedText.png differ
diff --git a/docs/content/images/text-controls/TextWith1pxUnderline.png b/docs/content/images/text-controls/TextWith1pxUnderline.png
new file mode 100644 (file)
index 0000000..082d19e
Binary files /dev/null and b/docs/content/images/text-controls/TextWith1pxUnderline.png differ
diff --git a/docs/content/images/text-controls/TextWithBiggerShadow.png b/docs/content/images/text-controls/TextWithBiggerShadow.png
new file mode 100644 (file)
index 0000000..921f745
Binary files /dev/null and b/docs/content/images/text-controls/TextWithBiggerShadow.png differ
diff --git a/docs/content/images/text-controls/TextWithColorShadow.png b/docs/content/images/text-controls/TextWithColorShadow.png
new file mode 100644 (file)
index 0000000..a82635d
Binary files /dev/null and b/docs/content/images/text-controls/TextWithColorShadow.png differ
diff --git a/docs/content/images/text-controls/TextWithColorUnderline.png b/docs/content/images/text-controls/TextWithColorUnderline.png
new file mode 100644 (file)
index 0000000..42ec4ff
Binary files /dev/null and b/docs/content/images/text-controls/TextWithColorUnderline.png differ
diff --git a/docs/content/images/text-controls/TextWithShadow.png b/docs/content/images/text-controls/TextWithShadow.png
new file mode 100644 (file)
index 0000000..1cde8d2
Binary files /dev/null and b/docs/content/images/text-controls/TextWithShadow.png differ
diff --git a/docs/content/images/text-controls/TextWithUnderline.png b/docs/content/images/text-controls/TextWithUnderline.png
new file mode 100644 (file)
index 0000000..530920a
Binary files /dev/null and b/docs/content/images/text-controls/TextWithUnderline.png differ
index 8031d99..2065659 100644 (file)
@@ -12,56 +12,71 @@ Let's take a look at the code for this test application.
 
 <h2 class="pg"> Example code </h2>
 \code
-#include <dali/dali.h>
 
-using namespace Dali;
+#include <dali-toolkit/dali-toolkit.h>
 
-/******************************************************
- * Demonstrates how to display "Hello World" on screen
- ******************************************************/
+using namespace Dali;
+using Dali::Toolkit::TextLabel;
 
-class ExampleApp
+// This example shows how to create and display Hello World! using a simple TextActor
+//
+class HelloWorldController : public ConnectionTracker
 {
 public:
-  ExampleApp(Application &app)
-  : mApp(app)
+
+  HelloWorldController( Application& application )
+  : mApplication( application )
   {
-    // Connect to Dali::Application init signal. Do not make calls to Dali before this signal is received.
-    app.SignalInit().Connect(this, &ExampleApp::Create);
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect( this, &HelloWorldController::Create );
   }
 
-  ~ExampleApp()
+  ~HelloWorldController()
   {
-    // Remove Hello World TextActor from stage
-    Stage::GetCurrent().Remove(mTextActor);
+    // Remove Hello World actor from stage
+    Stage::GetCurrent().Remove(mTextLabel);
   }
 
-public:
-
-  void Create(Application& app)
+  // The Init signal is received once (only) during the Application lifetime
+  void Create( Application& application )
   {
-    // Initialize the actor
-    mTextActor = TextActor::New("Hello World");
+    // Get a handle to the stage
+    Stage stage = Stage::GetCurrent();
+
+    mTextLabel = TextLabel::New( "Hello World" );
+    mTextLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+    stage.Add( mTextLabel );
 
-    // Center the actor. Note: default anchor point is CENTER
-    mTextActor.SetParentOrigin(ParentOrigin::CENTER);
+    // Respond to a click anywhere on the stage
+    stage.GetRootLayer().TouchedSignal().Connect( this, &HelloWorldController::OnTouch );
+  }
 
-    // Display the actor on the stage
-    Stage::GetCurrent().Add(mTextActor);
+  bool OnTouch( Actor actor, const TouchEvent& touch )
+  {
+    // quit the application
+    mApplication.Quit();
+    return true;
   }
 
 private:
-  Application& mApp;
-  TextActor mTextActor;
+  Application&  mApplication;
+  TextLabel mTextLabel;
 };
 
-int
-main(int argc, char **argv)
+void RunTest( Application& application )
+{
+  HelloWorldController test( application );
+
+  application.MainLoop();
+}
+
+// Entry point for Linux & Tizen applications
+//
+int main( int argc, char **argv )
 {
-  Application daliApp(&argc, &argv);
+  Application application = Application::New( &argc, &argv );
 
-  ExampleApp helloApp (daliApp);
-  daliApp.MainLoop();
+  RunTest( application );
 
   return 0;
 }
@@ -85,10 +100,10 @@ main(int argc, char **argv)
  That's why we store the Actor's handle:
  \code
    ...
-   mTextActor = TextActor::New("Hello World");
+   mTextLabel = TextLabel::New("Hello World");
    ...
  \endcode
- Even if the TextActor is removed from the stage, it will be kept alive through our reference.\n
+ Even if the TextLabel is removed from the stage, it will be kept alive through our reference.\n
  You can read more about implicit smart-pointer semantics in chapter \link handle-body-idiom Handle – body\endlink.
 
  <h2 class="pg"> Main loop </h2>
@@ -107,6 +122,12 @@ main(int argc, char **argv)
 
  After running './hello' this should be visible on the screen:
 
- \image html Text-Actor.png "Hello world example"
+<table border=0 cellpadding=10>
+<tr>
+  <td>
+  \image html Text-Label.png "Hello world example"
+  </td>
+</tr>
+</table>
 
 */
index 8838e78..0a85d51 100644 (file)
@@ -244,7 +244,7 @@ This is a basic example of a button defined in JSON by setting the default prope
         }
       },
       "label-actor": {
-        "type": "TextView",
+        "type": "TextLabel",
         "text": "Normal"
       }
     }
index 837e022..3bb5ece 100644 (file)
@@ -6,19 +6,13 @@
  *
  * @code
  * {
- *     "fonts":
- *     {
- *         "freesans": {"name": "FreeSans", "point-size": 12.0, "weight": "WEIGHT_REGULAR" }
- *     },
- *     "actors":
- *     [
- *         {"name":"text-actor",
- *          "type":"Text",
- *          "text":"Hello World",
- *          "font":"freesans",
- *          "parent-origin":"CENTER"
- *         }
- *     ]
+ *  // a tree of actors
+ *  "stage": [{
+ *    "name": "text-label",
+ *    "type": "TextLabel",
+ *    "text": "Hello World",
+ *    "parent-origin": "CENTER"
+ *  }]
  * }
  * @endcode
  *
@@ -31,7 +25,7 @@
  *
  * builder.LoadFromString(json_data);
  *
- * Actor actor = builder.GetActor("text-actor");
+ * Actor actor = builder.GetActor("text-label");
  *
  * Stage::GetCurrent().Add(actor);
  * @endcode
  * daliscript hello-world.js
  * @endcode
  *
- * The TextActor control to display Hello World can be constructed using Javascript dot notation accessing Dali Actor Properties.
+ * The TextLabel control to display Hello World can be constructed using Javascript dot notation accessing Dali Actor Properties.
  *
  * @code
- * var textActor = Dali.TextActor();
+ * var textLabel = Dali.TextLabel();
  *
- * textActor.text          = "Hello World";
- * textActor.font          = "FreeSans";
- * textActor.font-weight   = "WEIGHT_REGULAR";
- * textActor.parent-origin = "CENTER";
+ * textLabel.text          = "Hello World";
+ * textLabel.font-family   = "FreeSans";
+ * textLabel.font-style    = "Regular";
+ * textLabel.parent-origin = "CENTER";
  *
  * Dali.Run();
  * @endcode
index 8259359..2f64d83 100644 (file)
@@ -92,8 +92,7 @@ Dimension::WIDTH then there is a height-for-width dependency in effect. The clas
 is a text view that wraps its text. The following example snippet shows a text view that expands its width to the size of its parent, wraps its
 contents and then determines its height based on the width.
 @code
-TextView text = TextView::New( "Example" );
-text.SetMultilinePolicy( SplitByWord );
+TextLabel text = TextLabel::New( "Example" );
 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
 @endcode
@@ -140,11 +139,7 @@ content.SetFitHeight( 1 );
 content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
 
 // Text
-Toolkit::TextView text = Toolkit::TextView::New();
-text.SetText( "Do you really want to quit?" );
-text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
-text.SetWidthExceedPolicy( Toolkit::TextView::Split );
-text.SetLineJustification( Toolkit::TextView::Left );
+Toolkit::TextLabel text = Toolkit::TextLabel::New( "Do you really want to quit?" );
 text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
 
@@ -174,9 +169,7 @@ checkBox.SetSize( Vector2( 48, 48 ) );
 
 root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) );
 
-Toolkit::TextView text2 = Toolkit::TextView::New();
-text2.SetText( "Don't show again" );
-text2.SetLineJustification( Toolkit::TextView::Left );
+Toolkit::TextLabel text2 = Toolkit::TextLabel::New( "Don't show again" );
 text2.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) );
 
 root.AddChild( text2, Toolkit::TableView::CellPosition( 0, 1 ) );
index 35754de..24f8b1b 100644 (file)
@@ -11,39 +11,33 @@ To display a TextLabel the TEXT property must be set using a UTF-8 string.
 \code
 TextLabel label = TextLabel::New();
 label.SetProperty( TextLabel::Property::TEXT, "Hello World" );
+label.SetAnchorPoint( AnchorPoint::TOP_LEFT );
 Stage::GetCurrent().Add( label );
 \endcode
 
 The label must also be added to the stage, or to an actor which is on the stage.\n
-In this example the text-label will be automatically given a natural size i.e. large enough to fit the text.\n
-The position of the label on-screen is dependent on the parent-origin and anchor-point properties:
+The position of the label on-screen is dependent on the parent-origin and anchor-point properties.\n
 
 <table border=0 cellpadding=10>
 <tr>
   <td>
   \image html TextLabelTopLeft.png
   </td>
-  <td>
-  \image html TextLabelCenter.png
-  </td>
 </tr>
 <tr>
   <td>
   (ParentOrigin::TOP_LEFT, AnchorPoint::TOP_LEFT)
   </td>
-  <td>
-  (ParentOrigin::CENTER, AnchorPoint::CENTER)
-  </td>
 </tr>
 </table>
 
-\subsection fontselection Font Selection
+\subsection fontSelection Font Selection
 
 By default TextLabel will automatically select a suitable font from the platform.\n
 Typically fonts do not support all scripts, for example Latin fonts often do not provide Arabic glyphs.\n
 Therefore you should expect TextLabel to select different fonts for each script.
 
-Alternatively a font may be requested using eiter or all of FONT_FAMILY, FONT_STYLE, and POINT_SIZE properties:
+Alternatively a font may be requested using either or all of FONT_FAMILY, FONT_STYLE, and POINT_SIZE properties:
 \code
 label.SetProperty( TextLabel::Property::FONT_FAMILY, "HelveticaNue" );
 label.SetProperty( TextLabel::Property::FONT_STYLE,  "Regular" );
@@ -51,16 +45,70 @@ label.SetProperty( TextLabel::Property::POINT_SIZE,  12.0f );
 \endcode
 However the TextLabel will fall-back to using the default font, if the requested font does not support the required scripts.
 
-\subsection fontselection Text Alignment
+\subsection fontStyles Font Styles
+
+Setting a font size programmatically is not ideal for applications which support multiple screen resolutions etc.\n
+A more flexible approach is to prepare various JSON stylesheets, and request a different style for each platform:\n
+
+\code
+StyleManager styleManager = StyleManager::Get();
+styleManager.RequestThemeChange( "example-path/example.json" );
+\endcode
+
+To change the font for standard text labels, this JSON syntax can be used:
+
+\code
+{
+  "styles":
+  {
+    "textlabel":
+    {
+      "font-family":"Arial",
+      "font-style":"Regular",
+      "point-size":8
+    }
+  }
+}
+\endcode
+
+However the same point-size is unlikely to be suitable for all labels in an application.\n
+To set custom sizes simply set a "style name" for each case, and then provide a style override in JSON:
+
+\code
+  label.SetProperty( Control::Property::STYLE_NAME, "custom" );
+\endcode
+
+\code
+{
+  "styles":
+  {
+    "textlabel":
+    {
+      "font-family":"Arial",
+      "font-style":"Regular",
+      "point-size":8
+    },
+
+    "custom":
+    {
+      "point-size":10
+    }
+  }
+}
+\endcode
+
+In the example above, standard text labels will have point-size 8, and "custom" labels will have point-size 10.\n
+
+\subsection textAlignment Text Alignment
 
 Wrapping can be enabled using the MULTI_LINE property:\n
 \code
 label.SetProperty( TextLabel::Property::MULTI_LINE, true );
 \endcode
 
-The text can be either aligned to the start, end, or center of the available area:
+The text can be either aligned horizontally to the beginning, end, or center of the available area:
 \code
-label.SetProperty( TextLabel::Property::ALIGNMENT, "BEGIN" ); // "CENTER" or "END"
+label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "BEGIN" ); // "CENTER" or "END"
 \endcode
 
 <table border=0 cellpadding=10>
@@ -105,4 +153,191 @@ label.SetProperty( TextLabel::Property::ALIGNMENT, "BEGIN" ); // "CENTER" or "EN
 </tr>
 </table>
 
+The examples above assume that the TextLabel size greater than the minimum required.\n
+The next section provides details about the other size related options.
+
+\subsection negotiatingSize Negotiating size
+
+\link size-negotiation Size negotiation \endlink is a layouting feature supported by UI controls such as TextLabel.\n
+There are several resize policies which are commonly used with TextLabels.\n
+The following examples show TextLabels actual size by setting a colored background, whilst the black area represents the size of the parent control:\n
+
+<h3>Using natural size</h3>
+
+With a "natural" size TextLabel will be large enough to display the text without wrapping, and will not have extra space to align the text within.\n
+Therefore in this example the same result would be displayed, regardless of the alignment or multi-line properties.\n
+
+\code
+TextLabel label = TextLabel::New( "Hello World" );
+label.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+label.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+label.SetBackgroundColor( Color::BLUE );
+Stage::GetCurrent().Add( label );
+\endcode
+
+<table border=0 cellpadding=10>
+<tr>
+  <td>
+  \image html HelloWorld-NaturalSize.png
+  </td>
+</tr>
+</table>
+
+<h3>Height-for-width negotiation</h3>
+
+To layout text labels vertically, a fixed (maximum) width should be provided by the parent control.\n
+Each TextLabel will then report a desired height for the given width.\n
+Here is an example of this behavior using TableView as the parent:
+
+\code
+TableView parent = TableView::New( 3, 1 );
+parent.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+parent.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
+parent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+Stage::GetCurrent().Add( parent );
+
+TextLabel label = TextLabel::New( "Hello World" );
+label.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+label.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
+label.SetBackgroundColor( Color::BLUE );
+parent.AddChild( label, TableView::CellPosition( 0, 0 ) );
+parent.SetFitHeight( 0 );
+
+label = TextLabel::New( "A Quick Brown Fox Jumps Over The Lazy Dog" );
+label.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+label.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
+label.SetBackgroundColor( Color::GREEN );
+label.SetProperty( TextLabel::Property::MULTI_LINE, true );
+parent.AddChild( label, TableView::CellPosition( 1, 0 ) );
+parent.SetFitHeight( 1 );
+
+label = TextLabel::New( "لإعادة ترتيب الشاشات، يجب تغيير نوع العرض إلى شبكة قابلة للتخصيص." );
+label.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+label.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
+label.SetBackgroundColor( Color::BLUE );
+label.SetProperty( TextLabel::Property::MULTI_LINE, true );
+parent.AddChild( label, TableView::CellPosition( 2, 0 ) );
+parent.SetFitHeight( 2 );
+\endcode
+
+<table border=0 cellpadding=10>
+<tr>
+  <td>
+  \image html HelloWorld-HeightForWidth.png
+  </td>
+</tr>
+</table>
+
+Note that the "Hello World" text label (above) has been given the full width, not the natural width.
+
+\subsection textLabelDecorations TextLabel Decorations
+
+<h3>Color</h3>
+
+To change the color of the text, the recommended way is to use the TEXT_COLOR property.\n
+Note that unlike the Actor::COLOR property, this will not affect child Actors added to the TextLabel.\n
+
+\code
+label.SetProperty( TextLabel::Property::TEXT, "Red Text" );
+label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
+\endcode
+
+<table border=0 cellpadding=10>
+<tr>
+  <td>
+  \image html RedText.png
+  </td>
+</tr>
+</table>
+
+<h3>Drop Shadow</h3>
+
+To add a drop-shadow to the text, simply set the SHADOW_OFFSET property with non-zero values.\n
+The color can also be selected using the SHADOW_COLOR property.\n
+
+\code
+stage.SetBackgroundColor( Color::BLUE );
+
+label1.SetProperty( TextLabel::Property::TEXT, "Plain Text" );
+
+label2.SetProperty( TextLabel::Property::TEXT, "Text with Shadow" );
+label2.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
+label4.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
+
+label3.SetProperty( TextLabel::Property::TEXT, "Text with Bigger Shadow" );
+label3.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 2.0f, 2.0f ) );
+label4.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
+
+label4.SetProperty( TextLabel::Property::TEXT, "Text with Color Shadow" );
+label4.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
+label4.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::RED );
+\endcode
+
+<table border=0 cellpadding=10>
+<tr>
+  <td>
+  \image html PlainText.png
+  </td>
+</tr>
+<tr>
+  <td>
+  \image html TextWithShadow.png
+  </td>
+</tr>
+<tr>
+  <td>
+  \image html TextWithBiggerShadow.png
+  </td>
+</tr>
+<tr>
+  <td>
+  \image html TextWithColorShadow.png
+  </td>
+</tr>
+</table>
+
+<h3>Underline</h3>
+
+The text can be underlined by setting UNDERLINE_ENABLED.\n
+The color can also be selected using the UNDERLINE_COLOR property.\n
+
+\code
+label1.SetProperty( TextLabel::Property::TEXT, "Text with Underline" );
+label1.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
+
+label2.SetProperty( TextLabel::Property::TEXT, "Text with Color Underline" );
+label2.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
+label2.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::GREEN );
+\endcode
+
+<table border=0 cellpadding=10>
+<tr>
+  <td>
+  \image html TextWithUnderline.png
+  </td>
+</tr>
+<tr>
+  <td>
+  \image html TextWithColorUnderline.png
+  </td>
+</tr>
+</table>
+
+By default the underline height will be taken from the font metrics, however this can be overridden using the UNDERLINE_HEIGHT property:
+
+\code
+label1.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
+\endcode
+
+<table border=0 cellpadding=10>
+<tr>
+  <td>
+  \image html TextWith1pxUnderline.png
+  </td>
+</tr>
+</table>
+
 */