Merge "Size negotiation patch 3: Scope size negotiation enums" into tizen
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Tue, 14 Apr 2015 10:52:41 +0000 (03:52 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 14 Apr 2015 10:52:41 +0000 (03:52 -0700)
29 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h
dali-toolkit/internal/controls/buttons/button-impl.cpp
dali-toolkit/internal/controls/cluster/cluster-impl.cpp
dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.cpp
dali-toolkit/internal/controls/popup/popup-impl.cpp
dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp
dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp
dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp
dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp
dali-toolkit/internal/controls/slider/slider-impl.cpp
dali-toolkit/internal/controls/view/view-impl.cpp
dali-toolkit/internal/focus-manager/focus-manager-impl.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp
dali-toolkit/internal/text/character-set-conversion.h
dali-toolkit/internal/text/layouts/layout-engine.cpp
dali-toolkit/internal/text/layouts/layout-parameters.h
dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h
dali-toolkit/internal/text/rendering/text-backend.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp
dali-toolkit/public-api/controls/cluster/cluster-style.cpp
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h
dali-toolkit/public-api/focus-manager/keyboard-focus-manager.cpp
docs/content/programming-guide/custom-actor.h
plugins/dali-script-v8/src/animation/animation-api.cpp
plugins/dali-script-v8/src/signals/signal-manager.cpp

index b094fde..36cb94b 100644 (file)
  */
 
 // EXTERNAL INCLUDES
+#include <cstdio>  // fprintf
 #include <sstream>
 #include <string>
+#include <cstring> // for strcpy, strncpy
 #include <map>
 
 // INTERNAL INCLUDES
index c42531f..d1f30bc 100644 (file)
@@ -19,6 +19,7 @@
 #include "button-impl.h"
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/events/touch-event.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
index d4daf3c..d43d63a 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <algorithm>
+#include <cstring> // for strcmp
 #include <dali/public-api/animation/animation.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
index 84eb4e4..26956dc 100644 (file)
@@ -19,6 +19,7 @@
 #include "navigation-control-impl.h"
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/animation/animation.h>
 #include <dali/public-api/events/key-event.h>
 #include <dali/public-api/object/type-registry.h>
index 8a1c679..a5aed9b 100755 (executable)
@@ -19,6 +19,7 @@
 #include <dali-toolkit/internal/controls/popup/popup-impl.h>
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/adaptor-framework/key.h>
 #include <dali/public-api/adaptor-framework/physical-keyboard.h>
 #include <dali/public-api/animation/constraints.h>
index d57f2a4..0d7b833 100755 (executable)
@@ -19,6 +19,7 @@
 #include <dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.h>
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/animation/constraint.h>
 #include <dali/public-api/animation/constraints.h>
 #include <dali/public-api/object/type-registry.h>
index 9ad835f..a3f222e 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h>
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <algorithm>
 #include <dali/public-api/animation/constraint.h>
 #include <dali/public-api/animation/constraints.h>
index 613b0e8..a789981 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h>
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/object/property-index-ranges.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
index 09582cf..496d20f 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h>
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/animation/constraints.h>
 #include <dali/public-api/common/stage.h>
 #include <dali/public-api/events/mouse-wheel-event.h>
index 3db2f3e..5f7cf72 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
 
index 7ab8438..4c1b2fa 100755 (executable)
@@ -19,7 +19,9 @@
 #include <dali-toolkit/internal/controls/slider/slider-impl.h>
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <sstream>
+#include <limits>
 #include <dali/public-api/events/touch-event.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
index 9a5ac2e..19dd781 100644 (file)
@@ -19,6 +19,7 @@
 #include "view-impl.h"
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/animation/constraints.h>
 #include <dali/public-api/common/stage.h>
 #include <dali/public-api/object/type-registry.h>
index 24343dd..b1f3c14 100644 (file)
@@ -19,6 +19,7 @@
 #include "focus-manager-impl.h"
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/adaptor-framework/accessibility-manager.h>
 #include <dali/public-api/adaptor-framework/sound-player.h>
index ff75d04..5b0bcb5 100644 (file)
@@ -19,6 +19,7 @@
 #include "keyboard-focus-manager-impl.h"
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/adaptor-framework/accessibility-manager.h>
 #include <dali/public-api/adaptor-framework/singleton-service.h>
index 5d7d4be..9fee428 100644 (file)
@@ -19,6 +19,7 @@
 #include "keyinput-focus-manager-impl.h"
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/common/stage.h>
 
index c8da542..7a62498 100644 (file)
@@ -38,7 +38,7 @@ namespace Toolkit
  *
  * @return The number of characters.
  */
-DALI_IMPORT_API uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, uint32_t length );
+uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, uint32_t length );
 
 /**
  * @brief Retrieves the number of bytes needed to encode in UTF8 the given text array encoded in UTF32.
@@ -48,7 +48,7 @@ DALI_IMPORT_API uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, u
  *
  * @return The number of bytes.
  */
-DALI_IMPORT_API uint32_t GetNumberOfUtf8Bytes( const uint32_t* const utf32, uint32_t numberOfCharacters );
+uint32_t GetNumberOfUtf8Bytes( const uint32_t* const utf32, uint32_t numberOfCharacters );
 
 /**
  * @brief Converts a text array encoded in UTF8 into a text array encoded in UTF32.
@@ -61,7 +61,7 @@ DALI_IMPORT_API uint32_t GetNumberOfUtf8Bytes( const uint32_t* const utf32, uint
  *
  * @return The number of characters.
  */
-DALI_IMPORT_API uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf32 );
+uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf32 );
 
 /**
  * @brief Converts a text array encoded in UTF32 into a text array encoded in UTF8.
@@ -74,7 +74,7 @@ DALI_IMPORT_API uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length
  *
  * @return The number of bytes.
  */
-DALI_IMPORT_API uint32_t Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, uint8_t* utf8 );
+uint32_t Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, uint8_t* utf8 );
 
 } // namespace Toolkit
 
index 1a97dd4..e165103 100644 (file)
@@ -40,6 +40,7 @@ namespace
 {
 
 const float MAX_FLOAT = std::numeric_limits<float>::max();
+const bool RTL = true;
 
 } //namespace
 
@@ -48,12 +49,40 @@ const float MAX_FLOAT = std::numeric_limits<float>::max();
  */
 struct LineLayout
 {
+  LineLayout()
+  : glyphIndex( 0u ),
+    characterIndex( 0u ),
+    numberOfCharacters( 0u ),
+    numberOfGlyphs( 0u ),
+    length( 0.f ),
+    widthAdvanceDiff( 0.f ),
+    wsLengthEndOfLine( 0.f ),
+    ascender( 0.f ),
+    descender( MAX_FLOAT )
+  {}
+
+  ~LineLayout()
+  {}
+
+  void Clear()
+  {
+    glyphIndex = 0u;
+    characterIndex = 0u;
+    numberOfCharacters = 0u;
+    numberOfGlyphs = 0u;
+    length = 0.f;
+    widthAdvanceDiff = 0.f;
+    wsLengthEndOfLine = 0.f;
+    ascender = 0.f;
+    descender = MAX_FLOAT;
+  }
+
   GlyphIndex     glyphIndex;         ///< Index of the first glyph to be laid-out.
   CharacterIndex characterIndex;     ///< Index of the first character to be laid-out.
   Length         numberOfCharacters; ///< The number of characters which fit in one line.
   Length         numberOfGlyphs;     ///< The number of glyph which fit in one line.
   float          length;             ///< The length of the glyphs which fit in one line.
-  float          widthAdvanceDiff;   ///< The difference between the width and the advance of the last glyph.
+  float          widthAdvanceDiff;   ///< The difference between the xBearing + width and the advance of the last glyph.
   float          wsLengthEndOfLine;  ///< The length of the white spaces at the end of the line.
   float          ascender;           ///< The maximum ascender of all fonts in the line.
   float          descender;          ///< The minimum descender of all fonts in the line.
@@ -70,114 +99,118 @@ struct LayoutEngine::Impl
   }
 
   /**
-   * Retrieves the line layout for a given box width.
+   * @brief Updates the line ascender and descender with the metrics of a new font.
+   *
+   * @param[in] fontId The id of the new font.
+   * @param[in,out] lineLayout The line layout.
    */
-  void GetLineLayoutForBox( const LayoutParameters& parameters,
-                            LineLayout& lineLayout )
+  void UpdateLineHeight( FontId fontId, LineLayout& lineLayout )
   {
-    // Initializes the line layout.
-    lineLayout.numberOfCharacters = 0u;
-    lineLayout.numberOfGlyphs = 0u;
-    lineLayout.length = 0.f;
-    lineLayout.wsLengthEndOfLine = 0.f;
-    lineLayout.ascender = 0.f;
-    lineLayout.descender = MAX_FLOAT;
-
-    // Get the last glyph index.
-    const GlyphIndex lastGlyphIndex = parameters.totalNumberOfGlyphs - 1u;
+    Text::FontMetrics fontMetrics;
+    mFontClient.GetFontMetrics( fontId, fontMetrics );
 
-    FontId lastFontId = 0u;
-    for( GlyphIndex glyphIndex = lineLayout.glyphIndex;
-         glyphIndex < parameters.totalNumberOfGlyphs;
-         ++glyphIndex )
+    // Sets the maximum ascender.
+    if( fontMetrics.ascender > lineLayout.ascender )
     {
-      // Get the glyph info.
-      const GlyphInfo& glyphInfo = *( parameters.glyphsBuffer + glyphIndex );
-
-      // Check whether is a white space.
-      const Character character = *( parameters.textBuffer + lineLayout.numberOfCharacters );
-      const bool isWhiteSpace = TextAbstraction::IsWhiteSpace( character );
-
-      // Get the character indices for the current glyph. The last character index is needed
-      // because there are glyphs formed by more than one character but their break info is
-      // given only for the last character.
-      const Length charactersPerGlyph = *( parameters.charactersPerGlyphBuffer + glyphIndex );
-
-      // Increase the number of characters.
-      lineLayout.numberOfCharacters += charactersPerGlyph;
-
-      // Increase the number of glyphs.
-      lineLayout.numberOfGlyphs++;
-
-      // Increase the accumulated length.
-      const float glyphLength = ( glyphIndex == lastGlyphIndex ) ? glyphInfo.width : glyphInfo.advance;
+      lineLayout.ascender = fontMetrics.ascender;
+    }
 
-      if( isWhiteSpace )
-      {
-        // Add the length to the length of white spaces at the end of the line.
-        lineLayout.wsLengthEndOfLine += glyphLength;
-      }
-      else
-      {
-        // Add as well any previous white space length.
-        lineLayout.length += lineLayout.wsLengthEndOfLine + glyphLength;
+    // Sets the minimum descender.
+    if( fontMetrics.descender < lineLayout.descender )
+    {
+      lineLayout.descender = fontMetrics.descender;
+    }
+  }
 
-        // Clear the white space length at the end of the line.
-        lineLayout.wsLengthEndOfLine = 0.f;
-      }
+  /**
+   * @brief Merges a temporary line layout into the line layout.
+   *
+   * @param[in,out] lineLayout The line layout.
+   * @param[in] tmpLineLayout A temporary line layout.
+   */
+  void MergeLineLayout( LineLayout& lineLayout,
+                        const LineLayout& tmpLineLayout )
+  {
+    lineLayout.numberOfCharacters += tmpLineLayout.numberOfCharacters;
+    lineLayout.numberOfGlyphs += tmpLineLayout.numberOfGlyphs;
+    lineLayout.length += tmpLineLayout.length;
 
-      if( lastFontId != glyphInfo.fontId )
-      {
-        Text::FontMetrics fontMetrics;
-        mFontClient.GetFontMetrics( glyphInfo.fontId, fontMetrics );
+    if( 0.f < tmpLineLayout.length )
+    {
+      lineLayout.length += lineLayout.wsLengthEndOfLine;
 
-        // Sets the maximum ascender.
-        if( fontMetrics.ascender > lineLayout.ascender )
-        {
-          lineLayout.ascender = fontMetrics.ascender;
-        }
+      lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine;
+      lineLayout.widthAdvanceDiff = tmpLineLayout.widthAdvanceDiff;
+    }
+    else
+    {
+      lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine;
+    }
 
-        // Sets the minimum descender.
-        if( fontMetrics.descender < lineLayout.descender )
-        {
-          lineLayout.descender = fontMetrics.descender;
-        }
+    if( tmpLineLayout.ascender > lineLayout.ascender )
+    {
+      lineLayout.ascender = tmpLineLayout.ascender;
+    }
 
-        lastFontId = glyphInfo.fontId;
-      }
+    if( tmpLineLayout.descender < lineLayout.descender )
+    {
+      lineLayout.descender = tmpLineLayout.descender;
     }
   }
 
   /**
    * Retrieves the line layout for a given box width.
    */
-  void GetMultiLineLayoutForBox( const LayoutParameters& parameters,
-                                 LineLayout& lineLayout )
+  void GetLineLayoutForBox( const LayoutParameters& parameters,
+                            LineLayout& lineLayout )
   {
-    // Initializes the line layout.
-    lineLayout.numberOfCharacters = 0u;
-    lineLayout.numberOfGlyphs = 0u;
-    lineLayout.length = 0.f;
-    lineLayout.widthAdvanceDiff = 0.f;
-    lineLayout.wsLengthEndOfLine = 0.f;
-    lineLayout.ascender = 0.f;
-    lineLayout.descender = MAX_FLOAT;
-
     // Stores temporary line layout which has not been added to the final line layout.
     LineLayout tmpLineLayout;
-    tmpLineLayout.numberOfCharacters = 0u;
-    tmpLineLayout.numberOfGlyphs = 0u;
-    tmpLineLayout.length = 0.f;
-    tmpLineLayout.widthAdvanceDiff = 0.f;
-    tmpLineLayout.wsLengthEndOfLine = 0.f;
-    tmpLineLayout.ascender = 0.f;
-    tmpLineLayout.descender = MAX_FLOAT;
-
-    FontId lastFontId = 0u;
+
+    const bool isMultiline = mLayout == MULTI_LINE_BOX;
+    const GlyphIndex lastGlyphIndex = parameters.totalNumberOfGlyphs - 1u;
+
+    // If the first glyph has a negative bearing its absolute value needs to be added to the line length.
+    // In the case the line starts with a right to left character the bearing needs to be substracted to the line length.
+    const GlyphInfo& glyphInfo = *( parameters.glyphsBuffer + lineLayout.glyphIndex );
+    float initialHorizontalBearing = glyphInfo.xBearing;
+
+    lineLayout.characterIndex = *( parameters.glyphsToCharactersBuffer + lineLayout.glyphIndex );
+    const CharacterDirection firstCharacterDirection = ( NULL == parameters.characterDirectionBuffer ) ? false : *( parameters.characterDirectionBuffer + lineLayout.characterIndex );
+
+    if( RTL == firstCharacterDirection )
+    {
+      initialHorizontalBearing = -initialHorizontalBearing;
+
+      if( 0.f < glyphInfo.xBearing )
+      {
+        tmpLineLayout.length = glyphInfo.xBearing;
+        initialHorizontalBearing = 0.f;
+      }
+    }
+    else
+    {
+      if( 0.f > glyphInfo.xBearing )
+      {
+        tmpLineLayout.length = -glyphInfo.xBearing;
+        initialHorizontalBearing = 0.f;
+      }
+    }
+
+    // Calculate the line height if there is no characters.
+    FontId lastFontId = glyphInfo.fontId;
+    UpdateLineHeight( lastFontId, tmpLineLayout );
+
+    const float boundingBoxWidth = parameters.boundingBox.width - initialHorizontalBearing;
+
+    bool oneWordLaidOut = false;
+
     for( GlyphIndex glyphIndex = lineLayout.glyphIndex;
          glyphIndex < parameters.totalNumberOfGlyphs;
          ++glyphIndex )
     {
+      const bool isLastGlyph = glyphIndex == lastGlyphIndex;
+
       // Get the glyph info.
       const GlyphInfo& glyphInfo = *( parameters.glyphsBuffer + glyphIndex );
 
@@ -208,121 +241,62 @@ struct LayoutEngine::Impl
       if( isWhiteSpace )
       {
         // Add the length to the length of white spaces at the end of the line.
-        tmpLineLayout.wsLengthEndOfLine += glyphInfo.advance; // I use the advance as the width is always zero for the white spaces.
-        tmpLineLayout.widthAdvanceDiff = 0.f;
+        tmpLineLayout.wsLengthEndOfLine += glyphInfo.advance; // The advance is used as the width is always zero for the white spaces.
       }
       else
       {
         // Add as well any previous white space length.
         tmpLineLayout.length += tmpLineLayout.wsLengthEndOfLine + glyphInfo.advance;
-        tmpLineLayout.widthAdvanceDiff = glyphInfo.width - glyphInfo.advance;
+        if( RTL == firstCharacterDirection )
+        {
+          tmpLineLayout.widthAdvanceDiff = -glyphInfo.xBearing;
+        }
+        else
+        {
+          tmpLineLayout.widthAdvanceDiff = glyphInfo.xBearing + glyphInfo.width - glyphInfo.advance;
+        }
 
         // Clear the white space length at the end of the line.
         tmpLineLayout.wsLengthEndOfLine = 0.f;
       }
 
       // Check if the accumulated length fits in the width of the box.
-      if( lineLayout.length + tmpLineLayout.length + tmpLineLayout.widthAdvanceDiff + ( ( 0.f < tmpLineLayout.length ) ? lineLayout.wsLengthEndOfLine : 0.f ) > parameters.boundingBox.width )
+      if( isMultiline && oneWordLaidOut && !isWhiteSpace &&
+          ( lineLayout.length + lineLayout.wsLengthEndOfLine + tmpLineLayout.length + tmpLineLayout.widthAdvanceDiff > boundingBoxWidth ) )
       {
         // Current word does not fit in the box's width.
         return;
       }
 
-      if( TextAbstraction::LINE_MUST_BREAK == lineBreakInfo )
+      if( ( isMultiline || isLastGlyph ) &&
+          ( TextAbstraction::LINE_MUST_BREAK == lineBreakInfo ) )
       {
         // Must break the line. Update the line layout and return.
-        lineLayout.numberOfCharacters += tmpLineLayout.numberOfCharacters;
-        lineLayout.numberOfGlyphs += tmpLineLayout.numberOfGlyphs;
-        lineLayout.length += tmpLineLayout.length;
-        lineLayout.widthAdvanceDiff = tmpLineLayout.widthAdvanceDiff;
-
-        if( 0.f < tmpLineLayout.length )
-        {
-          lineLayout.length += lineLayout.wsLengthEndOfLine;
-
-          lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine;
-        }
-        else
-        {
-          lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine;
-        }
-
-        if( tmpLineLayout.ascender > lineLayout.ascender )
-        {
-          lineLayout.ascender = tmpLineLayout.ascender;
-        }
+        MergeLineLayout( lineLayout, tmpLineLayout );
 
-        if( tmpLineLayout.descender < lineLayout.descender )
-        {
-          lineLayout.descender = tmpLineLayout.descender;
-        }
-
-        tmpLineLayout.numberOfCharacters = 0u;
-        tmpLineLayout.numberOfGlyphs = 0u;
-        tmpLineLayout.length = 0u;
-        tmpLineLayout.widthAdvanceDiff = 0u;
-        tmpLineLayout.wsLengthEndOfLine = 0u;
-        tmpLineLayout.ascender = 0.f;
-        tmpLineLayout.descender = MAX_FLOAT;
         return;
       }
 
-      if( TextAbstraction::WORD_BREAK == wordBreakInfo )
+      if( isMultiline &&
+          ( TextAbstraction::WORD_BREAK == wordBreakInfo ) )
       {
-        // Current glyph is the last one of the current word.
-        // Add the temporal layout to the current one.
-        lineLayout.numberOfCharacters += tmpLineLayout.numberOfCharacters;
-        lineLayout.numberOfGlyphs += tmpLineLayout.numberOfGlyphs;
-        lineLayout.length += tmpLineLayout.length;
-        lineLayout.widthAdvanceDiff = tmpLineLayout.widthAdvanceDiff;
-
-        if( 0.f < tmpLineLayout.length )
-        {
-          lineLayout.length += lineLayout.wsLengthEndOfLine;
-
-          lineLayout.wsLengthEndOfLine = tmpLineLayout.wsLengthEndOfLine;
-        }
-        else
-        {
-          lineLayout.wsLengthEndOfLine += tmpLineLayout.wsLengthEndOfLine;
-        }
-
-        if( tmpLineLayout.ascender > lineLayout.ascender )
+        if( !oneWordLaidOut && !isWhiteSpace )
         {
-          lineLayout.ascender = tmpLineLayout.ascender;
+          oneWordLaidOut = true;
         }
 
-        if( tmpLineLayout.descender < lineLayout.descender )
-        {
-          lineLayout.descender = tmpLineLayout.descender;
-        }
+        // Current glyph is the last one of the current word.
+        // Add the temporal layout to the current one.
+        MergeLineLayout( lineLayout, tmpLineLayout );
 
-        tmpLineLayout.numberOfCharacters = 0u;
-        tmpLineLayout.numberOfGlyphs = 0u;
-        tmpLineLayout.length = 0u;
-        tmpLineLayout.widthAdvanceDiff = 0u;
-        tmpLineLayout.wsLengthEndOfLine = 0u;
-        tmpLineLayout.ascender = 0.f;
-        tmpLineLayout.descender = MAX_FLOAT;
+        tmpLineLayout.Clear();
       }
 
+      // Check if the font of the current glyph is the same of the previous one.
+      // If it's different the ascender and descender need to be updated.
       if( lastFontId != glyphInfo.fontId )
       {
-        Text::FontMetrics fontMetrics;
-        mFontClient.GetFontMetrics( glyphInfo.fontId, fontMetrics );
-
-        // Sets the maximum ascender.
-        if( fontMetrics.ascender > tmpLineLayout.ascender )
-        {
-          tmpLineLayout.ascender = fontMetrics.ascender;
-        }
-
-        // Sets the minimum descender.
-        if( -fontMetrics.descender < tmpLineLayout.descender )
-        {
-          tmpLineLayout.descender = fontMetrics.descender;
-        }
-
+        UpdateLineHeight( glyphInfo.fontId, tmpLineLayout );
         lastFontId = glyphInfo.fontId;
       }
     }
@@ -333,32 +307,77 @@ struct LayoutEngine::Impl
                    Vector<LineRun>& lines,
                    Size& actualSize )
   {
-    // TODO Switch between different layouts
-    bool update = false;
+    Vector2* glyphPositionsBuffer = glyphPositions.Begin();
 
-    switch( mLayout )
+    float penY = 0.f;
+    for( GlyphIndex index = 0u; index < layoutParameters.totalNumberOfGlyphs; )
     {
-      case LayoutEngine::SINGLE_LINE_BOX:
+      // Get the layout for the line.
+      LineLayout layout;
+      layout.glyphIndex = index;
+      GetLineLayoutForBox( layoutParameters,
+                           layout );
+
+      if( 0u == layout.numberOfGlyphs )
       {
-        update = SingleLineLayout( layoutParameters,
-                                   glyphPositions,
-                                   lines,
-                                   actualSize );
-        break;
+        // The width is too small and no characters are laid-out.
+        return false;
       }
-      case LayoutEngine::MULTI_LINE_BOX:
+
+      LineRun lineRun;
+      lineRun.glyphIndex = index;
+      lineRun.numberOfGlyphs = layout.numberOfGlyphs;
+      lineRun.characterRun.characterIndex = layout.characterIndex;
+      lineRun.characterRun.numberOfCharacters = layout.numberOfCharacters;
+      lineRun.width = layout.length + layout.widthAdvanceDiff;
+      lineRun.ascender = layout.ascender;
+      lineRun.descender = layout.descender;
+      lineRun.extraLength = layout.wsLengthEndOfLine > 0.f ? layout.wsLengthEndOfLine - layout.widthAdvanceDiff : 0.f;
+      lineRun.direction = false;
+
+      lines.PushBack( lineRun );
+
+      // Update the actual size.
+      if( lineRun.width > actualSize.width )
       {
-        update = MultiLineLayout( layoutParameters,
-                                  glyphPositions,
-                                  lines,
-                                  actualSize );
-        break;
+        actualSize.width = lineRun.width;
       }
-      default:
-        break;
+
+      actualSize.height += ( lineRun.ascender + -lineRun.descender );
+
+      // Traverse the glyphs and set the positions.
+
+      penY += layout.ascender;
+
+      // Check if the x bearing of the first character is negative.
+      // If it has a negative x bearing, it will exceed the boundaries of the actor,
+      // so the penX position needs to be moved to the right.
+      float penX = 0.f;
+
+      const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + index );
+      if( 0.f > glyph.xBearing )
+      {
+        penX = -glyph.xBearing;
+      }
+
+      for( GlyphIndex i = index; i < index + layout.numberOfGlyphs; ++i )
+      {
+        const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + i );
+        Vector2& position = *( glyphPositionsBuffer + i );
+
+        position.x = penX + glyph.xBearing;
+        position.y = penY - glyph.yBearing;
+
+        penX += glyph.advance;
+      }
+
+      penY += -layout.descender;
+
+      // Increase the glyph index.
+      index += layout.numberOfGlyphs;
     }
 
-    return update;
+    return true;
   }
 
   void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters,
@@ -371,6 +390,11 @@ struct LayoutEngine::Impl
 
       float penX = 0.f;
 
+      const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *bidiLine.visualToLogicalMap;
+      const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) );
+
+      penX = -glyph.xBearing;
+
       Vector2* glyphPositionsBuffer = glyphPositions.Begin();
 
       // Traverses the characters of the right to left paragraph.
@@ -462,125 +486,6 @@ struct LayoutEngine::Impl
     }
   }
 
-  bool SingleLineLayout( const LayoutParameters& layoutParameters,
-                         Vector<Vector2>& glyphPositions,
-                         Vector<LineRun>& lines,
-                         Size& actualSize )
-  {
-    LineLayout layout;
-    layout.glyphIndex = 0u;
-    GetLineLayoutForBox( layoutParameters,
-                         layout );
-
-    // Create a line run and add it to the lines.
-    const GlyphIndex lastGlyphIndex = layoutParameters.totalNumberOfGlyphs - 1u;
-
-    LineRun lineRun;
-    lineRun.glyphIndex = 0u;
-    lineRun.numberOfGlyphs = layoutParameters.totalNumberOfGlyphs;
-    lineRun.characterRun.characterIndex = 0u;
-    lineRun.characterRun.numberOfCharacters = *( layoutParameters.glyphsToCharactersBuffer + lastGlyphIndex ) + *( layoutParameters.charactersPerGlyphBuffer + lastGlyphIndex );
-    lineRun.width = layout.length;
-    lineRun.ascender = layout.ascender;
-    lineRun.descender = layout.descender;
-    lineRun.extraLength = layout.wsLengthEndOfLine;
-    lineRun.direction = false;
-
-    lines.PushBack( lineRun );
-
-    // Update the actual size.
-    actualSize.width = layout.length;
-    actualSize.height = lineRun.ascender + -lineRun.descender;
-
-    float penX = 0.f;
-    float penY = layout.ascender;
-
-    Vector2* glyphPositionsBuffer = glyphPositions.Begin();
-    for( GlyphIndex glyphIndex = 0u; glyphIndex < layout.numberOfGlyphs; ++glyphIndex )
-    {
-      const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + glyphIndex );
-      Vector2& position = *( glyphPositionsBuffer + glyphIndex );
-
-      position.x = penX + glyph.xBearing;
-      position.y = penY - glyph.yBearing;
-
-      penX += glyph.advance;
-    }
-
-    return true;
-  }
-
-  bool MultiLineLayout( const LayoutParameters& layoutParameters,
-                        Vector<Vector2>& glyphPositions,
-                        Vector<LineRun>& lines,
-                        Size& actualSize )
-  {
-    float penY = 0.f;
-    for( GlyphIndex index = 0u; index < layoutParameters.totalNumberOfGlyphs; )
-    {
-      float penX = 0.f;
-
-      // Get the layout for the line.
-      LineLayout layout;
-      layout.glyphIndex = index;
-      GetMultiLineLayoutForBox( layoutParameters,
-                                layout );
-
-      if( 0u == layout.numberOfGlyphs )
-      {
-        // The width is too small and no characters are laid-out.
-        return false;
-      }
-
-      // Create a line run and add it to the lines.
-      const GlyphIndex lastGlyphIndex = index + layout.numberOfGlyphs - 1u;
-
-      LineRun lineRun;
-      lineRun.glyphIndex = index;
-      lineRun.numberOfGlyphs = layout.numberOfGlyphs;
-      lineRun.characterRun.characterIndex = *( layoutParameters.glyphsToCharactersBuffer + index );
-      lineRun.characterRun.numberOfCharacters = ( *( layoutParameters.glyphsToCharactersBuffer + lastGlyphIndex ) + *( layoutParameters.charactersPerGlyphBuffer + lastGlyphIndex ) ) - lineRun.characterRun.characterIndex;
-      lineRun.width = layout.length + ( ( layout.widthAdvanceDiff > 0.f ) ? layout.widthAdvanceDiff : 0.f );
-      lineRun.ascender = layout.ascender;
-      lineRun.descender = layout.descender;
-      lineRun.extraLength = layout.wsLengthEndOfLine;
-      lineRun.direction = false;
-
-      lines.PushBack( lineRun );
-
-      // Update the actual size.
-      if( layout.length + layout.widthAdvanceDiff > actualSize.width )
-      {
-        actualSize.width = layout.length;
-      }
-
-      actualSize.height += ( lineRun.ascender + -lineRun.descender );
-
-      // Traverse the glyphs and set the positions.
-
-      penY += layout.ascender;
-
-      Vector2* glyphPositionsBuffer = glyphPositions.Begin();
-      for( GlyphIndex i = index; i < index + layout.numberOfGlyphs; ++i )
-      {
-        const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + i );
-        Vector2& position = *( glyphPositionsBuffer + i );
-
-        position.x = penX + glyph.xBearing;
-        position.y = penY - glyph.yBearing;
-
-        penX += glyph.advance;
-      }
-
-      penY += -layout.descender;
-
-      // Increase the glyph index.
-      index += layout.numberOfGlyphs;
-    }
-
-    return true;
-  }
-
   float CalculateHorizontalAlignment( float boxWidth,
                                       float lineLength,
                                       float extraLength,
index a370c02..8a49a91 100644 (file)
@@ -56,6 +56,7 @@ struct LayoutParameters
                     const Character* const textBuffer,
                     const LineBreakInfo* const lineBreakInfoBuffer,
                     const WordBreakInfo* const wordBreakInfoBuffer,
+                    const CharacterDirection* const characterDirectionBuffer,
                     Length totalNumberOfGlyphs,
                     const GlyphInfo* const glyphsBuffer,
                     const CharacterIndex* const glyphsToCharactersBuffer,
@@ -64,6 +65,7 @@ struct LayoutParameters
     textBuffer( textBuffer ),
     lineBreakInfoBuffer( lineBreakInfoBuffer ),
     wordBreakInfoBuffer( wordBreakInfoBuffer ),
+    characterDirectionBuffer( characterDirectionBuffer ),
     totalNumberOfGlyphs( totalNumberOfGlyphs ),
     glyphsBuffer( glyphsBuffer ),
     glyphsToCharactersBuffer( glyphsToCharactersBuffer ),
@@ -74,18 +76,19 @@ struct LayoutParameters
     numberOfBidirectionalInfoRuns( 0u )
   {}
 
-  Vector2                     boundingBox;
-  const Character* const      textBuffer;
-  const LineBreakInfo* const  lineBreakInfoBuffer;
-  const WordBreakInfo* const  wordBreakInfoBuffer;
-  Length                      totalNumberOfGlyphs;
-  const GlyphInfo* const      glyphsBuffer;
-  const CharacterIndex* const glyphsToCharactersBuffer;
-  const Length* const         charactersPerGlyphBuffer;
-  GlyphIndex*                 charactersToGlyphsBuffer;        ///< The character to glyph conversion table.
-  Length*                     glyphsPerCharacterBuffer;        ///< The number of glyphs per character.
-  BidirectionalLineInfoRun*   lineBidirectionalInfoRunsBuffer; ///< Bidirectional conversion tables per line.
-  Length                      numberOfBidirectionalInfoRuns;   ///< The number of lines with bidirectional info.
+  Vector2                         boundingBox;
+  const Character* const          textBuffer;
+  const LineBreakInfo* const      lineBreakInfoBuffer;
+  const WordBreakInfo* const      wordBreakInfoBuffer;
+  const CharacterDirection* const characterDirectionBuffer;
+  Length                          totalNumberOfGlyphs;
+  const GlyphInfo* const          glyphsBuffer;
+  const CharacterIndex* const     glyphsToCharactersBuffer;
+  const Length* const             charactersPerGlyphBuffer;
+  GlyphIndex*                     charactersToGlyphsBuffer;        ///< The character to glyph conversion table.
+  Length*                         glyphsPerCharacterBuffer;        ///< The number of glyphs per character.
+  BidirectionalLineInfoRun*       lineBidirectionalInfoRunsBuffer; ///< Bidirectional conversion tables per line.
+  Length                          numberOfBidirectionalInfoRuns;   ///< The number of lines with bidirectional info.
 };
 
 } // namespace Text
index cbfa754..6a10947 100644 (file)
@@ -34,7 +34,7 @@ class AtlasGlyphManager;
 }
 
 
-class DALI_IMPORT_API AtlasGlyphManager : public BaseHandle
+class AtlasGlyphManager : public BaseHandle
 {
 public:
 
index df7bfa2..42eacff 100644 (file)
@@ -41,7 +41,7 @@ class Backend;
 /**
  * @brief Provides access to different text rendering backends.
  */
-class DALI_IMPORT_API Backend : public BaseHandle
+class Backend : public BaseHandle
 {
 public:
 
index 2a3631f..1e9ee89 100644 (file)
@@ -1804,6 +1804,7 @@ bool Controller::DoRelayout( const Size& size,
 
     Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
     Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
+    Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
     Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
     Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
     Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
@@ -1813,6 +1814,7 @@ bool Controller::DoRelayout( const Size& size,
                                        mImpl->mLogicalModel->mText.Begin(),
                                        lineBreakInfo.Begin(),
                                        wordBreakInfo.Begin(),
+                                       ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
                                        numberOfGlyphs,
                                        glyphs.Begin(),
                                        glyphsToCharactersMap.Begin(),
index 1a58f8d..888322a 100644 (file)
@@ -19,6 +19,7 @@
 #include "cube-transition-effect-impl.h"
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <dali/public-api/common/stage.h>
 #include <dali/public-api/images/buffer-image.h>
 #include <dali/public-api/object/type-registry.h>
index 6ef28a6..0e2d988 100644 (file)
@@ -18,6 +18,9 @@
 // CLASS HEADER
 #include <dali-toolkit/public-api/controls/cluster/cluster-style.h>
 
+// EXTERNAL INCLUDES
+#include <limits>
+
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/cluster/cluster-style-impl.h>
 
index 9e21d2a..d65c16b 100644 (file)
@@ -19,6 +19,8 @@
 #include <dali-toolkit/public-api/controls/control-impl.h>
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
+#include <limits>
 #include <stack>
 #include <dali/public-api/actors/image-actor.h>
 #include <dali/public-api/actors/mesh-actor.h>
index d41a704..ee9ca7d 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <boost/function.hpp>
 #include <dali/public-api/animation/alpha-functions.h>
 #include <dali/public-api/common/vector-wrapper.h>
 
index 45d0fbf..cc315c0 100644 (file)
@@ -20,6 +20,7 @@
 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 
 // INTERNAL INCLUDES
 
index 147ad73..808bfca 100644 (file)
@@ -2,7 +2,7 @@
  * The Dali::CustomActor is used as a base class for UI controls.  It is a proxy object to enable derived classes access
  * to a subset of the methods defined in the internal Actor class.
  *
- * Classes deriving from Custom Actor should follow the same design principle as the rest of the Dali API.
+ * Classes deriving from Custom Actor should follow the same handle - body design principle as the rest of the Dali API.
  *
  * One class of the new UI control should inherit from Dali::CustomActor, while a second should inherit
  * Dali::CustomActorImpl.  This implementation class contains a number of pure virtual methods that enable the new UI
  *
  * In the New() method for the myNewButton class, the user should then create a new instance of the myNewButtonImpl class
  * and pass this to the constructor of the myNewButton object.  Internally the connection will be made
- * between the new widget actor and Dali, thus allowing messages such as OnSizeSet to be received by the new actor.
+ * between the new widget actor and Dali, thus allowing messages such as OnPropertySet to be received by the new actor.
  *
  * It is the responsibility of the implementation of the new UI control to implement the method bodies for the inherited
  * pure virtual methods from Dali::CustomActorImpl.  Obviously the application won't compile if the methods are not
  * overidden, but the user does not need to fill in the code for methods they don't want or need to use.
  *
- * The following code shows the static New() method from the implementation part of the TextView UI control:
- * \code
- * Dali::Toolkit::TextView TextView::New()
- * {
- *   // Create the implementation, temporarily owned on stack
- *   boost::intrusive_ptr< TextView > textView = new TextView;
- *
- *   // Pass ownership to CustomActor
- *   Dali::Toolkit::TextView handle( *textView );
- *
- *   // Second-phase init of the implementation
- *   // This can only be done after the CustomActor connection has been made...
- *   textView->Initialize();
- *
- *   return handle;
- * }
- * \endcode
- *
  * After the implementation object is created it is passed back to the basic Text View through the constructor,the
  * constructor uses this passed in object to initialise the internal implementation objects.
  *
  * handler methods, and do all the rest of their widget processing the the main myNewButton class.  Access to the
  * implementation class can be gained using the GetImpl(*this) method.  For example:
  *
- * \code
- * void TextView::SetFont(const Font newFont)
- * {
- *  GetImpl(*this).SetFont(newFont);
- * }
- * \endcode
  */
index 3fba14a..1a11440 100644 (file)
 #include "animation-api.h"
 #include "path-wrapper.h"
 
+// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
+#include <dali/integration-api/debug.h>
+
+
 // INTERNAL INCLUDES
 #include <v8-utils.h>
-#include <dali/integration-api/debug.h>
 #include <animation/animation-wrapper.h>
 #include <object/property-value-wrapper.h>
-#include <dali/public-api/common/map-wrapper.h>
 
 namespace Dali
 {
@@ -43,7 +46,6 @@ struct AlphaFuncStruct
 };
 /**
  * Contains a list of alpha functions that can be used.
- * We use a stl map as lookup to map a string name to the function
  */
 const AlphaFuncStruct AlphaFunctionTable[]=
 {
index 55d4a0e..d8359e2 100644 (file)
 // CLASS HEADER
 #include "signal-manager.h"
 
+// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
+#include <dali/public-api/images/resource-image.h>
+#include <dali/public-api/object/any.h>
+#include <dali/public-api/events/pan-gesture-detector.h>
+#include <dali/public-api/object/any.h>
+#include <dali/public-api/images/image.h>
+#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/hover-event.h>
+#include <dali/public-api/events/mouse-wheel-event.h>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/events/pan-gesture.h>
+
 // INTERNAL INCLUDES
 #include <v8-utils.h>
 #include <object/handle-wrapper.h>
 #include <events/pan-gesture-detector-wrapper.h>
 #include <toolkit/focus-manager/keyboard-focus-manager-wrapper.h>
 #include <signals/dali-any-javascript-converter.h>
-#include <dali/public-api/images/resource-image.h>
-#include <dali/public-api/object/any.h>
-#include <dali/public-api/events/pan-gesture-detector.h>
-#include <dali/public-api/object/any.h>
-#include <dali/public-api/images/image.h>
-#include <dali/public-api/events/touch-event.h>
-#include <dali/public-api/events/hover-event.h>
-#include <dali/public-api/events/mouse-wheel-event.h>
-#include <dali/public-api/events/key-event.h>
-#include <dali/public-api/events/pan-gesture.h>