Fix decorator cursor size didn't changed issue 73/305273/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 30 Jan 2024 12:16:41 +0000 (21:16 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 31 Jan 2024 06:27:39 +0000 (15:27 +0900)
Since dali don't change the size during Relayout callback working,
the cursor size was not applied at 'current' relayout result.

So there was some issue that the cursor size applied well after 1 event loop working.

To avoid this issue, let we 'add' some relayout required actor to container.
It will call Relayout internally, at this loop.

TODO : Is there any other actor to be changed during relayout?

Change-Id: I88f48c7b64e76644ea8738abce4245a584c83cc9
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/text/controller/text-controller-impl.cpp
dali-toolkit/internal/text/decorator/text-decorator.cpp
dali-toolkit/internal/text/decorator/text-decorator.h

index dcb33d7..a3dde6b 100644 (file)
@@ -780,7 +780,7 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container)
     if(mDecorator &&
        (Text::Controller::NONE_UPDATED != (Text::Controller::DECORATOR_UPDATED & updateTextType)))
     {
-      mDecorator->Relayout(contentSize);
+      mDecorator->Relayout(contentSize, container);
     }
 
     if(!mRenderer)
index 1714946..4d68826 100644 (file)
@@ -691,7 +691,7 @@ void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container)
     if(mDecorator &&
        (Text::Controller::NONE_UPDATED != (Text::Controller::DECORATOR_UPDATED & updateTextType)))
     {
-      mDecorator->Relayout(contentSize);
+      mDecorator->Relayout(contentSize, container);
     }
 
     if(!mRenderer)
index eb24eb9..4336221 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT
 
 constexpr float MAX_FLOAT = std::numeric_limits<float>::max();
 
-const char* EMPTY_STRING = "";
+const char* EMPTY_STRING         = "";
 const char* MIME_TYPE_TEXT_PLAIN = "text/plain;charset=utf-8";
 
 } // namespace
@@ -482,14 +482,14 @@ void Controller::Impl::UpdateAnchorColor()
       if(mModel->mLogicalModel->mColorRuns.Count() > anchor.colorRunIndex)
       {
         ColorRun& colorRun = *(mModel->mLogicalModel->mColorRuns.Begin() + anchor.colorRunIndex);
-        colorRun.color = mAnchorColor;
-        updateNeeded = true;
+        colorRun.color     = mAnchorColor;
+        updateNeeded       = true;
       }
       if(mModel->mLogicalModel->mUnderlinedCharacterRuns.Count() > anchor.underlinedCharacterRunIndex)
       {
         UnderlinedCharacterRun& underlineRun = *(mModel->mLogicalModel->mUnderlinedCharacterRuns.Begin() + anchor.underlinedCharacterRunIndex);
-        underlineRun.properties.color = mAnchorColor;
-        updateNeeded = true;
+        underlineRun.properties.color        = mAnchorColor;
+        updateNeeded                         = true;
       }
     }
     else if(!anchor.isMarkupClickedColorSet && anchor.isClicked)
@@ -497,14 +497,14 @@ void Controller::Impl::UpdateAnchorColor()
       if(mModel->mLogicalModel->mColorRuns.Count() > anchor.colorRunIndex)
       {
         ColorRun& colorRun = *(mModel->mLogicalModel->mColorRuns.Begin() + anchor.colorRunIndex);
-        colorRun.color = mAnchorClickedColor;
-        updateNeeded = true;
+        colorRun.color     = mAnchorClickedColor;
+        updateNeeded       = true;
       }
       if(mModel->mLogicalModel->mUnderlinedCharacterRuns.Count() > anchor.underlinedCharacterRunIndex)
       {
         UnderlinedCharacterRun& underlineRun = *(mModel->mLogicalModel->mUnderlinedCharacterRuns.Begin() + anchor.underlinedCharacterRunIndex);
-        underlineRun.properties.color = mAnchorClickedColor;
-        updateNeeded = true;
+        underlineRun.properties.color        = mAnchorClickedColor;
+        updateNeeded                         = true;
       }
     }
   }
@@ -1011,6 +1011,8 @@ void Controller::Impl::SetEditable(bool editable)
     {
       bool decoratorEditable = editable && mIsUserInteractionEnabled;
       mEventData->mDecorator->SetEditable(decoratorEditable);
+      mEventData->mDecoratorUpdated = true;
+      RequestRelayout();
     }
   }
 }
@@ -1387,7 +1389,7 @@ CharacterIndex Controller::Impl::CalculateNewCursorIndex(CharacterIndex index) c
   else
   {
     Length textLength = mModel->mVisualModel->mCharactersToGlyph.Count();
-    cursorIndex = cursorIndex + numberOfCharacters > textLength ? textLength : cursorIndex + numberOfCharacters;
+    cursorIndex       = cursorIndex + numberOfCharacters > textLength ? textLength : cursorIndex + numberOfCharacters;
   }
 
   // Will update the cursor hook position.
@@ -2013,6 +2015,8 @@ void Controller::Impl::SetUserInteractionEnabled(bool enabled)
   {
     bool editable = mEventData->mEditingEnabled && enabled;
     mEventData->mDecorator->SetEditable(editable);
+    mEventData->mDecoratorUpdated = true;
+    RequestRelayout();
   }
 }
 
index cda3996..4befac0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
 #include <dali/public-api/object/property-notification.h>
 #include <dali/public-api/rendering/geometry.h>
 #include <dali/public-api/rendering/renderer.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
@@ -251,7 +252,7 @@ struct Decorator::Impl : public ConnectionTracker
    * Relayout of the decorations owned by the decorator.
    * @param[in] size The Size of the UI control the decorator is adding it's decorations to.
    */
-  void Relayout(const Vector2& size)
+  void Relayout(const Vector2& size, RelayoutContainer& container)
   {
     mControlSize = size;
 
@@ -273,6 +274,8 @@ struct Decorator::Impl : public ConnectionTracker
       {
         mPrimaryCursor.SetProperty(Actor::Property::POSITION, Vector2(cursor.position.x, cursor.position.y));
         mPrimaryCursor.SetProperty(Actor::Property::SIZE, Size(mCursorWidth, cursor.cursorHeight));
+
+        container.Add(mPrimaryCursor, Size(mCursorWidth, cursor.cursorHeight));
       }
       mPrimaryCursor.SetProperty(Actor::Property::VISIBLE, mPrimaryCursorVisible && mCursorBlinkStatus);
     }
@@ -287,6 +290,8 @@ struct Decorator::Impl : public ConnectionTracker
       {
         mSecondaryCursor.SetProperty(Actor::Property::POSITION, Vector2(cursor.position.x, cursor.position.y));
         mSecondaryCursor.SetProperty(Actor::Property::SIZE, Size(mCursorWidth, cursor.cursorHeight));
+
+        container.Add(mSecondaryCursor, Size(mCursorWidth, cursor.cursorHeight));
       }
       mSecondaryCursor.SetProperty(Actor::Property::VISIBLE, mSecondaryCursorVisible && mCursorBlinkStatus);
     }
@@ -301,7 +306,7 @@ struct Decorator::Impl : public ConnectionTracker
       grabHandle.horizontallyVisible = ((mControlSize.width - (grabHandle.position.x + floor(0.5f * mCursorWidth)) > -Math::MACHINE_EPSILON_1000) &&
                                         (grabHandle.position.x > -Math::MACHINE_EPSILON_1000));
       grabHandle.verticallyVisible   = ((fabsf(mControlSize.height - grabHandle.lineHeight) - grabHandle.position.y > -Math::MACHINE_EPSILON_1000) &&
-                                        (grabHandle.position.y + grabHandle.lineHeight > -Math::MACHINE_EPSILON_1000));
+                                      (grabHandle.position.y + grabHandle.lineHeight > -Math::MACHINE_EPSILON_1000));
 
       const bool isVisible = grabHandle.horizontallyVisible && grabHandle.verticallyVisible && (!mHidePrimaryCursorAndGrabHandle);
       if(isVisible)
@@ -954,9 +959,9 @@ struct Decorator::Impl : public ConnectionTracker
     if(!mCopyPastePopup.actor)
     {
       mCopyPastePopup.actor = TextSelectionPopup::New(&mTextSelectionPopupCallbackInterface);
-  #ifdef DECORATOR_DEBUG
+#ifdef DECORATOR_DEBUG
       mCopyPastePopup.actor.SetProperty(Dali::Actor::Property::NAME, "mCopyPastePopup");
-  #endif
+#endif
       mCopyPastePopup.actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
       mCopyPastePopup.actor.SetProperty(Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D);
       mCopyPastePopup.actor.OnRelayoutSignal().Connect(this, &Decorator::Impl::SetPopupPosition); // Position popup after size negotiation
@@ -1096,11 +1101,11 @@ struct Decorator::Impl : public ConnectionTracker
 
   void ApplyDisplacement(HandleImpl& handle, float yLocalPosition)
   {
-    if( handle.actor )
+    if(handle.actor)
     {
       float adjustedDisplacementX = 0.0f;
       float adjustedDisplacementY = 0.0f;
-      if (mSmoothHandlePanEnabled)
+      if(mSmoothHandlePanEnabled)
       {
         adjustedDisplacementX = CalculateAdjustedDisplacement(handle.position.x, handle.grabDisplacementX, mControlSize.x);
         adjustedDisplacementY = CalculateAdjustedDisplacement(handle.position.y, handle.grabDisplacementY, (mControlSize.y - handle.lineHeight));
@@ -1994,9 +1999,9 @@ void Decorator::GetBoundingBox(Rect<int>& boundingBox) const
   WorldToLocalCoordinatesBoundingBox(mImpl->mBoundingBox, boundingBox);
 }
 
-void Decorator::Relayout(const Vector2& size)
+void Decorator::Relayout(const Vector2& size, RelayoutContainer& container)
 {
-  mImpl->Relayout(size);
+  mImpl->Relayout(size, container);
 }
 
 void Decorator::UpdatePositions(const Vector2& scrollOffset)
@@ -2164,8 +2169,6 @@ void Decorator::SetEditable(bool editable)
       SetPopupActive(false);
     }
   }
-
-  mImpl->Relayout(mImpl->mControlSize);
 }
 /** Handles **/
 
index dc6a5d5..ab0153a 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXT_DECORATOR_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/intrusive-ptr.h>
 #include <dali/public-api/math/rect.h>
-#include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/object/property-map.h>
+#include <dali/public-api/object/ref-object.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
@@ -193,8 +193,10 @@ public:
    * @brief The decorator waits until a relayout before creating actors etc.
    *
    * @param[in] size The size of the parent control after size-negotiation.
+   * @param[in,out]  container  The control should add actors to this container that it is not able
+   *                            to allocate a size for.
    */
-  void Relayout(const Dali::Vector2& size);
+  void Relayout(const Dali::Vector2& size, RelayoutContainer& container);
 
   /**
    * @brief Updates the decorator's actor positions after scrolling.