[Tizen] If matchSystemLanguageDirection is set, it must follow the direction of the... 40/221440/1
authorJoogab Yun <joogab.yun@samsung.com>
Tue, 31 Dec 2019 05:20:09 +0000 (14:20 +0900)
committerJoogab Yun <joogab.yun@samsung.com>
Thu, 2 Jan 2020 09:58:26 +0000 (18:58 +0900)
Change-Id: I05d25ad67d43a2303d4902f120a026b14e1ac2e4

automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/internal/visuals/text/text-visual.cpp

index 11584a9..e819f7d 100755 (executable)
@@ -1187,3 +1187,25 @@ int UtcDaliTextControllerMaxLengthSetText(void)
 
   END_TEST;
 }
+
+int UtcDaliTextControllerDirectionCoverage(void)
+{
+  tet_infoline(" UtcDaliTextControllerDirectionCoverage");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  ConfigureTextLabel(controller);
+
+  controller->SetMatchSystemLanguageDirection( true );
+  controller->SetLayoutDirection( Dali::LayoutDirection::RIGHT_TO_LEFT );
+
+  // Perform a relayout
+  const Size size( Dali::Stage::GetCurrent().GetSize() );
+  controller->Relayout(size);
+
+  tet_result(TET_PASS);
+
+  END_TEST;
+}
index 3444c39..3c5333d 100755 (executable)
@@ -1373,7 +1373,7 @@ void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container )
     mActiveLayer.SetPosition( padding.start, padding.top );
   }
 
-  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize, layoutDirection );
+  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize );
 
   if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
       !mRenderer )
index 3f2becd..91aa5a6 100755 (executable)
@@ -1419,7 +1419,7 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
     mActiveLayer.SetPosition( padding.start, padding.top );
   }
 
-  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize, layoutDirection );
+  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize );
 
   if( ( Text::Controller::NONE_UPDATED != updateTextType ) ||
       !mRenderer )
index c521817..c1fb31f 100755 (executable)
@@ -965,10 +965,7 @@ void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container )
     mController->SetTextFitContentSize( contentSize );
   }
 
-  // Support Right-To-Left
-  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
-
-  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize, layoutDirection );
+  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( contentSize );
 
   if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
      || mTextUpdateNeeded )
@@ -979,6 +976,7 @@ void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container )
     TextVisual::EnableRendererUpdate( mVisual );
 
     // Support Right-To-Left of padding
+    Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
     if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
     {
       std::swap( padding.start, padding.end );
index ff038f4..6f9fe15 100755 (executable)
@@ -23,6 +23,8 @@
 #include <cmath>
 #include <memory.h>
 #include <dali/public-api/adaptor-framework/key.h>
+#include <dali/public-api/actors/layer.h>
+#include <dali/public-api/common/stage.h>
 #include <dali/integration-api/debug.h>
 #include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
 #include <dali/devel-api/text-abstraction/font-client.h>
@@ -2475,7 +2477,7 @@ void Controller::SetVerticalLineAlignment( Toolkit::DevelText::VerticalLineAlign
 
 // public : Relayout.
 
-Controller::UpdateTextType Controller::Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection )
+Controller::UpdateTextType Controller::Relayout( const Size& size )
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f, autoScroll[%s]\n", this, size.width, size.height, mImpl->mIsAutoScrollEnabled ?"true":"false"  );
 
@@ -2548,20 +2550,25 @@ Controller::UpdateTextType Controller::Relayout( const Size& size, Dali::LayoutD
     mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
   }
 
-  if( mImpl->mModel->mMatchSystemLanguageDirection  && mImpl->mLayoutDirection != layoutDirection )
+  if( mImpl->mModel->mMatchSystemLanguageDirection )
   {
-    // Clear the update info. This info will be set the next time the text is updated.
-    mImpl->mTextUpdateInfo.mClearAll = true;
-    // Apply modifications to the model
-    // Shape the text again is needed because characters like '()[]{}' have to be mirrored and the glyphs generated again.
-    mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
-                                                             GET_GLYPH_METRICS         |
-                                                             SHAPE_TEXT                |
-                                                             UPDATE_DIRECTION          |
-                                                             LAYOUT                    |
-                                                             BIDI_INFO                 |
-                                                             REORDER );
-    mImpl->mLayoutDirection = layoutDirection;
+    Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( Dali::Stage::GetCurrent().GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+
+    if( mImpl->mLayoutDirection != layoutDirection )
+    {
+      // Clear the update info. This info will be set the next time the text is updated.
+      mImpl->mTextUpdateInfo.mClearAll = true;
+      // Apply modifications to the model
+      // Shape the text again is needed because characters like '()[]{}' have to be mirrored and the glyphs generated again.
+      mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+                                                              GET_GLYPH_METRICS         |
+                                                              SHAPE_TEXT                |
+                                                              UPDATE_DIRECTION          |
+                                                              LAYOUT                    |
+                                                              BIDI_INFO                 |
+                                                              REORDER );
+      mImpl->mLayoutDirection = layoutDirection;
+    }
   }
 
   // Make sure the model is up-to-date before layouting.
index 82a7a15..4e3f5a0 100755 (executable)
@@ -1384,11 +1384,10 @@ public: // Relayout.
    *
    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
    * @param[in] size A the size of a bounding box to layout text within.
-   * @param[in] layoutDirection The direction of the system language.
    *
    * @return Whether the text model or decorations were updated.
    */
-  UpdateTextType Relayout( const Size& size, Dali::LayoutDirection::Type layoutDirection = Dali::LayoutDirection::LEFT_TO_RIGHT );
+  UpdateTextType Relayout( const Size& size );
 
   /**
    * @brief Request a relayout using the ControlInterface.
index 1171033..a328e8f 100755 (executable)
@@ -626,9 +626,7 @@ void TextVisual::UpdateRenderer()
     return;
   }
 
-  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( control.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
-
-  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( relayoutSize, layoutDirection );
+  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( relayoutSize );
 
   if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType )
    || mRendererUpdateNeeded )