X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fdevel-api%2Fadaptor-framework%2Finput-method-context.h;h=0487b068bbb7722115a2939c14d4b17612cae39f;hb=HEAD;hp=1209d61ef8c4815bb852e371196157eb3c2bdc2b;hpb=b5df1bb407571346d34ca2131928f82671fee584;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/devel-api/adaptor-framework/input-method-context.h b/dali/devel-api/adaptor-framework/input-method-context.h old mode 100755 new mode 100644 index 1209d61..8a76899 --- a/dali/devel-api/adaptor-framework/input-method-context.h +++ b/dali/devel-api/adaptor-framework/input-method-context.h @@ -2,7 +2,7 @@ #define DALI_INPUT_METHOD_CONTEXT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -19,24 +19,23 @@ */ // EXTERNAL INCLUDES -#include #include +#include // EXTERNAL INCLUDES +#include #include #include -#include namespace Dali { - namespace Internal DALI_INTERNAL { namespace Adaptor { class InputMethodContext; } -} +} // namespace DALI_INTERNAL class Actor; @@ -48,14 +47,13 @@ class Actor; class DALI_ADAPTOR_API InputMethodContext : public BaseHandle { public: - /** - * @brief The direction of text. - */ + * @brief The direction of text. + */ enum TextDirection { - LeftToRight, - RightToLeft, + LEFT_TO_RIGHT, + RIGHT_TO_LEFT, }; /** @@ -63,12 +61,13 @@ public: */ enum EventType { - VOID, ///< No event - PRE_EDIT, ///< Pre-Edit changed - COMMIT, ///< Commit recieved - DELETE_SURROUNDING, ///< Event to delete a range of characters from the string - GET_SURROUNDING, ///< Event to query string and cursor position - PRIVATE_COMMAND ///< Private command sent from the input panel + VOID, ///< No event + PRE_EDIT, ///< Pre-Edit changed + COMMIT, ///< Commit recieved + DELETE_SURROUNDING, ///< Event to delete a range of characters from the string + GET_SURROUNDING, ///< Event to query string and cursor position + PRIVATE_COMMAND, ///< Private command sent from the input panel + SELECTION_SET ///< input method needs to set the selection }; /** @@ -76,10 +75,10 @@ public: */ enum State { - DEFAULT = 0, ///< Unknown state - SHOW, ///< Input panel is shown - HIDE, ///< Input panel is hidden - WILL_SHOW ///< Input panel in process of being shown + DEFAULT = 0, ///< Unknown state + SHOW, ///< Input panel is shown + HIDE, ///< Input panel is hidden + WILL_SHOW ///< Input panel in process of being shown }; /** @@ -87,8 +86,8 @@ public: */ enum KeyboardType { - SOFTWARE_KEYBOARD, ///< Software keyboard (Virtual keyboard) is default - HARDWARE_KEYBOARD ///< Hardware keyboard + SOFTWARE_KEYBOARD, ///< Software keyboard (Virtual keyboard) is default + HARDWARE_KEYBOARD ///< Hardware keyboard }; /** @@ -96,8 +95,24 @@ public: */ enum class InputPanelLanguage { - AUTOMATIC, ///< IME Language automatically set depending on the system display - ALPHABET ///< Latin alphabet at all times + AUTOMATIC, ///< IME Language automatically set depending on the system display + ALPHABET ///< Latin alphabet(default). It can be changed according to OSD(On Screen Display) language. + }; + + /** + * @brief Enumeration for defining the types of Ecore_IMF Input Panel align. + */ + enum class InputPanelAlign + { + TOP_LEFT, ///< The top-left corner + TOP_CENTER, ///< The top-center position + TOP_RIGHT, ///< The top-right corner + MIDDLE_LEFT, ///< The middle-left position + MIDDLE_CENTER, ///< The middle-center position + MIDDLE_RIGHT, ///< The middle-right position + BOTTOM_LEFT, ///< The bottom-left corner + BOTTOM_CENTER, ///< The bottom-center position + BOTTOM_RIGHT ///< The bottom-right corner }; /** @@ -120,6 +135,13 @@ public: */ struct PreeditAttributeData { + PreeditAttributeData() + : preeditType(PreeditStyle::NONE), + startIndex(0), + endIndex(0) + { + } + PreeditStyle preeditType; /// The preedit style type unsigned int startIndex; /// The start index of preedit unsigned int endIndex; /// The end index of preedit @@ -135,11 +157,11 @@ public: */ EventData() : predictiveString(), - eventName( VOID ), - cursorOffset( 0 ), - numberOfChars ( 0 ) - { - }; + eventName(VOID), + cursorOffset(0), + numberOfChars(0), + startIndex(0), + endIndex(0){}; /** * @brief Constructor @@ -149,19 +171,40 @@ public: * @param[in] aCursorOffset Start position from the current cursor position to start deleting characters. * @param[in] aNumberOfChars The number of characters to delete from the cursorOffset. */ - EventData( EventType aEventName, const std::string& aPredictiveString, int aCursorOffset, int aNumberOfChars ) - : predictiveString( aPredictiveString ), - eventName( aEventName ), - cursorOffset( aCursorOffset ), - numberOfChars( aNumberOfChars ) + EventData(EventType aEventName, const std::string& aPredictiveString, int aCursorOffset, int aNumberOfChars) + : predictiveString(aPredictiveString), + eventName(aEventName), + cursorOffset(aCursorOffset), + numberOfChars(aNumberOfChars), + startIndex(0), + endIndex(0) + { + } + + /** + * @brief Constructor + * + * @param[in] aEventName The name of the event from the InputMethodContext. + * @param[in] aStartIndex The start index of selection. + * @param[in] aEndIndex The end index of selection. + */ + EventData(EventType aEventName, int aStartIndex, int aEndIndex) + : predictiveString(), + eventName(aEventName), + cursorOffset(0), + numberOfChars(0), + startIndex(aStartIndex), + endIndex(aEndIndex) { } // Data std::string predictiveString; ///< The pre-edit or commit string. - EventType eventName; ///< The name of the event from the InputMethodContext. - int cursorOffset; ///< Start position from the current cursor position to start deleting characters. - int numberOfChars; ///< number of characters to delete from the cursorOffset. + EventType eventName; ///< The name of the event from the InputMethodContext. + int cursorOffset; ///< Start position from the current cursor position to start deleting characters. + int numberOfChars; ///< number of characters to delete from the cursorOffset. + int startIndex; ///< The start index of selection. + int endIndex; ///< The end index of selection. }; /** @@ -174,9 +217,9 @@ public: */ CallbackData() : currentText(), - cursorPosition( 0 ), - update( false ), - preeditResetRequired( false ) + cursorPosition(0), + update(false), + preeditResetRequired(false) { } @@ -187,34 +230,33 @@ public: * @param[in] aCurrentText current text string * @param[in] aPreeditResetRequired flag if preedit reset is required. */ - CallbackData( bool aUpdate, int aCursorPosition, const std::string& aCurrentText, bool aPreeditResetRequired ) - : currentText( aCurrentText ), - cursorPosition( aCursorPosition ), - update( aUpdate ), - preeditResetRequired( aPreeditResetRequired ) + CallbackData(bool aUpdate, int aCursorPosition, const std::string& aCurrentText, bool aPreeditResetRequired) + : currentText(aCurrentText), + cursorPosition(aCursorPosition), + update(aUpdate), + preeditResetRequired(aPreeditResetRequired) { } - std::string currentText; ///< current text string - int cursorPosition; ///< new position of cursor - bool update :1; ///< if cursor position needs to be updated - bool preeditResetRequired :1; ///< flag if preedit reset is required. + std::string currentText; ///< current text string + int cursorPosition; ///< new position of cursor + bool update : 1; ///< if cursor position needs to be updated + bool preeditResetRequired : 1; ///< flag if preedit reset is required. }; - typedef Signal< void (InputMethodContext&) > ActivatedSignalType; ///< Keyboard actived signal - typedef Signal< CallbackData ( InputMethodContext&, const EventData& ) > KeyboardEventSignalType; ///< keyboard events - typedef Signal< void () > VoidSignalType; - typedef Signal< void ( bool ) > StatusSignalType; - typedef Signal< void ( KeyboardType ) > KeyboardTypeSignalType; ///< keyboard type - typedef Signal< void ( int ) > KeyboardResizedSignalType; ///< Keyboard resized signal - typedef Signal< void ( int ) > LanguageChangedSignalType; ///< Language changed signal - typedef Signal< void ( const std::string&, const std::string&, const std::string& ) > ContentReceivedSignalType; ///< Content received signal + typedef Signal ActivatedSignalType; ///< Keyboard actived signal + typedef Signal KeyboardEventSignalType; ///< keyboard events + typedef Signal VoidSignalType; + typedef Signal StatusSignalType; + typedef Signal KeyboardTypeSignalType; ///< keyboard type + typedef Signal KeyboardResizedSignalType; ///< Keyboard resized signal + typedef Signal LanguageChangedSignalType; ///< Language changed signal + typedef Signal ContentReceivedSignalType; ///< Content received signal -public: + using PreEditAttributeDataContainer = Vector; +public: /** - * @brief Retrieve a handle to the instance of InputMethodContext. - * @return A handle to the InputMethodContext. * @brief Constructor. */ InputMethodContext(); @@ -236,14 +278,14 @@ public: * * @param[in] actor The actor that uses the new InputMethodContext instance. */ - static InputMethodContext New( Actor actor ); + static InputMethodContext New(Actor actor); /** * @brief Copy constructor. * * @param[in] inputMethodContext InputMethodContext to copy. The copied inputMethodContext will point at the same implementation. */ - InputMethodContext( const InputMethodContext& inputMethodContext ); + InputMethodContext(const InputMethodContext& inputMethodContext); /** * @brief Assignment operator. @@ -251,7 +293,7 @@ public: * @param[in] inputMethodContext The InputMethodContext to assign from. * @return The updated InputMethodContext. */ - InputMethodContext& operator=( const InputMethodContext& inputMethodContext ); + InputMethodContext& operator=(const InputMethodContext& inputMethodContext); /** * @brief Downcast a handle to InputMethodContext handle. @@ -262,10 +304,9 @@ public: * @param[in] handle Handle to an object. * @return Handle to an InputMethodContext or an uninitialized handle. */ - static InputMethodContext DownCast( BaseHandle handle ); + static InputMethodContext DownCast(BaseHandle handle); public: - /** * @brief Finalize the InputMethodContext. * @@ -301,7 +342,7 @@ public: * * @param[in] toggle True means that keyboard should be restored after focus lost and regained. */ - void SetRestoreAfterFocusLost( bool toggle ); + void SetRestoreAfterFocusLost(bool toggle); /** * @brief Send message reset the pred-edit state / InputMethodContext module. @@ -320,7 +361,7 @@ public: * * @param[in] cursorPosition position of cursor */ - void SetCursorPosition( unsigned int cursorPosition ); + void SetCursorPosition(unsigned int cursorPosition); /** * @brief Gets cursor position stored in VirtualKeyboard, this is required by the InputMethodContext. @@ -334,7 +375,7 @@ public: * * @param[in] text The text string surrounding the current cursor point. */ - void SetSurroundingText( const std::string& text ); + void SetSurroundingText(const std::string& text); /** * @brief Gets current text string set within the InputMethodContext manager, this is used to offer predictive suggestions. @@ -348,7 +389,7 @@ public: * * @param[in] multiLine True if multiline text input is used */ - void NotifyTextInputMultiLine( bool multiLine ); + void NotifyTextInputMultiLine(bool multiLine); /** * @brief Returns text direction of the keyboard's current input language. @@ -371,13 +412,13 @@ public: * @brief Set one or more of the Input Method options * @param[in] options The options to be applied */ - void ApplyOptions( const InputMethodOptions& options ); + void ApplyOptions(const InputMethodOptions& options); /** * @brief Sets up the input-panel specific data. * @param[in] data The specific data to be set to the input panel */ - void SetInputPanelData( const std::string& data ); + void SetInputPanelData(const std::string& data); /** * @brief Gets the specific data of the current active input panel. @@ -387,7 +428,7 @@ public: * It is just used to get a specific data from the input panel to an application. * @param[in] data The specific data to be got from the input panel */ - void GetInputPanelData( std::string& data ); + void GetInputPanelData(std::string& data); /** * @brief Gets the state of the current active input panel. @@ -401,13 +442,13 @@ public: * The default is true. * @param[in] visible True if the return key is visible(enabled), false otherwise. */ - void SetReturnKeyState( bool visible ); + void SetReturnKeyState(bool visible); /** * @brief Enable to show the input panel automatically when focused. * @param[in] enabled If true, the input panel will be shown when focused */ - void AutoEnableInputPanel( bool enabled ); + void AutoEnableInputPanel(bool enabled); /** * @brief Shows the input panel. @@ -443,7 +484,7 @@ public: * You can receive a media content URI and its MIME type from ContentReceivedSignal(). @see ContentReceivedSignal * @param[in] mimeTypes The allowed MIME types */ - void SetContentMIMETypes( const std::string& mimeTypes ); + void SetContentMIMETypes(const std::string& mimeTypes); /** * @brief Process event key down or up, whether filter a key to isf. @@ -451,14 +492,14 @@ public: * @param[in] keyEvent The event key to be handled. * @return Whether the event key is handled. */ - bool FilterEventKey( const Dali::KeyEvent& keyEvent ); + bool FilterEventKey(const Dali::KeyEvent& keyEvent); /** * @brief Sets whether the IM context should allow to use the text prediction. * * @param[in] prediction Whether to allow text prediction or not. */ - void AllowTextPrediction( bool prediction ); + void AllowTextPrediction(bool prediction); /** * @brief Gets whether the IM context allow to use the text prediction. @@ -473,7 +514,7 @@ public: * This method can be used when you want to show the English keyboard. * @param[in] language The language to be set to the input panel */ - void SetInputPanelLanguage( InputPanelLanguage language ); + void SetInputPanelLanguage(InputPanelLanguage language); /** * @brief Gets the language of the input panel. @@ -488,17 +529,30 @@ public: * @param[in] x The top-left x coordinate of the input panel * @param[in] y The top-left y coordinate of the input panel */ - void SetInputPanelPosition( unsigned int x, unsigned int y ); + void SetInputPanelPosition(unsigned int x, unsigned int y); /** - * @brief Gets the preedit attrs data. + * @brief Sets the alignment and its x, y coordinates of the input panel. + * + * Regardless of the rotation degree, the x, y values of the top-left corner on the screen are based on 0, 0. + * When the IME size is changed, its size will change according to the set alignment. * - * @param[out] attrs The preedit attrs data. + * @param[in] x The x coordinate of the InputPanelAlign value. + * @param[in] y The y coordinate of the InputPanelAlign value. + * @param[in] align one of the InputPanelAlign values specifying the desired alignment. + * @return true on success, false otherwise. + * @remarks This API can be used to set the alignment of a floating IME. */ - void GetPreeditStyle( Vector& attrs ) const; + bool SetInputPanelPositionAlign(int x, int y, InputPanelAlign align); -public: + /** + * @brief Gets the preedit attributes data. + * + * @param[out] attrs The preedit attributes data. + */ + void GetPreeditStyle(PreEditAttributeDataContainer& attrs) const; +public: // Signals /** @@ -581,18 +635,14 @@ public: ContentReceivedSignalType& ContentReceivedSignal(); public: - /** * @brief This constructor is used by InputMethodContext::New(). * * @param[in] inputMethodContext A pointer to the InputMethodContext. */ - explicit DALI_INTERNAL InputMethodContext( Internal::Adaptor::InputMethodContext* inputMethodContext ); - + explicit DALI_INTERNAL InputMethodContext(Internal::Adaptor::InputMethodContext* inputMethodContext); }; - - } // namespace Dali #endif // DALI_INPUT_METHOD_CONTEXT_H