From 3c2a5c792a154d11bd97cf587ae142b277ad45c0 Mon Sep 17 00:00:00 2001 From: suhyung Eom Date: Thu, 2 Feb 2017 18:12:54 +0900 Subject: [PATCH] Changed to use ImfManager for virtual keyboard APIs Signed-off-by: suhyung Eom Change-Id: Ie75184fa24ecb09ae370ccdcb134569ca30db4f8 --- .../utc-Dali-Text-Controller.cpp | 35 ++++++++++- .../toolkit-imf-manager.cpp | 35 ++++++++++- .../dali-toolkit-test-utils/toolkit-imf-manager.h | 30 ++++++++++ .../src/dali-toolkit/utc-Dali-TextField.cpp | 37 +++++++++++- .../controls/text-controls/text-editor-impl.cpp | 48 ++++++---------- .../controls/text-controls/text-editor-impl.h | 3 +- .../controls/text-controls/text-field-impl.cpp | 67 +++++++++++----------- .../controls/text-controls/text-field-impl.h | 4 +- .../internal/text/text-controller-impl.cpp | 24 +++++++- dali-toolkit/internal/text/text-controller-impl.h | 1 + dali-toolkit/internal/text/text-controller.cpp | 17 ++++++ dali-toolkit/internal/text/text-controller.h | 16 ++++++ 12 files changed, 243 insertions(+), 74 deletions(-) diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp index b92f090..9b8217b 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -437,3 +437,36 @@ int UtcDaliTextControllerSetGetAutoScrollEnabled(void) tet_result(TET_PASS); END_TEST; } + +int UtcDaliTextControllerSetGetCheckProperty(void) +{ + tet_infoline(" UtcDaliTextControllerSetGetCheckProperty"); + ToolkitTestApplication application; + + // Creates a text controller. + ControllerPtr controller = Controller::New(); + + DALI_TEST_CHECK( controller ); + + // Enable the text input. + // Creates a decorator. + Text::DecoratorPtr decorator = Text::Decorator::New( *controller, *controller ); + + // Enables the text input. + controller->EnableTextInput( decorator ); + + DALI_TEST_CHECK( !controller->IsInputModePassword() ); + + // Set the text input to password. + controller->SetInputModePassword( true ); + + DALI_TEST_CHECK( controller->IsInputModePassword() ); + + // Unset the text input to password. + controller->SetInputModePassword( false ); + + DALI_TEST_CHECK( !controller->IsInputModePassword() ); + + tet_result(TET_PASS); + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp index 11dfca9..edb97ba 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp @@ -36,6 +36,8 @@ class ImfManager : public Dali::BaseObject public: typedef Dali::ImfManager::ImfManagerSignalType ImfManagerSignalType; typedef Dali::ImfManager::ImfEventSignalType ImfEventSignalType; + typedef Dali::ImfManager::StatusSignalType ImfStatusSignalType; + typedef Dali::ImfManager::VoidSignalType ImfVoidSignalType; public: static Dali::ImfManager Get(); @@ -54,10 +56,14 @@ public: unsigned int GetCursorPosition() const; void SetSurroundingText( const std::string& text ); const std::string& GetSurroundingText() const; + void ApplyOptions( const InputMethodOptions& options ); public: // Signals ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; } ImfEventSignalType& EventReceivedSignal() { return mEventSignal; } + ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; } + ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; } + ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; } protected: virtual ~ImfManager(); @@ -76,10 +82,13 @@ private: std::string mSurroundingText; bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained. bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected. + InputMethodOptions mOptions; ImfManagerSignalType mActivatedSignal; ImfEventSignalType mEventSignal; - + ImfStatusSignalType mKeyboardStatusSignal; + ImfVoidSignalType mKeyboardResizeSignal; + ImfVoidSignalType mKeyboardLanguageChangedSignal; static Dali::ImfManager mToolkitImfManager; @@ -195,6 +204,10 @@ const std::string& ImfManager::GetSurroundingText() const return mSurroundingText; } +void ImfManager::ApplyOptions( const InputMethodOptions& options ) +{ +} + } // Adaptor } // Internal @@ -271,6 +284,11 @@ void ImfManager::NotifyTextInputMultiLine( bool multiLine ) { } +void ImfManager::ApplyOptions( const InputMethodOptions& options ) +{ + Internal::Adaptor::ImfManager::GetImplementation(*this).ApplyOptions( options ); +} + ImfManager::ImfManagerSignalType& ImfManager::ActivatedSignal() { return Internal::Adaptor::ImfManager::GetImplementation(*this).ActivatedSignal(); @@ -281,6 +299,21 @@ ImfManager::ImfEventSignalType& ImfManager::EventReceivedSignal() return Internal::Adaptor::ImfManager::GetImplementation(*this).EventReceivedSignal(); } +ImfManager::StatusSignalType& ImfManager::StatusChangedSignal() +{ + return Internal::Adaptor::ImfManager::GetImplementation(*this).StatusChangedSignal(); +} + +ImfManager::VoidSignalType& ImfManager::ResizedSignal() +{ + return Internal::Adaptor::ImfManager::GetImplementation(*this).ResizedSignal(); +} + +ImfManager::VoidSignalType& ImfManager::LanguageChangedSignal() +{ + return Internal::Adaptor::ImfManager::GetImplementation(*this).LanguageChangedSignal(); +} + ImfManager::ImfManager(Internal::Adaptor::ImfManager *impl) : BaseHandle(impl) { diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.h index 7049354..a777d95 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.h @@ -22,6 +22,7 @@ #define __DALI_IMF_MANAGER_H__ #include #include +#include namespace Dali DALI_IMPORT_API { @@ -133,6 +134,8 @@ public: typedef Signal< void (ImfManager&) > ImfManagerSignalType; ///< Keyboard actived signal typedef Signal< ImfCallbackData ( ImfManager&, const ImfEventData& ) > ImfEventSignalType; ///< keyboard events + typedef Signal< void () > VoidSignalType; + typedef Signal< void (bool) > StatusSignalType; public: @@ -217,6 +220,12 @@ public: */ void NotifyTextInputMultiLine( bool multiLine ); + /** + * @brief Set one or more of the Input Method options + * @param[in] options The options to be applied + */ + void ApplyOptions( const InputMethodOptions& options ); + public: // Signals @@ -235,6 +244,27 @@ public: */ ImfEventSignalType& EventReceivedSignal(); + /** + * @brief Connect to this signal to be notified when the virtual keyboard is shown or hidden. + * + * @return The signal connect to status changed event. + */ + StatusSignalType& StatusChangedSignal(); + + /** + * @brief Connect to this signal to be notified when the virtual keyboard is resized. + * + * @return The signal to connect to resized event. + */ + VoidSignalType& ResizedSignal(); + + /** + * @brief Connect to this signal to be notified when the virtual keyboard's language is changed. + * + * @return The signal to connect to language changed event. + */ + VoidSignalType& LanguageChangedSignal(); + // Construction & Destruction /** diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index ced9421..c1fc637 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -654,6 +654,38 @@ int UtcDaliTextFieldSetPropertyP(void) field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect( 0, 0, 1, 1 ) ); DALI_TEST_EQUALS( field.GetProperty >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect( 0, 0, 1, 1 ), TEST_LOCATION ); + // Check the input method setting + Property::Map propertyMap; + InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER; + InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD; + InputMethod::ActionButtonTitle::Type actionButton = InputMethod::ActionButtonTitle::GO; + int inputVariation = 1; + propertyMap["PANEL_LAYOUT"] = panelLayout; + propertyMap["AUTO_CAPITALISE"] = autoCapital; + propertyMap["ACTION_BUTTON"] = actionButton; + propertyMap["VARIATION"] = inputVariation; + field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap ); + + Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS ); + Property::Map map; + DALI_TEST_CHECK( value.Get( map ) ); + + int layout = 0; + DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) ); + DALI_TEST_EQUALS( static_cast(panelLayout), layout, TEST_LOCATION ); + + int capital = 0; + DALI_TEST_CHECK( map[ "AUTO_CAPITALISE" ].Get( capital ) ); + DALI_TEST_EQUALS( static_cast(autoCapital), capital, TEST_LOCATION ); + + int action = 0; + DALI_TEST_CHECK( map[ "ACTION_BUTTON" ].Get( action ) ); + DALI_TEST_EQUALS( static_cast(actionButton), action, TEST_LOCATION ); + + int variation = 0; + DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) ); + DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION ); + // Check input color property. field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION ); @@ -1840,6 +1872,9 @@ int utcDaliTextFieldEvent07(void) field.SetSize( 300.f, 50.f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + Property::Map propertyMap; + propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD; + field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap ); // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index b6d9900..e7dcd62 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -995,6 +994,8 @@ void TextEditor::OnInitialize() EnableGestureDetection( static_cast( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) ); GetTapGestureDetector().SetMaximumTapsRequired( 2 ); + mImfManager = ImfManager::Get(); + self.TouchSignal().Connect( this, &TextEditor::OnTouched ); // Set BoundingBox to stage size if not already set. @@ -1162,20 +1163,15 @@ void TextEditor::OnKeyInputFocusGained() { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyInputFocusGained %p\n", mController.Get() ); - VirtualKeyboard::StatusChangedSignal().Connect( this, &TextEditor::KeyboardStatusChanged ); + mImfManager.StatusChangedSignal().Connect( this, &TextEditor::KeyboardStatusChanged ); - ImfManager imfManager = ImfManager::Get(); + mImfManager.EventReceivedSignal().Connect( this, &TextEditor::OnImfEvent ); - if ( imfManager ) - { - imfManager.EventReceivedSignal().Connect( this, &TextEditor::OnImfEvent ); + // Notify that the text editing start. + mImfManager.Activate(); - // Notify that the text editing start. - imfManager.Activate(); - - // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated. - imfManager.SetRestoreAfterFocusLost( true ); - } + // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated. + mImfManager.SetRestoreAfterFocusLost( true ); ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); @@ -1193,19 +1189,15 @@ void TextEditor::OnKeyInputFocusLost() { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor:OnKeyInputFocusLost %p\n", mController.Get() ); - VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextEditor::KeyboardStatusChanged ); + mImfManager.StatusChangedSignal().Disconnect( this, &TextEditor::KeyboardStatusChanged ); - ImfManager imfManager = ImfManager::Get(); - if ( imfManager ) - { - // The text editing is finished. Therefore the imf manager don't have restore activation. - imfManager.SetRestoreAfterFocusLost( false ); + // The text editing is finished. Therefore the imf manager don't have restore activation. + mImfManager.SetRestoreAfterFocusLost( false ); - // Notify that the text editing finish. - imfManager.Deactivate(); + // Notify that the text editing finish. + mImfManager.Deactivate(); - imfManager.EventReceivedSignal().Disconnect( this, &TextEditor::OnImfEvent ); - } + mImfManager.EventReceivedSignal().Disconnect( this, &TextEditor::OnImfEvent ); ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); @@ -1223,11 +1215,7 @@ void TextEditor::OnTap( const TapGesture& gesture ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnTap %p\n", mController.Get() ); - // Show the keyboard if it was hidden. - if (!VirtualKeyboard::IsVisible()) - { - VirtualKeyboard::Show(); - } + mImfManager.Activate(); // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y ); @@ -1242,11 +1230,7 @@ void TextEditor::OnPan( const PanGesture& gesture ) void TextEditor::OnLongPress( const LongPressGesture& gesture ) { - // Show the keyboard if it was hidden. - if (!VirtualKeyboard::IsVisible()) - { - VirtualKeyboard::Show(); - } + mImfManager.Activate(); mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y ); diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h index 09465a8..40f5e03 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_TEXT_EDITOR_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -262,6 +262,7 @@ private: // Data Toolkit::TextEditor::TextChangedSignalType mTextChangedSignal; Toolkit::TextEditor::InputStyleChangedSignalType mInputStyleChangedSignal; + ImfManager mImfManager; Text::ControllerPtr mController; Text::RendererPtr mRenderer; Text::DecoratorPtr mDecorator; diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 6a846e4..2aff8e4 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -32,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -590,8 +590,18 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS: { - const Property::Map map = value.Get(); - VirtualKeyboard::ApplySettings( map ); + const Property::Map* map = value.GetMap(); + if (map) + { + impl.mInputMethodOptions.ApplyProperty( *map ); + } + impl.mController->SetInputModePassword( impl.mInputMethodOptions.IsPassword() ); + + Toolkit::Control control = Toolkit::KeyInputFocusManager::Get().GetCurrentFocusControl(); + if (control == textField) + { + impl.mImfManager.ApplyOptions( impl.mInputMethodOptions ); + } break; } case Toolkit::TextField::Property::INPUT_COLOR: @@ -994,6 +1004,9 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } case Toolkit::TextField::Property::INPUT_METHOD_SETTINGS: { + Property::Map map; + impl.mInputMethodOptions.RetrieveProperty( map ); + value = map; break; } case Toolkit::TextField::Property::INPUT_COLOR: @@ -1153,6 +1166,8 @@ void TextField::OnInitialize() EnableGestureDetection( static_cast( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) ); GetTapGestureDetector().SetMaximumTapsRequired( 2 ); + mImfManager = ImfManager::Get(); + self.TouchSignal().Connect( this, &TextField::OnTouched ); // Set BoundingBox to stage size if not already set. @@ -1308,20 +1323,17 @@ void TextField::OnKeyInputFocusGained() { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() ); - VirtualKeyboard::StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged ); + mImfManager.ApplyOptions( mInputMethodOptions ); - ImfManager imfManager = ImfManager::Get(); + mImfManager.StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged ); - if ( imfManager ) - { - imfManager.EventReceivedSignal().Connect( this, &TextField::OnImfEvent ); + mImfManager.EventReceivedSignal().Connect( this, &TextField::OnImfEvent ); - // Notify that the text editing start. - imfManager.Activate(); + // Notify that the text editing start. + mImfManager.Activate(); - // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated. - imfManager.SetRestoreAfterFocusLost( true ); - } + // When window gain lost focus, the imf manager is deactivated. Thus when window gain focus again, the imf manager must be activated. + mImfManager.SetRestoreAfterFocusLost( true ); ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); @@ -1339,19 +1351,14 @@ void TextField::OnKeyInputFocusLost() { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField:OnKeyInputFocusLost %p\n", mController.Get() ); - VirtualKeyboard::StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged ); + mImfManager.StatusChangedSignal().Disconnect( this, &TextField::KeyboardStatusChanged ); + // The text editing is finished. Therefore the imf manager don't have restore activation. + mImfManager.SetRestoreAfterFocusLost( false ); - ImfManager imfManager = ImfManager::Get(); - if ( imfManager ) - { - // The text editing is finished. Therefore the imf manager don't have restore activation. - imfManager.SetRestoreAfterFocusLost( false ); - - // Notify that the text editing finish. - imfManager.Deactivate(); + // Notify that the text editing finish. + mImfManager.Deactivate(); - imfManager.EventReceivedSignal().Disconnect( this, &TextField::OnImfEvent ); - } + mImfManager.EventReceivedSignal().Disconnect( this, &TextField::OnImfEvent ); ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); @@ -1369,11 +1376,7 @@ void TextField::OnTap( const TapGesture& gesture ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get() ); - // Show the keyboard if it was hidden. - if (!VirtualKeyboard::IsVisible()) - { - VirtualKeyboard::Show(); - } + mImfManager.Activate(); // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x, gesture.localPoint.y ); @@ -1388,11 +1391,7 @@ void TextField::OnPan( const PanGesture& gesture ) void TextField::OnLongPress( const LongPressGesture& gesture ) { - // Show the keyboard if it was hidden. - if (!VirtualKeyboard::IsVisible()) - { - VirtualKeyboard::Show(); - } + mImfManager.Activate(); mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y ); diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h index 796e57f..0b7b629 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_TEXT_FIELD_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -265,11 +265,13 @@ private: // Data Toolkit::TextField::MaxLengthReachedSignalType mMaxLengthReachedSignal; Toolkit::TextField::InputStyleChangedSignalType mInputStyleChangedSignal; + ImfManager mImfManager; Text::ControllerPtr mController; Text::RendererPtr mRenderer; Text::DecoratorPtr mDecorator; Toolkit::Control mStencil; ///< For EXCEED_POLICY_CLIP std::vector mClippingDecorationActors; ///< Decoration actors which need clipping. + Dali::InputMethodOptions mInputMethodOptions; Actor mRenderableActor; CallbackBase* mIdleCallback; diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 3a44c2f..c7adc7b 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -55,6 +55,7 @@ struct SelectionBoxInfo const float MAX_FLOAT = std::numeric_limits::max(); const float MIN_FLOAT = std::numeric_limits::min(); const Dali::Toolkit::Text::CharacterDirection LTR = false; ///< Left To Right direction +const uint32_t STAR = 0x2A; } // namespace @@ -100,7 +101,8 @@ EventData::EventData( DecoratorPtr decorator ) mScrollAfterUpdatePosition( false ), mScrollAfterDelete( false ), mAllTextSelected( false ), - mUpdateInputStyle( false ) + mUpdateInputStyle( false ), + mPasswordInput( false ) { mImfManager = ImfManager::Get(); } @@ -767,8 +769,24 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired ) return false; } - Vector& utf32Characters = mModel->mLogicalModel->mText; + Vector utf32CharactersStar; + const Length characterCount = mModel->mLogicalModel->mText.Count(); + const bool isPasswordInput = ( mEventData != NULL && mEventData->mPasswordInput && + !mEventData->mIsShowingPlaceholderText && characterCount > 0 ); + + if (isPasswordInput) + { + utf32CharactersStar.Resize( characterCount ); + + uint32_t* begin = utf32CharactersStar.Begin(); + uint32_t* end = begin + characterCount; + while ( begin < end ) + { + *begin++ = STAR; + } + } + Vector& utf32Characters = isPasswordInput ? utf32CharactersStar : mModel->mLogicalModel->mText; const Length numberOfCharacters = utf32Characters.Count(); // Index to the first character of the first paragraph to be updated. @@ -2556,7 +2574,7 @@ CharacterIndex Controller::Impl::CalculateNewCursorIndex( CharacterIndex index ) const Script script = mModel->mLogicalModel->GetScript( index ); if( HasLigatureMustBreak( script ) ) { - // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ï»», ... + // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ï»», ... numberOfCharacters = 1u; } } diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 424ac0b..0eb8451 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -148,6 +148,7 @@ struct EventData bool mScrollAfterDelete : 1; ///< Whether to scroll after delete characters. bool mAllTextSelected : 1; ///< True if the selection handles are selecting all the text. bool mUpdateInputStyle : 1; ///< Whether to update the input style after moving the cursor. + bool mPasswordInput : 1; ///< True if password input is enabled. bool mCheckScrollAmount : 1; ///< Whether to check scrolled amount after updating the position }; diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 1bb0fed..8500659 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1313,6 +1313,23 @@ const std::string& Controller::GetInputOutlineProperties() const return GetDefaultOutlineProperties(); } +void Controller::SetInputModePassword( bool passwordInput ) +{ + if( NULL != mImpl->mEventData ) + { + mImpl->mEventData->mPasswordInput = passwordInput; + } +} + +bool Controller::IsInputModePassword() +{ + if( NULL != mImpl->mEventData ) + { + return mImpl->mEventData->mPasswordInput; + } + return false; +} + // public : Queries & retrieves. Layout::Engine& Controller::GetLayoutEngine() diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index f5b825e..4bb6f7c 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -334,6 +334,22 @@ public: // Configure the text controller. */ bool IsTextElideEnabled() const; + /** + * @brief Sets input type to password + * + * @note The string is displayed continuous "*" + * + * @param[in] passwordInput True if password input is enabled. + */ + void SetInputModePassword( bool passwordInput ); + + /** + * @brief Returns whether the input mode type is set as password. + * + * @return True if input mode type is password + */ + bool IsInputModePassword(); + public: // Update. /** -- 2.7.4