Add TextField BACKGROUND property and more Preedit style options 95/218695/10
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Wed, 27 Nov 2019 05:47:25 +0000 (14:47 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Wed, 22 Jan 2020 06:57:27 +0000 (15:57 +0900)
Change-Id: Ia4ce089bbee50bac45542268ef9ddaada8c9a657
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
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/devel-api/controls/text-controls/text-field-devel.h
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/visual-model-impl.cpp

index b756ed7..a76ccb9 100755 (executable)
@@ -289,6 +289,107 @@ int UtcDaliTextControllerImfEvent(void)
   END_TEST;
 }
 
+int UtcDaliTextControllerImfPreeditStyle(void)
+{
+  tet_infoline(" UtcDaliTextControllerImfPreeditStyle");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  std::string text;
+  InputMethodContext::EventData imfEvent;
+
+  DALI_TEST_CHECK( controller );
+
+  // Configures the text controller similarly to the text-field.
+  ConfigureTextField( controller );
+
+  InputMethodContext inputMethodContext = InputMethodContext::New();
+
+  // Send COMMIT event.
+  imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "Hello ", 0, 6 );
+  controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+
+  // Force to update the model.
+  controller->GetNaturalSize();
+
+  controller->GetText( text );
+  DALI_TEST_EQUALS( "Hello ", text, TEST_LOCATION );
+
+  // Send PRE_EDIT event
+  imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
+  controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+  inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::NONE );
+  controller->GetNaturalSize();
+
+  controller->GetText( text );
+  DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+
+  imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
+  controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+
+  // Set the preedit style as REVERSE
+  inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::REVERSE );
+  controller->GetNaturalSize();
+
+  controller->GetText( text );
+  DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+
+  imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
+  controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+
+  // Set the preedit style as HIGHLIGHT
+  inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::HIGHLIGHT );
+  controller->GetNaturalSize();
+
+  controller->GetText( text );
+  DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+
+  imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
+  controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+
+  // Set the preedit style as CUSTOM_PLATFORM_STYLE_1
+  inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_1 );
+  controller->GetNaturalSize();
+
+  controller->GetText( text );
+  DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+
+  imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
+  controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+
+  // Set the preedit style as CUSTOM_PLATFORM_STYLE_2
+  inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2 );
+  controller->GetNaturalSize();
+
+  controller->GetText( text );
+  DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+
+  imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
+  controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+
+  // Set the preedit style as CUSTOM_PLATFORM_STYLE_3
+  inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3 );
+  controller->GetNaturalSize();
+
+  controller->GetText( text );
+  DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+
+  imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "w", 6, 1 );
+  controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+
+  // Set the preedit style as CUSTOM_PLATFORM_STYLE_4
+  inputMethodContext.SetPreeditStyle( InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4 );
+  controller->GetNaturalSize();
+
+  controller->GetText( text );
+  DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+
+  tet_result(TET_PASS);
+  END_TEST;
+}
+
 int UtcDaliTextControllerTextPopupButtonTouched(void)
 {
   tet_infoline(" UtcDaliTextControllerTextPopupButtonTouched");
index f316e50..2446f29 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -60,7 +60,7 @@ public:
   void ApplyOptions( const InputMethodOptions& options );
   bool FilterEventKey( const Dali::KeyEvent& keyEvent );
   void SetPreeditStyle( Dali::InputMethodContext::PreeditStyle type );
-  Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const;
+  void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const;
 
 public:  // Signals
   ActivatedSignalType& ActivatedSignal() { return mActivatedSignal; }
@@ -87,7 +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;
+  Vector< Dali::InputMethodContext::PreeditAttributeData > mPreeditAttrs; ///< Stores preedit attr data
 
   ActivatedSignalType      mActivatedSignal;
   KeyboardEventSignalType  mEventSignal;
@@ -128,8 +128,7 @@ InputMethodContext::InputMethodContext( /*Ecore_X_Window ecoreXwin*/ )
 : mIMFCursorPosition( 0 ),
   mSurroundingText(),
   mRestoreAfterFocusLost( false ),
-  mIdleCallbackConnected( false ),
-  mPreeditStyle( Dali::InputMethodContext::PreeditStyle::NONE )
+  mIdleCallbackConnected( false )
 {
   CreateContext( /*ecoreXwin*/ );
   ConnectCallbacks();
@@ -219,12 +218,14 @@ bool InputMethodContext::FilterEventKey( const Dali::KeyEvent& keyEvent )
 
 void InputMethodContext::SetPreeditStyle( Dali::InputMethodContext::PreeditStyle type )
 {
-  mPreeditStyle = type;
+  Dali::InputMethodContext::PreeditAttributeData data;
+  data.preeditType = type;
+  mPreeditAttrs.PushBack( data );
 }
 
-Dali::InputMethodContext::PreeditStyle InputMethodContext::GetPreeditStyle() const
+void InputMethodContext::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const
 {
-  return mPreeditStyle;
+  attrs = mPreeditAttrs;
 }
 } // Adaptor
 
@@ -327,9 +328,9 @@ void InputMethodContext::SetPreeditStyle( Dali::InputMethodContext::PreeditStyle
   Internal::Adaptor::InputMethodContext::GetImplementation(*this).SetPreeditStyle( type );
 }
 
-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
index a56ea81..395ad4d 100755 (executable)
@@ -102,10 +102,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
   };
 
   /**
@@ -309,11 +323,11 @@ public:
   void SetPreeditStyle( PreeditStyle type );
 
   /**
-   * @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<PreeditAttributeData>& attrs ) const;
 
 public:
 
index 881fdde..7e050ff 100755 (executable)
@@ -102,6 +102,7 @@ const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION               = "enableSh
 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE                   = "enableGrabHandle";
 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION      = "matchSystemLanguageDirection";
 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP             = "enableGrabHandlePopup";
+const char* const PROPERTY_NAME_BACKGROUND                           = "textBackground";
 
 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
@@ -470,6 +471,7 @@ int UtcDaliTextFieldGetPropertyP(void)
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
+  DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
 
   END_TEST;
 }
@@ -929,6 +931,10 @@ int UtcDaliTextFieldSetPropertyP(void)
   field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
   DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
 
+  // Check the background property
+  field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
+  DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
+
   application.SendNotification();
   application.Render();
 
index 5e92a92..3a4864c 100755 (executable)
@@ -114,7 +114,15 @@ namespace Property
         * @details Name "enableGrabHandlePopup", type Property::BOOLEAN.
         * @note The default value is true, which means the grab handle popup is enabled by default.
         */
-      ENABLE_GRAB_HANDLE_POPUP = ELLIPSIS + 4
+      ENABLE_GRAB_HANDLE_POPUP = ELLIPSIS + 4,
+
+      /**
+       * @brief The default text background parameters.
+       * @details Name "textBackground", type Property::VECTOR4.
+       * @note Use "textBackground" as property name to avoid conflict with Control's "background" property.
+       * @note The default value is Color::TRANSPARENT.
+       */
+      BACKGROUND = ELLIPSIS + 5
 
   };
 } // namespace Property
index 6a1f1c9..e9d1fe4 100755 (executable)
@@ -134,6 +134,7 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableShiftSelection",
 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandle",               BOOLEAN,   ENABLE_GRAB_HANDLE                   )
 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "matchSystemLanguageDirection",   BOOLEAN,   MATCH_SYSTEM_LANGUAGE_DIRECTION      )
 DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandlePopup",          BOOLEAN,   ENABLE_GRAB_HANDLE_POPUP             )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "textBackground",                 VECTOR4,   BACKGROUND                           )
 
 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged",        SIGNAL_TEXT_CHANGED )
 DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached",   SIGNAL_MAX_LENGTH_REACHED )
@@ -767,7 +768,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       }
       case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
       {
-        if (impl.mController)
+        if( impl.mController )
         {
           const bool grabHandlePopupEnabled = value.Get<bool>();
           DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE_POPUP %d\n", impl.mController.Get(), grabHandlePopupEnabled);
@@ -776,6 +777,18 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
           break;
         }
       }
+      case Toolkit::DevelTextField::Property::BACKGROUND:
+      {
+        if( impl.mController )
+        {
+          const Vector4 backgroundColor = value.Get< Vector4 >();
+          DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p BACKGROUND %f,%f,%f,%f\n", impl.mController.Get(), backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a );
+
+          impl.mController->SetBackgroundEnabled( true );
+          impl.mController->SetBackgroundColor( backgroundColor );
+        }
+        break;
+      }
     } // switch
   } // textfield
 }
@@ -1185,12 +1198,20 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde
       }
       case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP:
       {
-        if (impl.mController)
+        if( impl.mController )
         {
           value = impl.mController->IsGrabHandlePopupEnabled();
         }
         break;
       }
+      case Toolkit::DevelTextField::Property::BACKGROUND:
+      {
+        if( impl.mController )
+        {
+          value = impl.mController->GetBackgroundColor();
+        }
+        break;
+      }
     } //switch
   }
 
index fa48e52..c39d5e8 100755 (executable)
@@ -98,6 +98,12 @@ struct BackgroundMesh
   Vector< unsigned short > mIndices;       ///< container of indices
 };
 
+const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f );
+const Dali::Vector4 BACKGROUND_SUB4( 0.58f, 0.87f, 0.96f, 1.f );
+const Dali::Vector4 BACKGROUND_SUB5( 0.83f, 0.94f, 0.98f, 1.f );
+const Dali::Vector4 BACKGROUND_SUB6( 1.f, 0.5f, 0.5f, 1.f );
+const Dali::Vector4 BACKGROUND_SUB7( 1.f, 0.8f, 0.8f, 1.f );
+
 } // namespace
 
 namespace Dali
@@ -1080,35 +1086,130 @@ bool Controller::Impl::UpdateModel( OperationsMask operationsRequired )
       mEventData->mPreEditFlag &&
       ( 0u != mModel->mVisualModel->mCharactersToGlyph.Count() ) )
   {
-    Dali::InputMethodContext::PreeditStyle type = mEventData->mInputMethodContext.GetPreeditStyle();
+    Vector< Dali::InputMethodContext::PreeditAttributeData > attrs;
+    mEventData->mInputMethodContext.GetPreeditStyle( attrs );
+    Dali::InputMethodContext::PreeditStyle type = Dali::InputMethodContext::PreeditStyle::NONE;
 
-    switch( type )
+    // Check the type of preedit and run it.
+    for( Vector<Dali::InputMethodContext::PreeditAttributeData>::Iterator it = attrs.Begin(), endIt = attrs.End(); it != endIt; it++ )
     {
-      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();
+      Dali::InputMethodContext::PreeditAttributeData attrData = *it;
+      DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::UpdateModel PreeditStyle type : %d  start %d end %d \n", attrData.preeditType, attrData.startIndex, attrData.endIndex  );
+      type =  attrData.preeditType;
 
-        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 );
+      // Check the number of commit characters for the start position.
+      unsigned int numberOfCommit = mEventData->mPrimaryCursorPosition - mEventData->mPreEditLength;
+      Length numberOfIndices = attrData.endIndex - attrData.startIndex;
 
-        GlyphRun underlineRun;
-        underlineRun.glyphIndex = glyphStart;
-        underlineRun.numberOfGlyphs = 1u + glyphEnd - glyphStart;
-
-        mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
-        break;
+      switch( type )
+      {
+        case Dali::InputMethodContext::PreeditStyle::UNDERLINE:
+        {
+          // Add the underline for the pre-edit text.
+          GlyphRun underlineRun;
+          underlineRun.glyphIndex = attrData.startIndex + numberOfCommit;
+          underlineRun.numberOfGlyphs = attrData.endIndex - attrData.startIndex;
+          mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
+          break;
+        }
+        case Dali::InputMethodContext::PreeditStyle::REVERSE:
+        {
+          Vector4 textColor = mModel->mVisualModel->GetTextColor();
+          ColorRun backgroundColorRun;
+          backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit;
+          backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices;
+          backgroundColorRun.color = textColor;
+          mModel->mLogicalModel->mBackgroundColorRuns.PushBack( backgroundColorRun );
+
+          Vector4 backgroundColor = mModel->mVisualModel->GetBackgroundColor();
+          Vector<ColorRun>  colorRuns;
+          colorRuns.Resize( 1u );
+          ColorRun& colorRun = *( colorRuns.Begin() );
+          colorRun.color = backgroundColor;
+          colorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit;
+          colorRun.characterRun.numberOfCharacters = numberOfIndices;
+
+          mModel->mLogicalModel->mColorRuns.PushBack( colorRun );
+          break;
+        }
+        case Dali::InputMethodContext::PreeditStyle::HIGHLIGHT:
+        {
+          ColorRun backgroundColorRun;
+          backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit;
+          backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices;
+          backgroundColorRun.color = LIGHT_BLUE;
+          mModel->mLogicalModel->mBackgroundColorRuns.PushBack( backgroundColorRun );
+          break;
+        }
+        case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_1:
+        {
+          // CUSTOM_PLATFORM_STYLE_1 should be drawn with background and underline together.
+          ColorRun backgroundColorRun;
+          backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit;
+          backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices;
+          backgroundColorRun.color = BACKGROUND_SUB4;
+          mModel->mLogicalModel->mBackgroundColorRuns.PushBack( backgroundColorRun );
+
+          GlyphRun underlineRun;
+          underlineRun.glyphIndex = attrData.startIndex + numberOfCommit;
+          underlineRun.numberOfGlyphs = attrData.endIndex - attrData.startIndex;
+          mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
+          break;
+        }
+        case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2:
+        {
+          // CUSTOM_PLATFORM_STYLE_2 should be drawn with background and underline together.
+          ColorRun backgroundColorRun;
+          backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit;
+          backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices;
+          backgroundColorRun.color = BACKGROUND_SUB5;
+          mModel->mLogicalModel->mBackgroundColorRuns.PushBack( backgroundColorRun );
+
+          GlyphRun underlineRun;
+          underlineRun.glyphIndex = attrData.startIndex + numberOfCommit;
+          underlineRun.numberOfGlyphs = attrData.endIndex - attrData.startIndex;
+          mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
+          break;
+        }
+        case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3:
+        {
+          // CUSTOM_PLATFORM_STYLE_3 should be drawn with background and underline together.
+          ColorRun backgroundColorRun;
+          backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit;
+          backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices;
+          backgroundColorRun.color = BACKGROUND_SUB6;
+          mModel->mLogicalModel->mBackgroundColorRuns.PushBack( backgroundColorRun );
+
+          GlyphRun underlineRun;
+          underlineRun.glyphIndex = attrData.startIndex + numberOfCommit;
+          underlineRun.numberOfGlyphs = attrData.endIndex - attrData.startIndex;
+          mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
+          break;
+        }
+        case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4:
+        {
+          // CUSTOM_PLATFORM_STYLE_4 should be drawn with background and underline together.
+          ColorRun backgroundColorRun;
+          backgroundColorRun.characterRun.characterIndex = attrData.startIndex + numberOfCommit;
+          backgroundColorRun.characterRun.numberOfCharacters = numberOfIndices;
+          backgroundColorRun.color = BACKGROUND_SUB7;
+          mModel->mLogicalModel->mBackgroundColorRuns.PushBack( backgroundColorRun );
+
+          GlyphRun underlineRun;
+          underlineRun.glyphIndex = attrData.startIndex + numberOfCommit;
+          underlineRun.numberOfGlyphs = attrData.endIndex - attrData.startIndex;
+          mModel->mVisualModel->mUnderlineRuns.PushBack( underlineRun );
+          break;
+        }
+        case Dali::InputMethodContext::PreeditStyle::NONE:
+        default:
+        {
+          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;
     }
+    attrs.Clear();
+    updated = true;
   }
 
   if( NO_OPERATION != ( COLOR & operations ) )
@@ -3165,6 +3266,7 @@ Actor Controller::Impl::CreateBackgroundActor()
 
     const Vector4* const backgroundColorsBuffer = mView.GetBackgroundColors();
     const ColorIndex* const backgroundColorIndicesBuffer = mView.GetBackgroundColorIndices();
+    const Vector4& defaultBackgroundColor = mModel->mVisualModel->IsBackgroundEnabled() ? mModel->mVisualModel->GetBackgroundColor() : Color::TRANSPARENT;
 
     Vector4 quad;
     uint32_t numberOfQuads = 0u;
@@ -3176,7 +3278,7 @@ Actor Controller::Impl::CreateBackgroundActor()
       // Get the background color of the character.
       // The color index zero is reserved for the default background color (i.e. Color::TRANSPARENT)
       const ColorIndex backgroundColorIndex = ( nullptr == backgroundColorsBuffer ) ? 0u : *( backgroundColorIndicesBuffer + i );
-      const Vector4& backgroundColor = ( 0u == backgroundColorIndex ) ? Color::TRANSPARENT : *( backgroundColorsBuffer + backgroundColorIndex - 1u );
+      const Vector4& backgroundColor = ( 0u == backgroundColorIndex ) ? defaultBackgroundColor : *( backgroundColorsBuffer + backgroundColorIndex - 1u );
 
       // Only create quads for glyphs with a background color
       if ( backgroundColor != Color::TRANSPARENT )
index 0b0e9cf..0407147 100755 (executable)
@@ -3714,11 +3714,7 @@ bool Controller::RemoveText( int cursorOffset,
       // it means all texts should be removed and all Preedit variables should be initialized.
       if( ( currentText.Count() - numberOfCharacters == 0 ) && ( cursorIndex == 0 ) )
       {
-        if( mImpl->mEventData )
-        {
-          mImpl->mEventData->mPreEditStartPosition = 0;
-          mImpl->mEventData->mPreEditLength = 0;
-        }
+        mImpl->ClearPreEditFlag();
       }
 
       // Updates the text style runs by removing characters. Runs with no characters are removed.
index 3b1f5b7..6a06e58 100755 (executable)
@@ -469,7 +469,7 @@ VisualModel::VisualModel()
   mShadowColor( Color::BLACK ),
   mUnderlineColor( Color::BLACK ),
   mOutlineColor( Color::WHITE ),
-  mBackgroundColor( Color::CYAN ),
+  mBackgroundColor( Color::TRANSPARENT ),
   mControlSize(),
   mShadowOffset(),
   mUnderlineHeight( 0.0f ),