Merge changes Ia2ec4b45,Ied29583a into devel/master
authorPaul Wisbey <p.wisbey@samsung.com>
Tue, 22 Nov 2016 16:04:04 +0000 (08:04 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 22 Nov 2016 16:04:04 +0000 (08:04 -0800)
* changes:
  Text - First Page Renderer implementation.
  ModelView implementation.

52 files changed:
automated-tests/src/dali-toolkit-internal/CMakeLists.txt
automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp [moved from automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-model.cpp with 76% similarity]
automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.h [moved from automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-model.h with 73% similarity]
automated-tests/src/dali-toolkit-internal/utc-Dali-BidirectionalSupport.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-LogicalModel.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Cursor.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Markup.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-abstraction.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
build/tizen/dali-toolkit/Makefile.am
dali-toolkit/dali-toolkit.h
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/visuals/text-visual-properties.h [new file with mode: 0644]
dali-toolkit/devel-api/visuals/visual-properties-devel.h [new file with mode: 0644]
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/file.list
dali-toolkit/internal/text/layouts/layout-alignment.h [moved from dali-toolkit/internal/text/text-scroller-interface.cpp with 52% similarity]
dali-toolkit/internal/text/layouts/layout-engine.cpp
dali-toolkit/internal/text/layouts/layout-engine.h
dali-toolkit/internal/text/layouts/layout-parameters.h
dali-toolkit/internal/text/multi-language-support-impl.cpp
dali-toolkit/internal/text/rendering/text-typesetter.cpp [new file with mode: 0644]
dali-toolkit/internal/text/rendering/text-typesetter.h [new file with mode: 0644]
dali-toolkit/internal/text/rendering/view-model.cpp [new file with mode: 0644]
dali-toolkit/internal/text/rendering/view-model.h [new file with mode: 0644]
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/internal/text/text-model-interface.h [new file with mode: 0644]
dali-toolkit/internal/text/text-model.cpp [new file with mode: 0644]
dali-toolkit/internal/text/text-model.h [new file with mode: 0644]
dali-toolkit/internal/text/text-scroller-interface.h
dali-toolkit/internal/text/visual-model-impl.cpp
dali-toolkit/internal/text/visual-model-impl.h
dali-toolkit/internal/visuals/text/text-visual.cpp
dali-toolkit/internal/visuals/text/text-visual.h
dali-toolkit/internal/visuals/visual-factory-impl.cpp
dali-toolkit/public-api/file.list
dali-toolkit/public-api/visuals/text-visual-properties.h [deleted file]
dali-toolkit/public-api/visuals/visual-properties.h

index 4a9a003..99ee1db 100644 (file)
@@ -21,6 +21,8 @@ SET(TC_SOURCES
  utc-Dali-VisualFactoryResolveUrl.cpp
  utc-Dali-Visuals.cpp
  utc-Dali-Text-Markup.cpp
+ utc-Dali-Text-Typesetter.cpp
+ utc-Dali-Text-ViewModel.cpp
 )
 
 # Append list of test harness files (Won't get parsed for test cases)
@@ -53,7 +55,7 @@ LIST(APPEND TC_SOURCES
    ../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp
    ../dali-toolkit/dali-toolkit-test-utils/test-native-image.cpp
-   dali-toolkit-test-utils/toolkit-text-model.cpp
+   dali-toolkit-test-utils/toolkit-text-utils.cpp
 )
 
 
  *
  */
 
-#include "toolkit-text-model.h"
+// FILE HEADER
+#include "toolkit-text-utils.h"
 
 // EXTERNAL INCLUDES
+#include <limits>
 #include <dali/devel-api/text-abstraction/font-client.h>
 
 // INTERNAL INCLUDES
@@ -260,25 +262,26 @@ void CreateTextModel( const std::string& text,
   }
 
   // 9) Layout the text
-  LayoutEngine layoutEngine;
+  Layout::Engine layoutEngine;
   layoutEngine.SetMetrics( metrics );
-  layoutEngine.SetLayout( LayoutEngine::MULTI_LINE_BOX );
+  layoutEngine.SetLayout( Layout::Engine::MULTI_LINE_BOX );
 
   // Set the layout parameters.
   const Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
   const Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
 
-  LayoutParameters layoutParameters( textArea,
-                                     utf32Characters.Begin(),
-                                     lineBreakInfo.Begin(),
-                                     wordBreakInfo.Begin(),
-                                     ( 0u != characterDirections.Count() ) ? characterDirections.Begin() : NULL,
-                                     glyphs.Begin(),
-                                     glyphsToCharactersMap.Begin(),
-                                     charactersPerGlyph.Begin(),
-                                     charactersToGlyph.Begin(),
-                                     glyphsPerCharacter.Begin(),
-                                     numberOfGlyphs );
+  Layout::Parameters layoutParameters( textArea,
+                                       utf32Characters.Begin(),
+                                       lineBreakInfo.Begin(),
+                                       wordBreakInfo.Begin(),
+                                       ( 0u != characterDirections.Count() ) ? characterDirections.Begin() : NULL,
+                                       glyphs.Begin(),
+                                       glyphsToCharactersMap.Begin(),
+                                       charactersPerGlyph.Begin(),
+                                       charactersToGlyph.Begin(),
+                                       glyphsPerCharacter.Begin(),
+                                       numberOfGlyphs,
+                                       Layout::HORIZONTAL_ALIGN_BEGIN );
 
   Vector<LineRun>& lines = visualModel->mLines;
 
@@ -296,7 +299,8 @@ void CreateTextModel( const std::string& text,
   layoutEngine.LayoutText( layoutParameters,
                            glyphPositions,
                            lines,
-                           layoutSize );
+                           layoutSize,
+                           false );
 
   // 10) Reorder the lines
   if( 0u != bidirectionalInfo.Count() )
@@ -333,10 +337,91 @@ void CreateTextModel( const std::string& text,
     layoutEngine.Align( textArea,
                         0u,
                         numberOfCharacters,
+                        Layout::HORIZONTAL_ALIGN_BEGIN,
                         lines );
   }
 }
 
+void ConfigureTextLabel( ControllerPtr controller )
+{
+  TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+  fontClient.SetDpi( 93u, 93u );
+
+  // Set the text layout as multi-line.
+  controller->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX );
+
+  // Set cursor's width to zero.
+  controller->GetLayoutEngine().SetCursorWidth( 0 );
+
+  // Disables the text input.
+  controller->EnableTextInput( NULL );
+
+  // Disables the vertical scrolling.
+  controller->SetVerticalScrollEnabled( false );
+
+  // Disables the horizontal scrolling.
+  controller->SetHorizontalScrollEnabled( false );
+
+  // Enable the text elide.
+  controller->SetTextElideEnabled( true );
+}
+
+void ConfigureTextField( ControllerPtr controller )
+{
+  TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+  fontClient.SetDpi( 93u, 93u );
+
+  // Creates a decorator.
+  Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+                                                       *controller );
+
+  // Set the text layout as multi-line.
+  controller->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX );
+
+  // Enables the text input.
+  controller->EnableTextInput( decorator );
+
+  // Enables the vertical scrolling after the text input has been enabled.
+  controller->SetVerticalScrollEnabled( false );
+
+  // Disables the horizontal scrolling.
+  controller->SetHorizontalScrollEnabled( true );
+
+  // No maximum number of characters.
+  controller->SetMaximumNumberOfCharacters( 50u );
+
+  // Disable the text elide.
+  controller->SetTextElideEnabled( false );
+}
+
+void ConfigureTextEditor( ControllerPtr controller )
+{
+  TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+  fontClient.SetDpi( 93u, 93u );
+
+  // Creates a decorator.
+  Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+                                                       *controller );
+
+  // Set the text layout as multi-line.
+  controller->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX );
+
+  // Enables the text input.
+  controller->EnableTextInput( decorator );
+
+  // Enables the vertical scrolling after the text input has been enabled.
+  controller->SetVerticalScrollEnabled( true );
+
+  // Disables the horizontal scrolling.
+  controller->SetHorizontalScrollEnabled( false );
+
+  // No maximum number of characters.
+  controller->SetMaximumNumberOfCharacters( std::numeric_limits<Length>::max() );
+
+  // Disable the text elide.
+  controller->SetTextElideEnabled( false );
+}
+
 } // namespace Text
 
 } // namespace Toolkit
@@ -1,5 +1,5 @@
-#ifndef __DALI_TOOLKIT_TEXT_MODEL_H__
-#define __DALI_TOOLKIT_TEXT_MODEL_H__
+#ifndef __DALI_TOOLKIT_TEXT_UTILS_H__
+#define __DALI_TOOLKIT_TEXT_UTILS_H__
 
 /*
  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  */
 
-// EXTERNAL INCLUDES
-
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/logical-model-impl.h>
 #include <dali-toolkit/internal/text/metrics.h>
 #include <dali-toolkit/internal/text/visual-model-impl.h>
+#include <dali-toolkit/internal/text/text-controller.h>
 
 namespace Dali
 {
@@ -70,10 +69,31 @@ void CreateTextModel( const std::string& text,
                       VisualModelPtr& visualModel,
                       MetricsPtr& metrics );
 
+/**
+ * @brief Configures the text @p controller similarly to the one configured by the text-label.
+ *
+ * @param[in,out] The text controller to configure.
+ */
+void ConfigureTextLabel( ControllerPtr controller );
+
+/**
+ * @brief Configures the text @p controller similarly to the one configured by the text-field.
+ *
+ * @param[in,out] The text controller to configure.
+ */
+void ConfigureTextField( ControllerPtr controller );
+
+/**
+ * @brief Configures the text @p controller similarly to the one configured by the text-editor.
+ *
+ * @param[in,out] The text controller to configure.
+ */
+void ConfigureTextEditor( ControllerPtr controller );
+
 } // namespace Text
 
 } // namespace Toolkit
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_TEXT_MODEL_H__
+#endif // __DALI_TOOLKIT_TEXT_UTILS_H__
index 629e4f3..37b5277 100644 (file)
@@ -24,7 +24,7 @@
 #include <dali-toolkit/internal/text/text-run-container.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
 
 using namespace Dali;
 using namespace Toolkit;
index 25a724c..f8df615 100644 (file)
@@ -22,7 +22,7 @@
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/internal/text/text-run-container.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
 
 
 using namespace Dali;
index cdb29f9..b92f090 100644 (file)
 
 #include <stdlib.h>
 #include <limits>
-#include <unistd.h>
 
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
+#include <toolkit-text-utils.h>
 #include <dali-toolkit/internal/text/text-controller.h>
 #include <dali-toolkit/internal/text/text-control-interface.h>
 #include <dali-toolkit/internal/text/text-editable-control-interface.h>
@@ -43,34 +43,6 @@ const char* const OPTION_CLIPBOARD("optionClipboard");      // "Clipboard" popup
 
 const Size CONTROL_SIZE( 300.f, 60.f );
 
-const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
-
-class ControlImpl : public ControlInterface, public Text::EditableControlInterface
-{
-public:
-  ControlImpl()
-  : ControlInterface()
-  {}
-
-  virtual ~ControlImpl()
-  {}
-
-  virtual void AddDecoration( Actor& actor, bool needsClipping )
-  {}
-
-  virtual void RequestTextRelayout()
-  {}
-
-  virtual void TextChanged()
-  {}
-
-  virtual void MaxLengthReached()
-  {}
-
-  virtual void InputStyleChanged( InputStyle::Mask inputStyleMask )
-  {}
-};
-
 std::string gClipboardText;
 void ContentSelectedCallback( ClipboardEventNotifier& notifier )
 {
@@ -86,9 +58,73 @@ int UtcDaliTextController(void)
 
   // Creates a text controller.
   ControllerPtr controller = Controller::New();
+  DALI_TEST_CHECK( controller );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextControllerSetGetScrollEnabled(void)
+{
+  tet_infoline(" UtcDaliTextControllerSetGetScrollEnabled");
+  ToolkitTestApplication application;
 
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
   DALI_TEST_CHECK( controller );
 
+  // Configures the text controller similarly to the text-editor.
+  ConfigureTextEditor( controller );
+
+  DALI_TEST_CHECK( !controller->IsHorizontalScrollEnabled() );
+  DALI_TEST_CHECK( controller->IsVerticalScrollEnabled() );
+
+  // Configures the text controller similarly to the text-field.
+  ConfigureTextField( controller );
+
+  DALI_TEST_CHECK( controller->IsHorizontalScrollEnabled() );
+  DALI_TEST_CHECK( !controller->IsVerticalScrollEnabled() );
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+
+  DALI_TEST_CHECK( !controller->IsHorizontalScrollEnabled() );
+  DALI_TEST_CHECK( !controller->IsVerticalScrollEnabled() );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextControllerSetIsTextElide(void)
+{
+  tet_infoline(" UtcDaliTextControllerSetIsTextElide");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+  DALI_TEST_CHECK( controller );
+
+  // Configures the text controller similarly to the text-editor.
+  ConfigureTextEditor( controller );
+  DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION );
+
+  controller->SetTextElideEnabled( true );
+  DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION );
+
+  // Configures the text controller similarly to the text-field.
+  ConfigureTextField( controller );
+  DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION );
+
+  controller->SetTextElideEnabled( true );
+  DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION );
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+  DALI_TEST_EQUALS( true, controller->IsTextElideEnabled(), TEST_LOCATION );
+
+  controller->SetTextElideEnabled( false );
+  DALI_TEST_EQUALS( false, controller->IsTextElideEnabled(), TEST_LOCATION );
+
   tet_result(TET_PASS);
   END_TEST;
 }
@@ -100,7 +136,6 @@ int UtcDaliTextControllerEnableCursorBlinking(void)
 
   // Creates a text controller.
   ControllerPtr controller = Controller::New();
-
   DALI_TEST_CHECK( controller );
 
   // There is no text input enabled.
index 195c81b..1755b8b 100644 (file)
@@ -22,7 +22,7 @@
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/internal/text/cursor-helper-functions.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
 
 
 using namespace Dali;
index 4d42843..80c4631 100644 (file)
@@ -24,7 +24,7 @@
 #include <dali-toolkit/internal/text/text-run-container.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
 
 using namespace Dali;
 using namespace Toolkit;
@@ -51,7 +51,7 @@ struct LayoutTextData
   float*               positions;
   unsigned int         numberOfLines;
   LineRun*             lines;
-  LayoutEngine::Layout layout;
+  Layout::Engine::Type layout;
   unsigned int         startIndex;
   unsigned int         numberOfGlyphs;
   bool                 ellipsis:1;
@@ -152,24 +152,24 @@ bool LayoutTextTest( const LayoutTextData& data )
                         glyphPositions.Begin() + data.startIndex + data.numberOfGlyphs );
 
   // 3) Layout
-  LayoutEngine engine;
+  Layout::Engine engine;
   engine.SetMetrics( metrics );
-  engine.SetTextEllipsisEnabled( data.ellipsis );
   engine.SetLayout( data.layout );
 
   const Length totalNumberOfGlyphs = visualModel->mGlyphs.Count();
 
-  LayoutParameters layoutParameters( data.textArea,
-                                     logicalModel->mText.Begin(),
-                                     logicalModel->mLineBreakInfo.Begin(),
-                                     logicalModel->mWordBreakInfo.Begin(),
-                                     ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL,
-                                     visualModel->mGlyphs.Begin(),
-                                     visualModel->mGlyphsToCharacters.Begin(),
-                                     visualModel->mCharactersPerGlyph.Begin(),
-                                     visualModel->mCharactersToGlyph.Begin(),
-                                     visualModel->mGlyphsPerCharacter.Begin(),
-                                     totalNumberOfGlyphs );
+  Layout::Parameters layoutParameters( data.textArea,
+                                       logicalModel->mText.Begin(),
+                                       logicalModel->mLineBreakInfo.Begin(),
+                                       logicalModel->mWordBreakInfo.Begin(),
+                                       ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL,
+                                       visualModel->mGlyphs.Begin(),
+                                       visualModel->mGlyphsToCharacters.Begin(),
+                                       visualModel->mCharactersPerGlyph.Begin(),
+                                       visualModel->mCharactersToGlyph.Begin(),
+                                       visualModel->mGlyphsPerCharacter.Begin(),
+                                       totalNumberOfGlyphs,
+                                       Layout::HORIZONTAL_ALIGN_BEGIN );
 
   layoutParameters.isLastNewParagraph = isLastNewParagraph;
 
@@ -184,7 +184,8 @@ bool LayoutTextTest( const LayoutTextData& data )
   const bool updated = engine.LayoutText( layoutParameters,
                                           glyphPositions,
                                           lines,
-                                          layoutSize );
+                                          layoutSize,
+                                          data.ellipsis );
 
   // 4) Compare the results.
 
@@ -369,20 +370,21 @@ bool ReLayoutRightToLeftLinesTest( const ReLayoutRightToLeftLinesData& data )
                    metrics );
 
   // 2) Call the ReLayoutRightToLeftLines() method.
-  LayoutEngine engine;
+  Layout::Engine engine;
   engine.SetMetrics( metrics );
 
-  LayoutParameters layoutParameters( data.textArea,
-                                     logicalModel->mText.Begin(),
-                                     logicalModel->mLineBreakInfo.Begin(),
-                                     logicalModel->mWordBreakInfo.Begin(),
-                                     ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL,
-                                     visualModel->mGlyphs.Begin(),
-                                     visualModel->mGlyphsToCharacters.Begin(),
-                                     visualModel->mCharactersPerGlyph.Begin(),
-                                     visualModel->mCharactersToGlyph.Begin(),
-                                     visualModel->mGlyphsPerCharacter.Begin(),
-                                     visualModel->mGlyphs.Count() );
+  Layout::Parameters layoutParameters( data.textArea,
+                                       logicalModel->mText.Begin(),
+                                       logicalModel->mLineBreakInfo.Begin(),
+                                       logicalModel->mWordBreakInfo.Begin(),
+                                       ( 0u != logicalModel->mCharacterDirections.Count() ) ? logicalModel->mCharacterDirections.Begin() : NULL,
+                                       visualModel->mGlyphs.Begin(),
+                                       visualModel->mGlyphsToCharacters.Begin(),
+                                       visualModel->mCharactersPerGlyph.Begin(),
+                                       visualModel->mCharactersToGlyph.Begin(),
+                                       visualModel->mGlyphsPerCharacter.Begin(),
+                                       visualModel->mGlyphs.Count(),
+                                       Layout::HORIZONTAL_ALIGN_BEGIN  );
 
   layoutParameters.numberOfBidirectionalInfoRuns = logicalModel->mBidirectionalLineInfo.Count();
   layoutParameters.lineBidirectionalInfoRunsBuffer = logicalModel->mBidirectionalLineInfo.Begin();
@@ -424,17 +426,17 @@ bool ReLayoutRightToLeftLinesTest( const ReLayoutRightToLeftLinesData& data )
 
 struct AlignData
 {
-  std::string                       description;
-  std::string                       text;
-  Size                              textArea;
-  unsigned int                      numberOfFonts;
-  FontDescriptionRun*               fontDescriptions;
-  LayoutEngine::HorizontalAlignment horizontalAlignment;
-  LayoutEngine::VerticalAlignment   verticalAlignment;
-  unsigned int                      startIndex;
-  unsigned int                      numberOfCharacters;
-  unsigned int                      numberOfLines;
-  float*                            lineOffsets;
+  std::string                 description;
+  std::string                 text;
+  Size                        textArea;
+  unsigned int                numberOfFonts;
+  FontDescriptionRun*         fontDescriptions;
+  Layout::HorizontalAlignment horizontalAlignment;
+  Layout::VerticalAlignment   verticalAlignment;
+  unsigned int                startIndex;
+  unsigned int                numberOfCharacters;
+  unsigned int                numberOfLines;
+  float*                      lineOffsets;
 };
 
 bool AlignTest( const AlignData& data )
@@ -477,15 +479,13 @@ bool AlignTest( const AlignData& data )
                    metrics );
 
   // Call the Align method.
-  LayoutEngine engine;
+  Layout::Engine engine;
   engine.SetMetrics( metrics );
 
-  engine.SetHorizontalAlignment( data.horizontalAlignment );
-  engine.SetVerticalAlignment( data.verticalAlignment );
-
   engine.Align( data.textArea,
                 data.startIndex,
                 data.numberOfCharacters,
+                data.horizontalAlignment,
                 visualModel->mLines );
 
   // Compare results.
@@ -556,61 +556,12 @@ int UtcDaliTextLayoutSetGetLayout(void)
   ToolkitTestApplication application;
   tet_infoline(" UtcDaliTextLayoutSetGetLayout");
 
-  LayoutEngine engine;
-
-  DALI_TEST_CHECK( LayoutEngine::SINGLE_LINE_BOX == engine.GetLayout() );
-
-  engine.SetLayout( LayoutEngine::MULTI_LINE_BOX );
-  DALI_TEST_CHECK( LayoutEngine::MULTI_LINE_BOX == engine.GetLayout() );
-
-  tet_result(TET_PASS);
-  END_TEST;
-}
-
-int UtcDaliTextLayoutSetGetTextEllipsisEnabled(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliTextLayoutSetGetTextEllipsisEnabled");
-
-  LayoutEngine engine;
-
-  DALI_TEST_CHECK( !engine.GetTextEllipsisEnabled() );
-
-  engine.SetTextEllipsisEnabled( true );
-  DALI_TEST_CHECK( engine.GetTextEllipsisEnabled() );
-
-  tet_result(TET_PASS);
-  END_TEST;
-}
-
-int UtcDaliTextLayoutSetGetHorizontalAlignment(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" ");
-
-  LayoutEngine engine;
+  Layout::Engine engine;
 
-  DALI_TEST_CHECK( LayoutEngine::HORIZONTAL_ALIGN_BEGIN == engine.GetHorizontalAlignment() );
-
-  engine.SetHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_END );
-  DALI_TEST_CHECK( LayoutEngine::HORIZONTAL_ALIGN_END == engine.GetHorizontalAlignment() );
-
-  tet_result(TET_PASS);
-  END_TEST;
-}
-
-int UtcDaliTextLayoutSetGetVerticalAlignment(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliTextLayoutSetGetVerticalAlignment");
-
-  LayoutEngine engine;
-
-  DALI_TEST_CHECK( LayoutEngine::VERTICAL_ALIGN_TOP == engine.GetVerticalAlignment() );
-
-  engine.SetVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP );
-  DALI_TEST_CHECK( LayoutEngine::VERTICAL_ALIGN_TOP == engine.GetVerticalAlignment() );
+  DALI_TEST_CHECK( Layout::Engine::SINGLE_LINE_BOX == engine.GetLayout() );
 
+  engine.SetLayout( Layout::Engine::MULTI_LINE_BOX );
+  DALI_TEST_CHECK( Layout::Engine::MULTI_LINE_BOX == engine.GetLayout() );
 
   tet_result(TET_PASS);
   END_TEST;
@@ -621,7 +572,7 @@ int UtcDaliTextLayoutSetGetCursorWidth(void)
   ToolkitTestApplication application;
   tet_infoline(" ");
 
-  LayoutEngine engine;
+  Layout::Engine engine;
 
   DALI_TEST_EQUALS( 1, engine.GetCursorWidth(), TEST_LOCATION );
 
@@ -651,7 +602,7 @@ int UtcDaliTextLayoutNoText(void)
     NULL,
     0u,
     NULL,
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     0u,
     false,
@@ -705,7 +656,7 @@ int UtcDaliTextLayoutSmallTextArea01(void)
     NULL,
     0u,
     NULL,
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     11u,
     false,
@@ -775,7 +726,7 @@ int UtcDaliTextLayoutSmallTextArea02(void)
     positions,
     1u,
     lines.Begin(),
-    LayoutEngine::SINGLE_LINE_BOX,
+    Layout::Engine::SINGLE_LINE_BOX,
     0u,
     11u,
     false,
@@ -918,7 +869,7 @@ int UtcDaliTextLayoutMultilineText01(void)
     positions,
     5u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     48u,
     false,
@@ -1126,7 +1077,7 @@ int UtcDaliTextLayoutMultilineText02(void)
     positions,
     6u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     55u,
     false,
@@ -1227,7 +1178,7 @@ int UtcDaliTextLayoutMultilineText03(void)
     positions,
     3u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     29u,
     false,
@@ -1313,7 +1264,7 @@ int UtcDaliTextLayoutMultilineText04(void)
     positions,
     2u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     13u,
     false,
@@ -1427,7 +1378,7 @@ int UtcDaliTextLayoutMultilineText05(void)
     positions,
     2u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     17u,
     false,
@@ -1983,7 +1934,7 @@ int UtcDaliTextUpdateLayout01(void)
     positions,
     19u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     64u,
     false,
@@ -2539,7 +2490,7 @@ int UtcDaliTextUpdateLayout02(void)
     positions,
     19u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     64u,
     64u,
     false,
@@ -3095,7 +3046,7 @@ int UtcDaliTextUpdateLayout03(void)
     positions,
     19u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     128u,
     64u,
     false,
@@ -3171,7 +3122,7 @@ int UtcDaliTextLayoutEllipsis01(void)
     positions,
     1u,
     lines.Begin(),
-    LayoutEngine::SINGLE_LINE_BOX,
+    Layout::Engine::SINGLE_LINE_BOX,
     0u,
     51u,
     true,
@@ -3261,7 +3212,7 @@ int UtcDaliTextLayoutEllipsis02(void)
     positions,
     2u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     51u,
     true,
@@ -3403,7 +3354,7 @@ int UtcDaliTextLayoutEllipsis03(void)
     positions,
     1u,
     lines.Begin(),
-    LayoutEngine::SINGLE_LINE_BOX,
+    Layout::Engine::SINGLE_LINE_BOX,
     0u,
     72u,
     true,
@@ -3559,7 +3510,7 @@ int UtcDaliTextLayoutEllipsis04(void)
     positions,
     2u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     72u,
     true,
@@ -3633,7 +3584,7 @@ int UtcDaliTextLayoutEllipsis05(void)
     positions,
     1u,
     lines.Begin(),
-    LayoutEngine::MULTI_LINE_BOX,
+    Layout::Engine::MULTI_LINE_BOX,
     0u,
     11u,
     true,
@@ -4186,8 +4137,8 @@ int UtcDaliTextAlign01(void)
     textArea,
     6u,
     fontDescriptionRuns.Begin(),
-    LayoutEngine::HORIZONTAL_ALIGN_BEGIN,
-    LayoutEngine::VERTICAL_ALIGN_TOP,
+    Layout::HORIZONTAL_ALIGN_BEGIN,
+    Layout::VERTICAL_ALIGN_TOP,
     0u,
     22u,
     6u,
@@ -4305,8 +4256,8 @@ int UtcDaliTextAlign02(void)
     textArea,
     6u,
     fontDescriptionRuns.Begin(),
-    LayoutEngine::HORIZONTAL_ALIGN_BEGIN,
-    LayoutEngine::VERTICAL_ALIGN_TOP,
+    Layout::HORIZONTAL_ALIGN_BEGIN,
+    Layout::VERTICAL_ALIGN_TOP,
     22u,
     26u,
     6u,
@@ -4424,8 +4375,8 @@ int UtcDaliTextAlign03(void)
     textArea,
     6u,
     fontDescriptionRuns.Begin(),
-    LayoutEngine::HORIZONTAL_ALIGN_BEGIN,
-    LayoutEngine::VERTICAL_ALIGN_TOP,
+    Layout::HORIZONTAL_ALIGN_BEGIN,
+    Layout::VERTICAL_ALIGN_TOP,
     48u,
     26u,
     6u,
@@ -4543,8 +4494,8 @@ int UtcDaliTextAlign04(void)
     textArea,
     6u,
     fontDescriptionRuns.Begin(),
-    LayoutEngine::HORIZONTAL_ALIGN_CENTER,
-    LayoutEngine::VERTICAL_ALIGN_TOP,
+    Layout::HORIZONTAL_ALIGN_CENTER,
+    Layout::VERTICAL_ALIGN_TOP,
     0u,
     22u,
     6u,
@@ -4662,8 +4613,8 @@ int UtcDaliTextAlign05(void)
     textArea,
     6u,
     fontDescriptionRuns.Begin(),
-    LayoutEngine::HORIZONTAL_ALIGN_CENTER,
-    LayoutEngine::VERTICAL_ALIGN_TOP,
+    Layout::HORIZONTAL_ALIGN_CENTER,
+    Layout::VERTICAL_ALIGN_TOP,
     22u,
     26u,
     6u,
@@ -4781,8 +4732,8 @@ int UtcDaliTextAlign06(void)
     textArea,
     6u,
     fontDescriptionRuns.Begin(),
-    LayoutEngine::HORIZONTAL_ALIGN_CENTER,
-    LayoutEngine::VERTICAL_ALIGN_TOP,
+    Layout::HORIZONTAL_ALIGN_CENTER,
+    Layout::VERTICAL_ALIGN_TOP,
     48u,
     26u,
     6u,
@@ -4900,8 +4851,8 @@ int UtcDaliTextAlign07(void)
     textArea,
     6u,
     fontDescriptionRuns.Begin(),
-    LayoutEngine::HORIZONTAL_ALIGN_END,
-    LayoutEngine::VERTICAL_ALIGN_TOP,
+    Layout::HORIZONTAL_ALIGN_END,
+    Layout::VERTICAL_ALIGN_TOP,
     0u,
     22u,
     6u,
@@ -5019,8 +4970,8 @@ int UtcDaliTextAlign08(void)
     textArea,
     6u,
     fontDescriptionRuns.Begin(),
-    LayoutEngine::HORIZONTAL_ALIGN_END,
-    LayoutEngine::VERTICAL_ALIGN_TOP,
+    Layout::HORIZONTAL_ALIGN_END,
+    Layout::VERTICAL_ALIGN_TOP,
     22u,
     26u,
     6u,
@@ -5138,8 +5089,8 @@ int UtcDaliTextAlign09(void)
     textArea,
     6u,
     fontDescriptionRuns.Begin(),
-    LayoutEngine::HORIZONTAL_ALIGN_END,
-    LayoutEngine::VERTICAL_ALIGN_TOP,
+    Layout::HORIZONTAL_ALIGN_END,
+    Layout::VERTICAL_ALIGN_TOP,
     48u,
     26u,
     6u,
@@ -5154,3 +5105,18 @@ int UtcDaliTextAlign09(void)
   tet_result(TET_PASS);
   END_TEST;
 }
+
+int UtcDaliTextLayoutSetGetDefaultLineSpacing(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliTextLayoutSetGetDefaultLineSpacing");
+
+  Layout::Engine engine;
+  DALI_TEST_EQUALS( 0.f, engine.GetDefaultLineSpacing(), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  engine.SetDefaultLineSpacing( 10.f );
+  DALI_TEST_EQUALS( 10.f, engine.GetDefaultLineSpacing(), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
index 23f7e51..87db667 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
 #include <dali-toolkit/internal/text/markup-processor.h>
 #include <dali-toolkit/internal/text/markup-processor-helper-functions.h>
 #include <dali-toolkit/internal/text/color-run.h>
index 7b319fb..e4464fd 100644 (file)
@@ -21,7 +21,7 @@
 #include <dali-toolkit/internal/text/shaper.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
 
 using namespace Dali;
 using namespace Toolkit;
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp
new file mode 100644 (file)
index 0000000..63f9a22
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <limits>
+#include <unistd.h>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <toolkit-text-utils.h>
+#include <dali-toolkit/internal/text/rendering/text-typesetter.h>
+#include <dali-toolkit/internal/text/rendering/view-model.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+namespace
+{
+const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
+const PointSize26Dot6 EMOJI_FONT_SIZE = 62u * 64u;
+} // namespace
+
+int UtcDaliTextTypesetter(void)
+{
+  tet_infoline(" UtcDaliTextTypesetter");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextTypesetterGetViewModel(void)
+{
+  tet_infoline(" UtcDaliTextTypesetter");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextRenderingControllerRender(void)
+{
+  tet_infoline(" UtcDaliTextRenderingControllerRender");
+  ToolkitTestApplication application;
+
+  // Load some fonts.
+  TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+
+  char* pathNamePtr = get_current_dir_name();
+  const std::string pathName( pathNamePtr );
+  free( pathNamePtr );
+
+  fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
+  fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+
+  // Sets the text.
+  controller->SetMarkupProcessorEnabled( true );
+  controller->SetText( "<font family='TizenSansRegular'>Hello world </font><font family='TizenColorEmoji'>\xF0\x9F\x98\x81</font>" );
+
+  // Creates the text's model and relais-out the text.
+  const Size relayoutSize( 120.f, 60.f );
+  controller->Relayout( relayoutSize );
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr renderingController = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( renderingController );
+
+  // Renders the text and creates the final bitmap.
+  PixelData bitmap = renderingController->Render( relayoutSize );
+  DALI_TEST_CHECK( bitmap );
+
+  DALI_TEST_EQUALS( 120u, bitmap.GetWidth(), TEST_LOCATION );
+  DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+  DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION );
+
+  // Changes vertical alignment.
+  controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_CENTER );
+  controller->Relayout( relayoutSize );
+
+  // Renders the text and creates the final bitmap.
+  bitmap = renderingController->Render( relayoutSize );
+  DALI_TEST_CHECK( bitmap );
+
+  DALI_TEST_EQUALS( 120u, bitmap.GetWidth(), TEST_LOCATION );
+  DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+  DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION );
+
+  controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_BOTTOM );
+  controller->Relayout( relayoutSize );
+
+  // Renders the text and creates the final bitmap.
+  bitmap = renderingController->Render( relayoutSize );
+  DALI_TEST_CHECK( bitmap );
+
+  DALI_TEST_EQUALS( 120u, bitmap.GetWidth(), TEST_LOCATION );
+  DALI_TEST_EQUALS( 60u, bitmap.GetHeight(), TEST_LOCATION );
+  DALI_TEST_EQUALS( Pixel::RGBA8888, bitmap.GetPixelFormat(), TEST_LOCATION );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp
new file mode 100644 (file)
index 0000000..422e6ac
--- /dev/null
@@ -0,0 +1,653 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <toolkit-text-utils.h>
+#include <dali-toolkit/internal/text/font-description-run.h>
+#include <dali-toolkit/internal/text/rendering/text-typesetter.h>
+#include <dali-toolkit/internal/text/rendering/view-model.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+namespace
+{
+
+const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
+
+const Size CONTROL_SIZE( 200.f, 400.f );
+const Size CONTROL_SMALL_SIZE( 50.f, 100.f );
+const char* LOREM_IPSUM = "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n"
+  "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n"
+  "Ne nec nulla regione albucius, mea doctus delenit ad!\n"
+  "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n"
+  "Quidam corpora at duo. An eos possim scripserit?\n\n"
+  "Aťqui dicant sěnťenťíae aň vel!\n"
+  "Vis viris médiocrem elaboraret ét, verear civibus moderatius ex duo!\n"
+  "Án veri laborě iňtěgré quó, mei aď poššit lobortis, mei prompťa čonsťitůťó eů.\n"
+  "Aliquip sanctůs delicáta quí ěá, et natum aliquam est?\n"
+  "Asšúm sapěret usu ůť.\n"
+  "Síť ut apeirián laboramúš percipitur, sůas hařum ín éos?\n";
+const Vector2 LOREM_SCROLL_POSITION( 0.f, -208.f );
+const Length LOREM_NUMBER_OF_LINES = 32u;
+const Length LOREM_NUMBER_OF_LINES_ELIDED = 21u;
+const Length LOREM_NUMBER_OF_GLYPHS = 632;
+const Length LOREM_NUMBER_OF_GLYPHS_ELIDED = 397u;
+
+// The expected layout size for UtcDaliTextViewModelGetLayoutSize
+const Size LAYOUT_SIZE( 190.f, 48.f );
+
+// The expected color indices for UtcDaliTextViewModelGetColors
+const ColorIndex COLOR_INDICES[] = { 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 2u, 2u, 2u, 2u, 2u, 1u, 1u, 1u, 1u, 1u, 3u, 1u, 1u, 1u, 0u, 0u, 0u, 0u };
+const Length NUMBER_OF_COLORS = 3u;
+const Vector4 COLORS[] = { Color::RED, Color::BLUE, Color::GREEN };
+
+struct ElideData
+{
+  std::string  description;
+  std::string  text;
+  Vector2      size;
+  unsigned int numberOfLines;
+  unsigned int numberOfGlyphs;
+  float*       positions;
+};
+
+bool ElideTest( const ElideData& data )
+{
+  std::cout << "  testing : " << data.description << std::endl;
+
+  // Load some fonts.
+  TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+  fontClient.SetDpi( 93u, 93u );
+
+  char* pathNamePtr = get_current_dir_name();
+  const std::string pathName( pathNamePtr );
+  free( pathNamePtr );
+
+  fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
+  fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
+  fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+
+  // Sets a text and relais-out.
+  controller->SetMarkupProcessorEnabled( true );
+
+  controller->SetText( data.text );
+  controller->Relayout( data.size );
+
+  // Elide the glyphs.
+  model->ElideGlyphs();
+
+  if( data.numberOfLines != model->GetNumberOfLines() )
+  {
+    std::cout << "  different number of lines : " << model->GetNumberOfLines() << ", expected : " << data.numberOfLines << std::endl;
+    return false;
+  }
+
+  if( data.numberOfGlyphs != model->GetNumberOfGlyphs() )
+  {
+    std::cout << "  different number of glyphs : " << model->GetNumberOfGlyphs() << ", expected : " << data.numberOfGlyphs << std::endl;
+    return false;
+  }
+
+  const Vector2* const layoutBuffer = model->GetLayout();
+  const Length numberOfLines = model->GetNumberOfLines();
+
+  if( numberOfLines != 0u )
+  {
+    const LineRun& lastLine = *( model->GetLines() + numberOfLines - 1u );
+    const Length numberOfLastLineGlyphs = data.numberOfGlyphs - lastLine.glyphRun.glyphIndex;
+
+    std::cout << "  last line alignment offset : " << lastLine.alignmentOffset << std::endl;
+
+    for( unsigned int index = 0u; index < numberOfLastLineGlyphs; ++index )
+    {
+      if( *( data.positions + index ) != ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + index ) ).x ) )
+      {
+        std::cout << "  different layout :";
+        for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i )
+        {
+          std::cout << " " << ( lastLine.alignmentOffset + ( *( layoutBuffer + lastLine.glyphRun.glyphIndex + i ) ).x );
+        }
+        std::cout << std::endl;
+        std::cout << "          expected :";
+        for( unsigned int i = 0; i < numberOfLastLineGlyphs; ++i )
+        {
+          std::cout << " " << *( data.positions + i );
+        }
+        std::cout << std::endl;
+        return false;
+      }
+    }
+  }
+
+  return true;
+}
+
+} // namespace
+
+int UtcDaliTextViewModel(void)
+{
+  tet_infoline(" UtcDaliTextViewModel");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextViewModelGetControlSize(void)
+{
+  tet_infoline(" UtcDaliTextViewModelGetControlSize");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  // Configures the text controller similarly to the text-editor.
+  ConfigureTextEditor( controller );
+
+  // The text has not been laid-out. The stored control's size should be zero.
+  DALI_TEST_EQUALS( Size::ZERO, model->GetControlSize(), TEST_LOCATION );
+
+  // Sets a text and relais-out.
+  controller->SetText( "Hello world" );
+  controller->Relayout( CONTROL_SIZE );
+
+  // The control's size should be stored now.
+  DALI_TEST_EQUALS( CONTROL_SIZE, model->GetControlSize(), TEST_LOCATION );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextViewModelGetLayoutSize(void)
+{
+  tet_infoline(" UtcDaliTextViewModelGetLayoutSize");
+  ToolkitTestApplication application;
+
+  // Load some fonts.
+  TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+  fontClient.SetDpi( 93u, 93u );
+
+  char* pathNamePtr = get_current_dir_name();
+  const std::string pathName( pathNamePtr );
+  free( pathNamePtr );
+
+  fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  // Configures the text controller similarly to the text-editor.
+  ConfigureTextEditor( controller );
+
+  // The text has not been laid-out. The stored control's size should be zero.
+  DALI_TEST_EQUALS( Size::ZERO, model->GetLayoutSize(), TEST_LOCATION );
+
+  // Sets a text and relais-out.
+  controller->SetMarkupProcessorEnabled( true );
+  controller->SetText( "<font family='TizenSansRegular' size='10'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>" );
+  controller->Relayout( CONTROL_SIZE );
+
+  // The control's size should be stored now.
+  DALI_TEST_EQUALS( LAYOUT_SIZE, model->GetLayoutSize(), TEST_LOCATION );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextViewModelGetScrollPosition(void)
+{
+  tet_infoline(" UtcDaliTextViewModelGetScrollPosition");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  // Configures the text controller similarly to the text-editor.
+  ConfigureTextEditor( controller );
+
+  // No text has been set. The scroll position should be zero.
+  DALI_TEST_EQUALS( Vector2::ZERO, model->GetScrollPosition(), TEST_LOCATION );
+
+  // Gains the keyboard focus, sets a big text and relais-out.
+  controller->KeyboardFocusGainEvent();
+  controller->SetText( LOREM_IPSUM );
+  controller->Relayout( CONTROL_SIZE );
+
+  // The text should be scrolled to the end.
+  DALI_TEST_EQUALS( LOREM_SCROLL_POSITION, model->GetScrollPosition(), TEST_LOCATION );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextViewModelGetAlignment(void)
+{
+  tet_infoline(" UtcDaliTextViewModelGetAlignment");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  DALI_TEST_EQUALS( Layout::HORIZONTAL_ALIGN_BEGIN, model->GetHorizontalAlignment(), TEST_LOCATION );
+  DALI_TEST_EQUALS( Layout::VERTICAL_ALIGN_TOP, model->GetVerticalAlignment(), TEST_LOCATION );
+
+  controller->SetHorizontalAlignment( Layout::HORIZONTAL_ALIGN_CENTER );
+  controller->SetVerticalAlignment( Layout::VERTICAL_ALIGN_CENTER );
+
+  DALI_TEST_EQUALS( Layout::HORIZONTAL_ALIGN_CENTER, model->GetHorizontalAlignment(), TEST_LOCATION );
+  DALI_TEST_EQUALS( Layout::VERTICAL_ALIGN_CENTER, model->GetVerticalAlignment(), TEST_LOCATION );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextViewModelIsTextElideEnabled(void)
+{
+  tet_infoline(" UtcDaliTextViewModelIsTextElideEnabled");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  // Configures the text controller similarly to the text-editor.
+  ConfigureTextEditor( controller );
+
+  // Elide text should be disabled.
+  DALI_TEST_CHECK( !model->IsTextElideEnabled() );
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+
+  // Elide text should be enabled.
+  DALI_TEST_CHECK( model->IsTextElideEnabled() );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextViewModelGetLines(void)
+{
+  tet_infoline(" UtcDaliTextViewModelGetLines");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  // Configures the text controller similarly to the text-editor.
+  ConfigureTextEditor( controller );
+
+  // The number of lines should be zero.
+  DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
+  DALI_TEST_CHECK( NULL == model->GetLines() );
+
+  // Sets a text and relais-out.
+  controller->SetText( LOREM_IPSUM );
+  controller->Relayout( CONTROL_SIZE );
+
+  DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION );
+  DALI_TEST_CHECK( NULL != model->GetLines() );
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+
+  // Relais-out for the text-label configuration.
+  controller->Relayout( Size( 100.f, 100.f) ); // Change the size to force a relayout.
+  controller->Relayout( CONTROL_SIZE );
+
+  DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION );
+  DALI_TEST_CHECK( NULL != model->GetLines() );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextViewModelGetGlyphsLayout(void)
+{
+  tet_infoline(" UtcDaliTextViewModelGetGlyphsLayout");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  // Configures the text controller similarly to the text-editor.
+  ConfigureTextEditor( controller );
+
+  // The number of glyphs should be zero.
+  DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+  DALI_TEST_CHECK( NULL == model->GetGlyphs() );
+  DALI_TEST_CHECK( NULL == model->GetLayout() );
+
+  // Sets a text and relais-out.
+  controller->SetText( LOREM_IPSUM );
+  controller->Relayout( CONTROL_SIZE );
+
+  DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION );
+  DALI_TEST_CHECK( NULL != model->GetGlyphs() );
+  DALI_TEST_CHECK( NULL != model->GetLayout() );
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+
+  // Relais-out for the text-label configuration.
+  controller->Relayout( Size( 100.f, 100.f) ); // Change the size to force a relayout.
+  controller->Relayout( CONTROL_SIZE );
+
+  // Elide the glyphs.
+  model->ElideGlyphs();
+
+  DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION );
+  DALI_TEST_CHECK( NULL != model->GetGlyphs() );
+  DALI_TEST_CHECK( NULL != model->GetLayout() );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextViewModelGetColors(void)
+{
+  tet_infoline(" UtcDaliTextViewModelGetColors");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+
+  // Sets a text and relais-out.
+  controller->SetMarkupProcessorEnabled( true );
+  controller->SetText( "Lorem <color value='red'>ips<color value='blue'>um do</color>lor s<color value='green'>i</color>t a</color>met." );
+  controller->Relayout( CONTROL_SIZE );
+
+  DALI_TEST_EQUALS( Color::BLACK, model->GetDefaultColor(), TEST_LOCATION );
+
+  const ColorIndex* const colorIndicesBuffer = model->GetColorIndices();
+
+  const Length numberOfGlyphs = model->GetNumberOfGlyphs();
+  for( ColorIndex index = 0u; index < numberOfGlyphs; ++index )
+  {
+    DALI_TEST_EQUALS( COLOR_INDICES[index], *( colorIndicesBuffer + index ), TEST_LOCATION );
+  }
+
+  const Vector4* const colors = model->GetColors();
+  for( unsigned int index = 0u; index < NUMBER_OF_COLORS; ++index )
+  {
+    DALI_TEST_EQUALS( COLORS[index], *( colors + index ), TEST_LOCATION );
+  }
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextViewModelElideText01(void)
+{
+  tet_infoline(" UtcDaliTextViewModelElideText01");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  // Tests the rendering controller has been created.
+  TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+  DALI_TEST_CHECK( typesetter );
+
+  // Tests the view model has been created.
+  ViewModel* model = typesetter->GetViewModel();
+  DALI_TEST_CHECK( NULL != model );
+
+  // Configures the text controller similarly to the text-editor.
+  ConfigureTextEditor( controller );
+
+  // The number of glyphs should be zero.
+  DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+  DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
+  DALI_TEST_CHECK( NULL == model->GetGlyphs() );
+  DALI_TEST_CHECK( NULL == model->GetLayout() );
+
+  // Sets a text and relais-out.
+  controller->SetText( LOREM_IPSUM );
+  controller->Relayout( CONTROL_SIZE );
+
+  // Keep the pointers to the glyphs and layout.
+  // As the text is not elided with this configuration, the pointers shoud be the same after calling the ElideGlyphs() method.
+  const GlyphInfo* const glyphsModel = model->GetGlyphs();
+  const Vector2* layoutsModel = model->GetLayout();
+
+  // Elide the glyphs. Text shouldn't be elided with this configuration.
+  model->ElideGlyphs();
+
+  DALI_TEST_CHECK( glyphsModel == model->GetGlyphs() );
+  DALI_TEST_CHECK( layoutsModel == model->GetLayout() );
+
+  DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS, model->GetNumberOfGlyphs(), TEST_LOCATION );
+  DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES, model->GetNumberOfLines(), TEST_LOCATION );
+
+  // Configures the text controller similarly to the text-label.
+  ConfigureTextLabel( controller );
+
+  // Clear the text and relais-out.
+  controller->SetText( "" );
+  controller->Relayout( CONTROL_SIZE );
+
+  DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+  DALI_TEST_EQUALS( 0u, model->GetNumberOfLines(), TEST_LOCATION );
+
+  // Elide the glyphs. Should not add the ellipsis glyph.
+  model->ElideGlyphs();
+
+  DALI_TEST_EQUALS( 0u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+
+  // Sets a text that doesn't need to be elided.
+  controller->SetText( "Hello\n" );
+  controller->Relayout( CONTROL_SIZE );
+
+  // Elide the glyphs.
+  model->ElideGlyphs();
+
+  DALI_TEST_EQUALS( 6u, model->GetNumberOfGlyphs(), TEST_LOCATION );
+  DALI_TEST_EQUALS( 2u, model->GetNumberOfLines(), TEST_LOCATION );
+
+  // Sets a text and relais-out.
+  controller->SetText( LOREM_IPSUM );
+  controller->Relayout( CONTROL_SIZE );
+
+  // Elide the glyphs.
+  model->ElideGlyphs();
+
+  DALI_TEST_EQUALS( LOREM_NUMBER_OF_GLYPHS_ELIDED, model->GetNumberOfGlyphs(), TEST_LOCATION );
+  DALI_TEST_EQUALS( LOREM_NUMBER_OF_LINES_ELIDED, model->GetNumberOfLines(), TEST_LOCATION );
+  const GlyphInfo* const glyphs = model->GetGlyphs();
+  const Vector2* layouts = model->GetLayout();
+  DALI_TEST_CHECK( NULL != glyphs );
+  DALI_TEST_CHECK( NULL != layouts );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
+int UtcDaliTextViewModelElideText02(void)
+{
+  tet_infoline(" UtcDaliTextViewModelElideText02");
+
+  Size textSize00( 100.f, 100.f );
+
+  Size textSize01( 80.f, 100.f );
+  float positions01[] = { 0.f, 10.f, 16.f, 26.f, 35.f, 38.f, 46.f, 56.f };
+
+  Size textSize02( 80.f, 100.f );
+  float positions02[] = { 72.f, 63.f, 54.f, 50.f, 43.f, 38.f, 30.f, 11.f };
+
+  Size textSize03( 80.f, 100.f );
+  float positions03[] = { 77.f, 76.f, 71.f, 62.f, 60.f, 52.f, 47.f, 42.f, 39.f, 35.f, 32.f, 13.f };
+
+  Size textSize04( 80.f, 10.f );
+  float positions04[] = { 2.f };
+
+  struct ElideData data[] =
+  {
+    {
+      "void text",
+      "",
+      textSize00,
+      0u,
+      0u,
+      NULL
+    },
+    {
+      "Latin script",
+      "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
+      textSize01,
+      5u,
+      42u,
+      positions01
+    },
+    {
+      "Hebrew script",
+      "<font family='TizenSansHebrew'>צעד על לשון המלצת לאחרונה, אם לכאן שנורו סרבול מדע, קרן דת שפות להפוך.</font>",
+      textSize02,
+      5u,
+      49u,
+      positions02
+    },
+    {
+      "Arabic script",
+      "<font family='TizenSansArabic'>عل النفط ديسمبر الإمداد بال, بين وترك شعار هو. لمّ من المبرمة النفط بالسيطرة, أم يتم تحرّك وبغطاء, عدم في لإعادة وإقامة رجوعهم.</font>",
+      textSize03,
+      5u,
+      79u,
+      positions03
+    },
+    {
+      "Small control size, no line fits.",
+      "<font family='TizenSans'>Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.</font>",
+      textSize04,
+      1u,
+      1u,
+      positions04
+    }
+  };
+  const unsigned int numberOfTests = 5u;
+
+  for( unsigned int index = 0u; index < numberOfTests; ++index )
+  {
+    ToolkitTestApplication application;
+    if( !ElideTest( data[index] ) )
+    {
+      tet_result(TET_FAIL);
+    }
+  }
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
index 11b09f1..a13b4d8 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <toolkit-text-model.h>
+#include <toolkit-text-utils.h>
 
 
 using namespace Dali;
index a4bfbcb..b8ccf57 100644 (file)
 
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 #include <dali-toolkit/internal/visuals/wireframe/wireframe-visual.h>
+#include <dali-toolkit/dali-toolkit.h>
 
 using namespace Dali::Toolkit::Internal;
 
@@ -70,3 +73,51 @@ int UtcDaliWireframeVisual(void)
   tet_result(TET_PASS);
   END_TEST;
 }
+
+int UtcDaliTextVisual(void)
+{
+  tet_infoline(" UtcDaliTextVisual");
+  ToolkitTestApplication application;
+
+  Stage stage = Stage::GetCurrent();
+
+  Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+  control.SetParentOrigin( ParentOrigin::CENTER );
+
+  Dali::Property::Map map;
+  map[ Dali::Toolkit::Visual::Property::TYPE ] = Dali::Toolkit::DevelVisual::TEXT;
+  map[ Dali::Toolkit::TextVisual::Property::ENABLE_MARKUP ] = true;
+  std::string markupText( "<color value='blue'><font size='50'>H</font></color>ello <color value='blue'><font size='50'>w</font></color>orld" );
+  map[ Dali::Toolkit::TextVisual::Property::TEXT ] = markupText;
+  map[ Dali::Toolkit::TextVisual::Property::TEXT_COLOR ] = Dali::Vector4( 0.25f, 0.25f, 0.5f, 1.f );
+  map[ Dali::Toolkit::TextVisual::Property::FONT_FAMILY ] = "TizenSansRegular";
+  map[ Dali::Toolkit::TextVisual::Property::POINT_SIZE ] = 30.f;
+  map[ Dali::Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT ] = "CENTER";
+  map[ Dali::Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT ] = "CENTER";
+
+  control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
+
+  stage.Add( control );
+
+  try
+  {
+    application.SendNotification();
+    application.Render();
+  }
+  catch( ... )
+  {
+    tet_result(TET_FAIL);
+  }
+
+  // The renderer should be removed.
+  control.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+  control.SetSize( 1.f, 0.f );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( 0u, control.GetRendererCount(), TEST_LOCATION );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
index d06ba71..df25aaa 100644 (file)
@@ -152,6 +152,7 @@ public:
   void GetFontMetrics( FontId fontId, FontMetrics& metrics ){}
   GlyphIndex GetGlyphIndex( FontId fontId, Character charcode ){return 0;}
   bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal ){return true;}
+  void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data ){}
   PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex ){return PixelData();}
   void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob,
                          unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
@@ -159,6 +160,7 @@ public:
     blobLength = 0;
   }
   const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 pointSize ){return mGlyphInfo;}
+  bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ){return false;}
 private:
   unsigned int mDpiHorizontal;
   unsigned int mDpiVertical;
@@ -356,6 +358,14 @@ FontClient::FontClient( const FontClient& handle )
 {
 }
 
+FontClient::GlyphBufferData::GlyphBufferData()
+{
+}
+
+FontClient::GlyphBufferData::~GlyphBufferData()
+{
+}
+
 FontClient& FontClient::operator=( const FontClient& handle )
 {
   BaseHandle::operator=( handle );
@@ -462,12 +472,16 @@ bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType typ
   return GetImplementation(*this).GetGlyphMetrics( array, size, horizontal );
 }
 
+void FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data )
+{
+  GetImplementation(*this).CreateBitmap( fontId, glyphIndex, data );
+}
+
 PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
 {
   return GetImplementation(*this).CreateBitmap( fontId, glyphIndex );
 }
 
-
 void FontClient::CreateVectorBlob( FontId fontId,
                                    GlyphIndex glyphIndex,
                                    VectorBlob*& blob,
@@ -483,6 +497,11 @@ const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 pointSize )
   return GetImplementation(*this).GetEllipsisGlyph( pointSize );
 }
 
+bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
+{
+  return GetImplementation(*this).IsColorGlyph( fontId, glyphIndex );
+}
+
 FontClient::FontClient( Internal::FontClient* internal )
 : BaseHandle( internal )
 {
index 022695d..dd9a805 100644 (file)
@@ -1442,3 +1442,93 @@ int utcDaliTextEditorEvent03(void)
 
   END_TEST;
 }
+
+int utcDaliTextEditorEvent04(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextEditorEvent04");
+
+  // Checks if the highlight actor is created.
+
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK( editor );
+
+  Stage::GetCurrent().Add( editor );
+
+  editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
+  editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
+  editor.SetSize( 100.f, 50.f );
+  editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Tap on the text editor
+  application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
+  application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Move at the end of the text.
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) );
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  for( unsigned int index = 0u; index < 10u; ++index )
+  {
+    application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
+    application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
+
+    // Render and notify
+    application.SendNotification();
+    application.Render();
+  }
+
+  // Add a character
+  application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
+  // Add some key events
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down ) );
+  application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  for( unsigned int index = 0u; index < 10u; ++index )
+  {
+    application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
+    application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
+
+    // Render and notify
+    application.SendNotification();
+    application.Render();
+  }
+
+  // Add a character
+  application.ProcessEvent( GenerateKey( " ", " ", 0, 0, 0, Integration::KeyEvent::Down ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
+
+  END_TEST;
+}
index 1045ad4..6f04d64 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <iostream>
 #include <stdlib.h>
+#include <unistd.h>
+
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
 
@@ -63,6 +65,8 @@ const char* const PROPERTY_NAME_EMBOSS = "emboss";
 const char* const PROPERTY_NAME_OUTLINE = "outline";
 
 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
+const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
+const unsigned int EMOJI_FONT_SIZE = 3968u;
 
 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
 {
@@ -471,46 +475,21 @@ int UtcDaliToolkitTextLabelLanguagesP(void)
   application.SendNotification();
   application.Render();
 
-  END_TEST;
-}
+  TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
 
-int UtcDaliToolkitTextLabelVectorBasedP(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliToolkitTextLabelVectorBasedP");
+  char* pathNamePtr = get_current_dir_name();
+  const std::string pathName( pathNamePtr );
+  free( pathNamePtr );
 
-  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-  glAbstraction.EnableTextureCallTrace( true );
+  fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
 
-  TextLabel label = TextLabel::New();
-  label.SetParentOrigin( ParentOrigin::CENTER );
-  label.SetSize( Stage::GetCurrent().GetSize() );
-  label.SetProperty( TextLabel::Property::TEXT, "Hello World" );
-  label.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
-  label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Toolkit::Text::RENDERING_VECTOR_BASED );
-  Stage::GetCurrent().Add( label );
-
-  application.SendNotification();
-  application.Render();
-
-  // Test that the vector data is uploaded to atlas
-  DALI_TEST_CHECK( glAbstraction.GetTextureTrace().FindMethod("TexSubImage2D") );
-  glAbstraction.GetTextureTrace().Reset();
-
-  // Add another label with the same text in a different point-size
-  TextLabel label2 = TextLabel::New();
-  label2.SetProperty( TextLabel::Property::TEXT, "Hello World" );
-  label2.SetProperty( TextLabel::Property::POINT_SIZE, 13.0f );
-  label2.SetProperty( TextLabel::Property::RENDERING_BACKEND, Toolkit::Text::RENDERING_VECTOR_BASED );
-  Stage::GetCurrent().Add( label2 );
+  const std::string emojis = "<font family='TizenColorEmoji'>\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84</font>";
+  label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
+  label.SetProperty( TextLabel::Property::TEXT, emojis );
 
   application.SendNotification();
   application.Render();
 
-  // Test that no additional vector data was uploaded to atlas
-  // i.e. the same vector data can be used to render any point-size
-  DALI_TEST_CHECK( ! glAbstraction.GetTextureTrace().FindMethod("TexSubImage2D") );
-
   END_TEST;
 }
 
index 814af17..14e8a19 100644 (file)
@@ -24,6 +24,8 @@
 #include <dali/public-api/rendering/shader.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/devel-api/align-enums.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include "dummy-control.h"
@@ -278,7 +280,7 @@ int UtcDaliVisualSize(void)
   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf" );
 
   propertyMap.Clear();
-  propertyMap.Insert( Visual::Property::TYPE, Visual::TEXT );
+  propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT );
   propertyMap.Insert( TextVisual::Property::ENABLE_MARKUP, true );
   propertyMap.Insert( TextVisual::Property::TEXT, "<font family='TizenSans' size='12'>Hello world</font>" );
   propertyMap.Insert( TextVisual::Property::MULTI_LINE, true );
@@ -948,7 +950,7 @@ int UtcDaliVisualGetPropertyMap10(void)
   VisualFactory factory = VisualFactory::Get();
 
   Property::Map propertyMap;
-  propertyMap.Insert( Visual::Property::TYPE, Visual::TEXT );
+  propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT );
   propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
   propertyMap.Insert( "text", "Hello world" );
   propertyMap.Insert( "fontFamily", "TizenSans" );
@@ -963,9 +965,6 @@ int UtcDaliVisualGetPropertyMap10(void)
   propertyMap.Insert( "verticalAlignment", "CENTER" );
   propertyMap.Insert( "textColor", Color::RED );
   propertyMap.Insert( "enableMarkup", false );
-  propertyMap.Insert( "enableAutoScroll", false );
-  propertyMap.Insert( "lineSpacing", 0.f );
-  propertyMap.Insert( "batchingEnabled", false );
   Visual::Base textVisual = factory.CreateVisual( propertyMap );
 
   Property::Map resultMap;
@@ -974,11 +973,7 @@ int UtcDaliVisualGetPropertyMap10(void)
   //Check values in the result map are identical to the initial map's values.
   Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER );
   DALI_TEST_CHECK( value );
-  DALI_TEST_EQUALS( value->Get<int>(), (int)Visual::TEXT, TEST_LOCATION );
-
-  value = resultMap.Find( TextVisual::Property::RENDERING_BACKEND, Property::INTEGER );
-  DALI_TEST_CHECK( value );
-  DALI_TEST_EQUALS( value->Get<int>(), Toolkit::Text::DEFAULT_RENDERING_BACKEND, TEST_LOCATION );
+  DALI_TEST_EQUALS( value->Get<int>(), (int)DevelVisual::TEXT, TEST_LOCATION );
 
   value = resultMap.Find( TextVisual::Property::TEXT, Property::STRING );
   DALI_TEST_CHECK( value );
@@ -1019,17 +1014,6 @@ int UtcDaliVisualGetPropertyMap10(void)
   DALI_TEST_CHECK( value );
   DALI_TEST_CHECK( !value->Get<bool>() );
 
-  value = resultMap.Find( TextVisual::Property::ENABLE_AUTO_SCROLL, Property::BOOLEAN );
-  DALI_TEST_CHECK( !value );
-
-  value = resultMap.Find( TextVisual::Property::LINE_SPACING, Property::FLOAT );
-  DALI_TEST_CHECK( value );
-  DALI_TEST_EQUALS( value->Get<float>(), 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
-  value = resultMap.Find( TextVisual::Property::BATCHING_ENABLED, Property::BOOLEAN );
-  DALI_TEST_CHECK( value );
-  DALI_TEST_CHECK( !value->Get<bool>() );
-
   END_TEST;
 }
 
@@ -1695,7 +1679,7 @@ int UtcDaliVisualTextVisualRender(void)
 
   VisualFactory factory = VisualFactory::Get();
   Property::Map propertyMap;
-  propertyMap.Insert( Visual::Property::TYPE, Visual::TEXT );
+  propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT );
   propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
   propertyMap.Insert( "text", "Hello world" );
   propertyMap.Insert( "fontFamily", "TizenSans" );
@@ -1710,9 +1694,6 @@ int UtcDaliVisualTextVisualRender(void)
   propertyMap.Insert( "verticalAlignment", "CENTER" );
   propertyMap.Insert( "textColor", Color::RED );
   propertyMap.Insert( "enableMarkup", false );
-  propertyMap.Insert( "enableAutoScroll", false );
-  propertyMap.Insert( "lineSpacing", 0.f );
-  propertyMap.Insert( "batchingEnabled", false );
   Visual::Base textVisual = factory.CreateVisual( propertyMap );
   textVisual.SetDepthIndex( 1.f );
 
index 166feb4..38f4c89 100644 (file)
@@ -118,6 +118,7 @@ develapitransitioneffectsdir =  $(develapidir)/transition-effects
 develapitoolbardir =            $(develapicontrolsdir)/tool-bar
 develapitextselectionpopupdir = $(develapicontrolsdir)/text-controls
 develapivisualfactorydir =      $(develapidir)/visual-factory
+develapivisualsdir =            $(develapidir)/visuals
 
 # devel headers
 develapi_HEADERS =                  $(devel_api_header_files)
@@ -135,6 +136,7 @@ develapipageturnview_HEADERS =      $(devel_api_page_turn_view_header_files)
 develapipopup_HEADERS =             $(devel_api_popup_header_files)
 develapiprogressbar_HEADERS =       $(devel_api_progress_bar_header_files)
 develapivisualfactory_HEADERS =     $(devel_api_visual_factory_header_files)
+develapivisuals_HEADERS =           $(devel_api_visuals_header_files)
 develapiscripting_HEADERS =         $(devel_api_scripting_header_files)
 develapishadowview_HEADERS =        $(devel_api_shadow_view_header_files)
 develapishadereffects_HEADERS =     $(devel_api_shader_effects_header_files)
index ba7e85b..c155cc2 100644 (file)
@@ -64,7 +64,6 @@
 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
 #include <dali-toolkit/public-api/visuals/mesh-visual-properties.h>
 #include <dali-toolkit/public-api/visuals/primitive-visual-properties.h>
-#include <dali-toolkit/public-api/visuals/text-visual-properties.h>
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 
 #include <dali-toolkit/public-api/dali-toolkit-version.h>
index a0cd28a..26846a0 100755 (executable)
@@ -84,6 +84,10 @@ devel_api_visual_factory_header_files = \
   $(devel_api_src_dir)/visual-factory/visual-factory.h \
   $(devel_api_src_dir)/visual-factory/visual-base.h
 
+devel_api_visuals_header_files = \
+  $(devel_api_src_dir)/visuals/text-visual-properties.h \
+  $(devel_api_src_dir)/visuals/visual-properties-devel.h
+
 devel_api_shadow_view_header_files = \
   $(devel_api_src_dir)/controls/shadow-view/shadow-view.h
 
diff --git a/dali-toolkit/devel-api/visuals/text-visual-properties.h b/dali-toolkit/devel-api/visuals/text-visual-properties.h
new file mode 100644 (file)
index 0000000..dfb91ec
--- /dev/null
@@ -0,0 +1,101 @@
+#ifndef DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H
+#define DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/toolkit-property-index-ranges.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace TextVisual
+{
+
+namespace Property
+{
+
+enum
+{
+  /**
+   * @brief The text to display in UTF-8 format,
+   * @details name "text", type STRING
+   */
+  TEXT = VISUAL_PROPERTY_START_INDEX,
+
+  /**
+   * @brief The requested font family to use,
+   * @details name "fontFamily", type STRING
+   */
+  FONT_FAMILY,
+
+  /**
+   * @brief The requested font style to use,
+   * @details name "fontStyle", type MAP
+   */
+  FONT_STYLE,
+
+  /**
+   * @brief The size of font in points
+   * @details name "pointSize", type FLOAT
+   */
+  POINT_SIZE,
+
+  /**
+   * @brief The single-line or multi-line layout option
+   * @details name "multiLine", type BOOLEAN, default false
+   */
+  MULTI_LINE,
+
+  /**
+   * @brief The line horizontal alignment
+   * @details name "horizontalAlignment", type STRING,  values "BEGIN", "CENTER", "END", default BEGIN
+   */
+  HORIZONTAL_ALIGNMENT,
+
+  /**
+   * @brief The line vertical alignment
+   * @details name "verticalAlignment", type STRING,  values "TOP",   "CENTER", "BOTTOM", default TOP
+   */
+  VERTICAL_ALIGNMENT,
+
+  /**
+   * @brief The color of the text
+   * @details name "textColor", type VECTOR4
+   */
+  TEXT_COLOR,
+
+  /**
+   * @brief  Whether the mark-up processing is enabled
+   * @details name "enableMarkup", type BOOLEAN
+   */
+  ENABLE_MARKUP,
+};
+
+} // namespace Property
+
+} // namespace TextVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H
diff --git a/dali-toolkit/devel-api/visuals/visual-properties-devel.h b/dali-toolkit/devel-api/visuals/visual-properties-devel.h
new file mode 100644 (file)
index 0000000..08f5c3a
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef DALI_TOOLKIT_VISUAL_PROPERTIES_DEVEL_H
+#define DALI_TOOLKIT_VISUAL_PROPERTIES_DEVEL_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelVisual
+{
+
+/**
+ * @brief All the visual types.
+ */
+enum Type
+{
+  BORDER = Dali::Toolkit::Visual::BORDER,
+  COLOR = Dali::Toolkit::Visual::COLOR,
+  GRADIENT = Dali::Toolkit::Visual::GRADIENT,
+  IMAGE = Dali::Toolkit::Visual::IMAGE,
+  MESH = Dali::Toolkit::Visual::MESH,
+  PRIMITIVE = Dali::Toolkit::Visual::PRIMITIVE,
+  WIREFRAME = Dali::Toolkit::Visual::WIREFRAME,
+  TEXT = Dali::Toolkit::Visual::WIREFRAME + 1, ///< Renders text.
+};
+
+} // namespace DevelVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_VISUAL_PROPERTIES_DEVEL_H
index 299ef5d..81696b7 100644 (file)
@@ -65,9 +65,9 @@ namespace
 
 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
-  { "BEGIN",  Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN  },
-  { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
-  { "END",    Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END    },
+  { "BEGIN",  Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN  },
+  { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER },
+  { "END",    Toolkit::Text::Layout::HORIZONTAL_ALIGN_END    },
 };
 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
 
@@ -173,7 +173,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       {
         if( impl.mController )
         {
-          const std::string text = value.Get< std::string >();
+          const std::string& text = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p TEXT %s\n", impl.mController.Get(), text.c_str() );
 
           impl.mController->SetText( text );
@@ -184,12 +184,12 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       {
         if( impl.mController )
         {
-          const Vector4 textColor = value.Get< Vector4 >();
+          const Vector4& textColor = value.Get< Vector4 >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
 
-          if( impl.mController->GetTextColor() != textColor )
+          if( impl.mController->GetDefaultColor() != textColor )
           {
-            impl.mController->SetTextColor( textColor );
+            impl.mController->SetDefaultColor( textColor );
             impl.mController->SetInputColor( textColor );
             impl.mRenderer.Reset();
           }
@@ -200,7 +200,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       {
         if( impl.mController )
         {
-          const std::string fontFamily = value.Get< std::string >();
+          const std::string& fontFamily = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
           impl.mController->SetDefaultFontFamily( fontFamily );
         }
@@ -229,14 +229,14 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       {
         if( impl.mController )
         {
-          const std::string alignStr = value.Get< std::string >();
+          const std::string& alignStr = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p HORIZONTAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
 
-          LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
-          if( Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(),
-                                                                              HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                              HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
-                                                                              alignment ) )
+          Layout::HorizontalAlignment alignment( Layout::HORIZONTAL_ALIGN_BEGIN );
+          if( Scripting::GetEnumeration< Layout::HorizontalAlignment >( alignStr.c_str(),
+                                                                        HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                        HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                        alignment ) )
           {
             impl.mController->SetHorizontalAlignment( alignment );
           }
@@ -269,7 +269,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       {
         if( impl.mDecorator )
         {
-          const Vector4 color = value.Get< Vector4 >();
+          const Vector4& color = value.Get< Vector4 >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
 
           impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
@@ -281,7 +281,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       {
         if( impl.mDecorator )
         {
-          const Vector4 color = value.Get< Vector4 >();
+          const Vector4& color = value.Get< Vector4 >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
 
           impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
@@ -441,7 +441,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       {
         if( impl.mDecorator )
         {
-          const Rect<int> box = value.Get< Rect<int> >();
+          const Rect<int>& box = value.Get< Rect<int> >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p DECORATION_BOUNDING_BOX %d,%d %dx%d\n", impl.mController.Get(), box.x, box.y, box.width, box.height );
 
           impl.mDecorator->SetBoundingBox( box );
@@ -464,7 +464,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       {
         if( impl.mController )
         {
-          const Vector4 inputColor = value.Get< Vector4 >();
+          const Vector4& inputColor = value.Get< Vector4 >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), inputColor.r, inputColor.g, inputColor.b, inputColor.a );
 
           impl.mController->SetInputColor( inputColor );
@@ -475,7 +475,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
       {
         if( impl.mController )
         {
-          const std::string fontFamily = value.Get< std::string >();
+          const std::string& fontFamily = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
           impl.mController->SetInputFontFamily( fontFamily );
         }
@@ -624,7 +624,7 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind
       {
         if ( impl.mController )
         {
-          value = impl.mController->GetTextColor();
+          value = impl.mController->GetDefaultColor();
         }
         break;
       }
@@ -653,9 +653,9 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind
       {
         if( impl.mController )
         {
-          const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
-                                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+          const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
+                                                                                                          HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                          HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
           if( name )
           {
             value = std::string( name );
@@ -938,7 +938,7 @@ void TextEditor::OnInitialize()
   mDecorator = Text::Decorator::New( *mController,
                                      *mController );
 
-  mController->GetLayoutEngine().SetLayout( LayoutEngine::MULTI_LINE_BOX );
+  mController->GetLayoutEngine().SetLayout( Layout::Engine::MULTI_LINE_BOX );
 
   // Enables the text input.
   mController->EnableTextInput( mDecorator );
@@ -1088,7 +1088,7 @@ void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType )
 
   if( mRenderableActor )
   {
-    const Vector2& scrollOffset = mController->GetScrollPosition();
+    const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
 
     mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
 
index 4723b33..e95ac99 100644 (file)
@@ -63,17 +63,17 @@ namespace
 
 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
-  { "BEGIN",  Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN  },
-  { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
-  { "END",    Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END    },
+  { "BEGIN",  Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN  },
+  { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER },
+  { "END",    Toolkit::Text::Layout::HORIZONTAL_ALIGN_END    },
 };
 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
 
 const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
 {
-  { "TOP",    Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP    },
-  { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
-  { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
+  { "TOP",    Toolkit::Text::Layout::VERTICAL_ALIGN_TOP    },
+  { "CENTER", Toolkit::Text::Layout::VERTICAL_ALIGN_CENTER },
+  { "BOTTOM", Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM },
 };
 const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
 
@@ -199,7 +199,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const std::string text = value.Get< std::string >();
+          const std::string& text = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT %s\n", impl.mController.Get(), text.c_str() );
 
           impl.mController->SetText( text );
@@ -210,7 +210,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const std::string text = value.Get< std::string >();
+          const std::string& text = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
 
           impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
@@ -221,7 +221,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const std::string text = value.Get< std::string >();
+          const std::string& text = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str() );
 
           impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
@@ -232,7 +232,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const std::string fontFamily = value.Get< std::string >();
+          const std::string& fontFamily = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
           impl.mController->SetDefaultFontFamily( fontFamily );
         }
@@ -277,14 +277,14 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const std::string alignStr = value.Get< std::string >();
+          const std::string& alignStr = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p HORIZONTAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
 
-          LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
-          if( Scripting::GetEnumeration< LayoutEngine::HorizontalAlignment >( alignStr.c_str(),
-                                                                              HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                              HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
-                                                                              alignment ) )
+          Layout::HorizontalAlignment alignment( Layout::HORIZONTAL_ALIGN_BEGIN );
+          if( Scripting::GetEnumeration< Layout::HorizontalAlignment >( alignStr.c_str(),
+                                                                        HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                        HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                        alignment ) )
           {
             impl.mController->SetHorizontalAlignment( alignment );
           }
@@ -295,14 +295,14 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const std::string alignStr = value.Get< std::string >();
+          const std::string& alignStr = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p VERTICAL_ALIGNMENT %s\n", impl.mController.Get(), alignStr.c_str() );
 
-          LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
-          if( Scripting::GetEnumeration< LayoutEngine::VerticalAlignment >( alignStr.c_str(),
-                                                                            VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                            VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
-                                                                            alignment ) )
+          Layout::VerticalAlignment alignment( Layout::VERTICAL_ALIGN_BOTTOM );
+          if( Scripting::GetEnumeration< Layout::VerticalAlignment >( alignStr.c_str(),
+                                                                      VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                      VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                      alignment ) )
           {
             impl.mController->SetVerticalAlignment( alignment );
           }
@@ -313,12 +313,12 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const Vector4 textColor = value.Get< Vector4 >();
+          const Vector4& textColor = value.Get< Vector4 >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
 
-          if( impl.mController->GetTextColor() != textColor )
+          if( impl.mController->GetDefaultColor() != textColor )
           {
-            impl.mController->SetTextColor( textColor );
+            impl.mController->SetDefaultColor( textColor );
             impl.mController->SetInputColor( textColor );
             impl.mRenderer.Reset();
           }
@@ -329,7 +329,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const Vector4 textColor = value.Get< Vector4 >();
+          const Vector4& textColor = value.Get< Vector4 >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_COLOR %f,%f,%f,%f\n", impl.mController.Get(), textColor.r, textColor.g, textColor.b, textColor.a );
 
           if( impl.mController->GetPlaceholderTextColor() != textColor )
@@ -344,7 +344,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const Vector2 shadowOffset = value.Get< Vector2 >();
+          const Vector2& shadowOffset = value.Get< Vector2 >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_OFFSET %f,%f\n", impl.mController.Get(), shadowOffset.x, shadowOffset.y );
 
           if ( impl.mController->GetShadowOffset() != shadowOffset )
@@ -359,7 +359,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const Vector4 shadowColor = value.Get< Vector4 >();
+          const Vector4& shadowColor = value.Get< Vector4 >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_COLOR %f,%f,%f,%f\n", impl.mController.Get(), shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a );
 
           if ( impl.mController->GetShadowColor() != shadowColor )
@@ -374,7 +374,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mDecorator )
         {
-          const Vector4 color = value.Get< Vector4 >();
+          const Vector4& color = value.Get< Vector4 >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
 
           impl.mDecorator->SetCursorColor( PRIMARY_CURSOR, color );
@@ -386,7 +386,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mDecorator )
         {
-          const Vector4 color = value.Get< Vector4 >();
+          const Vector4& color = value.Get< Vector4 >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SECONDARY_CURSOR_COLOR %f,%f,%f,%f\n", impl.mController.Get(), color.r, color.g, color.b, color.a );
 
           impl.mDecorator->SetCursorColor( SECONDARY_CURSOR, color );
@@ -608,7 +608,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const std::string fontFamily = value.Get< std::string >();
+          const std::string& fontFamily = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p INPUT_FONT_FAMILY %s\n", impl.mController.Get(), fontFamily.c_str() );
           impl.mController->SetInputFontFamily( fontFamily );
         }
@@ -791,9 +791,9 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde
       {
         if( impl.mController )
         {
-          const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetLayoutEngine().GetHorizontalAlignment(),
-                                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+          const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
+                                                                                                          HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                          HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
           if( name )
           {
             value = std::string( name );
@@ -803,11 +803,11 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde
       }
       case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
       {
-        if( impl.mController )
+        if( impl.mController ) 
         {
-          const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetLayoutEngine().GetVerticalAlignment(),
-                                                                                                              VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                                                              VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+          const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( impl.mController->GetVerticalAlignment(),
+                                                                                                        VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                                        VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
           if( name )
           {
             value = std::string( name );
@@ -819,7 +819,7 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde
       {
         if ( impl.mController )
         {
-          value = impl.mController->GetTextColor();
+          value = impl.mController->GetDefaultColor();
         }
         break;
       }
@@ -1123,7 +1123,7 @@ void TextField::OnInitialize()
   mDecorator = Text::Decorator::New( *mController,
                                      *mController );
 
-  mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
+  mController->GetLayoutEngine().SetLayout( Layout::Engine::SINGLE_LINE_BOX );
 
   // Enables the text input.
   mController->EnableTextInput( mDecorator );
@@ -1267,7 +1267,7 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
 
   if( mRenderableActor )
   {
-    const Vector2& scrollOffset = mController->GetScrollPosition();
+    const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
 
     mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
 
index 094e755..0129388 100644 (file)
@@ -33,7 +33,7 @@
 #include <dali-toolkit/internal/text/text-definitions.h>
 #include <dali-toolkit/internal/styling/style-manager-impl.h>
 
-using Dali::Toolkit::Text::LayoutEngine;
+using namespace Dali::Toolkit::Text;
 
 namespace Dali
 {
@@ -58,17 +58,17 @@ namespace
 
 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
-  { "BEGIN",  Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN  },
-  { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
-  { "END",    Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END    },
+  { "BEGIN",  Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN  },
+  { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER },
+  { "END",    Toolkit::Text::Layout::HORIZONTAL_ALIGN_END    },
 };
 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
 
 const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
 {
-  { "TOP",    Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP    },
-  { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
-  { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
+  { "TOP",    Toolkit::Text::Layout::VERTICAL_ALIGN_TOP    },
+  { "CENTER", Toolkit::Text::Layout::VERTICAL_ALIGN_CENTER },
+  { "BOTTOM", Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM },
 };
 const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
 
@@ -170,7 +170,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const std::string fontFamily = value.Get< std::string >();
+          const std::string& fontFamily = value.Get< std::string >();
 
           DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextLabel::SetProperty Property::FONT_FAMILY newFont(%s)\n", fontFamily.c_str() );
           impl.mController->SetDefaultFontFamily( fontFamily );
@@ -207,11 +207,11 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
-          if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( value.Get< std::string >().c_str(),
-                                                                                             HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                             HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
-                                                                                             alignment ) )
+          Layout::HorizontalAlignment alignment( Layout::HORIZONTAL_ALIGN_BEGIN );
+          if( Scripting::GetEnumeration< Toolkit::Text::Layout::HorizontalAlignment >( value.Get< std::string >().c_str(),
+                                                                                       HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                       HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                                       alignment ) )
           {
             impl.mController->SetHorizontalAlignment( alignment );
           }
@@ -222,11 +222,11 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
-          if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( value.Get< std::string >().c_str(),
-                                                                                           VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                                           VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
-                                                                                           alignment ) )
+          Layout::VerticalAlignment alignment( Layout::VERTICAL_ALIGN_BOTTOM );
+          if( Scripting::GetEnumeration< Toolkit::Text::Layout::VerticalAlignment >( value.Get< std::string >().c_str(),
+                                                                                     VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                     VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                                     alignment ) )
           {
             impl.mController->SetVerticalAlignment( alignment );
           }
@@ -238,10 +238,10 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const Vector4 textColor = value.Get< Vector4 >();
-          if( impl.mController->GetTextColor() != textColor )
+          const Vector4& textColor = value.Get< Vector4 >();
+          if( impl.mController->GetDefaultColor() != textColor )
           {
-            impl.mController->SetTextColor( textColor );
+            impl.mController->SetDefaultColor( textColor );
             impl.mRenderer.Reset();
           }
         }
@@ -252,7 +252,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const Vector2 shadowOffset = value.Get< Vector2 >();
+          const Vector2& shadowOffset = value.Get< Vector2 >();
           if ( impl.mController->GetShadowOffset() != shadowOffset )
           {
             impl.mController->SetShadowOffset( shadowOffset );
@@ -265,7 +265,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const Vector4 shadowColor = value.Get< Vector4 >();
+          const Vector4& shadowColor = value.Get< Vector4 >();
           if ( impl.mController->GetShadowColor() != shadowColor )
           {
             impl.mController->SetShadowColor( shadowColor );
@@ -278,7 +278,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
       {
         if( impl.mController )
         {
-          const Vector4 color = value.Get< Vector4 >();
+          const Vector4& color = value.Get< Vector4 >();
           if ( impl.mController->GetUnderlineColor() != color )
           {
             impl.mController->SetUnderlineColor( color );
@@ -342,7 +342,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
              // If request is enable (true) then start autoscroll as not already running
              else
              {
-               impl.mController->GetLayoutEngine().SetTextEllipsisEnabled( false );
+               impl.mController->SetTextElideEnabled( false );
                impl.mController->SetAutoScrollEnabled( enableAutoScroll );
              }
           }
@@ -485,9 +485,9 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
       {
         if( impl.mController )
         {
-          const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
-                                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+          const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( impl.mController->GetHorizontalAlignment(),
+                                                                                                          HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                          HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
           if( name )
           {
             value = std::string( name );
@@ -499,9 +499,9 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
       {
         if( impl.mController )
         {
-          const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( impl.mController->GetVerticalAlignment(),
-                                                                                                              VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                                                              VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+          const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( impl.mController->GetVerticalAlignment(),
+                                                                                                        VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                                        VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
           if( name )
           {
             value = std::string( name );
@@ -513,7 +513,7 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
       {
         if ( impl.mController )
         {
-          value = impl.mController->GetTextColor();
+          value = impl.mController->GetDefaultColor();
         }
         break;
       }
@@ -652,9 +652,9 @@ void TextLabel::OnInitialize()
   self.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
 
   // Enable the text ellipsis.
-  LayoutEngine& engine = mController->GetLayoutEngine();
+  mController->SetTextElideEnabled( true );   // If false then text larger than control will overflow
 
-  engine.SetTextEllipsisEnabled( true );   // If false then text larger than control will overflow
+  Layout::Engine& engine = mController->GetLayoutEngine();
   engine.SetCursorWidth( 0u ); // Do not layout space for the cursor.
 
   self.OnStageSignal().Connect( this, &TextLabel::OnStageConnect );
@@ -737,7 +737,7 @@ void TextLabel::RenderText()
 
     if( renderableActor )
     {
-      const Vector2& scrollOffset = mController->GetScrollPosition();
+      const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
       renderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
 
       self.Add( renderableActor );
@@ -800,7 +800,7 @@ void TextLabel::ScrollingFinished()
   // Pure Virtual from TextScroller Interface
   DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::ScrollingFinished\n");
   mController->SetAutoScrollEnabled( false );
-  mController->GetLayoutEngine().SetTextEllipsisEnabled( true );
+  mController->SetTextElideEnabled( true );
   RequestTextRelayout();
 }
 
index 1e78bf6..994faaf 100644 (file)
@@ -114,8 +114,8 @@ toolkit_src_files = \
    $(toolkit_src_dir)/text/text-effects-style.cpp \
    $(toolkit_src_dir)/text/text-font-style.cpp \
    $(toolkit_src_dir)/text/text-io.cpp \
+   $(toolkit_src_dir)/text/text-model.cpp \
    $(toolkit_src_dir)/text/text-scroller.cpp \
-   $(toolkit_src_dir)/text/text-scroller-interface.cpp \
    $(toolkit_src_dir)/text/text-view.cpp \
    $(toolkit_src_dir)/text/text-view-interface.cpp \
    $(toolkit_src_dir)/text/visual-model-impl.cpp \
@@ -132,6 +132,8 @@ toolkit_src_files = \
    $(toolkit_src_dir)/text/rendering/atlas/atlas-manager-impl.cpp \
    $(toolkit_src_dir)/text/rendering/atlas/atlas-mesh-factory.cpp \
    $(toolkit_src_dir)/text/rendering/text-backend-impl.cpp \
+   $(toolkit_src_dir)/text/rendering/text-typesetter.cpp \
+   $(toolkit_src_dir)/text/rendering/view-model.cpp \
    $(toolkit_src_dir)/transition-effects/cube-transition-effect-impl.cpp \
    $(toolkit_src_dir)/transition-effects/cube-transition-cross-effect-impl.cpp \
    $(toolkit_src_dir)/transition-effects/cube-transition-fold-effect-impl.cpp \
@@ -1,3 +1,6 @@
+#ifndef DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H
+#define DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H
+
 /*
  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
@@ -15,9 +18,6 @@
  *
  */
 
-// CLASS HEADER
-#include <dali-toolkit/internal/text/text-scroller-interface.h>
-
 namespace Dali
 {
 
@@ -27,16 +27,38 @@ namespace Toolkit
 namespace Text
 {
 
-ScrollerInterface::ScrollerInterface()
+namespace Layout
 {
-}
 
-ScrollerInterface::~ScrollerInterface()
+/**
+ * @brief Speficies the horizontal alignment.
+ *
+ * BEGIN is on the left for Left To Right languages whereas is right for Right To Left.
+ * Similarly, END is on the right for Left To Right languages and left for Right To Left.
+ */
+enum HorizontalAlignment
 {
-}
+  HORIZONTAL_ALIGN_BEGIN,
+  HORIZONTAL_ALIGN_CENTER,
+  HORIZONTAL_ALIGN_END
+};
+
+/**
+ * @brief Speficies the vertical alignment.
+ */
+enum VerticalAlignment
+{
+  VERTICAL_ALIGN_TOP,
+  VERTICAL_ALIGN_CENTER,
+  VERTICAL_ALIGN_BOTTOM
+};
+
+} // namespace Layout
 
 } // namespace Text
 
 } // namespace Toolkit
 
 } // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H
index 717c752..148ff58 100644 (file)
@@ -38,6 +38,9 @@ namespace Toolkit
 namespace Text
 {
 
+namespace Layout
+{
+
 namespace
 {
 
@@ -99,15 +102,12 @@ struct LineLayout
   float          descender;          ///< The minimum descender of all fonts in the line.
 };
 
-struct LayoutEngine::Impl
+struct Engine::Impl
 {
   Impl()
-  : mLayout( LayoutEngine::SINGLE_LINE_BOX ),
-    mHorizontalAlignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN ),
-    mVerticalAlignment( LayoutEngine::VERTICAL_ALIGN_TOP ),
+  : mLayout( Layout::Engine::SINGLE_LINE_BOX ),
     mCursorWidth( CURSOR_WIDTH ),
-    mDefaultLineSpacing( LINE_SPACING ),
-    mEllipsisEnabled( false )
+    mDefaultLineSpacing( LINE_SPACING )
   {
   }
 
@@ -187,7 +187,7 @@ struct LayoutEngine::Impl
    * @param[in,out] paragraphDirection in: the current paragraph's direction, out: the next paragraph's direction. Is set after a must break.
    * @param[in] completelyFill Whether to completely fill the line ( even if the last word exceeds the boundaries ).
    */
-  void GetLineLayoutForBox( const LayoutParameters& parameters,
+  void GetLineLayoutForBox( const Parameters& parameters,
                             LineLayout& lineLayout,
                             CharacterDirection& paragraphDirection,
                             bool completelyFill )
@@ -538,7 +538,7 @@ struct LayoutEngine::Impl
    *
    * return Whether the line is ellipsized.
    */
-  bool EllipsisLine( const LayoutParameters& layoutParameters,
+  bool EllipsisLine( const Parameters& layoutParameters,
                      const LineLayout& layout,
                      Size& layoutSize,
                      LineRun* linesBuffer,
@@ -620,7 +620,7 @@ struct LayoutEngine::Impl
    * @param[in,out] numberOfLines The number of laid-out lines.
    * @param[in] isLastLine Whether the laid-out line is the last one.
    */
-  void UpdateTextLayout( const LayoutParameters& layoutParameters,
+  void UpdateTextLayout( const Parameters& layoutParameters,
                          const LineLayout& layout,
                          Size& layoutSize,
                          LineRun* linesBuffer,
@@ -678,7 +678,7 @@ struct LayoutEngine::Impl
    * @param[in,out] linesBuffer Pointer to the line's buffer.
    * @param[in,out] numberOfLines The number of laid-out lines.
    */
-  void UpdateTextLayout( const LayoutParameters& layoutParameters,
+  void UpdateTextLayout( const Parameters& layoutParameters,
                          CharacterIndex characterIndex,
                          GlyphIndex glyphIndex,
                          Size& layoutSize,
@@ -742,7 +742,7 @@ struct LayoutEngine::Impl
    * @param[in] characterOffset The offset to be added to the runs of characters.
    * @param[in] glyphOffset The offset to be added to the runs of glyphs.
    */
-  void UpdateLineIndexOffsets( const LayoutParameters& layoutParameters,
+  void UpdateLineIndexOffsets( const Parameters& layoutParameters,
                                Vector<LineRun>& lines,
                                Length characterOffset,
                                Length glyphOffset )
@@ -763,10 +763,11 @@ struct LayoutEngine::Impl
     }
   }
 
-  bool LayoutText( const LayoutParameters& layoutParameters,
+  bool LayoutText( const Parameters& layoutParameters,
                    Vector<Vector2>& glyphPositions,
                    Vector<LineRun>& lines,
-                   Size& layoutSize )
+                   Size& layoutSize,
+                   bool elideTextEnabled )
   {
     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->LayoutText\n" );
     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "  box size %f, %f\n", layoutParameters.boundingBox.width, layoutParameters.boundingBox.height );
@@ -890,7 +891,7 @@ struct LayoutEngine::Impl
       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "  pen y %f\n", penY );
 
       bool ellipsis = false;
-      if( mEllipsisEnabled )
+      if( elideTextEnabled )
       {
         // Does the ellipsis of the last line.
         ellipsis = EllipsisLine( layoutParameters,
@@ -1014,7 +1015,7 @@ struct LayoutEngine::Impl
     return true;
   }
 
-  void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters,
+  void ReLayoutRightToLeftLines( const Parameters& layoutParameters,
                                  CharacterIndex startIndex,
                                  Length numberOfCharacters,
                                  Vector<Vector2>& glyphPositions )
@@ -1076,6 +1077,7 @@ struct LayoutEngine::Impl
   void Align( const Size& size,
               CharacterIndex startIndex,
               Length numberOfCharacters,
+              HorizontalAlignment horizontalAlignment,
               Vector<LineRun>& lines )
   {
     const CharacterIndex lastCharacterPlusOne = startIndex + numberOfCharacters;
@@ -1102,18 +1104,20 @@ struct LayoutEngine::Impl
       // Calculate the line's alignment offset accordingly with the align option,
       // the box width, line length, and the paragraph's direction.
       CalculateHorizontalAlignment( size.width,
+                                    horizontalAlignment,
                                     line );
     }
   }
 
   void CalculateHorizontalAlignment( float boxWidth,
+                                     HorizontalAlignment horizontalAlignment,
                                      LineRun& line )
   {
     line.alignmentOffset = 0.f;
     const bool isRTL = RTL == line.direction;
     float lineLength = line.width;
 
-    HorizontalAlignment alignment = mHorizontalAlignment;
+    HorizontalAlignment alignment = horizontalAlignment;
     if( isRTL )
     {
       // Swap the alignment type if the line is right to left.
@@ -1191,100 +1195,67 @@ struct LayoutEngine::Impl
     line.ellipsis = false;
   }
 
-  LayoutEngine::Layout mLayout;
-  LayoutEngine::HorizontalAlignment mHorizontalAlignment;
-  LayoutEngine::VerticalAlignment mVerticalAlignment;
+  Type mLayout;
   float mCursorWidth;
   float mDefaultLineSpacing;
 
   IntrusivePtr<Metrics> mMetrics;
-
-  bool mEllipsisEnabled:1;
 };
 
-LayoutEngine::LayoutEngine()
+Engine::Engine()
 : mImpl( NULL )
 {
-  mImpl = new LayoutEngine::Impl();
+  mImpl = new Engine::Impl();
 }
 
-LayoutEngine::~LayoutEngine()
+Engine::~Engine()
 {
   delete mImpl;
 }
 
-void LayoutEngine::SetMetrics( MetricsPtr& metrics )
+void Engine::SetMetrics( MetricsPtr& metrics )
 {
   mImpl->mMetrics = metrics;
 }
 
-void LayoutEngine::SetLayout( Layout layout )
+void Engine::SetLayout( Type layout )
 {
   mImpl->mLayout = layout;
 }
 
-LayoutEngine::Layout LayoutEngine::GetLayout() const
+Engine::Type Engine::GetLayout() const
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "GetLayout[%d]\n", mImpl->mLayout);
   return mImpl->mLayout;
 }
 
-void LayoutEngine::SetTextEllipsisEnabled( bool enabled )
-{
-  DALI_LOG_INFO( gLogFilter, Debug::General, "-->LayoutEngine::SetTextEllipsisEnabled[%s]\n", (enabled)?"true":"false" );
-  mImpl->mEllipsisEnabled = enabled;
-}
-
-bool LayoutEngine::GetTextEllipsisEnabled() const
-{
-  return mImpl->mEllipsisEnabled;
-}
-
-void LayoutEngine::SetHorizontalAlignment( HorizontalAlignment alignment )
-{
-  mImpl->mHorizontalAlignment = alignment;
-}
-
-LayoutEngine::HorizontalAlignment LayoutEngine::GetHorizontalAlignment() const
-{
-  return mImpl->mHorizontalAlignment;
-}
-
-void LayoutEngine::SetVerticalAlignment( VerticalAlignment alignment )
-{
-  mImpl->mVerticalAlignment = alignment;
-}
-
-LayoutEngine::VerticalAlignment LayoutEngine::GetVerticalAlignment() const
-{
-  return mImpl->mVerticalAlignment;
-}
-
-void LayoutEngine::SetCursorWidth( int width )
+void Engine::SetCursorWidth( int width )
 {
   mImpl->mCursorWidth = static_cast<float>( width );
 }
 
-int LayoutEngine::GetCursorWidth() const
+int Engine::GetCursorWidth() const
 {
   return static_cast<int>( mImpl->mCursorWidth );
 }
 
-bool LayoutEngine::LayoutText( const LayoutParameters& layoutParameters,
-                               Vector<Vector2>& glyphPositions,
-                               Vector<LineRun>& lines,
-                               Size& layoutSize )
+bool Engine::LayoutText( const Parameters& layoutParameters,
+                         Vector<Vector2>& glyphPositions,
+                         Vector<LineRun>& lines,
+                         Size& layoutSize,
+                         bool elideTextEnabled )
 {
   return mImpl->LayoutText( layoutParameters,
                             glyphPositions,
                             lines,
-                            layoutSize );
+                            layoutSize,
+                            elideTextEnabled );
 }
 
-void LayoutEngine::ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters,
-                                             CharacterIndex startIndex,
-                                             Length numberOfCharacters,
-                                             Vector<Vector2>& glyphPositions )
+void Engine::ReLayoutRightToLeftLines( const Parameters& layoutParameters,
+                                       CharacterIndex startIndex,
+                                       Length numberOfCharacters,
+                                       Vector<Vector2>& glyphPositions )
 {
   mImpl->ReLayoutRightToLeftLines( layoutParameters,
                                    startIndex,
@@ -1292,27 +1263,31 @@ void LayoutEngine::ReLayoutRightToLeftLines( const LayoutParameters& layoutParam
                                    glyphPositions );
 }
 
-void LayoutEngine::Align( const Size& size,
-                          CharacterIndex startIndex,
-                          Length numberOfCharacters,
-                          Vector<LineRun>& lines )
+void Engine::Align( const Size& size,
+                    CharacterIndex startIndex,
+                    Length numberOfCharacters,
+                    Layout::HorizontalAlignment horizontalAlignment,
+                    Vector<LineRun>& lines )
 {
   mImpl->Align( size,
                 startIndex,
                 numberOfCharacters,
+                horizontalAlignment,
                 lines );
 }
 
-void LayoutEngine::SetDefaultLineSpacing( float lineSpacing )
+void Engine::SetDefaultLineSpacing( float lineSpacing )
 {
   mImpl->mDefaultLineSpacing = lineSpacing;
 }
 
-float LayoutEngine::GetDefaultLineSpacing() const
+float Engine::GetDefaultLineSpacing() const
 {
   return mImpl->mDefaultLineSpacing;
 }
 
+} // namespace Layout
+
 } // namespace Text
 
 } // namespace Toolkit
index 79daa23..71768ee 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
-#define __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
+#ifndef DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
+#define DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
 #include <dali/public-api/math/vector2.h>
 
 // INTERNAL INCLUDE
+#include <dali-toolkit/internal/text/layouts/layout-alignment.h>
 #include <dali-toolkit/internal/text/line-run.h>
 #include <dali-toolkit/internal/text/metrics.h>
 
@@ -35,44 +36,33 @@ namespace Toolkit
 namespace Text
 {
 
-struct LayoutParameters;
+namespace Layout
+{
+
+struct Parameters;
 
 /**
  * @brief LayoutEngine is responsible for calculating the visual position of glyphs in layout.
  */
-class LayoutEngine
+class Engine
 {
 public:
 
-  enum Layout
+  enum Type
   {
     SINGLE_LINE_BOX,
     MULTI_LINE_BOX
   };
 
-  enum HorizontalAlignment
-  {
-    HORIZONTAL_ALIGN_BEGIN,
-    HORIZONTAL_ALIGN_CENTER,
-    HORIZONTAL_ALIGN_END
-  };
-
-  enum VerticalAlignment
-  {
-    VERTICAL_ALIGN_TOP,
-    VERTICAL_ALIGN_CENTER,
-    VERTICAL_ALIGN_BOTTOM
-  };
-
   /**
    * @brief Create a new instance of a LayoutEngine.
    */
-  LayoutEngine();
+  Engine();
 
   /**
    * @brief Virtual destructor.
    */
-  ~LayoutEngine();
+  ~Engine();
 
   /**
    * @brief Provide the wrapper around FontClient used to get metrics
@@ -86,54 +76,14 @@ public:
    *
    * @param[in] layout The required layout.
    */
-  void SetLayout( Layout layout );
+  void SetLayout( Type layout );
 
   /**
    * @brief Query the required layout.
    *
    * @return The required layout.
    */
-  Layout GetLayout() const;
-
-  /**
-   * @brief Enable or disable the text ellipsis.
-   *
-   * @param[in] enabled Whether to enable the text ellipsis.
-   */
-  void SetTextEllipsisEnabled( bool enabled );
-
-  /**
-   * @return Whether the text ellipsis is enabled.
-   */
-  bool GetTextEllipsisEnabled() const;
-
-  /**
-   * @brief Choose the required text horizontal alignment.
-   *
-   * @param[in] alignment The required alignment.
-   */
-  void SetHorizontalAlignment( HorizontalAlignment alignment );
-
-  /**
-   * @brief Query the required text horizontal alignment.
-   *
-   * @return The required alignment.
-   */
-  HorizontalAlignment GetHorizontalAlignment() const;
-
-  /**
-   * @brief Choose the required text vertical alignment.
-   *
-   * @param[in] alignment The required alignment.
-   */
-  void SetVerticalAlignment( VerticalAlignment alignment );
-
-  /**
-   * @brief Query the required text vertical alignment.
-   *
-   * @return The required alignment.
-   */
-  VerticalAlignment GetVerticalAlignment() const;
+  Type GetLayout() const;
 
   /**
    * @brief Sets the width of the cursor.
@@ -156,13 +106,15 @@ public:
    * @param[out] glyphPositions The positions of all the glyphs.
    * @param[out] lines The laid-out lines.
    * @param[out] layoutSize The size of the text after it has been laid-out.
+   * @param[in] elideTextEnabled Whether the text elide is enabled.
    *
    * @return \e true if the text has been re-laid-out. \e false means the given width is too small to layout even a single character.
    */
-  bool LayoutText( const LayoutParameters& layoutParameters,
+  bool LayoutText( const Parameters& layoutParameters,
                    Vector<Vector2>& glyphPositions,
                    Vector<LineRun>& lines,
-                   Size& layoutSize );
+                   Size& layoutSize,
+                   bool elideTextEnabled );
 
   /**
    * @brief Re-lays out those lines with right to left characters.
@@ -174,7 +126,7 @@ public:
    * @param[in] numberOfCharacters The number of characters.
    * @param[in,out] glyphPositions The positions of all the glyphs.
    */
-  void ReLayoutRightToLeftLines( const LayoutParameters& layoutParameters,
+  void ReLayoutRightToLeftLines( const Parameters& layoutParameters,
                                  CharacterIndex startIndex,
                                  Length numberOfCharacters,
                                  Vector<Vector2>& glyphPositions );
@@ -185,11 +137,13 @@ public:
    * @param[in] size The size of the container where the text is laid-out.
    * @param[in] startIndex Character index of the line from where the lines are aligned.
    * @param[in] numberOfCharacters The number of characters.
+   * @param[in] horizontalAlignment The horizontal alignment.
    * @param[in,out] lines The laid-out lines.
    */
   void Align( const Size& size,
               CharacterIndex startIndex,
               Length numberOfCharacters,
+              Layout::HorizontalAlignment horizontalAlignment,
               Vector<LineRun>& lines );
 
   /**
@@ -209,20 +163,23 @@ public:
 private:
 
   // Undefined
-  LayoutEngine( const LayoutEngine& handle );
+  Engine( const Engine& handle );
 
   // Undefined
-  LayoutEngine& operator=( const LayoutEngine& handle );
+  Engine& operator=( const Engine& handle );
 
 private:
 
   struct Impl;
   Impl* mImpl;
 };
+
+} // namespace Layout
+
 } // namespace Text
 
 } // namespace Toolkit
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
+#endif // DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H
index 8d875bf..f62191f 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H__
-#define __DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H__
+#ifndef DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H
+#define DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,10 +35,13 @@ namespace Text
 
 struct BidirectionalLineInfoRun;
 
+namespace Layout
+{
+
 /**
  * @brief Struct used to pass parameters.
  */
-struct LayoutParameters
+struct Parameters
 {
   /**
    * Constructor with the needed parameters to layout the text.
@@ -54,18 +57,20 @@ struct LayoutParameters
    * @param[in] charactersToGlyphsBuffer Vector with indices pointing the first glyph of each character.
    * @param[in] glyphsPerCharacterBuffer Vector with the number of glyphs shaped from the character.
    * @param[in] totalNumberOfGlyphs The number of glyphs.
+   * @param[in] horizontalAlignment The horizontal alignment.
    */
-  LayoutParameters( const Vector2& boundingBox,
-                    const Character* const textBuffer,
-                    const LineBreakInfo* const lineBreakInfoBuffer,
-                    const WordBreakInfo* const wordBreakInfoBuffer,
-                    const CharacterDirection* const characterDirectionBuffer,
-                    const GlyphInfo* const glyphsBuffer,
-                    const CharacterIndex* const glyphsToCharactersBuffer,
-                    const Length* const charactersPerGlyphBuffer,
-                    const GlyphIndex* const charactersToGlyphsBuffer,
-                    const Length* const glyphsPerCharacterBuffer,
-                    Length totalNumberOfGlyphs )
+  Parameters( const Vector2& boundingBox,
+              const Character* const textBuffer,
+              const LineBreakInfo* const lineBreakInfoBuffer,
+              const WordBreakInfo* const wordBreakInfoBuffer,
+              const CharacterDirection* const characterDirectionBuffer,
+              const GlyphInfo* const glyphsBuffer,
+              const CharacterIndex* const glyphsToCharactersBuffer,
+              const Length* const charactersPerGlyphBuffer,
+              const GlyphIndex* const charactersToGlyphsBuffer,
+              const Length* const glyphsPerCharacterBuffer,
+              Length totalNumberOfGlyphs,
+              HorizontalAlignment horizontalAlignment )
   : boundingBox( boundingBox ),
     textBuffer( textBuffer ),
     lineBreakInfoBuffer( lineBreakInfoBuffer ),
@@ -81,6 +86,7 @@ struct LayoutParameters
     startGlyphIndex( 0u ),
     numberOfGlyphs( 0u ),
     totalNumberOfGlyphs( totalNumberOfGlyphs ),
+    horizontalAlignment( horizontalAlignment ),
     startLineIndex( 0u ),
     estimatedNumberOfLines( 0u ),
     isLastNewParagraph( false )
@@ -101,15 +107,18 @@ struct LayoutParameters
   GlyphIndex                      startGlyphIndex;                 ///< Index to the first glyph to layout.
   Length                          numberOfGlyphs;                  ///< The number of glyphs to layout.
   Length                          totalNumberOfGlyphs;             ///< The number of glyphs.
+  HorizontalAlignment             horizontalAlignment;             ///< The horizontal alignment.
   LineIndex                       startLineIndex;                  ///< The line index where to insert the new lines.
   Length                          estimatedNumberOfLines;          ///< The estimated number of lines.
   bool                            isLastNewParagraph;              ///< Whether the last character is a new paragraph character.
 };
 
+} // namespace Layout
+
 } // namespace Text
 
 } // namespace Toolkit
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H__
+#endif // DALI_TOOLKIT_TEXT_LAYOUT_PARAMETERS_H
index 32e7c38..260bd5a 100644 (file)
@@ -589,10 +589,8 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
           if( isValidFont &&
               isEmojiScript )
           {
-            const PixelData bitmap = fontClient.CreateBitmap( fontId, glyphIndex );
-
-            // For color emojis, the font is valid if the bitmap is RGBA.
-            isValidFont = bitmap && ( Pixel::BGRA8888 == bitmap.GetPixelFormat() );
+            // For color emojis, the font is valid if the glyph is a color glyph (the bitmap is RGBA).
+            isValidFont = fontClient.IsColorGlyph( fontId, glyphIndex );
           }
 
           // If there is a valid font, cache it.
diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.cpp b/dali-toolkit/internal/text/rendering/text-typesetter.cpp
new file mode 100644 (file)
index 0000000..62e3b14
--- /dev/null
@@ -0,0 +1,285 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/text/rendering/text-typesetter.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/text-abstraction/font-client.h>
+#include <memory.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/rendering/view-model.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+namespace
+{
+
+/**
+ * @brief Data struct used to set the buffer of the glyph's bitmap into the final bitmap's buffer.
+ */
+struct GlyphData
+{
+  uint32_t*                                    bitmapBuffer;     ///< The buffer of the whole bitmap. The format is RGBA8888.
+  Vector2*                                     position;         ///< The position of the glyph.
+  TextAbstraction::FontClient::GlyphBufferData glyphBitmap;      ///< The glyph's bitmap.
+  unsigned int                                 width;            ///< The bitmap's width.
+  unsigned int                                 height;           ///< The bitmap's height.
+  int                                          horizontalOffset; ///< The horizontal offset to be added to the 'x' glyph's position.
+  int                                          verticalOffset;   ///< The vertical offset to be added to the 'y' glyph's position.
+};
+
+/**
+ * @brief Sets the glyph's buffer into the bitmap's buffer.
+ *
+ * @param[in] data Struct which contains the glyph's data and the bitmap's data.
+ * @param[in] position The position of the glyph.
+ * @param[in] color The color of the glyph.
+ */
+void TypesetGlyph( const GlyphData& data,
+                   const Vector2* const position,
+                   const Vector4* const color )
+{
+  if( ( 0u == data.glyphBitmap.width ) || ( 0u == data.glyphBitmap.height ) )
+  {
+    // Nothing to do if the width or height of the buffer is zero.
+    return;
+  }
+
+  const int widthMinusOne = static_cast<int>( data.width - 1u );
+  const int heightMinusOne = static_cast<int>( data.height - 1u );
+
+  // Whether the given glyph is a color one.
+  const bool isColorGlyph = Pixel::BGRA8888 == data.glyphBitmap.format;
+
+  // Pointer to the color glyph if there is one.
+  const uint32_t* const colorGlyphBuffer = isColorGlyph ? reinterpret_cast<uint32_t*>( data.glyphBitmap.buffer ) : NULL;
+
+  // Pack the given color into a 32bit buffer. The alpha channel will be updated later for each pixel.
+  // The format is RGBA8888.
+  uint32_t packedColor = 0u;
+  uint8_t* packedColorBuffer = reinterpret_cast<uint8_t*>( &packedColor );
+  *( packedColorBuffer + 2 ) = static_cast<uint8_t>( color->b * 255.f );
+  *( packedColorBuffer + 1 ) = static_cast<uint8_t>( color->g * 255.f );
+    *packedColorBuffer       = static_cast<uint8_t>( color->r * 255.f );
+
+  // Initial vertical offset.
+  const int yOffset = data.verticalOffset + position->y;
+
+  // Traverse the pixels of the glyph line per line.
+  for( int lineIndex = 0, glyphHeight = static_cast<int>( data.glyphBitmap.height ); lineIndex < glyphHeight; ++lineIndex )
+  {
+    const int yOffsetIndex = yOffset + lineIndex;
+    if( ( 0 > yOffsetIndex ) || ( yOffsetIndex > heightMinusOne ) )
+    {
+      // Do not write out of bounds.
+      break;
+    }
+
+    const int verticalOffset = yOffsetIndex * data.width;
+    const int xOffset = data.horizontalOffset + position->x;
+    const int glyphBufferOffset = lineIndex * static_cast<int>( data.glyphBitmap.width );
+    for( int index = 0, glyphWidth = static_cast<int>( data.glyphBitmap.width ); index < glyphWidth; ++index )
+    {
+      const int xOffsetIndex = xOffset + index;
+      if( ( 0 > xOffsetIndex ) || ( xOffsetIndex > widthMinusOne ) )
+      {
+        // Don't write out of bounds.
+        break;
+      }
+
+      if( isColorGlyph )
+      {
+        // Retrieves the color from the glyph. The format is BGRA8888.
+        uint32_t packedColorGlyph = *( colorGlyphBuffer + glyphBufferOffset + index );
+
+        // Update the alpha channel.
+        uint8_t* packedColorGlyphBuffer = reinterpret_cast<uint8_t*>( &packedColorGlyph );
+        std::swap( *packedColorGlyphBuffer, *( packedColorGlyphBuffer + 2u ) ); // Swap B and R.
+        *( packedColorGlyphBuffer + 3u ) = static_cast<uint8_t>( color->a * static_cast<float>( *( packedColorGlyphBuffer + 3u ) ) );
+
+        // Set the color into the final pixel buffer.
+        *( data.bitmapBuffer + verticalOffset + xOffsetIndex ) = packedColorGlyph;
+      }
+      else
+      {
+        // Update the alpha channel.
+        const uint8_t alpha = *( data.glyphBitmap.buffer + glyphBufferOffset + index );
+        *( packedColorBuffer + 3u ) = static_cast<uint8_t>( color->a * static_cast<float>( alpha ) );
+
+        // Set the color into the final pixel buffer.
+        *( data.bitmapBuffer + verticalOffset + xOffsetIndex ) = packedColor;
+      }
+    }
+  }
+}
+
+} // namespace
+
+TypesetterPtr Typesetter::New( const ModelInterface* const model )
+{
+  return TypesetterPtr( new Typesetter( model ) );
+}
+
+ViewModel* Typesetter::GetViewModel()
+{
+  return mModel;
+}
+
+PixelData Typesetter::Render( const Vector2& size )
+{
+  // @todo. This initial implementation for a TextLabel has only one visible page.
+
+  // Elides the text if needed.
+  mModel->ElideGlyphs();
+
+  // Retrieves the layout size.
+  const Size& layoutSize = mModel->GetLayoutSize();
+
+  // Set the offset for the vertical alignment.
+  int penY = 0u;
+
+  switch( mModel->GetVerticalAlignment() )
+  {
+    case Layout::VERTICAL_ALIGN_TOP:
+    {
+      // No offset to add.
+      break;
+    }
+    case Layout::VERTICAL_ALIGN_CENTER:
+    {
+      penY = static_cast<int>( 0.5f * ( size.height - layoutSize.height ) );
+      break;
+    }
+    case Layout::VERTICAL_ALIGN_BOTTOM:
+    {
+      penY = static_cast<int>( size.height - layoutSize.height );
+      break;
+    }
+  }
+
+  // Retrieve lines, glyphs, positions and colors from the view model.
+  const Length modelNumberOfLines = mModel->GetNumberOfLines();
+  const LineRun* const modelLinesBuffer = mModel->GetLines();
+  const Length numberOfGlyphs = mModel->GetNumberOfGlyphs();
+  const GlyphInfo* const glyphsBuffer = mModel->GetGlyphs();
+  const Vector2* const positionBuffer = mModel->GetLayout();
+  const Vector4* const colorsBuffer = mModel->GetColors();
+  const ColorIndex* const colorIndexBuffer = mModel->GetColorIndices();
+
+  // Whether to use the default color.
+  const bool useDefaultColor = NULL == colorsBuffer;
+  const Vector4& defaultColor = mModel->GetDefaultColor();
+
+  // Create and initialize the pixel buffer.
+  GlyphData glyphData;
+  glyphData.verticalOffset = penY;
+
+  glyphData.width = static_cast<unsigned int>( size.width );
+  glyphData.height = static_cast<unsigned int>( size.height );
+  const unsigned int bufferSizeInt = glyphData.width * glyphData.height;
+  const unsigned int bufferSizeChar = 4u * bufferSizeInt;
+  glyphData.bitmapBuffer = new uint32_t[ bufferSizeInt ]; // This array will get deleted by PixelData because of the DELETE_ARRAY parameter.
+  memset( glyphData.bitmapBuffer, 0u, bufferSizeChar );
+
+  PixelData pixelData = PixelData::New( reinterpret_cast<uint8_t*>( glyphData.bitmapBuffer ),
+                                        bufferSizeChar,
+                                        glyphData.width,
+                                        glyphData.height,
+                                        Pixel::RGBA8888, // The format is RGBA8888 because is the format accepted by the image atlas manager.
+                                        PixelData::DELETE_ARRAY );
+
+  // Get a handle of the font client. Used to retrieve the bitmaps of the glyphs.
+  TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+
+  // Traverses the lines of the text.
+  for( LineIndex lineIndex = 0u; lineIndex < modelNumberOfLines; ++lineIndex )
+  {
+    const LineRun& line = *( modelLinesBuffer + lineIndex );
+
+    // Sets the horizontal offset of the line.
+    glyphData.horizontalOffset = static_cast<int>( line.alignmentOffset );
+
+    // Increases the vertical offset with the line's ascender.
+    glyphData.verticalOffset += static_cast<int>( line.ascender );
+
+    // Traverses the glyphs of the line.
+    const GlyphIndex endGlyphIndex = std::min( numberOfGlyphs, line.glyphRun.glyphIndex + line.glyphRun.numberOfGlyphs );
+    for( GlyphIndex glyphIndex = line.glyphRun.glyphIndex; glyphIndex < endGlyphIndex; ++glyphIndex )
+    {
+      // Retrieve the glyph's info.
+      const GlyphInfo* const glyphInfo = glyphsBuffer + glyphIndex;
+
+      if( ( glyphInfo->width < Math::MACHINE_EPSILON_1000 ) ||
+          ( glyphInfo->height < Math::MACHINE_EPSILON_1000 ) )
+      {
+        // Nothing to do if the glyph's width or height is zero.
+        continue;
+      }
+
+      // Retrieves the glyph's position.
+      const Vector2* const position = positionBuffer + glyphIndex;
+
+      // Retrieves the glyph's color.
+      const ColorIndex colorIndex = *( colorIndexBuffer + glyphIndex );
+      const Vector4* const color = ( useDefaultColor || ( 0u == colorIndex ) ) ? &defaultColor : colorsBuffer + ( colorIndex - 1u );
+
+      // Retrieves the glyph's bitmap.
+      glyphData.glyphBitmap.buffer = NULL;
+      fontClient.CreateBitmap( glyphInfo->fontId,
+                               glyphInfo->index,
+                               glyphData.glyphBitmap );
+
+      // Sets the glyph's bitmap into the bitmap of the whole text.
+      if( NULL != glyphData.glyphBitmap.buffer )
+      {
+        TypesetGlyph( glyphData,
+                      position,
+                      color );
+      }
+    }
+
+    // Increases the vertical offset with the line's descender.
+    glyphData.verticalOffset += static_cast<int>( -line.descender );
+  }
+
+  return pixelData;
+}
+
+Typesetter::Typesetter( const ModelInterface* const model )
+: mModel( new ViewModel( model ) )
+{
+}
+
+Typesetter::~Typesetter()
+{
+  delete mModel;
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.h b/dali-toolkit/internal/text/rendering/text-typesetter.h
new file mode 100644 (file)
index 0000000..62d9d94
--- /dev/null
@@ -0,0 +1,114 @@
+#ifndef DALI_TOOLKIT_TEXT_TYPESETTER_H
+#define DALI_TOOLKIT_TEXT_TYPESETTER_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
+#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/images/pixel-data.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+class ModelInterface;
+class ViewModel;
+class Typesetter;
+
+typedef IntrusivePtr<Typesetter> TypesetterPtr;
+
+/**
+ * @brief This class is responsible of controlling the data flow of the text's rendering process.
+ */
+class Typesetter : public RefObject
+{
+public: // Constructor.
+  /**
+   * @brief Creates a Typesetter instance.
+   *
+   * The typesetter composes the final text retrieving the glyphs and the
+   * styles from the text's model.
+   *
+   * @param[in] model Pointer to the text's data model.
+   */
+  static TypesetterPtr New( const ModelInterface* const model );
+
+public:
+  /**
+   * @brief Retrieves the pointer to the view model.
+   *
+   * @return A pointer to the view model.
+   */
+  ViewModel* GetViewModel();
+
+  /**
+   * @brief Renders the text.
+   *
+   * Does the following operations:
+   * - Finds the visible pages needed to be rendered.
+   * - Elide glyphs if needed.
+   * - Retrieves the data buffers from the text model.
+   * - Creates the pixel data used to generate the final image with the given size.
+   * - Traverse the visible glyphs, retrieve their bitmaps and compose the final pixel data.
+   *
+   * @param[in] size The renderer size.
+   *
+   * @return A pixel data with the text rendered.
+   */
+  PixelData Render( const Vector2& size );
+
+private:
+  /**
+   * @brief Private constructor.
+   *
+   * @param[in] model Pointer to the text's data model.
+   */
+  Typesetter( const ModelInterface* const model );
+
+  // Declared private and left undefined to avoid copies.
+  Typesetter( const Typesetter& handle );
+
+  // Declared private and left undefined to avoid copies.
+  Typesetter& operator=( const Typesetter& handle );
+
+protected:
+
+  /**
+   * @brief A reference counted object may only be deleted by calling Unreference().
+   *
+   * Destroys the visual model.
+   */
+  virtual ~Typesetter();
+
+private:
+   ViewModel* mModel;
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_TYPESETTER_H
diff --git a/dali-toolkit/internal/text/rendering/view-model.cpp b/dali-toolkit/internal/text/rendering/view-model.cpp
new file mode 100644 (file)
index 0000000..5636506
--- /dev/null
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/text/rendering/view-model.h>
+
+// EXTERNAL INCLUDES
+#include <memory.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/line-run.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+ViewModel::ViewModel( const ModelInterface* const model )
+: mModel( model ),
+  mElidedGlyphs(),
+  mElidedLayout(),
+  mIsTextElided( false )
+{
+}
+
+ViewModel::~ViewModel()
+{
+}
+
+const Size& ViewModel::GetControlSize() const
+{
+  return mModel->GetControlSize();
+}
+
+const Size& ViewModel::GetLayoutSize() const
+{
+  return mModel->GetLayoutSize();
+}
+
+const Vector2& ViewModel::GetScrollPosition() const
+{
+  return mModel->GetScrollPosition();
+}
+
+Layout::HorizontalAlignment ViewModel::GetHorizontalAlignment() const
+{
+  return mModel->GetHorizontalAlignment();
+}
+
+Layout::VerticalAlignment ViewModel::GetVerticalAlignment() const
+{
+  return mModel->GetVerticalAlignment();
+}
+
+bool ViewModel::IsTextElideEnabled() const
+{
+  return mModel->IsTextElideEnabled();
+}
+
+Length ViewModel::GetNumberOfLines() const
+{
+  return mModel->GetNumberOfLines();
+}
+
+const LineRun* const ViewModel::GetLines() const
+{
+  return mModel->GetLines();
+}
+
+Length ViewModel::GetNumberOfGlyphs() const
+{
+  if( mIsTextElided && mModel->IsTextElideEnabled() )
+  {
+     return mElidedGlyphs.Count();
+  }
+  else
+  {
+    return mModel->GetNumberOfGlyphs();
+  }
+
+  return 0u;
+}
+
+const GlyphInfo* const ViewModel::GetGlyphs() const
+{
+  if( mIsTextElided && mModel->IsTextElideEnabled() )
+  {
+    return mElidedGlyphs.Begin();
+  }
+  else
+  {
+    return mModel->GetGlyphs();
+  }
+
+  return NULL;
+}
+
+const Vector2* const ViewModel::GetLayout() const
+{
+  if( mIsTextElided && mModel->IsTextElideEnabled() )
+  {
+    return mElidedLayout.Begin();
+  }
+  else
+  {
+    return mModel->GetLayout();
+  }
+
+  return NULL;
+}
+
+const Vector4* const ViewModel::GetColors() const
+{
+  return mModel->GetColors();
+}
+
+const ColorIndex* const ViewModel::GetColorIndices() const
+{
+  return mModel->GetColorIndices();
+}
+
+const Vector4& ViewModel::GetDefaultColor() const
+{
+  return mModel->GetDefaultColor();
+}
+
+void ViewModel::ElideGlyphs()
+{
+  mIsTextElided = false;
+
+  if( mModel->IsTextElideEnabled() )
+  {
+    const Length numberOfLines = mModel->GetNumberOfLines();
+    if( 0u != numberOfLines )
+    {
+      const LineRun* const lines = mModel->GetLines();
+
+      const LineRun& lastLine = *( lines + ( numberOfLines - 1u ) );
+      const Length numberOfLaidOutGlyphs = lastLine.glyphRun.glyphIndex + lastLine.glyphRun.numberOfGlyphs;
+
+      if( lastLine.ellipsis && ( 0u != numberOfLaidOutGlyphs ) )
+      {
+        mIsTextElided = true;
+        TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+
+        const GlyphInfo* const glyphs = mModel->GetGlyphs();
+        const Vector2* const positions = mModel->GetLayout();
+
+        // Copy the glyphs to be elided.
+        mElidedGlyphs.Resize( numberOfLaidOutGlyphs );
+        mElidedLayout.Resize( numberOfLaidOutGlyphs );
+
+        GlyphInfo* elidedGlyphsBuffer = mElidedGlyphs.Begin();
+        Vector2* elidedPositionsBuffer = mElidedLayout.Begin();
+
+        memcpy( elidedGlyphsBuffer, glyphs, numberOfLaidOutGlyphs * sizeof( GlyphInfo ) );
+        memcpy( elidedPositionsBuffer, positions, numberOfLaidOutGlyphs * sizeof( Vector2 ) );
+
+        const Size& controlSize = mModel->GetControlSize();
+
+        if( ( 1u == numberOfLines ) &&
+            ( lastLine.ascender - lastLine.descender > controlSize.height ) )
+        {
+          // Get the first glyph which is going to be replaced and the ellipsis glyph.
+          GlyphInfo& glyphToRemove = *elidedGlyphsBuffer;
+          const GlyphInfo& ellipsisGlyph = fontClient.GetEllipsisGlyph( fontClient.GetPointSize( glyphToRemove.fontId ) );
+
+          // Change the 'x' and 'y' position of the ellipsis glyph.
+          Vector2& position = *elidedPositionsBuffer;
+
+          position.x = ellipsisGlyph.xBearing;
+          position.y = -lastLine.ascender + controlSize.height - ellipsisGlyph.yBearing;
+
+          // Replace the glyph by the ellipsis glyph and resize the buffers.
+          glyphToRemove = ellipsisGlyph;
+
+          mElidedGlyphs.Resize( 1u );
+          mElidedLayout.Resize( 1u );
+
+          return;
+        }
+
+        // firstPenX, penY and firstPenSet are used to position the ellipsis glyph if needed.
+        float firstPenX = 0.f; // Used if rtl text is elided.
+        float penY = 0.f;
+        bool firstPenSet = false;
+
+        // Add the ellipsis glyph.
+        bool inserted = false;
+        float removedGlypsWidth = 0.f;
+        Length numberOfRemovedGlyphs = 0u;
+        GlyphIndex index = numberOfLaidOutGlyphs - 1u;
+
+        // The ellipsis glyph has to fit in the place where the last glyph(s) is(are) removed.
+        while( !inserted )
+        {
+          const GlyphInfo& glyphToRemove = *( elidedGlyphsBuffer + index );
+
+          if( 0u != glyphToRemove.fontId )
+          {
+            // i.e. The font id of the glyph shaped from the '\n' character is zero.
+
+            // Need to reshape the glyph as the font may be different in size.
+            const GlyphInfo& ellipsisGlyph = fontClient.GetEllipsisGlyph( fontClient.GetPointSize( glyphToRemove.fontId ) );
+
+            if( !firstPenSet )
+            {
+              const Vector2& position = *( elidedPositionsBuffer + index );
+
+              // Calculates the penY of the current line. It will be used to position the ellipsis glyph.
+              penY = position.y + glyphToRemove.yBearing;
+
+              // Calculates the first penX which will be used if rtl text is elided.
+              firstPenX = position.x - glyphToRemove.xBearing;
+              if( firstPenX < -ellipsisGlyph.xBearing )
+              {
+                // Avoids to exceed the bounding box when rtl text is elided.
+                firstPenX = -ellipsisGlyph.xBearing;
+              }
+
+              removedGlypsWidth = -ellipsisGlyph.xBearing;
+
+              firstPenSet = true;
+            }
+
+            removedGlypsWidth += std::min( glyphToRemove.advance, ( glyphToRemove.xBearing + glyphToRemove.width ) );
+
+            // Calculate the width of the ellipsis glyph and check if it fits.
+            const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing;
+
+            if( ellipsisGlyphWidth < removedGlypsWidth )
+            {
+              GlyphInfo& glyphInfo = *( elidedGlyphsBuffer + index );
+              Vector2& position = *( elidedPositionsBuffer + index );
+              position.x -= ( 0.f > glyphInfo.xBearing ) ? glyphInfo.xBearing : 0.f;
+
+              // Replace the glyph by the ellipsis glyph.
+              glyphInfo = ellipsisGlyph;
+
+              // Change the 'x' and 'y' position of the ellipsis glyph.
+
+              if( position.x > firstPenX )
+              {
+                position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+              }
+
+              position.x += ellipsisGlyph.xBearing;
+              position.y = penY - ellipsisGlyph.yBearing;
+
+              inserted = true;
+            }
+          }
+
+          if( !inserted )
+          {
+            if( index > 0u )
+            {
+              --index;
+            }
+            else
+            {
+              // No space for the ellipsis.
+              inserted = true;
+            }
+            ++numberOfRemovedGlyphs;
+          }
+        } // while( !inserted )
+
+          // 'Removes' all the glyphs after the ellipsis glyph.
+        const Length numberOfGlyphs = numberOfLaidOutGlyphs - numberOfRemovedGlyphs;
+        mElidedGlyphs.Resize( numberOfGlyphs );
+        mElidedLayout.Resize( numberOfGlyphs );
+      }
+    }
+  }
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/text/rendering/view-model.h b/dali-toolkit/internal/text/rendering/view-model.h
new file mode 100644 (file)
index 0000000..8038820
--- /dev/null
@@ -0,0 +1,152 @@
+#ifndef DALI_TOOLKIT_TEXT_VIEW_MODEL_H
+#define DALI_TOOLKIT_TEXT_VIEW_MODEL_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-vector.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/text-model-interface.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+/**
+ * @brief Responsible of creating and store temporary modifications of the text model.
+ * i.e. The elide of text.
+ */
+class ViewModel : public ModelInterface
+{
+public:
+  /**
+   * @brief Constructor.
+   *
+   * Keeps the pointer to the text's model. It initializes all the members of the class to their defaults.
+   *
+   * @param[in] model Pointer to the text's model interface.
+   */
+  ViewModel( const ModelInterface* const model );
+
+  /**
+   * @brief Virtual destructor.
+   *
+   * It's a default destructor.
+   */
+  virtual ~ViewModel();
+
+  /**
+   * @copydoc ModelInterface::GetControlSize()
+   */
+  virtual const Size& GetControlSize() const;
+
+  /**
+   * @copydoc ModelInterface::GetLayoutSize()
+   */
+  virtual const Size& GetLayoutSize() const;
+
+  /**
+   * @copydoc ModelInterface::GetScrollPosition()
+   */
+  virtual const Vector2& GetScrollPosition() const;
+
+  /**
+   * @copydoc ModelInterface::GetHorizontalAlignment()
+   */
+  virtual Layout::HorizontalAlignment GetHorizontalAlignment() const;
+
+  /**
+   * @copydoc ModelInterface::GetVerticalAlignment()
+   */
+  virtual Layout::VerticalAlignment GetVerticalAlignment() const;
+
+  /**
+   * @copydoc ModelInterface::IsTextElideEnabled()
+   */
+  virtual bool IsTextElideEnabled() const;
+
+  /**
+   * @copydoc ModelInterface::GetNumberOfLines()
+   */
+  virtual Length GetNumberOfLines() const;
+
+  /**
+   * @copydoc ModelInterface::GetLines()
+   */
+  virtual const LineRun* const GetLines() const;
+
+  /**
+   * @copydoc ModelInterface::GetNumberOfGlyphs()
+   */
+  virtual Length GetNumberOfGlyphs() const;
+
+  /**
+   * @copydoc ModelInterface::GetGlyphs()
+   */
+  virtual const GlyphInfo* const GetGlyphs() const;
+
+  /**
+   * @copydoc ModelInterface::GetLayout()
+   */
+  virtual const Vector2* const GetLayout() const;
+
+  /**
+   * @copydoc ModelInterface::GetColors()
+   */
+  virtual const Vector4* const GetColors() const;
+
+  /**
+   * @copydoc ModelInterface::GetColorIndices()
+   */
+  virtual const ColorIndex* const GetColorIndices() const;
+
+  /**
+   * @copydoc ModelInterface::GetDefaultColor()
+   */
+  virtual const Vector4& GetDefaultColor() const;
+
+  /**
+   * @brief Does the text elide.
+   *
+   * It stores a copy of the visible glyphs and removes as many glyphs as needed
+   * from the last visible line to add the ellipsis glyph.
+   *
+   * It stores as well a copy of the positions for each visible glyph.
+   */
+  void ElideGlyphs();
+
+private:
+  const ModelInterface* const mModel;            ///< Pointer to the text's model.
+  Vector<GlyphInfo>           mElidedGlyphs;     ///< Stores the glyphs of the elided text.
+  Vector<Vector2>             mElidedLayout;     ///< Stores the positions of each glyph of the elided text.
+  bool                        mIsTextElided : 1; ///< Whether the text has been elided.
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H
index 1c5044a..85f48ec 100644 (file)
@@ -277,7 +277,7 @@ bool Controller::Impl::ProcessInputEvents()
     const CharacterIndex styleIndex = ( mEventData->mPrimaryCursorPosition > 0u ) ? mEventData->mPrimaryCursorPosition - 1u : 0u;
 
     // Retrieve the style from the style runs stored in the logical model.
-    mLogicalModel->RetrieveStyle( styleIndex, mEventData->mInputStyle );
+    mModel->mLogicalModel->RetrieveStyle( styleIndex, mEventData->mInputStyle );
 
     // Compare if the input style has changed.
     const bool hasInputStyleChanged = !currentInputStyle.Equal( mEventData->mInputStyle );
@@ -329,8 +329,8 @@ void Controller::Impl::NotifyImfMultiLineStatus()
 {
   if ( mEventData )
   {
-    LayoutEngine::Layout layout = mLayoutEngine.GetLayout();
-    mEventData->mImfManager.NotifyTextInputMultiLine( layout == LayoutEngine::MULTI_LINE_BOX );
+    Text::Layout::Engine::Type layout = mLayoutEngine.GetLayout();
+    mEventData->mImfManager.NotifyTextInputMultiLine( layout == Text::Layout::Engine::MULTI_LINE_BOX );
   }
 }
 
@@ -359,9 +359,9 @@ Length Controller::Impl::GetNumberOfWhiteSpaces( CharacterIndex index ) const
   Length numberOfWhiteSpaces = 0u;
 
   // Get the buffer to the text.
-  Character* utf32CharacterBuffer = mLogicalModel->mText.Begin();
+  Character* utf32CharacterBuffer = mModel->mLogicalModel->mText.Begin();
 
-  const Length totalNumberOfCharacters = mLogicalModel->mText.Count();
+  const Length totalNumberOfCharacters = mModel->mLogicalModel->mText.Count();
   for( ; index < totalNumberOfCharacters; ++index, ++numberOfWhiteSpaces )
   {
     if( !TextAbstraction::IsWhiteSpace( *( utf32CharacterBuffer + index ) ) )
@@ -376,12 +376,12 @@ Length Controller::Impl::GetNumberOfWhiteSpaces( CharacterIndex index ) const
 void Controller::Impl::GetText( CharacterIndex index, std::string& text ) const
 {
   // Get the total number of characters.
-  Length numberOfCharacters = mLogicalModel->mText.Count();
+  Length numberOfCharacters = mModel->mLogicalModel->mText.Count();
 
   // Retrieve the text.
   if( 0u != numberOfCharacters )
   {
-    Utf32ToUtf8( mLogicalModel->mText.Begin() + index, numberOfCharacters - index, text );
+    Utf32ToUtf8( mModel->mLogicalModel->mText.Begin() + index, numberOfCharacters - index, text );
   }
 }
 
@@ -392,7 +392,7 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters )
   mTextUpdateInfo.mStartLineIndex = 0u;
   numberOfCharacters = 0u;
 
-  const Length numberOfParagraphs = mLogicalModel->mParagraphInfo.Count();
+  const Length numberOfParagraphs = mModel->mLogicalModel->mParagraphInfo.Count();
   if( 0u == numberOfParagraphs )
   {
     mTextUpdateInfo.mParagraphCharacterIndex = 0u;
@@ -416,8 +416,8 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters )
       numberOfCharacters = 0u;
       mTextUpdateInfo.mRequestedNumberOfCharacters = mTextUpdateInfo.mNumberOfCharactersToAdd - mTextUpdateInfo.mNumberOfCharactersToRemove;
 
-      mTextUpdateInfo.mStartGlyphIndex = mVisualModel->mGlyphs.Count();
-      mTextUpdateInfo.mStartLineIndex = mVisualModel->mLines.Count() - 1u;
+      mTextUpdateInfo.mStartGlyphIndex = mModel->mVisualModel->mGlyphs.Count();
+      mTextUpdateInfo.mStartLineIndex = mModel->mVisualModel->mLines.Count() - 1u;
 
       // Nothing else to do;
       return;
@@ -436,19 +436,19 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters )
     {
       numberOfCharactersToUpdate = ( mTextUpdateInfo.mNumberOfCharactersToRemove > 0u ) ? mTextUpdateInfo.mNumberOfCharactersToRemove : 1u;
     }
-    mLogicalModel->FindParagraphs( mTextUpdateInfo.mCharacterIndex,
-                                   numberOfCharactersToUpdate,
-                                   paragraphsToBeUpdated );
+    mModel->mLogicalModel->FindParagraphs( mTextUpdateInfo.mCharacterIndex,
+                                           numberOfCharactersToUpdate,
+                                           paragraphsToBeUpdated );
   }
 
   if( 0u != paragraphsToBeUpdated.Count() )
   {
     const ParagraphRunIndex firstParagraphIndex = *( paragraphsToBeUpdated.Begin() );
-    const ParagraphRun& firstParagraph = *( mLogicalModel->mParagraphInfo.Begin() + firstParagraphIndex );
+    const ParagraphRun& firstParagraph = *( mModel->mLogicalModel->mParagraphInfo.Begin() + firstParagraphIndex );
     mTextUpdateInfo.mParagraphCharacterIndex = firstParagraph.characterRun.characterIndex;
 
     ParagraphRunIndex lastParagraphIndex = *( paragraphsToBeUpdated.End() - 1u );
-    const ParagraphRun& lastParagraph = *( mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex );
+    const ParagraphRun& lastParagraph = *( mModel->mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex );
 
     if( ( mTextUpdateInfo.mNumberOfCharactersToRemove > 0u ) &&                                            // Some character are removed.
         ( lastParagraphIndex < numberOfParagraphs - 1u ) &&                                                // There is a next paragraph.
@@ -456,7 +456,7 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters )
           ( mTextUpdateInfo.mCharacterIndex + mTextUpdateInfo.mNumberOfCharactersToRemove ) ) )
     {
       // The new paragraph character of the last updated paragraph has been removed so is going to be merged with the next one.
-      const ParagraphRun& lastParagraph = *( mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex + 1u );
+      const ParagraphRun& lastParagraph = *( mModel->mLogicalModel->mParagraphInfo.Begin() + lastParagraphIndex + 1u );
 
       numberOfCharacters = lastParagraph.characterRun.characterIndex + lastParagraph.characterRun.numberOfCharacters - mTextUpdateInfo.mParagraphCharacterIndex;
     }
@@ -467,45 +467,45 @@ void Controller::Impl::CalculateTextUpdateIndices( Length& numberOfCharacters )
   }
 
   mTextUpdateInfo.mRequestedNumberOfCharacters = numberOfCharacters + mTextUpdateInfo.mNumberOfCharactersToAdd - mTextUpdateInfo.mNumberOfCharactersToRemove;
-  mTextUpdateInfo.mStartGlyphIndex = *( mVisualModel->mCharactersToGlyph.Begin() + mTextUpdateInfo.mParagraphCharacterIndex );
+  mTextUpdateInfo.mStartGlyphIndex = *( mModel->mVisualModel->mCharactersToGlyph.Begin() + mTextUpdateInfo.mParagraphCharacterIndex );
 }
 
 void Controller::Impl::ClearFullModelData( OperationsMask operations )
 {
   if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) )
   {
-    mLogicalModel->mLineBreakInfo.Clear();
-    mLogicalModel->mParagraphInfo.Clear();
+    mModel->mLogicalModel->mLineBreakInfo.Clear();
+    mModel->mLogicalModel->mParagraphInfo.Clear();
   }
 
   if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) )
   {
-    mLogicalModel->mLineBreakInfo.Clear();
+    mModel->mLogicalModel->mLineBreakInfo.Clear();
   }
 
   if( NO_OPERATION != ( GET_SCRIPTS & operations ) )
   {
-    mLogicalModel->mScriptRuns.Clear();
+    mModel->mLogicalModel->mScriptRuns.Clear();
   }
 
   if( NO_OPERATION != ( VALIDATE_FONTS & operations ) )
   {
-    mLogicalModel->mFontRuns.Clear();
+    mModel->mLogicalModel->mFontRuns.Clear();
   }
 
-  if( 0u != mLogicalModel->mBidirectionalParagraphInfo.Count() )
+  if( 0u != mModel->mLogicalModel->mBidirectionalParagraphInfo.Count() )
   {
     if( NO_OPERATION != ( BIDI_INFO & operations ) )
     {
-      mLogicalModel->mBidirectionalParagraphInfo.Clear();
-      mLogicalModel->mCharacterDirections.Clear();
+      mModel->mLogicalModel->mBidirectionalParagraphInfo.Clear();
+      mModel->mLogicalModel->mCharacterDirections.Clear();
     }
 
     if( NO_OPERATION != ( REORDER & operations ) )
     {
       // Free the allocated memory used to store the conversion table in the bidirectional line info run.
-      for( Vector<BidirectionalLineInfoRun>::Iterator it = mLogicalModel->mBidirectionalLineInfo.Begin(),
-             endIt = mLogicalModel->mBidirectionalLineInfo.End();
+      for( Vector<BidirectionalLineInfoRun>::Iterator it = mModel->mLogicalModel->mBidirectionalLineInfo.Begin(),
+             endIt = mModel->mLogicalModel->mBidirectionalLineInfo.End();
            it != endIt;
            ++it )
       {
@@ -514,28 +514,28 @@ void Controller::Impl::ClearFullModelData( OperationsMask operations )
         free( bidiLineInfo.visualToLogicalMap );
         bidiLineInfo.visualToLogicalMap = NULL;
       }
-      mLogicalModel->mBidirectionalLineInfo.Clear();
+      mModel->mLogicalModel->mBidirectionalLineInfo.Clear();
     }
   }
 
   if( NO_OPERATION != ( SHAPE_TEXT & operations ) )
   {
-    mVisualModel->mGlyphs.Clear();
-    mVisualModel->mGlyphsToCharacters.Clear();
-    mVisualModel->mCharactersToGlyph.Clear();
-    mVisualModel->mCharactersPerGlyph.Clear();
-    mVisualModel->mGlyphsPerCharacter.Clear();
-    mVisualModel->mGlyphPositions.Clear();
+    mModel->mVisualModel->mGlyphs.Clear();
+    mModel->mVisualModel->mGlyphsToCharacters.Clear();
+    mModel->mVisualModel->mCharactersToGlyph.Clear();
+    mModel->mVisualModel->mCharactersPerGlyph.Clear();
+    mModel->mVisualModel->mGlyphsPerCharacter.Clear();
+    mModel->mVisualModel->mGlyphPositions.Clear();
   }
 
   if( NO_OPERATION != ( LAYOUT & operations ) )
   {
-    mVisualModel->mLines.Clear();
+    mModel->mVisualModel->mLines.Clear();
   }
 
   if( NO_OPERATION != ( COLOR & operations ) )
   {
-    mVisualModel->mColorIndices.Clear();
+    mModel->mVisualModel->mColorIndices.Clear();
   }
 }
 
@@ -546,23 +546,23 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara
   if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) )
   {
     // Clear the line break info.
-    LineBreakInfo* lineBreakInfoBuffer = mLogicalModel->mLineBreakInfo.Begin();
+    LineBreakInfo* lineBreakInfoBuffer = mModel->mLogicalModel->mLineBreakInfo.Begin();
 
-    mLogicalModel->mLineBreakInfo.Erase( lineBreakInfoBuffer + startIndex,
-                                         lineBreakInfoBuffer + endIndexPlusOne );
+    mModel->mLogicalModel->mLineBreakInfo.Erase( lineBreakInfoBuffer + startIndex,
+                                                 lineBreakInfoBuffer + endIndexPlusOne );
 
     // Clear the paragraphs.
     ClearCharacterRuns( startIndex,
                         endIndex,
-                        mLogicalModel->mParagraphInfo );
+                        mModel->mLogicalModel->mParagraphInfo );
   }
 
   if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) )
   {
     // Clear the word break info.
-    WordBreakInfo* wordBreakInfoBuffer = mLogicalModel->mWordBreakInfo.Begin();
+    WordBreakInfo* wordBreakInfoBuffer = mModel->mLogicalModel->mWordBreakInfo.Begin();
 
-    mLogicalModel->mWordBreakInfo.Erase( wordBreakInfoBuffer + startIndex,
+    mModel->mLogicalModel->mWordBreakInfo.Erase( wordBreakInfoBuffer + startIndex,
                                          wordBreakInfoBuffer + endIndexPlusOne );
   }
 
@@ -571,7 +571,7 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara
     // Clear the scripts.
     ClearCharacterRuns( startIndex,
                         endIndex,
-                        mLogicalModel->mScriptRuns );
+                        mModel->mLogicalModel->mScriptRuns );
   }
 
   if( NO_OPERATION != ( VALIDATE_FONTS & operations ) )
@@ -579,36 +579,36 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara
     // Clear the fonts.
     ClearCharacterRuns( startIndex,
                         endIndex,
-                        mLogicalModel->mFontRuns );
+                        mModel->mLogicalModel->mFontRuns );
   }
 
-  if( 0u != mLogicalModel->mBidirectionalParagraphInfo.Count() )
+  if( 0u != mModel->mLogicalModel->mBidirectionalParagraphInfo.Count() )
   {
     if( NO_OPERATION != ( BIDI_INFO & operations ) )
     {
       // Clear the bidirectional paragraph info.
       ClearCharacterRuns( startIndex,
                           endIndex,
-                          mLogicalModel->mBidirectionalParagraphInfo );
+                          mModel->mLogicalModel->mBidirectionalParagraphInfo );
 
       // Clear the character's directions.
-      CharacterDirection* characterDirectionsBuffer = mLogicalModel->mCharacterDirections.Begin();
+      CharacterDirection* characterDirectionsBuffer = mModel->mLogicalModel->mCharacterDirections.Begin();
 
-      mLogicalModel->mCharacterDirections.Erase( characterDirectionsBuffer + startIndex,
-                                                 characterDirectionsBuffer + endIndexPlusOne );
+      mModel->mLogicalModel->mCharacterDirections.Erase( characterDirectionsBuffer + startIndex,
+                                                         characterDirectionsBuffer + endIndexPlusOne );
     }
 
     if( NO_OPERATION != ( REORDER & operations ) )
     {
-      uint32_t startRemoveIndex = mLogicalModel->mBidirectionalLineInfo.Count();
+      uint32_t startRemoveIndex = mModel->mLogicalModel->mBidirectionalLineInfo.Count();
       uint32_t endRemoveIndex = startRemoveIndex;
       ClearCharacterRuns( startIndex,
                           endIndex,
-                          mLogicalModel->mBidirectionalLineInfo,
+                          mModel->mLogicalModel->mBidirectionalLineInfo,
                           startRemoveIndex,
                           endRemoveIndex );
 
-      BidirectionalLineInfoRun* bidirectionalLineInfoBuffer = mLogicalModel->mBidirectionalLineInfo.Begin();
+      BidirectionalLineInfoRun* bidirectionalLineInfoBuffer = mModel->mLogicalModel->mBidirectionalLineInfo.Begin();
 
       // Free the allocated memory used to store the conversion table in the bidirectional line info run.
       for( Vector<BidirectionalLineInfoRun>::Iterator it = bidirectionalLineInfoBuffer + startRemoveIndex,
@@ -622,8 +622,8 @@ void Controller::Impl::ClearCharacterModelData( CharacterIndex startIndex, Chara
         bidiLineInfo.visualToLogicalMap = NULL;
       }
 
-      mLogicalModel->mBidirectionalLineInfo.Erase( bidirectionalLineInfoBuffer + startRemoveIndex,
-                                                   bidirectionalLineInfoBuffer + endRemoveIndex );
+      mModel->mLogicalModel->mBidirectionalLineInfo.Erase( bidirectionalLineInfoBuffer + startRemoveIndex,
+                                                           bidirectionalLineInfoBuffer + endRemoveIndex );
     }
   }
 }
@@ -634,8 +634,8 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character
   const Length numberOfCharactersRemoved = endIndexPlusOne - startIndex;
 
   // Convert the character index to glyph index before deleting the character to glyph and the glyphs per character buffers.
-  GlyphIndex* charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
-  Length* glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
+  GlyphIndex* charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin();
+  Length* glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin();
 
   const GlyphIndex endGlyphIndexPlusOne = *( charactersToGlyphBuffer + endIndex ) + *( glyphsPerCharacterBuffer + endIndex );
   const Length numberOfGlyphsRemoved = endGlyphIndexPlusOne - mTextUpdateInfo.mStartGlyphIndex;
@@ -644,7 +644,7 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character
   {
     // Update the character to glyph indices.
     for( Vector<GlyphIndex>::Iterator it =  charactersToGlyphBuffer + endIndexPlusOne,
-           endIt =  charactersToGlyphBuffer + mVisualModel->mCharactersToGlyph.Count();
+           endIt =  charactersToGlyphBuffer + mModel->mVisualModel->mCharactersToGlyph.Count();
          it != endIt;
          ++it )
     {
@@ -653,23 +653,23 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character
     }
 
     // Clear the character to glyph conversion table.
-    mVisualModel->mCharactersToGlyph.Erase( charactersToGlyphBuffer + startIndex,
-                                            charactersToGlyphBuffer + endIndexPlusOne );
+    mModel->mVisualModel->mCharactersToGlyph.Erase( charactersToGlyphBuffer + startIndex,
+                                                    charactersToGlyphBuffer + endIndexPlusOne );
 
     // Clear the glyphs per character table.
-    mVisualModel->mGlyphsPerCharacter.Erase( glyphsPerCharacterBuffer + startIndex,
-                                             glyphsPerCharacterBuffer + endIndexPlusOne );
+    mModel->mVisualModel->mGlyphsPerCharacter.Erase( glyphsPerCharacterBuffer + startIndex,
+                                                     glyphsPerCharacterBuffer + endIndexPlusOne );
 
     // Clear the glyphs buffer.
-    GlyphInfo* glyphsBuffer = mVisualModel->mGlyphs.Begin();
-    mVisualModel->mGlyphs.Erase( glyphsBuffer + mTextUpdateInfo.mStartGlyphIndex,
-                                 glyphsBuffer + endGlyphIndexPlusOne );
+    GlyphInfo* glyphsBuffer = mModel->mVisualModel->mGlyphs.Begin();
+    mModel->mVisualModel->mGlyphs.Erase( glyphsBuffer + mTextUpdateInfo.mStartGlyphIndex,
+                                         glyphsBuffer + endGlyphIndexPlusOne );
 
-    CharacterIndex* glyphsToCharactersBuffer = mVisualModel->mGlyphsToCharacters.Begin();
+    CharacterIndex* glyphsToCharactersBuffer = mModel->mVisualModel->mGlyphsToCharacters.Begin();
 
     // Update the glyph to character indices.
     for( Vector<CharacterIndex>::Iterator it = glyphsToCharactersBuffer + endGlyphIndexPlusOne,
-           endIt = glyphsToCharactersBuffer + mVisualModel->mGlyphsToCharacters.Count();
+           endIt = glyphsToCharactersBuffer + mModel->mVisualModel->mGlyphsToCharacters.Count();
          it != endIt;
          ++it )
     {
@@ -678,55 +678,55 @@ void Controller::Impl::ClearGlyphModelData( CharacterIndex startIndex, Character
     }
 
     // Clear the glyphs to characters buffer.
-    mVisualModel->mGlyphsToCharacters.Erase( glyphsToCharactersBuffer + mTextUpdateInfo.mStartGlyphIndex,
-                                             glyphsToCharactersBuffer  + endGlyphIndexPlusOne );
+    mModel->mVisualModel->mGlyphsToCharacters.Erase( glyphsToCharactersBuffer + mTextUpdateInfo.mStartGlyphIndex,
+                                                     glyphsToCharactersBuffer  + endGlyphIndexPlusOne );
 
     // Clear the characters per glyph buffer.
-    Length* charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
-    mVisualModel->mCharactersPerGlyph.Erase( charactersPerGlyphBuffer + mTextUpdateInfo.mStartGlyphIndex,
-                                             charactersPerGlyphBuffer + endGlyphIndexPlusOne );
+    Length* charactersPerGlyphBuffer = mModel->mVisualModel->mCharactersPerGlyph.Begin();
+    mModel->mVisualModel->mCharactersPerGlyph.Erase( charactersPerGlyphBuffer + mTextUpdateInfo.mStartGlyphIndex,
+                                                     charactersPerGlyphBuffer + endGlyphIndexPlusOne );
 
     // Clear the positions buffer.
-    Vector2* positionsBuffer = mVisualModel->mGlyphPositions.Begin();
-    mVisualModel->mGlyphPositions.Erase( positionsBuffer + mTextUpdateInfo.mStartGlyphIndex,
-                                         positionsBuffer + endGlyphIndexPlusOne );
+    Vector2* positionsBuffer = mModel->mVisualModel->mGlyphPositions.Begin();
+    mModel->mVisualModel->mGlyphPositions.Erase( positionsBuffer + mTextUpdateInfo.mStartGlyphIndex,
+                                                 positionsBuffer + endGlyphIndexPlusOne );
   }
 
   if( NO_OPERATION != ( LAYOUT & operations ) )
   {
     // Clear the lines.
-    uint32_t startRemoveIndex = mVisualModel->mLines.Count();
+    uint32_t startRemoveIndex = mModel->mVisualModel->mLines.Count();
     uint32_t endRemoveIndex = startRemoveIndex;
     ClearCharacterRuns( startIndex,
                         endIndex,
-                        mVisualModel->mLines,
+                        mModel->mVisualModel->mLines,
                         startRemoveIndex,
                         endRemoveIndex );
 
     // Will update the glyph runs.
-    startRemoveIndex = mVisualModel->mLines.Count();
+    startRemoveIndex = mModel->mVisualModel->mLines.Count();
     endRemoveIndex = startRemoveIndex;
     ClearGlyphRuns( mTextUpdateInfo.mStartGlyphIndex,
                     endGlyphIndexPlusOne - 1u,
-                    mVisualModel->mLines,
+                    mModel->mVisualModel->mLines,
                     startRemoveIndex,
                     endRemoveIndex );
 
     // Set the line index from where to insert the new laid-out lines.
     mTextUpdateInfo.mStartLineIndex = startRemoveIndex;
 
-    LineRun* linesBuffer = mVisualModel->mLines.Begin();
-    mVisualModel->mLines.Erase( linesBuffer + startRemoveIndex,
-                                linesBuffer + endRemoveIndex );
+    LineRun* linesBuffer = mModel->mVisualModel->mLines.Begin();
+    mModel->mVisualModel->mLines.Erase( linesBuffer + startRemoveIndex,
+                                        linesBuffer + endRemoveIndex );
   }
 
   if( NO_OPERATION != ( COLOR & operations ) )
   {
-    if( 0u != mVisualModel->mColorIndices.Count() )
+    if( 0u != mModel->mVisualModel->mColorIndices.Count() )
     {
-      ColorIndex* colorIndexBuffer = mVisualModel->mColorIndices.Begin();
-      mVisualModel->mColorIndices.Erase( colorIndexBuffer + mTextUpdateInfo.mStartGlyphIndex,
-                                         colorIndexBuffer + endGlyphIndexPlusOne );
+      ColorIndex* colorIndexBuffer = mModel->mVisualModel->mColorIndices.Begin();
+      mModel->mVisualModel->mColorIndices.Erase( colorIndexBuffer + mTextUpdateInfo.mStartGlyphIndex,
+                                                 colorIndexBuffer + endGlyphIndexPlusOne );
     }
   }
 }
@@ -749,9 +749,9 @@ void Controller::Impl::ClearModelData( CharacterIndex startIndex, CharacterIndex
   }
 
   // The estimated number of lines. Used to avoid reallocations when layouting.
-  mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mVisualModel->mLines.Count(), mLogicalModel->mParagraphInfo.Count() );
+  mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mModel->mVisualModel->mLines.Count(), mModel->mLogicalModel->mParagraphInfo.Count() );
 
-  mVisualModel->ClearCaches();
+  mModel->mVisualModel->ClearCaches();
 }
 
 bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
@@ -767,7 +767,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
     return false;
   }
 
-  Vector<Character>& utf32Characters = mLogicalModel->mText;
+  Vector<Character>& utf32Characters = mModel->mLogicalModel->mText;
 
   const Length numberOfCharacters = utf32Characters.Count();
 
@@ -790,7 +790,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
   // Whether the model is updated.
   bool updated = false;
 
-  Vector<LineBreakInfo>& lineBreakInfo = mLogicalModel->mLineBreakInfo;
+  Vector<LineBreakInfo>& lineBreakInfo = mModel->mLogicalModel->mLineBreakInfo;
   const Length requestedNumberOfCharacters = mTextUpdateInfo.mRequestedNumberOfCharacters;
 
   if( NO_OPERATION != ( GET_LINE_BREAKS & operations ) )
@@ -807,12 +807,12 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
                       lineBreakInfo );
 
     // Create the paragraph info.
-    mLogicalModel->CreateParagraphInfo( startIndex,
-                                        requestedNumberOfCharacters );
+    mModel->mLogicalModel->CreateParagraphInfo( startIndex,
+                                                requestedNumberOfCharacters );
     updated = true;
   }
 
-  Vector<WordBreakInfo>& wordBreakInfo = mLogicalModel->mWordBreakInfo;
+  Vector<WordBreakInfo>& wordBreakInfo = mModel->mLogicalModel->mWordBreakInfo;
   if( NO_OPERATION != ( GET_WORD_BREAKS & operations ) )
   {
     // Retrieves the word break info. The word break info is used to layout the text (where to wrap the text in lines).
@@ -828,8 +828,8 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
   const bool getScripts = NO_OPERATION != ( GET_SCRIPTS & operations );
   const bool validateFonts = NO_OPERATION != ( VALIDATE_FONTS & operations );
 
-  Vector<ScriptRun>& scripts = mLogicalModel->mScriptRuns;
-  Vector<FontRun>& validFonts = mLogicalModel->mFontRuns;
+  Vector<ScriptRun>& scripts = mModel->mLogicalModel->mScriptRuns;
+  Vector<FontRun>& validFonts = mModel->mLogicalModel->mFontRuns;
 
   if( getScripts || validateFonts )
   {
@@ -849,7 +849,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
     if( validateFonts )
     {
       // Validate the fonts set through the mark-up string.
-      Vector<FontDescriptionRun>& fontDescriptionRuns = mLogicalModel->mFontDescriptionRuns;
+      Vector<FontDescriptionRun>& fontDescriptionRuns = mModel->mLogicalModel->mFontDescriptionRuns;
 
       // Get the default font's description.
       TextAbstraction::FontDescription defaultFontDescription;
@@ -876,10 +876,10 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
 
   Vector<Character> mirroredUtf32Characters;
   bool textMirrored = false;
-  const Length numberOfParagraphs = mLogicalModel->mParagraphInfo.Count();
+  const Length numberOfParagraphs = mModel->mLogicalModel->mParagraphInfo.Count();
   if( NO_OPERATION != ( BIDI_INFO & operations ) )
   {
-    Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mLogicalModel->mBidirectionalParagraphInfo;
+    Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mModel->mLogicalModel->mBidirectionalParagraphInfo;
     bidirectionalInfo.Reserve( numberOfParagraphs );
 
     // Calculates the bidirectional info for the whole paragraph if it contains right to left scripts.
@@ -893,7 +893,7 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
     if( 0u != bidirectionalInfo.Count() )
     {
       // Only set the character directions if there is right to left characters.
-      Vector<CharacterDirection>& directions = mLogicalModel->mCharacterDirections;
+      Vector<CharacterDirection>& directions = mModel->mLogicalModel->mCharacterDirections;
       GetCharactersDirection( bidirectionalInfo,
                               numberOfCharacters,
                               startIndex,
@@ -913,14 +913,14 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
     else
     {
       // There is no right to left characters. Clear the directions vector.
-      mLogicalModel->mCharacterDirections.Clear();
+      mModel->mLogicalModel->mCharacterDirections.Clear();
     }
     updated = true;
   }
 
-  Vector<GlyphInfo>& glyphs = mVisualModel->mGlyphs;
-  Vector<CharacterIndex>& glyphsToCharactersMap = mVisualModel->mGlyphsToCharacters;
-  Vector<Length>& charactersPerGlyph = mVisualModel->mCharactersPerGlyph;
+  Vector<GlyphInfo>& glyphs = mModel->mVisualModel->mGlyphs;
+  Vector<CharacterIndex>& glyphsToCharactersMap = mModel->mVisualModel->mGlyphsToCharacters;
+  Vector<Length>& charactersPerGlyph = mModel->mVisualModel->mCharactersPerGlyph;
   Vector<GlyphIndex> newParagraphGlyphs;
   newParagraphGlyphs.Reserve( numberOfParagraphs );
 
@@ -942,8 +942,8 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
                newParagraphGlyphs );
 
     // Create the 'number of glyphs' per character and the glyph to character conversion tables.
-    mVisualModel->CreateGlyphsPerCharacterTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters );
-    mVisualModel->CreateCharacterToGlyphTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters );
+    mModel->mVisualModel->CreateGlyphsPerCharacterTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters );
+    mModel->mVisualModel->CreateCharacterToGlyphTable( startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters );
     updated = true;
   }
 
@@ -970,25 +970,25 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
   if( NO_OPERATION != ( COLOR & operations ) )
   {
     // Set the color runs in glyphs.
-    SetColorSegmentationInfo( mLogicalModel->mColorRuns,
-                              mVisualModel->mCharactersToGlyph,
-                              mVisualModel->mGlyphsPerCharacter,
+    SetColorSegmentationInfo( mModel->mLogicalModel->mColorRuns,
+                              mModel->mVisualModel->mCharactersToGlyph,
+                              mModel->mVisualModel->mGlyphsPerCharacter,
                               startIndex,
                               mTextUpdateInfo.mStartGlyphIndex,
                               requestedNumberOfCharacters,
-                              mVisualModel->mColors,
-                              mVisualModel->mColorIndices );
+                              mModel->mVisualModel->mColors,
+                              mModel->mVisualModel->mColorIndices );
 
     updated = true;
   }
 
   if( ( NULL != mEventData ) &&
       mEventData->mPreEditFlag &&
-      ( 0u != mVisualModel->mCharactersToGlyph.Count() ) )
+      ( 0u != mModel->mVisualModel->mCharactersToGlyph.Count() ) )
   {
     // Add the underline for the pre-edit text.
-    const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
-    const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
+    const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin();
+    const Length* const glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin();
 
     const GlyphIndex glyphStart = *( charactersToGlyphBuffer + mEventData->mPreEditStartPosition );
     const CharacterIndex lastPreEditCharacter = mEventData->mPreEditStartPosition + ( ( mEventData->mPreEditLength > 0u ) ? mEventData->mPreEditLength - 1u : 0u );
@@ -1000,11 +1000,11 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
     underlineRun.numberOfGlyphs = 1u + glyphEnd - glyphStart;
 
     // TODO: At the moment the underline runs are only for pre-edit.
-    mVisualModel->mUnderlineRuns.PushBack( underlineRun );
+    mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
   }
 
   // The estimated number of lines. Used to avoid reallocations when layouting.
-  mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mVisualModel->mLines.Count(), mLogicalModel->mParagraphInfo.Count() );
+  mTextUpdateInfo.mEstimatedNumberOfLines = std::max( mModel->mVisualModel->mLines.Count(), mModel->mLogicalModel->mParagraphInfo.Count() );
 
   // Set the previous number of characters for the next time the text is updated.
   mTextUpdateInfo.mPreviousNumberOfCharacters = numberOfCharacters;
@@ -1117,7 +1117,7 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event )
   }
   else if( Dali::DALI_KEY_CURSOR_RIGHT == keyCode )
   {
-    if( mLogicalModel->mText.Count() > mEventData->mPrimaryCursorPosition )
+    if( mModel->mLogicalModel->mText.Count() > mEventData->mPrimaryCursorPosition )
     {
       mEventData->mPrimaryCursorPosition = CalculateNewCursorIndex( mEventData->mPrimaryCursorPosition );
     }
@@ -1132,7 +1132,7 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event )
       characterIndex = mEventData->mPrimaryCursorPosition - 1u;
     }
 
-    const LineIndex lineIndex = mVisualModel->GetLineOfCharacter( characterIndex );
+    const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( characterIndex );
 
     if( lineIndex > 0u )
     {
@@ -1142,14 +1142,14 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event )
                          cursorInfo );
 
       // Get the line above.
-      const LineRun& line = *( mVisualModel->mLines.Begin() + ( lineIndex - 1u ) );
+      const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + ( lineIndex - 1u ) );
 
       // Get the next hit 'y' point.
       const float hitPointY = cursorInfo.lineOffset - 0.5f * ( line.ascender - line.descender );
 
       // Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index.
-      mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mVisualModel,
-                                                                        mLogicalModel,
+      mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+                                                                        mModel->mLogicalModel,
                                                                         mMetrics,
                                                                         mEventData->mCursorHookPositionX,
                                                                         hitPointY );
@@ -1165,9 +1165,9 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event )
       characterIndex = mEventData->mPrimaryCursorPosition - 1u;
     }
 
-    const LineIndex lineIndex = mVisualModel->GetLineOfCharacter( characterIndex );
+    const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( characterIndex );
 
-    if( lineIndex + 1u < mVisualModel->mLines.Count() )
+    if( lineIndex + 1u < mModel->mVisualModel->mLines.Count() )
     {
       // Retrieve the cursor position info.
       CursorInfo cursorInfo;
@@ -1175,14 +1175,14 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event )
                          cursorInfo );
 
       // Get the line below.
-      const LineRun& line = *( mVisualModel->mLines.Begin() + lineIndex + 1u );
+      const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + lineIndex + 1u );
 
       // Get the next hit 'y' point.
       const float hitPointY = cursorInfo.lineOffset + cursorInfo.lineHeight + 0.5f * ( line.ascender - line.descender );
 
       // Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index.
-      mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mVisualModel,
-                                                                        mLogicalModel,
+      mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+                                                                        mModel->mLogicalModel,
                                                                         mMetrics,
                                                                         mEventData->mCursorHookPositionX,
                                                                         hitPointY );
@@ -1205,14 +1205,14 @@ void Controller::Impl::OnTapEvent( const Event& event )
       if( IsShowingRealText() )
       {
         // Convert from control's coords to text's coords.
-        const float xPosition = event.p2.mFloat - mScrollPosition.x;
-        const float yPosition = event.p3.mFloat - mScrollPosition.y;
+        const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x;
+        const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y;
 
         // Keep the tap 'x' position. Used to move the cursor.
         mEventData->mCursorHookPositionX = xPosition;
 
-        mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mVisualModel,
-                                                                          mLogicalModel,
+        mEventData->mPrimaryCursorPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+                                                                          mModel->mLogicalModel,
                                                                           mMetrics,
                                                                           xPosition,
                                                                           yPosition );
@@ -1269,13 +1269,13 @@ void Controller::Impl::OnPanEvent( const Event& event )
     }
     case Gesture::Continuing:
     {
-      const Vector2& layoutSize = mVisualModel->GetLayoutSize();
-      const Vector2 currentScroll = mScrollPosition;
+      const Vector2& layoutSize = mModel->mVisualModel->GetLayoutSize();
+      const Vector2 currentScroll = mModel->mScrollPosition;
 
       if( isHorizontalScrollEnabled )
       {
         const float displacementX = event.p2.mFloat;
-        mScrollPosition.x += displacementX;
+        mModel->mScrollPosition.x += displacementX;
 
         ClampHorizontalScroll( layoutSize );
       }
@@ -1283,12 +1283,12 @@ void Controller::Impl::OnPanEvent( const Event& event )
       if( isVerticalScrollEnabled )
       {
         const float displacementY = event.p3.mFloat;
-        mScrollPosition.y += displacementY;
+        mModel->mScrollPosition.y += displacementY;
 
         ClampVerticalScroll( layoutSize );
       }
 
-      mEventData->mDecorator->UpdatePositions( mScrollPosition - currentScroll );
+      mEventData->mDecorator->UpdatePositions( mModel->mScrollPosition - currentScroll );
       break;
     }
     case Gesture::Finished:
@@ -1330,12 +1330,12 @@ void Controller::Impl::OnHandleEvent( const Event& event )
   if( HANDLE_PRESSED == state )
   {
     // Convert from decorator's coords to text's coords.
-    const float xPosition = event.p2.mFloat - mScrollPosition.x;
-    const float yPosition = event.p3.mFloat - mScrollPosition.y;
+    const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x;
+    const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y;
 
     // Need to calculate the handle's new position.
-    const CharacterIndex handleNewPosition = Text::GetClosestCursorIndex( mVisualModel,
-                                                                          mLogicalModel,
+    const CharacterIndex handleNewPosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+                                                                          mModel->mLogicalModel,
                                                                           mMetrics,
                                                                           xPosition,
                                                                           yPosition );
@@ -1404,11 +1404,11 @@ void Controller::Impl::OnHandleEvent( const Event& event )
     if( handleStopScrolling || isSmoothHandlePanEnabled )
     {
       // Convert from decorator's coords to text's coords.
-      const float xPosition = event.p2.mFloat - mScrollPosition.x;
-      const float yPosition = event.p3.mFloat - mScrollPosition.y;
+      const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x;
+      const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y;
 
-      handlePosition = Text::GetClosestCursorIndex( mVisualModel,
-                                                    mLogicalModel,
+      handlePosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+                                                    mModel->mLogicalModel,
                                                     mMetrics,
                                                     xPosition,
                                                     yPosition );
@@ -1475,17 +1475,17 @@ void Controller::Impl::OnHandleEvent( const Event& event )
   {
     const float xSpeed = event.p2.mFloat;
     const float ySpeed = event.p3.mFloat;
-    const Vector2& layoutSize = mVisualModel->GetLayoutSize();
-    const Vector2 currentScrollPosition = mScrollPosition;
+    const Vector2& layoutSize = mModel->mVisualModel->GetLayoutSize();
+    const Vector2 currentScrollPosition = mModel->mScrollPosition;
 
-    mScrollPosition.x += xSpeed;
-    mScrollPosition.y += ySpeed;
+    mModel->mScrollPosition.x += xSpeed;
+    mModel->mScrollPosition.y += ySpeed;
 
     ClampHorizontalScroll( layoutSize );
     ClampVerticalScroll( layoutSize );
 
     bool endOfScroll = false;
-    if( Vector2::ZERO == ( currentScrollPosition - mScrollPosition ) )
+    if( Vector2::ZERO == ( currentScrollPosition - mModel->mScrollPosition ) )
     {
       // Notify the decorator there is no more text to scroll.
       // The decorator won't send more scroll events.
@@ -1510,7 +1510,7 @@ void Controller::Impl::OnHandleEvent( const Event& event )
       if( mEventData->mDecorator->IsHorizontalScrollEnabled() )
       {
         // Position the grag handle close to either the left or right edge.
-        position.x = scrollRightDirection ? 0.f : mVisualModel->mControlSize.width;
+        position.x = scrollRightDirection ? 0.f : mModel->mVisualModel->mControlSize.width;
       }
 
       if( mEventData->mDecorator->IsVerticalScrollEnabled() )
@@ -1518,16 +1518,16 @@ void Controller::Impl::OnHandleEvent( const Event& event )
         position.x = mEventData->mCursorHookPositionX;
 
         // Position the grag handle close to either the top or bottom edge.
-        position.y = scrollBottomDirection ? 0.f : mVisualModel->mControlSize.height;
+        position.y = scrollBottomDirection ? 0.f : mModel->mVisualModel->mControlSize.height;
       }
 
       // Get the new handle position.
       // The grab handle's position is in decorator's coords. Need to transforms to text's coords.
-      const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mVisualModel,
-                                                                         mLogicalModel,
+      const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+                                                                         mModel->mLogicalModel,
                                                                          mMetrics,
-                                                                         position.x - mScrollPosition.x,
-                                                                         position.y - mScrollPosition.y );
+                                                                         position.x - mModel->mScrollPosition.x,
+                                                                         position.y - mModel->mScrollPosition.y );
 
       if( mEventData->mPrimaryCursorPosition != handlePosition )
       {
@@ -1551,7 +1551,7 @@ void Controller::Impl::OnHandleEvent( const Event& event )
       if( mEventData->mDecorator->IsHorizontalScrollEnabled() )
       {
         // Position the selection handle close to either the left or right edge.
-        position.x = scrollRightDirection ? 0.f : mVisualModel->mControlSize.width;
+        position.x = scrollRightDirection ? 0.f : mModel->mVisualModel->mControlSize.width;
       }
 
       if( mEventData->mDecorator->IsVerticalScrollEnabled() )
@@ -1559,16 +1559,16 @@ void Controller::Impl::OnHandleEvent( const Event& event )
         position.x = mEventData->mCursorHookPositionX;
 
         // Position the grag handle close to either the top or bottom edge.
-        position.y = scrollBottomDirection ? 0.f : mVisualModel->mControlSize.height;
+        position.y = scrollBottomDirection ? 0.f : mModel->mVisualModel->mControlSize.height;
       }
 
       // Get the new handle position.
       // The selection handle's position is in decorator's coords. Need to transform to text's coords.
-      const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mVisualModel,
-                                                                         mLogicalModel,
+      const CharacterIndex handlePosition = Text::GetClosestCursorIndex( mModel->mVisualModel,
+                                                                         mModel->mLogicalModel,
                                                                          mMetrics,
-                                                                         position.x - mScrollPosition.x,
-                                                                         position.y - mScrollPosition.y );
+                                                                         position.x - mModel->mScrollPosition.x,
+                                                                         position.y - mModel->mScrollPosition.y );
 
       if( leftSelectionHandleEvent )
       {
@@ -1616,8 +1616,8 @@ void Controller::Impl::OnSelectEvent( const Event& event )
   if( mEventData->mSelectionEnabled )
   {
     // Convert from control's coords to text's coords.
-    const float xPosition = event.p2.mFloat - mScrollPosition.x;
-    const float yPosition = event.p3.mFloat - mScrollPosition.y;
+    const float xPosition = event.p2.mFloat - mModel->mScrollPosition.x;
+    const float yPosition = event.p3.mFloat - mModel->mScrollPosition.y;
 
     // Calculates the logical position from the x,y coords.
     RepositionSelectionHandles( xPosition,
@@ -1640,7 +1640,7 @@ void Controller::Impl::OnSelectAllEvent()
     ChangeState( EventData::SELECTING );
 
     mEventData->mLeftSelectionPosition = 0u;
-    mEventData->mRightSelectionPosition = mLogicalModel->mText.Count();
+    mEventData->mRightSelectionPosition = mModel->mLogicalModel->mText.Count();
 
     mEventData->mScrollAfterUpdatePosition = true;
     mEventData->mUpdateLeftSelectionPosition = true;
@@ -1664,7 +1664,7 @@ void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete
   const CharacterIndex startOfSelectedText = handlesCrossed ? mEventData->mRightSelectionPosition : mEventData->mLeftSelectionPosition;
   const Length lengthOfSelectedText = ( handlesCrossed ? mEventData->mLeftSelectionPosition : mEventData->mRightSelectionPosition ) - startOfSelectedText;
 
-  Vector<Character>& utf32Characters = mLogicalModel->mText;
+  Vector<Character>& utf32Characters = mModel->mLogicalModel->mText;
   const Length numberOfCharacters = utf32Characters.Count();
 
   // Validate the start and end selection points
@@ -1680,7 +1680,7 @@ void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete
       currentInputStyle.Copy( mEventData->mInputStyle );
 
       // Set as input style the style of the first deleted character.
-      mLogicalModel->RetrieveStyle( startOfSelectedText, mEventData->mInputStyle );
+      mModel->mLogicalModel->RetrieveStyle( startOfSelectedText, mEventData->mInputStyle );
 
       // Compare if the input style has changed.
       const bool hasInputStyleChanged = !currentInputStyle.Equal( mEventData->mInputStyle );
@@ -1692,7 +1692,7 @@ void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete
         mEventData->mInputStyleChangedQueue.PushBack( styleChangedMask );
       }
 
-      mLogicalModel->UpdateTextStyleRuns( startOfSelectedText, -static_cast<int>( lengthOfSelectedText ) );
+      mModel->mLogicalModel->UpdateTextStyleRuns( startOfSelectedText, -static_cast<int>( lengthOfSelectedText ) );
 
       // Mark the paragraphs to be updated.
       mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
@@ -1772,15 +1772,15 @@ void Controller::Impl::RepositionSelectionHandles()
 
   mEventData->mDecorator->ClearHighlights();
 
-  const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
-  const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
-  const GlyphInfo* const glyphsBuffer = mVisualModel->mGlyphs.Begin();
-  const Vector2* const positionsBuffer = mVisualModel->mGlyphPositions.Begin();
-  const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
-  const CharacterIndex* const glyphToCharacterBuffer = mVisualModel->mGlyphsToCharacters.Begin();
-  const CharacterDirection* const modelCharacterDirectionsBuffer = ( 0u != mLogicalModel->mCharacterDirections.Count() ) ? mLogicalModel->mCharacterDirections.Begin() : NULL;
+  const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin();
+  const Length* const glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin();
+  const GlyphInfo* const glyphsBuffer = mModel->mVisualModel->mGlyphs.Begin();
+  const Vector2* const positionsBuffer = mModel->mVisualModel->mGlyphPositions.Begin();
+  const Length* const charactersPerGlyphBuffer = mModel->mVisualModel->mCharactersPerGlyph.Begin();
+  const CharacterIndex* const glyphToCharacterBuffer = mModel->mVisualModel->mGlyphsToCharacters.Begin();
+  const CharacterDirection* const modelCharacterDirectionsBuffer = ( 0u != mModel->mLogicalModel->mCharacterDirections.Count() ) ? mModel->mLogicalModel->mCharacterDirections.Begin() : NULL;
 
-  const bool isLastCharacter = selectionEnd >= mLogicalModel->mText.Count();
+  const bool isLastCharacter = selectionEnd >= mModel->mLogicalModel->mText.Count();
   const CharacterDirection startDirection = ( ( NULL == modelCharacterDirectionsBuffer ) ? false : *( modelCharacterDirectionsBuffer + selectionStart ) );
   const CharacterDirection endDirection = ( ( NULL == modelCharacterDirectionsBuffer ) ? false : *( modelCharacterDirectionsBuffer + ( selectionEnd - ( isLastCharacter ? 1u : 0u ) ) ) );
 
@@ -1802,14 +1802,14 @@ void Controller::Impl::RepositionSelectionHandles()
   const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + selectionEndMinusOne ) + ( ( numberOfGlyphs > 0 ) ? numberOfGlyphs - 1u : 0u );
 
   // Get the lines where the glyphs are laid-out.
-  const LineRun* lineRun = mVisualModel->mLines.Begin();
+  const LineRun* lineRun = mModel->mVisualModel->mLines.Begin();
 
   LineIndex lineIndex = 0u;
   Length numberOfLines = 0u;
-  mVisualModel->GetNumberOfLines( glyphStart,
-                                  1u + glyphEnd - glyphStart,
-                                  lineIndex,
-                                  numberOfLines );
+  mModel->mVisualModel->GetNumberOfLines( glyphStart,
+                                          1u + glyphEnd - glyphStart,
+                                          lineIndex,
+                                          numberOfLines );
   const LineIndex firstLineIndex = lineIndex;
 
   // Create the structure to store some selection box info.
@@ -1829,11 +1829,11 @@ void Controller::Impl::RepositionSelectionHandles()
   // Retrieve the first line and get the line's vertical offset, the line's height and the index to the last glyph.
 
   // The line's vertical offset of all the lines before the line where the first glyph is laid-out.
-  selectionBoxInfo->lineOffset = CalculateLineOffset( mVisualModel->mLines,
+  selectionBoxInfo->lineOffset = CalculateLineOffset( mModel->mVisualModel->mLines,
                                                       firstLineIndex );
 
   // Transform to decorator's (control) coords.
-  selectionBoxInfo->lineOffset += mScrollPosition.y;
+  selectionBoxInfo->lineOffset += mModel->mScrollPosition.y;
 
   lineRun += firstLineIndex;
 
@@ -1845,11 +1845,11 @@ void Controller::Impl::RepositionSelectionHandles()
 
   // Check if the first glyph is a ligature that must be broken like Latin ff, fi, or Arabic ﻻ, etc which needs special code.
   const Length numberOfCharactersStart = *( charactersPerGlyphBuffer + glyphStart );
-  bool splitStartGlyph = ( numberOfCharactersStart > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionStart ) );
+  bool splitStartGlyph = ( numberOfCharactersStart > 1u ) && HasLigatureMustBreak( mModel->mLogicalModel->GetScript( selectionStart ) );
 
   // Check if the last glyph is a ligature that must be broken like Latin ff, fi, or Arabic ﻻ, etc which needs special code.
   const Length numberOfCharactersEnd = *( charactersPerGlyphBuffer + glyphEnd );
-  bool splitEndGlyph = ( glyphStart != glyphEnd ) && ( numberOfCharactersEnd > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionEndMinusOne ) );
+  bool splitEndGlyph = ( glyphStart != glyphEnd ) && ( numberOfCharactersEnd > 1u ) && HasLigatureMustBreak( mModel->mLogicalModel->GetScript( selectionEndMinusOne ) );
 
   // The number of quads of the selection box.
   const unsigned int numberOfQuads = 1u + ( glyphEnd - glyphStart ) + ( ( numberOfLines > 1u ) ? 2u * numberOfLines : 0u );
@@ -1882,7 +1882,7 @@ void Controller::Impl::RepositionSelectionHandles()
       // Calculate the number of characters selected.
       const Length numberOfCharacters = ( glyphStart == glyphEnd ) ? ( selectionEnd - selectionStart ) : ( numberOfCharactersStart - interGlyphIndex );
 
-      quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x + glyphAdvance * static_cast<float>( isCurrentRightToLeft ? ( numberOfCharactersStart - interGlyphIndex - numberOfCharacters ) : interGlyphIndex );
+      quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mModel->mScrollPosition.x + glyphAdvance * static_cast<float>( isCurrentRightToLeft ? ( numberOfCharactersStart - interGlyphIndex - numberOfCharacters ) : interGlyphIndex );
       quad.y = selectionBoxInfo->lineOffset;
       quad.z = quad.x + static_cast<float>( numberOfCharacters ) * glyphAdvance;
       quad.w = selectionBoxInfo->lineOffset + selectionBoxInfo->lineHeight;
@@ -1913,7 +1913,7 @@ void Controller::Impl::RepositionSelectionHandles()
 
       const Length numberOfCharacters = numberOfCharactersEnd - interGlyphIndex;
 
-      quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x + ( isCurrentRightToLeft ? ( glyphAdvance * static_cast<float>( numberOfCharacters ) ) : 0.f );
+      quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mModel->mScrollPosition.x + ( isCurrentRightToLeft ? ( glyphAdvance * static_cast<float>( numberOfCharacters ) ) : 0.f );
       quad.y = selectionBoxInfo->lineOffset;
       quad.z = quad.x + static_cast<float>( interGlyphIndex ) * glyphAdvance;
       quad.w = quad.y + selectionBoxInfo->lineHeight;
@@ -1930,7 +1930,7 @@ void Controller::Impl::RepositionSelectionHandles()
       continue;
     }
 
-    quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x;
+    quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mModel->mScrollPosition.x;
     quad.y = selectionBoxInfo->lineOffset;
     quad.z = quad.x + glyph.advance;
     quad.w = quad.y + selectionBoxInfo->lineHeight;
@@ -1995,7 +1995,7 @@ void Controller::Impl::RepositionSelectionHandles()
   if( 1u < numberOfLines )
   {
     // Boxify the first line.
-    lineRun = mVisualModel->mLines.Begin() + firstLineIndex;
+    lineRun = mModel->mVisualModel->mLines.Begin() + firstLineIndex;
     const SelectionBoxInfo& firstSelectionBoxLineInfo = *( selectionBoxLinesInfo.Begin() );
 
     bool boxifyBegin = ( LTR != lineRun->direction ) && ( LTR != startDirection );
@@ -2021,7 +2021,7 @@ void Controller::Impl::RepositionSelectionHandles()
     {
       quad.x = firstSelectionBoxLineInfo.maxX;
       quad.y = firstSelectionBoxLineInfo.lineOffset;
-      quad.z = mVisualModel->mControlSize.width;
+      quad.z = mModel->mVisualModel->mControlSize.width;
       quad.w = firstSelectionBoxLineInfo.lineOffset + firstSelectionBoxLineInfo.lineHeight;
 
       // Boxify at the end of the line.
@@ -2030,7 +2030,7 @@ void Controller::Impl::RepositionSelectionHandles()
       ++actualNumberOfQuads;
 
       // Update the size of the highlighted text.
-      maxHighlightX = mVisualModel->mControlSize.width;
+      maxHighlightX = mModel->mVisualModel->mControlSize.width;
     }
 
     // Boxify the central lines.
@@ -2054,7 +2054,7 @@ void Controller::Impl::RepositionSelectionHandles()
 
         quad.x = info.maxX;
         quad.y = info.lineOffset;
-        quad.z = mVisualModel->mControlSize.width;
+        quad.z = mModel->mVisualModel->mControlSize.width;
         quad.w = info.lineOffset + info.lineHeight;
 
         mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
@@ -2064,11 +2064,11 @@ void Controller::Impl::RepositionSelectionHandles()
 
       // Update the size of the highlighted text.
       minHighlightX = 0.f;
-      maxHighlightX = mVisualModel->mControlSize.width;
+      maxHighlightX = mModel->mVisualModel->mControlSize.width;
     }
 
     // Boxify the last line.
-    lineRun = mVisualModel->mLines.Begin() + firstLineIndex + numberOfLines - 1u;
+    lineRun = mModel->mVisualModel->mLines.Begin() + firstLineIndex + numberOfLines - 1u;
     const SelectionBoxInfo& lastSelectionBoxLineInfo = *( selectionBoxLinesInfo.End() - 1u );
 
     boxifyBegin = ( LTR == lineRun->direction ) && ( LTR == endDirection );
@@ -2094,7 +2094,7 @@ void Controller::Impl::RepositionSelectionHandles()
     {
       quad.x = lastSelectionBoxLineInfo.maxX;
       quad.y = lastSelectionBoxLineInfo.lineOffset;
-      quad.z = mVisualModel->mControlSize.width;
+      quad.z = mModel->mVisualModel->mControlSize.width;
       quad.w = lastSelectionBoxLineInfo.lineOffset + lastSelectionBoxLineInfo.lineHeight;
 
       // Boxify at the end of the line.
@@ -2103,7 +2103,7 @@ void Controller::Impl::RepositionSelectionHandles()
       ++actualNumberOfQuads;
 
       // Update the size of the highlighted text.
-      maxHighlightX = mVisualModel->mControlSize.width;
+      maxHighlightX = mModel->mVisualModel->mControlSize.width;
     }
   }
 
@@ -2126,22 +2126,22 @@ void Controller::Impl::RepositionSelectionHandles()
     GetCursorPosition( mEventData->mLeftSelectionPosition,
                        primaryCursorInfo );
 
-    const Vector2 primaryPosition = primaryCursorInfo.primaryPosition + mScrollPosition;
+    const Vector2 primaryPosition = primaryCursorInfo.primaryPosition + mModel->mScrollPosition;
 
     mEventData->mDecorator->SetPosition( LEFT_SELECTION_HANDLE,
                                          primaryPosition.x,
-                                         primaryCursorInfo.lineOffset + mScrollPosition.y,
+                                         primaryCursorInfo.lineOffset + mModel->mScrollPosition.y,
                                          primaryCursorInfo.lineHeight );
 
     CursorInfo secondaryCursorInfo;
     GetCursorPosition( mEventData->mRightSelectionPosition,
                        secondaryCursorInfo );
 
-    const Vector2 secondaryPosition = secondaryCursorInfo.primaryPosition + mScrollPosition;
+    const Vector2 secondaryPosition = secondaryCursorInfo.primaryPosition + mModel->mScrollPosition;
 
     mEventData->mDecorator->SetPosition( RIGHT_SELECTION_HANDLE,
                                          secondaryPosition.x,
-                                         secondaryCursorInfo.lineOffset + mScrollPosition.y,
+                                         secondaryCursorInfo.lineOffset + mModel->mScrollPosition.y,
                                          secondaryCursorInfo.lineHeight );
   }
 
@@ -2166,8 +2166,8 @@ void Controller::Impl::RepositionSelectionHandles( float visualX, float visualY
     return;
   }
 
-  const Length numberOfGlyphs = mVisualModel->mGlyphs.Count();
-  const Length numberOfLines  = mVisualModel->mLines.Count();
+  const Length numberOfGlyphs = mModel->mVisualModel->mGlyphs.Count();
+  const Length numberOfLines  = mModel->mVisualModel->mLines.Count();
   if( ( 0 == numberOfGlyphs ) ||
       ( 0 == numberOfLines ) )
   {
@@ -2178,8 +2178,8 @@ void Controller::Impl::RepositionSelectionHandles( float visualX, float visualY
   // Find which word was selected
   CharacterIndex selectionStart( 0 );
   CharacterIndex selectionEnd( 0 );
-  const bool indicesFound = FindSelectionIndices( mVisualModel,
-                                                  mLogicalModel,
+  const bool indicesFound = FindSelectionIndices( mModel->mVisualModel,
+                                                  mModel->mLogicalModel,
                                                   mMetrics,
                                                   visualX,
                                                   visualY,
@@ -2243,7 +2243,7 @@ void Controller::Impl::SetPopupButtons()
   }
   else if( EventData::EDITING_WITH_POPUP == mEventData->mState )
   {
-    if( mLogicalModel->mText.Count() && !IsShowingPlaceholderText() )
+    if( mModel->mLogicalModel->mText.Count() && !IsShowingPlaceholderText() )
     {
       buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL );
     }
@@ -2486,21 +2486,21 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
     cursorInfo.lineHeight = GetDefaultFontLineHeight();
     cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
 
-    switch( mLayoutEngine.GetHorizontalAlignment() )
+    switch( mModel->mHorizontalAlignment )
     {
-      case LayoutEngine::HORIZONTAL_ALIGN_BEGIN:
+      case Layout::HORIZONTAL_ALIGN_BEGIN:
       {
         cursorInfo.primaryPosition.x = 0.f;
         break;
       }
-      case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
+      case Layout::HORIZONTAL_ALIGN_CENTER:
       {
-        cursorInfo.primaryPosition.x = floorf( 0.5f * mVisualModel->mControlSize.width );
+        cursorInfo.primaryPosition.x = floorf( 0.5f * mModel->mVisualModel->mControlSize.width );
         break;
       }
-      case LayoutEngine::HORIZONTAL_ALIGN_END:
+      case Layout::HORIZONTAL_ALIGN_END:
       {
-        cursorInfo.primaryPosition.x = mVisualModel->mControlSize.width - mEventData->mDecorator->GetCursorWidth();
+        cursorInfo.primaryPosition.x = mModel->mVisualModel->mControlSize.width - mEventData->mDecorator->GetCursorWidth();
         break;
       }
     }
@@ -2509,13 +2509,13 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
     return;
   }
 
-  Text::GetCursorPosition( mVisualModel,
-                           mLogicalModel,
+  Text::GetCursorPosition( mModel->mVisualModel,
+                           mModel->mLogicalModel,
                            mMetrics,
                            logical,
                            cursorInfo );
 
-  if( LayoutEngine::MULTI_LINE_BOX == mLayoutEngine.GetLayout() )
+  if( Layout::Engine::MULTI_LINE_BOX == mLayoutEngine.GetLayout() )
   {
     // If the text is editable and multi-line, the cursor position after a white space shouldn't exceed the boundaries of the text control.
 
@@ -2527,7 +2527,7 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
       cursorInfo.primaryPosition.x = 0.f;
     }
 
-    const float edgeWidth = mVisualModel->mControlSize.width - static_cast<float>( mEventData->mDecorator->GetCursorWidth() );
+    const float edgeWidth = mModel->mVisualModel->mControlSize.width - static_cast<float>( mEventData->mDecorator->GetCursorWidth() );
     if( cursorInfo.primaryPosition.x > edgeWidth )
     {
       cursorInfo.primaryPosition.x = edgeWidth;
@@ -2545,15 +2545,15 @@ CharacterIndex Controller::Impl::CalculateNewCursorIndex( CharacterIndex index )
 
   CharacterIndex cursorIndex = mEventData->mPrimaryCursorPosition;
 
-  const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
-  const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
+  const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin();
+  const Length* const charactersPerGlyphBuffer = mModel->mVisualModel->mCharactersPerGlyph.Begin();
 
   GlyphIndex glyphIndex = *( charactersToGlyphBuffer + index );
   Length numberOfCharacters = *( charactersPerGlyphBuffer + glyphIndex );
 
   if( numberOfCharacters > 1u )
   {
-    const Script script = mLogicalModel->GetScript( index );
+    const Script script = mModel->mLogicalModel->GetScript( index );
     if( HasLigatureMustBreak( script ) )
     {
       // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ﻻ,  ...
@@ -2594,7 +2594,7 @@ void Controller::Impl::UpdateCursorPosition( const CursorInfo& cursorInfo )
     return;
   }
 
-  const Vector2 cursorPosition = cursorInfo.primaryPosition + mScrollPosition;
+  const Vector2 cursorPosition = cursorInfo.primaryPosition + mModel->mScrollPosition;
 
   // Sets the cursor position.
   mEventData->mDecorator->SetPosition( PRIMARY_CURSOR,
@@ -2609,18 +2609,18 @@ void Controller::Impl::UpdateCursorPosition( const CursorInfo& cursorInfo )
     // Sets the grab handle position.
     mEventData->mDecorator->SetPosition( GRAB_HANDLE,
                                          cursorPosition.x,
-                                         cursorInfo.lineOffset + mScrollPosition.y,
+                                         cursorInfo.lineOffset + mModel->mScrollPosition.y,
                                          cursorInfo.lineHeight );
   }
 
   if( cursorInfo.isSecondaryCursor )
   {
     mEventData->mDecorator->SetPosition( SECONDARY_CURSOR,
-                                         cursorInfo.secondaryPosition.x + mScrollPosition.x,
-                                         cursorInfo.secondaryPosition.y + mScrollPosition.y,
+                                         cursorInfo.secondaryPosition.x + mModel->mScrollPosition.x,
+                                         cursorInfo.secondaryPosition.y + mModel->mScrollPosition.y,
                                          cursorInfo.secondaryCursorHeight,
                                          cursorInfo.lineHeight );
-    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + mScrollPosition.x, cursorInfo.secondaryPosition.y + mScrollPosition.y );
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + mModel->mScrollPosition.x, cursorInfo.secondaryPosition.y + mModel->mScrollPosition.y );
   }
 
   // Set which cursors are active according the state.
@@ -2652,58 +2652,58 @@ void Controller::Impl::UpdateSelectionHandle( HandleType handleType,
     return;
   }
 
-  const Vector2 cursorPosition = cursorInfo.primaryPosition + mScrollPosition;
+  const Vector2 cursorPosition = cursorInfo.primaryPosition + mModel->mScrollPosition;
 
   // Sets the handle's position.
   mEventData->mDecorator->SetPosition( handleType,
                                        cursorPosition.x,
-                                       cursorInfo.lineOffset + mScrollPosition.y,
+                                       cursorInfo.lineOffset + mModel->mScrollPosition.y,
                                        cursorInfo.lineHeight );
 
   // If selection handle at start of the text and other at end of the text then all text is selected.
   const CharacterIndex startOfSelection = std::min( mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition );
   const CharacterIndex endOfSelection = std::max ( mEventData->mLeftSelectionPosition, mEventData->mRightSelectionPosition );
-  mEventData->mAllTextSelected = ( startOfSelection == 0 ) && ( endOfSelection == mLogicalModel->mText.Count() );
+  mEventData->mAllTextSelected = ( startOfSelection == 0 ) && ( endOfSelection == mModel->mLogicalModel->mText.Count() );
 }
 
 void Controller::Impl::ClampHorizontalScroll( const Vector2& layoutSize )
 {
   // Clamp between -space & 0.
 
-  if( layoutSize.width > mVisualModel->mControlSize.width )
+  if( layoutSize.width > mModel->mVisualModel->mControlSize.width )
   {
-    const float space = ( layoutSize.width - mVisualModel->mControlSize.width );
-    mScrollPosition.x = ( mScrollPosition.x < -space ) ? -space : mScrollPosition.x;
-    mScrollPosition.x = ( mScrollPosition.x > 0.f ) ? 0.f : mScrollPosition.x;
+    const float space = ( layoutSize.width - mModel->mVisualModel->mControlSize.width );
+    mModel->mScrollPosition.x = ( mModel->mScrollPosition.x < -space ) ? -space : mModel->mScrollPosition.x;
+    mModel->mScrollPosition.x = ( mModel->mScrollPosition.x > 0.f ) ? 0.f : mModel->mScrollPosition.x;
 
     mEventData->mDecoratorUpdated = true;
   }
   else
   {
-    mScrollPosition.x = 0.f;
+    mModel->mScrollPosition.x = 0.f;
   }
 }
 
 void Controller::Impl::ClampVerticalScroll( const Vector2& layoutSize )
 {
-  if( LayoutEngine::SINGLE_LINE_BOX == mLayoutEngine.GetLayout() )
+  if( Layout::Engine::SINGLE_LINE_BOX == mLayoutEngine.GetLayout() )
   {
     // Nothing to do if the text is single line.
     return;
   }
 
   // Clamp between -space & 0.
-  if( layoutSize.height > mVisualModel->mControlSize.height )
+  if( layoutSize.height > mModel->mVisualModel->mControlSize.height )
   {
-    const float space = ( layoutSize.height - mVisualModel->mControlSize.height );
-    mScrollPosition.y = ( mScrollPosition.y < -space ) ? -space : mScrollPosition.y;
-    mScrollPosition.y = ( mScrollPosition.y > 0.f ) ? 0.f : mScrollPosition.y;
+    const float space = ( layoutSize.height - mModel->mVisualModel->mControlSize.height );
+    mModel->mScrollPosition.y = ( mModel->mScrollPosition.y < -space ) ? -space : mModel->mScrollPosition.y;
+    mModel->mScrollPosition.y = ( mModel->mScrollPosition.y > 0.f ) ? 0.f : mModel->mScrollPosition.y;
 
     mEventData->mDecoratorUpdated = true;
   }
   else
   {
-    mScrollPosition.y = 0.f;
+    mModel->mScrollPosition.y = 0.f;
   }
 }
 
@@ -2716,28 +2716,28 @@ void Controller::Impl::ScrollToMakePositionVisible( const Vector2& position, flo
   const float positionEndY = position.y + lineHeight;
 
   // Transform the position to decorator coords.
-  const float decoratorPositionBeginX = position.x + mScrollPosition.x;
-  const float decoratorPositionEndX = positionEndX + mScrollPosition.x;
+  const float decoratorPositionBeginX = position.x + mModel->mScrollPosition.x;
+  const float decoratorPositionEndX = positionEndX + mModel->mScrollPosition.x;
 
-  const float decoratorPositionBeginY = position.y + mScrollPosition.y;
-  const float decoratorPositionEndY = positionEndY + mScrollPosition.y;
+  const float decoratorPositionBeginY = position.y + mModel->mScrollPosition.y;
+  const float decoratorPositionEndY = positionEndY + mModel->mScrollPosition.y;
 
   if( decoratorPositionBeginX < 0.f )
   {
-    mScrollPosition.x = -position.x;
+    mModel->mScrollPosition.x = -position.x;
   }
-  else if( decoratorPositionEndX > mVisualModel->mControlSize.width )
+  else if( decoratorPositionEndX > mModel->mVisualModel->mControlSize.width )
   {
-    mScrollPosition.x = mVisualModel->mControlSize.width - positionEndX;
+    mModel->mScrollPosition.x = mModel->mVisualModel->mControlSize.width - positionEndX;
   }
 
   if( decoratorPositionBeginY < 0.f )
   {
-    mScrollPosition.y = -position.y;
+    mModel->mScrollPosition.y = -position.y;
   }
-  else if( decoratorPositionEndY > mVisualModel->mControlSize.height )
+  else if( decoratorPositionEndY > mModel->mVisualModel->mControlSize.height )
   {
-    mScrollPosition.y = mVisualModel->mControlSize.height - positionEndY;
+    mModel->mScrollPosition.y = mModel->mVisualModel->mControlSize.height - positionEndY;
   }
 }
 
@@ -2747,11 +2747,11 @@ void Controller::Impl::ScrollTextToMatchCursor( const CursorInfo& cursorInfo )
   const Vector2& currentCursorPosition = mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
 
   // Calculate the offset to match the cursor position before the character was deleted.
-  mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x;
-  mScrollPosition.y = currentCursorPosition.y - cursorInfo.lineOffset;
+  mModel->mScrollPosition.x = currentCursorPosition.x - cursorInfo.primaryPosition.x;
+  mModel->mScrollPosition.y = currentCursorPosition.y - cursorInfo.lineOffset;
 
-  ClampHorizontalScroll( mVisualModel->GetLayoutSize() );
-  ClampVerticalScroll( mVisualModel->GetLayoutSize() );
+  ClampHorizontalScroll( mModel->mVisualModel->GetLayoutSize() );
+  ClampVerticalScroll( mModel->mVisualModel->GetLayoutSize() );
 
   // Makes the new cursor position visible if needed.
   ScrollToMakePositionVisible( cursorInfo.primaryPosition, cursorInfo.lineHeight );
index 3a89308..81b6554 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/input-style.h>
-#include <dali-toolkit/internal/text/layouts/layout-engine.h>
-#include <dali-toolkit/internal/text/logical-model-impl.h>
 #include <dali-toolkit/internal/text/text-controller.h>
+#include <dali-toolkit/internal/text/text-model.h>
 #include <dali-toolkit/internal/text/text-view.h>
-#include <dali-toolkit/internal/text/visual-model-impl.h>
 
 namespace Dali
 {
@@ -289,8 +287,7 @@ struct Controller::Impl
         EditableControlInterface* editableControlInterface )
   : mControlInterface( controlInterface ),
     mEditableControlInterface( editableControlInterface ),
-    mLogicalModel(),
-    mVisualModel(),
+    mModel(),
     mFontDefaults( NULL ),
     mUnderlineDefaults( NULL ),
     mShadowDefaults( NULL ),
@@ -301,10 +298,8 @@ struct Controller::Impl
     mClipboard(),
     mView(),
     mMetrics(),
-    mLayoutEngine(),
     mModifyEvents(),
     mTextColor( Color::BLACK ),
-    mScrollPosition(),
     mTextUpdateInfo(),
     mOperationsPending( NO_OPERATION ),
     mMaximumNumberOfCharacters( 50u ),
@@ -314,21 +309,20 @@ struct Controller::Impl
     mIsAutoScrollEnabled( false ),
     mAutoScrollDirectionRTL( false )
   {
-    mLogicalModel = LogicalModel::New();
-    mVisualModel  = VisualModel::New();
+    mModel = Model::New();
 
     mFontClient = TextAbstraction::FontClient::Get();
     mClipboard = Clipboard::Get();
 
-    mView.SetVisualModel( mVisualModel );
+    mView.SetVisualModel( mModel->mVisualModel );
 
     // Use this to access FontClient i.e. to get down-scaled Emoji metrics.
     mMetrics = Metrics::New( mFontClient );
     mLayoutEngine.SetMetrics( mMetrics );
 
     // Set the text properties to default
-    mVisualModel->SetUnderlineEnabled( false );
-    mVisualModel->SetUnderlineHeight( 0.0f );
+    mModel->mVisualModel->SetUnderlineEnabled( false );
+    mModel->mVisualModel->SetUnderlineHeight( 0.0f );
   }
 
   ~Impl()
@@ -399,7 +393,7 @@ struct Controller::Impl
   bool IsShowingRealText() const
   {
     return ( !IsShowingPlaceholderText() &&
-             0u != mLogicalModel->mText.Count() );
+             0u != mModel->mLogicalModel->mText.Count() );
   }
 
   /**
@@ -412,7 +406,7 @@ struct Controller::Impl
       mEventData->mIsShowingPlaceholderText = false;
 
       // Remove mPlaceholderTextColor
-      mVisualModel->SetTextColor( mTextColor );
+      mModel->mVisualModel->SetTextColor( mTextColor );
     }
   }
 
@@ -693,8 +687,7 @@ public:
 
   ControlInterface* mControlInterface;     ///< Reference to the text controller.
   EditableControlInterface* mEditableControlInterface; ///< Reference to the editable text controller.
-  LogicalModelPtr mLogicalModel;           ///< Pointer to the logical model.
-  VisualModelPtr  mVisualModel;            ///< Pointer to the visual model.
+  ModelPtr mModel;                         ///< Pointer to the text's model.
   FontDefaults* mFontDefaults;             ///< Avoid allocating this when the user does not specify a font.
   UnderlineDefaults* mUnderlineDefaults;   ///< Avoid allocating this when the user does not specify underline parameters.
   ShadowDefaults* mShadowDefaults;         ///< Avoid allocating this when the user does not specify shadow parameters.
@@ -705,14 +698,9 @@ public:
   Clipboard mClipboard;                    ///< Handle to the system clipboard
   View mView;                              ///< The view interface to the rendering back-end.
   MetricsPtr mMetrics;                     ///< A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics.
-  LayoutEngine mLayoutEngine;              ///< The layout engine.
+  Layout::Engine mLayoutEngine;            ///< The layout engine.
   Vector<ModifyEvent> mModifyEvents;       ///< Temporary stores the text set until the next relayout.
   Vector4 mTextColor;                      ///< The regular text color
-  /**
-   * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
-   * Typically this will have a negative value with scrolling occurs.
-   */
-  Vector2 mScrollPosition;                 ///< The text is offset by this position when scrolling.
   TextUpdateInfo mTextUpdateInfo;          ///< Info of the characters updated.
   OperationsMask mOperationsPending;       ///< Operations pending to be done to layout the text.
   Length mMaximumNumberOfCharacters;       ///< Maximum number of characters that can be inserted.
index 360be60..5a82cc9 100644 (file)
@@ -122,6 +122,15 @@ ControllerPtr Controller::New( ControlInterface* controlInterface,
 
 void Controller::EnableTextInput( DecoratorPtr decorator )
 {
+  if( !decorator )
+  {
+    delete mImpl->mEventData;
+    mImpl->mEventData = NULL;
+
+    // Nothing else to do.
+    return;
+  }
+
   if( NULL == mImpl->mEventData )
   {
     mImpl->mEventData = new EventData( decorator );
@@ -151,9 +160,9 @@ bool Controller::IsMarkupProcessorEnabled() const
 
 void Controller::SetAutoScrollEnabled( bool enable )
 {
-  DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled[%s] SingleBox[%s]-> [%p]\n", (enable)?"true":"false", ( mImpl->mLayoutEngine.GetLayout() == LayoutEngine::SINGLE_LINE_BOX)?"true":"false", this );
+  DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetAutoScrollEnabled[%s] SingleBox[%s]-> [%p]\n", (enable)?"true":"false", ( mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX)?"true":"false", this );
 
-  if( mImpl->mLayoutEngine.GetLayout() == LayoutEngine::SINGLE_LINE_BOX )
+  if( mImpl->mLayoutEngine.GetLayout() == Layout::Engine::SINGLE_LINE_BOX )
   {
     if( enable )
     {
@@ -202,10 +211,10 @@ float Controller::GetAutoScrollLineAlignment() const
 {
   float offset = 0.f;
 
-  if( mImpl->mVisualModel &&
-      ( 0u != mImpl->mVisualModel->mLines.Count() ) )
+  if( mImpl->mModel->mVisualModel &&
+      ( 0u != mImpl->mModel->mVisualModel->mLines.Count() ) )
   {
-    offset = ( *mImpl->mVisualModel->mLines.Begin() ).alignmentOffset;
+    offset = ( *mImpl->mModel->mVisualModel->mLines.Begin() ).alignmentOffset;
   }
 
   return offset;
@@ -219,7 +228,6 @@ void Controller::SetHorizontalScrollEnabled( bool enable )
     mImpl->mEventData->mDecorator->SetHorizontalScrollEnabled( enable );
   }
 }
-
 bool Controller::IsHorizontalScrollEnabled() const
 {
   if( ( NULL != mImpl->mEventData ) &&
@@ -312,7 +320,7 @@ bool Controller::GetEnableCursorBlink() const
 
 void Controller::SetMultiLineEnabled( bool enable )
 {
-  const LayoutEngine::Layout layout = enable ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
+  const Layout::Engine::Type layout = enable ? Layout::Engine::MULTI_LINE_BOX : Layout::Engine::SINGLE_LINE_BOX;
 
   if( layout != mImpl->mLayoutEngine.GetLayout() )
   {
@@ -333,15 +341,15 @@ void Controller::SetMultiLineEnabled( bool enable )
 
 bool Controller::IsMultiLineEnabled() const
 {
-  return LayoutEngine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
+  return Layout::Engine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
 }
 
-void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
+void Controller::SetHorizontalAlignment( Layout::HorizontalAlignment alignment )
 {
-  if( alignment != mImpl->mLayoutEngine.GetHorizontalAlignment() )
+  if( alignment != mImpl->mModel->mHorizontalAlignment )
   {
     // Set the alignment.
-    mImpl->mLayoutEngine.SetHorizontalAlignment( alignment );
+    mImpl->mModel->mHorizontalAlignment = alignment;
 
     // Set the flag to redo the alignment operation.
     mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
@@ -350,17 +358,17 @@ void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment align
   }
 }
 
-LayoutEngine::HorizontalAlignment Controller::GetHorizontalAlignment() const
+Layout::HorizontalAlignment Controller::GetHorizontalAlignment() const
 {
-  return mImpl->mLayoutEngine.GetHorizontalAlignment();
+  return mImpl->mModel->mHorizontalAlignment;
 }
 
-void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
+void Controller::SetVerticalAlignment( Layout::VerticalAlignment alignment )
 {
-  if( alignment != mImpl->mLayoutEngine.GetVerticalAlignment() )
+  if( alignment != mImpl->mModel->mVerticalAlignment )
   {
     // Set the alignment.
-    mImpl->mLayoutEngine.SetVerticalAlignment( alignment );
+    mImpl->mModel->mVerticalAlignment = alignment;
 
     mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
 
@@ -368,9 +376,19 @@ void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment
   }
 }
 
-LayoutEngine::VerticalAlignment Controller::GetVerticalAlignment() const
+Layout::VerticalAlignment Controller::GetVerticalAlignment() const
+{
+  return mImpl->mModel->mVerticalAlignment;
+}
+
+void Controller::SetTextElideEnabled( bool enabled )
 {
-  return mImpl->mLayoutEngine.GetVerticalAlignment();
+  mImpl->mModel->mElideEnabled = enabled;
+}
+
+bool Controller::IsTextElideEnabled() const
+{
+  return mImpl->mModel->mElideEnabled;
 }
 
 // public : Update
@@ -404,10 +422,10 @@ void Controller::SetText( const std::string& text )
 
   if( !text.empty() )
   {
-    mImpl->mVisualModel->SetTextColor( mImpl->mTextColor );
+    mImpl->mModel->mVisualModel->SetTextColor( mImpl->mTextColor );
 
-    MarkupProcessData markupProcessData( mImpl->mLogicalModel->mColorRuns,
-                                         mImpl->mLogicalModel->mFontDescriptionRuns );
+    MarkupProcessData markupProcessData( mImpl->mModel->mLogicalModel->mColorRuns,
+                                         mImpl->mModel->mLogicalModel->mFontDescriptionRuns );
 
     Length textSize = 0u;
     const uint8_t* utf8 = NULL;
@@ -428,7 +446,7 @@ void Controller::SetText( const std::string& text )
     }
 
     //  Convert text into UTF-32
-    Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
+    Vector<Character>& utf32Characters = mImpl->mModel->mLogicalModel->mText;
     utf32Characters.Resize( textSize );
 
     // Transform a text array encoded in utf8 into an array encoded in utf32.
@@ -437,10 +455,10 @@ void Controller::SetText( const std::string& text )
     utf32Characters.Resize( characterCount );
 
     DALI_ASSERT_DEBUG( textSize >= characterCount && "Invalid UTF32 conversion length" );
-    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, textSize, mImpl->mLogicalModel->mText.Count() );
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", this, textSize, mImpl->mModel->mLogicalModel->mText.Count() );
 
     // The characters to be added.
-    mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mLogicalModel->mText.Count();
+    mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
 
     // To reset the cursor position
     lastCursorIndex = characterCount;
@@ -508,7 +526,7 @@ void Controller::SetPlaceholderText( PlaceholderType type, const std::string& te
 
     // Update placeholder if there is no text
     if( mImpl->IsShowingPlaceholderText() ||
-        ( 0u == mImpl->mLogicalModel->mText.Count() ) )
+        ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
     {
       ShowPlaceholderText();
     }
@@ -693,19 +711,19 @@ float Controller::GetDefaultPointSize() const
   return 0.0f;
 }
 
-void Controller::SetTextColor( const Vector4& textColor )
+void Controller::SetDefaultColor( const Vector4& color )
 {
-  mImpl->mTextColor = textColor;
+  mImpl->mTextColor = color;
 
   if( !mImpl->IsShowingPlaceholderText() )
   {
-    mImpl->mVisualModel->SetTextColor( textColor );
+    mImpl->mModel->mVisualModel->SetTextColor( color );
 
     mImpl->RequestRelayout();
   }
 }
 
-const Vector4& Controller::GetTextColor() const
+const Vector4& Controller::GetDefaultColor() const
 {
   return mImpl->mTextColor;
 }
@@ -719,7 +737,7 @@ void Controller::SetPlaceholderTextColor( const Vector4& textColor )
 
   if( mImpl->IsShowingPlaceholderText() )
   {
-    mImpl->mVisualModel->SetTextColor( textColor );
+    mImpl->mModel->mVisualModel->SetTextColor( textColor );
     mImpl->RequestRelayout();
   }
 }
@@ -736,62 +754,62 @@ const Vector4& Controller::GetPlaceholderTextColor() const
 
 void Controller::SetShadowOffset( const Vector2& shadowOffset )
 {
-  mImpl->mVisualModel->SetShadowOffset( shadowOffset );
+  mImpl->mModel->mVisualModel->SetShadowOffset( shadowOffset );
 
   mImpl->RequestRelayout();
 }
 
 const Vector2& Controller::GetShadowOffset() const
 {
-  return mImpl->mVisualModel->GetShadowOffset();
+  return mImpl->mModel->mVisualModel->GetShadowOffset();
 }
 
 void Controller::SetShadowColor( const Vector4& shadowColor )
 {
-  mImpl->mVisualModel->SetShadowColor( shadowColor );
+  mImpl->mModel->mVisualModel->SetShadowColor( shadowColor );
 
   mImpl->RequestRelayout();
 }
 
 const Vector4& Controller::GetShadowColor() const
 {
-  return mImpl->mVisualModel->GetShadowColor();
+  return mImpl->mModel->mVisualModel->GetShadowColor();
 }
 
 void Controller::SetUnderlineColor( const Vector4& color )
 {
-  mImpl->mVisualModel->SetUnderlineColor( color );
+  mImpl->mModel->mVisualModel->SetUnderlineColor( color );
 
   mImpl->RequestRelayout();
 }
 
 const Vector4& Controller::GetUnderlineColor() const
 {
-  return mImpl->mVisualModel->GetUnderlineColor();
+  return mImpl->mModel->mVisualModel->GetUnderlineColor();
 }
 
 void Controller::SetUnderlineEnabled( bool enabled )
 {
-  mImpl->mVisualModel->SetUnderlineEnabled( enabled );
+  mImpl->mModel->mVisualModel->SetUnderlineEnabled( enabled );
 
   mImpl->RequestRelayout();
 }
 
 bool Controller::IsUnderlineEnabled() const
 {
-  return mImpl->mVisualModel->IsUnderlineEnabled();
+  return mImpl->mModel->mVisualModel->IsUnderlineEnabled();
 }
 
 void Controller::SetUnderlineHeight( float height )
 {
-  mImpl->mVisualModel->SetUnderlineHeight( height );
+  mImpl->mModel->mVisualModel->SetUnderlineHeight( height );
 
   mImpl->RequestRelayout();
 }
 
 float Controller::GetUnderlineHeight() const
 {
-  return mImpl->mVisualModel->GetUnderlineHeight();
+  return mImpl->mModel->mVisualModel->GetUnderlineHeight();
 }
 
 void Controller::SetDefaultEmbossProperties( const std::string& embossProperties )
@@ -861,10 +879,10 @@ void Controller::SetInputColor( const Vector4& color )
       const Length lengthOfSelectedText = ( handlesCrossed ? mImpl->mEventData->mLeftSelectionPosition : mImpl->mEventData->mRightSelectionPosition ) - startOfSelectedText;
 
       // Add the color run.
-      const VectorBase::SizeType numberOfRuns = mImpl->mLogicalModel->mColorRuns.Count();
-      mImpl->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
+      const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count();
+      mImpl->mModel->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
 
-      ColorRun& colorRun = *( mImpl->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
+      ColorRun& colorRun = *( mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
       colorRun.color = color;
       colorRun.characterRun.characterIndex = startOfSelectedText;
       colorRun.characterRun.numberOfCharacters = lengthOfSelectedText;
@@ -904,7 +922,7 @@ void Controller::SetInputFontFamily( const std::string& fontFamily )
       CharacterIndex startOfSelectedText = 0u;
       Length lengthOfSelectedText = 0u;
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
-                                                                            mImpl->mLogicalModel,
+                                                                            mImpl->mModel->mLogicalModel,
                                                                             startOfSelectedText,
                                                                             lengthOfSelectedText );
 
@@ -963,7 +981,7 @@ void Controller::SetInputFontWeight( FontWeight weight )
       CharacterIndex startOfSelectedText = 0u;
       Length lengthOfSelectedText = 0u;
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
-                                                                            mImpl->mLogicalModel,
+                                                                            mImpl->mModel->mLogicalModel,
                                                                             startOfSelectedText,
                                                                             lengthOfSelectedText );
 
@@ -1029,7 +1047,7 @@ void Controller::SetInputFontWidth( FontWidth width )
       CharacterIndex startOfSelectedText = 0u;
       Length lengthOfSelectedText = 0u;
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
-                                                                            mImpl->mLogicalModel,
+                                                                            mImpl->mModel->mLogicalModel,
                                                                             startOfSelectedText,
                                                                             lengthOfSelectedText );
 
@@ -1095,7 +1113,7 @@ void Controller::SetInputFontSlant( FontSlant slant )
       CharacterIndex startOfSelectedText = 0u;
       Length lengthOfSelectedText = 0u;
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
-                                                                            mImpl->mLogicalModel,
+                                                                            mImpl->mModel->mLogicalModel,
                                                                             startOfSelectedText,
                                                                             lengthOfSelectedText );
 
@@ -1161,7 +1179,7 @@ void Controller::SetInputFontPointSize( float size )
       CharacterIndex startOfSelectedText = 0u;
       Length lengthOfSelectedText = 0u;
       FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
-                                                                            mImpl->mLogicalModel,
+                                                                            mImpl->mModel->mLogicalModel,
                                                                             startOfSelectedText,
                                                                             lengthOfSelectedText );
 
@@ -1297,7 +1315,7 @@ const std::string& Controller::GetInputOutlineProperties() const
 
 // public : Queries & retrieves.
 
-LayoutEngine& Controller::GetLayoutEngine()
+Layout::Engine& Controller::GetLayoutEngine()
 {
   return mImpl->mLayoutEngine;
 }
@@ -1307,11 +1325,6 @@ View& Controller::GetView()
   return mImpl->mView;
 }
 
-const Vector2& Controller::GetScrollPosition() const
-{
-  return mImpl->mScrollPosition;
-}
-
 Vector3 Controller::GetNaturalSize()
 {
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n" );
@@ -1339,10 +1352,10 @@ Vector3 Controller::GetNaturalSize()
 
     // Set the update info to relayout the whole text.
     mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
-    mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count();
+    mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
 
     // Store the actual control's size to restore later.
-    const Size actualControlSize = mImpl->mVisualModel->mControlSize;
+    const Size actualControlSize = mImpl->mModel->mVisualModel->mControlSize;
 
     DoRelayout( Size( MAX_FLOAT, MAX_FLOAT ),
                 static_cast<OperationsMask>( onlyOnceOperations |
@@ -1360,7 +1373,7 @@ Vector3 Controller::GetNaturalSize()
 
     // Stores the natural size to avoid recalculate it again
     // unless the text/style changes.
-    mImpl->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
+    mImpl->mModel->mVisualModel->SetNaturalSize( naturalSize.GetVectorXY() );
 
     mImpl->mRecalculateNaturalSize = false;
 
@@ -1368,13 +1381,13 @@ Vector3 Controller::GetNaturalSize()
     mImpl->mTextUpdateInfo.Clear();
 
     // Restore the actual control's size.
-    mImpl->mVisualModel->mControlSize = actualControlSize;
+    mImpl->mModel->mVisualModel->mControlSize = actualControlSize;
 
     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
   }
   else
   {
-    naturalSize = mImpl->mVisualModel->GetNaturalSize();
+    naturalSize = mImpl->mModel->mVisualModel->GetNaturalSize();
 
     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z );
   }
@@ -1392,7 +1405,7 @@ float Controller::GetHeightForWidth( float width )
   ProcessModifyEvents();
 
   Size layoutSize;
-  if( fabsf( width - mImpl->mVisualModel->mControlSize.width ) > Math::MACHINE_EPSILON_1000 )
+  if( fabsf( width - mImpl->mModel->mVisualModel->mControlSize.width ) > Math::MACHINE_EPSILON_1000 )
   {
     // Operations that can be done only once until the text changes.
     const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32  |
@@ -1412,10 +1425,10 @@ float Controller::GetHeightForWidth( float width )
 
     // Set the update info to relayout the whole text.
     mImpl->mTextUpdateInfo.mParagraphCharacterIndex = 0u;
-    mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mLogicalModel->mText.Count();
+    mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters = mImpl->mModel->mLogicalModel->mText.Count();
 
     // Store the actual control's width.
-    const float actualControlWidth = mImpl->mVisualModel->mControlSize.width;
+    const float actualControlWidth = mImpl->mModel->mVisualModel->mControlSize.width;
 
     DoRelayout( Size( width, MAX_FLOAT ),
                 static_cast<OperationsMask>( onlyOnceOperations |
@@ -1436,19 +1449,24 @@ float Controller::GetHeightForWidth( float width )
     mImpl->mTextUpdateInfo.Clear();
 
     // Restore the actual control's width.
-    mImpl->mVisualModel->mControlSize.width = actualControlWidth;
+    mImpl->mModel->mVisualModel->mControlSize.width = actualControlWidth;
 
     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height );
   }
   else
   {
-    layoutSize = mImpl->mVisualModel->GetLayoutSize();
+    layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height );
   }
 
   return layoutSize.height;
 }
 
+const ModelInterface* const Controller::GetTextModel() const
+{
+  return mImpl->mModel.Get();
+}
+
 // public : Relayout.
 
 Controller::UpdateTextType Controller::Relayout( const Size& size )
@@ -1459,9 +1477,9 @@ Controller::UpdateTextType Controller::Relayout( const Size& size )
 
   if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
   {
-    if( 0u != mImpl->mVisualModel->mGlyphPositions.Count() )
+    if( 0u != mImpl->mModel->mVisualModel->mGlyphPositions.Count() )
     {
-      mImpl->mVisualModel->mGlyphPositions.Clear();
+      mImpl->mModel->mVisualModel->mGlyphPositions.Clear();
       updateTextType = MODEL_UPDATED;
     }
 
@@ -1475,11 +1493,11 @@ Controller::UpdateTextType Controller::Relayout( const Size& size )
   }
 
   // Whether a new size has been set.
-  const bool newSize = ( size != mImpl->mVisualModel->mControlSize );
+  const bool newSize = ( size != mImpl->mModel->mVisualModel->mControlSize );
 
   if( newSize )
   {
-    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mVisualModel->mControlSize.width, mImpl->mVisualModel->mControlSize.height );
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mModel->mVisualModel->mControlSize.width, mImpl->mModel->mVisualModel->mControlSize.height );
 
     // Layout operations that need to be done if the size changes.
     mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
@@ -1525,7 +1543,7 @@ Controller::UpdateTextType Controller::Relayout( const Size& size )
   Vector2 offset;
   if( newSize && isEditable )
   {
-    offset = mImpl->mScrollPosition;
+    offset = mImpl->mModel->mScrollPosition;
   }
 
   if( !isEditable || !IsMultiLineEnabled() )
@@ -1542,7 +1560,7 @@ Controller::UpdateTextType Controller::Relayout( const Size& size )
       mImpl->ClampHorizontalScroll( layoutSize );
 
       // Update the decorator's positions is needed if there is a new size.
-      mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mScrollPosition - offset );
+      mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mModel->mScrollPosition - offset );
     }
 
     // Move the cursor, grab handle etc.
@@ -1889,7 +1907,7 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons
 
       if( textDeleted )
       {
-        if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
+        if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
             !mImpl->IsPlaceholderAvailable() )
         {
           mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
@@ -1983,7 +2001,7 @@ void Controller::PasteClipboardItemEvent()
 
 void Controller::GetTargetSize( Vector2& targetSize )
 {
-  targetSize = mImpl->mVisualModel->mControlSize;
+  targetSize = mImpl->mModel->mVisualModel->mControlSize;
 }
 
 void Controller::AddDecoration( Actor& actor, bool needsClipping )
@@ -2064,7 +2082,7 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt
       mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
       mImpl->mOperationsPending = ALL_OPERATIONS;
 
-      if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
+      if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
           !mImpl->IsPlaceholderAvailable() )
       {
         mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
@@ -2148,10 +2166,10 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
                  mImpl->mEventData->mPrimaryCursorPosition, mImpl->mEventData->mPreEditFlag, mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
 
   // TODO: At the moment the underline runs are only for pre-edit.
-  mImpl->mVisualModel->mUnderlineRuns.Clear();
+  mImpl->mModel->mVisualModel->mUnderlineRuns.Clear();
 
   // Keep the current number of characters.
-  const Length currentNumberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mLogicalModel->mText.Count() : 0u;
+  const Length currentNumberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mModel->mLogicalModel->mText.Count() : 0u;
 
   // Remove the previous IMF pre-edit.
   if( mImpl->mEventData->mPreEditFlag && ( 0u != mImpl->mEventData->mPreEditLength ) )
@@ -2221,7 +2239,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
       DALI_LOG_INFO( gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength );
     }
 
-    const Length numberOfCharactersInModel = mImpl->mLogicalModel->mText.Count();
+    const Length numberOfCharactersInModel = mImpl->mModel->mLogicalModel->mText.Count();
 
     // Restrict new text to fit within Maximum characters setting.
     Length maxSizeOfNewText = std::min( ( mImpl->mMaximumNumberOfCharacters - numberOfCharactersInModel ), characterCount );
@@ -2233,7 +2251,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
     // Update the text's style.
 
     // Updates the text style runs by adding characters.
-    mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, maxSizeOfNewText );
+    mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, maxSizeOfNewText );
 
     // Get the character index from the cursor index.
     const CharacterIndex styleIndex = ( cursorIndex > 0u ) ? cursorIndex - 1u : 0u;
@@ -2241,7 +2259,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
     // Retrieve the text's style for the given index.
     InputStyle style;
     mImpl->RetrieveDefaultInputStyle( style );
-    mImpl->mLogicalModel->RetrieveStyle( styleIndex, style );
+    mImpl->mModel->mLogicalModel->RetrieveStyle( styleIndex, style );
 
     // Whether to add a new text color run.
     const bool addColorRun = ( style.textColor != mImpl->mEventData->mInputStyle.textColor );
@@ -2256,10 +2274,10 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
     // Add style runs.
     if( addColorRun )
     {
-      const VectorBase::SizeType numberOfRuns = mImpl->mLogicalModel->mColorRuns.Count();
-      mImpl->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
+      const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mColorRuns.Count();
+      mImpl->mModel->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
 
-      ColorRun& colorRun = *( mImpl->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
+      ColorRun& colorRun = *( mImpl->mModel->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
       colorRun.color = mImpl->mEventData->mInputStyle.textColor;
       colorRun.characterRun.characterIndex = cursorIndex;
       colorRun.characterRun.numberOfCharacters = maxSizeOfNewText;
@@ -2271,10 +2289,10 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
         addFontSlantRun  ||
         addFontSizeRun )
     {
-      const VectorBase::SizeType numberOfRuns = mImpl->mLogicalModel->mFontDescriptionRuns.Count();
-      mImpl->mLogicalModel->mFontDescriptionRuns.Resize( numberOfRuns + 1u );
+      const VectorBase::SizeType numberOfRuns = mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Count();
+      mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Resize( numberOfRuns + 1u );
 
-      FontDescriptionRun& fontDescriptionRun = *( mImpl->mLogicalModel->mFontDescriptionRuns.Begin() + numberOfRuns );
+      FontDescriptionRun& fontDescriptionRun = *( mImpl->mModel->mLogicalModel->mFontDescriptionRuns.Begin() + numberOfRuns );
 
       if( addFontNameRun )
       {
@@ -2315,7 +2333,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
     }
 
     // Insert at current cursor position.
-    Vector<Character>& modifyText = mImpl->mLogicalModel->mText;
+    Vector<Character>& modifyText = mImpl->mModel->mLogicalModel->mText;
 
     if( cursorIndex < numberOfCharactersInModel )
     {
@@ -2333,12 +2351,12 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
     // Update the cursor index.
     cursorIndex += maxSizeOfNewText;
 
-    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, mImpl->mModel->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition );
   }
 
-  const Length numberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mLogicalModel->mText.Count() : 0u;
+  const Length numberOfCharacters = mImpl->IsShowingRealText() ? mImpl->mModel->mLogicalModel->mText.Count() : 0u;
 
-  if( ( 0u == mImpl->mLogicalModel->mText.Count() ) &&
+  if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) &&
       mImpl->IsPlaceholderAvailable() )
   {
     // Show place-holder if empty after removing the pre-edit text
@@ -2365,7 +2383,7 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
 
   if( maxLengthReached )
   {
-    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mLogicalModel->mText.Count() );
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", mImpl->mModel->mLogicalModel->mText.Count() );
 
     mImpl->ResetImfManager();
 
@@ -2402,12 +2420,12 @@ bool Controller::RemoveText( int cursorOffset,
   }
 
   DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n",
-                 this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters );
+                 this, mImpl->mModel->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters );
 
   if( !mImpl->IsShowingPlaceholderText() )
   {
     // Delete at current cursor position
-    Vector<Character>& currentText = mImpl->mLogicalModel->mText;
+    Vector<Character>& currentText = mImpl->mModel->mLogicalModel->mText;
     CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
 
     CharacterIndex cursorIndex = oldCursorIndex;
@@ -2441,7 +2459,7 @@ bool Controller::RemoveText( int cursorOffset,
         mImpl->RetrieveDefaultInputStyle( mImpl->mEventData->mInputStyle );
 
         // Update the input style.
-        mImpl->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle );
+        mImpl->mModel->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle );
 
         // Compare if the input style has changed.
         const bool hasInputStyleChanged = !currentInputStyle.Equal( mImpl->mEventData->mInputStyle );
@@ -2455,7 +2473,7 @@ bool Controller::RemoveText( int cursorOffset,
       }
 
       // Updates the text style runs by removing characters. Runs with no characters are removed.
-      mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );
+      mImpl->mModel->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );
 
       // Remove the characters.
       Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
@@ -2511,7 +2529,7 @@ bool Controller::DoRelayout( const Size& size,
   const Length requestedNumberOfCharacters = mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters;
 
   // Get the current layout size.
-  layoutSize = mImpl->mVisualModel->GetLayoutSize();
+  layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
 
   if( NO_OPERATION != ( LAYOUT & operations ) )
   {
@@ -2522,21 +2540,21 @@ bool Controller::DoRelayout( const Size& size,
     // Fill the vectors again.
 
     // Calculate the number of glyphs to layout.
-    const Vector<GlyphIndex>& charactersToGlyph = mImpl->mVisualModel->mCharactersToGlyph;
-    const Vector<Length>& glyphsPerCharacter = mImpl->mVisualModel->mGlyphsPerCharacter;
+    const Vector<GlyphIndex>& charactersToGlyph = mImpl->mModel->mVisualModel->mCharactersToGlyph;
+    const Vector<Length>& glyphsPerCharacter = mImpl->mModel->mVisualModel->mGlyphsPerCharacter;
     const GlyphIndex* const charactersToGlyphBuffer = charactersToGlyph.Begin();
     const Length* const glyphsPerCharacterBuffer = glyphsPerCharacter.Begin();
 
     const CharacterIndex lastIndex = startIndex + ( ( requestedNumberOfCharacters > 0u ) ? requestedNumberOfCharacters - 1u : 0u );
     const GlyphIndex startGlyphIndex = mImpl->mTextUpdateInfo.mStartGlyphIndex;
     const Length numberOfGlyphs = ( requestedNumberOfCharacters > 0u ) ? *( charactersToGlyphBuffer + lastIndex ) + *( glyphsPerCharacterBuffer + lastIndex ) - startGlyphIndex : 0u;
-    const Length totalNumberOfGlyphs = mImpl->mVisualModel->mGlyphs.Count();
+    const Length totalNumberOfGlyphs = mImpl->mModel->mVisualModel->mGlyphs.Count();
 
     if( 0u == totalNumberOfGlyphs )
     {
       if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
       {
-        mImpl->mVisualModel->SetLayoutSize( Size::ZERO );
+        mImpl->mModel->mVisualModel->SetLayoutSize( Size::ZERO );
       }
 
       // Nothing else to do if there is no glyphs.
@@ -2544,33 +2562,34 @@ bool Controller::DoRelayout( const Size& size,
       return true;
     }
 
-    const Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
-    const Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
-    const Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
-    const Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
-    const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
-    const Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
-    const Character* const textBuffer = mImpl->mLogicalModel->mText.Begin();
+    const Vector<LineBreakInfo>& lineBreakInfo = mImpl->mModel->mLogicalModel->mLineBreakInfo;
+    const Vector<WordBreakInfo>& wordBreakInfo = mImpl->mModel->mLogicalModel->mWordBreakInfo;
+    const Vector<CharacterDirection>& characterDirection = mImpl->mModel->mLogicalModel->mCharacterDirections;
+    const Vector<GlyphInfo>& glyphs = mImpl->mModel->mVisualModel->mGlyphs;
+    const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mModel->mVisualModel->mGlyphsToCharacters;
+    const Vector<Length>& charactersPerGlyph = mImpl->mModel->mVisualModel->mCharactersPerGlyph;
+    const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin();
 
     // Set the layout parameters.
-    LayoutParameters layoutParameters( size,
-                                       textBuffer,
-                                       lineBreakInfo.Begin(),
-                                       wordBreakInfo.Begin(),
-                                       ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
-                                       glyphs.Begin(),
-                                       glyphsToCharactersMap.Begin(),
-                                       charactersPerGlyph.Begin(),
-                                       charactersToGlyphBuffer,
-                                       glyphsPerCharacterBuffer,
-                                       totalNumberOfGlyphs );
+    Layout::Parameters layoutParameters( size,
+                                         textBuffer,
+                                         lineBreakInfo.Begin(),
+                                         wordBreakInfo.Begin(),
+                                         ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
+                                         glyphs.Begin(),
+                                         glyphsToCharactersMap.Begin(),
+                                         charactersPerGlyph.Begin(),
+                                         charactersToGlyphBuffer,
+                                         glyphsPerCharacterBuffer,
+                                         totalNumberOfGlyphs,
+                                         mImpl->mModel->mHorizontalAlignment );
 
     // Resize the vector of positions to have the same size than the vector of glyphs.
-    Vector<Vector2>& glyphPositions = mImpl->mVisualModel->mGlyphPositions;
+    Vector<Vector2>& glyphPositions = mImpl->mModel->mVisualModel->mGlyphPositions;
     glyphPositions.Resize( totalNumberOfGlyphs );
 
     // Whether the last character is a new paragraph character.
-    mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph =  TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mLogicalModel->mText.Count() - 1u ) ) );
+    mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph =  TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mModel->mLogicalModel->mText.Count() - 1u ) ) );
     layoutParameters.isLastNewParagraph = mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph;
 
     // The initial glyph and the number of glyphs to layout.
@@ -2583,8 +2602,9 @@ bool Controller::DoRelayout( const Size& size,
     Size newLayoutSize;
     viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
                                                    glyphPositions,
-                                                   mImpl->mVisualModel->mLines,
-                                                   newLayoutSize );
+                                                   mImpl->mModel->mVisualModel->mLines,
+                                                   newLayoutSize,
+                                                   mImpl->mModel->mElideEnabled );
 
     viewUpdated = viewUpdated || ( newLayoutSize != layoutSize );
 
@@ -2592,7 +2612,7 @@ bool Controller::DoRelayout( const Size& size,
     {
       layoutSize = newLayoutSize;
 
-      if ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) )
+      if( NO_OPERATION != ( UPDATE_DIRECTION & operations ) )
       {
         mImpl->mAutoScrollDirectionRTL = false;
       }
@@ -2600,21 +2620,21 @@ bool Controller::DoRelayout( const Size& size,
       // Reorder the lines
       if( NO_OPERATION != ( REORDER & operations ) )
       {
-        Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mLogicalModel->mBidirectionalParagraphInfo;
-        Vector<BidirectionalLineInfoRun>& bidirectionalLineInfo = mImpl->mLogicalModel->mBidirectionalLineInfo;
+        Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mModel->mLogicalModel->mBidirectionalParagraphInfo;
+        Vector<BidirectionalLineInfoRun>& bidirectionalLineInfo = mImpl->mModel->mLogicalModel->mBidirectionalLineInfo;
 
         // Check first if there are paragraphs with bidirectional info.
         if( 0u != bidirectionalInfo.Count() )
         {
           // Get the lines
-          const Length numberOfLines = mImpl->mVisualModel->mLines.Count();
+          const Length numberOfLines = mImpl->mModel->mVisualModel->mLines.Count();
 
           // Reorder the lines.
           bidirectionalLineInfo.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
           ReorderLines( bidirectionalInfo,
                         startIndex,
                         requestedNumberOfCharacters,
-                        mImpl->mVisualModel->mLines,
+                        mImpl->mModel->mVisualModel->mLines,
                         bidirectionalLineInfo );
 
           // Set the bidirectional info per line into the layout parameters.
@@ -2629,7 +2649,7 @@ bool Controller::DoRelayout( const Size& size,
 
           if ( ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) ) && ( numberOfLines > 0 ) )
           {
-            const LineRun* const firstline = mImpl->mVisualModel->mLines.Begin();
+            const LineRun* const firstline = mImpl->mModel->mVisualModel->mLines.Begin();
             if ( firstline )
             {
               mImpl->mAutoScrollDirectionRTL = firstline->direction;
@@ -2641,22 +2661,23 @@ bool Controller::DoRelayout( const Size& size,
       // Sets the layout size.
       if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
       {
-        mImpl->mVisualModel->SetLayoutSize( layoutSize );
+        mImpl->mModel->mVisualModel->SetLayoutSize( layoutSize );
       }
     } // view updated
 
     // Store the size used to layout the text.
-    mImpl->mVisualModel->mControlSize = size;
+    mImpl->mModel->mVisualModel->mControlSize = size;
   }
 
   if( NO_OPERATION != ( ALIGN & operations ) )
   {
     // The laid-out lines.
-    Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
+    Vector<LineRun>& lines = mImpl->mModel->mVisualModel->mLines;
 
     mImpl->mLayoutEngine.Align( size,
                                 startIndex,
                                 requestedNumberOfCharacters,
+                                mImpl->mModel->mHorizontalAlignment,
                                 lines );
 
     viewUpdated = true;
@@ -2672,7 +2693,7 @@ bool Controller::DoRelayout( const Size& size,
 
 void Controller::CalculateVerticalOffset( const Size& controlSize )
 {
-  Size layoutSize = mImpl->mVisualModel->GetLayoutSize();
+  Size layoutSize = mImpl->mModel->mVisualModel->GetLayoutSize();
 
   if( fabsf( layoutSize.height ) < Math::MACHINE_EPSILON_1000 )
   {
@@ -2680,21 +2701,21 @@ void Controller::CalculateVerticalOffset( const Size& controlSize )
     layoutSize.height = mImpl->GetDefaultFontLineHeight();
   }
 
-  switch( mImpl->mLayoutEngine.GetVerticalAlignment() )
+  switch( mImpl->mModel->mVerticalAlignment )
   {
-    case LayoutEngine::VERTICAL_ALIGN_TOP:
+    case Layout::VERTICAL_ALIGN_TOP:
     {
-      mImpl->mScrollPosition.y = 0.f;
+      mImpl->mModel->mScrollPosition.y = 0.f;
       break;
     }
-    case LayoutEngine::VERTICAL_ALIGN_CENTER:
+    case Layout::VERTICAL_ALIGN_CENTER:
     {
-      mImpl->mScrollPosition.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment.
+      mImpl->mModel->mScrollPosition.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment.
       break;
     }
-    case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
+    case Layout::VERTICAL_ALIGN_BOTTOM:
     {
-      mImpl->mScrollPosition.y = controlSize.height - layoutSize.height;
+      mImpl->mModel->mScrollPosition.y = controlSize.height - layoutSize.height;
       break;
     }
   }
@@ -2842,7 +2863,7 @@ bool Controller::BackspaceKeyEvent()
 
   if( removed )
   {
-    if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
+    if( ( 0u != mImpl->mModel->mLogicalModel->mText.Count() ) ||
         !mImpl->IsPlaceholderAvailable() )
     {
       mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
@@ -2863,7 +2884,7 @@ bool Controller::BackspaceKeyEvent()
 void Controller::ResetText()
 {
   // Reset buffers.
-  mImpl->mLogicalModel->mText.Clear();
+  mImpl->mModel->mLogicalModel->mText.Clear();
 
   // We have cleared everything including the placeholder-text
   mImpl->PlaceholderCleared();
@@ -2920,11 +2941,11 @@ void Controller::ShowPlaceholderText()
     mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
 
     // Reset model for showing placeholder.
-    mImpl->mLogicalModel->mText.Clear();
-    mImpl->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor );
+    mImpl->mModel->mLogicalModel->mText.Clear();
+    mImpl->mModel->mVisualModel->SetTextColor( mImpl->mEventData->mPlaceholderTextColor );
 
     // Convert text into UTF-32
-    Vector<Character>& utf32Characters = mImpl->mLogicalModel->mText;
+    Vector<Character>& utf32Characters = mImpl->mModel->mLogicalModel->mText;
     utf32Characters.Resize( size );
 
     // This is a bit horrible but std::string returns a (signed) char*
@@ -2962,7 +2983,7 @@ void Controller::ClearFontData()
   // Set flags to update the model.
   mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
   mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
-  mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mLogicalModel->mText.Count();
+  mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count();
 
   mImpl->mTextUpdateInfo.mClearAll = true;
   mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
@@ -2980,8 +3001,8 @@ void Controller::ClearFontData()
 
 void Controller::ClearStyleData()
 {
-  mImpl->mLogicalModel->mColorRuns.Clear();
-  mImpl->mLogicalModel->ClearFontDescriptionRuns();
+  mImpl->mModel->mLogicalModel->mColorRuns.Clear();
+  mImpl->mModel->mLogicalModel->ClearFontDescriptionRuns();
 }
 
 void Controller::ResetCursorPosition( CharacterIndex cursorIndex )
@@ -3004,7 +3025,7 @@ void Controller::ResetScrollPosition()
   if( NULL != mImpl->mEventData )
   {
     // Reset the scroll position.
-    mImpl->mScrollPosition = Vector2::ZERO;
+    mImpl->mModel->mScrollPosition = Vector2::ZERO;
     mImpl->mEventData->mScrollAfterUpdatePosition = true;
   }
 }
index a78d0eb..6f4b864 100644 (file)
@@ -26,6 +26,7 @@
 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
+#include <dali-toolkit/internal/text/text-model-interface.h>
 
 namespace Dali
 {
@@ -40,6 +41,7 @@ class Controller;
 class ControlInterface;
 class EditableControlInterface;
 class View;
+class RenderingController;
 
 typedef IntrusivePtr<Controller> ControllerPtr;
 
@@ -297,24 +299,40 @@ public: // Configure the text controller.
   bool IsMultiLineEnabled() const;
 
   /**
-   * @copydoc Dali::Toolkit::Text::LayoutEngine::SetHorizontalAlignment()
+   * @brief Sets the text's horizontal alignment.
+   *
+   * @param[in] alignment The horizontal alignment.
+   */
+  void SetHorizontalAlignment( Layout::HorizontalAlignment alignment );
+
+  /**
+   * @copydoc ModelInterface::GetHorizontalAlignment()
    */
-  void SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment );
+  Layout::HorizontalAlignment GetHorizontalAlignment() const;
 
   /**
-   * @copydoc Dali::Toolkit::Text::LayoutEngine::GetHorizontalAlignment()
+   * @brief Sets the text's vertical alignment.
+   *
+   * @param[in] alignment The vertical alignment.
    */
-  LayoutEngine::HorizontalAlignment GetHorizontalAlignment() const;
+  void SetVerticalAlignment( Layout::VerticalAlignment alignment );
 
   /**
-   * @copydoc Dali::Toolkit::Text::LayoutEngine::SetVerticalAlignment()
+   * @copydoc ModelInterface::GetVerticalAlignment()
    */
-  void SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment );
+  Layout::VerticalAlignment GetVerticalAlignment() const;
 
   /**
-   * @copydoc Dali::Toolkit::Text::LayoutEngine::GetVerticalAlignment()
+   * @brief Enable or disable the text elide.
+   *
+   * @param[in] enabled Whether to enable the text elide.
    */
-  LayoutEngine::VerticalAlignment GetVerticalAlignment() const;
+  void SetTextElideEnabled( bool enabled );
+
+  /**
+   * @copydoc ModelInterface::IsTextElideEnabled()
+   */
+  bool IsTextElideEnabled() const;
 
 public: // Update.
 
@@ -443,18 +461,18 @@ public: // Default style & Input style
   float GetDefaultPointSize() const;
 
   /**
-   * @brief Set the text color
+   * @brief Sets the text's default color.
    *
-   * @param textColor The text color
+   * @param color The default color.
    */
-  void SetTextColor( const Vector4& textColor );
+  void SetDefaultColor( const Vector4& color );
 
   /**
-   * @brief Retrieve the text color
+   * @brief Retrieves the text's default color.
    *
-   * @return The text color
+   * @return The default color.
    */
-  const Vector4& GetTextColor() const;
+  const Vector4& GetDefaultColor() const;
 
   /**
    * @brief Set the text color
@@ -770,7 +788,7 @@ public: // Queries & retrieves.
    *
    * @return A reference to the layout engine.
    */
-  LayoutEngine& GetLayoutEngine();
+  Layout::Engine& GetLayoutEngine();
 
   /**
    * @brief Return a view of the text.
@@ -780,13 +798,6 @@ public: // Queries & retrieves.
   View& GetView();
 
   /**
-   * @brief Query the current scroll position; the UI control is responsible for moving actors to this position.
-   *
-   * @return The scroll position.
-   */
-  const Vector2& GetScrollPosition() const;
-
-  /**
    * @copydoc Control::GetNaturalSize()
    */
   Vector3 GetNaturalSize();
@@ -796,6 +807,13 @@ public: // Queries & retrieves.
    */
   float GetHeightForWidth( float width );
 
+  /**
+   * @brief Retrieves the text's model.
+   *
+   * @return A pointer to the text's model.
+   */
+  const ModelInterface* const GetTextModel() const;
+
 public: // Relayout.
 
   /**
diff --git a/dali-toolkit/internal/text/text-model-interface.h b/dali-toolkit/internal/text/text-model-interface.h
new file mode 100644 (file)
index 0000000..e6b50c9
--- /dev/null
@@ -0,0 +1,155 @@
+#ifndef DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
+#define DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/math/vector2.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/layouts/layout-alignment.h>
+#include <dali-toolkit/internal/text/line-run.h>
+#include <dali-toolkit/internal/text/text-definitions.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+/**
+ * @brief Interface class used to retrieve the text's model from the text-controller.
+ */
+class ModelInterface
+{
+public:
+  /**
+   * @brief Virtual destructor.
+   */
+  virtual ~ModelInterface()
+  {}
+
+  /**
+   * @brief Retrives the control's size.
+   *
+   * @return The control's size.
+   */
+  virtual const Size& GetControlSize() const = 0;
+
+  /**
+   * @brief Retrives the layout's size.
+   *
+   * @return The layout's size.
+   */
+  virtual const Size& GetLayoutSize() const = 0;
+
+  /**
+   * @brief Retrieves the text's scroll position.
+   *
+   * @return The scroll position.
+   */
+  virtual const Vector2& GetScrollPosition() const = 0;
+
+  /**
+   * @brief Retrieves the text's horizontal alignment.
+   *
+   * @return The horizontal alignment.
+   */
+  virtual Layout::HorizontalAlignment GetHorizontalAlignment() const = 0;
+
+  /**
+   * @brief Retrieves the text's vertical alignment.
+   *
+   * @return The vertical alignment.
+   */
+  virtual Layout::VerticalAlignment GetVerticalAlignment() const = 0;
+
+  /**
+   * @brief Whether the text elide property is enabled.
+   *
+   * @return @e true if the text elide property is enabled, @e false otherwise.
+   */
+  virtual bool IsTextElideEnabled() const = 0;
+
+  /**
+   * @brief Retrieves the number of laid-out lines.
+   *
+   * @return The number of laid-out lines.
+   */
+  virtual Length GetNumberOfLines() const = 0;
+
+  /**
+   * @brief Retrieves the laid-out lines.
+   *
+   * @return A pointer to the vector with the laid-out lines.
+   */
+  virtual const LineRun* const GetLines() const = 0;
+
+  /**
+   * @brief Retrieves the number of laid-out glyphs.
+   *
+   * @return The number of laid-out glyphs.
+   */
+  virtual Length GetNumberOfGlyphs() const = 0;
+
+  /**
+   * @brief Retrieves the laid-out glyphs.
+   *
+   * @return A pointer to the vector with the laid-out glyphs.
+   */
+  virtual const GlyphInfo* const GetGlyphs() const = 0;
+
+  /**
+   * @brief Retrieves the text layout.
+   *
+   * @return A pointer to the vector with the positions for each glyph.
+   */
+  virtual const Vector2* const GetLayout() const = 0;
+
+  /**
+   * @brief Retrieves the vector of colors.
+   *
+   * @return Pointer to the vector of colors.
+   */
+  virtual const Vector4* const GetColors() const = 0;
+
+  /**
+   * @brief Retrieves the vector of indices to the vector of colors.
+   *
+   * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
+   */
+  virtual const ColorIndex* const GetColorIndices() const = 0;
+
+  /**
+   * @brief Retrieves the text's default color.
+   *
+   * @return The default color.
+   */
+  virtual const Vector4& GetDefaultColor() const = 0;
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
diff --git a/dali-toolkit/internal/text/text-model.cpp b/dali-toolkit/internal/text/text-model.cpp
new file mode 100644 (file)
index 0000000..eca74df
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/text/text-model.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+ModelPtr Model::New()
+{
+  return ModelPtr( new Model() );
+}
+
+const Size& Model::GetControlSize() const
+{
+  return mVisualModel->mControlSize;
+}
+
+const Size& Model::GetLayoutSize() const
+{
+  return mVisualModel->GetLayoutSize();
+}
+
+const Vector2& Model::GetScrollPosition() const
+{
+  return mScrollPosition;
+}
+
+Layout::HorizontalAlignment Model::GetHorizontalAlignment() const
+{
+  return mHorizontalAlignment;
+}
+
+Layout::VerticalAlignment Model::GetVerticalAlignment() const
+{
+  return mVerticalAlignment;
+}
+
+bool Model::IsTextElideEnabled() const
+{
+  return mElideEnabled;
+}
+
+Length Model::GetNumberOfLines() const
+{
+  return mVisualModel->mLines.Count();
+}
+
+const LineRun* const Model::GetLines() const
+{
+  return mVisualModel->mLines.Begin();
+}
+
+Length Model::GetNumberOfGlyphs() const
+{
+  return mVisualModel->mGlyphs.Count();
+}
+
+const GlyphInfo* const Model::GetGlyphs() const
+{
+  return mVisualModel->mGlyphs.Begin();
+}
+
+const Vector2* const Model::GetLayout() const
+{
+  return mVisualModel->mGlyphPositions.Begin();
+}
+
+const Vector4* const Model::GetColors() const
+{
+  return mVisualModel->mColors.Begin();
+}
+
+const ColorIndex* const Model::GetColorIndices() const
+{
+  return mVisualModel->mColorIndices.Begin();
+}
+
+const Vector4& Model::GetDefaultColor() const
+{
+  return mVisualModel->mTextColor;
+}
+
+Model::Model()
+: mLogicalModel(),
+  mVisualModel(),
+  mScrollPosition(),
+  mHorizontalAlignment( Layout::HORIZONTAL_ALIGN_BEGIN ),
+  mVerticalAlignment( Layout::VERTICAL_ALIGN_TOP ),
+  mElideEnabled( false )
+{
+  mLogicalModel = LogicalModel::New();
+  mVisualModel = VisualModel::New();
+}
+
+Model::~Model()
+{
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/text/text-model.h b/dali-toolkit/internal/text/text-model.h
new file mode 100644 (file)
index 0000000..765dd31
--- /dev/null
@@ -0,0 +1,170 @@
+#ifndef DALI_TOOLKIT_TEXT_MODEL_H
+#define DALI_TOOLKIT_TEXT_MODEL_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/ref-object.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/layouts/layout-alignment.h>
+#include <dali-toolkit/internal/text/logical-model-impl.h>
+#include <dali-toolkit/internal/text/text-model-interface.h>
+#include <dali-toolkit/internal/text/visual-model-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+// Forward declarations.
+class Model;
+
+typedef IntrusivePtr<Model> ModelPtr;
+
+/**
+ * @brief Implementation class used to retrieve the text's model from the text-controller.
+ */
+class Model : public RefObject, public ModelInterface
+{
+
+public: // Constructor.
+
+  /**
+   * @brief Create a new instance of a text Model.
+   *
+   * @return A pointer to a new text Model.
+   */
+  static ModelPtr New();
+
+public:
+
+  /**
+   * @copydoc ModelInterface::GetControlSize()
+   */
+  virtual const Size& GetControlSize() const;
+
+  /**
+   * @copydoc ModelInterface::GetLayoutSize()
+   */
+  virtual const Size& GetLayoutSize() const;
+
+  /**
+   * @copydoc ModelInterface::GetScrollPosition()
+   */
+  virtual const Vector2& GetScrollPosition() const;
+
+  /**
+   * @copydoc ModelInterface::GetHorizontalAlignment()
+   */
+  virtual Layout::HorizontalAlignment GetHorizontalAlignment() const;
+
+  /**
+   * @copydoc ModelInterface::GetVerticalAlignment()
+   */
+  virtual Layout::VerticalAlignment GetVerticalAlignment() const;
+
+  /**
+   * @copydoc ModelInterface::IsTextElideEnabled()
+   */
+  virtual bool IsTextElideEnabled() const;
+
+  /**
+   * @copydoc ModelInterface::GetNumberOfLines()
+   */
+  virtual Length GetNumberOfLines() const;
+
+  /**
+   * @copydoc ModelInterface::GetLines()
+   */
+  virtual const LineRun* const GetLines() const;
+
+  /**
+   * @copydoc ModelInterface::GetNumberOfGlyphs()
+   */
+  virtual Length GetNumberOfGlyphs() const;
+
+  /**
+   * @copydoc ModelInterface::GetGlyphs()
+   */
+  virtual const GlyphInfo* const GetGlyphs() const;
+
+  /**
+   * @copydoc ModelInterface::GetLayout()
+   */
+  virtual const Vector2* const GetLayout() const;
+
+  /**
+   * @copydoc ModelInterface::GetColors()
+   */
+  virtual const Vector4* const GetColors() const;
+
+  /**
+   * @copydoc ModelInterface::GetColorIndices()
+   */
+  virtual const ColorIndex* const GetColorIndices() const;
+
+  /**
+   * @copydoc ModelInterface::GetDefaultColor()
+   */
+  virtual const Vector4& GetDefaultColor() const;
+
+private: // Private contructors & copy operator.
+
+  /**
+   * @brief Private constructor.
+   */
+  Model();
+
+  // Undefined.
+  Model( const Model& handle );
+
+  // Undefined.
+  Model& operator=( const Model& handle );
+
+protected:
+
+  /**
+   * @brief A reference counted object may only be deleted by calling Unreference().
+   */
+  virtual ~Model();
+
+public:
+  LogicalModelPtr             mLogicalModel;        ///< Pointer to the logical model.
+  VisualModelPtr              mVisualModel;         ///< Pointer to the visual model.
+  /**
+   * 0,0 means that the top-left corner of the layout matches the top-left corner of the UI control.
+   * Typically this will have a negative value with scrolling occurs.
+   */
+  Vector2                     mScrollPosition;      ///< The text is offset by this position when scrolling.
+  Layout::HorizontalAlignment mHorizontalAlignment; ///< The layout's horizontal alignment.
+  Layout::VerticalAlignment   mVerticalAlignment;   ///< The layout's vertical alignment.
+  bool                        mElideEnabled:1;      ///< Whether the text's elide is enabled.
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_MODEL_H
index 31a0819..08b1153 100644 (file)
@@ -37,14 +37,10 @@ class ScrollerInterface
 public:
 
   /**
-   * @brief Constructor.
-   */
-  ScrollerInterface();
-
-  /**
    * @brief Virtual destructor.
    */
-  virtual ~ScrollerInterface();
+  virtual ~ScrollerInterface()
+  {}
 
   /**
    * @brief Called when the scrolling finishes
index c1faee7..92bc48d 100644 (file)
@@ -410,7 +410,8 @@ VisualModel::VisualModel()
   mTextColor( Color::BLACK ),
   mShadowColor( Color::BLACK ),
   mUnderlineColor( Color::BLACK ),
-  mShadowOffset( Vector2::ZERO ),
+  mControlSize(),
+  mShadowOffset(),
   mUnderlineHeight( 0.0f ),
   mNaturalSize(),
   mLayoutSize(),
index 7c1accb..b024307 100644 (file)
@@ -313,10 +313,10 @@ public:
   Vector<Vector4>        mColors;               ///< Colors of the glyphs.
   Vector<ColorIndex>     mColorIndices;         ///< Indices to the vector of colors for each glyphs.
 
-  Vector2                mControlSize;           ///< The size of the UI control the decorator is adding it's decorations to.
   Vector4                mTextColor;            ///< The text color
   Vector4                mShadowColor;          ///< Color of drop shadow
   Vector4                mUnderlineColor;       ///< Color of underline
+  Size                   mControlSize;          ///< The size of the UI control.
   Vector2                mShadowOffset;         ///< Offset for drop shadow, 0 indicates no shadow
   float                  mUnderlineHeight;      ///< Fixed height for underline to override font metrics.
 
index 4228ecf..b67617a 100644 (file)
 // CLASS HEADER
 #include <dali-toolkit/internal/visuals/text/text-visual.h>
 
-// EXTERNAL HEADER
-#include <dali/devel-api/scripting/enum-helper.h>
-// #include <dali/devel-api/scripting/scripting.h>
-
 // INTERNAL HEADER
-#include <dali-toolkit/public-api/text/rendering-backend.h>
-#include <dali-toolkit/public-api/visuals/text-visual-properties.h>
 #include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
-#include <dali-toolkit/internal/text/rendering/text-backend.h>
-#include <dali-toolkit/internal/text/text-view.h>
+#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/internal/text/text-font-style.h>
-#include <dali-toolkit/internal/text/text-effects-style.h>
-
-using Dali::Toolkit::Text::LayoutEngine;
 
 namespace Dali
 {
@@ -49,7 +42,6 @@ namespace
 {
 
 // Property names.
-const char * const RENDERING_BACKEND_PROPERTY( "renderingBackend" );
 const char * const TEXT_PROPERTY( "text" );
 const char * const FONT_FAMILY_PROPERTY( "fontFamily" );
 const char * const FONT_STYLE_PROPERTY( "fontStyle" );
@@ -59,46 +51,41 @@ const char * const HORIZONTAL_ALIGNMENT_PROPERTY( "horizontalAlignment" );
 const char * const VERTICAL_ALIGNMENT_PROPERTY( "verticalAlignment" );
 const char * const TEXT_COLOR_PROPERTY( "textColor" );
 const char * const ENABLE_MARKUP_PROPERTY( "enableMarkup" );
-const char * const ENABLE_AUTO_SCROLL_PROPERTY( "enableAutoScroll" );
-const char * const AUTO_SCROLL_SPEED_PROPERTY( "autoScrollSpeed" );
-const char * const AUTO_SCROLL_LOOP_COUNT_PROPERTY( "autoScrollLoopCount" );
-const char * const AUTO_SCROLL_GAP_PROPERTY( "autoScrollGap" );
-const char * const LINE_SPACING_PROPERTY( "lineSpacing" );
-const char * const UNDERLINE_PROPERTY( "underline" );
-const char * const SHADOW_PROPERTY( "shadow" );
-const char * const OUTLINE_PROPERTY( "outline" );
-const char * const BATCHING_ENABLED_PROPERTY( "batchingEnabled" );
+
+const std::string PIXEL_AREA_UNIFORM_NAME = "pixelArea";
 
 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
-  { "BEGIN",  Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN  },
-  { "CENTER", Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_CENTER },
-  { "END",    Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_END    },
+  { "BEGIN",  Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN  },
+  { "CENTER", Toolkit::Text::Layout::HORIZONTAL_ALIGN_CENTER },
+  { "END",    Toolkit::Text::Layout::HORIZONTAL_ALIGN_END    },
 };
 const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE ) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
 
 const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
 {
-  { "TOP",    Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_TOP    },
-  { "CENTER", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_CENTER },
-  { "BOTTOM", Toolkit::Text::LayoutEngine::VERTICAL_ALIGN_BOTTOM },
+  { "TOP",    Toolkit::Text::Layout::VERTICAL_ALIGN_TOP    },
+  { "CENTER", Toolkit::Text::Layout::VERTICAL_ALIGN_CENTER },
+  { "BOTTOM", Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM },
 };
 const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof( VERTICAL_ALIGNMENT_STRING_TABLE ) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
 
-std::string GetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
+const Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f );
+
+std::string GetHorizontalAlignment( Toolkit::Text::Layout::HorizontalAlignment alignment )
 {
-  const char* name = Scripting::GetEnumerationName<Toolkit::Text::LayoutEngine::HorizontalAlignment>( alignment,
-                                                                                                      HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                                      HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+  const char* name = Scripting::GetEnumerationName<Toolkit::Text::Layout::HorizontalAlignment>( alignment,
+                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
 
   return std::string( name );
 }
 
-std::string GetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
+std::string GetVerticalAlignment( Toolkit::Text::Layout::VerticalAlignment alignment )
 {
-  const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( alignment,
-                                                                                                      VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                                                      VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+  const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( alignment,
+                                                                                                VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                                VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
 
   return std::string( name );
 }
@@ -110,12 +97,24 @@ const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
   uniform mediump vec4 pixelArea;
   varying mediump vec2 vTexCoord;\n
   \n
+
+  //Visual size and offset
+  uniform mediump vec2 offset;\n
+  uniform mediump vec2 size;\n
+  uniform mediump vec4 offsetSizeMode;\n
+  uniform mediump vec2 origin;\n
+  uniform mediump vec2 anchorPoint;\n
+
+  vec4 ComputeVertexPosition()\n
+  {\n
+    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
+    vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
+    return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
+  }\n
+
   void main()\n
   {\n
-    mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
-    vertexPosition.xyz *= uSize;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-    \n
+    mediump vec4 vertexPosition = uMvpMatrix *ComputeVertexPosition();\n
     vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n
     gl_Position = vertexPosition;\n
   }\n
@@ -134,27 +133,6 @@ const char* FRAGMENT_SHADER_ATLAS_CLAMP = DALI_COMPOSE_SHADER(
     }\n
 );
 
-Geometry CreateGeometry( VisualFactoryCache& factoryCache, ImageDimensions gridSize )
-{
-  Geometry geometry;
-
-  if( gridSize == ImageDimensions( 1, 1 ) )
-  {
-    geometry = factoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
-    if( !geometry )
-    {
-      geometry =  VisualFactoryCache::CreateQuadGeometry();
-      factoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry );
-    }
-  }
-  else
-  {
-    geometry = VisualFactoryCache::CreateGridGeometry( gridSize );
-  }
-
-  return geometry;
-}
-
 } // unnamed namespace
 
 TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache )
@@ -177,9 +155,7 @@ void TextVisual::DoCreatePropertyMap( Property::Map& map ) const
   Property::Value value;
 
   map.Clear();
-  map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::TEXT );
-
-  map.Insert( Toolkit::TextVisual::Property::RENDERING_BACKEND, mRenderingBackend );
+  map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::DevelVisual::TEXT );
 
   std::string text;
   mController->GetText( text );
@@ -198,29 +174,15 @@ void TextVisual::DoCreatePropertyMap( Property::Map& map ) const
 
   map.Insert( Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT, GetVerticalAlignment( mController->GetVerticalAlignment() ) );
 
-  map.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, mController->GetTextColor() );
+  map.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, mController->GetDefaultColor() );
 
   map.Insert( Toolkit::TextVisual::Property::ENABLE_MARKUP, mController->IsMarkupProcessorEnabled() );
-
-  map.Insert( Toolkit::TextVisual::Property::LINE_SPACING, mController->GetDefaultLineSpacing() );
-
-  GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT );
-  map.Insert( Toolkit::TextVisual::Property::UNDERLINE, value );
-
-  GetShadowProperties( mController, value, Text::EffectStyle::DEFAULT );
-  map.Insert( Toolkit::TextVisual::Property::SHADOW, value );
-
-  GetOutlineProperties( mController, value, Text::EffectStyle::DEFAULT );
-  map.Insert( Toolkit::TextVisual::Property::OUTLINE, value );
-
-  map.Insert( Toolkit::TextVisual::Property::BATCHING_ENABLED, false ); // TODO
 }
 
 TextVisual::TextVisual( VisualFactoryCache& factoryCache )
 : Visual::Base( factoryCache ),
   mController( Text::Controller::New() ),
-  mRenderingBackend( Toolkit::Text::DEFAULT_RENDERING_BACKEND ),
-  mHasBeenStaged( false )
+  mTypesetter( Text::Typesetter::New( mController->GetTextModel() ) )
 {
 }
 
@@ -246,11 +208,7 @@ void TextVisual::DoSetProperties( const Property::Map& propertyMap )
       }
       case Property::Key::STRING:
       {
-        if( keyValue.first.stringKey == RENDERING_BACKEND_PROPERTY )
-        {
-          DoSetProperty( Toolkit::TextVisual::Property::RENDERING_BACKEND, keyValue.second );
-        }
-        else if( keyValue.first.stringKey == TEXT_PROPERTY )
+        if( keyValue.first.stringKey == TEXT_PROPERTY )
         {
           DoSetProperty( Toolkit::TextVisual::Property::TEXT, keyValue.second );
         }
@@ -286,52 +244,16 @@ void TextVisual::DoSetProperties( const Property::Map& propertyMap )
         {
           DoSetProperty( Toolkit::TextVisual::Property::ENABLE_MARKUP, keyValue.second );
         }
-        else if( keyValue.first.stringKey == ENABLE_AUTO_SCROLL_PROPERTY )
-        {
-          DoSetProperty( Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL, keyValue.second );
-        }
-        else if( keyValue.first.stringKey == AUTO_SCROLL_SPEED_PROPERTY )
-        {
-          DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED, keyValue.second );
-        }
-        else if( keyValue.first.stringKey == AUTO_SCROLL_LOOP_COUNT_PROPERTY )
-        {
-          DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT, keyValue.second );
-        }
-        else if( keyValue.first.stringKey == AUTO_SCROLL_GAP_PROPERTY )
-        {
-          DoSetProperty( Toolkit::TextVisual::Property::AUTO_SCROLL_GAP, keyValue.second );
-        }
-        else if( keyValue.first.stringKey == LINE_SPACING_PROPERTY )
-        {
-          DoSetProperty( Toolkit::TextVisual::Property::LINE_SPACING, keyValue.second );
-        }
-        else if( keyValue.first.stringKey == UNDERLINE_PROPERTY )
-        {
-          DoSetProperty( Toolkit::TextVisual::Property::UNDERLINE, keyValue.second );
-        }
-        else if( keyValue.first.stringKey == SHADOW_PROPERTY )
-        {
-          DoSetProperty( Toolkit::TextVisual::Property::SHADOW, keyValue.second );
-        }
-        else if( keyValue.first.stringKey == OUTLINE_PROPERTY )
-        {
-          DoSetProperty( Toolkit::TextVisual::Property::OUTLINE, keyValue.second );
-        }
-        else if( keyValue.first.stringKey == BATCHING_ENABLED_PROPERTY )
-        {
-          DoSetProperty( Toolkit::TextVisual::Property::BATCHING_ENABLED, keyValue.second );
-        }
         break;
       }
     }
   }
 
-  // Retrieve the layout engine to set whether to elide the text and set the cursor's width.
-  Text::LayoutEngine& engine = mController->GetLayoutEngine();
-
   // Elide the text if it exceeds the boundaries.
-  engine.SetTextEllipsisEnabled( true );
+  mController->SetTextElideEnabled( true );
+
+  // Retrieve the layout engine to set the cursor's width.
+  Text::Layout::Engine& engine = mController->GetLayoutEngine();
 
   // Sets 0 as cursor's width.
   engine.SetCursorWidth( 0u ); // Do not layout space for the cursor.
@@ -339,64 +261,29 @@ void TextVisual::DoSetProperties( const Property::Map& propertyMap )
 
 void TextVisual::DoSetOnStage( Actor& actor )
 {
-  // TODO Create the actual renderer(s) for the text!!!!
-  //      Will crash if no mImpl->mRenderer is set.
-  Geometry geometry;
-  Shader shader;
+  mControl = actor;
 
-  geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) );
+  CreateRenderer();
+}
 
-  shader = mFactoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
-  if( !shader )
+void TextVisual::DoSetOffStage( Actor& actor )
+{
+  if( mImpl->mRenderer )
   {
-    shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
-    mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
-  }
+    // Removes the renderer from the actor.
+    actor.RemoveRenderer( mImpl->mRenderer );
 
-  mImpl->mRenderer = Renderer::New( geometry, shader );
-
-  mSelf = actor;
-
-  if( mHasBeenStaged )
-  {
-    RenderText();
+    DestroyRenderer();
   }
-  else
-  {
-    mHasBeenStaged = true;
-  }
-}
 
-void TextVisual::DoSetOffStage( Actor& actor )
-{
-  mSelf.Reset();
+  // Resets the control handle.
+  mControl.Reset();
 }
 
 void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
 {
   switch( index )
   {
-    case Toolkit::TextVisual::Property::RENDERING_BACKEND:
-    {
-      int backend = propertyValue.Get<int>();
-
-#ifndef ENABLE_VECTOR_BASED_TEXT_RENDERING
-      if( Text::RENDERING_VECTOR_BASED == backend )
-      {
-        backend = TextAbstraction::BITMAP_GLYPH; // Fallback to bitmap-based rendering
-      }
-#endif
-      if( mRenderingBackend != backend )
-      {
-        mRenderingBackend = backend;
-        mRenderer.Reset();
-
-        // When using the vector-based rendering, the size of the GLyphs are different
-        TextAbstraction::GlyphType glyphType = ( Text::RENDERING_VECTOR_BASED == mRenderingBackend ) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
-        mController->SetGlyphType( glyphType );
-      }
-      break;
-    }
     case Toolkit::TextVisual::Property::TEXT:
     {
       mController->SetText( propertyValue.Get<std::string>() );
@@ -429,11 +316,11 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
     }
     case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT:
     {
-      LayoutEngine::HorizontalAlignment alignment( LayoutEngine::HORIZONTAL_ALIGN_BEGIN );
-      if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::HorizontalAlignment >( propertyValue.Get< std::string >().c_str(),
-                                                                                         HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                         HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
-                                                                                         alignment ) )
+      Toolkit::Text::Layout::HorizontalAlignment alignment( Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN );
+      if( Scripting::GetEnumeration< Toolkit::Text::Layout::HorizontalAlignment >( propertyValue.Get< std::string >().c_str(),
+                                                                                   HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                   HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                                   alignment ) )
       {
         mController->SetHorizontalAlignment( alignment );
       }
@@ -441,11 +328,11 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
     }
     case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT:
     {
-      LayoutEngine::VerticalAlignment alignment( LayoutEngine::VERTICAL_ALIGN_BOTTOM );
-      if( Scripting::GetEnumeration< Toolkit::Text::LayoutEngine::VerticalAlignment >( propertyValue.Get< std::string >().c_str(),
-                                                                                       VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                                       VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
-                                                                                       alignment ) )
+      Toolkit::Text::Layout::VerticalAlignment alignment( Toolkit::Text::Layout::VERTICAL_ALIGN_BOTTOM );
+      if( Scripting::GetEnumeration< Toolkit::Text::Layout::VerticalAlignment >( propertyValue.Get< std::string >().c_str(),
+                                                                                 VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                 VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
+                                                                                 alignment ) )
       {
         mController->SetVerticalAlignment( alignment );
       }
@@ -453,11 +340,10 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
     }
     case Toolkit::TextVisual::Property::TEXT_COLOR:
     {
-      const Vector4 textColor = propertyValue.Get< Vector4 >();
-      if( mController->GetTextColor() != textColor )
+      const Vector4& textColor = propertyValue.Get< Vector4 >();
+      if( mController->GetDefaultColor() != textColor )
       {
-        mController->SetTextColor( textColor );
-        mRenderer.Reset();
+        mController->SetDefaultColor( textColor );
       }
       break;
     }
@@ -467,153 +353,6 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
       mController->SetMarkupProcessorEnabled( enableMarkup );
       break;
     }
-    case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL:
-    {
-      // nothing to do.
-      break;
-    }
-    case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED:
-    {
-      // nothing to do.
-      break;
-    }
-    case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT:
-    {
-      // nothing to do.
-      break;
-    }
-    case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP:
-    {
-      // nothing to do.
-      break;
-    }
-    case Toolkit::TextVisual::Property::LINE_SPACING:
-    {
-      const float lineSpacing = propertyValue.Get<float>();
-      mController->SetDefaultLineSpacing( lineSpacing );
-      mRenderer.Reset();
-      break;
-    }
-    case Toolkit::TextVisual::Property::UNDERLINE:
-    {
-      // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed.
-      //        Only the code for the MAP case should be kept.
-      switch( propertyValue.GetType() )
-      {
-        case Property::VECTOR4:
-        {
-          const Vector4 color = propertyValue.Get<Vector4>();
-          if( mController->GetUnderlineColor() != color )
-          {
-            mController->SetUnderlineColor( color );
-            mRenderer.Reset();
-          }
-          break;
-        }
-        case Property::FLOAT:
-        {
-          float height = propertyValue.Get<float>();
-          if( fabsf( mController->GetUnderlineHeight() - height ) > Math::MACHINE_EPSILON_1000 )
-          {
-            mController->SetUnderlineHeight( height );
-            mRenderer.Reset();
-          }
-          break;
-        }
-        case Property::BOOLEAN:
-        {
-          const bool enabled = propertyValue.Get<bool>();
-          if( mController->IsUnderlineEnabled() != enabled )
-          {
-            mController->SetUnderlineEnabled( enabled );
-            mRenderer.Reset();
-          }
-          break;
-        }
-        case Property::MAP:
-        {
-          const bool update = SetUnderlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
-          if( update )
-          {
-            mRenderer.Reset();
-          }
-          break;
-        }
-        default:
-        {
-          // Nothing to do.
-          break;
-        }
-      }
-
-      break;
-    }
-    case Toolkit::TextVisual::Property::SHADOW:
-    {
-      // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed.
-      //        Only the code for the MAP case should be kept.
-      switch( propertyValue.GetType() )
-      {
-        case Property::VECTOR2:
-        {
-          const Vector2 shadowOffset = propertyValue.Get<Vector2>();
-          if( mController->GetShadowOffset() != shadowOffset )
-          {
-            mController->SetShadowOffset( shadowOffset );
-            mRenderer.Reset();
-          }
-          break;
-        }
-        case Property::VECTOR4:
-        {
-          const Vector4 shadowColor = propertyValue.Get<Vector4>();
-          if( mController->GetShadowColor() != shadowColor )
-          {
-            mController->SetShadowColor( shadowColor );
-            mRenderer.Reset();
-          }
-          break;
-        }
-        case Property::MAP:
-        {
-          const bool update = SetShadowProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
-          if( update )
-          {
-            mRenderer.Reset();
-          }
-          break;
-        }
-        default:
-        {
-          // Nothing to do.
-          break;
-        }
-      }
-      break;
-    }
-    case Toolkit::TextVisual::Property::EMBOSS:
-    {
-      const bool update = SetEmbossProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
-      if( update )
-      {
-        mRenderer.Reset();
-     }
-      break;
-    }
-    case Toolkit::TextVisual::Property::OUTLINE:
-    {
-      const bool update = SetOutlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
-      if( update )
-      {
-        mRenderer.Reset();
-      }
-      break;
-    }
-    case Toolkit::TextVisual::Property::BATCHING_ENABLED:
-    {
-      // TODO
-      break;
-    }
     default:
     {
       // Should not arrive here.
@@ -628,11 +367,6 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index )
 
   switch( index )
   {
-    case Toolkit::TextVisual::Property::RENDERING_BACKEND:
-    {
-      value = mRenderingBackend;
-      break;
-    }
     case Toolkit::TextVisual::Property::TEXT:
     {
       std::string text;
@@ -662,9 +396,9 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index )
     }
     case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT:
     {
-      const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( mController->GetHorizontalAlignment(),
-                                                                                                            HORIZONTAL_ALIGNMENT_STRING_TABLE,
-                                                                                                            HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
+      const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::HorizontalAlignment >( mController->GetHorizontalAlignment(),
+                                                                                                      HORIZONTAL_ALIGNMENT_STRING_TABLE,
+                                                                                                      HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
       if( name )
       {
         value = std::string( name );
@@ -673,9 +407,9 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index )
     }
     case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT:
     {
-      const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( mController->GetVerticalAlignment(),
-                                                                                                          VERTICAL_ALIGNMENT_STRING_TABLE,
-                                                                                                          VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
+      const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( mController->GetVerticalAlignment(),
+                                                                                                    VERTICAL_ALIGNMENT_STRING_TABLE,
+                                                                                                    VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
       if( name )
       {
         value = std::string( name );
@@ -684,7 +418,7 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index )
     }
     case Toolkit::TextVisual::Property::TEXT_COLOR:
     {
-      value = mController->GetTextColor();
+      value = mController->GetDefaultColor();
       break;
     }
     case Toolkit::TextVisual::Property::ENABLE_MARKUP:
@@ -692,56 +426,6 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index )
       value = mController->IsMarkupProcessorEnabled();
       break;
     }
-    case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL:
-    {
-      // nothing to do.
-      break;
-    }
-    case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED:
-    {
-      // nothing to do.
-      break;
-    }
-    case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT:
-    {
-      // nothing to do.
-      break;
-    }
-    case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP:
-    {
-      // nothing to do.
-      break;
-    }
-    case Toolkit::TextVisual::Property::LINE_SPACING:
-    {
-      value = mController->GetDefaultLineSpacing();
-      break;
-    }
-    case Toolkit::TextVisual::Property::UNDERLINE:
-    {
-      GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT );
-      break;
-    }
-    case Toolkit::TextVisual::Property::SHADOW:
-    {
-      GetShadowProperties( mController, value, Text::EffectStyle::DEFAULT );
-      break;
-    }
-    case Toolkit::TextVisual::Property::EMBOSS:
-    {
-      GetEmbossProperties( mController, value, Text::EffectStyle::DEFAULT );
-      break;
-    }
-    case Toolkit::TextVisual::Property::OUTLINE:
-    {
-      GetOutlineProperties( mController, value, Text::EffectStyle::DEFAULT );
-      break;
-    }
-    case Toolkit::TextVisual::Property::BATCHING_ENABLED:
-    {
-      // TODO
-      break;
-    }
     default:
     {
       // Should not arrive here.
@@ -754,55 +438,123 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index )
 
 void TextVisual::OnSetTransform()
 {
-  Vector2 visualSize = mImpl->mTransform.GetVisualSize( mImpl->mControlSize );
+  CreateRenderer();
+}
 
-  // Note, the direction should come from the layout of the parent control
-  mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
+void TextVisual::CreateRenderer()
+{
+  Actor control = mControl.GetHandle();
+  if( !control )
+  {
+    // Nothing to do.
+    return;
+  }
+
+  // Calculates the size to be used to relayout.
+  Vector2 relayoutSize;
+
+  const bool isWidthRelative = fabsf( mImpl->mTransform.mOffsetSizeMode.z ) < Math::MACHINE_EPSILON_1000;
+  const bool isHeightRelative = fabsf( mImpl->mTransform.mOffsetSizeMode.w ) < Math::MACHINE_EPSILON_1000;
 
-  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( visualSize );
+  // Round the size and offset to avoid pixel alignement issues.
+  relayoutSize.width = floorf( 0.5f + ( isWidthRelative ? mImpl->mControlSize.width * mImpl->mTransform.mSize.x : mImpl->mTransform.mSize.width ) );
+  relayoutSize.height = floorf( 0.5f + ( isHeightRelative ? mImpl->mControlSize.height * mImpl->mTransform.mSize.y : mImpl->mTransform.mSize.height ) );
 
-  if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) ||
-      !mRenderer )
+  if( ( fabsf( relayoutSize.width ) < Math::MACHINE_EPSILON_1000 ) || ( fabsf( relayoutSize.height ) < Math::MACHINE_EPSILON_1000 ) )
   {
-    if( !mRenderer )
+    // Remove any renderer previously set.
+    if( mImpl->mRenderer )
     {
-      mRenderer = Text::Backend::Get().NewRenderer( mRenderingBackend );
+      control.RemoveRenderer( mImpl->mRenderer );
+
+      DestroyRenderer();
     }
-    RenderText();
-  }
-}
 
-void TextVisual::RenderText()
-{
-  Actor self = mSelf.GetHandle();
-  if( !self )
-  {
-    // Nothing to do if the handle is not initialized.
+    // Nothing else to do if the relayout size is zero.
     return;
   }
 
-  Actor renderableActor;
+  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( relayoutSize );
 
-  if( mRenderer )
+  if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
   {
-    renderableActor = mRenderer->Render( mController->GetView(), Toolkit::DepthIndex::TEXT );
-  }
+    // Remove any renderer previously set.
+    if( mImpl->mRenderer )
+    {
+      control.RemoveRenderer( mImpl->mRenderer );
 
-  if( renderableActor != mRenderableActor )
-  {
-    UnparentAndReset( mRenderableActor );
+      DestroyRenderer();
+    }
 
-    if( renderableActor )
+    if( ( relayoutSize.width > Math::MACHINE_EPSILON_1000 ) &&
+        ( relayoutSize.height > Math::MACHINE_EPSILON_1000 ) )
     {
-      const Vector2& scrollOffset = mController->GetScrollPosition();
-      renderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
+      PixelData data = mTypesetter->Render( relayoutSize );
+
+      Geometry geometry;
+      Shader shader;
+      TextureSet textureSet;
+
+      Vector4 atlasRect;
+
+      textureSet = mFactoryCache.GetAtlasManager()->Add( atlasRect, data );
+      mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
+
+      // Filter mode needs to be set to nearest to avoid blurry text.
+      Sampler sampler = Sampler::New();
+      sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
+      textureSet.SetSampler( 0u, sampler );
+
+      geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
+      if( !geometry )
+      {
+        geometry =  VisualFactoryCache::CreateQuadGeometry();
+        mFactoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY , geometry );
+      }
+
+      shader = mFactoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
+      if( !shader )
+      {
+        shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
+        mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
+      }
+      shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
 
-      self.Add( renderableActor );
+      mImpl->mRenderer = Renderer::New( geometry, shader );
+      mImpl->mRenderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, Toolkit::DepthIndex::TEXT );
+      mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, atlasRect );
+
+      mImpl->mRenderer.SetTextures( textureSet );
+
+      control.AddRenderer( mImpl->mRenderer );
+
+      //Register transform properties
+      mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
+
+      mImpl->mFlags |= Impl::IS_FROM_CACHE;
     }
-    mRenderableActor = renderableActor;
   }
 }
 
+void TextVisual::DestroyRenderer()
+{
+  // Removes the text's image from the texture atlas.
+  Vector4 atlasRect;
+
+  const Property::Index index = mImpl->mRenderer.GetPropertyIndex( ATLAS_RECT_UNIFORM_NAME );
+  if( index != Property::INVALID_INDEX )
+  {
+    const Property::Value& atlasRectValue = mImpl->mRenderer.GetProperty( index );
+    atlasRectValue.Get( atlasRect );
+
+    const TextureSet& textureSet = mImpl->mRenderer.GetTextures();
+    mFactoryCache.GetAtlasManager()->Remove( textureSet, atlasRect );
+  }
+
+  // Resets the renderer.
+  mImpl->mRenderer.Reset();
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index b345c76..777729b 100644 (file)
  *
  */
 
-// EXTERNAL INCLUDES
-#include <dali/devel-api/object/weak-handle.h>
-#include <dali/public-api/common/intrusive-ptr.h>
-
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
-#include <dali-toolkit/internal/text/rendering/text-renderer.h>
+#include <dali-toolkit/internal/text/rendering/text-typesetter.h>
 #include <dali-toolkit/internal/text/text-controller.h>
 
 namespace Dali
@@ -145,20 +141,19 @@ protected:
 private:
 
   /**
-   * @brief Render view, create and attach actor(s) to this TextView.
-   * @todo In a next patch a new text render back-end won't add extra actors.
+   * @brief Creates the text's renderer.
    */
-  void RenderText();
-
-private:
-  Text::ControllerPtr          mController;               ///< The text's controller.
-  WeakHandle<Actor>            mSelf;
+  void CreateRenderer();
 
-  Text::RendererPtr            mRenderer;
-  Actor                        mRenderableActor;
+  /**
+   * @brief Destroys the text's renderer.
+   */
+  void DestroyRenderer();
 
-  int mRenderingBackend;
-  bool mHasBeenStaged           : 1;
+private:
+  Text::ControllerPtr mController; ///< The text's controller.
+  Text::TypesetterPtr mTypesetter; ///< The text's typesetter.
+  WeakHandle<Actor>   mControl;    ///< The control where the renderer is added.
 };
 
 } // namespace Internal
index 43c5077..d2e9ee2 100644 (file)
@@ -29,6 +29,7 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
 #include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/visuals/border/border-visual.h>
 #include <dali-toolkit/internal/visuals/color/color-visual.h>
 #include <dali-toolkit/internal/visuals/gradient/gradient-visual.h>
@@ -107,7 +108,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property
   else
   {
     Property::Value* typeValue = propertyMap.Find( Toolkit::VisualProperty::TYPE, VISUAL_TYPE );
-    Toolkit::Visual::Type visualType = Toolkit::Visual::IMAGE; // Default to IMAGE type.
+    Toolkit::DevelVisual::Type visualType = Toolkit::DevelVisual::IMAGE; // Default to IMAGE type.
     if( typeValue )
     {
       Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, visualType );
@@ -191,7 +192,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property
         break;
       }
 
-      case Toolkit::Visual::TEXT:
+      case Toolkit::DevelVisual::TEXT:
       {
         visualPtr = TextVisual::New( *( mFactoryCache.Get() ) );
         break;
index a4e4e56..861f2de 100755 (executable)
@@ -119,5 +119,4 @@ public_api_visuals_header_files = \
   $(public_api_src_dir)/visuals/image-visual-properties.h \
   $(public_api_src_dir)/visuals/mesh-visual-properties.h \
   $(public_api_src_dir)/visuals/primitive-visual-properties.h \
-  $(public_api_src_dir)/visuals/text-visual-properties.h \
   $(public_api_src_dir)/visuals/visual-properties.h
diff --git a/dali-toolkit/public-api/visuals/text-visual-properties.h b/dali-toolkit/public-api/visuals/text-visual-properties.h
deleted file mode 100644 (file)
index 0e2dd5d..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-#ifndef DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H
-#define DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/toolkit-property-index-ranges.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace TextVisual
-{
-
-namespace Property
-{
-
-enum
-{
-  /**
-   * @brief The type of rendering e.g. bitmap-based
-   * @details name "renderingBackend", type INTEGER, default RENDERING_SHARED_ATLAS
-   * @SINCE_1_2.11
-   */
-  RENDERING_BACKEND = VISUAL_PROPERTY_START_INDEX,
-
-  /**
-   * @brief The text to display in UTF-8 format,
-   * @details name "text", type STRING
-   * @SINCE_1_2.11
-   */
-  TEXT,
-
-  /**
-   * @brief The requested font family to use,
-   * @details name "fontFamily", type STRING
-   * @SINCE_1_2.11
-   */
-  FONT_FAMILY,
-
-  /**
-   * @brief The requested font style to use,
-   * @details name "fontStyle", type STRING or MAP
-   * @SINCE_1_2.13
-   */
-  FONT_STYLE,
-
-  /**
-   * @brief The size of font in points
-   * @details name "pointSize", type FLOAT
-   * @SINCE_1_2.11
-   */
-  POINT_SIZE,
-
-  /**
-   * @brief The single-line or multi-line layout option
-   * @details name "multiLine", type BOOLEAN, default false
-   * @SINCE_1_2.11
-   */
-  MULTI_LINE,
-
-  /**
-   * @brief The line horizontal alignment
-   * @details name "horizontalAlignment", type STRING,  values "BEGIN", "CENTER", "END", default BEGIN
-   * @SINCE_1_2.11
-   */
-  HORIZONTAL_ALIGNMENT,
-
-  /**
-   * @brief The line vertical alignment
-   * @details name "verticalAlignment", type STRING,  values "TOP",   "CENTER", "BOTTOM", default TOP
-   * @SINCE_1_2.11
-   */
-  VERTICAL_ALIGNMENT,
-
-  /**
-   * @brief The color of the text
-   * @details name "textColor", type VECTOR4
-   * @SINCE_1_2.11
-   */
-  TEXT_COLOR,
-
-  /**
-   * @brief  Whether the mark-up processing is enabled
-   * @details name "enableMarkup", type BOOLEAN
-   * @SINCE_1_2.11
-   */
-  ENABLE_MARKUP,
-
-  /**
-   * @brief  Start or stop auto scrolling,
-   * @details name "enableAutoScroll", type BOOLEAN, default is false
-   * @SINCE_1_2.11
-   */
-  ENABLE_AUTO_SCROLL,
-
-  /**
-   * @brief Sets the speed of scrolling in pixels per second,
-   * @details name "autoScrollSpeed", type INTEGER, default in style sheet
-   * @SINCE_1_2.11
-   */
-  AUTO_SCROLL_SPEED,
-
-  /**
-   * @brief  Number of complete loops when scrolling enabled
-   * @details name "autoScrollLoopCount", type INTEGER, default in style sheet
-   * @SINCE_1_2.11
-   */
-  AUTO_SCROLL_LOOP_COUNT,
-
-  /**
-   * @brief  Gap before before scrolling wraps
-   * @details name "autoScrollGap", type INTEGER, default in style sheet but can be overridden to prevent same text being show at start and end.
-   * @SINCE_1_2.11
-   */
-  AUTO_SCROLL_GAP,
-
-  /**
-   * @brief The default extra space between lines in points.
-   * @details name "lineSpacing", type FLOAT.
-   * @SINCE_1_2.11
-   */
-  LINE_SPACING,
-
-  /**
-   * @brief The default underline parameters.
-   * @details name "underline", type STRING or MAP.
-   * @SINCE_1_2.13
-   */
-  UNDERLINE,
-
-  /**
-   * @brief The default shadow parameters.
-   * @details name "shadow", type STRING or MAP.
-   * @SINCE_1_2.13
-   */
-  SHADOW,
-
-  /**
-   * @brief The default emboss parameters.
-   * @details name "emboss", type STRING or MAP.
-   * @SINCE_1_2.13
-   */
-  EMBOSS,
-
-  /**
-   * @brief The default outline parameters.
-   * @details name "outline", type STRING or MAP.
-   * @SINCE_1_2.13
-   */
-  OUTLINE,
-
-  /**
-   * @brief This enables Text visuals to automatically be converted to Batch-Text visuals.
-   * @details Name "batchingEnabled", type Property::BOOLEAN.
-   * @SINCE_1_2.11
-   * @note Optional. If not specified, the default is false.
-   */
-  BATCHING_ENABLED,
-};
-
-} // namespace Property
-
-} // namespace TextVisual
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // DALI_TOOLKIT_TEXT_VISUAL_PROPERTIES_H
index ef07c89..c4f5cb2 100644 (file)
@@ -42,8 +42,7 @@ enum Type
   IMAGE, ///< Renders an image into the control's quad. @SINCE_1_1.45
   MESH, ///< Renders a mesh using an "obj" file, optionally with textures provided by an "mtl" file. @SINCE_1_1.45
   PRIMITIVE, ///< Renders a simple 3D shape, such as a cube or sphere. @SINCE_1_1.45
-  WIREFRAME, ///< Renders a simple wire-frame outlining a quad. @SINCE_1_2_2
-  TEXT, ///< Renders text. @SINCE_1_2.11
+  WIREFRAME ///< Renders a simple wire-frame outlining a quad. @SINCE_1_2_2
 };
 
 namespace Property