[Tizen] support match align for system language direciton on text Field and
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller-impl.cpp
index 97a3da9..79d8a41 100755 (executable)
@@ -2741,7 +2741,37 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
     cursorInfo.lineHeight = GetDefaultFontLineHeight();
     cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
 
-    switch( mModel->mHorizontalAlignment )
+    bool isRTL = false;
+    HorizontalAlignment::Type alignment = mModel->mHorizontalAlignment;
+    if( mModel->mMatchSystemLanguageDirection )
+    {
+      isRTL = mLayoutDirection == LayoutDirection::RIGHT_TO_LEFT;
+    }
+    // Swap the alignment type if the line is right to left.
+    if( isRTL )
+    {
+      switch( alignment )
+      {
+        case HorizontalAlignment::BEGIN:
+        {
+          alignment = HorizontalAlignment::END;
+          break;
+        }
+        case HorizontalAlignment::CENTER:
+        {
+          // Nothing to do.
+          break;
+        }
+        case HorizontalAlignment::END:
+        {
+          alignment = HorizontalAlignment::BEGIN;
+          break;
+        }
+      }
+    }
+
+
+    switch( alignment )
     {
       case Text::HorizontalAlignment::BEGIN :
       {