Text vertical alignment added. 42/37442/3
authorVictor Cebollada <v.cebollada@samsung.com>
Thu, 26 Mar 2015 15:37:44 +0000 (15:37 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Thu, 26 Mar 2015 16:14:14 +0000 (16:14 +0000)
Change-Id: I5779ef71b2c7f1c041d88232941853fcecd22701
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/text/layouts/layout-engine.cpp
dali-toolkit/internal/text/layouts/layout-engine.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/public-api/controls/text-controls/text-field.h
dali-toolkit/public-api/controls/text-controls/text-label.h

index 71a4c5f..390cb89 100644 (file)
@@ -54,13 +54,21 @@ namespace
 namespace
 {
 
-const Scripting::StringEnum< Toolkit::Text::LayoutEngine::Alignment > ALIGNMENT_STRING_TABLE[] =
+const Scripting::StringEnum< Toolkit::Text::LayoutEngine::HorizontalAlignment > HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
-  { "BEGIN",  Toolkit::Text::LayoutEngine::ALIGN_BEGIN  },
-  { "CENTER", Toolkit::Text::LayoutEngine::ALIGN_CENTER },
-  { "END",    Toolkit::Text::LayoutEngine::ALIGN_END    },
+  { "BEGIN",  Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN  },
+  { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
+  { "END",    Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END    },
 };
-const unsigned int ALIGNMENT_STRING_TABLE_COUNT = sizeof( ALIGNMENT_STRING_TABLE ) / sizeof( ALIGNMENT_STRING_TABLE[0] );
+const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
+
+const Scripting::StringEnum< Toolkit::Text::LayoutEngine::VerticalAlignment > VERTICAL_ALIGNMENT_STRING_TABLE[] =
+{
+  { "TOP",    Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP    },
+  { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
+  { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
+};
+const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
 
 // Type registration
 BaseHandle Create()
@@ -84,8 +92,9 @@ DALI_PROPERTY_REGISTRATION( TextField, "enable-cursor-blink",     BOOLEAN,   ENA
 DALI_PROPERTY_REGISTRATION( TextField, "cursor-blink-interval",   FLOAT,     CURSOR_BLINK_INTERVAL   )
 DALI_PROPERTY_REGISTRATION( TextField, "cursor-blink-duration",   FLOAT,     CURSOR_BLINK_DURATION   )
 DALI_PROPERTY_REGISTRATION( TextField, "grab-handle-image",       STRING,    GRAB_HANDLE_IMAGE       )
-DALI_PROPERTY_REGISTRATION( TextField, "decoration bounding-box", RECTANGLE, DECORATION_BOUNDING_BOX )
-DALI_PROPERTY_REGISTRATION( TextField, "alignment",               STRING,    ALIGNMENT               )
+DALI_PROPERTY_REGISTRATION( TextField, "decoration-bounding-box", RECTANGLE, DECORATION_BOUNDING_BOX )
+DALI_PROPERTY_REGISTRATION( TextField, "horizontal-alignment",    STRING,    HORIZONTAL_ALIGNMENT    )
+DALI_PROPERTY_REGISTRATION( TextField, "vertical-alignment",      STRING,    VERTICAL_ALIGNMENT      )
 DALI_TYPE_REGISTRATION_END()
 
 } // namespace
@@ -247,16 +256,30 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
         }
         break;
       }
-      case Toolkit::TextField::Property::ALIGNMENT:
+      case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
       {
         LayoutEngine& engine = impl.mController->GetLayoutEngine();
-        const LayoutEngine::Alignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::Alignment >( value.Get< std::string >().c_str(),
-                                                                                                                       ALIGNMENT_STRING_TABLE,
-                                                                                                                       ALIGNMENT_STRING_TABLE_COUNT );
+        const LayoutEngine::HorizontalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
+                                                                                                                                           HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                                                           HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
 
-        if( engine.GetAlignment() != alignment )
+        if( engine.GetHorizontalAlignment() != alignment )
         {
-          engine.SetAlignment( alignment );
+          engine.SetHorizontalAlignment( alignment );
+          impl.RequestTextRelayout();
+        }
+        break;
+      }
+      case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
+      {
+        LayoutEngine& engine = impl.mController->GetLayoutEngine();
+        const LayoutEngine::VerticalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
+                                                                                                                                       VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                                                                       VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+
+        if( engine.GetVerticalAlignment() != alignment )
+        {
+          engine.SetVerticalAlignment( alignment );
           impl.RequestTextRelayout();
         }
         break;
@@ -352,13 +375,23 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde
         }
         break;
       }
-      case Toolkit::TextField::Property::ALIGNMENT:
+      case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
+      {
+        if( impl.mController )
+        {
+          value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
+                                                                                                                  HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                                  HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+        }
+        break;
+      }
+      case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
       {
         if( impl.mController )
         {
-          value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::Alignment >( impl.mController->GetLayoutEngine().GetAlignment(),
-                                                                                                        ALIGNMENT_STRING_TABLE,
-                                                                                                        ALIGNMENT_STRING_TABLE_COUNT ) );
+          value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
+                                                                                                                  VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                                                  VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ) );
         }
         break;
       }
index efcecbf..1da86f5 100644 (file)
@@ -50,13 +50,21 @@ namespace
 namespace
 {
 
-const Scripting::StringEnum< Toolkit::Text::LayoutEngine::Alignment > ALIGNMENT_STRING_TABLE[] =
+const Scripting::StringEnum< Toolkit::Text::LayoutEngine::HorizontalAlignment > HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
-  { "BEGIN",  Toolkit::Text::LayoutEngine::ALIGN_BEGIN  },
-  { "CENTER", Toolkit::Text::LayoutEngine::ALIGN_CENTER },
-  { "END",    Toolkit::Text::LayoutEngine::ALIGN_END    },
+  { "BEGIN",  Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN  },
+  { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
+  { "END",    Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END    },
 };
-const unsigned int ALIGNMENT_STRING_TABLE_COUNT = sizeof( ALIGNMENT_STRING_TABLE ) / sizeof( ALIGNMENT_STRING_TABLE[0] );
+const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
+
+const Scripting::StringEnum< Toolkit::Text::LayoutEngine::VerticalAlignment > VERTICAL_ALIGNMENT_STRING_TABLE[] =
+{
+  { "TOP",    Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP    },
+  { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
+  { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
+};
+const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
 
 // Type registration
 BaseHandle Create()
@@ -67,13 +75,14 @@ BaseHandle Create()
 // Setup properties, signals and actions using the type-registry.
 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextLabel, Toolkit::Control, Create );
 
-DALI_PROPERTY_REGISTRATION( TextLabel, "rendering-backend", INTEGER, RENDERING_BACKEND )
-DALI_PROPERTY_REGISTRATION( TextLabel, "text",              STRING,  TEXT              )
-DALI_PROPERTY_REGISTRATION( TextLabel, "font-family",       STRING,  FONT_FAMILY       )
-DALI_PROPERTY_REGISTRATION( TextLabel, "font-style",        STRING,  FONT_STYLE        )
-DALI_PROPERTY_REGISTRATION( TextLabel, "point-size",        FLOAT,   POINT_SIZE        )
-DALI_PROPERTY_REGISTRATION( TextLabel, "multi-line",        BOOLEAN, MULTI_LINE        )
-DALI_PROPERTY_REGISTRATION( TextLabel, "alignment",         STRING,  ALIGNMENT         )
+DALI_PROPERTY_REGISTRATION( TextLabel, "rendering-backend",    INTEGER, RENDERING_BACKEND    )
+DALI_PROPERTY_REGISTRATION( TextLabel, "text",                 STRING,  TEXT                 )
+DALI_PROPERTY_REGISTRATION( TextLabel, "font-family",          STRING,  FONT_FAMILY          )
+DALI_PROPERTY_REGISTRATION( TextLabel, "font-style",           STRING,  FONT_STYLE           )
+DALI_PROPERTY_REGISTRATION( TextLabel, "point-size",           FLOAT,   POINT_SIZE           )
+DALI_PROPERTY_REGISTRATION( TextLabel, "multi-line",           BOOLEAN, MULTI_LINE           )
+DALI_PROPERTY_REGISTRATION( TextLabel, "horizontal-alignment", STRING,  HORIZONTAL_ALIGNMENT )
+DALI_PROPERTY_REGISTRATION( TextLabel, "vertical-alignment",   STRING,  VERTICAL_ALIGNMENT   )
 
 DALI_TYPE_REGISTRATION_END()
 
@@ -181,16 +190,30 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
         }
         break;
       }
-      case Toolkit::TextLabel::Property::ALIGNMENT:
+      case Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT:
       {
         LayoutEngine& engine = impl.mController->GetLayoutEngine();
-        const LayoutEngine::Alignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::Alignment >( value.Get< std::string >().c_str(),
-                                                                                                                       ALIGNMENT_STRING_TABLE,
-                                                                                                                       ALIGNMENT_STRING_TABLE_COUNT );
+        const LayoutEngine::HorizontalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
+                                                                                                                                           HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                                                           HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
 
-        if( engine.GetAlignment() != alignment )
+        if( engine.GetHorizontalAlignment() != alignment )
         {
-          engine.SetAlignment( alignment );
+          engine.SetHorizontalAlignment( alignment );
+          impl.RequestTextRelayout();
+        }
+        break;
+      }
+      case Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT:
+      {
+        LayoutEngine& engine = impl.mController->GetLayoutEngine();
+        const LayoutEngine::VerticalAlignment alignment = Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
+                                                                                                                                       VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                                                                       VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+
+        if( engine.GetVerticalAlignment() != alignment )
+        {
+          engine.SetVerticalAlignment( alignment );
           impl.RequestTextRelayout();
         }
         break;
@@ -233,13 +256,23 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
         }
         break;
       }
-      case Toolkit::TextLabel::Property::ALIGNMENT:
+      case Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT:
+      {
+        if( impl.mController )
+        {
+          value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
+                                                                                                                  HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                                  HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT ) );
+        }
+        break;
+      }
+      case Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT:
       {
         if( impl.mController )
         {
-          value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::Alignment >( impl.mController->GetLayoutEngine().GetAlignment(),
-                                                                                                        ALIGNMENT_STRING_TABLE,
-                                                                                                        ALIGNMENT_STRING_TABLE_COUNT ) );
+          value = std::string( Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
+                                                                                                                VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                                                VERTICAL_ALIGNMENT_STRING_TABLE_COUNT ) );
         }
         break;
       }
index 9bde93f..fa1e919 100644 (file)
@@ -55,7 +55,8 @@ struct LayoutEngine::Impl
 {
   Impl()
   : mLayout( LayoutEngine::SINGLE_LINE_BOX ),
-    mAlignment( LayoutEngine::ALIGN_BEGIN )
+    mHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ),
+    mVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP )
   {
     mFontClient = TextAbstraction::FontClient::Get();
   }
@@ -435,10 +436,10 @@ struct LayoutEngine::Impl
 
       // 2) Calculate the alignment offset accordingly with the align option,
       //    the box width, line length, and the paragraphs direction.
-      float alignOffset = CalculateAlignment( layoutSize.width,
-                                              line.lineSize.width,
-                                              line.extraLength,
-                                              paragraphDirection );
+      float alignOffset = CalculateHorizontalAlignment( layoutSize.width,
+                                                        line.lineSize.width,
+                                                        line.extraLength,
+                                                        paragraphDirection );
 
       // 3) Traverse all glyphs and update the 'x' position.
       for( GlyphIndex index = line.glyphIndex,
@@ -568,42 +569,42 @@ struct LayoutEngine::Impl
     return true;
   }
 
-  float CalculateAlignment( float boxWidth,
-                            float lineLength,
-                            float extraLength,
-                            bool paragraphDirection )
+  float CalculateHorizontalAlignment( float boxWidth,
+                                      float lineLength,
+                                      float extraLength,
+                                      bool paragraphDirection )
   {
     float offset = 0.f;
 
-    Alignment alignment = mAlignment;
+    HorizontalAlignment alignment = mHorizontalAlignment;
     if( paragraphDirection &&
-        ( ALIGN_CENTER != alignment ) )
+        ( HORIZONTAL_ALIGN_CENTER != alignment ) )
     {
-      if( ALIGN_BEGIN == alignment )
+      if( HORIZONTAL_ALIGN_BEGIN == alignment )
       {
-        alignment = ALIGN_END;
+        alignment = HORIZONTAL_ALIGN_END;
       }
       else
       {
-        alignment = ALIGN_BEGIN;
+        alignment = HORIZONTAL_ALIGN_BEGIN;
       }
     }
 
     switch( alignment )
     {
-      case ALIGN_BEGIN:
+      case HORIZONTAL_ALIGN_BEGIN:
       {
         offset = 0.f;
         break;
       }
-      case ALIGN_CENTER:
+      case HORIZONTAL_ALIGN_CENTER:
       {
         offset = 0.5f * ( boxWidth - lineLength );
         const int intOffset = static_cast<int>( offset ); // try to avoid pixel alignment.
         offset = static_cast<float>( intOffset );
         break;
       }
-      case ALIGN_END:
+      case HORIZONTAL_ALIGN_END:
       {
         offset = boxWidth - lineLength;
         break;
@@ -619,7 +620,8 @@ struct LayoutEngine::Impl
   }
 
   LayoutEngine::Layout mLayout;
-  LayoutEngine::Alignment mAlignment;
+  LayoutEngine::HorizontalAlignment mHorizontalAlignment;
+  LayoutEngine::VerticalAlignment mVerticalAlignment;
 
   TextAbstraction::FontClient mFontClient;
 };
@@ -645,14 +647,24 @@ unsigned int LayoutEngine::GetLayout() const
   return mImpl->mLayout;
 }
 
-void LayoutEngine::SetAlignment( Alignment alignment )
+void LayoutEngine::SetHorizontalAlignment( HorizontalAlignment alignment )
 {
-  mImpl->mAlignment = alignment;
+  mImpl->mHorizontalAlignment = alignment;
 }
 
-LayoutEngine::Alignment LayoutEngine::GetAlignment() const
+LayoutEngine::HorizontalAlignment LayoutEngine::GetHorizontalAlignment() const
 {
-  return mImpl->mAlignment;
+  return mImpl->mHorizontalAlignment;
+}
+
+void LayoutEngine::SetVerticalAlignment( VerticalAlignment alignment )
+{
+  mImpl->mVerticalAlignment = alignment;
+}
+
+LayoutEngine::VerticalAlignment LayoutEngine::GetVerticalAlignment() const
+{
+  return mImpl->mVerticalAlignment;
 }
 
 bool LayoutEngine::LayoutText( const LayoutParameters& layoutParameters,
index 1315445..0c17d68 100644 (file)
@@ -51,11 +51,18 @@ public:
     MULTI_LINE_BOX
   };
 
-  enum Alignment
+  enum HorizontalAlignment
   {
-    ALIGN_BEGIN,
-    ALIGN_CENTER,
-    ALIGN_END
+    HORIZONTAL_ALIGN_BEGIN,
+    HORIZONTAL_ALIGN_CENTER,
+    HORIZONTAL_ALIGN_END
+  };
+
+  enum VerticalAlignment
+  {
+    VERTICAL_ALIGN_TOP,
+    VERTICAL_ALIGN_CENTER,
+    VERTICAL_ALIGN_BOTTOM
   };
 
   /**
@@ -83,18 +90,32 @@ public:
   unsigned int GetLayout() const;
 
   /**
-   * @brief Choose the required line alignment.
+   * @brief Choose the required text horizontal alignment.
+   *
+   * @param[in] alignment The required alignment.
+   */
+  void SetHorizontalAlignment( HorizontalAlignment alignment );
+
+  /**
+   * @brief Query the required text horizontal alignment.
+   *
+   * @return The required alignment.
+   */
+  HorizontalAlignment GetHorizontalAlignment() const;
+
+  /**
+   * @brief Choose the required text vertical alignment.
    *
    * @param[in] alignment The required alignment.
    */
-  void SetAlignment( Alignment alignment );
+  void SetVerticalAlignment( VerticalAlignment alignment );
 
   /**
-   * @brief Query the required line alignment.
+   * @brief Query the required text vertical alignment.
    *
    * @return The required alignment.
    */
-  Alignment GetAlignment() const;
+  VerticalAlignment GetVerticalAlignment() const;
 
   /**
    * @brief Store the visual position of glyphs in the VisualModel.
index 7643e4d..ae4bbac 100644 (file)
@@ -1512,49 +1512,66 @@ bool Controller::DoRelayout( const Size& size,
 
 void Controller::CalculateTextAlignment( const Size& size )
 {
-  // TODO : Calculate the vertical offset.
-
   // Get the direction of the first character.
   const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
 
   const Size& actualSize = mImpl->mVisualModel->GetActualSize();
 
   // If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
-  LayoutEngine::Alignment alignment = mImpl->mLayoutEngine.GetAlignment();
+  LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
   if( firstParagraphDirection &&
-      ( LayoutEngine::ALIGN_CENTER != alignment ) )
+      ( LayoutEngine::HORIZONTAL_ALIGN_CENTER != horizontalAlignment ) )
   {
-    if( LayoutEngine::ALIGN_BEGIN == alignment )
+    if( LayoutEngine::HORIZONTAL_ALIGN_BEGIN == horizontalAlignment )
     {
-      alignment = LayoutEngine::ALIGN_END;
+      horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_END;
     }
     else
     {
-      alignment = LayoutEngine::ALIGN_BEGIN;
+      horizontalAlignment = LayoutEngine::HORIZONTAL_ALIGN_BEGIN;
     }
   }
 
-  switch( alignment )
+  switch( horizontalAlignment )
   {
-    case LayoutEngine::ALIGN_BEGIN:
+    case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
     {
-      mImpl->mAlignmentOffset = Vector2::ZERO;
+      mImpl->mAlignmentOffset.x = 0.f;
       break;
     }
-    case LayoutEngine::ALIGN_CENTER:
+    case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
     {
-      mImpl->mAlignmentOffset.y = 0.f;
       const int intOffset = static_cast<int>( 0.5f * ( size.width - actualSize.width ) ); // try to avoid pixel alignment.
       mImpl->mAlignmentOffset.x = static_cast<float>( intOffset );
       break;
     }
-    case LayoutEngine::ALIGN_END:
+    case LayoutEngine::HORIZONTAL_ALIGN_END:
     {
-      mImpl->mAlignmentOffset.y = 0.f;
       mImpl->mAlignmentOffset.x = size.width - actualSize.width;
       break;
     }
   }
+
+  const LayoutEngine::VerticalAlignment verticalAlignment = mImpl->mLayoutEngine.GetVerticalAlignment();
+  switch( verticalAlignment )
+  {
+    case LayoutEngine::VERTICAL_ALIGN_TOP:
+    {
+      mImpl->mAlignmentOffset.y = 0.f;
+      break;
+    }
+    case LayoutEngine::VERTICAL_ALIGN_CENTER:
+    {
+      const int intOffset = static_cast<int>( 0.5f * ( size.height - actualSize.height ) ); // try to avoid pixel alignment.
+      mImpl->mAlignmentOffset.y = static_cast<float>( intOffset );
+      break;
+    }
+    case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
+    {
+      mImpl->mAlignmentOffset.y = size.height - actualSize.height;
+      break;
+    }
+  }
 }
 
 View& Controller::GetView()
index 2e37724..3736a2f 100644 (file)
@@ -69,7 +69,8 @@ public:
       CURSOR_BLINK_DURATION,                    ///< name "cursor-blink-duration",   The cursor will stop blinking after this duration (if non-zero),          type FLOAT
       GRAB_HANDLE_IMAGE,                        ///< name "grab-handle-image",       The image to display for grab handle,                                     type STRING
       DECORATION_BOUNDING_BOX,                  ///< name "decoration-bounding-box", The decorations (handles etc) will positioned within this area on-screen, type RECTANGLE
-      ALIGNMENT,                                ///< name "alignment",               The line alignment,                                                       type STRING,    values "BEGIN", "CENTER", "END"
+      HORIZONTAL_ALIGNMENT,                     ///< name "horizontal-alignment",    The line horizontal alignment,                                            type STRING,  values "BEGIN", "CENTER", "END"
+      VERTICAL_ALIGNMENT                        ///< name "vertical-alignment",      The line vertical alignment,                                              type STRING,  values   "TOP",   "CENTER",   "BOTTOM"
     };
   };
 
index fdb9ec7..37f2771 100644 (file)
@@ -57,13 +57,14 @@ public:
   {
     enum
     {
-      RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "rendering-backend", The type or rendering e.g. bitmap-based,      type INT
-      TEXT,                                     ///< name "text",              The text to display in UTF-8 format,          type STRING
-      FONT_FAMILY,                              ///< name "font-family",       The requested font family,                    type STRING
-      FONT_STYLE,                               ///< name "font-style",        The requested font style e.g. Regular/Italic, type STRING
-      POINT_SIZE,                               ///< name "point-size",        The size of font in points,                   type FLOAT
-      MULTI_LINE,                               ///< name "multi-line",        The single-line or multi-line layout option,  type BOOLEAN
-      ALIGNMENT,                                ///< name "alignment",         The line alignment,                           type STRING,  values "BEGIN", "CENTER", "END"
+      RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "rendering-backend",    The type or rendering e.g. bitmap-based,      type INT
+      TEXT,                                     ///< name "text",                 The text to display in UTF-8 format,          type STRING
+      FONT_FAMILY,                              ///< name "font-family",          The requested font family,                    type STRING
+      FONT_STYLE,                               ///< name "font-style",           The requested font style e.g. Regular/Italic, type STRING
+      POINT_SIZE,                               ///< name "point-size",           The size of font in points,                   type FLOAT
+      MULTI_LINE,                               ///< name "multi-line",           The single-line or multi-line layout option,  type BOOLEAN
+      HORIZONTAL_ALIGNMENT,                     ///< name "horizontal-alignment", The line horizontal alignment,                type STRING,  values "BEGIN", "CENTER", "END"
+      VERTICAL_ALIGNMENT                        ///< name "vertical-alignment",   The line vertical alignment,                  type STRING,  values   "TOP",   "CENTER",   "BOTTOM"
     };
   };