ModelView implementation. 49/86349/14
authorVictor Cebollada <v.cebollada@samsung.com>
Fri, 26 Aug 2016 13:53:09 +0000 (14:53 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Mon, 21 Nov 2016 10:54:21 +0000 (10:54 +0000)
* Creates an interface to access the text's model from the text rendering modules.
* In the case the text is elided, it stores a copy of the elided text,
  the ellipsis glyph and the modified layout.
* It creates a basic Text::RenderingController class which stores the
  pointer to the text's model.

Change-Id: Ied29583a0e1648dab9d78575dcbc042353c949dc
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
36 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/utc-Dali-TextEditor.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/file.list
dali-toolkit/internal/text/layouts/layout-alignment.h [new file with mode: 0644]
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/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/visual-model-impl.cpp
dali-toolkit/internal/text/visual-model-impl.h
dali-toolkit/internal/visuals/text/text-visual.cpp

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..a0a3be9 100644 (file)
@@ -23,6 +23,7 @@
 
 #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>
@@ -45,32 +46,6 @@ 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 +61,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 +139,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..e7226ba
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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 <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.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;
+
+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;
+}
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 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 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..91060dc 100644 (file)
@@ -114,6 +114,7 @@ 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 \
@@ -132,6 +133,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 \
diff --git a/dali-toolkit/internal/text/layouts/layout-alignment.h b/dali-toolkit/internal/text/layouts/layout-alignment.h
new file mode 100644 (file)
index 0000000..df61ff2
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H
+#define DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_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.
+ *
+ */
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+namespace Layout
+{
+
+/**
+ * @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
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..6911686
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/rendering/view-model.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+TypesetterPtr Typesetter::New( const ModelInterface* const model )
+{
+  return TypesetterPtr( new Typesetter( model ) );
+}
+
+ViewModel* Typesetter::GetViewModel()
+{
+  return mModel;
+}
+
+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..b8f5f77
--- /dev/null
@@ -0,0 +1,97 @@
+#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>
+
+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();
+
+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 11a9161..a6a69d1 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.
@@ -1888,7 +1906,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 );
@@ -1982,7 +2000,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 )
@@ -2063,7 +2081,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 );
@@ -2147,10 +2165,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 ) )
@@ -2220,7 +2238,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 );
@@ -2232,7 +2250,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;
@@ -2240,7 +2258,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 );
@@ -2255,10 +2273,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;
@@ -2270,10 +2288,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 )
       {
@@ -2314,7 +2332,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 )
     {
@@ -2332,12 +2350,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
@@ -2364,7 +2382,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();
 
@@ -2401,12 +2419,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;
@@ -2440,7 +2458,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 );
@@ -2454,7 +2472,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;
@@ -2510,7 +2528,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 ) )
   {
@@ -2521,21 +2539,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.
@@ -2543,33 +2561,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.
@@ -2582,8 +2601,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 );
 
@@ -2591,7 +2611,7 @@ bool Controller::DoRelayout( const Size& size,
     {
       layoutSize = newLayoutSize;
 
-      if ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) )
+      if( NO_OPERATION != ( UPDATE_DIRECTION & operations ) )
       {
         mImpl->mAutoScrollDirectionRTL = false;
       }
@@ -2599,21 +2619,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.
@@ -2628,7 +2648,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;
@@ -2640,22 +2660,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;
@@ -2671,7 +2692,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 )
   {
@@ -2679,21 +2700,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;
     }
   }
@@ -2841,7 +2862,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 );
@@ -2862,7 +2883,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();
@@ -2919,11 +2940,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*
@@ -2961,7 +2982,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;
@@ -2979,8 +3000,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 )
@@ -3003,7 +3024,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 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..67e6bcf 100644 (file)
 
 // 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/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/internal/text/layouts/layout-alignment.h>
 #include <dali-toolkit/internal/text/rendering/text-backend.h>
+#include <dali-toolkit/internal/text/text-effects-style.h>
+#include <dali-toolkit/internal/text/text-font-style.h>
 #include <dali-toolkit/internal/text/text-view.h>
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.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
 {
@@ -71,34 +69,34 @@ const char * const BATCHING_ENABLED_PROPERTY( "batchingEnabled" );
 
 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 )
+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 );
 }
@@ -198,7 +196,7 @@ 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() );
 
@@ -327,11 +325,11 @@ void TextVisual::DoSetProperties( const Property::Map& propertyMap )
     }
   }
 
-  // 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.
@@ -429,11 +427,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 +439,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,10 +451,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 );
+        mController->SetDefaultColor( textColor );
         mRenderer.Reset();
       }
       break;
@@ -502,7 +500,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
       {
         case Property::VECTOR4:
         {
-          const Vector4 color = propertyValue.Get<Vector4>();
+          const Vector4& color = propertyValue.Get<Vector4>();
           if( mController->GetUnderlineColor() != color )
           {
             mController->SetUnderlineColor( color );
@@ -556,7 +554,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
       {
         case Property::VECTOR2:
         {
-          const Vector2 shadowOffset = propertyValue.Get<Vector2>();
+          const Vector2& shadowOffset = propertyValue.Get<Vector2>();
           if( mController->GetShadowOffset() != shadowOffset )
           {
             mController->SetShadowOffset( shadowOffset );
@@ -566,7 +564,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
         }
         case Property::VECTOR4:
         {
-          const Vector4 shadowColor = propertyValue.Get<Vector4>();
+          const Vector4& shadowColor = propertyValue.Get<Vector4>();
           if( mController->GetShadowColor() != shadowColor )
           {
             mController->SetShadowColor( shadowColor );
@@ -662,9 +660,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 +671,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 +682,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:
@@ -794,7 +792,7 @@ void TextVisual::RenderText()
 
     if( renderableActor )
     {
-      const Vector2& scrollOffset = mController->GetScrollPosition();
+      const Vector2& scrollOffset = mController->GetTextModel()->GetScrollPosition();
       renderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
 
       self.Add( renderableActor );