Fix text cursor position issue 51/268351/7
authorBowon Ryu <bowon.ryu@samsung.com>
Tue, 21 Dec 2021 11:10:38 +0000 (20:10 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Wed, 22 Dec 2021 11:43:30 +0000 (20:43 +0900)
When the size or direction of text is changed,
all decorator elements should be updated.

Change-Id: Ib2fb61f684801c5743762df67e8e6d53399c8098
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/internal/text/text-controller-relayouter.cpp

index d1a04e9..a6e2668 100644 (file)
@@ -3565,6 +3565,12 @@ int UtcDaliTextFieldSelectWholeText(void)
   application.SendNotification();
   application.Render();
 
   application.SendNotification();
   application.Render();
 
+  // Even if resize, selection should remain.
+  textField.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 50.f ) );
+
+  application.SendNotification();
+  application.Render();
+
   // Should be 2 children, the stencil and the layer
   DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
 
   // Should be 2 children, the stencil and the layer
   DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
 
index 34e7053..c9a4fb0 100644 (file)
@@ -397,8 +397,11 @@ Controller::UpdateTextType Controller::Relayouter::Relayout(Controller& controll
     textUpdateInfo.mCharacterIndex     = 0u;
   }
 
     textUpdateInfo.mCharacterIndex     = 0u;
   }
 
+  bool layoutDirectionChanged = false;
   if(impl.mLayoutDirection != layoutDirection)
   {
   if(impl.mLayoutDirection != layoutDirection)
   {
+    // Flag to indicate that the layout direction has changed.
+    layoutDirectionChanged = true;
     // Clear the update info. This info will be set the next time the text is updated.
     textUpdateInfo.mClearAll = true;
     // Apply modifications to the model
     // Clear the update info. This info will be set the next time the text is updated.
     textUpdateInfo.mClearAll = true;
     // Apply modifications to the model
@@ -449,13 +452,25 @@ Controller::UpdateTextType Controller::Relayouter::Relayout(Controller& controll
 
   if(isEditable)
   {
 
   if(isEditable)
   {
-    if(newSize)
+    if(newSize || layoutDirectionChanged)
     {
     {
-      // If there is a new size, the scroll position needs to be clamped.
+      // If there is a new size or layout direction is changed, the scroll position needs to be clamped.
       impl.ClampHorizontalScroll(layoutSize);
 
       // Update the decorator's positions is needed if there is a new size.
       impl.mEventData->mDecorator->UpdatePositions(model->mScrollPosition - offset);
       impl.ClampHorizontalScroll(layoutSize);
 
       // Update the decorator's positions is needed if there is a new size.
       impl.mEventData->mDecorator->UpdatePositions(model->mScrollPosition - offset);
+
+      // All decorator elements need to be updated.
+      if(EventData::IsEditingState(impl.mEventData->mState))
+      {
+        impl.mEventData->mScrollAfterUpdatePosition = true;
+        impl.mEventData->mUpdateCursorPosition = true;
+        impl.mEventData->mUpdateGrabHandlePosition = true;
+      }
+      else if(impl.mEventData->mState == EventData::SELECTING)
+      {
+        impl.mEventData->mUpdateHighlightBox = true;
+      }
     }
 
     // Move the cursor, grab handle etc.
     }
 
     // Move the cursor, grab handle etc.