Merge "Add read-only property for getting text line count" into devel/master
authorHeeyong Song <heeyong.song@samsung.com>
Fri, 2 Jun 2017 04:37:37 +0000 (04:37 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 2 Jun 2017 04:37:37 +0000 (04:37 +0000)
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/text/layouts/layout-alignment.h
dali-toolkit/internal/text/text-scroller.cpp
dali-toolkit/internal/text/text-scroller.h

index 4c1e449..4e1fd0f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -559,7 +559,7 @@ int UtcDaliToolkitTextlabelScrollingP(void)
   ToolkitTestApplication application;
   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
-  TextLabel labelFinished = TextLabel::New("Some text to scroll");
+  TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
 
   DALI_TEST_CHECK( labelImmediate );
   DALI_TEST_CHECK( labelFinished );
@@ -605,6 +605,206 @@ int UtcDaliToolkitTextlabelScrollingP(void)
   END_TEST;
 }
 
+int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
+{
+  ToolkitTestApplication application;
+  TextLabel labelShort = TextLabel::New("Some text to scroll");
+  TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!");
+
+  DALI_TEST_CHECK( labelShort );
+  DALI_TEST_CHECK( labelLong );
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+  Stage::GetCurrent().Add( labelShort );
+  // Turn on all the effects
+  labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
+  labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+  labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
+
+  Stage::GetCurrent().Add( labelLong );
+  // Turn on all the effects
+  labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
+  labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+  labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
+
+  try
+  {
+    // Render some text with the shared atlas backend
+    labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+    labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+    application.SendNotification();
+    application.Render();
+
+    labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+    labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+    application.SendNotification();
+    application.Render();
+
+  }
+  catch( ... )
+  {
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
+{
+  ToolkitTestApplication application;
+  TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
+  TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
+
+  DALI_TEST_CHECK( labelShort );
+  DALI_TEST_CHECK( labelLong );
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+  Stage::GetCurrent().Add( labelShort );
+  // Turn on all the effects
+  labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
+  labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+  labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
+
+  Stage::GetCurrent().Add( labelLong );
+  // Turn on all the effects
+  labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
+  labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+  labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
+
+  try
+  {
+    // Render some text with the shared atlas backend
+    labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+    labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+    application.SendNotification();
+    application.Render();
+
+    labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+    labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+    application.SendNotification();
+    application.Render();
+
+  }
+  catch( ... )
+  {
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
+{
+  ToolkitTestApplication application;
+  TextLabel labelShort = TextLabel::New("Some text to scroll");
+  TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!");
+
+  DALI_TEST_CHECK( labelShort );
+  DALI_TEST_CHECK( labelLong );
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+  Stage::GetCurrent().Add( labelShort );
+  // Turn on all the effects
+  labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
+  labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+  labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
+
+  Stage::GetCurrent().Add( labelLong );
+  // Turn on all the effects
+  labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
+  labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+  labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
+
+  try
+  {
+    // Render some text with the shared atlas backend
+    labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+    labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+    application.SendNotification();
+    application.Render();
+
+    labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+    labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+    application.SendNotification();
+    application.Render();
+
+  }
+  catch( ... )
+  {
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
+{
+  ToolkitTestApplication application;
+  TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
+  TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
+
+  DALI_TEST_CHECK( labelShort );
+  DALI_TEST_CHECK( labelLong );
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+  Stage::GetCurrent().Add( labelShort );
+  // Turn on all the effects
+  labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
+  labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+  labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+  labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
+
+  Stage::GetCurrent().Add( labelLong );
+  // Turn on all the effects
+  labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
+  labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+  labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+  labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
+
+  try
+  {
+    // Render some text with the shared atlas backend
+    labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+    labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+    application.SendNotification();
+    application.Render();
+
+    labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+    labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+    application.SendNotification();
+    application.Render();
+
+  }
+  catch( ... )
+  {
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}
+
 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
 {
   ToolkitTestApplication application;
index 5187b25..5f17f00 100644 (file)
@@ -350,7 +350,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
              {
                if( impl.mTextScroller )
                {
-                 impl.mTextScroller->SetLoopCount( 0 ); // Causes the current animation to finish playing (0)
+                 impl.mTextScroller->StopScrolling();
                }
              }
              // If request is enable (true) then start autoscroll as not already running
@@ -891,7 +891,7 @@ void TextLabel::SetUpAutoScrolling()
     // If speed, loopCount or gap not set via property system then will need to create a TextScroller with defaults
     mTextScroller = Text::TextScroller::New( *this );
   }
-  mTextScroller->SetParameters( mRenderableActor, controlSize, offScreenSize, direction, alignmentOffset );
+  mTextScroller->SetParameters( mRenderableActor, controlSize, offScreenSize, direction, alignmentOffset, mController->GetHorizontalAlignment() );
 
   Actor self = Self();
   self.Add( mTextScroller->GetScrollingText() );
index df61ff2..339b321 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,6 +53,12 @@ enum VerticalAlignment
   VERTICAL_ALIGN_BOTTOM
 };
 
+enum AlignmentCount
+{
+  HORIZONTAL_ALIGN_COUNT = HORIZONTAL_ALIGN_END + 1,
+  VERTICAL_ALIGN_COUNT = VERTICAL_ALIGN_BOTTOM + 1
+};
+
 } // namespace Layout
 
 } // namespace Text
index c80cf7d..7d9933d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@ const char* VERTEX_SHADER_SCROLL = DALI_COMPOSE_SHADER(
   uniform mediump float uDelta;\n
   uniform mediump vec2 uTextureSize;
   uniform mediump float uGap;\n
-  uniform mediump float uRtl;\n
+  uniform mediump float uAlign;\n
   \n
   void main()\n
   {\n
@@ -70,7 +70,7 @@ const char* VERTEX_SHADER_SCROLL = DALI_COMPOSE_SHADER(
       float smallTextPadding = max(uSize.x - uTextureSize.x, 0. );\n
       float gap = max( uGap, smallTextPadding );\n
       float delta = floor ( uDelta ) + 0.5;
-      vTexCoord.x = ( delta  + ( uRtl * ( uTextureSize.x - uSize.x ) ) + (  aPosition.x * uSize.x ) )/ ( uTextureSize.x + gap );\n
+      vTexCoord.x = ( delta  + ( uAlign * ( uTextureSize.x - uSize.x ) ) + (  aPosition.x * uSize.x ) )/ ( uTextureSize.x + gap );\n
       vTexCoord.y = ( 0.5 + floor(  aPosition.y * uSize.y ) )/ ( uTextureSize.y ) ;\n
       vRatio = uTextureSize.x / ( uTextureSize.x + gap );\n
       gl_Position = uProjection * vertexPosition;
@@ -96,6 +96,54 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
 );
 
 /**
+ * @brief How the text should be aligned when scrolling the text.
+ *
+ * 0.0f aligns the text to the left, 1.0f aligns the text to the right.
+ * The final alignment depends on three factors:
+ *   1) The alignment value of the text label (Use Text::Layout::HorizontalAlignment enumerations).
+ *   2) The text direction, i.e. whether it's LTR or RTL (0 = LTR, 1 = RTL).
+ *   3) Whether the text is greater than the size of the control ( 0 = Text width <= Control width, 1 = Text width > Control width ).
+ */
+const float ALIGNMENT_TABLE[ Text::Layout::HORIZONTAL_ALIGN_COUNT ][ 2 ][ 2 ] =
+{
+  // HORIZONTAL_ALIGN_BEGIN
+  {
+    { // LTR
+      0.0f, // Text width <= Control width
+      0.0f  // Text width >  Control width
+    },
+    { // RTL
+      1.0f, // Text width <= Control width
+      1.0f  // Text width >  Control width
+    }
+  },
+
+  // HORIZONTAL_ALIGN_CENTER
+  {
+    { // LTR
+      0.5f, // Text width <= Control width
+      0.0f  // Text width >  Control width
+    },
+    { // RTL
+      0.5f, // Text width <= Control width
+      1.0f  // Text width >  Control width
+    }
+  },
+
+  // HORIZONTAL_ALIGN_END
+  {
+    { // LTR
+      1.0f, // Text width <= Control width
+      0.0f  // Text width >  Control width
+    },
+    { // RTL
+      0.0f, // Text width <= Control width
+      1.0f  // Text width >  Control width
+    }
+  }
+};
+
+/**
  * @brief Create and set up a camera for the render task to use
  *
  * @param[in] sizeOfTarget size of the source camera to look at
@@ -224,35 +272,11 @@ int TextScroller::GetSpeed() const
 
 void TextScroller::SetLoopCount( int loopCount )
 {
-  if ( loopCount > 0 )
+  if ( loopCount >= 0 )
   {
     mLoopCount = loopCount;
   }
 
-  if (  mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING )
-  {
-    if ( loopCount == 0 ) // Request to stop looping
-    {
-      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetLoopCount Single loop forced\n" );
-      switch( mStopMode )
-      {
-        case DevelTextLabel::AutoScrollStopMode::IMMEDIATE:
-        {
-          mScrollAnimation.Stop();
-          break;
-        }
-        case DevelTextLabel::AutoScrollStopMode::FINISH_LOOP:
-        {
-          mScrollAnimation.SetLoopCount( 1 ); // As animation already playing this allows the current animation to finish instead of trying to stop mid-way
-          break;
-        }
-        default:
-        {
-           DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Undifined AutoScrollStopMode\n" );
-        }
-      }
-    }
-  }
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetLoopCount [%d] Status[%s]\n", mLoopCount, (loopCount)?"looping":"stop" );
 }
 
@@ -277,6 +301,30 @@ void TextScroller::SetStopMode( DevelTextLabel::AutoScrollStopMode::Type stopMod
   mStopMode = stopMode;
 }
 
+void TextScroller::StopScrolling()
+{
+  if ( mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING )
+  {
+    switch( mStopMode )
+    {
+      case DevelTextLabel::AutoScrollStopMode::IMMEDIATE:
+      {
+        mScrollAnimation.Stop();
+        break;
+      }
+      case DevelTextLabel::AutoScrollStopMode::FINISH_LOOP:
+      {
+        mScrollAnimation.SetLoopCount( 1 ); // As animation already playing this allows the current animation to finish instead of trying to stop mid-way
+        break;
+      }
+      default:
+      {
+          DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Undifined AutoScrollStopMode\n" );
+      }
+    }
+  }
+}
+
 DevelTextLabel::AutoScrollStopMode::Type TextScroller::GetStopMode() const
 {
   return mStopMode;
@@ -308,7 +356,7 @@ TextScroller::~TextScroller()
   CleanUp();
 }
 
-void TextScroller::SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset )
+void TextScroller::SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset, Layout::HorizontalAlignment horizontalAlignment )
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters controlSize[%f,%f] offscreenSize[%f,%f] direction[%d] alignmentOffset[%f]\n",
                  controlSize.x, controlSize.y, offScreenSize.x, offScreenSize.y, direction, alignmentOffset );
@@ -327,24 +375,58 @@ void TextScroller::SetParameters( Actor sourceActor, const Size& controlSize, co
   CreateRenderer( offscreenRenderTargetForText, renderer );
   CreateRenderTask( sourceActor, mOffscreenCameraActor, offscreenRenderTargetForText, mRenderTask );
 
-  // Reposition camera to match alignment of target, RTL text has direction=true
-  if ( direction )
+  float xPosition = 0.0f;
+  switch( horizontalAlignment )
   {
-    mOffscreenCameraActor.SetX( alignmentOffset + offScreenSize.width*0.5f );
-  }
-  else
-  {
-    mOffscreenCameraActor.SetX( offScreenSize.width * 0.5f );
+    case Layout::HORIZONTAL_ALIGN_BEGIN:
+    {
+      // Reposition camera to match alignment of target, RTL text has direction=true
+      if ( direction )
+      {
+        xPosition = alignmentOffset + offScreenSize.width * 0.5f;
+      }
+      else
+      {
+        xPosition = offScreenSize.width * 0.5f;
+      }
+      break;
+    }
+
+    case Layout::HORIZONTAL_ALIGN_CENTER:
+    {
+      xPosition = controlSize.width * 0.5f;
+      break;
+    }
+
+    case Layout::HORIZONTAL_ALIGN_END:
+    {
+      // Reposition camera to match alignment of target, RTL text has direction=true
+      if ( direction )
+      {
+        xPosition = offScreenSize.width * 0.5f;
+      }
+      else
+      {
+        xPosition = alignmentOffset + offScreenSize.width * 0.5f;
+      }
+      break;
+    }
   }
 
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters xPosition[%f]\n", xPosition );
+
+  mOffscreenCameraActor.SetX( xPosition );
   mOffscreenCameraActor.SetY( offScreenSize.height * 0.5f );
 
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters mWrapGap[%f]\n", mWrapGap )
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters mWrapGap[%f]\n", mWrapGap );
+
+  const float align = ALIGNMENT_TABLE[ horizontalAlignment ][ direction ][ offScreenSize.width > controlSize.width ];
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters align[%f]\n", align );
 
   mScrollingTextActor = Actor::New();
   mScrollingTextActor.AddRenderer( renderer );
   mScrollingTextActor.RegisterProperty( "uTextureSize", offScreenSize );
-  mScrollingTextActor.RegisterProperty( "uRtl", ((direction)?1.0f:0.0f) );
+  mScrollingTextActor.RegisterProperty( "uAlign", align );
   mScrollingTextActor.RegisterProperty( "uGap", mWrapGap );
   mScrollingTextActor.SetSize( controlSize.width, std::min( offScreenSize.height, controlSize.height ) );
   mScrollDeltaIndex = mScrollingTextActor.RegisterProperty( "uDelta", 0.0f );
index f6c0b87..2d611bb 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TOOLKIT_TEXT_SCROLLER_H__
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <dali/public-api/actors/camera-actor.h>
 #include <dali/public-api/animation/animation.h>
 #include <dali/public-api/render-tasks/render-task.h>
-#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
 #include <dali-toolkit/internal/text/text-definitions.h>
+#include <dali-toolkit/internal/text/layouts/layout-alignment.h>
 
 namespace Dali
 {
@@ -66,7 +67,7 @@ public:
    * @param[in] alignmentOffset alignment of source text
    *
    */
-  void SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset );
+  void SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset, Layout::HorizontalAlignment horizontalAlignment );
 
   /**
    * @brief Set the gap distance to elapse before the text wraps around
@@ -123,6 +124,11 @@ public:
   void SetStopMode( DevelTextLabel::AutoScrollStopMode::Type stopMode );
 
   /**
+   * @brief Stop the auto scrolling.
+   */
+  void StopScrolling();
+
+  /**
    * @brief Get the mode of scrolling stop
    * @return stopMode type when text scrolling is stoped.
    */