From: Bowon Ryu Date: Thu, 24 Nov 2022 10:56:16 +0000 (+0900) Subject: Fix hidden input issue X-Git-Tag: accepted/tizen/unified/20221130.171045^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5c4eea32ac6eff21edbc662f5e879c9614da165;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 df1c60b899..94855caa40 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 adf1af0389..ff4697b7f2 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 ab2aba5cb6..5259350078 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 b13c263c49..6dcf0c91ba 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