(TextInput) Moving selection handles when word selected does not de-select current...
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-input / text-input-impl.cpp
index 7e2a1af..7600969 100644 (file)
@@ -281,9 +281,9 @@ Dali::Toolkit::TextInput TextInput::New()
   TextInputPtr textInput(new TextInput());
   // Pass ownership to CustomActor via derived handle
   Dali::Toolkit::TextInput handle(*textInput);
+  handle.SetName( "TextInput");
 
   textInput->Initialize();
-
   return handle;
 }
 
@@ -1152,6 +1152,7 @@ void TextInput::CreateActiveLayer()
 {
   Actor self = Self();
   mActiveLayer = Layer::New();
+  mActiveLayer.SetName ( "ActiveLayerActor" );
 
   mActiveLayer.SetAnchorPoint( AnchorPoint::CENTER);
   mActiveLayer.SetParentOrigin( ParentOrigin::CENTER);
@@ -1541,6 +1542,12 @@ void TextInput::OnLongPress(Dali::Actor actor, Dali::LongPressGesture longPress)
 {
   DALI_LOG_INFO( gLogFilter, Debug::General, "OnLongPress\n" );
 
+  // Ignore longpress if in selection mode already
+  if( mHighlightMeshActor )
+  {
+    return;
+  }
+
   if(longPress.state == Dali::Gesture::Started)
   {
     // Start edit mode on long press
@@ -1951,11 +1958,7 @@ void TextInput::ScrollTextViewToMakeCursorVisible( const Vector3& cursorPosition
     scrollOffset.x += cursorPosition.x;
   }
 
-  if( cursorPosition.y - cursorSize.height < 0.f )
-  {
-    scrollOffset.y += ( cursorPosition.y - cursorSize.height );
-  }
-  else if( cursorPosition.y > controlSize.height )
+  if( cursorPosition.y - cursorSize.height < 0.f || cursorPosition.y > controlSize.height )
   {
     scrollOffset.y += cursorPosition.y;
   }
@@ -2080,6 +2083,7 @@ void TextInput::SetUpTouchEvents()
 void TextInput::CreateTextViewActor()
 {
   mDisplayedTextView = Toolkit::TextView::New();
+  mDisplayedTextView.SetName( "TextView ");
   mDisplayedTextView.SetMarkupProcessingEnabled( mMarkUpEnabled );
   mDisplayedTextView.SetParentOrigin(ParentOrigin::TOP_LEFT);
   mDisplayedTextView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
@@ -2267,7 +2271,7 @@ ImfManager::ImfCallbackData TextInput::ImfEventReceived( Dali::ImfManager& imfMa
       }
       else
       {
-        if( std::abs( imfEvent.cursorOffset ) < mCursorPosition )
+        if( static_cast<std::size_t>(std::abs( imfEvent.cursorOffset )) < mCursorPosition )
         {
           toDelete = mCursorPosition + imfEvent.cursorOffset;
         }
@@ -2639,6 +2643,8 @@ void TextInput::DeleteHighlightedText( bool inheritStyle )
 
     RemoveHighlight();
 
+    EmitTextModified();
+
     if( inheritStyle )
     {
       const TextStyle oldInputStyle( mInputStyle );
@@ -3497,7 +3503,7 @@ TextInput::HighlightInfo TextInput::CalculateHighlightInfo()
           // TODO: TextView should have a table of visual rows, and each character a reference to the row
           // that it resides on. That way this enumeration is not necessary.
           Vector2 min, max;
-          if(lastIt->mIsNewLineChar)
+          if(lastIt->mIsNewParagraphChar)
           {
             // If the last character is a new line, then to get the row rect, we need to scan from the character before the new line.
             lastIt = std::max( mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 );
@@ -3544,7 +3550,7 @@ TextInput::HighlightInfo TextInput::CalculateHighlightInfo()
       {
         // finished selection.
         Vector2 min, max;
-        if(lastIt->mIsNewLineChar)
+        if(lastIt->mIsNewParagraphChar)
         {
           lastIt = std::max( mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 );
         }
@@ -3910,7 +3916,7 @@ bool TextInput::ReturnClosestIndex(const Vector2& source, std::size_t& closestIn
         if( fabsf( closestYdifference - currentYdifference )  < CHARACTER_THRESHOLD )
         {
           // ignore new line character.
-          if( !info.mIsNewLineChar )
+          if( !info.mIsNewParagraphChar )
           {
             matchedCharacters.push_back( info );
             numberOfMatchedCharacters++;
@@ -3924,7 +3930,7 @@ bool TextInput::ReturnClosestIndex(const Vector2& source, std::size_t& closestIn
     // and check if user is touching below previous line.
     const Toolkit::TextView::CharacterLayoutInfo& lastInfo( mTextLayoutInfo.mCharacterLayoutInfoTable[mTextLayoutInfo.mCharacterLayoutInfoTable.size() - 1] );
 
-    if( ( lastInfo.mIsVisible ) && ( lastInfo.mIsNewLineChar ) && ( sourceScrollOffset.y > lastInfo.mPosition.y ) )
+    if( ( lastInfo.mIsVisible ) && ( lastInfo.mIsNewParagraphChar ) && ( sourceScrollOffset.y > lastInfo.mPosition.y ) )
     {
       closestIndex = mTextLayoutInfo.mCharacterLayoutInfoTable.size();
     }
@@ -4182,7 +4188,7 @@ Vector3 TextInput::GetActualPositionFromCharacterPosition(std::size_t characterP
       }
 
       Toolkit::TextView::CharacterLayoutInfo info = mTextLayoutInfo.mCharacterLayoutInfoTable[ visualCharacterPosition ];
-      if( ( visualCharacterPosition > 0 ) && info.mIsNewLineChar && !IsScrollEnabled() )
+      if( ( visualCharacterPosition > 0 ) && info.mIsNewParagraphChar && !IsScrollEnabled() )
       {
         // Prevents the cursor to exceed the boundary if the last visible character is a 'new line character' and the scroll is not enabled.
         const Vector3& size = GetControlSize();
@@ -4194,7 +4200,7 @@ Vector3 TextInput::GetActualPositionFromCharacterPosition(std::size_t characterP
         info = mTextLayoutInfo.mCharacterLayoutInfoTable[ visualCharacterPosition ];
       }
 
-      if(!info.mIsNewLineChar)
+      if(!info.mIsNewParagraphChar)
       {
         cursorPosition = PositionCursorAfterWordWrap( characterPosition ); // Get position of cursor/handles taking in account auto word wrap.
       }
@@ -4394,7 +4400,7 @@ std::size_t TextInput::GetRowStartFromCharacterPosition(std::size_t logicalPosit
   {
     logicalPosition--;
     std::size_t visualPosition = GetVisualPosition(logicalPosition);
-    if(mTextLayoutInfo.mCharacterLayoutInfoTable[visualPosition].mIsNewLineChar)
+    if(mTextLayoutInfo.mCharacterLayoutInfoTable[visualPosition].mIsNewParagraphChar)
     {
       logicalPosition++;
       break;
@@ -4464,7 +4470,7 @@ Size TextInput::GetRowRectFromCharacterPosition(std::size_t characterPosition, V
     --it;
 
     if( (it->mPosition.y < referenceLine) ||
-        (it->mIsNewLineChar) ||
+        (it->mIsNewParagraphChar) ||
         (!it->mIsVisible) )
     {
       break;
@@ -4481,7 +4487,7 @@ Size TextInput::GetRowRectFromCharacterPosition(std::size_t characterPosition, V
   while(it != end)
   {
     if( (it->mPosition.y > referenceLine) ||
-        (it->mIsNewLineChar) ||
+        (it->mIsNewParagraphChar) ||
         (!it->mIsVisible) )
     {
       break;
@@ -4741,7 +4747,6 @@ void TextInput::CreateHighlight()
 
     mHighlightMeshActor = MeshActor::New( mHighlightMesh );
     mHighlightMeshActor.SetName( "HighlightMeshActor" );
-    mHighlightMeshActor.SetInheritShaderEffect( false );
     mHighlightMeshActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
     mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
     mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
@@ -4807,6 +4812,7 @@ void TextInput::PasteText( const Text& text )
   if( update )
   {
     CursorUpdate();
+    EmitTextModified();
   }
 
   if( insertedStringLength < text.GetLength() )