Fixed scroll issue when use padding of TextField/TextEditor 01/252201/6
authorBowon Ryu <bowon.ryu@samsung.com>
Mon, 25 Jan 2021 11:10:57 +0000 (20:10 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Mon, 22 Feb 2021 02:06:15 +0000 (11:06 +0900)
In OnRelayout, the size of mStencil, mActiveLayer should be calculated including padding.
And the elements of text-decorator should also be positioned based on the size including padding.

Change-Id: Iafc745a464b39560bb9707675878d3b47944653b
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.h
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h

index 22880d3..42f9926 100644 (file)
@@ -1381,6 +1381,14 @@ float TextEditor::GetHeightForWidth(float width)
   return mController->GetHeightForWidth(width) + padding.top + padding.bottom;
 }
 
+void TextEditor::ResizeActor(Actor& actor, const Vector2& size)
+{
+  if (actor.GetProperty<Vector3>(Dali::Actor::Property::SIZE).GetVectorXY() != size)
+  {
+    actor.SetProperty(Actor::Property::SIZE, size);
+  }
+}
+
 void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container)
 {
   DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextEditor OnRelayout\n");
@@ -1410,10 +1418,12 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container)
   if(mStencil)
   {
     mStencil.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
+    ResizeActor(mStencil, contentSize);
   }
   if(mActiveLayer)
   {
     mActiveLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
+    ResizeActor(mActiveLayer, contentSize);
   }
 
   const Text::Controller::UpdateTextType updateTextType = mController->Relayout(contentSize, layoutDirection);
@@ -1426,7 +1436,7 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container)
     if(mDecorator &&
        (Text::Controller::NONE_UPDATED != (Text::Controller::DECORATOR_UPDATED & updateTextType)))
     {
-      mDecorator->Relayout(size);
+      mDecorator->Relayout(contentSize);
     }
 
     if(!mRenderer)
index 6be336b..ed8d039 100644 (file)
@@ -356,6 +356,14 @@ private: // Implementation
   TextEditor& operator=(const TextEditor& rhs);
 
   /**
+   * @brief Resize actor to the given size.
+   *
+   * @param[in] actor The actor to be resized.
+   * @param[in] size Size to change.
+   */
+  void ResizeActor( Actor& actor, const Vector2& size );
+
+  /**
    * @brief Render view, create and attach actor(s) to this text editor.
    */
   void RenderText(Text::Controller::UpdateTextType updateTextType);
index 4cca3fd..9ad7a84 100644 (file)
@@ -1333,6 +1333,14 @@ float TextField::GetHeightForWidth(float width)
   return mController->GetHeightForWidth(width) + padding.top + padding.bottom;
 }
 
+void TextField::ResizeActor(Actor& actor, const Vector2& size)
+{
+  if (actor.GetProperty<Vector3>(Dali::Actor::Property::SIZE).GetVectorXY() != size)
+  {
+    actor.SetProperty(Actor::Property::SIZE, size);
+  }
+}
+
 void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container)
 {
   DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
@@ -1362,10 +1370,12 @@ void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container)
   if(mStencil)
   {
     mStencil.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
+    ResizeActor(mStencil, contentSize);
   }
   if(mActiveLayer)
   {
     mActiveLayer.SetProperty(Actor::Property::POSITION, Vector2(padding.start, padding.top));
+    ResizeActor(mActiveLayer, contentSize);
   }
 
   const Text::Controller::UpdateTextType updateTextType = mController->Relayout(contentSize, layoutDirection);
@@ -1378,7 +1388,7 @@ void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container)
     if(mDecorator &&
        (Text::Controller::NONE_UPDATED != (Text::Controller::DECORATOR_UPDATED & updateTextType)))
     {
-      mDecorator->Relayout(size);
+      mDecorator->Relayout(contentSize);
     }
 
     if(!mRenderer)
index 87f4060..dbafa30 100644 (file)
@@ -312,6 +312,14 @@ private: // Implementation
   TextField& operator=(const TextField& rhs);
 
   /**
+   * @brief Resize actor to the given size.
+   *
+   * @param[in] actor The actor to be resized.
+   * @param[in] size Size to change.
+   */
+  void ResizeActor( Actor& actor, const Vector2& size );
+
+  /**
    * @brief Render view, create and attach actor(s) to this Text Field.
    */
   void RenderText(Text::Controller::UpdateTextType updateTextType);