Add Text Preedit Style 08/216108/6
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Mon, 21 Oct 2019 06:05:08 +0000 (15:05 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Thu, 24 Oct 2019 06:25:38 +0000 (15:25 +0900)
- Currently, only Underline is supported for Preedit style.
  But, Highlight and Reverse style should be added later.
- Added PreeditStyle::NONE as default preedit style.

Change-Id: I7fe9e3258eba425e8ad408c6c6222d96f54e162d
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-input-method-context.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-input-method-context.h
dali-toolkit/internal/text/text-controller-impl.cpp

index e581626..e1787c9 100755 (executable)
@@ -258,6 +258,9 @@ int UtcDaliTextControllerImfEvent(void)
   controller->GetText( text );
   DALI_TEST_EQUALS( "Hello ", text, TEST_LOCATION );
 
+  // for coverage
+  inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::UNDERLINE );
+
   // Send PRE_EDIT event
   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "wo", 6, 2 );
   controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
index 74a2bd5..f316e50 100755 (executable)
@@ -59,6 +59,8 @@ public:
   const std::string& GetSurroundingText() const;
   void ApplyOptions( const InputMethodOptions& options );
   bool FilterEventKey( const Dali::KeyEvent& keyEvent );
+  void SetPreeditStyle( Dali::InputMethodContext::PreeditStyle type );
+  Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const;
 
 public:  // Signals
   ActivatedSignalType& ActivatedSignal() { return mActivatedSignal; }
@@ -85,6 +87,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 mPreeditStyle;
 
   ActivatedSignalType      mActivatedSignal;
   KeyboardEventSignalType  mEventSignal;
@@ -125,7 +128,8 @@ InputMethodContext::InputMethodContext( /*Ecore_X_Window ecoreXwin*/ )
 : mIMFCursorPosition( 0 ),
   mSurroundingText(),
   mRestoreAfterFocusLost( false ),
-  mIdleCallbackConnected( false )
+  mIdleCallbackConnected( false ),
+  mPreeditStyle( Dali::InputMethodContext::PreeditStyle::NONE )
 {
   CreateContext( /*ecoreXwin*/ );
   ConnectCallbacks();
@@ -212,6 +216,16 @@ bool InputMethodContext::FilterEventKey( const Dali::KeyEvent& keyEvent )
 {
   return false;
 }
+
+void InputMethodContext::SetPreeditStyle( Dali::InputMethodContext::PreeditStyle type )
+{
+  mPreeditStyle = type;
+}
+
+Dali::InputMethodContext::PreeditStyle InputMethodContext::GetPreeditStyle() const
+{
+  return mPreeditStyle;
+}
 } // Adaptor
 
 } // Internal
@@ -308,6 +322,17 @@ bool InputMethodContext::FilterEventKey( const Dali::KeyEvent& keyEvent )
   return Internal::Adaptor::InputMethodContext::GetImplementation(*this).FilterEventKey( keyEvent );
 }
 
+void InputMethodContext::SetPreeditStyle( Dali::InputMethodContext::PreeditStyle type )
+{
+  Internal::Adaptor::InputMethodContext::GetImplementation(*this).SetPreeditStyle( type );
+}
+
+Dali::InputMethodContext::PreeditStyle InputMethodContext::GetPreeditStyle() const
+{
+  return Internal::Adaptor::InputMethodContext::GetImplementation(*this).GetPreeditStyle();
+}
+
+// Signals
 InputMethodContext::ActivatedSignalType& InputMethodContext::ActivatedSignal()
 {
   return Internal::Adaptor::InputMethodContext::GetImplementation(*this).ActivatedSignal();
index cf174cf..a56ea81 100755 (executable)
@@ -47,7 +47,16 @@ class InputMethodContext : public BaseHandle
 public:
 
   /**
-   * @brief Events that are generated by the input method context.
+  * @brief The direction of text.
+  */
+  enum TextDirection
+  {
+    LeftToRight,
+    RightToLeft,
+  };
+
+  /**
+   * @brief Events that are generated by the InputMethodContext.
    */
   enum EventType
   {
@@ -60,7 +69,47 @@ public:
   };
 
   /**
-   * @brief This structure is used to pass on data from the input method cotext regarding predictive text.
+   * @brief Enumeration for state of the input panel.
+   */
+  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
+  };
+
+  /**
+   * @brief Enumeration for the type of Keyboard.
+   */
+  enum KeyboardType
+  {
+    SOFTWARE_KEYBOARD,  ///< Software keyboard (Virtual keyboard) is default
+    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
+    ALPHABET      ///< Latin alphabet at all times
+  };
+
+  /**
+   * @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
   {
@@ -252,6 +301,20 @@ public:
    */
   bool FilterEventKey( const Dali::KeyEvent& keyEvent );
 
+  /**
+   * @brief Sets the preedit type.
+   *
+   * @param[in] type The preedit style type
+   */
+  void SetPreeditStyle( PreeditStyle type );
+
+  /**
+   * @brief Gets the preedit type.
+   *
+   * @return The preedit style type
+   */
+  PreeditStyle GetPreeditStyle() const;
+
 public:
 
   // Signals
index 2686153..2c9a78d 100755 (executable)
@@ -1072,21 +1072,35 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
       mEventData->mPreEditFlag &&
       ( 0u != mModel->mVisualModel->mCharactersToGlyph.Count() ) )
   {
-    // Add the underline for the pre-edit text.
-    const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin();
-    const Length* const glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin();
+    Dali::InputMethodContext::PreeditStyle type = mEventData->mInputMethodContext.GetPreeditStyle();
 
-    const GlyphIndex glyphStart = *( charactersToGlyphBuffer + mEventData->mPreEditStartPosition );
-    const CharacterIndex lastPreEditCharacter = mEventData->mPreEditStartPosition + ( ( mEventData->mPreEditLength > 0u ) ? mEventData->mPreEditLength - 1u : 0u );
-    const Length numberOfGlyphsLastCharacter = *( glyphsPerCharacterBuffer + lastPreEditCharacter );
-    const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + lastPreEditCharacter ) + ( numberOfGlyphsLastCharacter > 1u ? numberOfGlyphsLastCharacter - 1u : 0u );
+    switch( type )
+    {
+      case Dali::InputMethodContext::PreeditStyle::UNDERLINE:
+      {
+        // Add the underline for the pre-edit text.
+        const GlyphIndex* const charactersToGlyphBuffer = mModel->mVisualModel->mCharactersToGlyph.Begin();
+        const Length* const glyphsPerCharacterBuffer = mModel->mVisualModel->mGlyphsPerCharacter.Begin();
 
-    GlyphRun underlineRun;
-    underlineRun.glyphIndex = glyphStart;
-    underlineRun.numberOfGlyphs = 1u + glyphEnd - glyphStart;
+        const GlyphIndex glyphStart = *( charactersToGlyphBuffer + mEventData->mPreEditStartPosition );
+        const CharacterIndex lastPreEditCharacter = mEventData->mPreEditStartPosition + ( ( mEventData->mPreEditLength > 0u ) ? mEventData->mPreEditLength - 1u : 0u );
+        const Length numberOfGlyphsLastCharacter = *( glyphsPerCharacterBuffer + lastPreEditCharacter );
+        const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + lastPreEditCharacter ) + ( numberOfGlyphsLastCharacter > 1u ? numberOfGlyphsLastCharacter - 1u : 0u );
 
-    // TODO: At the moment the underline runs are only for pre-edit.
-    mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
+        GlyphRun underlineRun;
+        underlineRun.glyphIndex = glyphStart;
+        underlineRun.numberOfGlyphs = 1u + glyphEnd - glyphStart;
+
+        mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
+        break;
+      }
+      // TODO :  At this moment, other styles for preedit are not implemented yet.
+      case Dali::InputMethodContext::PreeditStyle::REVERSE:
+      case Dali::InputMethodContext::PreeditStyle::HIGHLIGHT:
+      case Dali::InputMethodContext::PreeditStyle::NONE:
+      default:
+        break;
+    }
   }
 
   // The estimated number of lines. Used to avoid reallocations when layouting.