From: Seoyeon Kim Date: Mon, 16 Dec 2019 05:20:59 +0000 (+0900) Subject: Add more Preedit enumerations for custom styles X-Git-Tag: dali_1.4.55~5^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F01%2F220201%2F3;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Add more Preedit enumerations for custom styles - Add more preedit styles for substring : CUSTOM_PLATFORM_STYLE_1 ~ 4 - The preedit type is NONE, SUB1 ~ SUB7. But, DALi changed the name exactly, such as 'UNDERLINE' instead of 'SUB1' and 'REVERSE' instead of 'SUB2'. CUSTOM_PLATFORM_STYLE_1 ~ 4 are just to draw the text in underline with various background color. - The index received from imf is a byte. So, it should be converted to character index. Change-Id: Iea64e1bfc27ff291cee592c839013171df75d31c Signed-off-by: Seoyeon Kim --- diff --git a/dali/devel-api/adaptor-framework/input-method-context.cpp b/dali/devel-api/adaptor-framework/input-method-context.cpp index 854134c..4dbbcd3 100755 --- a/dali/devel-api/adaptor-framework/input-method-context.cpp +++ b/dali/devel-api/adaptor-framework/input-method-context.cpp @@ -221,9 +221,9 @@ void InputMethodContext::SetInputPanelPosition( unsigned int x, unsigned int y ) Internal::Adaptor::InputMethodContext::GetImplementation(*this).SetInputPanelPosition( x, y ); } -Dali::InputMethodContext::PreeditStyle InputMethodContext::GetPreeditStyle() const +void InputMethodContext::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const { - return Internal::Adaptor::InputMethodContext::GetImplementation(*this).GetPreeditStyle(); + Internal::Adaptor::InputMethodContext::GetImplementation(*this).GetPreeditStyle( attrs ); } // Signals diff --git a/dali/devel-api/adaptor-framework/input-method-context.h b/dali/devel-api/adaptor-framework/input-method-context.h index 3eb5553..1209d61 100755 --- a/dali/devel-api/adaptor-framework/input-method-context.h +++ b/dali/devel-api/adaptor-framework/input-method-context.h @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include // EXTERNAL INCLUDES #include @@ -104,10 +105,24 @@ public: */ enum class PreeditStyle { - NONE, ///< None style - UNDERLINE, ///< Underline substring style - REVERSE, ///< Reverse substring style - HIGHLIGHT ///< Highlight substring style + NONE, ///< None style + UNDERLINE, ///< Underline substring style + REVERSE, ///< Reverse substring style + HIGHLIGHT, ///< Highlight substring style + CUSTOM_PLATFORM_STYLE_1, ///< Custom style for platform + CUSTOM_PLATFORM_STYLE_2, ///< Custom style for platform + CUSTOM_PLATFORM_STYLE_3, ///< Custom style for platform + CUSTOM_PLATFORM_STYLE_4 ///< Custom style for platform + }; + + /** + * @brief This structure is for the preedit style types and indices. + */ + struct PreeditAttributeData + { + PreeditStyle preeditType; /// The preedit style type + unsigned int startIndex; /// The start index of preedit + unsigned int endIndex; /// The end index of preedit }; /** @@ -476,11 +491,11 @@ public: void SetInputPanelPosition( unsigned int x, unsigned int y ); /** - * @brief Gets the preedit type. + * @brief Gets the preedit attrs data. * - * @return The preedit style type + * @param[out] attrs The preedit attrs data. */ - PreeditStyle GetPreeditStyle() const; + void GetPreeditStyle( Vector& attrs ) const; public: diff --git a/dali/internal/input/common/input-method-context-impl.h b/dali/internal/input/common/input-method-context-impl.h index 35e1765..a923588 100755 --- a/dali/internal/input/common/input-method-context-impl.h +++ b/dali/internal/input/common/input-method-context-impl.h @@ -276,7 +276,7 @@ public: /** * @copydoc Dali::InputMethodContext::GetPreeditStyle() */ - virtual Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const { return Dali::InputMethodContext::PreeditStyle(); } + virtual void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const {} public: // Signals diff --git a/dali/internal/input/generic/input-method-context-impl-generic.cpp b/dali/internal/input/generic/input-method-context-impl-generic.cpp index 04292c4..b84f58e 100644 --- a/dali/internal/input/generic/input-method-context-impl-generic.cpp +++ b/dali/internal/input/generic/input-method-context-impl-generic.cpp @@ -298,11 +298,10 @@ void InputMethodContextGeneric::SetInputPanelPosition( unsigned int x, unsigned DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelPosition\n" ); } -Dali::InputMethodContext::PreeditStyle InputMethodContextGeneric::GetPreeditStyle() const +void InputMethodContextGeneric::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs) const { DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n" ); - - return Dali::InputMethodContext::PreeditStyle::NONE; + // Do Nothing } } // Adaptor diff --git a/dali/internal/input/generic/input-method-context-impl-generic.h b/dali/internal/input/generic/input-method-context-impl-generic.h index a4cec18..2aa4b67 100644 --- a/dali/internal/input/generic/input-method-context-impl-generic.h +++ b/dali/internal/input/generic/input-method-context-impl-generic.h @@ -267,7 +267,7 @@ public: /** * @copydoc Dali::InputMethodContext::GetPreeditStyle() */ - Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override; + void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const override; public: diff --git a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp index 1d7be3e..ab7c78b 100755 --- a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp +++ b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp @@ -324,7 +324,6 @@ InputMethodContextEcoreWl::InputMethodContextEcoreWl( Dali::Actor actor ) mSurroundingText(), mRestoreAfterFocusLost( false ), mIdleCallbackConnected( false ), - mPreeditType( Dali::InputMethodContext::PreeditStyle::NONE ), mWindowId( GetWindowIdFromActor( actor ) ) { ecore_imf_init(); @@ -503,6 +502,8 @@ void InputMethodContextEcoreWl::PreEditChanged( void*, ImfContext* imfContext, v Ecore_IMF_Preedit_Attr* attr; + mPreeditAttrs.Clear(); + // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string. // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string. ecore_imf_context_preedit_string_with_attributes_get( context, &preEditString, &attrs, &cursorPosition ); @@ -512,66 +513,85 @@ void InputMethodContextEcoreWl::PreEditChanged( void*, ImfContext* imfContext, v // iterate through the list of attributes getting the type, start and end position. for ( l = attrs, (attr = static_cast( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast( eina_list_data_get(l) ) )) { + Dali::InputMethodContext::PreeditAttributeData data; + data.startIndex = 0; + data.endIndex = 0; + + size_t visualCharacterIndex = 0; + size_t byteIndex = 0; + + // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ). + const char leadByte = preEditString[byteIndex]; + while( leadByte != '\0' ) + { + // attr->end_index is provided as a byte position not character and we need to know the character position. + const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character. + if( byteIndex <= attr->start_index ) + { + data.startIndex = visualCharacterIndex; + } + if ( byteIndex >= attr->end_index ) + { + data.endIndex = visualCharacterIndex; + break; + // end loop as found cursor position that matches byte position + } + else + { + byteIndex += currentSequenceLength; // jump to next character + visualCharacterIndex++; // increment character count so we know our position for when we get a match + } + } + switch( attr->preedit_type ) { case ECORE_IMF_PREEDIT_TYPE_NONE: { - mPreeditType = Dali::InputMethodContext::PreeditStyle::NONE; + data.preeditType = Dali::InputMethodContext::PreeditStyle::NONE; break; } case ECORE_IMF_PREEDIT_TYPE_SUB1: { - mPreeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE; + data.preeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE; break; } case ECORE_IMF_PREEDIT_TYPE_SUB2: { - mPreeditType = Dali::InputMethodContext::PreeditStyle::REVERSE; + data.preeditType = Dali::InputMethodContext::PreeditStyle::REVERSE; break; } case ECORE_IMF_PREEDIT_TYPE_SUB3: { - mPreeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT; + data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT; break; } - default: + case ECORE_IMF_PREEDIT_TYPE_SUB4: { + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_1; break; } - } - -#ifdef DALI_PROFILE_UBUNTU - if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF) -#else // DALI_PROFILE_UBUNTU - if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF) -#endif // DALI_PROFILE_UBUNTU - { - // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages. - - size_t visualCharacterIndex = 0; - size_t byteIndex = 0; - - // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ). - const char leadByte = preEditString[byteIndex]; - while( leadByte != '\0' ) + case ECORE_IMF_PREEDIT_TYPE_SUB5: { - // attr->end_index is provided as a byte position not character and we need to know the character position. - const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character. - if ( byteIndex == attr->end_index ) - { - cursorPosition = visualCharacterIndex; - break; - // end loop as found cursor position that matches byte position - } - else - { - byteIndex += currentSequenceLength; // jump to next character - visualCharacterIndex++; // increment character count so we know our position for when we get a match - } - - DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString )); + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB6: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB7: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4; + break; + } + default: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::NONE; + break; } } + mPreeditAttrs.PushBack( data ); } } @@ -1125,10 +1145,10 @@ void InputMethodContextEcoreWl::SetInputPanelPosition( unsigned int x, unsigned mBackupOperations[Operation::SET_INPUT_PANEL_POSITION] = std::bind( &InputMethodContextEcoreWl::SetInputPanelPosition, this, x, y ); } -Dali::InputMethodContext::PreeditStyle InputMethodContextEcoreWl::GetPreeditStyle() const +void InputMethodContextEcoreWl::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const { DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetPreeditStyle\n" ); - return mPreeditType; + attrs = mPreeditAttrs; } bool InputMethodContextEcoreWl::ProcessEventKeyDown( const KeyEvent& keyEvent ) diff --git a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h index 095e914..4ffac3a 100755 --- a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h +++ b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h @@ -265,7 +265,7 @@ public: /** * @copydoc Dali::InputMethodContext::GetPreeditStyle() */ - Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override; + void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const override; private: /** @@ -345,7 +345,7 @@ private: std::vector mKeyEvents; ///< Stores key events to be sent from idle call-back. InputMethodOptions mOptions; - Dali::InputMethodContext::PreeditStyle mPreeditType; + Vector< Dali::InputMethodContext::PreeditAttributeData > mPreeditAttrs; ///< Stores preedit attr data int mWindowId; }; diff --git a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp index 1b516c2..ce6a57c 100755 --- a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp +++ b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp @@ -149,8 +149,7 @@ InputMethodContextX::InputMethodContextX( Dali::Actor actor ) mIMFCursorPosition( 0 ), mSurroundingText(), mRestoreAfterFocusLost( false ), - mIdleCallbackConnected( false ), - mPreeditType( Dali::InputMethodContext::PreeditStyle::NONE ) + mIdleCallbackConnected( false ) { ecore_imf_init(); @@ -314,6 +313,8 @@ void InputMethodContextX::PreEditChanged( void*, ImfContext* imfContext, void* e Ecore_IMF_Preedit_Attr* attr; + mPreeditAttrs.Clear(); + // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string. // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string. ecore_imf_context_preedit_string_with_attributes_get( context, &preEditString, &attrs, &cursorPosition ); @@ -323,66 +324,85 @@ void InputMethodContextX::PreEditChanged( void*, ImfContext* imfContext, void* e // iterate through the list of attributes getting the type, start and end position. for ( l = attrs, (attr = static_cast( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast( eina_list_data_get(l) ) )) { + Dali::InputMethodContext::PreeditAttributeData data; + data.startIndex = 0; + data.endIndex = 0; + + size_t visualCharacterIndex = 0; + size_t byteIndex = 0; + + // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ). + const char leadByte = preEditString[byteIndex]; + while( leadByte != '\0' ) + { + // attr->end_index is provided as a byte position not character and we need to know the character position. + const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character. + if( byteIndex <= attr->start_index ) + { + data.startIndex = visualCharacterIndex; + } + if ( byteIndex >= attr->end_index ) + { + data.endIndex = visualCharacterIndex; + break; + // end loop as found cursor position that matches byte position + } + else + { + byteIndex += currentSequenceLength; // jump to next character + visualCharacterIndex++; // increment character count so we know our position for when we get a match + } + } + switch( attr->preedit_type ) { case ECORE_IMF_PREEDIT_TYPE_NONE: { - mPreeditType = Dali::InputMethodContext::PreeditStyle::NONE; + data.preeditType = Dali::InputMethodContext::PreeditStyle::NONE; break; } case ECORE_IMF_PREEDIT_TYPE_SUB1: { - mPreeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE; + data.preeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE; break; } case ECORE_IMF_PREEDIT_TYPE_SUB2: { - mPreeditType = Dali::InputMethodContext::PreeditStyle::REVERSE; + data.preeditType = Dali::InputMethodContext::PreeditStyle::REVERSE; break; } case ECORE_IMF_PREEDIT_TYPE_SUB3: { - mPreeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT; + data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT; break; } - default: + case ECORE_IMF_PREEDIT_TYPE_SUB4: { + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_1; break; } - } - -#ifdef DALI_PROFILE_UBUNTU - if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF) -#else // DALI_PROFILE_UBUNTU - if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF) -#endif // DALI_PROFILE_UBUNTU - { - // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages. - - size_t visualCharacterIndex = 0; - size_t byteIndex = 0; - - // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ). - const char leadByte = preEditString[byteIndex]; - while( leadByte != '\0' ) + case ECORE_IMF_PREEDIT_TYPE_SUB5: { - // attr->end_index is provided as a byte position not character and we need to know the character position. - const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character. - if ( byteIndex == attr->end_index ) - { - cursorPosition = static_cast( visualCharacterIndex ); - break; - // end loop as found cursor position that matches byte position - } - else - { - byteIndex += currentSequenceLength; // jump to next character - visualCharacterIndex++; // increment character count so we know our position for when we get a match - } - - DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString )); + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB6: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB7: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4; + break; + } + default: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::NONE; + break; } } + mPreeditAttrs.PushBack( data ); } } @@ -820,10 +840,10 @@ void InputMethodContextX::SetInputPanelPosition( unsigned int x, unsigned int y // ecore_imf_context_input_panel_position_set() is supported from ecore-imf 1.21.0 version. } -Dali::InputMethodContext::PreeditStyle InputMethodContextX::GetPreeditStyle() const +void InputMethodContextX::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const { DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n" ); - return mPreeditType; + attrs = mPreeditAttrs; } bool InputMethodContextX::ProcessEventKeyDown( const KeyEvent& keyEvent ) diff --git a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.h b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.h index f3222d8..f4de117 100755 --- a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.h +++ b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.h @@ -271,7 +271,7 @@ public: /** * @copydoc Dali::InputMethodContext::GetPreeditStyle() */ - Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override; + void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const override; private: /** @@ -346,7 +346,7 @@ private: 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; - Dali::InputMethodContext::PreeditStyle mPreeditType; + Vector< Dali::InputMethodContext::PreeditAttributeData > mPreeditAttrs; ///< Stores preedit attr data }; } // namespace Adaptor diff --git a/dali/internal/input/windows/input-method-context-impl-win.cpp b/dali/internal/input/windows/input-method-context-impl-win.cpp index 3902cb0..dad833c 100755 --- a/dali/internal/input/windows/input-method-context-impl-win.cpp +++ b/dali/internal/input/windows/input-method-context-impl-win.cpp @@ -62,8 +62,7 @@ InputMethodContextWin::InputMethodContextWin( Dali::Actor actor ) mIMFCursorPosition( 0 ), mSurroundingText(), mRestoreAfterFocusLost( false ), - mIdleCallbackConnected( false ), - mPreeditType( Dali::InputMethodContext::PreeditStyle::NONE ) + mIdleCallbackConnected( false ) { actor.OnStageSignal().Connect( this, &InputMethodContextWin::OnStaged ); @@ -365,10 +364,10 @@ void InputMethodContextWin::SetInputPanelPosition( unsigned int x, unsigned int DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelPosition\n" ); } -Dali::InputMethodContext::PreeditStyle InputMethodContextWin::GetPreeditStyle() const +void InputMethodContextWin::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const { DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetPreeditStyle\n" ); - return mPreeditType; + attrs = mPreeditAttrs; } bool InputMethodContextWin::ProcessEventKeyDown( const KeyEvent& keyEvent ) diff --git a/dali/internal/input/windows/input-method-context-impl-win.h b/dali/internal/input/windows/input-method-context-impl-win.h index fffc088..1af29ef 100755 --- a/dali/internal/input/windows/input-method-context-impl-win.h +++ b/dali/internal/input/windows/input-method-context-impl-win.h @@ -259,7 +259,7 @@ public: /** * @copydoc Dali::InputMethodContext::GetPreeditStyle() */ - Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override; + void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const override; private: /** @@ -319,7 +319,7 @@ private: 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; - Dali::InputMethodContext::PreeditStyle mPreeditType; + Vector< Dali::InputMethodContext::PreeditAttributeData > mPreeditAttrs; }; } // namespace Adaptor