From d5f5622b5e4ac08d630e37c1710261830efe2c35 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Tue, 29 Nov 2022 19:48:44 +0900 Subject: [PATCH] fix white space issue in hidden input The calculated text size is used in atlas renderer. When the text is all white space, partial render issue occurs because the width is 0. To avoid issue, do not remove the white space size in hidden input mode. Change-Id: Id92becdb0103fa6dee20c5cd272ee3d4314121c6 Signed-off-by: Bowon Ryu --- .../dali-toolkit-test-utils/toolkit-text-utils.cpp | 2 ++ .../utc-Dali-Text-CharacterSpacing.cpp | 2 ++ .../dali-toolkit-internal/utc-Dali-Text-Layout.cpp | 2 ++ dali-toolkit/devel-api/text/text-utils-devel.cpp | 2 ++ .../text/controller/text-controller-relayouter.cpp | 6 ++++++ dali-toolkit/internal/text/hidden-text.cpp | 5 +++++ dali-toolkit/internal/text/hidden-text.h | 6 ++++++ .../internal/text/layouts/layout-engine.cpp | 24 +++++++++++++++++----- dali-toolkit/internal/text/layouts/layout-engine.h | 2 ++ 9 files changed, 46 insertions(+), 5 deletions(-) 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 5fc9349..046f997 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 @@ -353,11 +353,13 @@ void CreateTextModel(const std::string& text, bool isAutoScroll = false; bool isAutoScrollMaxTextureExceeded = false; + bool isHiddenInputEnabled = false; layoutEngine.LayoutText(layoutParameters, layoutSize, false, isAutoScroll, isAutoScrollMaxTextureExceeded, + isHiddenInputEnabled, 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 5a15b09..8e84bc4 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 @@ -182,11 +182,13 @@ bool LayoutTextTest(const LayoutTextData& data) bool isAutoScroll = false; bool isAutoScrollMaxTextureExceeded = false; + bool isHiddenInputEnabled = false; const bool updated = engine.LayoutText(layoutParameters, layoutSize, data.ellipsis, isAutoScroll, isAutoScrollMaxTextureExceeded, + isHiddenInputEnabled, 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 index 6ec3bfe..9792612 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp @@ -182,11 +182,13 @@ bool LayoutTextTest(const LayoutTextData& data) bool isAutoScroll = false; bool isAutoScrollMaxTextureExceeded = false; + bool isHiddenInputEnabled = false; const bool updated = engine.LayoutText(layoutParameters, layoutSize, data.ellipsis, isAutoScroll, isAutoScrollMaxTextureExceeded, + isHiddenInputEnabled, 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 401b82f..07c89ff 100644 --- a/dali-toolkit/devel-api/text/text-utils-devel.cpp +++ b/dali-toolkit/devel-api/text/text-utils-devel.cpp @@ -1067,12 +1067,14 @@ Size LayoutText(const RendererParameters& textParameters, TextAbstraction::TextR Size newLayoutSize; bool isAutoScrollEnabled = false; bool isAutoScrollMaxTextureExceeded = false; + bool isHiddenInputEnabled = false; layoutEngine.LayoutText(layoutParameters, newLayoutSize, textParameters.ellipsisEnabled, isAutoScrollEnabled, isAutoScrollMaxTextureExceeded, + isHiddenInputEnabled, ellipsisPosition); return newLayoutSize; diff --git a/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp b/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp index f95019a..48df46e 100644 --- a/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp @@ -641,6 +641,11 @@ bool Controller::Relayouter::DoRelayout(Controller::Impl& impl, const Size& size // Update the visual model. bool isAutoScrollEnabled = impl.mIsAutoScrollEnabled; bool isAutoScrollMaxTextureExceeded = impl.mIsAutoScrollMaxTextureExceeded; + bool isHiddenInputEnabled = false; + if(impl.mHiddenInput && impl.mEventData != nullptr && impl.mHiddenInput->GetHideMode() != Toolkit::HiddenInput::Mode::HIDE_NONE) + { + isHiddenInputEnabled = true; + } Size newLayoutSize; viewUpdated = impl.mLayoutEngine.LayoutText(layoutParameters, @@ -648,6 +653,7 @@ bool Controller::Relayouter::DoRelayout(Controller::Impl& impl, const Size& size elideTextEnabled, isAutoScrollEnabled, isAutoScrollMaxTextureExceeded, + isHiddenInputEnabled, ellipsisPosition); impl.mIsAutoScrollEnabled = isAutoScrollEnabled; diff --git a/dali-toolkit/internal/text/hidden-text.cpp b/dali-toolkit/internal/text/hidden-text.cpp index 5259350..4f0cabf 100644 --- a/dali-toolkit/internal/text/hidden-text.cpp +++ b/dali-toolkit/internal/text/hidden-text.cpp @@ -190,6 +190,11 @@ void HiddenText::InitPreviousTextCount() mPreviousTextCount = 0u; } +int HiddenText::GetHideMode() +{ + return mHideMode; +} + bool HiddenText::OnTick() { if(mObserver != NULL) diff --git a/dali-toolkit/internal/text/hidden-text.h b/dali-toolkit/internal/text/hidden-text.h index 6dcf0c9..49d8010 100644 --- a/dali-toolkit/internal/text/hidden-text.h +++ b/dali-toolkit/internal/text/hidden-text.h @@ -82,6 +82,12 @@ public: // Intended for internal use void InitPreviousTextCount(); /** + * @brief Returns the hide mode of hidden text. + * @return The hide mode of hidden text. + */ + int GetHideMode(); + + /** * @brief Invoked when the timer is expired */ bool OnTick(); diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 39af47c..7bbf2cc 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -667,6 +667,7 @@ struct Engine::Impl * @param[out] lineLayout The line layout. * @param[in] completelyFill Whether to completely fill the line ( even if the last word exceeds the boundaries ). * @param[in] ellipsisPosition Where is the location the text elide + * @param[in] hiddenInputEnabled Whether the hidden input is enabled. */ void GetLineLayoutForBox(const Parameters& parameters, LayoutBidiParameters& bidiParameters, @@ -674,7 +675,8 @@ struct Engine::Impl bool completelyFill, DevelText::EllipsisPosition::Type ellipsisPosition, bool enforceEllipsisInSingleLine, - bool elideTextEnabled) + bool elideTextEnabled, + bool hiddenInputEnabled) { DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->GetLineLayoutForBox\n"); DALI_LOG_INFO(gLogFilter, Debug::Verbose, " initial glyph index : %d\n", lineLayout.glyphIndex); @@ -826,7 +828,10 @@ struct Engine::Impl const float previousTmpLength = tmpLineLayout.length; const float previousTmpWhiteSpaceLengthEndOfLine = tmpLineLayout.whiteSpaceLengthEndOfLine; - if(isWhiteSpace) + // The calculated text size is used in atlas renderer. + // When the text is all white space, partial render issue occurs because the width is 0. + // To avoid issue, do not remove the white space size in hidden input mode. + if(isWhiteSpace && !hiddenInputEnabled) { // Add the length to the length of white spaces at the end of the line. tmpLineLayout.whiteSpaceLengthEndOfLine += glyphMetrics.advance; @@ -907,7 +912,7 @@ struct Engine::Impl tmpLineLayout.numberOfGlyphs -= numberOfGLyphsInGroup; } - if(isRemovedGlyphWhiteSpace) + if(isRemovedGlyphWhiteSpace && !hiddenInputEnabled) { tmpLineLayout.penX -= glyphMetrics.advance; tmpLineLayout.length -= glyphMetrics.advance; @@ -1247,6 +1252,7 @@ struct Engine::Impl * @param[in] penY The vertical layout position. * @param[in] currentParagraphDirection The current paragraph's direction. * @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] isHiddenInputEnabled Whether the hidden input is enabled. * @param[in] ellipsisPosition Where is the location the text elide * * return Whether the line is ellipsized. @@ -1261,6 +1267,7 @@ struct Engine::Impl float penY, bool& isAutoScrollEnabled, bool isAutoScrollMaxTextureExceeded, + bool isHiddenInputEnabled, DevelText::EllipsisPosition::Type ellipsisPosition, bool enforceEllipsisInSingleLine) { @@ -1310,7 +1317,8 @@ struct Engine::Impl true, ellipsisPosition, enforceEllipsisInSingleLine, - true); + true, + isHiddenInputEnabled); if(ellipsisPosition == DevelText::EllipsisPosition::START && !isMultiline) { @@ -1608,6 +1616,7 @@ struct Engine::Impl bool elideTextEnabled, bool& isAutoScrollEnabled, bool isAutoScrollMaxTextureExceeded, + bool isHiddenInputEnabled, DevelText::EllipsisPosition::Type ellipsisPosition) { DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->LayoutText\n"); @@ -1797,7 +1806,8 @@ struct Engine::Impl false, ellipsisPosition, false, - elideTextEnabled); + elideTextEnabled, + isHiddenInputEnabled); DALI_LOG_INFO(gLogFilter, Debug::Verbose, " glyph index %d\n", layout.glyphIndex); DALI_LOG_INFO(gLogFilter, Debug::Verbose, " character index %d\n", layout.characterIndex); @@ -1848,6 +1858,7 @@ struct Engine::Impl penY, isAutoScrollEnabled, isAutoScrollMaxTextureExceeded, + isHiddenInputEnabled, ellipsisPosition, false); } @@ -1867,6 +1878,7 @@ struct Engine::Impl penY, isAutoScrollEnabled, isAutoScrollMaxTextureExceeded, + isHiddenInputEnabled, ellipsisPosition, true); } @@ -2262,6 +2274,7 @@ bool Engine::LayoutText(Parameters& layoutParameters, bool elideTextEnabled, bool& isAutoScrollEnabled, bool isAutoScrollMaxTextureExceeded, + bool isHiddenInputEnabled, DevelText::EllipsisPosition::Type ellipsisPosition) { return mImpl->LayoutText(layoutParameters, @@ -2269,6 +2282,7 @@ bool Engine::LayoutText(Parameters& layoutParameters, elideTextEnabled, isAutoScrollEnabled, isAutoScrollMaxTextureExceeded, + isHiddenInputEnabled, ellipsisPosition); } diff --git a/dali-toolkit/internal/text/layouts/layout-engine.h b/dali-toolkit/internal/text/layouts/layout-engine.h index 9fa22c6..5fa41d6 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.h +++ b/dali-toolkit/internal/text/layouts/layout-engine.h @@ -108,6 +108,7 @@ public: * @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] isHiddenInputEnabled if isHiddenInputEnabled is true, hidden input feature is enabled. * @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. @@ -117,6 +118,7 @@ public: bool elideTextEnabled, bool& isAutoScrollEnabled, bool isAutoScrollMaxTextureExceeded, + bool isHiddenInputEnabled, DevelText::EllipsisPosition::Type ellipsisPosition); /** -- 2.7.4