Merge "Fix alignment issues with field and editor." into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / dali-toolkit-test-utils / toolkit-text-utils.cpp
index 6028e02..701977d 100755 (executable)
@@ -102,7 +102,9 @@ void CreateTextModel( const std::string& text,
                       ModelPtr& textModel,
                       MetricsPtr& metrics,
                       bool markupProcessorEnabled,
-                      LineWrap::Mode wrapMode )
+                      LineWrap::Mode wrapMode,
+                      bool ellipsisEnabled,
+                      DevelText::EllipsisPosition::Type ellipsisPosition)
 {
   textModel = Model::New(); ///< Pointer to the text's model.
   LogicalModelPtr logicalModel = textModel->mLogicalModel;
@@ -133,6 +135,12 @@ void CreateTextModel( const std::string& text,
     utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
   }
 
+  //Ellipsis
+  textModel-> mElideEnabled = ellipsisEnabled;
+  textModel-> mVisualModel->SetTextElideEnabled(ellipsisEnabled);
+  textModel-> mEllipsisPosition = ellipsisPosition;
+  textModel-> mVisualModel->SetEllipsisPosition(ellipsisPosition);
+
   // 1) Convert to utf32
   Vector<Character>& utf32Characters = logicalModel->mText;
   utf32Characters.Resize( textSize );
@@ -323,7 +331,6 @@ void CreateTextModel( const std::string& text,
   // Set the layout parameters.
   textModel->mHorizontalAlignment = Text::HorizontalAlignment::BEGIN;
   textModel->mIgnoreSpacesAfterText = true;
-  textModel->mMatchSystemLanguageDirection = false;
   Layout::Parameters layoutParameters( textArea,
                                        textModel );
 
@@ -344,7 +351,8 @@ void CreateTextModel( const std::string& text,
   layoutEngine.LayoutText( layoutParameters,
                            layoutSize,
                            false,
-                           isAutoScroll );
+                           isAutoScroll,
+                           ellipsisPosition);
 
   if( options.align )
   {
@@ -385,7 +393,7 @@ void ConfigureTextLabel( ControllerPtr controller )
   controller->SetTextElideEnabled( true );
 
   // Disable match system language direction
-  controller->SetMatchSystemLanguageDirection(false);
+  controller->SetMatchLayoutDirection(DevelText::MatchLayoutDirection::CONTENTS);
 }
 
 void ConfigureTextField( ControllerPtr controller )
@@ -417,7 +425,7 @@ void ConfigureTextField( ControllerPtr controller )
   controller->SetTextElideEnabled( false );
 
   // Disable match system language direction
-  controller->SetMatchSystemLanguageDirection(false);
+  controller->SetMatchLayoutDirection(DevelText::MatchLayoutDirection::CONTENTS);
 }
 
 void ConfigureTextEditor( ControllerPtr controller )
@@ -449,7 +457,48 @@ void ConfigureTextEditor( ControllerPtr controller )
   controller->SetTextElideEnabled( false );
 
   // Disable match system language direction
-  controller->SetMatchSystemLanguageDirection(false);
+  controller->SetMatchLayoutDirection(DevelText::MatchLayoutDirection::CONTENTS);
+}
+
+
+Vector<FontDescriptionRun> CreateSingleFontDescription(
+                    const CharacterRun&         characterRun,
+                    const std::string           fontFamilyName,
+                    const FontWeight            weight,
+                    const FontWidth             width,
+                    const FontSlant             slant,
+                    const PointSize26Dot6       size,
+                    const bool                  familyDefined,
+                    const bool                  weightDefined,
+                    const bool                  widthDefined,
+                    const bool                  slantDefined,
+                    const bool                  sizeDefined)
+{
+
+  FontDescriptionRun fontDescriptionRun =
+  {
+    characterRun,
+    nullptr,
+    0u,
+    weight,
+    width,
+    slant,
+    size,
+    familyDefined,
+    weightDefined,
+    widthDefined,
+    slantDefined,
+    sizeDefined
+  };
+
+  fontDescriptionRun.familyLength = fontFamilyName.size();
+  fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
+  memcpy( fontDescriptionRun.familyName, fontFamilyName.c_str(), fontDescriptionRun.familyLength );
+
+  Vector<FontDescriptionRun> fontDescriptionRuns;
+  fontDescriptionRuns.PushBack(fontDescriptionRun);
+
+  return fontDescriptionRuns;
 }
 
 } // namespace Text