Corrected camel case for BgraShader
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller.cpp
index 3433301..c3bec4f 100644 (file)
@@ -41,6 +41,7 @@ using std::vector;
 namespace
 {
 const float MAX_FLOAT = std::numeric_limits<float>::max();
+const std::string EMPTY_STRING;
 } // namespace
 
 namespace Dali
@@ -240,8 +241,14 @@ struct Controller::TextInput
       GetClosestCursorPosition( xPosition, yPosition, height );
 
       mDecorator->SetPosition( PRIMARY_CURSOR, xPosition, yPosition, height );
+      mDecorator->HidePopup();
       mDecoratorUpdated = true;
     }
+    else if ( GRAB_HANDLE_RELEASED == state )
+    {
+      mDecorator->ShowPopup();
+    }
+
   }
 
   void ChangeState( State newState )
@@ -256,6 +263,7 @@ struct Controller::TextInput
         mDecorator->StopCursorBlink();
         mDecorator->SetGrabHandleActive( false );
         mDecorator->SetSelectionActive( false );
+        mDecorator->HidePopup();
         mDecoratorUpdated = true;
       }
       else if ( SELECTING == mState )
@@ -483,7 +491,7 @@ const std::string& Controller::GetDefaultFontFamily() const
     return mImpl->mFontDefaults->mDefaultFontFamily;
   }
 
-  return Dali::String::EMPTY;
+  return EMPTY_STRING;
 }
 
 void Controller::SetDefaultFontStyle( const std::string& defaultFontStyle )
@@ -506,7 +514,7 @@ const std::string& Controller::GetDefaultFontStyle() const
     return mImpl->mFontDefaults->mDefaultFontStyle;
   }
 
-  return Dali::String::EMPTY;
+  return EMPTY_STRING;
 }
 
 void Controller::SetDefaultPointSize( float pointSize )
@@ -555,6 +563,7 @@ bool Controller::Relayout( const Vector2& size )
                                                              LAYOUT                    |
                                                              UPDATE_ACTUAL_SIZE        |
                                                              UPDATE_POSITIONS          |
+                                                             UPDATE_LINES              |
                                                              REORDER );
 
     mImpl->mControlSize = size;
@@ -710,9 +719,10 @@ bool Controller::DoRelayout( const Vector2& size,
 
   if( LAYOUT & operations )
   {
+    const Length numberOfCharacters = mImpl->mLogicalModel->GetNumberOfCharacters();
+
     if( 0u == numberOfGlyphs )
     {
-      const Length numberOfCharacters = mImpl->mLogicalModel->GetNumberOfCharacters();
       numberOfGlyphs = mImpl->mVisualModel->GetNumberOfGlyphs();
 
       lineBreakInfo.Resize( numberOfCharacters );
@@ -755,22 +765,40 @@ bool Controller::DoRelayout( const Vector2& size,
     Vector<Vector2> glyphPositions;
     glyphPositions.Resize( numberOfGlyphs );
 
-    // Update the visual model
+    // The laid-out lines.
+    // It's not possible to know in how many lines the text is going to be laid-out,
+    // but it can be resized at least with the number of 'paragraphs' to avoid
+    // some re-allocations.
+    Vector<LineRun> lines;
+    lines.Reserve( mImpl->mLogicalModel->GetNumberOfBidirectionalInfoRuns( 0u, numberOfCharacters ) );
+
+    // Update the visual model.
     viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
                                                    glyphPositions,
+                                                   lines,
                                                    layoutSize );
 
-    // Sets the positions into the model.
-    if( UPDATE_POSITIONS & operations )
+    if( viewUpdated )
     {
-      mImpl->mVisualModel->SetGlyphPositions( glyphPositions.Begin(),
-                                              numberOfGlyphs );
-    }
+      // Sets the positions into the model.
+      if( UPDATE_POSITIONS & operations )
+      {
+        mImpl->mVisualModel->SetGlyphPositions( glyphPositions.Begin(),
+                                                numberOfGlyphs );
+      }
 
-    // Sets the actual size.
-    if( UPDATE_ACTUAL_SIZE & operations )
-    {
-      mImpl->mVisualModel->SetActualSize( layoutSize );
+      // Sets the lines into the model.
+      if( UPDATE_LINES & operations )
+      {
+        mImpl->mVisualModel->SetLines( lines.Begin(),
+                                       lines.Count() );
+      }
+
+      // Sets the actual size.
+      if( UPDATE_ACTUAL_SIZE & operations )
+      {
+        mImpl->mVisualModel->SetActualSize( layoutSize );
+      }
     }
   }
   else