From: Bowon Ryu Date: Thu, 24 Nov 2022 10:56:16 +0000 (+0900) Subject: [Tizen] Fix hidden input issue X-Git-Tag: accepted/tizen/7.0/unified/20221212.015720~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F284898%2F1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [Tizen] Fix hidden input issue Fixed issues with SHOW_LAST_CHARACTER mode - After all text is deleted, the first input character is not visible. - The last character is always visible regardless of the position of the cursor. Change-Id: I48689bf7e38b05c655d416c4e2df1d4553dca992 Signed-off-by: Bowon Ryu --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index df1c60b..94855ca 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -3012,6 +3012,7 @@ int utcDaliTextFieldEvent09(void) application.Render(); field.SetProperty(TextField::Property::TEXT, "Hello"); + field.SetProperty(TextField::Property::PLACEHOLDER_TEXT, "Placeholder text"); field.SetProperty(TextField::Property::POINT_SIZE, 10.f); field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f)); field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); @@ -3031,6 +3032,12 @@ int utcDaliTextFieldEvent09(void) application.ProcessEvent(GenerateKey("d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); application.SendNotification(); application.Render(); + for(unsigned int index = 0u; index < 6u; ++index) + { + application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE)); + application.SendNotification(); + application.Render(); + } map[HiddenInput::Property::MODE] = HiddenInput::Mode::HIDE_ALL; map[HiddenInput::Property::SUBSTITUTE_CHARACTER] = 0x23; diff --git a/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp b/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp index adf1af0..ff4697b 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp @@ -70,10 +70,17 @@ bool ControllerImplModelUpdater::Update(Controller::Impl& impl, OperationsMask o Vector& srcCharacters = impl.mModel->mLogicalModel->mText; Vector displayCharacters; bool useHiddenText = false; - if(impl.mHiddenInput && impl.mEventData != nullptr && !impl.mEventData->mIsShowingPlaceholderText) + if(impl.mHiddenInput && impl.mEventData != nullptr) { - impl.mHiddenInput->Substitute(srcCharacters, displayCharacters); - useHiddenText = true; + if(impl.mEventData->mIsShowingPlaceholderText) + { + impl.mHiddenInput->InitPreviousTextCount(); + } + else + { + impl.mHiddenInput->Substitute(srcCharacters, displayCharacters, impl.mEventData->mPrimaryCursorPosition); + useHiddenText = true; + } } Vector& utf32Characters = useHiddenText ? displayCharacters : srcCharacters; diff --git a/dali-toolkit/internal/text/hidden-text.cpp b/dali-toolkit/internal/text/hidden-text.cpp index ab2aba5..5259350 100644 --- a/dali-toolkit/internal/text/hidden-text.cpp +++ b/dali-toolkit/internal/text/hidden-text.cpp @@ -42,7 +42,8 @@ HiddenText::HiddenText(Observer* observer) mSubstituteText(STAR), mDisplayDuration(DEFAULT_SHOW_DURATION), mSubstituteCount(0), - mPreviousTextCount(0) + mPreviousTextCount(0u), + mIsLastCharacterShow(false) { mTimer = Timer::New(mDisplayDuration); mTimer.TickSignal().Connect(this, &HiddenText::OnTick); @@ -85,7 +86,7 @@ void HiddenText::GetProperties(Property::Map& map) map[Toolkit::HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION] = mDisplayDuration; } -void HiddenText::Substitute(const Vector& source, Vector& destination) +void HiddenText::Substitute(const Vector& source, Vector& destination, Length cursorPos) { const Length characterCount = source.Count(); @@ -125,14 +126,15 @@ void HiddenText::Substitute(const Vector& source, Vector& } case Toolkit::HiddenInput::Mode::SHOW_LAST_CHARACTER: { + hideStart = begin; + hideEnd = end; if(mPreviousTextCount < characterCount) { - hideStart = begin; - hideEnd = end - 1; if(mDisplayDuration > 0) { mTimer.SetInterval(mDisplayDuration); mTimer.Start(); + mIsLastCharacterShow = true; } else { @@ -141,34 +143,60 @@ void HiddenText::Substitute(const Vector& source, Vector& } else { - hideStart = begin; - hideEnd = end; + mIsLastCharacterShow = false; } break; } } - for(; begin < end; ++begin) + + + if(mHideMode == Toolkit::HiddenInput::Mode::SHOW_LAST_CHARACTER) { - if(begin >= hideStart && begin < hideEnd) + Length currentPos = 0u; + for(; begin < end; ++begin) { - *begin = static_cast(mSubstituteText); + if(begin >= hideStart && begin < hideEnd && cursorPos > 0u && currentPos != cursorPos - 1u) + { + *begin = static_cast(mSubstituteText); + } + else + { + *begin = mIsLastCharacterShow ? *sourcePos : static_cast(mSubstituteText); + } sourcePos++; + currentPos++; } - else + } + else + { + for(; begin < end; ++begin) { - *begin = *sourcePos++; + if(begin >= hideStart && begin < hideEnd) + { + *begin = static_cast(mSubstituteText); + sourcePos++; + } + else + { + *begin = *sourcePos++; + } } } mPreviousTextCount = characterCount; } +void HiddenText::InitPreviousTextCount() +{ + mPreviousTextCount = 0u; +} + bool HiddenText::OnTick() { if(mObserver != NULL) { mObserver->DisplayTimeExpired(); } - + mIsLastCharacterShow = false; return false; } diff --git a/dali-toolkit/internal/text/hidden-text.h b/dali-toolkit/internal/text/hidden-text.h index b13c263..6dcf0c9 100644 --- a/dali-toolkit/internal/text/hidden-text.h +++ b/dali-toolkit/internal/text/hidden-text.h @@ -74,7 +74,12 @@ public: // Intended for internal use * @param[in] source The original text * @param[out] destination The applied text */ - void Substitute(const Vector& source, Vector& destination); + void Substitute(const Vector& source, Vector& destination, Length currentCursorIndex); + + /** + * @brief Initialize the value of PreviousTextCount + */ + void InitPreviousTextCount(); /** * @brief Invoked when the timer is expired @@ -89,6 +94,7 @@ private: int mDisplayDuration; int mSubstituteCount; Length mPreviousTextCount; + bool mIsLastCharacterShow; }; } // namespace Text