From ebf934591e44439f76b1240cef344b1132bcc1d6 Mon Sep 17 00:00:00 2001 From: "taeyoon0.lee" Date: Tue, 12 Dec 2017 17:18:18 +0900 Subject: [PATCH] Modified GetTextDirection for TEXT_DIRECTION property - Requirement is to check always the direction if textlabel gets text. Change-Id: I0fe40c84f9cf1567fa7ae5acdfdea46f1b71911a --- automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp | 7 ++----- dali-toolkit/internal/text/text-controller.cpp | 11 +++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 45214f8..35e1ae7 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -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; diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index d054cbc..3a58fc7 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -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; } -- 2.7.4