From: Bowon Ryu Date: Thu, 9 Jun 2022 10:28:54 +0000 (+0000) Subject: Merge "Fix text AutoScroll ellipsis issue" into devel/master X-Git-Tag: dali_2.1.26~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=b5fd9045b672b657db6f6647ed57d0380d29a6aa;hp=45ad62cd772319bc585a48c868b31892881374bb Merge "Fix text AutoScroll ellipsis issue" into devel/master --- diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp index e8bbb21..5b8469d 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp @@ -351,11 +351,13 @@ void CreateTextModel(const std::string& text, layoutParameters.startLineIndex = 0u; layoutParameters.estimatedNumberOfLines = logicalModel->mParagraphInfo.Count(); - bool isAutoScroll = false; + bool isAutoScroll = false; + bool isAutoScrollMaxTextureExceeded = false; layoutEngine.LayoutText(layoutParameters, layoutSize, false, isAutoScroll, + isAutoScrollMaxTextureExceeded, ellipsisPosition); if(options.align) diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSpacing.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSpacing.cpp index f636a19..5a15b09 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSpacing.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSpacing.cpp @@ -180,11 +180,13 @@ bool LayoutTextTest(const LayoutTextData& data) layoutSize = Vector2::ZERO; - bool isAutoScroll = false; - const bool updated = engine.LayoutText(layoutParameters, + bool isAutoScroll = false; + bool isAutoScrollMaxTextureExceeded = false; + const bool updated = engine.LayoutText(layoutParameters, layoutSize, data.ellipsis, isAutoScroll, + isAutoScrollMaxTextureExceeded, DevelText::EllipsisPosition::END); // 4) Compare the results. diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp old mode 100755 new mode 100644 index 9b71156..6ec3bfe --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp @@ -180,11 +180,13 @@ bool LayoutTextTest(const LayoutTextData& data) layoutSize = Vector2::ZERO; - bool isAutoScroll = false; - const bool updated = engine.LayoutText(layoutParameters, + bool isAutoScroll = false; + bool isAutoScrollMaxTextureExceeded = false; + const bool updated = engine.LayoutText(layoutParameters, layoutSize, data.ellipsis, isAutoScroll, + isAutoScrollMaxTextureExceeded, data.ellipsisPosition); // 4) Compare the results. diff --git a/dali-toolkit/devel-api/text/text-utils-devel.cpp b/dali-toolkit/devel-api/text/text-utils-devel.cpp index c9ab7b5..d1d6900 100644 --- a/dali-toolkit/devel-api/text/text-utils-devel.cpp +++ b/dali-toolkit/devel-api/text/text-utils-devel.cpp @@ -1065,11 +1065,14 @@ Size LayoutText(const RendererParameters& textParameters, TextAbstraction::TextR // Update the visual model. Size newLayoutSize; - bool isAutoScrollEnabled = false; + bool isAutoScrollEnabled = false; + bool isAutoScrollMaxTextureExceeded = false; + layoutEngine.LayoutText(layoutParameters, newLayoutSize, textParameters.ellipsisEnabled, isAutoScrollEnabled, + isAutoScrollMaxTextureExceeded, ellipsisPosition); return newLayoutSize; diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index 76d0ee2..97ccc81 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -1125,6 +1125,7 @@ void TextLabel::SetUpAutoScrolling() if(textNaturalSize.width > maxTextureSize) { mController->SetTextElideEnabled(true); + mController->SetAutoScrollMaxTextureExceeded(true); } GetHeightForWidth(maxTextureSize); wrapGap = std::max(maxTextureSize - textNaturalSize.width, 0.0f); @@ -1152,6 +1153,7 @@ void TextLabel::SetUpAutoScrolling() Renderer renderer = static_cast(GetImplementation(mVisual)).GetRenderer(); mTextScroller->SetParameters(Self(), renderer, textureSet, controlSize, verifiedSize, wrapGap, direction, mController->GetHorizontalAlignment(), mController->GetVerticalAlignment()); mController->SetTextElideEnabled(actualellipsis); + mController->SetAutoScrollMaxTextureExceeded(false); } void TextLabel::ScrollingFinished() diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 41e41a9..39af47c 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -1260,16 +1260,22 @@ struct Engine::Impl Length& numberOfLines, float penY, bool& isAutoScrollEnabled, + bool isAutoScrollMaxTextureExceeded, DevelText::EllipsisPosition::Type ellipsisPosition, bool enforceEllipsisInSingleLine) { - const bool ellipsis = enforceEllipsisInSingleLine || (isAutoScrollEnabled ? (penY - layout.descender > layoutParameters.boundingBox.height) : ((penY - layout.descender > layoutParameters.boundingBox.height) || ((mLayout == SINGLE_LINE_BOX) && (layout.length > layoutParameters.boundingBox.width)))); + const bool ellipsis = enforceEllipsisInSingleLine || (isAutoScrollEnabled ? isAutoScrollMaxTextureExceeded : ((penY - layout.descender > layoutParameters.boundingBox.height) || ((mLayout == SINGLE_LINE_BOX) && (layout.length > layoutParameters.boundingBox.width)))); const bool isMultiline = !enforceEllipsisInSingleLine && (mLayout == MULTI_LINE_BOX); if(ellipsis && (ellipsisPosition == DevelText::EllipsisPosition::END || !isMultiline)) { - isAutoScrollEnabled = false; - // Do not layout more lines if ellipsis is enabled. + if(penY - layout.descender > layoutParameters.boundingBox.height) + { + // Even if auto scroll is enabled and text is bigger than max texture size, + // if the the height is small, auto scroll should not work. + isAutoScrollEnabled = false; + } + // Do not layout more lines if ellipsis is enabled. // The last line needs to be completely filled with characters. // Part of a word may be used. @@ -1601,6 +1607,7 @@ struct Engine::Impl Size& layoutSize, bool elideTextEnabled, bool& isAutoScrollEnabled, + bool isAutoScrollMaxTextureExceeded, DevelText::EllipsisPosition::Type ellipsisPosition) { DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->LayoutText\n"); @@ -1801,7 +1808,7 @@ struct Engine::Impl CharacterIndex lastCharacterInParagraph = currentParagraphRun.characterRun.characterIndex + currentParagraphRun.characterRun.numberOfCharacters - 1; //check if this is the last line in paragraph, if false we should use the default relative line size (the one set using the property) - if(lastCharacterInParagraph >= layout.characterIndex && lastCharacterInParagraph < layout.characterIndex+layout.numberOfCharacters) + if(lastCharacterInParagraph >= layout.characterIndex && lastCharacterInParagraph < layout.characterIndex + layout.numberOfCharacters) { layout.relativeLineSize = mRelativeLineSize; } @@ -1840,6 +1847,7 @@ struct Engine::Impl numberOfLines, penY, isAutoScrollEnabled, + isAutoScrollMaxTextureExceeded, ellipsisPosition, false); } @@ -1858,6 +1866,7 @@ struct Engine::Impl numberOfLines, penY, isAutoScrollEnabled, + isAutoScrollMaxTextureExceeded, ellipsisPosition, true); } @@ -2252,12 +2261,14 @@ bool Engine::LayoutText(Parameters& layoutParameters, Size& layoutSize, bool elideTextEnabled, bool& isAutoScrollEnabled, + bool isAutoScrollMaxTextureExceeded, DevelText::EllipsisPosition::Type ellipsisPosition) { return mImpl->LayoutText(layoutParameters, layoutSize, elideTextEnabled, isAutoScrollEnabled, + isAutoScrollMaxTextureExceeded, ellipsisPosition); } diff --git a/dali-toolkit/internal/text/layouts/layout-engine.h b/dali-toolkit/internal/text/layouts/layout-engine.h index 6b78e87..9fa22c6 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.h +++ b/dali-toolkit/internal/text/layouts/layout-engine.h @@ -107,6 +107,7 @@ public: * @param[out] layoutSize The size of the text after it has been laid-out. * @param[in] elideTextEnabled Whether the text elide is enabled. * @param[in,out] isAutoScrollEnabled If the isAutoScrollEnabled is true and the height of the text exceeds the boundaries of the control the text is elided and the isAutoScrollEnabled is set to false to disable the autoscroll + * @param[in] isAutoScrollMaxTextureExceeded If isAutoScrollMaxTextureExceeded is true, enable ellipsis during auro scroll. * @param[in] ellipsisPosition The location of the text ellipsis * * @return \e true if the text has been re-laid-out. \e false means the given width is too small to layout even a single character. @@ -115,6 +116,7 @@ public: Size& layoutSize, bool elideTextEnabled, bool& isAutoScrollEnabled, + bool isAutoScrollMaxTextureExceeded, DevelText::EllipsisPosition::Type ellipsisPosition); /** diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 5e28f9c..7eaf5ee 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -346,6 +346,7 @@ struct Controller::Impl mMarkupProcessorEnabled(false), mClipboardHideEnabled(true), mIsAutoScrollEnabled(false), + mIsAutoScrollMaxTextureExceeded(false), mUpdateTextDirection(true), mIsTextDirectionRTL(false), mUnderlineSetByString(false), @@ -1000,12 +1001,13 @@ public: std::unique_ptr mInputFilter; ///< Avoid allocating this when the user does not specify input filter mode. Vector2 mTextFitContentSize; ///< Size of Text fit content - bool mRecalculateNaturalSize : 1; ///< Whether the natural size needs to be recalculated. - bool mMarkupProcessorEnabled : 1; ///< Whether the mark-up procesor is enabled. - bool mClipboardHideEnabled : 1; ///< Whether the ClipboardHide function work or not - bool mIsAutoScrollEnabled : 1; ///< Whether auto text scrolling is enabled. - bool mUpdateTextDirection : 1; ///< Whether the text direction needs to be updated. - CharacterDirection mIsTextDirectionRTL : 1; ///< Whether the text direction is right to left or not + bool mRecalculateNaturalSize : 1; ///< Whether the natural size needs to be recalculated. + bool mMarkupProcessorEnabled : 1; ///< Whether the mark-up procesor is enabled. + bool mClipboardHideEnabled : 1; ///< Whether the ClipboardHide function work or not + bool mIsAutoScrollEnabled : 1; ///< Whether auto text scrolling is enabled. + bool mIsAutoScrollMaxTextureExceeded : 1; ///< Whether auto text scrolling is exceed max texture size. + bool mUpdateTextDirection : 1; ///< Whether the text direction needs to be updated. + CharacterDirection mIsTextDirectionRTL : 1; ///< Whether the text direction is right to left or not bool mUnderlineSetByString : 1; ///< Set when underline is set by string (legacy) instead of map bool mShadowSetByString : 1; ///< Set when shadow is set by string (legacy) instead of map diff --git a/dali-toolkit/internal/text/text-controller-relayouter.cpp b/dali-toolkit/internal/text/text-controller-relayouter.cpp index 3e4c9c8..b9b4f56 100644 --- a/dali-toolkit/internal/text/text-controller-relayouter.cpp +++ b/dali-toolkit/internal/text/text-controller-relayouter.cpp @@ -93,6 +93,12 @@ Size Controller::Relayouter::CalculateLayoutSizeOnRequiredControllerSize(Control { impl.UpdateModel(onlyOnceOperations); + if(impl.mIsAutoScrollEnabled) + { + // Layout the text for the new width. + operationsPending = static_cast(operationsPending | requestedOperationsMask); + } + DoRelayout(impl, requestedControllerSize, static_cast(onlyOnceOperations | requestedOperationsMask), @@ -619,12 +625,15 @@ bool Controller::Relayouter::DoRelayout(Controller::Impl& impl, const Size& size } // Update the visual model. - bool isAutoScrollEnabled = impl.mIsAutoScrollEnabled; + bool isAutoScrollEnabled = impl.mIsAutoScrollEnabled; + bool isAutoScrollMaxTextureExceeded = impl.mIsAutoScrollMaxTextureExceeded; + Size newLayoutSize; viewUpdated = impl.mLayoutEngine.LayoutText(layoutParameters, newLayoutSize, elideTextEnabled, isAutoScrollEnabled, + isAutoScrollMaxTextureExceeded, ellipsisPosition); impl.mIsAutoScrollEnabled = isAutoScrollEnabled; diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index bf92f6a..7cc8831 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -172,6 +172,11 @@ void Controller::SetAutoScrollEnabled(bool enable) mImpl->SetAutoScrollEnabled(enable); } +void Controller::SetAutoScrollMaxTextureExceeded(bool exceed) +{ + mImpl->mIsAutoScrollMaxTextureExceeded = exceed; +} + bool Controller::IsAutoScrollEnabled() const { DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Controller::IsAutoScrollEnabled[%s]\n", mImpl->mIsAutoScrollEnabled ? "true" : "false"); diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index 3e987dd..0def96f 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -257,6 +257,15 @@ public: // Configure the text controller. void SetAutoScrollEnabled(bool enable); /** + * @brief Whether the auto scrolling texture exceed max texture. + * + * By default is false. + * + * @param[in] exceed Whether the auto scrolling texture exceed max texture. + */ + void SetAutoScrollMaxTextureExceeded(bool exceed); + + /** * @brief Retrieves whether auto text scrolling is enabled. * * By default is disabled.