Fix for PLACEHOLDER_TEXT_FOCUSED feature 53/38953/3
authorPaul Wisbey <p.wisbey@samsung.com>
Sat, 2 May 2015 10:12:07 +0000 (11:12 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Sat, 2 May 2015 10:44:09 +0000 (11:44 +0100)
Change-Id: Ifd2601e7f5d9a012d18af9b5279ade4782d9a164

dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller.cpp

index 1825840..6453f9a 100644 (file)
@@ -307,7 +307,7 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     }
 #if defined(DEBUG_ENABLED)
     Toolkit::AtlasGlyphManager::Metrics metrics = mGlyphManager.GetMetrics();
-    DALI_LOG_INFO( gLogFilter, Debug::Concise, "TextAtlasRenderer::GlyphManager::GlyphCount: %i, AtlasCount: %i, TextureMemoryUse: %iK\n",
+    DALI_LOG_INFO( gLogFilter, Debug::General, "TextAtlasRenderer::GlyphManager::GlyphCount: %i, AtlasCount: %i, TextureMemoryUse: %iK\n",
                                                 metrics.mGlyphCount,
                                                 metrics.mAtlasMetrics.mAtlasCount,
                                                 metrics.mAtlasMetrics.mTextureMemoryUsed / 1024 );
index 49b8f3d..00c666e 100644 (file)
@@ -455,44 +455,33 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event )
 
 void Controller::Impl::OnTapEvent( const Event& event )
 {
-  if( NULL == mEventData )
+  if( NULL != mEventData )
   {
-    // Nothing to do if there is no text input.
-    return;
-  }
+    const unsigned int tapCount = event.p1.mUint;
 
-  const unsigned int tapCount = event.p1.mUint;
-
-  if( 1u == tapCount )
-  {
-    // Grab handle is not shown until a tap is received whilst EDITING
-    if( EventData::EDITING == mEventData->mState &&
-        !IsShowingPlaceholderText() )
+    if( 1u == tapCount )
     {
-      if( mEventData->mGrabHandleEnabled )
+      if( ! IsShowingPlaceholderText() )
       {
-        mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
-      }
-      mEventData->mDecorator->SetPopupActive( false );
-    }
-
-    ChangeState( EventData::EDITING );
-
-    const float xPosition = event.p2.mFloat - mEventData->mScrollPosition.x - mAlignmentOffset.x;
-    const float yPosition = event.p3.mFloat - mEventData->mScrollPosition.y - mAlignmentOffset.y;
-
-    mEventData->mPrimaryCursorPosition = GetClosestCursorIndex( xPosition,
-                                                                yPosition );
+        const float xPosition = event.p2.mFloat - mEventData->mScrollPosition.x - mAlignmentOffset.x;
+        const float yPosition = event.p3.mFloat - mEventData->mScrollPosition.y - mAlignmentOffset.y;
 
-    mEventData->mUpdateCursorPosition = true;
-    mEventData->mScrollAfterUpdateCursorPosition = true;
-  }
-  else if( mEventData->mSelectionEnabled &&
-           ( 2u == tapCount ) )
-  {
-    ChangeState( EventData::SELECTING );
+        mEventData->mPrimaryCursorPosition = GetClosestCursorIndex( xPosition,
+                                                                    yPosition );
+      }
+      else
+      {
+        mEventData->mPrimaryCursorPosition = 0u;
+      }
 
-    RepositionSelectionHandles( event.p2.mFloat, event.p3.mFloat );
+      mEventData->mUpdateCursorPosition = true;
+      mEventData->mScrollAfterUpdateCursorPosition = true;
+    }
+    else if( mEventData->mSelectionEnabled &&
+             ( 2u == tapCount ) )
+    {
+      RepositionSelectionHandles( event.p2.mFloat, event.p3.mFloat );
+    }
   }
 }
 
index 57356d0..99bed83 100644 (file)
@@ -1122,6 +1122,37 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y )
 {
   DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
 
+  if( NULL != mImpl->mEventData )
+  {
+    if( 1u == tapCount )
+    {
+      bool tapDuringEditMode( EventData::EDITING == mImpl->mEventData->mState );
+
+      mImpl->ChangeState( EventData::EDITING );
+
+      if( mImpl->IsShowingPlaceholderText() )
+      {
+        // Alternative placeholder-text is used when editing
+        ShowPlaceholderText();
+      }
+      else if( EventData::EDITING == mImpl->mEventData->mState )
+      {
+        // Grab handle is not shown until a tap is received whilst EDITING
+        if( tapDuringEditMode )
+        {
+          mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+        }
+        mImpl->mEventData->mDecorator->SetPopupActive( false );
+      }
+    }
+    else if( mImpl->mEventData->mSelectionEnabled &&
+             ( 2u == tapCount ) )
+    {
+      mImpl->ChangeState( EventData::SELECTING );
+    }
+  }
+
+  // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
   if( mImpl->mEventData )
   {
     Event event( Event::TAP_EVENT );
@@ -1214,6 +1245,9 @@ void Controller::ShowPlaceholderText()
 
     mImpl->mEventData->mIsShowingPlaceholderText = true;
 
+    // Cancel previously queued inserts etc.
+    mImpl->mModifyEvents.clear();
+
     // Disable handles when showing place-holder text
     mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
     mImpl->mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );