Add Preedit style - Highlight and Reverse 84/213784/5
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Wed, 11 Sep 2019 07:56:34 +0000 (16:56 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Thu, 24 Oct 2019 06:59:29 +0000 (15:59 +0900)
Change-Id: I57de1afe6d91e15ce617243abe2f6fe54cc838f2
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
dali/devel-api/adaptor-framework/input-method-context.cpp
dali/devel-api/adaptor-framework/input-method-context.h
dali/internal/input/common/input-method-context-impl.h
dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp
dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h
dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp
dali/internal/input/ubuntu-x11/input-method-context-impl-x.h
dali/internal/input/windows/input-method-context-impl-win.cpp
dali/internal/input/windows/input-method-context-impl-win.h

index 0b8e3f7..854134c 100755 (executable)
@@ -221,6 +221,11 @@ void InputMethodContext::SetInputPanelPosition( unsigned int x, unsigned int y )
   Internal::Adaptor::InputMethodContext::GetImplementation(*this).SetInputPanelPosition( x, y );
 }
 
+Dali::InputMethodContext::PreeditStyle InputMethodContext::GetPreeditStyle() const
+{
+  return Internal::Adaptor::InputMethodContext::GetImplementation(*this).GetPreeditStyle();
+}
+
 // Signals
 InputMethodContext::ActivatedSignalType& InputMethodContext::ActivatedSignal()
 {
index 85f754a..3eb5553 100755 (executable)
@@ -90,6 +90,9 @@ public:
     HARDWARE_KEYBOARD   ///< Hardware keyboard
   };
 
+  /**
+   * @brief Enumeration for the language mode of the input panel.
+   */
   enum class InputPanelLanguage
   {
     AUTOMATIC,    ///< IME Language automatically set depending on the system display
@@ -97,6 +100,17 @@ public:
   };
 
   /**
+   * @brief Enumeration for the preedit style types.
+   */
+  enum class PreeditStyle
+  {
+    NONE,         ///< None style
+    UNDERLINE,    ///< Underline substring style
+    REVERSE,      ///< Reverse substring style
+    HIGHLIGHT     ///< Highlight substring style
+  };
+
+  /**
    * @brief This structure is used to pass on data from the InputMethodContext regarding predictive text.
    */
   struct EventData
@@ -461,6 +475,13 @@ public:
    */
   void SetInputPanelPosition( unsigned int x, unsigned int y );
 
+  /**
+   * @brief Gets the preedit type.
+   *
+   * @return The preedit style type
+   */
+  PreeditStyle GetPreeditStyle() const;
+
 public:
 
   // Signals
index eabc764..e16cc44 100755 (executable)
@@ -273,6 +273,11 @@ public:
    */
   virtual void SetInputPanelPosition( unsigned int x, unsigned int y ) {}
 
+  /**
+   * @copydoc Dali::InputMethodContext::GetPreeditStyle()
+   */
+  virtual Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const { return Dali::InputMethodContext::PreeditStyle(); }
+
 public:  // Signals
 
   /**
index 663eb39..d1bba79 100755 (executable)
@@ -324,6 +324,7 @@ InputMethodContextEcoreWl::InputMethodContextEcoreWl( Dali::Actor actor )
   mSurroundingText(),
   mRestoreAfterFocusLost( false ),
   mIdleCallbackConnected( false ),
+  mPreeditType( Dali::InputMethodContext::PreeditStyle::NONE ),
   mWindowId( GetWindowIdFromActor( actor ) )
 {
   ecore_imf_init();
@@ -510,6 +511,34 @@ 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<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
     {
+      switch( attr->preedit_type )
+      {
+        case ECORE_IMF_PREEDIT_TYPE_NONE:
+        {
+          mPreeditType = Dali::InputMethodContext::PreeditStyle::NONE;
+          break;
+        }
+        case ECORE_IMF_PREEDIT_TYPE_SUB1:
+        {
+          mPreeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE;
+          break;
+        }
+        case ECORE_IMF_PREEDIT_TYPE_SUB2:
+        {
+          mPreeditType = Dali::InputMethodContext::PreeditStyle::REVERSE;
+          break;
+        }
+        case ECORE_IMF_PREEDIT_TYPE_SUB3:
+        {
+          mPreeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT;
+          break;
+        }
+        default:
+        {
+          break;
+        }
+      }
+
 #ifdef DALI_PROFILE_UBUNTU
       if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF)
 #else // DALI_PROFILE_UBUNTU
@@ -1079,6 +1108,12 @@ void InputMethodContextEcoreWl::SetInputPanelPosition( unsigned int x, unsigned
   }
 }
 
+Dali::InputMethodContext::PreeditStyle InputMethodContextEcoreWl::GetPreeditStyle() const
+{
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetPreeditStyle\n" );
+  return mPreeditType;
+}
+
 bool InputMethodContextEcoreWl::ProcessEventKeyDown( const KeyEvent& keyEvent )
 {
   bool eventHandled( false );
index 8e414d4..095e914 100755 (executable)
@@ -262,6 +262,11 @@ public:
    */
   void SetInputPanelPosition( unsigned int x, unsigned int y ) override;
 
+  /**
+   * @copydoc Dali::InputMethodContext::GetPreeditStyle()
+   */
+  Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override;
+
 private:
   /**
    * Context created the first time and kept until deleted.
@@ -340,6 +345,7 @@ private:
 
   std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
   InputMethodOptions mOptions;
+  Dali::InputMethodContext::PreeditStyle mPreeditType;
 
   int mWindowId;
 };
index adfbd2f..8517a05 100755 (executable)
@@ -149,7 +149,8 @@ InputMethodContextX::InputMethodContextX( Dali::Actor actor )
   mIMFCursorPosition( 0 ),
   mSurroundingText(),
   mRestoreAfterFocusLost( false ),
-  mIdleCallbackConnected( false )
+  mIdleCallbackConnected( false ),
+  mPreeditType( Dali::InputMethodContext::PreeditStyle::NONE )
 {
   ecore_imf_init();
 
@@ -322,6 +323,34 @@ 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<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
     {
+      switch( attr->preedit_type )
+      {
+        case ECORE_IMF_PREEDIT_TYPE_NONE:
+        {
+          mPreeditType = Dali::InputMethodContext::PreeditStyle::NONE;
+          break;
+        }
+        case ECORE_IMF_PREEDIT_TYPE_SUB1:
+        {
+          mPreeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE;
+          break;
+        }
+        case ECORE_IMF_PREEDIT_TYPE_SUB2:
+        {
+          mPreeditType = Dali::InputMethodContext::PreeditStyle::REVERSE;
+          break;
+        }
+        case ECORE_IMF_PREEDIT_TYPE_SUB3:
+        {
+          mPreeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT;
+          break;
+        }
+        default:
+        {
+          break;
+        }
+      }
+
 #ifdef DALI_PROFILE_UBUNTU
       if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF)
 #else // DALI_PROFILE_UBUNTU
@@ -791,6 +820,12 @@ 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
+{
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n" );
+  return mPreeditType;
+}
+
 bool InputMethodContextX::ProcessEventKeyDown( const KeyEvent& keyEvent )
 {
   bool eventHandled( false );
index 7edb8d8..f3222d8 100755 (executable)
@@ -268,6 +268,11 @@ public:
    */
   void SetInputPanelPosition( unsigned int x, unsigned int y ) override;
 
+  /**
+   * @copydoc Dali::InputMethodContext::GetPreeditStyle()
+   */
+  Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override;
+
 private:
   /**
    * Context created the first time and kept until deleted.
@@ -341,6 +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;
 };
 
 } // namespace Adaptor
index 5bd9b6f..4cd4b65 100755 (executable)
@@ -62,7 +62,8 @@ InputMethodContextWin::InputMethodContextWin( Dali::Actor actor )
   mIMFCursorPosition( 0 ),\r
   mSurroundingText(),\r
   mRestoreAfterFocusLost( false ),\r
-  mIdleCallbackConnected( false )\r
+  mIdleCallbackConnected( false ),\r
+  mPreeditType( Dali::InputMethodContext::PreeditStyle::NONE )\r
 {\r
 \r
   actor.OnStageSignal().Connect( this, &InputMethodContextWin::OnStaged );\r
@@ -364,6 +365,12 @@ void InputMethodContextWin::SetInputPanelPosition( unsigned int x, unsigned int
   DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelPosition\n" );\r
 }\r
 \r
+Dali::InputMethodContext::PreeditStyle InputMethodContextWin::GetPreeditStyle() const\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetPreeditStyle\n" );\r
+  return mPreeditType;\r
+}\r
+\r
 bool InputMethodContextWin::ProcessEventKeyDown( const KeyEvent& keyEvent )\r
 {\r
   bool eventHandled( false );\r
index 61847a0..fffc088 100755 (executable)
@@ -256,6 +256,11 @@ public:
    */\r
   void SetInputPanelPosition( unsigned int x, unsigned int y ) override;\r
 \r
+  /**\r
+   * @copydoc Dali::InputMethodContext::GetPreeditStyle()\r
+   */\r
+  Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override;\r
+\r
 private:\r
   /**\r
    * Context created the first time and kept until deleted.\r
@@ -314,6 +319,7 @@ private:
   bool mRestoreAfterFocusLost:1;             ///< Whether the keyboard needs to be restored (activated ) after focus regained.\r
   bool mIdleCallbackConnected:1;             ///< Whether the idle callback is already connected.\r
   InputMethodOptions        mOptions;\r
+  Dali::InputMethodContext::PreeditStyle mPreeditType;\r
 };\r
 \r
 } // namespace Adaptor\r