From fa6739682ff1ed028e635ece1f8676211966fe23 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Tue, 30 Jan 2024 21:16:41 +0900 Subject: [PATCH] Fix decorator cursor size didn't changed issue 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 --- .../controls/text-controls/text-editor-impl.cpp | 2 +- .../controls/text-controls/text-field-impl.cpp | 2 +- .../text/controller/text-controller-impl.cpp | 26 +++++++++++++--------- .../internal/text/decorator/text-decorator.cpp | 25 ++++++++++++--------- .../internal/text/decorator/text-decorator.h | 8 ++++--- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index dcb33d7..a3dde6b 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -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) diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 1714946..4d68826 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -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) diff --git a/dali-toolkit/internal/text/controller/text-controller-impl.cpp b/dali-toolkit/internal/text/controller/text-controller-impl.cpp index eb24eb9..4336221 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl.cpp @@ -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::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(); } } diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index cda3996..4befac0 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -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 #include #include +#include // INTERNAL INCLUDES #include @@ -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& 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 **/ diff --git a/dali-toolkit/internal/text/decorator/text-decorator.h b/dali-toolkit/internal/text/decorator/text-decorator.h index dc6a5d5..ab0153a 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.h +++ b/dali-toolkit/internal/text/decorator/text-decorator.h @@ -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 #include -#include #include +#include // INTERNAL INCLUDES #include @@ -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. -- 2.7.4