From a59fbe2d4cd2152ae29d38e8eb7f6a2425000d6c Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Wed, 16 Jun 2021 19:01:05 +0900 Subject: [PATCH] Change MatchSystemLanguageDirection is true. Default text LTR/RTL direction follows the system language direction. And check DALI_MATCH_SYSTEM_LANGUAGE_DIRECTION environment. If you set export DALI_MATCH_SYSTEM_LANGUAGE_DIRECTION=0 then MatchSystemLanguageDirection is false. Change-Id: Ic9c1516a8cdcf45a5ec187097509e7d996d374ff --- .../dali-toolkit-test-utils/toolkit-text-utils.cpp | 9 +++++++++ automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp | 10 +++++----- automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp | 8 ++++---- automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp | 1 + dali-toolkit/internal/text/text-model.cpp | 14 +++++++++++++- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp index 0a426b0..918e9cc 100755 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp @@ -382,6 +382,9 @@ void ConfigureTextLabel( ControllerPtr controller ) // Enable the text elide. controller->SetTextElideEnabled( true ); + + // Disable match system language direction + controller->SetMatchSystemLanguageDirection(false); } void ConfigureTextField( ControllerPtr controller ) @@ -411,6 +414,9 @@ void ConfigureTextField( ControllerPtr controller ) // Disable the text elide. controller->SetTextElideEnabled( false ); + + // Disable match system language direction + controller->SetMatchSystemLanguageDirection(false); } void ConfigureTextEditor( ControllerPtr controller ) @@ -440,6 +446,9 @@ void ConfigureTextEditor( ControllerPtr controller ) // Disable the text elide. controller->SetTextElideEnabled( false ); + + // Disable match system language direction + controller->SetMatchSystemLanguageDirection(false); } } // namespace Text diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 675e2c7..31d1762 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -3048,13 +3048,13 @@ int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void) application.SendNotification(); application.Render(); - // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'. - DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION ); - - // Check the enable match system language direction property - editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true ); + // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'. DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION ); + // Check the disable match system language direction property + editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false ); + DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION ); + application.SendNotification(); application.Render(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 51d27c8..2044ea3 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -3162,12 +3162,12 @@ int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void) application.SendNotification(); application.Render(); - // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'. - DALI_TEST_EQUALS( field.GetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION ); + // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'. + DALI_TEST_EQUALS( field.GetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION ); // Check the match system language direction property - field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true ); - DALI_TEST_EQUALS( field.GetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION ); + field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false ); + DALI_TEST_EQUALS( field.GetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION ); application.SendNotification(); application.Render(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 9a187d6..f505faf 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -1512,6 +1512,7 @@ int UtcDaliToolkitTextlabelTextDirection(void) label.SetProperty( TextLabel::Property::TEXT, "Hello world" ); label.SetProperty( TextLabel::Property::POINT_SIZE, 20 ); + label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false ); application.GetScene().Add( label ); // Test LTR text diff --git a/dali-toolkit/internal/text/text-model.cpp b/dali-toolkit/internal/text/text-model.cpp index 948044e..8565eb3 100644 --- a/dali-toolkit/internal/text/text-model.cpp +++ b/dali-toolkit/internal/text/text-model.cpp @@ -18,12 +18,20 @@ // CLASS HEADER #include +// EXTERNAL INCLUDES +#include + namespace Dali { namespace Toolkit { namespace Text { +namespace +{ +const char* DALI_ENV_MATCH_SYSTEM_LANGUAGE_DIRECTION("DALI_MATCH_SYSTEM_LANGUAGE_DIRECTION"); +} + ModelPtr Model::New() { return ModelPtr(new Model()); @@ -216,10 +224,14 @@ Model::Model() mAlignmentOffset(0.0f), mElideEnabled(false), mIgnoreSpacesAfterText(true), - mMatchSystemLanguageDirection(false) + mMatchSystemLanguageDirection(true) { mLogicalModel = LogicalModel::New(); mVisualModel = VisualModel::New(); + + // Check environment variable for DALI_MATCH_SYSTEM_LANGUAGE_DIRECTION + auto match = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_MATCH_SYSTEM_LANGUAGE_DIRECTION); + mMatchSystemLanguageDirection = match ? (std::atoi(match) == 0 ? false : true) : mMatchSystemLanguageDirection; } Model::~Model() -- 2.7.4