From: Bowon Ryu Date: Thu, 21 Sep 2023 10:06:54 +0000 (+0900) Subject: Fix GetHeightForWidth for text controller X-Git-Tag: dali_2.2.46~5^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=da9f7b93ae00d0aa64a959549ed9da3469a49e46 Fix GetHeightForWidth for text controller In the case of text label, the height of the layout is used when returning the cached value of GetHeightForWidth. But, this value is the height of the layout that has been Ellipsis processed. It's not the height of the entire Text. So, the intended height cannot be obtained. This patch simply stores calculated values. Change-Id: Ia5d06bdac39556776749de3e3078a3a7e230c36c Signed-off-by: Bowon Ryu --- diff --git a/dali-toolkit/internal/text/controller/text-controller-impl.h b/dali-toolkit/internal/text/controller/text-controller-impl.h index 97010cc..0f910d0 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl.h +++ b/dali-toolkit/internal/text/controller/text-controller-impl.h @@ -341,6 +341,7 @@ struct Controller::Impl mMaximumNumberOfCharacters(50u), mHiddenInput(NULL), mInputFilter(nullptr), + mLastHeightForWidth(0.0f, 0.0f), mRecalculateNaturalSize(true), mMarkupProcessorEnabled(false), mClipboardHideEnabled(true), @@ -1024,6 +1025,7 @@ public: HiddenText* mHiddenInput; ///< Avoid allocating this when the user does not specify hidden input mode. std::unique_ptr mInputFilter; ///< Avoid allocating this when the user does not specify input filter mode. Vector2 mTextFitContentSize; ///< Size of Text fit content + Vector2 mLastHeightForWidth; ///< Size of Text content from GetHeightForWidth bool mRecalculateNaturalSize : 1; ///< Whether the natural size needs to be recalculated. bool mMarkupProcessorEnabled : 1; ///< Whether the mark-up procesor is enabled. diff --git a/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp b/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp index d595d00..c3711f3 100644 --- a/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp @@ -345,13 +345,11 @@ float Controller::Relayouter::GetHeightForWidth(Controller& controller, float wi EventHandler::ProcessModifyEvents(controller); Controller::Impl& impl = *controller.mImpl; - ModelPtr& model = impl.mModel; - VisualModelPtr& visualModel = model->mVisualModel; TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo; Size layoutSize; - if(fabsf(width - visualModel->mControlSize.width) > Math::MACHINE_EPSILON_1000 || + if(fabsf(width - impl.mLastHeightForWidth.width) > Math::MACHINE_EPSILON_1000 || textUpdateInfo.mFullRelayoutNeeded || textUpdateInfo.mClearAll) { @@ -360,12 +358,14 @@ float Controller::Relayouter::GetHeightForWidth(Controller& controller, float wi Size sizeRequestedWidthAndMaxHeight = Size(width, MAX_FLOAT); layoutSize = CalculateLayoutSizeOnRequiredControllerSize(controller, sizeRequestedWidthAndMaxHeight, requestedOperationsMask); + impl.mLastHeightForWidth.width = width; + impl.mLastHeightForWidth.height = layoutSize.height; DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height); } else { - layoutSize = visualModel->GetLayoutSize(); + layoutSize = impl.mLastHeightForWidth; DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height); }