Modified GetTextDirection for TEXT_DIRECTION property 94/163594/4
authortaeyoon0.lee <taeyoon0.lee@samsung.com>
Tue, 12 Dec 2017 08:18:18 +0000 (17:18 +0900)
committertaeyoon0.lee <taeyoon0.lee@samsung.com>
Tue, 12 Dec 2017 09:32:35 +0000 (18:32 +0900)
 - Requirement is to check always the direction if textlabel gets text.

Change-Id: I0fe40c84f9cf1567fa7ae5acdfdea46f1b71911a

automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
dali-toolkit/internal/text/text-controller.cpp

index 45214f8b364cc3209b1aa2977bb653c10478f8d7..35e1ae7e864ddf27183372617099602fa0ff2882 100644 (file)
@@ -1163,18 +1163,15 @@ int UtcDaliToolkitTextlabelTextDirection(void)
   tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
 
   TextLabel label = TextLabel::New();
+  DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
+
   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
   Stage::GetCurrent().Add( label );
 
-  application.SendNotification();
-  application.Render();
-
   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
 
   label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
-  application.SendNotification();
-  application.Render();
   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
 
   END_TEST;
index d054cbcfe7701bb1e5f2121a6d392f19bb8349b3..3a58fc7ebd775b2a5814013d005cfd6e62a428aa 100755 (executable)
@@ -2105,8 +2105,15 @@ void Controller::GetPlaceholderProperty( Property::Map& map )
 
 Toolkit::DevelText::TextDirection::Type Controller::GetTextDirection()
 {
-  const LineRun* const firstline = mImpl->mModel->mVisualModel->mLines.Begin();
-  if ( firstline && firstline->direction )
+  if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
+  {
+    return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT;
+  }
+
+  const Character character = mImpl->mModel->mLogicalModel->mText[0];
+  Script script = TextAbstraction::GetCharacterScript( character );
+
+  if( TextAbstraction::IsRightToLeftScript( script ) )
   {
     return Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT;
   }