Sorts text sequences in LTR and RTL by system language direction. 71/191971/16
authorJoogab Yun <joogab.yun@samsung.com>
Fri, 26 Oct 2018 06:42:14 +0000 (15:42 +0900)
committerjoogab yun <joogab.yun@samsung.com>
Fri, 2 Nov 2018 00:31:15 +0000 (00:31 +0000)
if matchSystemLanguageDirection property set true,
The text order follows the system language direction.

Change-Id: I4164975b98a2068718a4cc7c0b90afe8839b0acf

19 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.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/bidirectional-support.cpp [changed mode: 0644->0755]
dali-toolkit/internal/text/bidirectional-support.h [changed mode: 0644->0755]
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
docs/content/images/text-controls/HelloWorld-Default-BEGIN.png [new file with mode: 0755]
docs/content/images/text-controls/HelloWorld-Default-CENTER.png [new file with mode: 0755]
docs/content/images/text-controls/HelloWorld-Default-END.png
docs/content/images/text-controls/HelloWorld-System-BEGIN.png [new file with mode: 0755]
docs/content/images/text-controls/HelloWorld-System-CENTER.png [new file with mode: 0755]
docs/content/images/text-controls/HelloWorld-System-END.png
docs/content/images/text-controls/LTR_RTL.png [new file with mode: 0755]
docs/content/images/text-controls/LTR_order.png [new file with mode: 0755]
docs/content/images/text-controls/RTL_order.png [new file with mode: 0755]
docs/content/shared-javascript-and-cpp-documentation/text-label.md

index 75312ef..bef3271 100755 (executable)
@@ -70,7 +70,8 @@ public:
     }
     return bidirectionalSupportHandle;
   }
-  BidiInfoIndex CreateInfo( const Character* const paragraph, Length numberOfCharacters ){return 0;}
+  BidiInfoIndex CreateInfo( const Character* const paragraph, Length numberOfCharacters,
+                            bool matchSystemLanguageDirection, LayoutDirection::Type layoutDirection ){return 0;}
 
   void DestroyInfo( BidiInfoIndex bidiInfoIndex )
   {
@@ -302,9 +303,11 @@ BidirectionalSupport BidirectionalSupport::Get()
 }
 
 BidiInfoIndex BidirectionalSupport::CreateInfo( const Character* const paragraph,
-                                                Length numberOfCharacters )
+                                                Length numberOfCharacters,
+                                                bool matchSystemLanguageDirection,
+                                                LayoutDirection::Type layoutDirection )
 {
-  return GetImplementation( *this ).CreateInfo( paragraph, numberOfCharacters );
+  return GetImplementation( *this ).CreateInfo( paragraph, numberOfCharacters, matchSystemLanguageDirection, layoutDirection );
 }
 
 void BidirectionalSupport::DestroyInfo( BidiInfoIndex bidiInfoIndex )
index af57128..5196d17 100755 (executable)
@@ -1226,6 +1226,10 @@ void TextEditor::OnInitialize()
   mController->SetNoTextDoubleTapAction( Controller::NoTextTap::HIGHLIGHT );
   mController->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT );
 
+  // Sets layoutDirection value
+  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+  mController->SetLayoutDirection( layoutDirection );
+
   // Forward input events to controller
   EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
   GetTapGestureDetector().SetMaximumTapsRequired( 2 );
index d4485ba..5077ced 100755 (executable)
@@ -1286,6 +1286,10 @@ void TextField::OnInitialize()
   mController->SetNoTextDoubleTapAction( Controller::NoTextTap::HIGHLIGHT );
   mController->SetNoTextLongPressAction( Controller::NoTextTap::HIGHLIGHT );
 
+  // Sets layoutDirection value
+  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+  mController->SetLayoutDirection( layoutDirection );
+
   // Forward input events to controller
   EnableGestureDetection( static_cast<Gesture::Type>( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) );
   GetTapGestureDetector().SetMaximumTapsRequired( 2 );
index 7a8c283..376709a 100755 (executable)
@@ -884,6 +884,10 @@ void TextLabel::OnInitialize()
   // Enable the text ellipsis.
   mController->SetTextElideEnabled( true );   // If false then text larger than control will overflow
 
+  // Sets layoutDirection value
+  Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+  mController->SetLayoutDirection( layoutDirection );
+
   Layout::Engine& engine = mController->GetLayoutEngine();
   engine.SetCursorWidth( 0u ); // Do not layout space for the cursor.
 }
old mode 100644 (file)
new mode 100755 (executable)
index 57dc613..9f9bddc
@@ -88,7 +88,9 @@ void SetBidirectionalInfo( const Vector<Character>& text,
                            const Vector<LineBreakInfo>& lineBreakInfo,
                            CharacterIndex startIndex,
                            Length numberOfCharacters,
-                           Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo )
+                           Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
+                           bool matchSystemLanguageDirection,
+                           Dali::LayoutDirection::Type layoutDirection )
 {
   // Find where to insert the new paragraphs.
   BidirectionalRunIndex bidiInfoIndex = 0u;
@@ -165,7 +167,9 @@ void SetBidirectionalInfo( const Vector<Character>& text,
 
         // Create the bidirectional info for the whole paragraph and store the index to the table with this info in the run.
         bidirectionalRun.bidirectionalInfoIndex = bidirectionalSupport.CreateInfo( textBuffer + bidirectionalRun.characterRun.characterIndex,
-                                                                                   bidirectionalRun.characterRun.numberOfCharacters );
+                                                                                   bidirectionalRun.characterRun.numberOfCharacters,
+                                                                                   matchSystemLanguageDirection,
+                                                                                   layoutDirection );
 
         bidirectionalInfo.Insert( bidirectionalInfo.Begin() + bidiInfoIndex, bidirectionalRun );
         ++bidiInfoIndex;
old mode 100644 (file)
new mode 100755 (executable)
index 39ec9d6..c29f401
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/actors/actor-enumerations.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/bidirectional-line-info-run.h>
@@ -45,13 +46,17 @@ namespace Text
  * @param[in] startIndex The character from where the bidirectional info is set.
  * @param[in] numberOfCharacters The number of characters.
  * @param[out] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
+ * @param[in] matchSystemLanguageDirection Whether match for system language direction or not.
+ * @param[in] layoutDirection The direction of the system language.
  */
 void SetBidirectionalInfo( const Vector<Character>& text,
                            const Vector<ScriptRun>& scripts,
                            const Vector<LineBreakInfo>& lineBreakInfo,
                            CharacterIndex startIndex,
                            Length numberOfCharacters,
-                           Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo );
+                           Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
+                           bool matchSystemLanguageDirection = false,
+                           Dali::LayoutDirection::Type layoutDirection = LayoutDirection::LEFT_TO_RIGHT );
 
 /**
  * Sets the visual to logical map tables.
index caefc0c..97a3da9 100755 (executable)
@@ -963,7 +963,9 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
                           lineBreakInfo,
                           startIndex,
                           requestedNumberOfCharacters,
-                          bidirectionalInfo );
+                          bidirectionalInfo,
+                          mModel->mMatchSystemLanguageDirection,
+                          mLayoutDirection );
 
     if( 0u != bidirectionalInfo.Count() )
     {
index f0b496f..5d0543c 100755 (executable)
@@ -427,6 +427,11 @@ void Controller::SetMatchSystemLanguageDirection( bool match )
   mImpl->mModel->mMatchSystemLanguageDirection = match;
 }
 
+void Controller::SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection )
+{
+  mImpl->mLayoutDirection = layoutDirection;
+}
+
 
 void Controller::SetLineWrapMode( Text::LineWrap::Mode lineWrapMode )
 {
index f92a69d..33f1f8f 100755 (executable)
@@ -1255,6 +1255,13 @@ public: // Queries & retrieves.
    */
   void SetMatchSystemLanguageDirection( bool match );
 
+  /**
+   * @brief Sets layoutDirection value
+   * @param[in] layoutDirection The value of system language direction
+   */
+  void SetLayoutDirection( Dali::LayoutDirection::Type layoutDirection );
+
+
 public: // Relayout.
 
   /**
diff --git a/docs/content/images/text-controls/HelloWorld-Default-BEGIN.png b/docs/content/images/text-controls/HelloWorld-Default-BEGIN.png
new file mode 100755 (executable)
index 0000000..ca9d860
Binary files /dev/null and b/docs/content/images/text-controls/HelloWorld-Default-BEGIN.png differ
diff --git a/docs/content/images/text-controls/HelloWorld-Default-CENTER.png b/docs/content/images/text-controls/HelloWorld-Default-CENTER.png
new file mode 100755 (executable)
index 0000000..cb28206
Binary files /dev/null and b/docs/content/images/text-controls/HelloWorld-Default-CENTER.png differ
index 3302d08..204ba94 100755 (executable)
Binary files a/docs/content/images/text-controls/HelloWorld-Default-END.png and b/docs/content/images/text-controls/HelloWorld-Default-END.png differ
diff --git a/docs/content/images/text-controls/HelloWorld-System-BEGIN.png b/docs/content/images/text-controls/HelloWorld-System-BEGIN.png
new file mode 100755 (executable)
index 0000000..11c8eda
Binary files /dev/null and b/docs/content/images/text-controls/HelloWorld-System-BEGIN.png differ
diff --git a/docs/content/images/text-controls/HelloWorld-System-CENTER.png b/docs/content/images/text-controls/HelloWorld-System-CENTER.png
new file mode 100755 (executable)
index 0000000..cb28206
Binary files /dev/null and b/docs/content/images/text-controls/HelloWorld-System-CENTER.png differ
index 2794090..d8c674b 100755 (executable)
Binary files a/docs/content/images/text-controls/HelloWorld-System-END.png and b/docs/content/images/text-controls/HelloWorld-System-END.png differ
diff --git a/docs/content/images/text-controls/LTR_RTL.png b/docs/content/images/text-controls/LTR_RTL.png
new file mode 100755 (executable)
index 0000000..d9defc3
Binary files /dev/null and b/docs/content/images/text-controls/LTR_RTL.png differ
diff --git a/docs/content/images/text-controls/LTR_order.png b/docs/content/images/text-controls/LTR_order.png
new file mode 100755 (executable)
index 0000000..6e8a3c1
Binary files /dev/null and b/docs/content/images/text-controls/LTR_order.png differ
diff --git a/docs/content/images/text-controls/RTL_order.png b/docs/content/images/text-controls/RTL_order.png
new file mode 100755 (executable)
index 0000000..b97e0f8
Binary files /dev/null and b/docs/content/images/text-controls/RTL_order.png differ
index 9b463e4..8b9d4d6 100755 (executable)
@@ -90,14 +90,14 @@ label.HorizontalAlignment = "BEGIN"; // "CENTER" or "END"
 
 
 
-The text's alignment can be modified to match the direction of the system language.
+The text's alignment and order can be modified to match the direction of the system language.
 
-If the MATCH_SYSTEM_LANGUAGE_DIRECTION property is set to true then the direction of the text is ignored, instead the text is aligned as the system default language.
+If the MATCH_SYSTEM_LANGUAGE_DIRECTION property is set to true then the direction of the text is ignored, instead the text is aligned and ordered as the system default language.
 
 ~~~{.cpp}
 // C++
 
-label.SetProperty( TextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
+label.SetProperty( Toolkit::DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
 ~~~
 
 ~~~{.js}
@@ -109,8 +109,19 @@ label.matchSystemLanguageDirection = true;
 |  |  |
 |--|--|
 | Current system language direction left-to-right | |
-| END alignment and MATCH_SYSTEM_LANGUAGE_DIRECTION set to TRUE. | END alignment and MATCH_SYSTEM_LANGUAGE_DIRECTION set to FALSE (default). |
-| ![ ](HelloWorld-System-END.png) | ![ ](HelloWorld-Default-END.png) |
+| MATCH_SYSTEM_LANGUAGE_DIRECTION set to TRUE. | MATCH_SYSTEM_LANGUAGE_DIRECTION set to FALSE (default). |
+| BEGIN alignment | BEGIN alignment  |
+| ![ ](../assets/img/text-controls/HelloWorld-System-BEGIN.png) ![ ](HelloWorld-System-BEGIN.png) | ![ ](../assets/img/text-controls/HelloWorld-Default-BEGIN.png) ![ ](HelloWorld-Default-BEGIN.png) |
+| CENTER alignment | CENTER alignment  |
+| ![ ](../assets/img/text-controls/HelloWorld-System-CENTER.png) ![ ](HelloWorld-System-CENTER.png) | ![ ](../assets/img/text-controls/HelloWorld-Default-CENTER.png) ![ ](HelloWorld-Default-CENTER.png) |
+| END alignment | END alignment  |
+| ![ ](../assets/img/text-controls/HelloWorld-System-END.png) ![ ](HelloWorld-System-END.png) | ![ ](../assets/img/text-controls/HelloWorld-Default-END.png) ![ ](HelloWorld-Default-END.png) |
+
+
+|  |  |
+|--|--|
+| Current system language direction left-to-right | Current system language direction right-to-left |
+| ![ ](../assets/img/text-controls/LTR_order.png) ![ ](LTR_order.png)  | ![ ](../assets/img/text-controls/RTL_order.png) ![ ](RTL_order.png) |
 
 
 The examples above assume that the TextLabel size greater than the minimum required.